@dragonmastery/zinia-forms-core 0.5.5 → 0.5.7

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
@@ -278,13 +278,13 @@ interface SelectOption<TData = Record<string, any>> {
278
278
  */
279
279
  type ZodEnumValues<T extends z.ZodEnum<[string, ...string[]]>> = T['_def']['values'][number];
280
280
  /**
281
- * Type for a mapping of enum values to labels
281
+ * Type for a mapping of enum values to labels (values and labels can be string or number)
282
282
  */
283
- type EnumValueToLabelMap<T extends string> = Record<T, string>;
283
+ type EnumValueToLabelMap<T extends string | number = string | number> = Record<T, string | number>;
284
284
  /**
285
285
  * Type for a value-to-label mapping that can be either a function or an object map
286
286
  */
287
- type ValueToLabelMapping<T extends string = string> = ((value: string) => string) | EnumValueToLabelMap<T>;
287
+ type ValueToLabelMapping<T extends string | number = string | number> = ((value: T) => string | number) | EnumValueToLabelMap<T>;
288
288
  /**
289
289
  * Helper type to extract the type of a field at a given path
290
290
  */
@@ -671,7 +671,7 @@ type ArrayFieldComponent<T, P extends Path<T>> = vue.FunctionalComponent<Omit<Ar
671
671
  * Type for enum field components that require valueToLabel
672
672
  */
673
673
  type EnumFieldComponent<T, P extends Path<T>> = (props: Omit<SelectFieldProps<T>, 'name' | 'valueToLabel'> & {
674
- valueToLabel: Record<FieldPathToEnum<T, P>, string>;
674
+ valueToLabel: Record<FieldPathToEnum<T, P>, string | number>;
675
675
  }, context?: any) => any;
676
676
  /**
677
677
  * Type for combobox field components (searchable select with optional creation)
@@ -753,9 +753,9 @@ interface FieldMetadata$1 {
753
753
  max?: number;
754
754
  /** Regular expression pattern for validation */
755
755
  pattern?: RegExp;
756
- /** Options for enum fields */
756
+ /** Options for enum fields (value can be string or number when valueType is 'number') */
757
757
  options?: Array<{
758
- value: string;
758
+ value: string | number;
759
759
  label: string;
760
760
  }>;
761
761
  /** Default value for the field */
@@ -774,8 +774,13 @@ interface FieldMetadata$1 {
774
774
  rows?: number;
775
775
  /** For textarea fields, number of columns to display */
776
776
  cols?: number;
777
- /** For enum fields, map values to display labels */
778
- valueToLabel?: Record<string, string>;
777
+ /** For enum fields, map values to display labels (keys and values can be string or number) */
778
+ valueToLabel?: Record<string | number, string | number>;
779
+ /**
780
+ * Coerce select/combobox values to this type when setting form state.
781
+ * Use 'number' when valueToLabel has numeric keys - stores numbers instead of strings.
782
+ */
783
+ valueType?: 'number';
779
784
  /** Whether the field should be disabled */
780
785
  disabled?: boolean;
781
786
  /** Whether the field should be hidden */
@@ -854,7 +859,7 @@ declare function createTypedComboboxField<T, P extends Path<T>>(baseComboboxFiel
854
859
  * @returns A factory function that creates a type-safe select field
855
860
  */
856
861
  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>;
862
+ valueToLabel: Record<E, string | number>;
858
863
  }, context?: any) => any;
859
864
  /**
860
865
  * Type-safe select field component with valueToLabel based on field path
@@ -862,7 +867,7 @@ declare function createTypedSelectField<T, P extends Path<T>>(baseSelectField: F
862
867
  interface TypedSelectFieldComponent<T> {
863
868
  <P extends Path<T>>(props: Omit<SelectFieldProps<T>, 'valueToLabel'> & {
864
869
  name: P;
865
- valueToLabel?: Record<string, string>;
870
+ valueToLabel?: Record<string | number, string | number>;
866
871
  }): ReturnType<FunctionalComponent>;
867
872
  }
868
873
 
@@ -880,7 +885,7 @@ type DisplayFieldComponent<T, P extends Path<T>, _FieldType extends string = 'st
880
885
  size?: string;
881
886
  variant?: string;
882
887
  copyable?: boolean;
883
- valueToLabel?: Record<string, string>;
888
+ valueToLabel?: Record<string | number, string | number>;
884
889
  separator?: string;
885
890
  itemRenderer?: (item: any, index: number) => string;
886
891
  maxItems?: number;
@@ -996,10 +1001,10 @@ declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T,
996
1001
  default: () => any;
997
1002
  }, {}>;
998
1003
  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>;
1004
+ valueToLabel: Record<E, string | number>;
1000
1005
  }, context?: any) => any;
1001
1006
  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>;
1007
+ valueToLabel: Record<E, string | number>;
1003
1008
  }, context?: any) => any) | undefined; };
1004
1009
  fields: Record<Path<z.TypeOf<T>>, any>;
1005
1010
  field: <P extends Path<z.TypeOf<T>>>(path: P) => any;
@@ -1445,7 +1450,7 @@ interface DisplayFieldProps<FormType> {
1445
1450
  class: string;
1446
1451
  label?: string;
1447
1452
  }>;
1448
- valueToLabel?: Record<string, string>;
1453
+ valueToLabel?: Record<string | number, string | number>;
1449
1454
  separator?: string;
1450
1455
  itemRenderer?: (item: any, index: number) => string;
1451
1456
  maxItems?: number;
@@ -1688,8 +1693,14 @@ interface SchemaFieldMetadata {
1688
1693
  rows?: number;
1689
1694
  /** For textarea fields, number of columns to display */
1690
1695
  cols?: number;
1691
- /** For enum fields, map values to display labels */
1692
- valueToLabel?: Record<string, string>;
1696
+ /** For enum fields, map values to display labels (keys and values can be string or number) */
1697
+ valueToLabel?: Record<string | number, string | number>;
1698
+ /**
1699
+ * Coerce select/combobox values to this type when setting form state.
1700
+ * Use 'number' when valueToLabel has numeric keys - stores numbers instead of strings.
1701
+ * Keeps Zod strict (no transforms needed); the field handles coercion at input time.
1702
+ */
1703
+ valueType?: 'number';
1693
1704
  /** Whether to hide validation errors */
1694
1705
  hideError?: boolean;
1695
1706
  /** Step value for numeric fields */
@@ -2064,6 +2075,8 @@ interface ColumnDefinition<TData, TField extends keyof TData> {
2064
2075
  filterAllowCreate?: boolean;
2065
2076
  filterAllOptionText?: string;
2066
2077
  filterShowAllOption?: boolean;
2078
+ filterSearchable?: boolean;
2079
+ filterDefaultOperator?: 'eq' | 'ne' | 'in' | 'notIn';
2067
2080
  sortLabels?: {
2068
2081
  asc: string;
2069
2082
  desc: string;
@@ -2815,10 +2828,10 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
2815
2828
  default: () => any;
2816
2829
  }, {}>;
2817
2830
  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"> & {
2818
- valueToLabel: Record<E, string>;
2831
+ valueToLabel: Record<E, string | number>;
2819
2832
  }, context?: any) => any;
2820
2833
  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"> & {
2821
- valueToLabel: Record<E, string>;
2834
+ valueToLabel: Record<E, string | number>;
2822
2835
  }, context?: any) => any) | undefined; };
2823
2836
  fields: Record<Path<z.TypeOf<T>>, any>;
2824
2837
  field: <P extends Path<z.TypeOf<T>>>(path: P) => any;