cogsbox-state 0.5.473 → 0.5.475-canary.0

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