@quillsql/react 1.7.2 → 1.7.3

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 +208 -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 +51 -8
  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
package/lib/Dashboard.js CHANGED
@@ -1,64 +1,45 @@
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 };
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
46
7
  }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
27
  };
48
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const jsx_runtime_1 = require("react/jsx-runtime");
49
30
  /* eslint-disable @typescript-eslint/ban-ts-comment */
50
31
  // @ts-nocheck
51
- import React, { useContext, useEffect, useState, useRef } from 'react';
52
- import Chart from './Chart';
53
- import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, } from './Context';
54
- import { startOfToday, sub } from 'date-fns';
55
- import { DateRangePicker } from './DateRangePicker/index';
56
- import axios from 'axios';
57
- import Modal from './components/Modal/Modal';
58
- import { HoveredValueContext, SelectedValueContext } from './contexts';
59
- import { DropdownItem } from './components/Dropdown';
60
- import { ArrowDownHeadIcon } from './assets';
61
- import { useInternalState, useSelectOnKeyDown } from './hooks';
32
+ const react_1 = __importStar(require("react"));
33
+ const Chart_1 = __importDefault(require("./Chart"));
34
+ const Context_1 = require("./Context");
35
+ const date_fns_1 = require("date-fns");
36
+ const index_1 = require("./DateRangePicker/index");
37
+ const index_2 = __importDefault(require("axios/index"));
38
+ const Modal_1 = __importDefault(require("./components/Modal/Modal"));
39
+ const contexts_1 = require("./contexts");
40
+ const Dropdown_1 = require("./components/Dropdown");
41
+ const assets_1 = require("./assets");
42
+ const hooks_1 = require("./hooks");
62
43
  // const theme = {
63
44
  // fontFamily: 'Inter; Helvetica',
64
45
  // primaryTextColor: '#212121',
@@ -67,93 +48,83 @@ import { useInternalState, useSelectOnKeyDown } from './hooks';
67
48
  // chartTickColor: '#CCCCCC',
68
49
  // chartColors: ['#6269E9', '#E14F62'],
69
50
  // };
