@splenddev/kreativ-core 0.1.0 → 0.1.2
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 +37 -5
- package/dist/hooks/index.cjs +11 -4
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +2 -12
- package/dist/hooks/index.d.ts +2 -12
- package/dist/hooks/index.js +11 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +215 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +212 -5
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +556 -4
- package/dist/types/index.d.ts +556 -4
- package/dist/utils/index.cjs +204 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +7 -2
- package/dist/utils/index.d.ts +7 -2
- package/dist/utils/index.js +201 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/common-1QyKLdTc.d.cts +0 -557
- package/dist/common-1QyKLdTc.d.ts +0 -557
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,549 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a value that adapts responsively to different screen sizes.
|
|
5
|
+
* It can be provided as:
|
|
6
|
+
* - A single value of type `T` (applies to all breakpoints), or
|
|
7
|
+
* - An object mapping breakpoint names to values, where each key is optional.
|
|
8
|
+
*
|
|
9
|
+
* The object supports:
|
|
10
|
+
* - `base`: the default value applied when no specific breakpoint matches.
|
|
11
|
+
* - Any breakpoint defined by `BaseBreakpoint` (e.g., `"sm"`, `"md"`, `"lg"`, `"xl"`, `"2xl"`).
|
|
12
|
+
*
|
|
13
|
+
* When an object is provided, the component will resolve the most appropriate value
|
|
14
|
+
* based on the current viewport width, falling back to `base` or the next larger breakpoint.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The type of the value (e.g., `string`, `number`, `CSSProperties`).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Single value for all screens
|
|
20
|
+
* const padding: ResponsiveValue<number> = 16;
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Responsive object with breakpoint-specific values
|
|
24
|
+
* const padding: ResponsiveValue<number> = {
|
|
25
|
+
* base: 8,
|
|
26
|
+
* sm: 12,
|
|
27
|
+
* md: 16,
|
|
28
|
+
* lg: 24,
|
|
29
|
+
* };
|
|
30
|
+
*/
|
|
31
|
+
type ResponsiveValue<T, B extends string = BaseBreakpoint> = T | Partial<Record<"base" | B, T>>;
|
|
32
|
+
type ResponsiveStyles = Record<string, CSSProperties>;
|
|
33
|
+
|
|
34
|
+
type FormFieldStatus = "none" | "error" | "success" | "warning";
|
|
35
|
+
type TokenReferenceString = `{${string}}`;
|
|
36
|
+
type Easing = "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
|
37
|
+
/**
|
|
38
|
+
* Predefined size keys for components. `"xs"` is the smallest, `"xl"` the largest.
|
|
39
|
+
* Custom string sizes can also be used via `SizeValue`.
|
|
40
|
+
*/
|
|
41
|
+
type Size = "xs" | "sm" | "md" | "lg" | "xl";
|
|
42
|
+
/**
|
|
43
|
+
* Layout orientation of a group or container.
|
|
44
|
+
*/
|
|
45
|
+
type Orientation = "horizontal" | "vertical";
|
|
46
|
+
/**
|
|
47
|
+
* A size value that can be either a predefined `Size` or any custom string.
|
|
48
|
+
* This allows theme extensions with additional size tokens.
|
|
49
|
+
*/
|
|
50
|
+
type SizeValue = ResponsiveValue<Size | (string & {})>;
|
|
51
|
+
/**
|
|
52
|
+
* Base visual variants supported by most components.
|
|
53
|
+
* - `"solid"`: filled background with high contrast.
|
|
54
|
+
* - `"outline"`: bordered with transparent background.
|
|
55
|
+
* - `"ghost"`: minimal, often transparent with subtle hover.
|
|
56
|
+
* - `"soft"`: subtle background with less contrast than `solid`.
|
|
57
|
+
*/
|
|
58
|
+
type BaseVariant = "solid" | "outline" | "ghost" | "soft";
|
|
59
|
+
/**
|
|
60
|
+
* Default responsive breakpoints supported by the design system.
|
|
61
|
+
* These breakpoints are used to define responsive behavior across different screen sizes.
|
|
62
|
+
* The order from smallest to largest is: `"sm"`, `"md"`, `"lg"`, `"xl"`, `"2xl"`.
|
|
63
|
+
*
|
|
64
|
+
* - `"sm"`: small screens (e.g., mobile phones)
|
|
65
|
+
* - `"md"`: medium screens (e.g., tablets)
|
|
66
|
+
* - `"lg"`: large screens (e.g., desktops)
|
|
67
|
+
* - `"xl"`: extra large screens (e.g., large desktops)
|
|
68
|
+
* - `"2xl"`: 2x extra large screens (e.g., ultra-wide displays)
|
|
69
|
+
*/
|
|
70
|
+
type BaseBreakpoint = "sm" | "md" | "lg" | "xl" | "2xl";
|
|
71
|
+
/**
|
|
72
|
+
* Base color palette keys. These map to theme-defined colors.
|
|
73
|
+
* - `"brand"`: primary brand color.
|
|
74
|
+
* - `"destructive"`: for errors or dangerous actions.
|
|
75
|
+
* - `"success"`: for positive outcomes.
|
|
76
|
+
* - `"warning"`: for cautionary states.
|
|
77
|
+
* - `"info"`: for informational highlights.
|
|
78
|
+
* - `"neutral"`: default or muted color.
|
|
79
|
+
* - `"white"`: white color (useful on dark backgrounds).
|
|
80
|
+
* - `"inherit"`: inherits the parent's color.
|
|
81
|
+
*/
|
|
82
|
+
type BaseColor = "brand" | "destructive" | "success" | "warning" | "info" | "neutral" | "white" | "inherit";
|
|
83
|
+
/**
|
|
84
|
+
* Generic variant type; currently aliased to `BaseVariant`.
|
|
85
|
+
* Can be extended in the future.
|
|
86
|
+
*/
|
|
87
|
+
type Variant = BaseVariant;
|
|
88
|
+
/**
|
|
89
|
+
* Interface for components that accept a CSS class name for styling customisation.
|
|
90
|
+
*/
|
|
91
|
+
interface Styleable {
|
|
92
|
+
/** Additional CSS class names to apply. */
|
|
93
|
+
className?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Animation types for theme-based transitions.
|
|
97
|
+
* - `"none"`: no animation.
|
|
98
|
+
* - `"fade"`: opacity transition.
|
|
99
|
+
* - `"rotate"`: rotation animation.
|
|
100
|
+
* - `"slide"`: sliding motion.
|
|
101
|
+
* - `"scale"`: scaling effect.
|
|
102
|
+
*/
|
|
103
|
+
type ThemeAnimation = "none" | "fade" | "rotate" | "slide" | "scale";
|
|
104
|
+
/**
|
|
105
|
+
* Recursively makes all properties of `T` optional.
|
|
106
|
+
* Useful for partial theme overrides or deep configuration objects.
|
|
107
|
+
*/
|
|
108
|
+
type DeepPartial<T> = {
|
|
109
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Extends `CSSProperties` to allow custom CSS variables (e.g., `--my-var`).
|
|
113
|
+
*/
|
|
114
|
+
type CSSPropertiesWithVars = CSSProperties & {
|
|
115
|
+
[key: `--${string}`]: string | number | undefined;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Represents the result of a validity check.
|
|
119
|
+
* - `invalid`: `true` if the value is invalid.
|
|
120
|
+
* - `message`: optional error message to display.
|
|
121
|
+
*/
|
|
122
|
+
type ReportedValidity = {
|
|
123
|
+
invalid: boolean;
|
|
124
|
+
message?: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Base properties shared by most components.
|
|
128
|
+
* Includes styling, children, and unstyled mode.
|
|
129
|
+
*/
|
|
130
|
+
interface BaseProps {
|
|
131
|
+
/**
|
|
132
|
+
* Additional CSS classes to merge with the component's default styles.
|
|
133
|
+
*/
|
|
134
|
+
className?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Inline styles to apply to the root element.
|
|
137
|
+
* These take precedence over className styles.
|
|
138
|
+
*/
|
|
139
|
+
style?: CSSProperties;
|
|
140
|
+
/**
|
|
141
|
+
* The content to render inside the component.
|
|
142
|
+
*/
|
|
143
|
+
children?: ReactNode;
|
|
144
|
+
/**
|
|
145
|
+
* When `true`, removes all default styling (useful for custom styling from scratch).
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
unstyled?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Props for components that support a `size` property.
|
|
152
|
+
*/
|
|
153
|
+
interface SizeProps {
|
|
154
|
+
/**
|
|
155
|
+
* The size of the component. Can be a predefined size or a custom string.
|
|
156
|
+
* @default "md"
|
|
157
|
+
*/
|
|
158
|
+
size?: SizeValue;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Props for components that support a `color` property.
|
|
162
|
+
* @template Color - The color type (defaults to `string`).
|
|
163
|
+
*/
|
|
164
|
+
interface ColorProps<Color extends string = string> {
|
|
165
|
+
/**
|
|
166
|
+
* The color of the component. Typically matches the theme's color palette.
|
|
167
|
+
*/
|
|
168
|
+
color?: Color;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Props for components that support a `variant` property.
|
|
172
|
+
* @template Variant - The variant type (defaults to `string`).
|
|
173
|
+
*/
|
|
174
|
+
interface VariantProps<Variant extends string = string> {
|
|
175
|
+
/**
|
|
176
|
+
* The visual style variant of the component.
|
|
177
|
+
* Common variants: `"solid"`, `"outline"`, `"ghost"`, `"soft"`.
|
|
178
|
+
*/
|
|
179
|
+
variant?: Variant;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Props for components that apply typography styles from the theme.
|
|
183
|
+
*/
|
|
184
|
+
interface TypographyProps {
|
|
185
|
+
/**
|
|
186
|
+
* The typography style to apply, matching a key defined in the theme's typography configuration.
|
|
187
|
+
* For example, `"heading1"`, `"bodyLarge"`, etc.
|
|
188
|
+
*/
|
|
189
|
+
typography?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Props for components that can be disabled.
|
|
193
|
+
*/
|
|
194
|
+
interface DisabledProps {
|
|
195
|
+
/**
|
|
196
|
+
* When `true`, the component is non-interactive and visually dimmed.
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
disabled?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Props for components that can display a loading state.
|
|
203
|
+
*/
|
|
204
|
+
interface LoadingProps {
|
|
205
|
+
/**
|
|
206
|
+
* When `true`, shows a loading indicator and blocks user interaction.
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
isLoading?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Props for components that can expand to full width.
|
|
213
|
+
*/
|
|
214
|
+
interface FullWidthProps {
|
|
215
|
+
/**
|
|
216
|
+
* When `true`, the component spans the full available width of its container.
|
|
217
|
+
* @default false
|
|
218
|
+
*/
|
|
219
|
+
fullWidth?: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Props for components that support clearing their current value.
|
|
223
|
+
*/
|
|
224
|
+
interface ClearableProps {
|
|
225
|
+
/**
|
|
226
|
+
* When `true`, a clear button or action is shown to reset the value.
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
clearable?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Callback invoked when the value is cleared (e.g., click on clear button).
|
|
232
|
+
*/
|
|
233
|
+
onClear?: () => void;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Props for enabling undo/redo functionality on the input value.
|
|
237
|
+
*/
|
|
238
|
+
interface UndoRedoProps {
|
|
239
|
+
/**
|
|
240
|
+
* Callback invoked when an undo action is performed.
|
|
241
|
+
* The new value is passed to allow external state synchronisation.
|
|
242
|
+
*/
|
|
243
|
+
onUndo?: (value: string | number | undefined) => void;
|
|
244
|
+
/**
|
|
245
|
+
* Callback invoked when a redo action is performed.
|
|
246
|
+
* The new value is passed to allow external state synchronisation.
|
|
247
|
+
*/
|
|
248
|
+
onRedo?: (value: string | number | undefined) => void;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Props for components that can display visual feedback states.
|
|
252
|
+
* Typically used for form fields or interactive elements.
|
|
253
|
+
*/
|
|
254
|
+
interface StateProps {
|
|
255
|
+
/**
|
|
256
|
+
* When `true`, applies an error style (e.g., red border, error icon).
|
|
257
|
+
* @default false
|
|
258
|
+
*/
|
|
259
|
+
error?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* When `true`, applies a success style (e.g., green border, checkmark).
|
|
262
|
+
* @default false
|
|
263
|
+
*/
|
|
264
|
+
success?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* When `true`, applies a warning style (e.g., yellow/orange border, warning icon).
|
|
267
|
+
* @default false
|
|
268
|
+
*/
|
|
269
|
+
warning?: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* When `true`, automatically scrolls the input into view when it
|
|
272
|
+
* transitions into an error state.
|
|
273
|
+
* @default false
|
|
274
|
+
*/
|
|
275
|
+
scrollIntoViewOnError?: boolean;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Props for components that support a status indicator.
|
|
279
|
+
* Typically used with `FormFieldStatus` from the design system.
|
|
280
|
+
*/
|
|
281
|
+
interface StatusProps {
|
|
282
|
+
/**
|
|
283
|
+
* The status of the component. Can be `"success"`, `"error"`, `"warning"`, or `"none"`.
|
|
284
|
+
* This influences the visual appearance (color, icon, etc.).
|
|
285
|
+
*/
|
|
286
|
+
status?: FormFieldStatus;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Props for components that arrange children in a group with a specific layout direction.
|
|
290
|
+
*/
|
|
291
|
+
interface OrientationProps {
|
|
292
|
+
/**
|
|
293
|
+
* The layout direction of the group.
|
|
294
|
+
* - `"horizontal"`: children are placed side by side.
|
|
295
|
+
* - `"vertical"`: children are stacked vertically.
|
|
296
|
+
* @default "horizontal"
|
|
297
|
+
*/
|
|
298
|
+
orientation?: Orientation;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Generic props for controlling a value with both controlled and uncontrolled modes.
|
|
302
|
+
* Allows customising the property names for value, default value, and onChange.
|
|
303
|
+
*
|
|
304
|
+
* @template T - The type of the value.
|
|
305
|
+
* @template TValueProp - The name of the controlled value property (default: `"value"`).
|
|
306
|
+
* @template TDefaultProp - The name of the uncontrolled default property (default: `"defaultValue"`).
|
|
307
|
+
* @template TOnChangeProp - The name of the change callback property (default: `"onValueChange"`).
|
|
308
|
+
*/
|
|
309
|
+
type ControlledProps<T, TValueProp extends string = "value", TDefaultProp extends string = "defaultValue", TOnChangeProp extends string = "onValueChange", TIsRequired extends boolean = false> = TIsRequired extends true ? {
|
|
310
|
+
[K in TValueProp]: T;
|
|
311
|
+
} & {
|
|
312
|
+
[K in TDefaultProp]: T;
|
|
313
|
+
} & {
|
|
314
|
+
[K in TOnChangeProp]: (value: T) => void;
|
|
315
|
+
} : {
|
|
316
|
+
[K in TValueProp]?: T;
|
|
317
|
+
} & {
|
|
318
|
+
[K in TDefaultProp]?: T;
|
|
319
|
+
} & {
|
|
320
|
+
[K in TOnChangeProp]?: (value: T) => void;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Props for a controlled or uncontrolled stateful component.
|
|
324
|
+
*
|
|
325
|
+
* @typeParam T - The state value type.
|
|
326
|
+
* @typeParam TStateProp - The controlled state prop name.
|
|
327
|
+
* @typeParam TSetStateProp - The state change callback prop name.
|
|
328
|
+
*/
|
|
329
|
+
/**
|
|
330
|
+
* Defines optional state control props for a component: a state value and its setter.
|
|
331
|
+
*
|
|
332
|
+
* This is useful for components that can be used in both controlled and uncontrolled modes,
|
|
333
|
+
* where the caller may provide state and setter optionally.
|
|
334
|
+
*
|
|
335
|
+
* @template T - The type of the state value (default: `boolean`).
|
|
336
|
+
* @template TStateProp - The name of the state prop (default: `"state"`).
|
|
337
|
+
* @template TSetStateProp - The name of the setter prop (default: `"setState"` based on `TStateProp`).
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* interface MyComponentProps extends StateControlProps<string, "value", "onValueChange"> {
|
|
342
|
+
* label: string;
|
|
343
|
+
* }
|
|
344
|
+
* // Result:
|
|
345
|
+
* // {
|
|
346
|
+
* // label: string;
|
|
347
|
+
* // value?: string;
|
|
348
|
+
* // onValueChange?: (value: string) => void;
|
|
349
|
+
* // }
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* // Default prop names: "state" and "setState"
|
|
355
|
+
* type Props = StateControlProps<number>;
|
|
356
|
+
* // => { state?: number; setState?: (value: number) => void }
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
type StateControlProps<T = boolean, TStateProp extends string = "state", TSetStateProp extends string = `set${Capitalize<TStateProp>}`> = {
|
|
360
|
+
[K in TStateProp]?: T;
|
|
361
|
+
} & {
|
|
362
|
+
[K in TSetStateProp]?: (value: T) => void;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Defines **required** state control props for a component: a mandatory state value and its setter.
|
|
366
|
+
*
|
|
367
|
+
* Use this when your component **must** be controlled externally – the caller is forced to provide
|
|
368
|
+
* the state and the setter function.
|
|
369
|
+
*
|
|
370
|
+
* @template T - The type of the state value (default: `boolean`).
|
|
371
|
+
* @template TStateProp - The name of the state prop (default: `"state"`).
|
|
372
|
+
* @template TSetStateProp - The name of the setter prop (default: `"setState"` based on `TStateProp`).
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* interface ControlledInputProps extends RequiredStateControlProps<string, "value", "onChange"> {
|
|
377
|
+
* placeholder?: string;
|
|
378
|
+
* }
|
|
379
|
+
* // Result:
|
|
380
|
+
* // {
|
|
381
|
+
* // placeholder?: string;
|
|
382
|
+
* // value: string;
|
|
383
|
+
* // onChange: (value: string) => void;
|
|
384
|
+
* // }
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* // Default prop names: "state" and "setState"
|
|
390
|
+
* type Props = RequiredStateControlProps<number>;
|
|
391
|
+
* // => { state: number; setState: (value: number) => void }
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
type RequiredStateControlProps<T = boolean, TStateProp extends string = "state", TSetStateProp extends string = `set${Capitalize<TStateProp>}`> = {
|
|
395
|
+
[K in TStateProp]: T;
|
|
396
|
+
} & {
|
|
397
|
+
[K in TSetStateProp]: (value: T) => void;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Props for a string-based value component (e.g., input, select, textarea).
|
|
401
|
+
* Uses `value`, `defaultValue`, and `onValueChange` as the controlled props.
|
|
402
|
+
* @template T - The value type (defaults to `string`).
|
|
403
|
+
*/
|
|
404
|
+
type ValueProps<T = string, TIsRequired extends boolean = false> = TIsRequired extends true ? ControlledProps<T, "value", "defaultValue", "onValueChange", true> : ControlledProps<T, "value", "defaultValue", "onValueChange">;
|
|
405
|
+
/**
|
|
406
|
+
* Props for components that can trim whitespace from the value.
|
|
407
|
+
*/
|
|
408
|
+
interface TrimProps {
|
|
409
|
+
/**
|
|
410
|
+
* When `true`, removes leading and trailing whitespace from the value
|
|
411
|
+
* when the value is committed (e.g., on blur or form submit).
|
|
412
|
+
* @default false
|
|
413
|
+
*/
|
|
414
|
+
trim?: boolean;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Props for components that can be embedded inside a parent container.
|
|
418
|
+
* When `embedded`, the component drops its own container styling (borders, radius, focus ring)
|
|
419
|
+
* to blend seamlessly into the parent.
|
|
420
|
+
*/
|
|
421
|
+
interface EmbeddedProps {
|
|
422
|
+
/**
|
|
423
|
+
* When `true`, renders the component without its standalone container styling.
|
|
424
|
+
* Useful for components placed inside a parent that already provides a visual container.
|
|
425
|
+
* @default false
|
|
426
|
+
*/
|
|
427
|
+
embedded?: boolean;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* A validation result: either `true` (valid), `false` (invalid with default message),
|
|
431
|
+
* or a `string` (invalid with custom message).
|
|
432
|
+
*/
|
|
433
|
+
type ValidationResult = boolean | string;
|
|
434
|
+
/**
|
|
435
|
+
* Determines when validation should be triggered.
|
|
436
|
+
* - `"change"`: on every value change.
|
|
437
|
+
* - `"blur"`: when the element loses focus.
|
|
438
|
+
* - `"both"`: on both change and blur.
|
|
439
|
+
*/
|
|
440
|
+
type ValidateOn = "change" | "blur" | "both";
|
|
441
|
+
/**
|
|
442
|
+
* Props for components that support validation of their value.
|
|
443
|
+
* @template T - The type of the value being validated.
|
|
444
|
+
*/
|
|
445
|
+
interface ValidateProps<T = string> {
|
|
446
|
+
/**
|
|
447
|
+
* A validation function that receives the current value and returns:
|
|
448
|
+
* - `true` if valid,
|
|
449
|
+
* - `false` if invalid (default error message),
|
|
450
|
+
* - a `string` if invalid (custom error message).
|
|
451
|
+
*/
|
|
452
|
+
validate?: (value: T) => ValidationResult;
|
|
453
|
+
/**
|
|
454
|
+
* When to run the validation.
|
|
455
|
+
* @default "blur"
|
|
456
|
+
*/
|
|
457
|
+
validateOn?: ValidateOn;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
type TokenValue = string | number;
|
|
461
|
+
interface TokenDefinition<T extends TokenValue = TokenValue> {
|
|
462
|
+
value: T;
|
|
463
|
+
}
|
|
464
|
+
interface TokenGroup {
|
|
465
|
+
[key: string]: TokenDefinition | TokenGroup;
|
|
466
|
+
}
|
|
467
|
+
interface ColorScale {
|
|
468
|
+
[key: string]: TokenDefinition<string>;
|
|
469
|
+
}
|
|
470
|
+
interface ColorTokens {
|
|
471
|
+
[key: string]: ColorScale | TokenDefinition<string>;
|
|
472
|
+
}
|
|
473
|
+
interface SpacingTokens {
|
|
474
|
+
[key: string]: TokenDefinition<string>;
|
|
475
|
+
}
|
|
476
|
+
interface RadiusTokens {
|
|
477
|
+
[key: string]: TokenDefinition<string>;
|
|
478
|
+
}
|
|
479
|
+
interface FontTokens {
|
|
480
|
+
[key: string]: TokenDefinition<string>;
|
|
481
|
+
}
|
|
482
|
+
interface FontSizeTokens {
|
|
483
|
+
[key: string]: TokenDefinition<string>;
|
|
484
|
+
}
|
|
485
|
+
interface FontWeightTokens {
|
|
486
|
+
[key: string]: TokenDefinition<string>;
|
|
487
|
+
}
|
|
488
|
+
interface LineHeightTokens {
|
|
489
|
+
[key: string]: TokenDefinition<string>;
|
|
490
|
+
}
|
|
491
|
+
interface LetterSpacingTokens {
|
|
492
|
+
[key: string]: TokenDefinition<string>;
|
|
493
|
+
}
|
|
494
|
+
interface ShadowTokens {
|
|
495
|
+
[key: string]: TokenDefinition<string>;
|
|
496
|
+
}
|
|
497
|
+
interface AnimationTokens {
|
|
498
|
+
[key: string]: TokenDefinition<string>;
|
|
499
|
+
}
|
|
500
|
+
interface BreakpointTokens {
|
|
501
|
+
[key: string]: TokenDefinition<string>;
|
|
502
|
+
}
|
|
503
|
+
interface DesignTokens {
|
|
504
|
+
colors?: ColorTokens;
|
|
505
|
+
spacing?: SpacingTokens;
|
|
506
|
+
radii?: RadiusTokens;
|
|
507
|
+
fonts?: FontTokens;
|
|
508
|
+
fontSizes?: FontSizeTokens;
|
|
509
|
+
fontWeights?: FontWeightTokens;
|
|
510
|
+
lineHeights?: LineHeightTokens;
|
|
511
|
+
letterSpacings?: LetterSpacingTokens;
|
|
512
|
+
shadows?: ShadowTokens;
|
|
513
|
+
animations?: AnimationTokens;
|
|
514
|
+
breakpoints?: BreakpointTokens;
|
|
515
|
+
[key: string]: unknown;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* A value that can differ between light and dark color modes.
|
|
519
|
+
*
|
|
520
|
+
* Locked shape (Sep 2026): explicit discriminated union, not shape
|
|
521
|
+
* inference. `sameForBothModes: true` is a stated author decision,
|
|
522
|
+
* not something inferred from a bare value.
|
|
523
|
+
*/
|
|
524
|
+
type ColorModeValue<T = string> = {
|
|
525
|
+
sameForBothModes: true;
|
|
526
|
+
value: T;
|
|
527
|
+
} | {
|
|
528
|
+
sameForBothModes?: false;
|
|
529
|
+
light: T;
|
|
530
|
+
dark: T;
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* A semantic token — represents a role (e.g. "background", "text")
|
|
534
|
+
* rather than a raw value. Always routes through ColorModeValue,
|
|
535
|
+
* even when mode-invariant (via the sameForBothModes branch).
|
|
536
|
+
*/
|
|
537
|
+
interface SemanticToken<T extends TokenValue = string> {
|
|
538
|
+
value: ColorModeValue<T>;
|
|
539
|
+
}
|
|
540
|
+
interface SemanticColorTokens {
|
|
541
|
+
[key: string]: SemanticToken<string>;
|
|
542
|
+
}
|
|
543
|
+
interface SemanticTokens {
|
|
544
|
+
colors?: SemanticColorTokens;
|
|
545
|
+
[key: string]: unknown;
|
|
546
|
+
}
|
|
4
547
|
|
|
5
548
|
interface SizeToken {
|
|
6
549
|
height?: string;
|
|
@@ -15,6 +558,15 @@ interface SizeToken {
|
|
|
15
558
|
}
|
|
16
559
|
type SizeScale = Record<string, SizeToken>;
|
|
17
560
|
|
|
561
|
+
interface TypographyStyle {
|
|
562
|
+
fontFamily?: string | TokenReferenceString;
|
|
563
|
+
fontSize?: string | TokenReferenceString;
|
|
564
|
+
fontWeight?: string | number | TokenReferenceString;
|
|
565
|
+
lineHeight?: string | TokenReferenceString;
|
|
566
|
+
letterSpacing?: string | TokenReferenceString;
|
|
567
|
+
}
|
|
568
|
+
type Typography = Record<string, TypographyStyle>;
|
|
569
|
+
|
|
18
570
|
/**
|
|
19
571
|
* A single style value inside a StyleObject — either a raw CSS value
|
|
20
572
|
* or (via resolveToken) a "{...}" token reference string.
|
|
@@ -91,4 +643,4 @@ interface ThemeOverride {
|
|
|
91
643
|
}
|
|
92
644
|
type ColorMode = "light" | "dark" | "system";
|
|
93
645
|
|
|
94
|
-
export {
|
|
646
|
+
export type { AnimationTokens, BaseBreakpoint, BaseColor, BaseProps, BaseVariant, BreakpointTokens, CSSPropertiesWithVars, ClearableProps, ColorMode, ColorModeValue, ColorProps, ColorScale, ColorTokens, ControlledProps, CustomRecipes, DeepPartial, DefaultRecipeCollection, DesignTokens, DisabledProps, Easing, EmbeddedProps, FontSizeTokens, FontTokens, FontWeightTokens, FormFieldStatus, FullWidthProps, IntensityMap, LetterSpacingTokens, LineHeightTokens, LoadingProps, Orientation, OrientationProps, RadiusTokens, RecipeCollection, RecipeCompoundVariant, RecipeDefinition, RecipeStyle, RecipeVariant, RecipeVariantValue, ReportedValidity, RequiredStateControlProps, ResolvedTokens, ResponsiveStyles, ResponsiveValue, SemanticColorTokens, SemanticToken, SemanticTokens, ShadowTokens, Size, SizeProps, SizeScale, SizeToken, SizeValue, SpacingTokens, StateControlProps, StateProps, StatusProps, StyleObject, StyleValue, Styleable, Theme, ThemeAnimation, ThemeOverride, ThemeTogglerTransition, ThemeTransition, TokenDefinition, TokenGroup, TokenReferenceString, TokenValue, TrimProps, Typography, TypographyProps, TypographyStyle, UndoRedoProps, ValidateOn, ValidateProps, ValidationResult, ValueProps, Variant, VariantProps };
|