@govtechsg/sgds-web-component 3.30.1-rc.5 → 3.30.1-rc.7

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.
Files changed (76) hide show
  1. package/components/Checkbox/index.umd.min.js +2 -2
  2. package/components/Checkbox/index.umd.min.js.map +1 -1
  3. package/components/Checkbox/sgds-checkbox.d.ts +7 -1
  4. package/components/Checkbox/sgds-checkbox.js +14 -0
  5. package/components/Checkbox/sgds-checkbox.js.map +1 -1
  6. package/components/ComboBox/index.umd.min.js +266 -266
  7. package/components/ComboBox/index.umd.min.js.map +1 -1
  8. package/components/DataTable/index.umd.min.js +301 -301
  9. package/components/DataTable/index.umd.min.js.map +1 -1
  10. package/components/Datepicker/index.umd.min.js +3 -3
  11. package/components/Datepicker/index.umd.min.js.map +1 -1
  12. package/components/Datepicker/sgds-datepicker.d.ts +1 -1
  13. package/components/Datepicker/sgds-datepicker.js +5 -1
  14. package/components/Datepicker/sgds-datepicker.js.map +1 -1
  15. package/components/FileUpload/index.umd.min.js +1 -1
  16. package/components/FileUpload/index.umd.min.js.map +1 -1
  17. package/components/Input/index.umd.min.js +3 -3
  18. package/components/Input/index.umd.min.js.map +1 -1
  19. package/components/Input/sgds-input.d.ts +1 -0
  20. package/components/Input/sgds-input.js +7 -0
  21. package/components/Input/sgds-input.js.map +1 -1
  22. package/components/QuantityToggle/index.umd.min.js +230 -230
  23. package/components/QuantityToggle/index.umd.min.js.map +1 -1
  24. package/components/QuantityToggle/sgds-quantity-toggle.d.ts +1 -0
  25. package/components/QuantityToggle/sgds-quantity-toggle.js +9 -0
  26. package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  27. package/components/Radio/index.umd.min.js +1 -1
  28. package/components/Radio/index.umd.min.js.map +1 -1
  29. package/components/Radio/sgds-radio-group.d.ts +1 -1
  30. package/components/Radio/sgds-radio-group.js +5 -1
  31. package/components/Radio/sgds-radio-group.js.map +1 -1
  32. package/components/Select/index.umd.min.js +1 -1
  33. package/components/Select/index.umd.min.js.map +1 -1
  34. package/components/Textarea/index.umd.min.js +1 -1
  35. package/components/Textarea/index.umd.min.js.map +1 -1
  36. package/components/Textarea/sgds-textarea.d.ts +1 -1
  37. package/components/Textarea/sgds-textarea.js +6 -2
  38. package/components/Textarea/sgds-textarea.js.map +1 -1
  39. package/components/index.umd.min.js +9 -9
  40. package/components/index.umd.min.js.map +1 -1
  41. package/custom-elements.json +20 -3
  42. package/index.umd.min.js +722 -722
  43. package/index.umd.min.js.map +1 -1
  44. package/package.json +1 -1
  45. package/react/components/Checkbox/sgds-checkbox.cjs.js +14 -0
  46. package/react/components/Checkbox/sgds-checkbox.cjs.js.map +1 -1
  47. package/react/components/Checkbox/sgds-checkbox.js +14 -0
  48. package/react/components/Checkbox/sgds-checkbox.js.map +1 -1
  49. package/react/components/Datepicker/sgds-datepicker.cjs.js +5 -1
  50. package/react/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
  51. package/react/components/Datepicker/sgds-datepicker.js +5 -1
  52. package/react/components/Datepicker/sgds-datepicker.js.map +1 -1
  53. package/react/components/Input/sgds-input.cjs.js +7 -0
  54. package/react/components/Input/sgds-input.cjs.js.map +1 -1
  55. package/react/components/Input/sgds-input.js +7 -0
  56. package/react/components/Input/sgds-input.js.map +1 -1
  57. package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js +9 -0
  58. package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
  59. package/react/components/QuantityToggle/sgds-quantity-toggle.js +9 -0
  60. package/react/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  61. package/react/components/Radio/sgds-radio-group.cjs.js +5 -1
  62. package/react/components/Radio/sgds-radio-group.cjs.js.map +1 -1
  63. package/react/components/Radio/sgds-radio-group.js +5 -1
  64. package/react/components/Radio/sgds-radio-group.js.map +1 -1
  65. package/react/components/Textarea/sgds-textarea.cjs.js +6 -2
  66. package/react/components/Textarea/sgds-textarea.cjs.js.map +1 -1
  67. package/react/components/Textarea/sgds-textarea.js +6 -2
  68. package/react/components/Textarea/sgds-textarea.js.map +1 -1
  69. package/react/utils/validatorMixin.cjs.js +2 -3
  70. package/react/utils/validatorMixin.cjs.js.map +1 -1
  71. package/react/utils/validatorMixin.js +2 -3
  72. package/react/utils/validatorMixin.js.map +1 -1
  73. package/types/react.d.ts +1 -1
  74. package/utils/validatorMixin.d.ts +1 -1
  75. package/utils/validatorMixin.js +2 -3
  76. package/utils/validatorMixin.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-input.cjs.js","names":["SgdsFormValidatorMixin","FormControlElement","formTextControlStyles","formPlaceholderStyles","inputStyle","SgdsSpinner","SgdsIcon","classMap","nothing","ifDefined","live","property","defaultValue","state","watch"],"sources":["../../../../src/components/Input/sgds-input.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport formTextControlStyles from \"../../styles/form-text-control.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport type { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport { SgdsSpinner } from \"../Spinner/sgds-spinner\";\nimport inputStyle from \"./input.css\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\n/**\n * @summary Text inputs allow your users to enter letters, numbers and symbols on a single line.\n *\n * @slot icon - The slot for leading icon of text input\n * @slot trailing-icon - The slot for trailing icon of text input. When present, it overrides valid icon and loading spinner rendered when valid prop or loading prop are true\n * @slot action - The slot for call to action of the text input. It is recommended to use sgds-icon-button within this slot\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-focus - Emitted when input is in focus.\n * @event sgds-blur - Emitted when input is not in focus.\n * @event sgds-invalid - Emitted when input is invalid\n * @event sgds-valid - Emitted when input is valid\n *\n */\nexport class SgdsInput extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [...FormControlElement.styles, formTextControlStyles, formPlaceholderStyles, inputStyle];\n /** @internal */\n static dependencies = {\n \"sgds-spinner\": SgdsSpinner,\n \"sgds-icon\": SgdsIcon\n };\n\n @property({ reflect: true }) type:\n | \"email\"\n | \"number\"\n | \"password\"\n | \"search\"\n | \"tel\"\n | \"text\"\n | \"time\"\n | \"url\"\n | \"datetime-local\" = \"text\";\n\n /** The prefix of the input */\n @property({ type: String }) prefix: string;\n\n /** The suffix of the input */\n @property({ type: String }) suffix: string;\n\n /** Sets the minimum length of the input */\n @property({ type: Number, reflect: true }) minlength: number;\n\n /** Sets the maximum length of the input */\n @property({ type: Number, reflect: true }) maxlength: number;\n\n /** The input's minimum value. Only applies number input types. */\n @property() min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property() max: number;\n\n /** The input's placeholder text. */\n @property({ type: String, reflect: true }) placeholder = \"placeholder\";\n\n /** A pattern to validate input against. */\n @property({ type: String }) pattern: string;\n\n /** Autofocus the input */\n @property({ type: Boolean, reflect: true }) autofocus = false;\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Controlling of autocomplete behaviour */\n @property({ type: String, reflect: true }) autocomplete = \"on\";\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to number input types.\n */\n @property() step: number | \"any\";\n\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n\n /**Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = \"\";\n\n /** Marks the component as valid. */\n @property({ type: Boolean, reflect: true }) valid = false;\n\n /** Marks the component as loading. */\n @property({ type: Boolean, reflect: true }) loading = false;\n\n /** Makes the input a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Disables native and sgds validation for the input. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n\n /**The input's value attribute. */\n @property({ reflect: true }) value = \"\";\n\n @state() protected _isTouched = false;\n\n @state() private _showPassword = false;\n\n /** Sets focus on the input. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n /** Sets blur on the input. */\n public blur() {\n this.input.blur();\n }\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void {\n return this._mixinSetValidity(flags, message, anchor);\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n protected _handleFocus() {\n this.emit(\"sgds-focus\");\n }\n\n protected _handleBlur() {\n const sgdsBlur = this.emit(\"sgds-blur\", { cancelable: true });\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (sgdsBlur.defaultPrevented) return;\n\n this.setInvalid(!this._mixinCheckValidity());\n this._isTouched = true;\n }\n private _handleClick() {\n this.focus();\n }\n\n protected _handleChange(e: Event) {\n this.value = this.input.value;\n const sgdsChange = this.emit(\"sgds-change\", { cancelable: true });\n\n if (sgdsChange.defaultPrevented) return;\n\n super._mixinHandleChange(e);\n }\n protected _handleInputChange(e: Event) {\n this.value = this.input.value;\n const sgdsInput = this.emit(\"sgds-input\", { cancelable: true });\n\n if (sgdsInput.defaultPrevented) return;\n\n super._mixinHandleInputChange(e);\n }\n /** @internal */\n @watch(\"_isTouched\", { waitUntilFirstUpdate: true })\n _handleIsTouched() {\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (this._isTouched) {\n this.setInvalid(!this._mixinCheckValidity());\n }\n }\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.setInvalid(false);\n }\n\n protected _renderInput() {\n const wantFeedbackStyle = this.hasFeedback === \"both\" || this.hasFeedback === \"style\";\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n const ariaDescribedBy =\n [\n this.hintText ? `${this._controlId}Help` : \"\",\n this.invalid && wantFeedbackText ? `${this._controlId}-invalid` : \"\"\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n return html`\n <div\n class=\"form-control-group ${classMap({\n disabled: this.disabled,\n readonly: this.readonly,\n \"is-invalid\": this.invalid && wantFeedbackStyle\n })}\"\n @click=${this._handleClick}\n >\n <slot name=\"icon\"></slot>\n ${this.prefix ? html`<span class=\"form-control-prefix\">${this.prefix}</span>` : nothing}\n <input\n class=\"form-control\"\n type=${this._inputType()}\n id=${this._controlId}\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n aria-invalid=${this.invalid ? \"true\" : \"false\"}\n pattern=${ifDefined(this.pattern)}\n ?autofocus=${this.autofocus}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n .value=${live(this.value)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step as number)}\n @input=${(e: Event) => this._handleInputChange(e)}\n @change=${(e: Event) => this._handleChange(e)}\n @invalid=${() => this.setInvalid(true)}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-describedby=${ifDefined(ariaDescribedBy)}\n .autocomplete=${this.autocomplete}\n />\n ${this.type === \"password\" ? this._renderPasswordToggle() : nothing}\n ${this.suffix ? html`<span class=\"form-control-suffix\">${this.suffix}</span>` : nothing}\n <slot name=\"trailing-icon\">\n ${this.loading ? html`<sgds-spinner size=\"sm\"></sgds-spinner>` : nothing}\n ${this.valid ? html`<sgds-icon name=\"check-circle-fill\" class=\"valid-icon\"></sgds-icon>` : nothing}\n </slot>\n </div>\n `;\n }\n protected _renderPasswordToggle() {\n return html`<sgds-icon\n tabIndex=\"0\"\n role=\"button\"\n aria-label=${this._showPassword ? \"Hide password\" : \"Show password\"}\n name=${this._showPassword ? \"eye-slash-fill\" : \"eye-fill\"}\n @click=${() => (this._showPassword = !this._showPassword)}\n ></sgds-icon>`;\n }\n protected _inputType() {\n if (this.type === \"password\" && this._showPassword) {\n return \"text\";\n }\n return this.type;\n }\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <sgds-icon name=\"exclamation-circle-fill\" size=\"md\"></sgds-icon>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n required: this.required\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n render() {\n return html`\n <div\n class=\"form-control-container ${classMap({\n disabled: this.disabled\n })}\"\n >\n ${this._renderLabel()}\n <div class=\"form-control-row\">\n ${this._renderInput()}\n <slot name=\"action\"></slot>\n </div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsInput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,YAAb,cAA+BA,uBAAAA,uBAAuBC,6BAAAA,OAAkB,CAAC,CAA4B;;;EAiB5E,KAAA,OAAA;EAqBkC,KAAA,cAAA;EAMD,KAAA,YAAA;EAGD,KAAA,WAAA;EAGG,KAAA,eAAA;EAgB3C,KAAA,eAAA;EAGqC,KAAA,QAAA;EAGE,KAAA,UAAA;EAGC,KAAA,WAAA;EAGE,KAAA,aAAA;EAGpB,KAAA,QAAA;EAEL,KAAA,aAAA;EAEC,KAAA,gBAAA;;;EApFjB,KAAA,SAAA;GAAC,GAAGA,6BAAAA,QAAmB;GAAQC,0BAAAA;GAAuBC,yBAAAA;GAAuBC,cAAAA;EAAU;;;EAEjF,KAAA,eAAA;GACpB,gBAAgBC,qBAAAA;GAChB,aAAaC,kBAAAA;EACf;;;CAkFA,MAAa,SAAwB;EACnC,KAAK,MAAM,MAAM,OAAO;CAC1B;;CAEA,OAAc;EACZ,KAAK,MAAM,KAAK;CAClB;;;;;CAMA,iBAAiC;EAC/B,OAAO,KAAK,qBAAqB;CACnC;;;;CAIA,gBAAgC;EAC9B,OAAO,KAAK,oBAAoB;CAClC;;;;CAIA,YAAmB,OAA4B,SAAkB,QAA4B;EAC3F,OAAO,KAAK,kBAAkB,OAAO,SAAS,MAAM;CACtD;;;;CAKA,IAAW,WAA0B;EACnC,OAAO,KAAK,kBAAkB;CAChC;;;;CAIA,IAAW,oBAAoB;EAC7B,OAAO,KAAK,2BAA2B;CACzC;CAEA,eAAyB;EACvB,KAAK,KAAK,YAAY;CACxB;CAEA,cAAwB;EACtB,MAAM,WAAW,KAAK,KAAK,aAAa,EAAE,YAAY,KAAK,CAAC;EAC5D,IAAI,KAAK,+BAA+B,GAAG;EAC3C,IAAI,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A,UAAA,WAAA,iBAAA,KAAA,CAAA;AA6ENC,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,cAAc,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,oBAAA,IAAA;AAOlDA,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,YAAY,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,yBAAA,IAAA"}
