cogsbox-state 0.5.484 → 0.5.485
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 +1 -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 +86 -87
- 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 +51 -21
- package/src/Components.tsx +19 -21
- 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,12 +1,12 @@
|
|
|
1
|
-
import { jsx as E, Fragment as
|
|
1
|
+
import { jsx as E, Fragment as H } from "react/jsx-runtime";
|
|
2
2
|
import { pluginStore as C } from "./pluginStore.js";
|
|
3
3
|
import { createScopedMetadataContext as $, toDeconstructedMethods as Q } from "./plugins.js";
|
|
4
|
-
import
|
|
4
|
+
import L, { memo as q, useState as F, useRef as N, useCallback as j, useEffect as P, useLayoutEffect as X, useMemo as Y } from "react";
|
|
5
5
|
import { getGlobalStore as M } from "./store.js";
|
|
6
6
|
import { useInView as Z } from "react-intersection-observer";
|
|
7
7
|
import { v4 as z } from "uuid";
|
|
8
8
|
import { isDeepEqual as V } from "./utility.js";
|
|
9
|
-
import { runValidation as
|
|
9
|
+
import { runValidation as B } from "./validation.js";
|
|
10
10
|
const {
|
|
11
11
|
getInitialOptions: K,
|
|
12
12
|
getShadowMetadata: ft,
|
|
@@ -23,37 +23,37 @@ function ot({
|
|
|
23
23
|
stateKey: o,
|
|
24
24
|
children: c
|
|
25
25
|
}) {
|
|
26
|
-
const { getInitialOptions:
|
|
26
|
+
const { getInitialOptions: S, getShadowMetadata: v, getShadowValue: r } = M.getState(), s = S(o), y = v(o, t)?.validation, A = y?.status || "NOT_VALIDATED", m = (y?.errors || []).map((p) => ({
|
|
27
27
|
...p,
|
|
28
28
|
path: t
|
|
29
|
-
})), l =
|
|
29
|
+
})), l = m.filter((p) => p.severity === "error").map((p) => p.message), i = m.filter((p) => p.severity === "warning").map((p) => p.message), T = l[0] || i[0], f = l.length > 0 ? "error" : i.length > 0 ? "warning" : void 0, { registeredPlugins: a } = C.getState(), h = {};
|
|
30
30
|
return a.forEach((p) => {
|
|
31
31
|
if (s && s.hasOwnProperty(p.name)) {
|
|
32
|
-
const R = p.name,
|
|
32
|
+
const R = p.name, O = C.getState().getHookResult(o, R), W = $(
|
|
33
33
|
o,
|
|
34
34
|
R,
|
|
35
35
|
t
|
|
36
36
|
);
|
|
37
37
|
h[R] = {
|
|
38
|
-
hookData:
|
|
38
|
+
hookData: O,
|
|
39
39
|
getFieldMetaData: W.getFieldMetaData,
|
|
40
40
|
setFieldMetaData: W.setFieldMetaData,
|
|
41
41
|
removeFieldMetaData: W.removeFieldMetaData
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
}), /* @__PURE__ */ E(
|
|
45
|
-
children: /* @__PURE__ */ E(
|
|
44
|
+
}), /* @__PURE__ */ E(H, { children: s?.formElements?.validation && !e?.validation?.disable ? s.formElements.validation({
|
|
45
|
+
children: /* @__PURE__ */ E(L.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
50
|
hasErrors: l.length > 0,
|
|
51
51
|
hasWarnings: i.length > 0,
|
|
52
|
-
allErrors:
|
|
52
|
+
allErrors: m,
|
|
53
53
|
path: t,
|
|
54
54
|
getData: () => r(o, t),
|
|
55
55
|
plugins: h
|
|
56
|
-
}) : /* @__PURE__ */ E(
|
|
56
|
+
}) : /* @__PURE__ */ E(L.Fragment, { children: c }, t.toString()) });
|
|
57
57
|
}
|
|
58
58
|
const bt = q(
|
|
59
59
|
rt,
|
|
@@ -64,32 +64,32 @@ function rt({
|
|
|
64
64
|
itemComponentId: t,
|
|
65
65
|
itemPath: o,
|
|
66
66
|
localIndex: c,
|
|
67
|
-
arraySetter:
|
|
68
|
-
rebuildStateShape:
|
|
67
|
+
arraySetter: S,
|
|
68
|
+
rebuildStateShape: v,
|
|
69
69
|
renderFn: r
|
|
70
70
|
}) {
|
|
71
|
-
const [, s] = F({}), { ref:
|
|
72
|
-
|
|
73
|
-
const l =
|
|
71
|
+
const [, s] = F({}), { ref: g, inView: y } = Z(), A = N(null), m = [e, ...o].join(".");
|
|
72
|
+
_(e, t, s);
|
|
73
|
+
const l = j(
|
|
74
74
|
(a) => {
|
|
75
|
-
A.current = a,
|
|
75
|
+
A.current = a, g(a);
|
|
76
76
|
},
|
|
77
|
-
[
|
|
77
|
+
[g]
|
|
78
78
|
);
|
|
79
79
|
P(() => {
|
|
80
|
-
const a = nt(
|
|
80
|
+
const a = nt(m, (h) => {
|
|
81
81
|
s({});
|
|
82
82
|
});
|
|
83
83
|
return () => a();
|
|
84
|
-
}, [
|
|
84
|
+
}, [m]);
|
|
85
85
|
const i = G(e, o);
|
|
86
86
|
if (i === void 0) return null;
|
|
87
|
-
const T =
|
|
87
|
+
const T = v({
|
|
88
88
|
currentState: i,
|
|
89
89
|
path: o,
|
|
90
90
|
componentId: t
|
|
91
|
-
}), f = r(T, c,
|
|
92
|
-
return
|
|
91
|
+
}), f = r(T, c, S);
|
|
92
|
+
return L.isValidElement(f) ? L.cloneElement(f, {
|
|
93
93
|
ref: (a) => {
|
|
94
94
|
l(a);
|
|
95
95
|
const { ref: h } = f;
|
|
@@ -102,12 +102,12 @@ function Mt({
|
|
|
102
102
|
path: t,
|
|
103
103
|
rebuildStateShape: o,
|
|
104
104
|
renderFn: c,
|
|
105
|
-
formOpts:
|
|
106
|
-
setState:
|
|
105
|
+
formOpts: S,
|
|
106
|
+
setState: v
|
|
107
107
|
}) {
|
|
108
|
-
const r = N(z()).current, [, s] = F({}),
|
|
109
|
-
|
|
110
|
-
const
|
|
108
|
+
const r = N(z()).current, [, s] = F({}), g = N(null), y = [e, ...t].join(".");
|
|
109
|
+
_(e, r, s);
|
|
110
|
+
const m = M.getState().getShadowNode(e, t)?._meta?.typeInfo, l = G(e, t), [i, T] = F(l), f = N(!1), a = N(null);
|
|
111
111
|
P(() => {
|
|
112
112
|
!f.current && !V(l, i) && T(l);
|
|
113
113
|
}, [l]), P(() => {
|
|
@@ -116,13 +116,13 @@ function Mt({
|
|
|
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 b = g.current;
|
|
120
|
+
if (!b) return "input";
|
|
121
|
+
const x = b.tagName.toLowerCase();
|
|
122
122
|
if (x === "textarea") return "textarea";
|
|
123
123
|
if (x === "select") return "select";
|
|
124
124
|
if (x === "input") {
|
|
125
|
-
const k =
|
|
125
|
+
const k = b.type;
|
|
126
126
|
if (k === "checkbox") return "checkbox";
|
|
127
127
|
if (k === "radio") return "radio";
|
|
128
128
|
if (k === "range") return "range";
|
|
@@ -131,23 +131,23 @@ function Mt({
|
|
|
131
131
|
return "input";
|
|
132
132
|
};
|
|
133
133
|
u.clientActivityState.elements.set(r, {
|
|
134
|
-
domRef:
|
|
134
|
+
domRef: g,
|
|
135
135
|
elementType: w(),
|
|
136
|
-
inputType:
|
|
136
|
+
inputType: g.current?.type,
|
|
137
137
|
mountedAt: Date.now()
|
|
138
138
|
}), console.log("currentMeta", u), d(e, t, u);
|
|
139
|
-
const D = M.getState().subscribeToPath(y, (
|
|
140
|
-
!f.current && i !==
|
|
139
|
+
const D = M.getState().subscribeToPath(y, (b) => {
|
|
140
|
+
!f.current && i !== b && s({});
|
|
141
141
|
});
|
|
142
142
|
return () => {
|
|
143
143
|
D(), a.current && (clearTimeout(a.current), f.current = !1);
|
|
144
|
-
const
|
|
145
|
-
|
|
144
|
+
const b = M.getState().getShadowMetadata(e, t);
|
|
145
|
+
b?.clientActivityState?.elements && (b.clientActivityState.elements.delete(r), d(e, t, b));
|
|
146
146
|
};
|
|
147
147
|
}, []);
|
|
148
|
-
const h =
|
|
148
|
+
const h = j(
|
|
149
149
|
(n) => {
|
|
150
|
-
const d = M.getState().getShadowNode(e, t)?._meta?.typeInfo ??
|
|
150
|
+
const d = M.getState().getShadowNode(e, t)?._meta?.typeInfo ?? m;
|
|
151
151
|
d ? d.type === "number" && typeof n == "string" ? n = n === "" ? d.nullable ? null : d.default ?? 0 : Number(n) : d.type === "boolean" && typeof n == "string" ? n = n === "true" || n === "1" : d.type === "date" && typeof n == "string" && (n = new Date(n)) : typeof l === "number" && typeof n == "string" && (n = n === "" ? 0 : Number(n)), T(n);
|
|
152
152
|
const { getShadowMetadata: u, setShadowMetadata: w } = M.getState(), D = u(e, t);
|
|
153
153
|
if (D?.clientActivityState?.elements?.has(r)) {
|
|
@@ -160,7 +160,7 @@ function Mt({
|
|
|
160
160
|
keystrokeCount: (I.currentActivity.details?.keystrokeCount || 0) + 1
|
|
161
161
|
}, w(e, t, D));
|
|
162
162
|
}
|
|
163
|
-
const
|
|
163
|
+
const b = D?.clientActivityState?.elements?.get(r);
|
|
164
164
|
U({
|
|
165
165
|
stateKey: e,
|
|
166
166
|
activityType: "input",
|
|
@@ -174,32 +174,32 @@ 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: (b?.currentActivity?.details?.keystrokeCount || 0) + 1
|
|
178
178
|
}
|
|
179
|
-
}),
|
|
179
|
+
}), B({
|
|
180
180
|
stateKey: e,
|
|
181
181
|
path: t,
|
|
182
182
|
newValue: n,
|
|
183
183
|
updateType: "update"
|
|
184
184
|
}, "onChange"), f.current = !0, a.current && clearTimeout(a.current);
|
|
185
|
-
const k =
|
|
185
|
+
const k = S?.debounceTime ?? 200;
|
|
186
186
|
a.current = setTimeout(() => {
|
|
187
|
-
f.current = !1,
|
|
187
|
+
f.current = !1, v(n, t, {
|
|
188
188
|
updateType: "update",
|
|
189
189
|
validationTrigger: "onChange"
|
|
190
190
|
});
|
|
191
191
|
}, k);
|
|
192
192
|
},
|
|
193
193
|
[
|
|
194
|
-
|
|
194
|
+
v,
|
|
195
195
|
t,
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
S?.debounceTime,
|
|
197
|
+
m,
|
|
198
198
|
l,
|
|
199
199
|
e,
|
|
200
200
|
r
|
|
201
201
|
]
|
|
202
|
-
), p =
|
|
202
|
+
), p = j(() => {
|
|
203
203
|
const { getShadowMetadata: n, setShadowMetadata: d } = M.getState(), u = n(e, t);
|
|
204
204
|
if (u?.clientActivityState?.elements?.has(r)) {
|
|
205
205
|
const w = u.clientActivityState.elements.get(r);
|
|
@@ -219,42 +219,41 @@ function Mt({
|
|
|
219
219
|
path: t,
|
|
220
220
|
timestamp: Date.now(),
|
|
221
221
|
details: {
|
|
222
|
-
cursorPosition:
|
|
222
|
+
cursorPosition: g.current?.selectionStart
|
|
223
223
|
}
|
|
224
224
|
});
|
|
225
|
-
}, [e, t, r, i]), R =
|
|
225
|
+
}, [e, t, r, i]), R = j(() => {
|
|
226
226
|
const { getShadowMetadata: n, setShadowMetadata: d } = M.getState();
|
|
227
|
-
a.current && (clearTimeout(a.current), a.current = null, f.current = !1,
|
|
228
|
-
updateType: "update",
|
|
229
|
-
validationTrigger: "onBlur"
|
|
230
|
-
}));
|
|
227
|
+
a.current && (clearTimeout(a.current), a.current = null, f.current = !1, v(i, t, { updateType: "update" }));
|
|
231
228
|
const u = n(e, t);
|
|
232
229
|
if (u?.clientActivityState?.elements?.has(r)) {
|
|
233
|
-
const
|
|
234
|
-
|
|
230
|
+
const b = u.clientActivityState.elements.get(r);
|
|
231
|
+
b.currentActivity = void 0, d(e, t, u);
|
|
235
232
|
}
|
|
236
233
|
const w = u?.clientActivityState?.elements?.get(r)?.currentActivity?.startTime;
|
|
237
|
-
|
|
234
|
+
K(e)?.validation?.onBlur && B(
|
|
235
|
+
{
|
|
236
|
+
stateKey: e,
|
|
237
|
+
path: t,
|
|
238
|
+
newValue: i,
|
|
239
|
+
updateType: "update"
|
|
240
|
+
},
|
|
241
|
+
"onBlur"
|
|
242
|
+
), U({
|
|
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
|
+
}, [i, v, t, e, r, l]), O = o({
|
|
254
253
|
path: t,
|
|
255
254
|
componentId: r,
|
|
256
255
|
meta: void 0
|
|
257
|
-
}), W = new Proxy(
|
|
256
|
+
}), W = new Proxy(O, {
|
|
258
257
|
get(n, d) {
|
|
259
258
|
return d === "$inputProps" ? {
|
|
260
259
|
value: i ?? "",
|
|
@@ -263,13 +262,13 @@ function Mt({
|
|
|
263
262
|
},
|
|
264
263
|
onFocus: p,
|
|
265
264
|
onBlur: R,
|
|
266
|
-
ref:
|
|
265
|
+
ref: g
|
|
267
266
|
} : n[d];
|
|
268
267
|
}
|
|
269
268
|
}), J = c(W);
|
|
270
|
-
return /* @__PURE__ */ E(ot, { formOpts:
|
|
269
|
+
return /* @__PURE__ */ E(ot, { formOpts: S, path: t, stateKey: e, children: J });
|
|
271
270
|
}
|
|
272
|
-
function
|
|
271
|
+
function _(e, t, o) {
|
|
273
272
|
const c = `${e}////${t}`;
|
|
274
273
|
X(() => (tt(e, c, {
|
|
275
274
|
forceUpdate: () => o({}),
|
|
@@ -286,32 +285,32 @@ function yt({
|
|
|
286
285
|
dependencies: o,
|
|
287
286
|
// NEW: Optional array of Proxy objects or path arrays
|
|
288
287
|
rebuildStateShape: c,
|
|
289
|
-
renderFn:
|
|
288
|
+
renderFn: S
|
|
290
289
|
}) {
|
|
291
|
-
const [
|
|
292
|
-
|
|
290
|
+
const [v] = F(() => z()), [, r] = F({});
|
|
291
|
+
_(e, v, r);
|
|
293
292
|
const s = Y(() => o && o.length > 0 ? o.map((y) => [e, ...y.$_path].join(".")) : [[e, ...t].join(".")], [e, t, o]);
|
|
294
293
|
P(() => {
|
|
295
|
-
const y = M.getState(), A = s.map((
|
|
294
|
+
const y = M.getState(), A = s.map((m) => y.subscribeToPath(m, () => {
|
|
296
295
|
r({});
|
|
297
296
|
}));
|
|
298
297
|
return () => {
|
|
299
|
-
A.forEach((
|
|
298
|
+
A.forEach((m) => m());
|
|
300
299
|
};
|
|
301
300
|
}, [s]);
|
|
302
|
-
const
|
|
301
|
+
const g = c({
|
|
303
302
|
path: t,
|
|
304
|
-
componentId:
|
|
303
|
+
componentId: v,
|
|
305
304
|
meta: void 0
|
|
306
305
|
});
|
|
307
|
-
return /* @__PURE__ */ E(
|
|
306
|
+
return /* @__PURE__ */ E(H, { children: S(g) });
|
|
308
307
|
}
|
|
309
308
|
q(function({
|
|
310
309
|
children: t,
|
|
311
310
|
stateKey: o,
|
|
312
311
|
path: c,
|
|
313
|
-
pluginName:
|
|
314
|
-
wrapperDepth:
|
|
312
|
+
pluginName: S,
|
|
313
|
+
wrapperDepth: v
|
|
315
314
|
}) {
|
|
316
315
|
const [, r] = F({});
|
|
317
316
|
P(() => {
|
|
@@ -320,10 +319,10 @@ q(function({
|
|
|
320
319
|
r({});
|
|
321
320
|
});
|
|
322
321
|
}, [o, c]);
|
|
323
|
-
const s = C.getState().registeredPlugins.find((T) => T.name ===
|
|
324
|
-
if (!s?.formWrapper || !
|
|
325
|
-
return /* @__PURE__ */ E(
|
|
326
|
-
const l = Q(
|
|
322
|
+
const s = C.getState().registeredPlugins.find((T) => T.name === S), g = C.getState().stateHandlers.get(o), y = M.getState().getShadowNode(o, c)?._meta?.typeInfo, A = C.getState().pluginOptions.get(o)?.get(S), m = C.getState().getHookResult(o, S);
|
|
323
|
+
if (!s?.formWrapper || !g)
|
|
324
|
+
return /* @__PURE__ */ E(H, { children: t });
|
|
325
|
+
const l = Q(g), i = $(
|
|
327
326
|
o,
|
|
328
327
|
s.name,
|
|
329
328
|
c
|
|
@@ -336,9 +335,9 @@ q(function({
|
|
|
336
335
|
...l,
|
|
337
336
|
...i,
|
|
338
337
|
options: A,
|
|
339
|
-
hookData:
|
|
338
|
+
hookData: m,
|
|
340
339
|
fieldType: y?.type,
|
|
341
|
-
wrapperDepth:
|
|
340
|
+
wrapperDepth: v
|
|
342
341
|
});
|
|
343
342
|
});
|
|
344
343
|
export {
|
|
@@ -347,6 +346,6 @@ export {
|
|
|
347
346
|
rt as ListItemWrapper,
|
|
348
347
|
bt as MemoizedCogsItemWrapper,
|
|
349
348
|
ot as ValidationWrapper,
|
|
350
|
-
|
|
349
|
+
_ as useRegisterComponent
|
|
351
350
|
};
|
|
352
351
|
//# sourceMappingURL=Components.js.map
|
package/dist/Components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components.js","sources":["../src/Components.tsx"],"sourcesContent":["import {\r\n FormElementParams,\r\n StateObject,\r\n UpdateTypeDetail,\r\n type FormOptsType,\r\n} from './CogsState';\r\nimport { pluginStore } from './pluginStore';\r\nimport {\r\n createMetadataContext,\r\n createScopedMetadataContext,\r\n PluginsApi,\r\n toDeconstructedMethods,\r\n} from './plugins';\r\nimport React, {\r\n memo,\r\n RefObject,\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useRef,\r\n useState,\r\n useMemo,\r\n type ReactNode,\r\n} from 'react';\r\nimport { getGlobalStore, ValidationError, ValidationSeverity } from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\r\nimport { runValidation } from './validation';\r\n\r\nconst {\r\n getInitialOptions,\r\n\r\n getShadowMetadata,\r\n setShadowMetadata,\r\n getShadowValue,\r\n\r\n registerComponent,\r\n unregisterComponent,\r\n\r\n notifyPathSubscribers,\r\n subscribeToPath,\r\n} = getGlobalStore.getState();\r\nconst { stateHandlers, notifyFormUpdate } = pluginStore.getState();\r\n\r\nexport type ValidationWrapperProps = {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n stateKey: string;\r\n children: ReactNode;\r\n};\r\n\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n stateKey,\r\n children,\r\n}: ValidationWrapperProps) {\r\n const { getInitialOptions, getShadowMetadata, getShadowValue } =\r\n getGlobalStore.getState();\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n\r\n const shadowMeta = getShadowMetadata(stateKey!, path);\r\n const validationState = shadowMeta?.validation;\r\n\r\n const status = validationState?.status || 'NOT_VALIDATED';\r\n\r\n const errors = (validationState?.errors || []).map((err) => ({\r\n ...err,\r\n path: path,\r\n })) as ValidationError[];\r\n const errorMessages = errors\r\n .filter((err) => err.severity === 'error')\r\n .map((err) => err.message);\r\n const warningMessages = errors\r\n .filter((err) => err.severity === 'warning')\r\n .map((err) => err.message);\r\n\r\n // Use first error, or first warning if no errors\r\n const message = errorMessages[0] || warningMessages[0];\r\n const primarySeverity: ValidationSeverity =\r\n errorMessages.length > 0\r\n ? 'error'\r\n : warningMessages.length > 0\r\n ? 'warning'\r\n : undefined;\r\n const { registeredPlugins } = pluginStore.getState();\r\n const pluginsApi: PluginsApi = {};\r\n\r\n // We iterate over ALL registered plugins in the app.\r\n registeredPlugins.forEach((plugin) => {\r\n if (thisStateOpts && thisStateOpts.hasOwnProperty(plugin.name)) {\r\n const pluginName = plugin.name;\r\n\r\n const hookData = pluginStore\r\n .getState()\r\n .getHookResult(stateKey!, pluginName);\r\n\r\n const scopedMetadata = createScopedMetadataContext(\r\n stateKey!,\r\n pluginName,\r\n path\r\n );\r\n\r\n pluginsApi[pluginName] = {\r\n hookData,\r\n getFieldMetaData: scopedMetadata.getFieldMetaData,\r\n setFieldMetaData: scopedMetadata.setFieldMetaData,\r\n removeFieldMetaData: scopedMetadata.removeFieldMetaData,\r\n };\r\n }\r\n });\r\n\r\n return (\r\n <>\r\n {thisStateOpts?.formElements?.validation &&\r\n !formOpts?.validation?.disable ? (\r\n thisStateOpts.formElements!.validation!({\r\n children: (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n ),\r\n status, // Now passes the new ValidationStatus type\r\n message: formOpts?.validation?.hideMessage\r\n ? ''\r\n : formOpts?.validation?.message || message || '',\r\n severity: primarySeverity,\r\n hasErrors: errorMessages.length > 0,\r\n hasWarnings: warningMessages.length > 0,\r\n allErrors: errors,\r\n path: path,\r\n getData: () => getShadowValue(stateKey!, path),\r\n plugins: pluginsApi,\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\nexport const MemoizedCogsItemWrapper = memo(\r\n ListItemWrapper,\r\n (prevProps, nextProps) => {\r\n // Re-render if any of these change:\r\n return (\r\n prevProps.itemPath.join('.') === nextProps.itemPath.join('.') &&\r\n prevProps.stateKey === nextProps.stateKey &&\r\n prevProps.itemComponentId === nextProps.itemComponentId &&\r\n prevProps.localIndex === nextProps.localIndex\r\n );\r\n }\r\n);\r\n\r\nexport function ListItemWrapper({\r\n stateKey,\r\n itemComponentId,\r\n itemPath,\r\n localIndex,\r\n arraySetter,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n itemComponentId: string;\r\n itemPath: string[];\r\n localIndex: number;\r\n arraySetter: any;\r\n rebuildStateShape: any;\r\n renderFn: any;\r\n}) {\r\n const [, forceUpdate] = useState({});\r\n const { ref: inViewRef, inView } = useInView();\r\n const elementRef = useRef<HTMLElement | null>(null); // Changed to HTMLElement to be generic\r\n\r\n const fullKey = [stateKey, ...itemPath].join('.');\r\n\r\n useRegisterComponent(stateKey, itemComponentId, forceUpdate);\r\n\r\n const setRefs = useCallback(\r\n (element: HTMLElement | null) => {\r\n elementRef.current = element;\r\n inViewRef(element);\r\n },\r\n [inViewRef]\r\n );\r\n\r\n useEffect(() => {\r\n const unsubscribe = subscribeToPath(fullKey, (e) => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [fullKey]);\r\n\r\n const itemValue = getShadowValue(stateKey, itemPath);\r\n if (itemValue === undefined) return null;\r\n\r\n const itemSetter = rebuildStateShape({\r\n currentState: itemValue,\r\n path: itemPath,\r\n componentId: itemComponentId,\r\n });\r\n\r\n // 1. Render the user's content (e.g. the <tr>)\r\n const children = renderFn(itemSetter, localIndex, arraySetter);\r\n\r\n // 2. AUTO-DETECT: If it is a single valid element (<tr>, <div>, <li>), inject the ref.\r\n if (React.isValidElement(children)) {\r\n // We clone the element and force our ref onto it\r\n return React.cloneElement(children as React.ReactElement<any>, {\r\n ref: (node: any) => {\r\n // Apply our virtualization ref\r\n setRefs(node);\r\n\r\n // Preserve any ref the user might have put on the element themselves\r\n const { ref: existingRef } = children as any;\r\n if (typeof existingRef === 'function') {\r\n existingRef(node);\r\n } else if (existingRef && 'current' in existingRef) {\r\n (existingRef as any).current = node;\r\n }\r\n },\r\n });\r\n }\r\n\r\n // 3. Fallback: If they returned a Fragment or string, we MUST wrap it to measure it.\r\n // (Note: This specific fallback will still break inside a <tbody>, but\r\n // as long as you return a <tr> above, line 90 catches it).\r\n return <div ref={setRefs}>{children}</div>;\r\n}\r\n\r\nexport function FormElementWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n formOpts,\r\n setState,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (params: FormElementParams<any>) => ReactNode;\r\n formOpts?: FormOptsType;\r\n setState: any;\r\n}) {\r\n const componentId = useRef(uuidv4()).current;\r\n\r\n const [, forceUpdate] = useState({});\r\n const formElementRef = useRef<any>(null);\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n // Get the shadow node to access typeInfo and schema\r\n const shadowNode = getGlobalStore.getState().getShadowNode(stateKey, path);\r\n const typeInfo = shadowNode?._meta?.typeInfo;\r\n\r\n const globalStateValue = getShadowValue(stateKey, path);\r\n const [localValue, setLocalValue] = useState<any>(globalStateValue);\r\n const isCurrentlyDebouncing = useRef(false);\r\n const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);\r\n\r\n useEffect(() => {\r\n if (\r\n !isCurrentlyDebouncing.current &&\r\n !isDeepEqual(globalStateValue, localValue)\r\n ) {\r\n setLocalValue(globalStateValue);\r\n }\r\n }, [globalStateValue]);\r\n\r\n useEffect(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n console.log('FormElementWrapper effect running for:', stateKey, path);\r\n\r\n // Initialize clientActivityState if needed\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n if (!currentMeta.clientActivityState) {\r\n currentMeta.clientActivityState = { elements: new Map() };\r\n }\r\n\r\n // Detect element type from the ref\r\n const detectElementType = () => {\r\n const el = formElementRef.current;\r\n if (!el) return 'input';\r\n const tagName = el.tagName.toLowerCase();\r\n if (tagName === 'textarea') return 'textarea';\r\n if (tagName === 'select') return 'select';\r\n if (tagName === 'input') {\r\n const type = (el as HTMLInputElement).type;\r\n if (type === 'checkbox') return 'checkbox';\r\n if (type === 'radio') return 'radio';\r\n if (type === 'range') return 'range';\r\n if (type === 'file') return 'file';\r\n }\r\n return 'input';\r\n };\r\n\r\n // Add this element to the Map\r\n currentMeta.clientActivityState.elements.set(componentId, {\r\n domRef: formElementRef,\r\n elementType: detectElementType(),\r\n inputType: formElementRef.current?.type,\r\n mountedAt: Date.now(),\r\n });\r\n console.log('currentMeta', currentMeta);\r\n setShadowMetadata(stateKey, path, currentMeta);\r\n\r\n // Subscribe to path updates\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, (newValue) => {\r\n if (!isCurrentlyDebouncing.current && localValue !== newValue) {\r\n forceUpdate({});\r\n }\r\n });\r\n\r\n // Cleanup\r\n return () => {\r\n unsubscribe();\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n\r\n // Remove element from Map\r\n const meta = getGlobalStore.getState().getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements) {\r\n meta.clientActivityState.elements.delete(componentId);\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n };\r\n }, []);\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n const liveTypeInfo =\r\n getGlobalStore.getState().getShadowNode(stateKey, path)?._meta\r\n ?.typeInfo ?? typeInfo;\r\n\r\n // Type conversion logic (keep existing)\r\n if (liveTypeInfo) {\r\n if (liveTypeInfo.type === 'number' && typeof newValue === 'string') {\r\n newValue =\r\n newValue === ''\r\n ? liveTypeInfo.nullable\r\n ? null\r\n : (liveTypeInfo.default ?? 0)\r\n : Number(newValue);\r\n } else if (\r\n liveTypeInfo.type === 'boolean' &&\r\n typeof newValue === 'string'\r\n ) {\r\n newValue = newValue === 'true' || newValue === '1';\r\n } else if (\r\n liveTypeInfo.type === 'date' &&\r\n typeof newValue === 'string'\r\n ) {\r\n newValue = new Date(newValue);\r\n }\r\n } else {\r\n const currentType = typeof globalStateValue;\r\n if (currentType === 'number' && typeof newValue === 'string') {\r\n newValue = newValue === '' ? 0 : Number(newValue);\r\n }\r\n }\r\n\r\n setLocalValue(newValue);\r\n\r\n // Update input activity details\r\n const { getShadowMetadata, setShadowMetadata } =\r\n getGlobalStore.getState();\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId);\r\n if (element && element.currentActivity?.type === 'focus') {\r\n element!.currentActivity.details = {\r\n ...element!.currentActivity.details,\r\n value: newValue,\r\n previousValue:\r\n element!.currentActivity.details?.value || globalStateValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n keystrokeCount:\r\n (element!.currentActivity.details?.keystrokeCount || 0) + 1,\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n }\r\n const element = meta?.clientActivityState?.elements?.get(componentId);\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'input', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n value: newValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n isComposing: false, // You'd need to track this from the actual input event\r\n isPasting: false, // You'd need to track this from paste events\r\n keystrokeCount:\r\n (element?.currentActivity?.details?.keystrokeCount || 0) + 1,\r\n },\r\n });\r\n // Validation (keep existing)\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: newValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onChange');\r\n\r\n // Debounce state update (keep existing)\r\n isCurrentlyDebouncing.current = true;\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onChange',\r\n });\r\n }, debounceTime);\r\n },\r\n [\r\n setState,\r\n path,\r\n formOpts?.debounceTime,\r\n typeInfo,\r\n globalStateValue,\r\n stateKey,\r\n componentId,\r\n ]\r\n );\r\n\r\n const handleFocus = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Update element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = {\r\n type: 'focus',\r\n startTime: Date.now(),\r\n details: {\r\n value: localValue,\r\n inputLength:\r\n typeof localValue === 'string' ? localValue.length : undefined,\r\n },\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'focus', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n cursorPosition: formElementRef.current?.selectionStart,\r\n },\r\n });\r\n }, [stateKey, path, componentId, localValue]);\r\n const handleBlur = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Clear debounce if active\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n debounceTimeoutRef.current = null;\r\n isCurrentlyDebouncing.current = false;\r\n setState(localValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onBlur',\r\n });\r\n }\r\n\r\n // Clear element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = undefined;\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n const focusStartTime =\r\n meta?.clientActivityState?.elements?.get(componentId)?.currentActivity\r\n ?.startTime;\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'blur', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n duration: focusStartTime ? Date.now() - focusStartTime : undefined,\r\n details: {\r\n duration: focusStartTime ? Date.now() - focusStartTime : 0,\r\n },\r\n });\r\n\r\n // Run validation if configured\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n if (validationOptions?.onBlur) {\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: localValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onBlur');\r\n }\r\n }, [localValue, setState, path, stateKey, componentId, globalStateValue]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n const stateWithInputProps = new Proxy(baseState, {\r\n get(target, prop) {\r\n if (prop === '$inputProps') {\r\n return {\r\n value: localValue ?? '',\r\n onChange: (e: any) => {\r\n debouncedUpdate(e.target.value);\r\n },\r\n onFocus: handleFocus,\r\n onBlur: handleBlur,\r\n ref: formElementRef,\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n const initialElement = renderFn(stateWithInputProps);\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {initialElement}\r\n </ValidationWrapper>\r\n );\r\n}\r\n\r\nexport function useRegisterComponent(\r\n stateKey: string,\r\n componentId: string,\r\n forceUpdate: (o: object) => void\r\n) {\r\n const fullComponentId = `${stateKey}////${componentId}`;\r\n\r\n useLayoutEffect(() => {\r\n registerComponent(stateKey, fullComponentId, {\r\n forceUpdate: () => forceUpdate({}),\r\n paths: new Set(),\r\n reactiveType: ['component'],\r\n });\r\n return () => {\r\n unregisterComponent(stateKey, fullComponentId);\r\n };\r\n }, [stateKey, fullComponentId]);\r\n}\r\n\r\nexport function IsolatedComponentWrapper({\r\n stateKey,\r\n path, // The path of the parent node (e.g. ['form'])\r\n dependencies, // NEW: Optional array of Proxy objects or path arrays\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n dependencies?: any[]; // The explicit list of dependencies\r\n rebuildStateShape: (options: any) => any;\r\n renderFn: (state: any) => React.ReactNode;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\r\n const pathsToSubscribe = useMemo(() => {\r\n if (dependencies && dependencies.length > 0) {\r\n return dependencies.map((dep) => {\r\n return [stateKey, ...dep.$_path].join('.');\r\n });\r\n }\r\n\r\n return [[stateKey, ...path].join('.')];\r\n }, [stateKey, path, dependencies]);\r\n\r\n // 2. Subscribe to ALL calculated paths\r\n useEffect(() => {\r\n const store = getGlobalStore.getState();\r\n\r\n // Create an array of unsubscribe functions\r\n const unsubs = pathsToSubscribe.map((fullPathKey) => {\r\n return store.subscribeToPath(fullPathKey, () => {\r\n forceUpdate({});\r\n });\r\n });\r\n\r\n return () => {\r\n unsubs.forEach((unsub) => unsub());\r\n };\r\n }, [pathsToSubscribe]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n return <>{renderFn(baseState)}</>;\r\n}\r\n// 1. Define the MINIMAL props needed.\r\ntype PluginWrapperProps = {\r\n children: ReactNode;\r\n stateKey: string;\r\n path: string[];\r\n pluginName: string;\r\n wrapperDepth: number;\r\n};\r\n\r\nconst PluginWrapper = memo(function PluginWrapper({\r\n children,\r\n stateKey,\r\n path,\r\n pluginName,\r\n wrapperDepth,\r\n}: PluginWrapperProps) {\r\n const [, forceUpdate] = useState({});\r\n\r\n useEffect(() => {\r\n const fullPathKey = [stateKey, ...path].join('.');\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(fullPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return unsubscribe;\r\n }, [stateKey, path]);\r\n\r\n const plugin = pluginStore\r\n .getState()\r\n .registeredPlugins.find((p) => p.name === pluginName);\r\n\r\n const stateHandler: StateObject<any> | undefined = pluginStore\r\n .getState()\r\n .stateHandlers.get(stateKey);\r\n\r\n const typeInfo = getGlobalStore.getState().getShadowNode(stateKey, path)\r\n ?._meta?.typeInfo;\r\n\r\n const options = pluginStore\r\n .getState()\r\n .pluginOptions.get(stateKey)\r\n ?.get(pluginName);\r\n\r\n const hookData = pluginStore.getState().getHookResult(stateKey, pluginName);\r\n\r\n if (!plugin?.formWrapper || !stateHandler) {\r\n return <>{children}</>;\r\n }\r\n\r\n const deconstructed = toDeconstructedMethods(stateHandler);\r\n const scopedMetadataContext = createScopedMetadataContext(\r\n stateKey,\r\n plugin.name,\r\n path\r\n );\r\n return plugin.formWrapper({\r\n element: children,\r\n path,\r\n stateKey,\r\n pluginName: plugin.name,\r\n ...deconstructed,\r\n\r\n ...scopedMetadataContext,\r\n options,\r\n hookData,\r\n fieldType: typeInfo?.type,\r\n wrapperDepth,\r\n });\r\n});\r\n"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","stateHandlers","notifyFormUpdate","pluginStore","ValidationWrapper","formOpts","path","stateKey","children","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","primarySeverity","registeredPlugins","pluginsApi","plugin","pluginName","hookData","scopedMetadata","createScopedMetadataContext","jsx","Fragment","React","MemoizedCogsItemWrapper","memo","ListItemWrapper","prevProps","nextProps","itemComponentId","itemPath","localIndex","arraySetter","rebuildStateShape","renderFn","forceUpdate","useState","inViewRef","inView","useInView","elementRef","useRef","fullKey","useRegisterComponent","setRefs","useCallback","element","useEffect","unsubscribe","e","itemValue","itemSetter","node","existingRef","FormElementWrapper","setState","componentId","uuidv4","formElementRef","stateKeyPathKey","typeInfo","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","isDeepEqual","currentMeta","detectElementType","el","tagName","type","newValue","meta","debouncedUpdate","liveTypeInfo","runValidation","debounceTime","handleFocus","handleBlur","focusStartTime","baseState","stateWithInputProps","target","prop","initialElement","fullComponentId","useLayoutEffect","IsolatedComponentWrapper","dependencies","pathsToSubscribe","useMemo","dep","store","unsubs","fullPathKey","unsub","wrapperDepth","p","stateHandler","options","deconstructed","toDeconstructedMethods","scopedMetadataContext"],"mappings":";;;;;;;;;AA8BA,MAAM;AAAA,EACJ,mBAAAA;AAAA,EAEA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EAEA,mBAAAC;AAAA,EACA,qBAAAC;AAAA,EAEA,uBAAAC;AAAA,EACA,iBAAAC;AACF,IAAIC,EAAe,SAAA,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AAA,EAAA,CACD;AACH,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Components.js","sources":["../src/Components.tsx"],"sourcesContent":["import {\r\n FormElementParams,\r\n StateObject,\r\n UpdateTypeDetail,\r\n type FormOptsType,\r\n} from './CogsState';\r\nimport { pluginStore } from './pluginStore';\r\nimport {\r\n createMetadataContext,\r\n createScopedMetadataContext,\r\n PluginsApi,\r\n toDeconstructedMethods,\r\n} from './plugins';\r\nimport React, {\r\n memo,\r\n RefObject,\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useRef,\r\n useState,\r\n useMemo,\r\n type ReactNode,\r\n} from 'react';\r\nimport { getGlobalStore, ValidationError, ValidationSeverity } from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\r\nimport { runValidation } from './validation';\r\n\r\nconst {\r\n getInitialOptions,\r\n\r\n getShadowMetadata,\r\n setShadowMetadata,\r\n getShadowValue,\r\n\r\n registerComponent,\r\n unregisterComponent,\r\n\r\n notifyPathSubscribers,\r\n subscribeToPath,\r\n} = getGlobalStore.getState();\r\nconst { stateHandlers, notifyFormUpdate } = pluginStore.getState();\r\n\r\nexport type ValidationWrapperProps = {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n stateKey: string;\r\n children: ReactNode;\r\n};\r\n\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n stateKey,\r\n children,\r\n}: ValidationWrapperProps) {\r\n const { getInitialOptions, getShadowMetadata, getShadowValue } =\r\n getGlobalStore.getState();\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n\r\n const shadowMeta = getShadowMetadata(stateKey!, path);\r\n const validationState = shadowMeta?.validation;\r\n\r\n const status = validationState?.status || 'NOT_VALIDATED';\r\n\r\n const errors = (validationState?.errors || []).map((err) => ({\r\n ...err,\r\n path: path,\r\n })) as ValidationError[];\r\n const errorMessages = errors\r\n .filter((err) => err.severity === 'error')\r\n .map((err) => err.message);\r\n const warningMessages = errors\r\n .filter((err) => err.severity === 'warning')\r\n .map((err) => err.message);\r\n\r\n // Use first error, or first warning if no errors\r\n const message = errorMessages[0] || warningMessages[0];\r\n const primarySeverity: ValidationSeverity =\r\n errorMessages.length > 0\r\n ? 'error'\r\n : warningMessages.length > 0\r\n ? 'warning'\r\n : undefined;\r\n const { registeredPlugins } = pluginStore.getState();\r\n const pluginsApi: PluginsApi = {};\r\n\r\n // We iterate over ALL registered plugins in the app.\r\n registeredPlugins.forEach((plugin) => {\r\n if (thisStateOpts && thisStateOpts.hasOwnProperty(plugin.name)) {\r\n const pluginName = plugin.name;\r\n\r\n const hookData = pluginStore\r\n .getState()\r\n .getHookResult(stateKey!, pluginName);\r\n\r\n const scopedMetadata = createScopedMetadataContext(\r\n stateKey!,\r\n pluginName,\r\n path\r\n );\r\n\r\n pluginsApi[pluginName] = {\r\n hookData,\r\n getFieldMetaData: scopedMetadata.getFieldMetaData,\r\n setFieldMetaData: scopedMetadata.setFieldMetaData,\r\n removeFieldMetaData: scopedMetadata.removeFieldMetaData,\r\n };\r\n }\r\n });\r\n\r\n return (\r\n <>\r\n {thisStateOpts?.formElements?.validation &&\r\n !formOpts?.validation?.disable ? (\r\n thisStateOpts.formElements!.validation!({\r\n children: (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n ),\r\n status, // Now passes the new ValidationStatus type\r\n message: formOpts?.validation?.hideMessage\r\n ? ''\r\n : formOpts?.validation?.message || message || '',\r\n severity: primarySeverity,\r\n hasErrors: errorMessages.length > 0,\r\n hasWarnings: warningMessages.length > 0,\r\n allErrors: errors,\r\n path: path,\r\n getData: () => getShadowValue(stateKey!, path),\r\n plugins: pluginsApi,\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\nexport const MemoizedCogsItemWrapper = memo(\r\n ListItemWrapper,\r\n (prevProps, nextProps) => {\r\n // Re-render if any of these change:\r\n return (\r\n prevProps.itemPath.join('.') === nextProps.itemPath.join('.') &&\r\n prevProps.stateKey === nextProps.stateKey &&\r\n prevProps.itemComponentId === nextProps.itemComponentId &&\r\n prevProps.localIndex === nextProps.localIndex\r\n );\r\n }\r\n);\r\n\r\nexport function ListItemWrapper({\r\n stateKey,\r\n itemComponentId,\r\n itemPath,\r\n localIndex,\r\n arraySetter,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n itemComponentId: string;\r\n itemPath: string[];\r\n localIndex: number;\r\n arraySetter: any;\r\n rebuildStateShape: any;\r\n renderFn: any;\r\n}) {\r\n const [, forceUpdate] = useState({});\r\n const { ref: inViewRef, inView } = useInView();\r\n const elementRef = useRef<HTMLElement | null>(null); // Changed to HTMLElement to be generic\r\n\r\n const fullKey = [stateKey, ...itemPath].join('.');\r\n\r\n useRegisterComponent(stateKey, itemComponentId, forceUpdate);\r\n\r\n const setRefs = useCallback(\r\n (element: HTMLElement | null) => {\r\n elementRef.current = element;\r\n inViewRef(element);\r\n },\r\n [inViewRef]\r\n );\r\n\r\n useEffect(() => {\r\n const unsubscribe = subscribeToPath(fullKey, (e) => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [fullKey]);\r\n\r\n const itemValue = getShadowValue(stateKey, itemPath);\r\n if (itemValue === undefined) return null;\r\n\r\n const itemSetter = rebuildStateShape({\r\n currentState: itemValue,\r\n path: itemPath,\r\n componentId: itemComponentId,\r\n });\r\n\r\n // 1. Render the user's content (e.g. the <tr>)\r\n const children = renderFn(itemSetter, localIndex, arraySetter);\r\n\r\n // 2. AUTO-DETECT: If it is a single valid element (<tr>, <div>, <li>), inject the ref.\r\n if (React.isValidElement(children)) {\r\n // We clone the element and force our ref onto it\r\n return React.cloneElement(children as React.ReactElement<any>, {\r\n ref: (node: any) => {\r\n // Apply our virtualization ref\r\n setRefs(node);\r\n\r\n // Preserve any ref the user might have put on the element themselves\r\n const { ref: existingRef } = children as any;\r\n if (typeof existingRef === 'function') {\r\n existingRef(node);\r\n } else if (existingRef && 'current' in existingRef) {\r\n (existingRef as any).current = node;\r\n }\r\n },\r\n });\r\n }\r\n\r\n // 3. Fallback: If they returned a Fragment or string, we MUST wrap it to measure it.\r\n // (Note: This specific fallback will still break inside a <tbody>, but\r\n // as long as you return a <tr> above, line 90 catches it).\r\n return <div ref={setRefs}>{children}</div>;\r\n}\r\n\r\nexport function FormElementWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n formOpts,\r\n setState,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (params: FormElementParams<any>) => ReactNode;\r\n formOpts?: FormOptsType;\r\n setState: any;\r\n}) {\r\n const componentId = useRef(uuidv4()).current;\r\n\r\n const [, forceUpdate] = useState({});\r\n const formElementRef = useRef<any>(null);\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n // Get the shadow node to access typeInfo and schema\r\n const shadowNode = getGlobalStore.getState().getShadowNode(stateKey, path);\r\n const typeInfo = shadowNode?._meta?.typeInfo;\r\n\r\n const globalStateValue = getShadowValue(stateKey, path);\r\n const [localValue, setLocalValue] = useState<any>(globalStateValue);\r\n const isCurrentlyDebouncing = useRef(false);\r\n const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);\r\n\r\n useEffect(() => {\r\n if (\r\n !isCurrentlyDebouncing.current &&\r\n !isDeepEqual(globalStateValue, localValue)\r\n ) {\r\n setLocalValue(globalStateValue);\r\n }\r\n }, [globalStateValue]);\r\n\r\n useEffect(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n console.log('FormElementWrapper effect running for:', stateKey, path);\r\n\r\n // Initialize clientActivityState if needed\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n if (!currentMeta.clientActivityState) {\r\n currentMeta.clientActivityState = { elements: new Map() };\r\n }\r\n\r\n // Detect element type from the ref\r\n const detectElementType = () => {\r\n const el = formElementRef.current;\r\n if (!el) return 'input';\r\n const tagName = el.tagName.toLowerCase();\r\n if (tagName === 'textarea') return 'textarea';\r\n if (tagName === 'select') return 'select';\r\n if (tagName === 'input') {\r\n const type = (el as HTMLInputElement).type;\r\n if (type === 'checkbox') return 'checkbox';\r\n if (type === 'radio') return 'radio';\r\n if (type === 'range') return 'range';\r\n if (type === 'file') return 'file';\r\n }\r\n return 'input';\r\n };\r\n\r\n // Add this element to the Map\r\n currentMeta.clientActivityState.elements.set(componentId, {\r\n domRef: formElementRef,\r\n elementType: detectElementType(),\r\n inputType: formElementRef.current?.type,\r\n mountedAt: Date.now(),\r\n });\r\n console.log('currentMeta', currentMeta);\r\n setShadowMetadata(stateKey, path, currentMeta);\r\n\r\n // Subscribe to path updates\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, (newValue) => {\r\n if (!isCurrentlyDebouncing.current && localValue !== newValue) {\r\n forceUpdate({});\r\n }\r\n });\r\n\r\n // Cleanup\r\n return () => {\r\n unsubscribe();\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n\r\n // Remove element from Map\r\n const meta = getGlobalStore.getState().getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements) {\r\n meta.clientActivityState.elements.delete(componentId);\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n };\r\n }, []);\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n const liveTypeInfo =\r\n getGlobalStore.getState().getShadowNode(stateKey, path)?._meta\r\n ?.typeInfo ?? typeInfo;\r\n\r\n // Type conversion logic (keep existing)\r\n if (liveTypeInfo) {\r\n if (liveTypeInfo.type === 'number' && typeof newValue === 'string') {\r\n newValue =\r\n newValue === ''\r\n ? liveTypeInfo.nullable\r\n ? null\r\n : (liveTypeInfo.default ?? 0)\r\n : Number(newValue);\r\n } else if (\r\n liveTypeInfo.type === 'boolean' &&\r\n typeof newValue === 'string'\r\n ) {\r\n newValue = newValue === 'true' || newValue === '1';\r\n } else if (\r\n liveTypeInfo.type === 'date' &&\r\n typeof newValue === 'string'\r\n ) {\r\n newValue = new Date(newValue);\r\n }\r\n } else {\r\n const currentType = typeof globalStateValue;\r\n if (currentType === 'number' && typeof newValue === 'string') {\r\n newValue = newValue === '' ? 0 : Number(newValue);\r\n }\r\n }\r\n\r\n setLocalValue(newValue);\r\n\r\n // Update input activity details\r\n const { getShadowMetadata, setShadowMetadata } =\r\n getGlobalStore.getState();\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId);\r\n if (element && element.currentActivity?.type === 'focus') {\r\n element!.currentActivity.details = {\r\n ...element!.currentActivity.details,\r\n value: newValue,\r\n previousValue:\r\n element!.currentActivity.details?.value || globalStateValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n keystrokeCount:\r\n (element!.currentActivity.details?.keystrokeCount || 0) + 1,\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n }\r\n const element = meta?.clientActivityState?.elements?.get(componentId);\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'input', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n value: newValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n isComposing: false, // You'd need to track this from the actual input event\r\n isPasting: false, // You'd need to track this from paste events\r\n keystrokeCount:\r\n (element?.currentActivity?.details?.keystrokeCount || 0) + 1,\r\n },\r\n });\r\n // Validation (keep existing)\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: newValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onChange');\r\n\r\n // Debounce state update (keep existing)\r\n isCurrentlyDebouncing.current = true;\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onChange',\r\n });\r\n }, debounceTime);\r\n },\r\n [\r\n setState,\r\n path,\r\n formOpts?.debounceTime,\r\n typeInfo,\r\n globalStateValue,\r\n stateKey,\r\n componentId,\r\n ]\r\n );\r\n\r\n const handleFocus = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Update element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = {\r\n type: 'focus',\r\n startTime: Date.now(),\r\n details: {\r\n value: localValue,\r\n inputLength:\r\n typeof localValue === 'string' ? localValue.length : undefined,\r\n },\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'focus', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n cursorPosition: formElementRef.current?.selectionStart,\r\n },\r\n });\r\n }, [stateKey, path, componentId, localValue]);\r\n const handleBlur = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Clear debounce if active\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n debounceTimeoutRef.current = null;\r\n isCurrentlyDebouncing.current = false;\r\n setState(localValue, path, { updateType: 'update' });\r\n }\r\n\r\n // Clear element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = undefined;\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n const focusStartTime =\r\n meta?.clientActivityState?.elements?.get(componentId)?.currentActivity\r\n ?.startTime;\r\n\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n if (validationOptions?.onBlur) {\r\n runValidation(\r\n {\r\n stateKey,\r\n path,\r\n newValue: localValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n },\r\n 'onBlur'\r\n );\r\n }\r\n\r\n // Refine / plugin validation runs after field validation so it wins on conflict\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'blur',\r\n path,\r\n timestamp: Date.now(),\r\n duration: focusStartTime ? Date.now() - focusStartTime : undefined,\r\n details: {\r\n duration: focusStartTime ? Date.now() - focusStartTime : 0,\r\n },\r\n });\r\n }, [localValue, setState, path, stateKey, componentId, globalStateValue]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n const stateWithInputProps = new Proxy(baseState, {\r\n get(target, prop) {\r\n if (prop === '$inputProps') {\r\n return {\r\n value: localValue ?? '',\r\n onChange: (e: any) => {\r\n debouncedUpdate(e.target.value);\r\n },\r\n onFocus: handleFocus,\r\n onBlur: handleBlur,\r\n ref: formElementRef,\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n const initialElement = renderFn(stateWithInputProps);\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {initialElement}\r\n </ValidationWrapper>\r\n );\r\n}\r\n\r\nexport function useRegisterComponent(\r\n stateKey: string,\r\n componentId: string,\r\n forceUpdate: (o: object) => void\r\n) {\r\n const fullComponentId = `${stateKey}////${componentId}`;\r\n\r\n useLayoutEffect(() => {\r\n registerComponent(stateKey, fullComponentId, {\r\n forceUpdate: () => forceUpdate({}),\r\n paths: new Set(),\r\n reactiveType: ['component'],\r\n });\r\n return () => {\r\n unregisterComponent(stateKey, fullComponentId);\r\n };\r\n }, [stateKey, fullComponentId]);\r\n}\r\n\r\nexport function IsolatedComponentWrapper({\r\n stateKey,\r\n path, // The path of the parent node (e.g. ['form'])\r\n dependencies, // NEW: Optional array of Proxy objects or path arrays\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n dependencies?: any[]; // The explicit list of dependencies\r\n rebuildStateShape: (options: any) => any;\r\n renderFn: (state: any) => React.ReactNode;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\r\n const pathsToSubscribe = useMemo(() => {\r\n if (dependencies && dependencies.length > 0) {\r\n return dependencies.map((dep) => {\r\n return [stateKey, ...dep.$_path].join('.');\r\n });\r\n }\r\n\r\n return [[stateKey, ...path].join('.')];\r\n }, [stateKey, path, dependencies]);\r\n\r\n // 2. Subscribe to ALL calculated paths\r\n useEffect(() => {\r\n const store = getGlobalStore.getState();\r\n\r\n // Create an array of unsubscribe functions\r\n const unsubs = pathsToSubscribe.map((fullPathKey) => {\r\n return store.subscribeToPath(fullPathKey, () => {\r\n forceUpdate({});\r\n });\r\n });\r\n\r\n return () => {\r\n unsubs.forEach((unsub) => unsub());\r\n };\r\n }, [pathsToSubscribe]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n return <>{renderFn(baseState)}</>;\r\n}\r\n// 1. Define the MINIMAL props needed.\r\ntype PluginWrapperProps = {\r\n children: ReactNode;\r\n stateKey: string;\r\n path: string[];\r\n pluginName: string;\r\n wrapperDepth: number;\r\n};\r\n\r\nconst PluginWrapper = memo(function PluginWrapper({\r\n children,\r\n stateKey,\r\n path,\r\n pluginName,\r\n wrapperDepth,\r\n}: PluginWrapperProps) {\r\n const [, forceUpdate] = useState({});\r\n\r\n useEffect(() => {\r\n const fullPathKey = [stateKey, ...path].join('.');\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(fullPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return unsubscribe;\r\n }, [stateKey, path]);\r\n\r\n const plugin = pluginStore\r\n .getState()\r\n .registeredPlugins.find((p) => p.name === pluginName);\r\n\r\n const stateHandler: StateObject<any> | undefined = pluginStore\r\n .getState()\r\n .stateHandlers.get(stateKey);\r\n\r\n const typeInfo = getGlobalStore.getState().getShadowNode(stateKey, path)\r\n ?._meta?.typeInfo;\r\n\r\n const options = pluginStore\r\n .getState()\r\n .pluginOptions.get(stateKey)\r\n ?.get(pluginName);\r\n\r\n const hookData = pluginStore.getState().getHookResult(stateKey, pluginName);\r\n\r\n if (!plugin?.formWrapper || !stateHandler) {\r\n return <>{children}</>;\r\n }\r\n\r\n const deconstructed = toDeconstructedMethods(stateHandler);\r\n const scopedMetadataContext = createScopedMetadataContext(\r\n stateKey,\r\n plugin.name,\r\n path\r\n );\r\n return plugin.formWrapper({\r\n element: children,\r\n path,\r\n stateKey,\r\n pluginName: plugin.name,\r\n ...deconstructed,\r\n\r\n ...scopedMetadataContext,\r\n options,\r\n hookData,\r\n fieldType: typeInfo?.type,\r\n wrapperDepth,\r\n });\r\n});\r\n"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","stateHandlers","notifyFormUpdate","pluginStore","ValidationWrapper","formOpts","path","stateKey","children","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","primarySeverity","registeredPlugins","pluginsApi","plugin","pluginName","hookData","scopedMetadata","createScopedMetadataContext","jsx","Fragment","React","MemoizedCogsItemWrapper","memo","ListItemWrapper","prevProps","nextProps","itemComponentId","itemPath","localIndex","arraySetter","rebuildStateShape","renderFn","forceUpdate","useState","inViewRef","inView","useInView","elementRef","useRef","fullKey","useRegisterComponent","setRefs","useCallback","element","useEffect","unsubscribe","e","itemValue","itemSetter","node","existingRef","FormElementWrapper","setState","componentId","uuidv4","formElementRef","stateKeyPathKey","typeInfo","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","isDeepEqual","currentMeta","detectElementType","el","tagName","type","newValue","meta","debouncedUpdate","liveTypeInfo","runValidation","debounceTime","handleFocus","handleBlur","focusStartTime","baseState","stateWithInputProps","target","prop","initialElement","fullComponentId","useLayoutEffect","IsolatedComponentWrapper","dependencies","pathsToSubscribe","useMemo","dep","store","unsubs","fullPathKey","unsub","wrapperDepth","p","stateHandler","options","deconstructed","toDeconstructedMethods","scopedMetadataContext"],"mappings":";;;;;;;;;AA8BA,MAAM;AAAA,EACJ,mBAAAA;AAAA,EAEA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EAEA,mBAAAC;AAAA,EACA,qBAAAC;AAAA,EAEA,uBAAAC;AAAA,EACA,iBAAAC;AACF,IAAIC,EAAe,SAAA,GACb,EAAE,eAAAC,IAAe,kBAAAC,MAAqBC,EAAY,SAAA;AASjD,SAASC,GAAkB;AAAA,EAChC,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAM,EAAE,mBAAAhB,GAAmB,mBAAAC,GAAmB,gBAAAE,EAAAA,IAC5CK,EAAe,SAAA,GACXS,IAAgBjB,EAAkBe,CAAS,GAG3CG,IADajB,EAAkBc,GAAWD,CAAI,GAChB,YAE9BK,IAASD,GAAiB,UAAU,iBAEpCE,KAAUF,GAAiB,UAAU,CAAA,GAAI,IAAI,CAACG,OAAS;AAAA,IAC3D,GAAGA;AAAA,IACH,MAAAP;AAAA,EAAA,EACA,GACIQ,IAAgBF,EACnB,OAAO,CAACC,MAAQA,EAAI,aAAa,OAAO,EACxC,IAAI,CAACA,MAAQA,EAAI,OAAO,GACrBE,IA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,EAChD,SAAA,EACA,cAAc,IAAII,CAAQ,GAEvByD,IAAWhE,EAAe,SAAA,EAAW,cAAcO,GAAUD,CAAI,GACnE,OAAO,UAELkG,IAAUrG,EACb,WACA,cAAc,IAAII,CAAQ,GACzB,IAAIc,CAAU,GAEZC,IAAWnB,EAAY,SAAA,EAAW,cAAcI,GAAUc,CAAU;AAE1E,MAAI,CAACD,GAAQ,eAAe,CAACmF;AAC3B,kCAAU,UAAA/F,GAAS;AAGrB,QAAMiG,IAAgBC,EAAuBH,CAAY,GACnDI,IAAwBnF;AAAA,IAC5BjB;AAAA,IACAa,EAAO;AAAA,IACPd;AAAA,EAAA;AAEF,SAAOc,EAAO,YAAY;AAAA,IACxB,SAASZ;AAAA,IACT,MAAAF;AAAA,IACA,UAAAC;AAAA,IACA,YAAYa,EAAO;AAAA,IACnB,GAAGqF;AAAA,IAEH,GAAGE;AAAA,IACH,SAAAH;AAAA,IACA,UAAAlF;AAAA,IACA,WAAW0C,GAAU;AAAA,IACrB,cAAAqC;AAAA,EAAA,CACD;AACH,CAAC;"}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ type DeconstructedCogsMethods<TStateSlice = any> = {
|
|
|
54
54
|
dontUpdate?: boolean;
|
|
55
55
|
}) => void;
|
|
56
56
|
addZodErrors: (errors: any[]) => void;
|
|
57
|
+
clearZodErrors: (paths: string[][]) => void;
|
|
57
58
|
getState: () => TStateSlice;
|
|
58
59
|
setOptions: (options: any) => void;
|
|
59
60
|
};
|
|
@@ -64,6 +65,7 @@ export declare function toDeconstructedMethods(stateHandler: StateObject<any>):
|
|
|
64
65
|
dontUpdate?: boolean;
|
|
65
66
|
}) => void;
|
|
66
67
|
addZodErrors: (errors: any[]) => void;
|
|
68
|
+
clearZodErrors: (paths: string[][]) => void;
|
|
67
69
|
getState: () => any;
|
|
68
70
|
setOptions: (opts: any) => void;
|
|
69
71
|
};
|