@dragonmastery/zinia-forms-core 0.3.13 → 0.3.16
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 +131 -1
- package/dist/index.js +1106 -277
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1170,6 +1170,14 @@ interface DeleteModalProps<FormType = any> {
|
|
|
1170
1170
|
interface DataTableProps<FormType> {
|
|
1171
1171
|
class?: string;
|
|
1172
1172
|
name?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* Height behavior for the table container
|
|
1175
|
+
* - 'auto' (default): Table expands to fill available space with a minimum height to prevent squishing
|
|
1176
|
+
* - 'fixed': Uses fixed height (850px, max 90vh) - original behavior
|
|
1177
|
+
* - number: Fixed pixel height (e.g., 600)
|
|
1178
|
+
* - string: Custom CSS height value (e.g., '50vh', '600px')
|
|
1179
|
+
*/
|
|
1180
|
+
height?: 'auto' | 'fixed' | number | string;
|
|
1173
1181
|
}
|
|
1174
1182
|
|
|
1175
1183
|
/**
|
|
@@ -1279,6 +1287,118 @@ interface StyleCreators {
|
|
|
1279
1287
|
}, {}>;
|
|
1280
1288
|
}
|
|
1281
1289
|
|
|
1290
|
+
/**
|
|
1291
|
+
* Form state management hook
|
|
1292
|
+
* Provides reactive form state with proper reactivity handling
|
|
1293
|
+
*/
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
* Form state interface
|
|
1297
|
+
*/
|
|
1298
|
+
interface FormState<T, CalcType = any, ExtraDataType = any> {
|
|
1299
|
+
data: T;
|
|
1300
|
+
calculatedValues: CalcType;
|
|
1301
|
+
touched: Record<string, boolean>;
|
|
1302
|
+
dirty: Record<string, boolean>;
|
|
1303
|
+
errors: Record<string, string>;
|
|
1304
|
+
focused: Record<string, boolean>;
|
|
1305
|
+
displayText: Record<string, string>;
|
|
1306
|
+
selectedIndex: Record<string, number>;
|
|
1307
|
+
collapsedFields: Record<string, {
|
|
1308
|
+
isFieldCollapsed: boolean;
|
|
1309
|
+
collapsedItems: number[];
|
|
1310
|
+
defaultCollapsedInitialized: boolean;
|
|
1311
|
+
}>;
|
|
1312
|
+
undoHistory: Record<string, {
|
|
1313
|
+
type: 'add' | 'remove' | 'swap';
|
|
1314
|
+
previousState: any;
|
|
1315
|
+
currentState: any;
|
|
1316
|
+
timestamp: number;
|
|
1317
|
+
}[]>;
|
|
1318
|
+
redoHistory: Record<string, {
|
|
1319
|
+
type: 'add' | 'remove' | 'swap';
|
|
1320
|
+
previousState: any;
|
|
1321
|
+
currentState: any;
|
|
1322
|
+
timestamp: number;
|
|
1323
|
+
}[]>;
|
|
1324
|
+
pendingOperations: Record<string, {
|
|
1325
|
+
type: 'add' | 'remove' | 'swap';
|
|
1326
|
+
index?: number;
|
|
1327
|
+
indexA?: number;
|
|
1328
|
+
indexB?: number;
|
|
1329
|
+
item?: any;
|
|
1330
|
+
previousState: any;
|
|
1331
|
+
currentState: any;
|
|
1332
|
+
timestamp: number;
|
|
1333
|
+
timeoutId?: number;
|
|
1334
|
+
}[]>;
|
|
1335
|
+
arrayItemIds: Record<string, string[]>;
|
|
1336
|
+
isSubmitting: boolean;
|
|
1337
|
+
hasAttemptedSubmit: boolean;
|
|
1338
|
+
submitAttemptsCount: number;
|
|
1339
|
+
submitError: string | null;
|
|
1340
|
+
isReady: boolean;
|
|
1341
|
+
isLoading: boolean;
|
|
1342
|
+
loadError: string | null;
|
|
1343
|
+
extraData: ExtraDataType;
|
|
1344
|
+
fetchedOptions: Record<string, any[]>;
|
|
1345
|
+
loadingOptions: Record<string, boolean>;
|
|
1346
|
+
asyncCascadingParents: Record<string, string>;
|
|
1347
|
+
loadingAutoPopulate: Record<string, boolean>;
|
|
1348
|
+
populatingFields: Record<string, boolean>;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* Type definitions for async cascading selection and auto-population
|
|
1353
|
+
*/
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Helper type to get the value type of a field path
|
|
1357
|
+
*/
|
|
1358
|
+
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;
|
|
1359
|
+
/**
|
|
1360
|
+
* Configuration for async cascading selection (parent → child options fetching via API)
|
|
1361
|
+
*/
|
|
1362
|
+
interface AsyncCascadingSelectConfig<FormType, ParentField extends Path<FormType> = Path<FormType>, ChildField extends Path<FormType> = Path<FormType>> {
|
|
1363
|
+
/** Parent field that triggers child options fetch */
|
|
1364
|
+
parentField: ParentField;
|
|
1365
|
+
/** Child field that will be populated with fetched options */
|
|
1366
|
+
childField: ChildField;
|
|
1367
|
+
/** Async function to fetch child options based on parent value */
|
|
1368
|
+
fetchOptionsFn: (parentValue: FieldValue<FormType, ParentField>) => Promise<Array<SelectOption>>;
|
|
1369
|
+
/** Whether to clear child field when parent changes (default: true) */
|
|
1370
|
+
clearOnParentChange?: boolean;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Type for the async cascading selects configuration object
|
|
1374
|
+
* Uses a mapped type to preserve field path type safety
|
|
1375
|
+
*/
|
|
1376
|
+
type AsyncCascadingSelectsConfig<FormType> = {
|
|
1377
|
+
[K in string]: AsyncCascadingSelectConfig<FormType, Path<FormType>, Path<FormType>>;
|
|
1378
|
+
};
|
|
1379
|
+
/**
|
|
1380
|
+
* Configuration for auto-population (select/combobox → other fields)
|
|
1381
|
+
*/
|
|
1382
|
+
interface AutoPopulateConfig<FormType, TData = any, SourceField extends Path<FormType> = Path<FormType>> {
|
|
1383
|
+
/**
|
|
1384
|
+
* Optional async function to fetch data when option is selected.
|
|
1385
|
+
* If provided, this will be called instead of using option.data.
|
|
1386
|
+
* Receives the selected option value and returns the data object.
|
|
1387
|
+
*/
|
|
1388
|
+
fetchDataFn?: (selectedValue: FieldValue<FormType, SourceField>) => Promise<TData>;
|
|
1389
|
+
/** Mapping of form fields to data properties for auto-population */
|
|
1390
|
+
fields: {
|
|
1391
|
+
[TargetField in Path<FormType>]?: string | ((data: TData) => FieldValue<FormType, TargetField>);
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Type for the auto-populate configuration object
|
|
1396
|
+
* Key is the select/combobox field name, value is the auto-populate config
|
|
1397
|
+
*/
|
|
1398
|
+
type AutoPopulateConfigs<FormType> = Partial<{
|
|
1399
|
+
[SourceField in Path<FormType>]: AutoPopulateConfig<FormType, any>;
|
|
1400
|
+
}>;
|
|
1401
|
+
|
|
1282
1402
|
/**
|
|
1283
1403
|
* Options for merging server data with local changes
|
|
1284
1404
|
*/
|
|
@@ -1342,6 +1462,8 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
|
|
|
1342
1462
|
[K in keyof ExtraDataType]?: () => Promise<ExtraDataType[K]>;
|
|
1343
1463
|
};
|
|
1344
1464
|
fetchData?: () => Promise<z.infer<typeof schema>>;
|
|
1465
|
+
asyncCascadingSelects?: AsyncCascadingSelectsConfig<z.infer<T>>;
|
|
1466
|
+
autoPopulate?: AutoPopulateConfigs<z.infer<T>>;
|
|
1345
1467
|
calculationFn?: (values: z.infer<T>, extraData?: ExtraDataType) => CalcType;
|
|
1346
1468
|
debug?: {
|
|
1347
1469
|
all?: boolean;
|
|
@@ -1355,6 +1477,7 @@ declare function useForm<T extends z.ZodObject<any>, CalcType = (values: z.infer
|
|
|
1355
1477
|
form: {
|
|
1356
1478
|
storeName: string;
|
|
1357
1479
|
values: z.TypeOf<T>;
|
|
1480
|
+
state: FormState<z.TypeOf<T>, CalcType, ExtraDataType>;
|
|
1358
1481
|
readonly calculatedValues: CalcType;
|
|
1359
1482
|
readonly extraData: ExtraDataType;
|
|
1360
1483
|
readonly isValid: boolean;
|
|
@@ -1933,9 +2056,10 @@ interface ColumnDefinition<TData, TField extends keyof TData> {
|
|
|
1933
2056
|
textWrap?: 'truncate' | 'wrap';
|
|
1934
2057
|
format?: (value: TData[TField], row: TData) => string;
|
|
1935
2058
|
render?: (value: TData[TField], row: TData) => any;
|
|
1936
|
-
filterType?: 'text' | 'select' | 'number' | 'boolean';
|
|
2059
|
+
filterType?: 'text' | 'select' | 'number' | 'boolean' | 'combobox';
|
|
1937
2060
|
filterOptions?: FilterOptionItem[];
|
|
1938
2061
|
filterOptionsLoader?: () => Promise<FilterOptionItem[]>;
|
|
2062
|
+
filterAllowCreate?: boolean;
|
|
1939
2063
|
sortLabels?: {
|
|
1940
2064
|
asc: string;
|
|
1941
2065
|
desc: string;
|
|
@@ -2056,6 +2180,9 @@ declare function useDataTable<TSchema extends z.ZodObject<any>>(schema: TSchema,
|
|
|
2056
2180
|
sortDrawerOpen: vue.Ref<boolean, boolean>;
|
|
2057
2181
|
openSortDrawer: () => boolean;
|
|
2058
2182
|
closeSortDrawer: () => boolean;
|
|
2183
|
+
filterDrawerOpen: vue.Ref<boolean, boolean>;
|
|
2184
|
+
openFilterDrawer: () => boolean;
|
|
2185
|
+
closeFilterDrawer: () => boolean;
|
|
2059
2186
|
};
|
|
2060
2187
|
fieldsMetadata: Record<string, FieldMetadata>;
|
|
2061
2188
|
columns: (z.TypeOf<TSchema> extends infer T ? { [K in keyof T]?: ColumnDefinition<z.TypeOf<TSchema>, K> | undefined; } : never) & {
|
|
@@ -2221,6 +2348,9 @@ declare function useCursorDataTable<TSchema extends z.ZodObject<any>>(schema: TS
|
|
|
2221
2348
|
sortDrawerOpen: vue.Ref<boolean, boolean>;
|
|
2222
2349
|
openSortDrawer: () => boolean;
|
|
2223
2350
|
closeSortDrawer: () => boolean;
|
|
2351
|
+
filterDrawerOpen: vue.Ref<boolean, boolean>;
|
|
2352
|
+
openFilterDrawer: () => boolean;
|
|
2353
|
+
closeFilterDrawer: () => boolean;
|
|
2224
2354
|
};
|
|
2225
2355
|
fieldsMetadata: Record<string, FieldMetadata>;
|
|
2226
2356
|
columns: (z.TypeOf<TSchema> extends infer T ? { [K in keyof T]?: ColumnDefinition<z.TypeOf<TSchema>, K> | undefined; } : never) & {
|