@devtable/dashboard 0.1.0 → 0.3.1

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.
@@ -32,11 +32,11 @@ var __objRest = (source, exclude) => {
32
32
  import React from "react";
33
33
  import _ from "lodash";
34
34
  import { WidthProvider, Responsive } from "react-grid-layout";
35
- import { Text, Table, Group, LoadingOverlay, Box, Textarea, Button, TextInput, ActionIcon, useMantineTheme, ColorSwatch, Select, Slider, Switch, JsonInput, Divider, Modal, AppShell, Navbar, Tabs, Tooltip, Container, SegmentedControl } from "@mantine/core";
35
+ import { Text, Table, Group, LoadingOverlay, Box, Textarea, Button, TextInput, ActionIcon, useMantineTheme, ColorSwatch, Select, Switch, Slider, JsonInput, Divider, Modal, AppShell, Navbar, Tabs, Tooltip, Menu, Container, SegmentedControl } from "@mantine/core";
36
36
  import { useRequest } from "ahooks";
37
37
  import axios from "axios";
38
- import { Trash, DeviceFloppy, Settings, Refresh, InfoCircle, Paint, PlayerPlay, PlaylistAdd, Recycle, Share } from "tabler-icons-react";
39
- import { useElementSize, randomId, useInputState } from "@mantine/hooks";
38
+ import { Trash, DeviceFloppy, InfoCircle, Refresh, Settings, Paint, PlayerPlay, PlaylistAdd, Recycle, Share } from "tabler-icons-react";
39
+ import { useElementSize, randomId, useInputState, useListState } from "@mantine/hooks";
40
40
  import ReactEChartsCore from "echarts-for-react/lib/core";
41
41
  import * as echarts from "echarts/core";
42
42
  import { SunburstChart, BarChart, LineChart } from "echarts/charts";
@@ -94,15 +94,20 @@ function getSQLParams(context, definitions) {
94
94
  ret[curr.key] = formatSQL(curr.value, context);
95
95
  return ret;
96
96
  }, {});
97
- return _.defaultsDeep(context, sqlSnippetRecord);
97
+ return _.merge({}, sqlSnippetRecord, context);
98
98
  }
