cogsbox-state 0.5.472 → 0.5.473
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 +98 -82
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +1020 -950
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.jsx +276 -217
- package/dist/Components.jsx.map +1 -1
- package/dist/PluginRunner.d.ts +10 -0
- package/dist/PluginRunner.d.ts.map +1 -0
- package/dist/PluginRunner.jsx +128 -0
- package/dist/PluginRunner.jsx.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -26
- package/dist/index.js.map +1 -1
- package/dist/pluginStore.d.ts +43 -0
- package/dist/pluginStore.d.ts.map +1 -0
- package/dist/pluginStore.js +52 -0
- package/dist/pluginStore.js.map +1 -0
- package/dist/plugins.d.ts +1326 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +76 -0
- package/dist/plugins.js.map +1 -0
- package/dist/store.d.ts +50 -15
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +509 -470
- package/dist/store.js.map +1 -1
- package/dist/utility.d.ts +1 -1
- package/dist/utility.d.ts.map +1 -1
- package/dist/utility.js +12 -12
- package/dist/utility.js.map +1 -1
- package/dist/validation.d.ts +7 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +39 -0
- package/dist/validation.js.map +1 -0
- package/package.json +13 -3
- package/src/CogsState.tsx +658 -457
- package/src/Components.tsx +272 -194
- package/src/PluginRunner.tsx +208 -0
- package/src/index.ts +2 -0
- package/src/pluginStore.ts +159 -0
- package/src/plugins.ts +548 -0
- package/src/store.ts +748 -493
- package/src/utility.ts +31 -31
- package/src/validation.ts +84 -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,
|
|
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;AAGrB,OAAO,KASN,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,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,sBAAsB,2CAqDxB;AACD,eAAO,MAAM,uBAAuB,mDAWnC,CAAC;AACF,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;IAEjB,iBAAiB,EAAE,CAAC,OAAO,EAAE;QAC3B,YAAY,EAAE,GAAG,CAAC;QAClB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,KAAK,GAAG,CAAC;IACV,QAAQ,EAAE,CACR,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,MAAM,EAEb,WAAW,EAAE,GAAG,KACb,KAAK,CAAC,SAAS,CAAC;CACtB,kDAkEA;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,IAAI,EACJ,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iBAAiB,EAAE,CAAC,OAAO,EAAE;QAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,KAAK,GAAG,CAAC;IACV,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9D,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;CACf,2CAwTA;AACD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,QAiBjC;AAiDD,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,IAAI,EACJ,iBAAiB,EACjB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iBAAiB,EAAE,CAAC,OAAO,EAAE;QAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,KAAK,GAAG,CAAC;IACV,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAC;CAC3C,2CAuBA"}
|
package/dist/Components.jsx
CHANGED
|
@@ -1,295 +1,354 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { jsx as A, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { pluginStore as C } from "./pluginStore.js";
|
|
3
|
+
import { createMetadataContext as X, toDeconstructedMethods as Y } from "./plugins.js";
|
|
4
|
+
import U, { memo as _, useState as E, useRef as L, useCallback as k, useEffect as R, useLayoutEffect as $, useMemo as Z } from "react";
|
|
5
|
+
import { getGlobalStore as v } from "./store.js";
|
|
6
|
+
import { useInView as V } from "react-intersection-observer";
|
|
7
|
+
import { v4 as q } from "uuid";
|
|
8
|
+
import { isDeepEqual as K } from "./utility.js";
|
|
9
|
+
import { runValidation as B } from "./validation.js";
|
|
7
10
|
const {
|
|
8
|
-
getInitialOptions:
|
|
9
|
-
getShadowMetadata:
|
|
10
|
-
setShadowMetadata:
|
|
11
|
-
getShadowValue:
|
|
12
|
-
registerComponent:
|
|
13
|
-
unregisterComponent:
|
|
14
|
-
notifyPathSubscribers:
|
|
15
|
-
subscribeToPath:
|
|
16
|
-
} =
|
|
17
|
-
function
|
|
11
|
+
getInitialOptions: tt,
|
|
12
|
+
getShadowMetadata: bt,
|
|
13
|
+
setShadowMetadata: et,
|
|
14
|
+
getShadowValue: z,
|
|
15
|
+
registerComponent: nt,
|
|
16
|
+
unregisterComponent: ot,
|
|
17
|
+
notifyPathSubscribers: rt,
|
|
18
|
+
subscribeToPath: it
|
|
19
|
+
} = v.getState(), { stateHandlers: yt, notifyFormUpdate: x } = C.getState();
|
|
20
|
+
function at({
|
|
18
21
|
formOpts: t,
|
|
19
22
|
path: e,
|
|
20
|
-
stateKey:
|
|
21
|
-
children:
|
|
23
|
+
stateKey: o,
|
|
24
|
+
children: i
|
|
22
25
|
}) {
|
|
23
|
-
const { getInitialOptions: l, getShadowMetadata:
|
|
24
|
-
...
|
|
26
|
+
const { getInitialOptions: l, getShadowMetadata: s, getShadowValue: r } = v.getState(), f = l(o), T = s(o, e)?.validation, w = T?.status || "NOT_VALIDATED", g = (T?.errors || []).map((c) => ({
|
|
27
|
+
...c,
|
|
25
28
|
path: e
|
|
26
|
-
})),
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
children: /* @__PURE__ */
|
|
29
|
-
status:
|
|
29
|
+
})), d = g.filter((c) => c.severity === "error").map((c) => c.message), a = g.filter((c) => c.severity === "warning").map((c) => c.message), M = d[0] || a[0], S = d.length > 0 ? "error" : a.length > 0 ? "warning" : void 0;
|
|
30
|
+
return /* @__PURE__ */ A(O, { children: f?.formElements?.validation && !t?.validation?.disable ? f.formElements.validation({
|
|
31
|
+
children: /* @__PURE__ */ A(U.Fragment, { children: i }, e.toString()),
|
|
32
|
+
status: w,
|
|
30
33
|
// Now passes the new ValidationStatus type
|
|
31
|
-
message: t?.validation?.hideMessage ? "" : t?.validation?.message ||
|
|
32
|
-
severity:
|
|
33
|
-
hasErrors:
|
|
34
|
-
hasWarnings:
|
|
34
|
+
message: t?.validation?.hideMessage ? "" : t?.validation?.message || M || "",
|
|
35
|
+
severity: S,
|
|
36
|
+
hasErrors: d.length > 0,
|
|
37
|
+
hasWarnings: a.length > 0,
|
|
35
38
|
allErrors: g,
|
|
36
39
|
path: e,
|
|
37
|
-
getData: () =>
|
|
38
|
-
}) : /* @__PURE__ */
|
|
40
|
+
getData: () => r(o, e)
|
|
41
|
+
}) : /* @__PURE__ */ A(U.Fragment, { children: i }, e.toString()) });
|
|
39
42
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
43
|
+
const Mt = _(
|
|
44
|
+
ct,
|
|
42
45
|
(t, e) => t.itemPath.join(".") === e.itemPath.join(".") && t.stateKey === e.stateKey && t.itemComponentId === e.itemComponentId && t.localIndex === e.localIndex
|
|
43
46
|
);
|
|
44
|
-
function
|
|
47
|
+
function ct({
|
|
45
48
|
stateKey: t,
|
|
46
49
|
itemComponentId: e,
|
|
47
|
-
itemPath:
|
|
48
|
-
localIndex:
|
|
50
|
+
itemPath: o,
|
|
51
|
+
localIndex: i,
|
|
49
52
|
arraySetter: l,
|
|
50
|
-
rebuildStateShape:
|
|
51
|
-
renderFn:
|
|
53
|
+
rebuildStateShape: s,
|
|
54
|
+
renderFn: r
|
|
52
55
|
}) {
|
|
53
|
-
const [, f] =
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
(
|
|
57
|
-
|
|
56
|
+
const [, f] = E({}), { ref: m, inView: T } = V(), w = L(null), g = st(w), d = L(!1), a = [t, ...o].join(".");
|
|
57
|
+
P(t, e, f);
|
|
58
|
+
const M = k(
|
|
59
|
+
(h) => {
|
|
60
|
+
w.current = h, m(h);
|
|
58
61
|
},
|
|
59
|
-
[
|
|
62
|
+
[m]
|
|
60
63
|
);
|
|
61
|
-
|
|
62
|
-
const
|
|
64
|
+
R(() => {
|
|
65
|
+
const h = it(a, (H) => {
|
|
63
66
|
f({});
|
|
64
67
|
});
|
|
65
|
-
return () =>
|
|
66
|
-
}, [
|
|
67
|
-
if (!T || !g ||
|
|
68
|
+
return () => h();
|
|
69
|
+
}, [a]), R(() => {
|
|
70
|
+
if (!T || !g || d.current)
|
|
68
71
|
return;
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
72
|
+
const h = w.current;
|
|
73
|
+
if (h && h.offsetHeight > 0) {
|
|
74
|
+
d.current = !0;
|
|
75
|
+
const H = h.offsetHeight;
|
|
76
|
+
et(t, o, {
|
|
74
77
|
virtualizer: {
|
|
75
|
-
itemHeight:
|
|
76
|
-
domRef:
|
|
78
|
+
itemHeight: H,
|
|
79
|
+
domRef: h
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
|
-
const
|
|
80
|
-
|
|
82
|
+
const F = o.slice(0, -1), N = [t, ...F].join(".");
|
|
83
|
+
rt(N, {
|
|
81
84
|
type: "ITEMHEIGHT",
|
|
82
|
-
itemKey:
|
|
83
|
-
ref:
|
|
85
|
+
itemKey: o.join("."),
|
|
86
|
+
ref: w.current
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
|
-
}, [T, g, t,
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
+
}, [T, g, t, o]);
|
|
90
|
+
const S = z(t, o);
|
|
91
|
+
if (S === void 0)
|
|
89
92
|
return null;
|
|
90
|
-
const
|
|
91
|
-
currentState:
|
|
92
|
-
path:
|
|
93
|
+
const c = s({
|
|
94
|
+
currentState: S,
|
|
95
|
+
path: o,
|
|
93
96
|
componentId: e
|
|
94
|
-
}),
|
|
95
|
-
return /* @__PURE__ */
|
|
97
|
+
}), D = r(c, i, l);
|
|
98
|
+
return /* @__PURE__ */ A("div", { ref: M, children: D });
|
|
96
99
|
}
|
|
97
|
-
function
|
|
100
|
+
function Tt({
|
|
98
101
|
stateKey: t,
|
|
99
102
|
path: e,
|
|
100
|
-
rebuildStateShape:
|
|
101
|
-
renderFn:
|
|
103
|
+
rebuildStateShape: o,
|
|
104
|
+
renderFn: i,
|
|
102
105
|
formOpts: l,
|
|
103
|
-
setState:
|
|
106
|
+
setState: s
|
|
104
107
|
}) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
!
|
|
110
|
-
}, [
|
|
111
|
-
const
|
|
112
|
-
|
|
108
|
+
const r = L(q()).current, [, f] = E({}), m = L(null), T = [t, ...e].join(".");
|
|
109
|
+
P(t, r, f);
|
|
110
|
+
const g = v.getState().getShadowNode(t, e)?._meta?.typeInfo, d = z(t, e), [a, M] = E(d), S = L(!1), c = L(null), D = Z(() => C.getState().getPluginConfigsForState(t).filter((n) => typeof n.plugin.formWrapper == "function"), [t]);
|
|
111
|
+
R(() => {
|
|
112
|
+
!S.current && !K(d, a) && M(d);
|
|
113
|
+
}, [d]), R(() => {
|
|
114
|
+
const { getShadowMetadata: n, setShadowMetadata: p } = v.getState(), u = n(t, e) || {};
|
|
115
|
+
u.clientActivityState || (u.clientActivityState = { elements: /* @__PURE__ */ new Map() });
|
|
116
|
+
const I = () => {
|
|
117
|
+
const b = m.current;
|
|
118
|
+
if (!b) return "input";
|
|
119
|
+
const y = b.tagName.toLowerCase();
|
|
120
|
+
if (y === "textarea") return "textarea";
|
|
121
|
+
if (y === "select") return "select";
|
|
122
|
+
if (y === "input") {
|
|
123
|
+
const j = b.type;
|
|
124
|
+
if (j === "checkbox") return "checkbox";
|
|
125
|
+
if (j === "radio") return "radio";
|
|
126
|
+
if (j === "range") return "range";
|
|
127
|
+
if (j === "file") return "file";
|
|
128
|
+
}
|
|
129
|
+
return "input";
|
|
130
|
+
};
|
|
131
|
+
u.clientActivityState.elements.set(r, {
|
|
132
|
+
domRef: m,
|
|
133
|
+
elementType: I(),
|
|
134
|
+
inputType: m.current?.type,
|
|
135
|
+
mountedAt: Date.now()
|
|
136
|
+
}), p(t, e, u);
|
|
137
|
+
const W = v.getState().subscribeToPath(T, (b) => {
|
|
138
|
+
!S.current && a !== b && f({});
|
|
113
139
|
});
|
|
114
140
|
return () => {
|
|
115
|
-
|
|
141
|
+
W(), c.current && (clearTimeout(c.current), S.current = !1);
|
|
142
|
+
const b = v.getState().getShadowMetadata(t, e);
|
|
143
|
+
b?.clientActivityState?.elements && (b.clientActivityState.elements.delete(r), p(t, e, b));
|
|
116
144
|
};
|
|
117
145
|
}, []);
|
|
118
|
-
const
|
|
119
|
-
(
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
C,
|
|
132
|
-
r,
|
|
133
|
-
typeof r
|
|
134
|
-
), g && C) {
|
|
135
|
-
const p = g.safeParse(r);
|
|
136
|
-
p.success ? v = { success: !0 } : v = {
|
|
137
|
-
success: !1,
|
|
138
|
-
message: ("issues" in p.error ? p.error.issues : p.error.errors)[0]?.message || "Invalid value"
|
|
139
|
-
};
|
|
140
|
-
} else {
|
|
141
|
-
const p = h.zodSchemaV4 || h.zodSchemaV3;
|
|
142
|
-
if (!p) return;
|
|
143
|
-
const q = x(t, []), P = JSON.parse(JSON.stringify(q));
|
|
144
|
-
let j = P;
|
|
145
|
-
for (let L = 0; L < e.length - 1; L++)
|
|
146
|
-
j[e[L]] || (j[e[L]] = {}), j = j[e[L]];
|
|
147
|
-
e.length > 0 ? j[e[e.length - 1]] = r : Object.assign(P, r);
|
|
148
|
-
const A = p.safeParse(P);
|
|
149
|
-
if (A.success)
|
|
150
|
-
v = { success: !0 };
|
|
151
|
-
else {
|
|
152
|
-
const G = ("issues" in A.error ? A.error.issues : A.error.errors).filter((_) => {
|
|
153
|
-
if (e.some((H) => H.startsWith("id:"))) {
|
|
154
|
-
const H = e[0].startsWith("id:") ? [] : e.slice(0, -1), k = y.getState().getShadowMetadata(t, H);
|
|
155
|
-
if (k?.arrayKeys) {
|
|
156
|
-
e.slice(0, -1).join(".");
|
|
157
|
-
const ee = k.arrayKeys.findIndex(
|
|
158
|
-
(re) => re === e[e.length - 2]
|
|
159
|
-
), te = [...H, ee, ...e.slice(-1)];
|
|
160
|
-
return JSON.stringify(_.path) === JSON.stringify(te);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return JSON.stringify(_.path) === JSON.stringify(e);
|
|
164
|
-
});
|
|
165
|
-
G.length > 0 ? v = {
|
|
166
|
-
success: !1,
|
|
167
|
-
message: G[0]?.message
|
|
168
|
-
} : v = { success: !0 };
|
|
169
|
-
}
|
|
146
|
+
const h = k(
|
|
147
|
+
(n) => {
|
|
148
|
+
g ? g.type === "number" && typeof n == "string" ? n = n === "" ? g.nullable ? null : g.default ?? 0 : Number(n) : g.type === "boolean" && typeof n == "string" ? n = n === "true" || n === "1" : g.type === "date" && typeof n == "string" && (n = new Date(n)) : typeof d === "number" && typeof n == "string" && (n = n === "" ? 0 : Number(n)), M(n);
|
|
149
|
+
const { getShadowMetadata: p, setShadowMetadata: u } = v.getState(), I = p(t, e);
|
|
150
|
+
if (I?.clientActivityState?.elements?.has(r)) {
|
|
151
|
+
const y = I.clientActivityState.elements.get(r);
|
|
152
|
+
y && y.currentActivity?.type === "focus" && (y.currentActivity.details = {
|
|
153
|
+
...y.currentActivity.details,
|
|
154
|
+
value: n,
|
|
155
|
+
previousValue: y.currentActivity.details?.value || d,
|
|
156
|
+
inputLength: typeof n == "string" ? n.length : void 0,
|
|
157
|
+
keystrokeCount: (y.currentActivity.details?.keystrokeCount || 0) + 1
|
|
158
|
+
}, u(t, e, I));
|
|
170
159
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
status: "INVALID",
|
|
183
|
-
errors: [
|
|
184
|
-
{
|
|
185
|
-
source: "client",
|
|
186
|
-
message: v.message,
|
|
187
|
-
severity: W
|
|
188
|
-
}
|
|
189
|
-
],
|
|
190
|
-
lastValidated: Date.now(),
|
|
191
|
-
validatedValue: r
|
|
192
|
-
}
|
|
193
|
-
})), f({});
|
|
194
|
-
},
|
|
195
|
-
[t, e, g]
|
|
196
|
-
), S = z(
|
|
197
|
-
(r) => {
|
|
198
|
-
c ? c.type === "number" && typeof r == "string" ? r = r === "" ? c.nullable ? null : c.default ?? 0 : Number(r) : c.type === "boolean" && typeof r == "string" ? r = r === "true" || r === "1" : c.type === "date" && typeof r == "string" && (r = new Date(r)) : typeof u === "number" && typeof r == "string" && (r = r === "" ? 0 : Number(r)), E(r), M(r, "onChange"), m.current = !0, o.current && clearTimeout(o.current);
|
|
160
|
+
x({
|
|
161
|
+
stateKey: t,
|
|
162
|
+
type: "input",
|
|
163
|
+
path: e,
|
|
164
|
+
value: n
|
|
165
|
+
}), B({
|
|
166
|
+
stateKey: t,
|
|
167
|
+
path: e,
|
|
168
|
+
newValue: n,
|
|
169
|
+
updateType: "update"
|
|
170
|
+
}, "onChange"), S.current = !0, c.current && clearTimeout(c.current);
|
|
199
171
|
const b = l?.debounceTime ?? 200;
|
|
200
|
-
|
|
201
|
-
|
|
172
|
+
c.current = setTimeout(() => {
|
|
173
|
+
S.current = !1, s(n, e, {
|
|
174
|
+
updateType: "update",
|
|
175
|
+
validationTrigger: "onChange"
|
|
176
|
+
});
|
|
202
177
|
}, b);
|
|
203
178
|
},
|
|
204
179
|
[
|
|
205
|
-
|
|
180
|
+
s,
|
|
206
181
|
e,
|
|
207
182
|
l?.debounceTime,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
183
|
+
g,
|
|
184
|
+
d,
|
|
185
|
+
t,
|
|
186
|
+
r
|
|
211
187
|
]
|
|
212
|
-
),
|
|
213
|
-
|
|
214
|
-
|
|
188
|
+
), H = k(() => {
|
|
189
|
+
const { getShadowMetadata: n, setShadowMetadata: p } = v.getState(), u = n(t, e);
|
|
190
|
+
if (u?.clientActivityState?.elements?.has(r)) {
|
|
191
|
+
const I = u.clientActivityState.elements.get(r);
|
|
192
|
+
I.currentActivity = {
|
|
193
|
+
type: "focus",
|
|
194
|
+
startTime: Date.now(),
|
|
195
|
+
details: {
|
|
196
|
+
value: a,
|
|
197
|
+
inputLength: typeof a == "string" ? a.length : void 0
|
|
198
|
+
}
|
|
199
|
+
}, p(t, e, u);
|
|
200
|
+
}
|
|
201
|
+
x({
|
|
202
|
+
stateKey: t,
|
|
203
|
+
type: "focus",
|
|
204
|
+
path: e,
|
|
205
|
+
value: a
|
|
206
|
+
});
|
|
207
|
+
}, [t, e, r, a]), F = k(() => {
|
|
208
|
+
const { getShadowMetadata: n, setShadowMetadata: p } = v.getState();
|
|
209
|
+
c.current && (clearTimeout(c.current), c.current = null, S.current = !1, s(a, e, {
|
|
210
|
+
updateType: "update",
|
|
211
|
+
validationTrigger: "onBlur"
|
|
212
|
+
}));
|
|
213
|
+
const u = n(t, e);
|
|
214
|
+
if (u?.clientActivityState?.elements?.has(r)) {
|
|
215
|
+
const W = u.clientActivityState.elements.get(r);
|
|
216
|
+
W.currentActivity = void 0, p(t, e, u);
|
|
217
|
+
}
|
|
218
|
+
x({
|
|
219
|
+
stateKey: t,
|
|
220
|
+
type: "blur",
|
|
221
|
+
path: e,
|
|
222
|
+
value: a
|
|
223
|
+
}), tt(t)?.validation?.onBlur && B({
|
|
224
|
+
stateKey: t,
|
|
225
|
+
path: e,
|
|
226
|
+
newValue: a,
|
|
227
|
+
updateType: "update"
|
|
228
|
+
}, "onBlur");
|
|
229
|
+
}, [a, s, e, t, r, d]), N = o({
|
|
215
230
|
path: e,
|
|
216
|
-
componentId:
|
|
231
|
+
componentId: r,
|
|
217
232
|
meta: void 0
|
|
218
|
-
}),
|
|
219
|
-
get(
|
|
220
|
-
return
|
|
221
|
-
value:
|
|
222
|
-
onChange: (
|
|
223
|
-
|
|
233
|
+
}), G = new Proxy(N, {
|
|
234
|
+
get(n, p) {
|
|
235
|
+
return p === "$inputProps" ? {
|
|
236
|
+
value: a ?? "",
|
|
237
|
+
onChange: (u) => {
|
|
238
|
+
h(u.target.value);
|
|
224
239
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
240
|
+
onFocus: H,
|
|
241
|
+
onBlur: F,
|
|
242
|
+
ref: m
|
|
243
|
+
} : n[p];
|
|
228
244
|
}
|
|
229
|
-
})
|
|
230
|
-
|
|
245
|
+
}), J = i(G), Q = D.reduceRight(
|
|
246
|
+
(n, p, u) => /* @__PURE__ */ A(
|
|
247
|
+
ut,
|
|
248
|
+
{
|
|
249
|
+
stateKey: t,
|
|
250
|
+
path: e,
|
|
251
|
+
pluginName: p.plugin.name,
|
|
252
|
+
wrapperDepth: D.length - 1 - u,
|
|
253
|
+
children: n
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
J
|
|
257
|
+
);
|
|
258
|
+
return /* @__PURE__ */ A(at, { formOpts: l, path: e, stateKey: t, children: Q });
|
|
231
259
|
}
|
|
232
|
-
function
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
forceUpdate: () =>
|
|
260
|
+
function P(t, e, o) {
|
|
261
|
+
const i = `${t}////${e}`;
|
|
262
|
+
$(() => (nt(t, i, {
|
|
263
|
+
forceUpdate: () => o({}),
|
|
236
264
|
paths: /* @__PURE__ */ new Set(),
|
|
237
265
|
reactiveType: ["component"]
|
|
238
266
|
}), () => {
|
|
239
|
-
|
|
240
|
-
}), [t,
|
|
267
|
+
ot(t, i);
|
|
268
|
+
}), [t, i]);
|
|
241
269
|
}
|
|
242
|
-
const
|
|
243
|
-
const [e,
|
|
244
|
-
return
|
|
270
|
+
const st = (t) => {
|
|
271
|
+
const [e, o] = E(!1);
|
|
272
|
+
return $(() => {
|
|
245
273
|
if (!t.current) {
|
|
246
|
-
|
|
274
|
+
o(!0);
|
|
247
275
|
return;
|
|
248
276
|
}
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
251
|
-
|
|
277
|
+
const i = Array.from(t.current.querySelectorAll("img"));
|
|
278
|
+
if (i.length === 0) {
|
|
279
|
+
o(!0);
|
|
252
280
|
return;
|
|
253
281
|
}
|
|
254
282
|
let l = 0;
|
|
255
|
-
const
|
|
256
|
-
l++, l ===
|
|
283
|
+
const s = () => {
|
|
284
|
+
l++, l === i.length && o(!0);
|
|
257
285
|
};
|
|
258
|
-
return
|
|
259
|
-
|
|
286
|
+
return i.forEach((r) => {
|
|
287
|
+
r.complete ? s() : (r.addEventListener("load", s), r.addEventListener("error", s));
|
|
260
288
|
}), () => {
|
|
261
|
-
|
|
262
|
-
|
|
289
|
+
i.forEach((r) => {
|
|
290
|
+
r.removeEventListener("load", s), r.removeEventListener("error", s);
|
|
263
291
|
});
|
|
264
292
|
};
|
|
265
293
|
}, [t.current]), e;
|
|
266
294
|
};
|
|
267
|
-
function
|
|
295
|
+
function wt({
|
|
268
296
|
stateKey: t,
|
|
269
297
|
path: e,
|
|
270
|
-
rebuildStateShape:
|
|
271
|
-
renderFn:
|
|
298
|
+
rebuildStateShape: o,
|
|
299
|
+
renderFn: i
|
|
272
300
|
}) {
|
|
273
|
-
const [l] =
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
301
|
+
const [l] = E(() => q()), [, s] = E({}), r = [t, ...e].join(".");
|
|
302
|
+
P(t, l, s), R(() => {
|
|
303
|
+
const m = v.getState().subscribeToPath(r, () => {
|
|
304
|
+
s({});
|
|
277
305
|
});
|
|
278
|
-
return () =>
|
|
279
|
-
}, [
|
|
280
|
-
const f =
|
|
306
|
+
return () => m();
|
|
307
|
+
}, [r]);
|
|
308
|
+
const f = o({
|
|
281
309
|
path: e,
|
|
282
310
|
componentId: l,
|
|
283
311
|
meta: void 0
|
|
284
312
|
});
|
|
285
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ A(O, { children: i(f) });
|
|
286
314
|
}
|
|
315
|
+
const ut = _(function({
|
|
316
|
+
children: e,
|
|
317
|
+
stateKey: o,
|
|
318
|
+
path: i,
|
|
319
|
+
pluginName: l,
|
|
320
|
+
wrapperDepth: s
|
|
321
|
+
}) {
|
|
322
|
+
const [, r] = E({});
|
|
323
|
+
R(() => {
|
|
324
|
+
const M = [o, ...i].join(".");
|
|
325
|
+
return v.getState().subscribeToPath(M, () => {
|
|
326
|
+
r({});
|
|
327
|
+
});
|
|
328
|
+
}, [o, i]);
|
|
329
|
+
const f = C.getState().registeredPlugins.find((M) => M.name === l), m = C.getState().stateHandlers.get(o), T = v.getState().getShadowNode(o, i)?._meta?.typeInfo, w = C.getState().pluginOptions.get(o)?.get(l), g = C.getState().getHookResult(o, l);
|
|
330
|
+
if (!f?.formWrapper || !m)
|
|
331
|
+
return /* @__PURE__ */ A(O, { children: e });
|
|
332
|
+
const d = X(o, f.name), a = Y(m);
|
|
333
|
+
return f.formWrapper({
|
|
334
|
+
element: e,
|
|
335
|
+
path: i,
|
|
336
|
+
stateKey: o,
|
|
337
|
+
pluginName: f.name,
|
|
338
|
+
...a,
|
|
339
|
+
...d,
|
|
340
|
+
options: w,
|
|
341
|
+
hookData: g,
|
|
342
|
+
fieldType: T?.type,
|
|
343
|
+
wrapperDepth: s
|
|
344
|
+
});
|
|
345
|
+
});
|
|
287
346
|
export {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
347
|
+
Tt as FormElementWrapper,
|
|
348
|
+
wt as IsolatedComponentWrapper,
|
|
349
|
+
ct as ListItemWrapper,
|
|
350
|
+
Mt as MemoizedCogsItemWrapper,
|
|
351
|
+
at as ValidationWrapper,
|
|
352
|
+
P as useRegisterComponent
|
|
294
353
|
};
|
|
295
354
|
//# sourceMappingURL=Components.jsx.map
|