@dazhicheng/ui 1.5.6 → 1.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/components/tt-area/TtArea.vue.d.ts +2 -0
- package/dist/components/tt-area/index.d.ts +1 -0
- package/dist/components/tt-button/index.d.ts +1739 -0
- package/dist/components/tt-button/index.vue.d.ts +1004 -0
- package/dist/components/tt-checkbox/index.d.ts +36 -0
- package/dist/components/tt-checkbox/index.vue.d.ts +28 -0
- package/dist/components/tt-checkbox/type.d.ts +9 -0
- package/dist/components/tt-drawer/index.d.ts +3703 -0
- package/dist/components/tt-drawer/src/RenderDrawer.vue.d.ts +2121 -0
- package/dist/components/tt-drawer/src/components/DrawerFooter.vue.d.ts +94 -0
- package/dist/components/tt-drawer/src/components/DrawerHeader.vue.d.ts +27 -0
- package/dist/components/tt-drawer/src/hooks/useDrawerRender.d.ts +10 -0
- package/dist/components/tt-drawer/src/hooks/useResizable.d.ts +9 -0
- package/dist/components/tt-drawer/src/index.d.ts +10 -0
- package/dist/components/tt-drawer/src/props.d.ts +99 -0
- package/dist/components/tt-drawer/src/typing.d.ts +154 -0
- package/dist/components/tt-drawer/src/utils/drawer-api.d.ts +87 -0
- package/dist/components/tt-empty/index.d.ts +18 -0
- package/dist/components/tt-form/index.d.ts +13 -0
- package/dist/components/tt-form/src/components/ExpandableArrow.vue.d.ts +33 -0
- package/dist/components/tt-form/src/components/FormActions.vue.d.ts +34 -0
- package/dist/components/tt-form/src/components/Slot.d.ts +7 -0
- package/dist/components/tt-form/src/config.d.ts +6 -0
- package/dist/components/tt-form/src/form/FormControl.vue.d.ts +19 -0
- package/dist/components/tt-form/src/form/FormDescription.vue.d.ts +23 -0
- package/dist/components/tt-form/src/form/FormItem.vue.d.ts +23 -0
- package/dist/components/tt-form/src/form/FormLabel.vue.d.ts +23 -0
- package/dist/components/tt-form/src/form/FormMessage.vue.d.ts +2 -0
- package/dist/components/tt-form/src/form/FormMessageToolTip.vue.d.ts +8 -0
- package/dist/components/tt-form/src/form/FormWarnMessage.vue.d.ts +25 -0
- package/dist/components/tt-form/src/form/RenderContent.vue.d.ts +23 -0
- package/dist/components/tt-form/src/form/index.d.ts +10 -0
- package/dist/components/tt-form/src/form/injectionKeys.d.ts +2 -0
- package/dist/components/tt-form/src/form/useFormField.d.ts +11 -0
- package/dist/components/tt-form/src/form-render/FormField.vue.d.ts +28 -0
- package/dist/components/tt-form/src/form-render/FormLabel.vue.d.ts +27 -0
- package/dist/components/tt-form/src/form-render/context.d.ts +7 -0
- package/dist/components/tt-form/src/form-render/dependencies.d.ts +361 -0
- package/dist/components/tt-form/src/form-render/expandable.d.ts +9 -0
- package/dist/components/tt-form/src/form-render/form.vue.d.ts +38 -0
- package/dist/components/tt-form/src/form-render/helper.d.ts +11 -0
- package/dist/components/tt-form/src/form-render/index.d.ts +3 -0
- package/dist/components/tt-form/src/formApi.d.ts +71 -0
- package/dist/components/tt-form/src/hooks/useEmitAsProps.d.ts +7 -0
- package/dist/components/tt-form/src/hooks/useFormFieldBus.d.ts +14 -0
- package/dist/components/tt-form/src/hooks/useForwardPriorityValues.d.ts +14 -0
- package/dist/components/tt-form/src/hooks/useForwardProps.d.ts +7 -0
- package/dist/components/tt-form/src/hooks/useForwardPropsEmits.d.ts +8 -0
- package/dist/components/tt-form/src/index.vue.d.ts +27 -0
- package/dist/components/tt-form/src/shared/createContext.d.ts +8 -0
- package/dist/components/tt-form/src/shared/global-state.d.ts +17 -0
- package/dist/components/tt-form/src/shared/store.d.ts +1 -0
- package/dist/components/tt-form/src/shared/zod-defaults.d.ts +54 -0
- package/dist/components/tt-form/src/types/common.d.ts +11 -0
- package/dist/components/tt-form/src/types/forms.d.ts +280 -0
- package/dist/components/tt-form/src/types/index.d.ts +3 -0
- package/dist/components/tt-form/src/types/paths.d.ts +142 -0
- package/dist/components/tt-form/src/types/shared.d.ts +19 -0
- package/dist/components/tt-form/src/types.d.ts +383 -0
- package/dist/components/tt-form/src/useForm.d.ts +2 -0
- package/dist/components/tt-form/src/useFormContext.d.ts +12 -0
- package/dist/components/tt-form-item-error-tooltip/index.d.ts +1549 -0
- package/dist/components/tt-form-item-error-tooltip/index.vue.d.ts +784 -0
- package/dist/components/tt-icon/index.d.ts +76 -0
- package/dist/components/tt-icon/index.vue.d.ts +32 -0
- package/dist/components/tt-image/index.d.ts +127 -0
- package/dist/components/tt-image/src/components/ImageViewer.d.ts +89 -0
- package/dist/components/tt-image/tt-image.d.ts +126 -0
- package/dist/components/tt-loading/index.d.ts +16 -0
- package/dist/components/tt-loading/src/directive.d.ts +9 -0
- package/dist/components/tt-loading/src/loading.vue.d.ts +12 -0
- package/dist/components/tt-loading/src/service.d.ts +25 -0
- package/dist/components/tt-loading/src/type.d.ts +20 -0
- package/dist/components/tt-modal/index.d.ts +1809 -0
- package/dist/components/tt-modal/src/RenderModal.vue.d.ts +1008 -0
- package/dist/components/tt-modal/src/components/ModalFooter.vue.d.ts +210 -0
- package/dist/components/tt-modal/src/components/ModalHeader.vue.d.ts +31 -0
- package/dist/components/tt-modal/src/components/ModalWrapper.vue.d.ts +224 -0
- package/dist/components/tt-modal/src/hooks/useModalRender.d.ts +110 -0
- package/dist/components/tt-modal/src/index.d.ts +5 -0
- package/dist/components/tt-modal/src/props.d.ts +161 -0
- package/dist/components/tt-modal/src/typing.d.ts +188 -0
- package/dist/components/tt-modal/src/utils/modal-api.d.ts +97 -0
- package/dist/components/tt-part/index.d.ts +398 -0
- package/dist/components/tt-part/index.vue.d.ts +253 -0
- package/dist/components/tt-part/type.d.ts +100 -0
- package/dist/components/tt-part-item/index.d.ts +105 -0
- package/dist/components/tt-part-item/index.vue.d.ts +71 -0
- package/dist/components/tt-part-item/type.d.ts +81 -0
- package/dist/components/tt-select/index.d.ts +7 -0
- package/dist/components/tt-select/src/Select.vue.d.ts +861 -0
- package/dist/components/tt-select/src/components/SelectTable.vue.d.ts +111 -0
- package/dist/components/tt-select/src/components/Table.vue.d.ts +250 -0
- package/dist/components/tt-select/src/const.d.ts +16 -0
- package/dist/components/tt-select/src/hooks/useDataSource.d.ts +115 -0
- package/dist/components/tt-select/src/hooks/useGrid.d.ts +32 -0
- package/dist/components/tt-select/src/hooks/useKeyboard.d.ts +59 -0
- package/dist/components/tt-select/src/hooks/usePagination.d.ts +16 -0
- package/dist/components/tt-select/src/hooks/useSelect.d.ts +87 -0
- package/dist/components/tt-select/src/hooks/useSelectTableEvent.d.ts +178 -0
- package/dist/components/tt-select/src/props.d.ts +190 -0
- package/dist/components/tt-select/src/types/index.d.ts +142 -0
- package/dist/components/tt-select/src/utils/index.d.ts +9 -0
- package/dist/components/tt-table/index.d.ts +127 -0
- package/dist/components/tt-table/src/Table.vue.d.ts +1691 -0
- package/dist/components/tt-table/src/componentMap.d.ts +8 -0
- package/dist/components/tt-table/src/components/RowContext.d.ts +24 -0
- package/dist/components/tt-table/src/components/TableAction.vue.d.ts +79 -0
- package/dist/components/tt-table/src/components/TableButtons.d.ts +30 -0
- package/dist/components/tt-table/src/components/TableColumnModal.vue.d.ts +26 -0
- package/dist/components/tt-table/src/components/TableToobalTools.vue.d.ts +1537 -0
- package/dist/components/tt-table/src/emits.d.ts +1 -0
- package/dist/components/tt-table/src/enum.d.ts +2 -0
- package/dist/components/tt-table/src/hooks/useCellArea.d.ts +15 -0
- package/dist/components/tt-table/src/hooks/useColumns.d.ts +27 -0
- package/dist/components/tt-table/src/hooks/useCustomColumns.d.ts +20 -0
- package/dist/components/tt-table/src/hooks/useDataSource.d.ts +29 -0
- package/dist/components/tt-table/src/hooks/useLeftRightSlot.d.ts +1082 -0
- package/dist/components/tt-table/src/hooks/usePagination.d.ts +102 -0
- package/dist/components/tt-table/src/hooks/useRowSelection.d.ts +30 -0
- package/dist/components/tt-table/src/hooks/useTable.d.ts +7 -0
- package/dist/components/tt-table/src/hooks/useTableContext.d.ts +43 -0
- package/dist/components/tt-table/src/hooks/useTableEvent.d.ts +101 -0
- package/dist/components/tt-table/src/hooks/useTableForm.d.ts +15 -0
- package/dist/components/tt-table/src/hooks/useTableFormEvent.d.ts +10 -0
- package/dist/components/tt-table/src/hooks/useTableHeight.d.ts +15 -0
- package/dist/components/tt-table/src/hooks/useTableRender.d.ts +93 -0
- package/dist/components/tt-table/src/hooks/useTableSlot.d.ts +11 -0
- package/dist/components/tt-table/src/props.d.ts +436 -0
- package/dist/components/tt-table/src/toolProps.d.ts +23 -0
- package/dist/components/tt-table/src/types/table.d.ts +489 -0
- package/dist/components/tt-table/src/types/tableAction.d.ts +26 -0
- package/dist/components/tt-table/src/types/tableForm.d.ts +64 -0
- package/dist/components/tt-table/src/types/tableTools.d.ts +10 -0
- package/dist/components/tt-table/src/utils/context.d.ts +18 -0
- package/dist/components/tt-table/src/utils/filters.d.ts +109 -0
- package/dist/components/tt-table/src/utils/table-api.d.ts +250 -0
- package/dist/components/tt-table/src/utils/table-form-api.d.ts +88 -0
- package/dist/components/tt-table/src/utils/vxeTable.d.ts +28 -0
- package/dist/components/tt-text/index.d.ts +76 -0
- package/dist/components/tt-text/index.vue.d.ts +50 -0
- package/dist/components/tt-tree-select/index.d.ts +5 -0
- package/dist/components/tt-tree-select/src/TtTreeSelect.vue.d.ts +6 -0
- package/dist/components/tt-tree-select/src/cache-options.d.ts +35 -0
- package/dist/components/tt-tree-select/src/select.d.ts +10 -0
- package/dist/components/tt-tree-select/src/tree.d.ts +23 -0
- package/dist/components/tt-tree-select/src/utils.d.ts +10 -0
- package/dist/components/tt-validate/index.d.ts +1 -0
- package/dist/components/tt-validate/src/ErrorMessage.d.ts +61 -0
- package/dist/components/tt-validate/src/Field.d.ts +430 -0
- package/dist/components/tt-validate/src/FieldArray.d.ts +47 -0
- package/dist/components/tt-validate/src/Form.d.ts +271 -0
- package/dist/components/tt-validate/src/config.d.ts +14 -0
- package/dist/components/tt-validate/src/defineRule.d.ts +9 -0
- package/dist/components/tt-validate/src/index.d.ts +36 -0
- package/dist/components/tt-validate/src/symbols.d.ts +6 -0
- package/dist/components/tt-validate/src/types/common.d.ts +11 -0
- package/dist/components/tt-validate/src/types/forms.d.ts +280 -0
- package/dist/components/tt-validate/src/types/index.d.ts +3 -0
- package/dist/components/tt-validate/src/types/paths.d.ts +142 -0
- package/dist/components/tt-validate/src/types/shared.d.ts +19 -0
- package/dist/components/tt-validate/src/useField.d.ts +30 -0
- package/dist/components/tt-validate/src/useFieldArray.d.ts +3 -0
- package/dist/components/tt-validate/src/useFieldError.d.ts +5 -0
- package/dist/components/tt-validate/src/useFieldState.d.ts +47 -0
- package/dist/components/tt-validate/src/useFieldValue.d.ts +5 -0
- package/dist/components/tt-validate/src/useForm.d.ts +23 -0
- package/dist/components/tt-validate/src/useFormErrors.d.ts +4 -0
- package/dist/components/tt-validate/src/useFormValues.d.ts +4 -0
- package/dist/components/tt-validate/src/useIsFieldDirty.d.ts +5 -0
- package/dist/components/tt-validate/src/useIsFieldTouched.d.ts +5 -0
- package/dist/components/tt-validate/src/useIsFieldValid.d.ts +5 -0
- package/dist/components/tt-validate/src/useIsFormDirty.d.ts +4 -0
- package/dist/components/tt-validate/src/useIsFormTouched.d.ts +4 -0
- package/dist/components/tt-validate/src/useIsFormValid.d.ts +4 -0
- package/dist/components/tt-validate/src/useIsSubmitting.d.ts +4 -0
- package/dist/components/tt-validate/src/useIsValidating.d.ts +4 -0
- package/dist/components/tt-validate/src/useResetForm.d.ts +2 -0
- package/dist/components/tt-validate/src/useSetFieldError.d.ts +5 -0
- package/dist/components/tt-validate/src/useSetFieldTouched.d.ts +5 -0
- package/dist/components/tt-validate/src/useSetFieldValue.d.ts +5 -0
- package/dist/components/tt-validate/src/useSetFormErrors.d.ts +4 -0
- package/dist/components/tt-validate/src/useSetFormTouched.d.ts +4 -0
- package/dist/components/tt-validate/src/useSetFormValues.d.ts +4 -0
- package/dist/components/tt-validate/src/useSubmitCount.d.ts +4 -0
- package/dist/components/tt-validate/src/useSubmitForm.d.ts +2 -0
- package/dist/components/tt-validate/src/useValidateField.d.ts +6 -0
- package/dist/components/tt-validate/src/useValidateForm.d.ts +5 -0
- package/dist/components/tt-validate/src/utils/assertions.d.ts +54 -0
- package/dist/components/tt-validate/src/utils/common.d.ts +48 -0
- package/dist/components/tt-validate/src/utils/events.d.ts +1 -0
- package/dist/components/tt-validate/src/utils/index.d.ts +5 -0
- package/dist/components/tt-validate/src/utils/rules.d.ts +13 -0
- package/dist/components/tt-validate/src/utils/shared.d.ts +19 -0
- package/dist/components/tt-validate/src/utils/vnode.d.ts +22 -0
- package/dist/components/tt-validate/src/validate.d.ts +21 -0
- package/dist/components/tt-validate/zod/index.d.ts +1 -0
- package/dist/components/types.d.ts +227 -0
- package/dist/directives/auto-tip/index.d.ts +3 -0
- package/dist/directives/dialog-resize/index.d.ts +25 -0
- package/dist/directives/dialog-resize/use-css-variable.d.ts +1 -0
- package/dist/directives/dialog-resize/use-draggable.d.ts +4 -0
- package/dist/directives/dialog-resize/use-fullscreen.d.ts +1 -0
- package/dist/directives/dialog-resize/use-parse-translate.d.ts +4 -0
- package/dist/directives/dialog-resize/use-resizer.d.ts +2 -0
- package/dist/directives/disabled-tip/index.d.ts +17 -0
- package/dist/directives/index.d.ts +3 -0
- package/dist/hooks/useFormat.d.ts +73 -0
- package/dist/hooks/useLoading.d.ts +9 -0
- package/dist/hooks/useSetup.d.ts +8 -0
- package/dist/hooks/useTable.d.ts +5 -0
- package/dist/hooks/useTemplateSlot.d.ts +9 -0
- package/dist/index.d.ts +46 -0
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
type BrowserNativeObject = Date | FileList | File;
|
|
2
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether the type is any
|
|
5
|
+
* See {@link https://stackoverflow.com/a/49928360/3406963}
|
|
6
|
+
* @typeParam T - type which may be any
|
|
7
|
+
* ```
|
|
8
|
+
* IsAny<any> = true
|
|
9
|
+
* IsAny<string> = false
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether T1 can be exactly (mutually) assigned to T2
|
|
15
|
+
* @typeParam T1 - type to check
|
|
16
|
+
* @typeParam T2 - type to check against
|
|
17
|
+
* ```
|
|
18
|
+
* IsEqual<string, string> = true
|
|
19
|
+
* IsEqual<'foo', 'foo'> = true
|
|
20
|
+
* IsEqual<string, number> = false
|
|
21
|
+
* IsEqual<string, number> = false
|
|
22
|
+
* IsEqual<string, 'foo'> = false
|
|
23
|
+
* IsEqual<'foo', string> = false
|
|
24
|
+
* IsEqual<'foo' | 'bar', 'foo'> = boolean // 'foo' is assignable, but 'bar' is not (true | false) -> boolean
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export type IsEqual<T1, T2> = T1 extends T2 ? (<G>() => G extends T1 ? 1 : 2) extends <G>() => G extends T2 ? 1 : 2 ? true : false : false;
|
|
28
|
+
/**
|
|
29
|
+
* Type to query whether an array type T is a tuple type.
|
|
30
|
+
* @typeParam T - type which may be an array or tuple
|
|
31
|
+
* @example
|
|
32
|
+
* ```
|
|
33
|
+
* IsTuple<[number]> = true
|
|
34
|
+
* IsTuple<number[]> = false
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"] ? false : true;
|
|
38
|
+
/**
|
|
39
|
+
* Type which can be used to index an array or tuple type.
|
|
40
|
+
*/
|
|
41
|
+
type ArrayKey = number;
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to break apart T1 and check if any are equal to T2
|
|
44
|
+
*
|
|
45
|
+
* See {@link IsEqual}
|
|
46
|
+
*/
|
|
47
|
+
type AnyIsEqual<T1, T2> = T1 extends T2 ? (IsEqual<T1, T2> extends true ? true : never) : never;
|
|
48
|
+
/**
|
|
49
|
+
* Type which given a tuple type returns its own keys, i.e. only its indices.
|
|
50
|
+
* @typeParam T - tuple type
|
|
51
|
+
* @example
|
|
52
|
+
* ```
|
|
53
|
+
* TupleKeys<[number, string]> = '0' | '1'
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
type TupleKeys<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Helper type to construct tuple key paths and recurse into its elements.
|
|
59
|
+
*
|
|
60
|
+
* See {@link Path}
|
|
61
|
+
*/
|
|
62
|
+
type PathInternalTuple<TValue extends ReadonlyArray<any>, TraversedTypes> = {
|
|
63
|
+
[Key in TupleKeys<TValue> & string]: `[${Key}]` | `[${Key}]${PathInternal<TValue[Key], TraversedTypes, false>}`;
|
|
64
|
+
}[TupleKeys<TValue> & string];
|
|
65
|
+
/**
|
|
66
|
+
* Helper type to construct array key paths and recurse into its elements.
|
|
67
|
+
*
|
|
68
|
+
* See {@link Path}
|
|
69
|
+
*/
|
|
70
|
+
type PathInternalArray<TValue extends ReadonlyArray<any>, TraversedTypes> = `[${ArrayKey}]` | `[${ArrayKey}]${PathInternal<TValue[ArrayKey], TraversedTypes, false>}`;
|
|
71
|
+
/**
|
|
72
|
+
* Helper type to construct object key paths and recurse into its nested values.
|
|
73
|
+
*
|
|
74
|
+
* See {@link Path}
|
|
75
|
+
*/
|
|
76
|
+
type PathInternalObject<TValue, TraversedTypes, First extends boolean> = {
|
|
77
|
+
[Key in keyof TValue & string]: First extends true ? `${Key}` | `${Key}${PathInternal<TValue[Key], TraversedTypes, false>}` : `.${Key}` | `.${Key}${PathInternal<TValue[Key], TraversedTypes, false>}`;
|
|
78
|
+
}[keyof TValue & string];
|
|
79
|
+
/**
|
|
80
|
+
* Helper type to construct nested any object key paths.
|
|
81
|
+
*
|
|
82
|
+
* See {@link Path}
|
|
83
|
+
*/
|
|
84
|
+
type PathInternalAny = `.${string}` | `[${string}]` | `[${string}].${string}`;
|
|
85
|
+
/**
|
|
86
|
+
* Helper type for recursively constructing paths through a type.
|
|
87
|
+
*
|
|
88
|
+
* This obscures internal type params TraversedTypes and First from ed contract.
|
|
89
|
+
*
|
|
90
|
+
* See {@link Path}
|
|
91
|
+
*/
|
|
92
|
+
type PathInternal<TValue, TraversedTypes, First extends boolean> = TValue extends Primitive | BrowserNativeObject ? IsAny<TValue> extends true ? PathInternalAny : never : TValue extends ReadonlyArray<any> ? true extends AnyIsEqual<TraversedTypes, TValue> ? never : IsTuple<TValue> extends true ? PathInternalTuple<TValue, TraversedTypes | TValue> : PathInternalArray<TValue, TraversedTypes | TValue> : TValue extends Record<string, any> ? PathInternalObject<TValue, TraversedTypes | TValue, First> : "";
|
|
93
|
+
/**
|
|
94
|
+
* Helper type for recursively constructing paths through a type.
|
|
95
|
+
* This actually constructs the strings and recurses into nested
|
|
96
|
+
* object types.
|
|
97
|
+
*
|
|
98
|
+
* See {@link ArrayPath}
|
|
99
|
+
*/
|
|
100
|
+
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>}`;
|
|
101
|
+
/**
|
|
102
|
+
* Helper type for recursively constructing paths through a type.
|
|
103
|
+
* This obscures the internal type param TraversedTypes from ed contract.
|
|
104
|
+
*
|
|
105
|
+
* See {@link ArrayPath}
|
|
106
|
+
*/
|
|
107
|
+
type ArrayPathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
|
|
108
|
+
[K in TupleKeys<T>]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
|
|
109
|
+
}[TupleKeys<T>] : ArrayPathImpl<ArrayKey, V, TraversedTypes> : {
|
|
110
|
+
[K in keyof T]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
|
|
111
|
+
}[keyof T];
|
|
112
|
+
/**
|
|
113
|
+
* Type which eagerly collects all paths through a type which point to an array
|
|
114
|
+
* type.
|
|
115
|
+
* @typeParam T - type which should be introspected.
|
|
116
|
+
* @example
|
|
117
|
+
* ```
|
|
118
|
+
* Path<{foo: {bar: string[], baz: number[]}}> = 'foo.bar' | 'foo.baz'
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type ArrayPath<T> = T extends any ? ArrayPathInternal<T> : never;
|
|
122
|
+
/**
|
|
123
|
+
* Type to evaluate the type which the given path points to.
|
|
124
|
+
* @typeParam T - deeply nested type which is indexed by the path
|
|
125
|
+
* @typeParam P - path into the deeply nested type
|
|
126
|
+
* @example
|
|
127
|
+
* ```
|
|
128
|
+
* PathValue<{foo: {bar: string}}, 'foo.bar'> = string
|
|
129
|
+
* PathValue<[number, string], '1'> = string
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export 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;
|
|
133
|
+
/**
|
|
134
|
+
* Type which eagerly collects all paths through a type
|
|
135
|
+
* @typeParam T - type which should be introspected
|
|
136
|
+
* @example
|
|
137
|
+
* ```
|
|
138
|
+
* Path<{foo: {bar: string}}> = 'foo' | 'foo.bar'
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export type Path<T> = T extends any ? PathInternal<T, T, true> & string : never;
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type FieldValidationMetaInfo = {
|
|
2
|
+
field: string;
|
|
3
|
+
name: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
form: Record<string, unknown>;
|
|
7
|
+
rule?: {
|
|
8
|
+
name: string;
|
|
9
|
+
params?: Record<string, unknown> | unknown[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type ValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams, ctx: FieldValidationMetaInfo) => boolean | string | Promise<boolean | string>;
|
|
13
|
+
export type SimpleValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams) => boolean | string | Promise<boolean | string>;
|
|
14
|
+
export type ValidationMessageGenerator = (ctx: FieldValidationMetaInfo) => string;
|
|
15
|
+
export type Optional<T> = T extends Record<string, any> ? Partial<T> : T | undefined;
|
|
16
|
+
export type InterpolateOptions = {
|
|
17
|
+
prefix: string;
|
|
18
|
+
suffix: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { ButtonProps, CheckboxProps, CheckboxGroupProps, DatePickerProps, InputProps, InputNumberProps, RadioProps, RadioGroupProps, SelectProps, SelectV2Props, SwitchProps, TimePickerDefaultProps, UploadProps, CascaderProps } from 'element-plus';
|
|
2
|
+
import { FieldOptions, FormContext, GenericObject } from 'vee-validate';
|
|
3
|
+
import { Component, HtmlHTMLAttributes, MaybeRefOrGetter, Ref } from 'vue';
|
|
4
|
+
import { ZodTypeAny } from 'zod';
|
|
5
|
+
import { TtTextProps } from '../../tt-text';
|
|
6
|
+
import { TtSelectProp } from '../../tt-select';
|
|
7
|
+
import { FormApi } from './formApi';
|
|
8
|
+
export type FormLayout = "horizontal" | "inline" | "vertical";
|
|
9
|
+
export interface BaseFormComponentMap {
|
|
10
|
+
TtSelect: TtSelectProp;
|
|
11
|
+
ElCheckbox: CheckboxProps;
|
|
12
|
+
ElCheckboxButton: CheckboxProps;
|
|
13
|
+
ElCheckboxGroup: CheckboxGroupProps;
|
|
14
|
+
ElDatePicker: DatePickerProps;
|
|
15
|
+
ElInput: InputProps;
|
|
16
|
+
ElInputNumber: InputNumberProps;
|
|
17
|
+
ElRadio: RadioProps;
|
|
18
|
+
ElRadioGroup: RadioGroupProps;
|
|
19
|
+
ElSelect: SelectProps;
|
|
20
|
+
ElSelectV2: SelectV2Props;
|
|
21
|
+
ElSwitch: SwitchProps;
|
|
22
|
+
ElTimePicker: TimePickerDefaultProps;
|
|
23
|
+
ElTreeSelect: Record<string, any>;
|
|
24
|
+
ElUpload: UploadProps;
|
|
25
|
+
ElCascader: CascaderProps;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 表单组件类型字符串联合类型
|
|
29
|
+
* 基于 BaseFormComponentMap 接口的键名
|
|
30
|
+
*/
|
|
31
|
+
export type BaseFormComponentType = keyof BaseFormComponentMap;
|
|
32
|
+
type Breakpoints = "2xl:" | "3xl:" | "" | "lg:" | "md:" | "sm:" | "xl:";
|
|
33
|
+
type GridCols = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
|
|
34
|
+
export type WrapperClassType = `${Breakpoints}grid-cols-${GridCols}` | (Record<never, never> & string);
|
|
35
|
+
export type FormItemClassType = `${Breakpoints}cols-end-${"auto" | GridCols}` | `${Breakpoints}cols-span-${"auto" | "full" | GridCols}` | `${Breakpoints}cols-start-${"auto" | GridCols}` | (Record<never, never> & string) | WrapperClassType;
|
|
36
|
+
export type FormFieldOptions = Partial<FieldOptions & {
|
|
37
|
+
validateOnBlur?: boolean;
|
|
38
|
+
validateOnChange?: boolean;
|
|
39
|
+
validateOnInput?: boolean;
|
|
40
|
+
validateOnModelUpdate?: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
export interface FormShape {
|
|
43
|
+
/** 默认值 */
|
|
44
|
+
default?: any;
|
|
45
|
+
/** 字段名 */
|
|
46
|
+
fieldName: string;
|
|
47
|
+
/** 是否必填 */
|
|
48
|
+
required?: boolean;
|
|
49
|
+
rules?: ZodTypeAny;
|
|
50
|
+
}
|
|
51
|
+
export type MaybeComponentPropKey = "options" | "placeholder" | "title" | keyof HtmlHTMLAttributes | (Record<never, never> & string);
|
|
52
|
+
export type MaybeComponentProps = {
|
|
53
|
+
[K in MaybeComponentPropKey]?: any;
|
|
54
|
+
};
|
|
55
|
+
export type FormActions = FormContext<GenericObject>;
|
|
56
|
+
export type CustomRenderType = (() => Component | string) | string;
|
|
57
|
+
export type FormSchemaRuleType = "required" | "selectRequired" | null | (Record<never, never> & string) | ZodTypeAny;
|
|
58
|
+
type FormItemDependenciesCondition<T = boolean | PromiseLike<boolean>> = (value: Partial<Record<string, any>>, actions: FormActions) => T;
|
|
59
|
+
type FormItemDependenciesConditionWithRules = (value: Partial<Record<string, any>>, actions: FormActions) => FormSchemaRuleType | PromiseLike<FormSchemaRuleType>;
|
|
60
|
+
type FormItemDependenciesConditionWithProps = (value: Partial<Record<string, any>>, actions: FormActions) => MaybeComponentProps | PromiseLike<MaybeComponentProps>;
|
|
61
|
+
export interface FormItemDependencies {
|
|
62
|
+
/**
|
|
63
|
+
* 组件参数
|
|
64
|
+
* @returns 组件参数
|
|
65
|
+
*/
|
|
66
|
+
componentProps?: FormItemDependenciesConditionWithProps;
|
|
67
|
+
/**
|
|
68
|
+
* 是否禁用
|
|
69
|
+
* @returns 是否禁用
|
|
70
|
+
*/
|
|
71
|
+
disabled?: boolean | FormItemDependenciesCondition;
|
|
72
|
+
/**
|
|
73
|
+
* 是否渲染(删除dom)
|
|
74
|
+
* @returns 是否渲染
|
|
75
|
+
*/
|
|
76
|
+
if?: boolean | FormItemDependenciesCondition;
|
|
77
|
+
/**
|
|
78
|
+
* 是否必填
|
|
79
|
+
* @returns 是否必填
|
|
80
|
+
*/
|
|
81
|
+
required?: FormItemDependenciesCondition;
|
|
82
|
+
/**
|
|
83
|
+
* 字段规则
|
|
84
|
+
*/
|
|
85
|
+
rules?: FormItemDependenciesConditionWithRules;
|
|
86
|
+
/**
|
|
87
|
+
* 是否隐藏(Css)
|
|
88
|
+
* @returns 是否隐藏
|
|
89
|
+
*/
|
|
90
|
+
show?: boolean | FormItemDependenciesCondition;
|
|
91
|
+
/**
|
|
92
|
+
* 任意触发都会执行
|
|
93
|
+
*/
|
|
94
|
+
trigger?: FormItemDependenciesCondition<void>;
|
|
95
|
+
/**
|
|
96
|
+
* 触发字段
|
|
97
|
+
*/
|
|
98
|
+
triggerFields: string[];
|
|
99
|
+
}
|
|
100
|
+
type ComponentProps = ((value: Partial<Record<string, any>>, actions: FormActions) => MaybeComponentProps) | MaybeComponentProps;
|
|
101
|
+
export interface FormCommonConfig {
|
|
102
|
+
/**
|
|
103
|
+
* 在Label后显示一个冒号
|
|
104
|
+
*/
|
|
105
|
+
colon?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* 所有表单项的props
|
|
108
|
+
*/
|
|
109
|
+
componentProps?: ComponentProps;
|
|
110
|
+
/**
|
|
111
|
+
* 所有表单项的控件样式
|
|
112
|
+
*/
|
|
113
|
+
controlClass?: string;
|
|
114
|
+
/**
|
|
115
|
+
* 所有表单项的禁用状态
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
disabled?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 是否禁用所有表单项的change事件监听
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
disabledOnChangeListener?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* 是否禁用所有表单项的input事件监听
|
|
126
|
+
* @default true
|
|
127
|
+
*/
|
|
128
|
+
disabledOnInputListener?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* 所有表单项的空状态值,默认都是undefined,naive-ui的空状态值是null
|
|
131
|
+
*/
|
|
132
|
+
emptyStateValue?: null | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* 所有表单项的控件样式
|
|
135
|
+
* @default {}
|
|
136
|
+
*/
|
|
137
|
+
formFieldProps?: FormFieldOptions;
|
|
138
|
+
/**
|
|
139
|
+
* 所有表单项的栅格布局,支持函数形式
|
|
140
|
+
* @default ""
|
|
141
|
+
*/
|
|
142
|
+
formItemClass?: (() => string) | string;
|
|
143
|
+
/**
|
|
144
|
+
* 隐藏所有表单项label
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
hideLabel?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* 是否隐藏必填标记
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
hideRequiredMark?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* 所有表单项的label样式
|
|
155
|
+
* @default ""
|
|
156
|
+
*/
|
|
157
|
+
labelClass?: string;
|
|
158
|
+
/**
|
|
159
|
+
* 所有表单项的label宽度
|
|
160
|
+
*/
|
|
161
|
+
labelWidth?: number;
|
|
162
|
+
/**
|
|
163
|
+
* 所有表单项的model属性名
|
|
164
|
+
* @default "modelValue"
|
|
165
|
+
*/
|
|
166
|
+
modelPropName?: string;
|
|
167
|
+
/**
|
|
168
|
+
* 所有表单项的wrapper样式
|
|
169
|
+
*/
|
|
170
|
+
wrapperClass?: string;
|
|
171
|
+
}
|
|
172
|
+
type RenderComponentContentType = (value: Partial<Record<string, any>>, api: FormActions) => Record<string, any>;
|
|
173
|
+
export type HandleSubmitFn = (values: Record<string, any>) => Promise<void> | void;
|
|
174
|
+
export type HandleResetFn = (values: Record<string, any>) => Promise<void> | void;
|
|
175
|
+
export type FieldMappingTime = [
|
|
176
|
+
string,
|
|
177
|
+
[
|
|
178
|
+
string,
|
|
179
|
+
string
|
|
180
|
+
],
|
|
181
|
+
(((value: any, fieldName: string) => any) | [string, string] | null | string)?
|
|
182
|
+
][];
|
|
183
|
+
export type ArrayToStringFields = Array<[string[], string?] | string | string[]>;
|
|
184
|
+
export interface FormSchema<T extends BaseFormComponentType = BaseFormComponentType> extends FormCommonConfig {
|
|
185
|
+
/** 组件 */
|
|
186
|
+
component: Component | T;
|
|
187
|
+
/** 组件参数 */
|
|
188
|
+
componentProps?: ComponentProps;
|
|
189
|
+
/** 默认值 */
|
|
190
|
+
defaultValue?: any;
|
|
191
|
+
/** 依赖 */
|
|
192
|
+
dependencies?: FormItemDependencies;
|
|
193
|
+
/** 描述 */
|
|
194
|
+
description?: CustomRenderType;
|
|
195
|
+
/** 字段名 */
|
|
196
|
+
fieldName: string;
|
|
197
|
+
/** 帮助信息 */
|
|
198
|
+
help?: CustomRenderType;
|
|
199
|
+
/** 是否隐藏表单项 */
|
|
200
|
+
hide?: boolean;
|
|
201
|
+
/** 表单项 */
|
|
202
|
+
label?: CustomRenderType;
|
|
203
|
+
renderComponentContent?: RenderComponentContentType;
|
|
204
|
+
/** 字段规则 */
|
|
205
|
+
rules?: FormSchemaRuleType;
|
|
206
|
+
/** 后缀 */
|
|
207
|
+
suffix?: CustomRenderType;
|
|
208
|
+
/** 帮助信息触发器 */
|
|
209
|
+
helpTrigger?: "hover" | "click" | "focus" | "contextmenu";
|
|
210
|
+
/** label本身文字气泡设置 */
|
|
211
|
+
toolTip?: TtTextProps;
|
|
212
|
+
/** 非label文字气泡设置 */
|
|
213
|
+
toolTipText?: CustomRenderType;
|
|
214
|
+
}
|
|
215
|
+
export interface FormFieldProps extends FormSchema {
|
|
216
|
+
required?: boolean;
|
|
217
|
+
}
|
|
218
|
+
export interface FormRenderProps<T extends BaseFormComponentType = BaseFormComponentType> {
|
|
219
|
+
/**
|
|
220
|
+
* 表单字段数组映射字符串配置 默认使用","
|
|
221
|
+
*/
|
|
222
|
+
arrayToStringFields?: ArrayToStringFields;
|
|
223
|
+
/**
|
|
224
|
+
* 是否折叠,在showCollapseButton=true下生效
|
|
225
|
+
* true:折叠 false:展开
|
|
226
|
+
*/
|
|
227
|
+
collapsed?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* 折叠时保持行数
|
|
230
|
+
* @default 1
|
|
231
|
+
*/
|
|
232
|
+
collapsedRows?: number;
|
|
233
|
+
/**
|
|
234
|
+
* 是否触发resize事件
|
|
235
|
+
* @default false
|
|
236
|
+
*/
|
|
237
|
+
collapseTriggerResize?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* 表单项通用后备配置,当子项目没配置时使用这里的配置,子项目配置优先级高于此配置
|
|
240
|
+
*/
|
|
241
|
+
commonConfig?: FormCommonConfig;
|
|
242
|
+
/**
|
|
243
|
+
* 紧凑模式(移除表单每一项底部为校验信息预留的空间)
|
|
244
|
+
*/
|
|
245
|
+
compact?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* 组件v-model事件绑定
|
|
248
|
+
*/
|
|
249
|
+
componentBindEventMap?: Partial<Record<BaseFormComponentType, string>>;
|
|
250
|
+
/**
|
|
251
|
+
* 组件集合
|
|
252
|
+
*/
|
|
253
|
+
componentMap: Record<BaseFormComponentType, Component>;
|
|
254
|
+
/**
|
|
255
|
+
* 表单字段映射到时间格式
|
|
256
|
+
*/
|
|
257
|
+
fieldMappingTime?: FieldMappingTime;
|
|
258
|
+
/**
|
|
259
|
+
* 表单实例
|
|
260
|
+
*/
|
|
261
|
+
form?: FormContext<GenericObject>;
|
|
262
|
+
/**
|
|
263
|
+
* 表单项布局
|
|
264
|
+
*/
|
|
265
|
+
layout?: FormLayout;
|
|
266
|
+
/**
|
|
267
|
+
* 表单定义
|
|
268
|
+
*/
|
|
269
|
+
schema?: FormSchema<T>[];
|
|
270
|
+
/**
|
|
271
|
+
* 是否显示展开/折叠
|
|
272
|
+
*/
|
|
273
|
+
showCollapseButton?: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* 格式化日期
|
|
276
|
+
*/
|
|
277
|
+
/**
|
|
278
|
+
* 表单栅格布局
|
|
279
|
+
* @default "grid-cols-1"
|
|
280
|
+
*/
|
|
281
|
+
wrapperClass?: WrapperClassType;
|
|
282
|
+
}
|
|
283
|
+
export type ActionButtonOptions = {
|
|
284
|
+
[key: string]: any;
|
|
285
|
+
content?: MaybeRefOrGetter<string>;
|
|
286
|
+
show?: boolean;
|
|
287
|
+
customFn?: (value: Record<string, any>) => Record<string, any>;
|
|
288
|
+
} & Partial<ButtonProps>;
|
|
289
|
+
export interface TtFormProps<T extends BaseFormComponentType = BaseFormComponentType> extends Omit<FormRenderProps<T>, "componentBindEventMap" | "componentMap" | "form"> {
|
|
290
|
+
/**
|
|
291
|
+
* 操作按钮是否反转(提交按钮前置)
|
|
292
|
+
*/
|
|
293
|
+
actionButtonsReverse?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* 操作按钮组的样式
|
|
296
|
+
* newLine: 在新行显示。rowEnd: 在行内显示,靠右对齐(默认)。inline: 使用grid默认样式
|
|
297
|
+
*/
|
|
298
|
+
actionLayout?: "inline" | "newLine" | "rowEnd";
|
|
299
|
+
/**
|
|
300
|
+
* 操作按钮组显示位置,默认靠右显示
|
|
301
|
+
*/
|
|
302
|
+
actionPosition?: "center" | "left" | "right";
|
|
303
|
+
/**
|
|
304
|
+
* 表单操作区域class
|
|
305
|
+
*/
|
|
306
|
+
actionWrapperClass?: Array<object | string> | object | string;
|
|
307
|
+
/**
|
|
308
|
+
* 表单字段数组映射字符串配置 默认使用","
|
|
309
|
+
*/
|
|
310
|
+
arrayToStringFields?: ArrayToStringFields;
|
|
311
|
+
/**
|
|
312
|
+
* 表单字段映射
|
|
313
|
+
*/
|
|
314
|
+
fieldMappingTime?: FieldMappingTime;
|
|
315
|
+
/**
|
|
316
|
+
* 表单收起展开状态变化回调
|
|
317
|
+
*/
|
|
318
|
+
handleCollapsedChange?: (collapsed: boolean) => void;
|
|
319
|
+
/**
|
|
320
|
+
* 表单重置回调
|
|
321
|
+
*/
|
|
322
|
+
handleReset?: HandleResetFn;
|
|
323
|
+
/**
|
|
324
|
+
* 表单提交回调
|
|
325
|
+
*/
|
|
326
|
+
handleSubmit?: HandleSubmitFn;
|
|
327
|
+
/**
|
|
328
|
+
* 表单值变化回调
|
|
329
|
+
*/
|
|
330
|
+
handleValuesChange?: (values: Record<string, any>, fieldsChanged: string[]) => void;
|
|
331
|
+
/**
|
|
332
|
+
* 重置按钮参数
|
|
333
|
+
*/
|
|
334
|
+
resetButtonOptions?: ActionButtonOptions;
|
|
335
|
+
/**
|
|
336
|
+
* 验证失败时是否自动滚动到第一个错误字段
|
|
337
|
+
* @default false
|
|
338
|
+
*/
|
|
339
|
+
scrollToFirstError?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* 是否显示默认操作按钮
|
|
342
|
+
* @default true
|
|
343
|
+
*/
|
|
344
|
+
showDefaultActions?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* 提交按钮参数
|
|
347
|
+
*/
|
|
348
|
+
submitButtonOptions?: ActionButtonOptions;
|
|
349
|
+
/**
|
|
350
|
+
* 是否在字段值改变时提交表单
|
|
351
|
+
* @default false
|
|
352
|
+
*/
|
|
353
|
+
submitOnChange?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* 是否在回车时提交表单
|
|
356
|
+
* @default false
|
|
357
|
+
*/
|
|
358
|
+
submitOnEnter?: boolean;
|
|
359
|
+
}
|
|
360
|
+
export type ExtendedFormApi = FormApi & {
|
|
361
|
+
useStore: <T = NoInfer<TtFormProps>>(selector?: (state: NoInfer<TtFormProps>) => T) => Readonly<Ref<T>>;
|
|
362
|
+
};
|
|
363
|
+
export interface TtFormAdapterOptions<T extends BaseFormComponentType = BaseFormComponentType> {
|
|
364
|
+
config?: {
|
|
365
|
+
baseModelPropName?: string;
|
|
366
|
+
disabledOnChangeListener?: boolean;
|
|
367
|
+
disabledOnInputListener?: boolean;
|
|
368
|
+
emptyStateValue?: null | undefined;
|
|
369
|
+
modelPropNameMap?: Partial<Record<T, string>>;
|
|
370
|
+
};
|
|
371
|
+
defineRules?: {
|
|
372
|
+
required?: (value: any, params: any, ctx: Record<string, any>) => boolean | string;
|
|
373
|
+
selectRequired?: (value: any, params: any, ctx: Record<string, any>) => boolean | string;
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* 根据组件类型推断组件参数类型的基础类型
|
|
378
|
+
* Base type for component props based on component type
|
|
379
|
+
* @template T - 组件类型(内置组件名或自定义组件)
|
|
380
|
+
* @template P - 自定义组件的 Props 类型(可选,用于自定义组件类型推断)
|
|
381
|
+
*/
|
|
382
|
+
export type InferredComponentPropsType<T extends BaseFormComponentType | Component, P = never> = T extends BaseFormComponentType ? Partial<BaseFormComponentMap[T]> & MaybeComponentProps : [P] extends [never] ? MaybeComponentProps : Partial<P> & MaybeComponentProps;
|
|
383
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { BaseFormComponentType, ExtendedFormApi, TtFormProps } from './types';
|
|
2
|
+
export declare function useForm<T extends BaseFormComponentType = BaseFormComponentType>(options: TtFormProps<T>): readonly [import('vue').DefineSetupFnComponent<TtFormProps<keyof import('./types').BaseFormComponentMap>, {}, {}, TtFormProps<keyof import('./types').BaseFormComponentMap> & {}, import('vue').PublicProps>, ExtendedFormApi];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { ExtendedFormApi, FormActions, TtFormProps } from './types';
|
|
3
|
+
type ExtendFormProps = TtFormProps & {
|
|
4
|
+
formApi?: ExtendedFormApi;
|
|
5
|
+
};
|
|
6
|
+
export declare const injectFormProps: <T extends [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions] | null | undefined = [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions]>(fallback?: T | undefined) => T extends null ? [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions] | null : [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions], provideFormProps: (contextValue: [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions]) => [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions];
|
|
7
|
+
export declare const injectComponentRefMap: <T extends Map<string, unknown> | null | undefined = Map<string, unknown>>(fallback?: T | undefined) => T extends null ? Map<string, unknown> | null : Map<string, unknown>, provideComponentRefMap: (contextValue: Map<string, unknown>) => Map<string, unknown>;
|
|
8
|
+
export declare function useFormInitial(props: ComputedRef<TtFormProps> | TtFormProps): {
|
|
9
|
+
delegatedSlots: ComputedRef<string[]>;
|
|
10
|
+
form: import('vee-validate').FormContext<Record<string, any>, Record<string, any>>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|