@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.
@@ -0,0 +1,260 @@
1
+ "use client";
2
+ import {
3
+ Separator
4
+ } from "./chunk-HYTILYE5.js";
5
+ import {
6
+ Label
7
+ } from "./chunk-E2TQMDO7.js";
8
+ import {
9
+ cn
10
+ } from "./chunk-G6SRSWXB.js";
11
+
12
+ // src/primitives/field.tsx
13
+ import { useMemo } from "react";
14
+ import { cva } from "class-variance-authority";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ function FieldSet({ className, ...props }) {
17
+ return /* @__PURE__ */ jsx(
18
+ "fieldset",
19
+ {
20
+ "data-slot": "field-set",
21
+ className: cn(
22
+ "flex flex-col gap-6",
23
+ "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
24
+ className
25
+ ),
26
+ ...props
27
+ }
28
+ );
29
+ }
30
+ function FieldLegend({
31
+ className,
32
+ variant = "legend",
33
+ ...props
34
+ }) {
35
+ return /* @__PURE__ */ jsx(
36
+ "legend",
37
+ {
38
+ "data-slot": "field-legend",
39
+ "data-variant": variant,
40
+ className: cn(
41
+ "mb-3 font-medium",
42
+ "data-[variant=legend]:text-base",
43
+ "data-[variant=label]:text-sm",
44
+ className
45
+ ),
46
+ ...props
47
+ }
48
+ );
49
+ }
50
+ function FieldGroup({ className, ...props }) {
51
+ return /* @__PURE__ */ jsx(
52
+ "div",
53
+ {
54
+ "data-slot": "field-group",
55
+ className: cn(
56
+ "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",
57
+ className
58
+ ),
59
+ ...props
60
+ }
61
+ );
62
+ }
63
+ var fieldVariants = cva(
64
+ "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
65
+ {
66
+ variants: {
67
+ orientation: {
68
+ vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
69
+ horizontal: [
70
+ "flex-row items-center",
71
+ "[&>[data-slot=field-label]]:flex-auto",
72
+ "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
73
+ ],
74
+ responsive: [
75
+ "flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto",
76
+ "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
77
+ "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
78
+ ]
79
+ }
80
+ },
81
+ defaultVariants: { orientation: "vertical" }
82
+ }
83
+ );
84
+ function Field({
85
+ className,
86
+ orientation = "vertical",
87
+ ...props
88
+ }) {
89
+ return /* @__PURE__ */ jsx(
90
+ "div",
91
+ {
92
+ role: "group",
93
+ "data-slot": "field",
94
+ "data-orientation": orientation,
95
+ className: cn(fieldVariants({ orientation }), className),
96
+ ...props
97
+ }
98
+ );
99
+ }
100
+ function FieldContent({ className, ...props }) {
101
+ return /* @__PURE__ */ jsx(
102
+ "div",
103
+ {
104
+ "data-slot": "field-content",
105
+ className: cn(
106
+ "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
107
+ className
108
+ ),
109
+ ...props
110
+ }
111
+ );
112
+ }
113
+ function FieldLabel({ className, ...props }) {
114
+ return /* @__PURE__ */ jsx(
115
+ Label,
116
+ {
117
+ "data-slot": "field-label",
118
+ className: cn(
119
+ "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
120
+ "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",
121
+ "has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",
122
+ className
123
+ ),
124
+ ...props
125
+ }
126
+ );
127
+ }
128
+ function FieldTitle({ className, ...props }) {
129
+ return /* @__PURE__ */ jsx(
130
+ "div",
131
+ {
132
+ "data-slot": "field-label",
133
+ className: cn(
134
+ "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
135
+ className
136
+ ),
137
+ ...props
138
+ }
139
+ );
140
+ }
141
+ function FieldDescription({ className, ...props }) {
142
+ return /* @__PURE__ */ jsx(
143
+ "p",
144
+ {
145
+ "data-slot": "field-description",
146
+ className: cn(
147
+ "text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
148
+ "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
149
+ "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
150
+ className
151
+ ),
152
+ ...props
153
+ }
154
+ );
155
+ }
156
+ function FieldSeparator({
157
+ children,
158
+ className,
159
+ ...props
160
+ }) {
161
+ return /* @__PURE__ */ jsxs(
162
+ "div",
163
+ {
164
+ "data-slot": "field-separator",
165
+ "data-content": !!children,
166
+ className: cn(
167
+ "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
168
+ className
169
+ ),
170
+ ...props,
171
+ children: [
172
+ /* @__PURE__ */ jsx(Separator, { className: "absolute inset-0 top-1/2" }),
173
+ children && /* @__PURE__ */ jsx(
174
+ "span",
175
+ {
176
+ className: "relative mx-auto block w-fit bg-background px-2 text-muted-foreground",
177
+ "data-slot": "field-separator-content",
178
+ children
179
+ }
180
+ )
181
+ ]
182
+ }
183
+ );
184
+ }
185
+ function FieldError({
186
+ className,
187
+ children,
188
+ errors,
189
+ ...props
190
+ }) {
191
+ const content = useMemo(() => {
192
+ if (children) return children;
193
+ if (!errors?.length) return null;
194
+ const uniqueErrors = [
195
+ ...new Map(errors.map((error) => [error?.message, error])).values()
196
+ ];
197
+ if (uniqueErrors.length === 1) return uniqueErrors[0]?.message;
198
+ return /* @__PURE__ */ jsx("ul", { className: "ml-4 flex list-disc flex-col gap-1", children: uniqueErrors.map(
199
+ (error, index) => error?.message && /* @__PURE__ */ jsx("li", { children: error.message }, index)
200
+ ) });
201
+ }, [children, errors]);
202
+ if (!content) return null;
203
+ return /* @__PURE__ */ jsx(
204
+ "div",
205
+ {
206
+ role: "alert",
207
+ "data-slot": "field-error",
208
+ className: cn("text-sm font-normal text-destructive", className),
209
+ ...props,
210
+ children: content
211
+ }
212
+ );
213
+ }
214
+ function FormField({
215
+ label,
216
+ htmlFor,
217
+ actions,
218
+ description,
219
+ children,
220
+ className,
221
+ ...props
222
+ }) {
223
+ return /* @__PURE__ */ jsxs("div", { className: cn("space-y-1.5", className), ...props, children: [
224
+ (label || actions) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
225
+ typeof label === "string" ? /* @__PURE__ */ jsx(Label, { htmlFor, children: label }) : label,
226
+ actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: actions })
227
+ ] }),
228
+ children,
229
+ description && /* @__PURE__ */ jsx("p", { className: "text-sm leading-relaxed text-muted-foreground", children: description })
230
+ ] });
231
+ }
232
+ var columnStyles = {
233
+ 1: "grid-cols-1",
234
+ 2: "grid-cols-1 sm:grid-cols-2",
235
+ 3: "grid-cols-1 sm:grid-cols-3"
236
+ };
237
+ function FieldGrid({ columns = 2, gap = "default", className, ...props }) {
238
+ return /* @__PURE__ */ jsx(
239
+ "div",
240
+ {
241
+ className: cn("grid", gap === "default" ? "gap-4" : "gap-8", columnStyles[columns], className),
242
+ ...props
243
+ }
244
+ );
245
+ }
246
+
247
+ export {
248
+ FieldSet,
249
+ FieldLegend,
250
+ FieldGroup,
251
+ Field,
252
+ FieldContent,
253
+ FieldLabel,
254
+ FieldTitle,
255
+ FieldDescription,
256
+ FieldSeparator,
257
+ FieldError,
258
+ FormField,
259
+ FieldGrid
260
+ };
@@ -0,0 +1,273 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
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
+ var NEUTRAL_THEME_ID = "minimal";
158
+ var NEUTRAL_PALETTE = {
159
+ id: NEUTRAL_THEME_ID,
160
+ label: "Neutral",
161
+ description: "Black and white, square corners.",
162
+ radius: NEUTRAL_RADIUS,
163
+ light: NEUTRAL.light,
164
+ dark: NEUTRAL.dark
165
+ };
166
+ function colorAlias(token) {
167
+ if (token.startsWith("chart-")) return null;
168
+ if (token === "sidebar-background") return "--color-sidebar";
169
+ return `--color-${token}`;
170
+ }
171
+ var RADIUS_SCALE = [
172
+ ["--radius-sm", "calc(var(--radius) - 4px)"],
173
+ ["--radius-md", "calc(var(--radius) - 2px)"],
174
+ ["--radius-lg", "var(--radius)"],
175
+ ["--radius-xl", "calc(var(--radius) + 4px)"],
176
+ ["--radius-2xl", "calc(var(--radius) + 8px)"]
177
+ ];
178
+ function paletteDeclarations(tokens, names, radius, { indent = " ", aliasSource = "neutral-theme.ts" } = {}) {
179
+ const value = (token) => {
180
+ const hex = tokens[token];
181
+ if (hex === void 0) throw new Error(`Missing token: ${token}`);
182
+ return hexToHsl(hex);
183
+ };
184
+ const lines = [`${indent}--radius: ${radius};`];
185
+ for (const token of names) {
186
+ lines.push(`${indent}--${token}: ${value(token)};`);
187
+ }
188
+ lines.push(`${indent}--sidebar: ${value("sidebar-background")};`);
189
+ lines.push(`${indent}/* Tailwind-facing aliases \u2014 see ${aliasSource} */`);
190
+ for (const token of names) {
191
+ const alias = colorAlias(token);
192
+ if (alias) lines.push(`${indent}${alias}: hsl(var(--${token}));`);
193
+ }
194
+ for (const [name, scale] of RADIUS_SCALE) {
195
+ lines.push(`${indent}${name}: ${scale};`);
196
+ }
197
+ return lines.join("\n");
198
+ }
199
+ function paletteStyle(tokens, radius, names = SEMANTIC_TOKENS) {
200
+ const value = (token) => {
201
+ const hex = tokens[token];
202
+ if (hex === void 0) throw new Error(`Missing token: ${token}`);
203
+ return hexToHsl(hex);
204
+ };
205
+ const style = {};
206
+ if (radius !== void 0) style["--radius"] = radius;
207
+ for (const token of names) style[`--${token}`] = value(token);
208
+ style["--sidebar"] = value("sidebar-background");
209
+ for (const token of names) {
210
+ const alias = colorAlias(token);
211
+ if (alias) style[alias] = `hsl(var(--${token}))`;
212
+ }
213
+ for (const [name, scale] of RADIUS_SCALE) style[name] = scale;
214
+ return style;
215
+ }
216
+ function paletteBlock(selector, declarations, indent = "") {
217
+ const head = selector.split("\n").map((line) => indent + line).join("\n");
218
+ return `${head} {
219
+ ${declarations}
220
+ ${indent}}
221
+ `;
222
+ }
223
+ function layerBlock(name, rules) {
224
+ return `@layer ${name} {
225
+ ${rules.join("\n")}}
226
+ `;
227
+ }
228
+ var DARK_ROOT_SELECTOR = ":root:where(.dark)";
229
+ function baseLayerPalette(light, dark, indent = " ") {
230
+ return layerBlock("base", [
231
+ paletteBlock(":root", light, indent),
232
+ paletteBlock(DARK_ROOT_SELECTOR, dark, indent)
233
+ ]);
234
+ }
235
+ var PALETTE_GENERATED_HEADER = `/* GENERATED FILE \u2014 do not edit.
236
+ * Source: src/lib/neutral-theme.ts \xB7 Regenerate: pnpm gen:themes
237
+ *
238
+ * The neutral palette: light on :root, dark when the root carries the
239
+ * \`.dark\` class. It sits in \`@layer base\`, so any unlayered palette rule
240
+ * or a host's own :root overrides wins on layer order alone. Imported by
241
+ * tokens.css; every --color-* alias and the radius scale are re-declared
242
+ * alongside the tokens they read.
243
+ */`;
244
+ function renderPaletteCss() {
245
+ const declarations = (mode) => paletteDeclarations(NEUTRAL[mode], SEMANTIC_TOKENS, NEUTRAL_RADIUS, {
246
+ indent: " "
247
+ });
248
+ return [
249
+ PALETTE_GENERATED_HEADER,
250
+ baseLayerPalette(declarations("light"), declarations("dark"))
251
+ ].join("\n");
252
+ }
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+ exports.SEMANTIC_TOKENS = SEMANTIC_TOKENS; exports.hexToRgb = hexToRgb; exports.hexToHsl = hexToHsl; exports.luminance = luminance; exports.contrastRatio = contrastRatio; exports.bestForeground = bestForeground; exports.NEUTRAL_RADIUS = NEUTRAL_RADIUS; exports.NEUTRAL = NEUTRAL; exports.NEUTRAL_THEME_ID = NEUTRAL_THEME_ID; exports.NEUTRAL_PALETTE = NEUTRAL_PALETTE; exports.colorAlias = colorAlias; exports.paletteDeclarations = paletteDeclarations; exports.paletteStyle = paletteStyle; exports.paletteBlock = paletteBlock; exports.layerBlock = layerBlock; exports.baseLayerPalette = baseLayerPalette; exports.PALETTE_GENERATED_HEADER = PALETTE_GENERATED_HEADER; exports.renderPaletteCss = renderPaletteCss;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import {
3
+ toggleVariants
4
+ } from "./chunk-FJLINIC6.js";
5
+ import {
6
+ cn
7
+ } from "./chunk-G6SRSWXB.js";
8
+
9
+ // src/primitives/toggle-group.tsx
10
+ import * as React from "react";
11
+ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var ToggleGroupContext = React.createContext({
14
+ size: "default",
15
+ variant: "default"
16
+ });
17
+ var ToggleGroup = React.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsx(
18
+ ToggleGroupPrimitive.Root,
19
+ {
20
+ ref,
21
+ className: cn("flex items-center justify-center gap-1", className),
22
+ ...props,
23
+ children: /* @__PURE__ */ jsx(ToggleGroupContext.Provider, { value: { variant, size }, children })
24
+ }
25
+ ));
26
+ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
27
+ var ToggleGroupItem = React.forwardRef(({ className, children, variant, size, grow = false, textSize = "inherit", ...props }, ref) => {
28
+ const context = React.useContext(ToggleGroupContext);
29
+ return /* @__PURE__ */ jsx(
30
+ ToggleGroupPrimitive.Item,
31
+ {
32
+ ref,
33
+ className: cn(
34
+ toggleVariants({
35
+ variant: context.variant || variant,
36
+ size: context.size || size
37
+ }),
38
+ grow && "flex-1",
39
+ textSize === "xs" && "text-xs",
40
+ className
41
+ ),
42
+ ...props,
43
+ children
44
+ }
45
+ );
46
+ });
47
+ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
48
+
49
+ export {
50
+ ToggleGroup,
51
+ ToggleGroupItem
52
+ };