@webority/tokens 0.149.0 → 0.150.0
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/brand.d.ts +39 -25
- package/dist/brand.js +2 -2
- package/dist/build.d.ts +41 -0
- package/dist/build.js +5 -5
- package/dist/canvas/webority-phone.json +1 -1
- package/dist/canvas/webority-web-390.json +1 -1
- package/dist/canvas/webority-web.json +1 -1
- package/dist/check.d.ts +37 -0
- package/dist/check.js +3 -3
- package/dist/cli.d.ts +15 -96
- package/dist/cli.js +1 -1
- package/dist/emit/canvas.d.ts +8 -0
- package/dist/emit/canvas.js +1 -1
- package/dist/emit/email.d.ts +32 -0
- package/dist/emit/email.js +2 -2
- package/dist/emit/meanings.d.ts +3 -0
- package/dist/emit/phone.d.ts +26 -0
- package/dist/emit/phone.js +3 -3
- package/dist/emit/web.d.ts +18 -0
- package/dist/emit/web.js +14 -14
- package/dist/guards.d.ts +3 -0
- package/dist/guards.js +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/meanings.json +1 -1
- package/dist/model/colour.d.ts +8 -0
- package/dist/model/colour.js +1 -1
- package/dist/model/contrast.d.ts +26 -0
- package/dist/model/contrast.js +1 -1
- package/dist/model/index.d.ts +52 -0
- package/dist/model/length.d.ts +21 -0
- package/dist/model/length.js +1 -1
- package/dist/model/load.d.ts +32 -0
- package/dist/model/load.js +1 -1
- package/dist/model/references.d.ts +3 -0
- package/dist/model/references.js +1 -1
- package/dist/model/resolve.d.ts +4 -0
- package/dist/model/resolve.js +2 -2
- package/dist/names.d.ts +1 -11
- package/dist/names.js +1 -1
- package/dist/outputs.d.ts +51 -102
- package/dist/present.d.ts +1 -0
- package/dist/present.js +1 -0
- package/dist/ramp.d.ts +8 -0
- package/dist/ramp.js +1 -1
- package/dist/upgrade/classes.d.ts +13 -0
- package/dist/upgrade/classes.js +2 -2
- package/dist/upgrade/components.d.ts +19 -0
- package/dist/upgrade/components.js +3 -3
- package/dist/upgrade/css.d.ts +28 -0
- package/dist/upgrade/css.js +2 -2
- package/dist/upgrade/index.d.ts +64 -0
- package/dist/upgrade/index.js +2 -2
- package/dist/upgrade/razorAttributes.d.ts +19 -0
- package/dist/upgrade/razorAttributes.js +2 -2
- package/dist/upgrade/razorTags.d.ts +19 -0
- package/dist/upgrade/razorTags.js +2 -2
- package/dist/upgrade/razorValueSplits.d.ts +19 -0
- package/dist/upgrade/razorValueSplits.js +2 -2
- package/dist/upgrade/source.d.ts +19 -0
- package/dist/upgrade/source.js +3 -3
- package/dist/upgrade/tagScan.d.ts +7 -0
- package/dist/upgrade/tagScan.js +1 -1
- package/dist/upgrade/themeReads.d.ts +55 -0
- package/dist/upgrade/themeReads.js +2 -2
- package/dist/upgrade/valueSplits.d.ts +23 -0
- package/dist/upgrade/valueSplits.js +3 -3
- package/dist/upgrade/wrapperValues.d.ts +71 -0
- package/dist/upgrade/wrapperValues.js +1 -1
- package/dist/webority.d.ts +1 -0
- package/package.json +7 -3
- package/renames/renames.d.ts +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Mode, Model } from "../model/index.ts";
|
|
2
|
+
export interface PhoneToken {
|
|
3
|
+
path: readonly string[];
|
|
4
|
+
type: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
/** The first alias the token names, "space.lg" for "{space.lg}"; null for a literal. From Model.referenceIn. */
|
|
7
|
+
reference: string | null;
|
|
8
|
+
platforms: readonly ("web" | "phone")[] | null;
|
|
9
|
+
/** The com.webority extension object, or null. */
|
|
10
|
+
extensions: Record<string, unknown> | null;
|
|
11
|
+
}
|
|
12
|
+
export interface PhoneTokenSets {
|
|
13
|
+
light: readonly PhoneToken[];
|
|
14
|
+
dark: readonly PhoneToken[];
|
|
15
|
+
}
|
|
16
|
+
export interface EmittedFile {
|
|
17
|
+
name: string;
|
|
18
|
+
contents: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function phoneSets(model: Model, mode: Mode): readonly PhoneToken[];
|
|
21
|
+
export declare function emitPhoneTheme(sets: PhoneTokenSets): EmittedFile;
|
|
22
|
+
export declare function emitPhoneBrand(library: PhoneTokenSets, branded: PhoneTokenSets, source: {
|
|
23
|
+
package: string;
|
|
24
|
+
version: string;
|
|
25
|
+
brand: string;
|
|
26
|
+
}): EmittedFile;
|
package/dist/emit/phone.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}\n`}}function
|
|
3
|
-
`)}\n`}}function
|
|
1
|
+
import{isObjectLike as e}from"../guards.js";import{present as t}from"../present.js";var n="// Generated by `webority brand --library` from packages/tokens/src/source. Do not edit: run `corepack pnpm --filter @webority/mobile-ui tokens`.",r=/^[A-Za-z_$][A-Za-z0-9_$]*$/,i=/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/,o=[`xs`,`sm`,`md`,`lg`,`xl`],s=`must be component.<name>.<prop> or component.<name>.<size>.<prop>`,c=[`light`,`dark`],l=new Map([[`color`,`colors`],[`space`,`space`],[`radius`,`radius`],[`text`,`text`],[`weight`,`weight`],[`leading`,`leading`],[`letter-spacing`,`letter-spacing`],[`font`,`font`],[`shadow`,`shadow`],[`size`,`size`],[`component`,`components`]]),u=[{key:`colors`,constName:`COLOR_NAMES`,typeName:`ColorName`},{key:`space`,constName:`SPACE_NAMES`,typeName:`SpaceName`},{key:`radius`,constName:`RADIUS_NAMES`,typeName:`RadiusName`},{key:`text`,constName:`TEXT_NAMES`,typeName:`TextName`},{key:`weight`,constName:`WEIGHT_NAMES`,typeName:`WeightName`},{key:`leading`,constName:`LEADING_NAMES`,typeName:`LeadingName`},{key:`letter-spacing`,constName:`LETTER_SPACING_NAMES`,typeName:`LetterSpacingName`},{key:`font`,constName:`FONT_NAMES`,typeName:`FontName`},{key:`shadow`,constName:`SHADOW_NAMES`,typeName:`ShadowName`},{key:`motion.duration`,constName:`DURATION_NAMES`,typeName:`DurationName`},{key:`motion.ease`,constName:`EASE_NAMES`,typeName:`EaseName`},{key:`size`,constName:`SIZE_NAMES`,typeName:`SizeName`}],d={space:`SpaceName`,text:`TextName`,radius:`RadiusName`,px:`number`,number:`number`,ms:`number`},f=[`export type FontWeightValue = "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";`,`/** Face name per weight; an empty object means the platform system font. */`,`export type FontFaces = Partial<Record<WeightName, string>>;`,`export interface PhoneShadow {`,` shadowColor: string;`,` shadowOffset: { width: number; height: number };`,` shadowOpacity: number;`,` shadowRadius: number;`,` elevation: number;`,`}`,`export type ComponentKind = "space" | "text" | "radius" | "px" | "number" | "ms";`,`type Sized<S extends string, T> = Record<S, T>;`,`type L3 = "sm" | "md" | "lg";`],p=[`export interface TokenSet {`,` mode: "light" | "dark";`,` colors: Record<ColorName, string>;`,` space: Record<SpaceName, number>;`,` radius: Record<RadiusName, number>;`,` text: Record<TextName, { size: number }>;`,` weight: Record<WeightName, FontWeightValue>;`,` leading: Record<LeadingName, number>;`,` "letter-spacing": Record<LetterSpacingName, number>;`,` font: Record<FontName, FontFaces>;`,` shadow: Record<ShadowName, PhoneShadow>;`,` motion: { duration: Record<DurationName, number>; ease: Record<EaseName, readonly [number, number, number, number]> };`,` size: Record<SizeName, number>;`,` components: ComponentTokens;`,`}`];function m(e,t){let n=e.contexts.find(e=>e.platform===`phone`&&e.mode===t);if(!n)throw Error(`phoneSets: the model has no ${t} phone context`);let r=[];for(let t of e.tokens.values()){if(!e.existsIn(t.path,n))continue;let i=e.resolvedIn(t.path,n);r.push({path:t.path.split(`.`),type:t.type,value:t.group===`text`?_(t.path,i):i,reference:e.referenceIn(t.path,n)??null,platforms:t.platforms,extensions:Object.keys(t.extensions).length>0?t.extensions:null})}return r}function h(e){let t=E(e.light),r=E(e.dark);I(t,r);let i=[n];for(let e of u)i.push(...B(e,b(t.lists,e.key)));return i.push(...f),i.push(...G(t.components)),i.push(...K(t.components)),i.push(...p),i.push(...Y(`lightTokens`,`light`,t)),i.push(...Y(`darkTokens`,`dark`,r)),{name:`tokens.generated.ts`,contents:`${i.join(`
|
|
2
|
+
`)}\n`}}function g(e,t,n){let r={colors:{light:{},dark:{}},radius:{},font:{}};for(let n of c){let i=E(e[n]).values,a=E(t[n]).values;for(let e of new Set([...i.keys(),...a.keys()])){let t=i.get(e),o=a.get(e);if(!t&&o&&e.startsWith(`colors.`))continue;if(!t||!o)throw Error(R(e));if(JSON.stringify(t.value)===JSON.stringify(o.value))continue;let s=e.lastIndexOf(`.`),c=e.slice(0,s),l=e.slice(s+1);if(c===`radius`&&(l===`none`||l===`pill`))throw Error(`A brand cannot change radius none or pill`);if(c===`colors`)r.colors[n][l]=o.value;else if(c===`radius`)L(r.radius,l,o.value,e);else if(c===`font`)L(r.font,l,o.value,e);else throw Error(R(e))}}let i=Object.fromEntries(c.filter(e=>Object.keys(r.colors[e]).length>0).map(e=>[e,r.colors[e]])),a={};Object.keys(i).length>0&&(a.colors=i),Object.keys(r.radius).length>0&&(a.radius=r.radius),Object.keys(r.font).length>0&&(a.font=r.font);let o=[`// Generated by \`webority brand\` for ${n.brand} from ${n.package} ${n.version}. Do not edit.`,``,`/** @type {import("@webority/mobile-ui").BrandOverrides} */`];return Object.keys(a).length===0?o.push(`export const brand = {};`):o.push(`export const brand = {`,...Object.entries(a).flatMap(([e,t])=>Z(e,t,` `)),`};`),{name:`brand.phone.js`,contents:`${o.join(`
|
|
3
|
+
`)}\n`}}function _(e,t){return{size:T(t,e)}}function v(t,n){return e(t)?t[n]:void 0}function y(e,n){return t(e[n],`token path segment ${n}`)}function b(e,n){return t(e.get(n),`phone emitter ${n} list`)}function x(e,n){return t(e.get(n),`phone emitter value for ${n}`).value}function S(e){return e.extensions?.internal===!0?!1:e.platforms===null||e.platforms.includes(`phone`)}function C(e,t){return Error(`Token group ${e} has no phone mapping; mark it web or add one to emit/phone.js (first: ${t})`)}function w(e){let[t,n]=e.path;if(t===`motion`){if(n===`duration`||n===`ease`)return`motion.${n}`;throw C(t,e.path.join(`.`))}let r=t===void 0?void 0:l.get(t);if(r===void 0)throw C(t,e.path.join(`.`));return r}function T(t,n){let r=e(t)?t.value:t;if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Token ${n} has no numeric value`);return r}function E(e){let t=new Map(u.map(e=>[e.key,[]])),n=new Map,r=new Map;for(let i of e){if(!S(i))continue;let e=i.path.join(`.`),a=w(i);if(i.value===void 0||i.value===null)throw Error(`Token ${e} has no phone value`);if(a===`components`){P(i,e,n,r);continue}let o=i.path.slice(a.startsWith(`motion.`)?2:1).join(`-`);n.set(`${a}.${o}`,{path:e,value:D(a,o,i,e)}),b(t,a).push(o)}return{lists:t,values:n,components:r}}function D(e,t,n,r){let{value:i}=n;switch(e){case`colors`:return i;case`space`:case`radius`:case`letter-spacing`:case`size`:case`leading`:case`motion.duration`:return T(i,r);case`text`:return{size:T(v(i,`size`),r)};case`weight`:return String(T(i,r));case`font`:return O(n,t);case`shadow`:return k(n,t,r);case`motion.ease`:return j(i,r)}}function O(e,t){if(Array.isArray(e.value)&&e.value.length===1&&e.value[0]===`System`)return{};if(!e.extensions?.faces)throw Error(`Font ${t} is not the system font and has no faces`);return e.extensions.faces}function k(t,n,r){let i=t.value;if(!e(i))throw Error(`Shadow ${n} has no shadow value`);let{hex:a,opacity:o}=A(i.color,r),s=t.extensions?.elevation;if(typeof s!=`number`||!Number.isFinite(s))throw Error(`Shadow ${n} has no elevation`);return{shadowColor:a,shadowOffset:{width:T(i.offsetX,r),height:T(i.offsetY,r)},shadowOpacity:o,shadowRadius:T(i.blur,r),elevation:s}}function A(e,t){let n=typeof e==`string`?i.exec(e):null;if(n){let e=n[1],r=n[2];if(e===void 0)throw Error(`Shadow ${t} colour has no digits`);let i=r===void 0?1:Math.round(parseInt(r,16)/255*1e3)/1e3;return{hex:`#${e.toLowerCase()}`,opacity:i}}let r=typeof e==`string`?a.exec(e):null;if(r)return{hex:`#${r.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`,opacity:Number(r[4])};throw Error(`Shadow ${t} colour is not #RRGGBB, #RRGGBBAA or rgba(): ${String(e)}`)}function j(e,t){if(!Array.isArray(e)||e.length!==4||!e.every(e=>Number.isFinite(e)))throw Error(`Token ${t} has no phone value`);return[...e]}function M(e){return e!==void 0&&o.includes(e)}function N(e,n){return t(e.props.get(n),`component prop ${n} kind`)}function P(e,t,n,r){let i=e.path,a=i.length===4;if(i.length!==3&&!a||a&&!M(i[2]))throw Error(`Component token ${t} ${s}`);let o=y(i,1),c=y(i,i.length-1),{kind:l,value:u}=F(e,t),d=r.get(o);if(d===void 0&&(d={props:new Map,sizes:new Map,free:new Map},r.set(o,d)),d.props.has(c)&&d.props.get(c)!==l)throw Error(`Component ${o} prop ${c} has two kinds`);if(d.props.set(c,l),a){let e=y(i,2),r=d.sizes.get(e);r===void 0&&(r=new Map,d.sizes.set(e,r)),r.set(c,u),n.set(`components.${o}.${e}.${c}`,{path:t,value:u})}else d.free.set(c,u),n.set(`components.${o}.${c}`,{path:t,value:u})}function F(e,t){let{reference:n}=e;for(let[e,t]of[[`space.`,`space`],[`text.`,`text`],[`radius.`,`radius`]])if(n?.startsWith(e))return{kind:t,value:n.slice(e.length)};if(!n){if(e.type===`dimension`)return{kind:`px`,value:T(e.value,t)};if(e.type===`number`)return{kind:`number`,value:T(e.value,t)};if(e.type===`duration`)return{kind:`ms`,value:T(e.value,t)}}throw Error(`Component token ${t} has an unsupported value`)}function I(e,t){for(let[n,{path:r}]of e.values)if(!t.values.has(n))throw Error(`Token ${r} exists in one mode only`);for(let[n,{path:r}]of t.values)if(!e.values.has(n))throw Error(`Token ${r} exists in one mode only`)}function L(e,t,n,r){if(Object.hasOwn(e,t)&&JSON.stringify(e[t])!==JSON.stringify(n))throw Error(`A brand sets ${r} differently in light and dark`);e[t]=n}function R(e){return`A brand overrides colours, radius and fonts only; ${e} differs`}function z(e){return r.test(e)?e:JSON.stringify(e)}function B(e,t){let n=`export type ${e.typeName} = (typeof ${e.constName})[number];`;return t.length<=12?[`export const ${e.constName} = [${t.map(e=>JSON.stringify(e)).join(`, `)}] as const;`,n]:[`export const ${e.constName} = [`,...t.map(e=>` ${JSON.stringify(e)},`),`] as const;`,n]}var V=140;function H(e,t){return t.map(t=>`${z(t)}: ${d[N(e,t)]}`)}function U(e){return e.split(/[^A-Za-z0-9]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function W(e,t){return[`export interface ${e} {`,...t.map(e=>` ${e};`),`}`]}function G(e){let t=[],n=[];for(let[r,i]of e){let e=H(i,[...i.free.keys()]),a=H(i,[...new Set([...i.sizes.values()].flatMap(e=>[...e.keys()]))]),s=o.filter(e=>i.sizes.has(e)),c=s.join()===`sm,md,lg`?`L3`:s.map(e=>JSON.stringify(e)).join(` | `),l=e=>`{ ${e.join(`; `)} }`,u=(t,n)=>a.length===0?n:`Sized<${c}, ${t}>${e.length>0?` & ${n}`:``}`,d=` ${z(r)}: ${u(l(a),l(e))};`;if(d.length<=V){n.push(d);continue}let f=U(r);a.length>0&&t.push(...W(`${f}SizeTokens`,a)),e.length>0&&t.push(...W(`${f}Tokens`,e)),n.push(` ${z(r)}: ${u(`${f}SizeTokens`,`${f}Tokens`)};`)}let r=[...t,`export interface ComponentTokens {`,...n];return r.push(`}`,`export type ComponentName = keyof ComponentTokens;`,`type SizeKeysOf<C extends ComponentName> = Extract<keyof ComponentTokens[C], "xs" | "sm" | "md" | "lg" | "xl">;`,`export type ComponentSizeTokens<C extends ComponentName> = ComponentTokens[C][SizeKeysOf<C>];`),r}function K(e){let t=[`export const COMPONENT_KINDS = {`];for(let[n,r]of e){let e=[...r.props].map(([e,t])=>`${z(e)}: ${JSON.stringify(t)}`),i=` ${z(n)}: { ${e.join(`, `)} },`;i.length<=V?t.push(i):t.push(` ${z(n)}: {`,...e.map(e=>` ${e},`),` },`)}return t.push(`} as const satisfies { readonly [C in ComponentName]: Readonly<Record<string, ComponentKind>> };`),t}function q(e){let t={};for(let[n,r]of e){let e={};for(let t of o){let n=r.sizes.get(t);n!==void 0&&(e[t]=Object.fromEntries(n))}for(let[t,n]of r.free)e[t]=n;t[n]=e}return t}function J(e,t){let{lists:n}=t,r=(e,n)=>Object.fromEntries(n.map(n=>[n,x(t.values,`${e}.${n}`)]));return{mode:e,colors:r(`colors`,b(n,`colors`)),space:r(`space`,b(n,`space`)),radius:r(`radius`,b(n,`radius`)),text:r(`text`,b(n,`text`)),weight:r(`weight`,b(n,`weight`)),leading:r(`leading`,b(n,`leading`)),"letter-spacing":r(`letter-spacing`,b(n,`letter-spacing`)),font:r(`font`,b(n,`font`)),shadow:r(`shadow`,b(n,`shadow`)),motion:{duration:r(`motion.duration`,b(n,`motion.duration`)),ease:r(`motion.ease`,b(n,`motion.ease`))},size:r(`size`,b(n,`size`)),components:q(t.components)}}function Y(e,t,n){let r=J(t,n);return[`export const ${e}: TokenSet = {`,...Object.entries(r).flatMap(([e,t])=>Z(e,t,` `)),`};`]}function X(e){return Array.isArray(e)?`[${e.map(e=>X(e)).join(`, `)}]`:JSON.stringify(e)}function Z(e,t,n){let r=`${n}${z(e)}`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=Object.entries(t);return e.length===0?[`${r}: {},`]:[`${r}: {`,...e.flatMap(([e,t])=>Z(e,t,`${n} `)),`${n}},`]}return[`${r}: ${X(t)},`]}export{g as emitPhoneBrand,h as emitPhoneTheme,m as phoneSets};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Model } from "../model/index.ts";
|
|
2
|
+
/** Library mode: the token SCSS and the Bootstrap variables, references kept as var(). */
|
|
3
|
+
export interface LibraryWebFiles {
|
|
4
|
+
tokens: string;
|
|
5
|
+
bootstrap: string;
|
|
6
|
+
}
|
|
7
|
+
/** Brand mode: only what differs from the library, as brand.css and _brand-variables.scss. */
|
|
8
|
+
export interface BrandWebFiles {
|
|
9
|
+
css: string;
|
|
10
|
+
variables: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Library mode returns the tokens and bootstrap SCSS. Brand mode returns the brand CSS and variables that differ from the library.
|
|
14
|
+
*/
|
|
15
|
+
export declare function emitWeb(model: Model): LibraryWebFiles;
|
|
16
|
+
export declare function emitWeb(model: Model, options: {
|
|
17
|
+
library: Model;
|
|
18
|
+
}): BrandWebFiles;
|
package/dist/emit/web.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{BREAKPOINT_PX as
|
|
2
|
-
:root[data-bs-theme="dark"]`,
|
|
3
|
-
[data-bs-theme="dark"]:not(:root)`,
|
|
1
|
+
import{isObjectLike as e}from"../guards.js";import{BREAKPOINT_PX as t,TOUCH_MEDIA as n,breakpointRules as r,fluidLength as i,touchValue as a}from"../model/length.js";import{cssVarOfPath as o}from"../names.js";import{present as s}from"../present.js";var c={mode:`light`,platform:`web`,width:1440},l={mode:`dark`,platform:`web`,width:1440},u={mode:`light`,platform:`web`,width:390},d=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,ee=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/,te=/^#[0-9a-f]{6}$/i,f=[[`--bs-body-color`,`text`],[`--bs-emphasis-color`,`text`],[`--bs-secondary-color`,`text-muted`],[`--bs-tertiary-color`,`text-subtle`],[`--bs-heading-color`,`text`],[`--bs-body-bg`,`bg`],[`--bs-border-color`,`border`],[`--bs-secondary-bg`,`surface`],[`--bs-tertiary-bg`,`bg-muted`],[`--bs-primary`,`primary`]],p=[[`--bs-body-bg-rgb`,`bg`],[`--bs-primary-rgb`,`primary`],[`--bs-body-color-rgb`,`text`],[`--bs-emphasis-color-rgb`,`text`],[`--bs-secondary-color-rgb`,`text-muted`],[`--bs-tertiary-color-rgb`,`text-subtle`],[`--bs-secondary-bg-rgb`,`surface`],[`--bs-tertiary-bg-rgb`,`bg-muted`],[`--bs-border-color-rgb`,`border`]],ne=[[`--bs-secondary-rgb`,`text-muted`]],m=[[`$body-color`,`color.text-body`],[`$body-secondary-color`,`color.text-muted`],[`$body-tertiary-color`,`color.text-subtle`],[`$body-secondary-bg`,`color.bg-subtle`],[`$body-tertiary-bg`,`color.bg-muted`],[`$border-color`,`color.border`],[`$border-color-translucent`,null],[`$border-radius`,`radius.md`],[`$border-radius-sm`,`radius.sm`],[`$border-radius-lg`,`radius.lg`],[`$border-radius-pill`,`radius.pill`],[`$wui-shadow-overlay`,`shadow.popover`],[`$wui-shadow-overlay-lg`,`shadow.modal`],[`$link-color`,`color.link`],[`$line-height-base`,`leading.body`],[`$headings-line-height`,`leading.heading`],[`$display-line-height`,`leading.display`]],h=[[`$primary`,`color.primary`]],g={"$border-color-translucent":`rgba(13, 24, 43, 0.08)`},_=[`color.link`,`color.primary-hover`],re=`:root[data-theme="dark"],
|
|
2
|
+
:root[data-bs-theme="dark"]`,v=`[data-theme="dark"]:not(:root),
|
|
3
|
+
[data-bs-theme="dark"]:not(:root)`,ie=`:root[data-theme="auto"]`,y=`:root[data-theme="dark"] [data-theme="light"],
|
|
4
4
|
:root[data-theme="dark"] [data-bs-theme="light"],
|
|
5
5
|
:root[data-bs-theme="dark"] [data-theme="light"],
|
|
6
|
-
:root[data-bs-theme="dark"] [data-bs-theme="light"]`,
|
|
7
|
-
:root[data-theme="auto"] [data-bs-theme="light"]`,
|
|
6
|
+
:root[data-bs-theme="dark"] [data-bs-theme="light"]`,b=`:root[data-theme="auto"] [data-theme="light"],
|
|
7
|
+
:root[data-theme="auto"] [data-bs-theme="light"]`,x=`[data-theme="dark"]:not(:root) [data-theme="light"],
|
|
8
8
|
[data-theme="dark"]:not(:root) [data-bs-theme="light"],
|
|
9
9
|
[data-bs-theme="dark"]:not(:root) [data-theme="light"],
|
|
10
|
-
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,
|
|
10
|
+
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,S=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,C=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,w=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,T=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`,E=`// A light box under a dark page root takes literal light values: var() would resolve against the dark root.`,D=`/* A light box under a dark page root takes literal light values: var() would resolve against the dark root. */`;function O(e){return String(Number(e.toFixed(4)))}function k(e,t){return s(e.tokens.get(t),`token ${t}`)}function ae(e){if(e==null)return 1440;if(typeof e==`number`)return e;throw Error(`emitWeb: fluidUntil must be a number`)}function A(t,n){if(typeof n==`string`)return n.replace(d,(e,t)=>`var(${o(t)})`);if(typeof n==`number`)return O(n);if(Array.isArray(n)){if(t.type===`cubicBezier`&&n.length===4&&n.every(e=>typeof e==`number`))return`cubic-bezier(${n.map(e=>O(e)).join(`, `)})`;if(t.type===`fontFamily`&&n.every(e=>typeof e==`string`))return n.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(e(n)){if(`unit`in n&&typeof n.value==`number`)return`${O(n.value)}${String(n.unit)}`;if(`color`in n)return[n.offsetX,n.offsetY,n.blur,n.spread,n.color].map(e=>A(t,e)).join(` `)}throw Error(`emitWeb: ${t.path}: cannot write a ${t.type} value as CSS.`)}function j(e,t,n){return A(k(e,t),e.valueIn(t,n))}function M(t,n){if(e(n)&&n.unit===`px`&&typeof n.value==`number`)return n.value;throw Error(`emitWeb: ${t}: a text size must be a px dimension.`)}function N(e,t){let n=k(e,t),a=o(t);if(n.group===`text`){if(r(n).length>0)throw Error(`emitWeb: ${t}: a text size cannot carry breakpoints.`);let o=M(t,e.valueIn(t,u)),s=M(t,e.valueIn(t,c)),l=n.extensions?.fluidUntil;if(o!==s&&l===void 0)throw Error(`emitWeb: ${t}: the 390 and 1440 sizes differ but no fluidUntil is recorded.`);return{path:t,name:a,root:i(o,s,ae(l)),tiers:[]}}let s=r(n);return s.length>0?{path:t,name:a,root:j(e,t,u),tiers:s.map(e=>({tier:e.tier,text:A(n,e.value)}))}:{path:t,name:a,root:j(e,t,c),tiers:[]}}function P(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,c)&&t.push(N(e,n));return t}function F(e,t){let n=[];for(let[i,a]of e.tokens){if(!e.existsIn(i,l)||!e.existsIn(i,c)||r(a).length>0)continue;let s=j(e,i,l);if(a.group===`text`){if(s!==j(e,i,c))throw Error(`emitWeb: ${i}: a text size cannot change with the mode.`)}else t(i,s)&&n.push({path:i,name:o(i),text:s,light:j(e,i,c)})}return n}function I(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function L(e,t){let n=[],r=(r,i)=>{for(let[a,o]of r){let r=`color.${o}`,s=U(e,r,l);if(t(r,s)){let t=i?I(U(e,r,c)):null;n.push({name:a,text:I(s),light:t})}}};return r(p,!0),r(ne,!1),n}function R(e,t,n){return!e.tokens.has(`color.primary`)||!t.tokens.has(`color.primary`)||e.resolvedIn(`color.primary`,n)===t.resolvedIn(`color.primary`,n)?[]:z(e,n)}function z(e,t){let n=U(e,`color.primary`,t);return[{name:`--bs-primary`,text:n},{name:`--bs-primary-rgb`,text:I(n)}]}function B(e,t,n){return!_.every(n=>e.tokens.has(n)&&t.tokens.has(n))||e.resolvedIn(`color.link`,n)===t.resolvedIn(`color.link`,n)?[]:V(e,n)}function V(e,t){let n=U(e,`color.link`,t),r=U(e,`color.primary-hover`,t);return[{name:`--bs-link-color`,text:n},{name:`--bs-link-color-rgb`,text:I(n)},{name:`--bs-link-hover-color`,text:r},{name:`--bs-link-hover-color-rgb`,text:I(r)}]}function H(e){return _.every(t=>e.tokens.has(t))?[{name:`--bs-link-color`,text:`var(--color-link)`,light:`var(--color-link)`},{name:`--bs-link-color-rgb`,text:I(U(e,`color.link`,l)),light:I(U(e,`color.link`,c))},{name:`--bs-link-hover-color`,text:`var(--color-primary-hover)`,light:`var(--color-primary-hover)`},{name:`--bs-link-hover-color-rgb`,text:I(U(e,`color.primary-hover`,l)),light:I(U(e,`color.primary-hover`,c))}]:[]}function U(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`||!te.test(r))throw Error(`emitWeb: ${t}: a Bootstrap rgb triplet needs an opaque colour.`);return r}function W(e,t){let n=F(e,t?(e,n)=>!t.tokens.has(e)||!t.existsIn(e,l)||n!==j(t,e,l):(t,n)=>n!==j(e,t,c)),r=L(e,t?(e,n)=>n!==t.resolvedIn(e,l):()=>!0);if(t){let i=B(e,t,c).length>0?V(e,l):B(e,t,l);return[...n,...r,...i]}let i=f.map(([e,t])=>{let n=`var(${o(`color.${t}`)})`;return{name:e,text:n,light:n}});return[...n,...i,...r,...H(e)]}function G(e,t,n){return e.tokens.has(n)&&t.tokens.has(n)&&e.resolvedIn(n,c)!==t.resolvedIn(n,c)}function K(e,t){let n=f.filter(([n,r])=>n!==`--bs-primary`&&G(e,t,`color.${r}`)).map(([e,t])=>({name:e,text:`var(${o(`color.${t}`)})`})),r=p.filter(([n,r])=>n!==`--bs-primary-rgb`&&G(e,t,`color.${r}`)).map(([t,n])=>({name:t,text:I(U(e,`color.${n}`,c))}));return[...n,...r]}function q(e,t){return`${e} {\n${t.join(`
|
|
11
11
|
`).split(`
|
|
12
12
|
`).map(e=>e===``?e:` ${e}`).join(`
|
|
13
|
-
`)}\n}`}function
|
|
13
|
+
`)}\n}`}function J(e){return e.split(`,
|
|
14
14
|
`).map(e=>`:where(${e})`).join(`,
|
|
15
|
-
`)}function
|
|
16
|
-
`)}\n);`,
|
|
15
|
+
`)}function oe(e,t){let n=W(e,null).filter(e=>e.light!=null);if(!t)return n;let r=new Map(W(t,null).filter(e=>e.light!=null).map(e=>[e.name,e.light]));return n.filter(e=>r.get(e.name)!==e.light)}function se(e,t){if(e.length===0)return[];let n=e.map(e=>`${e.name}: ${String(e.light)};`);return[t?D:E,q(y,n),q(J(y),[`color-scheme: light;`,`color: var(--color-text);`]),q(`@media (prefers-color-scheme: dark)`,[q(b,n),q(J(b),[`color-scheme: light;`,`color: var(--color-text);`])])]}function ce(e){let t=[];for(let n=0;n<e.length;n+=6)t.push(e.slice(n,n+6).join(`, `));return[`$wui-dark-layer-names: (\n${t.map((e,n)=>` ${e}${n<t.length-1?`,`:``}`).join(`
|
|
16
|
+
`)}\n);`,S,q(`html`,[`@each $name in $wui-dark-layer-names {`,` --wui-light-#{$name}: var(--#{$name});`,`}`]),q(x,[`@each $name in $wui-dark-layer-names {`,` --#{$name}: var(--wui-light-#{$name});`,`}`]),q(J(x),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
|
|
17
17
|
|
|
18
|
-
`)}function
|
|
18
|
+
`)}function le(e){return[C,q(`html`,e.map(e=>`--wui-light-${e}: var(--${e});`)),q(x,e.map(e=>`--${e}: var(--wui-light-${e});`)),q(J(x),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
|
|
19
19
|
|
|
20
|
-
`)}function
|
|
20
|
+
`)}function Y(e,t,n=!1){let{package:r,version:i,brand:a}=e.source,o=t?`Generated by ${r} ${i} for the ${a} brand. Do not edit; run webority brand.`:`Generated by ${r} ${i} from its token source. Do not edit; run webority brand --library.`;return n?`/* ${o} */`:`// ${o}`}function X(e,r){let i=P(e),o=new Map((r?P(r):[]).map(e=>[e.path,e])),s=[],l=i.filter(e=>o.get(e.path)?.root!==e.root).map(e=>`${e.name}: ${e.root};`);r&&(l.push(...R(e,r,c).map(e=>`${e.name}: ${e.text};`)),l.push(...B(e,r,c).map(e=>`${e.name}: ${e.text};`)),l.push(...K(e,r).map(e=>`${e.name}: ${e.text};`))),l.length>0&&s.push(q(`:root`,l));for(let[e,n]of Object.entries(t)){let t=[];for(let n of i)for(let r of n.tiers)r.tier===e&&o.get(n.path)?.tiers.find(t=>t.tier===e)?.text!==r.text&&t.push(`${n.name}: ${r.text};`);t.length>0&&s.push(q(`@media (min-width: ${n}px)`,[q(`:root`,t)]))}let u=[];for(let t of i){let n=k(e,t.path),i=a(n);if(i===null)continue;let o=A(n,i),s=r?.tokens.get(t.path),c=s?a(s):null;s&&c!==null&&A(s,c)===o||u.push(`${t.name}: ${o};`)}u.length>0&&s.push(q(`@media ${n}`,[q(`:root`,u)]));let d=W(e,r);if(d.length>0){let t=d.map(e=>`${e.name}: ${e.text};`),n=r?T:w;s.push(q(re,[...t,`color-scheme: dark;`]),q(v,t),`${n}\n${q(J(v),[`color-scheme: dark;`,`color: var(--color-text);`])}`);let i=d.map(e=>e.name.slice(2));if(r){let e=new Set(W(r,null).map(e=>e.name.slice(2))),t=i.filter(t=>!e.has(t));t.length>0&&s.push(le(t))}else s.push(ce(i));s.push(q(`@media (prefers-color-scheme: dark)`,[q(ie,[...t,`color-scheme: dark;`])])),s.push(...se(oe(e,r),r!==null))}return`${[Y(e,r!==null,r!==null),...s].join(`
|
|
21
21
|
|
|
22
|
-
`)}\n`}function
|
|
23
|
-
`)}\n`}function
|
|
24
|
-
`)}\n`}function
|
|
22
|
+
`)}\n`}function Z(e,t){let n=k(e,t);if(n.type===`color`)return String(e.resolvedIn(t,c));let r=e.valueIn(t,c),i=(typeof r==`string`?ee.exec(r):null)?.[1];if(i!==void 0)return Z(e,i);let a=A(n,r);if(a.includes(`var(`))throw Error(`emitWeb: ${t}: a Bootstrap variable needs a literal.`);return a}function Q(e,t,n){return n===null?g[t]:Z(e,n)}function $(e){let t=m.map(([t,n])=>`${t}: ${String(Q(e,t,n))} !default;`);return`${[Y(e,!1),...t].join(`
|
|
23
|
+
`)}\n`}function ue(e,t){let n=[...h,...m].filter(([n,r])=>Q(e,n,r)!==Q(t,n,r)).map(([t,n])=>`${t}: ${String(Q(e,t,n))};`);return`${[Y(e,!0),...n].join(`
|
|
24
|
+
`)}\n`}function de(e,t){return t===void 0?{tokens:X(e,null),bootstrap:$(e)}:{css:X(e,t.library),variables:ue(e,t.library)}}export{de as emitWeb};
|
package/dist/guards.d.ts
ADDED
package/dist/guards.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e instanceof Error?e.message:String(e)}function t(e){return typeof e==`object`&&!!e}function n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{t as isObjectLike,n as isRecord,e as messageOf};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type { RenameTable, RetiredThemeRead } from "../renames/renames";
|
|
2
|
-
export type { BrandLayer, Deviations, LibrarySources } from "./brand";
|
|
3
|
-
export { BRAND_OUTPUT_FILES, HEAD_FOLDER, loadBrand } from "./brand";
|
|
4
|
-
export type * from "./cli";
|
|
5
|
-
export { brand, check, run, upgrade } from "./cli";
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
export type { RenameTable, RetiredThemeRead } from "../renames/renames.d.ts";
|
|
2
|
+
export type { BrandLayer, Deviations, LibrarySources } from "./brand.ts";
|
|
3
|
+
export { BRAND_OUTPUT_FILES, HEAD_FOLDER, loadBrand } from "./brand.ts";
|
|
4
|
+
export type * from "./cli.ts";
|
|
5
|
+
export { brand, check, run, upgrade } from "./cli.ts";
|
|
6
|
+
export { cssVar } from "./names.ts";
|
|
7
|
+
export type * from "./outputs.ts";
|
package/dist/meanings.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Lookup = (name: string) => string | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* @param value
|
|
4
|
+
* @param lookup returns the raw value of a custom property name such as "--wui-blue-500", or undefined
|
|
5
|
+
* @returns #rrggbb, or #rrggbbaa when the alpha is below 1
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveColour(value: string, lookup: Lookup): string;
|
|
8
|
+
export {};
|
package/dist/model/colour.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{present as e}from"../present.js";function t(e,t){let n=[],r=0,i=null,a=0;for(let o=0;o<e.length;o++){let s=e[o];i?s===`\\`?o++:s===i&&(i=null):s===`"`||s===`'`?i=s:s===`(`||s===`[`?r++:s===`)`||s===`]`?r--:s===t&&r===0&&(n.push(e.slice(a,o)),a=o+1)}return n.push(e.slice(a)),n}var n=10,r=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,i=/^rgba?\(([\s\S]*)\)$/i,a=/^color-mix\(([\s\S]*)\)$/i,o=/^var\(([\s\S]*)\)$/i;function s(l,u,f=0){if(f>n)return null;let p=l.trim(),m=o.exec(p);if(m){let n=t(e(m[1],`the var() arguments`),`,`),r=e(n[0],`the var() name`).trim();if(!/^--[a-z0-9-]+$/i.test(r))return null;let i=u(r);if(i!==void 0)return s(i,u,f+1);let a=n.slice(1).join(`,`).trim();return a?s(a,u,f+1):null}let h=r.exec(p);if(h){let t=e(h[1],`the hex colour digits`);t.length<=4&&(t=[...t].map(e=>e+e).join(``)),t.length===6&&(t+=`ff`);let n=e=>Number.parseInt(t.slice(e,e+2),16);return[n(0),n(2),n(4),n(6)/255]}let g=i.exec(p);if(g)return c(e(g[1],`the rgb() arguments`));let _=a.exec(p);if(_)return d(e(_[1],`the color-mix() arguments`),u,f);let v=p.toLowerCase();return v===`white`?[255,255,255,1]:v===`black`?[0,0,0,1]:v===`transparent`?[0,0,0,0]:null}function c(n){let r=n.trim(),i,a=t(r,`/`);if(a.length>2)return null;a.length===2&&(r=e(a[0],`the colour before the alpha slash`).trim(),i=e(a[1],`the alpha after the slash`).trim());let o=t(r,`,`).flatMap(e=>e.trim().split(/\s+/)).filter(Boolean);if(o.length!==3&&o.length!==4)return null;let s=o.slice(0,3).map(e=>/^-?\d*\.?\d+$/.test(e)?Math.min(255,Math.max(0,Number(e))):null).filter(e=>e!==null);if(s.length!==3)return null;if(o.length===4){if(i!==void 0)return null;i=e(o[3],`the alpha channel`)}let c=i===void 0?1:l(i);return c===null?null:[e(s[0],`the red channel`),e(s[1],`the green channel`),e(s[2],`the blue channel`),c]}function l(e){let t=e.trim(),n=/^(-?\d*\.?\d+)%$/.exec(t);return n?Math.min(1,Math.max(0,Number(n[1])/100)):/^-?\d*\.?\d+$/.test(t)?Math.min(1,Math.max(0,Number(t))):null}function u(t){let n=t.trim(),r=/\s+(-?\d*\.?\d+)%$/.exec(n);if(!r)return{colour:n};let i=n.slice(0,r.index).trim();return i?{colour:i,percent:Number(e(r[1],`the mix percentage`))}:null}function d(n,r,i){let a=t(n,`,`);if(a.length!==3||!/^in\s+srgb$/i.test(e(a[0],`the colour-space argument`).trim()))return null;let o=u(e(a[1],`the first mix argument`)),c=u(e(a[2],`the second mix argument`));if(!o||!c)return null;let l=s(o.colour,r,i+1),d=s(c.colour,r,i+1);if(!l||!d)return null;let f=o.percent,p=c.percent,m,h,g=1;if(f===void 0&&p===void 0)m=50,h=50;else if(p===void 0)m=f??0,h=100-m;else if(f===void 0)h=p,m=100-h;else if(m=f,h=p,m+h!==100){let e=m+h;e>0?(e<100&&(g=e/100),m=m*100/e,h=h*100/e):(m=0,h=0)}let _=m/100,v=h/100,y=l[3]*_+d[3]*v,b=e=>y===0?0:(l[e]*l[3]*_+d[e]*d[3]*v)/y;return[b(0),b(1),b(2),y*g]}function f(e){let t=e.slice(0,3).map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``),n=Math.round(Math.min(1,Math.max(0,e[3]))*255);return`#${t}${n<255?n.toString(16).padStart(2,`0`):``}`}function p(e,t){let n=s(e,t,0);if(n===null)throw Error(`colour "${e}" does not resolve to a colour.`);return f(n)}export{p as resolveColour};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JsonObject } from "../brand.ts";
|
|
2
|
+
import type { Model } from "./index.ts";
|
|
3
|
+
/** Margin over WCAG AA 4.5:1, so rounding to a hex never lands under it; equal to mobile-ui's TARGET. */
|
|
4
|
+
export declare const READABLE_TARGET: number;
|
|
5
|
+
/**
|
|
6
|
+
* @param a opaque #rrggbb
|
|
7
|
+
* @param b opaque #rrggbb
|
|
8
|
+
*/
|
|
9
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* The fill as a solid under its label at READABLE_TARGET: unchanged when the pair reads or either value is not #rrggbb;
|
|
12
|
+
* otherwise its HSL lightness moves away from the label in 0.0025 steps, hue and saturation kept.
|
|
13
|
+
* @returns lowercase #rrggbb, or fill as given when it is not #rrggbb
|
|
14
|
+
*/
|
|
15
|
+
export declare function deriveSolidFill(fill: string, on: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The phone-only brand layer that makes each mode's primary fill read under its label. A mode whose fill and label
|
|
18
|
+
* equal the library's, or whose pair already reads, gets nothing.
|
|
19
|
+
* @param model the branded model
|
|
20
|
+
* @param library the library model
|
|
21
|
+
* @returns DTCG trees, each {} or { color: { primary: { $type: "color", $value } } }
|
|
22
|
+
*/
|
|
23
|
+
export declare function phonePairLayer(model: Model, library: Model): {
|
|
24
|
+
light: JsonObject;
|
|
25
|
+
dark: JsonObject;
|
|
26
|
+
};
|
package/dist/model/contrast.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=4.55,t=/^#[0-9a-f]{6}$/i,n=.0025,r=e=>{let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]},i=e=>{let
|
|
1
|
+
var e=4.55,t=/^#[0-9a-f]{6}$/i,n=.0025,r=e=>{let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]},i=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},a=e=>{let[t,n,a]=r(e);return .2126*i(t)+.7152*i(n)+.0722*i(a)},o=e=>{let[t,n,i]=r(e),a=t/255,o=n/255,s=i/255,c=Math.max(a,o,s),l=Math.min(a,o,s),u=c-l,d=(c+l)/2;if(u===0)return[0,0,d];let f=d>.5?u/(2-c-l):u/(c+l);return[(c===a?((o-s)/u+6)%6:c===o?(s-a)/u+2:(a-o)/u+4)*60,f,d]},s=([e,t,n])=>{let r=t*Math.min(n,1-n),i=t=>{let i=(t+e/30)%12,a=n-r*Math.max(-1,Math.min(i-3,9-i,1));return Math.round(a*255).toString(16).padStart(2,`0`)};return`#${i(0)}${i(8)}${i(4)}`.toUpperCase()},c=(e,t,r)=>{let[i,a,c]=o(e),l=e;for(let e=c+t*n;e>=0&&e<=1;e+=t*n)if(l=s([i,a,e]),r(l))return l;return l};function l(e,t){let n=a(e),r=a(t),i=Math.max(n,r),o=Math.min(n,r);return(i+.05)/(o+.05)}function u(n,r){if(!t.test(n)||!t.test(r))return n;let i=t=>l(t,r)>=e;return i(n)?n.toLowerCase():c(n,a(r)>a(n)?-1:1,i).toLowerCase()}function d(e,t){let n={};for(let r of[`light`,`dark`]){let i={mode:r,platform:`phone`,width:null};if(![`color.primary`,`color.on-primary`].every(n=>e.existsIn(n,i)&&t.existsIn(n,i)))continue;let a=String(e.resolvedIn(`color.primary`,i)),o=String(e.resolvedIn(`color.on-primary`,i));if(a===t.resolvedIn(`color.primary`,i)&&o===t.resolvedIn(`color.on-primary`,i))continue;let s=u(a,o);s!==a.toLowerCase()&&(n[r]={color:{primary:{$type:`color`,$value:s}}})}return{light:n.light??{},dark:n.dark??{}}}export{e as READABLE_TARGET,l as contrastRatio,u as deriveSolidFill,d as phonePairLayer};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { BrandInput } from "./load.ts";
|
|
2
|
+
export type Mode = "light" | "dark";
|
|
3
|
+
export type Platform = "web" | "phone";
|
|
4
|
+
export interface Context {
|
|
5
|
+
mode: Mode;
|
|
6
|
+
platform: Platform;
|
|
7
|
+
width: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface Token {
|
|
10
|
+
/** dotted path, such as "color.text-muted" */
|
|
11
|
+
path: string;
|
|
12
|
+
/** first segment */
|
|
13
|
+
group: string;
|
|
14
|
+
/** the rest joined with hyphens */
|
|
15
|
+
name: string;
|
|
16
|
+
/** $type, inherited from the group when the token has none */
|
|
17
|
+
type: string;
|
|
18
|
+
description: string | null;
|
|
19
|
+
/** null when the token has no mark */
|
|
20
|
+
platforms: Platform[] | null;
|
|
21
|
+
internal: boolean;
|
|
22
|
+
/** true only for a token a brand file declares that the library does not */
|
|
23
|
+
brandOwn: boolean;
|
|
24
|
+
/** the com.webority object, empty when absent */
|
|
25
|
+
extensions: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface Model {
|
|
28
|
+
/** every path declared by the base set (and the brand file) */
|
|
29
|
+
tokens: Map<string, Token>;
|
|
30
|
+
/** light and dark x web at 1440 and 390, and light and dark x phone */
|
|
31
|
+
contexts: Context[];
|
|
32
|
+
existsIn: (path: string, context: Context) => boolean;
|
|
33
|
+
/** $value after overrides, references kept */
|
|
34
|
+
valueIn: (path: string, context: Context) => unknown;
|
|
35
|
+
/** references followed, color-mix computed */
|
|
36
|
+
resolvedIn: (path: string, context: Context) => unknown;
|
|
37
|
+
/** the first "{a.b}" the value names, as "a.b"; emitters never parse value strings */
|
|
38
|
+
referenceIn: (path: string, context: Context) => string | undefined;
|
|
39
|
+
source: {
|
|
40
|
+
package: string;
|
|
41
|
+
version: string;
|
|
42
|
+
brand: string | null;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Loads, validates and indexes the source. Throws one Error listing every refusal.
|
|
47
|
+
* With a brand, the layer's base overrides every mode and its dark overrides the dark context only.
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadModel(options?: {
|
|
50
|
+
resolverPath?: string;
|
|
51
|
+
brand?: BrandInput;
|
|
52
|
+
}): Promise<Model>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Token } from "./index.ts";
|
|
2
|
+
type Tier = "md" | "lg" | "xl";
|
|
3
|
+
export declare const BREAKPOINT_PX: Readonly<Record<Tier, number>>;
|
|
4
|
+
export declare const TOUCH_MEDIA: string;
|
|
5
|
+
/**
|
|
6
|
+
* @returns the touch value, or null when the token has none
|
|
7
|
+
*/
|
|
8
|
+
export declare function touchValue(token: Pick<Token, "extensions">): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a rem length, or a clamp() that scales linearly from `at390Px` at 390px to `at1440Px` at `fluidUntilPx`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fluidLength(at390Px: number, at1440Px: number, fluidUntilPx?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* @returns each tier the token sets, in md, lg, xl order
|
|
15
|
+
*/
|
|
16
|
+
export declare function breakpointRules(token: Pick<Token, "extensions">): {
|
|
17
|
+
tier: string;
|
|
18
|
+
px: number;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
export {};
|
package/dist/model/length.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
import{isRecord as e}from"../guards.js";var t={md:768,lg:992,xl:1200},n=`(max-width: 575.98px), (pointer: coarse)`,r=e=>Object.hasOwn(t,e);function i(e){return e.extensions?.touch??null}function a(e){return String(Number(e.toFixed(4)))}function o(e,t,n=1440){let r=e,i=t,o=n;if(!(o>390&&o<=1440))throw Error(`fluidUntil ${o} must be above 390 and at most 1440.`);if(r===i)return`${a(i/16)}rem`;let s=(i-r)/(o-390),c=`${a((r-s*390)/16)}rem ${s<0?`-`:`+`} ${a(Math.abs(s)*100)}vw`;return`clamp(${a(Math.min(r,i)/16)}rem, ${c}, ${a(Math.max(r,i)/16)}rem)`}function s(n){let i=n.extensions?.breakpoints;if(i==null)return[];if(!e(i))throw Error(`breakpoints must be an object of md, lg or xl values.`);for(let e of Object.keys(i))if(!Object.hasOwn(t,e))throw Error(`breakpoint "${e}" is not a tier; use md, lg or xl.`);return Object.keys(t).filter(r).filter(e=>Object.hasOwn(i,e)).map(e=>{let n=i[e];if(typeof n!=`string`)throw Error(`breakpoint "${e}" must be a length string.`);return{tier:e,px:t[e],value:n}})}export{t as BREAKPOINT_PX,n as TOUCH_MEDIA,s as breakpointRules,o as fluidLength,i as touchValue};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BrandLayer } from "../brand.ts";
|
|
2
|
+
import type { Token } from "./index.ts";
|
|
3
|
+
export type BrandInput = Omit<BrandLayer, "email"> & {
|
|
4
|
+
email?: BrandLayer["email"];
|
|
5
|
+
};
|
|
6
|
+
export interface Entry {
|
|
7
|
+
value: unknown;
|
|
8
|
+
file: string;
|
|
9
|
+
}
|
|
10
|
+
export type Layer = Map<string, Entry>;
|
|
11
|
+
export interface Sources {
|
|
12
|
+
tokens: Map<string, Token>;
|
|
13
|
+
layers: {
|
|
14
|
+
base: Layer;
|
|
15
|
+
dark: Layer;
|
|
16
|
+
phone: Layer;
|
|
17
|
+
width390: Layer;
|
|
18
|
+
brandBase: Layer;
|
|
19
|
+
brandDark: Layer;
|
|
20
|
+
brandPhoneLight: Layer;
|
|
21
|
+
brandPhoneDark: Layer;
|
|
22
|
+
};
|
|
23
|
+
cssNames: Map<string, string>;
|
|
24
|
+
source: {
|
|
25
|
+
package: string;
|
|
26
|
+
version: string;
|
|
27
|
+
brand: string | null;
|
|
28
|
+
};
|
|
29
|
+
refusals: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function line(file: string, path: string, rule: string, fix: string): string;
|
|
32
|
+
export declare function readSources(resolverPath: string, brand: BrandInput | undefined): Promise<Sources>;
|
package/dist/model/load.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__toESM as e}from"../_virtual/_rolldown/runtime.js";import{require__2020 as t}from"../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";import{STEPS as
|
|
1
|
+
import{__toESM as e}from"../_virtual/_rolldown/runtime.js";import{require__2020 as t}from"../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";import{messageOf as n}from"../guards.js";import{STEPS as r,cssVarOfPath as i}from"../names.js";import{present as a}from"../present.js";import{readFile as o}from"node:fs/promises";import{basename as s,dirname as c,resolve as l}from"node:path";var u=e(t(),1),d=new URL(`../../package.json`,import.meta.url),f=new URL(`../../schema/webority-tokens.schema.json`,import.meta.url),p=`Declare each token in one source file.`;function m(e,t,n,r){return`${e}: ${t}: ${n}. ${r}`}function h(e,t){e.includes(t)||e.push(t)}function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _(e){return g(e)&&typeof e.$ref==`string`}function v(e){return Array.isArray(e)&&e.every(e=>e===`web`||e===`phone`)}var y=e=>Object.hasOwn(r,e);function b(e){let t=e.$extensions;if(!g(t))return{};let n=t[`com.webority`];return g(n)?n:{}}function x(e){let t=[],n=(e,r,i)=>{for(let[a,o]of Object.entries(e)){if(a.startsWith(`$`)||!g(o))continue;let e=[...r,a],s=typeof o.$type==`string`?o.$type:i.type,c={...i.extensions,...b(o)};`$value`in o?t.push({path:e.join(`.`),token:o,type:s,extensions:c}):n(o,e,{type:s,extensions:c})}};return n(e,[],{type:void 0,extensions:{}}),t}function S(e,t){let[n,...r]=e.path.split(`.`),i=e.extensions;return{path:e.path,group:a(n,`the token group`),name:r.join(`-`),type:t,description:typeof e.token.$description==`string`?e.token.$description:null,platforms:v(i.platforms)?i.platforms:null,internal:i.internal===!0,brandOwn:!1,extensions:i}}function C(e,t,n,a){let{path:o,group:s,name:c}=e,l;try{l=i(o)}catch{h(n,m(t,o,`its group ${s} has no CSS prefix`,`Add the group to PREFIX in names.ts.`))}if(y(s)&&!r[s].includes(c)&&h(n,m(t,o,`"${c}" is not a step of ${s}`,`Use one of: ${r[s].join(`, `)}.`)),l!==void 0){let e=a.get(l);e===void 0?a.set(l,o):e!==o&&h(n,m(t,o,`its CSS name ${l} is also the name of ${e}`,`Rename one of the two tokens.`))}}function w(e,t,n,r){let i={...e.extensions};return(i.platforms!==void 0||i.internal!==void 0)&&(h(r,m(t,e.path,`changes the platforms or internal mark`,`Set marks in the base set only.`)),delete i.platforms,delete i.internal),Object.assign(n.extensions,i),{value:e.token.$value,file:t}}function T(e,t,n){h(e,m(t,n,`overrides a token the base set does not declare`,`Declare ${n} in the base set first.`))}function E(e,t,n){let r=new Map;for(let{ref:i,data:a}of e)if(a)for(let e of x(a)){let a=t.get(e.path);a?r.set(e.path,w(e,i,a,n)):T(n,i,e.path)}return r}async function D(e,t){let r=s(e),i=[],v=c(e),y;try{y=JSON.parse(await o(e,`utf8`))}catch(e){throw Error(m(r,`(file)`,`cannot be read as JSON (${n(e)})`,`Restore the file or correct its path.`))}if(!Array.isArray(y.sets)||y.sets.length===0||!y.sets.every(e=>g(e)&&Array.isArray(e.sources)&&e.sources.every(_)))throw Error(m(r,`sets`,`must be a non-empty array of { sources: [{ "$ref": string }] }`,`Match the resolver of the library source.`));if(!Array.isArray(y.modifiers))throw Error(m(r,`modifiers`,`must be an array`,`Match the resolver of the library source.`));let b=y.sets,D=y.modifiers,O=[[`mode`,[`light`,`dark`]],[`platform`,[`web`,`phone`]],[`width`,[`1440`,`390`]]];if(D.length!==O.length)throw Error(m(r,`modifiers`,`must hold the mode, platform and width modifiers, in that order`,`Match the resolver of the library source.`));let ee=e=>Array.isArray(e)&&e.length===0;O.forEach(([e,t],n)=>{let i=D[n],o=g(i)&&g(i.contexts)?i.contexts:void 0,s=o===void 0?``:Object.keys(o).sort().join(`,`);if(!(g(i)&&o!==void 0&&i.name===e&&s===[...t].sort().join(`,`)&&t.every(e=>{let t=o[e];return Array.isArray(t)&&t.every(_)})&&ee(o[a(t[0],`the default context of the ${e} modifier`)])))throw Error(m(r,`modifiers.${e}`,`is not the ${e} modifier with the contexts ${t.join(`, `)} and an empty list for ${t[0]}`,`Match the resolver of the library source, whose default context lists no file.`))});let k=(e,t)=>a(D.find(t=>t.name===e),`the ${e} modifier`).contexts[t],A=b.flatMap(e=>e.sources.map(e=>e.$ref)),j=k(`mode`,`dark`).map(e=>e.$ref),M=k(`platform`,`phone`).map(e=>e.$ref),N=k(`width`,`390`).map(e=>e.$ref),P=JSON.parse(await o(f,`utf8`)),F=new u.default({allErrors:!0,strict:!1});F.addSchema(P);let I=F.compile(P),L=F.getSchema(`${P.$id}#/$defs/sourceMeaning`);if(!L)throw Error(`webority-tokens: the schema has no sourceMeaning definition.`);let R=new Map,z=async e=>{let t=l(v,e);if(R.has(t))return a(R.get(t),`the cached file ${t}`);let r;try{r=JSON.parse(await o(t,`utf8`))}catch(r){return h(i,m(e,`(file)`,`cannot be read as JSON (${n(r)})`,`Restore the file or correct its $ref in the resolver.`)),R.set(t,null),null}let c=[];I(r)||c.push(...I.errors??[]),s(t)===`meaning.tokens.json`&&!L(r)&&c.push(...L.errors??[]);for(let t of c){if(t.keyword===`if`)continue;let n=t.instancePath.slice(1).split(`/`).filter(e=>e!==``),r=n.length===0?`(file)`:n.map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)).join(`.`),a=t.params?.additionalProperty??t.params?.propertyName,o=a===void 0?String(t.message):`${String(t.message)} "${a}"`;h(i,m(e,r,o,`Correct it against schema/webority-tokens.schema.json.`))}return R.set(t,r),r},B=async e=>Promise.all(e.map(async e=>({ref:e,data:await z(e)}))),V=await B(A),H=await B(j),U=await B(M),W=await B(N),G=new Map,K=new Map,q=new Map;for(let{ref:e,data:t}of V)if(t)for(let n of x(t)){if(G.has(n.path)){h(i,m(e,n.path,`is already declared in ${a(q.get(n.path),`the base entry at ${n.path}`).file}`,p));continue}if(n.type===void 0||n.type===``){h(i,m(e,n.path,`has no $type`,`Add $type to the token or to its group.`));continue}let t=S(n,n.type);C(t,e,i,K),G.set(n.path,t),q.set(n.path,{value:n.token.$value,file:e})}let J=E(H,G,i),te=E(U,G,i),ne=E(W,G,i),Y=new Map,X=new Map,Z=new Map,Q=new Map;if(t){let e=`brand ${t.name}`;for(let n of x(t.base)){let t=G.get(n.path);if(t){Y.set(n.path,w(n,e,t,i));continue}if(n.type===void 0||n.type===``){h(i,m(e,n.path,`has no $type`,`Add $type to the token or to its group.`));continue}let r=S(n,n.type);C(r,e,i,K),r.brandOwn=!0,G.set(n.path,r),Y.set(n.path,{value:n.token.$value,file:e})}for(let n of x(t.dark)){let t=G.get(n.path);t?X.set(n.path,w(n,e,t,i)):T(i,e,n.path)}let n=[[t.phone?.light,Z],[t.phone?.dark,Q]];for(let[t,r]of n)if(g(t))for(let n of x(t)){let t=G.get(n.path);t?r.set(n.path,w(n,e,t,i)):T(i,e,n.path)}}let $=JSON.parse(await o(d,`utf8`)),re={package:$.name,version:$.version,brand:t?.name??null};return{tokens:G,layers:{base:q,dark:J,phone:te,width390:ne,brandBase:Y,brandDark:X,brandPhoneLight:Z,brandPhoneDark:Q},cssNames:K,source:re,refusals:i}}export{m as line,D as readSources};
|
package/dist/model/references.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{isRecord as e}from"../guards.js";import{present as t}from"../present.js";function n(r){return typeof r==`string`?[...r.matchAll(/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g)].map(e=>t(e[1],`the match's group name`)):Array.isArray(r)?r.flatMap(n):e(r)?Object.values(r).flatMap(n):[]}function r(n,i){if(typeof n==`string`){let e=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/.exec(n);return e?i(t(e[1],`the whole match's group name`),!0):n.replace(/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,(e,t)=>String(i(t,!1)))}return Array.isArray(n)?n.map(e=>r(e,i)):e(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,r(t,i)])):n}function i(e){let t=[],n=new Set,r=new Set,i=[],a=new Set,o=s=>{i.push(s),a.add(s);for(let c of e.get(s)??[])if(e.has(c)){if(a.has(c)){let e=[...i.slice(i.indexOf(c)),c],r=[...new Set(e)].sort().join(`,`);n.has(r)||(n.add(r),t.push(e))}else r.has(c)||o(c)}i.pop(),a.delete(s),r.add(s)};for(let t of e.keys())r.has(t)||o(t);return t}export{i as findCycles,r as mapReferences,n as referencesIn};
|
package/dist/model/resolve.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`));return{tokens:
|
|
1
|
+
import{messageOf as e}from"../guards.js";import{cssVarOfPath as t}from"../names.js";import{present as n}from"../present.js";import{resolveColour as r}from"./colour.js";import{line as i}from"./load.js";import{findCycles as a,mapReferences as o,referencesIn as s}from"./references.js";function c(){return[{mode:`light`,platform:`web`,width:1440},{mode:`dark`,platform:`web`,width:1440},{mode:`light`,platform:`web`,width:390},{mode:`dark`,platform:`web`,width:390},{mode:`light`,platform:`phone`,width:null},{mode:`dark`,platform:`phone`,width:null}]}function l(e){return`${e.mode}|${e.platform}|${e.width}`}function u(e,t,n){if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`value`in e&&`unit`in e)return`${e.value}${e.unit}`;throw Error(`model: ${t} cannot sit inside the text of ${n}`)}function d({tokens:d,layers:f,cssNames:p,source:m,refusals:h}){let g=c(),_=e=>{let t=g.find(t=>t.mode===e.mode&&t.platform===e.platform&&t.width===e.width);if(!t)throw Error(`model: ${JSON.stringify(e)} is not one of the model's contexts`);return t},v=e=>{let t=[f.base];return e.mode===`dark`&&t.push(f.dark),e.platform===`phone`&&t.push(f.phone),e.platform===`web`&&e.width===390&&t.push(f.width390),t.push(f.brandBase),e.mode===`dark`&&t.push(f.brandDark),e.platform===`phone`&&t.push(e.mode===`dark`?f.brandPhoneDark:f.brandPhoneLight),t},y=new Set([f.brandBase,f.brandDark,f.brandPhoneLight,f.brandPhoneDark]),b=(e,t,r)=>r.platform===`phone`&&y.has(e)&&t.startsWith(`font.`)&&!n(d.get(t),`the token at ${t}`).extensions.faces,x=(e,t)=>{let n=v(t).reverse();for(let r of n){if(b(r,e,t)||r===f.brandBase&&t.mode===`dark`&&f.dark.has(e))continue;let n=r.get(e);if(n)return n}},S=(e,t)=>n(x(e,t),`the entry for ${e}`),C=(e,t)=>{let n=d.get(e);return n?n.platforms===null||n.platforms.includes(t.platform):!1},w=(e,t)=>{if(!C(e,t))throw Error(`model: ${e} does not exist on ${t.platform}`)},T=new Map,E=(e,i)=>{let a=`${l(i)}|${e}`;if(T.has(a))return T.get(a);w(e,i);let s=n(d.get(e),`the token at ${e}`),{value:c}=S(e,i),f;if(s.type===`color`){if(typeof c!=`string`)throw Error(`model: ${e} is a colour with a value that is not text`);if(s.extensions.derive)throw Error(`model: ${e} uses derive, which is removed; set the colour itself`);let n=String(o(c,e=>`var(${t(e)})`));f=r(n,e=>D(e,i))}else f=o(c,(t,n)=>{let r=E(t,i);return n?r:u(r,t,e)});return T.set(a,f),f},D=(e,t)=>{let r=p.get(e);if(r===void 0||!C(r,t))return;if(n(d.get(r),`the token at ${r}`).type===`color`){let e=E(r,t);return typeof e==`string`?e:void 0}let{value:i}=S(r,t);return typeof i==`string`?i:void 0},O=()=>{for(let e of Object.values(f))for(let[t,n]of e)for(let e of s(n.value))if(!d.has(e)){let r=i(n.file,t,`references ${e}, which no token declares`,`Declare ${e} or correct the name.`);h.includes(r)||h.push(r)}},k=()=>{for(let e of g){let t=new Map;for(let n of d.keys())C(n,e)&&t.set(n,s(S(n,e).value));for(let r of a(t)){let t=n(r[0],`the first token of the cycle`),a=i(S(t,e).file,t,`reference cycle ${r.join(` -> `)}`,`Point one of these tokens at a value instead.`);h.includes(a)||h.push(a)}}},A=()=>{for(let e of g)for(let t of d.keys()){if(!C(t,e))continue;let{file:n,value:r}=S(t,e);for(let a of s(r))if(d.has(a)&&!C(a,e)){let r=i(n,t,`references ${a}, which does not exist on ${e.platform}`,`Mark ${t} for the platform that has ${a}, or give ${t} a ${e.platform} override.`);h.includes(r)||h.push(r)}}},j=()=>{for(let t of g)for(let n of d.keys())if(C(n,t))try{E(n,t)}catch(r){let a=i(S(n,t).file,n,e(r).replace(/\.$/,``),`Correct the value or the tokens it references.`);h.includes(a)||h.push(a)}},M=h.length;O();let N=h.length>M;if(N||k(),N||A(),h.length===0&&j(),h.length>0)throw Error(h.join(`
|
|
2
|
+
`));return{tokens:d,contexts:c(),existsIn:(e,t)=>C(e,_(t)),valueIn:(e,t)=>{let n=_(t);return w(e,n),structuredClone(S(e,n).value)},resolvedIn:(e,t)=>{let n=_(t);return structuredClone(E(e,n))},referenceIn:(e,t)=>{let n=_(t);return w(e,n),s(S(e,n).value)[0]},source:m}}export{c as buildContexts,d as buildModel};
|
package/dist/names.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const STEPS: {
|
|
3
|
-
readonly space: readonly string[];
|
|
4
|
-
readonly radius: readonly string[];
|
|
5
|
-
readonly text: readonly string[];
|
|
6
|
-
readonly weight: readonly string[];
|
|
7
|
-
readonly "letter-spacing": readonly string[];
|
|
8
|
-
readonly leading: readonly string[];
|
|
9
|
-
};
|
|
10
|
-
|
|
1
|
+
export declare const STEPS: Readonly<Record<"space" | "radius" | "text" | "weight" | "letter-spacing" | "leading", readonly string[]>>;
|
|
11
2
|
export declare function cssVar(group: string, name: string): string;
|
|
12
|
-
|
|
13
3
|
export declare function cssVarOfPath(path: string): string;
|
package/dist/names.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
import{present as e}from"./present.js";var t={palette:`--wui-`,color:`--color-`,effect:`--wui-`,space:`--wui-space-`,radius:`--wui-radius-`,text:`--wui-fs-`,weight:`--wui-fw-`,leading:`--wui-lh-`,"letter-spacing":`--wui-letter-spacing-`,font:`--wui-font-`,shadow:`--wui-shadow-`,motion:`--wui-`,section:`--wui-section-`,size:`--wui-`,z:`--wui-z-`,component:`--wui-`},n={space:[`none`,`xxs`,`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`4xl`],radius:[`none`,`sm`,`md`,`lg`,`xl`,`pill`],text:[`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`,`7xl`,`8xl`],weight:[`normal`,`medium`,`semibold`,`bold`],"letter-spacing":[`tight`,`normal`,`wide`],leading:[`heading`,`body`,`display`,`prose`,`lead`]};function r(e,n){let r=t[e];if(r===void 0)throw Error(`webority-tokens: ${e} is not a token group; add it to PREFIX in names.ts.`);return`${r}${n}`}function i(t){let[n,...i]=t.split(`.`);return r(e(n,`the token group`),i.join(`-`))}export{n as STEPS,r as cssVar,i as cssVarOfPath};
|