@m4l/components 9.82.0 → 9.82.1-beta-hotfix-790-m4l-components-dynamic-form-validation.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.
Files changed (26) hide show
  1. package/components/DynamicForm/DynamicForm.d.ts.map +1 -1
  2. package/components/DynamicForm/DynamicForm.js +69 -69
  3. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/buildDynamicFormBatchPayload.d.ts +11 -0
  4. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/buildDynamicFormBatchPayload.d.ts.map +1 -0
  5. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/buildDynamicFormBatchPayload.js +64 -0
  6. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/constants.d.ts +3 -0
  7. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/constants.d.ts.map +1 -0
  8. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/constants.js +10 -0
  9. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/index.d.ts +3 -0
  10. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/index.d.ts.map +1 -0
  11. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/types.d.ts +13 -0
  12. package/components/DynamicForm/helpers/buildDynamicFormBatchPayload/types.d.ts.map +1 -0
  13. package/components/DynamicForm/helpers/createFieldValidationSchema/createFieldValidationSchema.d.ts.map +1 -1
  14. package/components/DynamicForm/helpers/createFieldValidationSchema/createFieldValidationSchema.js +68 -49
  15. package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/validationStrategies.d.ts.map +1 -1
  16. package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/validationStrategies.js +103 -101
  17. package/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.d.ts.map +1 -1
  18. package/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.js +52 -48
  19. package/components/DynamicForm/hooks/useDynamicFormData/types.d.ts +3 -2
  20. package/components/DynamicForm/hooks/useDynamicFormData/types.d.ts.map +1 -1
  21. package/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.d.ts +2 -2
  22. package/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.d.ts.map +1 -1
  23. package/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.js +106 -82
  24. package/components/DynamicForm/types.d.ts +8 -6
  25. package/components/DynamicForm/types.d.ts.map +1 -1
  26. package/package.json +7 -7
@@ -1,142 +1,150 @@
1
1
  import * as u from "yup";
