@dragonmastery/zinia-forms-core 0.4.7 → 0.4.8

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 CHANGED
@@ -1,9 +1,64 @@
1
1
  import * as vue from 'vue';
2
- import { FunctionalComponent, Ref, App } from 'vue';
2
+ import { FunctionalComponent, App, Ref, ComputedRef } from 'vue';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * Types for registered styles
7
+ * This allows for autocomplete of registered style names
8
+ */
9
+ /**
10
+ * Union type of all registered style names
11
+ * Update this when adding new built-in styles
12
+ */
13
+ type BuiltInStyleName = 'daisy_ui';
14
+ /**
15
+ * Type for custom registered style names
16
+ * This is a string literal type that can be extended by users
17
+ */
18
+ type CustomStyleName = string;
19
+ /**
20
+ * Union type of all possible style names
21
+ * This includes both built-in styles and custom styles
22
+ */
23
+ type RegisteredStyleName = BuiltInStyleName | CustomStyleName;
24
+
25
+ /**
26
+ * Create base form components for a schema
27
+ *
28
+ * @param schema The Zod schema for the form
29
+ * @param renderStyle The style to use for rendering
30
+ * @returns Base form components (Form, SubmitButton, ResetButton)
31
+ */
32
+ declare function createBaseComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
33
+ Form: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
34
+ SubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
35
+ ResetButton: vue.FunctionalComponent<ResetButtonProps<z.TypeOf<T>>, {}, any, {}>;
36
+ FormErrorsSummary: vue.FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
37
+ };
38
+
39
+ /**
40
+ * Create base display components using registered styles
41
+ *
42
+ * @param schema The Zod schema for the data
43
+ * @param styleName The style to use for rendering
44
+ * @returns Base display components
45
+ */
46
+ declare function createBaseDisplayComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
47
+ ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<T>>, {}, any, {}>;
48
+ };
49
+
5
50
  type BrowserNativeObject = Date | FileList | File;
6
51
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
52
+ /**
53
+ * Checks whether the type is any
54
+ * See {@link https://stackoverflow.com/a/49928360/3406963}
55
+ * @typeParam T - type which may be any
56
+ * ```
57
+ * IsAny<any> = true
58
+ * IsAny<string> = false
59
+ * ```
60
+ */
61
+ type IsAny<T> = 0 extends 1 & T ? true : false;
7
62
  /**
8
63
  * Checks whether T1 can be exactly (mutually) assigned to T2
9
64
  * @typeParam T1 - type to check
@@ -67,6 +122,46 @@ type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? Is
67
122
  }[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : {
68
123
  [K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>;
69
124
  }[keyof T];
125
+ /**
126
+ * Helper type for recursively constructing paths through a type.
127
+ * This actually constructs the strings and recurses into nested
128
+ * object types.
129
+ *
130
+ * See {@link ArrayPath}
131
+ */
132
+ type ArrayPathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : V extends ReadonlyArray<infer U> ? U extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}` | `${K}.${ArrayPathInternal<V, TraversedTypes | V>}` : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}.${ArrayPathInternal<V, TraversedTypes | V>}`;
133
+ /**
134
+ * Helper type for recursively constructing paths through a type.
135
+ * This obscures the internal type param TraversedTypes from ed contract.
136
+ *
137
+ * See {@link ArrayPath}
138
+ */
139
+ type ArrayPathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
140
+ [K in TupleKeys<T>]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
141
+ }[TupleKeys<T>] : ArrayPathImpl<ArrayKey, V, TraversedTypes> : {
142
+ [K in keyof T]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
143
+ }[keyof T];
144
+ /**
145
+ * Type which eagerly collects all paths through a type which point to an array
146
+ * type.
147
+ * @typeParam T - type which should be introspected.
148
+ * @example
149
+ * ```
150
+ * Path<{foo: {bar: string[], baz: number[]}}> = 'foo.bar' | 'foo.baz'
151
+ * ```
152
+ */
153
+ type ArrayPath<T> = T extends any ? ArrayPathInternal<T> : never;
154
+ /**
155
+ * Type to evaluate the type which the given path points to.
156
+ * @typeParam T - deeply nested type which is indexed by the path
157
+ * @typeParam P - path into the deeply nested type
158
+ * @example
159
+ * ```
160
+ * PathValue<{foo: {bar: string}}, 'foo.bar'> = string
161
+ * PathValue<[number, string], '1'> = string
162
+ * ```
163
+ */
164
+ type PathValue<T, P extends Path<T> | ArrayPath<T>> = T extends any ? P extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValue<V, R & Path<V>> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : never : never : never;
70
165
  /**
71
166
  * Type which eagerly collects all paths through a type
72
167
  * @typeParam T - type which should be introspected
@@ -525,6 +620,10 @@ type SegmentToPascalCase<S extends string> = S extends `${infer First}_${infer R
525
620
  * Also handles underscores by removing them and capitalizing each segment
526
621
  */
527
622
  type PathToPascalCase<P extends string> = P extends `${infer A}.${infer B}` ? `${SegmentToPascalCase<A>}${PathToPascalCase<B>}` : `${SegmentToPascalCase<P>}Field`;
623
+ /**
624
+ * Helper type to extract enum type from a schema path
625
+ */
626
+ type ExtractEnumType<T, P extends Path<T>> = P extends keyof T ? T[P] extends string ? T[P] : string : string;
528
627
  /**
529
628
  * Type that maps field paths to their corresponding enum types
530
629
  */
@@ -691,132 +790,309 @@ interface FieldMetadata {
691
790
  autocomplete?: string;
692
791
  }
693
792
 
793
+ interface ArrayFieldSlots<ItemType> {
794
+ itemRenderer: (props: {
795
+ item: ItemType;
796
+ index: number;
797
+ fields: FieldNames<ItemType>;
798
+ }) => any;
799
+ availableItemRenderer: (props: {
800
+ item: ItemType;
801
+ index: number;
802
+ }) => any;
803
+ itemActions: (props: {
804
+ item: ItemType;
805
+ index: number;
806
+ fields: FieldNames<ItemType>;
807
+ }) => any;
808
+ fieldSummary: (props: {
809
+ items: ItemType[];
810
+ }) => any;
811
+ default: () => any;
812
+ }
813
+
694
814
  /**
695
- * Types for schema metadata in the form system
815
+ * Functions for creating type-safe array fields
696
816
  */
697
817
 
698
818
  /**
699
- * Additional metadata that can be associated with schema fields
700
- * This interface defines properties that can be attached to schema fields
701
- * to customize their behavior and appearance
819
+ * Create a factory function that returns a properly typed ArrayField based on the field path
820
+ * This preserves the ItemType so that Vue's template slots are properly typed
821
+ *
822
+ * @param baseArrayField The base array field component
823
+ * @param fieldPath The field path to create an array field for
824
+ * @param metadata Optional metadata to apply to the field
825
+ * @returns A properly typed array field component with slot types preserved
702
826
  */
703
- interface SchemaFieldMetadata {
704
- /** The input type for rendering the field */
705
- inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local' | 'combobox' | 'array';
706
- /** Placeholder text for the field */
707
- placeholder?: string;
708
- /** The display label for the field */
709
- label?: string;
710
- /** Help text to display with the field */
711
- helpText?: string;
712
- /** For textarea fields, number of rows to display */
713
- rows?: number;
714
- /** For textarea fields, number of columns to display */
715
- cols?: number;
716
- /** For enum fields, map values to display labels */
717
- valueToLabel?: Record<string, string>;
718
- /** Whether to hide validation errors */
719
- hideError?: boolean;
720
- /** Step value for numeric fields */
721
- step?: number;
722
- /** Any other custom properties */
723
- [key: string]: any;
724
- }
827
+ 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>>, {}>;
828
+
725
829
  /**
726
- * Type for the registry mapping field paths to their metadata
830
+ * Functions for creating type-safe combobox fields
727
831
  */
728
- type MetadataRegistry = Record<string, SchemaFieldMetadata>;
832
+
729
833
  /**
730
- * Type helper to extract all possible paths from a Zod schema
834
+ * Create a factory function that returns a properly typed ComboboxField based on the field path
835
+ *
836
+ * @param baseComboboxField The base combobox field component
837
+ * @param fieldPath The field path to create a combobox field for
838
+ * @returns A factory function that creates a type-safe combobox field
839
+ *
840
+ * This preserves path-specific typing for features like dependsOn (cascading dropdowns)
841
+ * and ensures type safety between selectOptions and optionFilterFn
731
842
  */
732
- type PathsOf<T extends z.ZodTypeAny> = Path<z.infer<T>>;
733
-
734
- interface CurrencyFieldProps<FormType> {
735
- name: FlexiblePath<FormType>;
736
- label?: string;
737
- hideLabel?: boolean;
738
- description?: string;
739
- required?: boolean;
740
- placeholder?: string;
741
- disabled?: boolean;
742
- readonly?: boolean;
743
- class?: string | string[];
744
- size?: string;
745
- variant?: string;
746
- min?: number;
747
- max?: number;
748
- step?: number;
749
- }
843
+ 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;
750
844
 
751
- interface DateTimeLocalFieldProps<FormType> {
752
- name: FlexiblePath<FormType>;
753
- label?: string;
754
- hideLabel?: boolean;
755
- description?: string;
756
- required?: boolean;
757
- placeholder?: string;
758
- disabled?: boolean;
759
- readonly?: boolean;
760
- class?: string | string[];
761
- size?: string;
762
- variant?: string;
763
- min?: string;
764
- max?: string;
765
- step?: number;
766
- }
845
+ /**
846
+ * Functions for creating type-safe select fields
847
+ */
767
848
 
768
- interface EmailFieldProps<FormType> {
769
- name: FlexiblePath<FormType>;
770
- label?: string;
771
- hideLabel?: boolean;
772
- description?: string;
773
- required?: boolean;
774
- placeholder?: string;
775
- disabled?: boolean;
776
- readonly?: boolean;
777
- autocomplete?: string;
778
- class?: string | string[];
779
- size?: string;
780
- variant?: string;
849
+ /**
850
+ * Create a factory function that returns a properly typed SelectField based on the field path
851
+ *
852
+ * @param baseSelectField The base select field component
853
+ * @param fieldPath The field path to create a select field for
854
+ * @returns A factory function that creates a type-safe select field
855
+ */
856
+ 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"> & {
857
+ valueToLabel: Record<E, string>;
858
+ }, context?: any) => any;
859
+ /**
860
+ * Type-safe select field component with valueToLabel based on field path
861
+ */
862
+ interface TypedSelectFieldComponent<T> {
863
+ <P extends Path<T>>(props: Omit<SelectFieldProps<T>, 'valueToLabel'> & {
864
+ name: P;
865
+ valueToLabel?: Record<string, string>;
866
+ }): ReturnType<FunctionalComponent>;
781
867
  }
782
868
 
783
- interface FileFieldProps<FormType> {
784
- name: FlexiblePath<FormType>;
869
+ /**
870
+ * Type for display field components
871
+ */
872
+ type DisplayFieldComponent<T, P extends Path<T>, _FieldType extends string = 'string'> = (props: {
873
+ name?: P;
785
874
  label?: string;
786
875
  hideLabel?: boolean;
787
876
  description?: string;
788
- required?: boolean;
789
- disabled?: boolean;
790
- readonly?: boolean;
877
+ format?: 'default' | 'currency' | 'date' | 'datetime' | 'boolean' | 'email' | 'url' | 'phone' | 'number';
878
+ emptyText?: string;
791
879
  class?: string | string[];
792
880
  size?: string;
793
881
  variant?: string;
794
- accept?: string;
795
- multiple?: boolean;
796
- }
797
-
882
+ copyable?: boolean;
883
+ valueToLabel?: Record<string, string>;
884
+ separator?: string;
885
+ itemRenderer?: (item: any, index: number) => string;
886
+ maxItems?: number;
887
+ }, context?: any) => any;
798
888
  /**
799
- * Props for the FormErrorsSummary component
889
+ * Type for the display components object with PascalCase keys derived from field paths
890
+ * This mirrors the ComponentsType from the form system but with Display suffix
800
891
  */
