@epicbagel/saas-kit 1.2.3 → 1.4.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 (80) hide show
  1. package/README.md +115 -0
  2. package/dist/chunk-2TKLS73N.js +121 -0
  3. package/dist/chunk-4UUTKR3V.cjs +53 -0
  4. package/dist/chunk-BTHYGHOH.cjs +143 -0
  5. package/dist/chunk-D5EHW3O2.cjs +52 -0
  6. package/dist/chunk-F3DAFAMD.js +271 -0
  7. package/dist/chunk-GRY77463.cjs +121 -0
  8. package/dist/chunk-HAP6USTP.cjs +46 -0
  9. package/dist/chunk-HAQOT2CD.js +46 -0
  10. package/dist/chunk-HHV4G77I.js +55 -0
  11. package/dist/{chunk-KYQPX754.js → chunk-HRLP4BHJ.js} +7 -7
  12. package/dist/{chunk-N6V3DDKU.cjs → chunk-IH3COANJ.cjs} +7 -7
  13. package/dist/chunk-JTI4244T.js +143 -0
  14. package/dist/chunk-QEJ2STIV.js +53 -0
  15. package/dist/chunk-TWCJMFST.js +260 -0
  16. package/dist/chunk-U3YFP6ZV.cjs +273 -0
  17. package/dist/chunk-VLXPLKFR.cjs +55 -0
  18. package/dist/chunk-X3PRMR5G.js +52 -0
  19. package/dist/chunk-ZJFYOXSM.cjs +260 -0
  20. package/dist/lib/neutral-theme.cjs +39 -236
  21. package/dist/lib/neutral-theme.d.cts +44 -2
  22. package/dist/lib/neutral-theme.d.ts +44 -2
  23. package/dist/lib/neutral-theme.js +23 -219
  24. package/dist/primitives/activity-feed.cjs +3 -3
  25. package/dist/primitives/activity-feed.js +4 -4
  26. package/dist/primitives/board-view.cjs +6 -6
  27. package/dist/primitives/board-view.js +5 -5
  28. package/dist/primitives/chat.cjs +14 -14
  29. package/dist/primitives/chat.js +12 -12
  30. package/dist/primitives/code-block.cjs +5 -50
  31. package/dist/primitives/code-block.js +5 -50
  32. package/dist/primitives/connection.cjs +6 -6
  33. package/dist/primitives/connection.js +7 -7
  34. package/dist/primitives/copy-button.cjs +3 -3
  35. package/dist/primitives/copy-button.js +2 -2
  36. package/dist/primitives/document-preview.cjs +54 -0
  37. package/dist/primitives/document-preview.d.cts +30 -0
  38. package/dist/primitives/document-preview.d.ts +30 -0
  39. package/dist/primitives/document-preview.js +54 -0
  40. package/dist/primitives/editable-list.cjs +1 -1
  41. package/dist/primitives/editable-list.js +1 -1
  42. package/dist/primitives/field.cjs +12 -239
  43. package/dist/primitives/field.js +16 -243
  44. package/dist/primitives/file-dropzone.cjs +3 -3
  45. package/dist/primitives/file-dropzone.js +2 -2
  46. package/dist/primitives/file-preview-internals.cjs +20 -0
  47. package/dist/primitives/file-preview-internals.d.cts +44 -0
  48. package/dist/primitives/file-preview-internals.d.ts +44 -0
  49. package/dist/primitives/file-preview-internals.js +20 -0
  50. package/dist/primitives/file-preview.cjs +327 -0
  51. package/dist/primitives/file-preview.d.cts +92 -0
  52. package/dist/primitives/file-preview.d.ts +92 -0
  53. package/dist/primitives/file-preview.js +327 -0
  54. package/dist/primitives/filter-bar.cjs +4 -4
  55. package/dist/primitives/filter-bar.js +3 -3
  56. package/dist/primitives/image.cjs +4 -48
  57. package/dist/primitives/image.js +3 -47
  58. package/dist/primitives/radio-group.cjs +4 -39
  59. package/dist/primitives/radio-group.js +4 -39
  60. package/dist/primitives/resource-list.cjs +6 -6
  61. package/dist/primitives/resource-list.js +5 -5
  62. package/dist/primitives/responsive-dialog.cjs +26 -142
  63. package/dist/primitives/responsive-dialog.js +13 -129
  64. package/dist/primitives/section.cjs +2 -2
  65. package/dist/primitives/section.js +3 -3
  66. package/dist/primitives/switch-field.cjs +2 -2
  67. package/dist/primitives/switch-field.js +3 -3
  68. package/dist/primitives/theme-selector.cjs +188 -0
  69. package/dist/primitives/theme-selector.d.cts +78 -0
  70. package/dist/primitives/theme-selector.d.ts +78 -0
  71. package/dist/primitives/theme-selector.js +188 -0
  72. package/dist/primitives/toggle-group.cjs +5 -45
  73. package/dist/primitives/toggle-group.js +5 -45
  74. package/package.json +31 -1
  75. package/dist/{chunk-6OTAGP2I.cjs → chunk-KADJ56AH.cjs} +2 -2
  76. package/dist/{chunk-EHKMVJ6O.js → chunk-M7FYGAGO.js} +3 -3
  77. package/dist/{chunk-PVZ4JGDU.js → chunk-MLHNYRFX.js} +6 -6
  78. package/dist/{chunk-PWOQMTPX.js → chunk-NW3OWKBN.js} +3 -3
  79. package/dist/{chunk-CYH63OCL.cjs → chunk-SGW4FWBX.cjs} +6 -6
  80. package/dist/{chunk-ENJNZ323.cjs → chunk-VKIGJNJR.cjs} +2 -2
