@devtable/dashboard 1.9.0 → 1.12.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.
@@ -36,7 +36,7 @@ var __publicField = (obj, key, value) => {
36
36
  import React from "react";
37
37
  import _ from "lodash";
38
38
  import { WidthProvider, Responsive } from "react-grid-layout";
39
- import { Popover, Tooltip, Group, Text, ActionIcon, TextInput, Box, LoadingOverlay, Table, Select, Button, useMantineTheme, ColorSwatch, JsonInput, Anchor, Slider, ColorInput, Accordion, Switch, Modal, AppShell, Tabs, Menu, Divider, Container, SegmentedControl, Textarea } from "@mantine/core";
39
+ import { Popover, Tooltip, Group, Text, ActionIcon, TextInput, Box, LoadingOverlay, Table, Select, Button, useMantineTheme, ColorSwatch, SegmentedControl, NumberInput, Switch, Slider, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
40
40
  import { useRequest } from "ahooks";
41
41
  import axios from "axios";
42
42
  import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Resize, Paint, PlayerPlay, ClipboardText, Database, Recycle, Share } from "tabler-icons-react";
@@ -49,8 +49,8 @@ import { CanvasRenderer } from "echarts/renderers";
49
49
  import { GridComponent, LegendComponent, TooltipComponent, VisualMapComponent } from "echarts/components";
50
50
  import numbro from "numbro";
51
51
  import "echarts-gl";
52
- import { useForm, Controller } from "react-hook-form";
53
- import { formList, useForm as useForm$1 } from "@mantine/form";
52
+ import { useForm, Controller, useFieldArray } from "react-hook-form";
53
+ import { useForm as useForm$1, formList } from "@mantine/form";
54
54
  import { Prism } from "@mantine/prism";
55
55
  var DashboardMode = /* @__PURE__ */ ((DashboardMode2) => {
56
56
  DashboardMode2["Use"] = "use";
@@ -668,12 +668,6 @@ const defaultOption$1 = {
668
668
  fontWeight: "bold"
669
669
  }
670
670
  },
671
- yAxis: {
672
- nameTextStyle: {
673
- fontWeight: "bolder",
674
- align: "left"
675
- }
676
- },
677
671
  grid: {
678
672
  top: 30,
679
673
  left: 15,
@@ -682,56 +676,64 @@ const defaultOption$1 = {
682
676
  containLabel: true
683
677
  }
684
678
  };
685
- function VizLineBarChart({
679
+ function VizCartesianChart({
686
680
  conf,
687
681
  data,
688
682
  width,
689
683
  height
690
684
  }) {
691
685
  const option = React.useMemo(() => {
692
- var _c, _d;
693
- const valueFormatters = conf.series.reduce((ret, {
694
- name,
695
- y_axis_data_formatter
696
- }) => {
697
- ret[name] = function formatter({
698
- value
699
- }) {
700
- if (!y_axis_data_formatter) {
686
+ var _c;
687
+ const labelFormatters = conf.y_axes.reduce((ret, {
688
+ label_formatter
689
+ }, index2) => {
690
+ ret[index2] = function formatter(payload) {
691
+ const value = typeof payload === "object" ? payload.value : payload;
692
+ if (!label_formatter) {
701
693
  return value;
702
694
  }
703
695
  try {
704
- return numbro(value).format(JSON.parse(y_axis_data_formatter));
696
+ return numbro(value).format(label_formatter);
705
697
  } catch (error) {
706
698
  console.error(error);
707
699
  return value;
708
700
  }
709
701
  };
710
702
  return ret;
703
+ }, {
704
+ default: ({
705
+ value
706
+ }) => value
707
+ });
708
+ const yAxisIndexMap = conf.series.reduce((ret, {
709
+ yAxisIndex,
710
+ name
711
+ }) => {
712
+ ret[name] = yAxisIndex;
713
+ return ret;
711
714
  }, {});
712
715
  const series = conf.series.map((_a) => {
713
716
  var _b = _a, {
714
717
  y_axis_data_key,
715
- y_axis_data_formatter,
716
- name,
717
- label_position = "top"
718
+ yAxisIndex,
719
+ label_position,
720
+ name
718
721
  } = _b, rest = __objRest(_b, [
719
722
  "y_axis_data_key",
720
- "y_axis_data_formatter",
721
- "name",
722
- "label_position"
723
+ "yAxisIndex",
724
+ "label_position",
725
+ "name"
723
726
  ]);
724
727
  const ret = __spreadValues({
725
728
  data: data.map((d) => d[y_axis_data_key]),
726
729
  label: {
727
- show: true,
728
- position: label_position
730
+ show: !!label_position,
731
+ position: label_position,
732
+ formatter: labelFormatters[yAxisIndex != null ? yAxisIndex : "default"]
729
733
  },
730
- name
734
+ name,
735
+ yAxisIndex
731
736
  }, rest);
732
- if (y_axis_data_formatter) {
733
- ret.label.formatter = valueFormatters[name];
734
- }
735
737
  return ret;
736
738
  });
737
739
  const customOptions = {
@@ -739,9 +741,20 @@ function VizLineBarChart({
739
741
  data: data.map((d) => d[conf.x_axis_data_key]),
740
742
  name: (_c = conf.x_axis_name) != null ? _c : ""
741
743
  },
742
- yAxis: {
743
- name: (_d = conf.y_axis_name) != null ? _d : ""
744
- },
744
+ yAxis: conf.y_axes.map((_d, index2) => {
745
+ var _e = _d, {
746
+ label_formatter
747
+ } = _e, rest = __objRest(_e, [
748
+ "label_formatter"
749
+ ]);
750
+ var _a;
751
+ return __spreadProps(__spreadValues({}, rest), {
752
+ axisLabel: {
753
+ show: true,
754
+ formatter: (_a = labelFormatters[index2]) != null ? _a : labelFormatters.default
755
+ }
756
+ });
757
+ }),
745
758
  dataset: {
746
759
  source: data
747
760
  },
@@ -756,10 +769,13 @@ function VizLineBarChart({
756
769
  seriesName,
757
770
  value
758
771
  }) => {
772
+ var _a;
759
773
  if (!seriesName) {
760
774
  return value;
761
775
  }
762
- return `${seriesName}: ${valueFormatters[seriesName]({
776
+ const yAxisIndex = yAxisIndexMap[seriesName];
777
+ const formatter = (_a = labelFormatters[yAxisIndex]) != null ? _a : labelFormatters.default;
778
+ return `${seriesName}: ${formatter({
763
779
  value
764
780
  })}`;
765
781
  });
@@ -1542,7 +1558,8 @@ function renderViz(width, height, data, viz) {
1542
1558
  case "sunburst":
1543
1559
  return /* @__PURE__ */ jsx(Sunbrust, __spreadValues({}, props));
1544
1560
  case "line-bar":
1545
- return /* @__PURE__ */ jsx(VizLineBarChart, __spreadValues({}, props));
1561
+ case "cartesian":
1562
+ return /* @__PURE__ */ jsx(VizCartesianChart, __spreadValues({}, props));
1546
1563
  case "table":
1547
1564
  return /* @__PURE__ */ jsx(VizTable, __spreadValues({}, props));
1548
1565
  case "text":
@@ -1818,11 +1835,10 @@ function MantineColorSelector({
1818
1835
  })]
1819
1836
  });
1820
1837
  }
1821
- const numbroFormatExample = JSON.stringify({
1822
- output: "percent",
1823
- mantissa: 2
1824
- }, null, 2);
1825
1838
  const labelPositions = [{
1839
+ label: "off",
1840
+ value: ""
1841
+ }, {
1826
1842
  label: "top",
1827
1843
  value: "top"
1828
1844
  }, {
@@ -1862,74 +1878,472 @@ const labelPositions = [{
1862
1878
  label: "insideBottomRight",
1863
1879
  value: "insideBottomRight"
1864
1880
  }];
1881
+ function SeriesItemField({
1882
+ control,
1883
+ index: index2,
1884
+ remove,
1885
+ seriesItem,
1886
+ yAxisOptions
1887
+ }) {
1888
+ const type = seriesItem.type;
1889
+ return /* @__PURE__ */ jsxs(Group, {
1890
+ direction: "column",
1891
+ grow: true,
1892
+ my: 0,
1893
+ p: "md",
1894
+ pr: 40,
1895
+ sx: {
1896
+ border: "1px solid #eee",
1897
+ position: "relative"
1898
+ },
1899
+ children: [/* @__PURE__ */ jsx(Group, {
1900
+ direction: "column",
1901
+ grow: true,
1902
+ noWrap: true,
1903
+ children: /* @__PURE__ */ jsx(Controller, {
1904
+ name: `series.${index2}.type`,
1905
+ control,
1906
+ render: ({
1907
+ field
1908
+ }) => /* @__PURE__ */ jsx(SegmentedControl, __spreadValues({
1909
+ data: [{
1910
+ label: "Line",
1911
+ value: "line"
1912
+ }, {
1913
+ label: "Bar",
1914
+ value: "bar"
1915
+ }, {
1916
+ label: "Scatter",
1917
+ value: "scatter",
1918
+ disabled: true
1919
+ }, {
1920
+ label: "Boxplot",
1921
+ value: "boxplot",
1922
+ disabled: true
1923
+ }]
1924
+ }, field))
1925
+ })
1926
+ }), /* @__PURE__ */ jsx(Controller, {
1927
+ name: `series.${index2}.name`,
1928
+ control,
1929
+ render: ({
1930
+ field
1931
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
1932
+ label: "Name",
1933
+ required: true,
1934
+ sx: {
1935
+ flex: 1
1936
+ }
1937
+ }, field))
1938
+ }), /* @__PURE__ */ jsxs(Group, {
1939
+ direction: "row",
1940
+ grow: true,
1941
+ noWrap: true,
1942
+ children: [/* @__PURE__ */ jsx(Controller, {
1943
+ name: `series.${index2}.y_axis_data_key`,
1944
+ control,
1945
+ render: ({
1946
+ field
1947
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
1948
+ label: "Value key",
1949
+ required: true,
1950
+ sx: {
1951
+ flex: 1
1952
+ }
1953
+ }, field))
1954
+ }), /* @__PURE__ */ jsx(Controller, {
1955
+ name: `series.${index2}.yAxisIndex`,
1956
+ control,
1957
+ render: (_a) => {
1958
+ var {
1959
+ field: _b
1960
+ } = _a, _c = _b, {
1961
+ value,
1962
+ onChange
1963
+ } = _c, rest = __objRest(_c, [
1964
+ "value",
1965
+ "onChange"
1966
+ ]);
1967
+ var _a2;
1968
+ return /* @__PURE__ */ jsx(Select, __spreadProps(__spreadValues({
1969
+ label: "Y Axis",
1970
+ data: yAxisOptions,
1971
+ disabled: yAxisOptions.length === 0
1972
+ }, rest), {
1973
+ value: (_a2 = value == null ? void 0 : value.toString()) != null ? _a2 : "",
1974
+ onChange: (value2) => {
1975
+ if (!value2) {
1976
+ onChange(0);
1977
+ return;
1978
+ }
1979
+ onChange(Number(value2));
1980
+ },
1981
+ sx: {
1982
+ flex: 1
1983
+ }
1984
+ }));
1985
+ }
1986
+ })]
1987
+ }), type === "bar" && /* @__PURE__ */ jsxs(Group, {
1988
+ direction: "row",
1989
+ grow: true,
1990
+ align: "top",
1991
+ children: [/* @__PURE__ */ jsx(Controller, {
1992
+ name: `series.${index2}.stack`,
1993
+ control,
1994
+ render: ({
1995
+ field
1996
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
1997
+ label: "Stack",
1998
+ placeholder: "Stack bars by this ID",
1999
+ sx: {
2000
+ flexGrow: 1
2001
+ }
2002
+ }, field))
2003
+ }), /* @__PURE__ */ jsx(Controller, {
2004
+ name: `series.${index2}.barWidth`,
2005
+ control,
2006
+ render: ({
2007
+ field
2008
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
2009
+ label: "Bar Width",
2010
+ sx: {
2011
+ flexGrow: 1
2012
+ }
2013
+ }, field))
2014
+ })]
2015
+ }), /* @__PURE__ */ jsx(Controller, {
2016
+ name: `series.${index2}.label_position`,
2017
+ control,
2018
+ render: ({
2019
+ field
2020
+ }) => /* @__PURE__ */ jsx(Select, __spreadValues({
2021
+ label: "Label Position",
2022
+ data: labelPositions
2023
+ }, field))
2024
+ }), /* @__PURE__ */ jsxs(Group, {
2025
+ direction: "column",
2026
+ grow: true,
2027
+ spacing: 4,
2028
+ children: [/* @__PURE__ */ jsx(Text, {
2029
+ size: "sm",
2030
+ children: "Color"
2031
+ }), /* @__PURE__ */ jsx(Controller, {
2032
+ name: `series.${index2}.color`,
2033
+ control,
2034
+ render: ({
2035
+ field
2036
+ }) => /* @__PURE__ */ jsx(MantineColorSelector, __spreadValues({}, field))
2037
+ })]
2038
+ }), /* @__PURE__ */ jsx(ActionIcon, {
2039
+ color: "red",
2040
+ variant: "hover",
2041
+ onClick: () => remove(index2),
2042
+ sx: {
2043
+ position: "absolute",
2044
+ top: 15,
2045
+ right: 5
2046
+ },
2047
+ children: /* @__PURE__ */ jsx(Trash, {
2048
+ size: 16
2049
+ })
2050
+ })]
2051
+ }, index2);
2052
+ }
2053
+ function SeriesField({
2054
+ control,
2055
+ watch,
2056
+ getValues
2057
+ }) {
2058
+ const {
2059
+ fields,
2060
+ append,
2061
+ remove
2062
+ } = useFieldArray({
2063
+ control,
2064
+ name: "series"
2065
+ });
2066
+ const watchFieldArray = watch("y_axes");
2067
+ const controlledFields = fields.map((field, index2) => {
2068
+ return __spreadValues(__spreadValues({}, field), watchFieldArray[index2]);
2069
+ });
2070
+ const addSeries = () => append({
2071
+ type: "bar",
2072
+ name: randomId(),
2073
+ showSymbol: false,
2074
+ y_axis_data_key: "value",
2075
+ yAxisIndex: 0,
2076
+ label_position: "top",
2077
+ stack: "",
2078
+ color: "#000"
2079
+ });
2080
+ const yAxisOptions = React.useMemo(() => {
2081
+ return getValues().y_axes.map(({
2082
+ name
2083
+ }, index2) => ({
2084
+ label: name,
2085
+ value: index2.toString()
2086
+ }));
2087
+ }, [getValues]);
2088
+ return /* @__PURE__ */ jsxs(Group, {
2089
+ direction: "column",
2090
+ grow: true,
2091
+ children: [/* @__PURE__ */ jsx(Text, {
2092
+ mt: "xl",
2093
+ mb: 0,
2094
+ children: "Series"
2095
+ }), controlledFields.map((seriesItem, index2) => /* @__PURE__ */ jsx(SeriesItemField, {
2096
+ control,
2097
+ index: index2,
2098
+ remove,
2099
+ seriesItem,
2100
+ yAxisOptions
2101
+ })), /* @__PURE__ */ jsx(Group, {
2102
+ position: "center",
2103
+ mt: "xs",
2104
+ children: /* @__PURE__ */ jsx(Button, {
2105
+ onClick: addSeries,
2106
+ children: "Add a Series"
2107
+ })
2108
+ })]
2109
+ });
2110
+ }
2111
+ const defaultNumbroFormat = {
2112
+ mantissa: 0,
2113
+ output: "number"
2114
+ };
2115
+ function NumbroFormatSelector({
2116
+ value,
2117
+ onChange
2118
+ }) {
2119
+ const changeOutput = (output) => {
2120
+ onChange(__spreadProps(__spreadValues({}, value), {
2121
+ output
2122
+ }));
2123
+ };
2124
+ const changeMantissa = (mantissa) => {
2125
+ const trimMantissa = mantissa === 0 ? false : value.trimMantissa;
2126
+ onChange(__spreadProps(__spreadValues({}, value), {
2127
+ mantissa,
2128
+ trimMantissa
2129
+ }));
2130
+ };
2131
+ const changeTrimMantissa = (event) => {
2132
+ onChange(__spreadProps(__spreadValues({}, value), {
2133
+ trimMantissa: event.currentTarget.checked
2134
+ }));
2135
+ };
2136
+ return /* @__PURE__ */ jsx(Group, {
2137
+ direction: "column",
2138
+ grow: true,
2139
+ noWrap: true,
2140
+ children: /* @__PURE__ */ jsxs(Group, {
2141
+ direction: "row",
2142
+ grow: true,
2143
+ children: [/* @__PURE__ */ jsx(Select, {
2144
+ label: "Format",
2145
+ data: [{
2146
+ label: "1234",
2147
+ value: "number"
2148
+ }, {
2149
+ label: "99%",
2150
+ value: "percent"
2151
+ }],
2152
+ value: value.output,
2153
+ onChange: changeOutput
2154
+ }), /* @__PURE__ */ jsx(NumberInput, {
2155
+ label: "Mantissa",
2156
+ defaultValue: 0,
2157
+ min: 0,
2158
+ step: 1,
2159
+ max: 4,
2160
+ value: value.mantissa,
2161
+ onChange: changeMantissa
2162
+ }), /* @__PURE__ */ jsx(Switch, {
2163
+ label: "Trim mantissa",
2164
+ checked: value.trimMantissa,
2165
+ onChange: changeTrimMantissa,
2166
+ disabled: value.mantissa === 0
2167
+ })]
2168
+ })
2169
+ });
2170
+ }
2171
+ function YAxisField({
2172
+ control,
2173
+ index: index2,
2174
+ remove
2175
+ }) {
2176
+ return /* @__PURE__ */ jsxs(Group, {
2177
+ direction: "column",
2178
+ grow: true,
2179
+ my: 0,
2180
+ p: "md",
2181
+ pr: 40,
2182
+ sx: {
2183
+ border: "1px solid #eee",
2184
+ position: "relative"
2185
+ },
2186
+ children: [/* @__PURE__ */ jsx(Group, {
2187
+ direction: "row",
2188
+ grow: true,
2189
+ noWrap: true,
2190
+ children: /* @__PURE__ */ jsx(Controller, {
2191
+ name: `y_axes.${index2}.name`,
2192
+ control,
2193
+ render: ({
2194
+ field
2195
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
2196
+ label: "Name",
2197
+ required: true,
2198
+ sx: {
2199
+ flex: 1
2200
+ }
2201
+ }, field))
2202
+ })
2203
+ }), /* @__PURE__ */ jsx(Group, {
2204
+ direction: "column",
2205
+ grow: true,
2206
+ noWrap: true,
2207
+ children: /* @__PURE__ */ jsx(Controller, {
2208
+ name: `y_axes.${index2}.label_formatter`,
2209
+ control,
2210
+ render: ({
2211
+ field
2212
+ }) => /* @__PURE__ */ jsx(NumbroFormatSelector, __spreadValues({}, field))
2213
+ })
2214
+ }), /* @__PURE__ */ jsx(ActionIcon, {
2215
+ color: "red",
2216
+ variant: "hover",
2217
+ onClick: () => remove(index2),
2218
+ sx: {
2219
+ position: "absolute",
2220
+ top: 15,
2221
+ right: 5
2222
+ },
2223
+ disabled: index2 === 0,
2224
+ children: /* @__PURE__ */ jsx(Trash, {
2225
+ size: 16
2226
+ })
2227
+ })]
2228
+ }, index2);
2229
+ }
2230
+ function YAxesField({
2231
+ control,
2232
+ watch
2233
+ }) {
2234
+ const {
2235
+ fields,
2236
+ append,
2237
+ remove
2238
+ } = useFieldArray({
2239
+ control,
2240
+ name: "y_axes"
2241
+ });
2242
+ const watchFieldArray = watch("y_axes");
2243
+ const controlledFields = fields.map((field, index2) => {
2244
+ return __spreadValues(__spreadValues({}, field), watchFieldArray[index2]);
2245
+ });
2246
+ const addYAxis = () => append({
2247
+ name: "",
2248
+ label_formatter: defaultNumbroFormat
2249
+ });
2250
+ return /* @__PURE__ */ jsxs(Group, {
2251
+ direction: "column",
2252
+ grow: true,
2253
+ children: [/* @__PURE__ */ jsx(Text, {
2254
+ mt: "xl",
2255
+ mb: 0,
2256
+ children: "Y Axes"
2257
+ }), controlledFields.map((field, index2) => /* @__PURE__ */ jsx(YAxisField, {
2258
+ control,
2259
+ index: index2,
2260
+ remove
2261
+ })), /* @__PURE__ */ jsx(Group, {
2262
+ position: "center",
2263
+ mt: "xs",
2264
+ children: /* @__PURE__ */ jsx(Button, {
2265
+ onClick: addYAxis,
2266
+ children: "Add a Y Axis"
2267
+ })
2268
+ })]
2269
+ });
2270
+ }
1865
2271
  function withDefaults(series) {
1866
2272
  function setDefaults({
1867
2273
  type,
1868
2274
  name,
1869
2275
  showSymbol,
1870
2276
  y_axis_data_key = "value",
1871
- y_axis_data_formatter = "",
2277
+ yAxisIndex = 0,
1872
2278
  label_position = "top",
1873
2279
  stack = "1",
1874
- color: color2 = "black"
2280
+ color: color2 = "black",
2281
+ barWidth = "30"
1875
2282
  }) {
1876
2283
  return {
1877
2284
  type,
1878
2285
  name,
1879
2286
  showSymbol,
1880
2287
  y_axis_data_key,
1881
- y_axis_data_formatter,
2288
+ yAxisIndex,
1882
2289
  label_position,
1883
2290
  stack,
1884
- color: color2
2291
+ color: color2,
2292
+ barWidth
1885
2293
  };
1886
2294
  }
1887
2295
  return series.map(setDefaults);
1888
2296
  }
1889
- function VizLineBarChartPanel({
2297
+ function VizCartesianChartPanel({
1890
2298
  conf,
1891
2299
  setConf
1892
2300
  }) {
1893
2301
  const _a = conf, {
1894
- series
2302
+ series,
2303
+ y_axes
1895
2304
  } = _a, restConf = __objRest(_a, [
1896
- "series"
2305
+ "series",
2306
+ "y_axes"
1897
2307
  ]);
1898
- const initialValues = React.useMemo(() => {
2308
+ const defaultValues = React.useMemo(() => {
1899
2309
  const _a2 = restConf, {
1900
- x_axis_name = "",
1901
- y_axis_name = ""
2310
+ x_axis_name = ""
1902
2311
  } = _a2, rest = __objRest(_a2, [
1903
- "x_axis_name",
1904
- "y_axis_name"
2312
+ "x_axis_name"
1905
2313
  ]);
1906
2314
  return __spreadValues({
1907
- series: formList(withDefaults(series != null ? series : [])),
2315
+ series: withDefaults(series != null ? series : []),
1908
2316
  x_axis_name,
1909
- y_axis_name
2317
+ y_axes: y_axes != null ? y_axes : [{
2318
+ name: "Y Axis",
2319
+ label_formatter: defaultNumbroFormat
2320
+ }]
1910
2321
  }, rest);
1911
2322
  }, [series, restConf]);
1912
- const form = useForm$1({
1913
- initialValues
1914
- });
1915
- const addSeries = () => form.addListItem("series", {
1916
- type: "bar",
1917
- name: randomId(),
1918
- showSymbol: false,
1919
- y_axis_data_key: "value",
1920
- y_axis_data_formatter: "",
1921
- label_position: "top",
1922
- stack: "",
1923
- color: "#000"
2323
+ React.useEffect(() => {
2324
+ const configMalformed = !_.isEqual(conf, defaultValues);
2325
+ if (configMalformed) {
2326
+ setConf(defaultValues);
2327
+ }
2328
+ }, [conf, defaultValues]);
2329
+ const {
2330
+ control,
2331
+ handleSubmit,
2332
+ watch,
2333
+ formState: {
2334
+ isDirty
2335
+ },
2336
+ getValues
2337
+ } = useForm({
2338
+ defaultValues
1924
2339
  });
1925
- const changed = React.useMemo(() => !_.isEqual(form.values, initialValues), [form.values, initialValues]);
1926
2340
  return /* @__PURE__ */ jsx(Group, {
1927
2341
  direction: "column",
1928
2342
  mt: "md",
1929
2343
  spacing: "xs",
1930
2344
  grow: true,
1931
2345
  children: /* @__PURE__ */ jsxs("form", {
1932
- onSubmit: form.onSubmit(setConf),
2346
+ onSubmit: handleSubmit(setConf),
1933
2347
  children: [/* @__PURE__ */ jsxs(Group, {
1934
2348
  position: "apart",
1935
2349
  mb: "lg",
@@ -1943,117 +2357,43 @@ function VizLineBarChartPanel({
1943
2357
  mr: 5,
1944
2358
  variant: "filled",
1945
2359
  color: "blue",
1946
- disabled: !changed,
2360
+ disabled: !isDirty,
1947
2361
  children: /* @__PURE__ */ jsx(DeviceFloppy, {
1948
2362
  size: 20
1949
2363
  })
1950
2364
  })]
1951
- }), /* @__PURE__ */ jsx(TextInput, __spreadValues({
1952
- size: "md",
1953
- mb: "lg",
1954
- label: "X Axis Data Key"
1955
- }, form.getInputProps("x_axis_data_key"))), /* @__PURE__ */ jsxs(Group, {
2365
+ }), /* @__PURE__ */ jsx(Controller, {
2366
+ name: "x_axis_data_key",
2367
+ control,
2368
+ render: ({
2369
+ field
2370
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
2371
+ size: "md",
2372
+ mb: "lg",
2373
+ label: "X Axis Data Key"
2374
+ }, field))
2375
+ }), /* @__PURE__ */ jsx(Group, {
1956
2376
  direction: "column",
1957
2377
  grow: true,
1958
2378
  noWrap: true,
1959
2379
  mb: "lg",
1960
- children: [/* @__PURE__ */ jsx(TextInput, __spreadValues({
1961
- size: "md",
1962
- label: "X Axis Name"
1963
- }, form.getInputProps("x_axis_name"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
1964
- size: "md",
1965
- label: "Y Axis Name"
1966
- }, form.getInputProps("y_axis_name")))]
1967
- }), /* @__PURE__ */ jsxs(Group, {
1968
- direction: "column",
1969
- grow: true,
1970
- children: [/* @__PURE__ */ jsx(Text, {
1971
- mt: "xl",
1972
- mb: 0,
1973
- children: "Series"
1974
- }), form.values.series.map((item, index2) => /* @__PURE__ */ jsxs(Group, {
1975
- direction: "column",
1976
- grow: true,
1977
- my: 0,
1978
- p: "md",
1979
- pr: 40,
1980
- sx: {
1981
- border: "1px solid #eee",
1982
- position: "relative"
1983
- },
1984
- children: [/* @__PURE__ */ jsxs(Group, {
1985
- direction: "row",
1986
- grow: true,
1987
- noWrap: true,
1988
- children: [/* @__PURE__ */ jsx(TextInput, __spreadValues({
1989
- label: "Name",
1990
- required: true,
1991
- sx: {
1992
- flex: 1
1993
- }
1994
- }, form.getListInputProps("series", index2, "name"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
1995
- label: "Stack",
1996
- placeholder: "Stack bars by this ID"
1997
- }, form.getListInputProps("series", index2, "stack"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
1998
- label: "Value key",
1999
- required: true
2000
- }, form.getListInputProps("series", index2, "y_axis_data_key")))]
2001
- }), /* @__PURE__ */ jsxs(Group, {
2002
- direction: "row",
2003
- grow: true,
2004
- noWrap: true,
2005
- align: "top",
2006
- children: [/* @__PURE__ */ jsx(Select, __spreadValues({
2007
- label: "Label Position",
2008
- data: labelPositions
2009
- }, form.getListInputProps("series", index2, "label_position"))), /* @__PURE__ */ jsx(JsonInput, __spreadValues({
2010
- sx: {
2011
- label: {
2012
- width: "100%"
2013
- }
2014
- },
2015
- label: /* @__PURE__ */ jsxs(Group, {
2016
- position: "apart",
2017
- children: [/* @__PURE__ */ jsx(Text, {
2018
- children: "Value Formatter"
2019
- }), /* @__PURE__ */ jsx(Anchor, {
2020
- href: "https://numbrojs.com/format.html",
2021
- target: "_blank",
2022
- children: "Formats"
2023
- })]
2024
- }),
2025
- placeholder: numbroFormatExample,
2026
- minRows: 4,
2027
- maxRows: 12,
2028
- autosize: true
2029
- }, form.getListInputProps("series", index2, "y_axis_data_formatter")))]
2030
- }), /* @__PURE__ */ jsxs(Group, {
2031
- direction: "column",
2032
- grow: true,
2033
- children: [/* @__PURE__ */ jsx(Text, {
2034
- children: "Color"
2035
- }), /* @__PURE__ */ jsx(MantineColorSelector, __spreadValues({}, form.getListInputProps("series", index2, "color")))]
2036
- }), /* @__PURE__ */ jsx(ActionIcon, {
2037
- color: "red",
2038
- variant: "hover",
2039
- onClick: () => form.removeListItem("series", index2),
2040
- sx: {
2041
- position: "absolute",
2042
- top: 15,
2043
- right: 5
2044
- },
2045
- children: /* @__PURE__ */ jsx(Trash, {
2046
- size: 16
2047
- })
2048
- })]
2049
- }, index2)), /* @__PURE__ */ jsx(Group, {
2050
- position: "center",
2051
- mt: "xs",
2052
- children: /* @__PURE__ */ jsx(Button, {
2053
- onClick: addSeries,
2054
- children: "Add a Series"
2055
- })
2056
- })]
2380
+ children: /* @__PURE__ */ jsx(Controller, {
2381
+ name: "x_axis_name",
2382
+ control,
2383
+ render: ({
2384
+ field
2385
+ }) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
2386
+ size: "md",
2387
+ label: "X Axis Name"
2388
+ }, field))
2389
+ })
2390
+ }), /* @__PURE__ */ jsx(YAxesField, {
2391
+ control,
2392
+ watch
2393
+ }), /* @__PURE__ */ jsx(SeriesField, {
2394
+ control,
2395
+ watch,
2396
+ getValues
2057
2397
  })]
2058
2398
  })
2059
2399
  });
@@ -2953,9 +3293,9 @@ const types = [{
2953
3293
  label: "Bar Chart (3D)",
2954
3294
  Panel: VizBar3DPanel
2955
3295
  }, {
2956
- value: "line-bar",
2957
- label: "Line-Bar Chart",
2958
- Panel: VizLineBarChartPanel
3296
+ value: "cartesian",
3297
+ label: "Cartesian Chart",
3298
+ Panel: VizCartesianChartPanel
2959
3299
  }, {
2960
3300
  value: "pie",
2961
3301
  label: "Pie Chart",
@@ -4058,9 +4398,8 @@ function Dashboard({
4058
4398
  return !_.isEqual(dataSources, dashboard.definition.dataSources);
4059
4399
  }, [dashboard, panels, sqlSnippets, dataSources]);
4060
4400
  const saveDashboardChanges = async () => {
4061
- const d = _.merge({}, dashboard, {
4062
- panels
4063
- }, {
4401
+ const d = __spreadProps(__spreadValues({}, dashboard), {
4402
+ panels,
4064
4403
  definition: {
4065
4404
  sqlSnippets,
4066
4405
  dataSources