@spectrum-web-components/theme 0.9.2-express.0 → 0.9.2

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 (45) hide show
  1. package/README.md +38 -56
  2. package/custom-elements.json +4 -164
  3. package/package.json +4 -11
  4. package/src/Theme.d.ts +7 -12
  5. package/src/Theme.js +13 -57
  6. package/src/Theme.js.map +1 -1
  7. package/src/scale-large.css.js +1 -1
  8. package/src/scale-large.css.js.map +1 -1
  9. package/src/scale-medium.css.js +1 -1
  10. package/src/scale-medium.css.js.map +1 -1
  11. package/src/typography.css.js +1 -1
  12. package/src/typography.css.js.map +1 -1
  13. package/express/scale-large.d.ts +0 -1
  14. package/express/scale-large.js +0 -15
  15. package/express/scale-large.js.map +0 -1
  16. package/express/scale-medium.d.ts +0 -1
  17. package/express/scale-medium.js +0 -15
  18. package/express/scale-medium.js.map +0 -1
  19. package/express/theme-dark.d.ts +0 -1
  20. package/express/theme-dark.js +0 -15
  21. package/express/theme-dark.js.map +0 -1
  22. package/express/theme-light.d.ts +0 -1
  23. package/express/theme-light.js +0 -15
  24. package/express/theme-light.js.map +0 -1
  25. package/src/express/core.d.ts +0 -1
  26. package/src/express/core.js +0 -15
  27. package/src/express/core.js.map +0 -1
  28. package/src/express/scale-large.css.d.ts +0 -2
  29. package/src/express/scale-large.css.js +0 -3267
  30. package/src/express/scale-large.css.js.map +0 -1
  31. package/src/express/scale-medium.css.d.ts +0 -2
  32. package/src/express/scale-medium.css.js +0 -3305
  33. package/src/express/scale-medium.css.js.map +0 -1
  34. package/src/express/theme-dark.css.d.ts +0 -2
  35. package/src/express/theme-dark.css.js +0 -29
  36. package/src/express/theme-dark.css.js.map +0 -1
  37. package/src/express/theme-light.css.d.ts +0 -2
  38. package/src/express/theme-light.css.js +0 -29
  39. package/src/express/theme-light.css.js.map +0 -1
  40. package/src/express/theme.css.d.ts +0 -2
  41. package/src/express/theme.css.js +0 -1365
  42. package/src/express/theme.css.js.map +0 -1
  43. package/src/express/themes.d.ts +0 -5
  44. package/src/express/themes.js +0 -17
  45. package/src/express/themes.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/theme",
3
- "version": "0.9.2-express.0+05f17c2d6",
3
+ "version": "0.9.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -22,8 +22,6 @@
22
22
  "exports": {
23
23
  ".": "./src/index.js",
24
24
  "./src/*": "./src/*",
25
- "./express/*": "./express/*",
26
- "./src/express/*": "./src/express/*",
27
25
  "./package.json": "./package.json",
28
26
  "./sp-theme": "./sp-theme.js",
29
27
  "./sp-theme.js": "./sp-theme.js",
@@ -59,7 +57,7 @@
59
57
  ],
60
58
  "dependencies": {
61
59
  "@spectrum-web-components/base": "^0.5.1",
62
- "@spectrum-web-components/styles": "^0.11.2-express.0+05f17c2d6",
60
+ "@spectrum-web-components/styles": "^0.11.2",
63
61
  "tslib": "^2.0.0"
64
62
  },
65
63
  "types": "./src/index.d.ts",
@@ -68,12 +66,7 @@
68
66
  "./sp-*.js",
69
67
  "./theme-*.js",
70
68
  "./scale-*.js",
71
- "./express/theme-*.js",
72
- "./express/theme-*.ts",
73
- "./express/scale-*.js",
74
- "./src/themes.js",
75
- "./src/express/core.js",
76
- "./src/express/themes.js"
69
+ "./src/themes.js"
77
70
  ],
78
- "gitHead": "05f17c2d6789de73b10a3f0abc0ae625b83d728b"
71
+ "gitHead": "5ad16bd185710525afa48bd76099cb0ebde4c4cb"
79
72
  }