801
- interface FormErrorsSummaryProps {
802
- /**
803
- * Custom title for the errors section
804
- */
805
- title?: string;
806
- /**
807
- * Whether to show the component only after form submission has been attempted
808
- * @default true
809
- */
810
- showOnlyAfterSubmitAttempt?: boolean;
811
- /**
812
- * Custom CSS class for the container
813
- */
814
- className?: string;
815
- /**
816
- * Icon to display next to the title
817
- * @default 'exclamation-circle'
818
- */
819
- icon?: string;
892
+ type DisplayComponentsType<T> = {
893
+ [K in Path<T> as `${PathToPascalCase<K & string>}` extends `${infer Base}Field` ? `${Base}Display` : `${PathToPascalCase<K & string>}Display`]: DisplayFieldComponent<T, K>;
894
+ };
895
+ /**
896
+ * Generate display field components for a schema based on metadata
897
+ *
898
+ * @param schema The Zod schema for the data
899
+ * @param fieldsMetadata Metadata for fields
900
+ * @param renderStyle The style to use for rendering
901
+ * @returns Generated display field components
902
+ */
903
+ declare function generateDisplayComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
904
+ generic: {
905
+ DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<T>>, {}, any, {}>;
906
+ fields: { [K in Path<z.TypeOf<T>>]: DisplayFieldComponent<z.TypeOf<T>, K, string>; };
907
+ field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
908
+ };
909
+ typed: DisplayComponentsType<z.TypeOf<T>>;
910
+ };
911
+
912
+ /**
913
+ * Generate field components for a schema based on metadata
914
+ *
915
+ * @param schema The Zod schema for the form
916
+ * @param fieldsMetadata Metadata for form fields
917
+ * @param renderStyle The style to use for rendering
918
+ * @returns Generated field components
919
+ */
920
+ declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
921
+ generic: {
922
+ TextField: vue.FunctionalComponent<TextFieldProps<z.TypeOf<T>>, {}, any, {}>;
923
+ NumberField: vue.FunctionalComponent<NumberFieldProps<z.TypeOf<T>>, {}, any, {}>;
924
+ SelectField: vue.FunctionalComponent<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
925
+ CheckboxField: vue.FunctionalComponent<CheckboxFieldProps<z.TypeOf<T>>, {}, any, {}>;
926
+ TextareaField: vue.FunctionalComponent<TextareaFieldProps<z.TypeOf<T>>, {}, any, {}>;
927
+ RadioField: vue.FunctionalComponent<RadioFieldProps<z.TypeOf<T>>, {}, any, {}>;
928
+ FileField: vue.FunctionalComponent<FileFieldProps<z.TypeOf<T>>, {}, any, {}>;
929
+ DateField: vue.FunctionalComponent<DateFieldProps<z.TypeOf<T>>, {}, any, {}>;
930
+ TimeField: vue.FunctionalComponent<TimeFieldProps<z.TypeOf<T>>, {}, any, {}>;
931
+ DateTimeLocalField: vue.FunctionalComponent<DateTimeLocalFieldProps<z.TypeOf<T>>, {}, any, {}>;
932
+ RangeField: vue.FunctionalComponent<RangeFieldProps<z.TypeOf<T>>, {}, any, {}>;
933
+ PasswordField: vue.FunctionalComponent<PasswordFieldProps<z.TypeOf<T>>, {}, any, {}>;
934
+ EmailField: vue.FunctionalComponent<EmailFieldProps<z.TypeOf<T>>, {}, any, {}>;
935
+ UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
936
+ TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
937
+ SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
938
+ ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
939
+ ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
940
+ itemRenderer: (props: {
941
+ item: any;
942
+ index: number;
943
+ fields: Record<string, string> | {
944
+ [x: string]: string;
945
+ };
946
+ }) => any;
947
+ availableItemRenderer: (props: {
948
+ item: any;
949
+ index: number;
950
+ }) => any;
951
+ itemActions: (props: {
952
+ item: any;
953
+ index: number;
954
+ fields: Record<string, string> | {
955
+ [x: string]: string;
956
+ };
957
+ }) => any;
958
+ fieldSummary: (props: {
959
+ items: any[];
960
+ }) => any;
961
+ default: () => any;
962
+ }, {}>;
963
+ TransferListField: vue.FunctionalComponent<TransferListFieldProps<z.TypeOf<T>, any>, {}, {
964
+ itemRenderer: (props: {
965
+ item: any;
966
+ index: number;
967
+ getFieldName: (fieldPath: string) => string;
968
+ }) => any;
969
+ availableItemRenderer: (props: {
970
+ item: any;
971
+ index: number;
972
+ }) => any;
973
+ selectedItemRenderer: (props: {
974
+ item: any;
975
+ index: number;
976
+ getFieldName: (fieldPath: string) => string;
977
+ }) => any;
978
+ default: () => any;
979
+ }, {}>;
980
+ ToppingsField: vue.FunctionalComponent<ToppingsFieldProps<z.TypeOf<T>, any>, {}, {
981
+ itemRenderer: (props: {
982
+ item: any;
983
+ index: number;
984
+ getFieldName: (fieldPath: string) => string;
985
+ }) => any;
986
+ availableItemRenderer: (props: {
987
+ item: any;
988
+ index: number;
989
+ }) => any;
990
+ toppingRenderer: (props: {
991
+ topping: any;
992
+ isSelected: boolean;
993
+ placement: string;
994
+ isExtra: boolean;
995
+ }) => any;
996
+ default: () => any;
997
+ }, {}>;
998
+ 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>>, any>, "name" | "valueToLabel"> & {
999
+ valueToLabel: Record<E, string>;
1000
+ }, context?: any) => any;
1001
+ 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>>, any>, "name" | "valueToLabel"> & {
1002
+ valueToLabel: Record<E, string>;
1003
+ }, context?: any) => any) | undefined; };
1004
+ fields: Record<Path<z.TypeOf<T>>, any>;
1005
+ field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
1006
+ };
1007
+ typed: ComponentsType<z.TypeOf<T>>;
1008
+ };
1009
+
1010
+ interface CurrencyFieldProps<FormType> {
1011
+ name: FlexiblePath<FormType>;
1012
+ label?: string;
1013
+ hideLabel?: boolean;
1014
+ description?: string;
1015
+ required?: boolean;
1016
+ placeholder?: string;
1017
+ disabled?: boolean;
1018
+ readonly?: boolean;
1019
+ class?: string | string[];
1020
+ size?: string;
1021
+ variant?: string;
1022
+ min?: number;
1023
+ max?: number;
1024
+ step?: number;
1025
+ }
1026
+
1027
+ interface DateTimeLocalFieldProps<FormType> {
1028
+ name: FlexiblePath<FormType>;
1029
+ label?: string;
1030
+ hideLabel?: boolean;
1031
+ description?: string;
1032
+ required?: boolean;
1033
+ placeholder?: string;
1034
+ disabled?: boolean;
1035
+ readonly?: boolean;
1036
+ class?: string | string[];
1037
+ size?: string;
1038
+ variant?: string;
1039
+ min?: string;
1040
+ max?: string;
1041
+ step?: number;
1042
+ }
1043
+
1044
+ interface EmailFieldProps<FormType> {
1045
+ name: FlexiblePath<FormType>;
1046
+ label?: string;
1047
+ hideLabel?: boolean;
1048
+ description?: string;
1049
+ required?: boolean;
1050
+ placeholder?: string;
1051
+ disabled?: boolean;
1052
+ readonly?: boolean;
1053
+ autocomplete?: string;
1054
+ class?: string | string[];
1055
+ size?: string;
1056
+ variant?: string;
1057
+ }
1058
+
1059
+ interface FileFieldProps<FormType> {
1060
+ name: FlexiblePath<FormType>;
1061
+ label?: string;
1062
+ hideLabel?: boolean;
1063
+ description?: string;
1064
+ required?: boolean;
1065
+ disabled?: boolean;
1066
+ readonly?: boolean;
1067
+ class?: string | string[];
1068
+ size?: string;
1069
+ variant?: string;
1070
+ accept?: string;
1071
+ multiple?: boolean;
1072
+ }
1073
+
1074
+ /**
1075
+ * Props for the FormErrorsSummary component
1076
+ */
1077
+ interface FormErrorsSummaryProps {
1078
+ /**
1079
+ * Custom title for the errors section
1080
+ */
1081
+ title?: string;
1082
+ /**
1083
+ * Whether to show the component only after form submission has been attempted
1084
+ * @default true
1085
+ */
1086
+ showOnlyAfterSubmitAttempt?: boolean;
1087
+ /**
1088
+ * Custom CSS class for the container
1089
+ */
1090
+ className?: string;
1091
+ /**
1092
+ * Icon to display next to the title
1093
+ * @default 'exclamation-circle'
1094
+ */
1095
+ icon?: string;
820
1096
  }
821
1097
 