@@ -1,238 +1,41 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- // src/lib/neutral-theme.ts
4
- var SEMANTIC_TOKENS = [
5
- "background",
6
- "foreground",
7
- "card",
8
- "card-foreground",
9
- "popover",
10
- "popover-foreground",
11
- "primary",
12
- "primary-foreground",
13
- "secondary",
14
- "secondary-foreground",
15
- "muted",
16
- "muted-foreground",
17
- "accent",
18
- "accent-foreground",
19
- "destructive",
20
- "destructive-foreground",
21
- "border",
22
- "input",
23
- "ring",
24
- "chart-1",
25
- "chart-2",
26
- "chart-3",
27
- "chart-4",
28
- "chart-5",
29
- "sidebar-background",
30
- "sidebar-foreground",
31
- "sidebar-primary",
32
- "sidebar-primary-foreground",
33
- "sidebar-accent",
34
- "sidebar-accent-foreground",
35
- "sidebar-border",
36
- "sidebar-ring"
37
- ];
38
- function hexToRgb(hex) {
39
- const h = hex.replace("#", "").trim();
40
- const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
41
- if (!/^[0-9a-fA-F]{6}$/.test(full)) {
42
- throw new Error(`Not a hex colour: ${hex}`);
43
- }
44
- return [
45
- parseInt(full.slice(0, 2), 16),
46
- parseInt(full.slice(2, 4), 16),
47
- parseInt(full.slice(4, 6), 16)
48
- ];
49
- }
50
- function hexToHsl(hex) {
51
- const [r255, g255, b255] = hexToRgb(hex);
52
- const r = r255 / 255;
53
- const g = g255 / 255;
54
- const b = b255 / 255;
55
- const max = Math.max(r, g, b);
56
- const min = Math.min(r, g, b);
57
- const l = (max + min) / 2;
58
- const d = max - min;
59
- let h = 0;
60
- let s = 0;
61
- if (d !== 0) {
62
- s = d / (1 - Math.abs(2 * l - 1));
63
- if (max === r) h = (g - b) / d % 6;
64
- else if (max === g) h = (b - r) / d + 2;
65
- else h = (r - g) / d + 4;
66
- h *= 60;
67
- if (h < 0) h += 360;
68
- }
69
- const round = (n) => Math.round(n * 10) / 10;
70
- return `${round(h)} ${round(s * 100)}% ${round(l * 100)}%`;
71
- }
72
- function luminance(hex) {
73
- const [r, g, b] = hexToRgb(hex).map((v) => {
74
- const c = v / 255;
75
- return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
76
- });
77
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
78
- }
79
- function contrastRatio(a, b) {
80
- const la = luminance(a);
81
- const lb = luminance(b);
82
- const [hi, lo] = la > lb ? [la, lb] : [lb, la];
83
- return (hi + 0.05) / (lo + 0.05);
84
- }
85
- function bestForeground(bg, candidates) {
86
- let best = candidates[0];
87
- let bestRatio = 0;
88
- for (const c of candidates) {
89
- const ratio = contrastRatio(bg, c);
90
- if (ratio > bestRatio) {
91
- best = c;
92
- bestRatio = ratio;
93
- }
94
- }
95
- return best;
96
- }
97
- var NEUTRAL_RADIUS = "0rem";
98
- function neutral(mode) {
99
- const light = mode === "light";
100
- const danger = "#d71921";
101
- const mono = light ? {
102
- bg: "#ffffff",
103
- fg: "#000000",
104
- surface: "#f5f5f5",
105
- subtle: "#666666",
106
- border: "#e5e5e5",
107
- sidebar: "#fafafa",
108
- strong: "#333333"
109
- } : {
110
- bg: "#000000",
111
- fg: "#ffffff",
112
- surface: "#1a1a1a",
113
- subtle: "#999999",
114
- border: "#333333",
115
- sidebar: "#0d0d0d",
116
- strong: "#cccccc"
117
- };
118
- return {
119
- background: mono.bg,
120
- foreground: mono.fg,
121
- card: mono.bg,
122
- "card-foreground": mono.fg,
123
- popover: mono.bg,
124
- "popover-foreground": mono.fg,
125
- primary: mono.fg,
126
- "primary-foreground": mono.bg,
127
- secondary: mono.surface,
128
- "secondary-foreground": mono.fg,
129
- muted: mono.surface,
130
- "muted-foreground": mono.subtle,
131
- accent: mono.surface,
132
- "accent-foreground": mono.fg,
133
- destructive: danger,
134
- "destructive-foreground": bestForeground(danger, ["#ffffff", "#000000"]),
135
- border: mono.border,
136
- input: mono.border,
137
- ring: mono.fg,
138
- "chart-1": light ? "#333333" : "#cccccc",
139
- "chart-2": light ? "#4d4d4d" : "#b3b3b3",
140
- "chart-3": light ? "#666666" : "#999999",
141
- "chart-4": light ? "#808080" : "#808080",
142
- "chart-5": light ? "#999999" : "#666666",
143
- "sidebar-background": mono.sidebar,
144
- "sidebar-foreground": mono.fg,
145
- "sidebar-primary": mono.fg,
146
- "sidebar-primary-foreground": mono.bg,
147
- "sidebar-accent": mono.surface,
148
- "sidebar-accent-foreground": mono.fg,
149
- "sidebar-border": mono.border,
150
- "sidebar-ring": mono.border
151
- };
152
- }
153
- var NEUTRAL = {
154
- light: neutral("light"),
155
- dark: neutral("dark")
156
- };
157
- function colorAlias(token) {
158
- if (token.startsWith("chart-")) return null;
159
- if (token === "sidebar-background") return "--color-sidebar";
160
- return `--color-${token}`;
161
- }
162
- function paletteDeclarations(tokens, names, radius, { indent = " ", aliasSource = "neutral-theme.ts" } = {}) {
163
- const value = (token) => {
164
- const hex = tokens[token];
165
- if (hex === void 0) throw new Error(`Missing token: ${token}`);
166
- return hexToHsl(hex);
167
- };
168
- const lines = [`${indent}--radius: ${radius};`];
169
- for (const token of names) {
170
- lines.push(`${indent}--${token}: ${value(token)};`);
171
- }
172
- lines.push(`${indent}--sidebar: ${value("sidebar-background")};`);
173
- lines.push(`${indent}/* Tailwind-facing aliases \u2014 see ${aliasSource} */`);
174
- for (const token of names) {
175
- const alias = colorAlias(token);
176
- if (alias) lines.push(`${indent}${alias}: hsl(var(--${token}));`);
177
- }
178
- lines.push(`${indent}--radius-sm: calc(var(--radius) - 4px);`);
179
- lines.push(`${indent}--radius-md: calc(var(--radius) - 2px);`);
180
- lines.push(`${indent}--radius-lg: var(--radius);`);
181
- lines.push(`${indent}--radius-xl: calc(var(--radius) + 4px);`);
182
- lines.push(`${indent}--radius-2xl: calc(var(--radius) + 8px);`);
183
- return lines.join("\n");
184
- }
185
- function paletteBlock(selector, declarations, indent = "") {
186
- const head = selector.split("\n").map((line) => indent + line).join("\n");
187
- return `${head} {
188
- ${declarations}
189
- ${indent}}
190
- `;
191
- }
192
- function layerBlock(name, rules) {
193
- return `@layer ${name} {
194
- ${rules.join("\n")}}
195
- `;
196
- }
197
- var DARK_ROOT_SELECTOR = ":root:where(.dark)";
198
- function baseLayerPalette(light, dark, indent = " ") {
199
- return layerBlock("base", [
200
- paletteBlock(":root", light, indent),
201
- paletteBlock(DARK_ROOT_SELECTOR, dark, indent)
202
- ]);
203
- }
204
- var PALETTE_GENERATED_HEADER = `/* GENERATED FILE \u2014 do not edit.
205
- * Source: src/lib/neutral-theme.ts \xB7 Regenerate: pnpm gen:themes
206
- *
207
- * The neutral palette: light on :root, dark when the root carries the
208
- * \`.dark\` class. It sits in \`@layer base\`, so any unlayered palette rule
209
- * or a host's own :root overrides wins on layer order alone. Imported by
210
- * tokens.css; every --color-* alias and the radius scale are re-declared
211
- * alongside the tokens they read.
212
- */`;
213
- function renderPaletteCss() {
214
- const declarations = (mode) => paletteDeclarations(NEUTRAL[mode], SEMANTIC_TOKENS, NEUTRAL_RADIUS, {
215
- indent: " "
216
- });
217
- return [
218
- PALETTE_GENERATED_HEADER,
219
- baseLayerPalette(declarations("light"), declarations("dark"))
220
- ].join("\n");
221
- }
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
- exports.NEUTRAL = NEUTRAL; exports.NEUTRAL_RADIUS = NEUTRAL_RADIUS; exports.PALETTE_GENERATED_HEADER = PALETTE_GENERATED_HEADER; exports.SEMANTIC_TOKENS = SEMANTIC_TOKENS; exports.baseLayerPalette = baseLayerPalette; exports.bestForeground = bestForeground; exports.colorAlias = colorAlias; exports.contrastRatio = contrastRatio; exports.hexToHsl = hexToHsl; exports.hexToRgb = hexToRgb; exports.layerBlock = layerBlock; exports.luminance = luminance; exports.paletteBlock = paletteBlock; exports.paletteDeclarations = paletteDeclarations; exports.renderPaletteCss = renderPaletteCss;
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ var _chunkU3YFP6ZVcjs = require('../chunk-U3YFP6ZV.cjs');
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ exports.NEUTRAL = _chunkU3YFP6ZVcjs.NEUTRAL; exports.NEUTRAL_PALETTE = _chunkU3YFP6ZVcjs.NEUTRAL_PALETTE; exports.NEUTRAL_RADIUS = _chunkU3YFP6ZVcjs.NEUTRAL_RADIUS; exports.NEUTRAL_THEME_ID = _chunkU3YFP6ZVcjs.NEUTRAL_THEME_ID; exports.PALETTE_GENERATED_HEADER = _chunkU3YFP6ZVcjs.PALETTE_GENERATED_HEADER; exports.SEMANTIC_TOKENS = _chunkU3YFP6ZVcjs.SEMANTIC_TOKENS; exports.baseLayerPalette = _chunkU3YFP6ZVcjs.baseLayerPalette; exports.bestForeground = _chunkU3YFP6ZVcjs.bestForeground; exports.colorAlias = _chunkU3YFP6ZVcjs.colorAlias; exports.contrastRatio = _chunkU3YFP6ZVcjs.contrastRatio; exports.hexToHsl = _chunkU3YFP6ZVcjs.hexToHsl; exports.hexToRgb = _chunkU3YFP6ZVcjs.hexToRgb; exports.layerBlock = _chunkU3YFP6ZVcjs.layerBlock; exports.luminance = _chunkU3YFP6ZVcjs.luminance; exports.paletteBlock = _chunkU3YFP6ZVcjs.paletteBlock; exports.paletteDeclarations = _chunkU3YFP6ZVcjs.paletteDeclarations; exports.paletteStyle = _chunkU3YFP6ZVcjs.paletteStyle; exports.renderPaletteCss = _chunkU3YFP6ZVcjs.renderPaletteCss;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * The neutral palette, plus the token contract, colour maths and CSS
3
- * rendering that every palette shares.
3
+ * rendering that every palette shares, and the shape a theme picker offers
4
+ * a palette in (`ThemePalette`).
4
5
  *
5
6
  * Neutral is plain black and white with square corners. `pnpm gen:themes`
6
7
  * renders it to `src/styles/palette.gen.css`, which `styles/tokens.css`
@@ -47,6 +48,38 @@ declare function bestForeground(bg: string, candidates: string[]): string;
47
48
  declare const NEUTRAL_RADIUS = "0rem";
48
49
  /** The neutral palette's semantic tokens, per mode, as hex. */
49
50
  declare const NEUTRAL: Readonly<Record<ThemeMode, SemanticTokenMap>>;
51
+ /**
52
+ * The `data-theme` value the neutral palette answers to. The stylesheet
53
+ * paints the neutral palette wherever no palette is named, so stamping this
54
+ * id changes nothing on screen; a host stores it like any other pick.
55
+ */
56
+ declare const NEUTRAL_THEME_ID = "minimal";
57
+ /**
58
+ * A palette a theme picker offers (`primitives/theme-selector`).
59
+ *
60
+ * `id` is the palette's `data-theme` value, and what a host stores when
61
+ * someone picks it. The tokens are optional. Given for a mode, a preview of
62
+ * that mode paints from them directly (`paletteStyle`), whatever palette the
63
+ * page around it is in. Without them, the preview carries `data-theme` and
64
+ * `data-mode` instead, and the page's palette CSS has to paint those on any
65
+ * element, not just the root.
66
+ */
67
+ interface ThemePalette {
68
+ /** The `data-theme` value. Stable: hosts store it. */
69
+ readonly id: string;
70
+ /** Display name. */
71
+ readonly label: string;
72
+ /** One line under the name. */
73
+ readonly description?: string;
74
+ /** `--radius` for the palette's previews. Leave out to keep the page's. */
75
+ readonly radius?: string;
76
+ /** Light mode's semantic tokens, as hex. */
77
+ readonly light?: Readonly<SemanticTokenMap>;
78
+ /** Dark mode's semantic tokens, as hex. */
79
+ readonly dark?: Readonly<SemanticTokenMap>;
80
+ }
81
+ /** The neutral palette as a picker offers it: the kit's default. */
82
+ declare const NEUTRAL_PALETTE: ThemePalette;
50
83
  /**
51
84
  * The Tailwind colour name each token feeds, or null for tokens with no
52
85
  * utility (the chart series are read directly as `var(--chart-1)`).
@@ -65,6 +98,15 @@ interface PaletteDeclarationOptions {
65
98
  * aliases and the radius scale.
66
99
  */
67
100
  declare function paletteDeclarations(tokens: Readonly<Record<string, string>>, names: readonly string[], radius: string, { indent, aliasSource }?: PaletteDeclarationOptions): string;
101
+ /**
102
+ * `paletteDeclarations` as an inline style: the same custom properties with
103
+ * the same values, for one element (`style={paletteStyle(tokens, radius)}`).
104
+ * The element then paints in that palette whatever palette the page around
105
+ * it is in, because the `--color-*` aliases are declared, and so
106
+ * substituted, on the element itself. Without `radius` it keeps the page's
107
+ * `--radius`. This is how `PalettePreview` paints a palette's tokens.
108
+ */
109
+ declare function paletteStyle(tokens: Readonly<Record<string, string>>, radius?: string, names?: readonly string[]): Record<string, string>;
68
110
  /**
69
111
  * One rule: `selector { declarations }`, newline-terminated. `indent`
70
112
  * prefixes each selector line and the closing brace, for a rule nested in
@@ -89,4 +131,4 @@ declare const PALETTE_GENERATED_HEADER = "/* GENERATED FILE \u2014 do not edit.\
89
131
  /** `src/styles/palette.gen.css`: the neutral palette, light then dark. */
90
132
  declare function renderPaletteCss(): string;
91
133
 
92
- export { NEUTRAL, NEUTRAL_RADIUS, PALETTE_GENERATED_HEADER, type PaletteDeclarationOptions, SEMANTIC_TOKENS, type SemanticToken, type SemanticTokenMap, type ThemeMode, baseLayerPalette, bestForeground, colorAlias, contrastRatio, hexToHsl, hexToRgb, layerBlock, luminance, paletteBlock, paletteDeclarations, renderPaletteCss };
134
+ export { NEUTRAL, NEUTRAL_PALETTE, NEUTRAL_RADIUS, NEUTRAL_THEME_ID, PALETTE_GENERATED_HEADER, type PaletteDeclarationOptions, SEMANTIC_TOKENS, type SemanticToken, type SemanticTokenMap, type ThemeMode, type ThemePalette, baseLayerPalette, bestForeground, colorAlias, contrastRatio, hexToHsl, hexToRgb, layerBlock, luminance, paletteBlock, paletteDeclarations, paletteStyle, renderPaletteCss };
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * The neutral palette, plus the token contract, colour maths and CSS
3
- * rendering that every palette shares.
3
+ * rendering that every palette shares, and the shape a theme picker offers
4
+ * a palette in (`ThemePalette`).
4
5
  *
5
6
  * Neutral is plain black and white with square corners. `pnpm gen:themes`
6
7
  * renders it to `src/styles/palette.gen.css`, which `styles/tokens.css`
@@ -47,6 +48,38 @@ declare function bestForeground(bg: string, candidates: string[]): string;
47
48
  declare const NEUTRAL_RADIUS = "0rem";
48
49
  /** The neutral palette's semantic tokens, per mode, as hex. */
49
50
  declare const NEUTRAL: Readonly<Record<ThemeMode, SemanticTokenMap>>;
