@frontile/forms 0.17.0-beta.24 → 0.17.0-beta.26
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/declarations/components/checkbox-group.d.ts +3 -1
- package/declarations/components/checkbox.d.ts +2 -0
- package/declarations/components/field-types.d.ts +14 -0
- package/declarations/components/field.d.ts +85 -0
- package/declarations/components/form-control.d.ts +1 -0
- package/declarations/components/form.d.ts +244 -8
- package/declarations/components/input.d.ts +5 -0
- package/declarations/components/radio-group.d.ts +1 -1
- package/declarations/components/radio.d.ts +2 -0
- package/declarations/components/select.d.ts +228 -13
- package/declarations/components/switch.d.ts +21 -16
- package/declarations/components/textarea.d.ts +2 -0
- package/declarations/index.d.ts +3 -0
- package/declarations/utils/index.d.ts +1 -0
- package/declarations/utils/nested-data.d.ts +44 -0
- package/declarations/utils/standard-validator.d.ts +151 -0
- package/dist/_app_/components/field-types.js +1 -0
- package/dist/_app_/components/field.js +1 -0
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/checkbox.js +8 -2
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/field-types.js +2 -0
- package/dist/components/field-types.js.map +1 -0
- package/dist/components/field.js +103 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.js +12 -29
- package/dist/components/form.js.map +1 -1
- package/dist/components/input.js +8 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/native-select.js +1 -1
- package/dist/components/radio-group.js +1 -1
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/radio.js +8 -2
- package/dist/components/radio.js.map +1 -1
- package/dist/components/select.js +165 -20
- package/dist/components/select.js.map +1 -1
- package/dist/components/switch.js +5 -2
- package/dist/components/switch.js.map +1 -1
- package/dist/components/textarea.js +8 -2
- package/dist/components/textarea.js.map +1 -1
- package/dist/form-CVuJDJUq.js +726 -0
- package/dist/form-CVuJDJUq.js.map +1 -0
- package/dist/form-Dzyb1-8B.js +623 -0
- package/dist/form-Dzyb1-8B.js.map +1 -0
- package/dist/index-CeaQc-U7.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-BPCpkOf1-B5Lbloj7.js +67 -0
- package/dist/runtime-BPCpkOf1-B5Lbloj7.js.map +1 -0
- package/dist/test-support.js +2 -2
- package/dist/test-support.js.map +1 -1
- package/package.json +10 -7
|
@@ -7,15 +7,35 @@ import { type PopoverSignature, type ContentSignature } from '@frontile/overlays
|
|
|
7
7
|
import { type FormControlSharedArgs } from './form-control';
|
|
8
8
|
interface BaseSelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'flipOptions' | 'middleware' | 'shiftOptions' | 'offsetOptions' | 'strategy' | 'didClose'>, Pick<ListboxSignature<T>['Args'], 'appearance' | 'intent' | 'disabledKeys' | 'allowEmpty' | 'items' | 'onAction'>, Pick<ContentSignature['Args'], 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'transition'>, FormControlSharedArgs {
|
|
9
9
|
}
|
|
10
|
-
interface
|
|
11
|
-
/**
|
|
12
|
-
* Determines the selection mode of the select component.
|
|
13
|
-
* - 'single': Only one item can be selected at a time.
|
|
14
|
-
* @defaultValue 'single'
|
|
15
|
-
*/
|
|
16
|
-
selectionMode?: 'single' | undefined;
|
|
10
|
+
interface BaseSingleSelectArgs<T> extends BaseSelectArgs<T> {
|
|
17
11
|
/**
|
|
18
12
|
* The currently selected key for single selection mode.
|
|
13
|
+
*
|
|
14
|
+
* **Data Flow:**
|
|
15
|
+
* - Pass this to set the initial selection
|
|
16
|
+
* - Update this in your `onSelectionChange` handler to maintain two-way binding
|
|
17
|
+
* - The component calls `onSelectionChange` whenever the user changes the selection
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```gts
|
|
21
|
+
* import { tracked } from '@glimmer/tracking';
|
|
22
|
+
*
|
|
23
|
+
* class MyComponent {
|
|
24
|
+
* @tracked selectedKey = 'option1';
|
|
25
|
+
*
|
|
26
|
+
* handleSelectionChange = (key: string | null) => {
|
|
27
|
+
* this.selectedKey = key; // Update parent state
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* <template>
|
|
31
|
+
* <Select
|
|
32
|
+
* @selectedKey={{this.selectedKey}}
|
|
33
|
+
* @onSelectionChange={{this.handleSelectionChange}}
|
|
34
|
+
* @items={{this.items}}
|
|
35
|
+
* />
|
|
36
|
+
* </template>
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
19
39
|
*/
|
|
20
40
|
selectedKey?: string | null;
|
|
21
41
|
/**
|
|
@@ -24,9 +44,28 @@ interface SingleSelectArgs<T> extends BaseSelectArgs<T> {
|
|
|
24
44
|
selectedKeys?: never;
|
|
25
45
|
/**
|
|
26
46
|
* Callback fired when the selection changes in single mode.
|
|
47
|
+
*
|
|
48
|
+
* Update your `@selectedKey` state in this callback to maintain two-way binding.
|
|
49
|
+
*
|
|
50
|
+
* @param key - The newly selected key, or null if selection was cleared
|
|
27
51
|
*/
|
|
28
52
|
onSelectionChange?: (key: string | null) => void;
|
|
29
53
|
}
|
|
54
|
+
interface ExplicitSingleSelectArgs<T> extends BaseSingleSelectArgs<T> {
|
|
55
|
+
/**
|
|
56
|
+
* Determines the selection mode of the select component.
|
|
57
|
+
* - 'single': Only one item can be selected at a time.
|
|
58
|
+
*/
|
|
59
|
+
selectionMode: 'single';
|
|
60
|
+
}
|
|
61
|
+
interface DefaultSingleSelectArgs<T> extends BaseSingleSelectArgs<T> {
|
|
62
|
+
/**
|
|
63
|
+
* Determines the selection mode of the select component.
|
|
64
|
+
* - 'single': Only one item can be selected at a time.
|
|
65
|
+
* @defaultValue 'single'
|
|
66
|
+
*/
|
|
67
|
+
selectionMode?: undefined;
|
|
68
|
+
}
|
|
30
69
|
interface MultipleSelectArgs<T> extends BaseSelectArgs<T> {
|
|
31
70
|
/**
|
|
32
71
|
* Determines the selection mode of the select component.
|
|
@@ -39,14 +78,45 @@ interface MultipleSelectArgs<T> extends BaseSelectArgs<T> {
|
|
|
39
78
|
selectedKey?: never;
|
|
40
79
|
/**
|
|
41
80
|
* The currently selected keys for multiple selection mode.
|
|
81
|
+
*
|
|
82
|
+
* **Data Flow:**
|
|
83
|
+
* - Pass this to set the initial selection (array of keys)
|
|
84
|
+
* - Update this in your `onSelectionChange` handler to maintain two-way binding
|
|
85
|
+
* - The component calls `onSelectionChange` whenever the user changes the selection
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```gts
|
|
89
|
+
* import { tracked } from '@glimmer/tracking';
|
|
90
|
+
*
|
|
91
|
+
* class MyComponent {
|
|
92
|
+
* @tracked selectedKeys = ['option1', 'option2'];
|
|
93
|
+
*
|
|
94
|
+
* handleSelectionChange = (keys: string[]) => {
|
|
95
|
+
* this.selectedKeys = keys; // Update parent state
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* <template>
|
|
99
|
+
* <Select
|
|
100
|
+
* @selectionMode="multiple"
|
|
101
|
+
* @selectedKeys={{this.selectedKeys}}
|
|
102
|
+
* @onSelectionChange={{this.handleSelectionChange}}
|
|
103
|
+
* @items={{this.items}}
|
|
104
|
+
* />
|
|
105
|
+
* </template>
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
42
108
|
*/
|
|
43
109
|
selectedKeys?: string[];
|
|
44
110
|
/**
|
|
45
111
|
* Callback fired when the selection changes in multiple mode.
|
|
112
|
+
*
|
|
113
|
+
* Update your `@selectedKeys` state in this callback to maintain two-way binding.
|
|
114
|
+
*
|
|
115
|
+
* @param keys - The newly selected keys (empty array if all selections cleared)
|
|
46
116
|
*/
|
|
47
117
|
onSelectionChange?: (keys: string[]) => void;
|
|
48
118
|
}
|
|
49
|
-
type SelectArgs<T> = (
|
|
119
|
+
type SelectArgs<T> = (ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T> | MultipleSelectArgs<T>) & {
|
|
50
120
|
/**
|
|
51
121
|
* The unique identifier for the select component.
|
|
52
122
|
*/
|
|
@@ -60,8 +130,9 @@ type SelectArgs<T> = (SingleSelectArgs<T> | MultipleSelectArgs<T>) & {
|
|
|
60
130
|
* - 'sm': Small
|
|
61
131
|
* - 'md': Medium
|
|
62
132
|
* - 'lg': Large
|
|
63
|
-
*
|
|
64
|
-
*
|
|
133
|
+
* - 'trigger': Same size as the trigger
|
|
134
|
+
*
|
|
135
|
+
* @defaultValue 'trigger'
|
|
65
136
|
*/
|
|
66
137
|
popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';
|
|
67
138
|
/**
|
|
@@ -135,9 +206,8 @@ type SelectArgs<T> = (SingleSelectArgs<T> | MultipleSelectArgs<T>) & {
|
|
|
135
206
|
startContentPointerEvents?: 'none' | 'auto';
|
|
136
207
|
/**
|
|
137
208
|
* Controls pointer-events property of endContent.
|
|
138
|
-
*
|
|
139
|
-
* needs to capture events,
|
|
140
|
-
* element only.
|
|
209
|
+
* Defaults to `none` to pass click events to the input. If your content
|
|
210
|
+
* needs to capture events, add the `pointer-events-auto` class to that element.
|
|
141
211
|
*
|
|
142
212
|
* @defaultValue 'none'
|
|
143
213
|
*/
|
|
@@ -148,6 +218,10 @@ type SelectArgs<T> = (SingleSelectArgs<T> | MultipleSelectArgs<T>) & {
|
|
|
148
218
|
* @defaultValue false
|
|
149
219
|
*/
|
|
150
220
|
hideEmptyContent?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Callback fired when the select component loses focus.
|
|
223
|
+
*/
|
|
224
|
+
onBlur?: () => void;
|
|
151
225
|
};
|
|
152
226
|
interface SelectSignature<T> {
|
|
153
227
|
Args: SelectArgs<T>;
|
|
@@ -174,11 +248,69 @@ interface SelectSignature<T> {
|
|
|
174
248
|
emptyContent: [];
|
|
175
249
|
};
|
|
176
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Select Component - A feature-rich dropdown selection component
|
|
253
|
+
*
|
|
254
|
+
* ## Selection State Architecture
|
|
255
|
+
*
|
|
256
|
+
* This component uses a **two-way data binding pattern** for managing selection state:
|
|
257
|
+
*
|
|
258
|
+
* ### Data Flow
|
|
259
|
+
* 1. **External → Internal (Initialization & Updates)**
|
|
260
|
+
* - Parent passes `@selectedKey` or `@selectedKeys` as arguments
|
|
261
|
+
* - Constructor initializes internal tracked properties (`_selectedKey` or `_selectedKeys`)
|
|
262
|
+
* - Modifiers (`updateSingleSelectValue`, `updateMultipleSelectValue`) sync internal state
|
|
263
|
+
* when parent updates the arguments
|
|
264
|
+
*
|
|
265
|
+
* 2. **Internal State Management**
|
|
266
|
+
* - `_selectedKey` / `_selectedKeys`: Internal tracked state (prefixed with underscore)
|
|
267
|
+
* - These serve as the "source of truth" for rendering and reactivity
|
|
268
|
+
* - Getters (`getSelectedKey`, `selectedKeys`) expose this internal state to the template
|
|
269
|
+
*
|
|
270
|
+
* 3. **Internal → External (User Interactions)**
|
|
271
|
+
* - User interactions trigger selection change handlers
|
|
272
|
+
* - Handlers update internal `_selectedKey` / `_selectedKeys` for immediate UI update
|
|
273
|
+
* - Handlers call parent's `@onSelectionChange` callback to notify of state change
|
|
274
|
+
* - Parent updates its state, which flows back through step 1
|
|
275
|
+
*
|
|
276
|
+
* ### Why Both Internal State AND Callbacks?
|
|
277
|
+
* - **Internal state:** Enables immediate, responsive UI updates (`_selectedKey` / `_selectedKeys`)
|
|
278
|
+
* - **Parent callback:** Enables parent to take action when changes occur (`@onSelectionChange`)
|
|
279
|
+
* - This pattern provides both responsive UX and parent inclusion over state
|
|
280
|
+
*
|
|
281
|
+
* ### Example Flow
|
|
282
|
+
* ```
|
|
283
|
+
* User clicks item
|
|
284
|
+
* → onSelectionChange handler
|
|
285
|
+
* → Updates _selectedKey (immediate UI update)
|
|
286
|
+
* → Calls parent's @onSelectionChange callback
|
|
287
|
+
* → Parent updates its @selectedKey state
|
|
288
|
+
* → updateSingleSelectValue modifier syncs _selectedKey with new arg value
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
177
291
|
declare class Select<T = unknown> extends Component<SelectSignature<T>> {
|
|
178
292
|
nodes: ListItem[];
|
|
179
293
|
isOpen: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Internal tracked state for single selection mode.
|
|
296
|
+
* Source of truth for rendering. Synced with @selectedKey via the updateSingleSelectValue modifier.
|
|
297
|
+
*/
|
|
180
298
|
_selectedKey: string | null;
|
|
299
|
+
/**
|
|
300
|
+
* Internal tracked state for multiple selection mode.
|
|
301
|
+
* Source of truth for rendering. Synced with @selectedKeys via the updateMultipleSelectValue modifier.
|
|
302
|
+
*/
|
|
181
303
|
_selectedKeys: string[];
|
|
304
|
+
/**
|
|
305
|
+
* Initializes the component and sets up initial selection state.
|
|
306
|
+
*
|
|
307
|
+
* **Initialization:**
|
|
308
|
+
* 1. Determines selection mode (single vs multiple)
|
|
309
|
+
* 2. Copies external arg values (@selectedKey or @selectedKeys) to internal tracked state
|
|
310
|
+
* 3. Logs warnings if incorrect args are used for the selection mode
|
|
311
|
+
*
|
|
312
|
+
* Note: After instantiation, modifiers keep internal state synced with external arguments.
|
|
313
|
+
*/
|
|
182
314
|
constructor(owner: Owner, args: SelectArgs<T>);
|
|
183
315
|
validateArgs(): void;
|
|
184
316
|
filterValue?: string;
|
|
@@ -204,15 +336,66 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
|
|
|
204
336
|
Element: HTMLInputElement | HTMLButtonElement;
|
|
205
337
|
}>;
|
|
206
338
|
};
|
|
339
|
+
/**
|
|
340
|
+
* Handles selection changes from the Listbox component.
|
|
341
|
+
*
|
|
342
|
+
* **Flow:**
|
|
343
|
+
* 1. Updates internal state (`_selectedKey` or `_selectedKeys`) for immediate UI updates
|
|
344
|
+
* 2. Calls parent's `@onSelectionChange` callback to notify of the change
|
|
345
|
+
* 3. Parent updates its state, which flows back via modifier to complete the cycle
|
|
346
|
+
*
|
|
347
|
+
* **Side effects:**
|
|
348
|
+
* - Clears filter value (for searchable selects)
|
|
349
|
+
* - Triggers form input event for native form integration
|
|
350
|
+
*
|
|
351
|
+
* @param keys - Array of selected keys from Listbox (converted to single value in single mode)
|
|
352
|
+
*/
|
|
207
353
|
onSelectionChange: (keys: string[]) => void;
|
|
354
|
+
/**
|
|
355
|
+
* Handles selection changes from the native <select> element.
|
|
356
|
+
*
|
|
357
|
+
* This is similar to `onSelectionChange` but accepts a single key directly
|
|
358
|
+
* rather than an array, matching the native select's single-value API.
|
|
359
|
+
*
|
|
360
|
+
* **Flow:**
|
|
361
|
+
* 1. Updates internal `_selectedKey` for immediate UI update
|
|
362
|
+
* 2. Calls parent's `@onSelectionChange` callback
|
|
363
|
+
*
|
|
364
|
+
* @param key - The selected key, or null if cleared
|
|
365
|
+
*/
|
|
208
366
|
onSingleSelectionChange: (key: string | null) => void;
|
|
209
367
|
onOpenChange: (isOpen: boolean) => void;
|
|
210
368
|
onFilterChange: (event: Event) => void;
|
|
369
|
+
/**
|
|
370
|
+
* Returns current selection as an array for template rendering.
|
|
371
|
+
*
|
|
372
|
+
* Normalizes both single and multiple selection modes to a consistent array interface:
|
|
373
|
+
* - Multiple mode: Returns `_selectedKeys` directly
|
|
374
|
+
* - Single mode: Converts `_selectedKey` to array format (or empty array if null)
|
|
375
|
+
*
|
|
376
|
+
* Note: Always returns internal tracked state rather than arguments. External updates
|
|
377
|
+
* sync through modifiers to maintain consistency.
|
|
378
|
+
*
|
|
379
|
+
* @returns Array of selected keys (empty array if none selected)
|
|
380
|
+
*/
|
|
211
381
|
get selectedKeys(): string[];
|
|
382
|
+
/**
|
|
383
|
+
* Returns the selected key for single selection mode.
|
|
384
|
+
*
|
|
385
|
+
* **Returns:**
|
|
386
|
+
* - Single mode: Returns `_selectedKey` (string or null)
|
|
387
|
+
* - Multiple mode: Returns null (not applicable)
|
|
388
|
+
*
|
|
389
|
+
* Note: Always returns internal tracked state rather than arguments. External updates
|
|
390
|
+
* sync through modifiers to maintain consistency.
|
|
391
|
+
*
|
|
392
|
+
* @returns The selected key, or null if none selected or in multiple mode
|
|
393
|
+
*/
|
|
212
394
|
get getSelectedKey(): string | null;
|
|
213
395
|
get blockScroll(): boolean;
|
|
214
396
|
get disableFocusTrap(): boolean;
|
|
215
397
|
onAction: (key: string) => void;
|
|
398
|
+
handleBlur(): void;
|
|
216
399
|
clearSelectedKeys: () => void;
|
|
217
400
|
onItemsChange: (nodes: ListItem[], _: "add" | "remove") => void;
|
|
218
401
|
didClose: () => void;
|
|
@@ -311,6 +494,38 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
|
|
|
311
494
|
get filteredItems(): T[] | undefined;
|
|
312
495
|
get showEmptyContent(): boolean;
|
|
313
496
|
get autoActivateMode(): 'first' | 'selected';
|
|
497
|
+
/**
|
|
498
|
+
* Syncs internal `_selectedKeys` with external `@selectedKeys` argument.
|
|
499
|
+
*
|
|
500
|
+
* Runs whenever `@selectedKeys` changes:
|
|
501
|
+
* - Updates `_selectedKeys` to match the new external value
|
|
502
|
+
* - Normalizes undefined/null to empty array
|
|
503
|
+
*
|
|
504
|
+
* This enables UI updates when the external value changes.
|
|
505
|
+
*/
|
|
506
|
+
updateMultipleSelectValue: import("ember-modifier").FunctionBasedModifier<{
|
|
507
|
+
Args: {
|
|
508
|
+
Positional: [string[] | null | undefined];
|
|
509
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
510
|
+
};
|
|
511
|
+
Element: HTMLDivElement;
|
|
512
|
+
}>;
|
|
513
|
+
/**
|
|
514
|
+
* Syncs internal `_selectedKey` with external `@selectedKey` argument.
|
|
515
|
+
*
|
|
516
|
+
* Runs whenever `@selectedKey` changes:
|
|
517
|
+
* - Updates `_selectedKey` to match the new external value
|
|
518
|
+
* - Handles null values for cleared selections
|
|
519
|
+
*
|
|
520
|
+
* This enables UI updates when the external value changes.
|
|
521
|
+
*/
|
|
522
|
+
updateSingleSelectValue: import("ember-modifier").FunctionBasedModifier<{
|
|
523
|
+
Args: {
|
|
524
|
+
Positional: [string | null | undefined];
|
|
525
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
526
|
+
};
|
|
527
|
+
Element: HTMLDivElement;
|
|
528
|
+
}>;
|
|
314
529
|
}
|
|
315
530
|
export { Select, type SelectSignature };
|
|
316
531
|
export default Select;
|
|
@@ -41,6 +41,10 @@ interface Args extends FormControlSharedArgs {
|
|
|
41
41
|
* Receives the new boolean value and, optionally, the triggering Event.
|
|
42
42
|
*/
|
|
43
43
|
onChange?: ((value: boolean, event: Event) => void) | ((value: boolean) => void);
|
|
44
|
+
/**
|
|
45
|
+
* Callback triggered when the Switch loses focus (blur event).
|
|
46
|
+
*/
|
|
47
|
+
onBlur?: () => void;
|
|
44
48
|
}
|
|
45
49
|
interface SwitchSignature {
|
|
46
50
|
Args: Args;
|
|
@@ -59,85 +63,86 @@ declare class Switch extends Component<SwitchSignature> {
|
|
|
59
63
|
get isControlled(): boolean;
|
|
60
64
|
get isSelected(): boolean;
|
|
61
65
|
handleChange: (event: Event) => void;
|
|
66
|
+
handleBlur: () => void;
|
|
62
67
|
get classes(): {
|
|
63
68
|
base: (slotProps?: ({
|
|
64
|
-
intent?: "
|
|
69
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
65
70
|
size?: "sm" | "md" | "lg" | undefined;
|
|
66
71
|
isDisabled?: boolean | undefined;
|
|
67
72
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
68
73
|
labelContainer: (slotProps?: ({
|
|
69
|
-
intent?: "
|
|
74
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
70
75
|
size?: "sm" | "md" | "lg" | undefined;
|
|
71
76
|
isDisabled?: boolean | undefined;
|
|
72
77
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
73
78
|
label: (slotProps?: ({
|
|
74
|
-
intent?: "
|
|
79
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
75
80
|
size?: "sm" | "md" | "lg" | undefined;
|
|
76
81
|
isDisabled?: boolean | undefined;
|
|
77
82
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
78
83
|
wrapper: (slotProps?: ({
|
|
79
|
-
intent?: "
|
|
84
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
80
85
|
size?: "sm" | "md" | "lg" | undefined;
|
|
81
86
|
isDisabled?: boolean | undefined;
|
|
82
87
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
83
88
|
hiddenInput: (slotProps?: ({
|
|
84
|
-
intent?: "
|
|
89
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
85
90
|
size?: "sm" | "md" | "lg" | undefined;
|
|
86
91
|
isDisabled?: boolean | undefined;
|
|
87
92
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
88
93
|
thumb: (slotProps?: ({
|
|
89
|
-
intent?: "
|
|
94
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
90
95
|
size?: "sm" | "md" | "lg" | undefined;
|
|
91
96
|
isDisabled?: boolean | undefined;
|
|
92
97
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
93
98
|
startContent: (slotProps?: ({
|
|
94
|
-
intent?: "
|
|
99
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
95
100
|
size?: "sm" | "md" | "lg" | undefined;
|
|
96
101
|
isDisabled?: boolean | undefined;
|
|
97
102
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
98
103
|
endContent: (slotProps?: ({
|
|
99
|
-
intent?: "
|
|
104
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
100
105
|
size?: "sm" | "md" | "lg" | undefined;
|
|
101
106
|
isDisabled?: boolean | undefined;
|
|
102
107
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
103
108
|
} & {
|
|
104
109
|
base: (slotProps?: ({
|
|
105
|
-
intent?: "
|
|
110
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
106
111
|
size?: "sm" | "md" | "lg" | undefined;
|
|
107
112
|
isDisabled?: boolean | undefined;
|
|
108
113
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
109
114
|
labelContainer: (slotProps?: ({
|
|
110
|
-
intent?: "
|
|
115
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
111
116
|
size?: "sm" | "md" | "lg" | undefined;
|
|
112
117
|
isDisabled?: boolean | undefined;
|
|
113
118
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
114
119
|
label: (slotProps?: ({
|
|
115
|
-
intent?: "
|
|
120
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
116
121
|
size?: "sm" | "md" | "lg" | undefined;
|
|
117
122
|
isDisabled?: boolean | undefined;
|
|
118
123
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
119
124
|
wrapper: (slotProps?: ({
|
|
120
|
-
intent?: "
|
|
125
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
121
126
|
size?: "sm" | "md" | "lg" | undefined;
|
|
122
127
|
isDisabled?: boolean | undefined;
|
|
123
128
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
124
129
|
hiddenInput: (slotProps?: ({
|
|
125
|
-
intent?: "
|
|
130
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
126
131
|
size?: "sm" | "md" | "lg" | undefined;
|
|
127
132
|
isDisabled?: boolean | undefined;
|
|
128
133
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
129
134
|
thumb: (slotProps?: ({
|
|
130
|
-
intent?: "
|
|
135
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
131
136
|
size?: "sm" | "md" | "lg" | undefined;
|
|
132
137
|
isDisabled?: boolean | undefined;
|
|
133
138
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
134
139
|
startContent: (slotProps?: ({
|
|
135
|
-
intent?: "
|
|
140
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
136
141
|
size?: "sm" | "md" | "lg" | undefined;
|
|
137
142
|
isDisabled?: boolean | undefined;
|
|
138
143
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
139
144
|
endContent: (slotProps?: ({
|
|
140
|
-
intent?: "
|
|
145
|
+
intent?: "primary" | "success" | "danger" | "warning" | "default" | undefined;
|
|
141
146
|
size?: "sm" | "md" | "lg" | undefined;
|
|
142
147
|
isDisabled?: boolean | undefined;
|
|
143
148
|
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
@@ -9,6 +9,7 @@ interface Args extends FormControlSharedArgs {
|
|
|
9
9
|
classes?: SlotsToClasses<TextareaSlots>;
|
|
10
10
|
onInput?: (value: string, event: InputEvent) => void;
|
|
11
11
|
onChange?: (value: string, event: InputEvent) => void;
|
|
12
|
+
onBlur?: () => void;
|
|
12
13
|
}
|
|
13
14
|
interface TextareaSignature {
|
|
14
15
|
Args: Args;
|
|
@@ -17,6 +18,7 @@ interface TextareaSignature {
|
|
|
17
18
|
declare class Textarea extends Component<TextareaSignature> {
|
|
18
19
|
handleOnInput(event: Event): void;
|
|
19
20
|
handleOnChange(event: Event): void;
|
|
21
|
+
handleOnBlur(): void;
|
|
20
22
|
get classes(): {
|
|
21
23
|
base: (slotProps?: ({
|
|
22
24
|
size?: "sm" | "md" | "lg" | undefined;
|
package/declarations/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './components/form';
|
|
2
|
+
export * from './components/field';
|
|
2
3
|
export * from './components/checkbox';
|
|
3
4
|
export * from './components/checkbox-group';
|
|
4
5
|
export * from './components/form-description';
|
|
@@ -12,3 +13,5 @@ export * from './components/radio';
|
|
|
12
13
|
export * from './components/radio-group';
|
|
13
14
|
export * from './components/form-control';
|
|
14
15
|
export * from './components/switch';
|
|
16
|
+
export * from './utils/standard-validator';
|
|
17
|
+
export * from './utils/nested-data';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for working with nested data structures in forms.
|
|
3
|
+
* These functions convert between nested objects and flat dotted-path notation.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Flattens a nested object into a flat object with dotted-path keys.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* flattenData({name: {first: 'John', last: 'Doe'}, email: 'john@example.com'})
|
|
10
|
+
* // Returns: {'name.first': 'John', 'name.last': 'Doe', 'email': 'john@example.com'}
|
|
11
|
+
*
|
|
12
|
+
* @param data - The nested data object to flatten
|
|
13
|
+
* @param prefix - Internal parameter for recursion (parent path)
|
|
14
|
+
* @returns A flat object with dotted-path keys
|
|
15
|
+
*/
|
|
16
|
+
export declare function flattenData<T = unknown>(data: Record<string, unknown>, prefix?: string): Record<string, T>;
|
|
17
|
+
/**
|
|
18
|
+
* Unflattens a flat object with dotted-path keys into a nested object structure.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* unflattenData({'name.first': 'John', 'name.last': 'Doe', 'email': 'john@example.com'})
|
|
22
|
+
* // Returns: {name: {first: 'John', last: 'Doe'}, email: 'john@example.com'}
|
|
23
|
+
*
|
|
24
|
+
* @param data - The flat data object with dotted-path keys
|
|
25
|
+
* @returns A nested object structure
|
|
26
|
+
*/
|
|
27
|
+
export declare function unflattenData<T = unknown>(data: Record<string, unknown>): Record<string, T>;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the data structure contains any nested objects.
|
|
30
|
+
* If true, we need to handle it as nested data.
|
|
31
|
+
*
|
|
32
|
+
* @param data - The data object to check
|
|
33
|
+
* @returns True if the data contains nested plain objects
|
|
34
|
+
*/
|
|
35
|
+
export declare function hasNestedData(data: Record<string, unknown>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Deep equality comparison for nested objects.
|
|
38
|
+
* Handles primitives, arrays, and nested objects.
|
|
39
|
+
*
|
|
40
|
+
* @param a - First value to compare
|
|
41
|
+
* @param b - Second value to compare
|
|
42
|
+
* @returns True if values are deeply equal
|
|
43
|
+
*/
|
|
44
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|