822
1098
  interface FormProps<FormType> {
@@ -1197,6 +1473,33 @@ interface DataTableProps<FormType> {
1197
1473
  height?: 'auto' | 'fixed' | number | string;
1198
1474
  }
1199
1475
 
1476
+ /**
1477
+ * Common action icons as SVG strings
1478
+ * These are Heroicons (heroicons.com) in SVG format for easy use in actions
1479
+ */
1480
+ declare const ActionIcons: {
1481
+ 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>";
1482
+ 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>";
1483
+ 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>";
1484
+ 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>";
1485
+ 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>";
1486
+ 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>";
1487
+ 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>";
1488
+ 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>";
1489
+ 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>";
1490
+ 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>";
1491
+ 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>";
1492
+ 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>";
1493
+ 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>";
1494
+ 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>";
1495
+ readonly check: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\" /></svg>";
1496
+ readonly checkCircle: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\" /></svg>";
1497
+ readonly save: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" aria-hidden=\"true\" data-slot=\"icon\" fill=\"none\" class=\"size-6\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 20.25h12A2.25 2.25 0 0 0 20.25 18V7.5L16.5 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25zm9.75-16.5v5h-9.5v-5zM13 5.5V7m-6.75 4.25h11.5v6.5H6.25Z\"></path>\n</svg>";
1498
+ readonly spinner: "<svg class=\"animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\"><circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\"></circle><path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"></path></svg>";
1499
+ 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>";
1500
+ 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>";
1501
+ };
1502
+
1200
1503
  /**
1201
1504
  * Types for style creators in the form system
1202
1505
  */
@@ -1305,705 +1608,248 @@ interface StyleCreators {
1305
1608
  }
1306
1609
 
1307
1610
  /**
1308
- * Form state management hook
1309
- * Provides reactive form state with proper reactivity handling
1611
+ * Zinia Forms Plugin
1612
+ * Allows registering custom render styles at the application level
1310
1613
  */
1311
1614
 
1312
1615
  /**
1313
- * Form state interface
1616
+ * Plugin options for Zinia
1314
1617
  */
1315
- interface FormState<T, CalcType = any, ExtraDataType = any> {
1316
- data: T;
1317
- calculatedValues: CalcType;
1318
- touched: Record<string, boolean>;
1319
- dirty: Record<string, boolean>;
1320
- errors: Record<string, string>;
1321
- focused: Record<string, boolean>;
1322
- displayText: Record<string, string>;
1323
- selectedIndex: Record<string, number>;
1324
- collapsedFields: Record<string, {
1325
- isFieldCollapsed: boolean;
1326
- collapsedItems: number[];
1327
- defaultCollapsedInitialized: boolean;
1328
- }>;
1329
- undoHistory: Record<string, {
1330
- type: 'add' | 'remove' | 'swap';
1331
- previousState: any;
1332
- currentState: any;
1333
- timestamp: number;
1334
- }[]>;
1335
- redoHistory: Record<string, {
1336
- type: 'add' | 'remove' | 'swap';
1337
- previousState: any;
1338
- currentState: any;
1339
- timestamp: number;
1340
- }[]>;
1341
- pendingOperations: Record<string, {
1342
- type: 'add' | 'remove' | 'swap';
1343
- index?: number;
1344
- indexA?: number;
1345
- indexB?: number;
1346
- item?: any;
1347
- previousState: any;
1348
- currentState: any;
1349
- timestamp: number;
1350
- timeoutId?: number;
1351
- }[]>;
1352
- arrayItemIds: Record<string, string[]>;
1353
- isSubmitting: boolean;
1354
- hasAttemptedSubmit: boolean;
1355
- submitAttemptsCount: number;
1356
- submitError: string | null;
1357
- isReady: boolean;
1358
- isLoading: boolean;
1359
- loadError: string | null;
1360
- extraData: ExtraDataType;
1361
- fetchedOptions: Record<string, any[]>;
1362
- loadingOptions: Record<string, boolean>;
1363
- asyncCascadingParents: Record<string, string>;
1364
- loadingAutoPopulate: Record<string, boolean>;
1365
- populatingFields: Record<string, boolean>;
1618
+ interface ZiniaPluginOptions {
1619
+ /**
1620
+ * Map of style names to style creators
1621
+ */
1622
+ styles?: Record<string, StyleCreators>;
1623
+ /**
1624
+ * Default style to use if none specified in useForm
1625
+ */
1626
+ defaultStyle?: string;
1366
1627
  }
1367
-
1368
1628
  /**
1369
- * Type definitions for async cascading selection and auto-population
1629
+ * Vue plugin for Zinia Forms
1630
+ */
1631
+ declare const ZiniaPlugin: {
1632
+ install(app: App, options?: ZiniaPluginOptions): void;
1633
+ };
1634
+ /**
1635
+ * Get a registered style by name
1636
+ *
1637
+ * @param styleName Name of the style to get
1638
+ * @returns Style creators for the requested style or undefined if not found
1639
+ */
1640
+ declare function getRegisteredStyle(styleName?: string): StyleCreators | undefined;
1641
+ /**
1642
+ * Check if a style is registered
1643
+ *
1644
+ * @param styleName Name of the style to check
1645
+ * @returns True if the style is registered
1646
+ */
1647
+ declare function hasRegisteredStyle(styleName: string): boolean;
1648
+ /**
1649
+ * Get the default style name
1650
+ *
1651
+ * @returns Name of the default style
1652
+ */
1653
+ declare function getDefaultStyle(): string;
1654
+ /**
1655
+ * Get all registered style names
1656
+ *
1657
+ * @returns Array of registered style names
1658
+ */
1659
+ declare function getRegisteredStyleNames(): string[];
1660
+ /**
1661
+ * Register a style at runtime
1662
+ * Useful for dynamically loading styles
1663
+ *
1664
+ * @param styleName Name of the style to register
1665
+ * @param creators Style creators for the style
1370
1666
  */
1667
+ declare function registerStyle(styleName: string, creators: StyleCreators): void;
1371
1668
 
1372
1669
  /**
1373
- * Helper type to get the value type of a field path
1670
+ * Types for schema metadata in the form system
1374
1671
  */
1375
- type FieldValue<FormType, P extends Path<FormType>> = P extends keyof FormType ? FormType[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof FormType ? FormType[K] extends Record<string, any> ? FieldValue<FormType[K], Rest & Path<FormType[K]>> : never : never : never;
1672
+
1376
1673
  /**
1377
- * Configuration for async cascading selection (parent child options fetching via API)
1674
+ * Additional metadata that can be associated with schema fields
1675
+ * This interface defines properties that can be attached to schema fields
1676
+ * to customize their behavior and appearance
1378
1677
  */
1379
- interface AsyncCascadingSelectConfig<FormType, ParentField extends Path<FormType> = Path<FormType>, ChildField extends Path<FormType> = Path<FormType>> {
1380
- /** Parent field that triggers child options fetch */
1381
- parentField: ParentField;
1382
- /** Child field that will be populated with fetched options */
1383
- childField: ChildField;
1384
- /** Async function to fetch child options based on parent value */
1385
- fetchOptionsFn: (parentValue: FieldValue<FormType, ParentField>) => Promise<Array<SelectOption>>;
1386
- /** Whether to clear child field when parent changes (default: true) */
1387
- clearOnParentChange?: boolean;
1678
+ interface SchemaFieldMetadata {
1679
+ /** The input type for rendering the field */
1680
+ inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local' | 'combobox' | 'array';
1681
+ /** Placeholder text for the field */
1682
+ placeholder?: string;
1683
+ /** The display label for the field */
1684
+ label?: string;
1685
+ /** Help text to display with the field */
1686
+ helpText?: string;
1687
+ /** For textarea fields, number of rows to display */
1688
+ rows?: number;
1689
+ /** For textarea fields, number of columns to display */
1690
+ cols?: number;
1691
+ /** For enum fields, map values to display labels */
1692
+ valueToLabel?: Record<string, string>;
1693
+ /** Whether to hide validation errors */
1694
+ hideError?: boolean;
1695
+ /** Step value for numeric fields */
1696
+ step?: number;
1697
+ /** Any other custom properties */
1698
+ [key: string]: any;
1388
1699
  }
1389
1700
  /**
1390
- * Type for the async cascading selects configuration object
1391
- * Uses a mapped type to preserve field path type safety
1701
+ * Type for the registry mapping field paths to their metadata
1392
1702
  */
1393
- type AsyncCascadingSelectsConfig<FormType> = {
1394
- [K in string]: AsyncCascadingSelectConfig<FormType, Path<FormType>, Path<FormType>>;
1395
- };
1703
+ type MetadataRegistry = Record<string, SchemaFieldMetadata>;
1396
1704
  /**
1397
- * Configuration for auto-population (select/combobox other fields)
1705
+ * Type helper to extract all possible paths from a Zod schema
1398
1706
  */
1399
- interface AutoPopulateConfig<FormType, TData = any, SourceField extends Path<FormType> = Path<FormType>> {
1400
- /**
1401
- * Optional async function to fetch data when option is selected.
1402
- * If provided, this will be called instead of using option.data.
1403
- * Receives the selected option value and returns the data object.
1404
- */
1405
- fetchDataFn?: (selectedValue: FieldValue<FormType, SourceField>) => Promise<TData>;
1406
- /** Mapping of form fields to data properties for auto-population */
1407
- fields: {
1408
- [TargetField in Path<FormType>]?: string | ((data: TData) => FieldValue<FormType, TargetField>);
1409
- };
1410
- }
1707
+ type PathsOf<T extends z.ZodTypeAny> = Path<z.infer<T>>;
1708
+
1411
1709
  /**
1412
- * Type for the auto-populate configuration object
1413
- * Key is the select/combobox field name, value is the auto-populate config
1710
+ * Registry for storing schema metadata
1414
1711
  */
1415
- type AutoPopulateConfigs<FormType> = Partial<{
1416
- [SourceField in Path<FormType>]: AutoPopulateConfig<FormType, any>;
1417
- }>;
1418
1712
 
1419
1713
  /**
1420
- * Options for merging server data with local changes
1714
+ * Get metadata for a specific field in a schema
1715
+ *
1716
+ * @param schemaId Unique identifier for the schema
1717
+ * @param path Path to the field
1718
+ * @returns Metadata for the field or undefined if not found
1421
1719
  */
1422
- interface MergeOptions<T> {
1423
- /**
1424
- * Fields to preserve from local storage when merging with server data
1425
- * If not provided, all fields will be merged with local data taking precedence
1426
- */
1427
- preserveLocalFields?: (keyof T)[];
1428
- /**
1429
- * Custom merge function to handle complex merging logic
1430
- * If provided, this will be used instead of the default merge strategy
1431
- */
1432
- customMergeFunction?: (serverData: T, localData: T) => T;
1433
- }
1720
+ declare function getFieldMetadata(schemaId: string, path: string): SchemaFieldMetadata | undefined;
1721
+ /**
1722
+ * Get all metadata for a schema
1723
+ *
1724
+ * @param schemaId Unique identifier for the schema
1725
+ * @returns All metadata for the schema or an empty object if not found
1726
+ */
1727
+ declare function getAllSchemaMetadata(schemaId: string): MetadataRegistry;
1728
+ /**
1729
+ * Set metadata for a schema
1730
+ *
1731
+ * @param schemaId Unique identifier for the schema
1732
+ * @param metadata Object mapping field paths to their metadata
1733
+ */
1734
+ declare function setSchemaMetadata(schemaId: string, metadata: MetadataRegistry): void;
1735
+ /**
1736
+ * Check if a schema has metadata
1737
+ *
1738
+ * @param schemaId Unique identifier for the schema
1739
+ * @returns True if the schema has metadata, false otherwise
1740
+ */
1741
+ declare function hasSchemaMetadata(schemaId: string): boolean;
1742
+ /**
1743
+ * Clear metadata for a schema
1744
+ *
1745
+ * @param schemaId Unique identifier for the schema
1746
+ */
1747
+ declare function clearSchemaMetadata(schemaId: string): void;
1748
+ /**
1749
+ * Clear all metadata from the registry
1750
+ */
1751
+ declare function clearAllMetadata(): void;
1434
1752
 
1435
1753
  /**
1436
- * Types for registered styles
1437
- * This allows for autocomplete of registered style names
1754
+ * Functions for registering schema metadata
1438
1755
  */
1756
+
1439
1757
  /**
1440
- * Union type of all registered style names
1441
- * Update this when adding new built-in styles
1758
+ * Register metadata for a schema
1759
+ *
1760
+ * @param schemaId Unique identifier for the schema
1761
+ * @param metadata Object mapping field paths to their metadata
1442
1762
  */
1443
- type BuiltInStyleName = 'daisy_ui';
1763
+ declare function registerSchemaMetadata(schemaId: string, metadata: MetadataRegistry): void;
1444
1764
  /**
1445
- * Type for custom registered style names
1446
- * This is a string literal type that can be extended by users
1765
+ * Register metadata for a schema with type checking for field paths
1766
+ *
1767
+ * @param schema The Zod schema
1768
+ * @param schemaId Unique identifier for the schema
1769
+ * @param metadata Object mapping field paths to their metadata
1447
1770
  */
1448
- type CustomStyleName = string;
1771
+ declare function registerSchemaMetadata<T extends z.ZodObject<any>>(schema: T, schemaId: string, metadata: {
1772
+ [K in PathsOf<T>]?: SchemaFieldMetadata;
1773
+ }): void;
1774
+
1449
1775
  /**
1450
- * Union type of all possible style names
1451
- * This includes both built-in styles and custom styles
1776
+ * Functions for attaching metadata to schemas
1452
1777
  */
1453
- type RegisteredStyleName = BuiltInStyleName | CustomStyleName;
1454
1778
 
1455
- declare const ZINIA_FORM_KEY = "ziniaForm";
1456
- declare const ZINIA_FIELDS_KEY = "ziniaFields";
1457
- declare const ZINIA_FIELDS_GENERIC_KEY = "ziniaFieldsGeneric";
1458
- declare const ZINIA_FORM_SCHEMA_KEY = "ziniaFormSchema";
1459
- type DataLoaderReturnTypes<T> = {
1460
- [K in keyof T]: T[K] extends () => Promise<infer R> ? R : never;
1461
- };
1779
+ declare const SCHEMA_ID_SYMBOL: unique symbol;
1462
1780
  /**
1463
- * Create a type-safe form system using functional components
1781
+ * Helper function to get the schema ID from a schema object
1464
1782
  *
1465
- * @param schema The Zod schema for the form
1466
- * @param options Form options
1467
- * @returns Form API and components
1783
+ * @param schema Zod schema that might have a schema ID attached
1784
+ * @returns The schema ID or undefined if not found
1468
1785
  */
1469
- 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: {
1470
- storeName: string;
1471
- schemaId?: string;
1472
- persistToLocalStorage?: boolean;
1473
- initialValues?: Partial<z.infer<typeof schema>>;
1474
- renderStyle?: RegisteredStyleName;
1475
- autoProvide?: boolean;
1476
- validateOnMount?: boolean;
1477
- mergeOptions?: MergeOptions<z.infer<typeof schema>>;
1478
- dataLoaders?: {
1479
- [K in keyof ExtraDataType]?: () => Promise<ExtraDataType[K]>;
1480
- };
1481
- fetchData?: () => Promise<z.infer<typeof schema>>;
1482
- asyncCascadingSelects?: AsyncCascadingSelectsConfig<z.infer<T>>;
1483
- autoPopulate?: AutoPopulateConfigs<z.infer<T>>;
1484
- calculationFn?: (values: z.infer<T>, extraData?: ExtraDataType) => CalcType;
1485
- debug?: {
1486
- all?: boolean;
1487
- formState?: boolean;
1488
- validation?: boolean;
1489
- calculations?: boolean;
1490
- persistence?: boolean;
1491
- reactivity?: boolean;
1492
- };
1493
- }): {
1494
- form: {
1495
- storeName: string;
1496
- values: z.TypeOf<T>;
1497
- state: FormState<z.TypeOf<T>, CalcType, ExtraDataType>;
1498
- readonly calculatedValues: CalcType;
1499
- readonly extraData: ExtraDataType;
1500
- readonly isValid: boolean;
1501
- readonly isDirty: boolean;
1502
- isSubmitting: boolean;
1503
- readonly hasAttemptedSubmit: boolean;
1504
- readonly submitAttemptsCount: number;
1505
- readonly errors: Record<string, string>;
1506
- readonly touched: Record<string, boolean>;
1507
- readonly dirty: Record<string, boolean>;
1508
- readonly collapsedFields: Record<string, {
1509
- isFieldCollapsed: boolean;
1510
- collapsedItems: number[];
1511
- defaultCollapsedInitialized: boolean;
1512
- }>;
1513
- readonly undoHistory: Record<string, {
1514
- type: "add" | "remove" | "swap";
1515
- previousState: any;
1516
- currentState: any;
1517
- timestamp: number;
1518
- }[]>;
1519
- readonly redoHistory: Record<string, {
1520
- type: "add" | "remove" | "swap";
1521
- previousState: any;
1522
- currentState: any;
1523
- timestamp: number;
1524
- }[]>;
1525
- readonly pendingOperations: Record<string, {
1526
- type: "add" | "remove" | "swap";
1527
- index?: number;
1528
- indexA?: number;
1529
- indexB?: number;
1530
- item?: any;
1531
- previousState: any;
1532
- currentState: any;
1533
- timestamp: number;
1534
- timeoutId?: number;
1535
- }[]>;
1536
- readonly fieldsMetadata: Record<string, FieldMetadata>;
1537
- validate: (options?: {
1538
- markErrorsAsTouched: boolean;
1539
- }) => boolean;
1540
- validateField: (path: string) => boolean;
1541
- reset: (newInitialData?: z.TypeOf<T> | undefined) => void;
1542
- setSubmitting: (value: boolean) => void;
1543
- incrementSubmitAttempts: () => void;
1544
- setSubmitError: (error: string | null) => void;
1545
- readonly isReady: boolean;
1546
- readonly isLoading: boolean;
1547
- readonly loadError: string | null;
1548
- readonly submitError: string | null;
1549
- setLoading: (value: boolean) => void;
1550
- setReady: (value: boolean) => void;
1551
- setLoadError: (error: string | null) => void;
1552
- getValue: (path: string) => any;
1553
- setValue: (path: string, value: any) => void;
1554
- touchField: (path: string) => void;
1555
- isTouched: (path: string) => boolean;
1556
- isDirtyField: (path: string) => boolean;
1557
- resetField: (path: string) => void;
1558
- hasError: (path: string) => boolean;
1559
- getError: (path: string) => string;
1560
- setFocus: (path: string, value: boolean) => void;
1561
- isFocused: (path: string) => boolean;
1562
- setDisplayText: (path: string, text: string) => void;
1563
- getDisplayText: (path: string) => string;
1564
- setSelectedIndex: (path: string, index: number) => void;
1565
- getSelectedIndex: (path: string) => number;
1566
- getArrayItemId: (path: string, index: number) => string;
1567
- addArrayItemId: (path: string, index?: number) => string;
1568
- removeArrayItemId: (path: string, index: number) => void;
1569
- swapArrayItemIds: (path: string, indexA: number, indexB: number) => void;
1570
- syncArrayItemIds: (path: string) => void;
1571
- };
1572
- ZiniaForm: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
1573
- ZiniaSubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
1574
- ZiniaResetButton: vue.FunctionalComponent<ResetButtonProps<z.TypeOf<T>>, {}, any, {}>;
1575
- ZiniaFormErrorsSummary: vue.FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
1576
- zinia: ComponentsType<z.TypeOf<T>>;
1577
- ziniaGeneric: {
1578
- TextField: vue.FunctionalComponent<TextFieldProps<z.TypeOf<T>>, {}, any, {}>;
1579
- NumberField: vue.FunctionalComponent<NumberFieldProps<z.TypeOf<T>>, {}, any, {}>;
1580
- SelectField: vue.FunctionalComponent<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
1581
- CheckboxField: vue.FunctionalComponent<CheckboxFieldProps<z.TypeOf<T>>, {}, any, {}>;
1582
- TextareaField: vue.FunctionalComponent<TextareaFieldProps<z.TypeOf<T>>, {}, any, {}>;
1583
- RadioField: vue.FunctionalComponent<RadioFieldProps<z.TypeOf<T>>, {}, any, {}>;
1584
- FileField: vue.FunctionalComponent<FileFieldProps<z.TypeOf<T>>, {}, any, {}>;
1585
- DateField: vue.FunctionalComponent<DateFieldProps<z.TypeOf<T>>, {}, any, {}>;
1586
- TimeField: vue.FunctionalComponent<TimeFieldProps<z.TypeOf<T>>, {}, any, {}>;
1587
- DateTimeLocalField: vue.FunctionalComponent<DateTimeLocalFieldProps<z.TypeOf<T>>, {}, any, {}>;
1588
- RangeField: vue.FunctionalComponent<RangeFieldProps<z.TypeOf<T>>, {}, any, {}>;
1589
- PasswordField: vue.FunctionalComponent<PasswordFieldProps<z.TypeOf<T>>, {}, any, {}>;
1590
- EmailField: vue.FunctionalComponent<EmailFieldProps<z.TypeOf<T>>, {}, any, {}>;
1591
- UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
1592
- TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
1593
- SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
1594
- ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
1595
- ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
1596
- itemRenderer: (props: {
1597
- item: any;
1598
- index: number;
1599
- fields: Record<string, string> | {
1600
- [x: string]: string;
1601
- };
1602
- }) => any;
1603
- availableItemRenderer: (props: {
1604
- item: any;
1605
- index: number;
1606
- }) => any;
1607
- itemActions: (props: {
1608
- item: any;
1609
- index: number;
1610
- fields: Record<string, string> | {
1611
- [x: string]: string;
1612
- };
1613
- }) => any;
1614
- fieldSummary: (props: {
1615
- items: any[];
1616
- }) => any;
1617
- default: () => any;
1618
- }, {}>;
1619
- TransferListField: vue.FunctionalComponent<TransferListFieldProps<z.TypeOf<T>, any>, {}, {
1620
- itemRenderer: (props: {
1621
- item: any;
1622
- index: number;
1623
- getFieldName: (fieldPath: string) => string;
1624
- }) => any;
1625
- availableItemRenderer: (props: {
1626
- item: any;
1627
- index: number;
1628
- }) => any;
1629
- selectedItemRenderer: (props: {
1630
- item: any;
1631
- index: number;
1632
- getFieldName: (fieldPath: string) => string;
1633
- }) => any;
1634
- default: () => any;
1635
- }, {}>;
1636
- ToppingsField: vue.FunctionalComponent<ToppingsFieldProps<z.TypeOf<T>, any>, {}, {
1637
- itemRenderer: (props: {
1638
- item: any;
1639
- index: number;
1640
- getFieldName: (fieldPath: string) => string;
1641
- }) => any;
1642
- availableItemRenderer: (props: {
1643
- item: any;
1644
- index: number;
1645
- }) => any;
1646
- toppingRenderer: (props: {
1647
- topping: any;
1648
- isSelected: boolean;
1649
- placement: string;
1650
- isExtra: boolean;
1651
- }) => any;
1652
- default: () => any;
1653
- }, {}>;
1654
- 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>>, any>, "name" | "valueToLabel"> & {
1655
- valueToLabel: Record<E, string>;
1656
- }, context?: any) => any;
1657
- 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>>, any>, "name" | "valueToLabel"> & {
1658
- valueToLabel: Record<E, string>;
1659
- }, context?: any) => any) | undefined; };
1660
- fields: Record<Path<z.TypeOf<T>>, any>;
1661
- field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
1662
- };
1663
- load: () => Promise<void>;
1664
- loadAllData: () => Promise<void>;
1665
- refreshFormData: () => Promise<void>;
1666
- clearSavedFormState: () => void;
1667
- refreshData: (keys?: Array<keyof ExtraDataType>) => Promise<void>;
1668
- };
1669
- type UseFormType = ReturnType<typeof useForm>;
1670
- type ZiniaForm = UseFormType['form'];
1671
- type ZiniaFormFields = UseFormType['zinia'];
1672
- type ZiniaFormGenericFields = UseFormType['ziniaGeneric'];
1673
- type UseFormTyped<T extends z.ZodObject<any>, CalcType = any, ExtraDataType extends Record<string, any> = Record<string, any>> = ReturnType<typeof useForm<T, CalcType, ExtraDataType>>;
1674
-
1675
- /**
1676
- * Create base form components for a schema
1677
- *
1678
- * @param schema The Zod schema for the form
1679
- * @param renderStyle The style to use for rendering
1680
- * @returns Base form components (Form, SubmitButton, ResetButton)
1681
- */
1682
- declare function createBaseComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
1683
- Form: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
1684
- SubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
1685
- ResetButton: vue.FunctionalComponent<ResetButtonProps<z.TypeOf<T>>, {}, any, {}>;
1686
- FormErrorsSummary: vue.FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
1687
- };
1688
-
1689
- /**
1690
- * Create base display components using registered styles
1691
- *
1692
- * @param schema The Zod schema for the data
1693
- * @param styleName The style to use for rendering
1694
- * @returns Base display components
1695
- */
1696
- declare function createBaseDisplayComponents<T extends z.ZodObject<any>>(schema: T, styleName?: RegisteredStyleName): {
1697
- ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<T>>, {}, any, {}>;
1698
- };
1699
-
1700
- interface ArrayFieldSlots<ItemType> {
1701
- itemRenderer: (props: {
1702
- item: ItemType;
1703
- index: number;
1704
- fields: FieldNames<ItemType>;
1705
- }) => any;
1706
- availableItemRenderer: (props: {
1707
- item: ItemType;
1708
- index: number;
1709
- }) => any;
1710
- itemActions: (props: {
1711
- item: ItemType;
1712
- index: number;
1713
- fields: FieldNames<ItemType>;
1714
- }) => any;
1715
- fieldSummary: (props: {
1716
- items: ItemType[];
1717
- }) => any;
1718
- default: () => any;
1719
- }
1720
-
1721
- /**
1722
- * Functions for creating type-safe array fields
1723
- */
1724
-
1725
- /**
1726
- * Create a factory function that returns a properly typed ArrayField based on the field path
1727
- * This preserves the ItemType so that Vue's template slots are properly typed
1728
- *
1729
- * @param baseArrayField The base array field component
1730
- * @param fieldPath The field path to create an array field for
1731
- * @param metadata Optional metadata to apply to the field
1732
- * @returns A properly typed array field component with slot types preserved
1733
- */
1734
- 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>>, {}>;
1735
-
1736
- /**
1737
- * Functions for creating type-safe combobox fields
1738
- */
1739
-
1740
- /**
1741
- * Create a factory function that returns a properly typed ComboboxField based on the field path
1742
- *
1743
- * @param baseComboboxField The base combobox field component
1744
- * @param fieldPath The field path to create a combobox field for
1745
- * @returns A factory function that creates a type-safe combobox field
1746
- *
1747
- * This preserves path-specific typing for features like dependsOn (cascading dropdowns)
1748
- * and ensures type safety between selectOptions and optionFilterFn
1749
- */
1750
- 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;
1751
-
1752
- /**
1753
- * Functions for creating type-safe select fields
1754
- */
1755
-
1756
- /**
1757
- * Create a factory function that returns a properly typed SelectField based on the field path
1758
- *
1759
- * @param baseSelectField The base select field component
1760
- * @param fieldPath The field path to create a select field for
1761
- * @returns A factory function that creates a type-safe select field
1762
- */
1763
- 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"> & {
1764
- valueToLabel: Record<E, string>;
1765
- }, context?: any) => any;
1766
- /**
1767
- * Type-safe select field component with valueToLabel based on field path
1768
- */
1769
- interface TypedSelectFieldComponent<T> {
1770
- <P extends Path<T>>(props: Omit<SelectFieldProps<T>, 'valueToLabel'> & {
1771
- name: P;
1772
- valueToLabel?: Record<string, string>;
1773
- }): ReturnType<FunctionalComponent>;
1774
- }
1775
-
1776
- /**
1777
- * Type for display field components
1778
- */
1779
- type DisplayFieldComponent<T, P extends Path<T>, _FieldType extends string = 'string'> = (props: {
1780
- name?: P;
1781
- label?: string;
1782
- hideLabel?: boolean;
1783
- description?: string;
1784
- format?: 'default' | 'currency' | 'date' | 'datetime' | 'boolean' | 'email' | 'url' | 'phone' | 'number';
1785
- emptyText?: string;
1786
- class?: string | string[];
1787
- size?: string;
1788
- variant?: string;
1789
- copyable?: boolean;
1790
- valueToLabel?: Record<string, string>;
1791
- separator?: string;
1792
- itemRenderer?: (item: any, index: number) => string;
1793
- maxItems?: number;
1794
- }, context?: any) => any;
1795
- /**
1796
- * Type for the display components object with PascalCase keys derived from field paths
1797
- * This mirrors the ComponentsType from the form system but with Display suffix
1798
- */
1799
- type DisplayComponentsType<T> = {
1800
- [K in Path<T> as `${PathToPascalCase<K & string>}` extends `${infer Base}Field` ? `${Base}Display` : `${PathToPascalCase<K & string>}Display`]: DisplayFieldComponent<T, K>;
1801
- };
1802
- /**
1803
- * Generate display field components for a schema based on metadata
1804
- *
1805
- * @param schema The Zod schema for the data
1806
- * @param fieldsMetadata Metadata for fields
1807
- * @param renderStyle The style to use for rendering
1808
- * @returns Generated display field components
1809
- */
1810
- declare function generateDisplayComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
1811
- generic: {
1812
- DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<T>>, {}, any, {}>;
1813
- fields: { [K in Path<z.TypeOf<T>>]: DisplayFieldComponent<z.TypeOf<T>, K, string>; };
1814
- field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
1815
- };
1816
- typed: DisplayComponentsType<z.TypeOf<T>>;
1817
- };
1818
-
1819
- /**
1820
- * Generate field components for a schema based on metadata
1821
- *
1822
- * @param schema The Zod schema for the form
1823
- * @param fieldsMetadata Metadata for form fields
1824
- * @param renderStyle The style to use for rendering
1825
- * @returns Generated field components
1826
- */
1827
- declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T, fieldsMetadata: Record<string, FieldMetadata>, styleName?: RegisteredStyleName): {
1828
- generic: {
1829
- TextField: vue.FunctionalComponent<TextFieldProps<z.TypeOf<T>>, {}, any, {}>;
1830
- NumberField: vue.FunctionalComponent<NumberFieldProps<z.TypeOf<T>>, {}, any, {}>;
1831
- SelectField: vue.FunctionalComponent<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
1832
- CheckboxField: vue.FunctionalComponent<CheckboxFieldProps<z.TypeOf<T>>, {}, any, {}>;
1833
- TextareaField: vue.FunctionalComponent<TextareaFieldProps<z.TypeOf<T>>, {}, any, {}>;
1834
- RadioField: vue.FunctionalComponent<RadioFieldProps<z.TypeOf<T>>, {}, any, {}>;
1835
- FileField: vue.FunctionalComponent<FileFieldProps<z.TypeOf<T>>, {}, any, {}>;
1836
- DateField: vue.FunctionalComponent<DateFieldProps<z.TypeOf<T>>, {}, any, {}>;
1837
- TimeField: vue.FunctionalComponent<TimeFieldProps<z.TypeOf<T>>, {}, any, {}>;
1838
- DateTimeLocalField: vue.FunctionalComponent<DateTimeLocalFieldProps<z.TypeOf<T>>, {}, any, {}>;
1839
- RangeField: vue.FunctionalComponent<RangeFieldProps<z.TypeOf<T>>, {}, any, {}>;
1840
- PasswordField: vue.FunctionalComponent<PasswordFieldProps<z.TypeOf<T>>, {}, any, {}>;
1841
- EmailField: vue.FunctionalComponent<EmailFieldProps<z.TypeOf<T>>, {}, any, {}>;
1842
- UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
1843
- TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
1844
- SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
1845
- ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
1846
- ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
1847
- itemRenderer: (props: {
1848
- item: any;
1849
- index: number;
1850
- fields: Record<string, string> | {
1851
- [x: string]: string;
1852
- };
1853
- }) => any;
1854
- availableItemRenderer: (props: {
1855
- item: any;
1856
- index: number;
1857
- }) => any;
1858
- itemActions: (props: {
1859
- item: any;
1860
- index: number;
1861
- fields: Record<string, string> | {
1862
- [x: string]: string;
1863
- };
1864
- }) => any;
1865
- fieldSummary: (props: {
1866
- items: any[];
1867
- }) => any;
1868
- default: () => any;
1869
- }, {}>;
1870
- TransferListField: vue.FunctionalComponent<TransferListFieldProps<z.TypeOf<T>, any>, {}, {
1871
- itemRenderer: (props: {
1872
- item: any;
1873
- index: number;
1874
- getFieldName: (fieldPath: string) => string;
1875
- }) => any;
1876
- availableItemRenderer: (props: {
1877
- item: any;
1878
- index: number;
1879
- }) => any;
1880
- selectedItemRenderer: (props: {
1881
- item: any;
1882
- index: number;
1883
- getFieldName: (fieldPath: string) => string;
1884
- }) => any;
1885
- default: () => any;
1886
- }, {}>;
1887
- ToppingsField: vue.FunctionalComponent<ToppingsFieldProps<z.TypeOf<T>, any>, {}, {
1888
- itemRenderer: (props: {
1889
- item: any;
1890
- index: number;
1891
- getFieldName: (fieldPath: string) => string;
1892
- }) => any;
1893
- availableItemRenderer: (props: {
1894
- item: any;
1895
- index: number;
1896
- }) => any;
1897
- toppingRenderer: (props: {
1898
- topping: any;
1899
- isSelected: boolean;
1900
- placement: string;
1901
- isExtra: boolean;
1902
- }) => any;
1903
- default: () => any;
1904
- }, {}>;
1905
- 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>>, any>, "name" | "valueToLabel"> & {
1906
- valueToLabel: Record<E, string>;
1907
- }, context?: any) => any;
1908
- 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>>, any>, "name" | "valueToLabel"> & {
1909
- valueToLabel: Record<E, string>;
1910
- }, context?: any) => any) | undefined; };
1911
- fields: Record<Path<z.TypeOf<T>>, any>;
1912
- field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
1913
- };
1914
- typed: ComponentsType<z.TypeOf<T>>;
1915
- };
1786
+ declare function getSchemaId(schema: z.ZodTypeAny): string | undefined;
1787
+ /**
1788
+ * Helper function to create a schema with associated metadata
1789
+ *
1790
+ * @param schema Zod schema
1791
+ * @param schemaId Unique identifier for the schema
1792
+ * @param metadata Metadata for the schema fields
1793
+ * @returns The original schema with the schema ID attached
1794
+ */
1795
+ declare function withMetadata<T extends z.ZodObject<any>>(schema: T, schemaId: string, metadata: {
1796
+ [K in PathsOf<T>]?: SchemaFieldMetadata;
1797
+ }): T;
1916
1798
 
