@quillsql/react 2.10.39 → 2.11.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 (123) hide show
  1. package/dist/cjs/Chart.d.ts +4 -0
  2. package/dist/cjs/Chart.d.ts.map +1 -1
  3. package/dist/cjs/Chart.js +5 -5
  4. package/dist/cjs/ChartBuilder.js +2 -2
  5. package/dist/cjs/Context.d.ts +1 -1
  6. package/dist/cjs/Context.d.ts.map +1 -1
  7. package/dist/cjs/Context.js +3 -1
  8. package/dist/cjs/Dashboard.d.ts +3 -1
  9. package/dist/cjs/Dashboard.d.ts.map +1 -1
  10. package/dist/cjs/Dashboard.js +4 -4
  11. package/dist/cjs/QuillProvider.d.ts +3 -1
  12. package/dist/cjs/QuillProvider.d.ts.map +1 -1
  13. package/dist/cjs/QuillProvider.js +2 -2
  14. package/dist/cjs/ReportBuilder.d.ts +40 -40
  15. package/dist/cjs/ReportBuilder.d.ts.map +1 -1
  16. package/dist/cjs/ReportBuilder.js +2026 -917
  17. package/dist/cjs/components/Chart/LineChart.d.ts +5 -1
  18. package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
  19. package/dist/cjs/components/Chart/LineChart.js +18 -6
  20. package/dist/cjs/components/QuillTable.d.ts +1 -1
  21. package/dist/cjs/components/QuillTable.d.ts.map +1 -1
  22. package/dist/cjs/components/QuillTable.js +157 -157
  23. package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts +2 -0
  24. package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -0
  25. package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +128 -0
  26. package/dist/cjs/components/ReportBuilder/ast.d.ts +512 -0
  27. package/dist/cjs/components/ReportBuilder/ast.d.ts.map +1 -0
  28. package/dist/cjs/components/ReportBuilder/ast.js +210 -0
  29. package/dist/cjs/components/ReportBuilder/bigDateMap.d.ts +7 -0
  30. package/dist/cjs/components/ReportBuilder/bigDateMap.d.ts.map +1 -0
  31. package/dist/cjs/components/ReportBuilder/bigDateMap.js +689 -0
  32. package/dist/cjs/components/ReportBuilder/constants.d.ts +89 -0
  33. package/dist/cjs/components/ReportBuilder/constants.d.ts.map +1 -0
  34. package/dist/cjs/components/ReportBuilder/constants.js +130 -0
  35. package/dist/cjs/components/ReportBuilder/convert.d.ts +41 -0
  36. package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -0
  37. package/dist/cjs/components/ReportBuilder/convert.js +730 -0
  38. package/dist/cjs/components/ReportBuilder/operators.d.ts +445 -0
  39. package/dist/cjs/components/ReportBuilder/operators.d.ts.map +1 -0
  40. package/dist/cjs/components/ReportBuilder/operators.js +552 -0
  41. package/dist/cjs/components/ReportBuilder/pivot.d.ts +10 -0
  42. package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -0
  43. package/dist/cjs/components/ReportBuilder/pivot.js +2 -0
  44. package/dist/cjs/components/ReportBuilder/postgres.d.ts +150 -0
  45. package/dist/cjs/components/ReportBuilder/postgres.d.ts.map +1 -0
  46. package/dist/cjs/components/ReportBuilder/postgres.js +365 -0
  47. package/dist/cjs/components/ReportBuilder/schema.d.ts +23 -0
  48. package/dist/cjs/components/ReportBuilder/schema.d.ts.map +1 -0
  49. package/dist/cjs/components/ReportBuilder/schema.js +2 -0
  50. package/dist/cjs/components/ReportBuilder/ui.d.ts +34 -0
  51. package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -0
  52. package/dist/cjs/components/ReportBuilder/ui.js +389 -0
  53. package/dist/cjs/components/ReportBuilder/util.d.ts +76 -0
  54. package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -0
  55. package/dist/cjs/components/ReportBuilder/util.js +648 -0
  56. package/dist/cjs/components/UiComponents.d.ts +15 -2
  57. package/dist/cjs/components/UiComponents.d.ts.map +1 -1
  58. package/dist/cjs/components/UiComponents.js +50 -3
  59. package/dist/cjs/utils/crypto.d.ts +1 -1
  60. package/dist/cjs/utils/crypto.d.ts.map +1 -1
  61. package/dist/cjs/utils/crypto.js +9 -5
  62. package/dist/esm/Chart.d.ts +4 -0
  63. package/dist/esm/Chart.d.ts.map +1 -1
  64. package/dist/esm/Chart.js +5 -5
  65. package/dist/esm/ChartBuilder.js +1 -1
  66. package/dist/esm/Context.d.ts +1 -1
  67. package/dist/esm/Context.d.ts.map +1 -1
  68. package/dist/esm/Context.js +3 -1
  69. package/dist/esm/Dashboard.d.ts +3 -1
  70. package/dist/esm/Dashboard.d.ts.map +1 -1
  71. package/dist/esm/Dashboard.js +4 -4
  72. package/dist/esm/QuillProvider.d.ts +3 -1
  73. package/dist/esm/QuillProvider.d.ts.map +1 -1
  74. package/dist/esm/QuillProvider.js +2 -2
  75. package/dist/esm/ReportBuilder.d.ts +40 -40
  76. package/dist/esm/ReportBuilder.d.ts.map +1 -1
  77. package/dist/esm/ReportBuilder.js +2028 -917
  78. package/dist/esm/components/Chart/LineChart.d.ts +5 -1
  79. package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
  80. package/dist/esm/components/Chart/LineChart.js +18 -6
  81. package/dist/esm/components/QuillTable.d.ts +1 -1
  82. package/dist/esm/components/QuillTable.d.ts.map +1 -1
  83. package/dist/esm/components/QuillTable.js +157 -157
  84. package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts +2 -0
  85. package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -0
  86. package/dist/esm/components/ReportBuilder/AddColumnPopover.js +125 -0
  87. package/dist/esm/components/ReportBuilder/ast.d.ts +512 -0
  88. package/dist/esm/components/ReportBuilder/ast.d.ts.map +1 -0
  89. package/dist/esm/components/ReportBuilder/ast.js +186 -0
  90. package/dist/esm/components/ReportBuilder/bigDateMap.d.ts +7 -0
  91. package/dist/esm/components/ReportBuilder/bigDateMap.d.ts.map +1 -0
  92. package/dist/esm/components/ReportBuilder/bigDateMap.js +686 -0
  93. package/dist/esm/components/ReportBuilder/constants.d.ts +89 -0
  94. package/dist/esm/components/ReportBuilder/constants.d.ts.map +1 -0
  95. package/dist/esm/components/ReportBuilder/constants.js +127 -0
  96. package/dist/esm/components/ReportBuilder/convert.d.ts +41 -0
  97. package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -0
  98. package/dist/esm/components/ReportBuilder/convert.js +719 -0
  99. package/dist/esm/components/ReportBuilder/operators.d.ts +445 -0
  100. package/dist/esm/components/ReportBuilder/operators.d.ts.map +1 -0
  101. package/dist/esm/components/ReportBuilder/operators.js +548 -0
  102. package/dist/esm/components/ReportBuilder/pivot.d.ts +10 -0
  103. package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -0
  104. package/dist/esm/components/ReportBuilder/pivot.js +1 -0
  105. package/dist/esm/components/ReportBuilder/postgres.d.ts +150 -0
  106. package/dist/esm/components/ReportBuilder/postgres.d.ts.map +1 -0
  107. package/dist/esm/components/ReportBuilder/postgres.js +355 -0
  108. package/dist/esm/components/ReportBuilder/schema.d.ts +23 -0
  109. package/dist/esm/components/ReportBuilder/schema.d.ts.map +1 -0
  110. package/dist/esm/components/ReportBuilder/schema.js +1 -0
  111. package/dist/esm/components/ReportBuilder/ui.d.ts +34 -0
  112. package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -0
  113. package/dist/esm/components/ReportBuilder/ui.js +366 -0
  114. package/dist/esm/components/ReportBuilder/util.d.ts +76 -0
  115. package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -0
  116. package/dist/esm/components/ReportBuilder/util.js +616 -0
  117. package/dist/esm/components/UiComponents.d.ts +15 -2
  118. package/dist/esm/components/UiComponents.d.ts.map +1 -1
  119. package/dist/esm/components/UiComponents.js +47 -2
  120. package/dist/esm/utils/crypto.d.ts +1 -1
  121. package/dist/esm/utils/crypto.d.ts.map +1 -1
  122. package/dist/esm/utils/crypto.js +9 -5
  123. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, }: {
2
+ export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dashedComparison, customPrimaryColor, customComparisonColor, singlePointStyle, }: {
3
3
  colors?: string[];
4
4
  yAxisFields: any[];
5
5
  data: any[];
@@ -13,5 +13,9 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
13
13
  hideXAxis: boolean;
14
14
  hideYAxis: boolean;
15
15
  hideCartesianGrid: boolean;
16
+ dashedComparison: boolean;
17
+ customPrimaryColor: string | undefined;
18
+ customComparisonColor: string | undefined;
19
+ singlePointStyle: 'dot' | 'line';
16
20
  }): import("react/jsx-runtime").JSX.Element | null;
