Input Amount: API Table
class: LionInputAmount
, lion-input-amount
Fields
Name | Privacy | Type | Default | Description | Inherited From |
---|---|---|---|---|---|
slots | public | Adds "._feedbackNode" as described below | LionField | ||
__currencyLabel | protected | ||||
parser | public | parseAmount | Converts viewValue to modelValue For instance, a localized date to a Date Object | LionField | |
formatter | public | formatAmount | Converts modelValue to formattedValue (formattedValue will be synced with `._inputNode.value`) For instance, a Date object to a localized date. | LionField | |
currency | public | string | undefined | undefined | ||
locale | public | string | undefined | undefined | ||
__currencyDisplayNodeIsConnected | protected | boolean | true | ||
_currencyDisplayNodeSlot | protected | string | 'after' | The slot to put the currency display node in. Can be 'prefix', 'suffix', 'before' and 'after'. Default will be 'after'. | |
modelValue | public | LionField | |||
_inputNode | protected | HTMLInputElement | HTMLTextAreaElement | The interactive (form) element. Can be a native element like input/textarea/select or an element with tabindex > -1 | LionField | |
selectionStart | public | number | NativeTextFieldMixin | ||
selectionEnd | public | number | NativeTextFieldMixin | ||
value | public | The view value. Will be delegated to `._inputNode.value` Note: Overrides the implementation from FormatMixin | LionField | ||
_focusableNode | protected | HTMLElement | The focusable element: could be an input, textarea, select, button or any other element with tabindex > -1 | LionField | |
autocomplete | public | string | undefined | undefined | Delegates this property to input/textarea/select. | NativeTextFieldMixin |
formatOn | protected | string | 'change' | Event that will trigger formatting (more precise, visual update of the view, so the user sees the formatted value) Default: 'change' | LionField |
formatOptions | public | ({}) | Configuration object that will be available inside the formatter function | LionField | |
formattedValue | public | string|undefined | undefined | The view value is the result of the formatter function (when available). The result will be stored in the native _inputNode (usually an input[type=text]). Examples: - For a date input, this would be '20/01/1999' (dependent on locale). - For a number input, this could be '1,234.56' (a String representation of modelValue 1234.56) | LionField |
serializedValue | public | string|undefined | undefined | The serialized version of the model value. This value exists for maximal compatibility with the platform API. The serialized value can be an interface in context where data binding is not supported and a serialized string needs to be set. Examples: - For a date input, this would be the iso format of a date, e.g. '1999-01-20'. - For a number input this would be the String representation of a float ('1234.56' instead of 1234.56) When no parser is available, the value is usually the same as the formattedValue (being _inputNode.value) | LionField |
_isPasting | protected | boolean | false | Whether the user is pasting content. Allows Subclassers to do this in their subclass: | LionField |
_isHandlingUserInput | protected | boolean | false | Flag that will be set when user interaction takes place (for instance after an 'input' event). Will be added as meta info to the `model-value-changed` event. Depending on whether a user is interacting, formatting logic will be handled differently. | LionField |
focused | public | boolean | false | Whether the focusable element within (`._focusableNode`) is focused. Reflects to attribute '[focused]' as a styling hook | LionField |
focusedVisible | public | boolean | false | Whether the focusable element within (`._focusableNode`) matches ':focus-visible' Reflects to attribute '[focused-visible]' as a styling hook See: https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible | LionField |
autofocus | public | boolean | false | LionField | |
label | public | string | '' | The label text for the input node. When no value is defined, textContent of [slot=label] will be used | LionField |
helpText | public | string | '' | The helpt text for the input node. When no value is defined, textContent of [slot=help-text] will be used | LionField |
fieldName | public | string | Will be used in validation messages to refer to the current field | LionField | |
_labelNode | protected | Element where label will be rendered to | LionField | ||
_helpTextNode | protected | Element where help text will be rendered to | LionField | ||
_feedbackNode | protected | Element where validation feedback will be rendered to | LionField | ||
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) | LionField |
labelSrOnly | public | boolean | false | The label will only be visible for srceen readers when true | LionField |
_inputId | protected | string | Unique id that can be used in all light dom | LionField | |
_ariaLabelledNodes | public | HTMLElement[] | [] | Contains all elements that should end up in aria-labelledby of `._inputNode` | LionField |
_ariaDescribedNodes | public | HTMLElement[] | [] | Contains all elements that should end up in aria-describedby of `._inputNode` | LionField |
_repropagationRole | public | 'child'|'choice-group'|'fieldset' | 'child' | Based on the role, details of handling model-value-changed repropagation differ. | LionField |
_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. | LionField |
type | public | string | 'text' | LionInput | |
placeholder | public | string | '' | LionInput | |
name | public | string | '' | The name the element will be registered with to the .formElements collection of the parent. Also, it serves as the key of key/value pairs in modelValue/serializedValue objects | LionField |
_parentFormGroup | protected | FormRegistrarHost | undefined | undefined | The registrar this FormControl registers to, Usually a descendant of FormGroup or ChoiceGroup | LionField |
allowCrossRootRegistration | public | boolean | false | To encourage accessibility best practices, `form-element-register` events do not pierce through shadow roots. This forces the developer to create form groups and fieldsets that automatically allow the creation of accessible relationships in the same dom tree. Use this option if you know what you're doing. It will then be possible to nest FormControls inside shadow dom. See https://lion.js.org/fundamentals/rationales/accessibility/#shadow-roots-and-accessibility | LionField |
_requestedToBeDisabled | protected | boolean | false | LionField | |
disabled | public | boolean | false | LionField | |
_feedbackConditionMeta | protected | Allows Subclassers to add meta info for feedbackCondition | LionField | ||
touched | public | boolean | false | True when user has focused and left(blurred) the field. | LionField |
dirty | public | boolean | false | True when user has changed the value of the field. | LionField |
prefilled | public | boolean | false | True when user has left non-empty field or input is prefilled. The name must be seen from the point of view of the input field: once the user enters the input field, the value is non-empty. | LionField |
filled | public | boolean | false | True when the modelValue is non-empty (see _isEmpty in FormControlMixin) | LionField |
_leaveEvent | protected | string | 'blur' | The event that triggers the touched state | LionField |
_valueChangedEvent | protected | string | 'model-value-changed' | The event that triggers the dirty state | LionField |
submitted | public | LionField | |||
operationMode | public | OperationMode | Types of input interaction of the FormControl (for instance 'enter'|'select'|'upload') | LionField | |
_allValidators | protected | Validator[] | Combination of validators provided by Application Developer and the default validators | LionField | |
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. | LionField |
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"]` | LionField |
validationStates | public | ValidationStates | {} | The outcome of a validation 'round'. Keyed by ValidationType and Validator name | LionField |
isPending | public | boolean | false | Flag indicating whether async validation is pending. Creates attribute [is-pending] as a styling hook | LionField |
validators | public | Validator[] | [] | Used by Application Developers to add Validators to a FormControl. | LionField |
defaultValidators | public | Validator[] | [] | Used by Subclassers to add default Validators to a particular FormControl. A date input for instance, always needs the isDate validator. | LionField |
_visibleMessagesAmount | protected | number | 1 | The amount of feedback messages that will visible in LionValidationFeedback | LionField |
__SyncUpdatableNamespace | protected | SyncUpdatableNamespace | {} | Namespace for this mixin that guarantees naming clashes will not occur... | LionField |
Methods
Name | Privacy | Description | Parameters | Return | Inherited From |
---|---|---|---|---|---|
_connectSlotMixin | protected | Upon connecting slot mixin, we should check if the required slot was created by the slot mixin, and if so, we should execute the currency changed flow which evaluates whether the slot node should be removed for invalid currencies | LionField | ||
_reflectBackOn | protected | Every time .formattedValue is attempted to sync to the view value (on change/blur and on modelValue change), this condition is checked. When enhancing it, it's recommended to call via `return this._myExtraCondition && super._reflectBackOn()` | boolean | LionField | |
_onCurrencyChanged | protected | { currency }, opts: @param {string?} opts.currency * | |||
__reformat | protected | ||||
_setValueAndPreserveCaret | protected | Restores the cursor to its original position after updating the value. | newValue: string | NativeTextFieldMixin | |
_reflectBackFormattedValueToUser | protected | Note: Overrides the implementation from FormatMixin | LionField | ||
preprocessor | public | Preprocessors could be considered 'live formatters'. Their result is shown to the user on keyup instead of after blurring the field. The biggest difference between preprocessors and formatters is their moment of execution: preprocessors are run before modelValue is computed (and work based on view value), whereas formatters are run after the parser (and are based on modelValue) Automatically formats code while typing. It depends on a preprocessro that smartly updates the viewValue and caret position for best UX. | v: string, opts: FormatOptions & { prevViewValue: string; currentCaretIndex: number } | { viewValue:string; caretIndex:number; }|string|undefined | LionField |
serializer | public | Converts `.modelValue` to `.serializedValue` For instance, a Date object to an iso formatted date string | v: ? | string | LionField |
deserializer | public | Converts `.serializedValue` to `.modelValue` For instance, an iso formatted date string to a Date object | v: ? | ? | LionField |
_calculateValues | protected | Responsible for storing all representations(modelValue, serializedValue, formattedValue and value) of the input value. Prevents infinite loops, so all value observers can be treated like they will only be called once, without indirectly calling other observers. (in fact, some are called twice, but the __preventRecursiveTrigger lock prevents the second call from having effect). | { source }, config: {source:'model'|'serialized'|'formatted'|null} | LionField | |
_onModelValueChanged | protected | Responds to modelValue changes in the synchronous cycle (most subclassers should listen to the asynchronous cycle ('modelValue' in the .updated lifecycle)) | args: { modelValue: unknown; }[] | LionField | |
_dispatchModelValueChangedEvent | protected | This is wrapped in a distinct method, so that parents can control when the changed event is fired. For objects, a deep comparison might be needed. | args: { modelValue: unknown; }[] | LionField | |
_syncValueUpwards | protected | Synchronization from `._inputNode.value` to `LionField` (flow [2]) Downwards syncing should only happen for `LionField`.value changes from 'above'. This triggers _onModelValueChanged and connects user input to the parsing/formatting/serializing loop. | LionField | ||
_proxyInputEvent | protected | This can be called whenever the view value should be updated. Dependent on component type ("input" for <input> or "change" for <select>(mainly for IE)) a different event should be used as source for the "user-input-changed" event (which can be seen as an abstraction layer on top of other events (input, change, whatever)) | LionField | ||
_onUserInputChanged | protected | LionField | |||
__onCompositionEvent | protected | { type }, event: Event | LionField | ||
focus | public | Calls `focus()` on focusable element within | LionField | ||
blur | public | Calls `blur()` on focusable element within | LionField | ||
_triggerInitialModelValueChangedEvent | protected | LionField | |||
_enhanceLightDomClasses | protected | LionField | |||
_enhanceLightDomA11y | protected | LionField | |||
_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[] | LionField | |
__reflectAriaAttr | protected | Will handle help text, validation feedback and character counter, prefix/suffix/before/after (if they contain data-description flag attr). Also, contents of id references that will be put in the <lion-field>._ariaDescribedby property from an external context, will be read by a screen reader. | attrName: string, nodes: Element[], reorder: boolean|undefined | LionField | |
_groupOneTemplate | protected | TemplateResult | LionField | ||
_groupTwoTemplate | protected | TemplateResult | LionField | ||
_labelTemplate | protected | TemplateResult | LionField | ||
_helpTextTemplate | protected | TemplateResult | LionField | ||
_inputGroupTemplate | protected | TemplateResult | LionField | ||
_inputGroupBeforeTemplate | protected | TemplateResult | LionField | ||
_inputGroupPrefixTemplate | protected | TemplateResult | nothing | LionField | ||
_inputGroupInputTemplate | protected | TemplateResult | LionField | ||
_inputGroupSuffixTemplate | protected | TemplateResult | nothing | LionField | ||
_inputGroupAfterTemplate | protected | TemplateResult | LionField | ||
_feedbackTemplate | protected | TemplateResult | LionField | ||
_isEmpty | protected | Used for Required validation and computation of interaction states | modelValue: any | boolean | LionField |
_getAriaDescriptionElements | protected | This function exposes descripion elements that a FormGroup should expose to its children. See FormGroupMixin.__getAllDescriptionElementsInParentChain() | Array.<HTMLElement> | LionField | |
addToAriaLabelledBy | public | Allows to add extra element references to aria-labelledby attribute. | element: HTMLElement, { idPrefix = '', reorder = true }, customConfig: {idPrefix?:string; reorder?: boolean} | LionField | |
removeFromAriaLabelledBy | public | Allows to remove element references from aria-labelledby attribute. | element: HTMLElement | LionField | |
addToAriaDescribedBy | public | Allows to add element references to aria-describedby attribute. | element: HTMLElement, { idPrefix = '', reorder = true }, customConfig: {idPrefix?:string; reorder?: boolean} | LionField | |
removeFromAriaDescribedBy | public | Allows to remove element references from aria-describedby attribute. | element: HTMLElement | LionField | |
__getDirectSlotChild | protected | slotName: string | HTMLElement | undefined | LionField | |
_dispatchInitialModelValueChangedEvent | protected | LionField | |||
_onBeforeRepropagateChildrenValues | protected | Hook for Subclassers to add logic before repropagation | ev: CustomEvent | LionField | |
__repropagateChildrenValues | protected | ev: CustomEvent | LionField | ||
_repropagationCondition | protected | Based on provided target, this condition determines whether received model-value-changed event should be repropagated | target: FormControlHost | LionField | |
_onLabelClick | protected | LionField | |||
makeRequestToBeDisabled | public | LionField | |||
retractRequestToBeDisabled | public | LionField | |||
__rerenderSlot | protected | slotName: string | LionField | ||
__appendNodes | protected | `{ nodes, renderParent = this, slotName }, options: @param {Node[]} options.nodes * @param {Element} [options.renderParent] It's recommended to create a render target in light dom (like ), * which can be used as a render target for most * @param {string} options.slotName For the first render, it's best to use slotName |
` | | LionField |
| __initSlots
| protected | Here we look what's inside our `get slots`.
Rerenderable slots get scheduled and "one time slots" get rendered once on connected | slotNames: string[]
| | LionField |
| _isPrivateSlot
| protected | | slotName: string
| boolean
| LionField |
| initInteractionState
| public | Evaluations performed on connectedCallback.
This method is public, so it can be called at a later moment (when we need to wait for
registering children for instance) as well.
Since this method will be called twice in last mentioned scenario, it must stay idempotent. | | | LionField |
| _iStateOnLeave
| protected | Sets touched value to true and reevaluates prefilled state.
When false, on next interaction, user will start with a clean state. | | | LionField |
| _iStateOnValueChange
| protected | Sets dirty value and validates when already touched or invalid | | | LionField |
| resetInteractionState
| public | Resets touched and dirty, and recomputes prefilled | | | LionField |
| _onTouchedChanged
| protected | Dispatches event on touched state change | | | LionField |
| _onDirtyChanged
| protected | Dispatches event on touched state change | | | LionField |
| _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: InteractionStates
| | LionField |
| updateSync
| public | An abstraction that has the exact same api as `requestUpdate`, but taking
into account:
- [member order independence](https://github.com/webcomponents/gold-standard/wiki/Member-Order-Independence)
- property effects start when all (light) dom has initialized (on firstUpdated)
- property effects don't interrupt the first meaningful paint
- compatible with propertyAccessor.`hasChanged`: no manual checks needed or accidentally
run property effects / events when no change happened
effects when values didn't change
All code previously present in requestUpdate can be placed in this method. | name: string, oldValue: ?
| | LionField |
| 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 }
| | LionField |
| __executeValidators
| protected | | | | LionField |
| _onValidatorUpdated
| protected | | e: Event\|CustomEvent
| | LionField |
| _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 | | | LionField |
| 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
| LionField |
| _hasFeedbackVisibleFor
| protected | Used to translate `.hasFeedbackFor` and `.shouldShowFeedbackFor` to `.showsFeedbackFor` | type: string
| | LionField |
| _updateShouldShowFeedbackFor
| protected | | | | LionField |
| _prioritizeAndFilterFeedback
| protected | Orders all active validators in this.__validationResult.
Can also filter out occurrences (based on interaction states) | { validationResult }, opts: { validationResult: Validator[] }
| Validator[]
| LionField |
| createScopedElement
| public | | tagName
| | LionField |
| defineScopedElement
| public | Defines a scoped element. | tagName: string, classToBeRegistered: typeof HTMLElement
| | LionField |
| attachShadow
| public | | options: ShadowRootInit
| ShadowRoot
| LionField |
| reset
| public | Resets modelValue to initial value.
Interaction states are cleared | | | LionField |
| clear
| public | Clears modelValue.
Interaction states are not cleared (use resetInteractionState for this) | | | LionField |
| _onChange
| protected | Dispatches custom bubble event | ev: Event=
| | LionField |
Events
Name | Type | Description | Inherited From |
---|---|---|---|
model-value-changed | CustomEvent | LionField | |
user-input-changed | Event | LionField | |
focus | Event | LionField | |
blur | Event | LionField | |
focusin | Event | LionField | |
focusout | Event | LionField | |
form-element-name-changed | CustomEvent | LionField | |
form-element-register | CustomEvent | LionField | |
touched-changed | Event | LionField | |
dirty-changed | Event | LionField | |
showsFeedbackForChanged | Event | LionField | |
Event | LionField | ||
shouldShowFeedbackForChanged | Event | LionField | |
validate-performed | Event | private event that should be listened to by LionFieldSet | LionField |
Attributes
Name | Field | Inherited From |
---|---|---|
currency | currency | |
modelValue | modelValue | |
autocomplete | autocomplete | NativeTextFieldMixin |
focused | focused | LionField |
focused-visible | focusedVisible | LionField |
autofocus | autofocus | LionField |
readonly | readOnly | LionField |
label | label | LionField |
label-sr-only | labelSrOnly | LionField |
help-text | helpText | LionField |
type | type | LionInput |
placeholder | placeholder | LionInput |
name | name | LionField |
allow-cross-root-registration | allowCrossRootRegistration | LionField |
disabled | disabled | LionField |
touched | touched | LionField |
dirty | dirty | LionField |
filled | filled | LionField |
shows-feedback-for | showsFeedbackFor | LionField |
is-pending | isPending | LionField |