Socket
Socket
Sign inDemoInstall

@spectrum-web-components/theme

Package Overview
Dependencies
Maintainers
12
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/theme - npm Package Compare versions

Comparing version 0.48.0 to 0.48.1

8

package.json
{
"name": "@spectrum-web-components/theme",
"version": "0.48.0",
"version": "0.48.1",
"publishConfig": {

@@ -240,4 +240,4 @@ "access": "public"

"dependencies": {
"@spectrum-web-components/base": "^0.48.0",
"@spectrum-web-components/styles": "^0.48.0"
"@spectrum-web-components/base": "^0.48.1",
"@spectrum-web-components/styles": "^0.48.1"
},

@@ -269,3 +269,3 @@ "types": "./src/index.d.ts",

],
"gitHead": "55dbbf99f33ba075fc2ca4201acd9ed56cee1c46"
"gitHead": "b756ecc3587411e4dbeb825bad40a9f4a3c7a248"
}
import { CSSResultGroup } from '@spectrum-web-components/base';
import { Color, FragmentName, FragmentType, ProvideLang, Scale, SettableFragmentTypes, ShadowRootWithAdoptedStyleSheets, SystemVariant, ThemeFragmentMap, ThemeKindProvider } from './theme-interfaces';
import { Color, FragmentName, FragmentType, ProvideLang, Scale, SettableFragmentTypes, ShadowRootWithAdoptedStyleSheets, SystemVariant, ThemeFragmentMap, ThemeKindProvider } from './theme-interfaces.js';
export type { ProvideLang, ThemeFragmentMap, Color, Scale, SystemVariant };

@@ -4,0 +4,0 @@ /**

@@ -7,3 +7,3 @@ "use strict";

SYSTEM_VARIANT_VALUES
} from "./theme-interfaces";
} from "./theme-interfaces.dev.js";
const _Theme = class _Theme extends HTMLElement {

@@ -10,0 +10,0 @@ constructor() {

@@ -1,2 +0,2 @@

"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 g}from"./theme-interfaces";const r=class r extends HTMLElement{constructor(){super();this._dir="";this._system="spectrum";this._color="";this._scale="";this.trackedChildren=new Set;this._updateRequested=!1;this._contextConsumers=new Map;this.attachShadow({mode:"open"});const e=document.importNode(r.template.content,!0);this.shadowRoot.appendChild(e),this.shouldAdoptStyles(),this.addEventListener("sp-language-context",this._handleContextPresence),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,void 0):e==="system"?(this.system=s,void 0):e==="dir"&&(this.dir=s))}requestUpdate(){this.shouldAdoptStyles()}get system(){const e=r.themeFragmentsByKind.get("system"),{name:t}=e&&e.get("default")||{};return this._system||t||""}set system(e){if(e===this._system)return;const t=e&&g.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=r.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=r.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=[...r.themeFragmentsByKind.keys()],t=(n,i,a)=>{const l=a&&a!=="theme"&&a!=="system"&&this.theme!=="spectrum"&&this.system!=="spectrum"?n.get(`${i}-${this.system}`):n.get(i),m=i==="spectrum"||!a||this.hasAttribute(a);if(l&&m)return l.styles},s=e.reduce((n,i)=>{const a=r.themeFragmentsByKind.get(i);let l;if(i==="app"||i==="core")l=t(a,i);else{const{[i]:m}=this;l=t(a,m,i)}return l&&n.push(l),n},[]),o=r.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}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}connectedCallback(){if(this.shouldAdoptStyles(),r.instances.add(this),!this.hasAttribute("dir")){let e=this.assignedSlot||this.parentNode;for(;e!==document.documentElement&&!(e instanceof r);)e=e.assignedSlot||e.parentNode||e.host;this.dir=e.dir==="rtl"?e.dir:"ltr"}}disconnectedCallback(){r.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 o=r.themeFragmentsByKind.get(t)||new Map;o.size===0&&(r.themeFragmentsByKind.set(t,o),o.set("default",{name:e,styles:s}),r.defaultFragments.add(e)),o.set(e,{name:e,styles:s}),r.instances.forEach(n=>n.shouldAdoptStyles())}_provideContext(){this._contextConsumers.forEach(([e,t])=>e(this.lang,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,o]=this._contextConsumers.get(t)||[];s&&o&&s(this.lang||document.documentElement.lang||navigator.language,o)}};r.themeFragmentsByKind=new Map,r.defaultFragments=new Set(["spectrum"]),r.instances=new Set,r.VERSION=d;export let Theme=r;function V(h,c){}function B(h,c,e,t,s,o){}
"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 g}from"./theme-interfaces.js";const r=class r extends HTMLElement{constructor(){super();this._dir="";this._system="spectrum";this._color="";this._scale="";this.trackedChildren=new Set;this._updateRequested=!1;this._contextConsumers=new Map;this.attachShadow({mode:"open"});const e=document.importNode(r.template.content,!0);this.shadowRoot.appendChild(e),this.shouldAdoptStyles(),this.addEventListener("sp-language-context",this._handleContextPresence),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,void 0):e==="system"?(this.system=s,void 0):e==="dir"&&(this.dir=s))}requestUpdate(){this.shouldAdoptStyles()}get system(){const e=r.themeFragmentsByKind.get("system"),{name:t}=e&&e.get("default")||{};return this._system||t||""}set system(e){if(e===this._system)return;const t=e&&g.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=r.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=r.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=[...r.themeFragmentsByKind.keys()],t=(n,i,a)=>{const l=a&&a!=="theme"&&a!=="system"&&this.theme!=="spectrum"&&this.system!=="spectrum"?n.get(`${i}-${this.system}`):n.get(i),m=i==="spectrum"||!a||this.hasAttribute(a);if(l&&m)return l.styles},s=e.reduce((n,i)=>{const a=r.themeFragmentsByKind.get(i);let l;if(i==="app"||i==="core")l=t(a,i);else{const{[i]:m}=this;l=t(a,m,i)}return l&&n.push(l),n},[]),o=r.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}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}connectedCallback(){if(this.shouldAdoptStyles(),r.instances.add(this),!this.hasAttribute("dir")){let e=this.assignedSlot||this.parentNode;for(;e!==document.documentElement&&!(e instanceof r);)e=e.assignedSlot||e.parentNode||e.host;this.dir=e.dir==="rtl"?e.dir:"ltr"}}disconnectedCallback(){r.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 o=r.themeFragmentsByKind.get(t)||new Map;o.size===0&&(r.themeFragmentsByKind.set(t,o),o.set("default",{name:e,styles:s}),r.defaultFragments.add(e)),o.set(e,{name:e,styles:s}),r.instances.forEach(n=>n.shouldAdoptStyles())}_provideContext(){this._contextConsumers.forEach(([e,t])=>e(this.lang,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,o]=this._contextConsumers.get(t)||[];s&&o&&s(this.lang||document.documentElement.lang||navigator.language,o)}};r.themeFragmentsByKind=new Map,r.defaultFragments=new Set(["spectrum"]),r.instances=new Set,r.VERSION=d;export let Theme=r;function V(h,c){}function B(h,c,e,t,s,o){}
//# sourceMappingURL=Theme.js.map

@@ -5,3 +5,3 @@ "use strict";

import { stub } from "sinon";
import { testForLitDevWarnings } from "../../../test/testing-helpers";
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
describe("Theme", () => {

@@ -8,0 +8,0 @@ testForLitDevWarnings(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc