@@ -24,7 +24,7 @@ Features:
2424- Support for 'pure render' optimization.
2525- Reference implementation of 'linked' UI controls (` tags.jsx ` ).
2626 - Standard tags: ` <Input /> ` and ` <TextArea /> ` (with validation), ` <Select /> ` ,
27- - Custom tags: ` <Radio /> ` , ` <Checkbox /> `
27+ - Custom tags: ` <Radio /> ` , ` <Checkbox /> ` , ` <NumberInput /> `
2828- TypeScript source and type definitions.
2929- Backward compatible with standard React 0.14 links API
3030
@@ -50,6 +50,7 @@ Features:
5050 - ` link.clone() ` creates shallow copy of the enclosed object.
5151- Added "Users List" application example.
5252- ` link.toggle ` is _ removed_ . Use ` link.update( x => !x ) ` instead.
53+ - ` <NumberInput/> ` tag with input rejection for numbers.
5354
5455# Installation
5556
@@ -323,14 +324,120 @@ const numLink = List.state( this, 'num' )
323324console .log ( numLink .error );
324325```
325326
326- # Data binding examples
327+ ## Data binding examples
327328
328329Here are the set of [ working] ( https://volicon.github.io/valuelink/databinding.html ) [ examples] ( /databinding.html ) for typical data binding use cases.
329330
330331Also, there's [ working] ( https://volicon.github.io/valuelink ) [ example] ( /example/userslist.jsx ) of an application managing the users list.
331332
332333[ Custom elements boilerplate] ( /tags.jsx ) which is used by both examples is another good example.
333334
335+ ### Text and number form fields
336+
337+ ##### <Input type =" text " />, <TextArea />
338+
339+ ` tags.jsx ` contains wrappers for standard ` <input> ` and ` <textarea> ` tags,
340+ which can be directly bound to the string state elements.
341+
342+ These wrappers will add ` invalid ` class to enclosed HTML element, if an error is present in the bound link.
343+
344+ ``` jsx
345+ < Input type= " text" valueLink= { link } / >
346+ < TextArea valueLink= { link } / >
347+ ```
348+
349+ ##### <NumberInput />
350+
351+ There's also cross-browser implementation of * numeric input* tag. It has following differences compared to ` <Input> ` :
352+
353+ - Keyboard input which obviously leads to invalid values (e.g. letters) are rejected.
354+ - Value is being always converted to valid number.
355+ - There are ` integer ` and ` positive ` boolean props controlling input rejection. They can be combined.
356+
357+ ` <NumberInput> ` validates its value, and adds ` invalid ` class to enclosed input element if it's not a number.
358+
359+ ``` jsx
360+ < NumberInput valueLink= { link } / >
361+ < NumberInput valueLink= { link } integer= { true }/ >
362+ < NumberInput valueLink= { link } positive= { true }/ >
363+ ```
364+
365+ ### Checkboxes
366+
367+ ##### <Input type =" checkbox " >
368+
369+ Wrapper for the standard ` <input> ` . Directly binds boolean value with ` checkedLink ` property.
370+
371+ ``` jsx
372+ < Input type= " text" checkedLink= { booleanLink } / >
373+ < Input type= " text" checkedLink= { arrayLink .contains ( ' option' ) } / >
374+ ```
375+
376+ ##### <Checkbox >
377+
378+ Internally, it's ` <div> ` element which toggles ` selected ` class on click.
379+ Thus, it can be easily styled.
380+
381+ By default, it has ` checkbox ` CSS class, which can be overridden by passing ` className ` prop.
382+
383+ It passes through anything else, including ` children ` .
384+
385+ ``` jsx
386+ < Checkbox checkedLink= { booleanLink } / >
387+ < Checkbox checkedLink= { arrayLink .contains ( ' option' ) } / >
388+ ```
389+
390+ ### Radio Groups and Select list
391+
392+ ##### <Select >
393+
394+ Wrapper for standard <select />. Regular <option /> tags must be used. All props are passed through.
395+
396+ ``` jsx
397+ < Select valueLink= { linkToSelectedValue }>
398+ < option value= " a" > A < / option>
399+ < option value= " b" > B < / option>
400+ < / Select>
401+ ```
402+
403+ ##### <Input type =" radio " >
404+
405+ Wrapper for the standard ` <input> ` . Directly binds boolean value with ` checkedLink ` property.
406+
407+ Can be directly bound to the state member using ` valueLink ` property.
408+
409+ ``` jsx
410+ < label>
411+ A :
412+ < Input type= " radio" valueLink= { flagLink } value= " a" / >
413+ < / label>
414+ < label>
415+ B :
416+ < Input type= " radio" valueLink= { flagLink } value= " b" / >
417+ < / label>
418+ ```
419+
420+ ##### <Radio >
421+
422+ Internally, it's ` <div> ` element which always sets ` selected ` class on click. Thus,
423+ it can be easily styled.
424+
425+ By default, it has ` radio ` CSS class, which can be overridden by passing ` className ` prop.
426+ It passes through anything else, including ` children ` .
427+
428+ It * must* be used in conjunction with ` link.equals( 'value' ) ` method.
429+
430+ ``` jsx
431+ < label>
432+ A :
433+ < Radio checkedLink= { flagLink .equals ( ' a' ) } / >
434+ < / label>
435+ < label>
436+ B :
437+ < Radio checkedLink= { flagLink .equals ( ' b' ) } / >
438+ < / label>
439+ ```
440+
334441[ method ] : /images/method.png
335442[ static ] : /images/static.png
336443[ var ] : /images/var.png
0 commit comments