@saasflare/ui 1.0.0 → 1.0.1

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,316 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as class_variance_authority_types from 'class-variance-authority/types';
3
+ import * as React from 'react';
4
+ import { VariantProps } from 'class-variance-authority';
5
+
6
+ /**
7
+ * @fileoverview Theme-related types and constants consumed by SaasflareProvider,
8
+ * SaasflareShell, and CustomPaletteInjector.
9
+ * @module packages/ui/types/theme-props
10
+ * @package ui
11
+ *
12
+ * Palette colors live in `styles/palettes.css` (OKLCH) — the single source of
13
+ * truth. To render a swatch in a picker, wrap an element in `data-palette={id}`
14
+ * and paint it with `oklch(var(--primary-l) var(--primary-c) var(--primary-h))`.
15
+ * Do NOT add a hex `color` field here; it will drift from palettes.css.
16
+ */
17
+ /** All 16 available color palette ids and display names. */
18
+ declare const PALETTES: readonly [{
19
+ readonly id: "ocean";
20
+ readonly name: "Ocean";
21
+ }, {
22
+ readonly id: "achromatic";
23
+ readonly name: "Achromatic";
24
+ }, {
25
+ readonly id: "black";
26
+ readonly name: "Black";
27
+ }, {
28
+ readonly id: "ink";
29
+ readonly name: "Ink";
30
+ }, {
31
+ readonly id: "aurora";
32
+ readonly name: "Aurora";
33
+ }, {
34
+ readonly id: "indigo";
35
+ readonly name: "Indigo";
36
+ }, {
37
+ readonly id: "emerald";
38
+ readonly name: "Emerald";
39
+ }, {
40
+ readonly id: "violet";
41
+ readonly name: "Violet";
42
+ }, {
43
+ readonly id: "coral";
44
+ readonly name: "Coral";
45
+ }, {
46
+ readonly id: "stone";
47
+ readonly name: "Stone";
48
+ }, {
49
+ readonly id: "jade";
50
+ readonly name: "Jade";
51
+ }, {
52
+ readonly id: "cobalt";
53
+ readonly name: "Cobalt";
54
+ }, {
55
+ readonly id: "amber";
56
+ readonly name: "Amber";
57
+ }, {
58
+ readonly id: "fuchsia";
59
+ readonly name: "Fuchsia";
60
+ }, {
61
+ readonly id: "honey";
62
+ readonly name: "Honey";
63
+ }, {
64
+ readonly id: "teal";
65
+ readonly name: "Teal";
66
+ }, {
67
+ readonly id: "iris";
68
+ readonly name: "Iris";
69
+ }, {
70
+ readonly id: "ruby";
71
+ readonly name: "Ruby";
72
+ }];
73
+ /** Union of all preset color palette IDs. */
74
+ type PaletteId = (typeof PALETTES)[number]["id"];
75
+ /**
76
+ * Visual surface style variant.
77
+ *
78
+ * The union uses `(string & {})` so app-level custom surfaces (e.g.
79
+ * "neumorphic") registered via a [data-style="…"] selector in the
80
+ * app's globals.css are accepted without a type patch, while preset
81
+ * ids keep their autocomplete.
82
+ */
83
+ type StyleVariant = "flat" | "glass" | (string & {});
84
+ /** All available built-in surface style variants. */
85
+ declare const STYLES: readonly [{
86
+ readonly id: "flat";
87
+ readonly name: "Flat";
88
+ }, {
89
+ readonly id: "glass";
90
+ readonly name: "Glass";
91
+ }];
92
+ /**
93
+ * Radius preset — orthogonal to {@link Surface} (geometry vs. material).
94
+ *
95
+ * Maps to `[data-radius]` selectors in theme.css; each preset sets `--radius`
96
+ * (and at "pill" also overrides the entire `--radius-sm/md/lg/xl` scale so
97
+ * derived values don't drift to ~9995px).
98
+ *
99
+ * Per-component override: pass `radius` on any Saasflare component.
100
+ * Per-theme override: `CustomPalette.radius` wins via inline style.
101
+ */
102
+ type Radius = "sharp" | "soft" | "rounded" | "pill";
103
+ /** All available built-in radius presets. */
104
+ declare const RADII: readonly [{
105
+ readonly id: "sharp";
106
+ readonly name: "Sharp";
107
+ }, {
108
+ readonly id: "soft";
109
+ readonly name: "Soft";
110
+ }, {
111
+ readonly id: "rounded";
112
+ readonly name: "Rounded";
113
+ }, {
114
+ readonly id: "pill";
115
+ readonly name: "Pill";
116
+ }];
117
+ /**
118
+ * Custom color theme — high-level, developer-friendly.
119
+ *
120
+ * Pass any CSS color as `primary` (hex, oklch, rgb, hsl, named color).
121
+ * Hex values are converted to OKLCH internally via {@link hexToOklch};
122
+ * other formats are passed through as the raw `--primary` value.
123
+ *
124
+ * @example
125
+ * <SaasflareProvider
126
+ * palette={{ name: "acme", primary: "#007AFF" }}
127
+ * />
128
+ *
129
+ * @example Escape hatch for full control
130
+ * <SaasflareProvider palette={{
131
+ * name: "acme",
132
+ * primary: "#007AFF",
133
+ * light: { "--background": "#fafafa" },
134
+ * dark: { "--background": "#0a0a0a" },
135
+ * }} />
136
+ */
137
+ interface CustomPalette {
138
+ /** Unique name — written to `data-palette` attribute. */
139
+ name: string;
140
+ /** Primary brand color in any CSS color format. Required. */
141
+ primary: string;
142
+ /**
143
+ * Optional neutral axis override — drives backgrounds, muted, borders,
144
+ * cards, popovers, sidebar (i.e. the entire grey foundation of the UI),
145
+ * not just one accent token. Accepts hex or an explicit hue angle (0-360).
146
+ * Default: tinted from `primary` with a tiny chroma for "brand warmth".
147
+ */
148
+ neutral?: string;
149
+ /** Optional border radius override (any CSS length). */
150
+ radius?: string;
151
+ /** Escape hatch: raw CSS custom property overrides applied in light mode. */
152
+ light?: Record<string, string>;
153
+ /** Escape hatch: raw CSS custom property overrides applied in dark mode. */
154
+ dark?: Record<string, string>;
155
+ }
156
+ /**
157
+ * Accepted values for the `palette` prop (brand colors — distinct from `theme`,
158
+ * which controls light/dark mode and is delegated to next-themes).
159
+ *
160
+ * - omit (undefined) → defers to persisted user preference, then global.css baseline
161
+ * - PaletteId → preset palette via [data-palette] selector
162
+ * - arbitrary string → app-registered [data-palette="…"] in the app's globals.css
163
+ * - CustomPalette → runtime palette via inline CSS custom properties
164
+ *
165
+ * The `(string & {})` branch preserves autocomplete for the 16 preset ids
166
+ * while still permitting arbitrary strings.
167
+ */
168
+ type Palette = PaletteId | (string & {}) | CustomPalette;
169
+ /**
170
+ * Accepted values for the `surface` prop.
171
+ *
172
+ * - omit (undefined) → defers to persisted user preference, then "flat" baseline
173
+ * - StyleVariant → "flat" | "glass" | app-registered custom surface
174
+ */
175
+ type Surface = StyleVariant;
176
+ /**
177
+ * Accepted values for the `radius` prop on SaasflareProvider / Shell.
178
+ *
179
+ * - omit (undefined) → defers to persisted user preference, then "rounded" baseline
180
+ * - Radius → forces [data-radius] on <html>
181
+ */
182
+ type RadiusProp = Radius;
183
+
184
+ /**
185
+ * @fileoverview Base props and resolver hook for Saasflare components.
186
+ * @module packages/ui/providers/use-saasflare-props
187
+ * @package ui
188
+ *
189
+ * Every Saasflare component MUST:
190
+ * 1. Extend SaasflareComponentProps in its props interface
191
+ * 2. Call useSaasflareProps(props) to resolve effective values
192
+ *
193
+ * This ensures consistent precedence:
194
+ * component prop > provider context > hardcoded defaults
195
+ *
196
+ * @example
197
+ * interface CardProps extends SaasflareComponentProps {
198
+ * title: string
199
+ * }
200
+ *
201
+ * function Card({ title, ...sfProps }: CardProps) {
202
+ * const { surface, radius, animated } = useSaasflareProps(sfProps)
203
+ * // surface/radius are guaranteed to be resolved, never undefined
204
+ * }
205
+ */
206
+
207
+ /** Props that every Saasflare component accepts for theme integration. */
208
+ interface SaasflareComponentProps {
209
+ /** Surface style override. Omit to inherit from provider. */
210
+ surface?: StyleVariant;
211
+ /** Radius preset override. Omit to inherit from provider. */
212
+ radius?: Radius;
213
+ /** Animation override. Omit to inherit from provider. */
214
+ animated?: boolean;
215
+ }
216
+ /** Fully resolved theme values — no optionals, no undefined. */
217
+ interface ResolvedSaasflareProps {
218
+ /** Active surface style. */
219
+ surface: StyleVariant;
220
+ /** Active radius preset. */
221
+ radius: Radius;
222
+ /** Whether animations are enabled. */
223
+ animated: boolean;
224
+ /** Active brand palette id (null = global.css baseline). */
225
+ palette: string | null;
226
+ }
227
+ /**
228
+ * Resolves component-level overrides against the provider context.
229
+ *
230
+ * Precedence: component prop > provider context > hardcoded default
231
+ *
232
+ * Safe without a provider — returns sensible defaults.
233
+ */
234
+ declare function useSaasflareProps(props?: SaasflareComponentProps): ResolvedSaasflareProps;
235
+
236
+ declare const INTENTS: readonly ["primary", "neutral", "success", "warning", "danger", "info"];
237
+ type Intent = (typeof INTENTS)[number];
238
+ /**
239
+ * Button variant definitions using the 3-axis system.
240
+ *
241
+ * Axes:
242
+ * variant — visual treatment: solid, soft, outline, ghost, link, glass, shadow
243
+ * intent — color intent via data-intent attribute + CSS tokens
244
+ * size — dimensional: xs, sm, md, lg, xl, icon, icon-xs, icon-sm, icon-lg
245
+ */
246
+ declare const buttonVariants: (props?: ({
247
+ variant?: "link" | "glass" | "soft" | "solid" | "outline" | "ghost" | "shadow" | null | undefined;
248
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
249
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
250
+ /** Framer-motion event overrides that conflict with React HTML events */
251
+ type MotionConflicts = "onDrag" | "onDragStart" | "onDragEnd" | "onAnimationStart" | "onAnimationEnd";
252
+ /**
253
+ * Props for the Saasflare Button component.
254
+ *
255
+ * Extends {@link SaasflareComponentProps} to accept `surface` and `animated`
256
+ * overrides that are resolved against the <SaasflareProvider> context.
257
+ */
258
+ interface ButtonProps extends Omit<React.ComponentProps<"button">, MotionConflicts>, VariantProps<typeof buttonVariants>, SaasflareComponentProps {
259
+ /** Render as child element (Radix Slot pattern) */
260
+ asChild?: boolean;
261
+ /** Semantic color intent */
262
+ intent?: Intent;
263
+ /** Show loading spinner (replaces left icon, keeps text visible) */
264
+ loading?: boolean;
265
+ /** Stretch to full width of container */
266
+ fullWidth?: boolean;
267
+ }
268
+ /**
269
+ * Primary interactive button with motion, loading, and intent support.
270
+ *
271
+ * Resolves `surface` and `animated` via {@link useSaasflareProps} with the
272
+ * precedence: component prop > <SaasflareProvider> context > hardcoded default.
273
+ *
274
+ * When no explicit `variant` is set and the resolved surface is `"glass"`, the
275
+ * button promotes itself to `variant="glass"`. An explicit `variant` prop always
276
+ * wins over the surface-based promotion.
277
+ *
278
+ * @component
279
+ * @layer ui
280
+ *
281
+ * @param {string} variant - Visual treatment: "solid" | "soft" | "outline" | "ghost" | "link" | "glass" | "shadow"
282
+ * @param {string} intent - Color intent: "primary" | "neutral" | "success" | "warning" | "danger" | "info"
283
+ * @param {string} size - Button size: "xs" | "sm" | "md" | "lg" | "xl" | "icon" | "icon-xs" | "icon-sm" | "icon-lg"
284
+ * @param {string} surface - Surface style override: "flat" | "glass" (inherits from provider when omitted)
285
+ * @param {boolean} animated - Gate motion effects (inherits from provider when omitted)
286
+ * @param {boolean} loading - Shows spinner, sets aria-busy, preserves width
287
+ * @param {boolean} fullWidth - Stretches to container width
288
+ * @param {boolean} asChild - Render as child element (Slot pattern)
289
+ *
290
+ * @example
291
+ * // Solid primary (default)
292
+ * <Button>Save Changes</Button>
293
+ *
294
+ * @example
295
+ * // Outline danger
296
+ * <Button variant="outline" intent="danger">Delete Account</Button>
297
+ *
298
+ * @example
299
+ * // Inherits surface from provider — auto-promotes to glass variant
300
+ * <SaasflareProvider surface="glass"><Button>Frosted</Button></SaasflareProvider>
301
+ *
302
+ * @example
303
+ * // Loading state
304
+ * <Button loading>Processing...</Button>
305
+ *
306
+ * @example
307
+ * // Icon button
308
+ * <Button variant="ghost" size="icon"><SettingsIcon /></Button>
309
+ *
310
+ * @example
311
+ * // Legacy API (deprecated but supported)
312
+ * <Button variant="destructive">Delete</Button>
313
+ */
314
+ declare function Button({ className, variant: variantProp, size, intent: intentProp, asChild, loading, fullWidth, surface, animated, disabled, children, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
315
+
316
+ export { Button as B, type CustomPalette as C, type Intent as I, type Palette as P, type RadiusProp as R, type Surface as S, type StyleVariant as a, type Radius as b, type SaasflareComponentProps as c, type ButtonProps as d, PALETTES as e, type PaletteId as f, RADII as g, type ResolvedSaasflareProps as h, STYLES as i, buttonVariants as j, useSaasflareProps as u };