@epicbagel/saas-kit 1.3.0 → 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.
@@ -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
  };
@@ -1,255 +1,22 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
  "use client";
3
3
 
4
4
 
5
- var _chunkNQK5ZWC7cjs = require('../chunk-NQK5ZWC7.cjs');
6
5
 
7
6
 
8
- var _chunkIQZLUT2Ycjs = require('../chunk-IQZLUT2Y.cjs');
9
7
 
10
8
 
11
- var _chunkKWLSBTB2cjs = require('../chunk-KWLSBTB2.cjs');
12
9
 
13
- // src/primitives/field.tsx
14
- var _react = require('react');
15
- var _classvarianceauthority = require('class-variance-authority');
16
- var _jsxruntime = require('react/jsx-runtime');
17
- function FieldSet({ className, ...props }) {
18
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
19
- "fieldset",
20
- {
21
- "data-slot": "field-set",
22
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
23
- "flex flex-col gap-6",
24
- "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
25
- className
26
- ),
27
- ...props
28
- }
29
- );
30
- }
31
- function FieldLegend({
32
- className,
33
- variant = "legend",
34
- ...props
35
- }) {
36
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
37
- "legend",
38
- {
39
- "data-slot": "field-legend",
40
- "data-variant": variant,
41
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
42
- "mb-3 font-medium",
43
- "data-[variant=legend]:text-base",
44
- "data-[variant=label]:text-sm",
45
- className
46
- ),
47
- ...props
48
- }
49
- );
50
- }
51
- function FieldGroup({ className, ...props }) {
52
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
53
- "div",
54
- {
55
- "data-slot": "field-group",
56
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
57
- "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
58
- className
59
- ),
60
- ...props
61
- }
62
- );
63
- }
64
- var fieldVariants = _classvarianceauthority.cva.call(void 0,
65
- "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
66
- {
67
- variants: {
68
- orientation: {
69
- vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
70
- horizontal: [
71
- "flex-row items-center",
72
- "[&>[data-slot=field-label]]:flex-auto",
73
- "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
74
- ],
75
- responsive: [
76
- "flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto",
77
- "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
78
- "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
79
- ]
80
- }
81
- },
82
- defaultVariants: { orientation: "vertical" }
83
- }
84
- );
85
- function Field({
86
- className,
87
- orientation = "vertical",
88
- ...props
89
- }) {
90
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
91
- "div",
92
- {
93
- role: "group",
94
- "data-slot": "field",
95
- "data-orientation": orientation,
96
- className: _chunkKWLSBTB2cjs.cn.call(void 0, fieldVariants({ orientation }), className),
97
- ...props
98
- }
99
- );
100
- }
101
- function FieldContent({ className, ...props }) {
102
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
103
- "div",
104
- {
105
- "data-slot": "field-content",
106
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
107
- "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
108
- className
109
- ),
110
- ...props
111
- }
112
- );
113
- }
114
- function FieldLabel({ className, ...props }) {
115
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
116
- _chunkIQZLUT2Ycjs.Label,
117
- {
118
- "data-slot": "field-label",
119
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
120
- "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
121
- "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
122
- "has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",
123
- className
124
- ),
125
- ...props
126
- }
127
- );
128
- }
129
- function FieldTitle({ className, ...props }) {
130
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
131
- "div",
132
- {
133
- "data-slot": "field-label",
134
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
135
- "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
136
- className
137
- ),
138
- ...props
139
- }
140
- );
141
- }
142
- function FieldDescription({ className, ...props }) {
143
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
144
- "p",
145
- {
146
- "data-slot": "field-description",
147
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
148
- "text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
149
- "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
150
- "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
151
- className
152
- ),
153
- ...props
154
- }
155
- );
156
- }
157
- function FieldSeparator({
158
- children,
159
- className,
160
- ...props
161
- }) {
162
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
163
- "div",
164
- {
165
- "data-slot": "field-separator",
166
- "data-content": !!children,
167
- className: _chunkKWLSBTB2cjs.cn.call(void 0,
168
- "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
169
- className
170
- ),
171
- ...props,
172
- children: [
173
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNQK5ZWC7cjs.Separator, { className: "absolute inset-0 top-1/2" }),
174
- children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
175
- "span",
176
- {
177
- className: "relative mx-auto block w-fit bg-background px-2 text-muted-foreground",
178
- "data-slot": "field-separator-content",
179
- children
180
- }
181
- )
182
- ]
183
- }
184
- );
185
- }
186
- function FieldError({
187
- className,
188
- children,
189
- errors,
190
- ...props
191
- }) {
192
- const content = _react.useMemo.call(void 0, () => {
193
- if (children) return children;
194
- if (!_optionalChain([errors, 'optionalAccess', _ => _.length])) return null;
195
- const uniqueErrors = [
196
- ...new Map(errors.map((error) => [_optionalChain([error, 'optionalAccess', _2 => _2.message]), error])).values()
197
- ];
198
- if (uniqueErrors.length === 1) return _optionalChain([uniqueErrors, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.message]);
199
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "ml-4 flex list-disc flex-col gap-1", children: uniqueErrors.map(
200
- (error, index) => _optionalChain([error, 'optionalAccess', _5 => _5.message]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: error.message }, index)
201
- ) });
202
- }, [children, errors]);
203
- if (!content) return null;
204
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
205
- "div",
206
- {
207
- role: "alert",
208
- "data-slot": "field-error",
209
- className: _chunkKWLSBTB2cjs.cn.call(void 0, "text-sm font-normal text-destructive", className),
210
- ...props,
211
- children: content
212
- }
213
- );
214
- }
215
- function FormField({
216
- label,
217
- htmlFor,
218
- actions,
219
- description,
220
- children,
221
- className,
222
- ...props
223
- }) {
224
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkKWLSBTB2cjs.cn.call(void 0, "space-y-1.5", className), ...props, children: [
225
- (label || actions) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
226
- typeof label === "string" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIQZLUT2Ycjs.Label, { htmlFor, children: label }) : label,
227
- actions && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center gap-1", children: actions })
228
- ] }),
229
- children,
230
- description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm leading-relaxed text-muted-foreground", children: description })
231
- ] });
232
- }
233
- var columnStyles = {
234
- 1: "grid-cols-1",
235
- 2: "grid-cols-1 sm:grid-cols-2",
236
- 3: "grid-cols-1 sm:grid-cols-3"
237
- };
238
- function FieldGrid({ columns = 2, gap = "default", className, ...props }) {
239
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
240
- "div",
241
- {
242
- className: _chunkKWLSBTB2cjs.cn.call(void 0, "grid", gap === "default" ? "gap-4" : "gap-8", columnStyles[columns], className),
243
- ...props
244
- }
245
- );
246
- }
247
10
 
248
11
 
249
12
 
250
13
 
251
14
 
252
15
 
16
+ var _chunkZJFYOXSMcjs = require('../chunk-ZJFYOXSM.cjs');
17
+ require('../chunk-NQK5ZWC7.cjs');
18
+ require('../chunk-IQZLUT2Y.cjs');
19
+ require('../chunk-KWLSBTB2.cjs');
253
20
 
254
21
 
255
22
 
@@ -257,4 +24,10 @@ function FieldGrid({ columns = 2, gap = "default", className, ...props }) {
257
24
 
258
25
 
259
26
 
260
- exports.Field = Field; exports.FieldContent = FieldContent; exports.FieldDescription = FieldDescription; exports.FieldError = FieldError; exports.FieldGrid = FieldGrid; exports.FieldGroup = FieldGroup; exports.FieldLabel = FieldLabel; exports.FieldLegend = FieldLegend; exports.FieldSeparator = FieldSeparator; exports.FieldSet = FieldSet; exports.FieldTitle = FieldTitle; exports.FormField = FormField;
27
+
28
+
29
+
30
+
31
+
32
+
33
+ exports.Field = _chunkZJFYOXSMcjs.Field; exports.FieldContent = _chunkZJFYOXSMcjs.FieldContent; exports.FieldDescription = _chunkZJFYOXSMcjs.FieldDescription; exports.FieldError = _chunkZJFYOXSMcjs.FieldError; exports.FieldGrid = _chunkZJFYOXSMcjs.FieldGrid; exports.FieldGroup = _chunkZJFYOXSMcjs.FieldGroup; exports.FieldLabel = _chunkZJFYOXSMcjs.FieldLabel; exports.FieldLegend = _chunkZJFYOXSMcjs.FieldLegend; exports.FieldSeparator = _chunkZJFYOXSMcjs.FieldSeparator; exports.FieldSet = _chunkZJFYOXSMcjs.FieldSet; exports.FieldTitle = _chunkZJFYOXSMcjs.FieldTitle; exports.FormField = _chunkZJFYOXSMcjs.FormField;