@quillsql/react 1.7.2 → 1.7.4

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 (136) hide show
  1. package/lib/AddToDashboardModal.js +249 -369
  2. package/lib/AddToDashboardModal.js.map +1 -1
  3. package/lib/BarList.js +92 -109
  4. package/lib/BarList.js.map +1 -1
  5. package/lib/Chart.d.ts +0 -1
  6. package/lib/Chart.js +359 -419
  7. package/lib/Chart.js.map +1 -1
  8. package/lib/Context.d.ts +1 -2
  9. package/lib/Context.js +91 -85
  10. package/lib/Context.js.map +1 -1
  11. package/lib/Dashboard.js +181 -209
  12. package/lib/Dashboard.js.map +1 -1
  13. package/lib/DateRangePicker/Calendar.js +87 -91
  14. package/lib/DateRangePicker/Calendar.js.map +1 -1
  15. package/lib/DateRangePicker/DateRangePicker.js +70 -68
  16. package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
  17. package/lib/DateRangePicker/DateRangePickerButton.js +46 -57
  18. package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
  19. package/lib/DateRangePicker/dateRangePickerUtils.js +105 -99
  20. package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
  21. package/lib/DateRangePicker/index.js +8 -1
  22. package/lib/DateRangePicker/index.js.map +1 -1
  23. package/lib/PieChart.js +221 -225
  24. package/lib/PieChart.js.map +1 -1
  25. package/lib/QuillProvider.d.ts +1 -2
  26. package/lib/QuillProvider.js +8 -18
  27. package/lib/QuillProvider.js.map +1 -1
  28. package/lib/ReportBuilder.js +430 -526
  29. package/lib/ReportBuilder.js.map +1 -1
  30. package/lib/SQLEditor.js +182 -268
  31. package/lib/SQLEditor.js.map +1 -1
  32. package/lib/Table.js +207 -261
  33. package/lib/Table.js.map +1 -1
  34. package/lib/TableChart.js +76 -75
  35. package/lib/TableChart.js.map +1 -1
  36. package/lib/assets/ArrowDownHeadIcon.js +5 -28
  37. package/lib/assets/ArrowDownHeadIcon.js.map +1 -1
  38. package/lib/assets/ArrowDownIcon.js +5 -28
  39. package/lib/assets/ArrowDownIcon.js.map +1 -1
  40. package/lib/assets/ArrowDownRightIcon.js +5 -28
  41. package/lib/assets/ArrowDownRightIcon.js.map +1 -1
  42. package/lib/assets/ArrowLeftHeadIcon.js +5 -28
  43. package/lib/assets/ArrowLeftHeadIcon.js.map +1 -1
  44. package/lib/assets/ArrowRightHeadIcon.js +5 -28
  45. package/lib/assets/ArrowRightHeadIcon.js.map +1 -1
  46. package/lib/assets/ArrowRightIcon.js +5 -28
  47. package/lib/assets/ArrowRightIcon.js.map +1 -1
  48. package/lib/assets/ArrowUpHeadIcon.js +5 -28
  49. package/lib/assets/ArrowUpHeadIcon.js.map +1 -1
  50. package/lib/assets/ArrowUpIcon.js +5 -28
  51. package/lib/assets/ArrowUpIcon.js.map +1 -1
  52. package/lib/assets/ArrowUpRightIcon.js +5 -28
  53. package/lib/assets/ArrowUpRightIcon.js.map +1 -1
  54. package/lib/assets/CalendarIcon.js +5 -28
  55. package/lib/assets/CalendarIcon.js.map +1 -1
  56. package/lib/assets/DoubleArrowLeftHeadIcon.js +5 -28
  57. package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -1
  58. package/lib/assets/DoubleArrowRightHeadIcon.js +5 -28
  59. package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -1
  60. package/lib/assets/ExclamationFilledIcon.js +5 -28
  61. package/lib/assets/ExclamationFilledIcon.js.map +1 -1
  62. package/lib/assets/LoadingSpinner.js +5 -28
  63. package/lib/assets/LoadingSpinner.js.map +1 -1
  64. package/lib/assets/SearchIcon.js +5 -28
  65. package/lib/assets/SearchIcon.js.map +1 -1
  66. package/lib/assets/XCircleIcon.js +5 -28
  67. package/lib/assets/XCircleIcon.js.map +1 -1
  68. package/lib/assets/index.js +38 -16
  69. package/lib/assets/index.js.map +1 -1
  70. package/lib/components/BigModal/BigModal.js +45 -43
  71. package/lib/components/BigModal/BigModal.js.map +1 -1
  72. package/lib/components/Dropdown/Dropdown.js +57 -53
  73. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  74. package/lib/components/Dropdown/DropdownItem.js +43 -40
  75. package/lib/components/Dropdown/DropdownItem.js.map +1 -1
  76. package/lib/components/Dropdown/index.js +10 -2
  77. package/lib/components/Dropdown/index.js.map +1 -1
  78. package/lib/components/Modal/Modal.js +45 -43
  79. package/lib/components/Modal/Modal.js.map +1 -1
  80. package/lib/components/Modal/index.js +8 -1
  81. package/lib/components/Modal/index.js.map +1 -1
  82. package/lib/components/selectUtils.js +20 -15
  83. package/lib/components/selectUtils.js.map +1 -1
  84. package/lib/contexts/BaseColorContext.js +5 -3
  85. package/lib/contexts/BaseColorContext.js.map +1 -1
  86. package/lib/contexts/HoveredValueContext.js +5 -3
  87. package/lib/contexts/HoveredValueContext.js.map +1 -1
  88. package/lib/contexts/RootStylesContext.js +5 -3
  89. package/lib/contexts/RootStylesContext.js.map +1 -1
  90. package/lib/contexts/SelectedValueContext.js +5 -3
  91. package/lib/contexts/SelectedValueContext.js.map +1 -1
  92. package/lib/contexts/index.js +14 -4
  93. package/lib/contexts/index.js.map +1 -1
  94. package/lib/hooks/index.js +14 -4
  95. package/lib/hooks/index.js.map +1 -1
  96. package/lib/hooks/useInternalState.js +9 -7
  97. package/lib/hooks/useInternalState.js.map +1 -1
  98. package/lib/hooks/useOnClickOutside.js +8 -6
  99. package/lib/hooks/useOnClickOutside.js.map +1 -1
  100. package/lib/hooks/useOnWindowResize.js +9 -7
  101. package/lib/hooks/useOnWindowResize.js.map +1 -1
  102. package/lib/hooks/useQuill.js +60 -111
  103. package/lib/hooks/useQuill.js.map +1 -1
  104. package/lib/hooks/useSelectOnKeyDown.js +17 -15
  105. package/lib/hooks/useSelectOnKeyDown.js.map +1 -1
  106. package/lib/index.js +22 -8
  107. package/lib/index.js.map +1 -1
  108. package/lib/lib/font.d.ts +13 -0
  109. package/lib/lib/font.js +17 -0
  110. package/lib/lib/font.js.map +1 -0
  111. package/lib/lib/index.d.ts +3 -0
  112. package/lib/lib/index.js +20 -0
  113. package/lib/lib/index.js.map +1 -0
  114. package/lib/lib/inputTypes.d.ts +20 -0
  115. package/lib/lib/inputTypes.js +57 -0
  116. package/lib/lib/inputTypes.js.map +1 -0
  117. package/lib/lib/utils.d.ts +9 -0
  118. package/lib/lib/utils.js +46 -0
  119. package/lib/lib/utils.js.map +1 -0
  120. package/package.json +6 -13
  121. package/src/AddToDashboardModal.tsx +2 -9
  122. package/src/Chart.tsx +49 -20
  123. package/src/Context.tsx +0 -3
  124. package/src/Dashboard.tsx +2 -3
  125. package/src/PieChart.tsx +2 -2
  126. package/src/QuillProvider.tsx +0 -3
  127. package/src/ReportBuilder.tsx +3 -9
  128. package/src/SQLEditor.tsx +99 -12
  129. package/src/Table.tsx +99 -10
  130. package/src/hooks/useQuill.ts +1 -2
  131. package/src/lib/font.ts +14 -0
  132. package/src/lib/index.ts +3 -0
  133. package/src/lib/inputTypes.ts +81 -0
  134. package/src/lib/utils.tsx +46 -0
  135. package/tsconfig.json +3 -3
  136. package/rollup.config.ts +0 -21