1917
- interface NoDataDisplayProps {
1918
- message?: string;
1919
- class?: string;
1920
- variant?: 'info' | 'warning';
1921
- }
1922
- declare const NoDataDisplay: FunctionalComponent<NoDataDisplayProps>;
1799
+ /**
1800
+ * DaisyUI style package
1801
+ * Provides all component creators for the DaisyUI style
1802
+ */
1923
1803
 
1924
- interface ErrorDisplayProps {
1925
- error: string | Error | unknown;
1926
- class?: string;
1927
- variant?: 'error' | 'warning' | 'info';
1928
- }
1929
- declare const ErrorDisplay: FunctionalComponent<ErrorDisplayProps>;
1804
+ /**
1805
+ * Complete set of DaisyUI style creators
1806
+ * Can be registered with the Zinia plugin
1807
+ */
1808
+ declare const daisyUIStyle: StyleCreators;
1930
1809
 
1931
- interface LoadingDisplayProps {
1932
- message?: string;
1933
- size?: 'sm' | 'md' | 'lg';
1934
- class?: string;
1935
- }
1936
- declare const LoadingDisplay: FunctionalComponent<LoadingDisplayProps>;
1810
+ /**
1811
+ * Helper functions for creating and extending render styles
1812
+ */
1937
1813
 