1
+ {"version":3,"file":"sgds-input.cjs.js","names":["SgdsFormValidatorMixin","FormControlElement","formTextControlStyles","formPlaceholderStyles","inputStyle","SgdsSpinner","SgdsIcon","classMap","nothing","ifDefined","live","property","defaultValue","state","watch"],"sources":["../../../../src/components/Input/sgds-input.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport formTextControlStyles from \"../../styles/form-text-control.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport type { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport { SgdsSpinner } from \"../Spinner/sgds-spinner\";\nimport inputStyle from \"./input.css\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\n/**\n * @summary Text inputs allow your users to enter letters, numbers and symbols on a single line.\n *\n * @slot icon - The slot for leading icon of text input\n * @slot trailing-icon - The slot for trailing icon of text input. When present, it overrides valid icon and loading spinner rendered when valid prop or loading prop are true\n * @slot action - The slot for call to action of the text input. It is recommended to use sgds-icon-button within this slot\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-focus - Emitted when input is in focus.\n * @event sgds-blur - Emitted when input is not in focus.\n * @event sgds-invalid - Emitted when input is invalid\n * @event sgds-valid - Emitted when input is valid\n *\n */\nexport class SgdsInput extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [...FormControlElement.styles, formTextControlStyles, formPlaceholderStyles, inputStyle];\n /** @internal */\n static dependencies = {\n \"sgds-spinner\": SgdsSpinner,\n \"sgds-icon\": SgdsIcon\n };\n\n @property({ reflect: true }) type:\n | \"email\"\n | \"number\"\n | \"password\"\n | \"search\"\n | \"tel\"\n | \"text\"\n | \"time\"\n | \"url\"\n | \"datetime-local\" = \"text\";\n\n /** The prefix of the input */\n @property({ type: String }) prefix: string;\n\n /** The suffix of the input */\n @property({ type: String }) suffix: string;\n\n /** Sets the minimum length of the input */\n @property({ type: Number, reflect: true }) minlength: number;\n\n /** Sets the maximum length of the input */\n @property({ type: Number, reflect: true }) maxlength: number;\n\n /** The input's minimum value. Only applies number input types. */\n @property() min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property() max: number;\n\n /** The input's placeholder text. */\n @property({ type: String, reflect: true }) placeholder = \"placeholder\";\n\n /** A pattern to validate input against. */\n @property({ type: String }) pattern: string;\n\n /** Autofocus the input */\n @property({ type: Boolean, reflect: true }) autofocus = false;\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Controlling of autocomplete behaviour */\n @property({ type: String, reflect: true }) autocomplete = \"on\";\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to number input types.\n */\n @property() step: number | \"any\";\n\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n\n /**Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = \"\";\n\n /** Marks the component as valid. */\n @property({ type: Boolean, reflect: true }) valid = false;\n\n /** Marks the component as loading. */\n @property({ type: Boolean, reflect: true }) loading = false;\n\n /** Makes the input a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Disables native and sgds validation for the input. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n\n /**The input's value attribute. */\n @property({ reflect: true }) value = \"\";\n\n @state() protected _isTouched = false;\n\n @state() private _showPassword = false;\n\n /** Sets focus on the input. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n /** Sets blur on the input. */\n public blur() {\n this.input.blur();\n }\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void {\n return this._mixinSetValidity(flags, message, anchor);\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n protected _handleFocus() {\n this.emit(\"sgds-focus\");\n }\n\n protected _handleBlur() {\n const sgdsBlur = this.emit(\"sgds-blur\", { cancelable: true });\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (sgdsBlur.defaultPrevented) return;\n\n this.setInvalid(!this._mixinCheckValidity());\n this._isTouched = true;\n }\n private _handleClick() {\n this.focus();\n }\n\n protected _handleChange(e: Event) {\n this.value = this.input.value;\n const sgdsChange = this.emit(\"sgds-change\", { cancelable: true });\n\n if (sgdsChange.defaultPrevented) return;\n\n super._mixinHandleChange(e);\n }\n protected _handleInputChange(e: Event) {\n this.value = this.input.value;\n const sgdsInput = this.emit(\"sgds-input\", { cancelable: true });\n\n if (sgdsInput.defaultPrevented) return;\n\n super._mixinHandleInputChange(e);\n }\n /** @internal */\n @watch(\"_isTouched\", { waitUntilFirstUpdate: true })\n _handleIsTouched() {\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (this._isTouched) {\n this.setInvalid(!this._mixinCheckValidity());\n }\n }\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.setInvalid(false);\n }\n\n @watch(\"value\", { waitUntilFirstUpdate: true })\n async _handleValueChange() {\n this._mixinSetFormValue();\n await this.updateComplete;\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(this.input);\n }\n\n protected _renderInput() {\n const wantFeedbackStyle = this.hasFeedback === \"both\" || this.hasFeedback === \"style\";\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n const ariaDescribedBy =\n [\n this.hintText ? `${this._controlId}Help` : \"\",\n this.invalid && wantFeedbackText ? `${this._controlId}-invalid` : \"\"\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n return html`\n <div\n class=\"form-control-group ${classMap({\n disabled: this.disabled,\n readonly: this.readonly,\n \"is-invalid\": this.invalid && wantFeedbackStyle\n })}\"\n @click=${this._handleClick}\n >\n <slot name=\"icon\"></slot>\n ${this.prefix ? html`<span class=\"form-control-prefix\">${this.prefix}</span>` : nothing}\n <input\n class=\"form-control\"\n type=${this._inputType()}\n id=${this._controlId}\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n aria-invalid=${this.invalid ? \"true\" : \"false\"}\n pattern=${ifDefined(this.pattern)}\n ?autofocus=${this.autofocus}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n .value=${live(this.value)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step as number)}\n @input=${(e: Event) => this._handleInputChange(e)}\n @change=${(e: Event) => this._handleChange(e)}\n @invalid=${() => this.setInvalid(true)}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-describedby=${ifDefined(ariaDescribedBy)}\n .autocomplete=${this.autocomplete}\n />\n ${this.type === \"password\" ? this._renderPasswordToggle() : nothing}\n ${this.suffix ? html`<span class=\"form-control-suffix\">${this.suffix}</span>` : nothing}\n <slot name=\"trailing-icon\">\n ${this.loading ? html`<sgds-spinner size=\"sm\"></sgds-spinner>` : nothing}\n ${this.valid ? html`<sgds-icon name=\"check-circle-fill\" class=\"valid-icon\"></sgds-icon>` : nothing}\n </slot>\n </div>\n `;\n }\n protected _renderPasswordToggle() {\n return html`<sgds-icon\n tabIndex=\"0\"\n role=\"button\"\n aria-label=${this._showPassword ? \"Hide password\" : \"Show password\"}\n name=${this._showPassword ? \"eye-slash-fill\" : \"eye-fill\"}\n @click=${() => (this._showPassword = !this._showPassword)}\n ></sgds-icon>`;\n }\n protected _inputType() {\n if (this.type === \"password\" && this._showPassword) {\n return \"text\";\n }\n return this.type;\n }\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <sgds-icon name=\"exclamation-circle-fill\" size=\"md\"></sgds-icon>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n required: this.required\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n render() {\n return html`\n <div\n class=\"form-control-container ${classMap({\n disabled: this.disabled\n })}\"\n >\n ${this._renderLabel()}\n <div class=\"form-control-row\">\n ${this._renderInput()}\n <slot name=\"action\"></slot>\n </div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsInput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,YAAb,cAA+BA,uBAAAA,uBAAuBC,6BAAAA,OAAkB,CAAC,CAA4B;;;EAiB5E,KAAA,OAAA;EAqBkC,KAAA,cAAA;EAMD,KAAA,YAAA;EAGD,KAAA,WAAA;EAGG,KAAA,eAAA;EAgB3C,KAAA,eAAA;EAGqC,KAAA,QAAA;EAGE,KAAA,UAAA;EAGC,KAAA,WAAA;EAGE,KAAA,aAAA;EAGpB,KAAA,QAAA;EAEL,KAAA,aAAA;EAEC,KAAA,gBAAA;;;EApFjB,KAAA,SAAA;GAAC,GAAGA,6BAAAA,QAAmB;GAAQC,0BAAAA;GAAuBC,yBAAAA;GAAuBC,cAAAA;EAAU;;;EAEjF,KAAA,eAAA;GACpB,gBAAgBC,qBAAAA;GAChB,aAAaC,kBAAAA;EACf;;;CAkFA,MAAa,SAAwB;EACnC,KAAK,MAAM,MAAM,OAAO;CAC1B;;CAEA,OAAc;EACZ,KAAK,MAAM,KAAK;CAClB;;;;;CAMA,iBAAiC;EAC/B,OAAO,KAAK,qBAAqB;CACnC;;;;CAIA,gBAAgC;EAC9B,OAAO,KAAK,oBAAoB;CAClC;;;;CAIA,YAAmB,OAA4B,SAAkB,QAA4B;EAC3F,OAAO,KAAK,kBAAkB,OAAO,SAAS,MAAM;CACtD;;;;CAKA,IAAW,WAA0B;EACnC,OAAO,KAAK,kBAAkB;CAChC;;;;CAIA,IAAW,oBAAoB;EAC7B,OAAO,KAAK,2BAA2B;CACzC;CAEA,eAAyB;EACvB,KAAK,KAAK,YAAY;CACxB;CAEA,cAAwB;EACtB,MAAM,WAAW,KAAK,KAAK,aAAa,EA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WAAA,SAAA,KAAA,CAAA;AAE1BE,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,MAAAA,CAAM,CAAA,GAAA,UAAA,WAAA,cAAA,KAAA,CAAA;AAENA,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,MAAAA,CAAM,CAAA,GAAA,UAAA,WAAA,iBAAA,KAAA,CAAA;AA6ENC,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,cAAc,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,oBAAA,IAAA;AAOlDA,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,YAAY,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,yBAAA,IAAA;AAMhDA,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,SAAS,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,sBAAA,IAAA"}
@@ -131,6 +131,12 @@ var SgdsInput = class extends SgdsFormValidatorMixin(FormControlElement) {
131
131
  _handleDisabledChange() {
132
132
  this.setInvalid(false);
133
133
  }
134
+ async _handleValueChange() {
135
+ this._mixinSetFormValue();
136
+ await this.updateComplete;
137
+ if (this._mixinShouldSkipSgdsValidation()) return;
138
+ this._mixinValidate(this.input);
139
+ }
134
140
  _renderInput() {
135
141
  const wantFeedbackStyle = this.hasFeedback === "both" || this.hasFeedback === "style";
136
142
  const wantFeedbackText = this.hasFeedback === "both" || this.hasFeedback === "text";
@@ -297,6 +303,7 @@ __decorate([state()], SgdsInput.prototype, "_isTouched", void 0);
297
303
  __decorate([state()], SgdsInput.prototype, "_showPassword", void 0);
298
304
  __decorate([watch("_isTouched", { waitUntilFirstUpdate: true })], SgdsInput.prototype, "_handleIsTouched", null);
299
305
  __decorate([watch("disabled", { waitUntilFirstUpdate: true })], SgdsInput.prototype, "_handleDisabledChange", null);
306
+ __decorate([watch("value", { waitUntilFirstUpdate: true })], SgdsInput.prototype, "_handleValueChange", null);
300
307
  //#endregion
301
308
  export { SgdsInput, SgdsInput as default };
302
309
 
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-input.js","names":["formTextControlStyles","formPlaceholderStyles","inputStyle"],"sources":["../../../../src/components/Input/sgds-input.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport formTextControlStyles from \"../../styles/form-text-control.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport type { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport { SgdsSpinner } from \"../Spinner/sgds-spinner\";\nimport inputStyle from \"./input.css\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\n/**\n * @summary Text inputs allow your users to enter letters, numbers and symbols on a single line.\n *\n * @slot icon - The slot for leading icon of text input\n * @slot trailing-icon - The slot for trailing icon of text input. When present, it overrides valid icon and loading spinner rendered when valid prop or loading prop are true\n * @slot action - The slot for call to action of the text input. It is recommended to use sgds-icon-button within this slot\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-focus - Emitted when input is in focus.\n * @event sgds-blur - Emitted when input is not in focus.\n * @event sgds-invalid - Emitted when input is invalid\n * @event sgds-valid - Emitted when input is valid\n *\n */\nexport class SgdsInput extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [...FormControlElement.styles, formTextControlStyles, formPlaceholderStyles, inputStyle];\n /** @internal */\n static dependencies = {\n \"sgds-spinner\": SgdsSpinner,\n \"sgds-icon\": SgdsIcon\n };\n\n @property({ reflect: true }) type:\n | \"email\"\n | \"number\"\n | \"password\"\n | \"search\"\n | \"tel\"\n | \"text\"\n | \"time\"\n | \"url\"\n | \"datetime-local\" = \"text\";\n\n /** The prefix of the input */\n @property({ type: String }) prefix: string;\n\n /** The suffix of the input */\n @property({ type: String }) suffix: string;\n\n /** Sets the minimum length of the input */\n @property({ type: Number, reflect: true }) minlength: number;\n\n /** Sets the maximum length of the input */\n @property({ type: Number, reflect: true }) maxlength: number;\n\n /** The input's minimum value. Only applies number input types. */\n @property() min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property() max: number;\n\n /** The input's placeholder text. */\n @property({ type: String, reflect: true }) placeholder = \"placeholder\";\n\n /** A pattern to validate input against. */\n @property({ type: String }) pattern: string;\n\n /** Autofocus the input */\n @property({ type: Boolean, reflect: true }) autofocus = false;\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Controlling of autocomplete behaviour */\n @property({ type: String, reflect: true }) autocomplete = \"on\";\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to number input types.\n */\n @property() step: number | \"any\";\n\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n\n /**Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = \"\";\n\n /** Marks the component as valid. */\n @property({ type: Boolean, reflect: true }) valid = false;\n\n /** Marks the component as loading. */\n @property({ type: Boolean, reflect: true }) loading = false;\n\n /** Makes the input a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Disables native and sgds validation for the input. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n\n /**The input's value attribute. */\n @property({ reflect: true }) value = \"\";\n\n @state() protected _isTouched = false;\n\n @state() private _showPassword = false;\n\n /** Sets focus on the input. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n /** Sets blur on the input. */\n public blur() {\n this.input.blur();\n }\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void {\n return this._mixinSetValidity(flags, message, anchor);\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n protected _handleFocus() {\n this.emit(\"sgds-focus\");\n }\n\n protected _handleBlur() {\n const sgdsBlur = this.emit(\"sgds-blur\", { cancelable: true });\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (sgdsBlur.defaultPrevented) return;\n\n this.setInvalid(!this._mixinCheckValidity());\n this._isTouched = true;\n }\n private _handleClick() {\n this.focus();\n }\n\n protected _handleChange(e: Event) {\n this.value = this.input.value;\n const sgdsChange = this.emit(\"sgds-change\", { cancelable: true });\n\n if (sgdsChange.defaultPrevented) return;\n\n super._mixinHandleChange(e);\n }\n protected _handleInputChange(e: Event) {\n this.value = this.input.value;\n const sgdsInput = this.emit(\"sgds-input\", { cancelable: true });\n\n if (sgdsInput.defaultPrevented) return;\n\n super._mixinHandleInputChange(e);\n }\n /** @internal */\n @watch(\"_isTouched\", { waitUntilFirstUpdate: true })\n _handleIsTouched() {\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (this._isTouched) {\n this.setInvalid(!this._mixinCheckValidity());\n }\n }\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.setInvalid(false);\n }\n\n protected _renderInput() {\n const wantFeedbackStyle = this.hasFeedback === \"both\" || this.hasFeedback === \"style\";\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n const ariaDescribedBy =\n [\n this.hintText ? `${this._controlId}Help` : \"\",\n this.invalid && wantFeedbackText ? `${this._controlId}-invalid` : \"\"\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n return html`\n <div\n class=\"form-control-group ${classMap({\n disabled: this.disabled,\n readonly: this.readonly,\n \"is-invalid\": this.invalid && wantFeedbackStyle\n })}\"\n @click=${this._handleClick}\n >\n <slot name=\"icon\"></slot>\n ${this.prefix ? html`<span class=\"form-control-prefix\">${this.prefix}</span>` : nothing}\n <input\n class=\"form-control\"\n type=${this._inputType()}\n id=${this._controlId}\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n aria-invalid=${this.invalid ? \"true\" : \"false\"}\n pattern=${ifDefined(this.pattern)}\n ?autofocus=${this.autofocus}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n .value=${live(this.value)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step as number)}\n @input=${(e: Event) => this._handleInputChange(e)}\n @change=${(e: Event) => this._handleChange(e)}\n @invalid=${() => this.setInvalid(true)}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-describedby=${ifDefined(ariaDescribedBy)}\n .autocomplete=${this.autocomplete}\n />\n ${this.type === \"password\" ? this._renderPasswordToggle() : nothing}\n ${this.suffix ? html`<span class=\"form-control-suffix\">${this.suffix}</span>` : nothing}\n <slot name=\"trailing-icon\">\n ${this.loading ? html`<sgds-spinner size=\"sm\"></sgds-spinner>` : nothing}\n ${this.valid ? html`<sgds-icon name=\"check-circle-fill\" class=\"valid-icon\"></sgds-icon>` : nothing}\n </slot>\n </div>\n `;\n }\n protected _renderPasswordToggle() {\n return html`<sgds-icon\n tabIndex=\"0\"\n role=\"button\"\n aria-label=${this._showPassword ? \"Hide password\" : \"Show password\"}\n name=${this._showPassword ? \"eye-slash-fill\" : \"eye-fill\"}\n @click=${() => (this._showPassword = !this._showPassword)}\n ></sgds-icon>`;\n }\n protected _inputType() {\n if (this.type === \"password\" && this._showPassword) {\n return \"text\";\n }\n return this.type;\n }\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <sgds-icon name=\"exclamation-circle-fill\" size=\"md\"></sgds-icon>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n required: this.required\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n render() {\n return html`\n <div\n class=\"form-control-container ${classMap({\n disabled: this.disabled\n })}\"\n >\n ${this._renderLabel()}\n <div class=\"form-control-row\">\n ${this._renderInput()}\n <slot name=\"action\"></slot>\n </div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsInput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,YAAb,cAA+B,uBAAuB,kBAAkB,CAAC,CAA4B;;;EAiB5E,KAAA,OAAA;EAqBkC,KAAA,cAAA;EAMD,KAAA,YAAA;EAGD,KAAA,WAAA;EAGG,KAAA,eAAA;EAgB3C,KAAA,eAAA;EAGqC,KAAA,QAAA;EAGE,K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GAAA,UAAA,WAAA,eAAA,KAAA,CAAA;AAGxC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,UAAA,WAAA,mBAAA,KAAA,CAAA;AAGxC,WAAA,CAAA,aAAa,CAAA,GAAA,UAAA,WAAA,gBAAA,KAAA,CAAA;AAIb,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,UAAA,WAAA,SAAA,KAAA,CAAA;AAGzC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,UAAA,WAAA,WAAA,KAAA,CAAA;AAGzC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,UAAA,WAAA,YAAA,KAAA,CAAA;AAGzC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,UAAA,WAAA,cAAA,KAAA,CAAA;AAGzC,WAAA,CAAA,SAAS,EAAE,SAAS,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,SAAA,KAAA,CAAA;AAE1B,WAAA,CAAA,MAAM,CAAA,GAAA,UAAA,WAAA,cAAA,KAAA,CAAA;AAEN,WAAA,CAAA,MAAM,CAAA,GAAA,UAAA,WAAA,iBAAA,KAAA,CAAA;AA6EN,WAAA,CAAA,MAAM,cAAc,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,oBAAA,IAAA;AAOlD,WAAA,CAAA,MAAM,YAAY,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,UAAA,WAAA,yBAAA,IAAA"}
1
+ {"version":3,"file":"sgds-input.js","names":["formTextControlStyles","formPlaceholderStyles","inputStyle"],"sources":["../../../../src/components/Input/sgds-input.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport formTextControlStyles from \"../../styles/form-text-control.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport type { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport { SgdsSpinner } from \"../Spinner/sgds-spinner\";\nimport inputStyle from \"./input.css\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\n/**\n * @summary Text inputs allow your users to enter letters, numbers and symbols on a single line.\n *\n * @slot icon - The slot for leading icon of text input\n * @slot trailing-icon - The slot for trailing icon of text input. When present, it overrides valid icon and loading spinner rendered when valid prop or loading prop are true\n * @slot action - The slot for call to action of the text input. It is recommended to use sgds-icon-button within this slot\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-focus - Emitted when input is in focus.\n * @event sgds-blur - Emitted when input is not in focus.\n * @event sgds-invalid - Emitted when input is invalid\n * @event sgds-valid - Emitted when input is valid\n *\n */\nexport class SgdsInput extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [...FormControlElement.styles, formTextControlStyles, formPlaceholderStyles, inputStyle];\n /** @internal */\n static dependencies = {\n \"sgds-spinner\": SgdsSpinner,\n \"sgds-icon\": SgdsIcon\n };\n\n @property({ reflect: true }) type:\n | \"email\"\n | \"number\"\n | \"password\"\n | \"search\"\n | \"tel\"\n | \"text\"\n | \"time\"\n | \"url\"\n | \"datetime-local\" = \"text\";\n\n /** The prefix of the input */\n @property({ type: String }) prefix: string;\n\n /** The suffix of the input */\n @property({ type: String }) suffix: string;\n\n /** Sets the minimum length of the input */\n @property({ type: Number, reflect: true }) minlength: number;\n\n /** Sets the maximum length of the input */\n @property({ type: Number, reflect: true }) maxlength: number;\n\n /** The input's minimum value. Only applies number input types. */\n @property() min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property() max: number;\n\n /** The input's placeholder text. */\n @property({ type: String, reflect: true }) placeholder = \"placeholder\";\n\n /** A pattern to validate input against. */\n @property({ type: String }) pattern: string;\n\n /** Autofocus the input */\n @property({ type: Boolean, reflect: true }) autofocus = false;\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Controlling of autocomplete behaviour */\n @property({ type: String, reflect: true }) autocomplete = \"on\";\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to number input types.\n */\n @property() step: number | \"any\";\n\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n\n /**Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = \"\";\n\n /** Marks the component as valid. */\n @property({ type: Boolean, reflect: true }) valid = false;\n\n /** Marks the component as loading. */\n @property({ type: Boolean, reflect: true }) loading = false;\n\n /** Makes the input a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Disables native and sgds validation for the input. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n\n /**The input's value attribute. */\n @property({ reflect: true }) value = \"\";\n\n @state() protected _isTouched = false;\n\n @state() private _showPassword = false;\n\n /** Sets focus on the input. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n /** Sets blur on the input. */\n public blur() {\n this.input.blur();\n }\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void {\n return this._mixinSetValidity(flags, message, anchor);\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n protected _handleFocus() {\n this.emit(\"sgds-focus\");\n }\n\n protected _handleBlur() {\n const sgdsBlur = this.emit(\"sgds-blur\", { cancelable: true });\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (sgdsBlur.defaultPrevented) return;\n\n this.setInvalid(!this._mixinCheckValidity());\n this._isTouched = true;\n }\n private _handleClick() {\n this.focus();\n }\n\n protected _handleChange(e: Event) {\n this.value = this.input.value;\n const sgdsChange = this.emit(\"sgds-change\", { cancelable: true });\n\n if (sgdsChange.defaultPrevented) return;\n\n super._mixinHandleChange(e);\n }\n protected _handleInputChange(e: Event) {\n this.value = this.input.value;\n const sgdsInput = this.emit(\"sgds-input\", { cancelable: true });\n\n if (sgdsInput.defaultPrevented) return;\n\n super._mixinHandleInputChange(e);\n }\n /** @internal */\n @watch(\"_isTouched\", { waitUntilFirstUpdate: true })\n _handleIsTouched() {\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (this._isTouched) {\n this.setInvalid(!this._mixinCheckValidity());\n }\n }\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.setInvalid(false);\n }\n\n @watch(\"value\", { waitUntilFirstUpdate: true })\n async _handleValueChange() {\n this._mixinSetFormValue();\n await this.updateComplete;\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(this.input);\n }\n\n protected _renderInput() {\n const wantFeedbackStyle = this.hasFeedback === \"both\" || this.hasFeedback === \"style\";\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n const ariaDescribedBy =\n [\n this.hintText ? `${this._controlId}Help` : \"\",\n this.invalid && wantFeedbackText ? `${this._controlId}-invalid` : \"\"\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n return html`\n <div\n class=\"form-control-group ${classMap({\n disabled: this.disabled,\n readonly: this.readonly,\n \"is-invalid\": this.invalid && wantFeedbackStyle\n })}\"\n @click=${this._handleClick}\n >\n <slot name=\"icon\"></slot>\n ${this.prefix ? html`<span class=\"form-control-prefix\">${this.prefix}</span>` : nothing}\n <input\n class=\"form-control\"\n type=${this._inputType()}\n id=${this._controlId}\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n aria-invalid=${this.invalid ? \"true\" : \"false\"}\n pattern=${ifDefined(this.pattern)}\n ?autofocus=${this.autofocus}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n .value=${live(this.value)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step as number)}\n @input=${(e: Event) => this._handleInputChange(e)}\n @change=${(e: Event) => this._handleChange(e)}\n @invalid=${() => this.setInvalid(true)}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-describedby=${ifDefined(ariaDescribedBy)}\n .autocomplete=${this.autocomplete}\n />\n ${this.type === \"password\" ? this._renderPasswordToggle() : nothing}\n ${this.suffix ? html`<span class=\"form-control-suffix\">${this.suffix}</span>` : nothing}\n <slot name=\"trailing-icon\">\n ${this.loading ? html`<sgds-spinner size=\"sm\"></sgds-spinner>` : nothing}\n ${this.valid ? html`<sgds-icon name=\"check-circle-fill\" class=\"valid-icon\"></sgds-icon>` : nothing}\n </slot>\n </div>\n `;\n }\n protected _renderPasswordToggle() {\n return html`<sgds-icon\n tabIndex=\"0\"\n role=\"button\"\n aria-label=${this._showPassword ? \"Hide password\" : \"Show password\"}\n name=${this._showPassword ? \"eye-slash-fill\" : \"eye-fill\"}\n @click=${() => (this._showPassword = !this._showPassword)}\n ></sgds-icon>`;\n }\n protected _inputType() {\n if (this.type === \"password\" && this._showPassword) {\n return \"text\";\n }\n return this.type;\n }\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <sgds-icon name=\"exclamation-circle-fill\" size=\"md\"></sgds-icon>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n required: this.required\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n render() {\n return html`\n <div\n class=\"form-control-container ${classMap({\n disabled: this.disabled\n })}\"\n >\n ${this._renderLabel()}\n <div class=\"form-control-row\">\n ${this._renderInput()}\n <slot name=\"action\"></slot>\n </div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsInput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,YAAb,cAA+B,uBAAuB,kBAAkB,CAAC,CAA4B;;;EAiB5E,KAAA,OAAA;EAqBkC,KAAA,cAAA;EAMD,KAAA,YAAA;EAGD,KAAA,WAAA;EAGG,KAAA,eAAA;EAgB3C,KAAA,eAAA;EAGqC,KAAA,QAAA;EAGE,KAAA,UAAA;EAGC,KAAA,WAAA;EAGE,KAAA,aAAA;EAGpB,KAAA,QAAA;EAEL,KAAA,aAAA;EAEC,KAAA,gBAAA;;;EApFjB,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esm/decorate.cjs.js");
3
+ const require_watch = require("../../utils/watch.cjs.js");
3
4
  const require_sgds_icon_button = require("../IconButton/sgds-icon-button.cjs.js");
4
5
  const require_form_placeholder = require("../../styles/form-placeholder.cjs.js");
5
6
  const require_form_control_element = require("../../base/form-control-element.cjs.js");
@@ -75,6 +76,13 @@ var SgdsQuantityToggle = class extends require_validatorMixin.SgdsFormValidatorM
75
76
  get validationMessage() {
76
77
  return this._mixinGetValidationMessage();
77
78
  }
79
+ async _handleValuePropertyChange() {
80
+ this._mixinSetFormValue();
81
+ await this.updateComplete;
82
+ if (this._mixinShouldSkipSgdsValidation()) return;
83
+ const sgdsInput = await this._sgdsInput;
84
+ this._mixinValidate(sgdsInput.input);
85
+ }
78
86
  async _handleValueChange(e, eventName) {
79
87
  e.stopPropagation();
80
88
  const sgdsInput = await this._sgdsInput;
@@ -262,6 +270,7 @@ require_decorate.default([(0, lit_decorators_js.property)({
262
270
  })], SgdsQuantityToggle.prototype, "readonly", void 0);
263
271
  require_decorate.default([require_defaultvalue.defaultValue()], SgdsQuantityToggle.prototype, "defaultValue", void 0);
264
272
  require_decorate.default([(0, lit_decorators_js.queryAsync)("sgds-input")], SgdsQuantityToggle.prototype, "_sgdsInput", void 0);
273
+ require_decorate.default([require_watch.watch("value", { waitUntilFirstUpdate: true })], SgdsQuantityToggle.prototype, "_handleValuePropertyChange", null);
265
274
  //#endregion
266
275
  exports.SgdsQuantityToggle = SgdsQuantityToggle;
267
276
  exports.default = SgdsQuantityToggle;
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-quantity-toggle.cjs.js","names":["SgdsFormValidatorMixin","FormControlElement","formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle","SgdsInput","SgdsIconButton","classMap","ifDefined","live","query","property","defaultValue","queryAsync"],"sources":["../../../../src/components/QuantityToggle/sgds-quantity-toggle.ts"],"sourcesContent":["import { property, query, queryAsync } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport svgStyles from \"../../styles/svg.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport SgdsIconButton from \"../IconButton/sgds-icon-button\";\nimport SgdsInput from \"../Input/sgds-input\";\nimport quantityToggleStyle from \"./quantity-toggle.css\";\nimport formControlStyle from \"../../styles/form-text-control.css\";\n/**\n * @summary The quantity toggle component is used to increase or decrease an incremental venue, best used when the user needs to enter or adjust the quantity of a selected item.\n *\n * @slot invalidIcon - The slot for invalid icon\n *\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-invalid - Emitted when the control's invalid state is set to true.\n * @event sgds-valid - Emitted when the control's invalid state is set to false.\n *\n */\nexport class SgdsQuantityToggle extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [\n ...FormControlElement.styles,\n formPlaceholderStyles,\n svgStyles,\n formControlStyle,\n quantityToggleStyle\n ];\n\n /** @internal */\n static dependencies = {\n \"sgds-input\": SgdsInput,\n \"sgds-icon-button\": SgdsIconButton\n };\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='increase by']\") private plusBtn: HTMLButtonElement;\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='decrease by']\") private minusBtn: HTMLButtonElement;\n\n /** The input's value. Set to 0 by default */\n @property({ type: Number, reflect: true }) value = 0;\n\n /** Controls the incremental / decremental value of the input */\n @property({ type: Number }) step = 1;\n\n /** The input's minimum value. Only applies number input types. */\n @property({ type: Number }) min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property({ type: Number }) max: number;\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n /** Disables native and sgds validation for the quantity toggle. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n /** Sets the quantity toggle as readonly */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = 0;\n\n @queryAsync(\"sgds-input\") private _sgdsInput: Promise<SgdsInput>;\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n private async _handleValueChange(e: Event, eventName: \"sgds-change\" | \"sgds-input\") {\n e.stopPropagation();\n const sgdsInput = await this._sgdsInput;\n if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === \"\") {\n sgdsInput.value = \"0\";\n }\n this.value = parseInt(sgdsInput.value);\n this._mixinSetFormValue();\n this.emit(eventName);\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (eventName === \"sgds-input\") {\n this.invalid = false;\n }\n this._mixinValidate(sgdsInput.input);\n if (eventName === \"sgds-change\") {\n this.invalid = !this._mixinReportValidity();\n }\n }\n\n private async _mixinResetFormControl() {\n const sgdsInput = await this._sgdsInput;\n this.value = this.defaultValue;\n sgdsInput.input.value = this.value.toString();\n this._mixinResetValidity(sgdsInput.input);\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const allowedKeys = [\n \"Backspace\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"ArrowLeft\",\n \"ArrowRight\",\n ...Array.from(Array(10).keys()).map(key => key.toString()),\n \"Tab\"\n ];\n\n // Allow keydown event only if the pressed key is in the allowedKeys array\n if (!allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n private _handleInvalid() {\n this.invalid = true;\n }\n private _handleValid() {\n this.invalid = false;\n }\n\n /** Simulates a click on the plus button */\n public plus() {\n this.plusBtn.click();\n }\n\n /** Simulates a click on the minus button */\n public minus() {\n this.minusBtn.click();\n }\n\n private async _onPlus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n this.value = parseInt(sgdsInput.value) + parseInt(sgdsInput.step.toString());\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n private async _onMinus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n if (this.value < this.step) {\n this.value = 0;\n } else {\n this.value = parseInt(sgdsInput.value) - parseInt(sgdsInput.step.toString());\n }\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n\n /**\n * Validates the input on button clicks of the toggle.\n * Input is validated every time the button is click to update the invalid state\n * to indiciate the validity of quantity toggle\n * @param input native HTMLInputElement\n */\n private async _validateOnClick(input: HTMLInputElement) {\n const sgdsInput = await this._sgdsInput;\n await sgdsInput.updateComplete;\n this._mixinSetFormValue();\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(input);\n this.invalid = !this._mixinReportValidity();\n }\n\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <slot name=\"invalidIcon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\n <path\n d=\"M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n </slot>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n disabled: this.disabled\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n\n render() {\n return html`\n <div class=\"form-control-container m-width-160\">\n ${this._renderLabel()}\n <div class=\"input-group\">\n <sgds-icon-button\n class=\"minus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`decrease by ${this.step}`}\n ?disabled=${this.disabled ||\n (this.min !== undefined ? this.value <= this.min : this.value < 1) ||\n this.readonly}\n @click=${this._onMinus}\n name=\"dash\"\n >\n </sgds-icon-button>\n <sgds-input\n type=\"number\"\n class=\"quantity-toggle\"\n name=${ifDefined(this.name)}\n step=${ifDefined(this.step)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n .value=${live(this.value)}\n @sgds-change=${(e: Event) => this._handleValueChange(e, \"sgds-change\")}\n @sgds-input=${(e: Event) => this._handleValueChange(e, \"sgds-input\")}\n @sgds-invalid=${this._handleInvalid}\n @sgds-valid=${this._handleValid}\n @keydown=${this._handleKeyDown}\n ?disabled=${this.disabled}\n ?noValidate=${this._mixinShouldSkipSgdsValidation()}\n id=${this._controlId}\n ?invalid=${this.invalid}\n hasFeedback=${ifDefined(this.hasFeedback !== \"text\" ? \"style\" : undefined)}\n ></sgds-input>\n <sgds-icon-button\n class=\"plus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`increase by ${this.step}`}\n @click=${this._onPlus}\n ?disabled=${this.disabled ||\n (this.max !== undefined && this.max && this.value >= this.max) ||\n this.readonly}\n name=\"plus\"\n >\n </sgds-icon-button>\n </div>\n <div id=\"${this._controlId}-announcer\" aria-live=\"assertive\" class=\"visually-hidden\">${this.value}</div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsQuantityToggle;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,cAAwCA,uBAAAA,uBAAuBC,6BAAAA,OAAkB,CAAC,CAA4B;;;EAoBzD,KAAA,QAAA;EAGhB,KAAA,OAAA;EAasB,KAAA,aAAA;EAEF,KAAA,WAAA;EAIxC,KAAA,eAAA;;;EAzCC,KAAA,SAAA;GACd,GAAGA,6BAAAA,QAAmB;GACtBC,yBAAAA;GACAC,YAAAA;GACAC,0BAAAA;GACAC,wBAAAA;EACF;;;EAGsB,KAAA,eAAA;GACpB,cAAcC,mBAAAA;GACd,oBAAoBC,yBAAAA;EACtB;;;;;;CAqCA,iBAAiC;EAC/B,OAAO,KAAK,qBAAqB;CACnC;;;;CAIA,gBAAgC;EAC9B,OAAO,KAAK,oBAAoB;CAClC;;;;CAKA,IAAW,WAA0B;EACnC,OAAO,KAAK,kBAAkB;CAChC;;;;CAIA,IAAW,oBAA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yles","svgStyles","formControlStyle","quantityToggleStyle","SgdsInput","SgdsIconButton","classMap","ifDefined","live","query","property","defaultValue","queryAsync","watch"],"sources":["../../../../src/components/QuantityToggle/sgds-quantity-toggle.ts"],"sourcesContent":["import { property, query, queryAsync } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport svgStyles from \"../../styles/svg.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport SgdsIconButton from \"../IconButton/sgds-icon-button\";\nimport SgdsInput from \"../Input/sgds-input\";\nimport quantityToggleStyle from \"./quantity-toggle.css\";\nimport formControlStyle from \"../../styles/form-text-control.css\";\n/**\n * @summary The quantity toggle component is used to increase or decrease an incremental venue, best used when the user needs to enter or adjust the quantity of a selected item.\n *\n * @slot invalidIcon - The slot for invalid icon\n *\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-invalid - Emitted when the control's invalid state is set to true.\n * @event sgds-valid - Emitted when the control's invalid state is set to false.\n *\n */\nexport class SgdsQuantityToggle extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [\n ...FormControlElement.styles,\n formPlaceholderStyles,\n svgStyles,\n formControlStyle,\n quantityToggleStyle\n ];\n\n /** @internal */\n static dependencies = {\n \"sgds-input\": SgdsInput,\n \"sgds-icon-button\": SgdsIconButton\n };\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='increase by']\") private plusBtn: HTMLButtonElement;\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='decrease by']\") private minusBtn: HTMLButtonElement;\n\n /** The input's value. Set to 0 by default */\n @property({ type: Number, reflect: true }) value = 0;\n\n /** Controls the incremental / decremental value of the input */\n @property({ type: Number }) step = 1;\n\n /** The input's minimum value. Only applies number input types. */\n @property({ type: Number }) min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property({ type: Number }) max: number;\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n /** Disables native and sgds validation for the quantity toggle. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n /** Sets the quantity toggle as readonly */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = 0;\n\n @queryAsync(\"sgds-input\") private _sgdsInput: Promise<SgdsInput>;\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n @watch(\"value\", { waitUntilFirstUpdate: true })\n async _handleValuePropertyChange() {\n this._mixinSetFormValue();\n await this.updateComplete;\n if (this._mixinShouldSkipSgdsValidation()) return;\n const sgdsInput = await this._sgdsInput;\n this._mixinValidate(sgdsInput.input);\n }\n\n private async _handleValueChange(e: Event, eventName: \"sgds-change\" | \"sgds-input\") {\n e.stopPropagation();\n const sgdsInput = await this._sgdsInput;\n if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === \"\") {\n sgdsInput.value = \"0\";\n }\n this.value = parseInt(sgdsInput.value);\n this._mixinSetFormValue();\n this.emit(eventName);\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (eventName === \"sgds-input\") {\n this.invalid = false;\n }\n this._mixinValidate(sgdsInput.input);\n if (eventName === \"sgds-change\") {\n this.invalid = !this._mixinReportValidity();\n }\n }\n\n private async _mixinResetFormControl() {\n const sgdsInput = await this._sgdsInput;\n this.value = this.defaultValue;\n sgdsInput.input.value = this.value.toString();\n this._mixinResetValidity(sgdsInput.input);\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const allowedKeys = [\n \"Backspace\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"ArrowLeft\",\n \"ArrowRight\",\n ...Array.from(Array(10).keys()).map(key => key.toString()),\n \"Tab\"\n ];\n\n // Allow keydown event only if the pressed key is in the allowedKeys array\n if (!allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n private _handleInvalid() {\n this.invalid = true;\n }\n private _handleValid() {\n this.invalid = false;\n }\n\n /** Simulates a click on the plus button */\n public plus() {\n this.plusBtn.click();\n }\n\n /** Simulates a click on the minus button */\n public minus() {\n this.minusBtn.click();\n }\n\n private async _onPlus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n this.value = parseInt(sgdsInput.value) + parseInt(sgdsInput.step.toString());\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n private async _onMinus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n if (this.value < this.step) {\n this.value = 0;\n } else {\n this.value = parseInt(sgdsInput.value) - parseInt(sgdsInput.step.toString());\n }\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n\n /**\n * Validates the input on button clicks of the toggle.\n * Input is validated every time the button is click to update the invalid state\n * to indiciate the validity of quantity toggle\n * @param input native HTMLInputElement\n */\n private async _validateOnClick(input: HTMLInputElement) {\n const sgdsInput = await this._sgdsInput;\n await sgdsInput.updateComplete;\n this._mixinSetFormValue();\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(input);\n this.invalid = !this._mixinReportValidity();\n }\n\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <slot name=\"invalidIcon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\n <path\n d=\"M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n </slot>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n disabled: this.disabled\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n\n render() {\n return html`\n <div class=\"form-control-container m-width-160\">\n ${this._renderLabel()}\n <div class=\"input-group\">\n <sgds-icon-button\n class=\"minus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`decrease by ${this.step}`}\n ?disabled=${this.disabled ||\n (this.min !== undefined ? this.value <= this.min : this.value < 1) ||\n this.readonly}\n @click=${this._onMinus}\n name=\"dash\"\n >\n </sgds-icon-button>\n <sgds-input\n type=\"number\"\n class=\"quantity-toggle\"\n name=${ifDefined(this.name)}\n step=${ifDefined(this.step)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n .value=${live(this.value)}\n @sgds-change=${(e: Event) => this._handleValueChange(e, \"sgds-change\")}\n @sgds-input=${(e: Event) => this._handleValueChange(e, \"sgds-input\")}\n @sgds-invalid=${this._handleInvalid}\n @sgds-valid=${this._handleValid}\n @keydown=${this._handleKeyDown}\n ?disabled=${this.disabled}\n ?noValidate=${this._mixinShouldSkipSgdsValidation()}\n id=${this._controlId}\n ?invalid=${this.invalid}\n hasFeedback=${ifDefined(this.hasFeedback !== \"text\" ? \"style\" : undefined)}\n ></sgds-input>\n <sgds-icon-button\n class=\"plus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`increase by ${this.step}`}\n @click=${this._onPlus}\n ?disabled=${this.disabled ||\n (this.max !== undefined && this.max && this.value >= this.max) ||\n this.readonly}\n name=\"plus\"\n >\n </sgds-icon-button>\n </div>\n <div id=\"${this._controlId}-announcer\" aria-live=\"assertive\" class=\"visually-hidden\">${this.value}</div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsQuantityToggle;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAAwCA,uBAAAA,uBAAuBC,6BAAAA,OAAkB,CAAC,CAA4B;;;EAoBzD,KAAA,QAAA;EAGhB,KAAA,OAAA;EAasB,KAAA,aAAA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,CAAA;AAExCA,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,SAAAA,CAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,cAAA,KAAA,CAAA;AAEzCA,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,SAAAA,CAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,YAAA,KAAA,CAAA;AAGzCC,iBAAAA,QAAAA,CAAAA,qBAAAA,aAAa,CAAA,GAAA,mBAAA,WAAA,gBAAA,KAAA,CAAA;AAGbC,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,WAAAA,CAAW,YAAY,CAAA,GAAA,mBAAA,WAAA,cAAA,KAAA,CAAA;AA6BvBC,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,SAAS,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,8BAAA,IAAA"}
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
3
+ import { watch } from "../../utils/watch.js";
3
4
  import { SgdsIconButton } from "../IconButton/sgds-icon-button.js";
4
5
  import css_248z from "../../styles/form-placeholder.js";
5
6
  import FormControlElement from "../../base/form-control-element.js";
@@ -75,6 +76,13 @@ var SgdsQuantityToggle = class extends SgdsFormValidatorMixin(FormControlElement
75
76
  get validationMessage() {
76
77
  return this._mixinGetValidationMessage();
77
78
  }
79
+ async _handleValuePropertyChange() {
80
+ this._mixinSetFormValue();
81
+ await this.updateComplete;
82
+ if (this._mixinShouldSkipSgdsValidation()) return;
83
+ const sgdsInput = await this._sgdsInput;
84
+ this._mixinValidate(sgdsInput.input);
85
+ }
78
86
  async _handleValueChange(e, eventName) {
79
87
  e.stopPropagation();
80
88
  const sgdsInput = await this._sgdsInput;
@@ -262,6 +270,7 @@ __decorate([property({
262
270
  })], SgdsQuantityToggle.prototype, "readonly", void 0);
263
271
  __decorate([defaultValue()], SgdsQuantityToggle.prototype, "defaultValue", void 0);
264
272
  __decorate([queryAsync("sgds-input")], SgdsQuantityToggle.prototype, "_sgdsInput", void 0);
273
+ __decorate([watch("value", { waitUntilFirstUpdate: true })], SgdsQuantityToggle.prototype, "_handleValuePropertyChange", null);
265
274
  //#endregion
266
275
  export { SgdsQuantityToggle, SgdsQuantityToggle as default };
267
276
 
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-quantity-toggle.js","names":["formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle"],"sources":["../../../../src/components/QuantityToggle/sgds-quantity-toggle.ts"],"sourcesContent":["import { property, query, queryAsync } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport svgStyles from \"../../styles/svg.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport SgdsIconButton from \"../IconButton/sgds-icon-button\";\nimport SgdsInput from \"../Input/sgds-input\";\nimport quantityToggleStyle from \"./quantity-toggle.css\";\nimport formControlStyle from \"../../styles/form-text-control.css\";\n/**\n * @summary The quantity toggle component is used to increase or decrease an incremental venue, best used when the user needs to enter or adjust the quantity of a selected item.\n *\n * @slot invalidIcon - The slot for invalid icon\n *\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-invalid - Emitted when the control's invalid state is set to true.\n * @event sgds-valid - Emitted when the control's invalid state is set to false.\n *\n */\nexport class SgdsQuantityToggle extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [\n ...FormControlElement.styles,\n formPlaceholderStyles,\n svgStyles,\n formControlStyle,\n quantityToggleStyle\n ];\n\n /** @internal */\n static dependencies = {\n \"sgds-input\": SgdsInput,\n \"sgds-icon-button\": SgdsIconButton\n };\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='increase by']\") private plusBtn: HTMLButtonElement;\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='decrease by']\") private minusBtn: HTMLButtonElement;\n\n /** The input's value. Set to 0 by default */\n @property({ type: Number, reflect: true }) value = 0;\n\n /** Controls the incremental / decremental value of the input */\n @property({ type: Number }) step = 1;\n\n /** The input's minimum value. Only applies number input types. */\n @property({ type: Number }) min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property({ type: Number }) max: number;\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n /** Disables native and sgds validation for the quantity toggle. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n /** Sets the quantity toggle as readonly */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = 0;\n\n @queryAsync(\"sgds-input\") private _sgdsInput: Promise<SgdsInput>;\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n private async _handleValueChange(e: Event, eventName: \"sgds-change\" | \"sgds-input\") {\n e.stopPropagation();\n const sgdsInput = await this._sgdsInput;\n if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === \"\") {\n sgdsInput.value = \"0\";\n }\n this.value = parseInt(sgdsInput.value);\n this._mixinSetFormValue();\n this.emit(eventName);\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (eventName === \"sgds-input\") {\n this.invalid = false;\n }\n this._mixinValidate(sgdsInput.input);\n if (eventName === \"sgds-change\") {\n this.invalid = !this._mixinReportValidity();\n }\n }\n\n private async _mixinResetFormControl() {\n const sgdsInput = await this._sgdsInput;\n this.value = this.defaultValue;\n sgdsInput.input.value = this.value.toString();\n this._mixinResetValidity(sgdsInput.input);\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const allowedKeys = [\n \"Backspace\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"ArrowLeft\",\n \"ArrowRight\",\n ...Array.from(Array(10).keys()).map(key => key.toString()),\n \"Tab\"\n ];\n\n // Allow keydown event only if the pressed key is in the allowedKeys array\n if (!allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n private _handleInvalid() {\n this.invalid = true;\n }\n private _handleValid() {\n this.invalid = false;\n }\n\n /** Simulates a click on the plus button */\n public plus() {\n this.plusBtn.click();\n }\n\n /** Simulates a click on the minus button */\n public minus() {\n this.minusBtn.click();\n }\n\n private async _onPlus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n this.value = parseInt(sgdsInput.value) + parseInt(sgdsInput.step.toString());\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n private async _onMinus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n if (this.value < this.step) {\n this.value = 0;\n } else {\n this.value = parseInt(sgdsInput.value) - parseInt(sgdsInput.step.toString());\n }\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n\n /**\n * Validates the input on button clicks of the toggle.\n * Input is validated every time the button is click to update the invalid state\n * to indiciate the validity of quantity toggle\n * @param input native HTMLInputElement\n */\n private async _validateOnClick(input: HTMLInputElement) {\n const sgdsInput = await this._sgdsInput;\n await sgdsInput.updateComplete;\n this._mixinSetFormValue();\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(input);\n this.invalid = !this._mixinReportValidity();\n }\n\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <slot name=\"invalidIcon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\n <path\n d=\"M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n </slot>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n disabled: this.disabled\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n\n render() {\n return html`\n <div class=\"form-control-container m-width-160\">\n ${this._renderLabel()}\n <div class=\"input-group\">\n <sgds-icon-button\n class=\"minus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`decrease by ${this.step}`}\n ?disabled=${this.disabled ||\n (this.min !== undefined ? this.value <= this.min : this.value < 1) ||\n this.readonly}\n @click=${this._onMinus}\n name=\"dash\"\n >\n </sgds-icon-button>\n <sgds-input\n type=\"number\"\n class=\"quantity-toggle\"\n name=${ifDefined(this.name)}\n step=${ifDefined(this.step)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n .value=${live(this.value)}\n @sgds-change=${(e: Event) => this._handleValueChange(e, \"sgds-change\")}\n @sgds-input=${(e: Event) => this._handleValueChange(e, \"sgds-input\")}\n @sgds-invalid=${this._handleInvalid}\n @sgds-valid=${this._handleValid}\n @keydown=${this._handleKeyDown}\n ?disabled=${this.disabled}\n ?noValidate=${this._mixinShouldSkipSgdsValidation()}\n id=${this._controlId}\n ?invalid=${this.invalid}\n hasFeedback=${ifDefined(this.hasFeedback !== \"text\" ? \"style\" : undefined)}\n ></sgds-input>\n <sgds-icon-button\n class=\"plus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`increase by ${this.step}`}\n @click=${this._onPlus}\n ?disabled=${this.disabled ||\n (this.max !== undefined && this.max && this.value >= this.max) ||\n this.readonly}\n name=\"plus\"\n >\n </sgds-icon-button>\n </div>\n <div id=\"${this._controlId}-announcer\" aria-live=\"assertive\" class=\"visually-hidden\">${this.value}</div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsQuantityToggle;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,cAAwC,uBAAuB,kBAAkB,CAAC,CAA4B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;AAGlD,WAAA,CAAA,SAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,SAAA,KAAA,CAAA;AAGxC,WAAA,CAAA,SAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,mBAAA,WAAA,QAAA,KAAA,CAAA;AAGzB,WAAA,CAAA,SAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,mBAAA,WAAA,OAAA,KAAA,CAAA;AAGzB,WAAA,CAAA,SAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,mBAAA,WAAA,OAAA,KAAA,CAAA;AAEzB,WAAA,CAAA,SAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,eAAA,KAAA,CAAA;AAGxC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,mBAAA,KAAA,CAAA;AAExC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,cAAA,KAAA,CAAA;AAEzC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,YAAA,KAAA,CAAA;AAGzC,WAAA,CAAA,aAAa,CAAA,GAAA,mBAAA,WAAA,gBAAA,KAAA,CAAA;AAGb,WAAA,CAAA,WAAW,YAAY,CAAA,GAAA,mBAAA,WAAA,cAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"sgds-quantity-toggle.js","names":["formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle"],"sources":["../../../../src/components/QuantityToggle/sgds-quantity-toggle.ts"],"sourcesContent":["import { property, query, queryAsync } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { html } from \"lit/static-html.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport formPlaceholderStyles from \"../../styles/form-placeholder.css\";\nimport svgStyles from \"../../styles/svg.css\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport { SgdsFormControl } from \"../../utils/formSubmitController\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport SgdsIconButton from \"../IconButton/sgds-icon-button\";\nimport SgdsInput from \"../Input/sgds-input\";\nimport quantityToggleStyle from \"./quantity-toggle.css\";\nimport formControlStyle from \"../../styles/form-text-control.css\";\n/**\n * @summary The quantity toggle component is used to increase or decrease an incremental venue, best used when the user needs to enter or adjust the quantity of a selected item.\n *\n * @slot invalidIcon - The slot for invalid icon\n *\n * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.\n * @event sgds-input - Emitted when the control receives input and its value changes.\n * @event sgds-invalid - Emitted when the control's invalid state is set to true.\n * @event sgds-valid - Emitted when the control's invalid state is set to false.\n *\n */\nexport class SgdsQuantityToggle extends SgdsFormValidatorMixin(FormControlElement) implements SgdsFormControl {\n static styles = [\n ...FormControlElement.styles,\n formPlaceholderStyles,\n svgStyles,\n formControlStyle,\n quantityToggleStyle\n ];\n\n /** @internal */\n static dependencies = {\n \"sgds-input\": SgdsInput,\n \"sgds-icon-button\": SgdsIconButton\n };\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='increase by']\") private plusBtn: HTMLButtonElement;\n /** @internal */\n @query(\"sgds-icon-button[ariaLabel^='decrease by']\") private minusBtn: HTMLButtonElement;\n\n /** The input's value. Set to 0 by default */\n @property({ type: Number, reflect: true }) value = 0;\n\n /** Controls the incremental / decremental value of the input */\n @property({ type: Number }) step = 1;\n\n /** The input's minimum value. Only applies number input types. */\n @property({ type: Number }) min: number;\n\n /** The input's maximum value. Only applies number input types. */\n @property({ type: Number }) max: number;\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: String, reflect: true }) hasFeedback: \"style\" | \"text\" | \"both\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback: string;\n /** Disables native and sgds validation for the quantity toggle. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n /** Sets the quantity toggle as readonly */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue()\n defaultValue = 0;\n\n @queryAsync(\"sgds-input\") private _sgdsInput: Promise<SgdsInput>;\n\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n @watch(\"value\", { waitUntilFirstUpdate: true })\n async _handleValuePropertyChange() {\n this._mixinSetFormValue();\n await this.updateComplete;\n if (this._mixinShouldSkipSgdsValidation()) return;\n const sgdsInput = await this._sgdsInput;\n this._mixinValidate(sgdsInput.input);\n }\n\n private async _handleValueChange(e: Event, eventName: \"sgds-change\" | \"sgds-input\") {\n e.stopPropagation();\n const sgdsInput = await this._sgdsInput;\n if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === \"\") {\n sgdsInput.value = \"0\";\n }\n this.value = parseInt(sgdsInput.value);\n this._mixinSetFormValue();\n this.emit(eventName);\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (eventName === \"sgds-input\") {\n this.invalid = false;\n }\n this._mixinValidate(sgdsInput.input);\n if (eventName === \"sgds-change\") {\n this.invalid = !this._mixinReportValidity();\n }\n }\n\n private async _mixinResetFormControl() {\n const sgdsInput = await this._sgdsInput;\n this.value = this.defaultValue;\n sgdsInput.input.value = this.value.toString();\n this._mixinResetValidity(sgdsInput.input);\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const allowedKeys = [\n \"Backspace\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"ArrowLeft\",\n \"ArrowRight\",\n ...Array.from(Array(10).keys()).map(key => key.toString()),\n \"Tab\"\n ];\n\n // Allow keydown event only if the pressed key is in the allowedKeys array\n if (!allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n private _handleInvalid() {\n this.invalid = true;\n }\n private _handleValid() {\n this.invalid = false;\n }\n\n /** Simulates a click on the plus button */\n public plus() {\n this.plusBtn.click();\n }\n\n /** Simulates a click on the minus button */\n public minus() {\n this.minusBtn.click();\n }\n\n private async _onPlus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n this.value = parseInt(sgdsInput.value) + parseInt(sgdsInput.step.toString());\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n private async _onMinus(event: MouseEvent) {\n const sgdsInput = await this._sgdsInput;\n event.preventDefault();\n event.stopPropagation();\n if (this.value < this.step) {\n this.value = 0;\n } else {\n this.value = parseInt(sgdsInput.value) - parseInt(sgdsInput.step.toString());\n }\n this._validateOnClick(sgdsInput.input);\n this.emit(\"sgds-change\");\n }\n\n /**\n * Validates the input on button clicks of the toggle.\n * Input is validated every time the button is click to update the invalid state\n * to indiciate the validity of quantity toggle\n * @param input native HTMLInputElement\n */\n private async _validateOnClick(input: HTMLInputElement) {\n const sgdsInput = await this._sgdsInput;\n await sgdsInput.updateComplete;\n this._mixinSetFormValue();\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(input);\n this.invalid = !this._mixinReportValidity();\n }\n\n protected _renderFeedback() {\n const wantFeedbackText = this.hasFeedback === \"both\" || this.hasFeedback === \"text\";\n return this.invalid && wantFeedbackText\n ? html` <div class=\"invalid-feedback-container\">\n <slot name=\"invalidIcon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\n <path\n d=\"M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n </slot>\n <div id=\"${this._controlId}-invalid\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.validationMessage}\n </div>\n </div>`\n : html`${this._renderHintText()}`;\n }\n\n protected _renderLabel() {\n const labelTemplate = html`\n <label\n for=${this._controlId}\n id=${this._labelId}\n class=${classMap({\n \"form-label\": true,\n disabled: this.disabled\n })}\n >${this.label}</label\n >\n `;\n return this.label && labelTemplate;\n }\n\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n\n render() {\n return html`\n <div class=\"form-control-container m-width-160\">\n ${this._renderLabel()}\n <div class=\"input-group\">\n <sgds-icon-button\n class=\"minus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`decrease by ${this.step}`}\n ?disabled=${this.disabled ||\n (this.min !== undefined ? this.value <= this.min : this.value < 1) ||\n this.readonly}\n @click=${this._onMinus}\n name=\"dash\"\n >\n </sgds-icon-button>\n <sgds-input\n type=\"number\"\n class=\"quantity-toggle\"\n name=${ifDefined(this.name)}\n step=${ifDefined(this.step)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n .value=${live(this.value)}\n @sgds-change=${(e: Event) => this._handleValueChange(e, \"sgds-change\")}\n @sgds-input=${(e: Event) => this._handleValueChange(e, \"sgds-input\")}\n @sgds-invalid=${this._handleInvalid}\n @sgds-valid=${this._handleValid}\n @keydown=${this._handleKeyDown}\n ?disabled=${this.disabled}\n ?noValidate=${this._mixinShouldSkipSgdsValidation()}\n id=${this._controlId}\n ?invalid=${this.invalid}\n hasFeedback=${ifDefined(this.hasFeedback !== \"text\" ? \"style\" : undefined)}\n ></sgds-input>\n <sgds-icon-button\n class=\"plus-btn\"\n variant=\"outline\"\n tone=\"neutral\"\n size=\"md\"\n ariaLabel=${`increase by ${this.step}`}\n @click=${this._onPlus}\n ?disabled=${this.disabled ||\n (this.max !== undefined && this.max && this.value >= this.max) ||\n this.readonly}\n name=\"plus\"\n >\n </sgds-icon-button>\n </div>\n <div id=\"${this._controlId}-announcer\" aria-live=\"assertive\" class=\"visually-hidden\">${this.value}</div>\n ${this._renderFeedback()}\n </div>\n `;\n }\n}\n\nexport default SgdsQuantityToggle;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAAwC,uBAAuB,kBAAkB,CAAC,CAA4B;;;EAoBzD,KAAA,QAAA;EAGhB,KAAA,OAAA;EAasB,KAAA,aAAA;EAEF,KAAA,WAAA;EAIxC,KAAA,eAAA;;;EAzCC,KAAA,SAAA;GACd,GAAG,mBAAmB;GACtBA;GACAC;GACAC;GACAC;EACF;;;EAGsB,KAAA,eAAA;GACpB,cAAc;GACd,oBAAoB;EACtB;;;;;;CAqCA,iBAAiC;EAC/B,OAAO,KAAK,qBAAqB;CACnC;;;;CAIA,gBAAgC;EAC9B,OAAO,KAAK,oBAAoB;CAClC;;;;CAKA,IAAW,WAA0B;EACnC,OAAO,KAA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A,CAAA,SAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,mBAAA,WAAA,OAAA,KAAA,CAAA;AAGzB,WAAA,CAAA,SAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,mBAAA,WAAA,OAAA,KAAA,CAAA;AAEzB,WAAA,CAAA,SAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,eAAA,KAAA,CAAA;AAGxC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,mBAAA,KAAA,CAAA;AAExC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,cAAA,KAAA,CAAA;AAEzC,WAAA,CAAA,SAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,YAAA,KAAA,CAAA;AAGzC,WAAA,CAAA,aAAa,CAAA,GAAA,mBAAA,WAAA,gBAAA,KAAA,CAAA;AAGb,WAAA,CAAA,WAAW,YAAY,CAAA,GAAA,mBAAA,WAAA,cAAA,KAAA,CAAA;AA6BvB,WAAA,CAAA,MAAM,SAAS,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,mBAAA,WAAA,8BAAA,IAAA"}
@@ -36,8 +36,12 @@ var SgdsRadioGroup = class extends require_validatorMixin.SgdsFormValidatorMixin
36
36
  static {
37
37
  this.styles = [...require_form_control_element.default.styles, require_radio_group.default];
38
38
  }
39
- _handleValueChange() {
39
+ async _handleValueChange() {
40
40
  this._updateCheckedRadio();
41
+ this._mixinSetFormValue();
42
+ await this.updateComplete;
43
+ if (this._mixinShouldSkipSgdsValidation()) return;
44
+ this._mixinValidate(this.input);
41
45
  }
42
46
  _handleInvalidChange() {
43
47
  this._radios.forEach((r) => r.invalid = this.invalid);
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-radio-group.cjs.js","names":["SgdsFormValidatorMixin","FormControlElement","radioGroupStyles","classMap","live","nothing","query","state","property","watch","queryAssignedElements"],"sources":["../../../../src/components/Radio/sgds-radio-group.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { live } from \"lit/directives/live.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport radioGroupStyles from \"./radio-group.css\";\nimport SgdsRadio from \"./sgds-radio\";\nimport type { ISgdsRadioGroupChangeEventDetail } from \"./types\";\nexport type { ISgdsRadioGroupChangeEventDetail };\n\n/**\n * @summary RadioGroup group multiple radios so they function as a single form control.\n *\n * @slot default - The default slot where sgds-radio are placed.\n * @slot invalidIcon - The slot for invalid icon\n *\n * @event sgds-change - Emitted when the radio group's selected value changes.\n * @eventDetail {ISgdsRadioGroupChangeEventDetail} sgds-change\n * @event sgds-invalid - Emitted when the radio group's invalid state is set to true.\n * @event sgds-valid - Emitted when the radio group's invalid state is set to false.\n *\n */\nexport class SgdsRadioGroup extends SgdsFormValidatorMixin(FormControlElement) {\n static styles = [...FormControlElement.styles, radioGroupStyles];\n\n /**@internal */\n @query(\"slot:not([name])\") defaultSlot: HTMLSlotElement;\n\n /**@internal */\n @state() defaultValue = \"\";\n\n /** The selected value of the control. */\n @property({ reflect: true }) value = \"\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback = \"\";\n\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: Boolean, reflect: true }) hasFeedback = false;\n\n /** Makes the input as a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Disables native and sgds validation for the radio group. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n\n /** Automatically focuses the selected radio input in the group when it becomes checked. */\n @property({ type: Boolean, reflect: true }) autofocus = false;\n\n @watch(\"value\", { waitUntilFirstUpdate: true })\n _handleValueChange() {\n this._updateCheckedRadio();\n }\n @watch(\"invalid\", { waitUntilFirstUpdate: true })\n _handleInvalidChange() {\n this._radios.forEach(r => (r.invalid = this.invalid));\n }\n\n @state() private _isTouched = false;\n /**\n * radio requries a custom _mixinResetFormControl as the update of input value\n * requires to fire a reset event manually\n * */\n private _mixinResetFormControl() {\n this.value = this.input.value = this.defaultValue;\n this._updateInputValue(\"reset\");\n this._mixinResetValidity(this.input);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.defaultValue = this.value;\n this.addEventListener(\"sgds-blur\", () => {\n this._isTouched = true;\n });\n }\n\n firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n const radios = this._radios;\n radios.forEach((item, index) => {\n if (radios.length > 1) {\n switch (index) {\n case 0:\n item.setAttribute(\"first-of-type\", \"\");\n break;\n\n case radios.length - 1:\n item.setAttribute(\"last-of-type\", \"\");\n break;\n\n default:\n item.setAttribute(\"nth-of-type\", \"\");\n }\n }\n });\n if (this.value) {\n this._updateInputValue(\"change\");\n }\n }\n\n @queryAssignedElements()\n private _radios!: Array<SgdsRadio>;\n\n private _handleRadioClick(event: MouseEvent) {\n event.preventDefault();\n const target = event.target as SgdsRadio;\n\n if (target.disabled) {\n return;\n }\n\n this.value = target.value;\n this.emit<ISgdsRadioGroupChangeEventDetail>(\"sgds-change\", { detail: { value: this.value } });\n\n this._updateInputValue();\n\n const radios = this._radios;\n\n radios.forEach(radio => {\n return (radio.checked = radio === target);\n });\n }\n /**\n * when input value is set programatically, need to manually dispatch a change event\n * In order to prevent race conditions and ensure sequence of events, set input's value here instead of binding to value prop of input\n */\n private _updateInputValue(eventName = \"change\") {\n this.input.value = this.value;\n this.input.dispatchEvent(new InputEvent(eventName));\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n if (![\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\", \" \"].includes(event.key)) {\n return;\n }\n\n const radios = this._radios.filter(radio => !radio.disabled);\n const checkedRadio = radios.find(radio => radio.checked) ?? radios[0];\n //if eventkey is space, index increment is 0, if eventkey arrowup/arrowleft, index is -1, arrowright/arrowdown, index incr is 1\n const incr = event.key === \" \" ? 0 : [\"ArrowUp\", \"ArrowLeft\"].includes(event.key) ? -1 : 1;\n let index = radios.indexOf(checkedRadio) + incr;\n if (index < 0) {\n index = radios.length - 1;\n }\n if (index > radios.length - 1) {\n index = 0;\n }\n\n this._radios.forEach(radio => {\n radio.checked = false;\n radio.tabIndex = -1;\n });\n\n this.value = radios[index].value;\n this.emit<ISgdsRadioGroupChangeEventDetail>(\"sgds-change\", { detail: { value: this.value } });\n this._updateInputValue();\n radios[index].checked = true;\n radios[index].tabIndex = 0;\n // preventDefault at the end to allow Tab\n event.preventDefault();\n }\n\n private _handleSlotChange() {\n const radios = this._radios;\n\n radios.forEach(radio => {\n radio.autofocus = this.autofocus;\n radio.checked = radio.value === this.value;\n\n return radio;\n });\n this._disabledChildRadios();\n if (!radios.some(radio => radio.checked)) {\n if (radios[0]) radios[0].tabIndex = 0;\n }\n }\n\n private _updateCheckedRadio() {\n const radios = this._radios;\n radios.forEach(radio => (radio.checked = radio.value === this.value));\n }\n\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n @watch(\"_isTouched\", { waitUntilFirstUpdate: true })\n _handleIsTouched() {\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (this._isTouched) {\n this.invalid = !this.input.checkValidity();\n }\n }\n\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.setInvalid(false);\n this._disabledChildRadios();\n }\n\n private _disabledChildRadios() {\n if (this.disabled) {\n const radios = this._radios;\n radios.forEach(radio => (radio.disabled = this.disabled));\n }\n }\n\n render() {\n const defaultSlot = html`\n <slot\n class=\"radio-container\"\n @click=${this._handleRadioClick}\n @keydown=${this._handleKeyDown}\n @slotchange=${this._handleSlotChange}\n role=\"presentation\"\n ></slot>\n `;\n return html`\n <fieldset name=${this.name}>\n <div class=\"label-hint-container\">\n <label\n class=${classMap({\n \"form-label\": true,\n required: this.required\n })}\n >\n ${this.label}\n </label>\n ${this._renderHintText()}\n </div>\n ${defaultSlot}\n <input\n type=\"text\"\n class=\"radio-group-validation-input ${classMap({\n \"is-invalid\": this.hasFeedback && this.invalid\n })}\"\n ?required=${this.required}\n tabindex=\"-1\"\n @change=${(e: Event) => super._mixinHandleChange(e)}\n .value=${live(this.value)}\n aria-describedby=${this.invalid && this.hasFeedback ? \"radio-group-feedback\" : `${this._controlId}Help`}\n />\n ${this.invalid && this.hasFeedback\n ? html`\n <div class=\"invalid-feedback-container\">\n <slot name=\"invalidIcon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\n <path\n d=\"M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n </slot>\n <div id=\"radio-group-feedback\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}\n </div>\n </div>\n `\n : nothing}\n </fieldset>\n `;\n }\n}\n\nexport default SgdsRadioGroup;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAa,iBAAb,cAAoCA,uBAAAA,uBAAuBC,6BAAAA,OAAkB,CAAC,CAAC;;;EAOrD,KAAA,eAAA;EAGa,KAAA,QAAA;EAGwB,KAAA,kBAAA;EAGH,KAAA,cAAA;EAGH,KAAA,WAAA;EAGE,KAAA,aAAA;EAGD,KAAA,YAAA;EAW1B,KAAA,aAAA;;;EAnCd,KAAA,SAAA,CAAC,GAAGA,6BAAAA,QAAmB,QAAQC,oBAAAA,OAAgB;;CA0B/D,qBACqB;EACnB,KAAK,oBAAoB;CAC3B;CACA,uBACuB;EACrB,KAAK,QAAQ,SAAQ,MAAM,EAAE,UAAU,KAAK,OAAQ;CACtD;;;;;CAOA,yBAAiC;EAC/B,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK;EACrC,KAAK,kBAAkB,OAAO;EAC9B,KAAK,oBAAoB,KAAK,KAAK;CACrC;CAEA,oBAAoB;EAClB,MAAM,kBAAkB;EACxB,KAAK,eAAe,KAAK;EACzB,KAAK,iBAAiB,mBAAmB;GACvC,KAAK,aAAa;EACpB,CAAC;CACH;CAEA,aAAa,mBAA2C;EACtD,MAAM,aAAa,iBAAiB;EACpC,MAAM,SAAS,KAAK;EACpB,OAAO,SAAS,MAAM,UAAU;GAC9B,IAAI,OAAO,SAAS,GAClB,QAAQ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AA,WAAA,eAAA,KAAA,CAAA;AAGzCA,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,SAAAA,CAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,eAAA,WAAA,YAAA,KAAA,CAAA;AAGzCA,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,SAAAA,CAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,eAAA,WAAA,cAAA,KAAA,CAAA;AAGzCA,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,SAAAA,CAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,eAAA,WAAA,aAAA,KAAA,CAAA;AAEzCC,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,SAAS,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,eAAA,WAAA,sBAAA,IAAA;AAI7CA,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,WAAW,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,eAAA,WAAA,wBAAA,IAAA;AAK/CF,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,MAAAA,CAAM,CAAA,GAAA,eAAA,WAAA,cAAA,KAAA,CAAA;AA2CNG,iBAAAA,QAAAA,EAAAA,GAAAA,kBAAAA,sBAAAA,CAAsB,CAAA,GAAA,eAAA,WAAA,WAAA,KAAA,CAAA;AAiHtBD,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,cAAc,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,eAAA,WAAA,oBAAA,IAAA;AAQlDA,iBAAAA,QAAAA,CAAAA,cAAAA,MAAM,YAAY,EAAE,sBAAsB,KAAK,CAAC,CAAA,GAAA,eAAA,WAAA,yBAAA,IAAA"}
1
+ {"version":3,"file":"sgds-radio-group.cjs.js","names":["SgdsFormValidatorMixin","FormControlElement","radioGroupStyles","classMap","live","nothing","query","state","property","watch","queryAssignedElements"],"sources":["../../../../src/components/Radio/sgds-radio-group.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { live } from \"lit/directives/live.js\";\nimport FormControlElement from \"../../base/form-control-element\";\nimport { SgdsFormValidatorMixin } from \"../../utils/validatorMixin\";\nimport { watch } from \"../../utils/watch\";\nimport radioGroupStyles from \"./radio-group.css\";\nimport SgdsRadio from \"./sgds-radio\";\nimport type { ISgdsRadioGroupChangeEventDetail } from \"./types\";\nexport type { ISgdsRadioGroupChangeEventDetail };\n\n/**\n * @summary RadioGroup group multiple radios so they function as a single form control.\n *\n * @slot default - The default slot where sgds-radio are placed.\n * @slot invalidIcon - The slot for invalid icon\n *\n * @event sgds-change - Emitted when the radio group's selected value changes.\n * @eventDetail {ISgdsRadioGroupChangeEventDetail} sgds-change\n * @event sgds-invalid - Emitted when the radio group's invalid state is set to true.\n * @event sgds-valid - Emitted when the radio group's invalid state is set to false.\n *\n */\nexport class SgdsRadioGroup extends SgdsFormValidatorMixin(FormControlElement) {\n static styles = [...FormControlElement.styles, radioGroupStyles];\n\n /**@internal */\n @query(\"slot:not([name])\") defaultSlot: HTMLSlotElement;\n\n /**@internal */\n @state() defaultValue = \"\";\n\n /** The selected value of the control. */\n @property({ reflect: true }) value = \"\";\n\n /**Feedback text for error state when validated */\n @property({ type: String, reflect: true }) invalidFeedback = \"\";\n\n /** Allows invalidFeedback, invalid and valid styles to be visible with the input */\n @property({ type: Boolean, reflect: true }) hasFeedback = false;\n\n /** Makes the input as a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Disables native and sgds validation for the radio group. */\n @property({ type: Boolean, reflect: true }) noValidate = false;\n\n /** Automatically focuses the selected radio input in the group when it becomes checked. */\n @property({ type: Boolean, reflect: true }) autofocus = false;\n\n @watch(\"value\", { waitUntilFirstUpdate: true })\n async _handleValueChange() {\n this._updateCheckedRadio();\n this._mixinSetFormValue();\n await this.updateComplete;\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(this.input);\n }\n @watch(\"invalid\", { waitUntilFirstUpdate: true })\n _handleInvalidChange() {\n this._radios.forEach(r => (r.invalid = this.invalid));\n }\n\n @state() private _isTouched = false;\n /**\n * radio requries a custom _mixinResetFormControl as the update of input value\n * requires to fire a reset event manually\n * */\n private _mixinResetFormControl() {\n this.value = this.input.value = this.defaultValue;\n this._updateInputValue(\"reset\");\n this._mixinResetValidity(this.input);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.defaultValue = this.value;\n this.addEventListener(\"sgds-blur\", () => {\n this._isTouched = true;\n });\n }\n\n firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n const radios = this._radios;\n radios.forEach((item, index) => {\n if (radios.length > 1) {\n switch (index) {\n case 0:\n item.setAttribute(\"first-of-type\", \"\");\n break;\n\n case radios.length - 1:\n item.setAttribute(\"last-of-type\", \"\");\n break;\n\n default:\n item.setAttribute(\"nth-of-type\", \"\");\n }\n }\n });\n if (this.value) {\n this._updateInputValue(\"change\");\n }\n }\n\n @queryAssignedElements()\n private _radios!: Array<SgdsRadio>;\n\n private _handleRadioClick(event: MouseEvent) {\n event.preventDefault();\n const target = event.target as SgdsRadio;\n\n if (target.disabled) {\n return;\n }\n\n this.value = target.value;\n this.emit<ISgdsRadioGroupChangeEventDetail>(\"sgds-change\", { detail: { value: this.value } });\n\n this._updateInputValue();\n\n const radios = this._radios;\n\n radios.forEach(radio => {\n return (radio.checked = radio === target);\n });\n }\n /**\n * when input value is set programatically, need to manually dispatch a change event\n * In order to prevent race conditions and ensure sequence of events, set input's value here instead of binding to value prop of input\n */\n private _updateInputValue(eventName = \"change\") {\n this.input.value = this.value;\n this.input.dispatchEvent(new InputEvent(eventName));\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n if (![\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\", \" \"].includes(event.key)) {\n return;\n }\n\n const radios = this._radios.filter(radio => !radio.disabled);\n const checkedRadio = radios.find(radio => radio.checked) ?? radios[0];\n //if eventkey is space, index increment is 0, if eventkey arrowup/arrowleft, index is -1, arrowright/arrowdown, index incr is 1\n const incr = event.key === \" \" ? 0 : [\"ArrowUp\", \"ArrowLeft\"].includes(event.key) ? -1 : 1;\n let index = radios.indexOf(checkedRadio) + incr;\n if (index < 0) {\n index = radios.length - 1;\n }\n if (index > radios.length - 1) {\n index = 0;\n }\n\n this._radios.forEach(radio => {\n radio.checked = false;\n radio.tabIndex = -1;\n });\n\n this.value = radios[index].value;\n this.emit<ISgdsRadioGroupChangeEventDetail>(\"sgds-change\", { detail: { value: this.value } });\n this._updateInputValue();\n radios[index].checked = true;\n radios[index].tabIndex = 0;\n // preventDefault at the end to allow Tab\n event.preventDefault();\n }\n\n private _handleSlotChange() {\n const radios = this._radios;\n\n radios.forEach(radio => {\n radio.autofocus = this.autofocus;\n radio.checked = radio.value === this.value;\n\n return radio;\n });\n this._disabledChildRadios();\n if (!radios.some(radio => radio.checked)) {\n if (radios[0]) radios[0].tabIndex = 0;\n }\n }\n\n private _updateCheckedRadio() {\n const radios = this._radios;\n radios.forEach(radio => (radio.checked = radio.value === this.value));\n }\n\n protected _renderHintText() {\n const hintTextTemplate = html` <div id=\"${this._controlId}Help\" class=\"form-text\">${this.hintText}</div> `;\n return this.hintText && hintTextTemplate;\n }\n /**\n * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state\n * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput\n */\n public reportValidity(): boolean {\n return this._mixinReportValidity();\n }\n /**\n * Checks for validity without any native error popup message\n */\n public checkValidity(): boolean {\n return this._mixinCheckValidity();\n }\n\n /**\n * Returns the ValidityState object\n */\n public get validity(): ValidityState {\n return this._mixinGetValidity();\n }\n /**\n * Returns the validation message based on the ValidityState\n */\n public get validationMessage() {\n return this._mixinGetValidationMessage();\n }\n\n @watch(\"_isTouched\", { waitUntilFirstUpdate: true })\n _handleIsTouched() {\n if (this._mixinShouldSkipSgdsValidation()) return;\n if (this._isTouched) {\n this.invalid = !this.input.checkValidity();\n }\n }\n\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.setInvalid(false);\n this._disabledChildRadios();\n }\n\n private _disabledChildRadios() {\n if (this.disabled) {\n const radios = this._radios;\n radios.forEach(radio => (radio.disabled = this.disabled));\n }\n }\n\n render() {\n const defaultSlot = html`\n <slot\n class=\"radio-container\"\n @click=${this._handleRadioClick}\n @keydown=${this._handleKeyDown}\n @slotchange=${this._handleSlotChange}\n role=\"presentation\"\n ></slot>\n `;\n return html`\n <fieldset name=${this.name}>\n <div class=\"label-hint-container\">\n <label\n class=${classMap({\n \"form-label\": true,\n required: this.required\n })}\n >\n ${this.label}\n </label>\n ${this._renderHintText()}\n </div>\n ${defaultSlot}\n <input\n type=\"text\"\n class=\"radio-group-validation-input ${classMap({\n \"is-invalid\": this.hasFeedback && this.invalid\n })}\"\n ?required=${this.required}\n tabindex=\"-1\"\n @change=${(e: Event) => super._mixinHandleChange(e)}\n .value=${live(this.value)}\n aria-describedby=${this.invalid && this.hasFeedback ? \"radio-group-feedback\" : `${this._controlId}Help`}\n />\n ${this.invalid && this.hasFeedback\n ? html`\n <div class=\"invalid-feedback-container\">\n <slot name=\"invalidIcon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\n <path\n d=\"M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n </slot>\n <div id=\"radio-group-feedback\" class=\"invalid-feedback\">\n ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}\n </div>\n </div>\n `\n : nothing}\n </fieldset>\n `;\n }\n}\n\nexport default SgdsRadioGroup;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAa,iBAAb,cAAoCA,uBAAAA,uBAAuBC,6BAAAA,OAAkB,CAAC,CAAC;;;EAOrD,KAAA,eAAA;EAGa,KAAA,QAAA;EAGwB,KAAA,kBAAA;EAGH,KAAA,cAAA;EAGH,KAAA,WAAA;EAGE,KAAA,aAAA;EAGD,KAAA,YAAA;EAe1B,KAAA,aAAA;;;EAvCd,KAAA,SAAA,CAAC,GAAGA,6BAAAA,QAAmB,QAAQC,oBAAAA,OAAgB;;CA0B/D,MACM,qBAAqB;EACzB,KAAK,oBAAoB;EACzB,KAAK,mBAAmB;EACxB,MAAM,KAAK;EACX,IAAI,KAAK,+BAA+B,GAAG;EAC3C,KAAK,eAAe,KAAK,KAAK;CAChC;CACA,uBACuB;EACrB,KAAK,QAAQ,SAAQ,MAAM,EAAE,UAAU,KAAK,OAAQ;CACtD;;;;;CAOA,yBAAiC;EAC/B,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK;EACrC,KAAK,kBAAkB,OAAO;EAC9B,KAAK,oBAAoB,KAAK,KAAK;CACrC;CAEA,oBAAoB;EAClB,MAAM,kBAAkB;EACxB,KAAK,eAAe,KAAK;EACzB,KAAK,iBAAiB,mBAAmB;GACvC,KAAK,aAAa;EACpB,CAAC;CACH;CAEA,aAAa,mBAA2C;EACtD,MAAM,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 @@ var SgdsRadioGroup = class extends SgdsFormValidatorMixin(FormControlElement) {
36
36
  static {
37
37
  this.styles = [...FormControlElement.styles, css_248z];
38
38
  }
39
- _handleValueChange() {
39
+ async _handleValueChange() {
40
40
  this._updateCheckedRadio();
41
+ this._mixinSetFormValue();
42
+ await this.updateComplete;
43
+ if (this._mixinShouldSkipSgdsValidation()) return;
44
+ this._mixinValidate(this.input);
41
45
  }
42
46
  _handleInvalidChange() {
43
47
  this._radios.forEach((r) => r.invalid = this.invalid);