@spectrum-web-components/reactive-controllers 0.0.0-20241209155954

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +14 -0
  2. package/package.json +95 -0
  3. package/src/Color.d.ts +46 -0
  4. package/src/Color.dev.js +198 -0
  5. package/src/Color.dev.js.map +7 -0
  6. package/src/Color.js +2 -0
  7. package/src/Color.js.map +7 -0
  8. package/src/DependencyManger.d.ts +26 -0
  9. package/src/DependencyManger.dev.js +46 -0
  10. package/src/DependencyManger.dev.js.map +7 -0
  11. package/src/DependencyManger.js +2 -0
  12. package/src/DependencyManger.js.map +7 -0
  13. package/src/ElementResolution.d.ts +23 -0
  14. package/src/ElementResolution.dev.js +85 -0
  15. package/src/ElementResolution.dev.js.map +7 -0
  16. package/src/ElementResolution.js +2 -0
  17. package/src/ElementResolution.js.map +7 -0
  18. package/src/FocusGroup.d.ts +62 -0
  19. package/src/FocusGroup.dev.js +308 -0
  20. package/src/FocusGroup.dev.js.map +7 -0
  21. package/src/FocusGroup.js +2 -0
  22. package/src/FocusGroup.js.map +7 -0
  23. package/src/LanguageResolution.d.ts +11 -0
  24. package/src/LanguageResolution.dev.js +41 -0
  25. package/src/LanguageResolution.dev.js.map +7 -0
  26. package/src/LanguageResolution.js +2 -0
  27. package/src/LanguageResolution.js.map +7 -0
  28. package/src/MatchMedia.d.ts +13 -0
  29. package/src/MatchMedia.dev.js +29 -0
  30. package/src/MatchMedia.dev.js.map +7 -0
  31. package/src/MatchMedia.js +2 -0
  32. package/src/MatchMedia.js.map +7 -0
  33. package/src/PendingState.d.ts +40 -0
  34. package/src/PendingState.dev.js +57 -0
  35. package/src/PendingState.dev.js.map +7 -0
  36. package/src/PendingState.js +10 -0
  37. package/src/PendingState.js.map +7 -0
  38. package/src/RovingTabindex.d.ts +19 -0
  39. package/src/RovingTabindex.dev.js +72 -0
  40. package/src/RovingTabindex.dev.js.map +7 -0
  41. package/src/RovingTabindex.js +2 -0
  42. package/src/RovingTabindex.js.map +7 -0
  43. package/src/SystemContextResolution.d.ts +15 -0
  44. package/src/SystemContextResolution.dev.js +39 -0
  45. package/src/SystemContextResolution.dev.js.map +7 -0
  46. package/src/SystemContextResolution.js +2 -0
  47. package/src/SystemContextResolution.js.map +7 -0
  48. package/src/index.d.ts +2 -0
  49. package/src/index.dev.js +4 -0
  50. package/src/index.dev.js.map +7 -0
  51. package/src/index.js +2 -0
  52. package/src/index.js.map +7 -0
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ export const languageResolverUpdatedSymbol = Symbol(
3
+ "language resolver updated"
4
+ );
5
+ export class LanguageResolutionController {
6
+ constructor(host) {
7
+ this.language = document.documentElement.lang || navigator.language;
8
+ this.host = host;
9
+ this.host.addController(this);
10
+ }
11
+ hostConnected() {
12
+ this.resolveLanguage();
13
+ }
14
+ hostDisconnected() {
15
+ var _a;
16
+ (_a = this.unsubscribe) == null ? void 0 : _a.call(this);
17
+ }
18
+ resolveLanguage() {
19
+ const queryThemeEvent = new CustomEvent(
20
+ "sp-language-context",
21
+ {
22
+ bubbles: true,
23
+ composed: true,
24
+ detail: {
25
+ callback: (lang, unsubscribe) => {
26
+ const previous = this.language;
27
+ this.language = lang;
28
+ this.unsubscribe = unsubscribe;
29
+ this.host.requestUpdate(
30
+ languageResolverUpdatedSymbol,
31
+ previous
32
+ );
33
+ }
34
+ },
35
+ cancelable: true
36
+ }
37
+ );
38
+ this.host.dispatchEvent(queryThemeEvent);
39
+ }
40
+ }
41
+ //# sourceMappingURL=LanguageResolution.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["LanguageResolution.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning 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;",
6
+ "names": []
7
+ }
@@ -0,0 +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)}}
2
+ //# sourceMappingURL=LanguageResolution.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["LanguageResolution.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning 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"]
7
+ }
@@ -0,0 +1,13 @@
1
+ import type { ReactiveController, ReactiveElement } from 'lit';
2
+ export declare const DARK_MODE = "(prefers-color-scheme: dark)";
3
+ export declare const IS_MOBILE = "(max-width: 743px) and (hover: none) and (pointer: coarse)";
4
+ export declare class MatchMediaController implements ReactiveController {
5
+ key: symbol;
6
+ matches: boolean;
7
+ protected host: ReactiveElement;
8
+ protected media: MediaQueryList;
9
+ constructor(host: ReactiveElement, query: string);
10
+ hostConnected(): void;
11
+ hostDisconnected(): void;
12
+ protected onChange(event: MediaQueryListEvent): void;
13
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ export const DARK_MODE = "(prefers-color-scheme: dark)";
3
+ export const IS_MOBILE = "(max-width: 743px) and (hover: none) and (pointer: coarse)";
4
+ export class MatchMediaController {
5
+ constructor(host, query) {
6
+ this.key = Symbol("match-media-key");
7
+ this.matches = false;
8
+ this.host = host;
9
+ this.host.addController(this);
10
+ this.media = window.matchMedia(query);
11
+ this.matches = this.media.matches;
12
+ this.onChange = this.onChange.bind(this);
13
+ host.addController(this);
14
+ }
15
+ hostConnected() {
16
+ var _a;
17
+ (_a = this.media) == null ? void 0 : _a.addEventListener("change", this.onChange);
18
+ }
19
+ hostDisconnected() {
20
+ var _a;
21
+ (_a = this.media) == null ? void 0 : _a.removeEventListener("change", this.onChange);
22
+ }
23
+ onChange(event) {
24
+ if (this.matches === event.matches) return;
25
+ this.matches = event.matches;
26
+ this.host.requestUpdate(this.key, !this.matches);
27
+ }
28
+ }
29
+ //# sourceMappingURL=MatchMedia.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["MatchMedia.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\nexport const DARK_MODE = '(prefers-color-scheme: dark)';\nexport const IS_MOBILE =\n '(max-width: 743px) and (hover: none) and (pointer: coarse)';\n\nexport class MatchMediaController implements ReactiveController {\n key = Symbol('match-media-key');\n\n matches = false;\n\n protected host: ReactiveElement;\n\n protected media: MediaQueryList;\n\n constructor(host: ReactiveElement, query: string) {\n this.host = host;\n this.host.addController(this);\n this.media = window.matchMedia(query);\n this.matches = this.media.matches;\n this.onChange = this.onChange.bind(this);\n host.addController(this);\n }\n\n public hostConnected(): void {\n this.media?.addEventListener('change', this.onChange);\n }\n\n public hostDisconnected(): void {\n this.media?.removeEventListener('change', this.onChange);\n }\n\n protected onChange(event: MediaQueryListEvent): void {\n if (this.matches === event.matches) return;\n this.matches = event.matches;\n this.host.requestUpdate(this.key, !this.matches);\n }\n}\n"],
5
+ "mappings": ";AAaO,aAAM,YAAY;AAClB,aAAM,YACT;AAEG,aAAM,qBAAmD;AAAA,EAS5D,YAAY,MAAuB,OAAe;AARlD,eAAM,OAAO,iBAAiB;AAE9B,mBAAU;AAON,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAC5B,SAAK,QAAQ,OAAO,WAAW,KAAK;AACpC,SAAK,UAAU,KAAK,MAAM;AAC1B,SAAK,WAAW,KAAK,SAAS,KAAK,IAAI;AACvC,SAAK,cAAc,IAAI;AAAA,EAC3B;AAAA,EAEO,gBAAsB;AAnCjC;AAoCQ,eAAK,UAAL,mBAAY,iBAAiB,UAAU,KAAK;AAAA,EAChD;AAAA,EAEO,mBAAyB;AAvCpC;AAwCQ,eAAK,UAAL,mBAAY,oBAAoB,UAAU,KAAK;AAAA,EACnD;AAAA,EAEU,SAAS,OAAkC;AACjD,QAAI,KAAK,YAAY,MAAM,QAAS;AACpC,SAAK,UAAU,MAAM;AACrB,SAAK,KAAK,cAAc,KAAK,KAAK,CAAC,KAAK,OAAO;AAAA,EACnD;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export const DARK_MODE="(prefers-color-scheme: dark)",IS_MOBILE="(max-width: 743px) and (hover: none) and (pointer: coarse)";export class MatchMediaController{constructor(e,t){this.key=Symbol("match-media-key");this.matches=!1;this.host=e,this.host.addController(this),this.media=window.matchMedia(t),this.matches=this.media.matches,this.onChange=this.onChange.bind(this),e.addController(this)}hostConnected(){var e;(e=this.media)==null||e.addEventListener("change",this.onChange)}hostDisconnected(){var e;(e=this.media)==null||e.removeEventListener("change",this.onChange)}onChange(e){this.matches!==e.matches&&(this.matches=e.matches,this.host.requestUpdate(this.key,!this.matches))}}
2
+ //# sourceMappingURL=MatchMedia.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["MatchMedia.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\nexport const DARK_MODE = '(prefers-color-scheme: dark)';\nexport const IS_MOBILE =\n '(max-width: 743px) and (hover: none) and (pointer: coarse)';\n\nexport class MatchMediaController implements ReactiveController {\n key = Symbol('match-media-key');\n\n matches = false;\n\n protected host: ReactiveElement;\n\n protected media: MediaQueryList;\n\n constructor(host: ReactiveElement, query: string) {\n this.host = host;\n this.host.addController(this);\n this.media = window.matchMedia(query);\n this.matches = this.media.matches;\n this.onChange = this.onChange.bind(this);\n host.addController(this);\n }\n\n public hostConnected(): void {\n this.media?.addEventListener('change', this.onChange);\n }\n\n public hostDisconnected(): void {\n this.media?.removeEventListener('change', this.onChange);\n }\n\n protected onChange(event: MediaQueryListEvent): void {\n if (this.matches === event.matches) return;\n this.matches = event.matches;\n this.host.requestUpdate(this.key, !this.matches);\n }\n}\n"],
5
+ "mappings": "aAaO,aAAM,UAAY,+BACZ,UACT,6DAEG,aAAM,oBAAmD,CAS5D,YAAYA,EAAuBC,EAAe,CARlD,SAAM,OAAO,iBAAiB,EAE9B,aAAU,GAON,KAAK,KAAOD,EACZ,KAAK,KAAK,cAAc,IAAI,EAC5B,KAAK,MAAQ,OAAO,WAAWC,CAAK,EACpC,KAAK,QAAU,KAAK,MAAM,QAC1B,KAAK,SAAW,KAAK,SAAS,KAAK,IAAI,EACvCD,EAAK,cAAc,IAAI,CAC3B,CAEO,eAAsB,CAnCjC,IAAAE,GAoCQA,EAAA,KAAK,QAAL,MAAAA,EAAY,iBAAiB,SAAU,KAAK,SAChD,CAEO,kBAAyB,CAvCpC,IAAAA,GAwCQA,EAAA,KAAK,QAAL,MAAAA,EAAY,oBAAoB,SAAU,KAAK,SACnD,CAEU,SAASC,EAAkC,CAC7C,KAAK,UAAYA,EAAM,UAC3B,KAAK,QAAUA,EAAM,QACrB,KAAK,KAAK,cAAc,KAAK,IAAK,CAAC,KAAK,OAAO,EACnD,CACJ",
6
+ "names": ["host", "query", "_a", "event"]
7
+ }
@@ -0,0 +1,40 @@
1
+ import { LitElement, ReactiveController, TemplateResult } from 'lit';
2
+ import '@spectrum-web-components/progress-circle/sp-progress-circle.js';
3
+ /**
4
+ * Represents a host element with pending state.
5
+ */
6
+ export interface HostWithPendingState extends LitElement {
7
+ pendingLabel?: string;
8
+ pending: boolean;
9
+ disabled: boolean;
10
+ pendingStateController: PendingStateController<HostWithPendingState>;
11
+ }
12
+ /**
13
+ * Represents a controller for managing the pending state of a reactive element.
14
+ *
15
+ * @template T - The type of the reactive element.
16
+ */
17
+ export declare class PendingStateController<T extends HostWithPendingState> implements ReactiveController {
18
+ /**
19
+ * The host element that this controller is attached to.
20
+ */
21
+ host: T;
22
+ /**
23
+ * Creates an instance of PendingStateController.
24
+ * @param host - The host element that this controller is attached to.
25
+ */
26
+ constructor(host: T);
27
+ cachedAriaLabel: string | null;
28
+ /**
29
+ * Renders the pending state UI.
30
+ * @returns A TemplateResult representing the pending state UI.
31
+ */
32
+ renderPendingState(): TemplateResult;
33
+ /**
34
+ * Updates the ARIA label of the host element based on the pending state.
35
+ * Manages Cached Aria Label
36
+ */
37
+ private updateAriaLabel;
38
+ hostConnected(): void;
39
+ hostUpdated(): void;
40
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ import { html } from "lit";
3
+ import "@spectrum-web-components/progress-circle/sp-progress-circle.js";
4
+ export class PendingStateController {
5
+ /**
6
+ * Creates an instance of PendingStateController.
7
+ * @param host - The host element that this controller is attached to.
8
+ */
9
+ constructor(host) {
10
+ this.cachedAriaLabel = null;
11
+ this.host = host;
12
+ this.host.addController(this);
13
+ }
14
+ /**
15
+ * Renders the pending state UI.
16
+ * @returns A TemplateResult representing the pending state UI.
17
+ */
18
+ renderPendingState() {
19
+ const pendingLabel = this.host.pendingLabel || "Pending";
20
+ return this.host.pending ? html`
21
+ <sp-progress-circle
22
+ id="loader"
23
+ size="s"
24
+ indeterminate
25
+ aria-valuetext=${pendingLabel}
26
+ class="progress-circle"
27
+ ></sp-progress-circle>
28
+ ` : html``;
29
+ }
30
+ /**
31
+ * Updates the ARIA label of the host element based on the pending state.
32
+ * Manages Cached Aria Label
33
+ */
34
+ updateAriaLabel() {
35
+ const { pending, disabled, pendingLabel } = this.host;
36
+ const currentAriaLabel = this.host.getAttribute("aria-label");
37
+ if (pending && !disabled && currentAriaLabel !== pendingLabel) {
38
+ this.cachedAriaLabel = currentAriaLabel;
39
+ this.host.setAttribute("aria-label", pendingLabel || "Pending");
40
+ } else if (!pending || disabled) {
41
+ if (this.cachedAriaLabel) {
42
+ this.host.setAttribute("aria-label", this.cachedAriaLabel);
43
+ } else if (!pending) {
44
+ this.host.removeAttribute("aria-label");
45
+ }
46
+ }
47
+ }
48
+ hostConnected() {
49
+ if (!this.cachedAriaLabel)
50
+ this.cachedAriaLabel = this.host.getAttribute("aria-label");
51
+ this.updateAriaLabel();
52
+ }
53
+ hostUpdated() {
54
+ this.updateAriaLabel();
55
+ }
56
+ }
57
+ //# sourceMappingURL=PendingState.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["PendingState.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning 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": []
7
+ }
@@ -0,0 +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`
2
+ <sp-progress-circle
3
+ id="loader"
4
+ size="s"
5
+ indeterminate
6
+ aria-valuetext=${e}
7
+ class="progress-circle"
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()}}
10
+ //# sourceMappingURL=PendingState.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["PendingState.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning 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"]
7
+ }
@@ -0,0 +1,19 @@
1
+ import { FocusGroupConfig, FocusGroupController } from './FocusGroup.js';
2
+ export type RovingTabindexConfig<T> = FocusGroupConfig<T>;
3
+ interface UpdateTabIndexes {
4
+ tabIndex: number;
5
+ removeTabIndex?: boolean;
6
+ }
7
+ export declare class RovingTabindexController<T extends HTMLElement> extends FocusGroupController<T> {
8
+ protected set focused(focused: boolean);
9
+ protected get focused(): boolean;
10
+ private managed;
11
+ private manageIndexesAnimationFrame;
12
+ clearElementCache(offset?: number): void;
13
+ manageTabindexes(): void;
14
+ updateTabindexes(getTabIndex: (el: HTMLElement) => UpdateTabIndexes): void;
15
+ manage(): void;
16
+ unmanage(): void;
17
+ hostUpdated(): void;
18
+ }
19
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ import { FocusGroupController } from "./FocusGroup.dev.js";
3
+ export class RovingTabindexController extends FocusGroupController {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.managed = true;
7
+ this.manageIndexesAnimationFrame = 0;
8
+ }
9
+ set focused(focused) {
10
+ if (focused === this.focused) return;
11
+ super.focused = focused;
12
+ this.manageTabindexes();
13
+ }
14
+ get focused() {
15
+ return super.focused;
16
+ }
17
+ clearElementCache(offset = 0) {
18
+ cancelAnimationFrame(this.manageIndexesAnimationFrame);
19
+ super.clearElementCache(offset);
20
+ if (!this.managed) return;
21
+ this.manageIndexesAnimationFrame = requestAnimationFrame(
22
+ () => this.manageTabindexes()
23
+ );
24
+ }
25
+ manageTabindexes() {
26
+ if (this.focused) {
27
+ this.updateTabindexes(() => ({ tabIndex: -1 }));
28
+ } else {
29
+ this.updateTabindexes((el) => {
30
+ return {
31
+ removeTabIndex: el.contains(this.focusInElement) && el !== this.focusInElement,
32
+ tabIndex: el === this.focusInElement ? 0 : -1
33
+ };
34
+ });
35
+ }
36
+ }
37
+ updateTabindexes(getTabIndex) {
38
+ this.elements.forEach((el) => {
39
+ const { tabIndex, removeTabIndex } = getTabIndex(el);
40
+ if (!removeTabIndex) {
41
+ if (this.focused) {
42
+ if (el !== this.elements[this.currentIndex]) {
43
+ el.tabIndex = tabIndex;
44
+ }
45
+ } else {
46
+ el.tabIndex = tabIndex;
47
+ }
48
+ return;
49
+ }
50
+ el.removeAttribute("tabindex");
51
+ const updatable = el;
52
+ if (updatable.requestUpdate) updatable.requestUpdate();
53
+ });
54
+ }
55
+ manage() {
56
+ this.managed = true;
57
+ this.manageTabindexes();
58
+ super.manage();
59
+ }
60
+ unmanage() {
61
+ this.managed = false;
62
+ this.updateTabindexes(() => ({ tabIndex: 0 }));
63
+ super.unmanage();
64
+ }
65
+ hostUpdated() {
66
+ super.hostUpdated();
67
+ if (!this.host.hasUpdated) {
68
+ this.manageTabindexes();
69
+ }
70
+ }
71
+ }
72
+ //# sourceMappingURL=RovingTabindex.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["RovingTabindex.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { FocusGroupConfig, FocusGroupController } from './FocusGroup.dev.js'\n\nexport type RovingTabindexConfig<T> = FocusGroupConfig<T>;\ninterface UpdateTabIndexes {\n tabIndex: number;\n removeTabIndex?: boolean;\n}\n\nexport class RovingTabindexController<\n T extends HTMLElement,\n> extends FocusGroupController<T> {\n protected override set focused(focused: boolean) {\n if (focused === this.focused) return;\n super.focused = focused;\n this.manageTabindexes();\n }\n\n protected override get focused(): boolean {\n return super.focused;\n }\n\n private managed = true;\n\n private manageIndexesAnimationFrame = 0;\n\n override clearElementCache(offset = 0): void {\n cancelAnimationFrame(this.manageIndexesAnimationFrame);\n super.clearElementCache(offset);\n if (!this.managed) return;\n\n this.manageIndexesAnimationFrame = requestAnimationFrame(() =>\n this.manageTabindexes()\n );\n }\n\n manageTabindexes(): void {\n if (this.focused) {\n this.updateTabindexes(() => ({ tabIndex: -1 }));\n } else {\n this.updateTabindexes((el: HTMLElement): UpdateTabIndexes => {\n return {\n removeTabIndex:\n el.contains(this.focusInElement) &&\n el !== this.focusInElement,\n tabIndex: el === this.focusInElement ? 0 : -1,\n };\n });\n }\n }\n\n updateTabindexes(getTabIndex: (el: HTMLElement) => UpdateTabIndexes): void {\n this.elements.forEach((el) => {\n const { tabIndex, removeTabIndex } = getTabIndex(el);\n if (!removeTabIndex) {\n if (this.focused) {\n if (el !== this.elements[this.currentIndex]) {\n el.tabIndex = tabIndex;\n }\n } else {\n el.tabIndex = tabIndex;\n }\n return;\n }\n el.removeAttribute('tabindex');\n const updatable = el as unknown as {\n requestUpdate?: () => void;\n };\n if (updatable.requestUpdate) updatable.requestUpdate();\n });\n }\n\n override manage(): void {\n this.managed = true;\n this.manageTabindexes();\n super.manage();\n }\n\n override unmanage(): void {\n this.managed = false;\n this.updateTabindexes(() => ({ tabIndex: 0 }));\n super.unmanage();\n }\n\n override hostUpdated(): void {\n super.hostUpdated();\n if (!this.host.hasUpdated) {\n this.manageTabindexes();\n }\n }\n}\n"],
5
+ "mappings": ";AAWA,SAA2B,4BAA4B;AAQhD,aAAM,iCAEH,qBAAwB;AAAA,EAF3B;AAAA;AAaH,SAAQ,UAAU;AAElB,SAAQ,8BAA8B;AAAA;AAAA,EAZtC,IAAuB,QAAQ,SAAkB;AAC7C,QAAI,YAAY,KAAK,QAAS;AAC9B,UAAM,UAAU;AAChB,SAAK,iBAAiB;AAAA,EAC1B;AAAA,EAEA,IAAuB,UAAmB;AACtC,WAAO,MAAM;AAAA,EACjB;AAAA,EAMS,kBAAkB,SAAS,GAAS;AACzC,yBAAqB,KAAK,2BAA2B;AACrD,UAAM,kBAAkB,MAAM;AAC9B,QAAI,CAAC,KAAK,QAAS;AAEnB,SAAK,8BAA8B;AAAA,MAAsB,MACrD,KAAK,iBAAiB;AAAA,IAC1B;AAAA,EACJ;AAAA,EAEA,mBAAyB;AACrB,QAAI,KAAK,SAAS;AACd,WAAK,iBAAiB,OAAO,EAAE,UAAU,GAAG,EAAE;AAAA,IAClD,OAAO;AACH,WAAK,iBAAiB,CAAC,OAAsC;AACzD,eAAO;AAAA,UACH,gBACI,GAAG,SAAS,KAAK,cAAc,KAC/B,OAAO,KAAK;AAAA,UAChB,UAAU,OAAO,KAAK,iBAAiB,IAAI;AAAA,QAC/C;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EAEA,iBAAiB,aAA0D;AACvE,SAAK,SAAS,QAAQ,CAAC,OAAO;AAC1B,YAAM,EAAE,UAAU,eAAe,IAAI,YAAY,EAAE;AACnD,UAAI,CAAC,gBAAgB;AACjB,YAAI,KAAK,SAAS;AACd,cAAI,OAAO,KAAK,SAAS,KAAK,YAAY,GAAG;AACzC,eAAG,WAAW;AAAA,UAClB;AAAA,QACJ,OAAO;AACH,aAAG,WAAW;AAAA,QAClB;AACA;AAAA,MACJ;AACA,SAAG,gBAAgB,UAAU;AAC7B,YAAM,YAAY;AAGlB,UAAI,UAAU,cAAe,WAAU,cAAc;AAAA,IACzD,CAAC;AAAA,EACL;AAAA,EAES,SAAe;AACpB,SAAK,UAAU;AACf,SAAK,iBAAiB;AACtB,UAAM,OAAO;AAAA,EACjB;AAAA,EAES,WAAiB;AACtB,SAAK,UAAU;AACf,SAAK,iBAAiB,OAAO,EAAE,UAAU,EAAE,EAAE;AAC7C,UAAM,SAAS;AAAA,EACnB;AAAA,EAES,cAAoB;AACzB,UAAM,YAAY;AAClB,QAAI,CAAC,KAAK,KAAK,YAAY;AACvB,WAAK,iBAAiB;AAAA,IAC1B;AAAA,EACJ;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";import{FocusGroupController as i}from"./FocusGroup.js";export class RovingTabindexController extends i{constructor(){super(...arguments);this.managed=!0;this.manageIndexesAnimationFrame=0}set focused(e){e!==this.focused&&(super.focused=e,this.manageTabindexes())}get focused(){return super.focused}clearElementCache(e=0){cancelAnimationFrame(this.manageIndexesAnimationFrame),super.clearElementCache(e),this.managed&&(this.manageIndexesAnimationFrame=requestAnimationFrame(()=>this.manageTabindexes()))}manageTabindexes(){this.focused?this.updateTabindexes(()=>({tabIndex:-1})):this.updateTabindexes(e=>({removeTabIndex:e.contains(this.focusInElement)&&e!==this.focusInElement,tabIndex:e===this.focusInElement?0:-1}))}updateTabindexes(e){this.elements.forEach(a=>{const{tabIndex:n,removeTabIndex:s}=e(a);if(!s){this.focused?a!==this.elements[this.currentIndex]&&(a.tabIndex=n):a.tabIndex=n;return}a.removeAttribute("tabindex");const t=a;t.requestUpdate&&t.requestUpdate()})}manage(){this.managed=!0,this.manageTabindexes(),super.manage()}unmanage(){this.managed=!1,this.updateTabindexes(()=>({tabIndex:0})),super.unmanage()}hostUpdated(){super.hostUpdated(),this.host.hasUpdated||this.manageTabindexes()}}
2
+ //# sourceMappingURL=RovingTabindex.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["RovingTabindex.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { FocusGroupConfig, FocusGroupController } from './FocusGroup.js';\n\nexport type RovingTabindexConfig<T> = FocusGroupConfig<T>;\ninterface UpdateTabIndexes {\n tabIndex: number;\n removeTabIndex?: boolean;\n}\n\nexport class RovingTabindexController<\n T extends HTMLElement,\n> extends FocusGroupController<T> {\n protected override set focused(focused: boolean) {\n if (focused === this.focused) return;\n super.focused = focused;\n this.manageTabindexes();\n }\n\n protected override get focused(): boolean {\n return super.focused;\n }\n\n private managed = true;\n\n private manageIndexesAnimationFrame = 0;\n\n override clearElementCache(offset = 0): void {\n cancelAnimationFrame(this.manageIndexesAnimationFrame);\n super.clearElementCache(offset);\n if (!this.managed) return;\n\n this.manageIndexesAnimationFrame = requestAnimationFrame(() =>\n this.manageTabindexes()\n );\n }\n\n manageTabindexes(): void {\n if (this.focused) {\n this.updateTabindexes(() => ({ tabIndex: -1 }));\n } else {\n this.updateTabindexes((el: HTMLElement): UpdateTabIndexes => {\n return {\n removeTabIndex:\n el.contains(this.focusInElement) &&\n el !== this.focusInElement,\n tabIndex: el === this.focusInElement ? 0 : -1,\n };\n });\n }\n }\n\n updateTabindexes(getTabIndex: (el: HTMLElement) => UpdateTabIndexes): void {\n this.elements.forEach((el) => {\n const { tabIndex, removeTabIndex } = getTabIndex(el);\n if (!removeTabIndex) {\n if (this.focused) {\n if (el !== this.elements[this.currentIndex]) {\n el.tabIndex = tabIndex;\n }\n } else {\n el.tabIndex = tabIndex;\n }\n return;\n }\n el.removeAttribute('tabindex');\n const updatable = el as unknown as {\n requestUpdate?: () => void;\n };\n if (updatable.requestUpdate) updatable.requestUpdate();\n });\n }\n\n override manage(): void {\n this.managed = true;\n this.manageTabindexes();\n super.manage();\n }\n\n override unmanage(): void {\n this.managed = false;\n this.updateTabindexes(() => ({ tabIndex: 0 }));\n super.unmanage();\n }\n\n override hostUpdated(): void {\n super.hostUpdated();\n if (!this.host.hasUpdated) {\n this.manageTabindexes();\n }\n }\n}\n"],
5
+ "mappings": "aAWA,OAA2B,wBAAAA,MAA4B,kBAQhD,aAAM,iCAEHA,CAAwB,CAF3B,kCAaH,KAAQ,QAAU,GAElB,KAAQ,4BAA8B,EAZtC,IAAuB,QAAQC,EAAkB,CACzCA,IAAY,KAAK,UACrB,MAAM,QAAUA,EAChB,KAAK,iBAAiB,EAC1B,CAEA,IAAuB,SAAmB,CACtC,OAAO,MAAM,OACjB,CAMS,kBAAkBC,EAAS,EAAS,CACzC,qBAAqB,KAAK,2BAA2B,EACrD,MAAM,kBAAkBA,CAAM,EACzB,KAAK,UAEV,KAAK,4BAA8B,sBAAsB,IACrD,KAAK,iBAAiB,CAC1B,EACJ,CAEA,kBAAyB,CACjB,KAAK,QACL,KAAK,iBAAiB,KAAO,CAAE,SAAU,EAAG,EAAE,EAE9C,KAAK,iBAAkBC,IACZ,CACH,eACIA,EAAG,SAAS,KAAK,cAAc,GAC/BA,IAAO,KAAK,eAChB,SAAUA,IAAO,KAAK,eAAiB,EAAI,EAC/C,EACH,CAET,CAEA,iBAAiBC,EAA0D,CACvE,KAAK,SAAS,QAASD,GAAO,CAC1B,KAAM,CAAE,SAAAE,EAAU,eAAAC,CAAe,EAAIF,EAAYD,CAAE,EACnD,GAAI,CAACG,EAAgB,CACb,KAAK,QACDH,IAAO,KAAK,SAAS,KAAK,YAAY,IACtCA,EAAG,SAAWE,GAGlBF,EAAG,SAAWE,EAElB,MACJ,CACAF,EAAG,gBAAgB,UAAU,EAC7B,MAAMI,EAAYJ,EAGdI,EAAU,eAAeA,EAAU,cAAc,CACzD,CAAC,CACL,CAES,QAAe,CACpB,KAAK,QAAU,GACf,KAAK,iBAAiB,EACtB,MAAM,OAAO,CACjB,CAES,UAAiB,CACtB,KAAK,QAAU,GACf,KAAK,iBAAiB,KAAO,CAAE,SAAU,CAAE,EAAE,EAC7C,MAAM,SAAS,CACnB,CAES,aAAoB,CACzB,MAAM,YAAY,EACb,KAAK,KAAK,YACX,KAAK,iBAAiB,CAE9B,CACJ",
6
+ "names": ["FocusGroupController", "focused", "offset", "el", "getTabIndex", "tabIndex", "removeTabIndex", "updatable"]
7
+ }
@@ -0,0 +1,15 @@
1
+ import type { ReactiveController, ReactiveElement } from 'lit';
2
+ import type { SystemVariant } from '@spectrum-web-components/theme';
3
+ export declare const systemResolverUpdatedSymbol: unique symbol;
4
+ export type ProvideSystem = {
5
+ callback: (system: SystemVariant, unsubscribe: () => void) => void;
6
+ };
7
+ export declare class SystemResolutionController implements ReactiveController {
8
+ private host;
9
+ system: SystemVariant;
10
+ private unsubscribe?;
11
+ constructor(host: ReactiveElement);
12
+ hostConnected(): void;
13
+ hostDisconnected(): void;
14
+ private resolveSystem;
15
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ export const systemResolverUpdatedSymbol = Symbol("system resolver updated");
3
+ export class SystemResolutionController {
4
+ constructor(host) {
5
+ this.system = "spectrum";
6
+ this.host = host;
7
+ this.host.addController(this);
8
+ }
9
+ hostConnected() {
10
+ this.resolveSystem();
11
+ }
12
+ hostDisconnected() {
13
+ var _a;
14
+ (_a = this.unsubscribe) == null ? void 0 : _a.call(this);
15
+ }
16
+ resolveSystem() {
17
+ const querySystemEvent = new CustomEvent(
18
+ "sp-system-context",
19
+ {
20
+ bubbles: true,
21
+ composed: true,
22
+ detail: {
23
+ callback: (system, unsubscribe) => {
24
+ const previous = this.system;
25
+ this.system = system;
26
+ this.unsubscribe = unsubscribe;
27
+ this.host.requestUpdate(
28
+ systemResolverUpdatedSymbol,
29
+ previous
30
+ );
31
+ }
32
+ },
33
+ cancelable: true
34
+ }
35
+ );
36
+ this.host.dispatchEvent(querySystemEvent);
37
+ }
38
+ }
39
+ //# sourceMappingURL=SystemContextResolution.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["SystemContextResolution.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { SystemVariant } from '@spectrum-web-components/theme';\n\nexport const systemResolverUpdatedSymbol = Symbol('system resolver updated');\n\nexport type ProvideSystem = {\n callback: (system: SystemVariant, unsubscribe: () => void) => void;\n};\n\nexport class SystemResolutionController implements ReactiveController {\n private host: ReactiveElement;\n public system: SystemVariant = 'spectrum';\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.resolveSystem();\n }\n\n public hostDisconnected(): void {\n this.unsubscribe?.();\n }\n\n private resolveSystem(): void {\n const querySystemEvent = new CustomEvent<ProvideSystem>(\n 'sp-system-context',\n {\n bubbles: true,\n composed: true,\n detail: {\n callback: (\n system: SystemVariant,\n unsubscribe: () => void\n ) => {\n const previous = this.system;\n this.system = system;\n this.unsubscribe = unsubscribe;\n this.host.requestUpdate(\n systemResolverUpdatedSymbol,\n previous\n );\n },\n },\n cancelable: true,\n }\n );\n this.host.dispatchEvent(querySystemEvent);\n }\n}\n"],
5
+ "mappings": ";AAcO,aAAM,8BAA8B,OAAO,yBAAyB;AAMpE,aAAM,2BAAyD;AAAA,EAKlE,YAAY,MAAuB;AAHnC,SAAO,SAAwB;AAI3B,SAAK,OAAO;AACZ,SAAK,KAAK,cAAc,IAAI;AAAA,EAChC;AAAA,EAEO,gBAAsB;AACzB,SAAK,cAAc;AAAA,EACvB;AAAA,EAEO,mBAAyB;AAlCpC;AAmCQ,eAAK,gBAAL;AAAA,EACJ;AAAA,EAEQ,gBAAsB;AAC1B,UAAM,mBAAmB,IAAI;AAAA,MACzB;AAAA,MACA;AAAA,QACI,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,UACJ,UAAU,CACN,QACA,gBACC;AACD,kBAAM,WAAW,KAAK;AACtB,iBAAK,SAAS;AACd,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,gBAAgB;AAAA,EAC5C;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export const systemResolverUpdatedSymbol=Symbol("system resolver updated");export class SystemResolutionController{constructor(e){this.system="spectrum";this.host=e,this.host.addController(this)}hostConnected(){this.resolveSystem()}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}resolveSystem(){const e=new CustomEvent("sp-system-context",{bubbles:!0,composed:!0,detail:{callback:(t,s)=>{const o=this.system;this.system=t,this.unsubscribe=s,this.host.requestUpdate(systemResolverUpdatedSymbol,o)}},cancelable:!0});this.host.dispatchEvent(e)}}
2
+ //# sourceMappingURL=SystemContextResolution.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["SystemContextResolution.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { SystemVariant } from '@spectrum-web-components/theme';\n\nexport const systemResolverUpdatedSymbol = Symbol('system resolver updated');\n\nexport type ProvideSystem = {\n callback: (system: SystemVariant, unsubscribe: () => void) => void;\n};\n\nexport class SystemResolutionController implements ReactiveController {\n private host: ReactiveElement;\n public system: SystemVariant = 'spectrum';\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.resolveSystem();\n }\n\n public hostDisconnected(): void {\n this.unsubscribe?.();\n }\n\n private resolveSystem(): void {\n const querySystemEvent = new CustomEvent<ProvideSystem>(\n 'sp-system-context',\n {\n bubbles: true,\n composed: true,\n detail: {\n callback: (\n system: SystemVariant,\n unsubscribe: () => void\n ) => {\n const previous = this.system;\n this.system = system;\n this.unsubscribe = unsubscribe;\n this.host.requestUpdate(\n systemResolverUpdatedSymbol,\n previous\n );\n },\n },\n cancelable: true,\n }\n );\n this.host.dispatchEvent(querySystemEvent);\n }\n}\n"],
5
+ "mappings": "aAcO,aAAM,4BAA8B,OAAO,yBAAyB,EAMpE,aAAM,0BAAyD,CAKlE,YAAYA,EAAuB,CAHnC,KAAO,OAAwB,WAI3B,KAAK,KAAOA,EACZ,KAAK,KAAK,cAAc,IAAI,CAChC,CAEO,eAAsB,CACzB,KAAK,cAAc,CACvB,CAEO,kBAAyB,CAlCpC,IAAAC,GAmCQA,EAAA,KAAK,cAAL,MAAAA,EAAA,UACJ,CAEQ,eAAsB,CAC1B,MAAMC,EAAmB,IAAI,YACzB,oBACA,CACI,QAAS,GACT,SAAU,GACV,OAAQ,CACJ,SAAU,CACNC,EACAC,IACC,CACD,MAAMC,EAAW,KAAK,OACtB,KAAK,OAASF,EACd,KAAK,YAAcC,EACnB,KAAK,KAAK,cACN,4BACAC,CACJ,CACJ,CACJ,EACA,WAAY,EAChB,CACJ,EACA,KAAK,KAAK,cAAcH,CAAgB,CAC5C,CACJ",
6
+ "names": ["host", "_a", "querySystemEvent", "system", "unsubscribe", "previous"]
7
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './MatchMedia.js';
2
+ export * from './RovingTabindex.js';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ export * from "./MatchMedia.dev.js";
3
+ export * from "./RovingTabindex.dev.js";
4
+ //# sourceMappingURL=index.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './MatchMedia.dev.js'\nexport * from './RovingTabindex.dev.js'\n"],
5
+ "mappings": ";AAYA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";export*from"./MatchMedia.js";export*from"./RovingTabindex.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './MatchMedia.js';\nexport * from './RovingTabindex.js';\n"],
5
+ "mappings": "aAYA,WAAc,kBACd,WAAc",
6
+ "names": []
7
+ }