x-ui-design 0.6.33 → 0.6.41

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.
@@ -1,5 +1,7 @@
1
- import React from 'react';
2
- import { FormInstance, FormProps } from '../../types/form';
1
+ import React, { FC } from 'react';
2
+ import { FormInstance, FormItemProps, FormProps } from '../../types/form';
3
3
  export declare const FormContext: React.Context<FormInstance | null>;
4
- declare const _default: React.NamedExoticComponent<FormProps>;
5
- export default _default;
4
+ declare const Form: FC<FormProps> & {
5
+ Item: FC<FormItemProps>;
6
+ };
7
+ export default Form;
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  import { FormItemProps } from '../../../types/form';
3
3
  import './style.css';
4
- declare const FormItem: React.MemoExoticComponent<({ prefixCls, name, label, rules, children, className, layout, style, extra, hideLabel, removeErrorMessageHeight, ...props }: FormItemProps) => React.JSX.Element>;
4
+ declare const FormItem: {
5
+ ({ prefixCls, name, label, rules, children, className, layout, style, dependencies, initialValue, feedbackIcons, extra, hideLabel, removeErrorMessageHeight, ...props }: FormItemProps): React.JSX.Element;
6
+ displayName: string;
7
+ };
5
8
  export default FormItem;
@@ -8,28 +8,7 @@ declare const DatePicker: import("react").ComponentType<import("@/types/datepick
8
8
  declare const RangePicker: import("react").ComponentType<import("@/types/datepicker").TRangePickerProps>;
9
9
  declare const TimePicker: import("react").ComponentType<import("@/types/datepicker").TimePickerProps>;
10
10
  declare const Form: import("react").ComponentType<import("@/types/form").FormProps>;
11
- declare const FormItem: import("react").ComponentType<import("@/types").DefaultProps & {
12
- name: string;
13
- label?: string | import("react").ReactNode;
14
- rules?: import("@/types/form").RuleObject[];
15
- initialValue?: import("@/types").RuleType;
16
- children: (import("react").ReactElement & {
17
- props: {
18
- value: import("@/types").RuleTypes;
19
- };
20
- }) | (import("react").ReactElement & {
21
- props: {
22
- value: import("@/types").RuleTypes;
23
- };
24
- })[];
25
- layout?: import("@/types/form").FormLayoutTypes;
26
- dependencies?: string[];
27
- normalize?: (value: import("@/types").RuleType, prevValue: import("@/types").RuleType, allValues: import("@/types").RuleType) => import("@/types").RuleType;
28
- feedbackIcons?: boolean;
29
- extra?: import("react").ReactNode;
30
- hideLabel?: boolean;
31
- removeErrorMessageHeight?: boolean;
32
- }>;
11
+ declare const FormItem: import("react").ComponentType<import("@/types/form").FormItemProps>;
33
12
  declare const Input: import("react").ComponentType<import("@/types/input").InputProps>;
34
13
  declare const Textarea: import("react").ComponentType<import("@/types/input").TextareaProps>;
35
14
  declare const Radio: import("react").ComponentType<import("@/types/radio").RadioProps>;
@@ -74,16 +74,17 @@ export interface FormItemChildComponentProps {
74
74
  child: ReactElement;
75
75
  name: string;
76
76
  error: boolean;
77
- initialValue: RuleTypes;
77
+ fieldValue: RuleTypes;
78
+ value: RuleType;
79
+ setFieldValue: (name: string, value: RuleType, errors?: string[], reset?: boolean | null | undefined, touch?: boolean) => void;
78
80
  onChange?: (e: SyntheticBaseEvent, option?: OptionProps) => void;
79
81
  size?: SizeType;
80
82
  normalize?: (value: RuleType, prevValue: RuleType, allValues: RuleType) => RuleType;
81
83
  noStyle?: boolean;
82
84
  feedbackIcons?: boolean;
83
85
  ref?: FieldInstancesRef | null;
84
- dependencies?: string[];
85
86
  }
86
- export type FormInstance = {
87
+ export interface FormInstance {
87
88
  submit: () => Promise<Record<string, RuleTypes> | undefined>;
88
89
  setFields: (fields: FieldData[]) => void;
89
90
  resetFields: (nameList?: string[], showError?: boolean | null) => void;
@@ -101,7 +102,6 @@ export type FormInstance = {
101
102
  subscribeToField: (name: string, callback: (value: RuleTypes) => void) => () => void;
102
103
  subscribeToForm: (callback: (values: Record<string, RuleTypes>) => void) => () => void;
103
104
  subscribeToFields: (names: string[], callback: (values: Record<string, RuleTypes>) => void) => () => void;
104
- subscribeToFieldError: (name: string, callback: (errors: string[]) => void) => () => void;
105
105
  isFieldValidating: (name: string) => boolean;
106
106
  onFieldsChange?: (changedFields: FieldData[]) => void;
107
107
  onValuesChange?: (changedValues: Record<string, RuleTypes>, allValues: Record<string, RuleTypes>) => void;
@@ -118,4 +118,4 @@ export type FormInstance = {
118
118
  errorFields: Pick<FieldError, 'errors' | 'name'>[];
119
119
  }) => void) => void;
120
120
  changeStep: (step: number) => void;
121
- };
121
+ }
package/dist/index.d.ts CHANGED
@@ -6,8 +6,6 @@ import * as __types_radio from '@/types/radio';
6
6
  export { RadioButtonProps, RadioGroupProps, RadioProps } from '@/types/radio';
