@kuniversedev/design-tokens 1.0.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/css.cjs ADDED
@@ -0,0 +1,348 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/css-vars.ts
21
+ var css_vars_exports = {};
22
+ __export(css_vars_exports, {
23
+ applyCSSVarsToDocument: () => applyCSSVarsToDocument,
24
+ cssVarsString: () => cssVarsString,
25
+ darkThemeCSS: () => darkThemeCSS,
26
+ flattenTokens: () => flattenTokens,
27
+ generateCSSVars: () => generateCSSVars,
28
+ generateCompleteCSS: () => generateCompleteCSS,
29
+ generateDarkThemeCSS: () => generateDarkThemeCSS,
30
+ generateLightThemeCSS: () => generateLightThemeCSS,
31
+ getCSSVar: () => getCSSVar,
32
+ lightThemeCSS: () => lightThemeCSS,
33
+ setCSSVar: () => setCSSVar
34
+ });
35
+ module.exports = __toCommonJS(css_vars_exports);
36
+
37
+ // src/index.ts
38
+ var colorsImpl = {
39
+ // Base neutrals
40
+ black: "#000000",
41
+ white: "#FFFFFF",
42
+ gray: {
43
+ 100: "#F5F5F5",
44
+ 300: "#D4D4D4",
45
+ 500: "#737373",
46
+ 700: "#404040",
47
+ 900: "#171717"
48
+ },
49
+ // Dark mode semantic surfaces
50
+ background: "#0A0A0A",
51
+ surface: "#1A1A1A",
52
+ foreground: "#FFFFFF",
53
+ muted: "#2A2A2A",
54
+ border: "#333333",
55
+ // Accent / status
56
+ primary: "#0066FF",
57
+ secondary: "#00CC88",
58
+ success: "#00DD77",
59
+ error: "#FF3333",
60
+ warning: "#FFAA00"
61
+ };
62
+ var typographyImpl = {
63
+ fontFamily: {
64
+ sans: 'Power Grotesk, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
65
+ mono: 'JetBrains Mono, "Fira Code", monospace',
66
+ display: 'Power Grotesk, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
67
+ },
68
+ scale: {
69
+ hero: { size: "4rem", lineHeight: "1.125", weight: 700 },
70
+ // 64px
71
+ h1: { size: "3rem", lineHeight: "1.167", weight: 700 },
72
+ // 48px
73
+ h2: { size: "2rem", lineHeight: "1.25", weight: 600 },
74
+ // 32px
75
+ h3: { size: "1.5rem", lineHeight: "1.333", weight: 600 },
76
+ // 24px
77
+ body: { size: "1rem", lineHeight: "1.5", weight: 400 },
78
+ // 16px
79
+ small: { size: "0.875rem", lineHeight: "1.429", weight: 400 },
80
+ // 14px
81
+ tiny: { size: "0.75rem", lineHeight: "1.333", weight: 400 }
82
+ // 12px
83
+ },
84
+ fontWeight: {
85
+ thin: 200,
86
+ light: 300,
87
+ regular: 400,
88
+ medium: 500,
89
+ semibold: 600,
90
+ bold: 700,
91
+ black: 900
92
+ }
93
+ };
94
+ var spacingImpl = {
95
+ 0: "0",
96
+ 1: "4px",
97
+ 2: "8px",
98
+ 3: "12px",
99
+ 4: "16px",
100
+ 5: "20px",
101
+ 6: "24px",
102
+ 7: "28px",
103
+ 8: "32px",
104
+ 9: "36px",
105
+ 10: "40px",
106
+ 12: "48px",
107
+ 14: "56px",
108
+ 15: "60px",
109
+ // K-Universe 60px margin principle
110
+ 16: "64px",
111
+ 18: "72px",
112
+ 20: "80px",
113
+ 24: "96px",
114
+ 32: "128px"
115
+ };
116
+ var motionImpl = {
117
+ duration: {
118
+ instant: "100ms",
119
+ fast: "200ms",
120
+ default: "300ms",
121
+ slow: "500ms",
122
+ crawl: "800ms"
123
+ },
124
+ easing: {
125
+ default: "cubic-bezier(0.4, 0, 0.2, 1)",
126
+ smooth: "cubic-bezier(0.25, 0.1, 0.25, 1)",
127
+ sharp: "cubic-bezier(0.4, 0, 0.6, 1)",
128
+ accelerate: "cubic-bezier(0.4, 0, 1, 1)",
129
+ decelerate: "cubic-bezier(0, 0, 0.2, 1)"
130
+ }
131
+ };
132
+ var layoutImpl = {
133
+ margin: "60px",
134
+ // primary horizontal landmark
135
+ sectionSpacing: "96px",
136
+ container: {
137
+ sm: "640px",
138
+ md: "768px",
139
+ lg: "1024px",
140
+ xl: "1280px",
141
+ max: "1320px"
142
+ // K-Universe max-width
143
+ },
144
+ measure: "65ch"
145
+ };
146
+ var radiusImpl = {
147
+ none: "0",
148
+ xs: "2px",
149
+ sm: "4px",
150
+ md: "6px",
151
+ lg: "8px",
152
+ xl: "12px",
153
+ "2xl": "16px",
154
+ "3xl": "24px",
155
+ round: "9999px"
156
+ };
157
+ var shadowsImpl = {
158
+ xs: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
159
+ sm: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
160
+ md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
161
+ lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
162
+ xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
163
+ "2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
164
+ inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.05)",
165
+ cardHover: "0 20px 55px rgba(0, 0, 0, 0.55)",
166
+ elevated: "0 24px 60px rgba(0, 0, 0, 0.45)"
167
+ };
168
+ var zIndexImpl = {
169
+ bg: -1,
170
+ base: 0,
171
+ content: 10,
172
+ dropdown: 100,
173
+ sticky: 200,
174
+ overlay: 300,
175
+ modal: 400,
176
+ popover: 500,
177
+ tooltip: 600,
178
+ toast: 700
179
+ };
180
+ var borderWidthImpl = {
181
+ thin: "1px",
182
+ base: "2px",
183
+ thick: "4px"
184
+ };
185
+ var tokens = {
186
+ colors: colorsImpl,
187
+ typography: typographyImpl,
188
+ spacing: spacingImpl,
189
+ motion: motionImpl,
190
+ layout: layoutImpl,
191
+ radius: radiusImpl,
192
+ shadows: shadowsImpl,
193
+ zIndex: zIndexImpl,
194
+ borderWidth: borderWidthImpl
195
+ };
196
+ var colors = tokens.colors;
197
+ var typography = tokens.typography;
198
+ var spacing = tokens.spacing;
199
+ var motion = tokens.motion;
200
+ var layout = tokens.layout;
201
+ var radius = tokens.radius;
202
+ var shadows = tokens.shadows;
203
+ var zIndex = tokens.zIndex;
204
+ var borderWidth = tokens.borderWidth;
205
+
206
+ // src/css-vars.ts
207
+ function toKebab(str) {
208
+ return str.replace(/([a-z\d])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase();
209
+ }
210
+ var CATEGORY_PREFIXES = {
211
+ colors: "color",
212
+ typography: "",
213
+ // further split per sub-key (font-family, scale, font-weight)
214
+ spacing: "spacing",
215
+ motion: "",
216
+ // split: duration, easing
217
+ layout: "layout",
218
+ radius: "radius",
219
+ shadows: "shadow",
220
+ zIndex: "z-index",
221
+ borderWidth: "border-width"
222
+ };
223
+ function flattenTokens(obj, prefix) {
224
+ if (obj === null || obj === void 0) return [];
225
+ if (typeof obj !== "object" || Array.isArray(obj)) {
226
+ return [[`--${prefix}`, String(obj)]];
227
+ }
228
+ const pairs = [];
229
+ for (const [key, value] of Object.entries(obj)) {
230
+ const segment = toKebab(key);
231
+ const nextPrefix = prefix ? `${prefix}-${segment}` : segment;
232
+ pairs.push(...flattenTokens(value, nextPrefix));
233
+ }
234
+ return pairs;
235
+ }
236
+ function pairsForCategory(categoryKey, value) {
237
+ const prefix = CATEGORY_PREFIXES[categoryKey];
238
+ return flattenTokens(value, prefix);
239
+ }
240
+ function buildPairs(t) {
241
+ const pairs = [];
242
+ for (const key of Object.keys(t)) {
243
+ pairs.push(...pairsForCategory(key, t[key]));
244
+ }
245
+ return pairs;
246
+ }
247
+ function pairsToLines(pairs, indent = " ") {
248
+ return pairs.map(([name, val]) => `${indent}${name}: ${val};`).join("\n");
249
+ }
250
+ var SECTION_LABELS = {
251
+ colors: "Colors",
252
+ typography: "Typography",
253
+ spacing: "Spacing",
254
+ motion: "Motion",
255
+ layout: "Layout",
256
+ radius: "Border Radius",
257
+ shadows: "Shadows",
258
+ zIndex: "Z-Index",
259
+ borderWidth: "Border Width"
260
+ };
261
+ function buildSectionedCSSBody(t, indent = " ") {
262
+ const sections = [];
263
+ for (const key of Object.keys(t)) {
264
+ const label = SECTION_LABELS[key] ?? key;
265
+ const pairs = pairsForCategory(key, t[key]);
266
+ if (pairs.length === 0) continue;
267
+ sections.push(`${indent}/* ${label} */`);
268
+ sections.push(pairsToLines(pairs, indent));
269
+ }
270
+ return sections.join("\n");
271
+ }
272
+ var LIGHT_THEME_OVERRIDES = [
273
+ ["--color-background", "#FFFFFF"],
274
+ ["--color-foreground", "#000000"],
275
+ ["--color-surface", "#F5F5F5"],
276
+ ["--color-muted", "#E5E5E5"],
277
+ ["--color-border", "#D4D4D4"]
278
+ ];
279
+ function generateCSSVars(t, prefix) {
280
+ let pairs = buildPairs(t);
281
+ if (prefix) {
282
+ pairs = pairs.map(([name, val]) => [`--${prefix}-${name.slice(2)}`, val]);
283
+ }
284
+ return `:root {
285
+ ${pairsToLines(pairs)}
286
+ }`;
287
+ }
288
+ function generateDarkThemeCSS(t) {
289
+ const body = buildSectionedCSSBody(t);
290
+ return `:root {
291
+ ${body}
292
+ }`;
293
+ }
294
+ function generateLightThemeCSS(_t) {
295
+ const lines = LIGHT_THEME_OVERRIDES.map(([name, val]) => ` ${name}: ${val};`).join("\n");
296
+ return `[data-theme="light"] {
297
+ ${lines}
298
+ }`;
299
+ }
300
+ function generateCompleteCSS(t) {
301
+ return [
302
+ generateDarkThemeCSS(t),
303
+ "",
304
+ generateLightThemeCSS(t)
305
+ ].join("\n");
306
+ }
307
+ function applyCSSVarsToDocument(theme) {
308
+ if (typeof document === "undefined") return;
309
+ const root = document.documentElement;
310
+ const pairs = buildPairs(tokens);
311
+ for (const [name, value] of pairs) {
312
+ root.style.setProperty(name, value);
313
+ }
314
+ if (theme === "light") {
315
+ root.setAttribute("data-theme", "light");
316
+ for (const [name, value] of LIGHT_THEME_OVERRIDES) {
317
+ root.style.setProperty(name, value);
318
+ }
319
+ } else {
320
+ root.removeAttribute("data-theme");
321
+ }
322
+ }
323
+ function getCSSVar(name) {
324
+ if (typeof document === "undefined") return "";
325
+ return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
326
+ }
327
+ function setCSSVar(name, value) {
328
+ if (typeof document === "undefined") return;
329
+ document.documentElement.style.setProperty(name, value);
330
+ }
331
+ var cssVarsString = generateCSSVars(tokens);
332
+ var darkThemeCSS = generateDarkThemeCSS(tokens);
333
+ var lightThemeCSS = generateLightThemeCSS(tokens);
334
+ // Annotate the CommonJS export names for ESM import in node:
335
+ 0 && (module.exports = {
336
+ applyCSSVarsToDocument,
337
+ cssVarsString,
338
+ darkThemeCSS,
339
+ flattenTokens,
340
+ generateCSSVars,
341
+ generateCompleteCSS,
342
+ generateDarkThemeCSS,
343
+ generateLightThemeCSS,
344
+ getCSSVar,
345
+ lightThemeCSS,
346
+ setCSSVar
347
+ });
348
+ //# sourceMappingURL=css.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/css-vars.ts","../src/index.ts"],"sourcesContent":["/**\n * @k-universe/design-tokens — CSS custom properties generation\n *\n * Generates CSS variable strings from the token object and provides\n * browser utilities for applying / reading / writing CSS vars at runtime.\n *\n * Package exports needed (add to package.json exports — handled by Agent 5 / build config):\n * \"./css\": \"./src/css-vars.ts\"\n * \"./standalone/css\": \"./src/standalone/tokens.css\"\n */\n\n// Package exports needed: \"./css\": \"./src/css-vars.ts\", \"./standalone/css\": \"./src/standalone/tokens.css\"\n\nimport type { DesignTokens } from './types.js';\nimport { tokens } from './index.js';\n\n// ---------------------------------------------------------------------------\n// Internal: camelCase / PascalCase → kebab-case\n// ---------------------------------------------------------------------------\n\n/**\n * Converts a camelCase or PascalCase segment to kebab-case.\n * Numeric-only segments are left as-is (e.g. '100', '2xl').\n */\nfunction toKebab(str: string): string {\n return str\n // Insert hyphen before uppercase letters that follow a lowercase/digit\n .replace(/([a-z\\d])([A-Z])/g, '$1-$2')\n // Insert hyphen before uppercase letters that are followed by lowercase (e.g. XMLParser → xml-parser)\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n}\n\n// ---------------------------------------------------------------------------\n// Internal: CSS-var name prefix map per top-level token category\n// ---------------------------------------------------------------------------\n\nconst CATEGORY_PREFIXES: Record<string, string> = {\n colors: 'color',\n typography: '', // further split per sub-key (font-family, scale, font-weight)\n spacing: 'spacing',\n motion: '', // split: duration, easing\n layout: 'layout',\n radius: 'radius',\n shadows: 'shadow',\n zIndex: 'z-index',\n borderWidth: 'border-width',\n};\n\n// ---------------------------------------------------------------------------\n// Internal: flattenTokens\n// ---------------------------------------------------------------------------\n\n/**\n * Recursively walks an object and produces a flat array of\n * `['--name', 'value']` pairs for every leaf node.\n *\n * @param obj - The (sub-)object to walk.\n * @param prefix - Accumulated CSS-var name prefix (without leading `--`).\n * @returns Array of `[varName, value]` tuples.\n */\nexport function flattenTokens(\n obj: unknown,\n prefix: string,\n): Array<[string, string]> {\n if (obj === null || obj === undefined) return [];\n\n if (typeof obj !== 'object' || Array.isArray(obj)) {\n // Leaf value — emit the var\n return [[`--${prefix}`, String(obj)]];\n }\n\n const pairs: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n const segment = toKebab(key);\n const nextPrefix = prefix ? `${prefix}-${segment}` : segment;\n pairs.push(...flattenTokens(value, nextPrefix));\n }\n\n return pairs;\n}\n\n// ---------------------------------------------------------------------------\n// Internal: build pairs for one top-level token category\n// ---------------------------------------------------------------------------\n\nfunction pairsForCategory(\n categoryKey: keyof DesignTokens,\n value: unknown,\n): Array<[string, string]> {\n const prefix = CATEGORY_PREFIXES[categoryKey as string];\n return flattenTokens(value, prefix);\n}\n\n// ---------------------------------------------------------------------------\n// Internal: build the full flat pairs map from a DesignTokens object\n// ---------------------------------------------------------------------------\n\nfunction buildPairs(t: DesignTokens): Array<[string, string]> {\n const pairs: Array<[string, string]> = [];\n\n for (const key of Object.keys(t) as Array<keyof DesignTokens>) {\n pairs.push(...pairsForCategory(key, t[key]));\n }\n\n return pairs;\n}\n\n// ---------------------------------------------------------------------------\n// Internal: pairs → CSS property lines, indented\n// ---------------------------------------------------------------------------\n\nfunction pairsToLines(pairs: Array<[string, string]>, indent = ' '): string {\n return pairs.map(([name, val]) => `${indent}${name}: ${val};`).join('\\n');\n}\n\n// ---------------------------------------------------------------------------\n// Internal: section-commented block builder\n// ---------------------------------------------------------------------------\n\nconst SECTION_LABELS: Partial<Record<keyof DesignTokens, string>> = {\n colors: 'Colors',\n typography: 'Typography',\n spacing: 'Spacing',\n motion: 'Motion',\n layout: 'Layout',\n radius: 'Border Radius',\n shadows: 'Shadows',\n zIndex: 'Z-Index',\n borderWidth: 'Border Width',\n};\n\nfunction buildSectionedCSSBody(t: DesignTokens, indent = ' '): string {\n const sections: string[] = [];\n\n for (const key of Object.keys(t) as Array<keyof DesignTokens>) {\n const label = SECTION_LABELS[key] ?? key;\n const pairs = pairsForCategory(key, t[key]);\n if (pairs.length === 0) continue;\n\n sections.push(`${indent}/* ${label} */`);\n sections.push(pairsToLines(pairs, indent));\n }\n\n return sections.join('\\n');\n}\n\n// ---------------------------------------------------------------------------\n// Light-theme overrides (semantic surface colours only)\n// ---------------------------------------------------------------------------\n\n/**\n * The light theme overrides only the semantic surface tokens.\n * All other tokens (spacing, motion, etc.) remain unchanged.\n */\nconst LIGHT_THEME_OVERRIDES: Array<[string, string]> = [\n ['--color-background', '#FFFFFF'],\n ['--color-foreground', '#000000'],\n ['--color-surface', '#F5F5F5'],\n ['--color-muted', '#E5E5E5'],\n ['--color-border', '#D4D4D4'],\n];\n\n// ---------------------------------------------------------------------------\n// Public: generateCSSVars\n// ---------------------------------------------------------------------------\n\n/**\n * Generates a `:root { ... }` CSS block string from a DesignTokens object.\n *\n * @param t - Token object to generate from.\n * @param prefix - Optional additional prefix for all var names (rarely needed).\n *\n * @example\n * ```typescript\n * import { generateCSSVars, tokens } from \"@k-universe/design-tokens/css\";\n * const css = generateCSSVars(tokens);\n * // \":root {\\n --color-background: #0A0A0A;\\n ...\\n}\"\n * ```\n */\nexport function generateCSSVars(t: DesignTokens, prefix?: string): string {\n let pairs = buildPairs(t);\n\n if (prefix) {\n pairs = pairs.map(([name, val]) => [`--${prefix}-${name.slice(2)}`, val]);\n }\n\n return `:root {\\n${pairsToLines(pairs)}\\n}`;\n}\n\n// ---------------------------------------------------------------------------\n// Public: generateDarkThemeCSS\n// ---------------------------------------------------------------------------\n\n/**\n * Generates the dark-theme `:root { ... }` block.\n * Dark mode is the default / primary context for K-Universe.\n *\n * @example\n * ```typescript\n * const css = generateDarkThemeCSS(tokens);\n * ```\n */\nexport function generateDarkThemeCSS(t: DesignTokens): string {\n const body = buildSectionedCSSBody(t);\n return `:root {\\n${body}\\n}`;\n}\n\n// ---------------------------------------------------------------------------\n// Public: generateLightThemeCSS\n// ---------------------------------------------------------------------------\n\n/**\n * Generates the `[data-theme=\"light\"] { ... }` override block.\n * Only overrides semantic surface colours — all other tokens are inherited.\n *\n * @example\n * ```typescript\n * const css = generateLightThemeCSS(tokens);\n * ```\n */\nexport function generateLightThemeCSS(_t: DesignTokens): string {\n const lines = LIGHT_THEME_OVERRIDES\n .map(([name, val]) => ` ${name}: ${val};`)\n .join('\\n');\n return `[data-theme=\"light\"] {\\n${lines}\\n}`;\n}\n\n// ---------------------------------------------------------------------------\n// Public: generateCompleteCSS\n// ---------------------------------------------------------------------------\n\n/**\n * Generates the complete CSS: dark `:root` block + light `[data-theme=\"light\"]` block.\n *\n * @example\n * ```typescript\n * import { generateCompleteCSS, tokens } from \"@k-universe/design-tokens/css\";\n *\n * // In a Next.js layout or global stylesheet:\n * const css = generateCompleteCSS(tokens);\n * ```\n */\nexport function generateCompleteCSS(t: DesignTokens): string {\n return [\n generateDarkThemeCSS(t),\n '',\n generateLightThemeCSS(t),\n ].join('\\n');\n}\n\n// ---------------------------------------------------------------------------\n// Public: applyCSSVarsToDocument\n// ---------------------------------------------------------------------------\n\n/**\n * Applies all design tokens as CSS custom properties to `document.documentElement`.\n * SSR-safe — no-ops when `document` is not available.\n *\n * @param theme - Optional theme override. Defaults to dark (no attribute set).\n * Passing `'light'` sets `data-theme=\"light\"` on `<html>`.\n * Passing `'dark'` removes the attribute.\n *\n * @example\n * ```typescript\n * // In a client-only bootstrap file:\n * import { applyCSSVarsToDocument } from \"@k-universe/design-tokens/css\";\n * applyCSSVarsToDocument(); // dark theme (default)\n * applyCSSVarsToDocument('light'); // light theme\n * ```\n */\nexport function applyCSSVarsToDocument(theme?: 'dark' | 'light'): void {\n if (typeof document === 'undefined') return;\n\n const root = document.documentElement;\n const pairs = buildPairs(tokens);\n\n for (const [name, value] of pairs) {\n root.style.setProperty(name, value);\n }\n\n if (theme === 'light') {\n root.setAttribute('data-theme', 'light');\n for (const [name, value] of LIGHT_THEME_OVERRIDES) {\n root.style.setProperty(name, value);\n }\n } else {\n root.removeAttribute('data-theme');\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public: getCSSVar / setCSSVar\n// ---------------------------------------------------------------------------\n\n/**\n * Reads a CSS custom property value from `document.documentElement` at runtime.\n * Returns an empty string when called server-side.\n *\n * @param name - Full CSS var name including `--`, e.g. `'--color-primary'`.\n *\n * @example\n * ```typescript\n * const primary = getCSSVar('--color-primary'); // '#0066FF'\n * ```\n */\nexport function getCSSVar(name: string): string {\n if (typeof document === 'undefined') return '';\n return getComputedStyle(document.documentElement).getPropertyValue(name).trim();\n}\n\n/**\n * Sets a CSS custom property on `document.documentElement` at runtime.\n * No-ops when called server-side.\n *\n * @param name - Full CSS var name including `--`, e.g. `'--color-primary'`.\n * @param value - The new value.\n *\n * @example\n * ```typescript\n * setCSSVar('--color-primary', '#FF6600');\n * ```\n */\nexport function setCSSVar(name: string, value: string): void {\n if (typeof document === 'undefined') return;\n document.documentElement.style.setProperty(name, value);\n}\n\n// ---------------------------------------------------------------------------\n// Pre-computed exports (generated at module load time)\n// ---------------------------------------------------------------------------\n\n/**\n * Pre-computed flat `:root { ... }` CSS string from the default token set.\n * Import and inject directly into a `<style>` tag or CSS-in-JS system.\n *\n * @example\n * ```typescript\n * import { cssVarsString } from \"@k-universe/design-tokens/css\";\n * // inject into a <style> tag in layout.tsx\n * ```\n */\nexport const cssVarsString: string = generateCSSVars(tokens);\n\n/**\n * Pre-computed dark-theme `:root { ... }` block with section comments.\n */\nexport const darkThemeCSS: string = generateDarkThemeCSS(tokens);\n\n/**\n * Pre-computed `[data-theme=\"light\"] { ... }` override block.\n */\nexport const lightThemeCSS: string = generateLightThemeCSS(tokens);\n","/**\n * @k-universe/design-tokens\n *\n * Foundational design token implementation for K-Universe.\n * All values are authoritative — derived from the K-Universe design system spec.\n *\n * @example\n * ```typescript\n * import { tokens } from \"@k-universe/design-tokens\";\n *\n * tokens.colors.background // '#0A0A0A'\n * tokens.colors.foreground // '#FFFFFF'\n * tokens.colors.secondary // '#00CC88'\n * tokens.typography.fontFamily.sans // 'Power Grotesk, ...'\n * ```\n */\n\n// Re-export all types from the types module\nexport type {\n ColorToken,\n DimensionToken,\n DurationToken,\n EasingToken,\n ShadowToken,\n ColorScale,\n ColorTokens,\n TypeScaleEntry,\n FontFamilyTokens,\n TypeScaleTokens,\n FontWeightTokens,\n TypographyTokens,\n SpacingTokens,\n DurationTokens,\n EasingTokens,\n MotionTokens,\n ContainerTokens,\n LayoutTokens,\n RadiusTokens,\n ShadowTokens,\n ZIndexTokens,\n BorderWidthTokens,\n DesignTokens,\n} from './types.js';\n\nimport type { DesignTokens } from './types.js';\n\n// ---------------------------------------------------------------------------\n// Colors\n// ---------------------------------------------------------------------------\n\nconst colorsImpl = {\n // Base neutrals\n black: '#000000',\n white: '#FFFFFF',\n gray: {\n 100: '#F5F5F5',\n 300: '#D4D4D4',\n 500: '#737373',\n 700: '#404040',\n 900: '#171717',\n },\n\n // Dark mode semantic surfaces\n background: '#0A0A0A',\n surface: '#1A1A1A',\n foreground: '#FFFFFF',\n muted: '#2A2A2A',\n border: '#333333',\n\n // Accent / status\n primary: '#0066FF',\n secondary: '#00CC88',\n success: '#00DD77',\n error: '#FF3333',\n warning: '#FFAA00',\n} as const satisfies DesignTokens['colors'];\n\n// ---------------------------------------------------------------------------\n// Typography\n// ---------------------------------------------------------------------------\n\nconst typographyImpl = {\n fontFamily: {\n sans: 'Power Grotesk, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif',\n mono: 'JetBrains Mono, \"Fira Code\", monospace',\n display: 'Power Grotesk, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif',\n },\n\n scale: {\n hero: { size: '4rem', lineHeight: '1.125', weight: 700 }, // 64px\n h1: { size: '3rem', lineHeight: '1.167', weight: 700 }, // 48px\n h2: { size: '2rem', lineHeight: '1.25', weight: 600 }, // 32px\n h3: { size: '1.5rem', lineHeight: '1.333', weight: 600 }, // 24px\n body: { size: '1rem', lineHeight: '1.5', weight: 400 }, // 16px\n small: { size: '0.875rem', lineHeight: '1.429', weight: 400 }, // 14px\n tiny: { size: '0.75rem', lineHeight: '1.333', weight: 400 }, // 12px\n },\n\n fontWeight: {\n thin: 200,\n light: 300,\n regular: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n black: 900,\n },\n} as const satisfies DesignTokens['typography'];\n\n// ---------------------------------------------------------------------------\n// Spacing — 8px base grid\n// ---------------------------------------------------------------------------\n\nconst spacingImpl = {\n 0: '0',\n 1: '4px',\n 2: '8px',\n 3: '12px',\n 4: '16px',\n 5: '20px',\n 6: '24px',\n 7: '28px',\n 8: '32px',\n 9: '36px',\n 10: '40px',\n 12: '48px',\n 14: '56px',\n 15: '60px', // K-Universe 60px margin principle\n 16: '64px',\n 18: '72px',\n 20: '80px',\n 24: '96px',\n 32: '128px',\n} as const satisfies DesignTokens['spacing'];\n\n// ---------------------------------------------------------------------------\n// Motion\n// ---------------------------------------------------------------------------\n\nconst motionImpl = {\n duration: {\n instant: '100ms',\n fast: '200ms',\n default: '300ms',\n slow: '500ms',\n crawl: '800ms',\n },\n\n easing: {\n default: 'cubic-bezier(0.4, 0, 0.2, 1)',\n smooth: 'cubic-bezier(0.25, 0.1, 0.25, 1)',\n sharp: 'cubic-bezier(0.4, 0, 0.6, 1)',\n accelerate: 'cubic-bezier(0.4, 0, 1, 1)',\n decelerate: 'cubic-bezier(0, 0, 0.2, 1)',\n },\n} as const satisfies DesignTokens['motion'];\n\n// ---------------------------------------------------------------------------\n// Layout\n// ---------------------------------------------------------------------------\n\nconst layoutImpl = {\n margin: '60px', // primary horizontal landmark\n sectionSpacing: '96px',\n container: {\n sm: '640px',\n md: '768px',\n lg: '1024px',\n xl: '1280px',\n max: '1320px', // K-Universe max-width\n },\n measure: '65ch',\n} as const satisfies DesignTokens['layout'];\n\n// ---------------------------------------------------------------------------\n// Border radius\n// ---------------------------------------------------------------------------\n\nconst radiusImpl = {\n none: '0',\n xs: '2px',\n sm: '4px',\n md: '6px',\n lg: '8px',\n xl: '12px',\n '2xl': '16px',\n '3xl': '24px',\n round: '9999px',\n} as const satisfies DesignTokens['radius'];\n\n// ---------------------------------------------------------------------------\n// Shadows — neutral black only, no colored glow\n// ---------------------------------------------------------------------------\n\nconst shadowsImpl = {\n xs: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',\n sm: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)',\n md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',\n lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)',\n xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)',\n '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',\n inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.05)',\n cardHover: '0 20px 55px rgba(0, 0, 0, 0.55)',\n elevated: '0 24px 60px rgba(0, 0, 0, 0.45)',\n} as const satisfies DesignTokens['shadows'];\n\n// ---------------------------------------------------------------------------\n// Z-index\n// ---------------------------------------------------------------------------\n\nconst zIndexImpl = {\n bg: -1,\n base: 0,\n content: 10,\n dropdown: 100,\n sticky: 200,\n overlay: 300,\n modal: 400,\n popover: 500,\n tooltip: 600,\n toast: 700,\n} as const satisfies DesignTokens['zIndex'];\n\n// ---------------------------------------------------------------------------\n// Border width\n// ---------------------------------------------------------------------------\n\nconst borderWidthImpl = {\n thin: '1px',\n base: '2px',\n thick: '4px',\n} as const satisfies DesignTokens['borderWidth'];\n\n// ---------------------------------------------------------------------------\n// Root tokens object\n// ---------------------------------------------------------------------------\n\n/**\n * Primary design tokens export.\n *\n * @example\n * ```typescript\n * import { tokens } from \"@k-universe/design-tokens\";\n *\n * tokens.colors.background // '#0A0A0A'\n * tokens.colors.foreground // '#FFFFFF'\n * tokens.colors.secondary // '#00CC88'\n * tokens.typography.fontFamily.sans // 'Power Grotesk, ...'\n * tokens.spacing[15] // '60px' — 60px margin principle\n * tokens.motion.duration.default // '300ms'\n * ```\n */\nexport const tokens: DesignTokens = {\n colors: colorsImpl,\n typography: typographyImpl,\n spacing: spacingImpl,\n motion: motionImpl,\n layout: layoutImpl,\n radius: radiusImpl,\n shadows: shadowsImpl,\n zIndex: zIndexImpl,\n borderWidth: borderWidthImpl,\n};\n\n// ---------------------------------------------------------------------------\n// Convenience shortcut exports\n// ---------------------------------------------------------------------------\n\n/** Alias for tokens — backwards compatibility. */\nexport const designTokens: DesignTokens = tokens;\n\n/** Shortcut: tokens.colors */\nexport const colors = tokens.colors;\n\n/** Shortcut: tokens.typography */\nexport const typography = tokens.typography;\n\n/** Shortcut: tokens.spacing */\nexport const spacing = tokens.spacing;\n\n/** Shortcut: tokens.motion */\nexport const motion = tokens.motion;\n\n/** Shortcut: tokens.layout */\nexport const layout = tokens.layout;\n\n/** Shortcut: tokens.radius */\nexport const radius = tokens.radius;\n\n/** Shortcut: tokens.shadows */\nexport const shadows = tokens.shadows;\n\n/** Shortcut: tokens.zIndex */\nexport const zIndex = tokens.zIndex;\n\n/** Shortcut: tokens.borderWidth */\nexport const borderWidth = tokens.borderWidth;\n\n// ---------------------------------------------------------------------------\n// Utility: mergeTokens\n// ---------------------------------------------------------------------------\n\ntype DeepPartial<T> = {\n [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];\n};\n\n/**\n * Deep-merges override tokens into a base token set.\n * Returns a new object — does not mutate the base.\n *\n * @example\n * ```typescript\n * import { tokens, mergeTokens } from \"@k-universe/design-tokens\";\n *\n * const theme = mergeTokens(tokens, {\n * colors: { primary: '#FF6600' },\n * });\n * ```\n */\nexport function mergeTokens(\n base: DesignTokens,\n overrides: DeepPartial<DesignTokens>,\n): DesignTokens {\n return deepMerge(base, overrides) as DesignTokens;\n}\n\nfunction deepMerge<T extends object>(target: T, source: DeepPartial<T>): T {\n const result: T = { ...target };\n\n for (const key in source) {\n if (!Object.prototype.hasOwnProperty.call(source, key)) continue;\n\n const sourceVal = source[key as keyof typeof source];\n const targetVal = target[key as keyof T];\n\n if (\n sourceVal !== null &&\n typeof sourceVal === 'object' &&\n !Array.isArray(sourceVal) &&\n targetVal !== null &&\n typeof targetVal === 'object' &&\n !Array.isArray(targetVal)\n ) {\n (result as Record<string, unknown>)[key] = deepMerge(\n targetVal as object,\n sourceVal as DeepPartial<typeof targetVal>,\n );\n } else if (sourceVal !== undefined) {\n (result as Record<string, unknown>)[key] = sourceVal;\n }\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Utility: getTokenByPath\n// ---------------------------------------------------------------------------\n\n/**\n * Retrieves a token value using dot-notation path access.\n *\n * @param obj - The token object to traverse (typically `tokens`).\n * @param path - Dot-notation path string, e.g. `'colors.primary'`.\n * @returns The value at the given path, or `undefined` if not found.\n *\n * @example\n * ```typescript\n * import { tokens, getTokenByPath } from \"@k-universe/design-tokens\";\n *\n * getTokenByPath(tokens, 'colors.primary') // '#0066FF'\n * getTokenByPath(tokens, 'motion.duration.default') // '300ms'\n * getTokenByPath(tokens, 'spacing.15') // '60px'\n * ```\n */\nexport function getTokenByPath(\n obj: unknown,\n path: string,\n): unknown {\n if (!path) return obj;\n\n const segments = path.split('.');\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkDA,IAAM,aAAa;AAAA;AAAA,EAEjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,EACP;AAAA;AAAA,EAGA,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,QAAQ;AAAA;AAAA,EAGR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAA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* @k-universe/design-tokens — CSS custom properties generation
5
+ *
6
+ * Generates CSS variable strings from the token object and provides
7
+ * browser utilities for applying / reading / writing CSS vars at runtime.
8
+ *
9
+ * Package exports needed (add to package.json exports — handled by Agent 5 / build config):
10
+ * "./css": "./src/css-vars.ts"
11
+ * "./standalone/css": "./src/standalone/tokens.css"
12
+ */
13
+
14
+ /**
15
+ * Recursively walks an object and produces a flat array of
16
+ * `['--name', 'value']` pairs for every leaf node.
17
+ *
18
+ * @param obj - The (sub-)object to walk.
19
+ * @param prefix - Accumulated CSS-var name prefix (without leading `--`).
20
+ * @returns Array of `[varName, value]` tuples.
21
+ */
22
+ declare function flattenTokens(obj: unknown, prefix: string): Array<[string, string]>;
23
+ /**
24
+ * Generates a `:root { ... }` CSS block string from a DesignTokens object.
25
+ *
26
+ * @param t - Token object to generate from.
27
+ * @param prefix - Optional additional prefix for all var names (rarely needed).
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { generateCSSVars, tokens } from "@k-universe/design-tokens/css";
32
+ * const css = generateCSSVars(tokens);
33
+ * // ":root {\n --color-background: #0A0A0A;\n ...\n}"
34
+ * ```
35
+ */
36
+ declare function generateCSSVars(t: DesignTokens, prefix?: string): string;
37
+ /**
38
+ * Generates the dark-theme `:root { ... }` block.
39
+ * Dark mode is the default / primary context for K-Universe.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const css = generateDarkThemeCSS(tokens);
44
+ * ```
45
+ */
46
+ declare function generateDarkThemeCSS(t: DesignTokens): string;
47
+ /**
48
+ * Generates the `[data-theme="light"] { ... }` override block.
49
+ * Only overrides semantic surface colours — all other tokens are inherited.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const css = generateLightThemeCSS(tokens);
54
+ * ```
55
+ */
56
+ declare function generateLightThemeCSS(_t: DesignTokens): string;
57
+ /**
58
+ * Generates the complete CSS: dark `:root` block + light `[data-theme="light"]` block.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { generateCompleteCSS, tokens } from "@k-universe/design-tokens/css";
63
+ *
64
+ * // In a Next.js layout or global stylesheet:
65
+ * const css = generateCompleteCSS(tokens);
66
+ * ```
67
+ */
68
+ declare function generateCompleteCSS(t: DesignTokens): string;
69
+ /**
70
+ * Applies all design tokens as CSS custom properties to `document.documentElement`.
71
+ * SSR-safe — no-ops when `document` is not available.
72
+ *
73
+ * @param theme - Optional theme override. Defaults to dark (no attribute set).
74
+ * Passing `'light'` sets `data-theme="light"` on `<html>`.
75
+ * Passing `'dark'` removes the attribute.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // In a client-only bootstrap file:
80
+ * import { applyCSSVarsToDocument } from "@k-universe/design-tokens/css";
81
+ * applyCSSVarsToDocument(); // dark theme (default)
82
+ * applyCSSVarsToDocument('light'); // light theme
83
+ * ```
84
+ */
85
+ declare function applyCSSVarsToDocument(theme?: 'dark' | 'light'): void;
86
+ /**
87
+ * Reads a CSS custom property value from `document.documentElement` at runtime.
88
+ * Returns an empty string when called server-side.
89
+ *
90
+ * @param name - Full CSS var name including `--`, e.g. `'--color-primary'`.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const primary = getCSSVar('--color-primary'); // '#0066FF'
95
+ * ```
96
+ */
97
+ declare function getCSSVar(name: string): string;
98
+ /**
99
+ * Sets a CSS custom property on `document.documentElement` at runtime.
100
+ * No-ops when called server-side.
101
+ *
102
+ * @param name - Full CSS var name including `--`, e.g. `'--color-primary'`.
103
+ * @param value - The new value.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * setCSSVar('--color-primary', '#FF6600');
108
+ * ```
109
+ */
110
+ declare function setCSSVar(name: string, value: string): void;
111
+ /**
112
+ * Pre-computed flat `:root { ... }` CSS string from the default token set.
113
+ * Import and inject directly into a `<style>` tag or CSS-in-JS system.
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * import { cssVarsString } from "@k-universe/design-tokens/css";
118
+ * // inject into a <style> tag in layout.tsx
119
+ * ```
120
+ */
121
+ declare const cssVarsString: string;
122
+ /**
123
+ * Pre-computed dark-theme `:root { ... }` block with section comments.
124
+ */
125
+ declare const darkThemeCSS: string;
126
+ /**
127
+ * Pre-computed `[data-theme="light"] { ... }` override block.
128
+ */
129
+ declare const lightThemeCSS: string;
130
+
131
+ export { applyCSSVarsToDocument, cssVarsString, darkThemeCSS, flattenTokens, generateCSSVars, generateCompleteCSS, generateDarkThemeCSS, generateLightThemeCSS, getCSSVar, lightThemeCSS, setCSSVar };
package/dist/css.d.ts ADDED
@@ -0,0 +1,131 @@
1
+ import { D as DesignTokens } from './types-BcWm9ccA.js';
2
+
3
+ /**
4
+ * @k-universe/design-tokens — CSS custom properties generation
5
+ *
6
+ * Generates CSS variable strings from the token object and provides
7
+ * browser utilities for applying / reading / writing CSS vars at runtime.
8
+ *
9
+ * Package exports needed (add to package.json exports — handled by Agent 5 / build config):
10
+ * "./css": "./src/css-vars.ts"
11
+ * "./standalone/css": "./src/standalone/tokens.css"
12
+ */
13
+
14
+ /**
15
+ * Recursively walks an object and produces a flat array of
16
+ * `['--name', 'value']` pairs for every leaf node.
17
+ *
18
+ * @param obj - The (sub-)object to walk.
19
+ * @param prefix - Accumulated CSS-var name prefix (without leading `--`).
20
+ * @returns Array of `[varName, value]` tuples.
21
+ */
22
+ declare function flattenTokens(obj: unknown, prefix: string): Array<[string, string]>;
23
+ /**
24
+ * Generates a `:root { ... }` CSS block string from a DesignTokens object.
25
+ *
26
+ * @param t - Token object to generate from.
27
+ * @param prefix - Optional additional prefix for all var names (rarely needed).
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { generateCSSVars, tokens } from "@k-universe/design-tokens/css";
32
+ * const css = generateCSSVars(tokens);
33
+ * // ":root {\n --color-background: #0A0A0A;\n ...\n}"
34
+ * ```
35
+ */
36
+ declare function generateCSSVars(t: DesignTokens, prefix?: string): string;
37
+ /**
38
+ * Generates the dark-theme `:root { ... }` block.
39
+ * Dark mode is the default / primary context for K-Universe.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const css = generateDarkThemeCSS(tokens);
44
+ * ```
45
+ */
46
+ declare function generateDarkThemeCSS(t: DesignTokens): string;
47
+ /**
48
+ * Generates the `[data-theme="light"] { ... }` override block.
49
+ * Only overrides semantic surface colours — all other tokens are inherited.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const css = generateLightThemeCSS(tokens);
54
+ * ```
55
+ */
56
+ declare function generateLightThemeCSS(_t: DesignTokens): string;
57
+ /**
58
+ * Generates the complete CSS: dark `:root` block + light `[data-theme="light"]` block.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { generateCompleteCSS, tokens } from "@k-universe/design-tokens/css";
63
+ *
64
+ * // In a Next.js layout or global stylesheet:
65
+ * const css = generateCompleteCSS(tokens);
66
+ * ```
67
+ */
68
+ declare function generateCompleteCSS(t: DesignTokens): string;
69
+ /**
70
+ * Applies all design tokens as CSS custom properties to `document.documentElement`.
71
+ * SSR-safe — no-ops when `document` is not available.
72
+ *
73
+ * @param theme - Optional theme override. Defaults to dark (no attribute set).
74
+ * Passing `'light'` sets `data-theme="light"` on `<html>`.
75
+ * Passing `'dark'` removes the attribute.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // In a client-only bootstrap file:
80
+ * import { applyCSSVarsToDocument } from "@k-universe/design-tokens/css";
81
+ * applyCSSVarsToDocument(); // dark theme (default)
82
+ * applyCSSVarsToDocument('light'); // light theme
83
+ * ```
84
+ */
85
+ declare function applyCSSVarsToDocument(theme?: 'dark' | 'light'): void;
86
+ /**
87
+ * Reads a CSS custom property value from `document.documentElement` at runtime.
88
+ * Returns an empty string when called server-side.
89
+ *
90
+ * @param name - Full CSS var name including `--`, e.g. `'--color-primary'`.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const primary = getCSSVar('--color-primary'); // '#0066FF'
95
+ * ```
96
+ */
97
+ declare function getCSSVar(name: string): string;
98
+ /**
99
+ * Sets a CSS custom property on `document.documentElement` at runtime.
100
+ * No-ops when called server-side.
101
+ *
102
+ * @param name - Full CSS var name including `--`, e.g. `'--color-primary'`.
103
+ * @param value - The new value.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * setCSSVar('--color-primary', '#FF6600');
108
+ * ```
109
+ */
110
+ declare function setCSSVar(name: string, value: string): void;
111
+ /**
112
+ * Pre-computed flat `:root { ... }` CSS string from the default token set.
113
+ * Import and inject directly into a `<style>` tag or CSS-in-JS system.
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * import { cssVarsString } from "@k-universe/design-tokens/css";
118
+ * // inject into a <style> tag in layout.tsx
119
+ * ```
120
+ */
121
+ declare const cssVarsString: string;
122
+ /**
123
+ * Pre-computed dark-theme `:root { ... }` block with section comments.
124
+ */
125
+ declare const darkThemeCSS: string;
126
+ /**
127
+ * Pre-computed `[data-theme="light"] { ... }` override block.
128
+ */
129
+ declare const lightThemeCSS: string;
130
+
131
+ export { applyCSSVarsToDocument, cssVarsString, darkThemeCSS, flattenTokens, generateCSSVars, generateCompleteCSS, generateDarkThemeCSS, generateLightThemeCSS, getCSSVar, lightThemeCSS, setCSSVar };