datastake-daf 0.6.590 → 0.6.592

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.
@@ -40535,7 +40535,6 @@ function AuthForm(_ref) {
40535
40535
  const next = async () => {
40536
40536
  try {
40537
40537
  await formInstance.validateFields(currentFields.map(f => f.name));
40538
- // Save current step values before moving to next step
40539
40538
  const currentValues = formInstance.getFieldsValue();
40540
40539
  setAllFormValues(prev => _objectSpread2(_objectSpread2({}, prev), currentValues));
40541
40540
  setCurrentStep(prev => prev + 1);
@@ -40563,10 +40562,21 @@ function AuthForm(_ref) {
40563
40562
  };
40564
40563
  const checkRequiredFieldsFilled = (changedValues, allValues) => {
40565
40564
  const requiredFields = currentFields.filter(f => f.required).map(f => f.name);
40566
- return requiredFields.every(fieldName => {
40565
+ const allFilled = requiredFields.every(fieldName => {
40567
40566
  const value = allValues[fieldName];
40567
+ if (typeof value === 'boolean') {
40568
+ return value === true;
40569
+ }
40568
40570
  return value !== undefined && value !== null && value !== '';
40569
40571
  });
40572
+ const fieldErrors = formInstance.getFieldsError(requiredFields);
40573
+ const hasErrors = fieldErrors.some(_ref2 => {
40574
+ let {
40575
+ errors
40576
+ } = _ref2;
40577
+ return errors.length > 0;
40578
+ });
40579
+ return allFilled && !hasErrors;
40570
40580
  };
40571
40581
  React.useEffect(() => {
40572
40582
  setFormErrors(errors);
@@ -40630,15 +40640,23 @@ function AuthForm(_ref) {
40630
40640
  style: {
40631
40641
  marginBottom: 0
40632
40642
  },
40643
+ valuePropName: field.valuePropName,
40633
40644
  children: inputNode
40634
40645
  }, field.name);
40635
40646
  };
40647
+ const handleValuesChange = changedValues => {
40648
+ const changedFieldNames = Object.keys(changedValues);
40649
+ changedFieldNames.forEach(fieldName => {
40650
+ formInstance.validateFields([fieldName]).catch(() => {});
40651
+ });
40652
+ };
40636
40653
  return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
40637
40654
  children: /*#__PURE__*/jsxRuntime.jsxs(antd.Form, {
40638
40655
  form: formInstance,
40639
40656
  layout: "vertical",
40640
40657
  initialValues: initialValues,
40641
40658
  onFinish: handleSubmit,
40659
+ onValuesChange: handleValuesChange,
40642
40660
  children: [currentFields.map(renderField), formErrors ? renderErrors(formErrors, t) : null, isMultiStep && currentStep > 0 ? /*#__PURE__*/jsxRuntime.jsxs("div", {
40643
40661
  className: "flex flex-column gap-2",
40644
40662
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.590",
3
+ "version": "0.6.592",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -44,7 +44,6 @@ function AuthForm ({
44
44
  await formInstance.validateFields(
45
45
  currentFields.map((f) => f.name)
46
46
  );
47
- // Save current step values before moving to next step
48
47
  const currentValues = formInstance.getFieldsValue();
49
48
  setAllFormValues((prev) => ({ ...prev, ...currentValues }));
50
49
  setCurrentStep((prev) => prev + 1);
@@ -80,10 +79,19 @@ function AuthForm ({
80
79
 
81
80
  const checkRequiredFieldsFilled = (changedValues, allValues) => {
82
81
  const requiredFields = currentFields.filter(f => f.required).map(f => f.name);
83
- return requiredFields.every(fieldName => {
82
+
83
+ const allFilled = requiredFields.every(fieldName => {
84
84
  const value = allValues[fieldName];
85
+ if (typeof value === 'boolean') {
86
+ return value === true;
87
+ }
85
88
  return value !== undefined && value !== null && value !== '';
86
89
  });
90
+
91
+ const fieldErrors = formInstance.getFieldsError(requiredFields);
92
+ const hasErrors = fieldErrors.some(({ errors }) => errors.length > 0);
93
+
94
+ return allFilled && !hasErrors;
87
95
  };
88
96
 
89
97
  useEffect(() => {
@@ -138,12 +146,27 @@ function AuthForm ({
138
146
  }
139
147
 
140
148
  return (
141
- <Form.Item key={field.name} name={field.name} label={field.label} rules={field.rules} style={{ marginBottom: 0 }}>
149
+ <Form.Item
150
+ key={field.name}
151
+ name={field.name}
152
+ label={field.label}
153
+ rules={field.rules}
154
+ style={{ marginBottom: 0 }}
155
+ valuePropName={field.valuePropName}
156
+ >
142
157
  {inputNode}
143
158
  </Form.Item>
144
159
  );
145
160
  };
146
161
 
162
+ const handleValuesChange = (changedValues) => {
163
+ const changedFieldNames = Object.keys(changedValues);
164
+ changedFieldNames.forEach(fieldName => {
165
+ formInstance.validateFields([fieldName]).catch(() => {
166
+ });
167
+ });
168
+ };
169
+
147
170
  return (
148
171
  <>
149
172
  <Form
@@ -151,6 +174,7 @@ function AuthForm ({
151
174
  layout="vertical"
152
175
  initialValues={initialValues}
153
176
  onFinish={handleSubmit}
177
+ onValuesChange={handleValuesChange}
154
178
  >
155
179
  {currentFields.map(renderField)}
156
180