@devtable/dashboard 1.17.0 → 1.18.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/dashboard.es.js +100 -82
- package/dist/dashboard.umd.js +8 -8
- package/dist/panel/settings/common/data-field-selector.d.ts +12 -0
- package/dist/panel/viz/bar-3d/panel.d.ts +2 -2
- package/dist/panel/viz/cartesian/panel/index.d.ts +1 -1
- package/dist/panel/viz/cartesian/panel/series.d.ts +2 -1
- package/dist/panel/viz/pie/panel.d.ts +1 -1
- package/dist/panel/viz/stats/panel.d.ts +1 -1
- package/dist/panel/viz/sunburst/panel.d.ts +1 -1
- package/dist/panel/viz/table/panel.d.ts +1 -1
- package/dist/types/viz-panel.d.ts +1 -0
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -1673,9 +1673,39 @@ function PreviewViz({}) {
|
|
|
1673
1673
|
loading
|
|
1674
1674
|
});
|
|
1675
1675
|
}
|
|
1676
|
+
function _DataFieldSelector({
|
|
1677
|
+
label,
|
|
1678
|
+
required,
|
|
1679
|
+
value,
|
|
1680
|
+
onChange,
|
|
1681
|
+
data,
|
|
1682
|
+
sx
|
|
1683
|
+
}, ref) {
|
|
1684
|
+
const options = React.useMemo(() => {
|
|
1685
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
1686
|
+
return [];
|
|
1687
|
+
}
|
|
1688
|
+
const keys = Object.keys(data[0]);
|
|
1689
|
+
return keys.map((k2) => ({
|
|
1690
|
+
label: k2,
|
|
1691
|
+
value: k2
|
|
1692
|
+
}));
|
|
1693
|
+
}, [data]);
|
|
1694
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
1695
|
+
ref,
|
|
1696
|
+
label,
|
|
1697
|
+
data: options,
|
|
1698
|
+
value,
|
|
1699
|
+
onChange,
|
|
1700
|
+
required,
|
|
1701
|
+
sx
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
const DataFieldSelector = React.forwardRef(_DataFieldSelector);
|
|
1676
1705
|
function VizBar3DPanel({
|
|
1677
1706
|
conf,
|
|
1678
|
-
setConf
|
|
1707
|
+
setConf,
|
|
1708
|
+
data
|
|
1679
1709
|
}) {
|
|
1680
1710
|
const defaultValues = _.assign({}, {
|
|
1681
1711
|
"x_axis_data_key": "x",
|
|
@@ -1723,12 +1753,10 @@ function VizBar3DPanel({
|
|
|
1723
1753
|
control,
|
|
1724
1754
|
render: ({
|
|
1725
1755
|
field
|
|
1726
|
-
}) => /* @__PURE__ */ jsx(
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
size: "md",
|
|
1731
|
-
label: "Data Key"
|
|
1756
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
1757
|
+
label: "Data Field",
|
|
1758
|
+
required: true,
|
|
1759
|
+
data
|
|
1732
1760
|
}, field))
|
|
1733
1761
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
1734
1762
|
name: "xAxis3D.name",
|
|
@@ -1759,12 +1787,10 @@ function VizBar3DPanel({
|
|
|
1759
1787
|
control,
|
|
1760
1788
|
render: ({
|
|
1761
1789
|
field
|
|
1762
|
-
}) => /* @__PURE__ */ jsx(
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
size: "md",
|
|
1767
|
-
label: "Data Key"
|
|
1790
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
1791
|
+
label: "Data Field",
|
|
1792
|
+
required: true,
|
|
1793
|
+
data
|
|
1768
1794
|
}, field))
|
|
1769
1795
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
1770
1796
|
name: "yAxis3D.name",
|
|
@@ -1795,12 +1821,10 @@ function VizBar3DPanel({
|
|
|
1795
1821
|
control,
|
|
1796
1822
|
render: ({
|
|
1797
1823
|
field
|
|
1798
|
-
}) => /* @__PURE__ */ jsx(
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
size: "md",
|
|
1803
|
-
label: "Data Key"
|
|
1824
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
1825
|
+
label: "Data Field",
|
|
1826
|
+
required: true,
|
|
1827
|
+
data
|
|
1804
1828
|
}, field))
|
|
1805
1829
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
1806
1830
|
name: "zAxis3D.name",
|
|
@@ -1938,7 +1962,8 @@ function SeriesItemField({
|
|
|
1938
1962
|
index: index2,
|
|
1939
1963
|
remove,
|
|
1940
1964
|
seriesItem,
|
|
1941
|
-
yAxisOptions
|
|
1965
|
+
yAxisOptions,
|
|
1966
|
+
data
|
|
1942
1967
|
}) {
|
|
1943
1968
|
const type = seriesItem.type;
|
|
1944
1969
|
return /* @__PURE__ */ jsxs(Group, {
|
|
@@ -1999,9 +2024,10 @@ function SeriesItemField({
|
|
|
1999
2024
|
control,
|
|
2000
2025
|
render: ({
|
|
2001
2026
|
field
|
|
2002
|
-
}) => /* @__PURE__ */ jsx(
|
|
2003
|
-
label: "Value
|
|
2027
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2028
|
+
label: "Value Field",
|
|
2004
2029
|
required: true,
|
|
2030
|
+
data,
|
|
2005
2031
|
sx: {
|
|
2006
2032
|
flex: 1
|
|
2007
2033
|
}
|
|
@@ -2108,7 +2134,8 @@ function SeriesItemField({
|
|
|
2108
2134
|
function SeriesField({
|
|
2109
2135
|
control,
|
|
2110
2136
|
watch,
|
|
2111
|
-
getValues
|
|
2137
|
+
getValues,
|
|
2138
|
+
data
|
|
2112
2139
|
}) {
|
|
2113
2140
|
const {
|
|
2114
2141
|
fields,
|
|
@@ -2152,7 +2179,8 @@ function SeriesField({
|
|
|
2152
2179
|
index: index2,
|
|
2153
2180
|
remove,
|
|
2154
2181
|
seriesItem,
|
|
2155
|
-
yAxisOptions
|
|
2182
|
+
yAxisOptions,
|
|
2183
|
+
data
|
|
2156
2184
|
})), /* @__PURE__ */ jsx(Group, {
|
|
2157
2185
|
position: "center",
|
|
2158
2186
|
mt: "xs",
|
|
@@ -2353,7 +2381,8 @@ function withDefaults(series) {
|
|
|
2353
2381
|
}
|
|
2354
2382
|
function VizCartesianChartPanel({
|
|
2355
2383
|
conf,
|
|
2356
|
-
setConf
|
|
2384
|
+
setConf,
|
|
2385
|
+
data
|
|
2357
2386
|
}) {
|
|
2358
2387
|
const _a = conf, {
|
|
2359
2388
|
series,
|
|
@@ -2419,38 +2448,41 @@ function VizCartesianChartPanel({
|
|
|
2419
2448
|
size: 20
|
|
2420
2449
|
})
|
|
2421
2450
|
})]
|
|
2422
|
-
}), /* @__PURE__ */
|
|
2423
|
-
name: "x_axis_data_key",
|
|
2424
|
-
control,
|
|
2425
|
-
render: ({
|
|
2426
|
-
field
|
|
2427
|
-
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2428
|
-
size: "md",
|
|
2429
|
-
mb: "lg",
|
|
2430
|
-
label: "X Axis Data Key"
|
|
2431
|
-
}, field))
|
|
2432
|
-
}), /* @__PURE__ */ jsx(Group, {
|
|
2451
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
2433
2452
|
direction: "column",
|
|
2434
2453
|
grow: true,
|
|
2435
2454
|
noWrap: true,
|
|
2436
2455
|
mb: "lg",
|
|
2437
|
-
children: /* @__PURE__ */ jsx(Controller, {
|
|
2456
|
+
children: [/* @__PURE__ */ jsx(Controller, {
|
|
2457
|
+
name: "x_axis_data_key",
|
|
2458
|
+
control,
|
|
2459
|
+
render: ({
|
|
2460
|
+
field
|
|
2461
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2462
|
+
label: "X Axis Data Field",
|
|
2463
|
+
required: true,
|
|
2464
|
+
data,
|
|
2465
|
+
sx: {
|
|
2466
|
+
flex: 1
|
|
2467
|
+
}
|
|
2468
|
+
}, field))
|
|
2469
|
+
}), /* @__PURE__ */ jsx(Controller, {
|
|
2438
2470
|
name: "x_axis_name",
|
|
2439
2471
|
control,
|
|
2440
2472
|
render: ({
|
|
2441
2473
|
field
|
|
2442
2474
|
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2443
|
-
size: "md",
|
|
2444
2475
|
label: "X Axis Name"
|
|
2445
2476
|
}, field))
|
|
2446
|
-
})
|
|
2477
|
+
})]
|
|
2447
2478
|
}), /* @__PURE__ */ jsx(YAxesField, {
|
|
2448
2479
|
control,
|
|
2449
2480
|
watch
|
|
2450
2481
|
}), /* @__PURE__ */ jsx(SeriesField, {
|
|
2451
2482
|
control,
|
|
2452
2483
|
watch,
|
|
2453
|
-
getValues
|
|
2484
|
+
getValues,
|
|
2485
|
+
data
|
|
2454
2486
|
})]
|
|
2455
2487
|
})
|
|
2456
2488
|
});
|
|
@@ -2460,7 +2492,8 @@ function VizPiePanel({
|
|
|
2460
2492
|
label_field,
|
|
2461
2493
|
value_field
|
|
2462
2494
|
},
|
|
2463
|
-
setConf
|
|
2495
|
+
setConf,
|
|
2496
|
+
data
|
|
2464
2497
|
}) {
|
|
2465
2498
|
const form = useForm$1({
|
|
2466
2499
|
initialValues: {
|
|
@@ -2503,19 +2536,14 @@ function VizPiePanel({
|
|
|
2503
2536
|
border: "1px solid #eee",
|
|
2504
2537
|
borderRadius: "5px"
|
|
2505
2538
|
},
|
|
2506
|
-
children: [/* @__PURE__ */ jsx(
|
|
2539
|
+
children: [/* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2507
2540
|
label: "Label Field",
|
|
2508
2541
|
required: true,
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
}
|
|
2512
|
-
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2542
|
+
data
|
|
2543
|
+
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2513
2544
|
label: "Value Field",
|
|
2514
|
-
placeholder: "get column value by this field",
|
|
2515
2545
|
required: true,
|
|
2516
|
-
|
|
2517
|
-
flex: 1
|
|
2518
|
-
}
|
|
2546
|
+
data
|
|
2519
2547
|
}, form.getInputProps("value_field")))]
|
|
2520
2548
|
})]
|
|
2521
2549
|
})
|
|
@@ -2713,7 +2741,8 @@ function _ColorArrayInput({
|
|
|
2713
2741
|
const ColorArrayInput = React.forwardRef(_ColorArrayInput);
|
|
2714
2742
|
function VizStatsPanel({
|
|
2715
2743
|
conf,
|
|
2716
|
-
setConf
|
|
2744
|
+
setConf,
|
|
2745
|
+
data
|
|
2717
2746
|
}) {
|
|
2718
2747
|
const defaultValues = _.merge({}, {
|
|
2719
2748
|
align: "center",
|
|
@@ -2789,6 +2818,7 @@ function VizStatsPanel({
|
|
|
2789
2818
|
children: [/* @__PURE__ */ jsxs(Group, {
|
|
2790
2819
|
direction: "row",
|
|
2791
2820
|
grow: true,
|
|
2821
|
+
noWrap: true,
|
|
2792
2822
|
children: [/* @__PURE__ */ jsx(Controller, {
|
|
2793
2823
|
name: "content.prefix",
|
|
2794
2824
|
control,
|
|
@@ -2805,12 +2835,10 @@ function VizStatsPanel({
|
|
|
2805
2835
|
control,
|
|
2806
2836
|
render: ({
|
|
2807
2837
|
field
|
|
2808
|
-
}) => /* @__PURE__ */ jsx(
|
|
2838
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2809
2839
|
label: "Data Field",
|
|
2810
2840
|
required: true,
|
|
2811
|
-
|
|
2812
|
-
flexGrow: 1
|
|
2813
|
-
}
|
|
2841
|
+
data
|
|
2814
2842
|
}, field))
|
|
2815
2843
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
2816
2844
|
name: "content.postfix",
|
|
@@ -2939,7 +2967,8 @@ function SunburstPanel({
|
|
|
2939
2967
|
label_field,
|
|
2940
2968
|
value_field
|
|
2941
2969
|
},
|
|
2942
|
-
setConf
|
|
2970
|
+
setConf,
|
|
2971
|
+
data
|
|
2943
2972
|
}) {
|
|
2944
2973
|
const form = useForm$1({
|
|
2945
2974
|
initialValues: {
|
|
@@ -2982,19 +3011,14 @@ function SunburstPanel({
|
|
|
2982
3011
|
border: "1px solid #eee",
|
|
2983
3012
|
borderRadius: "5px"
|
|
2984
3013
|
},
|
|
2985
|
-
children: [/* @__PURE__ */ jsx(
|
|
3014
|
+
children: [/* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2986
3015
|
label: "Label Field",
|
|
2987
3016
|
required: true,
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
}
|
|
2991
|
-
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
3017
|
+
data
|
|
3018
|
+
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2992
3019
|
label: "Value Field",
|
|
2993
|
-
placeholder: "get column value by this field",
|
|
2994
3020
|
required: true,
|
|
2995
|
-
|
|
2996
|
-
flex: 1
|
|
2997
|
-
}
|
|
3021
|
+
data
|
|
2998
3022
|
}, form.getInputProps("value_field")))]
|
|
2999
3023
|
})]
|
|
3000
3024
|
})
|
|
@@ -3026,7 +3050,8 @@ function VizTablePanel(_e) {
|
|
|
3026
3050
|
} = _h, restConf = __objRest(_h, [
|
|
3027
3051
|
"columns"
|
|
3028
3052
|
]), {
|
|
3029
|
-
setConf
|
|
3053
|
+
setConf,
|
|
3054
|
+
data
|
|
3030
3055
|
} = _f;
|
|
3031
3056
|
const form = useForm$1({
|
|
3032
3057
|
initialValues: __spreadValues({
|
|
@@ -3080,10 +3105,10 @@ function VizTablePanel(_e) {
|
|
|
3080
3105
|
border: "1px solid #eee",
|
|
3081
3106
|
borderRadius: "5px"
|
|
3082
3107
|
},
|
|
3083
|
-
children: [/* @__PURE__ */ jsx(
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3108
|
+
children: [/* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
3109
|
+
label: "ID Field",
|
|
3110
|
+
required: true,
|
|
3111
|
+
data
|
|
3087
3112
|
}, form.getInputProps("id_field"))), /* @__PURE__ */ jsxs(Group, {
|
|
3088
3113
|
position: "apart",
|
|
3089
3114
|
mb: "lg",
|
|
@@ -3179,25 +3204,16 @@ function VizTablePanel(_e) {
|
|
|
3179
3204
|
children: [/* @__PURE__ */ jsxs(Group, {
|
|
3180
3205
|
position: "apart",
|
|
3181
3206
|
grow: true,
|
|
3182
|
-
sx: {
|
|
3183
|
-
"> *": {
|
|
3184
|
-
flexGrow: 1,
|
|
3185
|
-
maxWidth: "100%"
|
|
3186
|
-
}
|
|
3187
|
-
},
|
|
3188
3207
|
children: [/* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
3189
3208
|
label: "Label",
|
|
3190
3209
|
required: true,
|
|
3191
3210
|
sx: {
|
|
3192
3211
|
flex: 1
|
|
3193
3212
|
}
|
|
3194
|
-
}, form.getListInputProps("columns", index2, "label"))), /* @__PURE__ */ jsx(
|
|
3213
|
+
}, form.getListInputProps("columns", index2, "label"))), /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
3195
3214
|
label: "Value Field",
|
|
3196
|
-
placeholder: "get column value by this field",
|
|
3197
3215
|
required: true,
|
|
3198
|
-
|
|
3199
|
-
flex: 1
|
|
3200
|
-
}
|
|
3216
|
+
data
|
|
3201
3217
|
}, form.getListInputProps("columns", index2, "value_field"))), /* @__PURE__ */ jsx(ValueTypeSelector, __spreadValues({
|
|
3202
3218
|
label: "Value Type",
|
|
3203
3219
|
sx: {
|
|
@@ -3405,6 +3421,7 @@ const types = [{
|
|
|
3405
3421
|
}];
|
|
3406
3422
|
function EditVizConf() {
|
|
3407
3423
|
const {
|
|
3424
|
+
data,
|
|
3408
3425
|
viz,
|
|
3409
3426
|
setViz
|
|
3410
3427
|
} = React.useContext(PanelContext);
|
|
@@ -3449,7 +3466,8 @@ function EditVizConf() {
|
|
|
3449
3466
|
})
|
|
3450
3467
|
}), Panel2 && /* @__PURE__ */ jsx(Panel2, {
|
|
3451
3468
|
conf: viz.conf,
|
|
3452
|
-
setConf: setVizConf
|
|
3469
|
+
setConf: setVizConf,
|
|
3470
|
+
data
|
|
3453
3471
|
}), !Panel2 && /* @__PURE__ */ jsx(JsonInput, {
|
|
3454
3472
|
minRows: 20,
|
|
3455
3473
|
label: "Config",
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(y,T){typeof exports=="object"&&typeof module!="undefined"?T(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"],T):(y=typeof globalThis!="undefined"?globalThis:y||self,T(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,T,_,P,r,he,ft,S,Ie,E,mt,ht,re,ie,Q,xt,Cr,w,$,q){"use strict";var br=Object.defineProperty,yr=Object.defineProperties;var Sr=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var Pe=(y,T,_)=>T in y?br(y,T,{enumerable:!0,configurable:!0,writable:!0,value:_}):y[T]=_,h=(y,T)=>{for(var _ in T||(T={}))dt.call(T,_)&&Pe(y,_,T[_]);if(me)for(var _ of me(T))ct.call(T,_)&&Pe(y,_,T[_]);return y},G=(y,T)=>yr(y,Sr(T));var z=(y,T)=>{var _={};for(var P in y)dt.call(y,P)&&T.indexOf(P)<0&&(_[P]=y[P]);if(y!=null&&me)for(var P of me(y))T.indexOf(P)<0&&ct.call(y,P)&&(_[P]=y[P]);return _};var pt=(y,T,_)=>(Pe(y,typeof T!="symbol"?T+"":T,_),_);function U(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function gt(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 l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var c=U(T),D=U(_),Le=U(P),bt=U(ft),yt=U(Ie),oe=U(mt),B=gt(ht),K=U(xt),A=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(A||{});const St={layoutFrozen:!1,freezeLayout:()=>{},mode:A.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},j=c.default.createContext(St);function Ct(e,n){const i=Object.keys(n),l=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(o){return console.error(o),o.message}}function xe(e,n){const i=Object.keys(n),l=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(o){throw i.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):o}}function Ae(e,n){const i=n.sqlSnippets.reduce((l,o)=>(l[o.key]=xe(o.value,e),l),{});return D.default.merge({},i,e)}function wt(e,n,i){try{const l=Ae(n,i);return xe(e,l)}catch(l){return console.error(l),l.message}}const Y={baseURL:"http://localhost:31200",getRequest(e){return(n,i,l={})=>{const o=h({"X-Requested-With":"XMLHttpRequest","Content-Type":l.string?"application/x-www-form-urlencoded":"application/json"},l.headers),s={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?i:l.params,headers:o};return e==="POST"&&(s.data=l.string?JSON.stringify(i):i),bt.default(s).then(a=>a.data).catch(a=>Promise.reject(a))}}},Me=({context:e,definitions:n,title:i,dataSource:l})=>async()=>{if(!l||!l.sql)return[];const{type:o,key:s,sql:a}=l,u=a.includes("$");try{const d=Ae(e,n),f=xe(a,d);return u&&(console.groupCollapsed(`Final SQL for: ${i}`),console.log(f),console.groupEnd()),await Y.getRequest("POST")("/query",{type:o,key:s,sql:f})}catch(d){return console.error(d),[]}};async function vt(){try{return await Y.getRequest("GET")("/query/sources",{})}catch(e){return console.error(e),{}}}const Oe={},Tt=Oe,R=c.default.createContext(Oe),Gt={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},dataSourceID:"",setDataSourceID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},M=c.default.createContext(Gt),_t={sqlSnippets:[],setSQLSnippets:()=>{},dataSources:[],setDataSources:()=>{}},O=c.default.createContext(_t);var le={exports:{}},ae={};/**
|
|
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,It=Symbol.for("react.element"),zt=Symbol.for("react.fragment"),Dt=Object.prototype.hasOwnProperty,Pt=_t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Lt={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)&&!Lt.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:It,type:e,key:s,ref:a,props:l,_owner:Pt.current}}le.Fragment=zt,le.jsx=Oe,le.jsxs=Oe,oe.exports=le;const t=oe.exports.jsx,p=oe.exports.jsxs,X=oe.exports.Fragment;function ke({position:e,trigger:n="click"}){const{freezeLayout:i}=c.default.useContext(F),[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(bt.default,{readOnly:!0,value:s,onChange:I.default.noop,sx:{border:"none"}})})}function At(){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(De.RichTextEditor,{value:i,onChange:o,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Ee 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 Mt(){const{title:e}=c.default.useContext(A);return t(Ee,{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(A),[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(At,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Mt,{})})]})}function qe({id:e}){const n=c.default.useContext(M),i=c.default.useContext($),o=c.default.useMemo(()=>n.dataSources.find(u=>u.id===e),[n.dataSources,e]),{data:l=[],loading:s,refresh:a}=me.useRequest(Ae({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(M),{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(qe,{id:n})]})}B.use([ne.SunburstChart,re.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=z(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=I.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=I.default.merge({},qt,x,a,{series:{data:u}});return t(ie.default,{echarts:B,option:m,style:{width:i,height:o}})}B.use([ne.BarChart,ne.LineChart,W.GridComponent,W.LegendComponent,W.TooltipComponent,re.CanvasRenderer]);const Rt={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 Bt({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(O){return console.error(O),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 O=T,{y_axis_data_key:m,yAxisIndex:h,label_position:g,name:y}=O,C=z(O,["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: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=z(C,["label_formatter"]);var T;return G(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:y,value:C})=>{var P;if(!y)return C;const T=a[y],O=(P=s[T])!=null?P:s.default;return`${y}: ${O({value:C})}`});return g.unshift(`<strong>${h[0].name}</strong>`),g.join("<br />")}}};return I.default.merge({},Rt,d)},[e,n]);return!i||!o?null:t(ie.default,{echarts:B,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 Ft({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=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 Wt({value:e,type:n}){switch(n){case j.string:return t(Ft,{value:e});case j.eloc:return t(jt,{value:e});case j.number:return t(Nt,{value:e});case j.percentage:return t(Vt,{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=z(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,G(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=G(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 Jt({conf:{paragraphs:e},data:n}){return t(X,{children:e.map((a,s)=>{var u=a,{template:i,size:o}=u,l=z(u,["template","size"]);return t(r.Text,G(f({},l),{sx:{fontSize:o},children:Ut(i,n[0])}),`${i}---${s}`)})})}B.use([W.GridComponent,W.VisualMapComponent,W.LegendComponent,W.TooltipComponent,re.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=z(h,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),d=c.default.useMemo(()=>I.default.minBy(n,g=>g[a])[a],[n,a]),x=c.default.useMemo(()=>I.default.maxBy(n,g=>g[a])[a],[n,a]),m=G(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 Sr="";B.use([ne.PieChart,re.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=z(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=I.default.merge({},Kt,d,a,{series:{data:u}});return t(ie.default,{echarts:B,option:x,style:{width:i,height:o}})}var $e=function(){};const Zt=(e,n,i)=>Math.min(Math.max(i,e),n),Re=(e,n,i)=>{const o=n-e;return o===0?1:(i-e)/o},xe=(e,n,i)=>-i*e+i*n+e,Be=(e,n)=>i=>Math.max(Math.min(i,n),e),Z=e=>e%1?Number(e.toFixed(5)):e,ae=/(-)?([\d]*\.?[\d])+/g,ge=/(#[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 H(e){return typeof e=="string"}const se={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Fe=Object.assign(Object.assign({},se),{transform:Be(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 be=(e,n)=>i=>Boolean(H(i)&&Ht.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),je=(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:be("hsl","hue"),parse:je("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(Fe.transform(o))+")"},en=Be(0,255),ye=Object.assign(Object.assign({},se),{transform:e=>Math.round(en(e))}),N={test:be("rgb","red"),parse:je("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:o=1})=>"rgba("+ye.transform(e)+", "+ye.transform(n)+", "+ye.transform(i)+", "+Z(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 Se={test:be("#"),parse:tn,transform:N.transform},ue={test:e=>N.test(e)||Se.test(e)||U.test(e),parse:e=>N.test(e)?N.parse(e):U.test(e)?U.parse(e):Se.parse(e),transform:e=>H(e)?e:e.hasOwnProperty("red")?N.transform(e):U.transform(e)},Ne="${c}",Ve="${n}";function nn(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(ge))===null||o===void 0?void 0:o.length)!==null&&l!==void 0?l:0)>0}function We(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const o=e.match(ge);o&&(i=o.length,e=e.replace(ge,Ne),n.push(...o.map(ue.parse)));const l=e.match(ae);return l&&(e=e.replace(ae,Ve),n.push(...l.map(se.parse))),{values:n,numColors:i,tokenised:e}}function Qe(e){return We(e).values}function Ue(e){const{values:n,numColors:i,tokenised:o}=We(e),l=n.length;return s=>{let a=o;for(let u=0;u<l;u++)a=a.replace(u<i?Ne:Ve,u<i?ue.transform(s[u]):Z(s[u]));return a}}const rn=e=>typeof e=="number"?0:e;function on(e){const n=Qe(e);return Ue(e)(n.map(rn))}const Je={test:nn,parse:Qe,createTransformer:Ue,getAnimatableNone:on};function Ce(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 Ye({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=Ce(d,u,e+1/3),s=Ce(d,u,e),a=Ce(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=[Se,N,U],Ke=e=>an.find(n=>n.test(e)),Xe=(e,n)=>{let i=Ke(e),o=Ke(n),l=i.parse(e),s=o.parse(n);i===U&&(l=Ye(l),i=N),o===U&&(s=Ye(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=xe(l.alpha,s.alpha,u),i.transform(a)}},sn=e=>typeof e=="number",un=(e,n)=>i=>n(e(i)),Ze=(...e)=>e.reduce(un);function He(e,n){return sn(e)?i=>xe(e,n,i):ue.test(e)?Xe(e,n):nt(e,n)}const et=(e,n)=>{const i=[...e],o=i.length,l=e.map((s,a)=>He(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]=He(e[l],n[l]));return l=>{for(const s in o)i[s]=o[s](l);return i}};function tt(e){const n=Je.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 nt=(e,n)=>{const i=Je.createTransformer(n),o=tt(e),l=tt(n);return o.numHSL===l.numHSL&&o.numRGB===l.numRGB&&o.numNumbers>=l.numNumbers?Ze(et(o.parsed,l.parsed),i):a=>`${a>0?n:e}`},cn=(e,n)=>i=>xe(e,n,i);function pn(e){if(typeof e=="number")return cn;if(typeof e=="string")return ue.test(e)?Xe:nt;if(Array.isArray(e))return et;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=Ze(d,u)}o.push(u)}return o}function mn([e,n],[i]){return o=>i(Re(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=Re(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;$e(s===n.length),$e(!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}){ct(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(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Sn(s){var a=s,{conf:u}=a,d=u,{content:e,size:n,color:i}=d,o=z(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,T=(P=l==null?void 0:l[0])==null?void 0:P[y];return["string","number"].includes(typeof T)?[h,K.default(T).format(C),g].join(" "):yn(T)},[e,l]);return t(r.Text,G(f({},o),{color:x,sx:{fontSize:n},children:m}))}function Cn(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(Bt,f({},l));case"table":return t(Qt,f({},l));case"text":return t(Jt,f({},l));case"stats":return t(Sn,f({},l));case"bar-3d":return t(Yt,f({},l));case"pie":return t(Xt,f({},l));default:return null}}function rt({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&&t(Ee,{children:Cn(l,s,n,e)})]})}function wn({}){const{data:e,loading:n,viz:i}=c.default.useContext(A);return t(rt,{viz:i,data:e,loading:n})}function vn({conf:e,setConf:n}){const i=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 Tn({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 we=c.default.forwardRef(Tn),Gn=[{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 _n({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=z(h,["value","onChange"]);var g;return t(r.Select,G(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(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:Gn},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(we,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 In({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: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(_n,{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 it={mantissa:0,output:"number"};function zn({value:e,onChange:n},i){const o=a=>{n(G(f({},e),{output:a}))},l=a=>{const u=a===0?!1:e.trimMantissa;n(G(f({},e),{mantissa:a,trimMantissa:u}))},s=a=>{n(G(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 ot=c.default.forwardRef(zn);function Dn({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(ot,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 Pn({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:it});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((d,x)=>t(Dn,{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 Ln(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 An({conf:e,setConf:n}){const h=e,{series:i,y_axes:o}=h,l=z(h,["series","y_axes"]),s=c.default.useMemo(()=>{const C=l,{x_axis_name:g=""}=C,y=z(C,["x_axis_name"]);return f({series:Ln(i!=null?i:[]),x_axis_name:g,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:it}]},y)},[i,l]);c.default.useEffect(()=>{!I.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(Pn,{control:a,watch:d}),t(In,{control:a,watch:d,getValues:m})]})})}function Mn({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 de=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function On({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 lt=c.default.forwardRef(On);function kn({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(()=>!I.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 y=g.currentTarget.value;s(C=>(C.splice(h,1,y),[...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 En=c.default.forwardRef(kn);function qn({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(y=>(y.splice(g,1),[...y]))},[s]),d=c.default.useMemo(()=>!I.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,y])=>y[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,y)=>t(r.ColorInput,{value:g,onChange:C=>{s(T=>(T.splice(y,1,C),[...T]))},swatches:h,rightSection:t(r.ActionIcon,{onClick:()=>u(y),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 $n=c.default.forwardRef(qn);function Rn({conf:e,setConf:n}){const i=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(ot,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(lt,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(we,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(En,f({label:"Value Range"},d))}),t(w.Controller,{name:"color.colorRange",control:o,render:({field:d})=>t($n,f({label:"Color Range"},d))})]})]})})]})]})})}function Bn({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 Fn=Object.values(j).map(e=>({label:e,value:e}));function jn({label:e,value:n,onChange:i,sx:o}){return t(r.Select,{label:e,data:Fn,value:n,onChange:i,sx:o})}function Nn(o){var l=o,{conf:s}=l,a=s,{columns:e}=a,n=z(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(jn,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(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(u.values,null,2)})]})})}const at=[{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 Vn({conf:e,setConf:n}){var l;const i=q.useForm({initialValues:{paragraphs:q.formList((l=e.paragraphs)!=null?l:at)}}),o=()=>i.addListItem("paragraphs",G(f({},at[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(we,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(lt,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(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const ve=[{value:"text",label:"Text",Panel:Vn},{value:"stats",label:"Stats",Panel:Rn},{value:"table",label:"Table",Panel:Nn},{value:"sunburst",label:"Sunburst",Panel:Bn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:vn},{value:"cartesian",label:"Cartesian Chart",Panel:An},{value:"pie",label:"Pie Chart",Panel:Mn}];function Wn(){const{viz:e,setViz:n}=c.default.useContext(A),[i,o]=E.useInputState(e.type),l=e.type!==i,s=c.default.useCallback(()=>{!l||n(x=>G(f({},x),{type:i}))},[l,i]),a=x=>{n(m=>G(f({},m),{conf:x}))},u=x=>{try{a(JSON.parse(x))}catch(m){console.error(m)}},d=c.default.useMemo(()=>{var x;return(x=ve.find(m=>m.value===i))==null?void 0:x.Panel},[i,ve]);return p(X,{children:[t(r.Select,{label:"Visualization",value:i,onChange:o,data:ve,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 Qn({}){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(Wn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(wn,{})})]})}function Un({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(F),{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(Et,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(kt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Qn,{})})]})})})}function Jn({}){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(F);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(Un,{opened:e,close:o})]})}var wr="";function Te({viz:e,dataSourceID:n,title:i,description:o,update:l,layout:s,id:a}){const u=c.default.useContext($),d=c.default.useContext(M),[x,m]=c.default.useState(i),[h,g]=c.default.useState(o),[y,C]=c.default.useState(n),[T,O]=c.default.useState(e),P=c.default.useMemo(()=>{if(!!y)return d.dataSources.find(Ie=>Ie.id===y)},[y,d.dataSources]);c.default.useEffect(()=>{l==null||l({id:a,layout:s,title:x,description:h,dataSourceID:y,viz:T})},[x,h,P,T,a,s,y]);const{data:Y=[],loading:ce,refresh:te}=me.useRequest(Ae({context:u,definitions:d,title:x,dataSource:P}),{refreshDeps:[u,d,P]}),_e=te;return t(A.Provider,{value:{data:Y,loading:ce,title:x,setTitle:m,description:h,setDescription:g,dataSourceID:y,setDataSourceID:C,viz:T,setViz:O,refreshData:_e},children:p(r.Container,{className:"panel-root",children:[t(Jn,{}),t(rt,{viz:T,data:Y,loading:ce})]})})}var vr="";const Yn=D.WidthProvider(Pe.default);function st({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(y=>{var C=y,{i:h}=C,g=z(C,["i"]);x.set(h,g)});const m=e.map(h=>G(f({},h),{layout:x.get(h.id)}));n(m)},[e,n]);return t(Yn,{onLayoutChange:u,className:i,rowHeight:o,isDraggable:s,isResizable:a,children:e.map((h,m)=>{var g=h,{id:d}=g,x=z(g,["id"]);return t("div",{"data-grid":x.layout,children:t(Te,G(f({id:d},x),{destroy:()=>l(d),update:y=>{n(C=>(C.splice(m,1,y),[...C]))}}))},d)})})}function Ge(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Kn({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:Ge(t(S.PlayerPlay,{size:20}),"Use"),value:L.Use},{label:Ge(t(S.Resize,{size:20}),"Layout"),value:L.Layout},{label:Ge(t(S.Paint,{size:20}),"Content"),value:L.Edit}]})}const Xn=`
|
|
9
|
+
*/var Dt=c.default,zt=Symbol.for("react.element"),Pt=Symbol.for("react.fragment"),It=Object.prototype.hasOwnProperty,Lt=Dt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0};function ke(e,n,i){var l,o={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(l in n)It.call(n,l)&&!At.hasOwnProperty(l)&&(o[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)o[l]===void 0&&(o[l]=n[l]);return{$$typeof:zt,type:e,key:s,ref:a,props:o,_owner:Lt.current}}ae.Fragment=Pt,ae.jsx=ke,ae.jsxs=ke,le.exports=ae;const t=le.exports.jsx,p=le.exports.jsxs,Z=le.exports.Fragment;function qe({position:e,trigger:n="click"}){const{freezeLayout:i}=c.default.useContext(j),[l,o]=c.default.useState(!1),{description:s}=c.default.useContext(M);if(c.default.useEffect(()=>{i(l)},[l]),!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:()=>o(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:l,onClose:()=>o(!1),withCloseButton:!0,withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,children:t(yt.default,{readOnly:!0,value:s,onChange:D.default.noop,sx:{border:"none"}})})}function Mt(){const{description:e,setDescription:n}=c.default.useContext(M),[i,l]=c.default.useState(e),o=e!==i,s=c.default.useCallback(()=>{!o||n(i)},[o,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:!o,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(Ie.RichTextEditor,{value:i,onChange:l,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Ee 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 Ot(){const{title:e}=c.default.useContext(M);return t(Ee,{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(qe,{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 kt(){const{title:e,setTitle:n}=c.default.useContext(M),[i,l]=E.useInputState(e),o=e!==i,s=c.default.useCallback(()=>{!o||n(i)},[o,i]);return t(r.TextInput,{value:i,onChange:l,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!o,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function qt({}){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(kt,{}),t(Mt,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Ot,{})})]})}function $e({id:e}){const n=c.default.useContext(O),i=c.default.useContext(R),l=c.default.useMemo(()=>n.dataSources.find(u=>u.id===e),[n.dataSources,e]),{data:o=[],loading:s,refresh:a}=he.useRequest(Me({context:i,definitions:n,title:e,dataSource:l}),{refreshDeps:[i,n,l]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):o.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"}),o.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",o.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(o==null?void 0:o[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:o.slice(0,10).map((u,d)=>t("tr",{children:Object.values(u).map((f,x)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:f})})},`${f}--${x}`))},`row-${d}`))})]})]})}function Et({}){const{dataSources:e}=c.default.useContext(O),{dataSourceID:n,setDataSourceID:i,data:l,loading:o}=c.default.useContext(M),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($e,{id:n})]})}B.use([re.SunburstChart,ie.CanvasRenderer]);const $t={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Rt({conf:e,data:n,width:i,height:l}){const m=e,{label_field:o="name",value_field:s="value"}=m,a=z(m,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(g=>({name:g[o],value:Number(g[s])})),[n,o,s]),d=c.default.useMemo(()=>{var g,b;return(b=(g=D.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?b:1},[u]),f=c.default.useMemo(()=>({series:{label:{formatter:({name:g,value:b})=>b/d<.2?" ":g}}}),[d]),x=D.default.merge({},$t,f,a,{series:{data:u}});return t(oe.default,{echarts:B,option:x,style:{width:i,height:l}})}B.use([re.BarChart,re.LineChart,Q.GridComponent,Q.LegendComponent,Q.TooltipComponent,ie.CanvasRenderer]);const Ft={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 Bt({conf:e,data:n,width:i,height:l}){const o=c.default.useMemo(()=>{var f;const s=e.y_axes.reduce((x,{label_formatter:m},g)=>(x[g]=function(C){const v=typeof C=="object"?C.value:C;if(!m)return v;try{return K.default(v).format(m)}catch(k){return console.error(k),v}},x),{default:({value:x})=>x}),a=e.series.reduce((x,{yAxisIndex:m,name:g})=>(x[g]=m,x),{}),u=e.series.map(v=>{var k=v,{y_axis_data_key:x,yAxisIndex:m,label_position:g,name:b}=k,C=z(k,["y_axis_data_key","yAxisIndex","label_position","name"]);return h({data:n.map(X=>X[x]),label:{show:!!g,position:g,formatter:s[m!=null?m:"default"]},name:b,yAxisIndex:m},C)}),d={xAxis:{data:n.map(x=>x[e.x_axis_data_key]),name:(f=e.x_axis_name)!=null?f:""},yAxis:e.y_axes.map((b,g)=>{var C=b,{label_formatter:x}=C,m=z(C,["label_formatter"]);var v;return G(h({},m),{axisLabel:{show:!0,formatter:(v=s[g])!=null?v:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(x){const m=Array.isArray(x)?x:[x];if(m.length===0)return"";const g=m.map(({seriesName:b,value:C})=>{var L;if(!b)return C;const v=a[b],k=(L=s[v])!=null?L:s.default;return`${b}: ${k({value:C})}`});return g.unshift(`<strong>${m[0].name}</strong>`),g.join("<br />")}}};return D.default.merge({},Ft,d)},[e,n]);return!i||!l?null:t(oe.default,{echarts:B,option:o,style:{width:i,height:l}})}var N=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(N||{});function jt({value:e}){return t(r.Text,{component:"span",children:e})}function Nt({value:e}){return t(r.Text,{component:"span",children:e})}function Vt({value:e}){const n=K.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Wt({value:e}){const n=K.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function Qt({value:e,type:n}){switch(n){case N.string:return t(jt,{value:e});case N.eloc:return t(Nt,{value:e});case N.number:return t(Vt,{value:e});case N.percentage:return t(Wt,{value:e})}}function Ut({conf:e,data:n=[],width:i,height:l}){const x=e,{id_field:o,use_raw_columns:s,columns:a}=x,u=z(x,["id_field","use_raw_columns","columns"]),d=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(m=>m.label),[s,a,n]),f=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(m=>({label:m,value_field:m,value_type:N.string})):a,[s,a,n]);return p(r.Table,G(h({sx:{maxHeight:l}},u),{children:[t("thead",{children:t("tr",{children:d.map(m=>t("th",{children:m},m))})}),t("tbody",{children:n.slice(0,30).map((m,g)=>t("tr",{children:f.map(({value_field:b,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Qt,{value:m[b],type:C})})},`${b}--${m[b]}`))},o?m[o]:`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 Jt(e,n={}){const i=G(h({},n),{numbro:K.default}),l=Object.keys(i),o=Object.values(i);try{return new Function(...l,`return \`${e}\`;`)(...o)}catch(s){return s.message}}function Yt({conf:{paragraphs:e},data:n}){return t(Z,{children:e.map((a,s)=>{var u=a,{template:i,size:l}=u,o=z(u,["template","size"]);return t(r.Text,G(h({},o),{sx:{fontSize:l},children:Jt(i,n[0])}),`${i}---${s}`)})})}B.use([Q.GridComponent,Q.VisualMapComponent,Q.LegendComponent,Q.TooltipComponent,ie.CanvasRenderer]);function Xt({conf:e,data:n,width:i,height:l}){const m=e,{x_axis_data_key:o,y_axis_data_key:s,z_axis_data_key:a}=m,u=z(m,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),d=c.default.useMemo(()=>D.default.minBy(n,g=>g[a])[a],[n,a]),f=c.default.useMemo(()=>D.default.maxBy(n,g=>g[a])[a],[n,a]),x=G(h({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:f,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[o],g[s],g[a]])}]});return t(oe.default,{echarts:B,option:x,style:{width:i,height:l}})}var wr="";B.use([re.PieChart,ie.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 Zt({conf:e,data:n,width:i,height:l}){const x=e,{label_field:o="name",value_field:s="value"}=x,a=z(x,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(m=>({name:m[o],value:Number(m[s])})),[n,o,s]),d=c.default.useMemo(()=>({series:{labelLayout:function(m){const g=m.labelRect.x<i/2,b=m.labelLinePoints;return b[2][0]=g?m.labelRect.x:m.labelRect.x+m.labelRect.width,{labelLinePoints:b}}}}),[i]),f=D.default.merge({},Kt,d,a,{series:{data:u}});return t(oe.default,{echarts:B,option:f,style:{width:i,height:l}})}var Re=function(){};const Ht=(e,n,i)=>Math.min(Math.max(i,e),n),Fe=(e,n,i)=>{const l=n-e;return l===0?1:(i-e)/l},ge=(e,n,i)=>-i*e+i*n+e,Be=(e,n)=>i=>Math.max(Math.min(i,n),e),H=e=>e%1?Number(e.toFixed(5)):e,se=/(-)?([\d]*\.?[\d])+/g,be=/(#[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,en=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function ee(e){return typeof e=="string"}const ue={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},je=Object.assign(Object.assign({},ue),{transform:Be(0,1)});Object.assign(Object.assign({},ue),{default:1});const te=(e=>({test:n=>ee(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},te),{parse:e=>te.parse(e)/100,transform:e=>te.transform(e*100)});const ye=(e,n)=>i=>Boolean(ee(i)&&en.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Ne=(e,n,i)=>l=>{if(!ee(l))return l;const[o,s,a,u]=l.match(se);return{[e]:parseFloat(o),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},J={test:ye("hsl","hue"),parse:Ne("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:l=1})=>"hsla("+Math.round(e)+", "+te.transform(H(n))+", "+te.transform(H(i))+", "+H(je.transform(l))+")"},tn=Be(0,255),Se=Object.assign(Object.assign({},ue),{transform:e=>Math.round(tn(e))}),V={test:ye("rgb","red"),parse:Ne("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:l=1})=>"rgba("+Se.transform(e)+", "+Se.transform(n)+", "+Se.transform(i)+", "+H(je.transform(l))+")"};function nn(e){let n="",i="",l="",o="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),l=e.substr(5,2),o=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),l=e.substr(3,1),o=e.substr(4,1),n+=n,i+=i,l+=l,o+=o),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(l,16),alpha:o?parseInt(o,16)/255:1}}const Ce={test:ye("#"),parse:nn,transform:V.transform},de={test:e=>V.test(e)||Ce.test(e)||J.test(e),parse:e=>V.test(e)?V.parse(e):J.test(e)?J.parse(e):Ce.parse(e),transform:e=>ee(e)?e:e.hasOwnProperty("red")?V.transform(e):J.transform(e)},Ve="${c}",We="${n}";function rn(e){var n,i,l,o;return isNaN(e)&&ee(e)&&((i=(n=e.match(se))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((o=(l=e.match(be))===null||l===void 0?void 0:l.length)!==null&&o!==void 0?o:0)>0}function Qe(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const l=e.match(be);l&&(i=l.length,e=e.replace(be,Ve),n.push(...l.map(de.parse)));const o=e.match(se);return o&&(e=e.replace(se,We),n.push(...o.map(ue.parse))),{values:n,numColors:i,tokenised:e}}function Ue(e){return Qe(e).values}function Je(e){const{values:n,numColors:i,tokenised:l}=Qe(e),o=n.length;return s=>{let a=l;for(let u=0;u<o;u++)a=a.replace(u<i?Ve:We,u<i?de.transform(s[u]):H(s[u]));return a}}const on=e=>typeof e=="number"?0:e;function ln(e){const n=Ue(e);return Je(e)(n.map(on))}const Ye={test:rn,parse:Ue,createTransformer:Je,getAnimatableNone:ln};function we(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 Xe({hue:e,saturation:n,lightness:i,alpha:l}){e/=360,n/=100,i/=100;let o=0,s=0,a=0;if(!n)o=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,d=2*i-u;o=we(d,u,e+1/3),s=we(d,u,e),a=we(d,u,e-1/3)}return{red:Math.round(o*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:l}}const an=(e,n,i)=>{const l=e*e,o=n*n;return Math.sqrt(Math.max(0,i*(o-l)+l))},sn=[Ce,V,J],Ke=e=>sn.find(n=>n.test(e)),Ze=(e,n)=>{let i=Ke(e),l=Ke(n),o=i.parse(e),s=l.parse(n);i===J&&(o=Xe(o),i=V),l===J&&(s=Xe(s),l=V);const a=Object.assign({},o);return u=>{for(const d in a)d!=="alpha"&&(a[d]=an(o[d],s[d],u));return a.alpha=ge(o.alpha,s.alpha,u),i.transform(a)}},un=e=>typeof e=="number",dn=(e,n)=>i=>n(e(i)),He=(...e)=>e.reduce(dn);function et(e,n){return un(e)?i=>ge(e,n,i):de.test(e)?Ze(e,n):rt(e,n)}const tt=(e,n)=>{const i=[...e],l=i.length,o=e.map((s,a)=>et(s,n[a]));return s=>{for(let a=0;a<l;a++)i[a]=o[a](s);return i}},cn=(e,n)=>{const i=Object.assign(Object.assign({},e),n),l={};for(const o in i)e[o]!==void 0&&n[o]!==void 0&&(l[o]=et(e[o],n[o]));return o=>{for(const s in l)i[s]=l[s](o);return i}};function nt(e){const n=Ye.parse(e),i=n.length;let l=0,o=0,s=0;for(let a=0;a<i;a++)l||typeof n[a]=="number"?l++:n[a].hue!==void 0?s++:o++;return{parsed:n,numNumbers:l,numRGB:o,numHSL:s}}const rt=(e,n)=>{const i=Ye.createTransformer(n),l=nt(e),o=nt(n);return l.numHSL===o.numHSL&&l.numRGB===o.numRGB&&l.numNumbers>=o.numNumbers?He(tt(l.parsed,o.parsed),i):a=>`${a>0?n:e}`},pn=(e,n)=>i=>ge(e,n,i);function fn(e){if(typeof e=="number")return pn;if(typeof e=="string")return de.test(e)?Ze:rt;if(Array.isArray(e))return tt;if(typeof e=="object")return cn}function mn(e,n,i){const l=[],o=i||fn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=o(e[a],e[a+1]);if(n){const d=Array.isArray(n)?n[a]:n;u=He(d,u)}l.push(u)}return l}function hn([e,n],[i]){return l=>i(Fe(e,n,l))}function xn(e,n){const i=e.length,l=i-1;return o=>{let s=0,a=!1;if(o<=e[0]?a=!0:o>=e[l]&&(s=l-1,a=!0),!a){let d=1;for(;d<i&&!(e[d]>o||d===l);d++);s=d-1}const u=Fe(e[s],e[s+1],o);return n[s](u)}}function gn(e,n,{clamp:i=!0,ease:l,mixer:o}={}){const s=e.length;Re(s===n.length),Re(!l||!Array.isArray(l)||l.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=mn(n,l,o),u=s===2?hn(e,a):xn(e,a);return i?d=>u(Ht(e[0],e[s-1],d)):u}class bn{constructor({valueRange:n,colorRange:i}){pt(this,"mapper");this.mapper=gn(n,i)}getColor(n){return this.mapper(n)}}function yn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new bn(e),l=n[e.valueField];return i.getColor(l)}return"black"}function Sn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Cn(s){var a=s,{conf:u}=a,d=u,{content:e,size:n,color:i}=d,l=z(d,["content","size","color"]),{data:o}=a;const f=c.default.useMemo(()=>yn(i,o[0]),[i,o]),x=c.default.useMemo(()=>{var L;const{prefix:m,postfix:g,data_field:b,formatter:C}=e,v=(L=o==null?void 0:o[0])==null?void 0:L[b];return["string","number"].includes(typeof v)?[m,K.default(v).format(C),g].join(" "):Sn(v)},[e,o]);return t(r.Text,G(h({},l),{color:f,sx:{fontSize:n},children:x}))}function wn(e,n,i,l){const o={width:e,height:n,data:i,conf:l.conf};switch(l.type){case"sunburst":return t(Rt,h({},o));case"line-bar":case"cartesian":return t(Bt,h({},o));case"table":return t(Ut,h({},o));case"text":return t(Yt,h({},o));case"stats":return t(Cn,h({},o));case"bar-3d":return t(Xt,h({},o));case"pie":return t(Zt,h({},o));default:return null}}function it({viz:e,data:n,loading:i}){const{ref:l,width:o,height:s}=E.useElementSize(),a=c.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:l,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:l,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&t(Ee,{children:wn(o,s,n,e)})]})}function vn({}){const{data:e,loading:n,viz:i}=c.default.useContext(M);return t(it,{viz:i,data:e,loading:n})}function Tn({label:e,required:n,value:i,onChange:l,data:o,sx:s},a){const u=c.default.useMemo(()=>!Array.isArray(o)||o.length===0?[]:Object.keys(o[0]).map(f=>({label:f,value:f})),[o]);return t(r.Select,{ref:a,label:e,data:u,value:i,onChange:l,required:n,sx:s})}const I=c.default.forwardRef(Tn);function Gn({conf:e,setConf:n,data:i}){const l=D.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:s,formState:a}=w.useForm({defaultValues:l});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:s(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:u})=>t(I,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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:u})=>t(I,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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:u})=>t(I,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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 _n({value:e,onChange:n},i){const l=r.useMantineTheme(),o=c.default.useMemo(()=>Object.entries(l.colors).map(([a,u])=>({label:a,value:u[6]})),[l]),s=c.default.useMemo(()=>o.some(a=>a.value===e),[e,o]);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:o,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 ve=c.default.forwardRef(_n),Dn=[{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 zn({control:e,index:n,remove:i,seriesItem:l,yAxisOptions:o,data:s}){const a=l.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:u})=>t(r.SegmentedControl,h({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter",disabled:!0},{label:"Boxplot",value:"boxplot",disabled:!0}]},u))})}),t(w.Controller,{name:`series.${n}.name`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},u))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(w.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:u})=>t(I,h({label:"Value Field",required:!0,data:s,sx:{flex:1}},u))}),t(w.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:x=>{var{field:m}=x,g=m,{value:u,onChange:d}=g,f=z(g,["value","onChange"]);var b;return t(r.Select,G(h({label:"Y Axis",data:o,disabled:o.length===0},f),{value:(b=u==null?void 0:u.toString())!=null?b:"",onChange:C=>{if(!C){d(0);return}d(Number(C))},sx:{flex:1}}))}})]}),a==="bar"&&p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(w.Controller,{name:`series.${n}.stack`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},u))}),t(w.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Bar Width",sx:{flexGrow:1}},u))})]}),t(w.Controller,{name:`series.${n}.label_position`,control:e,render:({field:u})=>t(r.Select,h({label:"Label Position",data:Dn},u))}),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:u})=>t(ve,h({},u))})]}),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 Pn({control:e,watch:n,getValues:i,data:l}){const{fields:o,append:s,remove:a}=w.useFieldArray({control:e,name:"series"}),u=n("y_axes"),d=o.map((m,g)=>h(h({},m),u[g])),f=()=>s({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},g)=>({label:m,value:g.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),d.map((m,g)=>t(zn,{control:e,index:g,remove:a,seriesItem:m,yAxisOptions:x,data:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:f,children:"Add a Series"})})]})}const ot={mantissa:0,output:"number"};function In({value:e,onChange:n},i){const l=a=>{n(G(h({},e),{output:a}))},o=a=>{const u=a===0?!1:e.trimMantissa;n(G(h({},e),{mantissa:a,trimMantissa:u}))},s=a=>{n(G(h({},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:l}),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:s,disabled:e.mantissa===0})]})})}const lt=c.default.forwardRef(In);function Ln({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:l})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},l))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(w.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:l})=>t(lt,h({},l))})}),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 An({control:e,watch:n}){const{fields:i,append:l,remove:o}=w.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((d,f)=>h(h({},d),s[f])),u=()=>l({name:"",label_formatter:ot});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((d,f)=>t(Ln,{control:e,index:f,remove:o})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function Mn(e){function n({type:i,name:l,showSymbol:o,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:d="1",color:f="black",barWidth:x="30"}){return{type:i,name:l,showSymbol:o,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:d,color:f,barWidth:x}}return e.map(n)}function On({conf:e,setConf:n,data:i}){const g=e,{series:l,y_axes:o}=g,s=z(g,["series","y_axes"]),a=c.default.useMemo(()=>{const v=s,{x_axis_name:b=""}=v,C=z(v,["x_axis_name"]);return h({series:Mn(l!=null?l:[]),x_axis_name:b,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:ot}]},C)},[l,s]);c.default.useEffect(()=>{!D.default.isEqual(e,a)&&n(a)},[e,a]);const{control:u,handleSubmit:d,watch:f,formState:{isDirty:x},getValues:m}=w.useForm({defaultValues:a});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:d(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})})]}),p(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:[t(w.Controller,{name:"x_axis_data_key",control:u,render:({field:b})=>t(I,h({label:"X Axis Data Field",required:!0,data:i,sx:{flex:1}},b))}),t(w.Controller,{name:"x_axis_name",control:u,render:({field:b})=>t(r.TextInput,h({label:"X Axis Name"},b))})]}),t(An,{control:u,watch:f}),t(Pn,{control:u,watch:f,getValues:m,data:i})]})})}function kn({conf:{label_field:e,value_field:n},setConf:i,data:l}){const o=$.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(I,h({label:"Label Field",required:!0,data:l},o.getInputProps("label_field"))),t(I,h({label:"Value Field",required:!0,data:l},o.getInputProps("value_field")))]})]})})}const ce=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function qn({label:e,value:n,onChange:i},l){var a,u;const[o,s]=c.default.useState((u=(a=ce.find(d=>d.label===n))==null?void 0:a.value)!=null?u:ce[0].value);return c.default.useEffect(()=>{const d=ce.find(f=>f.value===o);d&&i(d.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:ce,value:o,onChange:s,step:25,placeholder:"Pick a font size",ref:l})]})}const at=c.default.forwardRef(qn);function En({label:e,value:n,onChange:i},l){const[o,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(x=>[...x,""])},[s]),u=c.default.useCallback(x=>{s(m=>(m.splice(x,1),[...m]))},[s]),d=c.default.useMemo(()=>!D.default.isEqual(o,n),[o,n]),f=()=>{i(o.map(x=>x.toString()))};return p(Z,{children:[p(r.Group,{position:"left",ref:l,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((x,m)=>t(r.TextInput,{value:x,onChange:g=>{const b=g.currentTarget.value;s(C=>(C.splice(m,1,b),[...C]))},rightSection:t(r.ActionIcon,{onClick:()=>u(m),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 $n=c.default.forwardRef(En);function Rn({label:e,value:n,onChange:i},l){const[o,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(()=>!D.default.isEqual(o,n),[o,n]),f=()=>{i(o.map(g=>g.toString()))},x=r.useMantineTheme(),m=c.default.useMemo(()=>Object.entries(x.colors).map(([g,b])=>b[6]),[x]);return p(Z,{children:[p(r.Group,{position:"left",ref:l,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((g,b)=>t(r.ColorInput,{value:g,onChange:C=>{s(v=>(v.splice(b,1,C),[...v]))},swatches:m,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 Fn=c.default.forwardRef(Rn);function Bn({conf:e,setConf:n,data:i}){const l=D.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:s,watch:a,formState:{isDirty:u}}=w.useForm({defaultValues:l}),d=a("color.type");return a("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:s(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:!u,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,noWrap:!0,children:[t(w.Controller,{name:"content.prefix",control:o,render:({field:f})=>t(r.TextInput,h({label:"Prefix",sx:{flexGrow:1}},f))}),t(w.Controller,{name:"content.data_field",control:o,render:({field:f})=>t(I,h({label:"Data Field",required:!0,data:i},f))}),t(w.Controller,{name:"content.postfix",control:o,render:({field:f})=>t(r.TextInput,h({label:"Postfix",sx:{flexGrow:1}},f))})]}),t(w.Controller,{name:"content.formatter",control:o,render:({field:f})=>t(lt,h({},f))})]})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(w.Controller,{name:"size",control:o,render:({field:f})=>t(r.TextInput,h({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},f))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(w.Controller,{name:"weight",control:o,render:({field:f})=>t(at,h({label:"Font Weight"},f))})})]}),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:f})=>t(r.Select,h({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},f))}),d==="static"&&t(w.Controller,{name:"color.staticColor",control:o,render:({field:f})=>t(ve,h({},f))}),d==="continuous"&&p(Z,{children:[t(w.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:f})=>t(r.TextInput,h({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},f))}),t(w.Controller,{name:"color.valueRange",control:o,render:({field:f})=>t($n,h({label:"Value Range"},f))}),t(w.Controller,{name:"color.colorRange",control:o,render:({field:f})=>t(Fn,h({label:"Color Range"},f))})]})]})})]})]})})}function jn({conf:{label_field:e,value_field:n},setConf:i,data:l}){const o=$.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(I,h({label:"Label Field",required:!0,data:l},o.getInputProps("label_field"))),t(I,h({label:"Value Field",required:!0,data:l},o.getInputProps("value_field")))]})]})})}const Nn=Object.values(N).map(e=>({label:e,value:e}));function Vn({label:e,value:n,onChange:i,sx:l}){return t(r.Select,{label:e,data:Nn,value:n,onChange:i,sx:l})}function Wn(o){var s=o,{conf:a}=s,u=a,{columns:e}=u,n=z(u,["columns"]),{setConf:i,data:l}=s;const d=$.useForm({initialValues:h({id_field:"id",use_raw_columns:!0,columns:$.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),f=()=>d.addListItem("columns",{label:E.randomId(),value_field:"value",value_type:N.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:d.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(I,h({label:"ID Field",required:!0,data:l},d.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,h({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.getInputProps("horizontalSpacing"))),t(r.TextInput,h({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,h({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.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,h({label:"Striped"},d.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,h({label:"Highlight on hover"},d.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,h({label:"Use Original Data Columns"},d.getInputProps("use_raw_columns",{type:"checkbox"}))),!d.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),d.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,children:[t(r.TextInput,h({label:"Label",required:!0,sx:{flex:1}},d.getListInputProps("columns",m,"label"))),t(I,h({label:"Value Field",required:!0,data:l},d.getListInputProps("columns",m,"value_field"))),t(Vn,h({label:"Value Type",sx:{flex:1}},d.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>d.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:f,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(q.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(d.values,null,2)})]})})}const st=[{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 Qn({conf:e,setConf:n}){var o;const i=$.useForm({initialValues:{paragraphs:$.formList((o=e.paragraphs)!=null?o:st)}}),l=()=>i.addListItem("paragraphs",G(h({},st[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,h({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(ve,h({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,h({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(at,h({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:l,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(q.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Te=[{value:"text",label:"Text",Panel:Qn},{value:"stats",label:"Stats",Panel:Bn},{value:"table",label:"Table",Panel:Wn},{value:"sunburst",label:"Sunburst",Panel:jn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:Gn},{value:"cartesian",label:"Cartesian Chart",Panel:On},{value:"pie",label:"Pie Chart",Panel:kn}];function Un(){const{data:e,viz:n,setViz:i}=c.default.useContext(M),[l,o]=E.useInputState(n.type),s=n.type!==l,a=c.default.useCallback(()=>{!s||i(x=>G(h({},x),{type:l}))},[s,l]),u=x=>{i(m=>G(h({},m),{conf:x}))},d=x=>{try{u(JSON.parse(x))}catch(m){console.error(m)}},f=c.default.useMemo(()=>{var x;return(x=Te.find(m=>m.value===l))==null?void 0:x.Panel},[l,Te]);return p(Z,{children:[t(r.Select,{label:"Visualization",value:l,onChange:o,data:Te,rightSection:t(r.ActionIcon,{disabled:!s,onClick:a,children:t(S.DeviceFloppy,{size:20})})}),f&&t(f,{conf:n.conf,setConf:u,data:e}),!f&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(n.conf,null,2),onChange:d})]})}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(Un,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(vn,{})})]})}function Yn({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j),{data:l,loading:o,viz:s,title:a}=c.default.useContext(M);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:o,exitTransitionDuration:0}),t(Et,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(qt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Jn,{})})]})})})}function Xn({}){const[e,n]=c.default.useState(!1),i=()=>n(!0),l=()=>n(!1),{title:o,refreshData:s}=c.default.useContext(M),{inEditMode:a}=c.default.useContext(j);return p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[t(r.Group,{children:t(qe,{})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:o})}),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(Yn,{opened:e,close:l})]})}var Tr="";function Ge({viz:e,dataSourceID:n,title:i,description:l,update:o,layout:s,id:a}){const u=c.default.useContext(R),d=c.default.useContext(O),[f,x]=c.default.useState(i),[m,g]=c.default.useState(l),[b,C]=c.default.useState(n),[v,k]=c.default.useState(e),L=c.default.useMemo(()=>{if(!!b)return d.dataSources.find(ze=>ze.id===b)},[b,d.dataSources]);c.default.useEffect(()=>{o==null||o({id:a,layout:s,title:f,description:m,dataSourceID:b,viz:v})},[f,m,L,v,a,s,b]);const{data:X=[],loading:pe,refresh:ne}=he.useRequest(Me({context:u,definitions:d,title:f,dataSource:L}),{refreshDeps:[u,d,L]}),De=ne;return t(M.Provider,{value:{data:X,loading:pe,title:f,setTitle:x,description:m,setDescription:g,dataSourceID:b,setDataSourceID:C,viz:v,setViz:k,refreshData:De},children:p(r.Container,{className:"panel-root",children:[t(Xn,{}),t(it,{viz:v,data:X,loading:pe})]})})}var Gr="";const Kn=P.WidthProvider(Le.default);function ut({panels:e,setPanels:n,className:i="layout",rowHeight:l=10,onRemoveItem:o,isDraggable:s,isResizable:a}){const u=c.default.useCallback(d=>{const f=new Map;d.forEach(b=>{var C=b,{i:m}=C,g=z(C,["i"]);f.set(m,g)});const x=e.map(m=>G(h({},m),{layout:f.get(m.id)}));n(x)},[e,n]);return t(Kn,{onLayoutChange:u,className:i,rowHeight:l,isDraggable:s,isResizable:a,children:e.map((m,x)=>{var g=m,{id:d}=g,f=z(g,["id"]);return t("div",{"data-grid":f.layout,children:t(Ge,G(h({id:d},f),{destroy:()=>o(d),update:b=>{n(C=>(C.splice(x,1,b),[...C]))}}))},d)})})}function _e(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Zn({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:_e(t(S.PlayerPlay,{size:20}),"Use"),value:A.Use},{label:_e(t(S.Resize,{size:20}),"Layout"),value:A.Layout},{label:_e(t(S.Paint,{size:20}),"Content"),value:A.Edit}]})}const Hn=`
|
|
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 er({}){const e=c.default.useContext(R),{sqlSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>{const o=n.reduce((s,a)=>(s[a.key]=a.value,s),{});return JSON.stringify(o,null,2)},[n]),l=c.default.useMemo(()=>JSON.stringify(e,null,2),[e]);return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",maxWidth:"40%",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(q.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:Hn}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context"}),t(q.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable SQL Snippets"}),t(q.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:i})]})]})}function tr({value:e}){const n=c.default.useContext(R),i=c.default.useContext(O),l=c.default.useMemo(()=>wt(e,n,i),[e,n,i]);return t(q.Prism,{language:"sql",colorScheme:"light",children:l})}function nr({value:e,onChange:n}){const i=$.useForm({initialValues:e}),l=c.default.useCallback(f=>{n(f)},[n]),o=c.default.useMemo(()=>!D.default.isEqual(e,i.values),[e,i.values]);c.default.useEffect(()=>{i.reset()},[e]);const{data:s={},loading:a}=he.useRequest(vt,{refreshDeps:[]},[]),u=c.default.useMemo(()=>Object.keys(s).map(f=>({label:f,value:f})),[s]),d=c.default.useMemo(()=>{const f=s[i.values.type];return f?f.map(x=>({label:x,value:x})):[]},[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(l),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:!o||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,h({placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:a},i.getInputProps("id"))),t(r.Select,h({label:"Data Source Type",data:u,sx:{flex:1},disabled:a},i.getInputProps("type"))),t(r.Select,h({label:"Data Source Key",data:d,sx:{flex:1},disabled:a},i.getInputProps("key")))]}),p(r.Tabs,{children:[t(r.Tabs.Tab,{label:"SQL",children:t(r.Textarea,G(h({autosize:!0,minRows:12,maxRows:24},i.getInputProps("sql")),{className:"code-textarea"}))}),t(r.Tabs.Tab,{label:"Preview",children:t(tr,{value:i.values.sql})})]})]})]})})}function rr({id:e,setID:n}){const{dataSources:i,setDataSources:l}=c.default.useContext(O),o=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}l(d=>{const f=d.findIndex(x=>x.id===e);return d.splice(f,1,a),[...d]}),n(a.id)},[e,i,l,n]);return e?o?t(nr,{value:o,onChange:s}):t("span",{children:"Invalid Data Source ID"}):null}function ir({id:e,setID:n}){const{dataSources:i,setDataSources:l}=c.default.useContext(O),o=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){o();return}i.findIndex(d=>d.id===e)===-1&&o()},[e,i,o]);const s=c.default.useMemo(()=>i.map(u=>({value:u.id,label:u.id})),[i]),a=c.default.useCallback(()=>{const u={id:E.randomId(),type:"postgresql",key:"",sql:""};l(d=>[...d,u]),n(u.id)},[l,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 or({}){const[e,n]=c.default.useState("");return p(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".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:[p(r.Group,{direction:"column",grow:!0,sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[t(ir,{id:e,setID:n}),t(rr,{id:e,setID:n})]}),t(er,{})]}),t($e,{id:e})]})}function lr({}){const e=c.default.useContext(R),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",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(q.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(q.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:JSON.stringify(e,null,2)})]})]})}function ar({value:e}){const n=c.default.useContext(R),i=c.default.useMemo(()=>Ct(e,n),[e,n]);return p(r.Group,{direction:"column",noWrap:!0,grow:!0,children:[t(r.Text,{children:"Preview"}),t(q.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:i})]})}function sr({}){const{sqlSnippets:e,setSQLSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>({snippets:$.formList(e!=null?e:[])}),[e]),l=$.useForm({initialValues:i}),o=()=>l.addListItem("snippets",{key:E.randomId(),value:""}),s=c.default.useMemo(()=>!D.default.isEqual(l.values,i),[l.values,i]),a=({snippets:u})=>{n(u)};return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",flexGrow:1},children:p("form",{onSubmit:l.onSubmit(a),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:!s,children:t(S.DeviceFloppy,{size:20})})]}),t(r.Group,{px:"md",pb:"md",pt:"md",children:p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((u,d)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,h({label:"Key",required:!0},l.getListInputProps("snippets",d,"key"))),t(r.Textarea,G(h({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",d,"value")),{className:"code-textarea"})),t(ar,{value:l.values.snippets[d].value}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",d),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},d)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:o,children:"Add a snippet"})})]})})]})})}const ur=`SELECT *
|
|
25
25
|
FROM commit
|
|
26
|
-
WHERE \${author_time_condition}`;function
|
|
26
|
+
WHERE \${author_time_condition}`;function dr(){return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",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:"Guide"})}),t(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:t(q.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
|
+
${ur}
|
|
30
30
|
|
|
31
31
|
-- where author_time_condition is:
|
|
32
32
|
author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
|
|
33
|
-
`})})]})}function
|
|
33
|
+
`})})]})}function cr({}){return t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".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(sr,{}),p(r.Group,{direction:"column",grow:!0,noWrap:!0,sx:{maxWidth:"40%"},children:[t(dr,{}),t(lr,{})]})]})})}function pr({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j);return c.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"Data Settings",trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:p(r.Tabs,{children:[t(r.Tabs.Tab,{label:"SQL Snippet",children:t(cr,{})}),t(r.Tabs.Tab,{label:"Data Source",children:t(or,{})})]})})}function fr({mode:e,setMode:n,hasChanges:i,addPanel:l,saveChanges:o}){const{inLayoutMode:s,inEditMode:a,inUseMode:u}=c.default.useContext(j),[d,f]=c.default.useState(!1),x=()=>f(!0),m=()=>f(!1);return p(r.Group,{position:"apart",pt:"sm",pb:"xs",children:[t(r.Group,{position:"left",children:t(Zn,{mode:e,setMode:n})}),p(r.Group,{position:"right",children:[!u&&t(r.Button,{variant:"default",size:"sm",onClick:l,leftIcon:t(S.PlaylistAdd,{size:20}),children:"Add a Panel"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:x,leftIcon:t(S.Database,{size:20}),children:"Data Settings"}),!u&&t(r.Button,{variant:"default",size:"sm",onClick:o,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(pr,{opened:d,close:m}),u&&t(r.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:t(S.Share,{size:20}),children:"Share"})]})}function mr({context:e,dashboard:n,update:i,className:l="dashboard",config:o}){Y.baseURL!==o.apiBaseURL&&(Y.baseURL=o.apiBaseURL);const[s,a]=c.default.useState(!1),[u,d]=c.default.useState(n.panels),[f,x]=c.default.useState(n.definition.sqlSnippets),[m,g]=c.default.useState(n.definition.dataSources),[b,C]=c.default.useState(A.Edit),v=c.default.useMemo(()=>{const F=W=>JSON.parse(JSON.stringify(W));return!D.default.isEqual(F(u),F(n.panels))||!D.default.isEqual(f,n.definition.sqlSnippets)?!0:!D.default.isEqual(m,n.definition.dataSources)},[n,u,f,m]),k=async()=>{const F=G(h({},n),{panels:u,definition:{sqlSnippets:f,dataSources:m}});await i(F)},L=()=>{const F=E.randomId(),fe={id:F,layout:{x:0,y:1/0,w:3,h:15},title:`New Panel - ${F}`,description:"",dataSourceID:"",viz:{type:"text",conf:{}}};d(W=>[...W,fe])},X=F=>{const fe=u.findIndex(W=>W.id===F);d(W=>(W.splice(fe,1),[...W]))},pe=b===A.Edit,ne=b===A.Layout,De=b===A.Use,ze=c.default.useMemo(()=>({sqlSnippets:f,setSQLSnippets:x,dataSources:m,setDataSources:g}),[f,x,m,g]);return t(R.Provider,{value:e,children:t("div",{className:l,children:t(O.Provider,{value:ze,children:p(j.Provider,{value:{layoutFrozen:s,freezeLayout:a,mode:b,inEditMode:pe,inLayoutMode:ne,inUseMode:De},children:[t(fr,{mode:b,setMode:C,hasChanges:v,addPanel:L,saveChanges:k}),t(ut,{panels:u,setPanels:d,isDraggable:ne,isResizable:ne,onRemoveItem:X})]})})})})}const hr=P.WidthProvider(Le.default);function xr({panels:e,className:n="layout",rowHeight:i=10}){return t(hr,{className:n,rowHeight:i,isDraggable:!1,isResizable:!1,children:e.map(s=>{var a=s,{id:l}=a,o=z(a,["id"]);return t("div",{"data-grid":o.layout,children:t(Ge,h({id:l},o))},l)})})}function gr({context:e,dashboard:n,className:i="dashboard",config:l}){Y.baseURL!==l.apiBaseURL&&(Y.baseURL=l.apiBaseURL);const o=c.default.useMemo(()=>G(h({},n.definition),{setSQLSnippets:()=>{},setDataSources:()=>{}}),[n]);return t(R.Provider,{value:e,children:t("div",{className:i,children:t(O.Provider,{value:o,children:t(j.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:A.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:t(xr,{panels:n.panels})})})})})}y.ContextInfoContext=R,y.Dashboard=mr,y.DashboardLayout=ut,y.DashboardMode=A,y.DefinitionContext=O,y.LayoutStateContext=j,y.Panel=Ge,y.PanelContext=M,y.ReadOnlyDashboard=gr,y.initialContextInfoContext=Tt,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Sx } from "@mantine/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface IDataFieldSelector {
|
|
4
|
+
label: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
value: string;
|
|
7
|
+
onChange: (v: string) => void;
|
|
8
|
+
data: any[];
|
|
9
|
+
sx?: Sx;
|
|
10
|
+
}
|
|
11
|
+
export declare const DataFieldSelector: React.ForwardRefExoticComponent<IDataFieldSelector & React.RefAttributes<unknown>>;
|
|
12
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare function VizBar3DPanel({ conf, setConf }:
|
|
2
|
+
import { IVizPanelProps } from "../../../types";
|
|
3
|
+
export declare function VizBar3DPanel({ conf, setConf, data }: IVizPanelProps): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IVizCartesianChartPanel } from "../type";
|
|
3
|
-
export declare function VizCartesianChartPanel({ conf, setConf }: IVizCartesianChartPanel): JSX.Element;
|
|
3
|
+
export declare function VizCartesianChartPanel({ conf, setConf, data }: IVizCartesianChartPanel): JSX.Element;
|
|
@@ -5,6 +5,7 @@ interface ISeriesField {
|
|
|
5
5
|
control: Control<ICartesianChartConf, any>;
|
|
6
6
|
watch: UseFormWatch<ICartesianChartConf>;
|
|
7
7
|
getValues: UseFormGetValues<ICartesianChartConf>;
|
|
8
|
+
data: any[];
|
|
8
9
|
}
|
|
9
|
-
export declare function SeriesField({ control, watch, getValues }: ISeriesField): JSX.Element;
|
|
10
|
+
export declare function SeriesField({ control, watch, getValues, data }: ISeriesField): JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IVizPanelProps } from "../../../types/viz-panel";
|
|
3
|
-
export declare function VizPiePanel({ conf: { label_field, value_field }, setConf }: IVizPanelProps): JSX.Element;
|
|
3
|
+
export declare function VizPiePanel({ conf: { label_field, value_field }, setConf, data }: IVizPanelProps): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IVizPanelProps } from "../../../types/viz-panel";
|
|
3
|
-
export declare function VizStatsPanel({ conf, setConf }: IVizPanelProps): JSX.Element;
|
|
3
|
+
export declare function VizStatsPanel({ conf, setConf, data }: IVizPanelProps): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IVizPanelProps } from "../../../types/viz-panel";
|
|
3
|
-
export declare function SunburstPanel({ conf: { label_field, value_field }, setConf }: IVizPanelProps): JSX.Element;
|
|
3
|
+
export declare function SunburstPanel({ conf: { label_field, value_field }, setConf, data }: IVizPanelProps): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IVizPanelProps } from "../../../types/viz-panel";
|
|
3
|
-
export declare function VizTablePanel({ conf: { columns, ...restConf }, setConf }: IVizPanelProps): JSX.Element;
|
|
3
|
+
export declare function VizTablePanel({ conf: { columns, ...restConf }, setConf, data }: IVizPanelProps): JSX.Element;
|