1938
- declare const ZINIA_DISPLAY_KEY = "ziniaDisplay";
1939
- declare const ZINIA_DISPLAY_FIELDS_KEY = "ziniaDisplayFields";
1940
- declare const ZINIA_DISPLAY_FIELDS_GENERIC_KEY = "ziniaDisplayFieldsGeneric";
1941
- declare const ZINIA_DISPLAY_SCHEMA_KEY = "ziniaDisplaySchema";
1942
- interface DisplayOptions<TData, TExtra extends Record<string, any>> {
1943
- data?: TData | Ref<TData>;
1944
- schemaId?: string;
1945
- storeName?: string;
1946
- renderStyle?: RegisteredStyleName;
1947
- autoProvide?: boolean;
1948
- loading?: boolean | Ref<boolean>;
1949
- error?: string | null | Ref<string | null>;
1950
- fetchData?: () => Promise<TData>;
1951
- dataLoaders?: {
1952
- [K in keyof TExtra]?: () => Promise<TExtra[K]>;
1953
- };
1954
- autoLoad?: boolean;
1955
- onLoad?: (data: TData) => void;
1956
- onError?: (error: Error) => void;
1957
- debug?: boolean;
1958
- }
1959
- declare function useDisplay<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>>(schema: TSchema, options?: DisplayOptions<z.infer<TSchema>, TExtra>): {
1960
- display: {
1961
- storeName: string;
1962
- readonly data: z.TypeOf<TSchema> | null;
1963
- readonly extraData: TExtra;
1964
- readonly isLoading: boolean;
1965
- readonly isReady: boolean;
1966
- readonly error: string | null;
1967
- readonly lastLoadTime: number | null;
1968
- fieldsMetadata: Record<string, FieldMetadata>;
1969
- readonly isAsyncMode: boolean;
1970
- load: (options_?: {
1971
- data?: boolean;
1972
- extra?: boolean;
1973
- specificLoaders?: Array<keyof TExtra>;
1974
- }) => Promise<void>;
1975
- loadData: () => Promise<void>;
1976
- loadExtraData: (keys?: Array<keyof TExtra>) => Promise<void>;
1977
- loadAllData: () => Promise<void>;
1978
- refreshData: () => Promise<void>;
1979
- clear: () => void;
1980
- getValue: (path: string) => any;
1981
- };
1982
- ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<TSchema>>, {}, any, {}>;
1983
- LoadingDisplay: vue.FunctionalComponent<LoadingDisplayProps, {}, any, {}>;
1984
- ErrorDisplay: vue.FunctionalComponent<ErrorDisplayProps, {}, any, {}>;
1985
- NoDataDisplay: vue.FunctionalComponent<NoDataDisplayProps, {}, any, {}>;
1986
- zinia: DisplayComponentsType<z.TypeOf<TSchema>>;
1987
- ziniaGeneric: {
1988
- DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<TSchema>>, {}, any, {}>;
1989
- fields: { [K in Path<z.TypeOf<TSchema>>]: DisplayFieldComponent<z.TypeOf<TSchema>, K, string>; };
1990
- field: <P extends Path<z.TypeOf<TSchema>>>(path: P) => any;
1991
- };
1992
- load: (options_?: {
1993
- data?: boolean;
1994
- extra?: boolean;
1995
- specificLoaders?: Array<keyof TExtra>;
1996
- }) => Promise<void>;
1997
- loadData: () => Promise<void>;
1998
- loadExtraData: (keys?: Array<keyof TExtra>) => Promise<void>;
1999
- loadAllData: () => Promise<void>;
2000
- refreshData: () => Promise<void>;
2001
- clear: () => void;
2002
- };
2003
- type UseDisplayType<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = ReturnType<typeof useDisplay<TSchema, TExtra>>;
2004
- type ZiniaDisplay<TSchema extends z.ZodObject<any> = z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['display'];
2005
- type ZiniaDisplayFields<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['zinia'];
2006
- type ZiniaDisplayGenericFields<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['ziniaGeneric'];
1814
+ /**
1815
+ * Extend an existing style with custom overrides
1816
+ *
1817
+ * @param baseStyle The base style to extend
1818
+ * @param overrides Custom overrides for specific components
1819
+ * @returns A new style that combines the base style with the overrides
1820
+ */
1821
+ declare function extendStyle(baseStyle: StyleCreators, overrides: Partial<StyleCreators>): StyleCreators;
1822
+ /**
1823
+ * Merge multiple styles together
1824
+ * Later styles will override earlier ones for any overlapping components
1825
+ *
1826
+ * @param styles Array of styles to merge
1827
+ * @returns A new style that combines all the provided styles
1828
+ */
1829
+ declare function mergeStyles(...styles: Array<Partial<StyleCreators>>): StyleCreators;
1830
+ /**
1831
+ * Create a partial style with only the components you need
1832
+ * Useful when you want to override just a few components in a base style
1833
+ *
1834
+ * @param creators Object containing only the component creators you want to override
1835
+ * @returns A partial style object that can be used with extendStyle
1836
+ */
1837
+ declare function createPartialStyle<T extends Partial<StyleCreators>>(creators: T): T;
1838
+ /**
1839
+ * Create a style template with placeholder implementations
1840
+ * Useful as a starting point for creating a completely new style
1841
+ *
1842
+ * @returns A style object with placeholder implementations that throw errors
1843
+ */
1844
+ declare function createStyleTemplate(): StyleCreators;
1845
+
1846
+ /**
1847
+ * Types for render styles in the form system
1848
+ */
1849
+ /**
1850
+ * Available rendering styles for form components
1851
+ */
1852
+ type RenderStyle = 'daisy_ui';
2007
1853
 
