@spectrum-web-components/theme 0.14.0-devmode.0 → 0.14.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.
Files changed (75) hide show
  1. package/core.js +1 -3
  2. package/core.js.map +1 -1
  3. package/express/scale-large.js +1 -4
  4. package/express/scale-large.js.map +1 -1
  5. package/express/scale-medium.js +1 -4
  6. package/express/scale-medium.js.map +1 -1
  7. package/express/theme-dark.js +1 -4
  8. package/express/theme-dark.js.map +1 -1
  9. package/express/theme-darkest.js +1 -4
  10. package/express/theme-darkest.js.map +1 -1
  11. package/express/theme-light.js +1 -4
  12. package/express/theme-light.js.map +1 -1
  13. package/express/theme-lightest.js +1 -4
  14. package/express/theme-lightest.js.map +1 -1
  15. package/package.json +4 -4
  16. package/scale-large.js +1 -4
  17. package/scale-large.js.map +1 -1
  18. package/scale-medium.js +1 -4
  19. package/scale-medium.js.map +1 -1
  20. package/sp-theme.js +1 -2
  21. package/sp-theme.js.map +1 -1
  22. package/src/Theme.js +1 -298
  23. package/src/Theme.js.map +1 -1
  24. package/src/express/core.js +1 -3
  25. package/src/express/core.js.map +1 -1
  26. package/src/express/scale-large.css.js +2 -4
  27. package/src/express/scale-large.css.js.map +1 -1
  28. package/src/express/scale-medium.css.js +2 -4
  29. package/src/express/scale-medium.css.js.map +1 -1
  30. package/src/express/theme-dark.css.js +2 -4
  31. package/src/express/theme-dark.css.js.map +1 -1
  32. package/src/express/theme-light.css.js +2 -4
  33. package/src/express/theme-light.css.js.map +1 -1
  34. package/src/express/theme.css.js +2 -4
  35. package/src/express/theme.css.js.map +1 -1
  36. package/src/express/themes.js +1 -6
  37. package/src/express/themes.js.map +1 -1
  38. package/src/index.js +1 -1
  39. package/src/index.js.map +1 -1
  40. package/src/scale-large.css.js +2 -4
  41. package/src/scale-large.css.js.map +1 -1
  42. package/src/scale-medium.css.js +2 -4
  43. package/src/scale-medium.css.js.map +1 -1
  44. package/src/theme-dark.css.js +2 -4
  45. package/src/theme-dark.css.js.map +1 -1
  46. package/src/theme-darkest.css.js +2 -4
  47. package/src/theme-darkest.css.js.map +1 -1
  48. package/src/theme-light.css.js +2 -4
  49. package/src/theme-light.css.js.map +1 -1
  50. package/src/theme-lightest.css.js +2 -4
  51. package/src/theme-lightest.css.js.map +1 -1
  52. package/src/theme.css.js +2 -4
  53. package/src/theme.css.js.map +1 -1
  54. package/src/themes.js +1 -6
  55. package/src/themes.js.map +1 -1
  56. package/src/typography.css.js +2 -4
  57. package/src/typography.css.js.map +1 -1
  58. package/stories/theme.stories.js +14 -55
  59. package/stories/theme.stories.js.map +1 -1
  60. package/test/theme-devmode.test.js +2 -23
  61. package/test/theme-devmode.test.js.map +1 -1
  62. package/test/theme-lazy.test.js +6 -95
  63. package/test/theme-lazy.test.js.map +1 -1
  64. package/test/theme.test-vrt.js +1 -3
  65. package/test/theme.test-vrt.js.map +1 -1
  66. package/test/themes.test.js +10 -116
  67. package/test/themes.test.js.map +1 -1
  68. package/theme-dark.js +1 -4
  69. package/theme-dark.js.map +1 -1
  70. package/theme-darkest.js +1 -4
  71. package/theme-darkest.js.map +1 -1
  72. package/theme-light.js +1 -4
  73. package/theme-light.js.map +1 -1
  74. package/theme-lightest.js +1 -4
  75. package/theme-lightest.js.map +1 -1