70
- export default function Dashboard(_a) {
71
- var name = _a.name, containerStyle = _a.containerStyle, maxColumnWidth = _a.maxColumnWidth, rowHeight = _a.rowHeight, onClickDashboardItem = _a.onClickDashboardItem, hideDateFilter = _a.hideDateFilter;
72
- var _b = useState(null), dashboardSections = _b[0], setDashboardSections = _b[1];
73
- var dashboard = useContext(DashboardContext).dashboard;
74
- var client = useContext(ClientContext)[0];
75
- var theme = useContext(ThemeContext)[0];
76
- var dashboardFiltersDispatch = useContext(DashboardFiltersContext).dashboardFiltersDispatch;
77
- var _c = useState([]), configFilters = _c[0], setConfigFilters = _c[1];
78
- React.useEffect(function () {
79
- function getDashboards() {
80
- return __awaiter(this, void 0, void 0, function () {
81
- var publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, response_1, response, error_1;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0:
85
- publicKey = client.publicKey, customerId = client.customerId, environment = client.environment, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders, withCredentials = client.withCredentials;
86
- _a.label = 1;
87
- case 1:
88
- _a.trys.push([1, 5, , 6]);
89
- if (!queryEndpoint) return [3 /*break*/, 3];
90
- return [4 /*yield*/, axios.post(queryEndpoint, {
91
- metadata: { name: name, task: 'config' },
92
- }, {
93
- headers: queryHeaders,
94
- withCredentials: withCredentials,
95
- })];
96
- case 2:
97
- response_1 = _a.sent();
98
- if (response_1.status !== 200) {
99
- throw new Error("HTTP error! Status: ".concat(response_1.status));
100
- }
101
- setDashboardSections(response_1.data.sections);
102
- setConfigFilters(response_1.data.filters || []);
103
- return [2 /*return*/];
104
- case 3: return [4 /*yield*/, axios.get('https://quill-344421.uc.r.appspot.com/dashconfig', {
105
- params: {
106
- publicKey: publicKey,
107
- orgId: customerId,
108
- name: name,
109
- task: 'dashconfig',
110
- },
111
- headers: {
112
- environment: environment || undefined,
113
- },
114
- })];
115
- case 4:
116
- response = _a.sent();
117
- if (response.status !== 200) {
118
- throw new Error("HTTP error! Status: ".concat(response.status));
119
- }
120
- setDashboardSections(response.data.sections);
121
- setConfigFilters(response.data.filters || []);
122
- return [3 /*break*/, 6];
123
- case 5:
124
- error_1 = _a.sent();
125
- console.error('Error fetching data:', error_1);
126
- return [3 /*break*/, 6];
127
- case 6: return [2 /*return*/];
51
+ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideDateFilter, }) {
52
+ const [dashboardSections, setDashboardSections] = (0, react_1.useState)(null);
53
+ const { dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
54
+ const [client] = (0, react_1.useContext)(Context_1.ClientContext);
55
+ const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
56
+ const { dashboardFiltersDispatch } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
57
+ const [configFilters, setConfigFilters] = (0, react_1.useState)([]);
58
+ react_1.default.useEffect(() => {
59
+ async function getDashboards() {
60
+ const { publicKey, customerId, environment, queryEndpoint, queryHeaders, } = client;
61
+ try {
62
+ // const response = await fetch(
63
+ // `https://quill-344421.uc.r.appspot.com/dashsections/${publicKey}/${customerId}/${name}`
64
+ // );
65
+ if (queryEndpoint) {
66
+ //&& queryHeaders
67
+ // @ts-ignore
68
+ const response = await index_2.default.post(queryEndpoint, {
69
+ metadata: { name, task: 'config' },
70
+ }, {
71
+ headers: queryHeaders,
72
+ });
73
+ if (response.status !== 200) {
74
+ throw new Error(`HTTP error! Status: ${response.status}`);
128
75
  }
76
+ setDashboardSections(response.data.sections);
77
+ setConfigFilters(response.data.filters || []);
78
+ return;
79
+ }
80
+ const response = await index_2.default.get('https://quill-344421.uc.r.appspot.com/dashconfig', {
81
+ params: {
82
+ publicKey: publicKey,
83
+ orgId: customerId,
84
+ name: name,
85
+ task: 'dashconfig',
86
+ },
87
+ headers: {
88
+ environment: environment || undefined,
89
+ },
129
90
  });
130
- });
91
+ if (response.status !== 200) {
92
+ throw new Error(`HTTP error! Status: ${response.status}`);
93
+ }
94
+ setDashboardSections(response.data.sections);
95
+ setConfigFilters(response.data.filters || []);
96
+ }
97
+ catch (error) {
98
+ console.error('Error fetching data:', error);
99
+ }
131
100
  }
132
101
  getDashboards();
133
102
  }, [name]);
134
- useEffect(function () {
103
+ (0, react_1.useEffect)(() => {
135
104
  // change to be set on the dashboard / section as default date range
136
- var filter = {
137
- startDate: sub(startOfToday(), { days: 90 }),
105
+ const filter = {
106
+ startDate: (0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { days: 90 }),
138
107
  endDate: new Date(),
139
108
  filterType: 'DATE_RANGE',
140
109
  };
141
110
  dashboardFiltersDispatch({
142
111
  type: 'ADD_DASHBOARD_FILTER',
143
112
  id: 'date_range',
144
- data: __assign({}, filter),
113
+ data: {
114
+ ...filter,
115
+ },
145
116
  });
146
117
  }, []);
147
- var handleOnClickDashboardItem = function (id) {
118
+ const handleOnClickDashboardItem = id => {
148
119
  if (dashboard[id]) {
149
120
  onClickDashboardItem(dashboard[id]);
150
121
  }
151
122
  };
152
- var onChangeDateFilter = function (dateFilter) {
123
+ const onChangeDateFilter = dateFilter => {
153
124
  setGlobalDateFilter(dateFilter[0], dateFilter[1]);
154
125
  };
155
- var setGlobalDateFilter = function (startDate, endDate) {
156
- var filter = {
126
+ const setGlobalDateFilter = (startDate, endDate) => {
127
+ const filter = {
157
128
  startDate: startDate,
158
129
  endDate: endDate,
159
130
  filterType: 'DATE_RANGE',
@@ -161,48 +132,53 @@ export default function Dashboard(_a) {
161
132
  dashboardFiltersDispatch({
162
133
  type: 'ADD_DASHBOARD_FILTER',
163
134
  id: 'date_range',
164
- data: __assign({}, filter),
135
+ data: {
136
+ ...filter,
137
+ },
165
138
  });
166
139
  };
167
- var onChangeFilter = function (value, filter) {
140
+ const onChangeFilter = (value, filter) => {
168
141
  dashboardFiltersDispatch({
169
142
  type: 'ADD_DASHBOARD_FILTER',
170
143
  id: 'date_range',
171
- data: __assign(__assign({}, filter), { selectedValue: filter.options.find(function (elem) { return elem[removeQuotes(filter.field)] === value[2]; })[removeQuotes(filter.field)] }),
144
+ data: {
145
+ ...filter,
146
+ selectedValue: filter.options.find(elem => elem[removeQuotes(filter.field)] === value[2])[removeQuotes(filter.field)],
147
+ },
172
148
  });
173
149
  };
174
150
  if (!dashboardSections) {
175
151
  return null;
176
152
  }
177
- return (_jsxs("div", __assign({ style: containerStyle }, { children: [_jsxs("div", __assign({ style: {
153
+ return ((0, jsx_runtime_1.jsxs)("div", { style: containerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
178
154
  display: 'flex',
179
155
  boxSizing: 'content-box',
180
156
  flexDirection: 'row',
181
157
  alignItems: 'center',
182
- } }, { children: [!hideDateFilter ? (_jsxs("div", __assign({ style: { width: 420, marginBottom: 25, marginLeft: 25 } }, { children: [_jsx("div", __assign({ style: {
158
+ }, children: [!hideDateFilter ? ((0, jsx_runtime_1.jsxs)("div", { style: { width: 420, marginBottom: 25, marginLeft: 25 }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
183
159
  marginBottom: 6,
184
160
  fontWeight: '600',
185
161
  color: theme.secondaryTextColor,
186
162
  fontFamily: theme.fontFamily,
187
163
  fontSize: 14,
188
- } }, { children: "Date" })), _jsx(DateRangePicker
164
+ }, children: "Date" }), (0, jsx_runtime_1.jsx)(index_1.DateRangePicker
189
165
  // change to be set on the dashboard / section as default date range
190
166
  , {
191
167
  // change to be set on the dashboard / section as default date range
192
- defaultValue: [undefined, undefined, '90d'], onValueChange: onChangeDateFilter, theme: theme })] }))) : null, _jsx("div", __assign({ style: { width: 280, marginBottom: 25, marginLeft: 25 } }, { children: configFilters.map(function (elem, index) { return (_jsx(Filter, { onValueChange: function (value) { return onChangeFilter(value, elem); }, defaultValue: [
168
+ defaultValue: [undefined, undefined, '90d'], onValueChange: onChangeDateFilter, theme: theme })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: { width: 280, marginBottom: 25, marginLeft: 25 }, children: configFilters.map((elem, index) => ((0, jsx_runtime_1.jsx)(Filter, { onValueChange: value => onChangeFilter(value, elem), defaultValue: [
193
169
  undefined,
194
170
  undefined,
195
171
  elem.options[removeQuotes(elem.field)],
196
- ], theme: theme, filter: elem }, 'filter' + configFilters.field + index)); }) }))] })), Object.keys(dashboardSections)
172
+ ], theme: theme, filter: elem }, 'filter' + configFilters.field + index))) })] }), Object.keys(dashboardSections)
197
173
  .sort(function (a, b) {
198
174
  return a.length - b.length;
199
175
  })
200
- .map(function (section, sectionIndex) {
201
- return (_jsxs("div", __assign({ style: {
176
+ .map((section, sectionIndex) => {
177
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
202
178
  width: '100%',
203
179
  display: 'flex',
204
180
  flexDirection: 'column',
205
- } }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && (_jsx("h1", __assign({ style: {
181
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && ((0, jsx_runtime_1.jsx)("h1", { style: {
206
182
  fontSize: 22,
207
183
  color: theme.primaryTextColor,
208
184
  fontFamily: theme.fontFamily,
@@ -212,20 +188,20 @@ export default function Dashboard(_a) {
212
188
  marginLeft: 25,
213
189
  textAlign: 'left',
214
190
  marginTop: 12,
215
- } }, { children: section })))] })), dashboardSections[section].filter(function (elem) { return elem.chartType === 'metric'; }).length ? (_jsx("div", __assign({ style: {
191
+ }, children: section }))] }), dashboardSections[section].filter(elem => elem.chartType === 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
216
192
  boxSizing: 'content-box',
217
- width: "100%",
193
+ width: `100%`,
218
194
  listStyleType: 'none',
219
195
  marginBottom: 50,
220
196
  display: 'grid',
221
197
  gridGap: 25,
222
- gridTemplateColumns: "repeat(auto-fill,minmax(".concat(maxColumnWidth || 400, "px, 1fr))"),
223
- gridTemplateRows: "repeat(".concat(170, "px)"),
224
- } }, { children: dashboardSections[section]
225
- .filter(function (elem) { return elem.chartType === 'metric'; })
226
- .map(function (elem, index) {
227
- return (_jsx("div", __assign({ onClick: onClickDashboardItem
228
- ? function () { return handleOnClickDashboardItem(elem._id); }
198
+ gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
199
+ gridTemplateRows: `repeat(${170}px)`,
200
+ }, children: dashboardSections[section]
201
+ .filter(elem => elem.chartType === 'metric')
202
+ .map((elem, index) => {
203
+ return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
204
+ ? () => handleOnClickDashboardItem(elem._id)
229
205
  : undefined, style: {
230
206
  // background: theme.elevatedCardColor,
231
207
  // borderRadius: theme.borderRadius,
@@ -236,22 +212,22 @@ export default function Dashboard(_a) {
236
212
  height: '100%',
237
213
  cursor: 'pointer',
238
214
  width: '100%',
239
- } }, { children: _jsx("div", __assign({
215
+ }, children: (0, jsx_runtime_1.jsx)("div", {
240
216
  // className="group-hover:bg-black"
241
217
  style: {
242
218
  width: '100%',
243
219
  boxSizing: 'content-box',
244
220
  height: '100%',
245
- } }, { children: _jsx("div", __assign({ style: {
221
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
246
222
  width: '100%',
247
223
  boxSizing: 'content-box',
248
224
  height: '100%',
249
- } }, { children: _jsxs("div", __assign({ style: {
225
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
250
226
  display: 'flex',
251
227
  flexDirection: 'column',
252
228
  justifyContent: 'space-between',
253
229
  boxSizing: 'content-box',
254
- } }, { children: [_jsxs("div", __assign({
230
+ }, children: [(0, jsx_runtime_1.jsxs)("div", {
255
231
  // className="group-hover:bg-black"
256
232
  style: {
257
233
  display: 'flex',
@@ -262,7 +238,7 @@ export default function Dashboard(_a) {
262
238
  // paddingLeft: theme.padding,
263
239
  paddingRight: 25,
264
240
  // paddingTop: theme.padding,
265
- } }, { children: [_jsx("div", __assign({ title: elem.name, style: {
241
+ }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
266
242
  fontFamily: theme.fontFamily,
267
243
  color: theme.primaryTextColor,
268
244
  boxSizing: 'content-box',
@@ -281,7 +257,7 @@ export default function Dashboard(_a) {
281
257
  display: 'block',
282
258
  maxWidth: '100%',
283
259
  overflow: 'hidden',
284
- } }, { children: elem.name })), onClickDashboardItem ? (_jsx("div", __assign({
260
+ }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
285
261
  // className="hover:bg-black"
286
262
  style: {
287
263
  fontFamily: theme.fontFamily,
@@ -294,27 +270,26 @@ export default function Dashboard(_a) {
294
270
  display: 'flex',
295
271
  alignItems: 'center',
296
272
  justifyContent: 'flex-end',
297
- } }, { children: 'view report →' }))) : null] })), _jsx("div", __assign({ style: { padding: 0 } }, { children: _jsx(Chart, { containerStyle: {
273
+ }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: { padding: 0 }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
298
274
  display: 'flex',
299
275
  // width: '100%',
300
276
  height: 30,
301
277
  // marginBottom: 50,
302
278
  marginTop: 20,
303
- }, dateFilter: true, chartId: elem._id, query: elem.queryString }) }))] })) })) })) }), elem.name + '' + index));
304
- }) }))) : null, _jsx("div", __assign({ style: {
279
+ }, dateFilter: true, chartId: elem._id, query: elem.queryString }) })] }) }) }) }, elem.name + '' + index));
280
+ }) })) : null, (0, jsx_runtime_1.jsx)("div", { style: {
305
281
  // width: `100%`,
306
282
  listStyleType: 'none',
307
283
  display: 'grid',
308
284
  gridGap: 25,
309
285
  boxSizing: 'content-box',
310
- gridTemplateColumns: "repeat(auto-fill,minmax(".concat(maxColumnWidth || 400, "px, 1fr))"),
311
- gridTemplateRows: "repeat(auto-fill, ".concat(rowHeight || 400, "px)"),
312
- } }, { children: dashboardSections[section]
313
- .filter(function (elem) { return elem.chartType !== 'metric'; })
314
- .map(function (elem, index) {
315
- var _a;
316
- return (_jsx("div", __assign({ onClick: onClickDashboardItem
317
- ? function () { return handleOnClickDashboardItem(elem._id); }
286
+ gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
287
+ gridTemplateRows: `repeat(auto-fill, ${rowHeight || 400}px)`,
288
+ }, children: dashboardSections[section]
289
+ .filter(elem => elem.chartType !== 'metric')
290
+ .map((elem, index) => {
291
+ return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
292
+ ? () => handleOnClickDashboardItem(elem._id)
318
293
  : undefined,
319
294
  // onClick={() => handleEditDashboardItem(elem)}
320
295
  // className="qq-shadow"
@@ -330,21 +305,21 @@ export default function Dashboard(_a) {
330
305
  minHeight: rowHeight || 400,
331
306
  borderRadius: 8,
332
307
  paddingTop: 20,
333
- } }, { children: _jsx("div", __assign({ style: {
308
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
334
309
  width: '100%',
335
310
  height: '100%',
336
311
  boxSizing: 'content-box',
337
- } }, { children: _jsx("div", __assign({ style: {
312
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
338
313
  width: '100%',
339
314
  height: '100%',
340
315
  boxSizing: 'content-box',
341
- } }, { children: _jsxs("div", __assign({ style: {
316
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
342
317
  display: 'flex',
343
318
  flexDirection: 'column',
344
319
  justifyContent: 'space-between',
345
320
  height: '100%',
346
321
  boxSizing: 'content-box',
347
- } }, { children: [_jsxs("div", __assign({ style: {
322
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
348
323
  display: 'flex',
349
324
  flexDirection: 'row',
350
325
  justifyContent: 'space-between',
@@ -353,7 +328,7 @@ export default function Dashboard(_a) {
353
328
  // paddingLeft: theme.padding,
354
329
  // paddingRight: theme.padding,
355
330
  // paddingTop: theme.padding,
356
- } }, { children: [_jsx("div", __assign({ style: {
331
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
357
332
  fontFamily: theme.fontFamily,
358
333
  color: theme.primaryTextColor,
359
334
  boxSizing: 'content-box',
@@ -370,7 +345,7 @@ export default function Dashboard(_a) {
370
345
  display: 'block',
371
346
  maxWidth: '100%',
372
347
  overflow: 'hidden',
373
- } }, { children: elem.name })), onClickDashboardItem ? (_jsx("div", __assign({
348
+ }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
374
349
  // className="hover:bg-black"
375
350
  style: {
376
351
  fontFamily: theme.fontFamily,
@@ -383,28 +358,27 @@ export default function Dashboard(_a) {
383
358
  display: 'flex',
384
359
  alignItems: 'center',
385
360
  justifyContent: 'flex-end',
386
- } }, { children: 'view report →' }))) : null] })), _jsx("div", __assign({ style: {
361
+ }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: {
387
362
  padding: 0,
388
363
  height: '100%',
389
364
  boxSizing: 'content-box',
390
- } }, { children: _jsx(Chart, { containerStyle: {
365
+ }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
391
366
  display: 'flex',
392
367
  width: '100%',
393
368
  // TODO: fix fixed height
394
369
  height: 300,
395
370
  marginBottom: 50,
396
371
  marginTop: 30,
397
- }, isDateFilter: true, chartId: elem._id, colors: ((_a = theme.chartColors) === null || _a === void 0 ? void 0 : _a.length)
372
+ }, isDateFilter: true, chartId: elem._id, colors: theme.chartColors?.length
398
373
  ? theme.chartColors
399
- : undefined }) }))] })) })) })) }), elem.name + '' + index));
400
- }) }))] }), section + '' + sectionIndex));
401
- })] })));
374
+ : undefined }) })] }) }) }) }, elem.name + '' + index));
375
+ }) })] }, section + '' + sectionIndex));
376
+ })] }));
402
377
  }
