cogsbox-state 0.5.469 → 0.5.471
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 +2 -48
- package/dist/CogsState.d.ts +1 -1
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.jsx +48 -48
- package/dist/Components.jsx.map +1 -1
- package/dist/index.js +5 -4
- package/dist/store.d.ts +1 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +23 -18
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +1 -1
- package/src/Components.tsx +2 -2
- package/src/store.ts +9 -4
package/dist/Components.jsx
CHANGED
|
@@ -20,24 +20,24 @@ function ne({
|
|
|
20
20
|
stateKey: n,
|
|
21
21
|
children: o
|
|
22
22
|
}) {
|
|
23
|
-
const { getInitialOptions: l, getShadowMetadata: s, getShadowValue: a } = b.getState(),
|
|
24
|
-
...
|
|
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
25
|
path: t
|
|
26
|
-
})),
|
|
27
|
-
return /* @__PURE__ */ w(x, { children:
|
|
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
28
|
children: /* @__PURE__ */ w(U.Fragment, { children: o }, t.toString()),
|
|
29
29
|
status: i,
|
|
30
30
|
// Now passes the new ValidationStatus type
|
|
31
31
|
message: e?.validation?.hideMessage ? "" : e?.validation?.message || L || "",
|
|
32
32
|
severity: V,
|
|
33
|
-
hasErrors:
|
|
33
|
+
hasErrors: u.length > 0,
|
|
34
34
|
hasWarnings: c.length > 0,
|
|
35
|
-
allErrors:
|
|
35
|
+
allErrors: v,
|
|
36
36
|
path: t,
|
|
37
37
|
getData: () => a(n, t)
|
|
38
38
|
}) : /* @__PURE__ */ w(U.Fragment, { children: o }, t.toString()) });
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const me = _(
|
|
41
41
|
oe,
|
|
42
42
|
(e, t) => e.itemPath.join(".") === t.itemPath.join(".") && e.stateKey === t.stateKey && e.itemComponentId === t.itemComponentId && e.localIndex === t.localIndex
|
|
43
43
|
);
|
|
@@ -50,8 +50,8 @@ function oe({
|
|
|
50
50
|
rebuildStateShape: s,
|
|
51
51
|
renderFn: a
|
|
52
52
|
}) {
|
|
53
|
-
const [,
|
|
54
|
-
F(e, t,
|
|
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
55
|
const L = J(
|
|
56
56
|
(r) => {
|
|
57
57
|
i.current = r, h(r);
|
|
@@ -59,42 +59,42 @@ function oe({
|
|
|
59
59
|
[h]
|
|
60
60
|
);
|
|
61
61
|
C(() => {
|
|
62
|
-
const r = re(c, (
|
|
63
|
-
|
|
62
|
+
const r = re(c, (g) => {
|
|
63
|
+
f({});
|
|
64
64
|
});
|
|
65
65
|
return () => r();
|
|
66
66
|
}, [c]), C(() => {
|
|
67
|
-
if (!
|
|
67
|
+
if (!m || !v || u.current)
|
|
68
68
|
return;
|
|
69
69
|
const r = i.current;
|
|
70
70
|
if (r && r.offsetHeight > 0) {
|
|
71
|
-
|
|
72
|
-
const
|
|
71
|
+
u.current = !0;
|
|
72
|
+
const g = r.offsetHeight;
|
|
73
73
|
I(e, n, {
|
|
74
74
|
virtualizer: {
|
|
75
|
-
itemHeight:
|
|
75
|
+
itemHeight: g,
|
|
76
76
|
domRef: r
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
-
const
|
|
79
|
+
const S = n.slice(0, -1), D = [e, ...S].join(".");
|
|
80
80
|
te(D, {
|
|
81
81
|
type: "ITEMHEIGHT",
|
|
82
82
|
itemKey: n.join("."),
|
|
83
83
|
ref: i.current
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
}, [
|
|
86
|
+
}, [m, v, e, n]);
|
|
87
87
|
const V = R(e, n);
|
|
88
88
|
if (V === void 0)
|
|
89
89
|
return null;
|
|
90
|
-
const
|
|
90
|
+
const d = s({
|
|
91
91
|
currentState: V,
|
|
92
92
|
path: n,
|
|
93
93
|
componentId: t
|
|
94
|
-
}), z = a(
|
|
94
|
+
}), z = a(d, o, l);
|
|
95
95
|
return /* @__PURE__ */ w("div", { ref: L, children: z });
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function ge({
|
|
98
98
|
stateKey: e,
|
|
99
99
|
path: t,
|
|
100
100
|
rebuildStateShape: n,
|
|
@@ -102,25 +102,25 @@ function me({
|
|
|
102
102
|
formOpts: l,
|
|
103
103
|
setState: s
|
|
104
104
|
}) {
|
|
105
|
-
const [a] = p(() => G()), [,
|
|
106
|
-
F(e, a,
|
|
107
|
-
const
|
|
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
108
|
C(() => {
|
|
109
|
-
!
|
|
110
|
-
}, [
|
|
111
|
-
const r = b.getState().subscribeToPath(h, (
|
|
112
|
-
!
|
|
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({});
|
|
113
113
|
});
|
|
114
114
|
return () => {
|
|
115
|
-
r(), c.current && (clearTimeout(c.current),
|
|
115
|
+
r(), c.current && (clearTimeout(c.current), u.current = !1);
|
|
116
116
|
};
|
|
117
117
|
}, []);
|
|
118
118
|
const L = J(
|
|
119
119
|
(r) => {
|
|
120
|
-
typeof
|
|
121
|
-
const
|
|
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
122
|
c.current = setTimeout(() => {
|
|
123
|
-
if (
|
|
123
|
+
if (u.current = !1, s(r, t, { updateType: "update" }), !b.getState().getShadowMetadata(e, [])?.features?.validationEnabled) return;
|
|
124
124
|
const M = Z(e)?.validation, N = M?.zodSchemaV4 || M?.zodSchemaV3;
|
|
125
125
|
if (N) {
|
|
126
126
|
const E = R(e, []), y = N.safeParse(E), O = H(e, t) || {};
|
|
@@ -164,12 +164,12 @@ function me({
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
},
|
|
167
|
+
}, S), f({});
|
|
168
168
|
},
|
|
169
169
|
[s, t, l?.debounceTime, e]
|
|
170
170
|
), V = J(async () => {
|
|
171
|
-
if (console.log("handleBlur triggered"), c.current && (clearTimeout(c.current), c.current = null,
|
|
172
|
-
const { getInitialOptions:
|
|
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
173
|
if (!D) return;
|
|
174
174
|
const M = H(e, t);
|
|
175
175
|
I(e, t, {
|
|
@@ -218,22 +218,22 @@ function me({
|
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
}, [e, t, i, s]),
|
|
221
|
+
f({});
|
|
222
|
+
}, [e, t, i, s]), d = n({
|
|
223
223
|
path: t,
|
|
224
224
|
componentId: a,
|
|
225
225
|
meta: void 0
|
|
226
|
-
}), z = new Proxy(
|
|
227
|
-
get(r,
|
|
228
|
-
return
|
|
226
|
+
}), z = new Proxy(d, {
|
|
227
|
+
get(r, g) {
|
|
228
|
+
return g === "$inputProps" ? {
|
|
229
229
|
value: i ?? "",
|
|
230
|
-
onChange: (
|
|
231
|
-
L(
|
|
230
|
+
onChange: (S) => {
|
|
231
|
+
L(S.target.value);
|
|
232
232
|
},
|
|
233
233
|
// 5. Wire the new onBlur handler to the input props.
|
|
234
234
|
onBlur: V,
|
|
235
235
|
ref: Q.getState().getFormRef(e + "." + t.join("."))
|
|
236
|
-
} : r[
|
|
236
|
+
} : r[g];
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
return /* @__PURE__ */ w(ne, { formOpts: l, path: t, stateKey: e, children: o(z) });
|
|
@@ -273,7 +273,7 @@ const se = (e) => {
|
|
|
273
273
|
};
|
|
274
274
|
}, [e.current]), t;
|
|
275
275
|
};
|
|
276
|
-
function
|
|
276
|
+
function ve({
|
|
277
277
|
stateKey: e,
|
|
278
278
|
path: t,
|
|
279
279
|
rebuildStateShape: n,
|
|
@@ -286,18 +286,18 @@ function Se({
|
|
|
286
286
|
});
|
|
287
287
|
return () => h();
|
|
288
288
|
}, [a]);
|
|
289
|
-
const
|
|
289
|
+
const f = n({
|
|
290
290
|
path: t,
|
|
291
291
|
componentId: l,
|
|
292
292
|
meta: void 0
|
|
293
293
|
});
|
|
294
|
-
return
|
|
294
|
+
return /* @__PURE__ */ w(x, { children: o(f) });
|
|
295
295
|
}
|
|
296
296
|
export {
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
ge as FormElementWrapper,
|
|
298
|
+
ve as IsolatedComponentWrapper,
|
|
299
299
|
oe as ListItemWrapper,
|
|
300
|
-
|
|
300
|
+
me as MemoizedCogsItemWrapper,
|
|
301
301
|
ne as ValidationWrapper,
|
|
302
302
|
F as useRegisterComponent
|
|
303
303
|
};
|
package/dist/Components.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components.jsx","sources":["../src/Components.tsx"],"sourcesContent":["import { FormElementParams, type FormOptsType } from './CogsState';\r\nimport React, {\r\n memo,\r\n RefObject,\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useRef,\r\n useState,\r\n} from 'react';\r\nimport {\r\n formRefStore,\r\n getGlobalStore,\r\n ValidationError,\r\n ValidationSeverity,\r\n} from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\r\nconst {\r\n getInitialOptions,\r\n\r\n getShadowMetadata,\r\n setShadowMetadata,\r\n getShadowValue,\r\n\r\n registerComponent,\r\n unregisterComponent,\r\n\r\n notifyPathSubscribers,\r\n subscribeToPath,\r\n} = getGlobalStore.getState();\r\nexport type ValidationWrapperProps = {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n stateKey: string;\r\n children: React.ReactNode;\r\n};\r\n\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n stateKey,\r\n children,\r\n}: ValidationWrapperProps) {\r\n const { getInitialOptions, getShadowMetadata, getShadowValue } =\r\n getGlobalStore.getState();\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n\r\n const shadowMeta = getShadowMetadata(stateKey!, path);\r\n const validationState = shadowMeta?.validation;\r\n\r\n const status = validationState?.status || 'NOT_VALIDATED';\r\n\r\n const errors = (validationState?.errors || []).map((err) => ({\r\n ...err,\r\n path: path,\r\n })) as ValidationError[];\r\n const errorMessages = errors\r\n .filter((err) => err.severity === 'error')\r\n .map((err) => err.message);\r\n const warningMessages = errors\r\n .filter((err) => err.severity === 'warning')\r\n .map((err) => err.message);\r\n\r\n // Use first error, or first warning if no errors\r\n const message = errorMessages[0] || warningMessages[0];\r\n const primarySeverity: ValidationSeverity =\r\n errorMessages.length > 0\r\n ? 'error'\r\n : warningMessages.length > 0\r\n ? 'warning'\r\n : undefined;\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 status, // Now passes the new ValidationStatus type\r\n message: formOpts?.validation?.hideMessage\r\n ? ''\r\n : formOpts?.validation?.message || message || '',\r\n severity: primarySeverity,\r\n hasErrors: errorMessages.length > 0,\r\n hasWarnings: warningMessages.length > 0,\r\n allErrors: errors,\r\n path: path,\r\n getData: () => getShadowValue(stateKey!, path),\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\nexport const MemoizedCogsItemWrapper = memo(\r\n ListItemWrapper,\r\n (prevProps, nextProps) => {\r\n // Re-render if any of these change:\r\n return (\r\n prevProps.itemPath.join('.') === nextProps.itemPath.join('.') &&\r\n prevProps.stateKey === nextProps.stateKey &&\r\n prevProps.itemComponentId === nextProps.itemComponentId &&\r\n prevProps.localIndex === nextProps.localIndex\r\n );\r\n }\r\n);\r\nexport function ListItemWrapper({\r\n stateKey,\r\n itemComponentId,\r\n itemPath,\r\n localIndex,\r\n arraySetter,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n itemComponentId: string;\r\n itemPath: string[];\r\n localIndex: number;\r\n arraySetter: any;\r\n\r\n rebuildStateShape: (options: {\r\n currentState: any;\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (\r\n setter: any,\r\n index: number,\r\n\r\n arraySetter: any\r\n ) => React.ReactNode;\r\n}) {\r\n const [, forceUpdate] = useState({});\r\n const { ref: inViewRef, inView } = useInView();\r\n const elementRef = useRef<HTMLDivElement | null>(null);\r\n\r\n const imagesLoaded = useImageLoaded(elementRef);\r\n const hasReportedInitialHeight = useRef(false);\r\n const fullKey = [stateKey, ...itemPath].join('.');\r\n useRegisterComponent(stateKey, itemComponentId, forceUpdate);\r\n\r\n const setRefs = useCallback(\r\n (element: HTMLDivElement | null) => {\r\n elementRef.current = element;\r\n inViewRef(element); // This is the ref from useInView\r\n },\r\n [inViewRef]\r\n );\r\n\r\n useEffect(() => {\r\n const unsubscribe = subscribeToPath(fullKey, (e) => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [fullKey]);\r\n useEffect(() => {\r\n if (!inView || !imagesLoaded || hasReportedInitialHeight.current) {\r\n return;\r\n }\r\n\r\n const element = elementRef.current;\r\n if (element && element.offsetHeight > 0) {\r\n hasReportedInitialHeight.current = true;\r\n const newHeight = element.offsetHeight;\r\n\r\n setShadowMetadata(stateKey, itemPath, {\r\n virtualizer: {\r\n itemHeight: newHeight,\r\n domRef: element,\r\n },\r\n });\r\n\r\n const arrayPath = itemPath.slice(0, -1);\r\n const arrayPathKey = [stateKey, ...arrayPath].join('.');\r\n notifyPathSubscribers(arrayPathKey, {\r\n type: 'ITEMHEIGHT',\r\n itemKey: itemPath.join('.'),\r\n\r\n ref: elementRef.current,\r\n });\r\n }\r\n }, [inView, imagesLoaded, stateKey, itemPath]);\r\n\r\n const itemValue = getShadowValue(stateKey, itemPath);\r\n\r\n if (itemValue === undefined) {\r\n return null;\r\n }\r\n\r\n const itemSetter = rebuildStateShape({\r\n currentState: itemValue,\r\n path: itemPath,\r\n componentId: itemComponentId,\r\n });\r\n const children = renderFn(itemSetter, localIndex, arraySetter);\r\n\r\n return <div ref={setRefs}>{children}</div>;\r\n}\r\n\r\nexport function FormElementWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n formOpts,\r\n setState,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (params: FormElementParams<any>) => React.ReactNode;\r\n formOpts?: FormOptsType;\r\n setState: any;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n const globalStateValue = getShadowValue(stateKey, path);\r\n const [localValue, setLocalValue] = useState<any>(globalStateValue);\r\n const isCurrentlyDebouncing = useRef(false);\r\n const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);\r\n\r\n useEffect(() => {\r\n if (\r\n !isCurrentlyDebouncing.current &&\r\n !isDeepEqual(globalStateValue, localValue)\r\n ) {\r\n setLocalValue(globalStateValue);\r\n }\r\n }, [globalStateValue]);\r\n\r\n useEffect(() => {\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, (newValue) => {\r\n if (!isCurrentlyDebouncing.current && localValue !== newValue) {\r\n forceUpdate({});\r\n }\r\n });\r\n return () => {\r\n unsubscribe();\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n };\r\n }, []);\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n const currentType = typeof globalStateValue;\r\n if (currentType === 'number' && typeof newValue === 'string') {\r\n newValue = newValue === '' ? 0 : Number(newValue);\r\n }\r\n setLocalValue(newValue);\r\n isCurrentlyDebouncing.current = true;\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, { updateType: 'update' });\r\n\r\n // NEW: Check if validation is enabled via features\r\n const rootMeta = getGlobalStore\r\n .getState()\r\n .getShadowMetadata(stateKey, []);\r\n if (!rootMeta?.features?.validationEnabled) return;\r\n\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n const zodSchema =\r\n validationOptions?.zodSchemaV4 || validationOptions?.zodSchemaV3;\r\n\r\n if (zodSchema) {\r\n const fullState = getShadowValue(stateKey, []);\r\n const result = zodSchema.safeParse(fullState);\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n\r\n if (!result.success) {\r\n const errors =\r\n 'issues' in result.error\r\n ? result.error.issues\r\n : (result.error as any).errors;\r\n\r\n const pathErrors = errors.filter(\r\n (error: any) =>\r\n JSON.stringify(error.path) === JSON.stringify(path)\r\n );\r\n\r\n if (pathErrors.length > 0) {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'INVALID',\r\n errors: [\r\n {\r\n source: 'client',\r\n message: pathErrors[0]?.message,\r\n severity: 'warning', // Gentle error during typing\r\n },\r\n ],\r\n lastValidated: Date.now(),\r\n validatedValue: newValue,\r\n },\r\n });\r\n } else {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: newValue,\r\n },\r\n });\r\n }\r\n } else {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: newValue,\r\n },\r\n });\r\n }\r\n }\r\n }, debounceTime);\r\n forceUpdate({});\r\n },\r\n [setState, path, formOpts?.debounceTime, stateKey]\r\n );\r\n\r\n const handleBlur = useCallback(async () => {\r\n console.log('handleBlur triggered');\r\n\r\n // Commit any pending changes\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n debounceTimeoutRef.current = null;\r\n isCurrentlyDebouncing.current = false;\r\n setState(localValue, path, { updateType: 'update' });\r\n }\r\n const rootMeta = getShadowMetadata(stateKey, []);\r\n if (!rootMeta?.features?.validationEnabled) return;\r\n const { getInitialOptions } = getGlobalStore.getState();\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n const zodSchema =\r\n validationOptions?.zodSchemaV4 || validationOptions?.zodSchemaV3;\r\n\r\n if (!zodSchema) return;\r\n\r\n // Get the full path including stateKey\r\n\r\n // Update validation state to \"validating\"\r\n const currentMeta = getShadowMetadata(stateKey, path);\r\n\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALIDATING',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: localValue,\r\n },\r\n });\r\n\r\n // Validate full state\r\n const fullState = getShadowValue(stateKey, []);\r\n const result = zodSchema.safeParse(fullState);\r\n\r\n if (!result.success) {\r\n const errors =\r\n 'issues' in result.error\r\n ? result.error.issues\r\n : (result.error as any).errors;\r\n\r\n // Find errors for this specific path\r\n const pathErrors = errors.filter((error: any) => {\r\n // For array paths, we need to translate indices to ULIDs\r\n if (path.some((p) => p.startsWith('id:'))) {\r\n // This is an array item path like [\"id:xyz\", \"name\"]\r\n const parentPath = path[0]!.startsWith('id:')\r\n ? []\r\n : path.slice(0, -1);\r\n\r\n const arrayMeta = getGlobalStore\r\n .getState()\r\n .getShadowMetadata(stateKey, parentPath);\r\n\r\n if (arrayMeta?.arrayKeys) {\r\n const itemKey = [stateKey, ...path.slice(0, -1)].join('.');\r\n const itemIndex = arrayMeta.arrayKeys.indexOf(itemKey);\r\n\r\n // Compare with Zod path\r\n const zodPath = [...parentPath, itemIndex, ...path.slice(-1)];\r\n const match =\r\n JSON.stringify(error.path) === JSON.stringify(zodPath);\r\n\r\n return match;\r\n }\r\n }\r\n\r\n const directMatch = JSON.stringify(error.path) === JSON.stringify(path);\r\n\r\n return directMatch;\r\n });\r\n\r\n // Update shadow metadata with validation result\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'INVALID',\r\n errors: pathErrors.map((err: any) => ({\r\n source: 'client' as const,\r\n message: err.message,\r\n severity: 'error' as const, // Hard error on blur\r\n })),\r\n lastValidated: Date.now(),\r\n validatedValue: localValue,\r\n },\r\n });\r\n } else {\r\n // Validation passed\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: localValue,\r\n },\r\n });\r\n }\r\n forceUpdate({});\r\n }, [stateKey, path, localValue, setState]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n const stateWithInputProps = new Proxy(baseState, {\r\n get(target, prop) {\r\n if (prop === 'inputProps') {\r\n return {\r\n value: localValue ?? '',\r\n onChange: (e: any) => {\r\n debouncedUpdate(e.target.value);\r\n },\r\n // 5. Wire the new onBlur handler to the input props.\r\n onBlur: handleBlur,\r\n ref: formRefStore\r\n .getState()\r\n .getFormRef(stateKey + '.' + path.join('.')),\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {renderFn(stateWithInputProps)}\r\n </ValidationWrapper>\r\n );\r\n}\r\nexport function useRegisterComponent(\r\n stateKey: string,\r\n componentId: string,\r\n forceUpdate: (o: object) => void\r\n) {\r\n const fullComponentId = `${stateKey}////${componentId}`;\r\n\r\n useLayoutEffect(() => {\r\n // Call the safe, centralized function to register\r\n registerComponent(stateKey, fullComponentId, {\r\n forceUpdate: () => forceUpdate({}),\r\n paths: new Set(),\r\n reactiveType: ['component'],\r\n });\r\n\r\n // The cleanup now calls the safe, centralized unregister function\r\n return () => {\r\n unregisterComponent(stateKey, fullComponentId);\r\n };\r\n }, [stateKey, fullComponentId]); // Dependencies are stable and correct\r\n}\r\n\r\nconst useImageLoaded = (ref: RefObject<HTMLElement>): boolean => {\r\n const [loaded, setLoaded] = useState(false);\r\n\r\n useLayoutEffect(() => {\r\n if (!ref.current) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n const images = Array.from(ref.current.querySelectorAll('img'));\r\n\r\n // If there are no images, we are \"loaded\" immediately.\r\n if (images.length === 0) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n let loadedCount = 0;\r\n const handleImageLoad = () => {\r\n loadedCount++;\r\n if (loadedCount === images.length) {\r\n setLoaded(true);\r\n }\r\n };\r\n\r\n images.forEach((image) => {\r\n if (image.complete) {\r\n handleImageLoad();\r\n } else {\r\n image.addEventListener('load', handleImageLoad);\r\n image.addEventListener('error', handleImageLoad);\r\n }\r\n });\r\n\r\n return () => {\r\n images.forEach((image) => {\r\n image.removeEventListener('load', handleImageLoad);\r\n image.removeEventListener('error', handleImageLoad);\r\n });\r\n };\r\n }, [ref.current]);\r\n\r\n return loaded;\r\n};\r\n// Components.tsx\r\n\r\n// Generic isolated component wrapper\r\nexport function IsolatedComponentWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (state: any) => React.ReactNode;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\r\n useEffect(() => {\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [stateKeyPathKey]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n console.log('baseState', baseState?.$get());\r\n return <>{renderFn(baseState)}</>;\r\n}\r\n"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","ValidationWrapper","formOpts","path","stateKey","children","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","primarySeverity","jsx","Fragment","React","MemoizedCogsItemWrapper","memo","ListItemWrapper","prevProps","nextProps","itemComponentId","itemPath","localIndex","arraySetter","rebuildStateShape","renderFn","forceUpdate","useState","inViewRef","inView","useInView","elementRef","useRef","imagesLoaded","useImageLoaded","hasReportedInitialHeight","fullKey","useRegisterComponent","setRefs","useCallback","element","useEffect","unsubscribe","e","newHeight","arrayPath","arrayPathKey","itemValue","itemSetter","FormElementWrapper","setState","componentId","uuidv4","stateKeyPathKey","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","isDeepEqual","newValue","debouncedUpdate","debounceTime","validationOptions","zodSchema","fullState","result","currentMeta","pathErrors","error","handleBlur","p","parentPath","arrayMeta","itemKey","itemIndex","zodPath","baseState","stateWithInputProps","target","prop","formRefStore","fullComponentId","useLayoutEffect","ref","loaded","setLoaded","images","loadedCount","handleImageLoad","image","IsolatedComponentWrapper"],"mappings":";;;;;;AAmBA,MAAM;AAAA,EACJ,mBAAAA;AAAA,EAEA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EAEA,mBAAAC;AAAA,EACA,qBAAAC;AAAA,EAEA,uBAAAC;AAAA,EACA,iBAAAC;AACF,IAAIC,EAAe,SAAA;AAQZ,SAASC,GAAkB;AAAA,EAChC,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAM,EAAE,mBAAAb,GAAmB,mBAAAC,GAAmB,gBAAAE,EAAAA,IAC5CK,EAAe,SAAA,GACXM,IAAgBd,EAAkBY,CAAS,GAG3CG,IADad,EAAkBW,GAAWD,CAAI,GAChB,YAE9BK,IAASD,GAAiB,UAAU,iBAEpCE,KAAUF,GAAiB,UAAU,CAAA,GAAI,IAAI,CAACG,OAAS;AAAA,IAC3D,GAAGA;AAAA,IACH,MAAAP;AAAA,EAAA,EACA,GACIQ,IAAgBF,EACnB,OAAO,CAACC,MAAQA,EAAI,aAAa,OAAO,EACxC,IAAI,CAACA,MAAQA,EAAI,OAAO,GACrBE,IAAkBH,EACrB,OAAO,CAACC,MAAQA,EAAI,aAAa,SAAS,EAC1C,IAAI,CAAC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
|
|
1
|
+
{"version":3,"file":"Components.jsx","sources":["../src/Components.tsx"],"sourcesContent":["import { FormElementParams, type FormOptsType } from './CogsState';\r\nimport React, {\r\n memo,\r\n RefObject,\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useRef,\r\n useState,\r\n} from 'react';\r\nimport {\r\n formRefStore,\r\n getGlobalStore,\r\n ValidationError,\r\n ValidationSeverity,\r\n} from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\r\nconst {\r\n getInitialOptions,\r\n\r\n getShadowMetadata,\r\n setShadowMetadata,\r\n getShadowValue,\r\n\r\n registerComponent,\r\n unregisterComponent,\r\n\r\n notifyPathSubscribers,\r\n subscribeToPath,\r\n} = getGlobalStore.getState();\r\nexport type ValidationWrapperProps = {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n stateKey: string;\r\n children: React.ReactNode;\r\n};\r\n\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n stateKey,\r\n children,\r\n}: ValidationWrapperProps) {\r\n const { getInitialOptions, getShadowMetadata, getShadowValue } =\r\n getGlobalStore.getState();\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n\r\n const shadowMeta = getShadowMetadata(stateKey!, path);\r\n const validationState = shadowMeta?.validation;\r\n\r\n const status = validationState?.status || 'NOT_VALIDATED';\r\n\r\n const errors = (validationState?.errors || []).map((err) => ({\r\n ...err,\r\n path: path,\r\n })) as ValidationError[];\r\n const errorMessages = errors\r\n .filter((err) => err.severity === 'error')\r\n .map((err) => err.message);\r\n const warningMessages = errors\r\n .filter((err) => err.severity === 'warning')\r\n .map((err) => err.message);\r\n\r\n // Use first error, or first warning if no errors\r\n const message = errorMessages[0] || warningMessages[0];\r\n const primarySeverity: ValidationSeverity =\r\n errorMessages.length > 0\r\n ? 'error'\r\n : warningMessages.length > 0\r\n ? 'warning'\r\n : undefined;\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 status, // Now passes the new ValidationStatus type\r\n message: formOpts?.validation?.hideMessage\r\n ? ''\r\n : formOpts?.validation?.message || message || '',\r\n severity: primarySeverity,\r\n hasErrors: errorMessages.length > 0,\r\n hasWarnings: warningMessages.length > 0,\r\n allErrors: errors,\r\n path: path,\r\n getData: () => getShadowValue(stateKey!, path),\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\nexport const MemoizedCogsItemWrapper = memo(\r\n ListItemWrapper,\r\n (prevProps, nextProps) => {\r\n // Re-render if any of these change:\r\n return (\r\n prevProps.itemPath.join('.') === nextProps.itemPath.join('.') &&\r\n prevProps.stateKey === nextProps.stateKey &&\r\n prevProps.itemComponentId === nextProps.itemComponentId &&\r\n prevProps.localIndex === nextProps.localIndex\r\n );\r\n }\r\n);\r\nexport function ListItemWrapper({\r\n stateKey,\r\n itemComponentId,\r\n itemPath,\r\n localIndex,\r\n arraySetter,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n itemComponentId: string;\r\n itemPath: string[];\r\n localIndex: number;\r\n arraySetter: any;\r\n\r\n rebuildStateShape: (options: {\r\n currentState: any;\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (\r\n setter: any,\r\n index: number,\r\n\r\n arraySetter: any\r\n ) => React.ReactNode;\r\n}) {\r\n const [, forceUpdate] = useState({});\r\n const { ref: inViewRef, inView } = useInView();\r\n const elementRef = useRef<HTMLDivElement | null>(null);\r\n\r\n const imagesLoaded = useImageLoaded(elementRef);\r\n const hasReportedInitialHeight = useRef(false);\r\n const fullKey = [stateKey, ...itemPath].join('.');\r\n useRegisterComponent(stateKey, itemComponentId, forceUpdate);\r\n\r\n const setRefs = useCallback(\r\n (element: HTMLDivElement | null) => {\r\n elementRef.current = element;\r\n inViewRef(element); // This is the ref from useInView\r\n },\r\n [inViewRef]\r\n );\r\n\r\n useEffect(() => {\r\n const unsubscribe = subscribeToPath(fullKey, (e) => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [fullKey]);\r\n useEffect(() => {\r\n if (!inView || !imagesLoaded || hasReportedInitialHeight.current) {\r\n return;\r\n }\r\n\r\n const element = elementRef.current;\r\n if (element && element.offsetHeight > 0) {\r\n hasReportedInitialHeight.current = true;\r\n const newHeight = element.offsetHeight;\r\n\r\n setShadowMetadata(stateKey, itemPath, {\r\n virtualizer: {\r\n itemHeight: newHeight,\r\n domRef: element,\r\n },\r\n });\r\n\r\n const arrayPath = itemPath.slice(0, -1);\r\n const arrayPathKey = [stateKey, ...arrayPath].join('.');\r\n notifyPathSubscribers(arrayPathKey, {\r\n type: 'ITEMHEIGHT',\r\n itemKey: itemPath.join('.'),\r\n\r\n ref: elementRef.current,\r\n });\r\n }\r\n }, [inView, imagesLoaded, stateKey, itemPath]);\r\n\r\n const itemValue = getShadowValue(stateKey, itemPath);\r\n\r\n if (itemValue === undefined) {\r\n return null;\r\n }\r\n\r\n const itemSetter = rebuildStateShape({\r\n currentState: itemValue,\r\n path: itemPath,\r\n componentId: itemComponentId,\r\n });\r\n const children = renderFn(itemSetter, localIndex, arraySetter);\r\n\r\n return <div ref={setRefs}>{children}</div>;\r\n}\r\n\r\nexport function FormElementWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n formOpts,\r\n setState,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (params: FormElementParams<any>) => React.ReactNode;\r\n formOpts?: FormOptsType;\r\n setState: any;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n const globalStateValue = getShadowValue(stateKey, path);\r\n const [localValue, setLocalValue] = useState<any>(globalStateValue);\r\n const isCurrentlyDebouncing = useRef(false);\r\n const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);\r\n\r\n useEffect(() => {\r\n if (\r\n !isCurrentlyDebouncing.current &&\r\n !isDeepEqual(globalStateValue, localValue)\r\n ) {\r\n setLocalValue(globalStateValue);\r\n }\r\n }, [globalStateValue]);\r\n\r\n useEffect(() => {\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, (newValue) => {\r\n if (!isCurrentlyDebouncing.current && localValue !== newValue) {\r\n forceUpdate({});\r\n }\r\n });\r\n return () => {\r\n unsubscribe();\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n };\r\n }, []);\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n const currentType = typeof globalStateValue;\r\n if (currentType === 'number' && typeof newValue === 'string') {\r\n newValue = newValue === '' ? 0 : Number(newValue);\r\n }\r\n setLocalValue(newValue);\r\n isCurrentlyDebouncing.current = true;\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, { updateType: 'update' });\r\n\r\n // NEW: Check if validation is enabled via features\r\n const rootMeta = getGlobalStore\r\n .getState()\r\n .getShadowMetadata(stateKey, []);\r\n if (!rootMeta?.features?.validationEnabled) return;\r\n\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n const zodSchema =\r\n validationOptions?.zodSchemaV4 || validationOptions?.zodSchemaV3;\r\n\r\n if (zodSchema) {\r\n const fullState = getShadowValue(stateKey, []);\r\n const result = zodSchema.safeParse(fullState);\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n\r\n if (!result.success) {\r\n const errors =\r\n 'issues' in result.error\r\n ? result.error.issues\r\n : (result.error as any).errors;\r\n\r\n const pathErrors = errors.filter(\r\n (error: any) =>\r\n JSON.stringify(error.path) === JSON.stringify(path)\r\n );\r\n\r\n if (pathErrors.length > 0) {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'INVALID',\r\n errors: [\r\n {\r\n source: 'client',\r\n message: pathErrors[0]?.message,\r\n severity: 'warning', // Gentle error during typing\r\n },\r\n ],\r\n lastValidated: Date.now(),\r\n validatedValue: newValue,\r\n },\r\n });\r\n } else {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: newValue,\r\n },\r\n });\r\n }\r\n } else {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: newValue,\r\n },\r\n });\r\n }\r\n }\r\n }, debounceTime);\r\n forceUpdate({});\r\n },\r\n [setState, path, formOpts?.debounceTime, stateKey]\r\n );\r\n\r\n const handleBlur = useCallback(async () => {\r\n console.log('handleBlur triggered');\r\n\r\n // Commit any pending changes\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n debounceTimeoutRef.current = null;\r\n isCurrentlyDebouncing.current = false;\r\n setState(localValue, path, { updateType: 'update' });\r\n }\r\n const rootMeta = getShadowMetadata(stateKey, []);\r\n if (!rootMeta?.features?.validationEnabled) return;\r\n const { getInitialOptions } = getGlobalStore.getState();\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n const zodSchema =\r\n validationOptions?.zodSchemaV4 || validationOptions?.zodSchemaV3;\r\n\r\n if (!zodSchema) return;\r\n\r\n // Get the full path including stateKey\r\n\r\n // Update validation state to \"validating\"\r\n const currentMeta = getShadowMetadata(stateKey, path);\r\n\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALIDATING',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: localValue,\r\n },\r\n });\r\n\r\n // Validate full state\r\n const fullState = getShadowValue(stateKey, []);\r\n const result = zodSchema.safeParse(fullState);\r\n\r\n if (!result.success) {\r\n const errors =\r\n 'issues' in result.error\r\n ? result.error.issues\r\n : (result.error as any).errors;\r\n\r\n // Find errors for this specific path\r\n const pathErrors = errors.filter((error: any) => {\r\n // For array paths, we need to translate indices to ULIDs\r\n if (path.some((p) => p.startsWith('id:'))) {\r\n // This is an array item path like [\"id:xyz\", \"name\"]\r\n const parentPath = path[0]!.startsWith('id:')\r\n ? []\r\n : path.slice(0, -1);\r\n\r\n const arrayMeta = getGlobalStore\r\n .getState()\r\n .getShadowMetadata(stateKey, parentPath);\r\n\r\n if (arrayMeta?.arrayKeys) {\r\n const itemKey = [stateKey, ...path.slice(0, -1)].join('.');\r\n const itemIndex = arrayMeta.arrayKeys.indexOf(itemKey);\r\n\r\n // Compare with Zod path\r\n const zodPath = [...parentPath, itemIndex, ...path.slice(-1)];\r\n const match =\r\n JSON.stringify(error.path) === JSON.stringify(zodPath);\r\n\r\n return match;\r\n }\r\n }\r\n\r\n const directMatch = JSON.stringify(error.path) === JSON.stringify(path);\r\n\r\n return directMatch;\r\n });\r\n\r\n // Update shadow metadata with validation result\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'INVALID',\r\n errors: pathErrors.map((err: any) => ({\r\n source: 'client' as const,\r\n message: err.message,\r\n severity: 'error' as const, // Hard error on blur\r\n })),\r\n lastValidated: Date.now(),\r\n validatedValue: localValue,\r\n },\r\n });\r\n } else {\r\n // Validation passed\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: localValue,\r\n },\r\n });\r\n }\r\n forceUpdate({});\r\n }, [stateKey, path, localValue, setState]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n const stateWithInputProps = new Proxy(baseState, {\r\n get(target, prop) {\r\n if (prop === '$inputProps') {\r\n return {\r\n value: localValue ?? '',\r\n onChange: (e: any) => {\r\n debouncedUpdate(e.target.value);\r\n },\r\n // 5. Wire the new onBlur handler to the input props.\r\n onBlur: handleBlur,\r\n ref: formRefStore\r\n .getState()\r\n .getFormRef(stateKey + '.' + path.join('.')),\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {renderFn(stateWithInputProps)}\r\n </ValidationWrapper>\r\n );\r\n}\r\nexport function useRegisterComponent(\r\n stateKey: string,\r\n componentId: string,\r\n forceUpdate: (o: object) => void\r\n) {\r\n const fullComponentId = `${stateKey}////${componentId}`;\r\n\r\n useLayoutEffect(() => {\r\n // Call the safe, centralized function to register\r\n registerComponent(stateKey, fullComponentId, {\r\n forceUpdate: () => forceUpdate({}),\r\n paths: new Set(),\r\n reactiveType: ['component'],\r\n });\r\n\r\n // The cleanup now calls the safe, centralized unregister function\r\n return () => {\r\n unregisterComponent(stateKey, fullComponentId);\r\n };\r\n }, [stateKey, fullComponentId]); // Dependencies are stable and correct\r\n}\r\n\r\nconst useImageLoaded = (ref: RefObject<HTMLElement>): boolean => {\r\n const [loaded, setLoaded] = useState(false);\r\n\r\n useLayoutEffect(() => {\r\n if (!ref.current) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n const images = Array.from(ref.current.querySelectorAll('img'));\r\n\r\n // If there are no images, we are \"loaded\" immediately.\r\n if (images.length === 0) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n let loadedCount = 0;\r\n const handleImageLoad = () => {\r\n loadedCount++;\r\n if (loadedCount === images.length) {\r\n setLoaded(true);\r\n }\r\n };\r\n\r\n images.forEach((image) => {\r\n if (image.complete) {\r\n handleImageLoad();\r\n } else {\r\n image.addEventListener('load', handleImageLoad);\r\n image.addEventListener('error', handleImageLoad);\r\n }\r\n });\r\n\r\n return () => {\r\n images.forEach((image) => {\r\n image.removeEventListener('load', handleImageLoad);\r\n image.removeEventListener('error', handleImageLoad);\r\n });\r\n };\r\n }, [ref.current]);\r\n\r\n return loaded;\r\n};\r\n// Components.tsx\r\n\r\n// Generic isolated component wrapper\r\nexport function IsolatedComponentWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (state: any) => React.ReactNode;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\r\n useEffect(() => {\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [stateKeyPathKey]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n return <>{renderFn(baseState)}</>;\r\n}\r\n"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","ValidationWrapper","formOpts","path","stateKey","children","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","primarySeverity","jsx","Fragment","React","MemoizedCogsItemWrapper","memo","ListItemWrapper","prevProps","nextProps","itemComponentId","itemPath","localIndex","arraySetter","rebuildStateShape","renderFn","forceUpdate","useState","inViewRef","inView","useInView","elementRef","useRef","imagesLoaded","useImageLoaded","hasReportedInitialHeight","fullKey","useRegisterComponent","setRefs","useCallback","element","useEffect","unsubscribe","e","newHeight","arrayPath","arrayPathKey","itemValue","itemSetter","FormElementWrapper","setState","componentId","uuidv4","stateKeyPathKey","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","isDeepEqual","newValue","debouncedUpdate","debounceTime","validationOptions","zodSchema","fullState","result","currentMeta","pathErrors","error","handleBlur","p","parentPath","arrayMeta","itemKey","itemIndex","zodPath","baseState","stateWithInputProps","target","prop","formRefStore","fullComponentId","useLayoutEffect","ref","loaded","setLoaded","images","loadedCount","handleImageLoad","image","IsolatedComponentWrapper"],"mappings":";;;;;;AAmBA,MAAM;AAAA,EACJ,mBAAAA;AAAA,EAEA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EAEA,mBAAAC;AAAA,EACA,qBAAAC;AAAA,EAEA,uBAAAC;AAAA,EACA,iBAAAC;AACF,IAAIC,EAAe,SAAA;AAQZ,SAASC,GAAkB;AAAA,EAChC,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAM,EAAE,mBAAAb,GAAmB,mBAAAC,GAAmB,gBAAAE,EAAAA,IAC5CK,EAAe,SAAA,GACXM,IAAgBd,EAAkBY,CAAS,GAG3CG,IADad,EAAkBW,GAAWD,CAAI,GAChB,YAE9BK,IAASD,GAAiB,UAAU,iBAEpCE,KAAUF,GAAiB,UAAU,CAAA,GAAI,IAAI,CAACG,OAAS;AAAA,IAC3D,GAAGA;AAAA,IACH,MAAAP;AAAA,EAAA,EACA,GACIQ,IAAgBF,EACnB,OAAO,CAACC,MAAQA,EAAI,aAAa,OAAO,EACxC,IAAI,CAACA,MAAQA,EAAI,OAAO,GACrBE,IAAkBH,EACrB,OAAO,CAACC,MAAQA,EAAI,aAAa,SAAS,EAC1C,IAAI,CAACA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@
|
|
|
1
1
|
import { $cogsSignal as r, addStateOptions as o, createCogsState as a, createCogsStateFromSync as s, useCogsStateFn as n } from "./CogsState.jsx";
|
|
2
|
-
import { CogsStateClient as
|
|
2
|
+
import { CogsStateClient as f, config as i, useCogsConfig as c } from "./CogsStateClient.jsx";
|
|
3
3
|
import { debounce as p, deepMerge as S, deleteNestedProperty as u, getArrayLengthDifferences as l, getArrayLengthDifferencesArray as m, getDifferences as y, getDifferencesArray as C, isArray as x, isDeepEqual as A, isFunction as D, isObject as b, transformStateFunc as F, updateNestedProperty as h } from "./utility.js";
|
|
4
4
|
import { useCogsTrpcValidationLink as N } from "./TRPCValidationLink.js";
|
|
5
|
-
import { buildShadowNode as P, formRefStore as j,
|
|
5
|
+
import { buildShadowNode as P, formRefStore as j, generateId as k, getGlobalStore as q } from "./store.js";
|
|
6
6
|
export {
|
|
7
7
|
r as $cogsSignal,
|
|
8
|
-
|
|
8
|
+
f as CogsStateClient,
|
|
9
9
|
o as addStateOptions,
|
|
10
10
|
P as buildShadowNode,
|
|
11
11
|
i as config,
|
|
@@ -15,11 +15,12 @@ export {
|
|
|
15
15
|
S as deepMerge,
|
|
16
16
|
u as deleteNestedProperty,
|
|
17
17
|
j as formRefStore,
|
|
18
|
+
k as generateId,
|
|
18
19
|
l as getArrayLengthDifferences,
|
|
19
20
|
m as getArrayLengthDifferencesArray,
|
|
20
21
|
y as getDifferences,
|
|
21
22
|
C as getDifferencesArray,
|
|
22
|
-
|
|
23
|
+
q as getGlobalStore,
|
|
23
24
|
x as isArray,
|
|
24
25
|
A as isDeepEqual,
|
|
25
26
|
D as isFunction,
|
package/dist/store.d.ts
CHANGED
|
@@ -150,6 +150,7 @@ export type CogsGlobalState = {
|
|
|
150
150
|
getSyncInfo: (key: string) => SyncInfo | null;
|
|
151
151
|
};
|
|
152
152
|
export declare function buildShadowNode(value: any): ShadowNode;
|
|
153
|
+
export declare function generateId(prefix?: string): string;
|
|
153
154
|
export declare const getGlobalStore: import('zustand').UseBoundStore<import('zustand').StoreApi<CogsGlobalState>>;
|
|
154
155
|
export {};
|
|
155
156
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,QAAQ,EACR,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,UAAU,GAAG,GAAG,CAAC;AAEtB,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACjE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7D,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,qBAAqB,EAAE,CACrB,QAAQ,EAAE,MAAM,KACb,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS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AG,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAC5D,sBAAsB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAElE,kBAAkB,EAAE,GAAG,CACrB,MAAM,EACN;QACE,IAAI,EAAE,GAAG,CAAC;QACV,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;QACxC,SAAS,EAAE,MAAM,CAAC;KACnB,CACF,CAAC;IAEF,oBAAoB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,IAAI,CAAC;IAE9D,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACrD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;IAEnD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,UAAU,CA8BtD;AAQD,wBAAgB,UAAU,CAAC,MAAM,SAAO,GAAG,MAAM,CAEhD;AAED,eAAO,MAAM,cAAc,8EAklBxB,CAAC"}
|
package/dist/store.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { create as w } from "zustand";
|
|
2
|
-
import { ulid as y } from "ulid";
|
|
3
2
|
const _ = w((l, a) => ({
|
|
4
3
|
formRefs: /* @__PURE__ */ new Map(),
|
|
5
4
|
registerFormRef: (e, t) => l((o) => {
|
|
@@ -18,25 +17,30 @@ const _ = w((l, a) => ({
|
|
|
18
17
|
}), n;
|
|
19
18
|
}
|
|
20
19
|
}));
|
|
21
|
-
function
|
|
20
|
+
function h(l) {
|
|
22
21
|
if (l === null || typeof l != "object")
|
|
23
22
|
return { value: l };
|
|
24
23
|
if (Array.isArray(l)) {
|
|
25
24
|
const a = { _meta: { arrayKeys: [] } }, e = [];
|
|
26
25
|
return l.forEach((t) => {
|
|
27
|
-
const o = `id:${
|
|
28
|
-
a[o] =
|
|
26
|
+
const o = `id:${b()}`;
|
|
27
|
+
a[o] = h(t), e.push(o);
|
|
29
28
|
}), a._meta.arrayKeys = e, a;
|
|
30
29
|
}
|
|
31
30
|
if (l.constructor === Object) {
|
|
32
31
|
const a = { _meta: {} };
|
|
33
32
|
for (const e in l)
|
|
34
|
-
Object.prototype.hasOwnProperty.call(l, e) && (a[e] =
|
|
33
|
+
Object.prototype.hasOwnProperty.call(l, e) && (a[e] = h(l[e]));
|
|
35
34
|
return a;
|
|
36
35
|
}
|
|
37
36
|
return { value: l };
|
|
38
37
|
}
|
|
39
|
-
const p = /* @__PURE__ */ new Map()
|
|
38
|
+
const p = /* @__PURE__ */ new Map();
|
|
39
|
+
let M = 0;
|
|
40
|
+
function b(l = "id") {
|
|
41
|
+
return `${l}:${(M++).toString(36)}`;
|
|
42
|
+
}
|
|
43
|
+
const E = w((l, a) => ({
|
|
40
44
|
// Remove shadowStateStore from Zustand state
|
|
41
45
|
setTransformCache: (e, t, o, n) => {
|
|
42
46
|
const s = a().getShadowMetadata(e, t) || {};
|
|
@@ -58,7 +62,7 @@ const p = /* @__PURE__ */ new Map(), E = w((l, a) => ({
|
|
|
58
62
|
i && (n.components = i), f && (n.features = f), c && (n.lastServerSync = c), d && (n.stateSource = d), u && (n.baseServerState = u);
|
|
59
63
|
}
|
|
60
64
|
p.delete(e), p.delete(`[${e}`);
|
|
61
|
-
const s =
|
|
65
|
+
const s = h(t);
|
|
62
66
|
s._meta || (s._meta = {}), Object.assign(s._meta, n);
|
|
63
67
|
const r = Array.isArray(t) ? `[${e}` : e;
|
|
64
68
|
p.set(r, s);
|
|
@@ -109,7 +113,7 @@ const p = /* @__PURE__ */ new Map(), E = w((l, a) => ({
|
|
|
109
113
|
r[t[c]] || (r[t[c]] = {}), r = r[t[c]];
|
|
110
114
|
const i = t.length === 0 ? r : r[t[t.length - 1]];
|
|
111
115
|
if (!i) {
|
|
112
|
-
r[t[t.length - 1]] =
|
|
116
|
+
r[t[t.length - 1]] = h(o), a().notifyPathSubscribers([e, ...t].join("."), {
|
|
113
117
|
type: "UPDATE",
|
|
114
118
|
newValue: o
|
|
115
119
|
});
|
|
@@ -118,16 +122,16 @@ const p = /* @__PURE__ */ new Map(), E = w((l, a) => ({
|
|
|
118
122
|
function f(c, d) {
|
|
119
123
|
if (typeof d != "object" || d === null || Array.isArray(d)) {
|
|
120
124
|
const S = c._meta;
|
|
121
|
-
for (const
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
Object.assign(c,
|
|
125
|
+
for (const y in c)
|
|
126
|
+
y !== "_meta" && delete c[y];
|
|
127
|
+
const m = h(d);
|
|
128
|
+
Object.assign(c, m), S && (c._meta = { ...S, ...c._meta || {} });
|
|
125
129
|
return;
|
|
126
130
|
}
|
|
127
131
|
const u = new Set(Object.keys(d));
|
|
128
132
|
for (const S of u) {
|
|
129
|
-
const
|
|
130
|
-
c[S] ? f(c[S],
|
|
133
|
+
const m = d[S];
|
|
134
|
+
c[S] ? f(c[S], m) : c[S] = h(m);
|
|
131
135
|
}
|
|
132
136
|
for (const S in c)
|
|
133
137
|
S === "_meta" || !Object.prototype.hasOwnProperty.call(c, S) || u.has(S) || delete c[S];
|
|
@@ -157,7 +161,7 @@ const p = /* @__PURE__ */ new Map(), E = w((l, a) => ({
|
|
|
157
161
|
);
|
|
158
162
|
return;
|
|
159
163
|
}
|
|
160
|
-
const r = `id:${
|
|
164
|
+
const r = `id:${b()}`, i = { [r]: h(o) }, f = s._meta.arrayKeys, c = n !== void 0 && n >= 0 && n <= f.length ? n : f.length;
|
|
161
165
|
c >= f.length ? f.push(r) : f.splice(c, 0, r), a().addItemsToArrayNode(e, t, i, f);
|
|
162
166
|
const d = [e, ...t].join(".");
|
|
163
167
|
a().notifyPathSubscribers(d, {
|
|
@@ -179,8 +183,8 @@ const p = /* @__PURE__ */ new Map(), E = w((l, a) => ({
|
|
|
179
183
|
}
|
|
180
184
|
const r = {}, i = [];
|
|
181
185
|
o.forEach((u) => {
|
|
182
|
-
const S = `id:${
|
|
183
|
-
i.push(S), r[S] =
|
|
186
|
+
const S = `id:${b()}`;
|
|
187
|
+
i.push(S), r[S] = h(u);
|
|
184
188
|
});
|
|
185
189
|
const f = s._meta.arrayKeys, c = n !== void 0 && n >= 0 && n <= f.length ? n : f.length;
|
|
186
190
|
c >= f.length ? f.push(...i) : f.splice(c, 0, ...i), a().addItemsToArrayNode(e, t, r, f);
|
|
@@ -348,8 +352,9 @@ const p = /* @__PURE__ */ new Map(), E = w((l, a) => ({
|
|
|
348
352
|
getSyncInfo: (e) => a().syncInfoStore.get(e) || null
|
|
349
353
|
}));
|
|
350
354
|
export {
|
|
351
|
-
|
|
355
|
+
h as buildShadowNode,
|
|
352
356
|
_ as formRefStore,
|
|
357
|
+
b as generateId,
|
|
353
358
|
E as getGlobalStore
|
|
354
359
|
};
|
|
355
360
|
//# sourceMappingURL=store.js.map
|