package/core.js CHANGED
@@ -1,4 +1,2 @@
1
- import { Theme } from "./src/Theme.js";
2
- import coreStyles from "./src/theme.css.js";
3
- Theme.registerThemeFragment("spectrum", "theme", coreStyles);
1
+ import{Theme as e}from"./src/Theme.js";import m from"./src/theme.css.js";e.registerThemeFragment("spectrum","theme",m);
4
2
  //# sourceMappingURL=core.js.map
package/core.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["core.ts"],
4
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\nimport { Theme } from './src/Theme.js';\n\nimport coreStyles from './src/theme.css.js';\n\nTheme.registerThemeFragment('spectrum', 'theme', coreStyles);\n"],
5
- "mappings": "AAYA;AAEA;AAEA,MAAM,sBAAsB,YAAY,SAAS,UAAU;",
5
+ "mappings": "AAYA,uCAEA,kCAEA,EAAM,sBAAsB,WAAY,QAAS,CAAU",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,2 @@
1
- import largeStyles from "../src/express/scale-large.css.js";
2
- import { Theme } from "../src/Theme.js";
3
- import "../src/express/core.js";
4
- Theme.registerThemeFragment("large-express", "scale", largeStyles);
1
+ import e from"../src/express/scale-large.css.js";import{Theme as r}from"../src/Theme.js";import"../src/express/core.js";r.registerThemeFragment("large-express","scale",e);
5
2
  //# sourceMappingURL=scale-large.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["scale-large.ts"],
