1.0.5 • Published 7 years ago

amvm-ui v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

amvm-ui

Installation

npm install amvm-ui --save

Components

Input

PropRequiredDescription
metanoForm model meta object.
typenoType of input element. Allowed types: text, password, textarea, radio, checkbox. If not set, default is text.
refFnnoRef callback function. This function will be assign to ref prop on <input/> element.

This component renders just <input> with passed props. If className is not set, default value form-control is assigned to className (except when type is radio or checkbox). Passed props will overwrite attributes that are set using meta object.

FormGroupInput

PropRequiredDescription
metanoForm model meta object.
labelTextnoText for <label> tag. First, meta's title property is used to set <label> text, then this props can overwrite it.
typenoType of input element. Allowed types: text, password, textarea, radio, checkbox. This prop is passed into <Input> component.
parentStylenoCss rules that will be applied to container div element.
refFnnoRef callback function. This function will be assign to ref prop on <input/> element.

If meta has errors array with length > 0, then we add has-error css class to specific html tag.

If type is text, output is:

<div className='form-group {has-error}' style={parentStyle}>
    <label for="id" className='control-label'>Label text</label>
    <Input {...targetProps} type={type} />
    <FormGroupError error={meta ? meta.errors : null} />
</div>

If type is radio or checkbox, output is:

<div className='radio|checkbox {has-error}' style={parentStyle}>
    <label className='control-label'>
        <Input {...targetProps} type={type} /> {labelText}
        <FormGroupError error={meta ? meta.errors : null} />
    </label>
</div>

FormGroup

PropRequiredDescription
successnoif set to true, has-success css class will be added
warningnoif set to true, has-warning css class will be added
errornoif set to true, has-error css class will be added

This component renders <div className='form-group has-success|has-warning|has-error />. Value set to className prop will be added to list of css classes.

Dropdown

PropRequiredDescription
metanoForm model meta object.
sourcenoArray of object. This is array will be used to create <option> tags if children props is null.
valueFieldnoName of object property that will be used for value attribute when building <option> tag using source prop.
textFieldnoName of object property that will be used as a content when building <option> tag using source prop.
optionsLabelnoIf set, it will be first <option> with value of set-null and key of -99999 when building <option> tag using source prop
refFnnoRef callback function. This function will be assign to ref prop on <input/> element.

This is the order on how dropdown will build <option> tags:

  1. If there are children for <Dropdown> component, they will be used as dropdown options.

  2. If meta has dropdownValues property, then this property will be looped and for each array item <option> will be created. Each array item should be object of type { value: 'xx', text: 'yy' }

  3. If dropdown has source, valueField, textField, then these props will be used to create <option> tags.

FormGroupDropdown

PropRequiredDescription
metanoForm model meta object.
sourcenoArray of object. This is array will be used to create <option> tags if children props is null.
valueFieldnoName of object property that will be used for value attribute when building <option> tag using source prop.
textFieldnoName of object property that will be used as a content when building <option> tag using source prop.
optionsLabelnoIf set, it will be first <option> with value of set-null and key of -99999 when building <option> tag using source prop
labelTextnoText for <label> tag. First, meta's title property is used to set <label> text, then this props can overwrite it.
parentStylenoCss rules that will be applied to container div element.
refFnnoRef callback function. This function will be assign to ref prop on <input/> element.

Component creates <div className='form-control {has-error}' /> and passes all props to <Dropdown /> child component.

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago