@dialpad/dialtone-tokens 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/doc.json CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/doc.json
3
3
  size: 104434071 bytes
4
- sha256: 0f012045c8bde85b7633d3aa46935106978ce7459ee282907157724a71360fe8
4
+ sha256: bbc3af2f2def62c68cce4e089f9a63f88e503565f647cb224c9b03da0833c07a
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./core.cjs`);var t=Object.freeze([`sandstone`,`steel`,`graphite`,`iron`,`amethyst`,`jade`]),n=new Set(t),r=!1,i=0,a=null;function o(e,t=document.documentElement,n=null){if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setBrand(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}if(e===null){d(`dialtone-css-brand`,t?.shadowRoot??t),a&&(t?.setAttribute(`data-dt-brand`,a.brand),t?.setAttribute(`data-dt-material`,a.material??`sandstone`));return}return e.base?s(e,t,n):c(e,t)}function s(e,t=document.documentElement,n=null){t?.setAttribute(`data-dt-theme`,e.base.name),t?.setAttribute(`data-dt-brand`,e.brand.name);let r=t?.shadowRoot??t;u(`dialtone-css-theme`,e.base.css,r),u(`dialtone-css-brand`,e.brand.css,r),n?(u(`dialtone-css-contrast`,n.css,r),t?.setAttribute(`data-dt-contrast`,`high`)):(d(`dialtone-css-contrast`,r),t?.setAttribute(`data-dt-contrast`,`default`))}function c(e,t=document.documentElement){let n=t?.shadowRoot??t;if(e.core&&!r&&(u(`dialtone-css-core`,e.core,n),r=!0),e.baseColors&&!n?.querySelector(`#dialtone-css-base-colors`)&&u(`dialtone-css-base-colors`,e.baseColors,n),e.brand){let r=a?.brand;r&&e.brand.name===r?(d(`dialtone-css-brand`,n),t?.setAttribute(`data-dt-brand`,r),t?.setAttribute(`data-dt-material`,a?.material??`sandstone`)):(u(`dialtone-css-brand`,e.brand.css,n),t?.setAttribute(`data-dt-brand`,e.brand.name),m(e,t))}e.contrast&&(u(`dialtone-css-contrast`,e.contrast.css,n),t?.setAttribute(`data-dt-contrast`,e.contrast.name))}function l(t,n,a=null){let o=++i;if(t){u(`dialtone-css-core`,e.core,n),r=!0;return}if(a){u(`dialtone-css-core`,a.core,n),r=!0;return}u(`dialtone-css-core`,``,n),Promise.resolve().then(()=>require(`./core-no-layers.cjs`)).then(({default:e})=>{o===i&&(u(`dialtone-css-core`,e.core,n),r=!0)}).catch(e=>{o===i&&console.error(`[Dialtone] initDialtoneTheme: failed to load no-layers core tokens.`,e)})}function u(e,t,n,r=null){if(n?.querySelector(`#`+e)){let r=n.querySelector(`#`+e);r.innerHTML=t}else{let i=document.createElement(`style`);i.setAttribute(`type`,`text/css`),i.setAttribute(`id`,e),i.innerHTML=t;let a=n?.querySelector(`head`)??n,o=r?n?.querySelector(`#`+r):null;o&&o.parentNode===a?a.insertBefore(i,o):a?.appendChild(i)}}function d(e,t){t?.querySelector(`#`+e)?.remove()}function f(e,t=document.documentElement){if(e!==`light`&&e!==`dark`){console.warn(`Invalid mode: ${e}. Must be 'light' or 'dark'`);return}if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setMode(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}t?.setAttribute(`data-dt-mode`,e)}function p(e,t=document.documentElement){if(!e||typeof e!=`object`)throw TypeError(`[Dialtone] setBaseBrand: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';`);if(!e.brand||typeof e.brand!=`object`)throw TypeError(`[Dialtone] setBaseBrand: brandTheme.brand must be an object with {name, css} properties.`);if(typeof e.brand.name!=`string`||!e.brand.name||typeof e.brand.css!=`string`)throw TypeError(`[Dialtone] setBaseBrand: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.`);if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setBaseBrand(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let n=t?.shadowRoot??t;u(`dialtone-css-brand-base`,e.brand.css,n),t?.setAttribute(`data-dt-brand`,e.brand.name),m(e,t),d(`dialtone-css-brand`,n),a&&(a.brand=e.brand.name,a.material=v(e)??`sandstone`)}function m(e,t){let r=e.material?.name;if(r){if(n.has(r)){t?.setAttribute(`data-dt-material`,r);return}console.warn(`[Dialtone] setBaseBrand: brand '${e.brand.name}' declares unknown material '${r}'; falling back to sandstone.`),t?.setAttribute(`data-dt-material`,`sandstone`)}}function h(e,t=document.documentElement){if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setContrast(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let n=t?.shadowRoot??t;e&&e.contrast?(u(`dialtone-css-contrast`,e.contrast.css,n),t?.setAttribute(`data-dt-contrast`,e.contrast.name)):(d(`dialtone-css-contrast`,n),t?.setAttribute(`data-dt-contrast`,`default`))}function g(e,t=document.documentElement){if(e!=null&&typeof e!=`string`)throw TypeError(`[Dialtone] setMaterial: expected a string material name or null.`);if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setMaterial(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let r=e||`sandstone`;if(!n.has(r)){console.warn(`[Dialtone] setMaterial: unknown material '${e}'; falling back to sandstone.`),t?.setAttribute(`data-dt-material`,`sandstone`);return}t?.setAttribute(`data-dt-material`,r)}function _(t,n=`light`,r=document.documentElement,i={}){let{layers:o=!0,core:s=null}=i;if(!t||typeof t!=`object`)throw TypeError(`[Dialtone] initDialtoneTheme: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';`);if(!t.brand||typeof t.brand!=`object`)throw TypeError(`[Dialtone] initDialtoneTheme: brandTheme.brand must be an object with {name, css} properties. Ensure you're importing a valid brand theme.`);if(typeof t.brand.name!=`string`||!t.brand.name||typeof t.brand.css!=`string`)throw TypeError(`[Dialtone] initDialtoneTheme: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.`);if(n!==`light`&&n!==`dark`)throw TypeError(`[Dialtone] initDialtoneTheme: mode must be 'light' or 'dark', got '${n}'.`);if(!r||typeof r!=`object`)throw TypeError(`[Dialtone] initDialtoneTheme: rootNode must be an HTMLElement or host element with shadowRoot.`);if(r instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to initDialtoneTheme(). Please pass the host element instead. The function will access shadowRoot automatically.
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./materials.cjs`),t=require(`./core.cjs`);var n=Object.freeze([`sandstone`,`steel`,`graphite`,`iron`,`amethyst`,`jade`]),r=new Set(n),i=!1,a=0,o=null;function s(e,t=document.documentElement,n=null){if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setBrand(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}if(e===null){f(`dialtone-css-brand`,t?.shadowRoot??t),o&&(t?.setAttribute(`data-dt-brand`,o.brand),g(o.material??`sandstone`,t));return}return e.base?c(e,t,n):l(e,t)}function c(e,t=document.documentElement,n=null){t?.setAttribute(`data-dt-theme`,e.base.name),t?.setAttribute(`data-dt-brand`,e.brand.name);let r=t?.shadowRoot??t;d(`dialtone-css-theme`,e.base.css,r),d(`dialtone-css-brand`,e.brand.css,r),n?(d(`dialtone-css-contrast`,n.css,r),t?.setAttribute(`data-dt-contrast`,`high`)):(f(`dialtone-css-contrast`,r),t?.setAttribute(`data-dt-contrast`,`default`))}function l(e,t=document.documentElement){let n=t?.shadowRoot??t;if(e.core&&!i&&(d(`dialtone-css-core`,e.core,n),i=!0),e.baseColors&&!n?.querySelector(`#dialtone-css-base-colors`)&&d(`dialtone-css-base-colors`,e.baseColors,n),e.brand){let r=o?.brand;r&&e.brand.name===r?(f(`dialtone-css-brand`,n),t?.setAttribute(`data-dt-brand`,r),g(o?.material??`sandstone`,t)):(d(`dialtone-css-brand`,e.brand.css,n),t?.setAttribute(`data-dt-brand`,e.brand.name),h(e,t))}e.contrast&&(d(`dialtone-css-contrast`,e.contrast.css,n),t?.setAttribute(`data-dt-contrast`,e.contrast.name))}function u(e,n,r=null){let o=++a;if(e){d(`dialtone-css-core`,t.core,n),i=!0;return}if(r){d(`dialtone-css-core`,r.core,n),i=!0;return}d(`dialtone-css-core`,``,n),Promise.resolve().then(()=>require(`./core-no-layers.cjs`)).then(({default:e})=>{o===a&&(d(`dialtone-css-core`,e.core,n),i=!0)}).catch(e=>{o===a&&console.error(`[Dialtone] initDialtoneTheme: failed to load no-layers core tokens.`,e)})}function d(e,t,n,r=null){if(n?.querySelector(`#`+e)){let r=n.querySelector(`#`+e);r.innerHTML=t}else{let i=document.createElement(`style`);i.setAttribute(`type`,`text/css`),i.setAttribute(`id`,e),i.innerHTML=t;let a=n?.querySelector(`head`)??n,o=r?n?.querySelector(`#`+r):null;o&&o.parentNode===a?a.insertBefore(i,o):a?.appendChild(i)}}function f(e,t){t?.querySelector(`#`+e)?.remove()}function p(e,t=document.documentElement){if(e!==`light`&&e!==`dark`){console.warn(`Invalid mode: ${e}. Must be 'light' or 'dark'`);return}if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setMode(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}t?.setAttribute(`data-dt-mode`,e)}function m(e,t=document.documentElement){if(!e||typeof e!=`object`)throw TypeError(`[Dialtone] setBaseBrand: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';`);if(!e.brand||typeof e.brand!=`object`)throw TypeError(`[Dialtone] setBaseBrand: brandTheme.brand must be an object with {name, css} properties.`);if(typeof e.brand.name!=`string`||!e.brand.name||typeof e.brand.css!=`string`)throw TypeError(`[Dialtone] setBaseBrand: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.`);if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setBaseBrand(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let n=t?.shadowRoot??t;d(`dialtone-css-brand-base`,e.brand.css,n),t?.setAttribute(`data-dt-brand`,e.brand.name),h(e,t),f(`dialtone-css-brand`,n),o&&(o.brand=e.brand.name,o.material=b(e)??`sandstone`)}function h(e,t){let n=e.material?.name;if(n){if(r.has(n)){g(n,t);return}console.warn(`[Dialtone] setBaseBrand: brand '${e.brand.name}' declares unknown material '${n}'; falling back to sandstone.`),g(`sandstone`,t)}}function g(t,n){let r=n?.shadowRoot??n,i=e[t];i?d(`dialtone-css-material`,i.css,r):f(`dialtone-css-material`,r),n?.setAttribute(`data-dt-material`,t)}function _(e,t=document.documentElement){if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setContrast(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let n=t?.shadowRoot??t;e&&e.contrast?(d(`dialtone-css-contrast`,e.contrast.css,n),t?.setAttribute(`data-dt-contrast`,e.contrast.name)):(f(`dialtone-css-contrast`,n),t?.setAttribute(`data-dt-contrast`,`default`))}function v(e,t=document.documentElement){if(e!=null&&typeof e!=`string`)throw TypeError(`[Dialtone] setMaterial: expected a string material name or null.`);if(t instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to setMaterial(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let n=e||`sandstone`;if(!r.has(n)){console.warn(`[Dialtone] setMaterial: unknown material '${e}'; falling back to sandstone.`),g(`sandstone`,t);return}g(n,t)}function y(e,n=`light`,r=document.documentElement,i={}){let{layers:a=!0,core:s=null}=i;if(!e||typeof e!=`object`)throw TypeError(`[Dialtone] initDialtoneTheme: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';`);if(!e.brand||typeof e.brand!=`object`)throw TypeError(`[Dialtone] initDialtoneTheme: brandTheme.brand must be an object with {name, css} properties. Ensure you're importing a valid brand theme.`);if(typeof e.brand.name!=`string`||!e.brand.name||typeof e.brand.css!=`string`)throw TypeError(`[Dialtone] initDialtoneTheme: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.`);if(n!==`light`&&n!==`dark`)throw TypeError(`[Dialtone] initDialtoneTheme: mode must be 'light' or 'dark', got '${n}'.`);if(!r||typeof r!=`object`)throw TypeError(`[Dialtone] initDialtoneTheme: rootNode must be an HTMLElement or host element with shadowRoot.`);if(r instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to initDialtoneTheme(). Please pass the host element instead. The function will access shadowRoot automatically.
2
2
  Correct: initDialtoneTheme(brand, mode, hostElement)
