@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var scopedElements = require('@open-wc/scoped-elements');
|
|
7
7
|
var decorators_js = require('lit/decorators.js');
|
|
8
8
|
var classMap_js = require('lit/directives/class-map.js');
|
|
9
9
|
var live_js = require('lit/directives/live.js');
|
|
@@ -31,7 +31,7 @@ var actionCard = require('./action-card.cjs.js');
|
|
|
31
31
|
* @csspart title - The action card title
|
|
32
32
|
* @csspart text - The action card text
|
|
33
33
|
*/
|
|
34
|
-
class SgdsActionCard extends
|
|
34
|
+
class SgdsActionCard extends scopedElements.ScopedElementsMixin(cardElement.CardElement) {
|
|
35
35
|
constructor() {
|
|
36
36
|
super(...arguments);
|
|
37
37
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-action-card.cjs.js","sources":["../../../src/components/ActionCard/sgds-action-card.ts"],"sourcesContent":["import { ScopedElementsMixin } from \"@open-wc/scoped-elements
|
|
1
|
+
{"version":3,"file":"sgds-action-card.cjs.js","sources":["../../../src/components/ActionCard/sgds-action-card.ts"],"sourcesContent":["import { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { Ref, createRef, ref } from \"lit/directives/ref.js\";\nimport { html } from \"lit/static-html.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport genId from \"../../utils/generateId\";\nimport { watch } from \"../../utils/watch\";\nimport { SgdsCheckbox } from \"../Checkbox/sgds-checkbox\";\nimport { SgdsRadio } from \"../Radio/sgds-radio\";\nimport actionCardStyles from \"./action-card.css\";\n\n/**\n * @summary Action Card are cards with built in checkbox or radio components. The ref of input is extended to the Card's body.\n * @slot icon - Icon content in the card-subtitile\n * @slot card-subtitle - The subtitle of the card\n * @slot card-title - The title of the card\n * @slot card-text - The paragrapher text of the card\n *\n * @event sgds-change - Emitted when the checked state of card's checkbox changes or when the selected card's radio has changed\n *\n * @csspart base - The action card base wrapper\n * @csspart body - The action card body\n * @csspart subtitle - The action card subtitle\n * @csspart title - The action card title\n * @csspart text - The action card text\n */\nexport class SgdsActionCard extends ScopedElementsMixin(CardElement) {\n static styles = [...CardElement.styles, actionCardStyles];\n /**@internal */\n static get scopedElements() {\n return {\n \"sgds-checkbox\": SgdsCheckbox,\n \"sgds-radio\": SgdsRadio\n };\n }\n /** @internal */\n inputRef: Ref<SgdsCheckbox | SgdsRadio> = createRef();\n /** Name of the HTML form control. Submitted with the form as part of a name/value pair. */\n @property({ reflect: true }) name: string;\n /** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */\n @property({ type: String }) value: string;\n /** Disables the input (so the user can't check / uncheck it). */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /** Draws the input in a checked state. */\n @property({ type: Boolean, reflect: true }) checked = false;\n\n /** The type of input of the action card */\n @property({ type: String, reflect: true }) type: TypeVariant = \"checkbox\";\n\n /** Controls the active styling of the action card */\n @property({ reflect: true, type: Boolean })\n active = false;\n\n /** Simulates a click on the input control*/\n public click() {\n this.inputRef.value.click();\n }\n /** @internal Declare the click event listener*/\n async handleInputChange() {\n this.inputRef.value.click();\n this.emit(\"sgds-change\");\n }\n /** @internal The input's id. */\n private inputId: string = genId(\"action-card\", \"input\");\n\n /** @internal */\n @watch(\"checked\")\n async handleRadioCheckedChange() {\n this.active = this.checked;\n }\n /** @internal */\n @watch(\"disabled\")\n async handleDisabledChange() {\n this.active = !this.disabled;\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === \"Enter\" && !hasModifier) {\n this.handleInputChange();\n }\n }\n\n render() {\n const checkbox = html`<sgds-checkbox\n ${ref(this.inputRef)}\n ?disabled=${this.disabled}\n id=${this.inputId}\n @click=${this.handleInputChange}\n @keydown=${this._handleKeyDown}\n .value=${live(this.value)}\n ?checked=${live(this.checked)}\n @sgds-change=${(e: CustomEvent) => (this.checked = e.detail.checked)}\n ></sgds-checkbox>`;\n\n const radio = html`<sgds-radio\n ${ref(this.inputRef)}\n ?disabled=${this.disabled}\n id=${this.inputId}\n @click=${this.handleInputChange}\n @keydown=${this._handleKeyDown}\n .value=${live(this.value)}\n ?checked=${live(this.checked)}\n ></sgds-radio>`;\n\n return html`\n <div\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this.handleInputChange}\n @keydown=${this._handleKeyDown}\n variant=\"card-action\"\n class=\"sgds card\n ${classMap({\n [`text-${this.textColor}`]: this.textColor,\n [`bg-${this.bgColor}`]: this.bgColor,\n [`border-${this.borderColor}`]: this.borderColor,\n [\"is-active\"]: this.active\n })}\n \"\n part=\"base\"\n >\n <div class=\"card-body\" part=\"body\">\n <h6 class=\"card-subtitle\" part=\"subtitle\">\n <div>\n <slot name=\"icon\"></slot>\n <slot name=\"card-subtitle\"></slot>\n </div>\n <div class=\"card-input\">${this.type === \"checkbox\" ? checkbox : radio}</div>\n </h6>\n <h5 class=\"card-title\" part=\"title\"><slot name=\"card-title\"></slot></h5>\n <p class=\"card-text\" part=\"text\"><slot name=\"card-text\"></slot></p>\n </div>\n </div>\n `;\n }\n}\n\nexport type TypeVariant = \"checkbox\" | \"radio\";\n\nexport default SgdsActionCard;\n"],"names":["ScopedElementsMixin","CardElement","createRef","genId","SgdsCheckbox","SgdsRadio","html","ref","live","classMap","actionCardStyles","__decorate","property","watch"],"mappings":";;;;;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;AAcG;MACU,cAAe,SAAQA,kCAAmB,CAACC,uBA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;AAAgC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI1ED,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAgBTD,gBAAA,CAAA;IADLE,WAAK,CAAC,SAAS,CAAC;AAGhB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,0BAAA,EAAA,IAAA,CAAA,CAAA;AAGKF,gBAAA,CAAA;IADLE,WAAK,CAAC,UAAU,CAAC;AAGjB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,sBAAA,EAAA,IAAA,CAAA;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { Ref } from "lit/directives/ref.js";
|
|
|
2
2
|
import { CardElement } from "../../base/card-element";
|
|
3
3
|
import { SgdsCheckbox } from "../Checkbox/sgds-checkbox";
|
|
4
4
|
import { SgdsRadio } from "../Radio/sgds-radio";
|
|
5
|
-
declare const SgdsActionCard_base: typeof CardElement & import("@open-wc/scoped-elements/
|
|
5
|
+
declare const SgdsActionCard_base: typeof CardElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
6
6
|
/**
|
|
7
7
|
* @summary Action Card are cards with built in checkbox or radio components. The ref of input is extended to the Card's body.
|
|
8
8
|
* @slot icon - Icon content in the card-subtitile
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
-
import { ScopedElementsMixin } from '@open-wc/scoped-elements
|
|
2
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { live } from 'lit/directives/live.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-action-card.js","sources":["../../../src/components/ActionCard/sgds-action-card.ts"],"sourcesContent":["import { ScopedElementsMixin } from \"@open-wc/scoped-elements
|
|
1
|
+
{"version":3,"file":"sgds-action-card.js","sources":["../../../src/components/ActionCard/sgds-action-card.ts"],"sourcesContent":["import { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { Ref, createRef, ref } from \"lit/directives/ref.js\";\nimport { html } from \"lit/static-html.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport genId from \"../../utils/generateId\";\nimport { watch } from \"../../utils/watch\";\nimport { SgdsCheckbox } from \"../Checkbox/sgds-checkbox\";\nimport { SgdsRadio } from \"../Radio/sgds-radio\";\nimport actionCardStyles from \"./action-card.css\";\n\n/**\n * @summary Action Card are cards with built in checkbox or radio components. The ref of input is extended to the Card's body.\n * @slot icon - Icon content in the card-subtitile\n * @slot card-subtitle - The subtitle of the card\n * @slot card-title - The title of the card\n * @slot card-text - The paragrapher text of the card\n *\n * @event sgds-change - Emitted when the checked state of card's checkbox changes or when the selected card's radio has changed\n *\n * @csspart base - The action card base wrapper\n * @csspart body - The action card body\n * @csspart subtitle - The action card subtitle\n * @csspart title - The action card title\n * @csspart text - The action card text\n */\nexport class SgdsActionCard extends ScopedElementsMixin(CardElement) {\n static styles = [...CardElement.styles, actionCardStyles];\n /**@internal */\n static get scopedElements() {\n return {\n \"sgds-checkbox\": SgdsCheckbox,\n \"sgds-radio\": SgdsRadio\n };\n }\n /** @internal */\n inputRef: Ref<SgdsCheckbox | SgdsRadio> = createRef();\n /** Name of the HTML form control. Submitted with the form as part of a name/value pair. */\n @property({ reflect: true }) name: string;\n /** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */\n @property({ type: String }) value: string;\n /** Disables the input (so the user can't check / uncheck it). */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /** Draws the input in a checked state. */\n @property({ type: Boolean, reflect: true }) checked = false;\n\n /** The type of input of the action card */\n @property({ type: String, reflect: true }) type: TypeVariant = \"checkbox\";\n\n /** Controls the active styling of the action card */\n @property({ reflect: true, type: Boolean })\n active = false;\n\n /** Simulates a click on the input control*/\n public click() {\n this.inputRef.value.click();\n }\n /** @internal Declare the click event listener*/\n async handleInputChange() {\n this.inputRef.value.click();\n this.emit(\"sgds-change\");\n }\n /** @internal The input's id. */\n private inputId: string = genId(\"action-card\", \"input\");\n\n /** @internal */\n @watch(\"checked\")\n async handleRadioCheckedChange() {\n this.active = this.checked;\n }\n /** @internal */\n @watch(\"disabled\")\n async handleDisabledChange() {\n this.active = !this.disabled;\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === \"Enter\" && !hasModifier) {\n this.handleInputChange();\n }\n }\n\n render() {\n const checkbox = html`<sgds-checkbox\n ${ref(this.inputRef)}\n ?disabled=${this.disabled}\n id=${this.inputId}\n @click=${this.handleInputChange}\n @keydown=${this._handleKeyDown}\n .value=${live(this.value)}\n ?checked=${live(this.checked)}\n @sgds-change=${(e: CustomEvent) => (this.checked = e.detail.checked)}\n ></sgds-checkbox>`;\n\n const radio = html`<sgds-radio\n ${ref(this.inputRef)}\n ?disabled=${this.disabled}\n id=${this.inputId}\n @click=${this.handleInputChange}\n @keydown=${this._handleKeyDown}\n .value=${live(this.value)}\n ?checked=${live(this.checked)}\n ></sgds-radio>`;\n\n return html`\n <div\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this.handleInputChange}\n @keydown=${this._handleKeyDown}\n variant=\"card-action\"\n class=\"sgds card\n ${classMap({\n [`text-${this.textColor}`]: this.textColor,\n [`bg-${this.bgColor}`]: this.bgColor,\n [`border-${this.borderColor}`]: this.borderColor,\n [\"is-active\"]: this.active\n })}\n \"\n part=\"base\"\n >\n <div class=\"card-body\" part=\"body\">\n <h6 class=\"card-subtitle\" part=\"subtitle\">\n <div>\n <slot name=\"icon\"></slot>\n <slot name=\"card-subtitle\"></slot>\n </div>\n <div class=\"card-input\">${this.type === \"checkbox\" ? checkbox : radio}</div>\n </h6>\n <h5 class=\"card-title\" part=\"title\"><slot name=\"card-title\"></slot></h5>\n <p class=\"card-text\" part=\"text\"><slot name=\"card-text\"></slot></p>\n </div>\n </div>\n `;\n }\n}\n\nexport type TypeVariant = \"checkbox\" | \"radio\";\n\nexport default SgdsActionCard;\n"],"names":["actionCardStyles"],"mappings":";;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;AAcG;MACU,cAAe,SAAQ,mBAAmB,CAAC,WAAW,CAAC,CAAA;AAApE,IAAA,WAAA,GAAA;;;QAUE,IAAQ,CAAA,QAAA,GAAkC,SAAS,EAAE,CAAC;;QAMV,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAEjB,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;;QAGjB,IAAI,CAAA,IAAA,GAAgB,UAAU,CAAC;;QAI1E,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;AAYP,QAAA,IAAA,CAAA,OAAO,GAAW,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;KAwEzD;;AA1GC,IAAA,WAAW,cAAc,GAAA;QACvB,OAAO;AACL,YAAA,eAAe,EAAE,YAAY;AAC7B,YAAA,YAAY,EAAE,SAAS;SACxB,CAAC;KACH;;IAoBM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;KAC7B;;AAED,IAAA,MAAM,iBAAiB,GAAA;AACrB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;AAC5B,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC1B;;IAMK,MAAA,wBAAwB,GAAA;AAC5B,QAAA,IAAI,CAAC,MAAM,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O,EAAE,IAAI,EAAE,CAAC;AAAkB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEjB,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAiB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGjB,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAgC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI1E,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAgBT,UAAA,CAAA;IADL,KAAK,CAAC,SAAS,CAAC;AAGhB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,0BAAA,EAAA,IAAA,CAAA,CAAA;AAGK,UAAA,CAAA;IADL,KAAK,CAAC,UAAU,CAAC;AAGjB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,sBAAA,EAAA,IAAA,CAAA;;;;"}
|
|
@@ -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$3;
|
|
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$3 = (code, warning) => {
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
};
|
|
200
200
|
issueWarning$3('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$3('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$3('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$2;
|
|
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$2 = (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$2('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$2('multiple-versions', `Multiple versions of Lit loaded. ` +
|
|
2538
2538
|
`Loading multiple versions is not recommended.`);
|
|
2539
2539
|
}
|
|
@@ -3224,45 +3224,120 @@
|
|
|
3224
3224
|
}
|
|
3225
3225
|
|
|
3226
3226
|
/**
|
|
3227
|
-
* @
|
|
3228
|
-
*
|
|
3227
|
+
* @license
|
|
3228
|
+
* Copyright 2019 Google LLC
|
|
3229
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3230
|
+
*/
|
|
3231
|
+
const global = window;
|
|
3232
|
+
/**
|
|
3233
|
+
* Whether the current browser supports `adoptedStyleSheets`.
|
|
3234
|
+
*/
|
|
3235
|
+
const supportsAdoptingStyleSheets = global.ShadowRoot &&
|
|
3236
|
+
(global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&
|
|
3237
|
+
'adoptedStyleSheets' in Document.prototype &&
|
|
3238
|
+
'replace' in CSSStyleSheet.prototype;
|
|
3239
|
+
/**
|
|
3240
|
+
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
|
|
3241
|
+
* available but `adoptedStyleSheets` is not, styles are appended to the
|
|
3242
|
+
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
|
|
3243
|
+
* Note, when shimming is used, any styles that are subsequently placed into
|
|
3244
|
+
* the shadowRoot should be placed *before* any shimmed adopted styles. This
|
|
3245
|
+
* will match spec behavior that gives adopted sheets precedence over styles in
|
|
3246
|
+
* shadowRoot.
|
|
3247
|
+
*/
|
|
3248
|
+
const adoptStyles = (renderRoot, styles) => {
|
|
3249
|
+
if (supportsAdoptingStyleSheets) {
|
|
3250
|
+
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
3251
|
+
}
|
|
3252
|
+
else {
|
|
3253
|
+
styles.forEach((s) => {
|
|
3254
|
+
const style = document.createElement('style');
|
|
3255
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3256
|
+
const nonce = global['litNonce'];
|
|
3257
|
+
if (nonce !== undefined) {
|
|
3258
|
+
style.setAttribute('nonce', nonce);
|
|
3259
|
+
}
|
|
3260
|
+
style.textContent = s.cssText;
|
|
3261
|
+
renderRoot.appendChild(style);
|
|
3262
|
+
});
|
|
3263
|
+
}
|
|
3264
|
+
};
|
|
3265
|
+
|
|
3266
|
+
/**
|
|
3267
|
+
* @typedef {import('./types').RenderOptions} RenderOptions
|
|
3268
|
+
* @typedef {import('./types').ScopedElementsMixin} ScopedElementsMixin
|
|
3269
|
+
* @typedef {import('./types').ScopedElementsHost} ScopedElementsHost
|
|
3270
|
+
* @typedef {import('./types').ScopedElementsMap} ScopedElementsMap
|
|
3271
|
+
* @typedef {import('@lit/reactive-element').CSSResultOrNative} CSSResultOrNative
|
|
3229
3272
|
*/
|
|
3230
3273
|
|
|
3231
|
-
|
|
3232
|
-
const
|
|
3233
|
-
if (!versions.includes(version)) {
|
|
3234
|
-
versions.push(version);
|
|
3235
|
-
}
|
|
3274
|
+
// @ts-ignore
|
|
3275
|
+
const supportsScopedRegistry = !!ShadowRoot.prototype.createElement;
|
|
3236
3276
|
|
|
3237
3277
|
/**
|
|
3238
|
-
* @template {import('./types
|
|
3278
|
+
* @template {import('./types').Constructor<HTMLElement>} T
|
|
3239
3279
|
* @param {T} superclass
|
|
3240
|
-
* @return {T & import('./types
|
|
3280
|
+
* @return {T & import('./types').Constructor<ScopedElementsHost>}
|
|
3241
3281
|
*/
|
|
3242
|
-
const ScopedElementsMixinImplementation
|
|
3282
|
+
const ScopedElementsMixinImplementation = superclass =>
|
|
3243
3283
|
/** @type {ScopedElementsHost} */
|
|
3244
3284
|
class ScopedElementsHost extends superclass {
|
|
3245
3285
|
/**
|
|
3246
3286
|
* Obtains the scoped elements definitions map if specified.
|
|
3247
3287
|
*
|
|
3248
|
-
* @
|
|
3288
|
+
* @returns {ScopedElementsMap}
|
|
3289
|
+
*/
|
|
3290
|
+
static get scopedElements() {
|
|
3291
|
+
return {};
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
/**
|
|
3295
|
+
* Obtains the ShadowRoot options.
|
|
3296
|
+
*
|
|
3297
|
+
* @type {ShadowRootInit}
|
|
3249
3298
|
*/
|
|
3250
|
-
static
|
|
3299
|
+
static get shadowRootOptions() {
|
|
3300
|
+
return this.__shadowRootOptions;
|
|
3301
|
+
}
|
|
3251
3302
|
|
|
3252
|
-
|
|
3253
|
-
|
|
3303
|
+
/**
|
|
3304
|
+
* Set the shadowRoot options.
|
|
3305
|
+
*
|
|
3306
|
+
* @param {ShadowRootInit} value
|
|
3307
|
+
*/
|
|
3308
|
+
static set shadowRootOptions(value) {
|
|
3309
|
+
this.__shadowRootOptions = value;
|
|
3254
3310
|
}
|
|
3255
3311
|
|
|
3256
|
-
/**
|
|
3257
|
-
|
|
3312
|
+
/**
|
|
3313
|
+
* Obtains the element styles.
|
|
3314
|
+
*
|
|
3315
|
+
* @returns {CSSResultOrNative[]}
|
|
3316
|
+
*/
|
|
3317
|
+
static get elementStyles() {
|
|
3318
|
+
return this.__elementStyles;
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
static set elementStyles(styles) {
|
|
3322
|
+
this.__elementStyles = styles;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
// either TS or ESLint will complain here
|
|
3326
|
+
// eslint-disable-next-line no-unused-vars
|
|
3327
|
+
constructor(..._args) {
|
|
3328
|
+
super();
|
|
3329
|
+
/** @type {RenderOptions} */
|
|
3330
|
+
this.renderOptions = this.renderOptions || undefined;
|
|
3331
|
+
}
|
|
3258
3332
|
|
|
3259
3333
|
/**
|
|
3260
3334
|
* Obtains the CustomElementRegistry associated to the ShadowRoot.
|
|
3261
3335
|
*
|
|
3262
|
-
* @returns {CustomElementRegistry
|
|
3336
|
+
* @returns {CustomElementRegistry}
|
|
3263
3337
|
*/
|
|
3264
3338
|
get registry() {
|
|
3265
|
-
|
|
3339
|
+
// @ts-ignore
|
|
3340
|
+
return this.constructor.__registry;
|
|
3266
3341
|
}
|
|
3267
3342
|
|
|
3268
3343
|
/**
|
|
@@ -3271,15 +3346,13 @@
|
|
|
3271
3346
|
* @param {CustomElementRegistry} registry
|
|
3272
3347
|
*/
|
|
3273
3348
|
set registry(registry) {
|
|
3274
|
-
|
|
3349
|
+
// @ts-ignore
|
|
3350
|
+
this.constructor.__registry = registry;
|
|
3275
3351
|
}
|
|
3276
3352
|
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
*/
|
|
3281
|
-
attachShadow(options) {
|
|
3282
|
-
const { scopedElements } = /** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
3353
|
+
createRenderRoot() {
|
|
3354
|
+
const { scopedElements, shadowRootOptions, elementStyles } =
|
|
3355
|
+
/** @type {typeof ScopedElementsHost} */ (this.constructor);
|
|
3283
3356
|
|
|
3284
3357
|
const shouldCreateRegistry =
|
|
3285
3358
|
!this.registry ||
|
|
@@ -3291,60 +3364,89 @@
|
|
|
3291
3364
|
* Create a new registry if:
|
|
3292
3365
|
* - the registry is not defined
|
|
3293
3366
|
* - this class doesn't have its own registry *AND* has no shared registry
|
|
3294
|
-
* This is important specifically for superclasses/inheritance
|
|
3295
3367
|
*/
|
|
3296
3368
|
if (shouldCreateRegistry) {
|
|
3297
|
-
this.registry = new CustomElementRegistry();
|
|
3298
|
-
for (const [tagName, klass] of Object.entries(scopedElements
|
|
3299
|
-
this.
|
|
3369
|
+
this.registry = supportsScopedRegistry ? new CustomElementRegistry() : customElements;
|
|
3370
|
+
for (const [tagName, klass] of Object.entries(scopedElements)) {
|
|
3371
|
+
this.defineScopedElement(tagName, klass);
|
|
3300
3372
|
}
|
|
3301
3373
|
}
|
|
3302
3374
|
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3375
|
+
/** @type {ShadowRootInit} */
|
|
3376
|
+
const options = {
|
|
3377
|
+
mode: 'open',
|
|
3378
|
+
...shadowRootOptions,
|
|
3306
3379
|
customElements: this.registry,
|
|
3307
|
-
|
|
3308
|
-
// For backwards compatibility, we pass it as both
|
|
3309
|
-
registry: this.registry,
|
|
3310
|
-
});
|
|
3311
|
-
}
|
|
3312
|
-
};
|
|
3380
|
+
};
|
|
3313
3381
|
|
|
3314
|
-
|
|
3382
|
+
const createdRoot = this.attachShadow(options);
|
|
3383
|
+
if (supportsScopedRegistry) {
|
|
3384
|
+
this.renderOptions.creationScope = createdRoot;
|
|
3385
|
+
}
|
|
3315
3386
|
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
* @typedef {import('lit').LitElement} LitElement
|
|
3321
|
-
* @typedef {typeof import('lit').LitElement} TypeofLitElement
|
|
3322
|
-
* @typedef {import('@open-wc/dedupe-mixin').Constructor<LitElement>} LitElementConstructor
|
|
3323
|
-
* @typedef {import('@open-wc/dedupe-mixin').Constructor<ScopedElementsHost>} ScopedElementsHostConstructor
|
|
3324
|
-
*/
|
|
3387
|
+
if (createdRoot instanceof ShadowRoot) {
|
|
3388
|
+
adoptStyles(createdRoot, elementStyles);
|
|
3389
|
+
this.renderOptions.renderBefore = this.renderOptions.renderBefore || createdRoot.firstChild;
|
|
3390
|
+
}
|
|
3325
3391
|
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
* @param {T} superclass
|
|
3329
|
-
* @return {T & ScopedElementsHostConstructor}
|
|
3330
|
-
*/
|
|
3331
|
-
const ScopedElementsMixinImplementation = superclass =>
|
|
3332
|
-
/** @type {ScopedElementsHost} */
|
|
3333
|
-
class ScopedElementsHost extends ScopedElementsMixin$1(superclass) {
|
|
3334
|
-
createRenderRoot() {
|
|
3335
|
-
const { shadowRootOptions, elementStyles } = /** @type {TypeofLitElement} */ (
|
|
3336
|
-
this.constructor
|
|
3337
|
-
);
|
|
3392
|
+
return createdRoot;
|
|
3393
|
+
}
|
|
3338
3394
|
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3395
|
+
createScopedElement(tagName) {
|
|
3396
|
+
const root = supportsScopedRegistry ? this.shadowRoot : document;
|
|
3397
|
+
// @ts-ignore polyfill to support createElement on shadowRoot is loaded
|
|
3398
|
+
return root.createElement(tagName);
|
|
3399
|
+
}
|
|
3342
3400
|
|
|
3343
|
-
|
|
3401
|
+
/**
|
|
3402
|
+
* Defines a scoped element.
|
|
3403
|
+
*
|
|
3404
|
+
* @param {string} tagName
|
|
3405
|
+
* @param {typeof HTMLElement} klass
|
|
3406
|
+
*/
|
|
3407
|
+
defineScopedElement(tagName, klass) {
|
|
3408
|
+
const registeredClass = this.registry.get(tagName);
|
|
3409
|
+
if (registeredClass && supportsScopedRegistry === false && registeredClass !== klass) {
|
|
3410
|
+
// eslint-disable-next-line no-console
|
|
3411
|
+
console.error(
|
|
3412
|
+
[
|
|
3413
|
+
`You are trying to re-register the "${tagName}" custom element with a different class via ScopedElementsMixin.`,
|
|
3414
|
+
'This is only possible with a CustomElementRegistry.',
|
|
3415
|
+
'Your browser does not support this feature so you will need to load a polyfill for it.',
|
|
3416
|
+
'Load "@webcomponents/scoped-custom-element-registry" before you register ANY web component to the global customElements registry.',
|
|
3417
|
+
'e.g. add "<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>" as your first script tag.',
|
|
3418
|
+
'For more details you can visit https://open-wc.org/docs/development/scoped-elements/',
|
|
3419
|
+
].join('\n'),
|
|
3420
|
+
);
|
|
3421
|
+
}
|
|
3422
|
+
if (!registeredClass) {
|
|
3423
|
+
return this.registry.define(tagName, klass);
|
|
3424
|
+
}
|
|
3425
|
+
return this.registry.get(tagName);
|
|
3426
|
+
}
|
|
3344
3427
|
|
|
3345
|
-
|
|
3428
|
+
/**
|
|
3429
|
+
* @deprecated use the native el.tagName instead
|
|
3430
|
+
*
|
|
3431
|
+
* @param {string} tagName
|
|
3432
|
+
* @returns {string} the tag name
|
|
3433
|
+
*/
|
|
3434
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3435
|
+
getScopedTagName(tagName) {
|
|
3436
|
+
// @ts-ignore
|
|
3437
|
+
return this.constructor.getScopedTagName(tagName);
|
|
3438
|
+
}
|
|
3346
3439
|
|
|
3347
|
-
|
|
3440
|
+
/**
|
|
3441
|
+
* @deprecated use the native el.tagName instead
|
|
3442
|
+
*
|
|
3443
|
+
* @param {string} tagName
|
|
3444
|
+
* @returns {string} the tag name
|
|
3445
|
+
*/
|
|
3446
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3447
|
+
static getScopedTagName(tagName) {
|
|
3448
|
+
// @ts-ignore
|
|
3449
|
+
return this.__registry.get(tagName) ? tagName : undefined;
|
|
3348
3450
|
}
|
|
3349
3451
|
};
|
|
3350
3452
|
|