Fieldset: API Table
class: LionFieldset
, lion-fieldset
Fields
Name | Privacy | Type | Default | Description | Inherited From |
---|---|---|---|---|---|
defaultValidators | public | Validator[] | [new FormElementsHaveNoError()] | Used by Subclassers to add default Validators to a particular FormControl. A date input for instance, always needs the isDate validator. | ValidateMixin |
dirty | public | boolean | false | True when any of the children is dirty (see InteractionStateMixin for more details.) | FormGroupMixin |
disabled | public | boolean | false | Disables all formElements in group | DisabledMixin |
done | public | boolean | false | FormRegistrarMixin | |
fieldName | public | string | Will be used in validation messages to refer to the current field | FormControlMixin | |
focused | public | boolean | false | True when any of the children is focused. | FormGroupMixin |
formattedValue | public | Object keyed by formElements names, containing formElements' formattedValues | FormGroupMixin | ||
formElements | public | FormControlsCollection | new FormControlsCollection() | Closely mimics the natively supported HTMLFormControlsCollection. It can be accessed both like an array and an object (based on control/element names). | FormRegistrarMixin |
hasFeedbackFor | public | ValidationType[] | [] | As soon as validation happens (after modelValue/validators/validator param change), this array is updated with the active ValidationTypes ('error'|'warning'|'success'|'info' etc.). Notice the difference with `.showsFeedbackFor`, which filters `.hasFeedbackFor` based on `.feedbackCondition()`. For styling purposes, will be reflected to [has-feedback-for="error warning"]. This can be useful for subtle visual feedback on keyup, like a red/green border around an input. | ValidateMixin |
helpText | public | string | '' | The helpt text for the input node. When no value is defined, textContent of [slot=help-text] will be used | FormControlMixin |
initComplete | public | Promise<any> | new Promise((resolve, reject) => { this.__resolveInitComplete = resolve; this.__rejectInitComplete = reject; }) | initComplete resolves after all pending initialization logic (for instance `<form-group .serializedValue=$>`) is executed | FormRegistrarMixin |
isPending | public | boolean | false | Flag indicating whether async validation is pending. Creates attribute [is-pending] as a styling hook | ValidateMixin |
label | public | string | '' | The label text for the input node. When no value is defined, textContent of [slot=label] will be used | FormControlMixin |
labelSrOnly | public | boolean | false | The label will only be visible for srceen readers when true | FormControlMixin |
modelValue | public | Object keyed by formElements names, containing formElements' modelValues | FormControlMixin | ||
operationMode | public | OperationMode | Types of input interaction of the FormControl (for instance 'enter'|'select'|'upload') | ValidateMixin | |
prefilled | public | boolean | True when all of the children are prefilled (see InteractionStateMixin for more details.) | FormGroupMixin | |
readOnly | public | boolean | false | A Boolean attribute which, if present, indicates that the user should not be able to edit the value of the input. The difference between disabled and readonly is that read-only controls can still function, whereas disabled controls generally do not function as controls until they are enabled. (From: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-readonly) | FormControlMixin |
registrationComplete | public | Promise<any> & {done?:boolean} | new Promise((resolve, reject) => { this.__resolveRegistrationComplete = resolve; this.__rejectRegistrationComplete = reject; }) | registrationComplete waits for all children formElements to have registered | FormRegistrarMixin |
serializedValue | public | Object keyed by formElements names, containing formElements' serializedValues | FormGroupMixin | ||
showsFeedbackFor | public | ValidationType[] | [] | Based on outcome of feedbackCondition, this array decides what ValidationTypes should be shown in validationFeedback, based on meta data like interaction states. For styling purposes, it reflects it `[shows-feedback-for="error warning"]` | ValidateMixin |
submitted | public | boolean | false | True when parent form is submitted | FormGroupMixin |
touched | public | boolean | false | True when the group as a whole is blurred (see InteractionStateMixin for more details.) | FormGroupMixin |
validationStates | public | ValidationStates | {} | The outcome of a validation 'round'. Keyed by ValidationType and Validator name | ValidateMixin |
validators | public | Validator[] | [] | Used by Application Developers to add Validators to a FormControl. | ValidateMixin |
value | public | string | '' | FormGroupMixin | |
_allValidators | protected | Validator[] | Combination of validators provided by Application Developer and the default validators | ValidateMixin | |
_ariaDescribedNodes | public | HTMLElement[] | [] | Contains all elements that should end up in aria-describedby of `._inputNode` | FormControlMixin |
_ariaLabelledNodes | public | HTMLElement[] | [] | Contains all elements that should end up in aria-labelledby of `._inputNode` | FormControlMixin |
_feedbackConditionMeta | protected | Allows Subclassers to add meta info for feedbackCondition | ValidateMixin | ||
_feedbackNode | protected | Element where validation feedback will be rendered to | FormControlMixin | ||
_helpTextNode | protected | Element where help text will be rendered to | FormControlMixin | ||
_initialModelValue | protected | Gathers initial model values of all children. Used when resetGroup() is called. | FormGroupMixin | ||
_inputId | protected | string | Unique id that can be used in all light dom | FormControlMixin | |
_inputNode | protected | The host element with role group (or radio-group or form) containing necessary aria attributes | FormControlMixin | ||
_isFormOrFieldset | protected | boolean | true | Flag that determines how ".formElements" should behave. For a regular fieldset (see LionFieldset) we expect ".formElements" to be accessible as an object. In case of a radio-group, a checkbox-group or a select/listbox, it should act like an array (see ChoiceGroupMixin). Usually, when false, we deal with a choice-group (radio-group, checkbox-group, (multi)select) | FormRegistrarMixin |
_isRepropagationEndpoint | public | boolean | false | By default, a field with _repropagationRole 'choice-group' will act as an 'endpoint'. This means it will be considered as an individual field: for a select, individual options will not be part of the formPath. They will. Similarly, components that (a11y wise) need to be fieldsets, but 'interaction wise' (from Application Developer perspective) need to be more like fields (think of an amount-input with a currency select box next to it), can set this to true to hide private internals in the formPath. | FormControlMixin |
_labelNode | protected | Element where label will be rendered to | FormControlMixin | ||
_repropagationRole | public | 'child'|'choice-group'|'fieldset' | 'fieldset' | Based on the role, details of handling model-value-changed repropagation differ. | FormControlMixin |
_requestedToBeDisabled | protected | boolean | false | DisabledMixin | |
_visibleMessagesAmount | protected | number | 1 | The amount of feedback messages that will visible in LionValidationFeedback | ValidateMixin |
Methods
Name | Privacy | Description | Parameters | Return | Inherited From |
---|---|---|---|---|---|
addFormElement | public | child: FormControl & {serializedValue:string|object}, indexToInsertAt: number | FormRegistrarMixin | ||
addToAriaDescribedBy | public | Allows to add element references to aria-describedby attribute. | element: HTMLElement, { idPrefix = '', reorder = true }, customConfig: {idPrefix?:string; reorder?: boolean} | FormControlMixin | |
addToAriaLabelledBy | public | Allows to add extra element references to aria-labelledby attribute. | element: HTMLElement, { idPrefix = '', reorder = true }, customConfig: {idPrefix?:string; reorder?: boolean} | FormControlMixin | |
clearGroup | public | Clears all values and resets all interaction states of all FormControls in group, | FormGroupMixin | ||
click | public | DisabledMixin | |||
feedbackCondition | public | Allows the Application Developer to specify when a feedback message should be shown | type: string, meta: object, currentCondition: ((type: string, meta: object) => boolean) | boolean | ValidateMixin |
isRegisteredFormElement | public | el: ElementWithParentFormGroup | FormRegistrarMixin | ||
makeRequestToBeDisabled | public | DisabledMixin | |||
removeFormElement | public | el: FormRegisteringHost & FormControl | FormRegistrarMixin | ||
removeFromAriaDescribedBy | public | Allows to remove element references from aria-describedby attribute. | element: HTMLElement | FormControlMixin | |
removeFromAriaLabelledBy | public | Allows to remove element references from aria-labelledby attribute. | element: HTMLElement | FormControlMixin | |
resetGroup | public | Resets to initial/prefilled values and interaction states of all FormControls in group, | FormGroupMixin | ||
resetInteractionState | public | Resets all interaction states for all formElements | FormGroupMixin | ||
retractRequestToBeDisabled | public | DisabledMixin | |||
submitGroup | public | Handles interaction state 'submitted'. This allows children to enable visibility of validation feedback | FormGroupMixin | ||
updateSync | public | name: string, oldValue: ? | ValidateMixin | ||
validate | public | Triggered by: - modelValue change - change in the 'validators' array - change in the config of an individual Validator Three situations are handled: - a1) the FormControl is empty: further execution is halted. When the Required Validator (being mutually exclusive to the other Validators) is applied, it will end up in the validation result (as the only Validator, since further execution was halted). - a2) there are synchronous Validators: this is the most common flow. When modelValue hasn't changed since last async results were generated, 'sync results' are merged with the 'async results'. - a3) there are asynchronous Validators: for instance when server side evaluation is needed. Executions are scheduled and awaited and the 'async results' are merged with the 'sync results'. - b) there are MetaValidators. After steps a1, a2, or a3 are finished, the holistic MetaValidators (evaluating the total result of the 'regular' (a1, a2 and a3) validators) will be run... Situations a2 and a3 are not mutually exclusive and can be triggered within one `validate()` call. Situation b will occur after every call. | { clearCurrentResult = false }, opts: { clearCurrentResult?: boolean } | ValidateMixin | |
_anyFormElementHas | protected | Returns true when one of the formElements has requested | property: string | FormGroupMixin | |
_anyFormElementHasFeedbackFor | protected | state: string | FormGroupMixin | ||
_checkForOutsideClick | protected | event: Event | FormGroupMixin | ||
_completeRegistration | protected | Resolves the registrationComplete promise. Subclassers can delay if needed | FormRegistrarMixin | ||
_dispatchInitialModelValueChangedEvent | protected | FormControlMixin | |||
_enhanceLightDomA11y | protected | FormControlMixin | |||
_enhanceLightDomA11yForAdditionalSlots | protected | Enhances additional slots(prefix, suffix, before, after) defined by developer. When boolean attribute data-label or data-description is found, the slot element will be connected to the input via aria-labelledby or aria-describedby | additionalSlots: string[] | FormControlMixin | |
_enhanceLightDomClasses | protected | FormControlMixin | |||
_everyFormElementHas | protected | Returns true when all of the formElements have requested property | property: string | FormGroupMixin | |
_feedbackTemplate | protected | TemplateResult | FormControlMixin | ||
_getAriaDescriptionElements | protected | This function exposes descripion elements that a FormGroup should expose to its children. See FormGroupMixin.__getAllDescriptionElementsInParentChain() | Array.<HTMLElement> | FormControlMixin | |
_getFromAllFormElements | protected | Gets a keyed be name object for requested property (like modelValue/serializedValue) | property: string, filterFn: (el: FormControl, property?: string) => boolean | {[name:string]: any} | FormGroupMixin |
_getFromAllFormElementsFilter | protected | A filter function which will exclude a form field when returning false By default, exclude form fields which are disabled The type is be passed as well for more fine grained control, e.g. distinguish the filter when fetching modelValue versus serializedValue | el: FormControl, type: string | boolean | FormGroupMixin |
_groupOneTemplate | protected | TemplateResult | FormControlMixin | ||
_groupTwoTemplate | protected | TemplateResult | FormControlMixin | ||
_hasFeedbackVisibleFor | protected | Used to translate `.hasFeedbackFor` and `.shouldShowFeedbackFor` to `.showsFeedbackFor` | type: string | ValidateMixin | |
_helpTextTemplate | protected | TemplateResult | FormControlMixin | ||
_inputGroupAfterTemplate | protected | TemplateResult | FormControlMixin | ||
_inputGroupBeforeTemplate | protected | TemplateResult | FormControlMixin | ||
_inputGroupInputTemplate | protected | TemplateResult | FormControlMixin | ||
_inputGroupPrefixTemplate | protected | TemplateResult | nothing | FormControlMixin | ||
_inputGroupSuffixTemplate | protected | TemplateResult | nothing | FormControlMixin | ||
_inputGroupTemplate | protected | TemplateResult | FormControlMixin | ||
_isEmpty | protected | Used for Required validation and computation of interaction states | modelValue: any | boolean | FormControlMixin |
_labelTemplate | protected | TemplateResult | FormControlMixin | ||
_onBeforeRepropagateChildrenValues | protected | Hook for Subclassers to add logic before repropagation | ev: CustomEvent | FormControlMixin | |
_onFocusOut | protected | ev: Event | FormGroupMixin | ||
_onLabelClick | protected | FormControlMixin | |||
_onRequestToAddFormElement | protected | Hook for Subclassers to perform logic before an element is added | ev: CustomEvent | FormRegistrarMixin | |
_onRequestToChangeFormElementName | protected | ev: CustomEvent | FormRegistrarMixin | ||
_onRequestToRemoveFormElement | protected | ev: CustomEvent | FormRegistrarMixin | ||
_onValidatorUpdated | protected | e: Event|CustomEvent | ValidateMixin | ||
_prioritizeAndFilterFeedback | protected | Orders all active validators in this.__validationResult. Can also filter out occurrences (based on interaction states) | { validationResult }, opts: { validationResult: Validator[] } | Validator[] | ValidateMixin |
_repropagationCondition | protected | Based on provided target, this condition determines whether received model-value-changed event should be repropagated | target: FormControlHost | FormControlMixin | |
_setValueForAllFormElements | protected | Sets the same value for requested property in all formElements | property: string | number, value: any | FormGroupMixin | |
_setValueMapForAllFormElements | protected | Allows to set formElements values via a keyed object structure | property: string, values: { [x: string]: any; } | FormGroupMixin | |
_showFeedbackConditionFor | protected | Default feedbackCondition condition, used by Subclassers, that will be used when `feedbackCondition()` is not overridden by Application Developer. Show the validity feedback when returning true, don't show when false | type: string, meta: object | ValidateMixin | |
_syncDirty | protected | FormGroupMixin | |||
_syncFocused | protected | FormGroupMixin | |||
_triggerInitialModelValueChangedEvent | protected | FormControlMixin | |||
_updateFeedbackComponent | protected | Responsible for retrieving messages from Validators and (delegation of) rendering them. For `._feedbackNode` (extension of LionValidationFeedback): - retrieve messages from highest prio Validators - provide the result to custom feedback node and let the custom node decide on their renderings In both cases: - we compute the 'show' flag (like 'hasErrorVisible') for all types - we set the customValidity message of the highest prio Validator - we set aria-invalid="true" in case hasErrorVisible is true | ValidateMixin | ||
_updateShouldShowFeedbackFor | protected | ValidateMixin |
Events
Name | Type | Description | Inherited From |
---|---|---|---|
form-element-name-changed | CustomEvent | FormControlMixin | |
model-value-changed | CustomEvent | FormControlMixin | |
showsFeedbackForChanged | Event | ValidateMixin | |
Event | ValidateMixin | ||
shouldShowFeedbackForChanged | Event | ValidateMixin | |
validate-performed | Event | private event that should be listened to by LionFieldSet | ValidateMixin |
Attributes
Name | Field | Inherited From |
---|---|---|
submitted | submitted | FormGroupMixin |
focused | focused | FormGroupMixin |
dirty | dirty | FormGroupMixin |
touched | touched | FormGroupMixin |
prefilled | prefilled | FormGroupMixin |
_isFormOrFieldset | _isFormOrFieldset | FormRegistrarMixin |
readonly | readOnly | FormControlMixin |
label | label | FormControlMixin |
label-sr-only | labelSrOnly | FormControlMixin |
help-text | helpText | FormControlMixin |
shows-feedback-for | showsFeedbackFor | ValidateMixin |
is-pending | isPending | ValidateMixin |
disabled | disabled | DisabledMixin |