@spectrum-web-components/reactive-controllers 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/reactive-controllers",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -89,8 +89,8 @@
89
89
  "css"
90
90
  ],
91
91
  "dependencies": {
92
- "@spectrum-web-components/progress-circle": "1.8.0",
93
- "colorjs.io": "^0.5.2",
92
+ "@spectrum-web-components/progress-circle": "1.9.0",
93
+ "colorjs.io": "0.5.2",
94
94
  "lit": "^2.5.0 || ^3.1.3"
95
95
  },
96
96
  "types": "./src/index.d.ts",
@@ -4,7 +4,7 @@ export const languageResolverUpdatedSymbol = Symbol(
4
4
  );
5
5
  export class LanguageResolutionController {
6
6
  constructor(host) {
7
- this.language = document.documentElement.lang || navigator.language;
7
+ this.language = document.documentElement.lang || navigator.language || "en-US";
8
8
  this.host = host;
9
9
  this.host.addController(this);
10
10
  }
@@ -16,6 +16,11 @@ export class LanguageResolutionController {
16
16
  (_a = this.unsubscribe) == null ? void 0 : _a.call(this);
17
17
  }
18
18
  resolveLanguage() {
19
+ try {
20
+ Intl.DateTimeFormat.supportedLocalesOf([this.language]);
21
+ } catch (e) {
22
+ this.language = "en-US";
23
+ }
19
24
  const queryThemeEvent = new CustomEvent(
20
25
  "sp-language-context",
21
26
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["LanguageResolution.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { ProvideLang } from '@spectrum-web-components/theme';\n\nexport const languageResolverUpdatedSymbol = Symbol(\n 'language resolver updated'\n);\n\nexport class LanguageResolutionController implements ReactiveController {\n private host: ReactiveElement;\n language = document.documentElement.lang || navigator.language;\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 private resolveLanguage(): void {\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"],
5
- "mappings": ";AAeO,aAAM,gCAAgC;AAAA,EACzC;AACJ;AAEO,aAAM,6BAA2D;AAAA,EAKpE,YAAY,MAAuB;AAHnC,oBAAW,SAAS,gBAAgB,QAAQ,UAAU;AAIlD,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAAA,EAChC;AAAA,EAEO,gBAAsB;AACzB,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEO,mBAAyB;AAjCpC;AAkCQ,eAAK,gBAAL;AAAA,EACJ;AAAA,EAEQ,kBAAwB;AAC5B,UAAM,kBAAkB,IAAI;AAAA,MACxB;AAAA,MACA;AAAA,QACI,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,UACJ,UAAU,CAAC,MAAc,gBAA4B;AACjD,kBAAM,WAAW,KAAK;AACtB,iBAAK,WAAW;AAChB,iBAAK,cAAc;AACnB,iBAAK,KAAK;AAAA,cACN;AAAA,cACA;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QACA,YAAY;AAAA,MAChB;AAAA,IACJ;AACA,SAAK,KAAK,cAAc,eAAe;AAAA,EAC3C;AACJ;",
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { ProvideLang } from '@spectrum-web-components/theme';\n\nexport const languageResolverUpdatedSymbol = Symbol(\n 'language resolver updated'\n);\n\nexport class LanguageResolutionController implements ReactiveController {\n private host: ReactiveElement;\n language = document.documentElement.lang || navigator.language || 'en-US';\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 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"],
5
+ "mappings": ";AAeO,aAAM,gCAAgC;AAAA,EACzC;AACJ;AAEO,aAAM,6BAA2D;AAAA,EAKpE,YAAY,MAAuB;AAHnC,oBAAW,SAAS,gBAAgB,QAAQ,UAAU,YAAY;AAI9D,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAAA,EAChC;AAAA,EAEO,gBAAsB;AACzB,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEO,mBAAyB;AAjCpC;AAkCQ,eAAK,gBAAL;AAAA,EACJ;AAAA,EAEQ,kBAAwB;AAC5B,QAAI;AACA,WAAK,eAAe,mBAAmB,CAAC,KAAK,QAAQ,CAAC;AAAA,IAC1D,SAAQ;AACJ,WAAK,WAAW;AAAA,IACpB;AACA,UAAM,kBAAkB,IAAI;AAAA,MACxB;AAAA,MACA;AAAA,QACI,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,UACJ,UAAU,CAAC,MAAc,gBAA4B;AACjD,kBAAM,WAAW,KAAK;AACtB,iBAAK,WAAW;AAChB,iBAAK,cAAc;AACnB,iBAAK,KAAK;AAAA,cACN;AAAA,cACA;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QACA,YAAY;AAAA,MAChB;AAAA,IACJ;AACA,SAAK,KAAK,cAAc,eAAe;AAAA,EAC3C;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";export const languageResolverUpdatedSymbol=Symbol("language resolver updated");export class LanguageResolutionController{constructor(e){this.language=document.documentElement.lang||navigator.language;this.host=e,this.host.addController(this)}hostConnected(){this.resolveLanguage()}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}resolveLanguage(){const e=new CustomEvent("sp-language-context",{bubbles:!0,composed:!0,detail:{callback:(t,o)=>{const a=this.language;this.language=t,this.unsubscribe=o,this.host.requestUpdate(languageResolverUpdatedSymbol,a)}},cancelable:!0});this.host.dispatchEvent(e)}}
1
+ "use strict";export const languageResolverUpdatedSymbol=Symbol("language resolver updated");export class LanguageResolutionController{constructor(e){this.language=document.documentElement.lang||navigator.language||"en-US";this.host=e,this.host.addController(this)}hostConnected(){this.resolveLanguage()}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}resolveLanguage(){try{Intl.DateTimeFormat.supportedLocalesOf([this.language])}catch(t){this.language="en-US"}const e=new CustomEvent("sp-language-context",{bubbles:!0,composed:!0,detail:{callback:(t,o)=>{const a=this.language;this.language=t,this.unsubscribe=o,this.host.requestUpdate(languageResolverUpdatedSymbol,a)}},cancelable:!0});this.host.dispatchEvent(e)}}
2
2
  //# sourceMappingURL=LanguageResolution.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["LanguageResolution.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { ProvideLang } from '@spectrum-web-components/theme';\n\nexport const languageResolverUpdatedSymbol = Symbol(\n 'language resolver updated'\n);\n\nexport class LanguageResolutionController implements ReactiveController {\n private host: ReactiveElement;\n language = document.documentElement.lang || navigator.language;\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 private resolveLanguage(): void {\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"],
5
- "mappings": "aAeO,aAAM,8BAAgC,OACzC,2BACJ,EAEO,aAAM,4BAA2D,CAKpE,YAAYA,EAAuB,CAHnC,cAAW,SAAS,gBAAgB,MAAQ,UAAU,SAIlD,KAAK,KAAOA,EACZ,KAAK,KAAK,cAAc,IAAI,CAChC,CAEO,eAAsB,CACzB,KAAK,gBAAgB,CACzB,CAEO,kBAAyB,CAjCpC,IAAAC,GAkCQA,EAAA,KAAK,cAAL,MAAAA,EAAA,UACJ,CAEQ,iBAAwB,CAC5B,MAAMC,EAAkB,IAAI,YACxB,sBACA,CACI,QAAS,GACT,SAAU,GACV,OAAQ,CACJ,SAAU,CAACC,EAAcC,IAA4B,CACjD,MAAMC,EAAW,KAAK,SACtB,KAAK,SAAWF,EAChB,KAAK,YAAcC,EACnB,KAAK,KAAK,cACN,8BACAC,CACJ,CACJ,CACJ,EACA,WAAY,EAChB,CACJ,EACA,KAAK,KAAK,cAAcH,CAAe,CAC3C,CACJ",
6
- "names": ["host", "_a", "queryThemeEvent", "lang", "unsubscribe", "previous"]
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { ProvideLang } from '@spectrum-web-components/theme';\n\nexport const languageResolverUpdatedSymbol = Symbol(\n 'language resolver updated'\n);\n\nexport class LanguageResolutionController implements ReactiveController {\n private host: ReactiveElement;\n language = document.documentElement.lang || navigator.language || 'en-US';\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 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"],
5
+ "mappings": "aAeO,aAAM,8BAAgC,OACzC,2BACJ,EAEO,aAAM,4BAA2D,CAKpE,YAAYA,EAAuB,CAHnC,cAAW,SAAS,gBAAgB,MAAQ,UAAU,UAAY,QAI9D,KAAK,KAAOA,EACZ,KAAK,KAAK,cAAc,IAAI,CAChC,CAEO,eAAsB,CACzB,KAAK,gBAAgB,CACzB,CAEO,kBAAyB,CAjCpC,IAAAC,GAkCQA,EAAA,KAAK,cAAL,MAAAA,EAAA,UACJ,CAEQ,iBAAwB,CAC5B,GAAI,CACA,KAAK,eAAe,mBAAmB,CAAC,KAAK,QAAQ,CAAC,CAC1D,OAAQC,EAAA,CACJ,KAAK,SAAW,OACpB,CACA,MAAMC,EAAkB,IAAI,YACxB,sBACA,CACI,QAAS,GACT,SAAU,GACV,OAAQ,CACJ,SAAU,CAACC,EAAcC,IAA4B,CACjD,MAAMC,EAAW,KAAK,SACtB,KAAK,SAAWF,EAChB,KAAK,YAAcC,EACnB,KAAK,KAAK,cACN,8BACAC,CACJ,CACJ,CACJ,EACA,WAAY,EAChB,CACJ,EACA,KAAK,KAAK,cAAcH,CAAe,CAC3C,CACJ",
6
+ "names": ["host", "_a", "e", "queryThemeEvent", "lang", "unsubscribe", "previous"]
7
7
  }
@@ -9,10 +9,14 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import { LitElement, ReactiveController, TemplateResult } from 'lit';
13
12
  import '@spectrum-web-components/progress-circle/sp-progress-circle.js';
13
+ import { LitElement, ReactiveController, TemplateResult } from 'lit';
14
14
  /**
15
- * Represents a host element with pending state.
15
+ * Renders a pending state visual element and manages the aria-label of the host element.
16
+ *
17
+ * Currently this is used by Button only since the host element is the interactive element that needs pending state. This pattern does not work for components where the interactive element that needs pending state is in the shadow DOM. i.e. Combobox and Picker.
18
+ *
19
+ * @TODO consider deprecating this controller since it is not used by any other component.
16
20
  */
17
21
  export interface HostWithPendingState extends LitElement {
18
22
  pendingLabel?: string;
@@ -39,6 +43,8 @@ export declare class PendingStateController<T extends HostWithPendingState> impl
39
43
  /**
40
44
  * Renders the pending state UI.
41
45
  * @returns A TemplateResult representing the pending state UI.
46
+ *
47
+ * @TODO [SWC-1119, SWC-1255, SWC-459] Confirm the accessibility warning and a11y dom tree are accurate for the pending state in button, combobox, and picker components.
42
48
  */
43
49
  renderPendingState(): TemplateResult;
44
50
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- import { html } from "lit";
3
2
  import "@spectrum-web-components/progress-circle/sp-progress-circle.js";
3
+ import { html } from "lit";
4
4
  export class PendingStateController {
5
5
  /**
6
6
  * Creates an instance of PendingStateController.
@@ -14,16 +14,17 @@ export class PendingStateController {
14
14
  /**
15
15
  * Renders the pending state UI.
16
16
  * @returns A TemplateResult representing the pending state UI.
17
+ *
18
+ * @TODO [SWC-1119, SWC-1255, SWC-459] Confirm the accessibility warning and a11y dom tree are accurate for the pending state in button, combobox, and picker components.
17
19
  */
18
20
  renderPendingState() {
19
- const pendingLabel = this.host.pendingLabel || "Pending";
20
21
  return this.host.pending ? html`
21
22
  <sp-progress-circle
22
23
  id="loader"
23
24
  size="s"
24
25
  indeterminate
25
- aria-valuetext=${pendingLabel}
26
26
  class="progress-circle"
27
+ role="presentation"
27
28
  ></sp-progress-circle>
28
29
  ` : html``;
29
30
  }
@@ -34,13 +35,22 @@ export class PendingStateController {
34
35
  updateAriaLabel() {
35
36
  const { pending, disabled, pendingLabel } = this.host;
36
37
  const currentAriaLabel = this.host.getAttribute("aria-label");
37
- if (pending && !disabled && currentAriaLabel !== pendingLabel) {
38
+ function shouldCacheAriaLabel(cached, current, pending2) {
39
+ return !cached && current !== pending2 || cached !== current && current !== pending2;
40
+ }
41
+ if (shouldCacheAriaLabel(
42
+ this.cachedAriaLabel,
43
+ currentAriaLabel,
44
+ pendingLabel
45
+ )) {
38
46
  this.cachedAriaLabel = currentAriaLabel;
47
+ }
48
+ if (pending && !disabled) {
39
49
  this.host.setAttribute("aria-label", pendingLabel || "Pending");
40
- } else if (!pending || disabled) {
50
+ } else {
41
51
  if (this.cachedAriaLabel) {
42
52
  this.host.setAttribute("aria-label", this.cachedAriaLabel);
43
- } else if (!pending) {
53
+ } else {
44
54
  this.host.removeAttribute("aria-label");
45
55
  }
46
56
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["PendingState.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { html, LitElement, ReactiveController, TemplateResult } from 'lit';\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\n\n/**\n * Represents a host element with pending state.\n */\nexport interface HostWithPendingState extends LitElement {\n pendingLabel?: string;\n pending: boolean;\n disabled: boolean;\n pendingStateController: PendingStateController<HostWithPendingState>;\n}\n\n/**\n * Represents a controller for managing the pending state of a reactive element.\n *\n * @template T - The type of the reactive element.\n */\nexport class PendingStateController<T extends HostWithPendingState>\n implements ReactiveController\n{\n /**\n * The host element that this controller is attached to.\n */\n public host: T;\n\n /**\n * Creates an instance of PendingStateController.\n * @param host - The host element that this controller is attached to.\n */\n constructor(host: T) {\n this.host = host;\n this.host.addController(this);\n }\n\n public cachedAriaLabel: string | null = null;\n /**\n * Renders the pending state UI.\n * @returns A TemplateResult representing the pending state UI.\n */\n public renderPendingState(): TemplateResult {\n const pendingLabel = this.host.pendingLabel || 'Pending';\n return this.host.pending\n ? html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n aria-valuetext=${pendingLabel}\n class=\"progress-circle\"\n ></sp-progress-circle>\n `\n : html``;\n }\n\n /**\n * Updates the ARIA label of the host element based on the pending state.\n * Manages Cached Aria Label\n */\n private updateAriaLabel(): void {\n const { pending, disabled, pendingLabel } = this.host;\n const currentAriaLabel = this.host.getAttribute('aria-label');\n\n if (pending && !disabled && currentAriaLabel !== pendingLabel) {\n // Cache the current `aria-label` to be restored when no longer `pending`\n this.cachedAriaLabel = currentAriaLabel;\n // Since it is pending, we set the aria-label to `pendingLabel` or \"Pending\"\n this.host.setAttribute('aria-label', pendingLabel || 'Pending');\n } else if (!pending || disabled) {\n // Restore the cached `aria-label` if it exists\n if (this.cachedAriaLabel) {\n this.host.setAttribute('aria-label', this.cachedAriaLabel);\n } else if (!pending) {\n // If no cached `aria-label` and not `pending`, remove the `aria-label`\n this.host.removeAttribute('aria-label');\n }\n }\n }\n\n hostConnected(): void {\n if (!this.cachedAriaLabel)\n this.cachedAriaLabel = this.host.getAttribute('aria-label');\n this.updateAriaLabel();\n }\n\n hostUpdated(): void {\n this.updateAriaLabel();\n }\n}\n"],
5
- "mappings": ";AAYA,SAAS,YAA4D;AACrE,OAAO;AAiBA,aAAM,uBAEb;AAAA;AAAA;AAAA;AAAA;AAAA,EAUI,YAAY,MAAS;AAKrB,SAAO,kBAAiC;AAJpC,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,qBAAqC;AACxC,UAAM,eAAe,KAAK,KAAK,gBAAgB;AAC/C,WAAO,KAAK,KAAK,UACX;AAAA;AAAA;AAAA;AAAA;AAAA,uCAKyB,YAAY;AAAA;AAAA;AAAA,kBAIrC;AAAA,EACV;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,kBAAwB;AAC5B,UAAM,EAAE,SAAS,UAAU,aAAa,IAAI,KAAK;AACjD,UAAM,mBAAmB,KAAK,KAAK,aAAa,YAAY;AAE5D,QAAI,WAAW,CAAC,YAAY,qBAAqB,cAAc;AAE3D,WAAK,kBAAkB;AAEvB,WAAK,KAAK,aAAa,cAAc,gBAAgB,SAAS;AAAA,IAClE,WAAW,CAAC,WAAW,UAAU;AAE7B,UAAI,KAAK,iBAAiB;AACtB,aAAK,KAAK,aAAa,cAAc,KAAK,eAAe;AAAA,MAC7D,WAAW,CAAC,SAAS;AAEjB,aAAK,KAAK,gBAAgB,YAAY;AAAA,MAC1C;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,gBAAsB;AAClB,QAAI,CAAC,KAAK;AACN,WAAK,kBAAkB,KAAK,KAAK,aAAa,YAAY;AAC9D,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEA,cAAoB;AAChB,SAAK,gBAAgB;AAAA,EACzB;AACJ;",
6
- "names": []
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\nimport { html, LitElement, ReactiveController, TemplateResult } from 'lit';\n\n/**\n * Renders a pending state visual element and manages the aria-label of the host element.\n * \n * Currently this is used by Button only since the host element is the interactive element that needs pending state. This pattern does not work for components where the interactive element that needs pending state is in the shadow DOM. i.e. Combobox and Picker.\n * \n * @TODO consider deprecating this controller since it is not used by any other component.\n */\nexport interface HostWithPendingState extends LitElement {\n pendingLabel?: string;\n pending: boolean;\n disabled: boolean;\n pendingStateController: PendingStateController<HostWithPendingState>;\n}\n\n/**\n * Represents a controller for managing the pending state of a reactive element.\n *\n * @template T - The type of the reactive element.\n */\nexport class PendingStateController<T extends HostWithPendingState>\n implements ReactiveController\n{\n /**\n * The host element that this controller is attached to.\n */\n public host: T;\n\n /**\n * Creates an instance of PendingStateController.\n * @param host - The host element that this controller is attached to.\n */\n constructor(host: T) {\n this.host = host;\n this.host.addController(this);\n }\n\n public cachedAriaLabel: string | null = null;\n /**\n * Renders the pending state UI.\n * @returns A TemplateResult representing the pending state UI.\n *\n * @TODO [SWC-1119, SWC-1255, SWC-459] Confirm the accessibility warning and a11y dom tree are accurate for the pending state in button, combobox, and picker components.\n */\n public renderPendingState(): TemplateResult {\n return this.host.pending\n ? html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n class=\"progress-circle\"\n role=\"presentation\"\n ></sp-progress-circle>\n `\n : html``;\n }\n\n /**\n * Updates the ARIA label of the host element based on the pending state.\n * Manages Cached Aria Label\n */\n private updateAriaLabel(): void {\n const { pending, disabled, pendingLabel } = this.host;\n const currentAriaLabel = this.host.getAttribute('aria-label');\n\n function shouldCacheAriaLabel(\n cached: string | null,\n current: string | null,\n pending: string | undefined\n ): boolean {\n return (\n (!cached && current !== pending) ||\n (cached !== current && current !== pending)\n );\n }\n\n // If the current `aria-label` is different from the pending label, cache it\n // or if the cached `aria-label` is different from the current `aria-label`, cache it\n if (\n shouldCacheAriaLabel(\n this.cachedAriaLabel,\n currentAriaLabel,\n pendingLabel\n )\n ) {\n this.cachedAriaLabel = currentAriaLabel;\n }\n\n if (pending && !disabled) {\n // Since it is pending, we set the aria-label to `pendingLabel` or \"Pending\"\n this.host.setAttribute('aria-label', pendingLabel || 'Pending');\n } else {\n // Restore the cached `aria-label` if it exists\n if (this.cachedAriaLabel) {\n this.host.setAttribute('aria-label', this.cachedAriaLabel);\n } else {\n this.host.removeAttribute('aria-label');\n }\n }\n }\n\n hostConnected(): void {\n if (!this.cachedAriaLabel)\n this.cachedAriaLabel = this.host.getAttribute('aria-label');\n this.updateAriaLabel();\n }\n\n hostUpdated(): void {\n this.updateAriaLabel();\n }\n}\n"],
5
+ "mappings": ";AAYA,OAAO;AACP,SAAS,YAA4D;AAqB9D,aAAM,uBAEb;AAAA;AAAA;AAAA;AAAA;AAAA,EAUI,YAAY,MAAS;AAKrB,SAAO,kBAAiC;AAJpC,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,qBAAqC;AACxC,WAAO,KAAK,KAAK,UACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBASA;AAAA,EACV;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,kBAAwB;AAC5B,UAAM,EAAE,SAAS,UAAU,aAAa,IAAI,KAAK;AACjD,UAAM,mBAAmB,KAAK,KAAK,aAAa,YAAY;AAE5D,aAAS,qBACL,QACA,SACAA,UACO;AACP,aACK,CAAC,UAAU,YAAYA,YACvB,WAAW,WAAW,YAAYA;AAAA,IAE3C;AAIA,QACI;AAAA,MACI,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACJ,GACF;AACE,WAAK,kBAAkB;AAAA,IAC3B;AAEA,QAAI,WAAW,CAAC,UAAU;AAEtB,WAAK,KAAK,aAAa,cAAc,gBAAgB,SAAS;AAAA,IAClE,OAAO;AAEH,UAAI,KAAK,iBAAiB;AACtB,aAAK,KAAK,aAAa,cAAc,KAAK,eAAe;AAAA,MAC7D,OAAO;AACH,aAAK,KAAK,gBAAgB,YAAY;AAAA,MAC1C;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,gBAAsB;AAClB,QAAI,CAAC,KAAK;AACN,WAAK,kBAAkB,KAAK,KAAK,aAAa,YAAY;AAC9D,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEA,cAAoB;AAChB,SAAK,gBAAgB;AAAA,EACzB;AACJ;",
6
+ "names": ["pending"]
7
7
  }
@@ -1,10 +1,10 @@
1
- "use strict";import{html as s}from"lit";import"@spectrum-web-components/progress-circle/sp-progress-circle.js";export class PendingStateController{constructor(e){this.cachedAriaLabel=null;this.host=e,this.host.addController(this)}renderPendingState(){const e=this.host.pendingLabel||"Pending";return this.host.pending?s`
1
+ "use strict";import"@spectrum-web-components/progress-circle/sp-progress-circle.js";import{html as r}from"lit";export class PendingStateController{constructor(e){this.cachedAriaLabel=null;this.host=e,this.host.addController(this)}renderPendingState(){return this.host.pending?r`
2
2
  <sp-progress-circle
3
3
  id="loader"
4
4
  size="s"
5
5
  indeterminate
6
- aria-valuetext=${e}
7
6
  class="progress-circle"
7
+ role="presentation"
8
8
  ></sp-progress-circle>
9
- `:s``}updateAriaLabel(){const{pending:e,disabled:t,pendingLabel:i}=this.host,a=this.host.getAttribute("aria-label");e&&!t&&a!==i?(this.cachedAriaLabel=a,this.host.setAttribute("aria-label",i||"Pending")):(!e||t)&&(this.cachedAriaLabel?this.host.setAttribute("aria-label",this.cachedAriaLabel):e||this.host.removeAttribute("aria-label"))}hostConnected(){this.cachedAriaLabel||(this.cachedAriaLabel=this.host.getAttribute("aria-label")),this.updateAriaLabel()}hostUpdated(){this.updateAriaLabel()}}
9
+ `:r``}updateAriaLabel(){const{pending:e,disabled:n,pendingLabel:i}=this.host,a=this.host.getAttribute("aria-label");function o(l,t,s){return!l&&t!==s||l!==t&&t!==s}o(this.cachedAriaLabel,a,i)&&(this.cachedAriaLabel=a),e&&!n?this.host.setAttribute("aria-label",i||"Pending"):this.cachedAriaLabel?this.host.setAttribute("aria-label",this.cachedAriaLabel):this.host.removeAttribute("aria-label")}hostConnected(){this.cachedAriaLabel||(this.cachedAriaLabel=this.host.getAttribute("aria-label")),this.updateAriaLabel()}hostUpdated(){this.updateAriaLabel()}}
10
10
  //# sourceMappingURL=PendingState.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["PendingState.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { html, LitElement, ReactiveController, TemplateResult } from 'lit';\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\n\n/**\n * Represents a host element with pending state.\n */\nexport interface HostWithPendingState extends LitElement {\n pendingLabel?: string;\n pending: boolean;\n disabled: boolean;\n pendingStateController: PendingStateController<HostWithPendingState>;\n}\n\n/**\n * Represents a controller for managing the pending state of a reactive element.\n *\n * @template T - The type of the reactive element.\n */\nexport class PendingStateController<T extends HostWithPendingState>\n implements ReactiveController\n{\n /**\n * The host element that this controller is attached to.\n */\n public host: T;\n\n /**\n * Creates an instance of PendingStateController.\n * @param host - The host element that this controller is attached to.\n */\n constructor(host: T) {\n this.host = host;\n this.host.addController(this);\n }\n\n public cachedAriaLabel: string | null = null;\n /**\n * Renders the pending state UI.\n * @returns A TemplateResult representing the pending state UI.\n */\n public renderPendingState(): TemplateResult {\n const pendingLabel = this.host.pendingLabel || 'Pending';\n return this.host.pending\n ? html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n aria-valuetext=${pendingLabel}\n class=\"progress-circle\"\n ></sp-progress-circle>\n `\n : html``;\n }\n\n /**\n * Updates the ARIA label of the host element based on the pending state.\n * Manages Cached Aria Label\n */\n private updateAriaLabel(): void {\n const { pending, disabled, pendingLabel } = this.host;\n const currentAriaLabel = this.host.getAttribute('aria-label');\n\n if (pending && !disabled && currentAriaLabel !== pendingLabel) {\n // Cache the current `aria-label` to be restored when no longer `pending`\n this.cachedAriaLabel = currentAriaLabel;\n // Since it is pending, we set the aria-label to `pendingLabel` or \"Pending\"\n this.host.setAttribute('aria-label', pendingLabel || 'Pending');\n } else if (!pending || disabled) {\n // Restore the cached `aria-label` if it exists\n if (this.cachedAriaLabel) {\n this.host.setAttribute('aria-label', this.cachedAriaLabel);\n } else if (!pending) {\n // If no cached `aria-label` and not `pending`, remove the `aria-label`\n this.host.removeAttribute('aria-label');\n }\n }\n }\n\n hostConnected(): void {\n if (!this.cachedAriaLabel)\n this.cachedAriaLabel = this.host.getAttribute('aria-label');\n this.updateAriaLabel();\n }\n\n hostUpdated(): void {\n this.updateAriaLabel();\n }\n}\n"],
5
- "mappings": "aAYA,OAAS,QAAAA,MAA4D,MACrE,MAAO,iEAiBA,aAAM,sBAEb,CAUI,YAAYC,EAAS,CAKrB,KAAO,gBAAiC,KAJpC,KAAK,KAAOA,EACZ,KAAK,KAAK,cAAc,IAAI,CAChC,CAOO,oBAAqC,CACxC,MAAMC,EAAe,KAAK,KAAK,cAAgB,UAC/C,OAAO,KAAK,KAAK,QACXF;AAAA;AAAA;AAAA;AAAA;AAAA,uCAKyBE,CAAY;AAAA;AAAA;AAAA,gBAIrCF,GACV,CAMQ,iBAAwB,CAC5B,KAAM,CAAE,QAAAG,EAAS,SAAAC,EAAU,aAAAF,CAAa,EAAI,KAAK,KAC3CG,EAAmB,KAAK,KAAK,aAAa,YAAY,EAExDF,GAAW,CAACC,GAAYC,IAAqBH,GAE7C,KAAK,gBAAkBG,EAEvB,KAAK,KAAK,aAAa,aAAcH,GAAgB,SAAS,IACvD,CAACC,GAAWC,KAEf,KAAK,gBACL,KAAK,KAAK,aAAa,aAAc,KAAK,eAAe,EACjDD,GAER,KAAK,KAAK,gBAAgB,YAAY,EAGlD,CAEA,eAAsB,CACb,KAAK,kBACN,KAAK,gBAAkB,KAAK,KAAK,aAAa,YAAY,GAC9D,KAAK,gBAAgB,CACzB,CAEA,aAAoB,CAChB,KAAK,gBAAgB,CACzB,CACJ",
6
- "names": ["html", "host", "pendingLabel", "pending", "disabled", "currentAriaLabel"]
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\nimport { html, LitElement, ReactiveController, TemplateResult } from 'lit';\n\n/**\n * Renders a pending state visual element and manages the aria-label of the host element.\n * \n * Currently this is used by Button only since the host element is the interactive element that needs pending state. This pattern does not work for components where the interactive element that needs pending state is in the shadow DOM. i.e. Combobox and Picker.\n * \n * @TODO consider deprecating this controller since it is not used by any other component.\n */\nexport interface HostWithPendingState extends LitElement {\n pendingLabel?: string;\n pending: boolean;\n disabled: boolean;\n pendingStateController: PendingStateController<HostWithPendingState>;\n}\n\n/**\n * Represents a controller for managing the pending state of a reactive element.\n *\n * @template T - The type of the reactive element.\n */\nexport class PendingStateController<T extends HostWithPendingState>\n implements ReactiveController\n{\n /**\n * The host element that this controller is attached to.\n */\n public host: T;\n\n /**\n * Creates an instance of PendingStateController.\n * @param host - The host element that this controller is attached to.\n */\n constructor(host: T) {\n this.host = host;\n this.host.addController(this);\n }\n\n public cachedAriaLabel: string | null = null;\n /**\n * Renders the pending state UI.\n * @returns A TemplateResult representing the pending state UI.\n *\n * @TODO [SWC-1119, SWC-1255, SWC-459] Confirm the accessibility warning and a11y dom tree are accurate for the pending state in button, combobox, and picker components.\n */\n public renderPendingState(): TemplateResult {\n return this.host.pending\n ? html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n class=\"progress-circle\"\n role=\"presentation\"\n ></sp-progress-circle>\n `\n : html``;\n }\n\n /**\n * Updates the ARIA label of the host element based on the pending state.\n * Manages Cached Aria Label\n */\n private updateAriaLabel(): void {\n const { pending, disabled, pendingLabel } = this.host;\n const currentAriaLabel = this.host.getAttribute('aria-label');\n\n function shouldCacheAriaLabel(\n cached: string | null,\n current: string | null,\n pending: string | undefined\n ): boolean {\n return (\n (!cached && current !== pending) ||\n (cached !== current && current !== pending)\n );\n }\n\n // If the current `aria-label` is different from the pending label, cache it\n // or if the cached `aria-label` is different from the current `aria-label`, cache it\n if (\n shouldCacheAriaLabel(\n this.cachedAriaLabel,\n currentAriaLabel,\n pendingLabel\n )\n ) {\n this.cachedAriaLabel = currentAriaLabel;\n }\n\n if (pending && !disabled) {\n // Since it is pending, we set the aria-label to `pendingLabel` or \"Pending\"\n this.host.setAttribute('aria-label', pendingLabel || 'Pending');\n } else {\n // Restore the cached `aria-label` if it exists\n if (this.cachedAriaLabel) {\n this.host.setAttribute('aria-label', this.cachedAriaLabel);\n } else {\n this.host.removeAttribute('aria-label');\n }\n }\n }\n\n hostConnected(): void {\n if (!this.cachedAriaLabel)\n this.cachedAriaLabel = this.host.getAttribute('aria-label');\n this.updateAriaLabel();\n }\n\n hostUpdated(): void {\n this.updateAriaLabel();\n }\n}\n"],
5
+ "mappings": "aAYA,MAAO,iEACP,OAAS,QAAAA,MAA4D,MAqB9D,aAAM,sBAEb,CAUI,YAAYC,EAAS,CAKrB,KAAO,gBAAiC,KAJpC,KAAK,KAAOA,EACZ,KAAK,KAAK,cAAc,IAAI,CAChC,CASO,oBAAqC,CACxC,OAAO,KAAK,KAAK,QACXD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBASAA,GACV,CAMQ,iBAAwB,CAC5B,KAAM,CAAE,QAAAE,EAAS,SAAAC,EAAU,aAAAC,CAAa,EAAI,KAAK,KAC3CC,EAAmB,KAAK,KAAK,aAAa,YAAY,EAE5D,SAASC,EACLC,EACAC,EACAN,EACO,CACP,MACK,CAACK,GAAUC,IAAYN,GACvBK,IAAWC,GAAWA,IAAYN,CAE3C,CAKII,EACI,KAAK,gBACLD,EACAD,CACJ,IAEA,KAAK,gBAAkBC,GAGvBH,GAAW,CAACC,EAEZ,KAAK,KAAK,aAAa,aAAcC,GAAgB,SAAS,EAG1D,KAAK,gBACL,KAAK,KAAK,aAAa,aAAc,KAAK,eAAe,EAEzD,KAAK,KAAK,gBAAgB,YAAY,CAGlD,CAEA,eAAsB,CACb,KAAK,kBACN,KAAK,gBAAkB,KAAK,KAAK,aAAa,YAAY,GAC9D,KAAK,gBAAgB,CACzB,CAEA,aAAoB,CAChB,KAAK,gBAAgB,CACzB,CACJ",
6
+ "names": ["html", "host", "pending", "disabled", "pendingLabel", "currentAriaLabel", "shouldCacheAriaLabel", "cached", "current"]
7
7
  }