cogsbox-state 0.5.482 → 0.5.484
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/dist/CogsState.d.ts +4 -3
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.js +360 -363
- package/dist/CogsState.js.map +1 -1
- package/dist/CogsStateClient.d.ts +2 -2
- package/dist/CogsStateClient.d.ts.map +1 -1
- package/dist/CogsStateClient.js.map +1 -1
- package/dist/Components.d.ts +3 -3
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +202 -201
- package/dist/Components.js.map +1 -1
- package/dist/PluginRunner.d.ts +2 -2
- package/dist/PluginRunner.d.ts.map +1 -1
- package/dist/PluginRunner.js +86 -85
- package/dist/PluginRunner.js.map +1 -1
- package/dist/pluginStore.d.ts +1 -0
- package/dist/pluginStore.d.ts.map +1 -1
- package/dist/pluginStore.js +22 -18
- package/dist/pluginStore.js.map +1 -1
- package/dist/plugins.d.ts +4 -4
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +124 -118
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +68 -74
- package/src/CogsStateClient.tsx +2 -2
- package/src/Components.tsx +17 -9
- package/src/PluginRunner.tsx +33 -35
- package/src/pluginStore.ts +7 -1
- package/src/plugins.ts +5 -6
- package/src/store.ts +24 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
type ConfigType = {
|
|
4
4
|
sessionId?: string;
|
|
@@ -6,7 +6,7 @@ type ConfigType = {
|
|
|
6
6
|
export declare const config: ConfigType;
|
|
7
7
|
export declare const useCogsConfig: () => ConfigType;
|
|
8
8
|
export declare function CogsStateClient({ children, sessionId, }: {
|
|
9
|
-
children:
|
|
9
|
+
children: ReactNode;
|
|
10
10
|
sessionId?: string;
|
|
11
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CogsStateClient.d.ts","sourceRoot":"","sources":["../src/CogsStateClient.tsx"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"CogsStateClient.d.ts","sourceRoot":"","sources":["../src/CogsStateClient.tsx"],"names":[],"mappings":"AAEA,OAAc,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,KAAK,UAAU,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACzC,eAAO,MAAM,MAAM,EAAE,UAEpB,CAAC;AAIF,eAAO,MAAM,aAAa,kBAAgC,CAAC;AAE3D,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAMA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CogsStateClient.js","sources":["../src/CogsStateClient.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { createContext, useContext } from \"react\";\r\ntype ConfigType = { sessionId?: string };\r\nexport const config: ConfigType = {\r\n sessionId: undefined,\r\n};\r\n\r\nconst CogsContext = createContext<ConfigType>(config);\r\n\r\nexport const useCogsConfig = () => useContext(CogsContext);\r\n\r\nexport function CogsStateClient({\r\n children,\r\n sessionId,\r\n}: {\r\n children:
|
|
1
|
+
{"version":3,"file":"CogsStateClient.js","sources":["../src/CogsStateClient.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { createContext, useContext, type ReactNode } from \"react\";\r\ntype ConfigType = { sessionId?: string };\r\nexport const config: ConfigType = {\r\n sessionId: undefined,\r\n};\r\n\r\nconst CogsContext = createContext<ConfigType>(config);\r\n\r\nexport const useCogsConfig = () => useContext(CogsContext);\r\n\r\nexport function CogsStateClient({\r\n children,\r\n sessionId,\r\n}: {\r\n children: ReactNode;\r\n sessionId?: string;\r\n}) {\r\n return (\r\n <CogsContext.Provider value={{ sessionId }}>\r\n {children}\r\n </CogsContext.Provider>\r\n );\r\n}\r\n"],"names":["config","CogsContext","createContext","useCogsConfig","useContext","CogsStateClient","children","sessionId","jsx"],"mappings":";;;AAIO,MAAMA,IAAqB;AAAA,EAChC,WAAW;AACb,GAEMC,IAAcC,EAA0BF,CAAM,GAEvCG,IAAgB,MAAMC,EAAWH,CAAW;AAElD,SAASI,EAAgB;AAAA,EAC9B,UAAAC;AAAA,EACA,WAAAC;AACF,GAGG;AACD,SACE,gBAAAC,EAACP,EAAY,UAAZ,EAAqB,OAAO,EAAE,WAAAM,EAAA,GAC5B,UAAAD,GACH;AAEJ;"}
|
package/dist/Components.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FormElementParams, FormOptsType } from './CogsState';
|
|
2
|
-
import { default as React } from 'react';
|
|
2
|
+
import { default as React, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
export type ValidationWrapperProps = {
|
|
5
5
|
formOpts?: FormOptsType;
|
|
6
6
|
path: string[];
|
|
7
7
|
stateKey: string;
|
|
8
|
-
children:
|
|
8
|
+
children: ReactNode;
|
|
9
9
|
};
|
|
10
10
|
export declare function ValidationWrapper({ formOpts, path, stateKey, children, }: ValidationWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export declare const MemoizedCogsItemWrapper: React.MemoExoticComponent<typeof ListItemWrapper>;
|
|
@@ -26,7 +26,7 @@ export declare function FormElementWrapper({ stateKey, path, rebuildStateShape,
|
|
|
26
26
|
componentId: string;
|
|
27
27
|
meta?: any;
|
|
28
28
|
}) => any;
|
|
29
|
-
renderFn: (params: FormElementParams<any>) =>
|
|
29
|
+
renderFn: (params: FormElementParams<any>) => ReactNode;
|
|
30
30
|
formOpts?: FormOptsType;
|
|
31
31
|
setState: any;
|
|
32
32
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/Components.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../src/Components.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAQrB,OAAO,
|
|
1
|
+
{"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../src/Components.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,EASZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAsBf,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,sBAAsB,2CAiFxB;AACD,eAAO,MAAM,uBAAuB,mDAWnC,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC;IACjB,iBAAiB,EAAE,GAAG,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC;CACf,kDA2DA;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,IAAI,EACJ,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iBAAiB,EAAE,CAAC,OAAO,EAAE;QAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,KAAK,GAAG,CAAC;IACV,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;IACxD,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;CACf,2CA0TA;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,QAcjC;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,IAAI,EAAE,8CAA8C;AACpD,YAAY,EAAE,sDAAsD;AACpE,iBAAiB,EACjB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;IACrB,iBAAiB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAC;CAC3C,2CAuCA"}
|
package/dist/Components.js
CHANGED
|
@@ -1,166 +1,167 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as E, Fragment as B } from "react/jsx-runtime";
|
|
2
2
|
import { pluginStore as C } from "./pluginStore.js";
|
|
3
|
-
import { createScopedMetadataContext as
|
|
4
|
-
import
|
|
5
|
-
import { getGlobalStore as
|
|
6
|
-
import { useInView as
|
|
7
|
-
import { v4 as
|
|
8
|
-
import { isDeepEqual as
|
|
9
|
-
import { runValidation as
|
|
3
|
+
import { createScopedMetadataContext as $, toDeconstructedMethods as Q } from "./plugins.js";
|
|
4
|
+
import j, { memo as q, useState as F, useRef as N, useCallback as O, useEffect as P, useLayoutEffect as X, useMemo as Y } from "react";
|
|
5
|
+
import { getGlobalStore as M } from "./store.js";
|
|
6
|
+
import { useInView as Z } from "react-intersection-observer";
|
|
7
|
+
import { v4 as z } from "uuid";
|
|
8
|
+
import { isDeepEqual as V } from "./utility.js";
|
|
9
|
+
import { runValidation as _ } from "./validation.js";
|
|
10
10
|
const {
|
|
11
|
-
getInitialOptions:
|
|
12
|
-
getShadowMetadata:
|
|
13
|
-
setShadowMetadata:
|
|
14
|
-
getShadowValue:
|
|
15
|
-
registerComponent:
|
|
16
|
-
unregisterComponent:
|
|
17
|
-
notifyPathSubscribers:
|
|
18
|
-
subscribeToPath:
|
|
19
|
-
} =
|
|
20
|
-
function
|
|
11
|
+
getInitialOptions: K,
|
|
12
|
+
getShadowMetadata: ft,
|
|
13
|
+
setShadowMetadata: pt,
|
|
14
|
+
getShadowValue: G,
|
|
15
|
+
registerComponent: tt,
|
|
16
|
+
unregisterComponent: et,
|
|
17
|
+
notifyPathSubscribers: St,
|
|
18
|
+
subscribeToPath: nt
|
|
19
|
+
} = M.getState(), { stateHandlers: vt, notifyFormUpdate: U } = C.getState();
|
|
20
|
+
function ot({
|
|
21
21
|
formOpts: e,
|
|
22
22
|
path: t,
|
|
23
23
|
stateKey: o,
|
|
24
|
-
children:
|
|
24
|
+
children: c
|
|
25
25
|
}) {
|
|
26
|
-
const { getInitialOptions:
|
|
27
|
-
...
|
|
26
|
+
const { getInitialOptions: v, getShadowMetadata: b, getShadowValue: r } = M.getState(), s = v(o), y = b(o, t)?.validation, A = y?.status || "NOT_VALIDATED", g = (y?.errors || []).map((p) => ({
|
|
27
|
+
...p,
|
|
28
28
|
path: t
|
|
29
|
-
})),
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
29
|
+
})), l = g.filter((p) => p.severity === "error").map((p) => p.message), i = g.filter((p) => p.severity === "warning").map((p) => p.message), T = l[0] || i[0], f = l.length > 0 ? "error" : i.length > 0 ? "warning" : void 0, { registeredPlugins: a } = C.getState(), h = {};
|
|
30
|
+
return a.forEach((p) => {
|
|
31
|
+
if (s && s.hasOwnProperty(p.name)) {
|
|
32
|
+
const R = p.name, L = C.getState().getHookResult(o, R), W = $(
|
|
33
33
|
o,
|
|
34
|
-
|
|
34
|
+
R,
|
|
35
35
|
t
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
hookData:
|
|
39
|
-
getFieldMetaData:
|
|
40
|
-
setFieldMetaData:
|
|
41
|
-
removeFieldMetaData:
|
|
37
|
+
h[R] = {
|
|
38
|
+
hookData: L,
|
|
39
|
+
getFieldMetaData: W.getFieldMetaData,
|
|
40
|
+
setFieldMetaData: W.setFieldMetaData,
|
|
41
|
+
removeFieldMetaData: W.removeFieldMetaData
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
}), /* @__PURE__ */
|
|
45
|
-
children: /* @__PURE__ */
|
|
46
|
-
status:
|
|
44
|
+
}), /* @__PURE__ */ E(B, { children: s?.formElements?.validation && !e?.validation?.disable ? s.formElements.validation({
|
|
45
|
+
children: /* @__PURE__ */ E(j.Fragment, { children: c }, t.toString()),
|
|
46
|
+
status: A,
|
|
47
47
|
// Now passes the new ValidationStatus type
|
|
48
|
-
message: e?.validation?.hideMessage ? "" : e?.validation?.message ||
|
|
49
|
-
severity:
|
|
50
|
-
hasErrors:
|
|
51
|
-
hasWarnings:
|
|
52
|
-
allErrors:
|
|
48
|
+
message: e?.validation?.hideMessage ? "" : e?.validation?.message || T || "",
|
|
49
|
+
severity: f,
|
|
50
|
+
hasErrors: l.length > 0,
|
|
51
|
+
hasWarnings: i.length > 0,
|
|
52
|
+
allErrors: g,
|
|
53
53
|
path: t,
|
|
54
54
|
getData: () => r(o, t),
|
|
55
|
-
plugins:
|
|
56
|
-
}) : /* @__PURE__ */
|
|
55
|
+
plugins: h
|
|
56
|
+
}) : /* @__PURE__ */ E(j.Fragment, { children: c }, t.toString()) });
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const bt = q(
|
|
59
|
+
rt,
|
|
60
60
|
(e, t) => e.itemPath.join(".") === t.itemPath.join(".") && e.stateKey === t.stateKey && e.itemComponentId === t.itemComponentId && e.localIndex === t.localIndex
|
|
61
61
|
);
|
|
62
|
-
function
|
|
62
|
+
function rt({
|
|
63
63
|
stateKey: e,
|
|
64
64
|
itemComponentId: t,
|
|
65
65
|
itemPath: o,
|
|
66
|
-
localIndex:
|
|
67
|
-
arraySetter:
|
|
68
|
-
rebuildStateShape:
|
|
66
|
+
localIndex: c,
|
|
67
|
+
arraySetter: v,
|
|
68
|
+
rebuildStateShape: b,
|
|
69
69
|
renderFn: r
|
|
70
70
|
}) {
|
|
71
|
-
const [,
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
(
|
|
75
|
-
|
|
71
|
+
const [, s] = F({}), { ref: m, inView: y } = Z(), A = N(null), g = [e, ...o].join(".");
|
|
72
|
+
H(e, t, s);
|
|
73
|
+
const l = O(
|
|
74
|
+
(a) => {
|
|
75
|
+
A.current = a, m(a);
|
|
76
76
|
},
|
|
77
77
|
[m]
|
|
78
78
|
);
|
|
79
79
|
P(() => {
|
|
80
|
-
const
|
|
81
|
-
|
|
80
|
+
const a = nt(g, (h) => {
|
|
81
|
+
s({});
|
|
82
82
|
});
|
|
83
|
-
return () =>
|
|
84
|
-
}, [
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
currentState:
|
|
83
|
+
return () => a();
|
|
84
|
+
}, [g]);
|
|
85
|
+
const i = G(e, o);
|
|
86
|
+
if (i === void 0) return null;
|
|
87
|
+
const T = b({
|
|
88
|
+
currentState: i,
|
|
89
89
|
path: o,
|
|
90
90
|
componentId: t
|
|
91
|
-
}),
|
|
92
|
-
return
|
|
93
|
-
ref: (
|
|
94
|
-
|
|
95
|
-
const { ref:
|
|
96
|
-
typeof
|
|
91
|
+
}), f = r(T, c, v);
|
|
92
|
+
return j.isValidElement(f) ? j.cloneElement(f, {
|
|
93
|
+
ref: (a) => {
|
|
94
|
+
l(a);
|
|
95
|
+
const { ref: h } = f;
|
|
96
|
+
typeof h == "function" ? h(a) : h && "current" in h && (h.current = a);
|
|
97
97
|
}
|
|
98
|
-
}) : /* @__PURE__ */
|
|
98
|
+
}) : /* @__PURE__ */ E("div", { ref: l, children: f });
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function Mt({
|
|
101
101
|
stateKey: e,
|
|
102
102
|
path: t,
|
|
103
103
|
rebuildStateShape: o,
|
|
104
|
-
renderFn:
|
|
105
|
-
formOpts:
|
|
106
|
-
setState:
|
|
104
|
+
renderFn: c,
|
|
105
|
+
formOpts: v,
|
|
106
|
+
setState: b
|
|
107
107
|
}) {
|
|
108
|
-
const r =
|
|
109
|
-
|
|
110
|
-
const
|
|
108
|
+
const r = N(z()).current, [, s] = F({}), m = N(null), y = [e, ...t].join(".");
|
|
109
|
+
H(e, r, s);
|
|
110
|
+
const g = M.getState().getShadowNode(e, t)?._meta?.typeInfo, l = G(e, t), [i, T] = F(l), f = N(!1), a = N(null);
|
|
111
111
|
P(() => {
|
|
112
|
-
!
|
|
113
|
-
}, [
|
|
114
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
112
|
+
!f.current && !V(l, i) && T(l);
|
|
113
|
+
}, [l]), P(() => {
|
|
114
|
+
const { getShadowMetadata: n, setShadowMetadata: d } = M.getState();
|
|
115
115
|
console.log("FormElementWrapper effect running for:", e, t);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
if (
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
129
|
-
if (
|
|
116
|
+
const u = n(e, t) || {};
|
|
117
|
+
u.clientActivityState || (u.clientActivityState = { elements: /* @__PURE__ */ new Map() });
|
|
118
|
+
const w = () => {
|
|
119
|
+
const S = m.current;
|
|
120
|
+
if (!S) return "input";
|
|
121
|
+
const x = S.tagName.toLowerCase();
|
|
122
|
+
if (x === "textarea") return "textarea";
|
|
123
|
+
if (x === "select") return "select";
|
|
124
|
+
if (x === "input") {
|
|
125
|
+
const k = S.type;
|
|
126
|
+
if (k === "checkbox") return "checkbox";
|
|
127
|
+
if (k === "radio") return "radio";
|
|
128
|
+
if (k === "range") return "range";
|
|
129
|
+
if (k === "file") return "file";
|
|
130
130
|
}
|
|
131
131
|
return "input";
|
|
132
132
|
};
|
|
133
|
-
|
|
133
|
+
u.clientActivityState.elements.set(r, {
|
|
134
134
|
domRef: m,
|
|
135
|
-
elementType:
|
|
135
|
+
elementType: w(),
|
|
136
136
|
inputType: m.current?.type,
|
|
137
137
|
mountedAt: Date.now()
|
|
138
|
-
}), console.log("currentMeta",
|
|
139
|
-
const
|
|
140
|
-
!
|
|
138
|
+
}), console.log("currentMeta", u), d(e, t, u);
|
|
139
|
+
const D = M.getState().subscribeToPath(y, (S) => {
|
|
140
|
+
!f.current && i !== S && s({});
|
|
141
141
|
});
|
|
142
142
|
return () => {
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
143
|
+
D(), a.current && (clearTimeout(a.current), f.current = !1);
|
|
144
|
+
const S = M.getState().getShadowMetadata(e, t);
|
|
145
|
+
S?.clientActivityState?.elements && (S.clientActivityState.elements.delete(r), d(e, t, S));
|
|
146
146
|
};
|
|
147
147
|
}, []);
|
|
148
|
-
const
|
|
148
|
+
const h = O(
|
|
149
149
|
(n) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
const d = M.getState().getShadowNode(e, t)?._meta?.typeInfo ?? g;
|
|
151
|
+
d ? d.type === "number" && typeof n == "string" ? n = n === "" ? d.nullable ? null : d.default ?? 0 : Number(n) : d.type === "boolean" && typeof n == "string" ? n = n === "true" || n === "1" : d.type === "date" && typeof n == "string" && (n = new Date(n)) : typeof l === "number" && typeof n == "string" && (n = n === "" ? 0 : Number(n)), T(n);
|
|
152
|
+
const { getShadowMetadata: u, setShadowMetadata: w } = M.getState(), D = u(e, t);
|
|
153
|
+
if (D?.clientActivityState?.elements?.has(r)) {
|
|
154
|
+
const I = D.clientActivityState.elements.get(r);
|
|
155
|
+
I && I.currentActivity?.type === "focus" && (I.currentActivity.details = {
|
|
156
|
+
...I.currentActivity.details,
|
|
156
157
|
value: n,
|
|
157
|
-
previousValue:
|
|
158
|
+
previousValue: I.currentActivity.details?.value || l,
|
|
158
159
|
inputLength: typeof n == "string" ? n.length : void 0,
|
|
159
|
-
keystrokeCount: (
|
|
160
|
-
},
|
|
160
|
+
keystrokeCount: (I.currentActivity.details?.keystrokeCount || 0) + 1
|
|
161
|
+
}, w(e, t, D));
|
|
161
162
|
}
|
|
162
|
-
const
|
|
163
|
-
|
|
163
|
+
const S = D?.clientActivityState?.elements?.get(r);
|
|
164
|
+
U({
|
|
164
165
|
stateKey: e,
|
|
165
166
|
activityType: "input",
|
|
166
167
|
// Changed from 'type'
|
|
@@ -173,45 +174,45 @@ function bt({
|
|
|
173
174
|
// You'd need to track this from the actual input event
|
|
174
175
|
isPasting: !1,
|
|
175
176
|
// You'd need to track this from paste events
|
|
176
|
-
keystrokeCount: (
|
|
177
|
+
keystrokeCount: (S?.currentActivity?.details?.keystrokeCount || 0) + 1
|
|
177
178
|
}
|
|
178
|
-
}),
|
|
179
|
+
}), _({
|
|
179
180
|
stateKey: e,
|
|
180
181
|
path: t,
|
|
181
182
|
newValue: n,
|
|
182
183
|
updateType: "update"
|
|
183
|
-
}, "onChange"),
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
}, "onChange"), f.current = !0, a.current && clearTimeout(a.current);
|
|
185
|
+
const k = v?.debounceTime ?? 200;
|
|
186
|
+
a.current = setTimeout(() => {
|
|
187
|
+
f.current = !1, b(n, t, {
|
|
187
188
|
updateType: "update",
|
|
188
189
|
validationTrigger: "onChange"
|
|
189
190
|
});
|
|
190
|
-
},
|
|
191
|
+
}, k);
|
|
191
192
|
},
|
|
192
193
|
[
|
|
193
|
-
|
|
194
|
+
b,
|
|
194
195
|
t,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
v?.debounceTime,
|
|
197
|
+
g,
|
|
198
|
+
l,
|
|
198
199
|
e,
|
|
199
200
|
r
|
|
200
201
|
]
|
|
201
|
-
),
|
|
202
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
|
|
202
|
+
), p = O(() => {
|
|
203
|
+
const { getShadowMetadata: n, setShadowMetadata: d } = M.getState(), u = n(e, t);
|
|
204
|
+
if (u?.clientActivityState?.elements?.has(r)) {
|
|
205
|
+
const w = u.clientActivityState.elements.get(r);
|
|
206
|
+
w.currentActivity = {
|
|
206
207
|
type: "focus",
|
|
207
208
|
startTime: Date.now(),
|
|
208
209
|
details: {
|
|
209
|
-
value:
|
|
210
|
-
inputLength: typeof
|
|
210
|
+
value: i,
|
|
211
|
+
inputLength: typeof i == "string" ? i.length : void 0
|
|
211
212
|
}
|
|
212
|
-
},
|
|
213
|
+
}, d(e, t, u);
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
+
U({
|
|
215
216
|
stateKey: e,
|
|
216
217
|
activityType: "focus",
|
|
217
218
|
// Changed from 'type'
|
|
@@ -221,131 +222,131 @@ function bt({
|
|
|
221
222
|
cursorPosition: m.current?.selectionStart
|
|
222
223
|
}
|
|
223
224
|
});
|
|
224
|
-
}, [e, t, r,
|
|
225
|
-
const { getShadowMetadata: n, setShadowMetadata:
|
|
226
|
-
|
|
225
|
+
}, [e, t, r, i]), R = O(() => {
|
|
226
|
+
const { getShadowMetadata: n, setShadowMetadata: d } = M.getState();
|
|
227
|
+
a.current && (clearTimeout(a.current), a.current = null, f.current = !1, b(i, t, {
|
|
227
228
|
updateType: "update",
|
|
228
229
|
validationTrigger: "onBlur"
|
|
229
230
|
}));
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
const
|
|
233
|
-
|
|
231
|
+
const u = n(e, t);
|
|
232
|
+
if (u?.clientActivityState?.elements?.has(r)) {
|
|
233
|
+
const S = u.clientActivityState.elements.get(r);
|
|
234
|
+
S.currentActivity = void 0, d(e, t, u);
|
|
234
235
|
}
|
|
235
|
-
const
|
|
236
|
-
|
|
236
|
+
const w = u?.clientActivityState?.elements?.get(r)?.currentActivity?.startTime;
|
|
237
|
+
U({
|
|
237
238
|
stateKey: e,
|
|
238
239
|
activityType: "blur",
|
|
239
240
|
// Changed from 'type'
|
|
240
241
|
path: t,
|
|
241
242
|
timestamp: Date.now(),
|
|
242
|
-
duration:
|
|
243
|
+
duration: w ? Date.now() - w : void 0,
|
|
243
244
|
details: {
|
|
244
|
-
duration:
|
|
245
|
+
duration: w ? Date.now() - w : 0
|
|
245
246
|
}
|
|
246
|
-
}),
|
|
247
|
+
}), K(e)?.validation?.onBlur && _({
|
|
247
248
|
stateKey: e,
|
|
248
249
|
path: t,
|
|
249
|
-
newValue:
|
|
250
|
+
newValue: i,
|
|
250
251
|
updateType: "update"
|
|
251
252
|
}, "onBlur");
|
|
252
|
-
}, [
|
|
253
|
+
}, [i, b, t, e, r, l]), L = o({
|
|
253
254
|
path: t,
|
|
254
255
|
componentId: r,
|
|
255
256
|
meta: void 0
|
|
256
|
-
}),
|
|
257
|
-
get(n,
|
|
258
|
-
return
|
|
259
|
-
value:
|
|
260
|
-
onChange: (
|
|
261
|
-
|
|
257
|
+
}), W = new Proxy(L, {
|
|
258
|
+
get(n, d) {
|
|
259
|
+
return d === "$inputProps" ? {
|
|
260
|
+
value: i ?? "",
|
|
261
|
+
onChange: (u) => {
|
|
262
|
+
h(u.target.value);
|
|
262
263
|
},
|
|
263
|
-
onFocus:
|
|
264
|
-
onBlur:
|
|
264
|
+
onFocus: p,
|
|
265
|
+
onBlur: R,
|
|
265
266
|
ref: m
|
|
266
|
-
} : n[
|
|
267
|
+
} : n[d];
|
|
267
268
|
}
|
|
268
|
-
}),
|
|
269
|
-
return /* @__PURE__ */
|
|
269
|
+
}), J = c(W);
|
|
270
|
+
return /* @__PURE__ */ E(ot, { formOpts: v, path: t, stateKey: e, children: J });
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
-
const
|
|
273
|
-
|
|
272
|
+
function H(e, t, o) {
|
|
273
|
+
const c = `${e}////${t}`;
|
|
274
|
+
X(() => (tt(e, c, {
|
|
274
275
|
forceUpdate: () => o({}),
|
|
275
276
|
paths: /* @__PURE__ */ new Set(),
|
|
276
277
|
reactiveType: ["component"]
|
|
277
278
|
}), () => {
|
|
278
|
-
|
|
279
|
-
}), [e,
|
|
279
|
+
et(e, c);
|
|
280
|
+
}), [e, c]);
|
|
280
281
|
}
|
|
281
|
-
function
|
|
282
|
+
function yt({
|
|
282
283
|
stateKey: e,
|
|
283
284
|
path: t,
|
|
284
285
|
// The path of the parent node (e.g. ['form'])
|
|
285
286
|
dependencies: o,
|
|
286
287
|
// NEW: Optional array of Proxy objects or path arrays
|
|
287
|
-
rebuildStateShape:
|
|
288
|
-
renderFn:
|
|
288
|
+
rebuildStateShape: c,
|
|
289
|
+
renderFn: v
|
|
289
290
|
}) {
|
|
290
|
-
const [
|
|
291
|
-
|
|
292
|
-
const
|
|
291
|
+
const [b] = F(() => z()), [, r] = F({});
|
|
292
|
+
H(e, b, r);
|
|
293
|
+
const s = Y(() => o && o.length > 0 ? o.map((y) => [e, ...y.$_path].join(".")) : [[e, ...t].join(".")], [e, t, o]);
|
|
293
294
|
P(() => {
|
|
294
|
-
const y =
|
|
295
|
+
const y = M.getState(), A = s.map((g) => y.subscribeToPath(g, () => {
|
|
295
296
|
r({});
|
|
296
297
|
}));
|
|
297
298
|
return () => {
|
|
298
|
-
|
|
299
|
+
A.forEach((g) => g());
|
|
299
300
|
};
|
|
300
|
-
}, [
|
|
301
|
-
const m =
|
|
301
|
+
}, [s]);
|
|
302
|
+
const m = c({
|
|
302
303
|
path: t,
|
|
303
|
-
componentId:
|
|
304
|
+
componentId: b,
|
|
304
305
|
meta: void 0
|
|
305
306
|
});
|
|
306
|
-
return /* @__PURE__ */
|
|
307
|
+
return /* @__PURE__ */ E(B, { children: v(m) });
|
|
307
308
|
}
|
|
308
|
-
|
|
309
|
+
q(function({
|
|
309
310
|
children: t,
|
|
310
311
|
stateKey: o,
|
|
311
|
-
path:
|
|
312
|
-
pluginName:
|
|
313
|
-
wrapperDepth:
|
|
312
|
+
path: c,
|
|
313
|
+
pluginName: v,
|
|
314
|
+
wrapperDepth: b
|
|
314
315
|
}) {
|
|
315
|
-
const [, r] =
|
|
316
|
+
const [, r] = F({});
|
|
316
317
|
P(() => {
|
|
317
|
-
const
|
|
318
|
-
return
|
|
318
|
+
const T = [o, ...c].join(".");
|
|
319
|
+
return M.getState().subscribeToPath(T, () => {
|
|
319
320
|
r({});
|
|
320
321
|
});
|
|
321
|
-
}, [o,
|
|
322
|
-
const
|
|
323
|
-
if (!
|
|
324
|
-
return /* @__PURE__ */
|
|
325
|
-
const
|
|
322
|
+
}, [o, c]);
|
|
323
|
+
const s = C.getState().registeredPlugins.find((T) => T.name === v), m = C.getState().stateHandlers.get(o), y = M.getState().getShadowNode(o, c)?._meta?.typeInfo, A = C.getState().pluginOptions.get(o)?.get(v), g = C.getState().getHookResult(o, v);
|
|
324
|
+
if (!s?.formWrapper || !m)
|
|
325
|
+
return /* @__PURE__ */ E(B, { children: t });
|
|
326
|
+
const l = Q(m), i = $(
|
|
326
327
|
o,
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
s.name,
|
|
329
|
+
c
|
|
329
330
|
);
|
|
330
|
-
return
|
|
331
|
+
return s.formWrapper({
|
|
331
332
|
element: t,
|
|
332
|
-
path:
|
|
333
|
+
path: c,
|
|
333
334
|
stateKey: o,
|
|
334
|
-
pluginName:
|
|
335
|
-
...
|
|
336
|
-
...
|
|
337
|
-
options:
|
|
338
|
-
hookData:
|
|
335
|
+
pluginName: s.name,
|
|
336
|
+
...l,
|
|
337
|
+
...i,
|
|
338
|
+
options: A,
|
|
339
|
+
hookData: g,
|
|
339
340
|
fieldType: y?.type,
|
|
340
|
-
wrapperDepth:
|
|
341
|
+
wrapperDepth: b
|
|
341
342
|
});
|
|
342
343
|
});
|
|
343
344
|
export {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
345
|
+
Mt as FormElementWrapper,
|
|
346
|
+
yt as IsolatedComponentWrapper,
|
|
347
|
+
rt as ListItemWrapper,
|
|
348
|
+
bt as MemoizedCogsItemWrapper,
|
|
349
|
+
ot as ValidationWrapper,
|
|
350
|
+
H as useRegisterComponent
|
|
350
351
|
};
|
|
351
352
|
//# sourceMappingURL=Components.js.map
|