@dragonmastery/zinia-forms-core 0.3.0 → 0.3.2

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
@@ -139,6 +139,87 @@ interface CheckboxFieldProps<FormType> {
139
139
  variant?: string;
140
140
  }
141
141
 
142
+ /**
143
+ * Option item for combobox fields - can be a string or label/value object
144
+ */
145
+ type ComboboxOption = string | {
146
+ label: string;
147
+ value: string;
148
+ };
149
+ /**
150
+ * Props for the ComboboxField component
151
+ */
152
+ interface ComboboxFieldProps<FormType, P extends Path<FormType> = Path<FormType>> {
153
+ /**
154
+ * Field name (path in the form state)
155
+ * Accepts both static paths and dynamic paths for use in array fields
156
+ */
157
+ name: FlexiblePath<FormType>;
158
+ /**
159
+ * Field label
160
+ */
161
+ label?: string;
162
+ /**
163
+ * Whether to hide the label
164
+ */
165
+ hideLabel?: boolean;
166
+ /**
167
+ * Field description
168
+ */
169
+ description?: string;
170
+ /**
171
+ * Whether the field is required
172
+ */
173
+ required?: boolean;
174
+ /**
175
+ * Placeholder text
176
+ */
177
+ placeholder?: string;
178
+ /**
179
+ * Whether the field is disabled
180
+ */
181
+ disabled?: boolean;
182
+ /**
183
+ * Whether the field is readonly
184
+ */
185
+ readonly?: boolean;
186
+ /**
187
+ * CSS classes to apply to the field
188
+ */
189
+ class?: string | string[];
190
+ /**
191
+ * Field size
192
+ */
193
+ size?: string;
194
+ /**
195
+ * Field variant
196
+ */
197
+ variant?: string;
198
+ /**
199
+ * Combobox options (array of strings or label/value objects)
200
+ * If not provided, will use options from schema metadata
201
+ *
202
+ * For async loading, use form-level dataLoaders and pass options via extraData:
203
+ * ```ts
204
+ * useForm(schema, {
205
+ * dataLoaders: { products: loadProducts },
206
+ * });
207
+ * // Then: :options="form.extraData.products || []"
208
+ * ```
209
+ */
210
+ options?: ComboboxOption[];
211
+ /**
212
+ * Whether to allow creating new values that don't exist in the options
213
+ * Default: true
214
+ */
215
+ allowCreate?: boolean;
216
+ /**
217
+ * Custom filter function for options
218
+ * Default: filters by case-insensitive substring match
219
+ */
220
+ filterFn?: (query: string, option: ComboboxOption) => boolean;
221
+ }
222
+
142
223
  interface CurrencyFieldProps<FormType> {
143
224
  name: FlexiblePath<FormType>;
144
225
  label?: string;
@@ -811,7 +892,7 @@ interface FieldMetadata {
811
892
  /** The data type of the field */
812
893
  type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'enum' | 'date' | 'union';
813
894
  /** The input type for rendering the field */
814
- inputType?: 'text' | 'email' | 'url' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'array' | 'currency' | 'date' | 'time' | 'datetime-local' | 'file' | 'range' | 'search';
895
+ inputType?: 'text' | 'email' | 'url' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'array' | 'currency' | 'date' | 'time' | 'datetime-local' | 'file' | 'range' | 'search' | 'combobox';
815
896
  /** The display label for the field */
816
897
  label?: string;
817
898
  /** Placeholder text for the field */
@@ -870,7 +951,7 @@ interface FieldMetadata {
870
951
  */
871
952
  interface SchemaFieldMetadata {
872
953
  /** The input type for rendering the field */
873
- inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local';
954
+ inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local' | 'combobox';
874
955
  /** Placeholder text for the field */
875
956
  placeholder?: string;
876
957
  /** The display label for the field */
@@ -928,6 +1009,7 @@ interface StyleCreators {
928
1009
  createSearchField: <FormType>() => FunctionalComponent<SearchFieldProps<FormType>, {}, any, {}>;
929
1010
  createTimeField: <FormType>() => FunctionalComponent<TimeFieldProps<FormType>, {}, any, {}>;
930
1011
  createDateTimeLocalField: <FormType>() => FunctionalComponent<DateTimeLocalFieldProps<FormType>, {}, any, {}>;
1012
+ createComboboxField: <FormType>() => FunctionalComponent<ComboboxFieldProps<FormType>, {}, any, {}>;
931
1013
  createArrayField: <FormType, ItemType = any>() => FunctionalComponent<ArrayFieldProps<FormType, ItemType>, {}, {
932
1014
  itemRenderer: (props: {
933
1015
  item: ItemType;
@@ -1107,6 +1189,12 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
1107
1189
  resetField: (path: string) => void;
1108
1190
  hasError: (path: string) => boolean;
1109
1191
  getError: (path: string) => string;
1192
+ setFocus: (path: string, value: boolean) => void;
1193
+ isFocused: (path: string) => boolean;
1194
+ setDisplayText: (path: string, text: string) => void;
1195
+ getDisplayText: (path: string) => string;
1196
+ setSelectedIndex: (path: string, index: number) => void;
1197
+ getSelectedIndex: (path: string) => number;
1110
1198
  };
1111
1199
  ZiniaForm: vue.FunctionalComponent<FormProps<z.TypeOf<T>>, {}, any, {}>;
1112
1200
  ZiniaSubmitButton: vue.FunctionalComponent<SubmitButtonProps<z.TypeOf<T>>, {}, any, {}>;
@@ -1506,6 +1594,10 @@ interface FilterValue {
1506
1594
  value: any;
1507
1595
  operator: 'eq' | 'contains' | 'gt' | 'lt' | 'in' | 'between';
1508
1596
  }
1597
+ type FilterOptionItem = {
1598
+ label: string;
1599
+ value: any;
1600
+ } | string | number;
1509
1601
  interface BaseActionItem<TData> {
1510
1602
  key: string;
1511
1603
  /**
@@ -1557,8 +1649,8 @@ interface ColumnDefinition<TData, TField extends keyof TData> {
1557
1649
  format?: (value: TData[TField], row: TData) => string;
1558
1650
  render?: (value: TData[TField], row: TData) => any;
1559
1651
  filterType?: 'text' | 'select' | 'number' | 'boolean';
1560
- filterOptions?: any[];
1561
- filterOptionsLoader?: () => Promise<any[]>;
1652
+ filterOptions?: FilterOptionItem[];
1653
+ filterOptionsLoader?: () => Promise<FilterOptionItem[]>;
1562
1654
  sortLabels?: {
1563
1655
  asc: string;
1564
1656
  desc: string;
@@ -2160,4 +2252,4 @@ declare const ActionIcons: {
2160
2252
  readonly dotsHorizontal: "<svg fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z\" /></svg>";
2161
2253
  };
2162
2254
 
2163
- export { ActionIcons, type ActionItem, type ActionsConfig, type ButtonActionItem, type ColumnDefinition, type CursorDataTableOptions, type CursorFetchParams, type CursorFetchResult, type DataTableColumns, type DataTableOptions, type DisplayComponentsType, type DisplayFieldComponent, ErrorDisplay, type FetchDataParams, type FetchDataResult, type FilterValue, type LinkActionItem, LoadingDisplay, NoDataDisplay, SCHEMA_ID_SYMBOL, type TypedSelectFieldComponent, type UseCursorDataTableType, type UseDataTableType, type UseDeleteModalType, type UseDisplayType, type UseFormType, type UseFormTyped, ZINIA_DATA_TABLE_ACTIONS_KEY, ZINIA_DATA_TABLE_COLUMNS_KEY, ZINIA_DATA_TABLE_FILTER_INPUTS_KEY, ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY, ZINIA_DATA_TABLE_KEY, ZINIA_DATA_TABLE_NAME_KEY, ZINIA_DATA_TABLE_OPTIONS_KEY, ZINIA_DATA_TABLE_SEARCH_INPUT_KEY, ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY, ZINIA_DELETE_MODAL_FIELDS_KEY, ZINIA_DELETE_MODAL_KEY, ZINIA_DELETE_MODAL_SCHEMA_KEY, ZINIA_DISPLAY_FIELDS_GENERIC_KEY, ZINIA_DISPLAY_FIELDS_KEY, ZINIA_DISPLAY_KEY, ZINIA_DISPLAY_SCHEMA_KEY, ZINIA_FIELDS_GENERIC_KEY, ZINIA_FIELDS_KEY, ZINIA_FORM_KEY, ZINIA_FORM_SCHEMA_KEY, type ZiniaDataTable, type ZiniaDeleteModal, type ZiniaDeleteModalFields, type ZiniaDeleteModalGenericFields, type ZiniaDisplay, type ZiniaDisplayFields, type ZiniaDisplayGenericFields, type ZiniaForm, type ZiniaFormFields, type ZiniaFormGenericFields, ZiniaPlugin, type ZiniaPluginOptions, clearAllMetadata, clearSchemaMetadata, createBaseComponents, createBaseDisplayComponents, createPartialStyle, createStyleTemplate, createTypedArrayField, createTypedSelectField, daisyUIStyle, extendStyle, generateDisplayComponents, generateFieldComponents, getAllSchemaMetadata, getDefaultStyle, getFieldMetadata, getRegisteredStyle, getRegisteredStyleNames, getSchemaId, hasRegisteredStyle, hasSchemaMetadata, mergeStyles, plainStyle, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };
2255
+ export { ActionIcons, type ActionItem, type ActionsConfig, type ButtonActionItem, type ColumnDefinition, type CursorDataTableOptions, type CursorFetchParams, type CursorFetchResult, type DataTableColumns, type DataTableOptions, type DisplayComponentsType, type DisplayFieldComponent, ErrorDisplay, type FetchDataParams, type FetchDataResult, type FilterOptionItem, type FilterValue, type LinkActionItem, LoadingDisplay, NoDataDisplay, SCHEMA_ID_SYMBOL, type TypedSelectFieldComponent, type UseCursorDataTableType, type UseDataTableType, type UseDeleteModalType, type UseDisplayType, type UseFormType, type UseFormTyped, ZINIA_DATA_TABLE_ACTIONS_KEY, ZINIA_DATA_TABLE_COLUMNS_KEY, ZINIA_DATA_TABLE_FILTER_INPUTS_KEY, ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY, ZINIA_DATA_TABLE_KEY, ZINIA_DATA_TABLE_NAME_KEY, ZINIA_DATA_TABLE_OPTIONS_KEY, ZINIA_DATA_TABLE_SEARCH_INPUT_KEY, ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY, ZINIA_DELETE_MODAL_FIELDS_KEY, ZINIA_DELETE_MODAL_KEY, ZINIA_DELETE_MODAL_SCHEMA_KEY, ZINIA_DISPLAY_FIELDS_GENERIC_KEY, ZINIA_DISPLAY_FIELDS_KEY, ZINIA_DISPLAY_KEY, ZINIA_DISPLAY_SCHEMA_KEY, ZINIA_FIELDS_GENERIC_KEY, ZINIA_FIELDS_KEY, ZINIA_FORM_KEY, ZINIA_FORM_SCHEMA_KEY, type ZiniaDataTable, type ZiniaDeleteModal, type ZiniaDeleteModalFields, type ZiniaDeleteModalGenericFields, type ZiniaDisplay, type ZiniaDisplayFields, type ZiniaDisplayGenericFields, type ZiniaForm, type ZiniaFormFields, type ZiniaFormGenericFields, ZiniaPlugin, type ZiniaPluginOptions, clearAllMetadata, clearSchemaMetadata, createBaseComponents, createBaseDisplayComponents, createPartialStyle, createStyleTemplate, createTypedArrayField, createTypedSelectField, daisyUIStyle, extendStyle, generateDisplayComponents, generateFieldComponents, getAllSchemaMetadata, getDefaultStyle, getFieldMetadata, getRegisteredStyle, getRegisteredStyleNames, getSchemaId, hasRegisteredStyle, hasSchemaMetadata, mergeStyles, plainStyle, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };