8.2.3 • Published 2 years ago

@orcden/od-forms v8.2.3

Weekly downloads
192
License
MIT
Repository
bitbucket
Last release
2 years ago

OD Forms

A series of components to make building html forms fast and easy. NEW in 8.2.0: Dynamic labels!

<od-form> is a smart component to wrap other OD Form elements. It offers a series of benefits over semantic html forms while maintaining the ability to interact as one would normally with an html form. Supports semantic html attributes.

<od-form-array> is a smart component to wrap other OD Form elements. It creates a series of od-form elements based on a template to return an array of data. It also allows for simple creation and deletion of entries.

<od-form-input> is a simple component to create an input element. Like other Form Elements it comes with a series of styling and functional benefits including built in labels and semantic html attributes.

<od-form-textarea> is a simple component to create a textarea element. Like other Form Elements it comes with a series of styling and functional benefits including built in labels and semantic html attributes.

<od-form-selectlist> is a simple component to create a select element. Like other Form Elements it comes with a series of styling and functional benefits including built in labels and semantic html attributes. Supports both dynamic options and statically defined options.

<od-form-multiselect> is a simple component to create a series of checkbox elements. Like other Form Elements it comes with a series of styling and functional benefits including built in labels and semantic html attributes. Supports both dynamic options and statically defined options.

<od-form-radioselect> is a simple component to create a series of radio elements. Like other Form Elements it comes with a series of styling and functional benefits including built in labels and semantic html attributes. Supports both dynamic options and statically defined options.

<od-form-richtext> is a simple component to create custom richtext field. Like other Form Elements it comes with a series of styling and functional benefits including built in labels and semantic html attributes.

Installation

  • Install with npm
npm i @orcden/od-forms

Usage

Please note that your usage may differ depending on your framework

import { OdForm, OdFormInput } from '@orcden/od-forms';
<od-form id='od-form1'>                 //unique id required
    <od-form-input  name='first-name'   //required
                    autocomplete='given-name'>First Name: </od-form-input>
    
    <od-form-textarea   name='textarea'>Textarea: </od-form-textarea>

    <od-form-selectlist name='select1'
                        options-get='http://myapiroute.com/api/options' //returns [{ optionName: 'option 1', id: '0' },...]
                        options-label='optionName'
                        options-value='id'>
        <label slot='label'>Select1:</label>
        <option value=''>-</option> //statically defined option
    </od-form-selectlist>

    <od-form-multiselect    name='multi'
                            options-get='http://myapiroute.com/api/options'
                            options-label='optionName'
                            options-value='id'>
        <label slot='label'>Multi:</label>
        <od-form-input  value='1st'>1st: </od-form-input> //statically defined option
    </od-form-multiselect>
                
    <od-form-radioselect    name='radio'
                            options-get='http://myapiroute.com/api/options'
                            options-label='optionName'
                            options-value='id'>
        <label slot='label'>Radio:</label>
        <od-form-input  value='1st'>1st: </od-form-input>
    </od-form-radioselect>
</od-form>
<od-form-array id='od-form-array1'>                 //unique id required
    <od-form-input  name='first-name'               //required
                    autocomplete='given-name'>First Name: </od-form-input>
    
    <od-form-textarea   name='textarea'>Textarea: </od-form-textarea>
                
    <od-form-radioselect    name='radio'
                            options-get='http://myapiroute.com/api/options'
                            options-label='optionName'
                            options-value='id'>
        <label slot='label'>Radio:</label>
        <od-form-input  value='1st'>1st: </od-form-input>
    </od-form-radioselect>
</od-form-array>

//  **Also supports any other OD Form Element**

Attributes

OD Form

AttributeTypeDefaultDescription
disabledBooleanfalseToggles the hiding of the input fields and the display of the value fields.
inlineBooleanfalseTells the form to display all of its elements in a single line. Overrides child element inline attributes

** Also supports any semantic html form attribute

OD Form Array

AttributeTypeDefaultDescription
disabledBooleanfalseToggles the hiding of the input fields and the display of the value fields.
inlineBooleanfalseTells all child forms to display all of its elements in a single line. Overrides child element inline attributes

OD Form Input

AttributeTypeDefaultDescription
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedTwo-way binding support to set/get the html input value property
checkedBooleanfalseTwo-way binding support to set/get the html input checked property

