@m4l/components 9.33.0 → 9.33.1-beta-fix-typeck-and-warnings.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.
@@ -1 +1 @@
1
- {"version":3,"file":"useFieldsWithFetchedOptions.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,SAAS,CAAC;AAuIjB;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gCAAgC,GACtC,iCAAiC,CAiInC"}
1
+ {"version":3,"file":"useFieldsWithFetchedOptions.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,SAAS,CAAC;AAyIjB;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gCAAgC,GACtC,iCAAiC,CAkInC"}
@@ -1,31 +1,31 @@
1
- import { useState as y, useRef as R, useEffect as h, useMemo as C } from "react";
2
- import { useNetwork as q } from "@m4l/core";
1
+ import { useState as g, useRef as y, useMemo as R, useEffect as m } from "react";
2
+ import { useNetwork as w } from "@m4l/core";
3
3
  import { normalizeOptionsResponse as E } from "./normalizeOptionsResponse.js";
4
4
  import { isSupportedDynamicFormField as M } from "../../helpers/fieldContractAllowlist/fieldContractAllowlist.js";
5
- import { isMultipleOptionField as I } from "../../helpers/optionFieldValueContract/isMultipleOptionField.js";
6
- import { isRecord as T } from "../../helpers/isRecord/isRecord.js";
7
- import { normalizeEndpointParams as N } from "../../helpers/normalizeEndpointParams/normalizeEndpointParams.js";
8
- const P = /* @__PURE__ */ new Set([
5
+ import { isMultipleOptionField as q } from "../../helpers/optionFieldValueContract/isMultipleOptionField.js";
6
+ import { isRecord as I } from "../../helpers/isRecord/isRecord.js";
7
+ import { normalizeEndpointParams as T } from "../../helpers/normalizeEndpointParams/normalizeEndpointParams.js";
8
+ const N = /* @__PURE__ */ new Set([
9
9
  "RHFSelect",
10
10
  "RHFCheckableList",
11
11
  "RHFAutocomplete",
12
12
  "RHFRadioGroup",
13
13
  "RHFImageSelector"
14
14
  ]);
15
- function j(t) {
16
- const { fieldType: n, options: u, endpoint: p } = t;
17
- return !n?.componentId || !P.has(n.componentId) || !p ? !1 : !Array.isArray(u) || u.length === 0;
15
+ function P(t) {
16
+ const { fieldType: n, options: c, endpoint: p } = t;
17
+ return !n?.componentId || !N.has(n.componentId) || !p ? !1 : !Array.isArray(c) || c.length === 0;
18
18
  }
19
- function H(t) {
20
- return M(t) ? j(t) : !1;
19
+ function j(t) {
20
+ return M(t) ? P(t) : !1;
21
21
  }
22
- function l(t) {
23
- return Array.isArray(t) ? `[${t.map((n) => l(n)).join(",")}]` : typeof t == "object" && t !== null ? `{${Object.keys(t).sort().map((n) => `${JSON.stringify(n)}:${l(t[n])}`).join(",")}}` : JSON.stringify(t);
22
+ function h(t) {
23
+ return Array.isArray(t) ? `[${t.map((n) => h(n)).join(",")}]` : typeof t == "object" && t !== null ? `{${Object.keys(t).sort().map((n) => `${JSON.stringify(n)}:${h(t[n])}`).join(",")}}` : JSON.stringify(t);
24
24
  }
25
25
  function S(t, n) {
26
- return I(t.fieldType) || !T(n) ? [] : [n];
26
+ return q(t.fieldType) || !I(n) ? [] : [n];
27
27
  }
28
- function V(t) {
28
+ function H(t) {
29
29
  if (Array.isArray(t.currentValue))
30
30
  return t.currentValue;
31
31
  const n = S(
@@ -35,12 +35,13 @@ function V(t) {
35
35
  return n.length > 0 ? n : Array.isArray(t.defaultValue) ? t.defaultValue : S(t, t.defaultValue);
36
36
  }
37
37
  function F(t) {
38
- if (!H(t) || !t.endpoint)
38
+ if (!j(t) || !t.endpoint)
39
39
  return;
40
- const n = N(t.endpointParams ?? {});
40
+ const n = T(t.endpointParams ?? {});
41
41
  return {
42
+ endpoint: t.endpoint,
42
43
  field: t,
43
- key: l({
44
+ key: h({
44
45
  componentId: t.fieldType.componentId,
45
46
  endPoint: t.endpoint,
46
47
  fieldId: t.id,
@@ -49,21 +50,19 @@ function F(t) {
49
50
  parms: n
50
51
  };
51
52
  }
52
- function K(t) {
53
- const { fields: n } = t, { networkOperation: u } = q(), [p, d] = y({}), [A, O] = y(0), c = R(/* @__PURE__ */ new Map()), f = R(/* @__PURE__ */ new Set()), m = n.flatMap((r) => {
53
+ function J(t) {
54
+ const { fields: n } = t, { networkOperation: c } = w(), [p, d] = g({}), [b, O] = g(0), u = y(/* @__PURE__ */ new Map()), l = y(/* @__PURE__ */ new Set()), f = R(() => n.flatMap((r) => {
54
55
  const e = F(r);
55
56
  return e ? [e] : [];
56
- }), g = l(
57
- m.map(({ key: r }) => r)
58
- );
59
- return h(() => {
57
+ }), [n]);
58
+ return m(() => {
60
59
  const r = new Set(
61
- m.map(({ key: e }) => e)
60
+ f.map(({ key: e }) => e)
62
61
  );
63
- f.current = new Set(
64
- [...f.current].filter((e) => r.has(e))
65
- ), c.current.forEach((e, o) => {
66
- r.has(o) || (e.abort(), c.current.delete(o));
62
+ l.current = new Set(
63
+ [...l.current].filter((e) => r.has(e))
64
+ ), u.current.forEach((e, o) => {
65
+ r.has(o) || (e.abort(), u.current.delete(o));
67
66
  }), d((e) => {
68
67
  let o = !1;
69
68
  const s = {};
@@ -71,17 +70,20 @@ function K(t) {
71
70
  r.has(i) ? s[i] = a : o = !0;
72
71
  return o ? s : e;
73
72
  });
74
- }, [g]), h(() => () => {
75
- c.current.forEach((r) => {
76
- r.abort();
77
- }), c.current.clear();
78
- }, []), h(() => {
79
- const r = m.filter(({ key: e }) => !f.current.has(e));
80
- r.length !== 0 && (r.forEach(({ key: e }) => f.current.add(e)), O((e) => e + r.length), r.forEach(({ field: e, key: o, parms: s }) => {
73
+ }, [f]), m(() => {
74
+ const r = u.current;
75
+ return () => {
76
+ r.forEach((e) => {
77
+ e.abort();
78
+ }), r.clear();
79
+ };
80
+ }, []), m(() => {
81
+ const r = f.filter(({ key: e }) => !l.current.has(e));
82
+ r.length !== 0 && (r.forEach(({ key: e }) => l.current.add(e)), O((e) => e + r.length), r.forEach(({ endpoint: e, key: o, parms: s }) => {
81
83
  const i = new AbortController();
82
- c.current.set(o, i), u({
84
+ u.current.set(o, i), c({
83
85
  method: "GET",
84
- endPoint: e.endpoint,
86
+ endPoint: e,
85
87
  parms: s,
86
88
  timeout: 3e4,
87
89
  isRemote: !0,
@@ -90,29 +92,29 @@ function K(t) {
90
92
  }).then((a) => {
91
93
  if (i.signal.aborted)
92
94
  return;
93
- const b = E(a);
94
- d((w) => ({ ...w, [o]: b }));
95
+ const A = E(a);
96
+ d((C) => ({ ...C, [o]: A }));
95
97
  }).catch(() => {
96
98
  i.signal.aborted || d((a) => ({ ...a, [o]: [] }));
97
99
  }).finally(() => {
98
- O((a) => Math.max(0, a - 1)), c.current.delete(o);
100
+ O((a) => Math.max(0, a - 1)), u.current.delete(o);
99
101
  });
100
102
  }));
101
- }, [g, u]), {
102
- fields: C(() => n.map((r) => {
103
+ }, [f, c]), {
104
+ fields: R(() => n.map((r) => {
103
105
  const e = F(r);
104
106
  if (!e)
105
107
  return r;
106
- const o = V(r), s = p[e.key] ?? o;
108
+ const o = H(r), s = p[e.key] ?? o;
107
109
  return {
108
110
  ...r,
109
111
  options: s.length > 0 ? s : o,
110
112
  endpoint: void 0
111
113
  };
112
114
  }), [p, n]),
113
- isLoadingOptions: A > 0
115
+ isLoadingOptions: b > 0
114
116
  };
115
117
  }
116
118
  export {
117
- K as useFieldsWithFetchedOptions
119
+ J as useFieldsWithFetchedOptions
118
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.33.0",
3
+ "version": "9.33.1-beta-fix-typeck-and-warnings.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -50,23 +50,23 @@
50
50
  "@hookform/resolvers": "2.9.11",
51
51
  "nprogress": "0.2.0",
52
52
  "react-transition-group": "4.4.5",
53
+ "react-rnd": "10.5.2",
54
+ "@mui/x-date-pickers": "6.20.2",
53
55
  "react-color": "2.19.3",
54
- "react-draggable": "4.5.0",
55
56
  "react-dropzone": "14.4.1",
57
+ "react-draggable": "4.5.0",
56
58
  "react-spinners": "0.13.8",
57
- "@mui/x-date-pickers": "6.20.2",
58
- "react-rnd": "10.5.2",
59
- "simplebar-react": "3.2.6",
60
- "react-resizable-panels": "2.1.9",
61
59
  "chart.js": "4.5.1",
62
60
  "chartjs-chart-error-bars": "4.4.5",
63
61
  "qrcode.react": "3.2.0",
62
+ "react-resizable-panels": "2.1.9",
64
63
  "react-data-grid": "7.0.0-beta.47",
65
64
  "react-dnd": "16.0.1",
66
65
  "react-dnd-html5-backend": "16.0.1",
66
+ "simplebar-react": "3.2.6",
67
+ "date-fns": "2.30.0",
67
68
  "react-window": "1.8.11",
68
69
  "react-resizable": "3.1.3",
69
- "date-fns": "2.30.0",
70
70
  "@tanstack/react-virtual": "3.13.23"
71
71
  }
72
72
  }