@spectrum-web-components/base 1.9.1 → 1.10.0
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/package.json +3 -2
- package/src/Base.d.ts +1 -17
- package/src/Base.dev.js +1 -172
- package/src/Base.dev.js.map +3 -3
- package/src/Base.js +1 -1
- package/src/Base.js.map +3 -3
- package/src/define-element.d.ts +1 -5
- package/src/define-element.dev.js +1 -12
- package/src/define-element.dev.js.map +2 -2
- package/src/define-element.js +1 -1
- package/src/define-element.js.map +3 -3
- package/src/sizedMixin.d.ts +1 -17
- package/src/sizedMixin.dev.js +1 -59
- package/src/sizedMixin.dev.js.map +2 -2
- package/src/sizedMixin.js +1 -1
- package/src/sizedMixin.js.map +3 -3
- package/src/version.js +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/adobe/spectrum-web-components.git",
|
|
12
|
-
"directory": "tools/base"
|
|
12
|
+
"directory": "1st-gen/tools/base"
|
|
13
13
|
},
|
|
14
14
|
"author": "Adobe",
|
|
15
15
|
"homepage": "https://opensource.adobe.com/spectrum-web-components/tools/base",
|
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
"css"
|
|
120
120
|
],
|
|
121
121
|
"dependencies": {
|
|
122
|
+
"@spectrum-web-components/core": "0.0.1",
|
|
122
123
|
"lit": "^2.5.0 || ^3.1.3"
|
|
123
124
|
},
|
|
124
125
|
"types": "./src/index.d.ts",
|
package/src/Base.d.ts
CHANGED
|
@@ -9,20 +9,4 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
type Constructor<T = Record<string, unknown>> = {
|
|
14
|
-
new (...args: any[]): T;
|
|
15
|
-
prototype: T;
|
|
16
|
-
};
|
|
17
|
-
export interface SpectrumInterface {
|
|
18
|
-
shadowRoot: ShadowRoot;
|
|
19
|
-
isLTR: boolean;
|
|
20
|
-
hasVisibleFocusInTree(): boolean;
|
|
21
|
-
dir: 'ltr' | 'rtl';
|
|
22
|
-
}
|
|
23
|
-
export declare function SpectrumMixin<T extends Constructor<ReactiveElement>>(constructor: T): T & Constructor<SpectrumInterface>;
|
|
24
|
-
declare const SpectrumElement_base: typeof LitElement & Constructor<SpectrumInterface>;
|
|
25
|
-
export declare class SpectrumElement extends SpectrumElement_base {
|
|
26
|
-
static VERSION: string;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
12
|
+
export * from '@spectrum-web-components/core/shared/base/Base.js';
|
package/src/Base.dev.js
CHANGED
|
@@ -1,174 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
import { version } from "@spectrum-web-components/base/src/version.js";
|
|
4
|
-
import { LitElement } from "lit";
|
|
5
|
-
const observedForElements = /* @__PURE__ */ new Set();
|
|
6
|
-
const updateRTL = () => {
|
|
7
|
-
const dir = document.documentElement.dir === "rtl" ? document.documentElement.dir : "ltr";
|
|
8
|
-
observedForElements.forEach((el) => {
|
|
9
|
-
el.setAttribute("dir", dir);
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
const rtlObserver = new MutationObserver(updateRTL);
|
|
13
|
-
rtlObserver.observe(document.documentElement, {
|
|
14
|
-
attributes: true,
|
|
15
|
-
attributeFilter: ["dir"]
|
|
16
|
-
});
|
|
17
|
-
const canManageContentDirection = (el) => typeof el.startManagingContentDirection !== "undefined" || el.tagName === "SP-THEME";
|
|
18
|
-
export function SpectrumMixin(constructor) {
|
|
19
|
-
class SpectrumMixinElement extends constructor {
|
|
20
|
-
/**
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
get isLTR() {
|
|
24
|
-
return this.dir === "ltr";
|
|
25
|
-
}
|
|
26
|
-
hasVisibleFocusInTree() {
|
|
27
|
-
const getAncestors = (root = document) => {
|
|
28
|
-
var _a2;
|
|
29
|
-
let currentNode = root.activeElement;
|
|
30
|
-
while ((currentNode == null ? void 0 : currentNode.shadowRoot) && currentNode.shadowRoot.activeElement) {
|
|
31
|
-
currentNode = currentNode.shadowRoot.activeElement;
|
|
32
|
-
}
|
|
33
|
-
const ancestors = currentNode ? [currentNode] : [];
|
|
34
|
-
while (currentNode) {
|
|
35
|
-
const ancestor = currentNode.assignedSlot || currentNode.parentElement || ((_a2 = currentNode.getRootNode()) == null ? void 0 : _a2.host);
|
|
36
|
-
if (ancestor) {
|
|
37
|
-
ancestors.push(ancestor);
|
|
38
|
-
}
|
|
39
|
-
currentNode = ancestor;
|
|
40
|
-
}
|
|
41
|
-
return ancestors;
|
|
42
|
-
};
|
|
43
|
-
const activeElement = getAncestors(
|
|
44
|
-
this.getRootNode()
|
|
45
|
-
)[0];
|
|
46
|
-
if (!activeElement) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
return activeElement.matches(":focus-visible") || activeElement.matches(".focus-visible");
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return activeElement.matches(".focus-visible");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
connectedCallback() {
|
|
56
|
-
if (!this.hasAttribute("dir")) {
|
|
57
|
-
let dirParent = this.assignedSlot || this.parentNode;
|
|
58
|
-
while (dirParent !== document.documentElement && !canManageContentDirection(
|
|
59
|
-
dirParent
|
|
60
|
-
)) {
|
|
61
|
-
dirParent = dirParent.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
62
|
-
dirParent.parentNode || // DOM Element detected
|
|
63
|
-
dirParent.host;
|
|
64
|
-
}
|
|
65
|
-
this.dir = dirParent.dir === "rtl" ? dirParent.dir : this.dir || "ltr";
|
|
66
|
-
if (dirParent === document.documentElement) {
|
|
67
|
-
observedForElements.add(this);
|
|
68
|
-
} else {
|
|
69
|
-
const { localName } = dirParent;
|
|
70
|
-
if (localName.search("-") > -1 && !customElements.get(localName)) {
|
|
71
|
-
customElements.whenDefined(localName).then(() => {
|
|
72
|
-
dirParent.startManagingContentDirection(this);
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
dirParent.startManagingContentDirection(
|
|
76
|
-
this
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
this._dirParent = dirParent;
|
|
81
|
-
}
|
|
82
|
-
super.connectedCallback();
|
|
83
|
-
}
|
|
84
|
-
disconnectedCallback() {
|
|
85
|
-
super.disconnectedCallback();
|
|
86
|
-
if (this._dirParent) {
|
|
87
|
-
if (this._dirParent === document.documentElement) {
|
|
88
|
-
observedForElements.delete(this);
|
|
89
|
-
} else {
|
|
90
|
-
this._dirParent.stopManagingContentDirection(
|
|
91
|
-
this
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
this.removeAttribute("dir");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return SpectrumMixinElement;
|
|
99
|
-
}
|
|
100
|
-
export class SpectrumElement extends SpectrumMixin(LitElement) {
|
|
101
|
-
}
|
|
102
|
-
SpectrumElement.VERSION = version;
|
|
103
|
-
if (true) {
|
|
104
|
-
const ignoreWarningTypes = {
|
|
105
|
-
default: false,
|
|
106
|
-
accessibility: false,
|
|
107
|
-
api: false
|
|
108
|
-
};
|
|
109
|
-
const ignoreWarningLevels = {
|
|
110
|
-
default: false,
|
|
111
|
-
low: false,
|
|
112
|
-
medium: false,
|
|
113
|
-
high: false,
|
|
114
|
-
deprecation: false
|
|
115
|
-
};
|
|
116
|
-
window.__swc = {
|
|
117
|
-
...window.__swc,
|
|
118
|
-
ignoreWarningLocalNames: {
|
|
119
|
-
/* c8 ignore next 1 */
|
|
120
|
-
...((_a = window.__swc) == null ? void 0 : _a.ignoreWarningLocalNames) || {}
|
|
121
|
-
},
|
|
122
|
-
ignoreWarningTypes: {
|
|
123
|
-
...ignoreWarningTypes,
|
|
124
|
-
/* c8 ignore next 1 */
|
|
125
|
-
...((_b = window.__swc) == null ? void 0 : _b.ignoreWarningTypes) || {}
|
|
126
|
-
},
|
|
127
|
-
ignoreWarningLevels: {
|
|
128
|
-
...ignoreWarningLevels,
|
|
129
|
-
/* c8 ignore next 1 */
|
|
130
|
-
...((_c = window.__swc) == null ? void 0 : _c.ignoreWarningLevels) || {}
|
|
131
|
-
},
|
|
132
|
-
issuedWarnings: /* @__PURE__ */ new Set(),
|
|
133
|
-
warn: (element, message, url, { type = "api", level = "default", issues } = {}) => {
|
|
134
|
-
const { localName = "base" } = element || {};
|
|
135
|
-
const id = `${localName}:${type}:${level}`;
|
|
136
|
-
if (!window.__swc.verbose && window.__swc.issuedWarnings.has(id))
|
|
137
|
-
return;
|
|
138
|
-
if (window.__swc.ignoreWarningLocalNames[localName]) return;
|
|
139
|
-
if (window.__swc.ignoreWarningTypes[type]) return;
|
|
140
|
-
if (window.__swc.ignoreWarningLevels[level]) return;
|
|
141
|
-
window.__swc.issuedWarnings.add(id);
|
|
142
|
-
let listedIssues = "";
|
|
143
|
-
if (issues && issues.length) {
|
|
144
|
-
issues.unshift("");
|
|
145
|
-
listedIssues = issues.join("\n - ") + "\n";
|
|
146
|
-
}
|
|
147
|
-
const intro = level === "deprecation" ? "DEPRECATION NOTICE: " : "";
|
|
148
|
-
const inspectElement = element ? "\nInspect this issue in the follow element:" : "";
|
|
149
|
-
const displayURL = (element ? "\n\n" : "\n") + url + "\n";
|
|
150
|
-
const messages = [];
|
|
151
|
-
messages.push(
|
|
152
|
-
intro + message + "\n" + listedIssues + inspectElement
|
|
153
|
-
);
|
|
154
|
-
if (element) {
|
|
155
|
-
messages.push(element);
|
|
156
|
-
}
|
|
157
|
-
messages.push(displayURL, {
|
|
158
|
-
data: {
|
|
159
|
-
localName,
|
|
160
|
-
type,
|
|
161
|
-
level
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
console.warn(...messages);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
window.__swc.warn(
|
|
168
|
-
void 0,
|
|
169
|
-
"Spectrum Web Components is in dev mode. Not recommended for production!",
|
|
170
|
-
"https://opensource.adobe.com/spectrum-web-components/dev-mode/",
|
|
171
|
-
{ type: "default" }
|
|
172
|
-
);
|
|
173
|
-
}
|
|
2
|
+
export * from "@spectrum-web-components/core/shared/base/Base.js";
|
|
174
3
|
//# sourceMappingURL=Base.dev.js.map
|
package/src/Base.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Base.ts"],
|
|
4
|
-
"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 { version } from '@spectrum-web-components/base/src/version.js';\nimport { LitElement, ReactiveElement } from 'lit';\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 (window.__swc.DEBUG) {\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 ignoreWarningLocalNames: {\n /* c8 ignore next 1 */\n ...(window.__swc?.ignoreWarningLocalNames || {}),\n },\n ignoreWarningTypes: {\n ...ignoreWarningTypes,\n /* c8 ignore next 1 */\n ...(window.__swc?.ignoreWarningTypes || {}),\n },\n ignoreWarningLevels: {\n ...ignoreWarningLevels,\n /* c8 ignore next 1 */\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 /* c8 ignore next 3 */\n if (window.__swc.ignoreWarningLocalNames[localName]) return;\n if (window.__swc.ignoreWarningTypes[type]) return;\n if (window.__swc.ignoreWarningLevels[level]) return;\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"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
4
|
+
"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 * from '@spectrum-web-components/core/shared/base/Base.js';\n"],
|
|
5
|
+
"mappings": ";AAYA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/src/Base.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";export*from"@spectrum-web-components/core/shared/base/Base.js";
|
|
2
2
|
//# sourceMappingURL=Base.js.map
|
package/src/Base.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Base.ts"],
|
|
4
|
-
"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 { version } from '@spectrum-web-components/base/src/version.js';\nimport { LitElement, ReactiveElement } from 'lit';\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 (window.__swc.DEBUG) {\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 ignoreWarningLocalNames: {\n /* c8 ignore next 1 */\n ...(window.__swc?.ignoreWarningLocalNames || {}),\n },\n ignoreWarningTypes: {\n ...ignoreWarningTypes,\n /* c8 ignore next 1 */\n ...(window.__swc?.ignoreWarningTypes || {}),\n },\n ignoreWarningLevels: {\n ...ignoreWarningLevels,\n /* c8 ignore next 1 */\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 /* c8 ignore next 3 */\n if (window.__swc.ignoreWarningLocalNames[localName]) return;\n if (window.__swc.ignoreWarningTypes[type]) return;\n if (window.__swc.ignoreWarningLevels[level]) return;\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"],
|
|
5
|
-
"mappings": "aAYA,
|
|
6
|
-
"names": [
|
|
4
|
+
"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 * from '@spectrum-web-components/core/shared/base/Base.js';\n"],
|
|
5
|
+
"mappings": "aAYA,WAAc",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/src/define-element.d.ts
CHANGED
|
@@ -9,8 +9,4 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
new (...params: unknown[]): HTMLElement;
|
|
14
|
-
}
|
|
15
|
-
export declare function defineElement(name: string, constructor: CustomElementConstructor): void;
|
|
16
|
-
export {};
|
|
12
|
+
export * from '@spectrum-web-components/core/shared/base/define-element.js';
|
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export
|
|
3
|
-
if (window.__swc && true) {
|
|
4
|
-
if (customElements.get(name)) {
|
|
5
|
-
window.__swc.warn(
|
|
6
|
-
void 0,
|
|
7
|
-
`Attempted to redefine <${name}>. This usually indicates that multiple versions of the same web component were loaded onto a single page.`,
|
|
8
|
-
"https://opensource.adobe.com/spectrum-web-components/registry-conflicts"
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
customElements.define(name, constructor);
|
|
13
|
-
}
|
|
2
|
+
export * from "@spectrum-web-components/core/shared/base/define-element.js";
|
|
14
3
|
//# sourceMappingURL=define-element.dev.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["define-element.ts"],
|
|
4
|
-
"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\
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"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 * from '@spectrum-web-components/core/shared/base/define-element.js';\n"],
|
|
5
|
+
"mappings": ";AAYA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/define-element.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";export
|
|
1
|
+
"use strict";export*from"@spectrum-web-components/core/shared/base/define-element.js";
|
|
2
2
|
//# sourceMappingURL=define-element.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["define-element.ts"],
|
|
4
|
-
"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\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"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 * from '@spectrum-web-components/core/shared/base/define-element.js';\n"],
|
|
5
|
+
"mappings": "aAYA,WAAc",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/src/sizedMixin.d.ts
CHANGED
|
@@ -9,20 +9,4 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
type Constructor<T = Record<string, unknown>> = {
|
|
14
|
-
new (...args: any[]): T;
|
|
15
|
-
prototype: T;
|
|
16
|
-
};
|
|
17
|
-
export type ElementSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
|
|
18
|
-
export declare const ElementSizes: Record<string, ElementSize>;
|
|
19
|
-
export type DefaultElementSize = Exclude<ElementSize, 'xxs' | 'xs' | 'xxl'>;
|
|
20
|
-
export interface SizedElementInterface {
|
|
21
|
-
size: ElementSize;
|
|
22
|
-
}
|
|
23
|
-
export declare function SizedMixin<T extends Constructor<ReactiveElement>>(constructor: T, { validSizes, noDefaultSize, defaultSize, }?: {
|
|
24
|
-
validSizes?: ElementSize[];
|
|
25
|
-
noDefaultSize?: boolean;
|
|
26
|
-
defaultSize?: ElementSize;
|
|
27
|
-
}): T & Constructor<SizedElementInterface>;
|
|
28
|
-
export {};
|
|
12
|
+
export * from '@spectrum-web-components/core/shared/base/sizedMixin.js';
|
package/src/sizedMixin.dev.js
CHANGED
|
@@ -1,61 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
-
if (decorator = decorators[i])
|
|
8
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
-
if (kind && result) __defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import { property } from "lit/decorators.js";
|
|
13
|
-
export const ElementSizes = {
|
|
14
|
-
xxs: "xxs",
|
|
15
|
-
xs: "xs",
|
|
16
|
-
s: "s",
|
|
17
|
-
m: "m",
|
|
18
|
-
l: "l",
|
|
19
|
-
xl: "xl",
|
|
20
|
-
xxl: "xxl"
|
|
21
|
-
};
|
|
22
|
-
export function SizedMixin(constructor, {
|
|
23
|
-
validSizes = ["s", "m", "l", "xl"],
|
|
24
|
-
noDefaultSize,
|
|
25
|
-
defaultSize = "m"
|
|
26
|
-
} = {}) {
|
|
27
|
-
class SizedElement extends constructor {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...arguments);
|
|
30
|
-
this._size = defaultSize;
|
|
31
|
-
}
|
|
32
|
-
get size() {
|
|
33
|
-
return this._size || defaultSize;
|
|
34
|
-
}
|
|
35
|
-
set size(value) {
|
|
36
|
-
const fallbackSize = noDefaultSize ? null : defaultSize;
|
|
37
|
-
const size = value ? value.toLocaleLowerCase() : value;
|
|
38
|
-
const validSize = validSizes.includes(size) ? size : fallbackSize;
|
|
39
|
-
if (validSize) {
|
|
40
|
-
this.setAttribute("size", validSize);
|
|
41
|
-
}
|
|
42
|
-
if (this._size === validSize) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const oldSize = this._size;
|
|
46
|
-
this._size = validSize;
|
|
47
|
-
this.requestUpdate("size", oldSize);
|
|
48
|
-
}
|
|
49
|
-
update(changes) {
|
|
50
|
-
if (!this.hasAttribute("size") && !noDefaultSize) {
|
|
51
|
-
this.setAttribute("size", this.size);
|
|
52
|
-
}
|
|
53
|
-
super.update(changes);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
__decorateClass([
|
|
57
|
-
property({ type: String })
|
|
58
|
-
], SizedElement.prototype, "size", 1);
|
|
59
|
-
return SizedElement;
|
|
60
|
-
}
|
|
2
|
+
export * from "@spectrum-web-components/core/shared/base/sizedMixin.js";
|
|
61
3
|
//# sourceMappingURL=sizedMixin.dev.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sizedMixin.ts"],
|
|
4
|
-
"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 */\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"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 */\nexport * from '@spectrum-web-components/core/shared/base/sizedMixin.js';\n"],
|
|
5
|
+
"mappings": ";AAWA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/sizedMixin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";export*from"@spectrum-web-components/core/shared/base/sizedMixin.js";
|
|
2
2
|
//# sourceMappingURL=sizedMixin.js.map
|
package/src/sizedMixin.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sizedMixin.ts"],
|
|
4
|
-
"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 */\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"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 */\nexport * from '@spectrum-web-components/core/shared/base/sizedMixin.js';\n"],
|
|
5
|
+
"mappings": "aAWA,WAAc",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 * from '@spectrum-web-components/core/shared/base/version.js';
|