@govtechsg/sgds-web-component 3.21.2-rc.0 → 3.21.2-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/Button/index.umd.min.js +5 -3
- package/components/Button/index.umd.min.js.map +1 -1
- package/components/Button/sgds-button.d.ts +4 -0
- package/components/Button/sgds-button.js +8 -0
- package/components/Button/sgds-button.js.map +1 -1
- package/components/Datepicker/index.umd.min.js +14 -12
- package/components/Datepicker/index.umd.min.js.map +1 -1
- package/components/FileUpload/index.umd.min.js +4 -2
- package/components/FileUpload/index.umd.min.js.map +1 -1
- package/components/Pagination/index.umd.min.js +4 -2
- package/components/Pagination/index.umd.min.js.map +1 -1
- package/components/index.umd.min.js +4 -2
- package/components/index.umd.min.js.map +1 -1
- package/css/fouc.css +1 -1
- package/custom-elements.json +643 -607
- package/index.umd.min.js +4 -2
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Button/sgds-button.cjs.js +8 -0
- package/react/components/Button/sgds-button.cjs.js.map +1 -1
- package/react/components/Button/sgds-button.js +8 -0
- package/react/components/Button/sgds-button.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/react/utils/formSubmitController.cjs.js +5 -0
- package/react/utils/formSubmitController.cjs.js.map +1 -1
- package/react/utils/formSubmitController.js +5 -0
- package/react/utils/formSubmitController.js.map +1 -1
- package/types/react.d.ts +20 -16
- package/utils/formSubmitController.js +5 -0
- package/utils/formSubmitController.js.map +1 -1
|
@@ -16,6 +16,10 @@ export declare class SgdsButton extends ButtonElement {
|
|
|
16
16
|
static styles: import("lit").CSSResult[];
|
|
17
17
|
/** @internal */
|
|
18
18
|
private readonly formSubmitController;
|
|
19
|
+
/** The name of the button, submitted as a name/value pair with form data only when this button is the submitter. Only works with `type="submit"`. Has no effect when the button is rendered as a link (i.e. when `href` is set). */
|
|
20
|
+
name: string;
|
|
21
|
+
/** The value of the button, submitted as a name/value pair with form data only when this button is the submitter. Only works with `type="submit"`. Has no effect when the button is rendered as a link (i.e. when `href` is set). */
|
|
22
|
+
value: string;
|
|
19
23
|
/** The behavior of the button with default as `type='button', `reset` resets all the controls to their initial values and `submit` submits the form data to the server */
|
|
20
24
|
type: "button" | "submit" | "reset";
|
|
21
25
|
/**
|
|
@@ -87,6 +87,8 @@ class SgdsButton extends ButtonElement {
|
|
|
87
87
|
})}"
|
|
88
88
|
?disabled=${ifDefined(isLink ? undefined : this.disabled)}
|
|
89
89
|
type=${ifDefined(isLink ? undefined : this.type)}
|
|
90
|
+
name=${ifDefined(isLink ? undefined : this.name)}
|
|
91
|
+
value=${ifDefined(isLink ? undefined : this.value)}
|
|
90
92
|
href=${ifDefined(isLink ? this.href : undefined)}
|
|
91
93
|
target=${ifDefined(isLink ? this.target : undefined)}
|
|
92
94
|
download=${ifDefined(isLink ? this.download : undefined)}
|
|
@@ -114,6 +116,12 @@ class SgdsButton extends ButtonElement {
|
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
SgdsButton.styles = [...ButtonElement.styles, css_248z, css_248z$1];
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: String, reflect: true })
|
|
121
|
+
], SgdsButton.prototype, "name", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
property({ type: String, reflect: true })
|
|
124
|
+
], SgdsButton.prototype, "value", void 0);
|
|
117
125
|
__decorate([
|
|
118
126
|
property({ type: String, reflect: true })
|
|
119
127
|
], SgdsButton.prototype, "type", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-button.js","sources":["../../../src/components/Button/sgds-button.ts"],"sourcesContent":["import { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport ButtonElement from \"../../base/button-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { FormSubmitController } from \"../../utils/formSubmitController\";\nimport anchorStyles from \"../../styles/anchor.css\";\nimport buttonStyles from \"./button.css\";\n\nexport type ButtonVariant = \"primary\" | \"outline\" | \"ghost\" | \"danger\";\n\n/**\n * @summary Custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.\n *\n * @slot default - The button's label.\n * @slot leftIcon - The slot for icon to the left of the button text\n * @slot rightIcon - The slot for icon to the right of the button text\n *\n * @event sgds-blur - Emitted when the button is blurred.\n * @event sgds-focus - Emitted when the button is focused.\n *\n *\n */\nexport class SgdsButton extends ButtonElement {\n static styles = [...ButtonElement.styles, anchorStyles, buttonStyles];\n\n /** @internal */\n private readonly formSubmitController = new FormSubmitController(this, {\n form: (input: HTMLInputElement) => {\n // Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query\n // the form from the same root using its id\n if (input.hasAttribute(\"form\")) {\n const doc = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute(\"form\");\n return doc.getElementById(formId) as HTMLFormElement;\n }\n\n // Fall back to the closest containing form\n return input.closest(\"form\");\n }\n });\n /** The behavior of the button with default as `type='button', `reset` resets all the controls to their initial values and `submit` submits the form data to the server */\n @property({ type: String, reflect: true }) type: \"button\" | \"submit\" | \"reset\" = \"button\";\n /**\n * The \"form owner\" to associate the button with. If omitted, the closest containing form will be used instead. The\n * value of this attribute must be an id of a form in the same document or shadow root as the button.\n */\n @property({ type: String, reflect: true }) form: string;\n\n /** Used to override the form owner's `action` attribute. */\n @property({ type: String, reflect: true, attribute: \"formaction\" }) formAction: string;\n\n /** Used to override the form owner's `method` attribute. */\n @property({ type: String, reflect: true, attribute: \"formmethod\" }) formMethod: \"post\" | \"get\";\n\n /** Used to override the form owner's `novalidate` attribute. */\n @property({ attribute: \"formnovalidate\", type: Boolean, reflect: true })\n formNoValidate: boolean;\n\n /** Used to override the form owner's `target` attribute. */\n @property({ type: String, reflect: true, attribute: \"formtarget\" }) formTarget:\n | \"_self\"\n | \"_blank\"\n | \"_parent\"\n | \"_top\"\n | string;\n\n /** When set, the button will be in full width. */\n @property({ type: Boolean, reflect: true }) fullWidth = false;\n\n /** Used only for SSR to indicate the presence of the `leftIcon` slot. */\n @property({ type: Boolean }) hasLeftIconSlot = false;\n\n /** Used only for SSR to indicate the presence of the `rightIcon` slot. */\n @property({ type: Boolean }) hasRightIconSlot = false;\n\n private readonly hasSlotController = new HasSlotController(this, \"leftIcon\", \"rightIcon\");\n\n updated() {\n if (!this.hasLeftIconSlot) this.hasLeftIconSlot = this.hasSlotController.test(\"leftIcon\");\n if (!this.hasRightIconSlot) this.hasRightIconSlot = this.hasSlotController.test(\"rightIcon\");\n }\n\n protected override _handleClick(event: MouseEvent) {\n if (this.disabled || this.loading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.removeEventListener(\"click\", this._clickHandler);\n this.addEventListener(\"click\", this._clickHandler);\n }\n\n private _clickHandler = () => {\n if (this.type === \"submit\") {\n this.formSubmitController.submit(this);\n }\n if (this.type === \"reset\") {\n this.formSubmitController.reset(this);\n }\n };\n\n render() {\n const isLink = this.href;\n const tag = isLink ? literal`a` : literal`button`;\n const noIcon = !this.hasLeftIconSlot && !this.hasRightIconSlot;\n\n return html`\n <${tag}\n class=\"btn ${classMap({\n disabled: this.disabled,\n active: this.active,\n \"has-left-icon\": this.hasLeftIconSlot,\n \"has-right-icon\": this.hasRightIconSlot,\n \"no-icon\": noIcon,\n loading: this.loading\n })}\"\n ?disabled=${ifDefined(isLink ? undefined : this.disabled)}\n type=${ifDefined(isLink ? undefined : this.type)}\n href=${ifDefined(isLink ? this.href : undefined)}\n target=${ifDefined(isLink ? this.target : undefined)}\n download=${ifDefined(isLink ? this.download : undefined)}\n rel=${ifDefined(isLink && this.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n role=${ifDefined(isLink ? \"button\" : undefined)}\n aria-disabled=${this.disabled || this.loading ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this._handleClick}\n @keydown=${this._handleKeydown}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-label=${ifDefined(this.loading ? \"Loading\" : this.ariaLabel)}\n >\n ${\n this.loading\n ? html`<sgds-spinner\n size=${ifDefined(this._assignSpinnerSize(this.size))}\n tone=${ifDefined(this._assignSpinnerTone(this.tone, this.variant))}\n ></sgds-spinner>`\n : html`<slot name=\"leftIcon\"></slot>\n <span><slot></slot></span>\n <slot name=\"rightIcon\"></slot>`\n }\n \n </${tag}>\n `;\n }\n}\n\nexport default SgdsButton;\n"],"names":["anchorStyles","buttonStyles"],"mappings":";;;;;;;;;;;AAYA;;;;;;;;;;;AAWG;AACG,MAAO,UAAW,SAAQ,aAAa,CAAA;AAA7C,IAAA,WAAA,GAAA;;;AAImB,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE;AACrE,YAAA,IAAI,EAAE,CAAC,KAAuB,KAAI;;;AAGhC,gBAAA,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;AAC9B,oBAAA,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAA2B,CAAC;oBACzD,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC1C,oBAAA,OAAO,GAAG,CAAC,cAAc,CAAC,MAAM,CAAoB,CAAC;iBACtD;;AAGD,gBAAA,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAC9B;AACF,SAAA,CAAC,CAAC;;QAEwC,IAAI,CAAA,IAAA,GAAkC,QAAQ,CAAC;;QA0B9C,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;;QAGjC,IAAe,CAAA,eAAA,GAAG,KAAK,CAAC;;QAGxB,IAAgB,CAAA,gBAAA,GAAG,KAAK,CAAC;QAErC,IAAiB,CAAA,iBAAA,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAiBlF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AAC;AAA4B,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI/F,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG4C,UAAA,CAAA;AAAnE,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAKxD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGiC,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGjC,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAyB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGxB,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAA0B,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-button.js","sources":["../../../src/components/Button/sgds-button.ts"],"sourcesContent":["import { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport ButtonElement from \"../../base/button-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { FormSubmitController } from \"../../utils/formSubmitController\";\nimport anchorStyles from \"../../styles/anchor.css\";\nimport buttonStyles from \"./button.css\";\n\nexport type ButtonVariant = \"primary\" | \"outline\" | \"ghost\" | \"danger\";\n\n/**\n * @summary Custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.\n *\n * @slot default - The button's label.\n * @slot leftIcon - The slot for icon to the left of the button text\n * @slot rightIcon - The slot for icon to the right of the button text\n *\n * @event sgds-blur - Emitted when the button is blurred.\n * @event sgds-focus - Emitted when the button is focused.\n *\n *\n */\nexport class SgdsButton extends ButtonElement {\n static styles = [...ButtonElement.styles, anchorStyles, buttonStyles];\n\n /** @internal */\n private readonly formSubmitController = new FormSubmitController(this, {\n form: (input: HTMLInputElement) => {\n // Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query\n // the form from the same root using its id\n if (input.hasAttribute(\"form\")) {\n const doc = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute(\"form\");\n return doc.getElementById(formId) as HTMLFormElement;\n }\n\n // Fall back to the closest containing form\n return input.closest(\"form\");\n }\n });\n /** The name of the button, submitted as a name/value pair with form data only when this button is the submitter. Only works with `type=\"submit\"`. Has no effect when the button is rendered as a link (i.e. when `href` is set). */\n @property({ type: String, reflect: true }) name: string;\n\n /** The value of the button, submitted as a name/value pair with form data only when this button is the submitter. Only works with `type=\"submit\"`. Has no effect when the button is rendered as a link (i.e. when `href` is set). */\n @property({ type: String, reflect: true }) value: string;\n\n /** The behavior of the button with default as `type='button', `reset` resets all the controls to their initial values and `submit` submits the form data to the server */\n @property({ type: String, reflect: true }) type: \"button\" | \"submit\" | \"reset\" = \"button\";\n /**\n * The \"form owner\" to associate the button with. If omitted, the closest containing form will be used instead. The\n * value of this attribute must be an id of a form in the same document or shadow root as the button.\n */\n @property({ type: String, reflect: true }) form: string;\n\n /** Used to override the form owner's `action` attribute. */\n @property({ type: String, reflect: true, attribute: \"formaction\" }) formAction: string;\n\n /** Used to override the form owner's `method` attribute. */\n @property({ type: String, reflect: true, attribute: \"formmethod\" }) formMethod: \"post\" | \"get\";\n\n /** Used to override the form owner's `novalidate` attribute. */\n @property({ attribute: \"formnovalidate\", type: Boolean, reflect: true })\n formNoValidate: boolean;\n\n /** Used to override the form owner's `target` attribute. */\n @property({ type: String, reflect: true, attribute: \"formtarget\" }) formTarget:\n | \"_self\"\n | \"_blank\"\n | \"_parent\"\n | \"_top\"\n | string;\n\n /** When set, the button will be in full width. */\n @property({ type: Boolean, reflect: true }) fullWidth = false;\n\n /** Used only for SSR to indicate the presence of the `leftIcon` slot. */\n @property({ type: Boolean }) hasLeftIconSlot = false;\n\n /** Used only for SSR to indicate the presence of the `rightIcon` slot. */\n @property({ type: Boolean }) hasRightIconSlot = false;\n\n private readonly hasSlotController = new HasSlotController(this, \"leftIcon\", \"rightIcon\");\n\n updated() {\n if (!this.hasLeftIconSlot) this.hasLeftIconSlot = this.hasSlotController.test(\"leftIcon\");\n if (!this.hasRightIconSlot) this.hasRightIconSlot = this.hasSlotController.test(\"rightIcon\");\n }\n\n protected override _handleClick(event: MouseEvent) {\n if (this.disabled || this.loading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.removeEventListener(\"click\", this._clickHandler);\n this.addEventListener(\"click\", this._clickHandler);\n }\n\n private _clickHandler = () => {\n if (this.type === \"submit\") {\n this.formSubmitController.submit(this);\n }\n if (this.type === \"reset\") {\n this.formSubmitController.reset(this);\n }\n };\n\n render() {\n const isLink = this.href;\n const tag = isLink ? literal`a` : literal`button`;\n const noIcon = !this.hasLeftIconSlot && !this.hasRightIconSlot;\n\n return html`\n <${tag}\n class=\"btn ${classMap({\n disabled: this.disabled,\n active: this.active,\n \"has-left-icon\": this.hasLeftIconSlot,\n \"has-right-icon\": this.hasRightIconSlot,\n \"no-icon\": noIcon,\n loading: this.loading\n })}\"\n ?disabled=${ifDefined(isLink ? undefined : this.disabled)}\n type=${ifDefined(isLink ? undefined : this.type)}\n name=${ifDefined(isLink ? undefined : this.name)}\n value=${ifDefined(isLink ? undefined : this.value)}\n href=${ifDefined(isLink ? this.href : undefined)}\n target=${ifDefined(isLink ? this.target : undefined)}\n download=${ifDefined(isLink ? this.download : undefined)}\n rel=${ifDefined(isLink && this.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n role=${ifDefined(isLink ? \"button\" : undefined)}\n aria-disabled=${this.disabled || this.loading ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this._handleClick}\n @keydown=${this._handleKeydown}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-label=${ifDefined(this.loading ? \"Loading\" : this.ariaLabel)}\n >\n ${\n this.loading\n ? html`<sgds-spinner\n size=${ifDefined(this._assignSpinnerSize(this.size))}\n tone=${ifDefined(this._assignSpinnerTone(this.tone, this.variant))}\n ></sgds-spinner>`\n : html`<slot name=\"leftIcon\"></slot>\n <span><slot></slot></span>\n <slot name=\"rightIcon\"></slot>`\n }\n \n </${tag}>\n `;\n }\n}\n\nexport default SgdsButton;\n"],"names":["anchorStyles","buttonStyles"],"mappings":";;;;;;;;;;;AAYA;;;;;;;;;;;AAWG;AACG,MAAO,UAAW,SAAQ,aAAa,CAAA;AAA7C,IAAA,WAAA,GAAA;;;AAImB,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE;AACrE,YAAA,IAAI,EAAE,CAAC,KAAuB,KAAI;;;AAGhC,gBAAA,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;AAC9B,oBAAA,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAA2B,CAAC;oBACzD,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC1C,oBAAA,OAAO,GAAG,CAAC,cAAc,CAAC,MAAM,CAAoB,CAAC;iBACtD;;AAGD,gBAAA,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM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