@spectrum-web-components/theme 0.48.1 → 0.49.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/package.json +4 -4
- package/src/Theme.d.ts +25 -0
- package/src/Theme.dev.js +51 -0
- package/src/Theme.dev.js.map +2 -2
- package/src/Theme.js +1 -1
- package/src/Theme.js.map +3 -3
- package/src/theme-interfaces.d.ts +1 -0
- package/src/theme-interfaces.dev.js.map +1 -1
- package/src/theme-interfaces.js.map +1 -1
- package/custom-elements.json +0 -445
package/README.md
CHANGED
|
@@ -330,3 +330,75 @@ previewing or editing content that will be displayed in a light theme with a rig
|
|
|
330
330
|
## Language Context
|
|
331
331
|
|
|
332
332
|
The `<sp-theme>` element provides a language context for its descendents in the DOM. Descendents can resolve this context by dispatching an `sp-language-context` DOM event and supplying a `callback(lang: string) => void` method in the `detail` entry of the Custom Event. These callbacks will be reactively envoked when the `lang` attribute on the `<sp-theme>` element is updated. This way, you can control the resolved language in [`<sp-number-field>`](../components/number-field), [`<sp-slider>`](./components/slider), and other elements in one centralized place.
|
|
333
|
+
|
|
334
|
+
## System Context (private Beta API - subject to changes)
|
|
335
|
+
|
|
336
|
+
The <sp-theme> element provides a "system" context to its descendants in the DOM. This context indicates the Spectrum design system variant currently in use (e.g., 'spectrum', 'express', or 'spectrum-two').
|
|
337
|
+
|
|
338
|
+
#### Consuming the System Context in Components
|
|
339
|
+
|
|
340
|
+
Components can consume the system context by using the `SystemResolutionController`. This controller encapsulates the logic for resolving the system context, allowing it to be integrated into any component in few steps.
|
|
341
|
+
|
|
342
|
+
#### Steps to Consume the System Context:
|
|
343
|
+
|
|
344
|
+
1. Import the `SystemResolutionController` and the necessary types:
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
import {
|
|
348
|
+
SystemResolutionController,
|
|
349
|
+
systemResolverUpdatedSymbol,
|
|
350
|
+
} from './SystemResolutionController.js';
|
|
351
|
+
import type { SystemVariant } from '@spectrum-web-components/theme';
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
2. Instantiate the `SystemResolutionController`:
|
|
355
|
+
|
|
356
|
+
In your component class, create an instance of SystemResolutionController, passing `this` as the host element.
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
export class MyComponent extends LitElement {
|
|
360
|
+
private systemResolver = new SystemResolutionController(this);
|
|
361
|
+
|
|
362
|
+
// Rest of your component code...
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
3. Respond to system context changes:
|
|
367
|
+
|
|
368
|
+
Override the `update` lifecycle method to detect changes in the system context using the `systemResolverUpdatedSymbol`.
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
protected update(changes: Map<PropertyKey, unknown>): void {
|
|
372
|
+
super.update(changes);
|
|
373
|
+
if (changes.has(systemResolverUpdatedSymbol)) {
|
|
374
|
+
this.handleSystemChange();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
4. Implement the handler for system changes:
|
|
380
|
+
|
|
381
|
+
Create a method that will be called whenever the system context changes. Use `this.systemResolver.system` to access the current system variant.
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
private handleSystemChange(): void {
|
|
385
|
+
const currentSystem: SystemVariant = this.systemResolver.system;
|
|
386
|
+
// Implement logic based on the current system variant.
|
|
387
|
+
// For example, update styles, states or re-render parts of the component.
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
5. Use the system context in other parts of your component logic and/or template:
|
|
392
|
+
|
|
393
|
+
You can now use `this.systemResolver.system` anywhere in your component to adjust behavior or rendering based on the system variant.
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
render() {
|
|
397
|
+
return html`
|
|
398
|
+
<div>
|
|
399
|
+
<!-- Use the system context in your rendering logic -->
|
|
400
|
+
Current system variant: ${this.systemResolver.system}
|
|
401
|
+
</div>
|
|
402
|
+
`;
|
|
403
|
+
}
|
|
404
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0-beta.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -237,8 +237,8 @@
|
|
|
237
237
|
"lit-html"
|
|
238
238
|
],
|
|
239
239
|
"dependencies": {
|
|
240
|
-
"@spectrum-web-components/base": "^0.
|
|
241
|
-
"@spectrum-web-components/styles": "^0.
|
|
240
|
+
"@spectrum-web-components/base": "^0.49.0-beta.1",
|
|
241
|
+
"@spectrum-web-components/styles": "^0.49.0-beta.1"
|
|
242
242
|
},
|
|
243
243
|
"types": "./src/index.d.ts",
|
|
244
244
|
"customElements": "custom-elements.json",
|
|
@@ -265,5 +265,5 @@
|
|
|
265
265
|
"./src/spectrum-two/themes.js",
|
|
266
266
|
"./src/spectrum-two/themes-*.js"
|
|
267
267
|
],
|
|
268
|
-
"gitHead": "
|
|
268
|
+
"gitHead": "74ee2c5b1276e8e4f768566a1c3c4e263a7eb8b3"
|
|
269
269
|
}
|
package/src/Theme.d.ts
CHANGED
|
@@ -60,6 +60,23 @@ export declare class Theme extends HTMLElement implements ThemeKindProvider {
|
|
|
60
60
|
private get styles();
|
|
61
61
|
private static get template();
|
|
62
62
|
constructor();
|
|
63
|
+
/**
|
|
64
|
+
* Stores system context consumers and their associated callbacks.
|
|
65
|
+
*
|
|
66
|
+
* This Map associates each consumer component (HTMLElement) with a tuple containing:
|
|
67
|
+
* - The `SystemContextCallback` function to be invoked with the system context.
|
|
68
|
+
* - An `unsubscribe` function to remove the consumer from the Map when it's no longer needed.
|
|
69
|
+
*/
|
|
70
|
+
private _systemContextConsumers;
|
|
71
|
+
/**
|
|
72
|
+
* Handles the 'sp-system-context' event dispatched by descendant components requesting the system context.
|
|
73
|
+
*
|
|
74
|
+
* This method registers the requesting component's callback and provides the current system context to it.
|
|
75
|
+
* It also manages the unsubscribe mechanism to clean up when the component is disconnected.
|
|
76
|
+
*
|
|
77
|
+
* @param event - The custom event containing the callback function to provide the system context.
|
|
78
|
+
*/
|
|
79
|
+
private _handleSystemContext;
|
|
63
80
|
updateComplete: Promise<boolean>;
|
|
64
81
|
private __resolve;
|
|
65
82
|
private __createDeferredPromise;
|
|
@@ -74,5 +91,13 @@ export declare class Theme extends HTMLElement implements ThemeKindProvider {
|
|
|
74
91
|
static registerThemeFragment(name: FragmentName, kind: FragmentType, styles: CSSResultGroup): void;
|
|
75
92
|
private _contextConsumers;
|
|
76
93
|
private _provideContext;
|
|
94
|
+
/**
|
|
95
|
+
* Provides the current system context to all registered consumers.
|
|
96
|
+
*
|
|
97
|
+
* This method iterates over all registered system context consumers and invokes their callbacks,
|
|
98
|
+
* passing the current system variant and the unsubscribe function. This ensures that any component
|
|
99
|
+
* consuming the system context receives the updated system variant when the `system` (or `theme`) attribute changes.
|
|
100
|
+
*/
|
|
101
|
+
private _provideSystemContext;
|
|
77
102
|
private _handleContextPresence;
|
|
78
103
|
}
|
package/src/Theme.dev.js
CHANGED
|
@@ -12,6 +12,14 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
12
12
|
this._system = "spectrum";
|
|
13
13
|
this._color = "";
|
|
14
14
|
this._scale = "";
|
|
15
|
+
/**
|
|
16
|
+
* Stores system context consumers and their associated callbacks.
|
|
17
|
+
*
|
|
18
|
+
* This Map associates each consumer component (HTMLElement) with a tuple containing:
|
|
19
|
+
* - The `SystemContextCallback` function to be invoked with the system context.
|
|
20
|
+
* - An `unsubscribe` function to remove the consumer from the Map when it's no longer needed.
|
|
21
|
+
*/
|
|
22
|
+
this._systemContextConsumers = /* @__PURE__ */ new Map();
|
|
15
23
|
this.trackedChildren = /* @__PURE__ */ new Set();
|
|
16
24
|
this._updateRequested = false;
|
|
17
25
|
this._contextConsumers = /* @__PURE__ */ new Map();
|
|
@@ -23,6 +31,10 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
23
31
|
"sp-language-context",
|
|
24
32
|
this._handleContextPresence
|
|
25
33
|
);
|
|
34
|
+
this.addEventListener(
|
|
35
|
+
"sp-system-context",
|
|
36
|
+
this._handleSystemContext
|
|
37
|
+
);
|
|
26
38
|
this.updateComplete = this.__createDeferredPromise();
|
|
27
39
|
}
|
|
28
40
|
static get observedAttributes() {
|
|
@@ -66,9 +78,11 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
66
78
|
this._provideContext();
|
|
67
79
|
} else if (attrName === "theme") {
|
|
68
80
|
this.theme = value;
|
|
81
|
+
this._provideSystemContext();
|
|
69
82
|
warnBetaSystem(this, value);
|
|
70
83
|
} else if (attrName === "system") {
|
|
71
84
|
this.system = value;
|
|
85
|
+
this._provideSystemContext();
|
|
72
86
|
warnBetaSystem(this, value);
|
|
73
87
|
} else if (attrName === "dir") {
|
|
74
88
|
this.dir = value;
|
|
@@ -214,6 +228,30 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
214
228
|
}
|
|
215
229
|
return this.templateElement;
|
|
216
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Handles the 'sp-system-context' event dispatched by descendant components requesting the system context.
|
|
233
|
+
*
|
|
234
|
+
* This method registers the requesting component's callback and provides the current system context to it.
|
|
235
|
+
* It also manages the unsubscribe mechanism to clean up when the component is disconnected.
|
|
236
|
+
*
|
|
237
|
+
* @param event - The custom event containing the callback function to provide the system context.
|
|
238
|
+
*/
|
|
239
|
+
_handleSystemContext(event) {
|
|
240
|
+
event.stopPropagation();
|
|
241
|
+
const target = event.composedPath()[0];
|
|
242
|
+
if (this._systemContextConsumers.has(target)) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const unsubscribe = () => this._systemContextConsumers.delete(target);
|
|
246
|
+
this._systemContextConsumers.set(target, [
|
|
247
|
+
event.detail.callback,
|
|
248
|
+
unsubscribe
|
|
249
|
+
]);
|
|
250
|
+
const [callback] = this._systemContextConsumers.get(target) || [];
|
|
251
|
+
if (callback) {
|
|
252
|
+
callback(this.system, unsubscribe);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
217
255
|
__createDeferredPromise() {
|
|
218
256
|
return new Promise((resolve) => {
|
|
219
257
|
this.__resolve = resolve;
|
|
@@ -274,6 +312,19 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
274
312
|
([callback, unsubscribe]) => callback(this.lang, unsubscribe)
|
|
275
313
|
);
|
|
276
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Provides the current system context to all registered consumers.
|
|
317
|
+
*
|
|
318
|
+
* This method iterates over all registered system context consumers and invokes their callbacks,
|
|
319
|
+
* passing the current system variant and the unsubscribe function. This ensures that any component
|
|
320
|
+
* consuming the system context receives the updated system variant when the `system` (or `theme`) attribute changes.
|
|
321
|
+
*/
|
|
322
|
+
/* c8 ignore next 5 */
|
|
323
|
+
_provideSystemContext() {
|
|
324
|
+
this._systemContextConsumers.forEach(
|
|
325
|
+
([callback, unsubscribe]) => callback(this.system, unsubscribe)
|
|
326
|
+
);
|
|
327
|
+
}
|
|
277
328
|
_handleContextPresence(event) {
|
|
278
329
|
event.stopPropagation();
|
|
279
330
|
const target = event.composedPath()[0];
|
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 { 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,SAAS,eAAe;AACxB;AAAA,EAEI;AAAA,EAMA;AAAA,EAGA;AAAA,
|
|
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 SystemContextCallback,\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 this._provideSystemContext();\n warnBetaSystem(this, value as SystemVariant);\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n this._provideSystemContext();\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.addEventListener(\n 'sp-system-context',\n this._handleSystemContext as EventListener\n );\n\n this.updateComplete = this.__createDeferredPromise();\n }\n\n /**\n * Stores system context consumers and their associated callbacks.\n *\n * This Map associates each consumer component (HTMLElement) with a tuple containing:\n * - The `SystemContextCallback` function to be invoked with the system context.\n * - An `unsubscribe` function to remove the consumer from the Map when it's no longer needed.\n */\n private _systemContextConsumers = new Map<\n HTMLElement,\n [SystemContextCallback, () => void]\n >();\n\n /**\n * Handles the 'sp-system-context' event dispatched by descendant components requesting the system context.\n *\n * This method registers the requesting component's callback and provides the current system context to it.\n * It also manages the unsubscribe mechanism to clean up when the component is disconnected.\n *\n * @param event - The custom event containing the callback function to provide the system context.\n */\n private _handleSystemContext(\n event: CustomEvent<{ callback: SystemContextCallback }>\n ): void {\n event.stopPropagation();\n\n const target = event.composedPath()[0] as HTMLElement;\n\n /* c8 ignore next 4 */\n // Avoid duplicate registrations\n if (this._systemContextConsumers.has(target)) {\n return;\n }\n\n // Create an unsubscribe function\n const unsubscribe: () => void = () =>\n this._systemContextConsumers.delete(target);\n\n // Store the callback and unsubscribe function\n this._systemContextConsumers.set(target, [\n event.detail.callback,\n unsubscribe,\n ]);\n\n // Provide the context data\n const [callback] = this._systemContextConsumers.get(target) || [];\n if (callback) {\n callback(this.system, unsubscribe);\n }\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 /**\n * Provides the current system context to all registered consumers.\n *\n * This method iterates over all registered system context consumers and invokes their callbacks,\n * passing the current system variant and the unsubscribe function. This ensures that any component\n * consuming the system context receives the updated system variant when the `system` (or `theme`) attribute changes.\n */\n /* c8 ignore next 5 */\n private _provideSystemContext(): void {\n this._systemContextConsumers.forEach(([callback, unsubscribe]) =>\n callback(this.system, 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,SAAS,eAAe;AACxB;AAAA,EAEI;AAAA,EAMA;AAAA,EAGA;AAAA,OAKG;AAQA,MAAM,SAAN,MAAM,eAAc,YAAyC;AAAA,EAkQhE,cAAc;AACV,UAAM;AAhPV,gBAA2B;AAwD3B,SAAQ,UAA8B;AAoDtC,SAAQ,SAAqB;AAkC7B,SAAQ,SAAqB;AA0H7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,0BAA0B,oBAAI,IAGpC;AAuFF,SAAQ,kBAAoC,oBAAI,IAAI;AAEpD,SAAQ,mBAAmB;AAqC3B,SAAQ,oBAAoB,oBAAI,IAG9B;AA3JE,SAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAClC,UAAM,OAAO,SAAS,WAAW,OAAM,SAAS,SAAS,IAAI;AAC7D,SAAK,WAAW,YAAY,IAAI;AAChC,SAAK,kBAAkB;AACvB,SAAK;AAAA,MACD;AAAA,MACA,KAAK;AAAA,IACT;AACA,SAAK;AAAA,MACD;AAAA,MACA,KAAK;AAAA,IACT;AAEA,SAAK,iBAAiB,KAAK,wBAAwB;AAAA,EACvD;AAAA,EA3QA,WAAW,qBAA+B;AACtC,WAAO;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,IACJ;AAAA,EACJ;AAAA,EAIA,IAAa,IAAI,KAAyB;AACtC,QAAI,QAAQ,KAAK,IAAK;AACtB,SAAK,aAAa,OAAO,GAAG;AAC5B,S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E,iBACK,SAAS,WAAW,KAAK;AAAA,UAExC;AACE,eAAO;AAAA,UACH,iBAAiB,IAAI,KAAK,aAAa;AAAA,QAC3C;AAAA,MACJ;AAAA,IACJ;AAEA,QAAI,mBAAmB;AACnB,aAAO;AAAA,QACH;AAAA,MACJ;AAAA,IACJ;AACA,QAAI,CAAC,YAAY,SAAS,EAAE,SAAS,SAAS,EAAE,GAAG;AAC/C,aAAO;AAAA,QACH;AAAA,MACJ;AAAA,IACJ;AACA,sBAAkB,UAAU,QAAQ,SAAS,aAAa,QAAQ,CAAC;AACnE,sBAAkB,SAAS,OAAO,SAAS,aAAa,OAAO,CAAC;AAChE,sBAAkB,SAAS,OAAO,SAAS,aAAa,OAAO,CAAC;AAEhE,QAAI,OAAO,QAAQ;AACf,aAAO,MAAM;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,EAAE,OAAO;AAAA,MACb;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Theme.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";import{version as d}from"@spectrum-web-components/base/src/version.js";import{COLOR_VALUES as u,SCALE_VALUES as p,SYSTEM_VARIANT_VALUES as
|
|
1
|
+
"use strict";import{version as d}from"@spectrum-web-components/base/src/version.js";import{COLOR_VALUES as u,SCALE_VALUES as p,SYSTEM_VARIANT_VALUES as y}from"./theme-interfaces.js";const o=class o extends HTMLElement{constructor(){super();this._dir="";this._system="spectrum";this._color="";this._scale="";this._systemContextConsumers=new Map;this.trackedChildren=new Set;this._updateRequested=!1;this._contextConsumers=new Map;this.attachShadow({mode:"open"});const e=document.importNode(o.template.content,!0);this.shadowRoot.appendChild(e),this.shouldAdoptStyles(),this.addEventListener("sp-language-context",this._handleContextPresence),this.addEventListener("sp-system-context",this._handleSystemContext),this.updateComplete=this.__createDeferredPromise()}static get observedAttributes(){return["color","scale","lang","dir","system","theme"]}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,this._provideSystemContext(),void 0):e==="system"?(this.system=s,this._provideSystemContext(),void 0):e==="dir"&&(this.dir=s))}requestUpdate(){this.shouldAdoptStyles()}get system(){const e=o.themeFragmentsByKind.get("system"),{name:t}=e&&e.get("default")||{};return this._system||t||""}set system(e){if(e===this._system)return;const t=e&&y.includes(e)?e:this.system;t!==this._system&&(this._system=t,this.requestUpdate()),t?this.setAttribute("system",t):this.removeAttribute("system")}get theme(){return this.system||this.removeAttribute("system"),this.system}set theme(e){this.system=e,this.requestUpdate()}get color(){const e=o.themeFragmentsByKind.get("color"),{name:t}=e&&e.get("default")||{};return this._color||t||""}set color(e){if(e===this._color)return;const t=e&&u.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=o.themeFragmentsByKind.get("scale"),{name:t}=e&&e.get("default")||{};return this._scale||t||""}set scale(e){if(e===this._scale)return;const t=e&&p.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=[...o.themeFragmentsByKind.keys()],t=(n,r,a)=>{const l=a&&a!=="theme"&&a!=="system"&&this.theme!=="spectrum"&&this.system!=="spectrum"?n.get(`${r}-${this.system}`):n.get(r),m=r==="spectrum"||!a||this.hasAttribute(a);if(l&&m)return l.styles},s=e.reduce((n,r)=>{const a=o.themeFragmentsByKind.get(r);let l;if(r==="app"||r==="core")l=t(a,r);else{const{[r]:m}=this;l=t(a,m,r)}return l&&n.push(l),n},[]),i=o.themeFragmentsByKind;return this.system,this.color,this.scale,this.hasAttribute("theme"),[...s]}static get template(){return this.templateElement||(this.templateElement=document.createElement("template"),this.templateElement.innerHTML="<slot></slot>"),this.templateElement}_handleSystemContext(e){e.stopPropagation();const t=e.composedPath()[0];if(this._systemContextConsumers.has(t))return;const s=()=>this._systemContextConsumers.delete(t);this._systemContextConsumers.set(t,[e.detail.callback,s]);const[i]=this._systemContextConsumers.get(t)||[];i&&i(this.system,s)}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}connectedCallback(){if(this.shouldAdoptStyles(),o.instances.add(this),!this.hasAttribute("dir")){let e=this.assignedSlot||this.parentNode;for(;e!==document.documentElement&&!(e instanceof o);)e=e.assignedSlot||e.parentNode||e.host;this.dir=e.dir==="rtl"?e.dir:"ltr"}}disconnectedCallback(){o.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,t=[];for(const s of e)t.push(s.styleSheet);this.shadowRoot.adoptedStyleSheets=t}static registerThemeFragment(e,t,s){const i=o.themeFragmentsByKind.get(t)||new Map;i.size===0&&(o.themeFragmentsByKind.set(t,i),i.set("default",{name:e,styles:s}),o.defaultFragments.add(e)),i.set(e,{name:e,styles:s}),o.instances.forEach(n=>n.shouldAdoptStyles())}_provideContext(){this._contextConsumers.forEach(([e,t])=>e(this.lang,t))}_provideSystemContext(){this._systemContextConsumers.forEach(([e,t])=>e(this.system,t))}_handleContextPresence(e){e.stopPropagation();const t=e.composedPath()[0];if(this._contextConsumers.has(t))return;this._contextConsumers.set(t,[e.detail.callback,()=>this._contextConsumers.delete(t)]);const[s,i]=this._contextConsumers.get(t)||[];s&&i&&s(this.lang||document.documentElement.lang||navigator.language,i)}};o.themeFragmentsByKind=new Map,o.defaultFragments=new Set(["spectrum"]),o.instances=new Set,o.VERSION=d;export let Theme=o;function V(h,c){}function B(h,c,e,t,s,i){}
|
|
2
2
|
//# sourceMappingURL=Theme.js.map
|
package/src/Theme.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 { 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.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,OAAS,WAAAA,MAAe,+CACxB,OAEI,gBAAAC,EAMA,gBAAAC,EAGA,yBAAAC,
|
|
6
|
-
"names": ["version", "COLOR_VALUES", "SCALE_VALUES", "SYSTEM_VARIANT_VALUES", "_Theme", "node", "dir", "targetDir", "el", "attrName", "old", "value", "systemFragments", "name", "newValue", "system", "themeFragments", "color", "scale", "themeKinds", "getStyle", "fragments", "kind", "currentStyles", "isAppliedFragment", "styles", "acc", "kindFragments", "style", "themeFragmentsByKind", "
|
|
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 SystemContextCallback,\n SystemVariant,\n ThemeFragmentMap,\n ThemeKindProvider,\n} from './theme-interfaces.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 this._provideSystemContext();\n warnBetaSystem(this, value as SystemVariant);\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n this._provideSystemContext();\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.addEventListener(\n 'sp-system-context',\n this._handleSystemContext as EventListener\n );\n\n this.updateComplete = this.__createDeferredPromise();\n }\n\n /**\n * Stores system context consumers and their associated callbacks.\n *\n * This Map associates each consumer component (HTMLElement) with a tuple containing:\n * - The `SystemContextCallback` function to be invoked with the system context.\n * - An `unsubscribe` function to remove the consumer from the Map when it's no longer needed.\n */\n private _systemContextConsumers = new Map<\n HTMLElement,\n [SystemContextCallback, () => void]\n >();\n\n /**\n * Handles the 'sp-system-context' event dispatched by descendant components requesting the system context.\n *\n * This method registers the requesting component's callback and provides the current system context to it.\n * It also manages the unsubscribe mechanism to clean up when the component is disconnected.\n *\n * @param event - The custom event containing the callback function to provide the system context.\n */\n private _handleSystemContext(\n event: CustomEvent<{ callback: SystemContextCallback }>\n ): void {\n event.stopPropagation();\n\n const target = event.composedPath()[0] as HTMLElement;\n\n /* c8 ignore next 4 */\n // Avoid duplicate registrations\n if (this._systemContextConsumers.has(target)) {\n return;\n }\n\n // Create an unsubscribe function\n const unsubscribe: () => void = () =>\n this._systemContextConsumers.delete(target);\n\n // Store the callback and unsubscribe function\n this._systemContextConsumers.set(target, [\n event.detail.callback,\n unsubscribe,\n ]);\n\n // Provide the context data\n const [callback] = this._systemContextConsumers.get(target) || [];\n if (callback) {\n callback(this.system, unsubscribe);\n }\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 /**\n * Provides the current system context to all registered consumers.\n *\n * This method iterates over all registered system context consumers and invokes their callbacks,\n * passing the current system variant and the unsubscribe function. This ensures that any component\n * consuming the system context receives the updated system variant when the `system` (or `theme`) attribute changes.\n */\n /* c8 ignore next 5 */\n private _provideSystemContext(): void {\n this._systemContextConsumers.forEach(([callback, unsubscribe]) =>\n callback(this.system, 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,OAAS,WAAAA,MAAe,+CACxB,OAEI,gBAAAC,EAMA,gBAAAC,EAGA,yBAAAC,MAKG,wBAQA,MAAMC,EAAN,MAAMA,UAAc,WAAyC,CAkQhE,aAAc,CACV,MAAM,EAhPV,UAA2B,GAwD3B,KAAQ,QAA8B,WAoDtC,K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YSTEM_VARIANT_VALUES", "_Theme", "node", "dir", "targetDir", "el", "attrName", "old", "value", "systemFragments", "name", "newValue", "system", "themeFragments", "color", "scale", "themeKinds", "getStyle", "fragments", "kind", "currentStyles", "isAppliedFragment", "styles", "acc", "kindFragments", "style", "themeFragmentsByKind", "event", "target", "unsubscribe", "callback", "resolve", "dirParent", "styleSheets", "fragmentMap", "instance", "warnBetaSystem", "checkForIssues", "hasThemeAttribute"]
|
|
7
7
|
}
|
|
@@ -15,6 +15,7 @@ export declare const COLOR_VALUES: readonly ["light", "lightest", "dark", "darke
|
|
|
15
15
|
export type SystemVariant = (typeof SYSTEM_VARIANT_VALUES)[number];
|
|
16
16
|
export type Scale = (typeof SCALE_VALUES)[number];
|
|
17
17
|
export type Color = (typeof COLOR_VALUES)[number];
|
|
18
|
+
export type SystemContextCallback = (system: SystemVariant | '', unsubscribe: () => void) => void;
|
|
18
19
|
export type FragmentName = Color | Scale | SystemVariant | 'core' | 'app';
|
|
19
20
|
export type ThemeKindProvider = {
|
|
20
21
|
[P in SettableFragmentTypes]: SystemVariant | Color | Scale | '';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["theme-interfaces.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { CSSResultGroup } from '@spectrum-web-components/base';\n\nexport type ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\nexport type FragmentType =\n | 'color'\n | 'scale'\n | 'system'\n | 'theme'\n | 'core'\n | 'app';\nexport type SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';\nexport type FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\n\nexport const SYSTEM_VARIANT_VALUES = [\n 'spectrum',\n 'express',\n 'spectrum-two',\n] as const;\n\nexport const SCALE_VALUES = [\n 'medium',\n 'large',\n 'medium-express',\n 'large-express',\n 'medium-spectrum-two',\n 'large-spectrum-two',\n] as const;\n\nexport const COLOR_VALUES = [\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] as const;\n\nexport type SystemVariant = (typeof SYSTEM_VARIANT_VALUES)[number];\nexport type Scale = (typeof SCALE_VALUES)[number];\nexport type Color = (typeof COLOR_VALUES)[number];\n\nexport type FragmentName = Color | Scale | SystemVariant | 'core' | 'app';\n\nexport type ThemeKindProvider = {\n [P in SettableFragmentTypes]: SystemVariant | Color | Scale | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { CSSResultGroup } from '@spectrum-web-components/base';\n\nexport type ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\nexport type FragmentType =\n | 'color'\n | 'scale'\n | 'system'\n | 'theme'\n | 'core'\n | 'app';\nexport type SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';\nexport type FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\n\nexport const SYSTEM_VARIANT_VALUES = [\n 'spectrum',\n 'express',\n 'spectrum-two',\n] as const;\n\nexport const SCALE_VALUES = [\n 'medium',\n 'large',\n 'medium-express',\n 'large-express',\n 'medium-spectrum-two',\n 'large-spectrum-two',\n] as const;\n\nexport const COLOR_VALUES = [\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] as const;\n\nexport type SystemVariant = (typeof SYSTEM_VARIANT_VALUES)[number];\nexport type Scale = (typeof SCALE_VALUES)[number];\nexport type Color = (typeof COLOR_VALUES)[number];\n\nexport type SystemContextCallback = (\n system: SystemVariant | '',\n unsubscribe: () => void\n) => void;\n\nexport type FragmentName = Color | Scale | SystemVariant | 'core' | 'app';\n\nexport type ThemeKindProvider = {\n [P in SettableFragmentTypes]: SystemVariant | Color | Scale | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n"],
|
|
5
5
|
"mappings": ";AA4BO,aAAM,wBAAwB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACJ;AAEO,aAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEO,aAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["theme-interfaces.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { CSSResultGroup } from '@spectrum-web-components/base';\n\nexport type ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\nexport type FragmentType =\n | 'color'\n | 'scale'\n | 'system'\n | 'theme'\n | 'core'\n | 'app';\nexport type SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';\nexport type FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\n\nexport const SYSTEM_VARIANT_VALUES = [\n 'spectrum',\n 'express',\n 'spectrum-two',\n] as const;\n\nexport const SCALE_VALUES = [\n 'medium',\n 'large',\n 'medium-express',\n 'large-express',\n 'medium-spectrum-two',\n 'large-spectrum-two',\n] as const;\n\nexport const COLOR_VALUES = [\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] as const;\n\nexport type SystemVariant = (typeof SYSTEM_VARIANT_VALUES)[number];\nexport type Scale = (typeof SCALE_VALUES)[number];\nexport type Color = (typeof COLOR_VALUES)[number];\n\nexport type FragmentName = Color | Scale | SystemVariant | 'core' | 'app';\n\nexport type ThemeKindProvider = {\n [P in SettableFragmentTypes]: SystemVariant | Color | Scale | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { CSSResultGroup } from '@spectrum-web-components/base';\n\nexport type ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\nexport type FragmentType =\n | 'color'\n | 'scale'\n | 'system'\n | 'theme'\n | 'core'\n | 'app';\nexport type SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';\nexport type FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\n\nexport const SYSTEM_VARIANT_VALUES = [\n 'spectrum',\n 'express',\n 'spectrum-two',\n] as const;\n\nexport const SCALE_VALUES = [\n 'medium',\n 'large',\n 'medium-express',\n 'large-express',\n 'medium-spectrum-two',\n 'large-spectrum-two',\n] as const;\n\nexport const COLOR_VALUES = [\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] as const;\n\nexport type SystemVariant = (typeof SYSTEM_VARIANT_VALUES)[number];\nexport type Scale = (typeof SCALE_VALUES)[number];\nexport type Color = (typeof COLOR_VALUES)[number];\n\nexport type SystemContextCallback = (\n system: SystemVariant | '',\n unsubscribe: () => void\n) => void;\n\nexport type FragmentName = Color | Scale | SystemVariant | 'core' | 'app';\n\nexport type ThemeKindProvider = {\n [P in SettableFragmentTypes]: SystemVariant | Color | Scale | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n"],
|
|
5
5
|
"mappings": "aA4BO,aAAM,sBAAwB,CACjC,WACA,UACA,cACJ,EAEa,aAAe,CACxB,SACA,QACA,iBACA,gBACA,sBACA,oBACJ,EAEa,aAAe,CACxB,QACA,WACA,OACA,UACA,gBACA,mBACA,eACA,kBACA,qBACA,mBACJ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/custom-elements.json
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": "1.0.0",
|
|
3
|
-
"readme": "",
|
|
4
|
-
"modules": [
|
|
5
|
-
{
|
|
6
|
-
"kind": "javascript-module",
|
|
7
|
-
"path": "sp-theme.js",
|
|
8
|
-
"declarations": [],
|
|
9
|
-
"exports": [
|
|
10
|
-
{
|
|
11
|
-
"kind": "custom-element-definition",
|
|
12
|
-
"name": "sp-theme",
|
|
13
|
-
"declaration": {
|
|
14
|
-
"name": "Theme",
|
|
15
|
-
"module": "/src/Theme.js"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"kind": "javascript-module",
|
|
22
|
-
"path": "src/Theme.js",
|
|
23
|
-
"declarations": [
|
|
24
|
-
{
|
|
25
|
-
"kind": "class",
|
|
26
|
-
"description": "",
|
|
27
|
-
"name": "Theme",
|
|
28
|
-
"slots": [
|
|
29
|
-
{
|
|
30
|
-
"description": "Content on which to apply the CSS Custom Properties defined by the current theme configuration",
|
|
31
|
-
"name": ""
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"members": [
|
|
35
|
-
{
|
|
36
|
-
"kind": "field",
|
|
37
|
-
"name": "themeFragmentsByKind",
|
|
38
|
-
"type": {
|
|
39
|
-
"text": "ThemeFragmentMap"
|
|
40
|
-
},
|
|
41
|
-
"privacy": "private",
|
|
42
|
-
"static": true,
|
|
43
|
-
"default": "new Map()"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"kind": "field",
|
|
47
|
-
"name": "defaultFragments",
|
|
48
|
-
"type": {
|
|
49
|
-
"text": "Set<FragmentName>"
|
|
50
|
-
},
|
|
51
|
-
"privacy": "private",
|
|
52
|
-
"static": true,
|
|
53
|
-
"default": "new Set(['spectrum'])"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"kind": "field",
|
|
57
|
-
"name": "templateElement",
|
|
58
|
-
"type": {
|
|
59
|
-
"text": "HTMLTemplateElement | undefined"
|
|
60
|
-
},
|
|
61
|
-
"privacy": "private",
|
|
62
|
-
"static": true
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"kind": "field",
|
|
66
|
-
"name": "instances",
|
|
67
|
-
"type": {
|
|
68
|
-
"text": "Set<Theme>"
|
|
69
|
-
},
|
|
70
|
-
"privacy": "private",
|
|
71
|
-
"static": true,
|
|
72
|
-
"default": "new Set()"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"kind": "field",
|
|
76
|
-
"name": "VERSION",
|
|
77
|
-
"static": true,
|
|
78
|
-
"default": "version"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"kind": "field",
|
|
82
|
-
"name": "_dir",
|
|
83
|
-
"type": {
|
|
84
|
-
"text": "'ltr' | 'rtl' | ''"
|
|
85
|
-
},
|
|
86
|
-
"default": "''"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"kind": "field",
|
|
90
|
-
"name": "dir",
|
|
91
|
-
"type": {
|
|
92
|
-
"text": "\"ltr\" | \"rtl\" | \"\""
|
|
93
|
-
},
|
|
94
|
-
"description": "Reading direction of the content scoped to this `sp-theme` element.",
|
|
95
|
-
"attribute": "dir"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"kind": "field",
|
|
99
|
-
"name": "shadowRoot",
|
|
100
|
-
"type": {
|
|
101
|
-
"text": "ShadowRootWithAdoptedStyleSheets"
|
|
102
|
-
},
|
|
103
|
-
"privacy": "public"
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"kind": "field",
|
|
107
|
-
"name": "_system",
|
|
108
|
-
"type": {
|
|
109
|
-
"text": "SystemVariant | ''"
|
|
110
|
-
},
|
|
111
|
-
"privacy": "private",
|
|
112
|
-
"default": "'spectrum'"
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"kind": "field",
|
|
116
|
-
"name": "system",
|
|
117
|
-
"type": {
|
|
118
|
-
"text": "\"spectrum\" | \"express\""
|
|
119
|
-
},
|
|
120
|
-
"description": "The Spectrum system that is applied to the content scoped to this `sp-theme` element.\n\nA value is requried.",
|
|
121
|
-
"attribute": "system"
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"kind": "field",
|
|
125
|
-
"name": "theme",
|
|
126
|
-
"type": {
|
|
127
|
-
"text": "SystemVariant | ''"
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"kind": "field",
|
|
132
|
-
"name": "_color",
|
|
133
|
-
"type": {
|
|
134
|
-
"text": "Color | ''"
|
|
135
|
-
},
|
|
136
|
-
"privacy": "private",
|
|
137
|
-
"default": "''"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"kind": "field",
|
|
141
|
-
"name": "color",
|
|
142
|
-
"type": {
|
|
143
|
-
"text": "\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\""
|
|
144
|
-
},
|
|
145
|
-
"description": "The Spectrum color stops to apply to content scoped by this `sp-theme` element.\n\nA value is requried.",
|
|
146
|
-
"attribute": "color"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"kind": "field",
|
|
150
|
-
"name": "_scale",
|
|
151
|
-
"type": {
|
|
152
|
-
"text": "Scale | ''"
|
|
153
|
-
},
|
|
154
|
-
"privacy": "private",
|
|
155
|
-
"default": "''"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"kind": "field",
|
|
159
|
-
"name": "scale",
|
|
160
|
-
"type": {
|
|
161
|
-
"text": "\"medium\" | \"large\" | \"\""
|
|
162
|
-
},
|
|
163
|
-
"description": "The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n\nA value is requried.",
|
|
164
|
-
"attribute": "scale"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
"kind": "field",
|
|
168
|
-
"name": "template",
|
|
169
|
-
"type": {
|
|
170
|
-
"text": "HTMLTemplateElement"
|
|
171
|
-
},
|
|
172
|
-
"privacy": "private",
|
|
173
|
-
"static": true,
|
|
174
|
-
"readonly": true
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"kind": "field",
|
|
178
|
-
"name": "updateComplete",
|
|
179
|
-
"type": {
|
|
180
|
-
"text": "Promise<boolean>"
|
|
181
|
-
},
|
|
182
|
-
"privacy": "public"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
"kind": "field",
|
|
186
|
-
"name": "__resolve",
|
|
187
|
-
"type": {
|
|
188
|
-
"text": "(compelted: boolean) => void"
|
|
189
|
-
},
|
|
190
|
-
"privacy": "private"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
"kind": "method",
|
|
194
|
-
"name": "__createDeferredPromise",
|
|
195
|
-
"privacy": "private",
|
|
196
|
-
"return": {
|
|
197
|
-
"type": {
|
|
198
|
-
"text": "Promise<boolean>"
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"kind": "method",
|
|
204
|
-
"name": "startManagingContentDirection",
|
|
205
|
-
"privacy": "public",
|
|
206
|
-
"return": {
|
|
207
|
-
"type": {
|
|
208
|
-
"text": "void"
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
"parameters": [
|
|
212
|
-
{
|
|
213
|
-
"name": "el",
|
|
214
|
-
"type": {
|
|
215
|
-
"text": "HTMLElement"
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
]
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
"kind": "method",
|
|
222
|
-
"name": "stopManagingContentDirection",
|
|
223
|
-
"privacy": "public",
|
|
224
|
-
"return": {
|
|
225
|
-
"type": {
|
|
226
|
-
"text": "void"
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
"parameters": [
|
|
230
|
-
{
|
|
231
|
-
"name": "el",
|
|
232
|
-
"type": {
|
|
233
|
-
"text": "HTMLElement"
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
]
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"kind": "field",
|
|
240
|
-
"name": "trackedChildren",
|
|
241
|
-
"type": {
|
|
242
|
-
"text": "Set<HTMLElement>"
|
|
243
|
-
},
|
|
244
|
-
"privacy": "private",
|
|
245
|
-
"default": "new Set()"
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
"kind": "field",
|
|
249
|
-
"name": "_updateRequested",
|
|
250
|
-
"type": {
|
|
251
|
-
"text": "boolean"
|
|
252
|
-
},
|
|
253
|
-
"privacy": "private",
|
|
254
|
-
"default": "false"
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
"kind": "method",
|
|
258
|
-
"name": "shouldAdoptStyles",
|
|
259
|
-
"privacy": "private",
|
|
260
|
-
"return": {
|
|
261
|
-
"type": {
|
|
262
|
-
"text": "Promise<void>"
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
"kind": "method",
|
|
268
|
-
"name": "adoptStyles",
|
|
269
|
-
"privacy": "protected",
|
|
270
|
-
"return": {
|
|
271
|
-
"type": {
|
|
272
|
-
"text": "void"
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
"kind": "method",
|
|
278
|
-
"name": "registerThemeFragment",
|
|
279
|
-
"static": true,
|
|
280
|
-
"return": {
|
|
281
|
-
"type": {
|
|
282
|
-
"text": "void"
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
"parameters": [
|
|
286
|
-
{
|
|
287
|
-
"name": "name",
|
|
288
|
-
"type": {
|
|
289
|
-
"text": "FragmentName"
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"name": "kind",
|
|
294
|
-
"type": {
|
|
295
|
-
"text": "FragmentType"
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
"name": "styles",
|
|
300
|
-
"type": {
|
|
301
|
-
"text": "CSSResultGroup"
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
"kind": "field",
|
|
308
|
-
"name": "_contextConsumers",
|
|
309
|
-
"privacy": "private",
|
|
310
|
-
"default": "new Map<\n HTMLElement,\n [ProvideLang['callback'], () => void]\n >()"
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
"kind": "method",
|
|
314
|
-
"name": "_provideContext",
|
|
315
|
-
"privacy": "private",
|
|
316
|
-
"return": {
|
|
317
|
-
"type": {
|
|
318
|
-
"text": "void"
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
"kind": "method",
|
|
324
|
-
"name": "_handleContextPresence",
|
|
325
|
-
"privacy": "private",
|
|
326
|
-
"return": {
|
|
327
|
-
"type": {
|
|
328
|
-
"text": "void"
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
"parameters": [
|
|
332
|
-
{
|
|
333
|
-
"name": "event",
|
|
334
|
-
"type": {
|
|
335
|
-
"text": "CustomEvent<ProvideLang>"
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
]
|
|
339
|
-
}
|
|
340
|
-
],
|
|
341
|
-
"attributes": [
|
|
342
|
-
{
|
|
343
|
-
"name": "color",
|
|
344
|
-
"type": {
|
|
345
|
-
"text": "\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\""
|
|
346
|
-
},
|
|
347
|
-
"description": "The Spectrum color stops to apply to content scoped by this `sp-theme` element.\n\nA value is requried.",
|
|
348
|
-
"fieldName": "color"
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
"name": "scale",
|
|
352
|
-
"type": {
|
|
353
|
-
"text": "\"medium\" | \"large\" | \"\""
|
|
354
|
-
},
|
|
355
|
-
"description": "The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n\nA value is requried.",
|
|
356
|
-
"fieldName": "scale"
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
"name": "lang",
|
|
360
|
-
"type": {
|
|
361
|
-
"text": "string"
|
|
362
|
-
},
|
|
363
|
-
"description": "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>.",
|
|
364
|
-
"default": "\"\""
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"name": "dir",
|
|
368
|
-
"type": {
|
|
369
|
-
"text": "\"ltr\" | \"rtl\" | \"\""
|
|
370
|
-
},
|
|
371
|
-
"description": "Reading direction of the content scoped to this `sp-theme` element.",
|
|
372
|
-
"fieldName": "dir"
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
"name": "system",
|
|
376
|
-
"type": {
|
|
377
|
-
"text": "\"spectrum\" | \"express\""
|
|
378
|
-
},
|
|
379
|
-
"description": "The Spectrum system that is applied to the content scoped to this `sp-theme` element.\n\nA value is requried.",
|
|
380
|
-
"fieldName": "system"
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
"name": "theme"
|
|
384
|
-
}
|
|
385
|
-
],
|
|
386
|
-
"superclass": {
|
|
387
|
-
"name": "HTMLElement"
|
|
388
|
-
},
|
|
389
|
-
"tagName": "sp-theme",
|
|
390
|
-
"customElement": true
|
|
391
|
-
}
|
|
392
|
-
],
|
|
393
|
-
"exports": [
|
|
394
|
-
{
|
|
395
|
-
"kind": "js",
|
|
396
|
-
"name": "ProvideLang",
|
|
397
|
-
"declaration": {
|
|
398
|
-
"name": "ProvideLang",
|
|
399
|
-
"module": "src/Theme.js"
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
"kind": "js",
|
|
404
|
-
"name": "ThemeFragmentMap",
|
|
405
|
-
"declaration": {
|
|
406
|
-
"name": "ThemeFragmentMap",
|
|
407
|
-
"module": "src/Theme.js"
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
"kind": "js",
|
|
412
|
-
"name": "Color",
|
|
413
|
-
"declaration": {
|
|
414
|
-
"name": "Color",
|
|
415
|
-
"module": "src/Theme.js"
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
"kind": "js",
|
|
420
|
-
"name": "Scale",
|
|
421
|
-
"declaration": {
|
|
422
|
-
"name": "Scale",
|
|
423
|
-
"module": "src/Theme.js"
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
"kind": "js",
|
|
428
|
-
"name": "SystemVariant",
|
|
429
|
-
"declaration": {
|
|
430
|
-
"name": "SystemVariant",
|
|
431
|
-
"module": "src/Theme.js"
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
"kind": "js",
|
|
436
|
-
"name": "Theme",
|
|
437
|
-
"declaration": {
|
|
438
|
-
"name": "Theme",
|
|
439
|
-
"module": "src/Theme.js"
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
]
|
|
443
|
-
}
|
|
444
|
-
]
|
|
445
|
-
}
|