7
7
  import * as __types_input from '@/types/input';
8
8
  export { InputProps, TextareaProps } from '@/types/input';
9
- import * as __types from '@/types';
10
- export { DefaultProps, MouseEventHandlerSelect, RuleType, RuleTypes, SyntheticBaseEvent, TargetProps } from '@/types';
11
9
  import * as __types_form from '@/types/form';
12
10
  export { FieldData, FieldError, FieldInstancesInputRef, FormInstance, FormItemChildComponentProps, FormProps, RuleObject, RuleRender } from '@/types/form';
13
11
  import * as __types_datepicker from '@/types/datepicker';
@@ -21,6 +19,7 @@ export { BaseButtonProps, ButtonProps, ButtonType } from '@/types/button';
21
19
  export { ArrowIcon, CalendarIcon, CheckIcon, ClearIcon, DateDistanceIcon, ErrorIcon, LoadingIcon, SearchIcon, SpinerIcon, StampleIcon, SuccessIcon, TimeIcon, TrashIcon } from '@/components/Icons';
22
20
  export { useForm } from '@/hooks/useForm';
23
21
  export { useWatch } from '@/hooks/useWatch';
22
+ export { DefaultProps, MouseEventHandlerSelect, RuleType, RuleTypes, SyntheticBaseEvent, TargetProps } from '@/types';
24
23
  export { FormContext } from '@/components/Form/Form';
25
24
  export { clsx, createArray, parseValue } from '@/helpers';
26
25
  export { flattenChildren } from '@/helpers/flatten';
@@ -112,28 +111,7 @@ declare const DatePicker: react.ComponentType<__types_datepicker.TDatePickerProp
112
111
  declare const RangePicker: react.ComponentType<__types_datepicker.TRangePickerProps>;
113
112
  declare const TimePicker: react.ComponentType<__types_datepicker.TimePickerProps>;
114
113
  declare const Form: react.ComponentType<__types_form.FormProps>;
115
- declare const FormItem: react.ComponentType<__types.DefaultProps & {
116
- name: string;
117
- label?: string | react.ReactNode;
118
- rules?: __types_form.RuleObject[];
119
- initialValue?: __types.RuleType;
120
- children: (react.ReactElement & {
121
- props: {
122
- value: __types.RuleTypes;
123
- };
124
- }) | (react.ReactElement & {
125
- props: {
126
- value: __types.RuleTypes;
127
- };
128
- })[];
129
- layout?: __types_form.FormLayoutTypes;
130
- dependencies?: string[];
131
- normalize?: (value: __types.RuleType, prevValue: __types.RuleType, allValues: __types.RuleType) => __types.RuleType;
132
- feedbackIcons?: boolean;
133
- extra?: react.ReactNode;
134
- hideLabel?: boolean;
135
- removeErrorMessageHeight?: boolean;
136
- }>;
114
+ declare const FormItem: react.ComponentType<__types_form.FormItemProps>;
137
115
  declare const Input: react.ComponentType<__types_input.InputProps>;
