@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
|
}
|
|
@@ -3485,45 +3485,120 @@
|
|
|
3485
3485
|
}
|
|
3486
3486
|
|
|
3487
3487
|
/**
|
|
3488
|
-
* @
|
|
3489
|
-
*
|
|
3488
|
+
* @license
|
|
3489
|
+
* Copyright 2019 Google LLC
|
|
3490
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3491
|
+
*/
|
|
3492
|
+
const global = window;
|
|
3493
|
+
/**
|
|
3494
|
+
* Whether the current browser supports `adoptedStyleSheets`.
|
|
3495
|
+
*/
|
|
3496
|
+
const supportsAdoptingStyleSheets = global.ShadowRoot &&
|
|
3497
|
+
(global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&
|
|
3498
|
+
'adoptedStyleSheets' in Document.prototype &&
|
|
3499
|
+
'replace' in CSSStyleSheet.prototype;
|
|
3500
|
+
/**
|
|
3501
|
+
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
|
|
3502
|
+
* available but `adoptedStyleSheets` is not, styles are appended to the
|
|
3503
|
+
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
|
|
3504
|
+
* Note, when shimming is used, any styles that are subsequently placed into
|
|
3505
|
+
* the shadowRoot should be placed *before* any shimmed adopted styles. This
|
|
3506
|
+
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
3507
|
+
* shadowRoot.
|
|
3508
|
+
*/
|
|
3509
|
+
const adoptStyles = (renderRoot, styles) => {
|
|
3510
|
+
if (supportsAdoptingStyleSheets) {
|
|
3511
|
+
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
3512
|
+
}
|
|
3513
|
+
else {
|
|
3514
|
+
styles.forEach((s) => {
|
|
3515
|
+
const style = document.createElement('style');
|
|
3516
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3517
|
+
const nonce = global['litNonce'];
|
|
3518
|
+
if (nonce !== undefined) {
|
|
3519
|
+
style.setAttribute('nonce', nonce);
|
|
3520
|
+
}
|
|
3521
|
+
style.textContent = s.cssText;
|
|
3522
|
+
renderRoot.appendChild(style);
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
3525
|
+
};
|
|
3526
|
+
|
|
3527
|
+
/**
|
|
3528
|
+
* @typedef {import('./types').RenderOptions} RenderOptions
|
|
3529
|
+
* @typedef {import('./types').ScopedElementsMixin} ScopedElementsMixin
|
|
3530
|
+
* @typedef {import('./types').ScopedElementsHost} ScopedElementsHost
|
|
3531
|
+
* @typedef {import('./types').ScopedElementsMap} ScopedElementsMap
|
|
3532
|
+
* @typedef {import('@lit/reactive-element').CSSResultOrNative} CSSResultOrNative
|
|
3490
3533
|
*/
|
|
3491
3534
|
|
|
3492
|
-
|
|
3493
|
-
const
|
|
3494
|
-
if (!versions.includes(version)) {
|
|
3495
|
-
versions.push(version);
|
|
3496
|
-
}
|
|
3535
|
+
// @ts-ignore
|
|
3536
|
+
const supportsScopedRegistry = !!ShadowRoot.prototype.createElement;
|
|
3497
3537
|
|
|
3498
3538
|
/**
|
|
3499
|
-
* @template {import('./types
|
|
3539
|
+
* @template {import('./types').Constructor<HTMLElement>} T
|
|
3500
3540
|
* @param {T} superclass
|
|
3501
|
-
* @return {T & import('./types
|
|
3541
|
+
* @return {T & import('./types').Constructor<ScopedElementsHost>}
|
|
3502
3542
|
*/
|
|
3503
|
-
const ScopedElementsMixinImplementation
|
|
3543
|
+
const ScopedElementsMixinImplementation = superclass =>
|
|
3504
3544
|
/** @type {ScopedElementsHost} */
|
|
3505
3545
|
class ScopedElementsHost extends superclass {
|
|
3506
3546
|
/**
|
|
3507
3547
|
* Obtains the scoped elements definitions map if specified.
|
|
3508
3548
|
*
|
|
3509
|
-
* @
|
|
3549
|
+
* @returns {ScopedElementsMap}
|
|
3550
|
+
*/
|
|
3551
|
+
static get scopedElements() {
|
|
3552
|
+
return {};
|
|
3553
|
+
}
|
|
3554
|
+
|
|
3555
|
+
/**
|
|
3556
|
+
* Obtains the ShadowRoot options.
|
|
3557
|
+
*
|
|
3558
|
+
* @type {ShadowRootInit}
|
|
3510
3559
|
*/
|
|
3511
|
-
static
|
|
3560
|
+
static get shadowRootOptions() {
|
|
3561
|
+
return this.__shadowRootOptions;
|
|
3562
|
+
}
|
|
3512
3563
|
|
|
3513
|
-
|
|
3514
|
-
|
|
3564
|
+
/**
|
|
3565
|
+
* Set the shadowRoot options.
|
|
3566
|
+
*
|
|
3567
|
+
* @param {ShadowRootInit} value
|
|
3568
|
+
*/
|
|
3569
|
+
static set shadowRootOptions(value) {
|
|
3570
|
+
this.__shadowRootOptions = value;
|
|
3515
3571
|
}
|
|
3516
3572
|
|
|
3517
|
-
/**
|
|
3518
|
-
|
|
3573
|
+
/**
|
|
3574
|
+
* Obtains the element styles.
|
|
3575
|
+
*
|
|
3576
|
+
* @returns {CSSResultOrNative[]}
|
|
3577
|
+
*/
|
|
3578
|
+
static get elementStyles() {
|
|
3579
|
+
return this.__elementStyles;
|
|
3580
|
+
}
|
|
3581
|
+
|
|
3582
|
+
static set elementStyles(styles) {
|
|
3583
|
+
this.__elementStyles = styles;
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
// either TS or ESLint will complain here
|
|
3587
|
+
// eslint-disable-next-line no-unused-vars
|
|
3588
|
+
constructor(..._args) {
|
|
3589
|
+
super();
|
|
3590
|
+
/** @type {RenderOptions} */
|
|
3591
|
+
this.renderOptions = this.renderOptions || undefined;
|
|
3592
|
+
}
|
|
3519
3593
|
|
|
3520
3594
|
/**
|
|
3521
3595
|
* Obtains the CustomElementRegistry associated to the ShadowRoot.
|
|
3522
3596
|
*
|
|
3523
|
-
* @returns {CustomElementRegistry
|
|
3597
|
+
* @returns {CustomElementRegistry}
|
|
3524
3598
|
*/
|
|
3525
3599
|
get registry() {
|
|
3526
|
-
|
|
3600
|
+
// @ts-ignore
|
|
3601
|
+
return this.constructor.__registry;
|
|
3527
3602
|
}
|
|
3528
3603
|
|
|
3529
3604
|
/**
|
|
@@ -3532,15 +3607,13 @@
|
|
|
3532
3607
|
* @param {CustomElementRegistry} registry
|
|
3533
3608
|
*/
|
|
3534
3609
|
set registry(registry) {
|
|
3535
|
-
|
|
3610
|
+
// @ts-ignore
|
|
3611
|
+
this.constructor.__registry = registry;
|
|
3536
3612
|
}
|
|
3537
3613
|
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
*/
|
|
3542
|
-
attachShadow(options) {
|
|
3543
|
-
const { scopedElements } = /** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
3614
|
+
createRenderRoot() {
|
|
3615
|
+
const { scopedElements, shadowRootOptions, elementStyles } =
|
|
3616
|
+
/** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
3544
3617
|
|
|
3545
3618
|
const shouldCreateRegistry =
|
|
3546
3619
|
!this.registry ||
|
|
@@ -3552,60 +3625,89 @@
|
|
|
3552
3625
|
* Create a new registry if:
|
|
3553
3626
|
* - the registry is not defined
|
|
3554
3627
|
* - this class doesn't have its own registry *AND* has no shared registry
|
|
3555
|
-
* This is important specifically for superclasses/inheritance
|
|
3556
3628
|
*/
|
|
3557
3629
|
if (shouldCreateRegistry) {
|
|
3558
|
-
this.registry = new CustomElementRegistry();
|
|
3559
|
-
for (const [tagName, klass] of Object.entries(scopedElements
|
|
3560
|
-
this.
|
|
3630
|
+
this.registry = supportsScopedRegistry ? new CustomElementRegistry() : customElements;
|
|
3631
|
+
for (const [tagName, klass] of Object.entries(scopedElements)) {
|
|
3632
|
+
this.defineScopedElement(tagName, klass);
|
|
3561
3633
|
}
|
|
3562
3634
|
}
|
|
3563
3635
|
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3636
|
+
/** @type {ShadowRootInit} */
|
|
3637
|
+
const options = {
|
|
3638
|
+
mode: 'open',
|
|
3639
|
+
...shadowRootOptions,
|
|
3567
3640
|
customElements: this.registry,
|
|
3568
|
-
|
|
3569
|
-
// For backwards compatibility, we pass it as both
|
|
3570
|
-
registry: this.registry,
|
|
3571
|
-
});
|
|
3572
|
-
}
|
|
3573
|
-
};
|
|
3641
|
+
};
|
|
3574
3642
|
|
|
3575
|
-
|
|
3643
|
+
const createdRoot = this.attachShadow(options);
|
|
3644
|
+
if (supportsScopedRegistry) {
|
|
3645
|
+
this.renderOptions.creationScope = createdRoot;
|
|
3646
|
+
}
|
|
3576
3647
|
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
* @typedef {import('lit').LitElement} LitElement
|
|
3582
|
-
* @typedef {typeof import('lit').LitElement} TypeofLitElement
|
|
3583
|
-
* @typedef {import('@open-wc/dedupe-mixin').Constructor<LitElement>} LitElementConstructor
|
|
3584
|
-
* @typedef {import('@open-wc/dedupe-mixin').Constructor<ScopedElementsHost>} ScopedElementsHostConstructor
|
|
3585
|
-
*/
|
|
3648
|
+
if (createdRoot instanceof ShadowRoot) {
|
|
3649
|
+
adoptStyles(createdRoot, elementStyles);
|
|
3650
|
+
this.renderOptions.renderBefore = this.renderOptions.renderBefore || createdRoot.firstChild;
|
|
3651
|
+
}
|
|
3586
3652
|
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
* @param {T} superclass
|
|
3590
|
-
* @return {T & ScopedElementsHostConstructor}
|
|
3591
|
-
*/
|
|
3592
|
-
const ScopedElementsMixinImplementation = superclass =>
|
|
3593
|
-
/** @type {ScopedElementsHost} */
|
|
3594
|
-
class ScopedElementsHost extends ScopedElementsMixin$1(superclass) {
|
|
3595
|
-
createRenderRoot() {
|
|
3596
|
-
const { shadowRootOptions, elementStyles } = /** @type {TypeofLitElement} */ (
|
|
3597
|
-
this.constructor
|
|
3598
|
-
);
|
|
3653
|
+
return createdRoot;
|
|
3654
|
+
}
|
|
3599
3655
|
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3656
|
+
createScopedElement(tagName) {
|
|
3657
|
+
const root = supportsScopedRegistry ? this.shadowRoot : document;
|
|
3658
|
+
// @ts-ignore polyfill to support createElement on shadowRoot is loaded
|
|
3659
|
+
return root.createElement(tagName);
|
|
3660
|
+
}
|
|
3603
3661
|
|
|
3604
|
-
|
|
3662
|
+
/**
|
|
3663
|
+
* Defines a scoped element.
|
|
3664
|
+
*
|
|
3665
|
+
* @param {string} tagName
|
|
3666
|
+
* @param {typeof HTMLElement} klass
|
|
3667
|
+
*/
|
|
3668
|
+
defineScopedElement(tagName, klass) {
|
|
3669
|
+
const registeredClass = this.registry.get(tagName);
|
|
3670
|
+
if (registeredClass && supportsScopedRegistry === false && registeredClass !== klass) {
|
|
3671
|
+
// eslint-disable-next-line no-console
|
|
3672
|
+
console.error(
|
|
3673
|
+
[
|
|
3674
|
+
`You are trying to re-register the "${tagName}" custom element with a different class via ScopedElementsMixin.`,
|
|
3675
|
+
'This is only possible with a CustomElementRegistry.',
|
|
3676
|
+
'Your browser does not support this feature so you will need to load a polyfill for it.',
|
|
3677
|
+
'Load "@webcomponents/scoped-custom-element-registry" before you register ANY web component to the global customElements registry.',
|
|
3678
|
+
'e.g. add "<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>" as your first script tag.',
|
|
3679
|
+
'For more details you can visit https://open-wc.org/docs/development/scoped-elements/',
|
|
3680
|
+
].join('\n'),
|
|
3681
|
+
);
|
|
3682
|
+
}
|
|
3683
|
+
if (!registeredClass) {
|
|
3684
|
+
return this.registry.define(tagName, klass);
|
|
3685
|
+
}
|
|
3686
|
+
return this.registry.get(tagName);
|
|
3687
|
+
}
|
|
3605
3688
|
|
|
3606
|
-
|
|
3689
|
+
/**
|
|
3690
|
+
* @deprecated use the native el.tagName instead
|
|
3691
|
+
*
|
|
3692
|
+
* @param {string} tagName
|
|
3693
|
+
* @returns {string} the tag name
|
|
3694
|
+
*/
|
|
3695
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3696
|
+
getScopedTagName(tagName) {
|
|
3697
|
+
// @ts-ignore
|
|
3698
|
+
return this.constructor.getScopedTagName(tagName);
|
|
3699
|
+
}
|
|
3607
3700
|
|
|
3608
|
-
|
|
3701
|
+
/**
|
|
3702
|
+
* @deprecated use the native el.tagName instead
|
|
3703
|
+
*
|
|
3704
|
+
* @param {string} tagName
|
|
3705
|
+
* @returns {string} the tag name
|
|
3706
|
+
*/
|
|
3707
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3708
|
+
static getScopedTagName(tagName) {
|
|
3709
|
+
// @ts-ignore
|
|
3710
|
+
return this.__registry.get(tagName) ? tagName : undefined;
|
|
3609
3711
|
}
|
|
3610
3712
|
};
|
|
3611
3713
|
|