@ember-eui/validated-form 14.1.4 → 16.0.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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021
3
+ Copyright (c) 2020-present Alberto Cantu and Ember EUI contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/README.md CHANGED
@@ -4,9 +4,9 @@ Validated form for easy render oriented validations, depends on @ember/eui-core
4
4
 
5
5
  ## Compatibility
6
6
 
7
- - Ember.js v5.8 or above
8
- - Ember CLI v5.8 or above
9
- - Node.js v18 or above
7
+ - Ember.js v7.1 or above
8
+ - Ember CLI v7.1 or above
9
+ - Node.js v20.19 or above
10
10
 
11
11
  ## Installation
12
12
 
@@ -17,7 +17,7 @@ export interface FieldComboBoxSignature {
17
17
  formId?: string;
18
18
  /** Accessible label of the control. */
19
19
  ariaLabel?: string;
20
- /** Focuses the control on render. */
20
+ /** Focuses the control on render (same as `@autoFocus`). */
21
21
  autofocus?: boolean;
22
22
  /** Called with the selected options. */
23
23
  onChange?: (options: any[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"field-combo-box.d.ts","sourceRoot":"","sources":["../../../src/components/validated-form/field-combo-box.gts"],"names":[],"mappings":"AAsJA,OAAO,sBAAsB,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,sBAAsB;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AC,SAAS,CAAC,CAAC;KACpD,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,sBAAsB,CAAC,sBAAsB,CAAC;IACpG,kBAAkB,SAA0B;IAI5C,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE;CA6E5B"}
@@ -7,7 +7,7 @@ import EuiFormRow from '@ember-eui/core/components/eui-form-row';
7
7
  import { argOrDefault } from '@ember-eui/core/helpers';
8
8
  import optional from '@nullvoxpopuli/ember-composable-helpers/helpers/optional';
9
9
  import queue from '@nullvoxpopuli/ember-composable-helpers/helpers/queue';
10
- import { not } from 'ember-truth-helpers';
10
+ import { or, not } from 'ember-truth-helpers';
11
11
  import randomId from '../../-private/random-id.js';
12
12
  import ValidatedFormFieldBase from './field-base.js';
13
13
  import { precompileTemplate } from '@ember/template-compilation';
@@ -25,7 +25,7 @@ class ValidatedFormFieldComboBox extends ValidatedFormFieldBase {
25
25
  n(this.prototype, "handleChange", [action]);
26
26
  }
27
27
  static {
28
- setComponentTemplate(precompileTemplate("{{#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 @selectedOptions}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n <:field>\n <EuiComboBox class={{@fieldClasses}} @onChange={{this.handleChange}} @dropdownClass={{@dropdownClass}} @placeholder={{@placeholder}} @options={{this.options}} @singleSelection={{@singleSelection}} @selectedOptions={{@selectedOptions}} @searchEnabled={{argOrDefault @searchEnabled true}} @placeholderComponent={{@placeholderComponent}} @searchMessageComponent={{@searchMessageComponent}} @loadingMessage={{@loadingMessage}} @beforeOptionsComponent={{@beforeOptionsComponent}} @afterOptionsComponent={{@afterOptionsComponent}} @searchField={{@searchField}} @searchMessage={{@searchMessage}} @search={{@search}} aria-label={{@ariaLabel}} @isInvalid={{this.isInvalidAndTouched}} @isClearable={{@isClearable}} @fullWidth={{@fullWidth}} @isLoading={{@isLoading}} @readOnly={{@readOnly}} @compressed={{@compressed}} @onCreateOption={{@onCreateOption}} @matchTriggerWidth={{@matchTriggerWidth}} @customOptionText={{@customOptionText}} @onBlur={{queue (fn this.setIsTouched true) (optional @onBlur)}} @onFocus={{@onFocus}} @onClose={{@onClose}} @onOpen={{@onOpen}} @isDisabled={{@isDisabled}} @renderInPlace={{@renderInPlace}} @extra={{@extra}} ...attributes as |opt index select|>\n {{yield opt index select}}\n </EuiComboBox>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n{{/let}}", {
28
+ setComponentTemplate(precompileTemplate("{{#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 @selectedOptions}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n <:field>\n {{#let (component EuiComboBox onChange=this.handleChange options=this.options singleSelection=@singleSelection selectedOptions=@selectedOptions searchEnabled=(argOrDefault @searchEnabled true) searchField=@searchField search=@search searchMessage=@searchMessage searchMessageComponent=@searchMessageComponent searchPlaceholder=@searchPlaceholder placeholder=@placeholder placeholderComponent=@placeholderComponent loadingMessage=@loadingMessage noMatchesMessage=@noMatchesMessage noMatchesMessageComponent=@noMatchesMessageComponent beforeOptionsComponent=@beforeOptionsComponent afterOptionsComponent=@afterOptionsComponent selectedItemComponent=@selectedItemComponent dropdownClass=@dropdownClass optionsClass=@optionsClass onCreateOption=@onCreateOption alwaysShowCreateOption=@alwaysShowCreateOption customOptionText=@customOptionText delimiter=@delimiter isCaseSensitive=@isCaseSensitive sortMatchesBy=@sortMatchesBy matcher=@matcher optionMatcher=@optionMatcher typeAheadOptionMatcher=@typeAheadOptionMatcher async=@async onSearchChange=@onSearchChange noSuggestions=@noSuggestions truncationProps=@truncationProps rowHeight=@rowHeight onFocusBadge=@onFocusBadge prepend=@prepend append=@append triggerIcon=@triggerIcon isInvalid=this.isInvalidAndTouched isClearable=@isClearable isLoading=@isLoading isDisabled=@isDisabled readOnly=@readOnly fullWidth=@fullWidth compressed=@compressed closeOnSelect=@closeOnSelect autoFocus=(or @autoFocus @autofocus) initiallyOpen=@initiallyOpen defaultHighlighted=@defaultHighlighted matchTriggerWidth=@matchTriggerWidth renderInPlace=@renderInPlace horizontalPosition=@horizontalPosition verticalPosition=@verticalPosition destination=@destination preventScroll=@preventScroll calculatePosition=@calculatePosition eventType=@eventType tabindex=@tabindex ariaLabel=@ariaLabel ariaLabelledBy=@ariaLabelledBy required=@required triggerRole=@triggerRole title=@title triggerId=@triggerId removeTag=@removeTag onInput=@onInput onKeydown=@onKeydown registerApi=@registerApi onBlur=(queue (fn this.setIsTouched true) (optional @onBlur)) onFocus=@onFocus onClose=@onClose onOpen=@onOpen extra=@extra) as |ComboBox|}}\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}}", {
29
29
  strictMode: true,
30
30
  scope: () => ({
31
31
  argOrDefault,
@@ -35,6 +35,7 @@ class ValidatedFormFieldComboBox extends ValidatedFormFieldBase {
35
35
  didInsert,
36
36
  didUpdate,
37
37
  EuiComboBox,
38
+ or,
38
39
  queue,
39
40
  fn,
40
41
  optional
@@ -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 EuiComboBox from '@ember-eui/core/components/eui-combo-box';\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 } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\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. */\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\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 <template>\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 <EuiComboBox\n class={{@fieldClasses}}\n @onChange={{this.handleChange}}\n @dropdownClass={{@dropdownClass}}\n @placeholder={{@placeholder}}\n @options={{this.options}}\n @singleSelection={{@singleSelection}}\n @selectedOptions={{@selectedOptions}}\n @searchEnabled={{argOrDefault @searchEnabled true}}\n @placeholderComponent={{@placeholderComponent}}\n @searchMessageComponent={{@searchMessageComponent}}\n @loadingMessage={{@loadingMessage}}\n @beforeOptionsComponent={{@beforeOptionsComponent}}\n @afterOptionsComponent={{@afterOptionsComponent}}\n @searchField={{@searchField}}\n @searchMessage={{@searchMessage}}\n @search={{@search}}\n aria-label={{@ariaLabel}}\n @isInvalid={{this.isInvalidAndTouched}}\n @isClearable={{@isClearable}}\n @fullWidth={{@fullWidth}}\n @isLoading={{@isLoading}}\n @readOnly={{@readOnly}}\n @compressed={{@compressed}}\n @onCreateOption={{@onCreateOption}}\n @matchTriggerWidth={{@matchTriggerWidth}}\n @customOptionText={{@customOptionText}}\n @onBlur={{queue (fn this.setIsTouched true) (optional @onBlur)}}\n @onFocus={{@onFocus}}\n @onClose={{@onClose}}\n @onOpen={{@onOpen}}\n @isDisabled={{@isDisabled}}\n @renderInPlace={{@renderInPlace}}\n @extra={{@extra}}\n ...attributes\n as |opt index select|\n >\n {{yield opt index select}}\n </EuiComboBox>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n </template>\n}\n"],"names":["ValidatedFormFieldComboBox","ValidatedFormFieldBase","validationProperty","handleChange","options","args","onChange","notifyValidityChange","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","EuiComboBox","queue","fn","optional"],"mappings":";;;;;;;;;;;;;;;;AAsDe,MAAMA,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;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,olEAAA,EAuEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;QAAAC,WAAA;QAAAC,KAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
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 EuiComboBox from '@ember-eui/core/components/eui-combo-box';\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 randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\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\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 <template>\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 </template>\n}\n"],"names":["ValidatedFormFieldComboBox","ValidatedFormFieldBase","validationProperty","handleChange","options","args","onChange","notifyValidityChange","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","EuiComboBox","or","queue","fn","optional"],"mappings":";;;;;;;;;;;;;;;;AAsDe,MAAMA,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;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,01GAAA,EAwHA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;QAAAC,WAAA;QAAAC,EAAA;QAAAC,KAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -175,7 +175,7 @@ class ValidatedFormComponent extends Component {
175
175
  };
176
176
  }
177
177
  static {
178
- setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |formId|}}\n <EuiForm @tagName={{argOrDefault @tagName \"form\"}} id={{formId}} @isInvalid={{@isInvalid}} @invalidCallout={{@invalidCallout}} @error={{@error}} @errorTitle={{@errorTitle}} {{on \"submit\" this.handleSubmit}} {{on \"reset\" this.handleReset}} {{didInsert this.setNewValidity}} {{on \"focusout\" this.onFocusOut}} ...attributes>\n {{yield (hash onValidityChange=this.onChildValidityChange register=this.register unregister=this.unregister isValid=this.isValid isInvalid=this.isInvalid isTouched=this.isTouched isInvalidAndTouched=this.isInvalidAndTouched formId=(argOrDefault @formId formId) Form=(component this.theme.FieldNestedForm register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange tagName=\"div\" formId=(argOrDefault @formId formId) theme=@theme isDisabled=@isDisabled fullWidth=@fullWidth compressed=@compressed) FieldNestedForm=(component this.theme.FieldNestedForm register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange tagName=\"div\" formId=(argOrDefault @formId formId) theme=@theme isDisabled=@isDisabled fullWidth=@fullWidth compressed=@compressed) FieldBase=(component this.theme.FieldBase register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldNumber=(component this.theme.FieldNumber register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldText=(component this.theme.FieldText register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldPassword=(component this.theme.FieldPassword register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldTextArea=(component this.theme.FieldTextArea register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldSelect=(component this.theme.FieldSelect register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldComboBox=(component this.theme.FieldComboBox register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) isDisabled=@isDisabled) FieldCheckboxGroup=(component this.theme.FieldCheckboxGroup register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldRadioGroup=(component this.theme.FieldRadioGroup register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldRangeSlider=(component this.theme.FieldRangeSlider register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldDualRangeSlider=(component this.theme.FieldDualRangeSlider register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldSwitch=(component this.theme.FieldSwitch register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldMarkdownEditor=(component this.theme.FieldMarkdownEditor register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled))}}\n </EuiForm>\n{{/let}}", {
178
+ setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |formId|}}\n <EuiForm @tagName={{argOrDefault @tagName \"form\"}} id={{formId}} @isInvalid={{@isInvalid}} @invalidCallout={{@invalidCallout}} @error={{@error}} @errorTitle={{@errorTitle}} {{on \"submit\" this.handleSubmit}} {{on \"reset\" this.handleReset}} {{didInsert this.setNewValidity}} {{on \"focusout\" this.onFocusOut}} ...attributes>\n {{yield (hash onValidityChange=this.onChildValidityChange register=this.register unregister=this.unregister isValid=this.isValid isInvalid=this.isInvalid isTouched=this.isTouched isInvalidAndTouched=this.isInvalidAndTouched formId=(argOrDefault @formId formId) Form=(component this.theme.FieldNestedForm register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange tagName=\"div\" formId=(argOrDefault @formId formId) theme=this.theme isDisabled=@isDisabled fullWidth=@fullWidth compressed=@compressed) FieldNestedForm=(component this.theme.FieldNestedForm register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange tagName=\"div\" formId=(argOrDefault @formId formId) theme=this.theme isDisabled=@isDisabled fullWidth=@fullWidth compressed=@compressed) FieldBase=(component this.theme.FieldBase register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldNumber=(component this.theme.FieldNumber register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldText=(component this.theme.FieldText register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldPassword=(component this.theme.FieldPassword register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldTextArea=(component this.theme.FieldTextArea register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldSelect=(component this.theme.FieldSelect register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldComboBox=(component this.theme.FieldComboBox register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) isDisabled=@isDisabled) FieldCheckboxGroup=(component this.theme.FieldCheckboxGroup register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldRadioGroup=(component this.theme.FieldRadioGroup register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldRangeSlider=(component this.theme.FieldRangeSlider register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldDualRangeSlider=(component this.theme.FieldDualRangeSlider register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldSwitch=(component this.theme.FieldSwitch register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled) FieldMarkdownEditor=(component this.theme.FieldMarkdownEditor register=this.register unregister=this.unregister onValidityChange=this.onChildValidityChange fullWidth=@fullWidth compressed=@compressed formId=(argOrDefault @formId formId) disabled=@isDisabled))}}\n </EuiForm>\n{{/let}}", {
179
179
  strictMode: true,
180
180
  scope: () => ({
181
181
  argOrDefault,
@@ -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 } 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/**\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) => child.setIsTouched(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 this.childComponents\n .find((child) => {\n return 'formRowElement' in child && targetEuiFormRow === child.formRowElement;\n })\n ?.setIsTouched(true);\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=@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=@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":["ValidatedFormComponent","Component","g","prototype","tracked","A","i","lastIsValid","lastIsTouched","constructor","owner","args","register","willDestroy","unregister","isValid","isInvalid","isInvalidAndTouched","isTouched","addChild","child","childComponents","pushObject","triggerValidityChange","removeChild","removeObject","handleSubmit","e","target","currentTarget","preventDefault","setIsTouched","onInvalid","onSubmit","n","action","forEach","updateValidity","handleReset","onReset","isDestroyed","schedule","getIsValid","isEvery","getIsTouched","isAny","setNewValidity","next","isDestroying","onValidityChange","onChildValidityChange","onFocusOut","targetEuiFormRow","closest","find","formRowElement","theme","ValidatedFormDefaultTheme","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiForm","on","didInsert","hash","FieldNestedForm"],"mappings":";;;;;;;;;;;;;;;;AAwHe,MAAMA,+BAA+BC,SAAA,CAAU;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,iBAAA,EAAA,CAC3DC,OAAA,CAAA,EAAA,YAAA;MAAA,OAAoEC,CAAA,CAAsB,EAAE,CAAA;AAAA,IAAA,CAAA,CAAA;AAAA;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,IAAI,CAAC/B,eAAe,CACjBiC,IAAI,CAAElC,KAAA,IAAA;MACL,OAAO,gBAAA,IAAoBA,KAAA,IAASgC,gBAAA,KAAqBhC,KAAA,CAAMmC,cAAc;AAC/E,IAAA,CAAA,CAAA,EACExB,YAAA,CAAa,IAAA,CAAA;AACnB,EAAA;AAAA,EAAA;IAAAG,CAAA,CAAA,IAAA,CAAA/B,SAAA,EAAA,YAAA,EAAA,CAbCgC,MAAA,CAAA,CAAA;AAAA;EAeD,IAAIqB,KAAAA,GAAQ;IACV,MAAMA,KAAe,GAAuB,IAAI,CAAC7C,IAAI,CAAC6C,KAAK,IAAI,EAAC;IAEhE,OAAO;AAAE,MAAA,GAAGC,yBAAyB;MAAE,GAAGD;KAAM;AAClD,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,k0IAAA,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,GAAGpE,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 } 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/**\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) => child.setIsTouched(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 this.childComponents\n .find((child) => {\n return 'formRowElement' in child && targetEuiFormRow === child.formRowElement;\n })\n ?.setIsTouched(true);\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":["ValidatedFormComponent","Component","g","prototype","tracked","A","i","lastIsValid","lastIsTouched","constructor","owner","args","register","willDestroy","unregister","isValid","isInvalid","isInvalidAndTouched","isTouched","addChild","child","childComponents","pushObject","triggerValidityChange","removeChild","removeObject","handleSubmit","e","target","currentTarget","preventDefault","setIsTouched","onInvalid","onSubmit","n","action","forEach","updateValidity","handleReset","onReset","isDestroyed","schedule","getIsValid","isEvery","getIsTouched","isAny","setNewValidity","next","isDestroying","onValidityChange","onChildValidityChange","onFocusOut","targetEuiFormRow","closest","find","formRowElement","theme","ValidatedFormDefaultTheme","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiForm","on","didInsert","hash","FieldNestedForm"],"mappings":";;;;;;;;;;;;;;;;AAwHe,MAAMA,+BAA+BC,SAAA,CAAU;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,iBAAA,EAA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AAM,EAAuByB,OAAA,GAAU,aAAA,CAAA;IAEnE,IAAI,CAACD,gBAAA,EAAkB;AACrB,MAAA;AACF,IAAA;AAEA,IAAA,IAAI,CAAC/B,eAAe,CACjBiC,IAAI,CAAElC,KAAA,IAAA;MACL,OAAO,gBAAA,IAAoBA,KAAA,IAASgC,gBAAA,KAAqBhC,KAAA,CAAMmC,cAAc;AAC/E,IAAA,CAAA,CAAA,EACExB,YAAA,CAAa,IAAA,CAAA;AACnB,EAAA;AAAA,EAAA;IAAAG,CAAA,CAAA,IAAA,CAAA/B,SAAA,EAAA,YAAA,EAAA,CAbCgC,MAAA,CAAA,CAAA;AAAA;EAeD,IAAIqB,KAAAA,GAAQ;IACV,MAAMA,KAAe,GAAuB,IAAI,CAAC7C,IAAI,CAAC6C,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,GAAGpE,sBAAA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-eui/validated-form",
3
- "version": "14.1.4",
3
+ "version": "16.0.0",
4
4
  "description": "The default blueprint for ember-cli addons.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -45,9 +45,9 @@
45
45
  "ember-validators": "^5.0.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@ember-eui/core": "^14.0.0",
48
+ "@ember-eui/core": "^16.0.0",
49
49
  "@glimmer/component": "^2.0.0",
50
- "ember-source": ">= 4.12.0"
50
+ "ember-source": ">= 7.1.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/core": "^7.26.0",
@@ -55,7 +55,7 @@
55
55
  "@babel/plugin-proposal-decorators": "^7.25.9",
56
56
  "@babel/plugin-transform-typescript": "^7.12.13",
57
57
  "@babel/preset-typescript": "^7.18.6",
58
- "@ember-eui/core": "14.1.4",
58
+ "@ember-eui/core": "16.0.0",
59
59
  "@ember/optional-features": "^2.2.0",
60
60
  "@ember/test-helpers": "^5.2.1",
61
61
  "@ember/test-waiters": "^4.1.1",
@@ -100,14 +100,14 @@
100
100
  "babel-plugin-ember-template-compilation": "^4.0.0",
101
101
  "concurrently": "^9.1.2",
102
102
  "ember-basic-dropdown": "^9.0.0",
103
- "ember-cli": "~6.2.0",
103
+ "ember-cli": "~7.3.0",
104
104
  "ember-cli-clean-css": "^3.0.0",
105
105
  "ember-concurrency": "^5.1.0",
106
106
  "ember-focus-trap": "^1.1.0",
107
107
  "ember-keyboard": "^9.0.4",
108
108
  "ember-power-select": "^9.0.2",
109
109
  "ember-qunit": "^9.0.2",
110
- "ember-source": "~6.12.0",
110
+ "ember-source": "~7.3.0",
111
111
  "ember-strict-application-resolver": "^0.1.1",
112
112
  "ember-template-lint": "^6.1.0",
113
113
  "eslint": "^9.39.5",
@@ -131,7 +131,7 @@
131
131
  "webpack": "^5.97.1"
132
132
  },
133
133
  "engines": {
134
- "node": ">= 18"
134
+ "node": ">= 20.19.0"
135
135
  },
136
136
  "ember": {
137
137
  "edition": "octane"