403
- function Filter(_a) {
404
- var _b;
405
- var defaultValue = _a.defaultValue, theme = _a.theme, onValueChange = _a.onValueChange, filter = _a.filter;
378
+ exports.default = Dashboard;
379
+ function Filter({ defaultValue, theme, onValueChange, filter }) {
406
380
  //should be date as well as strings
407
- var dropdownOptions = [
381
+ const dropdownOptions = [
408
382
  { value: 'popupbagelsmardens', text: 'popupbagelsmardens' },
409
383
  { value: 'popupbagelswestport', text: 'popupbagelswestport' },
410
384
  { value: 'popupbagelseasthampton', text: 'popupbagelseasthampton' },
@@ -412,23 +386,23 @@ function Filter(_a) {
412
386
  { value: 'popupbagelsredding', text: 'popupbagelsredding' },
413
387
  { value: 'popupbagelsthompson', text: 'popupbagelsthompson' },
414
388
  ];
415
- var dropdownRef = useRef(null);
416
- var _c = useState(false), showDropdown = _c[0], setShowDropdown = _c[1];
417
- var _d = useInternalState(defaultValue, undefined), selectedValue = _d[0], setSelectedValue = _d[1];
418
- var selectedDropdownValue = selectedValue ? (_b = selectedValue[2]) !== null && _b !== void 0 ? _b : null : null;
419
- var handleDropdownOptionClick = function (dropdownValue) {
389
+ const dropdownRef = (0, react_1.useRef)(null);
390
+ const [showDropdown, setShowDropdown] = (0, react_1.useState)(false);
391
+ const [selectedValue, setSelectedValue] = (0, hooks_1.useInternalState)(defaultValue, undefined);
392
+ const selectedDropdownValue = selectedValue ? selectedValue[2] ?? null : null;
393
+ const handleDropdownOptionClick = (dropdownValue) => {
420
394
  setSelectedValue([undefined, undefined, dropdownValue]);
421
- onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange([undefined, undefined, dropdownValue]);
395
+ onValueChange?.([undefined, undefined, dropdownValue]);
422
396
  setShowDropdown(false);
423
397
  };
424
- var _e = useSelectOnKeyDown(handleDropdownOptionClick, dropdownOptions.map(function (option) { return option.value; }), showDropdown, setShowDropdown, selectedDropdownValue), hoveredDropdownValue = _e[0], handleDropdownKeyDown = _e[1];
425
- return (_jsxs("div", __assign({ style: { position: 'relative', width: '100%' } }, { children: [_jsx("div", __assign({ style: {
398
+ const [hoveredDropdownValue, handleDropdownKeyDown] = (0, hooks_1.useSelectOnKeyDown)(handleDropdownOptionClick, dropdownOptions.map((option) => option.value), showDropdown, setShowDropdown, selectedDropdownValue);
399
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative', width: '100%' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
426
400
  marginBottom: 6,
427
401
  fontWeight: '600',
428
402
  color: theme.secondaryTextColor,
429
403
  fontSize: 14,
430
404
  fontFamily: theme.fontFamily,
431
- } }, { children: filter.label })), _jsx(FilterDropdown, { showDropdown: showDropdown, setShowDropdown: setShowDropdown, handleDropdownKeyDown: handleDropdownKeyDown, dropdownRef: dropdownRef, theme: theme, selectedDropdownValue: selectedDropdownValue, dropdownOptions: filter.options, field: filter.field, label: filter.labelField }), _jsx(FilterModal, { showDropdown: showDropdown, setShowDropdown: setShowDropdown, dropdownRef: dropdownRef, theme: theme, hoveredDropdownValue: hoveredDropdownValue, selectedDropdownValue: selectedDropdownValue, dropdownOptions: filter.options, handleDropdownOptionClick: handleDropdownOptionClick, field: filter.field, label: filter.labelField })] })));
405
+ }, children: filter.label }), (0, jsx_runtime_1.jsx)(FilterDropdown, { showDropdown: showDropdown, setShowDropdown: setShowDropdown, handleDropdownKeyDown: handleDropdownKeyDown, dropdownRef: dropdownRef, theme: theme, selectedDropdownValue: selectedDropdownValue, dropdownOptions: filter.options, field: filter.field, label: filter.labelField }), (0, jsx_runtime_1.jsx)(FilterModal, { showDropdown: showDropdown, setShowDropdown: setShowDropdown, dropdownRef: dropdownRef, theme: theme, hoveredDropdownValue: hoveredDropdownValue, selectedDropdownValue: selectedDropdownValue, dropdownOptions: filter.options, handleDropdownOptionClick: handleDropdownOptionClick, field: filter.field, label: filter.labelField })] }));
432
406
  }
