cogsbox-state 0.5.470 → 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.
@@ -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,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,CAAC;CACt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AAE,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,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"}
@@ -1,304 +1,295 @@
1
- import { jsx as w, Fragment as x } from "react/jsx-runtime";
2
- import U, { memo as _, useState as p, useRef as j, useCallback as J, useEffect as C, useLayoutEffect as B } from "react";
3
- import { getGlobalStore as b, formRefStore as Q } from "./store.js";
4
- import { useInView as X } from "react-intersection-observer";
5
- import { v4 as G } from "uuid";
6
- import { isDeepEqual as Y } from "./utility.js";
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: Z,
9
- getShadowMetadata: H,
10
- setShadowMetadata: I,
11
- getShadowValue: R,
12
- registerComponent: K,
13
- unregisterComponent: ee,
14
- notifyPathSubscribers: te,
15
- subscribeToPath: re
16
- } = b.getState();
17
- function ne({
18
- formOpts: e,
19
- path: t,
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: o
21
+ children: s
22
22
  }) {
23
- const { getInitialOptions: l, getShadowMetadata: s, getShadowValue: a } = b.getState(), f = l(n), m = s(n, t)?.validation, i = m?.status || "NOT_VALIDATED", v = (m?.errors || []).map((d) => ({
24
- ...d,
25
- path: t
26
- })), u = v.filter((d) => d.severity === "error").map((d) => d.message), c = v.filter((d) => d.severity === "warning").map((d) => d.message), L = u[0] || c[0], V = u.length > 0 ? "error" : c.length > 0 ? "warning" : void 0;
27
- return /* @__PURE__ */ w(x, { children: f?.formElements?.validation && !e?.validation?.disable ? f.formElements.validation({
28
- children: /* @__PURE__ */ w(U.Fragment, { children: o }, t.toString()),
29
- status: i,
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: e?.validation?.hideMessage ? "" : e?.validation?.message || L || "",
32
- severity: V,
31
+ message: t?.validation?.hideMessage ? "" : t?.validation?.message || E || "",
32
+ severity: m,
33
33
  hasErrors: u.length > 0,
34
- hasWarnings: c.length > 0,
35
- allErrors: v,
36
- path: t,
37
- getData: () => a(n, t)
38
- }) : /* @__PURE__ */ w(U.Fragment, { children: o }, t.toString()) });
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 me = _(
41
- oe,
42
- (e, t) => e.itemPath.join(".") === t.itemPath.join(".") && e.stateKey === t.stateKey && e.itemComponentId === t.itemComponentId && e.localIndex === t.localIndex
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 oe({
45
- stateKey: e,
46
- itemComponentId: t,
44
+ function me({
45
+ stateKey: t,
46
+ itemComponentId: e,
47
47
  itemPath: n,
48
- localIndex: o,
48
+ localIndex: s,
49
49
  arraySetter: l,
50
- rebuildStateShape: s,
50
+ rebuildStateShape: i,
51
51
  renderFn: a
52
52
  }) {
53
- const [, f] = p({}), { ref: h, inView: m } = X(), i = j(null), v = se(i), u = j(!1), c = [e, ...n].join(".");
54
- F(e, t, f);
55
- const L = J(
56
- (r) => {
57
- i.current = r, h(r);
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
- [h]
59
+ [I]
60
60
  );
61
- C(() => {
62
- const r = re(c, (g) => {
61
+ w(() => {
62
+ const S = fe(d, (O) => {
63
63
  f({});
64
64
  });
65
- return () => r();
66
- }, [c]), C(() => {
67
- if (!m || !v || u.current)
65
+ return () => S();
66
+ }, [d]), w(() => {
67
+ if (!T || !g || u.current)
68
68
  return;
69
- const r = i.current;
70
- if (r && r.offsetHeight > 0) {
69
+ const S = c.current;
70
+ if (S && S.offsetHeight > 0) {
71
71
  u.current = !0;
72
- const g = r.offsetHeight;
73
- I(e, n, {
72
+ const O = S.offsetHeight;
73
+ U(t, n, {
74
74
  virtualizer: {
75
- itemHeight: g,
76
- domRef: r
75
+ itemHeight: O,
76
+ domRef: S
77
77
  }
78
78
  });
79
- const S = n.slice(0, -1), D = [e, ...S].join(".");
80
- te(D, {
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: i.current
83
+ ref: c.current
84
84
  });
85
85
  }
86
- }, [m, v, e, n]);
87
- const V = R(e, n);
88
- if (V === void 0)
86
+ }, [T, g, t, n]);
87
+ const m = x(t, n);
88
+ if (m === void 0)
89
89
  return null;
90
- const d = s({
91
- currentState: V,
90
+ const o = i({
91
+ currentState: m,
92
92
  path: n,
93
- componentId: t
94
- }), z = a(d, o, l);
95
- return /* @__PURE__ */ w("div", { ref: L, children: z });
93
+ componentId: e
94
+ }), M = a(o, s, l);
95
+ return /* @__PURE__ */ N("div", { ref: E, children: M });
96
96
  }
97
- function ge({
98
- stateKey: e,
99
- path: t,
97
+ function Ee({
98
+ stateKey: t,
99
+ path: e,
100
100
  rebuildStateShape: n,
101
- renderFn: o,
101
+ renderFn: s,
102
102
  formOpts: l,
103
- setState: s
103
+ setState: i
104
104
  }) {
105
- const [a] = p(() => G()), [, f] = p({}), h = [e, ...t].join(".");
106
- F(e, a, f);
107
- const m = R(e, t), [i, v] = p(m), u = j(!1), c = j(null);
108
- C(() => {
109
- !u.current && !Y(m, i) && v(m);
110
- }, [m]), C(() => {
111
- const r = b.getState().subscribeToPath(h, (g) => {
112
- !u.current && i !== g && f({});
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(), c.current && (clearTimeout(c.current), u.current = !1);
115
+ r(), o.current && (clearTimeout(o.current), m.current = !1);
116
116
  };
117
117
  }, []);
118
- const L = J(
119
- (r) => {
120
- typeof m === "number" && typeof r == "string" && (r = r === "" ? 0 : Number(r)), v(r), u.current = !0, c.current && clearTimeout(c.current);
121
- const S = l?.debounceTime ?? 200;
122
- c.current = setTimeout(() => {
123
- if (u.current = !1, s(r, t, { updateType: "update" }), !b.getState().getShadowMetadata(e, [])?.features?.validationEnabled) return;
124
- const M = Z(e)?.validation, N = M?.zodSchemaV4 || M?.zodSchemaV3;
125
- if (N) {
126
- const E = R(e, []), y = N.safeParse(E), O = H(e, t) || {};
127
- if (y.success)
128
- I(e, t, {
129
- ...O,
130
- validation: {
131
- status: "VALID",
132
- errors: [],
133
- lastValidated: Date.now(),
134
- validatedValue: r
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
- else {
138
- const W = ("issues" in y.error ? y.error.issues : y.error.errors).filter(
139
- (T) => JSON.stringify(T.path) === JSON.stringify(t)
140
- );
141
- W.length > 0 ? I(e, t, {
142
- ...O,
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
- const N = R(e, []), E = D.safeParse(N);
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: i
177
+ validatedValue: r
193
178
  }
194
- });
195
- else {
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: O.map((A) => ({
211
- source: "client",
212
- message: A.message,
213
- severity: "error"
214
- // Hard error on blur
215
- })),
183
+ errors: [
184
+ {
185
+ source: "client",
186
+ message: v.message,
187
+ severity: W
188
+ }
189
+ ],
216
190
  lastValidated: Date.now(),
217
- validatedValue: i
191
+ validatedValue: r
218
192
  }
219
- });
220
- }
221
- f({});
222
- }, [e, t, i, s]), d = n({
223
- path: t,
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
- }), z = new Proxy(d, {
227
- get(r, g) {
228
- return g === "$inputProps" ? {
229
- value: i ?? "",
230
- onChange: (S) => {
231
- L(S.target.value);
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
- // 5. Wire the new onBlur handler to the input props.
234
- onBlur: V,
235
- ref: Q.getState().getFormRef(e + "." + t.join("."))
236
- } : r[g];
225
+ onBlur: O,
226
+ ref: oe.getState().getFormRef(t + "." + e.join("."))
227
+ } : r[b];
237
228
  }
238
229
  });
239
- return /* @__PURE__ */ w(ne, { formOpts: l, path: t, stateKey: e, children: o(z) });
230
+ return /* @__PURE__ */ N(ge, { formOpts: l, path: e, stateKey: t, children: s(F) });
240
231
  }
241
- function F(e, t, n) {
242
- const o = `${e}////${t}`;
243
- B(() => (K(e, o, {
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
- ee(e, o);
249
- }), [e, o]);
239
+ ue(t, s);
240
+ }), [t, s]);
250
241
  }
251
- const se = (e) => {
252
- const [t, n] = p(!1);
253
- return B(() => {
254
- if (!e.current) {
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 o = Array.from(e.current.querySelectorAll("img"));
259
- if (o.length === 0) {
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 s = () => {
265
- l++, l === o.length && n(!0);
255
+ const i = () => {
256
+ l++, l === s.length && n(!0);
266
257
  };
267
- return o.forEach((a) => {
268
- a.complete ? s() : (a.addEventListener("load", s), a.addEventListener("error", s));
258
+ return s.forEach((a) => {
259
+ a.complete ? i() : (a.addEventListener("load", i), a.addEventListener("error", i));
269
260
  }), () => {
270
- o.forEach((a) => {
271
- a.removeEventListener("load", s), a.removeEventListener("error", s);
261
+ s.forEach((a) => {
262
+ a.removeEventListener("load", i), a.removeEventListener("error", i);
272
263
  });
273
264
  };
274
- }, [e.current]), t;
265
+ }, [t.current]), e;
275
266
  };
276
- function ve({
277
- stateKey: e,
278
- path: t,
267
+ function Me({
268
+ stateKey: t,
269
+ path: e,
279
270
  rebuildStateShape: n,
280
- renderFn: o
271
+ renderFn: s
281
272
  }) {
282
- const [l] = p(() => G()), [, s] = p({}), a = [e, ...t].join(".");
283
- F(e, l, s), C(() => {
284
- const h = b.getState().subscribeToPath(a, () => {
285
- s({});
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 () => h();
278
+ return () => I();
288
279
  }, [a]);
289
280
  const f = n({
290
- path: t,
281
+ path: e,
291
282
  componentId: l,
292
283
  meta: void 0
293
284
  });
294
- return /* @__PURE__ */ w(x, { children: o(f) });
285
+ return /* @__PURE__ */ N(X, { children: s(f) });
295
286
  }
296
287
  export {
297
- ge as FormElementWrapper,
298
- ve as IsolatedComponentWrapper,
299
- oe as ListItemWrapper,
300
- me as MemoizedCogsItemWrapper,
301
- ne as ValidationWrapper,
302
- F as useRegisterComponent
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