4
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\nimport largeStyles from '../src/express/scale-large.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/express/core.js';\n\nTheme.registerThemeFragment('large-express', 'scale', largeStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,iBAAiB,SAAS,WAAW;",
5
+ "mappings": "AAYA,iDACA,wCACA,+BAEA,EAAM,sBAAsB,gBAAiB,QAAS,CAAW",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,2 @@
1
- import mediumStyles from "../src/express/scale-medium.css.js";
2
- import { Theme } from "../src/Theme.js";
3
- import "../src/express/core.js";
4
- Theme.registerThemeFragment("medium-express", "scale", mediumStyles);
1
+ import e from"../src/express/scale-medium.css.js";import{Theme as m}from"../src/Theme.js";import"../src/express/core.js";m.registerThemeFragment("medium-express","scale",e);
5
2
  //# sourceMappingURL=scale-medium.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["scale-medium.ts"],
4
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\nimport mediumStyles from '../src/express/scale-medium.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/express/core.js';\n\nTheme.registerThemeFragment('medium-express', 'scale', mediumStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,kBAAkB,SAAS,YAAY;",
5
+ "mappings": "AAYA,kDACA,wCACA,+BAEA,EAAM,sBAAsB,iBAAkB,QAAS,CAAY",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,2 @@
1
- import darkStyles from "../src/express/theme-dark.css.js";
2
- import { Theme } from "../src/Theme.js";
3
- import "../src/express/core.js";
4
- Theme.registerThemeFragment("dark-express", "color", darkStyles);
1
+ import r from"../src/express/theme-dark.css.js";import{Theme as e}from"../src/Theme.js";import"../src/express/core.js";e.registerThemeFragment("dark-express","color",r);
5
2
  //# sourceMappingURL=theme-dark.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["theme-dark.ts"],
4
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\nimport darkStyles from '../src/express/theme-dark.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/express/core.js';\n\nTheme.registerThemeFragment('dark-express', 'color', darkStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,gBAAgB,SAAS,UAAU;",
5
+ "mappings": "AAYA,gDACA,wCACA,+BAEA,EAAM,sBAAsB,eAAgB,QAAS,CAAU",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,2 @@
1
- import darkStyles from "../src/express/theme-dark.css.js";
2
- import { Theme } from "../src/Theme.js";
3
- import "../src/express/core.js";
4
- Theme.registerThemeFragment("darkest-express", "color", darkStyles);
1
+ import r from"../src/express/theme-dark.css.js";import{Theme as e}from"../src/Theme.js";import"../src/express/core.js";e.registerThemeFragment("darkest-express","color",r);
5
2
  //# sourceMappingURL=theme-darkest.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["theme-darkest.ts"],
4
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\nimport darkStyles from '../src/express/theme-dark.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/express/core.js';\n\nTheme.registerThemeFragment('darkest-express', 'color', darkStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,mBAAmB,SAAS,UAAU;",
5
+ "mappings": "AAYA,gDACA,wCACA,+BAEA,EAAM,sBAAsB,kBAAmB,QAAS,CAAU",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,2 @@
1
- import lightStyles from "../src/express/theme-light.css.js";
2
- import { Theme } from "../src/Theme.js";
3
- import "../src/express/core.js";
4
- Theme.registerThemeFragment("light-express", "color", lightStyles);
1
+ import e from"../src/express/theme-light.css.js";import{Theme as r}from"../src/Theme.js";import"../src/express/core.js";r.registerThemeFragment("light-express","color",e);
5
2
  //# sourceMappingURL=theme-light.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["theme-light.ts"],
4
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\nimport lightStyles from '../src/express/theme-light.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/express/core.js';\n\nTheme.registerThemeFragment('light-express', 'color', lightStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,iBAAiB,SAAS,WAAW;",
5
+ "mappings": "AAYA,iDACA,wCACA,+BAEA,EAAM,sBAAsB,gBAAiB,QAAS,CAAW",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,2 @@
1
- import lightStyles from "../src/express/theme-light.css.js";
2
- import { Theme } from "../src/Theme.js";
3
- import "../src/express/core.js";
4
- Theme.registerThemeFragment("lightest-express", "color", lightStyles);
1
+ import e from"../src/express/theme-light.css.js";import{Theme as r}from"../src/Theme.js";import"../src/express/core.js";r.registerThemeFragment("lightest-express","color",e);
5
2
  //# sourceMappingURL=theme-lightest.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["theme-lightest.ts"],
4
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\nimport lightStyles from '../src/express/theme-light.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/express/core.js';\n\nTheme.registerThemeFragment('lightest-express', 'color', lightStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,oBAAoB,SAAS,WAAW;",
5
+ "mappings": "AAYA,iDACA,wCACA,+BAEA,EAAM,sBAAsB,mBAAoB,QAAS,CAAW",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/theme",
3
- "version": "0.14.0-devmode.0+7b0ea531e",
3
+ "version": "0.14.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -133,8 +133,8 @@
133
133
  "lit-html"
134
134
  ],
135
135
  "dependencies": {
136
- "@spectrum-web-components/base": "^0.6.0",
137
- "@spectrum-web-components/styles": "^0.15.1",
136
+ "@spectrum-web-components/base": "^0.7.0",
137
+ "@spectrum-web-components/styles": "^0.16.0",
138
138
  "tslib": "^2.0.0"
139
139
  },
140
140
  "types": "./src/index.d.ts",
@@ -151,5 +151,5 @@
151
151
  "./src/express/core.js",
152
152
  "./src/express/themes.js"
153
153
  ],
154
- "gitHead": "7b0ea531e9c7225c8964c5429bc5fd005618b80e"
154
+ "gitHead": "05c81318844160db3f8156144106e643507fef97"
155
155
  }
package/scale-large.js CHANGED
@@ -1,5 +1,2 @@
1
- import largeStyles from "./src/scale-large.css.js";
2
- import { Theme } from "./src/Theme.js";
3
- import "./core.js";
4
- Theme.registerThemeFragment("large", "scale", largeStyles);
1
+ import e from"./src/scale-large.css.js";import{Theme as r}from"./src/Theme.js";import"./core.js";r.registerThemeFragment("large","scale",e);
5
2
  //# sourceMappingURL=scale-large.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["scale-large.ts"],
4
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\nimport largeStyles from './src/scale-large.css.js';\nimport { Theme } from './src/Theme.js';\nimport './core.js';\n\nTheme.registerThemeFragment('large', 'scale', largeStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,SAAS,SAAS,WAAW;",
5
+ "mappings": "AAYA,wCACA,uCACA,kBAEA,EAAM,sBAAsB,QAAS,QAAS,CAAW",
6
6
  "names": []
7
7
  }
package/scale-medium.js CHANGED
@@ -1,5 +1,2 @@
1
- import mediumStyles from "./src/scale-medium.css.js";
2
- import { Theme } from "./src/Theme.js";
3
- import "./core.js";
4
- Theme.registerThemeFragment("medium", "scale", mediumStyles);
1
+ import m from"./src/scale-medium.css.js";import{Theme as e}from"./src/Theme.js";import"./core.js";e.registerThemeFragment("medium","scale",m);
5
2
  //# sourceMappingURL=scale-medium.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["scale-medium.ts"],
4
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\nimport mediumStyles from './src/scale-medium.css.js';\nimport { Theme } from './src/Theme.js';\nimport './core.js';\n\nTheme.registerThemeFragment('medium', 'scale', mediumStyles);\n"],
5
- "mappings": "AAYA;AACA;AACA;AAEA,MAAM,sBAAsB,UAAU,SAAS,YAAY;",
5
+ "mappings": "AAYA,yCACA,uCACA,kBAEA,EAAM,sBAAsB,SAAU,QAAS,CAAY",
6
6
  "names": []
7
7
  }
package/sp-theme.js CHANGED
@@ -1,3 +1,2 @@
1
- import { Theme } from "./src/Theme.js";
2
- customElements.define("sp-theme", Theme);
1
+ import{Theme as e}from"./src/Theme.js";customElements.define("sp-theme",e);
3
2
  //# sourceMappingURL=sp-theme.js.map
package/sp-theme.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["sp-theme.ts"],
4
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 { Theme } from './src/Theme.js';\n\ncustomElements.define('sp-theme', Theme);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-theme': Theme;\n }\n}\n"],
5
- "mappings": "AAWA;AAEA,eAAe,OAAO,YAAY,KAAK;",
5
+ "mappings": "AAWA,uCAEA,eAAe,OAAO,WAAY,CAAK",
6
6
  "names": []
7
7
  }
package/src/Theme.js CHANGED
@@ -1,299 +1,2 @@
1
- import {
2
- supportsAdoptingStyleSheets
3
- } from "@spectrum-web-components/base";
4
- const ThemeVariantValues = ["spectrum", "express"];
5
- const ScaleValues = ["medium", "large", "medium-express", "large-express"];
6
- const ColorValues = [
7
- "light",
8
- "lightest",
9
- "dark",
10
- "darkest",
11
- "light-express",
12
- "lightest-express",
13
- "dark-express",
14
- "darkest-express"
15
- ];
16
- const _Theme = class extends HTMLElement {
17
- constructor() {
18
- super();
19
- this._dir = "";
20
- this._theme = "spectrum";
21
- this._color = "";
22
- this._scale = "";
23
- this.trackedChildren = /* @__PURE__ */ new Set();
24
- this._updateRequested = false;
25
- this._contextConsumers = /* @__PURE__ */ new Map();
26
- this.attachShadow({ mode: "open" });
27
- const node = document.importNode(_Theme.template.content, true);
28
- this.shadowRoot.appendChild(node);
29
- this.shouldAdoptStyles();
30
- this.addEventListener("sp-query-theme", this.onQueryTheme);
31
- this.addEventListener("sp-language-context", this._handleContextPresence);
32
- this.updateComplete = this.__createDeferredPromise();
33
- }
34
- static get observedAttributes() {
35
- return ["color", "scale", "theme", "lang", "dir"];
36
- }
37
- set dir(dir) {
38
- if (dir === this.dir)
39
- return;
40
- this.setAttribute("dir", dir);
41
- this._dir = dir;
42
- const targetDir = dir === "rtl" ? dir : "ltr";
43
- this.trackedChildren.forEach((el) => {
44
- el.setAttribute("dir", targetDir);
45
- });
46
- }
47
- get dir() {
48
- return this._dir;
49
- }
50
- attributeChangedCallback(attrName, old, value) {
51
- if (old === value) {
52
- return;
53
- }
54
- if (attrName === "color") {
55
- this.color = value;
56
- } else if (attrName === "scale") {
57
- this.scale = value;
58
- } else if (attrName === "lang" && !!value) {
59
- this.lang = value;
60
- this._provideContext();
61
- } else if (attrName === "theme") {
62
- this.theme = value;
63
- } else if (attrName === "dir") {
64
- this.dir = value;
65
- }
66
- }
67
- requestUpdate() {
68
- if (window.ShadyCSS !== void 0 && !window.ShadyCSS.nativeShadow) {
69
- window.ShadyCSS.styleElement(this);
70
- } else {
71
- this.shouldAdoptStyles();
72
- }
73
- }
74
- get theme() {
75
- const themeFragments = _Theme.themeFragmentsByKind.get("theme");
76
- const { name } = themeFragments && themeFragments.get("default") || {};
77
- return this._theme || name || "";
78
- }
79
- set theme(newValue) {
80
- if (newValue === this._theme)
81
- return;
82
- const theme = !!newValue && ThemeVariantValues.includes(newValue) ? newValue : this.theme;
83
- if (theme !== this._theme) {
84
- this._theme = theme;
85
- this.requestUpdate();
86
- }
87
- if (theme) {
88
- this.setAttribute("theme", theme);
89
- } else {
90
- this.removeAttribute("theme");
91
- }
92
- }
93
- get color() {
94
- const themeFragments = _Theme.themeFragmentsByKind.get("color");
95
- const { name } = themeFragments && themeFragments.get("default") || {};
96
- return this._color || name || "";
97
- }
98
- set color(newValue) {
99
- if (newValue === this._color)
100
- return;
101
- const color = !!newValue && ColorValues.includes(newValue) ? newValue : this.color;
102
- if (color !== this._color) {
103
- this._color = color;
104
- this.requestUpdate();
105
- }
106
- if (color) {
107
- this.setAttribute("color", color);
108
- } else {
109
- this.removeAttribute("color");
110
- }
111
- }
112
- get scale() {
113
- const themeFragments = _Theme.themeFragmentsByKind.get("scale");
114
- const { name } = themeFragments && themeFragments.get("default") || {};
115
- return this._scale || name || "";
116
- }
117
- set scale(newValue) {
118
- if (newValue === this._scale)
119
- return;
120
- const scale = !!newValue && ScaleValues.includes(newValue) ? newValue : this.scale;
121
- if (scale !== this._scale) {
122
- this._scale = scale;
123
- this.requestUpdate();
124
- }
125
- if (scale) {
126
- this.setAttribute("scale", scale);
127
- } else {
128
- this.removeAttribute("scale");
129
- }
130
- }
131
- get styles() {
132
- const themeKinds = [
133
- ..._Theme.themeFragmentsByKind.keys()
134
- ];
135
- const getStyle = (fragments, name, kind) => {
136
- const currentStyles = kind && kind !== "theme" && this.theme === "express" ? fragments.get(`${name}-express`) : fragments.get(name);
137
- const isAppliedFragment = name === "spectrum" || !kind || this.hasAttribute(kind);
138
- if (currentStyles && isAppliedFragment) {
139
- return currentStyles.styles;
140
- }
141
- return;
142
- };
143
- const styles = themeKinds.reduce((acc, kind) => {
144
- const kindFragments = _Theme.themeFragmentsByKind.get(kind);
145
- let style;
146
- if (kind === "app" || kind === "core") {
147
- style = getStyle(kindFragments, kind);
148
- } else {
149
- const { [kind]: name } = this;
150
- style = getStyle(kindFragments, name, kind);
151
- }
152
- if (style) {
153
- acc.push(style);
154
- }
155
- return acc;
156
- }, []);
157
- if (false) {
158
- const issues = [];
159
- const checkForAttribute = (name, resolvedValue, actualValue) => {
160
- var _a;
161
- const themeModifier = this.theme && this.theme !== "spectrum" ? `-${this.theme}` : "";
162
- if (!resolvedValue) {
163
- issues.push(`You have not explicitly set the "${name}" attribute and there is no default value on which to fallback.`);
164
- } else if (!actualValue) {
165
- issues.push(`You have not explicitly set the "${name}" attribute, the default value ("${resolvedValue}") is being used as a fallback.`);
166
- } else if (!((_a = _Theme.themeFragmentsByKind.get(name)) == null ? void 0 : _a.get(resolvedValue + themeModifier))) {
167
- issues.push(`You have set "${name}='${resolvedValue}'" but the associated theme fragment has not been loaded.`);
168
- }
169
- };
170
- checkForAttribute("theme", this.theme, this._theme);
171
- checkForAttribute("color", this.color, this._color);
172
- checkForAttribute("scale", this.scale, this._scale);
173
- if (issues.length) {
174
- window.__swc.warn(this, "You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:", "https://opensource.adobe.com/spectrum-web-components/components/theme/#example", {
175
- issues
176
- });
177
- }
178
- }
179
- return [...styles];
180
- }
181
- static get template() {
182
- if (!this.templateElement) {
183
- this.templateElement = document.createElement("template");
184
- this.templateElement.innerHTML = "<slot></slot>";
185
- }
186
- return this.templateElement;
187
- }
188
- __createDeferredPromise() {
189
- return new Promise((resolve) => {
190
- this.__resolve = resolve;
191
- });
192
- }
193
- onQueryTheme(event) {
194
- if (event.defaultPrevented) {
195
- return;
196
- }
197
- event.preventDefault();
198
- const { detail: theme } = event;
199
- theme.color = this.color || void 0;
200
- theme.scale = this.scale || void 0;
201
- theme.lang = this.lang || document.documentElement.lang || navigator.language;
202
- theme.theme = this.theme || void 0;
203
- }
204
- connectedCallback() {
205
- this.shouldAdoptStyles();
206
- if (window.ShadyCSS !== void 0) {
207
- window.ShadyCSS.styleElement(this);
208
- }
209
- _Theme.instances.add(this);
210
- if (!this.hasAttribute("dir")) {
211
- let dirParent = this.assignedSlot || this.parentNode;
212
- while (dirParent !== document.documentElement && !(dirParent instanceof _Theme)) {
213
- dirParent = dirParent.assignedSlot || dirParent.parentNode || dirParent.host;
214
- }
215
- this.dir = dirParent.dir === "rtl" ? dirParent.dir : "ltr";
216
- }
217
- }
218
- disconnectedCallback() {
219
- _Theme.instances.delete(this);
220
- }
221
- startManagingContentDirection(el) {
222
- this.trackedChildren.add(el);
223
- }
224
- stopManagingContentDirection(el) {
225
- this.trackedChildren.delete(el);
226
- }
227
- async shouldAdoptStyles() {
228
- if (!this._updateRequested) {
229
- this.updateComplete = this.__createDeferredPromise();
230
- this._updateRequested = true;
231
- this._updateRequested = await false;
232
- this.adoptStyles();
233
- this.__resolve(true);
234
- }
235
- }
236
- adoptStyles() {
237
- const styles = this.styles;
238
- if (window.ShadyCSS !== void 0 && !window.ShadyCSS.nativeShadow && window.ShadyCSS.ScopingShim) {
239
- const fragmentCSS = [];
240
- for (const [kind, fragments] of _Theme.themeFragmentsByKind) {
241
- for (const [name, { styles: styles2 }] of fragments) {
242
- if (name === "default")
243
- continue;
244
- let cssText = styles2.cssText;
245
- if (!_Theme.defaultFragments.has(name)) {
246
- cssText = cssText.replace(":host", `:host([${kind}='${name}'])`);
247
- }
248
- fragmentCSS.push(cssText);
249
- }
250
- }
251
- window.ShadyCSS.ScopingShim.prepareAdoptedCssText(fragmentCSS, this.localName);
252
- window.ShadyCSS.prepareTemplate(_Theme.template, this.localName);
253
- } else if (supportsAdoptingStyleSheets) {
254
- const styleSheets = [];
255
- for (const style of styles) {
256
- styleSheets.push(style.styleSheet);
257
- }
258
- this.shadowRoot.adoptedStyleSheets = styleSheets;
259
- } else {
260
- const styleNodes = this.shadowRoot.querySelectorAll("style");
261
- styleNodes.forEach((element) => element.remove());
262
- styles.forEach((s) => {
263
- const style = document.createElement("style");
264
- style.textContent = s.cssText;
265
- this.shadowRoot.appendChild(style);
266
- });
267
- }
268
- }
269
- static registerThemeFragment(name, kind, styles) {
270
- const fragmentMap = _Theme.themeFragmentsByKind.get(kind) || /* @__PURE__ */ new Map();
271
- if (fragmentMap.size === 0) {
272
- _Theme.themeFragmentsByKind.set(kind, fragmentMap);
273
- fragmentMap.set("default", { name, styles });
274
- _Theme.defaultFragments.add(name);
275
- }
276
- fragmentMap.set(name, { name, styles });
277
- _Theme.instances.forEach((instance) => instance.shouldAdoptStyles());
278
- }
279
- _provideContext() {
280
- this._contextConsumers.forEach((consume) => consume(this.lang));
281
- }
282
- _handleContextPresence(event) {
283
- const target = event.composedPath()[0];
284
- if (this._contextConsumers.has(target)) {
285
- this._contextConsumers.delete(target);
286
- } else {
287
- this._contextConsumers.set(target, event.detail.callback);
288
- const callback = this._contextConsumers.get(target);
289
- if (callback) {
290
- callback(this.lang || document.documentElement.lang || navigator.language);
291
- }
292
- }
293
- }
294
- };
295
- export let Theme = _Theme;
296
- Theme.themeFragmentsByKind = /* @__PURE__ */ new Map();
297
- Theme.defaultFragments = /* @__PURE__ */ new Set(["spectrum"]);
298
- Theme.instances = /* @__PURE__ */ new Set();
1
+ import{supportsAdoptingStyleSheets as h}from"@spectrum-web-components/base";const d=["spectrum","express"],m=["medium","large","medium-express","large-express"],c=["light","lightest","dark","darkest","light-express","lightest-express","dark-express","darkest-express"],a=class extends HTMLElement{constructor(){super();this._dir="";this._theme="spectrum";this._color="";this._scale="";this.trackedChildren=new Set;this._updateRequested=!1;this._contextConsumers=new Map;this.attachShadow({mode:"open"});const e=document.importNode(a.template.content,!0);this.shadowRoot.appendChild(e),this.shouldAdoptStyles(),this.addEventListener("sp-query-theme",this.onQueryTheme),this.addEventListener("sp-language-context",this._handleContextPresence),this.updateComplete=this.__createDeferredPromise()}static get observedAttributes(){return["color","scale","theme","lang","dir"]}set dir(e){if(e===this.dir)return;this.setAttribute("dir",e),this._dir=e;const t=e==="rtl"?e:"ltr";this.trackedChildren.forEach(s=>{s.setAttribute("dir",t)})}get dir(){return this._dir}attributeChangedCallback(e,t,s){t!==s&&(e==="color"?this.color=s:e==="scale"?this.scale=s:e==="lang"&&!!s?(this.lang=s,this._provideContext()):e==="theme"?this.theme=s:e==="dir"&&(this.dir=s))}requestUpdate(){window.ShadyCSS!==void 0&&!window.ShadyCSS.nativeShadow?window.ShadyCSS.styleElement(this):this.shouldAdoptStyles()}get theme(){const e=a.themeFragmentsByKind.get("theme"),{name:t}=e&&e.get("default")||{};return this._theme||t||""}set theme(e){if(e===this._theme)return;const t=!!e&&d.includes(e)?e:this.theme;t!==this._theme&&(this._theme=t,this.requestUpdate()),t?this.setAttribute("theme",t):this.removeAttribute("theme")}get color(){const e=a.themeFragmentsByKind.get("color"),{name:t}=e&&e.get("default")||{};return this._color||t||""}set color(e){if(e===this._color)return;const t=!!e&&c.includes(e)?e:this.color;t!==this._color&&(this._color=t,this.requestUpdate()),t?this.setAttribute("color",t):this.removeAttribute("color")}get scale(){const e=a.themeFragmentsByKind.get("scale"),{name:t}=e&&e.get("default")||{};return this._scale||t||""}set scale(e){if(e===this._scale)return;const t=!!e&&m.includes(e)?e:this.scale;t!==this._scale&&(this._scale=t,this.requestUpdate()),t?this.setAttribute("scale",t):this.removeAttribute("scale")}get styles(){const e=[...a.themeFragmentsByKind.keys()],t=(i,r,n)=>{const o=n&&n!=="theme"&&this.theme==="express"?i.get(`${r}-express`):i.get(r),l=r==="spectrum"||!n||this.hasAttribute(n);if(o&&l)return o.styles};return[...e.reduce((i,r)=>{const n=a.themeFragmentsByKind.get(r);let o;if(r==="app"||r==="core")o=t(n,r);else{const{[r]:l}=this;o=t(n,l,r)}return o&&i.push(o),i},[])]}static get template(){return this.templateElement||(this.templateElement=document.createElement("template"),this.templateElement.innerHTML="<slot></slot>"),this.templateElement}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}onQueryTheme(e){if(e.defaultPrevented)return;e.preventDefault();const{detail:t}=e;t.color=this.color||void 0,t.scale=this.scale||void 0,t.lang=this.lang||document.documentElement.lang||navigator.language,t.theme=this.theme||void 0}connectedCallback(){if(this.shouldAdoptStyles(),window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this),a.instances.add(this),!this.hasAttribute("dir")){let e=this.assignedSlot||this.parentNode;for(;e!==document.documentElement&&!(e instanceof a);)e=e.assignedSlot||e.parentNode||e.host;this.dir=e.dir==="rtl"?e.dir:"ltr"}}disconnectedCallback(){a.instances.delete(this)}startManagingContentDirection(e){this.trackedChildren.add(e)}stopManagingContentDirection(e){this.trackedChildren.delete(e)}async shouldAdoptStyles(){this._updateRequested||(this.updateComplete=this.__createDeferredPromise(),this._updateRequested=!0,this._updateRequested=await!1,this.adoptStyles(),this.__resolve(!0))}adoptStyles(){const e=this.styles;if(window.ShadyCSS!==void 0&&!window.ShadyCSS.nativeShadow&&window.ShadyCSS.ScopingShim){const t=[];for(const[s,i]of a.themeFragmentsByKind)for(const[r,{styles:n}]of i){if(r==="default")continue;let o=n.cssText;a.defaultFragments.has(r)||(o=o.replace(":host",`:host([${s}='${r}'])`)),t.push(o)}window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t,this.localName),window.ShadyCSS.prepareTemplate(a.template,this.localName)}else if(h){const t=[];for(const s of e)t.push(s.styleSheet);this.shadowRoot.adoptedStyleSheets=t}else this.shadowRoot.querySelectorAll("style").forEach(s=>s.remove()),e.forEach(s=>{const i=document.createElement("style");i.textContent=s.cssText,this.shadowRoot.appendChild(i)})}static registerThemeFragment(e,t,s){const i=a.themeFragmentsByKind.get(t)||new Map;i.size===0&&(a.themeFragmentsByKind.set(t,i),i.set("default",{name:e,styles:s}),a.defaultFragments.add(e)),i.set(e,{name:e,styles:s}),a.instances.forEach(r=>r.shouldAdoptStyles())}_provideContext(){this._contextConsumers.forEach(e=>e(this.lang))}_handleContextPresence(e){const t=e.composedPath()[0];if(this._contextConsumers.has(t))this._contextConsumers.delete(t);else{this._contextConsumers.set(t,e.detail.callback);const s=this._contextConsumers.get(t);s&&s(this.lang||document.documentElement.lang||navigator.language)}}};export let Theme=a;Theme.themeFragmentsByKind=new Map,Theme.defaultFragments=new Set(["spectrum"]),Theme.instances=new Set;
299
2
  //# sourceMappingURL=Theme.js.map