@govtechsg/sgds-web-component 3.26.1-rc.0 → 3.26.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/QuantityToggle/index.umd.min.js +22 -22
- package/components/QuantityToggle/index.umd.min.js.map +1 -1
- package/components/QuantityToggle/sgds-quantity-toggle.js +9 -11
- package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
- package/components/index.umd.min.js +69 -69
- package/components/index.umd.min.js.map +1 -1
- package/css/fouc.css +1 -1
- package/custom-elements.json +392 -376
- package/index.umd.min.js +63 -63
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js +9 -11
- package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
- package/react/components/QuantityToggle/sgds-quantity-toggle.js +9 -11
- package/react/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
- package/react/index.cjs.js +6 -6
- package/react/index.d.ts +1 -1
- package/react/index.js +1 -1
- package/types/react.d.ts +16 -16
package/package.json
CHANGED
|
@@ -69,34 +69,32 @@ class SgdsQuantityToggle extends validatorMixin.SgdsFormValidatorMixin(formContr
|
|
|
69
69
|
get validationMessage() {
|
|
70
70
|
return this._mixinGetValidationMessage();
|
|
71
71
|
}
|
|
72
|
-
async _handleChange() {
|
|
72
|
+
async _handleChange(e) {
|
|
73
|
+
e.stopPropagation();
|
|
73
74
|
const sgdsInput = await this._sgdsInput;
|
|
74
75
|
if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === "") {
|
|
75
76
|
sgdsInput.value = "0";
|
|
76
77
|
}
|
|
77
78
|
this.value = parseInt(sgdsInput.value);
|
|
78
79
|
this._mixinSetFormValue();
|
|
80
|
+
this.emit("sgds-change");
|
|
79
81
|
if (this._mixinShouldSkipSgdsValidation())
|
|
80
82
|
return;
|
|
81
83
|
this._mixinValidate(sgdsInput.input);
|
|
82
84
|
this.invalid = !this._mixinReportValidity();
|
|
83
85
|
}
|
|
84
|
-
async _handleInputChange() {
|
|
86
|
+
async _handleInputChange(e) {
|
|
87
|
+
e.stopPropagation();
|
|
85
88
|
const sgdsInput = await this._sgdsInput;
|
|
86
|
-
if (this._mixinShouldSkipSgdsValidation()) {
|
|
87
|
-
if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === "") {
|
|
88
|
-
sgdsInput.value = "0";
|
|
89
|
-
}
|
|
90
|
-
this.value = parseInt(sgdsInput.value);
|
|
91
|
-
this._mixinSetFormValue();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.invalid = false;
|
|
95
89
|
if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === "") {
|
|
96
90
|
sgdsInput.value = "0";
|
|
97
91
|
}
|
|
98
92
|
this.value = parseInt(sgdsInput.value);
|
|
99
93
|
this._mixinSetFormValue();
|
|
94
|
+
this.emit("sgds-input");
|
|
95
|
+
if (this._mixinShouldSkipSgdsValidation())
|
|
96
|
+
return;
|
|
97
|
+
this.invalid = false;
|
|
100
98
|
this._mixinValidate(sgdsInput.input);
|
|
101
99
|
}
|
|
102
100
|
async _mixinResetFormControl() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-quantity-toggle.cjs.js","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 _handleChange() {\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 if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(sgdsInput.input);\n this.invalid = !this._mixinReportValidity();\n }\n private async _handleInputChange() {\n const sgdsInput = await this._sgdsInput;\n if (this._mixinShouldSkipSgdsValidation()) {\n if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === \"\") {\n sgdsInput.value = \"0\";\n }\n this.value = parseInt(sgdsInput.value);\n this._mixinSetFormValue();\n return;\n }\n this.invalid = false;\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._mixinValidate(sgdsInput.input);\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=${this._handleChange}\n @sgds-input=${this._handleInputChange}\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"],"names":["SgdsFormValidatorMixin","FormControlElement","html","classMap","ifDefined","live","formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle","SgdsInput","SgdsIconButton","__decorate","query","property","defaultValue","queryAsync"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;AAUG;MACU,kBAAmB,SAAQA,qCAAsB,CAACC,6BAAkB,CAAC,CAAA;AAAlF,IAAA,WAAA,GAAA;;;QAoB6C,IAAK,CAAA,KAAA,GAAG,CAAC,CAAC;;QAGzB,IAAI,CAAA,IAAA,GAAG,CAAC,CAAC;;QAaO,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAEnB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAI7D,IAAY,CAAA,YAAA,GAAG,CAAC,CAAC;KAyOlB;AArOC;;;AAGG;IACI,cAAc,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;KACpC;AACD;;AAEG;IACI,aAAa,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;KACnC;AAED;;AAEG;AACH,IAAA,IAAW,QAAQ,GAAA;AACjB,QAAA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,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI7DF,gBAAA,CAAA;AADC,IAAAG,yBAAY,EAAE;AACE,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEiBH,gBAAA,CAAA;IAAjCI,wBAAU,CAAC,YAAY,CAAC;AAAwC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-quantity-toggle.cjs.js","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 _handleChange(e: Event) {\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(\"sgds-change\");\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(sgdsInput.input);\n this.invalid = !this._mixinReportValidity();\n }\n private async _handleInputChange(e: Event) {\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(\"sgds-input\");\n if (this._mixinShouldSkipSgdsValidation()) return;\n this.invalid = false;\n this._mixinValidate(sgdsInput.input);\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=${this._handleChange}\n @sgds-input=${this._handleInputChange}\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"],"names":["SgdsFormValidatorMixin","FormControlElement","html","classMap","ifDefined","live","formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle","SgdsInput","SgdsIconButton","__decorate","query","property","defaultValue","queryAsync"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;AAUG;MACU,kBAAmB,SAAQA,qCAAsB,CAACC,6BAAkB,CAAC,CAAA;AAAlF,IAAA,WAAA,GAAA;;;QAoB6C,IAAK,CAAA,KAAA,GAAG,CAAC,CAAC;;QAGzB,IAAI,CAAA,IAAA,GAAG,CAAC,CAAC;;QAaO,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAEnB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAI7D,IAAY,CAAA,YAAA,GAAG,CAAC,CAAC;KAsOlB;AAlOC;;;AAGG;IACI,cAAc,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;KACpC;AACD;;AAEG;IACI,aAAa,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;KACnC;AAED;;AAEG;AACH,IAAA,IAAW,QAAQ,GAAA;AACjB,QAAA,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;KACjC;AACD;;AAEG;AACH,IAAA,IAAW,iBAAiB,GAAA;AAC1B,QAAA,OAAO,IAAI,CAAC,0BAA0B,EAAE,CAAC;KAC1C;IAEO,MAAM,aAAa,CAAC,CAAQ,EAAA;QAClC,CAAC,CAAC,eAAe,EAAE,CAAC;AACpB,QAAA,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;AACxC,QAAA,IAAI,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,KAAK,KAAK,EAAE,EAAE;AACnE,YAAA,SAAS,CAAC,KAAK,GAAG,GAAG,CAAC;SACvB;QACD,IAAI,CAAC,KAAK,GAAG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MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAwC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGvCF,gBAAA,CAAA;IAA1CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAyB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEvBF,gBAAA,CAAA;IAA3CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAoB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEnBF,gBAAA,CAAA;IAA3CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAkB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI7DF,gBAAA,CAAA;AADC,IAAAG,yBAAY,EAAE;AACE,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEiBH,gBAAA,CAAA;IAAjCI,wBAAU,CAAC,YAAY,CAAC;AAAwC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
|
|
@@ -65,34 +65,32 @@ class SgdsQuantityToggle extends SgdsFormValidatorMixin(FormControlElement) {
|
|
|
65
65
|
get validationMessage() {
|
|
66
66
|
return this._mixinGetValidationMessage();
|
|
67
67
|
}
|
|
68
|
-
async _handleChange() {
|
|
68
|
+
async _handleChange(e) {
|
|
69
|
+
e.stopPropagation();
|
|
69
70
|
const sgdsInput = await this._sgdsInput;
|
|
70
71
|
if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === "") {
|
|
71
72
|
sgdsInput.value = "0";
|
|
72
73
|
}
|
|
73
74
|
this.value = parseInt(sgdsInput.value);
|
|
74
75
|
this._mixinSetFormValue();
|
|
76
|
+
this.emit("sgds-change");
|
|
75
77
|
if (this._mixinShouldSkipSgdsValidation())
|
|
76
78
|
return;
|
|
77
79
|
this._mixinValidate(sgdsInput.input);
|
|
78
80
|
this.invalid = !this._mixinReportValidity();
|
|
79
81
|
}
|
|
80
|
-
async _handleInputChange() {
|
|
82
|
+
async _handleInputChange(e) {
|
|
83
|
+
e.stopPropagation();
|
|
81
84
|
const sgdsInput = await this._sgdsInput;
|
|
82
|
-
if (this._mixinShouldSkipSgdsValidation()) {
|
|
83
|
-
if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === "") {
|
|
84
|
-
sgdsInput.value = "0";
|
|
85
|
-
}
|
|
86
|
-
this.value = parseInt(sgdsInput.value);
|
|
87
|
-
this._mixinSetFormValue();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
this.invalid = false;
|
|
91
85
|
if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === "") {
|
|
92
86
|
sgdsInput.value = "0";
|
|
93
87
|
}
|
|
94
88
|
this.value = parseInt(sgdsInput.value);
|
|
95
89
|
this._mixinSetFormValue();
|
|
90
|
+
this.emit("sgds-input");
|
|
91
|
+
if (this._mixinShouldSkipSgdsValidation())
|
|
92
|
+
return;
|
|
93
|
+
this.invalid = false;
|
|
96
94
|
this._mixinValidate(sgdsInput.input);
|
|
97
95
|
}
|
|
98
96
|
async _mixinResetFormControl() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-quantity-toggle.js","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 _handleChange() {\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 if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(sgdsInput.input);\n this.invalid = !this._mixinReportValidity();\n }\n private async _handleInputChange() {\n const sgdsInput = await this._sgdsInput;\n if (this._mixinShouldSkipSgdsValidation()) {\n if (parseInt(sgdsInput.value) < this.step || sgdsInput.value === \"\") {\n sgdsInput.value = \"0\";\n }\n this.value = parseInt(sgdsInput.value);\n this._mixinSetFormValue();\n return;\n }\n this.invalid = false;\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._mixinValidate(sgdsInput.input);\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=${this._handleChange}\n @sgds-input=${this._handleInputChange}\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"],"names":["formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle"],"mappings":";;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;AAUG;MACU,kBAAmB,SAAQ,sBAAsB,CAAC,kBAAkB,CAAC,CAAA;AAAlF,IAAA,WAAA,GAAA;;;QAoB6C,IAAK,CAAA,KAAA,GAAG,CAAC,CAAC;;QAGzB,IAAI,CAAA,IAAA,GAAG,CAAC,CAAC;;QAaO,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAEnB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAI7D,IAAY,CAAA,YAAA,GAAG,CAAC,CAAC;KAyOlB;AArOC;;;AAGG;IACI,cAAc,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,oBAAoB,EA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E,OAAO,EAAE,IAAI,EAAE,CAAC;AAAkB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI7D,UAAA,CAAA;AADC,IAAA,YAAY,EAAE;AACE,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEiB,UAAA,CAAA;IAAjC,UAAU,CAAC,YAAY,CAAC;AAAwC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-quantity-toggle.js","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 _handleChange(e: Event) {\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(\"sgds-change\");\n if (this._mixinShouldSkipSgdsValidation()) return;\n this._mixinValidate(sgdsInput.input);\n this.invalid = !this._mixinReportValidity();\n }\n private async _handleInputChange(e: Event) {\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(\"sgds-input\");\n if (this._mixinShouldSkipSgdsValidation()) return;\n this.invalid = false;\n this._mixinValidate(sgdsInput.input);\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=${this._handleChange}\n @sgds-input=${this._handleInputChange}\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"],"names":["formPlaceholderStyles","svgStyles","formControlStyle","quantityToggleStyle"],"mappings":";;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;AAUG;MACU,kBAAmB,SAAQ,sBAAsB,CAAC,kBAAkB,CAAC,CAAA;AAAlF,IAAA,WAAA,GAAA;;;QAoB6C,IAAK,CAAA,KAAA,GAAG,CAAC,CAAC;;QAGzB,IAAI,CAAA,IAAA,GAAG,CAAC,CAAC;;QAaO,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAEnB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAI7D,IAAY,CAAA,YAAA,GAAG,CAAC,CAAC;KAsOlB;AAlOC;;;AAGG;IACI,cAAc,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;KACpC;AACD;;AAEG;IACI,aAAa,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;KACnC;AAED;;AAEG;AACH,IAAA,IAAW,QAAQ,GAAA;AACjB,QAAA,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;KACjC;AACD;;AAEG;AACH,IAAA,IAAW,iBAAiB,GAAA;AAC1B,QAAA,OAAO,IAAI,CAAC,0BAA0B,EAAE,CAAC;KAC1C;IAEO,MAAM,aAAa,CAAC,CAAQ,EAAA;QAClC,CAAC,CAAC,eAAe,EAAE,CAAC;AACpB,QAAA,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;AACxC,QAAA,IAAI,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,KAAK,KAAK,EAAE,EAAE;AACnE,YAAA,SAAS,CAAC,KAAK,GAAG,GAAG,CAAC;SACvB;QACD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC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AA,CAAA,CAAA;AAGvC,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAyB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEvB,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAoB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEnB,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAkB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI7D,UAAA,CAAA;AADC,IAAA,YAAY,EAAE;AACE,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEiB,UAAA,CAAA;IAAjC,UAAU,CAAC,YAAY,CAAC;AAAwC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
package/react/index.cjs.js
CHANGED
|
@@ -8,9 +8,9 @@ var index$1 = require('./accordion/index.cjs.js');
|
|
|
8
8
|
var index$2 = require('./alert-link/index.cjs.js');
|
|
9
9
|
var index$3 = require('./alert/index.cjs.js');
|
|
10
10
|
var index$4 = require('./badge/index.cjs.js');
|
|
11
|
-
var index$5 = require('./
|
|
12
|
-
var index$6 = require('./breadcrumb/index.cjs.js');
|
|
13
|
-
var index$7 = require('./
|
|
11
|
+
var index$5 = require('./button/index.cjs.js');
|
|
12
|
+
var index$6 = require('./breadcrumb-item/index.cjs.js');
|
|
13
|
+
var index$7 = require('./breadcrumb/index.cjs.js');
|
|
14
14
|
var index$8 = require('./card/index.cjs.js');
|
|
15
15
|
var index$9 = require('./checkbox-group/index.cjs.js');
|
|
16
16
|
var index$a = require('./checkbox/index.cjs.js');
|
|
@@ -88,9 +88,9 @@ exports.SgdsAccordion = index$1["default"];
|
|
|
88
88
|
exports.SgdsAlertLink = index$2["default"];
|
|
89
89
|
exports.SgdsAlert = index$3["default"];
|
|
90
90
|
exports.SgdsBadge = index$4["default"];
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
91
|
+
exports.SgdsButton = index$5["default"];
|
|
92
|
+
exports.SgdsBreadcrumbItem = index$6["default"];
|
|
93
|
+
exports.SgdsBreadcrumb = index$7["default"];
|
|
94
94
|
exports.SgdsCard = index$8["default"];
|
|
95
95
|
exports.SgdsCheckboxGroup = index$9["default"];
|
|
96
96
|
exports.SgdsCheckbox = index$a["default"];
|
package/react/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ export { default as SgdsAccordion } from './accordion';
|
|
|
3
3
|
export { default as SgdsAlertLink } from './alert-link';
|
|
4
4
|
export { default as SgdsAlert } from './alert';
|
|
5
5
|
export { default as SgdsBadge } from './badge';
|
|
6
|
+
export { default as SgdsButton } from './button';
|
|
6
7
|
export { default as SgdsBreadcrumbItem } from './breadcrumb-item';
|
|
7
8
|
export { default as SgdsBreadcrumb } from './breadcrumb';
|
|
8
|
-
export { default as SgdsButton } from './button';
|
|
9
9
|
export { default as SgdsCard } from './card';
|
|
10
10
|
export { default as SgdsCheckboxGroup } from './checkbox-group';
|
|
11
11
|
export { default as SgdsCheckbox } from './checkbox';
|
package/react/index.js
CHANGED
|
@@ -4,9 +4,9 @@ export { default as SgdsAccordion } from './accordion/index.js';
|
|
|
4
4
|
export { default as SgdsAlertLink } from './alert-link/index.js';
|
|
5
5
|
export { default as SgdsAlert } from './alert/index.js';
|
|
6
6
|
export { default as SgdsBadge } from './badge/index.js';
|
|
7
|
+
export { default as SgdsButton } from './button/index.js';
|
|
7
8
|
export { default as SgdsBreadcrumbItem } from './breadcrumb-item/index.js';
|
|
8
9
|
export { default as SgdsBreadcrumb } from './breadcrumb/index.js';
|
|
9
|
-
export { default as SgdsButton } from './button/index.js';
|
|
10
10
|
export { default as SgdsCard } from './card/index.js';
|
|
11
11
|
export { default as SgdsCheckboxGroup } from './checkbox-group/index.js';
|
|
12
12
|
export { default as SgdsCheckbox } from './checkbox/index.js';
|
package/types/react.d.ts
CHANGED
|
@@ -193,20 +193,6 @@ Variants include: `primary`, `accent`, `success`, `danger`, `warning`, `cyan`, `
|
|
|
193
193
|
onSgdsAfterHide?: SgdsEventHandler;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
// ── BreadcrumbItem ─────────────────────────────────────────────────────────────
|
|
197
|
-
|
|
198
|
-
export interface SgdsBreadcrumbItemProps extends SgdsBaseProps {
|
|
199
|
-
/** Indicates the link matches the current location of the page. Programmatically handled by SgdsBreadcrumb to set this prop to true for the last breadcrumb item */
|
|
200
|
-
active?: boolean;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ── Breadcrumb ─────────────────────────────────────────────────────────────
|
|
204
|
-
|
|
205
|
-
export interface SgdsBreadcrumbProps extends SgdsBaseProps {
|
|
206
|
-
/** The aria-label of nav element within breadcrumb component. */
|
|
207
|
-
ariaLabel?: string;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
196
|
// ── Button ─────────────────────────────────────────────────────────────
|
|
211
197
|
|
|
212
198
|
export interface SgdsButtonProps extends SgdsBaseProps {
|
|
@@ -263,6 +249,20 @@ value of this attribute must be an id of a form in the same document or shadow r
|
|
|
263
249
|
onSgdsFocus?: SgdsEventHandler;
|
|
264
250
|
}
|
|
265
251
|
|
|
252
|
+
// ── BreadcrumbItem ─────────────────────────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
export interface SgdsBreadcrumbItemProps extends SgdsBaseProps {
|
|
255
|
+
/** Indicates the link matches the current location of the page. Programmatically handled by SgdsBreadcrumb to set this prop to true for the last breadcrumb item */
|
|
256
|
+
active?: boolean;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ── Breadcrumb ─────────────────────────────────────────────────────────────
|
|
260
|
+
|
|
261
|
+
export interface SgdsBreadcrumbProps extends SgdsBaseProps {
|
|
262
|
+
/** The aria-label of nav element within breadcrumb component. */
|
|
263
|
+
ariaLabel?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
266
|
// ── Card ─────────────────────────────────────────────────────────────
|
|
267
267
|
|
|
268
268
|
export interface SgdsCardProps extends SgdsBaseProps {
|
|
@@ -1825,9 +1825,9 @@ declare module "react" {
|
|
|
1825
1825
|
"sgds-alert-link": React.DetailedHTMLProps<SgdsAlertLinkProps, HTMLElement>;
|
|
1826
1826
|
"sgds-alert": React.DetailedHTMLProps<SgdsAlertProps, HTMLElement>;
|
|
1827
1827
|
"sgds-badge": React.DetailedHTMLProps<SgdsBadgeProps, HTMLElement>;
|
|
1828
|
+
"sgds-button": React.DetailedHTMLProps<SgdsButtonProps, HTMLElement>;
|
|
1828
1829
|
"sgds-breadcrumb-item": React.DetailedHTMLProps<SgdsBreadcrumbItemProps, HTMLElement>;
|
|
1829
1830
|
"sgds-breadcrumb": React.DetailedHTMLProps<SgdsBreadcrumbProps, HTMLElement>;
|
|
1830
|
-
"sgds-button": React.DetailedHTMLProps<SgdsButtonProps, HTMLElement>;
|
|
1831
1831
|
"sgds-card": React.DetailedHTMLProps<SgdsCardProps, HTMLElement>;
|
|
1832
1832
|
"sgds-checkbox-group": React.DetailedHTMLProps<SgdsCheckboxGroupProps, HTMLElement>;
|
|
1833
1833
|
"sgds-checkbox": React.DetailedHTMLProps<SgdsCheckboxProps, HTMLElement>;
|
|
@@ -1912,9 +1912,9 @@ declare global {
|
|
|
1912
1912
|
"sgds-alert-link": HTMLElement;
|
|
1913
1913
|
"sgds-alert": HTMLElement;
|
|
1914
1914
|
"sgds-badge": HTMLElement;
|
|
1915
|
+
"sgds-button": HTMLElement;
|
|
1915
1916
|
"sgds-breadcrumb-item": HTMLElement;
|
|
1916
1917
|
"sgds-breadcrumb": HTMLElement;
|
|
1917
|
-
"sgds-button": HTMLElement;
|
|
1918
1918
|
"sgds-card": HTMLElement;
|
|
1919
1919
|
"sgds-checkbox-group": HTMLElement;
|
|
1920
1920
|
"sgds-checkbox": HTMLElement;
|