@xinghunm/compass-ui 0.2.0 → 0.3.0

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.mts CHANGED
@@ -1168,9 +1168,13 @@ interface FieldData {
1168
1168
  */
1169
1169
  interface FieldEntity {
1170
1170
  onStoreChange: () => void;
1171
- validateRules: () => Promise<string[] | null>;
1171
+ validateRules: (options?: {
1172
+ triggerName?: string;
1173
+ }) => Promise<string[] | null>;
1172
1174
  getName: () => string;
1173
1175
  getErrors: () => string[];
1176
+ isFieldValidating: () => boolean;
1177
+ isFieldTouched: () => boolean;
1174
1178
  props: {
1175
1179
  name?: string;
1176
1180
  rules?: RuleItem[];
@@ -1180,6 +1184,7 @@ interface FieldEntity {
1180
1184
  }
1181
1185
  interface Callbacks<Values = Record<string, unknown>> {
1182
1186
  onValuesChange?: (changedValues: Store, values: Values) => void;
1187
+ onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
1183
1188
  onFinish?: (values: Values) => void;
1184
1189
  onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1185
1190
  }
@@ -1193,10 +1198,12 @@ interface ValidateErrorEntity<Values = Record<string, unknown>> {
1193
1198
  }
1194
1199
  interface InternalHooks {
1195
1200
  registerField: (entity: FieldEntity) => () => void;
1201
+ registerWatch: (callback: (name: string) => void) => () => void;
1196
1202
  setInitialValues: (values: Store, init: boolean) => void;
1197
1203
  setCallbacks: (callbacks: Callbacks) => void;
1198
1204
  dispatch: (action: ReducerAction) => void;
1199
1205
  getFieldValue: (name: string) => StoreValue;
1206
+ notifyFieldChange: (name: string) => void;
1200
1207
  }
1201
1208
  interface FormInstance<Values = Record<string, unknown>> {
1202
1209
  getFieldValue: (name: string) => StoreValue;
@@ -1228,10 +1235,11 @@ interface FormProps<Values = Record<string, unknown>> {
1228
1235
  onFinish?: (values: Values) => void;
1229
1236
  onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1230
1237
  onValuesChange?: (changedValues: Store, values: Values) => void;
1238
+ onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
1231
1239
  className?: string;
1232
1240
  style?: React__default.CSSProperties;
1233
1241
  }
1234
- declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
1242
+ declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, onFieldsChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
1235
1243
 
1236
1244
  interface FormItemProps {
1237
1245
  name?: string;
@@ -1247,14 +1255,18 @@ declare const FormItem: React__default.FC<FormItemProps>;
1247
1255
 
1248
1256
  declare const useForm: <Values extends Record<string, unknown> = Record<string, unknown>>(form?: FormInstance<Values>) => [FormInstance<Values>];
1249
1257
 
1258
+ declare const useWatch: <T = unknown>(name: string | string[], form?: FormInstance) => T;
1259
+
1250
1260
  type InternalFormType = typeof Form$1;
1251
1261
  interface FormInterface extends InternalFormType {
1252
1262
  Item: typeof FormItem;
1253
1263
  useForm: typeof useForm;
1264
+ useWatch: typeof useWatch;
1254
1265
  }
1255
1266
  declare const Form: FormInterface & {
1256
1267
  Item: typeof FormItem;
1257
1268
  useForm: typeof useForm;
1269
+ useWatch: typeof useWatch;
1258
1270
  };
1259
1271
 
1260
1272
  export { Button, type ButtonProps, ConfigProvider, type ConfigProviderProps, type DataNode, DatePicker, type DatePickerProps, type DateRangePickerProps, Dropdown, type DropdownProps, type FieldData, Form, type FormInstance, type FormItemProps, type FormProps, InputField, type InputFieldProps, InputNumber, type InputNumberProps, type ItemType, Menu, type MenuItemProps, type MenuProps, messageWithHook as Message, type MessageProps, ModalWithStatics as Modal, type ModalBaseProps as ModalProps, Pagination, type PaginationProps, Progress, type ProgressProps, Select, type SelectOption, type SelectProps, type SelectValue, Steps, type StepsProps, Tree, type TreeNodeProps, type TreeProps, type ValidateErrorEntity };
package/dist/index.d.ts CHANGED
@@ -1168,9 +1168,13 @@ interface FieldData {
1168
1168
  */
1169
1169
  interface FieldEntity {
1170
1170
  onStoreChange: () => void;
1171
- validateRules: () => Promise<string[] | null>;
1171
+ validateRules: (options?: {
1172
+ triggerName?: string;
1173
+ }) => Promise<string[] | null>;
1172
1174
  getName: () => string;
1173
1175
  getErrors: () => string[];
1176
+ isFieldValidating: () => boolean;
1177
+ isFieldTouched: () => boolean;
1174
1178
  props: {
1175
1179
  name?: string;
1176
1180
  rules?: RuleItem[];
@@ -1180,6 +1184,7 @@ interface FieldEntity {
1180
1184
  }
1181
1185
  interface Callbacks<Values = Record<string, unknown>> {
1182
1186
  onValuesChange?: (changedValues: Store, values: Values) => void;
1187
+ onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
1183
1188
  onFinish?: (values: Values) => void;
1184
1189
  onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1185
1190
  }
@@ -1193,10 +1198,12 @@ interface ValidateErrorEntity<Values = Record<string, unknown>> {
1193
1198
  }
1194
1199
  interface InternalHooks {
1195
1200
  registerField: (entity: FieldEntity) => () => void;
1201
+ registerWatch: (callback: (name: string) => void) => () => void;
1196
1202
  setInitialValues: (values: Store, init: boolean) => void;
1197
1203
  setCallbacks: (callbacks: Callbacks) => void;
1198
1204
  dispatch: (action: ReducerAction) => void;
1199
1205
  getFieldValue: (name: string) => StoreValue;
1206
+ notifyFieldChange: (name: string) => void;
1200
1207
  }
1201
1208
  interface FormInstance<Values = Record<string, unknown>> {
1202
1209
  getFieldValue: (name: string) => StoreValue;
@@ -1228,10 +1235,11 @@ interface FormProps<Values = Record<string, unknown>> {
1228
1235
  onFinish?: (values: Values) => void;
1229
1236
  onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1230
1237
  onValuesChange?: (changedValues: Store, values: Values) => void;
1238
+ onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
1231
1239
  className?: string;
1232
1240
  style?: React__default.CSSProperties;
1233
1241
  }
1234
- declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
1242
+ declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, onFieldsChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
1235
1243
 
1236
1244
  interface FormItemProps {
1237
1245
  name?: string;
@@ -1247,14 +1255,18 @@ declare const FormItem: React__default.FC<FormItemProps>;
1247
1255
 
1248
1256
  declare const useForm: <Values extends Record<string, unknown> = Record<string, unknown>>(form?: FormInstance<Values>) => [FormInstance<Values>];
1249
1257
 
1258
+ declare const useWatch: <T = unknown>(name: string | string[], form?: FormInstance) => T;
1259
+
1250
1260
  type InternalFormType = typeof Form$1;
1251
1261
  interface FormInterface extends InternalFormType {
1252
1262
  Item: typeof FormItem;
1253
1263
  useForm: typeof useForm;
1264
+ useWatch: typeof useWatch;
1254
1265
  }
1255
1266
  declare const Form: FormInterface & {
1256
1267
  Item: typeof FormItem;
1257
1268
  useForm: typeof useForm;
1269
+ useWatch: typeof useWatch;
1258
1270
  };
1259
1271
 
1260
1272
  export { Button, type ButtonProps, ConfigProvider, type ConfigProviderProps, type DataNode, DatePicker, type DatePickerProps, type DateRangePickerProps, Dropdown, type DropdownProps, type FieldData, Form, type FormInstance, type FormItemProps, type FormProps, InputField, type InputFieldProps, InputNumber, type InputNumberProps, type ItemType, Menu, type MenuItemProps, type MenuProps, messageWithHook as Message, type MessageProps, ModalWithStatics as Modal, type ModalBaseProps as ModalProps, Pagination, type PaginationProps, Progress, type ProgressProps, Select, type SelectOption, type SelectProps, type SelectValue, Steps, type StepsProps, Tree, type TreeNodeProps, type TreeProps, type ValidateErrorEntity };