17
21
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAiBA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,GAC1B,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,kDAoMA"}
1
+ {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAiBA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,gBAAwB,EACxB,kBAA8B,EAC9B,qBAAiC,EACjC,gBAAwB,GACzB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC;CAClC,kDAyNA"}
@@ -7,7 +7,7 @@ import { selectColor } from '../../utils/color';
7
7
  import ChartTooltip from '../../components/Chart/ChartTooltip';
8
8
  import getDomain from '../../utils/getDomain';
9
9
  import { useEffect, useState } from 'react';
10
- export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, }) {
10
+ export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, dashedComparison = false, customPrimaryColor = undefined, customComparisonColor = undefined, singlePointStyle = 'dot', }) {
11
11
  const [formattedData, setFormattedData] = useState([]);
12
12
  if (!yAxisFields || !yAxisFields.length) {
13
13
  return null;
@@ -16,8 +16,9 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
16
16
  if (!data || data.length === 0) {
17
17
  return;
18
18
  }
19
+ let newData = data;
19
20
  if (typeof data[0][xAxisField] === 'object') {
20
- const curData = data.map((d) => {
21
+ newData = data.map((d) => {
21
22
  const formatted = { ...d };
22
23
  // NEED TO FORMAT FOR BIG QUERY
23
24
  if (d[xAxisField] && typeof d[xAxisField] === 'object') {
@@ -25,11 +26,12 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
25
26
  }
26
27
  return formatted;
27
28
  });
28
- setFormattedData(curData);
29
29
  }
30
- else {
31
- setFormattedData(data);
30
+ if (singlePointStyle === 'line' && newData.length == 1) {
31
+ const point = { ...newData[0] };
32
+ newData.push(point);
32
33
  }
34
+ setFormattedData(newData);
33
35
  }, [data]);
34
36
  if (!data || data.length === 0) {
35
37
  return (_jsx("div", { style: {
@@ -43,6 +45,16 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
43
45
  color: theme.secondaryTextColor,
44
46
  }, children: "No results found for specified time period." }));
45
47
  }
48
+ // Allows the users to override the color scheme on a per-chart basis.
49
+ const getCustomColor = (index) => {
50
+ if (index === 0 && customPrimaryColor) {
51
+ return customPrimaryColor;
52
+ }
53
+ if (index === 1 && comparison && customComparisonColor) {
54
+ return customComparisonColor;
55
+ }
56
+ return undefined; // use the default colors from the theme
57
+ };
46
58
  return (_jsx("div", { style: { ...containerStyle }, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', children: _jsxs(ReChartsAreaChart, { data: formattedData, children: [!hideCartesianGrid && (_jsx(CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), _jsx(XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
47
59
  fontSize: '12px',
48
60
  fontFamily: theme?.chartLabelFontFamily ||
@@ -87,5 +99,5 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
87
99
  { field: xAxisField, format: xAxisFormat },
88
100
  ],
89
101
  }), xAxisFormat: xAxisFormat, xAxisField: xAxisField, colors: colors, theme: theme }));
