| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import type {
- AutoCompleteProps,
- ButtonProps,
- CascaderProps,
- CheckboxGroupProps,
- CheckboxProps,
- DatePickerProps,
- DividerProps,
- InputNumberProps,
- InputProps,
- MentionsProps,
- RadioGroupProps,
- RadioProps,
- RangePickerProps,
- RateProps,
- SelectProps,
- SpaceProps,
- SwitchProps,
- TextAreaProps,
- TimePickerProps,
- TreeSelectProps,
- UploadProps,
- } from 'antdv-next';
- import type { Component } from 'vue';
- import type {
- ApiComponentSharedProps,
- VbenFormSchema as CoreFormSchema,
- FormActions,
- IconPickerProps,
- } from '@vben/common-ui';
- import type { ComponentType } from './component';
- type ComponentProps<P> =
- | ((
- value: Partial<Record<string, any>>,
- actions: FormActions,
- ) => P & Record<string, any>)
- | (P & Record<string, any>);
- /**
- * 与 {@link ComponentType} 中注册的组件名一一对应,便于 Schema 上 `component` + `componentProps` 联动提示
- */
- interface ComponentPropsMap {
- ApiCascader: ApiComponentSharedProps & CascaderProps;
- ApiSelect: ApiComponentSharedProps & SelectProps;
- ApiTreeSelect: ApiComponentSharedProps & TreeSelectProps;
- AutoComplete: AutoCompleteProps;
- Cascader: CascaderProps;
- Checkbox: CheckboxProps;
- CheckboxGroup: CheckboxGroupProps;
- DatePicker: DatePickerProps;
- DefaultButton: ButtonProps;
- Divider: DividerProps;
- IconPicker: IconPickerProps;
- Input: InputProps;
- InputNumber: InputNumberProps;
- InputPassword: InputProps;
- Mentions: MentionsProps;
- PrimaryButton: ButtonProps;
- Radio: RadioProps;
- RadioGroup: RadioGroupProps;
- RangePicker: RangePickerProps;
- Rate: RateProps;
- Select: SelectProps;
- Space: SpaceProps;
- Switch: SwitchProps;
- Textarea: TextAreaProps;
- TimePicker: TimePickerProps;
- TreeSelect: TreeSelectProps;
- Upload: UploadProps;
- }
- type BaseSchema = Omit<
- CoreFormSchema<ComponentType>,
- 'component' | 'componentProps'
- >;
- type RegisteredName = keyof ComponentPropsMap;
- type DiscriminatedFormSchema = {
- [K in RegisteredName]: BaseSchema & {
- component: K;
- componentProps?: ComponentProps<ComponentPropsMap[K]>;
- };
- }[RegisteredName];
- type FallbackFormSchema = BaseSchema & {
- component: Component | Exclude<ComponentType, RegisteredName>;
- componentProps?: CoreFormSchema<ComponentType>['componentProps'];
- };
- export type VbenFormSchema = DiscriminatedFormSchema | FallbackFormSchema;
|