cogsbox-state 0.5.485 → 0.5.487

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