@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
|
@@ -10,7 +10,7 @@ var staticHtml_js = require('lit/static-html.js');
|
|
|
10
10
|
var sgdsElement = require('../../base/sgds-element.cjs.js');
|
|
11
11
|
var watch = require('../../utils/watch.cjs.js');
|
|
12
12
|
var alert = require('./alert.cjs.js');
|
|
13
|
-
var
|
|
13
|
+
var scopedElements = require('@open-wc/scoped-elements');
|
|
14
14
|
var sgdsCloseButton = require('../../internals/CloseButton/sgds-close-button.cjs.js');
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -27,7 +27,7 @@ var sgdsCloseButton = require('../../internals/CloseButton/sgds-close-button.cjs
|
|
|
27
27
|
* @cssproperty --alert-icon-margin-right - The margin-right css of icon slot to position the gap between icon and alert message
|
|
28
28
|
*
|
|
29
29
|
*/
|
|
30
|
-
class SgdsAlert extends
|
|
30
|
+
class SgdsAlert extends scopedElements.ScopedElementsMixin(sgdsElement["default"]) {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
33
33
|
/** Controls the appearance of the alert */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-alert.cjs.js","sources":["../../../src/components/Alert/sgds-alert.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html } from \"lit/static-html.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { watch } from \"../../utils/watch\";\nimport alertStyle from \"./alert.css\";\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements
|
|
1
|
+
{"version":3,"file":"sgds-alert.cjs.js","sources":["../../../src/components/Alert/sgds-alert.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html } from \"lit/static-html.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { watch } from \"../../utils/watch\";\nimport alertStyle from \"./alert.css\";\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport SgdsCloseButton from \"../../internals/CloseButton/sgds-close-button\";\n\nexport type AlertVariant = \"primary\" | \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"light\";\n/**\n * @summary Alerts provide short, timely, and relevant information for your users. It can be a simple text message or customised HTML content with paragraphs, headings and links.\n *\n * @slot default - The alert's main content.\n * @slot icon - An icon to show in the alert. Pass in SVG elements.\n *\n * @event sgds-show - Emitted when the alert appears.\n * @event sgds-hide - Emitted after the alert closes.\n *\n * @cssproperty --alert-bg - The background color of alert\n * @cssproperty --alert-border-color - The color of the border of alert\n * @cssproperty --alert-icon-margin-right - The margin-right css of icon slot to position the gap between icon and alert message\n *\n */\nexport class SgdsAlert extends ScopedElementsMixin(SgdsElement) {\n static styles = [...SgdsElement.styles, alertStyle];\n /**@internal */\n static get scopedElements() {\n return {\n \"sgds-close-button\": SgdsCloseButton\n };\n }\n /** Controls the appearance of the alert */\n @property({ type: Boolean, reflect: true }) show = false;\n\n /** Enables a close button that allows the user to dismiss the alert. */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** The alert's theme variant. */\n @property({ type: String, reflect: true }) variant: AlertVariant = \"primary\";\n\n /** Closes the alert */\n public close() {\n this.show = false;\n }\n /**@internal */\n @watch(\"show\")\n _handleShowChange() {\n this.show ? this.emit(\"sgds-show\") : this.emit(\"sgds-hide\");\n }\n render() {\n return this.show\n ? html`\n <div\n class=\"${classMap({\n sgds: true,\n alert: true,\n fade: true,\n show: this.show,\n [`alert-dismissible`]: this.dismissible\n })}\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n >\n <i><slot name=\"icon\"></slot></i>\n <slot></slot>\n ${this.dismissible\n ? html`<sgds-close-button aria-label=\"close the alert\" @click=${this.close}></sgds-close-button>`\n : nothing}\n </div>\n `\n : nothing;\n }\n}\n\nexport default SgdsAlert;\n"],"names":["ScopedElementsMixin","SgdsElement","SgdsCloseButton","html","classMap","nothing","alertStyle","__decorate","property","watch"],"mappings":";;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;AAaG;MACU,SAAU,SAAQA,kCAAmB,CAACC,sBAAW,CAAC,CAAA;AAA/D,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAGrB,IAAO,CAAA,OAAA,GAAiB,SAAS,CAAC;KAkC9E;;AA9CC,IAAA,WAAW,cAAc,GAAA;QACvB,OAAO;AACL,YAAA,mBAAmB,EAAEC,+BAAe;SACrC,CAAC;KACH;;IAWM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;KACnB;;IAGD,iBAAiB,GAAA;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC7D;IACD,MAAM,GAAA;QACJ,OAAO,IAAI,CAAC,IAAI;cACZC,kBAAI,CAAA,CAAA;;AAES,mBAAA,EAAAC,oBAAQ,CAAC;AAChB,gBAAA,IAAI,EAAE,IAAI;AACV,gBAAA,KAAK,EAAE,IAAI;AACX,gBAAA,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,IAAI,CAAC,IAAI;AACf,gBAAA,CAAC,CAAmB,iBAAA,CAAA,GAAG,IAAI,CAAC,WAAW;aACxC,CAAC,CAAA;;0BAEY,IAAI,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,CAAA;;;;AAIxC,YAAA,EAAA,IAAI,CAAC,WAAW;AAChB,kBAAED,kBAAI,CAAA,0DAA0D,IAAI,CAAC,KAAK,CAAuB,qBAAA,CAAA;AACjG,kBAAEE,WAAO,CAAA;;AAEd,QAAA,CAAA;cACDA,WAAO,CAAC;KACb;;AA/CM,SAAM,CAAA,MAAA,GAAG,CAAC,GAAGJ,sBAAW,CAAC,MAAM,EAAEK,gBAAU,CAArC,CAAuC;AAQRC,gBAAA,CAAA;IAA3CC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAc,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGbD,gBAAA,CAAA;IAA3CC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAqB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGrBD,gBAAA,CAAA;IAA1CC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmC,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAQ7ED,gBAAA,CAAA;IADCE,WAAK,CAAC,MAAM,CAAC;AAGb,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,IAAA,CAAA;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { nothing } from "lit";
|
|
|
2
2
|
import SgdsElement from "../../base/sgds-element";
|
|
3
3
|
import SgdsCloseButton from "../../internals/CloseButton/sgds-close-button";
|
|
4
4
|
export type AlertVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light";
|
|
5
|
-
declare const SgdsAlert_base: typeof SgdsElement & import("@open-wc/scoped-elements/
|
|
5
|
+
declare const SgdsAlert_base: typeof SgdsElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
6
6
|
/**
|
|
7
7
|
* @summary Alerts provide short, timely, and relevant information for your users. It can be a simple text message or customised HTML content with paragraphs, headings and links.
|
|
8
8
|
*
|
|
@@ -6,7 +6,7 @@ import { html } from 'lit/static-html.js';
|
|
|
6
6
|
import SgdsElement from '../../base/sgds-element.js';
|
|
7
7
|
import { watch } from '../../utils/watch.js';
|
|
8
8
|
import css_248z from './alert.js';
|
|
9
|
-
import { ScopedElementsMixin } from '@open-wc/scoped-elements
|
|
9
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
10
10
|
import { SgdsCloseButton } from '../../internals/CloseButton/sgds-close-button.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-alert.js","sources":["../../../src/components/Alert/sgds-alert.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html } from \"lit/static-html.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { watch } from \"../../utils/watch\";\nimport alertStyle from \"./alert.css\";\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements
|
|
1
|
+
{"version":3,"file":"sgds-alert.js","sources":["../../../src/components/Alert/sgds-alert.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html } from \"lit/static-html.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { watch } from \"../../utils/watch\";\nimport alertStyle from \"./alert.css\";\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport SgdsCloseButton from \"../../internals/CloseButton/sgds-close-button\";\n\nexport type AlertVariant = \"primary\" | \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"light\";\n/**\n * @summary Alerts provide short, timely, and relevant information for your users. It can be a simple text message or customised HTML content with paragraphs, headings and links.\n *\n * @slot default - The alert's main content.\n * @slot icon - An icon to show in the alert. Pass in SVG elements.\n *\n * @event sgds-show - Emitted when the alert appears.\n * @event sgds-hide - Emitted after the alert closes.\n *\n * @cssproperty --alert-bg - The background color of alert\n * @cssproperty --alert-border-color - The color of the border of alert\n * @cssproperty --alert-icon-margin-right - The margin-right css of icon slot to position the gap between icon and alert message\n *\n */\nexport class SgdsAlert extends ScopedElementsMixin(SgdsElement) {\n static styles = [...SgdsElement.styles, alertStyle];\n /**@internal */\n static get scopedElements() {\n return {\n \"sgds-close-button\": SgdsCloseButton\n };\n }\n /** Controls the appearance of the alert */\n @property({ type: Boolean, reflect: true }) show = false;\n\n /** Enables a close button that allows the user to dismiss the alert. */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** The alert's theme variant. */\n @property({ type: String, reflect: true }) variant: AlertVariant = \"primary\";\n\n /** Closes the alert */\n public close() {\n this.show = false;\n }\n /**@internal */\n @watch(\"show\")\n _handleShowChange() {\n this.show ? this.emit(\"sgds-show\") : this.emit(\"sgds-hide\");\n }\n render() {\n return this.show\n ? html`\n <div\n class=\"${classMap({\n sgds: true,\n alert: true,\n fade: true,\n show: this.show,\n [`alert-dismissible`]: this.dismissible\n })}\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n >\n <i><slot name=\"icon\"></slot></i>\n <slot></slot>\n ${this.dismissible\n ? html`<sgds-close-button aria-label=\"close the alert\" @click=${this.close}></sgds-close-button>`\n : nothing}\n </div>\n `\n : nothing;\n }\n}\n\nexport default SgdsAlert;\n"],"names":["alertStyle"],"mappings":";;;;;;;;;;;AAWA;;;;;;;;;;;;;AAaG;MACU,SAAU,SAAQ,mBAAmB,CAAC,WAAW,CAAC,CAAA;AAA/D,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAGrB,IAAO,CAAA,OAAA,GAAiB,SAAS,CAAC;KAkC9E;;AA9CC,IAAA,WAAW,cAAc,GAAA;QACvB,OAAO;AACL,YAAA,mBAAmB,EAAE,eAAe;SACrC,CAAC;KACH;;IAWM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;KACnB;;IAGD,iBAAiB,GAAA;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC7D;IACD,MAAM,GAAA;QACJ,OAAO,IAAI,CAAC,IAAI;cACZ,IAAI,CAAA,CAAA;;AAES,mBAAA,EAAA,QAAQ,CAAC;AAChB,gBAAA,IAAI,EAAE,IAAI;AACV,gBAAA,KAAK,EAAE,IAAI;AACX,gBAAA,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,IAAI,CAAC,IAAI;AACf,gBAAA,CAAC,CAAmB,iBAAA,CAAA,GAAG,IAAI,CAAC,WAAW;aACxC,CAAC,CAAA;;0BAEY,IAAI,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,CAAA;;;;AAIxC,YAAA,EAAA,IAAI,CAAC,WAAW;AAChB,kBAAE,IAAI,CAAA,0DAA0D,IAAI,CAAC,KAAK,CAAuB,qBAAA,CAAA;AACjG,kBAAE,OAAO,CAAA;;AAEd,QAAA,CAAA;cACD,OAAO,CAAC;KACb;;AA/CM,SAAM,CAAA,MAAA,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,EAAEA,QAAU,CAArC,CAAuC;AAQR,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAc,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGb,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAqB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGrB,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmC,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAQ7E,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;AAGb,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,IAAA,CAAA;;;;"}
|
|
@@ -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
|