2008
1854
  declare const ZINIA_DATA_TABLE_KEY = "ziniaDataTable";
2009
1855
  declare const ZINIA_DATA_TABLE_COLUMNS_KEY = "ziniaDataTableColumns";
@@ -2416,6 +2262,27 @@ declare function useCursorDataTable<TSchema extends z.ZodObject<any>>(schema: TS
2416
2262
  };
2417
2263
  type UseCursorDataTableType<TSchema extends z.ZodObject<any>> = ReturnType<typeof useCursorDataTable<TSchema>>;
2418
2264
 
2265
+ interface NoDataDisplayProps {
2266
+ message?: string;
2267
+ class?: string;
2268
+ variant?: 'info' | 'warning';
2269
+ }
2270
+ declare const NoDataDisplay: FunctionalComponent<NoDataDisplayProps>;
2271
+
2272
+ interface ErrorDisplayProps {
2273
+ error: string | Error | unknown;
2274
+ class?: string;
2275
+ variant?: 'error' | 'warning' | 'info';
2276
+ }
2277
+ declare const ErrorDisplay: FunctionalComponent<ErrorDisplayProps>;
2278
+
2279
+ interface LoadingDisplayProps {
2280
+ message?: string;
2281
+ size?: 'sm' | 'md' | 'lg';
2282
+ class?: string;
2283
+ }
2284
+ declare const LoadingDisplay: FunctionalComponent<LoadingDisplayProps>;
2285
+
2419
2286
  declare const ZINIA_DELETE_MODAL_KEY = "ziniaDeleteModal";
2420
2287
  declare const ZINIA_DELETE_MODAL_FIELDS_KEY = "ziniaDeleteModalFields";
2421
2288
  declare const ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY = "ziniaDeleteModalFieldsGeneric";
@@ -2460,228 +2327,486 @@ type ZiniaDeleteModal<TSchema extends z.ZodObject<any>> = UseDeleteModalType<TSc
2460
2327
  type ZiniaDeleteModalFields<TSchema extends z.ZodObject<any>> = UseDeleteModalType<TSchema>['zinia'];
2461
2328
  type ZiniaDeleteModalGenericFields<TSchema extends z.ZodObject<any>> = UseDeleteModalType<TSchema>['ziniaGeneric'];
2462
2329
 
2330
+ declare const ZINIA_DISPLAY_KEY = "ziniaDisplay";
2331
+ declare const ZINIA_DISPLAY_FIELDS_KEY = "ziniaDisplayFields";
2332
+ declare const ZINIA_DISPLAY_FIELDS_GENERIC_KEY = "ziniaDisplayFieldsGeneric";
2333
+ declare const ZINIA_DISPLAY_SCHEMA_KEY = "ziniaDisplaySchema";
2334
+ interface DisplayOptions<TData, TExtra extends Record<string, any>> {
2335
+ data?: TData | Ref<TData>;
2336
+ schemaId?: string;
2337
+ storeName?: string;
2338
+ renderStyle?: RegisteredStyleName;
2339
+ autoProvide?: boolean;
2340
+ loading?: boolean | Ref<boolean>;
2341
+ error?: string | null | Ref<string | null>;
2342
+ fetchData?: () => Promise<TData>;
2343
+ dataLoaders?: {
2344
+ [K in keyof TExtra]?: () => Promise<TExtra[K]>;
2345
+ };
2346
+ autoLoad?: boolean;
2347
+ onLoad?: (data: TData) => void;
2348
+ onError?: (error: Error) => void;
2349
+ debug?: boolean;
2350
+ }
2351
+ declare function useDisplay<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>>(schema: TSchema, options?: DisplayOptions<z.infer<TSchema>, TExtra>): {
2352
+ display: {
2353
+ storeName: string;
2354
+ readonly data: z.TypeOf<TSchema> | null;
2355
+ readonly extraData: TExtra;
2356
+ readonly isLoading: boolean;
2357
+ readonly isReady: boolean;
2358
+ readonly error: string | null;
2359
+ readonly lastLoadTime: number | null;
2360
+ fieldsMetadata: Record<string, FieldMetadata>;
2361
+ readonly isAsyncMode: boolean;
2362
+ load: (options_?: {
2363
+ data?: boolean;
2364
+ extra?: boolean;
2365
+ specificLoaders?: Array<keyof TExtra>;
2366
+ }) => Promise<void>;
2367
+ loadData: () => Promise<void>;
2368
+ loadExtraData: (keys?: Array<keyof TExtra>) => Promise<void>;
2369
+ loadAllData: () => Promise<void>;
2370
+ refreshData: () => Promise<void>;
2371
+ clear: () => void;
2372
+ getValue: (path: string) => any;
2373
+ };
2374
+ ZiniaDisplay: vue.FunctionalComponent<DisplayProps<z.TypeOf<TSchema>>, {}, any, {}>;
2375
+ LoadingDisplay: vue.FunctionalComponent<LoadingDisplayProps, {}, any, {}>;
2376
+ ErrorDisplay: vue.FunctionalComponent<ErrorDisplayProps, {}, any, {}>;
2377
+ NoDataDisplay: vue.FunctionalComponent<NoDataDisplayProps, {}, any, {}>;
2378
+ zinia: DisplayComponentsType<z.TypeOf<TSchema>>;
2379
+ ziniaGeneric: {
2380
+ DisplayField: vue.FunctionalComponent<DisplayFieldProps<z.TypeOf<TSchema>>, {}, any, {}>;
2381
+ fields: { [K in Path<z.TypeOf<TSchema>>]: DisplayFieldComponent<z.TypeOf<TSchema>, K, string>; };
2382
+ field: <P extends Path<z.TypeOf<TSchema>>>(path: P) => any;
2383
+ };
2384
+ load: (options_?: {
2385
+ data?: boolean;
2386
+ extra?: boolean;
2387
+ specificLoaders?: Array<keyof TExtra>;
2388
+ }) => Promise<void>;
2389
+ loadData: () => Promise<void>;
2390
+ loadExtraData: (keys?: Array<keyof TExtra>) => Promise<void>;
2391
+ loadAllData: () => Promise<void>;
2392
+ refreshData: () => Promise<void>;
2393
+ clear: () => void;
2394
+ };
2395
+ type UseDisplayType<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = ReturnType<typeof useDisplay<TSchema, TExtra>>;
2396
+ type ZiniaDisplay<TSchema extends z.ZodObject<any> = z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['display'];
2397
+ type ZiniaDisplayFields<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['zinia'];
2398
+ type ZiniaDisplayGenericFields<TSchema extends z.ZodObject<any>, TExtra extends Record<string, any> = Record<string, any>> = UseDisplayType<TSchema, TExtra>['ziniaGeneric'];
2399
+
2463
2400
  /**
2464
- * Registry for storing schema metadata
2401
+ * Type definitions for async cascading selection and auto-population
2465
2402
  */
2466
2403
 
2467
2404
  /**
2468
- * Get metadata for a specific field in a schema
2469
- *
2470
- * @param schemaId Unique identifier for the schema
2471
- * @param path Path to the field
2472
- * @returns Metadata for the field or undefined if not found
2473
- */
2474
- declare function getFieldMetadata(schemaId: string, path: string): SchemaFieldMetadata | undefined;
2475
- /**
2476
- * Get all metadata for a schema
2477
- *
2478
- * @param schemaId Unique identifier for the schema
2479
- * @returns All metadata for the schema or an empty object if not found
2480
- */
2481
- declare function getAllSchemaMetadata(schemaId: string): MetadataRegistry;
2482
- /**
2483
- * Set metadata for a schema
2484
- *
2485
- * @param schemaId Unique identifier for the schema
2486
- * @param metadata Object mapping field paths to their metadata
2487
- */
2488
- declare function setSchemaMetadata(schemaId: string, metadata: MetadataRegistry): void;
2489
- /**
2490
- * Check if a schema has metadata
2491
- *
2492
- * @param schemaId Unique identifier for the schema
2493
- * @returns True if the schema has metadata, false otherwise
2494
- */
2495
- declare function hasSchemaMetadata(schemaId: string): boolean;
2496
- /**
2497
- * Clear metadata for a schema
2498
- *
2499
- * @param schemaId Unique identifier for the schema
2405
+ * Helper type to get the value type of a field path
2500
2406
  */
