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