138
116
  declare const Textarea: react.ComponentType<__types_input.TextareaProps>;
139
117
  declare const Radio: react.ComponentType<__types_radio.RadioProps>;
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import require$$1 from 'react/jsx-runtime';
2
- import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, memo, useContext, useMemo, useEffect, useCallback, createContext, useImperativeHandle, useLayoutEffect } from 'react';
2
+ import React, { useRef, useState, useEffect, Children, isValidElement, Fragment, Suspense, useContext, useMemo, createContext, useImperativeHandle, useCallback, useLayoutEffect } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import ReactDOMServer from 'react-dom/server';
5
5
 
@@ -627,10 +627,13 @@ const useForm = ({
627
627
  });
628
628
  const fieldInstancesRef = useRef({});
629
629
  const [isReseting, setIsReseting] = useState(false);
630
- const errorsRef = useRef({});
630
+ const [errors, setErrors] = useState({});
631
+ const errorsRef = useRef(errors);
631
632
  const fieldSubscribers = useRef({});
632
633
  const formSubscribers = useRef([]);
633
- const errorSubscribers = useRef({});
634
+ useEffect(() => {
635
+ errorsRef.current = errors;
636
+ }, [errors]);
634
637
  function getFormFields() {
635
638
  return Object.assign({}, ...Object.values(formRef.current));
636
639
  }
@@ -672,10 +675,12 @@ const useForm = ({
672
675
  touchedFieldsRef.current.add(name);
673
676
  }
674
677
  if (reset === null) {
675
- errorsRef.current[name] = [];
678
+ setErrors({
679
+ [name]: []
680
+ });
676
681
  return;
677
682
  }
678
- if (!errorsRef.current?.length) {
683
+ if (!errors?.length) {
679
684
  validateField(name).then(() => {
680
685
  const allValues = getFieldsValue();
681
686
  fieldSubscribers.current[name]?.forEach(callback => callback(value));
@@ -693,7 +698,9 @@ const useForm = ({
693
698
  }
694
699
  });
695
700
  } else {
696
- errorsRef.current[name] = errors || [];
701
+ setErrors({
702
+ [name]: errors
703
+ });
697
704
  }
698
705
  }
699
706
  function setFieldsValue(values, reset) {
@@ -769,12 +776,11 @@ const useForm = ({
769
776
  }
770
777
  }
771
778
  }));
772
- errorsRef.current = {
773
- ...errorsRef.current,
779
+ setErrors(prev => ({
780
+ ...prev,
774
781
  [name]: fieldErrors
775
- };
782
+ }));
776
783
  warningsRef.current[name] = fieldWarnings;
777
- errorSubscribers.current[name]?.forEach(callback => callback(fieldErrors));
778
784
  return fieldErrors.length === 0;
779
785
  }
780
786
  async function validateFields(nameList) {
@@ -805,12 +811,11 @@ const useForm = ({
805
811
  formData[name] = initialValues[name];
806
812
  touchedFieldsRef.current.delete(name);
807
813
  delete warningsRef.current[name];
808
- errorsRef.current = {
809
- ...errorsRef.current,
814
+ setErrors(prev => ({
815
+ ...prev,
810
816
  [name]: []
811
- };
817
+ }));
812
818
  setFieldValue(name, initialValues[name], undefined, showError);
813
- errorSubscribers.current[name]?.forEach(callback => callback([]));
814
819
  });
815
820
  } else {
816
821
  touchedFieldsRef.current.clear();
@@ -819,7 +824,6 @@ const useForm = ({
819
824
  ...formData
820
825
  }).forEach(name => {
821
826
  setFieldValue(name, initialValues[name], undefined, showError);
822
- errorSubscribers.current[name]?.forEach(callback => callback([]));
823
827
  });
824
828
  }
