@apotech-os/tokens 2.0.0 → 2.1.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/index.cjs CHANGED
@@ -61,67 +61,52 @@ function defineTheme(config) {
61
61
  }
62
62
 
63
63
  // src/default-theme.ts
64
- var BRAND = "oklch(0.549 0.231 268.1)";
65
- var BRAND_DARK = "oklch(0.68 0.16 268.1)";
66
64
  var defaultTheme = defineTheme({
67
- // Figma: 8px corners on inputs and buttons.
68
- radius: "0.5rem",
69
- // Inter is the Figma typeface but the platform does not bundle it yet, so this
65
+ radius: "0.625rem",
66
+ // Inter is the WOS typeface but the platform does not bundle it, so this
70
67
  // reads as "Inter if the machine has it, system stack otherwise".
71
68
  fontSans: "Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
72
- primary: BRAND,
69
+ primary: "#041C2D",
73
70
  spaces: {
74
- crm: "oklch(0.554 0.215 268.1)",
75
- experience: "oklch(0.62 0.13 233)",
76
- influence: "oklch(0.64 0.2 350)",
77
- pilotage: "oklch(0.7 0.16 62)",
78
- proSante: "oklch(0.62 0.11 172)"
71
+ crm: "#35618A",
72
+ experience: "#5B7387",
73
+ influence: "#B5432A",
74
+ pilotage: "#FFA800",
75
+ proSante: "#3E9B77"
79
76
  },
80
77
  status: {
81
- success: "oklch(0.51 0.14 150)",
82
- pending: "oklch(0.535 0.11 75)",
83
- approved: "oklch(0.545 0.235 268.1)",
84
- blocked: "oklch(0.545 0.22 27)",
85
- paused: "oklch(0.53 0.04 268.1)",
86
- info: "oklch(0.52 0.105 233)"
78
+ success: "#1F7D54",
79
+ pending: "#9A6B12",
80
+ approved: "#35618A",
81
+ blocked: "#B5432A",
82
+ paused: "#7A8089",
83
+ info: "#5B7387"
87
84
  },
88
85
  /**
89
- * Categorical palette: five hues spread from the brand around the wheel, all at
90
- * one lightness so no series reads as "louder" than another. Every entry clears
91
- * 4.5:1 on white — well past the 3:1 WCAG asks of a graphical object.
86
+ * Categorical palette from the WOS attribution screens (sure / decl / extr /
87
+ * leak / sure-green). Every entry clears 4.5:1 on white — well past the 3:1
88
+ * WCAG asks of a graphical object.
92
89
  */
93
- charts: [
94
- "oklch(0.55 0.2 268.1)",
95
- "oklch(0.55 0.09 196)",
96
- "oklch(0.55 0.15 150)",
97
- "oklch(0.55 0.115 70)",
98
- "oklch(0.55 0.2 345)"
99
- ],
90
+ charts: ["#041C2D", "#9A6B12", "#5B7387", "#B5432A", "#1F7D54"],
100
91
  dark: {
101
- primary: BRAND_DARK,
92
+ primary: "#FFA800",
102
93
  spaces: {
103
- crm: "oklch(0.74 0.135 268.1)",
104
- experience: "oklch(0.74 0.13 233)",
105
- influence: "oklch(0.74 0.19 350)",
106
- pilotage: "oklch(0.74 0.16 62)",
107
- proSante: "oklch(0.74 0.11 172)"
94
+ crm: "#7FA8CC",
95
+ experience: "#93A9BC",
96
+ influence: "#D97B63",
97
+ pilotage: "#FFB733",
98
+ proSante: "#95DFBA"
108
99
  },
109
100
  status: {
110
- success: "oklch(0.74 0.16 150)",
111
- pending: "oklch(0.74 0.15 75)",
112
- approved: "oklch(0.74 0.135 268.1)",
113
- blocked: "oklch(0.74 0.155 27)",
114
- paused: "oklch(0.74 0.02 268.1)",
115
- info: "oklch(0.74 0.13 233)"
101
+ success: "#7ED4A6",
102
+ pending: "#D9A83E",
103
+ approved: "#7FA8CC",
104
+ blocked: "#D97B63",
105
+ paused: "#9AA1AA",
106
+ info: "#93A9BC"
116
107
  },
117
- // Same hues, lifted to ~7:1 on the dark card.
118
- charts: [
119
- "oklch(0.74 0.13 268.1)",
120
- "oklch(0.74 0.125 196)",
121
- "oklch(0.74 0.17 150)",
122
- "oklch(0.74 0.16 70)",
123
- "oklch(0.74 0.17 345)"
124
- ]
108
+ // Same hues, lifted to stay legible on the dark card.
109
+ charts: ["#7FA8CC", "#FFA800", "#93A9BC", "#D97B63", "#95DFBA"]
125
110
  }
126
111
  });
127
112
 
@@ -137,7 +122,7 @@ var TYPE_SCALE = [
137
122
  ];
138
123
  var SPACING_STEP = "0.25rem";
139
124
  var SHADOWS = {
140
- card: "0 10px 30px -8px oklch(0.2 0.03 268.1 / 0.1)"
125
+ card: "0 1px 2px rgb(4 28 45 / 0.04), 0 2px 6px rgb(4 28 45 / 0.05)"
141
126
  };