51
+ /**
52
+ * The `data-theme` value the neutral palette answers to. The stylesheet
53
+ * paints the neutral palette wherever no palette is named, so stamping this
54
+ * id changes nothing on screen; a host stores it like any other pick.
55
+ */
56
+ declare const NEUTRAL_THEME_ID = "minimal";
57
+ /**
58
+ * A palette a theme picker offers (`primitives/theme-selector`).
59
+ *
60
+ * `id` is the palette's `data-theme` value, and what a host stores when
61
+ * someone picks it. The tokens are optional. Given for a mode, a preview of
62
+ * that mode paints from them directly (`paletteStyle`), whatever palette the
63
+ * page around it is in. Without them, the preview carries `data-theme` and
64
+ * `data-mode` instead, and the page's palette CSS has to paint those on any
65
+ * element, not just the root.
66
+ */
67
+ interface ThemePalette {
68
+ /** The `data-theme` value. Stable: hosts store it. */
69
+ readonly id: string;
70
+ /** Display name. */
71
+ readonly label: string;
72
+ /** One line under the name. */
73
+ readonly description?: string;
74
+ /** `--radius` for the palette's previews. Leave out to keep the page's. */
75
+ readonly radius?: string;
76
+ /** Light mode's semantic tokens, as hex. */
77
+ readonly light?: Readonly<SemanticTokenMap>;
78
+ /** Dark mode's semantic tokens, as hex. */
79
+ readonly dark?: Readonly<SemanticTokenMap>;
80
+ }
81
+ /** The neutral palette as a picker offers it: the kit's default. */
82
+ declare const NEUTRAL_PALETTE: ThemePalette;
50
83
  /**
51
84
  * The Tailwind colour name each token feeds, or null for tokens with no
52
85
  * utility (the chart series are read directly as `var(--chart-1)`).
@@ -65,6 +98,15 @@ interface PaletteDeclarationOptions {
65
98
  * aliases and the radius scale.
66
99
  */
67
100
  declare function paletteDeclarations(tokens: Readonly<Record<string, string>>, names: readonly string[], radius: string, { indent, aliasSource }?: PaletteDeclarationOptions): string;
101
+ /**
102
+ * `paletteDeclarations` as an inline style: the same custom properties with
103
+ * the same values, for one element (`style={paletteStyle(tokens, radius)}`).
104
+ * The element then paints in that palette whatever palette the page around
105
+ * it is in, because the `--color-*` aliases are declared, and so
106
+ * substituted, on the element itself. Without `radius` it keeps the page's
107
+ * `--radius`. This is how `PalettePreview` paints a palette's tokens.
108
+ */
109
+ declare function paletteStyle(tokens: Readonly<Record<string, string>>, radius?: string, names?: readonly string[]): Record<string, string>;
68
110
  /**
69
111
  * One rule: `selector { declarations }`, newline-terminated. `indent`
70
112
  * prefixes each selector line and the closing brace, for a rule nested in
@@ -89,4 +131,4 @@ declare const PALETTE_GENERATED_HEADER = "/* GENERATED FILE \u2014 do not edit.\
89
131
  /** `src/styles/palette.gen.css`: the neutral palette, light then dark. */
90
132
  declare function renderPaletteCss(): string;
91
133
 