433
407
  function removeQuotes(str) {
434
408
  if (str.startsWith('"') && str.endsWith('"')) {
@@ -438,22 +412,21 @@ function removeQuotes(str) {
438
412
  return str;
439
413
  }
440
414
  }
441
- function FilterDropdown(_a) {
442
- var setShowDropdown = _a.setShowDropdown, dropdownRef = _a.dropdownRef, showDropdown = _a.showDropdown, handleDropdownKeyDown = _a.handleDropdownKeyDown, theme = _a.theme, _b = _a.dropdownPlaceholder, dropdownPlaceholder = _b === void 0 ? 'Select' : _b, selectedDropdownValue = _a.selectedDropdownValue, dropdownOptions = _a.dropdownOptions, field = _a.field, label = _a.label;
443
- var dropdownText = selectedDropdownValue
444
- ? String(dropdownOptions.find(function (option) { return option[removeQuotes(field)] === selectedDropdownValue; })[removeQuotes(label)])
415
+ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDropdownKeyDown, theme, dropdownPlaceholder = 'Select', selectedDropdownValue, dropdownOptions, field, label, }) {
416
+ const dropdownText = selectedDropdownValue
417
+ ? String(dropdownOptions.find(option => option[removeQuotes(field)] === selectedDropdownValue)[removeQuotes(label)])
445
418
  : dropdownPlaceholder;
446
- return (_jsx("div", __assign({ style: {
419
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
447
420
  display: 'flex',
448
421
  alignItems: 'center',
449
422
  justifyContent: 'space-between',
450
423
  borderRadius: '0.375rem',
451
- background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
452
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
424
+ background: theme?.backgroundColor,
425
+ fontFamily: theme?.fontFamily,
453
426
  boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
454
- } }, { children: _jsxs("button", __assign({ type: "button", style: {
427
+ }, children: (0, jsx_runtime_1.jsxs)("button", { type: "button", style: {
455
428
  // fontFamily: theme?.fontFamily,
456
- borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E5E7EB',
429
+ borderColor: theme?.borderColor || '#E5E7EB',
457
430
  borderStyle: 'solid',
458
431
  borderWidth: 1,
459
432
  cursor: 'pointer',
@@ -470,31 +443,30 @@ function FilterDropdown(_a) {
470
443
  minHeight: 38,
471
444
  justifyContent: 'space-between',
472
445
  alignItems: 'center',
473
- background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
474
- fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '0.875rem',
446
+ background: theme?.backgroundColor,
447
+ fontSize: theme?.fontSizeSmall || '0.875rem',
475
448
  // fontWeight: theme?.fontWeightMedium || '800',
476
- }, ref: dropdownRef, onClick: function () { return setShowDropdown(!showDropdown); }, onKeyDown: handleDropdownKeyDown }, { children: [_jsx("p", __assign({ style: {
449
+ }, ref: dropdownRef, onClick: () => setShowDropdown(!showDropdown), onKeyDown: handleDropdownKeyDown, children: [(0, jsx_runtime_1.jsx)("p", { style: {
477
450
  margin: 0,
478
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
479
- color: (theme === null || theme === void 0 ? void 0 : theme.primaryTextColor) || '#364153',
451
+ fontFamily: theme?.fontFamily,
452
+ color: theme?.primaryTextColor || '#364153',
480
453
  overflow: 'hidden',
481
454
  textOverflow: 'ellipsis',
482
455
  whiteSpace: 'nowrap',
483
- fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightMedium) || '500',
484
- fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '0.875rem',
485
- } }, { children: dropdownText })), _jsx(ArrowDownHeadIcon, { style: {
456
+ fontWeight: theme?.fontWeightMedium || '500',
457
+ fontSize: theme?.fontSizeSmall || '0.875rem',
458
+ }, children: dropdownText }), (0, jsx_runtime_1.jsx)(assets_1.ArrowDownHeadIcon, { style: {
486
459
  height: '1.25rem',
487
460
  width: '1.25rem',
488
461
  flex: 'none',
489
- color: theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor,
462
+ color: theme?.secondaryTextColor,
490
463
  marginRight: '-0.25rem',
491
- }, "aria-hidden": "true" })] })) })));
464
+ }, "aria-hidden": "true" })] }) }));
492
465
  }