3
- Incorrect: initDialtoneTheme(brand, mode, hostElement.shadowRoot)`);return}let c=r?.shadowRoot??r;if(r===document.documentElement&&document.querySelector(`#dialtone-css-core`)!==null)throw Error(`[Dialtone] Cannot initialize theme on document.documentElement because theme styles already exist. You are likely in an embedded app/micro-frontend. You MUST pass your own container element as the rootNode parameter. Example: initDialtoneTheme(brandTheme, mode, myAppContainerElement)`);let d=a;if(d)if(d.brand===t.brand.name&&d.mode===n){if(d.layers===o){console.warn(`[Dialtone] Theme already initialized with brand '${t.brand.name}' and mode '${n}'. Re-applying the same theme may be unnecessary. If you need to switch themes dynamically, use setBaseBrand() or setMode() instead of calling initDialtoneTheme() again.`);return}console.warn(`[Dialtone] Theme already initialized with brand '${t.brand.name}' and mode '${n}' using layers=${d.layers}. Reloading core tokens with layers=${o}.`),l(o,c,s),a.layers=o;return}else{console.warn(`[Dialtone] Theme already initialized. Previous: brand='${d.brand}', mode='${d.mode}'. New: brand='${t.brand.name}', mode='${n}'. Re-initializing with different parameters. Consider using setBaseBrand()/setMode() for dynamic switching.`);return}l(o,c,s),u(`dialtone-css-base-colors`,e.baseColors,c),f(n,r),r?.setAttribute(`data-dt-contrast`,`default`),r?.setAttribute(`data-dt-material`,`sandstone`),p(t,r),a={brand:t.brand.name,mode:n,contrast:`default`,material:v(t)??`sandstone`,layers:o}}function v(e){return e?.material?.name??null}var y=e=>v(e)!==null,b=o,x=S;function S(e=document.documentElement){if(e instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to resetBrand(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let t=e?.shadowRoot??e;a=null,r=!1,i++,d(`dialtone-css-core`,t),d(`dialtone-css-base-colors`,t),d(`dialtone-css-material`,t),d(`dialtone-css-brand-base`,t),d(`dialtone-css-brand`,t),d(`dialtone-css-contrast`,t),e?.removeAttribute(`data-dt-mode`),e?.removeAttribute(`data-dt-brand`),e?.removeAttribute(`data-dt-contrast`),e?.removeAttribute(`data-dt-material`)}exports.VALID_MATERIALS=t,exports.getBrandMaterial=v,exports.hasBrandMaterialLock=y,exports.initDialtoneTheme=_,exports.resetBrand=S,exports.resetTheme=x,exports.setBaseBrand=p,exports.setBrand=o,exports.setContrast=h,exports.setMaterial=g,exports.setMode=f,exports.setTheme=b;
3
+ Incorrect: initDialtoneTheme(brand, mode, hostElement.shadowRoot)`);return}let c=r?.shadowRoot??r;if(r===document.documentElement&&document.querySelector(`#dialtone-css-core`)!==null)throw Error(`[Dialtone] Cannot initialize theme on document.documentElement because theme styles already exist. You are likely in an embedded app/micro-frontend. You MUST pass your own container element as the rootNode parameter. Example: initDialtoneTheme(brandTheme, mode, myAppContainerElement)`);let l=o;if(l)if(l.brand===e.brand.name&&l.mode===n){if(l.layers===a){console.warn(`[Dialtone] Theme already initialized with brand '${e.brand.name}' and mode '${n}'. Re-applying the same theme may be unnecessary. If you need to switch themes dynamically, use setBaseBrand() or setMode() instead of calling initDialtoneTheme() again.`);return}console.warn(`[Dialtone] Theme already initialized with brand '${e.brand.name}' and mode '${n}' using layers=${l.layers}. Reloading core tokens with layers=${a}.`),u(a,c,s),o.layers=a;return}else{console.warn(`[Dialtone] Theme already initialized. Previous: brand='${l.brand}', mode='${l.mode}'. New: brand='${e.brand.name}', mode='${n}'. Re-initializing with different parameters. Consider using setBaseBrand()/setMode() for dynamic switching.`);return}u(a,c,s),d(`dialtone-css-base-colors`,t.baseColors,c),p(n,r),r?.setAttribute(`data-dt-contrast`,`default`),r?.setAttribute(`data-dt-material`,`sandstone`),m(e,r),o={brand:e.brand.name,mode:n,contrast:`default`,material:b(e)??`sandstone`,layers:a}}function b(e){return e?.material?.name??null}var x=e=>b(e)!==null,S=s,C=w;function w(e=document.documentElement){if(e instanceof ShadowRoot){console.warn(`[Dialtone] You passed a ShadowRoot directly to resetBrand(). Please pass the host element instead. The function will access shadowRoot automatically.`);return}let t=e?.shadowRoot??e;o=null,i=!1,a++,f(`dialtone-css-core`,t),f(`dialtone-css-base-colors`,t),f(`dialtone-css-material`,t),f(`dialtone-css-brand-base`,t),f(`dialtone-css-brand`,t),f(`dialtone-css-contrast`,t),e?.removeAttribute(`data-dt-mode`),e?.removeAttribute(`data-dt-brand`),e?.removeAttribute(`data-dt-contrast`),e?.removeAttribute(`data-dt-material`)}exports.VALID_MATERIALS=n,exports.getBrandMaterial=b,exports.hasBrandMaterialLock=x,exports.initDialtoneTheme=y,exports.resetBrand=w,exports.resetTheme=C,exports.setBaseBrand=m,exports.setBrand=s,exports.setContrast=_,exports.setMaterial=v,exports.setMode=p,exports.setTheme=S;
@@ -1,54 +1,55 @@
1
- import e from "./core.js";
1
+ import e from "./materials.js";
2
+ import t from "./core.js";
2
3
  //#region themes/config.js
