cogsbox-state 0.5.6 → 0.5.8
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.
- package/README.md +474 -280
- package/dist/CogsState.jsx +323 -323
- package/dist/CogsState.jsx.map +1 -1
- package/dist/CogsStateClient.jsx +6 -6
- package/dist/CogsStateClient.jsx.map +1 -1
- package/dist/Functions.jsx +106 -106
- package/dist/Functions.jsx.map +1 -1
- package/dist/node_modules/zustand/esm/react.js +1 -1
- package/dist/useValidateZodPath.js +1 -1
- package/package.json +1 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -7
- package/dist/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/_virtual/index.js +0 -5
- package/dist/_virtual/index.js.map +0 -1
- package/dist/_virtual/jsx-runtime.jsx +0 -5
- package/dist/_virtual/jsx-runtime.jsx.map +0 -1
- package/dist/_virtual/react-jsx-runtime.jsx +0 -5
- package/dist/_virtual/react-jsx-runtime.jsx.map +0 -1
- package/dist/_virtual/react-jsx-runtime.production.jsx +0 -5
- package/dist/_virtual/react-jsx-runtime.production.jsx.map +0 -1
- package/dist/_virtual/react.js +0 -5
- package/dist/_virtual/react.js.map +0 -1
- package/dist/_virtual/react.production.js +0 -5
- package/dist/_virtual/react.production.js.map +0 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.jsx +0 -605
- package/dist/node_modules/react/cjs/react-jsx-runtime.jsx.map +0 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.jsx +0 -29
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.jsx.map +0 -1
- package/dist/node_modules/react/cjs/react.js +0 -1274
- package/dist/node_modules/react/cjs/react.js.map +0 -1
- package/dist/node_modules/react/cjs/react.production.js +0 -209
- package/dist/node_modules/react/cjs/react.production.js.map +0 -1
- package/dist/node_modules/react/index.js +0 -12
- package/dist/node_modules/react/index.js.map +0 -1
- package/dist/node_modules/react/jsx-runtime.jsx +0 -9
- package/dist/node_modules/react/jsx-runtime.jsx.map +0 -1
package/dist/Functions.jsx
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as V, Fragment as G } from "react/jsx-runtime";
|
|
2
2
|
import "./CogsState.jsx";
|
|
3
|
-
import { getNestedValue as
|
|
4
|
-
import
|
|
5
|
-
import { getGlobalStore as
|
|
6
|
-
import { validateZodPathFunc as
|
|
7
|
-
function
|
|
3
|
+
import { getNestedValue as R, isFunction as M, updateNestedProperty as E } from "./utility.js";
|
|
4
|
+
import B, { useState as b, useRef as j, useEffect as F } from "react";
|
|
5
|
+
import { getGlobalStore as a, formRefStore as W } from "./store.js";
|
|
6
|
+
import { validateZodPathFunc as Y } from "./useValidateZodPath.js";
|
|
7
|
+
function Z(r, e, n, o) {
|
|
8
8
|
r(
|
|
9
9
|
(t) => {
|
|
10
|
-
if (
|
|
11
|
-
const s = e(
|
|
12
|
-
let i =
|
|
10
|
+
if (M(e)) {
|
|
11
|
+
const s = e(R(t, n));
|
|
12
|
+
let i = E(n, t, s);
|
|
13
13
|
return typeof i == "string" && (i = i.trim()), i;
|
|
14
14
|
} else {
|
|
15
|
-
let s = !n || n.length == 0 ? e :
|
|
15
|
+
let s = !n || n.length == 0 ? e : E(n, t, e);
|
|
16
16
|
return typeof s == "string" && (s = s.trim()), s;
|
|
17
17
|
}
|
|
18
18
|
},
|
|
@@ -21,16 +21,16 @@ function P(r, e, n, o) {
|
|
|
21
21
|
o
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const s =
|
|
24
|
+
function ee(r, e, n, o, t) {
|
|
25
|
+
const s = a.getState().getNestedState(o, n);
|
|
26
26
|
r(
|
|
27
27
|
(i) => {
|
|
28
|
-
let
|
|
28
|
+
let l = !n || n.length == 0 ? i : R(i, [...n]), u = [...l];
|
|
29
29
|
return u.splice(
|
|
30
|
-
Number(t) == 0 ? t :
|
|
30
|
+
Number(t) == 0 ? t : l.length,
|
|
31
31
|
0,
|
|
32
|
-
|
|
33
|
-
), n.length == 0 ? u :
|
|
32
|
+
M(e) ? e(l) : e
|
|
33
|
+
), n.length == 0 ? u : E([...n], i, u);
|
|
34
34
|
},
|
|
35
35
|
[
|
|
36
36
|
...n,
|
|
@@ -41,18 +41,18 @@ function h(r, e, n, o, t) {
|
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function te(r, e, n, o) {
|
|
45
|
+
const t = a.getState().getNestedState(n, e);
|
|
46
46
|
r(
|
|
47
47
|
(s) => {
|
|
48
|
-
const i =
|
|
48
|
+
const i = R(s, [...e]);
|
|
49
49
|
if (o < 0 || o >= i?.length)
|
|
50
50
|
throw new Error(`Index ${o} does not exist in the array.`);
|
|
51
|
-
const
|
|
52
|
-
...i.slice(0,
|
|
53
|
-
...i.slice(
|
|
51
|
+
const l = o || Number(o) == 0 ? o : i.length - 1, u = [
|
|
52
|
+
...i.slice(0, l),
|
|
53
|
+
...i.slice(l + 1)
|
|
54
54
|
];
|
|
55
|
-
return console.log(o), e.length == 0 ? u :
|
|
55
|
+
return console.log(o), e.length == 0 ? u : E([...e], s, u);
|
|
56
56
|
},
|
|
57
57
|
[
|
|
58
58
|
...e,
|
|
@@ -61,83 +61,83 @@ function p(r, e, n, o) {
|
|
|
61
61
|
{ updateType: "cut" }
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
const [o, t] =
|
|
66
|
-
() => e(
|
|
67
|
-
), s =
|
|
68
|
-
return
|
|
69
|
-
i.current = r, t(e(
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
n(s.current,
|
|
73
|
-
}, u =
|
|
64
|
+
const T = (r, e, n = (o, t) => JSON.stringify(o) === JSON.stringify(t)) => {
|
|
65
|
+
const [o, t] = b(
|
|
66
|
+
() => e(a.getState(), r)
|
|
67
|
+
), s = j(o), i = j(r);
|
|
68
|
+
return F(() => {
|
|
69
|
+
i.current = r, t(e(a.getState(), r));
|
|
70
|
+
const l = (d) => {
|
|
71
|
+
const g = e(d, i.current);
|
|
72
|
+
n(s.current, g) || (s.current = g, t(g));
|
|
73
|
+
}, u = a.subscribe(l);
|
|
74
74
|
return () => {
|
|
75
75
|
u();
|
|
76
76
|
};
|
|
77
77
|
}, [r]), o;
|
|
78
|
-
},
|
|
78
|
+
}, _ = (r, e, n) => {
|
|
79
79
|
const o = r + "." + (e.length > 0 ? [e.join(".")] : []) + (n && n.length > 0 ? "." + n : "");
|
|
80
|
-
return n?.length === 0 ? [] :
|
|
80
|
+
return n?.length === 0 ? [] : T(
|
|
81
81
|
o,
|
|
82
82
|
(t, s) => t.getValidationErrors(s) || []
|
|
83
83
|
);
|
|
84
|
-
},
|
|
84
|
+
}, q = (r, e) => {
|
|
85
85
|
const n = `${r}:${e.join(".")}`;
|
|
86
|
-
return
|
|
86
|
+
return T(
|
|
87
87
|
n,
|
|
88
88
|
(o, t) => o.getSyncInfo(t)
|
|
89
89
|
);
|
|
90
|
-
},
|
|
90
|
+
}, H = (r, e) => T(
|
|
91
91
|
`${r}:${e.join(".")}`,
|
|
92
92
|
(n, o) => n.getNestedState(r, e)
|
|
93
|
-
),
|
|
93
|
+
), ne = ({
|
|
94
94
|
setState: r,
|
|
95
95
|
path: e,
|
|
96
96
|
child: n,
|
|
97
97
|
formOpts: o,
|
|
98
98
|
stateKey: t
|
|
99
99
|
}) => {
|
|
100
|
-
const [s, i] =
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
getValidationErrors:
|
|
104
|
-
addValidationError:
|
|
105
|
-
getInitialOptions:
|
|
106
|
-
removeValidationError:
|
|
107
|
-
} =
|
|
108
|
-
|
|
109
|
-
),
|
|
110
|
-
if (!
|
|
100
|
+
const [s, i] = b({}), { registerFormRef: l, getFormRef: u } = W.getState(), d = t + "." + e.join("."), g = j(null), S = u(d);
|
|
101
|
+
S || l(t + "." + e.join("."), g);
|
|
102
|
+
const z = S || g, {
|
|
103
|
+
getValidationErrors: I,
|
|
104
|
+
addValidationError: U,
|
|
105
|
+
getInitialOptions: A,
|
|
106
|
+
removeValidationError: w
|
|
107
|
+
} = a.getState(), y = H(t, e), [k, C] = b(
|
|
108
|
+
a.getState().getNestedState(t, e)
|
|
109
|
+
), m = A(t);
|
|
110
|
+
if (!m?.validation?.key)
|
|
111
111
|
throw new Error(
|
|
112
112
|
"Validation key not found. You need to set it in the options for the createCogsState function"
|
|
113
113
|
);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, [t, e.join("."),
|
|
118
|
-
const
|
|
119
|
-
let
|
|
120
|
-
|
|
114
|
+
const f = m.validation.key;
|
|
115
|
+
m.validation.onBlur, F(() => {
|
|
116
|
+
C(y);
|
|
117
|
+
}, [t, e.join("."), y]);
|
|
118
|
+
const v = j();
|
|
119
|
+
let $ = (c, O) => {
|
|
120
|
+
C(c), v.current && clearTimeout(v.current), v.current = setTimeout(
|
|
121
121
|
() => {
|
|
122
|
-
console.log(typeof
|
|
122
|
+
console.log(typeof y), Z(r, c, e, f);
|
|
123
123
|
},
|
|
124
|
-
o?.debounceTime ?? (typeof
|
|
124
|
+
o?.debounceTime ?? (typeof y == "boolean" ? 20 : 200)
|
|
125
125
|
);
|
|
126
126
|
};
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
|
|
127
|
+
const J = async () => {
|
|
128
|
+
if (m.validation?.zodSchema) {
|
|
129
|
+
w(f + "." + e.join("."));
|
|
130
130
|
try {
|
|
131
|
-
const c =
|
|
132
|
-
await
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
const c = a.getState().getNestedState(t, e);
|
|
132
|
+
await Y(
|
|
133
|
+
f,
|
|
134
|
+
m.validation.zodSchema,
|
|
135
135
|
e,
|
|
136
136
|
c
|
|
137
137
|
), console.log(
|
|
138
138
|
"Validation",
|
|
139
139
|
t,
|
|
140
|
-
|
|
140
|
+
m.validation.zodSchema,
|
|
141
141
|
e,
|
|
142
142
|
c
|
|
143
143
|
), i({});
|
|
@@ -146,40 +146,40 @@ const N = (r, e, n = (o, t) => JSON.stringify(o) === JSON.stringify(t)) => {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
F(() => () => {
|
|
150
|
+
v.current && clearTimeout(v.current);
|
|
151
151
|
}, []);
|
|
152
|
-
const
|
|
153
|
-
...
|
|
154
|
-
date: new Date(
|
|
155
|
-
} : null,
|
|
156
|
-
get: () =>
|
|
157
|
-
set:
|
|
158
|
-
syncStatus:
|
|
152
|
+
const N = q(t, e), P = N ? {
|
|
153
|
+
...N,
|
|
154
|
+
date: new Date(N.timeStamp)
|
|
155
|
+
} : null, D = n({
|
|
156
|
+
get: () => k || a.getState().getNestedState(t, e),
|
|
157
|
+
set: $,
|
|
158
|
+
syncStatus: P,
|
|
159
159
|
path: e,
|
|
160
|
-
validationErrors: () =>
|
|
160
|
+
validationErrors: () => I(f + "." + e.join(".")),
|
|
161
161
|
addValidationError: (c) => {
|
|
162
|
-
|
|
162
|
+
w(f + "." + e.join(".")), U(f + "." + e.join("."), c ?? "");
|
|
163
163
|
},
|
|
164
164
|
inputProps: {
|
|
165
|
-
value:
|
|
166
|
-
onChange: (c) =>
|
|
167
|
-
onBlur:
|
|
168
|
-
ref:
|
|
165
|
+
value: k || a.getState().getNestedState(t, e) || "",
|
|
166
|
+
onChange: (c) => $(c.target.value),
|
|
167
|
+
onBlur: J,
|
|
168
|
+
ref: z
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
|
-
return /* @__PURE__ */
|
|
172
|
-
|
|
171
|
+
return /* @__PURE__ */ V(G, { children: /* @__PURE__ */ V(
|
|
172
|
+
L,
|
|
173
173
|
{
|
|
174
174
|
formOpts: o,
|
|
175
175
|
path: e,
|
|
176
|
-
validationKey:
|
|
176
|
+
validationKey: f,
|
|
177
177
|
stateKey: t,
|
|
178
|
-
children:
|
|
178
|
+
children: D
|
|
179
179
|
}
|
|
180
180
|
) });
|
|
181
181
|
};
|
|
182
|
-
function
|
|
182
|
+
function L({
|
|
183
183
|
formOpts: r,
|
|
184
184
|
path: e,
|
|
185
185
|
validationKey: n,
|
|
@@ -187,34 +187,34 @@ function Z({
|
|
|
187
187
|
children: t,
|
|
188
188
|
validIndices: s
|
|
189
189
|
}) {
|
|
190
|
-
const { getInitialOptions: i } =
|
|
190
|
+
const { getInitialOptions: i } = a.getState(), l = _(
|
|
191
191
|
n,
|
|
192
192
|
e,
|
|
193
193
|
s
|
|
194
194
|
), u = [];
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
u.includes(
|
|
195
|
+
if (l) {
|
|
196
|
+
const S = l.join(", ");
|
|
197
|
+
u.includes(S) || u.push(S);
|
|
198
198
|
}
|
|
199
199
|
const d = i(o);
|
|
200
|
-
let
|
|
201
|
-
return /* @__PURE__ */
|
|
202
|
-
children: /* @__PURE__ */
|
|
203
|
-
active:
|
|
204
|
-
message: r?.validation?.hideMessage ? "" :
|
|
200
|
+
let g = d?.validation?.onBlur ? u?.length > 0 ? u?.join(", ") : r?.validation?.message ? r?.validation?.message : "" : "";
|
|
201
|
+
return /* @__PURE__ */ V(G, { children: d?.formElements?.validation && !r?.validation?.disable ? d.formElements.validation({
|
|
202
|
+
children: /* @__PURE__ */ V(B.Fragment, { children: t }, e.toString()),
|
|
203
|
+
active: g != "",
|
|
204
|
+
message: r?.validation?.hideMessage ? "" : g,
|
|
205
205
|
path: e,
|
|
206
206
|
...r?.key && { key: r?.key }
|
|
207
|
-
}) : /* @__PURE__ */
|
|
207
|
+
}) : /* @__PURE__ */ V(B.Fragment, { children: t }, e.toString()) });
|
|
208
208
|
}
|
|
209
209
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
210
|
+
ne as FormControlComponent,
|
|
211
|
+
L as ValidationWrapper,
|
|
212
|
+
te as cutFunc,
|
|
213
|
+
ee as pushFunc,
|
|
214
|
+
Z as updateFn,
|
|
215
|
+
H as useGetKeyState,
|
|
216
|
+
q as useGetSyncInfo,
|
|
217
|
+
_ as useGetValidationErrors,
|
|
218
|
+
T as useStoreSubscription
|
|
219
219
|
};
|
|
220
220
|
//# sourceMappingURL=Functions.jsx.map
|
package/dist/Functions.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Functions.jsx","sources":["../src/Functions.tsx"],"sourcesContent":["import {\r\n notifyComponent,\r\n type EffectiveSetState,\r\n type FormElementParams,\r\n type FormOptsType,\r\n type UpdateArg,\r\n type UpdateOpts,\r\n} from \"./CogsState\";\r\n\r\nimport { getNestedValue, isFunction, updateNestedProperty } from \"./utility\";\r\nimport { useEffect, useRef, useState } from \"react\";\r\nimport React from \"react\";\r\nimport { getGlobalStore, formRefStore } from \"./store\";\r\nimport { validateZodPathFunc } from \"./useValidateZodPath\";\r\n\r\nexport function updateFn<U>(\r\n setState: EffectiveSetState<U>,\r\n payload: UpdateArg<U>,\r\n path: string[],\r\n validationKey?: string\r\n): void {\r\n setState(\r\n (prevState) => {\r\n if (isFunction<U>(payload)) {\r\n const nestedValue = payload(getNestedValue(prevState, path));\r\n let value = updateNestedProperty(path, prevState, nestedValue);\r\n if (typeof value == \"string\") {\r\n value = value.trim();\r\n }\r\n return value;\r\n } else {\r\n let value =\r\n !path || path.length == 0\r\n ? payload\r\n : updateNestedProperty(path, prevState, payload);\r\n if (typeof value == \"string\") {\r\n value = value.trim();\r\n }\r\n return value;\r\n }\r\n },\r\n path,\r\n { updateType: \"update\" },\r\n validationKey\r\n );\r\n}\r\n\r\nexport function pushFunc<U>(\r\n setState: EffectiveSetState<U>,\r\n payload: UpdateArg<U>,\r\n path: string[],\r\n stateKey: string,\r\n index?: number\r\n): void {\r\n const array = getGlobalStore.getState().getNestedState(stateKey, path) as U[];\r\n setState(\r\n (prevState) => {\r\n let arrayToUpdate =\r\n !path || path.length == 0\r\n ? prevState\r\n : getNestedValue(prevState, [...path]);\r\n let returnedArray = [...arrayToUpdate];\r\n\r\n returnedArray.splice(\r\n index || Number(index) == 0 ? index : arrayToUpdate.length,\r\n 0,\r\n isFunction<U>(payload)\r\n ? payload(index == -1 ? undefined : arrayToUpdate)\r\n : payload\r\n );\r\n const value =\r\n path.length == 0\r\n ? returnedArray\r\n : updateNestedProperty([...path], prevState, returnedArray);\r\n\r\n return value as U;\r\n },\r\n [\r\n ...path,\r\n index || index === 0 ? index?.toString() : (array!.length - 1).toString(),\r\n ],\r\n {\r\n updateType: \"insert\",\r\n }\r\n );\r\n}\r\n\r\nexport function cutFunc<U>(\r\n setState: EffectiveSetState<U>,\r\n path: string[],\r\n stateKey: string,\r\n index: number\r\n): void {\r\n const array = getGlobalStore.getState().getNestedState(stateKey, path) as U[];\r\n setState(\r\n (prevState) => {\r\n const arrayToUpdate = getNestedValue(prevState, [...path]);\r\n if (index < 0 || index >= arrayToUpdate?.length) {\r\n throw new Error(`Index ${index} does not exist in the array.`);\r\n }\r\n const indexToCut =\r\n index || Number(index) == 0 ? index : arrayToUpdate.length - 1;\r\n\r\n const updatedArray = [\r\n ...arrayToUpdate.slice(0, indexToCut),\r\n ...arrayToUpdate.slice(indexToCut + 1),\r\n ] as U;\r\n\r\n console.log(index);\r\n return path.length == 0\r\n ? updatedArray\r\n : updateNestedProperty([...path], prevState, updatedArray);\r\n },\r\n [\r\n ...path,\r\n index || index === 0 ? index?.toString() : (array!.length - 1).toString(),\r\n ],\r\n { updateType: \"cut\" }\r\n );\r\n}\r\n\r\nexport const useStoreSubscription = <T,>(\r\n fullPath: string,\r\n selector: (\r\n store: ReturnType<typeof getGlobalStore.getState>,\r\n path: string\r\n ) => T,\r\n compare: (a: T, b: T) => boolean = (a, b) =>\r\n JSON.stringify(a) === JSON.stringify(b)\r\n) => {\r\n const [value, setValue] = useState<T>(() =>\r\n selector(getGlobalStore.getState(), fullPath)\r\n );\r\n const previousValueRef = useRef<T>(value);\r\n const fullPathRef = useRef(fullPath);\r\n useEffect(() => {\r\n fullPathRef.current = fullPath; // Ensure latest fullPath is always used\r\n\r\n setValue(selector(getGlobalStore.getState(), fullPath));\r\n\r\n const callback = (store: any) => {\r\n const newValue = selector(store, fullPathRef.current);\r\n\r\n if (!compare(previousValueRef.current, newValue)) {\r\n previousValueRef.current = newValue;\r\n setValue(newValue);\r\n }\r\n };\r\n const unsubscribe = getGlobalStore.subscribe(callback);\r\n return () => {\r\n unsubscribe();\r\n };\r\n }, [fullPath]);\r\n return value;\r\n};\r\nexport const useGetValidationErrors = (\r\n validationKey: string,\r\n path: string[],\r\n validIndices?: number[]\r\n) => {\r\n // Construct the full path the same way as ValidationWrapper\r\n const fullPath =\r\n validationKey +\r\n \".\" +\r\n (path.length > 0 ? [path.join(\".\")] : []) +\r\n (validIndices && validIndices.length > 0 ? \".\" + validIndices : \"\");\r\n\r\n // Skip subscription if we have empty indices\r\n if (validIndices?.length === 0) {\r\n return [];\r\n }\r\n\r\n return useStoreSubscription(\r\n fullPath,\r\n (store, path) => store.getValidationErrors(path) || []\r\n );\r\n};\r\n\r\nexport const useGetSyncInfo = (key: string, path: string[]) => {\r\n const syncKey = `${key}:${path.join(\".\")}`;\r\n return useStoreSubscription(syncKey, (store, path) =>\r\n store.getSyncInfo(path)\r\n );\r\n};\r\nexport const useGetKeyState = (key: string, path: string[]) => {\r\n return useStoreSubscription(`${key}:${path.join(\".\")}`, (store, fullPath) =>\r\n store.getNestedState(key, path)\r\n );\r\n};\r\ninterface FormControlComponentProps<TStateObject> {\r\n setState: EffectiveSetState<TStateObject>;\r\n\r\n path: string[];\r\n child: (obj: FormElementParams<TStateObject>) => JSX.Element;\r\n formOpts?: FormOptsType;\r\n stateKey: string;\r\n}\r\n\r\nexport const FormControlComponent = <TStateObject,>({\r\n setState,\r\n path,\r\n child,\r\n formOpts,\r\n stateKey,\r\n}: FormControlComponentProps<TStateObject>) => {\r\n const [_, forceUpdate] = useState({});\r\n const { registerFormRef, getFormRef } = formRefStore.getState();\r\n const refKey = stateKey + \".\" + path.join(\".\");\r\n\r\n // Create a local ref\r\n const localFormRef = useRef<HTMLInputElement>(null);\r\n\r\n // Get existing ref from the store (if any)\r\n const existingRef = getFormRef(refKey);\r\n if (!existingRef) {\r\n registerFormRef(stateKey + \".\" + path.join(\".\"), localFormRef);\r\n }\r\n // Use the existing ref if available, otherwise use the local one\r\n const formRef = existingRef || localFormRef;\r\n\r\n const {\r\n getValidationErrors,\r\n addValidationError,\r\n getInitialOptions,\r\n removeValidationError,\r\n } = getGlobalStore.getState();\r\n const stateValue = useGetKeyState(stateKey, path);\r\n const [inputValue, setInputValue] = useState<any>(\r\n getGlobalStore.getState().getNestedState(stateKey, path)\r\n );\r\n\r\n const initialOptions = getInitialOptions(stateKey);\r\n if (!initialOptions?.validation?.key) {\r\n throw new Error(\r\n \"Validation key not found. You need to set it in the options for the createCogsState function\"\r\n );\r\n }\r\n const validationKey = initialOptions.validation.key;\r\n const validateOnBlur = initialOptions.validation.onBlur === true;\r\n initialOptions;\r\n useEffect(() => {\r\n setInputValue(stateValue);\r\n }, [stateKey, path.join(\".\"), stateValue]);\r\n\r\n const timeoutRef = useRef<NodeJS.Timeout>();\r\n\r\n // Standard updater function (unchanged)\r\n let updater = (\r\n payload: UpdateArg<TStateObject>,\r\n opts?: UpdateOpts<TStateObject>\r\n ) => {\r\n setInputValue(payload);\r\n\r\n if (timeoutRef.current) {\r\n clearTimeout(timeoutRef.current);\r\n }\r\n\r\n timeoutRef.current = setTimeout(\r\n () => {\r\n console.log(typeof stateValue);\r\n updateFn(setState, payload, path, validationKey);\r\n },\r\n formOpts?.debounceTime ?? (typeof stateValue == \"boolean\" ? 20 : 200)\r\n );\r\n };\r\n\r\n // Handle blur event\r\n const handleBlur = async () => {\r\n if (!initialOptions.validation?.zodSchema) return;\r\n removeValidationError(validationKey + \".\" + path.join(\".\"));\r\n try {\r\n // Get the current field value\r\n const fieldValue = getGlobalStore\r\n .getState()\r\n .getNestedState(stateKey, path);\r\n\r\n // Use your existing validateZodPathFunc\r\n await validateZodPathFunc(\r\n validationKey,\r\n initialOptions.validation.zodSchema,\r\n path,\r\n fieldValue\r\n );\r\n console.log(\r\n \"Validation\",\r\n stateKey,\r\n initialOptions.validation.zodSchema,\r\n path,\r\n fieldValue\r\n );\r\n forceUpdate({});\r\n } catch (error) {\r\n console.error(\"Validation error:\", error);\r\n }\r\n };\r\n\r\n // Clear timeout on unmount\r\n useEffect(() => {\r\n return () => {\r\n if (timeoutRef.current) {\r\n clearTimeout(timeoutRef.current);\r\n }\r\n };\r\n }, []);\r\n\r\n const rawSyncStatus = useGetSyncInfo(stateKey, path);\r\n const syncStatus = rawSyncStatus\r\n ? {\r\n ...rawSyncStatus,\r\n date: new Date(rawSyncStatus.timeStamp),\r\n }\r\n : null;\r\n\r\n const childElement = child({\r\n get: () =>\r\n inputValue || getGlobalStore.getState().getNestedState(stateKey, path),\r\n set: updater,\r\n syncStatus,\r\n path: path,\r\n validationErrors: () =>\r\n getValidationErrors(validationKey + \".\" + path.join(\".\")),\r\n addValidationError: (message?: string) => {\r\n removeValidationError(validationKey + \".\" + path.join(\".\"));\r\n addValidationError(validationKey + \".\" + path.join(\".\"), message ?? \"\");\r\n },\r\n\r\n inputProps: {\r\n value:\r\n inputValue ||\r\n getGlobalStore.getState().getNestedState(stateKey, path) ||\r\n \"\",\r\n onChange: (e: any) => updater(e.target.value),\r\n onBlur: handleBlur,\r\n ref: formRef,\r\n },\r\n });\r\n\r\n return (\r\n <>\r\n <ValidationWrapper\r\n {...{\r\n formOpts,\r\n path,\r\n validationKey,\r\n stateKey,\r\n }}\r\n >\r\n {childElement}\r\n </ValidationWrapper>\r\n </>\r\n );\r\n};\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n validationKey,\r\n stateKey,\r\n children,\r\n validIndices,\r\n}: {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n validationKey: string;\r\n stateKey?: string;\r\n children: React.ReactNode;\r\n validIndices?: number[];\r\n}) {\r\n const { getInitialOptions } = getGlobalStore.getState();\r\n\r\n const validationErrors = useGetValidationErrors(\r\n validationKey,\r\n path,\r\n validIndices\r\n );\r\n\r\n const thesMessages: string[] = [];\r\n\r\n if (validationErrors) {\r\n const newMessage = validationErrors!.join(\", \");\r\n if (!thesMessages.includes(newMessage)) {\r\n thesMessages.push(newMessage);\r\n }\r\n }\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n let fullMessageString = thisStateOpts?.validation?.onBlur\r\n ? thesMessages?.length > 0\r\n ? thesMessages?.join(\", \")\r\n : formOpts?.validation?.message\r\n ? formOpts?.validation?.message\r\n : \"\"\r\n : \"\";\r\n\r\n return (\r\n <>\r\n {thisStateOpts?.formElements?.validation &&\r\n !formOpts?.validation?.disable ? (\r\n thisStateOpts.formElements!.validation!({\r\n children: (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n ),\r\n active: fullMessageString != \"\" ? true : false,\r\n message: formOpts?.validation?.hideMessage ? \"\" : fullMessageString,\r\n path,\r\n\r\n ...(formOpts?.key && { key: formOpts?.key }),\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\n"],"names":["updateFn","setState","payload","path","validationKey","prevState","isFunction","nestedValue","getNestedValue","value","updateNestedProperty","pushFunc","stateKey","index","array","getGlobalStore","arrayToUpdate","returnedArray","cutFunc","indexToCut","updatedArray","useStoreSubscription","fullPath","selector","compare","a","b","setValue","useState","previousValueRef","useRef","fullPathRef","useEffect","callback","store","newValue","unsubscribe","useGetValidationErrors","validIndices","useGetSyncInfo","key","syncKey","useGetKeyState","FormControlComponent","child","formOpts","_","forceUpdate","registerFormRef","getFormRef","formRefStore","refKey","localFormRef","existingRef","formRef","getValidationErrors","addValidationError","getInitialOptions","removeValidationError","stateValue","inputValue","setInputValue","initialOptions","timeoutRef","updater","opts","handleBlur","fieldValue","validateZodPathFunc","error","rawSyncStatus","syncStatus","childElement","message","e","jsx","Fragment","ValidationWrapper","children","validationErrors","thesMessages","newMessage","thisStateOpts","fullMessageString","React"],"mappings":";;;;;;AAeO,SAASA,EACdC,GACAC,GACAC,GACAC,GACM;AACN,EAAAH;AAAA,IACE,CAACI,MAAc;AACT,UAAAC,EAAcJ,CAAO,GAAG;AAC1B,cAAMK,IAAcL,EAAQM,EAAeH,GAAWF,CAAI,CAAC;AAC3D,YAAIM,IAAQC,EAAqBP,GAAME,GAAWE,CAAW;AACzD,eAAA,OAAOE,KAAS,aAClBA,IAAQA,EAAM,KAAK,IAEdA;AAAA,MAAA,OACF;AACD,YAAAA,IACF,CAACN,KAAQA,EAAK,UAAU,IACpBD,IACAQ,EAAqBP,GAAME,GAAWH,CAAO;AAC/C,eAAA,OAAOO,KAAS,aAClBA,IAAQA,EAAM,KAAK,IAEdA;AAAA,MAAA;AAAA,IAEX;AAAA,IACAN;AAAA,IACA,EAAE,YAAY,SAAS;AAAA,IACvBC;AAAA,EACF;AACF;AAEO,SAASO,EACdV,GACAC,GACAC,GACAS,GACAC,GACM;AACN,QAAMC,IAAQC,EAAe,SAAW,EAAA,eAAeH,GAAUT,CAAI;AACrE,EAAAF;AAAA,IACE,CAACI,MAAc;AACb,UAAIW,IACF,CAACb,KAAQA,EAAK,UAAU,IACpBE,IACAG,EAAeH,GAAW,CAAC,GAAGF,CAAI,CAAC,GACrCc,IAAgB,CAAC,GAAGD,CAAa;AAEvB,aAAAC,EAAA;AAAA,QACH,OAAOJ,CAAK,KAAK,IAAIA,IAAQG,EAAc;AAAA,QACpD;AAAA,QACAV,EAAcJ,CAAO,IACjBA,EAAkCc,CAAa,IAC/Cd;AAAA,MACN,GAEEC,EAAK,UAAU,IACXc,IACAP,EAAqB,CAAC,GAAGP,CAAI,GAAGE,GAAWY,CAAa;AAAA,IAGhE;AAAA,IACA;AAAA,MACE,GAAGd;AAAA,OACyCW,EAAO,SAAS,GAAG,SAAS;AAAA,IAC1E;AA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,UAAN,EAAsC,UAAAN,EAAlB,GAAA3E,EAAK,SAAsB,CAAA,GAEpD;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Functions.jsx","sources":["../src/Functions.tsx"],"sourcesContent":["import {\r\n notifyComponent,\r\n type EffectiveSetState,\r\n type FormElementParams,\r\n type FormOptsType,\r\n type UpdateArg,\r\n type UpdateOpts,\r\n} from \"./CogsState\";\r\n\r\nimport { getNestedValue, isFunction, updateNestedProperty } from \"./utility\";\r\nimport { useEffect, useRef, useState } from \"react\";\r\nimport React from \"react\";\r\nimport { getGlobalStore, formRefStore } from \"./store\";\r\nimport { validateZodPathFunc } from \"./useValidateZodPath\";\r\n\r\nexport function updateFn<U>(\r\n setState: EffectiveSetState<U>,\r\n payload: UpdateArg<U>,\r\n path: string[],\r\n validationKey?: string\r\n): void {\r\n setState(\r\n (prevState) => {\r\n if (isFunction<U>(payload)) {\r\n const nestedValue = payload(getNestedValue(prevState, path));\r\n let value = updateNestedProperty(path, prevState, nestedValue);\r\n if (typeof value == \"string\") {\r\n value = value.trim();\r\n }\r\n return value;\r\n } else {\r\n let value =\r\n !path || path.length == 0\r\n ? payload\r\n : updateNestedProperty(path, prevState, payload);\r\n if (typeof value == \"string\") {\r\n value = value.trim();\r\n }\r\n return value;\r\n }\r\n },\r\n path,\r\n { updateType: \"update\" },\r\n validationKey\r\n );\r\n}\r\n\r\nexport function pushFunc<U>(\r\n setState: EffectiveSetState<U>,\r\n payload: UpdateArg<U>,\r\n path: string[],\r\n stateKey: string,\r\n index?: number\r\n): void {\r\n const array = getGlobalStore.getState().getNestedState(stateKey, path) as U[];\r\n setState(\r\n (prevState) => {\r\n let arrayToUpdate =\r\n !path || path.length == 0\r\n ? prevState\r\n : getNestedValue(prevState, [...path]);\r\n let returnedArray = [...arrayToUpdate];\r\n\r\n returnedArray.splice(\r\n index || Number(index) == 0 ? index : arrayToUpdate.length,\r\n 0,\r\n isFunction<U>(payload)\r\n ? payload(index == -1 ? undefined : arrayToUpdate)\r\n : payload\r\n );\r\n const value =\r\n path.length == 0\r\n ? returnedArray\r\n : updateNestedProperty([...path], prevState, returnedArray);\r\n\r\n return value as U;\r\n },\r\n [\r\n ...path,\r\n index || index === 0 ? index?.toString() : (array!.length - 1).toString(),\r\n ],\r\n {\r\n updateType: \"insert\",\r\n }\r\n );\r\n}\r\n\r\nexport function cutFunc<U>(\r\n setState: EffectiveSetState<U>,\r\n path: string[],\r\n stateKey: string,\r\n index: number\r\n): void {\r\n const array = getGlobalStore.getState().getNestedState(stateKey, path) as U[];\r\n setState(\r\n (prevState) => {\r\n const arrayToUpdate = getNestedValue(prevState, [...path]);\r\n if (index < 0 || index >= arrayToUpdate?.length) {\r\n throw new Error(`Index ${index} does not exist in the array.`);\r\n }\r\n const indexToCut =\r\n index || Number(index) == 0 ? index : arrayToUpdate.length - 1;\r\n\r\n const updatedArray = [\r\n ...arrayToUpdate.slice(0, indexToCut),\r\n ...arrayToUpdate.slice(indexToCut + 1),\r\n ] as U;\r\n\r\n console.log(index);\r\n return path.length == 0\r\n ? updatedArray\r\n : updateNestedProperty([...path], prevState, updatedArray);\r\n },\r\n [\r\n ...path,\r\n index || index === 0 ? index?.toString() : (array!.length - 1).toString(),\r\n ],\r\n { updateType: \"cut\" }\r\n );\r\n}\r\n\r\nexport const useStoreSubscription = <T,>(\r\n fullPath: string,\r\n selector: (\r\n store: ReturnType<typeof getGlobalStore.getState>,\r\n path: string\r\n ) => T,\r\n compare: (a: T, b: T) => boolean = (a, b) =>\r\n JSON.stringify(a) === JSON.stringify(b)\r\n) => {\r\n const [value, setValue] = useState<T>(() =>\r\n selector(getGlobalStore.getState(), fullPath)\r\n );\r\n const previousValueRef = useRef<T>(value);\r\n const fullPathRef = useRef(fullPath);\r\n useEffect(() => {\r\n fullPathRef.current = fullPath; // Ensure latest fullPath is always used\r\n\r\n setValue(selector(getGlobalStore.getState(), fullPath));\r\n\r\n const callback = (store: any) => {\r\n const newValue = selector(store, fullPathRef.current);\r\n\r\n if (!compare(previousValueRef.current, newValue)) {\r\n previousValueRef.current = newValue;\r\n setValue(newValue);\r\n }\r\n };\r\n const unsubscribe = getGlobalStore.subscribe(callback);\r\n return () => {\r\n unsubscribe();\r\n };\r\n }, [fullPath]);\r\n return value;\r\n};\r\nexport const useGetValidationErrors = (\r\n validationKey: string,\r\n path: string[],\r\n validIndices?: number[]\r\n) => {\r\n // Construct the full path the same way as ValidationWrapper\r\n const fullPath =\r\n validationKey +\r\n \".\" +\r\n (path.length > 0 ? [path.join(\".\")] : []) +\r\n (validIndices && validIndices.length > 0 ? \".\" + validIndices : \"\");\r\n\r\n // Skip subscription if we have empty indices\r\n if (validIndices?.length === 0) {\r\n return [];\r\n }\r\n\r\n return useStoreSubscription(\r\n fullPath,\r\n (store, path) => store.getValidationErrors(path) || []\r\n );\r\n};\r\n\r\nexport const useGetSyncInfo = (key: string, path: string[]) => {\r\n const syncKey = `${key}:${path.join(\".\")}`;\r\n return useStoreSubscription(syncKey, (store, path) =>\r\n store.getSyncInfo(path)\r\n );\r\n};\r\nexport const useGetKeyState = (key: string, path: string[]) => {\r\n return useStoreSubscription(`${key}:${path.join(\".\")}`, (store, fullPath) =>\r\n store.getNestedState(key, path)\r\n );\r\n};\r\ninterface FormControlComponentProps<TStateObject> {\r\n setState: EffectiveSetState<TStateObject>;\r\n\r\n path: string[];\r\n child: (obj: FormElementParams<TStateObject>) => JSX.Element;\r\n formOpts?: FormOptsType;\r\n stateKey: string;\r\n}\r\n\r\nexport const FormControlComponent = <TStateObject,>({\r\n setState,\r\n path,\r\n child,\r\n formOpts,\r\n stateKey,\r\n}: FormControlComponentProps<TStateObject>) => {\r\n const [_, forceUpdate] = useState({});\r\n const { registerFormRef, getFormRef } = formRefStore.getState();\r\n const refKey = stateKey + \".\" + path.join(\".\");\r\n\r\n // Create a local ref\r\n const localFormRef = useRef<HTMLInputElement>(null);\r\n\r\n // Get existing ref from the store (if any)\r\n const existingRef = getFormRef(refKey);\r\n if (!existingRef) {\r\n registerFormRef(stateKey + \".\" + path.join(\".\"), localFormRef);\r\n }\r\n // Use the existing ref if available, otherwise use the local one\r\n const formRef = existingRef || localFormRef;\r\n\r\n const {\r\n getValidationErrors,\r\n addValidationError,\r\n getInitialOptions,\r\n removeValidationError,\r\n } = getGlobalStore.getState();\r\n const stateValue = useGetKeyState(stateKey, path);\r\n const [inputValue, setInputValue] = useState<any>(\r\n getGlobalStore.getState().getNestedState(stateKey, path)\r\n );\r\n\r\n const initialOptions = getInitialOptions(stateKey);\r\n if (!initialOptions?.validation?.key) {\r\n throw new Error(\r\n \"Validation key not found. You need to set it in the options for the createCogsState function\"\r\n );\r\n }\r\n const validationKey = initialOptions.validation.key;\r\n const validateOnBlur = initialOptions.validation.onBlur === true;\r\n initialOptions;\r\n useEffect(() => {\r\n setInputValue(stateValue);\r\n }, [stateKey, path.join(\".\"), stateValue]);\r\n\r\n const timeoutRef = useRef<NodeJS.Timeout>();\r\n\r\n // Standard updater function (unchanged)\r\n let updater = (\r\n payload: UpdateArg<TStateObject>,\r\n opts?: UpdateOpts<TStateObject>\r\n ) => {\r\n setInputValue(payload);\r\n\r\n if (timeoutRef.current) {\r\n clearTimeout(timeoutRef.current);\r\n }\r\n\r\n timeoutRef.current = setTimeout(\r\n () => {\r\n console.log(typeof stateValue);\r\n updateFn(setState, payload, path, validationKey);\r\n },\r\n formOpts?.debounceTime ?? (typeof stateValue == \"boolean\" ? 20 : 200)\r\n );\r\n };\r\n\r\n // Handle blur event\r\n const handleBlur = async () => {\r\n if (!initialOptions.validation?.zodSchema) return;\r\n removeValidationError(validationKey + \".\" + path.join(\".\"));\r\n try {\r\n // Get the current field value\r\n const fieldValue = getGlobalStore\r\n .getState()\r\n .getNestedState(stateKey, path);\r\n\r\n // Use your existing validateZodPathFunc\r\n await validateZodPathFunc(\r\n validationKey,\r\n initialOptions.validation.zodSchema,\r\n path,\r\n fieldValue\r\n );\r\n console.log(\r\n \"Validation\",\r\n stateKey,\r\n initialOptions.validation.zodSchema,\r\n path,\r\n fieldValue\r\n );\r\n forceUpdate({});\r\n } catch (error) {\r\n console.error(\"Validation error:\", error);\r\n }\r\n };\r\n\r\n // Clear timeout on unmount\r\n useEffect(() => {\r\n return () => {\r\n if (timeoutRef.current) {\r\n clearTimeout(timeoutRef.current);\r\n }\r\n };\r\n }, []);\r\n\r\n const rawSyncStatus = useGetSyncInfo(stateKey, path);\r\n const syncStatus = rawSyncStatus\r\n ? {\r\n ...rawSyncStatus,\r\n date: new Date(rawSyncStatus.timeStamp),\r\n }\r\n : null;\r\n\r\n const childElement = child({\r\n get: () =>\r\n inputValue || getGlobalStore.getState().getNestedState(stateKey, path),\r\n set: updater,\r\n syncStatus,\r\n path: path,\r\n validationErrors: () =>\r\n getValidationErrors(validationKey + \".\" + path.join(\".\")),\r\n addValidationError: (message?: string) => {\r\n removeValidationError(validationKey + \".\" + path.join(\".\"));\r\n addValidationError(validationKey + \".\" + path.join(\".\"), message ?? \"\");\r\n },\r\n\r\n inputProps: {\r\n value:\r\n inputValue ||\r\n getGlobalStore.getState().getNestedState(stateKey, path) ||\r\n \"\",\r\n onChange: (e: any) => updater(e.target.value),\r\n onBlur: handleBlur,\r\n ref: formRef,\r\n },\r\n });\r\n\r\n return (\r\n <>\r\n <ValidationWrapper\r\n {...{\r\n formOpts,\r\n path,\r\n validationKey,\r\n stateKey,\r\n }}\r\n >\r\n {childElement}\r\n </ValidationWrapper>\r\n </>\r\n );\r\n};\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n validationKey,\r\n stateKey,\r\n children,\r\n validIndices,\r\n}: {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n validationKey: string;\r\n stateKey?: string;\r\n children: React.ReactNode;\r\n validIndices?: number[];\r\n}) {\r\n const { getInitialOptions } = getGlobalStore.getState();\r\n\r\n const validationErrors = useGetValidationErrors(\r\n validationKey,\r\n path,\r\n validIndices\r\n );\r\n\r\n const thesMessages: string[] = [];\r\n\r\n if (validationErrors) {\r\n const newMessage = validationErrors!.join(\", \");\r\n if (!thesMessages.includes(newMessage)) {\r\n thesMessages.push(newMessage);\r\n }\r\n }\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n let fullMessageString = thisStateOpts?.validation?.onBlur\r\n ? thesMessages?.length > 0\r\n ? thesMessages?.join(\", \")\r\n : formOpts?.validation?.message\r\n ? formOpts?.validation?.message\r\n : \"\"\r\n : \"\";\r\n\r\n return (\r\n <>\r\n {thisStateOpts?.formElements?.validation &&\r\n !formOpts?.validation?.disable ? (\r\n thisStateOpts.formElements!.validation!({\r\n children: (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n ),\r\n active: fullMessageString != \"\" ? true : false,\r\n message: formOpts?.validation?.hideMessage ? \"\" : fullMessageString,\r\n path,\r\n\r\n ...(formOpts?.key && { key: formOpts?.key }),\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\n"],"names":["updateFn","setState","payload","path","validationKey","prevState","isFunction","nestedValue","getNestedValue","value","updateNestedProperty","pushFunc","stateKey","index","array","getGlobalStore","arrayToUpdate","returnedArray","cutFunc","indexToCut","updatedArray","useStoreSubscription","fullPath","selector","compare","a","b","setValue","useState","previousValueRef","useRef","fullPathRef","useEffect","callback","store","newValue","unsubscribe","useGetValidationErrors","validIndices","useGetSyncInfo","key","syncKey","useGetKeyState","FormControlComponent","child","formOpts","_","forceUpdate","registerFormRef","getFormRef","formRefStore","refKey","localFormRef","existingRef","formRef","getValidationErrors","addValidationError","getInitialOptions","removeValidationError","stateValue","inputValue","setInputValue","initialOptions","timeoutRef","updater","opts","handleBlur","fieldValue","validateZodPathFunc","error","rawSyncStatus","syncStatus","childElement","message","e","jsx","Fragment","ValidationWrapper","children","validationErrors","thesMessages","newMessage","thisStateOpts","fullMessageString","React"],"mappings":";;;;;;AAeO,SAASA,EACdC,GACAC,GACAC,GACAC,GACM;AACN,EAAAH;AAAA,IACE,CAACI,MAAc;AACT,UAAA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A,EAChC,UAAAhC;AAAA,EACA,MAAA1C;AAAA,EACA,eAAAC;AAAA,EACA,UAAAQ;AAAA,EACA,UAAAkE;AAAA,EACA,cAAAxC;AACF,GAOG;AACD,QAAM,EAAE,mBAAAmB,EAAA,IAAsB1C,EAAe,SAAS,GAEhDgE,IAAmB1C;AAAA,IACvBjC;AAAA,IACAD;AAAA,IACAmC;AAAA,EACF,GAEM0C,IAAyB,CAAC;AAEhC,MAAID,GAAkB;AACd,UAAAE,IAAaF,EAAkB,KAAK,IAAI;AAC9C,IAAKC,EAAa,SAASC,CAAU,KACnCD,EAAa,KAAKC,CAAU;AAAA,EAC9B;AAEI,QAAAC,IAAgBzB,EAAkB7C,CAAS;AACjD,MAAIuE,IAAoBD,GAAe,YAAY,SAC/CF,GAAc,SAAS,IACrBA,GAAc,KAAK,IAAI,IACvBnC,GAAU,YAAY,UACpBA,GAAU,YAAY,UACtB,KACJ;AAGF,SAAA,gBAAA8B,EAAAC,GAAA,EACG,UAAeM,GAAA,cAAc,cAC9B,CAACrC,GAAU,YAAY,UACrBqC,EAAc,aAAc,WAAY;AAAA,IACtC,4BACGE,EAAM,UAAN,EAAsC,UAAAN,KAAlB3E,EAAK,UAAsB;AAAA,IAElD,QAAQgF,KAAqB;AAAA,IAC7B,SAAStC,GAAU,YAAY,cAAc,KAAKsC;AAAA,IAClD,MAAAhF;AAAA,IAEA,GAAI0C,GAAU,OAAO,EAAE,KAAKA,GAAU,IAAI;AAAA,EAAA,CAC3C,IAED,gBAAA8B,EAACS,EAAM,UAAN,EAAsC,UAAAN,EAAlB,GAAA3E,EAAK,SAAsB,CAAA,GAEpD;AAEJ;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "react";
|
|
2
2
|
import { ZodArray as y, ZodObject as w, ZodOptional as u, ZodNullable as f, ZodEffects as l } from "zod";
|
|
3
3
|
import { getGlobalStore as g } from "./store.js";
|
|
4
4
|
import { create as m } from "./node_modules/zustand/esm/react.js";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_commonjsHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/_virtual/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.jsx","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-jsx-runtime.jsx","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-jsx-runtime.production.jsx","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/_virtual/react.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.production.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|