@govtechsg/sgds-web-component 3.6.0-rc.2 → 3.6.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 (233) hide show
  1. package/base/button.js +1 -1
  2. package/components/Alert/index.umd.min.js +17 -17
  3. package/components/Alert/index.umd.min.js.map +1 -1
  4. package/components/Alert/sgds-alert.d.ts +1 -1
  5. package/components/Alert/sgds-alert.js +2 -2
  6. package/components/Alert/sgds-alert.js.map +1 -1
  7. package/components/Badge/index.umd.min.js +16 -16
  8. package/components/Badge/index.umd.min.js.map +1 -1
  9. package/components/Badge/sgds-badge.d.ts +1 -1
  10. package/components/Badge/sgds-badge.js +2 -2
  11. package/components/Badge/sgds-badge.js.map +1 -1
  12. package/components/Breadcrumb/index.umd.min.js +17 -17
  13. package/components/Breadcrumb/index.umd.min.js.map +1 -1
  14. package/components/Breadcrumb/sgds-breadcrumb-item.d.ts +1 -0
  15. package/components/Breadcrumb/sgds-breadcrumb-item.js +5 -2
  16. package/components/Breadcrumb/sgds-breadcrumb-item.js.map +1 -1
  17. package/components/Button/index.umd.min.js +1 -1
  18. package/components/Card/index.umd.min.js.map +1 -1
  19. package/components/Card/sgds-card.js.map +1 -1
  20. package/components/CloseButton/close-button.js +6 -0
  21. package/components/CloseButton/index.js +5 -0
  22. package/components/CloseButton/index.js.map +1 -0
  23. package/components/CloseButton/index.umd.min.js +50 -0
  24. package/components/CloseButton/index.umd.min.js.map +1 -0
  25. package/{internals → components}/CloseButton/sgds-close-button.d.ts +2 -4
  26. package/{internals → components}/CloseButton/sgds-close-button.js +4 -10
  27. package/components/CloseButton/sgds-close-button.js.map +1 -0
  28. package/components/ComboBox/index.umd.min.js +18 -18
  29. package/components/ComboBox/index.umd.min.js.map +1 -1
  30. package/components/Datepicker/index.umd.min.js +1 -1
  31. package/components/Datepicker/index.umd.min.js.map +1 -1
  32. package/components/Drawer/index.umd.min.js +6 -11
  33. package/components/Drawer/index.umd.min.js.map +1 -1
  34. package/components/Drawer/sgds-drawer.d.ts +1 -1
  35. package/components/Drawer/sgds-drawer.js +1 -1
  36. package/components/Drawer/sgds-drawer.js.map +1 -1
  37. package/components/FileUpload/index.umd.min.js +26 -26
  38. package/components/FileUpload/index.umd.min.js.map +1 -1
  39. package/components/FileUpload/sgds-file-upload.d.ts +1 -1
  40. package/components/FileUpload/sgds-file-upload.js +1 -1
  41. package/components/FileUpload/sgds-file-upload.js.map +1 -1
  42. package/components/Footer/footer-item.js +1 -1
  43. package/components/Footer/footer.js +1 -1
  44. package/components/Footer/index.umd.min.js +17 -17
  45. package/components/Footer/index.umd.min.js.map +1 -1
  46. package/components/Footer/sgds-footer-item.d.ts +1 -0
  47. package/components/Footer/sgds-footer-item.js +11 -1
  48. package/components/Footer/sgds-footer-item.js.map +1 -1
  49. package/components/Footer/sgds-footer.js +7 -7
  50. package/components/Footer/sgds-footer.js.map +1 -1
  51. package/components/IconButton/index.umd.min.js +1 -1
  52. package/components/IconCard/index.umd.min.js.map +1 -1
  53. package/components/IconCard/sgds-icon-card.js.map +1 -1
  54. package/components/ImageCard/index.umd.min.js.map +1 -1
  55. package/components/ImageCard/sgds-image-card.js.map +1 -1
  56. package/components/Input/index.umd.min.js.map +1 -1
  57. package/components/Input/sgds-input.js.map +1 -1
  58. package/components/Link/index.umd.min.js +9 -9
  59. package/components/Link/index.umd.min.js.map +1 -1
  60. package/components/Link/link.js +1 -1
  61. package/components/Link/sgds-link.d.ts +7 -1
  62. package/components/Link/sgds-link.js +28 -2
  63. package/components/Link/sgds-link.js.map +1 -1
  64. package/components/Mainnav/index.umd.min.js +1 -1
  65. package/components/Modal/index.umd.min.js +4 -4
  66. package/components/Modal/index.umd.min.js.map +1 -1
  67. package/components/Modal/sgds-modal.d.ts +1 -1
  68. package/components/Modal/sgds-modal.js +2 -2
  69. package/components/Modal/sgds-modal.js.map +1 -1
  70. package/components/Pagination/index.umd.min.js +1 -1
  71. package/components/QuantityToggle/index.umd.min.js +1 -1
  72. package/components/QuantityToggle/index.umd.min.js.map +1 -1
  73. package/components/Subnav/index.umd.min.js +11 -9
  74. package/components/Subnav/index.umd.min.js.map +1 -1
  75. package/components/Subnav/sgds-subnav.d.ts +4 -0
  76. package/components/Subnav/sgds-subnav.js +18 -2
  77. package/components/Subnav/sgds-subnav.js.map +1 -1
  78. package/components/Subnav/subnav.js +1 -1
  79. package/components/SystemBanner/index.d.ts +6 -0
  80. package/components/SystemBanner/index.js +6 -0
  81. package/components/SystemBanner/index.js.map +1 -0
  82. package/components/SystemBanner/index.umd.min.js +2101 -0
  83. package/components/SystemBanner/index.umd.min.js.map +1 -0
  84. package/components/SystemBanner/sgds-system-banner-item.d.ts +24 -0
  85. package/components/SystemBanner/sgds-system-banner-item.js +93 -0
  86. package/components/SystemBanner/sgds-system-banner-item.js.map +1 -0
  87. package/components/SystemBanner/sgds-system-banner.d.ts +51 -0
  88. package/components/SystemBanner/sgds-system-banner.js +224 -0
  89. package/components/SystemBanner/sgds-system-banner.js.map +1 -0
  90. package/components/SystemBanner/system-banner-context.d.ts +3 -0
  91. package/components/SystemBanner/system-banner-context.js +6 -0
  92. package/components/SystemBanner/system-banner-context.js.map +1 -0
  93. package/components/SystemBanner/system-banner-item.js +6 -0
  94. package/components/SystemBanner/system-banner-item.js.map +1 -0
  95. package/components/SystemBanner/system-banner.js +6 -0
  96. package/components/SystemBanner/system-banner.js.map +1 -0
  97. package/components/Toast/index.umd.min.js +12 -12
  98. package/components/Toast/index.umd.min.js.map +1 -1
  99. package/components/Toast/sgds-toast.d.ts +1 -1
  100. package/components/Toast/sgds-toast.js +2 -2
  101. package/components/Toast/sgds-toast.js.map +1 -1
  102. package/components/index.d.ts +2 -0
  103. package/components/index.js +2 -0
  104. package/components/index.js.map +1 -1
  105. package/components/index.umd.min.js +168 -136
  106. package/components/index.umd.min.js.map +1 -1
  107. package/css/fouc.css +3 -0
  108. package/index.d.ts +3 -1
  109. package/index.js +3 -1
  110. package/index.js.map +1 -1
  111. package/index.umd.min.js +212 -161
  112. package/index.umd.min.js.map +1 -1
  113. package/package.json +1 -1
  114. package/react/base/button.cjs.js +1 -1
  115. package/react/base/button.js +1 -1
  116. package/react/close-button/index.cjs.js +40 -0
  117. package/react/close-button/index.cjs.js.map +1 -0
  118. package/react/close-button/index.d.ts +2 -0
  119. package/react/close-button/index.js +16 -0
  120. package/react/close-button/index.js.map +1 -0
  121. package/react/components/Alert/sgds-alert.cjs.js +2 -2
  122. package/react/components/Alert/sgds-alert.cjs.js.map +1 -1
  123. package/react/components/Alert/sgds-alert.js +2 -2
  124. package/react/components/Alert/sgds-alert.js.map +1 -1
  125. package/react/components/Badge/sgds-badge.cjs.js +2 -2
  126. package/react/components/Badge/sgds-badge.cjs.js.map +1 -1
  127. package/react/components/Badge/sgds-badge.js +2 -2
  128. package/react/components/Badge/sgds-badge.js.map +1 -1
  129. package/react/components/Breadcrumb/sgds-breadcrumb-item.cjs.js +5 -2
  130. package/react/components/Breadcrumb/sgds-breadcrumb-item.cjs.js.map +1 -1
  131. package/react/components/Breadcrumb/sgds-breadcrumb-item.js +5 -2
  132. package/react/components/Breadcrumb/sgds-breadcrumb-item.js.map +1 -1
  133. package/react/components/Card/sgds-card.cjs.js.map +1 -1
  134. package/react/components/Card/sgds-card.js.map +1 -1
  135. package/react/components/CloseButton/close-button.cjs.js +11 -0
  136. package/react/components/CloseButton/close-button.js +7 -0
  137. package/react/{internals → components}/CloseButton/sgds-close-button.cjs.js +4 -10
  138. package/react/components/CloseButton/sgds-close-button.cjs.js.map +1 -0
  139. package/react/{internals → components}/CloseButton/sgds-close-button.js +4 -10
  140. package/react/components/CloseButton/sgds-close-button.js.map +1 -0
  141. package/react/components/Drawer/sgds-drawer.cjs.js +1 -1
  142. package/react/components/Drawer/sgds-drawer.cjs.js.map +1 -1
  143. package/react/components/Drawer/sgds-drawer.js +1 -1
  144. package/react/components/Drawer/sgds-drawer.js.map +1 -1
  145. package/react/components/FileUpload/sgds-file-upload.cjs.js +1 -1
  146. package/react/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
  147. package/react/components/FileUpload/sgds-file-upload.js +1 -1
  148. package/react/components/FileUpload/sgds-file-upload.js.map +1 -1
  149. package/react/components/Footer/footer-item.cjs.js +1 -1
  150. package/react/components/Footer/footer-item.js +1 -1
  151. package/react/components/Footer/footer.cjs.js +1 -1
  152. package/react/components/Footer/footer.js +1 -1
  153. package/react/components/Footer/sgds-footer-item.cjs.js +11 -1
  154. package/react/components/Footer/sgds-footer-item.cjs.js.map +1 -1
  155. package/react/components/Footer/sgds-footer-item.js +11 -1
  156. package/react/components/Footer/sgds-footer-item.js.map +1 -1
  157. package/react/components/Footer/sgds-footer.cjs.js +7 -7
  158. package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
  159. package/react/components/Footer/sgds-footer.js +7 -7
  160. package/react/components/Footer/sgds-footer.js.map +1 -1
  161. package/react/components/IconCard/sgds-icon-card.cjs.js.map +1 -1
  162. package/react/components/IconCard/sgds-icon-card.js.map +1 -1
  163. package/react/components/ImageCard/sgds-image-card.cjs.js.map +1 -1
  164. package/react/components/ImageCard/sgds-image-card.js.map +1 -1
  165. package/react/components/Input/sgds-input.cjs.js.map +1 -1
  166. package/react/components/Input/sgds-input.js.map +1 -1
  167. package/react/components/Link/link.cjs.js +1 -1
  168. package/react/components/Link/link.js +1 -1
  169. package/react/components/Link/sgds-link.cjs.js +28 -2
  170. package/react/components/Link/sgds-link.cjs.js.map +1 -1
  171. package/react/components/Link/sgds-link.js +28 -2
  172. package/react/components/Link/sgds-link.js.map +1 -1
  173. package/react/components/Modal/sgds-modal.cjs.js +2 -2
  174. package/react/components/Modal/sgds-modal.cjs.js.map +1 -1
  175. package/react/components/Modal/sgds-modal.js +2 -2
  176. package/react/components/Modal/sgds-modal.js.map +1 -1
  177. package/react/components/Subnav/sgds-subnav.cjs.js +17 -1
  178. package/react/components/Subnav/sgds-subnav.cjs.js.map +1 -1
  179. package/react/components/Subnav/sgds-subnav.js +18 -2
  180. package/react/components/Subnav/sgds-subnav.js.map +1 -1
  181. package/react/components/Subnav/subnav.cjs.js +1 -1
  182. package/react/components/Subnav/subnav.js +1 -1
  183. package/react/components/SystemBanner/sgds-system-banner-item.cjs.js +99 -0
  184. package/react/components/SystemBanner/sgds-system-banner-item.cjs.js.map +1 -0
  185. package/react/components/SystemBanner/sgds-system-banner-item.js +94 -0
  186. package/react/components/SystemBanner/sgds-system-banner-item.js.map +1 -0
  187. package/react/components/SystemBanner/sgds-system-banner.cjs.js +230 -0
  188. package/react/components/SystemBanner/sgds-system-banner.cjs.js.map +1 -0
  189. package/react/components/SystemBanner/sgds-system-banner.js +225 -0
  190. package/react/components/SystemBanner/sgds-system-banner.js.map +1 -0
  191. package/react/components/SystemBanner/system-banner-context.cjs.js +11 -0
  192. package/react/components/SystemBanner/system-banner-context.cjs.js.map +1 -0
  193. package/react/components/SystemBanner/system-banner-context.js +7 -0
  194. package/react/components/SystemBanner/system-banner-context.js.map +1 -0
  195. package/react/components/SystemBanner/system-banner-item.cjs.js +11 -0
  196. package/react/components/SystemBanner/system-banner-item.cjs.js.map +1 -0
  197. package/react/components/SystemBanner/system-banner-item.js +7 -0
  198. package/react/components/SystemBanner/system-banner-item.js.map +1 -0
  199. package/react/components/SystemBanner/system-banner.cjs.js +11 -0
  200. package/react/components/SystemBanner/system-banner.cjs.js.map +1 -0
  201. package/react/components/SystemBanner/system-banner.js +7 -0
  202. package/react/components/SystemBanner/system-banner.js.map +1 -0
  203. package/react/components/Toast/sgds-toast.cjs.js +2 -2
  204. package/react/components/Toast/sgds-toast.cjs.js.map +1 -1
  205. package/react/components/Toast/sgds-toast.js +2 -2
  206. package/react/components/Toast/sgds-toast.js.map +1 -1
  207. package/react/index.cjs.js +114 -108
  208. package/react/index.cjs.js.map +1 -1
  209. package/react/index.d.ts +3 -0
  210. package/react/index.js +3 -0
  211. package/react/index.js.map +1 -1
  212. package/react/system-banner/index.cjs.js +43 -0
  213. package/react/system-banner/index.cjs.js.map +1 -0
  214. package/react/system-banner/index.d.ts +2 -0
  215. package/react/system-banner/index.js +19 -0
  216. package/react/system-banner/index.js.map +1 -0
  217. package/react/system-banner-item/index.cjs.js +42 -0
  218. package/react/system-banner-item/index.cjs.js.map +1 -0
  219. package/react/system-banner-item/index.d.ts +2 -0
  220. package/react/system-banner-item/index.js +18 -0
  221. package/react/system-banner-item/index.js.map +1 -0
  222. package/themes/root.css +14 -2
  223. package/internals/CloseButton/close-button.js +0 -6
  224. package/internals/CloseButton/sgds-close-button.js.map +0 -1
  225. package/react/internals/CloseButton/close-button.cjs.js +0 -11
  226. package/react/internals/CloseButton/close-button.js +0 -7
  227. package/react/internals/CloseButton/sgds-close-button.cjs.js.map +0 -1
  228. package/react/internals/CloseButton/sgds-close-button.js.map +0 -1
  229. package/utils/test.d.ts +0 -28
  230. /package/{internals → components}/CloseButton/close-button.js.map +0 -0
  231. /package/{internals → components}/CloseButton/index.d.ts +0 -0
  232. /package/react/{internals → components}/CloseButton/close-button.cjs.js.map +0 -0
  233. /package/react/{internals → components}/CloseButton/close-button.js.map +0 -0
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var tslib = require('tslib');
7
+ var lit = require('lit');
8
+ var decorators_js = require('lit/decorators.js');
9
+ var classMap_js = require('lit/directives/class-map.js');
10
+ var sgdsElement = require('../../base/sgds-element.cjs.js');
11
+ var systemBannerItem = require('./system-banner-item.cjs.js');
12
+ var slot = require('../../utils/slot.cjs.js');
13
+ var systemBannerContext = require('./system-banner-context.cjs.js');
14
+ var context = require('@lit/context');
15
+
16
+ /**
17
+ * @slot icon - The slot to pass in an icon element.
18
+ * @slot action - The slot to pass in an action element such as a button or link
19
+ * @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view
20
+ *
21
+ * @event sgds-show-more - The event emitted when user clicks on "show more" in the banner text message
22
+ */
23
+ class SgdsSystemBannerItem extends sgdsElement["default"] {
24
+ constructor() {
25
+ super(...arguments);
26
+ /** Used only for SSR to indicate the presence of the `action` slot. */
27
+ this.hasActionSlot = false;
28
+ this.clamped = false;
29
+ this.siblingsCount = 0;
30
+ this.hasSlotController = new slot.HasSlotController(this, "action");
31
+ }
32
+ async firstUpdated(_changedProperties) {
33
+ super.firstUpdated(_changedProperties);
34
+ await this.updateComplete;
35
+ this._clampCheck();
36
+ // Watch resizing for dynamic layout changes
37
+ this._resizeObserver = new ResizeObserver(() => this._clampCheck());
38
+ this._resizeObserver.observe(this.shadowRoot.querySelector(".message"));
39
+ }
40
+ disconnectedCallback() {
41
+ super.disconnectedCallback();
42
+ if (this._resizeObserver)
43
+ this._resizeObserver.disconnect();
44
+ }
45
+ updated() {
46
+ if (!this.hasActionSlot)
47
+ this.hasActionSlot = this.hasSlotController.test("action");
48
+ }
49
+ _clampCheck() {
50
+ const textEl = this.shadowRoot.querySelector(".message");
51
+ requestAnimationFrame(() => {
52
+ this.clamped = textEl.scrollHeight > textEl.clientHeight;
53
+ });
54
+ }
55
+ _handleShowMoreClick() {
56
+ this.emit("sgds-show-more");
57
+ }
58
+ render() {
59
+ return lit.html `
60
+ <div class="banner-item">
61
+ <slot name="icon"></slot>
62
+ <div class="banner-item__message_and__action">
63
+ <div class="clamped-container">
64
+ <div class=${classMap_js.classMap({ message: true, truncated: this.clamped })}>
65
+ <slot></slot>
66
+ </div>
67
+ ${this.clamped
68
+ ? lit.html `<span class="show-more"
69
+ >...<a class="show-more__link" @click="${this._handleShowMoreClick}">show more</a></span
70
+ >`
71
+ : lit.nothing}
72
+ </div>
73
+ ${this.hasActionSlot || this.siblingsCount > 1
74
+ ? lit.html `
75
+ <div class="action">
76
+ <slot name="action"></slot>
77
+ </div>
78
+ `
79
+ : lit.nothing}
80
+ </div>
81
+ </div>
82
+ `;
83
+ }
84
+ }
85
+ SgdsSystemBannerItem.styles = [...sgdsElement["default"].styles, systemBannerItem["default"]];
86
+ tslib.__decorate([
87
+ decorators_js.property({ type: Boolean })
88
+ ], SgdsSystemBannerItem.prototype, "hasActionSlot", void 0);
89
+ tslib.__decorate([
90
+ decorators_js.state()
91
+ ], SgdsSystemBannerItem.prototype, "clamped", void 0);
92
+ tslib.__decorate([
93
+ context.consume({ context: systemBannerContext.SystemBannerChildCountContext, subscribe: true }),
94
+ decorators_js.state()
95
+ ], SgdsSystemBannerItem.prototype, "siblingsCount", void 0);
96
+
97
+ exports.SgdsSystemBannerItem = SgdsSystemBannerItem;
98
+ exports["default"] = SgdsSystemBannerItem;
99
+ //# sourceMappingURL=sgds-system-banner-item.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sgds-system-banner-item.cjs.js","sources":["../../../../src/components/SystemBanner/sgds-system-banner-item.ts"],"sourcesContent":["import { html, nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport alertBannerItemStyles from \"./system-banner-item.css\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { SystemBannerChildCountContext } from \"./system-banner-context\";\nimport { consume } from \"@lit/context\";\n\n/**\n * @slot icon - The slot to pass in an icon element.\n * @slot action - The slot to pass in an action element such as a button or link\n * @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view\n *\n * @event sgds-show-more - The event emitted when user clicks on \"show more\" in the banner text message\n */\nexport class SgdsSystemBannerItem extends SgdsElement {\n static styles = [...SgdsElement.styles, alertBannerItemStyles];\n /** Used only for SSR to indicate the presence of the `action` slot. */\n @property({ type: Boolean }) hasActionSlot = false;\n\n @state() private clamped = false;\n\n @consume({ context: SystemBannerChildCountContext, subscribe: true })\n @state()\n private siblingsCount = 0;\n\n private readonly hasSlotController = new HasSlotController(this, \"action\");\n\n private _resizeObserver: ResizeObserver;\n async firstUpdated(_changedProperties) {\n super.firstUpdated(_changedProperties);\n await this.updateComplete;\n this._clampCheck();\n\n // Watch resizing for dynamic layout changes\n this._resizeObserver = new ResizeObserver(() => this._clampCheck());\n this._resizeObserver.observe(this.shadowRoot.querySelector(\".message\"));\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this._resizeObserver) this._resizeObserver.disconnect();\n }\n updated() {\n if (!this.hasActionSlot) this.hasActionSlot = this.hasSlotController.test(\"action\");\n }\n private _clampCheck() {\n const textEl = this.shadowRoot.querySelector(\".message\");\n requestAnimationFrame(() => {\n this.clamped = textEl.scrollHeight > textEl.clientHeight;\n });\n }\n\n private _handleShowMoreClick() {\n this.emit(\"sgds-show-more\");\n }\n render() {\n return html`\n <div class=\"banner-item\">\n <slot name=\"icon\"></slot>\n <div class=\"banner-item__message_and__action\">\n <div class=\"clamped-container\">\n <div class=${classMap({ message: true, truncated: this.clamped })}>\n <slot></slot>\n </div>\n ${this.clamped\n ? html`<span class=\"show-more\"\n >...<a class=\"show-more__link\" @click=\"${this._handleShowMoreClick}\">show more</a></span\n >`\n : nothing}\n </div>\n ${this.hasActionSlot || this.siblingsCount > 1\n ? html`\n <div class=\"action\">\n <slot name=\"action\"></slot>\n </div>\n `\n : nothing}\n </div>\n </div>\n `;\n }\n}\nexport default SgdsSystemBannerItem;\n"],"names":["SgdsElement","HasSlotController","html","classMap","nothing","alertBannerItemStyles","__decorate","property","state","consume","SystemBannerChildCountContext"],"mappings":";;;;;;;;;;;;;;;AASA;;;;;;AAMG;AACG,MAAO,oBAAqB,SAAQA,sBAAW,CAAA;AAArD,IAAA,WAAA,GAAA;;;QAG+B,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;QAElC,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;QAIzB,IAAa,CAAA,aAAA,GAAG,CAAC,CAAC;QAET,IAAiB,CAAA,iBAAA,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KAwD5E;IArDC,MAAM,YAAY,CAAC,kBAAkB,EAAA;AACnC,QAAA,KAAK,CAAC,YAAY,CA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AEE,WAAO,CAAA;;AAEX,UAAA,EAAA,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,GAAG,CAAC;cAC1CF,QAAI,CAAA,CAAA;;;;AAIH,cAAA,CAAA;AACH,cAAEE,WAAO,CAAA;;;KAGhB,CAAC;KACH;;AAjEM,oBAAM,CAAA,MAAA,GAAG,CAAC,GAAGJ,sBAAW,CAAC,MAAM,EAAEK,2BAAqB,CAAhD,CAAkD;AAElCC,gBAAA,CAAA;AAA5B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAuB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAElCD,gBAAA,CAAA;AAAhB,IAAAE,mBAAK,EAAE;AAAyB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIzBF,gBAAA,CAAA;IAFPG,eAAO,CAAC,EAAE,OAAO,EAAEC,iDAA6B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpE,IAAAF,mBAAK,EAAE;AACkB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
@@ -0,0 +1,94 @@
1
+ 'use client';
2
+ import { __decorate } from 'tslib';
3
+ import { html, nothing } from 'lit';
4
+ import { property, state } from 'lit/decorators.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
6
+ import SgdsElement from '../../base/sgds-element.js';
7
+ import css_248z from './system-banner-item.js';
8
+ import { HasSlotController } from '../../utils/slot.js';
9
+ import { SystemBannerChildCountContext } from './system-banner-context.js';
10
+ import { consume } from '@lit/context';
11
+
12
+ /**
13
+ * @slot icon - The slot to pass in an icon element.
14
+ * @slot action - The slot to pass in an action element such as a button or link
15
+ * @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view
16
+ *
17
+ * @event sgds-show-more - The event emitted when user clicks on "show more" in the banner text message
18
+ */
19
+ class SgdsSystemBannerItem extends SgdsElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ /** Used only for SSR to indicate the presence of the `action` slot. */
23
+ this.hasActionSlot = false;
24
+ this.clamped = false;
25
+ this.siblingsCount = 0;
26
+ this.hasSlotController = new HasSlotController(this, "action");
27
+ }
28
+ async firstUpdated(_changedProperties) {
29
+ super.firstUpdated(_changedProperties);
30
+ await this.updateComplete;
31
+ this._clampCheck();
32
+ // Watch resizing for dynamic layout changes
33
+ this._resizeObserver = new ResizeObserver(() => this._clampCheck());
34
+ this._resizeObserver.observe(this.shadowRoot.querySelector(".message"));
35
+ }
36
+ disconnectedCallback() {
37
+ super.disconnectedCallback();
38
+ if (this._resizeObserver)
39
+ this._resizeObserver.disconnect();
40
+ }
41
+ updated() {
42
+ if (!this.hasActionSlot)
43
+ this.hasActionSlot = this.hasSlotController.test("action");
44
+ }
45
+ _clampCheck() {
46
+ const textEl = this.shadowRoot.querySelector(".message");
47
+ requestAnimationFrame(() => {
48
+ this.clamped = textEl.scrollHeight > textEl.clientHeight;
49
+ });
50
+ }
51
+ _handleShowMoreClick() {
52
+ this.emit("sgds-show-more");
53
+ }
54
+ render() {
55
+ return html `
56
+ <div class="banner-item">
57
+ <slot name="icon"></slot>
58
+ <div class="banner-item__message_and__action">
59
+ <div class="clamped-container">
60
+ <div class=${classMap({ message: true, truncated: this.clamped })}>
61
+ <slot></slot>
62
+ </div>
63
+ ${this.clamped
64
+ ? html `<span class="show-more"
65
+ >...<a class="show-more__link" @click="${this._handleShowMoreClick}">show more</a></span
66
+ >`
67
+ : nothing}
68
+ </div>
69
+ ${this.hasActionSlot || this.siblingsCount > 1
70
+ ? html `
71
+ <div class="action">
72
+ <slot name="action"></slot>
73
+ </div>
74
+ `
75
+ : nothing}
76
+ </div>
77
+ </div>
78
+ `;
79
+ }
80
+ }
81
+ SgdsSystemBannerItem.styles = [...SgdsElement.styles, css_248z];
82
+ __decorate([
83
+ property({ type: Boolean })
84
+ ], SgdsSystemBannerItem.prototype, "hasActionSlot", void 0);
85
+ __decorate([
86
+ state()
87
+ ], SgdsSystemBannerItem.prototype, "clamped", void 0);
88
+ __decorate([
89
+ consume({ context: SystemBannerChildCountContext, subscribe: true }),
90
+ state()
91
+ ], SgdsSystemBannerItem.prototype, "siblingsCount", void 0);
92
+
93
+ export { SgdsSystemBannerItem, SgdsSystemBannerItem as default };
94
+ //# sourceMappingURL=sgds-system-banner-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sgds-system-banner-item.js","sources":["../../../../src/components/SystemBanner/sgds-system-banner-item.ts"],"sourcesContent":["import { html, nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport alertBannerItemStyles from \"./system-banner-item.css\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { SystemBannerChildCountContext } from \"./system-banner-context\";\nimport { consume } from \"@lit/context\";\n\n/**\n * @slot icon - The slot to pass in an icon element.\n * @slot action - The slot to pass in an action element such as a button or link\n * @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view\n *\n * @event sgds-show-more - The event emitted when user clicks on \"show more\" in the banner text message\n */\nexport class SgdsSystemBannerItem extends SgdsElement {\n static styles = [...SgdsElement.styles, alertBannerItemStyles];\n /** Used only for SSR to indicate the presence of the `action` slot. */\n @property({ type: Boolean }) hasActionSlot = false;\n\n @state() private clamped = false;\n\n @consume({ context: SystemBannerChildCountContext, subscribe: true })\n @state()\n private siblingsCount = 0;\n\n private readonly hasSlotController = new HasSlotController(this, \"action\");\n\n private _resizeObserver: ResizeObserver;\n async firstUpdated(_changedProperties) {\n super.firstUpdated(_changedProperties);\n await this.updateComplete;\n this._clampCheck();\n\n // Watch resizing for dynamic layout changes\n this._resizeObserver = new ResizeObserver(() => this._clampCheck());\n this._resizeObserver.observe(this.shadowRoot.querySelector(\".message\"));\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this._resizeObserver) this._resizeObserver.disconnect();\n }\n updated() {\n if (!this.hasActionSlot) this.hasActionSlot = this.hasSlotController.test(\"action\");\n }\n private _clampCheck() {\n const textEl = this.shadowRoot.querySelector(\".message\");\n requestAnimationFrame(() => {\n this.clamped = textEl.scrollHeight > textEl.clientHeight;\n });\n }\n\n private _handleShowMoreClick() {\n this.emit(\"sgds-show-more\");\n }\n render() {\n return html`\n <div class=\"banner-item\">\n <slot name=\"icon\"></slot>\n <div class=\"banner-item__message_and__action\">\n <div class=\"clamped-container\">\n <div class=${classMap({ message: true, truncated: this.clamped })}>\n <slot></slot>\n </div>\n ${this.clamped\n ? html`<span class=\"show-more\"\n >...<a class=\"show-more__link\" @click=\"${this._handleShowMoreClick}\">show more</a></span\n >`\n : nothing}\n </div>\n ${this.hasActionSlot || this.siblingsCount > 1\n ? html`\n <div class=\"action\">\n <slot name=\"action\"></slot>\n </div>\n `\n : nothing}\n </div>\n </div>\n `;\n }\n}\nexport default SgdsSystemBannerItem;\n"],"names":["alertBannerItemStyles"],"mappings":";;;;;;;;;;;AASA;;;;;;AAMG;AACG,MAAO,oBAAqB,SAAQ,WAAW,CAAA;AAArD,IAAA,WAAA,GAAA;;;QAG+B,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;QAElC,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;QAIzB,IAAa,CAAA,aAAA,GAAG,CAAC,CAAC;QAET,IAAiB,CAAA,iBAAA,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KAwD5E;IArDC,MAAM,YAAY,CAAC,kBAAkB,EAAA;AACnC,QAAA,KAAK,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;;AAGnB,QAAA,IAAI,CAAC,eAAe,GAAG,I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AAE,OAAO,CAAA;;;KAGhB,CAAC;KACH;;AAjEM,oBAAM,CAAA,MAAA,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,EAAEA,QAAqB,CAAhD,CAAkD;AAElC,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAuB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAElC,UAAA,CAAA;AAAhB,IAAA,KAAK,EAAE;AAAyB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIzB,UAAA,CAAA;IAFP,OAAO,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpE,IAAA,KAAK,EAAE;AACkB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
@@ -0,0 +1,230 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var tslib = require('tslib');
7
+ var lit = require('lit');
8
+ var decorators_js = require('lit/decorators.js');
9
+ var classMap_js = require('lit/directives/class-map.js');
10
+ var sgdsElement = require('../../base/sgds-element.cjs.js');
11
+ var sgdsCloseButton = require('../CloseButton/sgds-close-button.cjs.js');
12
+ var animate = require('../../utils/animate.cjs.js');
13
+ var animationRegistry = require('../../utils/animation-registry.cjs.js');
14
+ var watch = require('../../utils/watch.cjs.js');
15
+ var sgdsIcon = require('../Icon/sgds-icon.cjs.js');
16
+ var sgdsIconButton = require('../IconButton/sgds-icon-button.cjs.js');
17
+ var systemBanner = require('./system-banner.cjs.js');
18
+ var systemBannerContext = require('./system-banner-context.cjs.js');
19
+ var context = require('@lit/context');
20
+
21
+ /**
22
+ * @summary The system banner component for displaying important messages to users at the application level.
23
+ * Each banner can contain up to 5 banner items that cycle automatically every 5 seconds. Pagination appears when there are multiple items, allowing users to navigate between them. The banner can also be made dismissible with a close button.
24
+ * `sgds-system-banner-item` is the subcomponent for `sgds-system-banner`. Each banner item represents a message in the system banner.
25
+ *
26
+ * @slot default - The slot to pass in `sgds-system-banner-item`
27
+ *
28
+ * @event sgds-show - Emitted when the banner has start to appear on screen
29
+ * @event sgds-hide - Emitted when the banner is disappearing from the screen
30
+ */
31
+ class SgdsSystemBanner extends sgdsElement["default"] {
32
+ constructor() {
33
+ super(...arguments);
34
+ /** Controls the appearance of the alert */
35
+ this.show = false;
36
+ /** Enables a close button that allows the user to dismiss the alert. */
37
+ this.dismissible = false;
38
+ this._intervalId = null;
39
+ this._intervalTime = 5000;
40
+ this._currentIndex = 0;
41
+ }
42
+ /** Closes the alert */
43
+ close() {
44
+ this.show = false;
45
+ }
46
+ firstUpdated(changedProperties) {
47
+ super.firstUpdated(changedProperties);
48
+ this.childCount = this.bannerItem.length;
49
+ if (!this.show) {
50
+ this.banner.classList.add("d-none");
51
+ }
52
+ else {
53
+ this.childCount > 1 && this._startAutoCycle();
54
+ this.addEventListener("mouseenter", this._pauseAutoCycle.bind(this));
55
+ this.addEventListener("mouseleave", this._resumeAutoCycle.bind(this));
56
+ this.addEventListener("focus", this._pauseAutoCycle.bind(this));
57
+ this.addEventListener("blur", this._resumeAutoCycle.bind(this));
58
+ }
59
+ this._updateActiveItem();
60
+ if (this.childCount > 5) {
61
+ console.warn("It is not recommended to have more than 5 <sgds-system-banner-item> elements.");
62
+ }
63
+ }
64
+ disconnectedCallback() {
65
+ super.disconnectedCallback();
66
+ this._stopAutoCycle();
67
+ }
68
+ /**@internal */
69
+ async _handleShowChange() {
70
+ if (this.show) {
71
+ this.childCount > 1 && this._startAutoCycle();
72
+ this.emit("sgds-show");
73
+ this.banner.classList.remove("d-none");
74
+ }
75
+ else {
76
+ this._stopAutoCycle();
77
+ this.emit("sgds-hide");
78
+ this.banner.classList.add("d-none");
79
+ }
80
+ }
81
+ _updateActiveItem() {
82
+ const items = this.bannerItem;
83
+ items.forEach((item, i) => {
84
+ if (i === this._currentIndex) {
85
+ item.setAttribute("active", "");
86
+ }
87
+ else {
88
+ item.removeAttribute("active");
89
+ }
90
+ });
91
+ }
92
+ _next() {
93
+ const items = this.bannerItem;
94
+ this._currentIndex = (this._currentIndex + 1) % items.length;
95
+ this._updateActiveItem();
96
+ this._animateItem(items[this._currentIndex], "next");
97
+ this._resetAutoCycle();
98
+ }
99
+ _prev() {
100
+ const items = this.bannerItem;
101
+ this._currentIndex = (this._currentIndex - 1 + items.length) % items.length;
102
+ this._updateActiveItem();
103
+ this._animateItem(items[this._currentIndex], "prev");
104
+ this._resetAutoCycle();
105
+ }
106
+ async _animateItem(item, direction) {
107
+ // Cancel any existing animations before starting a new one
108
+ item.getAnimations().forEach(a => a.cancel());
109
+ // Start the slide-down animation
110
+ const bannerLoopMessage = animationRegistry.getAnimation(this, `banner.item.${direction}`);
111
+ await animate.animateTo(item, bannerLoopMessage.keyframes, bannerLoopMessage.options);
112
+ }
113
+ _startAutoCycle() {
114
+ this._stopAutoCycle(); // avoid duplicates
115
+ this._intervalId = setInterval(() => this._next(), this._intervalTime);
116
+ }
117
+ _stopAutoCycle() {
118
+ if (this._intervalId) {
119
+ clearInterval(this._intervalId);
120
+ this._intervalId = null;
121
+ }
122
+ }
123
+ _resetAutoCycle() {
124
+ this._stopAutoCycle();
125
+ this._startAutoCycle();
126
+ }
127
+ _pauseAutoCycle() {
128
+ this._stopAutoCycle();
129
+ }
130
+ _resumeAutoCycle() {
131
+ if (this.show && this.childCount > 1) {
132
+ this._startAutoCycle();
133
+ }
134
+ }
135
+ render() {
136
+ return lit.html `
137
+ <div
138
+ class="${classMap_js.classMap({
139
+ banner: true
140
+ })}"
141
+ role="alert"
142
+ aria-hidden=${this.show ? "false" : "true"}
143
+ >
144
+ <div class="content">
145
+ <slot id="loop-slot"></slot>
146
+ </div>
147
+ ${this.childCount > 1
148
+ ? lit.html ` <div class="pagination">
149
+ <sgds-icon-button
150
+ name="chevron-left"
151
+ tone="fixed-light"
152
+ variant="ghost"
153
+ size="xs"
154
+ @click=${this._prev}
155
+ ></sgds-icon-button>
156
+ <span>${this._currentIndex + 1}/${this.childCount}</span>
157
+ <sgds-icon-button
158
+ name="chevron-right"
159
+ tone="fixed-light"
160
+ variant="ghost"
161
+ size="xs"
162
+ @click=${this._next}
163
+ ></sgds-icon-button>
164
+ </div>`
165
+ : lit.nothing}
166
+ ${this.dismissible
167
+ ? lit.html `
168
+ <sgds-close-button aria-label="close the alert" @click=${this.close} tone="fixed-light"></sgds-close-button>
169
+ `
170
+ : lit.nothing}
171
+ </div>
172
+ `;
173
+ }
174
+ }
175
+ SgdsSystemBanner.styles = [...sgdsElement["default"].styles, systemBanner["default"]];
176
+ /**@internal */
177
+ SgdsSystemBanner.dependencies = {
178
+ "sgds-close-button": sgdsCloseButton.SgdsCloseButton,
179
+ "sgds-icon": sgdsIcon.SgdsIcon,
180
+ "sgds-icon-button": sgdsIconButton.SgdsIconButton
181
+ };
182
+ tslib.__decorate([
183
+ decorators_js.property({ type: Boolean, reflect: true })
184
+ ], SgdsSystemBanner.prototype, "show", void 0);
185
+ tslib.__decorate([
186
+ decorators_js.property({ type: Boolean, reflect: true })
187
+ ], SgdsSystemBanner.prototype, "dismissible", void 0);
188
+ tslib.__decorate([
189
+ decorators_js.queryAssignedElements({ flatten: true })
190
+ ], SgdsSystemBanner.prototype, "bannerItem", void 0);
191
+ tslib.__decorate([
192
+ decorators_js.query(".banner")
193
+ ], SgdsSystemBanner.prototype, "banner", void 0);
194
+ tslib.__decorate([
195
+ context.provide({ context: systemBannerContext.SystemBannerChildCountContext }),
196
+ decorators_js.state()
197
+ ], SgdsSystemBanner.prototype, "childCount", void 0);
198
+ tslib.__decorate([
199
+ decorators_js.state()
200
+ ], SgdsSystemBanner.prototype, "_intervalId", void 0);
201
+ tslib.__decorate([
202
+ decorators_js.state()
203
+ ], SgdsSystemBanner.prototype, "_currentIndex", void 0);
204
+ tslib.__decorate([
205
+ watch.watch("show", { waitUntilFirstUpdate: true })
206
+ ], SgdsSystemBanner.prototype, "_handleShowChange", null);
207
+ animationRegistry.setDefaultAnimation("banner.item.next", {
208
+ keyframes: [
209
+ { opacity: 0, transform: "translateY(-100%)" },
210
+ { opacity: 1, transform: "translateY(0)" }
211
+ ],
212
+ options: {
213
+ duration: 500,
214
+ easing: "cubic-bezier(0.45,0.05,0.55,0.95)"
215
+ }
216
+ });
217
+ animationRegistry.setDefaultAnimation("banner.item.prev", {
218
+ keyframes: [
219
+ { opacity: 0, transform: "translateY(100%)" },
220
+ { opacity: 1, transform: "translateY(0)" }
221
+ ],
222
+ options: {
223
+ duration: 500,
224
+ easing: "cubic-bezier(0.45,0.05,0.55,0.95)"
225
+ }
226
+ });
227
+
228
+ exports.SgdsSystemBanner = SgdsSystemBanner;
229
+ exports["default"] = SgdsSystemBanner;
230
+ //# sourceMappingURL=sgds-system-banner.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sgds-system-banner.cjs.js","sources":["../../../../src/components/SystemBanner/sgds-system-banner.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsCloseButton from \"../CloseButton/sgds-close-button\";\nimport { animateTo } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { watch } from \"../../utils/watch\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport SgdsIconButton from \"../IconButton/sgds-icon-button\";\nimport alertBannerStyles from \"./system-banner.css\";\nimport SgdsSystemBannerItem from \"./sgds-system-banner-item\";\nimport { SystemBannerChildCountContext } from \"./system-banner-context\";\nimport { provide } from \"@lit/context\";\n\n/**\n * @summary The system banner component for displaying important messages to users at the application level.\n * Each banner can contain up to 5 banner items that cycle automatically every 5 seconds. Pagination appears when there are multiple items, allowing users to navigate between them. The banner can also be made dismissible with a close button.\n * `sgds-system-banner-item` is the subcomponent for `sgds-system-banner`. Each banner item represents a message in the system banner.\n *\n * @slot default - The slot to pass in `sgds-system-banner-item`\n *\n * @event sgds-show - Emitted when the banner has start to appear on screen\n * @event sgds-hide - Emitted when the banner is disappearing from the screen\n */\nexport class SgdsSystemBanner extends SgdsElement {\n static styles = [...SgdsElement.styles, alertBannerStyles];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton,\n \"sgds-icon\": SgdsIcon,\n \"sgds-icon-button\": SgdsIconButton\n };\n /** Controls the appearance of the alert */\n @property({ type: Boolean, reflect: true }) show = false;\n\n /** Enables a close button that allows the user to dismiss the alert. */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** Closes the alert */\n public close() {\n this.show = false;\n }\n @queryAssignedElements({ flatten: true })\n private bannerItem: SgdsSystemBannerItem[];\n\n @query(\".banner\")\n private banner: HTMLDivElement;\n\n @provide({ context: SystemBannerChildCountContext })\n @state()\n private childCount: number;\n\n @state() private _intervalId = null;\n\n private _intervalTime = 5000;\n\n @state() private _currentIndex = 0;\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>): void {\n super.firstUpdated(changedProperties);\n this.childCount = this.bannerItem.length;\n if (!this.show) {\n this.banner.classList.add(\"d-none\");\n } else {\n this.childCount > 1 && this._startAutoCycle();\n this.addEventListener(\"mouseenter\", this._pauseAutoCycle.bind(this));\n this.addEventListener(\"mouseleave\", this._resumeAutoCycle.bind(this));\n\n this.addEventListener(\"focus\", this._pauseAutoCycle.bind(this));\n this.addEventListener(\"blur\", this._resumeAutoCycle.bind(this));\n }\n this._updateActiveItem();\n\n if (this.childCount > 5) {\n console.warn(\"It is not recommended to have more than 5 <sgds-system-banner-item> elements.\");\n }\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this._stopAutoCycle();\n }\n\n /**@internal */\n @watch(\"show\", { waitUntilFirstUpdate: true })\n async _handleShowChange() {\n if (this.show) {\n this.childCount > 1 && this._startAutoCycle();\n this.emit(\"sgds-show\");\n this.banner.classList.remove(\"d-none\");\n } else {\n this._stopAutoCycle();\n this.emit(\"sgds-hide\");\n this.banner.classList.add(\"d-none\");\n }\n }\n\n private _updateActiveItem() {\n const items = this.bannerItem;\n items.forEach((item, i) => {\n if (i === this._currentIndex) {\n item.setAttribute(\"active\", \"\");\n } else {\n item.removeAttribute(\"active\");\n }\n });\n }\n private _next() {\n const items = this.bannerItem;\n this._currentIndex = (this._currentIndex + 1) % items.length;\n this._updateActiveItem();\n this._animateItem(items[this._currentIndex], \"next\");\n this._resetAutoCycle();\n }\n\n private _prev() {\n const items = this.bannerItem;\n this._currentIndex = (this._currentIndex - 1 + items.length) % items.length;\n this._updateActiveItem();\n this._animateItem(items[this._currentIndex], \"prev\");\n this._resetAutoCycle();\n }\n private async _animateItem(item: SgdsSystemBannerItem, direction: \"next\" | \"prev\") {\n // Cancel any existing animations before starting a new one\n item.getAnimations().forEach(a => a.cancel());\n // Start the slide-down animation\n const bannerLoopMessage = getAnimation(this, `banner.item.${direction}`);\n await animateTo(item, bannerLoopMessage.keyframes, bannerLoopMessage.options);\n }\n private _startAutoCycle() {\n this._stopAutoCycle(); // avoid duplicates\n this._intervalId = setInterval(() => this._next(), this._intervalTime);\n }\n\n private _stopAutoCycle() {\n if (this._intervalId) {\n clearInterval(this._intervalId);\n this._intervalId = null;\n }\n }\n private _resetAutoCycle() {\n this._stopAutoCycle();\n this._startAutoCycle();\n }\n private _pauseAutoCycle(): void {\n this._stopAutoCycle();\n }\n\n private _resumeAutoCycle(): void {\n if (this.show && this.childCount > 1) {\n this._startAutoCycle();\n }\n }\n render() {\n return html`\n <div\n class=\"${classMap({\n banner: true\n })}\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n >\n <div class=\"content\">\n <slot id=\"loop-slot\"></slot>\n </div>\n ${this.childCount > 1\n ? html` <div class=\"pagination\">\n <sgds-icon-button\n name=\"chevron-left\"\n tone=\"fixed-light\"\n variant=\"ghost\"\n size=\"xs\"\n @click=${this._prev}\n ></sgds-icon-button>\n <span>${this._currentIndex + 1}/${this.childCount}</span>\n <sgds-icon-button\n name=\"chevron-right\"\n tone=\"fixed-light\"\n variant=\"ghost\"\n size=\"xs\"\n @click=${this._next}\n ></sgds-icon-button>\n </div>`\n : nothing}\n ${this.dismissible\n ? html`\n <sgds-close-button aria-label=\"close the alert\" @click=${this.close} tone=\"fixed-light\"></sgds-close-button>\n `\n : nothing}\n </div>\n `;\n }\n}\n\nexport default SgdsSystemBanner;\n\nsetDefaultAnimation(\"banner.item.next\", {\n keyframes: [\n { opacity: 0, transform: \"translateY(-100%)\" },\n { opacity: 1, transform: \"translateY(0)\" }\n ],\n options: {\n duration: 500,\n easing: \"cubic-bezier(0.45,0.05,0.55,0.95)\"\n }\n});\nsetDefaultAnimation(\"banner.item.prev\", {\n keyframes: [\n { opacity: 0, transform: \"translateY(100%)\" },\n { opacity: 1, transform: \"translateY(0)\" }\n ],\n options: {\n duration: 500,\n easing: \"cubic-bezier(0.45,0.05,0.55,0.95)\"\n }\n});\n"],"names":["SgdsElement","getAnimation","animateTo","html","classMap","nothing","alertBannerStyles","SgdsCloseButton","SgdsIcon","SgdsIconButton","__decorate","property","queryAssignedElements","query","provide","SystemBannerChildCountContext","state","watch","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;AASG;AACG,MAAO,gBAAiB,SAAQA,sBAAW,CAAA;AAAjD,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;QAgB/C,IAAW,CAAA,WAAA,GAAG,IAAI,CAAC;QAE5B,IAAa,CAAA,aAAA,GAAG,IAAI,CAAC;QAEZ,IAAa,CAAA,aAAA,GAAG,CAAC,CAAC;KAuIpC;;IAxJQ,KAAK,GAAA;AACV,QAAA,IAAI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