@adobe/spectrum-wc-core 2.0.0-beta.2 → 2.0.0-beta.4
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/README.md +1 -1
- package/dist/components/accordion/Accordion.base.js +28 -22
- package/dist/components/accordion/Accordion.base.js.map +1 -1
- package/dist/components/accordion/AccordionItem.base.d.ts +16 -6
- package/dist/components/accordion/AccordionItem.base.js +6 -3
- package/dist/components/accordion/AccordionItem.base.js.map +1 -1
- package/dist/components/action-group/ActionGroup.base.d.ts +108 -0
- package/dist/components/action-group/ActionGroup.base.js +53 -0
- package/dist/components/action-group/ActionGroup.base.js.map +1 -0
- package/dist/components/action-group/ActionGroup.types.d.ts +17 -0
- package/dist/components/action-group/ActionGroup.types.js +12 -0
- package/dist/components/action-group/ActionGroup.types.js.map +1 -0
- package/dist/components/action-group/index.d.ts +13 -0
- package/dist/components/action-group/index.js +3 -0
- package/dist/components/alert-banner/AlertBanner.base.js +11 -10
- package/dist/components/alert-banner/AlertBanner.base.js.map +1 -1
- package/dist/components/asset/Asset.base.d.ts +89 -10
- package/dist/components/asset/Asset.base.js +117 -12
- package/dist/components/asset/Asset.base.js.map +1 -1
- package/dist/components/asset/Asset.types.d.ts +20 -2
- package/dist/components/asset/Asset.types.js +10 -2
- package/dist/components/asset/Asset.types.js.map +1 -1
- package/dist/components/asset/index.js +3 -3
- package/dist/components/avatar/Avatar.base.js +18 -22
- package/dist/components/avatar/Avatar.base.js.map +1 -1
- package/dist/components/badge/Badge.base.d.ts +24 -8
- package/dist/components/badge/Badge.base.js +22 -17
- package/dist/components/badge/Badge.base.js.map +1 -1
- package/dist/components/button/Button.base.d.ts +20 -10
- package/dist/components/button/Button.base.js +17 -12
- package/dist/components/button/Button.base.js.map +1 -1
- package/dist/components/button-group/ButtonGroup.base.js +19 -12
- package/dist/components/button-group/ButtonGroup.base.js.map +1 -1
- package/dist/components/card/Card.base.d.ts +95 -46
- package/dist/components/card/Card.base.js +71 -23
- package/dist/components/card/Card.base.js.map +1 -1
- package/dist/components/card/Card.types.d.ts +1 -0
- package/dist/components/card/Card.types.js +2 -2
- package/dist/components/card/Card.types.js.map +1 -1
- package/dist/components/card/index.js +3 -3
- package/dist/components/divider/Divider.base.js +13 -8
- package/dist/components/divider/Divider.base.js.map +1 -1
- package/dist/components/dropzone/Dropzone.base.d.ts +74 -0
- package/dist/components/dropzone/Dropzone.base.js +82 -0
- package/dist/components/dropzone/Dropzone.base.js.map +1 -0
- package/dist/components/dropzone/Dropzone.types.d.ts +43 -0
- package/dist/components/dropzone/Dropzone.types.js +15 -0
- package/dist/components/dropzone/Dropzone.types.js.map +1 -0
- package/dist/components/dropzone/index.d.ts +13 -0
- package/dist/components/dropzone/index.js +3 -0
- package/dist/components/icon/Icon.base.d.ts +11 -7
- package/dist/components/icon/Icon.base.js +13 -20
- package/dist/components/icon/Icon.base.js.map +1 -1
- package/dist/components/illustrated-message/IllustratedMessage.base.d.ts +22 -8
- package/dist/components/illustrated-message/IllustratedMessage.base.js +33 -20
- package/dist/components/illustrated-message/IllustratedMessage.base.js.map +1 -1
- package/dist/components/infield-button/InfieldButton.base.d.ts +28 -0
- package/dist/components/infield-button/InfieldButton.base.js +22 -0
- package/dist/components/infield-button/InfieldButton.base.js.map +1 -0
- package/dist/components/infield-button/InfieldButton.types.d.ts +13 -0
- package/dist/components/infield-button/InfieldButton.types.js +11 -0
- package/dist/components/infield-button/InfieldButton.types.js.map +1 -0
- package/dist/components/infield-button/index.d.ts +13 -0
- package/dist/components/infield-button/index.js +3 -0
- package/dist/components/meter/Meter.base.js +11 -9
- package/dist/components/meter/Meter.base.js.map +1 -1
- package/dist/components/popover/Popover.base.d.ts +1 -21
- package/dist/components/popover/Popover.base.js +57 -77
- package/dist/components/popover/Popover.base.js.map +1 -1
- package/dist/components/progress-circle/ProgressCircle.base.d.ts +0 -1
- package/dist/components/progress-circle/ProgressCircle.base.js +26 -22
- package/dist/components/progress-circle/ProgressCircle.base.js.map +1 -1
- package/dist/components/status-light/StatusLight.base.d.ts +1 -1
- package/dist/components/status-light/StatusLight.base.js +12 -9
- package/dist/components/status-light/StatusLight.base.js.map +1 -1
- package/dist/components/tabs/TabPanel.base.d.ts +1 -1
- package/dist/components/tabs/TabPanel.base.js.map +1 -1
- package/dist/components/tabs/Tabs.base.js +44 -32
- package/dist/components/tabs/Tabs.base.js.map +1 -1
- package/dist/components/tooltip/Tooltip.base.js +57 -22
- package/dist/components/tooltip/Tooltip.base.js.map +1 -1
- package/dist/controllers/color-controller/src/color-controller.js +45 -44
- package/dist/controllers/color-controller/src/color-controller.js.map +1 -1
- package/dist/controllers/drag-and-drop-controller/index.d.ts +12 -0
- package/dist/controllers/drag-and-drop-controller/index.js +2 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.d.ts +68 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js +56 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js.map +1 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.d.ts +1 -1
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.js.map +1 -1
- package/dist/controllers/index.d.ts +6 -2
- package/dist/controllers/index.js +15 -11
- package/dist/controllers/language-resolution.d.ts +1 -1
- package/dist/controllers/language-resolution.js.map +1 -1
- package/dist/controllers/page-scroll-lock-controller/index.d.ts +12 -0
- package/dist/controllers/page-scroll-lock-controller/index.js +2 -0
- package/dist/controllers/{page-scroll-lock.js → page-scroll-lock-controller/src/page-scroll-lock.js} +1 -1
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.js.map +1 -0
- package/dist/controllers/slot-presence-controller/index.d.ts +12 -0
- package/dist/controllers/slot-presence-controller/index.js +2 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.d.ts +57 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js +44 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js.map +1 -0
- package/dist/controllers/slot-text-controller/index.d.ts +12 -0
- package/dist/controllers/slot-text-controller/index.js +2 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.d.ts +92 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.js +53 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.js.map +1 -0
- package/dist/controllers/trigger-press-controller/index.d.ts +12 -0
- package/dist/controllers/trigger-press-controller/index.js +2 -0
- package/dist/controllers/trigger-press-controller/src/trigger-press-controller.d.ts +149 -0
- package/dist/controllers/trigger-press-controller/src/trigger-press-controller.js +43 -0
- package/dist/controllers/trigger-press-controller/src/trigger-press-controller.js.map +1 -0
- package/dist/directives/index.d.ts +1 -1
- package/dist/element/define-element.js +1 -1
- package/dist/element/define-element.js.map +1 -1
- package/dist/element/index.d.ts +1 -1
- package/dist/element/index.js +2 -2
- package/dist/element/spectrum-element.d.ts +58 -15
- package/dist/element/spectrum-element.js +56 -37
- package/dist/element/spectrum-element.js.map +1 -1
- package/dist/element/version.d.ts +3 -3
- package/dist/element/version.js +1 -1
- package/dist/element/version.js.map +1 -1
- package/dist/mixins/index.d.ts +0 -2
- package/dist/mixins/index.js +4 -6
- package/dist/mixins/linear-progress-mixin.d.ts +1 -2
- package/dist/mixins/linear-progress-mixin.js +35 -34
- package/dist/mixins/linear-progress-mixin.js.map +1 -1
- package/dist/mixins/pending-mixin.js +12 -11
- package/dist/mixins/pending-mixin.js.map +1 -1
- package/dist/mixins/sized-mixin.d.ts +28 -0
- package/dist/mixins/sized-mixin.js +6 -6
- package/dist/mixins/sized-mixin.js.map +1 -1
- package/dist/utils/dev-validation.d.ts +88 -0
- package/dist/utils/dev-validation.js +33 -0
- package/dist/utils/dev-validation.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +12 -10
- package/dist/utils/is-focus-visible-in-tree.d.ts +33 -0
- package/dist/utils/is-focus-visible-in-tree.js +11 -0
- package/dist/utils/is-focus-visible-in-tree.js.map +1 -0
- package/dist/utils/resolve-trigger.js.map +1 -1
- package/package.json +213 -18
- package/CHANGELOG.md +0 -125
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/defineProperty.js +0 -12
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/toPrimitive.js +0 -14
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/toPropertyKey.js +0 -9
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/typeof.js +0 -11
- package/dist/controllers/page-scroll-lock.js.map +0 -1
- package/dist/mixins/observe-slot-presence.d.ts +0 -12
- package/dist/mixins/observe-slot-presence.js +0 -40
- package/dist/mixins/observe-slot-presence.js.map +0 -1
- package/dist/mixins/observe-slot-text.d.ts +0 -11
- package/dist/mixins/observe-slot-text.js +0 -60
- package/dist/mixins/observe-slot-text.js.map +0 -1
- /package/dist/controllers/{page-scroll-lock.d.ts → page-scroll-lock-controller/src/page-scroll-lock.d.ts} +0 -0
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { LitElement as r } from "lit";
|
|
1
|
+
import { coreVersion as e, version as t } from "./version.js";
|
|
2
|
+
import { LitElement as n } from "lit";
|
|
4
3
|
//#region element/spectrum-element.ts
|
|
5
|
-
var i;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var t;
|
|
10
|
-
let n = e(this.getRootNode());
|
|
11
|
-
return (t = n == null ? void 0 : n.matches(":focus-visible")) == null ? !1 : t;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return n;
|
|
4
|
+
var r, i = class extends n {};
|
|
5
|
+
r = i, r.VERSION = t, r.CORE_VERSION = e;
|
|
6
|
+
function a(e, t, n, r) {
|
|
7
|
+
return `${e}:${t}:${n}:${r}`;
|
|
15
8
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
function o(e, t) {
|
|
10
|
+
let { message: n, url: r, localName: i, type: a, level: o, listedIssues: s, elements: c, count: l } = e, u = o === "deprecation" ? "DEPRECATION NOTICE: " : "", d = t ? c : c.slice(0, 1), f = "";
|
|
11
|
+
f = l === 1 ? d.length ? "\nAffected element:" : "" : `\n${l} <${i}> elements affected:`;
|
|
12
|
+
let p = [u + n + "\n" + s + f];
|
|
13
|
+
for (let e of d) p.push(e);
|
|
14
|
+
return p.push((d.length ? "\n\n" : "\n") + r + "\n", { data: {
|
|
15
|
+
localName: i,
|
|
16
|
+
type: a,
|
|
17
|
+
level: o,
|
|
18
|
+
count: l
|
|
19
|
+
} }), p;
|
|
20
|
+
}
|
|
21
|
+
function s(e, t, n) {
|
|
22
|
+
var r;
|
|
23
|
+
if (!t) {
|
|
24
|
+
if (e.countedDevModeWarning) return;
|
|
25
|
+
e.countedDevModeWarning = !0, e.count += 1;
|
|
26
|
+
return;
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
let i = (r = e.countedElements) == null ? e.countedElements = /* @__PURE__ */ new Set() : r;
|
|
29
|
+
i.has(t) || (i.add(t), e.count += 1, e.elements.length < n && e.elements.push(t));
|
|
30
|
+
}
|
|
31
|
+
if (process.env.NODE_ENV !== "production") {
|
|
32
|
+
var c, l, u;
|
|
24
33
|
let e = {
|
|
25
34
|
default: !1,
|
|
26
35
|
accessibility: !1,
|
|
@@ -31,36 +40,46 @@ if (i = o, i.VERSION = n, i.CORE_VERSION = t, process.env.NODE_ENV === "developm
|
|
|
31
40
|
medium: !1,
|
|
32
41
|
high: !1,
|
|
33
42
|
deprecation: !1
|
|
43
|
+
}, n = /* @__PURE__ */ new Map(), r = !1, i = () => {
|
|
44
|
+
r = !1, n.forEach((e, t) => {
|
|
45
|
+
console.warn(...o(e, !!window.__swc.verbose)), window.__swc.issuedWarnings.add(t);
|
|
46
|
+
}), n.clear();
|
|
34
47
|
};
|
|
35
48
|
window.__swc = {
|
|
36
49
|
...window.__swc,
|
|
37
50
|
DEBUG: !0,
|
|
38
|
-
ignoreWarningLocalNames: { ...((
|
|
51
|
+
ignoreWarningLocalNames: { ...((c = window.__swc) == null ? void 0 : c.ignoreWarningLocalNames) || {} },
|
|
39
52
|
ignoreWarningTypes: {
|
|
40
53
|
...e,
|
|
41
|
-
...((
|
|
54
|
+
...((l = window.__swc) == null ? void 0 : l.ignoreWarningTypes) || {}
|
|
42
55
|
},
|
|
43
56
|
ignoreWarningLevels: {
|
|
44
57
|
...t,
|
|
45
|
-
...((
|
|
58
|
+
...((u = window.__swc) == null ? void 0 : u.ignoreWarningLevels) || {}
|
|
46
59
|
},
|
|
47
60
|
issuedWarnings: /* @__PURE__ */ new Set(),
|
|
48
|
-
warn: (e, t,
|
|
49
|
-
let { localName:
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
warn: (e, t, o, { type: c = "api", level: l = "default", issues: u } = {}) => {
|
|
62
|
+
let { localName: d = "base" } = e || {}, f = a(d, c, l, t);
|
|
63
|
+
if (window.__swc.ignoreWarningLocalNames[d] || window.__swc.ignoreWarningTypes[c] || window.__swc.ignoreWarningLevels[l] || !window.__swc.verbose && window.__swc.issuedWarnings.has(f)) return;
|
|
64
|
+
let p = n.get(f);
|
|
65
|
+
if (!p) {
|
|
66
|
+
let e = "";
|
|
67
|
+
u && u.length && (u.unshift(""), e = u.join("\n - ") + "\n"), p = {
|
|
68
|
+
message: t,
|
|
69
|
+
url: o,
|
|
70
|
+
localName: d,
|
|
71
|
+
type: c,
|
|
72
|
+
level: l,
|
|
73
|
+
listedIssues: e,
|
|
74
|
+
elements: [],
|
|
75
|
+
count: 0
|
|
76
|
+
}, n.set(f, p);
|
|
77
|
+
}
|
|
78
|
+
s(p, e, 10), r || (r = !0, queueMicrotask(i));
|
|
60
79
|
}
|
|
61
|
-
}, window.__swc.warn(void 0, "Spectrum Web Components is in dev mode. Not recommended for production!", "https://
|
|
80
|
+
}, window.__swc.warn(void 0, "Spectrum Web Components is in dev mode. Not recommended for production!", "https://spectrum-web-components.adobe.com/dev-mode/", { type: "default" });
|
|
62
81
|
}
|
|
63
82
|
//#endregion
|
|
64
|
-
export {
|
|
83
|
+
export { i as SpectrumElement, o as buildGroupedWarningArgs, s as recordAffectedElement, a as warningId };
|
|
65
84
|
|
|
66
85
|
//# sourceMappingURL=spectrum-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectrum-element.js","names":[],"sources":["../../element/spectrum-element.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 { getActiveElement } from '../utils/get-active-element.js';\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\n /**\n * @internal\n */\n public hasVisibleFocusInTree(): boolean {\n const active = getActiveElement(\n this.getRootNode() as Document | ShadowRoot\n );\n\n return active?.matches(':focus-visible') ?? false;\n }\n }\n return SpectrumMixinElement;\n}\n\nexport class SpectrumElement extends SpectrumMixin(LitElement) {\n /**\n * @internal\n */\n static VERSION = version;\n\n /**\n * @internal\n */\n static CORE_VERSION = coreVersion;\n\n /**\n * @internal\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(intro + message + '\\n' + listedIssues + inspectElement);\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"],"mappings":";;;;;AA4BA,SAAgB,EACd,GACoC;CACpC,MAAM,UAA6B,EAAY;EAS7C,wBAAwC;;GACtC,IAAM,IAAS,EACb,KAAK,aAAa,CACnB;AAED,WAAA,IAAA,KAAA,OAAA,KAAA,IAAO,EAAQ,QAAQ,iBAAiB,KAAA,OAAI,KAAJ;;;AAG5C,QAAO;;AAGT,IAAa,IAAb,cAAqC,EAAc,EAAW,CAAC;CAc7D,IAAoB,MAAwC;;AAC1D,UAAA,IAAO,iBAAiB,KAAK,CAAC,cAAA,OAAa,QAAb;;;AAIlC,uBAfmB,oBAKK,GAUxB,QAAA,IAAA,aAA6B,eAAe;;CAC1C,IAAM,IAAqB;EACzB,SAAS;EACT,eAAe;EACf,KAAK;EACN,EACK,IAAsB;EAC1B,SAAS;EACT,KAAK;EACL,QAAQ;EACR,MAAM;EACN,aAAa;EACd;AA+DD,CA9DA,OAAO,QAAQ;EACb,GAAG,OAAO;EACV,OAAO;EACP,yBAAyB,EACvB,KAAA,IAAI,OAAO,UAAA,OAAA,KAAA,IAAA,EAAO,4BAA2B,EAAE,EAChD;EACD,oBAAoB;GAClB,GAAG;GACH,KAAA,IAAI,OAAO,UAAA,OAAA,KAAA,IAAA,EAAO,uBAAsB,EAAE;GAC3C;EACD,qBAAqB;GACnB,GAAG;GACH,KAAA,IAAI,OAAO,UAAA,OAAA,KAAA,IAAA,EAAO,wBAAuB,EAAE;GAC5C;EACD,gCAAgB,IAAI,KAAK;EACzB,OACE,GACA,GACA,GACA,EAAE,UAAO,OAAO,WAAQ,WAAW,cAAW,EAAE,KACvC;GACT,IAAM,EAAE,eAAY,WAAW,KAAW,EAAE,EACtC,IAAK,GAAG,EAAU,GAAG,EAAK,GAAG;AAUnC,OATI,CAAC,OAAO,MAAM,WAAW,OAAO,MAAM,eAAe,IAAI,EAAG,IAG5D,OAAO,MAAM,wBAAwB,MAGrC,OAAO,MAAM,mBAAmB,MAGhC,OAAO,MAAM,oBAAoB,GACnC;AAEF,UAAO,MAAM,eAAe,IAAI,EAAG;GACnC,IAAI,IAAe;AACnB,GAAI,KAAU,EAAO,WACnB,EAAO,QAAQ,GAAG,EAClB,IAAe,EAAO,KAAK,WAAW,GAAG;GAE3C,IAAM,IAAQ,MAAU,gBAAgB,yBAAyB,IAC3D,IAAiB,IACnB,gDACA,IACE,KAAc,IAAU,SAAS,QAAQ,IAAM,MAC/C,IAAsB,EAAE;AAY9B,GAXA,EAAS,KAAK,IAAQ,IAAU,OAAO,IAAe,EAAe,EACjE,KACF,EAAS,KAAK,EAAQ,EAExB,EAAS,KAAK,GAAY,EACxB,MAAM;IACJ;IACA;IACA;IACD,EACF,CAAC,EACF,QAAQ,KAAK,GAAG,EAAS;;EAE5B,EAED,OAAO,MAAM,KACX,KAAA,GACA,2EACA,kEACA,EAAE,MAAM,WAAW,CACpB"}
|
|
1
|
+
{"version":3,"file":"spectrum-element.js","names":[],"sources":["../../element/spectrum-element.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 } from 'lit';\n\nimport { coreVersion, version } from './version.js';\n\nexport class SpectrumElement extends LitElement {\n /**\n * @internal\n */\n static VERSION = version;\n\n /**\n * @internal\n */\n static CORE_VERSION = coreVersion;\n}\n\n/**\n * Builds the deduplication key for a dev-mode warning. The `message` is part of\n * the key so two distinct problems that share a `type`/`level` (the common\n * case) do not suppress each other; only a verbatim repeat of the same warning\n * is deduplicated. Exported so the dedup key can be unit tested without relying\n * on the `NODE_ENV`-gated `window.__swc` setup below.\n */\nexport function warningId(\n localName: string,\n type: WarningType,\n level: WarningLevel,\n message: string\n): BrandedSWCWarningID {\n return `${localName}:${type}:${level}:${message}` as BrandedSWCWarningID;\n}\n\n/**\n * A group of dev-mode warnings that share a `warningId`, collected within a\n * single microtask so they can be emitted as one console line with a count.\n */\ntype BatchedWarning = {\n message: string;\n url: string;\n localName: string;\n type: WarningType;\n level: WarningLevel;\n listedIssues: string;\n elements: HTMLElement[];\n count: number;\n\n /**\n * Elements already counted in this batch, keyed by identity. A repeated\n * `warn()` for an element already here does not bump `count` again.\n */\n countedElements?: Set<HTMLElement>;\n\n /**\n * Whether the dev-mode warning (the only warning with no element) has been\n * counted, so repeats of it collapse to one.\n */\n countedDevModeWarning?: boolean;\n};\n\n/**\n * Builds the `console.warn` arguments for a grouped dev warning: the message\n * and a count line, then the element ref(s) to inspect. By default one\n * representative element is shown; `verbose` shows every collected element\n * (already capped at collection time). Exported so the grouped output can be\n * unit tested without the `NODE_ENV`-gated `window.__swc` setup below.\n *\n * @internal\n */\nexport function buildGroupedWarningArgs(\n batch: BatchedWarning,\n verbose: boolean\n): unknown[] {\n const {\n message,\n url,\n localName,\n type,\n level,\n listedIssues,\n elements,\n count,\n } = batch;\n const intro = level === 'deprecation' ? 'DEPRECATION NOTICE: ' : '';\n const shown = verbose ? elements : elements.slice(0, 1);\n let countLine = '';\n if (count === 1) {\n countLine = shown.length ? '\\nAffected element:' : '';\n } else {\n countLine = `\\n${count} <${localName}> elements affected:`;\n }\n const args: unknown[] = [intro + message + '\\n' + listedIssues + countLine];\n for (const el of shown) {\n args.push(el);\n }\n args.push((shown.length ? '\\n\\n' : '\\n') + url + '\\n', {\n data: { localName, type, level, count },\n });\n return args;\n}\n\n/**\n * Records one warning occurrence into its batch, counting by element identity:\n * `count` becomes the number of distinct elements with this warning, not the\n * number of `warn()` calls. A host that warns once per child (same message,\n * same element) still counts as one affected element. `count` is uncapped;\n * `maxDisplayed` only limits how many element refs are kept for display.\n *\n * @param batch - Grouped-warning batch to record into.\n * @param element - Element the warning is about, or `undefined` for the\n * dev-mode warning, which is not about a specific element.\n * @param maxDisplayed - Cap on element refs kept for display; does not affect\n * `count`.\n * @internal\n */\nexport function recordAffectedElement(\n batch: BatchedWarning,\n element: HTMLElement | undefined,\n maxDisplayed: number\n): void {\n if (!element) {\n // The dev-mode warning is the only warning with no element; count it once\n // however often it fires.\n if (batch.countedDevModeWarning) {\n return;\n }\n batch.countedDevModeWarning = true;\n batch.count += 1;\n return;\n }\n const countedElements = (batch.countedElements ??= new Set<HTMLElement>());\n if (countedElements.has(element)) {\n return; // this element is already counted for the batch\n }\n countedElements.add(element);\n batch.count += 1;\n if (batch.elements.length < maxDisplayed) {\n batch.elements.push(element);\n }\n}\n\n// Enabled in every environment except production (the ecosystem convention);\n// a production build strips this block via dead-code elimination.\nif (process.env.NODE_ENV !== 'production') {\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\n // Grouped warnings: collect same-`warningId` warnings fired within one\n // microtask and emit a single console line with the total count. By default\n // one representative element is shown for inspection; `verbose` lists all\n // collected elements (capped at WARNING_ELEMENT_CAP).\n const WARNING_ELEMENT_CAP = 10;\n const batchedWarnings = new Map<BrandedSWCWarningID, BatchedWarning>();\n let flushScheduled = false;\n\n const flushWarnings = (): void => {\n flushScheduled = false;\n batchedWarnings.forEach((batch, id) => {\n console.warn(\n ...buildGroupedWarningArgs(batch, Boolean(window.__swc.verbose))\n );\n window.__swc.issuedWarnings.add(id);\n });\n batchedWarnings.clear();\n };\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 = warningId(localName, type, level, message);\n // Ignore filters short-circuit before any batching.\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 // Session dedup: each id emits one grouped line per session. `verbose`\n // bypasses it so every microtask flush re-emits.\n if (!window.__swc.verbose && window.__swc.issuedWarnings.has(id)) {\n return;\n }\n // Collect into the per-id batch; `flushWarnings` builds the grouped\n // message on the next microtask.\n let batch = batchedWarnings.get(id);\n if (!batch) {\n let listedIssues = '';\n if (issues && issues.length) {\n issues.unshift('');\n listedIssues = issues.join('\\n - ') + '\\n';\n }\n batch = {\n message,\n url,\n localName,\n type,\n level,\n listedIssues,\n elements: [],\n count: 0,\n };\n batchedWarnings.set(id, batch);\n }\n recordAffectedElement(batch, element, WARNING_ELEMENT_CAP);\n if (!flushScheduled) {\n flushScheduled = true;\n queueMicrotask(flushWarnings);\n }\n },\n };\n\n window.__swc.warn(\n undefined,\n 'Spectrum Web Components is in dev mode. Not recommended for production!',\n 'https://spectrum-web-components.adobe.com/dev-mode/',\n { type: 'default' }\n );\n}\n"],"mappings":";;;OAgBa,IAAb,cAAqC,EAAW;mBAI7B,oBAKK;AAUxB,SAAgB,EACd,GACA,GACA,GACA,GACqB;AACrB,QAAO,GAAG,EAAU,GAAG,EAAK,GAAG,EAAM,GAAG;;AAuC1C,SAAgB,EACd,GACA,GACW;CACX,IAAM,EACJ,YACA,QACA,cACA,SACA,UACA,iBACA,aACA,aACE,GACE,IAAQ,MAAU,gBAAgB,yBAAyB,IAC3D,IAAQ,IAAU,IAAW,EAAS,MAAM,GAAG,EAAE,EACnD,IAAY;AAChB,CAGE,IAHE,MAAU,IACA,E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A,OAAA,KAAA,IAAA,EAAO,uBAAsB,EAAE;GAC3C;EACD,qBAAqB;GACnB,GAAG;GACH,KAAA,IAAI,OAAO,UAAA,OAAA,KAAA,IAAA,EAAO,wBAAuB,EAAE;GAC5C;EACD,gCAAgB,IAAI,KAAK;EACzB,OACE,GACA,GACA,GACA,EAAE,UAAO,OAAO,WAAQ,WAAW,cAAW,EAAE,KACvC;GACT,IAAM,EAAE,eAAY,WAAW,KAAW,EAAE,EACtC,IAAK,EAAU,GAAW,GAAM,GAAO,EAAQ;AAarD,OAXI,OAAO,MAAM,wBAAwB,MAGrC,OAAO,MAAM,mBAAmB,MAGhC,OAAO,MAAM,oBAAoB,MAKjC,CAAC,OAAO,MAAM,WAAW,OAAO,MAAM,eAAe,IAAI,EAAG,CAC9D;GAIF,IAAI,IAAQ,EAAgB,IAAI,EAAG;AACnC,OAAI,CAAC,GAAO;IACV,IAAI,IAAe;AAenB,IAdI,KAAU,EAAO,WACnB,EAAO,QAAQ,GAAG,EAClB,IAAe,EAAO,KAAK,WAAW,GAAG,OAE3C,IAAQ;KACN;KACA;KACA;KACA;KACA;KACA;KACA,UAAU,EAAE;KACZ,OAAO;KACR,EACD,EAAgB,IAAI,GAAI,EAAM;;AAGhC,GADA,EAAsB,GAAO,GAAS,GAAoB,EACrD,MACH,IAAiB,IACjB,eAAe,EAAc;;EAGlC,EAED,OAAO,MAAM,KACX,KAAA,GACA,2EACA,uDACA,EAAE,MAAM,WAAW,CACpB"}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* The version of the
|
|
13
|
+
* The version of the gen2 Spectrum Web Components library.
|
|
14
14
|
*/
|
|
15
|
-
export declare const version = "2.0.0-beta.
|
|
15
|
+
export declare const version = "2.0.0-beta.4";
|
|
16
16
|
/**
|
|
17
17
|
* The version of the core base package.
|
|
18
18
|
*/
|
|
19
|
-
export declare const coreVersion = "2.0.0-beta.
|
|
19
|
+
export declare const coreVersion = "2.0.0-beta.4";
|
package/dist/element/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../element/version.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\n// Auto-generated from
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../element/version.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\n// Auto-generated from gen2/packages/core/package.json\n// Generation: gen2\n// DO NOT EDIT - This file is generated by scripts/generate-versions.js\n\n/**\n * The version of the gen2 Spectrum Web Components library.\n */\nexport const version = '2.0.0-beta.4';\n\n/**\n * The version of the core base package.\n */\nexport const coreVersion = '2.0.0-beta.4';\n"],"mappings":";AAmBA,IAAa,IAAU,gBAKV,IAAc"}
|
package/dist/mixins/index.d.ts
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export { DisabledMixin, type DisabledInterface } from './disabled-mixin.js';
|
|
13
13
|
export { LINEAR_PROGRESS_LABEL_POSITIONS, LINEAR_PROGRESS_STATIC_COLORS, LINEAR_PROGRESS_VALID_SIZES, LinearProgressMixin, type LinearProgressInterface, type LinearProgressLabelPosition, type LinearProgressSize, type LinearProgressStaticColor, } from './linear-progress-mixin.js';
|
|
14
|
-
export { ObserveSlotPresence, type SlotPresenceObservingInterface, } from './observe-slot-presence.js';
|
|
15
|
-
export { ObserveSlotText, type SlotTextObservingInterface, } from './observe-slot-text.js';
|
|
16
14
|
export { PendingMixin, type PendingInterface } from './pending-mixin.js';
|
|
17
15
|
export { DEFAULT_ELEMENT_SIZES, ELEMENT_SIZES, SizedMixin, } from './sized-mixin.js';
|
|
18
16
|
export type { DefaultElementSize, ElementSize, SizedElementConstructor, SizedElementInterface, } from './sized-mixin.js';
|
package/dist/mixins/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { DisabledMixin as e } from "./disabled-mixin.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { DEFAULT_ELEMENT_SIZES as c, ELEMENT_SIZES as l, SizedMixin as u } from "./sized-mixin.js";
|
|
7
|
-
export { c as DEFAULT_ELEMENT_SIZES, e as DisabledMixin, l as ELEMENT_SIZES, n as LINEAR_PROGRESS_LABEL_POSITIONS, r as LINEAR_PROGRESS_STATIC_COLORS, i as LINEAR_PROGRESS_VALID_SIZES, a as LinearProgressMixin, t as ObserveSlotPresence, o as ObserveSlotText, s as PendingMixin, u as SizedMixin };
|
|
2
|
+
import { LINEAR_PROGRESS_LABEL_POSITIONS as t, LINEAR_PROGRESS_STATIC_COLORS as n, LINEAR_PROGRESS_VALID_SIZES as r, LinearProgressMixin as i } from "./linear-progress-mixin.js";
|
|
3
|
+
import { PendingMixin as a } from "./pending-mixin.js";
|
|
4
|
+
import { DEFAULT_ELEMENT_SIZES as o, ELEMENT_SIZES as s, SizedMixin as c } from "./sized-mixin.js";
|
|
5
|
+
export { o as DEFAULT_ELEMENT_SIZES, e as DisabledMixin, s as ELEMENT_SIZES, t as LINEAR_PROGRESS_LABEL_POSITIONS, n as LINEAR_PROGRESS_STATIC_COLORS, r as LINEAR_PROGRESS_VALID_SIZES, i as LinearProgressMixin, a as PendingMixin, c as SizedMixin };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactiveElement } from 'lit';
|
|
2
|
-
import { SlotPresenceObservingInterface } from './observe-slot-presence.js';
|
|
3
2
|
type Constructor<T = Record<string, unknown>> = {
|
|
4
3
|
new (...args: any[]): T;
|
|
5
4
|
prototype: T;
|
|
@@ -10,7 +9,7 @@ export declare const LINEAR_PROGRESS_STATIC_COLORS: readonly ["white", "black"];
|
|
|
10
9
|
export type LinearProgressStaticColor = (typeof LINEAR_PROGRESS_STATIC_COLORS)[number];
|
|
11
10
|
export declare const LINEAR_PROGRESS_LABEL_POSITIONS: readonly ["top", "side"];
|
|
12
11
|
export type LinearProgressLabelPosition = (typeof LINEAR_PROGRESS_LABEL_POSITIONS)[number];
|
|
13
|
-
export interface LinearProgressInterface
|
|
12
|
+
export interface LinearProgressInterface {
|
|
14
13
|
value: number;
|
|
15
14
|
minValue: number;
|
|
16
15
|
maxValue: number;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { __decorate as e } from "../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
|
|
2
2
|
import { LanguageResolutionController as t } from "../controllers/language-resolution.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { SlotPresenceController as n } from "../controllers/slot-presence-controller/src/slot-presence-controller.js";
|
|
4
|
+
import { isDebug as r, validateEnum as i, warnIf as a } from "../utils/dev-validation.js";
|
|
5
|
+
import "../utils/index.js";
|
|
6
|
+
import { property as o } from "lit/decorators.js";
|
|
5
7
|
//#region mixins/linear-progress-mixin.ts
|
|
6
|
-
var
|
|
8
|
+
var s = [
|
|
7
9
|
"s",
|
|
8
10
|
"m",
|
|
9
11
|
"l",
|
|
10
12
|
"xl"
|
|
11
|
-
],
|
|
12
|
-
function
|
|
13
|
-
class
|
|
13
|
+
], c = ["white", "black"], l = ["top", "side"], u = { style: "percent" }, d = "[slot=\"label\"]", f = "[slot=\"description\"]", p = 0;
|
|
14
|
+
function m(s) {
|
|
15
|
+
class m extends s {
|
|
14
16
|
constructor(...e) {
|
|
15
|
-
super(...e), this.value = 0, this.minValue = 0, this.maxValue = 100, this.accessibleLabel = "", this.labelPosition = "top", this.languageResolver = new t(this), this._instanceId = ++
|
|
17
|
+
super(...e), this.slotPresence = new n(this, [d, f]), this.value = 0, this.minValue = 0, this.maxValue = 100, this.accessibleLabel = "", this.labelPosition = "top", this.languageResolver = new t(this), this._instanceId = ++p;
|
|
16
18
|
}
|
|
17
19
|
get docsHref() {
|
|
18
20
|
return `https://spectrum-web-components.adobe.com/?path=/docs/components-${this.localName.replace(/^swc-/, "")}--docs`;
|
|
@@ -24,10 +26,10 @@ function d(i) {
|
|
|
24
26
|
return `swc-linear-progress-description-${this._instanceId}`;
|
|
25
27
|
}
|
|
26
28
|
get hasLabelSlotContent() {
|
|
27
|
-
return this.
|
|
29
|
+
return this.slotPresence.getPresence(d);
|
|
28
30
|
}
|
|
29
31
|
get hasDescriptionSlotContent() {
|
|
30
|
-
return this.
|
|
32
|
+
return this.slotPresence.getPresence(f);
|
|
31
33
|
}
|
|
32
34
|
get sanitizedMin() {
|
|
33
35
|
let e = Number.isFinite(this.minValue) ? this.minValue : 0, t = Number.isFinite(this.maxValue) ? this.maxValue : 100;
|
|
@@ -49,7 +51,7 @@ function d(i) {
|
|
|
49
51
|
}
|
|
50
52
|
get formattedValue() {
|
|
51
53
|
if (this.valueLabel) return this.valueLabel;
|
|
52
|
-
let e = this.sanitizedMin, t = this.sanitizedMax, n = this.formatOptions && typeof this.formatOptions == "object" && Object.keys(this.formatOptions).length > 0 ? this.formatOptions :
|
|
54
|
+
let e = this.sanitizedMin, t = this.sanitizedMax, n = this.formatOptions && typeof this.formatOptions == "object" && Object.keys(this.formatOptions).length > 0 ? this.formatOptions : u, r = new Intl.NumberFormat(this.languageResolver.language, n);
|
|
53
55
|
if (n.style === "percent") {
|
|
54
56
|
let n = t === e ? 0 : (this.clampedValue - e) / (t - e);
|
|
55
57
|
return r.format(n);
|
|
@@ -57,58 +59,57 @@ function d(i) {
|
|
|
57
59
|
return r.format(this.clampedValue);
|
|
58
60
|
}
|
|
59
61
|
updated(e) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
super.updated(e), r() && this.warnMissingAccessibleName(), r() && (e.has("value") || e.has("minValue") || e.has("maxValue")) && this.warnValueOutOfRange(), e.has("labelPosition") && i(this, {
|
|
63
|
+
prop: "label-position",
|
|
64
|
+
value: this.labelPosition,
|
|
65
|
+
valid: l,
|
|
66
|
+
url: "https://spectrum-web-components.adobe.com/?path=/docs/components-meter--docs"
|
|
67
|
+
}), e.has("staticColor") && this.staticColor !== void 0 && i(this, {
|
|
68
|
+
prop: "static-color",
|
|
69
|
+
value: this.staticColor,
|
|
70
|
+
valid: c,
|
|
71
|
+
url: "https://spectrum-web-components.adobe.com/?path=/docs/components-meter--docs"
|
|
72
|
+
});
|
|
62
73
|
}
|
|
63
74
|
warnValueOutOfRange() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (!Number.isFinite(t) || t >= n && t <= r) {
|
|
67
|
-
this._hasWarnedValueOutOfRange = !1;
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this._hasWarnedValueOutOfRange || (this._hasWarnedValueOutOfRange = !0, (e = window.__swc) == null || e.warn(this, `<${this.localName}> "value" (${t}) is outside the [${n}, ${r}] range and was clamped to ${this.clampedValue}.`, this.docsHref, { issues: ["set \"value\" within the \"min-value\" and \"max-value\" range, or", "adjust \"min-value\"/\"max-value\" so the range includes the value."] }));
|
|
75
|
+
let e = this.value, t = this.sanitizedMin, n = this.sanitizedMax;
|
|
76
|
+
!Number.isFinite(e) || e >= t && e <= n || a(this, !0, `<${this.localName}> "value" (${e}) is outside the [${t}, ${n}] range and was clamped to ${this.clampedValue}.`, this.docsHref, { issues: ["set \"value\" within the \"min-value\" and \"max-value\" range, or", "adjust \"min-value\"/\"max-value\" so the range includes the value."] });
|
|
71
77
|
}
|
|
72
78
|
warnMissingAccessibleName() {
|
|
73
|
-
|
|
74
|
-
if (this.hasLabelSlotContent || this.accessibleLabel) {
|
|
75
|
-
this._hasWarnedNoAccessibleName = !1;
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this._hasWarnedNoAccessibleName = !0, (e = window.__swc) == null || e.warn(this, `<${this.localName}> requires an accessible name.`, this.docsHref, {
|
|
79
|
+
this.hasLabelSlotContent || this.accessibleLabel || a(this, !0, `<${this.localName}> requires an accessible name.`, this.docsHref, {
|
|
79
80
|
type: "accessibility",
|
|
80
81
|
issues: ["add visible label content via the \"label\" named slot, or", "set the \"accessible-label\" attribute (or \"accessibleLabel\" property) when there is no visible label."]
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
return e([
|
|
85
|
+
return e([o({
|
|
85
86
|
type: Number,
|
|
86
87
|
reflect: !0
|
|
87
|
-
})],
|
|
88
|
+
})], m.prototype, "value", void 0), e([o({
|
|
88
89
|
type: Number,
|
|
89
90
|
reflect: !0,
|
|
90
91
|
attribute: "min-value"
|
|
91
|
-
})],
|
|
92
|
+
})], m.prototype, "minValue", void 0), e([o({
|
|
92
93
|
type: Number,
|
|
93
94
|
reflect: !0,
|
|
94
95
|
attribute: "max-value"
|
|
95
|
-
})],
|
|
96
|
+
})], m.prototype, "maxValue", void 0), e([o({
|
|
96
97
|
type: String,
|
|
97
98
|
attribute: "accessible-label"
|
|
98
|
-
})],
|
|
99
|
+
})], m.prototype, "accessibleLabel", void 0), e([o({
|
|
99
100
|
type: String,
|
|
100
101
|
attribute: "value-label"
|
|
101
|
-
})],
|
|
102
|
+
})], m.prototype, "valueLabel", void 0), e([o({ attribute: !1 })], m.prototype, "formatOptions", void 0), e([o({
|
|
102
103
|
type: String,
|
|
103
104
|
reflect: !0,
|
|
104
105
|
attribute: "label-position"
|
|
105
|
-
})],
|
|
106
|
+
})], m.prototype, "labelPosition", void 0), e([o({
|
|
106
107
|
type: String,
|
|
107
108
|
reflect: !0,
|
|
108
109
|
attribute: "static-color"
|
|
109
|
-
})],
|
|
110
|
+
})], m.prototype, "staticColor", void 0), m;
|
|
110
111
|
}
|
|
111
112
|
//#endregion
|
|
112
|
-
export {
|
|
113
|
+
export { l as LINEAR_PROGRESS_LABEL_POSITIONS, c as LINEAR_PROGRESS_STATIC_COLORS, s as LINEAR_PROGRESS_VALID_SIZES, m as LinearProgressMixin };
|
|
113
114
|
|
|
114
115
|
//# sourceMappingURL=linear-progress-mixin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear-progress-mixin.js","names":[],"sources":["../../mixins/linear-progress-mixin.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, ReactiveElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { LanguageResolutionController } from '../controllers/language-resolution.js';\nimport {\n ObserveSlotPresence,\n type SlotPresenceObservingInterface,\n} from './observe-slot-presence.js';\nimport type { ElementSize } from './sized-mixin.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 const LINEAR_PROGRESS_VALID_SIZES = [\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies readonly ElementSize[];\nexport type LinearProgressSize = (typeof LINEAR_PROGRESS_VALID_SIZES)[number];\n\nexport const LINEAR_PROGRESS_STATIC_COLORS = ['white', 'black'] as const;\nexport type LinearProgressStaticColor =\n (typeof LINEAR_PROGRESS_STATIC_COLORS)[number];\n\nexport const LINEAR_PROGRESS_LABEL_POSITIONS = ['top', 'side'] as const;\nexport type LinearProgressLabelPosition =\n (typeof LINEAR_PROGRESS_LABEL_POSITIONS)[number];\n\nconst DEFAULT_FORMAT_OPTIONS: Intl.NumberFormatOptions = { style: 'percent' };\n\nconst LABEL_SLOT_SELECTOR = '[slot=\"label\"]';\nconst DESCRIPTION_SLOT_SELECTOR = '[slot=\"description\"]';\n\nexport interface LinearProgressInterface extends SlotPresenceObservingInterface {\n value: number;\n minValue: number;\n maxValue: number;\n accessibleLabel: string;\n valueLabel?: string;\n formatOptions?: Intl.NumberFormatOptions;\n labelPosition: LinearProgressLabelPosition;\n staticColor?: LinearProgressStaticColor;\n readonly sanitizedMin: number;\n readonly sanitizedMax: number;\n readonly clampedValue: number;\n readonly fillPercent: number;\n readonly formattedValue: string;\n readonly hasLabelSlotContent: boolean;\n readonly hasDescriptionSlotContent: boolean;\n readonly labelContainerId: string;\n readonly descriptionContainerId: string;\n}\n\nlet nextLinearProgressId = 0;\n\n/**\n * Mixin for linear progress components. Owns the typed property\n * declarations, sanitized range + value, locale formatting, light-DOM\n * slot presence tracking (so the shadow-DOM containers and slots can\n * be fully conditional), and the DEBUG accessible-name warning.\n *\n * Intentionally silent on `role` and animation — those stay in each\n * component's own base class.\n */\nexport function LinearProgressMixin<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<LinearProgressInterface> {\n class LinearProgressElement\n extends ObserveSlotPresence(constructor, [\n LABEL_SLOT_SELECTOR,\n DESCRIPTION_SLOT_SELECTOR,\n ])\n implements LinearProgressInterface\n {\n /**\n * Current value. Sanitized via `clampedValue` for rendering and\n * `aria-valuenow`.\n */\n @property({ type: Number, reflect: true })\n public value = 0;\n\n /**\n * Bottom of the value range.\n */\n @property({ type: Number, reflect: true, attribute: 'min-value' })\n public minValue = 0;\n\n /**\n * Top of the value range.\n */\n @property({ type: Number, reflect: true, attribute: 'max-value' })\n public maxValue = 100;\n\n /**\n * Rare-case accessible-name fallback used when there is no visible\n * `label` slot content (for example, a data grid of meters).\n * Renders into `aria-label` on the role element when set.\n */\n @property({ type: String, attribute: 'accessible-label' })\n public accessibleLabel = '';\n\n /**\n * Custom value text (e.g. `\"1 of 4\"`). Overrides the auto-formatted\n * value in both rendered text and `aria-valuetext`.\n */\n @property({ type: String, attribute: 'value-label' })\n public valueLabel?: string;\n\n /**\n * `Intl.NumberFormatOptions` used to format the visible value and\n * `aria-valuetext` when `valueLabel` is unset. JS property only —\n * no attribute (full `Intl.NumberFormat` pass-through).\n */\n @property({ attribute: false })\n public formatOptions?: Intl.NumberFormatOptions;\n\n /**\n * Position of the label relative to the bar.\n */\n @property({ type: String, reflect: true, attribute: 'label-position' })\n public labelPosition: LinearProgressLabelPosition = 'top';\n\n /**\n * Static color override for use on images or colored backgrounds.\n */\n @property({ type: String, reflect: true, attribute: 'static-color' })\n public staticColor?: LinearProgressStaticColor;\n\n private readonly languageResolver = new LanguageResolutionController(this);\n\n private readonly _instanceId = ++nextLinearProgressId;\n\n /**\n * @internal\n *\n * Documentation URL used in DEBUG warnings. Derived from the custom\n * element tag name so each concrete component gets an accurate link\n * with no per-subclass override needed (e.g. `swc-meter` →\n * `components-meter--docs`, `swc-progress-bar` →\n * `components-progress-bar--docs`).\n */\n protected get docsHref(): string {\n const name = this.localName.replace(/^swc-/, '');\n return `https://spectrum-web-components.adobe.com/?path=/docs/components-${name}--docs`;\n }\n\n /**\n * @internal\n */\n public get labelContainerId(): string {\n return `swc-linear-progress-label-${this._instanceId}`;\n }\n\n /**\n * @internal\n */\n public get descriptionContainerId(): string {\n return `swc-linear-progress-description-${this._instanceId}`;\n }\n\n /**\n * @internal\n */\n public get hasLabelSlotContent(): boolean {\n return this.getSlotContentPresence(LABEL_SLOT_SELECTOR);\n }\n\n /**\n * @internal\n */\n public get hasDescriptionSlotContent(): boolean {\n return this.getSlotContentPresence(DESCRIPTION_SLOT_SELECTOR);\n }\n\n /**\n * @internal\n *\n * Sanitized lower bound: falls back to 0 when `minValue` is non-finite,\n * and to the smaller of (min, max) when the two are reversed. ARIA\n * `aria-valuemin`, `aria-valuenow`, `aria-valuetext`, and the rendered\n * fill all read from the same sanitized range so screen-reader output\n * stays internally consistent.\n */\n public get sanitizedMin(): number {\n const min = Number.isFinite(this.minValue) ? this.minValue : 0;\n const max = Number.isFinite(this.maxValue) ? this.maxValue : 100;\n return Math.min(min, max);\n }\n\n /**\n * @internal\n *\n * Sanitized upper bound. See `sanitizedMin`.\n */\n public get sanitizedMax(): number {\n const min = Number.isFinite(this.minValue) ? this.minValue : 0;\n const max = Number.isFinite(this.maxValue) ? this.maxValue : 100;\n return Math.max(min, max);\n }\n\n /**\n * @internal\n */\n public get clampedValue(): number {\n const value = Number.isFinite(this.value) ? this.value : 0;\n return Math.min(this.sanitizedMax, Math.max(this.sanitizedMin, value));\n }\n\n /**\n * @internal\n */\n public get fillPercent(): number {\n const min = this.sanitizedMin;\n const max = this.sanitizedMax;\n if (max === min) {\n return 0;\n }\n const fraction = (this.clampedValue - min) / (max - min);\n return Math.min(100, Math.max(0, fraction * 100));\n }\n\n /**\n * @internal\n */\n public get formattedValue(): string {\n if (this.valueLabel) {\n return this.valueLabel;\n }\n const min = this.sanitizedMin;\n const max = this.sanitizedMax;\n // Treat anything that is not a plain options object (null, undefined,\n // empty string from Storybook helpers, etc.) as \"no override\" and\n // fall back to the percent default.\n const providedOptions =\n this.formatOptions &&\n typeof this.formatOptions === 'object' &&\n Object.keys(this.formatOptions).length > 0\n ? this.formatOptions\n : DEFAULT_FORMAT_OPTIONS;\n const formatter = new Intl.NumberFormat(\n this.languageResolver.language,\n providedOptions\n );\n // Percent style consumes a fraction; every other style consumes the\n // raw value.\n if (providedOptions.style === 'percent') {\n const fraction =\n max === min ? 0 : (this.clampedValue - min) / (max - min);\n return formatter.format(fraction);\n }\n return formatter.format(this.clampedValue);\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n\n // Locale changes are picked up automatically: the\n // `LanguageResolutionController` requests an update with\n // `languageResolverUpdatedSymbol`, which re-runs `render()`. The\n // render template reads `formattedValue` (which reads\n // `languageResolver.language` lazily), so the new locale is already\n // reflected in this render cycle. No second `requestUpdate()`\n // needed here.\n\n // Only re-evaluate the accessible-name fallback when the inputs\n // that determine it actually change, so the warning does not fire\n // on every property update during development.\n if (\n window.__swc?.DEBUG &&\n (changes.has('accessibleLabel') || !this._hasWarnedNoAccessibleName)\n ) {\n this.warnMissingAccessibleName();\n }\n\n // Surface a dev warning when `value` falls outside the resolved\n // range. The value is still clamped for rendering and ARIA, but the\n // clamp is otherwise silent, so flag it as a likely authoring error.\n if (\n window.__swc?.DEBUG &&\n (changes.has('value') ||\n changes.has('minValue') ||\n changes.has('maxValue'))\n ) {\n this.warnValueOutOfRange();\n }\n }\n\n private _hasWarnedNoAccessibleName = false;\n\n private _hasWarnedValueOutOfRange = false;\n\n private warnValueOutOfRange(): void {\n const value = this.value;\n const min = this.sanitizedMin;\n const max = this.sanitizedMax;\n if (!Number.isFinite(value) || (value >= min && value <= max)) {\n this._hasWarnedValueOutOfRange = false;\n return;\n }\n if (this._hasWarnedValueOutOfRange) {\n return;\n }\n this._hasWarnedValueOutOfRange = true;\n window.__swc?.warn(\n this,\n `<${this.localName}> \"value\" (${value}) is outside the [${min}, ${max}] range and was clamped to ${this.clampedValue}.`,\n this.docsHref,\n {\n issues: [\n 'set \"value\" within the \"min-value\" and \"max-value\" range, or',\n 'adjust \"min-value\"/\"max-value\" so the range includes the value.',\n ],\n }\n );\n }\n\n private warnMissingAccessibleName(): void {\n if (this.hasLabelSlotContent || this.accessibleLabel) {\n this._hasWarnedNoAccessibleName = false;\n return;\n }\n this._hasWarnedNoAccessibleName = true;\n window.__swc?.warn(\n this,\n `<${this.localName}> requires an accessible name.`,\n this.docsHref,\n {\n type: 'accessibility',\n issues: [\n 'add visible label content via the \"label\" named slot, or',\n 'set the \"accessible-label\" attribute (or \"accessibleLabel\" property) when there is no visible label.',\n ],\n }\n );\n }\n }\n return LinearProgressElement as unknown as T &\n Constructor<LinearProgressInterface>;\n}\n"],"mappings":";;;;;AA2BA,IAAa,IAA8B;CACzC;CACA;CACA;CACA;CACD,EAGY,IAAgC,CAAC,SAAS,QAAQ,EAIlD,IAAkC,CAAC,OAAO,OAAO,EAIxD,IAAmD,EAAE,OAAO,WAAW,EAEvE,IAAsB,oBACtB,IAA4B,0BAsB9B,IAAuB;AAW3B,SAAgB,EACd,GAC0C;CAC1C,MAAM,UACI,EAAoB,GAAa,CACvC,GACA,EACD,CAAC,CAEJ;;6BAMiB,mBAMG,mBAMA,4BAQO,yBAqB2B,+BAQhB,IAAI,EAA6B,KAAK,qBAE3C,EAAE,qCA6JI,qCAED;;EApJpC,IAAc,WAAmB;AAE/B,UAAO,oEADM,KAAK,UAAU,QAAQ,SAAS,GAAG,CACgC;;EAMlF,IAAW,mBAA2B;AACpC,UAAO,6BAA6B,KAAK;;EAM3C,IAAW,yBAAiC;AAC1C,UAAO,mCAAmC,KAAK;;EAMjD,IAAW,sBAA+B;AACxC,UAAO,KAAK,uBAAuB,EAAoB;;EAMzD,IAAW,4BAAqC;AAC9C,UAAO,KAAK,uBAAuB,EAA0B;;EAY/D,IAAW,eAAuB;GAChC,IAAM,IAAM,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,WAAW,GACvD,IAAM,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,WAAW;AAC7D,UAAO,KAAK,IAAI,GAAK,EAAI;;EAQ3B,IAAW,eAAuB;GAChC,IAAM,IAAM,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,WAAW,GACvD,IAAM,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,WAAW;AAC7D,UAAO,KAAK,IAAI,GAAK,EAAI;;EAM3B,IAAW,eAAuB;GAChC,IAAM,IAAQ,OAAO,SAAS,KAAK,MAAM,GAAG,KAAK,QAAQ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names":[],"sources":["../../mixins/linear-progress-mixin.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, ReactiveElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { LanguageResolutionController } from '../controllers/language-resolution.js';\nimport { SlotPresenceController } from '../controllers/slot-presence-controller/index.js';\nimport { isDebug, validateEnum, warnIf } from '../utils/index.js';\nimport type { ElementSize } from './sized-mixin.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 const LINEAR_PROGRESS_VALID_SIZES = [\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies readonly ElementSize[];\nexport type LinearProgressSize = (typeof LINEAR_PROGRESS_VALID_SIZES)[number];\n\nexport const LINEAR_PROGRESS_STATIC_COLORS = ['white', 'black'] as const;\nexport type LinearProgressStaticColor =\n (typeof LINEAR_PROGRESS_STATIC_COLORS)[number];\n\nexport const LINEAR_PROGRESS_LABEL_POSITIONS = ['top', 'side'] as const;\nexport type LinearProgressLabelPosition =\n (typeof LINEAR_PROGRESS_LABEL_POSITIONS)[number];\n\nconst DEFAULT_FORMAT_OPTIONS: Intl.NumberFormatOptions = { style: 'percent' };\n\nconst LABEL_SLOT_SELECTOR = '[slot=\"label\"]';\nconst DESCRIPTION_SLOT_SELECTOR = '[slot=\"description\"]';\n\nexport interface LinearProgressInterface {\n value: number;\n minValue: number;\n maxValue: number;\n accessibleLabel: string;\n valueLabel?: string;\n formatOptions?: Intl.NumberFormatOptions;\n labelPosition: LinearProgressLabelPosition;\n staticColor?: LinearProgressStaticColor;\n readonly sanitizedMin: number;\n readonly sanitizedMax: number;\n readonly clampedValue: number;\n readonly fillPercent: number;\n readonly formattedValue: string;\n readonly hasLabelSlotContent: boolean;\n readonly hasDescriptionSlotContent: boolean;\n readonly labelContainerId: string;\n readonly descriptionContainerId: string;\n}\n\nlet nextLinearProgressId = 0;\n\n/**\n * Mixin for linear progress components. Owns the typed property\n * declarations, sanitized range + value, locale formatting, light-DOM\n * slot presence tracking (so the shadow-DOM containers and slots can\n * be fully conditional), and the DEBUG accessible-name warning.\n *\n * Intentionally silent on `role` and animation — those stay in each\n * component's own base class.\n */\nexport function LinearProgressMixin<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<LinearProgressInterface> {\n class LinearProgressElement\n extends constructor\n implements LinearProgressInterface\n {\n /**\n * Observes the light-DOM `label` and `description` slots so the shadow-DOM\n * containers and slots can be fully conditional.\n */\n private readonly slotPresence = new SlotPresenceController(this, [\n LABEL_SLOT_SELECTOR,\n DESCRIPTION_SLOT_SELECTOR,\n ]);\n\n /**\n * Current value. Sanitized via `clampedValue` for rendering and\n * `aria-valuenow`.\n */\n @property({ type: Number, reflect: true })\n public value = 0;\n\n /**\n * Bottom of the value range.\n */\n @property({ type: Number, reflect: true, attribute: 'min-value' })\n public minValue = 0;\n\n /**\n * Top of the value range.\n */\n @property({ type: Number, reflect: true, attribute: 'max-value' })\n public maxValue = 100;\n\n /**\n * Rare-case accessible-name fallback used when there is no visible\n * `label` slot content (for example, a data grid of meters).\n * Renders into `aria-label` on the role element when set.\n */\n @property({ type: String, attribute: 'accessible-label' })\n public accessibleLabel = '';\n\n /**\n * Custom value text (e.g. `\"1 of 4\"`). Overrides the auto-formatted\n * value in both rendered text and `aria-valuetext`.\n */\n @property({ type: String, attribute: 'value-label' })\n public valueLabel?: string;\n\n /**\n * `Intl.NumberFormatOptions` used to format the visible value and\n * `aria-valuetext` when `valueLabel` is unset. JS property only —\n * no attribute (full `Intl.NumberFormat` pass-through).\n */\n @property({ attribute: false })\n public formatOptions?: Intl.NumberFormatOptions;\n\n /**\n * Position of the label relative to the bar.\n */\n @property({ type: String, reflect: true, attribute: 'label-position' })\n public labelPosition: LinearProgressLabelPosition = 'top';\n\n /**\n * Static color override for use on images or colored backgrounds.\n */\n @property({ type: String, reflect: true, attribute: 'static-color' })\n public staticColor?: LinearProgressStaticColor;\n\n private readonly languageResolver = new LanguageResolutionController(this);\n\n private readonly _instanceId = ++nextLinearProgressId;\n\n /**\n * @internal\n *\n * Documentation URL used in DEBUG warnings. Derived from the custom\n * element tag name so each concrete component gets an accurate link\n * with no per-subclass override needed (e.g. `swc-meter` →\n * `components-meter--docs`, `swc-progress-bar` →\n * `components-progress-bar--docs`).\n */\n protected get docsHref(): string {\n const name = this.localName.replace(/^swc-/, '');\n return `https://spectrum-web-components.adobe.com/?path=/docs/components-${name}--docs`;\n }\n\n /**\n * @internal\n */\n public get labelContainerId(): string {\n return `swc-linear-progress-label-${this._instanceId}`;\n }\n\n /**\n * @internal\n */\n public get descriptionContainerId(): string {\n return `swc-linear-progress-description-${this._instanceId}`;\n }\n\n /**\n * @internal\n */\n public get hasLabelSlotContent(): boolean {\n return this.slotPresence.getPresence(LABEL_SLOT_SELECTOR);\n }\n\n /**\n * @internal\n */\n public get hasDescriptionSlotContent(): boolean {\n return this.slotPresence.getPresence(DESCRIPTION_SLOT_SELECTOR);\n }\n\n /**\n * @internal\n *\n * Sanitized lower bound: falls back to 0 when `minValue` is non-finite,\n * and to the smaller of (min, max) when the two are reversed. ARIA\n * `aria-valuemin`, `aria-valuenow`, `aria-valuetext`, and the rendered\n * fill all read from the same sanitized range so screen-reader output\n * stays internally consistent.\n */\n public get sanitizedMin(): number {\n const min = Number.isFinite(this.minValue) ? this.minValue : 0;\n const max = Number.isFinite(this.maxValue) ? this.maxValue : 100;\n return Math.min(min, max);\n }\n\n /**\n * @internal\n *\n * Sanitized upper bound. See `sanitizedMin`.\n */\n public get sanitizedMax(): number {\n const min = Number.isFinite(this.minValue) ? this.minValue : 0;\n const max = Number.isFinite(this.maxValue) ? this.maxValue : 100;\n return Math.max(min, max);\n }\n\n /**\n * @internal\n */\n public get clampedValue(): number {\n const value = Number.isFinite(this.value) ? this.value : 0;\n return Math.min(this.sanitizedMax, Math.max(this.sanitizedMin, value));\n }\n\n /**\n * @internal\n */\n public get fillPercent(): number {\n const min = this.sanitizedMin;\n const max = this.sanitizedMax;\n if (max === min) {\n return 0;\n }\n const fraction = (this.clampedValue - min) / (max - min);\n return Math.min(100, Math.max(0, fraction * 100));\n }\n\n /**\n * @internal\n */\n public get formattedValue(): string {\n if (this.valueLabel) {\n return this.valueLabel;\n }\n const min = this.sanitizedMin;\n const max = this.sanitizedMax;\n // Treat anything that is not a plain options object (null, undefined,\n // empty string from Storybook helpers, etc.) as \"no override\" and\n // fall back to the percent default.\n const providedOptions =\n this.formatOptions &&\n typeof this.formatOptions === 'object' &&\n Object.keys(this.formatOptions).length > 0\n ? this.formatOptions\n : DEFAULT_FORMAT_OPTIONS;\n const formatter = new Intl.NumberFormat(\n this.languageResolver.language,\n providedOptions\n );\n // Percent style consumes a fraction; every other style consumes the\n // raw value.\n if (providedOptions.style === 'percent') {\n const fraction =\n max === min ? 0 : (this.clampedValue - min) / (max - min);\n return formatter.format(fraction);\n }\n return formatter.format(this.clampedValue);\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n\n // Locale changes are picked up automatically: the\n // `LanguageResolutionController` requests an update with\n // `languageResolverUpdatedSymbol`, which re-runs `render()`. The\n // render template reads `formattedValue` (which reads\n // `languageResolver.language` lazily), so the new locale is already\n // reflected in this render cycle. No second `requestUpdate()`\n // needed here.\n\n // The accessible name can come from the `accessibleLabel` property or the\n // label slot (tracked by a slot controller that requests an update without\n // surfacing a changed property), so re-check on every dev render and let\n // the warning dedup handle repeats rather than gating on one property.\n if (isDebug()) {\n this.warnMissingAccessibleName();\n }\n\n // Surface a dev warning when `value` falls outside the resolved\n // range. The value is still clamped for rendering and ARIA, but the\n // clamp is otherwise silent, so flag it as a likely authoring error.\n if (\n isDebug() &&\n (changes.has('value') ||\n changes.has('minValue') ||\n changes.has('maxValue'))\n ) {\n this.warnValueOutOfRange();\n }\n\n if (changes.has('labelPosition')) {\n validateEnum(this, {\n prop: 'label-position',\n value: this.labelPosition,\n valid: LINEAR_PROGRESS_LABEL_POSITIONS,\n url: 'https://spectrum-web-components.adobe.com/?path=/docs/components-meter--docs',\n });\n }\n\n if (changes.has('staticColor') && this.staticColor !== undefined) {\n validateEnum(this, {\n prop: 'static-color',\n value: this.staticColor,\n valid: LINEAR_PROGRESS_STATIC_COLORS,\n url: 'https://spectrum-web-components.adobe.com/?path=/docs/components-meter--docs',\n });\n }\n }\n\n private warnValueOutOfRange(): void {\n const value = this.value;\n const min = this.sanitizedMin;\n const max = this.sanitizedMax;\n // Early return when the value is valid so the message is not built on\n // every in-range render.\n if (!Number.isFinite(value) || (value >= min && value <= max)) {\n return;\n }\n warnIf(\n this,\n true,\n `<${this.localName}> \"value\" (${value}) is outside the [${min}, ${max}] range and was clamped to ${this.clampedValue}.`,\n this.docsHref,\n {\n issues: [\n 'set \"value\" within the \"min-value\" and \"max-value\" range, or',\n 'adjust \"min-value\"/\"max-value\" so the range includes the value.',\n ],\n }\n );\n }\n\n private warnMissingAccessibleName(): void {\n // Early return when a name is present so the message is not built on\n // every render (this runs unconditionally in dev).\n if (this.hasLabelSlotContent || this.accessibleLabel) {\n return;\n }\n warnIf(\n this,\n true,\n `<${this.localName}> requires an accessible name.`,\n this.docsHref,\n {\n type: 'accessibility',\n issues: [\n 'add visible label content via the \"label\" named slot, or',\n 'set the \"accessible-label\" attribute (or \"accessibleLabel\" property) when there is no visible label.',\n ],\n }\n );\n }\n }\n return LinearProgressElement as unknown as T &\n Constructor<LinearProgressInterface>;\n}\n"],"mappings":";;;;;;;AAyBA,IAAa,IAA8B;CACzC;CACA;CACA;CACA;CACD,EAGY,IAA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CACF;;EAGH,4BAA0C;AAGpC,QAAK,uBAAuB,KAAK,mBAGrC,EACE,MACA,IACA,IAAI,KAAK,UAAU,iCACnB,KAAK,UACL;IACE,MAAM;IACN,QAAQ,CACN,8DACA,2GACD;IACF,CACF;;;AAGL,WA7QG,EAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,CAAC,CAAA,EAAA,EAAA,WAAA,SAAA,KAAA,EAAA,KAMzC,EAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,WAAW;EAAa,CAAC,CAAA,EAAA,EAAA,WAAA,YAAA,KAAA,EAAA,KAMjE,EAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,WAAW;EAAa,CAAC,CAAA,EAAA,EAAA,WAAA,YAAA,KAAA,EAAA,KAQjE,EAAS;EAAE,MAAM;EAAQ,WAAW;EAAoB,CAAC,CAAA,EAAA,EAAA,WAAA,mBAAA,KAAA,EAAA,KAOzD,EAAS;EAAE,MAAM;EAAQ,WAAW;EAAe,CAAC,CAAA,EAAA,EAAA,WAAA,cAAA,KAAA,EAAA,KAQpD,EAAS,EAAE,WAAW,IAAO,CAAC,CAAA,EAAA,EAAA,WAAA,iBAAA,KAAA,EAAA,KAM9B,EAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,WAAW;EAAkB,CAAC,CAAA,EAAA,EAAA,WAAA,iBAAA,KAAA,EAAA,KAMtE,EAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,WAAW;EAAgB,CAAC,CAAA,EAAA,EAAA,WAAA,eAAA,KAAA,EAAA,EA8NhE"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { __decorate as e } from "../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
|
|
2
|
-
import {
|
|
2
|
+
import { warnIf as t } from "../utils/dev-validation.js";
|
|
3
|
+
import "../utils/index.js";
|
|
4
|
+
import { PendingController as n } from "../controllers/pending-controller/src/pending-controller.js";
|
|
3
5
|
import "../controllers/pending-controller/index.js";
|
|
4
|
-
import { property as
|
|
6
|
+
import { property as r } from "lit/decorators.js";
|
|
5
7
|
//#region mixins/pending-mixin.ts
|
|
6
|
-
function
|
|
7
|
-
class
|
|
8
|
+
function i(i) {
|
|
9
|
+
class a extends i {
|
|
8
10
|
constructor(...e) {
|
|
9
|
-
super(...e), this.pending = !1, this._pendingController = new
|
|
11
|
+
super(...e), this.pending = !1, this._pendingController = new n(this, { resolveAccessibleName: () => {
|
|
10
12
|
var e, t;
|
|
11
13
|
return (e = this.accessibleLabel) == null ? ((t = this.textContent) == null ? void 0 : t.trim()) || null : e;
|
|
12
14
|
} }), this._suppressPendingActivation = (e) => {
|
|
@@ -29,21 +31,20 @@ function r(r) {
|
|
|
29
31
|
this.removeEventListener("click", this._suppressPendingActivation, !0), super.disconnectedCallback();
|
|
30
32
|
}
|
|
31
33
|
update(e) {
|
|
32
|
-
var t;
|
|
33
34
|
super.update(e);
|
|
34
35
|
let n = "disabled" in this && this.disabled === !0;
|
|
35
|
-
(
|
|
36
|
+
t(this, this.pending && n, `<${this.localName}> should not set both "pending" and "disabled" simultaneously. Use "pending" to keep the element focusable while unavailable, or "disabled" to fully remove it from the tab order.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-button--docs", { issues: ["pending + disabled"] });
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
return e([
|
|
39
|
+
return e([r({
|
|
39
40
|
type: Boolean,
|
|
40
41
|
reflect: !0
|
|
41
|
-
})],
|
|
42
|
+
})], a.prototype, "pending", void 0), e([r({
|
|
42
43
|
type: String,
|
|
43
44
|
attribute: "pending-label"
|
|
44
|
-
})],
|
|
45
|
+
})], a.prototype, "pendingLabel", void 0), a;
|
|
45
46
|
}
|
|
46
47
|
//#endregion
|
|
47
|
-
export {
|
|
48
|
+
export { i as PendingMixin };
|
|
48
49
|
|
|
49
50
|
//# sourceMappingURL=pending-mixin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-mixin.js","names":[],"sources":["../../mixins/pending-mixin.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 { PropertyValues, ReactiveElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { PendingController } from '../controllers/pending-controller/index.js';\nimport type { PendingSpinnerResult } from '../directives/pending-spinner/index.js';\n\n// Abstract-capable so the mixin can be applied over abstract base classes such\n// as `ButtonBase`; `new` alone cannot construct an abstract class.\ntype Constructor<T = Record<string, unknown>> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract new (...args: any[]) => T;\n\n/** The API {@link PendingMixin} adds to its host. */\nexport interface PendingInterface {\n pending: boolean;\n pendingLabel?: string;\n readonly pendingActive: boolean;\n getPendingAccessibleName(): string;\n renderPendingState(): PendingSpinnerResult;\n}\n\n/**\n * A mixin that adds the pending (busy) state to a host: the reactive `pending`\n * and `pending-label` properties, a {@link PendingController} for the delayed\n * visual / inline-size freeze / accessible-name derivation, and capture-phase\n * click suppression so activation is blocked while pending.\n *\n * The host stays focusable while pending; the mixin never sets the native\n * `disabled` attribute. The host's template is responsible for applying\n * `aria-disabled` and the pending `aria-label` (read from\n * {@link PendingInterface.getPendingAccessibleName}), and for rendering the\n * spinner with the `renderPendingSpinner` directive.\n *\n * The busy accessible name is derived from the host's optional\n * `accessibleLabel` when present, otherwise from trimmed `textContent`.\n *\n * @example\n * ```typescript\n * class MyButton extends PendingMixin(SpectrumElement) {\n * render() {\n * return html`<button\n * aria-disabled=${ifDefined(this.pending ? 'true' : undefined)}\n * aria-label=${ifDefined(this.pending ? this.getPendingAccessibleName() : this.accessibleLabel)}\n * >\n * <slot></slot>\n * ${this.renderPendingState()}\n * </button>`;\n * }\n * }\n * ```\n */\nexport function PendingMixin<\n T extends Constructor<ReactiveElement & { accessibleLabel?: string }>,\n>(constructor: T): T & Constructor<PendingInterface> {\n abstract class PendingElement\n extends constructor\n implements PendingInterface\n {\n /**\n * Whether the element is in a pending (busy) state. The element remains\n * focusable but activation is suppressed.\n */\n @property({ type: Boolean, reflect: true })\n public pending = false;\n\n /**\n * Custom accessible label used during the pending state. When omitted, the\n * pending label is derived from the resolved non-busy accessible name plus\n * a busy suffix (e.g. \"Save, busy\").\n */\n @property({ type: String, attribute: 'pending-label' })\n public pendingLabel?: string;\n\n private _pendingController = new PendingController(this, {\n resolveAccessibleName: () =>\n this.accessibleLabel ?? (this.textContent?.trim() || null),\n });\n\n /**\n * Whether the delayed busy visual is active. Read this in `render()` to\n * apply the busy styling.\n */\n public get pendingActive(): boolean {\n return this._pendingController.pendingActive;\n }\n\n /** Derives the pending-state accessible label. */\n public getPendingAccessibleName(): string {\n return this._pendingController.getPendingAccessibleName();\n }\n\n /**\n * Renders the pending spinner for the current state, via the controller.\n * Lets hosts render the indicator with `${this.renderPendingState()}` and no\n * separate directive import.\n */\n public renderPendingState(): PendingSpinnerResult {\n return this._pendingController.renderPendingState();\n }\n\n /**\n * Suppresses click activation while pending. Capture phase so slotted\n * light-DOM clicks are suppressed before host listeners run.\n */\n private readonly _suppressPendingActivation = (event: Event): void => {\n if (this.pending) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('click', this._suppressPendingActivation, true);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this._suppressPendingActivation, true);\n super.disconnectedCallback();\n }\n\n protected override update(changedProperties: PropertyValues): void {\n super.update(changedProperties);\n // Guard the `disabled` read with an `in` check rather than a cast: not\n // every host that applies this mixin necessarily has a `disabled`\n // property.\n const hasDisabled = 'disabled' in this && this.disabled === true;\n
|
|
1
|
+
{"version":3,"file":"pending-mixin.js","names":[],"sources":["../../mixins/pending-mixin.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 { PropertyValues, ReactiveElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { PendingController } from '../controllers/pending-controller/index.js';\nimport type { PendingSpinnerResult } from '../directives/pending-spinner/index.js';\nimport { warnIf } from '../utils/index.js';\n\n// Abstract-capable so the mixin can be applied over abstract base classes such\n// as `ButtonBase`; `new` alone cannot construct an abstract class.\ntype Constructor<T = Record<string, unknown>> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract new (...args: any[]) => T;\n\n/** The API {@link PendingMixin} adds to its host. */\nexport interface PendingInterface {\n pending: boolean;\n pendingLabel?: string;\n readonly pendingActive: boolean;\n getPendingAccessibleName(): string;\n renderPendingState(): PendingSpinnerResult;\n}\n\n/**\n * A mixin that adds the pending (busy) state to a host: the reactive `pending`\n * and `pending-label` properties, a {@link PendingController} for the delayed\n * visual / inline-size freeze / accessible-name derivation, and capture-phase\n * click suppression so activation is blocked while pending.\n *\n * The host stays focusable while pending; the mixin never sets the native\n * `disabled` attribute. The host's template is responsible for applying\n * `aria-disabled` and the pending `aria-label` (read from\n * {@link PendingInterface.getPendingAccessibleName}), and for rendering the\n * spinner with the `renderPendingSpinner` directive.\n *\n * The busy accessible name is derived from the host's optional\n * `accessibleLabel` when present, otherwise from trimmed `textContent`.\n *\n * @example\n * ```typescript\n * class MyButton extends PendingMixin(SpectrumElement) {\n * render() {\n * return html`<button\n * aria-disabled=${ifDefined(this.pending ? 'true' : undefined)}\n * aria-label=${ifDefined(this.pending ? this.getPendingAccessibleName() : this.accessibleLabel)}\n * >\n * <slot></slot>\n * ${this.renderPendingState()}\n * </button>`;\n * }\n * }\n * ```\n */\nexport function PendingMixin<\n T extends Constructor<ReactiveElement & { accessibleLabel?: string }>,\n>(constructor: T): T & Constructor<PendingInterface> {\n abstract class PendingElement\n extends constructor\n implements PendingInterface\n {\n /**\n * Whether the element is in a pending (busy) state. The element remains\n * focusable but activation is suppressed.\n */\n @property({ type: Boolean, reflect: true })\n public pending = false;\n\n /**\n * Custom accessible label used during the pending state. When omitted, the\n * pending label is derived from the resolved non-busy accessible name plus\n * a busy suffix (e.g. \"Save, busy\").\n */\n @property({ type: String, attribute: 'pending-label' })\n public pendingLabel?: string;\n\n private _pendingController = new PendingController(this, {\n resolveAccessibleName: () =>\n this.accessibleLabel ?? (this.textContent?.trim() || null),\n });\n\n /**\n * Whether the delayed busy visual is active. Read this in `render()` to\n * apply the busy styling.\n */\n public get pendingActive(): boolean {\n return this._pendingController.pendingActive;\n }\n\n /** Derives the pending-state accessible label. */\n public getPendingAccessibleName(): string {\n return this._pendingController.getPendingAccessibleName();\n }\n\n /**\n * Renders the pending spinner for the current state, via the controller.\n * Lets hosts render the indicator with `${this.renderPendingState()}` and no\n * separate directive import.\n */\n public renderPendingState(): PendingSpinnerResult {\n return this._pendingController.renderPendingState();\n }\n\n /**\n * Suppresses click activation while pending. Capture phase so slotted\n * light-DOM clicks are suppressed before host listeners run.\n */\n private readonly _suppressPendingActivation = (event: Event): void => {\n if (this.pending) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('click', this._suppressPendingActivation, true);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this._suppressPendingActivation, true);\n super.disconnectedCallback();\n }\n\n protected override update(changedProperties: PropertyValues): void {\n super.update(changedProperties);\n // Guard the `disabled` read with an `in` check rather than a cast: not\n // every host that applies this mixin necessarily has a `disabled`\n // property.\n const hasDisabled = 'disabled' in this && this.disabled === true;\n warnIf(\n this,\n this.pending && hasDisabled,\n `<${this.localName}> should not set both \"pending\" and \"disabled\" simultaneously. Use \"pending\" to keep the element focusable while unavailable, or \"disabled\" to fully remove it from the tab order.`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-button--docs',\n { issues: ['pending + disabled'] }\n );\n }\n }\n return PendingElement as unknown as T & Constructor<PendingInterface>;\n}\n"],"mappings":";;;;;;;AAgEA,SAAgB,EAEd,GAAmD;CACnD,MAAe,UACL,EAEV;;+BAMmB,8BAUY,IAAI,EAAkB,MAAM,EACvD,6BACE;;qBAAK,oBAAA,SAAA,IAAoB,KAAK,gBAAA,OAAA,KAAA,IAAA,EAAa,MAAM,KAAI,OAAhD;MACR,CAAC,qCA4B6C,MAAuB;AACpE,IAAI,KAAK,YACP,EAAM,gBAAgB,EACtB,EAAM,0BAA0B;;;EAzBpC,IAAW,gBAAyB;AAClC,UAAO,KAAK,mBAAmB;;EAIjC,2BAA0C;AACxC,UAAO,KAAK,mBAAmB,0BAA0B;;EAQ3D,qBAAkD;AAChD,UAAO,KAAK,mBAAmB,oBAAoB;;EAcrD,oBAA0C;AAExC,GADA,MAAM,mBAAmB,EACzB,KAAK,iBAAiB,SAAS,KAAK,4BAA4B,GAAK;;EAGvE,uBAA6C;AAE3C,GADA,KAAK,oBAAoB,SAAS,KAAK,4BAA4B,GAAK,EACxE,MAAM,sBAAsB;;EAG9B,OAA0B,GAAyC;AACjE,SAAM,OAAO,EAAkB;GAI/B,IAAM,IAAc,cAAc,QAAQ,KAAK,aAAa;AAC5D,KACE,MACA,KAAK,WAAW,GAChB,IAAI,KAAK,UAAU,qLACnB,iFACA,EAAE,QAAQ,CAAC,qBAAqB,EAAE,CACnC;;;AAGL,WA1EG,EAAS;EAAE,MAAM;EAAS,SAAS;EAAM,CAAC,CAAA,EAAA,EAAA,WAAA,WAAA,KAAA,EAAA,KAQ1C,EAAS;EAAE,MAAM;EAAQ,WAAW;EAAiB,CAAC,CAAA,EAAA,EAAA,WAAA,gBAAA,KAAA,EAAA,EAkElD"}
|
|
@@ -12,7 +12,35 @@ export interface SizedElementInterface {
|
|
|
12
12
|
}
|
|
13
13
|
export interface SizedElementConstructor {
|
|
14
14
|
readonly VALID_SIZES: readonly ElementSize[];
|
|
15
|
+
readonly NO_DEFAULT_SIZE: boolean;
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Mixes size-awareness into a Lit `ReactiveElement` subclass.
|
|
19
|
+
*
|
|
20
|
+
* ## Why NO_DEFAULT_SIZE is a static rather than a closure variable
|
|
21
|
+
*
|
|
22
|
+
* The original implementation captured `noDefaultSize` in a closure at call
|
|
23
|
+
* time. That works when a component applies SizedMixin directly to a plain
|
|
24
|
+
* base (e.g. `SizedMixin(SpectrumElement, { noDefaultSize: true })`), but
|
|
25
|
+
* breaks silently when a component extends a base that is already SizedMixin'd.
|
|
26
|
+
*
|
|
27
|
+
* Consider InfieldButton extending ButtonBase:
|
|
28
|
+
* - ButtonBase = SizedMixin(SpectrumElement, {}) — closure captures noDefaultSize=false
|
|
29
|
+
* - InfieldButtonBase extends ButtonBase
|
|
30
|
+
*
|
|
31
|
+
* Even if a second SizedMixin wrapper is applied with noDefaultSize=true, calling
|
|
32
|
+
* super.update() reaches the inner ButtonBase SizedMixin, whose update() still
|
|
33
|
+
* reads noDefaultSize=false from its closure and writes size="m" to the DOM.
|
|
34
|
+
* Likewise, when a parent calls removeAttribute('size'), the inherited setter
|
|
35
|
+
* reads the inner closure's fallbackSize='m' and immediately re-sets the attribute.
|
|
36
|
+
*
|
|
37
|
+
* Making NO_DEFAULT_SIZE a static property solves both problems: the setter and
|
|
38
|
+
* update() read this.constructor.NO_DEFAULT_SIZE, which follows the prototype
|
|
39
|
+
* chain to the leaf class. A subclass like InfieldButtonBase only needs to
|
|
40
|
+
* declare `static override readonly NO_DEFAULT_SIZE = true` — no mixin
|
|
41
|
+
* re-wrapping, no lifecycle interception, and the correct value is read by every
|
|
42
|
+
* SizedMixin layer in the chain.
|
|
43
|
+
*/
|
|
16
44
|
export declare function SizedMixin<T extends Constructor<ReactiveElement>>(constructor: T, { validSizes, noDefaultSize, defaultSize, }?: {
|
|
17
45
|
validSizes?: readonly ElementSize[];
|
|
18
46
|
noDefaultSize?: boolean;
|
|
@@ -25,16 +25,16 @@ function i(n, { validSizes: i = [...r], noDefaultSize: a, defaultSize: o = "m" }
|
|
|
25
25
|
return this._size || o;
|
|
26
26
|
}
|
|
27
27
|
set size(e) {
|
|
28
|
-
let t =
|
|
29
|
-
if (
|
|
30
|
-
let
|
|
31
|
-
this._size =
|
|
28
|
+
let t = this.constructor, n = t.NO_DEFAULT_SIZE ? null : o, r = e && e.toLocaleLowerCase(), i = t.VALID_SIZES.includes(r) ? r : n;
|
|
29
|
+
if (i && this.setAttribute("size", i), this._size === i) return;
|
|
30
|
+
let a = this._size;
|
|
31
|
+
this._size = i, this.requestUpdate("size", a);
|
|
32
32
|
}
|
|
33
33
|
update(e) {
|
|
34
|
-
!this.hasAttribute("size") && !
|
|
34
|
+
!this.hasAttribute("size") && !this.constructor.NO_DEFAULT_SIZE && this.setAttribute("size", this.size), super.update(e);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return s = c, s.VALID_SIZES = i, e([t({ type: String })], c.prototype, "size", null), c;
|
|
37
|
+
return s = c, s.VALID_SIZES = i, s.NO_DEFAULT_SIZE = a == null ? !1 : a, e([t({ type: String })], c.prototype, "size", null), c;
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
export { r as DEFAULT_ELEMENT_SIZES, n as ELEMENT_SIZES, i as SizedMixin };
|