@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.
- package/components/Accordion/accordion.cjs.js +1 -1
- package/components/Accordion/accordion.js +1 -1
- package/components/Accordion/index.umd.js +1 -1
- package/components/ActionCard/index.umd.js +1938 -1836
- package/components/ActionCard/index.umd.js.map +1 -1
- package/components/ActionCard/sgds-action-card.cjs.js +2 -2
- package/components/ActionCard/sgds-action-card.cjs.js.map +1 -1
- package/components/ActionCard/sgds-action-card.d.ts +1 -1
- package/components/ActionCard/sgds-action-card.js +1 -1
- package/components/ActionCard/sgds-action-card.js.map +1 -1
- package/components/Alert/index.umd.js +200 -98
- package/components/Alert/index.umd.js.map +1 -1
- package/components/Alert/sgds-alert.cjs.js +2 -2
- package/components/Alert/sgds-alert.cjs.js.map +1 -1
- package/components/Alert/sgds-alert.d.ts +1 -1
- package/components/Alert/sgds-alert.js +1 -1
- package/components/Alert/sgds-alert.js.map +1 -1
- package/components/ComboBox/index.umd.js +229 -127
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/ComboBox/sgds-combo-box.cjs.js +2 -2
- package/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
- package/components/ComboBox/sgds-combo-box.d.ts +1 -1
- package/components/ComboBox/sgds-combo-box.js +1 -1
- package/components/ComboBox/sgds-combo-box.js.map +1 -1
- package/components/Datepicker/index.umd.js +7836 -7734
- package/components/Datepicker/index.umd.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.cjs.js +2 -2
- package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.d.ts +1 -1
- package/components/Datepicker/sgds-datepicker.js +1 -1
- package/components/Datepicker/sgds-datepicker.js.map +1 -1
- package/components/Drawer/index.umd.js +200 -98
- package/components/Drawer/index.umd.js.map +1 -1
- package/components/Drawer/sgds-drawer.cjs.js +2 -2
- package/components/Drawer/sgds-drawer.cjs.js.map +1 -1
- package/components/Drawer/sgds-drawer.d.ts +1 -1
- package/components/Drawer/sgds-drawer.js +1 -1
- package/components/Drawer/sgds-drawer.js.map +1 -1
- package/components/Dropdown/index.umd.js +229 -127
- package/components/Dropdown/index.umd.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.cjs.js +2 -2
- package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.d.ts +1 -1
- package/components/Dropdown/sgds-dropdown.js +1 -1
- package/components/Dropdown/sgds-dropdown.js.map +1 -1
- package/components/FileUpload/index.umd.js +229 -127
- package/components/FileUpload/index.umd.js.map +1 -1
- package/components/FileUpload/sgds-file-upload.cjs.js +2 -2
- package/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
- package/components/FileUpload/sgds-file-upload.d.ts +1 -1
- package/components/FileUpload/sgds-file-upload.js +1 -1
- package/components/FileUpload/sgds-file-upload.js.map +1 -1
- package/components/Modal/index.umd.js +200 -98
- package/components/Modal/index.umd.js.map +1 -1
- package/components/Modal/sgds-modal.cjs.js +2 -2
- package/components/Modal/sgds-modal.cjs.js.map +1 -1
- package/components/Modal/sgds-modal.d.ts +1 -1
- package/components/Modal/sgds-modal.js +1 -1
- package/components/Modal/sgds-modal.js.map +1 -1
- package/components/QuantityToggle/index.umd.js +200 -98
- package/components/QuantityToggle/index.umd.js.map +1 -1
- package/components/QuantityToggle/sgds-quantity-toggle.cjs.js +2 -2
- package/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
- package/components/QuantityToggle/sgds-quantity-toggle.d.ts +1 -1
- package/components/QuantityToggle/sgds-quantity-toggle.js +1 -1
- package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
- package/components/Toast/index.umd.js +1938 -1836
- package/components/Toast/index.umd.js.map +1 -1
- package/components/Toast/sgds-toast.cjs.js +2 -2
- package/components/Toast/sgds-toast.cjs.js.map +1 -1
- package/components/Toast/sgds-toast.d.ts +1 -1
- package/components/Toast/sgds-toast.js +1 -1
- package/components/Toast/sgds-toast.js.map +1 -1
- package/components/index.umd.js +201 -99
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +201 -99
- package/index.umd.js.map +1 -1
- package/package.json +2 -2
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
*/
|
|
38
38
|
const NODE_MODE = false;
|
|
39
39
|
// Allows minifiers to rename references to globalThis
|
|
40
|
-
const global$
|
|
40
|
+
const global$3 = globalThis;
|
|
41
41
|
/**
|
|
42
42
|
* Whether the current browser supports `adoptedStyleSheets`.
|
|
43
43
|
*/
|
|
44
|
-
const supportsAdoptingStyleSheets = global$
|
|
45
|
-
(global$
|
|
44
|
+
const supportsAdoptingStyleSheets$1 = global$3.ShadowRoot &&
|
|
45
|
+
(global$3.ShadyCSS === undefined || global$3.ShadyCSS.nativeShadow) &&
|
|
46
46
|
'adoptedStyleSheets' in Document.prototype &&
|
|
47
47
|
'replace' in CSSStyleSheet.prototype;
|
|
48
48
|
const constructionToken = Symbol();
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
// constructable.
|
|
72
72
|
let styleSheet = this._styleSheet;
|
|
73
73
|
const strings = this._strings;
|
|
74
|
-
if (supportsAdoptingStyleSheets && styleSheet === undefined) {
|
|
74
|
+
if (supportsAdoptingStyleSheets$1 && styleSheet === undefined) {
|
|
75
75
|
const cacheable = strings !== undefined && strings.length === 1;
|
|
76
76
|
if (cacheable) {
|
|
77
77
|
styleSheet = cssTagCache.get(strings);
|
|
@@ -134,15 +134,15 @@
|
|
|
134
134
|
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
135
135
|
* shadowRoot.
|
|
136
136
|
*/
|
|
137
|
-
const adoptStyles = (renderRoot, styles) => {
|
|
138
|
-
if (supportsAdoptingStyleSheets) {
|
|
137
|
+
const adoptStyles$1 = (renderRoot, styles) => {
|
|
138
|
+
if (supportsAdoptingStyleSheets$1) {
|
|
139
139
|
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
142
142
|
for (const s of styles) {
|
|
143
143
|
const style = document.createElement('style');
|
|
144
144
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
-
const nonce = global$
|
|
145
|
+
const nonce = global$3['litNonce'];
|
|
146
146
|
if (nonce !== undefined) {
|
|
147
147
|
style.setAttribute('nonce', nonce);
|
|
148
148
|
}
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
}
|
|
159
159
|
return unsafeCSS(cssText);
|
|
160
160
|
};
|
|
161
|
-
const getCompatibleStyle = supportsAdoptingStyleSheets ||
|
|
161
|
+
const getCompatibleStyle = supportsAdoptingStyleSheets$1 ||
|
|
162
162
|
(NODE_MODE )
|
|
163
163
|
? (s) => s
|
|
164
164
|
: (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;
|
|
@@ -171,9 +171,9 @@
|
|
|
171
171
|
// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022
|
|
172
172
|
const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
|
|
173
173
|
// Lets a minifier replace globalThis references with a minified name
|
|
174
|
-
const global$
|
|
174
|
+
const global$2 = globalThis;
|
|
175
175
|
let issueWarning$4;
|
|
176
|
-
const trustedTypes$1 = global$
|
|
176
|
+
const trustedTypes$1 = global$2
|
|
177
177
|
.trustedTypes;
|
|
178
178
|
// Temporary workaround for https://crbug.com/993268
|
|
179
179
|
// Currently, any attribute starting with "on" is considered to be a
|
|
@@ -182,12 +182,12 @@
|
|
|
182
182
|
const emptyStringForBooleanAttribute = trustedTypes$1
|
|
183
183
|
? trustedTypes$1.emptyScript
|
|
184
184
|
: '';
|
|
185
|
-
const polyfillSupport$2 = global$
|
|
185
|
+
const polyfillSupport$2 = global$2.reactiveElementPolyfillSupportDevMode
|
|
186
186
|
;
|
|
187
187
|
{
|
|
188
188
|
// Ensure warnings are issued only 1x, even if multiple versions of Lit
|
|
189
189
|
// are loaded.
|
|
190
|
-
const issuedWarnings = (global$
|
|
190
|
+
const issuedWarnings = (global$2.litIssuedWarnings ??=
|
|
191
191
|
new Set());
|
|
192
192
|
// Issue a warning, if we haven't already.
|
|
193
193
|
issueWarning$4 = (code, warning) => {
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
};
|
|
200
200
|
issueWarning$4('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
201
201
|
// Issue polyfill support warning.
|
|
202
|
-
if (global$
|
|
202
|
+
if (global$2.ShadyDOM?.inUse && polyfillSupport$2 === undefined) {
|
|
203
203
|
issueWarning$4('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
204
204
|
`the \`polyfill-support\` module has not been loaded.`);
|
|
205
205
|
}
|
|
@@ -210,12 +210,12 @@
|
|
|
210
210
|
* Compiled out of prod mode builds.
|
|
211
211
|
*/
|
|
212
212
|
const debugLogEvent$1 = (event) => {
|
|
213
|
-
const shouldEmit = global$
|
|
213
|
+
const shouldEmit = global$2
|
|
214
214
|
.emitLitDebugLogEvents;
|
|
215
215
|
if (!shouldEmit) {
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
-
global$
|
|
218
|
+
global$2.dispatchEvent(new CustomEvent('lit-debug', {
|
|
219
219
|
detail: event,
|
|
220
220
|
}));
|
|
221
221
|
}
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
// Map from a class's metadata object to property options
|
|
288
288
|
// Note that we must use nullish-coalescing assignment so that we only use one
|
|
289
289
|
// map even if we load multiple version of this module.
|
|
290
|
-
global$
|
|
290
|
+
global$2.litPropertyMetadata ??= new WeakMap();
|
|
291
291
|
/**
|
|
292
292
|
* Base element class which manages element properties and attributes. When
|
|
293
293
|
* properties change, the `update` method is asynchronously called. This method
|
|
@@ -707,7 +707,7 @@
|
|
|
707
707
|
createRenderRoot() {
|
|
708
708
|
const renderRoot = this.shadowRoot ??
|
|
709
709
|
this.attachShadow(this.constructor.shadowRootOptions);
|
|
710
|
-
adoptStyles(renderRoot, this.constructor.elementStyles);
|
|
710
|
+
adoptStyles$1(renderRoot, this.constructor.elementStyles);
|
|
711
711
|
return renderRoot;
|
|
712
712
|
}
|
|
713
713
|
/**
|
|
@@ -1214,8 +1214,8 @@
|
|
|
1214
1214
|
}
|
|
1215
1215
|
// IMPORTANT: do not change the property name or the assignment expression.
|
|
1216
1216
|
// This line will be used in regexes to search for ReactiveElement usage.
|
|
1217
|
-
(global$
|
|
1218
|
-
if (global$
|
|
1217
|
+
(global$2.reactiveElementVersions ??= []).push('2.0.4');
|
|
1218
|
+
if (global$2.reactiveElementVersions.length > 1) {
|
|
1219
1219
|
issueWarning$4('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
1220
1220
|
`is not recommended.`);
|
|
1221
1221
|
}
|
|
@@ -1226,19 +1226,19 @@
|
|
|
1226
1226
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1227
1227
|
*/
|
|
1228
1228
|
// Allows minifiers to rename references to globalThis
|
|
1229
|
-
const global = globalThis;
|
|
1229
|
+
const global$1 = globalThis;
|
|
1230
1230
|
/**
|
|
1231
1231
|
* Useful for visualizing and logging insights into what the Lit template system is doing.
|
|
1232
1232
|
*
|
|
1233
1233
|
* Compiled out of prod mode builds.
|
|
1234
1234
|
*/
|
|
1235
1235
|
const debugLogEvent = (event) => {
|
|
1236
|
-
const shouldEmit = global
|
|
1236
|
+
const shouldEmit = global$1
|
|
1237
1237
|
.emitLitDebugLogEvents;
|
|
1238
1238
|
if (!shouldEmit) {
|
|
1239
1239
|
return;
|
|
1240
1240
|
}
|
|
1241
|
-
global.dispatchEvent(new CustomEvent('lit-debug', {
|
|
1241
|
+
global$1.dispatchEvent(new CustomEvent('lit-debug', {
|
|
1242
1242
|
detail: event,
|
|
1243
1243
|
}));
|
|
1244
1244
|
}
|
|
@@ -1249,24 +1249,24 @@
|
|
|
1249
1249
|
let debugLogRenderId = 0;
|
|
1250
1250
|
let issueWarning$3;
|
|
1251
1251
|
{
|
|
1252
|
-
global.litIssuedWarnings ??= new Set();
|
|
1252
|
+
global$1.litIssuedWarnings ??= new Set();
|
|
1253
1253
|
// Issue a warning, if we haven't already.
|
|
1254
1254
|
issueWarning$3 = (code, warning) => {
|
|
1255
1255
|
warning += code
|
|
1256
1256
|
? ` See https://lit.dev/msg/${code} for more information.`
|
|
1257
1257
|
: '';
|
|
1258
|
-
if (!global.litIssuedWarnings.has(warning)) {
|
|
1258
|
+
if (!global$1.litIssuedWarnings.has(warning)) {
|
|
1259
1259
|
console.warn(warning);
|
|
1260
|
-
global.litIssuedWarnings.add(warning);
|
|
1260
|
+
global$1.litIssuedWarnings.add(warning);
|
|
1261
1261
|
}
|
|
1262
1262
|
};
|
|
1263
1263
|
issueWarning$3('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
1264
1264
|
}
|
|
1265
|
-
const wrap = global.ShadyDOM?.inUse &&
|
|
1266
|
-
global.ShadyDOM?.noPatch === true
|
|
1267
|
-
? global.ShadyDOM.wrap
|
|
1265
|
+
const wrap = global$1.ShadyDOM?.inUse &&
|
|
1266
|
+
global$1.ShadyDOM?.noPatch === true
|
|
1267
|
+
? global$1.ShadyDOM.wrap
|
|
1268
1268
|
: (node) => node;
|
|
1269
|
-
const trustedTypes = global.trustedTypes;
|
|
1269
|
+
const trustedTypes = global$1.trustedTypes;
|
|
1270
1270
|
/**
|
|
1271
1271
|
* Our TrustedTypePolicy for HTML which is declared using the html template
|
|
1272
1272
|
* tag function.
|
|
@@ -2527,13 +2527,13 @@
|
|
|
2527
2527
|
}
|
|
2528
2528
|
}
|
|
2529
2529
|
// Apply polyfills if available
|
|
2530
|
-
const polyfillSupport$1 = global.litHtmlPolyfillSupportDevMode
|
|
2530
|
+
const polyfillSupport$1 = global$1.litHtmlPolyfillSupportDevMode
|
|
2531
2531
|
;
|
|
2532
2532
|
polyfillSupport$1?.(Template, ChildPart);
|
|
2533
2533
|
// IMPORTANT: do not change the property name or the assignment expression.
|
|
2534
2534
|
// This line will be used in regexes to search for lit-html usage.
|
|
2535
|
-
(global.litHtmlVersions ??= []).push('3.1.4');
|
|
2536
|
-
if (global.litHtmlVersions.length > 1) {
|
|
2535
|
+
(global$1.litHtmlVersions ??= []).push('3.1.4');
|
|
2536
|
+
if (global$1.litHtmlVersions.length > 1) {
|
|
2537
2537
|
issueWarning$3('multiple-versions', `Multiple versions of Lit loaded. ` +
|
|
2538
2538
|
`Loading multiple versions is not recommended.`);
|
|
2539
2539
|
}
|
|
@@ -3626,45 +3626,120 @@
|
|
|
3626
3626
|
}
|
|
3627
3627
|
|
|
3628
3628
|
/**
|
|
3629
|
-
* @
|
|
3630
|
-
*
|
|
3629
|
+
* @license
|
|
3630
|
+
* Copyright 2019 Google LLC
|
|
3631
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3632
|
+
*/
|
|
3633
|
+
const global = window;
|
|
3634
|
+
/**
|
|
3635
|
+
* Whether the current browser supports `adoptedStyleSheets`.
|
|
3636
|
+
*/
|
|
3637
|
+
const supportsAdoptingStyleSheets = global.ShadowRoot &&
|
|
3638
|
+
(global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&
|
|
3639
|
+
'adoptedStyleSheets' in Document.prototype &&
|
|
3640
|
+
'replace' in CSSStyleSheet.prototype;
|
|
3641
|
+
/**
|
|
3642
|
+
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
|
|
3643
|
+
* available but `adoptedStyleSheets` is not, styles are appended to the
|
|
3644
|
+
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
|
|
3645
|
+
* Note, when shimming is used, any styles that are subsequently placed into
|
|
3646
|
+
* the shadowRoot should be placed *before* any shimmed adopted styles. This
|
|
3647
|
+
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
3648
|
+
* shadowRoot.
|
|
3649
|
+
*/
|
|
3650
|
+
const adoptStyles = (renderRoot, styles) => {
|
|
3651
|
+
if (supportsAdoptingStyleSheets) {
|
|
3652
|
+
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
3653
|
+
}
|
|
3654
|
+
else {
|
|
3655
|
+
styles.forEach((s) => {
|
|
3656
|
+
const style = document.createElement('style');
|
|
3657
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3658
|
+
const nonce = global['litNonce'];
|
|
3659
|
+
if (nonce !== undefined) {
|
|
3660
|
+
style.setAttribute('nonce', nonce);
|
|
3661
|
+
}
|
|
3662
|
+
style.textContent = s.cssText;
|
|
3663
|
+
renderRoot.appendChild(style);
|
|
3664
|
+
});
|
|
3665
|
+
}
|
|
3666
|
+
};
|
|
3667
|
+
|
|
3668
|
+
/**
|
|
3669
|
+
* @typedef {import('./types').RenderOptions} RenderOptions
|
|
3670
|
+
* @typedef {import('./types').ScopedElementsMixin} ScopedElementsMixin
|
|
3671
|
+
* @typedef {import('./types').ScopedElementsHost} ScopedElementsHost
|
|
3672
|
+
* @typedef {import('./types').ScopedElementsMap} ScopedElementsMap
|
|
3673
|
+
* @typedef {import('@lit/reactive-element').CSSResultOrNative} CSSResultOrNative
|
|
3631
3674
|
*/
|
|
3632
3675
|
|
|
3633
|
-
|
|
3634
|
-
const
|
|
3635
|
-
if (!versions.includes(version)) {
|
|
3636
|
-
versions.push(version);
|
|
3637
|
-
}
|
|
3676
|
+
// @ts-ignore
|
|
3677
|
+
const supportsScopedRegistry = !!ShadowRoot.prototype.createElement;
|
|
3638
3678
|
|
|
3639
3679
|
/**
|
|
3640
|
-
* @template {import('./types
|
|
3680
|
+
* @template {import('./types').Constructor<HTMLElement>} T
|
|
3641
3681
|
* @param {T} superclass
|
|
3642
|
-
* @return {T & import('./types
|
|
3682
|
+
* @return {T & import('./types').Constructor<ScopedElementsHost>}
|
|
3643
3683
|
*/
|
|
3644
|
-
const ScopedElementsMixinImplementation
|
|
3684
|
+
const ScopedElementsMixinImplementation = superclass =>
|
|
3645
3685
|
/** @type {ScopedElementsHost} */
|
|
3646
3686
|
class ScopedElementsHost extends superclass {
|
|
3647
3687
|
/**
|
|
3648
3688
|
* Obtains the scoped elements definitions map if specified.
|
|
3649
3689
|
*
|
|
3650
|
-
* @
|
|
3690
|
+
* @returns {ScopedElementsMap}
|
|
3691
|
+
*/
|
|
3692
|
+
static get scopedElements() {
|
|
3693
|
+
return {};
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
/**
|
|
3697
|
+
* Obtains the ShadowRoot options.
|
|
3698
|
+
*
|
|
3699
|
+
* @type {ShadowRootInit}
|
|
3651
3700
|
*/
|
|
3652
|
-
static
|
|
3701
|
+
static get shadowRootOptions() {
|
|
3702
|
+
return this.__shadowRootOptions;
|
|
3703
|
+
}
|
|
3653
3704
|
|
|
3654
|
-
|
|
3655
|
-
|
|
3705
|
+
/**
|
|
3706
|
+
* Set the shadowRoot options.
|
|
3707
|
+
*
|
|
3708
|
+
* @param {ShadowRootInit} value
|
|
3709
|
+
*/
|
|
3710
|
+
static set shadowRootOptions(value) {
|
|
3711
|
+
this.__shadowRootOptions = value;
|
|
3656
3712
|
}
|
|
3657
3713
|
|
|
3658
|
-
/**
|
|
3659
|
-
|
|
3714
|
+
/**
|
|
3715
|
+
* Obtains the element styles.
|
|
3716
|
+
*
|
|
3717
|
+
* @returns {CSSResultOrNative[]}
|
|
3718
|
+
*/
|
|
3719
|
+
static get elementStyles() {
|
|
3720
|
+
return this.__elementStyles;
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
static set elementStyles(styles) {
|
|
3724
|
+
this.__elementStyles = styles;
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3727
|
+
// either TS or ESLint will complain here
|
|
3728
|
+
// eslint-disable-next-line no-unused-vars
|
|
3729
|
+
constructor(..._args) {
|
|
3730
|
+
super();
|
|
3731
|
+
/** @type {RenderOptions} */
|
|
3732
|
+
this.renderOptions = this.renderOptions || undefined;
|
|
3733
|
+
}
|
|
3660
3734
|
|
|
3661
3735
|
/**
|
|
3662
3736
|
* Obtains the CustomElementRegistry associated to the ShadowRoot.
|
|
3663
3737
|
*
|
|
3664
|
-
* @returns {CustomElementRegistry
|
|
3738
|
+
* @returns {CustomElementRegistry}
|
|
3665
3739
|
*/
|
|
3666
3740
|
get registry() {
|
|
3667
|
-
|
|
3741
|
+
// @ts-ignore
|
|
3742
|
+
return this.constructor.__registry;
|
|
3668
3743
|
}
|
|
3669
3744
|
|
|
3670
3745
|
/**
|
|
@@ -3673,15 +3748,13 @@
|
|
|
3673
3748
|
* @param {CustomElementRegistry} registry
|
|
3674
3749
|
*/
|
|
3675
3750
|
set registry(registry) {
|
|
3676
|
-
|
|
3751
|
+
// @ts-ignore
|
|
3752
|
+
this.constructor.__registry = registry;
|
|
3677
3753
|
}
|
|
3678
3754
|
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
*/
|
|
3683
|
-
attachShadow(options) {
|
|
3684
|
-
const { scopedElements } = /** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
3755
|
+
createRenderRoot() {
|
|
3756
|
+
const { scopedElements, shadowRootOptions, elementStyles } =
|
|
3757
|
+
/** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
3685
3758
|
|
|
3686
3759
|
const shouldCreateRegistry =
|
|
3687
3760
|
!this.registry ||
|
|
@@ -3693,60 +3766,89 @@
|
|
|
3693
3766
|
* Create a new registry if:
|
|
3694
3767
|
* - the registry is not defined
|
|
3695
3768
|
* - this class doesn't have its own registry *AND* has no shared registry
|
|
3696
|
-
* This is important specifically for superclasses/inheritance
|
|
3697
3769
|
*/
|
|
3698
3770
|
if (shouldCreateRegistry) {
|
|
3699
|
-
this.registry = new CustomElementRegistry();
|
|
3700
|
-
for (const [tagName, klass] of Object.entries(scopedElements
|
|
3701
|
-
this.
|
|
3771
|
+
this.registry = supportsScopedRegistry ? new CustomElementRegistry() : customElements;
|
|
3772
|
+
for (const [tagName, klass] of Object.entries(scopedElements)) {
|
|
3773
|
+
this.defineScopedElement(tagName, klass);
|
|
3702
3774
|
}
|
|
3703
3775
|
}
|
|
3704
3776
|
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3777
|
+
/** @type {ShadowRootInit} */
|
|
3778
|
+
const options = {
|
|
3779
|
+
mode: 'open',
|
|
3780
|
+
...shadowRootOptions,
|
|
3708
3781
|
customElements: this.registry,
|
|
3709
|
-
|
|
3710
|
-
// For backwards compatibility, we pass it as both
|
|
3711
|
-
registry: this.registry,
|
|
3712
|
-
});
|
|
3713
|
-
}
|
|
3714
|
-
};
|
|
3782
|
+
};
|
|
3715
3783
|
|
|
3716
|
-
|
|
3784
|
+
const createdRoot = this.attachShadow(options);
|
|
3785
|
+
if (supportsScopedRegistry) {
|
|
3786
|
+
this.renderOptions.creationScope = createdRoot;
|
|
3787
|
+
}
|
|
3717
3788
|
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
* @typedef {import('lit').LitElement} LitElement
|
|
3723
|
-
* @typedef {typeof import('lit').LitElement} TypeofLitElement
|
|
3724
|
-
* @typedef {import('@open-wc/dedupe-mixin').Constructor<LitElement>} LitElementConstructor
|
|
3725
|
-
* @typedef {import('@open-wc/dedupe-mixin').Constructor<ScopedElementsHost>} ScopedElementsHostConstructor
|
|
3726
|
-
*/
|
|
3789
|
+
if (createdRoot instanceof ShadowRoot) {
|
|
3790
|
+
adoptStyles(createdRoot, elementStyles);
|
|
3791
|
+
this.renderOptions.renderBefore = this.renderOptions.renderBefore || createdRoot.firstChild;
|
|
3792
|
+
}
|
|
3727
3793
|
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
* @param {T} superclass
|
|
3731
|
-
* @return {T & ScopedElementsHostConstructor}
|
|
3732
|
-
*/
|
|
3733
|
-
const ScopedElementsMixinImplementation = superclass =>
|
|
3734
|
-
/** @type {ScopedElementsHost} */
|
|
3735
|
-
class ScopedElementsHost extends ScopedElementsMixin$1(superclass) {
|
|
3736
|
-
createRenderRoot() {
|
|
3737
|
-
const { shadowRootOptions, elementStyles } = /** @type {TypeofLitElement} */ (
|
|
3738
|
-
this.constructor
|
|
3739
|
-
);
|
|
3794
|
+
return createdRoot;
|
|
3795
|
+
}
|
|
3740
3796
|
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3797
|
+
createScopedElement(tagName) {
|
|
3798
|
+
const root = supportsScopedRegistry ? this.shadowRoot : document;
|
|
3799
|
+
// @ts-ignore polyfill to support createElement on shadowRoot is loaded
|
|
3800
|
+
return root.createElement(tagName);
|
|
3801
|
+
}
|
|
3744
3802
|
|
|
3745
|
-
|
|
3803
|
+
/**
|
|
3804
|
+
* Defines a scoped element.
|
|
3805
|
+
*
|
|
3806
|
+
* @param {string} tagName
|
|
3807
|
+
* @param {typeof HTMLElement} klass
|
|
3808
|
+
*/
|
|
3809
|
+
defineScopedElement(tagName, klass) {
|
|
3810
|
+
const registeredClass = this.registry.get(tagName);
|
|
3811
|
+
if (registeredClass && supportsScopedRegistry === false && registeredClass !== klass) {
|
|
3812
|
+
// eslint-disable-next-line no-console
|
|
3813
|
+
console.error(
|
|
3814
|
+
[
|
|
3815
|
+
`You are trying to re-register the "${tagName}" custom element with a different class via ScopedElementsMixin.`,
|
|
3816
|
+
'This is only possible with a CustomElementRegistry.',
|
|
3817
|
+
'Your browser does not support this feature so you will need to load a polyfill for it.',
|
|
3818
|
+
'Load "@webcomponents/scoped-custom-element-registry" before you register ANY web component to the global customElements registry.',
|
|
3819
|
+
'e.g. add "<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>" as your first script tag.',
|
|
3820
|
+
'For more details you can visit https://open-wc.org/docs/development/scoped-elements/',
|
|
3821
|
+
].join('\n'),
|
|
3822
|
+
);
|
|
3823
|
+
}
|
|
3824
|
+
if (!registeredClass) {
|
|
3825
|
+
return this.registry.define(tagName, klass);
|
|
3826
|
+
}
|
|
3827
|
+
return this.registry.get(tagName);
|
|
3828
|
+
}
|
|
3746
3829
|
|
|
3747
|
-
|
|
3830
|
+
/**
|
|
3831
|
+
* @deprecated use the native el.tagName instead
|
|
3832
|
+
*
|
|
3833
|
+
* @param {string} tagName
|
|
3834
|
+
* @returns {string} the tag name
|
|
3835
|
+
*/
|
|
3836
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3837
|
+
getScopedTagName(tagName) {
|
|
3838
|
+
// @ts-ignore
|
|
3839
|
+
return this.constructor.getScopedTagName(tagName);
|
|
3840
|
+
}
|
|
3748
3841
|
|
|
3749
|
-
|
|
3842
|
+
/**
|
|
3843
|
+
* @deprecated use the native el.tagName instead
|
|
3844
|
+
*
|
|
3845
|
+
* @param {string} tagName
|
|
3846
|
+
* @returns {string} the tag name
|
|
3847
|
+
*/
|
|
3848
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3849
|
+
static getScopedTagName(tagName) {
|
|
3850
|
+
// @ts-ignore
|
|
3851
|
+
return this.__registry.get(tagName) ? tagName : undefined;
|
|
3750
3852
|
}
|
|
3751
3853
|
};
|
|
3752
3854
|
|