@devtable/dashboard 1.18.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/api-caller/index.d.ts +3 -3
  2. package/dist/contexts/definition-context.d.ts +2 -2
  3. package/dist/contexts/panel-context.d.ts +2 -2
  4. package/dist/dashboard.es.js +273 -147
  5. package/dist/dashboard.umd.js +8 -8
  6. package/dist/definition-editor/{data-source-editor → query-editor}/context-and-snippets.d.ts +0 -0
  7. package/dist/definition-editor/{data-source-editor → query-editor}/data-preview.d.ts +0 -0
  8. package/dist/definition-editor/query-editor/editor.d.ts +7 -0
  9. package/dist/definition-editor/query-editor/form.d.ts +8 -0
  10. package/dist/definition-editor/query-editor/index.d.ts +5 -0
  11. package/dist/definition-editor/{data-source-editor → query-editor}/preview-sql.d.ts +0 -0
  12. package/dist/definition-editor/query-editor/select-or-add-query.d.ts +7 -0
  13. package/dist/panel/index.d.ts +1 -1
  14. package/dist/panel/settings/pick-query/index.d.ts +5 -0
  15. package/dist/panel/viz/cartesian/panel/series/fields.bar.d.ts +9 -0
  16. package/dist/panel/viz/cartesian/panel/series/fields.line.d.ts +9 -0
  17. package/dist/panel/viz/cartesian/panel/series/fields.scatter.d.ts +9 -0
  18. package/dist/panel/viz/cartesian/panel/{series.d.ts → series/index.d.ts} +1 -1
  19. package/dist/panel/viz/cartesian/panel/series/series-item.d.ts +16 -0
  20. package/dist/panel/viz/cartesian/type.d.ts +4 -1
  21. package/dist/style.css +1 -1
  22. package/dist/types/dashboard.d.ts +3 -3
  23. package/package.json +1 -1
  24. package/dist/definition-editor/data-source-editor/editor.d.ts +0 -7
  25. package/dist/definition-editor/data-source-editor/form.d.ts +0 -8
  26. package/dist/definition-editor/data-source-editor/index.d.ts +0 -5
  27. package/dist/definition-editor/data-source-editor/select-or-add-data-source.d.ts +0 -7
  28. package/dist/panel/settings/pick-data-source/index.d.ts +0 -5
  29. package/dist/panel/viz/bar-3d/type.d.ts +0 -4
@@ -36,7 +36,7 @@ var __publicField = (obj, key, value) => {
36
36
  import React from "react";
37
37
  import _ from "lodash";
38
38
  import RGL, { WidthProvider } from "react-grid-layout";
39
- import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, SegmentedControl, NumberInput, Switch, Slider, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
39
+ import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, Switch, Slider, SegmentedControl, NumberInput, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
40
40
  import { useRequest } from "ahooks";
41
41
  import axios from "axios";
42
42
  import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Resize, Paint, PlayerPlay, Database, Recycle, Share } from "tabler-icons-react";
@@ -44,7 +44,7 @@ import RichTextEditor, { RichTextEditor as RichTextEditor$1 } from "@mantine/rte
44
44
  import { useInputState, useElementSize, randomId } from "@mantine/hooks";
45
45
  import ReactEChartsCore from "echarts-for-react/lib/core";
46
46
  import * as echarts from "echarts/core";
47
- import { SunburstChart, BarChart, LineChart, PieChart } from "echarts/charts";
47
+ import { SunburstChart, BarChart, LineChart, ScatterChart, PieChart } from "echarts/charts";
48
48
  import { CanvasRenderer } from "echarts/renderers";
49
49
  import { GridComponent, LegendComponent, TooltipComponent, VisualMapComponent } from "echarts/components";
50
50
  import numbro from "numbro";
@@ -132,11 +132,11 @@ const APIClient = {
132
132
  };
133
133
  }
134
134
  };
