@cyclone-ui/theme-builder 0.0.11 → 0.0.12
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/CHANGELOG.md +11 -0
- package/dist/preprocessor.cjs +1 -1
- package/dist/preprocessor.d.cts +3 -3
- package/dist/preprocessor.d.cts.map +1 -1
- package/dist/preprocessor.d.mts +3 -3
- package/dist/preprocessor.mjs +1 -1
- package/dist/preprocessor.mjs.map +1 -1
- package/package.json +1 -1
- package/src/preprocessor.ts +59 -34
- package/test/preprocessor.spec.ts +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Cyclone UI - Theme Builder
|
|
4
4
|
|
|
5
|
+
## [0.0.12](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.12) (10/18/2026)
|
|
6
|
+
|
|
7
|
+
### Miscellaneous
|
|
8
|
+
|
|
9
|
+
- **monorepo:** Remove generated shell-shock files ([094fb32d](https://github.com/storm-software/cyclone-ui/commit/094fb32d))
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- **preview-link:** Added the Preview Link trigger component package ([10c01c5e](https://github.com/storm-software/cyclone-ui/commit/10c01c5e))
|
|
14
|
+
- **tokens:** Added `brand` color theme to workspace ([735efe8a](https://github.com/storm-software/cyclone-ui/commit/735efe8a))
|
|
15
|
+
|
|
5
16
|
## [0.0.7](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.7) (10/14/2026)
|
|
6
17
|
|
|
7
18
|
### Bug Fixes
|
package/dist/preprocessor.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin");const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},A=[`base`,`danger`,`warning`,`info`,`discovery`,`success`],me={primary:E,secondary:pe,link:E},he={foreground:{lowSaturation:[{name:`hovered`,brightness:1.45},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},ge={outline:{lowSaturation:[de,w,T],saturated:[ue,fe,T]}},j=7.5,M=.01;function _e(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ve(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ve(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function ye(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function be(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let e of A){let o=t[e];if(!i(o)||!a(o.primary))continue;let s=`{color.${e}.primary}`,c=e=>L(`{color.elevated}`,e),l={[e]:[`${e} 3px focus ring with no gap`,[L(s,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(s,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[c(3),L(s,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[c(2),L(s,3)]]};for(let[t,[i,a]]of Object.entries(l))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:a,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function xe(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),W(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),W(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Te(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function Ee(e,t){return!Te(e,t)}const De=B(`#dddddd`).lightness,Oe=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?De:.75)}function q(e){return B(e).lightness<=(R(e)?Oe:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function ke(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function Ae(e,t,n){return Ee(e,n)?t:2-t}function Y(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function X(e,t,n){if(t.name===`hovered`&&Y(t,n)&&ke(e,n))return n===`dark`?-.25:.25}function je(e,t,n){let r=Y(t,n);return r&&n&&t.name===`active`&&ke(e,n)?ae[n]:r}function Me(e,t,n){return t.brightness===void 0?1:Y(t,n)?J(t)?1:t.brightness:Ae(e,t.brightness,n)}function Ne(e,t,n){let r=X(e,t,n),i=r===void 0?je(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=xe(a,Me(a,t,n))):a=Se(e,r),t.saturation!==void 0&&!z(e)&&(a=Ce(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):ye(a,t.fadeOver,t.opacity??1)}function Pe(e,t,n){let r=[],i=X(t,e,n),a=je(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Me(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Fe(e,t,n,r){let i=Pe(n,t,r),a=Ne(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Z(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||_e(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Fe(s,l,e,p))}}return o}function Ie(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=we(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(me))c=Z(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Le(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function Q(e,t,n,o){if(Array.isArray(e))return e.map(e=>Q(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:Q(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){for(let e of A){let n=c[e];i(n)&&!a(n)&&(c[e]=Ie(e,n,t,o))}for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?he[n.group]:void 0;r&&(c=Z(c,t,r,e,o))}}for(let[e,n]of Object.entries(ge))a(c[e])&&(c=Z(c,t,n,e,o));return n===`color`?Le(c):c}function $(e){let t=x(e),n=be(Q(t,t,void 0,oe(t)));return F(n,n)}var Re=(0,e.definePlugin)(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:$}]}));exports.default=Re,exports.tamaguiPreprocessor=$;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin");const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},me=[`shadows`];function A(e){return Object.entries(e).filter(e=>!me.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const he={primary:E,secondary:pe,link:E},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.45},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},_e={outline:{lowSaturation:[de,w,T],saturated:[ue,fe,T]}},j=7.5,M=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function be(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function xe(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),W(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),W(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Ee(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function De(e,t){return!Ee(e,t)}const Oe=B(`#dddddd`).lightness,ke=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?Oe:.75)}function q(e){return B(e).lightness<=(R(e)?ke:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function Ae(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function je(e,t,n){return De(e,n)?t:2-t}function Y(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function Me(e,t,n){if(t.name===`hovered`&&Y(t,n)&&Ae(e,n))return n===`dark`?-.25:.25}function Ne(e,t,n){let r=Y(t,n);return r&&n&&t.name===`active`&&Ae(e,n)?ae[n]:r}function X(e,t,n){return t.brightness===void 0?1:Y(t,n)?J(t)?1:t.brightness:je(e,t.brightness,n)}function Pe(e,t,n){let r=Me(e,t,n),i=r===void 0?Ne(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=Se(a,X(a,t,n))):a=Ce(e,r),t.saturation!==void 0&&!z(e)&&(a=we(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):be(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=Me(t,e,n),a=Ne(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=X(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Z(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=Te(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(he))c=Z(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function Q(e,t,n,o){if(Array.isArray(e))return e.map(e=>Q(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:Q(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of A(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Z(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Z(c,t,n,e,o));return n===`color`?Re(c):c}function $(e){let t=x(e),n=xe(Q(t,t,void 0,oe(t)));return F(n,n)}var Be=(0,e.definePlugin)(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:$}]}));exports.default=Be,exports.tamaguiPreprocessor=$;
|
package/dist/preprocessor.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
4
4
|
* Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
|
|
5
5
|
* colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
|
|
6
6
|
* `oklch()`. Root colors (emphasis, ink, subtle, subtlest, outline, backgrounds)
|
|
7
|
-
* stay in the root light and dark themes without rings. For
|
|
8
|
-
*
|
|
7
|
+
* stay in the root light and dark themes without rings. For each color group
|
|
8
|
+
* with a `primary` token (except excluded groups), a missing `secondary` background and `on-primary` /
|
|
9
9
|
* `on-secondary` text colors are generated, then hovered, active, inactive,
|
|
10
10
|
* and disabled variants are added to the outline, `foreground` and
|
|
11
11
|
* `background` group colors, and each theme color group's `primary`, `secondary`
|
|
@@ -19,7 +19,7 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
19
19
|
* group name as `theme` and `group`, unless already set; root state and `on-*`
|
|
20
20
|
* tokens get their main token name as `group` (e.g. `outline-active` →
|
|
21
21
|
* `outline`).
|
|
22
|
-
* Finally, focus rings are generated for
|
|
22
|
+
* Finally, focus rings are generated for each theme color group.
|
|
23
23
|
*/
|
|
24
24
|
declare function tamaguiPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
|
|
25
25
|
declare const _default: (options?: unknown) => import("@razorwind/core/plugin").Plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.d.cts","names":[],"sources":["../src/preprocessor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"preprocessor.d.cts","names":[],"sources":["../src/preprocessor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBAmhDgB,oBACd,YAAY,qBACX"}
|
package/dist/preprocessor.d.mts
CHANGED
|
@@ -4,8 +4,8 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
4
4
|
* Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
|
|
5
5
|
* colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
|
|
6
6
|
* `oklch()`. Root colors (emphasis, ink, subtle, subtlest, outline, backgrounds)
|
|
7
|
-
* stay in the root light and dark themes without rings. For
|
|
8
|
-
*
|
|
7
|
+
* stay in the root light and dark themes without rings. For each color group
|
|
8
|
+
* with a `primary` token (except excluded groups), a missing `secondary` background and `on-primary` /
|
|
9
9
|
* `on-secondary` text colors are generated, then hovered, active, inactive,
|
|
10
10
|
* and disabled variants are added to the outline, `foreground` and
|
|
11
11
|
* `background` group colors, and each theme color group's `primary`, `secondary`
|
|
@@ -19,7 +19,7 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
19
19
|
* group name as `theme` and `group`, unless already set; root state and `on-*`
|
|
20
20
|
* tokens get their main token name as `group` (e.g. `outline-active` →
|
|
21
21
|
* `outline`).
|
|
22
|
-
* Finally, focus rings are generated for
|
|
22
|
+
* Finally, focus rings are generated for each theme color group.
|
|
23
23
|
*/
|
|
24
24
|
declare function tamaguiPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
|
|
25
25
|
declare const _default: (options?: unknown) => import("@razorwind/core/plugin").Plugin;
|
package/dist/preprocessor.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},A=[`base`,`danger`,`warning`,`info`,`discovery`,`success`],me={primary:E,secondary:pe,link:E},he={foreground:{lowSaturation:[{name:`hovered`,brightness:1.45},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},ge={outline:{lowSaturation:[de,w,T],saturated:[ue,fe,T]}},j=7.5,M=.01;function _e(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ve(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ve(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function ye(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function be(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let e of A){let o=t[e];if(!i(o)||!a(o.primary))continue;let s=`{color.${e}.primary}`,c=e=>L(`{color.elevated}`,e),l={[e]:[`${e} 3px focus ring with no gap`,[L(s,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(s,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[c(3),L(s,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[c(2),L(s,3)]]};for(let[t,[i,a]]of Object.entries(l))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:a,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function xe(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),W(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),W(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Te(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function Ee(e,t){return!Te(e,t)}const De=B(`#dddddd`).lightness,Oe=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?De:.75)}function q(e){return B(e).lightness<=(R(e)?Oe:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function ke(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function Ae(e,t,n){return Ee(e,n)?t:2-t}function Y(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function X(e,t,n){if(t.name===`hovered`&&Y(t,n)&&ke(e,n))return n===`dark`?-.25:.25}function je(e,t,n){let r=Y(t,n);return r&&n&&t.name===`active`&&ke(e,n)?ae[n]:r}function Me(e,t,n){return t.brightness===void 0?1:Y(t,n)?J(t)?1:t.brightness:Ae(e,t.brightness,n)}function Ne(e,t,n){let r=X(e,t,n),i=r===void 0?je(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=xe(a,Me(a,t,n))):a=Se(e,r),t.saturation!==void 0&&!z(e)&&(a=Ce(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):ye(a,t.fadeOver,t.opacity??1)}function Pe(e,t,n){let r=[],i=X(t,e,n),a=je(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Me(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Fe(e,t,n,r){let i=Pe(n,t,r),a=Ne(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Z(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||_e(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Fe(s,l,e,p))}}return o}function Ie(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=we(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(me))c=Z(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Le(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function Q(e,t,n,o){if(Array.isArray(e))return e.map(e=>Q(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:Q(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){for(let e of A){let n=c[e];i(n)&&!a(n)&&(c[e]=Ie(e,n,t,o))}for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?he[n.group]:void 0;r&&(c=Z(c,t,r,e,o))}}for(let[e,n]of Object.entries(ge))a(c[e])&&(c=Z(c,t,n,e,o));return n===`color`?Le(c):c}function $(e){let t=x(e),n=be(Q(t,t,void 0,oe(t)));return F(n,n)}var Re=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:$}]}));export{Re as default,$ as tamaguiPreprocessor};
|
|
1
|
+
import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},me=[`shadows`];function A(e){return Object.entries(e).filter(e=>!me.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const he={primary:E,secondary:pe,link:E},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.45},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},_e={outline:{lowSaturation:[de,w,T],saturated:[ue,fe,T]}},j=7.5,M=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function be(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function xe(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),W(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),W(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Ee(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function De(e,t){return!Ee(e,t)}const Oe=B(`#dddddd`).lightness,ke=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?Oe:.75)}function q(e){return B(e).lightness<=(R(e)?ke:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function Ae(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function je(e,t,n){return De(e,n)?t:2-t}function Y(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function Me(e,t,n){if(t.name===`hovered`&&Y(t,n)&&Ae(e,n))return n===`dark`?-.25:.25}function Ne(e,t,n){let r=Y(t,n);return r&&n&&t.name===`active`&&Ae(e,n)?ae[n]:r}function X(e,t,n){return t.brightness===void 0?1:Y(t,n)?J(t)?1:t.brightness:je(e,t.brightness,n)}function Pe(e,t,n){let r=Me(e,t,n),i=r===void 0?Ne(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=Se(a,X(a,t,n))):a=Ce(e,r),t.saturation!==void 0&&!z(e)&&(a=we(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):be(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=Me(t,e,n),a=Ne(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=X(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Z(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=Te(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(he))c=Z(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function Q(e,t,n,o){if(Array.isArray(e))return e.map(e=>Q(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:Q(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of A(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Z(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Z(c,t,n,e,o));return n===`color`?Re(c):c}function $(e){let t=x(e),n=xe(Q(t,t,void 0,oe(t)));return F(n,n)}var Be=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:$}]}));export{Be as default,$ as tamaguiPreprocessor};
|
|
2
2
|
//# sourceMappingURL=preprocessor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","PURE_CONTRAST_COLORS","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","HAIRLINE_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","BACKGROUND_COLOR_STATE_INACTIVE","BACKGROUND_COLOR_STATE_DISABLED","BACKGROUND_COLOR_STATE_VARIANTS","
|
|
1
|
+
{"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","PURE_CONTRAST_COLORS","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","HAIRLINE_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","BACKGROUND_COLOR_STATE_INACTIVE","BACKGROUND_COLOR_STATE_DISABLED","BACKGROUND_COLOR_STATE_VARIANTS","NONE_THEME_COLOR_KEYS","themeColorGroups","entry","THEME_COLOR_STATE_VARIANTS","COLOR_STATE_TOKEN_GROUPS","COLOR_STATE_VARIANTS","MINIMUM_SUBTLE_CONTRAST_RATIO","SUBTLE_COLOR_LIGHTNESS_STEP","isStateVariantKey","getTokenAtPath","tree","part","path","resolveColorHex","direct","ref","seen","applyOpacity","rgb","opacity","applyFadeOver","foreground","base","background","offset","applyRingOpacity","inRingGroup","applyToLayer","isLowSaturation","index","ZERO","ringLayer","spread","addMissingRingTokens","ring","changed","name","ringColor","gap","variants","hexToOklch","isGreyscale","l","m","s","isInSrgbGamut","oklchToGamutMappedHex","minimumChroma","maximumChroma","candidateChroma","applyBrightness","factor","applyLightnessShift","shift","applySaturation","relativeLuminance","contrastRatio","firstLuminance","first","secondLuminance","second","lighter","darker","createOnColor","whiteContrast","createMutedColor","secondaryDirection","parentTheme","onMutedDirection","secondaryLightness","onMutedLightness","secondary","onMuted","isLightColor","isWhiteColor","isBlackColor","isDarkColor","LOW_SATURATION_WHITE_LIGHTNESS","LOW_SATURATION_BLACK_LIGHTNESS","isInteractionState","variant","isNearContrastPrimitive","directedBrightnessFactor","contrastPrimitive","contrastSideLightnessShift","stateContrastColor","primitive","stateBrightnessFactor","applyStateTransform","transformed","variantDetail","details","percent","createStateToken","detail","source","addColorStateTokens","group","names","onlyKey","baseVariants","hasHovered","tokenVariants","tokenParentTheme","variantKey","addThemeColorGroupTokens","onSecondary","pair","secondaryHex","addColorTokenGroups","root","populateEmptyBrandTheme","brand","injectColorStateVariants","childKey","withStates","tokenKey","tamaguiPreprocessor","converted","withRings","preprocessor_default","definePlugin"],"sources":[],"mappings":""}
|
package/package.json
CHANGED
package/src/preprocessor.ts
CHANGED
|
@@ -545,21 +545,20 @@ const BACKGROUND_COLOR_STATE_VARIANTS: ColorStateVariants = {
|
|
|
545
545
|
]
|
|
546
546
|
};
|
|
547
547
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
] as const;
|
|
548
|
+
const NONE_THEME_COLOR_KEYS = ["shadows"] as const;
|
|
549
|
+
|
|
550
|
+
/** Color groups with a primary token become child themes unless excluded. */
|
|
551
|
+
function themeColorGroups(
|
|
552
|
+
color: Record<string, unknown>
|
|
553
|
+
): [string, Record<string, unknown>][] {
|
|
554
|
+
return Object.entries(color).filter(
|
|
555
|
+
(entry): entry is [string, Record<string, unknown>] =>
|
|
556
|
+
!NONE_THEME_COLOR_KEYS.includes(entry[0]) &&
|
|
557
|
+
isPlainObject(entry[1]) &&
|
|
558
|
+
!isTokenNode(entry[1]) &&
|
|
559
|
+
isTokenNode(entry[1].primary)
|
|
560
|
+
);
|
|
561
|
+
}
|
|
563
562
|
|
|
564
563
|
/** State variants for the tokens inside each theme color group. */
|
|
565
564
|
const THEME_COLOR_STATE_VARIANTS: Record<string, ColorStateVariants> = {
|
|
@@ -806,12 +805,7 @@ function addMissingRingTokens(dictionary: unknown): unknown {
|
|
|
806
805
|
const ring = isPlainObject(dictionary.ring) ? { ...dictionary.ring } : {};
|
|
807
806
|
let changed = false;
|
|
808
807
|
|
|
809
|
-
for (const name of
|
|
810
|
-
const group = color[name];
|
|
811
|
-
if (!isPlainObject(group) || !isTokenNode(group.primary)) {
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
|
|
808
|
+
for (const [name] of themeColorGroups(color)) {
|
|
815
809
|
const ringColor = `{color.${name}.primary}`;
|
|
816
810
|
const gap = (spread: number) => ringLayer("{color.elevated}", spread);
|
|
817
811
|
const variants: Record<string, [string, unknown[]]> = {
|
|
@@ -1428,6 +1422,38 @@ function addColorTokenGroups(
|
|
|
1428
1422
|
return result;
|
|
1429
1423
|
}
|
|
1430
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* Brand themes without their own color tokens inherit the base theme colors.
|
|
1427
|
+
* Keep brand metadata (such as its description) so it remains the owning
|
|
1428
|
+
* theme once its copied tokens are processed below.
|
|
1429
|
+
*/
|
|
1430
|
+
function populateEmptyBrandTheme(
|
|
1431
|
+
color: Record<string, unknown>
|
|
1432
|
+
): Record<string, unknown> {
|
|
1433
|
+
const base = color.base;
|
|
1434
|
+
const brand = color.brand;
|
|
1435
|
+
if (
|
|
1436
|
+
!isPlainObject(base) ||
|
|
1437
|
+
isTokenNode(base) ||
|
|
1438
|
+
!isPlainObject(brand) ||
|
|
1439
|
+
isTokenNode(brand) ||
|
|
1440
|
+
Object.entries(brand).some(
|
|
1441
|
+
([key, value]) =>
|
|
1442
|
+
!RESERVED_KEYS.has(key) && !key.startsWith("$") && isTokenNode(value)
|
|
1443
|
+
)
|
|
1444
|
+
) {
|
|
1445
|
+
return color;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
return {
|
|
1449
|
+
...color,
|
|
1450
|
+
brand: {
|
|
1451
|
+
...(base as Record<string, unknown>),
|
|
1452
|
+
...(brand as Record<string, unknown>)
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1431
1457
|
function injectColorStateVariants(
|
|
1432
1458
|
node: unknown,
|
|
1433
1459
|
tree: unknown,
|
|
@@ -1463,16 +1489,15 @@ function injectColorStateVariants(
|
|
|
1463
1489
|
|
|
1464
1490
|
let withStates = result;
|
|
1465
1491
|
if (key === "color") {
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
}
|
|
1492
|
+
withStates = populateEmptyBrandTheme(withStates);
|
|
1493
|
+
|
|
1494
|
+
for (const [name, group] of themeColorGroups(withStates)) {
|
|
1495
|
+
withStates[name] = addThemeColorGroupTokens(
|
|
1496
|
+
name,
|
|
1497
|
+
group,
|
|
1498
|
+
tree,
|
|
1499
|
+
parentTheme
|
|
1500
|
+
);
|
|
1476
1501
|
}
|
|
1477
1502
|
|
|
1478
1503
|
for (const [tokenKey, token] of Object.entries(withStates)) {
|
|
@@ -1511,8 +1536,8 @@ function injectColorStateVariants(
|
|
|
1511
1536
|
* Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
|
|
1512
1537
|
* colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
|
|
1513
1538
|
* `oklch()`. Root colors (emphasis, ink, subtle, subtlest, outline, backgrounds)
|
|
1514
|
-
* stay in the root light and dark themes without rings. For
|
|
1515
|
-
*
|
|
1539
|
+
* stay in the root light and dark themes without rings. For each color group
|
|
1540
|
+
* with a `primary` token (except excluded groups), a missing `secondary` background and `on-primary` /
|
|
1516
1541
|
* `on-secondary` text colors are generated, then hovered, active, inactive,
|
|
1517
1542
|
* and disabled variants are added to the outline, `foreground` and
|
|
1518
1543
|
* `background` group colors, and each theme color group's `primary`, `secondary`
|
|
@@ -1526,7 +1551,7 @@ function injectColorStateVariants(
|
|
|
1526
1551
|
* group name as `theme` and `group`, unless already set; root state and `on-*`
|
|
1527
1552
|
* tokens get their main token name as `group` (e.g. `outline-active` →
|
|
1528
1553
|
* `outline`).
|
|
1529
|
-
* Finally, focus rings are generated for
|
|
1554
|
+
* Finally, focus rings are generated for each theme color group.
|
|
1530
1555
|
*/
|
|
1531
1556
|
export function tamaguiPreprocessor(
|
|
1532
1557
|
dictionary: PreprocessedTokens
|
|
@@ -56,6 +56,54 @@ const hueDistance = (first: number, second: number): number => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
describe("tamaguiPreprocessor", () => {
|
|
59
|
+
it("populates an empty brand theme from base color tokens", () => {
|
|
60
|
+
const result = tamaguiPreprocessor({
|
|
61
|
+
color: {
|
|
62
|
+
base: {
|
|
63
|
+
primary: colorToken("#336699"),
|
|
64
|
+
secondary: colorToken("#abcdef")
|
|
65
|
+
},
|
|
66
|
+
brand: {
|
|
67
|
+
$description: "The brand theme colors"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}) as any;
|
|
71
|
+
|
|
72
|
+
expect(result.color.brand).toMatchObject({
|
|
73
|
+
$description: "The brand theme colors",
|
|
74
|
+
primary: { $value: "#336699", theme: "brand", group: "brand" },
|
|
75
|
+
secondary: { $value: "#abcdef", theme: "brand", group: "brand" }
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("does not create a brand theme when it is absent", () => {
|
|
80
|
+
const result = tamaguiPreprocessor({
|
|
81
|
+
color: { base: { primary: colorToken("#336699") } }
|
|
82
|
+
}) as any;
|
|
83
|
+
|
|
84
|
+
expect(result.color).not.toHaveProperty("brand");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("treats any color group with a primary token as a theme unless excluded", () => {
|
|
88
|
+
const result = tamaguiPreprocessor({
|
|
89
|
+
color: {
|
|
90
|
+
custom: { primary: colorToken("#336699") },
|
|
91
|
+
shadows: { primary: colorToken("#336699") },
|
|
92
|
+
unthemed: { secondary: colorToken("#336699") }
|
|
93
|
+
}
|
|
94
|
+
}) as any;
|
|
95
|
+
|
|
96
|
+
expect(result.color.custom.primary.theme).toBe("custom");
|
|
97
|
+
expect(result.color.custom["on-primary"].$value).toBe("#FAFAFA");
|
|
98
|
+
expect(result.color.custom["primary-active"]).toBeDefined();
|
|
99
|
+
expect(result.ring.custom.theme).toBe("custom");
|
|
100
|
+
expect(result.color.shadows).not.toHaveProperty("on-primary");
|
|
101
|
+
expect(result.color.shadows).not.toHaveProperty("primary-active");
|
|
102
|
+
expect(result.ring).not.toHaveProperty("shadows");
|
|
103
|
+
expect(result.color.unthemed).not.toHaveProperty("on-primary");
|
|
104
|
+
expect(result.ring).not.toHaveProperty("unthemed");
|
|
105
|
+
});
|
|
106
|
+
|
|
59
107
|
it("generates missing on-primary text colors for theme color groups", () => {
|
|
60
108
|
const result = tamaguiPreprocessor({
|
|
61
109
|
color: {
|