@@ -1,81 +1,20 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __rest = (this && this.__rest) || function (s, e) {
49
- var t = {};
50
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
58
4
  };
59
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
- if (ar || !(i in from)) {
62
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63
- ar[i] = from[i];
64
- }
65
- }
66
- return to.concat(ar || Array.prototype.slice.call(from));
67
- };
68
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatDateBuckets = exports.isArrayOfValidDates = exports.isValidDate = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
69
8
  // @ts-nocheck
70
- import { useContext, useEffect, useState } from 'react';
71
- import { ClientContext, SchemaContext, ThemeContext } from './Context';
72
- import { Formik, Form, Field } from 'formik';
73
- import { differenceInDays, differenceInHours, differenceInMonths, differenceInYears, startOfDay, startOfHour, startOfMonth, startOfYear, } from 'date-fns';
74
- import axios from 'axios';
75
- import Chart from './Chart';
76
- import { XMarkIcon } from '@heroicons/react/20/solid';
9
+ const react_1 = require("react");
10
+ const Context_1 = require("./Context");
11
+ const formik_1 = require("formik");
12
+ const date_fns_1 = require("date-fns");
13
+ const axios_1 = __importDefault(require("axios"));
14
+ const Chart_1 = __importDefault(require("./Chart"));
15
+ const solid_1 = require("@heroicons/react/20/solid");
77
16
  function convertPostgresColumn(column) {
78
- var format;
17
+ let format;
79
18
  switch (column.dataTypeID) {
80
19
  case 20: // int8
81
20
  case 21: // int2
@@ -103,295 +42,248 @@ function convertPostgresColumn(column) {
103
42
  format: format,
104
43
  };
105
44
  }
106
- export default function AddToDashboardModal(_a) {
107
- var _this = this;
108
- var isOpen = _a.isOpen, setIsOpen = _a.setIsOpen, SelectComponent = _a.SelectComponent, TextInputComponent = _a.TextInputComponent, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, rows = _a.rows, columns = _a.columns, query = _a.query, ModalComponent = _a.ModalComponent, formHeaderStyle = _a.formHeaderStyle, formLabelStyle = _a.formLabelStyle;
109
- var theme = useContext(ThemeContext)[0];
110
- var client = useContext(ClientContext)[0];
111
- var _b = useContext(SchemaContext), schema = _b[0], setSchema = _b[1];
112
- useEffect(function () {
113
- var isSubscribed = true;
114
- function getSchema() {
115
- return __awaiter(this, void 0, void 0, function () {
116
- var publicKey, environment, response3;
117
- return __generator(this, function (_a) {
118
- switch (_a.label) {
119
- case 0:
120
- publicKey = client.publicKey, environment = client.environment;
121
- if (!!schema.length) return [3 /*break*/, 2];
122
- return [4 /*yield*/, axios.get("https://quill-344421.uc.r.appspot.com/schema2/".concat(publicKey, "/"), {
123
- headers: {
124
- Authorization: "Bearer ",
125
- environment: environment || undefined,
126
- },
127
- })];
128
- case 1:
129
- response3 = _a.sent();
130
- if (isSubscribed) {
131
- setSchema(response3.data.tables);
132
- }
133
- _a.label = 2;
134
- case 2: return [2 /*return*/];
135
- }
45
+ function AddToDashboardModal({ isOpen, setIsOpen, SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, rows, columns, query, ModalComponent, formHeaderStyle, formLabelStyle, }) {
46
+ const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
47
+ const [client] = (0, react_1.useContext)(Context_1.ClientContext);
48
+ const [schema, setSchema] = (0, react_1.useContext)(Context_1.SchemaContext);
49
+ (0, react_1.useEffect)(() => {
50
+ let isSubscribed = true;
51
+ async function getSchema() {
52
+ const { publicKey, environment } = client;
53
+ if (!schema.length) {
54
+ const response3 = await axios_1.default.get(`https://quill-344421.uc.r.appspot.com/schema2/${publicKey}/`, {
55
+ headers: {
56
+ Authorization: `Bearer `,
57
+ environment: environment || undefined,
58
+ },
136
59
  });
137
- });
60
+ if (isSubscribed) {
61
+ setSchema(response3.data.tables);
62
+ }
63
+ }
138
64
  }
139
65
  if (isSubscribed) {
140
66
  getSchema();
141
67
  }
142
- return function () {
68
+ return () => {
143
69
  isSubscribed = false;
144
70
  };
145
71
  }, [schema]);
146
- var editChart = function (_a) {
147
- var report = _a.report, values = _a.values, yAxisFields = _a.yAxisFields, columns = _a.columns, query = _a.query;
148
- return __awaiter(_this, void 0, void 0, function () {
149
- var publicKey, orgId, authToken, queryEndpoint, queryHeaders, withCredentials, xAxisLabel, yAxisLabel, chartName, chartType, xAxisField, xAxisFormat, dashboardName, dateFieldTable, dateField, i, response;
150
- return __generator(this, function (_b) {
151
- switch (_b.label) {
152
- case 0:
153
- publicKey = client.publicKey, orgId = client.orgId, authToken = client.authToken, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders, withCredentials = client.withCredentials;
154
- xAxisLabel = values.xAxisLabel, yAxisLabel = values.yAxisLabel, chartName = values.chartName, chartType = values.chartType, xAxisField = values.xAxisField, xAxisFormat = values.xAxisFormat, dashboardName = values.dashboardName, dateFieldTable = values.dateFieldTable, dateField = values.dateField;
155
- if (!chartName) {
156
- alert('Please enter a chart name');
157
- return [2 /*return*/];
158
- }
159
- // if (!dashboardName) {
160
- // alert("Please choose a dashboard name");
161
- // return;
162
- // }
163
- // if (!xAxisLabel && chartType !== "pie" && chartType !== "table") {
164
- // alert("Please enter a label for the x-axis");
165
- // return;
166
- // }
167
- // if (!yAxisLabel && chartType !== "pie" && chartType !== "table") {
168
- // alert("Please enter a label for the y-axis");
169
- // return;
170
- // }
171
- for (i = 0; i < yAxisFields.length; i++) {
172
- if (!yAxisFields[i].label && chartType !== 'pie') {
173
- alert("Please enter a label for column '".concat(yAxisFields[i].field, "'"));
174
- return [2 /*return*/];
175
- }
176
- }
177
- if (!client || !organization) {
178
- return [2 /*return*/];
179
- }
180
- if (!queryEndpoint) return [3 /*break*/, 2];
181
- return [4 /*yield*/, axios.post(queryEndpoint, {
182
- metadata: {
183
- name: chartName,
184
- xAxisField: xAxisField,
185
- yAxisFields: yAxisFields,
186
- xAxisLabel: xAxisLabel,
187
- xAxisFormat: xAxisFormat,
188
- yAxisLabel: yAxisLabel,
189
- chartType: chartType,
190
- dashboardName: dashboardName,
191
- columns: columns,
192
- dateField: { table: dateFieldTable, field: dateField },
193
- query: query,
194
- task: 'create',
195
- },
196
- }, { headers: queryHeaders, withCredentials: withCredentials })];
197
- case 1:
198
- response = _b.sent();
199
- return [3 /*break*/, 4];
200
- case 2: return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashedit/".concat(publicKey, "/").concat(orgId, "/"), {
201
- name: chartName,
202
- xAxisField: xAxisField,
203
- yAxisFields: yAxisFields,
204
- xAxisLabel: xAxisLabel,
205
- xAxisFormat: xAxisFormat,
206
- yAxisLabel: yAxisLabel,
207
- chartType: chartType,
208
- dashboardName: dashboardName,
209
- columns: columns,
210
- dateField: { table: dateFieldTable, field: dateField },
211
- query: query,
212
- }, {
213
- headers: {
214
- Authorization: "Bearer ".concat(authToken),
215
- environment: environment || undefined,
216
- },
217
- })];
218
- case 3:
219
- response = _b.sent();
220
- _b.label = 4;
221
- case 4:
222
- if (!response.data) {
223
- return [2 /*return*/];
224
- }
225
- // setDashboard((dashboard) => {
226
- // return {
227
- // ...dashboard,
228
- // [response.data._id]: { ...existingVisualization, ...response.data }
229
- // }
230
- // })
231
- setIsOpen(false);
232
- return [2 /*return*/];
233
- }
72
+ const editChart = async ({ report, values, yAxisFields, columns, query }) => {
73
+ const { publicKey, orgId, authToken, queryEndpoint, queryHeaders } = client;
74
+ const { xAxisLabel, yAxisLabel, chartName, chartType, xAxisField, xAxisFormat, dashboardName, dateFieldTable, dateField, } = values;
75
+ if (!chartName) {
76
+ alert('Please enter a chart name');
77
+ return;
78
+ }
79
+ // if (!dashboardName) {
80
+ // alert("Please choose a dashboard name");
81
+ // return;
82
+ // }
83
+ // if (!xAxisLabel && chartType !== "pie" && chartType !== "table") {
84
+ // alert("Please enter a label for the x-axis");
85
+ // return;
86
+ // }
87
+ // if (!yAxisLabel && chartType !== "pie" && chartType !== "table") {
88
+ // alert("Please enter a label for the y-axis");
89
+ // return;
90
+ // }
91
+ for (let i = 0; i < yAxisFields.length; i++) {
92
+ if (!yAxisFields[i].label && chartType !== 'pie') {
93
+ alert(`Please enter a label for column '${yAxisFields[i].field}'`);
94
+ return;
95
+ }
96
+ }
97
+ if (!client || !organization) {
98
+ return;
99
+ }
100
+ let response;
101
+ if (queryEndpoint) {
102
+ response = await axios_1.default.post(queryEndpoint, {
103
+ metadata: {
104
+ name: chartName,
105
+ xAxisField,
106
+ yAxisFields,
107
+ xAxisLabel,
108
+ xAxisFormat,
109
+ yAxisLabel,
110
+ chartType,
111
+ dashboardName,
112
+ columns,
113
+ dateField: { table: dateFieldTable, field: dateField },
114
+ query: query,
115
+ task: 'create',
116
+ },
117
+ }, { headers: queryHeaders });
118
+ }
119
+ else {
120
+ response = await axios_1.default.post(`https://quill-344421.uc.r.appspot.com/dashedit/${publicKey}/${orgId}/`, {
121
+ name: chartName,
122
+ xAxisField,
123
+ yAxisFields,
124
+ xAxisLabel,
125
+ xAxisFormat,
126
+ yAxisLabel,
127
+ chartType,
128
+ dashboardName,
129
+ columns,
130
+ dateField: { table: dateFieldTable, field: dateField },
131
+ query: query,
132
+ }, {
133
+ headers: {
134
+ Authorization: `Bearer ${authToken}`,
135
+ environment: environment || undefined,
136
+ },
234
137
  });
235
- });
138
+ }
139
+ if (!response.data) {
140
+ return;
141
+ }
142
+ // setDashboard((dashboard) => {
143
+ // return {
144
+ // ...dashboard,
145
+ // [response.data._id]: { ...existingVisualization, ...response.data }
146
+ // }
147
+ // })
148
+ setIsOpen(false);
149
+ // TODO: fire callback instead so user can customize action
150
+ // navigate("/dashboards");
236
151
  };
237
152
  return (
238
153
  // <BigModal theme={theme} showModal={isOpen} setShowModal={setIsOpen}>
239
- _jsx(ModalComponent, __assign({ isOpen: isOpen, title: 'Add to dashboard', onClose: function () { return setIsOpen(false); } }, { children: _jsx(ChartForm, { editChart: editChart, theme: theme, schema: schema, data: rows, fields: columns,
154
+ (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, title: 'Add to dashboard', onClose: () => setIsOpen(false), children: (0, jsx_runtime_1.jsx)(ChartForm, { editChart: editChart, theme: theme, schema: schema, data: rows, fields: columns,
240
155
  // leave null for now
241
156
  report: null, query: query,
242
157
  // organizationName={organization?.name}
243
- SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) }))
158
+ SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) })
244
159
  // </BigModal>
245
160
  );
246
161
  }
247
- function ChartForm(_a) {
248
- var _this = this;
249
- var data = _a.data, fields = _a.fields, theme = _a.theme, saveVisualization = _a.saveVisualization, report = _a.report, editChart = _a.editChart, schema = _a.schema, query = _a.query,
250
- // organizationName,
251
- SelectComponent = _a.SelectComponent, TextInputComponent = _a.TextInputComponent, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, formHeaderStyle = _a.formHeaderStyle, formLabelStyle = _a.formLabelStyle;
252
- var fieldOptions = Object.keys(data[0]).map(function (field) { return ({
162
+ exports.default = AddToDashboardModal;
163
+ function ChartForm({ data, fields, theme, saveVisualization, report, editChart, schema, query,
164
+ // organizationName,
165
+ SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, formHeaderStyle, formLabelStyle, }) {
166
+ const fieldOptions = Object.keys(data[0]).map(field => ({
253
167
  value: field,
254
168
  label: field,
255
- }); });
256
- var _b = useState([]), dateFieldOptions = _b[0], setDateFieldOptions = _b[1];
257
- useEffect(function () {
258
- var fetchReferencedTables = function () { return __awaiter(_this, void 0, void 0, function () {
259
- var result;
260
- return __generator(this, function (_a) {
261
- switch (_a.label) {
262
- case 0: return [4 /*yield*/, getReferencedTables(query, 'PostgresQL', schema)];
263
- case 1:
264
- result = _a.sent();
265
- setDateFieldOptions(result);
266
- return [2 /*return*/];
267
- }
268
- });
269
- }); };
169
+ }));
170
+ const [dateFieldOptions, setDateFieldOptions] = (0, react_1.useState)([]);
171
+ (0, react_1.useEffect)(() => {
172
+ const fetchReferencedTables = async () => {
173
+ const result = await getReferencedTables(query, 'PostgresQL', schema);
174
+ setDateFieldOptions(result);
175
+ };
270
176
  fetchReferencedTables();
271
177
  }, [query, schema]);
272
- return (_jsx(Formik, __assign({ initialValues: {
273
- xAxisField: (report === null || report === void 0 ? void 0 : report.xAxisField) || fieldOptions[0].value,
274
- xAxisLabel: (report === null || report === void 0 ? void 0 : report.xAxisLabel) || '',
275
- xAxisFormat: (report === null || report === void 0 ? void 0 : report.xAxisFormat) || FORMAT_OPTIONS[0].value,
276
- yAxisLabel: (report === null || report === void 0 ? void 0 : report.yAxisLabel) || '',
277
- chartName: report === null || report === void 0 ? void 0 : report.name,
278
- chartType: (report === null || report === void 0 ? void 0 : report.chartType) || 'bar',
178
+ return ((0, jsx_runtime_1.jsx)(formik_1.Formik, { initialValues: {
179
+ xAxisField: report?.xAxisField || fieldOptions[0].value,
180
+ xAxisLabel: report?.xAxisLabel || '',
181
+ xAxisFormat: report?.xAxisFormat || FORMAT_OPTIONS[0].value,
182
+ yAxisLabel: report?.yAxisLabel || '',
183
+ chartName: report?.name,
184
+ chartType: report?.chartType || 'bar',
279
185
  xAxisFieldLabel: '',
280
- dashboardName: (report === null || report === void 0 ? void 0 : report.dashboardName) || '',
186
+ dashboardName: report?.dashboardName || '',
281
187
  dateFieldTable: (dateFieldOptions.length && dateFieldOptions[0].name) || '',
282
188
  dateField: (dateFieldOptions.length && dateFieldOptions[0].columns[0].name) ||
283
189
  '',
284
- template: (report === null || report === void 0 ? void 0 : report.template) || false,
285
- }, onSubmit: function () { } }, { children: function (_a) {
286
- var values = _a.values, isSubmitting = _a.isSubmitting, setFieldValue = _a.setFieldValue;
287
- return (_jsx(FormikForm, { values: values, isSubmitting: isSubmitting, data: data, fieldOptions: fieldOptions, dateFieldOptions: dateFieldOptions, theme: theme, saveVisualization: saveVisualization, report: report, editChart: editChart, fields: fields, query: query, setFieldValue: setFieldValue,
288
- // organizationName={organizationName}
289
- SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }));
290
- } })));
190
+ template: report?.template || false,
191
+ }, onSubmit: () => { }, children: ({ values, isSubmitting, setFieldValue }) => ((0, jsx_runtime_1.jsx)(FormikForm, { values: values, isSubmitting: isSubmitting, data: data, fieldOptions: fieldOptions, dateFieldOptions: dateFieldOptions, theme: theme, saveVisualization: saveVisualization, report: report, editChart: editChart, fields: fields, query: query, setFieldValue: setFieldValue,
192
+ // organizationName={organizationName}
193
+ SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle })) }));
291
194
  }
292
- export function isValidDate(d) {
195
+ function isValidDate(d) {
293
196
  return d instanceof Date && !isNaN(d);
294
197
  }
295
- export var isArrayOfValidDates = function (arr, field) {
296
- return arr.every(function (d) { return new Date(d[field]) instanceof Date && !isNaN(new Date(d[field])); });
297
- };
298
- export function formatDateBuckets(startDate, endDate) {
198
+ exports.isValidDate = isValidDate;
199
+ const isArrayOfValidDates = (arr, field) => arr.every(d => new Date(d[field]) instanceof Date && !isNaN(new Date(d[field])));
200
+ exports.isArrayOfValidDates = isArrayOfValidDates;
201
+ function formatDateBuckets(startDate, endDate) {
299
202
  // Calculate the distance in hours
300
- var distanceInHours = Math.abs(differenceInHours(endDate, startDate));
203
+ const distanceInHours = Math.abs((0, date_fns_1.differenceInHours)(endDate, startDate));
301
204
  // Check if the distance is less than or equal to one hour
302
205
  if (distanceInHours <= 1) {
303
206
  return {
304
207
  unit: 'hour',
305
208
  format: 'h a',
306
- startOf: startOfHour,
209
+ startOf: date_fns_1.startOfHour,
307
210
  };
308
211
  }
309
212
  // Calculate the distance in days
310
- var distanceInDays = Math.abs(differenceInDays(endDate, startDate));
213
+ const distanceInDays = Math.abs((0, date_fns_1.differenceInDays)(endDate, startDate));
311
214
  // Check if the distance is less than or equal to one day
312
215
  if (distanceInDays <= 1) {
313
216
  return {
314
217
  unit: 'day',
315
218
  format: 'MMM d',
316
- startOf: startOfDay,
219
+ startOf: date_fns_1.startOfDay,
317
220
  };
318
221
  }
319
222
  // Calculate the distance in months
320
- var distanceInMonths = Math.abs(differenceInMonths(endDate, startDate));
223
+ const distanceInMonths = Math.abs((0, date_fns_1.differenceInMonths)(endDate, startDate));
321
224
  // Check if the distance is less than or equal to one month
322
225
  if (distanceInMonths <= 1) {
323
226
  return {
324
227
  unit: 'month',
325
228
  format: 'MMM yyyy',
326
- startOf: startOfMonth,
229
+ startOf: date_fns_1.startOfMonth,
327
230
  };
328
231
  }
329
232
  // Calculate the distance in years
330
- var distanceInYears = Math.abs(differenceInYears(endDate, startDate));
233
+ const distanceInYears = Math.abs((0, date_fns_1.differenceInYears)(endDate, startDate));
331
234
  // Check if the distance is less than or equal to one year
332
235
  if (distanceInYears <= 1) {
333
236
  return {
334
237
  unit: 'year',
335
238
  format: 'yyyy',
336
- startOf: startOfYear,
239
+ startOf: date_fns_1.startOfYear,
337
240
  };
338
241
  }
339
242
  // Otherwise, the distance is more than one year
340
243
  return {
341
244
  unit: 'year',
342
245
  format: 'yyyy',
343
- startOf: startOfYear,
246
+ startOf: date_fns_1.startOfYear,
344
247
  };
345
248
  }
346
- var FormTextInput = function (_a) {
347
- var field = _a.field, form = _a.form, props = __rest(_a, ["field", "form"]);
348
- var theme = props.theme, wider = props.wider;
349
- return (_jsx("input", __assign({ className: "px-[12px] text-sm h-[38px] py-1.5 shadow-sm w-[245px] border-[#E7E7E7] ".concat('text-[#212121]', " border-[1px] bg-[white] rounded-md"), type: "text" }, field, props)));
249
+ exports.formatDateBuckets = formatDateBuckets;
250
+ const FormTextInput = ({ field, form, ...props }) => {
251
+ const { theme, wider } = props;
252
+ return ((0, jsx_runtime_1.jsx)("input", { className: `px-[12px] text-sm h-[38px] py-1.5 shadow-sm w-[245px] border-[#E7E7E7] ${'text-[#212121]'} border-[1px] bg-[white] rounded-md`, type: "text", ...field, ...props }));
350
253
  };
351
- var POSTGRES_DATE_TYPES = [
254
+ const POSTGRES_DATE_TYPES = [
352
255
  'timestamp',
353
256
  'date',
354
257
  'timestamptz',
355
258
  'time',
356
259
  'timetz',
357
260
  ];
358
- function getReferencedTables(sqlQuery, databaseType, dbTables) {
359
- return __awaiter(this, void 0, void 0, function () {
360
- var tables, withAliases, response, ast, i, j, tablesInQuery;
361
- return __generator(this, function (_a) {
362
- switch (_a.label) {
363
- case 0:
364
- tables = [];
365
- withAliases = [];
366
- return [4 /*yield*/, axios.post('https://quill-344421.uc.r.appspot.com/astify', { query: sqlQuery })];
367
- case 1:
368
- response = _a.sent();
369
- ast = response.data.ast;
370
- ast = ast.length ? ast[0] : ast;
371
- if (ast.with && ast.with.length) {
372
- for (i = 0; i < ast.with.length; i++) {
373
- withAliases.push(ast.with[i].name.value);
374
- for (j = 0; j < ast.with[i].stmt.from.length; j++)
375
- tables.push(ast.with[i].stmt.from[j].table);
376
- }
377
- }
378
- tablesInQuery = __spreadArray(__spreadArray([], tables, true), ast.from.map(function (elem) { return elem.table; }), true).filter(function (elem) { return !withAliases.includes(elem); });
379
- return [2 /*return*/, dbTables
380
- .filter(function (table) { return tablesInQuery.includes(table.displayName); })
381
- .map(function (table) {
382
- return {
383
- name: table.displayName,
384
- columns: table.columns.filter(function (column) {
385
- return POSTGRES_DATE_TYPES.includes(column.fieldType);
386
- }),
387
- };
388
- })
389
- .filter(function (table) { return table.columns.length > 0; })];
390
- }
391
- });
392
- });
261
+ async function getReferencedTables(sqlQuery, databaseType, dbTables) {
262
+ // const parser = new Parser();
263
+ let tables = [];
264
+ let withAliases = [];
265
+ const response = await axios_1.default.post('https://quill-344421.uc.r.appspot.com/astify', { query: sqlQuery });
266
+ let ast = response.data.ast;
267
+ ast = ast.length ? ast[0] : ast;
268
+ if (ast.with && ast.with.length) {
269
+ for (let i = 0; i < ast.with.length; i++) {
270
+ withAliases.push(ast.with[i].name.value);
271
+ for (let j = 0; j < ast.with[i].stmt.from.length; j++)
272
+ tables.push(ast.with[i].stmt.from[j].table);
273
+ }
274
+ }
275
+ const tablesInQuery = [...tables, ...ast.from.map(elem => elem.table)].filter(elem => !withAliases.includes(elem));
276
+ return dbTables
277
+ .filter(table => tablesInQuery.includes(table.displayName))
278
+ .map(table => {
279
+ return {
280
+ name: table.displayName,
281
+ columns: table.columns.filter(column => POSTGRES_DATE_TYPES.includes(column.fieldType)),
282
+ };
283
+ })
284
+ .filter(table => table.columns.length > 0);
393
285
  }
394
- var FORMAT_OPTIONS = [
286
+ const FORMAT_OPTIONS = [
395
287
  { value: 'whole_number', label: 'whole number' },
396
288
  { value: 'one_decimal_place', label: 'one decimal place' },
397
289
  { value: 'dollar_amount', label: 'dollar amount' },
@@ -403,10 +295,9 @@ var FORMAT_OPTIONS = [
403
295
  { value: 'percent', label: 'percent' },
404
296
  { value: 'string', label: 'string' },
405
297
  ];
406
- function FormikForm(_a) {
407
- var values = _a.values, isSubmitting = _a.isSubmitting, data = _a.data, fieldOptions = _a.fieldOptions, dateFieldOptions = _a.dateFieldOptions, theme = _a.theme, report = _a.report, editChart = _a.editChart, fields = _a.fields, query = _a.query, SelectComponent = _a.SelectComponent, TextInputComponent = _a.TextInputComponent, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, setFieldValue = _a.setFieldValue, organizationName = _a.organizationName, formHeaderStyle = _a.formHeaderStyle, formLabelStyle = _a.formLabelStyle;
408
- var _b = useState({}), chartConfig = _b[0], setChartConfig = _b[1];
409
- var _c = useState(report
298
+ function FormikForm({ values, isSubmitting, data, fieldOptions, dateFieldOptions, theme, report, editChart, fields, query, SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, setFieldValue, organizationName, formHeaderStyle, formLabelStyle, }) {
299
+ const [chartConfig, setChartConfig] = (0, react_1.useState)({});
300
+ const [yAxisFields, setYAxisFields] = (0, react_1.useState)(report
410
301
  ? report.yAxisFields
411
302
  : [
412
303
  {
@@ -416,162 +307,157 @@ function FormikForm(_a) {
416
307
  label: '',
417
308
  format: 'whole_number',
418
309
  },
419
- ]), yAxisFields = _c[0], setYAxisFields = _c[1];
420
- var _d = useState(report && report.columns.length
310
+ ]);
311
+ const [columns, setColumns] = (0, react_1.useState)(report && report.columns.length
421
312
  ? report.columns
422
- : (fields === null || fields === void 0 ? void 0 : fields.length)
423
- ? fields.map(function (field) { return convertPostgresColumn(field); })
424
- : []), columns = _d[0], setColumns = _d[1];
425
- var handleAddYAxisField = function () {
426
- setYAxisFields(__spreadArray(__spreadArray([], yAxisFields, true), [
313
+ : fields?.length
314
+ ? fields.map(field => convertPostgresColumn(field))
315
+ : []);
316
+ const handleAddYAxisField = () => {
317
+ setYAxisFields([
318
+ ...yAxisFields,
427
319
  { label: '', field: '', format: 'whole_number' },
428
- ], false));
320
+ ]);
429
321
  };
430
- var handleDeleteYAxisField = function (index) {
431
- setYAxisFields(function (yAxisFields) { return yAxisFields.filter(function (_, i) { return index !== i; }); });
322
+ const handleDeleteYAxisField = index => {
323
+ setYAxisFields(yAxisFields => yAxisFields.filter((_, i) => index !== i));
432
324
  };
433
- var handleYAxisFieldChange = function (index, value) {
434
- var newYAxisFields = __spreadArray([], yAxisFields, true);
435
- newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { field: value });
325
+ const handleYAxisFieldChange = (index, value) => {
326
+ const newYAxisFields = [...yAxisFields];
327
+ newYAxisFields[index] = { ...newYAxisFields[index], field: value };
436
328
  setYAxisFields(newYAxisFields);
437
329
  };
438
- var handleYAxisFieldFormatChange = function (index, value) {
439
- var newYAxisFields = __spreadArray([], yAxisFields, true);
440
- newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { format: value });
330
+ const handleYAxisFieldFormatChange = (index, value) => {
331
+ const newYAxisFields = [...yAxisFields];
332
+ newYAxisFields[index] = { ...newYAxisFields[index], format: value };
441
333
  setYAxisFields(newYAxisFields);
442
334
  };
443
- var handleYAxisFieldLabelChange = function (index, value) {
444
- var newYAxisFields = __spreadArray([], yAxisFields, true);
445
- newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { label: value });
335
+ const handleYAxisFieldLabelChange = (index, value) => {
336
+ const newYAxisFields = [...yAxisFields];
337
+ newYAxisFields[index] = { ...newYAxisFields[index], label: value };
446
338
  setYAxisFields(newYAxisFields);
447
339
  };
448
- var handleColumnFieldChange = function (index, value) {
449
- var newColumns = __spreadArray([], columns, true);
450
- newColumns[index] = __assign(__assign({}, newColumns[index]), { field: value });
340
+ const handleColumnFieldChange = (index, value) => {
341
+ const newColumns = [...columns];
342
+ newColumns[index] = { ...newColumns[index], field: value };
451
343
  setColumns(newColumns);
452
344
  };
453
- var handleColumnFormatChange = function (index, value) {
454
- var newColumns = __spreadArray([], columns, true);
455
- newColumns[index] = __assign(__assign({}, newColumns[index]), { format: value });
345
+ const handleColumnFormatChange = (index, value) => {
346
+ const newColumns = [...columns];
347
+ newColumns[index] = { ...newColumns[index], format: value };
456
348
  setColumns(newColumns);
457
349
  };
458
- var handleColumnLabelChange = function (index, value) {
459
- var newColumns = __spreadArray([], columns, true);
460
- newColumns[index] = __assign(__assign({}, newColumns[index]), { label: value });
350
+ const handleColumnLabelChange = (index, value) => {
351
+ const newColumns = [...columns];
352
+ newColumns[index] = { ...newColumns[index], label: value };
461
353
  setColumns(newColumns);
462
354
  };
463
- useEffect(function () {
464
- setChartConfig(__assign(__assign({}, values), { yAxisFields: yAxisFields, rows: data }));
355
+ (0, react_1.useEffect)(() => {
356
+ setChartConfig({ ...values, yAxisFields: yAxisFields, rows: data });
465
357
  }, [values, yAxisFields]);
466
358
  // console.log('VIBE: ', { report, values, yAxisFields, columns, query });
467
- return (_jsx(Form, __assign({ style: { display: 'inline-block' } }, { children: _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsxs("div", __assign({ style: {
359
+ return ((0, jsx_runtime_1.jsx)(formik_1.Form, { style: { display: 'inline-block' }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
468
360
  display: 'flex',
469
361
  flexDirection: 'column',
470
- } }, { children: [_jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: { marginLeft: -25 } }, { children: Object.keys(chartConfig).length > 0 && (_jsx(Chart, { chartId: "646e37a660feef000be67a93", config: chartConfig, colors: theme.chartColors, containerStyle: {
362
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { marginLeft: -25 }, children: Object.keys(chartConfig).length > 0 && ((0, jsx_runtime_1.jsx)(Chart_1.default, { chartId: "646e37a660feef000be67a93", config: chartConfig, colors: theme.chartColors, containerStyle: {
471
363
  width: '100%',
472
364
  height: 300,
473
- } })) })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
365
+ } })) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: formHeaderStyle || {
474
366
  fontFamily: theme.fontFamily,
475
367
  color: theme.primaryTextColor,
476
368
  fontSize: theme.fontSize + 2,
477
369
  fontWeight: 600,
478
370
  marginTop: 20,
479
- } }, { children: 'Chart' })), _jsxs("div", __assign({ style: {
371
+ }, children: 'Chart' }), (0, jsx_runtime_1.jsxs)("div", { style: {
480
372
  display: 'flex',
481
373
  flexDirection: 'row',
482
374
  alignItems: 'center',
483
- } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
375
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
484
376
  fontSize: '14px',
485
377
  marginBottom: '6px',
486
378
  fontWeight: '600',
487
379
  marginTop: 8,
488
380
  color: theme.secondaryTextColor,
489
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
490
- } }, { children: "Name" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "chartName", component: TextInputComponent, theme: theme, wider: true }) }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
381
+ fontFamily: theme?.fontFamily,
382
+ }, children: "Name" }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: "chartName", component: TextInputComponent, theme: theme, wider: true }) })] }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
491
383
  fontFamily: theme.fontFamily,
492
384
  color: theme.secondaryTextColor,
493
385
  fontSize: theme.fontSize,
494
386
  fontWeight: theme.labelFontWeight,
495
387
  marginTop: 8,
496
388
  marginBottom: 6,
497
- } }, { children: "Dashboard name" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "dashboardName", component: TextInputComponent, theme: theme, wider: true }) }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
389
+ }, children: "Dashboard name" }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: "dashboardName", component: TextInputComponent, theme: theme, wider: true }) })] }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
498
390
  fontFamily: theme.fontFamily,
499
391
  color: theme.secondaryTextColor,
500
392
  fontSize: theme.fontSize,
501
393
  fontWeight: theme.labelFontWeight,
502
394
  marginTop: 8,
503
- } }, { children: "Chart type" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "chartType", component: SelectComponent, theme: theme, options: [
395
+ }, children: "Chart type" }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: "chartType", component: SelectComponent, theme: theme, options: [
504
396
  { label: 'bar', value: 'bar' },
505
397
  { label: 'line', value: 'line' },
506
398
  { label: 'column', value: 'column' },
507
399
  { label: 'pie', value: 'pie' },
508
400
  { label: 'metric', value: 'metric' },
509
401
  { label: 'table', value: 'table' },
510
- ] }) }))] }))] }))] })), _jsx("div", __assign({ style: {
402
+ ] }) })] })] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
511
403
  display: 'flex',
