@optiaxiom/proteus 0.3.0 → 1.1.0
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/esm/_virtual/_openai-shim-script.js +3 -2
- package/dist/esm/assets/src/proteus-chart/{ProteusChart.css.ts.vanilla-DNE5j3uT.css → ProteusChart.css.ts.vanilla-yGx8JdKz.css} +2 -2
- package/dist/esm/assets/src/proteus-chart/{ProteusChartTooltipContent.css.ts.vanilla-DM8u1icS.css → ProteusChartTooltipContent.css.ts.vanilla-HapBe2oo.css} +2 -2
- package/dist/esm/assets/src/proteus-document/{ProteusDocumentShell.css.ts.vanilla-DjZJuQ2A.css → ProteusDocumentShell.css.ts.vanilla-BPytQ9pT.css} +2 -2
- package/dist/esm/assets/src/proteus-image-carousel/{ProteusImageCarousel.css.ts.vanilla-CIwMJ4Cg.css → ProteusImageCarousel.css.ts.vanilla-DnlXoyv1.css} +2 -2
- package/dist/esm/assets/src/proteus-question/{ProteusQuestion.css.ts.vanilla-DiCe_bxf.css → ProteusQuestion.css.ts.vanilla-CpDgoW0l.css} +2 -2
- package/dist/esm/hooks/useEffectEvent.js +11 -10
- package/dist/esm/hooks/useObserveValue.js +24 -30
- package/dist/esm/icons/IconAngleLeft.js +13 -19
- package/dist/esm/icons/IconAngleRight.js +13 -19
- package/dist/esm/icons/IconX.js +10 -18
- package/dist/esm/icons/withIcon.js +17 -28
- package/dist/esm/index.js +22 -17
- package/dist/esm/proteus-action/ProteusAction.js +44 -39
- package/dist/esm/proteus-bridge/ProteusBridge.js +71 -85
- package/dist/esm/proteus-card-link/ProteusCardLink.js +24 -37
- package/dist/esm/proteus-chart/ProteusChart-css.js +14 -5
- package/dist/esm/proteus-chart/ProteusChart.js +86 -84
- package/dist/esm/proteus-chart/ProteusChartContext.js +3 -3
- package/dist/esm/proteus-chart/ProteusChartTooltipContent-css.js +23 -6
- package/dist/esm/proteus-chart/ProteusChartTooltipContent.js +52 -66
- package/dist/esm/proteus-data-table/ProteusDataTable.js +28 -29
- package/dist/esm/proteus-date-input/ProteusDateInput.js +23 -0
- package/dist/esm/proteus-document/ProteusDocumentContext.js +4 -3
- package/dist/esm/proteus-document/ProteusDocumentPathContext.js +6 -5
- package/dist/esm/proteus-document/ProteusDocumentRenderer.js +25 -33
- package/dist/esm/proteus-document/ProteusDocumentShell-css.js +32 -6
- package/dist/esm/proteus-document/ProteusDocumentShell.js +226 -219
- package/dist/esm/proteus-document/getProteusValue.js +28 -42
- package/dist/esm/proteus-document/resolveProteusProp.js +31 -49
- package/dist/esm/proteus-document/resolveProteusValue.js +73 -136
- package/dist/esm/proteus-document/schemas.js +42 -45
- package/dist/esm/proteus-document/useResolveProteusValues.js +10 -16
- package/dist/esm/proteus-element/ProteusElement.js +114 -180
- package/dist/esm/proteus-federated/ProteusFederated.js +51 -52
- package/dist/esm/proteus-file-icon/ProteusFileIcon.js +29 -38
- package/dist/esm/proteus-file-upload/ProteusFileUpload.js +107 -133
- package/dist/esm/proteus-image/ProteusImage.js +99 -106
- package/dist/esm/proteus-image/downloadFile.js +3 -2
- package/dist/esm/proteus-image-carousel/ProteusImageCarousel-css.js +49 -11
- package/dist/esm/proteus-image-carousel/ProteusImageCarousel.js +151 -163
- package/dist/esm/proteus-input/ProteusInput.js +19 -27
- package/dist/esm/proteus-length/ProteusLength.js +10 -0
- package/dist/esm/proteus-map/ProteusMap.js +18 -31
- package/dist/esm/proteus-map-index/ProteusMapIndex.js +11 -0
- package/dist/esm/proteus-pill-menu/ProteusPillMenu.js +65 -0
- package/dist/esm/proteus-pill-menu/useInputValueChangeInteraction.js +36 -0
- package/dist/esm/proteus-question/ProteusQuestion-css.js +40 -8
- package/dist/esm/proteus-question/ProteusQuestion.js +324 -400
- package/dist/esm/proteus-select/ProteusSelect.js +25 -40
- package/dist/esm/proteus-show/ProteusShow.js +10 -18
- package/dist/esm/proteus-switch/ProteusSwitch.js +33 -36
- package/dist/esm/proteus-textarea/ProteusTextarea.js +18 -27
- package/dist/esm/proteus-value/ProteusValue.js +4 -4
- package/dist/esm/schema/public-schema.js +4537 -0
- package/dist/esm/schema/runtime-schema.js +4460 -0
- package/dist/esm/spec.js +5 -1
- package/dist/esm/use-proteus-value/useProteusValue.js +8 -12
- package/dist/index.d.ts +516 -347
- package/dist/spec.d.ts +5 -9952
- package/package.json +5 -5
- package/dist/esm/icons/IconCalendar.js +0 -20
- package/dist/esm/schema/public-schema.json.js +0 -9041
- package/dist/esm/schema/runtime-schema.json.js +0 -8974
|
@@ -1,142 +1,79 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getProteusValue } from
|
|
3
|
-
|
|
2
|
+
import { getProteusValue } from "./getProteusValue.js";
|
|
3
|
+
//#region src/proteus-document/resolveProteusValue.tsx
|
|
4
4
|
function evaluateCondition(condition, data, parentPath, mapIndices = []) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return resolveProteusValue(left, data, parentPath, mapIndices) === resolveProteusValue(right, data, parentPath, mapIndices);
|
|
39
|
-
} else if ("!=" in condition) {
|
|
40
|
-
const [left, right] = condition["!="];
|
|
41
|
-
return resolveProteusValue(left, data, parentPath, mapIndices) !== resolveProteusValue(right, data, parentPath, mapIndices);
|
|
42
|
-
} else if ("<" in condition) {
|
|
43
|
-
const [left, right] = condition["<"];
|
|
44
|
-
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
45
|
-
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
46
|
-
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal < rightVal;
|
|
47
|
-
} else if ("<=" in condition) {
|
|
48
|
-
const [left, right] = condition["<="];
|
|
49
|
-
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
50
|
-
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
51
|
-
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal <= rightVal;
|
|
52
|
-
} else if (">" in condition) {
|
|
53
|
-
const [left, right] = condition[">"];
|
|
54
|
-
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
55
|
-
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
56
|
-
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal > rightVal;
|
|
57
|
-
} else if (">=" in condition) {
|
|
58
|
-
const [left, right] = condition[">="];
|
|
59
|
-
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
60
|
-
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
61
|
-
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal >= rightVal;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
5
|
+
if (!condition) return true;
|
|
6
|
+
if ("and" in condition) return condition.and.every((cond) => evaluateCondition(cond, data, parentPath, mapIndices));
|
|
7
|
+
if ("or" in condition) return condition.or.some((cond) => evaluateCondition(cond, data, parentPath, mapIndices));
|
|
8
|
+
if ("!!" in condition) return !!resolveProteusValue(condition["!!"], data, parentPath, mapIndices);
|
|
9
|
+
if ("!" in condition) return !resolveProteusValue(condition["!"], data, parentPath, mapIndices);
|
|
10
|
+
if ("==" in condition) {
|
|
11
|
+
const [left, right] = condition["=="];
|
|
12
|
+
return resolveProteusValue(left, data, parentPath, mapIndices) === resolveProteusValue(right, data, parentPath, mapIndices);
|
|
13
|
+
} else if ("!=" in condition) {
|
|
14
|
+
const [left, right] = condition["!="];
|
|
15
|
+
return resolveProteusValue(left, data, parentPath, mapIndices) !== resolveProteusValue(right, data, parentPath, mapIndices);
|
|
16
|
+
} else if ("<" in condition) {
|
|
17
|
+
const [left, right] = condition["<"];
|
|
18
|
+
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
19
|
+
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
20
|
+
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal < rightVal;
|
|
21
|
+
} else if ("<=" in condition) {
|
|
22
|
+
const [left, right] = condition["<="];
|
|
23
|
+
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
24
|
+
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
25
|
+
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal <= rightVal;
|
|
26
|
+
} else if (">" in condition) {
|
|
27
|
+
const [left, right] = condition[">"];
|
|
28
|
+
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
29
|
+
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
30
|
+
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal > rightVal;
|
|
31
|
+
} else if (">=" in condition) {
|
|
32
|
+
const [left, right] = condition[">="];
|
|
33
|
+
const leftVal = resolveProteusValue(left, data, parentPath, mapIndices);
|
|
34
|
+
const rightVal = resolveProteusValue(right, data, parentPath, mapIndices);
|
|
35
|
+
return typeof leftVal === "number" && typeof rightVal === "number" && leftVal >= rightVal;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
64
38
|
}
|
|
65
39
|
function resolveProteusValue(value, data, parentPath, mapIndices = []) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
parentPath,
|
|
104
|
-
mapIndices
|
|
105
|
-
);
|
|
106
|
-
return result.join(typeof sep === "string" ? sep : "");
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
if (value.$type === "Show" && "when" in value && "children" in value) {
|
|
111
|
-
const conditions = Array.isArray(value.when) ? value.when : [value.when];
|
|
112
|
-
const shouldShow = conditions.every(
|
|
113
|
-
(condition) => evaluateCondition(condition, data, parentPath, mapIndices)
|
|
114
|
-
);
|
|
115
|
-
if (!shouldShow) {
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
|
-
return resolveProteusValue(value.children, data, parentPath, mapIndices);
|
|
119
|
-
}
|
|
120
|
-
if (value.$type === "Concat" && "children" in value) {
|
|
121
|
-
if (!Array.isArray(value.children)) {
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
|
-
return value.children.map(
|
|
125
|
-
(child) => resolveProteusValue(child, data, parentPath, mapIndices)
|
|
126
|
-
).filter((v) => v !== void 0).join("");
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
|
-
if (Array.isArray(value)) {
|
|
131
|
-
return value.map((v) => resolveProteusValue(v, data, parentPath, mapIndices)).filter((v) => v !== void 0);
|
|
132
|
-
}
|
|
133
|
-
const resolved = {};
|
|
134
|
-
for (const [k, v] of Object.entries(value)) {
|
|
135
|
-
const r = resolveProteusValue(v, data, parentPath, mapIndices);
|
|
136
|
-
if (r !== void 0)
|
|
137
|
-
resolved[k] = r;
|
|
138
|
-
}
|
|
139
|
-
return resolved;
|
|
40
|
+
if (typeof value !== "object" || value === null) return value;
|
|
41
|
+
if ("$type" in value) {
|
|
42
|
+
if (value.$type === "MapIndex") return mapIndices.at(-1);
|
|
43
|
+
if (value.$type === "Value" && "path" in value && typeof value.path === "string") return getProteusValue(data, value, parentPath);
|
|
44
|
+
if (value.$type === "Length" && "path" in value && typeof value.path === "string") {
|
|
45
|
+
const arr = getProteusValue(data, { path: value.path }, parentPath);
|
|
46
|
+
return Array.isArray(arr) ? arr.length : 0;
|
|
47
|
+
}
|
|
48
|
+
if (value.$type === "Map" && "path" in value && typeof value.path === "string" && "children" in value) {
|
|
49
|
+
const array = getProteusValue(data, { path: value.path }, parentPath);
|
|
50
|
+
if (!Array.isArray(array)) return value;
|
|
51
|
+
const resolvedPath = value.path.startsWith("/") ? value.path : `${parentPath}/${value.path}`;
|
|
52
|
+
const items = array.map((_, index) => resolveProteusValue(value.children, data, `${resolvedPath}/${index}`, [...mapIndices, index])).filter((v) => v !== void 0);
|
|
53
|
+
const result = "flat" in value && value.flat ? items.flat() : items;
|
|
54
|
+
if ("separator" in value) {
|
|
55
|
+
const sep = resolveProteusValue(value.separator, data, parentPath, mapIndices);
|
|
56
|
+
return result.join(typeof sep === "string" ? sep : "");
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
if (value.$type === "Show" && "when" in value && "children" in value) {
|
|
61
|
+
if (!(Array.isArray(value.when) ? value.when : [value.when]).every((condition) => evaluateCondition(condition, data, parentPath, mapIndices))) return;
|
|
62
|
+
return resolveProteusValue(value.children, data, parentPath, mapIndices);
|
|
63
|
+
}
|
|
64
|
+
if (value.$type === "Concat" && "children" in value) {
|
|
65
|
+
if (!Array.isArray(value.children)) return value;
|
|
66
|
+
return value.children.map((child) => resolveProteusValue(child, data, parentPath, mapIndices)).filter((v) => v !== void 0).join("");
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(value)) return value.map((v) => resolveProteusValue(v, data, parentPath, mapIndices)).filter((v) => v !== void 0);
|
|
71
|
+
const resolved = {};
|
|
72
|
+
for (const [k, v] of Object.entries(value)) {
|
|
73
|
+
const r = resolveProteusValue(v, data, parentPath, mapIndices);
|
|
74
|
+
if (r !== void 0) resolved[k] = r;
|
|
75
|
+
}
|
|
76
|
+
return resolved;
|
|
140
77
|
}
|
|
141
|
-
|
|
78
|
+
//#endregion
|
|
142
79
|
export { evaluateCondition, resolveProteusValue };
|
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const documentValidator = new Validator(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
success: true
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return { error: result.errors.map(({ error }) => error), success: false };
|
|
1
|
+
import { definitions } from "../schema/runtime-schema.js";
|
|
2
|
+
import { Validator } from "@cfworker/json-schema";
|
|
3
|
+
//#region src/proteus-document/schemas.ts
|
|
4
|
+
const documentValidator = new Validator({
|
|
5
|
+
$ref: "#/definitions/ProteusDocument",
|
|
6
|
+
definitions
|
|
7
|
+
}, "7");
|
|
8
|
+
const elementValidator = new Validator({
|
|
9
|
+
$ref: "#/definitions/ProteusNode",
|
|
10
|
+
definitions
|
|
11
|
+
}, "7");
|
|
12
|
+
function safeParseDocument({ actions, body, ...data }) {
|
|
13
|
+
const result = documentValidator.validate({
|
|
14
|
+
body: [],
|
|
15
|
+
...data
|
|
16
|
+
});
|
|
17
|
+
if (result.valid) return {
|
|
18
|
+
data: {
|
|
19
|
+
actions,
|
|
20
|
+
body,
|
|
21
|
+
...data
|
|
22
|
+
},
|
|
23
|
+
success: true
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
error: result.errors.map(({ error }) => error),
|
|
27
|
+
success: false
|
|
28
|
+
};
|
|
33
29
|
}
|
|
34
|
-
function safeParseElement({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
function safeParseElement({ children, ...data }) {
|
|
31
|
+
const result = elementValidator.validate(data);
|
|
32
|
+
if (result.valid) return {
|
|
33
|
+
data: {
|
|
34
|
+
children,
|
|
35
|
+
...data
|
|
36
|
+
},
|
|
37
|
+
success: true
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
error: result.errors.map(({ error }) => error),
|
|
41
|
+
success: false
|
|
42
|
+
};
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
//#endregion
|
|
48
45
|
export { safeParseDocument, safeParseElement };
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { useProteusDocumentContext } from
|
|
2
|
-
import { useProteusDocumentPathContext } from
|
|
3
|
-
import { resolveProteusValue } from
|
|
4
|
-
|
|
1
|
+
import { useProteusDocumentContext } from "./ProteusDocumentContext.js";
|
|
2
|
+
import { useProteusDocumentPathContext } from "./ProteusDocumentPathContext.js";
|
|
3
|
+
import { resolveProteusValue } from "./resolveProteusValue.js";
|
|
4
|
+
//#region src/proteus-document/useResolveProteusValues.ts
|
|
5
5
|
function useResolveProteusValues(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
-
const resolved = {};
|
|
13
|
-
for (const [key, value] of Object.entries(props)) {
|
|
14
|
-
resolved[key] = resolveProteusValue(value, data, parentPath, mapIndices);
|
|
15
|
-
}
|
|
16
|
-
return resolved;
|
|
6
|
+
const { data } = useProteusDocumentContext("@optiaxiom/react/useResolveProteusValues");
|
|
7
|
+
const { mapIndices, path: parentPath } = useProteusDocumentPathContext("@optiaxiom/react/useResolveProteusValues");
|
|
8
|
+
const resolved = {};
|
|
9
|
+
for (const [key, value] of Object.entries(props)) resolved[key] = resolveProteusValue(value, data, parentPath, mapIndices);
|
|
10
|
+
return resolved;
|
|
17
11
|
}
|
|
18
|
-
|
|
12
|
+
//#endregion
|
|
19
13
|
export { useResolveProteusValues };
|