cogsbox-state 0.5.465 → 0.5.467
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 +3 -3
- package/dist/CogsState.d.ts +1 -0
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +1008 -1273
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.d.ts +39 -0
- package/dist/Components.d.ts.map +1 -0
- package/dist/Components.jsx +281 -0
- package/dist/Components.jsx.map +1 -0
- package/dist/index.js +11 -12
- package/dist/store.d.ts +2 -6
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +274 -236
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +144 -709
- package/src/Components.tsx +541 -0
- package/src/store.ts +293 -221
- package/dist/Functions.d.ts +0 -11
- package/dist/Functions.d.ts.map +0 -1
- package/dist/Functions.jsx +0 -29
- package/dist/Functions.jsx.map +0 -1
- package/src/Functions.tsx +0 -66
package/dist/Functions.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FormOptsType } from './CogsState';
|
|
2
|
-
import { default as React } from 'react';
|
|
3
|
-
|
|
4
|
-
export type ValidationWrapperProps = {
|
|
5
|
-
formOpts?: FormOptsType;
|
|
6
|
-
path: string[];
|
|
7
|
-
stateKey: string;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
};
|
|
10
|
-
export declare function ValidationWrapper({ formOpts, path, stateKey, children, }: ValidationWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
//# sourceMappingURL=Functions.d.ts.map
|
package/dist/Functions.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../src/Functions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,sBAAsB,2CAgDxB"}
|
package/dist/Functions.jsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { jsx as o, Fragment as w } from "react/jsx-runtime";
|
|
2
|
-
import d from "react";
|
|
3
|
-
import { getGlobalStore as M } from "./store.js";
|
|
4
|
-
function F({
|
|
5
|
-
formOpts: a,
|
|
6
|
-
path: e,
|
|
7
|
-
stateKey: s,
|
|
8
|
-
children: n
|
|
9
|
-
}) {
|
|
10
|
-
const { getInitialOptions: c, getShadowMetadata: v, getShadowValue: S } = M.getState(), i = c(s), g = v(s, e)?.validation, f = g?.status || "NOT_VALIDATED", r = (g?.errors || []).map((t) => ({
|
|
11
|
-
...t,
|
|
12
|
-
path: e
|
|
13
|
-
})), l = r.filter((t) => t.severity === "error").map((t) => t.message), m = r.filter((t) => t.severity === "warning").map((t) => t.message), h = l[0] || m[0];
|
|
14
|
-
return /* @__PURE__ */ o(w, { children: i?.formElements?.validation && !a?.validation?.disable ? i.formElements.validation({
|
|
15
|
-
children: /* @__PURE__ */ o(d.Fragment, { children: n }, e.toString()),
|
|
16
|
-
status: f,
|
|
17
|
-
// Now passes the new ValidationStatus type
|
|
18
|
-
message: a?.validation?.hideMessage ? "" : a?.validation?.message || h || "",
|
|
19
|
-
hasErrors: l.length > 0,
|
|
20
|
-
hasWarnings: m.length > 0,
|
|
21
|
-
allErrors: r,
|
|
22
|
-
path: e,
|
|
23
|
-
getData: () => S(s, e)
|
|
24
|
-
}) : /* @__PURE__ */ o(d.Fragment, { children: n }, e.toString()) });
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
F as ValidationWrapper
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=Functions.jsx.map
|
package/dist/Functions.jsx.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Functions.jsx","sources":["../src/Functions.tsx"],"sourcesContent":["import { type FormOptsType } from './CogsState';\r\nimport React from 'react';\r\nimport { getGlobalStore, ValidationError } from './store';\r\nimport { get } from 'http';\r\n\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\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\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\n"],"names":["ValidationWrapper","formOpts","path","stateKey","children","getInitialOptions","getShadowMetadata","getShadowValue","getGlobalStore","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","jsx","Fragment","React"],"mappings":";;;AAYO,SAASA,EAAkB;AAAA,EAChC,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAM,EAAE,mBAAAC,GAAmB,mBAAAC,GAAmB,gBAAAC,EAAA,IAC5CC,EAAe,SAAA,GACXC,IAAgBJ,EAAkBF,CAAS,GAG3CO,IADaJ,EAAkBH,GAAWD,CAAI,GAChB,YAE9BS,IAASD,GAAiB,UAAU,iBAEpCE,KAAUF,GAAiB,UAAU,CAAA,GAAI,IAAI,CAACG,OAAS;AAAA,IAC3D,GAAGA;AAAA,IACH,MAAAX;AAAA,EAAA,EACA,GACIY,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,MAAQA,EAAI,OAAO,GAGrBG,IAAUF,EAAc,CAAC,KAAKC,EAAgB,CAAC;AAErD,SACE,gBAAAE,EAAAC,GAAA,EACG,UAAAT,GAAe,cAAc,cAC9B,CAACR,GAAU,YAAY,UACrBQ,EAAc,aAAc,WAAY;AAAA,IACtC,4BACGU,EAAM,UAAN,EAAsC,UAAAf,KAAlBF,EAAK,UAAsB;AAAA,IAElD,QAAAS;AAAA;AAAA,IACA,SAASV,GAAU,YAAY,cAC3B,KACAA,GAAU,YAAY,WAAWe,KAAW;AAAA,IAEhD,WAAWF,EAAc,SAAS;AAAA,IAClC,aAAaC,EAAgB,SAAS;AAAA,IACtC,WAAWH;AAAA,IACX,MAAAV;AAAA,IACA,SAAS,MAAMK,EAAeJ,GAAWD,CAAI;AAAA,EAAA,CAC9C,IAED,gBAAAe,EAACE,EAAM,UAAN,EAAsC,UAAAf,EAAA,GAAlBF,EAAK,SAAA,CAAsB,GAEpD;AAEJ;"}
|
package/src/Functions.tsx
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { type FormOptsType } from './CogsState';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { getGlobalStore, ValidationError } from './store';
|
|
4
|
-
import { get } from 'http';
|
|
5
|
-
|
|
6
|
-
export type ValidationWrapperProps = {
|
|
7
|
-
formOpts?: FormOptsType;
|
|
8
|
-
path: string[];
|
|
9
|
-
stateKey: string;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function ValidationWrapper({
|
|
14
|
-
formOpts,
|
|
15
|
-
path,
|
|
16
|
-
stateKey,
|
|
17
|
-
children,
|
|
18
|
-
}: ValidationWrapperProps) {
|
|
19
|
-
const { getInitialOptions, getShadowMetadata, getShadowValue } =
|
|
20
|
-
getGlobalStore.getState();
|
|
21
|
-
const thisStateOpts = getInitialOptions(stateKey!);
|
|
22
|
-
|
|
23
|
-
const shadowMeta = getShadowMetadata(stateKey!, path);
|
|
24
|
-
const validationState = shadowMeta?.validation;
|
|
25
|
-
|
|
26
|
-
const status = validationState?.status || 'NOT_VALIDATED';
|
|
27
|
-
|
|
28
|
-
const errors = (validationState?.errors || []).map((err) => ({
|
|
29
|
-
...err,
|
|
30
|
-
path: path,
|
|
31
|
-
})) as ValidationError[];
|
|
32
|
-
const errorMessages = errors
|
|
33
|
-
.filter((err) => err.severity === 'error')
|
|
34
|
-
.map((err) => err.message);
|
|
35
|
-
const warningMessages = errors
|
|
36
|
-
.filter((err) => err.severity === 'warning')
|
|
37
|
-
.map((err) => err.message);
|
|
38
|
-
|
|
39
|
-
// Use first error, or first warning if no errors
|
|
40
|
-
const message = errorMessages[0] || warningMessages[0];
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<>
|
|
44
|
-
{thisStateOpts?.formElements?.validation &&
|
|
45
|
-
!formOpts?.validation?.disable ? (
|
|
46
|
-
thisStateOpts.formElements!.validation!({
|
|
47
|
-
children: (
|
|
48
|
-
<React.Fragment key={path.toString()}>{children}</React.Fragment>
|
|
49
|
-
),
|
|
50
|
-
status, // Now passes the new ValidationStatus type
|
|
51
|
-
message: formOpts?.validation?.hideMessage
|
|
52
|
-
? ''
|
|
53
|
-
: formOpts?.validation?.message || message || '',
|
|
54
|
-
|
|
55
|
-
hasErrors: errorMessages.length > 0,
|
|
56
|
-
hasWarnings: warningMessages.length > 0,
|
|
57
|
-
allErrors: errors,
|
|
58
|
-
path: path,
|
|
59
|
-
getData: () => getShadowValue(stateKey!, path),
|
|
60
|
-
})
|
|
61
|
-
) : (
|
|
62
|
-
<React.Fragment key={path.toString()}>{children}</React.Fragment>
|
|
63
|
-
)}
|
|
64
|
-
</>
|
|
65
|
-
);
|
|
66
|
-
}
|