135
- const queryBySQL = ({ context, definitions, title, dataSource }) => async () => {
136
- if (!dataSource || !dataSource.sql) {
135
+ const queryBySQL = ({ context, definitions, title, query }) => async () => {
136
+ if (!query || !query.sql) {
137
137
  return [];
138
138
  }
139
- const { type, key, sql } = dataSource;
139
+ const { type, key, sql } = query;
140
140
  const needParams = sql.includes("$");
141
141
  try {
142
142
  const params = getSQLParams(context, definitions);
@@ -174,8 +174,8 @@ const initialContext$1 = {
174
174
  description: "",
175
175
  setDescription: () => {
176
176
  },
177
- dataSourceID: "",
178
- setDataSourceID: () => {
177
+ queryID: "",
178
+ setQueryID: () => {
179
179
  },
180
180
  viz: {
181
181
  type: "",
@@ -191,8 +191,8 @@ const initialContext = {
191
191
  sqlSnippets: [],
192
192
  setSQLSnippets: () => {
193
193
  },
194
- dataSources: [],
195
- setDataSources: () => {
194
+ queries: [],
195
+ setQueries: () => {
196
196
  }
197
197
  };
198
198
  const DefinitionContext = React.createContext(initialContext);
@@ -230,8 +230,8 @@ const jsx = jsxRuntime.exports.jsx;
230
230
  const jsxs = jsxRuntime.exports.jsxs;
231
231
  const Fragment = jsxRuntime.exports.Fragment;
232
232
  function DescriptionPopover({
233
- position,
234
- trigger = "click"
233
+ position = "bottom",
234
+ trigger = "hover"
235
235
  }) {
236
236
  const {
237
237
  freezeLayout
@@ -269,13 +269,14 @@ function DescriptionPopover({
269
269
  return /* @__PURE__ */ jsx(Popover, {
270
270
  opened,
271
271
  onClose: () => setOpened(false),
272
- withCloseButton: true,
272
+ withCloseButton: trigger === "click",
273
273
  withArrow: true,
274
274
  trapFocus: true,
275
275
  closeOnEscape: false,
276
276
  placement: "center",
277
277
  position,
278
278
  target,
279
+ width: "40vw",
279
280
  children: /* @__PURE__ */ jsx(RichTextEditor, {
280
281
  readOnly: true,
281
282
  value: description,
@@ -380,7 +381,7 @@ function PreviewPanel() {
380
381
  mx: "auto",
381
382
  mt: "xl",
382
383
  p: "5px",
383
- spacing: "xs",
384
+ spacing: 5,
384
385
  sx: {
385
386
  width: "600px",
386
387
  height: "450px",
@@ -392,8 +393,6 @@ function PreviewPanel() {
392
393
  position: "apart",
393
394
  noWrap: true,
394
395
  sx: {
395
- borderBottom: "1px solid #eee",
396
- paddingBottom: "5px",
397
396
  flexGrow: 0,
398
397
  flexShrink: 0
399
398
  },
@@ -492,9 +491,9 @@ function DataPreview({
492
491
  }) {
493
492
  const definitions = React.useContext(DefinitionContext);
494
493
  const contextInfo = React.useContext(ContextInfoContext);
495
- const dataSource = React.useMemo(() => {
496
- return definitions.dataSources.find((d) => d.id === id);
497
- }, [definitions.dataSources, id]);
494
+ const query = React.useMemo(() => {
495
+ return definitions.queries.find((d) => d.id === id);
496
+ }, [definitions.queries, id]);
498
497
  const {
499
498
  data = [],
500
499
  loading,
@@ -503,9 +502,9 @@ function DataPreview({
503
502
  context: contextInfo,
504
503
  definitions,
505
504
  title: id,
506
- dataSource
505
+ query
507
506
  }), {
508
- refreshDeps: [contextInfo, definitions, dataSource]
507
+ refreshDeps: [contextInfo, definitions, query]
509
508
  });
510
509
  if (loading) {
511
510
  return /* @__PURE__ */ jsx(LoadingOverlay, {
@@ -581,22 +580,22 @@ function DataPreview({
581
580
  })]
582
581
  });
583
582
  }
584
- function PickDataSource({}) {
583
+ function PickQuery({}) {
585
584
  const {
586
- dataSources
585
+ queries
587
586
  } = React.useContext(DefinitionContext);
588
587
  const {
589
- dataSourceID,
590
- setDataSourceID,
588
+ queryID,
589
+ setQueryID,
591
590
  data,
592
591
  loading
593
592
  } = React.useContext(PanelContext);
594
593
  const options = React.useMemo(() => {
595
- return dataSources.map((d) => ({
594
+ return queries.map((d) => ({
596
595
  value: d.id,
597
596
  label: d.id
598
597
  }));
599
- }, [dataSources]);
598
+ }, [queries]);
600
599
  return /* @__PURE__ */ jsxs(Group, {
601
600
  direction: "column",
602
601
  grow: true,
@@ -608,11 +607,11 @@ function PickDataSource({}) {
608
607
  alignItems: "baseline"
609
608
  },
610
609
  children: [/* @__PURE__ */ jsx(Text, {
611
- children: "Select a Data Source"
610
+ children: "Select a Query"
612
611
  }), /* @__PURE__ */ jsx(Select, {
613
612
  data: options,
614
- value: dataSourceID,
615
- onChange: setDataSourceID,
613
+ value: queryID,
614
+ onChange: setQueryID,
616
615
  allowDeselect: false,
617
616
  clearable: false,
618
617
  sx: {
@@ -620,7 +619,7 @@ function PickDataSource({}) {
620
619
  }
621
620
  })]
622
621
  }), /* @__PURE__ */ jsx(DataPreview, {
623
- id: dataSourceID
622
+ id: queryID
624
623
  })]
625
624
  });
626
625
  }
@@ -689,7 +688,7 @@ function Sunbrust({
689
688
  }
690
689
  });
691
690
  }
692
- echarts.use([BarChart, LineChart, GridComponent, LegendComponent, TooltipComponent, CanvasRenderer]);
691
+ echarts.use([BarChart, LineChart, ScatterChart, GridComponent, LegendComponent, TooltipComponent, CanvasRenderer]);
693
692
  const defaultOption$1 = {
694
693
  legend: {
695
694
  show: true,
@@ -1914,6 +1913,139 @@ function _MantineColorSelector({
1914
1913
  });
1915
1914
  }
1916
1915
  const MantineColorSelector = React.forwardRef(_MantineColorSelector);
1916
+ function BarFields({
1917
+ control,
1918
+ index: index2
1919
+ }) {
1920
+ return /* @__PURE__ */ jsxs(Group, {
1921
+ direction: "row",
1922
+ grow: true,
1923
+ align: "top",
1924
+ children: [/* @__PURE__ */ jsx(Controller, {
1925
+ name: `series.${index2}.stack`,
1926
+ control,
1927
+ render: ({
1928
+ field
1929
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
1930
+ label: "Stack",
1931
+ placeholder: "Stack bars by this ID",
1932
+ sx: {
1933
+ flexGrow: 1
1934
+ }
1935
+ }, field))
1936
+ }), /* @__PURE__ */ jsx(Controller, {
1937
+ name: `series.${index2}.barWidth`,
1938
+ control,
1939
+ render: ({
1940
+ field
1941
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
1942
+ label: "Bar Width",
1943
+ sx: {
1944
+ flexGrow: 1
1945
+ }
1946
+ }, field))
1947
+ })]
1948
+ });
1949
+ }
1950
+ const stepOptions = [{
1951
+ label: "off",
1952
+ value: "false"
1953
+ }, {
1954
+ label: "start",
1955
+ value: "start"
1956
+ }, {
1957
+ label: "middle",
1958
+ value: "middle"
1959
+ }, {
1960
+ label: "end",
1961
+ value: "end"
1962
+ }];
1963
+ function LineFields({
1964
+ control,
1965
+ index: index2
1966
+ }) {
1967
+ return /* @__PURE__ */ jsxs(Group, {
1968
+ direction: "row",
1969
+ grow: true,
1970
+ align: "center",
1971
+ children: [/* @__PURE__ */ jsx(Controller, {
1972
+ name: `series.${index2}.step`,
1973
+ control,
1974
+ render: ({
1975
+ field
1976
+ }) => /* @__PURE__ */ jsx(Select, __spreadProps(__spreadValues({
1977
+ label: "Step",
1978
+ data: stepOptions,
1979
+ sx: {
1980
+ flexGrow: 1,
1981
+ maxWidth: "48%"
1982
+ }
1983
+ }, field), {
1984
+ value: String(field.value),
1985
+ onChange: (v) => {
1986
+ const step = v === "false" ? false : v;
1987
+ field.onChange(step);
1988
+ }
1989
+ }))
1990
+ }), /* @__PURE__ */ jsx(Controller, {
1991
+ name: `series.${index2}.smooth`,
1992
+ control,
1993
+ render: ({
1994
+ field
1995
+ }) => /* @__PURE__ */ jsx(Box, {
1996
+ sx: {
1997
+ flexGrow: 1
1998
+ },
1999
+ children: /* @__PURE__ */ jsx(Switch, {
2000
+ label: "Smooth Line",
2001
+ checked: field.value,
2002
+ onChange: (event) => field.onChange(event.currentTarget.checked)
2003
+ })
2004
+ })
2005
+ })]
2006
+ });
2007
+ }
2008
+ const symbolSizeOptions = Array.from(new Array(9), (_2, i) => ({
2009
+ label: String(i + 1),
2010
+ value: i + 1
2011
+ }));
2012
+ function ScatterFields({
2013
+ control,
2014
+ index: index2
2015
+ }) {
2016
+ return /* @__PURE__ */ jsx(Group, {
2017
+ direction: "row",
2018
+ grow: true,
2019
+ align: "center",
2020
+ children: /* @__PURE__ */ jsx(Controller, {
2021
+ name: `series.${index2}.symbolSize`,
2022
+ control,
2023
+ render: ({
2024
+ field
2025
+ }) => /* @__PURE__ */ jsxs(Group, {
2026
+ direction: "column",
2027
+ noWrap: true,
2028
+ sx: {
2029
+ flexGrow: 1
2030
+ },
2031
+ pb: 16,
2032
+ spacing: 4,
2033
+ children: [/* @__PURE__ */ jsx(Text, {
2034
+ size: "sm",
2035
+ children: "Size"
2036
+ }), /* @__PURE__ */ jsx(Slider, __spreadProps(__spreadValues({
2037
+ min: 1,
2038
+ max: 10,
2039
+ marks: symbolSizeOptions
2040
+ }, field), {
2041
+ sx: {
2042
+ width: "100%"
2043
+ }
2044
+ }))]
2045
+ })
2046
+ })
2047
+ });
2048
+ }
1917
2049
  const labelPositions = [{
1918
2050
  label: "off",
1919
2051
  value: ""
@@ -1994,8 +2126,7 @@ function SeriesItemField({
1994
2126
  value: "bar"
1995
2127
  }, {
1996
2128
  label: "Scatter",
1997
- value: "scatter",
1998
- disabled: true
2129
+ value: "scatter"
1999
2130
  }, {
2000
2131
  label: "Boxplot",
2001
2132
  value: "boxplot",
@@ -2065,34 +2196,15 @@ function SeriesItemField({
2065
2196
  }));
2066
2197
  }
2067
2198
  })]
2068
- }), type === "bar" && /* @__PURE__ */ jsxs(Group, {
2069
- direction: "row",
2070
- grow: true,
2071
- align: "top",
2072
- children: [/* @__PURE__ */ jsx(Controller, {
2073
- name: `series.${index2}.stack`,
2074
- control,
2075
- render: ({
2076
- field
2077
- }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
2078
- label: "Stack",
2079
- placeholder: "Stack bars by this ID",
2080
- sx: {
2081
- flexGrow: 1
2082
- }
2083
- }, field))
2084
- }), /* @__PURE__ */ jsx(Controller, {
2085
- name: `series.${index2}.barWidth`,
2086
- control,
2087
- render: ({
2088
- field
2089
- }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
2090
- label: "Bar Width",
2091
- sx: {
2092
- flexGrow: 1
2093
- }
2094
- }, field))
2095
- })]
2199
+ }), type === "line" && /* @__PURE__ */ jsx(LineFields, {
2200
+ index: index2,
2201
+ control
2202
+ }), type === "bar" && /* @__PURE__ */ jsx(BarFields, {
2203
+ index: index2,
2204
+ control
2205
+ }), type === "scatter" && /* @__PURE__ */ jsx(ScatterFields, {
2206
+ index: index2,
2207
+ control
2096
2208
  }), /* @__PURE__ */ jsx(Controller, {
2097
2209
  name: `series.${index2}.label_position`,
2098
2210
  control,
@@ -2145,7 +2257,7 @@ function SeriesField({
2145
2257
  control,
2146
2258
  name: "series"
2147
2259
  });
2148
- const watchFieldArray = watch("y_axes");
2260
+ const watchFieldArray = watch("series");
2149
2261
  const controlledFields = fields.map((field, index2) => {
2150
2262
  return __spreadValues(__spreadValues({}, field), watchFieldArray[index2]);
2151
2263
  });
@@ -2153,11 +2265,14 @@ function SeriesField({
2153
2265
  type: "bar",
2154
2266
  name: randomId(),
2155
2267
  showSymbol: false,
2268
+ symbolSize: 5,
2156
2269
  y_axis_data_key: "value",
2157
2270
  yAxisIndex: 0,
2158
2271
  label_position: "top",
2159
2272
  stack: "",
2160
- color: "#000"
2273
+ color: "#000",
2274
+ step: false,
2275
+ smooth: false
2161
2276
  });
2162
2277
  const yAxisOptions = React.useMemo(() => {
2163
2278
  return getValues().y_axes.map(({
@@ -2358,23 +2473,29 @@ function withDefaults(series) {
2358
2473
  type,
2359
2474
  name,
2360
2475
  showSymbol,
2476
+ symbolSize = 5,
2361
2477
  y_axis_data_key = "value",
2362
2478
  yAxisIndex = 0,
2363
2479
  label_position = "top",
2364
2480
  stack = "1",
2365
2481
  color: color2 = "black",
2366
- barWidth = "30"
2482
+ barWidth = "30",
2483
+ smooth = false,
2484
+ step = false
2367
2485
  }) {
2368
2486
  return {
2369
2487
  type,
2370
2488
  name,
2371
2489
  showSymbol,
2490
+ symbolSize,
2372
2491
  y_axis_data_key,
2373
2492
  yAxisIndex,
2374
2493
  label_position,
2375
2494
  stack,
2376
2495
  color: color2,
2377
- barWidth
2496
+ barWidth,
2497
+ smooth,
2498
+ step
2378
2499
  };
2379
2500
  }
2380
2501
  return series.map(setDefaults);
@@ -2416,13 +2537,14 @@ function VizCartesianChartPanel({
2416
2537
  control,
2417
2538
  handleSubmit,
2418
2539
  watch,
2419
- formState: {
2420
- isDirty
2421
- },
2422
2540
  getValues
2423
2541
  } = useForm({
2424
2542
  defaultValues
2425
2543
  });
2544
+ const values = getValues();
2545
+ const changed = React.useMemo(() => {
2546
+ return !_.isEqual(values, conf);
2547
+ }, [values, conf]);
2426
2548
  return /* @__PURE__ */ jsx(Group, {
2427
2549
  direction: "column",
2428
2550
  mt: "md",
@@ -2443,7 +2565,7 @@ function VizCartesianChartPanel({
2443
2565
  mr: 5,
2444
2566
  variant: "filled",
2445
2567
  color: "blue",
2446
- disabled: !isDirty,
2568
+ disabled: !changed,
2447
2569
  children: /* @__PURE__ */ jsx(DeviceFloppy, {
2448
2570
  size: 20
2449
2571
  })
@@ -3547,11 +3669,11 @@ function PanelSettingsModal({
3547
3669
  children: /* @__PURE__ */ jsxs(Tabs, {
3548
3670
  initialTab: 2,
3549
3671
  children: [/* @__PURE__ */ jsxs(Tabs.Tab, {
3550
- label: "Data Source",
3672
+ label: "Data",
3551
3673
  children: [/* @__PURE__ */ jsx(LoadingOverlay, {
3552
3674
  visible: loading,
3553
3675
  exitTransitionDuration: 0
3554
- }), /* @__PURE__ */ jsx(PickDataSource, {})]
3676
+ }), /* @__PURE__ */ jsx(PickQuery, {})]
3555
3677
  }), /* @__PURE__ */ jsx(Tabs.Tab, {
3556
3678
  label: "Panel",
3557
3679
  children: /* @__PURE__ */ jsx(PanelConfig, {})
@@ -3563,6 +3685,7 @@ function PanelSettingsModal({
3563
3685
  })
3564
3686
  });
3565
3687
  }
3688
+ var titleBar = "";
3566
3689
  function PanelTitleBar({}) {
3567
3690
  const [opened, setOpened] = React.useState(false);
3568
3691
  const open = () => setOpened(true);
@@ -3574,30 +3697,33 @@ function PanelTitleBar({}) {
3574
3697
  const {
3575
3698
  inEditMode
3576
3699
  } = React.useContext(LayoutStateContext);
3577
- return /* @__PURE__ */ jsxs(Group, {
3578
- position: "apart",
3579
- noWrap: true,
3700
+ return /* @__PURE__ */ jsxs(Box, {
3580
3701
  sx: {
3581
- borderBottom: "1px solid #eee",
3582
- paddingBottom: "5px"
3702
+ position: "relative"
3583
3703
  },
3584
- children: [/* @__PURE__ */ jsx(Group, {
3704
+ children: [/* @__PURE__ */ jsx(Box, {
3705
+ sx: {
3706
+ position: "absolute",
3707
+ left: 0,
3708
+ top: 0,
3709
+ height: 28
3710
+ },
3585
3711
  children: /* @__PURE__ */ jsx(DescriptionPopover, {})
3586
3712
  }), /* @__PURE__ */ jsx(Group, {
3587
3713
  grow: true,
3588
3714
  position: "center",
3589
- children: /* @__PURE__ */ jsx(Text, {
3590
- lineClamp: 1,
3591
- weight: "bold",
3592
- children: title
3593
- })
3594
- }), /* @__PURE__ */ jsx(Group, {
3595
- position: "right",
3596
- spacing: 0,
3715
+ px: 20,
3716
+ className: "panel-title-wrapper",
3597
3717
  sx: {
3598
- height: "28px"
3718
+ flexGrow: 1
3599
3719
  },
3600
3720
  children: /* @__PURE__ */ jsxs(Menu, {
3721
+ control: /* @__PURE__ */ jsx(Text, {
3722
+ lineClamp: 1,
3723
+ weight: "bold",
3724
+ children: title
3725
+ }),
3726
+ placement: "center",
3601
3727
  children: [/* @__PURE__ */ jsx(Menu.Item, {
3602
3728
  onClick: refreshData,
3603
3729
  icon: /* @__PURE__ */ jsx(Refresh, {
@@ -3628,7 +3754,7 @@ function PanelTitleBar({}) {
3628
3754
  var index$1 = "";
3629
3755
  function Panel({
3630
3756
  viz: initialViz,
3631
- dataSourceID: initialDataSourceID,
3757
+ queryID: initialQueryID,
3632
3758
  title: initialTitle,
3633
3759
  description: initialDesc,
3634
3760
  update,
@@ -3639,24 +3765,24 @@ function Panel({
3639
3765
  const definitions = React.useContext(DefinitionContext);
3640
3766
  const [title, setTitle] = React.useState(initialTitle);
3641
3767
  const [description, setDescription] = React.useState(initialDesc);
3642
- const [dataSourceID, setDataSourceID] = React.useState(initialDataSourceID);
3768
+ const [queryID, setQueryID] = React.useState(initialQueryID);
3643
3769
  const [viz, setViz] = React.useState(initialViz);
3644
- const dataSource = React.useMemo(() => {
3645
- if (!dataSourceID) {
3770
+ const query = React.useMemo(() => {
3771
+ if (!queryID) {
3646
3772
  return void 0;
3647
3773
  }
3648
- return definitions.dataSources.find((d) => d.id === dataSourceID);
3649
- }, [dataSourceID, definitions.dataSources]);
3774
+ return definitions.queries.find((d) => d.id === queryID);
3775
+ }, [queryID, definitions.queries]);
3650
3776
  React.useEffect(() => {
3651
3777
  update == null ? void 0 : update({
3652
3778
  id,
3653
3779
  layout,
3654
3780
  title,
3655
3781
  description,
3656
- dataSourceID,
3782
+ queryID,
3657
3783
  viz
3658
3784
  });
3659
- }, [title, description, dataSource, viz, id, layout, dataSourceID]);
3785
+ }, [title, description, query, viz, id, layout, queryID]);
3660
3786
  const {
3661
3787
  data = [],
3662
3788
  loading,
@@ -3665,9 +3791,9 @@ function Panel({
3665
3791
  context: contextInfo,
3666
3792
  definitions,
3667
3793
  title,
3668
- dataSource
3794
+ query
3669
3795
  }), {
3670
- refreshDeps: [contextInfo, definitions, dataSource]
3796
+ refreshDeps: [contextInfo, definitions, query]
3671
3797
  });
3672
3798
  const refreshData = refresh;
3673
3799
  return /* @__PURE__ */ jsx(PanelContext.Provider, {
@@ -3678,8 +3804,8 @@ function Panel({
3678
3804
  setTitle,
3679
3805
  description,
3680
3806
  setDescription,
3681
- dataSourceID,
3682
- setDataSourceID,
3807
+ queryID,
3808
+ setQueryID,
3683
3809
  viz,
3684
3810
  setViz,
3685
3811
  refreshData
@@ -3893,7 +4019,7 @@ function PreviewSQL({
3893
4019
  children: explained
3894
4020
  });
3895
4021
  }
3896
- function DataSourceForm({
4022
+ function QueryForm({
3897
4023
  value,
3898
4024
  onChange
3899
4025
  }) {
@@ -3950,7 +4076,7 @@ function DataSourceForm({
3950
4076
  },
3951
4077
  children: [/* @__PURE__ */ jsx(Text, {
3952
4078
  weight: 500,
3953
- children: "Data Source Configuration"
4079
+ children: "Edit Query"
3954
4080
  }), /* @__PURE__ */ jsx(ActionIcon, {
3955
4081
  type: "submit",
3956
4082
  mr: 5,
@@ -4013,81 +4139,81 @@ function DataSourceForm({
4013
4139
  })
4014
4140
  });
4015
4141
  }
4016
- function DataSourceEditor({
4142
+ function QueryEditor({
4017
4143
  id,
4018
4144
  setID
4019
4145
  }) {
4020
4146
  const {
4021
- dataSources,
4022
- setDataSources
4147
+ queries,
4148
+ setQueries
4023
4149
  } = React.useContext(DefinitionContext);
4024
- const dataSource = React.useMemo(() => {
4025
- return dataSources.find((d) => d.id === id);
4026
- }, [dataSources, id]);
4150
+ const query = React.useMemo(() => {
4151
+ return queries.find((d) => d.id === id);
4152
+ }, [queries, id]);
4027
4153
  const update = React.useCallback((value) => {
4028
- const index2 = dataSources.findIndex((d) => d.id === id);
4154
+ const index2 = queries.findIndex((d) => d.id === id);
4029
4155
  if (index2 === -1) {
4030
4156
  console.error(new Error("Invalid data source id when updating by id"));
4031
4157
  return;
4032
4158
  }
4033
- setDataSources((prevs) => {
4159
+ setQueries((prevs) => {
4034
4160
  const index22 = prevs.findIndex((p2) => p2.id === id);
4035
4161
  prevs.splice(index22, 1, value);
4036
4162
  return [...prevs];
4037
4163
  });
4038
4164
  setID(value.id);
4039
- }, [id, dataSources, setDataSources, setID]);
4165
+ }, [id, queries, setQueries, setID]);
4040
4166
  if (!id) {
4041
4167
  return null;
4042
4168
  }
4043
- if (!dataSource) {
4169
+ if (!query) {
4044
4170
  return /* @__PURE__ */ jsx("span", {
4045
4171
  children: "Invalid Data Source ID"
4046
4172
  });
4047
4173
  }
4048
- return /* @__PURE__ */ jsx(DataSourceForm, {
4049
- value: dataSource,
4174
+ return /* @__PURE__ */ jsx(QueryForm, {
4175
+ value: query,
4050
4176
  onChange: update
4051
4177
  });
4052
4178
  }
4053
- function SelectOrAddDataSource({
4179
+ function SelectOrAddQuery({
4054
4180
  id,
4055
4181
  setID
4056
4182
  }) {
4057
4183
  const {
4058
- dataSources,
4059
- setDataSources
4184
+ queries,
4185
+ setQueries
4060
4186
  } = React.useContext(DefinitionContext);
4061
4187
  const chooseDefault = React.useCallback(() => {
4062
4188
  var _a, _b;
4063
- setID((_b = (_a = dataSources[0]) == null ? void 0 : _a.id) != null ? _b : "");
4064
- }, [setID, dataSources]);
4189
+ setID((_b = (_a = queries[0]) == null ? void 0 : _a.id) != null ? _b : "");
4190
+ }, [setID, queries]);
4065
4191
  React.useEffect(() => {
4066
4192
  if (!id) {
4067
4193
  chooseDefault();
4068
4194
  return;
4069
4195
  }
4070
- const index2 = dataSources.findIndex((d) => d.id === id);
4196
+ const index2 = queries.findIndex((d) => d.id === id);
4071
4197
  if (index2 === -1) {
4072
4198
  chooseDefault();
4073
4199
  }
4074
- }, [id, dataSources, chooseDefault]);
4200
+ }, [id, queries, chooseDefault]);
4075
4201
  const options = React.useMemo(() => {
4076
- return dataSources.map((d) => ({
4202
+ return queries.map((d) => ({
4077
4203
  value: d.id,
4078
4204
  label: d.id
4079
4205
  }));
4080
- }, [dataSources]);
4206
+ }, [queries]);
4081
4207
  const add = React.useCallback(() => {
4082
- const newDataSource = {
4208
+ const newQuery = {
4083
4209
  id: randomId(),
4084
4210
  type: "postgresql",
4085
4211
  key: "",
4086
4212
  sql: ""
4087
4213
  };
4088
- setDataSources((prevs) => [...prevs, newDataSource]);
4089
- setID(newDataSource.id);
4090
- }, [setDataSources, setID]);
4214
+ setQueries((prevs) => [...prevs, newQuery]);
4215
+ setID(newQuery.id);
4216
+ }, [setQueries, setID]);
4091
4217
  return /* @__PURE__ */ jsx(Group, {
4092
4218
  pb: "xl",
4093
4219
  children: /* @__PURE__ */ jsxs(Group, {
@@ -4097,7 +4223,7 @@ function SelectOrAddDataSource({
4097
4223
  alignItems: "baseline"
4098
4224
  },
4099
4225
  children: [/* @__PURE__ */ jsx(Text, {
4100
- children: "Select a Data Source"
4226
+ children: "Select a Query"
4101
4227
  }), /* @__PURE__ */ jsx(Select, {
4102
4228
  data: options,
4103
4229
  value: id,
@@ -4114,13 +4240,13 @@ function SelectOrAddDataSource({
4114
4240
  mt: "md",
4115
4241
  children: /* @__PURE__ */ jsx(Button, {
4116
4242
  onClick: add,
4117
- children: "Add a Data Source"
4243
+ children: "Add a Query"
4118
4244
  })
4119
4245
  })]
4120
4246
  })
4121
4247
  });
4122
4248
  }
4123
- function EditDataSources({}) {
4249
+ function EditQueries({}) {
4124
4250
  const [id, setID] = React.useState("");
4125
4251
  return /* @__PURE__ */ jsxs(AppShell, {
4126
4252
  sx: {
@@ -4150,10 +4276,10 @@ function EditDataSources({}) {
4150
4276
  flexGrow: 1,
4151
4277
  maxWidth: "calc(60% - 16px)"
4152
4278
  },
4153
- children: [/* @__PURE__ */ jsx(SelectOrAddDataSource, {
4279
+ children: [/* @__PURE__ */ jsx(SelectOrAddQuery, {
4154
4280
  id,
4155
4281
  setID
4156
- }), /* @__PURE__ */ jsx(DataSourceEditor, {
4282
+ }), /* @__PURE__ */ jsx(QueryEditor, {
4157
4283
  id,
4158
4284
  setID
4159
4285
  })]
@@ -4471,8 +4597,8 @@ function DataEditorModal({
4471
4597
  label: "SQL Snippet",
4472
4598
  children: /* @__PURE__ */ jsx(EditSQLSnippets, {})
4473
4599
  }), /* @__PURE__ */ jsx(Tabs.Tab, {
4474
- label: "Data Source",
4475
- children: /* @__PURE__ */ jsx(EditDataSources, {})
4600
+ label: "Queries",
4601
+ children: /* @__PURE__ */ jsx(EditQueries, {})
4476
4602
  })]
4477
4603
  })
4478
4604
  });
@@ -4490,8 +4616,8 @@ function DashboardActions({
4490
4616
  inUseMode
4491
4617
  } = React.useContext(LayoutStateContext);
4492
4618
  const [dataEditorOpened, setDataEditorOpened] = React.useState(false);
4493
- const openDataSources = () => setDataEditorOpened(true);
4494
- const closeDataSources = () => setDataEditorOpened(false);
4619
+ const openQueries = () => setDataEditorOpened(true);
4620
+ const closeQueries = () => setDataEditorOpened(false);
4495
4621
  return /* @__PURE__ */ jsxs(Group, {
4496
4622
  position: "apart",
4497
4623
  pt: "sm",
@@ -4515,7 +4641,7 @@ function DashboardActions({
4515
4641
  }), inEditMode && /* @__PURE__ */ jsx(Button, {
4516
4642
  variant: "default",
4517
4643
  size: "sm",
4518
- onClick: openDataSources,
4644
+ onClick: openQueries,
4519
4645
  leftIcon: /* @__PURE__ */ jsx(Database, {
4520
4646
  size: 20
4521
4647
  }),
@@ -4540,7 +4666,7 @@ function DashboardActions({
4540
4666
  })]
4541
4667
  }), /* @__PURE__ */ jsx(DataEditorModal, {
4542
4668
  opened: dataEditorOpened,
4543
- close: closeDataSources
4669
+ close: closeQueries
4544
4670
  }), inUseMode && /* @__PURE__ */ jsx(Button, {
4545
4671
  variant: "default",
4546
4672
  size: "sm",
@@ -4565,7 +4691,7 @@ function Dashboard({
4565
4691
  const [layoutFrozen, freezeLayout] = React.useState(false);
4566
4692
  const [panels, setPanels] = React.useState(dashboard.panels);
4567
4693
  const [sqlSnippets, setSQLSnippets] = React.useState(dashboard.definition.sqlSnippets);
4568
- const [dataSources, setDataSources] = React.useState(dashboard.definition.dataSources);
4694
+ const [queries, setQueries] = React.useState(dashboard.definition.queries);
4569
4695
  const [mode, setMode] = React.useState(DashboardMode.Edit);
4570
4696
  const hasChanges = React.useMemo(() => {
4571
4697
  const cleanJSON = (v) => JSON.parse(JSON.stringify(v));
@@ -4576,14 +4702,14 @@ function Dashboard({
4576
4702
  if (!_.isEqual(sqlSnippets, dashboard.definition.sqlSnippets)) {
4577
4703
  return true;
4578
4704
  }
4579
- return !_.isEqual(dataSources, dashboard.definition.dataSources);
4580
- }, [dashboard, panels, sqlSnippets, dataSources]);
4705
+ return !_.isEqual(queries, dashboard.definition.queries);
4706
+ }, [dashboard, panels, sqlSnippets, queries]);
4581
4707
  const saveDashboardChanges = async () => {
4582
4708
  const d = __spreadProps(__spreadValues({}, dashboard), {
4583
4709
  panels,
4584
4710
  definition: {
4585
4711
  sqlSnippets,
4586
- dataSources
4712
+ queries
4587
4713
  }
4588
4714
  });
4589
4715
  await update(d);
@@ -4598,9 +4724,9 @@ function Dashboard({
4598
4724
  w: 3,
4599
4725
  h: 15
4600
4726
  },
4601
- title: `New Panel - ${id}`,
4602
- description: "",
4603
- dataSourceID: "",
4727
+ title: `Panel - ${id}`,
4728
+ description: "<p><br></p>",
4729
+ queryID: "",
4604
4730
  viz: {
4605
4731
  type: "text",
4606
4732
  conf: {}
@@ -4621,9 +4747,9 @@ function Dashboard({
4621
4747
  const definitions = React.useMemo(() => ({
4622
4748
  sqlSnippets,
4623
4749
  setSQLSnippets,
4624
- dataSources,
4625
- setDataSources
4626
- }), [sqlSnippets, setSQLSnippets, dataSources, setDataSources]);
4750
+ queries,
4751
+ setQueries
4752
+ }), [sqlSnippets, setSQLSnippets, queries, setQueries]);
4627
4753
  return /* @__PURE__ */ jsx(ContextInfoContext.Provider, {
4628
4754
  value: context,
4629
4755
  children: /* @__PURE__ */ jsx("div", {
@@ -4695,7 +4821,7 @@ function ReadOnlyDashboard({
4695
4821
  const definition = React.useMemo(() => __spreadProps(__spreadValues({}, dashboard.definition), {
4696
4822
  setSQLSnippets: () => {
4697
4823
  },
4698
- setDataSources: () => {
4824
+ setQueries: () => {
4699
4825
  }
4700
4826
  }), [dashboard]);
4701
4827
  return /* @__PURE__ */ jsx(ContextInfoContext.Provider, {