cogsbox-state 0.5.484 → 0.5.486

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,132 +1,132 @@
1
- import { jsx as E, Fragment as B } from "react/jsx-runtime";
2
- import { pluginStore as C } from "./pluginStore.js";
3
- import { createScopedMetadataContext as $, toDeconstructedMethods as Q } from "./plugins.js";
4
- import j, { memo as q, useState as F, useRef as N, useCallback as O, 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 _ } 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: v, getShadowMetadata: b, getShadowValue: r } = M.getState(), s = v(o), y = b(o, t)?.validation, A = y?.status || "NOT_VALIDATED", g = (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 = g.filter((p) => p.severity === "error").map((p) => p.message), i = g.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, L = 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] = {
38
- hookData: L,
39
- getFieldMetaData: W.getFieldMetaData,
40
- setFieldMetaData: W.setFieldMetaData,
41
- removeFieldMetaData: W.removeFieldMetaData
37
+ y[W] = {
38
+ hookData: O,
39
+ getFieldMetaData: k.getFieldMetaData,
40
+ setFieldMetaData: k.setFieldMetaData,
41
+ removeFieldMetaData: k.removeFieldMetaData
42
42
  };
43
43
  }
44
- }), /* @__PURE__ */ E(B, { children: s?.formElements?.validation && !e?.validation?.disable ? s.formElements.validation({
45
- children: /* @__PURE__ */ E(j.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,
50
+ hasErrors: d.length > 0,
51
+ hasWarnings: a.length > 0,
52
52
  allErrors: g,
53
53
  path: t,
54
54
  getData: () => r(o, t),
55
- plugins: h
56
- }) : /* @__PURE__ */ E(j.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
67
  arraySetter: v,
68
- rebuildStateShape: b,
68
+ rebuildStateShape: p,
69
69
  renderFn: r
70
70
  }) {
71
- const [, s] = F({}), { ref: m, inView: y } = Z(), A = N(null), g = [e, ...o].join(".");
72
- H(e, t, s);
73
- const l = O(
74
- (a) => {
75
- A.current = a, m(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
77
  [m]
78
78
  );
79
79
  P(() => {
80
- const a = nt(g, (h) => {
81
- s({});
80
+ const s = ut(g, (y) => {
81
+ l({});
82
82
  });
83
- return () => a();
83
+ return () => s();
84
84
  }, [g]);
85
- const i = G(e, o);
86
- if (i === void 0) return null;
87
- const T = b({
88
- currentState: i,
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
91
  }), f = r(T, c, v);
92
92
  return j.isValidElement(f) ? j.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);
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
105
  formOpts: v,
106
- setState: b
106
+ setState: p
107
107
  }) {
108
- const r = N(z()).current, [, s] = F({}), m = N(null), y = [e, ...t].join(".");
109
- H(e, r, s);
110
- const g = 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 S = m.current;
120
- if (!S) return "input";
121
- const x = S.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 = S.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
  };
@@ -135,33 +135,33 @@ function Mt({
135
135
  elementType: w(),
136
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, (S) => {
140
- !f.current && i !== S && 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 S = M.getState().getShadowMetadata(e, t);
145
- S?.clientActivityState?.elements && (S.clientActivityState.elements.delete(r), d(e, t, S));
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 = O(
148
+ const y = L(
149
149
  (n) => {
150
- const d = M.getState().getShadowNode(e, t)?._meta?.typeInfo ?? g;
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 S = 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,45 +174,45 @@ 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: (S?.currentActivity?.details?.keystrokeCount || 0) + 1
177
+ keystrokeCount: (M?.currentActivity?.details?.keystrokeCount || 0) + 1
178
178
  }
179
- }), _({
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 = v?.debounceTime ?? 200;
186
- a.current = setTimeout(() => {
187
- f.current = !1, b(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
- b,
194
+ p,
195
195
  t,
196
196
  v?.debounceTime,
197
197
  g,
198
- l,
198
+ d,
199
199
  e,
200
200
  r
201
201
  ]
202
- ), p = O(() => {
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'
@@ -222,64 +222,66 @@ function Mt({
222
222
  cursorPosition: m.current?.selectionStart
223
223
  }
224
224
  });
225
- }, [e, t, r, i]), R = O(() => {
226
- const { getShadowMetadata: n, setShadowMetadata: d } = M.getState();
227
- a.current && (clearTimeout(a.current), a.current = null, f.current = !1, b(i, t, {
228
- updateType: "update",
229
- validationTrigger: "onBlur"
230
- }));
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" }));
231
228
  const u = n(e, t);
232
229
  if (u?.clientActivityState?.elements?.has(r)) {
233
- const S = u.clientActivityState.elements.get(r);
234
- S.currentActivity = void 0, d(e, t, u);
230
+ const M = u.clientActivityState.elements.get(r);
231
+ M.currentActivity = void 0, i(e, t, u);
235
232
  }
236
233
  const w = u?.clientActivityState?.elements?.get(r)?.currentActivity?.startTime;
237
- U({
234
+ at(e)?.validation?.onBlur && G(
235
+ {
236
+ stateKey: e,
237
+ path: t,
238
+ newValue: a,
239
+ updateType: "update"
240
+ },
241
+ "onBlur"
242
+ ), B({
238
243
  stateKey: e,
239
244
  activityType: "blur",
240
- // Changed from 'type'
241
245
  path: t,
242
246
  timestamp: Date.now(),
243
247
  duration: w ? Date.now() - w : void 0,
244
248
  details: {
245
249
  duration: w ? Date.now() - w : 0
246
250
  }
247
- }), K(e)?.validation?.onBlur && _({
248
- stateKey: e,
249
- path: t,
250
- newValue: i,
251
- updateType: "update"
252
- }, "onBlur");
253
- }, [i, b, t, e, r, l]), L = o({
251
+ });
252
+ }, [a, p, t, e, r, d]), O = o({
254
253
  path: t,
255
254
  componentId: r,
256
255
  meta: void 0
257
- }), W = new Proxy(L, {
258
- get(n, d) {
259
- return d === "$inputProps" ? {
260
- 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 ?? "",
261
263
  onChange: (u) => {
262
- h(u.target.value);
264
+ y(u.target.value);
263
265
  },
264
- onFocus: p,
265
- onBlur: R,
266
+ onFocus: S,
267
+ onBlur: W,
266
268
  ref: m
267
- } : n[d];
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];
268
270
  }
269
- }), J = c(W);
270
- return /* @__PURE__ */ E(ot, { formOpts: v, path: t, stateKey: e, children: J });
271
+ }), tt = c(K);
272
+ return /* @__PURE__ */ C(dt, { formOpts: v, path: t, stateKey: e, children: tt });
271
273
  }
272
- function H(e, t, o) {
274
+ function z(e, t, o) {
273
275
  const c = `${e}////${t}`;
274
- X(() => (tt(e, c, {
276
+ nt(() => (ct(e, c, {
275
277
  forceUpdate: () => o({}),
276
278
  paths: /* @__PURE__ */ new Set(),
277
279
  reactiveType: ["component"]
278
280
  }), () => {
279
- et(e, c);
281
+ lt(e, c);
280
282
  }), [e, c]);
281
283
  }
282
- function yt({
284
+ function Et({
283
285
  stateKey: e,
284
286
  path: t,
285
287
  // The path of the parent node (e.g. ['form'])
@@ -288,65 +290,65 @@ function yt({
288
290
  rebuildStateShape: c,
289
291
  renderFn: v
290
292
  }) {
291
- const [b] = F(() => z()), [, r] = F({});
292
- H(e, b, r);
293
- 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]);
294
296
  P(() => {
295
- const y = M.getState(), A = s.map((g) => y.subscribeToPath(g, () => {
297
+ const h = b.getState(), A = l.map((g) => h.subscribeToPath(g, () => {
296
298
  r({});
297
299
  }));
298
300
  return () => {
299
301
  A.forEach((g) => g());
300
302
  };
301
- }, [s]);
303
+ }, [l]);
302
304
  const m = c({
303
305
  path: t,
304
- componentId: b,
306
+ componentId: p,
305
307
  meta: void 0
306
308
  });
307
- return /* @__PURE__ */ E(B, { children: v(m) });
309
+ return /* @__PURE__ */ C(q, { children: v(m) });
308
310
  }
309
- q(function({
311
+ Q(function({
310
312
  children: t,
311
313
  stateKey: o,
312
314
  path: c,
313
315
  pluginName: v,
314
- wrapperDepth: b
316
+ wrapperDepth: p
315
317
  }) {
316
- const [, r] = F({});
318
+ const [, r] = R({});
317
319
  P(() => {
318
320
  const T = [o, ...c].join(".");
319
- return M.getState().subscribeToPath(T, () => {
321
+ return b.getState().subscribeToPath(T, () => {
320
322
  r({});
321
323
  });
322
324
  }, [o, c]);
323
- const s = C.getState().registeredPlugins.find((T) => T.name === v), m = C.getState().stateHandlers.get(o), y = M.getState().getShadowNode(o, c)?._meta?.typeInfo, A = C.getState().pluginOptions.get(o)?.get(v), g = C.getState().getHookResult(o, v);
324
- if (!s?.formWrapper || !m)
325
- return /* @__PURE__ */ E(B, { children: t });
326
- const l = Q(m), 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(
327
329
  o,
328
- s.name,
330
+ l.name,
329
331
  c
330
332
  );
331
- return s.formWrapper({
333
+ return l.formWrapper({
332
334
  element: t,
333
335
  path: c,
334
336
  stateKey: o,
335
- pluginName: s.name,
336
- ...l,
337
- ...i,
337
+ pluginName: l.name,
338
+ ...d,
339
+ ...a,
338
340
  options: A,
339
341
  hookData: g,
340
- fieldType: y?.type,
341
- wrapperDepth: b
342
+ fieldType: h?.type,
343
+ wrapperDepth: p
342
344
  });
343
345
  });
344
346
  export {
345
- Mt as FormElementWrapper,
346
- yt as IsolatedComponentWrapper,
347
- rt as ListItemWrapper,
348
- bt as MemoizedCogsItemWrapper,
349
- ot as ValidationWrapper,
350
- H 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
351
353
  };
352
354
  //# sourceMappingURL=Components.js.map