825
829
  formSubscribers.current.forEach(callback => callback(getFieldsValue()));
@@ -849,22 +853,13 @@ const useForm = ({
849
853
  }
850
854
  function subscribeToFields(names, callback) {
851
855
  const fieldCallbacks = names.map(name => subscribeToField(name, () => {
852
- callback(getFieldsValue(names));
856
+ const updatedValues = getFieldsValue(names);
857
+ callback(updatedValues);
853
858
  }));
854
859
  return () => {
855
860
  fieldCallbacks.forEach(unsubscribe => unsubscribe());
856
861
  };
857
862
  }
858
- function subscribeToFieldError(name, callback) {
859
- if (!errorSubscribers.current[name]) {
860
- errorSubscribers.current[name] = [];
861
- }
862
- errorSubscribers.current[name].push(callback);
863
- callback(errorsRef.current[name] || []);
864
- return () => {
865
- errorSubscribers.current[name] = errorSubscribers.current[name].filter(cb => cb !== callback);
866
- };
867
- }
868
863
  function setScrollToFirstError(value) {
869
864
  _scrollToFirstError.current = value;
870
865
  }
@@ -874,12 +869,12 @@ const useForm = ({
874
869
  function setOnValuesChange(onValuesChange) {
875
870
  formHandlersRef.current.onValuesChange = onValuesChange;
876
871
  }
877
- function setOnFinishFailed(onFinishFailed) {
878
- formHandlersRef.current.onFinishFailed = onFinishFailed;
879
- }
880
872
  function setOnFinish(onFinish) {
881
873
  formHandlersRef.current.onFinish = onFinish;
882
874
  }
875
+ function setOnFinishFailed(onFinishFailed) {
876
+ formHandlersRef.current.onFinishFailed = onFinishFailed;
877
+ }
883
878
  function changeStep(step) {
884
879
  stepRef.current = step ?? 0;
885
880
  if (!formRef.current[stepRef.current]) {
@@ -899,12 +894,12 @@ const useForm = ({
899
894
  getFieldsValue,
900
895
  isFieldTouched,
901
896
  getFieldsError,
897
+ setOnFinishFailed,
902
898
  isFieldsTouched,
903
899
  getFieldWarning,
904
900
  isFieldValidating,
905
901
  subscribeToField,
906
902
  subscribeToForm,
907
- subscribeToFieldError,
908
903
  onFieldsChange,
909
904
  onValuesChange,
910
905
  getFieldInstance,
@@ -916,7 +911,6 @@ const useForm = ({
916
911
  setOnFinish,
917
912
  setOnFieldsChange,
918
913
  setOnValuesChange,
919
- setOnFinishFailed,
920
914
  changeStep
921
915
  };
922
916
  return formInstance;
@@ -1004,7 +998,7 @@ function flattenChildren(children) {
1004
998
  var css_248z$l = ".xUi-form-item{display:flex;position:relative}.xUi-form-item.noStyle{display:inline-flex;margin-bottom:0}.xUi-form-item-label{align-items:center;color:var(--xui-text-color);display:flex;font-size:var(--xui-font-size-md);font-weight:500;line-height:20px;margin-bottom:4px}.xUi-form-item-error{color:var(--xui-error-color);display:block;font-size:var(--xui-font-size-xs);line-height:16px;margin-bottom:8px;margin-top:4px;min-height:16px;position:relative;right:0;text-align:end;user-select:none}.xUi-form-item-required{color:var(--xui-error-color);display:inline-block;font-size:var(--xui-font-size-md);line-height:1;margin-left:4px;margin-right:4px}.xUi-form-item.horizontal{align-items:center;flex-direction:row;gap:4px}.xUi-form-item.vertical{align-self:flex-start;flex-direction:column}.xUi-form-item .xUi-input-container{width:-webkit-fill-available}";
1005
999
  styleInject(css_248z$l);
1006
1000
 
1007
- const FormItem$1 = /*#__PURE__*/memo(({
1001
+ const FormItem$1 = ({
1008
1002
  prefixCls = prefixClsFormItem,
1009
1003
  name,
1010
1004
  label,
@@ -1013,6 +1007,9 @@ const FormItem$1 = /*#__PURE__*/memo(({
1013
1007
  className = '',
1014
1008
  layout = 'vertical',
1015
1009
  style = {},
1010
+ dependencies = [],
1011
+ initialValue,
1012
+ feedbackIcons,
1016
1013
  extra,
1017
1014
  hideLabel = false,
1018
1015
  removeErrorMessageHeight = false,
@@ -1027,12 +1024,14 @@ const FormItem$1 = /*#__PURE__*/memo(({
1027
1024
  const {
1028
1025
  isReseting,
1029
1026
  registerField,
1027
+ getFieldError,
1028
+ getFieldValue,
1029
+ setFieldValue,
1030
1030
  getFieldInstance,
1031
1031
  setFieldInstance,
1032
- getFieldError,
1033
- subscribeToFieldError
1032
+ subscribeToFields,
1033
+ validateFields
1034
1034
  } = formContext;
1035
- const [errors, setErrors] = useState(getFieldError(name)?.[0]);
1036
1035
  const childrenList = useMemo(() => flattenChildren(children), [children]);
1037
1036
  useEffect(() => {
1038
1037
  if (name && !getFieldInstance(name)) {
@@ -1044,14 +1043,22 @@ const FormItem$1 = /*#__PURE__*/memo(({
1044
1043
  }, [name, fieldRef.current]);
1045
1044
  useEffect(() => () => registerField(name, undefined, true), [name]);
1046
1045
  useEffect(() => {
1047
- const unsubscribe = subscribeToFieldError(name, errors => {
1048
- setErrors(errors?.[0]);
1049
- });
1050
- return () => {
1051
- unsubscribe?.();
1052
- };
1053
- }, [name]);
1046
+ if (initialValue) {
1047
+ setFieldValue(name, initialValue);
1048
+ }
1049
+ }, []);
1050
+ useEffect(() => {
1051
+ if (name && dependencies.length > 0) {
1052
+ const unsubscribe = subscribeToFields(dependencies, () => {
1053
+ validateFields([name]);
1054
+ });
1055
+ return () => {
1056
+ unsubscribe();
1057
+ };
1058
+ }
1059
+ }, [dependencies, name]);
1054
1060
  const isRequired = useMemo(() => rules.some(rule => rule.required), [rules]);
1061
+ const errorMessage = getFieldError(name)?.[0];
1055
1062
  return /*#__PURE__*/React.createElement("div", {
1056
1063
  style: style,
1057
1064
  "data-instance": name,
@@ -1067,21 +1074,40 @@ const FormItem$1 = /*#__PURE__*/memo(({
1067
1074
  className: `${prefixCls}-required`
1068
1075
  }, "*")), Children.map(childrenList, (child, key) => {
1069
1076
  if (/*#__PURE__*/isValidElement(child)) {
1077
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1078
+ // @ts-expect-error
1079
+ const {
1080
+ onChange,
1081
+ value,
1082
+ ...childProps
1083
+ } = child.props;
1084
+ const fieldValue = value ?? getFieldValue(name) ?? initialValue;
1070
1085
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormItemChildComponent, _extends({}, props, {
1071
- key: `${key}_${name}_${isReseting}`
1086
+ key: `${key}_${isReseting}`
1072
1087
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1073
1088
  // @ts-expect-error
1074
1089
  ,
1075
1090
  ref: fieldRef,
1076
1091
  name: name,
1077
1092
  child: child,
1078
- error: !!errors
1093
+ value: value,
1094
+ error: !!errorMessage,
1095
+ fieldValue: fieldValue,
1096
+ setFieldValue: setFieldValue,
1097
+ feedbackIcons: feedbackIcons,
1098
+ onChange: onChange,
1099
+ noStyle: props.noStyle,
1100
+ normalize: props.normalize
1101
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1102
+ // @ts-expect-error
1103
+ ,
1104
+ size: childProps.size || props.size
1079
1105
  })), extra ? /*#__PURE__*/React.createElement("div", {
1080
1106
  className: `${prefixCls}-extra`
1081
1107
  }, extra || '') : null, !props.noStyle && /*#__PURE__*/React.createElement("span", {
1082
1108
  ref: errorRef,
1083
1109
  className: clsx([`${prefixCls}-error`, {
1084
- [`${prefixCls}-has-error`]: errors?.length
1110
+ [`${prefixCls}-has-error`]: errorMessage?.length
1085
1111
  }]),
1086
1112
  style: {
1087
1113
  ...(removeErrorMessageHeight ? {
@@ -1091,59 +1117,33 @@ const FormItem$1 = /*#__PURE__*/memo(({
1091
1117
  marginBottom: 0
1092
1118
  } : {})
1093
1119
  }
1094
- }, errors || ''));
1120
+ }, errorMessage || ''));
1095
1121
  }
1096
1122
  return child;
1097
1123
  }));
1098
- });
1099
- const FormItemChildComponent = /*#__PURE__*/memo(({
1124
+ };
1125
+ const FormItemChildComponent = ({
1100
1126
  child,
1101
1127
  name,
1102
1128
  error,
1103
- initialValue,
1129
+ fieldValue,
1130
+ setFieldValue,
1131
+ onChange,
1104
1132
  normalize,
1105
1133
  noStyle,
1134
+ feedbackIcons,
1106
1135
  ref,
1107
- dependencies = [],
1108
1136
  ...props
1109
1137
  }) => {
1110
1138
  const formContext = useContext(FormContext);
1111
- const _formFieldValue = useWatch({
1112
- name
1113
- });
1114
1139
  const [wasNormalize, setWasNormalize] = useState(false);
1115
1140
  const {
1116
- getFieldsValue,
1117
- setFieldValue,
1118
- subscribeToFields,
1119
- validateFields
1141
+ getFieldsValue
1120
1142
  } = formContext || {};
1121
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1122
- // @ts-expect-error
1123
- const {
1124
- onChange,
1125
- value
1126
- } = child.props;
1127
- const fieldValue = useMemo(() => value ?? _formFieldValue ?? initialValue, [value, _formFieldValue, initialValue]);
1128
- useEffect(() => {
1129
- if (initialValue) {
1130
- setFieldValue?.(name, initialValue);
1131
- }
1132
- }, [name]);
1133
- useEffect(() => {
1134
- if (name && dependencies.length > 0) {
1135
- const unsubscribe = subscribeToFields?.(dependencies, () => {
1136
- validateFields?.([name]);
1137
- });
1138
- return () => {
1139
- unsubscribe?.();
1140
- };
1141
- }
1142
- }, [dependencies, name]);
1143
1143
  const handleChange = (e, option) => {
1144
1144
  let rawValue = e?.target ? e.target.value : e;
1145
1145
  if (normalize) {
1146
- const prevValue = fieldValue;
1146
+ const prevValue = fieldValue ?? props.value;
1147
1147
  const allValues = getFieldsValue?.();
1148
1148
  rawValue = normalize(rawValue, prevValue, allValues);
1149
1149
  if (rawValue === prevValue) {
@@ -1156,10 +1156,10 @@ const FormItemChildComponent = /*#__PURE__*/memo(({
1156
1156
  return;
1157
1157
  }
1158
1158
  }
1159
- setFieldValue?.(name, rawValue, undefined, undefined, true);
1159
+ setFieldValue(name, rawValue, undefined, undefined, true);
1160
1160
  onChange?.(e, option);
1161
1161
  };
1162
- const injectPropsIntoFinalLeaf = useCallback(child => {
1162
+ const injectPropsIntoFinalLeaf = child => {
1163
1163
  if (! /*#__PURE__*/isValidElement(child)) {
1164
1164
  return child;
1165
1165
  }
@@ -1172,27 +1172,24 @@ const FormItemChildComponent = /*#__PURE__*/memo(({
1172
1172
  return child;
1173
1173
  }
1174
1174
  return /*#__PURE__*/React.createElement(child.type, _extends({}, props, {
1175
- ref: ref,
1176
- name: name
1175
+ ref: ref
1177
1176
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1178
1177
  // @ts-expect-error
1179
1178
  }, child.props, {
1180
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1181
- // @ts-expect-error
1182
- size: childProps.size || props.size,
1179
+ name: name,
1183
1180
  child: child,
1184
- value: fieldValue,
1185
1181
  onChange: handleChange,
1186
- key: `${name}_${wasNormalize}`
1182
+ key: `${name}_${wasNormalize}`,
1183
+ value: fieldValue ?? props.value
1187
1184
  }, 'dangerouslySetInnerHTML' in childProps ? {} : {
1188
1185
  __injected: true,
1189
1186
  ...(error ? {
1190
1187
  error
1191
1188
  } : {})
1192
1189
  }));
1193
- }, [name, fieldValue, wasNormalize, error, handleChange, props, ref]);
1190
+ };
1194
1191
  return injectPropsIntoFinalLeaf(child);
1195
- });
1192
+ };
1196
1193
  FormItem$1.displayName = 'FormItem';
1197
1194
 
1198
1195
  var Item = /*#__PURE__*/Object.freeze({
@@ -1224,7 +1221,7 @@ const Form$1 = ({
1224
1221
  });
1225
1222
  const formRef = useRef(null);
1226
1223
  const formInstance = useMemo(() => form || internalForm, [form, internalForm]);
1227
- const handleSubmit = useCallback(async e => {
1224
+ const handleSubmit = async e => {
1228
1225
  e.preventDefault();
1229
1226
  if (await formInstance.validateFields()) {
1230
1227
  onFinish?.(formInstance.getFieldsValue());
@@ -1235,9 +1232,8 @@ const Form$1 = ({
1235
1232
  errorFields
1236
1233
  });
1237
1234
  }
1238
- }, [formInstance, onFinish, onFinishFailed]);
1235
+ };
1239
1236
  const childrenList = useMemo(() => flattenChildren(children), [children]);
1240
- const formClassName = useMemo(() => `${prefixCls} ${className}`.trim(), [prefixCls, className]);
1241
1237
  useEffect(() => {
1242
1238
  if (onFinish) {
1243
1239
  formInstance.setOnFinish?.(onFinish);
@@ -1255,7 +1251,7 @@ const Form$1 = ({
1255
1251
  formInstance.setScrollToFirstError(scrollToFirstError);
1256
1252
  }
1257
1253
  }, [formInstance, onFieldsChange, onValuesChange, onFinishFailed, onFinish, scrollToFirstError]);
1258
- const injectPropsIntoFinalLeaf = useCallback(child => {
1254
+ const injectPropsIntoFinalLeaf = child => {
1259
1255
  if (! /*#__PURE__*/isValidElement(child)) {
1260
1256
  return child;
1261
1257
  }
@@ -1272,24 +1268,22 @@ const Form$1 = ({
1272
1268
  size: childProps.size || rest.size,
1273
1269
  layout: childProps.layout || layout
1274
1270
  }));
1275
- }, [rest.size, layout]);
1276
- const injectedChildren = useMemo(() => Children.map(childrenList, child => injectPropsIntoFinalLeaf(child)), [childrenList, injectPropsIntoFinalLeaf]);
1271
+ };
1277
1272
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
1278
1273
  value: formInstance
1279
1274
  }, /*#__PURE__*/React.createElement("form", {
1280
1275
  style: style,
1281
1276
  ref: formRef,
1282
1277
  onSubmit: handleSubmit,
1283
- className: formClassName
1284
- }, injectedChildren));
1278
+ className: `${prefixCls} ${className}`
1279
+ }, Children.map(childrenList, child => injectPropsIntoFinalLeaf(child))));
1285
1280
  };
1286
- Form$1.Item = /*#__PURE__*/memo(FormItem$1);
1287
- var Form$2 = /*#__PURE__*/memo(Form$1);
1281
+ Form$1.Item = FormItem$1;
1288
1282
 
1289
- var Form$3 = /*#__PURE__*/Object.freeze({
1283
+ var Form$2 = /*#__PURE__*/Object.freeze({
1290
1284
  __proto__: null,
1291
1285
  FormContext: FormContext,
1292
- default: Form$2
1286
+ default: Form$1
1293
1287
  });
1294
1288
 
1295
1289
  const useWatch = ({
@@ -1341,7 +1335,7 @@ const RangePicker$2 = dynamic$1(() => Promise.resolve().then(function () { retur
1341
1335
  const TimePicker$2 = dynamic$1(() => Promise.resolve().then(function () { return TimePicker$1; }), {
1342
1336
  ssr: false
1343
1337
  });
1344
- const Form = dynamic$1(() => Promise.resolve().then(function () { return Form$3; }), {
1338
+ const Form = dynamic$1(() => Promise.resolve().then(function () { return Form$2; }), {
1345
1339
  ssr: false
1346
1340
  });
1347
1341
  const FormItem = dynamic$1(() => Promise.resolve().then(function () { return Item; }), {
@@ -3071,8 +3065,8 @@ const InputComponent = ({
3071
3065
  }, prefix && /*#__PURE__*/React.createElement("span", {
3072
3066
  className: `${prefixCls}-prefix`
3073
3067
  }, prefix), /*#__PURE__*/React.createElement("input", _extends({}, props, {
3074
- suppressHydrationWarning: true,
3075
- ref: inputRef
3068
+ ref: inputRef,
3069
+ suppressHydrationWarning: true
3076
3070
  }, props.type === 'password' && iconRender ? {
3077
3071
  type: iconRenderVisible ? 'text' : 'password'
3078
3072
  } : {}, {
@@ -3613,7 +3607,7 @@ const SelectComponent = ({
3613
3607
  setSelected(optionValue);
3614
3608
  onChange?.(optionValue, option);
3615
3609
  onSelect?.(optionValue, option);
3616
- onDropdownVisibleChange?.(defaultOpen, optionValue);
3610
+ onDropdownVisibleChange?.(defaultOpen, option);
3617
3611
  }
3618
3612
  handleClearInputValue();
3619
3613
  };
@@ -3669,7 +3663,11 @@ const SelectComponent = ({
3669
3663
  isOpen: isOpen
3670
3664
  }));
3671
3665
  }, [showArrow, showSearch, isOpen, suffixIcon, searchIcon]);
3672
- const extractOptions = useCallback((children, options) => {
3666
+ const extractedOptions = children ? extractOptions(children) : Array.isArray(options) ? options : [];
3667
+ const triggerNode = useMemo(() => {
3668
+ return selectRef.current?.querySelector(`.${prefixCls}-trigger`);
3669
+ }, [prefixCls]);
3670
+ function extractOptions(children, options) {
3673
3671
  const result = [];
3674
3672
  const flatten = nodes => {
3675
3673
  try {
@@ -3693,11 +3691,7 @@ const SelectComponent = ({
3693
3691
  return result;
3694
3692
  }
3695
3693
  return options || [];
3696
- }, []);
3697
- const extractedOptions = children ? extractOptions(children) : Array.isArray(options) ? options : [];
3698
- const triggerNode = useMemo(() => {
3699
- return selectRef.current?.querySelector(`.${prefixCls}-trigger`);
3700
- }, [prefixCls]);
3694
+ }
3701
3695
  const filteredOptions = extractedOptions.filter(option => {
3702
3696
  if (typeof filterOption === 'function') {
3703
3697
  return filterOption(searchQuery, option);