90
- }, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: selectColor(elem, colors, index), stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: selectColor(elem, colors, index), fill: `url(#gradient${index})`, strokeWidth: 2, dot: false, isAnimationActive: isAnimationActive }, elem.field)))] }) }) }));
102
+ }, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: getCustomColor(index) ?? selectColor(elem, colors, index), stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: getCustomColor(index) ?? selectColor(elem, colors, index), fill: `url(#gradient${index})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && dashedComparison && index > 0 ? '5 5' : undefined, isAnimationActive: isAnimationActive }, elem.field)))] }) }) }));
91
103
  }
@@ -1,3 +1,3 @@
1
1
  import { TableComponentProps } from './UiComponents';
2
- export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle, downloadCSV, LoadingComponent, }: TableComponentProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle, LoadingComponent, rowsPerPage, emptyStateLabel, downloadCSV, }: TableComponentProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=QuillTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMrD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,gBAA0C,GAC3C,EAAE,mBAAmB,2CAsZrB"}
1
+ {"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMrD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAA0C,EAC1C,WAAgB,EAChB,eAAwC,EACxC,WAAW,GACZ,EAAE,mBAAmB,2CAsZrB"}
@@ -3,7 +3,7 @@ import { useContext, useEffect, useState } from 'react';
3
3
  import { compareValues } from '../utils/valueFormatter';
4
4
  import { ThemeContext } from '../Context';
5
5
  import ChartSkeleton from './Chart/ChartSkeleton';
6
- export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle, downloadCSV, LoadingComponent = () => _jsx(ChartSkeleton, {}), }) {
6
+ export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle, LoadingComponent = () => _jsx(ChartSkeleton, {}), rowsPerPage = 10, emptyStateLabel = 'No results returned.', downloadCSV, }) {
7
7
  const [activeRows, setActiveRows] = useState([]);
8
8
  const [page, setPage] = useState(1);
9
9
  const [maxPage, setMaxPage] = useState(1);
@@ -23,10 +23,10 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
23
23
  return sortDirection === 'asc' ? result : -result;
24
24
  });
25
25
  }
26
- const start = (page - 1) * 10;
27
- const end = page * 10;
26
+ const start = (page - 1) * rowsPerPage;
27
+ const end = page * rowsPerPage;
28
28
  if (sortedRows && sortedRows.length) {
29
- setMaxPage(Math.ceil(sortedRows.length / 10));
29
+ setMaxPage(Math.ceil(sortedRows.length / rowsPerPage));
30
30
  }
31
31
  setActiveRows(sortedRows.slice(start, end));
32
32
  setIsPaginating(false);
@@ -57,174 +57,174 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
57
57
  ...containerStyle,
58
58
  }, children: _jsx(LoadingComponent, {}) }));
59
59
  }
60
- return (_jsxs("div", { style: {
60
+ return (_jsx("div", { style: {
61
61
  width: '100%',
62
62
  height: '100%',
63
63
  overflow: 'visible',
64
64
  display: 'flex',
65
65
  flexDirection: 'column',
66
66
  ...containerStyle,
67
- }, children: [_jsx("div", { style: {
68
- height: '100%',
67
+ }, children: _jsx("div", { style: {
68
+ height: '100%',
69
+ width: '100%',
70
+ overflow: 'auto',
71
+ borderRadius: 6,
72
+ border: '1px solid rgb(229, 231, 235)',
73
+ padding: 0,
74
+ margin: 0,
75
+ boxSizing: 'border-box',
76
+ outline: 'none',
77
+ }, children: _jsxs("div", { role: "table", className: "table", style: {
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ minWidth: '0px',
69
81
  width: '100%',
70
- overflow: 'auto',
71
- borderRadius: 6,
72
- border: '1px solid rgb(229, 231, 235)',
73
- padding: 0,
74
- margin: 0,
75
- boxSizing: 'border-box',
76
- outline: 'none',
77
- }, children: _jsxs("div", { role: "table", className: "table", style: { minWidth: '0px', width: '100%', height: '100%' }, children: [_jsx("div", { className: "thead", children: _jsx("div", { role: "row", className: "tr", style: {
78
- display: 'flex',
79
- flex: '1 0 auto',
80
- minWidth: '100px',
81
- boxSizing: 'border-box',
82
- }, children: columns && columns.map((column, index) => (_jsxs("div", { onClick: () => toggleSort(column), style: {
83
- boxSizing: 'border-box',
84
- flex: '150 0 auto',
85
- minWidth: '50px',
86
- width: '150px',
87
- position: 'relative',
88
- cursor: 'pointer',
89
- background: 'rgb(249, 250, 251)',
90
- borderRight: index + 1 === columns.length
91
- ? '0px solid rgb(229, 231, 235)'
92
- : '1px solid rgb(229, 231, 235)',
93
- borderBottom: '1px solid rgb(229, 231, 235)',
94
- whiteSpace: 'nowrap',
95
- alignItems: 'center',
96
- overflowX: 'visible',
97
- margin: '0px',
98
- textOverflow: 'ellipsis',
99
- minHeight: '36px',
100
- userSelect: 'none',
101
- paddingLeft: 16,
102
- paddingRight: 16,
82
+ height: '100%',
83
+ }, children: [_jsxs("div", { style: { overflow: 'auto', flexGrow: 1 }, children: [_jsx("div", { className: "thead", children: _jsx("div", { role: "row", className: "tr", style: {
103
84
  display: 'flex',
104
- flexDirection: 'row',
105
- justifyContent: 'space-between',
106
- }, children: [_jsx("div", { "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r6-dropdown", style: {
107
- // fontFamily:
108
- // 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
109
- WebkitTapHighlightColor: 'transparent',
110
- fontFamily: theme?.fontFamily,
111
- // color: 'rgb(55, 65, 81)',
112
- color: theme?.primaryTextColor,
113
- textDecoration: 'none',
114
- fontSize: theme?.fontSizeSmall || '14px',
115
- fontWeight: theme?.fontWeightMedium || '500',
116
- lineHeight: '20px', // 1.25rem * 16px = 20px
117
- textOverflow: 'ellipsis',
85
+ flex: '1 0 auto',
86
+ minWidth: '100px',
87
+ boxSizing: 'border-box',
88
+ }, children: columns &&
89
+ columns.map((column, index) => (_jsxs("div", { onClick: () => toggleSort(column), style: {
90
+ boxSizing: 'border-box',
91
+ flex: '150 0 auto',
92
+ minWidth: '50px',
93
+ width: '150px',
94
+ position: 'relative',
95
+ cursor: 'pointer',
96
+ background: 'rgb(249, 250, 251)',
97
+ borderRight: index + 1 === columns.length
98
+ ? '0px solid rgb(229, 231, 235)'
99
+ : '1px solid rgb(229, 231, 235)',
100
+ borderBottom: '1px solid rgb(229, 231, 235)',
118
101
  whiteSpace: 'nowrap',
119
- overflow: 'hidden',
120
- }, children: column.label || column.field }), column.field === sortColumn && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.primaryTextColor, height: "14px", width: "14px", style: {
121
- transform: sortDirection === 'desc'
122
- ? 'rotate(180deg)'
123
- : undefined,
124
- }, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (activeRows && activeRows.length === 0) || (columns && columns.length === 0) ? (_jsx("div", { style: {
125
- paddingTop: '60px',
126
- display: 'flex',
127
- flex: '1 0 auto',
128
- margin: 'auto',
129
- justifyContent: 'center',
130
- alignItems: 'center',
131
- fontSize: 13,
132
- color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
133
- }, children: "No results returned." })) : (_jsx("div", { role: "rowgroup", className: "tbody", children: activeRows && activeRows.map((row, rowIndex) => (_jsx("div", { role: "row", className: "tr", style: {
102
+ alignItems: 'center',
103
+ overflowX: 'visible',
104
+ margin: '0px',
105
+ textOverflow: 'ellipsis',
106
+ minHeight: '36px',
107
+ userSelect: 'none',
108
+ paddingLeft: 16,
109
+ paddingRight: 16,
110
+ display: 'flex',
111
+ flexDirection: 'row',
112
+ justifyContent: 'space-between',
113
+ }, children: [_jsx("div", { "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r6-dropdown", style: {
114
+ // fontFamily:
115
+ // 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
116
+ WebkitTapHighlightColor: 'transparent',
117
+ fontFamily: theme?.fontFamily,
118
+ // color: 'rgb(55, 65, 81)',
119
+ color: theme?.primaryTextColor,
120
+ textDecoration: 'none',
121
+ fontSize: theme?.fontSizeSmall || '14px',
122
+ fontWeight: theme?.fontWeightMedium || '500',
123
+ lineHeight: '20px', // 1.25rem * 16px = 20px
124
+ textOverflow: 'ellipsis',
125
+ whiteSpace: 'nowrap',
126
+ overflow: 'hidden',
127
+ }, children: column.label || column.field }), column.field === sortColumn && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.primaryTextColor, height: "14px", width: "14px", style: {
128
+ transform: sortDirection === 'desc'
129
+ ? 'rotate(180deg)'
130
+ : undefined,
131
+ }, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (activeRows && activeRows.length === 0) ||
132
+ (columns && columns.length === 0) ? (_jsx("div", { style: {
133
+ padding: '60px 0',
134
134
  display: 'flex',
135
135
  flex: '1 0 auto',
136
- minWidth: '100px',
137
- boxSizing: 'border-box',
138
- }, children: columns.map((column, columnIndex) => (_jsx("div", { role: "cell", style: {
139
- boxSizing: 'border-box',
140
- flex: '150 0 auto',
141
- minWidth: '50px',
142
- width: '150px',
143
- display: 'flex',
144
- margin: '0px',
145
- textOverflow: 'ellipsis',
146
- minHeight: '36px',
147
- borderRight: columnIndex + 1 === columns.length
148
- ? '0px solid rgb(229, 231, 235)'
149
- : '1px solid rgb(229, 231, 235)',
150
- overflow: 'hidden',
151
- borderTop: rowIndex > 0
152
- ? '1px solid rgb(229, 231, 235)'
153
- : undefined,
154
- borderBottom: rowIndex === rows.length - 1
155
- ? '1px solid rgb(229, 231, 235)'
156
- : undefined,
157
- userSelect: 'none',
158
- }, children: _jsx("div", { style: {
159
- lineHeight: '24px',
160
- width: '100%',
136
+ margin: 'auto',
137
+ justifyContent: 'center',
138
+ alignItems: 'center',
139
+ fontSize: 13,
140
+ color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
141
+ }, children: emptyStateLabel })) : (_jsx("div", { role: "rowgroup", className: "tbody", children: activeRows &&
142
+ activeRows.map((row, rowIndex) => (_jsx("div", { role: "row", className: "tr", style: {
161
143
  display: 'flex',
162
- cursor: 'default',
163
- position: 'relative',
164
- userSelect: 'none',
165
- }, "data-testid": "static-cell", children: _jsx("div", { "aria-haspopup": "dialog", "aria-expanded": "false", style: {
166
- fontFamily: theme?.fontFamily ||
167
- 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
168
- WebkitTapHighlightColor: 'transparent',
169
- // color: 'rgb(55, 65, 81)',
170
- color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
171
- textDecoration: 'none',
172
- fontWeight: 400,
173
- fontSize: theme?.fontSizeSmall || '14px',
174
- lineHeight: '20px',
144
+ flex: '1 0 auto',
145
+ minWidth: '100px',
146
+ boxSizing: 'border-box',
147
+ }, children: columns.map((column, columnIndex) => (_jsx("div", { role: "cell", style: {
148
+ boxSizing: 'border-box',
149
+ flex: '150 0 auto',
150
+ minWidth: '50px',
151
+ width: '150px',
152
+ display: 'flex',
153
+ margin: '0px',
175
154
  textOverflow: 'ellipsis',
176
- whiteSpace: 'nowrap',
155
+ minHeight: '36px',
156
+ borderRight: columnIndex + 1 === columns.length
157
+ ? '0px solid rgb(229, 231, 235)'
158
+ : '1px solid rgb(229, 231, 235)',
177
159
  overflow: 'hidden',
178
- padding: '8px 16px',
160
+ borderTop: rowIndex > 0
161
+ ? '1px solid rgb(229, 231, 235)'
162
+ : undefined,
163
+ borderBottom: rowIndex === rows.length - 1
164
+ ? '1px solid rgb(229, 231, 235)'
165
+ : undefined,
179
166
  userSelect: 'none',
180
- }, children: row[column.field] }) }) }, 'sqlcell' + columnIndex))) }, 'sqlrow' + rowIndex))) }))] }) }), _jsx("div", { style: { position: 'relative' }, children: _jsx("div", { style: {
181
- display: 'flex',
182
- flex: '1 0 auto',
183
- minWidth: '100px',
184
- boxSizing: 'border-box',
185
- position: 'absolute',
186
- bottom: 0,
187
- left: 0,
188
- right: 0,
189
- height: 38,
190
- background: '#F9FAFB',
191
- borderRight: '1px solid rgb(229, 231, 235)',
192
- borderLeft: '1px solid rgb(229, 231, 235)',
193
- borderBottom: '1px solid rgb(229, 231, 235)',
194
- borderTop: '1px solid rgb(229, 231, 235)',
195
- borderBottomRightRadius: 6,
196
- borderBottomLeftRadius: 6,
197
- width: '100%',
198
- }, children: _jsxs("div", { style: {
167
+ }, children: _jsx("div", { style: {
168
+ lineHeight: '24px',
169
+ width: '100%',
170
+ display: 'flex',
171
+ cursor: 'default',
172
+ position: 'relative',
173
+ userSelect: 'none',
174
+ }, "data-testid": "static-cell", children: _jsx("div", { "aria-haspopup": "dialog", "aria-expanded": "false", style: {
175
+ fontFamily: theme?.fontFamily ||
176
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
177
+ WebkitTapHighlightColor: 'transparent',
178
+ // color: 'rgb(55, 65, 81)',
179
+ color: theme?.secondaryTextColor ||
180
+ 'rgb(55, 65, 81)',
181
+ textDecoration: 'none',
182
+ fontWeight: 400,
183
+ fontSize: theme?.fontSizeSmall || '14px',
184
+ lineHeight: '20px',
185
+ textOverflow: 'ellipsis',
186
+ whiteSpace: 'nowrap',
187
+ overflow: 'hidden',
188
+ padding: '8px 16px',
189
+ userSelect: 'none',
190
+ }, children: row[column.field] }) }) }, 'sqlcell' + columnIndex))) }, 'sqlrow' + rowIndex))) }))] }), _jsx("div", { style: {
199
191
  display: 'flex',
200
- flexDirection: 'row',
201
- alignItems: 'center',
202
- justifyContent: 'space-between',
192
+ minWidth: '100px',
193
+ height: 38,
194
+ borderTop: '1px solid rgb(229, 231, 235)',
195
+ background: '#F9FAFB',
203
196
  width: '100%',
204
- }, children: [showDownloadCSVButton ? (_jsx("button", { onClick: downloadCSV, style: {
205
- fontSize: 14,
206
- paddingLeft: 12,
207
- fontFamily: theme?.fontFamily,
208
- color: theme?.primaryTextColor,
209
- background: 'transparent',
210
- fontWeight: 500,
211
- cursor: 'pointer',
212
- border: 'none',
213
- }, children: "Download CSV" })) : (_jsx("div", {})), _jsxs("div", { style: {
214
- display: 'flex',
215
- flexDirection: 'row',
216
- alignItems: 'center',
217
- }, children: [_jsxs("div", { style: {
218
- fontSize: 12,
219
- fontFamily: theme?.fontFamily,
220
- color: theme?.primaryTextColor,
221
- }, children: [page, ' of ', maxPage] }), _jsx("div", { style: { width: 8 } }), _jsx("button", { onClick: decreasePage, style: {
222
- cursor: 'pointer',
223
- border: 'none',
224
- background: 'transparent',
225
- }, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.chartLabelFontFamily || theme?.fontFamily, height: "16px", width: "16px", children: _jsx("path", { fillRule: "evenodd", d: "M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z", clipRule: "evenodd" }) }) }), _jsx("button", { onClick: increasePage, style: {
226
- cursor: 'pointer',
227
- border: 'none',
228
- background: 'transparent',
229
- }, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.chartLabelFontFamily || theme?.fontFamily, height: "16px", width: "16px", children: _jsx("path", { fillRule: "evenodd", d: "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z", clipRule: "evenodd" }) }) }), _jsx("div", { style: { width: 12 } })] })] }) }) })] }));
197
+ }, children: _jsxs("div", { style: {
198
+ display: 'flex',
199
+ flexDirection: 'row',
200
+ alignItems: 'center',
201
+ justifyContent: 'space-between',
202
+ width: '100%',
203
+ height: 37,
204
+ }, children: [showDownloadCSVButton ? (_jsx("button", { onClick: downloadCSV, style: {
205
+ fontSize: 14,
206
+ paddingLeft: 12,
207
+ fontFamily: theme?.fontFamily,
208
+ color: theme?.primaryTextColor,
209
+ background: 'transparent',
210
+ fontWeight: 500,
211
+ cursor: 'pointer',
212
+ border: 'none',
213
+ }, children: "Download CSV" })) : (_jsx("div", {})), _jsxs("div", { style: {
214
+ display: 'flex',
215
+ flexDirection: 'row',
216
+ alignItems: 'center',
217
+ }, children: [_jsxs("div", { style: {
218
+ fontSize: 12,
219
+ fontFamily: theme?.fontFamily,
220
+ color: theme?.primaryTextColor,
221
+ }, children: [page, ' of ', maxPage] }), _jsx("div", { style: { width: 8 } }), _jsx("button", { onClick: decreasePage, style: {
222
+ cursor: 'pointer',
223
+ border: 'none',
224
+ background: 'transparent',
225
+ }, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.chartLabelFontFamily || theme?.fontFamily, height: "16px", width: "16px", children: _jsx("path", { fillRule: "evenodd", d: "M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z", clipRule: "evenodd" }) }) }), _jsx("button", { onClick: increasePage, style: {
226
+ cursor: 'pointer',
227
+ border: 'none',
228
+ background: 'transparent',
229
+ }, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.chartLabelFontFamily || theme?.fontFamily, height: "16px", width: "16px", children: _jsx("path", { fillRule: "evenodd", d: "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z", clipRule: "evenodd" }) }) }), _jsx("div", { style: { width: 12 } })] })] }) })] }) }) }));
230
230
  }
@@ -0,0 +1,2 @@
1
+ export default function AddColumnPopover({ onSave, orderedColumnNames, setOrderedColumnNames, selectedColumns, setSelectedColumns, isSelectedAllColumns, clearAllState, nameToColumn, baseAst, setBaseAst, pivot, initialTableName, defaultAST, defaultTable, setPivot, TextInput, SelectColumn, SecondaryButton, Button, HandleButton, }: any): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=AddColumnPopover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddColumnPopover.d.ts","sourceRoot":"","sources":["../../../../src/components/ReportBuilder/AddColumnPopover.tsx"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,MAAM,EACN,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,eAAe,EACf,MAAM,EACN,YAAY,GACb,EAAE,GAAG,2CA4LL"}
@@ -0,0 +1,125 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
4
+ import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, } from '@dnd-kit/sortable';
5
+ import { CSS as DND_CSS } from '@dnd-kit/utilities';
6
+ export default function AddColumnPopover({ onSave, orderedColumnNames, setOrderedColumnNames, selectedColumns, setSelectedColumns, isSelectedAllColumns, clearAllState, nameToColumn, baseAst, setBaseAst, pivot, initialTableName, defaultAST, defaultTable, setPivot, TextInput, SelectColumn, SecondaryButton, Button, HandleButton, }) {
7
+ const [search, setSearch] = useState('');
8
+ const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
9
+ coordinateGetter: sortableKeyboardCoordinates,
10
+ }));
11
+ // When a drag event ends, switch the item order.
12
+ function handleDragEnd(event) {
13
+ const { active, over } = event;
14
+ if (active.id !== over.id) {
15
+ setOrderedColumnNames((orderedColumnNames) => {
16
+ const oldIndex = orderedColumnNames.indexOf(active.id);
17
+ const newIndex = orderedColumnNames.indexOf(over.id);
18
+ return arrayMove(orderedColumnNames, oldIndex, newIndex);
19
+ });
20
+ }
21
+ }
22
+ const getColumnsInPivot = () => {
23
+ if (!pivot)
24
+ return [];
25
+ const { valueField, rowField, columnField } = pivot;
26
+ return [valueField, rowField, columnField].filter(Boolean);
27
+ };
28
+ const searchResults = orderedColumnNames
29
+ .filter((row) => {
30
+ const [table, _column] = row.split('.');
31
+ return (selectedColumns.length === 0 || selectedColumns[0].startsWith(table));
32
+ })
33
+ .filter((row) => search.length === 0 || row.includes(search));
34
+ return (_jsxs("div", { style: {
35
+ display: 'flex',
36
+ flexDirection: 'column',
37
+ gap: 2,
38
+ minWidth: 300,
39
+ maxHeight: 500,
40
+ }, children: [_jsx("div", { style: {
41
+ position: 'relative',
42
+ display: 'flex',
43
+ flexDirection: 'row',
44
+ alignItems: 'center',
45
+ marginTop: 2,
46
+ }, children: _jsx(TextInput, { type: "text", value: search, placeholder: 'Search...', style: { margin: '8px 0', width: '100%' }, onChange: (e) => setSearch(e.target.value) }) }), _jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: _jsx(SortableContext, { items: orderedColumnNames, strategy: verticalListSortingStrategy, children: _jsxs("div", { style: {
47
+ display: 'flex',
48
+ flexDirection: 'column',
49
+ gap: 8,
50
+ overflowY: 'auto',
51
+ maxWidth: '300px',
52
+ }, children: [searchResults.map((value) => {
53
+ return (_jsx(SortableItem, { selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, id: value, label: value.replace('.', ' '), SelectColumn: SelectColumn, HandleButton: HandleButton }, value));
54
+ }), search.length > 0 && searchResults.length === 0 && (_jsx("div", { children: "No results found" }))] }) }) }), _jsxs("div", { style: {
55
+ display: 'flex',
56
+ width: '100%',
57
+ flexDirection: 'row',
58
+ gap: 8,
59
+ justifyContent: 'end',
60
+ marginTop: 12,
61
+ }, children: [selectedColumns.length > 0 && !isSelectedAllColumns() && (_jsx(SecondaryButton, { onClick: () => setSelectedColumns(orderedColumnNames.filter((row) => {
62
+ const [table, _column] = row.split('.');
63
+ return selectedColumns[0].startsWith(table);
64
+ })), children: "Select all" })), selectedColumns.length > 0 && isSelectedAllColumns() && (_jsx(SecondaryButton, { onClick: () => setSelectedColumns([]), children: "Clear" })), _jsx(Button, { onMouseUp: () => {
65
+ // follow the ordering of the ordered column names
66
+ let tableName = initialTableName;
67
+ const orderedSelectedColumns = [];
68
+ for (const value of orderedColumnNames) {
69
+ const [table, column] = value.split('.');
70
+ if (selectedColumns.includes(value)) {
71
+ tableName = table;
72
+ orderedSelectedColumns.push(column);
73
+ }
74
+ }
75
+ if (orderedSelectedColumns.length === 0) {
76
+ clearAllState();
77
+ return;
78
+ }
79
+ // If there is already an AST saved in state, only update the columns
80
+ // otherwise fill in the defaultAST shape and also update columns.
81
+ const fallbackAST = {
82
+ ...defaultAST,
83
+ from: [{ ...defaultTable, table: tableName }],
84
+ columns: orderedSelectedColumns.map((name) => nameToColumn(name)),
85
+ };
86
+ const newBaseAst = {
87
+ ...baseAst,
88
+ from: [{ ...defaultTable, table: tableName }],
89
+ columns: baseAst?.columns.length
90
+ ? orderedSelectedColumns.map((name) => nameToColumn(name))
91
+ : baseAst?.columns,
92
+ };
93
+ const newAst = baseAst ? newBaseAst : fallbackAST;
94
+ setBaseAst(newAst);
95
+ // If the user deleted a column that was in the pivot, delete the Pivot
96
+ const columnInAST = (col) => newAst.columns.find((c) => c.expr?.value === col ||
97
+ c.expr?.column === col ||
98
+ c.as === col);
99
+ if (pivot &&
100
+ !getColumnsInPivot().every((c) => columnInAST(c))) {
101
+ setPivot(null);
102
+ }
103
+ onSave();
104
+ }, children: "Save" })] })] }));
105
+ }
106
+ const SortableItem = ({ id, label, setSelectedColumns, selectedColumns, SelectColumn, HandleButton, }) => {
107
+ const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: id });
108
+ const style = {
109
+ transform: DND_CSS.Transform.toString(transform),
110
+ transition,
111
+ };
112
+ const handleSelect = () => {
113
+ setSelectedColumns((selectedColumns) => {
114
+ if (selectedColumns.includes(id)) {
115
+ return selectedColumns.filter((column) => column !== id);
116
+ }
117
+ else {
118
+ return [...selectedColumns, id];
119
+ }
120
+ });
121
+ };
122
+ return (_jsx("div", { style: { userSelect: 'none', ...style }, ref: setNodeRef, children: _jsx(SelectColumn, { selected: selectedColumns?.includes(id), setSelected: handleSelect, label: label, children: _jsx("div", { style: {
123
+ cursor: 'grab',
124
+ }, ...attributes, ...listeners, children: _jsx(HandleButton, {}) }) }) }));
125
+ };