@govtechsg/sgds-web-component 3.3.2 → 3.3.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/Masthead/index.js +2 -2
  2. package/base/card.js +1 -1
  3. package/base/sgds-element2.js +1 -1
  4. package/components/Accordion/index.umd.js +1 -1
  5. package/components/Alert/index.umd.js +2 -2
  6. package/components/Badge/index.umd.js +1 -1
  7. package/components/Breadcrumb/index.umd.js +36 -11
  8. package/components/Breadcrumb/index.umd.js.map +1 -1
  9. package/components/Button/button.js +1 -1
  10. package/components/Button/index.umd.js +61 -54
  11. package/components/Button/index.umd.js.map +1 -1
  12. package/components/Button/sgds-button.d.ts +1 -6
  13. package/components/Button/sgds-button.js +11 -27
  14. package/components/Button/sgds-button.js.map +1 -1
  15. package/components/Card/index.umd.js +3330 -3251
  16. package/components/Card/index.umd.js.map +1 -1
  17. package/components/Card/sgds-card.d.ts +1 -0
  18. package/components/Card/sgds-card.js +9 -3
  19. package/components/Card/sgds-card.js.map +1 -1
  20. package/components/Checkbox/index.umd.js +1 -1
  21. package/components/ComboBox/index.umd.js +2 -2
  22. package/components/Datepicker/index.umd.js +62 -29
  23. package/components/Datepicker/index.umd.js.map +1 -1
  24. package/components/DescriptionList/index.umd.js +1 -1
  25. package/components/Divider/index.umd.js +1 -1
  26. package/components/Drawer/index.umd.js +1 -1
  27. package/components/Dropdown/index.umd.js +2 -2
  28. package/components/FileUpload/index.umd.js +62 -29
  29. package/components/FileUpload/index.umd.js.map +1 -1
  30. package/components/Footer/footer-item.js +1 -1
  31. package/components/Footer/index.umd.js +89 -45
  32. package/components/Footer/index.umd.js.map +1 -1
  33. package/components/Footer/sgds-footer.d.ts +1 -1
  34. package/components/Footer/sgds-footer.js +39 -44
  35. package/components/Footer/sgds-footer.js.map +1 -1
  36. package/components/Icon/icon.js +1 -1
  37. package/components/Icon/index.umd.js +2 -2
  38. package/components/IconButton/index.umd.js +2 -2
  39. package/components/IconCard/index.umd.js +93 -14
  40. package/components/IconCard/index.umd.js.map +1 -1
  41. package/components/IconCard/sgds-icon-card.d.ts +1 -0
  42. package/components/IconCard/sgds-icon-card.js +8 -3
  43. package/components/IconCard/sgds-icon-card.js.map +1 -1
  44. package/components/IconList/index.umd.js +1 -1
  45. package/components/ImageCard/index.umd.js +93 -14
  46. package/components/ImageCard/index.umd.js.map +1 -1
  47. package/components/ImageCard/sgds-image-card.d.ts +1 -0
  48. package/components/ImageCard/sgds-image-card.js +8 -3
  49. package/components/ImageCard/sgds-image-card.js.map +1 -1
  50. package/components/Input/index.umd.js +2 -2
  51. package/components/Link/index.umd.js +35 -10
  52. package/components/Link/index.umd.js.map +1 -1
  53. package/components/Link/link.js +1 -1
  54. package/components/Link/sgds-link.d.ts +3 -0
  55. package/components/Link/sgds-link.js +33 -8
  56. package/components/Link/sgds-link.js.map +1 -1
  57. package/components/Mainnav/index.umd.js +2 -2
  58. package/components/Masthead/index.umd.js +2 -2
  59. package/components/Masthead/masthead.js +1 -1
  60. package/components/Modal/index.umd.js +1 -1
  61. package/components/OverflowMenu/index.umd.js +2 -2
  62. package/components/Pagination/index.umd.js +62 -29
  63. package/components/Pagination/index.umd.js.map +1 -1
  64. package/components/ProgressBar/index.umd.js +1 -1
  65. package/components/QuantityToggle/index.umd.js +2 -2
  66. package/components/Radio/index.umd.js +1 -1
  67. package/components/Select/index.umd.js +2 -2
  68. package/components/Sidenav/index.umd.js +2 -2
  69. package/components/Skeleton/index.umd.js +1 -1
  70. package/components/Spinner/index.umd.js +1 -1
  71. package/components/Stepper/index.umd.js +2 -2
  72. package/components/Subnav/index.umd.js +3 -3
  73. package/components/Subnav/subnav-item.js +1 -1
  74. package/components/Switch/index.umd.js +1 -1
  75. package/components/Tab/index.umd.js +1 -1
  76. package/components/Table/index.umd.js +1 -1
  77. package/components/TableOfContents/index.umd.js +1 -1
  78. package/components/Textarea/index.umd.js +1 -1
  79. package/components/ThumbnailCard/index.umd.js +93 -14
  80. package/components/ThumbnailCard/index.umd.js.map +1 -1
  81. package/components/ThumbnailCard/sgds-thumbnail-card.d.ts +1 -0
  82. package/components/ThumbnailCard/sgds-thumbnail-card.js +8 -3
  83. package/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
  84. package/components/Toast/index.umd.js +1 -1
  85. package/components/Tooltip/index.umd.js +1 -1
  86. package/components/index.umd.js +113 -95
  87. package/components/index.umd.js.map +1 -1
  88. package/index.umd.js +115 -97
  89. package/index.umd.js.map +1 -1
  90. package/package.json +1 -1
  91. package/react/base/card.cjs.js +1 -1
  92. package/react/base/card.js +1 -1
  93. package/react/base/sgds-element.cjs2.js +1 -1
  94. package/react/base/sgds-element2.js +1 -1
  95. package/react/components/Button/button.cjs.js +1 -1
  96. package/react/components/Button/button.js +1 -1
  97. package/react/components/Button/sgds-button.cjs.js +10 -26
  98. package/react/components/Button/sgds-button.cjs.js.map +1 -1
  99. package/react/components/Button/sgds-button.js +11 -27
  100. package/react/components/Button/sgds-button.js.map +1 -1
  101. package/react/components/Card/sgds-card.cjs.js +9 -3
  102. package/react/components/Card/sgds-card.cjs.js.map +1 -1
  103. package/react/components/Card/sgds-card.js +9 -3
  104. package/react/components/Card/sgds-card.js.map +1 -1
  105. package/react/components/Footer/footer-item.cjs.js +1 -1
  106. package/react/components/Footer/footer-item.js +1 -1
  107. package/react/components/Footer/sgds-footer.cjs.js +38 -43
  108. package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
  109. package/react/components/Footer/sgds-footer.js +39 -44
  110. package/react/components/Footer/sgds-footer.js.map +1 -1
  111. package/react/components/Icon/icon.cjs.js +1 -1
  112. package/react/components/Icon/icon.js +1 -1
  113. package/react/components/IconCard/sgds-icon-card.cjs.js +8 -3
  114. package/react/components/IconCard/sgds-icon-card.cjs.js.map +1 -1
  115. package/react/components/IconCard/sgds-icon-card.js +8 -3
  116. package/react/components/IconCard/sgds-icon-card.js.map +1 -1
  117. package/react/components/ImageCard/sgds-image-card.cjs.js +8 -3
  118. package/react/components/ImageCard/sgds-image-card.cjs.js.map +1 -1
  119. package/react/components/ImageCard/sgds-image-card.js +8 -3
  120. package/react/components/ImageCard/sgds-image-card.js.map +1 -1
  121. package/react/components/Link/link.cjs.js +1 -1
  122. package/react/components/Link/link.js +1 -1
  123. package/react/components/Link/sgds-link.cjs.js +33 -8
  124. package/react/components/Link/sgds-link.cjs.js.map +1 -1
  125. package/react/components/Link/sgds-link.js +33 -8
  126. package/react/components/Link/sgds-link.js.map +1 -1
  127. package/react/components/Masthead/masthead.cjs.js +1 -1
  128. package/react/components/Masthead/masthead.js +1 -1
  129. package/react/components/Subnav/subnav-item.cjs.js +1 -1
  130. package/react/components/Subnav/subnav-item.js +1 -1
  131. package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js +8 -3
  132. package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js.map +1 -1
  133. package/react/components/ThumbnailCard/sgds-thumbnail-card.js +8 -3
  134. package/react/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
