cogsbox-state 0.5.483 → 0.5.485

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