@optiaxiom/proteus 0.1.1 → 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.
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1qll070;
2
- @layer optiaxiom._1qll070 {
1
+ @layer optiaxiom.gg0bi8;
2
+ @layer optiaxiom.gg0bi8 {
3
3
  .ProteusChart__jmlqij1 {
4
4
  border-radius: 16px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1qll070;
2
- @layer optiaxiom._1qll070 {
1
+ @layer optiaxiom.gg0bi8;
2
+ @layer optiaxiom.gg0bi8 {
3
3
  .ProteusChartTooltipContent__1gsvq810 {
4
4
  min-width: 128px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1qll070;
2
- @layer optiaxiom._1qll070 {
1
+ @layer optiaxiom.gg0bi8;
2
+ @layer optiaxiom.gg0bi8 {
3
3
  .ProteusQuestionItem__uar8vn2 {
4
4
  background-color: var(--ax-colors-bg-page);
5
5
  border-color: var(--ax-colors-bg-page);
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 { ProteusValue } from './proteus-value/ProteusValue.js';
14
+ export { useProteusValue } from './use-proteus-value/useProteusValue.js';
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-DWDlfc5R.css';
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-WrO00wrg.css';
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
- /* @__PURE__ */ jsxs(Group, { flexDirection: "column", gap: "4", children: [
100
- /* @__PURE__ */ jsx(Heading, { fontSize: "lg", fontWeight: "600", level: "2", lineClamp: "2", children: element.title }),
101
- !!element.subtitle && /* @__PURE__ */ jsx(Text, { color: "fg.secondary", fontSize: "sm", children: element.subtitle })
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":
@@ -26,38 +26,57 @@ function ProteusImage(props) {
26
26
  }
27
27
  ),
28
28
  /* @__PURE__ */ jsxs(Dialog, { onOpenChange: setOpen, open, children: [
29
- /* @__PURE__ */ jsx(DialogTrigger, { "aria-label": "Expand", asChild: true, children: /* @__PURE__ */ jsx(Box, { asChild: true, display: isLoaded ? "block" : "none", ...props, children: /* @__PURE__ */ jsx(
30
- "a",
29
+ /* @__PURE__ */ jsx(DialogTrigger, { "aria-label": "Expand", asChild: true, children: /* @__PURE__ */ jsx(
30
+ Box,
31
31
  {
32
- href: props.src,
33
- onClick: (event) => {
34
- event.preventDefault();
35
- setOpen(true);
36
- },
37
- type: "",
32
+ alignSelf: "center",
33
+ asChild: true,
34
+ display: isLoaded ? "block" : "none",
35
+ ...props,
38
36
  children: /* @__PURE__ */ jsx(
39
- Box,
37
+ "a",
40
38
  {
41
- asChild: true,
42
- objectFit: "cover",
43
- overflow: "hidden",
44
- rounded: "inherit",
39
+ href: props.src,
40
+ onClick: (event) => {
41
+ event.preventDefault();
42
+ setOpen(true);
43
+ },
44
+ type: "",
45
45
  children: /* @__PURE__ */ jsx(
46
- "img",
46
+ Box,
47
47
  {
48
- alt: props.alt,
49
- onLoad: () => setIsLoaded(true),
50
- ref: imgRef,
51
- src: props.src
48
+ asChild: true,
49
+ objectFit: "cover",
50
+ overflow: "hidden",
51
+ rounded: "inherit",
52
+ children: /* @__PURE__ */ jsx(
53
+ "img",
54
+ {
55
+ alt: props.alt,
56
+ onLoad: () => setIsLoaded(true),
57
+ ref: imgRef,
58
+ src: props.src
59
+ }
60
+ )
52
61
  }
53
62
  )
54
63
  }
55
64
  )
56
65
  }
57
- ) }) }),
58
- /* @__PURE__ */ jsxs(DialogContent, { size: "lg", children: [
66
+ ) }),
67
+ /* @__PURE__ */ jsxs(DialogContent, { size: "fullscreen", children: [
59
68
  /* @__PURE__ */ jsx(DialogHeader, { lineClamp: "1", children: props.alt }),
60
- /* @__PURE__ */ jsx(DialogBody, { children: /* @__PURE__ */ jsx(Box, { asChild: true, display: "block", objectFit: "cover", children: /* @__PURE__ */ jsx("img", { alt: props.alt, src: props.src }) }) }),
69
+ /* @__PURE__ */ jsx(DialogBody, { overflow: "hidden", children: /* @__PURE__ */ jsx(
70
+ Box,
71
+ {
72
+ asChild: true,
73
+ display: "block",
74
+ maxH: "full",
75
+ maxW: "full",
76
+ objectFit: "contain",
77
+ children: /* @__PURE__ */ jsx("img", { alt: props.alt, src: props.src })
78
+ }
79
+ ) }),
61
80
  /* @__PURE__ */ jsxs(DialogFooter, { children: [
62
81
  /* @__PURE__ */ jsx(DialogClose, { children: "Close" }),
63
82
  /* @__PURE__ */ jsx(
@@ -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-document/useProteusValue.js';
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-document/useProteusValue.js';
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-S1I3NGY4.css';
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-document/useProteusValue.js';
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-document/useProteusValue.js';
6
+ import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
7
7
 
8
8
  function ProteusTextarea(props) {
9
9
  const { onDataChange, readOnly } = useProteusDocumentContext(
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useProteusValue } from '../proteus-document/useProteusValue.js';
2
+ import { useProteusValue } from '../use-proteus-value/useProteusValue.js';
3
3
 
4
4
  function ProteusValue(props) {
5
5
  return useProteusValue(props);