@spectrum-web-components/core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +7 -0
  2. package/dist/components/alert-banner/AlertBanner.base.d.ts +38 -0
  3. package/dist/components/alert-banner/AlertBanner.base.js +66 -0
  4. package/dist/components/alert-banner/AlertBanner.base.js.map +1 -0
  5. package/dist/components/alert-banner/index.d.ts +12 -0
  6. package/dist/components/alert-banner/index.js +5 -0
  7. package/dist/components/alert-banner/index.js.map +1 -0
  8. package/dist/components/asset/Asset.base.d.ts +5 -0
  9. package/dist/components/asset/Asset.base.js +22 -0
  10. package/dist/components/asset/Asset.base.js.map +1 -0
  11. package/dist/components/asset/index.d.ts +12 -0
  12. package/dist/components/asset/index.js +5 -0
  13. package/dist/components/asset/index.js.map +1 -0
  14. package/dist/components/badge/Badge.base.d.ts +84 -0
  15. package/dist/components/badge/Badge.base.js +74 -0
  16. package/dist/components/badge/Badge.base.js.map +1 -0
  17. package/dist/components/badge/Badge.types.d.ts +21 -0
  18. package/dist/components/badge/Badge.types.js +50 -0
  19. package/dist/components/badge/Badge.types.js.map +1 -0
  20. package/dist/components/badge/index.d.ts +13 -0
  21. package/dist/components/badge/index.js +12 -0
  22. package/dist/components/badge/index.js.map +1 -0
  23. package/dist/components/divider/Divider.base.d.ts +33 -0
  24. package/dist/components/divider/Divider.base.js +35 -0
  25. package/dist/components/divider/Divider.base.js.map +1 -0
  26. package/dist/components/divider/Divider.types.d.ts +4 -0
  27. package/dist/components/divider/Divider.types.js +6 -0
  28. package/dist/components/divider/Divider.types.js.map +1 -0
  29. package/dist/components/divider/index.d.ts +13 -0
  30. package/dist/components/divider/index.js +8 -0
  31. package/dist/components/divider/index.js.map +1 -0
  32. package/dist/components/progress-circle/ProgressCircle.base.d.ts +76 -0
  33. package/dist/components/progress-circle/ProgressCircle.base.js +63 -0
  34. package/dist/components/progress-circle/ProgressCircle.base.js.map +1 -0
  35. package/dist/components/progress-circle/ProgressCircle.types.d.ts +7 -0
  36. package/dist/components/progress-circle/ProgressCircle.types.js +14 -0
  37. package/dist/components/progress-circle/ProgressCircle.types.js.map +1 -0
  38. package/dist/components/progress-circle/index.d.ts +13 -0
  39. package/dist/components/progress-circle/index.js +9 -0
  40. package/dist/components/progress-circle/index.js.map +1 -0
  41. package/dist/components/status-light/StatusLight.base.d.ts +64 -0
  42. package/dist/components/status-light/StatusLight.base.js +46 -0
  43. package/dist/components/status-light/StatusLight.base.js.map +1 -0
  44. package/dist/components/status-light/StatusLight.types.d.ts +21 -0
  45. package/dist/components/status-light/StatusLight.types.js +45 -0
  46. package/dist/components/status-light/StatusLight.types.js.map +1 -0
  47. package/dist/components/status-light/index.d.ts +13 -0
  48. package/dist/components/status-light/index.js +13 -0
  49. package/dist/components/status-light/index.js.map +1 -0
  50. package/dist/node_modules/@lit-labs/observers/mutation-controller.js +30 -0
  51. package/dist/node_modules/@lit-labs/observers/mutation-controller.js.map +1 -0
  52. package/dist/shared/base/Base.d.ts +17 -0
  53. package/dist/shared/base/Base.js +144 -0
  54. package/dist/shared/base/Base.js.map +1 -0
  55. package/dist/shared/base/define-element.d.ts +16 -0
  56. package/dist/shared/base/define-element.js +11 -0
  57. package/dist/shared/base/define-element.js.map +1 -0
  58. package/dist/shared/base/index.d.ts +15 -0
  59. package/dist/shared/base/index.js +13 -0
  60. package/dist/shared/base/index.js.map +1 -0
  61. package/dist/shared/base/sizedMixin.d.ts +20 -0
  62. package/dist/shared/base/sizedMixin.js +50 -0
  63. package/dist/shared/base/sizedMixin.js.map +1 -0
  64. package/dist/shared/base/version.d.ts +1 -0
  65. package/dist/shared/base/version.js +5 -0
  66. package/dist/shared/base/version.js.map +1 -0
  67. package/dist/shared/get-label-from-slot.d.ts +12 -0
  68. package/dist/shared/get-label-from-slot.js +10 -0
  69. package/dist/shared/get-label-from-slot.js.map +1 -0
  70. package/dist/shared/observe-slot-presence.d.ts +12 -0
  71. package/dist/shared/observe-slot-presence.js +53 -0
  72. package/dist/shared/observe-slot-presence.js.map +1 -0
  73. package/dist/shared/observe-slot-text.d.ts +11 -0
  74. package/dist/shared/observe-slot-text.js +74 -0
  75. package/dist/shared/observe-slot-text.js.map +1 -0
  76. package/package.json +76 -0
