cogsbox-state 0.5.485 → 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 +7 -0
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.js.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +173 -170
- package/dist/Components.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +16 -9
- package/src/Components.tsx +44 -18
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,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC;IACjB,iBAAiB,EAAE,GAAG,CAAC;IACvB,QAAQ,EAAE,GAAG,C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
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { pluginStore as
|
|
3
|
-
import { createScopedMetadataContext as
|
|
4
|
-
import
|
|
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:
|
|
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
|
-
|
|
37
|
+
y[W] = {
|
|
38
38
|
hookData: O,
|
|
39
|
-
getFieldMetaData:
|
|
40
|
-
setFieldMetaData:
|
|
41
|
-
removeFieldMetaData:
|
|
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:
|
|
52
|
-
allErrors:
|
|
50
|
+
hasErrors: d.length > 0,
|
|
51
|
+
hasWarnings: a.length > 0,
|
|
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
|
-
arraySetter:
|
|
68
|
-
rebuildStateShape:
|
|
67
|
+
arraySetter: v,
|
|
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 () =>
|
|
84
|
-
}, [
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const T =
|
|
88
|
-
currentState:
|
|
83
|
+
return () => s();
|
|
84
|
+
}, [g]);
|
|
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
|
-
}), f = r(T, c,
|
|
92
|
-
return
|
|
93
|
-
ref: (
|
|
94
|
-
|
|
95
|
-
const { ref:
|
|
96
|
-
typeof
|
|
91
|
+
}), f = r(T, c, v);
|
|
92
|
+
return j.isValidElement(f) ? j.cloneElement(f, {
|
|
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
|
-
formOpts:
|
|
106
|
-
setState:
|
|
105
|
+
formOpts: v,
|
|
106
|
+
setState: p
|
|
107
107
|
}) {
|
|
108
|
-
const r = N(
|
|
109
|
-
|
|
110
|
-
const
|
|
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
|
};
|
|
133
133
|
u.clientActivityState.elements.set(r, {
|
|
134
|
-
domRef:
|
|
134
|
+
domRef: m,
|
|
135
135
|
elementType: w(),
|
|
136
|
-
inputType:
|
|
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,72 +174,72 @@ 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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
v?.debounceTime,
|
|
197
|
+
g,
|
|
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'
|
|
219
219
|
path: t,
|
|
220
220
|
timestamp: Date.now(),
|
|
221
221
|
details: {
|
|
222
|
-
cursorPosition:
|
|
222
|
+
cursorPosition: m.current?.selectionStart
|
|
223
223
|
}
|
|
224
224
|
});
|
|
225
|
-
}, [e, t, r,
|
|
226
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
227
|
-
|
|
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" }));
|
|
228
228
|
const u = n(e, t);
|
|
229
229
|
if (u?.clientActivityState?.elements?.has(r)) {
|
|
230
|
-
const
|
|
231
|
-
|
|
230
|
+
const M = u.clientActivityState.elements.get(r);
|
|
231
|
+
M.currentActivity = void 0, i(e, t, u);
|
|
232
232
|
}
|
|
233
233
|
const w = u?.clientActivityState?.elements?.get(r)?.currentActivity?.startTime;
|
|
234
|
-
|
|
234
|
+
at(e)?.validation?.onBlur && G(
|
|
235
235
|
{
|
|
236
236
|
stateKey: e,
|
|
237
237
|
path: t,
|
|
238
|
-
newValue:
|
|
238
|
+
newValue: a,
|
|
239
239
|
updateType: "update"
|
|
240
240
|
},
|
|
241
241
|
"onBlur"
|
|
242
|
-
),
|
|
242
|
+
), B({
|
|
243
243
|
stateKey: e,
|
|
244
244
|
activityType: "blur",
|
|
245
245
|
path: t,
|
|
@@ -249,103 +249,106 @@ function Mt({
|
|
|
249
249
|
duration: w ? Date.now() - w : 0
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
|
-
}, [
|
|
252
|
+
}, [a, p, t, e, r, d]), O = o({
|
|
253
253
|
path: t,
|
|
254
254
|
componentId: r,
|
|
255
255
|
meta: void 0
|
|
256
|
-
}),
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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 ?? "",
|
|
260
263
|
onChange: (u) => {
|
|
261
|
-
|
|
264
|
+
y(u.target.value);
|
|
262
265
|
},
|
|
263
|
-
onFocus:
|
|
264
|
-
onBlur:
|
|
265
|
-
ref:
|
|
266
|
-
} : n[
|
|
266
|
+
onFocus: S,
|
|
267
|
+
onBlur: W,
|
|
268
|
+
ref: m
|
|
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];
|
|
267
270
|
}
|
|
268
|
-
}),
|
|
269
|
-
return /* @__PURE__ */
|
|
271
|
+
}), tt = c(K);
|
|
272
|
+
return /* @__PURE__ */ C(dt, { formOpts: v, path: t, stateKey: e, children: tt });
|
|
270
273
|
}
|
|
271
|
-
function
|
|
274
|
+
function z(e, t, o) {
|
|
272
275
|
const c = `${e}////${t}`;
|
|
273
|
-
|
|
276
|
+
nt(() => (ct(e, c, {
|
|
274
277
|
forceUpdate: () => o({}),
|
|
275
278
|
paths: /* @__PURE__ */ new Set(),
|
|
276
279
|
reactiveType: ["component"]
|
|
277
280
|
}), () => {
|
|
278
|
-
|
|
281
|
+
lt(e, c);
|
|
279
282
|
}), [e, c]);
|
|
280
283
|
}
|
|
281
|
-
function
|
|
284
|
+
function Et({
|
|
282
285
|
stateKey: e,
|
|
283
286
|
path: t,
|
|
284
287
|
// The path of the parent node (e.g. ['form'])
|
|
285
288
|
dependencies: o,
|
|
286
289
|
// NEW: Optional array of Proxy objects or path arrays
|
|
287
290
|
rebuildStateShape: c,
|
|
288
|
-
renderFn:
|
|
291
|
+
renderFn: v
|
|
289
292
|
}) {
|
|
290
|
-
const [
|
|
291
|
-
|
|
292
|
-
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]);
|
|
293
296
|
P(() => {
|
|
294
|
-
const
|
|
297
|
+
const h = b.getState(), A = l.map((g) => h.subscribeToPath(g, () => {
|
|
295
298
|
r({});
|
|
296
299
|
}));
|
|
297
300
|
return () => {
|
|
298
|
-
A.forEach((
|
|
301
|
+
A.forEach((g) => g());
|
|
299
302
|
};
|
|
300
|
-
}, [
|
|
301
|
-
const
|
|
303
|
+
}, [l]);
|
|
304
|
+
const m = c({
|
|
302
305
|
path: t,
|
|
303
|
-
componentId:
|
|
306
|
+
componentId: p,
|
|
304
307
|
meta: void 0
|
|
305
308
|
});
|
|
306
|
-
return /* @__PURE__ */
|
|
309
|
+
return /* @__PURE__ */ C(q, { children: v(m) });
|
|
307
310
|
}
|
|
308
|
-
|
|
311
|
+
Q(function({
|
|
309
312
|
children: t,
|
|
310
313
|
stateKey: o,
|
|
311
314
|
path: c,
|
|
312
|
-
pluginName:
|
|
313
|
-
wrapperDepth:
|
|
315
|
+
pluginName: v,
|
|
316
|
+
wrapperDepth: p
|
|
314
317
|
}) {
|
|
315
|
-
const [, r] =
|
|
318
|
+
const [, r] = R({});
|
|
316
319
|
P(() => {
|
|
317
320
|
const T = [o, ...c].join(".");
|
|
318
|
-
return
|
|
321
|
+
return b.getState().subscribeToPath(T, () => {
|
|
319
322
|
r({});
|
|
320
323
|
});
|
|
321
324
|
}, [o, c]);
|
|
322
|
-
const
|
|
323
|
-
if (!
|
|
324
|
-
return /* @__PURE__ */
|
|
325
|
-
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(
|
|
326
329
|
o,
|
|
327
|
-
|
|
330
|
+
l.name,
|
|
328
331
|
c
|
|
329
332
|
);
|
|
330
|
-
return
|
|
333
|
+
return l.formWrapper({
|
|
331
334
|
element: t,
|
|
332
335
|
path: c,
|
|
333
336
|
stateKey: o,
|
|
334
|
-
pluginName:
|
|
335
|
-
...
|
|
336
|
-
...
|
|
337
|
+
pluginName: l.name,
|
|
338
|
+
...d,
|
|
339
|
+
...a,
|
|
337
340
|
options: A,
|
|
338
|
-
hookData:
|
|
339
|
-
fieldType:
|
|
340
|
-
wrapperDepth:
|
|
341
|
+
hookData: g,
|
|
342
|
+
fieldType: h?.type,
|
|
343
|
+
wrapperDepth: p
|
|
341
344
|
});
|
|
342
345
|
});
|
|
343
346
|
export {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
It as FormElementWrapper,
|
|
348
|
+
Et as IsolatedComponentWrapper,
|
|
349
|
+
gt as ListItemWrapper,
|
|
350
|
+
Dt as MemoizedCogsItemWrapper,
|
|
351
|
+
dt as ValidationWrapper,
|
|
352
|
+
z as useRegisterComponent
|
|
350
353
|
};
|
|
351
354
|
//# sourceMappingURL=Components.js.map
|