92
- export { NEUTRAL, NEUTRAL_RADIUS, PALETTE_GENERATED_HEADER, type PaletteDeclarationOptions, SEMANTIC_TOKENS, type SemanticToken, type SemanticTokenMap, type ThemeMode, baseLayerPalette, bestForeground, colorAlias, contrastRatio, hexToHsl, hexToRgb, layerBlock, luminance, paletteBlock, paletteDeclarations, renderPaletteCss };
134
+ export { NEUTRAL, NEUTRAL_PALETTE, NEUTRAL_RADIUS, NEUTRAL_THEME_ID, PALETTE_GENERATED_HEADER, type PaletteDeclarationOptions, SEMANTIC_TOKENS, type SemanticToken, type SemanticTokenMap, type ThemeMode, type ThemePalette, baseLayerPalette, bestForeground, colorAlias, contrastRatio, hexToHsl, hexToRgb, layerBlock, luminance, paletteBlock, paletteDeclarations, paletteStyle, renderPaletteCss };
@@ -1,225 +1,28 @@
1
- // src/lib/neutral-theme.ts
2
- var SEMANTIC_TOKENS = [
3
- "background",
4
- "foreground",
5
- "card",
6
- "card-foreground",
7
- "popover",
8
- "popover-foreground",
9
- "primary",
10
- "primary-foreground",
11
- "secondary",
12
- "secondary-foreground",
13
- "muted",
14
- "muted-foreground",
15
- "accent",
16
- "accent-foreground",
17
- "destructive",
18
- "destructive-foreground",
19
- "border",
20
- "input",
21
- "ring",
22
- "chart-1",
23
- "chart-2",
24
- "chart-3",
25
- "chart-4",
26
- "chart-5",
27
- "sidebar-background",
28
- "sidebar-foreground",
29
- "sidebar-primary",
30
- "sidebar-primary-foreground",
31
- "sidebar-accent",
32
- "sidebar-accent-foreground",
33
- "sidebar-border",
34
- "sidebar-ring"
35
- ];
36
- function hexToRgb(hex) {
37
- const h = hex.replace("#", "").trim();
38
- const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
39
- if (!/^[0-9a-fA-F]{6}$/.test(full)) {
40
- throw new Error(`Not a hex colour: ${hex}`);
41
- }
42
- return [
43
- parseInt(full.slice(0, 2), 16),
44
- parseInt(full.slice(2, 4), 16),
45
- parseInt(full.slice(4, 6), 16)
46
- ];
47
- }
48
- function hexToHsl(hex) {
49
- const [r255, g255, b255] = hexToRgb(hex);
50
- const r = r255 / 255;
51
- const g = g255 / 255;
52
- const b = b255 / 255;
53
- const max = Math.max(r, g, b);
54
- const min = Math.min(r, g, b);
55
- const l = (max + min) / 2;
56
- const d = max - min;
57
- let h = 0;
58
- let s = 0;
59
- if (d !== 0) {
60
- s = d / (1 - Math.abs(2 * l - 1));
61
- if (max === r) h = (g - b) / d % 6;
62
- else if (max === g) h = (b - r) / d + 2;
63
- else h = (r - g) / d + 4;
64
- h *= 60;
65
- if (h < 0) h += 360;
66
- }
67
- const round = (n) => Math.round(n * 10) / 10;
68
- return `${round(h)} ${round(s * 100)}% ${round(l * 100)}%`;
69
- }
70
- function luminance(hex) {
71
- const [r, g, b] = hexToRgb(hex).map((v) => {
72
- const c = v / 255;
73
- return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
74
- });
75
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
76
- }
77
- function contrastRatio(a, b) {
78
- const la = luminance(a);
79
- const lb = luminance(b);
80
- const [hi, lo] = la > lb ? [la, lb] : [lb, la];
81
- return (hi + 0.05) / (lo + 0.05);
82
- }
83
- function bestForeground(bg, candidates) {
84
- let best = candidates[0];
85
- let bestRatio = 0;
86
- for (const c of candidates) {
87
- const ratio = contrastRatio(bg, c);
88
- if (ratio > bestRatio) {
89
- best = c;
90
- bestRatio = ratio;
91
- }
92
- }
93
- return best;
94
- }
95
- var NEUTRAL_RADIUS = "0rem";
96
- function neutral(mode) {
97
- const light = mode === "light";
98
- const danger = "#d71921";
99
- const mono = light ? {
100
- bg: "#ffffff",
101
- fg: "#000000",
102
- surface: "#f5f5f5",
103
- subtle: "#666666",
104
- border: "#e5e5e5",
105
- sidebar: "#fafafa",
106
- strong: "#333333"
107
- } : {
108
- bg: "#000000",
109
- fg: "#ffffff",
110
- surface: "#1a1a1a",
111
- subtle: "#999999",
112
- border: "#333333",
113
- sidebar: "#0d0d0d",
114
- strong: "#cccccc"
115
- };
116
- return {
117
- background: mono.bg,
118
- foreground: mono.fg,
119
- card: mono.bg,
120
- "card-foreground": mono.fg,
121
- popover: mono.bg,
122
- "popover-foreground": mono.fg,
123
- primary: mono.fg,
124
- "primary-foreground": mono.bg,
125
- secondary: mono.surface,
126
- "secondary-foreground": mono.fg,
127
- muted: mono.surface,
128
- "muted-foreground": mono.subtle,
129
- accent: mono.surface,
130
- "accent-foreground": mono.fg,
131
- destructive: danger,
132
- "destructive-foreground": bestForeground(danger, ["#ffffff", "#000000"]),
133
- border: mono.border,
134
- input: mono.border,
135
- ring: mono.fg,
136
- "chart-1": light ? "#333333" : "#cccccc",
137
- "chart-2": light ? "#4d4d4d" : "#b3b3b3",
138
- "chart-3": light ? "#666666" : "#999999",
139
- "chart-4": light ? "#808080" : "#808080",
140
- "chart-5": light ? "#999999" : "#666666",
141
- "sidebar-background": mono.sidebar,
142
- "sidebar-foreground": mono.fg,
143
- "sidebar-primary": mono.fg,
144
- "sidebar-primary-foreground": mono.bg,
145
- "sidebar-accent": mono.surface,
146
- "sidebar-accent-foreground": mono.fg,
147
- "sidebar-border": mono.border,
148
- "sidebar-ring": mono.border
149
- };
150
- }
151
- var NEUTRAL = {
152
- light: neutral("light"),
153
- dark: neutral("dark")
154
- };
155
- function colorAlias(token) {
156
- if (token.startsWith("chart-")) return null;
157
- if (token === "sidebar-background") return "--color-sidebar";
158
- return `--color-${token}`;
159
- }
160
- function paletteDeclarations(tokens, names, radius, { indent = " ", aliasSource = "neutral-theme.ts" } = {}) {
161
- const value = (token) => {
162
- const hex = tokens[token];
163
- if (hex === void 0) throw new Error(`Missing token: ${token}`);
164
- return hexToHsl(hex);
165
- };
166
- const lines = [`${indent}--radius: ${radius};`];
167
- for (const token of names) {
168
- lines.push(`${indent}--${token}: ${value(token)};`);
169
- }
170
- lines.push(`${indent}--sidebar: ${value("sidebar-background")};`);
171
- lines.push(`${indent}/* Tailwind-facing aliases \u2014 see ${aliasSource} */`);
172
- for (const token of names) {
173
- const alias = colorAlias(token);
174
- if (alias) lines.push(`${indent}${alias}: hsl(var(--${token}));`);
175
- }
176
- lines.push(`${indent}--radius-sm: calc(var(--radius) - 4px);`);
177
- lines.push(`${indent}--radius-md: calc(var(--radius) - 2px);`);
178
- lines.push(`${indent}--radius-lg: var(--radius);`);
179
- lines.push(`${indent}--radius-xl: calc(var(--radius) + 4px);`);
180
- lines.push(`${indent}--radius-2xl: calc(var(--radius) + 8px);`);
181
- return lines.join("\n");
182
- }
183
- function paletteBlock(selector, declarations, indent = "") {
184
- const head = selector.split("\n").map((line) => indent + line).join("\n");
185
- return `${head} {
186
- ${declarations}
187
- ${indent}}
188
- `;
189
- }
190
- function layerBlock(name, rules) {
191
- return `@layer ${name} {
192
- ${rules.join("\n")}}
193
- `;
194
- }
195
- var DARK_ROOT_SELECTOR = ":root:where(.dark)";
196
- function baseLayerPalette(light, dark, indent = " ") {
197
- return layerBlock("base", [
198
- paletteBlock(":root", light, indent),
199
- paletteBlock(DARK_ROOT_SELECTOR, dark, indent)
200
- ]);
201
- }
202
- var PALETTE_GENERATED_HEADER = `/* GENERATED FILE \u2014 do not edit.
203
- * Source: src/lib/neutral-theme.ts \xB7 Regenerate: pnpm gen:themes
204
- *
205
- * The neutral palette: light on :root, dark when the root carries the
206
- * \`.dark\` class. It sits in \`@layer base\`, so any unlayered palette rule
207
- * or a host's own :root overrides wins on layer order alone. Imported by
208
- * tokens.css; every --color-* alias and the radius scale are re-declared
209
- * alongside the tokens they read.
210
- */`;
211
- function renderPaletteCss() {
212
- const declarations = (mode) => paletteDeclarations(NEUTRAL[mode], SEMANTIC_TOKENS, NEUTRAL_RADIUS, {
213
- indent: " "
214
- });
215
- return [
216
- PALETTE_GENERATED_HEADER,
217
- baseLayerPalette(declarations("light"), declarations("dark"))
218
- ].join("\n");
219
- }
1
+ import {
2
+ NEUTRAL,
3
+ NEUTRAL_PALETTE,
4
+ NEUTRAL_RADIUS,
5
+ NEUTRAL_THEME_ID,
6
+ PALETTE_GENERATED_HEADER,
7
+ SEMANTIC_TOKENS,
8
+ baseLayerPalette,
9
+ bestForeground,
10
+ colorAlias,
11
+ contrastRatio,
12
+ hexToHsl,
13
+ hexToRgb,
14
+ layerBlock,
15
+ luminance,
16
+ paletteBlock,
17
+ paletteDeclarations,
18
+ paletteStyle,
19
+ renderPaletteCss
20
+ } from "../chunk-F3DAFAMD.js";
220
21
  export {
221
22
  NEUTRAL,
23
+ NEUTRAL_PALETTE,
222
24
  NEUTRAL_RADIUS,
25
+ NEUTRAL_THEME_ID,
223
26
  PALETTE_GENERATED_HEADER,
224
27
  SEMANTIC_TOKENS,
225
28
  baseLayerPalette,
@@ -232,5 +35,6 @@ export {
232
35
  luminance,
233
36
  paletteBlock,
234
37
  paletteDeclarations,
38
+ paletteStyle,
235
39
  renderPaletteCss
236
40
  };
@@ -4,13 +4,13 @@
4
4
  var _chunkKGFL3VWYcjs = require('../chunk-KGFL3VWY.cjs');
5
5
 
6
6
 
7
- var _chunkPQUSJEXLcjs = require('../chunk-PQUSJEXL.cjs');
8
- require('../chunk-VGTINL5Q.cjs');
9
7
 
10
8
 
9
+ var _chunkWABCLRBRcjs = require('../chunk-WABCLRBR.cjs');
11
10
 
12
11
 
13
- var _chunkWABCLRBRcjs = require('../chunk-WABCLRBR.cjs');
12
+ var _chunkPQUSJEXLcjs = require('../chunk-PQUSJEXL.cjs');
13
+ require('../chunk-VGTINL5Q.cjs');
14
14
  require('../chunk-I6GUOEBO.cjs');
15
15
 
16
16