@govtechsg/sgds-web-component 2.0.0-rc.1 → 2.0.0-rc.2

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 (78) hide show
  1. package/components/Accordion/accordion.cjs.js +1 -1
  2. package/components/Accordion/accordion.js +1 -1
  3. package/components/Accordion/index.umd.js +1 -1
  4. package/components/ActionCard/index.umd.js +1938 -1836
  5. package/components/ActionCard/index.umd.js.map +1 -1
  6. package/components/ActionCard/sgds-action-card.cjs.js +2 -2
  7. package/components/ActionCard/sgds-action-card.cjs.js.map +1 -1
  8. package/components/ActionCard/sgds-action-card.d.ts +1 -1
  9. package/components/ActionCard/sgds-action-card.js +1 -1
  10. package/components/ActionCard/sgds-action-card.js.map +1 -1
  11. package/components/Alert/index.umd.js +200 -98
  12. package/components/Alert/index.umd.js.map +1 -1
  13. package/components/Alert/sgds-alert.cjs.js +2 -2
  14. package/components/Alert/sgds-alert.cjs.js.map +1 -1
  15. package/components/Alert/sgds-alert.d.ts +1 -1
  16. package/components/Alert/sgds-alert.js +1 -1
  17. package/components/Alert/sgds-alert.js.map +1 -1
  18. package/components/ComboBox/index.umd.js +229 -127
  19. package/components/ComboBox/index.umd.js.map +1 -1
  20. package/components/ComboBox/sgds-combo-box.cjs.js +2 -2
  21. package/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
  22. package/components/ComboBox/sgds-combo-box.d.ts +1 -1
  23. package/components/ComboBox/sgds-combo-box.js +1 -1
  24. package/components/ComboBox/sgds-combo-box.js.map +1 -1
  25. package/components/Datepicker/index.umd.js +7836 -7734
  26. package/components/Datepicker/index.umd.js.map +1 -1
  27. package/components/Datepicker/sgds-datepicker.cjs.js +2 -2
  28. package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
  29. package/components/Datepicker/sgds-datepicker.d.ts +1 -1
  30. package/components/Datepicker/sgds-datepicker.js +1 -1
  31. package/components/Datepicker/sgds-datepicker.js.map +1 -1
  32. package/components/Drawer/index.umd.js +200 -98
  33. package/components/Drawer/index.umd.js.map +1 -1
  34. package/components/Drawer/sgds-drawer.cjs.js +2 -2
  35. package/components/Drawer/sgds-drawer.cjs.js.map +1 -1
  36. package/components/Drawer/sgds-drawer.d.ts +1 -1
  37. package/components/Drawer/sgds-drawer.js +1 -1
  38. package/components/Drawer/sgds-drawer.js.map +1 -1
  39. package/components/Dropdown/index.umd.js +229 -127
  40. package/components/Dropdown/index.umd.js.map +1 -1
  41. package/components/Dropdown/sgds-dropdown.cjs.js +2 -2
  42. package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
  43. package/components/Dropdown/sgds-dropdown.d.ts +1 -1
  44. package/components/Dropdown/sgds-dropdown.js +1 -1
  45. package/components/Dropdown/sgds-dropdown.js.map +1 -1
  46. package/components/FileUpload/index.umd.js +229 -127
  47. package/components/FileUpload/index.umd.js.map +1 -1
  48. package/components/FileUpload/sgds-file-upload.cjs.js +2 -2
  49. package/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
  50. package/components/FileUpload/sgds-file-upload.d.ts +1 -1
  51. package/components/FileUpload/sgds-file-upload.js +1 -1
  52. package/components/FileUpload/sgds-file-upload.js.map +1 -1
  53. package/components/Modal/index.umd.js +200 -98
  54. package/components/Modal/index.umd.js.map +1 -1
  55. package/components/Modal/sgds-modal.cjs.js +2 -2
  56. package/components/Modal/sgds-modal.cjs.js.map +1 -1
  57. package/components/Modal/sgds-modal.d.ts +1 -1
  58. package/components/Modal/sgds-modal.js +1 -1
  59. package/components/Modal/sgds-modal.js.map +1 -1
  60. package/components/QuantityToggle/index.umd.js +200 -98
  61. package/components/QuantityToggle/index.umd.js.map +1 -1
  62. package/components/QuantityToggle/sgds-quantity-toggle.cjs.js +2 -2
  63. package/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
  64. package/components/QuantityToggle/sgds-quantity-toggle.d.ts +1 -1
  65. package/components/QuantityToggle/sgds-quantity-toggle.js +1 -1
  66. package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  67. package/components/Toast/index.umd.js +1938 -1836
  68. package/components/Toast/index.umd.js.map +1 -1
  69. package/components/Toast/sgds-toast.cjs.js +2 -2
  70. package/components/Toast/sgds-toast.cjs.js.map +1 -1
  71. package/components/Toast/sgds-toast.d.ts +1 -1
  72. package/components/Toast/sgds-toast.js +1 -1
  73. package/components/Toast/sgds-toast.js.map +1 -1
  74. package/components/index.umd.js +201 -99
  75. package/components/index.umd.js.map +1 -1
  76. package/index.umd.js +201 -99
  77. package/index.umd.js.map +1 -1
  78. package/package.json +2 -2