2501
- declare function clearSchemaMetadata(schemaId: string): void;
2407
+ type FieldValue<FormType, P extends Path<FormType>> = P extends keyof FormType ? FormType[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof FormType ? FormType[K] extends Record<string, any> ? FieldValue<FormType[K], Rest & Path<FormType[K]>> : never : never : never;
2502
2408
  /**
2503
- * Clear all metadata from the registry
2409
+ * Configuration for async cascading selection (parent → child options fetching via API)
2504
2410
  */
2505
- declare function clearAllMetadata(): void;
2506
-
2411
+ interface AsyncCascadingSelectConfig<FormType, ParentField extends Path<FormType> = Path<FormType>, ChildField extends Path<FormType> = Path<FormType>> {
2412
+ /** Parent field that triggers child options fetch */
2413
+ parentField: ParentField;
2414
+ /** Child field that will be populated with fetched options */
2415
+ childField: ChildField;
2416
+ /** Async function to fetch child options based on parent value */
2417
+ fetchOptionsFn: (parentValue: FieldValue<FormType, ParentField>) => Promise<Array<SelectOption>>;
2418
+ /** Whether to clear child field when parent changes (default: true) */
2419
+ clearOnParentChange?: boolean;
2420
+ }
2507
2421
  /**
2508
- * Functions for registering schema metadata
2422
+ * Type for the async cascading selects configuration object
2423
+ * Uses a mapped type to preserve field path type safety
2509
2424
  */
2510
-
2425
+ type AsyncCascadingSelectsConfig<FormType> = {
2426
+ [K in string]: AsyncCascadingSelectConfig<FormType, Path<FormType>, Path<FormType>>;
2427
+ };
2511
2428
  /**
2512
- * Register metadata for a schema
2513
- *
2514
- * @param schemaId Unique identifier for the schema
2515
- * @param metadata Object mapping field paths to their metadata
2429
+ * Configuration for auto-population (select/combobox → other fields)
2516
2430
  */
2517
- declare function registerSchemaMetadata(schemaId: string, metadata: MetadataRegistry): void;
2431
+ interface AutoPopulateConfig<FormType, TData = any, SourceField extends Path<FormType> = Path<FormType>> {
2432
+ /**
2433
+ * Optional async function to fetch data when option is selected.
2434
+ * If provided, this will be called instead of using option.data.
2435
+ * Receives the selected option value and returns the data object.
2436
+ */
2437
+ fetchDataFn?: (selectedValue: FieldValue<FormType, SourceField>) => Promise<TData>;
2438
+ /** Mapping of form fields to data properties for auto-population */
2439
+ fields: {
2440
+ [TargetField in Path<FormType>]?: string | ((data: TData) => FieldValue<FormType, TargetField>);
2441
+ };
2442
+ }
2518
2443
  /**
2519
- * Register metadata for a schema with type checking for field paths
2520
- *
2521
- * @param schema The Zod schema
2522
- * @param schemaId Unique identifier for the schema
2523
- * @param metadata Object mapping field paths to their metadata
2444
+ * Type for the auto-populate configuration object
2445
+ * Key is the select/combobox field name, value is the auto-populate config
2524
2446
  */
2525
- declare function registerSchemaMetadata<T extends z.ZodObject<any>>(schema: T, schemaId: string, metadata: {
2526
- [K in PathsOf<T>]?: SchemaFieldMetadata;
2527
- }): void;
2447
+ type AutoPopulateConfigs<FormType> = Partial<{
2448
+ [SourceField in Path<FormType>]: AutoPopulateConfig<FormType, any>;
2449
+ }>;
2528
2450
 
2529
2451
  /**
2530
- * Functions for attaching metadata to schemas
2452
+ * Options for merging server data with local changes
2531
2453
  */
2454
+ interface MergeOptions<T> {
2455
+ /**
2456
+ * Fields to preserve from local storage when merging with server data
2457
+ * If not provided, all fields will be merged with local data taking precedence
2458
+ */
2459
+ preserveLocalFields?: (keyof T)[];
2460
+ /**
2461
+ * Custom merge function to handle complex merging logic
2462
+ * If provided, this will be used instead of the default merge strategy
2463
+ */
2464
+ customMergeFunction?: (serverData: T, localData: T) => T;
2465
+ }
2532
2466
 
2533
- declare const SCHEMA_ID_SYMBOL: unique symbol;
2534
- /**
2535
- * Helper function to get the schema ID from a schema object
2536
- *
2537
- * @param schema Zod schema that might have a schema ID attached
2538
- * @returns The schema ID or undefined if not found
2539
- */
2540
- declare function getSchemaId(schema: z.ZodTypeAny): string | undefined;
2467
+ declare const ZINIA_FORM_KEY = "ziniaForm";
2468
+ declare const ZINIA_FIELDS_KEY = "ziniaFields";
2469
+ declare const ZINIA_FIELDS_GENERIC_KEY = "ziniaFieldsGeneric";
2470
+ declare const ZINIA_FORM_SCHEMA_KEY = "ziniaFormSchema";
2471
+ type DataLoaderReturnTypes<T> = {
2472
+ [K in keyof T]: T[K] extends () => Promise<infer R> ? R : never;
2473
+ };
2541
2474
  /**
2542
- * Helper function to create a schema with associated metadata
2475
+ * Create a type-safe form system using functional components
2543
2476
  *
2544
- * @param schema Zod schema
2545
- * @param schemaId Unique identifier for the schema
2546
- * @param metadata Metadata for the schema fields
2547
- * @returns The original schema with the schema ID attached
2477
+ * @param schema The Zod schema for the form
2478
+ * @param options Form options
2479
+ * @returns Form API and components
2548
2480
  */
2549
- declare function withMetadata<T extends z.ZodObject<any>>(schema: T, schemaId: string, metadata: {
2550
- [K in PathsOf<T>]?: SchemaFieldMetadata;
2551
- }): T;
2481
+ 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: {
2482
+ storeName: string;
2483
+ schemaId?: string;
2484
+ persistToLocalStorage?: boolean;
2485
+ initialValues?: Partial<z.infer<typeof schema>>;
2486
+ renderStyle?: RegisteredStyleName;
2487
+ autoProvide?: boolean;
2488
+ validateOnMount?: boolean;
2489
+ mergeOptions?: MergeOptions<z.infer<typeof schema>>;
2490
+ dataLoaders?: {
2491
+ [K in keyof ExtraDataType]?: () => Promise<ExtraDataType[K]>;
2492
+ };
2493
+ fetchData?: () => Promise<z.infer<typeof schema>>;
2494
+ asyncCascadingSelects?: AsyncCascadingSelectsConfig<z.infer<T>>;
2495
+ autoPopulate?: AutoPopulateConfigs<z.infer<T>>;
2496
+ calculationFn?: (values: z.infer<T>, extraData?: ExtraDataType) => CalcType;
2497
+ debug?: {
2498
+ all?: boolean;
2499
+ formState?: boolean;
2500
+ validation?: boolean;
2501
+ calculations?: boolean;
2502
+ persistence?: boolean;
2503
+ reactivity?: boolean;
2504
+ };
2505
+ }): {
2506
+ form: {
2507
+ storeName: string;
2508
+ values: z.TypeOf<T>;
2509
+ state: FormState<z.TypeOf<T>, CalcType, ExtraDataType>;
2510
+ readonly calculatedValues: CalcType;
2511
+ readonly extraData: ExtraDataType;
2512
+ readonly isValid: boolean;
2513
+ readonly isDirty: boolean;
2514
+ isSubmitting: boolean;
2515
+ readonly hasAttemptedSubmit: boolean;
2516
+ readonly submitAttemptsCount: number;
2517
+ readonly errors: Record<string, string>;
2518
+ readonly touched: Record<string, boolean>;
2519
+ readonly dirty: Record<string, boolean>;
2520
+ readonly collapsedFields: Record<string, {
2521
+ isFieldCollapsed: boolean;
2522
+ collapsedItems: number[];
2523
+ defaultCollapsedInitialized: boolean;
2524
+ }>;
2525
+ readonly undoHistory: Record<string, {
2526
+ type: "add" | "remove" | "swap";
2527
+ previousState: any;
2528
+ currentState: any;
2529
+ timestamp: number;
2530
+ }[]>;
2531
+ readonly redoHistory: Record<string, {
2532
+ type: "add" | "remove" | "swap";
2533
+ previousState: any;
2534
+ currentState: any;
2535
+ timestamp: number;
2536
+ }[]>;
2537
+ readonly pendingOperations: Record<string, {
2538
+ type: "add" | "remove" | "swap";
2539
+ index?: number;
2540
+ indexA?: number;
2541
+ indexB?: number;
2542
+ item?: any;
2543
+ previousState: any;
2544
+ currentState: any;
2545
+ timestamp: number;
2546
+ timeoutId?: number;
2547
+ }[]>;
2548
+ readonly fieldsMetadata: Record<string, FieldMetadata>;
2549
+ validate: (options?: {
2550
+ markErrorsAsTouched: boolean;
2551
+ }) => boolean;
2552
+ validateField: (path: string) => boolean;
2553
+ reset: (newInitialData?: z.TypeOf<T> | undefined) => void;
2554
+ setSubmitting: (value: boolean) => void;
2555
+ incrementSubmitAttempts: () => void;
2556
+ setSubmitError: (error: string | null) => void;
2557
+ readonly isReady: boolean;
2558
+ readonly isLoading: boolean;
2559
+ readonly loadError: string | null;
2560
+ readonly submitError: string | null;
2561
+ setLoading: (value: boolean) => void;
2562
+ setReady: (value: boolean) => void;
2563
+ setLoadError: (error: string | null) => void;
2564
+ getValue: (path: string) => any;
2565
+ setValue: (path: string, value: any) => void;
2566
+ touchField: (path: string) => void;
2567
+ isTouched: (path: string) => boolean;
2568
+ isDirtyField: (path: string) => boolean;
2569
+ resetField: (path: string) => void;
2570
+ hasError: (path: string) => boolean;
2571
+ getError: (path: string) => string;
2572
+ setFocus: (path: string, value: boolean) => void;
2573
+ isFocused: (path: string) => boolean;
2574
+ setDisplayText: (path: string, text: string) => void;
2575
+ getDisplayText: (path: string) => string;
2576
+ setSelectedIndex: (path: string, index: number) => void;
2577
+ getSelectedIndex: (path: string) => number;
2578
+ getArrayItemId: (path: string, index: number) => string;
2579
+ addArrayItemId: (path: string, index?: number) => string;
2580
+ removeArrayItemId: (path: string, index: number) => void;
2581
+ swapArrayItemIds: (path: string, indexA: number, indexB: number) => void;
2582
+ syncArrayItemIds: (path: string) => void;
2583
+ };
2584
+ ZiniaForm: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
2585
+ ZiniaSubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
2586
+ ZiniaResetButton: vue.FunctionalComponent<ResetButtonProps<z.TypeOf<T>>, {}, any, {}>;
2587
+ ZiniaFormErrorsSummary: vue.FunctionalComponent<FormErrorsSummaryProps, {}, any, {}>;
2588
+ zinia: ComponentsType<z.TypeOf<T>>;
2589
+ ziniaGeneric: {
2590
+ TextField: vue.FunctionalComponent<TextFieldProps<z.TypeOf<T>>, {}, any, {}>;
2591
+ NumberField: vue.FunctionalComponent<NumberFieldProps<z.TypeOf<T>>, {}, any, {}>;
2592
+ SelectField: vue.FunctionalComponent<SelectFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
2593
+ CheckboxField: vue.FunctionalComponent<CheckboxFieldProps<z.TypeOf<T>>, {}, any, {}>;
2594
+ TextareaField: vue.FunctionalComponent<TextareaFieldProps<z.TypeOf<T>>, {}, any, {}>;
2595
+ RadioField: vue.FunctionalComponent<RadioFieldProps<z.TypeOf<T>>, {}, any, {}>;
2596
+ FileField: vue.FunctionalComponent<FileFieldProps<z.TypeOf<T>>, {}, any, {}>;
2597
+ DateField: vue.FunctionalComponent<DateFieldProps<z.TypeOf<T>>, {}, any, {}>;
2598
+ TimeField: vue.FunctionalComponent<TimeFieldProps<z.TypeOf<T>>, {}, any, {}>;
2599
+ DateTimeLocalField: vue.FunctionalComponent<DateTimeLocalFieldProps<z.TypeOf<T>>, {}, any, {}>;
2600
+ RangeField: vue.FunctionalComponent<RangeFieldProps<z.TypeOf<T>>, {}, any, {}>;
2601
+ PasswordField: vue.FunctionalComponent<PasswordFieldProps<z.TypeOf<T>>, {}, any, {}>;
2602
+ EmailField: vue.FunctionalComponent<EmailFieldProps<z.TypeOf<T>>, {}, any, {}>;
2603
+ UrlField: vue.FunctionalComponent<UrlFieldProps<z.TypeOf<T>>, {}, any, {}>;
2604
+ TelField: vue.FunctionalComponent<TelFieldProps<z.TypeOf<T>>, {}, any, {}>;
2605
+ SearchField: vue.FunctionalComponent<SearchFieldProps<z.TypeOf<T>>, {}, any, {}>;
2606
+ ComboboxField: vue.FunctionalComponent<ComboboxFieldProps<z.TypeOf<T>, Path<z.TypeOf<T>>, any>, {}, any, {}>;
2607
+ ArrayField: vue.FunctionalComponent<ArrayFieldProps<z.TypeOf<T>, any>, {}, {
2608
+ itemRenderer: (props: {
2609
+ item: any;
2610
+ index: number;
2611
+ fields: Record<string, string> | {
2612
+ [x: string]: string;
2613
+ };
2614
+ }) => any;
2615
+ availableItemRenderer: (props: {
2616
+ item: any;
2617
+ index: number;
2618
+ }) => any;
2619
+ itemActions: (props: {
2620
+ item: any;
2621
+ index: number;
2622
+ fields: Record<string, string> | {
2623
+ [x: string]: string;
2624
+ };
2625
+ }) => any;
2626
+ fieldSummary: (props: {
2627
+ items: any[];
2628
+ }) => any;
2629
+ default: () => any;
2630
+ }, {}>;
2631
+ TransferListField: vue.FunctionalComponent<TransferListFieldProps<z.TypeOf<T>, any>, {}, {
2632
+ itemRenderer: (props: {
2633
+ item: any;
2634
+ index: number;
2635
+ getFieldName: (fieldPath: string) => string;
2636
+ }) => any;
2637
+ availableItemRenderer: (props: {
2638
+ item: any;
2639
+ index: number;
2640
+ }) => any;
2641
+ selectedItemRenderer: (props: {
2642
+ item: any;
2643
+ index: number;
2644
+ getFieldName: (fieldPath: string) => string;
2645
+ }) => any;
2646
+ default: () => any;
2647
+ }, {}>;
2648
+ ToppingsField: vue.FunctionalComponent<ToppingsFieldProps<z.TypeOf<T>, any>, {}, {
2649
+ itemRenderer: (props: {
2650
+ item: any;
2651
+ index: number;
2652
+ getFieldName: (fieldPath: string) => string;
2653
+ }) => any;
2654
+ availableItemRenderer: (props: {
2655
+ item: any;
2656
+ index: number;
2657
+ }) => any;
2658
+ toppingRenderer: (props: {
2659
+ topping: any;
2660
+ isSelected: boolean;
2661
+ placement: string;
2662
+ isExtra: boolean;
2663
+ }) => any;
2664
+ default: () => any;
2665
+ }, {}>;
2666
+ 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>>, any>, "name" | "valueToLabel"> & {
2667
+ valueToLabel: Record<E, string>;
2668
+ }, context?: any) => any;
2669
+ 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>>, any>, "name" | "valueToLabel"> & {
2670
+ valueToLabel: Record<E, string>;
2671
+ }, context?: any) => any) | undefined; };
2672
+ fields: Record<Path<z.TypeOf<T>>, any>;
2673
+ field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
2674
+ };
2675
+ load: () => Promise<void>;
2676
+ loadAllData: () => Promise<void>;
2677
+ refreshFormData: () => Promise<void>;
2678
+ clearSavedFormState: () => void;
2679
+ refreshData: (keys?: Array<keyof ExtraDataType>) => Promise<void>;
2680
+ };
2681
+ type UseFormType = ReturnType<typeof useForm>;
2682
+ type ZiniaForm = UseFormType['form'];
2683
+ type ZiniaFormFields = UseFormType['zinia'];
2684
+ type ZiniaFormGenericFields = UseFormType['ziniaGeneric'];
2685
+ type UseFormTyped<T extends z.ZodObject<any>, CalcType = any, ExtraDataType extends Record<string, any> = Record<string, any>> = ReturnType<typeof useForm<T, CalcType, ExtraDataType>>;
2552
2686
 
