@spectrum-web-components/core 0.0.4 → 0.0.5-next.20260216143330
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/dist/components/badge/Badge.types.d.ts +1 -1
- package/dist/components/badge/Badge.types.js.map +1 -1
- package/dist/components/progress-circle/ProgressCircle.base.d.ts +2 -0
- package/dist/components/progress-circle/ProgressCircle.base.js +31 -24
- package/dist/components/progress-circle/ProgressCircle.base.js.map +1 -1
- package/dist/shared/base/Base.d.ts +2 -2
- package/dist/shared/base/Base.js +50 -93
- package/dist/shared/base/Base.js.map +1 -1
- package/dist/shared/base/version.d.ts +19 -1
- package/dist/shared/base/version.js +3 -2
- package/dist/shared/base/version.js.map +1 -1
- package/dist/shared/reactive-controllers/LanguageResolution.d.ts +63 -0
- package/dist/shared/reactive-controllers/LanguageResolution.js +50 -0
- package/dist/shared/reactive-controllers/LanguageResolution.js.map +1 -0
- package/dist/shared/reactive-controllers/index.d.ts +12 -0
- package/dist/shared/reactive-controllers/index.js +6 -0
- package/dist/shared/reactive-controllers/index.js.map +1 -0
- package/package.json +15 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
export declare const FIXED_VALUES: readonly ["block-start", "block-end", "inline-start", "inline-end"];
|
|
13
|
-
export declare const BADGE_VALID_SIZES:
|
|
13
|
+
export declare const BADGE_VALID_SIZES: ["s", "m", "l", "xl"];
|
|
14
14
|
export declare const BADGE_VARIANTS_SEMANTIC: readonly ["accent", "informative", "neutral", "positive", "notice", "negative"];
|
|
15
15
|
export declare const BADGE_VARIANTS_COLOR_S1: readonly ["fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow", "gray", "red", "orange", "chartreuse", "celery", "green", "cyan", "blue"];
|
|
16
16
|
export declare const BADGE_VARIANTS_COLOR_S2: readonly ["fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow", "gray", "red", "orange", "chartreuse", "celery", "green", "cyan", "blue", "pink", "turquoise", "brown", "cinnamon", "silver"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.types.js","sources":["../../../components/badge/Badge.types.ts"],"sourcesContent":["/**\n * Copyright 2026 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 type { ElementSize } from '@spectrum-web-components/core/shared/base/index.js';\n\n/*\n * @todo The S1 types can be removed once we are no longer maintaining 1st-gen.\n */\n\nexport const FIXED_VALUES = [\n 'block-start',\n 'block-end',\n 'inline-start',\n 'inline-end',\n] as const;\n\nexport const BADGE_VALID_SIZES = [\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies
|
|
1
|
+
{"version":3,"file":"Badge.types.js","sources":["../../../components/badge/Badge.types.ts"],"sourcesContent":["/**\n * Copyright 2026 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 type { ElementSize } from '@spectrum-web-components/core/shared/base/index.js';\n\n/*\n * @todo The S1 types can be removed once we are no longer maintaining 1st-gen.\n */\n\nexport const FIXED_VALUES = [\n 'block-start',\n 'block-end',\n 'inline-start',\n 'inline-end',\n] as const;\n\nexport const BADGE_VALID_SIZES = [\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies ElementSize[];\n\nexport const BADGE_VARIANTS_SEMANTIC = [\n 'accent',\n 'informative',\n 'neutral',\n 'positive',\n 'notice',\n 'negative',\n] as const;\n\nexport const BADGE_VARIANTS_COLOR_S1 = [\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n 'gray',\n 'red',\n 'orange',\n 'chartreuse',\n 'celery',\n 'green',\n 'cyan',\n 'blue',\n] as const;\n\nexport const BADGE_VARIANTS_COLOR_S2 = [\n ...BADGE_VARIANTS_COLOR_S1,\n 'pink',\n 'turquoise',\n 'brown',\n 'cinnamon',\n 'silver',\n] as const;\n\nexport const BADGE_VARIANTS_S1 = [\n ...BADGE_VARIANTS_SEMANTIC,\n ...BADGE_VARIANTS_COLOR_S1,\n] as const;\n\nexport const BADGE_VARIANTS_S2 = [\n ...BADGE_VARIANTS_SEMANTIC,\n ...BADGE_VARIANTS_COLOR_S2,\n] as const;\n\nexport type FixedValues = (typeof FIXED_VALUES)[number];\nexport type BadgeSize = (typeof BADGE_VALID_SIZES)[number];\nexport type BadgeSemanticVariant = (typeof BADGE_VARIANTS_SEMANTIC)[number];\nexport type BadgeColorVariantS1 = (typeof BADGE_VARIANTS_COLOR_S1)[number];\nexport type BadgeColorVariantS2 = (typeof BADGE_VARIANTS_COLOR_S2)[number];\nexport type BadgeVariantS1 = (typeof BADGE_VARIANTS_S1)[number];\nexport type BadgeVariantS2 = (typeof BADGE_VARIANTS_S2)[number];\nexport type BadgeVariant = BadgeVariantS1 | BadgeVariantS2;\n"],"names":["FIXED_VALUES","BADGE_VALID_SIZES","BADGE_VARIANTS_SEMANTIC","BADGE_VARIANTS_COLOR_S1","BADGE_VARIANTS_COLOR_S2","BADGE_VARIANTS_S1","BADGE_VARIANTS_S2"],"mappings":"AAkBO,MAAMA,IAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAEaC,IAAoB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAEaC,IAA0B;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAEaC,IAA0B;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAEaC,IAA0B;AAAA,EACnC,GAAGD;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAEaE,IAAoB;AAAA,EAC7B,GAAGH;AAAA,EACH,GAAGC;AACP,GAEaG,IAAoB;AAAA,EAC7B,GAAGJ;AAAA,EACH,GAAGE;AACP;"}
|
|
@@ -62,6 +62,7 @@ export declare abstract class ProgressCircleBase extends ProgressCircleBase_base
|
|
|
62
62
|
* Only relevant when indeterminate is false.
|
|
63
63
|
*/
|
|
64
64
|
progress: number;
|
|
65
|
+
private languageResolver;
|
|
65
66
|
/**
|
|
66
67
|
* @internal
|
|
67
68
|
*/
|
|
@@ -69,6 +70,7 @@ export declare abstract class ProgressCircleBase extends ProgressCircleBase_base
|
|
|
69
70
|
protected makeRotation(rotation: number): string | undefined;
|
|
70
71
|
protected handleSlotchange(): void;
|
|
71
72
|
protected firstUpdated(changes: PropertyValues): void;
|
|
73
|
+
private formatProgress;
|
|
72
74
|
protected updated(changes: PropertyValues): void;
|
|
73
75
|
}
|
|
74
76
|
export {};
|
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import { property as
|
|
2
|
-
import { SizedMixin as
|
|
3
|
-
import { getLabelFromSlot as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { property as a, query as p } from "lit/decorators.js";
|
|
2
|
+
import { SizedMixin as b, SpectrumElement as h } from "@spectrum-web-components/core/shared/base/index.js";
|
|
3
|
+
import { getLabelFromSlot as m } from "@spectrum-web-components/core/shared/get-label-from-slot.js";
|
|
4
|
+
import { LanguageResolutionController as d, languageResolverUpdatedSymbol as c } from "@spectrum-web-components/core/shared/reactive-controllers/LanguageResolution.js";
|
|
5
|
+
import { PROGRESS_CIRCLE_VALID_SIZES as g } from "./ProgressCircle.types.js";
|
|
6
|
+
var f = Object.defineProperty, i = (l, e, r, o) => {
|
|
7
|
+
for (var t = void 0, n = l.length - 1, u; n >= 0; n--)
|
|
8
|
+
(u = l[n]) && (t = u(e, r, t) || t);
|
|
9
|
+
return t && f(e, r, t), t;
|
|
9
10
|
};
|
|
10
|
-
class
|
|
11
|
-
validSizes:
|
|
11
|
+
class s extends b(h, {
|
|
12
|
+
validSizes: g
|
|
12
13
|
}) {
|
|
13
14
|
constructor() {
|
|
14
|
-
super(...arguments), this.indeterminate = !1, this.label = "", this.progress = 0;
|
|
15
|
+
super(...arguments), this.indeterminate = !1, this.label = "", this.progress = 0, this.languageResolver = new d(this);
|
|
15
16
|
}
|
|
16
17
|
makeRotation(e) {
|
|
17
18
|
return this.indeterminate ? void 0 : `transform: rotate(${e}deg);`;
|
|
18
19
|
}
|
|
19
20
|
handleSlotchange() {
|
|
20
|
-
const e =
|
|
21
|
+
const e = m(this.label, this.slotEl);
|
|
21
22
|
e && (this.label = e);
|
|
22
23
|
}
|
|
23
24
|
firstUpdated(e) {
|
|
24
25
|
super.firstUpdated(e), this.hasAttribute("role") || this.setAttribute("role", "progressbar");
|
|
25
26
|
}
|
|
27
|
+
formatProgress() {
|
|
28
|
+
return new Intl.NumberFormat(this.languageResolver.language, {
|
|
29
|
+
style: "percent",
|
|
30
|
+
unitDisplay: "narrow"
|
|
31
|
+
}).format(this.progress / 100);
|
|
32
|
+
}
|
|
26
33
|
updated(e) {
|
|
27
34
|
var r, o;
|
|
28
|
-
super.updated(e), !this.indeterminate && e.has("progress")
|
|
35
|
+
super.updated(e), e.has("indeterminate") && (this.indeterminate ? (this.removeAttribute("aria-valuemin"), this.removeAttribute("aria-valuemax"), this.removeAttribute("aria-valuenow"), this.removeAttribute("aria-valuetext")) : (this.setAttribute("aria-valuemin", "0"), this.setAttribute("aria-valuemax", "100"), this.setAttribute("aria-valuenow", "" + this.progress), this.setAttribute("aria-valuetext", this.formatProgress()))), !this.indeterminate && e.has("progress") && (this.setAttribute("aria-valuenow", "" + this.progress), this.setAttribute("aria-valuetext", this.formatProgress())), !this.indeterminate && e.has(c) && this.setAttribute("aria-valuetext", this.formatProgress()), e.has("label") && (this.label.length ? this.setAttribute("aria-label", this.label) : e.get("label") === this.getAttribute("aria-label") && this.removeAttribute("aria-label"));
|
|
29
36
|
const t = () => !!(this.label || this.getAttribute("aria-label") || this.getAttribute("aria-labelledby") || this.slotEl.assignedNodes().length);
|
|
30
37
|
(r = window.__swc) != null && r.DEBUG && !t() && this.getAttribute("role") === "progressbar" && ((o = window.__swc) == null || o.warn(
|
|
31
38
|
this,
|
|
@@ -44,21 +51,21 @@ class l extends d(u, {
|
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
i([
|
|
47
|
-
|
|
48
|
-
],
|
|
54
|
+
a({ type: String, reflect: !0, attribute: "static-color" })
|
|
55
|
+
], s.prototype, "staticColor");
|
|
49
56
|
i([
|
|
50
|
-
|
|
51
|
-
],
|
|
57
|
+
a({ type: Boolean, reflect: !0 })
|
|
58
|
+
], s.prototype, "indeterminate");
|
|
52
59
|
i([
|
|
53
|
-
|
|
54
|
-
],
|
|
60
|
+
a({ type: String })
|
|
61
|
+
], s.prototype, "label");
|
|
55
62
|
i([
|
|
56
|
-
|
|
57
|
-
],
|
|
63
|
+
a({ type: Number })
|
|
64
|
+
], s.prototype, "progress");
|
|
58
65
|
i([
|
|
59
|
-
|
|
60
|
-
],
|
|
66
|
+
p("slot")
|
|
67
|
+
], s.prototype, "slotEl");
|
|
61
68
|
export {
|
|
62
|
-
|
|
69
|
+
s as ProgressCircleBase
|
|
63
70
|
};
|
|
64
71
|
//# sourceMappingURL=ProgressCircle.base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressCircle.base.js","sources":["../../../components/progress-circle/ProgressCircle.base.ts"],"sourcesContent":["/**\n * Copyright 2026 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 } from 'lit';\nimport { property, query } from 'lit/decorators.js';\n\nimport {\n SizedMixin,\n SpectrumElement,\n} from '@spectrum-web-components/core/shared/base/index.js';\nimport { getLabelFromSlot } from '@spectrum-web-components/core/shared/get-label-from-slot.js';\n\nimport {\n PROGRESS_CIRCLE_VALID_SIZES,\n ProgressCircleStaticColor,\n} from './ProgressCircle.types.js';\n\n/**\n * A progress circle component that visually represents the completion progress of a task.\n * Can be used in both determinate (with specific progress value) and indeterminate (loading) states.\n *\n * @attribute {ElementSize} size - The size of the progress circle.\n *\n * @todo Why do we support both the slot and the label attribute? Should we deprecate the slot?\n *\n * @todo Figure out why our tool chain doesn't respect the line breaks in this slot description.\n *\n * @slot - Accessible label for the progress circle.\n *\n * Used to provide context about what is loading or progressing.\n */\nexport abstract class ProgressCircleBase extends SizedMixin(SpectrumElement, {\n validSizes: PROGRESS_CIRCLE_VALID_SIZES,\n}) {\n // ─────────────────────────\n // API TO OVERRIDE\n // ─────────────────────────\n\n /**\n * @internal\n *\n * A readonly array of the valid static colors for the progress circle.\n *\n * This is an actual internal property, intended not for customer use\n * but for use in internal validation logic, stories, tests, etc.\n *\n * Because S1 and S2 support different static colors, the value of this\n * property must be set in each subclass.\n */\n static readonly STATIC_COLORS: readonly string[];\n\n /**\n * @internal\n *\n * Static color variant for use on different backgrounds.\n *\n * This is a public property, but its valid values vary between S1 and S2,\n * so the property (and its docs) need to be redefined in each subclass.\n *\n * The type declared here is a union of the valid values for S1 and S2,\n * and should be narrowed in each subclass.\n */\n @property({ type: String, reflect: true, attribute: 'static-color' })\n public staticColor?: ProgressCircleStaticColor;\n\n // ──────────────────\n // SHARED API\n // ──────────────────\n\n /**\n * Whether the progress circle shows indeterminate progress (loading state).\n *\n * When true, displays an animated loading indicator instead of a specific progress value.\n */\n @property({ type: Boolean, reflect: true })\n public indeterminate = false;\n\n /**\n * Accessible label for the progress circle.\n *\n * Used to provide context about what is loading or progressing.\n */\n @property({ type: String })\n public label = '';\n\n /**\n * Progress value from 0 to 100.\n *\n * Only relevant when indeterminate is false.\n */\n @property({ type: Number })\n public progress = 0;\n\n // ──────────────────────\n // IMPLEMENTATION\n // ──────────────────────\n\n /**\n * @internal\n */\n @query('slot')\n private slotEl!: HTMLSlotElement;\n\n protected makeRotation(rotation: number): string | undefined {\n return this.indeterminate\n ? undefined\n : `transform: rotate(${rotation}deg);`;\n }\n\n protected handleSlotchange(): void {\n const labelFromSlot = getLabelFromSlot(this.label, this.slotEl);\n if (labelFromSlot) {\n this.label = labelFromSlot;\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'progressbar');\n }\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (!this.indeterminate && changes.has('progress')) {\n this.setAttribute('aria-valuenow', '' + this.progress);\n } else if (this.hasAttribute('aria-valuenow')) {\n this.removeAttribute('aria-valuenow');\n }\n if (changes.has('label')) {\n if (this.label.length) {\n this.setAttribute('aria-label', this.label);\n } else if (\n changes.get('label') === this.getAttribute('aria-label')\n ) {\n this.removeAttribute('aria-label');\n }\n }\n\n const hasAccessibleName = (): boolean => {\n return Boolean(\n this.label ||\n this.getAttribute('aria-label') ||\n this.getAttribute('aria-labelledby') ||\n this.slotEl.assignedNodes().length\n );\n };\n\n if (window.__swc?.DEBUG) {\n if (\n !hasAccessibleName() &&\n this.getAttribute('role') === 'progressbar'\n ) {\n window.__swc?.warn(\n this,\n '<sp-progress-circle> elements need one of the following to be accessible:',\n 'https://opensource.adobe.com/spectrum-web-components/components/progress-circle/#accessibility',\n {\n type: 'accessibility',\n issues: [\n 'value supplied to the \"label\" attribute, which will be displayed visually as part of the element, or',\n 'text content supplied directly to the <sp-progress-circle> element, or',\n 'value supplied to the \"aria-label\" attribute, which will only be provided to screen readers, or',\n 'an element ID reference supplied to the \"aria-labelledby\" attribute, which will be provided by screen readers and will need to be managed manually by the parent application.',\n ],\n }\n );\n }\n }\n }\n}\n"],"names":["ProgressCircleBase","SizedMixin","SpectrumElement","PROGRESS_CIRCLE_VALID_SIZES","rotation","labelFromSlot","getLabelFromSlot","changes","_a","_b","hasAccessibleName","__decorateClass","property","query"],"mappings":";;;;;;;;;AAuCO,MAAeA,UAA2BC,EAAWC,GAAiB;AAAA,EACzE,YAAYC;AAChB,CAAC,EAAE;AAAA,EAFI,cAAA;AAAA,UAAA,GAAA,SAAA,GA4CH,KAAO,gBAAgB,IAQvB,KAAO,QAAQ,IAQf,KAAO,WAAW;AAAA,EAAA;AAAA,EAYR,aAAaC,GAAsC;AACzD,WAAO,KAAK,gBACN,SACA,qBAAqBA,CAAQ;AAAA,EACvC;AAAA,EAEU,mBAAyB;AAC/B,UAAMC,IAAgBC,EAAiB,KAAK,OAAO,KAAK,MAAM;AAC9D,IAAID,MACA,KAAK,QAAQA;AAAA,EAErB;AAAA,EAEmB,aAAaE,GAA+B;AAC3D,UAAM,aAAaA,CAAO,GACrB,KAAK,aAAa,MAAM,KACzB,KAAK,aAAa,QAAQ,aAAa;AAAA,EAE/C;AAAA,EAEmB,QAAQA,GAA+B;AAnI9D,QAAAC,GAAAC;AAoIQ,UAAM,QAAQF,CAAO,GACjB,CAAC,KAAK,iBAAiBA,EAAQ,IAAI,UAAU,IAC7C,KAAK,aAAa,iBAAiB,KAAK,KAAK,QAAQ,IAC9C,KAAK,aAAa,eAAe,KACxC,KAAK,gBAAgB,eAAe,GAEpCA,EAAQ,IAAI,OAAO,MACf,KAAK,MAAM,SACX,KAAK,aAAa,cAAc,KAAK,KAAK,IAE1CA,EAAQ,IAAI,OAAO,MAAM,KAAK,aAAa,YAAY,KAEvD,KAAK,gBAAgB,YAAY;AAIzC,UAAMG,IAAoB,MACf,GACH,KAAK,SACD,KAAK,aAAa,YAAY,KAC9B,KAAK,aAAa,iBAAiB,KACnC,KAAK,OAAO,gBAAgB;AAIxC,KAAIF,IAAA,OAAO,UAAP,QAAAA,EAAc,SAEV,CAACE,EAAA,KACD,KAAK,aAAa,MAAM,MAAM,mBAE9BD,IAAA,OAAO,UAAP,QAAAA,EAAc;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACI,MAAM;AAAA,QACN,QAAQ;AAAA,UACJ;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACJ;AAAA,IACJ;AAAA,EAIhB;AACJ;AA5GWE,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM,WAAW,gBAAgB;AAAA,GA/BlDZ,EAgCX,WAAA,aAAA;AAYAW,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA3CxBZ,EA4CX,WAAA,eAAA;AAQAW,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAnDRZ,EAoDX,WAAA,OAAA;AAQAW,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA3DRZ,EA4DX,WAAA,UAAA;AAUCW,EAAA;AAAA,EADPE,EAAM,MAAM;AAAA,GArEKb,EAsEV,WAAA,QAAA;"}
|
|
1
|
+
{"version":3,"file":"ProgressCircle.base.js","sources":["../../../components/progress-circle/ProgressCircle.base.ts"],"sourcesContent":["/**\n * Copyright 2026 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 } from 'lit';\nimport { property, query } from 'lit/decorators.js';\n\nimport {\n SizedMixin,\n SpectrumElement,\n} from '@spectrum-web-components/core/shared/base/index.js';\nimport { getLabelFromSlot } from '@spectrum-web-components/core/shared/get-label-from-slot.js';\nimport {\n LanguageResolutionController,\n languageResolverUpdatedSymbol,\n} from '@spectrum-web-components/core/shared/reactive-controllers/LanguageResolution.js';\n\nimport {\n PROGRESS_CIRCLE_VALID_SIZES,\n ProgressCircleStaticColor,\n} from './ProgressCircle.types.js';\n\n/**\n * A progress circle component that visually represents the completion progress of a task.\n * Can be used in both determinate (with specific progress value) and indeterminate (loading) states.\n *\n * @attribute {ElementSize} size - The size of the progress circle.\n *\n * @todo Why do we support both the slot and the label attribute? Should we deprecate the slot?\n *\n * @todo Figure out why our tool chain doesn't respect the line breaks in this slot description.\n *\n * @slot - Accessible label for the progress circle.\n *\n * Used to provide context about what is loading or progressing.\n */\nexport abstract class ProgressCircleBase extends SizedMixin(SpectrumElement, {\n validSizes: PROGRESS_CIRCLE_VALID_SIZES,\n}) {\n // ─────────────────────────\n // API TO OVERRIDE\n // ─────────────────────────\n\n /**\n * @internal\n *\n * A readonly array of the valid static colors for the progress circle.\n *\n * This is an actual internal property, intended not for customer use\n * but for use in internal validation logic, stories, tests, etc.\n *\n * Because S1 and S2 support different static colors, the value of this\n * property must be set in each subclass.\n */\n static readonly STATIC_COLORS: readonly string[];\n\n /**\n * @internal\n *\n * Static color variant for use on different backgrounds.\n *\n * This is a public property, but its valid values vary between S1 and S2,\n * so the property (and its docs) need to be redefined in each subclass.\n *\n * The type declared here is a union of the valid values for S1 and S2,\n * and should be narrowed in each subclass.\n */\n @property({ type: String, reflect: true, attribute: 'static-color' })\n public staticColor?: ProgressCircleStaticColor;\n\n // ──────────────────\n // SHARED API\n // ──────────────────\n\n /**\n * Whether the progress circle shows indeterminate progress (loading state).\n *\n * When true, displays an animated loading indicator instead of a specific progress value.\n */\n @property({ type: Boolean, reflect: true })\n public indeterminate = false;\n\n /**\n * Accessible label for the progress circle.\n *\n * Used to provide context about what is loading or progressing.\n */\n @property({ type: String })\n public label = '';\n\n /**\n * Progress value from 0 to 100.\n *\n * Only relevant when indeterminate is false.\n */\n @property({ type: Number })\n public progress = 0;\n\n private languageResolver = new LanguageResolutionController(this);\n\n // ──────────────────────\n // IMPLEMENTATION\n // ──────────────────────\n\n /**\n * @internal\n */\n @query('slot')\n private slotEl!: HTMLSlotElement;\n\n protected makeRotation(rotation: number): string | undefined {\n return this.indeterminate\n ? undefined\n : `transform: rotate(${rotation}deg);`;\n }\n\n protected handleSlotchange(): void {\n const labelFromSlot = getLabelFromSlot(this.label, this.slotEl);\n if (labelFromSlot) {\n this.label = labelFromSlot;\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'progressbar');\n }\n }\n\n private formatProgress(): string {\n return new Intl.NumberFormat(this.languageResolver.language, {\n style: 'percent',\n unitDisplay: 'narrow',\n }).format(this.progress / 100);\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('indeterminate')) {\n if (this.indeterminate) {\n this.removeAttribute('aria-valuemin');\n this.removeAttribute('aria-valuemax');\n this.removeAttribute('aria-valuenow');\n this.removeAttribute('aria-valuetext');\n } else {\n this.setAttribute('aria-valuemin', '0');\n this.setAttribute('aria-valuemax', '100');\n this.setAttribute('aria-valuenow', '' + this.progress);\n this.setAttribute('aria-valuetext', this.formatProgress());\n }\n }\n if (!this.indeterminate && changes.has('progress')) {\n this.setAttribute('aria-valuenow', '' + this.progress);\n this.setAttribute('aria-valuetext', this.formatProgress());\n }\n if (!this.indeterminate && changes.has(languageResolverUpdatedSymbol)) {\n this.setAttribute('aria-valuetext', this.formatProgress());\n }\n if (changes.has('label')) {\n if (this.label.length) {\n this.setAttribute('aria-label', this.label);\n } else if (\n changes.get('label') === this.getAttribute('aria-label')\n ) {\n this.removeAttribute('aria-label');\n }\n }\n\n const hasAccessibleName = (): boolean => {\n return Boolean(\n this.label ||\n this.getAttribute('aria-label') ||\n this.getAttribute('aria-labelledby') ||\n this.slotEl.assignedNodes().length\n );\n };\n\n if (window.__swc?.DEBUG) {\n if (\n !hasAccessibleName() &&\n this.getAttribute('role') === 'progressbar'\n ) {\n window.__swc?.warn(\n this,\n '<sp-progress-circle> elements need one of the following to be accessible:',\n 'https://opensource.adobe.com/spectrum-web-components/components/progress-circle/#accessibility',\n {\n type: 'accessibility',\n issues: [\n 'value supplied to the \"label\" attribute, which will be displayed visually as part of the element, or',\n 'text content supplied directly to the <sp-progress-circle> element, or',\n 'value supplied to the \"aria-label\" attribute, which will only be provided to screen readers, or',\n 'an element ID reference supplied to the \"aria-labelledby\" attribute, which will be provided by screen readers and will need to be managed manually by the parent application.',\n ],\n }\n );\n }\n }\n }\n}\n"],"names":["ProgressCircleBase","SizedMixin","SpectrumElement","PROGRESS_CIRCLE_VALID_SIZES","LanguageResolutionController","rotation","labelFromSlot","getLabelFromSlot","changes","_a","_b","languageResolverUpdatedSymbol","hasAccessibleName","__decorateClass","property","query"],"mappings":";;;;;;;;;;AA2CO,MAAeA,UAA2BC,EAAWC,GAAiB;AAAA,EACzE,YAAYC;AAChB,CAAC,EAAE;AAAA,EAFI,cAAA;AAAA,UAAA,GAAA,SAAA,GA4CH,KAAO,gBAAgB,IAQvB,KAAO,QAAQ,IAQf,KAAO,WAAW,GAElB,KAAQ,mBAAmB,IAAIC,EAA6B,IAAI;AAAA,EAAA;AAAA,EAYtD,aAAaC,GAAsC;AACzD,WAAO,KAAK,gBAC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AAMI,IAAoB,MACf,GACH,KAAK,SACD,KAAK,aAAa,YAAY,KAC9B,KAAK,aAAa,iBAAiB,KACnC,KAAK,OAAO,gBAAgB;AAIxC,KAAIH,IAAA,OAAO,UAAP,QAAAA,EAAc,SAEV,CAACG,EAAA,KACD,KAAK,aAAa,MAAM,MAAM,mBAE9BF,IAAA,OAAO,UAAP,QAAAA,EAAc;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACI,MAAM;AAAA,QACN,QAAQ;AAAA,UACJ;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACJ;AAAA,IACJ;AAAA,EAIhB;AACJ;AApIWG,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM,WAAW,gBAAgB;AAAA,GA/BlDd,EAgCX,WAAA,aAAA;AAYAa,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA3CxBd,EA4CX,WAAA,eAAA;AAQAa,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAnDRd,EAoDX,WAAA,OAAA;AAQAa,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA3DRd,EA4DX,WAAA,UAAA;AAYCa,EAAA;AAAA,EADPE,EAAM,MAAM;AAAA,GAvEKf,EAwEV,WAAA,QAAA;"}
|
|
@@ -5,13 +5,13 @@ type Constructor<T = Record<string, unknown>> = {
|
|
|
5
5
|
};
|
|
6
6
|
export interface SpectrumInterface {
|
|
7
7
|
shadowRoot: ShadowRoot;
|
|
8
|
-
isLTR: boolean;
|
|
9
8
|
hasVisibleFocusInTree(): boolean;
|
|
10
|
-
dir: 'ltr' | 'rtl';
|
|
11
9
|
}
|
|
12
10
|
export declare function SpectrumMixin<T extends Constructor<ReactiveElement>>(constructor: T): T & Constructor<SpectrumInterface>;
|
|
13
11
|
declare const SpectrumElement_base: typeof LitElement & Constructor<SpectrumInterface>;
|
|
14
12
|
export declare class SpectrumElement extends SpectrumElement_base {
|
|
15
13
|
static VERSION: string;
|
|
14
|
+
static CORE_VERSION: string;
|
|
15
|
+
get dir(): CSSStyleDeclaration['direction'];
|
|
16
16
|
}
|
|
17
17
|
export {};
|
package/dist/shared/base/Base.js
CHANGED
|
@@ -1,91 +1,48 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { version as
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
u.forEach((d) => {
|
|
7
|
-
d.setAttribute("dir", i);
|
|
8
|
-
});
|
|
9
|
-
}, N = new MutationObserver(b);
|
|
10
|
-
N.observe(document.documentElement, {
|
|
11
|
-
attributes: !0,
|
|
12
|
-
attributeFilter: ["dir"]
|
|
13
|
-
});
|
|
14
|
-
const W = (i) => typeof i.startManagingContentDirection != "undefined" || i.tagName === "SP-THEME";
|
|
15
|
-
function C(i) {
|
|
16
|
-
class d extends i {
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
get isLTR() {
|
|
21
|
-
return this.dir === "ltr";
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
1
|
+
import { LitElement as v } from "lit";
|
|
2
|
+
import { version as E, coreVersion as W } from "./version.js";
|
|
3
|
+
var u, g, m;
|
|
4
|
+
function N(c) {
|
|
5
|
+
class o extends c {
|
|
26
6
|
hasVisibleFocusInTree() {
|
|
27
|
-
const
|
|
28
|
-
var
|
|
29
|
-
let e =
|
|
7
|
+
const i = ((t = document) => {
|
|
8
|
+
var n;
|
|
9
|
+
let e = t.activeElement;
|
|
30
10
|
for (; e != null && e.shadowRoot && e.shadowRoot.activeElement; )
|
|
31
11
|
e = e.shadowRoot.activeElement;
|
|
32
|
-
const
|
|
12
|
+
const r = e ? [e] : [];
|
|
33
13
|
for (; e; ) {
|
|
34
|
-
const
|
|
35
|
-
|
|
14
|
+
const a = e.assignedSlot || e.parentElement || ((n = e.getRootNode()) == null ? void 0 : n.host);
|
|
15
|
+
a && r.push(a), e = a;
|
|
36
16
|
}
|
|
37
|
-
return
|
|
17
|
+
return r;
|
|
38
18
|
})(
|
|
39
19
|
this.getRootNode()
|
|
40
20
|
)[0];
|
|
41
|
-
if (!
|
|
21
|
+
if (!i)
|
|
42
22
|
return !1;
|
|
43
23
|
try {
|
|
44
|
-
return
|
|
45
|
-
} catch (
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
connectedCallback() {
|
|
50
|
-
if (!this.hasAttribute("dir")) {
|
|
51
|
-
let t = this.assignedSlot || this.parentNode;
|
|
52
|
-
for (; t !== document.documentElement && !W(
|
|
53
|
-
t
|
|
54
|
-
); )
|
|
55
|
-
t = t.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
56
|
-
t.parentNode || // DOM Element detected
|
|
57
|
-
t.host;
|
|
58
|
-
if (this.dir = t.dir === "rtl" ? t.dir : this.dir || "ltr", t === document.documentElement)
|
|
59
|
-
u.add(this);
|
|
60
|
-
else {
|
|
61
|
-
const { localName: n } = t;
|
|
62
|
-
n.search("-") > -1 && !customElements.get(n) ? customElements.whenDefined(n).then(() => {
|
|
63
|
-
t.startManagingContentDirection(this);
|
|
64
|
-
}) : t.startManagingContentDirection(
|
|
65
|
-
this
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
this._dirParent = t;
|
|
24
|
+
return i.matches(":focus-visible") || i.matches(".focus-visible");
|
|
25
|
+
} catch (t) {
|
|
26
|
+
return i.matches(".focus-visible");
|
|
69
27
|
}
|
|
70
|
-
super.connectedCallback();
|
|
71
|
-
}
|
|
72
|
-
disconnectedCallback() {
|
|
73
|
-
super.disconnectedCallback(), this._dirParent && (this._dirParent === document.documentElement ? u.delete(this) : this._dirParent.stopManagingContentDirection(
|
|
74
|
-
this
|
|
75
|
-
), this.removeAttribute("dir"));
|
|
76
28
|
}
|
|
77
29
|
}
|
|
78
|
-
return
|
|
30
|
+
return o;
|
|
79
31
|
}
|
|
80
|
-
class
|
|
32
|
+
class f extends N(v) {
|
|
33
|
+
get dir() {
|
|
34
|
+
var o;
|
|
35
|
+
return (o = getComputedStyle(this).direction) != null ? o : "ltr";
|
|
36
|
+
}
|
|
81
37
|
}
|
|
82
|
-
|
|
38
|
+
f.VERSION = E;
|
|
39
|
+
f.CORE_VERSION = W;
|
|
83
40
|
if (process.env.NODE_ENV === "development") {
|
|
84
|
-
const
|
|
41
|
+
const c = {
|
|
85
42
|
default: !1,
|
|
86
43
|
accessibility: !1,
|
|
87
44
|
api: !1
|
|
88
|
-
},
|
|
45
|
+
}, o = {
|
|
89
46
|
default: !1,
|
|
90
47
|
low: !1,
|
|
91
48
|
medium: !1,
|
|
@@ -96,42 +53,42 @@ if (process.env.NODE_ENV === "development") {
|
|
|
96
53
|
...window.__swc,
|
|
97
54
|
DEBUG: !0,
|
|
98
55
|
ignoreWarningLocalNames: {
|
|
99
|
-
...((
|
|
56
|
+
...((u = window.__swc) == null ? void 0 : u.ignoreWarningLocalNames) || {}
|
|
100
57
|
},
|
|
101
58
|
ignoreWarningTypes: {
|
|
102
|
-
...
|
|
59
|
+
...c,
|
|
103
60
|
...((g = window.__swc) == null ? void 0 : g.ignoreWarningTypes) || {}
|
|
104
61
|
},
|
|
105
62
|
ignoreWarningLevels: {
|
|
106
|
-
...
|
|
107
|
-
...((
|
|
63
|
+
...o,
|
|
64
|
+
...((m = window.__swc) == null ? void 0 : m.ignoreWarningLevels) || {}
|
|
108
65
|
},
|
|
109
66
|
issuedWarnings: /* @__PURE__ */ new Set(),
|
|
110
|
-
warn: (
|
|
111
|
-
const { localName:
|
|
112
|
-
if (!window.__swc.verbose && window.__swc.issuedWarnings.has(
|
|
67
|
+
warn: (s, l, i, { type: t = "api", level: n = "default", issues: e } = {}) => {
|
|
68
|
+
const { localName: r = "base" } = s || {}, a = `${r}:${t}:${n}`;
|
|
69
|
+
if (!window.__swc.verbose && window.__swc.issuedWarnings.has(a) || window.__swc.ignoreWarningLocalNames[r] || window.__swc.ignoreWarningTypes[t] || window.__swc.ignoreWarningLevels[n])
|
|
113
70
|
return;
|
|
114
|
-
window.__swc.issuedWarnings.add(
|
|
115
|
-
let
|
|
116
|
-
e && e.length && (e.unshift(""),
|
|
71
|
+
window.__swc.issuedWarnings.add(a);
|
|
72
|
+
let w = "";
|
|
73
|
+
e && e.length && (e.unshift(""), w = e.join(`
|
|
117
74
|
- `) + `
|
|
118
75
|
`);
|
|
119
|
-
const
|
|
120
|
-
Inspect this issue in the follow element:` : "",
|
|
76
|
+
const p = n === "deprecation" ? "DEPRECATION NOTICE: " : "", _ = s ? `
|
|
77
|
+
Inspect this issue in the follow element:` : "", h = (s ? `
|
|
121
78
|
|
|
122
79
|
` : `
|
|
123
|
-
`) +
|
|
124
|
-
`,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
` +
|
|
128
|
-
),
|
|
80
|
+
`) + i + `
|
|
81
|
+
`, d = [];
|
|
82
|
+
d.push(
|
|
83
|
+
p + l + `
|
|
84
|
+
` + w + _
|
|
85
|
+
), s && d.push(s), d.push(h, {
|
|
129
86
|
data: {
|
|
130
|
-
localName:
|
|
131
|
-
type:
|
|
132
|
-
level:
|
|
87
|
+
localName: r,
|
|
88
|
+
type: t,
|
|
89
|
+
level: n
|
|
133
90
|
}
|
|
134
|
-
}), console.warn(...
|
|
91
|
+
}), console.warn(...d);
|
|
135
92
|
}
|
|
136
93
|
}, window.__swc.warn(
|
|
137
94
|
void 0,
|
|
@@ -141,7 +98,7 @@ Inspect this issue in the follow element:` : "", _ = (o ? `
|
|
|
141
98
|
);
|
|
142
99
|
}
|
|
143
100
|
export {
|
|
144
|
-
|
|
145
|
-
|
|
101
|
+
f as SpectrumElement,
|
|
102
|
+
N as SpectrumMixin
|
|
146
103
|
};
|
|
147
104
|
//# sourceMappingURL=Base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.js","sources":["../../../shared/base/Base.ts"],"sourcesContent":["/**\n * Copyright 2026 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 * @internal\n */\n public override shadowRoot!: ShadowRoot;\n private _dirParent?: HTMLElement;\n\n /**\n * @internal\n */\n public override dir!: 'ltr' | 'rtl';\n\n /**\n * @internal\n */\n public get isLTR(): boolean {\n return this.dir === 'ltr';\n }\n /**\n * @internal\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":["_a","_b","_c","observedForElements","updateRTL","dir","el","rtlObserver","canManageContentDirection","SpectrumMixin","constructor","SpectrumMixinElement","activeElement","root","currentNode","ancestors","ancestor","error","dirParent","localName","SpectrumElement","LitElement","version","ignoreWarningTypes","ignoreWarningLevels","element","message","url","type","level","issues","id","listedIssues","intro","inspectElement","displayURL","messages"],"mappings":";;AAAA,IAAAA,GAAAC,GAAAC;AAiCA,MAAMC,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;AAAA,EAC9B,CAAC;AACL,GAEME,IAAc,IAAI,iBAAiBH,CAAS;AAElDG,EAAY,QAAQ,SAAS,iBAAiB;AAAA,EAC1C,YAAY;AAAA,EACZ,iBAAiB,CAAC,KAAK;AAC3B,CAAC;AAMD,MAAMC,IAA4B,CAACF,MAC/B,OAAOA,EAAG,iCAAkC,eAC5CA,EAAG,YAAY;AAEZ,SAASG,EACZC,GACkC;AAAA,EAClC,MAAMC,UAA6BD,EAAY;AAAA;AAAA;AAAA;AAAA,IAe3C,IAAW,QAAiB;AACxB,aAAO,KAAK,QAAQ;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAIO,wBAAiC;AA0BpC,YAAME,KAzBe,C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AAS,IAAIS,CAAI,IAAIC,CAAK;AAUxC,UATI,CAAC,OAAO,MAAM,WAAW,OAAO,MAAM,eAAe,IAAIE,CAAE,KAG3D,OAAO,MAAM,wBAAwBZ,CAAS,KAG9C,OAAO,MAAM,mBAAmBS,CAAI,KAGpC,OAAO,MAAM,oBAAoBC,CAAK;AACtC;AAEJ,aAAO,MAAM,eAAe,IAAIE,CAAE;AAClC,UAAIC,IAAe;AACnB,MAAIF,KAAUA,EAAO,WACjBA,EAAO,QAAQ,EAAE,GACjBE,IAAeF,EAAO,KAAK;AAAA,OAAU,IAAI;AAAA;AAE7C,YAAMG,IAAQJ,MAAU,gBAAgB,yBAAyB,IAC3DK,IAAiBT,IACjB;AAAA,6CACA,IACAU,KAAcV,IAAU;AAAA;AAAA,IAAS;AAAA,KAAQE,IAAM;AAAA,GAC/CS,IAAsB,CAAA;AAC5B,MAAAA,EAAS;AAAA,QACLH,IAAQP,IAAU;AAAA,IAAOM,IAAeE;AAAA,MAAA,GAExCT,KACAW,EAAS,KAAKX,CAAO,GAEzBW,EAAS,KAAKD,GAAY;AAAA,QACtB,MAAM;AAAA,UACF,WAAAhB;AAAA,UACA,MAAAS;AAAA,UACA,OAAAC;AAAA,QAAA;AAAA,MACJ,CACH,GACD,QAAQ,KAAK,GAAGO,CAAQ;AAAA,IAC5B;AAAA,EAAA,GAGJ,OAAO,MAAM;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE,MAAM,UAAA;AAAA,EAAU;AAE1B;"}
|
|
1
|
+
{"version":3,"file":"Base.js","sources":["../../../shared/base/Base.ts"],"sourcesContent":["/**\n * Copyright 2026 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 { coreVersion, version } from './version.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 interface SpectrumInterface {\n shadowRoot: ShadowRoot;\n hasVisibleFocusInTree(): boolean;\n}\n\nexport function SpectrumMixin<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<SpectrumInterface> {\n class SpectrumMixinElement extends constructor {\n /**\n * @internal\n */\n public override shadowRoot!: ShadowRoot;\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 return SpectrumMixinElement;\n}\n\nexport class SpectrumElement extends SpectrumMixin(LitElement) {\n static VERSION = version;\n\n static CORE_VERSION = coreVersion;\n\n public override get dir(): CSSStyleDeclaration['direction'] {\n return getComputedStyle(this).direction ?? 'ltr';\n }\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":["_a","_b","_c","SpectrumMixin","constructor","SpectrumMixinElement","activeElement","root","currentNode","ancestors","ancestor","error","SpectrumElement","LitElement","version","coreVersion","ignoreWarningTypes","ignoreWarningLevels","element","message","url","type","level","issues","localName","id","listedIssues","intro","inspectElement","displayURL","messages"],"mappings":";;AAAA,IAAAA,GAAAC,GAAAC;AA2BO,SAASC,EACZC,GACkC;AAAA,EAClC,MAAMC,UAA6BD,EAAY;AAAA,IAKpC,wBAAiC;AA0BpC,YAAME,KAzBe,CAACC,IAAiB,aAA4B;AApC/E,YAAAP;AAsCgB,YAAIQ,IAAcD,EAAK;AACvB,eACIC,KAAA,QAAAA,EAAa,cACbA,EAAY,WAAW;AAEvB,UAAAA,IAAcA,EAAY,WACrB;AAET,cAAMC,IAA2BD,IAC3B,CAACA,CAAW,IACZ,CAAA;AACN,eAAOA,KAAa;AAChB,gBAAME,IACFF,EAAY,gBACZA,EAAY,mBACXR,IAAAQ,EAAY,YAAA,MAAZ,OAAA,SAAAR,EAA0C;AAC/C,UAAIU,KACAD,EAAU,KAAKC,CAAuB,GAE1CF,IAAcE;AAAA,QAClB;AACA,eAAOD;AAAA,MACX;AAAA,QAEI,KAAK,YAAA;AAAA,MAAY,EACnB,CAAC;AACH,UAAI,CAACH;AACD,eAAO;AAMX,UAAI;AACA,eACIA,EAAc,QAAQ,gBAAgB,KACtCA,EAAc,QAAQ,gBAAgB;AAAA,MAG9C,SAASK,GAAO;AACZ,eAAOL,EAAc,QAAQ,gBAAgB;AAAA,MACjD;AAAA,IACJ;AAAA,EAAA;AAEJ,SAAOD;AACX;AAEO,MAAMO,UAAwBT,EAAcU,CAAU,EAAE;AAAA,EAK3D,IAAoB,MAAwC;AA1FhE,QAAAb;AA2FQ,YAAOA,IAAA,iBAAiB,IAAI,EAAE,cAAvB,OAAAA,IAAoC;AAAA,EAC/C;AACJ;AARaY,EACF,UAAUE;AADRF,EAGF,eAAeG;AAO1B,IAAI,QAAQ,IAAI,aAAa,eAAe;AACxC,QAAMC,IAAqB;A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,IAAiBV,IACjB;AAAA,6CACA,IACAW,KAAcX,IAAU;AAAA;AAAA,IAAS;AAAA,KAAQE,IAAM;AAAA,GAC/CU,IAAsB,CAAA;AAC5B,MAAAA,EAAS;AAAA,QACLH,IAAQR,IAAU;AAAA,IAAOO,IAAeE;AAAA,MAAA,GAExCV,KACAY,EAAS,KAAKZ,CAAO,GAEzBY,EAAS,KAAKD,GAAY;AAAA,QACtB,MAAM;AAAA,UACF,WAAAL;AAAA,UACA,MAAAH;AAAA,UACA,OAAAC;AAAA,QAAA;AAAA,MACJ,CACH,GACD,QAAQ,KAAK,GAAGQ,CAAQ;AAAA,IAC5B;AAAA,EAAA,GAGJ,OAAO,MAAM;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE,MAAM,UAAA;AAAA,EAAU;AAE1B;"}
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
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
|
+
/**
|
|
13
|
+
* The version of the 2nd-gen Spectrum Web Components library.
|
|
14
|
+
*/
|
|
15
|
+
export declare const version = "0.0.5-next.20260216143330";
|
|
16
|
+
/**
|
|
17
|
+
* The version of the core base package.
|
|
18
|
+
*/
|
|
19
|
+
export declare const coreVersion = "0.0.5-next.20260216143330";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../shared/base/version.ts"],"sourcesContent":["//
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../shared/base/version.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\n// Auto-generated from 2nd-gen/packages/core/package.json\n// Generation: 2nd-gen\n// DO NOT EDIT - This file is generated by scripts/generate-versions.js\n\n/**\n * The version of the 2nd-gen Spectrum Web Components library.\n */\nexport const version = '0.0.5-next.20260216143330';\n\n/**\n * The version of the core base package.\n */\nexport const coreVersion = '0.0.5-next.20260216143330';\n"],"names":["version","coreVersion"],"mappings":"AAmBO,MAAMA,IAAU,6BAKVC,IAAc;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Symbol used to track language resolver updates in reactive element lifecycle.
|
|
4
|
+
* When the language context changes, components use this symbol to trigger updates
|
|
5
|
+
* to locale-dependent content (e.g., formatted dates, numbers, currency).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* protected override updated(changes: PropertyValues): void {
|
|
10
|
+
* if (changes.has(languageResolverUpdatedSymbol)) {
|
|
11
|
+
* // Re-render locale-dependent content
|
|
12
|
+
* this.setAttribute('aria-valuetext', this.formatProgress());
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const languageResolverUpdatedSymbol: unique symbol;
|
|
18
|
+
/**
|
|
19
|
+
* A reactive controller that manages language/locale resolution for components.
|
|
20
|
+
*
|
|
21
|
+
* This controller:
|
|
22
|
+
* - Automatically detects the document language or falls back to browser/default language
|
|
23
|
+
* - Subscribes to language context changes from parent `<sp-theme>` elements
|
|
24
|
+
* - Triggers host component updates when language changes
|
|
25
|
+
* - Validates locale support using Intl API
|
|
26
|
+
*
|
|
27
|
+
* Components using this controller can access the current language via the `language`
|
|
28
|
+
* property and will automatically re-render when the language context changes.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* class MyComponent extends SpectrumElement {
|
|
33
|
+
* private languageResolver = new LanguageResolutionController(this);
|
|
34
|
+
*
|
|
35
|
+
* protected override updated(changes: PropertyValues): void {
|
|
36
|
+
* if (changes.has(languageResolverUpdatedSymbol)) {
|
|
37
|
+
* // Update locale-dependent formatting
|
|
38
|
+
* this.formattedValue = new Intl.NumberFormat(
|
|
39
|
+
* this.languageResolver.language
|
|
40
|
+
* ).format(this.value);
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class LanguageResolutionController implements ReactiveController {
|
|
47
|
+
private host;
|
|
48
|
+
/**
|
|
49
|
+
* The currently resolved language/locale code (e.g., 'en-US', 'fr-FR').
|
|
50
|
+
* Defaults to document language, browser language, or 'en-US'.
|
|
51
|
+
*/
|
|
52
|
+
language: string;
|
|
53
|
+
private unsubscribe?;
|
|
54
|
+
constructor(host: ReactiveElement);
|
|
55
|
+
hostConnected(): void;
|
|
56
|
+
hostDisconnected(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Resolves the language from the theme context and validates it against Intl API.
|
|
59
|
+
* Falls back to 'en-US' if the language is not supported.
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
private resolveLanguage;
|
|
63
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const n = Symbol(
|
|
2
|
+
"language resolver updated"
|
|
3
|
+
);
|
|
4
|
+
class l {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
this.language = document.documentElement.lang || navigator.language || "en-US", this.host = e, this.host.addController(this);
|
|
7
|
+
}
|
|
8
|
+
hostConnected() {
|
|
9
|
+
this.resolveLanguage();
|
|
10
|
+
}
|
|
11
|
+
hostDisconnected() {
|
|
12
|
+
var e;
|
|
13
|
+
(e = this.unsubscribe) == null || e.call(this);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the language from the theme context and validates it against Intl API.
|
|
17
|
+
* Falls back to 'en-US' if the language is not supported.
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
resolveLanguage() {
|
|
21
|
+
try {
|
|
22
|
+
Intl.DateTimeFormat.supportedLocalesOf([this.language]);
|
|
23
|
+
} catch (t) {
|
|
24
|
+
this.language = "en-US";
|
|
25
|
+
}
|
|
26
|
+
const e = new CustomEvent(
|
|
27
|
+
"sp-language-context",
|
|
28
|
+
{
|
|
29
|
+
bubbles: !0,
|
|
30
|
+
composed: !0,
|
|
31
|
+
detail: {
|
|
32
|
+
callback: (t, a) => {
|
|
33
|
+
const s = this.language;
|
|
34
|
+
this.language = t, this.unsubscribe = a, this.host.requestUpdate(
|
|
35
|
+
n,
|
|
36
|
+
s
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
cancelable: !0
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
this.host.dispatchEvent(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
l as LanguageResolutionController,
|
|
48
|
+
n as languageResolverUpdatedSymbol
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=LanguageResolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageResolution.js","sources":["../../../shared/reactive-controllers/LanguageResolution.ts"],"sourcesContent":["/**\n * Copyright 2026 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 type { ReactiveController, ReactiveElement } from 'lit';\n\n// TODO: Update this when theme is migrated to 2nd-gen\ntype ProvideLang = {\n callback: (lang: string, unsubscribe: () => void) => void;\n};\n\n/**\n * Symbol used to track language resolver updates in reactive element lifecycle.\n * When the language context changes, components use this symbol to trigger updates\n * to locale-dependent content (e.g., formatted dates, numbers, currency).\n *\n * @example\n * ```typescript\n * protected override updated(changes: PropertyValues): void {\n * if (changes.has(languageResolverUpdatedSymbol)) {\n * // Re-render locale-dependent content\n * this.setAttribute('aria-valuetext', this.formatProgress());\n * }\n * }\n * ```\n */\nexport const languageResolverUpdatedSymbol = Symbol(\n 'language resolver updated'\n);\n\n/**\n * A reactive controller that manages language/locale resolution for components.\n *\n * This controller:\n * - Automatically detects the document language or falls back to browser/default language\n * - Subscribes to language context changes from parent `<sp-theme>` elements\n * - Triggers host component updates when language changes\n * - Validates locale support using Intl API\n *\n * Components using this controller can access the current language via the `language`\n * property and will automatically re-render when the language context changes.\n *\n * @example\n * ```typescript\n * class MyComponent extends SpectrumElement {\n * private languageResolver = new LanguageResolutionController(this);\n *\n * protected override updated(changes: PropertyValues): void {\n * if (changes.has(languageResolverUpdatedSymbol)) {\n * // Update locale-dependent formatting\n * this.formattedValue = new Intl.NumberFormat(\n * this.languageResolver.language\n * ).format(this.value);\n * }\n * }\n * }\n * ```\n */\nexport class LanguageResolutionController implements ReactiveController {\n private host: ReactiveElement;\n\n /**\n * The currently resolved language/locale code (e.g., 'en-US', 'fr-FR').\n * Defaults to document language, browser language, or 'en-US'.\n */\n language = document.documentElement.lang || navigator.language || 'en-US';\n\n private unsubscribe?: () => void;\n\n constructor(host: ReactiveElement) {\n this.host = host;\n this.host.addController(this);\n }\n\n public hostConnected(): void {\n this.resolveLanguage();\n }\n\n public hostDisconnected(): void {\n this.unsubscribe?.();\n }\n\n /**\n * Resolves the language from the theme context and validates it against Intl API.\n * Falls back to 'en-US' if the language is not supported.\n * @private\n */\n private resolveLanguage(): void {\n try {\n Intl.DateTimeFormat.supportedLocalesOf([this.language]);\n } catch {\n this.language = 'en-US';\n }\n const queryThemeEvent = new CustomEvent<ProvideLang>(\n 'sp-language-context',\n {\n bubbles: true,\n composed: true,\n detail: {\n callback: (lang: string, unsubscribe: () => void) => {\n const previous = this.language;\n this.language = lang;\n this.unsubscribe = unsubscribe;\n this.host.requestUpdate(\n languageResolverUpdatedSymbol,\n previous\n );\n },\n },\n cancelable: true,\n }\n );\n this.host.dispatchEvent(queryThemeEvent);\n }\n}\n"],"names":["languageResolverUpdatedSymbol","LanguageResolutionController","host","_a","e","queryThemeEvent","lang","unsubscribe","previous"],"mappings":"AAkCO,MAAMA,IAAgC;AAAA,EACzC;AACJ;AA8BO,MAAMC,EAA2D;AAAA,EAWpE,YAAYC,GAAuB;AAJnC,SAAA,WAAW,SAAS,gBAAgB,QAAQ,UAAU,YAAY,SAK9D,KAAK,OAAOA,GACZ,KAAK,KAAK,cAAc,IAAI;AAAA,EAChC;AAAA,EAEO,gBAAsB;AACzB,SAAK,gBAAA;AAAA,EACT;AAAA,EAEO,mBAAyB;AAtFpC,QAAAC;AAuFQ,KAAAA,IAAA,KAAK,gBAAL,QAAAA,EAAA,KAAA,IAAA;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOQ,kBAAwB;AAC5B,QAAI;AACA,WAAK,eAAe,mBAAmB,CAAC,KAAK,QAAQ,CAAC;AAAA,IAC1D,SAAQC,GAAA;AACJ,WAAK,WAAW;AAAA,IACpB;AACA,UAAMC,IAAkB,IAAI;AAAA,MACxB;AAAA,MACA;AAAA,QACI,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,UACJ,UAAU,CAACC,GAAcC,MAA4B;AACjD,kBAAMC,IAAW,KAAK;AACtB,iBAAK,WAAWF,GAChB,KAAK,cAAcC,GACnB,KAAK,KAAK;AAAA,cACNP;AAAA,cACAQ;AAAA,YAAA;AAAA,UAER;AAAA,QAAA;AAAA,QAEJ,YAAY;AAAA,MAAA;AAAA,IAChB;AAEJ,SAAK,KAAK,cAAcH,CAAe;AAAA,EAC3C;AACJ;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 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 { LanguageResolutionController, languageResolverUpdatedSymbol, } from './LanguageResolution.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-next.20260216143330",
|
|
4
4
|
"description": "Abstract base classes for Spectrum Web Components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Adobe",
|
|
@@ -82,6 +82,14 @@
|
|
|
82
82
|
"./shared/observe-slot-text.js": {
|
|
83
83
|
"types": "./dist/shared/observe-slot-text.d.ts",
|
|
84
84
|
"import": "./dist/shared/observe-slot-text.js"
|
|
85
|
+
},
|
|
86
|
+
"./shared/reactive-controllers": {
|
|
87
|
+
"types": "./dist/shared/reactive-controllers/index.d.ts",
|
|
88
|
+
"import": "./dist/shared/reactive-controllers/index.js"
|
|
89
|
+
},
|
|
90
|
+
"./shared/reactive-controllers/index.js": {
|
|
91
|
+
"types": "./dist/shared/reactive-controllers/index.d.ts",
|
|
92
|
+
"import": "./dist/shared/reactive-controllers/index.js"
|
|
85
93
|
}
|
|
86
94
|
},
|
|
87
95
|
"files": [
|
|
@@ -145,6 +153,12 @@
|
|
|
145
153
|
],
|
|
146
154
|
"shared/observe-slot-text.js": [
|
|
147
155
|
"dist/shared/observe-slot-text.d.ts"
|
|
156
|
+
],
|
|
157
|
+
"shared/reactive-controllers": [
|
|
158
|
+
"dist/shared/reactive-controllers/index.d.ts"
|
|
159
|
+
],
|
|
160
|
+
"shared/reactive-controllers/index.js": [
|
|
161
|
+
"dist/shared/reactive-controllers/index.d.ts"
|
|
148
162
|
]
|
|
149
163
|
}
|
|
150
164
|
},
|