@@ -0,0 +1,144 @@
1
+ import { LitElement as f } from "lit";
2
+ import { version as p } from "./version.js";
3
+ const l = /* @__PURE__ */ new Set(), _ = () => {
4
+ const i = document.documentElement.dir === "rtl" ? document.documentElement.dir : "ltr";
5
+ l.forEach((c) => {
6
+ c.setAttribute("dir", i);
7
+ });
8
+ }, E = new MutationObserver(_);
9
+ E.observe(document.documentElement, {
10
+ attributes: !0,
11
+ attributeFilter: ["dir"]
12
+ });
13
+ const b = (i) => typeof i.startManagingContentDirection < "u" || i.tagName === "SP-THEME";
14
+ function v(i) {
15
+ class c extends i {
16
+ /**
17
+ * @private
18
+ */
19
+ get isLTR() {
20
+ return this.dir === "ltr";
21
+ }
22
+ hasVisibleFocusInTree() {
23
+ const n = ((a = document) => {
24
+ let t = a.activeElement;
25
+ for (; t?.shadowRoot && t.shadowRoot.activeElement; )
26
+ t = t.shadowRoot.activeElement;
27
+ const s = t ? [t] : [];
28
+ for (; t; ) {
29
+ const o = t.assignedSlot || t.parentElement || t.getRootNode()?.host;
30
+ o && s.push(o), t = o;
31
+ }
32
+ return s;
33
+ })(
34
+ this.getRootNode()
35
+ )[0];
36
+ if (!n)
37
+ return !1;
38
+ try {
39
+ return n.matches(":focus-visible") || n.matches(".focus-visible");
40
+ } catch {
41
+ return n.matches(".focus-visible");
42
+ }
43
+ }
44
+ connectedCallback() {
45
+ if (!this.hasAttribute("dir")) {
46
+ let e = this.assignedSlot || this.parentNode;
47
+ for (; e !== document.documentElement && !b(
48
+ e
49
+ ); )
50
+ e = e.assignedSlot || // step into the shadow DOM of the parent of a slotted node
51
+ e.parentNode || // DOM Element detected
52
+ e.host;
53
+ if (this.dir = e.dir === "rtl" ? e.dir : this.dir || "ltr", e === document.documentElement)
54
+ l.add(this);
55
+ else {
56
+ const { localName: n } = e;
57
+ n.search("-") > -1 && !customElements.get(n) ? customElements.whenDefined(n).then(() => {
58
+ e.startManagingContentDirection(this);
59
+ }) : e.startManagingContentDirection(
60
+ this
61
+ );
62
+ }
63
+ this._dirParent = e;
64
+ }
65
+ super.connectedCallback();
66
+ }
67
+ disconnectedCallback() {
68
+ super.disconnectedCallback(), this._dirParent && (this._dirParent === document.documentElement ? l.delete(this) : this._dirParent.stopManagingContentDirection(
69
+ this
70
+ ), this.removeAttribute("dir"));
71
+ }
72
+ }
73
+ return c;
74
+ }
75
+ class C extends v(f) {
76
+ static {
77
+ this.VERSION = p;
78
+ }
79
+ }
80
+ if (process.env.NODE_ENV === "development") {
81
+ const i = {
82
+ default: !1,
83
+ accessibility: !1,
84
+ api: !1
85
+ }, c = {
86
+ default: !1,
87
+ low: !1,
88
+ medium: !1,
89
+ high: !1,
90
+ deprecation: !1
91
+ };
92
+ window.__swc = {
93
+ ...window.__swc,
94
+ DEBUG: !0,
95
+ ignoreWarningLocalNames: {
96
+ ...window.__swc?.ignoreWarningLocalNames || {}
97
+ },
98
+ ignoreWarningTypes: {
99
+ ...i,
100
+ ...window.__swc?.ignoreWarningTypes || {}
101
+ },
102
+ ignoreWarningLevels: {
103
+ ...c,
104
+ ...window.__swc?.ignoreWarningLevels || {}
105
+ },
106
+ issuedWarnings: /* @__PURE__ */ new Set(),
107
+ warn: (r, e, n, { type: a = "api", level: t = "default", issues: s } = {}) => {
108
+ const { localName: o = "base" } = r || {}, u = `${o}:${a}:${t}`;
109
+ if (!window.__swc.verbose && window.__swc.issuedWarnings.has(u) || window.__swc.ignoreWarningLocalNames[o] || window.__swc.ignoreWarningTypes[a] || window.__swc.ignoreWarningLevels[t])
110
+ return;
111
+ window.__swc.issuedWarnings.add(u);
112
+ let m = "";
113
+ s && s.length && (s.unshift(""), m = s.join(`
114
+ - `) + `
115
+ `);
116
+ const w = t === "deprecation" ? "DEPRECATION NOTICE: " : "", h = r ? `
117
+ Inspect this issue in the follow element:` : "", g = (r ? `
118
+
119
+ ` : `
120
+ `) + n + `
121
+ `, d = [];
122
+ d.push(
123
+ w + e + `
124
+ ` + m + h
125
+ ), r && d.push(r), d.push(g, {
126
+ data: {
127
+ localName: o,
128
+ type: a,
129
+ level: t
130
+ }
131
+ }), console.warn(...d);
132
+ }
133
+ }, window.__swc.warn(
134
+ void 0,
135
+ "Spectrum Web Components is in dev mode. Not recommended for production!",
136
+ "https://opensource.adobe.com/spectrum-web-components/dev-mode/",
137
+ { type: "default" }
138
+ );
139
+ }
140
+ export {
141
+ C as SpectrumElement,
142
+ v as SpectrumMixin
143
+ };
144
+ //# sourceMappingURL=Base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Base.js","sources":["../../../shared/base/Base.ts"],"sourcesContent":["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { LitElement, ReactiveElement } from 'lit';\n\nimport { version } from './version.js';\ntype ThemeRoot = HTMLElement & {\n startManagingContentDirection: (el: HTMLElement) => void;\n stopManagingContentDirection: (el: HTMLElement) => void;\n};\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SpectrumInterface {\n shadowRoot: ShadowRoot;\n isLTR: boolean;\n hasVisibleFocusInTree(): boolean;\n dir: 'ltr' | 'rtl';\n}\n\nconst observedForElements: Set<HTMLElement> = new Set();\n\nconst updateRTL = (): void => {\n const dir =\n document.documentElement.dir === 'rtl'\n ? document.documentElement.dir\n : 'ltr';\n observedForElements.forEach((el) => {\n el.setAttribute('dir', dir);\n });\n};\n\nconst rtlObserver = new MutationObserver(updateRTL);\n\nrtlObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['dir'],\n});\n\ntype ContentDirectionManager = HTMLElement & {\n startManagingContentDirection?(): void;\n};\n\nconst canManageContentDirection = (el: ContentDirectionManager): boolean =>\n typeof el.startManagingContentDirection !== 'undefined' ||\n el.tagName === 'SP-THEME';\n\nexport function SpectrumMixin<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<SpectrumInterface> {\n class SpectrumMixinElement extends constructor {\n /**\n * @private\n */\n public override shadowRoot!: ShadowRoot;\n private _dirParent?: HTMLElement;\n\n /**\n * @private\n */\n public override dir!: 'ltr' | 'rtl';\n\n /**\n * @private\n */\n public get isLTR(): boolean {\n return this.dir === 'ltr';\n }\n\n public hasVisibleFocusInTree(): boolean {\n const getAncestors = (root: Document = document): HTMLElement[] => {\n // eslint-disable-next-line @spectrum-web-components/document-active-element\n let currentNode = root.activeElement as HTMLElement;\n while (\n currentNode?.shadowRoot &&\n currentNode.shadowRoot.activeElement\n ) {\n currentNode = currentNode.shadowRoot\n .activeElement as HTMLElement;\n }\n const ancestors: HTMLElement[] = currentNode\n ? [currentNode]\n : [];\n while (currentNode) {\n const ancestor =\n currentNode.assignedSlot ||\n currentNode.parentElement ||\n (currentNode.getRootNode() as ShadowRoot)?.host;\n if (ancestor) {\n ancestors.push(ancestor as HTMLElement);\n }\n currentNode = ancestor as HTMLElement;\n }\n return ancestors;\n };\n const activeElement = getAncestors(\n this.getRootNode() as Document\n )[0];\n if (!activeElement) {\n return false;\n }\n // Browsers without support for the `:focus-visible`\n // selector will throw on the following test (Safari, older things).\n // Some won't throw, but will be focusing item rather than the menu and\n // will rely on the polyfill to know whether focus is \"visible\" or not.\n try {\n return (\n activeElement.matches(':focus-visible') ||\n activeElement.matches('.focus-visible')\n );\n /* c8 ignore next 3 */\n } catch (error) {\n return activeElement.matches('.focus-visible');\n }\n }\n\n public override connectedCallback(): void {\n if (!this.hasAttribute('dir')) {\n let dirParent = ((this as HTMLElement).assignedSlot ||\n this.parentNode) as HTMLElement;\n while (\n dirParent !== document.documentElement &&\n !canManageContentDirection(\n dirParent as ContentDirectionManager\n )\n ) {\n dirParent = ((dirParent as HTMLElement).assignedSlot || // step into the shadow DOM of the parent of a slotted node\n dirParent.parentNode || // DOM Element detected\n (dirParent as unknown as ShadowRoot)\n .host) as HTMLElement;\n }\n this.dir =\n dirParent.dir === 'rtl' ? dirParent.dir : this.dir || 'ltr';\n if (dirParent === document.documentElement) {\n observedForElements.add(this);\n } else {\n const { localName } = dirParent;\n if (\n localName.search('-') > -1 &&\n !customElements.get(localName)\n ) {\n /* c8 ignore next 5 */\n customElements.whenDefined(localName).then(() => {\n (\n dirParent as ThemeRoot\n ).startManagingContentDirection(this);\n });\n } else {\n (dirParent as ThemeRoot).startManagingContentDirection(\n this\n );\n }\n }\n this._dirParent = dirParent as HTMLElement;\n }\n super.connectedCallback();\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._dirParent) {\n if (this._dirParent === document.documentElement) {\n observedForElements.delete(this);\n } else {\n (this._dirParent as ThemeRoot).stopManagingContentDirection(\n this\n );\n }\n this.removeAttribute('dir');\n }\n }\n }\n return SpectrumMixinElement;\n}\n\nexport class SpectrumElement extends SpectrumMixin(LitElement) {\n static VERSION = version;\n}\n\nif (process.env.NODE_ENV === 'development') {\n const ignoreWarningTypes = {\n default: false,\n accessibility: false,\n api: false,\n };\n const ignoreWarningLevels = {\n default: false,\n low: false,\n medium: false,\n high: false,\n deprecation: false,\n };\n window.__swc = {\n ...window.__swc,\n DEBUG: true,\n ignoreWarningLocalNames: {\n ...(window.__swc?.ignoreWarningLocalNames || {}),\n },\n ignoreWarningTypes: {\n ...ignoreWarningTypes,\n ...(window.__swc?.ignoreWarningTypes || {}),\n },\n ignoreWarningLevels: {\n ...ignoreWarningLevels,\n ...(window.__swc?.ignoreWarningLevels || {}),\n },\n issuedWarnings: new Set(),\n warn: (\n element,\n message,\n url,\n { type = 'api', level = 'default', issues } = {}\n ): void => {\n const { localName = 'base' } = element || {};\n const id = `${localName}:${type}:${level}` as BrandedSWCWarningID;\n if (!window.__swc.verbose && window.__swc.issuedWarnings.has(id)) {\n return;\n }\n if (window.__swc.ignoreWarningLocalNames[localName]) {\n return;\n }\n if (window.__swc.ignoreWarningTypes[type]) {\n return;\n }\n if (window.__swc.ignoreWarningLevels[level]) {\n return;\n }\n window.__swc.issuedWarnings.add(id);\n let listedIssues = '';\n if (issues && issues.length) {\n issues.unshift('');\n listedIssues = issues.join('\\n - ') + '\\n';\n }\n const intro = level === 'deprecation' ? 'DEPRECATION NOTICE: ' : '';\n const inspectElement = element\n ? '\\nInspect this issue in the follow element:'\n : '';\n const displayURL = (element ? '\\n\\n' : '\\n') + url + '\\n';\n const messages: unknown[] = [];\n messages.push(\n intro + message + '\\n' + listedIssues + inspectElement\n );\n if (element) {\n messages.push(element);\n }\n messages.push(displayURL, {\n data: {\n localName,\n type,\n level,\n },\n });\n console.warn(...messages);\n },\n };\n\n window.__swc.warn(\n undefined,\n 'Spectrum Web Components is in dev mode. Not recommended for production!',\n 'https://opensource.adobe.com/spectrum-web-components/dev-mode/',\n { type: 'default' }\n );\n}\n"],"names":["observedForElements","updateRTL","dir","el","rtlObserver","canManageContentDirection","SpectrumMixin","constructor","SpectrumMixinElement","activeElement","root","currentNode","ancestors","ancestor","dirParent","localName","SpectrumElement","LitElement","version","ignoreWarningTypes","ignoreWarningLevels","element","message","url","type","level","issues","id","listedIssues","intro","inspectElement","displayURL","messages"],"mappings":";;AAiCA,MAAMA,wBAA4C,IAAA,GAE5CC,IAAY,MAAY;AAC1B,QAAMC,IACF,SAAS,gBAAgB,QAAQ,QAC3B,SAAS,gBAAgB,MACzB;AACV,EAAAF,EAAoB,QAAQ,CAACG,MAAO;AAChC,IAAAA,EAAG,aAAa,OAAOD,CAAG;AA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 -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ interface CustomElementConstructor {
13
+ new (...params: unknown[]): HTMLElement;
14
+ }
15
+ export declare function defineElement(name: string, constructor: CustomElementConstructor): void;
16
+ export {};
@@ -0,0 +1,11 @@
1
+ function o(e, t) {
2
+ window.__swc && window.__swc.DEBUG && customElements.get(e) && window.__swc.warn(
3
+ void 0,
4
+ `Attempted to redefine <${e}>. This usually indicates that multiple versions of the same web component were loaded onto a single page.`,
5
+ "https://opensource.adobe.com/spectrum-web-components/registry-conflicts"
6
+ ), customElements.define(e, t);
7
+ }
8
+ export {
9
+ o as defineElement
10
+ };
11
+ //# sourceMappingURL=define-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-element.js","sources":["../../../shared/base/define-element.ts"],"sourcesContent":["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ninterface CustomElementConstructor {\n new (...params: unknown[]): HTMLElement;\n}\n\nexport function defineElement(\n name: string,\n constructor: CustomElementConstructor\n): void {\n if (window.__swc && window.__swc.DEBUG) {\n if (customElements.get(name)) {\n window.__swc.warn(\n undefined,\n `Attempted to redefine <${name}>. This usually indicates that multiple versions of the same web component were loaded onto a single page.`,\n 'https://opensource.adobe.com/spectrum-web-components/registry-conflicts'\n );\n }\n }\n customElements.define(name, constructor);\n}\n"],"names":["defineElement","name","constructor"],"mappings":"AAgBO,SAASA,EACZC,GACAC,GACI;AACJ,EAAI,OAAO,SAAS,OAAO,MAAM,SACzB,eAAe,IAAID,CAAI,KACvB,OAAO,MAAM;AAAA,IACT;AAAA,IACA,0BAA0BA,CAAI;AAAA,IAC9B;AAAA,EAAA,GAIZ,eAAe,OAAOA,GAAMC,CAAW;AAC3C;"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ export { SpectrumElement, SpectrumMixin, type SpectrumInterface, } from './Base.js';
13
+ export { SizedMixin, type ElementSize, ElementSizes, type DefaultElementSize, type SizedElementInterface, } from './sizedMixin.js';
14
+ export { defineElement } from './define-element.js';
15
+ export { version } from './version.js';
@@ -0,0 +1,13 @@
1
+ import { SpectrumElement as m, SpectrumMixin as o } from "./Base.js";
2
+ import { ElementSizes as i, SizedMixin as n } from "./sizedMixin.js";
3
+ import { defineElement as x } from "./define-element.js";
4
+ import { version as S } from "./version.js";
5
+ export {
6
+ i as ElementSizes,
7
+ n as SizedMixin,
8
+ m as SpectrumElement,
9
+ o as SpectrumMixin,
10
+ x as defineElement,
11
+ S as version
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,20 @@
1
+ import { ReactiveElement } from 'lit';
2
+ type Constructor<T = Record<string, unknown>> = {
3
+ new (...args: any[]): T;
4
+ prototype: T;
5
+ };
6
+ export type ElementSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
7
+ export declare const ElementSizes: Record<string, ElementSize>;
8
+ export type DefaultElementSize = Exclude<ElementSize, 'xxs' | 'xs' | 'xxl'>;
9
+ export interface SizedElementInterface {
10
+ size: ElementSize;
11
+ }
12
+ export interface SizedElementConstructor {
13
+ readonly VALID_SIZES: ElementSize[];
14
+ }
15
+ export declare function SizedMixin<T extends Constructor<ReactiveElement>>(constructor: T, { validSizes, noDefaultSize, defaultSize, }?: {
16
+ validSizes?: ElementSize[];
17
+ noDefaultSize?: boolean;
18
+ defaultSize?: ElementSize;
19
+ }): T & Constructor<SizedElementInterface> & SizedElementConstructor;
20
+ export {};
@@ -0,0 +1,50 @@
1
+ import { property as z } from "lit/decorators.js";
2
+ var h = Object.defineProperty, u = Object.getOwnPropertyDescriptor, _ = (r, e, i, n) => {
3
+ for (var s = u(e, i), o = r.length - 1, t; o >= 0; o--)
4
+ (t = r[o]) && (s = t(e, i, s) || s);
5
+ return s && h(e, i, s), s;
6
+ };
7
+ const m = {
8
+ xxs: "xxs",
9
+ xs: "xs",
10
+ s: "s",
11
+ m: "m",
12
+ l: "l",
13
+ xl: "xl",
14
+ xxl: "xxl"
15
+ };
16
+ function d(r, {
17
+ validSizes: e = ["s", "m", "l", "xl"],
18
+ noDefaultSize: i,
19
+ defaultSize: n = "m"
20
+ } = {}) {
21
+ class s extends r {
22
+ constructor() {
23
+ super(...arguments), this._size = n;
24
+ }
25
+ static {
26
+ this.VALID_SIZES = e;
27
+ }
28
+ get size() {
29
+ return this._size || n;
30
+ }
31
+ set size(t) {
32
+ const l = i ? null : n, c = t && t.toLocaleLowerCase(), p = e.includes(c) ? c : l;
33
+ if (p && this.setAttribute("size", p), this._size === p)
34
+ return;
35
+ const x = this._size;
36
+ this._size = p, this.requestUpdate("size", x);
37
+ }
38
+ update(t) {
39
+ !this.hasAttribute("size") && !i && this.setAttribute("size", this.size), super.update(t);
40
+ }
41
+ }
42
+ return _([
43
+ z({ type: String })
44
+ ], s.prototype, "size"), s;
45
+ }
46
+ export {
47
+ m as ElementSizes,
48
+ d as SizedMixin
49
+ };
50
+ //# sourceMappingURL=sizedMixin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sizedMixin.js","sources":["../../../shared/base/sizedMixin.ts"],"sourcesContent":["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { PropertyValues, ReactiveElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport type ElementSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';\nexport const ElementSizes: Record<string, ElementSize> = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n};\nexport type DefaultElementSize = Exclude<ElementSize, 'xxs' | 'xs' | 'xxl'>;\n\nexport interface SizedElementInterface {\n size: ElementSize;\n}\n\nexport interface SizedElementConstructor {\n readonly VALID_SIZES: ElementSize[];\n}\n\nexport function SizedMixin<T extends Constructor<ReactiveElement>>(\n constructor: T,\n {\n validSizes = ['s', 'm', 'l', 'xl'],\n noDefaultSize,\n defaultSize = 'm',\n }: {\n validSizes?: ElementSize[];\n noDefaultSize?: boolean;\n defaultSize?: ElementSize;\n } = {}\n): T & Constructor<SizedElementInterface> & SizedElementConstructor {\n class SizedElement extends constructor {\n /**\n * @internal\n */\n static readonly VALID_SIZES: ElementSize[] = validSizes;\n\n @property({ type: String })\n public get size(): ElementSize {\n return this._size || defaultSize;\n }\n\n public set size(value: ElementSize) {\n const fallbackSize = noDefaultSize ? null : defaultSize;\n const size = (\n value ? value.toLocaleLowerCase() : value\n ) as ElementSize;\n const validSize = (\n validSizes.includes(size) ? size : fallbackSize\n ) as ElementSize;\n if (validSize) {\n this.setAttribute('size', validSize);\n }\n if (this._size === validSize) {\n return;\n }\n const oldSize = this._size;\n this._size = validSize;\n this.requestUpdate('size', oldSize);\n }\n\n private _size: ElementSize | null = defaultSize;\n\n protected override update(changes: PropertyValues): void {\n if (!this.hasAttribute('size') && !noDefaultSize) {\n this.setAttribute('size', this.size);\n }\n super.update(changes);\n }\n }\n return SizedElement;\n}\n"],"names":["ElementSizes","SizedMixin","constructor","validSizes","noDefaultSize","defaultSize","SizedElement","value","fallbackSize","size","validSize","oldSize","changes","__decorateClass","property"],"mappings":";;;;;;AAqBO,MAAMA,IAA4C;AAAA,EACrD,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,KAAK;AACT;AAWO,SAASC,EACZC,GACA;AAAA,EACI,YAAAC,IAAa,CAAC,KAAK,KAAK,KAAK,IAAI;AAAA,EACjC,eAAAC;AAAA,EACA,aAAAC,IAAc;AAClB,IAII,IAC4D;AAAA,EAChE,MAAMC,UAAqBJ,EAAY;AAAA,IAAvC,cAAA;AAAA,YAAA,GAAA,SAAA,GA8BI,KAAQ,QAA4BG;AAAA,IAAA;AAAA,IA1BpC,OAAA;AAAA,WAAgB,cAA6BF;AAAA,IAAA;AAAA,IAG7C,IAAW,OAAoB;AAC3B,aAAO,KAAK,SAASE;AAAA,IACzB;AAAA,IAEA,IAAW,KAAKE,GAAoB;AAChC,YAAMC,IAAeJ,IAAgB,OAAOC,GACtCI,IACFF,KAAQA,EAAM,kBAAA,GAEZG,IACFP,EAAW,SAASM,CAAI,IAAIA,IAAOD;AAKvC,UAHIE,KACA,KAAK,aAAa,QAAQA,CAAS,GAEnC,KAAK,UAAUA;AACf;AAEJ,YAAMC,IAAU,KAAK;AACrB,WAAK,QAAQD,GACb,KAAK,cAAc,QAAQC,CAAO;AAAA,IACtC;AAAA,IAImB,OAAOC,GAA+B;AACrD,MAAI,CAAC,KAAK,aAAa,MAAM,KAAK,CAACR,KAC/B,KAAK,aAAa,QAAQ,KAAK,IAAI,GAEvC,MAAM,OAAOQ,CAAO;AAAA,IACxB;AAAA,EAAA;AA9BW,SAAAC,EAAA;AAAA,IADVC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,EAAA,GANxBR,EAOS,WAAA,MAAA,GAgCRA;AACX;"}
@@ -0,0 +1 @@
1
+ export declare const version = "1.10.0";
@@ -0,0 +1,5 @@
1
+ const o = "1.10.0";
2
+ export {
3
+ o as version
4
+ };
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sources":["../../../shared/base/version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '1.10.0';\n"],"names":["version"],"mappings":"AACO,MAAMA,IAAU;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ export declare const getLabelFromSlot: (label: string, slotEl: HTMLSlotElement) => string | null;
@@ -0,0 +1,10 @@
1
+ const o = (r, l) => {
2
+ if (r)
3
+ return null;
4
+ const t = l.assignedNodes().reduce((e, n) => n.textContent ? e + n.textContent : e, "");
5
+ return t ? t.trim() : null;
6
+ };
7
+ export {
8
+ o as getLabelFromSlot
9
+ };
10
+ //# sourceMappingURL=get-label-from-slot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-label-from-slot.js","sources":["../../shared/get-label-from-slot.ts"],"sourcesContent":["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) {\n return null;\n }\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],"names":["getLabelFromSlot","label","slotEl","textContent","accumulator","node"],"mappings":"AAYO,MAAMA,IAAmB,CAC5BC,GACAC,MACgB;AAChB,MAAID;AACA,WAAO;AAEX,QAAME,IAAcD,EACf,cAAA,EACA,OAAO,CAACE,GAAqBC,MACtBA,EAAK,cACED,IAAcC,EAAK,cAEnBD,GAEZ,EAAE;AACT,SAAID,IACOA,EAAY,KAAA,IAEZ;AAEf;"}
@@ -0,0 +1,12 @@
1
+ import { ReactiveElement } from 'lit';
2
+ type Constructor<T = Record<string, unknown>> = {
3
+ new (...args: any[]): T;
4
+ prototype: T;
5
+ };
6
+ export interface SlotPresenceObservingInterface {
7
+ slotContentIsPresent: boolean;
8
+ getSlotContentPresence(selector: string): boolean;
9
+ managePresenceObservedSlot(): void;
10
+ }
11
+ export declare function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(constructor: T, lightDomSelector: string | string[]): T & Constructor<SlotPresenceObservingInterface>;
12
+ export {};
@@ -0,0 +1,53 @@
1
+ import { MutationController as g } from "../node_modules/@lit-labs/observers/mutation-controller.js";
2
+ const e = Symbol("slotContentIsPresent");
3
+ function b(a, r) {
4
+ var i, l;
5
+ const n = Array.isArray(r) ? r : [r];
6
+ class c extends (l = a, i = e, l) {
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ constructor(...t) {
9
+ super(t), this[i] = /* @__PURE__ */ new Map(), this.managePresenceObservedSlot = () => {
10
+ let o = !1;
11
+ n.forEach((s) => {
12
+ const h = !!this.querySelector(`:scope > ${s}`), u = this[e].get(s) || !1;
13
+ o = o || u !== h, this[e].set(
14
+ s,
15
+ !!this.querySelector(`:scope > ${s}`)
16
+ );
17
+ }), o && this.updateComplete.then(() => {
18
+ this.requestUpdate();
19
+ });
20
+ }, new g(this, {
21
+ config: {
22
+ childList: !0,
23
+ subtree: !0
24
+ },
25
+ callback: () => {
26
+ this.managePresenceObservedSlot();
27
+ }
28
+ }), this.managePresenceObservedSlot();
29
+ }
30
+ /**
31
+ * @private
32
+ */
33
+ get slotContentIsPresent() {
34
+ if (n.length === 1)
35
+ return this[e].get(n[0]) || !1;
36
+ throw new Error(
37
+ "Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead."
38
+ );
39
+ }
40
+ getSlotContentPresence(t) {
41
+ if (this[e].has(t))
42
+ return this[e].get(t) || !1;
43
+ throw new Error(
44
+ `The provided selector \`${t}\` is not being observed.`
45
+ );
46
+ }
47
+ }
48
+ return c;
49
+ }
50
+ export {
51
+ b as ObserveSlotPresence
52
+ };
53
+ //# sourceMappingURL=observe-slot-presence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-slot-presence.js","sources":["../../shared/observe-slot-presence.ts"],"sourcesContent":["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { ReactiveElement } from 'lit';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`:scope > ${selector}`);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(`:scope > ${selector}`)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n };\n }\n return SlotPresenceObservingElement;\n}\n"],"names":["slotContentIsPresent","ObserveSlotPresence","constructor","lightDomSelector","_a","_b","lightDomSelectors","SlotPresenceObservingElement","args","changes","selector","nextValue","previousValue","MutationController"],"mappings":";AAcA,MAAMA,IAAuB,OAAO,sBAAsB;AAcnD,SAASC,EACZC,GACAC,GAC+C;AA/BnD,MAAAC,GAAAC;AAgCI,QAAMC,IAAoB,MAAM,QAAQH,CAAgB,IAClDA,IACA,CAACA,CAAgB;AAAA,EACvB,MAAMI,WACMF,IAAAH,GAmCCE,IAAAJ,GAnCDK,GAEZ;AAAA;AAAA,IAEI,eAAeG,GAAa;AACxB,YAAMA,CAAI,GA8Bd,KAASJ,CAAA,wBAAkD,IAAA,GAW3D,KAAO,6BAA6B,MAAY;AAC5C,YAAIK,IAAU;AACd,QAAAH,EAAkB,QAAQ,CAACI,MAAa;AACpC,gBAAMC,IAAY,CAAC,CAAC,KAAK,cAAc,YAAYD,CAAQ,EAAE,GACvDE,IACF,KAAKZ,CAAoB,EAAE,IAAIU,CAAQ,KAAK;AAChD,UAAAD,IAAUA,KAAWG,MAAkBD,GACvC,KAAKX,CAAoB,EAAE;AAAA,YACvBU;AAAA,YACA,CAAC,CAAC,KAAK,cAAc,YAAYA,CAAQ,EAAE;AAAA,UAAA;AAAA,QAEnD,CAAC,GACGD,KACA,KAAK,eAAe,KAAK,MAAM;AAC3B,eAAK,cAAA;AAAA,QACT,CAAC;AAAA,MAET,GAxDI,IAAII,EAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,WAAW;AAAA,UACX,SAAS;AAAA,QAAA;AAAA,QAEb,UAAU,MAAM;AACZ,eAAK,2BAAA;AAAA,QACT;AAAA,MAAA,CACH,GAED,KAAK,2BAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAW,uBAAgC;AACvC,UAAIP,EAAkB,WAAW;AAC7B,eACI,KAAKN,CAAoB,EAAE,IAAIM,EAAkB,CAAC,CAAC,KACnD;AAGJ,YAAM,IAAI;AAAA,QACN;AAAA,MAAA;AAAA,IAGZ;AAAA,IAGO,uBAAuBI,GAA2B;AACrD,UAAI,KAAKV,CAAoB,EAAE,IAAIU,CAAQ;AACvC,eAAO,KAAKV,CAAoB,EAAE,IAAIU,CAAQ,KAAK;AAEvD,YAAM,IAAI;AAAA,QACN,2BAA2BA,CAAQ;AAAA,MAAA;AAAA,IAE3C;AAAA,EAAA;AAqBJ,SAAOH;AACX;"}
@@ -0,0 +1,11 @@
1
+ import { ReactiveElement } from 'lit';
2
+ type Constructor<T = Record<string, unknown>> = {
3
+ new (...args: any[]): T;
4
+ prototype: T;
5
+ };
6
+ export interface SlotTextObservingInterface {
7
+ slotHasContent: boolean;
8
+ manageTextObservedSlot(): void;
9
+ }
10
+ export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string, excludedSelectors?: string[]): T & Constructor<SlotTextObservingInterface>;
11
+ export {};
@@ -0,0 +1,74 @@
1
+ import { property as m, queryAssignedNodes as g } from "lit/decorators.js";
2
+ import { MutationController as x } from "../node_modules/@lit-labs/observers/mutation-controller.js";
3
+ var b = Object.defineProperty, p = (d, n, i, u) => {
4
+ for (var t = void 0, r = d.length - 1, o; r >= 0; r--)
5
+ (o = d[r]) && (t = o(n, i, t) || t);
6
+ return t && b(n, i, t), t;
7
+ };
8
+ const f = Symbol("assignedNodes");
9
+ function N(d, n, i = []) {
10
+ var u, t;
11
+ const r = (c) => (e) => c.matches(e);
12
+ class o extends (t = d, u = f, t) {
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ constructor(...e) {
15
+ super(e), this.slotHasContent = !1, new x(this, {
16
+ config: {
17
+ characterData: !0,
18
+ subtree: !0
19
+ },
20
+ callback: (l) => {
21
+ for (const s of l)
22
+ if (s.type === "characterData") {
23
+ this.manageTextObservedSlot();
24
+ return;
25
+ }
26
+ }
27
+ });
28
+ }
29
+ manageTextObservedSlot() {
30
+ if (!this[f])
31
+ return;
32
+ const e = [...this[f]].filter(
33
+ (l) => {
34
+ const s = l;
35
+ return s.tagName ? !i.some(r(s)) : s.textContent ? s.textContent.trim() : !1;
36
+ }
37
+ );
38
+ this.slotHasContent = e.length > 0;
39
+ }
40
+ update(e) {
41
+ if (!this.hasUpdated) {
42
+ const { childNodes: l } = this, s = [...l].filter((h) => {
43
+ const a = h;
44
+ return a.tagName ? i.some(
45
+ r(a)
46
+ ) ? !1 : (
47
+ // This pass happens at element upgrade and before slot rendering.
48
+ // Confirm it would exisit in a targeted slot if there was one supplied.
49
+ n ? a.getAttribute("slot") === n : !a.hasAttribute("slot")
50
+ ) : a.textContent ? a.textContent.trim() : !1;
51
+ });
52
+ this.slotHasContent = s.length > 0;
53
+ }
54
+ super.update(e);
55
+ }
56
+ firstUpdated(e) {
57
+ super.firstUpdated(e), this.updateComplete.then(() => {
58
+ this.manageTextObservedSlot();
59
+ });
60
+ }
61
+ }
62
+ return p([
63
+ m({ type: Boolean, attribute: !1 })
64
+ ], o.prototype, "slotHasContent"), p([
65
+ g({
66
+ slot: n,
67
+ flatten: !0
68
+ })
69
+ ], o.prototype, u), o;
70
+ }
71
+ export {
72
+ N as ObserveSlotText
73
+ };
74
+ //# sourceMappingURL=observe-slot-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-slot-text.js","sources":["../../shared/observe-slot-text.ts"],"sourcesContent":["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { PropertyValues, ReactiveElement } from 'lit';\nimport { property, queryAssignedNodes } from 'lit/decorators.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst assignedNodesList = Symbol('assignedNodes');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotTextObservingInterface {\n slotHasContent: boolean;\n manageTextObservedSlot(): void;\n}\n\nexport function ObserveSlotText<T extends Constructor<ReactiveElement>>(\n constructor: T,\n slotName?: string,\n excludedSelectors: string[] = []\n): T & Constructor<SlotTextObservingInterface> {\n const notExcluded = (el: HTMLElement) => (selector: string) => {\n return el.matches(selector);\n };\n\n class SlotTextObservingElement\n extends constructor\n implements SlotTextObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n characterData: true,\n subtree: true,\n },\n callback: (mutationsList: Array<MutationRecord>) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'characterData') {\n this.manageTextObservedSlot();\n return;\n }\n }\n },\n });\n }\n\n @property({ type: Boolean, attribute: false })\n public slotHasContent = false;\n\n @queryAssignedNodes({\n slot: slotName,\n flatten: true,\n })\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) {\n return;\n }\n const assignedNodes = [...this[assignedNodesList]].filter(\n (currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n return !excludedSelectors.some(notExcluded(node));\n }\n return node.textContent ? node.textContent.trim() : false;\n }\n );\n this.slotHasContent = assignedNodes.length > 0;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (!this.hasUpdated) {\n const { childNodes } = this;\n const textNodes = [...childNodes].filter((currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n const excluded = excludedSelectors.some(\n notExcluded(node)\n );\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exisit in a targeted slot if there was one supplied.\n slotName\n ? node.getAttribute('slot') === slotName\n : !node.hasAttribute('slot')\n : false;\n }\n return node.textContent ? node.textContent.trim() : false;\n });\n this.slotHasContent = textNodes.length > 0;\n }\n super.update(changedProperties);\n }\n\n protected override firstUpdated(\n changedProperties: PropertyValues\n ): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],"names":["assignedNodesList","ObserveSlotText","constructor","slotName","excludedSelectors","_a","_b","notExcluded","el","selector","SlotTextObservingElement","args","MutationController","mutationsList","mutation","assignedNodes","currentNode","node","changedProperties","childNodes","textNodes","__decorateClass","property","queryAssignedNodes"],"mappings":";;;;;;;AAeA,MAAMA,IAAoB,OAAO,eAAe;AAazC,SAASC,EACZC,GACAC,GACAC,IAA8B,CAAA,GACa;AAhC/C,MAAAC,GAAAC;AAiCI,QAAMC,IAAc,CAACC,MAAoB,CAACC,MAC/BD,EAAG,QAAQC,CAAQ;AAAA,EAG9B,MAAMC,WACMJ,IAAAJ,GA8BCG,IAAAL,GA9BDM,GAEZ;AAAA;AAAA,IAEI,eAAeK,GAAa;AACxB,YAAMA,CAAI,GAmBd,KAAO,iBAAiB,IAjBpB,IAAIC,EAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,eAAe;AAAA,UACf,SAAS;AAAA,QAAA;AAAA,QAEb,UAAU,CAACC,MAAyC;AAChD,q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mB;AAAA,MAChB,MAAMpB;AAAA,MACN,SAAS;AAAA,IAAA,CACZ;AAAA,EAAA,GA9BCO,EA+BO,WAAAL,CAAA,GAmDNK;AACX;"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@spectrum-web-components/core",
3
+ "version": "0.0.1",
4
+ "description": "Abstract base classes for Spectrum Web Components",
5
+ "license": "Apache-2.0",
6
+ "author": "Adobe",
7
+ "homepage": "https://opensource.adobe.com/spectrum-web-components/",
8
+ "repository": {
9
+ "directory": "2nd-gen/packages/core",
10
+ "type": "git",
11
+ "url": "https://github.com/adobe/spectrum-web-components.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/adobe/spectrum-web-components/issues"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./components/*": {
23
+ "types": "./dist/components/*/index.d.ts",
24
+ "import": "./dist/components/*/index.js"
25
+ },
26
+ "./shared/*": {
27
+ "types": "./dist/shared/*/index.d.ts",
28
+ "import": "./dist/shared/*/index.js"
29
+ },
30
+ "./shared/*.js": {
31
+ "types": "./dist/shared/*.d.ts",
32
+ "import": "./dist/shared/*.js"
33
+ },
34
+ "./shared/base/*.js": {
35
+ "types": "./dist/shared/base/*.d.ts",
36
+ "import": "./dist/shared/base/*.js"
37
+ }
38
+ },
39
+ "main": "./dist/index.js",
40
+ "module": "./dist/index.js",
41
+ "files": [
42
+ "dist/"
43
+ ],
44
+ "scripts": {
45
+ "build": "vite build",
46
+ "clean": "rimraf dist",
47
+ "dev": "vite build --watch",
48
+ "prepublishOnly": "yarn build"
49
+ },
50
+ "types": "./dist/index.d.ts",
51
+ "dependencies": {
52
+ "lit": "^2.5.0 || ^3.1.3"
53
+ },
54
+ "devDependencies": {
55
+ "glob": "11.0.3",
56
+ "rimraf": "6.0.1",
57
+ "typescript": "5.9.2",
58
+ "vite": "7.1.7",
59
+ "vite-plugin-dts": "4.5.4"
60
+ },
61
+ "keywords": [
62
+ "design-system",
63
+ "spectrum",
64
+ "adobe",
65
+ "adobe-spectrum",
66
+ "web components",
67
+ "web-components",
68
+ "lit-element",
69
+ "lit-html",
70
+ "component",
71
+ "css"
72
+ ],
73
+ "publishConfig": {
74
+ "access": "public"
75
+ }
76
+ }