@m4l/components 9.79.0 → 9.79.1-beta-improvement-789-m4l-components-dynamic-form-adjustments.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 (61) hide show
  1. package/components/DynamicForm/dictionary.d.ts +1 -0
  2. package/components/DynamicForm/dictionary.d.ts.map +1 -1
  3. package/components/DynamicForm/dictionary.js +9 -5
  4. package/components/DynamicForm/helpers/fieldContractAllowlist/fieldContractAllowlist.d.ts +1 -1
  5. package/components/DynamicForm/helpers/fieldContractAllowlist/fieldContractAllowlist.js +1 -1
  6. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/index.d.ts +1 -0
  7. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/index.d.ts.map +1 -1
  8. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/index.d.ts +2 -0
  9. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/index.d.ts.map +1 -0
  10. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/normalizeSelectBooleanPropsFromBackend.d.ts +6 -0
  11. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/normalizeSelectBooleanPropsFromBackend.d.ts.map +1 -0
  12. package/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/normalizeSelectBooleanPropsFromBackend.js +13 -0
  13. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.d.ts.map +1 -1
  14. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.js +5 -3
  15. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/selectBooleanStrategy.d.ts +4 -0
  16. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/selectBooleanStrategy.d.ts.map +1 -0
  17. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/selectBooleanStrategy.js +34 -0
  18. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/types.d.ts +5 -0
  19. package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/types.d.ts.map +1 -0
  20. package/components/DynamicForm/helpers/resolveInitialValue/resolveFallbackInitialValue/resolveFallbackInitialValue.d.ts.map +1 -1
  21. package/components/DynamicForm/helpers/resolveInitialValue/resolveFallbackInitialValue/resolveFallbackInitialValue.js +3 -3
  22. package/components/DynamicForm/helpers/resolveInitialValue/resolveInitialValue.js +14 -14
  23. package/components/DynamicForm/hooks/useInitializeVisibleFields/index.d.ts +3 -0
  24. package/components/DynamicForm/hooks/useInitializeVisibleFields/index.d.ts.map +1 -0
  25. package/components/DynamicForm/hooks/useInitializeVisibleFields/types.d.ts +8 -0
  26. package/components/DynamicForm/hooks/useInitializeVisibleFields/types.d.ts.map +1 -0
  27. package/components/DynamicForm/hooks/useInitializeVisibleFields/useInitializeVisibleFields.d.ts +4 -0
  28. package/components/DynamicForm/hooks/useInitializeVisibleFields/useInitializeVisibleFields.d.ts.map +1 -0
  29. package/components/DynamicForm/hooks/useInitializeVisibleFields/useInitializeVisibleFields.js +48 -0
  30. package/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.d.ts.map +1 -1
  31. package/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.js +81 -78
  32. package/components/DynamicForm/types.d.ts +8 -2
  33. package/components/DynamicForm/types.d.ts.map +1 -1
  34. package/components/DynamicForm/types.js +1 -0
  35. package/components/SelectBoolean/SelectBoolean.d.ts +8 -0
  36. package/components/SelectBoolean/SelectBoolean.d.ts.map +1 -0
  37. package/components/SelectBoolean/SelectBoolean.js +62 -0
  38. package/components/SelectBoolean/constants.d.ts +9 -0
  39. package/components/SelectBoolean/constants.d.ts.map +1 -0
  40. package/components/SelectBoolean/constants.js +11 -0
  41. package/components/SelectBoolean/dictionary.d.ts +8 -0
  42. package/components/SelectBoolean/dictionary.d.ts.map +1 -0
  43. package/components/SelectBoolean/dictionary.js +13 -0
  44. package/components/SelectBoolean/index.d.ts +4 -0
  45. package/components/SelectBoolean/index.d.ts.map +1 -0
  46. package/components/SelectBoolean/types.d.ts +14 -0
  47. package/components/SelectBoolean/types.d.ts.map +1 -0
  48. package/components/extended/mui/Select/dictionary.js +9 -4
  49. package/components/hook-form/RHFSelectBoolean/RHFSelectBoolean.d.ts +3 -0
  50. package/components/hook-form/RHFSelectBoolean/RHFSelectBoolean.d.ts.map +1 -0
  51. package/components/hook-form/RHFSelectBoolean/RHFSelectBoolean.js +33 -0
  52. package/components/hook-form/RHFSelectBoolean/index.d.ts +3 -0
  53. package/components/hook-form/RHFSelectBoolean/index.d.ts.map +1 -0
  54. package/components/hook-form/RHFSelectBoolean/types.d.ts +7 -0
  55. package/components/hook-form/RHFSelectBoolean/types.d.ts.map +1 -0
  56. package/components/hook-form/index.d.ts +1 -0
  57. package/components/hook-form/index.d.ts.map +1 -1
  58. package/components/index.d.ts +1 -0
  59. package/components/index.d.ts.map +1 -1
  60. package/index.js +665 -657
  61. package/package.json +5 -5
