@splenddev/kreativ-ui 0.1.0 → 0.2.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.
- package/README.md +1133 -1365
- package/dist/index.cjs +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +824 -110
- package/dist/index.d.ts +824 -110
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +1 -1
- package/package.json +103 -66
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { CSSProperties, ReactNode, ButtonHTMLAttributes, InputHTMLAttributes, ReactElement, HTMLAttributes, TextareaHTMLAttributes, RefObject, JSX } from 'react';
|
|
3
3
|
import { ClassValue } from 'clsx';
|
|
4
4
|
|
|
5
5
|
type Size = "xs" | "sm" | "md" | "lg" | "xl";
|
|
6
6
|
type Orientation = "horizontal" | "vertical";
|
|
7
7
|
type SizeValue = Size | (string & {});
|
|
8
8
|
type BaseVariant = "solid" | "outline" | "ghost" | "soft";
|
|
9
|
-
type
|
|
9
|
+
type BaseColor = "brand" | "destructive" | "success" | "warning" | "info" | "neutral" | "white";
|
|
10
|
+
type Variant = BaseVariant;
|
|
10
11
|
interface Styleable {
|
|
11
12
|
className?: string;
|
|
12
13
|
}
|
|
@@ -14,99 +15,802 @@ type BaseTransition = "none" | "fade" | "rotate" | "slide" | "scale";
|
|
|
14
15
|
type DeepPartial<T> = {
|
|
15
16
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
interface
|
|
21
|
-
|
|
18
|
+
type CSSPropertiesWithVars = CSSProperties & {
|
|
19
|
+
[key: `--${string}`]: string | number | undefined;
|
|
20
|
+
};
|
|
21
|
+
interface BaseProps {
|
|
22
|
+
/**
|
|
23
|
+
* Additional CSS classes.
|
|
24
|
+
*/
|
|
25
|
+
className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Inline styles.
|
|
28
|
+
*/
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
/**
|
|
31
|
+
* Component content.
|
|
32
|
+
*/
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Removes the component's default styling.
|
|
36
|
+
*/
|
|
37
|
+
unstyled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface SizeProps {
|
|
40
|
+
/**
|
|
41
|
+
* Component size.
|
|
42
|
+
*/
|
|
22
43
|
size?: SizeValue;
|
|
44
|
+
}
|
|
45
|
+
interface ColorProps<Color extends string = string> {
|
|
46
|
+
/**
|
|
47
|
+
* Component color.
|
|
48
|
+
*/
|
|
49
|
+
color?: Color;
|
|
50
|
+
}
|
|
51
|
+
interface VariantProps<Variant extends string = string> {
|
|
52
|
+
/**
|
|
53
|
+
* Visual variant.
|
|
54
|
+
*/
|
|
55
|
+
variant?: Variant;
|
|
56
|
+
}
|
|
57
|
+
interface DisabledProps {
|
|
58
|
+
/**
|
|
59
|
+
* Disables the component.
|
|
60
|
+
*/
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface LoadingProps {
|
|
64
|
+
/**
|
|
65
|
+
* Displays a loading state and prevents interaction.
|
|
66
|
+
*/
|
|
23
67
|
isLoading?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface FullWidthProps {
|
|
70
|
+
/**
|
|
71
|
+
* Makes the component span the available width.
|
|
72
|
+
*/
|
|
73
|
+
fullWidth?: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface ClearableProps {
|
|
76
|
+
/**
|
|
77
|
+
* Allows the current value to be cleared.
|
|
78
|
+
*/
|
|
79
|
+
clearable?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Called when the current value is cleared.
|
|
82
|
+
*/
|
|
83
|
+
onClear?: () => void;
|
|
84
|
+
}
|
|
85
|
+
interface StateProps {
|
|
86
|
+
/**
|
|
87
|
+
* Displays an error state.
|
|
88
|
+
*/
|
|
89
|
+
error?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Displays a success state.
|
|
92
|
+
*/
|
|
93
|
+
success?: boolean;
|
|
94
|
+
}
|
|
95
|
+
interface ValueProps {
|
|
96
|
+
/**
|
|
97
|
+
* Passed value
|
|
98
|
+
*/
|
|
99
|
+
value?: string;
|
|
100
|
+
/**
|
|
101
|
+
* For uncontrolled form control
|
|
102
|
+
*/
|
|
103
|
+
defaultValue?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Called when value is changed
|
|
106
|
+
*
|
|
107
|
+
* @param newValue
|
|
108
|
+
* @returns void
|
|
109
|
+
*/
|
|
110
|
+
onValueChange?: (newValue: string) => void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
type ButtonSize = SizeValue | "icon";
|
|
114
|
+
type ButtonVariant = BaseVariant | "link";
|
|
115
|
+
type ButtonColor = BaseColor;
|
|
116
|
+
interface ButtonRenderProps {
|
|
117
|
+
className?: string;
|
|
118
|
+
style?: React.CSSProperties;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
"aria-busy"?: boolean;
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
}
|
|
123
|
+
interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onDrag" | "onDragStart" | "onDragEnd" | "onAnimationStart" | "onAnimationEnd" | "onAnimationIteration" | "color">, BaseProps, ColorProps<ButtonColor>, VariantProps<ButtonVariant>, DisabledProps, LoadingProps, FullWidthProps {
|
|
124
|
+
size?: ButtonSize;
|
|
24
125
|
leftIcon?: ReactNode;
|
|
25
126
|
rightIcon?: ReactNode;
|
|
26
|
-
|
|
127
|
+
iconOnly?: boolean;
|
|
128
|
+
render?: (props: ButtonRenderProps) => React.ReactElement;
|
|
27
129
|
}
|
|
28
130
|
|
|
29
131
|
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
30
132
|
|
|
31
|
-
|
|
133
|
+
/**
|
|
134
|
+
* A CSS class name or a string containing multiple class names.
|
|
135
|
+
* Typically used to apply styles generated by a styling solution (e.g., CSS Modules, Tailwind, Panda CSS).
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const baseStyle: RecipeStyle = "btn btn-primary";
|
|
140
|
+
* const variantStyle: RecipeStyle = "bg-blue-500 hover:bg-blue-600";
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
type RecipeStyle = string;
|
|
144
|
+
type RecipeVariantValue = string | boolean | number;
|
|
145
|
+
/**
|
|
146
|
+
* A mapping of variant key to a CSS class string.
|
|
147
|
+
* Each variant option maps to a specific style.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const colorVariants: RecipeVariant = {
|
|
152
|
+
* brand: "bg-brand text-white",
|
|
153
|
+
* destructive: "bg-red-500 text-white",
|
|
154
|
+
* outline: "border-2 border-current bg-transparent",
|
|
155
|
+
* };
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
type RecipeVariant = Record<string, RecipeStyle>;
|
|
159
|
+
/**
|
|
160
|
+
* Defines a compound variant: a set of conditions (multiple variant keys)
|
|
161
|
+
* that together produce a specific className.
|
|
162
|
+
*
|
|
163
|
+
* This is useful when you need to apply styles only when two or more
|
|
164
|
+
* variant values are combined (e.g., `variant="solid"` AND `color="brand"`).
|
|
165
|
+
*
|
|
166
|
+
* @property conditions - A record where keys are variant names and values are the variant values.
|
|
167
|
+
* @property className - The style to apply when all conditions match.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const compound: RecipeCompoundVariant = {
|
|
172
|
+
* conditions: { variant: "solid", color: "brand" },
|
|
173
|
+
* className: "shadow-lg bg-brand-dark",
|
|
174
|
+
* };
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
interface RecipeCompoundVariant {
|
|
178
|
+
conditions: Record<string, RecipeVariantValue>;
|
|
179
|
+
className: RecipeStyle;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Defines the complete styling recipe for a single component.
|
|
183
|
+
*
|
|
184
|
+
* A recipe consists of:
|
|
185
|
+
* - **base**: styles applied to every instance of the component.
|
|
186
|
+
* - **variants**: a set of variant groups (e.g., `size`, `color`, `variant`).
|
|
187
|
+
* - **defaultVariants**: which variant values to use when none are provided.
|
|
188
|
+
* - **compoundVariants**: conditional styles that apply when multiple variant conditions are met.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const buttonRecipe: RecipeDefinition = {
|
|
193
|
+
* base: "inline-flex items-center justify-center rounded font-medium transition-colors",
|
|
194
|
+
* variants: {
|
|
195
|
+
* variant: {
|
|
196
|
+
* solid: "bg-brand text-white hover:bg-brand-dark",
|
|
197
|
+
* outline: "border-2 border-brand text-brand hover:bg-brand/10",
|
|
198
|
+
* ghost: "text-brand hover:bg-brand/10",
|
|
199
|
+
* },
|
|
200
|
+
* size: {
|
|
201
|
+
* sm: "px-3 py-1 text-sm",
|
|
202
|
+
* md: "px-4 py-2 text-base",
|
|
203
|
+
* lg: "px-6 py-3 text-lg",
|
|
204
|
+
* },
|
|
205
|
+
* },
|
|
206
|
+
* defaultVariants: {
|
|
207
|
+
* variant: "solid",
|
|
208
|
+
* size: "md",
|
|
209
|
+
* },
|
|
210
|
+
* compoundVariants: [
|
|
211
|
+
* {
|
|
212
|
+
* conditions: { variant: "solid", size: "lg" },
|
|
213
|
+
* className: "shadow-lg",
|
|
214
|
+
* },
|
|
215
|
+
* ],
|
|
216
|
+
* };
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
interface RecipeDefinition {
|
|
220
|
+
/**
|
|
221
|
+
* Base classes applied to every component.
|
|
222
|
+
* These are combined with the variant classes.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* base: "flex items-center gap-2"
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
base?: RecipeStyle;
|
|
230
|
+
/**
|
|
231
|
+
* Variant groups.
|
|
232
|
+
* Each key defines a variant prop name (e.g., `size`, `color`).
|
|
233
|
+
* The value is a map of variant option → CSS classes.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* variants: {
|
|
238
|
+
* size: {
|
|
239
|
+
* sm: "text-sm px-3 py-1",
|
|
240
|
+
* md: "text-base px-4 py-2",
|
|
241
|
+
* },
|
|
242
|
+
* color: {
|
|
243
|
+
* brand: "bg-brand text-white",
|
|
244
|
+
* destructive: "bg-red-500 text-white",
|
|
245
|
+
* },
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
variants?: Record<string, RecipeVariant>;
|
|
250
|
+
/**
|
|
251
|
+
* Variants used when no explicit prop is provided.
|
|
252
|
+
*
|
|
253
|
+
* Supports string, boolean, and numeric values.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* defaultVariants: {
|
|
258
|
+
* size: "md",
|
|
259
|
+
* rounded: false,
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
defaultVariants?: Record<string, RecipeVariantValue>;
|
|
264
|
+
/**
|
|
265
|
+
* Classes applied when multiple variant conditions match.
|
|
266
|
+
* This is useful for special combinations that require additional styling.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* compoundVariants: [
|
|
271
|
+
* {
|
|
272
|
+
* conditions: { variant: "solid", color: "brand" },
|
|
273
|
+
* className: "shadow-lg",
|
|
274
|
+
* },
|
|
275
|
+
* {
|
|
276
|
+
* conditions: { size: "lg", color: "destructive" },
|
|
277
|
+
* className: "uppercase",
|
|
278
|
+
* },
|
|
279
|
+
* ]
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
compoundVariants?: RecipeCompoundVariant[];
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A collection of component recipes, keyed by component name.
|
|
286
|
+
* Each component has its own `RecipeDefinition`.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* const recipes: RecipeCollection = {
|
|
291
|
+
* Button: buttonRecipe,
|
|
292
|
+
* Card: cardRecipe,
|
|
293
|
+
* Input: inputRecipe,
|
|
294
|
+
* };
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
type RecipeCollection = Record<string, RecipeDefinition>;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* The primitive value type for any design token.
|
|
301
|
+
* Can be a CSS value as a string (e.g., "16px", "#fff", "1.5rem")
|
|
302
|
+
* or a unitless number (e.g., 0, 1.5, 4).
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* const fontSize: TokenValue = "1.25rem";
|
|
307
|
+
* const opacity: TokenValue = 0.8;
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
type TokenValue = string | number;
|
|
311
|
+
/**
|
|
312
|
+
* A wrapper around a single design value.
|
|
313
|
+
* @template T - The specific TokenValue type (defaults to string | number).
|
|
314
|
+
*
|
|
315
|
+
* Every leaf in the token tree is a TokenDefinition.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* const blue500: TokenDefinition<string> = { value: "#3b82f6" };
|
|
320
|
+
* const spacing4: TokenDefinition<number> = { value: 4 };
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
interface TokenDefinition<T extends TokenValue = TokenValue> {
|
|
324
|
+
value: T;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* A recursive structure that allows nested token collections.
|
|
328
|
+
* Keys are arbitrary strings and values are either a leaf (TokenDefinition)
|
|
329
|
+
* or another nested group.
|
|
330
|
+
*
|
|
331
|
+
* This enables hierarchical paths like:
|
|
332
|
+
* - colors.blue.500
|
|
333
|
+
* - spacing.4
|
|
334
|
+
* - radii.md
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* const tokens: TokenGroup = {
|
|
339
|
+
* colors: {
|
|
340
|
+
* blue: {
|
|
341
|
+
* 50: { value: "#eff6ff" },
|
|
342
|
+
* 500: { value: "#3b82f6" },
|
|
343
|
+
* },
|
|
344
|
+
* red: { value: "#ef4444" }, // direct leaf
|
|
345
|
+
* },
|
|
346
|
+
* spacing: {
|
|
347
|
+
* sm: { value: "8px" },
|
|
348
|
+
* md: { value: "16px" },
|
|
349
|
+
* },
|
|
350
|
+
* };
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
interface TokenGroup {
|
|
354
|
+
[key: string]: TokenDefinition | TokenGroup;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* A flat collection of color values for a single color family.
|
|
358
|
+
* Keys typically represent shades (e.g., "50", "100", "500", "900").
|
|
359
|
+
* Each value is a TokenDefinition<string> representing a CSS color.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* const blueScale: ColorScale = {
|
|
364
|
+
* 50: { value: "#eff6ff" },
|
|
365
|
+
* 100: { value: "#dbeafe" },
|
|
366
|
+
* 500: { value: "#3b82f6" },
|
|
367
|
+
* 900: { value: "#1e3a8a" },
|
|
368
|
+
* };
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
interface ColorScale {
|
|
372
|
+
[key: string]: TokenDefinition<string>;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* A collection of color scales and/or direct color tokens.
|
|
376
|
+
* Keys are colour family names (e.g., "blue", "gray", "brand").
|
|
377
|
+
* Values can be a full ColorScale or a single TokenDefinition<string>.
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts
|
|
381
|
+
* const colors: ColorTokens = {
|
|
382
|
+
* blue: { 50: { value: "#eff6ff" }, 500: { value: "#3b82f6" } },
|
|
383
|
+
* gray: { 100: { value: "#f3f4f6" }, 900: { value: "#111827" } },
|
|
384
|
+
* brand: { value: "#2563eb" }, // flat single color
|
|
385
|
+
* };
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
32
388
|
interface ColorTokens {
|
|
33
|
-
|
|
34
|
-
brandHover: ColorToken;
|
|
35
|
-
brandFg: ColorToken;
|
|
36
|
-
surface: ColorToken;
|
|
37
|
-
surfaceRaised: ColorToken;
|
|
38
|
-
surfaceSunken: ColorToken;
|
|
39
|
-
border: ColorToken;
|
|
40
|
-
text: ColorToken;
|
|
41
|
-
textMuted: ColorToken;
|
|
42
|
-
danger: ColorToken;
|
|
43
|
-
dangerFg: ColorToken;
|
|
44
|
-
destructive: ColorToken;
|
|
45
|
-
destructiveFg: ColorToken;
|
|
46
|
-
destructiveHover: ColorToken;
|
|
47
|
-
success: ColorToken;
|
|
48
|
-
successFg: ColorToken;
|
|
49
|
-
successHover: ColorToken;
|
|
50
|
-
warning: ColorToken;
|
|
51
|
-
warningFg: ColorToken;
|
|
52
|
-
warningHover: ColorToken;
|
|
53
|
-
info: ColorToken;
|
|
54
|
-
infoFg: ColorToken;
|
|
55
|
-
infoHover: ColorToken;
|
|
56
|
-
}
|
|
57
|
-
interface ThemeTokens {
|
|
58
|
-
colors: ColorTokens;
|
|
59
|
-
radius: string;
|
|
60
|
-
font: string;
|
|
389
|
+
[key: string]: ColorScale | TokenDefinition<string>;
|
|
61
390
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
391
|
+
/**
|
|
392
|
+
* A flat map of spacing tokens.
|
|
393
|
+
* Keys describe the spacing size (e.g., "xs", "md", "lg", "4").
|
|
394
|
+
* Values are TokenDefinition<string> containing a CSS length.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* const spacing: SpacingTokens = {
|
|
399
|
+
* xs: { value: "4px" },
|
|
400
|
+
* md: { value: "16px" },
|
|
401
|
+
* lg: { value: "24px" },
|
|
402
|
+
* };
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
interface SpacingTokens {
|
|
406
|
+
[key: string]: TokenDefinition<string>;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* A flat map of border‑radius tokens.
|
|
410
|
+
* Keys describe the radius size (e.g., "sm", "md", "full").
|
|
411
|
+
* Values are TokenDefinition<string> containing a CSS length.
|
|
412
|
+
*/
|
|
413
|
+
interface RadiusTokens {
|
|
414
|
+
[key: string]: TokenDefinition<string>;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* A flat map of font‑family tokens.
|
|
418
|
+
* Keys describe the font name (e.g., "body", "heading", "mono").
|
|
419
|
+
* Values are TokenDefinition<string> containing a CSS font‑family value.
|
|
420
|
+
*/
|
|
421
|
+
interface FontTokens {
|
|
422
|
+
[key: string]: TokenDefinition<string>;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* A flat map of font‑size tokens.
|
|
426
|
+
* Keys describe the size name (e.g., "xs", "sm", "base", "xl").
|
|
427
|
+
* Values are TokenDefinition<string> containing a CSS font‑size.
|
|
428
|
+
*/
|
|
429
|
+
interface FontSizeTokens {
|
|
430
|
+
[key: string]: TokenDefinition<string>;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A flat map of font‑weight tokens.
|
|
434
|
+
* Keys describe the weight name (e.g., "normal", "medium", "bold").
|
|
435
|
+
* Values are TokenDefinition<string> containing a CSS font‑weight (e.g., "400", "700").
|
|
436
|
+
*/
|
|
437
|
+
interface FontWeightTokens {
|
|
438
|
+
[key: string]: TokenDefinition<string>;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* A flat map of line‑height tokens.
|
|
442
|
+
* Keys describe the line‑height name (e.g., "tight", "normal", "loose").
|
|
443
|
+
* Values are TokenDefinition<string> containing a CSS line‑height.
|
|
444
|
+
*/
|
|
445
|
+
interface LineHeightTokens {
|
|
446
|
+
[key: string]: TokenDefinition<string>;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* A flat map of letter‑spacing tokens.
|
|
450
|
+
* Keys describe the spacing name (e.g., "tight", "wide", "wider").
|
|
451
|
+
* Values are TokenDefinition<string> containing a CSS letter‑spacing.
|
|
452
|
+
*/
|
|
453
|
+
interface LetterSpacingTokens {
|
|
454
|
+
[key: string]: TokenDefinition<string>;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* A flat map of shadow tokens.
|
|
458
|
+
* Keys describe the shadow name (e.g., "sm", "md", "lg", "xl").
|
|
459
|
+
* Values are TokenDefinition<string> containing a CSS box‑shadow value.
|
|
460
|
+
*/
|
|
461
|
+
interface ShadowTokens {
|
|
462
|
+
[key: string]: TokenDefinition<string>;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* A flat map of animation tokens.
|
|
466
|
+
* Keys describe the animation name (e.g., "fade", "slide", "spin").
|
|
467
|
+
* Values are TokenDefinition<string> containing a CSS animation shorthand or keyframes name.
|
|
468
|
+
*/
|
|
469
|
+
interface AnimationTokens {
|
|
470
|
+
[key: string]: TokenDefinition<string>;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Primitive (raw) design tokens.
|
|
474
|
+
* These are mode‑agnostic values that serve as the foundation for semantic tokens.
|
|
475
|
+
* Each category is optional; you may define only the ones you need.
|
|
476
|
+
*
|
|
477
|
+
* The index signature allows custom token groups (e.g., "zIndices", "borders", "opacities")
|
|
478
|
+
* to be added as the design system evolves.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* const tokens: DesignTokens = {
|
|
483
|
+
* colors: {
|
|
484
|
+
* blue: { 50: { value: "#eff6ff" }, 500: { value: "#3b82f6" } },
|
|
485
|
+
* gray: { 100: { value: "#f3f4f6" }, 900: { value: "#111827" } },
|
|
486
|
+
* },
|
|
487
|
+
* spacing: { sm: { value: "8px" }, md: { value: "16px" } },
|
|
488
|
+
* radii: { md: { value: "8px" } },
|
|
489
|
+
* };
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
interface DesignTokens {
|
|
493
|
+
colors?: ColorTokens;
|
|
494
|
+
spacing?: SpacingTokens;
|
|
495
|
+
radii?: RadiusTokens;
|
|
496
|
+
fonts?: FontTokens;
|
|
497
|
+
fontSizes?: FontSizeTokens;
|
|
498
|
+
fontWeights?: FontWeightTokens;
|
|
499
|
+
lineHeights?: LineHeightTokens;
|
|
500
|
+
letterSpacings?: LetterSpacingTokens;
|
|
501
|
+
shadows?: ShadowTokens;
|
|
502
|
+
animations?: AnimationTokens;
|
|
503
|
+
[key: string]: unknown;
|
|
66
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* A value that can differ between light and dark color modes.
|
|
507
|
+
* @template T - The type of the value (defaults to string).
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```ts
|
|
511
|
+
* const brandColor: ColorModeValue = {
|
|
512
|
+
* light: "#3b82f6",
|
|
513
|
+
* dark: "#60a5fa",
|
|
514
|
+
* };
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
type ColorModeValue<T = string> = {
|
|
518
|
+
light: T;
|
|
519
|
+
dark: T;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* A semantic token that can be either a static value or a mode‑dependent value.
|
|
523
|
+
* @template T - The TokenValue type (defaults to string).
|
|
524
|
+
*
|
|
525
|
+
* Semantic tokens represent a role (e.g., "background", "text", "border")
|
|
526
|
+
* rather than a raw value. They are used to create themes that adapt to color mode.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* const surfaceToken: SemanticToken = {
|
|
531
|
+
* value: { light: "#ffffff", dark: "#1e293b" }
|
|
532
|
+
* };
|
|
533
|
+
* const dangerToken: SemanticToken = { value: "#ef4444" }; // static
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
interface SemanticToken<T extends TokenValue = string> {
|
|
537
|
+
value: T | ColorModeValue<T>;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* A flat record of semantic color tokens.
|
|
541
|
+
* Keys describe the color role (e.g., "brand", "surface", "text", "danger").
|
|
542
|
+
* Values are SemanticToken<string> that resolve to a CSS color.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const semanticColors: SemanticColorTokens = {
|
|
547
|
+
* brand: { value: { light: "#3b82f6", dark: "#60a5fa" } },
|
|
548
|
+
* surface: { value: { light: "#ffffff", dark: "#1e293b" } },
|
|
549
|
+
* text: { value: { light: "#111827", dark: "#f1f5f9" } },
|
|
550
|
+
* danger: { value: "#ef4444" }, // static
|
|
551
|
+
* };
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
interface SemanticColorTokens {
|
|
555
|
+
[key: string]: SemanticToken<string>;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Container for all semantic tokens.
|
|
559
|
+
* Currently only `colors` is defined, but the index signature allows
|
|
560
|
+
* future categories like `shadows`, `borders`, or `opacities`.
|
|
561
|
+
*/
|
|
562
|
+
interface SemanticTokens {
|
|
563
|
+
colors?: SemanticColorTokens;
|
|
564
|
+
[key: string]: unknown;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* A set of CSS properties that define a typography style.
|
|
568
|
+
* All properties are optional – you can compose styles incrementally.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```ts
|
|
572
|
+
* const headingStyle: TextStyle = {
|
|
573
|
+
* fontFamily: "Inter, sans-serif",
|
|
574
|
+
* fontSize: "2rem",
|
|
575
|
+
* fontWeight: 700,
|
|
576
|
+
* lineHeight: "1.2",
|
|
577
|
+
* letterSpacing: "-0.02em",
|
|
578
|
+
* };
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
interface TextStyle {
|
|
582
|
+
fontFamily?: string;
|
|
583
|
+
fontSize?: string;
|
|
584
|
+
fontWeight?: string | number;
|
|
585
|
+
lineHeight?: string;
|
|
586
|
+
letterSpacing?: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* A collection of named text styles.
|
|
590
|
+
* Keys are style names (e.g., "heading", "body", "caption", "label").
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* ```ts
|
|
594
|
+
* const textStyles: TextStyles = {
|
|
595
|
+
* heading: { fontSize: "2rem", fontWeight: 700 },
|
|
596
|
+
* body: { fontSize: "1rem", lineHeight: "1.5" },
|
|
597
|
+
* };
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
type TextStyles = Record<string, TextStyle>;
|
|
601
|
+
/**
|
|
602
|
+
* A set of CSS properties that define the dimensions and spacing
|
|
603
|
+
* for a component at a specific size.
|
|
604
|
+
*
|
|
605
|
+
* Used to build size‑variant scales for components (e.g., "sm", "md", "lg").
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```ts
|
|
609
|
+
* const buttonSize: SizeToken = {
|
|
610
|
+
* height: "40px",
|
|
611
|
+
* paddingX: "16px",
|
|
612
|
+
* fontSize: "1rem",
|
|
613
|
+
* iconSize: "20px",
|
|
614
|
+
* radius: "8px",
|
|
615
|
+
* };
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
67
618
|
interface SizeToken {
|
|
68
619
|
height?: string;
|
|
620
|
+
width?: string;
|
|
69
621
|
paddingX?: string;
|
|
622
|
+
paddingY?: string;
|
|
70
623
|
fontSize?: string;
|
|
71
624
|
gap?: string;
|
|
72
625
|
iconSize?: string;
|
|
73
626
|
radius?: string;
|
|
74
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* A collection of named size tokens.
|
|
630
|
+
* Keys are size names (e.g., "sm", "md", "lg", "xl").
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```ts
|
|
634
|
+
* const sizes: SizeScale = {
|
|
635
|
+
* sm: { height: "32px", paddingX: "12px", fontSize: "0.875rem" },
|
|
636
|
+
* md: { height: "40px", paddingX: "16px", fontSize: "1rem" },
|
|
637
|
+
* lg: { height: "48px", paddingX: "24px", fontSize: "1.125rem" },
|
|
638
|
+
* };
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
75
641
|
type SizeScale = Record<string, SizeToken>;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
642
|
+
/**
|
|
643
|
+
* Defines the transition properties for a theme change.
|
|
644
|
+
* `type` refers to a base transition key (imported from BaseTransition).
|
|
645
|
+
* `duration` and `delay` are in milliseconds.
|
|
646
|
+
* `easing` is a CSS easing function.
|
|
647
|
+
*/
|
|
648
|
+
interface ThemeTransition {
|
|
649
|
+
type?: BaseTransition;
|
|
650
|
+
duration?: number;
|
|
651
|
+
delay?: number;
|
|
652
|
+
easing?: string;
|
|
82
653
|
}
|
|
654
|
+
/**
|
|
655
|
+
* The complete theme object provided by the design system.
|
|
656
|
+
* It combines primitive tokens, semantic tokens, text styles,
|
|
657
|
+
* component recipes, a global intensity, legacy tokens, and size scales.
|
|
658
|
+
*
|
|
659
|
+
* @property tokens - Raw design values (colors, spacing, radii, etc.).
|
|
660
|
+
* @property semanticTokens - Role‑based tokens that adapt to color mode.
|
|
661
|
+
* @property textStyles - Reusable typography styles.
|
|
662
|
+
* @property recipes - Component‑specific styles (from RecipeCollection).
|
|
663
|
+
* @property intensity - A global multiplier for visual prominence (e.g., 0.8, 1, 1.2).
|
|
664
|
+
* @property light - Legacy theme tokens for light mode (kept for migration).
|
|
665
|
+
* @property dark - Legacy theme tokens for dark mode (kept for migration).
|
|
666
|
+
* @property sizes - Legacy component size scale (will move to recipes).
|
|
667
|
+
*/
|
|
83
668
|
interface Theme {
|
|
669
|
+
tokens: DesignTokens;
|
|
670
|
+
semanticTokens: SemanticTokens;
|
|
671
|
+
textStyles: TextStyles;
|
|
672
|
+
recipes: RecipeCollection;
|
|
84
673
|
intensity: number;
|
|
85
|
-
light: ThemeTokens;
|
|
86
|
-
dark: ThemeTokens;
|
|
87
674
|
sizes: SizeScale;
|
|
88
|
-
components?: ComponentOverrides;
|
|
89
675
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
676
|
+
/**
|
|
677
|
+
* A flat record of resolved token values, typically CSS‑ready strings.
|
|
678
|
+
* Used internally for injecting variables.
|
|
679
|
+
*/
|
|
680
|
+
type ResolvedTokens = Record<string, string>;
|
|
681
|
+
/**
|
|
682
|
+
* Defines three standard intensity levels.
|
|
683
|
+
* Useful for scaling effects like shadows, saturation, or contrast.
|
|
684
|
+
*/
|
|
685
|
+
interface IntensityMap {
|
|
686
|
+
subtle: number;
|
|
687
|
+
default: number;
|
|
688
|
+
bold: number;
|
|
689
|
+
}
|
|
690
|
+
interface ThemeOverride {
|
|
691
|
+
/**
|
|
692
|
+
* Override primitive design tokens.
|
|
693
|
+
* Allows partial updates to raw values like colors, spacing, radii, etc.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```ts
|
|
697
|
+
* tokens: {
|
|
698
|
+
* colors: { blue: { 500: { value: "#1d4ed8" } } },
|
|
699
|
+
* spacing: { md: { value: "20px" } },
|
|
700
|
+
* }
|
|
701
|
+
* ```
|
|
702
|
+
*/
|
|
703
|
+
tokens?: DeepPartial<DesignTokens>;
|
|
704
|
+
/**
|
|
705
|
+
* Override semantic tokens.
|
|
706
|
+
* Allows partial updates to role‑based tokens (brand, surface, text, etc.)
|
|
707
|
+
* that can adapt to light/dark modes.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```ts
|
|
711
|
+
* semanticTokens: {
|
|
712
|
+
* colors: {
|
|
713
|
+
* brand: { value: { light: "#1d4ed8", dark: "#60a5fa" } },
|
|
714
|
+
* surface: { value: { light: "#ffffff", dark: "#0f172a" } },
|
|
715
|
+
* },
|
|
716
|
+
* }
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
semanticTokens?: DeepPartial<SemanticTokens>;
|
|
720
|
+
/**
|
|
721
|
+
* Override reusable text styles.
|
|
722
|
+
* Allows partial updates to typography presets like heading, body, caption, etc.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* textStyles: {
|
|
727
|
+
* heading: { fontSize: "2.5rem", fontWeight: 800 },
|
|
728
|
+
* body: { fontSize: "1.125rem", lineHeight: "1.75" },
|
|
729
|
+
* }
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
textStyles?: DeepPartial<TextStyles>;
|
|
733
|
+
/**
|
|
734
|
+
* Override component recipes.
|
|
735
|
+
* Allows modifying the base styles, variants, default variants, and compound variants
|
|
736
|
+
* for any component (e.g., Button, Card, Input) without rewriting the entire theme.
|
|
737
|
+
*
|
|
738
|
+
* Each key is a component name, and the value is a deep partial of its RecipeDefinition.
|
|
739
|
+
* This means you can override only specific variants or classes while keeping the rest intact.
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```ts
|
|
743
|
+
* recipes: {
|
|
744
|
+
* Button: {
|
|
745
|
+
* base: "custom-base-class inline-flex items-center",
|
|
746
|
+
* variants: {
|
|
747
|
+
* size: {
|
|
748
|
+
* md: "px-6 py-3 text-lg", // override only the "md" size
|
|
749
|
+
* },
|
|
750
|
+
* },
|
|
751
|
+
* compoundVariants: [
|
|
752
|
+
* {
|
|
753
|
+
* conditions: { variant: "solid", color: "brand" },
|
|
754
|
+
* className: "shadow-lg custom-brand-shadow",
|
|
755
|
+
* },
|
|
756
|
+
* ],
|
|
757
|
+
* },
|
|
758
|
+
* Card: {
|
|
759
|
+
* base: "rounded-xl p-6 bg-surface",
|
|
760
|
+
* },
|
|
761
|
+
* }
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
recipes?: DeepPartial<RecipeCollection>;
|
|
765
|
+
/**
|
|
766
|
+
* Override the global visual intensity.
|
|
767
|
+
* A multiplier for effects like shadows, saturation, or contrast.
|
|
768
|
+
* Typical values: 0.8 (subtle), 1.0 (default), 1.2 (bold).
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* intensity: 1.1 // Slightly bolder than default
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
775
|
+
intensity?: number;
|
|
776
|
+
/**
|
|
777
|
+
* Override legacy component size scales.
|
|
778
|
+
* Allows updating specific size tokens (height, padding, fontSize, etc.)
|
|
779
|
+
* for a given size name (e.g., "sm", "md", "lg").
|
|
780
|
+
*
|
|
781
|
+
* This will eventually be replaced by component‑specific size variants in recipes.
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```ts
|
|
785
|
+
* sizes: {
|
|
786
|
+
* md: { height: "44px", paddingX: "20px" }, // override only "md" size
|
|
787
|
+
* lg: { height: "52px", fontSize: "1.25rem" },
|
|
788
|
+
* }
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
93
791
|
sizes?: Record<string, Partial<SizeToken>>;
|
|
94
|
-
|
|
95
|
-
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Represents the active color mode.
|
|
795
|
+
* - "light": force light mode.
|
|
796
|
+
* - "dark": force dark mode.
|
|
797
|
+
* - "system": follow the user's operating system preference.
|
|
798
|
+
*/
|
|
96
799
|
type ColorMode = "light" | "dark" | "system";
|
|
97
800
|
|
|
801
|
+
type ThemeTogglerVariant = Exclude<ButtonVariant, 'link'>;
|
|
98
802
|
type ThemeTogglerDisplay = "buttons" | "cycle";
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
interface ThemeTogglerProps {
|
|
803
|
+
type ThemeTogglerColor = Exclude<BaseColor, "destructive" | "warning" | "success" | "white" | "info">;
|
|
804
|
+
interface ThemeTogglerProps extends Omit<BaseProps, "children"> {
|
|
102
805
|
variant?: ThemeTogglerVariant;
|
|
103
806
|
activeVariant?: ThemeTogglerVariant;
|
|
104
|
-
|
|
807
|
+
color?: ButtonProps["color"];
|
|
808
|
+
activeColor?: ButtonProps["color"];
|
|
809
|
+
size?: ButtonProps["size"];
|
|
105
810
|
iconOnly?: boolean;
|
|
106
811
|
allowSystem?: boolean;
|
|
107
812
|
orientation?: Orientation;
|
|
108
813
|
rounded?: boolean;
|
|
109
|
-
unstyled?: boolean;
|
|
110
814
|
labels?: {
|
|
111
815
|
light?: string;
|
|
112
816
|
dark?: string;
|
|
@@ -117,37 +821,23 @@ interface ThemeTogglerProps {
|
|
|
117
821
|
dark?: React.ReactNode;
|
|
118
822
|
system?: React.ReactNode;
|
|
119
823
|
};
|
|
120
|
-
|
|
121
|
-
transition?: {
|
|
122
|
-
type: BaseTransition;
|
|
123
|
-
duration?: number;
|
|
124
|
-
delay?: number;
|
|
125
|
-
easing?: string;
|
|
126
|
-
};
|
|
824
|
+
buttonProps?: Omit<ButtonProps, "variant" | "color" | "size" | "children">;
|
|
127
825
|
display?: ThemeTogglerDisplay;
|
|
128
|
-
|
|
826
|
+
transition?: ThemeTransition;
|
|
129
827
|
}
|
|
130
828
|
|
|
131
|
-
declare function ThemeToggler({ variant, activeVariant, size, iconOnly, allowSystem, orientation, rounded, unstyled, labels, icons, className, buttonProps, display, transition, }: ThemeTogglerProps): react.JSX.Element;
|
|
829
|
+
declare function ThemeToggler({ variant, activeVariant, color, activeColor, size, iconOnly, allowSystem, orientation, rounded, unstyled, labels, icons, className, buttonProps, display, transition, }: ThemeTogglerProps): react.JSX.Element;
|
|
132
830
|
|
|
133
831
|
type InputVariant = "outline" | "filled" | "ghost";
|
|
134
832
|
type InputSize = "sm" | "md" | "lg";
|
|
135
833
|
type InputKind = "text" | "email" | "tel" | "url" | "search" | "numeric" | "password-current" | "password-new" | "number" | "date" | "time" | "datetime-local" | "month" | "week";
|
|
136
|
-
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size">,
|
|
137
|
-
variant?: InputVariant;
|
|
834
|
+
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size">, BaseProps, SizeProps, VariantProps<InputVariant>, DisabledProps, LoadingProps, FullWidthProps, ClearableProps, StateProps {
|
|
138
835
|
inputClassName?: string;
|
|
139
|
-
|
|
140
|
-
error?: boolean;
|
|
141
|
-
success?: boolean;
|
|
836
|
+
kind?: InputKind;
|
|
142
837
|
rounded?: boolean;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
fullWidth?: boolean;
|
|
838
|
+
startIcon?: ReactNode;
|
|
839
|
+
endIcon?: ReactNode;
|
|
146
840
|
hideKindIcon?: boolean;
|
|
147
|
-
isLoading?: boolean;
|
|
148
|
-
clearable?: boolean;
|
|
149
|
-
onClear?: () => void;
|
|
150
|
-
kind?: InputKind;
|
|
151
841
|
}
|
|
152
842
|
type InputKindDefaults = Record<InputKind, {
|
|
153
843
|
type?: string;
|
|
@@ -164,14 +854,13 @@ declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttri
|
|
|
164
854
|
|
|
165
855
|
declare const inputKindDefaults: InputKindDefaults;
|
|
166
856
|
|
|
167
|
-
interface FormFieldProps {
|
|
168
|
-
children: ReactNode;
|
|
857
|
+
interface FormFieldProps extends Omit<BaseProps, "unstyled"> {
|
|
169
858
|
id?: string;
|
|
170
859
|
error?: string;
|
|
171
860
|
required?: boolean;
|
|
172
861
|
}
|
|
173
862
|
|
|
174
|
-
declare function FormField({ id: externalId, error, required, children, }: FormFieldProps): react.JSX.Element;
|
|
863
|
+
declare function FormField({ id: externalId, error, required, className, children, }: FormFieldProps): react.JSX.Element;
|
|
175
864
|
declare namespace FormField {
|
|
176
865
|
var Label: typeof FormFieldLabel;
|
|
177
866
|
var Control: typeof FormFieldControl;
|
|
@@ -179,7 +868,7 @@ declare namespace FormField {
|
|
|
179
868
|
var Message: typeof FormFieldMessage;
|
|
180
869
|
}
|
|
181
870
|
|
|
182
|
-
declare function FormFieldLabel({ children, className }: {
|
|
871
|
+
declare function FormFieldLabel({ children, className, }: {
|
|
183
872
|
children: ReactNode;
|
|
184
873
|
className?: string;
|
|
185
874
|
}): react.JSX.Element;
|
|
@@ -188,14 +877,14 @@ declare function FormFieldDescription({ children, }: {
|
|
|
188
877
|
children: React.ReactNode;
|
|
189
878
|
}): react.JSX.Element;
|
|
190
879
|
|
|
191
|
-
declare function FormFieldMessage({ children
|
|
880
|
+
declare function FormFieldMessage({ children }: {
|
|
192
881
|
children: React.ReactNode;
|
|
193
882
|
}): react.JSX.Element;
|
|
194
883
|
|
|
195
884
|
type FormFieldControlProps<T = Record<string, unknown>> = {
|
|
196
885
|
children: ReactElement<T>;
|
|
197
886
|
};
|
|
198
|
-
declare function FormFieldControl<T = Record<string, unknown>>({ children, }: FormFieldControlProps<T>):
|
|
887
|
+
declare function FormFieldControl<T = Record<string, unknown>>({ children, }: FormFieldControlProps<T>): react.JSX.Element;
|
|
199
888
|
|
|
200
889
|
interface SelectProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
201
890
|
className?: string;
|
|
@@ -248,7 +937,7 @@ declare function SelectGroup({ children, className }: SelectGroupProps): react.J
|
|
|
248
937
|
|
|
249
938
|
declare function SelectLabel({ children, className }: SelectLabelProps): react.JSX.Element;
|
|
250
939
|
|
|
251
|
-
declare function Select({ value: valueProp, defaultValue, onValueChange, disabled, required, name, variant, size, className, placeholder, "aria-
|
|
940
|
+
declare function Select({ value: valueProp, defaultValue, onValueChange, disabled, required, name, variant, size, className, placeholder, "aria-describedby": ariaDescribedBy, clearable, error, success, tabIndex, rounded, children, }: SelectProps): react.JSX.Element;
|
|
252
941
|
declare namespace Select {
|
|
253
942
|
var Trigger: react.ForwardRefExoticComponent<SelectTriggerProps & react.RefAttributes<HTMLButtonElement>>;
|
|
254
943
|
var Content: typeof SelectContent;
|
|
@@ -276,11 +965,13 @@ interface SelectContextValue {
|
|
|
276
965
|
triggerId: string;
|
|
277
966
|
triggerRef: React.RefObject<HTMLDivElement | null>;
|
|
278
967
|
contentId: string;
|
|
279
|
-
isInvalid: boolean;
|
|
280
|
-
isSuccess: boolean;
|
|
281
968
|
describedBy?: string;
|
|
282
|
-
required?: boolean;
|
|
283
969
|
selectedLabel?: React.ReactNode;
|
|
970
|
+
labelId: string | undefined;
|
|
971
|
+
tabIndex?: number;
|
|
972
|
+
required?: boolean;
|
|
973
|
+
isInvalid: boolean;
|
|
974
|
+
isSuccess: boolean;
|
|
284
975
|
activeValue: string | undefined;
|
|
285
976
|
setActiveValue: (value: string | undefined) => void;
|
|
286
977
|
items: Map<string, SelectItemMeta>;
|
|
@@ -297,31 +988,39 @@ declare const SelectGroupContext: react.Context<{
|
|
|
297
988
|
setHasLabel: (id: string) => void;
|
|
298
989
|
} | null>;
|
|
299
990
|
|
|
991
|
+
type MarkdownEditorTabs = "write" | "preview";
|
|
992
|
+
interface MarkdownEditorProps extends Omit<TextareaCoreProps, "resize" | "autoResize"> {
|
|
993
|
+
/** Renders the Preview tab. Omit and Preview shows raw text with a dev warning. */
|
|
994
|
+
renderMarkdown?: (value: string) => ReactNode;
|
|
995
|
+
tab?: MarkdownEditorTabs;
|
|
996
|
+
defaultTab?: MarkdownEditorTabs;
|
|
997
|
+
onTabChange?: (tab: MarkdownEditorTabs) => void;
|
|
998
|
+
hint?: ReactNode;
|
|
999
|
+
}
|
|
1000
|
+
|
|
300
1001
|
type TextareaResize = "none" | "both" | "horizontal" | "vertical";
|
|
301
|
-
interface
|
|
302
|
-
value?: string;
|
|
303
|
-
defaultValue?: string;
|
|
304
|
-
className?: string;
|
|
305
|
-
size?: InputSize;
|
|
306
|
-
fullWidth?: boolean;
|
|
1002
|
+
interface TextareaCoreProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "size" | "defaultValue" | "value">, Omit<BaseProps, "unstyled" | "style">, SizeProps, StateProps, VariantProps<InputVariant>, ClearableProps, ValueProps, FullWidthProps {
|
|
307
1003
|
resize?: TextareaResize;
|
|
308
|
-
variant?: InputVariant;
|
|
309
1004
|
autoResize?: boolean;
|
|
310
1005
|
minRows?: number;
|
|
311
1006
|
maxRows?: number;
|
|
312
|
-
clearable?: boolean;
|
|
313
|
-
onClear?: () => void;
|
|
314
1007
|
characterCounter?: boolean;
|
|
315
1008
|
debounceDelay?: number;
|
|
316
1009
|
trimOnBlur?: boolean;
|
|
317
|
-
error?: boolean;
|
|
318
|
-
success?: boolean;
|
|
319
1010
|
onValidate?: (value: string) => boolean | string;
|
|
320
|
-
onValueChange?: (newValue: string) => void;
|
|
321
1011
|
}
|
|
1012
|
+
type TextareaProps = ({
|
|
1013
|
+
allowMarkdown?: false;
|
|
1014
|
+
} & TextareaCoreProps) | ({
|
|
1015
|
+
allowMarkdown: true;
|
|
1016
|
+
} & Omit<TextareaCoreProps, "resize"> & MarkdownEditorProps);
|
|
1017
|
+
|
|
1018
|
+
declare const TextareaCore: react.ForwardRefExoticComponent<TextareaCoreProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
322
1019
|
|
|
323
1020
|
declare const Textarea: react.ForwardRefExoticComponent<TextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
324
1021
|
|
|
1022
|
+
declare const MarkdownEditor: react.ForwardRefExoticComponent<MarkdownEditorProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
1023
|
+
|
|
325
1024
|
interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type" | "checked" | "defaultChecked">, Styleable {
|
|
326
1025
|
checked?: boolean;
|
|
327
1026
|
defaultChecked?: boolean;
|
|
@@ -412,7 +1111,7 @@ interface ComboboxInputProps {
|
|
|
412
1111
|
className?: string;
|
|
413
1112
|
}
|
|
414
1113
|
|
|
415
|
-
declare function ComboboxItem({ value, disabled, children, className }: ComboboxItemProps): react.JSX.Element | null;
|
|
1114
|
+
declare function ComboboxItem({ value, disabled, children, className, }: ComboboxItemProps): react.JSX.Element | null;
|
|
416
1115
|
|
|
417
1116
|
declare function ComboboxContent({ className, children, }: {
|
|
418
1117
|
className?: string;
|
|
@@ -471,7 +1170,7 @@ interface MultiSelectContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
471
1170
|
}
|
|
472
1171
|
declare function MultiSelectContent({ className, children, ...props }: MultiSelectContentProps): react.JSX.Element | null;
|
|
473
1172
|
|
|
474
|
-
declare function MultiSelectItem({ value, disabled, children, className }: MultiSelectItemProps): react.JSX.Element;
|
|
1173
|
+
declare function MultiSelectItem({ value, disabled, children, className, }: MultiSelectItemProps): react.JSX.Element;
|
|
475
1174
|
|
|
476
1175
|
declare function MultiSelect({ value: valueProp, defaultValue, onValueChange, disabled, required, name, variant, size, placeholder, maxVisibleChips, className, children, error, success, rounded, clearable, }: MultiSelectProps): react.JSX.Element;
|
|
477
1176
|
declare namespace MultiSelect {
|
|
@@ -535,14 +1234,16 @@ interface ThemeContextValue {
|
|
|
535
1234
|
resolvedMode: "light" | "dark";
|
|
536
1235
|
setMode: (mode: ColorMode) => void;
|
|
537
1236
|
fallbackSize: string;
|
|
1237
|
+
tokens: ResolvedTokens;
|
|
538
1238
|
}
|
|
539
1239
|
declare const ThemeContext: react.Context<ThemeContextValue | null>;
|
|
540
1240
|
|
|
541
1241
|
declare const defaultSizes: SizeScale;
|
|
1242
|
+
declare const defaultTextStyles: TextStyles;
|
|
1243
|
+
declare const defaultRecipes: RecipeCollection;
|
|
542
1244
|
declare const defaultTheme: Theme;
|
|
543
|
-
declare function resolveTokens(tokens: ThemeTokens): ThemeTokens;
|
|
544
1245
|
|
|
545
|
-
declare function tokensToCssVars(tokens:
|
|
1246
|
+
declare function tokensToCssVars(tokens: ResolvedTokens, mode: "light" | "dark", intensity: number): Record<string, string>;
|
|
546
1247
|
|
|
547
1248
|
declare function useTheme(): ThemeContextValue;
|
|
548
1249
|
|
|
@@ -561,11 +1262,24 @@ interface ResolvedSize {
|
|
|
561
1262
|
style: CSSProperties;
|
|
562
1263
|
iconSize?: string;
|
|
563
1264
|
}
|
|
564
|
-
|
|
1265
|
+
interface UseSizeStyleOptions {
|
|
1266
|
+
includeHeight?: boolean;
|
|
1267
|
+
}
|
|
1268
|
+
declare function useSizeStyle(size: string, iconOnly?: boolean, component?: string, options?: UseSizeStyleOptions): ResolvedSize;
|
|
565
1269
|
|
|
566
1270
|
declare function cn(...inputs: ClassValue[]): string;
|
|
567
1271
|
|
|
568
|
-
|
|
1272
|
+
/**
|
|
1273
|
+
* Converts an RGB color string to a hex color.
|
|
1274
|
+
*
|
|
1275
|
+
* Supports:
|
|
1276
|
+
* - "26 128 230"
|
|
1277
|
+
* - "26, 128, 230"
|
|
1278
|
+
* - "rgb(26, 128, 230)"
|
|
1279
|
+
*
|
|
1280
|
+
* Returns an empty string when the value is not a valid RGB color.
|
|
1281
|
+
*/
|
|
1282
|
+
declare function rgbToHex(value: string): string;
|
|
569
1283
|
declare function hexToRgbString(hex: string): string | null;
|
|
570
1284
|
|
|
571
|
-
export { type BaseTransition, type BaseVariant, Button, type ButtonProps, Checkbox, type CheckboxProps, type ColorMode, type
|
|
1285
|
+
export { type AnimationTokens, type BaseColor, type BaseProps, type BaseTransition, type BaseVariant, Button, type ButtonProps, type CSSPropertiesWithVars, Checkbox, type CheckboxProps, type ClearableProps, type ColorMode, type ColorModeValue, type ColorProps, type ColorScale, type ColorTokens, Combobox, ComboboxContent, ComboboxInput, type ComboboxInputProps, ComboboxItem, type ComboboxItemProps, type ComboboxProps, type DeepPartial, type DesignTokens, type DisabledProps, type FontSizeTokens, type FontTokens, type FontWeightTokens, FormField, FormFieldControl, FormFieldDescription, FormFieldLabel, FormFieldMessage, type FormFieldProps, type FullWidthProps, Input, type InputKind, type InputKindDefaults, type InputProps, type InputSize, type InputVariant, type IntensityMap, type LetterSpacingTokens, type LineHeightTokens, type LoadingProps, MarkdownEditor, type MarkdownEditorProps, type MarkdownEditorTabs, MultiSelect, MultiSelectContent, MultiSelectContext, type MultiSelectContextValue, MultiSelectItem, type MultiSelectItemMeta, type MultiSelectItemProps, type MultiSelectProps, MultiSelectTrigger, type Orientation, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadioSize, type RadiusTokens, type RecipeCollection, type RecipeCompoundVariant, type RecipeDefinition, type RecipeStyle, type RecipeVariant, type RecipeVariantValue, type ResolvedSize, type ResolvedTokens, Select, SelectContent, type SelectContentProps, SelectContext, type SelectContextValue, SelectGroup, SelectGroupContext, type SelectGroupProps, SelectItem, type SelectItemMeta, type SelectItemProps, type SelectLabelProps, type SelectProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, type SemanticColorTokens, type SemanticToken, type SemanticTokens, type ShadowTokens, type Size, type SizeProps, type SizeScale, type SizeToken, type SizeValue, type SpacingTokens, type StateProps, type Styleable, Switch, type SwitchProps, type TextStyle, type TextStyles, Textarea, TextareaCore, type TextareaCoreProps, type TextareaProps, type TextareaResize, type Theme, ThemeContext, type ThemeContextValue, type ThemeOverride, ThemeToggler, type ThemeTogglerColor, type ThemeTogglerDisplay, type ThemeTogglerProps, type ThemeTogglerVariant, type ThemeTransition, type TokenDefinition, type TokenGroup, type TokenValue, UIProvider, type UIProviderProps, type UseSizeStyleOptions, type ValueProps, type Variant, type VariantProps, cn, defaultRecipes, defaultSizes, defaultTextStyles, defaultTheme, hexToRgbString, inputKindDefaults, rgbToHex, tokensToCssVars, useBreakpoint, useMultiSelectContext, useSelectContext, useSizeStyle, useTheme };
|