@spectrum-web-components/reactive-controllers 0.49.0-beta.0 → 0.49.0-beta.1

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 CHANGED
@@ -4,9 +4,10 @@
4
4
 
5
5
  ### Reactive controllers
6
6
 
7
- - [ElementResolutionController](../element-resolution)
8
7
  - ColorController
8
+ - [ElementResolutionController](../element-resolution)
9
9
  - FocusGroupController
10
- - LanguageReslutionController
10
+ - LanguageResolutionController
11
11
  - [MatchMediaController](../match-media)
12
12
  - [RovingTabindexController](../roving-tab-index)
13
+ - SystemContextResolutionController
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/reactive-controllers",
3
- "version": "0.49.0-beta.0",
3
+ "version": "0.49.0-beta.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -57,6 +57,10 @@
57
57
  "development": "./src/RovingTabindex.dev.js",
58
58
  "default": "./src/RovingTabindex.js"
59
59
  },
60
+ "./src/SystemContextResolution.js": {
61
+ "development": "./src/SystemContextResolution.dev.js",
62
+ "default": "./src/SystemContextResolution.js"
63
+ },
60
64
  "./src/index.js": {
61
65
  "development": "./src/index.dev.js",
62
66
  "default": "./src/index.js"
@@ -87,5 +91,5 @@
87
91
  "sideEffects": [
88
92
  "./**/*.dev.js"
89
93
  ],
90
- "gitHead": "1aa9165b6529e70339c9c632d47335a2c0894f0b"
94
+ "gitHead": "74ee2c5b1276e8e4f768566a1c3c4e263a7eb8b3"
91
95
  }
@@ -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
+ }