package/src/Theme.d.ts CHANGED
@@ -14,25 +14,23 @@ declare global {
14
14
  declare type ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {
15
15
  adoptedStyleSheets?: CSSStyleSheet[];
16
16
  };
17
- declare type FragmentType = 'color' | 'scale' | 'theme' | 'core' | 'app';
18
- declare type SettableFragmentTypes = 'color' | 'scale' | 'theme';
17
+ declare type FragmentType = 'color' | 'scale' | 'core' | 'app';
18
+ declare type SettableFragmentTypes = 'color' | 'scale';
19
19
  declare type FragmentMap = Map<string, {
20
20
  name: string;
21
21
  styles: CSSResultGroup;
22
22
  }>;
23
23
  export declare type ThemeFragmentMap = Map<FragmentType, FragmentMap>;
24
- export declare type Color = 'light' | 'lightest' | 'dark' | 'darkest' | 'light-express' | 'lightest-express' | 'dark-express' | 'darkest-express';
25
- export declare type Scale = 'medium' | 'large' | 'medium-express' | 'large-express';
26
- export declare type Flavor = 'spectrum' | 'express';
27
- declare type FragmentName = Color | Scale | Flavor | 'core' | 'app';
24
+ export declare type Color = 'light' | 'lightest' | 'dark' | 'darkest';
25
+ export declare type Scale = 'medium' | 'large';
26
+ declare type FragmentName = Color | Scale | 'core' | 'app';
28
27
  export interface ThemeData {
29
28
  color?: Color;
30
29
  scale?: Scale;
31
30
  lang?: string;
32
- theme?: Flavor;
33
31
  }
34
32
  declare type ThemeKindProvider = {
35
- [P in SettableFragmentTypes]: Flavor | Color | Scale | '';
33
+ [P in SettableFragmentTypes]: Color | Scale | '';
36
34
  };
37
35
  export interface ProvideLang {
38
36
  callback: (lang: string) => void;
@@ -48,12 +46,9 @@ export declare class Theme extends HTMLElement implements ThemeKindProvider {
48
46
  private static templateElement?;
49
47
  private static instances;
50
48
  static get observedAttributes(): string[];
51
- protected attributeChangedCallback(attrName: SettableFragmentTypes | 'lang', old: string | null, value: string | null): void;
49
+ protected attributeChangedCallback(attrName: SettableFragmentTypes, old: string | null, value: string | null): void;
52
50
  private requestUpdate;
53
51
  shadowRoot: ShadowRootWithAdoptedStyleSheets;
54
- private _theme;
55
- get theme(): Flavor | '';
56
- set theme(newValue: Flavor | '');
57
52
  private _color;
58
53
  get color(): Color | '';
59
54
  set color(newValue: Color | '');
package/src/Theme.js CHANGED
@@ -11,18 +11,8 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  import { supportsAdoptingStyleSheets, } from '@spectrum-web-components/base';
13
13
  import coreStyles from './theme.css.js';
14
- const FlavorValues = ['spectrum', 'express'];
15
- const ScaleValues = ['medium', 'large', 'medium-express', 'large-express'];
16
- const ColorValues = [
17
- 'light',
18
- 'lightest',
19
- 'dark',
20
- 'darkest',
21
- 'light-express',
22
- 'lightest-express',
23
- 'dark-express',
24
- 'darkest-express',
25
- ];
14
+ const ScaleValues = ['medium', 'large'];
15
+ const ColorValues = ['light', 'lightest', 'dark', 'darkest'];
26
16
  /**
27
17
  * @element sp-theme
28
18
  *
@@ -31,7 +21,6 @@ const ColorValues = [
31
21
  export class Theme extends HTMLElement {
32
22
  constructor() {
33
23
  super();
34
- this._theme = 'spectrum';
35
24
  this._color = '';
36
25
  this._scale = '';
37
26
  this.trackedChildren = new Set();
@@ -46,7 +35,7 @@ export class Theme extends HTMLElement {
46
35
  this.updateComplete = this.__createDeferredPromise();
47
36
  }
48
37
  static get observedAttributes() {
49
- return ['color', 'scale', 'theme', 'lang'];
38
+ return ['color', 'scale', 'lang'];
50
39
  }
51
40
  attributeChangedCallback(attrName, old, value) {
52
41
  if (old === value) {
@@ -62,9 +51,6 @@ export class Theme extends HTMLElement {
62
51
  this.lang = value;
63
52
  this._provideContext();
64
53
  }
65
- else if (attrName === 'theme') {
66
- this.theme = value;
67
- }
68
54
  }
69
55
  requestUpdate() {
70
56
  if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
@@ -74,28 +60,6 @@ export class Theme extends HTMLElement {
74
60
  this.shouldAdoptStyles();
75
61
  }
76
62
  }
77
- get theme() {
78
- const themeFragments = Theme.themeFragmentsByKind.get('theme');
79
- const { name } = (themeFragments && themeFragments.get('default')) || {};
80
- return this._theme || name || '';
81
- }
82
- set theme(newValue) {
83
- if (newValue === this._theme)
84
- return;
85
- const theme = !!newValue && FlavorValues.includes(newValue)
86
- ? newValue
87
- : this.theme;
88
- if (theme !== this._theme) {
89
- this._theme = theme;
90
- this.requestUpdate();
91
- }
92
- if (theme) {
93
- this.setAttribute('theme', theme);
94
- }
95
- else {
96
- this.removeAttribute('theme');
97
- }
98
- }
99
63
  get color() {
100
64
  const themeFragments = Theme.themeFragmentsByKind.get('color');
101
65
  const { name } = (themeFragments && themeFragments.get('default')) || {};
@@ -144,27 +108,20 @@ export class Theme extends HTMLElement {
144
108
  const themeKinds = [
145
109
  ...Theme.themeFragmentsByKind.keys(),
146
110
  ];
147
- const getStyle = (fragments, name, kind) => {
148
- const currentStyles = fragments.get(name);
149
- // theme="spectrum" is available by default and doesn't need to be applied.
150
- const isAppliedFragment = name === 'spectrum' || !kind || this.hasAttribute(kind);
151
- if (currentStyles && isAppliedFragment) {
152
- return currentStyles.styles;
153
- }
154
- return;
155
- };
156
111
  const styles = themeKinds.reduce((acc, kind) => {
157
112
  const kindFragments = Theme.themeFragmentsByKind.get(kind);
158
- let style;
113
+ const addStyles = (name, kind) => {
114
+ const currentStyles = kindFragments.get(name);
115
+ if (currentStyles && (!kind || this.hasAttribute(kind))) {
116
+ acc.push(currentStyles.styles);
117
+ }
118
+ };
159
119
  if (kind === 'app' || kind === 'core') {
160
- style = getStyle(kindFragments, kind);
120
+ addStyles(kind);
161
121
  }
162
122
  else {
163
123
  const { [kind]: name } = this;
164
- style = getStyle(kindFragments, name, kind);
165
- }
166
- if (style) {
167
- acc.push(style);
124
+ addStyles(name, kind);
168
125
  }
169
126
  return acc;
170
127
  }, []);
@@ -192,7 +149,6 @@ export class Theme extends HTMLElement {
192
149
  theme.scale = this.scale || undefined;
193
150
  theme.lang =
194
151
  this.lang || document.documentElement.lang || navigator.language;
195
- theme.theme = this.theme || undefined;
196
152
  }
197
153
  connectedCallback() {
198
154
  this.shouldAdoptStyles();
@@ -327,7 +283,7 @@ export class Theme extends HTMLElement {
327
283
  }
328
284
  }
329
285
  Theme.themeFragmentsByKind = new Map();
330
- Theme.defaultFragments = new Set(['spectrum']);
286
+ Theme.defaultFragments = new Set(['core']);
331
287
  Theme.instances = new Set();
332
- Theme.registerThemeFragment('spectrum', 'theme', coreStyles);
288
+ Theme.registerThemeFragment('core', 'core', coreStyles);
333
289
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is 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 {\n CSSResult,\n CSSResultGroup,\n supportsAdoptingStyleSheets,\n} from '@spectrum-web-components/base';\n\nimport coreStyles from './theme.css.js';\n\ndeclare global {\n interface Window {\n ShadyCSS: {\n nativeShadow: boolean;\n prepareTemplate(\n template: HTMLTemplateElement,\n elementName: string,\n typeExtension?: string\n ): void;\n styleElement(host: HTMLElement): void;\n ScopingShim: {\n prepareAdoptedCssText(\n cssTextArray: string[],\n elementName: string\n ): void;\n };\n };\n }\n}\n\ntype ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\ntype FragmentType = 'color' | 'scale' | 'theme' | 'core' | 'app';\ntype SettableFragmentTypes = 'color' | 'scale' | 'theme';\ntype FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\nexport type Color =\n | 'light'\n | 'lightest'\n | 'dark'\n | 'darkest'\n | 'light-express'\n | 'lightest-express'\n | 'dark-express'\n | 'darkest-express';\nexport type Scale = 'medium' | 'large' | 'medium-express' | 'large-express';\nexport type Flavor = 'spectrum' | 'express';\nconst FlavorValues = ['spectrum', 'express'];\nconst ScaleValues = ['medium', 'large', 'medium-express', 'large-express'];\nconst ColorValues = [\n 'light',\n 'lightest',\n 'dark',\n 'darkest',\n 'light-express',\n 'lightest-express',\n 'dark-express',\n 'darkest-express',\n];\ntype FragmentName = Color | Scale | Flavor | 'core' | 'app';\n\nexport interface ThemeData {\n color?: Color;\n scale?: Scale;\n lang?: string;\n theme?: Flavor;\n}\n\ntype ThemeKindProvider = {\n [P in SettableFragmentTypes]: Flavor | Color | Scale | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string) => void;\n}\n\n/**\n * @element sp-theme\n *\n * @slot - Content on which to apply the CSS Custom Properties defined by the current theme configuration\n */\nexport class Theme extends HTMLElement implements ThemeKindProvider {\n private static themeFragmentsByKind: ThemeFragmentMap = new Map();\n private static defaultFragments: Set<FragmentName> = new Set(['spectrum']);\n private static templateElement?: HTMLTemplateElement;\n private static instances: Set<Theme> = new Set();\n\n static get observedAttributes(): string[] {\n return ['color', 'scale', 'theme', 'lang'];\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'theme') {\n this.theme = value as Flavor;\n }\n }\n\n private requestUpdate(): void {\n if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {\n window.ShadyCSS.styleElement(this);\n } else {\n this.shouldAdoptStyles();\n }\n }\n\n public shadowRoot!: ShadowRootWithAdoptedStyleSheets;\n\n private _theme: Flavor | '' = 'spectrum';\n\n get theme(): Flavor | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('theme');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._theme || (name as Flavor) || '';\n }\n\n set theme(newValue: Flavor | '') {\n if (newValue === this._theme) return;\n const theme =\n !!newValue && FlavorValues.includes(newValue)\n ? newValue\n : this.theme;\n if (theme !== this._theme) {\n this._theme = theme;\n this.requestUpdate();\n }\n if (theme) {\n this.setAttribute('theme', theme);\n } else {\n this.removeAttribute('theme');\n }\n }\n\n private _color: Color | '' = '';\n\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) return;\n const color =\n !!newValue && ColorValues.includes(newValue)\n ? newValue\n : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) return;\n const scale =\n !!newValue && ScaleValues.includes(newValue)\n ? newValue\n : this.scale;\n if (scale !== this._scale) {\n this._scale = scale;\n this.requestUpdate();\n }\n if (scale) {\n this.setAttribute('scale', scale);\n } else {\n this.removeAttribute('scale');\n }\n }\n\n private get styles(): CSSResultGroup[] {\n const themeKinds: FragmentType[] = [\n ...Theme.themeFragmentsByKind.keys(),\n ];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles = fragments.get(name);\n // theme=\"spectrum\" is available by default and doesn't need to be applied.\n const isAppliedFragment =\n name === 'spectrum' || !kind || this.hasAttribute(kind);\n if (currentStyles && isAppliedFragment) {\n return currentStyles.styles;\n }\n return;\n };\n const styles = themeKinds.reduce((acc, kind) => {\n const kindFragments = Theme.themeFragmentsByKind.get(\n kind\n ) as FragmentMap;\n let style: CSSResultGroup | undefined;\n if (kind === 'app' || kind === 'core') {\n style = getStyle(kindFragments, kind);\n } else {\n const { [kind]: name } = this;\n style = getStyle(kindFragments, <FragmentName>name, kind);\n }\n if (style) {\n acc.push(style);\n }\n return acc;\n }, [] as CSSResultGroup[]);\n return [...styles];\n }\n\n private static get template(): HTMLTemplateElement {\n if (!this.templateElement) {\n this.templateElement = document.createElement('template');\n this.templateElement.innerHTML = '<slot></slot>';\n }\n return this.templateElement;\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n const node = document.importNode(Theme.template.content, true);\n this.shadowRoot.appendChild(node);\n this.shouldAdoptStyles();\n this.addEventListener(\n 'sp-query-theme',\n this.onQueryTheme as EventListener\n );\n this.addEventListener(\n 'sp-language-context',\n this._handleContextPresence as EventListener\n );\n this.updateComplete = this.__createDeferredPromise();\n }\n\n public updateComplete!: Promise<boolean>;\n private __resolve!: (compelted: boolean) => void;\n\n private __createDeferredPromise(): Promise<boolean> {\n return new Promise((resolve) => {\n this.__resolve = resolve;\n });\n }\n\n private onQueryTheme(event: CustomEvent<ThemeData>): void {\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n const { detail: theme } = event;\n theme.color = this.color || undefined;\n theme.scale = this.scale || undefined;\n theme.lang =\n this.lang || document.documentElement.lang || navigator.language;\n theme.theme = this.theme || undefined;\n }\n\n protected connectedCallback(): void {\n this.shouldAdoptStyles();\n // Note, first update/render handles styleElement so we only call this if\n // connected after first update.\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined) {\n window.ShadyCSS.styleElement(this);\n }\n // Add `this` to the instances array.\n Theme.instances.add(this);\n const manageDir = (): void => {\n const { dir } = this;\n this.trackedChildren.forEach((el) => {\n el.setAttribute('dir', dir === 'rtl' ? dir : 'ltr');\n });\n };\n if (!this.observer) {\n this.observer = new MutationObserver(manageDir);\n }\n this.observer.observe(this, {\n attributes: true,\n attributeFilter: ['dir'],\n });\n if (!this.hasAttribute('dir')) {\n let dirParent = ((this as HTMLElement).assignedSlot ||\n this.parentNode) as HTMLElement | DocumentFragment | ShadowRoot;\n while (\n dirParent !== document.documentElement &&\n !(dirParent instanceof Theme)\n ) {\n dirParent = ((dirParent as HTMLElement).assignedSlot || // step into the shadow DOM of the parent of a slotted node\n dirParent.parentNode || // DOM Element detected\n (dirParent as ShadowRoot).host) as\n | HTMLElement\n | DocumentFragment\n | ShadowRoot;\n }\n this.dir = dirParent.dir === 'rtl' ? dirParent.dir : 'ltr';\n }\n requestAnimationFrame(() => manageDir());\n }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n this.observer.disconnect();\n }\n\n private observer!: MutationObserver;\n\n public startManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.add(el);\n }\n\n public stopManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.delete(el);\n }\n\n private trackedChildren: Set<HTMLElement> = new Set();\n\n private _updateRequested = false;\n\n private async shouldAdoptStyles(): Promise<void> {\n if (!this._updateRequested) {\n this.updateComplete = this.__createDeferredPromise();\n this._updateRequested = true;\n this._updateRequested = await false;\n this.adoptStyles();\n this.__resolve(true);\n }\n }\n\n protected adoptStyles(): void {\n const styles = this.styles; // No test coverage on Edge\n\n // There are three separate cases here based on Shadow DOM support.\n // (1) shadowRoot polyfilled: use ShadyCSS\n // (2) shadowRoot.adoptedStyleSheets available: use it.\n // (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after\n // rendering\n /* c8 ignore next */ if (\n window.ShadyCSS !== undefined &&\n !window.ShadyCSS.nativeShadow &&\n window.ShadyCSS.ScopingShim\n ) {\n // For browsers using the shim, there seems to be one set of\n // processed styles per template, so it is hard to nest styles. So,\n // for those, we load in all style fragments and then switch using a\n // host selector (e.g. :host([color='dark']))\n const fragmentCSS: string[] = [];\n for (const [kind, fragments] of Theme.themeFragmentsByKind) {\n for (const [name, { styles }] of fragments) {\n if (name === 'default') continue;\n let cssText = (styles as CSSResult).cssText;\n if (!Theme.defaultFragments.has(name as FragmentName)) {\n cssText = cssText.replace(\n ':host',\n `:host([${kind}='${name}'])`\n );\n }\n fragmentCSS.push(cssText);\n }\n }\n window.ShadyCSS.ScopingShim.prepareAdoptedCssText(\n fragmentCSS,\n this.localName\n );\n window.ShadyCSS.prepareTemplate(Theme.template, this.localName);\n } else if (supportsAdoptingStyleSheets) {\n const styleSheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n styleSheets.push(\n (style as CSSResult).styleSheet as CSSStyleSheet\n );\n }\n this.shadowRoot.adoptedStyleSheets = styleSheets;\n } else {\n const styleNodes = this.shadowRoot.querySelectorAll('style');\n styleNodes.forEach((element) => element.remove());\n styles.forEach((s) => {\n const style = document.createElement('style');\n style.textContent = (s as CSSResult).cssText;\n this.shadowRoot.appendChild(style);\n });\n }\n }\n\n static registerThemeFragment(\n name: FragmentName,\n kind: FragmentType,\n styles: CSSResultGroup\n ): void {\n const fragmentMap = Theme.themeFragmentsByKind.get(kind) || new Map();\n if (fragmentMap.size === 0) {\n Theme.themeFragmentsByKind.set(kind, fragmentMap);\n // we're adding our first fragment for this kind, set as default\n fragmentMap.set('default', { name, styles });\n Theme.defaultFragments.add(name);\n }\n fragmentMap.set(name, { name, styles });\n Theme.instances.forEach((instance) => instance.shouldAdoptStyles());\n }\n\n private _contextConsumers = new Map<HTMLElement, ProvideLang['callback']>();\n\n private _provideContext(): void {\n this._contextConsumers.forEach((consume) => consume(this.lang));\n }\n\n private _handleContextPresence(event: CustomEvent<ProvideLang>): void {\n const target = event.composedPath()[0] as HTMLElement;\n if (this._contextConsumers.has(target)) {\n this._contextConsumers.delete(target);\n } else {\n this._contextConsumers.set(target, event.detail.callback);\n const callback = this._contextConsumers.get(target);\n if (callback) {\n callback(\n this.lang ||\n document.documentElement.lang ||\n navigator.language\n );\n }\n }\n }\n}\n\nTheme.registerThemeFragment('spectrum', 'theme', coreStyles);\n"]}
1
+ {"version":3,"file":"Theme.js","sourceRoot":"","sources":["Theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAGH,2BAA2B,GAC9B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,UAAU,MAAM,gBAAgB,CAAC;AAgCxC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAiB7D;;;;GAIG;AACH,MAAM,OAAO,KAAM,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MAAM,CAAC,MAAM,CAAC,CAAC;SACzC;aAAM;YACH,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,QAAQ,EAAE;gBACV,QAAQ,CACJ,IAAI,CAAC,IAAI;oBACL,QAAQ,CAAC,eAAe,CAAC,IAAI;oBAC7B,SAAS,CAAC,QAAQ,CACzB,CAAC;aACL;SACJ;IACL,CAAC;;AAvUc,0BAAoB,GAAqB,IAAI,GAAG,EAAE,CAAC;AACnD,sBAAgB,GAAsB,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAExD,eAAS,GAAe,IAAI,GAAG,EAAE,CAAC;AAuUrD,KAAK,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC","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 {\n CSSResult,\n CSSResultGroup,\n supportsAdoptingStyleSheets,\n} from '@spectrum-web-components/base';\n\nimport coreStyles from './theme.css.js';\n\ndeclare global {\n interface Window {\n ShadyCSS: {\n nativeShadow: boolean;\n prepareTemplate(\n template: HTMLTemplateElement,\n elementName: string,\n typeExtension?: string\n ): void;\n styleElement(host: HTMLElement): void;\n ScopingShim: {\n prepareAdoptedCssText(\n cssTextArray: string[],\n elementName: string\n ): void;\n };\n };\n }\n}\n\ntype ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\ntype FragmentType = 'color' | 'scale' | 'core' | 'app';\ntype SettableFragmentTypes = 'color' | 'scale';\ntype FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\nexport type Color = 'light' | 'lightest' | 'dark' | 'darkest';\nexport type Scale = 'medium' | 'large';\nconst ScaleValues = ['medium', 'large'];\nconst ColorValues = ['light', 'lightest', 'dark', 'darkest'];\ntype FragmentName = Color | Scale | 'core' | 'app';\n\nexport interface ThemeData {\n color?: Color;\n scale?: Scale;\n lang?: string;\n}\n\ntype ThemeKindProvider = {\n [P in SettableFragmentTypes]: Color | Scale | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string) => void;\n}\n\n/**\n * @element sp-theme\n *\n * @slot - Content on which to apply the CSS Custom Properties defined by the current theme configuration\n */\nexport class Theme extends HTMLElement implements ThemeKindProvider {\n private static themeFragmentsByKind: ThemeFragmentMap = new Map();\n private static defaultFragments: Set<FragmentName> = new Set(['core']);\n private static templateElement?: HTMLTemplateElement;\n private static instances: Set<Theme> = new Set();\n\n static get observedAttributes(): string[] {\n return ['color', 'scale', 'lang'];\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes,\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n }\n }\n\n private requestUpdate(): void {\n if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {\n window.ShadyCSS.styleElement(this);\n } else {\n this.shouldAdoptStyles();\n }\n }\n\n public shadowRoot!: ShadowRootWithAdoptedStyleSheets;\n\n private _color: Color | '' = '';\n\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) return;\n const color =\n !!newValue && ColorValues.includes(newValue)\n ? newValue\n : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) return;\n const scale =\n !!newValue && ScaleValues.includes(newValue)\n ? newValue\n : this.scale;\n if (scale !== this._scale) {\n this._scale = scale;\n this.requestUpdate();\n }\n if (scale) {\n this.setAttribute('scale', scale);\n } else {\n this.removeAttribute('scale');\n }\n }\n\n private get styles(): CSSResult[] {\n const themeKinds: FragmentType[] = [\n ...Theme.themeFragmentsByKind.keys(),\n ];\n const styles = themeKinds.reduce((acc, kind) => {\n const kindFragments = Theme.themeFragmentsByKind.get(\n kind\n ) as FragmentMap;\n const addStyles = (\n name: FragmentName,\n kind?: FragmentType\n ): void => {\n const currentStyles = kindFragments.get(name);\n if (currentStyles && (!kind || this.hasAttribute(kind))) {\n acc.push(currentStyles.styles as CSSResult);\n }\n };\n if (kind === 'app' || kind === 'core') {\n addStyles(kind);\n } else {\n const { [kind]: name } = this;\n addStyles(<FragmentName>name, kind);\n }\n return acc;\n }, [] as CSSResult[]);\n return [...styles];\n }\n\n private static get template(): HTMLTemplateElement {\n if (!this.templateElement) {\n this.templateElement = document.createElement('template');\n this.templateElement.innerHTML = '<slot></slot>';\n }\n return this.templateElement;\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n const node = document.importNode(Theme.template.content, true);\n this.shadowRoot.appendChild(node);\n this.shouldAdoptStyles();\n this.addEventListener(\n 'sp-query-theme',\n this.onQueryTheme as EventListener\n );\n this.addEventListener(\n 'sp-language-context',\n this._handleContextPresence as EventListener\n );\n this.updateComplete = this.__createDeferredPromise();\n }\n\n public updateComplete!: Promise<boolean>;\n private __resolve!: (compelted: boolean) => void;\n\n private __createDeferredPromise(): Promise<boolean> {\n return new Promise((resolve) => {\n this.__resolve = resolve;\n });\n }\n\n private onQueryTheme(event: CustomEvent<ThemeData>): void {\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n const { detail: theme } = event;\n theme.color = this.color || undefined;\n theme.scale = this.scale || undefined;\n theme.lang =\n this.lang || document.documentElement.lang || navigator.language;\n }\n\n protected connectedCallback(): void {\n this.shouldAdoptStyles();\n // Note, first update/render handles styleElement so we only call this if\n // connected after first update.\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined) {\n window.ShadyCSS.styleElement(this);\n }\n // Add `this` to the instances array.\n Theme.instances.add(this);\n const manageDir = (): void => {\n const { dir } = this;\n this.trackedChildren.forEach((el) => {\n el.setAttribute('dir', dir === 'rtl' ? dir : 'ltr');\n });\n };\n if (!this.observer) {\n this.observer = new MutationObserver(manageDir);\n }\n this.observer.observe(this, {\n attributes: true,\n attributeFilter: ['dir'],\n });\n if (!this.hasAttribute('dir')) {\n let dirParent = ((this as HTMLElement).assignedSlot ||\n this.parentNode) as HTMLElement | DocumentFragment | ShadowRoot;\n while (\n dirParent !== document.documentElement &&\n !(dirParent instanceof Theme)\n ) {\n dirParent = ((dirParent as HTMLElement).assignedSlot || // step into the shadow DOM of the parent of a slotted node\n dirParent.parentNode || // DOM Element detected\n (dirParent as ShadowRoot).host) as\n | HTMLElement\n | DocumentFragment\n | ShadowRoot;\n }\n this.dir = dirParent.dir === 'rtl' ? dirParent.dir : 'ltr';\n }\n requestAnimationFrame(() => manageDir());\n }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n this.observer.disconnect();\n }\n\n private observer!: MutationObserver;\n\n public startManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.add(el);\n }\n\n public stopManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.delete(el);\n }\n\n private trackedChildren: Set<HTMLElement> = new Set();\n\n private _updateRequested = false;\n\n private async shouldAdoptStyles(): Promise<void> {\n if (!this._updateRequested) {\n this.updateComplete = this.__createDeferredPromise();\n this._updateRequested = true;\n this._updateRequested = await false;\n this.adoptStyles();\n this.__resolve(true);\n }\n }\n\n protected adoptStyles(): void {\n const styles = this.styles; // No test coverage on Edge\n\n // There are three separate cases here based on Shadow DOM support.\n // (1) shadowRoot polyfilled: use ShadyCSS\n // (2) shadowRoot.adoptedStyleSheets available: use it.\n // (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after\n // rendering\n /* c8 ignore next */ if (\n window.ShadyCSS !== undefined &&\n !window.ShadyCSS.nativeShadow &&\n window.ShadyCSS.ScopingShim\n ) {\n // For browsers using the shim, there seems to be one set of\n // processed styles per template, so it is hard to nest styles. So,\n // for those, we load in all style fragments and then switch using a\n // host selector (e.g. :host([color='dark']))\n const fragmentCSS: string[] = [];\n for (const [kind, fragments] of Theme.themeFragmentsByKind) {\n for (const [name, { styles }] of fragments) {\n if (name === 'default') continue;\n let cssText = (styles as CSSResult).cssText;\n if (!Theme.defaultFragments.has(name as FragmentName)) {\n cssText = cssText.replace(\n ':host',\n `:host([${kind}='${name}'])`\n );\n }\n fragmentCSS.push(cssText);\n }\n }\n window.ShadyCSS.ScopingShim.prepareAdoptedCssText(\n fragmentCSS,\n this.localName\n );\n window.ShadyCSS.prepareTemplate(Theme.template, this.localName);\n } else if (supportsAdoptingStyleSheets) {\n const styleSheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n styleSheets.push(\n (style as CSSResult).styleSheet as CSSStyleSheet\n );\n }\n this.shadowRoot.adoptedStyleSheets = styleSheets;\n } else {\n const styleNodes = this.shadowRoot.querySelectorAll('style');\n styleNodes.forEach((element) => element.remove());\n styles.forEach((s) => {\n const style = document.createElement('style');\n style.textContent = (s as CSSResult).cssText;\n this.shadowRoot.appendChild(style);\n });\n }\n }\n\n static registerThemeFragment(\n name: FragmentName,\n kind: FragmentType,\n styles: CSSResultGroup\n ): void {\n const fragmentMap = Theme.themeFragmentsByKind.get(kind) || new Map();\n if (fragmentMap.size === 0) {\n Theme.themeFragmentsByKind.set(kind, fragmentMap);\n // we're adding our first fragment for this kind, set as default\n fragmentMap.set('default', { name, styles });\n Theme.defaultFragments.add(name);\n }\n fragmentMap.set(name, { name, styles });\n Theme.instances.forEach((instance) => instance.shouldAdoptStyles());\n }\n\n private _contextConsumers = new Map<HTMLElement, ProvideLang['callback']>();\n\n private _provideContext(): void {\n this._contextConsumers.forEach((consume) => consume(this.lang));\n }\n\n private _handleContextPresence(event: CustomEvent<ProvideLang>): void {\n const target = event.composedPath()[0] as HTMLElement;\n if (this._contextConsumers.has(target)) {\n this._contextConsumers.delete(target);\n } else {\n this._contextConsumers.set(target, event.detail.callback);\n const callback = this._contextConsumers.get(target);\n if (callback) {\n callback(\n this.lang ||\n document.documentElement.lang ||\n navigator.language\n );\n }\n }\n }\n}\n\nTheme.registerThemeFragment('core', 'core', coreStyles);\n"]}
@@ -3269,7 +3269,7 @@ const styles = css `
3269
3269
  --spectrum-global-dimension-static-size-300
3270
3270
  );--spectrum-treeview-l-item-text-padding-top:var(
3271
3271
  --spectrum-global-dimension-static-size-150
3272
- )}
3272
+ )}:host,:root{--spectrum-global-dimension-dividers:1px}
3273
3273
  `;
3274
3274
  export default styles;
3275
3275
  //# sourceMappingURL=scale-large.css.js.map