@optiaxiom/proteus 0.1.2 → 0.1.3
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/assets/src/proteus-chart/{ProteusChart.css.ts.vanilla-DWDlfc5R.css → ProteusChart.css.ts.vanilla-CK1fYTqC.css} +2 -2
- package/dist/esm/assets/src/proteus-chart/{ProteusChartTooltipContent.css.ts.vanilla-WrO00wrg.css → ProteusChartTooltipContent.css.ts.vanilla-BdDP4nOV.css} +2 -2
- package/dist/esm/assets/src/proteus-question/{ProteusQuestionItem.css.ts.vanilla-S1I3NGY4.css → ProteusQuestionItem.css.ts.vanilla-aFgg_KJM.css} +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/proteus-chart/ProteusChart-css.js +1 -1
- package/dist/esm/proteus-chart/ProteusChartTooltipContent-css.js +1 -1
- package/dist/esm/proteus-document/ProteusDocumentShell.js +37 -6
- package/dist/esm/proteus-element/ProteusElement.js +5 -0
- package/dist/esm/proteus-input/ProteusInput.js +1 -1
- package/dist/esm/proteus-map/ProteusMap.js +1 -1
- package/dist/esm/proteus-question/ProteusQuestionItem-css.js +1 -1
- package/dist/esm/proteus-select/ProteusSelect.js +1 -1
- package/dist/esm/proteus-switch/ProteusSwitch.js +41 -0
- package/dist/esm/proteus-textarea/ProteusTextarea.js +1 -1
- package/dist/esm/proteus-value/ProteusValue.js +1 -1
- package/dist/esm/schema/public-schema.json.js +439 -0
- package/dist/esm/schema/runtime-schema.json.js +436 -0
- package/dist/esm/{proteus-document → use-proteus-value}/useProteusValue.js +3 -3
- package/dist/index.d.ts +8 -5
- package/dist/spec.d.ts +2193 -1512
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -11,4 +11,4 @@ export { ProteusMap } from './proteus-map/ProteusMap.js';
|
|
|
11
11
|
export { ProteusSelect } from './proteus-select/ProteusSelect.js';
|
|
12
12
|
export { ProteusShow } from './proteus-show/ProteusShow.js';
|
|
13
13
|
export { ProteusTextarea } from './proteus-textarea/ProteusTextarea.js';
|
|
14
|
-
export {
|
|
14
|
+
export { useProteusValue } from './use-proteus-value/useProteusValue.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-
|
|
1
|
+
import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-CK1fYTqC.css';
|
|
2
2
|
import { recipe } from '@optiaxiom/react/css-runtime';
|
|
3
3
|
|
|
4
4
|
var chart = recipe({base:[{border:'1',borderColor:'border.tertiary',fontSize:'sm',p:'16'},'ProteusChart__jmlqij1','ProteusChart__jmlqij0']});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-
|
|
1
|
+
import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-BdDP4nOV.css';
|
|
2
2
|
import { recipe } from '@optiaxiom/react/css-runtime';
|
|
3
3
|
|
|
4
4
|
var tooltip = recipe({base:[{bg:'bg.default',border:'1',borderColor:'border.secondary',display:'grid',fontSize:'sm',gap:'6',px:'8',py:'10',rounded:'lg',shadow:'lg'},'ProteusChartTooltipContent__1gsvq810']});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { Disclosure, DisclosureTrigger, Box, Group, Text, DisclosureContent, Heading } from '@optiaxiom/react';
|
|
3
|
+
import { Disclosure, DisclosureTrigger, Box, Group, Text, DisclosureContent, Heading, Tooltip } from '@optiaxiom/react';
|
|
4
4
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
5
|
-
import { set } from 'jsonpointer';
|
|
5
|
+
import { get, set } from 'jsonpointer';
|
|
6
6
|
import { useState, useRef, useEffect } from 'react';
|
|
7
7
|
import { useEffectEvent } from '../hooks/useEffectEvent.js';
|
|
8
8
|
import { downloadFile } from '../proteus-image/downloadFile.js';
|
|
@@ -49,6 +49,15 @@ function ProteusDocumentShell({
|
|
|
49
49
|
await onToolCall?.(event.tool);
|
|
50
50
|
} else if ("message" in event) {
|
|
51
51
|
await onMessage?.(event.message);
|
|
52
|
+
} else if (event.action === "message-from") {
|
|
53
|
+
const items = get(data, event.path);
|
|
54
|
+
if (!Array.isArray(items)) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Expected array at "${event.path}" for message-from action`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const message = items.map((item) => `${item.name}: ${item.value || "[Not specified]"}`).join("\n");
|
|
60
|
+
await onMessage?.(message);
|
|
52
61
|
} else if (event.action === "download") {
|
|
53
62
|
if (typeof event.url === "string") {
|
|
54
63
|
await downloadFile(event.url);
|
|
@@ -96,10 +105,32 @@ function ProteusDocumentShell({
|
|
|
96
105
|
pb: "0",
|
|
97
106
|
pt: element.appName ? "16" : "0",
|
|
98
107
|
children: [
|
|
99
|
-
element.title && /* @__PURE__ */ jsxs(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
element.title && /* @__PURE__ */ jsxs(
|
|
109
|
+
Group,
|
|
110
|
+
{
|
|
111
|
+
bg: element.titleIcon ? "bg.page" : "transparent",
|
|
112
|
+
gap: "8",
|
|
113
|
+
p: element.titleIcon ? "12" : void 0,
|
|
114
|
+
rounded: "lg",
|
|
115
|
+
children: [
|
|
116
|
+
element.titleIcon && /* @__PURE__ */ jsx(
|
|
117
|
+
Group,
|
|
118
|
+
{
|
|
119
|
+
bg: "bg.avatar.purple",
|
|
120
|
+
flex: "none",
|
|
121
|
+
justifyContent: "center",
|
|
122
|
+
rounded: "lg",
|
|
123
|
+
size: "lg",
|
|
124
|
+
children: /* @__PURE__ */ jsx(Box, { asChild: true, children: /* @__PURE__ */ jsx("img", { alt: "", src: element.titleIcon }) })
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ jsxs(Group, { flex: "1", flexDirection: "column", gap: "4", children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Heading, { fontSize: "lg", fontWeight: "600", level: "2", lineClamp: "2", children: element.title }),
|
|
129
|
+
!!element.subtitle && /* @__PURE__ */ jsx(Tooltip, { auto: true, content: element.subtitle, children: /* @__PURE__ */ jsx(Text, { color: "fg.secondary", lineClamp: "2", children: element.subtitle }) })
|
|
130
|
+
] })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
),
|
|
103
134
|
/* @__PURE__ */ jsx(Group, { asChild: true, flexDirection: "column", gap: "16", children: /* @__PURE__ */ jsx(
|
|
104
135
|
"form",
|
|
105
136
|
{
|
|
@@ -17,6 +17,7 @@ import { ProteusMap } from '../proteus-map/ProteusMap.js';
|
|
|
17
17
|
import { ProteusQuestion } from '../proteus-question/ProteusQuestion.js';
|
|
18
18
|
import { ProteusSelect } from '../proteus-select/ProteusSelect.js';
|
|
19
19
|
import { ProteusShow } from '../proteus-show/ProteusShow.js';
|
|
20
|
+
import { ProteusSwitch } from '../proteus-switch/ProteusSwitch.js';
|
|
20
21
|
import { ProteusTextarea } from '../proteus-textarea/ProteusTextarea.js';
|
|
21
22
|
import { ProteusValue } from '../proteus-value/ProteusValue.js';
|
|
22
23
|
|
|
@@ -92,6 +93,8 @@ const ProteusElement = ({
|
|
|
92
93
|
return /* @__PURE__ */ jsx(Group, { ...resolve(element) });
|
|
93
94
|
case "Heading":
|
|
94
95
|
return /* @__PURE__ */ jsx(Heading, { ...resolve(element) });
|
|
96
|
+
case "Icon":
|
|
97
|
+
return /* @__PURE__ */ jsx(Box, { asChild: true, ...resolve(element), children: /* @__PURE__ */ jsx("img", {}) });
|
|
95
98
|
case "IconCalendar":
|
|
96
99
|
return /* @__PURE__ */ jsx(Box, { asChild: true, ...resolve(element), children: /* @__PURE__ */ jsx(IconCalendar, {}) });
|
|
97
100
|
case "Image":
|
|
@@ -126,6 +129,8 @@ const ProteusElement = ({
|
|
|
126
129
|
...resolve(element)
|
|
127
130
|
}
|
|
128
131
|
);
|
|
132
|
+
case "Switch":
|
|
133
|
+
return /* @__PURE__ */ jsx(ProteusSwitch, { ...resolve(element) });
|
|
129
134
|
case "Text":
|
|
130
135
|
return /* @__PURE__ */ jsx(Text, { ...resolve(element) });
|
|
131
136
|
case "Textarea":
|
|
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Input } from '@optiaxiom/react';
|
|
4
4
|
import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
|
|
5
5
|
import { useProteusDocumentPathContext } from '../proteus-document/ProteusDocumentPathContext.js';
|
|
6
|
-
import { useProteusValue } from '../proteus-
|
|
6
|
+
import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
|
|
7
7
|
|
|
8
8
|
function ProteusInput(props) {
|
|
9
9
|
const { onDataChange, readOnly } = useProteusDocumentContext(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
|
|
4
4
|
import { useProteusDocumentPathContext, ProteusDocumentPathProvider } from '../proteus-document/ProteusDocumentPathContext.js';
|
|
5
|
-
import { useProteusValue } from '../proteus-
|
|
5
|
+
import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
|
|
6
6
|
|
|
7
7
|
function ProteusMap({ children, path, separator }) {
|
|
8
8
|
const { strict } = useProteusDocumentContext("@optiaxiom/proteus/ProteusMap");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './../assets/src/proteus-question/ProteusQuestionItem.css.ts.vanilla-
|
|
1
|
+
import './../assets/src/proteus-question/ProteusQuestionItem.css.ts.vanilla-aFgg_KJM.css';
|
|
2
2
|
import { recipe } from '@optiaxiom/react/css-runtime';
|
|
3
3
|
|
|
4
4
|
var addon = recipe({base:[{display:'grid',fontWeight:'500',placeItems:'center',rounded:'lg',size:'md',transition:'colors'},'ProteusQuestionItem__uar8vn3'],variants:{cursor:{pointer:{cursor:'pointer'}}}});
|
|
@@ -4,7 +4,7 @@ import { Select } from '@optiaxiom/react';
|
|
|
4
4
|
import { useRef } from 'react';
|
|
5
5
|
import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
|
|
6
6
|
import { useProteusDocumentPathContext } from '../proteus-document/ProteusDocumentPathContext.js';
|
|
7
|
-
import { useProteusValue } from '../proteus-
|
|
7
|
+
import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
|
|
8
8
|
|
|
9
9
|
function ProteusSelect({
|
|
10
10
|
children,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Switch } from '@optiaxiom/react';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
|
|
6
|
+
import { useProteusDocumentPathContext } from '../proteus-document/ProteusDocumentPathContext.js';
|
|
7
|
+
import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
|
|
8
|
+
|
|
9
|
+
function ProteusSwitch(props) {
|
|
10
|
+
const { onDataChange, readOnly } = useProteusDocumentContext(
|
|
11
|
+
"@optiaxiom/proteus/ProteusSwitch"
|
|
12
|
+
);
|
|
13
|
+
const { path: parentPath } = useProteusDocumentPathContext(
|
|
14
|
+
"@optiaxiom/proteus/ProteusSwitch"
|
|
15
|
+
);
|
|
16
|
+
const dataValue = useProteusValue({ path: props.name ?? "" });
|
|
17
|
+
const hasValue = props.value !== void 0;
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (hasValue && props.name && (dataValue === null || dataValue === void 0)) {
|
|
20
|
+
onDataChange?.(`${parentPath}/${props.name}`, "No");
|
|
21
|
+
}
|
|
22
|
+
}, [dataValue, hasValue, onDataChange, parentPath, props.name]);
|
|
23
|
+
const checked = hasValue ? dataValue === props.value : Boolean(dataValue);
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
Switch,
|
|
26
|
+
{
|
|
27
|
+
...props,
|
|
28
|
+
checked: props.name ? checked : false,
|
|
29
|
+
disabled: readOnly,
|
|
30
|
+
onCheckedChange: (newChecked) => {
|
|
31
|
+
if (props.name) {
|
|
32
|
+
const newValue = hasValue ? newChecked ? props.value : "No" : newChecked;
|
|
33
|
+
onDataChange?.(`${parentPath}/${props.name}`, newValue);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
ProteusSwitch.displayName = "@optiaxiom/proteus/ProteusSwitch";
|
|
40
|
+
|
|
41
|
+
export { ProteusSwitch };
|
|
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Textarea } from '@optiaxiom/react';
|
|
4
4
|
import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
|
|
5
5
|
import { useProteusDocumentPathContext } from '../proteus-document/ProteusDocumentPathContext.js';
|
|
6
|
-
import { useProteusValue } from '../proteus-
|
|
6
|
+
import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
|
|
7
7
|
|
|
8
8
|
function ProteusTextarea(props) {
|
|
9
9
|
const { onDataChange, readOnly } = useProteusDocumentContext(
|