@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,225 @@
1
+ 'use client';
2
+ import { __decorate } from 'tslib';
3
+ import { html, nothing } from 'lit';
4
+ import { property, queryAssignedElements, query, state } from 'lit/decorators.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
6
+ import SgdsElement from '../../base/sgds-element.js';
7
+ import { SgdsCloseButton } from '../CloseButton/sgds-close-button.js';
8
+ import { animateTo } from '../../utils/animate.js';
9
+ import { setDefaultAnimation, getAnimation } from '../../utils/animation-registry.js';
10
+ import { watch } from '../../utils/watch.js';
11
+ import { SgdsIcon } from '../Icon/sgds-icon.js';
12
+ import { SgdsIconButton } from '../IconButton/sgds-icon-button.js';
13
+ import css_248z from './system-banner.js';
14
+ import { SystemBannerChildCountContext } from './system-banner-context.js';
15
+ import { provide } from '@lit/context';
16
+
17
+ /**
18
+ * @summary The system banner component for displaying important messages to users at the application level.
19
+ * 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.
20
+ * `sgds-system-banner-item` is the subcomponent for `sgds-system-banner`. Each banner item represents a message in the system banner.
21
+ *
22
+ * @slot default - The slot to pass in `sgds-system-banner-item`
23
+ *
24
+ * @event sgds-show - Emitted when the banner has start to appear on screen
25
+ * @event sgds-hide - Emitted when the banner is disappearing from the screen
26
+ */
27
+ class SgdsSystemBanner extends SgdsElement {
28
+ constructor() {
29
+ super(...arguments);
30
+ /** Controls the appearance of the alert */
31
+ this.show = false;
32
+ /** Enables a close button that allows the user to dismiss the alert. */
33
+ this.dismissible = false;
34
+ this._intervalId = null;
35
+ this._intervalTime = 5000;
36
+ this._currentIndex = 0;
37
+ }
38
+ /** Closes the alert */
39
+ close() {
40
+ this.show = false;
41
+ }
42
+ firstUpdated(changedProperties) {
43
+ super.firstUpdated(changedProperties);
44
+ this.childCount = this.bannerItem.length;
45
+ if (!this.show) {
46
+ this.banner.classList.add("d-none");
47
+ }
48
+ else {
49
+ this.childCount > 1 && this._startAutoCycle();
50
+ this.addEventListener("mouseenter", this._pauseAutoCycle.bind(this));
51
+ this.addEventListener("mouseleave", this._resumeAutoCycle.bind(this));
52
+ this.addEventListener("focus", this._pauseAutoCycle.bind(this));
53
+ this.addEventListener("blur", this._resumeAutoCycle.bind(this));
54
+ }
55
+ this._updateActiveItem();
56
+ if (this.childCount > 5) {
57
+ console.warn("It is not recommended to have more than 5 <sgds-system-banner-item> elements.");
58
+ }
59
+ }
60
+ disconnectedCallback() {
61
+ super.disconnectedCallback();
62
+ this._stopAutoCycle();
63
+ }
64
+ /**@internal */
65
+ async _handleShowChange() {
66
+ if (this.show) {
67
+ this.childCount > 1 && this._startAutoCycle();
68
+ this.emit("sgds-show");
69
+ this.banner.classList.remove("d-none");
70
+ }
71
+ else {
72
+ this._stopAutoCycle();
73
+ this.emit("sgds-hide");
74
+ this.banner.classList.add("d-none");
75
+ }
76
+ }
77
+ _updateActiveItem() {
78
+ const items = this.bannerItem;
79
+ items.forEach((item, i) => {
80
+ if (i === this._currentIndex) {
81
+ item.setAttribute("active", "");
82
+ }
83
+ else {
84
+ item.removeAttribute("active");
85
+ }
86
+ });
87
+ }
88
+ _next() {
89
+ const items = this.bannerItem;
90
+ this._currentIndex = (this._currentIndex + 1) % items.length;
91
+ this._updateActiveItem();
92
+ this._animateItem(items[this._currentIndex], "next");
93
+ this._resetAutoCycle();
94
+ }
95
+ _prev() {
96
+ const items = this.bannerItem;
97
+ this._currentIndex = (this._currentIndex - 1 + items.length) % items.length;
98
+ this._updateActiveItem();
99
+ this._animateItem(items[this._currentIndex], "prev");
100
+ this._resetAutoCycle();
101
+ }
102
+ async _animateItem(item, direction) {
103
+ // Cancel any existing animations before starting a new one
104
+ item.getAnimations().forEach(a => a.cancel());
105
+ // Start the slide-down animation
106
+ const bannerLoopMessage = getAnimation(this, `banner.item.${direction}`);
107
+ await animateTo(item, bannerLoopMessage.keyframes, bannerLoopMessage.options);
108
+ }
109
+ _startAutoCycle() {
110
+ this._stopAutoCycle(); // avoid duplicates
111
+ this._intervalId = setInterval(() => this._next(), this._intervalTime);
112
+ }
113
+ _stopAutoCycle() {
114
+ if (this._intervalId) {
115
+ clearInterval(this._intervalId);
116
+ this._intervalId = null;
117
+ }
118
+ }
119
+ _resetAutoCycle() {
120
+ this._stopAutoCycle();
121
+ this._startAutoCycle();
122
+ }
123
+ _pauseAutoCycle() {
124
+ this._stopAutoCycle();
125
+ }
126
+ _resumeAutoCycle() {
127
+ if (this.show && this.childCount > 1) {
128
+ this._startAutoCycle();
129
+ }
130
+ }
131
+ render() {
132
+ return html `
133
+ <div
134
+ class="${classMap({
135
+ banner: true
136
+ })}"
137
+ role="alert"
138
+ aria-hidden=${this.show ? "false" : "true"}
139
+ >
140
+ <div class="content">
141
+ <slot id="loop-slot"></slot>
142
+ </div>
143
+ ${this.childCount > 1
144
+ ? html ` <div class="pagination">
145
+ <sgds-icon-button
146
+ name="chevron-left"
147
+ tone="fixed-light"
148
+ variant="ghost"
149
+ size="xs"
150
+ @click=${this._prev}
151
+ ></sgds-icon-button>
152
+ <span>${this._currentIndex + 1}/${this.childCount}</span>
153
+ <sgds-icon-button
154
+ name="chevron-right"
155
+ tone="fixed-light"
156
+ variant="ghost"
157
+ size="xs"
158
+ @click=${this._next}
159
+ ></sgds-icon-button>
160
+ </div>`
161
+ : nothing}
162
+ ${this.dismissible
163
+ ? html `
164
+ <sgds-close-button aria-label="close the alert" @click=${this.close} tone="fixed-light"></sgds-close-button>
165
+ `
166
+ : nothing}
167
+ </div>
168
+ `;
169
+ }
170
+ }
171
+ SgdsSystemBanner.styles = [...SgdsElement.styles, css_248z];
172
+ /**@internal */
173
+ SgdsSystemBanner.dependencies = {
174
+ "sgds-close-button": SgdsCloseButton,
175
+ "sgds-icon": SgdsIcon,
176
+ "sgds-icon-button": SgdsIconButton
177
+ };
178
+ __decorate([
179
+ property({ type: Boolean, reflect: true })
180
+ ], SgdsSystemBanner.prototype, "show", void 0);
181
+ __decorate([
182
+ property({ type: Boolean, reflect: true })
183
+ ], SgdsSystemBanner.prototype, "dismissible", void 0);
184
+ __decorate([
185
+ queryAssignedElements({ flatten: true })
186
+ ], SgdsSystemBanner.prototype, "bannerItem", void 0);
187
+ __decorate([
188
+ query(".banner")
189
+ ], SgdsSystemBanner.prototype, "banner", void 0);
190
+ __decorate([
191
+ provide({ context: SystemBannerChildCountContext }),
192
+ state()
193
+ ], SgdsSystemBanner.prototype, "childCount", void 0);
194
+ __decorate([
195
+ state()
196
+ ], SgdsSystemBanner.prototype, "_intervalId", void 0);
197
+ __decorate([
198
+ state()
199
+ ], SgdsSystemBanner.prototype, "_currentIndex", void 0);
200
+ __decorate([
201
+ watch("show", { waitUntilFirstUpdate: true })
202
+ ], SgdsSystemBanner.prototype, "_handleShowChange", null);
203
+ setDefaultAnimation("banner.item.next", {
204
+ keyframes: [
205
+ { opacity: 0, transform: "translateY(-100%)" },
206
+ { opacity: 1, transform: "translateY(0)" }
207
+ ],
208
+ options: {
209
+ duration: 500,
210
+ easing: "cubic-bezier(0.45,0.05,0.55,0.95)"
211
+ }
212
+ });
213
+ setDefaultAnimation("banner.item.prev", {
214
+ keyframes: [
215
+ { opacity: 0, transform: "translateY(100%)" },
216
+ { opacity: 1, transform: "translateY(0)" }
217
+ ],
218
+ options: {
219
+ duration: 500,
220
+ easing: "cubic-bezier(0.45,0.05,0.55,0.95)"
221
+ }
222
+ });
223
+
224
+ export { SgdsSystemBanner, SgdsSystemBanner as default };
225
+ //# sourceMappingURL=sgds-system-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sgds-system-banner.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":["alertBannerStyles"],"mappings":";;;;;;;;;;;;;;;;AAeA;;;;;;;;;AASG;AACG,MAAO,gBAAiB,SAAQ,WAAW,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,CAAC,IAAI,GAAG,KAAK,CAAC;KACnB;AAiBS,IAAA,YAAY,CAAC,iBAAyC,EAAA;AAC9D,QAAA,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;AACzC,QAAA,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,IAA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Property(exports, '__esModule', { value: true });
5
+
6
+ var context = require('@lit/context');
7
+
8
+ const SystemBannerChildCountContext = context.createContext("system-banner-children-count-context");
9
+
10
+ exports.SystemBannerChildCountContext = SystemBannerChildCountContext;
11
+ //# sourceMappingURL=system-banner-context.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-banner-context.cjs.js","sources":["../../../../src/components/SystemBanner/system-banner-context.ts"],"sourcesContent":["import { createContext } from \"@lit/context\";\n\nexport const SystemBannerChildCountContext = createContext<boolean>(\"system-banner-children-count-context\");\n"],"names":["createContext"],"mappings":";;;;;;;MAEa,6BAA6B,GAAGA,qBAAa,CAAU,sCAAsC;;;;"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import { createContext } from '@lit/context';
3
+
4
+ const SystemBannerChildCountContext = createContext("system-banner-children-count-context");
5
+
6
+ export { SystemBannerChildCountContext };
7
+ //# sourceMappingURL=system-banner-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-banner-context.js","sources":["../../../../src/components/SystemBanner/system-banner-context.ts"],"sourcesContent":["import { createContext } from \"@lit/context\";\n\nexport const SystemBannerChildCountContext = createContext<boolean>(\"system-banner-children-count-context\");\n"],"names":[],"mappings":";;;MAEa,6BAA6B,GAAG,aAAa,CAAU,sCAAsC;;;;"}
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var lit = require('lit');
7
+
8
+ var css_248z = lit.css`:host{display:block;font-size:var(--sgds-font-size-1,14px);font-style:normal;font-weight:var(--sgds-font-weight-regular,400);letter-spacing:var(--sgds-letter-spacing-normal,0);line-height:var(--sgds-line-height-20,20px);width:inherit}.banner-item{color:var(--sgds-color-fixed-light);display:flex;gap:var(--sgds-gap-sm);padding:var(--sgds-padding-2-xs) 0}.message{line-clamp:5;-webkit-line-clamp:5;-webkit-box-orient:vertical;display:-webkit-box;max-height:calc(var(--sgds-line-height-20, 20px)*5);overflow:hidden;word-break:break-all}.message.truncated:after{background-color:var(--sgds-surface-fixed-dark);bottom:0;content:"";height:var(--sgds-line-height-20,20px);position:absolute;right:0;text-align:right;width:10ch}.clamped-container{display:inline-block;margin-right:var(--sgds-margin-md);max-width:var(--sgds-dimension-872);position:relative}.show-more{bottom:0;position:absolute;right:0;white-space:nowrap}.show-more__link{cursor:pointer;text-decoration:underline}.action{align-items:center;display:flex;gap:var(--sgds-gap-2-xs,4px);margin-top:6px;min-height:var(--sgds-line-height-20);white-space:nowrap}slot[name=action]::slotted(a){color:var(--sgds-color-fixed-light)!important;font-size:var(--sgds-font-size-1,14px)!important;text-decoration:none!important}.banner-item__message_and__action{display:flex;flex:1 0 0;flex-direction:column;gap:var(--sgds-gap-xs)}@media (min-width:512px){.banner-item__message_and__action{flex-direction:row;gap:var(--sgds-gap-sm)}.action{margin-left:auto;margin-top:0}.message{line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;max-height:calc(var(--sgds-line-height-20, 20px)*2);overflow:hidden;word-break:break-all}}`;
9
+
10
+ exports["default"] = css_248z;
11
+ //# sourceMappingURL=system-banner-item.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-banner-item.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import { css } from 'lit';
3
+
4
+ var css_248z = css`:host{display:block;font-size:var(--sgds-font-size-1,14px);font-style:normal;font-weight:var(--sgds-font-weight-regular,400);letter-spacing:var(--sgds-letter-spacing-normal,0);line-height:var(--sgds-line-height-20,20px);width:inherit}.banner-item{color:var(--sgds-color-fixed-light);display:flex;gap:var(--sgds-gap-sm);padding:var(--sgds-padding-2-xs) 0}.message{line-clamp:5;-webkit-line-clamp:5;-webkit-box-orient:vertical;display:-webkit-box;max-height:calc(var(--sgds-line-height-20, 20px)*5);overflow:hidden;word-break:break-all}.message.truncated:after{background-color:var(--sgds-surface-fixed-dark);bottom:0;content:"";height:var(--sgds-line-height-20,20px);position:absolute;right:0;text-align:right;width:10ch}.clamped-container{display:inline-block;margin-right:var(--sgds-margin-md);max-width:var(--sgds-dimension-872);position:relative}.show-more{bottom:0;position:absolute;right:0;white-space:nowrap}.show-more__link{cursor:pointer;text-decoration:underline}.action{align-items:center;display:flex;gap:var(--sgds-gap-2-xs,4px);margin-top:6px;min-height:var(--sgds-line-height-20);white-space:nowrap}slot[name=action]::slotted(a){color:var(--sgds-color-fixed-light)!important;font-size:var(--sgds-font-size-1,14px)!important;text-decoration:none!important}.banner-item__message_and__action{display:flex;flex:1 0 0;flex-direction:column;gap:var(--sgds-gap-xs)}@media (min-width:512px){.banner-item__message_and__action{flex-direction:row;gap:var(--sgds-gap-sm)}.action{margin-left:auto;margin-top:0}.message{line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;max-height:calc(var(--sgds-line-height-20, 20px)*2);overflow:hidden;word-break:break-all}}`;
5
+
6
+ export { css_248z as default };
7
+ //# sourceMappingURL=system-banner-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-banner-item.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var lit = require('lit');
7
+
8
+ var css_248z = lit.css`.banner{align-items:center;background-color:var(--sgds-surface-fixed-dark);color:var(--sgds-color-fixed-light);display:flex;flex-direction:row;gap:var(--sgds-gap-xl);min-height:var(--sgds-dimension-64);padding:var(--sgds-padding-sm) var(--sgds-padding-2-xl);position:relative}.content{flex:1;overflow:hidden;width:100%}::slotted(sgds-system-banner-item){display:none;flex:0 0 100%;opacity:0}::slotted(sgds-system-banner-item[active]){display:block;opacity:1}.pagination{align-items:center;bottom:12px;display:flex;font-size:var(--sgds-font-size-0);font-weight:var(--sgds-font-weight-regular,400);gap:var(--sgds-gap-2-xs);letter-spacing:var(--sgds-letter-spacing-normal,0);line-height:var(--sgds-line-height-16,16px);position:absolute;right:20px}.d-none{display:none}sgds-close-button{position:absolute;right:20px;top:10px}@media (min-width:512px){.pagination,sgds-close-button{position:static}}`;
9
+
10
+ exports["default"] = css_248z;
11
+ //# sourceMappingURL=system-banner.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-banner.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import { css } from 'lit';
3
+
4
+ var css_248z = css`.banner{align-items:center;background-color:var(--sgds-surface-fixed-dark);color:var(--sgds-color-fixed-light);display:flex;flex-direction:row;gap:var(--sgds-gap-xl);min-height:var(--sgds-dimension-64);padding:var(--sgds-padding-sm) var(--sgds-padding-2-xl);position:relative}.content{flex:1;overflow:hidden;width:100%}::slotted(sgds-system-banner-item){display:none;flex:0 0 100%;opacity:0}::slotted(sgds-system-banner-item[active]){display:block;opacity:1}.pagination{align-items:center;bottom:12px;display:flex;font-size:var(--sgds-font-size-0);font-weight:var(--sgds-font-weight-regular,400);gap:var(--sgds-gap-2-xs);letter-spacing:var(--sgds-letter-spacing-normal,0);line-height:var(--sgds-line-height-16,16px);position:absolute;right:20px}.d-none{display:none}sgds-close-button{position:absolute;right:20px;top:10px}@media (min-width:512px){.pagination,sgds-close-button{position:static}}`;
5
+
6
+ export { css_248z as default };
7
+ //# sourceMappingURL=system-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-banner.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -7,7 +7,7 @@ var tslib = require('tslib');
7
7
  var lit = require('lit');
