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