** Also supports any semantic html input attribute

OD Form Textarea

AttributeTypeDefaultDescription
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedTwo-way binding support to set/get the html input value property

** Also supports any semantic html input attribute

OD Form Selectlist

AttributeTypeDefaultDescription
inlineBooleanfalseTells the element to align its input field inline with its label field
options-getStringnullFor dynamic options calls. This is the url of your option route
options-labelStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's label field ex. 'optionName'
options-valueStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's value field ex. 'id'

** Also supports any semantic html input attribute

OD Form Multiselect

AttributeTypeDefaultDescription
inlineBooleanfalseTells the element to align its input field inline with its label field
options-getStringnullFor dynamic options calls. This is the url of your option route
options-labelStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's label field ex. 'optionName'
options-valueStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's value field ex. 'id'

** Also supports any semantic html input attribute

OD Form Radioselect

AttributeTypeDefaultDescription
inlineBooleanfalseTells the element to align its input field inline with its label field
options-getStringnullFor dynamic options calls. This is the url of your option route
options-labelStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's label field ex. 'optionName'
options-valueStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's value field ex. 'id'

** Also supports any semantic html input attribute

OD Form Richtext

AttributeTypeDefaultDescription
disabledBooleanfalseHides the input field and
inlineBooleanfalseTells the element to align its input field inline with its label field
requiredBooleanfalseLets the form know that the field needs a value before continuing

Properties

OD Form

PropertyTypeDefaultDescription
formHTMLFormElementHTMLFormElementGet only. Returns the created html form. Can be used for any semantic html form hooks
disabledBooleanfalseToggles the hiding of the input fields and the display of the value fields.
inlineBooleanfalseTells the form to display all of its elements in a single line. Overrides child element inline attributes

OD Form Array

PropertyTypeDefaultDescription
formsArrayArrayGet only. Returns an array of the created html forms. Can be used for any semantic html form hooks
disabledBooleanfalseToggles the hiding of the input fields and the display of the value fields.
inlineBooleanfalseTells the form to display all of its elements in a single line. Overrides child element inline attributes

OD Form Input

PropertyTypeDefaultDescription
inputHTMLInputElementHTMLInputElementGet only. Returns the created html input. Can be used for any semantic html form hooks.
labelTextStringString ''Returns the text of the created html label. Can be used to set label text
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedget/set the html input value property
checkedBooleanfalseget/set the html input checked property

OD Form Textarea

PropertyTypeDefaultDescription
inputHTMLInputElementHTMLInputElementGet only. Returns the created html input. Can be used for any semantic html form hooks.
labelTextStringString ''Returns the text of the created html label. Can be used to set label text
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedget/set the html input value property

OD Form Selectlist

PropertyTypeDefaultDescription
inputHTMLInputElementHTMLInputElementGet only. Returns the created html input. Can be used for any semantic html form hooks.
labelTextStringString ''Returns the text of the created html label. Can be used to set label text
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedget/set the current selected value
optionsGetStringnullFor dynamic options calls. This is the url of your option route
optionsLabelStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's label field ex. 'optionName'
optionsValueStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's value field ex. 'id'

OD Form Multiselect

PropertyTypeDefaultDescription
inputsArrayArrayGet only. Returns an array of the nested inputs. Can be used for any semantic html form hooks.
labelTextStringString ''Returns the text of the created html label. Can be used to set label text
inlineBooleanfalseTells the element to align its input field inline with its label field
valueString/Arrayundefinedget/set the current selected values
optionsGetStringnullFor dynamic options calls. This is the url of your option route
optionsLabelStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's label field ex. 'optionName'
optionsValueStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's value field ex. 'id'

OD Form Radioselect

PropertyTypeDefaultDescription
inputsArrayArrayGet only. Returns an array of the nested inputs. Can be used for any semantic html form hooks.
labelTextStringString ''Returns the text of the created html label. Can be used to set label text
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedget/set the current selected value
optionsGetStringnullFor dynamic options calls. This is the url of your option route
optionsLabelStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's label field ex. 'optionName'
optionsValueStringnullFor dynamic options calls. This is the field identifier that corresponds to your option's value field ex. 'id'

OD Form Richtext