2553
2687
  /**
2554
- * Zinia Forms Plugin
2555
- * Allows registering custom render styles at the application level
2688
+ * Form state management hook
2689
+ * Provides reactive form state with proper reactivity handling
2556
2690
  */
2557
2691
 
2558
2692
  /**
2559
- * Plugin options for Zinia
2693
+ * Form state interface
2560
2694
  */
2561
- interface ZiniaPluginOptions {
2562
- /**
2563
- * Map of style names to style creators
2564
- */
2565
- styles?: Record<string, StyleCreators>;
2566
- /**
2567
- * Default style to use if none specified in useForm
2568
- */
2569
- defaultStyle?: string;
2695
+ interface FormState<T, CalcType = any, ExtraDataType = any> {
2696
+ data: T;
2697
+ calculatedValues: CalcType;
2698
+ touched: Record<string, boolean>;
2699
+ dirty: Record<string, boolean>;
2700
+ errors: Record<string, string>;
2701
+ focused: Record<string, boolean>;
2702
+ displayText: Record<string, string>;
2703
+ selectedIndex: Record<string, number>;
2704
+ collapsedFields: Record<string, {
2705
+ isFieldCollapsed: boolean;
2706
+ collapsedItems: number[];
2707
+ defaultCollapsedInitialized: boolean;
2708
+ }>;
2709
+ undoHistory: Record<string, {
2710
+ type: 'add' | 'remove' | 'swap';
2711
+ previousState: any;
2712
+ currentState: any;
2713
+ timestamp: number;
2714
+ }[]>;
2715
+ redoHistory: Record<string, {
2716
+ type: 'add' | 'remove' | 'swap';
2717
+ previousState: any;
2718
+ currentState: any;
2719
+ timestamp: number;
2720
+ }[]>;
2721
+ pendingOperations: Record<string, {
2722
+ type: 'add' | 'remove' | 'swap';
2723
+ index?: number;
2724
+ indexA?: number;
2725
+ indexB?: number;
2726
+ item?: any;
2727
+ previousState: any;
2728
+ currentState: any;
2729
+ timestamp: number;
2730
+ timeoutId?: number;
2731
+ }[]>;
2732
+ arrayItemIds: Record<string, string[]>;
2733
+ isSubmitting: boolean;
2734
+ hasAttemptedSubmit: boolean;
2735
+ submitAttemptsCount: number;
2736
+ submitError: string | null;
2737
+ isReady: boolean;
2738
+ isLoading: boolean;
2739
+ loadError: string | null;
2740
+ extraData: ExtraDataType;
2741
+ fetchedOptions: Record<string, any[]>;
2742
+ loadingOptions: Record<string, boolean>;
2743
+ asyncCascadingParents: Record<string, string>;
2744
+ loadingAutoPopulate: Record<string, boolean>;
2745
+ populatingFields: Record<string, boolean>;
2570
2746
  }
2571
2747
  /**
2572
- * Vue plugin for Zinia Forms
2573
- */
2574
- declare const ZiniaPlugin: {
2575
- install(app: App, options?: ZiniaPluginOptions): void;
2576
- };
2577
- /**
2578
- * Get a registered style by name
2579
- *
2580
- * @param styleName Name of the style to get
2581
- * @returns Style creators for the requested style or undefined if not found
2582
- */
2583
- declare function getRegisteredStyle(styleName?: string): StyleCreators | undefined;
2584
- /**
2585
- * Check if a style is registered
2586
- *
2587
- * @param styleName Name of the style to check
2588
- * @returns True if the style is registered
2589
- */
2590
- declare function hasRegisteredStyle(styleName: string): boolean;
2591
- /**
2592
- * Get the default style name
2593
- *
2594
- * @returns Name of the default style
2595
- */
2596
- declare function getDefaultStyle(): string;
2597
- /**
2598
- * Get all registered style names
2599
- *
2600
- * @returns Array of registered style names
2601
- */
2602
- declare function getRegisteredStyleNames(): string[];
2603
- /**
2604
- * Register a style at runtime
2605
- * Useful for dynamically loading styles
2748
+ * Create and manage form state with proper reactivity
2606
2749
  *
2607
- * @param styleName Name of the style to register
2608
- * @param creators Style creators for the style
2609
- */
2610
- declare function registerStyle(styleName: string, creators: StyleCreators): void;
2611
-
2612
- /**
2613
- * DaisyUI style package
2614
- * Provides all component creators for the DaisyUI style
2750
+ * @param initialData Initial form data
2751
+ * @param options Options for form state
2752
+ * @returns Form state and methods
2615
2753
  */
2616
-
2754
+ declare function useFormState<T, CalcType = any, ExtraDataType = any>(initialData: T, options?: {
2755
+ hasFetchData?: boolean;
2756
+ calculationFn?: (data: T, extraData?: ExtraDataType) => CalcType;
2757
+ storeName: string;
2758
+ debug?: boolean;
2759
+ extraData?: ExtraDataType;
2760
+ }): {
2761
+ state: FormState<T, CalcType, ExtraDataType>;
2762
+ calculatedValues: ComputedRef<CalcType>;
2763
+ isValid: ComputedRef<boolean>;
2764
+ isDirty: ComputedRef<boolean>;
2765
+ isSubmitting: ComputedRef<boolean>;
2766
+ hasAttemptedSubmit: ComputedRef<boolean>;
2767
+ submitAttemptsCount: ComputedRef<number>;
2768
+ submitError: ComputedRef<string | null>;
2769
+ isReady: ComputedRef<boolean>;
2770
+ isLoading: ComputedRef<boolean>;
2771
+ loadError: ComputedRef<string | null>;
2772
+ reset: (newInitialData?: T) => void;
2773
+ setSubmitting: (value: boolean) => void;
2774
+ incrementSubmitAttempts: () => void;
2775
+ setSubmitError: (error: string | null) => void;
2776
+ setLoading: (value: boolean) => void;
2777
+ setReady: (value: boolean) => void;
2778
+ setLoadError: (error: string | null) => void;
2779
+ updateExtraData: <E = ExtraDataType>(updates: Partial<E>) => void;
2780
+ };
2617
2781
  /**
2618
- * Complete set of DaisyUI style creators
2619
- * Can be registered with the Zinia plugin
2782
+ * Result of the useFormState hook
2620
2783
  */
2621
- declare const daisyUIStyle: StyleCreators;
2784
+ type FormStateResult<T, CalcType = any, ExtraDataType = any> = ReturnType<typeof useFormState<T, CalcType, ExtraDataType>>;
2622
2785
 
2623
2786
  /**
2624
- * Helper functions for creating and extending render styles
2787
+ * Form validation hook
2788
+ * Provides validation functions for form data
2625
2789
  */
2626
2790
 
2627
2791
  /**
2628
- * Extend an existing style with custom overrides
2629
- *
2630
- * @param baseStyle The base style to extend
2631
- * @param overrides Custom overrides for specific components
2632
- * @returns A new style that combines the base style with the overrides
2633
- */
2634
- declare function extendStyle(baseStyle: StyleCreators, overrides: Partial<StyleCreators>): StyleCreators;
2635
- /**
2636
- * Merge multiple styles together
2637
- * Later styles will override earlier ones for any overlapping components
2638
- *
2639
- * @param styles Array of styles to merge
2640
- * @returns A new style that combines all the provided styles
2641
- */
2642
- declare function mergeStyles(...styles: Array<Partial<StyleCreators>>): StyleCreators;
2643
- /**
2644
- * Create a partial style with only the components you need
2645
- * Useful when you want to override just a few components in a base style
2646
- *
2647
- * @param creators Object containing only the component creators you want to override
2648
- * @returns A partial style object that can be used with extendStyle
2649
- */
2650
- declare function createPartialStyle<T extends Partial<StyleCreators>>(creators: T): T;
2651
- /**
2652
- * Create a style template with placeholder implementations
2653
- * Useful as a starting point for creating a completely new style
2792
+ * Create form validation functions
2654
2793
  *
2655
- * @returns A style object with placeholder implementations that throw errors
2794
+ * @param schema The Zod schema for validation
2795
+ * @param formState The form state to validate
2796
+ * @returns Validation functions
2656
2797
  */
2657
- declare function createStyleTemplate(): StyleCreators;
2658
-
2798
+ declare function useFormValidation<T>(schema: z.ZodObject<any>, formState: FormState<T>, options?: {
2799
+ debug?: boolean;
2800
+ }): {
2801
+ validate: (options?: {
2802
+ markErrorsAsTouched: boolean;
2803
+ }) => boolean;
2804
+ validateField: (path: string) => boolean;
2805
+ };
2659
2806
  /**
2660
- * Common action icons as SVG strings
2661
- * These are Heroicons (heroicons.com) in SVG format for easy use in actions
2807
+ * Result of the useFormValidation hook
2662
2808
  */
2663
- declare const ActionIcons: {
2664
- 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>";
2665
- 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>";
2666
- 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>";
2667
- 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>";
2668
- 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>";
2669
- 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>";
2670
- 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>";
2671
- 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>";
2672
- 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>";
2673
- 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>";
2674
- 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>";
2675
- 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>";
2676
- 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>";
2677
- 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>";
2678
- readonly check: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\" /></svg>";
2679
- readonly checkCircle: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\" /></svg>";
2680
- readonly save: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" aria-hidden=\"true\" data-slot=\"icon\" fill=\"none\" class=\"size-6\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 20.25h12A2.25 2.25 0 0 0 20.25 18V7.5L16.5 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25zm9.75-16.5v5h-9.5v-5zM13 5.5V7m-6.75 4.25h11.5v6.5H6.25Z\"></path>\n</svg>";
2681
- readonly spinner: "<svg class=\"animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\"><circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\"></circle><path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"></path></svg>";
2682
- 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>";
2683
- 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>";
2684
- };
2809
+ type FormValidationResult<T> = ReturnType<typeof useFormValidation<T>>;
2685
2810
 
2686
2811
  /**
2687
2812
  * Debug configuration for Zinia Forms
@@ -2702,4 +2827,4 @@ declare const DEBUG_CONFIG: {
2702
2827
  */
2703
2828
  declare function isDebugEnabled(area: keyof Omit<typeof DEBUG_CONFIG, 'all'>): boolean;
2704
2829
 
2705
- 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, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };
2830
+ export { ActionIcons, type ActionItem, type ActionsConfig, type ArrayFieldProps, type ArrayFieldSlots, type ArrayItemType, type AsyncCascadingSelectsConfig, type AutoPopulateConfigs, type ButtonActionItem, COMBOBOX_FIELD_PROP_NAMES, type CheckboxFieldProps, type ColumnDefinition, type ComboboxFieldProps, type ComponentsType, 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 ExtractEnumType, type FetchDataParams, type FetchDataResult, type FieldMetadata, type FieldNames, type FieldPathToEnum, type FieldType, type FileFieldProps, type FilterOptionItem, type FilterValue, type FormErrorsSummaryProps, type FormProps, type FormState, type FormStateResult, type FormValidationResult, type LinkActionItem, LoadingDisplay, type MergeOptions, type MetadataRegistry, NoDataDisplay, type NumberFieldProps, type PasswordFieldProps, type Path, type PathToPascalCase, type PathValue, type PathsOf, type RadioFieldProps, type RangeFieldProps, type RenderStyle, type ResetButtonProps, SCHEMA_ID_SYMBOL, SELECT_FIELD_PROP_NAMES, type SchemaFieldMetadata, type SearchFieldProps, type SelectFieldProps, type SelectOption, type StyleCreators, 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, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };