@quillsql/react 1.7.1 → 1.7.2

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 (105) hide show
  1. package/lib/AddToDashboardModal.js +369 -249
  2. package/lib/AddToDashboardModal.js.map +1 -1
  3. package/lib/BarList.js +109 -92
  4. package/lib/BarList.js.map +1 -1
  5. package/lib/Chart.js +414 -364
  6. package/lib/Chart.js.map +1 -1
  7. package/lib/Context.js +84 -92
  8. package/lib/Context.js.map +1 -1
  9. package/lib/Dashboard.js +209 -181
  10. package/lib/Dashboard.js.map +1 -1
  11. package/lib/DateRangePicker/Calendar.js +91 -87
  12. package/lib/DateRangePicker/Calendar.js.map +1 -1
  13. package/lib/DateRangePicker/DateRangePicker.js +68 -70
  14. package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
  15. package/lib/DateRangePicker/DateRangePickerButton.js +57 -46
  16. package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
  17. package/lib/DateRangePicker/dateRangePickerUtils.js +99 -105
  18. package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
  19. package/lib/DateRangePicker/index.js +1 -8
  20. package/lib/DateRangePicker/index.js.map +1 -1
  21. package/lib/PieChart.js +225 -221
  22. package/lib/PieChart.js.map +1 -1
  23. package/lib/QuillProvider.js +18 -8
  24. package/lib/QuillProvider.js.map +1 -1
  25. package/lib/ReportBuilder.js +526 -430
  26. package/lib/ReportBuilder.js.map +1 -1
  27. package/lib/SQLEditor.js +268 -183
  28. package/lib/SQLEditor.js.map +1 -1
  29. package/lib/Table.js +256 -213
  30. package/lib/Table.js.map +1 -1
  31. package/lib/TableChart.js +75 -76
  32. package/lib/TableChart.js.map +1 -1
  33. package/lib/assets/ArrowDownHeadIcon.js +28 -5
  34. package/lib/assets/ArrowDownHeadIcon.js.map +1 -1
  35. package/lib/assets/ArrowDownIcon.js +28 -5
  36. package/lib/assets/ArrowDownIcon.js.map +1 -1
  37. package/lib/assets/ArrowDownRightIcon.js +28 -5
  38. package/lib/assets/ArrowDownRightIcon.js.map +1 -1
  39. package/lib/assets/ArrowLeftHeadIcon.js +28 -5
  40. package/lib/assets/ArrowLeftHeadIcon.js.map +1 -1
  41. package/lib/assets/ArrowRightHeadIcon.js +28 -5
  42. package/lib/assets/ArrowRightHeadIcon.js.map +1 -1
  43. package/lib/assets/ArrowRightIcon.js +28 -5
  44. package/lib/assets/ArrowRightIcon.js.map +1 -1
  45. package/lib/assets/ArrowUpHeadIcon.js +28 -5
  46. package/lib/assets/ArrowUpHeadIcon.js.map +1 -1
  47. package/lib/assets/ArrowUpIcon.js +28 -5
  48. package/lib/assets/ArrowUpIcon.js.map +1 -1
  49. package/lib/assets/ArrowUpRightIcon.js +28 -5
  50. package/lib/assets/ArrowUpRightIcon.js.map +1 -1
  51. package/lib/assets/CalendarIcon.js +28 -5
  52. package/lib/assets/CalendarIcon.js.map +1 -1
  53. package/lib/assets/DoubleArrowLeftHeadIcon.js +28 -5
  54. package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -1
  55. package/lib/assets/DoubleArrowRightHeadIcon.js +28 -5
  56. package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -1
  57. package/lib/assets/ExclamationFilledIcon.js +28 -5
  58. package/lib/assets/ExclamationFilledIcon.js.map +1 -1
  59. package/lib/assets/LoadingSpinner.js +28 -5
  60. package/lib/assets/LoadingSpinner.js.map +1 -1
  61. package/lib/assets/SearchIcon.js +28 -5
  62. package/lib/assets/SearchIcon.js.map +1 -1
  63. package/lib/assets/XCircleIcon.js +28 -5
  64. package/lib/assets/XCircleIcon.js.map +1 -1
  65. package/lib/assets/index.js +16 -38
  66. package/lib/assets/index.js.map +1 -1
  67. package/lib/components/BigModal/BigModal.js +43 -45
  68. package/lib/components/BigModal/BigModal.js.map +1 -1
  69. package/lib/components/Dropdown/Dropdown.js +53 -57
  70. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  71. package/lib/components/Dropdown/DropdownItem.js +40 -43
  72. package/lib/components/Dropdown/DropdownItem.js.map +1 -1
  73. package/lib/components/Dropdown/index.js +2 -10
  74. package/lib/components/Dropdown/index.js.map +1 -1
  75. package/lib/components/Modal/Modal.js +43 -45
  76. package/lib/components/Modal/Modal.js.map +1 -1
  77. package/lib/components/Modal/index.js +1 -8
  78. package/lib/components/Modal/index.js.map +1 -1
  79. package/lib/components/selectUtils.js +15 -20
  80. package/lib/components/selectUtils.js.map +1 -1
  81. package/lib/contexts/BaseColorContext.js +3 -5
  82. package/lib/contexts/BaseColorContext.js.map +1 -1
  83. package/lib/contexts/HoveredValueContext.js +3 -5
  84. package/lib/contexts/HoveredValueContext.js.map +1 -1
  85. package/lib/contexts/RootStylesContext.js +3 -5
  86. package/lib/contexts/RootStylesContext.js.map +1 -1
  87. package/lib/contexts/SelectedValueContext.js +3 -5
  88. package/lib/contexts/SelectedValueContext.js.map +1 -1
  89. package/lib/contexts/index.js +4 -14
  90. package/lib/contexts/index.js.map +1 -1
  91. package/lib/hooks/index.js +4 -14
  92. package/lib/hooks/index.js.map +1 -1
  93. package/lib/hooks/useInternalState.js +7 -9
  94. package/lib/hooks/useInternalState.js.map +1 -1
  95. package/lib/hooks/useOnClickOutside.js +6 -8
  96. package/lib/hooks/useOnClickOutside.js.map +1 -1
  97. package/lib/hooks/useOnWindowResize.js +7 -9
  98. package/lib/hooks/useOnWindowResize.js.map +1 -1
  99. package/lib/hooks/useQuill.js +111 -60
  100. package/lib/hooks/useQuill.js.map +1 -1
  101. package/lib/hooks/useSelectOnKeyDown.js +15 -17
  102. package/lib/hooks/useSelectOnKeyDown.js.map +1 -1
  103. package/lib/index.js +8 -22
  104. package/lib/index.js.map +1 -1
  105. package/package.json +1 -1
@@ -1,20 +1,81 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
4
58
  };
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");
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";
8
69
  // @ts-nocheck
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");
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';
16
77
  function convertPostgresColumn(column) {
17
- let format;
78
+ var format;
18
79
  switch (column.dataTypeID) {
19
80
  case 20: // int8
20
81
  case 21: // int2
@@ -42,248 +103,295 @@ function convertPostgresColumn(column) {
42
103
  format: format,
43
104
  };
44
105
  }
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
- },
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
+ }
59
136
  });
60
- if (isSubscribed) {
61
- setSchema(response3.data.tables);
62
- }
63
- }
137
+ });
64
138
  }
65
139
  if (isSubscribed) {
66
140
  getSchema();
67
141
  }
68
- return () => {
142
+ return function () {
69
143
  isSubscribed = false;
70
144
  };
71
145
  }, [schema]);
72
- const editChart = async ({ report, values, yAxisFields, columns, query }) => {
73
- const { publicKey, orgId, authToken, queryEndpoint, queryHeaders, withCredentials, } = 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, withCredentials });
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
- },
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
+ }
137
234
  });
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");
235
+ });
151
236
  };
152
237
  return (
153
238
  // <BigModal theme={theme} showModal={isOpen} setShowModal={setIsOpen}>
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,
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,
155
240
  // leave null for now
156
241
  report: null, query: query,
157
242
  // organizationName={organization?.name}
158
- SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) })
243
+ SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) }))
159
244
  // </BigModal>
160
245
  );
161
246
  }
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 => ({
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 ({
167
253
  value: field,
168
254
  label: field,
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
- };
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
+ }); };
176
270
  fetchReferencedTables();
177
271
  }, [query, schema]);
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',
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',
185
279
  xAxisFieldLabel: '',