493
- function FilterModal(_a) {
494
- var setShowDropdown = _a.setShowDropdown, dropdownRef = _a.dropdownRef, showDropdown = _a.showDropdown, theme = _a.theme, selectedDropdownValue = _a.selectedDropdownValue, hoveredDropdownValue = _a.hoveredDropdownValue, dropdownOptions = _a.dropdownOptions, handleDropdownOptionClick = _a.handleDropdownOptionClick, field = _a.field, label = _a.label;
495
- return (_jsx(Modal, __assign({ showModal: showDropdown, setShowModal: setShowDropdown, parentRef: dropdownRef, theme: theme }, { children: _jsx(SelectedValueContext.Provider, __assign({ value: {
466
+ function FilterModal({ setShowDropdown, dropdownRef, showDropdown, theme, selectedDropdownValue, hoveredDropdownValue, dropdownOptions, handleDropdownOptionClick, field, label, }) {
467
+ return ((0, jsx_runtime_1.jsx)(Modal_1.default, { showModal: showDropdown, setShowModal: setShowDropdown, parentRef: dropdownRef, theme: theme, children: (0, jsx_runtime_1.jsx)(contexts_1.SelectedValueContext.Provider, { value: {
496
468
  selectedValue: selectedDropdownValue,
497
469
  handleValueChange: handleDropdownOptionClick,
498
- } }, { children: _jsx(HoveredValueContext.Provider, __assign({ value: { hoveredValue: hoveredDropdownValue } }, { children: dropdownOptions.map(function (row, index) { return (_jsx(DropdownItem, { value: row[removeQuotes(field)], text: row[removeQuotes(label)], theme: theme, lastItem: dropdownOptions.length - 1 === index }, row[removeQuotes(field)])); }) })) })) })));
470
+ }, children: (0, jsx_runtime_1.jsx)(contexts_1.HoveredValueContext.Provider, { value: { hoveredValue: hoveredDropdownValue }, children: dropdownOptions.map((row, index) => ((0, jsx_runtime_1.jsx)(Dropdown_1.DropdownItem, { value: row[removeQuotes(field)], text: row[removeQuotes(label)], theme: theme, lastItem: dropdownOptions.length - 1 === index }, row[removeQuotes(field)]))) }) }) }));
499
471
  }
500
472
  //# sourceMappingURL=Dashboard.js.map