@quillsql/react 1.6.9 → 1.7.1

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 (201) 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.js +378 -491
  6. package/lib/Chart.js.map +1 -1
  7. package/lib/Context.d.ts +3 -3
  8. package/lib/Context.js +94 -96
  9. package/lib/Context.js.map +1 -1
  10. package/lib/Dashboard.js +200 -217
  11. package/lib/Dashboard.js.map +1 -1
  12. package/lib/DateRangePicker/Calendar.js +87 -91
  13. package/lib/DateRangePicker/Calendar.js.map +1 -1
  14. package/lib/DateRangePicker/DateRangePicker.js +70 -68
  15. package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
  16. package/lib/DateRangePicker/DateRangePickerButton.js +46 -57
  17. package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
  18. package/lib/DateRangePicker/dateRangePickerUtils.js +105 -99
  19. package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
  20. package/lib/DateRangePicker/index.js +8 -1
  21. package/lib/DateRangePicker/index.js.map +1 -1
  22. package/lib/PieChart.js +221 -225
  23. package/lib/PieChart.js.map +1 -1
  24. package/lib/QuillProvider.d.ts +2 -1
  25. package/lib/QuillProvider.js +8 -18
  26. package/lib/QuillProvider.js.map +1 -1
  27. package/lib/ReportBuilder.d.ts +1 -1
  28. package/lib/ReportBuilder.js +430 -526
  29. package/lib/ReportBuilder.js.map +1 -1
  30. package/lib/SQLEditor.js +183 -268
  31. package/lib/SQLEditor.js.map +1 -1
  32. package/lib/Table.js +213 -256
  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/package.json +9 -2
  109. package/rollup.config.ts +21 -0
  110. package/src/AddToDashboardModal.tsx +10 -3
  111. package/src/Chart.tsx +66 -195
  112. package/src/Context.tsx +10 -27
  113. package/src/Dashboard.tsx +40 -23
  114. package/src/QuillProvider.tsx +3 -0
  115. package/src/ReportBuilder.tsx +10 -5
  116. package/src/SQLEditor.tsx +9 -4
  117. package/src/Table.tsx +0 -1
  118. package/src/hooks/useQuill.ts +2 -1
  119. package/lib/AddToDashboardButton.d.ts +0 -1
  120. package/lib/AddToDashboardButton.js +0 -2
  121. package/lib/AddToDashboardButton.js.map +0 -1
  122. package/lib/AppContext.d.ts +0 -29
  123. package/lib/AppContext.js +0 -94
  124. package/lib/AppContext.js.map +0 -1
  125. package/lib/Button.d.ts +0 -26
  126. package/lib/Button.js +0 -151
  127. package/lib/Button.js.map +0 -1
  128. package/lib/ContextProvider.d.ts +0 -28
  129. package/lib/ContextProvider.js +0 -93
  130. package/lib/ContextProvider.js.map +0 -1
  131. package/lib/DateRangePicker.d.ts +0 -32
  132. package/lib/DateRangePicker.js +0 -105
  133. package/lib/DateRangePicker.js.map +0 -1
  134. package/lib/Dialog.d.ts +0 -68
  135. package/lib/Dialog.js +0 -407
  136. package/lib/Dialog.js.map +0 -1
  137. package/lib/Portal.d.ts +0 -32
  138. package/lib/Portal.js +0 -171
  139. package/lib/Portal.js.map +0 -1
  140. package/lib/Props.d.ts +0 -0
  141. package/lib/Props.js +0 -2
  142. package/lib/Props.js.map +0 -1
  143. package/lib/components/BigModal/Modal.d.ts +0 -14
  144. package/lib/components/BigModal/Modal.js +0 -109
  145. package/lib/components/BigModal/Modal.js.map +0 -1
  146. package/lib/components/Modal/Dropdown/Dropdown.d.ts +0 -12
  147. package/lib/components/Modal/Dropdown/Dropdown.js +0 -52
  148. package/lib/components/Modal/Dropdown/Dropdown.js.map +0 -1
  149. package/lib/components/Modal/Dropdown/DropdownItem.d.ts +0 -8
  150. package/lib/components/Modal/Dropdown/DropdownItem.js +0 -51
  151. package/lib/components/Modal/Dropdown/DropdownItem.js.map +0 -1
  152. package/lib/components/Modal/Dropdown/index.d.ts +0 -2
  153. package/lib/components/Modal/Dropdown/index.js +0 -3
  154. package/lib/components/Modal/Dropdown/index.js.map +0 -1
  155. package/lib/hooks/useSyncRefs.d.ts +0 -5
  156. package/lib/hooks/useSyncRefs.js +0 -38
  157. package/lib/hooks/useSyncRefs.js.map +0 -1
  158. package/lib/lib/colorClassNames.d.ts +0 -19
  159. package/lib/lib/colorClassNames.js +0 -3175
  160. package/lib/lib/colorClassNames.js.map +0 -1
  161. package/lib/lib/constants.d.ts +0 -16
  162. package/lib/lib/constants.js +0 -47
  163. package/lib/lib/constants.js.map +0 -1
  164. package/lib/lib/font.d.ts +0 -13
  165. package/lib/lib/font.js +0 -14
  166. package/lib/lib/font.js.map +0 -1
  167. package/lib/lib/hexColors.d.ts +0 -3
  168. package/lib/lib/hexColors.js +0 -29
  169. package/lib/lib/hexColors.js.map +0 -1
  170. package/lib/lib/index.d.ts +0 -3
  171. package/lib/lib/index.js +0 -4
  172. package/lib/lib/index.js.map +0 -1
  173. package/lib/lib/inputTypes.d.ts +0 -20
  174. package/lib/lib/inputTypes.js +0 -56
  175. package/lib/lib/inputTypes.js.map +0 -1
  176. package/lib/lib/shape.d.ts +0 -73
  177. package/lib/lib/shape.js +0 -74
  178. package/lib/lib/shape.js.map +0 -1
  179. package/lib/lib/sizing.d.ts +0 -46
  180. package/lib/lib/sizing.js +0 -43
  181. package/lib/lib/sizing.js.map +0 -1
  182. package/lib/lib/spacing.d.ts +0 -264
  183. package/lib/lib/spacing.js +0 -265
  184. package/lib/lib/spacing.js.map +0 -1
  185. package/lib/lib/theme.d.ts +0 -22
  186. package/lib/lib/theme.js +0 -46
  187. package/lib/lib/theme.js.map +0 -1
  188. package/lib/lib/utils.d.ts +0 -9
  189. package/lib/lib/utils.js +0 -40
  190. package/lib/lib/utils.js.map +0 -1
  191. package/lib/styles.css +0 -15795
  192. package/lib/types/Props.d.ts +0 -0
  193. package/lib/types/Props.js +0 -2
  194. package/lib/types/Props.js.map +0 -1
  195. package/lib/types.d.ts +0 -27
  196. package/lib/types.js +0 -6
  197. package/lib/types.js.map +0 -1
  198. package/src/lib/font.ts +0 -14
  199. package/src/lib/index.ts +0 -3
  200. package/src/lib/inputTypes.ts +0 -81
  201. package/src/lib/utils.tsx +0 -46
package/lib/Chart.js CHANGED
@@ -1,74 +1,47 @@
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;
47
24
  };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
56
27
  };
57
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ChartTooltipRow = exports.ChartTooltipFrame = exports.valueFormatter = void 0;
30
+ const jsx_runtime_1 = require("react/jsx-runtime");
58
31
  /* eslint-disable @typescript-eslint/ban-ts-comment */
59
32
  // @ts-nocheck
