@dragonmastery/zinia-forms-core 0.3.11 → 0.3.13
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/dist/index.d.ts +288 -210
- package/dist/index.js +314 -236
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -148,40 +148,6 @@ interface CheckboxFieldProps<FormType> {
|
|
|
148
148
|
variant?: string;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
interface DateFieldProps<FormType> {
|
|
152
|
-
name: FlexiblePath<FormType>;
|
|
153
|
-
label?: string;
|
|
154
|
-
hideLabel?: boolean;
|
|
155
|
-
description?: string;
|
|
156
|
-
required?: boolean;
|
|
157
|
-
placeholder?: string;
|
|
158
|
-
disabled?: boolean;
|
|
159
|
-
readonly?: boolean;
|
|
160
|
-
class?: string | string[];
|
|
161
|
-
size?: string;
|
|
162
|
-
variant?: string;
|
|
163
|
-
min?: string;
|
|
164
|
-
max?: string;
|
|
165
|
-
formatter?: (date: string) => unknown;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
interface NumberFieldProps<FormType> {
|
|
169
|
-
name: FlexiblePath<FormType>;
|
|
170
|
-
label?: string;
|
|
171
|
-
hideLabel?: boolean;
|
|
172
|
-
description?: string;
|
|
173
|
-
required?: boolean;
|
|
174
|
-
placeholder?: string;
|
|
175
|
-
disabled?: boolean;
|
|
176
|
-
readonly?: boolean;
|
|
177
|
-
class?: string | string[];
|
|
178
|
-
size?: string;
|
|
179
|
-
variant?: string;
|
|
180
|
-
min?: number;
|
|
181
|
-
max?: number;
|
|
182
|
-
step?: number;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
151
|
/**
|
|
186
152
|
* Option item for select fields
|
|
187
153
|
* @template TData - Type of the optional data object for storing additional metadata
|
|
@@ -368,6 +334,186 @@ interface SelectFieldProps<FormType, P extends Path<FormType> = Path<FormType>,
|
|
|
368
334
|
*/
|
|
369
335
|
declare const SELECT_FIELD_PROP_NAMES: readonly ["name", "selectOptions", "placeholder", "disabled", "readonly", "class", "label", "hideLabel", "description", "required", "size", "variant", "valueToLabel", "useSchemaOptions", "dependsOn", "optionFilterFn", "autoReset"];
|
|
370
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Props for the ComboboxField component
|
|
339
|
+
* @template FormType - The form type
|
|
340
|
+
* @template P - The field path in the form
|
|
341
|
+
* @template TData - The type of the data property in SelectOption (for cascading dropdowns)
|
|
342
|
+
*/
|
|
343
|
+
interface ComboboxFieldProps<FormType, P extends Path<FormType> = Path<FormType>, TData = any> {
|
|
344
|
+
/**
|
|
345
|
+
* Field name (path in the form state)
|
|
346
|
+
* Accepts both static paths and dynamic paths for use in array fields
|
|
347
|
+
*/
|
|
348
|
+
name: FlexiblePath<FormType>;
|
|
349
|
+
/**
|
|
350
|
+
* Field label
|
|
351
|
+
*/
|
|
352
|
+
label?: string;
|
|
353
|
+
/**
|
|
354
|
+
* Whether to hide the label
|
|
355
|
+
*/
|
|
356
|
+
hideLabel?: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Field description
|
|
359
|
+
*/
|
|
360
|
+
description?: string;
|
|
361
|
+
/**
|
|
362
|
+
* Whether the field is required
|
|
363
|
+
*/
|
|
364
|
+
required?: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Placeholder text
|
|
367
|
+
*/
|
|
368
|
+
placeholder?: string;
|
|
369
|
+
/**
|
|
370
|
+
* Whether the field is disabled
|
|
371
|
+
*/
|
|
372
|
+
disabled?: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Whether the field is readonly
|
|
375
|
+
*/
|
|
376
|
+
readonly?: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* CSS classes to apply to the field
|
|
379
|
+
*/
|
|
380
|
+
class?: string | string[];
|
|
381
|
+
/**
|
|
382
|
+
* Field size
|
|
383
|
+
*/
|
|
384
|
+
size?: string;
|
|
385
|
+
/**
|
|
386
|
+
* Field variant
|
|
387
|
+
*/
|
|
388
|
+
variant?: string;
|
|
389
|
+
/**
|
|
390
|
+
* Combobox options (overrides options from schema)
|
|
391
|
+
* Using selectOptions instead of options to avoid conflicts with HTML select element
|
|
392
|
+
*
|
|
393
|
+
* For async loading, use form-level dataLoaders and pass options via extraData:
|
|
394
|
+
* ```ts
|
|
395
|
+
* useForm(schema, {
|
|
396
|
+
* dataLoaders: { products: loadProducts },
|
|
397
|
+
* });
|
|
398
|
+
* // Then: :selectOptions="form.extraData.products || []"
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* // With typed data
|
|
403
|
+
* interface CityData { country: string; }
|
|
404
|
+
* const options: SelectOption<CityData>[] = [
|
|
405
|
+
* { value: 'nyc', label: 'New York', data: { country: 'usa' } }
|
|
406
|
+
* ];
|
|
407
|
+
*/
|
|
408
|
+
selectOptions?: SelectOption<TData>[];
|
|
409
|
+
/**
|
|
410
|
+
* Custom mapping function to convert values to labels
|
|
411
|
+
* This is useful when you want to customize how labels are displayed
|
|
412
|
+
* without providing a full options array
|
|
413
|
+
*
|
|
414
|
+
* Can be provided as either:
|
|
415
|
+
* 1. A function that takes a value and returns a label
|
|
416
|
+
* 2. An object map where keys are enum values and values are labels
|
|
417
|
+
*/
|
|
418
|
+
valueToLabel?: ValueToLabelMapping<FieldPathToEnum$1<FormType, P>>;
|
|
419
|
+
/**
|
|
420
|
+
* Whether to use options from the schema (default: true)
|
|
421
|
+
* Set to false to ignore schema options even when no options prop is provided
|
|
422
|
+
*/
|
|
423
|
+
useSchemaOptions?: boolean;
|
|
424
|
+
/**
|
|
425
|
+
* Field path that this field depends on for cascading dropdowns
|
|
426
|
+
* When the parent field changes, this field's options will be filtered
|
|
427
|
+
* and the field will be reset (unless autoReset is false)
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* // City field depends on country field
|
|
431
|
+
* <ComboboxField name="city" dependsOn="country" :optionFilterFn="filterCitiesByCountry" />
|
|
432
|
+
*/
|
|
433
|
+
dependsOn?: FlexiblePath<FormType>;
|
|
434
|
+
/**
|
|
435
|
+
* Function to filter options based on the parent field's value
|
|
436
|
+
* Receives the parent field value and all available options
|
|
437
|
+
* Should return the filtered options array
|
|
438
|
+
*
|
|
439
|
+
* The function signature is tied to the TData type parameter, ensuring type safety
|
|
440
|
+
* between selectOptions and optionFilterFn
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* // With typed data - both props must use the same data type
|
|
444
|
+
* interface CityData { country: string; }
|
|
445
|
+
* const filterCitiesByCountry = (
|
|
446
|
+
* countryValue: string,
|
|
447
|
+
* allOptions: SelectOption<CityData>[]
|
|
448
|
+
* ): SelectOption<CityData>[] => {
|
|
449
|
+
* return allOptions.filter(opt => opt.data?.country === countryValue);
|
|
450
|
+
* };
|
|
451
|
+
*/
|
|
452
|
+
optionFilterFn?: (parentValue: any, allOptions: SelectOption<TData>[]) => SelectOption<TData>[];
|
|
453
|
+
/**
|
|
454
|
+
* Whether to automatically reset this field when the parent field changes (default: true)
|
|
455
|
+
* Set to false if you want to preserve the value when parent changes
|
|
456
|
+
*/
|
|
457
|
+
autoReset?: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Whether to allow creating new values that don't exist in the options
|
|
460
|
+
* Default: false (must be explicitly set to true to allow creation)
|
|
461
|
+
*
|
|
462
|
+
* Note: This is specific to ComboboxField and not available in SelectField
|
|
463
|
+
*/
|
|
464
|
+
allowCreate?: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* Custom filter function for filtering options as user types
|
|
467
|
+
* Default: filters by case-insensitive substring match
|
|
468
|
+
*
|
|
469
|
+
* Note: This is specific to ComboboxField and not available in SelectField
|
|
470
|
+
* This is different from optionFilterFn which filters based on parent field values
|
|
471
|
+
*/
|
|
472
|
+
filterFn?: (query: string, option: SelectOption<TData>) => boolean;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Array of prop names for ComboboxField component.
|
|
476
|
+
* This is derived from ComboboxFieldProps interface and ensures type safety.
|
|
477
|
+
* Used for prop normalization and filtering in component implementations.
|
|
478
|
+
*
|
|
479
|
+
* TypeScript ensures all entries are valid keys of ComboboxFieldProps.
|
|
480
|
+
*/
|
|
481
|
+
declare const COMBOBOX_FIELD_PROP_NAMES: readonly ["name", "selectOptions", "placeholder", "disabled", "readonly", "class", "label", "hideLabel", "description", "required", "size", "variant", "valueToLabel", "useSchemaOptions", "dependsOn", "optionFilterFn", "autoReset", "allowCreate", "filterFn"];
|
|
482
|
+
|
|
483
|
+
interface DateFieldProps<FormType> {
|
|
484
|
+
name: FlexiblePath<FormType>;
|
|
485
|
+
label?: string;
|
|
486
|
+
hideLabel?: boolean;
|
|
487
|
+
description?: string;
|
|
488
|
+
required?: boolean;
|
|
489
|
+
placeholder?: string;
|
|
490
|
+
disabled?: boolean;
|
|
491
|
+
readonly?: boolean;
|
|
492
|
+
class?: string | string[];
|
|
493
|
+
size?: string;
|
|
494
|
+
variant?: string;
|
|
495
|
+
min?: string;
|
|
496
|
+
max?: string;
|
|
497
|
+
formatter?: (date: string) => unknown;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
interface NumberFieldProps<FormType> {
|
|
501
|
+
name: FlexiblePath<FormType>;
|
|
502
|
+
label?: string;
|
|
503
|
+
hideLabel?: boolean;
|
|
504
|
+
description?: string;
|
|
505
|
+
required?: boolean;
|
|
506
|
+
placeholder?: string;
|
|
507
|
+
disabled?: boolean;
|
|
508
|
+
readonly?: boolean;
|
|
509
|
+
class?: string | string[];
|
|
510
|
+
size?: string;
|
|
511
|
+
variant?: string;
|
|
512
|
+
min?: number;
|
|
513
|
+
max?: number;
|
|
514
|
+
step?: number;
|
|
515
|
+
}
|
|
516
|
+
|
|
371
517
|
/**
|
|
372
518
|
* Type to convert underscores to PascalCase
|
|
373
519
|
* This helper type processes a single segment by capitalizing after underscores
|
|
@@ -429,11 +575,11 @@ type EnumFieldComponent<T, P extends Path<T>> = (props: Omit<SelectFieldProps<T>
|
|
|
429
575
|
valueToLabel: Record<FieldPathToEnum<T, P>, string>;
|
|
430
576
|
}, context?: any) => any;
|
|
431
577
|
/**
|
|
432
|
-
* Type for
|
|
433
|
-
* Uses
|
|
434
|
-
*
|
|
578
|
+
* Type for combobox field components (searchable select with optional creation)
|
|
579
|
+
* Uses ComboboxFieldProps<T, P, TData> which extends SelectFieldProps with allowCreate and filterFn
|
|
580
|
+
* Preserves path-specific typing for props like dependsOn and ensures type safety
|
|
435
581
|
*/
|
|
436
|
-
type
|
|
582
|
+
type ComboboxFieldComponent<T, P extends Path<T>> = <TData = any>(props: Omit<ComboboxFieldProps<T, P, TData>, 'name'>, context?: any) => any;
|
|
437
583
|
/**
|
|
438
584
|
* Type for number field components
|
|
439
585
|
*/
|
|
@@ -461,14 +607,19 @@ type GenericFieldComponent = (props: any, context?: any) => any;
|
|
|
461
607
|
type UnwrapOptional<T> = Exclude<T, undefined | null>;
|
|
462
608
|
/**
|
|
463
609
|
* Maps a field path to its component type based on the field's actual type
|
|
464
|
-
*
|
|
465
|
-
*
|
|
610
|
+
* FieldType can be 'enum', 'combobox', or 'string' (default)
|
|
611
|
+
* - 'enum': Uses EnumFieldComponent (requires valueToLabel)
|
|
612
|
+
* - 'combobox': Uses ComboboxFieldComponent (includes allowCreate and filterFn)
|
|
613
|
+
* - 'string': Uses ComboboxFieldComponent (superset of SelectField with allowCreate and filterFn)
|
|
466
614
|
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
* This
|
|
615
|
+
* We use ComboboxFieldComponent for all string fields because:
|
|
616
|
+
* 1. ComboboxFieldProps includes all SelectFieldProps (it's a superset)
|
|
617
|
+
* 2. This allows allowCreate to be available in types even if the field uses SelectField at runtime
|
|
618
|
+
* 3. ComboboxField can handle all SelectField use cases, so it's safe to use as the default
|
|
619
|
+
*
|
|
620
|
+
* Everything else is inferred from the actual TypeScript type at the path
|
|
470
621
|
*/
|
|
471
|
-
type FieldComponentType<T, P extends Path<T>, FieldType extends string = 'string'> = FieldType extends 'enum' ? EnumFieldComponent<T, P> : P extends keyof T ? UnwrapOptional<T[P]> extends Array<any> | ReadonlyArray<any> ? ArrayFieldComponent<T, P> : UnwrapOptional<T[P]> extends number ? NumberFieldComponent<T> : UnwrapOptional<T[P]> extends boolean ? CheckboxFieldComponent<T> : UnwrapOptional<T[P]> extends Date ? DateFieldComponent<T> : UnwrapOptional<T[P]> extends string ?
|
|
622
|
+
type FieldComponentType<T, P extends Path<T>, FieldType extends string = 'string'> = FieldType extends 'enum' ? EnumFieldComponent<T, P> : FieldType extends 'combobox' ? ComboboxFieldComponent<T, P> : P extends keyof T ? UnwrapOptional<T[P]> extends Array<any> | ReadonlyArray<any> ? ArrayFieldComponent<T, P> : UnwrapOptional<T[P]> extends number ? NumberFieldComponent<T> : UnwrapOptional<T[P]> extends boolean ? CheckboxFieldComponent<T> : UnwrapOptional<T[P]> extends Date ? DateFieldComponent<T> : UnwrapOptional<T[P]> extends string ? ComboboxFieldComponent<T, P> : GenericFieldComponent : GenericFieldComponent;
|
|
472
623
|
/**
|
|
473
624
|
* Type for the components object with PascalCase keys derived from field paths
|
|
474
625
|
* Each component gets the right type based on what the field actually is
|
|
@@ -580,95 +731,6 @@ type MetadataRegistry = Record<string, SchemaFieldMetadata>;
|
|
|
580
731
|
*/
|
|
581
732
|
type PathsOf<T extends z.ZodTypeAny> = Path<z.infer<T>>;
|
|
582
733
|
|
|
583
|
-
/**
|
|
584
|
-
* Option item for combobox fields - can be a string or label/value object
|
|
585
|
-
*/
|
|
586
|
-
type ComboboxOption = string | {
|
|
587
|
-
label: string;
|
|
588
|
-
value: string;
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
|
-
* Props for the ComboboxField component
|
|
592
|
-
*/
|
|
593
|
-
interface ComboboxFieldProps<FormType, P extends Path<FormType> = Path<FormType>> {
|
|
594
|
-
/**
|
|
595
|
-
* Field name (path in the form state)
|
|
596
|
-
* Accepts both static paths and dynamic paths for use in array fields
|
|
597
|
-
*/
|
|
598
|
-
name: FlexiblePath<FormType>;
|
|
599
|
-
/**
|
|
600
|
-
* Field label
|
|
601
|
-
*/
|
|
602
|
-
label?: string;
|
|
603
|
-
/**
|
|
604
|
-
* Whether to hide the label
|
|
605
|
-
*/
|
|
606
|
-
hideLabel?: boolean;
|
|
607
|
-
/**
|
|
608
|
-
* Field description
|
|
609
|
-
*/
|
|
610
|
-
description?: string;
|
|
611
|
-
/**
|
|
612
|
-
* Whether the field is required
|
|
613
|
-
*/
|
|
614
|
-
required?: boolean;
|
|
615
|
-
/**
|
|
616
|
-
* Placeholder text
|
|
617
|
-
*/
|
|
618
|
-
placeholder?: string;
|
|
619
|
-
/**
|
|
620
|
-
* Whether the field is disabled
|
|
621
|
-
*/
|
|
622
|
-
disabled?: boolean;
|
|
623
|
-
/**
|
|
624
|
-
* Whether the field is readonly
|
|
625
|
-
*/
|
|
626
|
-
readonly?: boolean;
|
|
627
|
-
/**
|
|
628
|
-
* CSS classes to apply to the field
|
|
629
|
-
*/
|
|
630
|
-
class?: string | string[];
|
|
631
|
-
/**
|
|
632
|
-
* Field size
|
|
633
|
-
*/
|
|
634
|
-
size?: string;
|
|
635
|
-
/**
|
|
636
|
-
* Field variant
|
|
637
|
-
*/
|
|
638
|
-
variant?: string;
|
|
639
|
-
/**
|
|
640
|
-
* Combobox options (array of strings or label/value objects)
|
|
641
|
-
* If not provided, will use options from schema metadata
|
|
642
|
-
*
|
|
643
|
-
* For async loading, use form-level dataLoaders and pass options via extraData:
|
|
644
|
-
* ```ts
|
|
645
|
-
* useForm(schema, {
|
|
646
|
-
* dataLoaders: { products: loadProducts },
|
|
647
|
-
* });
|
|
648
|
-
* // Then: :options="form.extraData.products || []"
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
options?: ComboboxOption[];
|
|
652
|
-
/**
|
|
653
|
-
* Whether to allow creating new values that don't exist in the options
|
|
654
|
-
* Default: true
|
|
655
|
-
*/
|
|
656
|
-
allowCreate?: boolean;
|
|
657
|
-
/**
|
|
658
|
-
* Custom filter function for options
|
|
659
|
-
* Default: filters by case-insensitive substring match
|
|
660
|
-
*/
|
|
661
|
-
filterFn?: (query: string, option: ComboboxOption) => boolean;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Array of prop names for ComboboxField component.
|
|
665
|
-
* This is derived from ComboboxFieldProps interface and ensures type safety.
|
|
666
|
-
* Used for prop normalization and filtering in component implementations.
|
|
667
|
-
*
|
|
668
|
-
* TypeScript ensures all entries are valid keys of ComboboxFieldProps.
|
|
669
|
-
*/
|
|
670
|
-
declare const COMBOBOX_FIELD_PROP_NAMES: readonly ["name", "options", "placeholder", "disabled", "readonly", "class", "label", "hideLabel", "description", "required", "size", "variant", "allowCreate", "filterFn"];
|
|
671
|
-
|
|
672
734
|
interface CurrencyFieldProps<FormType> {
|
|
673
735
|
name: FlexiblePath<FormType>;
|
|
674
736
|
label?: string;
|
|
@@ -1389,7 +1451,7 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
|
|
|
1389
1451
|
UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1390
1452
|
TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1391
1453
|
SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1392
|
-
ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T
|
|
1454
|
+
ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
|
|
1393
1455
|
ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1394
1456
|
itemRenderer: (props: {
|
|
1395
1457
|
item: any;
|
|
@@ -1485,28 +1547,15 @@ declare function createBaseComponents<T extends z.ZodObject<any>>(schema: T, sty
|
|
|
1485
1547
|
};
|
|
1486
1548
|
|
|
1487
1549
|
/**
|
|
1488
|
-
*
|
|
1489
|
-
*/
|
|
1490
|
-
|
|
1491
|
-
/**
|
|
1492
|
-
* Create a factory function that returns a properly typed SelectField based on the field path
|
|
1550
|
+
* Create base display components using registered styles
|
|
1493
1551
|
*
|
|
1494
|
-
* @param
|
|
1495
|
-
* @param
|
|
1496
|
-
* @returns
|
|
1497
|
-
*/
|
|
1498
|
-
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"> & {
|
|
1499
|
-
valueToLabel: Record<E, string>;
|
|
1500
|
-
}, context?: any) => any;
|
|
1501
|
-
/**
|
|
1502
|
-
* Type-safe select field component with valueToLabel based on field path
|
|
1552
|
+
* @param schema The Zod schema for the data
|
|
1553
|
+
* @param styleName The style to use for rendering
|
|
1554
|
+
* @returns Base display components
|
|
1503
1555
|
*/
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
valueToLabel?: Record<string, string>;
|
|
1508
|
-
}): ReturnType<FunctionalComponent>;
|
|
1509
|
-
}
|
|
1556
|
+
declare function createBaseDisplayComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
|
|
1557
|
+
ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1558
|
+
};
|
|
1510
1559
|
|
|
1511
1560
|
interface ArrayFieldSlots<ItemType> {
|
|
1512
1561
|
itemRenderer: (props: {
|
|
@@ -1544,6 +1593,89 @@ interface ArrayFieldSlots<ItemType> {
|
|
|
1544
1593
|
*/
|
|
1545
1594
|
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">, {}, ArrayFieldSlots<ArrayItemType<T, P>>, {}>;
|
|
1546
1595
|
|
|
1596
|
+
/**
|
|
1597
|
+
* Functions for creating type-safe combobox fields
|
|
1598
|
+
*/
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* Create a factory function that returns a properly typed ComboboxField based on the field path
|
|
1602
|
+
*
|
|
1603
|
+
* @param baseComboboxField The base combobox field component
|
|
1604
|
+
* @param fieldPath The field path to create a combobox field for
|
|
1605
|
+
* @returns A factory function that creates a type-safe combobox field
|
|
1606
|
+
*
|
|
1607
|
+
* This preserves path-specific typing for features like dependsOn (cascading dropdowns)
|
|
1608
|
+
* and ensures type safety between selectOptions and optionFilterFn
|
|
1609
|
+
*/
|
|
1610
|
+
declare function createTypedComboboxField<T, P extends Path<T>>(baseComboboxField: FunctionalComponent<ComboboxFieldProps<T>>, fieldPath: P): <TData = any>(props: Omit<ComboboxFieldProps<T, P, TData>, "name">, context?: any) => any;
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Functions for creating type-safe select fields
|
|
1614
|
+
*/
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* Create a factory function that returns a properly typed SelectField based on the field path
|
|
1618
|
+
*
|
|
1619
|
+
* @param baseSelectField The base select field component
|
|
1620
|
+
* @param fieldPath The field path to create a select field for
|
|
1621
|
+
* @returns A factory function that creates a type-safe select field
|
|
1622
|
+
*/
|
|
1623
|
+
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"> & {
|
|
1624
|
+
valueToLabel: Record<E, string>;
|
|
1625
|
+
}, context?: any) => any;
|
|
1626
|
+
/**
|
|
1627
|
+
* Type-safe select field component with valueToLabel based on field path
|
|
1628
|
+
*/
|
|
1629
|
+
interface TypedSelectFieldComponent<T> {
|
|
1630
|
+
<P extends Path<T>>(props: Omit<SelectFieldProps<T>, 'valueToLabel'> & {
|
|
1631
|
+
name: P;
|
|
1632
|
+
valueToLabel?: Record<string, string>;
|
|
1633
|
+
}): ReturnType<FunctionalComponent>;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/**
|
|
1637
|
+
* Type for display field components
|
|
1638
|
+
*/
|
|
1639
|
+
type DisplayFieldComponent<T, P extends Path<T>, _FieldType extends string = 'string'> = (props: {
|
|
1640
|
+
name?: P;
|
|
1641
|
+
label?: string;
|
|
1642
|
+
hideLabel?: boolean;
|
|
1643
|
+
description?: string;
|
|
1644
|
+
format?: 'default' | 'currency' | 'date' | 'datetime' | 'boolean' | 'email' | 'url' | 'phone' | 'number';
|
|
1645
|
+
emptyText?: string;
|
|
1646
|
+
class?: string | string[];
|
|
1647
|
+
size?: string;
|
|
1648
|
+
variant?: string;
|
|
1649
|
+
copyable?: boolean;
|
|
1650
|
+
valueToLabel?: Record<string, string>;
|
|
1651
|
+
separator?: string;
|
|
1652
|
+
itemRenderer?: (item: any, index: number) => string;
|
|
1653
|
+
maxItems?: number;
|
|
1654
|
+
}, context?: any) => any;
|
|
1655
|
+
/**
|
|
1656
|
+
* Type for the display components object with PascalCase keys derived from field paths
|
|
1657
|
+
* This mirrors the ComponentsType from the form system but with Display suffix
|
|
1658
|
+
*/
|
|
1659
|
+
type DisplayComponentsType<T> = {
|
|
1660
|
+
[K in Path<T> as `${PathToPascalCase<K & string>}` extends `${infer Base}Field` ? `${Base}Display` : `${PathToPascalCase<K & string>}Display`]: DisplayFieldComponent<T, K>;
|
|
1661
|
+
};
|
|
1662
|
+
/**
|
|
1663
|
+
* Generate display field components for a schema based on metadata
|
|
1664
|
+
*
|
|
1665
|
+
* @param schema The Zod schema for the data
|
|
1666
|
+
* @param fieldsMetadata Metadata for fields
|
|
1667
|
+
* @param renderStyle The style to use for rendering
|
|
1668
|
+
* @returns Generated display field components
|
|
1669
|
+
*/
|
|
1670
|
+
declare function generateDisplayComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
|
|
1671
|
+
generic: {
|
|
1672
|
+
DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1673
|
+
fields: { [K in Path<z.TypeOf<T>>]: DisplayFieldComponent<z.TypeOf<T>, K, string>; };
|
|
1674
|
+
field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
|
|
1675
|
+
};
|
|
1676
|
+
typed: DisplayComponentsType<z.TypeOf<T>>;
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1547
1679
|
/**
|
|
1548
1680
|
* Generate field components for a schema based on metadata
|
|
1549
1681
|
*
|
|
@@ -1570,7 +1702,7 @@ declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T,
|
|
|
1570
1702
|
UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1571
1703
|
TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1572
1704
|
SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1573
|
-
ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T
|
|
1705
|
+
ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
|
|
1574
1706
|
ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
|
|
1575
1707
|
itemRenderer: (props: {
|
|
1576
1708
|
item: any;
|
|
@@ -1642,60 +1774,6 @@ declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T,
|
|
|
1642
1774
|
typed: ComponentsType<z.TypeOf<T>>;
|
|
1643
1775
|
};
|
|
1644
1776
|
|
|
1645
|
-
/**
|
|
1646
|
-
* Create base display components using registered styles
|
|
1647
|
-
*
|
|
1648
|
-
* @param schema The Zod schema for the data
|
|
1649
|
-
* @param styleName The style to use for rendering
|
|
1650
|
-
* @returns Base display components
|
|
1651
|
-
*/
|
|
1652
|
-
declare function createBaseDisplayComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
|
|
1653
|
-
ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1654
|
-
};
|
|
1655
|
-
|
|
1656
|
-
/**
|
|
1657
|
-
* Type for display field components
|
|
1658
|
-
*/
|
|
1659
|
-
type DisplayFieldComponent<T, P extends Path<T>, _FieldType extends string = 'string'> = (props: {
|
|
1660
|
-
name?: P;
|
|
1661
|
-
label?: string;
|
|
1662
|
-
hideLabel?: boolean;
|
|
1663
|
-
description?: string;
|
|
1664
|
-
format?: 'default' | 'currency' | 'date' | 'datetime' | 'boolean' | 'email' | 'url' | 'phone' | 'number';
|
|
1665
|
-
emptyText?: string;
|
|
1666
|
-
class?: string | string[];
|
|
1667
|
-
size?: string;
|
|
1668
|
-
variant?: string;
|
|
1669
|
-
copyable?: boolean;
|
|
1670
|
-
valueToLabel?: Record<string, string>;
|
|
1671
|
-
separator?: string;
|
|
1672
|
-
itemRenderer?: (item: any, index: number) => string;
|
|
1673
|
-
maxItems?: number;
|
|
1674
|
-
}, context?: any) => any;
|
|
1675
|
-
/**
|
|
1676
|
-
* Type for the display components object with PascalCase keys derived from field paths
|
|
1677
|
-
* This mirrors the ComponentsType from the form system but with Display suffix
|
|
1678
|
-
*/
|
|
1679
|
-
type DisplayComponentsType<T> = {
|
|
1680
|
-
[K in Path<T> as `${PathToPascalCase<K & string>}` extends `${infer Base}Field` ? `${Base}Display` : `${PathToPascalCase<K & string>}Display`]: DisplayFieldComponent<T, K>;
|
|
1681
|
-
};
|
|
1682
|
-
/**
|
|
1683
|
-
* Generate display field components for a schema based on metadata
|
|
1684
|
-
*
|
|
1685
|
-
* @param schema The Zod schema for the data
|
|
1686
|
-
* @param fieldsMetadata Metadata for fields
|
|
1687
|
-
* @param renderStyle The style to use for rendering
|
|
1688
|
-
* @returns Generated display field components
|
|
1689
|
-
*/
|
|
1690
|
-
declare function generateDisplayComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
|
|
1691
|
-
generic: {
|
|
1692
|
-
DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<T>>, {}, any, {}>;
|
|
1693
|
-
fields: { [K in Path<z.TypeOf<T>>]: DisplayFieldComponent<z.TypeOf<T>, K, string>; };
|
|
1694
|
-
field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
|
|
1695
|
-
};
|
|
1696
|
-
typed: DisplayComponentsType<z.TypeOf<T>>;
|
|
1697
|
-
};
|
|
1698
|
-
|
|
1699
1777
|
interface NoDataDisplayProps {
|
|
1700
1778
|
message?: string;
|
|
1701
1779
|
class?: string;
|
|
@@ -2478,4 +2556,4 @@ declare const DEBUG_CONFIG: {
|
|
|
2478
2556
|
*/
|
|
2479
2557
|
declare function isDebugEnabled(area: keyof Omit<typeof DEBUG_CONFIG, 'all'>): boolean;
|
|
2480
2558
|
|
|
2481
|
-
export { ActionIcons, type ActionItem, type ActionsConfig, type ArrayFieldProps, type ArrayFieldSlots, type ButtonActionItem, COMBOBOX_FIELD_PROP_NAMES, type CheckboxFieldProps, type ColumnDefinition, type ComboboxFieldProps, type
|
|
2559
|
+
export { ActionIcons, type ActionItem, type ActionsConfig, type ArrayFieldProps, type ArrayFieldSlots, type ButtonActionItem, COMBOBOX_FIELD_PROP_NAMES, type CheckboxFieldProps, type ColumnDefinition, type ComboboxFieldProps, type CurrencyFieldProps, type CursorDataTableOptions, type CursorFetchParams, type CursorFetchResult, DEBUG_CONFIG, type DataTableColumns, type DataTableOptions, type DataTableProps, type DateFieldProps, type DateTimeLocalFieldProps, type DeleteModalProps, type DisplayComponentsType, type DisplayFieldComponent, type DisplayFieldProps, type DisplayProps, type EmailFieldProps, type EnumValueToLabelMap, type EnumValuesFromField, ErrorDisplay, type FetchDataParams, type FetchDataResult, type FieldPathToEnum$1 as FieldPathToEnum, type FieldType, type FileFieldProps, type FilterOptionItem, type FilterValue, type FormErrorsSummaryProps, type FormProps, type LinkActionItem, LoadingDisplay, NoDataDisplay, type NumberFieldProps, type PasswordFieldProps, type RadioFieldProps, type RangeFieldProps, type ResetButtonProps, SCHEMA_ID_SYMBOL, SELECT_FIELD_PROP_NAMES, type SearchFieldProps, type SelectFieldProps, type SelectOption, type SubmitButtonProps, type TelFieldProps, type TextFieldProps, type TextareaFieldProps, type TimeFieldProps, type ToppingsFieldProps, type TransferListFieldProps, type TypedSelectFieldComponent, type UrlFieldProps, type UseCursorDataTableType, type UseDataTableType, type UseDeleteModalType, type UseDisplayType, type UseFormType, type UseFormTyped, type ValueToLabelMapping, 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, type ZodEnumValues, clearAllMetadata, clearSchemaMetadata, createBaseComponents, createBaseDisplayComponents, createPartialStyle, createStyleTemplate, createTypedArrayField, createTypedComboboxField, createTypedSelectField, daisyUIStyle, extendStyle, generateDisplayComponents, generateFieldComponents, getAllSchemaMetadata, getDefaultStyle, getFieldMetadata, getRegisteredStyle, getRegisteredStyleNames, getSchemaId, hasRegisteredStyle, hasSchemaMetadata, isDebugEnabled, mergeStyles, plainStyle, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };
|