@optiaxiom/proteus 1.0.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-BeRNNwBj.css → ProteusChart.css.ts.vanilla-yGx8JdKz.css} +2 -2
  3. package/dist/esm/assets/src/proteus-chart/{ProteusChartTooltipContent.css.ts.vanilla-Df_IhL_i.css → ProteusChartTooltipContent.css.ts.vanilla-HapBe2oo.css} +2 -2
  4. package/dist/esm/assets/src/proteus-document/{ProteusDocumentShell.css.ts.vanilla-CyMtrn1n.css → ProteusDocumentShell.css.ts.vanilla-BPytQ9pT.css} +2 -2
  5. package/dist/esm/assets/src/proteus-image-carousel/{ProteusImageCarousel.css.ts.vanilla-Dbf7yRF1.css → ProteusImageCarousel.css.ts.vanilla-DnlXoyv1.css} +2 -2
  6. package/dist/esm/assets/src/proteus-question/{ProteusQuestion.css.ts.vanilla-cmHZWqNR.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 +4 -4
  62. package/dist/esm/icons/IconCalendar.js +0 -20
  63. package/dist/esm/schema/public-schema.json.js +0 -9026
  64. package/dist/esm/schema/runtime-schema.json.js +0 -8959
@@ -1,90 +1,76 @@
1
1
  "use client";
2
- import { jsx } from 'react/jsx-runtime';
3
- import { AppBridge, PostMessageTransport } from '@modelcontextprotocol/ext-apps/app-bridge';
4
- import { useState, useRef, useEffect } from 'react';
5
- import { OPENAI_SHIM_SCRIPT } from '../_virtual/_openai-shim-script.js';
6
- import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
7
-
2
+ import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
3
+ import { OPENAI_SHIM_SCRIPT } from "../_virtual/_openai-shim-script.js";
4
+ import { useEffect, useRef, useState } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { AppBridge, PostMessageTransport } from "@modelcontextprotocol/ext-apps/app-bridge";
7
+ //#region src/proteus-bridge/ProteusBridge.tsx
8
8
  function ProteusBridge({ height = 400, resource }) {
9
- const { data, onEvent, useResource } = useProteusDocumentContext(
10
- "@optiaxiom/proteus/ProteusBridge"
11
- );
12
- const result = useResource?.(resource);
13
- const html = result?.data?.text ?? "";
14
- const mimeType = result?.data?.mimeType;
15
- const [iframe, setIframe] = useState(null);
16
- const dataRef = useRef(data);
17
- dataRef.current = data;
18
- useEffect(() => {
19
- if (!iframe?.contentWindow) {
20
- return;
21
- }
22
- const bridge = new AppBridge(
23
- null,
24
- { name: "Opal", version: "1.0.0" },
25
- { logging: {}, openLinks: {}, serverTools: {} },
26
- {
27
- hostContext: {
28
- containerDimensions: { maxHeight: iframe.clientHeight },
29
- displayMode: "inline"
30
- }
31
- }
32
- );
33
- bridge.oncalltool = async (params) => {
34
- const result2 = await onEvent({
35
- interaction: params.name,
36
- params: params.arguments ?? {}
37
- });
38
- return {
39
- content: [
40
- { text: JSON.stringify(result2 ?? ""), type: "text" }
41
- ]
42
- };
43
- };
44
- bridge.onmessage = async (params) => {
45
- const message = params.content?.filter((content) => content.type === "text").map((content) => content.text).join("\n\n") ?? "";
46
- await onEvent({ message });
47
- return {};
48
- };
49
- bridge.onopenlink = async ({ url }) => {
50
- window.open(url, "_blank", "noopener");
51
- return {};
52
- };
53
- bridge.addEventListener("sizechange", ({ height: height2 }) => {
54
- if (height2 != null) {
55
- iframe.style.height = `${height2}px`;
56
- }
57
- });
58
- bridge.addEventListener("initialized", () => {
59
- void bridge.sendToolResult({
60
- content: [
61
- {
62
- text: JSON.stringify(dataRef.current),
63
- type: "text"
64
- }
65
- ]
66
- });
67
- });
68
- const transport = new PostMessageTransport(
69
- iframe.contentWindow,
70
- iframe.contentWindow
71
- );
72
- void bridge.connect(transport);
73
- return () => {
74
- void bridge.close();
75
- };
76
- }, [iframe, onEvent]);
77
- return result?.isError || !html ? null : /* @__PURE__ */ jsx(
78
- "iframe",
79
- {
80
- ref: setIframe,
81
- sandbox: "allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms",
82
- srcDoc: mimeType === "text/html+skybridge" ? OPENAI_SHIM_SCRIPT + html : html,
83
- style: { border: "none", height, width: "100%" },
84
- title: "Opal Widget"
85
- }
86
- );
9
+ const { data, onEvent, useResource } = useProteusDocumentContext("@optiaxiom/proteus/ProteusBridge");
10
+ const result = useResource?.(resource);
11
+ const html = result?.data?.text ?? "";
12
+ const mimeType = result?.data?.mimeType;
13
+ const [iframe, setIframe] = useState(null);
14
+ const dataRef = useRef(data);
15
+ dataRef.current = data;
16
+ useEffect(() => {
17
+ if (!iframe?.contentWindow) return;
18
+ const bridge = new AppBridge(null, {
19
+ name: "Opal",
20
+ version: "1.0.0"
21
+ }, {
22
+ logging: {},
23
+ openLinks: {},
24
+ serverTools: {}
25
+ }, { hostContext: {
26
+ containerDimensions: { maxHeight: iframe.clientHeight },
27
+ displayMode: "inline"
28
+ } });
29
+ bridge.oncalltool = async (params) => {
30
+ const result = await onEvent({
31
+ interaction: params.name,
32
+ params: params.arguments ?? {}
33
+ });
34
+ return { content: [{
35
+ text: JSON.stringify(result ?? ""),
36
+ type: "text"
37
+ }] };
38
+ };
39
+ bridge.onmessage = async (params) => {
40
+ await onEvent({ message: params.content?.filter((content) => content.type === "text").map((content) => content.text).join("\n\n") ?? "" });
41
+ return {};
42
+ };
43
+ bridge.onopenlink = async ({ url }) => {
44
+ window.open(url, "_blank", "noopener");
45
+ return {};
46
+ };
47
+ bridge.addEventListener("sizechange", ({ height }) => {
48
+ if (height != null) iframe.style.height = `${height}px`;
49
+ });
50
+ bridge.addEventListener("initialized", () => {
51
+ bridge.sendToolResult({ content: [{
52
+ text: JSON.stringify(dataRef.current),
53
+ type: "text"
54
+ }] });
55
+ });
56
+ const transport = new PostMessageTransport(iframe.contentWindow, iframe.contentWindow);
57
+ bridge.connect(transport);
58
+ return () => {
59
+ bridge.close();
60
+ };
61
+ }, [iframe, onEvent]);
62
+ return result?.isError || !html ? null : /* @__PURE__ */ jsx("iframe", {
63
+ ref: setIframe,
64
+ sandbox: "allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms",
65
+ srcDoc: mimeType === "text/html+skybridge" ? OPENAI_SHIM_SCRIPT + html : html,
66
+ style: {
67
+ border: "none",
68
+ height,
69
+ width: "100%"
70
+ },
71
+ title: "Opal Widget"
72
+ });
87
73
  }
88
74
  ProteusBridge.displayName = "@optiaxiom/proteus/ProteusBridge";
89
-
75
+ //#endregion
90
76
  export { ProteusBridge };
@@ -1,41 +1,28 @@
1
1
  "use client";
2
- import { jsx } from 'react/jsx-runtime';
3
- import { CardLink } from '@optiaxiom/react';
4
- import { useState } from 'react';
5
- import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
6
- import { useResolveProteusValues } from '../proteus-document/useResolveProteusValues.js';
7
-
8
- function ProteusCardLink({
9
- children,
10
- onClick,
11
- ...props
12
- }) {
13
- const { onEvent } = useProteusDocumentContext(
14
- "@optiaxiom/proteus/ProteusCardLink"
15
- );
16
- const resolvedOnClick = useResolveProteusValues(
17
- onClick ?? {}
18
- );
19
- const [loading, setLoading] = useState(false);
20
- return /* @__PURE__ */ jsx(
21
- CardLink,
22
- {
23
- "aria-busy": loading || void 0,
24
- onClick: onClick ? async (event) => {
25
- event.preventDefault();
26
- if (loading) {
27
- return;
28
- }
29
- setLoading(true);
30
- await onEvent(resolvedOnClick);
31
- setLoading(false);
32
- } : void 0,
33
- target: "_blank",
34
- ...props,
35
- children
36
- }
37
- );
2
+ import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
3
+ import { useResolveProteusValues } from "../proteus-document/useResolveProteusValues.js";
4
+ import { CardLink } from "@optiaxiom/react";
5
+ import { useState } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ //#region src/proteus-card-link/ProteusCardLink.tsx
8
+ function ProteusCardLink({ children, onClick, ...props }) {
9
+ const { onEvent } = useProteusDocumentContext("@optiaxiom/proteus/ProteusCardLink");
10
+ const resolvedOnClick = useResolveProteusValues(onClick ?? {});
11
+ const [loading, setLoading] = useState(false);
12
+ return /* @__PURE__ */ jsx(CardLink, {
13
+ "aria-busy": loading || void 0,
14
+ onClick: onClick ? async (event) => {
15
+ event.preventDefault();
16
+ if (loading) return;
17
+ setLoading(true);
18
+ await onEvent(resolvedOnClick);
19
+ setLoading(false);
20
+ } : void 0,
21
+ target: "_blank",
22
+ ...props,
23
+ children
24
+ });
38
25
  }
39
26
  ProteusCardLink.displayName = "@optiaxiom/proteus/ProteusCardLink";
40
-
27
+ //#endregion
41
28
  export { ProteusCardLink };
@@ -1,6 +1,15 @@
1
- import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-BeRNNwBj.css';
2
- import { recipe } from '@optiaxiom/react/css-runtime';
3
-
4
- var chart = recipe({base:[{border:'1',borderColor:'border.tertiary',fontSize:'sm',p:'16'},'ProteusChart__jmlqij1','ProteusChart__jmlqij0']});
5
-
1
+ import "./../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-yGx8JdKz.css";
2
+ import { recipe } from "@optiaxiom/react/css-runtime";
3
+ //#region src/proteus-chart/ProteusChart.css.ts
4
+ var chart = recipe({ base: [
5
+ {
6
+ border: "1",
7
+ borderColor: "border.tertiary",
8
+ fontSize: "sm",
9
+ p: "16"
10
+ },
11
+ "ProteusChart__jmlqij1",
12
+ "ProteusChart__jmlqij0"
13
+ ] });
14
+ //#endregion
6
15
  export { chart };
@@ -1,89 +1,91 @@
1
1
  "use client";
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { Box, theme } from '@optiaxiom/react';
4
- import { get } from 'jsonpointer';
5
- import { useRef } from 'react';
6
- import { ResponsiveContainer, BarChart, LineChart, CartesianGrid, YAxis, XAxis, Tooltip, Bar, Line } from 'recharts';
7
- import { chart } from './ProteusChart-css.js';
8
- import { ProteusChartContext } from './ProteusChartContext.js';
9
- import { ProteusChartTooltipContent } from './ProteusChartTooltipContent.js';
10
-
11
- const DEFAULT_COLORS = ["#096DD9", "#E59700", "#38C56C", "#D1D8DE"];
2
+ import { chart } from "./ProteusChart-css.js";
3
+ import { ProteusChartContext } from "./ProteusChartContext.js";
4
+ import { ProteusChartTooltipContent } from "./ProteusChartTooltipContent.js";
5
+ import { Box, theme } from "@optiaxiom/react";
6
+ import { useRef } from "react";
7
+ import { get } from "jsonpointer";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { Bar, BarChart, CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
10
+ //#region src/proteus-chart/ProteusChart.tsx
11
+ const DEFAULT_COLORS = [
12
+ "#096DD9",
13
+ "#E59700",
14
+ "#38C56C",
15
+ "#D1D8DE"
16
+ ];
12
17
  const getColor = (index) => DEFAULT_COLORS[index % DEFAULT_COLORS.length];
13
- const ProteusChart = ({
14
- data,
15
- layout = "horizontal",
16
- series,
17
- type,
18
- xAxisKey
19
- }) => {
20
- const isVertical = layout === "vertical";
21
- const ChartComponent = type === "bar" ? BarChart : LineChart;
22
- const Chart = type === "bar" ? Bar : Line;
23
- const CategoryAxis = isVertical ? YAxis : XAxis;
24
- const ValueAxis = isVertical ? XAxis : YAxis;
25
- const containerRef = useRef(null);
26
- return /* @__PURE__ */ jsx(ProteusChartContext.Provider, { value: containerRef, children: /* @__PURE__ */ jsx(Box, { asChild: true, ref: containerRef, ...chart(), children: /* @__PURE__ */ jsx(ResponsiveContainer, { aspect: 16 / 9, width: "100%", children: /* @__PURE__ */ jsxs(ChartComponent, { data, layout, children: [
27
- /* @__PURE__ */ jsx(
28
- CartesianGrid,
29
- {
30
- stroke: theme.colors["border.secondary"],
31
- strokeDasharray: "4 4",
32
- vertical: false
33
- }
34
- ),
35
- /* @__PURE__ */ jsx(
36
- CategoryAxis,
37
- {
38
- axisLine: false,
39
- dataKey: (row) => get(row, "/" + xAxisKey),
40
- padding: { left: 16, right: 16 },
41
- tick: { fill: theme.colors["fg.secondary"] },
42
- tickFormatter: (value) => value.length > 30 ? value.slice(0, 30) + "\u2026" : value,
43
- tickLine: false,
44
- tickMargin: 8,
45
- type: "category",
46
- width: isVertical ? "auto" : void 0
47
- }
48
- ),
49
- /* @__PURE__ */ jsx(
50
- ValueAxis,
51
- {
52
- axisLine: { stroke: theme.colors["border.default"] },
53
- minTickGap: 32,
54
- tick: { fill: theme.colors["fg.secondary"] },
55
- tickFormatter: (value) => new Intl.NumberFormat(void 0, {
56
- compactDisplay: "short",
57
- notation: "compact"
58
- }).format(value),
59
- tickMargin: 8,
60
- type: "number",
61
- width: isVertical ? void 0 : "auto"
62
- }
63
- ),
64
- /* @__PURE__ */ jsx(
65
- Tooltip,
66
- {
67
- content: ProteusChartTooltipContent,
68
- cursor: false,
69
- portal: document.body
70
- }
71
- ),
72
- series?.map((s, i) => /* @__PURE__ */ jsx(
73
- Chart,
74
- {
75
- dataKey: (row) => get(row, "/" + s.dataKey),
76
- dot: false,
77
- fill: getColor(i),
78
- name: s.name ?? s.dataKey,
79
- radius: type === "bar" ? 4 : void 0,
80
- stroke: getColor(i),
81
- type: "natural"
82
- },
83
- i
84
- ))
85
- ] }) }) }) });
18
+ const ProteusChart = ({ data, layout = "horizontal", series, type, xAxisKey }) => {
19
+ const isVertical = layout === "vertical";
20
+ const ChartComponent = type === "bar" ? BarChart : LineChart;
21
+ const Chart = type === "bar" ? Bar : Line;
22
+ const CategoryAxis = isVertical ? YAxis : XAxis;
23
+ const ValueAxis = isVertical ? XAxis : YAxis;
24
+ const containerRef = useRef(null);
25
+ return /* @__PURE__ */ jsx(ProteusChartContext.Provider, {
26
+ value: containerRef,
27
+ children: /* @__PURE__ */ jsx(Box, {
28
+ asChild: true,
29
+ ref: containerRef,
30
+ ...chart(),
31
+ children: /* @__PURE__ */ jsx(ResponsiveContainer, {
32
+ aspect: 16 / 9,
33
+ width: "100%",
34
+ children: /* @__PURE__ */ jsxs(ChartComponent, {
35
+ data,
36
+ layout,
37
+ children: [
38
+ /* @__PURE__ */ jsx(CartesianGrid, {
39
+ stroke: theme.colors["border.secondary"],
40
+ strokeDasharray: "4 4",
41
+ vertical: false
42
+ }),
43
+ /* @__PURE__ */ jsx(CategoryAxis, {
44
+ axisLine: false,
45
+ dataKey: (row) => get(row, "/" + xAxisKey),
46
+ padding: {
47
+ left: 16,
48
+ right: 16
49
+ },
50
+ tick: { fill: theme.colors["fg.secondary"] },
51
+ tickFormatter: (value) => value.length > 30 ? value.slice(0, 30) + "" : value,
52
+ tickLine: false,
53
+ tickMargin: 8,
54
+ type: "category",
55
+ width: isVertical ? "auto" : void 0
56
+ }),
57
+ /* @__PURE__ */ jsx(ValueAxis, {
58
+ axisLine: { stroke: theme.colors["border.default"] },
59
+ minTickGap: 32,
60
+ tick: { fill: theme.colors["fg.secondary"] },
61
+ tickFormatter: (value) => new Intl.NumberFormat(void 0, {
62
+ compactDisplay: "short",
63
+ notation: "compact"
64
+ }).format(value),
65
+ tickMargin: 8,
66
+ type: "number",
67
+ width: isVertical ? void 0 : "auto"
68
+ }),
69
+ /* @__PURE__ */ jsx(Tooltip$1, {
70
+ content: ProteusChartTooltipContent,
71
+ cursor: false,
72
+ portal: document.body
73
+ }),
74
+ series?.map((s, i) => /* @__PURE__ */ jsx(Chart, {
75
+ dataKey: (row) => get(row, "/" + s.dataKey),
76
+ dot: false,
77
+ fill: getColor(i),
78
+ name: s.name ?? s.dataKey,
79
+ radius: type === "bar" ? 4 : void 0,
80
+ stroke: getColor(i),
81
+ type: "natural"
82
+ }, i))
83
+ ]
84
+ })
85
+ })
86
+ })
87
+ });
86
88
  };
87
89
  ProteusChart.displayName = "@optiaxiom/proteus/ProteusChart";
88
-
90
+ //#endregion
89
91
  export { ProteusChart };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { createContext, useContext } from 'react';
3
-
2
+ import { createContext, useContext } from "react";
3
+ //#region src/proteus-chart/ProteusChartContext.tsx
4
4
  const ProteusChartContext = createContext(void 0);
5
5
  const useProteusChartContainer = () => useContext(ProteusChartContext);
6
-
6
+ //#endregion
7
7
  export { ProteusChartContext, useProteusChartContainer };
@@ -1,7 +1,24 @@
1
- import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-Df_IhL_i.css';
2
- import { recipe } from '@optiaxiom/react/css-runtime';
3
-
4
- var tooltip = recipe({base:[{bg:'bg.default',border:'1',borderColor:'border.secondary',display:'grid',fontSize:'sm',gap:'6',pointerEvents:'none',px:'8',py:'10',rounded:'lg',shadow:'lg',transition:'all',z:'popover'},'ProteusChartTooltipContent__1gsvq810']});
5
- var value = recipe({base:[{color:'fg.default',fontWeight:'500'},'ProteusChartTooltipContent__1gsvq811']});
6
-
1
+ import { recipe } from "@optiaxiom/react/css-runtime";
2
+ import "./../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-HapBe2oo.css";
3
+ //#region src/proteus-chart/ProteusChartTooltipContent.css.ts
4
+ var tooltip = recipe({ base: [{
5
+ bg: "bg.default",
6
+ border: "1",
7
+ borderColor: "border.secondary",
8
+ display: "grid",
9
+ fontSize: "sm",
10
+ gap: "6",
11
+ pointerEvents: "none",
12
+ px: "8",
13
+ py: "10",
14
+ rounded: "lg",
15
+ shadow: "lg",
16
+ transition: "all",
17
+ z: "popover"
18
+ }, "ProteusChartTooltipContent__1gsvq810"] });
19
+ var value = recipe({ base: [{
20
+ color: "fg.default",
21
+ fontWeight: "500"
22
+ }, "ProteusChartTooltipContent__1gsvq811"] });
23
+ //#endregion
7
24
  export { tooltip, value };
@@ -1,70 +1,56 @@
1
1
  "use client";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { Box, Group } from '@optiaxiom/react';
4
- import { useRef } from 'react';
5
- import { applyFormatter } from '../proteus-document/getProteusValue.js';
6
- import { useProteusChartContainer } from './ProteusChartContext.js';
7
- import { value, tooltip } from './ProteusChartTooltipContent-css.js';
8
-
2
+ import { applyFormatter } from "../proteus-document/getProteusValue.js";
3
+ import { useProteusChartContainer } from "./ProteusChartContext.js";
4
+ import { tooltip, value } from "./ProteusChartTooltipContent-css.js";
5
+ import { Box, Group } from "@optiaxiom/react";
6
+ import { useRef } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/proteus-chart/ProteusChartTooltipContent.tsx
9
9
  const OFFSET = 10;
10
- function ProteusChartTooltipContent({
11
- active,
12
- coordinate,
13
- label,
14
- payload
15
- }) {
16
- const containerRef = useProteusChartContainer();
17
- const ref = useRef(null);
18
- if (!active || !payload?.length) {
19
- return null;
20
- }
21
- const wrapperRect = containerRef?.current?.querySelector(".recharts-wrapper")?.getBoundingClientRect();
22
- const tooltipRect = ref.current?.getBoundingClientRect();
23
- const cx = coordinate?.x ?? 0;
24
- const cy = coordinate?.y ?? 0;
25
- const th = tooltipRect?.height ?? 0;
26
- const translateX = cx + OFFSET;
27
- const translateY = cy - th / 2;
28
- return /* @__PURE__ */ jsxs(
29
- Box,
30
- {
31
- ref,
32
- style: {
33
- left: 0,
34
- top: 0,
35
- transform: `translate(${(wrapperRect?.left ?? 0) + translateX + window.scrollX}px, ${(wrapperRect?.top ?? 0) + translateY + window.scrollY}px)`
36
- },
37
- ...tooltip(),
38
- children: [
39
- label && /* @__PURE__ */ jsx(Box, { fontWeight: "500", children: label }),
40
- /* @__PURE__ */ jsx("div", { children: payload.filter((item) => item.type !== "none").map((item, i) => /* @__PURE__ */ jsxs(
41
- Box,
42
- {
43
- alignItems: "center",
44
- display: "flex",
45
- gap: "8",
46
- justifyContent: "space-between",
47
- children: [
48
- /* @__PURE__ */ jsxs(Group, { gap: "8", children: [
49
- /* @__PURE__ */ jsx(
50
- Box,
51
- {
52
- flex: "none",
53
- rounded: "xs",
54
- size: "10",
55
- style: { backgroundColor: item.color }
56
- }
57
- ),
58
- /* @__PURE__ */ jsx(Box, { color: "fg.tertiary", children: item.name ?? String(item.dataKey) })
59
- ] }),
60
- /* @__PURE__ */ jsx(Box, { ...value(), children: applyFormatter(item.value, "Number") })
61
- ]
62
- },
63
- i
64
- )) })
65
- ]
66
- }
67
- );
10
+ function ProteusChartTooltipContent({ active, coordinate, label, payload }) {
11
+ const containerRef = useProteusChartContainer();
12
+ const ref = useRef(null);
13
+ if (!active || !payload?.length) return null;
14
+ const wrapperRect = containerRef?.current?.querySelector(".recharts-wrapper")?.getBoundingClientRect();
15
+ const tooltipRect = ref.current?.getBoundingClientRect();
16
+ const cx = coordinate?.x ?? 0;
17
+ const cy = coordinate?.y ?? 0;
18
+ const th = tooltipRect?.height ?? 0;
19
+ const translateX = cx + OFFSET;
20
+ const translateY = cy - th / 2;
21
+ return /* @__PURE__ */ jsxs(Box, {
22
+ ref,
23
+ style: {
24
+ left: 0,
25
+ top: 0,
26
+ transform: `translate(${(wrapperRect?.left ?? 0) + translateX + window.scrollX}px, ${(wrapperRect?.top ?? 0) + translateY + window.scrollY}px)`
27
+ },
28
+ ...tooltip(),
29
+ children: [label && /* @__PURE__ */ jsx(Box, {
30
+ fontWeight: "500",
31
+ children: label
32
+ }), /* @__PURE__ */ jsx("div", { children: payload.filter((item) => item.type !== "none").map((item, i) => /* @__PURE__ */ jsxs(Box, {
33
+ alignItems: "center",
34
+ display: "flex",
35
+ gap: "8",
36
+ justifyContent: "space-between",
37
+ children: [/* @__PURE__ */ jsxs(Group, {
38
+ gap: "8",
39
+ children: [/* @__PURE__ */ jsx(Box, {
40
+ flex: "none",
41
+ rounded: "xs",
42
+ size: "10",
43
+ style: { backgroundColor: item.color }
44
+ }), /* @__PURE__ */ jsx(Box, {
45
+ color: "fg.tertiary",
46
+ children: item.name ?? String(item.dataKey)
47
+ })]
48
+ }), /* @__PURE__ */ jsx(Box, {
49
+ ...value(),
50
+ children: applyFormatter(item.value, "Number")
51
+ })]
52
+ }, i)) })]
53
+ });
68
54
  }
69
-
55
+ //#endregion
70
56
  export { ProteusChartTooltipContent };