8
8
  var decorators_js = require('lit/decorators.js');
9
9
  var sgdsElement = require('../../base/sgds-element.cjs.js');
10
- var sgdsCloseButton = require('../../internals/CloseButton/sgds-close-button.cjs.js');
10
+ var sgdsCloseButton = require('../CloseButton/sgds-close-button.cjs.js');
11
11
  var animate = require('../../utils/animate.cjs.js');
12
12
  var animationRegistry = require('../../utils/animation-registry.cjs.js');
13
13
  var event = require('../../utils/event.cjs.js');
@@ -122,7 +122,7 @@ class SgdsToast extends sgdsElement["default"] {
122
122
  ${this.dismissible
123
123
  ? lit.html `<sgds-close-button
124
124
  class="close-btn"
125
- ariaLabel="close toast"
125
+ aria-label="close toast"
126
126
  @click=${this.handleCloseClick}
127
127
  ></sgds-close-button>`
128
128
  : lit.nothing}
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-toast.cjs.js","sources":["../../../../src/components/Toast/sgds-toast.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedNodes } from \"lit/decorators.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsCloseButton from \"../../internals/CloseButton/sgds-close-button\";\nimport { animateTo } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { waitForEvent } from \"../../utils/event\";\nimport { watch } from \"../../utils/watch\";\nimport toastStyle from \"./toast.css\";\n/**\n * @summary Toast allows you to convey quick messaging notifications to the user.\n *\n * @slot default - The content to pass into toast's body\n * @slot action - The content to pass into toast's action\n * @slot icon - The icon in toast\n *\n * @event sgds-show - Emitted on show.\n * @event sgds-after-show - Emitted on show after animation has completed.\n * @event sgds-hide - Emitted on hide.\n * @event sgds-after-hide - Emitted on hide after animation has completed.\n *\n */\nexport class SgdsToast extends SgdsElement {\n static styles = [...SgdsElement.styles, toastStyle];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n /**@internal */\n @query(\"div.toast\") toast: HTMLElement;\n /** Controls the appearance of toast */\n @property({ type: Boolean, reflect: true }) show = false;\n /** The header title of toast. It is required to assign a title to toast */\n @property({ type: String, reflect: true }) title = \"Title\";\n /** Controls whether the toast has fade animation during its appearance/disappearance */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n /** Controls if the toast will hide itself after the delay time. Works with delay property */\n @property({ type: Boolean, reflect: true }) autohide = false;\n /** The amount of time taken in miliseconds for toast to disappear after its first render. It takes effect only when autohide is set to true. Defaults to 5000ms */\n @property({ type: Number, reflect: true }) delay = 5000;\n /**The variant styles of toast */\n @property({ type: String, reflect: true }) variant: \"success\" | \"warning\" | \"danger\" | \"info\" = \"info\";\n /** Controls whether or not the Toast is dismissible */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** Shows the toast */\n public async showToast() {\n if (this.show) {\n return;\n }\n\n this.show = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hide the toast */\n public async hideToast() {\n if (!this.show) {\n return;\n }\n this.show = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n /** @internal */\n handleCloseClick() {\n this.show = false;\n this.emit(\"sgds-close\");\n }\n /**@internal */\n @watch(\"show\", { waitUntilFirstUpdate: true })\n async handleShowChange() {\n if (this.show) {\n this.emit(\"sgds-show\");\n this.toast.classList.remove(\"d-none\");\n const toastAnimation = getAnimation(this, \"toast.show\");\n\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n\n this.emit(\"sgds-after-show\");\n } else {\n this.emit(\"sgds-hide\");\n\n const toastAnimation = getAnimation(this, \"toast.hide\");\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n this.toast.classList.add(\"d-none\");\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>): void {\n super.firstUpdated(changedProperties);\n\n if (!this.show) {\n this.toast.classList.add(\"d-none\");\n }\n\n if (this._actionNodes.length === 0) {\n return this.shadowRoot.querySelector(\"slot[name='action']\")?.classList.add(\"d-none\");\n }\n }\n\n @queryAssignedNodes({ slot: \"action\", flatten: true })\n private _actionNodes!: Array<Node>;\n\n render() {\n if (this.autohide && this.show) {\n setTimeout(() => {\n this.show = false;\n }, this.delay);\n }\n return html`\n <div\n class=\"toast\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n >\n <slot name=\"icon\"></slot>\n <div class=\"toast-content\">\n <div class=\"toast-body\">\n <strong>${this.title}</strong>\n <span><slot></slot></span>\n </div>\n <slot class=\"toast-action\" name=\"action\"></slot>\n </div>\n ${this.dismissible\n ? html`<sgds-close-button\n class=\"close-btn\"\n ariaLabel=\"close toast\"\n @click=${this.handleCloseClick}\n ></sgds-close-button>`\n : nothing}\n </div>\n `;\n }\n}\n\nexport default SgdsToast;\n\nsetDefaultAnimation(\"toast.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400, easing: \"ease\" }\n});\nsetDefaultAnimation(\"toast.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400, easing: \"ease\" }\n});\n"],"names":["SgdsElement","waitForEvent","getAnimation","animateTo","html","nothing","toastStyle","SgdsCloseButton","__decorate","query","property","watch","queryAssignedNodes","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;AASA;;;;;;;;;;;;AAYG;AACG,MAAO,SAAU,SAAQA,sBAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAEd,IAAK,CAAA,KAAA,GAAG,OAAO,CAAC;;QAEf,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAEpB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAElB,IAAK,CAAA,KAAA,GAAG,IAAI,CAAC;;QAEb,IAAO,CAAA,OAAA,GAA8C,MAAM,CAAC;;QAE3D,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;KAmGjE;;AAhGQ,IAAA,MAAM,SAAS,GAAA;AACpB,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO;SACR;AAED,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,Q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A6D,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAE3DF,gBAAA,CAAA;IAA3CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAqB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AA4B1DF,gBAAA,CAAA;IADLG,WAAK,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAuB7C,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA,CAAA;AAeOH,gBAAA,CAAA;IADPI,gCAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACnB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAsCrCC,qCAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC,CAAC;AACHA,qCAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC;;;;;"}
1
+ {"version":3,"file":"sgds-toast.cjs.js","sources":["../../../../src/components/Toast/sgds-toast.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedNodes } from \"lit/decorators.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 { waitForEvent } from \"../../utils/event\";\nimport { watch } from \"../../utils/watch\";\nimport toastStyle from \"./toast.css\";\n/**\n * @summary Toast allows you to convey quick messaging notifications to the user.\n *\n * @slot default - The content to pass into toast's body\n * @slot action - The content to pass into toast's action\n * @slot icon - The icon in toast\n *\n * @event sgds-show - Emitted on show.\n * @event sgds-after-show - Emitted on show after animation has completed.\n * @event sgds-hide - Emitted on hide.\n * @event sgds-after-hide - Emitted on hide after animation has completed.\n *\n */\nexport class SgdsToast extends SgdsElement {\n static styles = [...SgdsElement.styles, toastStyle];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n /**@internal */\n @query(\"div.toast\") toast: HTMLElement;\n /** Controls the appearance of toast */\n @property({ type: Boolean, reflect: true }) show = false;\n /** The header title of toast. It is required to assign a title to toast */\n @property({ type: String, reflect: true }) title = \"Title\";\n /** Controls whether the toast has fade animation during its appearance/disappearance */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n /** Controls if the toast will hide itself after the delay time. Works with delay property */\n @property({ type: Boolean, reflect: true }) autohide = false;\n /** The amount of time taken in miliseconds for toast to disappear after its first render. It takes effect only when autohide is set to true. Defaults to 5000ms */\n @property({ type: Number, reflect: true }) delay = 5000;\n /**The variant styles of toast */\n @property({ type: String, reflect: true }) variant: \"success\" | \"warning\" | \"danger\" | \"info\" = \"info\";\n /** Controls whether or not the Toast is dismissible */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** Shows the toast */\n public async showToast() {\n if (this.show) {\n return;\n }\n\n this.show = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hide the toast */\n public async hideToast() {\n if (!this.show) {\n return;\n }\n this.show = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n /** @internal */\n handleCloseClick() {\n this.show = false;\n this.emit(\"sgds-close\");\n }\n /**@internal */\n @watch(\"show\", { waitUntilFirstUpdate: true })\n async handleShowChange() {\n if (this.show) {\n this.emit(\"sgds-show\");\n this.toast.classList.remove(\"d-none\");\n const toastAnimation = getAnimation(this, \"toast.show\");\n\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n\n this.emit(\"sgds-after-show\");\n } else {\n this.emit(\"sgds-hide\");\n\n const toastAnimation = getAnimation(this, \"toast.hide\");\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n this.toast.classList.add(\"d-none\");\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>): void {\n super.firstUpdated(changedProperties);\n\n if (!this.show) {\n this.toast.classList.add(\"d-none\");\n }\n\n if (this._actionNodes.length === 0) {\n return this.shadowRoot.querySelector(\"slot[name='action']\")?.classList.add(\"d-none\");\n }\n }\n\n @queryAssignedNodes({ slot: \"action\", flatten: true })\n private _actionNodes!: Array<Node>;\n\n render() {\n if (this.autohide && this.show) {\n setTimeout(() => {\n this.show = false;\n }, this.delay);\n }\n return html`\n <div\n class=\"toast\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n >\n <slot name=\"icon\"></slot>\n <div class=\"toast-content\">\n <div class=\"toast-body\">\n <strong>${this.title}</strong>\n <span><slot></slot></span>\n </div>\n <slot class=\"toast-action\" name=\"action\"></slot>\n </div>\n ${this.dismissible\n ? html`<sgds-close-button\n class=\"close-btn\"\n aria-label=\"close toast\"\n @click=${this.handleCloseClick}\n ></sgds-close-button>`\n : nothing}\n </div>\n `;\n }\n}\n\nexport default SgdsToast;\n\nsetDefaultAnimation(\"toast.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400, easing: \"ease\" }\n});\nsetDefaultAnimation(\"toast.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400, easing: \"ease\" }\n});\n"],"names":["SgdsElement","waitForEvent","getAnimation","animateTo","html","nothing","toastStyle","SgdsCloseButton","__decorate","query","property","watch","queryAssignedNodes","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;AASA;;;;;;;;;;;;AAYG;AACG,MAAO,SAAU,SAAQA,sBAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAEd,IAAK,CAAA,KAAA,GAAG,OAAO,CAAC;;QAEf,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAEpB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAElB,IAAK,CAAA,KAAA,GAAG,IAAI,CAAC;;QAEb,IAAO,CAAA,OAAA,GAA8C,MAAM,CAAC;;QAE3D,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;KAmGjE;;AAhGQ,IAAA,MAAM,SAAS,GAAA;AACpB,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO;SACR;AAED,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,QAAA,OAAOC,kBAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;KAC9C;;AAGM,IAAA,MAAM,SAAS,GAAA;AACpB,QAAA,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,OAAO;SACR;AACD,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;AAClB,QAAA,OAAOA,kBAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;KAC9C;;IAGD,gBAAgB,GAAA;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;AAClB,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACzB;;IAGK,MAAA,gBAAgB,GAAA;AACpB,QAAA,IAAI,IAAI,CAAC,I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C,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACnB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAsCrCC,qCAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC,CAAC;AACHA,qCAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC;;;;;"}
@@ -3,7 +3,7 @@ import { __decorate } from 'tslib';
3
3
  import { html, nothing } from 'lit';
4
4
  import { query, property, queryAssignedNodes } from 'lit/decorators.js';
5
5
  import SgdsElement from '../../base/sgds-element.js';
6
- import { SgdsCloseButton } from '../../internals/CloseButton/sgds-close-button.js';
6
+ import { SgdsCloseButton } from '../CloseButton/sgds-close-button.js';
7
7
  import { animateTo } from '../../utils/animate.js';
8
8
  import { setDefaultAnimation, getAnimation } from '../../utils/animation-registry.js';
9
9
  import { waitForEvent } from '../../utils/event.js';
@@ -118,7 +118,7 @@ class SgdsToast extends SgdsElement {
118
118
  ${this.dismissible
119
119
  ? html `<sgds-close-button
120
120
  class="close-btn"
121
- ariaLabel="close toast"
121
+ aria-label="close toast"
122
122
  @click=${this.handleCloseClick}
123
123
  ></sgds-close-button>`
124
124
  : nothing}
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-toast.js","sources":["../../../../src/components/Toast/sgds-toast.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedNodes } from \"lit/decorators.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsCloseButton from \"../../internals/CloseButton/sgds-close-button\";\nimport { animateTo } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { waitForEvent } from \"../../utils/event\";\nimport { watch } from \"../../utils/watch\";\nimport toastStyle from \"./toast.css\";\n/**\n * @summary Toast allows you to convey quick messaging notifications to the user.\n *\n * @slot default - The content to pass into toast's body\n * @slot action - The content to pass into toast's action\n * @slot icon - The icon in toast\n *\n * @event sgds-show - Emitted on show.\n * @event sgds-after-show - Emitted on show after animation has completed.\n * @event sgds-hide - Emitted on hide.\n * @event sgds-after-hide - Emitted on hide after animation has completed.\n *\n */\nexport class SgdsToast extends SgdsElement {\n static styles = [...SgdsElement.styles, toastStyle];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n /**@internal */\n @query(\"div.toast\") toast: HTMLElement;\n /** Controls the appearance of toast */\n @property({ type: Boolean, reflect: true }) show = false;\n /** The header title of toast. It is required to assign a title to toast */\n @property({ type: String, reflect: true }) title = \"Title\";\n /** Controls whether the toast has fade animation during its appearance/disappearance */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n /** Controls if the toast will hide itself after the delay time. Works with delay property */\n @property({ type: Boolean, reflect: true }) autohide = false;\n /** The amount of time taken in miliseconds for toast to disappear after its first render. It takes effect only when autohide is set to true. Defaults to 5000ms */\n @property({ type: Number, reflect: true }) delay = 5000;\n /**The variant styles of toast */\n @property({ type: String, reflect: true }) variant: \"success\" | \"warning\" | \"danger\" | \"info\" = \"info\";\n /** Controls whether or not the Toast is dismissible */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** Shows the toast */\n public async showToast() {\n if (this.show) {\n return;\n }\n\n this.show = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hide the toast */\n public async hideToast() {\n if (!this.show) {\n return;\n }\n this.show = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n /** @internal */\n handleCloseClick() {\n this.show = false;\n this.emit(\"sgds-close\");\n }\n /**@internal */\n @watch(\"show\", { waitUntilFirstUpdate: true })\n async handleShowChange() {\n if (this.show) {\n this.emit(\"sgds-show\");\n this.toast.classList.remove(\"d-none\");\n const toastAnimation = getAnimation(this, \"toast.show\");\n\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n\n this.emit(\"sgds-after-show\");\n } else {\n this.emit(\"sgds-hide\");\n\n const toastAnimation = getAnimation(this, \"toast.hide\");\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n this.toast.classList.add(\"d-none\");\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>): void {\n super.firstUpdated(changedProperties);\n\n if (!this.show) {\n this.toast.classList.add(\"d-none\");\n }\n\n if (this._actionNodes.length === 0) {\n return this.shadowRoot.querySelector(\"slot[name='action']\")?.classList.add(\"d-none\");\n }\n }\n\n @queryAssignedNodes({ slot: \"action\", flatten: true })\n private _actionNodes!: Array<Node>;\n\n render() {\n if (this.autohide && this.show) {\n setTimeout(() => {\n this.show = false;\n }, this.delay);\n }\n return html`\n <div\n class=\"toast\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n >\n <slot name=\"icon\"></slot>\n <div class=\"toast-content\">\n <div class=\"toast-body\">\n <strong>${this.title}</strong>\n <span><slot></slot></span>\n </div>\n <slot class=\"toast-action\" name=\"action\"></slot>\n </div>\n ${this.dismissible\n ? html`<sgds-close-button\n class=\"close-btn\"\n ariaLabel=\"close toast\"\n @click=${this.handleCloseClick}\n ></sgds-close-button>`\n : nothing}\n </div>\n `;\n }\n}\n\nexport default SgdsToast;\n\nsetDefaultAnimation(\"toast.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400, easing: \"ease\" }\n});\nsetDefaultAnimation(\"toast.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400, easing: \"ease\" }\n});\n"],"names":["toastStyle"],"mappings":";;;;;;;;;;;;AASA;;;;;;;;;;;;AAYG;AACG,MAAO,SAAU,SAAQ,WAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAEd,IAAK,CAAA,KAAA,GAAG,OAAO,CAAC;;QAEf,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAEpB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAElB,IAAK,CAAA,KAAA,GAAG,IAAI,CAAC;;QAEb,IAAO,CAAA,OAAA,GAA8C,MAAM,CAAC;;QAE3D,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;KAmGjE;;AAhGQ,IAAA,MAAM,SAAS,GAAA;AACpB,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO;SACR;AAED,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,QAAA,OAAO,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;KAC9C;;AAGM,IAAA,MAAM,SAAS,GAAA;AACpB,QAAA,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,OAAO;SACR;AACD,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;AAClB,QAAA,OAAO,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;KAC9C;;IAGD,gBAAgB,GAAA;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;AAClB,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACzB;;IAGK,MAAA,gBAAgB,GAAA;AACpB,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;AACb,YAAA,IAAI,CA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AAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAsCrC,mBAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC,CAAC;AACH,mBAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC;;;;"}
1
+ {"version":3,"file":"sgds-toast.js","sources":["../../../../src/components/Toast/sgds-toast.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedNodes } from \"lit/decorators.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 { waitForEvent } from \"../../utils/event\";\nimport { watch } from \"../../utils/watch\";\nimport toastStyle from \"./toast.css\";\n/**\n * @summary Toast allows you to convey quick messaging notifications to the user.\n *\n * @slot default - The content to pass into toast's body\n * @slot action - The content to pass into toast's action\n * @slot icon - The icon in toast\n *\n * @event sgds-show - Emitted on show.\n * @event sgds-after-show - Emitted on show after animation has completed.\n * @event sgds-hide - Emitted on hide.\n * @event sgds-after-hide - Emitted on hide after animation has completed.\n *\n */\nexport class SgdsToast extends SgdsElement {\n static styles = [...SgdsElement.styles, toastStyle];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n /**@internal */\n @query(\"div.toast\") toast: HTMLElement;\n /** Controls the appearance of toast */\n @property({ type: Boolean, reflect: true }) show = false;\n /** The header title of toast. It is required to assign a title to toast */\n @property({ type: String, reflect: true }) title = \"Title\";\n /** Controls whether the toast has fade animation during its appearance/disappearance */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n /** Controls if the toast will hide itself after the delay time. Works with delay property */\n @property({ type: Boolean, reflect: true }) autohide = false;\n /** The amount of time taken in miliseconds for toast to disappear after its first render. It takes effect only when autohide is set to true. Defaults to 5000ms */\n @property({ type: Number, reflect: true }) delay = 5000;\n /**The variant styles of toast */\n @property({ type: String, reflect: true }) variant: \"success\" | \"warning\" | \"danger\" | \"info\" = \"info\";\n /** Controls whether or not the Toast is dismissible */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** Shows the toast */\n public async showToast() {\n if (this.show) {\n return;\n }\n\n this.show = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hide the toast */\n public async hideToast() {\n if (!this.show) {\n return;\n }\n this.show = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n /** @internal */\n handleCloseClick() {\n this.show = false;\n this.emit(\"sgds-close\");\n }\n /**@internal */\n @watch(\"show\", { waitUntilFirstUpdate: true })\n async handleShowChange() {\n if (this.show) {\n this.emit(\"sgds-show\");\n this.toast.classList.remove(\"d-none\");\n const toastAnimation = getAnimation(this, \"toast.show\");\n\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n\n this.emit(\"sgds-after-show\");\n } else {\n this.emit(\"sgds-hide\");\n\n const toastAnimation = getAnimation(this, \"toast.hide\");\n if (!this.noAnimation) {\n await animateTo(this.toast, toastAnimation.keyframes, toastAnimation.options);\n }\n this.toast.classList.add(\"d-none\");\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>): void {\n super.firstUpdated(changedProperties);\n\n if (!this.show) {\n this.toast.classList.add(\"d-none\");\n }\n\n if (this._actionNodes.length === 0) {\n return this.shadowRoot.querySelector(\"slot[name='action']\")?.classList.add(\"d-none\");\n }\n }\n\n @queryAssignedNodes({ slot: \"action\", flatten: true })\n private _actionNodes!: Array<Node>;\n\n render() {\n if (this.autohide && this.show) {\n setTimeout(() => {\n this.show = false;\n }, this.delay);\n }\n return html`\n <div\n class=\"toast\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n >\n <slot name=\"icon\"></slot>\n <div class=\"toast-content\">\n <div class=\"toast-body\">\n <strong>${this.title}</strong>\n <span><slot></slot></span>\n </div>\n <slot class=\"toast-action\" name=\"action\"></slot>\n </div>\n ${this.dismissible\n ? html`<sgds-close-button\n class=\"close-btn\"\n aria-label=\"close toast\"\n @click=${this.handleCloseClick}\n ></sgds-close-button>`\n : nothing}\n </div>\n `;\n }\n}\n\nexport default SgdsToast;\n\nsetDefaultAnimation(\"toast.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400, easing: \"ease\" }\n});\nsetDefaultAnimation(\"toast.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400, easing: \"ease\" }\n});\n"],"names":["toastStyle"],"mappings":";;;;;;;;;;;;AASA;;;;;;;;;;;;AAYG;AACG,MAAO,SAAU,SAAQ,WAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAEd,IAAK,CAAA,KAAA,GAAG,OAAO,CAAC;;QAEf,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAEpB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAElB,IAAK,CAAA,KAAA,GAAG,IAAI,CAAC;;QAEb,IAAO,CAAA,OAAA,GAA8C,MAAM,CAAC;;QAE3D,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;KAmGjE;;AAhGQ,IAAA,MAAM,SAAS,GAAA;AACpB,QAAA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