context.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { InjectionKey, ComputedRef } from 'vue';
  2. import type { ColProps } from '../grid';
  3. import type { RequiredMark } from './Form';
  4. import type { ValidateStatus, FieldExpose } from './FormItem';
  5. import type { FormLabelAlign, Rule, ValidateMessages } from './interface';
  6. export interface FormContextProps {
  7. model?: ComputedRef<any>;
  8. vertical: ComputedRef<boolean>;
  9. name?: ComputedRef<string>;
  10. colon?: ComputedRef<boolean>;
  11. labelAlign?: ComputedRef<FormLabelAlign>;
  12. labelWrap?: ComputedRef<boolean>;
  13. labelCol?: ComputedRef<ColProps>;
  14. wrapperCol?: ComputedRef<ColProps>;
  15. requiredMark?: ComputedRef<RequiredMark>;
  16. addField: (eventKey: string, field: FieldExpose) => void;
  17. removeField: (eventKey: string) => void;
  18. validateTrigger?: ComputedRef<string | string[]>;
  19. rules?: ComputedRef<{
  20. [k: string]: Rule[] | Rule;
  21. }>;
  22. onValidate: (name: string | number | Array<string | number>, status: boolean, errors: string[] | null) => void;
  23. validateMessages: ComputedRef<ValidateMessages>;
  24. }
  25. export declare const FormContextKey: InjectionKey<FormContextProps>;
  26. export declare const useProvideForm: (state: FormContextProps) => void;
  27. export declare const useInjectForm: () => FormContextProps;
  28. /** Used for ErrorList only */
  29. export interface FormItemPrefixContextProps {
  30. prefixCls: ComputedRef<string>;
  31. status?: ComputedRef<ValidateStatus>;
  32. }
  33. export declare const FormItemPrefixContextKey: InjectionKey<FormItemPrefixContextProps>;
  34. export declare const useProvideFormItemPrefix: (state: FormItemPrefixContextProps) => void;
  35. export declare const useInjectFormItemPrefix: () => FormItemPrefixContextProps;