@nswds/ui 1.0.0 → 1.2.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.
Files changed (37) hide show
  1. package/dist/components/badge.d.ts +26 -0
  2. package/dist/components/badge.js +410 -0
  3. package/dist/components/badge.js.map +1 -0
  4. package/dist/components/button.d.ts +35 -5
  5. package/dist/components/button.js +347 -39
  6. package/dist/components/button.js.map +1 -1
  7. package/dist/components/description-list.d.ts +8 -0
  8. package/dist/components/description-list.js +52 -0
  9. package/dist/components/description-list.js.map +1 -0
  10. package/dist/components/link.d.ts +18 -0
  11. package/dist/components/link.js +21 -0
  12. package/dist/components/link.js.map +1 -0
  13. package/dist/components/spinner.d.ts +19 -0
  14. package/dist/components/spinner.js +47 -0
  15. package/dist/components/spinner.js.map +1 -0
  16. package/dist/index.d.ts +11 -3
  17. package/dist/index.js +7 -0
  18. package/dist/lib/color-palette.d.ts +49 -0
  19. package/dist/lib/color-palette.js +5045 -0
  20. package/dist/lib/color-palette.js.map +1 -0
  21. package/dist/lib/colors.d.ts +38 -0
  22. package/dist/lib/colors.js +272 -0
  23. package/dist/lib/colors.js.map +1 -0
  24. package/dist/lib/theme-palette.d.ts +49 -0
  25. package/dist/lib/theme-palette.js +103 -0
  26. package/dist/lib/theme-palette.js.map +1 -0
  27. package/dist/lib/utils.d.ts +5 -1
  28. package/dist/lib/utils.js +16 -1
  29. package/dist/lib/utils.js.map +1 -1
  30. package/dist/styles/globals.css.d.d.ts +2 -0
  31. package/dist/styles/globals.css.d.js +3 -0
  32. package/dist/styles/globals.css.d.js.map +1 -0
  33. package/dist/styles.css +1 -1
  34. package/dist/types/types.d.ts +146 -0
  35. package/dist/types/types.js +3 -0
  36. package/dist/types/types.js.map +1 -0
  37. package/package.json +11 -3
