@ember-eui/validated-form 16.0.4 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/-private/lazy-component.d.ts +20 -0
- package/declarations/-private/lazy-component.d.ts.map +1 -0
- package/declarations/-private/reveal-first-invalid.d.ts +12 -0
- package/declarations/-private/reveal-first-invalid.d.ts.map +1 -0
- package/declarations/components/validated-form/field-base.d.ts +17 -1
- package/declarations/components/validated-form/field-base.d.ts.map +1 -1
- package/declarations/components/validated-form/field-combo-box.d.ts +2 -0
- package/declarations/components/validated-form/field-combo-box.d.ts.map +1 -1
- package/declarations/components/validated-form/field-dual-range-slider.d.ts +2 -0
- package/declarations/components/validated-form/field-dual-range-slider.d.ts.map +1 -1
- package/declarations/components/validated-form/field-markdown-editor.d.ts +10 -1
- package/declarations/components/validated-form/field-markdown-editor.d.ts.map +1 -1
- package/declarations/components/validated-form/field-range-slider.d.ts +2 -0
- package/declarations/components/validated-form/field-range-slider.d.ts.map +1 -1
- package/declarations/components/validated-form.d.ts +12 -1
- package/declarations/components/validated-form.d.ts.map +1 -1
- package/dist/-private/lazy-component.js +46 -0
- package/dist/-private/lazy-component.js.map +1 -0
- package/dist/-private/reveal-first-invalid.js +35 -0
- package/dist/-private/reveal-first-invalid.js.map +1 -0
- package/dist/components/validated-form/field-base.js +66 -18
- package/dist/components/validated-form/field-base.js.map +1 -1
- package/dist/components/validated-form/field-combo-box.js +7 -3
- package/dist/components/validated-form/field-combo-box.js.map +1 -1
- package/dist/components/validated-form/field-dual-range-slider.js +8 -4
- package/dist/components/validated-form/field-dual-range-slider.js.map +1 -1
- package/dist/components/validated-form/field-markdown-editor.js +10 -4
- package/dist/components/validated-form/field-markdown-editor.js.map +1 -1
- package/dist/components/validated-form/field-range-slider.js +8 -4
- package/dist/components/validated-form/field-range-slider.js.map +1 -1
- package/dist/components/validated-form.js +74 -18
- package/dist/components/validated-form.js.map +1 -1
- package/package.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-combo-box.js","sources":["../../../src/components/validated-form/field-combo-box.gts"],"sourcesContent":["import { fn } from '@ember/helper';\nimport { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport
|
|
1
|
+
{"version":3,"file":"field-combo-box.js","sources":["../../../src/components/validated-form/field-combo-box.gts"],"sourcesContent":["import { fn } from '@ember/helper';\nimport { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport optional from '@nullvoxpopuli/ember-composable-helpers/helpers/optional';\nimport queue from '@nullvoxpopuli/ember-composable-helpers/helpers/queue';\nimport { not, or } from 'ember-truth-helpers';\n\nimport { LazyComponent } from '../../-private/lazy-component.ts';\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type EuiComboBox from '@ember-eui/core/components/eui-combo-box';\nimport type { EuiComboBoxSignature } from '@ember-eui/core/components/eui-combo-box';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\n/**\n * A validated combo box in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldComboBoxSignature {\n Element: EuiComboBoxSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiComboBoxSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render (same as `@autoFocus`). */\n autofocus?: boolean;\n /** Called with the selected options. */\n onChange?: (options: any[]) => void;\n /** Placeholder text. */\n placeholder?: string;\n /** The options, see the control. */\n options?: EuiComboBoxSignature['Args']['options'];\n /** The selected options. */\n selectedOptions?: EuiComboBoxSignature['Args']['selectedOptions'];\n };\n Blocks: {\n label: EuiFormRowSignature['Blocks']['label'];\n helpText: EuiFormRowSignature['Blocks']['helpText'];\n default: EuiComboBoxSignature['Blocks']['default'];\n };\n}\n\n// imported on first render (see LazyComponent)\nconst euiComboBox = new LazyComponent<typeof EuiComboBox>(\n () => import('@ember-eui/core/components/eui-combo-box')\n);\n\nexport default class ValidatedFormFieldComboBox extends ValidatedFormFieldBase<FieldComboBoxSignature> {\n validationProperty = 'args.selectedOptions';\n\n @action\n //@ts-expect-error\n handleChange(options: any[]) {\n this.args.onChange(options);\n this.notifyValidityChange();\n }\n\n get EuiComboBox() {\n return euiComboBox.component;\n }\n\n <template>\n {{#let this.EuiComboBox as |EuiComboBox|}}\n {{#if EuiComboBox}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @selectedOptions}}\n >\n <:label>\n {{yield to=\"label\"}}\n </:label>\n <:field>\n {{#let\n (component\n EuiComboBox\n onChange=this.handleChange\n options=this.options\n singleSelection=@singleSelection\n selectedOptions=@selectedOptions\n searchEnabled=(argOrDefault @searchEnabled true)\n searchField=@searchField\n search=@search\n searchMessage=@searchMessage\n searchMessageComponent=@searchMessageComponent\n searchPlaceholder=@searchPlaceholder\n placeholder=@placeholder\n placeholderComponent=@placeholderComponent\n loadingMessage=@loadingMessage\n noMatchesMessage=@noMatchesMessage\n noMatchesMessageComponent=@noMatchesMessageComponent\n beforeOptionsComponent=@beforeOptionsComponent\n afterOptionsComponent=@afterOptionsComponent\n selectedItemComponent=@selectedItemComponent\n dropdownClass=@dropdownClass\n optionsClass=@optionsClass\n onCreateOption=@onCreateOption\n alwaysShowCreateOption=@alwaysShowCreateOption\n customOptionText=@customOptionText\n delimiter=@delimiter\n isCaseSensitive=@isCaseSensitive\n sortMatchesBy=@sortMatchesBy\n matcher=@matcher\n optionMatcher=@optionMatcher\n typeAheadOptionMatcher=@typeAheadOptionMatcher\n async=@async\n onSearchChange=@onSearchChange\n noSuggestions=@noSuggestions\n truncationProps=@truncationProps\n rowHeight=@rowHeight\n onFocusBadge=@onFocusBadge\n prepend=@prepend\n append=@append\n triggerIcon=@triggerIcon\n isInvalid=this.isInvalidAndTouched\n isClearable=@isClearable\n isLoading=@isLoading\n isDisabled=@isDisabled\n readOnly=@readOnly\n fullWidth=@fullWidth\n compressed=@compressed\n closeOnSelect=@closeOnSelect\n autoFocus=(or @autoFocus @autofocus)\n initiallyOpen=@initiallyOpen\n defaultHighlighted=@defaultHighlighted\n matchTriggerWidth=@matchTriggerWidth\n renderInPlace=@renderInPlace\n horizontalPosition=@horizontalPosition\n verticalPosition=@verticalPosition\n destination=@destination\n preventScroll=@preventScroll\n calculatePosition=@calculatePosition\n eventType=@eventType\n tabindex=@tabindex\n ariaLabel=@ariaLabel\n ariaLabelledBy=@ariaLabelledBy\n required=@required\n triggerRole=@triggerRole\n title=@title\n triggerId=@triggerId\n removeTag=@removeTag\n onInput=@onInput\n onKeydown=@onKeydown\n registerApi=@registerApi\n onBlur=(queue (fn this.setIsTouched true) (optional @onBlur))\n onFocus=@onFocus\n onClose=@onClose\n onOpen=@onOpen\n extra=@extra\n )\n as |ComboBox|\n }}\n {{#if (has-block)}}\n <ComboBox class={{@fieldClasses}} ...attributes as |opt index search|>\n {{yield opt index search}}\n </ComboBox>\n {{else}}\n {{! without a block, EuiComboBox renders the option labels }}\n <ComboBox class={{@fieldClasses}} ...attributes />\n {{/if}}\n {{/let}}\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n {{/let}}\n </template>\n}\n"],"names":["euiComboBox","LazyComponent","ValidatedFormFieldComboBox","ValidatedFormFieldBase","validationProperty","handleChange","options","args","onChange","notifyValidityChange","n","prototype","action","EuiComboBox","component","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","or","queue","fn","optional"],"mappings":";;;;;;;;;;;;;;;;AAuDA;AACA,MAAMA,cAAc,IAAIC,aAAA,CACtB,MAAM,OAAO,0CAAA,CAAA,CAAA;AAGA,MAAMC,mCAAmCC,sBAAA,CAAuB;AAC7EC,EAAAA,kBAAA,GAAqB,sBAAA;AAGrB;EACAC,YAAAA,CAAaC,OAAc,EAAE;AAC3B,IAAA,IAAI,CAACC,IAAI,CAACC,QAAQ,CAACF,OAAA,CAAA;IACnB,IAAI,CAACG,oBAAoB,EAAA;AAC3B,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;EAOD,IAAIC,WAAAA,GAAc;IAChB,OAAOb,YAAYc,SAAS;AAC9B,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,0gHAAA,EA4HA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;QAAAC,EAAA;QAAAC,KAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
3
3
|
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
4
|
-
import EuiDualRange from '@ember-eui/core/components/eui-dual-range';
|
|
5
4
|
import EuiFormRow from '@ember-eui/core/components/eui-form-row';
|
|
6
5
|
import { argOrDefault } from '@ember-eui/core/helpers';
|
|
7
6
|
import { not } from 'ember-truth-helpers';
|
|
7
|
+
import { LazyComponent } from '../../-private/lazy-component.js';
|
|
8
8
|
import randomId from '../../-private/random-id.js';
|
|
9
9
|
import ValidatedFormFieldBase from './field-base.js';
|
|
10
10
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
11
11
|
import { setComponentTemplate } from '@ember/component';
|
|
12
12
|
import { n } from 'decorator-transforms/runtime-esm';
|
|
13
13
|
|
|
14
|
+
// imported on first render (see LazyComponent)
|
|
15
|
+
const euiDualRange = new LazyComponent(() => import('@ember-eui/core/components/eui-dual-range'));
|
|
14
16
|
class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
15
17
|
//@ts-expect-error
|
|
16
18
|
handleChange(e, _isValid, _event) {
|
|
@@ -22,8 +24,11 @@ class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
|
22
24
|
static {
|
|
23
25
|
n(this.prototype, "handleChange", [action]);
|
|
24
26
|
}
|
|
27
|
+
get EuiDualRange() {
|
|
28
|
+
return euiDualRange.component;
|
|
29
|
+
}
|
|
25
30
|
static {
|
|
26
|
-
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n
|
|
31
|
+
setComponentTemplate(precompileTemplate("{{#let this.EuiDualRange as |EuiDualRange|}}\n {{#if EuiDualRange}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiDualRange class={{@fieldClasses}} form={{@formId}} @value={{@value}} @fullWidth={{@fullWidth}} @isInvalid={{this.isInvalidAndTouched}} @levels={{@levels}} @showLabels={{@showLabels}} @showInput={{@showInput}} @tickInterval={{@tickInterval}} @ticks={{@ticks}} aria-label={{@ariaLabel}} @disabled={{@disabled}} @compressed={{@compressed}} @showRange={{@showRange}} @showTicks={{@showTicks}} @readOnly={{@readOnly}} @id={{theId}} @step={{@step}} @onChange={{this.handleChange}} @max={{@max}} @min={{@min}} @isPrependProvided={{has-block \"prepend\"}} @isAppendProvided={{has-block \"append\"}} @isFakeMinBlock={{not (has-block \"min\")}} @isFakeMaxBlock={{not (has-block \"max\")}} autofocus={{@autofocus}} ...attributes>\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:min>\n {{yield to=\"min\"}}\n </:min>\n <:max>\n {{yield to=\"max\"}}\n </:max>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiDualRange>\n </:field>\n\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n{{/let}}", {
|
|
27
32
|
strictMode: true,
|
|
28
33
|
scope: () => ({
|
|
29
34
|
argOrDefault,
|
|
@@ -31,8 +36,7 @@ class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
|
31
36
|
EuiFormRow,
|
|
32
37
|
not,
|
|
33
38
|
didInsert,
|
|
34
|
-
didUpdate
|
|
35
|
-
EuiDualRange
|
|
39
|
+
didUpdate
|
|
36
40
|
})
|
|
37
41
|
}), this);
|
|
38
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-dual-range-slider.js","sources":["../../../src/components/validated-form/field-dual-range-slider.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport
|
|
1
|
+
{"version":3,"file":"field-dual-range-slider.js","sources":["../../../src/components/validated-form/field-dual-range-slider.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport { not } from 'ember-truth-helpers';\n\nimport { LazyComponent } from '../../-private/lazy-component.ts';\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type EuiDualRange from '@ember-eui/core/components/eui-dual-range';\nimport type {\n EuiDualRangeSignature,\n ValueMember\n} from '@ember-eui/core/components/eui-dual-range';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\n/**\n * A validated dual range slider in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldDualRangeSliderSignature {\n Element: EuiDualRangeSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiDualRangeSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Disables the control. */\n disabled?: boolean;\n /** Compressed control. */\n compressed?: boolean;\n /** @deprecated Has no effect. */\n hasFocus?: boolean;\n /** Shows a spinner. */\n isLoading?: boolean;\n /** Read-only control. */\n readOnly?: boolean;\n /** Icon of the control. */\n icon?: string;\n\n /** Called with `[lower, upper]`. */\n onChange?: (value: [ValueMember, ValueMember]) => void;\n };\n Blocks: {\n label: [];\n helpText: [...EuiFormRowSignature['Blocks']['helpText']];\n prepend: [...EuiDualRangeSignature['Blocks']['prepend']];\n min: [...EuiDualRangeSignature['Blocks']['min']];\n append: [...EuiDualRangeSignature['Blocks']['append']];\n max: [...EuiDualRangeSignature['Blocks']['max']];\n };\n}\n\n// imported on first render (see LazyComponent)\nconst euiDualRange = new LazyComponent<typeof EuiDualRange>(\n () => import('@ember-eui/core/components/eui-dual-range')\n);\n\nexport default class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase<FieldDualRangeSliderSignature> {\n @action\n //@ts-expect-error\n handleChange(\n e: [ValueMember, ValueMember],\n _isValid: boolean,\n _event: Event\n ) {\n // The received event for the dual range is an array with [min, max] as strings\n const value = [Number(e[0]), Number(e[1])];\n\n this.args.onChange(value);\n this.notifyValidityChange();\n }\n\n get EuiDualRange() {\n return euiDualRange.component;\n }\n\n <template>\n {{#let this.EuiDualRange as |EuiDualRange|}}\n {{#if EuiDualRange}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @value}}\n >\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiDualRange\n class={{@fieldClasses}}\n form={{@formId}}\n @value={{@value}}\n @fullWidth={{@fullWidth}}\n @isInvalid={{this.isInvalidAndTouched}}\n @levels={{@levels}}\n @showLabels={{@showLabels}}\n @showInput={{@showInput}}\n @tickInterval={{@tickInterval}}\n @ticks={{@ticks}}\n aria-label={{@ariaLabel}}\n @disabled={{@disabled}}\n @compressed={{@compressed}}\n @showRange={{@showRange}}\n @showTicks={{@showTicks}}\n @readOnly={{@readOnly}}\n @id={{theId}}\n @step={{@step}}\n @onChange={{this.handleChange}}\n @max={{@max}}\n @min={{@min}}\n @isPrependProvided={{has-block \"prepend\"}}\n @isAppendProvided={{has-block \"append\"}}\n @isFakeMinBlock={{not (has-block \"min\")}}\n @isFakeMaxBlock={{not (has-block \"max\")}}\n autofocus={{@autofocus}}\n ...attributes\n >\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:min>\n {{yield to=\"min\"}}\n </:min>\n <:max>\n {{yield to=\"max\"}}\n </:max>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiDualRange>\n </:field>\n\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n {{/let}}\n </template>\n}\n"],"names":["euiDualRange","LazyComponent","ValidatedFormFieldRangeSlider","ValidatedFormFieldBase","handleChange","e","_isValid","_event","value","Number","args","onChange","notifyValidityChange","n","prototype","action","EuiDualRange","component","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate"],"mappings":";;;;;;;;;;;;;AAiEA;AACA,MAAMA,eAAe,IAAIC,aAAA,CACvB,MAAM,OAAO,2CAAA,CAAA,CAAA;AAGA,MAAMC,sCAAsCC,sBAAA,CAAuB;AAEhF;AACAC,EAAAA,YAAAA,CACEC,CAA6B,EAC7BC,QAAiB,EACjBC,MAAa,EACb;AACA;AACA,IAAA,MAAMC,KAAA,GAAQ,CAACC,MAAA,CAAOJ,CAAC,CAAC,CAAA,CAAE,CAAA,EAAGI,MAAA,CAAOJ,CAAC,CAAC,CAAA,CAAE,CAAA,CAAE;AAE1C,IAAA,IAAI,CAACK,IAAI,CAACC,QAAQ,CAACH,KAAA,CAAA;IACnB,IAAI,CAACI,oBAAoB,EAAA;AAC3B,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAZCC,MAAA,CAAA,CAAA;AAAA;EAcD,IAAIC,YAAAA,GAAe;IACjB,OAAOhB,aAAaiB,SAAS;AAC/B,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,+mEAAA,EAgFA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -2,26 +2,33 @@ import { action } from '@ember/object';
|
|
|
2
2
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
3
3
|
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
4
4
|
import EuiFormRow from '@ember-eui/core/components/eui-form-row';
|
|
5
|
-
import EuiMarkdownEditor from '@ember-eui/core/components/eui-markdown-editor';
|
|
6
5
|
import { argOrDefault } from '@ember-eui/core/helpers';
|
|
7
6
|
import { not } from 'ember-truth-helpers';
|
|
7
|
+
import { LazyComponent } from '../../-private/lazy-component.js';
|
|
8
8
|
import randomId from '../../-private/random-id.js';
|
|
9
9
|
import ValidatedFormFieldBase from './field-base.js';
|
|
10
10
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
11
11
|
import { setComponentTemplate } from '@ember/component';
|
|
12
12
|
import { n } from 'decorator-transforms/runtime-esm';
|
|
13
13
|
|
|
14
|
+
// imported on first render without `@editorComponent` (see LazyComponent)
|
|
15
|
+
const euiMarkdownEditor = new LazyComponent(() => import('@ember-eui/core/components/eui-markdown-editor'));
|
|
14
16
|
class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase {
|
|
15
17
|
//@ts-expect-error
|
|
16
18
|
handleChange(str) {
|
|
17
19
|
this.args.onChange(str);
|
|
18
20
|
this.notifyValidityChange();
|
|
19
21
|
}
|
|
22
|
+
// `@editorComponent` takes any component: it gets the editor's args and
|
|
23
|
+
// attributes, unchecked
|
|
20
24
|
static {
|
|
21
25
|
n(this.prototype, "handleChange", [action]);
|
|
22
26
|
}
|
|
27
|
+
get MarkdownEditor() {
|
|
28
|
+
return this.args.editorComponent ?? euiMarkdownEditor.component;
|
|
29
|
+
}
|
|
23
30
|
static {
|
|
24
|
-
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n
|
|
31
|
+
setComponentTemplate(precompileTemplate("{{#let this.MarkdownEditor as |MarkdownEditor|}}\n {{#if MarkdownEditor}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label as |label|>\n {{yield label to=\"label\"}}\n </:label>\n <:field>\n <MarkdownEditor class={{@fieldClasses}} form={{@formId}} aria-label={{@ariaLabel}} @value={{@value}} @isInvalid={{this.isInvalidAndTouched}} @disabled={{@disabled}} @editorId={{theId}} @onChange={{this.handleChange}} @ariaDescribedBy={{@ariaDescribedBy}} @ariaLabel={{@ariaLabel}} @ariaLabelledBy={{@ariaLabelledBy}} autofocus={{@autofocus}} placeholder={{@placeholder}} @onParse={{@onParse}} @parsingPluginList={{@parsingPluginList}} @uiPlugins={{@uiPlugins}} @height={{@height}} @maxHeight={{@maxHeight}} @autoExpandPreview={{@autoExpandPreview}} @initialViewMode={{@initialViewMode}} ...attributes />\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n{{/let}}", {
|
|
25
32
|
strictMode: true,
|
|
26
33
|
scope: () => ({
|
|
27
34
|
argOrDefault,
|
|
@@ -29,8 +36,7 @@ class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase {
|
|
|
29
36
|
EuiFormRow,
|
|
30
37
|
not,
|
|
31
38
|
didInsert,
|
|
32
|
-
didUpdate
|
|
33
|
-
EuiMarkdownEditor
|
|
39
|
+
didUpdate
|
|
34
40
|
})
|
|
35
41
|
}), this);
|
|
36
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-markdown-editor.js","sources":["../../../src/components/validated-form/field-markdown-editor.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport
|
|
1
|
+
{"version":3,"file":"field-markdown-editor.js","sources":["../../../src/components/validated-form/field-markdown-editor.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport { not } from 'ember-truth-helpers';\n\nimport { LazyComponent } from '../../-private/lazy-component.ts';\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\nimport type EuiMarkdownEditor from '@ember-eui/core/components/eui-markdown-editor';\nimport type { EuiMarkdownEditorSignature } from '@ember-eui/core/components/eui-markdown-editor';\nimport type { ComponentLike } from '@glint/template';\n\n/**\n * A validated markdown editor in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldMarkdownEditorSignature {\n Element: EuiMarkdownEditorSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiMarkdownEditorSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Called with the markdown text. */\n onChange?: (value: string) => void;\n /** Placeholder text. */\n placeholder?: string;\n /**\n * Renders this editor instead of EuiMarkdownEditor (which is then\n * never loaded), with the same args.\n */\n editorComponent?: ComponentLike;\n };\n Blocks: {\n label: [...EuiFormRowSignature['Blocks']['label']];\n helpText: [...EuiFormRowSignature['Blocks']['helpText']];\n };\n}\n\ntype MarkdownEditorLike = ComponentLike<{\n Element: FieldMarkdownEditorSignature['Element'];\n Args: Record<string, any>;\n}>;\n\n// imported on first render without `@editorComponent` (see LazyComponent)\nconst euiMarkdownEditor = new LazyComponent<typeof EuiMarkdownEditor>(\n () => import('@ember-eui/core/components/eui-markdown-editor')\n);\n\nexport default class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase<FieldMarkdownEditorSignature> {\n @action\n //@ts-expect-error\n handleChange(str: string) {\n this.args.onChange(str);\n this.notifyValidityChange();\n }\n\n // `@editorComponent` takes any component: it gets the editor's args and\n // attributes, unchecked\n get MarkdownEditor(): MarkdownEditorLike | undefined {\n return (this.args.editorComponent ?? euiMarkdownEditor.component) as\n | MarkdownEditorLike\n | undefined;\n }\n\n <template>\n {{#let this.MarkdownEditor as |MarkdownEditor|}}\n {{#if MarkdownEditor}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @value}}\n >\n <:label as |label|>\n {{yield label to=\"label\"}}\n </:label>\n <:field>\n <MarkdownEditor\n class={{@fieldClasses}}\n form={{@formId}}\n aria-label={{@ariaLabel}}\n @value={{@value}}\n @isInvalid={{this.isInvalidAndTouched}}\n @disabled={{@disabled}}\n @editorId={{theId}}\n @onChange={{this.handleChange}}\n @ariaDescribedBy={{@ariaDescribedBy}}\n @ariaLabel={{@ariaLabel}}\n @ariaLabelledBy={{@ariaLabelledBy}}\n autofocus={{@autofocus}}\n placeholder={{@placeholder}}\n @onParse={{@onParse}}\n @parsingPluginList={{@parsingPluginList}}\n @uiPlugins={{@uiPlugins}}\n @height={{@height}}\n @maxHeight={{@maxHeight}}\n @autoExpandPreview={{@autoExpandPreview}}\n @initialViewMode={{@initialViewMode}}\n ...attributes\n />\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n {{/let}}\n </template>\n}\n"],"names":["euiMarkdownEditor","LazyComponent","ValidatedFormFieldMarkdownEditor","ValidatedFormFieldBase","handleChange","str","args","onChange","notifyValidityChange","n","prototype","action","MarkdownEditor","editorComponent","component","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate"],"mappings":";;;;;;;;;;;;;AA0DA;AACA,MAAMA,oBAAoB,IAAIC,aAAA,CAC5B,MAAM,OAAO,gDAAA,CAAA,CAAA;AAGA,MAAMC,yCAAyCC,sBAAA,CAAuB;AAEnF;EACAC,YAAAA,CAAaC,GAAW,EAAE;AACxB,IAAA,IAAI,CAACC,IAAI,CAACC,QAAQ,CAACF,GAAA,CAAA;IACnB,IAAI,CAACG,oBAAoB,EAAA;AAC3B,EAAA;AAEA;AACA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CARCC,MAAA,CAAA,CAAA;AAAA;EASD,IAAIC,cAAAA,GAAiD;IACnD,OAAQ,IAAI,CAACN,IAAI,CAACO,eAAe,IAAIb,iBAAA,CAAkBc,SAAS;AAGlE,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,6nDAAA,EA2DA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
2
2
|
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
3
3
|
import EuiFormRow from '@ember-eui/core/components/eui-form-row';
|
|
4
|
-
import EuiRange from '@ember-eui/core/components/eui-range';
|
|
5
4
|
import { argOrDefault } from '@ember-eui/core/helpers';
|
|
6
5
|
import { not } from 'ember-truth-helpers';
|
|
6
|
+
import { LazyComponent } from '../../-private/lazy-component.js';
|
|
7
7
|
import randomId from '../../-private/random-id.js';
|
|
8
8
|
import ValidatedFormFieldBase from './field-base.js';
|
|
9
9
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
10
|
import { setComponentTemplate } from '@ember/component';
|
|
11
11
|
|
|
12
|
+
// imported on first render (see LazyComponent)
|
|
13
|
+
const euiRange = new LazyComponent(() => import('@ember-eui/core/components/eui-range'));
|
|
12
14
|
class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
15
|
+
get EuiRange() {
|
|
16
|
+
return euiRange.component;
|
|
17
|
+
}
|
|
13
18
|
static {
|
|
14
|
-
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n
|
|
19
|
+
setComponentTemplate(precompileTemplate("{{#let this.EuiRange as |EuiRange|}}\n {{#if EuiRange}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiRange class={{@fieldClasses}} form={{@formId}} @compressed={{@compressed}} @readOnly={{@readOnly}} @fullWidth={{@fullWidth}} @id={{theId}} @levels={{@levels}} @step={{@step}} @showInput={{@showInput}} @showLabels={{@showLabels}} @showRange={{@showRange}} @showTicks={{@showTicks}} @showValue={{@showValue}} @disabled={{@disabled}} @ticks={{@ticks}} @tickInterval={{@tickInterval}} @valuePrepend={{@valuePrepend}} @valueAppend={{@valueAppend}} @onChange={{this.handleChange}} @value={{@value}} @max={{@max}} @isLoading={{@isLoading}} @min={{@min}} @isInvalid={{this.isInvalidAndTouched}} @isPrependProvided={{has-block \"prepend\"}} @isAppendProvided={{has-block \"append\"}} @isFakeMinBlock={{not (has-block \"min\")}} @isFakeMaxBlock={{not (has-block \"max\")}} @isFakeValueBlock={{not (has-block \"value\")}} @isFakeValuePrependBlock={{not (has-block \"valuePrepend\")}} @isFakeValueAppendBlock={{not (has-block \"valueAppend\")}} aria-label={{@ariaLabel}} autofocus={{@autofocus}} ...attributes>\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:min as |min|>\n {{yield min to=\"min\"}}\n </:min>\n <:valuePrepend>\n {{yield to=\"valuePrepend\"}}\n </:valuePrepend>\n <:value>\n {{yield to=\"value\"}}\n </:value>\n <:valueAppend>\n {{yield to=\"valueAppend\"}}\n </:valueAppend>\n <:max as |max|>\n {{yield max to=\"max\"}}\n </:max>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiRange>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}} \n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n{{/let}}", {
|
|
15
20
|
strictMode: true,
|
|
16
21
|
scope: () => ({
|
|
17
22
|
argOrDefault,
|
|
@@ -19,8 +24,7 @@ class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
|
19
24
|
EuiFormRow,
|
|
20
25
|
not,
|
|
21
26
|
didInsert,
|
|
22
|
-
didUpdate
|
|
23
|
-
EuiRange
|
|
27
|
+
didUpdate
|
|
24
28
|
})
|
|
25
29
|
}), this);
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-range-slider.js","sources":["../../../src/components/validated-form/field-range-slider.gts"],"sourcesContent":["import didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport
|
|
1
|
+
{"version":3,"file":"field-range-slider.js","sources":["../../../src/components/validated-form/field-range-slider.gts"],"sourcesContent":["import didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport { not } from 'ember-truth-helpers';\n\nimport { LazyComponent } from '../../-private/lazy-component.ts';\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\nimport type EuiRange from '@ember-eui/core/components/eui-range';\nimport type { EuiRangeSignature } from '@ember-eui/core/components/eui-range';\n\n/**\n * A validated range slider in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldRangeSliderSignature {\n Element: EuiRangeSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiRangeSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Called with the slider's value (a string). */\n onChange?: (value: string) => void;\n };\n Blocks: {\n label: [];\n helpText: [...EuiFormRowSignature['Blocks']['helpText']];\n prepend: [...EuiRangeSignature['Blocks']['prepend']];\n min: [...EuiRangeSignature['Blocks']['min']];\n valuePrepend: [...EuiRangeSignature['Blocks']['valuePrepend']];\n value: [...EuiRangeSignature['Blocks']['value']];\n valueAppend: [...EuiRangeSignature['Blocks']['valueAppend']];\n append: [...EuiRangeSignature['Blocks']['append']];\n max: [...EuiRangeSignature['Blocks']['max']];\n };\n}\n\n// imported on first render (see LazyComponent)\nconst euiRange = new LazyComponent<typeof EuiRange>(\n () => import('@ember-eui/core/components/eui-range')\n);\n\nexport default class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase<FieldRangeSliderSignature> {\n get EuiRange() {\n return euiRange.component;\n }\n\n <template>\n {{#let this.EuiRange as |EuiRange|}}\n {{#if EuiRange}}\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @value}}\n >\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiRange\n class={{@fieldClasses}}\n form={{@formId}}\n @compressed={{@compressed}}\n @readOnly={{@readOnly}}\n @fullWidth={{@fullWidth}}\n @id={{theId}}\n @levels={{@levels}}\n @step={{@step}}\n @showInput={{@showInput}}\n @showLabels={{@showLabels}}\n @showRange={{@showRange}}\n @showTicks={{@showTicks}}\n @showValue={{@showValue}}\n @disabled={{@disabled}}\n @ticks={{@ticks}}\n @tickInterval={{@tickInterval}}\n @valuePrepend={{@valuePrepend}}\n @valueAppend={{@valueAppend}}\n @onChange={{this.handleChange}}\n @value={{@value}}\n @max={{@max}}\n @isLoading={{@isLoading}}\n @min={{@min}}\n @isInvalid={{this.isInvalidAndTouched}}\n @isPrependProvided={{has-block \"prepend\"}}\n @isAppendProvided={{has-block \"append\"}}\n @isFakeMinBlock={{not (has-block \"min\")}}\n @isFakeMaxBlock={{not (has-block \"max\")}}\n @isFakeValueBlock={{not (has-block \"value\")}}\n @isFakeValuePrependBlock={{not (has-block \"valuePrepend\")}}\n @isFakeValueAppendBlock={{not (has-block \"valueAppend\")}}\n aria-label={{@ariaLabel}}\n autofocus={{@autofocus}}\n ...attributes\n >\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:min as |min|>\n {{yield min to=\"min\"}}\n </:min>\n <:valuePrepend>\n {{yield to=\"valuePrepend\"}}\n </:valuePrepend>\n <:value>\n {{yield to=\"value\"}}\n </:value>\n <:valueAppend>\n {{yield to=\"valueAppend\"}}\n </:valueAppend>\n <:max as |max|>\n {{yield max to=\"max\"}}\n </:max>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiRange>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}} \n </:helpText>\n </EuiFormRow>\n {{/let}}\n {{/if}}\n {{/let}}\n </template>\n}\n"],"names":["euiRange","LazyComponent","ValidatedFormFieldRangeSlider","ValidatedFormFieldBase","EuiRange","component","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate"],"mappings":";;;;;;;;;;;AAmDA;AACA,MAAMA,WAAW,IAAIC,aAAA,CACnB,MAAM,OAAO,sCAAA,CAAA,CAAA;AAGA,MAAMC,sCAAsCC,sBAAA,CAAuB;EAChF,IAAIC,QAAAA,GAAW;IACb,OAAOJ,SAASK,SAAS;AAC3B,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,grFAAA,EA+FA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -5,10 +5,11 @@ import { hash } from '@ember/helper';
|
|
|
5
5
|
import { on } from '@ember/modifier';
|
|
6
6
|
import { action, set } from '@ember/object';
|
|
7
7
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
8
|
-
import { schedule,
|
|
8
|
+
import { schedule, scheduleOnce } from '@ember/runloop';
|
|
9
9
|
import EuiForm from '@ember-eui/core/components/eui-form';
|
|
10
10
|
import { argOrDefault } from '@ember-eui/core/helpers';
|
|
11
11
|
import randomId from '../-private/random-id.js';
|
|
12
|
+
import { revealFirstInvalid } from '../-private/reveal-first-invalid.js';
|
|
12
13
|
import { ValidatedFormDefaultTheme } from './default-theme.js';
|
|
13
14
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
14
15
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -70,21 +71,59 @@ class ValidatedFormComponent extends Component {
|
|
|
70
71
|
get isInvalidAndTouched() {
|
|
71
72
|
return this.isInvalid && this.isTouched;
|
|
72
73
|
}
|
|
74
|
+
// The registered children that are invalid or touched. The child that
|
|
75
|
+
// changed updates them (see onChildValidityChange), so a keystroke costs
|
|
76
|
+
// the same whatever the number of fields.
|
|
77
|
+
children = new Set();
|
|
78
|
+
invalidChildren = new Set();
|
|
79
|
+
touchedChildren = new Set();
|
|
73
80
|
addChild(child) {
|
|
74
81
|
this.childComponents.pushObject(child);
|
|
82
|
+
this.children.add(child);
|
|
83
|
+
this.updateChild(child);
|
|
75
84
|
this.triggerValidityChange();
|
|
76
85
|
}
|
|
77
86
|
removeChild(child) {
|
|
78
87
|
this.childComponents.removeObject(child);
|
|
88
|
+
this.children.delete(child);
|
|
89
|
+
this.invalidChildren.delete(child);
|
|
90
|
+
this.touchedChildren.delete(child);
|
|
91
|
+
}
|
|
92
|
+
updateChild(child) {
|
|
93
|
+
if (child.isValid) {
|
|
94
|
+
this.invalidChildren.delete(child);
|
|
95
|
+
} else {
|
|
96
|
+
this.invalidChildren.add(child);
|
|
97
|
+
}
|
|
98
|
+
if (child.isTouched) {
|
|
99
|
+
this.touchedChildren.add(child);
|
|
100
|
+
} else {
|
|
101
|
+
this.touchedChildren.delete(child);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Children that do not say what changed (nested forms, app fields), and
|
|
105
|
+
// submitting, read every child again.
|
|
106
|
+
updateChildren() {
|
|
107
|
+
this.invalidChildren.clear();
|
|
108
|
+
this.touchedChildren.clear();
|
|
109
|
+
this.childComponents.forEach(child => this.updateChild(child));
|
|
79
110
|
}
|
|
80
111
|
async handleSubmit(e) {
|
|
81
112
|
if (e.target !== e.currentTarget) {
|
|
82
113
|
return;
|
|
83
114
|
}
|
|
84
115
|
e.preventDefault();
|
|
116
|
+
const form = e.currentTarget;
|
|
117
|
+
// app fields may not report their changes
|
|
118
|
+
this.updateChildren();
|
|
119
|
+
this.flushValidity();
|
|
85
120
|
if (this.isInvalid) {
|
|
86
121
|
this.setIsTouched(true);
|
|
87
122
|
this.args.onInvalid?.();
|
|
123
|
+
// fields mark their controls invalid once touched, i.e. in this render
|
|
124
|
+
if (this.args.revealFirstInvalid !== false) {
|
|
125
|
+
schedule('afterRender', null, revealFirstInvalid, form);
|
|
126
|
+
}
|
|
88
127
|
} else {
|
|
89
128
|
this.setIsTouched(false);
|
|
90
129
|
try {
|
|
@@ -134,41 +173,58 @@ class ValidatedFormComponent extends Component {
|
|
|
134
173
|
n(this.prototype, "unregister", [action]);
|
|
135
174
|
}
|
|
136
175
|
updateValidity() {
|
|
176
|
+
this.updateChildren();
|
|
137
177
|
this.triggerValidityChange();
|
|
138
178
|
}
|
|
139
179
|
static {
|
|
140
180
|
n(this.prototype, "updateValidity", [action]);
|
|
141
181
|
}
|
|
142
182
|
getIsValid() {
|
|
143
|
-
return this.
|
|
183
|
+
return this.invalidChildren.size === 0;
|
|
144
184
|
}
|
|
145
185
|
getIsTouched() {
|
|
146
|
-
return this.
|
|
186
|
+
return this.touchedChildren.size > 0;
|
|
147
187
|
}
|
|
148
188
|
triggerValidityChange() {
|
|
149
|
-
|
|
150
|
-
const lastIsTouched = this.isTouched;
|
|
151
|
-
if (lastIsValid !== this.getIsValid() || lastIsTouched !== this.getIsTouched()) {
|
|
189
|
+
if (this.isValid !== this.getIsValid() || this.isTouched !== this.getIsTouched()) {
|
|
152
190
|
this.setNewValidity();
|
|
153
191
|
}
|
|
154
192
|
}
|
|
193
|
+
// After the current render, in the same run loop (it used to wait for the
|
|
194
|
+
// next one); one update however many children changed.
|
|
155
195
|
setNewValidity() {
|
|
156
|
-
|
|
157
|
-
if (this.isDestroying || this.isDestroyed) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
this.isInvalid = !this.getIsValid();
|
|
161
|
-
this.isTouched = this.getIsTouched();
|
|
162
|
-
if (!this.isDestroying) {
|
|
163
|
-
this.args.onValidityChange?.(this.isValid, this.isTouched, this.isInvalidAndTouched);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
196
|
+
scheduleOnce('afterRender', this, this.flushValidity);
|
|
166
197
|
}
|
|
167
198
|
static {
|
|
168
199
|
n(this.prototype, "setNewValidity", [action]);
|
|
169
200
|
}
|
|
170
|
-
|
|
171
|
-
if (
|
|
201
|
+
flushValidity() {
|
|
202
|
+
if (this.isDestroying || this.isDestroyed) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const isInvalid = !this.getIsValid();
|
|
206
|
+
const isTouched = this.getIsTouched();
|
|
207
|
+
// the first flush always reports (as the form's insert did)
|
|
208
|
+
if (this.lastIsValid === !isInvalid && this.lastIsTouched === isTouched) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this.isInvalid = isInvalid;
|
|
212
|
+
this.isTouched = isTouched;
|
|
213
|
+
this.lastIsValid = this.isValid;
|
|
214
|
+
this.lastIsTouched = isTouched;
|
|
215
|
+
this.args.onValidityChange?.(this.isValid, this.isTouched, this.isInvalidAndTouched);
|
|
216
|
+
}
|
|
217
|
+
// Fields call it with `{ child, isValid, isTouched }` when theirs changes;
|
|
218
|
+
// nested forms with their own `(isValid, isTouched, …)`.
|
|
219
|
+
onChildValidityChange(change) {
|
|
220
|
+
if (this.isDestroying) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const child = change?.child;
|
|
224
|
+
if (child && this.children.has(child)) {
|
|
225
|
+
this.updateChild(child);
|
|
226
|
+
this.triggerValidityChange();
|
|
227
|
+
} else {
|
|
172
228
|
this.updateValidity();
|
|
173
229
|
}
|
|
174
230
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validated-form.js","sources":["../../src/components/validated-form.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { A } from '@ember/array';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { action, set } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport { next, schedule } from '@ember/runloop';\nimport EuiForm from '@ember-eui/core/components/eui-form';\nimport { argOrDefault } from '@ember-eui/core/helpers';\nimport type Owner from '@ember/owner';\n\nimport randomId from '../-private/random-id.ts';\nimport { ValidatedFormDefaultTheme } from './default-theme.ts';\n\nimport type { IValidatedFormTheme } from './default-theme';\nimport type FieldBase from './validated-form/field-base.gts';\nimport type { EuiFormSignature } from '@ember-eui/core/components/eui-form';\n\nexport type ValidatedFormChild = FieldBase | ValidatedFormComponent;\n\n// Custom children registered via `register` may not implement `setIsTouched`\n// (e.g. app fields not extending FieldBase), so fall back to setting the property.\nfunction setChildIsTouched(child: ValidatedFormChild, isTouched: boolean) {\n const maybeChild = child as Partial<ValidatedFormChild> | null | undefined;\n\n if (!maybeChild) {\n return;\n }\n\n if (typeof maybeChild.setIsTouched === 'function') {\n maybeChild.setIsTouched(isTouched);\n } else {\n set(maybeChild as { isTouched?: boolean }, 'isTouched', isTouched);\n }\n}\n\n/**\n * A form whose fields validate their own values with ember-validators\n * (`@validations`) or functions (`@customValidations`). Errors show once a\n * field is touched; submitting calls `@onSubmit` only when all fields are\n * valid.\n */\nexport interface ValidatedFormSignature {\n Element: EuiFormSignature['Element'];\n Args: {\n /** Id of the form; fields join it with `form=`. Defaults to a random id. */\n id?: string;\n /** HTML form that owns the fields; inherited by nested forms. */\n formId?: string;\n /** @private Nested forms register with their parent form. */\n register?: (child: ValidatedFormComponent) => void;\n /** @private Nested forms register with their parent form. */\n unregister?: (child: ValidatedFormComponent) => void;\n /** @private */\n addChild?: (child: ValidatedFormChild) => void;\n /** @private */\n removeChild?: (child: ValidatedFormChild) => void;\n /** Called on submit while a field is invalid (all fields show their errors). */\n onInvalid?: () => void;\n /**\n * Called on submit when every field is valid. If it returns a promise\n * that rejects, the fields are marked touched again.\n */\n onSubmit?: () => void | Promise<void>;\n /** Called when the form is reset. */\n onReset?: (e: Event) => void;\n /**\n * Called when the form's validity or touched state changes, e.g. to\n * disable the submit button while invalid.\n */\n onValidityChange?: (\n isValid: boolean,\n isTouched: boolean,\n isInvalidAndTouched: boolean\n ) => void;\n /** Replaces the yielded field components (see the theme docs). */\n theme?: Partial<IValidatedFormTheme>;\n /** Disables every field. */\n isDisabled?: boolean;\n /** Makes every field full width. */\n fullWidth?: boolean;\n /** Compressed fields, for dense forms. */\n compressed?: boolean;\n /** `'form'` (the default) or `'div'`. */\n tagName?: EuiFormSignature['Args']['tagName'];\n /** Shows `@error` in a callout above the form, see EuiForm. */\n isInvalid?: EuiFormSignature['Args']['isInvalid'];\n /** See EuiForm's `@invalidCallout`. */\n invalidCallout?: EuiFormSignature['Args']['invalidCallout'];\n /** Form-level errors, see EuiForm's `@error`. */\n error?: EuiFormSignature['Args']['error'];\n /** Title of the errors callout. */\n errorTitle?: EuiFormSignature['Args']['errorTitle'];\n };\n Blocks: {\n /**\n * Yields the form's state (`isValid`, `isInvalid`, `isTouched`,\n * `isInvalidAndTouched`, `formId`) and its field components, already\n * connected to it: `as |form|` → `<form.FieldText @label=\"Name\"\n * @value={{this.name}} @onChange={{…}} @validations={{…}} />`.\n */\n default: [\n {\n onValidityChange: (\n isValid: boolean,\n isTouched: boolean,\n isInvalidAndTouched: boolean\n ) => void;\n register: (child: ValidatedFormChild) => void;\n unregister: (child: ValidatedFormChild) => void;\n isValid: boolean;\n isInvalid: boolean;\n isTouched: boolean;\n isInvalidAndTouched: boolean;\n formId: string;\n Form: IValidatedFormTheme['FieldNestedForm'];\n FieldNestedForm: IValidatedFormTheme['FieldNestedForm'];\n FieldBase: IValidatedFormTheme['FieldBase'];\n FieldNumber: IValidatedFormTheme['FieldNumber'];\n FieldText: IValidatedFormTheme['FieldText'];\n FieldPassword: IValidatedFormTheme['FieldPassword'];\n FieldTextArea: IValidatedFormTheme['FieldTextArea'];\n FieldSelect: IValidatedFormTheme['FieldSelect'];\n FieldComboBox: IValidatedFormTheme['FieldComboBox'];\n FieldCheckboxGroup: IValidatedFormTheme['FieldCheckboxGroup'];\n FieldRadioGroup: IValidatedFormTheme['FieldRadioGroup'];\n FieldRangeSlider: IValidatedFormTheme['FieldRangeSlider'];\n FieldDualRangeSlider: IValidatedFormTheme['FieldDualRangeSlider'];\n FieldSwitch: IValidatedFormTheme['FieldSwitch'];\n FieldMarkdownEditor: IValidatedFormTheme['FieldMarkdownEditor'];\n }\n ];\n };\n}\n\nexport default class ValidatedFormComponent extends Component<ValidatedFormSignature> {\n @tracked childComponents: ReturnType<typeof A<ValidatedFormChild>> = A<ValidatedFormChild>([]);\n //cache to only notify if changed\n lastIsValid?: boolean;\n lastIsTouched?: boolean;\n\n @tracked isInvalid = false;\n @tracked isTouched = false;\n\n constructor(owner: Owner, args: ValidatedFormSignature['Args']) {\n super(owner, args);\n this.args.register?.(this);\n }\n\n willDestroy() {\n super.willDestroy();\n this.args.unregister?.(this);\n }\n\n get isValid() {\n return !this.isInvalid;\n }\n\n get isInvalidAndTouched() {\n return this.isInvalid && this.isTouched;\n }\n\n addChild(child: ValidatedFormChild) {\n this.childComponents.pushObject(child);\n this.triggerValidityChange();\n }\n\n removeChild(child: ValidatedFormChild) {\n this.childComponents.removeObject(child);\n }\n\n @action\n async handleSubmit(e: Event) {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n e.preventDefault();\n\n if (this.isInvalid) {\n this.setIsTouched(true);\n this.args.onInvalid?.();\n } else {\n this.setIsTouched(false);\n\n try {\n await this.args.onSubmit?.();\n } catch {\n this.setIsTouched(true);\n }\n }\n }\n\n @action\n setIsTouched(isTouched: boolean) {\n this.childComponents.forEach((child) => setChildIsTouched(child, isTouched));\n this.updateValidity();\n }\n\n @action\n handleReset(e: Event) {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n e.preventDefault();\n this.args.onReset?.(e);\n }\n\n @action\n register(child: ValidatedFormChild) {\n if (!this.isDestroyed) {\n schedule('afterRender', this, this.addChild, child);\n }\n }\n\n @action\n unregister(child: ValidatedFormChild) {\n if (!this.isDestroyed) {\n schedule('afterRender', this, this.removeChild, child);\n // When adding a child the validation gets calculated on a `did-insert` modifier\n // for removal there's no modifier so it gets called here\n schedule('afterRender', this, this.triggerValidityChange);\n }\n }\n\n @action\n updateValidity() {\n this.triggerValidityChange();\n }\n\n getIsValid() {\n return this.childComponents.isEvery('isValid');\n }\n\n getIsTouched() {\n return this.childComponents.isAny('isTouched');\n }\n\n triggerValidityChange() {\n const lastIsValid = this.isValid;\n const lastIsTouched = this.isTouched;\n\n if (\n lastIsValid !== this.getIsValid() ||\n lastIsTouched !== this.getIsTouched()\n ) {\n this.setNewValidity();\n }\n }\n\n @action\n setNewValidity() {\n next(() => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n this.isInvalid = !this.getIsValid();\n this.isTouched = this.getIsTouched();\n\n if (!this.isDestroying) {\n this.args.onValidityChange?.(\n this.isValid,\n this.isTouched,\n this.isInvalidAndTouched\n );\n }\n });\n }\n\n @action\n onChildValidityChange() {\n if (!this.isDestroying) {\n this.updateValidity();\n }\n }\n\n @action\n onFocusOut(e: FocusEvent) {\n const targetEuiFormRow = (e.target as HTMLInputElement)?.closest?.('.euiFormRow');\n\n if (!targetEuiFormRow) {\n return;\n }\n\n const field = this.childComponents.find((child) => {\n return 'formRowElement' in child && targetEuiFormRow === child.formRowElement;\n });\n\n if (!field) {\n return;\n }\n\n // Chrome also fires `focusout` when the focused element is removed, which\n // happens while rendering; touching the field then would update tracked\n // state that the same render already read. Defer it until after render.\n schedule('actions', () => {\n if (!field.isDestroying && !field.isDestroyed) {\n setChildIsTouched(field, true);\n }\n });\n }\n\n get theme() {\n const theme: Partial<IValidatedFormTheme> = this.args.theme || {};\n\n return { ...ValidatedFormDefaultTheme, ...theme };\n }\n\n <template>\n {{#let (argOrDefault @id (randomId)) as |formId|}}\n <EuiForm\n @tagName={{argOrDefault @tagName \"form\"}}\n id={{formId}}\n @isInvalid={{@isInvalid}}\n @invalidCallout={{@invalidCallout}}\n @error={{@error}}\n @errorTitle={{@errorTitle}}\n {{on \"submit\" this.handleSubmit}}\n {{on \"reset\" this.handleReset}}\n {{didInsert this.setNewValidity}}\n {{on \"focusout\" this.onFocusOut}}\n ...attributes\n >\n {{yield\n (hash\n onValidityChange=this.onChildValidityChange\n register=this.register\n unregister=this.unregister\n isValid=this.isValid\n isInvalid=this.isInvalid\n isTouched=this.isTouched\n isInvalidAndTouched=this.isInvalidAndTouched\n formId=(argOrDefault @formId formId)\n Form=(component\n this.theme.FieldNestedForm\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n tagName=\"div\"\n formId=(argOrDefault @formId formId)\n theme=this.theme\n isDisabled=@isDisabled\n fullWidth=@fullWidth\n compressed=@compressed\n )\n FieldNestedForm=(component\n this.theme.FieldNestedForm\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n tagName=\"div\"\n formId=(argOrDefault @formId formId)\n theme=this.theme\n isDisabled=@isDisabled\n fullWidth=@fullWidth\n compressed=@compressed\n )\n FieldBase=(component\n this.theme.FieldBase\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldNumber=(component\n this.theme.FieldNumber\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldText=(component\n this.theme.FieldText\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldPassword=(component\n this.theme.FieldPassword\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldTextArea=(component\n this.theme.FieldTextArea\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldSelect=(component\n this.theme.FieldSelect\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldComboBox=(component\n this.theme.FieldComboBox\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n isDisabled=@isDisabled\n )\n FieldCheckboxGroup=(component\n this.theme.FieldCheckboxGroup\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldRadioGroup=(component\n this.theme.FieldRadioGroup\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldRangeSlider=(component\n this.theme.FieldRangeSlider\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldDualRangeSlider=(component\n this.theme.FieldDualRangeSlider\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldSwitch=(component\n this.theme.FieldSwitch\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldMarkdownEditor=(component\n this.theme.FieldMarkdownEditor\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n )\n }}\n </EuiForm>\n {{/let}}\n </template>\n}\n\n// Default theme for ValidatedFormComponent. Do not remove.\nValidatedFormDefaultTheme.FieldNestedForm = ValidatedFormComponent;\n"],"names":["setChildIsTouched","child","isTouched","maybeChild","setIsTouched","set","ValidatedFormComponent","Component","g","prototype","tracked","A","i","lastIsValid","lastIsTouched","constructor","owner","args","register","willDestroy","unregister","isValid","isInvalid","isInvalidAndTouched","addChild","childComponents","pushObject","triggerValidityChange","removeChild","removeObject","handleSubmit","e","target","currentTarget","preventDefault","onInvalid","onSubmit","n","action","forEach","updateValidity","handleReset","onReset","isDestroyed","schedule","getIsValid","isEvery","getIsTouched","isAny","setNewValidity","next","isDestroying","onValidityChange","onChildValidityChange","onFocusOut","targetEuiFormRow","closest","field","find","formRowElement","theme","ValidatedFormDefaultTheme","setComponentTemplate","precompileTemplate","strictMode","scope","argOr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AAA;EA0BD,IAAIsB,KAAAA,GAAQ;IACV,MAAMA,KAAe,GAAuB,IAAI,CAAC3C,IAAI,CAAC2C,KAAK,IAAI,EAAC;IAEhE,OAAO;AAAE,MAAA,GAAGC,yBAAyB;MAAE,GAAGD;KAAM;AAClD,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,00IAAA,EAqLA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,OAAA;QAAAC,EAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA;AACAV,yBAAA,CAA0BW,eAAe,GAAGlE,sBAAA;;"}
|
|
1
|
+
{"version":3,"file":"validated-form.js","sources":["../../src/components/validated-form.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { A } from '@ember/array';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { action, set } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport { schedule, scheduleOnce } from '@ember/runloop';\nimport EuiForm from '@ember-eui/core/components/eui-form';\nimport { argOrDefault } from '@ember-eui/core/helpers';\nimport type Owner from '@ember/owner';\n\nimport randomId from '../-private/random-id.ts';\nimport { revealFirstInvalid } from '../-private/reveal-first-invalid.ts';\nimport { ValidatedFormDefaultTheme } from './default-theme.ts';\n\nimport type { IValidatedFormTheme } from './default-theme';\nimport type FieldBase from './validated-form/field-base.gts';\nimport type { EuiFormSignature } from '@ember-eui/core/components/eui-form';\n\nexport type ValidatedFormChild = FieldBase | ValidatedFormComponent;\n\n// Custom children registered via `register` may not implement `setIsTouched`\n// (e.g. app fields not extending FieldBase), so fall back to setting the property.\nfunction setChildIsTouched(child: ValidatedFormChild, isTouched: boolean) {\n const maybeChild = child as Partial<ValidatedFormChild> | null | undefined;\n\n if (!maybeChild) {\n return;\n }\n\n if (typeof maybeChild.setIsTouched === 'function') {\n maybeChild.setIsTouched(isTouched);\n } else {\n set(maybeChild as { isTouched?: boolean }, 'isTouched', isTouched);\n }\n}\n\n/**\n * A form whose fields validate their own values with ember-validators\n * (`@validations`) or functions (`@customValidations`). Errors show once a\n * field is touched; submitting calls `@onSubmit` only when all fields are\n * valid.\n */\nexport interface ValidatedFormSignature {\n Element: EuiFormSignature['Element'];\n Args: {\n /** Id of the form; fields join it with `form=`. Defaults to a random id. */\n id?: string;\n /** HTML form that owns the fields; inherited by nested forms. */\n formId?: string;\n /** @private Nested forms register with their parent form. */\n register?: (child: ValidatedFormComponent) => void;\n /** @private Nested forms register with their parent form. */\n unregister?: (child: ValidatedFormComponent) => void;\n /** @private */\n addChild?: (child: ValidatedFormChild) => void;\n /** @private */\n removeChild?: (child: ValidatedFormChild) => void;\n /** Called on submit while a field is invalid (all fields show their errors). */\n onInvalid?: () => void;\n /**\n * On a submit with errors, after `@onInvalid`, scroll to the first\n * invalid field and focus its control. Defaults to `true`.\n */\n revealFirstInvalid?: boolean;\n /**\n * Called on submit when every field is valid. If it returns a promise\n * that rejects, the fields are marked touched again.\n */\n onSubmit?: () => void | Promise<void>;\n /** Called when the form is reset. */\n onReset?: (e: Event) => void;\n /**\n * Called when the form's validity or touched state changes, e.g. to\n * disable the submit button while invalid.\n */\n onValidityChange?: (\n isValid: boolean,\n isTouched: boolean,\n isInvalidAndTouched: boolean\n ) => void;\n /** Replaces the yielded field components (see the theme docs). */\n theme?: Partial<IValidatedFormTheme>;\n /** Disables every field. */\n isDisabled?: boolean;\n /** Makes every field full width. */\n fullWidth?: boolean;\n /** Compressed fields, for dense forms. */\n compressed?: boolean;\n /** `'form'` (the default) or `'div'`. */\n tagName?: EuiFormSignature['Args']['tagName'];\n /** Shows `@error` in a callout above the form, see EuiForm. */\n isInvalid?: EuiFormSignature['Args']['isInvalid'];\n /** See EuiForm's `@invalidCallout`. */\n invalidCallout?: EuiFormSignature['Args']['invalidCallout'];\n /** Form-level errors, see EuiForm's `@error`. */\n error?: EuiFormSignature['Args']['error'];\n /** Title of the errors callout. */\n errorTitle?: EuiFormSignature['Args']['errorTitle'];\n };\n Blocks: {\n /**\n * Yields the form's state (`isValid`, `isInvalid`, `isTouched`,\n * `isInvalidAndTouched`, `formId`) and its field components, already\n * connected to it: `as |form|` → `<form.FieldText @label=\"Name\"\n * @value={{this.name}} @onChange={{…}} @validations={{…}} />`.\n */\n default: [\n {\n onValidityChange: (\n isValid: boolean,\n isTouched: boolean,\n isInvalidAndTouched: boolean\n ) => void;\n register: (child: ValidatedFormChild) => void;\n unregister: (child: ValidatedFormChild) => void;\n isValid: boolean;\n isInvalid: boolean;\n isTouched: boolean;\n isInvalidAndTouched: boolean;\n formId: string;\n Form: IValidatedFormTheme['FieldNestedForm'];\n FieldNestedForm: IValidatedFormTheme['FieldNestedForm'];\n FieldBase: IValidatedFormTheme['FieldBase'];\n FieldNumber: IValidatedFormTheme['FieldNumber'];\n FieldText: IValidatedFormTheme['FieldText'];\n FieldPassword: IValidatedFormTheme['FieldPassword'];\n FieldTextArea: IValidatedFormTheme['FieldTextArea'];\n FieldSelect: IValidatedFormTheme['FieldSelect'];\n FieldComboBox: IValidatedFormTheme['FieldComboBox'];\n FieldCheckboxGroup: IValidatedFormTheme['FieldCheckboxGroup'];\n FieldRadioGroup: IValidatedFormTheme['FieldRadioGroup'];\n FieldRangeSlider: IValidatedFormTheme['FieldRangeSlider'];\n FieldDualRangeSlider: IValidatedFormTheme['FieldDualRangeSlider'];\n FieldSwitch: IValidatedFormTheme['FieldSwitch'];\n FieldMarkdownEditor: IValidatedFormTheme['FieldMarkdownEditor'];\n }\n ];\n };\n}\n\nexport default class ValidatedFormComponent extends Component<ValidatedFormSignature> {\n @tracked childComponents: ReturnType<typeof A<ValidatedFormChild>> = A<ValidatedFormChild>([]);\n //cache to only notify if changed\n lastIsValid?: boolean;\n lastIsTouched?: boolean;\n\n @tracked isInvalid = false;\n @tracked isTouched = false;\n\n constructor(owner: Owner, args: ValidatedFormSignature['Args']) {\n super(owner, args);\n this.args.register?.(this);\n }\n\n willDestroy() {\n super.willDestroy();\n this.args.unregister?.(this);\n }\n\n get isValid() {\n return !this.isInvalid;\n }\n\n get isInvalidAndTouched() {\n return this.isInvalid && this.isTouched;\n }\n\n // The registered children that are invalid or touched. The child that\n // changed updates them (see onChildValidityChange), so a keystroke costs\n // the same whatever the number of fields.\n private children = new Set<ValidatedFormChild>();\n private invalidChildren = new Set<ValidatedFormChild>();\n private touchedChildren = new Set<ValidatedFormChild>();\n\n addChild(child: ValidatedFormChild) {\n this.childComponents.pushObject(child);\n this.children.add(child);\n this.updateChild(child);\n this.triggerValidityChange();\n }\n\n removeChild(child: ValidatedFormChild) {\n this.childComponents.removeObject(child);\n this.children.delete(child);\n this.invalidChildren.delete(child);\n this.touchedChildren.delete(child);\n }\n\n private updateChild(child: ValidatedFormChild) {\n if (child.isValid) {\n this.invalidChildren.delete(child);\n } else {\n this.invalidChildren.add(child);\n }\n\n if (child.isTouched) {\n this.touchedChildren.add(child);\n } else {\n this.touchedChildren.delete(child);\n }\n }\n\n // Children that do not say what changed (nested forms, app fields), and\n // submitting, read every child again.\n private updateChildren() {\n this.invalidChildren.clear();\n this.touchedChildren.clear();\n this.childComponents.forEach((child) => this.updateChild(child));\n }\n\n @action\n async handleSubmit(e: Event) {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n e.preventDefault();\n const form = e.currentTarget as HTMLElement;\n // app fields may not report their changes\n this.updateChildren();\n this.flushValidity();\n\n if (this.isInvalid) {\n this.setIsTouched(true);\n this.args.onInvalid?.();\n\n // fields mark their controls invalid once touched, i.e. in this render\n if (this.args.revealFirstInvalid !== false) {\n schedule('afterRender', null, revealFirstInvalid, form);\n }\n } else {\n this.setIsTouched(false);\n\n try {\n await this.args.onSubmit?.();\n } catch {\n this.setIsTouched(true);\n }\n }\n }\n\n @action\n setIsTouched(isTouched: boolean) {\n this.childComponents.forEach((child) => setChildIsTouched(child, isTouched));\n this.updateValidity();\n }\n\n @action\n handleReset(e: Event) {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n e.preventDefault();\n this.args.onReset?.(e);\n }\n\n @action\n register(child: ValidatedFormChild) {\n if (!this.isDestroyed) {\n schedule('afterRender', this, this.addChild, child);\n }\n }\n\n @action\n unregister(child: ValidatedFormChild) {\n if (!this.isDestroyed) {\n schedule('afterRender', this, this.removeChild, child);\n // When adding a child the validation gets calculated on a `did-insert` modifier\n // for removal there's no modifier so it gets called here\n schedule('afterRender', this, this.triggerValidityChange);\n }\n }\n\n @action\n updateValidity() {\n this.updateChildren();\n this.triggerValidityChange();\n }\n\n getIsValid() {\n return this.invalidChildren.size === 0;\n }\n\n getIsTouched() {\n return this.touchedChildren.size > 0;\n }\n\n triggerValidityChange() {\n if (\n this.isValid !== this.getIsValid() ||\n this.isTouched !== this.getIsTouched()\n ) {\n this.setNewValidity();\n }\n }\n\n // After the current render, in the same run loop (it used to wait for the\n // next one); one update however many children changed.\n @action\n setNewValidity() {\n scheduleOnce('afterRender', this, this.flushValidity);\n }\n\n private flushValidity() {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n const isInvalid = !this.getIsValid();\n const isTouched = this.getIsTouched();\n\n // the first flush always reports (as the form's insert did)\n if (\n this.lastIsValid === !isInvalid &&\n this.lastIsTouched === isTouched\n ) {\n return;\n }\n\n this.isInvalid = isInvalid;\n this.isTouched = isTouched;\n this.lastIsValid = this.isValid;\n this.lastIsTouched = isTouched;\n\n this.args.onValidityChange?.(\n this.isValid,\n this.isTouched,\n this.isInvalidAndTouched\n );\n }\n\n // Fields call it with `{ child, isValid, isTouched }` when theirs changes;\n // nested forms with their own `(isValid, isTouched, …)`.\n @action\n onChildValidityChange(change?: unknown) {\n if (this.isDestroying) {\n return;\n }\n\n const child = (change as { child?: ValidatedFormChild } | undefined)?.child;\n\n if (child && this.children.has(child)) {\n this.updateChild(child);\n this.triggerValidityChange();\n } else {\n this.updateValidity();\n }\n }\n\n @action\n onFocusOut(e: FocusEvent) {\n const targetEuiFormRow = (e.target as HTMLInputElement)?.closest?.('.euiFormRow');\n\n if (!targetEuiFormRow) {\n return;\n }\n\n const field = this.childComponents.find((child) => {\n return 'formRowElement' in child && targetEuiFormRow === child.formRowElement;\n });\n\n if (!field) {\n return;\n }\n\n // Chrome also fires `focusout` when the focused element is removed, which\n // happens while rendering; touching the field then would update tracked\n // state that the same render already read. Defer it until after render.\n schedule('actions', () => {\n if (!field.isDestroying && !field.isDestroyed) {\n setChildIsTouched(field, true);\n }\n });\n }\n\n get theme() {\n const theme: Partial<IValidatedFormTheme> = this.args.theme || {};\n\n return { ...ValidatedFormDefaultTheme, ...theme };\n }\n\n <template>\n {{#let (argOrDefault @id (randomId)) as |formId|}}\n <EuiForm\n @tagName={{argOrDefault @tagName \"form\"}}\n id={{formId}}\n @isInvalid={{@isInvalid}}\n @invalidCallout={{@invalidCallout}}\n @error={{@error}}\n @errorTitle={{@errorTitle}}\n {{on \"submit\" this.handleSubmit}}\n {{on \"reset\" this.handleReset}}\n {{didInsert this.setNewValidity}}\n {{on \"focusout\" this.onFocusOut}}\n ...attributes\n >\n {{yield\n (hash\n onValidityChange=this.onChildValidityChange\n register=this.register\n unregister=this.unregister\n isValid=this.isValid\n isInvalid=this.isInvalid\n isTouched=this.isTouched\n isInvalidAndTouched=this.isInvalidAndTouched\n formId=(argOrDefault @formId formId)\n Form=(component\n this.theme.FieldNestedForm\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n tagName=\"div\"\n formId=(argOrDefault @formId formId)\n theme=this.theme\n isDisabled=@isDisabled\n fullWidth=@fullWidth\n compressed=@compressed\n )\n FieldNestedForm=(component\n this.theme.FieldNestedForm\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n tagName=\"div\"\n formId=(argOrDefault @formId formId)\n theme=this.theme\n isDisabled=@isDisabled\n fullWidth=@fullWidth\n compressed=@compressed\n )\n FieldBase=(component\n this.theme.FieldBase\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldNumber=(component\n this.theme.FieldNumber\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldText=(component\n this.theme.FieldText\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldPassword=(component\n this.theme.FieldPassword\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldTextArea=(component\n this.theme.FieldTextArea\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldSelect=(component\n this.theme.FieldSelect\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldComboBox=(component\n this.theme.FieldComboBox\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n isDisabled=@isDisabled\n )\n FieldCheckboxGroup=(component\n this.theme.FieldCheckboxGroup\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldRadioGroup=(component\n this.theme.FieldRadioGroup\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldRangeSlider=(component\n this.theme.FieldRangeSlider\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldDualRangeSlider=(component\n this.theme.FieldDualRangeSlider\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldSwitch=(component\n this.theme.FieldSwitch\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n FieldMarkdownEditor=(component\n this.theme.FieldMarkdownEditor\n register=this.register\n unregister=this.unregister\n onValidityChange=this.onChildValidityChange\n fullWidth=@fullWidth\n compressed=@compressed\n formId=(argOrDefault @formId formId)\n disabled=@isDisabled\n )\n )\n }}\n </EuiForm>\n {{/let}}\n </template>\n}\n\n// Default theme for ValidatedFormComponent. Do not remove.\nValidatedFormDefaultTheme.FieldNestedForm = ValidatedFormComponent;\n"],"names":["setChildIsTouched","child","isTouched","maybeChild","setIsTouched","set","ValidatedFormComponent","Component","g","prototype","tracked","A","i","lastIsValid","lastIsTouched","constructor","owner","args","register","willDestroy","unregister","isValid","isInvalid","isInvalidAndTouched","children","Set","invalidChildren","touchedChildren","addChild","childComponents","pushObject","add","updateChild","triggerValidityChange","removeChild","removeObject","delete","updateChildren","clear","forEach","handleSubmit","e","target","currentTarget","preventDefault","form","flushValidity","onInvalid","revealFirstInvalid","schedule","onSubmit","n","action","updateValidity","handleReset","onReset","isDestroyed","getIsValid","size","getIsTouched","setNewValidity","scheduleOnce","isDestroying","onValidityChange","onChildValidityChange","change","has","onFocusOut","targetEuiFormRow","closest","field","find","formRowElement","theme","ValidatedFormDefaultTheme","setComponentTemplate","precompileTemplate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