@@ -4,6 +4,7 @@ export declare const DYNAMIC_FORM_EMPTY_STATE_LABELS: {
4
4
  title: string;
5
5
  message: string;
6
6
  };
7
+ /** Return every dictionary namespace required by DynamicForm and its field controls. */
7
8
  export declare const getDynamicFormComponentsDictionary: () => string[];
8
9
  export declare const DYNAMIC_FORM_DICTIONARY: {
9
10
  /** Empty-state title when no visible field can mount */
@@ -1 +1 @@
1
- {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../../../../packages/components/src/components/DynamicForm/dictionary.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D,uFAAuF;AACvF,eAAO,MAAM,+BAA+B;;;CAG3C,CAAC;AAEF,eAAO,MAAM,kCAAkC,gBAE9C,CAAC;AAEF,eAAO,MAAM,uBAAuB;IAClC,wDAAwD;;IAExD,4DAA4D;;IAE5D,2GAA2G;;;;;;;;;;;;IAY3G,oFAAoF;;IAEpF,kFAAkF;;IAElF,+EAA+E;;IAE/E,8DAA8D;;IAE9D,oEAAoE;;IAEpE,uFAAuF;;CAExF,CAAC"}
1
+ {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../../../../packages/components/src/components/DynamicForm/dictionary.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D,uFAAuF;AACvF,eAAO,MAAM,+BAA+B;;;CAG3C,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,kCAAkC,gBAK9C,CAAC;AAEF,eAAO,MAAM,uBAAuB;IAClC,wDAAwD;;IAExD,4DAA4D;;IAE5D,2GAA2G;;;;;;;;;;;;IAY3G,oFAAoF;;IAEpF,kFAAkF;;IAElF,+EAA+E;;IAE/E,8DAA8D;;IAE9D,oEAAoE;;IAEpE,uFAAuF;;CAExF,CAAC"}
@@ -1,7 +1,11 @@
1
- const _ = "dynamic_form", e = {
1
+ import { getSelectBooleanComponentsDictionary as e } from "../SelectBoolean/dictionary.js";
2
+ const _ = "dynamic_form", s = {
2
3
  title: "No visible fields",
3
4
  message: "This form has no fields to display at this time."
4
- }, E = () => [_], s = {
5
+ }, S = () => [
6
+ _,
7
+ ...e()
8
+ ], i = {
5
9
  /** Empty-state title when no visible field can mount */
6
10
  NO_VISIBLE_FIELDS_TITLE: `${_}.no_visible_fields_title`,
7
11
  /** Explain why the form body contains no field controls. */
@@ -32,8 +36,8 @@ const _ = "dynamic_form", e = {
32
36
  SECTION_CONTRACT_NOTICE: `${_}.section_contract_notice`
33
37
  };
34
38
  export {
35
- s as DYNAMIC_FORM_DICTIONARY,
39
+ i as DYNAMIC_FORM_DICTIONARY,
36
40
  _ as DYNAMIC_FORM_DICTIONARY_KEY,
37
- e as DYNAMIC_FORM_EMPTY_STATE_LABELS,
38
- E as getDynamicFormComponentsDictionary
41
+ s as DYNAMIC_FORM_EMPTY_STATE_LABELS,
42
+ S as getDynamicFormComponentsDictionary
39
43
  };
@@ -15,7 +15,7 @@ export declare const DYNAMIC_FORM_FIELD_COMPONENT_ALLOWLIST: {
15
15
  readonly fft_multiselect_text: readonly ["RHFCheckableList"];
16
16
  readonly fft_icon: readonly ["RHFImageSelector"];
17
17
  readonly fft_resource_dictionary: readonly ["RHFResourceDictionary"];
18
- readonly fft_boolean: readonly ["RHFCheckbox"];
18
+ readonly fft_boolean: readonly ["RHFCheckbox", "RHFSelectBoolean"];
19
19
  readonly fft_date_range: readonly ["RHFDateTimeRangePicker"];
20
20
  readonly fft_alert: readonly ["Alert"];
21
21
  readonly fft_section: readonly ["Section"];
@@ -28,7 +28,7 @@ const _ = {
28
28
  fft_multiselect_text: ["RHFCheckableList"],
29
29
  fft_icon: ["RHFImageSelector"],
30
30
  fft_resource_dictionary: ["RHFResourceDictionary"],
31
- fft_boolean: ["RHFCheckbox"],
31
+ fft_boolean: ["RHFCheckbox", "RHFSelectBoolean"],
32
32
  fft_date_range: ["RHFDateTimeRangePicker"],
33
33
  fft_alert: ["Alert"],
34
34
  fft_section: ["Section"]
@@ -10,5 +10,6 @@ export * from './normalizeNumberInputPropsFromBackend';
10
10
  export * from './normalizeRadioGroupPropsFromBackend';
11
11
  export * from './normalizeFieldOptionsForSelect';
12
12
  export * from './normalizeSelectPropsFromBackend';
13
+ export * from './normalizeSelectBooleanPropsFromBackend';
13
14
  export * from './normalizeTextFieldPropsFromBackend';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/normalizations/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/normalizations/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { normalizeSelectBooleanPropsFromBackend } from './normalizeSelectBooleanPropsFromBackend';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { GetLabelType } from '@m4l/core';
2
+ import { Field } from '../../../../types';
3
+ import { NormalizedSelectBooleanPropsFromBackendResult } from '../../strategies/selectBooleanStrategy/types';
4
+ /** Keep only valid boolean-select presentation copy from the backend component props. */
5
+ export declare function normalizeSelectBooleanPropsFromBackend(field: Field, getLabel: GetLabelType): NormalizedSelectBooleanPropsFromBackendResult;
6
+ //# sourceMappingURL=normalizeSelectBooleanPropsFromBackend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeSelectBooleanPropsFromBackend.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/normalizations/normalizeSelectBooleanPropsFromBackend/normalizeSelectBooleanPropsFromBackend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,KAAK,EAEN,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,8CAA8C,CAAC;AAElH,yFAAyF;AACzF,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,GACrB,6CAA6C,CAiB/C"}
@@ -0,0 +1,13 @@
1
+ import { resolveFieldInputLabel as l } from "../../../resolveFieldInputLabel/resolveFieldInputLabel.js";
2
+ import { resolveFieldTypeComponentProps as n } from "../../../resolveFieldContractAliases/resolveFieldContractAliases.js";
3
+ import { isRecord as s } from "../../../isRecord/isRecord.js";
4
+ function f(r, i) {
5
+ const o = l(r, i), e = n(r.fieldType);
6
+ if (!s(e))
7
+ return { resolvedLabel: o };
8
+ const t = {};
9
+ return typeof e.titleTrue == "string" && e.titleTrue.trim() !== "" && (t.titleTrue = e.titleTrue.trim()), typeof e.titleFalse == "string" && e.titleFalse.trim() !== "" && (t.titleFalse = e.titleFalse.trim()), { ...t, resolvedLabel: o };
10
+ }
11
+ export {
12
+ f as normalizeSelectBooleanPropsFromBackend
13
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAatD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAqBjF,CAAC"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AActD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAsBjF,CAAC"}
@@ -9,7 +9,8 @@ import { autocompleteStrategy as y } from "./autocompleteStrategy/autocompleteSt
9
9
  import { radioGroupStrategy as S } from "./radioGroupStrategy/radioGroupStrategy.js";
10
10
  import { imageSelectorStrategy as s } from "./imageSelectorStrategy/imageSelectorStrategy.js";
11
11
  import { alertStrategy as n } from "./alertStrategy/alertStrategy.js";
12
- const O = (() => {
12
+ import { selectBooleanStrategy as l } from "./selectBooleanStrategy/selectBooleanStrategy.js";
13
+ const _ = (() => {
13
14
  const t = {}, o = [
14
15
  m,
15
16
  a,
@@ -21,7 +22,8 @@ const O = (() => {
21
22
  y,
22
23
  S,
23
24
  s,
24
- n
25
+ n,
26
+ l
25
27
  ];
26
28
  for (const r of o)
27
29
  for (const e of r.componentIds)
@@ -29,5 +31,5 @@ const O = (() => {
29
31
  return t;
30
32
  })();
31
33
  export {
32
- O as FIELD_COMPONENT_STRATEGY_REGISTRY
34
+ _ as FIELD_COMPONENT_STRATEGY_REGISTRY
33
35
  };
@@ -0,0 +1,4 @@
1
+ import { FieldComponentStrategy } from '../types';
2
+ /** Render the canonical boolean select binding. */
3
+ export declare const selectBooleanStrategy: FieldComponentStrategy;
4
+ //# sourceMappingURL=selectBooleanStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectBooleanStrategy.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/selectBooleanStrategy.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,UAAU,CAAC;AAElB,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,EAAE,sBA6BnC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { jsx as p } from "@emotion/react/jsx-runtime";
2
+ import { normalizeSelectBooleanPropsFromBackend as i } from "../../normalizations/normalizeSelectBooleanPropsFromBackend/normalizeSelectBooleanPropsFromBackend.js";
3
+ import { RHFSelectBoolean as c } from "../../../../../hook-form/RHFSelectBoolean/RHFSelectBoolean.js";
4
+ import { resolveFieldMandatory as y, resolveFieldReadOnly as b } from "../../../resolveFieldContractAliases/resolveFieldContractAliases.js";
5
+ const v = {
6
+ componentIds: ["RHFSelectBoolean"],
7
+ /** Render RHFSelectBoolean using root field state and whitelisted presentation copy. */
8
+ render(o) {
9
+ const { field: e, props: r } = o, {
10
+ disabled: l,
11
+ getLabel: a,
12
+ readOnly: n,
13
+ size: t,
14
+ suppressLabel: s
15
+ } = r, { resolvedLabel: d, ...m } = i(e, a);
16
+ return /* @__PURE__ */ p(
17
+ c,
18
+ {
19
+ name: e.name,
20
+ size: t,
21
+ disabled: l,
22
+ readOnly: b(e, n),
23
+ ...!s && {
24
+ label: d,
25
+ mandatory: y(e)
26
+ },
27
+ ...m
28
+ }
29
+ );
30
+ }
31
+ };
32
+ export {
33
+ v as selectBooleanStrategy
34
+ };
@@ -0,0 +1,5 @@
1
+ import { RHFSelectBooleanRHFComponentPropsFromBackend } from '../../../../types';
2
+ export interface NormalizedSelectBooleanPropsFromBackendResult extends Partial<RHFSelectBooleanRHFComponentPropsFromBackend> {
3
+ resolvedLabel: string;
4
+ }
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectBooleanStrategy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,mBAAmB,CAAC;AAEtF,MAAM,WAAW,6CACf,SAAQ,OAAO,CAAC,4CAA4C,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveFallbackInitialValue.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveInitialValue/resolveFallbackInitialValue/resolveFallbackInitialValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,yBAAyB,CAmB3B"}
1
+ {"version":3,"file":"resolveFallbackInitialValue.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/DynamicForm/helpers/resolveInitialValue/resolveFallbackInitialValue/resolveFallbackInitialValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,yBAAyB,CAkB3B"}
@@ -1,7 +1,7 @@
1
- function u(l) {
2
- const r = l.currentValue !== null && l.currentValue !== void 0 && l.isVisible !== !1 ? l.currentValue : l.defaultValue;
1
+ function l(u) {
2
+ const r = u.currentValue !== null && u.currentValue !== void 0 ? u.currentValue : u.defaultValue;
3
3
  return r == null ? null : typeof r == "string" ? r : Array.isArray(r) ? JSON.stringify(r) : String(r);
4
4
  }
5
5
  export {
6
- u as resolveFallbackInitialValue
6
+ l as resolveFallbackInitialValue
7
7
  };
@@ -11,20 +11,20 @@ import { resolveScalarFieldValue as T } from "./resolveScalarFieldValue/resolveS
11
11
  import { isMultipleOptionField as S } from "../optionFieldValueContract/isMultipleOptionField.js";
12
12
  import { isRecord as h } from "../isRecord/isRecord.js";
13
13
  import { parseDateTimeRangeValue as v } from "../dateTimeRangeValue/dateTimeRangeValue.js";
14
- function D(e, a) {
14
+ function D(e, i) {
15
15
  const t = v(e);
16
16
  return t ? {
17
- endDate: t.endDate ? p(t.endDate, a?.name) : null,
18
- startDate: t.startDate ? p(t.startDate, a?.name) : null
17
+ endDate: t.endDate ? p(t.endDate, i?.name) : null,
18
+ startDate: t.startDate ? p(t.startDate, i?.name) : null
19
19
  } : _;
20
20
  }
21
- function K(e, a = {}) {
22
- const { timeZone: t = null } = a;
21
+ function K(e, i = {}) {
22
+ const { timeZone: t = null } = i;
23
23
  if (!V(e))
24
24
  return R(e);
25
- const s = I(e.fieldType), d = e.fieldType?.componentId, i = e.fieldType?.id, l = N(e);
26
- if (e.currentValue !== null && e.isVisible !== !1) {
27
- const r = e.currentValue, n = u.has(i ?? ""), f = d === "RHFSelect" && s?.multiple === !0;
25
+ const s = I(e.fieldType), d = e.fieldType?.componentId, a = e.fieldType?.id, l = N(e);
26
+ if (e.currentValue !== null && e.currentValue !== void 0) {
27
+ const r = e.currentValue, n = u.has(a ?? ""), f = d === "RHFSelect" && s?.multiple === !0;
28
28
  if (l)
29
29
  return D(r, t);
30
30
  if (m(e))
@@ -43,7 +43,7 @@ function K(e, a = {}) {
43
43
  }
44
44
  return [r];
45
45
  }
46
- return Array.isArray(r) ? r : typeof r == "string" || typeof r == "number" || typeof r == "boolean" ? T(r, i) : r;
46
+ return Array.isArray(r) ? r : typeof r == "string" || typeof r == "number" || typeof r == "boolean" ? T(r, a) : r;
47
47
  }
48
48
  if (e.defaultValue !== null && e.defaultValue !== void 0) {
49
49
  const r = e.defaultValue;
@@ -51,7 +51,7 @@ function K(e, a = {}) {
51
51
  return D(r, t);
52
52
  if (m(e))
53
53
  return A(e, r);
54
- if (u.has(i ?? "")) {
54
+ if (u.has(a ?? "")) {
55
55
  if (Array.isArray(r))
56
56
  return r;
57
57
  if (typeof r == "string")
@@ -65,11 +65,11 @@ function K(e, a = {}) {
65
65
  }
66
66
  return [r];
67
67
  }
68
- return Array.isArray(r) ? r : typeof r == "string" || typeof r == "number" || typeof r == "boolean" ? T(r, i) : r;
68
+ return Array.isArray(r) ? r : typeof r == "string" || typeof r == "number" || typeof r == "boolean" ? T(r, a) : r;
69
69
  }
70
70
  if (m(e))
71
- return S(e.fieldType) || u.has(i ?? "") ? [] : null;
72
- if (u.has(i ?? ""))
71
+ return S(e.fieldType) || u.has(a ?? "") ? [] : null;
72
+ if (u.has(a ?? ""))
73
73
  return [];
74
74
  if (l) {
75
75
  const r = h(s) ? s.defaultShortcut : void 0, n = typeof r == "string" ? r : y;
@@ -79,7 +79,7 @@ function K(e, a = {}) {
79
79
  ({ id: o }) => o === y
80
80
  ))?.resolveValue(E(t?.name)) ?? _;
81
81
  }
82
- return i === "fft_boolean" ? !1 : (F.has(i ?? ""), null);
82
+ return a === "fft_boolean" ? !1 : (F.has(a ?? ""), null);
83
83
  }
84
84
  export {
85
85
  K as resolveInitialValue
@@ -0,0 +1,3 @@
1
+ export { useInitializeVisibleFields } from './useInitializeVisibleFields';
2
+ export type { UseInitializeVisibleFieldsOptions } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useInitializeVisibleFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { FormStatusLoad } from '../../../hook-form/RHFormProvider/types';
2
+ import { DynamicFormApiResponse, Field } from '../../types';
3
+ export interface UseInitializeVisibleFieldsOptions {
4
+ data: DynamicFormApiResponse;
5
+ statusLoad: FormStatusLoad;
6
+ visibleFields: Field[];
7
+ }
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useInitializeVisibleFields/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,sBAAsB,CAAC;IAC7B,UAAU,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,KAAK,EAAE,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ import { UseInitializeVisibleFieldsOptions } from './types';
2
+ /** Initialize fields that enter the rendered form after React Hook Form created its default values. */
3
+ export declare function useInitializeVisibleFields(options: UseInitializeVisibleFieldsOptions): void;
4
+ //# sourceMappingURL=useInitializeVisibleFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInitializeVisibleFields.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useInitializeVisibleFields/useInitializeVisibleFields.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEjE,uGAAuG;AACvG,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,iCAAiC,GACzC,IAAI,CAsEN"}
@@ -0,0 +1,48 @@
1
+ import { useRef as s, useMemo as S, useEffect as y } from "react";
2
+ import { useFormContext as V } from "react-hook-form";
3
+ import { useUserPreferences as w } from "@m4l/core";
4
+ import { isRenderableDynamicFormField as z } from "../../helpers/isRenderableDynamicFormField/isRenderableDynamicFormField.js";
5
+ import { isSupportedInformationalField as R } from "../../helpers/fieldContractAllowlist/fieldContractAllowlist.js";
6
+ import { resolveInitialValue as g } from "../../helpers/resolveInitialValue/resolveInitialValue.js";
7
+ function Z(F) {
8
+ const { data: e, statusLoad: c, visibleFields: f } = F, m = w().timeZone ?? null, { getFieldState: d, getValues: l, resetField: u } = V(), i = s(/* @__PURE__ */ new Set()), n = s(/* @__PURE__ */ new Set()), o = S(
9
+ () => `${e.form.id}:${e.form.version}:${e.instance?.id ?? "new"}`,
10
+ [e.form.id, e.form.version, e.instance?.id]
11
+ ), p = s(o);
12
+ y(() => {
13
+ if (p.current !== o && (i.current.clear(), n.current = new Set(
14
+ e.fields.map((t) => t.name)
15
+ ), p.current = o), c === "reload_values_provider") {
16
+ i.current.clear(), n.current = new Set(
17
+ e.fields.map((t) => t.name)
18
+ );
19
+ return;
20
+ }
21
+ f.forEach((t) => {
22
+ const { name: r } = t;
23
+ if (!z(t) || R(t) || i.current.has(r))
24
+ return;
25
+ const a = r, h = l(a), I = d(a);
26
+ if (!n.current.has(r) && (h !== void 0 || I.isDirty || I.isTouched)) {
27
+ i.current.add(r);
28
+ return;
29
+ }
30
+ const v = g(t, { timeZone: m });
31
+ u(a, {
32
+ defaultValue: v
33
+ }), n.current.delete(r), i.current.add(r);
34
+ });
35
+ }, [
36
+ o,
37
+ e.fields,
38
+ d,
39
+ l,
40
+ u,
41
+ c,
42
+ m,
43
+ f
44
+ ]);
45
+ }
46
+ export {
47
+ Z as useInitializeVisibleFields
48
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicFormContent.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,aAAa,CAAC;AAgBrB,eAAO,MAAM,kBAAkB,oHAgN7B,CAAC"}
1
+ {"version":3,"file":"DynamicFormContent.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,aAAa,CAAC;AAgBrB,eAAO,MAAM,kBAAkB,oHAiN7B,CAAC"}