99
99
  const queryBySQL = (sql, context, definitions, title) => async () => {
100
100
  if (!sql) {
101
101
  return [];
102
102
  }
103
+ const needParams = sql.includes("$");
103
104
  const params = getSQLParams(context, definitions);
105
+ if (needParams && Object.keys(params).length === 0) {
106
+ console.error(`[queryBySQL] insufficient params for {${title}}'s SQL`);
107
+ return [];
108
+ }
104
109
  const formattedSQL = formatSQL(sql, params);
105
- if (sql.includes("$")) {
110
+ if (needParams) {
106
111
  console.groupCollapsed(`Final SQL for: ${title}`);
107
112
  console.log(formattedSQL);
108
113
  console.groupEnd();
@@ -168,6 +173,27 @@ reactJsxRuntime_production_min.jsxs = q;
168
173
  const jsx = jsxRuntime.exports.jsx;
169
174
  const jsxs = jsxRuntime.exports.jsxs;
170
175
  const Fragment = jsxRuntime.exports.Fragment;
176
+ class ErrorBoundary extends React.Component {
177
+ constructor(props) {
178
+ super(props);
179
+ this.state = {
180
+ hasError: false
181
+ };
182
+ }
183
+ static getDerivedStateFromError() {
184
+ return {
185
+ hasError: true
186
+ };
187
+ }
188
+ render() {
189
+ if (this.state.hasError) {
190
+ return /* @__PURE__ */ jsx("h1", {
191
+ children: "Something went wrong."
192
+ });
193
+ }
194
+ return this.props.children;
195
+ }
196
+ }
171
197
  echarts.use([SunburstChart, CanvasRenderer]);
172
198
  const defaultOption$1 = {
173
199
  tooltip: {
@@ -197,7 +223,7 @@ function Sunbrust({
197
223
  const chartData = React.useMemo(() => {
198
224
  return data.map((d) => ({
199
225
  name: d[label_field],
200
- value: d[value_field]
226
+ value: Number(d[value_field])
201
227
  }));
202
228
  }, [data, label_field, value_field]);
203
229
  const max = React.useMemo(() => {
@@ -219,7 +245,7 @@ function Sunbrust({
219
245
  }
220
246
  }
221
247
  }), []);
222
- const option = _.defaultsDeep(defaultOption$1, labelOption, restConf, {
248
+ const option = _.merge(defaultOption$1, labelOption, restConf, {
223
249
  series: {
224
250
  data: chartData
225
251
  }
@@ -244,7 +270,14 @@ const defaultOption = {
244
270
  xAxis: {
245
271
  type: "category"
246
272
  },
247
- yAxis: {}
273
+ yAxis: {},
274
+ grid: {
275
+ top: 30,
276
+ left: 10,
277
+ right: 10,
278
+ bottom: 10,
279
+ containLabel: true
280
+ }
248
281
  };
249
282
  function VizLineBarChart({
250
283
  conf,
@@ -440,11 +473,16 @@ function VizText({
440
473
  return /* @__PURE__ */ jsx(Fragment, {
441
474
  children: paragraphs.map((_a, index2) => {
442
475
  var _b = _a, {
443
- template
476
+ template,
477
+ size
444
478
  } = _b, rest = __objRest(_b, [
445
- "template"
479
+ "template",
480
+ "size"
446
481
  ]);
447
482
  return /* @__PURE__ */ jsx(Text, __spreadProps(__spreadValues({}, rest), {
483
+ sx: {
484
+ fontSize: size
485
+ },
448
486
  children: interpolateString(template, data[0])
449
487
  }), `${template}---${index2}`);
450
488
  })
@@ -684,7 +722,6 @@ function SQLSnippetsForm({
684
722
  sqlSnippets,
685
723
  setSQLSnippets
686
724
  }) {
687
- const submitButton = React.useRef(null);
688
725
  const initialValues = React.useMemo(() => ({
689
726
  snippets: formList(sqlSnippets != null ? sqlSnippets : [])
690
727
  }), [sqlSnippets]);
@@ -696,12 +733,6 @@ function SQLSnippetsForm({
696
733
  value: ""
697
734
  });
698
735
  const changed = React.useMemo(() => !_.isEqual(form.values, initialValues), [form.values, initialValues]);
699
- React.useEffect(() => {
700
- var _a;
701
- if (changed) {
702
- (_a = submitButton == null ? void 0 : submitButton.current) == null ? void 0 : _a.click();
703
- }
704
- }, [changed, submitButton.current]);
705
736
  const submit = ({
706
737
  snippets
707
738
  }) => {
@@ -710,19 +741,13 @@ function SQLSnippetsForm({
710
741
  return /* @__PURE__ */ jsx(Group, {
711
742
  direction: "column",
712
743
  sx: {
713
- width: "100%"
744
+ width: "100%",
745
+ position: "relative"
714
746
  },
715
747
  grow: true,
716
748
  children: /* @__PURE__ */ jsxs("form", {
717
749
  onSubmit: form.onSubmit(submit),
718
- children: [/* @__PURE__ */ jsx("button", {
719
- ref: submitButton,
720
- type: "submit",
721
- style: {
722
- display: "none"
723
- },
724
- children: "Ghost submit"
725
- }), form.values.snippets.map((_item, index2) => /* @__PURE__ */ jsxs(Group, {
750
+ children: [form.values.snippets.map((_item, index2) => /* @__PURE__ */ jsxs(Group, {
726
751
  direction: "column",
727
752
  grow: true,
728
753
  my: 0,
@@ -752,19 +777,24 @@ function SQLSnippetsForm({
752
777
  size: 16
753
778
  })
754
779
  })]
755
- }, index2)), /* @__PURE__ */ jsx(Group, {
780
+ }, index2)), /* @__PURE__ */ jsxs(Group, {
756
781
  position: "center",
757
782
  mt: "xl",
758
783
  grow: true,
759
784
  sx: {
760
- width: "60%"
785
+ width: "80%"
761
786
  },
762
787
  mx: "auto",
763
- children: /* @__PURE__ */ jsx(Button, {
764
- color: "blue",
788
+ children: [/* @__PURE__ */ jsx(Button, {
789
+ variant: "default",
765
790
  onClick: addSnippet,
766
791
  children: "Add a snippet"
767
- })
792
+ }), /* @__PURE__ */ jsx(Button, {
793
+ color: "blue",
794
+ type: "submit",
795
+ disabled: !changed,
796
+ children: "Submit"
797
+ })]
768
798
  })]
769
799
  })
770
800
  });
@@ -785,6 +815,7 @@ WHERE \${author_time_condition}`;
785
815
  width: "100%"
786
816
  },
787
817
  noCopy: true,
818
+ trim: false,
788
819
  colorScheme: "dark",
789
820
  children: `-- You may refer context data *by name*
790
821
  -- in SQL or VizConfig.
@@ -793,7 +824,7 @@ ${sampleSQL}
793
824
 
794
825
  -- where author_time_condition is:
795
826
  author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
796
- `
827
+ `
797
828
  }), /* @__PURE__ */ jsx(Text, {
798
829
  weight: 700,
799
830
  children: "SQL Snippets"
@@ -1080,7 +1111,6 @@ function VizLineBarChartPanel({
1080
1111
  conf,
1081
1112
  setConf
1082
1113
  }) {
1083
- const submitButton = React.useRef(null);
1084
1114
  const _a = conf, {
1085
1115
  series
1086
1116
  } = _a, restConf = __objRest(_a, [
@@ -1100,13 +1130,7 @@ function VizLineBarChartPanel({
1100
1130
  stack: "",
1101
1131
  color: "#000"
1102
1132
  });
1103
- const changed = React.useMemo(() => !_.isEqual(form.values, initialValues), [form.values, initialValues]);
1104
- React.useEffect(() => {
1105
- var _a2;
1106
- if (changed) {
1107
- (_a2 = submitButton == null ? void 0 : submitButton.current) == null ? void 0 : _a2.click();
1108
- }
1109
- }, [changed, submitButton.current]);
1133
+ React.useMemo(() => !_.isEqual(form.values, initialValues), [form.values, initialValues]);
1110
1134
  return /* @__PURE__ */ jsx(Group, {
1111
1135
  direction: "column",
1112
1136
  mt: "md",
@@ -1122,13 +1146,14 @@ function VizLineBarChartPanel({
1122
1146
  },
1123
1147
  children: [/* @__PURE__ */ jsx(Text, {
1124
1148
  children: "Chart Config"
1125
- }), /* @__PURE__ */ jsx("button", {
1126
- ref: submitButton,
1149
+ }), /* @__PURE__ */ jsx(ActionIcon, {
1127
1150
  type: "submit",
1128
- style: {
1129
- display: "none"
1130
- },
1131
- children: "Ghost submit"
1151
+ mr: 5,
1152
+ variant: "filled",
1153
+ color: "blue",
1154
+ children: /* @__PURE__ */ jsx(DeviceFloppy, {
1155
+ size: 20
1156
+ })
1132
1157
  })]
1133
1158
  }), /* @__PURE__ */ jsx(TextInput, __spreadValues({
1134
1159
  size: "md",
@@ -1199,20 +1224,17 @@ function VizLineBarChartPanel({
1199
1224
  })
1200
1225
  });
1201
1226
  }
1202
- function SunburstPanel(_a) {
1203
- var _b = _a, {
1204
- conf: _c
1205
- } = _b, _d = _c, {
1206
- columns
1207
- } = _d, restConf = __objRest(_d, [
1208
- "columns"
1209
- ]), {
1210
- setConf
1211
- } = _b;
1227
+ function SunburstPanel({
1228
+ conf: {
1229
+ label_field,
1230
+ value_field
1231
+ },
1232
+ setConf
1233
+ }) {
1212
1234
  const form = useForm({
1213
1235
  initialValues: {
1214
- label_field: "name",
1215
- value_field: "value"
1236
+ label_field,
1237
+ value_field
1216
1238
  }
1217
1239
  });
1218
1240
  return /* @__PURE__ */ jsx(Group, {
@@ -1268,52 +1290,6 @@ function SunburstPanel(_a) {
1268
1290
  })
1269
1291
  });
1270
1292
  }
1271
- const marks$1 = [{
1272
- "value": 0,
1273
- "label": "xs"
1274
- }, {
1275
- "value": 25,
1276
- "label": "sm"
1277
- }, {
1278
- "value": 50,
1279
- "label": "md"
1280
- }, {
1281
- "value": 75,
1282
- "label": "lg"
1283
- }, {
1284
- "value": 100,
1285
- "label": "xl"
1286
- }];
1287
- function MantineSizeSlider({
1288
- label,
1289
- value,
1290
- onChange
1291
- }) {
1292
- var _a, _b;
1293
- const [mark, setMark] = React.useState((_b = (_a = marks$1.find((m2) => m2.label === value)) == null ? void 0 : _a.value) != null ? _b : marks$1[0].value);
1294
- React.useEffect(() => {
1295
- const match = marks$1.find((s) => s.value === mark);
1296
- if (match) {
1297
- onChange(match.label);
1298
- }
1299
- }, [mark]);
1300
- return /* @__PURE__ */ jsxs(Group, {
1301
- direction: "column",
1302
- grow: true,
1303
- spacing: "xs",
1304
- mb: "lg",
1305
- children: [/* @__PURE__ */ jsx(Text, {
1306
- children: label
1307
- }), /* @__PURE__ */ jsx(Slider, {
1308
- label: null,
1309
- marks: marks$1,
1310
- value: mark,
1311
- onChange: setMark,
1312
- step: 25,
1313
- placeholder: "Pick a font size"
1314
- })]
1315
- });
1316
- }
1317
1293
  const valueTypes = Object.values(ValueType).map((v) => ({
1318
1294
  label: v,
1319
1295
  value: v
@@ -1332,16 +1308,16 @@ function ValueTypeSelector({
1332
1308
  sx
1333
1309
  });
1334
1310
  }
1335
- function VizTablePanel(_e) {
1336
- var _f = _e, {
1337
- conf: _g
1338
- } = _f, _h = _g, {
1311
+ function VizTablePanel(_a) {
1312
+ var _b = _a, {
1313
+ conf: _c
1314
+ } = _b, _d = _c, {
1339
1315
  columns
1340
- } = _h, restConf = __objRest(_h, [
1316
+ } = _d, restConf = __objRest(_d, [
1341
1317
  "columns"
1342
1318
  ]), {
1343
1319
  setConf
1344
- } = _f;
1320
+ } = _b;
1345
1321
  const form = useForm({
1346
1322
  initialValues: __spreadValues({
1347
1323
  id_field: "id",
@@ -1407,10 +1383,20 @@ function VizTablePanel(_e) {
1407
1383
  flexGrow: 1
1408
1384
  }
1409
1385
  },
1410
- children: [/* @__PURE__ */ jsx(MantineSizeSlider, __spreadValues({
1411
- label: "Horizontal Spacing"
1412
- }, form.getInputProps("horizontalSpacing"))), /* @__PURE__ */ jsx(MantineSizeSlider, __spreadValues({
1413
- label: "Vertical Spacing"
1386
+ children: [/* @__PURE__ */ jsx(TextInput, __spreadValues({
1387
+ label: "Horizontal Spacing",
1388
+ placeholder: "10px, 1em, 1rem, 100%...",
1389
+ required: true,
1390
+ sx: {
1391
+ flex: 1
1392
+ }
1393
+ }, form.getInputProps("horizontalSpacing"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
1394
+ label: "Vertical Spacing",
1395
+ placeholder: "10px, 1em, 1rem, 100%...",
1396
+ required: true,
1397
+ sx: {
1398
+ flex: 1
1399
+ }
1414
1400
  }, form.getInputProps("verticalSpacing")))]
1415
1401
  }), /* @__PURE__ */ jsx(Group, {
1416
1402
  position: "apart",
@@ -1421,8 +1407,13 @@ function VizTablePanel(_e) {
1421
1407
  flexGrow: 1
1422
1408
  }
1423
1409
  },
1424
- children: /* @__PURE__ */ jsx(MantineSizeSlider, __spreadValues({
1425
- label: "Font Size"
1410
+ children: /* @__PURE__ */ jsx(TextInput, __spreadValues({
1411
+ label: "Font Size",
1412
+ placeholder: "10px, 1em, 1rem, 100%...",
1413
+ required: true,
1414
+ sx: {
1415
+ flex: 1
1416
+ }
1426
1417
  }, form.getInputProps("size")))
1427
1418
  }), /* @__PURE__ */ jsxs(Group, {
1428
1419
  direction: "column",
@@ -1554,7 +1545,7 @@ const marks = [{
1554
1545
  label: "bold",
1555
1546
  value: 100
1556
1547
  }];
1557
- function MantineFontSizeSlider({
1548
+ function MantineFontWeightSlider({
1558
1549
  label,
1559
1550
  value,
1560
1551
  onChange
@@ -1663,7 +1654,17 @@ function VizTextPanel({
1663
1654
  children: [/* @__PURE__ */ jsx(Text, {
1664
1655
  children: "Color"
1665
1656
  }), /* @__PURE__ */ jsx(MantineColorSelector, __spreadValues({}, form.getListInputProps("paragraphs", index2, "color")))]
1666
- }), /* @__PURE__ */ jsxs(Group, {
1657
+ }), /* @__PURE__ */ jsx(Group, {
1658
+ direction: "column",
1659
+ grow: true,
1660
+ children: /* @__PURE__ */ jsx(TextInput, __spreadValues({
1661
+ label: "Font Size",
1662
+ placeholder: "10px, 1em, 1rem, 100%...",
1663
+ sx: {
1664
+ flex: 1
1665
+ }
1666
+ }, form.getListInputProps("paragraphs", index2, "size")))
1667
+ }), /* @__PURE__ */ jsx(Group, {
1667
1668
  position: "apart",
1668
1669
  grow: true,
1669
1670
  sx: {
@@ -1672,11 +1673,9 @@ function VizTextPanel({
1672
1673
  maxWidth: "100%"
1673
1674
  }
1674
1675
  },
1675
- children: [/* @__PURE__ */ jsx(MantineSizeSlider, __spreadValues({
1676
- label: "Font Size"
1677
- }, form.getListInputProps("paragraphs", index2, "size"))), /* @__PURE__ */ jsx(MantineFontSizeSlider, __spreadValues({
1676
+ children: /* @__PURE__ */ jsx(MantineFontWeightSlider, __spreadValues({
1678
1677
  label: "Font Weight"
1679
- }, form.getListInputProps("paragraphs", index2, "weight")))]
1678
+ }, form.getListInputProps("paragraphs", index2, "weight")))
1680
1679
  }), /* @__PURE__ */ jsx(ActionIcon, {
1681
1680
  color: "red",
1682
1681
  variant: "hover",
@@ -1794,7 +1793,10 @@ function VizConfig({}) {
1794
1793
  children: [/* @__PURE__ */ jsx(EditTitle, {}), /* @__PURE__ */ jsx(EditDescription, {}), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsx(EditVizConf, {})]
1795
1794
  });
1796
1795
  }
1797
- function PanelSettings({}) {
1796
+ function PanelSettingsModal({
1797
+ opened,
1798
+ close
1799
+ }) {
1798
1800
  const {
1799
1801
  freezeLayout
1800
1802
  } = React.useContext(LayoutStateContext);
@@ -1804,151 +1806,141 @@ function PanelSettings({}) {
1804
1806
  viz,
1805
1807
  title
1806
1808
  } = React.useContext(PanelContext);
1807
- const [opened, setOpened] = React.useState(false);
1808
- const open = () => setOpened(true);
1809
1809
  React.useEffect(() => {
1810
1810
  freezeLayout(opened);
1811
1811
  }, [opened]);
1812
- return /* @__PURE__ */ jsxs(Fragment, {
1813
- children: [/* @__PURE__ */ jsx(Modal, {
1814
- size: "96vw",
1815
- overflow: "inside",
1816
- opened,
1817
- onClose: () => setOpened(false),
1818
- title,
1819
- trapFocus: true,
1820
- onDragStart: (e) => {
1821
- e.stopPropagation();
1822
- },
1823
- children: /* @__PURE__ */ jsx(AppShell, {
1824
- sx: {
1825
- height: "90vh",
1826
- maxHeight: "calc(100vh - 185px)",
1827
- ".mantine-AppShell-body": {
1828
- height: "100%"
1829
- },
1830
- main: {
1831
- height: "100%",
1832
- width: "100%"
1833
- }
1812
+ return /* @__PURE__ */ jsx(Modal, {
1813
+ size: "96vw",
1814
+ overflow: "inside",
1815
+ opened,
1816
+ onClose: close,
1817
+ title,
1818
+ trapFocus: true,
1819
+ onDragStart: (e) => {
1820
+ e.stopPropagation();
1821
+ },
1822
+ children: /* @__PURE__ */ jsx(AppShell, {
1823
+ sx: {
1824
+ height: "90vh",
1825
+ maxHeight: "calc(100vh - 185px)",
1826
+ ".mantine-AppShell-body": {
1827
+ height: "100%"
1834
1828
  },
1835
- padding: "md",
1836
- navbar: /* @__PURE__ */ jsx(Navbar, {
1837
- width: {
1838
- base: "40%"
1839
- },
1829
+ main: {
1840
1830
  height: "100%",
1841
- p: "xs",
1842
- children: /* @__PURE__ */ jsxs(Tabs, {
1843
- initialTab: 1,
1844
- children: [/* @__PURE__ */ jsx(Tabs.Tab, {
1845
- label: "Context",
1846
- children: /* @__PURE__ */ jsx(ContextInfo, {})
1847
- }), /* @__PURE__ */ jsx(Tabs.Tab, {
1848
- label: "SQL Snippets",
1849
- children: /* @__PURE__ */ jsx(SQLSnippetsTab, {})
1850
- }), /* @__PURE__ */ jsx(Tabs.Tab, {
1851
- label: "SQL",
1852
- children: /* @__PURE__ */ jsx(QueryEditor, {})
1853
- }), /* @__PURE__ */ jsxs(Tabs.Tab, {
1854
- label: "Data",
1855
- children: [/* @__PURE__ */ jsx(LoadingOverlay, {
1856
- visible: loading
1857
- }), /* @__PURE__ */ jsx(QueryResult, {})]
1858
- }), /* @__PURE__ */ jsx(Tabs.Tab, {
1859
- label: "Viz Config",
1860
- children: /* @__PURE__ */ jsx(VizConfig, {})
1861
- })]
1862
- })
1863
- }),
1831
+ width: "100%"
1832
+ }
1833
+ },
1834
+ padding: "md",
1835
+ navbar: /* @__PURE__ */ jsx(Navbar, {
1836
+ width: {
1837
+ base: "40%"
1838
+ },
1839
+ height: "100%",
1840
+ p: "xs",
1841
+ children: /* @__PURE__ */ jsxs(Tabs, {
1842
+ initialTab: 1,
1843
+ children: [/* @__PURE__ */ jsx(Tabs.Tab, {
1844
+ label: "Context",
1845
+ children: /* @__PURE__ */ jsx(ContextInfo, {})
1846
+ }), /* @__PURE__ */ jsx(Tabs.Tab, {
1847
+ label: "SQL Snippets",
1848
+ children: /* @__PURE__ */ jsx(SQLSnippetsTab, {})
1849
+ }), /* @__PURE__ */ jsx(Tabs.Tab, {
1850
+ label: "SQL",
1851
+ children: /* @__PURE__ */ jsx(QueryEditor, {})
1852
+ }), /* @__PURE__ */ jsxs(Tabs.Tab, {
1853
+ label: "Data",
1854
+ children: [/* @__PURE__ */ jsx(LoadingOverlay, {
1855
+ visible: loading
1856
+ }), /* @__PURE__ */ jsx(QueryResult, {})]
1857
+ }), /* @__PURE__ */ jsx(Tabs.Tab, {
1858
+ label: "Viz Config",
1859
+ children: /* @__PURE__ */ jsx(VizConfig, {})
1860
+ })]
1861
+ })
1862
+ }),
1863
+ children: /* @__PURE__ */ jsx(ErrorBoundary, {
1864
1864
  children: /* @__PURE__ */ jsx(Viz, {
1865
1865
  viz,
1866
1866
  data,
1867
1867
  loading
1868
1868
  })
1869
1869
  })
1870
- }), /* @__PURE__ */ jsx(ActionIcon, {
1871
- variant: "hover",
1872
- color: "blue",
1873
- loading,
1874
- onClick: open,
1875
- children: /* @__PURE__ */ jsx(Settings, {
1876
- size: 16
1877
- })
1878
- })]
1870
+ })
1879
1871
  });
1880
1872
  }
1881
- function PanelTitle({
1882
- title,
1883
- description
1884
- }) {
1873
+ function PanelTitleBar({}) {
1874
+ const [opened, setOpened] = React.useState(false);
1875
+ const open = () => setOpened(true);
1876
+ const close = () => setOpened(false);
1877
+ const {
1878
+ title,
1879
+ description,
1880
+ loading,
1881
+ refreshData
1882
+ } = React.useContext(PanelContext);
1883
+ const {
1884
+ inEditMode
1885
+ } = React.useContext(LayoutStateContext);
1885
1886
  return /* @__PURE__ */ jsxs(Group, {
1886
- position: "center",
1887
+ position: "apart",
1888
+ noWrap: true,
1887
1889
  sx: {
1888
1890
  borderBottom: "1px solid #eee",
1889
1891
  paddingBottom: "5px"
1890
1892
  },
1891
- children: [!description && /* @__PURE__ */ jsx(Text, {
1892
- weight: "bold",
1893
- sx: {
1894
- marginLeft: "5px",
1895
- display: "inline"
1896
- },
1897
- children: title
1898
- }), description && /* @__PURE__ */ jsx("div", {
1899
- children: /* @__PURE__ */ jsxs(Tooltip, {
1893
+ children: [/* @__PURE__ */ jsx(Group, {
1894
+ children: description && /* @__PURE__ */ jsx(Tooltip, {
1900
1895
  label: description,
1901
1896
  withArrow: true,
1902
- children: [/* @__PURE__ */ jsx(InfoCircle, {
1897
+ children: /* @__PURE__ */ jsx(InfoCircle, {
1903
1898
  size: 12,
1904
1899
  style: {
1905
1900
  verticalAlign: "baseline",
1906
1901
  cursor: "pointer"
1907
1902
  }
1908
- }), /* @__PURE__ */ jsx(Text, {
1909
- weight: "bold",
1910
- sx: {
1911
- marginLeft: "5px",
1912
- display: "inline"
1913
- },
1914
- children: title
1915
- })]
1903
+ })
1916
1904
  })
1917
- })]
1918
- });
1919
- }
1920
- function PanelTitleBar({}) {
1921
- const {
1922
- title,
1923
- description,
1924
- loading,
1925
- refreshData
1926
- } = React.useContext(PanelContext);
1927
- const {
1928
- inEditMode
1929
- } = React.useContext(LayoutStateContext);
1930
- return /* @__PURE__ */ jsxs(Fragment, {
1931
- children: [/* @__PURE__ */ jsx(PanelTitle, {
1932
- title,
1933
- description
1934
- }), /* @__PURE__ */ jsxs(Group, {
1905
+ }), /* @__PURE__ */ jsx(Group, {
1906
+ grow: true,
1907
+ position: "center",
1908
+ children: /* @__PURE__ */ jsx(Text, {
1909
+ lineClamp: 1,
1910
+ weight: "bold",
1911
+ children: title
1912
+ })
1913
+ }), /* @__PURE__ */ jsx(Group, {
1935
1914
  position: "right",
1936
1915
  spacing: 0,
1937
1916
  sx: {
1938
- position: "absolute",
1939
- right: "15px",
1940
- top: "4px",
1941
1917
  height: "28px"
1942
1918
  },
1943
- children: [/* @__PURE__ */ jsx(ActionIcon, {
1944
- variant: "hover",
1945
- color: "blue",
1946
- loading,
1947
- onClick: refreshData,
1948
- children: /* @__PURE__ */ jsx(Refresh, {
1949
- size: 16
1950
- })
1951
- }), inEditMode && /* @__PURE__ */ jsx(PanelSettings, {})]
1919
+ children: /* @__PURE__ */ jsxs(Menu, {
1920
+ children: [/* @__PURE__ */ jsx(Menu.Item, {
1921
+ onClick: refreshData,
1922
+ icon: /* @__PURE__ */ jsx(Refresh, {
1923
+ size: 14
1924
+ }),
1925
+ children: "Refresh"
1926
+ }), inEditMode && /* @__PURE__ */ jsx(Menu.Item, {
1927
+ onClick: open,
1928
+ icon: /* @__PURE__ */ jsx(Settings, {
1929
+ size: 14
1930
+ }),
1931
+ children: "Settings"
1932
+ }), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsx(Menu.Item, {
1933
+ color: "red",
1934
+ disabled: true,
1935
+ icon: /* @__PURE__ */ jsx(Trash, {
1936
+ size: 14
1937
+ }),
1938
+ children: "Delete"
1939
+ })]
1940
+ })
1941
+ }), inEditMode && /* @__PURE__ */ jsx(PanelSettingsModal, {
1942
+ opened,
1943
+ close
1952
1944
  })]
1953
1945
  });
1954
1946
  }
@@ -1957,7 +1949,10 @@ function Panel({
1957
1949
  viz: initialViz,
1958
1950
  sql: initialSQL,
1959
1951
  title: initialTitle,
1960
- description: initialDesc
1952
+ description: initialDesc,
1953
+ update,
1954
+ layout,
1955
+ id
1961
1956
  }) {
1962
1957
  const contextInfo = React.useContext(ContextInfoContext);
1963
1958
  const definitions = React.useContext(DefinitionContext);
@@ -1965,6 +1960,16 @@ function Panel({
1965
1960
  const [description, setDescription] = React.useState(initialDesc);
1966
1961
  const [sql, setSQL] = React.useState(initialSQL);
1967
1962
  const [viz, setViz] = React.useState(initialViz);
1963
+ React.useEffect(() => {
1964
+ update({
1965
+ id,
1966
+ layout,
1967
+ title,
1968
+ description,
1969
+ sql,
1970
+ viz
1971
+ });
1972
+ }, [title, description, sql, viz, id, layout]);
1968
1973
  const {
1969
1974
  data = [],
1970
1975
  loading,
@@ -1989,10 +1994,12 @@ function Panel({
1989
1994
  },
1990
1995
  children: /* @__PURE__ */ jsxs(Container, {
1991
1996
  className: "panel-root",
1992
- children: [/* @__PURE__ */ jsx(PanelTitleBar, {}), /* @__PURE__ */ jsx(Viz, {
1993
- viz,
1994
- data,
1995
- loading
1997
+ children: [/* @__PURE__ */ jsx(PanelTitleBar, {}), /* @__PURE__ */ jsx(ErrorBoundary, {
1998
+ children: /* @__PURE__ */ jsx(Viz, {
1999
+ viz,
2000
+ data,
2001
+ loading
2002
+ })
1996
2003
  })]
1997
2004
  })
1998
2005
  });
@@ -2001,6 +2008,7 @@ var index = "";
2001
2008
  const ResponsiveReactGridLayout = WidthProvider(Responsive);
2002
2009
  function DashboardLayout({
2003
2010
  panels,
2011
+ setPanels,
2004
2012
  className = "layout",
2005
2013
  cols = {
2006
2014
  lg: 12,
@@ -2020,14 +2028,30 @@ function DashboardLayout({
2020
2028
  setBreakpoint(breakpoint);
2021
2029
  setLocalCols(localCols);
2022
2030
  };
2031
+ const onLayoutChange = React.useCallback((currentLayout) => {
2032
+ const m2 = /* @__PURE__ */ new Map();
2033
+ currentLayout.forEach((_a) => {
2034
+ var _b = _a, {
2035
+ i
2036
+ } = _b, rest = __objRest(_b, [
2037
+ "i"
2038
+ ]);
2039
+ m2.set(i, rest);
2040
+ });
2041
+ const newPanels = panels.map((p2) => __spreadProps(__spreadValues({}, p2), {
2042
+ layout: m2.get(p2.id)
2043
+ }));
2044
+ setPanels.setState(newPanels);
2045
+ }, [panels, setPanels]);
2023
2046
  return /* @__PURE__ */ jsx(ResponsiveReactGridLayout, {
2024
2047
  onBreakpointChange,
2048
+ onLayoutChange,
2025
2049
  className,
2026
2050
  cols,
2027
2051
  rowHeight,
2028
2052
  isDraggable,
2029
2053
  isResizable,
2030
- children: panels.map((_a) => {
2054
+ children: panels.map((_a, index2) => {
2031
2055
  var _b = _a, {
2032
2056
  id
2033
2057
  } = _b, rest = __objRest(_b, [
@@ -2035,9 +2059,14 @@ function DashboardLayout({
2035
2059
  ]);
2036
2060
  return /* @__PURE__ */ jsx("div", {
2037
2061
  "data-grid": rest.layout,
2038
- children: /* @__PURE__ */ jsx(Panel, __spreadValues({
2039
- destroy: () => onRemoveItem(id)
2040
- }, rest))
2062
+ children: /* @__PURE__ */ jsx(Panel, __spreadProps(__spreadValues({
2063
+ id
2064
+ }, rest), {
2065
+ destroy: () => onRemoveItem(id),
2066
+ update: (panel) => {
2067
+ setPanels.setItem(index2, panel);
2068
+ }
2069
+ }))
2041
2070
  }, id);
2042
2071
  })
2043
2072
  });
@@ -2075,7 +2104,9 @@ function ModeToggler({
2075
2104
  function DashboardActions({
2076
2105
  mode,
2077
2106
  setMode,
2078
- addPanel
2107
+ hasChanges,
2108
+ addPanel,
2109
+ saveChanges
2079
2110
  }) {
2080
2111
  const inEditMode = mode === DashboardMode.Edit;
2081
2112
  return /* @__PURE__ */ jsxs(Group, {
@@ -2101,15 +2132,16 @@ function DashboardActions({
2101
2132
  }), /* @__PURE__ */ jsx(Button, {
2102
2133
  variant: "default",
2103
2134
  size: "sm",
2104
- disabled: true,
2135
+ onClick: saveChanges,
2136
+ disabled: !hasChanges,
2105
2137
  leftIcon: /* @__PURE__ */ jsx(DeviceFloppy, {
2106
2138
  size: 20
2107
2139
  }),
2108
- children: "Save Dashboard"
2140
+ children: "Save Changes"
2109
2141
  }), /* @__PURE__ */ jsx(Button, {
2110
2142
  color: "red",
2111
2143
  size: "sm",
2112
- disabled: true,
2144
+ disabled: !hasChanges,
2113
2145
  leftIcon: /* @__PURE__ */ jsx(Recycle, {
2114
2146
  size: 20
2115
2147
  }),
@@ -2128,25 +2160,41 @@ function DashboardActions({
2128
2160
  }
2129
2161
  function Dashboard({
2130
2162
  dashboard,
2163
+ update,
2131
2164
  className = "dashboard"
2132
2165
  }) {
2133
2166
  const [layoutFrozen, freezeLayout] = React.useState(false);
2134
- const [newCounter, setNewCounter] = React.useState(0);
2135
2167
  const [breakpoint, setBreakpoint] = React.useState();
2136
2168
  const [localCols, setLocalCols] = React.useState();
2137
- const [panels, setPanels] = React.useState(dashboard.panels);
2169
+ const [panels, setPanels] = useListState(dashboard.panels);
2138
2170
  const [sqlSnippets, setSQLSnippets] = React.useState(dashboard.definition.sqlSnippets);
2139
2171
  const [mode, setMode] = React.useState(DashboardMode.Edit);
2172
+ const hasChanges = React.useMemo(() => {
2173
+ const cleanJSON = (v) => JSON.parse(JSON.stringify(v));
2174
+ const panelsEqual = _.isEqual(cleanJSON(panels), cleanJSON(dashboard.panels));
2175
+ if (!panelsEqual) {
2176
+ return true;
2177
+ }
2178
+ return !_.isEqual(sqlSnippets, dashboard.definition.sqlSnippets);
2179
+ }, [dashboard, panels, sqlSnippets]);
2180
+ const saveDashboardChanges = async () => {
2181
+ const d = _.merge({}, dashboard, {
2182
+ panels
2183
+ }, {
2184
+ definition: {
2185
+ sqlSnippets
2186
+ }
2187
+ });
2188
+ await update(d);
2189
+ };
2140
2190
  const addPanel = () => {
2141
- console.log("adding", "n" + newCounter);
2142
- setNewCounter((v) => v + 1);
2143
- const id = "n" + newCounter;
2191
+ const id = randomId();
2144
2192
  const newItem = {
2145
2193
  id,
2146
2194
  layout: {
2147
- x: panels.length * 2 % (localCols || 12),
2195
+ x: 0,
2148
2196
  y: Infinity,
2149
- w: 4,
2197
+ w: 3,
2150
2198
  h: 4
2151
2199
  },
2152
2200
  title: `New Panel - ${id}`,
@@ -2157,21 +2205,21 @@ function Dashboard({
2157
2205
  conf: {}
2158
2206
  }
2159
2207
  };
2160
- setPanels((panels2) => [...panels2, newItem]);
2208
+ setPanels.append(newItem);
2161
2209
  };
2162
2210
  const removePanelByID = (id) => {
2163
- setPanels((panels2) => _.reject(panels2, {
2164
- id
2165
- }));
2211
+ const index2 = panels.findIndex((p2) => p2.id === id);
2212
+ setPanels.remove(index2);
2166
2213
  };
2167
2214
  const inEditMode = mode === DashboardMode.Edit;
2215
+ const definitions = React.useMemo(() => ({
2216
+ sqlSnippets,
2217
+ setSQLSnippets
2218
+ }), [sqlSnippets, setSQLSnippets]);
2168
2219
  return /* @__PURE__ */ jsx("div", {
2169
2220
  className,
2170
2221
  children: /* @__PURE__ */ jsx(DefinitionContext.Provider, {
2171
- value: {
2172
- sqlSnippets,
2173
- setSQLSnippets
2174
- },
2222
+ value: definitions,
2175
2223
  children: /* @__PURE__ */ jsxs(LayoutStateContext.Provider, {
2176
2224
  value: {
2177
2225
  layoutFrozen,
@@ -2182,9 +2230,12 @@ function Dashboard({
2182
2230
  children: [/* @__PURE__ */ jsx(DashboardActions, {
2183
2231
  mode,
2184
2232
  setMode,
2185
- addPanel
2233
+ hasChanges,
2234
+ addPanel,
2235
+ saveChanges: saveDashboardChanges
2186
2236
  }), /* @__PURE__ */ jsx(DashboardLayout, {
2187
2237
  panels,
2238
+ setPanels,
2188
2239
  isDraggable: inEditMode && !layoutFrozen,
2189
2240
  isResizable: inEditMode && !layoutFrozen,
2190
2241
  onRemoveItem: removePanelByID,
@@ -1,4 +1,4 @@
1
- (function(p,v){typeof exports=="object"&&typeof module!="undefined"?v(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("ahooks"),require("axios"),require("tabler-icons-react"),require("@mantine/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("@mantine/prism"),require("@mantine/form"),require("react-hook-form")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","ahooks","axios","tabler-icons-react","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts/components","numbro","echarts-gl","@mantine/prism","@mantine/form","react-hook-form"],v):(p=typeof globalThis!="undefined"?globalThis:p||self,v(p.dashboard={},p.React,p._,p["react-grid-layout"],p["@mantine/core"],p.ahooks,p.axios,p["tabler-icons-react"],p["@mantine/hooks"],p["echarts-for-react/lib/core"],p["echarts/core"],p["echarts/charts"],p["echarts/renderers"],p["echarts/components"],p.numbro,p["echarts-gl"],p["@mantine/prism"],p["@mantine/form"],p["react-hook-form"]))})(this,function(p,v,S,w,t,be,ve,y,I,ye,Se,Y,K,D,Ce,zt,A,P,O){"use strict";var wt=Object.defineProperty,Tt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var fe=(p,v,S)=>v in p?wt(p,v,{enumerable:!0,configurable:!0,writable:!0,value:S}):p[v]=S,m=(p,v)=>{for(var S in v||(v={}))xe.call(v,S)&&fe(p,S,v[S]);if(U)for(var S of U(v))ge.call(v,S)&&fe(p,S,v[S]);return p},E=(p,v)=>Tt(p,_t(v));var z=(p,v)=>{var S={};for(var w in p)xe.call(p,w)&&v.indexOf(w)<0&&(S[w]=p[w]);if(p!=null&&U)for(var w of U(p))v.indexOf(w)<0&&ge.call(p,w)&&(S[w]=p[w]);return S};function M(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}function we(n){if(n&&n.__esModule)return n;var i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return n&&Object.keys(n).forEach(function(r){if(r!=="default"){var a=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(i,r,a.get?a:{enumerable:!0,get:function(){return n[r]}})}}),i.default=n,Object.freeze(i)}var u=M(v),T=M(S),Te=M(ve),X=M(ye),q=we(Se),ae=M(Ce),k=(n=>(n.Use="use",n.Edit="edit",n))(k||{});const _e={layoutFrozen:!1,freezeLayout:()=>{},mode:k.Edit,inEditMode:!1},$=u.default.createContext(_e),ze=(n=>(i,r,a={})=>{const o=m({"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json"},a.headers),s={baseURL:"http://localhost:31200",method:n,url:i,params:n==="GET"?r:a.params,headers:o};return n==="POST"&&(s.data=a.string?JSON.stringify(r):r),Te.default(s).then(l=>l.data).catch(l=>Promise.reject(l))})("POST");function le(n,i){const r=Object.keys(i),a=Object.values(i);return new Function(...r,`return \`${n}\`;`)(...a)}function Pe(n,i){const r=i.sqlSnippets.reduce((a,o)=>(a[o.key]=le(o.value,n),a),{});return T.default.defaultsDeep(n,r)}const Le=(n,i,r,a)=>async()=>{if(!n)return[];const o=Pe(i,r),s=le(n,o);return n.includes("$")&&(console.groupCollapsed(`Final SQL for: ${a}`),console.log(s),console.groupEnd()),await ze("/query",{sql:s})},oe={},Ie=oe,H=u.default.createContext(oe),ke={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},sql:"",setSQL:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},L=u.default.createContext(ke);var j={exports:{}},B={};/**
1
+ (function(p,S){typeof exports=="object"&&typeof module!="undefined"?S(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("ahooks"),require("axios"),require("tabler-icons-react"),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("@mantine/prism"),require("@mantine/form"),require("react-hook-form")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","ahooks","axios","tabler-icons-react","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts/components","numbro","echarts-gl","@mantine/prism","@mantine/form","react-hook-form"],S):(p=typeof globalThis!="undefined"?globalThis:p||self,S(p.dashboard={},p.React,p._,p["react-grid-layout"],p["@mantine/core"],p.ahooks,p.axios,p["tabler-icons-react"],p["@mantine/hooks"],p["echarts-for-react/lib/core"],p["echarts/core"],p["echarts/charts"],p["echarts/renderers"],p["echarts/components"],p.numbro,p["echarts-gl"],p["@mantine/prism"],p["@mantine/form"],p["react-hook-form"]))})(this,function(p,S,C,w,t,ve,ye,y,P,Se,Ce,X,H,A,we,zt,M,L,B){"use strict";var wt=Object.defineProperty,Tt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var xe=(p,S,C)=>S in p?wt(p,S,{enumerable:!0,configurable:!0,writable:!0,value:C}):p[S]=C,m=(p,S)=>{for(var C in S||(S={}))ge.call(S,C)&&xe(p,C,S[C]);if(K)for(var C of K(S))be.call(S,C)&&xe(p,C,S[C]);return p},k=(p,S)=>Tt(p,_t(S));var I=(p,S)=>{var C={};for(var w in p)ge.call(p,w)&&S.indexOf(w)<0&&(C[w]=p[w]);if(p!=null&&K)for(var w of K(p))S.indexOf(w)<0&&be.call(p,w)&&(C[w]=p[w]);return C};function j(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}function Te(n){if(n&&n.__esModule)return n;var i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return n&&Object.keys(n).forEach(function(r){if(r!=="default"){var a=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(i,r,a.get?a:{enumerable:!0,get:function(){return n[r]}})}}),i.default=n,Object.freeze(i)}var d=j(S),T=j(C),_e=j(ye),Z=j(Se),$=Te(Ce),re=j(we),q=(n=>(n.Use="use",n.Edit="edit",n))(q||{});const ze={layoutFrozen:!1,freezeLayout:()=>{},mode:q.Edit,inEditMode:!1},R=d.default.createContext(ze),Pe=(n=>(i,r,a={})=>{const o=m({"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json"},a.headers),s={baseURL:"http://localhost:31200",method:n,url:i,params:n==="GET"?r:a.params,headers:o};return n==="POST"&&(s.data=a.string?JSON.stringify(r):r),_e.default(s).then(l=>l.data).catch(l=>Promise.reject(l))})("POST");function ae(n,i){const r=Object.keys(i),a=Object.values(i);return new Function(...r,`return \`${n}\`;`)(...a)}function Ie(n,i){const r=i.sqlSnippets.reduce((a,o)=>(a[o.key]=ae(o.value,n),a),{});return T.default.merge({},r,n)}const Le=(n,i,r,a)=>async()=>{if(!n)return[];const o=n.includes("$"),s=Ie(i,r);if(o&&Object.keys(s).length===0)return console.error(`[queryBySQL] insufficient params for {${a}}'s SQL`),[];const l=ae(n,s);return o&&(console.groupCollapsed(`Final SQL for: ${a}`),console.log(l),console.groupEnd()),await Pe("/query",{sql:l})},oe={},De=oe,ee=d.default.createContext(oe),Ge={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},sql:"",setSQL:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},D=d.default.createContext(Ge);var Q={exports:{}},W={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,16 +6,16 @@
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 Ge=u.default,De=Symbol.for("react.element"),Ae=Symbol.for("react.fragment"),Oe=Object.prototype.hasOwnProperty,Ee=Ge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qe={key:!0,ref:!0,__self:!0,__source:!0};function se(n,i,r){var a,o={},s=null,l=null;r!==void 0&&(s=""+r),i.key!==void 0&&(s=""+i.key),i.ref!==void 0&&(l=i.ref);for(a in i)Oe.call(i,a)&&!qe.hasOwnProperty(a)&&(o[a]=i[a]);if(n&&n.defaultProps)for(a in i=n.defaultProps,i)o[a]===void 0&&(o[a]=i[a]);return{$$typeof:De,type:n,key:s,ref:l,props:o,_owner:Ee.current}}B.Fragment=Ae,B.jsx=se,B.jsxs=se,j.exports=B;const e=j.exports.jsx,c=j.exports.jsxs,N=j.exports.Fragment;q.use([Y.SunburstChart,K.CanvasRenderer]);const Me={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function $e({conf:n,data:i,width:r,height:a}){const h=n,{label_field:o="name",value_field:s="value"}=h,l=z(h,["label_field","value_field"]),d=u.default.useMemo(()=>i.map(b=>({name:b[o],value:b[s]})),[i,o,s]),f=u.default.useMemo(()=>{var b,C;return(C=(b=T.default.maxBy(d,_=>_.value))==null?void 0:b.value)!=null?C:1},[d]),g=u.default.useMemo(()=>({series:{label:{formatter:({name:b,value:C})=>C/f<.2?" ":b}}}),[]),x=T.default.defaultsDeep(Me,g,l,{series:{data:d}});return e(X.default,{echarts:q,option:x,style:{width:r,height:a}})}q.use([Y.BarChart,Y.LineChart,D.GridComponent,D.LegendComponent,D.TooltipComponent,K.CanvasRenderer]);const je={legend:{show:!0},tooltip:{trigger:"axis"},xAxis:{type:"category"},yAxis:{}};function Be({conf:n,data:i,width:r,height:a}){const o=u.default.useMemo(()=>{const s={dataset:{source:i}},l={xAxis:{data:i.map(f=>f[n.x_axis_data_key])}},d=n.series.map(x=>{var h=x,{y_axis_data_key:f}=h,g=z(h,["y_axis_data_key"]);return m({data:i.map(b=>b[f])},g)});return T.default.assign({},je,s,l,{series:d})},[n,i]);return!r||!a?null:e(X.default,{echarts:q,option:o,style:{width:r,height:a}})}var G=(n=>(n.string="string",n.number="number",n.eloc="eloc",n.percentage="percentage",n))(G||{});function Ne({value:n}){return e(t.Text,{component:"span",children:n})}function Ve({value:n}){return e(t.Text,{component:"span",children:n})}function Fe({value:n}){const i=ae.default(n).format({thousandSeparated:!0});return e(t.Text,{component:"span",children:i})}function Re({value:n}){const i=ae.default(n).format({output:"percent",mantissa:3});return e(t.Text,{component:"span",children:i})}function Qe({value:n,type:i}){switch(i){case G.string:return e(Ne,{value:n});case G.eloc:return e(Ve,{value:n});case G.number:return e(Fe,{value:n});case G.percentage:return e(Re,{value:n})}}function We({conf:n,data:i,width:r,height:a}){const x=n,{id_field:o,use_raw_columns:s,columns:l}=x,d=z(x,["id_field","use_raw_columns","columns"]),f=u.default.useMemo(()=>s?Object.keys(i==null?void 0:i[0]):l.map(h=>h.label),[s,l,i]),g=u.default.useMemo(()=>s?Object.keys(i==null?void 0:i[0]).map(h=>({label:h,value_field:h,value_type:G.string})):l,[s,l,i]);return c(t.Table,E(m({sx:{maxHeight:a}},d),{children:[e("thead",{children:e("tr",{children:f.map(h=>e("th",{children:h},h))})}),e("tbody",{children:i.map((h,b)=>e("tr",{children:g.map(({value_field:C,value_type:_})=>e("td",{children:e(t.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:e(Qe,{value:h[C],type:_})})},h[C]))},o?h[o]:`row-${b}`))})]}))}function Je(n,i={}){const r=Object.keys(i),a=Object.values(i);try{return new Function(...r,`return \`${n}\`;`)(...a)}catch(o){return o.message}}function Ue({conf:{paragraphs:n},data:i}){return e(N,{children:n.map((s,o)=>{var l=s,{template:r}=l,a=z(l,["template"]);return e(t.Text,E(m({},a),{children:Je(r,i[0])}),`${r}---${o}`)})})}q.use([D.GridComponent,D.VisualMapComponent,D.LegendComponent,D.TooltipComponent,K.CanvasRenderer]);function Ye({conf:n,data:i,width:r,height:a}){const h=n,{x_axis_data_key:o,y_axis_data_key:s,z_axis_data_key:l}=h,d=z(h,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),f=u.default.useMemo(()=>T.default.minBy(i,b=>b[l])[l],[i,l]),g=u.default.useMemo(()=>T.default.maxBy(i,b=>b[l])[l],[i,l]),x=E(m({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:f,max:g,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}}}},d),{series:[{type:"bar3D",wireframe:{},data:i.map(b=>[b[o],b[s],b[l]])}]});return e(X.default,{echarts:q,option:x,style:{width:r,height:a}})}var Lt="";function Ke(n,i,r,a){const o={width:n,height:i,data:r,conf:a.conf};switch(a.type){case"sunburst":return e($e,m({},o));case"line-bar":return e(Be,m({},o));case"table":return e(We,m({},o));case"text":return e(Ue,m({},o));case"bar-3d":return e(Ye,m({},o));default:return null}}function ue({viz:n,data:i,loading:r}){const{ref:a,width:o,height:s}=I.useElementSize(),l=u.default.useMemo(()=>!Array.isArray(i)||i.length===0,[i]);return r?e("div",{className:"viz-root",ref:a,children:e(t.LoadingOverlay,{visible:r})}):c("div",{className:"viz-root",ref:a,children:[l&&e(t.Text,{color:"gray",align:"center",children:"nothing to show"}),!l&&Ke(o,s,i,n)]})}function Xe({}){const n=u.default.useContext(H),i="SELECT *\nFROM commit\nWHERE author_time BETWEEN '${timeRange?.[0].toISOString()}' AND '${timeRange?.[1].toISOString()}'";return c(t.Group,{direction:"column",children:[e(A.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:`-- You may refer context data *by name*
9
+ */var ke=d.default,qe=Symbol.for("react.element"),Ee=Symbol.for("react.fragment"),Oe=Object.prototype.hasOwnProperty,Ae=ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Me={key:!0,ref:!0,__self:!0,__source:!0};function le(n,i,r){var a,o={},s=null,l=null;r!==void 0&&(s=""+r),i.key!==void 0&&(s=""+i.key),i.ref!==void 0&&(l=i.ref);for(a in i)Oe.call(i,a)&&!Me.hasOwnProperty(a)&&(o[a]=i[a]);if(n&&n.defaultProps)for(a in i=n.defaultProps,i)o[a]===void 0&&(o[a]=i[a]);return{$$typeof:qe,type:n,key:s,ref:l,props:o,_owner:Ae.current}}W.Fragment=Ee,W.jsx=le,W.jsxs=le,Q.exports=W;const e=Q.exports.jsx,c=Q.exports.jsxs,se=Q.exports.Fragment;class ue extends d.default.Component{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e("h1",{children:"Something went wrong."}):this.props.children}}$.use([X.SunburstChart,H.CanvasRenderer]);const Be={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Ne({conf:n,data:i,width:r,height:a}){const x=n,{label_field:o="name",value_field:s="value"}=x,l=I(x,["label_field","value_field"]),u=d.default.useMemo(()=>i.map(g=>({name:g[o],value:Number(g[s])})),[i,o,s]),f=d.default.useMemo(()=>{var g,v;return(v=(g=T.default.maxBy(u,z=>z.value))==null?void 0:g.value)!=null?v:1},[u]),h=d.default.useMemo(()=>({series:{label:{formatter:({name:g,value:v})=>v/f<.2?" ":g}}}),[]),b=T.default.merge(Be,h,l,{series:{data:u}});return e(Z.default,{echarts:$,option:b,style:{width:r,height:a}})}$.use([X.BarChart,X.LineChart,A.GridComponent,A.LegendComponent,A.TooltipComponent,H.CanvasRenderer]);const Fe={legend:{show:!0},tooltip:{trigger:"axis"},xAxis:{type:"category"},yAxis:{},grid:{top:30,left:10,right:10,bottom:10,containLabel:!0}};function $e({conf:n,data:i,width:r,height:a}){const o=d.default.useMemo(()=>{const s={dataset:{source:i}},l={xAxis:{data:i.map(f=>f[n.x_axis_data_key])}},u=n.series.map(b=>{var x=b,{y_axis_data_key:f}=x,h=I(x,["y_axis_data_key"]);return m({data:i.map(g=>g[f])},h)});return T.default.assign({},Fe,s,l,{series:u})},[n,i]);return!r||!a?null:e(Z.default,{echarts:$,option:o,style:{width:r,height:a}})}var E=(n=>(n.string="string",n.number="number",n.eloc="eloc",n.percentage="percentage",n))(E||{});function je({value:n}){return e(t.Text,{component:"span",children:n})}function Ve({value:n}){return e(t.Text,{component:"span",children:n})}function Re({value:n}){const i=re.default(n).format({thousandSeparated:!0});return e(t.Text,{component:"span",children:i})}function Qe({value:n}){const i=re.default(n).format({output:"percent",mantissa:3});return e(t.Text,{component:"span",children:i})}function We({value:n,type:i}){switch(i){case E.string:return e(je,{value:n});case E.eloc:return e(Ve,{value:n});case E.number:return e(Re,{value:n});case E.percentage:return e(Qe,{value:n})}}function Je({conf:n,data:i,width:r,height:a}){const b=n,{id_field:o,use_raw_columns:s,columns:l}=b,u=I(b,["id_field","use_raw_columns","columns"]),f=d.default.useMemo(()=>s?Object.keys(i==null?void 0:i[0]):l.map(x=>x.label),[s,l,i]),h=d.default.useMemo(()=>s?Object.keys(i==null?void 0:i[0]).map(x=>({label:x,value_field:x,value_type:E.string})):l,[s,l,i]);return c(t.Table,k(m({sx:{maxHeight:a}},u),{children:[e("thead",{children:e("tr",{children:f.map(x=>e("th",{children:x},x))})}),e("tbody",{children:i.map((x,g)=>e("tr",{children:h.map(({value_field:v,value_type:z})=>e("td",{children:e(t.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:e(We,{value:x[v],type:z})})},x[v]))},o?x[o]:`row-${g}`))})]}))}function Ue(n,i={}){const r=Object.keys(i),a=Object.values(i);try{return new Function(...r,`return \`${n}\`;`)(...a)}catch(o){return o.message}}function Ye({conf:{paragraphs:n},data:i}){return e(se,{children:n.map((l,s)=>{var u=l,{template:r,size:a}=u,o=I(u,["template","size"]);return e(t.Text,k(m({},o),{sx:{fontSize:a},children:Ue(r,i[0])}),`${r}---${s}`)})})}$.use([A.GridComponent,A.VisualMapComponent,A.LegendComponent,A.TooltipComponent,H.CanvasRenderer]);function Ke({conf:n,data:i,width:r,height:a}){const x=n,{x_axis_data_key:o,y_axis_data_key:s,z_axis_data_key:l}=x,u=I(x,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),f=d.default.useMemo(()=>T.default.minBy(i,g=>g[l])[l],[i,l]),h=d.default.useMemo(()=>T.default.maxBy(i,g=>g[l])[l],[i,l]),b=k(m({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:f,max:h,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:i.map(g=>[g[o],g[s],g[l]])}]});return e(Z.default,{echarts:$,option:b,style:{width:r,height:a}})}var It="";function Xe(n,i,r,a){const o={width:n,height:i,data:r,conf:a.conf};switch(a.type){case"sunburst":return e(Ne,m({},o));case"line-bar":return e($e,m({},o));case"table":return e(Je,m({},o));case"text":return e(Ye,m({},o));case"bar-3d":return e(Ke,m({},o));default:return null}}function de({viz:n,data:i,loading:r}){const{ref:a,width:o,height:s}=P.useElementSize(),l=d.default.useMemo(()=>!Array.isArray(i)||i.length===0,[i]);return r?e("div",{className:"viz-root",ref:a,children:e(t.LoadingOverlay,{visible:r})}):c("div",{className:"viz-root",ref:a,children:[l&&e(t.Text,{color:"gray",align:"center",children:"nothing to show"}),!l&&Xe(o,s,i,n)]})}function He({}){const n=d.default.useContext(ee),i="SELECT *\nFROM commit\nWHERE author_time BETWEEN '${timeRange?.[0].toISOString()}' AND '${timeRange?.[1].toISOString()}'";return c(t.Group,{direction:"column",children:[e(M.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:`-- You may refer context data *by name*
10
10
  -- in SQL or VizConfig.
11
11
 
12
- ${i}`}),e(t.Text,{weight:700,children:"Avaiable context entries"}),e(A.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:JSON.stringify(n,null,2)})]})}var It="";function He({}){const{sql:n,setSQL:i}=u.default.useContext(L),[r,a]=u.default.useState(!0),o=d=>{i(d.target.value)},s=u.default.useCallback(()=>{a(d=>!d)},[]),l=u.default.useCallback(()=>{i(d=>d.trim())},[i]);return c(t.Box,{className:"sql-query-editor-root",sx:{height:"100%"},children:[e(t.Textarea,{value:n,onChange:o,minRows:20,maxRows:20}),c(t.Group,{m:"md",position:"right",children:[e(t.Button,{color:"blue",onClick:l,children:"Format"}),e(t.Button,{variant:"default",onClick:s,children:"Toggle Preview"})]}),r&&e(A.Prism,{language:"sql",withLineNumbers:!0,noCopy:!0,colorScheme:"dark",children:n})]})}const Ze=He;function et({}){const{data:n}=u.default.useContext(L);return c("div",{className:"query-result-root",children:[c(t.Group,{mb:"xs",children:[e(t.Text,{weight:"bold",children:"Data Length: "}),n.length]}),e(A.Prism,{language:"json",colorScheme:"dark",children:JSON.stringify(n,null,2)})]})}const tt={sqlSnippets:[],setSQLSnippets:()=>{}},V=u.default.createContext(tt);function nt({sqlSnippets:n,setSQLSnippets:i}){const r=u.default.useRef(null),a=u.default.useMemo(()=>({snippets:P.formList(n!=null?n:[])}),[n]),o=P.useForm({initialValues:a}),s=()=>o.addListItem("snippets",{key:I.randomId(),value:""}),l=u.default.useMemo(()=>!T.default.isEqual(o.values,a),[o.values,a]);u.default.useEffect(()=>{var f;l&&((f=r==null?void 0:r.current)==null||f.click())},[l,r.current]);const d=({snippets:f})=>{i(f)};return e(t.Group,{direction:"column",sx:{width:"100%"},grow:!0,children:c("form",{onSubmit:o.onSubmit(d),children:[e("button",{ref:r,type:"submit",style:{display:"none"},children:"Ghost submit"}),o.values.snippets.map((f,g)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[e(t.TextInput,m({label:"Key",required:!0},o.getListInputProps("snippets",g,"key"))),e(t.Textarea,m({minRows:3,label:"Value",required:!0},o.getListInputProps("snippets",g,"value"))),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>o.removeListItem("snippets",g),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},g)),e(t.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:e(t.Button,{color:"blue",onClick:s,children:"Add a snippet"})})]})})}function it({}){const{sqlSnippets:n,setSQLSnippets:i}=u.default.useContext(V),r=`SELECT *
12
+ ${i}`}),e(t.Text,{weight:700,children:"Avaiable context entries"}),e(M.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:JSON.stringify(n,null,2)})]})}var Lt="";function Ze({}){const{sql:n,setSQL:i}=d.default.useContext(D),[r,a]=d.default.useState(!0),o=u=>{i(u.target.value)},s=d.default.useCallback(()=>{a(u=>!u)},[]),l=d.default.useCallback(()=>{i(u=>u.trim())},[i]);return c(t.Box,{className:"sql-query-editor-root",sx:{height:"100%"},children:[e(t.Textarea,{value:n,onChange:o,minRows:20,maxRows:20}),c(t.Group,{m:"md",position:"right",children:[e(t.Button,{color:"blue",onClick:l,children:"Format"}),e(t.Button,{variant:"default",onClick:s,children:"Toggle Preview"})]}),r&&e(M.Prism,{language:"sql",withLineNumbers:!0,noCopy:!0,colorScheme:"dark",children:n})]})}const et=Ze;function tt({}){const{data:n}=d.default.useContext(D);return c("div",{className:"query-result-root",children:[c(t.Group,{mb:"xs",children:[e(t.Text,{weight:"bold",children:"Data Length: "}),n.length]}),e(M.Prism,{language:"json",colorScheme:"dark",children:JSON.stringify(n,null,2)})]})}const nt={sqlSnippets:[],setSQLSnippets:()=>{}},J=d.default.createContext(nt);function it({sqlSnippets:n,setSQLSnippets:i}){const r=d.default.useMemo(()=>({snippets:L.formList(n!=null?n:[])}),[n]),a=L.useForm({initialValues:r}),o=()=>a.addListItem("snippets",{key:P.randomId(),value:""}),s=d.default.useMemo(()=>!T.default.isEqual(a.values,r),[a.values,r]),l=({snippets:u})=>{i(u)};return e(t.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:c("form",{onSubmit:a.onSubmit(l),children:[a.values.snippets.map((u,f)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[e(t.TextInput,m({label:"Key",required:!0},a.getListInputProps("snippets",f,"key"))),e(t.Textarea,m({minRows:3,label:"Value",required:!0},a.getListInputProps("snippets",f,"value"))),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>a.removeListItem("snippets",f),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},f)),c(t.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"80%"},mx:"auto",children:[e(t.Button,{variant:"default",onClick:o,children:"Add a snippet"}),e(t.Button,{color:"blue",type:"submit",disabled:!s,children:"Submit"})]})]})})}function rt({}){const{sqlSnippets:n,setSQLSnippets:i}=d.default.useContext(J),r=`SELECT *
13
13
  FROM commit
14
- WHERE \${author_time_condition}`;return c(t.Group,{direction:"column",children:[e(A.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:`-- You may refer context data *by name*
14
+ WHERE \${author_time_condition}`;return c(t.Group,{direction:"column",children:[e(M.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,trim:!1,colorScheme:"dark",children:`-- You may refer context data *by name*
15
15
  -- in SQL or VizConfig.
16
16
 
17
17
  ${r}
18
18
 
19
19
  -- where author_time_condition is:
20
20
  author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
21
- `}),e(t.Text,{weight:700,children:"SQL Snippets"}),e(nt,{sqlSnippets:n,setSQLSnippets:i})]})}function rt(){const{description:n,setDescription:i}=u.default.useContext(L),[r,a]=I.useInputState(n),o=n!==r,s=u.default.useCallback(()=>{!o||i(r)},[o,r]);return e(t.Textarea,{label:"Panel Description",value:r,onChange:a,minRows:2,rightSection:e(t.ActionIcon,{disabled:!o,onClick:s,sx:{alignSelf:"flex-start",marginTop:"4px"},children:e(y.DeviceFloppy,{size:20})})})}function at(){const{title:n,setTitle:i}=u.default.useContext(L),[r,a]=I.useInputState(n),o=n!==r,s=u.default.useCallback(()=>{!o||i(r)},[o,r]);return e(t.TextInput,{label:"Panel Title",value:r,onChange:a,rightSection:e(t.ActionIcon,{disabled:!o,onClick:s,children:e(y.DeviceFloppy,{size:20})})})}function lt({conf:n,setConf:i}){const r=T.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"}},n),{control:a,handleSubmit:o,formState:s}=O.useForm({defaultValues:r});return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:o(i),children:[e(t.Text,{children:"X Axis"}),c(t.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[e(O.Controller,{name:"x_axis_data_key",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Data Key"},l))}),e(O.Controller,{name:"xAxis3D.name",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Name"},l))})]}),e(t.Text,{mt:"lg",children:"Y Axis"}),c(t.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[e(O.Controller,{name:"y_axis_data_key",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Data Key"},l))}),e(O.Controller,{name:"yAxis3D.name",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Name"},l))})]}),e(t.Text,{mt:"lg",children:"Z Axis"}),c(t.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[e(O.Controller,{name:"z_axis_data_key",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Data Key"},l))}),e(O.Controller,{name:"zAxis3D.name",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Name"},l))})]}),e(t.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:c(t.Button,{color:"blue",type:"submit",children:[e(y.DeviceFloppy,{size:20}),e(t.Text,{ml:"md",children:"Save"})]})})]})})}function de({value:n,onChange:i}){const r=t.useMantineTheme(),a=u.default.useMemo(()=>Object.entries(r.colors).map(([s,l])=>({label:s,value:l[6]})),[r]),o=u.default.useMemo(()=>a.some(s=>s.value===n),[n,a]);return c(t.Group,{position:"apart",spacing:"xs",children:[e(t.TextInput,{placeholder:"Set any color",value:o?"":n,onChange:s=>i(s.currentTarget.value),rightSection:e(t.ColorSwatch,{color:o?"transparent":n,radius:4}),variant:o?"filled":"default",sx:{maxWidth:"100%",flexGrow:1}}),e(t.Text,{sx:{flexGrow:0},children:"or"}),e(t.Select,{data:a,value:n,onChange:i,variant:o?"default":"filled",placeholder:"Pick a theme color",icon:e(t.ColorSwatch,{color:o?n:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}function ot({conf:n,setConf:i}){const r=u.default.useRef(null),g=n,{series:a}=g,o=z(g,["series"]),s=u.default.useMemo(()=>m({series:P.formList(a!=null?a:[])},o),[a,o]),l=P.useForm({initialValues:s}),d=()=>l.addListItem("series",{type:"bar",name:I.randomId(),showSymbol:!1,y_axis_data_key:"value",stack:"",color:"#000"}),f=u.default.useMemo(()=>!T.default.isEqual(l.values,s),[l.values,s]);return u.default.useEffect(()=>{var x;f&&((x=r==null?void 0:r.current)==null||x.click())},[f,r.current]),e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:l.onSubmit(i),children:[c(t.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[e(t.Text,{children:"Chart Config"}),e("button",{ref:r,type:"submit",style:{display:"none"},children:"Ghost submit"})]}),e(t.TextInput,m({size:"md",mb:"lg",label:"X Axis Data Key"},l.getInputProps("x_axis_data_key"))),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{mt:"xl",mb:0,children:"Series"}),l.values.series.map((x,h)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[e(t.TextInput,m({label:"Label",required:!0,sx:{flex:1}},l.getListInputProps("series",h,"name"))),c(t.Group,{direction:"row",grow:!0,noWrap:!0,children:[e(t.TextInput,m({label:"Y Axis Data key",required:!0},l.getListInputProps("series",h,"y_axis_data_key"))),e(t.TextInput,m({label:"Stack ID",placeholder:"Stack bars by this ID"},l.getListInputProps("series",h,"stack")))]}),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{children:"Color"}),e(de,m({},l.getListInputProps("series",h,"color")))]}),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("series",h),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},h)),e(t.Group,{position:"center",mt:"xs",children:e(t.Button,{onClick:d,children:"Add a Series"})})]})]})})}function st(a){var o=a,{conf:s}=o,l=s,{columns:n}=l,i=z(l,["columns"]),{setConf:r}=o;const d=P.useForm({initialValues:{label_field:"name",value_field:"value"}});return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:d.onSubmit(r),children:[c(t.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[e(t.Text,{children:"Sunburst Config"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),c(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[e(t.TextInput,m({label:"Label Field",required:!0,sx:{flex:1}},d.getInputProps("label_field"))),e(t.TextInput,m({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},d.getInputProps("value_field")))]})]})})}const F=[{value:0,label:"xs"},{value:25,label:"sm"},{value:50,label:"md"},{value:75,label:"lg"},{value:100,label:"xl"}];function R({label:n,value:i,onChange:r}){var s,l;const[a,o]=u.default.useState((l=(s=F.find(d=>d.label===i))==null?void 0:s.value)!=null?l:F[0].value);return u.default.useEffect(()=>{const d=F.find(f=>f.value===a);d&&r(d.label)},[a]),c(t.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[e(t.Text,{children:n}),e(t.Slider,{label:null,marks:F,value:a,onChange:o,step:25,placeholder:"Pick a font size"})]})}const ut=Object.values(G).map(n=>({label:n,value:n}));function dt({label:n,value:i,onChange:r,sx:a}){return e(t.Select,{label:n,data:ut,value:i,onChange:r,sx:a})}function ct(a){var o=a,{conf:s}=o,l=s,{columns:n}=l,i=z(l,["columns"]),{setConf:r}=o;const d=P.useForm({initialValues:m({id_field:"id",use_raw_columns:!0,columns:P.formList(n!=null?n:[]),size:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},i)}),f=()=>d.addListItem("columns",{label:I.randomId(),value_field:"value",value_type:G.string});return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:d.onSubmit(r),children:[c(t.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[e(t.Text,{children:"Table Config"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),c(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[e(t.TextInput,m({size:"md",mb:"lg",label:"ID Field"},d.getInputProps("id_field"))),c(t.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[e(R,m({label:"Horizontal Spacing"},d.getInputProps("horizontalSpacing"))),e(R,m({label:"Vertical Spacing"},d.getInputProps("verticalSpacing")))]}),e(t.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:e(R,m({label:"Font Size"},d.getInputProps("size")))}),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{children:"Other"}),c(t.Group,{position:"apart",grow:!0,children:[e(t.Switch,m({label:"Striped"},d.getInputProps("striped",{type:"checkbox"}))),e(t.Switch,m({label:"Highlight on hover"},d.getInputProps("highlightOnHover",{type:"checkbox"})))]})]})]}),c(t.Group,{direction:"column",mt:"xs",spacing:"xs",grow:!0,p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[e(t.Switch,m({label:"Use Original Data Columns"},d.getInputProps("use_raw_columns",{type:"checkbox"}))),!d.values.use_raw_columns&&c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{mt:"xl",mb:0,children:"Custom Columns"}),d.values.columns.map((g,x)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[c(t.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[e(t.TextInput,m({label:"Label",required:!0,sx:{flex:1}},d.getListInputProps("columns",x,"label"))),e(t.TextInput,m({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},d.getListInputProps("columns",x,"value_field"))),e(dt,m({label:"Value Type",sx:{flex:1}},d.getListInputProps("columns",x,"value_type")))]}),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>d.removeListItem("columns",x),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},x)),e(t.Group,{position:"center",mt:"xs",children:e(t.Button,{onClick:f,children:"Add a Column"})})]})]}),e(t.Text,{weight:500,mb:"md",children:"Current Configuration:"}),e(A.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(d.values,null,2)})]})})}const Q=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function pt({label:n,value:i,onChange:r}){var s,l;const[a,o]=u.default.useState((l=(s=Q.find(d=>d.label===i))==null?void 0:s.value)!=null?l:Q[0].value);return u.default.useEffect(()=>{const d=Q.find(f=>f.value===a);d&&r(d.label)},[a]),c(t.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[e(t.Text,{children:n}),e(t.Slider,{label:null,marks:Q,value:a,onChange:o,step:25,placeholder:"Pick a font size"})]})}const ce=[{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 mt({conf:n,setConf:i}){var o;const r=P.useForm({initialValues:{paragraphs:P.formList((o=n.paragraphs)!=null?o:ce)}}),a=()=>r.addListItem("paragraphs",E(m({},ce[0]),{template:I.randomId()}));return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:r.onSubmit(i),children:[r.values.paragraphs.length===0&&e(t.Text,{color:"dimmed",align:"center",children:"Empty"}),c(t.Group,{position:"apart",mb:"xs",sx:{" + .mantine-Group-root":{marginTop:0}},children:[e(t.Text,{children:"Paragraphs"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),r.values.paragraphs.map((s,l)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[e(t.TextInput,m({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},r.getListInputProps("paragraphs",l,"template"))),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{children:"Color"}),e(de,m({},r.getListInputProps("paragraphs",l,"color")))]}),c(t.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[e(R,m({label:"Font Size"},r.getListInputProps("paragraphs",l,"size"))),e(pt,m({label:"Font Weight"},r.getListInputProps("paragraphs",l,"weight")))]}),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>r.removeListItem("paragraphs",l),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},l)),e(t.Group,{position:"center",mt:"md",children:e(t.Button,{onClick:a,children:"Add a Paragraph"})}),e(t.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),e(A.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(r.values,null,2)})]})})}const Z=[{value:"text",label:"Text",Panel:mt},{value:"table",label:"Table",Panel:ct},{value:"sunburst",label:"Sunburst",Panel:st},{value:"bar-3d",label:"Bar Chart (3D)",Panel:lt},{value:"line-bar",label:"Line-Bar Chart",Panel:ot}];function ht(){const{viz:n,setViz:i}=u.default.useContext(L),[r,a]=I.useInputState(n.type),o=n.type!==r,s=u.default.useCallback(()=>{!o||i(g=>E(m({},g),{type:r}))},[o,r]),l=g=>{i(x=>E(m({},x),{conf:g}))},d=g=>{try{l(JSON.parse(g))}catch(x){console.error(x)}},f=u.default.useMemo(()=>{var g;return(g=Z.find(x=>x.value===r))==null?void 0:g.Panel},[r,Z]);return c(N,{children:[e(t.Select,{label:"Visualization",value:r,onChange:a,data:Z,rightSection:e(t.ActionIcon,{disabled:!o,onClick:s,children:e(y.DeviceFloppy,{size:20})})}),f&&e(f,{conf:n.conf,setConf:l}),!f&&e(t.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(n.conf,null,2),onChange:d})]})}function ft({}){return c(t.Group,{grow:!0,direction:"column",children:[e(at,{}),e(rt,{}),e(t.Divider,{}),e(ht,{})]})}function xt({}){const{freezeLayout:n}=u.default.useContext($),{data:i,loading:r,viz:a,title:o}=u.default.useContext(L),[s,l]=u.default.useState(!1),d=()=>l(!0);return u.default.useEffect(()=>{n(s)},[s]),c(N,{children:[e(t.Modal,{size:"96vw",overflow:"inside",opened:s,onClose:()=>l(!1),title:o,trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:e(t.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%"}},padding:"md",navbar:e(t.Navbar,{width:{base:"40%"},height:"100%",p:"xs",children:c(t.Tabs,{initialTab:1,children:[e(t.Tabs.Tab,{label:"Context",children:e(Xe,{})}),e(t.Tabs.Tab,{label:"SQL Snippets",children:e(it,{})}),e(t.Tabs.Tab,{label:"SQL",children:e(Ze,{})}),c(t.Tabs.Tab,{label:"Data",children:[e(t.LoadingOverlay,{visible:r}),e(et,{})]}),e(t.Tabs.Tab,{label:"Viz Config",children:e(ft,{})})]})}),children:e(ue,{viz:a,data:i,loading:r})})}),e(t.ActionIcon,{variant:"hover",color:"blue",loading:r,onClick:d,children:e(y.Settings,{size:16})})]})}function gt({title:n,description:i}){return c(t.Group,{position:"center",sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[!i&&e(t.Text,{weight:"bold",sx:{marginLeft:"5px",display:"inline"},children:n}),i&&e("div",{children:c(t.Tooltip,{label:i,withArrow:!0,children:[e(y.InfoCircle,{size:12,style:{verticalAlign:"baseline",cursor:"pointer"}}),e(t.Text,{weight:"bold",sx:{marginLeft:"5px",display:"inline"},children:n})]})})]})}function bt({}){const{title:n,description:i,loading:r,refreshData:a}=u.default.useContext(L),{inEditMode:o}=u.default.useContext($);return c(N,{children:[e(gt,{title:n,description:i}),c(t.Group,{position:"right",spacing:0,sx:{position:"absolute",right:"15px",top:"4px",height:"28px"},children:[e(t.ActionIcon,{variant:"hover",color:"blue",loading:r,onClick:a,children:e(y.Refresh,{size:16})}),o&&e(xt,{})]})]})}var kt="";function pe({viz:n,sql:i,title:r,description:a}){const o=u.default.useContext(H),s=u.default.useContext(V),[l,d]=u.default.useState(r),[f,g]=u.default.useState(a),[x,h]=u.default.useState(i),[b,C]=u.default.useState(n),{data:_=[],loading:W,refresh:ee}=be.useRequest(Le(x,o,s,l),{refreshDeps:[o,s]}),te=ee;return e(L.Provider,{value:{data:_,loading:W,title:l,setTitle:d,description:f,setDescription:g,sql:x,setSQL:h,viz:b,setViz:C,refreshData:te},children:c(t.Container,{className:"panel-root",children:[e(bt,{}),e(ue,{viz:b,data:_,loading:W})]})})}var Gt="";const vt=w.WidthProvider(w.Responsive);function me({panels:n,className:i="layout",cols:r={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:a=10,onRemoveItem:o,isDraggable:s,isResizable:l,setLocalCols:d,setBreakpoint:f}){return e(vt,{onBreakpointChange:(x,h)=>{f(x),d(h)},className:i,cols:r,rowHeight:a,isDraggable:s,isResizable:l,children:n.map(b=>{var C=b,{id:x}=C,h=z(C,["id"]);return e("div",{"data-grid":h.layout,children:e(pe,m({destroy:()=>o(x)},h))},x)})})}function he(n,i){return c(t.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[n," ",i]})}function yt({mode:n,setMode:i}){return e(t.SegmentedControl,{value:n,onChange:i,data:[{label:he(e(y.PlayerPlay,{size:20}),"Use"),value:k.Use},{label:he(e(y.Paint,{size:20}),"Edit"),value:k.Edit}]})}function St({mode:n,setMode:i,addPanel:r}){const a=n===k.Edit;return c(t.Group,{position:"apart",pt:"sm",pb:"xs",children:[e(t.Group,{position:"left",children:e(yt,{mode:n,setMode:i})}),a&&c(t.Group,{position:"right",children:[e(t.Button,{variant:"default",size:"sm",onClick:r,leftIcon:e(y.PlaylistAdd,{size:20}),children:"Add a Panel"}),e(t.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:e(y.DeviceFloppy,{size:20}),children:"Save Dashboard"}),e(t.Button,{color:"red",size:"sm",disabled:!0,leftIcon:e(y.Recycle,{size:20}),children:"Revert Changes"})]}),!a&&e(t.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:e(y.Share,{size:20}),children:"Share"})]})}function Ct({dashboard:n,className:i="dashboard"}){const[r,a]=u.default.useState(!1),[o,s]=u.default.useState(0),[l,d]=u.default.useState(),[f,g]=u.default.useState(),[x,h]=u.default.useState(n.panels),[b,C]=u.default.useState(n.definition.sqlSnippets),[_,W]=u.default.useState(k.Edit),ee=()=>{console.log("adding","n"+o),s(re=>re+1);const J="n"+o,ie={id:J,layout:{x:x.length*2%(f||12),y:1/0,w:4,h:4},title:`New Panel - ${J}`,description:"description goes here",sql:"",viz:{type:"table",conf:{}}};h(re=>[...re,ie])},te=J=>{h(ie=>T.default.reject(ie,{id:J}))},ne=_===k.Edit;return e("div",{className:i,children:e(V.Provider,{value:{sqlSnippets:b,setSQLSnippets:C},children:c($.Provider,{value:{layoutFrozen:r,freezeLayout:a,mode:_,inEditMode:ne},children:[e(St,{mode:_,setMode:W,addPanel:ee}),e(me,{panels:x,isDraggable:ne&&!r,isResizable:ne&&!r,onRemoveItem:te,setLocalCols:g,setBreakpoint:d})]})})})}p.ContextInfoContext=H,p.Dashboard=Ct,p.DashboardLayout=me,p.DashboardMode=k,p.DefinitionContext=V,p.LayoutStateContext=$,p.Panel=pe,p.PanelContext=L,p.initialContextInfoContext=Ie,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
21
+ `}),e(t.Text,{weight:700,children:"SQL Snippets"}),e(it,{sqlSnippets:n,setSQLSnippets:i})]})}function at(){const{description:n,setDescription:i}=d.default.useContext(D),[r,a]=P.useInputState(n),o=n!==r,s=d.default.useCallback(()=>{!o||i(r)},[o,r]);return e(t.Textarea,{label:"Panel Description",value:r,onChange:a,minRows:2,rightSection:e(t.ActionIcon,{disabled:!o,onClick:s,sx:{alignSelf:"flex-start",marginTop:"4px"},children:e(y.DeviceFloppy,{size:20})})})}function ot(){const{title:n,setTitle:i}=d.default.useContext(D),[r,a]=P.useInputState(n),o=n!==r,s=d.default.useCallback(()=>{!o||i(r)},[o,r]);return e(t.TextInput,{label:"Panel Title",value:r,onChange:a,rightSection:e(t.ActionIcon,{disabled:!o,onClick:s,children:e(y.DeviceFloppy,{size:20})})})}function lt({conf:n,setConf:i}){const r=T.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"}},n),{control:a,handleSubmit:o,formState:s}=B.useForm({defaultValues:r});return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:o(i),children:[e(t.Text,{children:"X Axis"}),c(t.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[e(B.Controller,{name:"x_axis_data_key",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Data Key"},l))}),e(B.Controller,{name:"xAxis3D.name",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Name"},l))})]}),e(t.Text,{mt:"lg",children:"Y Axis"}),c(t.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[e(B.Controller,{name:"y_axis_data_key",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Data Key"},l))}),e(B.Controller,{name:"yAxis3D.name",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Name"},l))})]}),e(t.Text,{mt:"lg",children:"Z Axis"}),c(t.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[e(B.Controller,{name:"z_axis_data_key",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Data Key"},l))}),e(B.Controller,{name:"zAxis3D.name",control:a,render:({field:l})=>e(t.TextInput,m({sx:{flexGrow:1},size:"md",label:"Name"},l))})]}),e(t.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:c(t.Button,{color:"blue",type:"submit",children:[e(y.DeviceFloppy,{size:20}),e(t.Text,{ml:"md",children:"Save"})]})})]})})}function ce({value:n,onChange:i}){const r=t.useMantineTheme(),a=d.default.useMemo(()=>Object.entries(r.colors).map(([s,l])=>({label:s,value:l[6]})),[r]),o=d.default.useMemo(()=>a.some(s=>s.value===n),[n,a]);return c(t.Group,{position:"apart",spacing:"xs",children:[e(t.TextInput,{placeholder:"Set any color",value:o?"":n,onChange:s=>i(s.currentTarget.value),rightSection:e(t.ColorSwatch,{color:o?"transparent":n,radius:4}),variant:o?"filled":"default",sx:{maxWidth:"100%",flexGrow:1}}),e(t.Text,{sx:{flexGrow:0},children:"or"}),e(t.Select,{data:a,value:n,onChange:i,variant:o?"default":"filled",placeholder:"Pick a theme color",icon:e(t.ColorSwatch,{color:o?n:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}function st({conf:n,setConf:i}){const u=n,{series:r}=u,a=I(u,["series"]),o=d.default.useMemo(()=>m({series:L.formList(r!=null?r:[])},a),[r,a]),s=L.useForm({initialValues:o}),l=()=>s.addListItem("series",{type:"bar",name:P.randomId(),showSymbol:!1,y_axis_data_key:"value",stack:"",color:"#000"});return d.default.useMemo(()=>!T.default.isEqual(s.values,o),[s.values,o]),e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:s.onSubmit(i),children:[c(t.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[e(t.Text,{children:"Chart Config"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),e(t.TextInput,m({size:"md",mb:"lg",label:"X Axis Data Key"},s.getInputProps("x_axis_data_key"))),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{mt:"xl",mb:0,children:"Series"}),s.values.series.map((f,h)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[e(t.TextInput,m({label:"Label",required:!0,sx:{flex:1}},s.getListInputProps("series",h,"name"))),c(t.Group,{direction:"row",grow:!0,noWrap:!0,children:[e(t.TextInput,m({label:"Y Axis Data key",required:!0},s.getListInputProps("series",h,"y_axis_data_key"))),e(t.TextInput,m({label:"Stack ID",placeholder:"Stack bars by this ID"},s.getListInputProps("series",h,"stack")))]}),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{children:"Color"}),e(ce,m({},s.getListInputProps("series",h,"color")))]}),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>s.removeListItem("series",h),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},h)),e(t.Group,{position:"center",mt:"xs",children:e(t.Button,{onClick:l,children:"Add a Series"})})]})]})})}function ut({conf:{label_field:n,value_field:i},setConf:r}){const a=L.useForm({initialValues:{label_field:n,value_field:i}});return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:a.onSubmit(r),children:[c(t.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[e(t.Text,{children:"Sunburst Config"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),c(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[e(t.TextInput,m({label:"Label Field",required:!0,sx:{flex:1}},a.getInputProps("label_field"))),e(t.TextInput,m({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},a.getInputProps("value_field")))]})]})})}const dt=Object.values(E).map(n=>({label:n,value:n}));function ct({label:n,value:i,onChange:r,sx:a}){return e(t.Select,{label:n,data:dt,value:i,onChange:r,sx:a})}function pt(a){var o=a,{conf:s}=o,l=s,{columns:n}=l,i=I(l,["columns"]),{setConf:r}=o;const u=L.useForm({initialValues:m({id_field:"id",use_raw_columns:!0,columns:L.formList(n!=null?n:[]),size:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},i)}),f=()=>u.addListItem("columns",{label:P.randomId(),value_field:"value",value_type:E.string});return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:u.onSubmit(r),children:[c(t.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[e(t.Text,{children:"Table Config"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),c(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[e(t.TextInput,m({size:"md",mb:"lg",label:"ID Field"},u.getInputProps("id_field"))),c(t.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[e(t.TextInput,m({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("horizontalSpacing"))),e(t.TextInput,m({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("verticalSpacing")))]}),e(t.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:e(t.TextInput,m({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("size")))}),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{children:"Other"}),c(t.Group,{position:"apart",grow:!0,children:[e(t.Switch,m({label:"Striped"},u.getInputProps("striped",{type:"checkbox"}))),e(t.Switch,m({label:"Highlight on hover"},u.getInputProps("highlightOnHover",{type:"checkbox"})))]})]})]}),c(t.Group,{direction:"column",mt:"xs",spacing:"xs",grow:!0,p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[e(t.Switch,m({label:"Use Original Data Columns"},u.getInputProps("use_raw_columns",{type:"checkbox"}))),!u.values.use_raw_columns&&c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{mt:"xl",mb:0,children:"Custom Columns"}),u.values.columns.map((h,b)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[c(t.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[e(t.TextInput,m({label:"Label",required:!0,sx:{flex:1}},u.getListInputProps("columns",b,"label"))),e(t.TextInput,m({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},u.getListInputProps("columns",b,"value_field"))),e(ct,m({label:"Value Type",sx:{flex:1}},u.getListInputProps("columns",b,"value_type")))]}),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>u.removeListItem("columns",b),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},b)),e(t.Group,{position:"center",mt:"xs",children:e(t.Button,{onClick:f,children:"Add a Column"})})]})]}),e(t.Text,{weight:500,mb:"md",children:"Current Configuration:"}),e(M.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(u.values,null,2)})]})})}const U=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function mt({label:n,value:i,onChange:r}){var s,l;const[a,o]=d.default.useState((l=(s=U.find(u=>u.label===i))==null?void 0:s.value)!=null?l:U[0].value);return d.default.useEffect(()=>{const u=U.find(f=>f.value===a);u&&r(u.label)},[a]),c(t.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[e(t.Text,{children:n}),e(t.Slider,{label:null,marks:U,value:a,onChange:o,step:25,placeholder:"Pick a font size"})]})}const pe=[{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 ht({conf:n,setConf:i}){var o;const r=L.useForm({initialValues:{paragraphs:L.formList((o=n.paragraphs)!=null?o:pe)}}),a=()=>r.addListItem("paragraphs",k(m({},pe[0]),{template:P.randomId()}));return e(t.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:c("form",{onSubmit:r.onSubmit(i),children:[r.values.paragraphs.length===0&&e(t.Text,{color:"dimmed",align:"center",children:"Empty"}),c(t.Group,{position:"apart",mb:"xs",sx:{" + .mantine-Group-root":{marginTop:0}},children:[e(t.Text,{children:"Paragraphs"}),e(t.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:e(y.DeviceFloppy,{size:20})})]}),r.values.paragraphs.map((s,l)=>c(t.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[e(t.TextInput,m({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},r.getListInputProps("paragraphs",l,"template"))),c(t.Group,{direction:"column",grow:!0,children:[e(t.Text,{children:"Color"}),e(ce,m({},r.getListInputProps("paragraphs",l,"color")))]}),e(t.Group,{direction:"column",grow:!0,children:e(t.TextInput,m({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},r.getListInputProps("paragraphs",l,"size")))}),e(t.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:e(mt,m({label:"Font Weight"},r.getListInputProps("paragraphs",l,"weight")))}),e(t.ActionIcon,{color:"red",variant:"hover",onClick:()=>r.removeListItem("paragraphs",l),sx:{position:"absolute",top:15,right:5},children:e(y.Trash,{size:16})})]},l)),e(t.Group,{position:"center",mt:"md",children:e(t.Button,{onClick:a,children:"Add a Paragraph"})}),e(t.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),e(M.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(r.values,null,2)})]})})}const te=[{value:"text",label:"Text",Panel:ht},{value:"table",label:"Table",Panel:pt},{value:"sunburst",label:"Sunburst",Panel:ut},{value:"bar-3d",label:"Bar Chart (3D)",Panel:lt},{value:"line-bar",label:"Line-Bar Chart",Panel:st}];function ft(){const{viz:n,setViz:i}=d.default.useContext(D),[r,a]=P.useInputState(n.type),o=n.type!==r,s=d.default.useCallback(()=>{!o||i(h=>k(m({},h),{type:r}))},[o,r]),l=h=>{i(b=>k(m({},b),{conf:h}))},u=h=>{try{l(JSON.parse(h))}catch(b){console.error(b)}},f=d.default.useMemo(()=>{var h;return(h=te.find(b=>b.value===r))==null?void 0:h.Panel},[r,te]);return c(se,{children:[e(t.Select,{label:"Visualization",value:r,onChange:a,data:te,rightSection:e(t.ActionIcon,{disabled:!o,onClick:s,children:e(y.DeviceFloppy,{size:20})})}),f&&e(f,{conf:n.conf,setConf:l}),!f&&e(t.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(n.conf,null,2),onChange:u})]})}function xt({}){return c(t.Group,{grow:!0,direction:"column",children:[e(ot,{}),e(at,{}),e(t.Divider,{}),e(ft,{})]})}function gt({opened:n,close:i}){const{freezeLayout:r}=d.default.useContext(R),{data:a,loading:o,viz:s,title:l}=d.default.useContext(D);return d.default.useEffect(()=>{r(n)},[n]),e(t.Modal,{size:"96vw",overflow:"inside",opened:n,onClose:i,title:l,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:e(t.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%"}},padding:"md",navbar:e(t.Navbar,{width:{base:"40%"},height:"100%",p:"xs",children:c(t.Tabs,{initialTab:1,children:[e(t.Tabs.Tab,{label:"Context",children:e(He,{})}),e(t.Tabs.Tab,{label:"SQL Snippets",children:e(rt,{})}),e(t.Tabs.Tab,{label:"SQL",children:e(et,{})}),c(t.Tabs.Tab,{label:"Data",children:[e(t.LoadingOverlay,{visible:o}),e(tt,{})]}),e(t.Tabs.Tab,{label:"Viz Config",children:e(xt,{})})]})}),children:e(ue,{children:e(de,{viz:s,data:a,loading:o})})})})}function bt({}){const[n,i]=d.default.useState(!1),r=()=>i(!0),a=()=>i(!1),{title:o,description:s,loading:l,refreshData:u}=d.default.useContext(D),{inEditMode:f}=d.default.useContext(R);return c(t.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[e(t.Group,{children:s&&e(t.Tooltip,{label:s,withArrow:!0,children:e(y.InfoCircle,{size:12,style:{verticalAlign:"baseline",cursor:"pointer"}})})}),e(t.Group,{grow:!0,position:"center",children:e(t.Text,{lineClamp:1,weight:"bold",children:o})}),e(t.Group,{position:"right",spacing:0,sx:{height:"28px"},children:c(t.Menu,{children:[e(t.Menu.Item,{onClick:u,icon:e(y.Refresh,{size:14}),children:"Refresh"}),f&&e(t.Menu.Item,{onClick:r,icon:e(y.Settings,{size:14}),children:"Settings"}),e(t.Divider,{}),e(t.Menu.Item,{color:"red",disabled:!0,icon:e(y.Trash,{size:14}),children:"Delete"})]})}),f&&e(gt,{opened:n,close:a})]})}var Dt="";function me({viz:n,sql:i,title:r,description:a,update:o,layout:s,id:l}){const u=d.default.useContext(ee),f=d.default.useContext(J),[h,b]=d.default.useState(r),[x,g]=d.default.useState(a),[v,z]=d.default.useState(i),[_,O]=d.default.useState(n);d.default.useEffect(()=>{o({id:l,layout:s,title:h,description:x,sql:v,viz:_})},[h,x,v,_,l,s]);const{data:N=[],loading:F,refresh:V}=ve.useRequest(Le(v,u,f,h),{refreshDeps:[u,f]}),ne=V;return e(D.Provider,{value:{data:N,loading:F,title:h,setTitle:b,description:x,setDescription:g,sql:v,setSQL:z,viz:_,setViz:O,refreshData:ne},children:c(t.Container,{className:"panel-root",children:[e(bt,{}),e(ue,{children:e(de,{viz:_,data:N,loading:F})})]})})}var Gt="";const vt=w.WidthProvider(w.Responsive);function he({panels:n,setPanels:i,className:r="layout",cols:a={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:o=10,onRemoveItem:s,isDraggable:l,isResizable:u,setLocalCols:f,setBreakpoint:h}){const b=(g,v)=>{h(g),f(v)},x=d.default.useCallback(g=>{const v=new Map;g.forEach(N=>{var F=N,{i:_}=F,O=I(F,["i"]);v.set(_,O)});const z=n.map(_=>k(m({},_),{layout:v.get(_.id)}));i.setState(z)},[n,i]);return e(vt,{onBreakpointChange:b,onLayoutChange:x,className:r,cols:a,rowHeight:o,isDraggable:l,isResizable:u,children:n.map((_,z)=>{var O=_,{id:g}=O,v=I(O,["id"]);return e("div",{"data-grid":v.layout,children:e(me,k(m({id:g},v),{destroy:()=>s(g),update:N=>{i.setItem(z,N)}}))},g)})})}function fe(n,i){return c(t.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[n," ",i]})}function yt({mode:n,setMode:i}){return e(t.SegmentedControl,{value:n,onChange:i,data:[{label:fe(e(y.PlayerPlay,{size:20}),"Use"),value:q.Use},{label:fe(e(y.Paint,{size:20}),"Edit"),value:q.Edit}]})}function St({mode:n,setMode:i,hasChanges:r,addPanel:a,saveChanges:o}){const s=n===q.Edit;return c(t.Group,{position:"apart",pt:"sm",pb:"xs",children:[e(t.Group,{position:"left",children:e(yt,{mode:n,setMode:i})}),s&&c(t.Group,{position:"right",children:[e(t.Button,{variant:"default",size:"sm",onClick:a,leftIcon:e(y.PlaylistAdd,{size:20}),children:"Add a Panel"}),e(t.Button,{variant:"default",size:"sm",onClick:o,disabled:!r,leftIcon:e(y.DeviceFloppy,{size:20}),children:"Save Changes"}),e(t.Button,{color:"red",size:"sm",disabled:!r,leftIcon:e(y.Recycle,{size:20}),children:"Revert Changes"})]}),!s&&e(t.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:e(y.Share,{size:20}),children:"Share"})]})}function Ct({dashboard:n,update:i,className:r="dashboard"}){const[a,o]=d.default.useState(!1),[s,l]=d.default.useState(),[u,f]=d.default.useState(),[h,b]=P.useListState(n.panels),[x,g]=d.default.useState(n.definition.sqlSnippets),[v,z]=d.default.useState(q.Edit),_=d.default.useMemo(()=>{const G=ie=>JSON.parse(JSON.stringify(ie));return T.default.isEqual(G(h),G(n.panels))?!T.default.isEqual(x,n.definition.sqlSnippets):!0},[n,h,x]),O=async()=>{const G=T.default.merge({},n,{panels:h},{definition:{sqlSnippets:x}});await i(G)},N=()=>{const G=P.randomId(),Y={id:G,layout:{x:0,y:1/0,w:3,h:4},title:`New Panel - ${G}`,description:"description goes here",sql:"",viz:{type:"table",conf:{}}};b.append(Y)},F=G=>{const Y=h.findIndex(ie=>ie.id===G);b.remove(Y)},V=v===q.Edit,ne=d.default.useMemo(()=>({sqlSnippets:x,setSQLSnippets:g}),[x,g]);return e("div",{className:r,children:e(J.Provider,{value:ne,children:c(R.Provider,{value:{layoutFrozen:a,freezeLayout:o,mode:v,inEditMode:V},children:[e(St,{mode:v,setMode:z,hasChanges:_,addPanel:N,saveChanges:O}),e(he,{panels:h,setPanels:b,isDraggable:V&&!a,isResizable:V&&!a,onRemoveItem:F,setLocalCols:f,setBreakpoint:l})]})})})}p.ContextInfoContext=ee,p.Dashboard=Ct,p.DashboardLayout=he,p.DashboardMode=q,p.DefinitionContext=J,p.LayoutStateContext=R,p.Panel=me,p.PanelContext=D,p.initialContextInfoContext=De,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
  import { IDashboardPanel } from "../types/dashboard";
3
+ import { UseListStateHandlers } from "@mantine/hooks";
3
4
  interface IDashboardLayout {
4
5
  panels: IDashboardPanel[];
6
+ setPanels: UseListStateHandlers<IDashboardPanel>;
5
7
  className?: string;
6
8
  cols?: {
7
9
  lg: number;
@@ -17,5 +19,5 @@ interface IDashboardLayout {
17
19
  setLocalCols: React.Dispatch<React.SetStateAction<any>>;
18
20
  setBreakpoint: React.Dispatch<React.SetStateAction<any>>;
19
21
  }
20
- export declare function DashboardLayout({ panels, className, cols, rowHeight, onRemoveItem, isDraggable, isResizable, setLocalCols, setBreakpoint, }: IDashboardLayout): JSX.Element;
22
+ export declare function DashboardLayout({ panels, setPanels, className, cols, rowHeight, onRemoveItem, isDraggable, isResizable, setLocalCols, setBreakpoint, }: IDashboardLayout): JSX.Element;
21
23
  export {};
@@ -3,7 +3,9 @@ import { DashboardMode } from "../types";
3
3
  interface IDashboardActions {
4
4
  mode: DashboardMode;
5
5
  setMode: React.Dispatch<React.SetStateAction<DashboardMode>>;
6
+ hasChanges: boolean;
6
7
  addPanel: () => void;
8
+ saveChanges: () => void;
7
9
  }
8
- export declare function DashboardActions({ mode, setMode, addPanel, }: IDashboardActions): JSX.Element;
10
+ export declare function DashboardActions({ mode, setMode, hasChanges, addPanel, saveChanges, }: IDashboardActions): JSX.Element;
9
11
  export {};
@@ -3,6 +3,7 @@ import { IDashboard } from "../types/dashboard";
3
3
  interface IDashboardProps {
4
4
  dashboard: IDashboard;
5
5
  className?: string;
6
+ update: (dashboard: IDashboard) => Promise<void>;
6
7
  }
7
- export declare function Dashboard({ dashboard, className, }: IDashboardProps): JSX.Element;
8
+ export declare function Dashboard({ dashboard, update, className, }: IDashboardProps): JSX.Element;
8
9
  export {};
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ export declare class ErrorBoundary extends React.Component {
3
+ constructor(props: any);
4
+ static getDerivedStateFromError(): {
5
+ hasError: boolean;
6
+ };
7
+ render(): any;
8
+ }
@@ -1,12 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { IVizConfig } from '../types/dashboard';
3
- interface IPanel {
4
- layout: any;
2
+ import { IDashboardPanel } from '../types/dashboard';
3
+ interface IPanel extends IDashboardPanel {
5
4
  destroy: () => void;
6
- sql: string;
7
- viz: IVizConfig;
8
- title: string;
9
- description: string;
5
+ update: (panel: IDashboardPanel) => void;
10
6
  }
11
- export declare function Panel({ viz: initialViz, sql: initialSQL, title: initialTitle, description: initialDesc }: IPanel): JSX.Element;
7
+ export declare function Panel({ viz: initialViz, sql: initialSQL, title: initialTitle, description: initialDesc, update, layout, id, }: IPanel): JSX.Element;
12
8
  export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface IMantineFontWeightSlider {
3
+ label: string;
4
+ value: string;
5
+ onChange: (value: string) => void;
6
+ }
7
+ export declare function MantineFontWeightSlider({ label, value, onChange }: IMantineFontWeightSlider): JSX.Element;
8
+ export {};
@@ -1,5 +1,7 @@
1
1
  /// <reference types="react" />
2
- interface IPanelSettings {
2
+ interface IPanelSettingsModal {
3
+ opened: boolean;
4
+ close: () => void;
3
5
  }
4
- export declare function PanelSettings({}: IPanelSettings): JSX.Element;
6
+ export declare function PanelSettingsModal({ opened, close }: IPanelSettingsModal): JSX.Element;
5
7
  export {};
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { IVizPanelProps } from "../../../types/viz-panel";
3
- export declare function SunburstPanel({ conf: { columns, ...restConf }, setConf }: IVizPanelProps): JSX.Element;
3
+ export declare function SunburstPanel({ conf: { label_field, value_field }, setConf }: IVizPanelProps): JSX.Element;
@@ -11,6 +11,8 @@ export interface IDashboardPanel {
11
11
  y: number;
12
12
  w: number;
13
13
  h: number;
14
+ moved?: boolean;
15
+ static?: boolean;
14
16
  };
15
17
  sql: string;
16
18
  viz: IVizConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "0.1.0",
3
+ "version": "0.3.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- interface IMantineSizeSlider {
3
- label: string;
4
- value: string;
5
- onChange: (value: string) => void;
6
- }
7
- export declare function MantineSizeSlider({ label, value, onChange }: IMantineSizeSlider): JSX.Element;
8
- export {};
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- interface IMantineFontSizeSlider {
3
- label: string;
4
- value: string;
5
- onChange: (value: string) => void;
6
- }
7
- export declare function MantineFontSizeSlider({ label, value, onChange }: IMantineFontSizeSlider): JSX.Element;
8
- export {};