@@ -65,6 +65,235 @@
65
65
  };
66
66
  }
67
67
 
68
+ /**
69
+ * @license
70
+ * Copyright 2019 Google LLC
71
+ * SPDX-License-Identifier: BSD-3-Clause
72
+ */
73
+ const global$3 = window;
74
+ /**
75
+ * Whether the current browser supports `adoptedStyleSheets`.
76
+ */
77
+ const supportsAdoptingStyleSheets$1 = global$3.ShadowRoot &&
78
+ (global$3.ShadyCSS === undefined || global$3.ShadyCSS.nativeShadow) &&
79
+ 'adoptedStyleSheets' in Document.prototype &&
80
+ 'replace' in CSSStyleSheet.prototype;
81
+ /**
82
+ * Applies the given styles to a `shadowRoot`. When Shadow DOM is
83
+ * available but `adoptedStyleSheets` is not, styles are appended to the
84
+ * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
85
+ * Note, when shimming is used, any styles that are subsequently placed into
86
+ * the shadowRoot should be placed *before* any shimmed adopted styles. This
87
+ * will match spec behavior that gives adopted sheets precedence over styles in
88
+ * shadowRoot.
89
+ */
90
+ const adoptStyles$1 = (renderRoot, styles) => {
91
+ if (supportsAdoptingStyleSheets$1) {
92
+ renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
93
+ }
94
+ else {
95
+ styles.forEach((s) => {
96
+ const style = document.createElement('style');
97
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
+ const nonce = global$3['litNonce'];
99
+ if (nonce !== undefined) {
100
+ style.setAttribute('nonce', nonce);
101
+ }
102
+ style.textContent = s.cssText;
103
+ renderRoot.appendChild(style);
104
+ });
105
+ }
106
+ };
107
+
108
+ /**
109
+ * @typedef {import('./types').RenderOptions} RenderOptions
110
+ * @typedef {import('./types').ScopedElementsMixin} ScopedElementsMixin
111
+ * @typedef {import('./types').ScopedElementsHost} ScopedElementsHost
112
+ * @typedef {import('./types').ScopedElementsMap} ScopedElementsMap
113
+ * @typedef {import('@lit/reactive-element').CSSResultOrNative} CSSResultOrNative
114
+ */
115
+
116
+ // @ts-ignore
117
+ const supportsScopedRegistry = !!ShadowRoot.prototype.createElement;
118
+
119
+ /**
120
+ * @template {import('./types').Constructor<HTMLElement>} T
121
+ * @param {T} superclass
122
+ * @return {T & import('./types').Constructor<ScopedElementsHost>}
123
+ */
124
+ const ScopedElementsMixinImplementation = superclass =>
125
+ /** @type {ScopedElementsHost} */
126
+ class ScopedElementsHost extends superclass {
127
+ /**
128
+ * Obtains the scoped elements definitions map if specified.
129
+ *
130
+ * @returns {ScopedElementsMap}
131
+ */
132
+ static get scopedElements() {
133
+ return {};
134
+ }
135
+
136
+ /**
137
+ * Obtains the ShadowRoot options.
138
+ *
139
+ * @type {ShadowRootInit}
140
+ */
141
+ static get shadowRootOptions() {
142
+ return this.__shadowRootOptions;
143
+ }
144
+
145
+ /**
146
+ * Set the shadowRoot options.
147
+ *
148
+ * @param {ShadowRootInit} value
149
+ */
150
+ static set shadowRootOptions(value) {
151
+ this.__shadowRootOptions = value;
152
+ }
153
+
154
+ /**
155
+ * Obtains the element styles.
156
+ *
157
+ * @returns {CSSResultOrNative[]}
158
+ */
159
+ static get elementStyles() {
160
+ return this.__elementStyles;
161
+ }
162
+
163
+ static set elementStyles(styles) {
164
+ this.__elementStyles = styles;
165
+ }
166
+
167
+ // either TS or ESLint will complain here
168
+ // eslint-disable-next-line no-unused-vars
169
+ constructor(..._args) {
170
+ super();
171
+ /** @type {RenderOptions} */
172
+ this.renderOptions = this.renderOptions || undefined;
173
+ }
174
+
175
+ /**
176
+ * Obtains the CustomElementRegistry associated to the ShadowRoot.
177
+ *
178
+ * @returns {CustomElementRegistry}
179
+ */
180
+ get registry() {
181
+ // @ts-ignore
182
+ return this.constructor.__registry;
183
+ }
184
+
185
+ /**
186
+ * Set the CustomElementRegistry associated to the ShadowRoot
187
+ *
188
+ * @param {CustomElementRegistry} registry
189
+ */
190
+ set registry(registry) {
191
+ // @ts-ignore
192
+ this.constructor.__registry = registry;
193
+ }
194
+
195
+ createRenderRoot() {
196
+ const { scopedElements, shadowRootOptions, elementStyles } =
197
+ /** @type {typeof ScopedElementsHost} */ (this.constructor);
198
+
199
+ const shouldCreateRegistry =
200
+ !this.registry ||
201
+ // @ts-ignore
202
+ (this.registry === this.constructor.__registry &&
203
+ !Object.prototype.hasOwnProperty.call(this.constructor, '__registry'));
204
+
205
+ /**
206
+ * Create a new registry if:
207
+ * - the registry is not defined
208
+ * - this class doesn't have its own registry *AND* has no shared registry
209
+ */
210
+ if (shouldCreateRegistry) {
211
+ this.registry = supportsScopedRegistry ? new CustomElementRegistry() : customElements;
212
+ for (const [tagName, klass] of Object.entries(scopedElements)) {
213
+ this.defineScopedElement(tagName, klass);
214
+ }
215
+ }
216
+
217
+ /** @type {ShadowRootInit} */
218
+ const options = {
219
+ mode: 'open',
220
+ ...shadowRootOptions,
221
+ customElements: this.registry,
222
+ };
223
+
224
+ const createdRoot = this.attachShadow(options);
225
+ if (supportsScopedRegistry) {
226
+ this.renderOptions.creationScope = createdRoot;
227
+ }
228
+
229
+ if (createdRoot instanceof ShadowRoot) {
230
+ adoptStyles$1(createdRoot, elementStyles);
231
+ this.renderOptions.renderBefore = this.renderOptions.renderBefore || createdRoot.firstChild;
232
+ }
233
+
234
+ return createdRoot;
235
+ }
236
+
237
+ createScopedElement(tagName) {
238
+ const root = supportsScopedRegistry ? this.shadowRoot : document;
239
+ // @ts-ignore polyfill to support createElement on shadowRoot is loaded
240
+ return root.createElement(tagName);
241
+ }
242
+
243
+ /**
244
+ * Defines a scoped element.
245
+ *
246
+ * @param {string} tagName
247
+ * @param {typeof HTMLElement} klass
248
+ */
249
+ defineScopedElement(tagName, klass) {
250
+ const registeredClass = this.registry.get(tagName);
251
+ if (registeredClass && supportsScopedRegistry === false && registeredClass !== klass) {
252
+ // eslint-disable-next-line no-console
253
+ console.error(
254
+ [
255
+ `You are trying to re-register the "${tagName}" custom element with a different class via ScopedElementsMixin.`,
256
+ 'This is only possible with a CustomElementRegistry.',
257
+ 'Your browser does not support this feature so you will need to load a polyfill for it.',
258
+ 'Load "@webcomponents/scoped-custom-element-registry" before you register ANY web component to the global customElements registry.',
259
+ 'e.g. add "<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>" as your first script tag.',
260
+ 'For more details you can visit https://open-wc.org/docs/development/scoped-elements/',
261
+ ].join('\n'),
262
+ );
263
+ }
264
+ if (!registeredClass) {
265
+ return this.registry.define(tagName, klass);
266
+ }
267
+ return this.registry.get(tagName);
268
+ }
269
+
270
+ /**
271
+ * @deprecated use the native el.tagName instead
272
+ *
273
+ * @param {string} tagName
274
+ * @returns {string} the tag name
275
+ */
276
+ // eslint-disable-next-line class-methods-use-this
277
+ getScopedTagName(tagName) {
278
+ // @ts-ignore
279
+ return this.constructor.getScopedTagName(tagName);
280
+ }
281
+
282
+ /**
283
+ * @deprecated use the native el.tagName instead
284
+ *
285
+ * @param {string} tagName
286
+ * @returns {string} the tag name
287
+ */
288
+ // eslint-disable-next-line class-methods-use-this
289
+ static getScopedTagName(tagName) {
290
+ // @ts-ignore
291
+ return this.__registry.get(tagName) ? tagName : undefined;
292
+ }
293
+ };
294
+
295
+ const ScopedElementsMixin = dedupeMixin(ScopedElementsMixinImplementation);
296
+
68
297
  /**
69
298
  * @license
70
299
  * Copyright 2019 Google LLC
@@ -2804,133 +3033,6 @@
2804
3033
  `is not recommended.`);
2805
3034
  }
2806
3035
 
2807
- /**
2808
- * @typedef {import('./types.js').ScopedElementsHost} ScopedElementsHost
2809
- * @typedef {import('./types.js').ScopedElementsMap} ScopedElementsMap
2810
- */
2811
-
2812
- const version = '3.0.0';
2813
- const versions = window.scopedElementsVersions || (window.scopedElementsVersions = []);
2814
- if (!versions.includes(version)) {
2815
- versions.push(version);
2816
- }
2817
-
2818
- /**
2819
- * @template {import('./types.js').Constructor<HTMLElement>} T
2820
- * @param {T} superclass
2821
- * @return {T & import('./types.js').Constructor<ScopedElementsHost>}
2822
- */
2823
- const ScopedElementsMixinImplementation$1 = superclass =>
2824
- /** @type {ScopedElementsHost} */
2825
- class ScopedElementsHost extends superclass {
2826
- /**
2827
- * Obtains the scoped elements definitions map if specified.
2828
- *
2829
- * @type {ScopedElementsMap=}
2830
- */
2831
- static scopedElements;
2832
-
2833
- static get scopedElementsVersion() {
2834
- return version;
2835
- }
2836
-
2837
- /** @type {CustomElementRegistry=} */
2838
- static __registry;
2839
-
2840
- /**
2841
- * Obtains the CustomElementRegistry associated to the ShadowRoot.
2842
- *
2843
- * @returns {CustomElementRegistry=}
2844
- */
2845
- get registry() {
2846
- return /** @type {typeof ScopedElementsHost} */ (this.constructor).__registry;
2847
- }
2848
-
2849
- /**
2850
- * Set the CustomElementRegistry associated to the ShadowRoot
2851
- *
2852
- * @param {CustomElementRegistry} registry
2853
- */
2854
- set registry(registry) {
2855
- /** @type {typeof ScopedElementsHost} */ (this.constructor).__registry = registry;
2856
- }
2857
-
2858
- /**
2859
- * @param {ShadowRootInit} options
2860
- * @returns {ShadowRoot}
2861
- */
2862
- attachShadow(options) {
2863
- const { scopedElements } = /** @type {typeof ScopedElementsHost} */ (this.constructor);
2864
-
2865
- const shouldCreateRegistry =
2866
- !this.registry ||
2867
- // @ts-ignore
2868
- (this.registry === this.constructor.__registry &&
2869
- !Object.prototype.hasOwnProperty.call(this.constructor, '__registry'));
2870
-
2871
- /**
2872
- * Create a new registry if:
2873
- * - the registry is not defined
2874
- * - this class doesn't have its own registry *AND* has no shared registry
2875
- * This is important specifically for superclasses/inheritance
2876
- */
2877
- if (shouldCreateRegistry) {
2878
- this.registry = new CustomElementRegistry();
2879
- for (const [tagName, klass] of Object.entries(scopedElements ?? {})) {
2880
- this.registry.define(tagName, klass);
2881
- }
2882
- }
2883
-
2884
- return super.attachShadow({
2885
- ...options,
2886
- // The polyfill currently expects the registry to be passed as `customElements`
2887
- customElements: this.registry,
2888
- // But the proposal has moved forward, and renamed it to `registry`
2889
- // For backwards compatibility, we pass it as both
2890
- registry: this.registry,
2891
- });
2892
- }
2893
- };
2894
-
2895
- const ScopedElementsMixin$1 = dedupeMixin(ScopedElementsMixinImplementation$1);
2896
-
2897
- /**
2898
- * @typedef {import('./types.js').ScopedElementsHost} ScopedElementsHost
2899
- * @typedef {import('./types.js').ScopedElementsMap} ScopedElementsMap
2900
- * @typedef {import('lit').CSSResultOrNative} CSSResultOrNative
2901
- * @typedef {import('lit').LitElement} LitElement
2902
- * @typedef {typeof import('lit').LitElement} TypeofLitElement
2903
- * @typedef {import('@open-wc/dedupe-mixin').Constructor<LitElement>} LitElementConstructor
2904
- * @typedef {import('@open-wc/dedupe-mixin').Constructor<ScopedElementsHost>} ScopedElementsHostConstructor
2905
- */
2906
-
2907
- /**
2908
- * @template {LitElementConstructor} T
2909
- * @param {T} superclass
2910
- * @return {T & ScopedElementsHostConstructor}
2911
- */
2912
- const ScopedElementsMixinImplementation = superclass =>
2913
- /** @type {ScopedElementsHost} */
2914
- class ScopedElementsHost extends ScopedElementsMixin$1(superclass) {
2915
- createRenderRoot() {
2916
- const { shadowRootOptions, elementStyles } = /** @type {TypeofLitElement} */ (
2917
- this.constructor
2918
- );
2919
-
2920
- const shadowRoot = this.attachShadow(shadowRootOptions);
2921
- // @ts-ignore
2922
- this.renderOptions.creationScope = shadowRoot;
2923
-
2924
- adoptStyles(shadowRoot, elementStyles);
2925
-
2926
- this.renderOptions.renderBefore ??= shadowRoot.firstChild;
2927
-
2928
- return shadowRoot;
2929
- }
2930
- };
2931
-
2932
- const ScopedElementsMixin = dedupeMixin(ScopedElementsMixinImplementation);
2933
-
2934
3036
  /**
2935
3037
  * @license
2936
3038
  * Copyright 2017 Google LLC