512
404
  flexDirection: 'row',
513
405
  alignItems: 'center',
514
406
  // justifyContent: 'space-between',
515
407
  marginTop: 20,
516
- } }, { children: values.chartType !== 'table' && (_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
408
+ }, children: values.chartType !== 'table' && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
517
409
  fontFamily: theme.fontFamily,
518
410
  color: theme.secondaryTextColor,
519
411
  fontSize: theme.fontSize,
520
412
  fontWeight: theme.labelFontWeight,
521
- } }, { children: values.chartType === 'pie'
413
+ }, children: values.chartType === 'pie'
522
414
  ? 'Category column'
523
- : 'x-axis column' })), _jsx("div", { style: { height: 6 } }), _jsxs("div", __assign({ style: {
415
+ : 'x-axis column' }), (0, jsx_runtime_1.jsx)("div", { style: { height: 6 } }), (0, jsx_runtime_1.jsxs)("div", { style: {
524
416
  display: 'flex',
525
417
  flexDirection: 'row',
526
418
  alignItems: 'center',
527
- } }, { children: [_jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "xAxisField", component: SelectComponent, theme: theme, options: fieldOptions }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "xAxisLabel", component: TextInputComponent, theme: theme }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "xAxisFormat", component: SelectComponent, theme: theme, options: FORMAT_OPTIONS }) }))] }))] }))) })), _jsxs("div", __assign({ style: {
419
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: "xAxisField", component: SelectComponent, theme: theme, options: fieldOptions }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: "xAxisLabel", component: TextInputComponent, theme: theme }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: "xAxisFormat", component: SelectComponent, theme: theme, options: FORMAT_OPTIONS }) })] })] })) }), (0, jsx_runtime_1.jsxs)("div", { style: {
528
420
  display: 'flex',
529
421
  flexDirection: 'row',
530
422
  alignItems: 'flex-start',
531
423
  // justifyContent: 'space-between',
532
424
  marginTop: 20,
533
- } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
425
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
534
426
  fontFamily: theme.fontFamily,
535
427
  color: theme.secondaryTextColor,
536
428
  fontSize: theme.fontSize,
537
429
  fontWeight: theme.labelFontWeight,
538
430
  minWidth: 200,
539
- } }, { children: values.chartType === 'table'
431
+ }, children: values.chartType === 'table'
540
432
  ? 'Columns'