@@ -15,10 +15,6 @@ export type ButtonVariant = "primary" | "outline" | "ghost" | "danger";
15
15
  export declare class SgdsButton extends ButtonElement {
16
16
  static styles: import("lit").CSSResult[];
17
17
  /** @internal */
18
- private _hasLeftIcon;
19
- /** @internal */
20
- private _hasRightIcon;
21
- /** @internal */
22
18
  private readonly formSubmitController;
23
19
  /** 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 */
24
20
  type: "button" | "submit" | "reset";
@@ -37,10 +33,9 @@ export declare class SgdsButton extends ButtonElement {
37
33
  formTarget: "_self" | "_blank" | "_parent" | "_top" | string;
38
34
  /** When set, the button will be in full width. */
39
35
  fullWidth: boolean;
36
+ private readonly hasSlotController;
40
37
  protected _handleClick(event: MouseEvent): void;
41
38
  private _clickHandler;
42
- private _handleLeftIconSlotchange;
43
- private _handleRightIconSlotchange;
44
39
  render(): import("lit-html").TemplateResult;
45
40
  }
46
41
  export default SgdsButton;
@@ -1,10 +1,11 @@
1
1
  import { __decorate } from 'tslib';
2
- import { state, property } from 'lit/decorators.js';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  import { literal, html } from 'lit/static-html.js';
6
6
  import ButtonElement from '../../base/button-element.js';
7
7
  import css_248z from '../../styles/anchor.js';
8
+ import { HasSlotController } from '../../utils/slot.js';
8
9
  import { FormSubmitController } from '../../utils/formSubmitController.js';
9
10
  import css_248z$1 from './button.js';
10
11
 
@@ -24,10 +25,6 @@ class SgdsButton extends ButtonElement {
24
25
  constructor() {
25
26
  super(...arguments);
26
27
  /** @internal */
27
- this._hasLeftIcon = false;
28
- /** @internal */
29
- this._hasRightIcon = false;
30
- /** @internal */
31
28
  this.formSubmitController = new FormSubmitController(this, {
32
29
  form: (input) => {
33
30
  // Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query
@@ -45,6 +42,7 @@ class SgdsButton extends ButtonElement {
45
42
  this.type = "button";
46
43
  /** When set, the button will be in full width. */
47
44
  this.fullWidth = false;
45
+ this.hasSlotController = new HasSlotController(this, "leftIcon", "rightIcon");
48
46
  this._clickHandler = () => {
49
47
  if (this.type === "submit") {
50
48
  this.formSubmitController.submit(this);
@@ -63,28 +61,20 @@ class SgdsButton extends ButtonElement {
63
61
  this.removeEventListener("click", this._clickHandler);
64
62
  this.addEventListener("click", this._clickHandler);
65
63
  }
66
- _handleLeftIconSlotchange(e) {
67
- const childNodes = e.target.assignedNodes({ flatten: true });
68
- if (childNodes.length > 0) {
69
- return (this._hasLeftIcon = true);
70
- }
71
- }
72
- _handleRightIconSlotchange(e) {
73
- const childNodes = e.target.assignedNodes({ flatten: true });
74
- if (childNodes.length > 0) {
75
- return (this._hasRightIcon = true);
76
- }
77
- }
78
64
  render() {
79
65
  const isLink = this.href;
80
66
  const tag = isLink ? literal `a` : literal `button`;
67
+ const hasLeftIconSlot = this.hasSlotController.test("leftIcon");
68
+ const hasRightIconSlot = this.hasSlotController.test("rightIcon");
69
+ const noIconSlot = !hasLeftIconSlot && !hasRightIconSlot;
81
70
  return html `
82
71
  <${tag}
83
72
  class="btn ${classMap({
84
73
  disabled: this.disabled,
85
74
  active: this.active,
86
- "has-left-icon": this._hasLeftIcon,
87
- "has-right-icon": this._hasRightIcon
75
+ "has-left-icon": hasLeftIconSlot,
76
+ "has-right-icon": hasRightIconSlot,
77
+ "no-icon": noIconSlot
88
78
  })}"
89
79
  ?disabled=${ifDefined(isLink ? undefined : this.disabled)}
90
80
  type=${ifDefined(isLink ? undefined : this.type)}
@@ -100,20 +90,14 @@ class SgdsButton extends ButtonElement {
100
90
  @blur=${this._handleBlur}
101
91
  aria-label=${ifDefined(this.ariaLabel)}
102
92
  >
103
- <slot name="leftIcon" @slotchange=${this._handleLeftIconSlotchange}></slot>
93
+ <slot name="leftIcon"></slot>
104
94
  <span><slot></slot></span>
105
- <slot name="rightIcon" @slotchange=${this._handleRightIconSlotchange}></slot>
95
+ <slot name="rightIcon"></slot>
106
96
  </${tag}>
107
97
  `;
108
98
  }
109
99
  }
110
100
  SgdsButton.styles = [...ButtonElement.styles, css_248z, css_248z$1];
111
- __decorate([
112
- state()
113
- ], SgdsButton.prototype, "_hasLeftIcon", void 0);
114
- __decorate([
115
- state()
116
- ], SgdsButton.prototype, "_hasRightIcon", void 0);
117
101
  __decorate([
118
102
  property({ type: String, reflect: true })
119
103
  ], SgdsButton.prototype, "type", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-button.js","sources":["../../../src/components/Button/sgds-button.ts"],"sourcesContent":["import { property, state } 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 anchorStyles from \"../../styles/anchor.css\";\nimport { FormSubmitController } from \"../../utils/formSubmitController\";\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 /** @internal */\n @state()\n private _hasLeftIcon = false;\n\n /** @internal */\n @state()\n private _hasRightIcon = false;\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 protected override _handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\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 private _handleLeftIconSlotchange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLOrSVGImageElement>;\n if (childNodes.length > 0) {\n return (this._hasLeftIcon = true);\n }\n }\n\n private _handleRightIconSlotchange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLOrSVGImageElement>;\n if (childNodes.length > 0) {\n return (this._hasRightIcon = true);\n }\n }\n\n render() {\n const isLink = this.href;\n const tag = isLink ? literal`a` : literal`button`;\n return html`\n <${tag}\n class=\"btn ${classMap({\n disabled: this.disabled,\n active: this.active,\n \"has-left-icon\": this._hasLeftIcon,\n \"has-right-icon\": this._hasRightIcon\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 ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this._handleClick}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-label=${ifDefined(this.ariaLabel)}\n >\n <slot name=\"leftIcon\" @slotchange=${this._handleLeftIconSlotchange}></slot>\n <span><slot></slot></span>\n <slot name=\"rightIcon\" @slotchange=${this._handleRightIconSlotchange}></slot>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsButton;\n"],"names":["anchorStyles","buttonStyles"],"mappings":";;;;;;;;;;AAWA;;;;;;;;;;;AAWG;AACG,MAAO,UAAW,SAAQ,aAAa,CAAA;AAA7C,IAAA,WAAA,GAAA;;;QAIU,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;;QAIrB,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;;AAGb,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;QAatD,IAAa,CAAA,aAAA,GAAG,MAAK;AAC3B,YAAA,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;AAC1B,gBAAA,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aACxC;AACD,YAAA,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;AACzB,gBAAA,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACvC;AACH,SAAC,CAAC;KA+CH;AAjEoB,IAAA,YAAY,CAAC,KAA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,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;;;;"}
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 anchorStyles from \"../../styles/anchor.css\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { FormSubmitController } from \"../../utils/formSubmitController\";\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 private readonly hasSlotController = new HasSlotController(this, \"leftIcon\", \"rightIcon\");\n\n protected override _handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\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 hasLeftIconSlot = this.hasSlotController.test(\"leftIcon\");\n const hasRightIconSlot = this.hasSlotController.test(\"rightIcon\");\n const noIconSlot = !hasLeftIconSlot && !hasRightIconSlot;\n\n return html`\n <${tag}\n class=\"btn ${classMap({\n disabled: this.disabled,\n active: this.active,\n \"has-left-icon\": hasLeftIconSlot,\n \"has-right-icon\": hasRightIconSlot,\n \"no-icon\": noIconSlot\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 ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this._handleClick}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-label=${ifDefined(this.ariaLabel)}\n >\n <slot name=\"leftIcon\"></slot>\n <span><slot></slot></span>\n <slot name=\"rightIcon\"></slot>\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;QAE7C,IAAiB,CAAA,i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