PropertyTypeDefaultDescription
inputHTMLInputElementHTMLInputElementGet only. Returns the created html input. Can be used for any semantic html form hooks.
labelTextStringString ''Returns the text of the created html label. Can be used to set label text
inlineBooleanfalseTells the element to align its input field inline with its label field
valueStringundefinedget/set the html input value property
editorQuillQuillGet only. Returns the Quill inhstance for any required hooks

Functions

OD Form

NamereturnsParametersDescription
submitFormundefinedNoneTriggers an html submit event on the html form with custom validation.
htmlSubmitFormundefinedNoneTriggers an html submit event on the html form with html validation.
resetundefinedNoneTriggers a reset/clearing of the form data
validateBooleanNoneCycles through inputs and validates each one.
htmlValidateBooleanNoneTriggers an html validation of the form.
getDataObjectNoneReturns a JSON Object of the FormData associated with the html form.
getValueObjectString nameReturns the current value in the form associated with the given name parameter
setValueundefinedString name, Object dataSets the value in the form associated with the given name parameter
setCheckedundefinedString name, String value, Boolean isCheckedSets the associated checkbox or radio in the form associated with the given name parameter
populateundefinedObject dataPopulates the form with data based on a simple JSON Object.
saveAutocompleteundefinedNoneTriggers the form to save autocomplete data in the browser.

OD Form Array

NamereturnsParametersDescription
addNewEntryHTMLElementNoneAdds a new form based on the template to the DOM.
deleteEntryundefinedSting idDeletes the corresponding form entry from the DOM .
validateBooleanNoneCycles through form entries and validates each one.
getDataArrayNoneReturns a JSON Array of the FormData associated with the html form entries.
populateundefinedObject dataPopulates the form with data based on a simple JSON Array.
resetundefinedNoneTriggers a reset/clearing of all data in each form

Any Form Element

NamereturnsParametersDescription
listenundefinedeventName, callbackAdds an event listener to the form element in the ssame way you would a normal listener

Styling

  • CSS variables are available to alter the default styling provided
Shadow PartDescription
formSelects the html form
tableThe table used for aligning labels and inputs
table-rowRows under the table part
table-cellCells under the rows part
label-cellCells under the rows part containing the field label
input-cellCells under the rows part containing the input element
field-labelThe labels used for identifying separate fields
value-labelThe labels used in place of the inputs to display the current value
form-inputSelects inputs in the html form
form-selectSelects 'select' elements in the html form
form-textareaSeelects Textareas in the form
--ARRAY ONLY--
array-containerThe div used to insert new forms
array-fieldsetSelects the wrapper fieldset around each form
od-formSelects the OD Form Elements nested in each fieldset
add-buttonThe add button used to add new entries
delete-buttonThe button used to delete corresponding entries

Development

Run development server and show demo

npm run demo

Run linter

npm run lint

Fix linter errors

npm run fix

Build for production

npm run build
8.2.3

2 years ago

8.2.2

3 years ago

8.2.1

3 years ago

8.2.0

3 years ago

8.1.0

3 years ago

8.0.10

3 years ago

8.0.12

3 years ago

8.0.11

3 years ago

8.0.9

3 years ago

8.0.8

3 years ago

8.0.7

3 years ago

8.0.6

3 years ago

8.0.5

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.3

3 years ago

8.0.2

3 years ago

7.0.3

3 years ago

7.0.2

3 years ago

7.0.1

3 years ago

7.0.0

3 years ago

6.3.0

3 years ago

6.4.0

3 years ago

6.2.10

3 years ago

6.2.5

3 years ago

6.2.4

3 years ago

6.2.7

3 years ago

6.2.6

3 years ago

6.2.9

3 years ago

6.2.8

3 years ago

6.2.1

3 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.0

3 years ago

6.0.51

3 years ago

6.1.0

3 years ago

6.0.41

3 years ago

6.0.40

3 years ago

6.0.45

3 years ago

6.0.44

3 years ago

6.0.43

3 years ago

6.0.42

3 years ago

6.0.38

3 years ago

6.0.37

3 years ago

6.0.36

3 years ago

6.0.35

3 years ago

6.0.39

3 years ago

6.0.34

3 years ago

6.0.33

3 years ago

6.0.50

3 years ago

6.0.26

3 years ago

6.0.25

3 years ago

6.0.24

3 years ago

6.0.29

3 years ago

6.0.28

3 years ago

6.0.23

3 years ago

6.0.22

3 years ago

