@dragonmastery/zinia-forms-core 0.3.5 → 0.3.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
@@ -108,6 +108,10 @@ interface ArrayFieldProps<FormType, ItemType> {
108
108
  itemsSource?: () => ItemType[];
109
109
  itemRenderer?: (item: ItemType, index: number) => any;
110
110
  availableItemRenderer?: (item: ItemType, index: number) => any;
111
+ itemPreview?: (item: ItemType, index: number) => string;
112
+ showItemNumber?: boolean;
113
+ itemPreviewMaxLength?: number;
114
+ fieldSummary?: (items: ItemType[]) => string;
111
115
  createItem?: () => ItemType;
112
116
  onAddItem?: (item: ItemType) => void;
113
117
  onRemoveItem?: (index: number) => void;
@@ -116,7 +120,6 @@ interface ArrayFieldProps<FormType, ItemType> {
116
120
  minItems?: number;
117
121
  maxItems?: number;
118
122
  allowReordering?: boolean;
119
- autoPrefixFields?: boolean;
120
123
  ariaLabels?: {
121
124
  addButton?: string;
122
125
  removeButton?: string;
@@ -124,6 +127,8 @@ interface ArrayFieldProps<FormType, ItemType> {
124
127
  moveDownButton?: string;
125
128
  item?: string;
126
129
  };
130
+ collapseAllButton?: boolean;
131
+ defaultCollapsed?: boolean;
127
132
  }
128
133
 
129
134
  interface CheckboxFieldProps<FormType> {
@@ -382,6 +387,14 @@ type FieldPathToEnum<T, P extends Path<T>> = P extends keyof T ? T[P] extends st
382
387
  * ArrayItemType<{tasks: Task[]}, 'tasks'> = Task
383
388
  */
384
389
  type ArrayItemType<T, P extends Path<T>> = P extends keyof T ? T[P] extends ReadonlyArray<infer Item> ? Item : T[P] extends Array<infer Item> ? Item : never : never;
390
+ /**
391
+ * Type-safe fields object that provides autocomplete for field names
392
+ * Maps each key of T to a string (the prefixed field name)
393
+ * All fields return strings regardless of whether the actual field is optional
394
+ */
395
+ type FieldNames<T> = T extends Record<string, any> ? {
396
+ [K in keyof T]-?: string;
397
+ } : Record<string, string>;
385
398
  /**
386
399
  * Type for array field components with properly typed slots
387
400
  */
@@ -389,7 +402,7 @@ type ArrayFieldComponent<T, P extends Path<T>> = vue.FunctionalComponent<Omit<Ar
389
402
  itemRenderer: (props: {
390
403
  item: ArrayItemType<T, P>;
391
404
  index: number;
392
- getFieldName: (fieldPath: string) => string;
405
+ fields: FieldNames<ArrayItemType<T, P>>;
393
406
  }) => any;
394
407
  availableItemRenderer: (props: {
395
408
  item: ArrayItemType<T, P>;
@@ -526,7 +539,7 @@ interface FieldMetadata {
526
539
  */
527
540
  interface SchemaFieldMetadata {
528
541
  /** The input type for rendering the field */
529
- inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local' | 'combobox';
542
+ inputType?: 'text' | 'email' | 'tel' | 'number' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'password' | 'currency' | 'date' | 'time' | 'datetime-local' | 'combobox' | 'array';
530
543
  /** Placeholder text for the field */
531
544
  placeholder?: string;
532
545
  /** The display label for the field */
@@ -1117,7 +1130,7 @@ interface StyleCreators {
1117
1130
  itemRenderer: (props: {
1118
1131
  item: ItemType;
1119
1132
  index: number;
1120
- getFieldName: (fieldPath: string) => string;
1133
+ fields: FieldNames<ItemType>;
1121
1134
  }) => any;
1122
1135
  availableItemRenderer: (props: {
1123
1136
  item: ItemType;
@@ -1268,6 +1281,11 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
1268
1281
  readonly errors: Record<string, string>;
1269
1282
  readonly touched: Record<string, boolean>;
1270
1283
  readonly dirty: Record<string, boolean>;
1284
+ readonly collapsedFields: Record<string, {
1285
+ isFieldCollapsed: boolean;
1286
+ collapsedItems: number[];
1287
+ defaultCollapsedInitialized: boolean;
1288
+ }>;
1271
1289
  fieldsMetadata: Record<string, FieldMetadata>;
1272
1290
  validate: (options?: {
1273
1291
  markErrorsAsTouched: boolean;
@@ -1325,7 +1343,9 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
1325
1343
  itemRenderer: (props: {
1326
1344
  item: any;
1327
1345
  index: number;
1328
- getFieldName: (fieldPath: string) => string;
1346
+ fields: Record<string, string> | {
1347
+ [x: string]: string;
1348
+ };
1329
1349
  }) => any;
1330
1350
  availableItemRenderer: (props: {
1331
1351
  item: any;
@@ -1444,7 +1464,7 @@ declare function createTypedArrayField<T, P extends Path<T>>(baseArrayField: Fun
1444
1464
  itemRenderer: (props: {
1445
1465
  item: ArrayItemType<T, P>;
1446
1466
  index: number;
1447
- getFieldName: (fieldPath: string) => string;
1467
+ fields: FieldNames<ArrayItemType<T, P>>;
1448
1468
  }) => any;
1449
1469
  availableItemRenderer: (props: {
1450
1470
  item: ArrayItemType<T, P>;
@@ -1483,7 +1503,9 @@ declare function generateFieldComponents<T extends z.ZodObject<any>>(schema: T,
1483
1503
  itemRenderer: (props: {
1484
1504
  item: any;
1485
1505
  index: number;
1486
- getFieldName: (fieldPath: string) => string;
1506
+ fields: Record<string, string> | {
1507
+ [x: string]: string;
1508
+ };
1487
1509
  }) => any;
1488
1510
  availableItemRenderer: (props: {
1489
1511
  item: any;