cogsbox-state 0.5.484 → 0.5.486
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.
- package/dist/CogsState.d.ts +8 -0
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.js +576 -553
- package/dist/CogsState.js.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +163 -161
- package/dist/Components.js.map +1 -1
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +92 -91
- package/dist/plugins.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +67 -30
- package/src/Components.tsx +63 -39
- package/src/plugins.ts +3 -0
package/dist/Components.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../src/Components.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,EASZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAsBf,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,sBAAsB,2CAiFxB;AACD,eAAO,MAAM,uBAAuB,mDAWnC,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,M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GAAG,KAAK,GAAG,CAAC;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAC;CAC3C,2CAuCA"}
|
package/dist/Components.js
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { pluginStore as
|
|
3
|
-
import { createScopedMetadataContext as
|
|
4
|
-
import j, { memo as
|
|
5
|
-
import { getGlobalStore as
|
|
6
|
-
import { useInView as
|
|
7
|
-
import { v4 as
|
|
8
|
-
import { isDeepEqual as
|
|
9
|
-
import { runValidation as
|
|
1
|
+
import { jsx as C, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { pluginStore as E } from "./pluginStore.js";
|
|
3
|
+
import { createScopedMetadataContext as J, toDeconstructedMethods as et } from "./plugins.js";
|
|
4
|
+
import j, { memo as Q, useState as R, useRef as N, useCallback as L, useEffect as P, useLayoutEffect as nt, useMemo as ot } from "react";
|
|
5
|
+
import { getGlobalStore as b } from "./store.js";
|
|
6
|
+
import { useInView as rt } from "react-intersection-observer";
|
|
7
|
+
import { v4 as X } from "uuid";
|
|
8
|
+
import { isDeepEqual as it } from "./utility.js";
|
|
9
|
+
import { runValidation as G } from "./validation.js";
|
|
10
10
|
const {
|
|
11
|
-
getInitialOptions:
|
|
12
|
-
getShadowMetadata:
|
|
13
|
-
setShadowMetadata:
|
|
14
|
-
getShadowValue:
|
|
15
|
-
registerComponent:
|
|
16
|
-
unregisterComponent:
|
|
17
|
-
notifyPathSubscribers:
|
|
18
|
-
subscribeToPath:
|
|
19
|
-
} =
|
|
20
|
-
function
|
|
11
|
+
getInitialOptions: at,
|
|
12
|
+
getShadowMetadata: st,
|
|
13
|
+
setShadowMetadata: Tt,
|
|
14
|
+
getShadowValue: $,
|
|
15
|
+
registerComponent: ct,
|
|
16
|
+
unregisterComponent: lt,
|
|
17
|
+
notifyPathSubscribers: wt,
|
|
18
|
+
subscribeToPath: ut
|
|
19
|
+
} = b.getState(), { stateHandlers: At, notifyFormUpdate: B } = E.getState();
|
|
20
|
+
function dt({
|
|
21
21
|
formOpts: e,
|
|
22
22
|
path: t,
|
|
23
23
|
stateKey: o,
|
|
24
24
|
children: c
|
|
25
25
|
}) {
|
|
26
|
-
const { getInitialOptions: v, getShadowMetadata:
|
|
27
|
-
...
|
|
26
|
+
const { getInitialOptions: v, getShadowMetadata: p, getShadowValue: r } = b.getState(), l = v(o), h = p(o, t)?.validation, A = h?.status || "NOT_VALIDATED", g = (h?.errors || []).map((S) => ({
|
|
27
|
+
...S,
|
|
28
28
|
path: t
|
|
29
|
-
})),
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
29
|
+
})), d = g.filter((S) => S.severity === "error").map((S) => S.message), a = g.filter((S) => S.severity === "warning").map((S) => S.message), T = d[0] || a[0], f = d.length > 0 ? "error" : a.length > 0 ? "warning" : void 0, { registeredPlugins: s } = E.getState(), y = {};
|
|
30
|
+
return s.forEach((S) => {
|
|
31
|
+
if (l && l.hasOwnProperty(S.name)) {
|
|
32
|
+
const W = S.name, O = E.getState().getHookResult(o, W), k = J(
|
|
33
33
|
o,
|
|
34
|
-
|
|
34
|
+
W,
|
|
35
35
|
t
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
hookData:
|
|
39
|
-
getFieldMetaData:
|
|
40
|
-
setFieldMetaData:
|
|
41
|
-
removeFieldMetaData:
|
|
37
|
+
y[W] = {
|
|
38
|
+
hookData: O,
|
|
39
|
+
getFieldMetaData: k.getFieldMetaData,
|
|
40
|
+
setFieldMetaData: k.setFieldMetaData,
|
|
41
|
+
removeFieldMetaData: k.removeFieldMetaData
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
}), /* @__PURE__ */
|
|
45
|
-
children: /* @__PURE__ */
|
|
44
|
+
}), /* @__PURE__ */ C(q, { children: l?.formElements?.validation && !e?.validation?.disable ? l.formElements.validation({
|
|
45
|
+
children: /* @__PURE__ */ C(j.Fragment, { children: c }, t.toString()),
|
|
46
46
|
status: A,
|
|
47
47
|
// Now passes the new ValidationStatus type
|
|
48
48
|
message: e?.validation?.hideMessage ? "" : e?.validation?.message || T || "",
|
|
49
49
|
severity: f,
|
|
50
|
-
hasErrors:
|
|
51
|
-
hasWarnings:
|
|
50
|
+
hasErrors: d.length > 0,
|
|
51
|
+
hasWarnings: a.length > 0,
|
|
52
52
|
allErrors: g,
|
|
53
53
|
path: t,
|
|
54
54
|
getData: () => r(o, t),
|
|
55
|
-
plugins:
|
|
56
|
-
}) : /* @__PURE__ */
|
|
55
|
+
plugins: y
|
|
56
|
+
}) : /* @__PURE__ */ C(j.Fragment, { children: c }, t.toString()) });
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const Dt = Q(
|
|
59
|
+
gt,
|
|
60
60
|
(e, t) => e.itemPath.join(".") === t.itemPath.join(".") && e.stateKey === t.stateKey && e.itemComponentId === t.itemComponentId && e.localIndex === t.localIndex
|
|
61
61
|
);
|
|
62
|
-
function
|
|
62
|
+
function gt({
|
|
63
63
|
stateKey: e,
|
|
64
64
|
itemComponentId: t,
|
|
65
65
|
itemPath: o,
|
|
66
66
|
localIndex: c,
|
|
67
67
|
arraySetter: v,
|
|
68
|
-
rebuildStateShape:
|
|
68
|
+
rebuildStateShape: p,
|
|
69
69
|
renderFn: r
|
|
70
70
|
}) {
|
|
71
|
-
const [,
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
(
|
|
75
|
-
A.current =
|
|
71
|
+
const [, l] = R({}), { ref: m, inView: h } = rt(), A = N(null), g = [e, ...o].join(".");
|
|
72
|
+
z(e, t, l);
|
|
73
|
+
const d = L(
|
|
74
|
+
(s) => {
|
|
75
|
+
A.current = s, m(s);
|
|
76
76
|
},
|
|
77
77
|
[m]
|
|
78
78
|
);
|
|
79
79
|
P(() => {
|
|
80
|
-
const
|
|
81
|
-
|
|
80
|
+
const s = ut(g, (y) => {
|
|
81
|
+
l({});
|
|
82
82
|
});
|
|
83
|
-
return () =>
|
|
83
|
+
return () => s();
|
|
84
84
|
}, [g]);
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const T =
|
|
88
|
-
currentState:
|
|
85
|
+
const a = $(e, o);
|
|
86
|
+
if (a === void 0) return null;
|
|
87
|
+
const T = p({
|
|
88
|
+
currentState: a,
|
|
89
89
|
path: o,
|
|
90
90
|
componentId: t
|
|
91
91
|
}), f = r(T, c, v);
|
|
92
92
|
return j.isValidElement(f) ? j.cloneElement(f, {
|
|
93
|
-
ref: (
|
|
94
|
-
|
|
95
|
-
const { ref:
|
|
96
|
-
typeof
|
|
93
|
+
ref: (s) => {
|
|
94
|
+
d(s);
|
|
95
|
+
const { ref: y } = f;
|
|
96
|
+
typeof y == "function" ? y(s) : y && "current" in y && (y.current = s);
|
|
97
97
|
}
|
|
98
|
-
}) : /* @__PURE__ */
|
|
98
|
+
}) : /* @__PURE__ */ C("div", { ref: d, children: f });
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function It({
|
|
101
101
|
stateKey: e,
|
|
102
102
|
path: t,
|
|
103
103
|
rebuildStateShape: o,
|
|
104
104
|
renderFn: c,
|
|
105
105
|
formOpts: v,
|
|
106
|
-
setState:
|
|
106
|
+
setState: p
|
|
107
107
|
}) {
|
|
108
|
-
const r = N(
|
|
109
|
-
|
|
110
|
-
const g =
|
|
108
|
+
const r = N(X()).current, [, l] = R({}), m = N(null), h = [e, ...t].join(".");
|
|
109
|
+
z(e, r, l);
|
|
110
|
+
const g = b.getState().getShadowNode(e, t)?._meta?.typeInfo, d = $(e, t), [a, T] = R(d), f = N(!1), s = N(null);
|
|
111
111
|
P(() => {
|
|
112
|
-
!f.current && !
|
|
113
|
-
}, [
|
|
114
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
112
|
+
!f.current && !it(d, a) && T(d);
|
|
113
|
+
}, [d]), P(() => {
|
|
114
|
+
const { getShadowMetadata: n, setShadowMetadata: i } = b.getState();
|
|
115
115
|
console.log("FormElementWrapper effect running for:", e, t);
|
|
116
116
|
const u = n(e, t) || {};
|
|
117
117
|
u.clientActivityState || (u.clientActivityState = { elements: /* @__PURE__ */ new Map() });
|
|
118
118
|
const w = () => {
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
const x =
|
|
119
|
+
const M = m.current;
|
|
120
|
+
if (!M) return "input";
|
|
121
|
+
const x = M.tagName.toLowerCase();
|
|
122
122
|
if (x === "textarea") return "textarea";
|
|
123
123
|
if (x === "select") return "select";
|
|
124
124
|
if (x === "input") {
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
129
|
-
if (
|
|
125
|
+
const F = M.type;
|
|
126
|
+
if (F === "checkbox") return "checkbox";
|
|
127
|
+
if (F === "radio") return "radio";
|
|
128
|
+
if (F === "range") return "range";
|
|
129
|
+
if (F === "file") return "file";
|
|
130
130
|
}
|
|
131
131
|
return "input";
|
|
132
132
|
};
|
|
@@ -135,33 +135,33 @@ function Mt({
|
|
|
135
135
|
elementType: w(),
|
|
136
136
|
inputType: m.current?.type,
|
|
137
137
|
mountedAt: Date.now()
|
|
138
|
-
}), console.log("currentMeta", u),
|
|
139
|
-
const D =
|
|
140
|
-
!f.current &&
|
|
138
|
+
}), console.log("currentMeta", u), i(e, t, u);
|
|
139
|
+
const D = b.getState().subscribeToPath(h, (M) => {
|
|
140
|
+
!f.current && a !== M && l({});
|
|
141
141
|
});
|
|
142
142
|
return () => {
|
|
143
|
-
D(),
|
|
144
|
-
const
|
|
145
|
-
|
|
143
|
+
D(), s.current && (clearTimeout(s.current), f.current = !1);
|
|
144
|
+
const M = b.getState().getShadowMetadata(e, t);
|
|
145
|
+
M?.clientActivityState?.elements && (M.clientActivityState.elements.delete(r), i(e, t, M));
|
|
146
146
|
};
|
|
147
147
|
}, []);
|
|
148
|
-
const
|
|
148
|
+
const y = L(
|
|
149
149
|
(n) => {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
const { getShadowMetadata: u, setShadowMetadata: w } =
|
|
150
|
+
const i = b.getState().getShadowNode(e, t)?._meta?.typeInfo ?? g;
|
|
151
|
+
i ? i.type === "number" && typeof n == "string" ? n = n === "" ? i.nullable ? null : i.default ?? 0 : Number(n) : i.type === "boolean" && typeof n == "string" ? n = n === "true" || n === "1" : i.type === "date" && typeof n == "string" && (n = new Date(n)) : typeof d === "number" && typeof n == "string" && (n = n === "" ? 0 : Number(n)), T(n);
|
|
152
|
+
const { getShadowMetadata: u, setShadowMetadata: w } = b.getState(), D = u(e, t);
|
|
153
153
|
if (D?.clientActivityState?.elements?.has(r)) {
|
|
154
154
|
const I = D.clientActivityState.elements.get(r);
|
|
155
155
|
I && I.currentActivity?.type === "focus" && (I.currentActivity.details = {
|
|
156
156
|
...I.currentActivity.details,
|
|
157
157
|
value: n,
|
|
158
|
-
previousValue: I.currentActivity.details?.value ||
|
|
158
|
+
previousValue: I.currentActivity.details?.value || d,
|
|
159
159
|
inputLength: typeof n == "string" ? n.length : void 0,
|
|
160
160
|
keystrokeCount: (I.currentActivity.details?.keystrokeCount || 0) + 1
|
|
161
161
|
}, w(e, t, D));
|
|
162
162
|
}
|
|
163
|
-
const
|
|
164
|
-
|
|
163
|
+
const M = D?.clientActivityState?.elements?.get(r);
|
|
164
|
+
B({
|
|
165
165
|
stateKey: e,
|
|
166
166
|
activityType: "input",
|
|
167
167
|
// Changed from 'type'
|
|
@@ -174,45 +174,45 @@ function Mt({
|
|
|
174
174
|
// You'd need to track this from the actual input event
|
|
175
175
|
isPasting: !1,
|
|
176
176
|
// You'd need to track this from paste events
|
|
177
|
-
keystrokeCount: (
|
|
177
|
+
keystrokeCount: (M?.currentActivity?.details?.keystrokeCount || 0) + 1
|
|
178
178
|
}
|
|
179
|
-
}),
|
|
179
|
+
}), G({
|
|
180
180
|
stateKey: e,
|
|
181
181
|
path: t,
|
|
182
182
|
newValue: n,
|
|
183
183
|
updateType: "update"
|
|
184
|
-
}, "onChange"), f.current = !0,
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
f.current = !1,
|
|
184
|
+
}, "onChange"), f.current = !0, s.current && clearTimeout(s.current);
|
|
185
|
+
const F = v?.debounceTime ?? 200;
|
|
186
|
+
s.current = setTimeout(() => {
|
|
187
|
+
f.current = !1, p(n, t, {
|
|
188
188
|
updateType: "update",
|
|
189
189
|
validationTrigger: "onChange"
|
|
190
190
|
});
|
|
191
|
-
},
|
|
191
|
+
}, F);
|
|
192
192
|
},
|
|
193
193
|
[
|
|
194
|
-
|
|
194
|
+
p,
|
|
195
195
|
t,
|
|
196
196
|
v?.debounceTime,
|
|
197
197
|
g,
|
|
198
|
-
|
|
198
|
+
d,
|
|
199
199
|
e,
|
|
200
200
|
r
|
|
201
201
|
]
|
|
202
|
-
),
|
|
203
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
202
|
+
), S = L(() => {
|
|
203
|
+
const { getShadowMetadata: n, setShadowMetadata: i } = b.getState(), u = n(e, t);
|
|
204
204
|
if (u?.clientActivityState?.elements?.has(r)) {
|
|
205
205
|
const w = u.clientActivityState.elements.get(r);
|
|
206
206
|
w.currentActivity = {
|
|
207
207
|
type: "focus",
|
|
208
208
|
startTime: Date.now(),
|
|
209
209
|
details: {
|
|
210
|
-
value:
|
|
211
|
-
inputLength: typeof
|
|
210
|
+
value: a,
|
|
211
|
+
inputLength: typeof a == "string" ? a.length : void 0
|
|
212
212
|
}
|
|
213
|
-
},
|
|
213
|
+
}, i(e, t, u);
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
B({
|
|
216
216
|
stateKey: e,
|
|
217
217
|
activityType: "focus",
|
|
218
218
|
// Changed from 'type'
|
|
@@ -222,64 +222,66 @@ function Mt({
|
|
|
222
222
|
cursorPosition: m.current?.selectionStart
|
|
223
223
|
}
|
|
224
224
|
});
|
|
225
|
-
}, [e, t, r,
|
|
226
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
227
|
-
|
|
228
|
-
updateType: "update",
|
|
229
|
-
validationTrigger: "onBlur"
|
|
230
|
-
}));
|
|
225
|
+
}, [e, t, r, a]), W = L(() => {
|
|
226
|
+
const { getShadowMetadata: n, setShadowMetadata: i } = b.getState();
|
|
227
|
+
s.current && (clearTimeout(s.current), s.current = null, f.current = !1, p(a, t, { updateType: "update" }));
|
|
231
228
|
const u = n(e, t);
|
|
232
229
|
if (u?.clientActivityState?.elements?.has(r)) {
|
|
233
|
-
const
|
|
234
|
-
|
|
230
|
+
const M = u.clientActivityState.elements.get(r);
|
|
231
|
+
M.currentActivity = void 0, i(e, t, u);
|
|
235
232
|
}
|
|
236
233
|
const w = u?.clientActivityState?.elements?.get(r)?.currentActivity?.startTime;
|
|
237
|
-
|
|
234
|
+
at(e)?.validation?.onBlur && G(
|
|
235
|
+
{
|
|
236
|
+
stateKey: e,
|
|
237
|
+
path: t,
|
|
238
|
+
newValue: a,
|
|
239
|
+
updateType: "update"
|
|
240
|
+
},
|
|
241
|
+
"onBlur"
|
|
242
|
+
), B({
|
|
238
243
|
stateKey: e,
|
|
239
244
|
activityType: "blur",
|
|
240
|
-
// Changed from 'type'
|
|
241
245
|
path: t,
|
|
242
246
|
timestamp: Date.now(),
|
|
243
247
|
duration: w ? Date.now() - w : void 0,
|
|
244
248
|
details: {
|
|
245
249
|
duration: w ? Date.now() - w : 0
|
|
246
250
|
}
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
path: t,
|
|
250
|
-
newValue: i,
|
|
251
|
-
updateType: "update"
|
|
252
|
-
}, "onBlur");
|
|
253
|
-
}, [i, b, t, e, r, l]), L = o({
|
|
251
|
+
});
|
|
252
|
+
}, [a, p, t, e, r, d]), O = o({
|
|
254
253
|
path: t,
|
|
255
254
|
componentId: r,
|
|
256
255
|
meta: void 0
|
|
257
|
-
}),
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
}), k = st(e, t)?.validation, Y = k?.status || "NOT_VALIDATED", U = (k?.errors || []).map((n) => ({
|
|
257
|
+
...n,
|
|
258
|
+
path: t
|
|
259
|
+
})), _ = U.filter((n) => n.severity === "error").map((n) => n.message), H = U.filter((n) => n.severity === "warning").map((n) => n.message), Z = _[0] || H[0] || "", V = _.length > 0 ? "error" : H.length > 0 ? "warning" : void 0, K = new Proxy(O, {
|
|
260
|
+
get(n, i) {
|
|
261
|
+
return i === "$inputProps" ? {
|
|
262
|
+
value: a ?? "",
|
|
261
263
|
onChange: (u) => {
|
|
262
|
-
|
|
264
|
+
y(u.target.value);
|
|
263
265
|
},
|
|
264
|
-
onFocus:
|
|
265
|
-
onBlur:
|
|
266
|
+
onFocus: S,
|
|
267
|
+
onBlur: W,
|
|
266
268
|
ref: m
|
|
267
|
-
} : n[
|
|
269
|
+
} : i === "status" ? Y : i === "severity" ? V : i === "hasErrors" ? _.length > 0 : i === "hasWarnings" ? H.length > 0 : i === "allErrors" ? U : i === "message" ? Z : i === "getData" ? () => $(e, t) : n[i];
|
|
268
270
|
}
|
|
269
|
-
}),
|
|
270
|
-
return /* @__PURE__ */
|
|
271
|
+
}), tt = c(K);
|
|
272
|
+
return /* @__PURE__ */ C(dt, { formOpts: v, path: t, stateKey: e, children: tt });
|
|
271
273
|
}
|
|
272
|
-
function
|
|
274
|
+
function z(e, t, o) {
|
|
273
275
|
const c = `${e}////${t}`;
|
|
274
|
-
|
|
276
|
+
nt(() => (ct(e, c, {
|
|
275
277
|
forceUpdate: () => o({}),
|
|
276
278
|
paths: /* @__PURE__ */ new Set(),
|
|
277
279
|
reactiveType: ["component"]
|
|
278
280
|
}), () => {
|
|
279
|
-
|
|
281
|
+
lt(e, c);
|
|
280
282
|
}), [e, c]);
|
|
281
283
|
}
|
|
282
|
-
function
|
|
284
|
+
function Et({
|
|
283
285
|
stateKey: e,
|
|
284
286
|
path: t,
|
|
285
287
|
// The path of the parent node (e.g. ['form'])
|
|
@@ -288,65 +290,65 @@ function yt({
|
|
|
288
290
|
rebuildStateShape: c,
|
|
289
291
|
renderFn: v
|
|
290
292
|
}) {
|
|
291
|
-
const [
|
|
292
|
-
|
|
293
|
-
const
|
|
293
|
+
const [p] = R(() => X()), [, r] = R({});
|
|
294
|
+
z(e, p, r);
|
|
295
|
+
const l = ot(() => o && o.length > 0 ? o.map((h) => [e, ...h.$_path].join(".")) : [[e, ...t].join(".")], [e, t, o]);
|
|
294
296
|
P(() => {
|
|
295
|
-
const
|
|
297
|
+
const h = b.getState(), A = l.map((g) => h.subscribeToPath(g, () => {
|
|
296
298
|
r({});
|
|
297
299
|
}));
|
|
298
300
|
return () => {
|
|
299
301
|
A.forEach((g) => g());
|
|
300
302
|
};
|
|
301
|
-
}, [
|
|
303
|
+
}, [l]);
|
|
302
304
|
const m = c({
|
|
303
305
|
path: t,
|
|
304
|
-
componentId:
|
|
306
|
+
componentId: p,
|
|
305
307
|
meta: void 0
|
|
306
308
|
});
|
|
307
|
-
return /* @__PURE__ */
|
|
309
|
+
return /* @__PURE__ */ C(q, { children: v(m) });
|
|
308
310
|
}
|
|
309
|
-
|
|
311
|
+
Q(function({
|
|
310
312
|
children: t,
|
|
311
313
|
stateKey: o,
|
|
312
314
|
path: c,
|
|
313
315
|
pluginName: v,
|
|
314
|
-
wrapperDepth:
|
|
316
|
+
wrapperDepth: p
|
|
315
317
|
}) {
|
|
316
|
-
const [, r] =
|
|
318
|
+
const [, r] = R({});
|
|
317
319
|
P(() => {
|
|
318
320
|
const T = [o, ...c].join(".");
|
|
319
|
-
return
|
|
321
|
+
return b.getState().subscribeToPath(T, () => {
|
|
320
322
|
r({});
|
|
321
323
|
});
|
|
322
324
|
}, [o, c]);
|
|
323
|
-
const
|
|
324
|
-
if (!
|
|
325
|
-
return /* @__PURE__ */
|
|
326
|
-
const
|
|
325
|
+
const l = E.getState().registeredPlugins.find((T) => T.name === v), m = E.getState().stateHandlers.get(o), h = b.getState().getShadowNode(o, c)?._meta?.typeInfo, A = E.getState().pluginOptions.get(o)?.get(v), g = E.getState().getHookResult(o, v);
|
|
326
|
+
if (!l?.formWrapper || !m)
|
|
327
|
+
return /* @__PURE__ */ C(q, { children: t });
|
|
328
|
+
const d = et(m), a = J(
|
|
327
329
|
o,
|
|
328
|
-
|
|
330
|
+
l.name,
|
|
329
331
|
c
|
|
330
332
|
);
|
|
331
|
-
return
|
|
333
|
+
return l.formWrapper({
|
|
332
334
|
element: t,
|
|
333
335
|
path: c,
|
|
334
336
|
stateKey: o,
|
|
335
|
-
pluginName:
|
|
336
|
-
...
|
|
337
|
-
...
|
|
337
|
+
pluginName: l.name,
|
|
338
|
+
...d,
|
|
339
|
+
...a,
|
|
338
340
|
options: A,
|
|
339
341
|
hookData: g,
|
|
340
|
-
fieldType:
|
|
341
|
-
wrapperDepth:
|
|
342
|
+
fieldType: h?.type,
|
|
343
|
+
wrapperDepth: p
|
|
342
344
|
});
|
|
343
345
|
});
|
|
344
346
|
export {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
It as FormElementWrapper,
|
|
348
|
+
Et as IsolatedComponentWrapper,
|
|
349
|
+
gt as ListItemWrapper,
|
|
350
|
+
Dt as MemoizedCogsItemWrapper,
|
|
351
|
+
dt as ValidationWrapper,
|
|
352
|
+
z as useRegisterComponent
|
|
351
353
|
};
|
|
352
354
|
//# sourceMappingURL=Components.js.map
|