541
433
  : values.chartType === 'pie'
542
434
  ? 'Quantity column'
543
- : 'y-axis columns' })), _jsxs("div", __assign({ style: {
435
+ : 'y-axis columns' }), (0, jsx_runtime_1.jsxs)("div", { style: {
544
436
  display: 'flex',
545
437
  flexDirection: 'column',
546
- } }, { children: [yAxisFields.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
438
+ }, children: [yAxisFields.map((yAxisField, index) => ((0, jsx_runtime_1.jsx)("div", { style: {
547
439
  display: 'flex',
548
440
  flexDirection: 'row',
549
441
  alignItems: 'center',
550
442
  marginTop: index === 0 ? 6 : 10,
551
- } }, { children: _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "yAxisField-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.field, onChange: function (option) { return handleYAxisFieldChange(index, option); }, options: fieldOptions }) })) }), "yAxisField-".concat(index))); }), values.chartType !== 'pie' && (_jsx("div", __assign({ style: { marginTop: 12 } }, { children: _jsx(SecondaryButtonComponent, { onClick: handleAddYAxisField, label: "Add column +" }) }))), _jsx("div", { style: { height: 10 } })] }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: {
443
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: `yAxisField-${index}`, component: SelectComponent, theme: theme, value: yAxisField.field, onChange: option => handleYAxisFieldChange(index, option), options: fieldOptions }) }) }, `yAxisField-${index}`))), values.chartType !== 'pie' && ((0, jsx_runtime_1.jsx)("div", { style: { marginTop: 12 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAddYAxisField, label: "Add column +" }) })), (0, jsx_runtime_1.jsx)("div", { style: { height: 10 } })] })] }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsxs)("div", { style: {
552
444
  display: 'flex',
553
445
  flexDirection: 'column',
554
446
  justifyContent: 'flex-start',
555
- } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
447
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
556
448
  fontFamily: theme.fontFamily,
557
449
  color: 'transparent',
558
450
  fontSize: theme.fontSize,
559
451
  fontWeight: theme.labelFontWeight,
560
452
  minWidth: 200,
561
453
  // marginBottom: 10,
562
- } }, { children: "y-axis label" })), values.chartType !== 'pie' &&
563
- yAxisFields.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
454
+ }, children: "y-axis label" }), values.chartType !== 'pie' &&
455
+ yAxisFields.map((yAxisField, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
564
456
  display: 'flex',
565
457
  flexDirection: 'row',
566
458
  alignItems: 'center',
567
459
  marginTop: index === 0 ? 6 : 10,
568
- } }, { children: [_jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "yAxisField-".concat(index), component: TextInputComponent, theme: theme, placeholder: "Enter column label", value: yAxisField.label, onChange: function (event) {
569
- return handleYAxisFieldLabelChange(index, event.target.value);
570
- } }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "yAxisFieldFormat-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.format, onChange: function (option) {
571
- return handleYAxisFieldFormatChange(index, option);
572
- }, options: FORMAT_OPTIONS }) })), _jsx("div", __assign({ onClick: function () {
573
- return index > 0 ? handleDeleteYAxisField(index) : undefined;
574
- }, style: {
460
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: `yAxisField-${index}`, component: TextInputComponent, theme: theme, placeholder: "Enter column label", value: yAxisField.label, onChange: event => handleYAxisFieldLabelChange(index, event.target.value) }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: `yAxisFieldFormat-${index}`, component: SelectComponent, theme: theme, value: yAxisField.format, onChange: option => handleYAxisFieldFormatChange(index, option), options: FORMAT_OPTIONS }) }), (0, jsx_runtime_1.jsx)("div", { onClick: () => index > 0 ? handleDeleteYAxisField(index) : undefined, style: {
575
461
  cursor: index > 0 ? 'pointer' : undefined,
576
462
  paddingLeft: 6,
577
463
  paddingTop: 12,
@@ -581,58 +467,52 @@ function FormikForm(_a) {
581
467
  display: 'flex',
582
468
  alignItems: 'center',
583
469
  justifyContent: 'center',
584
- } }, { children: _jsx(XMarkIcon, { style: {
470
+ }, children: (0, jsx_runtime_1.jsx)(solid_1.XMarkIcon, { style: {
585
471
  height: '20px',
586
472
  width: '20px',
587
473
  color: index > 0
588
- ? theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor
474
+ ? theme?.secondaryTextColor
589
475
  : 'rgba(0,0,0,0)',
590
- }, "aria-hidden": "true" }) }))] }), "yAxisField-".concat(index))); })] }))] })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
476
+ }, "aria-hidden": "true" }) })] }, `yAxisField-${index}`)))] })] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: formHeaderStyle || {
591
477
  fontFamily: theme.fontFamily,
592
478
  color: theme.primaryTextColor,
593
479
  fontSize: theme.fontSize + 2,
594
480
  fontWeight: 600,
595
- } }, { children: 'Table' })), _jsxs("div", __assign({ style: {
481
+ }, children: 'Table' }), (0, jsx_runtime_1.jsxs)("div", { style: {
596
482
  display: 'flex',
597
483
  flexDirection: 'row',
598
484
  alignItems: 'flex-start',
599
485
  // justifyContent: 'space-between',
600
486
  // marginTop: 8,
601
- } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
487
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
602
488
  fontFamily: theme.fontFamily,
603
489
  color: theme.secondaryTextColor,
604
490
  fontSize: theme.fontSize,
605
491
  fontWeight: theme.labelFontWeight,
606
- } }, { children: 'Columns' })), _jsxs("div", __assign({ style: {
492
+ }, children: 'Columns' }), (0, jsx_runtime_1.jsxs)("div", { style: {
607
493
  display: 'flex',
608
494
  flexDirection: 'column',
609
- } }, { children: [columns.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
495
+ }, children: [columns.map((yAxisField, index) => ((0, jsx_runtime_1.jsx)("div", { style: {
610
496
  display: 'flex',
611
497
  flexDirection: 'row',
612
498
  alignItems: 'center',
613
499
  marginTop: index === 0 ? 6 : 10,
614
- } }, { children: _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "column-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.field, onChange: function (option) {
615
- return handleColumnFieldChange(index, option);
616
- }, options: fieldOptions }) })) }), "column-".concat(index))); }), _jsx("div", { style: { height: 10 } })] }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: {
500
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: `column-${index}`, component: SelectComponent, theme: theme, value: yAxisField.field, onChange: option => handleColumnFieldChange(index, option), options: fieldOptions }) }) }, `column-${index}`))), (0, jsx_runtime_1.jsx)("div", { style: { height: 10 } })] })] }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsxs)("div", { style: {
617
501
  display: 'flex',
618
502
  flexDirection: 'column',
619
503
  justifyContent: 'flex-start',
620
- } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
504
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
621
505
  fontFamily: theme.fontFamily,
622
506
  color: 'transparent',
623
507
  fontSize: theme.fontSize,
624
508
  fontWeight: theme.labelFontWeight,
625
509
  minWidth: 200,
626
510
  // marginBottom: 10,
627
- } }, { children: "label" })), columns.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
511
+ }, children: "label" }), columns.map((yAxisField, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
628
512
  display: 'flex',
629
513
  flexDirection: 'row',
630
514
  alignItems: 'center',
631
515
  marginTop: index === 0 ? 6 : 10,
632
- } }, { children: [_jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "columnlabel-".concat(index), component: TextInputComponent, theme: theme, placeholder: "Enter column label", value: yAxisField.label, onChange: function (event) {
633
- return handleColumnLabelChange(index, event.target.value);
634
- } }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "columnFormat-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.format, onChange: function (option) { return handleColumnFormatChange(index, option); }, options: FORMAT_OPTIONS }) }))] }), "column-".concat(index))); })] }))] })), _jsx("div", { style: { height: 20 } }), _jsx("div", { style: { height: 20 } }), _jsx(ButtonComponent, { onClick: function () {
635
- return editChart({ report: report, values: values, yAxisFields: yAxisFields, columns: columns, query: query });
636
- }, label: report ? 'Save changes' : 'Add to dashboard' })] })) })));
516
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: `columnlabel-${index}`, component: TextInputComponent, theme: theme, placeholder: "Enter column label", value: yAxisField.label, onChange: event => handleColumnLabelChange(index, event.target.value) }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { minWidth: 200 }, children: (0, jsx_runtime_1.jsx)(formik_1.Field, { name: `columnFormat-${index}`, component: SelectComponent, theme: theme, value: yAxisField.format, onChange: option => handleColumnFormatChange(index, option), options: FORMAT_OPTIONS }) })] }, `column-${index}`)))] })] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => editChart({ report, values, yAxisFields, columns, query }), label: report ? 'Save changes' : 'Add to dashboard' })] }) }));
637
517
  }
638
518
  //# sourceMappingURL=AddToDashboardModal.js.map