@devtable/dashboard 1.14.0 → 1.16.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/api-caller/request.d.ts +5 -2
- package/dist/dashboard.es.js +102 -94
- package/dist/dashboard.umd.js +7 -7
- package/dist/layout/index.d.ts +1 -10
- package/dist/layout/read-only.d.ts +1 -8
- package/dist/main/main.d.ts +3 -2
- package/dist/main/read-only.d.ts +3 -2
- package/dist/panel/error-boundary.d.ts +11 -6
- package/dist/panel/settings/common/color-array-input.d.ts +1 -1
- package/dist/panel/settings/common/mantine-color.d.ts +2 -2
- package/dist/panel/settings/common/mantine-font-weight.d.ts +2 -2
- package/dist/panel/settings/common/numbro-format-selector.d.ts +2 -2
- package/dist/panel/settings/common/text-array-input.d.ts +1 -1
- package/dist/types/dashboard.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import { Method } from 'axios';
|
|
2
|
+
export declare const APIClient: {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
getRequest(method: Method): (url: string, data: any, options?: any) => Promise<any>;
|
|
5
|
+
};
|
package/dist/dashboard.es.js
CHANGED
|
@@ -35,8 +35,8 @@ var __publicField = (obj, key, value) => {
|
|
|
35
35
|
};
|
|
36
36
|
import React from "react";
|
|
37
37
|
import _ from "lodash";
|
|
38
|
-
import { WidthProvider
|
|
39
|
-
import { Popover, Tooltip, Group, Text, ActionIcon,
|
|
38
|
+
import RGL, { WidthProvider } from "react-grid-layout";
|
|
39
|
+
import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, SegmentedControl, NumberInput, Switch, Slider, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
|
|
40
40
|
import { useRequest } from "ahooks";
|
|
41
41
|
import axios from "axios";
|
|
42
42
|
import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Resize, Paint, PlayerPlay, ClipboardText, Database, Recycle, Share } from "tabler-icons-react";
|
|
@@ -68,31 +68,32 @@ const initialContext$3 = {
|
|
|
68
68
|
inUseMode: true
|
|
69
69
|
};
|
|
70
70
|
const LayoutStateContext = React.createContext(initialContext$3);
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
const APIClient = {
|
|
72
|
+
baseURL: "http://localhost:31200",
|
|
73
|
+
getRequest(method) {
|
|
74
|
+
return (url, data, options = {}) => {
|
|
75
|
+
const headers = __spreadValues({
|
|
76
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
77
|
+
"Content-Type": options.string ? "application/x-www-form-urlencoded" : "application/json"
|
|
78
|
+
}, options.headers);
|
|
79
|
+
const conf = {
|
|
80
|
+
baseURL: this.baseURL,
|
|
81
|
+
method,
|
|
82
|
+
url,
|
|
83
|
+
params: method === "GET" ? data : options.params,
|
|
84
|
+
headers
|
|
85
|
+
};
|
|
86
|
+
if (method === "POST") {
|
|
87
|
+
conf.data = options.string ? JSON.stringify(data) : data;
|
|
88
|
+
}
|
|
89
|
+
return axios(conf).then((res) => {
|
|
90
|
+
return res.data;
|
|
91
|
+
}).catch((err) => {
|
|
92
|
+
return Promise.reject(err);
|
|
93
|
+
});
|
|
83
94
|
};
|
|
84
|
-
|
|
85
|
-
conf.data = options.string ? JSON.stringify(data) : data;
|
|
86
|
-
}
|
|
87
|
-
return axios(conf).then((res) => {
|
|
88
|
-
return res.data;
|
|
89
|
-
}).catch((err) => {
|
|
90
|
-
return Promise.reject(err);
|
|
91
|
-
});
|
|
92
|
-
};
|
|
95
|
+
}
|
|
93
96
|
};
|
|
94
|
-
const get = getRequest("GET");
|
|
95
|
-
const post = getRequest("POST");
|
|
96
97
|
function formatSQL(sql, params) {
|
|
97
98
|
const names = Object.keys(params);
|
|
98
99
|
const vals = Object.values(params);
|
|
@@ -126,7 +127,7 @@ const queryBySQL = ({ context, definitions, title, dataSource }) => async () =>
|
|
|
126
127
|
console.log(formattedSQL);
|
|
127
128
|
console.groupEnd();
|
|
128
129
|
}
|
|
129
|
-
const res = await
|
|
130
|
+
const res = await APIClient.getRequest("POST")("/query", { type, key, sql: formattedSQL });
|
|
130
131
|
return res;
|
|
131
132
|
} catch (error) {
|
|
132
133
|
console.error(error);
|
|
@@ -135,7 +136,7 @@ const queryBySQL = ({ context, definitions, title, dataSource }) => async () =>
|
|
|
135
136
|
};
|
|
136
137
|
async function getQuerySources() {
|
|
137
138
|
try {
|
|
138
|
-
const res = await
|
|
139
|
+
const res = await APIClient.getRequest("GET")("/query/sources", {});
|
|
139
140
|
return res;
|
|
140
141
|
} catch (error) {
|
|
141
142
|
console.error(error);
|
|
@@ -312,18 +313,37 @@ class ErrorBoundary extends React.Component {
|
|
|
312
313
|
constructor(props) {
|
|
313
314
|
super(props);
|
|
314
315
|
this.state = {
|
|
315
|
-
|
|
316
|
+
error: null
|
|
316
317
|
};
|
|
317
318
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
};
|
|
319
|
+
componentDidCatch(error) {
|
|
320
|
+
this.setState({
|
|
321
|
+
error
|
|
322
|
+
});
|
|
322
323
|
}
|
|
323
324
|
render() {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
var _a;
|
|
326
|
+
if (this.state.error) {
|
|
327
|
+
const retry = () => {
|
|
328
|
+
this.setState({
|
|
329
|
+
error: null
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
333
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
334
|
+
size: "xs",
|
|
335
|
+
children: (_a = this.state.error) == null ? void 0 : _a.message
|
|
336
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
337
|
+
variant: "subtle",
|
|
338
|
+
size: "xs",
|
|
339
|
+
mx: "auto",
|
|
340
|
+
compact: true,
|
|
341
|
+
sx: {
|
|
342
|
+
display: "block"
|
|
343
|
+
},
|
|
344
|
+
onClick: retry,
|
|
345
|
+
children: "Retry"
|
|
346
|
+
})]
|
|
327
347
|
});
|
|
328
348
|
}
|
|
329
349
|
return this.props.children;
|
|
@@ -1602,7 +1622,9 @@ function Viz({
|
|
|
1602
1622
|
color: "gray",
|
|
1603
1623
|
align: "center",
|
|
1604
1624
|
children: "nothing to show"
|
|
1605
|
-
}), !empty &&
|
|
1625
|
+
}), !empty && /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
1626
|
+
children: renderViz(width, height, data, viz)
|
|
1627
|
+
})]
|
|
1606
1628
|
});
|
|
1607
1629
|
}
|
|
1608
1630
|
function PreviewViz({}) {
|
|
@@ -1611,12 +1633,10 @@ function PreviewViz({}) {
|
|
|
1611
1633
|
loading,
|
|
1612
1634
|
viz
|
|
1613
1635
|
} = React.useContext(PanelContext);
|
|
1614
|
-
return /* @__PURE__ */ jsx(
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
loading
|
|
1619
|
-
})
|
|
1636
|
+
return /* @__PURE__ */ jsx(Viz, {
|
|
1637
|
+
viz,
|
|
1638
|
+
data,
|
|
1639
|
+
loading
|
|
1620
1640
|
});
|
|
1621
1641
|
}
|
|
1622
1642
|
function VizBar3DPanel({
|
|
@@ -1783,10 +1803,10 @@ function VizBar3DPanel({
|
|
|
1783
1803
|
})
|
|
1784
1804
|
});
|
|
1785
1805
|
}
|
|
1786
|
-
function
|
|
1806
|
+
function _MantineColorSelector({
|
|
1787
1807
|
value,
|
|
1788
1808
|
onChange
|
|
1789
|
-
}) {
|
|
1809
|
+
}, ref) {
|
|
1790
1810
|
const theme = useMantineTheme();
|
|
1791
1811
|
const themeColors = React.useMemo(() => {
|
|
1792
1812
|
return Object.entries(theme.colors).map(([color2, profile]) => ({
|
|
@@ -1835,6 +1855,7 @@ function MantineColorSelector({
|
|
|
1835
1855
|
})]
|
|
1836
1856
|
});
|
|
1837
1857
|
}
|
|
1858
|
+
const MantineColorSelector = React.forwardRef(_MantineColorSelector);
|
|
1838
1859
|
const labelPositions = [{
|
|
1839
1860
|
label: "off",
|
|
1840
1861
|
value: ""
|
|
@@ -2112,10 +2133,10 @@ const defaultNumbroFormat = {
|
|
|
2112
2133
|
mantissa: 0,
|
|
2113
2134
|
output: "number"
|
|
2114
2135
|
};
|
|
2115
|
-
function
|
|
2136
|
+
function _NumbroFormatSelector({
|
|
2116
2137
|
value,
|
|
2117
2138
|
onChange
|
|
2118
|
-
}) {
|
|
2139
|
+
}, ref) {
|
|
2119
2140
|
const changeOutput = (output) => {
|
|
2120
2141
|
onChange(__spreadProps(__spreadValues({}, value), {
|
|
2121
2142
|
output
|
|
@@ -2137,6 +2158,7 @@ function NumbroFormatSelector({
|
|
|
2137
2158
|
direction: "column",
|
|
2138
2159
|
grow: true,
|
|
2139
2160
|
noWrap: true,
|
|
2161
|
+
ref,
|
|
2140
2162
|
children: /* @__PURE__ */ jsxs(Group, {
|
|
2141
2163
|
direction: "row",
|
|
2142
2164
|
grow: true,
|
|
@@ -2168,6 +2190,7 @@ function NumbroFormatSelector({
|
|
|
2168
2190
|
})
|
|
2169
2191
|
});
|
|
2170
2192
|
}
|
|
2193
|
+
const NumbroFormatSelector = React.forwardRef(_NumbroFormatSelector);
|
|
2171
2194
|
function YAxisField({
|
|
2172
2195
|
control,
|
|
2173
2196
|
index: index2,
|
|
@@ -2480,11 +2503,11 @@ const marks = [{
|
|
|
2480
2503
|
label: "bold",
|
|
2481
2504
|
value: 100
|
|
2482
2505
|
}];
|
|
2483
|
-
function
|
|
2506
|
+
function _MantineFontWeightSlider({
|
|
2484
2507
|
label,
|
|
2485
2508
|
value,
|
|
2486
2509
|
onChange
|
|
2487
|
-
}) {
|
|
2510
|
+
}, ref) {
|
|
2488
2511
|
var _a, _b;
|
|
2489
2512
|
const [mark, setMark] = React.useState((_b = (_a = marks.find((m2) => m2.label === value)) == null ? void 0 : _a.value) != null ? _b : marks[0].value);
|
|
2490
2513
|
React.useEffect(() => {
|
|
@@ -2506,15 +2529,17 @@ function MantineFontWeightSlider({
|
|
|
2506
2529
|
value: mark,
|
|
2507
2530
|
onChange: setMark,
|
|
2508
2531
|
step: 25,
|
|
2509
|
-
placeholder: "Pick a font size"
|
|
2532
|
+
placeholder: "Pick a font size",
|
|
2533
|
+
ref
|
|
2510
2534
|
})]
|
|
2511
2535
|
});
|
|
2512
2536
|
}
|
|
2513
|
-
|
|
2537
|
+
const MantineFontWeightSlider = React.forwardRef(_MantineFontWeightSlider);
|
|
2538
|
+
function _TextArrayInput({
|
|
2514
2539
|
label,
|
|
2515
2540
|
value,
|
|
2516
2541
|
onChange
|
|
2517
|
-
}) {
|
|
2542
|
+
}, ref) {
|
|
2518
2543
|
const [values, setValues] = React.useState(Array.isArray(value) ? [...value] : []);
|
|
2519
2544
|
const add = React.useCallback(() => {
|
|
2520
2545
|
setValues((s) => [...s, ""]);
|
|
@@ -2534,6 +2559,7 @@ function TextArrayInput({
|
|
|
2534
2559
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2535
2560
|
children: [/* @__PURE__ */ jsxs(Group, {
|
|
2536
2561
|
position: "left",
|
|
2562
|
+
ref,
|
|
2537
2563
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
2538
2564
|
children: label
|
|
2539
2565
|
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
@@ -2577,11 +2603,12 @@ function TextArrayInput({
|
|
|
2577
2603
|
})]
|
|
2578
2604
|
});
|
|
2579
2605
|
}
|
|
2580
|
-
|
|
2606
|
+
const TextArrayInput = React.forwardRef(_TextArrayInput);
|
|
2607
|
+
function _ColorArrayInput({
|
|
2581
2608
|
label,
|
|
2582
2609
|
value,
|
|
2583
2610
|
onChange
|
|
2584
|
-
}) {
|
|
2611
|
+
}, ref) {
|
|
2585
2612
|
const [values, setValues] = React.useState(Array.isArray(value) ? [...value] : []);
|
|
2586
2613
|
const add = React.useCallback(() => {
|
|
2587
2614
|
setValues((s) => [...s, ""]);
|
|
@@ -2605,6 +2632,7 @@ function ColorArrayInput({
|
|
|
2605
2632
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2606
2633
|
children: [/* @__PURE__ */ jsxs(Group, {
|
|
2607
2634
|
position: "left",
|
|
2635
|
+
ref,
|
|
2608
2636
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
2609
2637
|
children: label
|
|
2610
2638
|
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
@@ -2648,6 +2676,7 @@ function ColorArrayInput({
|
|
|
2648
2676
|
})]
|
|
2649
2677
|
});
|
|
2650
2678
|
}
|
|
2679
|
+
const ColorArrayInput = React.forwardRef(_ColorArrayInput);
|
|
2651
2680
|
function VizStatsPanel({
|
|
2652
2681
|
conf,
|
|
2653
2682
|
setConf
|
|
@@ -3605,40 +3634,25 @@ function Panel({
|
|
|
3605
3634
|
},
|
|
3606
3635
|
children: /* @__PURE__ */ jsxs(Container, {
|
|
3607
3636
|
className: "panel-root",
|
|
3608
|
-
children: [/* @__PURE__ */ jsx(PanelTitleBar, {}), /* @__PURE__ */ jsx(
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
loading
|
|
3613
|
-
})
|
|
3637
|
+
children: [/* @__PURE__ */ jsx(PanelTitleBar, {}), /* @__PURE__ */ jsx(Viz, {
|
|
3638
|
+
viz,
|
|
3639
|
+
data,
|
|
3640
|
+
loading
|
|
3614
3641
|
})]
|
|
3615
3642
|
})
|
|
3616
3643
|
});
|
|
3617
3644
|
}
|
|
3618
3645
|
var index = "";
|
|
3619
|
-
const
|
|
3646
|
+
const ReactGridLayout$1 = WidthProvider(RGL);
|
|
3620
3647
|
function DashboardLayout({
|
|
3621
3648
|
panels,
|
|
3622
3649
|
setPanels,
|
|
3623
3650
|
className = "layout",
|
|
3624
|
-
cols = {
|
|
3625
|
-
lg: 12,
|
|
3626
|
-
md: 10,
|
|
3627
|
-
sm: 8,
|
|
3628
|
-
xs: 6,
|
|
3629
|
-
xxs: 4
|
|
3630
|
-
},
|
|
3631
3651
|
rowHeight = 10,
|
|
3632
3652
|
onRemoveItem,
|
|
3633
3653
|
isDraggable,
|
|
3634
|
-
isResizable
|
|
3635
|
-
setLocalCols,
|
|
3636
|
-
setBreakpoint
|
|
3654
|
+
isResizable
|
|
3637
3655
|
}) {
|
|
3638
|
-
const onBreakpointChange = (breakpoint, localCols) => {
|
|
3639
|
-
setBreakpoint(breakpoint);
|
|
3640
|
-
setLocalCols(localCols);
|
|
3641
|
-
};
|
|
3642
3656
|
const onLayoutChange = React.useCallback((currentLayout) => {
|
|
3643
3657
|
const m2 = /* @__PURE__ */ new Map();
|
|
3644
3658
|
currentLayout.forEach((_a) => {
|
|
@@ -3654,11 +3668,9 @@ function DashboardLayout({
|
|
|
3654
3668
|
}));
|
|
3655
3669
|
setPanels(newPanels);
|
|
3656
3670
|
}, [panels, setPanels]);
|
|
3657
|
-
return /* @__PURE__ */ jsx(
|
|
3658
|
-
onBreakpointChange,
|
|
3671
|
+
return /* @__PURE__ */ jsx(ReactGridLayout$1, {
|
|
3659
3672
|
onLayoutChange,
|
|
3660
3673
|
className,
|
|
3661
|
-
cols,
|
|
3662
3674
|
rowHeight,
|
|
3663
3675
|
isDraggable,
|
|
3664
3676
|
isResizable,
|
|
@@ -4416,11 +4428,13 @@ function Dashboard({
|
|
|
4416
4428
|
context,
|
|
4417
4429
|
dashboard,
|
|
4418
4430
|
update,
|
|
4419
|
-
className = "dashboard"
|
|
4431
|
+
className = "dashboard",
|
|
4432
|
+
config
|
|
4420
4433
|
}) {
|
|
4434
|
+
if (APIClient.baseURL !== config.apiBaseURL) {
|
|
4435
|
+
APIClient.baseURL = config.apiBaseURL;
|
|
4436
|
+
}
|
|
4421
4437
|
const [layoutFrozen, freezeLayout] = React.useState(false);
|
|
4422
|
-
const [breakpoint, setBreakpoint] = React.useState();
|
|
4423
|
-
const [localCols, setLocalCols] = React.useState();
|
|
4424
4438
|
const [panels, setPanels] = React.useState(dashboard.panels);
|
|
4425
4439
|
const [sqlSnippets, setSQLSnippets] = React.useState(dashboard.definition.sqlSnippets);
|
|
4426
4440
|
const [dataSources, setDataSources] = React.useState(dashboard.definition.dataSources);
|
|
@@ -4508,31 +4522,21 @@ function Dashboard({
|
|
|
4508
4522
|
setPanels,
|
|
4509
4523
|
isDraggable: inLayoutMode,
|
|
4510
4524
|
isResizable: inLayoutMode,
|
|
4511
|
-
onRemoveItem: removePanelByID
|
|
4512
|
-
setLocalCols,
|
|
4513
|
-
setBreakpoint
|
|
4525
|
+
onRemoveItem: removePanelByID
|
|
4514
4526
|
})]
|
|
4515
4527
|
})
|
|
4516
4528
|
})
|
|
4517
4529
|
})
|
|
4518
4530
|
});
|
|
4519
4531
|
}
|
|
4520
|
-
const
|
|
4532
|
+
const ReactGridLayout = WidthProvider(RGL);
|
|
4521
4533
|
function ReadOnlyDashboardLayout({
|
|
4522
4534
|
panels,
|
|
4523
4535
|
className = "layout",
|
|
4524
|
-
cols = {
|
|
4525
|
-
lg: 12,
|
|
4526
|
-
md: 10,
|
|
4527
|
-
sm: 8,
|
|
4528
|
-
xs: 6,
|
|
4529
|
-
xxs: 4
|
|
4530
|
-
},
|
|
4531
4536
|
rowHeight = 10
|
|
4532
4537
|
}) {
|
|
4533
|
-
return /* @__PURE__ */ jsx(
|
|
4538
|
+
return /* @__PURE__ */ jsx(ReactGridLayout, {
|
|
4534
4539
|
className,
|
|
4535
|
-
cols,
|
|
4536
4540
|
rowHeight,
|
|
4537
4541
|
isDraggable: false,
|
|
4538
4542
|
isResizable: false,
|
|
@@ -4554,8 +4558,12 @@ function ReadOnlyDashboardLayout({
|
|
|
4554
4558
|
function ReadOnlyDashboard({
|
|
4555
4559
|
context,
|
|
4556
4560
|
dashboard,
|
|
4557
|
-
className = "dashboard"
|
|
4561
|
+
className = "dashboard",
|
|
4562
|
+
config
|
|
4558
4563
|
}) {
|
|
4564
|
+
if (APIClient.baseURL !== config.apiBaseURL) {
|
|
4565
|
+
APIClient.baseURL = config.apiBaseURL;
|
|
4566
|
+
}
|
|
4559
4567
|
const definition = React.useMemo(() => __spreadProps(__spreadValues({}, dashboard.definition), {
|
|
4560
4568
|
setSQLSnippets: () => {
|
|
4561
4569
|
},
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(y,v){typeof exports=="object"&&typeof module!="undefined"?v(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("ahooks"),require("axios"),require("tabler-icons-react"),require("@mantine/rte"),require("@mantine/hooks"),require("echarts-for-react/lib/core"),require("echarts/core"),require("echarts/charts"),require("echarts/renderers"),require("echarts/components"),require("numbro"),require("echarts-gl"),require("react-hook-form"),require("@mantine/form"),require("@mantine/prism")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","ahooks","axios","tabler-icons-react","@mantine/rte","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts/components","numbro","echarts-gl","react-hook-form","@mantine/form","@mantine/prism"],v):(y=typeof globalThis!="undefined"?globalThis:y||self,v(y.dashboard={},y.React,y._,y["react-grid-layout"],y["@mantine/core"],y.ahooks,y.axios,y["tabler-icons-react"],y["@mantine/rte"],y["@mantine/hooks"],y["echarts-for-react/lib/core"],y["echarts/core"],y["echarts/charts"],y["echarts/renderers"],y["echarts/components"],y.numbro,y["echarts-gl"],y["react-hook-form"],y["@mantine/form"],y["@mantine/prism"]))})(this,function(y,v,G,D,r,me,ct,S,Ie,k,pt,ft,ne,re,N,mt,cr,w,E,R){"use strict";var sr=Object.defineProperty,ur=Object.defineProperties;var dr=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var ze=(y,v,G)=>v in y?sr(y,v,{enumerable:!0,configurable:!0,writable:!0,value:G}):y[v]=G,f=(y,v)=>{for(var G in v||(v={}))st.call(v,G)&&ze(y,G,v[G]);if(fe)for(var G of fe(v))ut.call(v,G)&&ze(y,G,v[G]);return y},z=(y,v)=>ur(y,dr(v));var I=(y,v)=>{var G={};for(var D in y)st.call(y,D)&&v.indexOf(D)<0&&(G[D]=y[D]);if(y!=null&&fe)for(var D of fe(y))v.indexOf(D)<0&&ut.call(y,D)&&(G[D]=y[D]);return G};var dt=(y,v,G)=>(ze(y,typeof v!="symbol"?v+"":v,G),G);function W(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function ht(e){if(e&&e.__esModule)return e;var n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(i){if(i!=="default"){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var c=W(v),_=W(G),De=W(D),xt=W(ct),gt=W(Ie),ie=W(pt),B=ht(ft),K=W(mt),L=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(L||{});const bt={layoutFrozen:!1,freezeLayout:()=>{},mode:L.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},q=c.default.createContext(bt),J={baseURL:"http://localhost:31200",getRequest(e){return(n,i,o={})=>{const l=f({"X-Requested-With":"XMLHttpRequest","Content-Type":o.string?"application/x-www-form-urlencoded":"application/json"},o.headers),s={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?i:o.params,headers:l};return e==="POST"&&(s.data=o.string?JSON.stringify(i):i),xt.default(s).then(a=>a.data).catch(a=>Promise.reject(a))}}};function Pe(e,n){const i=Object.keys(n),o=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...o)}catch(l){throw i.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):l}}function yt(e,n){const i=n.sqlSnippets.reduce((o,l)=>(o[l.key]=Pe(l.value,e),o),{});return _.default.merge({},i,e)}const Le=({context:e,definitions:n,title:i,dataSource:o})=>async()=>{if(!o||!o.sql)return[];const{type:l,key:s,sql:a}=o,u=a.includes("$");try{const d=yt(e,n),x=Pe(a,d);return u&&(console.groupCollapsed(`Final SQL for: ${i}`),console.log(x),console.groupEnd()),await J.getRequest("POST")("/query",{type:l,key:s,sql:x})}catch(d){return console.error(d),[]}};async function St(){try{return await J.getRequest("GET")("/query/sources",{})}catch(e){return console.error(e),{}}}const Ae={},Ct=Ae,Q=c.default.createContext(Ae),wt={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},dataSourceID:"",setDataSourceID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},A=c.default.createContext(wt),vt={sqlSnippets:[],setSQLSnippets:()=>{},dataSources:[],setDataSources:()=>{}},O=c.default.createContext(vt);var oe={exports:{}},le={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var _t=c.default,zt=Symbol.for("react.element"),It=Symbol.for("react.fragment"),Dt=Object.prototype.hasOwnProperty,Pt=_t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0};function Oe(e,n,i){var o,l={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(o in n)Dt.call(n,o)&&!At.hasOwnProperty(o)&&(l[o]=n[o]);if(e&&e.defaultProps)for(o in n=e.defaultProps,n)l[o]===void 0&&(l[o]=n[o]);return{$$typeof:zt,type:e,key:s,ref:a,props:l,_owner:Pt.current}}ie.Fragment=It,ie.jsx=Oe,ie.jsxs=Oe,re.exports=ie;const t=re.exports.jsx,p=re.exports.jsxs,K=re.exports.Fragment;function ke({position:e,trigger:n="click"}){const{freezeLayout:i}=c.default.useContext($),[o,l]=c.default.useState(!1),{description:s}=c.default.useContext(O);if(c.default.useEffect(()=>{i(o)},[o]),!s||s==="<p><br></p>")return null;const a=n==="click"?t(r.Tooltip,{label:"Click to see description",openDelay:500,children:t(S.InfoCircle,{size:20,onClick:()=>l(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:o,onClose:()=>l(!1),withCloseButton:!0,withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,children:t(gt.default,{readOnly:!0,value:s,onChange:z.default.noop,sx:{border:"none"}})})}function Lt(){const{description:e,setDescription:n}=c.default.useContext(O),[i,o]=c.default.useState(e),l=e!==i,s=c.default.useCallback(()=>{!l||n(i)},[l,i]);return p(r.Group,{direction:"column",sx:{flexGrow:1},children:[p(r.Group,{align:"end",children:[t(r.Text,{children:"Description"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(De.RichTextEditor,{value:i,onChange:o,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class fe extends c.default.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t("h1",{children:"Something went wrong."}):this.props.children}}function Mt(){const{title:e}=c.default.useContext(O);return t(fe,{children:p(r.Group,{direction:"column",grow:!0,noWrap:!0,mx:"auto",mt:"xl",p:"5px",spacing:"xs",sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px",flexGrow:0,flexShrink:0},children:[t(r.Group,{children:t(ke,{position:"bottom",trigger:"hover"})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:e})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),t(r.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function Ot(){const{title:e,setTitle:n}=c.default.useContext(O),[i,o]=E.useInputState(e),l=e!==i,s=c.default.useCallback(()=>{!l||n(i)},[l,i]);return t(r.TextInput,{value:i,onChange:o,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function kt({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[p(r.Group,{grow:!0,direction:"column",sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[t(Ot,{}),t(Lt,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Mt,{})})]})}function Ee({id:e}){const n=c.default.useContext(k),i=c.default.useContext(Q),o=c.default.useMemo(()=>n.dataSources.find(u=>u.id===e),[n.dataSources,e]),{data:l=[],loading:s,refresh:a}=pe.useRequest(Le({context:i,definitions:n,title:e,dataSource:o}),{refreshDeps:[i,n,o]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):l.length===0?t(r.Table,{}):p(r.Group,{my:"xl",direction:"column",grow:!0,sx:{border:"1px solid #eee"},children:[p(r.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(r.Group,{position:"left",children:[t(r.Text,{weight:500,children:"Preview Data"}),l.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",l.length]})]}),t(r.ActionIcon,{mr:15,variant:"hover",color:"blue",disabled:s,onClick:a,children:t(S.Refresh,{size:15})})]}),p(r.Table,{children:[t("thead",{children:t("tr",{children:Object.keys(l==null?void 0:l[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:l.slice(0,10).map((u,d)=>t("tr",{children:Object.values(u).map((x,m)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:x})})},`${x}--${m}`))},`row-${d}`))})]})]})}function Et({}){const{dataSources:e}=c.default.useContext(k),{dataSourceID:n,setDataSourceID:i,data:o,loading:l}=c.default.useContext(O),s=c.default.useMemo(()=>e.map(a=>({value:a.id,label:a.id})),[e]);return p(r.Group,{direction:"column",grow:!0,noWrap:!0,children:[p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Data Source"}),t(r.Select,{data:s,value:n,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),t(Ee,{id:n})]})}V.use([ee.SunburstChart,te.CanvasRenderer]);const qt={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function $t({conf:e,data:n,width:i,height:o}){const h=e,{label_field:l="name",value_field:s="value"}=h,a=D(h,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(g=>({name:g[l],value:Number(g[s])})),[n,l,s]),d=c.default.useMemo(()=>{var g,y;return(y=(g=z.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?y:1},[u]),x=c.default.useMemo(()=>({series:{label:{formatter:({name:g,value:y})=>y/d<.2?" ":g}}}),[d]),m=z.default.merge({},qt,x,a,{series:{data:u}});return t(ne.default,{echarts:V,option:m,style:{width:i,height:o}})}V.use([ee.BarChart,ee.LineChart,W.GridComponent,W.LegendComponent,W.TooltipComponent,te.CanvasRenderer]);const Bt={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:30,left:15,right:15,bottom:30,containLabel:!0}};function Ft({conf:e,data:n,width:i,height:o}){const l=c.default.useMemo(()=>{var x;const s=e.y_axes.reduce((m,{label_formatter:h},g)=>(m[g]=function(C){const w=typeof C=="object"?C.value:C;if(!h)return w;try{return Y.default(w).format(h)}catch(G){return console.error(G),w}},m),{default:({value:m})=>m}),a=e.series.reduce((m,{yAxisIndex:h,name:g})=>(m[g]=h,m),{}),u=e.series.map(w=>{var G=w,{y_axis_data_key:m,yAxisIndex:h,label_position:g,name:y}=G,C=D(G,["y_axis_data_key","yAxisIndex","label_position","name"]);return f({data:n.map(L=>L[m]),label:{show:!!g,position:g,formatter:s[h!=null?h:"default"]},name:y,yAxisIndex:h},C)}),d={xAxis:{data:n.map(m=>m[e.x_axis_data_key]),name:(x=e.x_axis_name)!=null?x:""},yAxis:e.y_axes.map((y,g)=>{var C=y,{label_formatter:m}=C,h=D(C,["label_formatter"]);var w;return I(f({},h),{axisLabel:{show:!0,formatter:(w=s[g])!=null?w:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(m){const h=Array.isArray(m)?m:[m];if(h.length===0)return"";const g=h.map(({seriesName:y,value:C})=>{var P;if(!y)return C;const w=a[y],G=(P=s[w])!=null?P:s.default;return`${y}: ${G({value:C})}`});return g.unshift(`<strong>${h[0].name}</strong>`),g.join("<br />")}}};return z.default.merge({},Bt,d)},[e,n]);return!i||!o?null:t(ne.default,{echarts:V,option:l,style:{width:i,height:o}})}var j=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(j||{});function Vt({value:e}){return t(r.Text,{component:"span",children:e})}function jt({value:e}){return t(r.Text,{component:"span",children:e})}function Nt({value:e}){const n=Y.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Rt({value:e}){const n=Y.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function Wt({value:e,type:n}){switch(n){case j.string:return t(Vt,{value:e});case j.eloc:return t(jt,{value:e});case j.number:return t(Nt,{value:e});case j.percentage:return t(Rt,{value:e})}}function Qt({conf:e,data:n=[],width:i,height:o}){const m=e,{id_field:l,use_raw_columns:s,columns:a}=m,u=D(m,["id_field","use_raw_columns","columns"]),d=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(h=>h.label),[s,a,n]),x=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(h=>({label:h,value_field:h,value_type:j.string})):a,[s,a,n]);return p(r.Table,I(f({sx:{maxHeight:o}},u),{children:[t("thead",{children:t("tr",{children:d.map(h=>t("th",{children:h},h))})}),t("tbody",{children:n.slice(0,30).map((h,g)=>t("tr",{children:x.map(({value_field:y,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Wt,{value:h[y],type:C})})},`${y}--${h[y]}`))},l?h[l]:`row-${g}`))}),n.length>100&&t("tfoot",{children:t("tr",{children:t("td",{colSpan:d.length,children:t(r.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]}))}function Ut(e,n={}){const i=I(f({},n),{numbro:Y.default}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}catch(s){return s.message}}function Jt({conf:{paragraphs:e},data:n}){return t(K,{children:e.map((a,s)=>{var u=a,{template:i,size:o}=u,l=D(u,["template","size"]);return t(r.Text,I(f({},l),{sx:{fontSize:o},children:Ut(i,n[0])}),`${i}---${s}`)})})}V.use([W.GridComponent,W.VisualMapComponent,W.LegendComponent,W.TooltipComponent,te.CanvasRenderer]);function Yt({conf:e,data:n,width:i,height:o}){const h=e,{x_axis_data_key:l,y_axis_data_key:s,z_axis_data_key:a}=h,u=D(h,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),d=c.default.useMemo(()=>z.default.minBy(n,g=>g[a])[a],[n,a]),x=c.default.useMemo(()=>z.default.maxBy(n,g=>g[a])[a],[n,a]),m=I(f({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:x,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}}},u),{series:[{type:"bar3D",wireframe:{},data:n.map(g=>[g[l],g[s],g[a]])}]});return t(ne.default,{echarts:V,option:m,style:{width:i,height:o}})}var cr="";V.use([ee.PieChart,te.CanvasRenderer]);const Kt={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
|
|
10
|
-
{percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function Xt({conf:e,data:n,width:i,height:o}){const m=e,{label_field:l="name",value_field:s="value"}=m,a=D(m,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(h=>({name:h[l],value:Number(h[s])})),[n,l,s]),d=c.default.useMemo(()=>({series:{labelLayout:function(h){const g=h.labelRect.x<i/2,y=h.labelLinePoints;return y[2][0]=g?h.labelRect.x:h.labelRect.x+h.labelRect.width,{labelLinePoints:y}}}}),[i]),x=z.default.merge({},Kt,d,a,{series:{data:u}});return t(ne.default,{echarts:V,option:x,style:{width:i,height:o}})}var qe=function(){};const Zt=(e,n,i)=>Math.min(Math.max(i,e),n),$e=(e,n,i)=>{const o=n-e;return o===0?1:(i-e)/o},me=(e,n,i)=>-i*e+i*n+e,Be=(e,n)=>i=>Math.max(Math.min(i,n),e),X=e=>e%1?Number(e.toFixed(5)):e,oe=/(-)?([\d]*\.?[\d])+/g,he=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Ht=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function Z(e){return typeof e=="string"}const le={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Fe=Object.assign(Object.assign({},le),{transform:Be(0,1)});Object.assign(Object.assign({},le),{default:1});const H=(e=>({test:n=>Z(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},H),{parse:e=>H.parse(e)/100,transform:e=>H.transform(e*100)});const xe=(e,n)=>i=>Boolean(Z(i)&&Ht.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Ve=(e,n,i)=>o=>{if(!Z(o))return o;const[l,s,a,u]=o.match(oe);return{[e]:parseFloat(l),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},U={test:xe("hsl","hue"),parse:Ve("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:o=1})=>"hsla("+Math.round(e)+", "+H.transform(X(n))+", "+H.transform(X(i))+", "+X(Fe.transform(o))+")"},en=Be(0,255),ge=Object.assign(Object.assign({},le),{transform:e=>Math.round(en(e))}),N={test:xe("rgb","red"),parse:Ve("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:o=1})=>"rgba("+ge.transform(e)+", "+ge.transform(n)+", "+ge.transform(i)+", "+X(Fe.transform(o))+")"};function tn(e){let n="",i="",o="",l="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),o=e.substr(5,2),l=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),o=e.substr(3,1),l=e.substr(4,1),n+=n,i+=i,o+=o,l+=l),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:l?parseInt(l,16)/255:1}}const be={test:xe("#"),parse:tn,transform:N.transform},ae={test:e=>N.test(e)||be.test(e)||U.test(e),parse:e=>N.test(e)?N.parse(e):U.test(e)?U.parse(e):be.parse(e),transform:e=>Z(e)?e:e.hasOwnProperty("red")?N.transform(e):U.transform(e)},je="${c}",Ne="${n}";function nn(e){var n,i,o,l;return isNaN(e)&&Z(e)&&((i=(n=e.match(oe))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((l=(o=e.match(he))===null||o===void 0?void 0:o.length)!==null&&l!==void 0?l:0)>0}function Re(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const o=e.match(he);o&&(i=o.length,e=e.replace(he,je),n.push(...o.map(ae.parse)));const l=e.match(oe);return l&&(e=e.replace(oe,Ne),n.push(...l.map(le.parse))),{values:n,numColors:i,tokenised:e}}function We(e){return Re(e).values}function Qe(e){const{values:n,numColors:i,tokenised:o}=Re(e),l=n.length;return s=>{let a=o;for(let u=0;u<l;u++)a=a.replace(u<i?je:Ne,u<i?ae.transform(s[u]):X(s[u]));return a}}const rn=e=>typeof e=="number"?0:e;function on(e){const n=We(e);return Qe(e)(n.map(rn))}const Ue={test:nn,parse:We,createTransformer:Qe,getAnimatableNone:on};function ye(e,n,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(n-e)*6*i:i<1/2?n:i<2/3?e+(n-e)*(2/3-i)*6:e}function Je({hue:e,saturation:n,lightness:i,alpha:o}){e/=360,n/=100,i/=100;let l=0,s=0,a=0;if(!n)l=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,d=2*i-u;l=ye(d,u,e+1/3),s=ye(d,u,e),a=ye(d,u,e-1/3)}return{red:Math.round(l*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:o}}const ln=(e,n,i)=>{const o=e*e,l=n*n;return Math.sqrt(Math.max(0,i*(l-o)+o))},an=[be,N,U],Ye=e=>an.find(n=>n.test(e)),Ke=(e,n)=>{let i=Ye(e),o=Ye(n),l=i.parse(e),s=o.parse(n);i===U&&(l=Je(l),i=N),o===U&&(s=Je(s),o=N);const a=Object.assign({},l);return u=>{for(const d in a)d!=="alpha"&&(a[d]=ln(l[d],s[d],u));return a.alpha=me(l.alpha,s.alpha,u),i.transform(a)}},sn=e=>typeof e=="number",un=(e,n)=>i=>n(e(i)),Xe=(...e)=>e.reduce(un);function Ze(e,n){return sn(e)?i=>me(e,n,i):ae.test(e)?Ke(e,n):tt(e,n)}const He=(e,n)=>{const i=[...e],o=i.length,l=e.map((s,a)=>Ze(s,n[a]));return s=>{for(let a=0;a<o;a++)i[a]=l[a](s);return i}},dn=(e,n)=>{const i=Object.assign(Object.assign({},e),n),o={};for(const l in i)e[l]!==void 0&&n[l]!==void 0&&(o[l]=Ze(e[l],n[l]));return l=>{for(const s in o)i[s]=o[s](l);return i}};function et(e){const n=Ue.parse(e),i=n.length;let o=0,l=0,s=0;for(let a=0;a<i;a++)o||typeof n[a]=="number"?o++:n[a].hue!==void 0?s++:l++;return{parsed:n,numNumbers:o,numRGB:l,numHSL:s}}const tt=(e,n)=>{const i=Ue.createTransformer(n),o=et(e),l=et(n);return o.numHSL===l.numHSL&&o.numRGB===l.numRGB&&o.numNumbers>=l.numNumbers?Xe(He(o.parsed,l.parsed),i):a=>`${a>0?n:e}`},cn=(e,n)=>i=>me(e,n,i);function pn(e){if(typeof e=="number")return cn;if(typeof e=="string")return ae.test(e)?Ke:tt;if(Array.isArray(e))return He;if(typeof e=="object")return dn}function fn(e,n,i){const o=[],l=i||pn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=l(e[a],e[a+1]);if(n){const d=Array.isArray(n)?n[a]:n;u=Xe(d,u)}o.push(u)}return o}function mn([e,n],[i]){return o=>i($e(e,n,o))}function hn(e,n){const i=e.length,o=i-1;return l=>{let s=0,a=!1;if(l<=e[0]?a=!0:l>=e[o]&&(s=o-1,a=!0),!a){let d=1;for(;d<i&&!(e[d]>l||d===o);d++);s=d-1}const u=$e(e[s],e[s+1],l);return n[s](u)}}function xn(e,n,{clamp:i=!0,ease:o,mixer:l}={}){const s=e.length;qe(s===n.length),qe(!o||!Array.isArray(o)||o.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=fn(n,o,l),u=s===2?mn(e,a):hn(e,a);return i?d=>u(Zt(e[0],e[s-1],d)):u}class gn{constructor({valueRange:n,colorRange:i}){dt(this,"mapper");this.mapper=xn(n,i)}getColor(n){return this.mapper(n)}}function bn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new gn(e),o=n[e.valueField];return i.getColor(o)}return"black"}function yn(s){var a=s,{conf:u}=a,d=u,{content:e,size:n,color:i}=d,o=D(d,["content","size","color"]),{data:l}=a;const x=c.default.useMemo(()=>bn(i,l[0]),[i,l]),m=c.default.useMemo(()=>{var P;const{prefix:h,postfix:g,data_field:y,formatter:C}=e,w=(P=l==null?void 0:l[0])==null?void 0:P[y];return[h,Y.default(w).format(C),g].join(" ")},[e,l]);return t(r.Text,I(f({},o),{color:x,sx:{fontSize:n},children:m}))}function Sn(e,n,i,o){const l={width:e,height:n,data:i,conf:o.conf};switch(o.type){case"sunburst":return t($t,f({},l));case"line-bar":case"cartesian":return t(Ft,f({},l));case"table":return t(Qt,f({},l));case"text":return t(Jt,f({},l));case"stats":return t(yn,f({},l));case"bar-3d":return t(Yt,f({},l));case"pie":return t(Xt,f({},l));default:return null}}function nt({viz:e,data:n,loading:i}){const{ref:o,width:l,height:s}=E.useElementSize(),a=c.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:o,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:o,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&Sn(l,s,n,e)]})}function Cn({}){const{data:e,loading:n,viz:i}=c.default.useContext(O);return t(fe,{children:t(nt,{viz:i,data:e,loading:n})})}function vn({conf:e,setConf:n}){const i=z.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},e),{control:o,handleSubmit:l,formState:s}=v.useForm({defaultValues:i});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:l(n),children:[t(r.Text,{children:"X Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"x_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"xAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Y Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"y_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"yAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Z Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"z_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"zAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(r.Button,{color:"blue",type:"submit",children:[t(S.DeviceFloppy,{size:20}),t(r.Text,{ml:"md",children:"Save"})]})})]})})}function Se({value:e,onChange:n}){const i=r.useMantineTheme(),o=c.default.useMemo(()=>Object.entries(i.colors).map(([s,a])=>({label:s,value:a[6]})),[i]),l=c.default.useMemo(()=>o.some(s=>s.value===e),[e,o]);return p(r.Group,{position:"apart",spacing:"xs",children:[t(r.TextInput,{placeholder:"Set any color",value:l?"":e,onChange:s=>n(s.currentTarget.value),rightSection:t(r.ColorSwatch,{color:l?"transparent":e,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"100%",flexGrow:1}}),t(r.Text,{sx:{flexGrow:0},children:"or"}),t(r.Select,{data:o,value:e,onChange:n,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:t(r.ColorSwatch,{color:l?e:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}const wn=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function Tn({control:e,index:n,remove:i,seriesItem:o,yAxisOptions:l}){const s=o.type;return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(v.Controller,{name:`series.${n}.type`,control:e,render:({field:a})=>t(r.SegmentedControl,f({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter",disabled:!0},{label:"Boxplot",value:"boxplot",disabled:!0}]},a))})}),t(v.Controller,{name:`series.${n}.name`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},a))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(v.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Value key",required:!0,sx:{flex:1}},a))}),t(v.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:x=>{var{field:m}=x,h=m,{value:a,onChange:u}=h,d=D(h,["value","onChange"]);var g;return t(r.Select,I(f({label:"Y Axis",data:l,disabled:l.length===0},d),{value:(g=a==null?void 0:a.toString())!=null?g:"",onChange:y=>{if(!y){u(0);return}u(Number(y))},sx:{flex:1}}))}})]}),s==="bar"&&p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(v.Controller,{name:`series.${n}.stack`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},a))}),t(v.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Bar Width",sx:{flexGrow:1}},a))})]}),t(v.Controller,{name:`series.${n}.label_position`,control:e,render:({field:a})=>t(r.Select,f({label:"Label Position",data:wn},a))}),p(r.Group,{direction:"column",grow:!0,spacing:4,children:[t(r.Text,{size:"sm",children:"Color"}),t(v.Controller,{name:`series.${n}.color`,control:e,render:({field:a})=>t(Se,f({},a))})]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},n)}function Gn({control:e,watch:n,getValues:i}){const{fields:o,append:l,remove:s}=v.useFieldArray({control:e,name:"series"}),a=n("y_axes"),u=o.map((m,h)=>f(f({},m),a[h])),d=()=>l({type:"bar",name:E.randomId(),showSymbol:!1,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000"}),x=c.default.useMemo(()=>i().y_axes.map(({name:m},h)=>({label:m,value:h.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),u.map((m,h)=>t(Tn,{control:e,index:h,remove:s,seriesItem:m,yAxisOptions:x})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:d,children:"Add a Series"})})]})}const rt={mantissa:0,output:"number"};function it({value:e,onChange:n}){const i=s=>{n(I(f({},e),{output:s}))},o=s=>{const a=s===0?!1:e.trimMantissa;n(I(f({},e),{mantissa:s,trimMantissa:a}))},l=s=>{n(I(f({},e),{trimMantissa:s.currentTarget.checked}))};return t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:p(r.Group,{direction:"row",grow:!0,children:[t(r.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i}),t(r.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:o}),t(r.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:l,disabled:e.mantissa===0})]})})}function _n({control:e,index:n,remove:i}){return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"row",grow:!0,noWrap:!0,children:t(v.Controller,{name:`y_axes.${n}.name`,control:e,render:({field:o})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},o))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(v.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:o})=>t(it,f({},o))})}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},disabled:n===0,children:t(S.Trash,{size:16})})]},n)}function zn({control:e,watch:n}){const{fields:i,append:o,remove:l}=v.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((d,x)=>f(f({},d),s[x])),u=()=>o({name:"",label_formatter:rt});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((d,x)=>t(_n,{control:e,index:x,remove:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function In(e){function n({type:i,name:o,showSymbol:l,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:d="1",color:x="black",barWidth:m="30"}){return{type:i,name:o,showSymbol:l,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:d,color:x,barWidth:m}}return e.map(n)}function Dn({conf:e,setConf:n}){const h=e,{series:i,y_axes:o}=h,l=D(h,["series","y_axes"]),s=c.default.useMemo(()=>{const C=l,{x_axis_name:g=""}=C,y=D(C,["x_axis_name"]);return f({series:In(i!=null?i:[]),x_axis_name:g,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:rt}]},y)},[i,l]);c.default.useEffect(()=>{!z.default.isEqual(e,s)&&n(s)},[e,s]);const{control:a,handleSubmit:u,watch:d,formState:{isDirty:x},getValues:m}=v.useForm({defaultValues:s});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u(n),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Chart Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!x,children:t(S.DeviceFloppy,{size:20})})]}),t(v.Controller,{name:"x_axis_data_key",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",mb:"lg",label:"X Axis Data Key"},g))}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:t(v.Controller,{name:"x_axis_name",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",label:"X Axis Name"},g))})}),t(zn,{control:a,watch:d}),t(Gn,{control:a,watch:d,getValues:m})]})})}function Pn({conf:{label_field:e,value_field:n},setConf:i}){const o=q.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Pie Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const se=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function ot({label:e,value:n,onChange:i}){var s,a;const[o,l]=c.default.useState((a=(s=se.find(u=>u.label===n))==null?void 0:s.value)!=null?a:se[0].value);return c.default.useEffect(()=>{const u=se.find(d=>d.value===o);u&&i(u.label)},[o]),p(r.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[t(r.Text,{children:e}),t(r.Slider,{label:null,marks:se,value:o,onChange:l,step:25,placeholder:"Pick a font size"})]})}function An({label:e,value:n,onChange:i}){const[o,l]=c.default.useState(Array.isArray(n)?[...n]:[]),s=c.default.useCallback(()=>{l(x=>[...x,""])},[l]),a=c.default.useCallback(x=>{l(m=>(m.splice(x,1),[...m]))},[l]),u=c.default.useMemo(()=>!z.default.isEqual(o,n),[o,n]),d=()=>{i(o.map(x=>x.toString()))};return p(K,{children:[p(r.Group,{position:"left",children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((x,m)=>t(r.TextInput,{value:x,onChange:h=>{const g=h.currentTarget.value;l(y=>(y.splice(m,1,g),[...y]))},rightSection:t(r.ActionIcon,{onClick:()=>a(m),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}function Ln({label:e,value:n,onChange:i}){const[o,l]=c.default.useState(Array.isArray(n)?[...n]:[]),s=c.default.useCallback(()=>{l(h=>[...h,""])},[l]),a=c.default.useCallback(h=>{l(g=>(g.splice(h,1),[...g]))},[l]),u=c.default.useMemo(()=>!z.default.isEqual(o,n),[o,n]),d=()=>{i(o.map(h=>h.toString()))},x=r.useMantineTheme(),m=c.default.useMemo(()=>Object.entries(x.colors).map(([h,g])=>g[6]),[x]);return p(K,{children:[p(r.Group,{position:"left",children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((h,g)=>t(r.ColorInput,{value:h,onChange:y=>{l(C=>(C.splice(g,1,y),[...C]))},swatches:m,rightSection:t(r.ActionIcon,{onClick:()=>a(g),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}function Mn({conf:e,setConf:n}){const i=z.default.merge({},{align:"center",size:"100px",weight:"bold",color:{type:"static",staticColor:"red"},content:{prefix:"",data_field:"",formatter:{output:"number",mantissa:0},postfix:""}},e),{control:o,handleSubmit:l,watch:s,formState:{isDirty:a}}=v.useForm({defaultValues:i}),u=s("color.type");return s("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:l(n),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Stats Configurations"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Accordion,{offsetIcon:!1,multiple:!0,initialState:{0:!0,2:!0},children:[t(r.Accordion.Item,{label:"Content",children:p(r.Group,{direction:"column",grow:!0,children:[p(r.Group,{direction:"row",grow:!0,children:[t(v.Controller,{name:"content.prefix",control:o,render:({field:d})=>t(r.TextInput,f({label:"Prefix",sx:{flexGrow:1}},d))}),t(v.Controller,{name:"content.data_field",control:o,render:({field:d})=>t(r.TextInput,f({label:"Data Field",required:!0,sx:{flexGrow:1}},d))}),t(v.Controller,{name:"content.postfix",control:o,render:({field:d})=>t(r.TextInput,f({label:"Postfix",sx:{flexGrow:1}},d))})]}),t(v.Controller,{name:"content.formatter",control:o,render:({field:d})=>t(it,f({},d))})]})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(v.Controller,{name:"size",control:o,render:({field:d})=>t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},d))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(v.Controller,{name:"weight",control:o,render:({field:d})=>t(ot,f({label:"Font Weight"},d))})})]}),t(r.Accordion.Item,{label:"Color",children:p(r.Group,{direction:"column",grow:!0,children:[t(v.Controller,{name:"color.type",control:o,render:({field:d})=>t(r.Select,f({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},d))}),u==="static"&&t(v.Controller,{name:"color.staticColor",control:o,render:({field:d})=>t(Se,f({},d))}),u==="continuous"&&p(K,{children:[t(v.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:d})=>t(r.TextInput,f({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},d))}),t(v.Controller,{name:"color.valueRange",control:o,render:({field:d})=>t(An,f({label:"Value Range"},d))}),t(v.Controller,{name:"color.colorRange",control:o,render:({field:d})=>t(Ln,f({label:"Color Range"},d))})]})]})})]})]})})}function On({conf:{label_field:e,value_field:n},setConf:i}){const o=q.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Sunburst Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const kn=Object.values(j).map(e=>({label:e,value:e}));function En({label:e,value:n,onChange:i,sx:o}){return t(r.Select,{label:e,data:kn,value:n,onChange:i,sx:o})}function qn(o){var l=o,{conf:s}=l,a=s,{columns:e}=a,n=D(a,["columns"]),{setConf:i}=l;const u=q.useForm({initialValues:f({id_field:"id",use_raw_columns:!0,columns:q.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),d=()=>u.addListItem("columns",{label:E.randomId(),value_field:"value",value_type:j.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Table Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({size:"md",mb:"lg",label:"ID Field"},u.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,f({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("horizontalSpacing"))),t(r.TextInput,f({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("fontSize")))}),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Other"}),p(r.Group,{position:"apart",grow:!0,children:[t(r.Switch,f({label:"Striped"},u.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,f({label:"Highlight on hover"},u.getInputProps("highlightOnHover",{type:"checkbox"})))]})]})]}),p(r.Group,{direction:"column",mt:"xs",spacing:"xs",grow:!0,p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.Switch,f({label:"Use Original Data Columns"},u.getInputProps("use_raw_columns",{type:"checkbox"}))),!u.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),u.values.columns.map((x,m)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[p(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[t(r.TextInput,f({label:"Label",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"label"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"value_field"))),t(En,f({label:"Value Type",sx:{flex:1}},u.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>u.removeListItem("columns",m),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},m)),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:d,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(F.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(u.values,null,2)})]})})}const lt=[{align:"center",size:"xl",weight:"bold",color:"black",template:"Time: ${new Date().toISOString()}"},{align:"center",size:"md",weight:"bold",color:"red",template:"Platform: ${navigator.userAgentData.platform}."}];function $n({conf:e,setConf:n}){var l;const i=q.useForm({initialValues:{paragraphs:q.formList((l=e.paragraphs)!=null?l:lt)}}),o=()=>i.addListItem("paragraphs",I(f({},lt[0]),{template:E.randomId()}));return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:i.onSubmit(n),children:[i.values.paragraphs.length===0&&t(r.Text,{color:"dimmed",align:"center",children:"Empty"}),p(r.Group,{position:"apart",mb:"xs",sx:{" + .mantine-Group-root":{marginTop:0}},children:[t(r.Text,{children:"Paragraphs"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),i.values.paragraphs.map((s,a)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},i.getListInputProps("paragraphs",a,"template"))),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Color"}),t(Se,f({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},i.getListInputProps("paragraphs",a,"size")))}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(ot,f({label:"Font Weight"},i.getListInputProps("paragraphs",a,"weight")))}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i.removeListItem("paragraphs",a),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},a)),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:o,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(F.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Ce=[{value:"text",label:"Text",Panel:$n},{value:"stats",label:"Stats",Panel:Mn},{value:"table",label:"Table",Panel:qn},{value:"sunburst",label:"Sunburst",Panel:On},{value:"bar-3d",label:"Bar Chart (3D)",Panel:vn},{value:"cartesian",label:"Cartesian Chart",Panel:Dn},{value:"pie",label:"Pie Chart",Panel:Pn}];function Bn(){const{viz:e,setViz:n}=c.default.useContext(O),[i,o]=E.useInputState(e.type),l=e.type!==i,s=c.default.useCallback(()=>{!l||n(x=>I(f({},x),{type:i}))},[l,i]),a=x=>{n(m=>I(f({},m),{conf:x}))},u=x=>{try{a(JSON.parse(x))}catch(m){console.error(m)}},d=c.default.useMemo(()=>{var x;return(x=Ce.find(m=>m.value===i))==null?void 0:x.Panel},[i,Ce]);return p(K,{children:[t(r.Select,{label:"Visualization",value:i,onChange:o,data:Ce,rightSection:t(r.ActionIcon,{disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})}),d&&t(d,{conf:e.conf,setConf:a}),!d&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:u})]})}function Fn({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[t(r.Group,{grow:!0,direction:"column",noWrap:!0,sx:{width:"40%",flexShrink:0,flexGrow:0},children:t(Bn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Cn,{})})]})}function Vn({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext($),{data:o,loading:l,viz:s,title:a}=c.default.useContext(O);return c.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:a,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%"}},padding:"md",children:p(r.Tabs,{initialTab:2,children:[p(r.Tabs.Tab,{label:"Data Source",children:[t(r.LoadingOverlay,{visible:l,exitTransitionDuration:0}),t(Et,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(kt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Fn,{})})]})})})}function jn({}){const[e,n]=c.default.useState(!1),i=()=>n(!0),o=()=>n(!1),{title:l,refreshData:s}=c.default.useContext(O),{inEditMode:a}=c.default.useContext($);return p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[t(r.Group,{children:t(ke,{})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:l})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"},children:p(r.Menu,{children:[t(r.Menu.Item,{onClick:s,icon:t(S.Refresh,{size:14}),children:"Refresh"}),a&&t(r.Menu.Item,{onClick:i,icon:t(S.Settings,{size:14}),children:"Settings"}),t(r.Divider,{}),t(r.Menu.Item,{color:"red",disabled:!0,icon:t(S.Trash,{size:14}),children:"Delete"})]})}),a&&t(Vn,{opened:e,close:o})]})}var fr="";function ve({viz:e,dataSourceID:n,title:i,description:o,update:l,layout:s,id:a}){const u=c.default.useContext(Q),d=c.default.useContext(k),[x,m]=c.default.useState(i),[h,g]=c.default.useState(o),[y,C]=c.default.useState(n),[w,G]=c.default.useState(e),P=c.default.useMemo(()=>{if(!!y)return d.dataSources.find(_e=>_e.id===y)},[y,d.dataSources]);c.default.useEffect(()=>{l==null||l({id:a,layout:s,title:x,description:h,dataSourceID:y,viz:w})},[x,h,P,w,a,s,y]);const{data:L=[],loading:ue,refresh:Te}=pe.useRequest(Le({context:u,definitions:d,title:x,dataSource:P}),{refreshDeps:[u,d,P]}),Ge=Te;return t(O.Provider,{value:{data:L,loading:ue,title:x,setTitle:m,description:h,setDescription:g,dataSourceID:y,setDataSourceID:C,viz:w,setViz:G,refreshData:Ge},children:p(r.Container,{className:"panel-root",children:[t(jn,{}),t(fe,{children:t(nt,{viz:w,data:L,loading:ue})})]})})}var mr="";const Nn=A.WidthProvider(A.Responsive);function at({panels:e,setPanels:n,className:i="layout",cols:o={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:l=10,onRemoveItem:s,isDraggable:a,isResizable:u,setLocalCols:d,setBreakpoint:x}){const m=(g,y)=>{x(g),d(y)},h=c.default.useCallback(g=>{const y=new Map;g.forEach(P=>{var L=P,{i:w}=L,G=D(L,["i"]);y.set(w,G)});const C=e.map(w=>I(f({},w),{layout:y.get(w.id)}));n(C)},[e,n]);return t(Nn,{onBreakpointChange:m,onLayoutChange:h,className:i,cols:o,rowHeight:l,isDraggable:a,isResizable:u,children:e.map((w,C)=>{var G=w,{id:g}=G,y=D(G,["id"]);return t("div",{"data-grid":y.layout,children:t(ve,I(f({id:g},y),{destroy:()=>s(g),update:P=>{n(L=>(L.splice(C,1,P),[...L]))}}))},g)})})}function we(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Rn({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:we(t(S.PlayerPlay,{size:20}),"Use"),value:M.Use},{label:we(t(S.Resize,{size:20}),"Layout"),value:M.Layout},{label:we(t(S.Paint,{size:20}),"Content"),value:M.Edit}]})}const Wn=`
|
|
9
|
+
*/var Tt=c.default,Gt=Symbol.for("react.element"),_t=Symbol.for("react.fragment"),zt=Object.prototype.hasOwnProperty,It=Tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Dt={key:!0,ref:!0,__self:!0,__source:!0};function Me(e,n,i){var o,l={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(o in n)zt.call(n,o)&&!Dt.hasOwnProperty(o)&&(l[o]=n[o]);if(e&&e.defaultProps)for(o in n=e.defaultProps,n)l[o]===void 0&&(l[o]=n[o]);return{$$typeof:Gt,type:e,key:s,ref:a,props:l,_owner:It.current}}le.Fragment=_t,le.jsx=Me,le.jsxs=Me,oe.exports=le;const t=oe.exports.jsx,p=oe.exports.jsxs,X=oe.exports.Fragment;function Oe({position:e,trigger:n="click"}){const{freezeLayout:i}=c.default.useContext(q),[o,l]=c.default.useState(!1),{description:s}=c.default.useContext(A);if(c.default.useEffect(()=>{i(o)},[o]),!s||s==="<p><br></p>")return null;const a=n==="click"?t(r.Tooltip,{label:"Click to see description",openDelay:500,children:t(S.InfoCircle,{size:20,onClick:()=>l(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:o,onClose:()=>l(!1),withCloseButton:!0,withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,children:t(gt.default,{readOnly:!0,value:s,onChange:_.default.noop,sx:{border:"none"}})})}function Pt(){const{description:e,setDescription:n}=c.default.useContext(A),[i,o]=c.default.useState(e),l=e!==i,s=c.default.useCallback(()=>{!l||n(i)},[l,i]);return p(r.Group,{direction:"column",sx:{flexGrow:1},children:[p(r.Group,{align:"end",children:[t(r.Text,{children:"Description"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(Ie.RichTextEditor,{value:i,onChange:o,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class ke extends c.default.Component{constructor(n){super(n),this.state={error:null}}componentDidCatch(n){this.setState({error:n})}render(){var n;if(this.state.error){const i=()=>{this.setState({error:null})};return p(r.Box,{children:[t(r.Text,{size:"xs",children:(n=this.state.error)==null?void 0:n.message}),t(r.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:i,children:"Retry"})]})}return this.props.children}}function Lt(){const{title:e}=c.default.useContext(A);return t(ke,{children:p(r.Group,{direction:"column",grow:!0,noWrap:!0,mx:"auto",mt:"xl",p:"5px",spacing:"xs",sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px",flexGrow:0,flexShrink:0},children:[t(r.Group,{children:t(Oe,{position:"bottom",trigger:"hover"})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:e})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),t(r.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function At(){const{title:e,setTitle:n}=c.default.useContext(A),[i,o]=k.useInputState(e),l=e!==i,s=c.default.useCallback(()=>{!l||n(i)},[l,i]);return t(r.TextInput,{value:i,onChange:o,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function Mt({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[p(r.Group,{grow:!0,direction:"column",sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[t(At,{}),t(Pt,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Lt,{})})]})}function Ee({id:e}){const n=c.default.useContext(O),i=c.default.useContext(Q),o=c.default.useMemo(()=>n.dataSources.find(u=>u.id===e),[n.dataSources,e]),{data:l=[],loading:s,refresh:a}=me.useRequest(Le({context:i,definitions:n,title:e,dataSource:o}),{refreshDeps:[i,n,o]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):l.length===0?t(r.Table,{}):p(r.Group,{my:"xl",direction:"column",grow:!0,sx:{border:"1px solid #eee"},children:[p(r.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(r.Group,{position:"left",children:[t(r.Text,{weight:500,children:"Preview Data"}),l.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",l.length]})]}),t(r.ActionIcon,{mr:15,variant:"hover",color:"blue",disabled:s,onClick:a,children:t(S.Refresh,{size:15})})]}),p(r.Table,{children:[t("thead",{children:t("tr",{children:Object.keys(l==null?void 0:l[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:l.slice(0,10).map((u,d)=>t("tr",{children:Object.values(u).map((x,m)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:x})})},`${x}--${m}`))},`row-${d}`))})]})]})}function Ot({}){const{dataSources:e}=c.default.useContext(O),{dataSourceID:n,setDataSourceID:i,data:o,loading:l}=c.default.useContext(A),s=c.default.useMemo(()=>e.map(a=>({value:a.id,label:a.id})),[e]);return p(r.Group,{direction:"column",grow:!0,noWrap:!0,children:[p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Data Source"}),t(r.Select,{data:s,value:n,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),t(Ee,{id:n})]})}B.use([ne.SunburstChart,re.CanvasRenderer]);const kt={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Et({conf:e,data:n,width:i,height:o}){const h=e,{label_field:l="name",value_field:s="value"}=h,a=I(h,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(g=>({name:g[l],value:Number(g[s])})),[n,l,s]),d=c.default.useMemo(()=>{var g,b;return(b=(g=_.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?b:1},[u]),x=c.default.useMemo(()=>({series:{label:{formatter:({name:g,value:b})=>b/d<.2?" ":g}}}),[d]),m=_.default.merge({},kt,x,a,{series:{data:u}});return t(ie.default,{echarts:B,option:m,style:{width:i,height:o}})}B.use([ne.BarChart,ne.LineChart,N.GridComponent,N.LegendComponent,N.TooltipComponent,re.CanvasRenderer]);const qt={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:30,left:15,right:15,bottom:30,containLabel:!0}};function $t({conf:e,data:n,width:i,height:o}){const l=c.default.useMemo(()=>{var x;const s=e.y_axes.reduce((m,{label_formatter:h},g)=>(m[g]=function(C){const T=typeof C=="object"?C.value:C;if(!h)return T;try{return K.default(T).format(h)}catch(M){return console.error(M),T}},m),{default:({value:m})=>m}),a=e.series.reduce((m,{yAxisIndex:h,name:g})=>(m[g]=h,m),{}),u=e.series.map(T=>{var M=T,{y_axis_data_key:m,yAxisIndex:h,label_position:g,name:b}=M,C=I(M,["y_axis_data_key","yAxisIndex","label_position","name"]);return f({data:n.map(Y=>Y[m]),label:{show:!!g,position:g,formatter:s[h!=null?h:"default"]},name:b,yAxisIndex:h},C)}),d={xAxis:{data:n.map(m=>m[e.x_axis_data_key]),name:(x=e.x_axis_name)!=null?x:""},yAxis:e.y_axes.map((b,g)=>{var C=b,{label_formatter:m}=C,h=I(C,["label_formatter"]);var T;return z(f({},h),{axisLabel:{show:!0,formatter:(T=s[g])!=null?T:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(m){const h=Array.isArray(m)?m:[m];if(h.length===0)return"";const g=h.map(({seriesName:b,value:C})=>{var P;if(!b)return C;const T=a[b],M=(P=s[T])!=null?P:s.default;return`${b}: ${M({value:C})}`});return g.unshift(`<strong>${h[0].name}</strong>`),g.join("<br />")}}};return _.default.merge({},qt,d)},[e,n]);return!i||!o?null:t(ie.default,{echarts:B,option:l,style:{width:i,height:o}})}var F=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(F||{});function Rt({value:e}){return t(r.Text,{component:"span",children:e})}function Bt({value:e}){return t(r.Text,{component:"span",children:e})}function Ft({value:e}){const n=K.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Vt({value:e}){const n=K.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function jt({value:e,type:n}){switch(n){case F.string:return t(Rt,{value:e});case F.eloc:return t(Bt,{value:e});case F.number:return t(Ft,{value:e});case F.percentage:return t(Vt,{value:e})}}function Nt({conf:e,data:n=[],width:i,height:o}){const m=e,{id_field:l,use_raw_columns:s,columns:a}=m,u=I(m,["id_field","use_raw_columns","columns"]),d=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(h=>h.label),[s,a,n]),x=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(h=>({label:h,value_field:h,value_type:F.string})):a,[s,a,n]);return p(r.Table,z(f({sx:{maxHeight:o}},u),{children:[t("thead",{children:t("tr",{children:d.map(h=>t("th",{children:h},h))})}),t("tbody",{children:n.slice(0,30).map((h,g)=>t("tr",{children:x.map(({value_field:b,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(jt,{value:h[b],type:C})})},`${b}--${h[b]}`))},l?h[l]:`row-${g}`))}),n.length>100&&t("tfoot",{children:t("tr",{children:t("td",{colSpan:d.length,children:t(r.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]}))}function Wt(e,n={}){const i=z(f({},n),{numbro:K.default}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}catch(s){return s.message}}function Qt({conf:{paragraphs:e},data:n}){return t(X,{children:e.map((a,s)=>{var u=a,{template:i,size:o}=u,l=I(u,["template","size"]);return t(r.Text,z(f({},l),{sx:{fontSize:o},children:Wt(i,n[0])}),`${i}---${s}`)})})}B.use([N.GridComponent,N.VisualMapComponent,N.LegendComponent,N.TooltipComponent,re.CanvasRenderer]);function Ut({conf:e,data:n,width:i,height:o}){const h=e,{x_axis_data_key:l,y_axis_data_key:s,z_axis_data_key:a}=h,u=I(h,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),d=c.default.useMemo(()=>_.default.minBy(n,g=>g[a])[a],[n,a]),x=c.default.useMemo(()=>_.default.maxBy(n,g=>g[a])[a],[n,a]),m=z(f({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:x,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}}},u),{series:[{type:"bar3D",wireframe:{},data:n.map(g=>[g[l],g[s],g[a]])}]});return t(ie.default,{echarts:B,option:m,style:{width:i,height:o}})}var pr="";B.use([ne.PieChart,re.CanvasRenderer]);const Jt={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
|
|
10
|
+
{percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function Yt({conf:e,data:n,width:i,height:o}){const m=e,{label_field:l="name",value_field:s="value"}=m,a=I(m,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(h=>({name:h[l],value:Number(h[s])})),[n,l,s]),d=c.default.useMemo(()=>({series:{labelLayout:function(h){const g=h.labelRect.x<i/2,b=h.labelLinePoints;return b[2][0]=g?h.labelRect.x:h.labelRect.x+h.labelRect.width,{labelLinePoints:b}}}}),[i]),x=_.default.merge({},Jt,d,a,{series:{data:u}});return t(ie.default,{echarts:B,option:x,style:{width:i,height:o}})}var qe=function(){};const Kt=(e,n,i)=>Math.min(Math.max(i,e),n),$e=(e,n,i)=>{const o=n-e;return o===0?1:(i-e)/o},he=(e,n,i)=>-i*e+i*n+e,Re=(e,n)=>i=>Math.max(Math.min(i,n),e),Z=e=>e%1?Number(e.toFixed(5)):e,ae=/(-)?([\d]*\.?[\d])+/g,xe=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Xt=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function H(e){return typeof e=="string"}const se={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Be=Object.assign(Object.assign({},se),{transform:Re(0,1)});Object.assign(Object.assign({},se),{default:1});const ee=(e=>({test:n=>H(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},ee),{parse:e=>ee.parse(e)/100,transform:e=>ee.transform(e*100)});const ge=(e,n)=>i=>Boolean(H(i)&&Xt.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Fe=(e,n,i)=>o=>{if(!H(o))return o;const[l,s,a,u]=o.match(ae);return{[e]:parseFloat(l),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},U={test:ge("hsl","hue"),parse:Fe("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:o=1})=>"hsla("+Math.round(e)+", "+ee.transform(Z(n))+", "+ee.transform(Z(i))+", "+Z(Be.transform(o))+")"},Zt=Re(0,255),be=Object.assign(Object.assign({},se),{transform:e=>Math.round(Zt(e))}),V={test:ge("rgb","red"),parse:Fe("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:o=1})=>"rgba("+be.transform(e)+", "+be.transform(n)+", "+be.transform(i)+", "+Z(Be.transform(o))+")"};function Ht(e){let n="",i="",o="",l="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),o=e.substr(5,2),l=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),o=e.substr(3,1),l=e.substr(4,1),n+=n,i+=i,o+=o,l+=l),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:l?parseInt(l,16)/255:1}}const ye={test:ge("#"),parse:Ht,transform:V.transform},ue={test:e=>V.test(e)||ye.test(e)||U.test(e),parse:e=>V.test(e)?V.parse(e):U.test(e)?U.parse(e):ye.parse(e),transform:e=>H(e)?e:e.hasOwnProperty("red")?V.transform(e):U.transform(e)},Ve="${c}",je="${n}";function en(e){var n,i,o,l;return isNaN(e)&&H(e)&&((i=(n=e.match(ae))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((l=(o=e.match(xe))===null||o===void 0?void 0:o.length)!==null&&l!==void 0?l:0)>0}function Ne(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const o=e.match(xe);o&&(i=o.length,e=e.replace(xe,Ve),n.push(...o.map(ue.parse)));const l=e.match(ae);return l&&(e=e.replace(ae,je),n.push(...l.map(se.parse))),{values:n,numColors:i,tokenised:e}}function We(e){return Ne(e).values}function Qe(e){const{values:n,numColors:i,tokenised:o}=Ne(e),l=n.length;return s=>{let a=o;for(let u=0;u<l;u++)a=a.replace(u<i?Ve:je,u<i?ue.transform(s[u]):Z(s[u]));return a}}const tn=e=>typeof e=="number"?0:e;function nn(e){const n=We(e);return Qe(e)(n.map(tn))}const Ue={test:en,parse:We,createTransformer:Qe,getAnimatableNone:nn};function Se(e,n,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(n-e)*6*i:i<1/2?n:i<2/3?e+(n-e)*(2/3-i)*6:e}function Je({hue:e,saturation:n,lightness:i,alpha:o}){e/=360,n/=100,i/=100;let l=0,s=0,a=0;if(!n)l=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,d=2*i-u;l=Se(d,u,e+1/3),s=Se(d,u,e),a=Se(d,u,e-1/3)}return{red:Math.round(l*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:o}}const rn=(e,n,i)=>{const o=e*e,l=n*n;return Math.sqrt(Math.max(0,i*(l-o)+o))},on=[ye,V,U],Ye=e=>on.find(n=>n.test(e)),Ke=(e,n)=>{let i=Ye(e),o=Ye(n),l=i.parse(e),s=o.parse(n);i===U&&(l=Je(l),i=V),o===U&&(s=Je(s),o=V);const a=Object.assign({},l);return u=>{for(const d in a)d!=="alpha"&&(a[d]=rn(l[d],s[d],u));return a.alpha=he(l.alpha,s.alpha,u),i.transform(a)}},ln=e=>typeof e=="number",an=(e,n)=>i=>n(e(i)),Xe=(...e)=>e.reduce(an);function Ze(e,n){return ln(e)?i=>he(e,n,i):ue.test(e)?Ke(e,n):tt(e,n)}const He=(e,n)=>{const i=[...e],o=i.length,l=e.map((s,a)=>Ze(s,n[a]));return s=>{for(let a=0;a<o;a++)i[a]=l[a](s);return i}},sn=(e,n)=>{const i=Object.assign(Object.assign({},e),n),o={};for(const l in i)e[l]!==void 0&&n[l]!==void 0&&(o[l]=Ze(e[l],n[l]));return l=>{for(const s in o)i[s]=o[s](l);return i}};function et(e){const n=Ue.parse(e),i=n.length;let o=0,l=0,s=0;for(let a=0;a<i;a++)o||typeof n[a]=="number"?o++:n[a].hue!==void 0?s++:l++;return{parsed:n,numNumbers:o,numRGB:l,numHSL:s}}const tt=(e,n)=>{const i=Ue.createTransformer(n),o=et(e),l=et(n);return o.numHSL===l.numHSL&&o.numRGB===l.numRGB&&o.numNumbers>=l.numNumbers?Xe(He(o.parsed,l.parsed),i):a=>`${a>0?n:e}`},un=(e,n)=>i=>he(e,n,i);function dn(e){if(typeof e=="number")return un;if(typeof e=="string")return ue.test(e)?Ke:tt;if(Array.isArray(e))return He;if(typeof e=="object")return sn}function cn(e,n,i){const o=[],l=i||dn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=l(e[a],e[a+1]);if(n){const d=Array.isArray(n)?n[a]:n;u=Xe(d,u)}o.push(u)}return o}function pn([e,n],[i]){return o=>i($e(e,n,o))}function fn(e,n){const i=e.length,o=i-1;return l=>{let s=0,a=!1;if(l<=e[0]?a=!0:l>=e[o]&&(s=o-1,a=!0),!a){let d=1;for(;d<i&&!(e[d]>l||d===o);d++);s=d-1}const u=$e(e[s],e[s+1],l);return n[s](u)}}function mn(e,n,{clamp:i=!0,ease:o,mixer:l}={}){const s=e.length;qe(s===n.length),qe(!o||!Array.isArray(o)||o.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=cn(n,o,l),u=s===2?pn(e,a):fn(e,a);return i?d=>u(Kt(e[0],e[s-1],d)):u}class hn{constructor({valueRange:n,colorRange:i}){dt(this,"mapper");this.mapper=mn(n,i)}getColor(n){return this.mapper(n)}}function xn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new hn(e),o=n[e.valueField];return i.getColor(o)}return"black"}function gn(s){var a=s,{conf:u}=a,d=u,{content:e,size:n,color:i}=d,o=I(d,["content","size","color"]),{data:l}=a;const x=c.default.useMemo(()=>xn(i,l[0]),[i,l]),m=c.default.useMemo(()=>{var P;const{prefix:h,postfix:g,data_field:b,formatter:C}=e,T=(P=l==null?void 0:l[0])==null?void 0:P[b];return[h,K.default(T).format(C),g].join(" ")},[e,l]);return t(r.Text,z(f({},o),{color:x,sx:{fontSize:n},children:m}))}function bn(e,n,i,o){const l={width:e,height:n,data:i,conf:o.conf};switch(o.type){case"sunburst":return t(Et,f({},l));case"line-bar":case"cartesian":return t($t,f({},l));case"table":return t(Nt,f({},l));case"text":return t(Qt,f({},l));case"stats":return t(gn,f({},l));case"bar-3d":return t(Ut,f({},l));case"pie":return t(Yt,f({},l));default:return null}}function nt({viz:e,data:n,loading:i}){const{ref:o,width:l,height:s}=k.useElementSize(),a=c.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:o,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:o,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&t(ke,{children:bn(l,s,n,e)})]})}function yn({}){const{data:e,loading:n,viz:i}=c.default.useContext(A);return t(nt,{viz:i,data:e,loading:n})}function Sn({conf:e,setConf:n}){const i=_.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},e),{control:o,handleSubmit:l,formState:s}=w.useForm({defaultValues:i});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:l(n),children:[t(r.Text,{children:"X Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(w.Controller,{name:"x_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(w.Controller,{name:"xAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Y Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(w.Controller,{name:"y_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(w.Controller,{name:"yAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Z Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(w.Controller,{name:"z_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(w.Controller,{name:"zAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(r.Button,{color:"blue",type:"submit",children:[t(S.DeviceFloppy,{size:20}),t(r.Text,{ml:"md",children:"Save"})]})})]})})}function Cn({value:e,onChange:n},i){const o=r.useMantineTheme(),l=c.default.useMemo(()=>Object.entries(o.colors).map(([a,u])=>({label:a,value:u[6]})),[o]),s=c.default.useMemo(()=>l.some(a=>a.value===e),[e,l]);return p(r.Group,{position:"apart",spacing:"xs",children:[t(r.TextInput,{placeholder:"Set any color",value:s?"":e,onChange:a=>n(a.currentTarget.value),rightSection:t(r.ColorSwatch,{color:s?"transparent":e,radius:4}),variant:s?"filled":"default",sx:{maxWidth:"100%",flexGrow:1}}),t(r.Text,{sx:{flexGrow:0},children:"or"}),t(r.Select,{data:l,value:e,onChange:n,variant:s?"default":"filled",placeholder:"Pick a theme color",icon:t(r.ColorSwatch,{color:s?e:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}const Ce=c.default.forwardRef(Cn),wn=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function vn({control:e,index:n,remove:i,seriesItem:o,yAxisOptions:l}){const s=o.type;return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(w.Controller,{name:`series.${n}.type`,control:e,render:({field:a})=>t(r.SegmentedControl,f({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter",disabled:!0},{label:"Boxplot",value:"boxplot",disabled:!0}]},a))})}),t(w.Controller,{name:`series.${n}.name`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},a))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(w.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Value key",required:!0,sx:{flex:1}},a))}),t(w.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:x=>{var{field:m}=x,h=m,{value:a,onChange:u}=h,d=I(h,["value","onChange"]);var g;return t(r.Select,z(f({label:"Y Axis",data:l,disabled:l.length===0},d),{value:(g=a==null?void 0:a.toString())!=null?g:"",onChange:b=>{if(!b){u(0);return}u(Number(b))},sx:{flex:1}}))}})]}),s==="bar"&&p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(w.Controller,{name:`series.${n}.stack`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},a))}),t(w.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Bar Width",sx:{flexGrow:1}},a))})]}),t(w.Controller,{name:`series.${n}.label_position`,control:e,render:({field:a})=>t(r.Select,f({label:"Label Position",data:wn},a))}),p(r.Group,{direction:"column",grow:!0,spacing:4,children:[t(r.Text,{size:"sm",children:"Color"}),t(w.Controller,{name:`series.${n}.color`,control:e,render:({field:a})=>t(Ce,f({},a))})]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},n)}function Tn({control:e,watch:n,getValues:i}){const{fields:o,append:l,remove:s}=w.useFieldArray({control:e,name:"series"}),a=n("y_axes"),u=o.map((m,h)=>f(f({},m),a[h])),d=()=>l({type:"bar",name:k.randomId(),showSymbol:!1,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000"}),x=c.default.useMemo(()=>i().y_axes.map(({name:m},h)=>({label:m,value:h.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),u.map((m,h)=>t(vn,{control:e,index:h,remove:s,seriesItem:m,yAxisOptions:x})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:d,children:"Add a Series"})})]})}const rt={mantissa:0,output:"number"};function Gn({value:e,onChange:n},i){const o=a=>{n(z(f({},e),{output:a}))},l=a=>{const u=a===0?!1:e.trimMantissa;n(z(f({},e),{mantissa:a,trimMantissa:u}))},s=a=>{n(z(f({},e),{trimMantissa:a.currentTarget.checked}))};return t(r.Group,{direction:"column",grow:!0,noWrap:!0,ref:i,children:p(r.Group,{direction:"row",grow:!0,children:[t(r.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:o}),t(r.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:l}),t(r.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:s,disabled:e.mantissa===0})]})})}const it=c.default.forwardRef(Gn);function _n({control:e,index:n,remove:i}){return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"row",grow:!0,noWrap:!0,children:t(w.Controller,{name:`y_axes.${n}.name`,control:e,render:({field:o})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},o))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(w.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:o})=>t(it,f({},o))})}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},disabled:n===0,children:t(S.Trash,{size:16})})]},n)}function zn({control:e,watch:n}){const{fields:i,append:o,remove:l}=w.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((d,x)=>f(f({},d),s[x])),u=()=>o({name:"",label_formatter:rt});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((d,x)=>t(_n,{control:e,index:x,remove:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function In(e){function n({type:i,name:o,showSymbol:l,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:d="1",color:x="black",barWidth:m="30"}){return{type:i,name:o,showSymbol:l,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:d,color:x,barWidth:m}}return e.map(n)}function Dn({conf:e,setConf:n}){const h=e,{series:i,y_axes:o}=h,l=I(h,["series","y_axes"]),s=c.default.useMemo(()=>{const C=l,{x_axis_name:g=""}=C,b=I(C,["x_axis_name"]);return f({series:In(i!=null?i:[]),x_axis_name:g,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:rt}]},b)},[i,l]);c.default.useEffect(()=>{!_.default.isEqual(e,s)&&n(s)},[e,s]);const{control:a,handleSubmit:u,watch:d,formState:{isDirty:x},getValues:m}=w.useForm({defaultValues:s});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u(n),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Chart Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!x,children:t(S.DeviceFloppy,{size:20})})]}),t(w.Controller,{name:"x_axis_data_key",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",mb:"lg",label:"X Axis Data Key"},g))}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:t(w.Controller,{name:"x_axis_name",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",label:"X Axis Name"},g))})}),t(zn,{control:a,watch:d}),t(Tn,{control:a,watch:d,getValues:m})]})})}function Pn({conf:{label_field:e,value_field:n},setConf:i}){const o=E.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Pie Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const de=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function Ln({label:e,value:n,onChange:i},o){var a,u;const[l,s]=c.default.useState((u=(a=de.find(d=>d.label===n))==null?void 0:a.value)!=null?u:de[0].value);return c.default.useEffect(()=>{const d=de.find(x=>x.value===l);d&&i(d.label)},[l]),p(r.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[t(r.Text,{children:e}),t(r.Slider,{label:null,marks:de,value:l,onChange:s,step:25,placeholder:"Pick a font size",ref:o})]})}const ot=c.default.forwardRef(Ln);function An({label:e,value:n,onChange:i},o){const[l,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(m=>[...m,""])},[s]),u=c.default.useCallback(m=>{s(h=>(h.splice(m,1),[...h]))},[s]),d=c.default.useMemo(()=>!_.default.isEqual(l,n),[l,n]),x=()=>{i(l.map(m=>m.toString()))};return p(X,{children:[p(r.Group,{position:"left",ref:o,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:x,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[l.map((m,h)=>t(r.TextInput,{value:m,onChange:g=>{const b=g.currentTarget.value;s(C=>(C.splice(h,1,b),[...C]))},rightSection:t(r.ActionIcon,{onClick:()=>u(h),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}const Mn=c.default.forwardRef(An);function On({label:e,value:n,onChange:i},o){const[l,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(g=>[...g,""])},[s]),u=c.default.useCallback(g=>{s(b=>(b.splice(g,1),[...b]))},[s]),d=c.default.useMemo(()=>!_.default.isEqual(l,n),[l,n]),x=()=>{i(l.map(g=>g.toString()))},m=r.useMantineTheme(),h=c.default.useMemo(()=>Object.entries(m.colors).map(([g,b])=>b[6]),[m]);return p(X,{children:[p(r.Group,{position:"left",ref:o,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:x,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[l.map((g,b)=>t(r.ColorInput,{value:g,onChange:C=>{s(T=>(T.splice(b,1,C),[...T]))},swatches:h,rightSection:t(r.ActionIcon,{onClick:()=>u(b),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}const kn=c.default.forwardRef(On);function En({conf:e,setConf:n}){const i=_.default.merge({},{align:"center",size:"100px",weight:"bold",color:{type:"static",staticColor:"red"},content:{prefix:"",data_field:"",formatter:{output:"number",mantissa:0},postfix:""}},e),{control:o,handleSubmit:l,watch:s,formState:{isDirty:a}}=w.useForm({defaultValues:i}),u=s("color.type");return s("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:l(n),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Stats Configurations"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Accordion,{offsetIcon:!1,multiple:!0,initialState:{0:!0,2:!0},children:[t(r.Accordion.Item,{label:"Content",children:p(r.Group,{direction:"column",grow:!0,children:[p(r.Group,{direction:"row",grow:!0,children:[t(w.Controller,{name:"content.prefix",control:o,render:({field:d})=>t(r.TextInput,f({label:"Prefix",sx:{flexGrow:1}},d))}),t(w.Controller,{name:"content.data_field",control:o,render:({field:d})=>t(r.TextInput,f({label:"Data Field",required:!0,sx:{flexGrow:1}},d))}),t(w.Controller,{name:"content.postfix",control:o,render:({field:d})=>t(r.TextInput,f({label:"Postfix",sx:{flexGrow:1}},d))})]}),t(w.Controller,{name:"content.formatter",control:o,render:({field:d})=>t(it,f({},d))})]})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(w.Controller,{name:"size",control:o,render:({field:d})=>t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},d))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(w.Controller,{name:"weight",control:o,render:({field:d})=>t(ot,f({label:"Font Weight"},d))})})]}),t(r.Accordion.Item,{label:"Color",children:p(r.Group,{direction:"column",grow:!0,children:[t(w.Controller,{name:"color.type",control:o,render:({field:d})=>t(r.Select,f({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},d))}),u==="static"&&t(w.Controller,{name:"color.staticColor",control:o,render:({field:d})=>t(Ce,f({},d))}),u==="continuous"&&p(X,{children:[t(w.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:d})=>t(r.TextInput,f({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},d))}),t(w.Controller,{name:"color.valueRange",control:o,render:({field:d})=>t(Mn,f({label:"Value Range"},d))}),t(w.Controller,{name:"color.colorRange",control:o,render:({field:d})=>t(kn,f({label:"Color Range"},d))})]})]})})]})]})})}function qn({conf:{label_field:e,value_field:n},setConf:i}){const o=E.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Sunburst Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const $n=Object.values(F).map(e=>({label:e,value:e}));function Rn({label:e,value:n,onChange:i,sx:o}){return t(r.Select,{label:e,data:$n,value:n,onChange:i,sx:o})}function Bn(o){var l=o,{conf:s}=l,a=s,{columns:e}=a,n=I(a,["columns"]),{setConf:i}=l;const u=E.useForm({initialValues:f({id_field:"id",use_raw_columns:!0,columns:E.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),d=()=>u.addListItem("columns",{label:k.randomId(),value_field:"value",value_type:F.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Table Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({size:"md",mb:"lg",label:"ID Field"},u.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,f({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("horizontalSpacing"))),t(r.TextInput,f({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("fontSize")))}),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Other"}),p(r.Group,{position:"apart",grow:!0,children:[t(r.Switch,f({label:"Striped"},u.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,f({label:"Highlight on hover"},u.getInputProps("highlightOnHover",{type:"checkbox"})))]})]})]}),p(r.Group,{direction:"column",mt:"xs",spacing:"xs",grow:!0,p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.Switch,f({label:"Use Original Data Columns"},u.getInputProps("use_raw_columns",{type:"checkbox"}))),!u.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),u.values.columns.map((x,m)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[p(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[t(r.TextInput,f({label:"Label",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"label"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"value_field"))),t(Rn,f({label:"Value Type",sx:{flex:1}},u.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>u.removeListItem("columns",m),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},m)),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:d,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(R.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(u.values,null,2)})]})})}const lt=[{align:"center",size:"xl",weight:"bold",color:"black",template:"Time: ${new Date().toISOString()}"},{align:"center",size:"md",weight:"bold",color:"red",template:"Platform: ${navigator.userAgentData.platform}."}];function Fn({conf:e,setConf:n}){var l;const i=E.useForm({initialValues:{paragraphs:E.formList((l=e.paragraphs)!=null?l:lt)}}),o=()=>i.addListItem("paragraphs",z(f({},lt[0]),{template:k.randomId()}));return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:i.onSubmit(n),children:[i.values.paragraphs.length===0&&t(r.Text,{color:"dimmed",align:"center",children:"Empty"}),p(r.Group,{position:"apart",mb:"xs",sx:{" + .mantine-Group-root":{marginTop:0}},children:[t(r.Text,{children:"Paragraphs"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),i.values.paragraphs.map((s,a)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},i.getListInputProps("paragraphs",a,"template"))),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Color"}),t(Ce,f({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},i.getListInputProps("paragraphs",a,"size")))}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(ot,f({label:"Font Weight"},i.getListInputProps("paragraphs",a,"weight")))}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i.removeListItem("paragraphs",a),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},a)),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:o,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(R.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const we=[{value:"text",label:"Text",Panel:Fn},{value:"stats",label:"Stats",Panel:En},{value:"table",label:"Table",Panel:Bn},{value:"sunburst",label:"Sunburst",Panel:qn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:Sn},{value:"cartesian",label:"Cartesian Chart",Panel:Dn},{value:"pie",label:"Pie Chart",Panel:Pn}];function Vn(){const{viz:e,setViz:n}=c.default.useContext(A),[i,o]=k.useInputState(e.type),l=e.type!==i,s=c.default.useCallback(()=>{!l||n(x=>z(f({},x),{type:i}))},[l,i]),a=x=>{n(m=>z(f({},m),{conf:x}))},u=x=>{try{a(JSON.parse(x))}catch(m){console.error(m)}},d=c.default.useMemo(()=>{var x;return(x=we.find(m=>m.value===i))==null?void 0:x.Panel},[i,we]);return p(X,{children:[t(r.Select,{label:"Visualization",value:i,onChange:o,data:we,rightSection:t(r.ActionIcon,{disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})}),d&&t(d,{conf:e.conf,setConf:a}),!d&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:u})]})}function jn({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[t(r.Group,{grow:!0,direction:"column",noWrap:!0,sx:{width:"40%",flexShrink:0,flexGrow:0},children:t(Vn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(yn,{})})]})}function Nn({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(q),{data:o,loading:l,viz:s,title:a}=c.default.useContext(A);return c.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:a,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%"}},padding:"md",children:p(r.Tabs,{initialTab:2,children:[p(r.Tabs.Tab,{label:"Data Source",children:[t(r.LoadingOverlay,{visible:l,exitTransitionDuration:0}),t(Ot,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(Mt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(jn,{})})]})})})}function Wn({}){const[e,n]=c.default.useState(!1),i=()=>n(!0),o=()=>n(!1),{title:l,refreshData:s}=c.default.useContext(A),{inEditMode:a}=c.default.useContext(q);return p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[t(r.Group,{children:t(Oe,{})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:l})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"},children:p(r.Menu,{children:[t(r.Menu.Item,{onClick:s,icon:t(S.Refresh,{size:14}),children:"Refresh"}),a&&t(r.Menu.Item,{onClick:i,icon:t(S.Settings,{size:14}),children:"Settings"}),t(r.Divider,{}),t(r.Menu.Item,{color:"red",disabled:!0,icon:t(S.Trash,{size:14}),children:"Delete"})]})}),a&&t(Nn,{opened:e,close:o})]})}var mr="";function ve({viz:e,dataSourceID:n,title:i,description:o,update:l,layout:s,id:a}){const u=c.default.useContext(Q),d=c.default.useContext(O),[x,m]=c.default.useState(i),[h,g]=c.default.useState(o),[b,C]=c.default.useState(n),[T,M]=c.default.useState(e),P=c.default.useMemo(()=>{if(!!b)return d.dataSources.find(_e=>_e.id===b)},[b,d.dataSources]);c.default.useEffect(()=>{l==null||l({id:a,layout:s,title:x,description:h,dataSourceID:b,viz:T})},[x,h,P,T,a,s,b]);const{data:Y=[],loading:ce,refresh:te}=me.useRequest(Le({context:u,definitions:d,title:x,dataSource:P}),{refreshDeps:[u,d,P]}),Ge=te;return t(A.Provider,{value:{data:Y,loading:ce,title:x,setTitle:m,description:h,setDescription:g,dataSourceID:b,setDataSourceID:C,viz:T,setViz:M,refreshData:Ge},children:p(r.Container,{className:"panel-root",children:[t(Wn,{}),t(nt,{viz:T,data:Y,loading:ce})]})})}var hr="";const Qn=D.WidthProvider(De.default);function at({panels:e,setPanels:n,className:i="layout",rowHeight:o=10,onRemoveItem:l,isDraggable:s,isResizable:a}){const u=c.default.useCallback(d=>{const x=new Map;d.forEach(b=>{var C=b,{i:h}=C,g=I(C,["i"]);x.set(h,g)});const m=e.map(h=>z(f({},h),{layout:x.get(h.id)}));n(m)},[e,n]);return t(Qn,{onLayoutChange:u,className:i,rowHeight:o,isDraggable:s,isResizable:a,children:e.map((h,m)=>{var g=h,{id:d}=g,x=I(g,["id"]);return t("div",{"data-grid":x.layout,children:t(ve,z(f({id:d},x),{destroy:()=>l(d),update:b=>{n(C=>(C.splice(m,1,b),[...C]))}}))},d)})})}function Te(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Un({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:Te(t(S.PlayerPlay,{size:20}),"Use"),value:L.Use},{label:Te(t(S.Resize,{size:20}),"Layout"),value:L.Layout},{label:Te(t(S.Paint,{size:20}),"Content"),value:L.Edit}]})}const Jn=`
|
|
11
11
|
-- You may reference context data or SQL snippets *by name*
|
|
12
12
|
-- in SQL or VizConfig.
|
|
13
13
|
SELECT *
|
|
@@ -18,16 +18,16 @@ WHERE
|
|
|
18
18
|
-- SQL snippets
|
|
19
19
|
AND \${author_email_condition}
|
|
20
20
|
\${order_by_clause}
|
|
21
|
-
`;function
|
|
21
|
+
`;function Yn({}){const e=c.default.useContext(Q),{sqlSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>{const l=n.reduce((s,a)=>(s[a.key]=a.value,s),{});return JSON.stringify(l,null,2)},[n]),o=c.default.useMemo(()=>JSON.stringify(e,null,2),[e]);return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",maxWidth:"48%",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Context"})}),p(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:[t(R.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:Jn}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context"}),t(R.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:o}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable SQL Snippets"}),t(R.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:i})]})]})}function Kn({value:e,onChange:n}){const i=E.useForm({initialValues:e}),o=c.default.useCallback(x=>{n(x)},[n]),l=c.default.useMemo(()=>!_.default.isEqual(e,i.values),[e,i.values]);c.default.useEffect(()=>{i.reset()},[e]);const{data:s={},loading:a}=me.useRequest(St,{refreshDeps:[]},[]),u=c.default.useMemo(()=>Object.keys(s).map(x=>({label:x,value:x})),[s]),d=c.default.useMemo(()=>{const x=s[i.values.type];return x?x.map(m=>({label:m,value:m})):[]},[s,i.values.type]);return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",flexGrow:1},children:p("form",{onSubmit:i.onSubmit(o),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Data Source Configuration"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!l||a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,children:[p(r.Group,{grow:!0,children:[t(r.TextInput,f({placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:a},i.getInputProps("id"))),t(r.Select,f({label:"Data Source Type",data:u,sx:{flex:1},disabled:a},i.getInputProps("type"))),t(r.Select,f({label:"Data Source Key",data:d,sx:{flex:1},disabled:a},i.getInputProps("key")))]}),t(r.Textarea,f({autosize:!0,minRows:12,maxRows:24},i.getInputProps("sql")))]})]})})}function Xn({id:e,setID:n}){const{dataSources:i,setDataSources:o}=c.default.useContext(O),l=c.default.useMemo(()=>i.find(a=>a.id===e),[i,e]),s=c.default.useCallback(a=>{if(i.findIndex(d=>d.id===e)===-1){console.error(new Error("Invalid data source id when updating by id"));return}o(d=>{const x=d.findIndex(m=>m.id===e);return d.splice(x,1,a),[...d]}),n(a.id)},[e,i,o,n]);return e?l?p(r.Group,{direction:"row",position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[t(Kn,{value:l,onChange:s}),t(Yn,{})]}):t("span",{children:"Invalid Data Source ID"}):null}function Zn({id:e,setID:n}){const{dataSources:i,setDataSources:o}=c.default.useContext(O),l=c.default.useCallback(()=>{var u,d;n((d=(u=i[0])==null?void 0:u.id)!=null?d:"")},[n,i]);c.default.useEffect(()=>{if(!e){l();return}i.findIndex(d=>d.id===e)===-1&&l()},[e,i,l]);const s=c.default.useMemo(()=>i.map(u=>({value:u.id,label:u.id})),[i]),a=c.default.useCallback(()=>{const u={id:k.randomId(),type:"postgresql",key:"",sql:""};o(d=>[...d,u]),n(u.id)},[o,n]);return t(r.Group,{pb:"xl",children:p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Data Source"}),t(r.Select,{data:s,value:e,onChange:n,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),t(r.Text,{children:"or"}),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:a,children:"Add a Data Source"})})]})})}function Hn({opened:e,close:n}){const[i,o]=c.default.useState(""),{freezeLayout:l}=c.default.useContext(q);return c.default.useEffect(()=>{l(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"Data Sources",trapFocus:!0,onDragStart:s=>{s.stopPropagation()},children:p(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",header:t(Zn,{id:i,setID:o}),children:[t(Xn,{id:i,setID:o}),t(Ee,{id:i})]})})}function er({}){const e=c.default.useContext(Q),n="SELECT *\nFROM commit\nWHERE author_time BETWEEN '${timeRange?.[0].toISOString()}' AND '${timeRange?.[1].toISOString()}'";return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",maxWidth:"48%",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Context"})}),p(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:[t(R.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:`-- You may refer context data *by name*
|
|
22
22
|
-- in SQL or VizConfig.
|
|
23
23
|
|
|
24
|
-
${n}`}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context entries"}),t(
|
|
24
|
+
${n}`}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context entries"}),t(R.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:JSON.stringify(e,null,2)})]})]})}function tr({}){const{sqlSnippets:e,setSQLSnippets:n}=c.default.useContext(O),i=`SELECT *
|
|
25
25
|
FROM commit
|
|
26
|
-
WHERE \${author_time_condition}`,o=c.default.useMemo(()=>({snippets:
|
|
26
|
+
WHERE \${author_time_condition}`,o=c.default.useMemo(()=>({snippets:E.formList(e!=null?e:[])}),[e]),l=E.useForm({initialValues:o}),s=()=>l.addListItem("snippets",{key:k.randomId(),value:""}),a=c.default.useMemo(()=>!_.default.isEqual(l.values,o),[l.values,o]),u=({snippets:d})=>{n(d)};return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee"},children:p("form",{onSubmit:l.onSubmit(u),children:[p(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:[t(r.Text,{weight:500,children:"SQL Snippets"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{px:"md",pb:"md",children:[t(R.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,trim:!1,colorScheme:"dark",children:`-- You may refer context data *by name*
|
|
27
27
|
-- in SQL or VizConfig.
|
|
28
28
|
|
|
29
29
|
${i}
|
|
30
30
|
|
|
31
31
|
-- where author_time_condition is:
|
|
32
32
|
author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
|
|
33
|
-
`}),p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((d,x)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({label:"Key",required:!0},l.getListInputProps("snippets",x,"key"))),t(r.Textarea,f({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",x,"value"))),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",x),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},x)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:s,children:"Add a snippet"})})]})]})]})})}function
|
|
33
|
+
`}),p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((d,x)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({label:"Key",required:!0},l.getListInputProps("snippets",x,"key"))),t(r.Textarea,f({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",x,"value"))),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",x),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},x)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:s,children:"Add a snippet"})})]})]})]})})}function nr({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(q);return c.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"SQL Snippets",trapFocus:!0,onDragStart:o=>{o.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:p(r.Group,{direction:"row",position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[t(tr,{}),t(er,{})]})})})}function rr({mode:e,setMode:n,hasChanges:i,addPanel:o,saveChanges:l}){const{inLayoutMode:s,inEditMode:a,inUseMode:u}=c.default.useContext(q),[d,x]=c.default.useState(!1),m=()=>x(!0),h=()=>x(!1),[g,b]=c.default.useState(!1),C=()=>b(!0),T=()=>b(!1);return p(r.Group,{position:"apart",pt:"sm",pb:"xs",children:[t(r.Group,{position:"left",children:t(Un,{mode:e,setMode:n})}),p(r.Group,{position:"right",children:[!u&&t(r.Button,{variant:"default",size:"sm",onClick:o,leftIcon:t(S.PlaylistAdd,{size:20}),children:"Add a Panel"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:C,leftIcon:t(S.ClipboardText,{size:20}),children:"SQL Snippets"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:m,leftIcon:t(S.Database,{size:20}),children:"Data Sources"}),!u&&t(r.Button,{variant:"default",size:"sm",onClick:l,disabled:!i,leftIcon:t(S.DeviceFloppy,{size:20}),children:"Save Changes"}),!u&&t(r.Button,{color:"red",size:"sm",disabled:!i,leftIcon:t(S.Recycle,{size:20}),children:"Revert Changes"})]}),t(Hn,{opened:d,close:h}),t(nr,{opened:g,close:T}),u&&t(r.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:t(S.Share,{size:20}),children:"Share"})]})}function ir({context:e,dashboard:n,update:i,className:o="dashboard",config:l}){J.baseURL!==l.apiBaseURL&&(J.baseURL=l.apiBaseURL);const[s,a]=c.default.useState(!1),[u,d]=c.default.useState(n.panels),[x,m]=c.default.useState(n.definition.sqlSnippets),[h,g]=c.default.useState(n.definition.dataSources),[b,C]=c.default.useState(L.Edit),T=c.default.useMemo(()=>{const $=j=>JSON.parse(JSON.stringify(j));return!_.default.isEqual($(u),$(n.panels))||!_.default.isEqual(x,n.definition.sqlSnippets)?!0:!_.default.isEqual(h,n.definition.dataSources)},[n,u,x,h]),M=async()=>{const $=z(f({},n),{panels:u,definition:{sqlSnippets:x,dataSources:h}});await i($)},P=()=>{const $=k.randomId(),pe={id:$,layout:{x:0,y:1/0,w:3,h:15},title:`New Panel - ${$}`,description:"",dataSourceID:"",viz:{type:"text",conf:{}}};d(j=>[...j,pe])},Y=$=>{const pe=u.findIndex(j=>j.id===$);d(j=>(j.splice(pe,1),[...j]))},ce=b===L.Edit,te=b===L.Layout,Ge=b===L.Use,_e=c.default.useMemo(()=>({sqlSnippets:x,setSQLSnippets:m,dataSources:h,setDataSources:g}),[x,m,h,g]);return t(Q.Provider,{value:e,children:t("div",{className:o,children:t(O.Provider,{value:_e,children:p(q.Provider,{value:{layoutFrozen:s,freezeLayout:a,mode:b,inEditMode:ce,inLayoutMode:te,inUseMode:Ge},children:[t(rr,{mode:b,setMode:C,hasChanges:T,addPanel:P,saveChanges:M}),t(at,{panels:u,setPanels:d,isDraggable:te,isResizable:te,onRemoveItem:Y})]})})})})}const or=D.WidthProvider(De.default);function lr({panels:e,className:n="layout",rowHeight:i=10}){return t(or,{className:n,rowHeight:i,isDraggable:!1,isResizable:!1,children:e.map(s=>{var a=s,{id:o}=a,l=I(a,["id"]);return t("div",{"data-grid":l.layout,children:t(ve,f({id:o},l))},o)})})}function ar({context:e,dashboard:n,className:i="dashboard",config:o}){J.baseURL!==o.apiBaseURL&&(J.baseURL=o.apiBaseURL);const l=c.default.useMemo(()=>z(f({},n.definition),{setSQLSnippets:()=>{},setDataSources:()=>{}}),[n]);return t(Q.Provider,{value:e,children:t("div",{className:i,children:t(O.Provider,{value:l,children:t(q.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:L.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:t(lr,{panels:n.panels})})})})})}y.ContextInfoContext=Q,y.Dashboard=ir,y.DashboardLayout=at,y.DashboardMode=L,y.DefinitionContext=O,y.LayoutStateContext=q,y.Panel=ve,y.PanelContext=A,y.ReadOnlyDashboard=ar,y.initialContextInfoContext=Ct,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/layout/index.d.ts
CHANGED
|
@@ -4,19 +4,10 @@ interface IDashboardLayout {
|
|
|
4
4
|
panels: IDashboardPanel[];
|
|
5
5
|
setPanels: React.Dispatch<React.SetStateAction<IDashboardPanel[]>>;
|
|
6
6
|
className?: string;
|
|
7
|
-
cols?: {
|
|
8
|
-
lg: number;
|
|
9
|
-
md: number;
|
|
10
|
-
sm: number;
|
|
11
|
-
xs: number;
|
|
12
|
-
xxs: number;
|
|
13
|
-
};
|
|
14
7
|
rowHeight?: number;
|
|
15
8
|
onRemoveItem: (id: string) => void;
|
|
16
9
|
isDraggable: boolean;
|
|
17
10
|
isResizable: boolean;
|
|
18
|
-
setLocalCols: React.Dispatch<React.SetStateAction<any>>;
|
|
19
|
-
setBreakpoint: React.Dispatch<React.SetStateAction<any>>;
|
|
20
11
|
}
|
|
21
|
-
export declare function DashboardLayout({ panels, setPanels, className,
|
|
12
|
+
export declare function DashboardLayout({ panels, setPanels, className, rowHeight, onRemoveItem, isDraggable, isResizable, }: IDashboardLayout): JSX.Element;
|
|
22
13
|
export {};
|
|
@@ -3,14 +3,7 @@ import { IDashboardPanel } from "../types/dashboard";
|
|
|
3
3
|
interface IReadOnlyDashboardLayout {
|
|
4
4
|
panels: IDashboardPanel[];
|
|
5
5
|
className?: string;
|
|
6
|
-
cols?: {
|
|
7
|
-
lg: number;
|
|
8
|
-
md: number;
|
|
9
|
-
sm: number;
|
|
10
|
-
xs: number;
|
|
11
|
-
xxs: number;
|
|
12
|
-
};
|
|
13
6
|
rowHeight?: number;
|
|
14
7
|
}
|
|
15
|
-
export declare function ReadOnlyDashboardLayout({ panels, className,
|
|
8
|
+
export declare function ReadOnlyDashboardLayout({ panels, className, rowHeight, }: IReadOnlyDashboardLayout): JSX.Element;
|
|
16
9
|
export {};
|
package/dist/main/main.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IDashboard } from "../types/dashboard";
|
|
2
|
+
import { IDashboard, IDashboardConfig } from "../types/dashboard";
|
|
3
3
|
import { ContextInfoContextType } from "../contexts";
|
|
4
4
|
interface IDashboardProps {
|
|
5
5
|
context: ContextInfoContextType;
|
|
6
6
|
dashboard: IDashboard;
|
|
7
7
|
className?: string;
|
|
8
8
|
update: (dashboard: IDashboard) => Promise<void>;
|
|
9
|
+
config: IDashboardConfig;
|
|
9
10
|
}
|
|
10
|
-
export declare function Dashboard({ context, dashboard, update, className, }: IDashboardProps): JSX.Element;
|
|
11
|
+
export declare function Dashboard({ context, dashboard, update, className, config, }: IDashboardProps): JSX.Element;
|
|
11
12
|
export {};
|
package/dist/main/read-only.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IDashboard } from "../types/dashboard";
|
|
2
|
+
import { IDashboard, IDashboardConfig } from "../types/dashboard";
|
|
3
3
|
import { ContextInfoContextType } from "../contexts";
|
|
4
4
|
interface IReadOnlyDashboard {
|
|
5
5
|
context: ContextInfoContextType;
|
|
6
6
|
dashboard: IDashboard;
|
|
7
7
|
className?: string;
|
|
8
|
+
config: IDashboardConfig;
|
|
8
9
|
}
|
|
9
|
-
export declare function ReadOnlyDashboard({ context, dashboard, className, }: IReadOnlyDashboard): JSX.Element;
|
|
10
|
+
export declare function ReadOnlyDashboard({ context, dashboard, className, config, }: IReadOnlyDashboard): JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
declare type PropType = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
declare type StateType = {
|
|
6
|
+
error: null | any;
|
|
7
|
+
};
|
|
8
|
+
export declare class ErrorBoundary extends React.Component<PropType, StateType> {
|
|
9
|
+
constructor(props: PropType);
|
|
10
|
+
componentDidCatch(error: any): void;
|
|
11
|
+
render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
|
8
12
|
}
|
|
13
|
+
export {};
|
|
@@ -4,5 +4,5 @@ interface IColorArrayInput {
|
|
|
4
4
|
value: string[];
|
|
5
5
|
onChange: (value: string[]) => void;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare const ColorArrayInput: React.ForwardRefExoticComponent<IColorArrayInput & React.RefAttributes<unknown>>;
|
|
8
8
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
interface IMantineColorSelector {
|
|
3
3
|
value?: string;
|
|
4
4
|
onChange: (value: string) => void;
|
|
5
5
|
}
|
|
6
|
-
export declare
|
|
6
|
+
export declare const MantineColorSelector: React.ForwardRefExoticComponent<IMantineColorSelector & React.RefAttributes<unknown>>;
|
|
7
7
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
interface IMantineFontWeightSlider {
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare const MantineFontWeightSlider: React.ForwardRefExoticComponent<IMantineFontWeightSlider & React.RefAttributes<unknown>>;
|
|
8
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
export declare type TNumbroFormat = {
|
|
3
3
|
mantissa: number;
|
|
4
4
|
output: 'percent' | 'number';
|
|
@@ -9,5 +9,5 @@ interface INumbroFormatSelector {
|
|
|
9
9
|
value: TNumbroFormat;
|
|
10
10
|
onChange: (v: TNumbroFormat) => void;
|
|
11
11
|
}
|
|
12
|
-
export declare
|
|
12
|
+
export declare const NumbroFormatSelector: React.ForwardRefExoticComponent<INumbroFormatSelector & React.RefAttributes<unknown>>;
|
|
13
13
|
export {};
|
|
@@ -4,5 +4,5 @@ interface ITextArrayInput {
|
|
|
4
4
|
value: string[] | number[];
|
|
5
5
|
onChange: (value: string[] | number[]) => void;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare const TextArrayInput: React.ForwardRefExoticComponent<ITextArrayInput & React.RefAttributes<unknown>>;
|
|
8
8
|
export {};
|