142
127
  function primitivesToCss() {
143
128
  const lines = [
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/theme.ts","../src/default-theme.ts","../src/primitives.ts","../src/dtcg.ts","../src/theme-to-css.ts"],"names":[],"mappings":";;;AAgFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,QACV,OAAA,IAAW,KAAA,IACX,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAwB,MAAA,KAAW,QAAA,IAC3C,OAAQ,MAAwB,QAAA,KAAa,QAAA;AAEjD;AASO,IAAM,aAAa,CAAC,KAAA,EAAO,YAAA,EAAc,WAAA,EAAa,YAAY,UAAU,CAAA;AAC5E,IAAM,cAAc,CAAC,SAAA,EAAW,WAAW,UAAA,EAAY,SAAA,EAAW,UAAU,MAAM,CAAA;AACzF,IAAM,WAAA,GAAc,CAAA;AAEpB,SAAS,YAAA,CAAa,OAAgB,IAAA,EAAsB;AAC1D,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,IAAA,OAAW,EAAA,EAAI;AACpD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,SAAA,EAAY,IAAI,CAAA,oCAAA,CAAsC,CAAA;AAAA,EACxE;AAGA,EAAA,IAAI,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,SAAA,EAAY,IAAI,CAAA,kCAAA,CAAoC,CAAA;AAAA,EACtE;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,YAAA,CA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**\n * The configurable layer of the design system.\n *\n * Two layers exist. *Primitives* — the gray scale, the radius/spacing/type/shadow\n * scales, the neutral surfaces — are fixed by the platform and ship as static CSS.\n * The *brand/semantic* layer below is the only thing an instance may set. A client\n * can restyle the vocabulary; it cannot invent a word.\n */\n\n/** Colours that differ between the light and the dark scheme. */\nexport interface ThemeScheme {\n /**\n * Brand colour. Drives `--primary`, and `--ring` follows it.\n *\n * Its label, `--primary-foreground`, is a primitive and stays put: near-white in\n * the light scheme, near-black in the dark one. A brand that is light in light\n * mode (or dark in dark mode) therefore loses its button labels — until the\n * contract grows a paired foreground, pick a colour that fits those two.\n */\n primary: string;\n /** Per-space accents — the icon rail, space badges. */\n spaces: ThemeSpaces;\n /** Semantic status colours — runs, approvals, automations. */\n status: ThemeStatus;\n /** Categorical chart palette. Exactly five, in plot order. */\n charts: ThemeCharts;\n}\n\nexport interface ThemeSpaces {\n crm: string;\n experience: string;\n influence: string;\n pilotage: string;\n proSante: string;\n}\n\nexport interface ThemeStatus {\n success: string;\n pending: string;\n approved: string;\n blocked: string;\n paused: string;\n info: string;\n}\n\nexport type ThemeCharts = readonly [string, string, string, string, string];\n\nexport interface ThemeConfig extends ThemeScheme {\n /** Corner radius the whole scale is derived from, e.g. `0.5rem`. */\n radius: string;\n /** Body font stack. */\n fontSans: string;\n /**\n * Dark-scheme overrides. Anything left out falls back to the light value —\n * which is a legibility bug more often than a shortcut, so override on purpose.\n * `radius` and `fontSans` are absent here: they do not vary by scheme.\n */\n dark?: {\n primary?: string;\n spaces?: Partial<ThemeSpaces>;\n status?: Partial<ThemeStatus>;\n charts?: ThemeCharts;\n };\n}\n\nexport interface ResolvedTheme {\n radius: string;\n fontSans: string;\n light: ThemeScheme;\n /** Fully resolved — every key of {@link ThemeScheme}, never a partial. */\n dark: ThemeScheme;\n}\n\n/**\n * `defineTheme`'s output, as opposed to the config that still has to go through it.\n *\n * Lives here rather than in each loader: a `theme.config` module may export either\n * shape, and every loader has to tell them apart the same way or dev and prod\n * disagree on what counts as already-validated.\n */\nexport function isResolvedTheme(value: unknown): value is ResolvedTheme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'light' in value &&\n 'dark' in value &&\n typeof (value as ResolvedTheme).radius === 'string' &&\n typeof (value as ResolvedTheme).fontSans === 'string'\n );\n}\n\n/**\n * The keys of each colour group, in CSS emission order.\n *\n * Single source: validation, resolution and the DTCG generator all read these, so\n * a new token cannot be added to half the pipeline. Internal — `src/index.ts`\n * decides the public API.\n */\nexport const SPACE_KEYS = ['crm', 'experience', 'influence', 'pilotage', 'proSante'] as const;\nexport const STATUS_KEYS = ['success', 'pending', 'approved', 'blocked', 'paused', 'info'] as const;\nconst CHART_COUNT = 5;\n\nfunction requireColor(value: unknown, path: string): string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`theme: \\`${path}\\` must be a non-empty colour string`);\n }\n // The generated CSS is inlined into a <style> tag, so a value carrying markup\n // would escape it. No colour needs these characters.\n if (/[<>]/.test(value)) {\n throw new Error(`theme: \\`${path}\\` must not contain \\`<\\` or \\`>\\``);\n }\n return value;\n}\n\nfunction requireGroup(value: unknown, path: string): void {\n if (typeof value !== 'object' || value === null) {\n throw new Error(`theme: \\`${path}\\` must be an object`);\n }\n}\n\n/** One colour group, overrides layered over the base, every key checked. */\nfunction resolveGroup<K extends string>(\n keys: readonly K[],\n base: Record<K, string>,\n overrides: Partial<Record<K, string>> | undefined,\n path: string,\n): Record<K, string> {\n requireGroup(base, path);\n // A non-object override is not a partial override — it is every key silently\n // falling back to light, which is exactly the bug this package exists to stop.\n if (overrides !== undefined) requireGroup(overrides, path);\n return Object.fromEntries(\n keys.map((key) => [key, requireColor(overrides?.[key] ?? base[key], `${path}.${key}`)]),\n ) as Record<K, string>;\n}\n\nfunction resolveScheme(\n base: ThemeScheme,\n overrides: ThemeConfig['dark'],\n path: 'light' | 'dark',\n): ThemeScheme {\n const spaces = resolveGroup(SPACE_KEYS, base.spaces, overrides?.spaces, `${path}.spaces`);\n const status = resolveGroup(STATUS_KEYS, base.status, overrides?.status, `${path}.status`);\n\n const charts = overrides?.charts ?? base.charts;\n if (!Array.isArray(charts) || charts.length !== CHART_COUNT) {\n throw new Error(`theme: \\`${path}.charts\\` must hold exactly ${CHART_COUNT} colours`);\n }\n charts.forEach((value, i) => requireColor(value, `${path}.charts[${i}]`));\n\n return {\n primary: requireColor(overrides?.primary ?? base.primary, `${path}.primary`),\n spaces,\n status,\n charts,\n };\n}\n\n/**\n * Validate a theme and resolve its dark scheme against its light one.\n *\n * The type makes an unknown or missing key a compile error; the checks here make\n * it a loud runtime error too, because `theme.config.ts` is loaded as plain JS by\n * the API and TypeScript is not there to catch it.\n */\nexport function defineTheme(config: ThemeConfig): ResolvedTheme {\n if (typeof config?.radius !== 'string' || config.radius.trim() === '') {\n throw new Error('theme: `radius` must be a non-empty CSS length');\n }\n if (typeof config.fontSans !== 'string' || config.fontSans.trim() === '') {\n throw new Error('theme: `fontSans` must be a non-empty font stack');\n }\n\n if (config.dark !== undefined) requireGroup(config.dark, 'dark');\n\n const light = resolveScheme(config, undefined, 'light');\n return {\n radius: config.radius,\n fontSans: config.fontSans,\n light,\n dark: resolveScheme(light, config.dark, 'dark'),\n };\n}\n","/**\n * The theme the platform ships with — and the fallback compiled into\n * `apps/web/src/index.css`, so a failed runtime injection degrades to \"neutral\n * but usable\", never to unstyled.\n *\n * Colours are OKLCH so lightness is perceptual: the dark scheme is the same hue\n * lifted to a legible lightness, not a different palette.\n */\nimport { defineTheme } from './theme.js';\n\n/**\n * Brand blue, from the Figma source of truth (`#3B5CF5`).\n * Contrast: 4.85:1 on the light background, 4.99:1 for `--primary-foreground` on it.\n */\nconst BRAND = 'oklch(0.549 0.231 268.1)';\n/** Same hue lifted for the dark scheme: 6.07:1 on the dark card, 6.59:1 for its label. */\nconst BRAND_DARK = 'oklch(0.68 0.16 268.1)';\n\nexport const defaultTheme = defineTheme({\n // Figma: 8px corners on inputs and buttons.\n radius: '0.5rem',\n // Inter is the Figma typeface but the platform does not bundle it yet, so this\n // reads as \"Inter if the machine has it, system stack otherwise\".\n fontSans:\n \"Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\",\n\n primary: BRAND,\n\n spaces: {\n crm: 'oklch(0.554 0.215 268.1)',\n experience: 'oklch(0.62 0.13 233)',\n influence: 'oklch(0.64 0.2 350)',\n pilotage: 'oklch(0.7 0.16 62)',\n proSante: 'oklch(0.62 0.11 172)',\n },\n\n status: {\n success: 'oklch(0.51 0.14 150)',\n pending: 'oklch(0.535 0.11 75)',\n approved: 'oklch(0.545 0.235 268.1)',\n blocked: 'oklch(0.545 0.22 27)',\n paused: 'oklch(0.53 0.04 268.1)',\n info: 'oklch(0.52 0.105 233)',\n },\n\n /**\n * Categorical palette: five hues spread from the brand around the wheel, all at\n * one lightness so no series reads as \"louder\" than another. Every entry clears\n * 4.5:1 on white — well past the 3:1 WCAG asks of a graphical object.\n */\n charts: [\n 'oklch(0.55 0.2 268.1)',\n 'oklch(0.55 0.09 196)',\n 'oklch(0.55 0.15 150)',\n 'oklch(0.55 0.115 70)',\n 'oklch(0.55 0.2 345)',\n ],\n\n dark: {\n primary: BRAND_DARK,\n spaces: {\n crm: 'oklch(0.74 0.135 268.1)',\n experience: 'oklch(0.74 0.13 233)',\n influence: 'oklch(0.74 0.19 350)',\n pilotage: 'oklch(0.74 0.16 62)',\n proSante: 'oklch(0.74 0.11 172)',\n },\n status: {\n success: 'oklch(0.74 0.16 150)',\n pending: 'oklch(0.74 0.15 75)',\n approved: 'oklch(0.74 0.135 268.1)',\n blocked: 'oklch(0.74 0.155 27)',\n paused: 'oklch(0.74 0.02 268.1)',\n info: 'oklch(0.74 0.13 233)',\n },\n // Same hues, lifted to ~7:1 on the dark card.\n charts: [\n 'oklch(0.74 0.13 268.1)',\n 'oklch(0.74 0.125 196)',\n 'oklch(0.74 0.17 150)',\n 'oklch(0.74 0.16 70)',\n 'oklch(0.74 0.17 345)',\n ],\n },\n});\n","/**\n * The primitive scales — type, spacing, elevation.\n *\n * Not part of `ThemeConfig`: an instance restyles the brand, it does not redraw\n * the grid the product is built on. They live here rather than being inherited\n * from Tailwind's defaults so the platform owns them: a Tailwind upgrade cannot\n * move the product's type, and P4's generated catalogue has one place to read.\n *\n * The values are today's, deliberately. Figma's hi-fi frames use a denser scale\n * (11 / 12 / 13 / 18 / 20 / 22 px against 12 / 14 / 16 / 18 / 20 / 24) and the\n * observed figure is recorded on each step — adopting it moves every screen in\n * the product, so it is a decision with a visual audit attached, not a rename.\n * When that decision is made, it is made here.\n */\n\nexport interface TypeStep {\n /** Tailwind's `text-<key>`. */\n key: string;\n size: string;\n /** Paired line height. Tailwind reads it as `--text-<key>--line-height`. */\n lineHeight: string;\n /** What the Figma frames use at this step, for the day the scale is reconciled. */\n figmaPx?: number;\n}\n\nexport const TYPE_SCALE: readonly TypeStep[] = [\n { key: 'xs', size: '0.75rem', lineHeight: 'calc(1 / 0.75)', figmaPx: 11 },\n { key: 'sm', size: '0.875rem', lineHeight: 'calc(1.25 / 0.875)', figmaPx: 12 },\n { key: 'base', size: '1rem', lineHeight: 'calc(1.5 / 1)', figmaPx: 13 },\n { key: 'lg', size: '1.125rem', lineHeight: 'calc(1.75 / 1.125)', figmaPx: 18 },\n { key: 'xl', size: '1.25rem', lineHeight: 'calc(1.75 / 1.25)', figmaPx: 20 },\n { key: '2xl', size: '1.5rem', lineHeight: 'calc(2 / 1.5)', figmaPx: 22 },\n { key: '3xl', size: '1.875rem', lineHeight: 'calc(2.25 / 1.875)' },\n];\n\n/**\n * The step every `p-`, `gap-` and `m-` utility multiplies. Figma's frames sit on\n * the same 4px grid, so this one needs no reconciling.\n */\nexport const SPACING_STEP = '0.25rem';\n\n/**\n * Figma has exactly one card elevation, and it is cool-tinted and wide where\n * Tailwind's defaults are neutral and tight. Offered as its own token rather\n * than by overriding `--shadow-sm`, which would restyle every existing surface.\n */\nexport const SHADOWS: Readonly<Record<string, string>> = {\n card: '0 10px 30px -8px oklch(0.2 0.03 268.1 / 0.1)',\n};\n\n/**\n * The primitives as a Tailwind `@theme` block.\n *\n * `@theme`, not `:root`: these are the vocabulary Tailwind generates utilities\n * from, and unlike the brand layer they are fixed at build time.\n */\nexport function primitivesToCss(): string {\n const lines = [\n ...TYPE_SCALE.flatMap((step) => [\n `--text-${step.key}: ${step.size};`,\n `--text-${step.key}--line-height: ${step.lineHeight};`,\n ]),\n `--spacing: ${SPACING_STEP};`,\n ...Object.entries(SHADOWS).map(([key, value]) => `--shadow-${key}: ${value};`),\n ];\n return `@theme {\\n${lines.map((line) => ` ${line}`).join('\\n')}\\n}\\n`;\n}\n","/**\n * DTCG (W3C Design Tokens) as the generator's intermediate format.\n *\n * Nothing here is public API — `themeToCss` is. The point of the detour is that a\n * Figma Variables export speaks DTCG: when that lands it plugs in as another\n * producer of these groups instead of a rewrite of the CSS generator.\n *\n * Token path → CSS custom property is mechanical: kebab-case each segment and\n * join with `-`. `space.proSante` → `--space-pro-sante`, `font.sans` →\n * `--font-sans`, `chart.1` → `--chart-1`. That is why the group names below are\n * the CSS prefixes and not prettier words.\n */\nimport { SPACE_KEYS, STATUS_KEYS, type ResolvedTheme, type ThemeScheme } from './theme.js';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily';\n\nexport interface DtcgToken {\n $type: DtcgType;\n $value: string;\n}\n\nexport interface DtcgGroup {\n [key: string]: DtcgToken | DtcgGroup;\n}\n\nconst isToken = (node: DtcgToken | DtcgGroup): node is DtcgToken => '$value' in node;\n\nconst color = ($value: string): DtcgToken => ({ $type: 'color', $value });\n\nconst colorGroup = <K extends string>(keys: readonly K[], group: Record<K, string>): DtcgGroup =>\n Object.fromEntries(keys.map((key) => [key, color(group[key])]));\n\n/** Colour tokens of one scheme — the keys that must exist in both `:root` and `.dark`. */\nexport function schemeToDtcg(scheme: ThemeScheme): DtcgGroup {\n return {\n primary: color(scheme.primary),\n space: colorGroup(SPACE_KEYS, scheme.spaces),\n status: colorGroup(STATUS_KEYS, scheme.status),\n chart: Object.fromEntries(scheme.charts.map((value, i) => [String(i + 1), color(value)])),\n };\n}\n\n/** Tokens that do not vary by scheme, so they are emitted in `:root` only. */\nexport function invariantsToDtcg(theme: ResolvedTheme): DtcgGroup {\n return {\n radius: { $type: 'dimension', $value: theme.radius },\n font: { sans: { $type: 'fontFamily', $value: theme.fontSans } },\n };\n}\n\nconst kebab = (segment: string) => segment.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/** `--custom-property: value;` for every token in the group, depth-first. */\nexport function dtcgToCustomProperties(group: DtcgGroup, path: string[] = []): string[] {\n return Object.entries(group).flatMap(([key, node]) => {\n const next = [...path, kebab(key)];\n return isToken(node)\n ? [`--${next.join('-')}: ${node.$value};`]\n : dtcgToCustomProperties(node, next);\n });\n}\n","import { dtcgToCustomProperties, invariantsToDtcg, schemeToDtcg } from './dtcg.js';\nimport type { ResolvedTheme } from './theme.js';\n\n/**\n * The id carried by the `<style>` tag this CSS is inlined into — the handle the\n * live theme is found by (`document.getElementById('apotech-theme')`).\n *\n * It is a cross-process contract: the API inlines the tag in production and the\n * dev Vite plugin inlines it in `pnpm dev`, so both must spell it the same way.\n */\nexport const THEME_STYLE_ID = 'apotech-theme';\n\nconst block = (selector: string, declarations: string[]) =>\n `${selector} {\\n${declarations.map((line) => ` ${line}`).join('\\n')}\\n}`;\n\n/**\n * Render a theme as `:root { … } .dark { … }`.\n *\n * Only *values* are emitted. The `@theme inline` vocabulary that teaches Tailwind\n * about `bg-primary` and friends stays at build time in `index.css` — a client\n * restyles the words, it does not add any.\n */\nexport function themeToCss(theme: ResolvedTheme): string {\n const root = [\n ...dtcgToCustomProperties(invariantsToDtcg(theme)),\n ...dtcgToCustomProperties(schemeToDtcg(theme.light)),\n ];\n return `${block(':root', root)}\\n${block('.dark', dtcgToCustomProperties(schemeToDtcg(theme.dark)))}\\n`;\n}\n"]}
1
+ {"version":3,"sources":["../src/theme.ts","../src/default-theme.ts","../src/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CAAA,CAAA,CAAG,CAAA,GACvC,sBAAA,CAAuB,MAAM,IAAI,CAAA;AAAA,EACvC,CAAC,CAAA;AACH;;;AClDO,IAAM,cAAA,GAAiB;AAE9B,IAAM,KAAA,GAAQ,CAAC,QAAA,EAAkB,YAAA,KAC/B,GAAG,QAAQ,CAAA;AAAA,EAAO,YAAA,CAAa,GAAA,CAAI,CAAC,IAAA,KAAS,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA,CAAA;AAS/D,SAAS,WAAW,KAAA,EAA8B;AACvD,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG,sBAAA,CAAuB,gBAAA,CAAiB,KAAK,CAAC,CAAA;AAAA,IACjD,GAAG,sBAAA,CAAuB,YAAA,CAAa,KAAA,CAAM,KAAK,CAAC;AAAA,GACrD;AACA,EAAA,OAAO,CAAA,EAAG,KAAA,CAAM,OAAA,EAAS,IAAI,CAAC;AAAA,EAAK,KAAA,CAAM,SAAS,sBAAA,CAAuB,YAAA,CAAa,MAAM,IAAI,CAAC,CAAC,CAAC;AAAA,CAAA;AACrG","file":"index.cjs","sourcesContent":["/**\n * The configurable layer of the design system.\n *\n * Two layers exist. *Primitives* — the gray scale, the radius/spacing/type/shadow\n * scales, the neutral surfaces — are fixed by the platform and ship as static CSS.\n * The *brand/semantic* layer below is the only thing an instance may set. A client\n * can restyle the vocabulary; it cannot invent a word.\n */\n\n/** Colours that differ between the light and the dark scheme. */\nexport interface ThemeScheme {\n /**\n * Brand colour. Drives `--primary`, and `--ring` follows it.\n *\n * Its label, `--primary-foreground`, is a primitive and stays put: near-white in\n * the light scheme, near-black in the dark one. A brand that is light in light\n * mode (or dark in dark mode) therefore loses its button labels — until the\n * contract grows a paired foreground, pick a colour that fits those two.\n */\n primary: string;\n /** Per-space accents — the icon rail, space badges. */\n spaces: ThemeSpaces;\n /** Semantic status colours — runs, approvals, automations. */\n status: ThemeStatus;\n /** Categorical chart palette. Exactly five, in plot order. */\n charts: ThemeCharts;\n}\n\nexport interface ThemeSpaces {\n crm: string;\n experience: string;\n influence: string;\n pilotage: string;\n proSante: string;\n}\n\nexport interface ThemeStatus {\n success: string;\n pending: string;\n approved: string;\n blocked: string;\n paused: string;\n info: string;\n}\n\nexport type ThemeCharts = readonly [string, string, string, string, string];\n\nexport interface ThemeConfig extends ThemeScheme {\n /** Corner radius the whole scale is derived from, e.g. `0.5rem`. */\n radius: string;\n /** Body font stack. */\n fontSans: string;\n /**\n * Dark-scheme overrides. Anything left out falls back to the light value —\n * which is a legibility bug more often than a shortcut, so override on purpose.\n * `radius` and `fontSans` are absent here: they do not vary by scheme.\n */\n dark?: {\n primary?: string;\n spaces?: Partial<ThemeSpaces>;\n status?: Partial<ThemeStatus>;\n charts?: ThemeCharts;\n };\n}\n\nexport interface ResolvedTheme {\n radius: string;\n fontSans: string;\n light: ThemeScheme;\n /** Fully resolved — every key of {@link ThemeScheme}, never a partial. */\n dark: ThemeScheme;\n}\n\n/**\n * `defineTheme`'s output, as opposed to the config that still has to go through it.\n *\n * Lives here rather than in each loader: a `theme.config` module may export either\n * shape, and every loader has to tell them apart the same way or dev and prod\n * disagree on what counts as already-validated.\n */\nexport function isResolvedTheme(value: unknown): value is ResolvedTheme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'light' in value &&\n 'dark' in value &&\n typeof (value as ResolvedTheme).radius === 'string' &&\n typeof (value as ResolvedTheme).fontSans === 'string'\n );\n}\n\n/**\n * The keys of each colour group, in CSS emission order.\n *\n * Single source: validation, resolution and the DTCG generator all read these, so\n * a new token cannot be added to half the pipeline. Internal — `src/index.ts`\n * decides the public API.\n */\nexport const SPACE_KEYS = ['crm', 'experience', 'influence', 'pilotage', 'proSante'] as const;\nexport const STATUS_KEYS = ['success', 'pending', 'approved', 'blocked', 'paused', 'info'] as const;\nconst CHART_COUNT = 5;\n\nfunction requireColor(value: unknown, path: string): string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`theme: \\`${path}\\` must be a non-empty colour string`);\n }\n // The generated CSS is inlined into a <style> tag, so a value carrying markup\n // would escape it. No colour needs these characters.\n if (/[<>]/.test(value)) {\n throw new Error(`theme: \\`${path}\\` must not contain \\`<\\` or \\`>\\``);\n }\n return value;\n}\n\nfunction requireGroup(value: unknown, path: string): void {\n if (typeof value !== 'object' || value === null) {\n throw new Error(`theme: \\`${path}\\` must be an object`);\n }\n}\n\n/** One colour group, overrides layered over the base, every key checked. */\nfunction resolveGroup<K extends string>(\n keys: readonly K[],\n base: Record<K, string>,\n overrides: Partial<Record<K, string>> | undefined,\n path: string,\n): Record<K, string> {\n requireGroup(base, path);\n // A non-object override is not a partial override — it is every key silently\n // falling back to light, which is exactly the bug this package exists to stop.\n if (overrides !== undefined) requireGroup(overrides, path);\n return Object.fromEntries(\n keys.map((key) => [key, requireColor(overrides?.[key] ?? base[key], `${path}.${key}`)]),\n ) as Record<K, string>;\n}\n\nfunction resolveScheme(\n base: ThemeScheme,\n overrides: ThemeConfig['dark'],\n path: 'light' | 'dark',\n): ThemeScheme {\n const spaces = resolveGroup(SPACE_KEYS, base.spaces, overrides?.spaces, `${path}.spaces`);\n const status = resolveGroup(STATUS_KEYS, base.status, overrides?.status, `${path}.status`);\n\n const charts = overrides?.charts ?? base.charts;\n if (!Array.isArray(charts) || charts.length !== CHART_COUNT) {\n throw new Error(`theme: \\`${path}.charts\\` must hold exactly ${CHART_COUNT} colours`);\n }\n charts.forEach((value, i) => requireColor(value, `${path}.charts[${i}]`));\n\n return {\n primary: requireColor(overrides?.primary ?? base.primary, `${path}.primary`),\n spaces,\n status,\n charts,\n };\n}\n\n/**\n * Validate a theme and resolve its dark scheme against its light one.\n *\n * The type makes an unknown or missing key a compile error; the checks here make\n * it a loud runtime error too, because `theme.config.ts` is loaded as plain JS by\n * the API and TypeScript is not there to catch it.\n */\nexport function defineTheme(config: ThemeConfig): ResolvedTheme {\n if (typeof config?.radius !== 'string' || config.radius.trim() === '') {\n throw new Error('theme: `radius` must be a non-empty CSS length');\n }\n if (typeof config.fontSans !== 'string' || config.fontSans.trim() === '') {\n throw new Error('theme: `fontSans` must be a non-empty font stack');\n }\n\n if (config.dark !== undefined) requireGroup(config.dark, 'dark');\n\n const light = resolveScheme(config, undefined, 'light');\n return {\n radius: config.radius,\n fontSans: config.fontSans,\n light,\n dark: resolveScheme(light, config.dark, 'dark'),\n };\n}\n","/**\n * The theme the platform ships with — and the fallback compiled into\n * `apps/web/src/index.css`, so a failed runtime injection degrades to the\n * platform look, never to unstyled.\n *\n * Values follow the WOS design system (wopilo-dashboard2), like the chrome\n * primitives in the shell stylesheet: Nuit `#041C2D` is the light-scheme brand\n * and Jour `#FFA800` the dark one — `--primary-foreground` is near-white in\n * light and near-black in dark, and that pairing is the only one both colours\n * pass contrast with. The dark scheme lifts the same hues to a legible\n * lightness, with Menthe `#95DFBA` as the mint accent.\n *\n * An admin can recover ANY of this from Paramètres › Thème: the DB row layers\n * over this default, and resetting deletes the row.\n */\nimport { defineTheme } from './theme.js';\n\nexport const defaultTheme = defineTheme({\n radius: '0.625rem',\n // Inter is the WOS typeface but the platform does not bundle it, so this\n // reads as \"Inter if the machine has it, system stack otherwise\".\n fontSans:\n \"Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\",\n\n primary: '#041C2D',\n\n spaces: {\n crm: '#35618A',\n experience: '#5B7387',\n influence: '#B5432A',\n pilotage: '#FFA800',\n proSante: '#3E9B77',\n },\n\n status: {\n success: '#1F7D54',\n pending: '#9A6B12',\n approved: '#35618A',\n blocked: '#B5432A',\n paused: '#7A8089',\n info: '#5B7387',\n },\n\n /**\n * Categorical palette from the WOS attribution screens (sure / decl / extr /\n * leak / sure-green). Every entry clears 4.5:1 on white — well past the 3:1\n * WCAG asks of a graphical object.\n */\n charts: ['#041C2D', '#9A6B12', '#5B7387', '#B5432A', '#1F7D54'],\n\n dark: {\n primary: '#FFA800',\n spaces: {\n crm: '#7FA8CC',\n experience: '#93A9BC',\n influence: '#D97B63',\n pilotage: '#FFB733',\n proSante: '#95DFBA',\n },\n status: {\n success: '#7ED4A6',\n pending: '#D9A83E',\n approved: '#7FA8CC',\n blocked: '#D97B63',\n paused: '#9AA1AA',\n info: '#93A9BC',\n },\n // Same hues, lifted to stay legible on the dark card.\n charts: ['#7FA8CC', '#FFA800', '#93A9BC', '#D97B63', '#95DFBA'],\n },\n});\n","/**\n * The primitive scales — type, spacing, elevation.\n *\n * Not part of `ThemeConfig`: an instance restyles the brand, it does not redraw\n * the grid the product is built on. They live here rather than being inherited\n * from Tailwind's defaults so the platform owns them: a Tailwind upgrade cannot\n * move the product's type, and P4's generated catalogue has one place to read.\n *\n * The values are today's, deliberately. Figma's hi-fi frames use a denser scale\n * (11 / 12 / 13 / 18 / 20 / 22 px against 12 / 14 / 16 / 18 / 20 / 24) and the\n * observed figure is recorded on each step — adopting it moves every screen in\n * the product, so it is a decision with a visual audit attached, not a rename.\n * When that decision is made, it is made here.\n */\n\nexport interface TypeStep {\n /** Tailwind's `text-<key>`. */\n key: string;\n size: string;\n /** Paired line height. Tailwind reads it as `--text-<key>--line-height`. */\n lineHeight: string;\n /** What the Figma frames use at this step, for the day the scale is reconciled. */\n figmaPx?: number;\n}\n\nexport const TYPE_SCALE: readonly TypeStep[] = [\n { key: 'xs', size: '0.75rem', lineHeight: 'calc(1 / 0.75)', figmaPx: 11 },\n { key: 'sm', size: '0.875rem', lineHeight: 'calc(1.25 / 0.875)', figmaPx: 12 },\n { key: 'base', size: '1rem', lineHeight: 'calc(1.5 / 1)', figmaPx: 13 },\n { key: 'lg', size: '1.125rem', lineHeight: 'calc(1.75 / 1.125)', figmaPx: 18 },\n { key: 'xl', size: '1.25rem', lineHeight: 'calc(1.75 / 1.25)', figmaPx: 20 },\n { key: '2xl', size: '1.5rem', lineHeight: 'calc(2 / 1.5)', figmaPx: 22 },\n { key: '3xl', size: '1.875rem', lineHeight: 'calc(2.25 / 1.875)' },\n];\n\n/**\n * The step every `p-`, `gap-` and `m-` utility multiplies. Figma's frames sit on\n * the same 4px grid, so this one needs no reconciling.\n */\nexport const SPACING_STEP = '0.25rem';\n\n/**\n * The platform has exactly one card elevation. The value is WOS's `--shadow`:\n * a whisper-soft double layer tinted with Nuit, where Tailwind's defaults are\n * neutral and tight. Offered as its own token rather than by overriding\n * `--shadow-sm`, which would restyle every existing surface.\n */\nexport const SHADOWS: Readonly<Record<string, string>> = {\n card: '0 1px 2px rgb(4 28 45 / 0.04), 0 2px 6px rgb(4 28 45 / 0.05)',\n};\n\n/**\n * The primitives as a Tailwind `@theme` block.\n *\n * `@theme`, not `:root`: these are the vocabulary Tailwind generates utilities\n * from, and unlike the brand layer they are fixed at build time.\n */\nexport function primitivesToCss(): string {\n const lines = [\n ...TYPE_SCALE.flatMap((step) => [\n `--text-${step.key}: ${step.size};`,\n `--text-${step.key}--line-height: ${step.lineHeight};`,\n ]),\n `--spacing: ${SPACING_STEP};`,\n ...Object.entries(SHADOWS).map(([key, value]) => `--shadow-${key}: ${value};`),\n ];\n return `@theme {\\n${lines.map((line) => ` ${line}`).join('\\n')}\\n}\\n`;\n}\n","/**\n * DTCG (W3C Design Tokens) as the generator's intermediate format.\n *\n * Nothing here is public API — `themeToCss` is. The point of the detour is that a\n * Figma Variables export speaks DTCG: when that lands it plugs in as another\n * producer of these groups instead of a rewrite of the CSS generator.\n *\n * Token path → CSS custom property is mechanical: kebab-case each segment and\n * join with `-`. `space.proSante` → `--space-pro-sante`, `font.sans` →\n * `--font-sans`, `chart.1` → `--chart-1`. That is why the group names below are\n * the CSS prefixes and not prettier words.\n */\nimport { SPACE_KEYS, STATUS_KEYS, type ResolvedTheme, type ThemeScheme } from './theme.js';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily';\n\nexport interface DtcgToken {\n $type: DtcgType;\n $value: string;\n}\n\nexport interface DtcgGroup {\n [key: string]: DtcgToken | DtcgGroup;\n}\n\nconst isToken = (node: DtcgToken | DtcgGroup): node is DtcgToken => '$value' in node;\n\nconst color = ($value: string): DtcgToken => ({ $type: 'color', $value });\n\nconst colorGroup = <K extends string>(keys: readonly K[], group: Record<K, string>): DtcgGroup =>\n Object.fromEntries(keys.map((key) => [key, color(group[key])]));\n\n/** Colour tokens of one scheme — the keys that must exist in both `:root` and `.dark`. */\nexport function schemeToDtcg(scheme: ThemeScheme): DtcgGroup {\n return {\n primary: color(scheme.primary),\n space: colorGroup(SPACE_KEYS, scheme.spaces),\n status: colorGroup(STATUS_KEYS, scheme.status),\n chart: Object.fromEntries(scheme.charts.map((value, i) => [String(i + 1), color(value)])),\n };\n}\n\n/** Tokens that do not vary by scheme, so they are emitted in `:root` only. */\nexport function invariantsToDtcg(theme: ResolvedTheme): DtcgGroup {\n return {\n radius: { $type: 'dimension', $value: theme.radius },\n font: { sans: { $type: 'fontFamily', $value: theme.fontSans } },\n };\n}\n\nconst kebab = (segment: string) => segment.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/** `--custom-property: value;` for every token in the group, depth-first. */\nexport function dtcgToCustomProperties(group: DtcgGroup, path: string[] = []): string[] {\n return Object.entries(group).flatMap(([key, node]) => {\n const next = [...path, kebab(key)];\n return isToken(node)\n ? [`--${next.join('-')}: ${node.$value};`]\n : dtcgToCustomProperties(node, next);\n });\n}\n","import { dtcgToCustomProperties, invariantsToDtcg, schemeToDtcg } from './dtcg.js';\nimport type { ResolvedTheme } from './theme.js';\n\n/**\n * The id carried by the `<style>` tag this CSS is inlined into — the handle the\n * live theme is found by (`document.getElementById('apotech-theme')`).\n *\n * It is a cross-process contract: the API inlines the tag in production and the\n * dev Vite plugin inlines it in `pnpm dev`, so both must spell it the same way.\n */\nexport const THEME_STYLE_ID = 'apotech-theme';\n\nconst block = (selector: string, declarations: string[]) =>\n `${selector} {\\n${declarations.map((line) => ` ${line}`).join('\\n')}\\n}`;\n\n/**\n * Render a theme as `:root { … } .dark { … }`.\n *\n * Only *values* are emitted. The `@theme inline` vocabulary that teaches Tailwind\n * about `bg-primary` and friends stays at build time in `index.css` — a client\n * restyles the words, it does not add any.\n */\nexport function themeToCss(theme: ResolvedTheme): string {\n const root = [\n ...dtcgToCustomProperties(invariantsToDtcg(theme)),\n ...dtcgToCustomProperties(schemeToDtcg(theme.light)),\n ];\n return `${block(':root', root)}\\n${block('.dark', dtcgToCustomProperties(schemeToDtcg(theme.dark)))}\\n`;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -113,9 +113,10 @@ declare const TYPE_SCALE: readonly TypeStep[];
113
113
  */
114
114
  declare const SPACING_STEP = "0.25rem";
115
115
  /**
116
- * Figma has exactly one card elevation, and it is cool-tinted and wide where
117
- * Tailwind's defaults are neutral and tight. Offered as its own token rather
118
- * than by overriding `--shadow-sm`, which would restyle every existing surface.
116
+ * The platform has exactly one card elevation. The value is WOS's `--shadow`:
117
+ * a whisper-soft double layer tinted with Nuit, where Tailwind's defaults are
118
+ * neutral and tight. Offered as its own token rather than by overriding
119
+ * `--shadow-sm`, which would restyle every existing surface.
119
120
  */
120
121
  declare const SHADOWS: Readonly<Record<string, string>>;
121
122
  /**
package/dist/index.d.ts CHANGED
@@ -113,9 +113,10 @@ declare const TYPE_SCALE: readonly TypeStep[];
113
113
  */
114
114
  declare const SPACING_STEP = "0.25rem";
115
115
  /**
116
- * Figma has exactly one card elevation, and it is cool-tinted and wide where
117
- * Tailwind's defaults are neutral and tight. Offered as its own token rather
118
- * than by overriding `--shadow-sm`, which would restyle every existing surface.
116
+ * The platform has exactly one card elevation. The value is WOS's `--shadow`:
117
+ * a whisper-soft double layer tinted with Nuit, where Tailwind's defaults are
118
+ * neutral and tight. Offered as its own token rather than by overriding
119
+ * `--shadow-sm`, which would restyle every existing surface.
119
120
  */
120
121
  declare const SHADOWS: Readonly<Record<string, string>>;
121
122
  /**
package/dist/index.js CHANGED
@@ -59,67 +59,52 @@ function defineTheme(config) {
59
59
  }
60
60
 
61
61
  // src/default-theme.ts
62
- var BRAND = "oklch(0.549 0.231 268.1)";
63
- var BRAND_DARK = "oklch(0.68 0.16 268.1)";
64
62
  var defaultTheme = defineTheme({
65
- // Figma: 8px corners on inputs and buttons.
66
- radius: "0.5rem",
67
- // Inter is the Figma typeface but the platform does not bundle it yet, so this
63
+ radius: "0.625rem",
64
+ // Inter is the WOS typeface but the platform does not bundle it, so this
68
65
  // reads as "Inter if the machine has it, system stack otherwise".
69
66
  fontSans: "Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
70
- primary: BRAND,
67
+ primary: "#041C2D",
71
68
  spaces: {
72
- crm: "oklch(0.554 0.215 268.1)",
73
- experience: "oklch(0.62 0.13 233)",
74
- influence: "oklch(0.64 0.2 350)",
75
- pilotage: "oklch(0.7 0.16 62)",
76
- proSante: "oklch(0.62 0.11 172)"
69
+ crm: "#35618A",
70
+ experience: "#5B7387",
71
+ influence: "#B5432A",
72
+ pilotage: "#FFA800",
73
+ proSante: "#3E9B77"
77
74
  },
78
75
  status: {
79
- success: "oklch(0.51 0.14 150)",
80
- pending: "oklch(0.535 0.11 75)",
81
- approved: "oklch(0.545 0.235 268.1)",
82
- blocked: "oklch(0.545 0.22 27)",
83
- paused: "oklch(0.53 0.04 268.1)",
84
- info: "oklch(0.52 0.105 233)"
76
+ success: "#1F7D54",
77
+ pending: "#9A6B12",
78
+ approved: "#35618A",
79
+ blocked: "#B5432A",
80
+ paused: "#7A8089",
81
+ info: "#5B7387"
85
82
  },
86
83
  /**
87
- * Categorical palette: five hues spread from the brand around the wheel, all at
88
- * one lightness so no series reads as "louder" than another. Every entry clears
89
- * 4.5:1 on white — well past the 3:1 WCAG asks of a graphical object.
84
+ * Categorical palette from the WOS attribution screens (sure / decl / extr /
85
+ * leak / sure-green). Every entry clears 4.5:1 on white — well past the 3:1
86
+ * WCAG asks of a graphical object.
90
87
  */
91
- charts: [
92
- "oklch(0.55 0.2 268.1)",
93
- "oklch(0.55 0.09 196)",
94
- "oklch(0.55 0.15 150)",
95
- "oklch(0.55 0.115 70)",
96
- "oklch(0.55 0.2 345)"
97
- ],
88
+ charts: ["#041C2D", "#9A6B12", "#5B7387", "#B5432A", "#1F7D54"],
98
89
  dark: {
99
- primary: BRAND_DARK,
90
+ primary: "#FFA800",
100
91
  spaces: {
101
- crm: "oklch(0.74 0.135 268.1)",
102
- experience: "oklch(0.74 0.13 233)",
103
- influence: "oklch(0.74 0.19 350)",
104
- pilotage: "oklch(0.74 0.16 62)",
105
- proSante: "oklch(0.74 0.11 172)"
92
+ crm: "#7FA8CC",
93
+ experience: "#93A9BC",
94
+ influence: "#D97B63",
95
+ pilotage: "#FFB733",
96
+ proSante: "#95DFBA"
106
97
  },
107
98
  status: {
108
- success: "oklch(0.74 0.16 150)",
109
- pending: "oklch(0.74 0.15 75)",
110
- approved: "oklch(0.74 0.135 268.1)",
111
- blocked: "oklch(0.74 0.155 27)",
112
- paused: "oklch(0.74 0.02 268.1)",
113
- info: "oklch(0.74 0.13 233)"
99
+ success: "#7ED4A6",
100
+ pending: "#D9A83E",
101
+ approved: "#7FA8CC",
102
+ blocked: "#D97B63",
103
+ paused: "#9AA1AA",
104
+ info: "#93A9BC"
114
105
  },
115
- // Same hues, lifted to ~7:1 on the dark card.
116
- charts: [
117
- "oklch(0.74 0.13 268.1)",
118
- "oklch(0.74 0.125 196)",
119
- "oklch(0.74 0.17 150)",
120
- "oklch(0.74 0.16 70)",
121
- "oklch(0.74 0.17 345)"
122
- ]
106
+ // Same hues, lifted to stay legible on the dark card.
107
+ charts: ["#7FA8CC", "#FFA800", "#93A9BC", "#D97B63", "#95DFBA"]
123
108
  }
124
109
  });
125
110
 
@@ -135,7 +120,7 @@ var TYPE_SCALE = [
135
120
  ];
136
121
  var SPACING_STEP = "0.25rem";
137
122
  var SHADOWS = {
138
- card: "0 10px 30px -8px oklch(0.2 0.03 268.1 / 0.1)"
123
+ card: "0 1px 2px rgb(4 28 45 / 0.04), 0 2px 6px rgb(4 28 45 / 0.05)"
139
124
  };
140
125
  function primitivesToCss() {
141
126
  const lines = [
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/theme.ts","../src/default-theme.ts","../src/primitives.ts","../src/dtcg.ts","../src/theme-to-css.ts"],"names":[],"mappings":";AAgFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,QACV,OAAA,IAAW,KAAA,IACX,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAwB,MAAA,KAAW,QAAA,IAC3C,OAAQ,MAAwB,QAAA,KAAa,QAAA;AAEjD;AASO,IAAM,aAAa,CAAC,KAAA,EAAO,YAAA,EAAc,WAAA,EAAa,YAAY,UAAU,CAAA;AAC5E,IAAM,cAAc,CAAC,SAAA,EAAW,WAAW,UAAA,EAAY,SAAA,EAAW,UAAU,MAAM,CAAA;AACzF,IAAM,WAAA,GAAc,CAAA;AAEpB,SAAS,YAAA,CAAa,OAAgB,IAAA,EAAsB;AAC1D,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,IAAA,OAAW,EAAA,EAAI;AACpD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,SAAA,EAAY,IAAI,CAAA,oCAAA,CAAsC,CAAA;AAAA,EACxE;AAGA,EAAA,IAAI,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,SAAA,EAAY,IAAI,CAAA,kCAAA,CAAoC,CAAA;AAAA,EACtE;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,YAAA,CAAa,OAAgB,IAAA,EAAoB;AACxD,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA,EAAM;AAC/C,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,SAAA,EAAY,IAAI,CAAA,oBAAA,CAAsB,CAAA;AAAA,EACxD;A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AO,MAAA,CAAO,QAAQ,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAC,GAAA,EAAK,IAAI,CAAA,KAAM;AACpD,IAAA,MAAM,OAAO,CAAC,GAAG,IAAA,EAAM,KAAA,CAAM,GAAG,CAAC,CAAA;AACjC,IAAA,OAAO,QAAQ,IAAI,CAAA,GACf,CAAC,CAAA,EAAA,EAAK,KAAK,IAAA,CAAK,GAAG,CAAC,CAAA,EAAA,EAAK,KAAK,MAAM,CAAA,CAAA,CAAG,CAAA,GACvC,sBAAA,CAAuB,MAAM,IAAI,CAAA;AAAA,EACvC,CAAC,CAAA;AACH;;;AClDO,IAAM,cAAA,GAAiB;AAE9B,IAAM,KAAA,GAAQ,CAAC,QAAA,EAAkB,YAAA,KAC/B,GAAG,QAAQ,CAAA;AAAA,EAAO,YAAA,CAAa,GAAA,CAAI,CAAC,IAAA,KAAS,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA,CAAA;AAS/D,SAAS,WAAW,KAAA,EAA8B;AACvD,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG,sBAAA,CAAuB,gBAAA,CAAiB,KAAK,CAAC,CAAA;AAAA,IACjD,GAAG,sBAAA,CAAuB,YAAA,CAAa,KAAA,CAAM,KAAK,CAAC;AAAA,GACrD;AACA,EAAA,OAAO,CAAA,EAAG,KAAA,CAAM,OAAA,EAAS,IAAI,CAAC;AAAA,EAAK,KAAA,CAAM,SAAS,sBAAA,CAAuB,YAAA,CAAa,MAAM,IAAI,CAAC,CAAC,CAAC;AAAA,CAAA;AACrG","file":"index.js","sourcesContent":["/**\n * The configurable layer of the design system.\n *\n * Two layers exist. *Primitives* — the gray scale, the radius/spacing/type/shadow\n * scales, the neutral surfaces — are fixed by the platform and ship as static CSS.\n * The *brand/semantic* layer below is the only thing an instance may set. A client\n * can restyle the vocabulary; it cannot invent a word.\n */\n\n/** Colours that differ between the light and the dark scheme. */\nexport interface ThemeScheme {\n /**\n * Brand colour. Drives `--primary`, and `--ring` follows it.\n *\n * Its label, `--primary-foreground`, is a primitive and stays put: near-white in\n * the light scheme, near-black in the dark one. A brand that is light in light\n * mode (or dark in dark mode) therefore loses its button labels — until the\n * contract grows a paired foreground, pick a colour that fits those two.\n */\n primary: string;\n /** Per-space accents — the icon rail, space badges. */\n spaces: ThemeSpaces;\n /** Semantic status colours — runs, approvals, automations. */\n status: ThemeStatus;\n /** Categorical chart palette. Exactly five, in plot order. */\n charts: ThemeCharts;\n}\n\nexport interface ThemeSpaces {\n crm: string;\n experience: string;\n influence: string;\n pilotage: string;\n proSante: string;\n}\n\nexport interface ThemeStatus {\n success: string;\n pending: string;\n approved: string;\n blocked: string;\n paused: string;\n info: string;\n}\n\nexport type ThemeCharts = readonly [string, string, string, string, string];\n\nexport interface ThemeConfig extends ThemeScheme {\n /** Corner radius the whole scale is derived from, e.g. `0.5rem`. */\n radius: string;\n /** Body font stack. */\n fontSans: string;\n /**\n * Dark-scheme overrides. Anything left out falls back to the light value —\n * which is a legibility bug more often than a shortcut, so override on purpose.\n * `radius` and `fontSans` are absent here: they do not vary by scheme.\n */\n dark?: {\n primary?: string;\n spaces?: Partial<ThemeSpaces>;\n status?: Partial<ThemeStatus>;\n charts?: ThemeCharts;\n };\n}\n\nexport interface ResolvedTheme {\n radius: string;\n fontSans: string;\n light: ThemeScheme;\n /** Fully resolved — every key of {@link ThemeScheme}, never a partial. */\n dark: ThemeScheme;\n}\n\n/**\n * `defineTheme`'s output, as opposed to the config that still has to go through it.\n *\n * Lives here rather than in each loader: a `theme.config` module may export either\n * shape, and every loader has to tell them apart the same way or dev and prod\n * disagree on what counts as already-validated.\n */\nexport function isResolvedTheme(value: unknown): value is ResolvedTheme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'light' in value &&\n 'dark' in value &&\n typeof (value as ResolvedTheme).radius === 'string' &&\n typeof (value as ResolvedTheme).fontSans === 'string'\n );\n}\n\n/**\n * The keys of each colour group, in CSS emission order.\n *\n * Single source: validation, resolution and the DTCG generator all read these, so\n * a new token cannot be added to half the pipeline. Internal — `src/index.ts`\n * decides the public API.\n */\nexport const SPACE_KEYS = ['crm', 'experience', 'influence', 'pilotage', 'proSante'] as const;\nexport const STATUS_KEYS = ['success', 'pending', 'approved', 'blocked', 'paused', 'info'] as const;\nconst CHART_COUNT = 5;\n\nfunction requireColor(value: unknown, path: string): string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`theme: \\`${path}\\` must be a non-empty colour string`);\n }\n // The generated CSS is inlined into a <style> tag, so a value carrying markup\n // would escape it. No colour needs these characters.\n if (/[<>]/.test(value)) {\n throw new Error(`theme: \\`${path}\\` must not contain \\`<\\` or \\`>\\``);\n }\n return value;\n}\n\nfunction requireGroup(value: unknown, path: string): void {\n if (typeof value !== 'object' || value === null) {\n throw new Error(`theme: \\`${path}\\` must be an object`);\n }\n}\n\n/** One colour group, overrides layered over the base, every key checked. */\nfunction resolveGroup<K extends string>(\n keys: readonly K[],\n base: Record<K, string>,\n overrides: Partial<Record<K, string>> | undefined,\n path: string,\n): Record<K, string> {\n requireGroup(base, path);\n // A non-object override is not a partial override — it is every key silently\n // falling back to light, which is exactly the bug this package exists to stop.\n if (overrides !== undefined) requireGroup(overrides, path);\n return Object.fromEntries(\n keys.map((key) => [key, requireColor(overrides?.[key] ?? base[key], `${path}.${key}`)]),\n ) as Record<K, string>;\n}\n\nfunction resolveScheme(\n base: ThemeScheme,\n overrides: ThemeConfig['dark'],\n path: 'light' | 'dark',\n): ThemeScheme {\n const spaces = resolveGroup(SPACE_KEYS, base.spaces, overrides?.spaces, `${path}.spaces`);\n const status = resolveGroup(STATUS_KEYS, base.status, overrides?.status, `${path}.status`);\n\n const charts = overrides?.charts ?? base.charts;\n if (!Array.isArray(charts) || charts.length !== CHART_COUNT) {\n throw new Error(`theme: \\`${path}.charts\\` must hold exactly ${CHART_COUNT} colours`);\n }\n charts.forEach((value, i) => requireColor(value, `${path}.charts[${i}]`));\n\n return {\n primary: requireColor(overrides?.primary ?? base.primary, `${path}.primary`),\n spaces,\n status,\n charts,\n };\n}\n\n/**\n * Validate a theme and resolve its dark scheme against its light one.\n *\n * The type makes an unknown or missing key a compile error; the checks here make\n * it a loud runtime error too, because `theme.config.ts` is loaded as plain JS by\n * the API and TypeScript is not there to catch it.\n */\nexport function defineTheme(config: ThemeConfig): ResolvedTheme {\n if (typeof config?.radius !== 'string' || config.radius.trim() === '') {\n throw new Error('theme: `radius` must be a non-empty CSS length');\n }\n if (typeof config.fontSans !== 'string' || config.fontSans.trim() === '') {\n throw new Error('theme: `fontSans` must be a non-empty font stack');\n }\n\n if (config.dark !== undefined) requireGroup(config.dark, 'dark');\n\n const light = resolveScheme(config, undefined, 'light');\n return {\n radius: config.radius,\n fontSans: config.fontSans,\n light,\n dark: resolveScheme(light, config.dark, 'dark'),\n };\n}\n","/**\n * The theme the platform ships with — and the fallback compiled into\n * `apps/web/src/index.css`, so a failed runtime injection degrades to \"neutral\n * but usable\", never to unstyled.\n *\n * Colours are OKLCH so lightness is perceptual: the dark scheme is the same hue\n * lifted to a legible lightness, not a different palette.\n */\nimport { defineTheme } from './theme.js';\n\n/**\n * Brand blue, from the Figma source of truth (`#3B5CF5`).\n * Contrast: 4.85:1 on the light background, 4.99:1 for `--primary-foreground` on it.\n */\nconst BRAND = 'oklch(0.549 0.231 268.1)';\n/** Same hue lifted for the dark scheme: 6.07:1 on the dark card, 6.59:1 for its label. */\nconst BRAND_DARK = 'oklch(0.68 0.16 268.1)';\n\nexport const defaultTheme = defineTheme({\n // Figma: 8px corners on inputs and buttons.\n radius: '0.5rem',\n // Inter is the Figma typeface but the platform does not bundle it yet, so this\n // reads as \"Inter if the machine has it, system stack otherwise\".\n fontSans:\n \"Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\",\n\n primary: BRAND,\n\n spaces: {\n crm: 'oklch(0.554 0.215 268.1)',\n experience: 'oklch(0.62 0.13 233)',\n influence: 'oklch(0.64 0.2 350)',\n pilotage: 'oklch(0.7 0.16 62)',\n proSante: 'oklch(0.62 0.11 172)',\n },\n\n status: {\n success: 'oklch(0.51 0.14 150)',\n pending: 'oklch(0.535 0.11 75)',\n approved: 'oklch(0.545 0.235 268.1)',\n blocked: 'oklch(0.545 0.22 27)',\n paused: 'oklch(0.53 0.04 268.1)',\n info: 'oklch(0.52 0.105 233)',\n },\n\n /**\n * Categorical palette: five hues spread from the brand around the wheel, all at\n * one lightness so no series reads as \"louder\" than another. Every entry clears\n * 4.5:1 on white — well past the 3:1 WCAG asks of a graphical object.\n */\n charts: [\n 'oklch(0.55 0.2 268.1)',\n 'oklch(0.55 0.09 196)',\n 'oklch(0.55 0.15 150)',\n 'oklch(0.55 0.115 70)',\n 'oklch(0.55 0.2 345)',\n ],\n\n dark: {\n primary: BRAND_DARK,\n spaces: {\n crm: 'oklch(0.74 0.135 268.1)',\n experience: 'oklch(0.74 0.13 233)',\n influence: 'oklch(0.74 0.19 350)',\n pilotage: 'oklch(0.74 0.16 62)',\n proSante: 'oklch(0.74 0.11 172)',\n },\n status: {\n success: 'oklch(0.74 0.16 150)',\n pending: 'oklch(0.74 0.15 75)',\n approved: 'oklch(0.74 0.135 268.1)',\n blocked: 'oklch(0.74 0.155 27)',\n paused: 'oklch(0.74 0.02 268.1)',\n info: 'oklch(0.74 0.13 233)',\n },\n // Same hues, lifted to ~7:1 on the dark card.\n charts: [\n 'oklch(0.74 0.13 268.1)',\n 'oklch(0.74 0.125 196)',\n 'oklch(0.74 0.17 150)',\n 'oklch(0.74 0.16 70)',\n 'oklch(0.74 0.17 345)',\n ],\n },\n});\n","/**\n * The primitive scales — type, spacing, elevation.\n *\n * Not part of `ThemeConfig`: an instance restyles the brand, it does not redraw\n * the grid the product is built on. They live here rather than being inherited\n * from Tailwind's defaults so the platform owns them: a Tailwind upgrade cannot\n * move the product's type, and P4's generated catalogue has one place to read.\n *\n * The values are today's, deliberately. Figma's hi-fi frames use a denser scale\n * (11 / 12 / 13 / 18 / 20 / 22 px against 12 / 14 / 16 / 18 / 20 / 24) and the\n * observed figure is recorded on each step — adopting it moves every screen in\n * the product, so it is a decision with a visual audit attached, not a rename.\n * When that decision is made, it is made here.\n */\n\nexport interface TypeStep {\n /** Tailwind's `text-<key>`. */\n key: string;\n size: string;\n /** Paired line height. Tailwind reads it as `--text-<key>--line-height`. */\n lineHeight: string;\n /** What the Figma frames use at this step, for the day the scale is reconciled. */\n figmaPx?: number;\n}\n\nexport const TYPE_SCALE: readonly TypeStep[] = [\n { key: 'xs', size: '0.75rem', lineHeight: 'calc(1 / 0.75)', figmaPx: 11 },\n { key: 'sm', size: '0.875rem', lineHeight: 'calc(1.25 / 0.875)', figmaPx: 12 },\n { key: 'base', size: '1rem', lineHeight: 'calc(1.5 / 1)', figmaPx: 13 },\n { key: 'lg', size: '1.125rem', lineHeight: 'calc(1.75 / 1.125)', figmaPx: 18 },\n { key: 'xl', size: '1.25rem', lineHeight: 'calc(1.75 / 1.25)', figmaPx: 20 },\n { key: '2xl', size: '1.5rem', lineHeight: 'calc(2 / 1.5)', figmaPx: 22 },\n { key: '3xl', size: '1.875rem', lineHeight: 'calc(2.25 / 1.875)' },\n];\n\n/**\n * The step every `p-`, `gap-` and `m-` utility multiplies. Figma's frames sit on\n * the same 4px grid, so this one needs no reconciling.\n */\nexport const SPACING_STEP = '0.25rem';\n\n/**\n * Figma has exactly one card elevation, and it is cool-tinted and wide where\n * Tailwind's defaults are neutral and tight. Offered as its own token rather\n * than by overriding `--shadow-sm`, which would restyle every existing surface.\n */\nexport const SHADOWS: Readonly<Record<string, string>> = {\n card: '0 10px 30px -8px oklch(0.2 0.03 268.1 / 0.1)',\n};\n\n/**\n * The primitives as a Tailwind `@theme` block.\n *\n * `@theme`, not `:root`: these are the vocabulary Tailwind generates utilities\n * from, and unlike the brand layer they are fixed at build time.\n */\nexport function primitivesToCss(): string {\n const lines = [\n ...TYPE_SCALE.flatMap((step) => [\n `--text-${step.key}: ${step.size};`,\n `--text-${step.key}--line-height: ${step.lineHeight};`,\n ]),\n `--spacing: ${SPACING_STEP};`,\n ...Object.entries(SHADOWS).map(([key, value]) => `--shadow-${key}: ${value};`),\n ];\n return `@theme {\\n${lines.map((line) => ` ${line}`).join('\\n')}\\n}\\n`;\n}\n","/**\n * DTCG (W3C Design Tokens) as the generator's intermediate format.\n *\n * Nothing here is public API — `themeToCss` is. The point of the detour is that a\n * Figma Variables export speaks DTCG: when that lands it plugs in as another\n * producer of these groups instead of a rewrite of the CSS generator.\n *\n * Token path → CSS custom property is mechanical: kebab-case each segment and\n * join with `-`. `space.proSante` → `--space-pro-sante`, `font.sans` →\n * `--font-sans`, `chart.1` → `--chart-1`. That is why the group names below are\n * the CSS prefixes and not prettier words.\n */\nimport { SPACE_KEYS, STATUS_KEYS, type ResolvedTheme, type ThemeScheme } from './theme.js';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily';\n\nexport interface DtcgToken {\n $type: DtcgType;\n $value: string;\n}\n\nexport interface DtcgGroup {\n [key: string]: DtcgToken | DtcgGroup;\n}\n\nconst isToken = (node: DtcgToken | DtcgGroup): node is DtcgToken => '$value' in node;\n\nconst color = ($value: string): DtcgToken => ({ $type: 'color', $value });\n\nconst colorGroup = <K extends string>(keys: readonly K[], group: Record<K, string>): DtcgGroup =>\n Object.fromEntries(keys.map((key) => [key, color(group[key])]));\n\n/** Colour tokens of one scheme — the keys that must exist in both `:root` and `.dark`. */\nexport function schemeToDtcg(scheme: ThemeScheme): DtcgGroup {\n return {\n primary: color(scheme.primary),\n space: colorGroup(SPACE_KEYS, scheme.spaces),\n status: colorGroup(STATUS_KEYS, scheme.status),\n chart: Object.fromEntries(scheme.charts.map((value, i) => [String(i + 1), color(value)])),\n };\n}\n\n/** Tokens that do not vary by scheme, so they are emitted in `:root` only. */\nexport function invariantsToDtcg(theme: ResolvedTheme): DtcgGroup {\n return {\n radius: { $type: 'dimension', $value: theme.radius },\n font: { sans: { $type: 'fontFamily', $value: theme.fontSans } },\n };\n}\n\nconst kebab = (segment: string) => segment.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/** `--custom-property: value;` for every token in the group, depth-first. */\nexport function dtcgToCustomProperties(group: DtcgGroup, path: string[] = []): string[] {\n return Object.entries(group).flatMap(([key, node]) => {\n const next = [...path, kebab(key)];\n return isToken(node)\n ? [`--${next.join('-')}: ${node.$value};`]\n : dtcgToCustomProperties(node, next);\n });\n}\n","import { dtcgToCustomProperties, invariantsToDtcg, schemeToDtcg } from './dtcg.js';\nimport type { ResolvedTheme } from './theme.js';\n\n/**\n * The id carried by the `<style>` tag this CSS is inlined into — the handle the\n * live theme is found by (`document.getElementById('apotech-theme')`).\n *\n * It is a cross-process contract: the API inlines the tag in production and the\n * dev Vite plugin inlines it in `pnpm dev`, so both must spell it the same way.\n */\nexport const THEME_STYLE_ID = 'apotech-theme';\n\nconst block = (selector: string, declarations: string[]) =>\n `${selector} {\\n${declarations.map((line) => ` ${line}`).join('\\n')}\\n}`;\n\n/**\n * Render a theme as `:root { … } .dark { … }`.\n *\n * Only *values* are emitted. The `@theme inline` vocabulary that teaches Tailwind\n * about `bg-primary` and friends stays at build time in `index.css` — a client\n * restyles the words, it does not add any.\n */\nexport function themeToCss(theme: ResolvedTheme): string {\n const root = [\n ...dtcgToCustomProperties(invariantsToDtcg(theme)),\n ...dtcgToCustomProperties(schemeToDtcg(theme.light)),\n ];\n return `${block(':root', root)}\\n${block('.dark', dtcgToCustomProperties(schemeToDtcg(theme.dark)))}\\n`;\n}\n"]}
1
+ {"version":3,"sources":["../src/theme.ts","../src/default-theme.ts","../src/primitives.ts","../src/dtcg.ts","../src/theme-to-css.ts"],"names":[],"mappings":";AAgFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,QACV,OAAA,IAAW,KAAA,IACX,MAAA,IAAU,KAAA,IACV,OAA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,EAAO,YAAA,CAAa,GAAA,CAAI,CAAC,IAAA,KAAS,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA,CAAA;AAS/D,SAAS,WAAW,KAAA,EAA8B;AACvD,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG,sBAAA,CAAuB,gBAAA,CAAiB,KAAK,CAAC,CAAA;AAAA,IACjD,GAAG,sBAAA,CAAuB,YAAA,CAAa,KAAA,CAAM,KAAK,CAAC;AAAA,GACrD;AACA,EAAA,OAAO,CAAA,EAAG,KAAA,CAAM,OAAA,EAAS,IAAI,CAAC;AAAA,EAAK,KAAA,CAAM,SAAS,sBAAA,CAAuB,YAAA,CAAa,MAAM,IAAI,CAAC,CAAC,CAAC;AAAA,CAAA;AACrG","file":"index.js","sourcesContent":["/**\n * The configurable layer of the design system.\n *\n * Two layers exist. *Primitives* — the gray scale, the radius/spacing/type/shadow\n * scales, the neutral surfaces — are fixed by the platform and ship as static CSS.\n * The *brand/semantic* layer below is the only thing an instance may set. A client\n * can restyle the vocabulary; it cannot invent a word.\n */\n\n/** Colours that differ between the light and the dark scheme. */\nexport interface ThemeScheme {\n /**\n * Brand colour. Drives `--primary`, and `--ring` follows it.\n *\n * Its label, `--primary-foreground`, is a primitive and stays put: near-white in\n * the light scheme, near-black in the dark one. A brand that is light in light\n * mode (or dark in dark mode) therefore loses its button labels — until the\n * contract grows a paired foreground, pick a colour that fits those two.\n */\n primary: string;\n /** Per-space accents — the icon rail, space badges. */\n spaces: ThemeSpaces;\n /** Semantic status colours — runs, approvals, automations. */\n status: ThemeStatus;\n /** Categorical chart palette. Exactly five, in plot order. */\n charts: ThemeCharts;\n}\n\nexport interface ThemeSpaces {\n crm: string;\n experience: string;\n influence: string;\n pilotage: string;\n proSante: string;\n}\n\nexport interface ThemeStatus {\n success: string;\n pending: string;\n approved: string;\n blocked: string;\n paused: string;\n info: string;\n}\n\nexport type ThemeCharts = readonly [string, string, string, string, string];\n\nexport interface ThemeConfig extends ThemeScheme {\n /** Corner radius the whole scale is derived from, e.g. `0.5rem`. */\n radius: string;\n /** Body font stack. */\n fontSans: string;\n /**\n * Dark-scheme overrides. Anything left out falls back to the light value —\n * which is a legibility bug more often than a shortcut, so override on purpose.\n * `radius` and `fontSans` are absent here: they do not vary by scheme.\n */\n dark?: {\n primary?: string;\n spaces?: Partial<ThemeSpaces>;\n status?: Partial<ThemeStatus>;\n charts?: ThemeCharts;\n };\n}\n\nexport interface ResolvedTheme {\n radius: string;\n fontSans: string;\n light: ThemeScheme;\n /** Fully resolved — every key of {@link ThemeScheme}, never a partial. */\n dark: ThemeScheme;\n}\n\n/**\n * `defineTheme`'s output, as opposed to the config that still has to go through it.\n *\n * Lives here rather than in each loader: a `theme.config` module may export either\n * shape, and every loader has to tell them apart the same way or dev and prod\n * disagree on what counts as already-validated.\n */\nexport function isResolvedTheme(value: unknown): value is ResolvedTheme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'light' in value &&\n 'dark' in value &&\n typeof (value as ResolvedTheme).radius === 'string' &&\n typeof (value as ResolvedTheme).fontSans === 'string'\n );\n}\n\n/**\n * The keys of each colour group, in CSS emission order.\n *\n * Single source: validation, resolution and the DTCG generator all read these, so\n * a new token cannot be added to half the pipeline. Internal — `src/index.ts`\n * decides the public API.\n */\nexport const SPACE_KEYS = ['crm', 'experience', 'influence', 'pilotage', 'proSante'] as const;\nexport const STATUS_KEYS = ['success', 'pending', 'approved', 'blocked', 'paused', 'info'] as const;\nconst CHART_COUNT = 5;\n\nfunction requireColor(value: unknown, path: string): string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`theme: \\`${path}\\` must be a non-empty colour string`);\n }\n // The generated CSS is inlined into a <style> tag, so a value carrying markup\n // would escape it. No colour needs these characters.\n if (/[<>]/.test(value)) {\n throw new Error(`theme: \\`${path}\\` must not contain \\`<\\` or \\`>\\``);\n }\n return value;\n}\n\nfunction requireGroup(value: unknown, path: string): void {\n if (typeof value !== 'object' || value === null) {\n throw new Error(`theme: \\`${path}\\` must be an object`);\n }\n}\n\n/** One colour group, overrides layered over the base, every key checked. */\nfunction resolveGroup<K extends string>(\n keys: readonly K[],\n base: Record<K, string>,\n overrides: Partial<Record<K, string>> | undefined,\n path: string,\n): Record<K, string> {\n requireGroup(base, path);\n // A non-object override is not a partial override — it is every key silently\n // falling back to light, which is exactly the bug this package exists to stop.\n if (overrides !== undefined) requireGroup(overrides, path);\n return Object.fromEntries(\n keys.map((key) => [key, requireColor(overrides?.[key] ?? base[key], `${path}.${key}`)]),\n ) as Record<K, string>;\n}\n\nfunction resolveScheme(\n base: ThemeScheme,\n overrides: ThemeConfig['dark'],\n path: 'light' | 'dark',\n): ThemeScheme {\n const spaces = resolveGroup(SPACE_KEYS, base.spaces, overrides?.spaces, `${path}.spaces`);\n const status = resolveGroup(STATUS_KEYS, base.status, overrides?.status, `${path}.status`);\n\n const charts = overrides?.charts ?? base.charts;\n if (!Array.isArray(charts) || charts.length !== CHART_COUNT) {\n throw new Error(`theme: \\`${path}.charts\\` must hold exactly ${CHART_COUNT} colours`);\n }\n charts.forEach((value, i) => requireColor(value, `${path}.charts[${i}]`));\n\n return {\n primary: requireColor(overrides?.primary ?? base.primary, `${path}.primary`),\n spaces,\n status,\n charts,\n };\n}\n\n/**\n * Validate a theme and resolve its dark scheme against its light one.\n *\n * The type makes an unknown or missing key a compile error; the checks here make\n * it a loud runtime error too, because `theme.config.ts` is loaded as plain JS by\n * the API and TypeScript is not there to catch it.\n */\nexport function defineTheme(config: ThemeConfig): ResolvedTheme {\n if (typeof config?.radius !== 'string' || config.radius.trim() === '') {\n throw new Error('theme: `radius` must be a non-empty CSS length');\n }\n if (typeof config.fontSans !== 'string' || config.fontSans.trim() === '') {\n throw new Error('theme: `fontSans` must be a non-empty font stack');\n }\n\n if (config.dark !== undefined) requireGroup(config.dark, 'dark');\n\n const light = resolveScheme(config, undefined, 'light');\n return {\n radius: config.radius,\n fontSans: config.fontSans,\n light,\n dark: resolveScheme(light, config.dark, 'dark'),\n };\n}\n","/**\n * The theme the platform ships with — and the fallback compiled into\n * `apps/web/src/index.css`, so a failed runtime injection degrades to the\n * platform look, never to unstyled.\n *\n * Values follow the WOS design system (wopilo-dashboard2), like the chrome\n * primitives in the shell stylesheet: Nuit `#041C2D` is the light-scheme brand\n * and Jour `#FFA800` the dark one — `--primary-foreground` is near-white in\n * light and near-black in dark, and that pairing is the only one both colours\n * pass contrast with. The dark scheme lifts the same hues to a legible\n * lightness, with Menthe `#95DFBA` as the mint accent.\n *\n * An admin can recover ANY of this from Paramètres › Thème: the DB row layers\n * over this default, and resetting deletes the row.\n */\nimport { defineTheme } from './theme.js';\n\nexport const defaultTheme = defineTheme({\n radius: '0.625rem',\n // Inter is the WOS typeface but the platform does not bundle it, so this\n // reads as \"Inter if the machine has it, system stack otherwise\".\n fontSans:\n \"Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\",\n\n primary: '#041C2D',\n\n spaces: {\n crm: '#35618A',\n experience: '#5B7387',\n influence: '#B5432A',\n pilotage: '#FFA800',\n proSante: '#3E9B77',\n },\n\n status: {\n success: '#1F7D54',\n pending: '#9A6B12',\n approved: '#35618A',\n blocked: '#B5432A',\n paused: '#7A8089',\n info: '#5B7387',\n },\n\n /**\n * Categorical palette from the WOS attribution screens (sure / decl / extr /\n * leak / sure-green). Every entry clears 4.5:1 on white — well past the 3:1\n * WCAG asks of a graphical object.\n */\n charts: ['#041C2D', '#9A6B12', '#5B7387', '#B5432A', '#1F7D54'],\n\n dark: {\n primary: '#FFA800',\n spaces: {\n crm: '#7FA8CC',\n experience: '#93A9BC',\n influence: '#D97B63',\n pilotage: '#FFB733',\n proSante: '#95DFBA',\n },\n status: {\n success: '#7ED4A6',\n pending: '#D9A83E',\n approved: '#7FA8CC',\n blocked: '#D97B63',\n paused: '#9AA1AA',\n info: '#93A9BC',\n },\n // Same hues, lifted to stay legible on the dark card.\n charts: ['#7FA8CC', '#FFA800', '#93A9BC', '#D97B63', '#95DFBA'],\n },\n});\n","/**\n * The primitive scales — type, spacing, elevation.\n *\n * Not part of `ThemeConfig`: an instance restyles the brand, it does not redraw\n * the grid the product is built on. They live here rather than being inherited\n * from Tailwind's defaults so the platform owns them: a Tailwind upgrade cannot\n * move the product's type, and P4's generated catalogue has one place to read.\n *\n * The values are today's, deliberately. Figma's hi-fi frames use a denser scale\n * (11 / 12 / 13 / 18 / 20 / 22 px against 12 / 14 / 16 / 18 / 20 / 24) and the\n * observed figure is recorded on each step — adopting it moves every screen in\n * the product, so it is a decision with a visual audit attached, not a rename.\n * When that decision is made, it is made here.\n */\n\nexport interface TypeStep {\n /** Tailwind's `text-<key>`. */\n key: string;\n size: string;\n /** Paired line height. Tailwind reads it as `--text-<key>--line-height`. */\n lineHeight: string;\n /** What the Figma frames use at this step, for the day the scale is reconciled. */\n figmaPx?: number;\n}\n\nexport const TYPE_SCALE: readonly TypeStep[] = [\n { key: 'xs', size: '0.75rem', lineHeight: 'calc(1 / 0.75)', figmaPx: 11 },\n { key: 'sm', size: '0.875rem', lineHeight: 'calc(1.25 / 0.875)', figmaPx: 12 },\n { key: 'base', size: '1rem', lineHeight: 'calc(1.5 / 1)', figmaPx: 13 },\n { key: 'lg', size: '1.125rem', lineHeight: 'calc(1.75 / 1.125)', figmaPx: 18 },\n { key: 'xl', size: '1.25rem', lineHeight: 'calc(1.75 / 1.25)', figmaPx: 20 },\n { key: '2xl', size: '1.5rem', lineHeight: 'calc(2 / 1.5)', figmaPx: 22 },\n { key: '3xl', size: '1.875rem', lineHeight: 'calc(2.25 / 1.875)' },\n];\n\n/**\n * The step every `p-`, `gap-` and `m-` utility multiplies. Figma's frames sit on\n * the same 4px grid, so this one needs no reconciling.\n */\nexport const SPACING_STEP = '0.25rem';\n\n/**\n * The platform has exactly one card elevation. The value is WOS's `--shadow`:\n * a whisper-soft double layer tinted with Nuit, where Tailwind's defaults are\n * neutral and tight. Offered as its own token rather than by overriding\n * `--shadow-sm`, which would restyle every existing surface.\n */\nexport const SHADOWS: Readonly<Record<string, string>> = {\n card: '0 1px 2px rgb(4 28 45 / 0.04), 0 2px 6px rgb(4 28 45 / 0.05)',\n};\n\n/**\n * The primitives as a Tailwind `@theme` block.\n *\n * `@theme`, not `:root`: these are the vocabulary Tailwind generates utilities\n * from, and unlike the brand layer they are fixed at build time.\n */\nexport function primitivesToCss(): string {\n const lines = [\n ...TYPE_SCALE.flatMap((step) => [\n `--text-${step.key}: ${step.size};`,\n `--text-${step.key}--line-height: ${step.lineHeight};`,\n ]),\n `--spacing: ${SPACING_STEP};`,\n ...Object.entries(SHADOWS).map(([key, value]) => `--shadow-${key}: ${value};`),\n ];\n return `@theme {\\n${lines.map((line) => ` ${line}`).join('\\n')}\\n}\\n`;\n}\n","/**\n * DTCG (W3C Design Tokens) as the generator's intermediate format.\n *\n * Nothing here is public API — `themeToCss` is. The point of the detour is that a\n * Figma Variables export speaks DTCG: when that lands it plugs in as another\n * producer of these groups instead of a rewrite of the CSS generator.\n *\n * Token path → CSS custom property is mechanical: kebab-case each segment and\n * join with `-`. `space.proSante` → `--space-pro-sante`, `font.sans` →\n * `--font-sans`, `chart.1` → `--chart-1`. That is why the group names below are\n * the CSS prefixes and not prettier words.\n */\nimport { SPACE_KEYS, STATUS_KEYS, type ResolvedTheme, type ThemeScheme } from './theme.js';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily';\n\nexport interface DtcgToken {\n $type: DtcgType;\n $value: string;\n}\n\nexport interface DtcgGroup {\n [key: string]: DtcgToken | DtcgGroup;\n}\n\nconst isToken = (node: DtcgToken | DtcgGroup): node is DtcgToken => '$value' in node;\n\nconst color = ($value: string): DtcgToken => ({ $type: 'color', $value });\n\nconst colorGroup = <K extends string>(keys: readonly K[], group: Record<K, string>): DtcgGroup =>\n Object.fromEntries(keys.map((key) => [key, color(group[key])]));\n\n/** Colour tokens of one scheme — the keys that must exist in both `:root` and `.dark`. */\nexport function schemeToDtcg(scheme: ThemeScheme): DtcgGroup {\n return {\n primary: color(scheme.primary),\n space: colorGroup(SPACE_KEYS, scheme.spaces),\n status: colorGroup(STATUS_KEYS, scheme.status),\n chart: Object.fromEntries(scheme.charts.map((value, i) => [String(i + 1), color(value)])),\n };\n}\n\n/** Tokens that do not vary by scheme, so they are emitted in `:root` only. */\nexport function invariantsToDtcg(theme: ResolvedTheme): DtcgGroup {\n return {\n radius: { $type: 'dimension', $value: theme.radius },\n font: { sans: { $type: 'fontFamily', $value: theme.fontSans } },\n };\n}\n\nconst kebab = (segment: string) => segment.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/** `--custom-property: value;` for every token in the group, depth-first. */\nexport function dtcgToCustomProperties(group: DtcgGroup, path: string[] = []): string[] {\n return Object.entries(group).flatMap(([key, node]) => {\n const next = [...path, kebab(key)];\n return isToken(node)\n ? [`--${next.join('-')}: ${node.$value};`]\n : dtcgToCustomProperties(node, next);\n });\n}\n","import { dtcgToCustomProperties, invariantsToDtcg, schemeToDtcg } from './dtcg.js';\nimport type { ResolvedTheme } from './theme.js';\n\n/**\n * The id carried by the `<style>` tag this CSS is inlined into — the handle the\n * live theme is found by (`document.getElementById('apotech-theme')`).\n *\n * It is a cross-process contract: the API inlines the tag in production and the\n * dev Vite plugin inlines it in `pnpm dev`, so both must spell it the same way.\n */\nexport const THEME_STYLE_ID = 'apotech-theme';\n\nconst block = (selector: string, declarations: string[]) =>\n `${selector} {\\n${declarations.map((line) => ` ${line}`).join('\\n')}\\n}`;\n\n/**\n * Render a theme as `:root { … } .dark { … }`.\n *\n * Only *values* are emitted. The `@theme inline` vocabulary that teaches Tailwind\n * about `bg-primary` and friends stays at build time in `index.css` — a client\n * restyles the words, it does not add any.\n */\nexport function themeToCss(theme: ResolvedTheme): string {\n const root = [\n ...dtcgToCustomProperties(invariantsToDtcg(theme)),\n ...dtcgToCustomProperties(schemeToDtcg(theme.light)),\n ];\n return `${block(':root', root)}\\n${block('.dark', dtcgToCustomProperties(schemeToDtcg(theme.dark)))}\\n`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apotech-os/tokens",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",