2
- import { DYNAMIC_FORM_DICTIONARY as d } from "../../../../dictionary.js";
3
- import { resolveValidationErrorMessage as m } from "../../../resolveValidationErrorMessage/resolveValidationErrorMessage.js";
4
- import { resolveFieldMandatory as T, resolveFieldHelperMessage as _ } from "../../../resolveFieldContractAliases/resolveFieldContractAliases.js";
5
- import { isDynamicFormDateRangeField as A } from "../../../isDateRangeField/isDateRangeField.js";
6
- import { applyRequiredValidation as M } from "../../../applyRequiredValidation/applyRequiredValidation.js";
7
- const v = {
2
+ import { DYNAMIC_FORM_DICTIONARY as c } from "../../../../dictionary.js";
3
+ import { resolveValidationErrorMessage as d } from "../../../resolveValidationErrorMessage/resolveValidationErrorMessage.js";
4
+ import { resolveFieldMandatory as A, resolveFieldHelperMessage as M } from "../../../resolveFieldContractAliases/resolveFieldContractAliases.js";
5
+ import { isDynamicFormDateRangeField as b } from "../../../isDateRangeField/isDateRangeField.js";
6
+ import { applyRequiredValidation as L } from "../../../applyRequiredValidation/applyRequiredValidation.js";
7
+ function p(o) {
8
+ const a = Number(o);
9
+ return Number.isFinite(a) ? a : void 0;
10
+ }
11
+ function _(o) {
12
+ const a = p(o);
13
+ return a !== void 0 && Number.isInteger(a) && a >= 0 ? a : void 0;
14
+ }
15
+ const S = {
8
16
  validationTypeId: "fvl_required",
9
17
  /**
10
18
  * Applies required validation when the field is required; otherwise returns the schema unchanged.
11
19
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
12
20
  * @returns Schema with required validation applied, or unchanged schema
13
21
  */
14
- apply(r) {
15
- const { field: a, getLabel: e, baseSchema: o, schema: t, validation: s } = r;
16
- if (!T(a))
22
+ apply(o) {
23
+ const { field: a, getLabel: e, baseSchema: s, schema: t, validation: r } = o;
24
+ if (!A(a))
17
25
  return t;
18
- const n = A(a), l = _(a), c = n && l ? l : e(n ? d.DATE_RANGE_REQUIRED_MESSAGE : d.IS_REQUIRED_MESSAGE), p = m(s, e, c);
19
- return M(a, t, o, p);
26
+ const n = b(a), l = M(a), m = n && l ? l : e(n ? c.DATE_RANGE_REQUIRED_MESSAGE : c.IS_REQUIRED_MESSAGE), v = d(r, e, m);
27
+ return L(a, t, s, v);
20
28
  }
21
- }, S = {
29
+ }, g = {
22
30
  validationTypeId: "fvl_max_length",
23
31
  /**
24
32
  * Applies max length constraint to string schema when validation value is present.
25
33
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
26
34
  * @returns Schema with `.max(length)` applied, or unchanged schema if not applicable
27
35
  */
28
- apply(r) {
29
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r, s = a.validationType, i = a.validationValue;
30
- if (!s?.requiresValue || !i || !(o instanceof u.StringSchema))
36
+ apply(o) {
37
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o, r = a.validationType, i = a.validationValue;
38
+ if (!r?.requiresValue || !i || !(s instanceof u.StringSchema))
31
39
  return t;
32
- const n = parseInt(i, 10);
33
- if (isNaN(n))
40
+ const n = _(i);
41
+ if (n === void 0)
34
42
  return t;
35
- const l = m(
43
+ const l = d(
36
44
  a,
37
45
  e,
38
- e(d.MAX_LENGTH_MESSAGE, n)
46
+ e(c.MAX_LENGTH_MESSAGE, n)
39
47
  );
40
48
  return t.max(n, l);
41
49
  }
42
- }, g = {
50
+ }, y = {
43
51
  validationTypeId: "fvl_min_length",
44
52
  /**
45
53
  * Applies min length constraint to string schema when validation value is present.
46
54
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
47
55
  * @returns Schema with `.min(length)` applied, or unchanged schema if not applicable
48
56
  */
49
- apply(r) {
50
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r, s = a.validationType, i = a.validationValue;
51
- if (!s?.requiresValue || !i || !(o instanceof u.StringSchema))
57
+ apply(o) {
58
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o, r = a.validationType, i = a.validationValue;
59
+ if (!r?.requiresValue || !i || !(s instanceof u.StringSchema))
52
60
  return t;
53
- const n = parseInt(i, 10);
54
- if (isNaN(n))
61
+ const n = _(i);
62
+ if (n === void 0)
55
63
  return t;
56
- const l = m(
64
+ const l = d(
57
65
  a,
58
66
  e,
59
- e(d.MIN_LENGTH_MESSAGE, n)
67
+ e(c.MIN_LENGTH_MESSAGE, n)
60
68
  );
61
69
  return t.min(n, l);
62
70
  }
63
- }, y = {
71
+ }, f = {
64
72
  validationTypeId: "fvl_max",
65
73
  /**
66
74
  * Applies maximum numeric value constraint when validation value is present.
67
75
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
68
76
  * @returns Schema with `.max(value)` applied, or unchanged schema if not applicable
69
77
  */
70
- apply(r) {
71
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r, s = a.validationType, i = a.validationValue;
72
- if (!s?.requiresValue || !i || !(o instanceof u.NumberSchema))
78
+ apply(o) {
79
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o, r = a.validationType, i = a.validationValue;
80
+ if (!r?.requiresValue || !i || !(s instanceof u.NumberSchema))
73
81
  return t;
74
- const n = parseFloat(i);
75
- if (isNaN(n))
82
+ const n = p(i);
83
+ if (n === void 0)
76
84
  return t;
77
- const l = m(
85
+ const l = d(
78
86
  a,
79
87
  e,
80
- e(d.MAX_VALUE_MESSAGE, n)
88
+ e(c.MAX_VALUE_MESSAGE, n)
81
89
  );
82
90
  return t.max(n, l);
83
91
  }
84
- }, f = {
92
+ }, I = {
85
93
  validationTypeId: "fvl_min",
86
94
  /**
87
95
  * Applies minimum numeric value constraint when validation value is present.
88
96
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
89
97
  * @returns Schema with `.min(value)` applied, or unchanged schema if not applicable
90
98
  */
91
- apply(r) {
92
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r, s = a.validationType, i = a.validationValue;
93
- if (!s?.requiresValue || !i || !(o instanceof u.NumberSchema))
99
+ apply(o) {
100
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o, r = a.validationType, i = a.validationValue;
101
+ if (!r?.requiresValue || !i || !(s instanceof u.NumberSchema))
94
102
  return t;
95
- const n = parseFloat(i);
96
- if (isNaN(n))
103
+ const n = p(i);
104
+ if (n === void 0)
97
105
  return t;
98
- const l = m(
106
+ const l = d(
99
107
  a,
100
108
  e,
101
- e(d.MIN_VALUE_MESSAGE, n)
109
+ e(c.MIN_VALUE_MESSAGE, n)
102
110
  );
103
111
  return t.min(n, l);
104
112
  }
105
- }, I = {
113
+ }, V = {
106
114
  validationTypeId: "fvl_email",
107
115
  /**
108
116
  * Applies email format validation to string schema.
109
117
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
110
118
  * @returns Schema with `.email()` applied, or unchanged schema if base is not string
111
119
  */
112
- apply(r) {
113
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r;
114
- if (!(o instanceof u.StringSchema))
120
+ apply(o) {
121
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o;
122
+ if (!(s instanceof u.StringSchema))
115
123
  return t;
116
- const s = m(
124
+ const r = d(
117
125
  a,
118
126
  e,
119
- e(d.EMAIL_INVALID_MESSAGE)
127
+ e(c.EMAIL_INVALID_MESSAGE)
120
128
  );
121
- return t.email(s);
129
+ return t.email(r).required(r);
122
130
  }
123
- }, V = {
131
+ }, h = {
124
132
  validationTypeId: "fvl_url",
125
133
  /**
126
134
  * Applies URL format validation to string schema.
127
135
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
128
136
  * @returns Schema with `.url()` applied, or unchanged schema if base is not string
129
137
  */
130
- apply(r) {
131
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r;
132
- if (!(o instanceof u.StringSchema))
138
+ apply(o) {
139
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o;
140
+ if (!(s instanceof u.StringSchema))
133
141
  return t;
134
- const s = m(
142
+ const r = d(
135
143
  a,
136
144
  e,
137
- e(d.URL_INVALID_MESSAGE)
145
+ e(c.URL_INVALID_MESSAGE)
138
146
  );
139
- return t.url(s);
147
+ return t.url(r).required(r);
140
148
  }
141
149
  }, E = {
142
150
  validationTypeId: "fvl_pattern",
@@ -146,94 +154,88 @@ const v = {
146
154
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
147
155
  * @returns Schema with `.matches(regex)` applied, or unchanged schema if not applicable
148
156
  */
149
- apply(r) {
150
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r, s = a.validationType, i = a.validationValue;
151
- if (!s?.requiresValue || !i || !(o instanceof u.StringSchema))
157
+ apply(o) {
158
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o, r = a.validationType, i = a.validationValue;
159
+ if (!r?.requiresValue || !i || !(s instanceof u.StringSchema))
152
160
  return t;
153
161
  try {
154
- const n = new RegExp(i), l = m(
162
+ const n = new RegExp(i), l = d(
155
163
  a,
156
164
  e,
157
- e(d.PATTERN_INVALID_MESSAGE)
165
+ e(c.PATTERN_INVALID_MESSAGE)
158
166
  );
159
167
  return t.matches(n, l);
160
168
  } catch (n) {
161
169
  return console.warn(`Invalid regex pattern: ${i}`, n), t;
162
170
  }
163
171
  }
164
- }, h = {
172
+ }, T = {
165
173
  validationTypeId: "fvl_custom",
166
174
  /**
167
175
  * Applies custom validation: for string, regex or exact match; for number, exact value match.
168
- * When no value is configured, string schema accepts any non-empty value.
176
+ * When no value is configured, the rule is skipped because it has no enforceable constraint.
169
177
  * @param ctx - Context with field, getLabel, baseSchema, schema, and validation
170
178
  * @returns Schema with custom `.test()` applied, or unchanged schema if base type not supported
171
179
  */
172
- apply(r) {
173
- const { validation: a, getLabel: e, baseSchema: o, schema: t } = r, s = a.validationType, i = a.validationValue, n = s?.requiresValue && i;
174
- if (o instanceof u.StringSchema) {
175
- const l = m(
180
+ apply(o) {
181
+ const { validation: a, getLabel: e, baseSchema: s, schema: t } = o, r = a.validationType, i = a.validationValue, n = r?.requiresValue === !0 && typeof i == "string" && i.trim() !== "";
182
+ if (s instanceof u.StringSchema) {
183
+ const l = d(
176
184
  a,
177
185
  e,
178
- e(d.CUSTOM_VALIDATION_MESSAGE)
186
+ e(c.CUSTOM_VALIDATION_MESSAGE)
179
187
  );
180
188
  return n ? t.test(
181
189
  "custom",
182
190
  l,
183
- (c) => {
184
- if (!c)
185
- return !0;
191
+ (m) => {
192
+ if (m == null)
193
+ return !1;
186
194
  try {
187
- return new RegExp(i).test(c);
195
+ return new RegExp(i).test(m);
188
196
  } catch {
189
- return c === i;
197
+ return m === i;
190
198
  }
191
199
  }
192
- ) : t.test(
193
- "custom",
194
- l,
195
- (c) => !c || !0
196
- );
200
+ ) : t;
197
201
  }
198
- if (o instanceof u.NumberSchema && n) {
199
- const l = m(
202
+ if (s instanceof u.NumberSchema && n) {
203
+ const l = p(i);
204
+ if (l === void 0)
205
+ return t;
206
+ const m = d(
200
207
  a,
201
208
  e,
202
- e(d.CUSTOM_VALIDATION_MESSAGE)
209
+ e(c.CUSTOM_VALIDATION_MESSAGE)
203
210
  );
204
211
  return t.test(
205
212
  "custom",
206
- l,
207
- (c) => {
208
- if (c == null)
209
- return !0;
210
- const p = parseFloat(i);
211
- return isNaN(p) ? !0 : c === p;
212
- }
213
+ m,
214
+ (v) => v == null ? !1 : v === l
213
215
  );
214
216
  }
215
217
  return t;
216
218
  }
217
- }, x = {
218
- [v.validationTypeId]: v,
219
+ }, q = {
219
220
  [S.validationTypeId]: S,
220
221
  [g.validationTypeId]: g,
221
222
  [y.validationTypeId]: y,
222
223
  [f.validationTypeId]: f,
223
224
  [I.validationTypeId]: I,
224
225
  [V.validationTypeId]: V,
226
+ [h.validationTypeId]: h,
225
227
  [E.validationTypeId]: E,
226
- [h.validationTypeId]: h
228
+ [T.validationTypeId]: T
227
229
  };
228
230
  export {
229
- x as VALIDATION_STRATEGY_REGISTRY,
230
- h as customValidationStrategy,
231
- I as emailValidationStrategy,
232
- S as maxLengthValidationStrategy,
233
- y as maxValidationStrategy,
234
- g as minLengthValidationStrategy,
235
- f as minValidationStrategy,
231
+ q as VALIDATION_STRATEGY_REGISTRY,
232
+ T as customValidationStrategy,
233
+ V as emailValidationStrategy,
234
+ g as maxLengthValidationStrategy,
235
+ f as maxValidationStrategy,
236
+ y as minLengthValidationStrategy,
237
+ I as minValidationStrategy,
236
238
  E as patternValidationStrategy,
237
- v as requiredValidationStrategy,
238
- V as urlValidationStrategy
239
+ S as requiredValidationStrategy,
240
+ h as urlValidationStrategy
239
241
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDynamicForm.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAqB,MAAM,aAAa,CAAC;AA0BxE;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,sBAAsB;;;EA+H1D"}
1
+ {"version":3,"file":"useDynamicForm.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAqB,MAAM,aAAa,CAAC;AA+BxE;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,sBAAsB;;;EA8H1D"}
@@ -1,69 +1,73 @@
1
- import { useMemo as c } from "react";
2
- import { EMPTY_DATA as F } from "../../constants.js";
3
- import { createValidationPartialObject as R, createValidationSchema as E, createValidationFullObject as I } from "../../../hook-form/RHFormProvider/schema.js";
4
- import { useUserPreferences as M, useModuleDictionary as P } from "@m4l/core";
5
- import { normalizeDynamicFormFields as j, resolveFormSections as O, isSectionField as y } from "../../helpers/resolveFormSections/resolveFormSections.js";
6
- import { isSupportedInformationalField as g, isSupportedDynamicFormField as Z } from "../../helpers/fieldContractAllowlist/fieldContractAllowlist.js";
7
- import { resolveInitialValue as x } from "../../helpers/resolveInitialValue/resolveInitialValue.js";
8
- import { createFieldValidationSchema as z } from "../../helpers/createFieldValidationSchema/createFieldValidationSchema.js";
9
- import { evaluateConditionalRule as S } from "../../helpers/evaluateConditionalRule/evaluateConditionalRule.js";
10
- function b(s, a) {
1
+ import { useMemo as r } from "react";
2
+ import * as A from "yup";
3
+ import { EMPTY_DATA as S } from "../../constants.js";
4
+ import { createValidationPartialObject as E, createValidationSchema as I, createValidationFullObject as M } from "../../../hook-form/RHFormProvider/schema.js";
5
+ import { useUserPreferences as P, useModuleDictionary as j } from "@m4l/core";
6
+ import { normalizeDynamicFormFields as x, resolveFormSections as O, isSectionField as V } from "../../helpers/resolveFormSections/resolveFormSections.js";
7
+ import { isSupportedInformationalField as b, isSupportedDynamicFormField as Y } from "../../helpers/fieldContractAllowlist/fieldContractAllowlist.js";
8
+ import { resolveInitialValue as Z } from "../../helpers/resolveInitialValue/resolveInitialValue.js";
9
+ import { createFieldValidationSchema as q } from "../../helpers/createFieldValidationSchema/createFieldValidationSchema.js";
10
+ import { evaluateConditionalRule as g } from "../../helpers/evaluateConditionalRule/evaluateConditionalRule.js";
11
+ function y(s, a) {
11
12
  return s.some(
12
- (e) => e.actionType === "show" && S(e, a[e.sourceFieldName]) || e.actionType === "hide" && !S(e, a[e.sourceFieldName])
13
+ (i) => i.actionType === "show" && g(i, a[i.sourceFieldName]) || i.actionType === "hide" && !g(i, a[i.sourceFieldName])
13
14
  );
14
15
  }
15
- function J(s) {
16
- const a = M().timeZone ?? null, e = c(
17
- () => j(s.fields ?? F.fields).fields,
16
+ function f() {
17
+ return A.mixed().nullable().notRequired();
18
+ }
19
+ function K(s) {
20
+ const a = P().timeZone ?? null, i = r(
21
+ () => x(s.fields ?? S.fields).fields,
18
22
  [s.fields]
19
- ), m = s.conditionalRules ?? F.conditionalRules, { ownerByFieldId: d } = c(() => O(e), [e]), { getLabel: h } = P(), V = c(() => {
20
- const t = {};
21
- return e.forEach((i) => {
22
- i.isVisible !== !1 && !y(i) && !g(i) && typeof i.name == "string" && i.name.trim() !== "" && (t[i.name] = x(i, { timeZone: a }));
23
- }), t;
24
- }, [e, a]), v = c(() => {
25
- const t = R({});
26
- return e.forEach((i) => {
27
- if (typeof i.name != "string" || i.name.trim() === "" || y(i) || !Z(i) || g(i))
23
+ ), c = s.conditionalRules ?? S.conditionalRules, { ownerByFieldId: h } = r(() => O(i), [i]), { getLabel: F } = j(), v = r(() => {
24
+ const o = {};
25
+ return i.forEach((e) => {
26
+ e.isVisible !== !1 && !V(e) && !b(e) && typeof e.name == "string" && e.name.trim() !== "" && (o[e.name] = Z(e, { timeZone: a }));
27
+ }), o;
28
+ }, [i, a]), C = r(() => {
29
+ const o = E({});
30
+ return i.forEach((e) => {
31
+ if (typeof e.name != "string" || e.name.trim() === "" || V(e) || !Y(e) || b(e))
28
32
  return;
29
- const r = z(i, h);
30
- if (!r)
33
+ const m = q(e, F);
34
+ if (!m)
31
35
  return;
32
- const n = d.get(i.id), l = n?.isConditional && typeof n.name == "string" ? m.filter((o) => o.isActive && o.targetFieldName === n.name) : [];
33
- if (!i.isConditional && !n?.isConditional) {
34
- const o = i.isVisible !== !1 && n?.isVisible !== !1;
35
- t[i.name] = o ? r : r.optional();
36
+ const n = h.get(e.id), l = n?.isConditional && typeof n.name == "string" ? c.filter((t) => t.isActive && t.targetFieldName === n.name) : [];
37
+ if (!e.isConditional && !n?.isConditional) {
38
+ const t = e.isVisible !== !1 && n?.isVisible !== !1;
39
+ o[e.name] = t ? m : f();
36
40
  return;
37
41
  }
38
- const u = i.isConditional ? m.filter((o) => o.isActive && o.targetFieldName === i.name) : [], p = [...new Set([...u, ...l].map((o) => o.sourceFieldName))];
39
- if (i.isConditional && u.length === 0 || n?.isConditional && l.length === 0 || p.length === 0) {
40
- t[i.name] = r.optional();
42
+ const u = e.isConditional ? c.filter((t) => t.isActive && t.targetFieldName === e.name) : [], d = [...new Set([...u, ...l].map((t) => t.sourceFieldName))];
43
+ if (e.isConditional && u.length === 0 || n?.isConditional && l.length === 0 || d.length === 0) {
44
+ o[e.name] = f();
41
45
  return;
42
46
  }
43
- const C = r.when(
44
- p,
47
+ const w = m.when(
48
+ d,
45
49
  {
46
50
  /** Returns true when the field is visible (any show rule met or any hide rule not met). */
47
- is: (o) => {
48
- const A = Array.isArray(o) ? o : [o], f = {};
49
- p.forEach((w, D) => {
50
- f[w] = A[D];
51
+ is: (...t) => {
52
+ const p = {};
53
+ d.forEach((T, D) => {
54
+ p[T] = t[D];
51
55
  });
52
- const N = i.isConditional ? b(u, f) : i.isVisible !== !1, T = n?.isConditional ? b(l, f) : n?.isVisible !== !1;
53
- return N && T;
56
+ const N = e.isConditional ? y(u, p) : e.isVisible !== !1, R = n?.isConditional ? y(l, p) : n?.isVisible !== !1;
57
+ return N && R;
54
58
  },
55
- then: (o) => o,
56
- otherwise: (o) => o.optional()
59
+ then: (t) => t,
60
+ otherwise: () => f()
57
61
  }
58
62
  );
59
- t[i.name] = C;
60
- }), E(I(t));
61
- }, [e, m, h, d]);
63
+ o[e.name] = w;
64
+ }), I(M(o));
65
+ }, [i, c, F, h]);
62
66
  return {
63
- initialValues: V,
64
- validationSchema: v
67
+ initialValues: v,
68
+ validationSchema: C
65
69
  };
66
70
  }
67
71
  export {
68
- J as useDynamicForm
72
+ K as useDynamicForm
69
73
  };
@@ -14,8 +14,9 @@ export interface UseDynamicFormDataProps {
14
14
  outputEndpoint?: string;
15
15
  /**
16
16
  * Submit strategy: `'form'` (default) sends a single request to `outputEndpoint`;
17
- * `'perField'` sends one POST per field to `forms/instances/{instanceId}/fields/{fieldId}/values`
18
- * concurrently via `Promise.all`.
17
+ * `'batch'` sends one atomic PATCH to `forms/instances/{instanceId}/values`; and
18
+ * `'perField'` sends one PATCH per field to `forms/instances/{instanceId}/fields/{fieldId}/values`
19
+ * concurrently via `Promise.all` for legacy consumers.
19
20
  */
20
21
  submitMode?: DynamicFormSubmitMode;
21
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useDynamicFormData/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC;IACtG,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9E,uEAAuE;IACvE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,0FAA0F;IAC1F,WAAW,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACxC,oEAAoE;IACpE,UAAU,EAAE,cAAc,CAAC;IAC3B,8EAA8E;IAC9E,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useDynamicFormData/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC;IACtG,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9E,uEAAuE;IACvE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,0FAA0F;IAC1F,WAAW,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACxC,oEAAoE;IACpE,UAAU,EAAE,cAAc,CAAC;IAC3B,8EAA8E;IAC9E,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB"}
@@ -6,8 +6,8 @@ import { UseDynamicFormDataProps, UseDynamicFormDataReturn } from './types';
6
6
  * - Fetch data from inputEndpoint via networkOperation
7
7
  * - Apply formatInputData when provided
8
8
  * - Manage loading state
9
- * - Send data to outputEndpoint on submit (submitMode 'form'), or one request per field
10
- * to `forms/instances/{instanceId}/fields/{fieldId}/values` via Promise.all (submitMode 'perField')
9
+ * - Send data to outputEndpoint on submit (submitMode 'form'), one atomic form-instance PATCH
10
+ * (submitMode 'batch'), or one request per field via Promise.all (submitMode 'perField')
11
11
  * - Apply formatOutputData before sending
12
12
  * - Serialize objects/arrays to JSON only when the target backend body key expects string payloads
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useDynamicFormData.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAgB5E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,uBAAuB,GAC7B,wBAAwB,CAiM1B"}
1
+ {"version":3,"file":"useDynamicFormData.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAgB5E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,uBAAuB,GAC7B,wBAAwB,CAsO1B"}