useForm.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import type { FormInstance, InternalFormInstance, InternalNamePath, StoreValue } from './interface';
  2. interface UpdateAction {
  3. type: 'updateValue';
  4. namePath: InternalNamePath;
  5. value: StoreValue;
  6. }
  7. interface ValidateAction {
  8. type: 'validateField';
  9. namePath: InternalNamePath;
  10. triggerName: string;
  11. }
  12. export type ReducerAction = UpdateAction | ValidateAction;
  13. export declare class FormStore {
  14. private formHooked;
  15. private forceRootUpdate;
  16. private subscribable;
  17. private store;
  18. private fieldEntities;
  19. private initialValues;
  20. private callbacks;
  21. private validateMessages;
  22. private preserve?;
  23. private lastValidatePromise;
  24. constructor(forceRootUpdate: () => void);
  25. getForm: () => InternalFormInstance;
  26. private getInternalHooks;
  27. private useSubscribe;
  28. /**
  29. * Record prev Form unmount fieldEntities which config preserve false.
  30. * This need to be refill with initialValues instead of store value.
  31. */
  32. private prevWithoutPreserves;
  33. /**
  34. * First time `setInitialValues` should update store with initial value
  35. */
  36. private setInitialValues;
  37. private destroyForm;
  38. private getInitialValue;
  39. private setCallbacks;
  40. private setValidateMessages;
  41. private setPreserve;
  42. private watchList;
  43. private registerWatch;
  44. private notifyWatch;
  45. private timeoutId;
  46. private warningUnhooked;
  47. private updateStore;
  48. /**
  49. * Get registered field entities.
  50. * @param pure Only return field which has a `name`. Default: false
  51. */
  52. private getFieldEntities;
  53. private getFieldsMap;
  54. private getFieldEntitiesForNamePathList;
  55. private getFieldsValue;
  56. private getFieldValue;
  57. private getFieldsError;
  58. private getFieldError;
  59. private getFieldWarning;
  60. private isFieldsTouched;
  61. private isFieldTouched;
  62. private isFieldsValidating;
  63. private isFieldValidating;
  64. /**
  65. * Reset Field with field `initialValue` prop.
  66. * Can pass `entities` or `namePathList` or just nothing.
  67. */
  68. private resetWithFieldInitialValue;
  69. private resetFields;
  70. private setFields;
  71. private getFields;
  72. /**
  73. * This only trigger when a field is on constructor to avoid we get initialValue too late
  74. */
  75. private initEntityValue;
  76. private isMergedPreserve;
  77. private registerField;
  78. private dispatch;
  79. private notifyObservers;
  80. /**
  81. * Notify dependencies children with parent update
  82. * We need delay to trigger validate in case Field is under render props
  83. */
  84. private triggerDependenciesUpdate;
  85. private updateValue;
  86. private setFieldsValue;
  87. private setFieldValue;
  88. private getDependencyChildrenFields;
  89. private triggerOnFieldsChange;
  90. private validateFields;
  91. private submit;
  92. }
  93. declare function useForm<Values = any>(form?: FormInstance<Values>): [FormInstance<Values>];
  94. export default useForm;