186
- dashboardName: report?.dashboardName || '',
280
+ dashboardName: (report === null || report === void 0 ? void 0 : report.dashboardName) || '',
187
281
  dateFieldTable: (dateFieldOptions.length && dateFieldOptions[0].name) || '',
188
282
  dateField: (dateFieldOptions.length && dateFieldOptions[0].columns[0].name) ||
189
283
  '',
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 })) }));
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
+ } })));
194
291
  }
195
- function isValidDate(d) {
292
+ export function isValidDate(d) {
196
293
  return d instanceof Date && !isNaN(d);
197
294
  }
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) {
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) {
202
299
  // Calculate the distance in hours
203
- const distanceInHours = Math.abs((0, date_fns_1.differenceInHours)(endDate, startDate));
300
+ var distanceInHours = Math.abs(differenceInHours(endDate, startDate));
204
301
  // Check if the distance is less than or equal to one hour
205
302
  if (distanceInHours <= 1) {
206
303
  return {
207
304
  unit: 'hour',
208
305
  format: 'h a',
209
- startOf: date_fns_1.startOfHour,
306
+ startOf: startOfHour,
210
307
  };
211
308
  }
212
309
  // Calculate the distance in days
213
- const distanceInDays = Math.abs((0, date_fns_1.differenceInDays)(endDate, startDate));
310
+ var distanceInDays = Math.abs(differenceInDays(endDate, startDate));
214
311
  // Check if the distance is less than or equal to one day
215
312
  if (distanceInDays <= 1) {
216
313
  return {
217
314
  unit: 'day',
218
315
  format: 'MMM d',
219
- startOf: date_fns_1.startOfDay,
316
+ startOf: startOfDay,
220
317
  };
221
318
  }
222
319
  // Calculate the distance in months
223
- const distanceInMonths = Math.abs((0, date_fns_1.differenceInMonths)(endDate, startDate));
320
+ var distanceInMonths = Math.abs(differenceInMonths(endDate, startDate));
224
321
  // Check if the distance is less than or equal to one month
225
322
  if (distanceInMonths <= 1) {
226
323
  return {
227
324
  unit: 'month',
228
325
  format: 'MMM yyyy',
229
- startOf: date_fns_1.startOfMonth,
326
+ startOf: startOfMonth,
230
327
  };
231
328
  }
232
329
  // Calculate the distance in years
233
- const distanceInYears = Math.abs((0, date_fns_1.differenceInYears)(endDate, startDate));
330
+ var distanceInYears = Math.abs(differenceInYears(endDate, startDate));
234
331
  // Check if the distance is less than or equal to one year
235
332
  if (distanceInYears <= 1) {
236
333
  return {
237
334
  unit: 'year',
238
335
  format: 'yyyy',
239
- startOf: date_fns_1.startOfYear,
336
+ startOf: startOfYear,
240
337
  };
241
338
  }
242
339
  // Otherwise, the distance is more than one year
243
340
  return {
244
341
  unit: 'year',
245
342
  format: 'yyyy',
246
- startOf: date_fns_1.startOfYear,
343
+ startOf: startOfYear,
247
344
  };
248
345
  }
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 }));
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)));
253
350
  };
254
- const POSTGRES_DATE_TYPES = [
351
+ var POSTGRES_DATE_TYPES = [
255
352
  'timestamp',
256
353
  'date',
257
354
  'timestamptz',
258
355
  'time',
259
356
  'timetz',
260
357
  ];
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);
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
+ });
285
393
  }
286
- const FORMAT_OPTIONS = [
394
+ var FORMAT_OPTIONS = [
287
395
  { value: 'whole_number', label: 'whole number' },
288
396
  { value: 'one_decimal_place', label: 'one decimal place' },
289
397
  { value: 'dollar_amount', label: 'dollar amount' },
@@ -295,9 +403,10 @@ const FORMAT_OPTIONS = [
295
403
  { value: 'percent', label: 'percent' },
296
404
  { value: 'string', label: 'string' },
297
405
  ];
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
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
301
410
  ? report.yAxisFields
302
411
  : [
303
412
  {
@@ -307,157 +416,162 @@ function FormikForm({ values, isSubmitting, data, fieldOptions, dateFieldOptions
307
416
  label: '',
308
417
  format: 'whole_number',
309
418
  },
310
- ]);
311
- const [columns, setColumns] = (0, react_1.useState)(report && report.columns.length
419
+ ]), yAxisFields = _c[0], setYAxisFields = _c[1];
420
+ var _d = useState(report && report.columns.length
312
421
  ? report.columns
313
- : fields?.length
314
- ? fields.map(field => convertPostgresColumn(field))
315
- : []);
316
- const handleAddYAxisField = () => {
317
- setYAxisFields([
318
- ...yAxisFields,
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), [
319
427
  { label: '', field: '', format: 'whole_number' },
320
- ]);
428
+ ], false));
321
429
  };
322
- const handleDeleteYAxisField = index => {
323
- setYAxisFields(yAxisFields => yAxisFields.filter((_, i) => index !== i));
430
+ var handleDeleteYAxisField = function (index) {
431
+ setYAxisFields(function (yAxisFields) { return yAxisFields.filter(function (_, i) { return index !== i; }); });
324
432
  };
325
- const handleYAxisFieldChange = (index, value) => {
326
- const newYAxisFields = [...yAxisFields];
327
- newYAxisFields[index] = { ...newYAxisFields[index], field: value };
433
+ var handleYAxisFieldChange = function (index, value) {
434
+ var newYAxisFields = __spreadArray([], yAxisFields, true);
435
+ newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { field: value });
328
436
  setYAxisFields(newYAxisFields);
329
437
  };
330
- const handleYAxisFieldFormatChange = (index, value) => {
331
- const newYAxisFields = [...yAxisFields];
332
- newYAxisFields[index] = { ...newYAxisFields[index], format: value };
438
+ var handleYAxisFieldFormatChange = function (index, value) {
439
+ var newYAxisFields = __spreadArray([], yAxisFields, true);
440
+ newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { format: value });
333
441
  setYAxisFields(newYAxisFields);
334
442
  };
335
- const handleYAxisFieldLabelChange = (index, value) => {
336
- const newYAxisFields = [...yAxisFields];
337
- newYAxisFields[index] = { ...newYAxisFields[index], label: value };
443
+ var handleYAxisFieldLabelChange = function (index, value) {
444
+ var newYAxisFields = __spreadArray([], yAxisFields, true);
445
+ newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { label: value });
338
446
  setYAxisFields(newYAxisFields);
339
447
  };
340
- const handleColumnFieldChange = (index, value) => {
341
- const newColumns = [...columns];
342
- newColumns[index] = { ...newColumns[index], field: value };
448
+ var handleColumnFieldChange = function (index, value) {
449
+ var newColumns = __spreadArray([], columns, true);
450
+ newColumns[index] = __assign(__assign({}, newColumns[index]), { field: value });
343
451
  setColumns(newColumns);
344
452
  };
345
- const handleColumnFormatChange = (index, value) => {
346
- const newColumns = [...columns];
347
- newColumns[index] = { ...newColumns[index], format: value };
453
+ var handleColumnFormatChange = function (index, value) {
454
+ var newColumns = __spreadArray([], columns, true);
455
+ newColumns[index] = __assign(__assign({}, newColumns[index]), { format: value });
348
456
  setColumns(newColumns);
349
457
  };
350
- const handleColumnLabelChange = (index, value) => {
351
- const newColumns = [...columns];
352
- newColumns[index] = { ...newColumns[index], label: value };
458
+ var handleColumnLabelChange = function (index, value) {
459
+ var newColumns = __spreadArray([], columns, true);
460
+ newColumns[index] = __assign(__assign({}, newColumns[index]), { label: value });
353
461
  setColumns(newColumns);
354
462
  };
355
- (0, react_1.useEffect)(() => {
356
- setChartConfig({ ...values, yAxisFields: yAxisFields, rows: data });
463
+ useEffect(function () {
464
+ setChartConfig(__assign(__assign({}, values), { yAxisFields: yAxisFields, rows: data }));
357
465
  }, [values, yAxisFields]);
358
466
  // console.log('VIBE: ', { report, values, yAxisFields, columns, query });
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: {
467
+ return (_jsx(Form, __assign({ style: { display: 'inline-block' } }, { children: _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsxs("div", __assign({ style: {
360
468
  display: 'flex',
361
469
  flexDirection: 'column',
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: {
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: {
363
471
  width: '100%',
364
472
  height: 300,
365
- } })) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: formHeaderStyle || {
473
+ } })) })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
366
474
  fontFamily: theme.fontFamily,
367
475
  color: theme.primaryTextColor,
368
476
  fontSize: theme.fontSize + 2,
369
477
  fontWeight: 600,
370
478
  marginTop: 20,
371
- }, children: 'Chart' }), (0, jsx_runtime_1.jsxs)("div", { style: {
479
+ } }, { children: 'Chart' })), _jsxs("div", __assign({ style: {
372
480
  display: 'flex',
373
481
  flexDirection: 'row',
374
482
  alignItems: 'center',
375
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
483
+ } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
376
484
  fontSize: '14px',
377
485
  marginBottom: '6px',
378
486
  fontWeight: '600',
379
487
  marginTop: 8,
380
488
  color: theme.secondaryTextColor,
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 || {
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 || {
383
491
  fontFamily: theme.fontFamily,
384
492
  color: theme.secondaryTextColor,
385
493
  fontSize: theme.fontSize,
386
494
  fontWeight: theme.labelFontWeight,
387
495
  marginTop: 8,
388
496
  marginBottom: 6,
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 || {
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 || {
390
498
  fontFamily: theme.fontFamily,
391
499
  color: theme.secondaryTextColor,
392
500
  fontSize: theme.fontSize,
393
501
  fontWeight: theme.labelFontWeight,
394
502
  marginTop: 8,
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: [
503
+ } }, { children: "Chart type" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "chartType", component: SelectComponent, theme: theme, options: [
396
504
  { label: 'bar', value: 'bar' },
397
505
  { label: 'line', value: 'line' },
398
506
  { label: 'column', value: 'column' },
399
507
  { label: 'pie', value: 'pie' },
400
508
  { label: 'metric', value: 'metric' },
401
509
  { label: 'table', value: 'table' },
402
- ] }) })] })] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
510
+ ] }) }))] }))] }))] })), _jsx("div", __assign({ style: {
403
511
  display: 'flex',
404
512
  flexDirection: 'row',
405
513
  alignItems: 'center',
406
514
  // justifyContent: 'space-between',
407
515
  marginTop: 20,
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 || {
516
+ } }, { children: values.chartType !== 'table' && (_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
409
517
  fontFamily: theme.fontFamily,
410
518
  color: theme.secondaryTextColor,
411
519
  fontSize: theme.fontSize,
412
520
  fontWeight: theme.labelFontWeight,
413
- }, children: values.chartType === 'pie'
521
+ } }, { children: values.chartType === 'pie'
414
522
  ? 'Category column'
415
- : 'x-axis column' }), (0, jsx_runtime_1.jsx)("div", { style: { height: 6 } }), (0, jsx_runtime_1.jsxs)("div", { style: {
523
+ : 'x-axis column' })), _jsx("div", { style: { height: 6 } }), _jsxs("div", __assign({ style: {
416
524
  display: 'flex',
417
525
  flexDirection: 'row',
418
526
  alignItems: 'center',
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: {
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: {
420
528
  display: 'flex',
421
529
  flexDirection: 'row',
422
530
  alignItems: 'flex-start',
423
531
  // justifyContent: 'space-between',
424
532
  marginTop: 20,
425
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
533
+ } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
426
534
  fontFamily: theme.fontFamily,
427
535
  color: theme.secondaryTextColor,
428
536
  fontSize: theme.fontSize,
429
537
  fontWeight: theme.labelFontWeight,
430
538
  minWidth: 200,
431
- }, children: values.chartType === 'table'
539
+ } }, { children: values.chartType === 'table'
432
540
  ? 'Columns'
433
541
  : values.chartType === 'pie'
434
542
  ? 'Quantity column'
435
- : 'y-axis columns' }), (0, jsx_runtime_1.jsxs)("div", { style: {
543
+ : 'y-axis columns' })), _jsxs("div", __assign({ style: {
436
544
  display: 'flex',
437
545
  flexDirection: 'column',
438
- }, children: [yAxisFields.map((yAxisField, index) => ((0, jsx_runtime_1.jsx)("div", { style: {
546
+ } }, { children: [yAxisFields.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
439
547
  display: 'flex',
440
548
  flexDirection: 'row',
441
549
  alignItems: 'center',
442
550
  marginTop: index === 0 ? 6 : 10,
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: {
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: {
444
552
  display: 'flex',
445
553
  flexDirection: 'column',
446
554
  justifyContent: 'flex-start',
447
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
555
+ } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
448
556
  fontFamily: theme.fontFamily,
449
557
  color: 'transparent',
450
558
  fontSize: theme.fontSize,
451
559
  fontWeight: theme.labelFontWeight,
452
560
  minWidth: 200,
453
561
  // marginBottom: 10,
454
- }, children: "y-axis label" }), values.chartType !== 'pie' &&
455
- yAxisFields.map((yAxisField, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
562
+ } }, { children: "y-axis label" })), values.chartType !== 'pie' &&
563
+ yAxisFields.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
456
564
  display: 'flex',
457
565
  flexDirection: 'row',
458
566
  alignItems: 'center',
459
567
  marginTop: index === 0 ? 6 : 10,
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: {
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: {
461
575
  cursor: index > 0 ? 'pointer' : undefined,
462
576
  paddingLeft: 6,
463
577
  paddingTop: 12,
@@ -467,52 +581,58 @@ function FormikForm({ values, isSubmitting, data, fieldOptions, dateFieldOptions
467
581
  display: 'flex',
468
582
  alignItems: 'center',
469
583
  justifyContent: 'center',
470
- }, children: (0, jsx_runtime_1.jsx)(solid_1.XMarkIcon, { style: {
584
+ } }, { children: _jsx(XMarkIcon, { style: {
471
585
  height: '20px',
472
586
  width: '20px',
473
587
  color: index > 0
474
- ? theme?.secondaryTextColor
588
+ ? theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor
475
589
  : 'rgba(0,0,0,0)',
476
- }, "aria-hidden": "true" }) })] }, `yAxisField-${index}`)))] })] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: formHeaderStyle || {
590
+ }, "aria-hidden": "true" }) }))] }), "yAxisField-".concat(index))); })] }))] })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
477
591
  fontFamily: theme.fontFamily,