3
- var t = Object.freeze([
4
+ var n = Object.freeze([
4
5
  "sandstone",
5
6
  "steel",
6
7
  "graphite",
7
8
  "iron",
8
9
  "amethyst",
9
10
  "jade"
10
- ]), n = new Set(t), r = !1, i = 0, a = null;
11
- function o(e, t = document.documentElement, n = null) {
11
+ ]), r = new Set(n), i = !1, a = 0, o = null;
12
+ function s(e, t = document.documentElement, n = null) {
12
13
  if (t instanceof ShadowRoot) {
13
14
  console.warn("[Dialtone] You passed a ShadowRoot directly to setBrand(). Please pass the host element instead. The function will access shadowRoot automatically.");
14
15
  return;
15
16
  }
16
17
  if (e === null) {
17
- d("dialtone-css-brand", t?.shadowRoot ?? t), a && (t?.setAttribute("data-dt-brand", a.brand), t?.setAttribute("data-dt-material", a.material ?? "sandstone"));
18
+ f("dialtone-css-brand", t?.shadowRoot ?? t), o && (t?.setAttribute("data-dt-brand", o.brand), g(o.material ?? "sandstone", t));
18
19
  return;
19
20
  }
20
- return e.base ? s(e, t, n) : c(e, t);
21
+ return e.base ? c(e, t, n) : l(e, t);
21
22
  }
22
- function s(e, t = document.documentElement, n = null) {
23
+ function c(e, t = document.documentElement, n = null) {
23
24
  t?.setAttribute("data-dt-theme", e.base.name), t?.setAttribute("data-dt-brand", e.brand.name);
24
25
  let r = t?.shadowRoot ?? t;
25
- u("dialtone-css-theme", e.base.css, r), u("dialtone-css-brand", e.brand.css, r), n ? (u("dialtone-css-contrast", n.css, r), t?.setAttribute("data-dt-contrast", "high")) : (d("dialtone-css-contrast", r), t?.setAttribute("data-dt-contrast", "default"));
26
+ d("dialtone-css-theme", e.base.css, r), d("dialtone-css-brand", e.brand.css, r), n ? (d("dialtone-css-contrast", n.css, r), t?.setAttribute("data-dt-contrast", "high")) : (f("dialtone-css-contrast", r), t?.setAttribute("data-dt-contrast", "default"));
26
27
  }
27
- function c(e, t = document.documentElement) {
28
+ function l(e, t = document.documentElement) {
28
29
  let n = t?.shadowRoot ?? t;
29
- if (e.core && !r && (u("dialtone-css-core", e.core, n), r = !0), e.baseColors && !n?.querySelector("#dialtone-css-base-colors") && u("dialtone-css-base-colors", e.baseColors, n), e.brand) {
30
- let r = a?.brand;
31
- r && e.brand.name === r ? (d("dialtone-css-brand", n), t?.setAttribute("data-dt-brand", r), t?.setAttribute("data-dt-material", a?.material ?? "sandstone")) : (u("dialtone-css-brand", e.brand.css, n), t?.setAttribute("data-dt-brand", e.brand.name), m(e, t));
30
+ if (e.core && !i && (d("dialtone-css-core", e.core, n), i = !0), e.baseColors && !n?.querySelector("#dialtone-css-base-colors") && d("dialtone-css-base-colors", e.baseColors, n), e.brand) {
31
+ let r = o?.brand;
32
+ r && e.brand.name === r ? (f("dialtone-css-brand", n), t?.setAttribute("data-dt-brand", r), g(o?.material ?? "sandstone", t)) : (d("dialtone-css-brand", e.brand.css, n), t?.setAttribute("data-dt-brand", e.brand.name), h(e, t));
32
33
  }
33
- e.contrast && (u("dialtone-css-contrast", e.contrast.css, n), t?.setAttribute("data-dt-contrast", e.contrast.name));
34
+ e.contrast && (d("dialtone-css-contrast", e.contrast.css, n), t?.setAttribute("data-dt-contrast", e.contrast.name));
34
35
  }
35
- function l(t, n, a = null) {
36
- let o = ++i;
37
- if (t) {
38
- u("dialtone-css-core", e.core, n), r = !0;
36
+ function u(e, n, r = null) {
37
+ let o = ++a;
38
+ if (e) {
39
+ d("dialtone-css-core", t.core, n), i = !0;
39
40
  return;
40
41
  }
41
- if (a) {
42
- u("dialtone-css-core", a.core, n), r = !0;
42
+ if (r) {
43
+ d("dialtone-css-core", r.core, n), i = !0;
43
44
  return;
44
45
  }
45
- u("dialtone-css-core", "", n), import("./core-no-layers.js").then(({ default: e }) => {
46
- o === i && (u("dialtone-css-core", e.core, n), r = !0);
46
+ d("dialtone-css-core", "", n), import("./core-no-layers.js").then(({ default: e }) => {
47
+ o === a && (d("dialtone-css-core", e.core, n), i = !0);
47
48
  }).catch((e) => {
48
- o === i && console.error("[Dialtone] initDialtoneTheme: failed to load no-layers core tokens.", e);
49
+ o === a && console.error("[Dialtone] initDialtoneTheme: failed to load no-layers core tokens.", e);
49
50
  });
50
51
  }
51
- function u(e, t, n, r = null) {
52
+ function d(e, t, n, r = null) {
52
53
  if (n?.querySelector("#" + e)) {
53
54
  let r = n.querySelector("#" + e);
54
55
  r.innerHTML = t;
@@ -59,10 +60,10 @@ function u(e, t, n, r = null) {
59
60
  o && o.parentNode === a ? a.insertBefore(i, o) : a?.appendChild(i);
60
61
  }
61
62
  }
62
- function d(e, t) {
63
+ function f(e, t) {
63
64
  t?.querySelector("#" + e)?.remove();
64
65
  }
65
- function f(e, t = document.documentElement) {
66
+ function p(e, t = document.documentElement) {
66
67
  if (e !== "light" && e !== "dark") {
67
68
  console.warn(`Invalid mode: ${e}. Must be 'light' or 'dark'`);
68
69
  return;
@@ -73,7 +74,7 @@ function f(e, t = document.documentElement) {
73
74
  }
74
75
  t?.setAttribute("data-dt-mode", e);
75
76
  }
76
- function p(e, t = document.documentElement) {
77
+ function m(e, t = document.documentElement) {
77
78
  if (!e || typeof e != "object") throw TypeError("[Dialtone] setBaseBrand: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';");
78
79
  if (!e.brand || typeof e.brand != "object") throw TypeError("[Dialtone] setBaseBrand: brandTheme.brand must be an object with {name, css} properties.");
79
80
  if (typeof e.brand.name != "string" || !e.brand.name || typeof e.brand.css != "string") throw TypeError("[Dialtone] setBaseBrand: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.");
@@ -82,44 +83,48 @@ function p(e, t = document.documentElement) {
82
83
  return;
83
84
  }
84
85
  let n = t?.shadowRoot ?? t;
85
- u("dialtone-css-brand-base", e.brand.css, n), t?.setAttribute("data-dt-brand", e.brand.name), m(e, t), d("dialtone-css-brand", n), a && (a.brand = e.brand.name, a.material = v(e) ?? "sandstone");
86
+ d("dialtone-css-brand-base", e.brand.css, n), t?.setAttribute("data-dt-brand", e.brand.name), h(e, t), f("dialtone-css-brand", n), o && (o.brand = e.brand.name, o.material = b(e) ?? "sandstone");
86
87
  }
87
- function m(e, t) {
88
- let r = e.material?.name;
89
- if (r) {
90
- if (n.has(r)) {
91
- t?.setAttribute("data-dt-material", r);
88
+ function h(e, t) {
89
+ let n = e.material?.name;
90
+ if (n) {
91
+ if (r.has(n)) {
92
+ g(n, t);
92
93
  return;
93
94
  }
94
- console.warn(`[Dialtone] setBaseBrand: brand '${e.brand.name}' declares unknown material '${r}'; falling back to sandstone.`), t?.setAttribute("data-dt-material", "sandstone");
95
+ console.warn(`[Dialtone] setBaseBrand: brand '${e.brand.name}' declares unknown material '${n}'; falling back to sandstone.`), g("sandstone", t);
95
96
  }
96
97
  }
97
- function h(e, t = document.documentElement) {
98
+ function g(t, n) {
99
+ let r = n?.shadowRoot ?? n, i = e[t];
100
+ i ? d("dialtone-css-material", i.css, r) : f("dialtone-css-material", r), n?.setAttribute("data-dt-material", t);
101
+ }
102
+ function _(e, t = document.documentElement) {
98
103
  if (t instanceof ShadowRoot) {
99
104
  console.warn("[Dialtone] You passed a ShadowRoot directly to setContrast(). Please pass the host element instead. The function will access shadowRoot automatically.");
100
105
  return;
101
106
  }
102
107
  let n = t?.shadowRoot ?? t;
103
- e && e.contrast ? (u("dialtone-css-contrast", e.contrast.css, n), t?.setAttribute("data-dt-contrast", e.contrast.name)) : (d("dialtone-css-contrast", n), t?.setAttribute("data-dt-contrast", "default"));
108
+ e && e.contrast ? (d("dialtone-css-contrast", e.contrast.css, n), t?.setAttribute("data-dt-contrast", e.contrast.name)) : (f("dialtone-css-contrast", n), t?.setAttribute("data-dt-contrast", "default"));
104
109
  }
105
- function g(e, t = document.documentElement) {
110
+ function v(e, t = document.documentElement) {
106
111
  if (e != null && typeof e != "string") throw TypeError("[Dialtone] setMaterial: expected a string material name or null.");
107
112
  if (t instanceof ShadowRoot) {
108
113
  console.warn("[Dialtone] You passed a ShadowRoot directly to setMaterial(). Please pass the host element instead. The function will access shadowRoot automatically.");
109
114
  return;
110
115
  }
111
- let r = e || "sandstone";
112
- if (!n.has(r)) {
113
- console.warn(`[Dialtone] setMaterial: unknown material '${e}'; falling back to sandstone.`), t?.setAttribute("data-dt-material", "sandstone");
116
+ let n = e || "sandstone";
117
+ if (!r.has(n)) {
118
+ console.warn(`[Dialtone] setMaterial: unknown material '${e}'; falling back to sandstone.`), g("sandstone", t);
114
119
  return;
115
120
  }
116
- t?.setAttribute("data-dt-material", r);
121
+ g(n, t);
117
122
  }
118
- function _(t, n = "light", r = document.documentElement, i = {}) {
119
- let { layers: o = !0, core: s = null } = i;
120
- if (!t || typeof t != "object") throw TypeError("[Dialtone] initDialtoneTheme: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';");
121
- if (!t.brand || typeof t.brand != "object") throw TypeError("[Dialtone] initDialtoneTheme: brandTheme.brand must be an object with {name, css} properties. Ensure you're importing a valid brand theme.");
122
- if (typeof t.brand.name != "string" || !t.brand.name || typeof t.brand.css != "string") throw TypeError("[Dialtone] initDialtoneTheme: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.");
123
+ function y(e, n = "light", r = document.documentElement, i = {}) {
124
+ let { layers: a = !0, core: s = null } = i;
125
+ if (!e || typeof e != "object") throw TypeError("[Dialtone] initDialtoneTheme: brandTheme must be an object. Import a brand theme like: import Dp from '@dialpad/dialtone-tokens/themes/dp';");
126
+ if (!e.brand || typeof e.brand != "object") throw TypeError("[Dialtone] initDialtoneTheme: brandTheme.brand must be an object with {name, css} properties. Ensure you're importing a valid brand theme.");
127
+ if (typeof e.brand.name != "string" || !e.brand.name || typeof e.brand.css != "string") throw TypeError("[Dialtone] initDialtoneTheme: brandTheme.brand.name must be a non-empty string and brandTheme.brand.css must be a string.");
123
128
  if (n !== "light" && n !== "dark") throw TypeError(`[Dialtone] initDialtoneTheme: mode must be 'light' or 'dark', got '${n}'.`);
124
129
  if (!r || typeof r != "object") throw TypeError("[Dialtone] initDialtoneTheme: rootNode must be an HTMLElement or host element with shadowRoot.");
125
130
  if (r instanceof ShadowRoot) {
@@ -128,37 +133,37 @@ function _(t, n = "light", r = document.documentElement, i = {}) {
128
133
  }
129
134
  let c = r?.shadowRoot ?? r;
130
135
  if (r === document.documentElement && document.querySelector("#dialtone-css-core") !== null) throw Error("[Dialtone] Cannot initialize theme on document.documentElement because theme styles already exist. You are likely in an embedded app/micro-frontend. You MUST pass your own container element as the rootNode parameter. Example: initDialtoneTheme(brandTheme, mode, myAppContainerElement)");
131
- let d = a;
132
- if (d) if (d.brand === t.brand.name && d.mode === n) {
133
- if (d.layers === o) {
134
- console.warn(`[Dialtone] Theme already initialized with brand '${t.brand.name}' and mode '${n}'. Re-applying the same theme may be unnecessary. If you need to switch themes dynamically, use setBaseBrand() or setMode() instead of calling initDialtoneTheme() again.`);
136
+ let l = o;
137
+ if (l) if (l.brand === e.brand.name && l.mode === n) {
138
+ if (l.layers === a) {
139
+ console.warn(`[Dialtone] Theme already initialized with brand '${e.brand.name}' and mode '${n}'. Re-applying the same theme may be unnecessary. If you need to switch themes dynamically, use setBaseBrand() or setMode() instead of calling initDialtoneTheme() again.`);
135
140
  return;
136
141
  }
137
- console.warn(`[Dialtone] Theme already initialized with brand '${t.brand.name}' and mode '${n}' using layers=${d.layers}. Reloading core tokens with layers=${o}.`), l(o, c, s), a.layers = o;
142
+ console.warn(`[Dialtone] Theme already initialized with brand '${e.brand.name}' and mode '${n}' using layers=${l.layers}. Reloading core tokens with layers=${a}.`), u(a, c, s), o.layers = a;
138
143
  return;
139
144
  } else {
140
- console.warn(`[Dialtone] Theme already initialized. Previous: brand='${d.brand}', mode='${d.mode}'. New: brand='${t.brand.name}', mode='${n}'. Re-initializing with different parameters. Consider using setBaseBrand()/setMode() for dynamic switching.`);
145
+ console.warn(`[Dialtone] Theme already initialized. Previous: brand='${l.brand}', mode='${l.mode}'. New: brand='${e.brand.name}', mode='${n}'. Re-initializing with different parameters. Consider using setBaseBrand()/setMode() for dynamic switching.`);
141
146
  return;
142
147
  }
143
- l(o, c, s), u("dialtone-css-base-colors", e.baseColors, c), f(n, r), r?.setAttribute("data-dt-contrast", "default"), r?.setAttribute("data-dt-material", "sandstone"), p(t, r), a = {
144
- brand: t.brand.name,
148
+ u(a, c, s), d("dialtone-css-base-colors", t.baseColors, c), p(n, r), r?.setAttribute("data-dt-contrast", "default"), r?.setAttribute("data-dt-material", "sandstone"), m(e, r), o = {
149
+ brand: e.brand.name,
145
150
  mode: n,
146
151
  contrast: "default",
147
- material: v(t) ?? "sandstone",
148
- layers: o
152
+ material: b(e) ?? "sandstone",
153
+ layers: a
149
154
  };
150
155
  }
151
- function v(e) {
156
+ function b(e) {
152
157
  return e?.material?.name ?? null;
153
158
  }
154
- var y = (e) => v(e) !== null, b = o, x = S;
155
- function S(e = document.documentElement) {
159
+ var x = (e) => b(e) !== null, S = s, C = w;
160
+ function w(e = document.documentElement) {
156
161
  if (e instanceof ShadowRoot) {
157
162
  console.warn("[Dialtone] You passed a ShadowRoot directly to resetBrand(). Please pass the host element instead. The function will access shadowRoot automatically.");
158
163
  return;
159
164
  }
160
165
  let t = e?.shadowRoot ?? e;
161
- a = null, r = !1, i++, d("dialtone-css-core", t), d("dialtone-css-base-colors", t), d("dialtone-css-material", t), d("dialtone-css-brand-base", t), d("dialtone-css-brand", t), d("dialtone-css-contrast", t), e?.removeAttribute("data-dt-mode"), e?.removeAttribute("data-dt-brand"), e?.removeAttribute("data-dt-contrast"), e?.removeAttribute("data-dt-material");
166
+ o = null, i = !1, a++, f("dialtone-css-core", t), f("dialtone-css-base-colors", t), f("dialtone-css-material", t), f("dialtone-css-brand-base", t), f("dialtone-css-brand", t), f("dialtone-css-contrast", t), e?.removeAttribute("data-dt-mode"), e?.removeAttribute("data-dt-brand"), e?.removeAttribute("data-dt-contrast"), e?.removeAttribute("data-dt-material");
162
167
  }
163
168
  //#endregion
164
- export { t as VALID_MATERIALS, v as getBrandMaterial, y as hasBrandMaterialLock, _ as initDialtoneTheme, S as resetBrand, x as resetTheme, p as setBaseBrand, o as setBrand, h as setContrast, g as setMaterial, f as setMode, b as setTheme };
169
+ export { n as VALID_MATERIALS, b as getBrandMaterial, x as hasBrandMaterialLock, y as initDialtoneTheme, w as resetBrand, C as resetTheme, m as setBaseBrand, s as setBrand, _ as setContrast, v as setMaterial, p as setMode, S as setTheme };
@@ -0,0 +1 @@
1
+ const e=require(`./chunks/chunk-qndmjIgv.js`);let t=require(`@dialpad/dialtone-tokens/layered/material/tokens-amethyst.css?inline`);t=e.t(t);let n=require(`@dialpad/dialtone-tokens/layered/material/tokens-graphite.css?inline`);n=e.t(n);let r=require(`@dialpad/dialtone-tokens/layered/material/tokens-iron.css?inline`);r=e.t(r);let i=require(`@dialpad/dialtone-tokens/layered/material/tokens-jade.css?inline`);i=e.t(i);let a=require(`@dialpad/dialtone-tokens/layered/material/tokens-steel.css?inline`);a=e.t(a);var o={amethyst:{name:`amethyst`,css:t.default},graphite:{name:`graphite`,css:n.default},iron:{name:`iron`,css:r.default},jade:{name:`jade`,css:i.default},steel:{name:`steel`,css:a.default}};module.exports=o;
@@ -0,0 +1,30 @@
1
+ import e from "@dialpad/dialtone-tokens/layered/material/tokens-amethyst.css?inline";
2
+ import t from "@dialpad/dialtone-tokens/layered/material/tokens-graphite.css?inline";
3
+ import n from "@dialpad/dialtone-tokens/layered/material/tokens-iron.css?inline";
4
+ import r from "@dialpad/dialtone-tokens/layered/material/tokens-jade.css?inline";
5
+ import i from "@dialpad/dialtone-tokens/layered/material/tokens-steel.css?inline";
6
+ //#region themes/materials.js
7
+ var a = {
8
+ amethyst: {
9
+ name: "amethyst",
10
+ css: e
11
+ },
12
+ graphite: {
13
+ name: "graphite",
14
+ css: t
15
+ },
16
+ iron: {
17
+ name: "iron",
18
+ css: n
19
+ },
20
+ jade: {
21
+ name: "jade",
22
+ css: r
23
+ },
24
+ steel: {
25
+ name: "steel",
26
+ css: i
27
+ }
28
+ };
29
+ //#endregion
30
+ export { a as default };
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../themes/config.js"],"names":[],"mappings":"AA4GA,gCAzBW,MAAM,GAAC,IAAI,aACX,aAAa,kBACb,MAAM,GAAC,IAAI,QAmDrB;AAkLD,8BAhBW,IAAI,aACJ,aAAa,QA+BvB;AAyBD,yCAjBW,UAAU,aACV,aAAa,QA6DvB;AAiDD,2CArBW,aAAa,GAAC,IAAI,aAClB,aAAa,QAsCvB;AAqBD,kCAPW,YAAY,GAAC,IAAI,aACjB,aAAa,QA+BvB;AAkED,8CAxDW,UAAU,SACV,IAAI,aACJ,aAAa,YAErB;IAA0B,MAAM;IASJ,IAAI;CAGhC,QAmKF;AAMD,6CAHW,UAAU,GACR,MAAM,GAAC,IAAI,CAIvB;AAuCD,yDAiCC;AAjwBD,gDAA6G;AA+rBtG,iDAHI,UAAU,GACR,OAAO,CAEqE;AAhmBzF,gCAzBW,MAAM,GAAC,IAAI,aACX,aAAa,kBACb,MAAM,GAAC,IAAI,QAmDrB;AAqmBD,yDAiCC;mBA7uBY,OAAO,GAAC,MAAM;4BAKd,WAAW,GAAC,UAAU;;UAOrB,MAAM;gBACN,MAAM;;;WAOjB;QAAyB,IAAI,EAAlB,MAAM;QACQ,GAAG,EAAjB,MAAM;KACjB;;;;;;cAQA;QAA4B,IAAI,EAArB,MAAM;QACW,GAAG,EAApB,MAAM;KACnB;;2BAGY,WAAW,GAAC,OAAO,GAAC,UAAU,GAAC,MAAM,GAAC,UAAU,GAAC,MAAM"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../themes/config.js"],"names":[],"mappings":"AAgHA,gCAzBW,MAAM,GAAC,IAAI,aACX,aAAa,kBACb,MAAM,GAAC,IAAI,QAmDrB;AAkLD,8BAhBW,IAAI,aACJ,aAAa,QA+BvB;AAyBD,yCAjBW,UAAU,aACV,aAAa,QA6DvB;AAmED,2CArBW,aAAa,GAAC,IAAI,aAClB,aAAa,QAsCvB;AAyBD,kCAPW,YAAY,GAAC,IAAI,aACjB,aAAa,QA+BvB;AAkED,8CAxDW,UAAU,SACV,IAAI,aACJ,aAAa,YAErB;IAA0B,MAAM;IASJ,IAAI;CAGhC,QAmKF;AAMD,6CAHW,UAAU,GACR,MAAM,GAAC,IAAI,CAIvB;AAuCD,yDAgCC;AAtxBD,gDAA6G;AAqtBtG,iDAHI,UAAU,GACR,OAAO,CAEqE;AAtnBzF,gCAzBW,MAAM,GAAC,IAAI,aACX,aAAa,kBACb,MAAM,GAAC,IAAI,QAmDrB;AA2nBD,yDAgCC;mBAlwBY,OAAO,GAAC,MAAM;4BAKd,WAAW,GAAC,UAAU;;UAOrB,MAAM;gBACN,MAAM;;;WAOjB;QAAyB,IAAI,EAAlB,MAAM;QACQ,GAAG,EAAjB,MAAM;KACjB;;;;;;cAQA;QAA4B,IAAI,EAArB,MAAM;QACW,GAAG,EAApB,MAAM;KACnB;;2BAGY,WAAW,GAAC,OAAO,GAAC,UAAU,GAAC,MAAM,GAAC,UAAU,GAAC,MAAM"}
@@ -0,0 +1,28 @@
1
+ declare namespace _default {
2
+ namespace amethyst {
3
+ export let name: string;
4
+ export { MaterialAmethyst as css };
5
+ }
6
+ namespace graphite {
7
+ let name_1: string;
8
+ export { name_1 as name };
9
+ export { MaterialGraphite as css };
10
+ }
11
+ namespace iron {
12
+ let name_2: string;
13
+ export { name_2 as name };
14
+ export { MaterialIron as css };
15
+ }
16
+ namespace jade {
17
+ let name_3: string;
18
+ export { name_3 as name };
19
+ export { MaterialJade as css };
20
+ }
21
+ namespace steel {
22
+ let name_4: string;
23
+ export { name_4 as name };
24
+ export { MaterialSteel as css };
25
+ }
26
+ }
27
+ export default _default;
28
+ //# sourceMappingURL=materials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materials.d.ts","sourceRoot":"","sources":["../../../themes/materials.js"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialpad/dialtone-tokens",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Design tokens for Dialtone.",
5
5
  "type": "module",
6
6
  "files": [