cogsbox-state 0.5.471 → 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/README.md +2 -5
- package/dist/CogsState.d.ts +105 -79
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +1082 -987
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.jsx +293 -243
- 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 +69 -26
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +436 -152
- 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 +18 -13
- package/src/CogsState.tsx +719 -458
- package/src/Components.tsx +304 -180
- 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 +881 -189
- 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,304 +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
|
|
18
|
-
formOpts:
|
|
19
|
-
path:
|
|
20
|
-
stateKey:
|
|
21
|
-
children:
|
|
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({
|
|
21
|
+
formOpts: t,
|
|
22
|
+
path: e,
|
|
23
|
+
stateKey: o,
|
|
24
|
+
children: i
|
|
22
25
|
}) {
|
|
23
|
-
const { getInitialOptions: l, getShadowMetadata: s, getShadowValue:
|
|
24
|
-
...
|
|
25
|
-
path:
|
|
26
|
-
})),
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
children: /* @__PURE__ */
|
|
29
|
-
status:
|
|
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,
|
|
28
|
+
path: e
|
|
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:
|
|
32
|
-
severity:
|
|
33
|
-
hasErrors:
|
|
34
|
-
hasWarnings:
|
|
35
|
-
allErrors:
|
|
36
|
-
path:
|
|
37
|
-
getData: () =>
|
|
38
|
-
}) : /* @__PURE__ */
|
|
34
|
+
message: t?.validation?.hideMessage ? "" : t?.validation?.message || M || "",
|
|
35
|
+
severity: S,
|
|
36
|
+
hasErrors: d.length > 0,
|
|
37
|
+
hasWarnings: a.length > 0,
|
|
38
|
+
allErrors: g,
|
|
39
|
+
path: e,
|
|
40
|
+
getData: () => r(o, e)
|
|
41
|
+
}) : /* @__PURE__ */ A(U.Fragment, { children: i }, e.toString()) });
|
|
39
42
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
(
|
|
43
|
+
const Mt = _(
|
|
44
|
+
ct,
|
|
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
|
|
45
|
-
stateKey:
|
|
46
|
-
itemComponentId:
|
|
47
|
-
itemPath:
|
|
48
|
-
localIndex:
|
|
47
|
+
function ct({
|
|
48
|
+
stateKey: t,
|
|
49
|
+
itemComponentId: e,
|
|
50
|
+
itemPath: o,
|
|
51
|
+
localIndex: i,
|
|
49
52
|
arraySetter: l,
|
|
50
53
|
rebuildStateShape: s,
|
|
51
|
-
renderFn:
|
|
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 (!
|
|
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
|
-
}, [
|
|
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
|
-
componentId:
|
|
94
|
-
}),
|
|
95
|
-
return /* @__PURE__ */
|
|
93
|
+
const c = s({
|
|
94
|
+
currentState: S,
|
|
95
|
+
path: o,
|
|
96
|
+
componentId: e
|
|
97
|
+
}), D = r(c, i, l);
|
|
98
|
+
return /* @__PURE__ */ A("div", { ref: M, children: D });
|
|
96
99
|
}
|
|
97
|
-
function
|
|
98
|
-
stateKey:
|
|
99
|
-
path:
|
|
100
|
-
rebuildStateShape:
|
|
101
|
-
renderFn:
|
|
100
|
+
function Tt({
|
|
101
|
+
stateKey: t,
|
|
102
|
+
path: e,
|
|
103
|
+
rebuildStateShape: o,
|
|
104
|
+
renderFn: i,
|
|
102
105
|
formOpts: l,
|
|
103
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
|
|
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));
|
|
159
|
+
}
|
|
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);
|
|
171
|
+
const b = l?.debounceTime ?? 200;
|
|
122
172
|
c.current = setTimeout(() => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
I(e, t, {
|
|
129
|
-
...O,
|
|
130
|
-
validation: {
|
|
131
|
-
status: "VALID",
|
|
132
|
-
errors: [],
|
|
133
|
-
lastValidated: Date.now(),
|
|
134
|
-
validatedValue: r
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
else {
|
|
138
|
-
const W = ("issues" in y.error ? y.error.issues : y.error.errors).filter(
|
|
139
|
-
(T) => JSON.stringify(T.path) === JSON.stringify(t)
|
|
140
|
-
);
|
|
141
|
-
W.length > 0 ? I(e, t, {
|
|
142
|
-
...O,
|
|
143
|
-
validation: {
|
|
144
|
-
status: "INVALID",
|
|
145
|
-
errors: [
|
|
146
|
-
{
|
|
147
|
-
source: "client",
|
|
148
|
-
message: W[0]?.message,
|
|
149
|
-
severity: "warning"
|
|
150
|
-
// Gentle error during typing
|
|
151
|
-
}
|
|
152
|
-
],
|
|
153
|
-
lastValidated: Date.now(),
|
|
154
|
-
validatedValue: r
|
|
155
|
-
}
|
|
156
|
-
}) : I(e, t, {
|
|
157
|
-
...O,
|
|
158
|
-
validation: {
|
|
159
|
-
status: "VALID",
|
|
160
|
-
errors: [],
|
|
161
|
-
lastValidated: Date.now(),
|
|
162
|
-
validatedValue: r
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}, S), f({});
|
|
173
|
+
S.current = !1, s(n, e, {
|
|
174
|
+
updateType: "update",
|
|
175
|
+
validationTrigger: "onChange"
|
|
176
|
+
});
|
|
177
|
+
}, b);
|
|
168
178
|
},
|
|
169
|
-
[
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
validation: {
|
|
189
|
-
status: "VALID",
|
|
190
|
-
errors: [],
|
|
191
|
-
lastValidated: Date.now(),
|
|
192
|
-
validatedValue: i
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
else {
|
|
196
|
-
const O = ("issues" in E.error ? E.error.issues : E.error.errors).filter((A) => {
|
|
197
|
-
if (t.some((T) => T.startsWith("id:"))) {
|
|
198
|
-
const T = t[0].startsWith("id:") ? [] : t.slice(0, -1), P = b.getState().getShadowMetadata(e, T);
|
|
199
|
-
if (P?.arrayKeys) {
|
|
200
|
-
const $ = [e, ...t.slice(0, -1)].join("."), q = P.arrayKeys.indexOf($), k = [...T, q, ...t.slice(-1)];
|
|
201
|
-
return JSON.stringify(A.path) === JSON.stringify(k);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return JSON.stringify(A.path) === JSON.stringify(t);
|
|
205
|
-
});
|
|
206
|
-
I(e, t, {
|
|
207
|
-
...M,
|
|
208
|
-
validation: {
|
|
209
|
-
status: "INVALID",
|
|
210
|
-
errors: O.map((A) => ({
|
|
211
|
-
source: "client",
|
|
212
|
-
message: A.message,
|
|
213
|
-
severity: "error"
|
|
214
|
-
// Hard error on blur
|
|
215
|
-
})),
|
|
216
|
-
lastValidated: Date.now(),
|
|
217
|
-
validatedValue: i
|
|
179
|
+
[
|
|
180
|
+
s,
|
|
181
|
+
e,
|
|
182
|
+
l?.debounceTime,
|
|
183
|
+
g,
|
|
184
|
+
d,
|
|
185
|
+
t,
|
|
186
|
+
r
|
|
187
|
+
]
|
|
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
|
|
218
198
|
}
|
|
219
|
-
});
|
|
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);
|
|
220
217
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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({
|
|
230
|
+
path: e,
|
|
231
|
+
componentId: r,
|
|
225
232
|
meta: void 0
|
|
226
|
-
}),
|
|
227
|
-
get(
|
|
228
|
-
return
|
|
229
|
-
value:
|
|
230
|
-
onChange: (
|
|
231
|
-
|
|
233
|
+
}), G = new Proxy(N, {
|
|
234
|
+
get(n, p) {
|
|
235
|
+
return p === "$inputProps" ? {
|
|
236
|
+
value: a ?? "",
|
|
237
|
+
onChange: (u) => {
|
|
238
|
+
h(u.target.value);
|
|
232
239
|
},
|
|
233
|
-
|
|
234
|
-
onBlur:
|
|
235
|
-
ref:
|
|
236
|
-
} :
|
|
240
|
+
onFocus: H,
|
|
241
|
+
onBlur: F,
|
|
242
|
+
ref: m
|
|
243
|
+
} : n[p];
|
|
237
244
|
}
|
|
238
|
-
})
|
|
239
|
-
|
|
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 });
|
|
240
259
|
}
|
|
241
|
-
function
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
forceUpdate: () =>
|
|
260
|
+
function P(t, e, o) {
|
|
261
|
+
const i = `${t}////${e}`;
|
|
262
|
+
$(() => (nt(t, i, {
|
|
263
|
+
forceUpdate: () => o({}),
|
|
245
264
|
paths: /* @__PURE__ */ new Set(),
|
|
246
265
|
reactiveType: ["component"]
|
|
247
266
|
}), () => {
|
|
248
|
-
|
|
249
|
-
}), [
|
|
267
|
+
ot(t, i);
|
|
268
|
+
}), [t, i]);
|
|
250
269
|
}
|
|
251
|
-
const
|
|
252
|
-
const [
|
|
253
|
-
return
|
|
254
|
-
if (!
|
|
255
|
-
|
|
270
|
+
const st = (t) => {
|
|
271
|
+
const [e, o] = E(!1);
|
|
272
|
+
return $(() => {
|
|
273
|
+
if (!t.current) {
|
|
274
|
+
o(!0);
|
|
256
275
|
return;
|
|
257
276
|
}
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
|
|
277
|
+
const i = Array.from(t.current.querySelectorAll("img"));
|
|
278
|
+
if (i.length === 0) {
|
|
279
|
+
o(!0);
|
|
261
280
|
return;
|
|
262
281
|
}
|
|
263
282
|
let l = 0;
|
|
264
283
|
const s = () => {
|
|
265
|
-
l++, l ===
|
|
284
|
+
l++, l === i.length && o(!0);
|
|
266
285
|
};
|
|
267
|
-
return
|
|
268
|
-
|
|
286
|
+
return i.forEach((r) => {
|
|
287
|
+
r.complete ? s() : (r.addEventListener("load", s), r.addEventListener("error", s));
|
|
269
288
|
}), () => {
|
|
270
|
-
|
|
271
|
-
|
|
289
|
+
i.forEach((r) => {
|
|
290
|
+
r.removeEventListener("load", s), r.removeEventListener("error", s);
|
|
272
291
|
});
|
|
273
292
|
};
|
|
274
|
-
}, [
|
|
293
|
+
}, [t.current]), e;
|
|
275
294
|
};
|
|
276
|
-
function
|
|
277
|
-
stateKey:
|
|
278
|
-
path:
|
|
279
|
-
rebuildStateShape:
|
|
280
|
-
renderFn:
|
|
295
|
+
function wt({
|
|
296
|
+
stateKey: t,
|
|
297
|
+
path: e,
|
|
298
|
+
rebuildStateShape: o,
|
|
299
|
+
renderFn: i
|
|
281
300
|
}) {
|
|
282
|
-
const [l] =
|
|
283
|
-
|
|
284
|
-
const
|
|
301
|
+
const [l] = E(() => q()), [, s] = E({}), r = [t, ...e].join(".");
|
|
302
|
+
P(t, l, s), R(() => {
|
|
303
|
+
const m = v.getState().subscribeToPath(r, () => {
|
|
285
304
|
s({});
|
|
286
305
|
});
|
|
287
|
-
return () =>
|
|
288
|
-
}, [
|
|
289
|
-
const f =
|
|
290
|
-
path:
|
|
306
|
+
return () => m();
|
|
307
|
+
}, [r]);
|
|
308
|
+
const f = o({
|
|
309
|
+
path: e,
|
|
291
310
|
componentId: l,
|
|
292
311
|
meta: void 0
|
|
293
312
|
});
|
|
294
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ A(O, { children: i(f) });
|
|
295
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
|
+
});
|
|
296
346
|
export {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
347
|
+
Tt as FormElementWrapper,
|
|
348
|
+
wt as IsolatedComponentWrapper,
|
|
349
|
+
ct as ListItemWrapper,
|
|
350
|
+
Mt as MemoizedCogsItemWrapper,
|
|
351
|
+
at as ValidationWrapper,
|
|
352
|
+
P as useRegisterComponent
|
|
303
353
|
};
|
|
304
354
|
//# sourceMappingURL=Components.jsx.map
|