478
592
  color: theme.primaryTextColor,
479
593
  fontSize: theme.fontSize + 2,
480
594
  fontWeight: 600,
481
- }, children: 'Table' }), (0, jsx_runtime_1.jsxs)("div", { style: {
595
+ } }, { children: 'Table' })), _jsxs("div", __assign({ style: {
482
596
  display: 'flex',
483
597
  flexDirection: 'row',
484
598
  alignItems: 'flex-start',
485
599
  // justifyContent: 'space-between',
486
600
  // marginTop: 8,
487
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
601
+ } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
488
602
  fontFamily: theme.fontFamily,
489
603
  color: theme.secondaryTextColor,
490
604
  fontSize: theme.fontSize,
491
605
  fontWeight: theme.labelFontWeight,
492
- }, children: 'Columns' }), (0, jsx_runtime_1.jsxs)("div", { style: {
606
+ } }, { children: 'Columns' })), _jsxs("div", __assign({ style: {
493
607
  display: 'flex',
494
608
  flexDirection: 'column',
495
- }, children: [columns.map((yAxisField, index) => ((0, jsx_runtime_1.jsx)("div", { style: {
609
+ } }, { children: [columns.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
496
610
  display: 'flex',
497
611
  flexDirection: 'row',
498
612
  alignItems: 'center',
499
613
  marginTop: index === 0 ? 6 : 10,
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: {
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: {
501
617
  display: 'flex',
502
618
  flexDirection: 'column',
503
619
  justifyContent: 'flex-start',
504
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: formLabelStyle || {
620
+ } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
505
621
  fontFamily: theme.fontFamily,
506
622
  color: 'transparent',
507
623
  fontSize: theme.fontSize,
508
624
  fontWeight: theme.labelFontWeight,
509
625
  minWidth: 200,
510
626
  // marginBottom: 10,
511
- }, children: "label" }), columns.map((yAxisField, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
627
+ } }, { children: "label" })), columns.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
512
628
  display: 'flex',
513
629
  flexDirection: 'row',
514
630
  alignItems: 'center',
515
631
  marginTop: index === 0 ? 6 : 10,
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' })] }) }));
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' })] })) })));
517
637
  }
518
638
  //# sourceMappingURL=AddToDashboardModal.js.map