@dragonmastery/zinia-forms-core 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +75 -0
- package/README.md +108 -0
- package/dist/index.d.ts +2163 -0
- package/dist/index.js +8544 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
- package/scripts/postinstall.js +27 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2163 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { FunctionalComponent, Ref, App } from 'vue';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
type BrowserNativeObject = Date | FileList | File;
|
|
6
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
7
|
+
/**
|
|
8
|
+
* Checks whether T1 can be exactly (mutually) assigned to T2
|
|
9
|
+
* @typeParam T1 - type to check
|
|
10
|
+
* @typeParam T2 - type to check against
|
|
11
|
+
* ```
|
|
12
|
+
* IsEqual<string, string> = true
|
|
13
|
+
* IsEqual<'foo', 'foo'> = true
|
|
14
|
+
* IsEqual<string, number> = false
|
|
15
|
+
* IsEqual<string, number> = false
|
|
16
|
+
* IsEqual<string, 'foo'> = false
|
|
17
|
+
* IsEqual<'foo', string> = false
|
|
18
|
+
* IsEqual<'foo' | 'bar', 'foo'> = boolean // 'foo' is assignable, but 'bar' is not (true | false) -> boolean
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
type IsEqual<T1, T2> = T1 extends T2 ? (<G>() => G extends T1 ? 1 : 2) extends <G>() => G extends T2 ? 1 : 2 ? true : false : false;
|
|
22
|
+
/**
|
|
23
|
+
* Type to query whether an array type T is a tuple type.
|
|
24
|
+
* @typeParam T - type which may be an array or tuple
|
|
25
|
+
* @example
|
|
26
|
+
* ```
|
|
27
|
+
* IsTuple<[number]> = true
|
|
28
|
+
* IsTuple<number[]> = false
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
|
|
32
|
+
/**
|
|
33
|
+
* Type which can be used to index an array or tuple type.
|
|
34
|
+
*/
|
|
35
|
+
type ArrayKey = number;
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to break apart T1 and check if any are equal to T2
|
|
38
|
+
*
|
|
39
|
+
* See {@link IsEqual}
|
|
40
|
+
*/
|
|
41
|
+
type AnyIsEqual<T1, T2> = T1 extends T2 ? (IsEqual<T1, T2> extends true ? true : never) : never;
|
|
42
|
+
/**
|
|
43
|
+
* Type which given a tuple type returns its own keys, i.e. only its indices.
|
|
44
|
+
* @typeParam T - tuple type
|
|
45
|
+
* @example
|
|
46
|
+
* ```
|
|
47
|
+
* TupleKeys<[number, string]> = '0' | '1'
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
type TupleKeys<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Helper type for recursively constructing paths through a type.
|
|
53
|
+
* This actually constructs the strings and recurses into nested
|
|
54
|
+
* object types.
|
|
55
|
+
*
|
|
56
|
+
* See {@link Path}
|
|
57
|
+
*/
|
|
58
|
+
type PathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? `${K}` : true extends AnyIsEqual<TraversedTypes, V> ? `${K}` : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`;
|
|
59
|
+
/**
|
|
60
|
+
* Helper type for recursively constructing paths through a type.
|
|
61
|
+
* This obscures the internal type param TraversedTypes from ed contract.
|
|
62
|
+
*
|
|
63
|
+
* See {@link Path}
|
|
64
|
+
*/
|
|
65
|
+
type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
|
|
66
|
+
[K in TupleKeys<T>]-?: PathImpl<K & string, T[K], TraversedTypes>;
|
|
67
|
+
}[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : {
|
|
68
|
+
[K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>;
|
|
69
|
+
}[keyof T];
|
|
70
|
+
/**
|
|
71
|
+
* Type which eagerly collects all paths through a type
|
|
72
|
+
* @typeParam T - type which should be introspected
|
|
73
|
+
* @example
|
|
74
|
+
* ```
|
|
75
|
+
* Path<{foo: {bar: string}}> = 'foo' | 'foo.bar'
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
type Path<T> = T extends any ? PathInternal<T> : never;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Represents a dynamic path that can be constructed at runtime
|
|
82
|
+
* This includes both static schema paths and dynamic array paths
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // Static paths (from schema)
|
|
86
|
+
* type StaticPaths = Path<FormType>; // "name" | "description" | "tasks"
|
|
87
|
+
*
|
|
88
|
+
* // Dynamic paths (constructed at runtime)
|
|
89
|
+
* type DynamicPaths = DynamicPath<FormType>; // "name" | "description" | "tasks" | "tasks.0.title" | "tasks.0.subtasks.1.completed"
|
|
90
|
+
*/
|
|
91
|
+
type DynamicPath<T> = Path<T> | string;
|
|
92
|
+
/**
|
|
93
|
+
* Helper type for field components that need to accept both static and dynamic paths
|
|
94
|
+
* This is the key to solving the `as any` problem
|
|
95
|
+
*/
|
|
96
|
+
type FlexiblePath<T> = DynamicPath<T>;
|
|
97
|
+
|
|
98
|
+
interface ArrayFieldProps<FormType, ItemType> {
|
|
99
|
+
name: FlexiblePath<FormType>;
|
|
100
|
+
label?: string;
|
|
101
|
+
hideLabel?: boolean;
|
|
102
|
+
description?: string;
|
|
103
|
+
required?: boolean;
|
|
104
|
+
disabled?: boolean;
|
|
105
|
+
readonly?: boolean;
|
|
106
|
+
class?: string | string[];
|
|
107
|
+
availableItems?: ItemType[];
|
|
108
|
+
itemsSource?: () => ItemType[];
|
|
109
|
+
itemRenderer?: (item: ItemType, index: number) => any;
|
|
110
|
+
availableItemRenderer?: (item: ItemType, index: number) => any;
|
|
111
|
+
createItem?: () => ItemType;
|
|
112
|
+
onAddItem?: (item: ItemType) => void;
|
|
113
|
+
onRemoveItem?: (index: number) => void;
|
|
114
|
+
onUpdateItem?: (index: number, item: ItemType) => void;
|
|
115
|
+
onSwapItems?: (indexA: number, indexB: number) => void;
|
|
116
|
+
minItems?: number;
|
|
117
|
+
maxItems?: number;
|
|
118
|
+
allowReordering?: boolean;
|
|
119
|
+
autoPrefixFields?: boolean;
|
|
120
|
+
ariaLabels?: {
|
|
121
|
+
addButton?: string;
|
|
122
|
+
removeButton?: string;
|
|
123
|
+
moveUpButton?: string;
|
|
124
|
+
moveDownButton?: string;
|
|
125
|
+
item?: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface CheckboxFieldProps<FormType> {
|
|
130
|
+
name: FlexiblePath<FormType>;
|
|
131
|
+
label?: string;
|
|
132
|
+
hideLabel?: boolean;
|
|
133
|
+
description?: string;
|
|
134
|
+
required?: boolean;
|
|
135
|
+
disabled?: boolean;
|
|
136
|
+
readonly?: boolean;
|
|
137
|
+
class?: string | string[];
|
|
138
|
+
size?: string;
|
|
139
|
+
variant?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface CurrencyFieldProps<FormType> {
|
|
143
|
+
name: FlexiblePath<FormType>;
|
|
144
|
+
label?: string;
|
|
145
|
+
hideLabel?: boolean;
|
|
146
|
+
description?: string;
|
|
147
|
+
required?: boolean;
|
|
148
|
+
placeholder?: string;
|
|
149
|
+
disabled?: boolean;
|
|
150
|
+
readonly?: boolean;
|
|
151
|
+
class?: string | string[];
|
|
152
|
+
size?: string;
|
|
153
|
+
variant?: string;
|
|
154
|
+
min?: number;
|
|
155
|
+
max?: number;
|
|
156
|
+
step?: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface DateFieldProps<FormType> {
|
|
160
|
+
name: FlexiblePath<FormType>;
|
|
161
|
+
label?: string;
|
|
162
|
+
hideLabel?: boolean;
|
|
163
|
+
description?: string;
|
|
164
|
+
required?: boolean;
|
|
165
|
+
placeholder?: string;
|
|
166
|
+
disabled?: boolean;
|
|
167
|
+
readonly?: boolean;
|
|
168
|
+
class?: string | string[];
|
|
169
|
+
size?: string;
|
|
170
|
+
variant?: string;
|
|
171
|
+
min?: string;
|
|
172
|
+
max?: string;
|
|
173
|
+
formatter?: (date: string) => unknown;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface DateTimeLocalFieldProps<FormType> {
|
|
177
|
+
name: FlexiblePath<FormType>;
|
|
178
|
+
label?: string;
|
|
179
|
+
hideLabel?: boolean;
|
|
180
|
+
description?: string;
|
|
181
|
+
required?: boolean;
|
|
182
|
+
placeholder?: string;
|
|
183
|
+
disabled?: boolean;
|
|
184
|
+
readonly?: boolean;
|
|
185
|
+
class?: string | string[];
|
|
186
|
+
size?: string;
|
|
187
|
+
variant?: string;
|
|
188
|
+
min?: string;
|
|
189
|
+
max?: string;
|
|
190
|
+
step?: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface EmailFieldProps<FormType> {
|
|
194
|
+
name: FlexiblePath<FormType>;
|
|
195
|
+
label?: string;
|
|
196
|
+
hideLabel?: boolean;
|
|
197
|
+
description?: string;
|
|
198
|
+
required?: boolean;
|
|
199
|
+
placeholder?: string;
|
|
200
|
+
disabled?: boolean;
|
|
201
|
+
readonly?: boolean;
|
|
202
|
+
autocomplete?: string;
|
|
203
|
+
class?: string | string[];
|
|
204
|
+
size?: string;
|
|
205
|
+
variant?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface FileFieldProps<FormType> {
|
|
209
|
+
name: FlexiblePath<FormType>;
|
|
210
|
+
label?: string;
|
|
211
|
+
hideLabel?: boolean;
|
|
212
|
+
description?: string;
|
|
213
|
+
required?: boolean;
|
|
214
|
+
disabled?: boolean;
|
|
215
|
+
readonly?: boolean;
|
|
216
|
+
class?: string | string[];
|
|
217
|
+
size?: string;
|
|
218
|
+
variant?: string;
|
|
219
|
+
accept?: string;
|
|
220
|
+
multiple?: boolean;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Props for the FormErrorsSummary component
|
|
225
|
+
*/
|
|
226
|
+
interface FormErrorsSummaryProps {
|
|
227
|
+
/**
|
|
228
|
+
* Custom title for the errors section
|
|
229
|
+
*/
|
|
230
|
+
title?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Whether to show the component only after form submission has been attempted
|
|
233
|
+
* @default true
|
|
234
|
+
*/
|
|
235
|
+
showOnlyAfterSubmitAttempt?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Custom CSS class for the container
|
|
238
|
+
*/
|
|
239
|
+
className?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Icon to display next to the title
|
|
242
|
+
* @default 'exclamation-circle'
|
|
243
|
+
*/
|
|
244
|
+
icon?: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface FormProps<FormType> {
|
|
248
|
+
title?: string;
|
|
249
|
+
subtitle?: string;
|
|
250
|
+
className?: string;
|
|
251
|
+
/**
|
|
252
|
+
* Custom submission handler - optional, if not provided will use default behavior.
|
|
253
|
+
* This is the preferred way to handle form submission as it avoids conflicts with native events.
|
|
254
|
+
*/
|
|
255
|
+
onHandleSubmit?: (data: FormType) => Promise<any> | any;
|
|
256
|
+
onSuccess?: (result: any) => void;
|
|
257
|
+
onError?: (error: any) => void;
|
|
258
|
+
onBeforeValidate?: () => void;
|
|
259
|
+
autoFocus?: boolean;
|
|
260
|
+
disabled?: boolean;
|
|
261
|
+
children?: any;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
interface NumberFieldProps<FormType> {
|
|
265
|
+
name: FlexiblePath<FormType>;
|
|
266
|
+
label?: string;
|
|
267
|
+
hideLabel?: boolean;
|
|
268
|
+
description?: string;
|
|
269
|
+
required?: boolean;
|
|
270
|
+
placeholder?: string;
|
|
271
|
+
disabled?: boolean;
|
|
272
|
+
readonly?: boolean;
|
|
273
|
+
class?: string | string[];
|
|
274
|
+
size?: string;
|
|
275
|
+
variant?: string;
|
|
276
|
+
min?: number;
|
|
277
|
+
max?: number;
|
|
278
|
+
step?: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
interface PasswordFieldProps<FormType> {
|
|
282
|
+
name: FlexiblePath<FormType>;
|
|
283
|
+
label?: string;
|
|
284
|
+
hideLabel?: boolean;
|
|
285
|
+
description?: string;
|
|
286
|
+
required?: boolean;
|
|
287
|
+
placeholder?: string;
|
|
288
|
+
disabled?: boolean;
|
|
289
|
+
readonly?: boolean;
|
|
290
|
+
autocomplete?: string;
|
|
291
|
+
class?: string | string[];
|
|
292
|
+
size?: string;
|
|
293
|
+
variant?: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface RadioFieldProps<FormType> {
|
|
297
|
+
name: FlexiblePath<FormType>;
|
|
298
|
+
label?: string;
|
|
299
|
+
hideLabel?: boolean;
|
|
300
|
+
description?: string;
|
|
301
|
+
required?: boolean;
|
|
302
|
+
disabled?: boolean;
|
|
303
|
+
readonly?: boolean;
|
|
304
|
+
class?: string | string[];
|
|
305
|
+
size?: string;
|
|
306
|
+
variant?: string;
|
|
307
|
+
options?: Array<{
|
|
308
|
+
value: string;
|
|
309
|
+
label: string;
|
|
310
|
+
}>;
|
|
311
|
+
inline?: boolean;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface RangeFieldProps<FormType> {
|
|
315
|
+
name: FlexiblePath<FormType>;
|
|
316
|
+
label?: string;
|
|
317
|
+
hideLabel?: boolean;
|
|
318
|
+
description?: string;
|
|
319
|
+
required?: boolean;
|
|
320
|
+
disabled?: boolean;
|
|
321
|
+
readonly?: boolean;
|
|
322
|
+
class?: string | string[];
|
|
323
|
+
size?: string;
|
|
324
|
+
variant?: string;
|
|
325
|
+
min?: number;
|
|
326
|
+
max?: number;
|
|
327
|
+
step?: number;
|
|
328
|
+
showValue?: boolean;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
interface ResetButtonProps<FormType> {
|
|
332
|
+
resetText?: string;
|
|
333
|
+
className?: string;
|
|
334
|
+
disabled?: boolean;
|
|
335
|
+
onReset?: () => void;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
interface SearchFieldProps<FormType> {
|
|
339
|
+
name: FlexiblePath<FormType>;
|
|
340
|
+
label?: string;
|
|
341
|
+
hideLabel?: boolean;
|
|
342
|
+
description?: string;
|
|
343
|
+
required?: boolean;
|
|
344
|
+
placeholder?: string;
|
|
345
|
+
disabled?: boolean;
|
|
346
|
+
readonly?: boolean;
|
|
347
|
+
autocomplete?: string;
|
|
348
|
+
class?: string | string[];
|
|
349
|
+
size?: string;
|
|
350
|
+
variant?: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Option item for select fields
|
|
355
|
+
*/
|
|
356
|
+
interface SelectOption {
|
|
357
|
+
value: string;
|
|
358
|
+
label: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Type for a mapping of enum values to labels
|
|
362
|
+
*/
|
|
363
|
+
type EnumValueToLabelMap<T extends string> = Record<T, string>;
|
|
364
|
+
/**
|
|
365
|
+
* Type for a value-to-label mapping that can be either a function or an object map
|
|
366
|
+
*/
|
|
367
|
+
type ValueToLabelMapping<T extends string = string> = ((value: string) => string) | EnumValueToLabelMap<T>;
|
|
368
|
+
/**
|
|
369
|
+
* Helper type to extract the type of a field at a given path
|
|
370
|
+
*/
|
|
371
|
+
type FieldType<T, P extends string> = P extends keyof T ? T[P] : P extends `${infer A}.${infer B}` ? A extends keyof T ? FieldType<T[A], B> : never : never;
|
|
372
|
+
/**
|
|
373
|
+
* Helper type to extract enum values from a field type
|
|
374
|
+
*/
|
|
375
|
+
type EnumValuesFromField<T> = T extends string ? T : never;
|
|
376
|
+
/**
|
|
377
|
+
* Type that maps field paths to their corresponding enum types
|
|
378
|
+
*/
|
|
379
|
+
type FieldPathToEnum$1<T, P extends Path<T>> = EnumValuesFromField<FieldType<T, P & string>>;
|
|
380
|
+
/**
|
|
381
|
+
* Props for the SelectField component
|
|
382
|
+
*/
|
|
383
|
+
interface SelectFieldProps<FormType, P extends Path<FormType> = Path<FormType>> {
|
|
384
|
+
/**
|
|
385
|
+
* Field name (path in the form state)
|
|
386
|
+
* Accepts both static paths and dynamic paths for use in array fields
|
|
387
|
+
*/
|
|
388
|
+
name: FlexiblePath<FormType>;
|
|
389
|
+
/**
|
|
390
|
+
* Field label
|
|
391
|
+
*/
|
|
392
|
+
label?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Whether to hide the label
|
|
395
|
+
*/
|
|
396
|
+
hideLabel?: boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Field description
|
|
399
|
+
*/
|
|
400
|
+
description?: string;
|
|
401
|
+
/**
|
|
402
|
+
* Whether the field is required
|
|
403
|
+
*/
|
|
404
|
+
required?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Placeholder text
|
|
407
|
+
*/
|
|
408
|
+
placeholder?: string;
|
|
409
|
+
/**
|
|
410
|
+
* Whether the field is disabled
|
|
411
|
+
*/
|
|
412
|
+
disabled?: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Whether the field is readonly
|
|
415
|
+
*/
|
|
416
|
+
readonly?: boolean;
|
|
417
|
+
/**
|
|
418
|
+
* CSS classes to apply to the field
|
|
419
|
+
*/
|
|
420
|
+
class?: string | string[];
|
|
421
|
+
/**
|
|
422
|
+
* Field size
|
|
423
|
+
*/
|
|
424
|
+
size?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Field variant
|
|
427
|
+
*/
|
|
428
|
+
variant?: string;
|
|
429
|
+
/**
|
|
430
|
+
* Select options (overrides options from schema)
|
|
431
|
+
* Using selectOptions instead of options to avoid conflicts with HTML select element
|
|
432
|
+
*/
|
|
433
|
+
selectOptions?: SelectOption[];
|
|
434
|
+
/**
|
|
435
|
+
* Custom mapping function to convert values to labels
|
|
436
|
+
* This is useful when you want to customize how labels are displayed
|
|
437
|
+
* without providing a full options array
|
|
438
|
+
*
|
|
439
|
+
* Can be provided as either:
|
|
440
|
+
* 1. A function that takes a value and returns a label
|
|
441
|
+
* 2. An object map where keys are enum values and values are labels
|
|
442
|
+
*/
|
|
443
|
+
valueToLabel?: ValueToLabelMapping<FieldPathToEnum$1<FormType, P>>;
|
|
444
|
+
/**
|
|
445
|
+
* Whether to use options from the schema (default: true)
|
|
446
|
+
* Set to false to ignore schema options even when no options prop is provided
|
|
447
|
+
*/
|
|
448
|
+
useSchemaOptions?: boolean;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
interface SubmitButtonProps<FormType> {
|
|
452
|
+
submitText?: string;
|
|
453
|
+
submittingText?: string;
|
|
454
|
+
className?: string;
|
|
455
|
+
disabled?: boolean;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
interface TelFieldProps<FormType> {
|
|
459
|
+
name: FlexiblePath<FormType>;
|
|
460
|
+
label?: string;
|
|
461
|
+
hideLabel?: boolean;
|
|
462
|
+
description?: string;
|
|
463
|
+
required?: boolean;
|
|
464
|
+
placeholder?: string;
|
|
465
|
+
disabled?: boolean;
|
|
466
|
+
readonly?: boolean;
|
|
467
|
+
autocomplete?: string;
|
|
468
|
+
class?: string | string[];
|
|
469
|
+
size?: string;
|
|
470
|
+
variant?: string;
|
|
471
|
+
pattern?: string;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
interface TextareaFieldProps<FormType> {
|
|
475
|
+
name: FlexiblePath<FormType>;
|
|
476
|
+
label?: string;
|
|
477
|
+
hideLabel?: boolean;
|
|
478
|
+
description?: string;
|
|
479
|
+
required?: boolean;
|
|
480
|
+
placeholder?: string;
|
|
481
|
+
disabled?: boolean;
|
|
482
|
+
readonly?: boolean;
|
|
483
|
+
class?: string | string[];
|
|
484
|
+
size?: string;
|
|
485
|
+
variant?: string;
|
|
486
|
+
rows?: number;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
interface TextFieldProps<FormType> {
|
|
490
|
+
name: FlexiblePath<FormType>;
|
|
491
|
+
label?: string;
|
|
492
|
+
hideLabel?: boolean;
|
|
493
|
+
description?: string;
|
|
494
|
+
required?: boolean;
|
|
495
|
+
placeholder?: string;
|
|
496
|
+
disabled?: boolean;
|
|
497
|
+
readonly?: boolean;
|
|
498
|
+
autocomplete?: string;
|
|
499
|
+
class?: string | string[];
|
|
500
|
+
size?: string;
|
|
501
|
+
variant?: string;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
interface TimeFieldProps<FormType> {
|
|
505
|
+
name: FlexiblePath<FormType>;
|
|
506
|
+
label?: string;
|
|
507
|
+
hideLabel?: boolean;
|
|
508
|
+
description?: string;
|
|
509
|
+
required?: boolean;
|
|
510
|
+
placeholder?: string;
|
|
511
|
+
disabled?: boolean;
|
|
512
|
+
readonly?: boolean;
|
|
513
|
+
class?: string | string[];
|
|
514
|
+
size?: string;
|
|
515
|
+
variant?: string;
|
|
516
|
+
min?: string;
|
|
517
|
+
max?: string;
|
|
518
|
+
step?: number;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Props for the ToppingsField component
|
|
523
|
+
*/
|
|
524
|
+
interface ToppingsFieldProps<FormType, ToppingType = any> {
|
|
525
|
+
/**
|
|
526
|
+
* Field name (path in the form state)
|
|
527
|
+
*/
|
|
528
|
+
name: FlexiblePath<FormType>;
|
|
529
|
+
/**
|
|
530
|
+
* Field label
|
|
531
|
+
*/
|
|
532
|
+
label?: string;
|
|
533
|
+
/**
|
|
534
|
+
* Whether to hide the label
|
|
535
|
+
*/
|
|
536
|
+
hideLabel?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Help text to display below the field
|
|
539
|
+
*/
|
|
540
|
+
helpText?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Whether the field is required
|
|
543
|
+
*/
|
|
544
|
+
required?: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Whether the field is disabled
|
|
547
|
+
*/
|
|
548
|
+
disabled?: boolean;
|
|
549
|
+
/**
|
|
550
|
+
* Whether the field is readonly
|
|
551
|
+
*/
|
|
552
|
+
readonly?: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* CSS classes to apply to the field
|
|
555
|
+
*/
|
|
556
|
+
class?: string | string[];
|
|
557
|
+
/**
|
|
558
|
+
* Field size
|
|
559
|
+
*/
|
|
560
|
+
size?: string;
|
|
561
|
+
/**
|
|
562
|
+
* Field variant
|
|
563
|
+
*/
|
|
564
|
+
variant?: string;
|
|
565
|
+
/**
|
|
566
|
+
* All available toppings to choose from
|
|
567
|
+
*/
|
|
568
|
+
allAvailableToppings: ToppingType[];
|
|
569
|
+
/**
|
|
570
|
+
* Function to get the name of a topping
|
|
571
|
+
*/
|
|
572
|
+
getToppingName?: (topping: ToppingType) => string;
|
|
573
|
+
/**
|
|
574
|
+
* Function to get the price of a topping
|
|
575
|
+
*/
|
|
576
|
+
getToppingPrice?: (topping: ToppingType) => number;
|
|
577
|
+
/**
|
|
578
|
+
* Function to get the placement of a topping (left, whole, right)
|
|
579
|
+
*/
|
|
580
|
+
getToppingPlacement?: (topping: ToppingType) => string;
|
|
581
|
+
/**
|
|
582
|
+
* Function to set the placement of a topping
|
|
583
|
+
*/
|
|
584
|
+
setToppingPlacement?: (topping: ToppingType, placement: string) => void;
|
|
585
|
+
/**
|
|
586
|
+
* Function to check if a topping has extra amount
|
|
587
|
+
*/
|
|
588
|
+
getIsExtraTopping?: (topping: ToppingType) => boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Function to toggle the extra amount of a topping
|
|
591
|
+
*/
|
|
592
|
+
toggleExtraTopping?: (topping: ToppingType, isExtra: boolean) => void;
|
|
593
|
+
/**
|
|
594
|
+
* Maximum number of toppings allowed
|
|
595
|
+
*/
|
|
596
|
+
maxToppings?: number;
|
|
597
|
+
/**
|
|
598
|
+
* Custom renderer for topping items
|
|
599
|
+
*/
|
|
600
|
+
toppingRenderer?: (topping: ToppingType, isSelected: boolean, placement: string, isExtra: boolean) => any;
|
|
601
|
+
/**
|
|
602
|
+
* ARIA labels for accessibility
|
|
603
|
+
*/
|
|
604
|
+
ariaLabels?: {
|
|
605
|
+
toppingsList?: string;
|
|
606
|
+
addTopping?: string;
|
|
607
|
+
removeTopping?: string;
|
|
608
|
+
leftSide?: string;
|
|
609
|
+
wholePizza?: string;
|
|
610
|
+
rightSide?: string;
|
|
611
|
+
extraTopping?: string;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
interface TransferListFieldProps<FormType, ItemType> {
|
|
616
|
+
name: FlexiblePath<FormType>;
|
|
617
|
+
label?: string;
|
|
618
|
+
hideLabel?: boolean;
|
|
619
|
+
description?: string;
|
|
620
|
+
required?: boolean;
|
|
621
|
+
disabled?: boolean;
|
|
622
|
+
readonly?: boolean;
|
|
623
|
+
class?: string | string[];
|
|
624
|
+
allAvailableItems: ItemType[];
|
|
625
|
+
itemIdentifier?: (item: ItemType) => string | number;
|
|
626
|
+
availableItemRenderer?: (item: ItemType, index: number) => any;
|
|
627
|
+
selectedItemRenderer?: (item: ItemType, index: number) => any;
|
|
628
|
+
allowReordering?: boolean;
|
|
629
|
+
autoPrefixFields?: boolean;
|
|
630
|
+
ariaLabels?: {
|
|
631
|
+
addButton?: string;
|
|
632
|
+
removeButton?: string;
|
|
633
|
+
moveUpButton?: string;
|
|
634
|
+
moveDownButton?: string;
|
|
635
|
+
availableItems?: string;
|
|
636
|
+
selectedItems?: string;
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
interface UrlFieldProps<FormType> {
|
|
641
|
+
name: FlexiblePath<FormType>;
|
|
642
|
+
label?: string;
|
|
643
|
+
hideLabel?: boolean;
|
|
644
|
+
description?: string;
|
|
645
|
+
required?: boolean;
|
|
646
|
+
placeholder?: string;
|
|
647
|
+
disabled?: boolean;
|
|
648
|
+
readonly?: boolean;
|
|
649
|
+
autocomplete?: string;
|
|
650
|
+
class?: string | string[];
|
|
651
|
+
size?: string;
|
|
652
|
+
variant?: string;
|
|
653
|
+
pattern?: string;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
interface DisplayProps<_FormType> {
|
|
657
|
+
loading?: boolean;
|
|
658
|
+
error?: string | null;
|
|
659
|
+
class?: string | string[];
|
|
660
|
+
variant?: 'default' | 'card' | 'bordered' | 'compact';
|
|
661
|
+
showLabels?: boolean;
|
|
662
|
+
layout?: 'vertical' | 'horizontal' | 'grid' | 'card-grid';
|
|
663
|
+
columns?: number;
|
|
664
|
+
title?: string;
|
|
665
|
+
loadingMessage?: string;
|
|
666
|
+
noDataMessage?: string;
|
|
667
|
+
cardClass?: string;
|
|
668
|
+
cardBodyClass?: string;
|
|
669
|
+
gap?: 'sm' | 'md' | 'lg';
|
|
670
|
+
fieldBorders?: boolean;
|
|
671
|
+
responsive?: boolean;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
interface DisplayFieldProps<FormType> {
|
|
675
|
+
name: FlexiblePath<FormType>;
|
|
676
|
+
label?: string;
|
|
677
|
+
hideLabel?: boolean;
|
|
678
|
+
description?: string;
|
|
679
|
+
format?: 'default' | 'currency' | 'date' | 'datetime' | 'boolean' | 'email' | 'url' | 'phone' | 'number' | 'badge' | 'status';
|
|
680
|
+
emptyText?: string;
|
|
681
|
+
class?: string | string[];
|
|
682
|
+
size?: 'sm' | 'md' | 'lg';
|
|
683
|
+
variant?: 'default' | 'bordered' | 'compact' | 'highlighted';
|
|
684
|
+
copyable?: boolean;
|
|
685
|
+
labelClass?: string;
|
|
686
|
+
valueClass?: string;
|
|
687
|
+
containerClass?: string;
|
|
688
|
+
badgeClass?: string;
|
|
689
|
+
statusMapping?: Record<string, {
|
|
690
|
+
class: string;
|
|
691
|
+
label?: string;
|
|
692
|
+
}>;
|
|
693
|
+
valueToLabel?: Record<string, string>;
|
|
694
|
+
separator?: string;
|
|
695
|
+
itemRenderer?: (item: any, index: number) => string;
|
|
696
|
+
maxItems?: number;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
interface DeleteModalProps<FormType = any> {
|
|
700
|
+
open: boolean;
|
|
701
|
+
onClose: () => void;
|
|
702
|
+
title?: string;
|
|
703
|
+
message?: string;
|
|
704
|
+
confirmText?: string;
|
|
705
|
+
cancelText?: string;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
interface DataTableProps<FormType> {
|
|
709
|
+
class?: string;
|
|
710
|
+
name?: string;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Type to convert underscores to PascalCase
|
|
715
|
+
* This helper type processes a single segment by capitalizing after underscores
|
|
716
|
+
*/
|
|
717
|
+
type SegmentToPascalCase<S extends string> = S extends `${infer First}_${infer Rest}` ? `${Capitalize<First>}${SegmentToPascalCase<Rest>}` : Capitalize<S>;
|
|
718
|
+
/**
|
|
719
|
+
* Type to convert a dot-separated path to PascalCase
|
|
720
|
+
* This uses recursion to handle any level of nesting
|
|
721
|
+
* Also handles underscores by removing them and capitalizing each segment
|
|
722
|
+
*/
|
|
723
|
+
type PathToPascalCase<P extends string> = P extends `${infer A}.${infer B}` ? `${SegmentToPascalCase<A>}${PathToPascalCase<B>}` : `${SegmentToPascalCase<P>}Field`;
|
|
724
|
+
/**
|
|
725
|
+
* Type that maps field paths to their corresponding enum types
|
|
726
|
+
*/
|
|
727
|
+
type FieldPathToEnum<T, P extends Path<T>> = P extends keyof T ? T[P] extends string ? T[P] : string : string;
|
|
728
|
+
/**
|
|
729
|
+
* Type that extracts the array element type from a field path
|
|
730
|
+
* If the path points to an array, it extracts the element type
|
|
731
|
+
* @example
|
|
732
|
+
* ArrayItemType<{users: User[]}, 'users'> = User
|
|
733
|
+
* ArrayItemType<{tasks: Task[]}, 'tasks'> = Task
|
|
734
|
+
*/
|
|
735
|
+
type ArrayItemType<T, P extends Path<T>> = P extends keyof T ? T[P] extends ReadonlyArray<infer Item> ? Item : T[P] extends Array<infer Item> ? Item : never : never;
|
|
736
|
+
/**
|
|
737
|
+
* Type for array field components with properly typed slots
|
|
738
|
+
*/
|
|
739
|
+
type ArrayFieldComponent<T, P extends Path<T>> = vue.FunctionalComponent<Omit<ArrayFieldProps<T, ArrayItemType<T, P>>, 'name'>, {}, {
|
|
740
|
+
itemRenderer: (props: {
|
|
741
|
+
item: ArrayItemType<T, P>;
|
|
742
|
+
index: number;
|
|
743
|
+
getFieldName: (fieldPath: string) => string;
|
|
744
|
+
}) => any;
|
|
745
|
+
availableItemRenderer: (props: {
|
|
746
|
+
item: ArrayItemType<T, P>;
|
|
747
|
+
index: number;
|
|
748
|
+
}) => any;
|
|
749
|
+
default: () => any;
|
|
750
|
+
}, {}>;
|
|
751
|
+
/**
|
|
752
|
+
* Type for enum field components that require valueToLabel
|
|
753
|
+
*/
|
|
754
|
+
type EnumFieldComponent<T, P extends Path<T>> = (props: Omit<SelectFieldProps<T>, 'name' | 'valueToLabel'> & {
|
|
755
|
+
valueToLabel: Record<FieldPathToEnum<T, P>, string>;
|
|
756
|
+
}, context?: any) => any;
|
|
757
|
+
/**
|
|
758
|
+
* Type for text field components
|
|
759
|
+
*/
|
|
760
|
+
type TextFieldComponent<T> = (props: Omit<TextFieldProps<T>, 'name'>, context?: any) => any;
|
|
761
|
+
/**
|
|
762
|
+
* Type for select field components (can work with string or enum fields)
|
|
763
|
+
*/
|
|
764
|
+
type SelectFieldComponent<T, P extends Path<T>> = (props: Omit<SelectFieldProps<T>, 'name'>, context?: any) => any;
|
|
765
|
+
/**
|
|
766
|
+
* Type for number field components
|
|
767
|
+
*/
|
|
768
|
+
type NumberFieldComponent<T> = (props: Omit<NumberFieldProps<T>, 'name'>, context?: any) => any;
|
|
769
|
+
/**
|
|
770
|
+
* Type for checkbox field components
|
|
771
|
+
*/
|
|
772
|
+
type CheckboxFieldComponent<T> = (props: Omit<CheckboxFieldProps<T>, 'name'>, context?: any) => any;
|
|
773
|
+
/**
|
|
774
|
+
* Type for date field components
|
|
775
|
+
*/
|
|
776
|
+
type DateFieldComponent<T> = (props: Omit<DateFieldProps<T>, 'name'>, context?: any) => any;
|
|
777
|
+
/**
|
|
778
|
+
* Generic field component type - fallback for any other field types
|
|
779
|
+
*/
|
|
780
|
+
type GenericFieldComponent = (props: any, context?: any) => any;
|
|
781
|
+
/**
|
|
782
|
+
* Maps a field path to its component type based on the field's actual type
|
|
783
|
+
* Enums are explicitly passed as FieldType = 'enum' since they can't be auto-detected
|
|
784
|
+
* Everything else is inferred from the actual TypeScript type at the path
|
|
785
|
+
*
|
|
786
|
+
* For string fields, we allow both TextFieldComponent and SelectFieldComponent
|
|
787
|
+
* because string fields can use inputType: 'select' in metadata to become SelectFields
|
|
788
|
+
*/
|
|
789
|
+
type FieldComponentType<T, P extends Path<T>, FieldType extends string = 'string'> = FieldType extends 'enum' ? EnumFieldComponent<T, P> : P extends keyof T ? T[P] extends Array<any> | ReadonlyArray<any> ? ArrayFieldComponent<T, P> : T[P] extends number ? NumberFieldComponent<T> : T[P] extends boolean ? CheckboxFieldComponent<T> : T[P] extends Date ? DateFieldComponent<T> : T[P] extends string ? // String fields can be either TextField or SelectField depending on inputType metadata
|
|
790
|
+
TextFieldComponent<T> | SelectFieldComponent<T, P> : GenericFieldComponent : GenericFieldComponent;
|
|
791
|
+
/**
|
|
792
|
+
* Type for the components object with PascalCase keys derived from field paths
|
|
793
|
+
* Each component gets the right type based on what the field actually is
|
|
794
|
+
*/
|
|
795
|
+
type ComponentsType<T> = {
|
|
796
|
+
[K in Path<T> as PathToPascalCase<K & string>]: FieldComponentType<T, K>;
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Types for field metadata in the form system
|
|
801
|
+
*/
|
|
802
|
+
/**
|
|
803
|
+
* Metadata about a form field
|
|
804
|
+
* This interface defines all the properties that describe a field's behavior and appearance
|
|
805
|
+
*/
|
|
806
|
+
interface FieldMetadata {
|
|
807
|
+
/** The full path to the field (e.g., 'user.firstName') */
|
|
808
|
+
path: string;
|
|
809
|
+
/** Whether the field is required (false if optional) */
|
|
810
|
+
isRequired: boolean;
|
|
811
|
+
/** The data type of the field */
|
|
812
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'enum' | 'date' | 'union';
|
|
813
|
+
/** The input type for rendering the field */
|
|
814
|
+
inputType?: 'text' | 'email' | 'url' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'array' | 'currency' | 'date' | 'time' | 'datetime-local' | 'file' | 'range' | 'search';
|
|
815
|
+
/** The display label for the field */
|
|
816
|
+
label?: string;
|
|
817
|
+
/** Placeholder text for the field */
|
|
818
|
+
placeholder?: string;
|
|
819
|
+
/** Minimum value (for number fields) or length (for string/array fields) */
|
|
820
|
+
min?: number;
|
|
821
|
+
/** Maximum value (for number fields) or length (for string/array fields) */
|
|
822
|
+
max?: number;
|
|
823
|
+
/** Regular expression pattern for validation */
|
|
824
|
+
pattern?: RegExp;
|
|
825
|
+
/** Options for enum fields */
|
|
826
|
+
options?: Array<{
|
|
827
|
+
value: string;
|
|
828
|
+
label: string;
|
|
829
|
+
}>;
|
|
830
|
+
/** Default value for the field */
|
|
831
|
+
defaultValue?: any;
|
|
832
|
+
/** Whether the field is an array */
|
|
833
|
+
isArray?: boolean;
|
|
834
|
+
/** Metadata for array element type */
|
|
835
|
+
arrayOf?: FieldMetadata;
|
|
836
|
+
/** Child field metadata for object types */
|
|
837
|
+
children?: Record<string, FieldMetadata>;
|
|
838
|
+
/** Available items for array fields */
|
|
839
|
+
availableItems?: any[];
|
|
840
|
+
/** Help text to display with the field */
|
|
841
|
+
helpText?: string;
|
|
842
|
+
/** For textarea fields, number of rows to display */
|
|
843
|
+
rows?: number;
|
|
844
|
+
/** For textarea fields, number of columns to display */
|
|
845
|
+
cols?: number;
|
|
846
|
+
/** For enum fields, map values to display labels */
|
|
847
|
+
valueToLabel?: Record<string, string>;
|
|
848
|
+
/** Whether the field should be disabled */
|
|
849
|
+
disabled?: boolean;
|
|
850
|
+
/** Whether the field should be hidden */
|
|
851
|
+
hidden?: boolean;
|
|
852
|
+
/** CSS class to apply to the field */
|
|
853
|
+
className?: string;
|
|
854
|
+
/** Whether the field should be focused on load */
|
|
855
|
+
autofocus?: boolean;
|
|
856
|
+
/** For number fields, the step value */
|
|
857
|
+
step?: number;
|
|
858
|
+
/** Autocomplete attribute for the field */
|
|
859
|
+
autocomplete?: string;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Types for schema metadata in the form system
|
|
864
|
+
*/
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Additional metadata that can be associated with schema fields
|
|
868
|
+
* This interface defines properties that can be attached to schema fields
|
|
869
|
+
* to customize their behavior and appearance
|
|
870
|
+
*/
|
|
871
|
+
interface SchemaFieldMetadata {
|
|
872
|
+
/** The input type for rendering the field */
|
|
873
|
+
inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local';
|
|
874
|
+
/** Placeholder text for the field */
|
|
875
|
+
placeholder?: string;
|
|
876
|
+
/** The display label for the field */
|
|
877
|
+
label?: string;
|
|
878
|
+
/** Help text to display with the field */
|
|
879
|
+
helpText?: string;
|
|
880
|
+
/** For textarea fields, number of rows to display */
|
|
881
|
+
rows?: number;
|
|
882
|
+
/** For textarea fields, number of columns to display */
|
|
883
|
+
cols?: number;
|
|
884
|
+
/** For enum fields, map values to display labels */
|
|
885
|
+
valueToLabel?: Record<string, string>;
|
|
886
|
+
/** Whether to hide validation errors */
|
|
887
|
+
hideError?: boolean;
|
|
888
|
+
/** Step value for numeric fields */
|
|
889
|
+
step?: number;
|
|
890
|
+
/** Any other custom properties */
|
|
891
|
+
[key: string]: any;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Type for the registry mapping field paths to their metadata
|
|
895
|
+
*/
|
|
896
|
+
type MetadataRegistry = Record<string, SchemaFieldMetadata>;
|
|
897
|
+
/**
|
|
898
|
+
* Type helper to extract all possible paths from a Zod schema
|
|
899
|
+
*/
|
|
900
|
+
type PathsOf<T extends z.ZodTypeAny> = Path<z.infer<T>>;
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Types for style creators in the form system
|
|
904
|
+
*/
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Interface for style creators that define how form components are rendered
|
|
908
|
+
* Each style creator is responsible for creating functional components for different form elements
|
|
909
|
+
*/
|
|
910
|
+
interface StyleCreators {
|
|
911
|
+
createForm: <FormType>() => FunctionalComponent<FormProps<FormType>, {}, any, {}>;
|
|
912
|
+
createSubmitButton: <FormType>() => FunctionalComponent<SubmitButtonProps<FormType>, {}, any, {}>;
|
|
913
|
+
createResetButton: <FormType>() => FunctionalComponent<ResetButtonProps<FormType>, {}, any, {}>;
|
|
914
|
+
createTextField: <FormType>() => FunctionalComponent<TextFieldProps<FormType>, {}, any, {}>;
|
|
915
|
+
createNumberField: <FormType>() => FunctionalComponent<NumberFieldProps<FormType>, {}, any, {}>;
|
|
916
|
+
createCurrencyField: <FormType>() => FunctionalComponent<CurrencyFieldProps<FormType>, {}, any, {}>;
|
|
917
|
+
createSelectField: <FormType>() => FunctionalComponent<SelectFieldProps<FormType>, {}, any, {}>;
|
|
918
|
+
createCheckboxField: <FormType>() => FunctionalComponent<CheckboxFieldProps<FormType>, {}, any, {}>;
|
|
919
|
+
createTextareaField: <FormType>() => FunctionalComponent<TextareaFieldProps<FormType>, {}, any, {}>;
|
|
920
|
+
createRadioField: <FormType>() => FunctionalComponent<RadioFieldProps<FormType>, {}, any, {}>;
|
|
921
|
+
createPasswordField: <FormType>() => FunctionalComponent<PasswordFieldProps<FormType>, {}, any, {}>;
|
|
922
|
+
createEmailField: <FormType>() => FunctionalComponent<EmailFieldProps<FormType>, {}, any, {}>;
|
|
923
|
+
createDateField: <FormType>() => FunctionalComponent<DateFieldProps<FormType>, {}, any, {}>;
|
|
924
|
+
createTelField: <FormType>() => FunctionalComponent<TelFieldProps<FormType>, {}, any, {}>;
|
|
925
|
+
createFileField: <FormType>() => FunctionalComponent<FileFieldProps<FormType>, {}, any, {}>;
|
|
926
|
+
createRangeField: <FormType>() => FunctionalComponent<RangeFieldProps<FormType>, {}, any, {}>;
|
|
927
|
+
createUrlField: <FormType>() => FunctionalComponent<UrlFieldProps<FormType>, {}, any, {}>;
|
|
928
|
+
createSearchField: <FormType>() => FunctionalComponent<SearchFieldProps<FormType>, {}, any, {}>;
|
|
929
|
+
createTimeField: <FormType>() => FunctionalComponent<TimeFieldProps<FormType>, {}, any, {}>;
|
|
930
|
+
createDateTimeLocalField: <FormType>() => FunctionalComponent<DateTimeLocalFieldProps<FormType>, {}, any, {}>;
|
|
931
|
+
createArrayField: <FormType, ItemType = any>() => FunctionalComponent<ArrayFieldProps<FormType, ItemType>, {}, {
|
|
932
|
+
itemRenderer: (props: {
|
|
933
|
+
item: ItemType;
|
|
934
|
+
index: number;
|
|
935
|
+
getFieldName: (fieldPath: string) => string;
|
|
936
|
+
}) => any;
|
|
937
|
+
availableItemRenderer: (props: {
|
|
938
|
+
item: ItemType;
|
|
939
|
+
index: number;
|
|
940
|
+
}) => any;
|
|
941
|
+
default: () => any;
|
|
942
|
+
}, {}>;
|
|
943
|
+
createTransferListField: <FormType, ItemType = any>() => FunctionalComponent<TransferListFieldProps<FormType, ItemType>, {}, {
|
|
944
|
+
itemRenderer: (props: {
|
|
945
|
+
item: ItemType;
|
|
946
|
+
index: number;
|
|
947
|
+
getFieldName: (fieldPath: string) => string;
|
|
948
|
+
}) => any;
|
|
949
|
+
availableItemRenderer: (props: {
|
|
950
|
+
item: ItemType;
|
|
951
|
+
index: number;
|
|
952
|
+
}) => any;
|
|
953
|
+
selectedItemRenderer: (props: {
|
|
954
|
+
item: ItemType;
|
|
955
|
+
index: number;
|
|
956
|
+
getFieldName: (fieldPath: string) => string;
|
|
957
|
+
}) => any;
|
|
958
|
+
default: () => any;
|
|
959
|
+
}, {}>;
|
|
960
|
+
createToppingsField: <FormType, ItemType = any>() => FunctionalComponent<ToppingsFieldProps<FormType, ItemType>, {}, {
|
|
961
|
+
itemRenderer: (props: {
|
|
962
|
+
item: ItemType;
|
|
963
|
+
index: number;
|
|
964
|
+
getFieldName: (fieldPath: string) => string;
|
|
965
|
+
}) => any;
|
|
966
|
+
availableItemRenderer: (props: {
|
|
967
|
+
item: ItemType;
|
|
968
|
+
index: number;
|
|
969
|
+
}) => any;
|
|
970
|
+
toppingRenderer: (props: {
|
|
971
|
+
topping: ItemType;
|
|
972
|
+
isSelected: boolean;
|
|
973
|
+
placement: string;
|
|
974
|
+
isExtra: boolean;
|
|
975
|
+
}) => any;
|
|
976
|
+
default: () => any;
|
|
977
|
+
}, {}>;
|
|
978
|
+
createFormErrorsSummary: () => FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
|
|
979
|
+
createDisplay: <FormType>() => FunctionalComponent<DisplayProps<FormType>, {}, any, {}>;
|
|
980
|
+
createDisplayField: <FormType>() => FunctionalComponent<DisplayFieldProps<FormType>, {}, any, {}>;
|
|
981
|
+
createDeleteModal: <FormType>() => FunctionalComponent<DeleteModalProps<FormType>, {}, any, {}>;
|
|
982
|
+
createDataTable: <FormType>() => FunctionalComponent<DataTableProps<FormType>, {}, {
|
|
983
|
+
[key: `cell-${string}`]: (props: {
|
|
984
|
+
value: any;
|
|
985
|
+
row: FormType;
|
|
986
|
+
field: string;
|
|
987
|
+
formattedValue: string;
|
|
988
|
+
}) => any;
|
|
989
|
+
'selection-actions': (props: {
|
|
990
|
+
hasSelection: boolean;
|
|
991
|
+
selectedCount: number;
|
|
992
|
+
selectedRows: FormType[];
|
|
993
|
+
onClearSelection: () => void;
|
|
994
|
+
triggerBulkAction: (action: string) => void;
|
|
995
|
+
}) => any;
|
|
996
|
+
default: () => any;
|
|
997
|
+
}, {}>;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Options for merging server data with local changes
|
|
1002
|
+
*/
|
|
1003
|
+
interface MergeOptions<T> {
|
|
1004
|
+
/**
|
|
1005
|
+
* Fields to preserve from local storage when merging with server data
|
|
1006
|
+
* If not provided, all fields will be merged with local data taking precedence
|
|
1007
|
+
*/
|
|
1008
|
+
preserveLocalFields?: (keyof T)[];
|
|
1009
|
+
/**
|
|
1010
|
+
* Custom merge function to handle complex merging logic
|
|
1011
|
+
* If provided, this will be used instead of the default merge strategy
|
|
1012
|
+
*/
|
|
1013
|
+
customMergeFunction?: (serverData: T, localData: T) => T;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Types for registered styles
|
|
1018
|
+
* This allows for autocomplete of registered style names
|
|
1019
|
+
*/
|
|
1020
|
+
/**
|
|
1021
|
+
* Union type of all registered style names
|
|
1022
|
+
* Update this when adding new built-in styles
|
|
1023
|
+
*/
|
|
1024
|
+
type BuiltInStyleName = 'daisy_ui' | 'plain';
|
|
1025
|
+
/**
|
|
1026
|
+
* Type for custom registered style names
|
|
1027
|
+
* This is a string literal type that can be extended by users
|
|
1028
|
+
*/
|
|
1029
|
+
type CustomStyleName = string;
|
|
1030
|
+
/**
|
|
1031
|
+
* Union type of all possible style names
|
|
1032
|
+
* This includes both built-in styles and custom styles
|
|
1033
|
+
*/
|
|
1034
|
+
type RegisteredStyleName = BuiltInStyleName | CustomStyleName;
|
|
1035
|
+
|
|
1036
|
+
declare const ZINIA_FORM_KEY = "ziniaForm";
|
|
1037
|
+
declare const ZINIA_FIELDS_KEY = "ziniaFields";
|
|
1038
|
+
declare const ZINIA_FIELDS_GENERIC_KEY = "ziniaFieldsGeneric";
|
|
1039
|
+
declare const ZINIA_FORM_SCHEMA_KEY = "ziniaFormSchema";
|
|
1040
|
+
type DataLoaderReturnTypes<T> = {
|
|
1041
|
+
[K in keyof T]: T[K] extends () => Promise<infer R> ? R : never;
|
|
1042
|
+
};
|
|
1043
|
+
/**
|
|
1044
|
+
* Create a type-safe form system using functional components
|
|
1045
|
+
*
|
|
1046
|
+
* @param schema The Zod schema for the form
|
|
1047
|
+
* @param options Form options
|
|
1048
|
+
* @returns Form API and components
|
|
1049
|
+
*/
|
|
1050
|
+
declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer<T>, extraData?: DataLoaderReturnTypes<Record<string, () => Promise<any>>>) => any, ExtraDataType = DataLoaderReturnTypes<Record<string, () => Promise<any>>>>(schema: T, options: {
|
|
1051
|
+
storeName: string;
|
|
1052
|
+
schemaId?: string;
|
|
1053
|
+
persistToLocalStorage?: boolean;
|
|
1054
|
+
initialValues?: Partial<z.infer<typeof schema>>;
|
|
1055
|
+
renderStyle?: RegisteredStyleName;
|
|
1056
|
+
autoProvide?: boolean;
|
|
1057
|
+
validateOnMount?: boolean;
|
|
1058
|
+
mergeOptions?: MergeOptions<z.infer<typeof schema>>;
|
|
1059
|
+
dataLoaders?: {
|
|
1060
|
+
[K in keyof ExtraDataType]?: () => Promise<ExtraDataType[K]>;
|
|
1061
|
+
};
|
|
1062
|
+
fetchData?: () => Promise<z.infer<typeof schema>>;
|
|
1063
|
+
calculationFn?: (values: z.infer<T>, extraData?: ExtraDataType) => CalcType;
|
|
1064
|
+
debug?: {
|
|
1065
|
+
all?: boolean;
|
|
1066
|
+
formState?: boolean;
|
|
1067
|
+
validation?: boolean;
|
|
1068
|
+
calculations?: boolean;
|
|
1069
|
+
persistence?: boolean;
|
|
1070
|
+
reactivity?: boolean;
|
|
1071
|
+
};
|
|
1072
|
+
}): {
|
|
1073
|
+
form: {
|
|
1074
|
+
storeName: string;
|
|
1075
|
+
values: z.TypeOf<T>;
|
|
1076
|
+
readonly calculatedValues: CalcType;
|
|
1077
|
+
readonly extraData: ExtraDataType;
|
|
1078
|
+
readonly isValid: boolean;
|
|
1079
|
+
readonly isDirty: boolean;
|
|
1080
|
+
isSubmitting: boolean;
|
|
1081
|
+
readonly hasAttemptedSubmit: boolean;
|
|
1082
|
+
readonly submitAttemptsCount: number;
|
|
1083
|
+
readonly errors: Record<string, string>;
|
|
1084
|
+
readonly touched: Record<string, boolean>;
|
|
1085
|
+
readonly dirty: Record<string, boolean>;
|
|
1086
|
+
fieldsMetadata: Record<string, FieldMetadata>;
|
|
1087
|
+
validate: (options?: {
|
|
1088
|
+
markErrorsAsTouched: boolean;
|
|
1089
|
+
}) => boolean;
|
|
1090
|
+
validateField: (path: string) => boolean;
|
|
1091
|
+
reset: (newInitialData?: z.TypeOf<T> | undefined) => void;
|
|
1092
|
+
setSubmitting: (value: boolean) => void;
|
|
1093
|
+
incrementSubmitAttempts: () => void;
|
|
1094
|
+
setSubmitError: (error: string | null) => void;
|
|
1095
|
+
readonly isReady: boolean;
|
|
1096
|
+
readonly isLoading: boolean;
|
|
1097
|
+
readonly loadError: string | null;
|
|
1098
|
+
readonly submitError: string | null;
|
|
1099
|
+
setLoading: (value: boolean) => void;
|
|
1100
|
+
setReady: (value: boolean) => void;
|
|
1101
|
+
setLoadError: (error: string | null) => void;
|
|
1102
|
+
getValue: (path: string) => any;
|
|
1103
|
+
setValue: (path: string, value: any) => void;
|
|
1104
|
+
touchField: (path: string) => void;
|
|
1105
|
+
isTouched: (path: string) => boolean;
|
|
1106
|
+
isDirtyField: (path: string) => boolean;
|
|
1107
|
+
resetField: (path: string) => void;
|
|
1108
|
+
hasError: (path: string) => boolean;
|
|
1109
|
+
getError: (path: string) => string;
|
|
1110
|
+
};
|
|
1111
|
+
ZiniaForm: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1112
|
+
ZiniaSubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1113
|
+
ZiniaResetButton: vue.FunctionalComponent<ResetButtonProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1114
|
+
ZiniaFormErrorsSummary: vue.FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
|
|
1115
|
+
zinia: ComponentsType<z.TypeOf<T>>;
|
|
1116
|
+
ziniaGeneric: {
|
|
1117
|
+
TextField: vue.FunctionalComponent<TextFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1118
|
+
NumberField: vue.FunctionalComponent<NumberFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1119
|
+
SelectField: vue.FunctionalComponent<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>>, {}, any, {}>;
|
|
1120
|
+
CheckboxField: vue.FunctionalComponent<CheckboxFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1121
|
+
TextareaField: vue.FunctionalComponent<TextareaFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1122
|
+
RadioField: vue.FunctionalComponent<RadioFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1123
|
+
FileField: vue.FunctionalComponent<FileFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1124
|
+
DateField: vue.FunctionalComponent<DateFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1125
|
+
TimeField: vue.FunctionalComponent<TimeFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1126
|
+
DateTimeLocalField: vue.FunctionalComponent<DateTimeLocalFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1127
|
+
RangeField: vue.FunctionalComponent<RangeFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1128
|
+
PasswordField: vue.FunctionalComponent<PasswordFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1129
|
+
EmailField: vue.FunctionalComponent<EmailFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1130
|
+
UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1131
|
+
TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1132
|
+
SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1133
|
+
ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1134
|
+
itemRenderer: (props: {
|
|
1135
|
+
item: any;
|
|
1136
|
+
index: number;
|
|
1137
|
+
getFieldName: (fieldPath: string) => string;
|
|
1138
|
+
}) => any;
|
|
1139
|
+
availableItemRenderer: (props: {
|
|
1140
|
+
item: any;
|
|
1141
|
+
index: number;
|
|
1142
|
+
}) => any;
|
|
1143
|
+
default: () => any;
|
|
1144
|
+
}, {}>;
|
|
1145
|
+
TransferListField: vue.FunctionalComponent<TransferListFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1146
|
+
itemRenderer: (props: {
|
|
1147
|
+
item: any;
|
|
1148
|
+
index: number;
|
|
1149
|
+
getFieldName: (fieldPath: string) => string;
|
|
1150
|
+
}) => any;
|
|
1151
|
+
availableItemRenderer: (props: {
|
|
1152
|
+
item: any;
|
|
1153
|
+
index: number;
|
|
1154
|
+
}) => any;
|
|
1155
|
+
selectedItemRenderer: (props: {
|
|
1156
|
+
item: any;
|
|
1157
|
+
index: number;
|
|
1158
|
+
getFieldName: (fieldPath: string) => string;
|
|
1159
|
+
}) => any;
|
|
1160
|
+
default: () => any;
|
|
1161
|
+
}, {}>;
|
|
1162
|
+
ToppingsField: vue.FunctionalComponent<ToppingsFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1163
|
+
itemRenderer: (props: {
|
|
1164
|
+
item: any;
|
|
1165
|
+
index: number;
|
|
1166
|
+
getFieldName: (fieldPath: string) => string;
|
|
1167
|
+
}) => any;
|
|
1168
|
+
availableItemRenderer: (props: {
|
|
1169
|
+
item: any;
|
|
1170
|
+
index: number;
|
|
1171
|
+
}) => any;
|
|
1172
|
+
toppingRenderer: (props: {
|
|
1173
|
+
topping: any;
|
|
1174
|
+
isSelected: boolean;
|
|
1175
|
+
placement: string;
|
|
1176
|
+
isExtra: boolean;
|
|
1177
|
+
}) => any;
|
|
1178
|
+
default: () => any;
|
|
1179
|
+
}, {}>;
|
|
1180
|
+
createTypedSelectField: <P extends Path<z.TypeOf<T>>>(fieldPath: P) => <E extends FieldPathToEnum<z.TypeOf<T>, P> = FieldPathToEnum<z.TypeOf<T>, P>>(props: Omit<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>>, "name" | "valueToLabel"> & {
|
|
1181
|
+
valueToLabel: Record<E, string>;
|
|
1182
|
+
}, context?: any) => any;
|
|
1183
|
+
typedSelectFields: { [K in Path<z.TypeOf<T>>]?: (<E extends FieldPathToEnum<z.TypeOf<T>, K> = FieldPathToEnum<z.TypeOf<T>, K>>(props: Omit<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>>, "name" | "valueToLabel"> & {
|
|
1184
|
+
valueToLabel: Record<E, string>;
|
|
1185
|
+
}, context?: any) => any) | undefined; };
|
|
1186
|
+
fields: Record<Path<z.TypeOf<T>>, any>;
|
|
1187
|
+
field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
|
|
1188
|
+
};
|
|
1189
|
+
load: () => Promise<void>;
|
|
1190
|
+
loadAllData: () => Promise<void>;
|
|
1191
|
+
refreshFormData: () => Promise<void>;
|
|
1192
|
+
clearSavedFormState: () => void;
|
|
1193
|
+
refreshData: (keys?: Array<keyof ExtraDataType>) => Promise<void>;
|
|
1194
|
+
};
|
|
1195
|
+
type UseFormType = ReturnType<typeof useForm>;
|
|
1196
|
+
type ZiniaForm = UseFormType['form'];
|
|
1197
|
+
type ZiniaFormFields = UseFormType['zinia'];
|
|
1198
|
+
type ZiniaFormGenericFields = UseFormType['ziniaGeneric'];
|
|
1199
|
+
type UseFormTyped<T extends z.ZodObject<any>, CalcType = any, ExtraDataType extends Record<string, any> = Record<string, any>> = ReturnType<typeof useForm<T, CalcType, ExtraDataType>>;
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Create base form components for a schema
|
|
1203
|
+
*
|
|
1204
|
+
* @param schema The Zod schema for the form
|
|
1205
|
+
* @param renderStyle The style to use for rendering
|
|
1206
|
+
* @returns Base form components (Form, SubmitButton, ResetButton)
|
|
1207
|
+
*/
|
|
1208
|
+
declare function createBaseComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
|
|
1209
|
+
Form: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1210
|
+
SubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1211
|
+
ResetButton: vue.FunctionalComponent<ResetButtonProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1212
|
+
FormErrorsSummary: vue.FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Functions for creating type-safe select fields
|
|
1217
|
+
*/
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Create a factory function that returns a properly typed SelectField based on the field path
|
|
1221
|
+
*
|
|
1222
|
+
* @param baseSelectField The base select field component
|
|
1223
|
+
* @param fieldPath The field path to create a select field for
|
|
1224
|
+
* @returns A factory function that creates a type-safe select field
|
|
1225
|
+
*/
|
|
1226
|
+
declare function createTypedSelectField<T, P extends Path<T>>(baseSelectField: FunctionalComponent<SelectFieldProps<T>>, fieldPath: P): <E extends FieldPathToEnum<T, P> = FieldPathToEnum<T, P>>(props: Omit<SelectFieldProps<T>, "name" | "valueToLabel"> & {
|
|
1227
|
+
valueToLabel: Record<E, string>;
|
|
1228
|
+
}, context?: any) => any;
|
|
1229
|
+
/**
|
|
1230
|
+
* Type-safe select field component with valueToLabel based on field path
|
|
1231
|
+
*/
|
|
1232
|
+
interface TypedSelectFieldComponent<T> {
|
|
1233
|
+
<P extends Path<T>>(props: Omit<SelectFieldProps<T>, 'valueToLabel'> & {
|
|
1234
|
+
name: P;
|
|
1235
|
+
valueToLabel?: Record<string, string>;
|
|
1236
|
+
}): ReturnType<FunctionalComponent>;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Functions for creating type-safe array fields
|
|
1241
|
+
*/
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Create a factory function that returns a properly typed ArrayField based on the field path
|
|
1245
|
+
* This preserves the ItemType so that Vue's template slots are properly typed
|
|
1246
|
+
*
|
|
1247
|
+
* @param baseArrayField The base array field component
|
|
1248
|
+
* @param fieldPath The field path to create an array field for
|
|
1249
|
+
* @param metadata Optional metadata to apply to the field
|
|
1250
|
+
* @returns A properly typed array field component with slot types preserved
|
|
1251
|
+
*/
|
|
1252
|
+
declare function createTypedArrayField<T, P extends Path<T>>(baseArrayField: FunctionalComponent<ArrayFieldProps<T, any>, {}, any, {}>, fieldPath: P, metadata?: FieldMetadata): FunctionalComponent<Omit<ArrayFieldProps<T, ArrayItemType<T, P>>, "name">, {}, {
|
|
1253
|
+
itemRenderer: (props: {
|
|
1254
|
+
item: ArrayItemType<T, P>;
|
|
1255
|
+
index: number;
|
|
1256
|
+
getFieldName: (fieldPath: string) => string;
|
|
1257
|
+
}) => any;
|
|
1258
|
+
availableItemRenderer: (props: {
|
|
1259
|
+
item: ArrayItemType<T, P>;
|
|
1260
|
+
index: number;
|
|
1261
|
+
}) => any;
|
|
1262
|
+
default: () => any;
|
|
1263
|
+
}, {}>;
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Generate field components for a schema based on metadata
|
|
1267
|
+
*
|
|
1268
|
+
* @param schema The Zod schema for the form
|
|
1269
|
+
* @param fieldsMetadata Metadata for form fields
|
|
1270
|
+
* @param renderStyle The style to use for rendering
|
|
1271
|
+
* @returns Generated field components
|
|
1272
|
+
*/
|
|
1273
|
+
declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
|
|
1274
|
+
generic: {
|
|
1275
|
+
TextField: vue.FunctionalComponent<TextFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1276
|
+
NumberField: vue.FunctionalComponent<NumberFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1277
|
+
SelectField: vue.FunctionalComponent<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>>, {}, any, {}>;
|
|
1278
|
+
CheckboxField: vue.FunctionalComponent<CheckboxFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1279
|
+
TextareaField: vue.FunctionalComponent<TextareaFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1280
|
+
RadioField: vue.FunctionalComponent<RadioFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1281
|
+
FileField: vue.FunctionalComponent<FileFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1282
|
+
DateField: vue.FunctionalComponent<DateFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1283
|
+
TimeField: vue.FunctionalComponent<TimeFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1284
|
+
DateTimeLocalField: vue.FunctionalComponent<DateTimeLocalFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1285
|
+
RangeField: vue.FunctionalComponent<RangeFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1286
|
+
PasswordField: vue.FunctionalComponent<PasswordFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1287
|
+
EmailField: vue.FunctionalComponent<EmailFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1288
|
+
UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1289
|
+
TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1290
|
+
SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1291
|
+
ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1292
|
+
itemRenderer: (props: {
|
|
1293
|
+
item: any;
|
|
1294
|
+
index: number;
|
|
1295
|
+
getFieldName: (fieldPath: string) => string;
|
|
1296
|
+
}) => any;
|
|
1297
|
+
availableItemRenderer: (props: {
|
|
1298
|
+
item: any;
|
|
1299
|
+
index: number;
|
|
1300
|
+
}) => any;
|
|
1301
|
+
default: () => any;
|
|
1302
|
+
}, {}>;
|
|
1303
|
+
TransferListField: vue.FunctionalComponent<TransferListFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1304
|
+
itemRenderer: (props: {
|
|
1305
|
+
item: any;
|
|
1306
|
+
index: number;
|
|
1307
|
+
getFieldName: (fieldPath: string) => string;
|
|
1308
|
+
}) => any;
|
|
1309
|
+
availableItemRenderer: (props: {
|
|
1310
|
+
item: any;
|
|
1311
|
+
index: number;
|
|
1312
|
+
}) => any;
|
|
1313
|
+
selectedItemRenderer: (props: {
|
|
1314
|
+
item: any;
|
|
1315
|
+
index: number;
|
|
1316
|
+
getFieldName: (fieldPath: string) => string;
|
|
1317
|
+
}) => any;
|
|
1318
|
+
default: () => any;
|
|
1319
|
+
}, {}>;
|
|
1320
|
+
ToppingsField: vue.FunctionalComponent<ToppingsFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1321
|
+
itemRenderer: (props: {
|
|
1322
|
+
item: any;
|
|
1323
|
+
index: number;
|
|
1324
|
+
getFieldName: (fieldPath: string) => string;
|
|
1325
|
+
}) => any;
|
|
1326
|
+
availableItemRenderer: (props: {
|
|
1327
|
+
item: any;
|
|
1328
|
+
index: number;
|
|
1329
|
+
}) => any;
|
|
1330
|
+
toppingRenderer: (props: {
|
|
1331
|
+
topping: any;
|
|
1332
|
+
isSelected: boolean;
|
|
1333
|
+
placement: string;
|
|
1334
|
+
isExtra: boolean;
|
|
1335
|
+
}) => any;
|
|
1336
|
+
default: () => any;
|
|
1337
|
+
}, {}>;
|
|
1338
|
+
createTypedSelectField: <P extends Path<z.TypeOf<T>>>(fieldPath: P) => <E extends FieldPathToEnum<z.TypeOf<T>, P> = FieldPathToEnum<z.TypeOf<T>, P>>(props: Omit<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>>, "name" | "valueToLabel"> & {
|
|
1339
|
+
valueToLabel: Record<E, string>;
|
|
1340
|
+
}, context?: any) => any;
|
|
1341
|
+
typedSelectFields: { [K in Path<z.TypeOf<T>>]?: (<E extends FieldPathToEnum<z.TypeOf<T>, K> = FieldPathToEnum<z.TypeOf<T>, K>>(props: Omit<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>>, "name" | "valueToLabel"> & {
|
|
1342
|
+
valueToLabel: Record<E, string>;
|
|
1343
|
+
}, context?: any) => any) | undefined; };
|
|
1344
|
+
fields: Record<Path<z.TypeOf<T>>, any>;
|
|
1345
|
+
field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
|
|
1346
|
+
};
|
|
1347
|
+
typed: ComponentsType<z.TypeOf<T>>;
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Create base display components using registered styles
|
|
1352
|
+
*
|
|
1353
|
+
* @param schema The Zod schema for the data
|
|
1354
|
+
* @param styleName The style to use for rendering
|
|
1355
|
+
* @returns Base display components
|
|
1356
|
+
*/
|
|
1357
|
+
declare function createBaseDisplayComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
|
|
1358
|
+
ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Type for display field components
|
|
1363
|
+
*/
|
|
1364
|
+
type DisplayFieldComponent<T, P extends Path<T>, _FieldType extends string = 'string'> = (props: {
|
|
1365
|
+
name?: P;
|
|
1366
|
+
label?: string;
|
|
1367
|
+
hideLabel?: boolean;
|
|
1368
|
+
description?: string;
|
|
1369
|
+
format?: 'default' | 'currency' | 'date' | 'datetime' | 'boolean' | 'email' | 'url' | 'phone' | 'number';
|
|
1370
|
+
emptyText?: string;
|
|
1371
|
+
class?: string | string[];
|
|
1372
|
+
size?: string;
|
|
1373
|
+
variant?: string;
|
|
1374
|
+
copyable?: boolean;
|
|
1375
|
+
valueToLabel?: Record<string, string>;
|
|
1376
|
+
separator?: string;
|
|
1377
|
+
itemRenderer?: (item: any, index: number) => string;
|
|
1378
|
+
maxItems?: number;
|
|
1379
|
+
}, context?: any) => any;
|
|
1380
|
+
/**
|
|
1381
|
+
* Type for the display components object with PascalCase keys derived from field paths
|
|
1382
|
+
* This mirrors the ComponentsType from the form system but with Display suffix
|
|
1383
|
+
*/
|
|
1384
|
+
type DisplayComponentsType<T> = {
|
|
1385
|
+
[K in Path<T> as `${PathToPascalCase<K & string>}` extends `${infer Base}Field` ? `${Base}Display` : `${PathToPascalCase<K & string>}Display`]: DisplayFieldComponent<T, K>;
|
|
1386
|
+
};
|
|
1387
|
+
/**
|
|
1388
|
+
* Generate display field components for a schema based on metadata
|
|
1389
|
+
*
|
|
1390
|
+
* @param schema The Zod schema for the data
|
|
1391
|
+
* @param fieldsMetadata Metadata for fields
|
|
1392
|
+
* @param renderStyle The style to use for rendering
|
|
1393
|
+
* @returns Generated display field components
|
|
1394
|
+
*/
|
|
1395
|
+
declare function generateDisplayComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
|
|
1396
|
+
generic: {
|
|
1397
|
+
DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1398
|
+
fields: { [K in Path<z.TypeOf<T>>]: DisplayFieldComponent<z.TypeOf<T>, K, string>; };
|
|
1399
|
+
field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
|
|
1400
|
+
};
|
|
1401
|
+
typed: DisplayComponentsType<z.TypeOf<T>>;
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
interface NoDataDisplayProps {
|
|
1405
|
+
message?: string;
|
|
1406
|
+
class?: string;
|
|
1407
|
+
variant?: 'info' | 'warning';
|
|
1408
|
+
}
|
|
1409
|
+
declare const NoDataDisplay: FunctionalComponent<NoDataDisplayProps>;
|
|
1410
|
+
|
|
1411
|
+
interface ErrorDisplayProps {
|
|
1412
|
+
error: string | Error | unknown;
|
|
1413
|
+
class?: string;
|
|
1414
|
+
variant?: 'error' | 'warning' | 'info';
|
|
1415
|
+
}
|
|
1416
|
+
declare const ErrorDisplay: FunctionalComponent<ErrorDisplayProps>;
|
|
1417
|
+
|
|
1418
|
+
interface LoadingDisplayProps {
|
|
1419
|
+
message?: string;
|
|
1420
|
+
size?: 'sm' | 'md' | 'lg';
|
|
1421
|
+
class?: string;
|
|
1422
|
+
}
|
|
1423
|
+
declare const LoadingDisplay: FunctionalComponent<LoadingDisplayProps>;
|
|
1424
|
+
|
|
1425
|
+
declare const ZINIA_DISPLAY_KEY = "ziniaDisplay";
|
|
1426
|
+
declare const ZINIA_DISPLAY_FIELDS_KEY = "ziniaDisplayFields";
|
|
1427
|
+
declare const ZINIA_DISPLAY_FIELDS_GENERIC_KEY = "ziniaDisplayFieldsGeneric";
|
|
1428
|
+
declare const ZINIA_DISPLAY_SCHEMA_KEY = "ziniaDisplaySchema";
|
|
1429
|
+
interface DisplayOptions<TData, TExtra extends Record<string, any>> {
|
|
1430
|
+
data?: TData | Ref<TData>;
|
|
1431
|
+
schemaId?: string;
|
|
1432
|
+
storeName?: string;
|
|
1433
|
+
renderStyle?: RegisteredStyleName;
|
|
1434
|
+
autoProvide?: boolean;
|
|
1435
|
+
loading?: boolean | Ref<boolean>;
|
|
1436
|
+
error?: string | null | Ref<string | null>;
|
|
1437
|
+
fetchData?: () => Promise<TData>;
|
|
1438
|
+
dataLoaders?: {
|
|
1439
|
+
[K in keyof TExtra]?: () => Promise<TExtra[K]>;
|
|
1440
|
+
};
|
|
1441
|
+
autoLoad?: boolean;
|
|
1442
|
+
onLoad?: (data: TData) => void;
|
|
1443
|
+
onError?: (error: Error) => void;
|
|
1444
|
+
debug?: boolean;
|
|
1445
|
+
}
|
|
1446
|
+
declare function useDisplay<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>>(schema: TSchema, options?: DisplayOptions<z.infer<TSchema>, TExtra>): {
|
|
1447
|
+
display: {
|
|
1448
|
+
storeName: string;
|
|
1449
|
+
readonly data: z.TypeOf<TSchema> | null;
|
|
1450
|
+
readonly extraData: TExtra;
|
|
1451
|
+
readonly isLoading: boolean;
|
|
1452
|
+
readonly isReady: boolean;
|
|
1453
|
+
readonly error: string | null;
|
|
1454
|
+
readonly lastLoadTime: number | null;
|
|
1455
|
+
fieldsMetadata: Record<string, FieldMetadata>;
|
|
1456
|
+
readonly isAsyncMode: boolean;
|
|
1457
|
+
load: (options_?: {
|
|
1458
|
+
data?: boolean;
|
|
1459
|
+
extra?: boolean;
|
|
1460
|
+
specificLoaders?: Array<keyof TExtra>;
|
|
1461
|
+
}) => Promise<void>;
|
|
1462
|
+
loadData: () => Promise<void>;
|
|
1463
|
+
loadExtraData: (keys?: Array<keyof TExtra>) => Promise<void>;
|
|
1464
|
+
loadAllData: () => Promise<void>;
|
|
1465
|
+
refreshData: () => Promise<void>;
|
|
1466
|
+
clear: () => void;
|
|
1467
|
+
getValue: (path: string) => any;
|
|
1468
|
+
};
|
|
1469
|
+
ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<TSchema>>, {}, any, {}>;
|
|
1470
|
+
LoadingDisplay: vue.FunctionalComponent<LoadingDisplayProps, {}, any, {}>;
|
|
1471
|
+
ErrorDisplay: vue.FunctionalComponent<ErrorDisplayProps, {}, any, {}>;
|
|
1472
|
+
NoDataDisplay: vue.FunctionalComponent<NoDataDisplayProps, {}, any, {}>;
|
|
1473
|
+
zinia: DisplayComponentsType<z.TypeOf<TSchema>>;
|
|
1474
|
+
ziniaGeneric: {
|
|
1475
|
+
DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<TSchema>>, {}, any, {}>;
|
|
1476
|
+
fields: { [K in Path<z.TypeOf<TSchema>>]: DisplayFieldComponent<z.TypeOf<TSchema>, K, string>; };
|
|
1477
|
+
field: <P extends Path<z.TypeOf<TSchema>>>(path: P) => any;
|
|
1478
|
+
};
|
|
1479
|
+
load: (options_?: {
|
|
1480
|
+
data?: boolean;
|
|
1481
|
+
extra?: boolean;
|
|
1482
|
+
specificLoaders?: Array<keyof TExtra>;
|
|
1483
|
+
}) => Promise<void>;
|
|
1484
|
+
loadData: () => Promise<void>;
|
|
1485
|
+
loadExtraData: (keys?: Array<keyof TExtra>) => Promise<void>;
|
|
1486
|
+
loadAllData: () => Promise<void>;
|
|
1487
|
+
refreshData: () => Promise<void>;
|
|
1488
|
+
clear: () => void;
|
|
1489
|
+
};
|
|
1490
|
+
type UseDisplayType<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = ReturnType<typeof useDisplay<TSchema, TExtra>>;
|
|
1491
|
+
type ZiniaDisplay<TSchema extends z.ZodObject<any> = z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['display'];
|
|
1492
|
+
type ZiniaDisplayFields<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['zinia'];
|
|
1493
|
+
type ZiniaDisplayGenericFields<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['ziniaGeneric'];
|
|
1494
|
+
|
|
1495
|
+
declare const ZINIA_DATA_TABLE_KEY = "ziniaDataTable";
|
|
1496
|
+
declare const ZINIA_DATA_TABLE_COLUMNS_KEY = "ziniaDataTableColumns";
|
|
1497
|
+
declare const ZINIA_DATA_TABLE_OPTIONS_KEY = "ziniaDataTableOptions";
|
|
1498
|
+
declare const ZINIA_DATA_TABLE_ACTIONS_KEY = "ziniaDataTableActions";
|
|
1499
|
+
declare const ZINIA_DATA_TABLE_SEARCH_INPUT_KEY = "ziniaDataTableSearchInput";
|
|
1500
|
+
declare const ZINIA_DATA_TABLE_FILTER_INPUTS_KEY = "ziniaDataTableFilterInputs";
|
|
1501
|
+
declare const ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY = "ziniaDataTableFilterOperators";
|
|
1502
|
+
declare const ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY = "ziniaDataTableFilterOptionsState";
|
|
1503
|
+
declare const ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY = "ziniaDataTableFilterOptionsLoading";
|
|
1504
|
+
declare const ZINIA_DATA_TABLE_NAME_KEY = "ziniaDataTableName";
|
|
1505
|
+
interface FilterValue {
|
|
1506
|
+
value: any;
|
|
1507
|
+
operator: 'eq' | 'contains' | 'gt' | 'lt' | 'in' | 'between';
|
|
1508
|
+
}
|
|
1509
|
+
interface BaseActionItem<TData> {
|
|
1510
|
+
key: string;
|
|
1511
|
+
/**
|
|
1512
|
+
* Label for the action. Optional - you can have icon-only, label-only, or both.
|
|
1513
|
+
* At least one of label or icon must be provided.
|
|
1514
|
+
*/
|
|
1515
|
+
label?: string;
|
|
1516
|
+
/**
|
|
1517
|
+
* Icon for the action. Optional - you can have icon-only, label-only, or both.
|
|
1518
|
+
* At least one of label or icon must be provided.
|
|
1519
|
+
*
|
|
1520
|
+
* Supports multiple formats:
|
|
1521
|
+
* - SVG string: ActionIcons.edit or '<svg>...</svg>'
|
|
1522
|
+
* - Vue component: import { PencilIcon } from '@heroicons/vue/24/outline'; then use PencilIcon
|
|
1523
|
+
* - Function: (row) => row.status === 'active' ? EditIcon : ViewIcon
|
|
1524
|
+
*/
|
|
1525
|
+
icon?: string | any | ((row: TData) => any);
|
|
1526
|
+
variant?: 'primary' | 'secondary' | 'accent' | 'ghost' | 'info' | 'success' | 'warning' | 'error';
|
|
1527
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
1528
|
+
visible?: (row: TData) => boolean;
|
|
1529
|
+
disabled?: (row: TData) => boolean;
|
|
1530
|
+
}
|
|
1531
|
+
interface ButtonActionItem<TData> extends BaseActionItem<TData> {
|
|
1532
|
+
type?: 'button';
|
|
1533
|
+
onClick: (row: TData, action: ActionItem<TData>) => void | Promise<void>;
|
|
1534
|
+
}
|
|
1535
|
+
interface LinkActionItem<TData> extends BaseActionItem<TData> {
|
|
1536
|
+
type: 'link';
|
|
1537
|
+
href: (row: TData) => string;
|
|
1538
|
+
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
1539
|
+
}
|
|
1540
|
+
type ActionItem<TData> = ButtonActionItem<TData> | LinkActionItem<TData>;
|
|
1541
|
+
interface ActionsConfig<TData> {
|
|
1542
|
+
column?: {
|
|
1543
|
+
label?: string;
|
|
1544
|
+
align?: 'left' | 'center' | 'right';
|
|
1545
|
+
width?: number;
|
|
1546
|
+
};
|
|
1547
|
+
items: ActionItem<TData>[];
|
|
1548
|
+
}
|
|
1549
|
+
interface ColumnDefinition<TData, TField extends keyof TData> {
|
|
1550
|
+
field?: TField;
|
|
1551
|
+
label: string;
|
|
1552
|
+
sortable?: boolean;
|
|
1553
|
+
filterable?: boolean;
|
|
1554
|
+
searchable?: boolean;
|
|
1555
|
+
align?: 'left' | 'center' | 'right';
|
|
1556
|
+
textWrap?: 'truncate' | 'wrap';
|
|
1557
|
+
format?: (value: TData[TField], row: TData) => string;
|
|
1558
|
+
render?: (value: TData[TField], row: TData) => any;
|
|
1559
|
+
filterType?: 'text' | 'select' | 'number' | 'boolean';
|
|
1560
|
+
filterOptions?: any[];
|
|
1561
|
+
filterOptionsLoader?: () => Promise<any[]>;
|
|
1562
|
+
sortLabels?: {
|
|
1563
|
+
asc: string;
|
|
1564
|
+
desc: string;
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
interface FetchDataParams<TData> {
|
|
1568
|
+
page: number;
|
|
1569
|
+
pageSize: number;
|
|
1570
|
+
sort: {
|
|
1571
|
+
field: keyof TData;
|
|
1572
|
+
direction: 'asc' | 'desc';
|
|
1573
|
+
} | null;
|
|
1574
|
+
filters: Record<string, FilterValue>;
|
|
1575
|
+
search: {
|
|
1576
|
+
query: string;
|
|
1577
|
+
searchableFields: Array<keyof TData>;
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
interface FetchDataResult<TData> {
|
|
1581
|
+
data: TData[];
|
|
1582
|
+
total: number;
|
|
1583
|
+
}
|
|
1584
|
+
interface DataTableOptions<TData> {
|
|
1585
|
+
fetchData: (params: FetchDataParams<TData>) => Promise<FetchDataResult<TData>>;
|
|
1586
|
+
columns: {
|
|
1587
|
+
[K in keyof TData]?: ColumnDefinition<TData, K>;
|
|
1588
|
+
} & {
|
|
1589
|
+
[key: string]: ColumnDefinition<TData, any>;
|
|
1590
|
+
};
|
|
1591
|
+
actions?: ActionsConfig<TData>;
|
|
1592
|
+
pagination?: {
|
|
1593
|
+
pageSize?: number;
|
|
1594
|
+
pageSizeOptions?: number[];
|
|
1595
|
+
};
|
|
1596
|
+
selection?: {
|
|
1597
|
+
mode?: 'single' | 'multiple' | 'none';
|
|
1598
|
+
rowKey?: keyof TData;
|
|
1599
|
+
};
|
|
1600
|
+
sorting?: {
|
|
1601
|
+
default?: {
|
|
1602
|
+
field: keyof TData;
|
|
1603
|
+
direction: 'asc' | 'desc';
|
|
1604
|
+
};
|
|
1605
|
+
};
|
|
1606
|
+
search?: {
|
|
1607
|
+
searchableFields?: Array<keyof TData>;
|
|
1608
|
+
};
|
|
1609
|
+
renderStyle?: RegisteredStyleName;
|
|
1610
|
+
schemaId?: string;
|
|
1611
|
+
name?: string;
|
|
1612
|
+
autoProvide?: boolean;
|
|
1613
|
+
debug?: boolean;
|
|
1614
|
+
onLoad?: (data: TData[]) => void;
|
|
1615
|
+
onError?: (error: Error) => void;
|
|
1616
|
+
onSelectionChange?: (selectedItems: TData[], selectionInfo: {
|
|
1617
|
+
count: number;
|
|
1618
|
+
isAllSelected: boolean;
|
|
1619
|
+
}) => void;
|
|
1620
|
+
onBulkAction?: (action: string, selectedItems: TData[]) => void;
|
|
1621
|
+
}
|
|
1622
|
+
declare function useDataTable<TSchema extends z.ZodObject<any>>(schema: TSchema, options: DataTableOptions<z.infer<TSchema>>): {
|
|
1623
|
+
table: {
|
|
1624
|
+
readonly data: z.TypeOf<TSchema>[];
|
|
1625
|
+
readonly isLoading: boolean;
|
|
1626
|
+
readonly error: string | null;
|
|
1627
|
+
readonly hasData: boolean;
|
|
1628
|
+
readonly isEmpty: boolean;
|
|
1629
|
+
readonly hasError: boolean;
|
|
1630
|
+
readonly lastLoadTime: number | null;
|
|
1631
|
+
pagination: {
|
|
1632
|
+
readonly currentPage: number;
|
|
1633
|
+
readonly pageSize: number;
|
|
1634
|
+
readonly totalPages: number;
|
|
1635
|
+
readonly totalRows: number;
|
|
1636
|
+
readonly canGoNext: boolean;
|
|
1637
|
+
readonly canGoPrev: boolean;
|
|
1638
|
+
readonly currentPageStart: number;
|
|
1639
|
+
readonly currentPageEnd: number;
|
|
1640
|
+
readonly hasTotal: boolean;
|
|
1641
|
+
};
|
|
1642
|
+
sorting: {
|
|
1643
|
+
readonly field: keyof z.TypeOf<TSchema> | null;
|
|
1644
|
+
readonly direction: "asc" | "desc";
|
|
1645
|
+
};
|
|
1646
|
+
filters: {
|
|
1647
|
+
readonly active: Record<string, FilterValue>;
|
|
1648
|
+
readonly count: number;
|
|
1649
|
+
};
|
|
1650
|
+
search: {
|
|
1651
|
+
readonly query: string;
|
|
1652
|
+
readonly searchableFields: Array<keyof z.TypeOf<TSchema>>;
|
|
1653
|
+
};
|
|
1654
|
+
selection: {
|
|
1655
|
+
readonly selectedRows: z.TypeOf<TSchema>[];
|
|
1656
|
+
readonly selectedCount: number;
|
|
1657
|
+
readonly isAllSelected: boolean;
|
|
1658
|
+
readonly hasSelection: boolean;
|
|
1659
|
+
};
|
|
1660
|
+
load: () => Promise<void>;
|
|
1661
|
+
refresh: () => Promise<void>;
|
|
1662
|
+
sort: (field: keyof z.TypeOf<TSchema>, direction?: "asc" | "desc") => Promise<void>;
|
|
1663
|
+
clearSort: () => Promise<void>;
|
|
1664
|
+
setFilter: (field: keyof z.TypeOf<TSchema>, value: any, operator?: FilterValue["operator"]) => Promise<void>;
|
|
1665
|
+
clearFilter: (field: keyof z.TypeOf<TSchema>) => Promise<void>;
|
|
1666
|
+
clearAllFilters: () => Promise<void>;
|
|
1667
|
+
setSearch: (query: string) => Promise<void>;
|
|
1668
|
+
clearSearch: () => Promise<void>;
|
|
1669
|
+
goToPage: (page: number) => Promise<void>;
|
|
1670
|
+
setPageSize: (size: number) => Promise<void>;
|
|
1671
|
+
nextPage: () => Promise<void>;
|
|
1672
|
+
prevPage: () => Promise<void>;
|
|
1673
|
+
selectRow: (row: z.TypeOf<TSchema>) => void;
|
|
1674
|
+
selectAll: () => void;
|
|
1675
|
+
clearSelection: () => void;
|
|
1676
|
+
isRowSelected: (row: z.TypeOf<TSchema>) => boolean;
|
|
1677
|
+
triggerBulkAction: (action: string) => void;
|
|
1678
|
+
ui: {
|
|
1679
|
+
sortDrawerOpen: vue.Ref<boolean, boolean>;
|
|
1680
|
+
openSortDrawer: () => boolean;
|
|
1681
|
+
closeSortDrawer: () => boolean;
|
|
1682
|
+
};
|
|
1683
|
+
fieldsMetadata: Record<string, FieldMetadata>;
|
|
1684
|
+
columns: (z.TypeOf<TSchema> extends infer T ? { [K in keyof T]?: ColumnDefinition<z.TypeOf<TSchema>, K> | undefined; } : never) & {
|
|
1685
|
+
[key: string]: ColumnDefinition<z.TypeOf<TSchema>, any>;
|
|
1686
|
+
};
|
|
1687
|
+
};
|
|
1688
|
+
ZiniaDataTable: vue.FunctionalComponent<DataTableProps<z.TypeOf<TSchema>>, {}, {
|
|
1689
|
+
[key: `cell-${string}`]: (props: {
|
|
1690
|
+
value: any;
|
|
1691
|
+
row: z.TypeOf<TSchema>;
|
|
1692
|
+
field: string;
|
|
1693
|
+
formattedValue: string;
|
|
1694
|
+
}) => any;
|
|
1695
|
+
'selection-actions': (props: {
|
|
1696
|
+
hasSelection: boolean;
|
|
1697
|
+
selectedCount: number;
|
|
1698
|
+
selectedRows: z.TypeOf<TSchema>[];
|
|
1699
|
+
onClearSelection: () => void;
|
|
1700
|
+
triggerBulkAction: (action: string) => void;
|
|
1701
|
+
}) => any;
|
|
1702
|
+
default: () => any;
|
|
1703
|
+
}, {}>;
|
|
1704
|
+
load: () => Promise<void>;
|
|
1705
|
+
refresh: () => Promise<void>;
|
|
1706
|
+
sort: (field: keyof z.TypeOf<TSchema>, direction?: "asc" | "desc") => Promise<void>;
|
|
1707
|
+
clearSort: () => Promise<void>;
|
|
1708
|
+
setFilter: (field: keyof z.TypeOf<TSchema>, value: any, operator?: FilterValue["operator"]) => Promise<void>;
|
|
1709
|
+
clearFilter: (field: keyof z.TypeOf<TSchema>) => Promise<void>;
|
|
1710
|
+
clearAllFilters: () => Promise<void>;
|
|
1711
|
+
setSearch: (query: string) => Promise<void>;
|
|
1712
|
+
clearSearch: () => Promise<void>;
|
|
1713
|
+
goToPage: (page: number) => Promise<void>;
|
|
1714
|
+
setPageSize: (size: number) => Promise<void>;
|
|
1715
|
+
nextPage: () => Promise<void>;
|
|
1716
|
+
prevPage: () => Promise<void>;
|
|
1717
|
+
selectRow: (row: z.TypeOf<TSchema>) => void;
|
|
1718
|
+
selectAll: () => void;
|
|
1719
|
+
clearSelection: () => void;
|
|
1720
|
+
isRowSelected: (row: z.TypeOf<TSchema>) => boolean;
|
|
1721
|
+
};
|
|
1722
|
+
type UseDataTableType<TSchema extends z.ZodObject<any>> = ReturnType<typeof useDataTable<TSchema>>;
|
|
1723
|
+
type ZiniaDataTable<TSchema extends z.ZodObject<any>> = UseDataTableType<TSchema>['table'];
|
|
1724
|
+
type DataTableColumns<TData> = {
|
|
1725
|
+
[K in keyof TData]?: ColumnDefinition<TData, K>;
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
interface CursorFetchParams<TData> {
|
|
1729
|
+
cursor?: string;
|
|
1730
|
+
pageSize: number;
|
|
1731
|
+
sort: {
|
|
1732
|
+
field: keyof TData;
|
|
1733
|
+
direction: 'asc' | 'desc';
|
|
1734
|
+
} | null;
|
|
1735
|
+
filters: Record<string, any>;
|
|
1736
|
+
search: {
|
|
1737
|
+
query: string;
|
|
1738
|
+
searchableFields: Array<keyof TData>;
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
interface CursorFetchResult<TData> {
|
|
1742
|
+
data: TData[];
|
|
1743
|
+
total?: number;
|
|
1744
|
+
hasNextPage: boolean;
|
|
1745
|
+
hasPreviousPage: boolean;
|
|
1746
|
+
prevPageCursor?: string;
|
|
1747
|
+
nextPageCursor?: string;
|
|
1748
|
+
}
|
|
1749
|
+
interface CursorDataTableOptions<TData> {
|
|
1750
|
+
fetchData: (params: CursorFetchParams<TData>) => Promise<CursorFetchResult<TData>>;
|
|
1751
|
+
columns: {
|
|
1752
|
+
[K in keyof TData]?: ColumnDefinition<TData, K>;
|
|
1753
|
+
} & {
|
|
1754
|
+
[key: string]: ColumnDefinition<TData, any>;
|
|
1755
|
+
};
|
|
1756
|
+
actions?: ActionsConfig<TData>;
|
|
1757
|
+
pagination?: {
|
|
1758
|
+
pageSize?: number;
|
|
1759
|
+
pageSizeOptions?: number[];
|
|
1760
|
+
};
|
|
1761
|
+
selection?: {
|
|
1762
|
+
mode?: 'single' | 'multiple' | 'none';
|
|
1763
|
+
rowKey?: keyof TData;
|
|
1764
|
+
};
|
|
1765
|
+
sorting?: {
|
|
1766
|
+
default?: {
|
|
1767
|
+
field: keyof TData;
|
|
1768
|
+
direction: 'asc' | 'desc';
|
|
1769
|
+
};
|
|
1770
|
+
};
|
|
1771
|
+
search?: {
|
|
1772
|
+
searchableFields?: Array<keyof TData>;
|
|
1773
|
+
};
|
|
1774
|
+
renderStyle?: RegisteredStyleName;
|
|
1775
|
+
schemaId?: string;
|
|
1776
|
+
name?: string;
|
|
1777
|
+
autoProvide?: boolean;
|
|
1778
|
+
debug?: boolean;
|
|
1779
|
+
onLoad?: (data: TData[]) => void;
|
|
1780
|
+
onError?: (error: Error) => void;
|
|
1781
|
+
onSelectionChange?: (selectedItems: TData[], selectionInfo: {
|
|
1782
|
+
count: number;
|
|
1783
|
+
isAllSelected: boolean;
|
|
1784
|
+
}) => void;
|
|
1785
|
+
onBulkAction?: (action: string, selectedItems: TData[]) => void;
|
|
1786
|
+
}
|
|
1787
|
+
declare function useCursorDataTable<TSchema extends z.ZodObject<any>>(schema: TSchema, options: CursorDataTableOptions<z.infer<TSchema>>): {
|
|
1788
|
+
table: {
|
|
1789
|
+
readonly data: z.TypeOf<TSchema>[];
|
|
1790
|
+
readonly isLoading: boolean;
|
|
1791
|
+
readonly error: string | null;
|
|
1792
|
+
readonly hasData: boolean;
|
|
1793
|
+
readonly isEmpty: boolean;
|
|
1794
|
+
readonly hasError: boolean;
|
|
1795
|
+
readonly lastLoadTime: number | null;
|
|
1796
|
+
pagination: {
|
|
1797
|
+
readonly currentPage: number;
|
|
1798
|
+
readonly pageSize: number;
|
|
1799
|
+
readonly totalPages: number;
|
|
1800
|
+
readonly totalRows: number;
|
|
1801
|
+
readonly hasTotal: boolean;
|
|
1802
|
+
readonly canGoNext: boolean;
|
|
1803
|
+
readonly canGoPrev: boolean;
|
|
1804
|
+
readonly currentPageStart: number;
|
|
1805
|
+
readonly currentPageEnd: number;
|
|
1806
|
+
};
|
|
1807
|
+
sorting: {
|
|
1808
|
+
readonly field: keyof z.TypeOf<TSchema> | null;
|
|
1809
|
+
readonly direction: "asc" | "desc";
|
|
1810
|
+
};
|
|
1811
|
+
filters: {
|
|
1812
|
+
readonly active: Record<string, any>;
|
|
1813
|
+
readonly count: number;
|
|
1814
|
+
};
|
|
1815
|
+
search: {
|
|
1816
|
+
readonly query: string;
|
|
1817
|
+
readonly searchableFields: Array<keyof z.TypeOf<TSchema>>;
|
|
1818
|
+
};
|
|
1819
|
+
selection: {
|
|
1820
|
+
readonly selectedRows: z.TypeOf<TSchema>[];
|
|
1821
|
+
readonly selectedCount: number;
|
|
1822
|
+
readonly isAllSelected: boolean;
|
|
1823
|
+
readonly hasSelection: boolean;
|
|
1824
|
+
};
|
|
1825
|
+
load: () => Promise<void>;
|
|
1826
|
+
refresh: () => Promise<void>;
|
|
1827
|
+
sort: (field: keyof z.TypeOf<TSchema>, direction?: "asc" | "desc") => Promise<void>;
|
|
1828
|
+
clearSort: () => Promise<void>;
|
|
1829
|
+
setFilter: (field: keyof z.TypeOf<TSchema>, value: any, operator?: any) => Promise<void>;
|
|
1830
|
+
clearFilter: (field: keyof z.TypeOf<TSchema>) => Promise<void>;
|
|
1831
|
+
clearAllFilters: () => Promise<void>;
|
|
1832
|
+
setSearch: (query: string) => Promise<void>;
|
|
1833
|
+
clearSearch: () => Promise<void>;
|
|
1834
|
+
nextPage: () => Promise<void>;
|
|
1835
|
+
prevPage: () => Promise<void>;
|
|
1836
|
+
firstPage: () => Promise<void>;
|
|
1837
|
+
setPageSize: (size: number) => Promise<void>;
|
|
1838
|
+
selectRow: (row: z.TypeOf<TSchema>) => void;
|
|
1839
|
+
selectAll: () => void;
|
|
1840
|
+
clearSelection: () => void;
|
|
1841
|
+
isRowSelected: (row: z.TypeOf<TSchema>) => boolean;
|
|
1842
|
+
triggerBulkAction: (action: string) => void;
|
|
1843
|
+
ui: {
|
|
1844
|
+
sortDrawerOpen: vue.Ref<boolean, boolean>;
|
|
1845
|
+
openSortDrawer: () => boolean;
|
|
1846
|
+
closeSortDrawer: () => boolean;
|
|
1847
|
+
};
|
|
1848
|
+
fieldsMetadata: Record<string, FieldMetadata>;
|
|
1849
|
+
columns: (z.TypeOf<TSchema> extends infer T ? { [K in keyof T]?: ColumnDefinition<z.TypeOf<TSchema>, K> | undefined; } : never) & {
|
|
1850
|
+
[key: string]: ColumnDefinition<z.TypeOf<TSchema>, any>;
|
|
1851
|
+
};
|
|
1852
|
+
};
|
|
1853
|
+
ZiniaDataTable: vue.FunctionalComponent<DataTableProps<z.TypeOf<TSchema>>, {}, {
|
|
1854
|
+
[key: `cell-${string}`]: (props: {
|
|
1855
|
+
value: any;
|
|
1856
|
+
row: z.TypeOf<TSchema>;
|
|
1857
|
+
field: string;
|
|
1858
|
+
formattedValue: string;
|
|
1859
|
+
}) => any;
|
|
1860
|
+
'selection-actions': (props: {
|
|
1861
|
+
hasSelection: boolean;
|
|
1862
|
+
selectedCount: number;
|
|
1863
|
+
selectedRows: z.TypeOf<TSchema>[];
|
|
1864
|
+
onClearSelection: () => void;
|
|
1865
|
+
triggerBulkAction: (action: string) => void;
|
|
1866
|
+
}) => any;
|
|
1867
|
+
default: () => any;
|
|
1868
|
+
}, {}>;
|
|
1869
|
+
load: () => Promise<void>;
|
|
1870
|
+
refresh: () => Promise<void>;
|
|
1871
|
+
sort: (field: keyof z.TypeOf<TSchema>, direction?: "asc" | "desc") => Promise<void>;
|
|
1872
|
+
clearSort: () => Promise<void>;
|
|
1873
|
+
setFilter: (field: keyof z.TypeOf<TSchema>, value: any, operator?: any) => Promise<void>;
|
|
1874
|
+
clearFilter: (field: keyof z.TypeOf<TSchema>) => Promise<void>;
|
|
1875
|
+
clearAllFilters: () => Promise<void>;
|
|
1876
|
+
setSearch: (query: string) => Promise<void>;
|
|
1877
|
+
clearSearch: () => Promise<void>;
|
|
1878
|
+
nextPage: () => Promise<void>;
|
|
1879
|
+
prevPage: () => Promise<void>;
|
|
1880
|
+
firstPage: () => Promise<void>;
|
|
1881
|
+
setPageSize: (size: number) => Promise<void>;
|
|
1882
|
+
selectRow: (row: z.TypeOf<TSchema>) => void;
|
|
1883
|
+
selectAll: () => void;
|
|
1884
|
+
clearSelection: () => void;
|
|
1885
|
+
isRowSelected: (row: z.TypeOf<TSchema>) => boolean;
|
|
1886
|
+
};
|
|
1887
|
+
type UseCursorDataTableType<TSchema extends z.ZodObject<any>> = ReturnType<typeof useCursorDataTable<TSchema>>;
|
|
1888
|
+
|
|
1889
|
+
declare const ZINIA_DELETE_MODAL_KEY = "ziniaDeleteModal";
|
|
1890
|
+
declare const ZINIA_DELETE_MODAL_FIELDS_KEY = "ziniaDeleteModalFields";
|
|
1891
|
+
declare const ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY = "ziniaDeleteModalFieldsGeneric";
|
|
1892
|
+
declare const ZINIA_DELETE_MODAL_SCHEMA_KEY = "ziniaDeleteModalSchema";
|
|
1893
|
+
interface DeleteModalOptions<TData> {
|
|
1894
|
+
data: TData | Ref<TData>;
|
|
1895
|
+
schemaId?: string;
|
|
1896
|
+
renderStyle?: RegisteredStyleName;
|
|
1897
|
+
autoProvide?: boolean;
|
|
1898
|
+
loading?: boolean | Ref<boolean>;
|
|
1899
|
+
error?: string | null | Ref<string | null>;
|
|
1900
|
+
onDeleteConfirm: (data: TData) => Promise<void>;
|
|
1901
|
+
onDeleteSuccess?: () => void;
|
|
1902
|
+
onDeleteError?: (error: Error) => void;
|
|
1903
|
+
debug?: boolean;
|
|
1904
|
+
}
|
|
1905
|
+
declare function useDeleteModal<TSchema extends z.ZodObject<any>>(schema: TSchema, options: DeleteModalOptions<z.infer<TSchema>>): {
|
|
1906
|
+
deleteModal: {
|
|
1907
|
+
readonly data: z.TypeOf<TSchema>;
|
|
1908
|
+
readonly isLoading: boolean;
|
|
1909
|
+
readonly error: string | null;
|
|
1910
|
+
fieldsMetadata: Record<string, FieldMetadata>;
|
|
1911
|
+
confirmDelete: () => Promise<void>;
|
|
1912
|
+
clearError: () => void;
|
|
1913
|
+
getValue: (path: string) => any;
|
|
1914
|
+
};
|
|
1915
|
+
ZiniaDeleteModal: vue.FunctionalComponent<DeleteModalProps<unknown>, {}, any, {}>;
|
|
1916
|
+
LoadingDisplay: vue.FunctionalComponent<LoadingDisplayProps, {}, any, {}>;
|
|
1917
|
+
ErrorDisplay: vue.FunctionalComponent<ErrorDisplayProps, {}, any, {}>;
|
|
1918
|
+
NoDataDisplay: vue.FunctionalComponent<NoDataDisplayProps, {}, any, {}>;
|
|
1919
|
+
zinia: DisplayComponentsType<z.TypeOf<TSchema>>;
|
|
1920
|
+
ziniaGeneric: {
|
|
1921
|
+
DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<TSchema>>, {}, any, {}>;
|
|
1922
|
+
fields: { [K in Path<z.TypeOf<TSchema>>]: DisplayFieldComponent<z.TypeOf<TSchema>, K, string>; };
|
|
1923
|
+
field: <P extends Path<z.TypeOf<TSchema>>>(path: P) => any;
|
|
1924
|
+
};
|
|
1925
|
+
confirmDelete: () => Promise<void>;
|
|
1926
|
+
clearError: () => void;
|
|
1927
|
+
};
|
|
1928
|
+
type UseDeleteModalType<TSchema extends z.ZodObject<any>> = ReturnType<typeof useDeleteModal<TSchema>>;
|
|
1929
|
+
type ZiniaDeleteModal<TSchema extends z.ZodObject<any>> = UseDeleteModalType<TSchema>['deleteModal'];
|
|
1930
|
+
type ZiniaDeleteModalFields<TSchema extends z.ZodObject<any>> = UseDeleteModalType<TSchema>['zinia'];
|
|
1931
|
+
type ZiniaDeleteModalGenericFields<TSchema extends z.ZodObject<any>> = UseDeleteModalType<TSchema>['ziniaGeneric'];
|
|
1932
|
+
|
|
1933
|
+
/**
|
|
1934
|
+
* Registry for storing schema metadata
|
|
1935
|
+
*/
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Get metadata for a specific field in a schema
|
|
1939
|
+
*
|
|
1940
|
+
* @param schemaId Unique identifier for the schema
|
|
1941
|
+
* @param path Path to the field
|
|
1942
|
+
* @returns Metadata for the field or undefined if not found
|
|
1943
|
+
*/
|
|
1944
|
+
declare function getFieldMetadata(schemaId: string, path: string): SchemaFieldMetadata | undefined;
|
|
1945
|
+
/**
|
|
1946
|
+
* Get all metadata for a schema
|
|
1947
|
+
*
|
|
1948
|
+
* @param schemaId Unique identifier for the schema
|
|
1949
|
+
* @returns All metadata for the schema or an empty object if not found
|
|
1950
|
+
*/
|
|
1951
|
+
declare function getAllSchemaMetadata(schemaId: string): MetadataRegistry;
|
|
1952
|
+
/**
|
|
1953
|
+
* Set metadata for a schema
|
|
1954
|
+
*
|
|
1955
|
+
* @param schemaId Unique identifier for the schema
|
|
1956
|
+
* @param metadata Object mapping field paths to their metadata
|
|
1957
|
+
*/
|
|
1958
|
+
declare function setSchemaMetadata(schemaId: string, metadata: MetadataRegistry): void;
|
|
1959
|
+
/**
|
|
1960
|
+
* Check if a schema has metadata
|
|
1961
|
+
*
|
|
1962
|
+
* @param schemaId Unique identifier for the schema
|
|
1963
|
+
* @returns True if the schema has metadata, false otherwise
|
|
1964
|
+
*/
|
|
1965
|
+
declare function hasSchemaMetadata(schemaId: string): boolean;
|
|
1966
|
+
/**
|
|
1967
|
+
* Clear metadata for a schema
|
|
1968
|
+
*
|
|
1969
|
+
* @param schemaId Unique identifier for the schema
|
|
1970
|
+
*/
|
|
1971
|
+
declare function clearSchemaMetadata(schemaId: string): void;
|
|
1972
|
+
/**
|
|
1973
|
+
* Clear all metadata from the registry
|
|
1974
|
+
*/
|
|
1975
|
+
declare function clearAllMetadata(): void;
|
|
1976
|
+
|
|
1977
|
+
/**
|
|
1978
|
+
* Functions for registering schema metadata
|
|
1979
|
+
*/
|
|
1980
|
+
|
|
1981
|
+
/**
|
|
1982
|
+
* Register metadata for a schema
|
|
1983
|
+
*
|
|
1984
|
+
* @param schemaId Unique identifier for the schema
|
|
1985
|
+
* @param metadata Object mapping field paths to their metadata
|
|
1986
|
+
*/
|
|
1987
|
+
declare function registerSchemaMetadata(schemaId: string, metadata: MetadataRegistry): void;
|
|
1988
|
+
/**
|
|
1989
|
+
* Register metadata for a schema with type checking for field paths
|
|
1990
|
+
*
|
|
1991
|
+
* @param schema The Zod schema
|
|
1992
|
+
* @param schemaId Unique identifier for the schema
|
|
1993
|
+
* @param metadata Object mapping field paths to their metadata
|
|
1994
|
+
*/
|
|
1995
|
+
declare function registerSchemaMetadata<T extends z.ZodObject<any>>(schema: T, schemaId: string, metadata: {
|
|
1996
|
+
[K in PathsOf<T>]?: SchemaFieldMetadata;
|
|
1997
|
+
}): void;
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* Functions for attaching metadata to schemas
|
|
2001
|
+
*/
|
|
2002
|
+
|
|
2003
|
+
declare const SCHEMA_ID_SYMBOL: unique symbol;
|
|
2004
|
+
/**
|
|
2005
|
+
* Helper function to get the schema ID from a schema object
|
|
2006
|
+
*
|
|
2007
|
+
* @param schema Zod schema that might have a schema ID attached
|
|
2008
|
+
* @returns The schema ID or undefined if not found
|
|
2009
|
+
*/
|
|
2010
|
+
declare function getSchemaId(schema: z.ZodTypeAny): string | undefined;
|
|
2011
|
+
/**
|
|
2012
|
+
* Helper function to create a schema with associated metadata
|
|
2013
|
+
*
|
|
2014
|
+
* @param schema Zod schema
|
|
2015
|
+
* @param schemaId Unique identifier for the schema
|
|
2016
|
+
* @param metadata Metadata for the schema fields
|
|
2017
|
+
* @returns The original schema with the schema ID attached
|
|
2018
|
+
*/
|
|
2019
|
+
declare function withMetadata<T extends z.ZodObject<any>>(schema: T, schemaId: string, metadata: {
|
|
2020
|
+
[K in PathsOf<T>]?: SchemaFieldMetadata;
|
|
2021
|
+
}): T;
|
|
2022
|
+
|
|
2023
|
+
/**
|
|
2024
|
+
* Zinia Forms Plugin
|
|
2025
|
+
* Allows registering custom render styles at the application level
|
|
2026
|
+
*/
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Plugin options for Zinia
|
|
2030
|
+
*/
|
|
2031
|
+
interface ZiniaPluginOptions {
|
|
2032
|
+
/**
|
|
2033
|
+
* Map of style names to style creators
|
|
2034
|
+
*/
|
|
2035
|
+
styles?: Record<string, StyleCreators>;
|
|
2036
|
+
/**
|
|
2037
|
+
* Default style to use if none specified in useForm
|
|
2038
|
+
*/
|
|
2039
|
+
defaultStyle?: string;
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Vue plugin for Zinia Forms
|
|
2043
|
+
*/
|
|
2044
|
+
declare const ZiniaPlugin: {
|
|
2045
|
+
install(app: App, options?: ZiniaPluginOptions): void;
|
|
2046
|
+
};
|
|
2047
|
+
/**
|
|
2048
|
+
* Get a registered style by name
|
|
2049
|
+
*
|
|
2050
|
+
* @param styleName Name of the style to get
|
|
2051
|
+
* @returns Style creators for the requested style or undefined if not found
|
|
2052
|
+
*/
|
|
2053
|
+
declare function getRegisteredStyle(styleName?: string): StyleCreators | undefined;
|
|
2054
|
+
/**
|
|
2055
|
+
* Check if a style is registered
|
|
2056
|
+
*
|
|
2057
|
+
* @param styleName Name of the style to check
|
|
2058
|
+
* @returns True if the style is registered
|
|
2059
|
+
*/
|
|
2060
|
+
declare function hasRegisteredStyle(styleName: string): boolean;
|
|
2061
|
+
/**
|
|
2062
|
+
* Get the default style name
|
|
2063
|
+
*
|
|
2064
|
+
* @returns Name of the default style
|
|
2065
|
+
*/
|
|
2066
|
+
declare function getDefaultStyle(): string;
|
|
2067
|
+
/**
|
|
2068
|
+
* Get all registered style names
|
|
2069
|
+
*
|
|
2070
|
+
* @returns Array of registered style names
|
|
2071
|
+
*/
|
|
2072
|
+
declare function getRegisteredStyleNames(): string[];
|
|
2073
|
+
/**
|
|
2074
|
+
* Register a style at runtime
|
|
2075
|
+
* Useful for dynamically loading styles
|
|
2076
|
+
*
|
|
2077
|
+
* @param styleName Name of the style to register
|
|
2078
|
+
* @param creators Style creators for the style
|
|
2079
|
+
*/
|
|
2080
|
+
declare function registerStyle(styleName: string, creators: StyleCreators): void;
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* DaisyUI style package
|
|
2084
|
+
* Provides all component creators for the DaisyUI style
|
|
2085
|
+
*/
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Complete set of DaisyUI style creators
|
|
2089
|
+
* Can be registered with the Zinia plugin
|
|
2090
|
+
*/
|
|
2091
|
+
declare const daisyUIStyle: StyleCreators;
|
|
2092
|
+
|
|
2093
|
+
/**
|
|
2094
|
+
* Plain style package
|
|
2095
|
+
* Provides all component creators for the Plain style (minimal styling)
|
|
2096
|
+
*/
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* Complete set of Plain style creators
|
|
2100
|
+
* Can be registered with the Zinia plugin
|
|
2101
|
+
*/
|
|
2102
|
+
declare const plainStyle: StyleCreators;
|
|
2103
|
+
|
|
2104
|
+
/**
|
|
2105
|
+
* Helper functions for creating and extending render styles
|
|
2106
|
+
*/
|
|
2107
|
+
|
|
2108
|
+
/**
|
|
2109
|
+
* Extend an existing style with custom overrides
|
|
2110
|
+
*
|
|
2111
|
+
* @param baseStyle The base style to extend
|
|
2112
|
+
* @param overrides Custom overrides for specific components
|
|
2113
|
+
* @returns A new style that combines the base style with the overrides
|
|
2114
|
+
*/
|
|
2115
|
+
declare function extendStyle(baseStyle: StyleCreators, overrides: Partial<StyleCreators>): StyleCreators;
|
|
2116
|
+
/**
|
|
2117
|
+
* Merge multiple styles together
|
|
2118
|
+
* Later styles will override earlier ones for any overlapping components
|
|
2119
|
+
*
|
|
2120
|
+
* @param styles Array of styles to merge
|
|
2121
|
+
* @returns A new style that combines all the provided styles
|
|
2122
|
+
*/
|
|
2123
|
+
declare function mergeStyles(...styles: Array<Partial<StyleCreators>>): StyleCreators;
|
|
2124
|
+
/**
|
|
2125
|
+
* Create a partial style with only the components you need
|
|
2126
|
+
* Useful when you want to override just a few components in a base style
|
|
2127
|
+
*
|
|
2128
|
+
* @param creators Object containing only the component creators you want to override
|
|
2129
|
+
* @returns A partial style object that can be used with extendStyle
|
|
2130
|
+
*/
|
|
2131
|
+
declare function createPartialStyle<T extends Partial<StyleCreators>>(creators: T): T;
|
|
2132
|
+
/**
|
|
2133
|
+
* Create a style template with placeholder implementations
|
|
2134
|
+
* Useful as a starting point for creating a completely new style
|
|
2135
|
+
*
|
|
2136
|
+
* @returns A style object with placeholder implementations that throw errors
|
|
2137
|
+
*/
|
|
2138
|
+
declare function createStyleTemplate(): StyleCreators;
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* Common action icons as SVG strings
|
|
2142
|
+
* These are Heroicons (heroicons.com) in SVG format for easy use in actions
|
|
2143
|
+
*/
|
|
2144
|
+
declare const ActionIcons: {
|
|
2145
|
+
readonly edit: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z\" /></svg>";
|
|
2146
|
+
readonly pencil: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z\" /></svg>";
|
|
2147
|
+
readonly delete: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16\" /></svg>";
|
|
2148
|
+
readonly trash: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16\" /></svg>";
|
|
2149
|
+
readonly view: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M15 12a3 3 0 11-6 0 3 3 0 016 0z\" /><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z\" /></svg>";
|
|
2150
|
+
readonly eye: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M15 12a3 3 0 11-6 0 3 3 0 016 0z\" /><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z\" /></svg>";
|
|
2151
|
+
readonly copy: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\" /></svg>";
|
|
2152
|
+
readonly duplicate: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\" /></svg>";
|
|
2153
|
+
readonly download: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z\" /></svg>";
|
|
2154
|
+
readonly share: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.367 2.684 3 3 0 00-5.367-2.684z\" /></svg>";
|
|
2155
|
+
readonly settings: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z\" /><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M15 12a3 3 0 11-6 0 3 3 0 016 0z\" /></svg>";
|
|
2156
|
+
readonly plus: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 6v6m0 0v6m0-6h6m-6 0H6\" /></svg>";
|
|
2157
|
+
readonly external: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14\" /></svg>";
|
|
2158
|
+
readonly arrowRight: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13 7l5 5m0 0l-5 5m5-5H6\" /></svg>";
|
|
2159
|
+
readonly dots: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z\" /></svg>";
|
|
2160
|
+
readonly dotsHorizontal: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z\" /></svg>";
|
|
2161
|
+
};
|
|
2162
|
+
|
|
2163
|
+
export { ActionIcons, type ActionItem, type ActionsConfig, type ButtonActionItem, type ColumnDefinition, type CursorDataTableOptions, type CursorFetchParams, type CursorFetchResult, type DataTableColumns, type DataTableOptions, type DisplayComponentsType, type DisplayFieldComponent, ErrorDisplay, type FetchDataParams, type FetchDataResult, type FilterValue, type LinkActionItem, LoadingDisplay, NoDataDisplay, SCHEMA_ID_SYMBOL, type TypedSelectFieldComponent, type UseCursorDataTableType, type UseDataTableType, type UseDeleteModalType, type UseDisplayType, type UseFormType, type UseFormTyped, ZINIA_DATA_TABLE_ACTIONS_KEY, ZINIA_DATA_TABLE_COLUMNS_KEY, ZINIA_DATA_TABLE_FILTER_INPUTS_KEY, ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY, ZINIA_DATA_TABLE_KEY, ZINIA_DATA_TABLE_NAME_KEY, ZINIA_DATA_TABLE_OPTIONS_KEY, ZINIA_DATA_TABLE_SEARCH_INPUT_KEY, ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY, ZINIA_DELETE_MODAL_FIELDS_KEY, ZINIA_DELETE_MODAL_KEY, ZINIA_DELETE_MODAL_SCHEMA_KEY, ZINIA_DISPLAY_FIELDS_GENERIC_KEY, ZINIA_DISPLAY_FIELDS_KEY, ZINIA_DISPLAY_KEY, ZINIA_DISPLAY_SCHEMA_KEY, ZINIA_FIELDS_GENERIC_KEY, ZINIA_FIELDS_KEY, ZINIA_FORM_KEY, ZINIA_FORM_SCHEMA_KEY, type ZiniaDataTable, type ZiniaDeleteModal, type ZiniaDeleteModalFields, type ZiniaDeleteModalGenericFields, type ZiniaDisplay, type ZiniaDisplayFields, type ZiniaDisplayGenericFields, type ZiniaForm, type ZiniaFormFields, type ZiniaFormGenericFields, ZiniaPlugin, type ZiniaPluginOptions, clearAllMetadata, clearSchemaMetadata, createBaseComponents, createBaseDisplayComponents, createPartialStyle, createStyleTemplate, createTypedArrayField, createTypedSelectField, daisyUIStyle, extendStyle, generateDisplayComponents, generateFieldComponents, getAllSchemaMetadata, getDefaultStyle, getFieldMetadata, getRegisteredStyle, getRegisteredStyleNames, getSchemaId, hasRegisteredStyle, hasSchemaMetadata, mergeStyles, plainStyle, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };
|