@spectrum-web-components/theme 0.47.2 → 0.48.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 +6 -6
- package/package.json +9 -5
- package/src/Theme.d.ts +2 -42
- package/src/Theme.dev.js +79 -162
- package/src/Theme.dev.js.map +3 -3
- package/src/Theme.js +1 -1
- package/src/Theme.js.map +3 -3
- package/src/theme-interfaces.d.ts +24 -0
- package/src/theme-interfaces.dev.js +27 -0
- package/src/theme-interfaces.dev.js.map +7 -0
- package/src/theme-interfaces.js +2 -0
- package/src/theme-interfaces.js.map +7 -0
- package/test/theme-devmode.test.js +82 -70
- package/test/theme-devmode.test.js.map +2 -2
- package/custom-elements.json +0 -423
package/README.md
CHANGED
|
@@ -100,11 +100,11 @@ When you're ready to look into more advanced usage of the components and themes
|
|
|
100
100
|
|
|
101
101
|
## Example
|
|
102
102
|
|
|
103
|
-
An `<sp-theme>` element expects a value for each of its `color` and `scale` attributes to be provided on the element. While not required, you can also use the `
|
|
103
|
+
An `<sp-theme>` element expects a value for each of its `color` and `scale` attributes to be provided on the element. While not required, you can also use the `system` attribute to specify whether the theme you're using is Spectrum Classic (the default), Spectrum 2 (upcoming release) or Spectrum Express.
|
|
104
104
|
|
|
105
105
|
```html
|
|
106
106
|
<sp-theme
|
|
107
|
-
|
|
107
|
+
system="spectrum"
|
|
108
108
|
color="light"
|
|
109
109
|
scale="medium"
|
|
110
110
|
style="background-color: var(--spectrum-gray-100)"
|
|
@@ -126,7 +126,7 @@ Once you've moved beyond the prototype phase of an application, it is likely tha
|
|
|
126
126
|
* Power a site using
|
|
127
127
|
*
|
|
128
128
|
* <sp-theme
|
|
129
|
-
*
|
|
129
|
+
* system="classic"
|
|
130
130
|
* color="darkest"
|
|
131
131
|
* scale="large"
|
|
132
132
|
* >
|
|
@@ -144,7 +144,7 @@ import '@spectrum-web-components/theme/sp-theme.js';
|
|
|
144
144
|
* Power a site using
|
|
145
145
|
*
|
|
146
146
|
* <sp-theme
|
|
147
|
-
*
|
|
147
|
+
* system="express"
|
|
148
148
|
* color="light"
|
|
149
149
|
* scale="medium"
|
|
150
150
|
* >
|
|
@@ -190,7 +190,7 @@ When bundling your application, be sure to consult the documentation of your bun
|
|
|
190
190
|
margin-top: 2em;
|
|
191
191
|
}
|
|
192
192
|
</style>
|
|
193
|
-
<sp-theme
|
|
193
|
+
<sp-theme system="express" color="light" scale="medium">
|
|
194
194
|
<hzn-app-stuff></hzn-app-stuff>
|
|
195
195
|
</sp-theme>
|
|
196
196
|
|
|
@@ -214,7 +214,7 @@ When bundling your application, be sure to consult the documentation of your bun
|
|
|
214
214
|
margin-top: 2em;
|
|
215
215
|
}
|
|
216
216
|
</style>
|
|
217
|
-
<sp-theme
|
|
217
|
+
<sp-theme system="express" color="dark" scale="large">
|
|
218
218
|
<hzn-app-stuff></hzn-app-stuff>
|
|
219
219
|
</sp-theme>
|
|
220
220
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0-beta.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
"./src/theme-dark.css.js": "./src/theme-dark.css.js",
|
|
43
43
|
"./src/theme-darkest-core-tokens.css.js": "./src/theme-darkest-core-tokens.css.js",
|
|
44
44
|
"./src/theme-darkest.css.js": "./src/theme-darkest.css.js",
|
|
45
|
+
"./src/theme-interfaces.js": {
|
|
46
|
+
"development": "./src/theme-interfaces.dev.js",
|
|
47
|
+
"default": "./src/theme-interfaces.js"
|
|
48
|
+
},
|
|
45
49
|
"./src/theme-light-core-tokens.css.js": "./src/theme-light-core-tokens.css.js",
|
|
46
50
|
"./src/theme-light.css.js": "./src/theme-light.css.js",
|
|
47
51
|
"./src/theme-lightest-core-tokens.css.js": "./src/theme-lightest-core-tokens.css.js",
|
|
@@ -233,12 +237,12 @@
|
|
|
233
237
|
"lit-html"
|
|
234
238
|
],
|
|
235
239
|
"dependencies": {
|
|
236
|
-
"@spectrum-web-components/base": "^0.
|
|
237
|
-
"@spectrum-web-components/styles": "^0.
|
|
240
|
+
"@spectrum-web-components/base": "^0.48.0-beta.1",
|
|
241
|
+
"@spectrum-web-components/styles": "^0.48.0-beta.1"
|
|
238
242
|
},
|
|
239
243
|
"types": "./src/index.d.ts",
|
|
240
244
|
"customElements": "custom-elements.json",
|
|
241
|
-
"deprecationNotice": "Color
|
|
245
|
+
"deprecationNotice": "Color 'lightest' and 'darkest' are deprecated. The 'theme' attribute has been deprecated in favor of 'system'. These deprecations will be removed in a future release.",
|
|
242
246
|
"sideEffects": [
|
|
243
247
|
"./sp-*.js",
|
|
244
248
|
"./**/*.dev.js",
|
|
@@ -261,5 +265,5 @@
|
|
|
261
265
|
"./src/spectrum-two/themes.js",
|
|
262
266
|
"./src/spectrum-two/themes-*.js"
|
|
263
267
|
],
|
|
264
|
-
"gitHead": "
|
|
268
|
+
"gitHead": "6659bda5743c40a00cd8143e020fd73d8f911514"
|
|
265
269
|
}
|
package/src/Theme.d.ts
CHANGED
|
@@ -1,44 +1,6 @@
|
|
|
1
1
|
import { CSSResultGroup } from '@spectrum-web-components/base';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ShadyCSS: {
|
|
5
|
-
nativeShadow: boolean;
|
|
6
|
-
prepareTemplate(template: HTMLTemplateElement, elementName: string, typeExtension?: string): void;
|
|
7
|
-
styleElement(host: HTMLElement): void;
|
|
8
|
-
ScopingShim: {
|
|
9
|
-
prepareAdoptedCssText(cssTextArray: string[], elementName: string): void;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
type ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {
|
|
15
|
-
adoptedStyleSheets?: CSSStyleSheet[];
|
|
16
|
-
};
|
|
17
|
-
type FragmentType = 'color' | 'scale' | 'system' | 'theme' | 'core' | 'app';
|
|
18
|
-
type SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';
|
|
19
|
-
type FragmentMap = Map<string, {
|
|
20
|
-
name: string;
|
|
21
|
-
styles: CSSResultGroup;
|
|
22
|
-
}>;
|
|
23
|
-
export type ThemeFragmentMap = Map<FragmentType, FragmentMap>;
|
|
24
|
-
export type Color = 'light' | 'lightest' | 'dark' | 'darkest' | 'light-express' | 'lightest-express' | 'dark-express' | 'darkest-express' | 'light-spectrum-two' | 'dark-spectrum-two';
|
|
25
|
-
export type ThemeVariant = 'spectrum' | 'express' | 'spectrum-two';
|
|
26
|
-
export type SystemVariant = 'spectrum' | 'express' | 'spectrum-two';
|
|
27
|
-
export type Scale = 'medium' | 'large' | 'medium-express' | 'large-express' | 'medium-spectrum-two' | 'large-spectrum-two';
|
|
28
|
-
type FragmentName = Color | Scale | ThemeVariant | SystemVariant | 'core' | 'app';
|
|
29
|
-
export interface ThemeData {
|
|
30
|
-
color?: Color;
|
|
31
|
-
scale?: Scale;
|
|
32
|
-
lang?: string;
|
|
33
|
-
theme?: SystemVariant;
|
|
34
|
-
system?: SystemVariant;
|
|
35
|
-
}
|
|
36
|
-
type ThemeKindProvider = {
|
|
37
|
-
[P in SettableFragmentTypes]: ThemeVariant | SystemVariant | Color | Scale | '';
|
|
38
|
-
};
|
|
39
|
-
export interface ProvideLang {
|
|
40
|
-
callback: (lang: string, unsubscribe: () => void) => void;
|
|
41
|
-
}
|
|
2
|
+
import { Color, FragmentName, FragmentType, ProvideLang, Scale, SettableFragmentTypes, ShadowRootWithAdoptedStyleSheets, SystemVariant, ThemeFragmentMap, ThemeKindProvider } from './theme-interfaces.js';
|
|
3
|
+
export type { ProvideLang, ThemeFragmentMap, Color, Scale, SystemVariant };
|
|
42
4
|
/**
|
|
43
5
|
* @element sp-theme
|
|
44
6
|
* @attr {string} [lang=""] - The language of the content scoped to this `sp-theme` element, see: <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang" target="_blank">MDN reference</a>.
|
|
@@ -101,7 +63,6 @@ export declare class Theme extends HTMLElement implements ThemeKindProvider {
|
|
|
101
63
|
updateComplete: Promise<boolean>;
|
|
102
64
|
private __resolve;
|
|
103
65
|
private __createDeferredPromise;
|
|
104
|
-
private onQueryTheme;
|
|
105
66
|
protected connectedCallback(): void;
|
|
106
67
|
protected disconnectedCallback(): void;
|
|
107
68
|
startManagingContentDirection(el: HTMLElement): void;
|
|
@@ -115,4 +76,3 @@ export declare class Theme extends HTMLElement implements ThemeKindProvider {
|
|
|
115
76
|
private _provideContext;
|
|
116
77
|
private _handleContextPresence;
|
|
117
78
|
}
|
|
118
|
-
export {};
|
package/src/Theme.dev.js
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import {
|
|
3
|
-
supportsAdoptingStyleSheets
|
|
4
|
-
} from "@spectrum-web-components/base";
|
|
5
2
|
import { version } from "@spectrum-web-components/base/src/version.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"large-express",
|
|
12
|
-
"medium-spectrum-two",
|
|
13
|
-
"large-spectrum-two"
|
|
14
|
-
];
|
|
15
|
-
const ColorValues = [
|
|
16
|
-
"light",
|
|
17
|
-
"lightest",
|
|
18
|
-
"dark",
|
|
19
|
-
"darkest",
|
|
20
|
-
"light-express",
|
|
21
|
-
"lightest-express",
|
|
22
|
-
"dark-express",
|
|
23
|
-
"darkest-express",
|
|
24
|
-
"light-spectrum-two",
|
|
25
|
-
"dark-spectrum-two"
|
|
26
|
-
];
|
|
3
|
+
import {
|
|
4
|
+
COLOR_VALUES,
|
|
5
|
+
SCALE_VALUES,
|
|
6
|
+
SYSTEM_VARIANT_VALUES
|
|
7
|
+
} from "./theme-interfaces.dev.js";
|
|
27
8
|
const _Theme = class _Theme extends HTMLElement {
|
|
28
9
|
constructor() {
|
|
29
10
|
super();
|
|
@@ -38,10 +19,6 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
38
19
|
const node = document.importNode(_Theme.template.content, true);
|
|
39
20
|
this.shadowRoot.appendChild(node);
|
|
40
21
|
this.shouldAdoptStyles();
|
|
41
|
-
this.addEventListener(
|
|
42
|
-
"sp-query-theme",
|
|
43
|
-
this.onQueryTheme
|
|
44
|
-
);
|
|
45
22
|
this.addEventListener(
|
|
46
23
|
"sp-language-context",
|
|
47
24
|
this._handleContextPresence
|
|
@@ -89,44 +66,16 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
89
66
|
this._provideContext();
|
|
90
67
|
} else if (attrName === "theme") {
|
|
91
68
|
this.theme = value;
|
|
92
|
-
|
|
93
|
-
window.__swc.warn(
|
|
94
|
-
this,
|
|
95
|
-
'property theme in <sp-theme> has been deprecated. Please use system instead like this <sp-theme system="spectrum"/>',
|
|
96
|
-
"https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation",
|
|
97
|
-
{ level: "deprecation" }
|
|
98
|
-
);
|
|
99
|
-
if (value === "spectrum-two") {
|
|
100
|
-
window.__swc.warn(
|
|
101
|
-
this,
|
|
102
|
-
"You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.",
|
|
103
|
-
"https://s2.spectrum.adobe.com/",
|
|
104
|
-
{ level: "high" }
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
69
|
+
warnBetaSystem(this, value);
|
|
108
70
|
} else if (attrName === "system") {
|
|
109
71
|
this.system = value;
|
|
110
|
-
|
|
111
|
-
if (value === "spectrum-two") {
|
|
112
|
-
window.__swc.warn(
|
|
113
|
-
this,
|
|
114
|
-
"You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.",
|
|
115
|
-
"https://s2.spectrum.adobe.com/",
|
|
116
|
-
{ level: "high" }
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
72
|
+
warnBetaSystem(this, value);
|
|
120
73
|
} else if (attrName === "dir") {
|
|
121
74
|
this.dir = value;
|
|
122
75
|
}
|
|
123
76
|
}
|
|
124
77
|
requestUpdate() {
|
|
125
|
-
|
|
126
|
-
window.ShadyCSS.styleElement(this);
|
|
127
|
-
} else {
|
|
128
|
-
this.shouldAdoptStyles();
|
|
129
|
-
}
|
|
78
|
+
this.shouldAdoptStyles();
|
|
130
79
|
}
|
|
131
80
|
/**
|
|
132
81
|
* The Spectrum system that is applied to the content scoped to this `sp-theme` element.
|
|
@@ -142,7 +91,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
142
91
|
}
|
|
143
92
|
set system(newValue) {
|
|
144
93
|
if (newValue === this._system) return;
|
|
145
|
-
const system = !!newValue &&
|
|
94
|
+
const system = !!newValue && SYSTEM_VARIANT_VALUES.includes(newValue) ? newValue : this.system;
|
|
146
95
|
if (system !== this._system) {
|
|
147
96
|
this._system = system;
|
|
148
97
|
this.requestUpdate();
|
|
@@ -183,7 +132,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
183
132
|
}
|
|
184
133
|
set color(newValue) {
|
|
185
134
|
if (newValue === this._color) return;
|
|
186
|
-
const color = !!newValue &&
|
|
135
|
+
const color = !!newValue && COLOR_VALUES.includes(newValue) ? newValue : this.color;
|
|
187
136
|
if (color !== this._color) {
|
|
188
137
|
this._color = color;
|
|
189
138
|
this.requestUpdate();
|
|
@@ -208,7 +157,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
208
157
|
}
|
|
209
158
|
set scale(newValue) {
|
|
210
159
|
if (newValue === this._scale) return;
|
|
211
|
-
const scale = !!newValue &&
|
|
160
|
+
const scale = !!newValue && SCALE_VALUES.includes(newValue) ? newValue : this.scale;
|
|
212
161
|
if (scale !== this._scale) {
|
|
213
162
|
this._scale = scale;
|
|
214
163
|
this.requestUpdate();
|
|
@@ -247,54 +196,15 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
247
196
|
}
|
|
248
197
|
return acc;
|
|
249
198
|
}, []);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
} else if (!actualValue) {
|
|
260
|
-
issues.push(
|
|
261
|
-
`You have not explicitly set the "${name}" attribute, the default value ("${resolvedValue}") is being used as a fallback.`
|
|
262
|
-
);
|
|
263
|
-
} else if (!((_a = _Theme.themeFragmentsByKind.get(name)) == null ? void 0 : _a.get(
|
|
264
|
-
resolvedValue + (name === "system" ? "" : systemModifier)
|
|
265
|
-
))) {
|
|
266
|
-
issues.push(
|
|
267
|
-
`You have set "${name}='${resolvedValue}'" but the associated system fragment has not been loaded.`
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
checkForAttribute("system", this.system, this._system);
|
|
272
|
-
checkForAttribute("color", this.color, this._color);
|
|
273
|
-
checkForAttribute("scale", this.scale, this._scale);
|
|
274
|
-
if (this.hasAttribute("theme")) {
|
|
275
|
-
issues.push(
|
|
276
|
-
`The "theme" attribute has been deprecated in favor of "system".`
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
if (issues.length) {
|
|
280
|
-
window.__swc.warn(
|
|
281
|
-
this,
|
|
282
|
-
"You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:",
|
|
283
|
-
"https://opensource.adobe.com/spectrum-web-components/components/theme/#example",
|
|
284
|
-
{
|
|
285
|
-
issues
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
if (["lightest", "darkest"].includes(this.color)) {
|
|
290
|
-
window.__swc.warn(
|
|
291
|
-
this,
|
|
292
|
-
`Color lightest and darkest are deprecated and will be removed in a future release`,
|
|
293
|
-
"https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation",
|
|
294
|
-
{ level: "deprecation" }
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
199
|
+
const themeFragmentsByKind = _Theme.themeFragmentsByKind;
|
|
200
|
+
checkForIssues(
|
|
201
|
+
this,
|
|
202
|
+
this.system,
|
|
203
|
+
this.color,
|
|
204
|
+
this.scale,
|
|
205
|
+
this.hasAttribute("theme"),
|
|
206
|
+
themeFragmentsByKind
|
|
207
|
+
);
|
|
298
208
|
return [...styles];
|
|
299
209
|
}
|
|
300
210
|
static get template() {
|
|
@@ -309,24 +219,8 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
309
219
|
this.__resolve = resolve;
|
|
310
220
|
});
|
|
311
221
|
}
|
|
312
|
-
/* c8 ignore next 12 */
|
|
313
|
-
onQueryTheme(event) {
|
|
314
|
-
if (event.defaultPrevented) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
event.preventDefault();
|
|
318
|
-
const { detail: theme } = event;
|
|
319
|
-
theme.color = this.color || void 0;
|
|
320
|
-
theme.scale = this.scale || void 0;
|
|
321
|
-
theme.lang = this.lang || document.documentElement.lang || navigator.language;
|
|
322
|
-
theme.theme = this.system || void 0;
|
|
323
|
-
theme.system = this.system || void 0;
|
|
324
|
-
}
|
|
325
222
|
connectedCallback() {
|
|
326
223
|
this.shouldAdoptStyles();
|
|
327
|
-
if (window.ShadyCSS !== void 0) {
|
|
328
|
-
window.ShadyCSS.styleElement(this);
|
|
329
|
-
}
|
|
330
224
|
_Theme.instances.add(this);
|
|
331
225
|
if (!this.hasAttribute("dir")) {
|
|
332
226
|
let dirParent = this.assignedSlot || this.parentNode;
|
|
@@ -358,43 +252,11 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
358
252
|
}
|
|
359
253
|
adoptStyles() {
|
|
360
254
|
const styles = this.styles;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
for (const [name, { styles: styles2 }] of fragments) {
|
|
365
|
-
if (name === "default") continue;
|
|
366
|
-
let cssText = styles2.cssText;
|
|
367
|
-
if (!_Theme.defaultFragments.has(name)) {
|
|
368
|
-
cssText = cssText.replace(
|
|
369
|
-
":host",
|
|
370
|
-
`:host([${kind}='${name}'])`
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
fragmentCSS.push(cssText);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(
|
|
377
|
-
fragmentCSS,
|
|
378
|
-
this.localName
|
|
379
|
-
);
|
|
380
|
-
window.ShadyCSS.prepareTemplate(_Theme.template, this.localName);
|
|
381
|
-
} else if (supportsAdoptingStyleSheets) {
|
|
382
|
-
const styleSheets = [];
|
|
383
|
-
for (const style of styles) {
|
|
384
|
-
styleSheets.push(
|
|
385
|
-
style.styleSheet
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
this.shadowRoot.adoptedStyleSheets = styleSheets;
|
|
389
|
-
} else {
|
|
390
|
-
const styleNodes = this.shadowRoot.querySelectorAll("style");
|
|
391
|
-
styleNodes.forEach((element) => element.remove());
|
|
392
|
-
styles.forEach((s) => {
|
|
393
|
-
const style = document.createElement("style");
|
|
394
|
-
style.textContent = s.cssText;
|
|
395
|
-
this.shadowRoot.appendChild(style);
|
|
396
|
-
});
|
|
255
|
+
const styleSheets = [];
|
|
256
|
+
for (const style of styles) {
|
|
257
|
+
styleSheets.push(style.styleSheet);
|
|
397
258
|
}
|
|
259
|
+
this.shadowRoot.adoptedStyleSheets = styleSheets;
|
|
398
260
|
}
|
|
399
261
|
static registerThemeFragment(name, kind, styles) {
|
|
400
262
|
const fragmentMap = _Theme.themeFragmentsByKind.get(kind) || /* @__PURE__ */ new Map();
|
|
@@ -436,4 +298,59 @@ _Theme.defaultFragments = /* @__PURE__ */ new Set(["spectrum"]);
|
|
|
436
298
|
_Theme.instances = /* @__PURE__ */ new Set();
|
|
437
299
|
_Theme.VERSION = version;
|
|
438
300
|
export let Theme = _Theme;
|
|
301
|
+
function warnBetaSystem(instance, value) {
|
|
302
|
+
if (value === "spectrum-two") {
|
|
303
|
+
window.__swc.warn(
|
|
304
|
+
instance,
|
|
305
|
+
"You are currently using the beta version of the Spectrum Two system. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.",
|
|
306
|
+
"https://s2.spectrum.adobe.com/",
|
|
307
|
+
{ level: "high" }
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function checkForIssues(instance, system, color, scale, hasThemeAttribute, themeFragmentsByKind) {
|
|
312
|
+
if (true) {
|
|
313
|
+
const issues = [];
|
|
314
|
+
const checkForAttribute = (name, resolvedValue, actualValue) => {
|
|
315
|
+
var _a;
|
|
316
|
+
const systemModifier = system && system !== "spectrum" ? `-${system}` : "";
|
|
317
|
+
if (!resolvedValue) {
|
|
318
|
+
issues.push(
|
|
319
|
+
`You have not explicitly set the "${name}" attribute and there is no default value on which to fallback.`
|
|
320
|
+
);
|
|
321
|
+
} else if (!actualValue) {
|
|
322
|
+
issues.push(
|
|
323
|
+
`You have not explicitly set the "${name}" attribute, the default value ("${resolvedValue}") is being used as a fallback.`
|
|
324
|
+
);
|
|
325
|
+
} else if (!((_a = themeFragmentsByKind.get(name)) == null ? void 0 : _a.get(
|
|
326
|
+
resolvedValue + (name === "system" ? "" : systemModifier)
|
|
327
|
+
))) {
|
|
328
|
+
issues.push(
|
|
329
|
+
`You have set "${name}='${resolvedValue}'" but the associated system fragment has not been loaded.`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
if (hasThemeAttribute) {
|
|
334
|
+
issues.push(
|
|
335
|
+
`DEPRECATION NOTICE: the "theme" attribute has been deprecated in favor of "system". For more information, see: https://opensource.adobe.com/spectrum-web-components/tools/theme/`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
if (["lightest", "darkest"].includes(color || "")) {
|
|
339
|
+
issues.push(
|
|
340
|
+
`DEPRECATION NOTICE: Color "lightest" and "darkest" are deprecated. For more information, see: https://opensource.adobe.com/spectrum-web-components/tools/theme/`
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
checkForAttribute("system", system, instance.getAttribute("system"));
|
|
344
|
+
checkForAttribute("color", color, instance.getAttribute("color"));
|
|
345
|
+
checkForAttribute("scale", scale, instance.getAttribute("scale"));
|
|
346
|
+
if (issues.length) {
|
|
347
|
+
window.__swc.warn(
|
|
348
|
+
instance,
|
|
349
|
+
"You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:",
|
|
350
|
+
"https://opensource.adobe.com/spectrum-web-components/components/theme/#example",
|
|
351
|
+
{ issues }
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
439
356
|
//# sourceMappingURL=Theme.dev.js.map
|
package/src/Theme.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Theme.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\nimport {\n CSSResult,\n CSSResultGroup,\n supportsAdoptingStyleSheets,\n} from '@spectrum-web-components/base';\nimport { version } from '@spectrum-web-components/base/src/version.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' | 'system' | 'theme' | 'core' | 'app';\ntype SettableFragmentTypes = 'color' | 'scale' | 'system' | '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'\n | 'light-spectrum-two'\n | 'dark-spectrum-two';\nexport type ThemeVariant = 'spectrum' | 'express' | 'spectrum-two';\nexport type SystemVariant = 'spectrum' | 'express' | 'spectrum-two';\nconst SystemVariantValues = ['spectrum', 'express', 'spectrum-two'];\nexport type Scale =\n | 'medium'\n | 'large'\n | 'medium-express'\n | 'large-express'\n | 'medium-spectrum-two'\n | 'large-spectrum-two';\nconst ScaleValues = [\n 'medium',\n 'large',\n 'medium-express',\n 'large-express',\n 'medium-spectrum-two',\n 'large-spectrum-two',\n];\nconst ColorValues = [\n 'light',\n 'lightest',\n 'dark',\n 'darkest',\n 'light-express',\n 'lightest-express',\n 'dark-express',\n 'darkest-express',\n 'light-spectrum-two',\n 'dark-spectrum-two',\n];\ntype FragmentName =\n | Color\n | Scale\n | ThemeVariant\n | SystemVariant\n | 'core'\n | 'app';\n\nexport interface ThemeData {\n color?: Color;\n scale?: Scale;\n lang?: string;\n theme?: SystemVariant;\n system?: SystemVariant;\n}\n\ntype ThemeKindProvider = {\n [P in SettableFragmentTypes]:\n | ThemeVariant\n | SystemVariant\n | Color\n | Scale\n | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n\n/**\n * @element sp-theme\n * @attr {string} [lang=\"\"] - The language of the content scoped to this `sp-theme` element, see: <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang\" target=\"_blank\">MDN reference</a>.\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 static VERSION = version;\n\n static get observedAttributes(): string[] {\n return [\n 'color',\n 'scale',\n 'lang',\n 'dir',\n 'system',\n /* deprecated attributes, but still observing */\n 'theme',\n ];\n }\n\n _dir: 'ltr' | 'rtl' | '' = '';\n\n override set dir(dir: 'ltr' | 'rtl' | '') {\n if (dir === this.dir) return;\n this.setAttribute('dir', dir);\n this._dir = dir;\n const targetDir = dir === 'rtl' ? dir : 'ltr';\n /* c8 ignore next 3 */\n this.trackedChildren.forEach((el) => {\n el.setAttribute('dir', targetDir);\n });\n }\n\n /**\n * Reading direction of the content scoped to this `sp-theme` element.\n * @type {\"ltr\" | \"rtl\" | \"\"}\n * @attr\n */\n override get dir(): 'ltr' | 'rtl' | '' {\n return this._dir;\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang' | 'dir',\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 /* c8 ignore next 3 */\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'theme') {\n this.theme = value as SystemVariant;\n if (window.__swc.DEBUG) {\n window.__swc.warn(\n this,\n 'property theme in <sp-theme> has been deprecated. Please use system instead like this <sp-theme system=\"spectrum\"/>',\n 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation',\n { level: 'deprecation' }\n );\n if (value === 'spectrum-two') {\n window.__swc.warn(\n this,\n 'You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.',\n 'https://s2.spectrum.adobe.com/',\n { level: 'high' }\n );\n }\n }\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n if (window.__swc.DEBUG) {\n if (value === 'spectrum-two') {\n window.__swc.warn(\n this,\n 'You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.',\n 'https://s2.spectrum.adobe.com/',\n { level: 'high' }\n );\n }\n }\n } else if (attrName === 'dir') {\n this.dir = value as 'ltr' | 'rtl' | '';\n }\n }\n\n private requestUpdate(): void {\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {\n window.ShadyCSS.styleElement(this);\n } else {\n this.shouldAdoptStyles();\n }\n }\n\n public override shadowRoot!: ShadowRootWithAdoptedStyleSheets;\n\n private _system: SystemVariant | '' = 'spectrum';\n /**\n * The Spectrum system that is applied to the content scoped to this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } =\n (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) return;\n const system =\n !!newValue && SystemVariantValues.includes(newValue)\n ? newValue\n : this.system;\n if (system !== this._system) {\n this._system = system;\n this.requestUpdate();\n }\n if (system) {\n this.setAttribute('system', system);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('system');\n }\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n get theme(): SystemVariant | '' {\n if (!this.system) {\n this.removeAttribute('system');\n }\n return this.system;\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n set theme(newValue: SystemVariant | '') {\n this.system = newValue;\n this.requestUpdate();\n }\n\n private _color: Color | '' = '';\n\n /**\n * The Spectrum color stops to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\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 /* c8 ignore next 3 */\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\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 /* c8 ignore next 3 */\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 =\n kind &&\n kind !== 'theme' &&\n kind !== 'system' &&\n this.theme !== 'spectrum' &&\n this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : 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 if (window.__swc.DEBUG) {\n const issues: string[] = [];\n const checkForAttribute = (\n name: FragmentType,\n resolvedValue?: string,\n actualValue?: string\n ): void => {\n const systemModifier =\n this.system && this.system !== 'spectrum'\n ? `-${this.system}`\n : '';\n if (!resolvedValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute and there is no default value on which to fallback.`\n );\n } else if (!actualValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute, the default value (\"${resolvedValue}\") is being used as a fallback.`\n );\n } else if (\n !Theme.themeFragmentsByKind\n .get(name)\n ?.get(\n resolvedValue +\n (name === 'system' ? '' : systemModifier)\n )\n ) {\n issues.push(\n `You have set \"${name}='${resolvedValue}'\" but the associated system fragment has not been loaded.`\n );\n }\n };\n\n checkForAttribute('system', this.system, this._system);\n checkForAttribute('color', this.color, this._color);\n checkForAttribute('scale', this.scale, this._scale);\n\n // Check for deprecated attributes\n if (this.hasAttribute('theme')) {\n issues.push(\n `The \"theme\" attribute has been deprecated in favor of \"system\".`\n );\n }\n\n if (issues.length) {\n window.__swc.warn(\n this,\n 'You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:',\n 'https://opensource.adobe.com/spectrum-web-components/components/theme/#example',\n {\n issues,\n }\n );\n }\n if (['lightest', 'darkest'].includes(this.color)) {\n window.__swc.warn(\n this,\n `Color lightest and darkest are deprecated and will be removed in a future release`,\n 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation',\n { level: 'deprecation' }\n );\n }\n }\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 /* c8 ignore next 12 */\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` is deprecated in favor of `system` but maintaining `theme` as a deprecated path.\n theme.theme = this.system || undefined;\n theme.system = this.system || 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 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 }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\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 rendering\n /* c8 ignore next 28 */\n 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 /* c8 ignore next 9 */\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<\n HTMLElement,\n [ProvideLang['callback'], () => void]\n >();\n\n /* c8 ignore next 5 */\n private _provideContext(): void {\n this._contextConsumers.forEach(([callback, unsubscribe]) =>\n callback(this.lang, unsubscribe)\n );\n }\n\n private _handleContextPresence(event: CustomEvent<ProvideLang>): void {\n event.stopPropagation();\n const target = event.composedPath()[0] as HTMLElement;\n /* c8 ignore next 3 */\n if (this._contextConsumers.has(target)) {\n return;\n }\n this._contextConsumers.set(target, [\n event.detail.callback,\n () => this._contextConsumers.delete(target),\n ]);\n const [callback, unsubscribe] =\n this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang ||\n document.documentElement.lang ||\n navigator.language,\n unsubscribe\n );\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
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 { CSSResult, CSSResultGroup } from '@spectrum-web-components/base';\nimport { version } from '@spectrum-web-components/base/src/version.js';\nimport {\n Color,\n COLOR_VALUES,\n FragmentMap,\n FragmentName,\n FragmentType,\n ProvideLang,\n Scale,\n SCALE_VALUES,\n SettableFragmentTypes,\n ShadowRootWithAdoptedStyleSheets,\n SYSTEM_VARIANT_VALUES,\n SystemVariant,\n ThemeFragmentMap,\n ThemeKindProvider,\n} from './theme-interfaces.dev.js'\nexport type { ProvideLang, ThemeFragmentMap, Color, Scale, SystemVariant };\n/**\n * @element sp-theme\n * @attr {string} [lang=\"\"] - The language of the content scoped to this `sp-theme` element, see: <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang\" target=\"_blank\">MDN reference</a>.\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 static VERSION = version;\n\n static get observedAttributes(): string[] {\n return [\n 'color',\n 'scale',\n 'lang',\n 'dir',\n 'system',\n /* deprecated attributes, but still observing */\n 'theme',\n ];\n }\n\n _dir: 'ltr' | 'rtl' | '' = '';\n\n override set dir(dir: 'ltr' | 'rtl' | '') {\n if (dir === this.dir) return;\n this.setAttribute('dir', dir);\n this._dir = dir;\n const targetDir = dir === 'rtl' ? dir : 'ltr';\n /* c8 ignore next 3 */\n this.trackedChildren.forEach((el) => {\n el.setAttribute('dir', targetDir);\n });\n }\n\n /**\n * Reading direction of the content scoped to this `sp-theme` element.\n * @type {\"ltr\" | \"rtl\" | \"\"}\n * @attr\n */\n override get dir(): 'ltr' | 'rtl' | '' {\n return this._dir;\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang' | 'dir',\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 /* c8 ignore next 3 */\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'theme') {\n this.theme = value as SystemVariant;\n warnBetaSystem(this, value as SystemVariant);\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n warnBetaSystem(this, value as SystemVariant);\n } else if (attrName === 'dir') {\n this.dir = value as 'ltr' | 'rtl' | '';\n }\n }\n private requestUpdate(): void {\n this.shouldAdoptStyles();\n }\n\n public override shadowRoot!: ShadowRootWithAdoptedStyleSheets;\n\n private _system: SystemVariant | '' = 'spectrum';\n /**\n * The Spectrum system that is applied to the content scoped to this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } =\n (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) return;\n const system =\n !!newValue && SYSTEM_VARIANT_VALUES.includes(newValue)\n ? newValue\n : this.system;\n if (system !== this._system) {\n this._system = system;\n this.requestUpdate();\n }\n if (system) {\n this.setAttribute('system', system);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('system');\n }\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n get theme(): SystemVariant | '' {\n /* c8 ignore next 3 */\n if (!this.system) {\n this.removeAttribute('system');\n }\n return this.system;\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n set theme(newValue: SystemVariant | '') {\n this.system = newValue;\n this.requestUpdate();\n }\n\n private _color: Color | '' = '';\n\n /**\n * The Spectrum color stops to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\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 && COLOR_VALUES.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 /* c8 ignore next 3 */\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\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 && SCALE_VALUES.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 /* c8 ignore next 3 */\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 =\n kind &&\n kind !== 'theme' &&\n kind !== 'system' &&\n this.theme !== 'spectrum' &&\n this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : 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 const themeFragmentsByKind = Theme.themeFragmentsByKind;\n\n checkForIssues(\n this,\n this.system,\n this.color,\n this.scale,\n this.hasAttribute('theme'),\n themeFragmentsByKind\n );\n\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-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 protected connectedCallback(): void {\n // Note, first update/render handles styleElement so we only call this if\n // connected after first update.\n this.shouldAdoptStyles();\n\n // Add `this` to the instances array.\n Theme.instances.add(this);\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 }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\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;\n const styleSheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n styleSheets.push((style as CSSResult).styleSheet!);\n }\n this.shadowRoot.adoptedStyleSheets = styleSheets;\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<\n HTMLElement,\n [ProvideLang['callback'], () => void]\n >();\n\n /* c8 ignore next 5 */\n private _provideContext(): void {\n this._contextConsumers.forEach(([callback, unsubscribe]) =>\n callback(this.lang, unsubscribe)\n );\n }\n\n private _handleContextPresence(event: CustomEvent<ProvideLang>): void {\n event.stopPropagation();\n const target = event.composedPath()[0] as HTMLElement;\n /* c8 ignore next 3 */\n if (this._contextConsumers.has(target)) {\n return;\n }\n this._contextConsumers.set(target, [\n event.detail.callback,\n () => this._contextConsumers.delete(target),\n ]);\n const [callback, unsubscribe] =\n this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang ||\n document.documentElement.lang ||\n navigator.language,\n unsubscribe\n );\n }\n }\n}\n\nfunction warnBetaSystem(instance: Theme, value: SystemVariant): void {\n if (window.__swc.DEBUG && value === 'spectrum-two') {\n window.__swc.warn(\n instance,\n 'You are currently using the beta version of the Spectrum Two system. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.',\n 'https://s2.spectrum.adobe.com/',\n { level: 'high' }\n );\n }\n}\n\nfunction checkForIssues(\n instance: Theme,\n system: SystemVariant | '',\n color: Color | '',\n scale: Scale | '',\n hasThemeAttribute: boolean,\n themeFragmentsByKind: ThemeFragmentMap\n): void {\n if (window.__swc.DEBUG) {\n const issues: string[] = [];\n const checkForAttribute = (\n name: 'system' | 'color' | 'scale',\n resolvedValue: string,\n actualValue: string | null\n ): void => {\n const systemModifier =\n system && system !== 'spectrum' ? `-${system}` : '';\n if (!resolvedValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute and there is no default value on which to fallback.`\n );\n } else if (!actualValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute, the default value (\"${resolvedValue}\") is being used as a fallback.`\n );\n } else if (\n !themeFragmentsByKind\n .get(name)\n ?.get(\n resolvedValue +\n (name === 'system' ? '' : systemModifier)\n )\n ) {\n issues.push(\n `You have set \"${name}='${resolvedValue}'\" but the associated system fragment has not been loaded.`\n );\n }\n };\n\n if (hasThemeAttribute) {\n issues.push(\n `DEPRECATION NOTICE: the \"theme\" attribute has been deprecated in favor of \"system\". For more information, see: https://opensource.adobe.com/spectrum-web-components/tools/theme/`\n );\n }\n if (['lightest', 'darkest'].includes(color || '')) {\n issues.push(\n `DEPRECATION NOTICE: Color \"lightest\" and \"darkest\" are deprecated. For more information, see: https://opensource.adobe.com/spectrum-web-components/tools/theme/`\n );\n }\n checkForAttribute('system', system, instance.getAttribute('system'));\n checkForAttribute('color', color, instance.getAttribute('color'));\n checkForAttribute('scale', scale, instance.getAttribute('scale'));\n\n if (issues.length) {\n window.__swc.warn(\n instance,\n 'You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:',\n 'https://opensource.adobe.com/spectrum-web-components/components/theme/#example',\n { issues }\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAaA,SAA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