60
- import { useState, useEffect, useContext, useMemo } from 'react';
61
- import { Area, CartesianGrid, ComposedChart as ReChartsAreaChart, ResponsiveContainer, Tooltip, XAxis, YAxis, Bar, BarChart as ReChartsBarChart, } from 'recharts';
62
- import { endOfWeek, format, isValid, startOfWeek } from 'date-fns';
63
- import { utcToZonedTime } from 'date-fns-tz';
64
- import BarList from './BarList';
65
- import PieChart, { findComplementaryAndAnalogousColors } from './PieChart';
66
- import axios from 'axios';
67
- import { ClientContext, DashboardContext, DateFilterContext, ThemeContext, DashboardFiltersContext, } from './Context';
68
- import Skeleton from 'react-loading-skeleton';
69
- import 'react-loading-skeleton/dist/skeleton.css';
70
- import TableChart from './TableChart';
71
- var colorValues = [
33
+ const react_1 = require("react");
34
+ const recharts_1 = require("recharts");
35
+ const date_fns_1 = require("date-fns");
36
+ const date_fns_tz_1 = require("date-fns-tz");
37
+ const BarList_1 = __importDefault(require("./BarList"));
38
+ const PieChart_1 = __importStar(require("./PieChart"));
39
+ const axios_1 = __importDefault(require("axios"));
40
+ const Context_1 = require("./Context");
41
+ const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
42
+ require("react-loading-skeleton/dist/skeleton.css");
43
+ const TableChart_1 = __importDefault(require("./TableChart"));
44
+ const colorValues = [
72
45
  'slate',
73
46
  'gray',
74
47
  'zinc',
@@ -124,21 +97,20 @@ var colorValues = [
124
97
  // 'The Pragmatic Engineer': 1726,
125
98
  // },
126
99
  // ];
127
- export var valueFormatter = function (_a) {
128
- var value = _a.value, field = _a.field, fields = _a.fields;
100
+ const valueFormatter = ({ value, field, fields }) => {
129
101
  if (value === undefined ||
130
102
  value === null ||
131
103
  field === undefined ||
132
104
  field === null) {
133
105
  return '';
134
106
  }
135
- var fieldInfo = fields.find(function (f) { return f.field === field; });
107
+ const fieldInfo = fields.find(f => f.field === field);
136
108
  if (!fieldInfo) {
137
109
  return '';
138
110
  }
139
- var formatType = fieldInfo.format;
140
- var numValue = Number(value);
141
- var absNumber = isNaN(numValue) ? 0 : Math.abs(numValue);
111
+ const formatType = fieldInfo.format;
112
+ const numValue = Number(value);
113
+ const absNumber = isNaN(numValue) ? 0 : Math.abs(numValue);
142
114
  if (formatType === 'percent') {
143
115
  if (absNumber < 1) {
144
116
  return (absNumber * 100).toFixed(0) + '%';
@@ -148,7 +120,7 @@ export var valueFormatter = function (_a) {
148
120
  }
149
121
  }
150
122
  if (formatType === 'dollar_amount') {
151
- var formatter = new Intl.NumberFormat('en-US', {
123
+ const formatter = new Intl.NumberFormat('en-US', {
152
124
  style: 'currency',
153
125
  currency: 'USD',
154
126
  minimumFractionDigits: 0,
@@ -175,36 +147,36 @@ export var valueFormatter = function (_a) {
175
147
  formatType === 'hh_ap_pm' ||
176
148
  formatType === 'MMM_dd-MMM_dd' ||
177
149
  formatType === 'MMM_dd_hh:mm_ap_pm') {
178
- var dateValue = new Date(value);
179
- var utcDate = utcToZonedTime(dateValue, 'UTC');
180
- if (!isValid(utcDate)) {
150
+ const dateValue = new Date(value);
151
+ const utcDate = (0, date_fns_tz_1.utcToZonedTime)(dateValue, 'UTC');
152
+ if (!(0, date_fns_1.isValid)(utcDate)) {
181
153
  return 'Invalid date';
182
154
  }
183
155
  if (formatType === 'MMM_yyyy') {
184
- return format(utcDate, 'MMM yyyy');
156
+ return (0, date_fns_1.format)(utcDate, 'MMM yyyy');
185
157
  }
186
158
  if (formatType === 'MMM_dd_yyyy') {
187
- return format(utcDate, 'dd MMM yyyy');
159
+ return (0, date_fns_1.format)(utcDate, 'dd MMM yyyy');
188
160
  }
189
161
  if (formatType === 'hh_ap_pm') {
190
- return format(utcDate, 'hh:mm aa');
162
+ return (0, date_fns_1.format)(utcDate, 'hh:mm aa');
191
163
  }
192
164
  if (formatType === 'MMM_dd-MMM_dd') {
193
- var start = startOfWeek(utcDate, { weekStartsOn: 1 }); // Monday
194
- var end = endOfWeek(utcDate, { weekStartsOn: 1 }); // Sunday
195
- var formattedDate = '';
165
+ const start = (0, date_fns_1.startOfWeek)(utcDate, { weekStartsOn: 1 }); // Monday
166
+ const end = (0, date_fns_1.endOfWeek)(utcDate, { weekStartsOn: 1 }); // Sunday
167
+ let formattedDate = '';
196
168
  // Check if start and end are in the same month
197
- if (format(start, 'MMM') === format(end, 'MMM')) {
198
- formattedDate = "".concat(format(start, 'MMM dd'), " - ").concat(format(end, 'dd'));
169
+ if ((0, date_fns_1.format)(start, 'MMM') === (0, date_fns_1.format)(end, 'MMM')) {
170
+ formattedDate = `${(0, date_fns_1.format)(start, 'MMM dd')} - ${(0, date_fns_1.format)(end, 'dd')}`;
199
171
  }
200
172
  else {
201
- formattedDate = "".concat(format(start, 'MMM dd'), " - ").concat(format(end, 'MMM dd'));
173
+ formattedDate = `${(0, date_fns_1.format)(start, 'MMM dd')} - ${(0, date_fns_1.format)(end, 'MMM dd')}`;
202
174
  }
203
175
  return formattedDate;
204
176
  }
205
177
  if (formatType === 'MMM_dd_hh:mm_ap_pm') {
206
- var formatStr = utcDate.getMinutes() === 0 ? 'MMM do h a' : 'MMM do h:mm a';
207
- var formattedTime = format(utcDate, formatStr);
178
+ const formatStr = utcDate.getMinutes() === 0 ? 'MMM do h a' : 'MMM do h:mm a';
179
+ let formattedTime = (0, date_fns_1.format)(utcDate, formatStr);
208
180
  formattedTime =
209
181
  formattedTime.slice(0, -2) + formattedTime.slice(-2).toLowerCase();
210
182
  return formattedTime;
@@ -215,85 +187,81 @@ export var valueFormatter = function (_a) {
215
187
  }
216
188
  return value.toString();
217
189
  };
218
- var yAxisFields = [
190
+ exports.valueFormatter = valueFormatter;
191
+ const yAxisFields = [
219
192
  { field: 'avg_days', label: 'average days' },
220
193
  { field: 'median_days', label: 'median days' },
221
194
  ];
222
- var labelFormatter = function (name) {
195
+ const labelFormatter = (name) => {
223
196
  // return yAxisFields.filter(elem => elem.field === name)[0].label;
224
197
  return name;
225
198
  };
226
- export var ChartTooltipFrame = function (_a) {
227
- var children = _a.children, theme = _a.theme;
228
- return (_jsx("div", __assign({ style: {
229
- borderStyle: 'solid',
230
- borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E5E7EB',
231
- overflow: 'hidden',
232
- borderWidth: 1,
233
- background: (theme === null || theme === void 0 ? void 0 : theme.backgroundColor) || '#ffffff',
234
- borderRadius: '6px',
235
- boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
236
- } }, { children: children })));
237
- };
238
- export var ChartTooltipRow = function (_a) {
239
- var value = _a.value, name = _a.name, color = _a.color, theme = _a.theme;
240
- return (_jsxs("div", __assign({ style: {
241
- marginRight: '24px',
242
- display: 'flex',
243
- alignItems: 'center',
244
- justifyContent: 'space-between',
245
- width: '100%',
246
- paddingTop: 2,
247
- paddingBottom: 2,
248
- } }, { children: [_jsxs("div", __assign({
249
- // className="qq-flex qq-items-center qq-space-x-2"
250
- style: {
251
- // marginLeft: '0.5rem',
252
- display: 'flex',
253
- alignItems: 'center',
254
- } }, { children: [_jsx("span", { style: {
255
- background: color,
256
- borderWidth: 2,
257
- borderColor: 'white',
258
- borderStyle: 'solid',
259
- borderColor: 'white',
260
- boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
261
- height: '8px',
262
- width: '8px',
263
- borderRadius: 100,
264
- marginRight: 4,
265
- } }), _jsx("p", __assign({
266
- // className={twMerge(
267
- // 'font-medium tabular-nums text-right whitespace-nowrap',
268
- // 'text-[#212121] !important'
269
- // )}
270
- style: {
271
- marginTop: 0,
272
- marginBottom: 0,
273
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
274
- color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
275
- fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '14px',
276
- fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightMedium) || '500',
277
- } }, { children: value }))] })), _jsx("p", __assign({ style: {
278
- marginTop: 0,
279
- marginBottom: 0,
280
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
281
- color: theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor,
282
- textAlign: 'right',
283
- whiteSpace: 'nowrap',
284
- overflow: 'hidden',
285
- textOverflow: 'ellipsis',
286
- fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '14px',
287
- fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightNormal) || '400',
288
- } }, { children: name }))] })));
289
- };
290
- var ChartTooltip = function (_a) {
291
- var active = _a.active, payload = _a.payload, label = _a.label, colors = _a.colors, valueFormatter = _a.valueFormatter, dateFormatter = _a.dateFormatter, theme = _a.theme;
199
+ const ChartTooltipFrame = ({ children, theme, }) => ((0, jsx_runtime_1.jsx)("div", { style: {
200
+ borderStyle: 'solid',
201
+ borderColor: theme?.borderColor || '#E5E7EB',
202
+ overflow: 'hidden',
203
+ borderWidth: 1,
204
+ background: theme?.backgroundColor || '#ffffff',
205
+ borderRadius: '6px',
206
+ boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
207
+ }, children: children }));
208
+ exports.ChartTooltipFrame = ChartTooltipFrame;
209
+ const ChartTooltipRow = ({ value, name, color, theme, }) => ((0, jsx_runtime_1.jsxs)("div", { style: {
210
+ marginRight: '24px',
211
+ display: 'flex',
212
+ alignItems: 'center',
213
+ justifyContent: 'space-between',
214
+ width: '100%',
215
+ paddingTop: 2,
216
+ paddingBottom: 2,
217
+ }, children: [(0, jsx_runtime_1.jsxs)("div", {
218
+ // className="qq-flex qq-items-center qq-space-x-2"
219
+ style: {
220
+ // marginLeft: '0.5rem',
221
+ display: 'flex',
222
+ alignItems: 'center',
223
+ }, children: [(0, jsx_runtime_1.jsx)("span", { style: {
224
+ background: color,
225
+ borderWidth: 2,
226
+ borderColor: 'white',
227
+ borderStyle: 'solid',
228
+ borderColor: 'white',
229
+ boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
230
+ height: '8px',
231
+ width: '8px',
232
+ borderRadius: 100,
233
+ marginRight: 4,
234
+ } }), (0, jsx_runtime_1.jsx)("p", {
235
+ // className={twMerge(
236
+ // 'font-medium tabular-nums text-right whitespace-nowrap',
237
+ // 'text-[#212121] !important'
238
+ // )}
239
+ style: {
240
+ marginTop: 0,
241
+ marginBottom: 0,
242
+ fontFamily: theme?.fontFamily,
243
+ color: theme?.primaryTextColor,
244
+ fontSize: theme?.fontSizeSmall || '14px',
245
+ fontWeight: theme?.fontWeightMedium || '500',
246
+ }, children: value })] }), (0, jsx_runtime_1.jsx)("p", { style: {
247
+ marginTop: 0,
248
+ marginBottom: 0,
249
+ fontFamily: theme?.fontFamily,
250
+ color: theme?.secondaryTextColor,
251
+ textAlign: 'right',
252
+ whiteSpace: 'nowrap',
253
+ overflow: 'hidden',
254
+ textOverflow: 'ellipsis',
255
+ fontSize: theme?.fontSizeSmall || '14px',
256
+ fontWeight: theme?.fontWeightNormal || '400',
257
+ }, children: name })] }));
258
+ exports.ChartTooltipRow = ChartTooltipRow;
259
+ const ChartTooltip = ({ active, payload, label, colors, valueFormatter, dateFormatter, theme, }) => {
292
260
  if (active && payload) {
293
- return (_jsxs(ChartTooltipFrame, __assign({ theme: theme }, { children: [_jsx("div", __assign({ style: {
261
+ return ((0, jsx_runtime_1.jsxs)(exports.ChartTooltipFrame, { theme: theme, children: [(0, jsx_runtime_1.jsx)("div", { style: {
294
262
  borderStyle: 'solid',
295
- borderBottomColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E5E7EB',
296
- background: (theme === null || theme === void 0 ? void 0 : theme.backgroundColor) || 'white',
263
+ borderBottomColor: theme?.borderColor || '#E5E7EB',
264
+ background: theme?.backgroundColor || 'white',
297
265
  borderTop: 'none',
298
266
  borderLeft: 'none',
299
267
  borderRight: 'none',
@@ -304,21 +272,21 @@ var ChartTooltip = function (_a) {
304
272
  paddingRight: '16px',
305
273
  paddingTop: '8px',
306
274
  paddingBottom: '8px',
307
- } }, { children: _jsx("p", __assign({ style: {
275
+ }, children: (0, jsx_runtime_1.jsx)("p", { style: {
308
276
  textAlign: 'left',
309
277
  marginTop: 0,
310
278
  marginBottom: 0,
311
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
312
- color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
313
- fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '14px',
314
- fontWeight: (theme === null || theme === void 0 ? void 0 : theme.boldFontWeight) || '500',
279
+ fontFamily: theme?.fontFamily,
280
+ color: theme?.primaryTextColor,
281
+ fontSize: theme?.fontSizeSmall || '14px',
282
+ fontWeight: theme?.boldFontWeight || '500',
315
283
  paddingTop: 2,
316
284
  paddingBottom: 2,
317
- } }, { children: !isNaN(new Date(label)) && dateFormatter
285
+ }, children: !isNaN(new Date(label)) && dateFormatter
318
286
  ? dateFormatter(label)
319
287
  : !isNaN(new Date(label))
320
- ? format(new Date(label), 'MMM yyyy')
321
- : label })) })), _jsx("div", __assign({
288
+ ? (0, date_fns_1.format)(new Date(label), 'MMM yyyy')
289
+ : label }) }), (0, jsx_runtime_1.jsx)("div", {
322
290
  // className="qq-px-4 qq-space-y-1 qq-py-2 qq-px-4"
323
291
  style: {
324
292
  paddingRight: '16px',
@@ -326,272 +294,201 @@ var ChartTooltip = function (_a) {
326
294
  paddingTop: '8px',
327
295
  paddingBottom: '8px',
328
296
  // marginTop: '0.25rem',
329
- } }, { children: payload.map(function (_a, idx) {
330
- var value = _a.value, name = _a.name;
331
- return (_jsx(ChartTooltipRow, { value: valueFormatter(value), name: labelFormatter(name),
332
- // color={categoryColors.get(name) ?? BaseColors.Blue}
333
- color: colors[idx], theme: theme }, "id-".concat(idx)));
334
- }) }))] })));
297
+ }, children: payload.map(({ value, name }, idx) => ((0, jsx_runtime_1.jsx)(exports.ChartTooltipRow, { value: valueFormatter(value), name: labelFormatter(name),
298
+ // color={categoryColors.get(name) ?? BaseColors.Blue}
299
+ color: colors[idx], theme: theme }, `id-${idx}`))) })] }));
335
300
  }
336
301
  return null;
337
302
  };
338
303
  // @ts-ignore
339
304
  function sumByKey(arr, key) {
340
305
  // @ts-ignore
341
- return arr.reduce(function (acc, cur) {
342
- var val = parseInt(cur[key], 10);
306
+ return arr.reduce((acc, cur) => {
307
+ const val = parseInt(cur[key], 10);
343
308
  return isNaN(val) ? acc : acc + val;
344
309
  }, 0);
345
310
  }
346
- var Chart = function (_a) {
347
- var chartId = _a.chartId, config = _a.config, colors = _a.colors, containerStyle = _a.containerStyle, dateFilter = _a.dateFilter, query = _a.query;
348
- var _b = useContext(DashboardContext), dispatch = _b.dispatch, dashboard = _b.dashboard;
349
- var dateFilterObj = useContext(DateFilterContext).dateFilterObj;
350
- var dashboardFilters = useContext(DashboardFiltersContext).dashboardFilters;
351
- var _c = useContext(ClientContext), client = _c[0], _ = _c[1];
352
- var theme = useContext(ThemeContext)[0];
353
- var chartColors = useMemo(function () {
354
- return (colors === null || colors === void 0 ? void 0 : colors.length) ? colors : ['#6269E9', '#E14F62'];
311
+ const Chart = ({ chartId, config, colors, containerStyle, dateFilter, query, }) => {
312
+ const { dispatch, dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
313
+ const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
314
+ const [client, _] = (0, react_1.useContext)(Context_1.ClientContext);
315
+ const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
316
+ const chartColors = (0, react_1.useMemo)(() => {
317
+ return colors?.length ? colors : ['#6269E9', '#E14F62'];
355
318
  }, [colors]);
356
- return (_jsx(ChartUpdater, { config: config, dispatch: dispatch, dashboard: dashboard, dateFilter: dateFilterObj, chartId: chartId, containerStyle: containerStyle, colors: chartColors, client: client, theme: theme, isDateFilter: dateFilter, dashboardFilters: dashboardFilters, query: query }));
319
+ return ((0, jsx_runtime_1.jsx)(ChartUpdater, { config: config, dispatch: dispatch, dashboard: dashboard, chartId: chartId, containerStyle: containerStyle, colors: chartColors, client: client, theme: theme, isDateFilter: dateFilter, dashboardFilters: dashboardFilters, query: query }));
357
320
  };
358
- function didFiltersChange(filterObject1, filterObject2) {
359
- // Both objects are null or undefined
360
- if (!filterObject1 && !filterObject2) {
361
- return false;
362
- }
363
- // One of the objects is null or undefined but the other is not
364
- if ((!filterObject1 || Object.keys(filterObject1).length === 0) &&
365
- filterObject2 &&
366
- Object.keys(filterObject2).length > 0) {
367
- return true;
368
- }
369
- if ((!filterObject2 || Object.keys(filterObject2).length === 0) &&
370
- filterObject1 &&
371
- Object.keys(filterObject1).length > 0) {
372
- return true;
373
- }
374
- // Objects have different number of keys
375
- if (filterObject1 &&
376
- filterObject2 &&
377
- Object.keys(filterObject1).length !== Object.keys(filterObject2).length) {
378
- return true;
379
- }
380
- for (var filterId in filterObject1) {
381
- if (filterObject2 && !filterObject2.hasOwnProperty(filterId)) {
382
- return true;
383
- }
384
- if (filterObject1 &&
385
- filterObject2 &&
386
- JSON.stringify(filterObject1[filterId]) !==
387
- JSON.stringify(filterObject2[filterId])) {
388
- // If the selectedValue field exists and is not undefined in either object
389
- if (('selectedValue' in filterObject1[filterId] &&
390
- filterObject1[filterId].selectedValue !== undefined) ||
391
- ('selectedValue' in filterObject2[filterId] &&
392
- filterObject2[filterId].selectedValue !== undefined)) {
393
- return true;
394
- }
395
- }
396
- }
397
- return false;
398
- }
399
- var ChartUpdater = function (_a) {
400
- var colors = _a.colors, chartId = _a.chartId, config = _a.config, containerStyle = _a.containerStyle, dashboard = _a.dashboard, dateFilter = _a.dateFilter, dispatch = _a.dispatch, client = _a.client, theme = _a.theme, isDateFilter = _a.isDateFilter, dashboardFilters = _a.dashboardFilters, query = _a.query;
401
- var _b = useState(config || null), chartConfig = _b[0], setChartConfig = _b[1];
402
- var _c = useState(true), loading = _c[0], setLoading = _c[1];
321
+ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, dispatch, client, theme, isDateFilter, dashboardFilters, query, }) => {
322
+ const [loading, setLoading] = (0, react_1.useState)(true);
403
323
  // console.log('chartConfig:', chartConfig);
404
324
  // console.log('chartConfig.rows:', chartConfig.rows);
405
325
  // console.log('chartConfig.xAxisField:', chartConfig.xAxisField);
406
- useEffect(function () {
407
- if (isDateFilter && !dateFilter.startDate && !dateFilter.endDate) {
326
+ (0, react_1.useEffect)(() => {
327
+ if (isDateFilter && !dateFilter) {
408
328
  return;
409
329
  }
410
- var isSubscribed = true;
411
- function getChartOptions(id, filtersChanged) {
412
- return __awaiter(this, void 0, void 0, function () {
413
- var _a, xAxisField, yAxisFields_1, xAxisLabel, yAxisLabel, xAxisFormat, chartType, rows, startDate, endDate, filters, publicKey, customerId, environment, queryEndpoint, queryHeaders, resp, _b, xAxisField, yAxisFields_2, xAxisLabel, yAxisLabel, xAxisFormat, chartType, resp, _c, xAxisField, yAxisFields_3, xAxisLabel, yAxisLabel, xAxisFormat, chartType, rows, e_1;
414
- return __generator(this, function (_d) {
415
- switch (_d.label) {
416
- case 0:
417
- if (!isSubscribed) return [3 /*break*/, 7];
418
- if (dashboard &&
419
- dashboard[id] &&
420
- !filtersChanged &&
421
- (!isDateFilter ||
422
- dashboard[id].startDate === dateFilter.startDate ||
423
- dashboard[id].endDate === dateFilter.endDate)) {
424
- _a = dashboard[id], xAxisField = _a.xAxisField, yAxisFields_1 = _a.yAxisFields, xAxisLabel = _a.xAxisLabel, yAxisLabel = _a.yAxisLabel, xAxisFormat = _a.xAxisFormat, chartType = _a.chartType, rows = _a.rows, startDate = _a.startDate, endDate = _a.endDate, filters = _a.filters;
425
- setChartConfig({
426
- xAxisField: xAxisField,
427
- yAxisFields: yAxisFields_1,
428
- xAxisLabel: xAxisLabel,
429
- yAxisLabel: yAxisLabel,
430
- xAxisFormat: xAxisFormat,
431
- chartType: chartType,
432
- rows: rows,
433
- startDate: startDate,
434
- endDate: endDate,
435
- filters: filters,
436
- });
437
- setLoading(false);
438
- return [2 /*return*/];
439
- }
440
- publicKey = client.publicKey, customerId = client.customerId, environment = client.environment, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders;
441
- setLoading(true);
442
- _d.label = 1;
443
- case 1:
444
- _d.trys.push([1, 6, , 7]);
445
- if (!queryEndpoint) return [3 /*break*/, 3];
446
- return [4 /*yield*/, axios.post(queryEndpoint, { metadata: { id: chartId, task: 'item' } }, { headers: queryHeaders })];
447
- case 2:
448
- resp = _d.sent();
449
- if (resp.data) {
450
- _b = resp.data, xAxisField = _b.xAxisField, yAxisFields_2 = _b.yAxisFields, xAxisLabel = _b.xAxisLabel, yAxisLabel = _b.yAxisLabel, xAxisFormat = _b.xAxisFormat, chartType = _b.chartType;
451
- setChartConfig({
452
- xAxisField: xAxisField,
453
- yAxisFields: yAxisFields_2,
454
- xAxisLabel: xAxisLabel,
455
- yAxisLabel: yAxisLabel,
456
- xAxisFormat: xAxisFormat,
457
- chartType: chartType,
458
- rows: resp.data.rows,
459
- filters: dashboardFilters,
460
- });
461
- setLoading(false);
462
- dispatch({
463
- type: 'UPDATE_DASHBOARD_ITEM',
464
- id: id,
465
- data: __assign(__assign({}, resp.data), { filters: dashboardFilters }),
466
- });
467
- }
468
- return [3 /*break*/, 5];
469
- case 3: return [4 /*yield*/, axios.get('https://quill-344421.uc.r.appspot.com/item', {
470
- params: {
471
- id: chartId,
472
- orgId: customerId,
473
- publicKey: publicKey,
474
- filters: Object.keys(dashboardFilters).map(function (key) { return dashboardFilters[key]; }),
475
- // startDate:
476
- // dateFilter &&
477
- // dateFilter.startDate &&
478
- // dateFilter.startDate.toISOString(),
479
- // endDate:
480
- // dateFilter &&
481
- // dateFilter.endDate &&
482
- // dateFilter.endDate.toISOString(),
330
+ let isSubscribed = true;
331
+ async function getChartOptions() {
332
+ if (isSubscribed) {
333
+ const { publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, } = client;
334
+ //queryEndpoint = undefined;
335
+ setLoading(true);
336
+ try {
337
+ // if self-hosting option, only get metadata and query
338
+ if (queryEndpoint) {
339
+ // const resp = await axios.get(
340
+ // 'https://quill-344421.uc.r.appspot.com/selfhostitem',
341
+ // {
342
+ // params: {
343
+ // id: chartId,
344
+ // orgId: customerId,
345
+ // publicKey: publicKey,
346
+ // },
347
+ // environment: environment || undefined,
348
+ // }
349
+ // );
350
+ if (dashboardFilters['date_range'] && dashboard[chartId]) {
351
+ const dateFilter = dashboardFilters['date_range'];
352
+ dateFilter.dateField = dashboard[chartId].dateField;
353
+ }
354
+ const resp = await axios_1.default.post(queryEndpoint, {
355
+ metadata: {
356
+ id: chartId,
357
+ task: 'item',
358
+ filters: {
359
+ ...Object.entries(dashboardFilters)
360
+ .filter(([key]) => key !== 'date_range')
361
+ .map(([, value]) => value),
362
+ dateFilter,
483
363
  },
484
- headers: {
485
- environment: environment || undefined,
364
+ },
365
+ }, { headers: queryHeaders, withCredentials });
366
+ if (resp.data) {
367
+ setLoading(false);
368
+ dispatch({
369
+ type: 'UPDATE_DASHBOARD_ITEM',
370
+ id: chartId,
371
+ data: {
372
+ ...resp.data,
486
373
  },
487
- })];
488
- case 4:
489
- resp = _d.sent();
490
- // console.log('RESP: ', resp.data);
491
- if (resp.data) {
492
- _c = resp.data, xAxisField = _c.xAxisField, yAxisFields_3 = _c.yAxisFields, xAxisLabel = _c.xAxisLabel, yAxisLabel = _c.yAxisLabel, xAxisFormat = _c.xAxisFormat, chartType = _c.chartType, rows = _c.rows;
493
- setChartConfig({
494
- xAxisField: xAxisField,
495
- yAxisFields: yAxisFields_3,
496
- xAxisLabel: xAxisLabel,
497
- yAxisLabel: yAxisLabel,
498
- xAxisFormat: xAxisFormat,
499
- chartType: chartType,
500
- rows: rows,
501
- startDate: dateFilter && dateFilter.startDate,
502
- endDate: dateFilter && dateFilter.endDate,
503
- filters: dashboardFilters,
504
- });
505
- setLoading(false);
506
- dispatch({
507
- type: 'UPDATE_DASHBOARD_ITEM',
508
- id: id,
509
- data: __assign(__assign({}, resp.data), { filters: dashboardFilters }),
510
- });
511
- }
512
- _d.label = 5;
513
- case 5: return [3 /*break*/, 7];
514
- case 6:
515
- e_1 = _d.sent();
516
- console.log('Error fetching chart: ', e_1);
374
+ });
375
+ }
376
+ }
377
+ else {
378
+ const resp = await axios_1.default.get('https://quill-344421.uc.r.appspot.com/item', {
379
+ params: {
380
+ id: chartId,
381
+ orgId: customerId,
382
+ publicKey: publicKey,
383
+ filters: Object.keys(dashboardFilters).map(key => dashboardFilters[key]),
384
+ // startDate:
385
+ // dateFilter &&
386
+ // dateFilter.startDate &&
387
+ // dateFilter.startDate.toISOString(),
388
+ // endDate:
389
+ // dateFilter &&
390
+ // dateFilter.endDate &&
391
+ // dateFilter.endDate.toISOString(),
392
+ },
393
+ headers: {
394
+ environment: environment || undefined,
395
+ },
396
+ });
397
+ // console.log('RESP: ', resp.data);
398
+ if (resp.data) {
517
399
  setLoading(false);
518
- return [3 /*break*/, 7];
519
- case 7: return [2 /*return*/];
400
+ dispatch({
401
+ type: 'UPDATE_DASHBOARD_ITEM',
402
+ id: chartId,
403
+ data: { ...resp.data },
404
+ });
405
+ }
520
406
  }
521
- });
522
- });
407
+ }
408
+ catch (e) {
409
+ console.log('Error fetching chart: ', e);
410
+ setLoading(false);
411
+ }
412
+ }
523
413
  }
524
414
  if (config) {
525
415
  setLoading(false);
526
416
  return;
527
417
  }
528
- var filtersChanged = didFiltersChange(dashboardFilters, chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.filters);
529
- if ((chartId && !chartConfig) ||
530
- (chartId && chartConfig && filtersChanged) ||
531
- (chartId &&
532
- chartConfig &&
533
- isDateFilter &&
534
- dateFilter &&
535
- (chartConfig.startDate !== dateFilter.startDate ||
536
- chartConfig.endDate !== dateFilter.endDate))) {
537
- getChartOptions(chartId, filtersChanged);
538
- }
539
- return function () {
418
+ getChartOptions(); //when wouldn't you run this????? saw if statements before that implied you might not run this sometimes
419
+ return () => {
540
420
  isSubscribed = false;
541
421
  };
542
- }, [chartConfig, dateFilter, dashboardFilters]);
422
+ }, [dashboardFilters]);
543
423
  // console.log('DASHBOARD FILTERS: ', dashboardFilters);
544
- useEffect(function () {
424
+ (0, react_1.useEffect)(() => {
545
425
  if (config) {
546
- setChartConfig(config);
426
+ dispatch({
427
+ type: 'UPDATE_DASHBOARD_ITEM',
428
+ id: chartId,
429
+ data: { ...config },
430
+ });
547
431
  }
548
432
  }, [config]);
549
- if (!chartConfig || loading) {
550
- return (_jsx("div", __assign({
433
+ const dateFilter = Object.values(dashboardFilters).find(filter => filter && filter.filterType === 'DATE_RANGE');
434
+ if (!dashboard[chartId] || loading) {
435
+ return ((0, jsx_runtime_1.jsx)("div", {
551
436
  // className="flex flex-col flex-1 h-[100%]"
552
- style: __assign(__assign({}, containerStyle), { marginLeft: 25, marginRight: 25, boxSizing: 'content-box', height: '100%', display: 'flex', flexDirection: 'column', flex: 1 }) }, { children: _jsx("div", __assign({ style: {
553
- height: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.height) || 300,
437
+ style: {
438
+ ...containerStyle,
439
+ marginLeft: 25,
440
+ marginRight: 25,
441
+ boxSizing: 'content-box',
442
+ height: '100%',
443
+ display: 'flex',
444
+ flexDirection: 'column',
445
+ flex: 1,
446
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
447
+ height: containerStyle?.height || 300,
554
448
  width: '100%',
555
449
  boxSizing: 'content-box',
556
- } }, { children: _jsx(Skeleton, { count: 1,
450
+ }, children: (0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { count: 1,
557
451
  // height={containerStyle?.height}
558
- height: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.height) && (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.marginTop)
559
- ? (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.height) + (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.marginTop)
560
- : (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.height)
561
- ? containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.height
452
+ height: containerStyle?.height && containerStyle?.marginTop
453
+ ? containerStyle?.height + containerStyle?.marginTop
454
+ : containerStyle?.height
455
+ ? containerStyle?.height
562
456
  : 300, borderRadius: 8,
563
457
  // highlightColor="#F7F7F8"
564
458
  highlightColor: "#FDFDFD",
565
459
  // baseColor="#F3F4F6"
566
- baseColor: "#F9F9FA", width: "100%" }) })) })));
460
+ baseColor: "#F9F9FA", width: "100%" }) }) }));
567
461
  }
568
- if ((chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.chartType) === 'pie') {
569
- var xAxisField = chartConfig.xAxisField, yAxisFields_4 = chartConfig.yAxisFields;
570
- return (_jsx(PieChart
462
+ if (dashboard[chartId]?.chartType === 'pie') {
463
+ const { xAxisField, yAxisFields } = dashboard[chartId];
464
+ return ((0, jsx_runtime_1.jsx)(PieChart_1.default
571
465
  // @ts-ignore
572
466
  , {
573
467
  // @ts-ignore
574
- containerStyle: containerStyle, data: chartConfig.rows.map(function (row) {
575
- return __assign(__assign({}, row), { count: parseInt(row[yAxisFields_4[0].field]) /
576
- sumByKey(chartConfig.rows, yAxisFields_4[0].field) });
577
- }), category: yAxisFields_4[0].field, index: xAxisField, colors: colors, theme: theme }));
468
+ containerStyle: containerStyle, data: dashboard[chartId].rows.map(row => {
469
+ return {
470
+ ...row,
471
+ count: parseInt(row[yAxisFields[0].field]) /
472
+ sumByKey(dashboard[chartId].rows, yAxisFields[0].field),
473
+ };
474
+ }), category: yAxisFields[0].field, index: xAxisField, colors: colors, theme: theme }));
578
475
  }
579
- if ((chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.chartType) === 'table') {
580
- return (_jsx(TableChart, { data: chartConfig.rows, yAxisFields: chartConfig.yAxisFields, theme: theme, containerStyle: containerStyle }));
476
+ if (dashboard[chartId]?.chartType === 'table') {
477
+ return ((0, jsx_runtime_1.jsx)(TableChart_1.default, { data: dashboard[chartId].rows, yAxisFields: dashboard[chartId].yAxisFields, theme: theme, containerStyle: containerStyle }));
581
478
  }
582
- if ((chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.chartType) === 'bar') {
583
- return (_jsx(BarList, { data: chartConfig.rows, theme: theme, yAxisFields: chartConfig.yAxisFields, xAxisFormat: chartConfig.xAxisFormat, colors: colors, xAxisField: chartConfig.xAxisField, containerStyle: containerStyle }));
479
+ if (dashboard[chartId]?.chartType === 'bar') {
480
+ return ((0, jsx_runtime_1.jsx)(BarList_1.default, { data: dashboard[chartId].rows, theme: theme, yAxisFields: dashboard[chartId].yAxisFields, xAxisFormat: dashboard[chartId].xAxisFormat, colors: colors, xAxisField: dashboard[chartId].xAxisField, containerStyle: containerStyle }));
584
481
  }
585
- if ((chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.chartType) === 'column') {
586
- return (_jsx(BarChart, { colors: colors, theme: theme, yAxisFields: chartConfig.yAxisFields,
482
+ if (dashboard[chartId]?.chartType === 'column') {
483
+ return ((0, jsx_runtime_1.jsx)(BarChart, { colors: colors, theme: theme, yAxisFields: dashboard[chartId].yAxisFields,
587
484
  // @ts-ignore
588
- data: chartConfig.rows, xAxisField: chartConfig.xAxisField, xAxisLabel: chartConfig.xAxisLabel, xAxisFormat: chartConfig.xAxisFormat, containerStyle: containerStyle }));
485
+ data: dashboard[chartId].rows, xAxisField: dashboard[chartId].xAxisField, xAxisLabel: dashboard[chartId].xAxisLabel, xAxisFormat: dashboard[chartId].xAxisFormat, containerStyle: containerStyle }));
589
486
  }
590
- if ((chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.chartType) === 'metric') {
591
- return (_jsx("div", __assign({ style: {
592
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
487
+ if (dashboard[chartId]?.chartType === 'metric') {
488
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
489
+ fontFamily: theme?.fontFamily,
593
490
  fontSize: 32,
594
- color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
491
+ color: theme?.primaryTextColor,
595
492
  fontWeight: '600',
596
493
  textOverflow: 'ellipsis',
597
494
  margin: 0,
@@ -605,25 +502,25 @@ var ChartUpdater = function (_a) {
605
502
  maxWidth: '100%',
606
503
  textAlign: 'left',
607
504
  overflow: 'hidden',
608
- height: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.height) || '100%',
505
+ height: containerStyle?.height || '100%',
609
506
  display: 'flex',
610
507
  flexDirection: 'column',
611
508
  // background: 'red',
612
- } }, { children: chartConfig.rows.length > 0 &&
613
- valueFormatter({
614
- value: chartConfig.rows[0][chartConfig.xAxisField],
615
- field: chartConfig.xAxisField,
509
+ }, children: dashboard[chartId].rows.length > 0 &&
510
+ (0, exports.valueFormatter)({
511
+ value: dashboard[chartId].rows[0][dashboard[chartId].xAxisField],
512
+ field: dashboard[chartId].xAxisField,
616
513
  fields: [
617
514
  {
618
- field: chartConfig.xAxisField,
619
- format: chartConfig.xAxisFormat,
515
+ field: dashboard[chartId].xAxisField,
516
+ format: dashboard[chartId].xAxisFormat,
620
517
  },
621
518
  ],
622
- }) })));
519
+ }) }));
623
520
  }
624
- return (_jsx(LineChart, { colors: colors, yAxisFields: chartConfig.yAxisFields,
521
+ return ((0, jsx_runtime_1.jsx)(LineChart, { colors: colors, yAxisFields: dashboard[chartId].yAxisFields,
625
522
  // @ts-ignore
626
- data: chartConfig.rows, xAxisField: chartConfig.xAxisField, xAxisLabel: chartConfig.xAxisLabel, xAxisFormat: chartConfig.xAxisFormat, containerStyle: containerStyle, theme: theme }));
523
+ data: dashboard[chartId].rows, xAxisField: dashboard[chartId].xAxisField, xAxisLabel: dashboard[chartId].xAxisLabel, xAxisFormat: dashboard[chartId].xAxisFormat, containerStyle: containerStyle, theme: theme }));
627
524
  };
628
525
  function formatNumber(num, label) {
629
526
  num = Number(num);
@@ -657,13 +554,13 @@ function formatNumber(num, label) {
657
554
  // return [adjustedMin, adjustedMax];
658
555
  // }
659
556
  function getDomain(data, fields) {
660
- var fieldsArray = fields.map(function (elem) { return elem.field; });
661
- var numericValues = [];
662
- data.forEach(function (item) {
663
- fieldsArray.forEach(function (field) {
664
- var value = item[field];
557
+ const fieldsArray = fields.map(elem => elem.field);
558
+ const numericValues = [];
559
+ data.forEach(item => {
560
+ fieldsArray.forEach(field => {
561
+ let value = item[field];
665
562
  // Try to cast the value to a number
666
- var numericValue = parseFloat(value);
563
+ const numericValue = parseFloat(value);
667
564
  if (!isNaN(numericValue)) {
668
565
  value = numericValue;
669
566
  }
@@ -672,29 +569,36 @@ function getDomain(data, fields) {
672
569
  }
673
570
  });
674
571
  });
675
- var _a = numericValues.reduce(function (_a, value) {
676
- var min = _a[0], max = _a[1];
677
- return [Math.min(min, value), Math.max(max, value)];
678
- }, [Infinity, -Infinity]), minValue = _a[0], maxValue = _a[1];
679
- var adjustedMin = Math.min(minValue, 0);
680
- var padding = Math.round(0.2 * (maxValue - minValue));
681
- var adjustedMax = maxValue + padding;
572
+ const [minValue, maxValue] = numericValues.reduce(([min, max], value) => [Math.min(min, value), Math.max(max, value)], [Infinity, -Infinity]);
573
+ const adjustedMin = Math.min(minValue, 0);
574
+ const padding = Math.round(0.2 * (maxValue - minValue));
575
+ const adjustedMax = maxValue + padding;
682
576
  return [adjustedMin, adjustedMax];
683
577
  }
684
- var CustomizedTick = function (_a) {
685
- var x = _a.x, y = _a.y, payload = _a.payload, theme = _a.theme;
578
+ const CustomizedTick = ({ x, y, payload, theme, }) => {
686
579
  // const { x, y, payload } = props;
687
- var maxLength = 10;
688
- var value = payload.value;
689
- var truncatedValue = value.length > maxLength ? value.substring(0, maxLength) + '...' : value;
690
- return (_jsx("text", __assign({ xlinkTitle: value, fill: theme === null || theme === void 0 ? void 0 : theme.chartLabelColor, fontSize: 12, x: x, y: y + 15, width: 30, textAnchor: "middle" }, { children: truncatedValue })));
580
+ const maxLength = 10;
581
+ const value = payload.value;
582
+ const truncatedValue = value.length > maxLength ? value.substring(0, maxLength) + '...' : value;
583
+ return ((0, jsx_runtime_1.jsx)("text", { xlinkTitle: value, fill: theme?.chartLabelColor, fontSize: 12, x: x, y: y + 15, width: 30, textAnchor: "middle", children: truncatedValue }));
691
584
  };
692
- function BarChart(_a) {
693
- var colors = _a.colors, yAxisFields = _a.yAxisFields, data = _a.data, containerStyle = _a.containerStyle, xAxisField = _a.xAxisField, xAxisLabel = _a.xAxisLabel, xAxisFormat = _a.xAxisFormat, theme = _a.theme;
694
- var newColors = findComplementaryAndAnalogousColors(colors[0], colors[1]);
695
- return (_jsx("div", __assign({ style: __assign(__assign({}, containerStyle), { boxSizing: 'content-box' }) }, { children: _jsx(ResponsiveContainer, __assign({ width: "100%", height: '100%' }, { children: _jsxs(ReChartsBarChart, __assign({ data: data,
585
+ function BarChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisLabel, xAxisFormat, theme, }) {
586
+ const newColors = (0, PieChart_1.findComplementaryAndAnalogousColors)(colors[0], colors[1]);
587
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
588
+ ...containerStyle,
589
+ boxSizing: 'content-box',
590
+ // display: 'flex',
591
+ // flexDirection: 'column',
592
+ // flex: 1,
593
+ // height: '100%',
594
+ // minHeight: 400,
595
+ // minWidth: 400,
596
+ // height: 400,
597
+ // width: 800,
598
+ // width: '100%',
599
+ }, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: '100%', children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: data,
696
600
  // stackOffset={'none'}
697
- layout: 'horizontal' }, { children: [_jsx(CartesianGrid, { strokeDasharray: "3 3", horizontal: true, vertical: false }), _jsx(YAxis
601
+ layout: 'horizontal', children: [(0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { strokeDasharray: "3 3", horizontal: true, vertical: false }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis
698
602
  // width={56}
699
603
  // width={30}
700
604
  // textAnchor="start"
@@ -707,13 +611,11 @@ function BarChart(_a) {
707
611
  tick: { transform: 'translate(-3, 0)' }, style: {
708
612
  fontSize: '12px',
709
613
  fontFamily: theme.chartLabelFontFamily,
710
- }, tickFormatter: function (tick) {
711
- return valueFormatter({
712
- value: tick,
713
- field: yAxisFields[0].field || 'what',
714
- fields: yAxisFields,
715
- });
716
- } }), _jsx(XAxis, { hide: false, dataKey: xAxisField,
614
+ }, tickFormatter: tick => (0, exports.valueFormatter)({
615
+ value: tick,
616
+ field: yAxisFields[0].field || 'what',
617
+ fields: yAxisFields,
618
+ }) }), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { hide: false, dataKey: xAxisField,
717
619
  // interval="preserveStartEnd"
718
620
  tick: { transform: 'translate(0, 6)' },
719
621
  //padding between labels and axis
@@ -722,40 +624,32 @@ function BarChart(_a) {
722
624
  // TODO: generalize
723
625
  fontFamily: theme.chartLabelFontFamily,
724
626
  marginTop: '20px',
725
- }, tickLine: false, axisLine: false, tickFormatter: function (tick) {
726
- return valueFormatter({
727
- value: tick,
728
- field: xAxisField,
729
- fields: [{ field: xAxisField, format: xAxisFormat }],
730
- });
731
- } }), _jsx(Tooltip, { wrapperStyle: { outline: 'none' }, isAnimationActive: false, cursor: { fill: '#d1d5db', opacity: '0.15' }, content: function (_a) {
732
- var active = _a.active, payload = _a.payload, label = _a.label;
733
- return (_jsx(ChartTooltip, { theme: theme, active: active, payload: payload, label: label, dateFormatter: function (value) {
734
- return valueFormatter({
735
- value: value,
736
- field: xAxisField,
737
- fields: [{ field: xAxisField, format: xAxisFormat }],
738
- });
739
- }, valueFormatter: function (value) {
740
- return valueFormatter({
741
- value: value,
742
- field: payload[0].dataKey,
743
- fields: yAxisFields,
744
- });
745
- }, colors: newColors }));
746
- }, position: { y: 0 } }), yAxisFields.map(function (elem, index) { return (_jsx(Bar, { name: elem.label, dataKey: elem.field, type: "linear",
627
+ }, tickLine: false, axisLine: false, tickFormatter: tick => (0, exports.valueFormatter)({
628
+ value: tick,
629
+ field: xAxisField,
630
+ fields: [{ field: xAxisField, format: xAxisFormat }],
631
+ }) }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { wrapperStyle: { outline: 'none' }, isAnimationActive: false, cursor: { fill: '#d1d5db', opacity: '0.15' }, content: ({ active, payload, label }) => {
632
+ return ((0, jsx_runtime_1.jsx)(ChartTooltip, { theme: theme, active: active, payload: payload, label: label, dateFormatter: value => (0, exports.valueFormatter)({
633
+ value,
634
+ field: xAxisField,
635
+ fields: [{ field: xAxisField, format: xAxisFormat }],
636
+ }), valueFormatter: value => (0, exports.valueFormatter)({
637
+ value,
638
+ field: payload[0].dataKey,
639
+ fields: yAxisFields,
640
+ }), colors: newColors }));
641
+ }, position: { y: 0 } }), yAxisFields.map((elem, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { name: elem.label, dataKey: elem.field, type: "linear",
747
642
  // stackId={stack || relative ? "a" : undefined}
748
643
  fill: newColors[index],
749
644
  // barSize={20}
750
- isAnimationActive: true }, elem.field)); })] })) })) })));
645
+ isAnimationActive: true }, elem.field)))] }) }) }));
751
646
  }
752
- function LineChart(_a) {
753
- var colors = _a.colors, yAxisFields = _a.yAxisFields, data = _a.data, containerStyle = _a.containerStyle, xAxisField = _a.xAxisField, xAxisLabel = _a.xAxisLabel, xAxisFormat = _a.xAxisFormat, theme = _a.theme;
647
+ function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisLabel, xAxisFormat, theme, }) {
754
648
  // console.log('CONTAINER: ', containerStyle);
755
649
  if (!yAxisFields || !yAxisFields.length) {
756
650
  return null;
757
651
  }
758
- return (_jsx("div", __assign({ style: __assign(__assign({}, containerStyle), { boxSizing: 'content-box' }) }, { children: _jsx(ResponsiveContainer, __assign({ width: "100%", height: '100%' }, { children: _jsxs(ReChartsAreaChart, __assign({ data: data }, { children: [_jsx(CartesianGrid, { strokeDasharray: "3 3", horizontal: true, vertical: false }), _jsx(XAxis
652
+ return ((0, jsx_runtime_1.jsx)("div", { style: { ...containerStyle, boxSizing: 'content-box' }, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: '100%', children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: data, children: [(0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { strokeDasharray: "3 3", horizontal: true, vertical: false }), (0, jsx_runtime_1.jsx)(recharts_1.XAxis
759
653
  // hide={!showXAxis}
760
654
  , {
761
655
  // hide={!showXAxis}
@@ -767,21 +661,19 @@ function LineChart(_a) {
767
661
  // }
768
662
  style: {
769
663
  fontSize: '12px',
770
- fontFamily: (theme === null || theme === void 0 ? void 0 : theme.chartLabelFontFamily) ||
771
- (theme === null || theme === void 0 ? void 0 : theme.fontFamily) ||
664
+ fontFamily: theme?.chartLabelFontFamily ||
665
+ theme?.fontFamily ||
772
666
  'Inter; Helvetica',
773
- color: (theme === null || theme === void 0 ? void 0 : theme.chartLabelColor) || '#666666',
667
+ color: theme?.chartLabelColor || '#666666',
774
668
  },
775
669
  // interval="preserveStartEnd"
776
670
  interval: "preserveStartEnd",
777
671
  // interval={0}
778
- tickLine: false, axisLine: false, padding: { left: 10, right: 10 }, minTickGap: 5, tickFormatter: function (tick) {
779
- return valueFormatter({
780
- value: tick,
781
- field: xAxisField,
782
- fields: [{ field: xAxisField, format: xAxisFormat }],
783
- });
784
- } }), _jsx(YAxis
672
+ tickLine: false, axisLine: false, padding: { left: 10, right: 10 }, minTickGap: 5, tickFormatter: tick => (0, exports.valueFormatter)({
673
+ value: tick,
674
+ field: xAxisField,
675
+ fields: [{ field: xAxisField, format: xAxisFormat }],
676
+ }) }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis
785
677
  // textAnchor="left"
786
678
  // tickMargin={0}
787
679
  // width={56}
@@ -797,39 +689,34 @@ function LineChart(_a) {
797
689
  // domain={yAxisDomain as AxisDomain}
798
690
  domain: getDomain(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, style: {
799
691
  fontSize: '12px',
800
- fontFamily: (theme === null || theme === void 0 ? void 0 : theme.chartLabelFontFamily) ||
801
- (theme === null || theme === void 0 ? void 0 : theme.fontFamily) ||
692
+ fontFamily: theme?.chartLabelFontFamily ||
693
+ theme?.fontFamily ||
802
694
  'Inter; Helvetica',
803
- color: (theme === null || theme === void 0 ? void 0 : theme.chartLabelColor) || '#666666',
804
- }, tickFormatter: function (value) {
805
- return valueFormatter({
806
- value: value,
807
- field: yAxisFields[0].field,
808
- fields: __spreadArray(__spreadArray([], yAxisFields, true), [
809
- { field: xAxisField, format: xAxisFormat },
810
- ], false),
811
- });
812
- } }), _jsx(Tooltip, { wrapperStyle: { outline: 'none' }, isAnimationActive: false, cursor: { stroke: '#d1d5db', strokeWidth: 1 }, content: function (_a) {
813
- var active = _a.active, payload = _a.payload, label = _a.label;
814
- return (_jsx(ChartTooltip, { active: active, payload: payload, label: label, dateFormatter: function (value) {
815
- return valueFormatter({
816
- value: value,
817
- field: xAxisField,
818
- fields: [{ field: xAxisField, format: xAxisFormat }],
819
- });
820
- }, valueFormatter: function (value) {
821
- return valueFormatter({
822
- value: value,
823
- field: payload[0].dataKey,
824
- fields: __spreadArray(__spreadArray([], yAxisFields, true), [
825
- { field: xAxisField, format: xAxisFormat },
826
- ], false),
827
- });
828
- }, colors: colors, theme: theme }));
829
- }, position: { y: 0 } }), yAxisFields.map(function (elem, index) { return (_jsx("defs", { children: _jsxs("linearGradient", __assign({ id: "gradient".concat(index), x1: "0", y1: "0", x2: "0", y2: "1" }, { children: [_jsx("stop", { offset: "5%", stopColor: colors[index], stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] })) }, "defs".concat(elem.field + index))); }), yAxisFields.map(function (elem, index) { return (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: colors[index],
695
+ color: theme?.chartLabelColor || '#666666',
696
+ }, tickFormatter: value => (0, exports.valueFormatter)({
697
+ value,
698
+ field: yAxisFields[0].field,
699
+ fields: [
700
+ ...yAxisFields,
701
+ { field: xAxisField, format: xAxisFormat },
702
+ ],
703
+ }) }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { wrapperStyle: { outline: 'none' }, isAnimationActive: false, cursor: { stroke: '#d1d5db', strokeWidth: 1 }, content: ({ active, payload, label }) => {
704
+ return ((0, jsx_runtime_1.jsx)(ChartTooltip, { active: active, payload: payload, label: label, dateFormatter: value => (0, exports.valueFormatter)({
705
+ value,
706
+ field: xAxisField,
707
+ fields: [{ field: xAxisField, format: xAxisFormat }],
708
+ }), valueFormatter: value => (0, exports.valueFormatter)({
709
+ value,
710
+ field: payload[0].dataKey,
711
+ fields: [
712
+ ...yAxisFields,
713
+ { field: xAxisField, format: xAxisFormat },
714
+ ],
715
+ }), colors: colors, theme: theme }));
716
+ }, position: { y: 0 } }), yAxisFields.map((elem, index) => ((0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsxs)("linearGradient", { id: `gradient${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "5%", stopColor: colors[index], stopOpacity: 0.4 }), (0, jsx_runtime_1.jsx)("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: colors[index],
830
717
  // if hide area
831
718
  // fill="transparent"
832
- fill: "url(#gradient".concat(index, ")"), strokeWidth: 2, dot: false, isAnimationActive: true }, elem.field)); })] })) })) })));
719
+ fill: `url(#gradient${index})`, strokeWidth: 2, dot: false, isAnimationActive: true }, elem.field)))] }) }) }));
833
720
  }
834
- export default Chart;
721
+ exports.default = Chart;
835
722
  //# sourceMappingURL=Chart.js.map