cogsbox-state 0.5.471 → 0.5.472
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 +15 -5
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +915 -890
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.jsx +214 -223
- package/dist/Components.jsx.map +1 -1
- package/dist/store.d.ts +23 -15
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +476 -231
- package/dist/store.js.map +1 -1
- package/package.json +8 -13
- package/src/CogsState.tsx +221 -161
- package/src/Components.tsx +215 -169
- package/src/store.ts +476 -39
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,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAQN,MAAM,OAAO,CAAC;AAuBf,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,E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AAS,CAAC;IAC9D,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;CACf,2CAoTA;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,295 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { getGlobalStore as
|
|
4
|
-
import { useInView as
|
|
5
|
-
import { v4 as
|
|
6
|
-
import { isDeepEqual as
|
|
1
|
+
import { jsx as N, Fragment as X } from "react/jsx-runtime";
|
|
2
|
+
import Q, { memo as ne, useState as R, useRef as D, useCallback as z, useEffect as w, useLayoutEffect as Y } from "react";
|
|
3
|
+
import { getGlobalStore as y, formRefStore as oe } from "./store.js";
|
|
4
|
+
import { useInView as se } from "react-intersection-observer";
|
|
5
|
+
import { v4 as Z } from "uuid";
|
|
6
|
+
import { isDeepEqual as ie } from "./utility.js";
|
|
7
7
|
const {
|
|
8
|
-
getInitialOptions:
|
|
9
|
-
getShadowMetadata:
|
|
10
|
-
setShadowMetadata:
|
|
11
|
-
getShadowValue:
|
|
12
|
-
registerComponent:
|
|
13
|
-
unregisterComponent:
|
|
14
|
-
notifyPathSubscribers:
|
|
15
|
-
subscribeToPath:
|
|
16
|
-
} =
|
|
17
|
-
function
|
|
18
|
-
formOpts:
|
|
19
|
-
path:
|
|
8
|
+
getInitialOptions: ae,
|
|
9
|
+
getShadowMetadata: ce,
|
|
10
|
+
setShadowMetadata: U,
|
|
11
|
+
getShadowValue: x,
|
|
12
|
+
registerComponent: le,
|
|
13
|
+
unregisterComponent: ue,
|
|
14
|
+
notifyPathSubscribers: de,
|
|
15
|
+
subscribeToPath: fe
|
|
16
|
+
} = y.getState();
|
|
17
|
+
function ge({
|
|
18
|
+
formOpts: t,
|
|
19
|
+
path: e,
|
|
20
20
|
stateKey: n,
|
|
21
|
-
children:
|
|
21
|
+
children: s
|
|
22
22
|
}) {
|
|
23
|
-
const { getInitialOptions: l, getShadowMetadata:
|
|
24
|
-
...
|
|
25
|
-
path:
|
|
26
|
-
})), u =
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
children: /* @__PURE__ */
|
|
29
|
-
status:
|
|
23
|
+
const { getInitialOptions: l, getShadowMetadata: i, getShadowValue: a } = y.getState(), f = l(n), T = i(n, e)?.validation, c = T?.status || "NOT_VALIDATED", g = (T?.errors || []).map((o) => ({
|
|
24
|
+
...o,
|
|
25
|
+
path: e
|
|
26
|
+
})), u = g.filter((o) => o.severity === "error").map((o) => o.message), d = g.filter((o) => o.severity === "warning").map((o) => o.message), E = u[0] || d[0], m = u.length > 0 ? "error" : d.length > 0 ? "warning" : void 0;
|
|
27
|
+
return /* @__PURE__ */ N(X, { children: f?.formElements?.validation && !t?.validation?.disable ? f.formElements.validation({
|
|
28
|
+
children: /* @__PURE__ */ N(Q.Fragment, { children: s }, e.toString()),
|
|
29
|
+
status: c,
|
|
30
30
|
// Now passes the new ValidationStatus type
|
|
31
|
-
message:
|
|
32
|
-
severity:
|
|
31
|
+
message: t?.validation?.hideMessage ? "" : t?.validation?.message || E || "",
|
|
32
|
+
severity: m,
|
|
33
33
|
hasErrors: u.length > 0,
|
|
34
|
-
hasWarnings:
|
|
35
|
-
allErrors:
|
|
36
|
-
path:
|
|
37
|
-
getData: () => a(n,
|
|
38
|
-
}) : /* @__PURE__ */
|
|
34
|
+
hasWarnings: d.length > 0,
|
|
35
|
+
allErrors: g,
|
|
36
|
+
path: e,
|
|
37
|
+
getData: () => a(n, e)
|
|
38
|
+
}) : /* @__PURE__ */ N(Q.Fragment, { children: s }, e.toString()) });
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
(
|
|
40
|
+
const Te = ne(
|
|
41
|
+
me,
|
|
42
|
+
(t, e) => t.itemPath.join(".") === e.itemPath.join(".") && t.stateKey === e.stateKey && t.itemComponentId === e.itemComponentId && t.localIndex === e.localIndex
|
|
43
43
|
);
|
|
44
|
-
function
|
|
45
|
-
stateKey:
|
|
46
|
-
itemComponentId:
|
|
44
|
+
function me({
|
|
45
|
+
stateKey: t,
|
|
46
|
+
itemComponentId: e,
|
|
47
47
|
itemPath: n,
|
|
48
|
-
localIndex:
|
|
48
|
+
localIndex: s,
|
|
49
49
|
arraySetter: l,
|
|
50
|
-
rebuildStateShape:
|
|
50
|
+
rebuildStateShape: i,
|
|
51
51
|
renderFn: a
|
|
52
52
|
}) {
|
|
53
|
-
const [, f] =
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
(
|
|
57
|
-
|
|
53
|
+
const [, f] = R({}), { ref: I, inView: T } = se(), c = D(null), g = Se(c), u = D(!1), d = [t, ...n].join(".");
|
|
54
|
+
$(t, e, f);
|
|
55
|
+
const E = z(
|
|
56
|
+
(S) => {
|
|
57
|
+
c.current = S, I(S);
|
|
58
58
|
},
|
|
59
|
-
[
|
|
59
|
+
[I]
|
|
60
60
|
);
|
|
61
|
-
|
|
62
|
-
const
|
|
61
|
+
w(() => {
|
|
62
|
+
const S = fe(d, (O) => {
|
|
63
63
|
f({});
|
|
64
64
|
});
|
|
65
|
-
return () =>
|
|
66
|
-
}, [
|
|
67
|
-
if (!
|
|
65
|
+
return () => S();
|
|
66
|
+
}, [d]), w(() => {
|
|
67
|
+
if (!T || !g || u.current)
|
|
68
68
|
return;
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
69
|
+
const S = c.current;
|
|
70
|
+
if (S && S.offsetHeight > 0) {
|
|
71
71
|
u.current = !0;
|
|
72
|
-
const
|
|
73
|
-
|
|
72
|
+
const O = S.offsetHeight;
|
|
73
|
+
U(t, n, {
|
|
74
74
|
virtualizer: {
|
|
75
|
-
itemHeight:
|
|
76
|
-
domRef:
|
|
75
|
+
itemHeight: O,
|
|
76
|
+
domRef: S
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
-
const
|
|
80
|
-
|
|
79
|
+
const B = n.slice(0, -1), F = [t, ...B].join(".");
|
|
80
|
+
de(F, {
|
|
81
81
|
type: "ITEMHEIGHT",
|
|
82
82
|
itemKey: n.join("."),
|
|
83
|
-
ref:
|
|
83
|
+
ref: c.current
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
}, [
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
86
|
+
}, [T, g, t, n]);
|
|
87
|
+
const m = x(t, n);
|
|
88
|
+
if (m === void 0)
|
|
89
89
|
return null;
|
|
90
|
-
const
|
|
91
|
-
currentState:
|
|
90
|
+
const o = i({
|
|
91
|
+
currentState: m,
|
|
92
92
|
path: n,
|
|
93
|
-
componentId:
|
|
94
|
-
}),
|
|
95
|
-
return /* @__PURE__ */
|
|
93
|
+
componentId: e
|
|
94
|
+
}), M = a(o, s, l);
|
|
95
|
+
return /* @__PURE__ */ N("div", { ref: E, children: M });
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
stateKey:
|
|
99
|
-
path:
|
|
97
|
+
function Ee({
|
|
98
|
+
stateKey: t,
|
|
99
|
+
path: e,
|
|
100
100
|
rebuildStateShape: n,
|
|
101
|
-
renderFn:
|
|
101
|
+
renderFn: s,
|
|
102
102
|
formOpts: l,
|
|
103
|
-
setState:
|
|
103
|
+
setState: i
|
|
104
104
|
}) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
!
|
|
110
|
-
}, [
|
|
111
|
-
const r =
|
|
112
|
-
!
|
|
105
|
+
const a = D(Z()).current, [, f] = R({}), I = [t, ...e].join(".");
|
|
106
|
+
$(t, a, f);
|
|
107
|
+
const c = y.getState().getShadowNode(t, e)?._meta?.typeInfo, g = c?.schema, u = x(t, e), [d, E] = R(u), m = D(!1), o = D(null);
|
|
108
|
+
w(() => {
|
|
109
|
+
!m.current && !ie(u, d) && E(u);
|
|
110
|
+
}, [u]), w(() => {
|
|
111
|
+
const r = y.getState().subscribeToPath(I, (b) => {
|
|
112
|
+
!m.current && d !== b && f({});
|
|
113
113
|
});
|
|
114
114
|
return () => {
|
|
115
|
-
r(),
|
|
115
|
+
r(), o.current && (clearTimeout(o.current), m.current = !1);
|
|
116
116
|
};
|
|
117
117
|
}, []);
|
|
118
|
-
const
|
|
119
|
-
(r) => {
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
118
|
+
const M = z(
|
|
119
|
+
(r, b) => {
|
|
120
|
+
if (!y.getState().getShadowMetadata(t, [])?.features?.validationEnabled) return;
|
|
121
|
+
const h = ae(t)?.validation;
|
|
122
|
+
if (!h) return;
|
|
123
|
+
const V = ce(t, e) || {}, K = V?.validation?.status;
|
|
124
|
+
let C = !1, W;
|
|
125
|
+
if (console.log("trigger", b, h), b === "onBlur" && h.onBlur ? (C = !0, W = h.onBlur ?? "error") : b === "onChange" && (h.onChange ? (C = !0, W = h.onChange) : K === "INVALID" && (C = !0, W = "warning")), !C) return;
|
|
126
|
+
let v = null;
|
|
127
|
+
if (console.log(
|
|
128
|
+
"shouldValidate 33",
|
|
129
|
+
e,
|
|
130
|
+
g,
|
|
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);
|
|
135
161
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
}
|
|
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 };
|
|
166
169
|
}
|
|
167
|
-
}, S), f({});
|
|
168
|
-
},
|
|
169
|
-
[s, t, l?.debounceTime, e]
|
|
170
|
-
), V = J(async () => {
|
|
171
|
-
if (console.log("handleBlur triggered"), c.current && (clearTimeout(c.current), c.current = null, u.current = !1, s(i, t, { updateType: "update" })), !H(e, [])?.features?.validationEnabled) return;
|
|
172
|
-
const { getInitialOptions: g } = b.getState(), S = g(e)?.validation, D = S?.zodSchemaV4 || S?.zodSchemaV3;
|
|
173
|
-
if (!D) return;
|
|
174
|
-
const M = H(e, t);
|
|
175
|
-
I(e, t, {
|
|
176
|
-
...M,
|
|
177
|
-
validation: {
|
|
178
|
-
status: "VALIDATING",
|
|
179
|
-
errors: [],
|
|
180
|
-
lastValidated: Date.now(),
|
|
181
|
-
validatedValue: i
|
|
182
170
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (E.success)
|
|
186
|
-
I(e, t, {
|
|
187
|
-
...M,
|
|
171
|
+
v && (v.success ? U(t, e, {
|
|
172
|
+
...V,
|
|
188
173
|
validation: {
|
|
189
174
|
status: "VALID",
|
|
190
175
|
errors: [],
|
|
191
176
|
lastValidated: Date.now(),
|
|
192
|
-
validatedValue:
|
|
177
|
+
validatedValue: r
|
|
193
178
|
}
|
|
194
|
-
})
|
|
195
|
-
|
|
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,
|
|
179
|
+
}) : U(t, e, {
|
|
180
|
+
...V,
|
|
208
181
|
validation: {
|
|
209
182
|
status: "INVALID",
|
|
210
|
-
errors:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
183
|
+
errors: [
|
|
184
|
+
{
|
|
185
|
+
source: "client",
|
|
186
|
+
message: v.message,
|
|
187
|
+
severity: W
|
|
188
|
+
}
|
|
189
|
+
],
|
|
216
190
|
lastValidated: Date.now(),
|
|
217
|
-
validatedValue:
|
|
191
|
+
validatedValue: r
|
|
218
192
|
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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);
|
|
199
|
+
const b = l?.debounceTime ?? 200;
|
|
200
|
+
o.current = setTimeout(() => {
|
|
201
|
+
m.current = !1, i(r, e, { updateType: "update" });
|
|
202
|
+
}, b);
|
|
203
|
+
},
|
|
204
|
+
[
|
|
205
|
+
i,
|
|
206
|
+
e,
|
|
207
|
+
l?.debounceTime,
|
|
208
|
+
M,
|
|
209
|
+
c,
|
|
210
|
+
u
|
|
211
|
+
]
|
|
212
|
+
), O = z(() => {
|
|
213
|
+
o.current && (clearTimeout(o.current), o.current = null, m.current = !1, i(d, e, { updateType: "update" })), M(d, "onBlur");
|
|
214
|
+
}, [d, i, e, M]), B = n({
|
|
215
|
+
path: e,
|
|
224
216
|
componentId: a,
|
|
225
217
|
meta: void 0
|
|
226
|
-
}),
|
|
227
|
-
get(r,
|
|
228
|
-
return
|
|
229
|
-
value:
|
|
230
|
-
onChange: (
|
|
231
|
-
|
|
218
|
+
}), F = new Proxy(B, {
|
|
219
|
+
get(r, b) {
|
|
220
|
+
return b === "$inputProps" ? {
|
|
221
|
+
value: d ?? "",
|
|
222
|
+
onChange: (J) => {
|
|
223
|
+
S(J.target.value);
|
|
232
224
|
},
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} : r[g];
|
|
225
|
+
onBlur: O,
|
|
226
|
+
ref: oe.getState().getFormRef(t + "." + e.join("."))
|
|
227
|
+
} : r[b];
|
|
237
228
|
}
|
|
238
229
|
});
|
|
239
|
-
return /* @__PURE__ */
|
|
230
|
+
return /* @__PURE__ */ N(ge, { formOpts: l, path: e, stateKey: t, children: s(F) });
|
|
240
231
|
}
|
|
241
|
-
function
|
|
242
|
-
const
|
|
243
|
-
|
|
232
|
+
function $(t, e, n) {
|
|
233
|
+
const s = `${t}////${e}`;
|
|
234
|
+
Y(() => (le(t, s, {
|
|
244
235
|
forceUpdate: () => n({}),
|
|
245
236
|
paths: /* @__PURE__ */ new Set(),
|
|
246
237
|
reactiveType: ["component"]
|
|
247
238
|
}), () => {
|
|
248
|
-
|
|
249
|
-
}), [
|
|
239
|
+
ue(t, s);
|
|
240
|
+
}), [t, s]);
|
|
250
241
|
}
|
|
251
|
-
const
|
|
252
|
-
const [
|
|
253
|
-
return
|
|
254
|
-
if (!
|
|
242
|
+
const Se = (t) => {
|
|
243
|
+
const [e, n] = R(!1);
|
|
244
|
+
return Y(() => {
|
|
245
|
+
if (!t.current) {
|
|
255
246
|
n(!0);
|
|
256
247
|
return;
|
|
257
248
|
}
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
249
|
+
const s = Array.from(t.current.querySelectorAll("img"));
|
|
250
|
+
if (s.length === 0) {
|
|
260
251
|
n(!0);
|
|
261
252
|
return;
|
|
262
253
|
}
|
|
263
254
|
let l = 0;
|
|
264
|
-
const
|
|
265
|
-
l++, l ===
|
|
255
|
+
const i = () => {
|
|
256
|
+
l++, l === s.length && n(!0);
|
|
266
257
|
};
|
|
267
|
-
return
|
|
268
|
-
a.complete ?
|
|
258
|
+
return s.forEach((a) => {
|
|
259
|
+
a.complete ? i() : (a.addEventListener("load", i), a.addEventListener("error", i));
|
|
269
260
|
}), () => {
|
|
270
|
-
|
|
271
|
-
a.removeEventListener("load",
|
|
261
|
+
s.forEach((a) => {
|
|
262
|
+
a.removeEventListener("load", i), a.removeEventListener("error", i);
|
|
272
263
|
});
|
|
273
264
|
};
|
|
274
|
-
}, [
|
|
265
|
+
}, [t.current]), e;
|
|
275
266
|
};
|
|
276
|
-
function
|
|
277
|
-
stateKey:
|
|
278
|
-
path:
|
|
267
|
+
function Me({
|
|
268
|
+
stateKey: t,
|
|
269
|
+
path: e,
|
|
279
270
|
rebuildStateShape: n,
|
|
280
|
-
renderFn:
|
|
271
|
+
renderFn: s
|
|
281
272
|
}) {
|
|
282
|
-
const [l] =
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
273
|
+
const [l] = R(() => Z()), [, i] = R({}), a = [t, ...e].join(".");
|
|
274
|
+
$(t, l, i), w(() => {
|
|
275
|
+
const I = y.getState().subscribeToPath(a, () => {
|
|
276
|
+
i({});
|
|
286
277
|
});
|
|
287
|
-
return () =>
|
|
278
|
+
return () => I();
|
|
288
279
|
}, [a]);
|
|
289
280
|
const f = n({
|
|
290
|
-
path:
|
|
281
|
+
path: e,
|
|
291
282
|
componentId: l,
|
|
292
283
|
meta: void 0
|
|
293
284
|
});
|
|
294
|
-
return /* @__PURE__ */
|
|
285
|
+
return /* @__PURE__ */ N(X, { children: s(f) });
|
|
295
286
|
}
|
|
296
287
|
export {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
288
|
+
Ee as FormElementWrapper,
|
|
289
|
+
Me as IsolatedComponentWrapper,
|
|
290
|
+
me as ListItemWrapper,
|
|
291
|
+
Te as MemoizedCogsItemWrapper,
|
|
292
|
+
ge as ValidationWrapper,
|
|
293
|
+
$ as useRegisterComponent
|
|
303
294
|
};
|
|
304
295
|
//# sourceMappingURL=Components.jsx.map
|