@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,167 +1,155 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
function ProteusImageCarousel({
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
Button,
|
|
153
|
-
{
|
|
154
|
-
appearance: "primary",
|
|
155
|
-
ml: "auto",
|
|
156
|
-
onClick: () => onEvent({ action: "download", url: images[0].src }),
|
|
157
|
-
children: "Download"
|
|
158
|
-
}
|
|
159
|
-
)
|
|
160
|
-
] })
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
);
|
|
2
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
3
|
+
import { IconAngleLeft } from "../icons/IconAngleLeft.js";
|
|
4
|
+
import { IconAngleRight } from "../icons/IconAngleRight.js";
|
|
5
|
+
import { ProteusImage } from "../proteus-image/ProteusImage.js";
|
|
6
|
+
import { carousel, content, navButton, slide, slideContainer, thumbnail, viewport } from "./ProteusImageCarousel-css.js";
|
|
7
|
+
import { Box, Button, Group, Menu, MenuContent, MenuTrigger, Text } from "@optiaxiom/react";
|
|
8
|
+
import { useCallback, useEffect, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
11
|
+
//#region src/proteus-image-carousel/ProteusImageCarousel.tsx
|
|
12
|
+
function ProteusImageCarousel({ images, title }) {
|
|
13
|
+
const { onEvent } = useProteusDocumentContext("@optiaxiom/proteus/ProteusImageCarousel");
|
|
14
|
+
const [emblaMainRef, emblaMainApi] = useEmblaCarousel({
|
|
15
|
+
loop: false,
|
|
16
|
+
watchDrag: false
|
|
17
|
+
});
|
|
18
|
+
const [emblaThumbsRef, emblaThumbsApi] = useEmblaCarousel({
|
|
19
|
+
containScroll: "keepSnaps",
|
|
20
|
+
dragFree: true
|
|
21
|
+
});
|
|
22
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
23
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
24
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
25
|
+
const onSelect = useCallback(() => {
|
|
26
|
+
if (!emblaMainApi || !emblaThumbsApi) return;
|
|
27
|
+
setSelectedIndex(emblaMainApi.selectedScrollSnap());
|
|
28
|
+
emblaThumbsApi.scrollTo(emblaMainApi.selectedScrollSnap());
|
|
29
|
+
setCanScrollPrev(emblaMainApi.canScrollPrev());
|
|
30
|
+
setCanScrollNext(emblaMainApi.canScrollNext());
|
|
31
|
+
}, [emblaMainApi, emblaThumbsApi]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!emblaMainApi) return;
|
|
34
|
+
onSelect();
|
|
35
|
+
emblaMainApi.on("select", onSelect).on("reInit", onSelect);
|
|
36
|
+
}, [emblaMainApi, onSelect]);
|
|
37
|
+
if (!images.length) return null;
|
|
38
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
39
|
+
"aria-label": title ?? "Image carousel",
|
|
40
|
+
"aria-roledescription": "carousel",
|
|
41
|
+
onKeyDownCapture: (event) => {
|
|
42
|
+
if (event.target instanceof HTMLInputElement) return;
|
|
43
|
+
if (event.key === "ArrowLeft") {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
emblaMainApi?.scrollPrev();
|
|
46
|
+
} else if (event.key === "ArrowRight") {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
emblaMainApi?.scrollNext();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
role: "region",
|
|
52
|
+
tabIndex: 0,
|
|
53
|
+
...carousel(),
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
56
|
+
...content(),
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Box, {
|
|
59
|
+
...viewport(),
|
|
60
|
+
ref: emblaMainRef,
|
|
61
|
+
children: /* @__PURE__ */ jsx(Group, {
|
|
62
|
+
...slideContainer(),
|
|
63
|
+
children: images.map((image, index) => /* @__PURE__ */ jsx(ProteusImage, {
|
|
64
|
+
alt: image.alt,
|
|
65
|
+
src: image.src,
|
|
66
|
+
...slide()
|
|
67
|
+
}, index))
|
|
68
|
+
})
|
|
69
|
+
}),
|
|
70
|
+
canScrollPrev && /* @__PURE__ */ jsx(Box, {
|
|
71
|
+
"aria-label": "Previous image",
|
|
72
|
+
asChild: true,
|
|
73
|
+
onClick: () => emblaMainApi?.scrollPrev(),
|
|
74
|
+
...navButton({ side: "left" }),
|
|
75
|
+
children: /* @__PURE__ */ jsx("button", { children: /* @__PURE__ */ jsx(IconAngleLeft, {}) })
|
|
76
|
+
}),
|
|
77
|
+
canScrollNext && /* @__PURE__ */ jsx(Box, {
|
|
78
|
+
"aria-label": "Next image",
|
|
79
|
+
asChild: true,
|
|
80
|
+
onClick: () => emblaMainApi?.scrollNext(),
|
|
81
|
+
...navButton({ side: "right" }),
|
|
82
|
+
children: /* @__PURE__ */ jsx("button", { children: /* @__PURE__ */ jsx(IconAngleRight, {}) })
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
}),
|
|
86
|
+
images.length > 1 && /* @__PURE__ */ jsx(Box, {
|
|
87
|
+
overflow: "hidden",
|
|
88
|
+
ref: emblaThumbsRef,
|
|
89
|
+
children: /* @__PURE__ */ jsx(Group, {
|
|
90
|
+
gap: "12",
|
|
91
|
+
children: images.map((image, index) => /* @__PURE__ */ jsx(Box, {
|
|
92
|
+
onClick: () => emblaMainApi?.scrollTo(index),
|
|
93
|
+
...thumbnail({ selected: index === selectedIndex }),
|
|
94
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
95
|
+
asChild: true,
|
|
96
|
+
objectFit: "cover",
|
|
97
|
+
size: "full",
|
|
98
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
99
|
+
alt: image.alt,
|
|
100
|
+
src: image.thumb ?? image.src
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
}, index))
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsxs(Group, {
|
|
107
|
+
mt: "4",
|
|
108
|
+
children: [images.length > 1 && /* @__PURE__ */ jsxs(Text, {
|
|
109
|
+
bg: "bg.secondary",
|
|
110
|
+
color: "fg.default",
|
|
111
|
+
fontSize: "sm",
|
|
112
|
+
fontWeight: "500",
|
|
113
|
+
px: "8",
|
|
114
|
+
py: "2",
|
|
115
|
+
rounded: "full",
|
|
116
|
+
children: [
|
|
117
|
+
selectedIndex + 1,
|
|
118
|
+
" / ",
|
|
119
|
+
images.length
|
|
120
|
+
]
|
|
121
|
+
}), images.length > 1 ? /* @__PURE__ */ jsxs(Menu, {
|
|
122
|
+
options: [{
|
|
123
|
+
execute: () => onEvent({
|
|
124
|
+
action: "download",
|
|
125
|
+
url: images[selectedIndex].src
|
|
126
|
+
}),
|
|
127
|
+
label: "Download this image"
|
|
128
|
+
}, {
|
|
129
|
+
execute: () => onEvent({
|
|
130
|
+
action: "download",
|
|
131
|
+
url: images.map((image) => image.src)
|
|
132
|
+
}),
|
|
133
|
+
label: "Download all images"
|
|
134
|
+
}],
|
|
135
|
+
children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
136
|
+
appearance: "primary",
|
|
137
|
+
ml: "auto",
|
|
138
|
+
children: "Download"
|
|
139
|
+
}), /* @__PURE__ */ jsx(MenuContent, { align: "end" })]
|
|
140
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
141
|
+
appearance: "primary",
|
|
142
|
+
ml: "auto",
|
|
143
|
+
onClick: () => onEvent({
|
|
144
|
+
action: "download",
|
|
145
|
+
url: images[0].src
|
|
146
|
+
}),
|
|
147
|
+
children: "Download"
|
|
148
|
+
})]
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
});
|
|
164
152
|
}
|
|
165
153
|
ProteusImageCarousel.displayName = "@optiaxiom/proteus/ProteusImageCarousel";
|
|
166
|
-
|
|
154
|
+
//#endregion
|
|
167
155
|
export { ProteusImageCarousel };
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
2
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
3
|
+
import { useProteusDocumentPathContext } from "../proteus-document/ProteusDocumentPathContext.js";
|
|
4
|
+
import { useProteusValue } from "../use-proteus-value/useProteusValue.js";
|
|
5
|
+
import { Input } from "@optiaxiom/react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/proteus-input/ProteusInput.tsx
|
|
8
8
|
function ProteusInput(props) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (props.name) {
|
|
22
|
-
onDataChange?.(`${parentPath}/${props.name}`, value2);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
readOnly,
|
|
26
|
-
value: props.name ? String(value ?? "") : ""
|
|
27
|
-
}
|
|
28
|
-
);
|
|
9
|
+
const { onDataChange, readOnly } = useProteusDocumentContext("@optiaxiom/proteus/ProteusInput");
|
|
10
|
+
const { path: parentPath } = useProteusDocumentPathContext("@optiaxiom/proteus/ProteusInput");
|
|
11
|
+
const value = useProteusValue({ path: props.name ?? "" });
|
|
12
|
+
const writePath = props.name ? `${parentPath}/${props.name}` : parentPath;
|
|
13
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
14
|
+
...props,
|
|
15
|
+
onValueChange: (value) => {
|
|
16
|
+
if (writePath) onDataChange?.(writePath, value);
|
|
17
|
+
},
|
|
18
|
+
readOnly,
|
|
19
|
+
value: String(value ?? "")
|
|
20
|
+
});
|
|
29
21
|
}
|
|
30
22
|
ProteusInput.displayName = "@optiaxiom/proteus/ProteusInput";
|
|
31
|
-
|
|
23
|
+
//#endregion
|
|
32
24
|
export { ProteusInput };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useProteusValue } from "../use-proteus-value/useProteusValue.js";
|
|
3
|
+
//#region src/proteus-length/ProteusLength.tsx
|
|
4
|
+
function ProteusLength({ path }) {
|
|
5
|
+
const value = useProteusValue({ path });
|
|
6
|
+
return Array.isArray(value) ? value.length : 0;
|
|
7
|
+
}
|
|
8
|
+
ProteusLength.displayName = "@optiaxiom/proteus/ProteusLength";
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ProteusLength };
|
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
3
|
+
import { ProteusDocumentPathProvider, useProteusDocumentPathContext } from "../proteus-document/ProteusDocumentPathContext.js";
|
|
4
|
+
import { useProteusValue } from "../use-proteus-value/useProteusValue.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/proteus-map/ProteusMap.tsx
|
|
7
7
|
function ProteusMap({ children, path, separator }) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return /* @__PURE__ */ jsx(Fragment, { children: array.map((_, index) => /* @__PURE__ */ jsxs(
|
|
22
|
-
ProteusDocumentPathProvider,
|
|
23
|
-
{
|
|
24
|
-
mapIndices: [...mapIndices, index],
|
|
25
|
-
path: `${path.startsWith("/") ? path : `${parentPath}/${path}`}/${index}`,
|
|
26
|
-
children: [
|
|
27
|
-
index > 0 && separator,
|
|
28
|
-
children
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
index
|
|
32
|
-
)) });
|
|
8
|
+
const { strict } = useProteusDocumentContext("@optiaxiom/proteus/ProteusMap");
|
|
9
|
+
const { mapIndices, path: parentPath } = useProteusDocumentPathContext("@optiaxiom/proteus/ProteusMap");
|
|
10
|
+
const array = useProteusValue({ path });
|
|
11
|
+
if (!Array.isArray(array)) {
|
|
12
|
+
if (strict) throw new Error(`Expected value at "${path}" to be an array got "${typeof array}" instead`);
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ jsx(Fragment, { children: array.map((_, index) => /* @__PURE__ */ jsxs(ProteusDocumentPathProvider, {
|
|
16
|
+
mapIndices: [...mapIndices, index],
|
|
17
|
+
path: `${path.startsWith("/") ? path : `${parentPath}/${path}`}/${index}`,
|
|
18
|
+
children: [index > 0 && separator, children]
|
|
19
|
+
}, index)) });
|
|
33
20
|
}
|
|
34
21
|
ProteusMap.displayName = "@optiaxiom/proteus/ProteusMap";
|
|
35
|
-
|
|
22
|
+
//#endregion
|
|
36
23
|
export { ProteusMap };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useProteusDocumentPathContext } from "../proteus-document/ProteusDocumentPathContext.js";
|
|
3
|
+
//#region src/proteus-map-index/ProteusMapIndex.tsx
|
|
4
|
+
function ProteusMapIndex() {
|
|
5
|
+
const { mapIndices } = useProteusDocumentPathContext("@optiaxiom/proteus/ProteusMapIndex");
|
|
6
|
+
const index = mapIndices.at(-1);
|
|
7
|
+
return index === void 0 ? null : index;
|
|
8
|
+
}
|
|
9
|
+
ProteusMapIndex.displayName = "@optiaxiom/proteus/ProteusMapIndex";
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ProteusMapIndex };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
3
|
+
import { useProteusDocumentPathContext } from "../proteus-document/ProteusDocumentPathContext.js";
|
|
4
|
+
import { useProteusValue } from "../use-proteus-value/useProteusValue.js";
|
|
5
|
+
import { useInputValueChangeInteraction } from "./useInputValueChangeInteraction.js";
|
|
6
|
+
import "@optiaxiom/react";
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { PillMenu, PillMenuContent, PillMenuTrigger } from "@optiaxiom/react/unstable";
|
|
10
|
+
//#region src/proteus-pill-menu/ProteusPillMenu.tsx
|
|
11
|
+
function ProteusPillMenu({ inputName, name, onInputValueChange, options = [] }) {
|
|
12
|
+
const { onDataChange, readOnly } = useProteusDocumentContext("@optiaxiom/proteus/ProteusPillMenu");
|
|
13
|
+
const { path: parentPath } = useProteusDocumentPathContext("@optiaxiom/proteus/ProteusPillMenu");
|
|
14
|
+
const { inputValue, loading } = useInputValueChangeInteraction({
|
|
15
|
+
inputName,
|
|
16
|
+
onInputValueChange
|
|
17
|
+
});
|
|
18
|
+
const resolved = useProteusValue({ path: name ?? "" });
|
|
19
|
+
const serialized = JSON.stringify(Array.isArray(resolved) ? resolved : []);
|
|
20
|
+
const value = useMemo(() => JSON.parse(serialized), [serialized]);
|
|
21
|
+
const menuOptions = useMemo(() => options.map((option) => ({
|
|
22
|
+
...option,
|
|
23
|
+
execute: () => {
|
|
24
|
+
if (readOnly || !name) return;
|
|
25
|
+
const next = value.some((v) => v.value === option.value) ? value.filter((v) => v.value !== option.value) : [...value, option];
|
|
26
|
+
onDataChange?.(`${parentPath}/${name}`, next);
|
|
27
|
+
},
|
|
28
|
+
multi: true,
|
|
29
|
+
selected: () => value.some((v) => v.value === option.value)
|
|
30
|
+
})), [
|
|
31
|
+
name,
|
|
32
|
+
onDataChange,
|
|
33
|
+
options,
|
|
34
|
+
parentPath,
|
|
35
|
+
readOnly,
|
|
36
|
+
value
|
|
37
|
+
]);
|
|
38
|
+
const menuValue = useMemo(() => value.map((item) => ({
|
|
39
|
+
execute: () => {
|
|
40
|
+
if (readOnly || !name) return;
|
|
41
|
+
onDataChange?.(`${parentPath}/${name}`, value.filter((v) => v.value !== item.value));
|
|
42
|
+
},
|
|
43
|
+
label: item.label,
|
|
44
|
+
multi: true
|
|
45
|
+
})), [
|
|
46
|
+
name,
|
|
47
|
+
onDataChange,
|
|
48
|
+
parentPath,
|
|
49
|
+
readOnly,
|
|
50
|
+
value
|
|
51
|
+
]);
|
|
52
|
+
return /* @__PURE__ */ jsxs(PillMenu, {
|
|
53
|
+
inputValue: inputName ? inputValue : void 0,
|
|
54
|
+
loading,
|
|
55
|
+
onInputValueChange: (inputValue) => {
|
|
56
|
+
if (inputName) onDataChange?.(`${parentPath}/${inputName}`, inputValue);
|
|
57
|
+
},
|
|
58
|
+
options: menuOptions,
|
|
59
|
+
value: menuValue,
|
|
60
|
+
children: [/* @__PURE__ */ jsx(PillMenuTrigger, { readOnly }), /* @__PURE__ */ jsx(PillMenuContent, {})]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
ProteusPillMenu.displayName = "@optiaxiom/proteus/ProteusPillMenu";
|
|
64
|
+
//#endregion
|
|
65
|
+
export { ProteusPillMenu };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
2
|
+
import { useResolveProteusValues } from "../proteus-document/useResolveProteusValues.js";
|
|
3
|
+
import { useProteusValue } from "../use-proteus-value/useProteusValue.js";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
//#region src/proteus-pill-menu/useInputValueChangeInteraction.ts
|
|
6
|
+
const useInputValueChangeInteraction = ({ inputName, onInputValueChange }) => {
|
|
7
|
+
const { onEvent } = useProteusDocumentContext("@optiaxiom/proteus/useInputValueChangeInteraction");
|
|
8
|
+
const inputValue = useProteusValue({ path: inputName ?? "" });
|
|
9
|
+
const resolvedOnInputValueChange = useResolveProteusValues(onInputValueChange ?? {});
|
|
10
|
+
const resolvedRef = useRef(resolvedOnInputValueChange);
|
|
11
|
+
resolvedRef.current = resolvedOnInputValueChange;
|
|
12
|
+
const onEventRef = useRef(onEvent);
|
|
13
|
+
onEventRef.current = onEvent;
|
|
14
|
+
const [loading, setLoading] = useState();
|
|
15
|
+
const requestIdRef = useRef(0);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (inputName && onInputValueChange) {
|
|
18
|
+
const id = ++requestIdRef.current;
|
|
19
|
+
(async () => {
|
|
20
|
+
setLoading("spinner");
|
|
21
|
+
await onEventRef.current(resolvedRef.current);
|
|
22
|
+
if (requestIdRef.current === id) setLoading(void 0);
|
|
23
|
+
})();
|
|
24
|
+
}
|
|
25
|
+
}, [
|
|
26
|
+
inputName,
|
|
27
|
+
inputValue,
|
|
28
|
+
onInputValueChange
|
|
29
|
+
]);
|
|
30
|
+
return {
|
|
31
|
+
inputValue,
|
|
32
|
+
loading
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { useInputValueChangeInteraction };
|
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var addon = recipe({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { recipe } from "@optiaxiom/react/css-runtime";
|
|
2
|
+
import "./../assets/src/proteus-question/ProteusQuestion.css.ts.vanilla-CpDgoW0l.css";
|
|
3
|
+
//#region src/proteus-question/ProteusQuestion.css.ts
|
|
4
|
+
var addon = recipe({
|
|
5
|
+
base: [{
|
|
6
|
+
display: "grid",
|
|
7
|
+
fontWeight: "500",
|
|
8
|
+
placeItems: "center",
|
|
9
|
+
rounded: "lg",
|
|
10
|
+
size: "md",
|
|
11
|
+
transition: "colors"
|
|
12
|
+
}, "ProteusQuestion__8f590p3"],
|
|
13
|
+
variants: { cursor: { pointer: { cursor: "pointer" } } }
|
|
14
|
+
});
|
|
15
|
+
var choice = recipe({
|
|
16
|
+
base: [
|
|
17
|
+
{
|
|
18
|
+
color: "fg.default",
|
|
19
|
+
flexDirection: "column",
|
|
20
|
+
fontSize: "md",
|
|
21
|
+
gap: "8",
|
|
22
|
+
px: "10",
|
|
23
|
+
py: "16",
|
|
24
|
+
rounded: "lg",
|
|
25
|
+
transition: "colors"
|
|
26
|
+
},
|
|
27
|
+
"ProteusQuestion__8f590p2",
|
|
28
|
+
"ProteusQuestion__8f590p1"
|
|
29
|
+
],
|
|
30
|
+
variants: { cursor: {
|
|
31
|
+
pointer: { borderB: "1" },
|
|
32
|
+
text: { cursor: "text" }
|
|
33
|
+
} }
|
|
34
|
+
});
|
|
35
|
+
var choiceGroup = recipe({ base: { flexDirection: "column" } });
|
|
36
|
+
var question = recipe({ base: [{
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
gap: "16"
|
|
39
|
+
}, "ProteusQuestion__8f590p0"] });
|
|
40
|
+
//#endregion
|
|
9
41
|
export { addon, choice, choiceGroup, question };
|