@@ -0,0 +1,38 @@
1
+ import { ColorData, Format, Output, Variant, ColorThemes } from '../types/types.js';
2
+
3
+ declare const shades: string[];
4
+ declare const darkenColor: (color: string, factor?: number) => string;
5
+ declare const lightenColor: (color: string, factor?: number) => string;
6
+ declare const addStartStopToColorArray: (colorArray: string[]) => string[];
7
+ declare const interpolateColors: (color1: string, color2: string, steps: number) => ColorData[];
8
+ declare const generateInterpolatedColors: (colorArray: string[]) => ColorData[];
9
+ declare const generateDataVisColors: (colorArray: string[], steps?: number) => ColorData[];
10
+ declare const getSurroundingColors: (colors: ColorData[], themeColor: string) => ColorData[];
11
+ declare const colorDataArray: (colorsToUse: ColorData[], paletteName: string, format: Format, output: Output, variant: Variant) => string[];
12
+ declare function createColorArray(colorArray: ColorData[], name: string, type: string): {
13
+ name: string;
14
+ colors: {
15
+ name?: string | undefined;
16
+ oklch: string;
17
+ hex: string;
18
+ rgb: string;
19
+ hsl: string;
20
+ token: string;
21
+ }[];
22
+ }[];
23
+ declare const isLightColor: (hexColor: string) => boolean;
24
+ declare const renderColorOutput: (colorsToUse: ColorData[], paletteName: string, format: Format, output: Output, variant: Variant) => string;
25
+ declare const renderColorOutputToDTFM: (colorsToUse: ColorData[], paletteName: string, format: Format, variant: Variant) => string;
26
+ declare const themeIndices: number[];
27
+ declare const themeTokens: number[];
28
+ declare const generateColorThemes: (colors: ColorThemes) => ColorThemes;
29
+ declare function oklchConverter(hex: string): string;
30
+ declare const getColorValue: (color: {
31
+ oklch: string;
32
+ hex: string;
33
+ rgb: string;
34
+ hsl: string;
35
+ }, colorFormat: "oklch" | "rgb" | "hsl" | "hex") => string;
36
+ declare const createColorData: (baseColors: string[], format: Format) => (string | null)[];
37
+
38
+ export { addStartStopToColorArray, colorDataArray, createColorArray, createColorData, darkenColor, generateColorThemes, generateDataVisColors, generateInterpolatedColors, getColorValue, getSurroundingColors, interpolateColors, isLightColor, lightenColor, oklchConverter, renderColorOutput, renderColorOutputToDTFM, shades, themeIndices, themeTokens };
@@ -0,0 +1,272 @@
1
+ import * as culori from 'culori';
2
+ import { kebabCase, camelCase } from '../lib/utils.js';
3
+
4
+ const shades = [
5
+ "lightest",
6
+ "lighter",
7
+ "light",
8
+ "DEFAULT",
9
+ "dark",
10
+ "darker",
11
+ "darkest"
12
+ ];
13
+ const darkenColor = (color, factor = 0.3) => {
14
+ const parsed = culori.parse(color);
15
+ if (!parsed || parsed.mode !== "oklch") return color;
16
+ parsed.l = Math.max(0, parsed.l * factor);
17
+ parsed.c = Math.max(0, parsed.c * 0.4);
18
+ return culori.formatCss(parsed);
19
+ };
20
+ const lightenColor = (color, factor = 2) => {
21
+ const parsed = culori.parse(color);
22
+ if (!parsed || parsed.mode !== "oklch") return color;
23
+ parsed.l = Math.min(1, parsed.l * factor);
24
+ parsed.c = parsed.c * 0.1;
25
+ return culori.formatCss(parsed);
26
+ };
27
+ const addStartStopToColorArray = (colorArray) => {
28
+ const darkColor = (color) => darkenColor(color, 0.3);
29
+ const lightColor = (color) => lightenColor(color, 2);
30
+ const colors = [...colorArray];
31
+ colors.unshift(darkColor(colorArray[0]));
32
+ colors.push(lightColor(colorArray[colorArray.length - 1]));
33
+ return colors;
34
+ };
35
+ const interpolateColors = (color1, color2, steps) => {
36
+ const results = [];
37
+ const interpolator = culori.interpolate([color1, color2], "oklch");
38
+ for (let i = 0; i < steps; i++) {
39
+ const t = i / (steps - 1);
40
+ const color = interpolator(t);
41
+ results.push({
42
+ oklch: culori.formatCss(color),
43
+ hex: culori.formatHex(color),
44
+ rgb: culori.formatRgb(color),
45
+ hsl: culori.formatHsl(color)
46
+ });
47
+ }
48
+ return results;
49
+ };
50
+ const generateInterpolatedColors = (colorArray) => {
51
+ const newColorArray = addStartStopToColorArray(colorArray);
52
+ let fullPalette = [];
53
+ for (let i = 0; i < newColorArray.length - 1; i++) {
54
+ const color1 = newColorArray[i];
55
+ const color2 = newColorArray[i + 1];
56
+ const steps = 5;
57
+ const interpolated = interpolateColors(color1, color2, steps);
58
+ if (i < newColorArray.length - 2) {
59
+ fullPalette = [...fullPalette, ...interpolated.slice(0, -1)];
60
+ } else {
61
+ fullPalette = [...fullPalette, ...interpolated];
62
+ }
63
+ }
64
+ const finalPaletteColours = fullPalette.slice(1, -1).reverse();
65
+ return finalPaletteColours;
66
+ };
67
+ const generateDataVisColors = (colorArray, steps = 6) => {
68
+ const fullPalette = [];
69
+ for (let i = 0; i < colorArray.length - 1; i++) {
70
+ const segment = interpolateColors(colorArray[i], colorArray[i + 1], steps);
71
+ fullPalette.push(...i === 0 ? segment : segment.slice(1));
72
+ }
73
+ return fullPalette;
74
+ };
75
+ const getSurroundingColors = (colors, themeColor) => {
76
+ const index = colors.findIndex((color) => color.oklch === themeColor);
77
+ if (index === -1) return [];
78
+ const start = Math.max(0, index - 3);
79
+ const end = Math.min(colors.length, index + 4);
80
+ const surroundingColors = colors.slice(start, end);
81
+ return surroundingColors;
82
+ };
83
+ const colorDataArray = (colorsToUse, paletteName, format, output, variant) => {
84
+ return colorsToUse.map((color, index) => {
85
+ const shade = (index + 1) * 50;
86
+ const value = color[format];
87
+ const key = variant === "shades" ? shade : shades[index];
88
+ const fullKey = variant === "shades" ? `${paletteName}-${shade}` : shades[index].includes("DEFAULT") ? `${paletteName}` : `${paletteName}-${shades[index]}`;
89
+ switch (output) {
90
+ case "js":
91
+ case "ts":
92
+ return `'${key}': '${value}'`;
93
+ case "css":
94
+ return `--${fullKey}: ${value};`;
95
+ case "scss":
96
+ return `$${fullKey}: ${value};`;
97
+ case "less":
98
+ return `@${fullKey}: ${value};`;
99
+ case "tailwind":
100
+ return `--color-${fullKey}: ${value};`;
101
+ case "json":
102
+ return `"${fullKey}": "${value}"`;
103
+ default:
104
+ return "";
105
+ }
106
+ });
107
+ };
108
+ function createColorArray(colorArray, name, type) {
109
+ const colorCategories = [];
110
+ const kebab = kebabCase(name);
111
+ colorCategories.push({
112
+ name,
113
+ colors: colorArray.map((color, index) => {
114
+ const value = 50 + index * 50;
115
+ const colorName = type === "shades" ? `${kebab}-${value}` : shades[index].includes("DEFAULT") ? `${kebab}` : `${kebab}-${shades[index]}`;
116
+ return {
117
+ token: colorName,
118
+ ...color,
119
+ ...value === 200 ? { name: `${name} 04` } : {},
120
+ ...value === 400 ? { name: `${name} 03` } : {},
121
+ ...value === 600 ? { name: `${name} 02` } : {},
122
+ ...value === 800 ? { name: `${name} 01` } : {}
123
+ };
124
+ })
125
+ });
126
+ return colorCategories;
127
+ }
128
+ const isLightColor = (hexColor) => {
129
+ const hex = hexColor.replace("#", "");
130
+ const r = Number.parseInt(hex.substring(0, 2), 16);
131
+ const g = Number.parseInt(hex.substring(2, 4), 16);
132
+ const b = Number.parseInt(hex.substring(4, 6), 16);
133
+ const brightness = (r * 299 + g * 587 + b * 114) / 1e3;
134
+ return brightness > 128;
135
+ };
136
+ const renderColorOutput = (colorsToUse, paletteName, format, output, variant) => {
137
+ const lines = colorDataArray(
138
+ colorsToUse,
139
+ paletteName,
140
+ format,
141
+ output,
142
+ variant
143
+ );
144
+ const indent = (str, level = 1) => " ".repeat(level) + str;
145
+ switch (output) {
146
+ case "js":
147
+ case "ts":
148
+ return `export const ${camelCase(paletteName)} = {
149
+ ${lines.map((line) => indent(line + ",")).join("\n")}
150
+ }`;
151
+ case "json":
152
+ return `{
153
+ "${paletteName}": {
154
+ ${lines.map((line) => indent(line + ",", 2)).join("\n")}
155
+ }
156
+ }`;
157
+ case "scss":
158
+ case "less":
159
+ case "css":
160
+ case "tailwind":
161
+ return lines.join("\n");
162
+ default:
163
+ return lines.join("\n");
164
+ }
165
+ };
166
+ const renderColorOutputToDTFM = (colorsToUse, paletteName, format, variant) => {
167
+ const isStructured = format !== "hex";
168
+ const parseToStructuredColor = (str) => {
169
+ const regex = /([a-z]+)\(([^)]+)\)/i;
170
+ const match = str.match(regex);
171
+ if (!match) return str;
172
+ const colorSpace = match[1];
173
+ const channelValues = match[2].split(/[\s,]+/).map((val) => parseFloat(val));
174
+ return {
175
+ colorSpace,
176
+ channels: channelValues,
177
+ alpha: 1
178
+ };
179
+ };
180
+ if (variant === "shades") {
181
+ const tokens = {
182
+ [paletteName]: {}
183
+ };
184
+ colorsToUse.forEach((color, index) => {
185
+ const shade = `${(index + 1) * 50}`;
186
+ const raw = color[format];
187
+ const value = {
188
+ $type: "color",
189
+ $value: isStructured ? parseToStructuredColor(raw) : raw
190
+ };
191
+ tokens[paletteName][shade] = value;
192
+ });
193
+ return JSON.stringify(tokens, null, 2);
194
+ } else {
195
+ const tokens = {};
196
+ colorsToUse.forEach((color, index) => {
197
+ const shade = shades[index] === "DEFAULT" ? `${paletteName}` : `${paletteName}-${shades[index]}`;
198
+ const raw = color[format];
199
+ const value = isStructured ? parseToStructuredColor(raw) : raw;
200
+ tokens[shade] = {
201
+ value,
202
+ type: "color"
203
+ };
204
+ });
205
+ return JSON.stringify(tokens, null, 2);
206
+ }
207
+ };
208
+ const themeIndices = [3, 7, 11, 15];
209
+ const themeTokens = [200, 400, 600, 800];
210
+ const generateColorThemes = (colors) => {
211
+ const colorThemes = {};
212
+ for (const category in colors) {
213
+ colorThemes[category] = {};
214
+ for (const shade in colors[category]) {
215
+ const base = colors[category][shade];
216
+ colorThemes[category][shade] = {
217
+ name: base.name,
218
+ colors: themeIndices.map((idx) => {
219
+ const c = base.colors[idx];
220
+ return {
221
+ token: c.token,
222
+ oklch: c.oklch,
223
+ hex: c.hex,
224
+ rgb: c.rgb,
225
+ hsl: c.hsl,
226
+ name: c.name
227
+ };
228
+ })
229
+ };
230
+ }
231
+ }
232
+ return colorThemes;
233
+ };
234
+ function oklchConverter(hex) {
235
+ const converted = culori.oklch(hex);
236
+ if (!converted) {
237
+ throw new Error(`Invalid hex color: ${hex}`);
238
+ }
239
+ return culori.formatCss(converted);
240
+ }
241
+ const getColorValue = (color, colorFormat) => {
242
+ switch (colorFormat) {
243
+ case "oklch":
244
+ return color.oklch;
245
+ case "rgb":
246
+ return color.rgb;
247
+ case "hsl":
248
+ return color.hsl;
249
+ case "hex":
250
+ default:
251
+ return color.hex;
252
+ }
253
+ };
254
+ const createColorData = (baseColors, format) => {
255
+ return baseColors.map((color) => {
256
+ if (!culori.parse(color)) {
257
+ console.warn(`Invalid color: ${color}`);
258
+ return null;
259
+ }
260
+ const colorData = {
261
+ oklch: culori.formatCss(color) || "",
262
+ hex: culori.formatHex(color) || "",
263
+ rgb: culori.formatRgb(color) || "",
264
+ hsl: culori.formatHsl(color) || ""
265
+ };
266
+ return getColorValue(colorData, format);
267
+ });
268
+ };
269
+
270
+ export { addStartStopToColorArray, colorDataArray, createColorArray, createColorData, darkenColor, generateColorThemes, generateDataVisColors, generateInterpolatedColors, getColorValue, getSurroundingColors, interpolateColors, isLightColor, lightenColor, oklchConverter, renderColorOutput, renderColorOutputToDTFM, shades, themeIndices, themeTokens };
271
+ //# sourceMappingURL=colors.js.map
272
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/colors.ts"],"names":[],"mappings":";;;AAaO,MAAM,MAAA,GAAS;AAAA,EACpB,UAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAEO,MAAM,WAAA,GAAc,CAAC,KAAA,EAAe,MAAA,GAAS,GAAA,KAAQ;AAC1D,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA;AACjC,EAAA,IAAI,CAAC,MAAA,IAAU,MAAA,CAAO,IAAA,KAAS,SAAS,OAAO,KAAA;AAG/C,EAAA,MAAA,CAAO,IAAI,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,MAAA,CAAO,IAAI,MAAM,CAAA;AAGxC,EAAA,MAAA,CAAO,IAAI,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,MAAA,CAAO,IAAI,GAAG,CAAA;AAErC,EAAA,OAAO,MAAA,CAAO,UAAU,MAAM,CAAA;AAChC;AAEO,MAAM,YAAA,GAAe,CAAC,KAAA,EAAe,MAAA,GAAS,CAAA,KAAM;AACzD,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA;AACjC,EAAA,I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I,CAAC,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA,EAAG;AACxB,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,eAAA,EAAkB,KAAK,CAAA,CAAE,CAAA;AACtC,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,MAAM,SAAA,GAAY;AAAA,MAChB,KAAA,EAAO,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK,EAAA;AAAA,MAClC,GAAA,EAAK,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK,EAAA;AAAA,MAChC,GAAA,EAAK,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK,EAAA;AAAA,MAChC,GAAA,EAAK,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK;AAAA,KAClC;AAEA,IAAA,OAAO,aAAA,CAAc,WAAW,MAAM,CAAA;AAAA,EACxC,CAAC,CAAA;AACH","file":"colors.js","sourcesContent":["import * as culori from 'culori'\nimport { camelCase, kebabCase } from '../lib/utils.js'\nimport {\n ColorData,\n // DesignTokensTheme,\n ColorProperty,\n ColorThemes,\n DesignTokensShades,\n Format,\n Output,\n Variant,\n} from '../types/types.js'\n\nexport const shades = [\n 'lightest',\n 'lighter',\n 'light',\n 'DEFAULT',\n 'dark',\n 'darker',\n 'darkest',\n]\n\nexport const darkenColor = (color: string, factor = 0.3) => {\n const parsed = culori.parse(color) // Parse input color\n if (!parsed || parsed.mode !== 'oklch') return color // Ensure it's OKLCH\n\n // Reduce lightness\n parsed.l = Math.max(0, parsed.l * factor)\n\n // Reduce chroma slightly\n parsed.c = Math.max(0, parsed.c * 0.4)\n\n return culori.formatCss(parsed)\n}\n\nexport const lightenColor = (color: string, factor = 2) => {\n const parsed = culori.parse(color) // Parse input color\n if (!parsed || parsed.mode !== 'oklch') return color // Ensure it's OKLCH\n\n // Increase lightness, but ensure it doesn't exceed 1\n parsed.l = Math.min(1, parsed.l * factor)\n\n // Reduce chroma slightly to avoid color distortion\n parsed.c = parsed.c * 0.1\n\n return culori.formatCss(parsed)\n}\n\nexport const addStartStopToColorArray = (colorArray: string[]): string[] => {\n const darkColor = (color: string) => darkenColor(color, 0.3)\n const lightColor = (color: string) => lightenColor(color, 2)\n\n const colors = [...colorArray]\n colors.unshift(darkColor(colorArray[0]!))\n colors.push(lightColor(colorArray[colorArray.length - 1]!))\n return colors\n}\n\nexport const interpolateColors = (\n color1: string,\n color2: string,\n steps: number\n): ColorData[] => {\n const results: ColorData[] = []\n\n const interpolator = culori.interpolate([color1, color2], 'oklch')\n\n for (let i = 0; i < steps; i++) {\n const t = i / (steps - 1)\n const color = interpolator(t)\n results.push({\n oklch: culori.formatCss(color),\n hex: culori.formatHex(color),\n rgb: culori.formatRgb(color),\n hsl: culori.formatHsl(color),\n })\n }\n\n return results\n}\n\nexport const generateInterpolatedColors = (\n colorArray: string[]\n): ColorData[] => {\n const newColorArray = addStartStopToColorArray(colorArray)\n\n let fullPalette: ColorData[] = []\n\n // Interpolate between pairs of colors\n for (let i = 0; i < newColorArray.length - 1; i++) {\n const color1 = newColorArray[i]!\n const color2 = newColorArray[i + 1]!\n const steps = 5\n\n const interpolated = interpolateColors(color1, color2, steps)\n // Remove the last color to avoid duplication, except for the last set\n if (i < newColorArray.length - 2) {\n fullPalette = [...fullPalette, ...interpolated.slice(0, -1)]\n } else {\n fullPalette = [...fullPalette, ...interpolated]\n }\n }\n\n const finalPaletteColours = fullPalette.slice(1, -1).reverse()\n\n return finalPaletteColours\n}\n\nexport const generateDataVisColors = (\n colorArray: string[],\n steps = 6\n): ColorData[] => {\n const fullPalette: ColorData[] = []\n\n for (let i = 0; i < colorArray.length - 1; i++) {\n const segment = interpolateColors(colorArray[i]!, colorArray[i + 1]!, steps)\n // For segments after the first, drop the first color to avoid duplicates at the join\n fullPalette.push(...(i === 0 ? segment : segment.slice(1)))\n }\n\n return fullPalette\n}\n\nexport const getSurroundingColors = (\n colors: ColorData[],\n themeColor: string\n) => {\n const index = colors.findIndex((color) => color.oklch === themeColor)\n\n if (index === -1) return []\n\n const start = Math.max(0, index - 3)\n const end = Math.min(colors.length, index + 4)\n\n const surroundingColors = colors.slice(start, end)\n\n return surroundingColors\n}\n\nexport const colorDataArray = (\n colorsToUse: ColorData[],\n paletteName: string,\n format: Format,\n output: Output,\n variant: Variant\n) => {\n return colorsToUse.map((color, index) => {\n const shade = (index + 1) * 50\n const value = color[format]\n const key = variant === 'shades' ? shade : shades[index]\n\n const fullKey =\n variant === 'shades'\n ? `${paletteName}-${shade}`\n : shades[index]!.includes('DEFAULT')\n ? `${paletteName}`\n : `${paletteName}-${shades[index]!}`\n\n switch (output) {\n case 'js':\n case 'ts':\n return `'${key}': '${value}'`\n\n case 'css':\n return `--${fullKey}: ${value};`\n\n case 'scss':\n return `$${fullKey}: ${value};`\n\n case 'less':\n return `@${fullKey}: ${value};`\n\n case 'tailwind':\n return `--color-${fullKey}: ${value};`\n\n case 'json':\n return `\"${fullKey}\": \"${value}\"`\n\n default:\n return ''\n }\n })\n}\n\nexport function createColorArray(\n colorArray: ColorData[],\n name: string,\n type: string\n) {\n const colorCategories = []\n const kebab = kebabCase(name)\n\n colorCategories.push({\n name: name,\n colors: colorArray.map((color, index) => {\n const value = 50 + index * 50\n const colorName =\n type === 'shades'\n ? `${kebab}-${value}`\n : shades[index]!.includes('DEFAULT')\n ? `${kebab}`\n : `${kebab}-${shades[index]!}`\n\n return {\n token: colorName,\n ...color,\n ...(value === 200 ? { name: `${name} 04` } : {}),\n ...(value === 400 ? { name: `${name} 03` } : {}),\n ...(value === 600 ? { name: `${name} 02` } : {}),\n ...(value === 800 ? { name: `${name} 01` } : {}),\n }\n }),\n })\n\n return colorCategories\n}\n\nexport const isLightColor = (hexColor: string) => {\n const hex = hexColor.replace('#', '')\n const r = Number.parseInt(hex.substring(0, 2), 16)\n const g = Number.parseInt(hex.substring(2, 4), 16)\n const b = Number.parseInt(hex.substring(4, 6), 16)\n const brightness = (r * 299 + g * 587 + b * 114) / 1000\n return brightness > 128\n}\n\nexport const renderColorOutput = (\n colorsToUse: ColorData[],\n paletteName: string,\n format: Format,\n output: Output,\n variant: Variant\n) => {\n const lines = colorDataArray(\n colorsToUse,\n paletteName,\n format,\n output,\n variant\n )\n\n const indent = (str: string, level = 1) => ' '.repeat(level) + str\n\n switch (output) {\n case 'js':\n case 'ts':\n return `export const ${camelCase(paletteName)} = {\\n${lines\n .map((line) => indent(line + ','))\n .join('\\n')}\\n}`\n\n case 'json':\n return `{\\n \"${paletteName}\": {\\n${lines\n .map((line) => indent(line + ',', 2))\n .join('\\n')}\\n }\\n}`\n\n case 'scss':\n case 'less':\n case 'css':\n case 'tailwind':\n return lines.join('\\n')\n\n default:\n return lines.join('\\n')\n }\n}\n\nexport const renderColorOutputToDTFM = (\n colorsToUse: ColorData[],\n paletteName: string,\n format: Format,\n variant: Variant\n): string => {\n const isStructured = format !== 'hex'\n\n const parseToStructuredColor = (str: string) => {\n const regex = /([a-z]+)\\(([^)]+)\\)/i\n const match = str.match(regex)\n if (!match) return str\n\n const colorSpace = match[1]!\n const channelValues = match[2]!\n .split(/[\\s,]+/)\n .map((val) => parseFloat(val))\n\n return {\n colorSpace,\n channels: channelValues,\n alpha: 1,\n }\n }\n\n if (variant === 'shades') {\n const tokens: DesignTokensShades = {\n [paletteName]: {},\n }\n\n colorsToUse.forEach((color, index) => {\n const shade = `${(index + 1) * 50}`\n const raw = color[format]\n const value = {\n $type: 'color' as const,\n $value: isStructured ? parseToStructuredColor(raw) : raw,\n }\n\n tokens[paletteName]![shade] = value\n })\n\n return JSON.stringify(tokens, null, 2)\n } else {\n const tokens: Record<string, ColorProperty> = {}\n\n colorsToUse.forEach((color, index) => {\n const shade =\n shades[index] === 'DEFAULT'\n ? `${paletteName}`\n : `${paletteName}-${shades[index]}`\n const raw = color[format]\n const value = isStructured ? parseToStructuredColor(raw) : raw\n\n tokens[shade] = {\n value,\n type: 'color',\n }\n })\n\n return JSON.stringify(tokens, null, 2)\n }\n\n /* if (variant === 'shades') {\n const tokens: DesignTokensShades = {\n [paletteName]: {},\n }\n\n colorsToUse.forEach((color, index) => {\n const shade = `${(index + 1) * 50}`\n const raw = color[format]\n const value = {\n $type: 'color' as const,\n $value: isStructured ? parseToStructuredColor(raw) : raw,\n }\n\n tokens[paletteName]![shade] = value\n })\n\n return JSON.stringify(tokens, null, 2)\n } else {\n const tokens: DesignTokensTheme = {\n [paletteName]: {\n value: '',\n type: 'color' as const,\n variants: {},\n },\n }\n\n colorsToUse.forEach((color, index) => {\n const shade = shades[index]\n const raw = color[format]\n const value = isStructured ? parseToStructuredColor(raw) : raw\n\n if (shade === 'DEFAULT') {\n tokens[paletteName].value = value\n } else {\n tokens[paletteName].variants[shade] = {\n value,\n type: 'color',\n }\n }\n })\n\n return JSON.stringify(tokens, null, 2)\n } */\n}\n\nexport const themeIndices = [3, 7, 11, 15]\nexport const themeTokens = [200, 400, 600, 800]\n\nexport const generateColorThemes = (colors: ColorThemes) => {\n const colorThemes: ColorThemes = {}\n\n for (const category in colors) {\n colorThemes[category] = {}\n\n for (const shade in colors[category]) {\n const base = colors[category]![shade]!\n colorThemes[category][shade] = {\n name: base.name,\n colors: themeIndices.map((idx) => {\n const c = base.colors[idx]!\n return {\n token: c.token,\n oklch: c.oklch,\n hex: c.hex,\n rgb: c.rgb,\n hsl: c.hsl,\n name: c.name,\n }\n }),\n }\n }\n }\n\n return colorThemes\n}\n\nexport function oklchConverter(hex: string): string {\n const converted = culori.oklch(hex)\n if (!converted) {\n throw new Error(`Invalid hex color: ${hex}`)\n }\n return culori.formatCss(converted)\n}\n\nexport const getColorValue = (\n color: { oklch: string; hex: string; rgb: string; hsl: string },\n colorFormat: 'oklch' | 'rgb' | 'hsl' | 'hex'\n): string => {\n switch (colorFormat) {\n case 'oklch':\n return color.oklch\n case 'rgb':\n return color.rgb\n case 'hsl':\n return color.hsl\n case 'hex':\n default:\n return color.hex\n }\n}\n\nexport const createColorData = (baseColors: string[], format: Format) => {\n return baseColors.map((color) => {\n if (!culori.parse(color)) {\n console.warn(`Invalid color: ${color}`)\n return null\n }\n\n const colorData = {\n oklch: culori.formatCss(color) || '',\n hex: culori.formatHex(color) || '',\n rgb: culori.formatRgb(color) || '',\n hsl: culori.formatHsl(color) || '',\n }\n\n return getColorValue(colorData, format)\n })\n}\n"]}
@@ -0,0 +1,49 @@
1
+ type ThemeCategory = 'brand' | 'aboriginal';
2
+ type ThemeVars = Record<string, string>;
3
+ declare const DEFAULT_THEME: {
4
+ readonly category: ThemeCategory;
5
+ readonly primaryHue: "blue";
6
+ readonly accentHue: "red";
7
+ };
8
+ /**
9
+ * Explicit hue lists per category. Matches the keys in `colorThemes[category]`
10
+ * (minus grey) but kept hardcoded so the picker can't accidentally surface a
11
+ * new hue that hasn't been reviewed for accessibility/contrast.
12
+ */
13
+ declare const BRAND_HUES: readonly ["green", "teal", "blue", "purple", "fuchsia", "red", "orange", "yellow", "brown"];
14
+ declare const ABORIGINAL_HUES: readonly ["red", "orange", "brown", "yellow", "green", "blue", "purple"];
15
+ declare function getColorHues(category: ThemeCategory): readonly string[];
16
+ /** Hues valid as an accent for the given primary — excludes grey and the primary itself. */
17
+ declare function getAccentHues(category: ThemeCategory, primaryHue: string): string[];
18
+ /** Display label for a hue, derived from the canonical "01" anchor name. */
19
+ declare function getHueLabel(category: ThemeCategory, hue: string): string;
20
+ /** Swatch hex for a primary option — uses the -800 step (NSW 01 anchor). */
21
+ declare function getPrimarySwatch(category: ThemeCategory, hue: string): string;
22
+ /** Swatch hex for an accent option — uses the -600 step (NSW 02 anchor). */
23
+ declare function getAccentSwatch(category: ThemeCategory, hue: string): string;
24
+ /**
25
+ * Coerce a requested hue into one that exists for the given category.
26
+ * Returns the requested hue if valid, otherwise the first available hue,
27
+ * otherwise the default.
28
+ */
29
+ declare function resolvePrimaryHue(category: ThemeCategory, requested: string | undefined): string;
30
+ /** Same as resolvePrimaryHue but also avoids colliding with the primary. */
31
+ declare function resolveAccentHue(category: ThemeCategory, primaryHue: string, requested: string | undefined): string;
32
+ /**
33
+ * Build a flat map of CSS custom properties to apply on `documentElement` for
34
+ * the chosen category + primary + accent hues. The override targets the
35
+ * Tailwind bridge scale vars (`--color-primary-50`…`-950`, `--color-accent-*`,
36
+ * `--color-grey-*`) because those are what NSW components actually consume.
37
+ *
38
+ * Pass the result through `setProperty(...)` per key. Keys not returned should
39
+ * be cleared with `removeProperty(...)` to fall back to globals.css.
40
+ */
41
+ declare function buildThemeVars(category: ThemeCategory, primaryHue: string, accentHue: string): ThemeVars;
42
+ /**
43
+ * The complete set of CSS custom-property names that `buildThemeVars` may
44
+ * write. The decorator clears any name in this list that isn't returned by a
45
+ * given call, so toggling between palettes never leaves stale overrides.
46
+ */
47
+ declare const THEME_VAR_NAMES: readonly string[];
48
+
49
+ export { ABORIGINAL_HUES, BRAND_HUES, DEFAULT_THEME, THEME_VAR_NAMES, type ThemeCategory, type ThemeVars, buildThemeVars, getAccentHues, getAccentSwatch, getColorHues, getHueLabel, getPrimarySwatch, resolveAccentHue, resolvePrimaryHue };
@@ -0,0 +1,103 @@
1
+ import { colorThemes, colors } from './color-palette.js';
2
+
3
+ const STEPS = [
4
+ 50,
5
+ 100,
6
+ 150,
7
+ 200,
8
+ 250,
9
+ 300,
10
+ 350,
11
+ 400,
12
+ 450,
13
+ 500,
14
+ 550,
15
+ 600,
16
+ 650,
17
+ 700,
18
+ 750,
19
+ 800,
20
+ 850,
21
+ 900,
22
+ 950
23
+ ];
24
+ const GREY_KEY = "grey";
25
+ const DEFAULT_THEME = {
26
+ category: "brand",
27
+ primaryHue: "blue",
28
+ accentHue: "red"
29
+ };
30
+ const BRAND_HUES = [
31
+ "green",
32
+ "teal",
33
+ "blue",
34
+ "purple",
35
+ "fuchsia",
36
+ "red",
37
+ "orange",
38
+ "yellow",
39
+ "brown"
40
+ ];
41
+ const ABORIGINAL_HUES = [
42
+ "red",
43
+ "orange",
44
+ "brown",
45
+ "yellow",
46
+ "green",
47
+ "blue",
48
+ "purple"
49
+ ];
50
+ function getColorHues(category) {
51
+ return category === "aboriginal" ? ABORIGINAL_HUES : BRAND_HUES;
52
+ }
53
+ function getAccentHues(category, primaryHue) {
54
+ return getColorHues(category).filter((h) => h !== primaryHue);
55
+ }
56
+ function prettifyName(raw, fallback) {
57
+ if (!raw) return fallback;
58
+ return raw.replace(/\b(NSW|0[1-4])\b/g, "").replace(/\s+/g, " ").trim() || fallback;
59
+ }
60
+ function getHueLabel(category, hue) {
61
+ return prettifyName(colorThemes[category]?.[hue]?.colors[3]?.name, hue);
62
+ }
63
+ function getPrimarySwatch(category, hue) {
64
+ return colorThemes[category]?.[hue]?.colors[3]?.hex ?? "#000000";
65
+ }
66
+ function getAccentSwatch(category, hue) {
67
+ return colorThemes[category]?.[hue]?.colors[2]?.hex ?? "#000000";
68
+ }
69
+ function resolvePrimaryHue(category, requested) {
70
+ const hues = getColorHues(category);
71
+ if (requested && hues.includes(requested)) return requested;
72
+ return hues[0] ?? DEFAULT_THEME.primaryHue;
73
+ }
74
+ function resolveAccentHue(category, primaryHue, requested) {
75
+ const hues = getAccentHues(category, primaryHue);
76
+ if (requested && hues.includes(requested)) return requested;
77
+ return hues[0] ?? DEFAULT_THEME.accentHue;
78
+ }
79
+ function writeScale(vars, slot, category, hue) {
80
+ const scale = colors[category]?.[hue]?.colors;
81
+ if (!scale) return;
82
+ for (const entry of scale) {
83
+ const m = entry.token.match(/-(\d+)$/);
84
+ if (!m) continue;
85
+ vars[`--color-${slot}-${m[1]}`] = entry.oklch;
86
+ }
87
+ }
88
+ function buildThemeVars(category, primaryHue, accentHue) {
89
+ const vars = {};
90
+ writeScale(vars, "primary", category, primaryHue);
91
+ writeScale(vars, "accent", category, accentHue);
92
+ writeScale(vars, "grey", category, GREY_KEY);
93
+ return vars;
94
+ }
95
+ const THEME_VAR_NAMES = [
96
+ ...STEPS.map((s) => `--color-primary-${s}`),
97
+ ...STEPS.map((s) => `--color-accent-${s}`),
98
+ ...STEPS.map((s) => `--color-grey-${s}`)
99
+ ];
100
+
101
+ export { ABORIGINAL_HUES, BRAND_HUES, DEFAULT_THEME, THEME_VAR_NAMES, buildThemeVars, getAccentHues, getAccentSwatch, getColorHues, getHueLabel, getPrimarySwatch, resolveAccentHue, resolvePrimaryHue };
102
+ //# sourceMappingURL=theme-palette.js.map
103
+ //# sourceMappingURL=theme-palette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/theme-palette.ts"],"names":[],"mappings":";;AAMA,MAAM,KAAA,GAAQ;AAAA,EACZ,EAAA;AAAA,EAAI,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAC1E,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK;AACZ,CAAA;AAEA,MAAM,QAAA,GAAW,MAAA;AAEV,MAAM,aAAA,GAAgB;AAAA,EAC3B,QAAA,EAAU,OAAA;AAAA,EACV,UAAA,EAAY,MAAA;AAAA,EACZ,SAAA,EAAW;AACb;AAOO,MAAM,UAAA,GAAa;AAAA,EACxB,OAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAEO,MAAM,eAAA,GAAkB;AAAA,EAC7B,KAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAEO,SAAS,aAAa,QAAA,EAA4C;AACvE,EAAA,OAAO,QAAA,KAAa,eAAe,eAAA,GAAkB,UAAA;AACvD;AAGO,SAAS,aAAA,CACd,UACA,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AAA,EAAgB,CAAC,CAAA,CAAE;AACzC","file":"theme-palette.js","sourcesContent":["import { colorThemes, colors } from './color-palette.js'\n\nexport type ThemeCategory = 'brand' | 'aboriginal'\n\nexport type ThemeVars = Record<string, string>\n\nconst STEPS = [\n 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800,\n 850, 900, 950,\n] as const\n\nconst GREY_KEY = 'grey'\n\nexport const DEFAULT_THEME = {\n category: 'brand' as ThemeCategory,\n primaryHue: 'blue',\n accentHue: 'red',\n} as const\n\n/**\n * Explicit hue lists per category. Matches the keys in `colorThemes[category]`\n * (minus grey) but kept hardcoded so the picker can't accidentally surface a\n * new hue that hasn't been reviewed for accessibility/contrast.\n */\nexport const BRAND_HUES = [\n 'green',\n 'teal',\n 'blue',\n 'purple',\n 'fuchsia',\n 'red',\n 'orange',\n 'yellow',\n 'brown',\n] as const\n\nexport const ABORIGINAL_HUES = [\n 'red',\n 'orange',\n 'brown',\n 'yellow',\n 'green',\n 'blue',\n 'purple',\n] as const\n\nexport function getColorHues(category: ThemeCategory): readonly string[] {\n return category === 'aboriginal' ? ABORIGINAL_HUES : BRAND_HUES\n}\n\n/** Hues valid as an accent for the given primary — excludes grey and the primary itself. */\nexport function getAccentHues(\n category: ThemeCategory,\n primaryHue: string,\n): string[] {\n return getColorHues(category).filter((h) => h !== primaryHue)\n}\n\n/**\n * Strip \"NSW\" and \"01\"/\"02\"/\"03\"/\"04\" markers from an anchor name so it\n * displays cleanly in the picker. \"NSW Green 01\" → \"Green\",\n * \"Earth Red\" → \"Earth Red\".\n */\nfunction prettifyName(raw: string | undefined, fallback: string): string {\n if (!raw) return fallback\n return (\n raw\n .replace(/\\b(NSW|0[1-4])\\b/g, '')\n .replace(/\\s+/g, ' ')\n .trim() || fallback\n )\n}\n\n/** Display label for a hue, derived from the canonical \"01\" anchor name. */\nexport function getHueLabel(category: ThemeCategory, hue: string): string {\n return prettifyName(colorThemes[category]?.[hue]?.colors[3]?.name, hue)\n}\n\n/** Swatch hex for a primary option — uses the -800 step (NSW 01 anchor). */\nexport function getPrimarySwatch(category: ThemeCategory, hue: string): string {\n return colorThemes[category]?.[hue]?.colors[3]?.hex ?? '#000000'\n}\n\n/** Swatch hex for an accent option — uses the -600 step (NSW 02 anchor). */\nexport function getAccentSwatch(category: ThemeCategory, hue: string): string {\n return colorThemes[category]?.[hue]?.colors[2]?.hex ?? '#000000'\n}\n\n/**\n * Coerce a requested hue into one that exists for the given category.\n * Returns the requested hue if valid, otherwise the first available hue,\n * otherwise the default.\n */\nexport function resolvePrimaryHue(\n category: ThemeCategory,\n requested: string | undefined,\n): string {\n const hues = getColorHues(category)\n if (requested && hues.includes(requested)) return requested\n return hues[0] ?? DEFAULT_THEME.primaryHue\n}\n\n/** Same as resolvePrimaryHue but also avoids colliding with the primary. */\nexport function resolveAccentHue(\n category: ThemeCategory,\n primaryHue: string,\n requested: string | undefined,\n): string {\n const hues = getAccentHues(category, primaryHue)\n if (requested && hues.includes(requested)) return requested\n return hues[0] ?? DEFAULT_THEME.accentHue\n}\n\n/**\n * Write the 19-step scale of `colors[category][hue].colors` into `vars` under\n * a given semantic slot. e.g. slot='primary' produces `--color-primary-50`\n * through `--color-primary-950`. Steps not present in the source are skipped.\n */\nfunction writeScale(\n vars: ThemeVars,\n slot: 'primary' | 'accent' | 'grey',\n category: ThemeCategory,\n hue: string,\n) {\n const scale = colors[category]?.[hue]?.colors\n if (!scale) return\n for (const entry of scale) {\n const m = entry.token.match(/-(\\d+)$/)\n if (!m) continue\n vars[`--color-${slot}-${m[1]}`] = entry.oklch\n }\n}\n\n/**\n * Build a flat map of CSS custom properties to apply on `documentElement` for\n * the chosen category + primary + accent hues. The override targets the\n * Tailwind bridge scale vars (`--color-primary-50`…`-950`, `--color-accent-*`,\n * `--color-grey-*`) because those are what NSW components actually consume.\n *\n * Pass the result through `setProperty(...)` per key. Keys not returned should\n * be cleared with `removeProperty(...)` to fall back to globals.css.\n */\nexport function buildThemeVars(\n category: ThemeCategory,\n primaryHue: string,\n accentHue: string,\n): ThemeVars {\n const vars: ThemeVars = {}\n writeScale(vars, 'primary', category, primaryHue)\n writeScale(vars, 'accent', category, accentHue)\n writeScale(vars, 'grey', category, GREY_KEY)\n return vars\n}\n\n/**\n * The complete set of CSS custom-property names that `buildThemeVars` may\n * write. The decorator clears any name in this list that isn't returned by a\n * given call, so toggling between palettes never leaves stale overrides.\n */\nexport const THEME_VAR_NAMES: readonly string[] = [\n ...STEPS.map((s) => `--color-primary-${s}`),\n ...STEPS.map((s) => `--color-accent-${s}`),\n ...STEPS.map((s) => `--color-grey-${s}`),\n]\n"]}
@@ -1,5 +1,9 @@
1
1
  import { ClassValue } from 'clsx';
2
2
 
3
3
  declare function cn(...inputs: ClassValue[]): string;
4
+ declare function truncate(text: string, maxLength: number): string;
5
+ declare function kebabCase(str: string): string;
6
+ declare function camelCase(str: string): string;
7
+ declare function humaniseVariant(key: string): string;
4
8
 
5
- export { cn };
9
+ export { camelCase, cn, humaniseVariant, kebabCase, truncate };
package/dist/lib/utils.js CHANGED
@@ -4,7 +4,22 @@ import { twMerge } from 'tailwind-merge';
4
4
  function cn(...inputs) {
5
5
  return twMerge(clsx(inputs));
6
6
  }
7
+ function truncate(text, maxLength) {
8
+ if (text.length <= maxLength) {
9
+ return text;
10
+ }
11
+ return text.slice(0, maxLength) + "...";
12
+ }
13
+ function kebabCase(str) {
14
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
15
+ }
16
+ function camelCase(str) {
17
+ return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
18
+ }
19
+ function humaniseVariant(key) {
20
+ return key.replace(/([a-z])([A-Z0-9])/g, "$1 $2").replace(/([0-9])([A-Za-z])/g, "$1 $2").replace(/_/g, " ").replace(/\bFull\s?Width\b/gi, "full width").replace(/\s+/g, " ").trim().replace(/^./, (s) => s.toUpperCase());
21
+ }
7
22
 
8
- export { cn };
23
+ export { camelCase, cn, humaniseVariant, kebabCase, truncate };
9
24
  //# sourceMappingURL=utils.js.map
10
25
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B","file":"utils.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAEO,SAAS,QAAA,CAAS,MAAc,SAAA,EAA2B;AAChE,EAAA,IAAI,IAAA,CAAK,UAAU,SAAA,EAAW;AAC5B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,KAAA;AACpC;AAEO,SAAS,UAAU,GAAA,EAAa;AACrC,EAAA,OAAO,GAAA,CACJ,QAAQ,iBAAA,EAAmB,OAAO,EAClC,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA,CACtB,WAAA,EAAY;AACjB;AAEO,SAAS,UAAU,GAAA,EAAa;AACrC,EAAA,OAAO,GAAA,CACJ,WAAA,EAAY,CACZ,OAAA,CAAQ,mBAAA,EAAqB,CAAC,CAAA,EAAG,GAAA,KAAQ,GAAA,CAAI,WAAA,EAAa,CAAA;AAC/D;AAEO,SAAS,gBAAgB,GAAA,EAAqB;AACnD,EAAA,OAAO,GAAA,CACJ,OAAA,CAAQ,oBAAA,EAAsB,OAAO,CAAA,CACrC,OAAA,CAAQ,oBAAA,EAAsB,OAAO,CAAA,CACrC,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CACjB,OAAA,CAAQ,oBAAA,EAAsB,YAAY,CAAA,CAC1C,OAAA,CAAQ,MAAA,EAAQ,GAAG,CAAA,CACnB,IAAA,EAAK,CACL,OAAA,CAAQ,IAAA,EAAM,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AACzC","file":"utils.js","sourcesContent":["import { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function truncate(text: string, maxLength: number): string {\n if (text.length <= maxLength) {\n return text\n }\n return text.slice(0, maxLength) + '...'\n}\n\nexport function kebabCase(str: string) {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase()\n}\n\nexport function camelCase(str: string) {\n return str\n .toLowerCase()\n .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase())\n}\n\nexport function humaniseVariant(key: string): string {\n return key\n .replace(/([a-z])([A-Z0-9])/g, '$1 $2')\n .replace(/([0-9])([A-Za-z])/g, '$1 $2')\n .replace(/_/g, ' ')\n .replace(/\\bFull\\s?Width\\b/gi, 'full width')\n .replace(/\\s+/g, ' ')\n .trim()\n .replace(/^./, (s) => s.toUpperCase())\n}\n"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=globals.css.d.js.map
3
+ //# sourceMappingURL=globals.css.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"globals.css.d.js"}