@spectrum-web-components/theme 1.12.3-test.20260827122947 → 1.12.4

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.
@@ -77,12 +77,6 @@
77
77
  "static": true,
78
78
  "default": "version"
79
79
  },
80
- {
81
- "kind": "field",
82
- "name": "CORE_VERSION",
83
- "static": true,
84
- "default": "coreVersion"
85
- },
86
80
  {
87
81
  "kind": "field",
88
82
  "name": "shadowRoot",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/theme",
3
- "version": "1.12.3-test.20260827122947",
3
+ "version": "1.12.4",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Adobe",
@@ -297,8 +297,8 @@
297
297
  ],
298
298
  "types": "./src/index.d.ts",
299
299
  "dependencies": {
300
- "@spectrum-web-components/base": "1.12.3-test.20260827122947",
301
- "@spectrum-web-components/styles": "1.12.3-test.20260827122947"
300
+ "@spectrum-web-components/base": "1.12.4",
301
+ "@spectrum-web-components/styles": "1.12.4"
302
302
  },
303
303
  "keywords": [
304
304
  "design-system",
package/src/Theme.d.ts CHANGED
@@ -24,7 +24,6 @@ export declare class Theme extends HTMLElement implements ThemeKindProvider {
24
24
  private static templateElement?;
25
25
  private static instances;
26
26
  static VERSION: string;
27
- static CORE_VERSION: string;
28
27
  static get observedAttributes(): string[];
29
28
  protected attributeChangedCallback(attrName: SettableFragmentTypes | 'lang', old: string | null, value: string | null): void;
30
29
  private requestUpdate;
package/src/Theme.dev.js CHANGED
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
- import {
3
- coreVersion,
4
- version
5
- } from "@spectrum-web-components/base/src/version.js";
2
+ import { version } from "@spectrum-web-components/base/src/version.js";
6
3
  import {
7
4
  COLOR_VALUES,
8
5
  SCALE_VALUES,
@@ -267,7 +264,6 @@ _Theme.themeFragmentsByKind = /* @__PURE__ */ new Map();
267
264
  _Theme.defaultFragments = /* @__PURE__ */ new Set(["spectrum"]);
268
265
  _Theme.instances = /* @__PURE__ */ new Set();
269
266
  _Theme.VERSION = version;
270
- _Theme.CORE_VERSION = coreVersion;
271
267
  export let Theme = _Theme;
272
268
  function checkForIssues(instance, system, color, scale, themeFragmentsByKind) {
273
269
  if (true) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["Theme.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { CSSResult, CSSResultGroup } from '@spectrum-web-components/base';\nimport {\n coreVersion,\n version,\n} from '@spectrum-web-components/base/src/version.js';\n\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/**\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 static CORE_VERSION = coreVersion;\n static get observedAttributes(): string[] {\n return ['color', 'scale', 'lang', 'system'];\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n this._provideSystemContext();\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 required.\n *\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } = (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) {\n return;\n }\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 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 required.\n *\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\n */\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) {\n return;\n }\n const color =\n !!newValue && COLOR_VALUES.includes(newValue) ? newValue : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is required.\n *\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\n */\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) {\n return;\n }\n const scale =\n !!newValue && SCALE_VALUES.includes(newValue) ? newValue : 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[] = [...Theme.themeFragmentsByKind.keys()];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles =\n kind && kind !== 'system' && this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : fragments.get(name);\n // system=\"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(kind) 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 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 private _systemContextConsumers = new Map<\n HTMLElement,\n [SystemContextCallback, () => void]\n >();\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 // 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!: (completed: 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 }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\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 _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] = this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang || document.documentElement.lang || navigator.language,\n unsubscribe\n );\n }\n }\n}\n\nfunction checkForIssues(\n instance: Theme,\n system: SystemVariant | '',\n color: Color | '',\n scale: Scale | '',\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(resolvedValue + (name === 'system' ? '' : systemModifier))\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 (['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;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,EAMA;AAAA,EAGA;AAAA,OAKK;AASA,MAAM,SAAN,MAAM,eAAc,YAAyC;AAAA,EAiMlE,cAAc;AACZ,UAAM;AA7JR,SAAQ,UAA8B;AAmCtC,SAAQ,SAAqB;AAiC7B,SAAQ,SAAqB;AA0G7B,SAAQ,0BAA0B,oBAAI,IAGpC;AAsDF,SAAQ,mBAAmB;AAqC3B,SAAQ,oBAAoB,oBAAI,IAG9B;AAjHA,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,MACH;AAAA,MACA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AI,oCAAoC,aAAa;AAAA,QAC3F;AAAA,MACF,WACE,GAAC,0BACE,IAAI,IAAI,MADV,mBAEG,IAAI,iBAAiB,SAAS,WAAW,KAAK,mBAClD;AACA,eAAO;AAAA,UACL,iBAAiB,IAAI,KAAK,aAAa;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,YAAY,SAAS,EAAE,SAAS,SAAS,EAAE,GAAG;AACjD,aAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;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;AACjB,aAAO,MAAM;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,EAAE,OAAO;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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';\n\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/**\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 static get observedAttributes(): string[] {\n return ['color', 'scale', 'lang', 'system'];\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n this._provideSystemContext();\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 required.\n *\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } = (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) {\n return;\n }\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 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 required.\n *\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\n */\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) {\n return;\n }\n const color =\n !!newValue && COLOR_VALUES.includes(newValue) ? newValue : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is required.\n *\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\n */\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) {\n return;\n }\n const scale =\n !!newValue && SCALE_VALUES.includes(newValue) ? newValue : 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[] = [...Theme.themeFragmentsByKind.keys()];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles =\n kind && kind !== 'system' && this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : fragments.get(name);\n // system=\"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(kind) 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 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 private _systemContextConsumers = new Map<\n HTMLElement,\n [SystemContextCallback, () => void]\n >();\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 // 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!: (completed: 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 }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\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 _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] = this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang || document.documentElement.lang || navigator.language,\n unsubscribe\n );\n }\n }\n}\n\nfunction checkForIssues(\n instance: Theme,\n system: SystemVariant | '',\n color: Color | '',\n scale: Scale | '',\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(resolvedValue + (name === 'system' ? '' : systemModifier))\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 (['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;AAExB;AAAA,EAEE;AAAA,EAMA;AAAA,EAGA;AAAA,OAKK;AASA,MAAM,SAAN,MAAM,eAAc,YAAyC;AAAA,EAgMlE,cAAc;AACZ,UAAM;AA7JR,SAAQ,UAA8B;AAmCtC,SAAQ,SAAqB;A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,MAAI,MAAqB;AACvB,UAAM,SAAmB,CAAC;AAC1B,UAAM,oBAAoB,CACxB,MACA,eACA,gBACS;AA5Yf;AA6YM,YAAM,iBACJ,UAAU,WAAW,aAAa,IAAI,MAAM,KAAK;AACnD,UAAI,CAAC,eAAe;AAClB,eAAO;AAAA,UACL,oCAAoC,IAAI;AAAA,QAC1C;AAAA,MACF,WAAW,CAAC,aAAa;AACvB,eAAO;AAAA,UACL,oCAAoC,IAAI,oCAAoC,aAAa;AAAA,QAC3F;AAAA,MACF,WACE,GAAC,0BACE,IAAI,IAAI,MADV,mBAEG,IAAI,iBAAiB,SAAS,WAAW,KAAK,mBAClD;AACA,eAAO;AAAA,UACL,iBAAiB,IAAI,KAAK,aAAa;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,YAAY,SAAS,EAAE,SAAS,SAAS,EAAE,GAAG;AACjD,aAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;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;AACjB,aAAO,MAAM;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,EAAE,OAAO;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/src/Theme.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";import{coreVersion as h,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._system="spectrum";this._color="";this._scale="";this._systemContextConsumers=new Map;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","system"]}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==="system"&&(this.system=s,this._provideSystemContext()))}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 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=(i,r,n)=>{const l=n&&n!=="system"&&this.system!=="spectrum"?i.get(`${r}-${this.system}`):i.get(r),m=r==="spectrum"||!n||this.hasAttribute(n);if(l&&m)return l.styles},s=e.reduce((i,r)=>{const n=o.themeFragmentsByKind.get(r);let l;if(r==="app"||r==="core")l=t(n,r);else{const{[r]:m}=this;l=t(n,m,r)}return l&&i.push(l),i},[]),a=o.themeFragmentsByKind;return this.system,this.color,this.scale,[...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[a]=this._systemContextConsumers.get(t)||[];a&&a(this.system,s)}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}connectedCallback(){this.shouldAdoptStyles(),o.instances.add(this)}disconnectedCallback(){o.instances.delete(this)}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 a=o.themeFragmentsByKind.get(t)||new Map;a.size===0&&(o.themeFragmentsByKind.set(t,a),a.set("default",{name:e,styles:s}),o.defaultFragments.add(e)),a.set(e,{name:e,styles:s}),o.instances.forEach(i=>i.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,a]=this._contextConsumers.get(t)||[];s&&a&&s(this.lang||document.documentElement.lang||navigator.language,a)}};o.themeFragmentsByKind=new Map,o.defaultFragments=new Set(["spectrum"]),o.instances=new Set,o.VERSION=d,o.CORE_VERSION=h;export let Theme=o;function k(g,c,e,t,s){}
1
+ "use strict";import{version as h}from"@spectrum-web-components/base/src/version.js";import{COLOR_VALUES as d,SCALE_VALUES as u,SYSTEM_VARIANT_VALUES as p}from"./theme-interfaces.js";const o=class o extends HTMLElement{constructor(){super();this._system="spectrum";this._color="";this._scale="";this._systemContextConsumers=new Map;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","system"]}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==="system"&&(this.system=s,this._provideSystemContext()))}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&&p.includes(e)?e:this.system;t!==this._system&&(this._system=t,this.requestUpdate()),t?this.setAttribute("system",t):this.removeAttribute("system")}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&&d.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&&u.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=(i,r,n)=>{const l=n&&n!=="system"&&this.system!=="spectrum"?i.get(`${r}-${this.system}`):i.get(r),m=r==="spectrum"||!n||this.hasAttribute(n);if(l&&m)return l.styles},s=e.reduce((i,r)=>{const n=o.themeFragmentsByKind.get(r);let l;if(r==="app"||r==="core")l=t(n,r);else{const{[r]:m}=this;l=t(n,m,r)}return l&&i.push(l),i},[]),a=o.themeFragmentsByKind;return this.system,this.color,this.scale,[...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[a]=this._systemContextConsumers.get(t)||[];a&&a(this.system,s)}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}connectedCallback(){this.shouldAdoptStyles(),o.instances.add(this)}disconnectedCallback(){o.instances.delete(this)}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 a=o.themeFragmentsByKind.get(t)||new Map;a.size===0&&(o.themeFragmentsByKind.set(t,a),a.set("default",{name:e,styles:s}),o.defaultFragments.add(e)),a.set(e,{name:e,styles:s}),o.instances.forEach(i=>i.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,a]=this._contextConsumers.get(t)||[];s&&a&&s(this.lang||document.documentElement.lang||navigator.language,a)}};o.themeFragmentsByKind=new Map,o.defaultFragments=new Set(["spectrum"]),o.instances=new Set,o.VERSION=h;export let Theme=o;function K(y,c,e,t,s){}
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": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { CSSResult, CSSResultGroup } from '@spectrum-web-components/base';\nimport {\n coreVersion,\n version,\n} from '@spectrum-web-components/base/src/version.js';\n\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/**\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 static CORE_VERSION = coreVersion;\n static get observedAttributes(): string[] {\n return ['color', 'scale', 'lang', 'system'];\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n this._provideSystemContext();\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 required.\n *\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } = (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) {\n return;\n }\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 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 required.\n *\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\n */\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) {\n return;\n }\n const color =\n !!newValue && COLOR_VALUES.includes(newValue) ? newValue : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is required.\n *\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\n */\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) {\n return;\n }\n const scale =\n !!newValue && SCALE_VALUES.includes(newValue) ? newValue : 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[] = [...Theme.themeFragmentsByKind.keys()];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles =\n kind && kind !== 'system' && this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : fragments.get(name);\n // system=\"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(kind) 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 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 private _systemContextConsumers = new Map<\n HTMLElement,\n [SystemContextCallback, () => void]\n >();\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 // 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!: (completed: 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 }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\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 _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] = this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang || document.documentElement.lang || navigator.language,\n unsubscribe\n );\n }\n }\n}\n\nfunction checkForIssues(\n instance: Theme,\n system: SystemVariant | '',\n color: Color | '',\n scale: Scale | '',\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(resolvedValue + (name === 'system' ? '' : systemModifier))\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 (['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,OACE,eAAAA,EACA,WAAAC,MACK,+CAEP,OAEE,gBAAAC,EAMA,gBAAAC,EAGA,yBAAAC,MAKK,wBASA,MAAMC,EAAN,MAAMA,UAAc,WAAyC,CAiMlE,aAAc,CACZ,MAAM,EA7JR,KAAQ,QAA8B,WAmCtC,KAAQ,OAAqB,GAiC7B,KAAQ,OAAqB,GA0G7B,KAAQ,wBAA0B,IAAI,IAyDtC,KAAQ,iBAAmB,GAqC3B,KAAQ,kBAAoB,IAAI,IA9G9B,KAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAClC,MAAMC,EAAO,SAAS,WAAWD,EAAM,SAAS,QAAS,EAAI,EAC7D,KAAK,WAAW,YAAYC,CAAI,EAChC,KAAK,kBAAkB,EACvB,KAAK,iBACH,sBACA,KAAK,sBACP,EACA,KAAK,iBACH,oBACA,KAAK,oBACP,EAEA,KAAK,eAAiB,KAAK,wBAAwB,CACrD,CA1MA,WAAW,oBAA+B,CACxC,MAAO,CAAC,QAAS,QAAS,OAAQ,QAAQ,CAC5C,CAEU,yBACRC,EACAC,EACAC,EACM,CACFD,IAAQC,IAGRF,IAAa,QACf,KAAK,MAAQE,EACJF,IAAa,QACtB,KAAK,MAAQE,EACJF,IAAa,QAAYE,GAClC,KAAK,KAAOA,EACZ,KAAK,gBAAgB,GACZF,IAAa,WACtB,KAAK,OAASE,EACd,KAAK,sBAAsB,GAE/B,CACQ,eAAsB,CAC5B,KAAK,kBAAkB,CACzB,CAaA,IAAI,QAA6B,CAC/B,MAAMC,EAAkBL,EAAM,qBAAqB,IAAI,QAAQ,EACzD,CAAE,KAAAM,C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BAAgB,EACtB,MAAMC,EAASD,EAAM,aAAa,EAAE,CAAC,EAErC,GAAI,KAAK,kBAAkB,IAAIC,CAAM,EACnC,OAEF,KAAK,kBAAkB,IAAIA,EAAQ,CACjCD,EAAM,OAAO,SACb,IAAM,KAAK,kBAAkB,OAAOC,CAAM,CAC5C,CAAC,EACD,KAAM,CAACE,EAAUD,CAAW,EAAI,KAAK,kBAAkB,IAAID,CAAM,GAAK,CAAC,EACnEE,GAAYD,GACdC,EACE,KAAK,MAAQ,SAAS,gBAAgB,MAAQ,UAAU,SACxDD,CACF,CAEJ,CACF,EAtVazB,EACI,qBAAyC,IAAI,IADjDA,EAEI,iBAAsC,IAAI,IAAI,CAAC,UAAU,CAAC,EAF9DA,EAII,UAAwB,IAAI,IAJhCA,EAKJ,QAAUJ,EALNI,EAMJ,aAAeL,EANjB,WAAM,MAANK,EAwVP,SAAS+B,EACPD,EACAtB,EACAE,EACAC,EACAW,EACM,CA+CR",
6
- "names": ["coreVersion", "version", "COLOR_VALUES", "SCALE_VALUES", "SYSTEM_VARIANT_VALUES", "_Theme", "node", "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", "styleSheets", "fragmentMap", "instance", "checkForIssues"]
4
+ "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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';\n\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/**\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 static get observedAttributes(): string[] {\n return ['color', 'scale', 'lang', 'system'];\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n this._provideSystemContext();\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 required.\n *\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } = (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) {\n return;\n }\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 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 required.\n *\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\n */\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) {\n return;\n }\n const color =\n !!newValue && COLOR_VALUES.includes(newValue) ? newValue : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is required.\n *\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\n */\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } = (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) {\n return;\n }\n const scale =\n !!newValue && SCALE_VALUES.includes(newValue) ? newValue : 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[] = [...Theme.themeFragmentsByKind.keys()];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles =\n kind && kind !== 'system' && this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : fragments.get(name);\n // system=\"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(kind) 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 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 private _systemContextConsumers = new Map<\n HTMLElement,\n [SystemContextCallback, () => void]\n >();\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 // 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!: (completed: 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 }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\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 _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] = this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang || document.documentElement.lang || navigator.language,\n unsubscribe\n );\n }\n }\n}\n\nfunction checkForIssues(\n instance: Theme,\n system: SystemVariant | '',\n color: Color | '',\n scale: Scale | '',\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(resolvedValue + (name === 'system' ? '' : systemModifier))\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 (['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: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KAAK,kBAAkB,OAAOC,CAAM,CAC5C,CAAC,EACD,KAAM,CAACE,EAAUD,CAAW,EAAI,KAAK,kBAAkB,IAAID,CAAM,GAAK,CAAC,EACnEE,GAAYD,GACdC,EACE,KAAK,MAAQ,SAAS,gBAAgB,MAAQ,UAAU,SACxDD,CACF,CAEJ,CACF,EArVazB,EACI,qBAAyC,IAAI,IADjDA,EAEI,iBAAsC,IAAI,IAAI,CAAC,UAAU,CAAC,EAF9DA,EAII,UAAwB,IAAI,IAJhCA,EAKJ,QAAUJ,EALZ,WAAM,MAANI,EAuVP,SAAS+B,EACPD,EACAtB,EACAE,EACAC,EACAW,EACM,CA+CR",
6
+ "names": ["version", "COLOR_VALUES", "SCALE_VALUES", "SYSTEM_VARIANT_VALUES", "_Theme", "node", "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", "styleSheets", "fragmentMap", "instance", "checkForIssues"]
7
7
  }