6.0.21

3 years ago

6.0.20

3 years ago

6.0.30

3 years ago

6.0.32

3 years ago

6.0.31

3 years ago

6.0.19

3 years ago

6.0.18

3 years ago

6.0.17

3 years ago

6.0.16

3 years ago

6.0.15

3 years ago

6.0.14

3 years ago

6.0.13

3 years ago

6.0.12

3 years ago

6.0.11

3 years ago

6.0.10

3 years ago

6.0.9

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.1.9

4 years ago

5.1.8

4 years ago

5.1.7

4 years ago

5.1.6

4 years ago

5.1.5

4 years ago

5.1.4

4 years ago

5.1.3

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.12

4 years ago

5.1.11

4 years ago

5.1.10

4 years ago

5.1.0

4 years ago

5.0.7

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.10.5

4 years ago

4.10.1

4 years ago

4.10.2

4 years ago

4.10.4

4 years ago

4.9.2

4 years ago

4.9.1

4 years ago

4.10.0

4 years ago

4.9.0

4 years ago

4.8.0

4 years ago

4.7.11

4 years ago

4.7.10

4 years ago

4.7.9

4 years ago

4.7.6

4 years ago

4.7.8

4 years ago

4.7.7

4 years ago

4.7.5

4 years ago

4.7.4

4 years ago

4.7.2

4 years ago

4.7.3

4 years ago

4.7.0

4 years ago

4.7.1

4 years ago

4.6.0

4 years ago

4.4.26

4 years ago

4.5.0

4 years ago

4.4.25

4 years ago

4.4.24

4 years ago

4.4.21

4 years ago

4.4.20

4 years ago

4.4.23

4 years ago

4.4.22

4 years ago

4.4.19

4 years ago

4.4.18

4 years ago

4.4.17

4 years ago

4.4.16

4 years ago

4.4.15

4 years ago

4.4.14

4 years ago

4.4.13

4 years ago

4.4.12

4 years ago

4.4.10

4 years ago

4.4.11

4 years ago

4.4.9

4 years ago

4.4.8

4 years ago

4.4.7

4 years ago

4.4.6

4 years ago

4.4.5

4 years ago

4.4.3

4 years ago

4.4.4

4 years ago

4.4.2

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.0

4 years ago

4.2.68

4 years ago

4.2.67

4 years ago

4.2.66

4 years ago

4.2.65

4 years ago

4.2.64

4 years ago

4.2.63

4 years ago

4.2.62

4 years ago

4.2.61

4 years ago

4.2.60

4 years ago

4.2.59

4 years ago

4.2.58

4 years ago

4.2.56

4 years ago

4.2.57

4 years ago

4.2.55

4 years ago

4.2.54

4 years ago

4.2.53

4 years ago

4.2.52

4 years ago

4.2.50

4 years ago

4.2.51

4 years ago

4.2.48

4 years ago

4.2.49

4 years ago

4.2.46

4 years ago

4.2.47

4 years ago

4.2.45

4 years ago

4.2.44

4 years ago

4.2.43

4 years ago

4.2.42

4 years ago

4.2.40

4 years ago

4.2.41

4 years ago

4.2.39

4 years ago

4.2.36

4 years ago

4.2.37

4 years ago

4.2.38

4 years ago

4.2.35

4 years ago

4.2.33

4 years ago

4.2.34

4 years ago

4.2.31

4 years ago

4.2.32

4 years ago

4.2.29

4 years ago

4.2.30

4 years ago

4.2.28

4 years ago

4.2.26

4 years ago

4.2.27

4 years ago

4.2.25

4 years ago

4.2.24

4 years ago

4.2.23

4 years ago

4.2.22

4 years ago

4.2.20

4 years ago

4.2.21

4 years ago

4.2.19

4 years ago

4.2.17

4 years ago

4.2.18

4 years ago

4.2.16

4 years ago

4.2.7

4 years ago

4.2.6

4 years ago

4.2.9

4 years ago

4.2.8

4 years ago

4.2.3

4 years ago

4.2.10

4 years ago

4.2.2

4 years ago

4.2.11

4 years ago

4.2.5

4 years ago

4.2.12

4 years ago

4.2.4

4 years ago

4.2.13

4 years ago

4.2.14

4 years ago

4.2.15

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.1

6 years ago

3.0.0

6 years ago