@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;
|
|
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"}
|
package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useNetwork as
|
|
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
|
|
6
|
-
import { isRecord as
|
|
7
|
-
import { normalizeEndpointParams as
|
|
8
|
-
const
|
|
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
|
|
16
|
-
const { fieldType: n, options:
|
|
17
|
-
return !n?.componentId || !
|
|
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
|
|
20
|
-
return M(t) ?
|
|
19
|
+
function j(t) {
|
|
20
|
+
return M(t) ? P(t) : !1;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return Array.isArray(t) ? `[${t.map((n) =>
|
|
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
|
|
26
|
+
return q(t.fieldType) || !I(n) ? [] : [n];
|
|
27
27
|
}
|
|
28
|
-
function
|
|
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 (!
|
|
38
|
+
if (!j(t) || !t.endpoint)
|
|
39
39
|
return;
|
|
40
|
-
const n =
|
|
40
|
+
const n = T(t.endpointParams ?? {});
|
|
41
41
|
return {
|
|
42
|
+
endpoint: t.endpoint,
|
|
42
43
|
field: t,
|
|
43
|
-
key:
|
|
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
|
|
53
|
-
const { fields: n } = t, { networkOperation:
|
|
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
|
-
}),
|
|
57
|
-
|
|
58
|
-
);
|
|
59
|
-
return h(() => {
|
|
57
|
+
}), [n]);
|
|
58
|
+
return m(() => {
|
|
60
59
|
const r = new Set(
|
|
61
|
-
|
|
60
|
+
f.map(({ key: e }) => e)
|
|
62
61
|
);
|
|
63
|
-
|
|
64
|
-
[...
|
|
65
|
-
),
|
|
66
|
-
r.has(o) || (e.abort(),
|
|
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
|
-
}, [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
84
|
+
u.current.set(o, i), c({
|
|
83
85
|
method: "GET",
|
|
84
|
-
endPoint: e
|
|
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
|
|
94
|
-
d((
|
|
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)),
|
|
100
|
+
O((a) => Math.max(0, a - 1)), u.current.delete(o);
|
|
99
101
|
});
|
|
100
102
|
}));
|
|
101
|
-
}, [
|
|
102
|
-
fields:
|
|
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 =
|
|
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:
|
|
115
|
+
isLoadingOptions: b > 0
|
|
114
116
|
};
|
|
115
117
|
}
|
|
116
118
|
export {
|
|
117
|
-
|
|
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
|
}
|