@quillsql/react 2.9.1 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/dist/AddToDashboardModal.d.ts +1 -0
  2. package/dist/AddToDashboardModal.d.ts.map +1 -1
  3. package/dist/AddToDashboardModal.js +152 -181
  4. package/dist/AddToDashboardModal.js.map +1 -1
  5. package/dist/BarList.d.ts +1 -0
  6. package/dist/BarList.js +36 -44
  7. package/dist/Chart.d.ts +5 -24
  8. package/dist/Chart.d.ts.map +1 -1
  9. package/dist/Chart.js +203 -802
  10. package/dist/Chart.js.map +1 -1
  11. package/dist/ChartBuilder.d.ts +1 -0
  12. package/dist/ChartBuilder.d.ts.map +1 -1
  13. package/dist/ChartBuilder.js +89 -91
  14. package/dist/ChartBuilder.js.map +1 -1
  15. package/dist/ChartEditor.d.ts +1 -0
  16. package/dist/ChartEditor.d.ts.map +1 -1
  17. package/dist/ChartEditor.js +23 -22
  18. package/dist/ChartEditor.js.map +1 -1
  19. package/dist/Context.d.ts +20 -0
  20. package/dist/Context.d.ts.map +1 -1
  21. package/dist/Context.js +81 -61
  22. package/dist/Context.js.map +1 -1
  23. package/dist/Dashboard.d.ts +4 -1
  24. package/dist/Dashboard.d.ts.map +1 -1
  25. package/dist/Dashboard.js +250 -251
  26. package/dist/Dashboard.js.map +1 -1
  27. package/dist/DateRangePicker/Calendar.d.ts +1 -0
  28. package/dist/DateRangePicker/Calendar.js +41 -46
  29. package/dist/DateRangePicker/DateRangePicker.d.ts +1 -0
  30. package/dist/DateRangePicker/DateRangePicker.js +32 -61
  31. package/dist/DateRangePicker/DateRangePickerButton.d.ts +1 -0
  32. package/dist/DateRangePicker/DateRangePickerButton.js +14 -17
  33. package/dist/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
  34. package/dist/DateRangePicker/dateRangePickerUtils.js +76 -90
  35. package/dist/DateRangePicker/index.d.ts +1 -0
  36. package/dist/DateRangePicker/index.js +1 -9
  37. package/dist/PieChart.d.ts +1 -0
  38. package/dist/PieChart.js +35 -70
  39. package/dist/QuillProvider.d.ts +1 -0
  40. package/dist/QuillProvider.js +4 -7
  41. package/dist/ReportBuilder.d.ts +1 -0
  42. package/dist/ReportBuilder.js +120 -129
  43. package/dist/SQLEditor.d.ts +1 -0
  44. package/dist/SQLEditor.js +56 -65
  45. package/dist/SQLEditor.js.map +1 -1
  46. package/dist/Table.d.ts +1 -0
  47. package/dist/Table.d.ts.map +1 -1
  48. package/dist/Table.js +65 -65
  49. package/dist/Table.js.map +1 -1
  50. package/dist/TableChart.d.ts +1 -0
  51. package/dist/TableChart.js +17 -45
  52. package/dist/api/ServerClient.d.ts +30 -0
  53. package/dist/api/ServerClient.d.ts.map +1 -0
  54. package/dist/api/ServerClient.js +39 -0
  55. package/dist/api/ServerClient.js.map +1 -0
  56. package/dist/assets/ArrowDownHeadIcon.d.ts +1 -0
  57. package/dist/assets/ArrowDownHeadIcon.js +3 -6
  58. package/dist/assets/ArrowDownIcon.d.ts +1 -0
  59. package/dist/assets/ArrowDownIcon.js +3 -6
  60. package/dist/assets/ArrowDownRightIcon.d.ts +1 -0
  61. package/dist/assets/ArrowDownRightIcon.js +3 -6
  62. package/dist/assets/ArrowLeftHeadIcon.d.ts +1 -0
  63. package/dist/assets/ArrowLeftHeadIcon.js +3 -6
  64. package/dist/assets/ArrowRightHeadIcon.d.ts +1 -0
  65. package/dist/assets/ArrowRightHeadIcon.js +3 -6
  66. package/dist/assets/ArrowRightIcon.d.ts +1 -0
  67. package/dist/assets/ArrowRightIcon.js +3 -6
  68. package/dist/assets/ArrowUpHeadIcon.d.ts +1 -0
  69. package/dist/assets/ArrowUpHeadIcon.js +3 -6
  70. package/dist/assets/ArrowUpIcon.d.ts +1 -0
  71. package/dist/assets/ArrowUpIcon.js +3 -6
  72. package/dist/assets/ArrowUpRightIcon.d.ts +1 -0
  73. package/dist/assets/ArrowUpRightIcon.js +3 -6
  74. package/dist/assets/CalendarIcon.d.ts +1 -0
  75. package/dist/assets/CalendarIcon.js +3 -6
  76. package/dist/assets/CalendarNormalIcon.d.ts +1 -0
  77. package/dist/assets/CalendarNormalIcon.js +3 -6
  78. package/dist/assets/DoubleArrowLeftHeadIcon.d.ts +1 -0
  79. package/dist/assets/DoubleArrowLeftHeadIcon.js +3 -6
  80. package/dist/assets/DoubleArrowRightHeadIcon.d.ts +1 -0
  81. package/dist/assets/DoubleArrowRightHeadIcon.js +3 -6
  82. package/dist/assets/ExclamationFilledIcon.d.ts +1 -0
  83. package/dist/assets/ExclamationFilledIcon.js +3 -6
  84. package/dist/assets/FilterIcon.d.ts +1 -0
  85. package/dist/assets/FilterIcon.js +3 -6
  86. package/dist/assets/LoadingSpinner.d.ts +1 -0
  87. package/dist/assets/LoadingSpinner.js +3 -6
  88. package/dist/assets/RefreshIcon.d.ts +1 -0
  89. package/dist/assets/RefreshIcon.js +3 -6
  90. package/dist/assets/SearchIcon.d.ts +1 -0
  91. package/dist/assets/SearchIcon.js +3 -6
  92. package/dist/assets/UpLeftArrowsIcon.d.ts +1 -0
  93. package/dist/assets/UpLeftArrowsIcon.js +3 -6
  94. package/dist/assets/XCircleIcon.d.ts +1 -0
  95. package/dist/assets/XCircleIcon.js +3 -6
  96. package/dist/assets/XIcon.d.ts +1 -0
  97. package/dist/assets/XIcon.js +3 -6
  98. package/dist/assets/index.d.ts +1 -0
  99. package/dist/assets/index.js +21 -49
  100. package/dist/components/Banner/index.d.ts +1 -0
  101. package/dist/components/Banner/index.js +6 -10
  102. package/dist/components/BigModal/BigModal.d.ts +1 -0
  103. package/dist/components/BigModal/BigModal.js +13 -39
  104. package/dist/components/Chart/BarChart.d.ts +15 -0
  105. package/dist/components/Chart/BarChart.d.ts.map +1 -0
  106. package/dist/components/Chart/BarChart.js +57 -0
  107. package/dist/components/Chart/BarChart.js.map +1 -0
  108. package/dist/components/Chart/ChartTooltip.d.ts +29 -0
  109. package/dist/components/Chart/ChartTooltip.d.ts.map +1 -0
  110. package/dist/components/Chart/ChartTooltip.js +229 -0
  111. package/dist/components/Chart/ChartTooltip.js.map +1 -0
  112. package/dist/components/Chart/ChartTooltipFrame.d.ts +6 -0
  113. package/dist/components/Chart/ChartTooltipFrame.d.ts.map +1 -0
  114. package/dist/components/Chart/ChartTooltipFrame.js +12 -0
  115. package/dist/components/Chart/ChartTooltipFrame.js.map +1 -0
  116. package/dist/components/Chart/ChartTooltipGroup.d.ts +11 -0
  117. package/dist/components/Chart/ChartTooltipGroup.d.ts.map +1 -0
  118. package/dist/components/Chart/ChartTooltipGroup.js +23 -0
  119. package/dist/components/Chart/ChartTooltipGroup.js.map +1 -0
  120. package/dist/components/Chart/ChartTooltipRow.d.ts +8 -0
  121. package/dist/components/Chart/ChartTooltipRow.d.ts.map +1 -0
  122. package/dist/components/Chart/ChartTooltipRow.js +41 -0
  123. package/dist/components/Chart/ChartTooltipRow.js.map +1 -0
  124. package/dist/components/Chart/LineChart.d.ts +13 -0
  125. package/dist/components/Chart/LineChart.d.ts.map +1 -0
  126. package/dist/components/Chart/LineChart.js +68 -0
  127. package/dist/components/Chart/LineChart.js.map +1 -0
  128. package/dist/components/Dropdown/Dropdown.d.ts +1 -0
  129. package/dist/components/Dropdown/Dropdown.js +24 -53
  130. package/dist/components/Dropdown/DropdownItem.d.ts +1 -0
  131. package/dist/components/Dropdown/DropdownItem.js +9 -35
  132. package/dist/components/Dropdown/index.d.ts +1 -0
  133. package/dist/components/Dropdown/index.js +2 -11
  134. package/dist/components/Modal/Modal.d.ts +1 -0
  135. package/dist/components/Modal/Modal.js +13 -39
  136. package/dist/components/Modal/index.d.ts +1 -0
  137. package/dist/components/Modal/index.js +1 -9
  138. package/dist/components/QuillCard.d.ts +1 -0
  139. package/dist/components/QuillCard.js +8 -13
  140. package/dist/components/ReportBuilder/ColumnSelector.d.ts +24 -6
  141. package/dist/components/ReportBuilder/ColumnSelector.d.ts.map +1 -1
  142. package/dist/components/ReportBuilder/ColumnSelector.js +56 -8
  143. package/dist/components/ReportBuilder/ColumnSelector.js.map +1 -0
  144. package/dist/components/ReportBuilder/FiltersModal.d.ts +40 -0
  145. package/dist/components/ReportBuilder/FiltersModal.d.ts.map +1 -0
  146. package/dist/components/ReportBuilder/FiltersModal.js +273 -0
  147. package/dist/components/ReportBuilder/FiltersModal.js.map +1 -0
  148. package/dist/components/ReportBuilder/SortModal.d.ts +28 -0
  149. package/dist/components/ReportBuilder/SortModal.d.ts.map +1 -0
  150. package/dist/components/ReportBuilder/SortModal.js +41 -0
  151. package/dist/components/ReportBuilder/SortModal.js.map +1 -0
  152. package/dist/components/SqlTextEditor.d.ts +1 -0
  153. package/dist/components/SqlTextEditor.js +4 -11
  154. package/dist/components/UiComponents.d.ts +1 -0
  155. package/dist/components/UiComponents.js +37 -51
  156. package/dist/components/selectUtils.d.ts +1 -0
  157. package/dist/components/selectUtils.js +6 -17
  158. package/dist/contexts/BaseColorContext.d.ts +1 -0
  159. package/dist/contexts/BaseColorContext.js +3 -6
  160. package/dist/contexts/HoveredValueContext.d.ts +1 -0
  161. package/dist/contexts/HoveredValueContext.js +3 -6
  162. package/dist/contexts/RootStylesContext.d.ts +1 -0
  163. package/dist/contexts/RootStylesContext.js +3 -6
  164. package/dist/contexts/SelectedValueContext.d.ts +1 -0
  165. package/dist/contexts/SelectedValueContext.js +3 -6
  166. package/dist/contexts/index.d.ts +1 -0
  167. package/dist/contexts/index.js +4 -15
  168. package/dist/hooks/index.d.ts +1 -0
  169. package/dist/hooks/index.js +4 -15
  170. package/dist/hooks/useDashboard.d.ts +1 -0
  171. package/dist/hooks/useDashboard.js +10 -15
  172. package/dist/hooks/useInternalState.d.ts +1 -0
  173. package/dist/hooks/useInternalState.js +3 -6
  174. package/dist/hooks/useOnClickOutside.d.ts +1 -0
  175. package/dist/hooks/useOnClickOutside.js +3 -6
  176. package/dist/hooks/useOnWindowResize.d.ts +1 -0
  177. package/dist/hooks/useOnWindowResize.js +4 -7
  178. package/dist/hooks/useQuill.d.ts +3 -2
  179. package/dist/hooks/useQuill.d.ts.map +1 -1
  180. package/dist/hooks/useQuill.js +37 -28
  181. package/dist/hooks/useQuill.js.map +1 -1
  182. package/dist/hooks/useSelectOnKeyDown.d.ts +1 -0
  183. package/dist/hooks/useSelectOnKeyDown.js +4 -7
  184. package/dist/index.d.ts +1 -0
  185. package/dist/index.js +13 -33
  186. package/dist/internals/ReportBuilder/PivotList.d.ts +1 -0
  187. package/dist/internals/ReportBuilder/PivotList.js +14 -20
  188. package/dist/internals/ReportBuilder/PivotModal.d.ts +3 -2
  189. package/dist/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
  190. package/dist/internals/ReportBuilder/PivotModal.js +280 -115
  191. package/dist/internals/ReportBuilder/PivotModal.js.map +1 -1
  192. package/dist/internals/ReportBuilder/PivotModal.spec.d.ts +1 -0
  193. package/dist/internals/ReportBuilder/PivotModal.spec.js +70 -73
  194. package/dist/lib/font.d.ts +1 -0
  195. package/dist/lib/font.js +2 -6
  196. package/dist/lib/index.d.ts +1 -0
  197. package/dist/lib/index.js +3 -20
  198. package/dist/lib/inputTypes.d.ts +1 -0
  199. package/dist/lib/inputTypes.js +1 -3
  200. package/dist/lib/utils.d.ts +1 -0
  201. package/dist/lib/utils.js +8 -19
  202. package/dist/test-data/tables.d.ts.map +1 -1
  203. package/dist/test-data/tables.js +27 -585
  204. package/dist/test-data/tables.js.map +1 -0
  205. package/dist/utils/aggregate.d.ts +1 -0
  206. package/dist/utils/aggregate.js +28 -35
  207. package/dist/utils/ast.d.ts +18 -0
  208. package/dist/utils/ast.d.ts.map +1 -0
  209. package/dist/utils/ast.js +310 -0
  210. package/dist/utils/ast.js.map +1 -0
  211. package/dist/utils/axisFormatter.d.ts +1 -0
  212. package/dist/utils/axisFormatter.js +19 -24
  213. package/dist/utils/color.d.ts +13 -0
  214. package/dist/utils/color.d.ts.map +1 -0
  215. package/dist/utils/color.js +247 -0
  216. package/dist/utils/color.js.map +1 -0
  217. package/dist/utils/colorToHex.d.ts +1 -0
  218. package/dist/utils/colorToHex.js +1 -5
  219. package/dist/utils/crypto.d.ts +2 -0
  220. package/dist/utils/crypto.d.ts.map +1 -0
  221. package/dist/utils/crypto.js +6 -0
  222. package/dist/utils/crypto.js.map +1 -0
  223. package/dist/utils/dataFetcher.d.ts +1 -0
  224. package/dist/utils/dataFetcher.d.ts.map +1 -1
  225. package/dist/utils/dataFetcher.js +8 -9
  226. package/dist/utils/dataFetcher.js.map +1 -1
  227. package/dist/utils/dates.d.ts +10 -0
  228. package/dist/utils/dates.d.ts.map +1 -0
  229. package/dist/utils/dates.js +32 -0
  230. package/dist/utils/dates.js.map +1 -0
  231. package/dist/utils/downloadCSV.d.ts +1 -0
  232. package/dist/utils/downloadCSV.js +1 -6
  233. package/dist/utils/getDomain.d.ts +8 -0
  234. package/dist/utils/getDomain.d.ts.map +1 -0
  235. package/dist/utils/getDomain.js +28 -0
  236. package/dist/utils/getDomain.js.map +1 -0
  237. package/dist/utils/merge.d.ts +2 -0
  238. package/dist/utils/merge.d.ts.map +1 -0
  239. package/dist/utils/merge.js +45 -0
  240. package/dist/utils/merge.js.map +1 -0
  241. package/dist/utils/schema.d.ts +7 -2
  242. package/dist/utils/schema.d.ts.map +1 -1
  243. package/dist/utils/schema.js +13 -7
  244. package/dist/utils/schema.js.map +1 -0
  245. package/dist/utils/sorting.d.ts +5 -0
  246. package/dist/utils/sorting.d.ts.map +1 -0
  247. package/dist/utils/sorting.js +14 -0
  248. package/dist/utils/sorting.js.map +1 -0
  249. package/dist/utils/textFormatting.d.ts.map +1 -1
  250. package/dist/utils/textFormatting.js +0 -1
  251. package/dist/utils/textFormatting.js.map +1 -0
  252. package/dist/utils/valueFormatter.d.ts +1 -0
  253. package/dist/utils/valueFormatter.js +19 -24
  254. package/dist/utils/valueFormatterCSV.d.ts +1 -0
  255. package/dist/utils/valueFormatterCSV.js +19 -24
  256. package/package.json +2 -3
  257. package/dist/DateRangePicker/Calendar.js.map +0 -1
  258. package/dist/DateRangePicker/dateRangePickerUtils.js.map +0 -1
  259. package/dist/DateRangePicker/index.js.map +0 -1
  260. package/dist/PieChart.js.map +0 -1
  261. package/dist/QuillProvider.js.map +0 -1
  262. package/dist/assets/ArrowDownIcon.js.map +0 -1
  263. package/dist/assets/ArrowDownRightIcon.js.map +0 -1
  264. package/dist/assets/ArrowLeftHeadIcon.js.map +0 -1
  265. package/dist/assets/ArrowRightHeadIcon.js.map +0 -1
  266. package/dist/assets/ArrowRightIcon.js.map +0 -1
  267. package/dist/assets/ArrowUpHeadIcon.js.map +0 -1
  268. package/dist/assets/ArrowUpIcon.js.map +0 -1
  269. package/dist/assets/ArrowUpRightIcon.js.map +0 -1
  270. package/dist/assets/CalendarIcon.js.map +0 -1
  271. package/dist/assets/CalendarNormalIcon.js.map +0 -1
  272. package/dist/assets/DoubleArrowLeftHeadIcon.js.map +0 -1
  273. package/dist/assets/DoubleArrowRightHeadIcon.js.map +0 -1
  274. package/dist/assets/ExclamationFilledIcon.js.map +0 -1
  275. package/dist/assets/FilterIcon.js.map +0 -1
  276. package/dist/assets/LoadingSpinner.js.map +0 -1
  277. package/dist/assets/RefreshIcon.js.map +0 -1
  278. package/dist/assets/SearchIcon.js.map +0 -1
  279. package/dist/assets/UpLeftArrowsIcon.js.map +0 -1
  280. package/dist/assets/XCircleIcon.js.map +0 -1
  281. package/dist/assets/XIcon.js.map +0 -1
  282. package/dist/assets/index.js.map +0 -1
  283. package/dist/components/BigModal/BigModal.js.map +0 -1
  284. package/dist/components/Dropdown/Dropdown.js.map +0 -1
  285. package/dist/components/Dropdown/DropdownItem.js.map +0 -1
  286. package/dist/components/Dropdown/index.js.map +0 -1
  287. package/dist/components/Modal/Modal.js.map +0 -1
  288. package/dist/components/Modal/index.js.map +0 -1
  289. package/dist/components/QuillCard.js.map +0 -1
  290. package/dist/components/selectUtils.js.map +0 -1
  291. package/dist/contexts/BaseColorContext.js.map +0 -1
  292. package/dist/contexts/HoveredValueContext.js.map +0 -1
  293. package/dist/contexts/RootStylesContext.js.map +0 -1
  294. package/dist/contexts/SelectedValueContext.js.map +0 -1
  295. package/dist/contexts/index.js.map +0 -1
  296. package/dist/hooks/index.js.map +0 -1
  297. package/dist/hooks/useDashboard.js.map +0 -1
  298. package/dist/hooks/useInternalState.js.map +0 -1
  299. package/dist/hooks/useOnClickOutside.js.map +0 -1
  300. package/dist/hooks/useOnWindowResize.js.map +0 -1
  301. package/dist/hooks/useSelectOnKeyDown.js.map +0 -1
  302. package/dist/index.js.map +0 -1
  303. package/dist/internals/ReportBuilder/PivotModal.spec.js.map +0 -1
  304. package/dist/lib/font.js.map +0 -1
  305. package/dist/lib/index.js.map +0 -1
  306. package/dist/lib/inputTypes.js.map +0 -1
  307. package/dist/lib/utils.js.map +0 -1
  308. package/dist/utils/aggregate.js.map +0 -1
  309. package/dist/utils/downloadCSV.js.map +0 -1
package/dist/Dashboard.js CHANGED
@@ -1,48 +1,19 @@
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]; } };
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 };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.QuillDateRangePicker = exports.DashboardFilter = exports.COMPARISON_OPTIONS = void 0;
30
- const jsx_runtime_1 = require("react/jsx-runtime");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
31
2
  // @ts-nocheck
32
3
  /* eslint-disable @typescript-eslint/ban-ts-comment */
33
- const react_1 = __importStar(require("react"));
34
- const Chart_1 = __importDefault(require("./Chart"));
35
- const dateRangePickerUtils_1 = require("./DateRangePicker/dateRangePickerUtils");
36
- const Context_1 = require("./Context");
37
- const date_fns_1 = require("date-fns");
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");
43
- const locale_1 = require("date-fns/locale");
44
- const useDashboard_1 = require("./hooks/useDashboard");
45
- exports.COMPARISON_OPTIONS = [
4
+ import React, { useContext, useEffect, useState, useRef, useCallback, } from 'react';
5
+ import Chart from './Chart';
6
+ import { capitalize, defaultOptions, getWeekdays, getRangeFromPreset, PRIMARY_RANGE, COMPARISON_RANGE, PRIMARY_CODES, } from './DateRangePicker/dateRangePickerUtils';
7
+ import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, DateFilterContext, useComparisonRange, useDateFilter, } from './Context';
8
+ import { addDays, eachDayOfInterval, endOfMonth, format, isAfter, isBefore, isEqual, isSaturday, isSunday, nextSaturday, previousSunday, startOfMonth, startOfToday, startOfWeek, startOfYear, sub, subDays, } from 'date-fns';
9
+ import Modal from './components/Modal/Modal';
10
+ import { HoveredValueContext, SelectedValueContext } from './contexts';
11
+ import { DropdownItem } from './components/Dropdown';
12
+ import { ArrowDownHeadIcon, ArrowLeftHeadIcon, ArrowRightHeadIcon, CalendarNormalIcon, } from './assets';
13
+ import { useInternalState, useOnClickOutside, useSelectOnKeyDown, } from './hooks';
14
+ import { enUS } from 'date-fns/locale';
15
+ import { useDashboard } from './hooks/useDashboard';
16
+ export const COMPARISON_OPTIONS = [
46
17
  {
47
18
  value: 'PREV_PERIOD',
48
19
  text: 'Previous Period',
@@ -64,10 +35,31 @@ exports.COMPARISON_OPTIONS = [
64
35
  text: 'No comparison',
65
36
  },
66
37
  ];
67
- function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePickerComponent, theme, }) {
68
- const [comparisonValue, setComparisonValue] = (0, react_1.useState)('');
69
- const [filterValue, setFilterValue] = (0, react_1.useState)(null);
70
- (0, react_1.useEffect)(() => {
38
+ export const PRIMARY_OPTIONS = [
39
+ { value: 'THIS_WEEK', text: 'This Week' },
40
+ { value: 'THIS_MONTH', text: 'This Month' },
41
+ { value: 'THIS_YEAR', text: 'This year' },
42
+ { value: 'LAST_7_DAYS', text: 'Last 7 days' },
43
+ { value: 'LAST_30_DAYS', text: 'Last 30 days' },
44
+ { value: 'LAST_90_DAYS', text: 'Last 90 days' },
45
+ { value: 'LAST_6_MONTHS', text: 'Last 6 months' },
46
+ { value: 'ALL_TIME', text: 'All time' },
47
+ ];
48
+ const FILTER_CODE_MAP = {
49
+ wk: 'This week',
50
+ m: 'This month',
51
+ y: 'This year',
52
+ w: 'Last 7 days',
53
+ t: 'Last 30 days',
54
+ '90d': 'Last 90 days',
55
+ '6m': 'Last 6 months',
56
+ at: 'All time',
57
+ };
58
+ export function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePickerComponent, theme, }) {
59
+ const { comparisonRange, setComparisonRange } = useComparisonRange();
60
+ const { setDateFilter } = useDateFilter();
61
+ const [filterValue, setFilterValue] = useState(null);
62
+ useEffect(() => {
71
63
  if (filter.filterType === 'date_range' &&
72
64
  !filter.selectedValue &&
73
65
  !filterValue) {
@@ -79,14 +71,21 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
79
71
  else if (filter.filterType === 'string') {
80
72
  setFilterValue(filter.selectedValue);
81
73
  }
82
- if (filter.comparison) {
83
- setComparisonValue(exports.COMPARISON_OPTIONS.find((option) => {
84
- return option.value === filter.comparisonRange.value;
85
- }).value);
74
+ if (filter.filterType == 'date_range') {
75
+ setDateFilter(FILTER_CODE_MAP[filter.selectedValue ? filter.selectedValue[2] : null]);
76
+ if (filter?.comparisonRange?.value) {
77
+ const newComparisonRange = COMPARISON_OPTIONS.find((option) => {
78
+ return option.value === filter.comparisonRange.value;
79
+ });
80
+ setComparisonRange(newComparisonRange);
81
+ }
82
+ else {
83
+ setComparisonRange(null);
84
+ }
86
85
  }
87
86
  }, [filter]);
88
87
  if (filter.filterType === 'string') {
89
- return ((0, jsx_runtime_1.jsx)(SelectComponent, { label: filter.label, value: filterValue, onChange: (e) => {
88
+ return (_jsx(SelectComponent, { label: filter.label, value: filterValue, onChange: (e) => {
90
89
  onChangeFilter(filter, e);
91
90
  }, options: [
92
91
  ...filter.options.map((elem) => {
@@ -98,11 +97,11 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
98
97
  ] }));
99
98
  }
100
99
  if (filter.filterType == 'date_range') {
101
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
100
+ return (_jsxs("div", { style: {
102
101
  display: 'flex',
103
102
  flexDirection: 'row',
104
103
  alignItems: 'flex-end',
105
- }, children: [(0, jsx_runtime_1.jsx)(DateRangePickerComponent, { dateRange: filterValue ? [filterValue[0], filterValue[1]] : [null, null], label: filter.label,
104
+ }, children: [_jsx(DateRangePickerComponent, { dateRange: filterValue ? [filterValue[0], filterValue[1]] : [null, null], label: filter.label,
106
105
  // value={filterValue}
107
106
  onChangeDateRange: (dateRange) => {
108
107
  onChangeFilter(filter, [dateRange[0], dateRange[1], null]);
@@ -111,7 +110,7 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
111
110
  ? filterValue[2]
112
111
  : '', onChangePreset: (preset) => {
113
112
  if (typeof preset === 'string') {
114
- const fullPreset = (0, dateRangePickerUtils_1.getRangeFromPreset)(preset);
113
+ const fullPreset = getRangeFromPreset(preset);
115
114
  onChangeFilter(filter, fullPreset);
116
115
  setFilterValue(fullPreset);
117
116
  return;
@@ -126,19 +125,19 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
126
125
  new Date(),
127
126
  preset?.value || '',
128
127
  ]);
129
- }, presetOptions: dateRangePickerUtils_1.defaultOptions }), filter.comparison && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { style: {
128
+ }, presetOptions: defaultOptions }), comparisonRange && (_jsx("div", { children: _jsxs("div", { style: {
130
129
  display: 'flex',
131
130
  flexDirection: 'row',
132
131
  alignItems: 'center',
133
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
132
+ }, children: [_jsx("div", { style: {
134
133
  paddingLeft: 16,
135
134
  paddingRight: 12,
136
135
  color: theme.secondaryTextColor,
137
- }, children: "compared to" }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: comparisonValue, onChange: (e) => {
138
- onChangeFilter(filter, null, exports.COMPARISON_OPTIONS.find((option) => {
136
+ }, children: "compared to" }), _jsx(SelectComponent, { value: comparisonRange.value, onChange: (e) => {
137
+ onChangeFilter(filter, null, COMPARISON_OPTIONS.find((option) => {
139
138
  return option.value === e;
140
139
  }));
141
- }, options: exports.COMPARISON_OPTIONS.map((compareOption) => {
140
+ }, options: COMPARISON_OPTIONS.map((compareOption) => {
142
141
  return {
143
142
  value: compareOption.value,
144
143
  label: compareOption.text,
@@ -147,45 +146,44 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
147
146
  }
148
147
  return null;
149
148
  }
150
- exports.DashboardFilter = DashboardFilter;
151
149
  const options = [
152
150
  {
153
- date_range: [(0, date_fns_1.startOfWeek)((0, date_fns_1.startOfToday)()), (0, date_fns_1.startOfToday)(), 'wk'],
151
+ date_range: [startOfWeek(startOfToday()), startOfToday(), 'wk'],
154
152
  },
155
153
  {
156
- date_range: [(0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { days: 90 }), (0, date_fns_1.startOfToday)(), '90d'],
154
+ date_range: [sub(startOfToday(), { days: 90 }), startOfToday(), '90d'],
157
155
  },
158
156
  {
159
- date_range: [(0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { days: 30 }), (0, date_fns_1.startOfToday)(), 't'],
157
+ date_range: [sub(startOfToday(), { days: 30 }), startOfToday(), 't'],
160
158
  },
161
159
  {
162
- date_range: [(0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { years: 100 }), (0, date_fns_1.startOfToday)(), 'at'],
160
+ date_range: [sub(startOfToday(), { years: 100 }), startOfToday(), 'at'],
163
161
  },
164
162
  {
165
- date_range: [(0, date_fns_1.startOfYear)((0, date_fns_1.startOfToday)()), (0, date_fns_1.startOfToday)(), 'y'],
163
+ date_range: [startOfYear(startOfToday()), startOfToday(), 'y'],
166
164
  },
167
165
  {
168
- date_range: [(0, date_fns_1.startOfMonth)((0, date_fns_1.startOfToday)()), (0, date_fns_1.startOfToday)(), 'm'],
166
+ date_range: [startOfMonth(startOfToday()), startOfToday(), 'm'],
169
167
  },
170
168
  {
171
- date_range: [(0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { days: 7 }), (0, date_fns_1.startOfToday)(), 'w'],
169
+ date_range: [sub(startOfToday(), { days: 7 }), startOfToday(), 'w'],
172
170
  },
173
171
  {
174
- date_range: [(0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { months: 6 }), (0, date_fns_1.startOfToday)(), '6m'],
172
+ date_range: [sub(startOfToday(), { months: 6 }), startOfToday(), '6m'],
175
173
  },
176
174
  ];
177
175
  const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
178
- const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
179
- const handleOnChange = (0, react_1.useCallback)((event) => {
176
+ const [theme] = useContext(ThemeContext);
177
+ const handleOnChange = useCallback((event) => {
180
178
  onChange(event.target.value);
181
179
  }, [onChange]);
182
- return ((0, jsx_runtime_1.jsxs)("div", { children: [label && ((0, jsx_runtime_1.jsx)("div", { style: {
180
+ return (_jsxs("div", { children: [label && (_jsx("div", { style: {
183
181
  marginBottom: 6,
184
182
  fontWeight: theme.labelFontWeight || '600',
185
183
  color: theme.secondaryTextColor,
186
184
  fontFamily: theme.fontFamily,
187
185
  fontSize: 14,
188
- }, children: label })), (0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative', height: 38 }, children: [(0, jsx_runtime_1.jsxs)("select", { onChange: handleOnChange, value: value ?? '', id: 'reportbuilderdropdown',
186
+ }, children: label })), _jsxs("div", { style: { position: 'relative', height: 38 }, children: [_jsxs("select", { onChange: handleOnChange, value: value ?? '', id: 'reportbuilderdropdown',
189
187
  // defaultValue="Select"
190
188
  style: {
191
189
  width: '100%',
@@ -209,7 +207,7 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
209
207
  fontSize: 14,
210
208
  fontWeight: 500,
211
209
  boxSizing: 'border-box',
212
- }, children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "Select" }), options.map((option, index) => ((0, jsx_runtime_1.jsx)("option", { value: option.value, children: option.label }, option.label + index)))] }), (0, jsx_runtime_1.jsx)(assets_1.ArrowDownHeadIcon, { style: {
210
+ }, children: [_jsx("option", { value: "", children: "Select" }), options.map((option, index) => (_jsx("option", { value: option.value, children: option.label }, option.label + index)))] }), _jsx(ArrowDownHeadIcon, { style: {
213
211
  height: '20px',
214
212
  width: '20px',
215
213
  flex: 'none',
@@ -220,27 +218,27 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
220
218
  }, "aria-hidden": "true" })] })] }));
221
219
  };
222
220
  const isBetween = (date, startDate, endDate) => {
223
- return (0, date_fns_1.isAfter)(date, startDate) && (0, date_fns_1.isBefore)(date, endDate);
221
+ return isAfter(date, startDate) && isBefore(date, endDate);
224
222
  };
225
223
  function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStartDate, localEndDate, }) {
226
- const firstDayOfDisplayedMonth = (0, date_fns_1.startOfMonth)(anchorDate);
227
- const lastDayOfDisplayedMonth = (0, date_fns_1.endOfMonth)(anchorDate);
228
- const weekdays = (0, dateRangePickerUtils_1.getWeekdays)(locale_1.enUS).map((dayName) => (0, dateRangePickerUtils_1.capitalize)(dayName, locale_1.enUS));
229
- const displayedDates = (0, date_fns_1.eachDayOfInterval)({
230
- start: (0, date_fns_1.isSunday)(firstDayOfDisplayedMonth)
224
+ const firstDayOfDisplayedMonth = startOfMonth(anchorDate);
225
+ const lastDayOfDisplayedMonth = endOfMonth(anchorDate);
226
+ const weekdays = getWeekdays(enUS).map((dayName) => capitalize(dayName, enUS));
227
+ const displayedDates = eachDayOfInterval({
228
+ start: isSunday(firstDayOfDisplayedMonth)
231
229
  ? firstDayOfDisplayedMonth
232
- : (0, date_fns_1.previousSunday)(firstDayOfDisplayedMonth),
233
- end: (0, date_fns_1.isSaturday)(lastDayOfDisplayedMonth)
230
+ : previousSunday(firstDayOfDisplayedMonth),
231
+ end: isSaturday(lastDayOfDisplayedMonth)
234
232
  ? lastDayOfDisplayedMonth
235
- : (0, date_fns_1.nextSaturday)(lastDayOfDisplayedMonth),
233
+ : nextSaturday(lastDayOfDisplayedMonth),
236
234
  });
237
- const displayedTitle = (0, dateRangePickerUtils_1.capitalize)((0, date_fns_1.format)(firstDayOfDisplayedMonth, 'MMMM yyyy', { locale: locale_1.enUS }), locale_1.enUS);
238
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
235
+ const displayedTitle = capitalize(format(firstDayOfDisplayedMonth, 'MMMM yyyy', { locale: enUS }), enUS);
236
+ return (_jsxs("div", { style: {
239
237
  display: 'flex',
240
238
  flexDirection: 'column',
241
239
  flex: 1,
242
240
  // alignItems: 'center',
243
- }, children: [(0, jsx_runtime_1.jsx)("h2", { style: {
241
+ }, children: [_jsx("h2", { style: {
244
242
  color: theme?.textColor || '#364153',
245
243
  fontSize: '13px',
246
244
  fontFamily: theme?.fontFamily,
@@ -254,7 +252,7 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
254
252
  justifyContent: 'center',
255
253
  marginBottom: 3,
256
254
  marginTop: 6,
257
- }, children: displayedTitle }), (0, jsx_runtime_1.jsx)("div", { style: {
255
+ }, children: displayedTitle }), _jsx("div", { style: {
258
256
  color: theme?.primaryTextColor || '#364153',
259
257
  textAlign: 'center',
260
258
  fontSize: 12,
@@ -262,7 +260,7 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
262
260
  display: 'grid',
263
261
  gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
264
262
  paddingTop: 6,
265
- }, children: weekdays.map((dayName) => ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', display: 'flex', justifyContent: 'center' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
263
+ }, children: weekdays.map((dayName) => (_jsx("div", { style: { width: '100%', display: 'flex', justifyContent: 'center' }, children: _jsx("div", { style: {
266
264
  display: 'flex',
267
265
  alignItems: 'center',
268
266
  justifyContent: 'center',
@@ -271,22 +269,14 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
271
269
  fontFamily: theme?.fontFamily,
272
270
  color: theme.secondaryTextColor,
273
271
  paddingBottom: 4,
274
- }, children: dayName }) }, dayName))) }), (0, jsx_runtime_1.jsx)("div", { style: {
272
+ }, children: dayName }) }, dayName))) }), _jsx("div", { style: {
275
273
  display: 'grid',
276
274
  gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
277
275
  borderRadius: 3,
278
276
  overflow: 'hidden',
279
277
  rowGap: 6,
280
278
  }, children: displayedDates.map((date, index) => {
281
- // const isCurrentDateDisabled = isDateDisabled(
282
- // date,
283
- // minDate,
284
- // maxDate,
285
- // firstDayOfDisplayedMonth,
286
- // lastDayOfDisplayedMonth
287
- // );
288
- // console.log(localStartDate === date, localStartDate, date);
289
- return ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%' }, children: (0, jsx_runtime_1.jsx)("button", { style: {
279
+ return (_jsx("div", { style: { width: '100%' }, children: _jsx("button", { style: {
290
280
  border: 'none',
291
281
  height: '34px',
292
282
  display: 'flex',
@@ -295,22 +285,22 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
295
285
  justifyContent: 'center',
296
286
  fontFamily: theme?.fontFamily,
297
287
  fontSize: 13,
298
- background: (0, date_fns_1.isEqual)(localStartDate, date) || (0, date_fns_1.isEqual)(localEndDate, date)
288
+ background: isEqual(localStartDate, date) || isEqual(localEndDate, date)
299
289
  ? theme.primaryTextColor
300
290
  : isBetween(date, localStartDate, localEndDate)
301
291
  ? '#F4F4F5'
302
292
  : 'transparent',
303
- color: (0, date_fns_1.isEqual)(localStartDate, date) || (0, date_fns_1.isEqual)(localEndDate, date)
293
+ color: isEqual(localStartDate, date) || isEqual(localEndDate, date)
304
294
  ? theme.backgroundColor
305
295
  : theme.primaryTextColor,
306
- borderRadius: (0, date_fns_1.isEqual)(localStartDate, date) || (0, date_fns_1.isEqual)(localEndDate, date)
296
+ borderRadius: isEqual(localStartDate, date) || isEqual(localEndDate, date)
307
297
  ? 3
308
298
  : 0,
309
299
  ...isBeginningOrEndOfWeek(index),
310
300
  }, type: "button", onClick: () => {
311
301
  onClickDate(date);
312
- }, children: (0, jsx_runtime_1.jsx)("time", { dateTime: (0, date_fns_1.format)(date, 'yyyy-MM-dd', { locale: locale_1.enUS }), children: (0, date_fns_1.format)(date, 'd', { locale: locale_1.enUS }) }) }) }, date.toString()));
313
- }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 8 } })] }));
302
+ }, children: _jsx("time", { dateTime: format(date, 'yyyy-MM-dd', { locale: enUS }), children: format(date, 'd', { locale: enUS }) }) }) }, date.toString()));
303
+ }) }), _jsx("div", { style: { height: 8 } })] }));
314
304
  }
315
305
  function isBeginningOrEndOfWeek(num) {
316
306
  // Check if the number is 0
@@ -327,48 +317,48 @@ function isBeginningOrEndOfWeek(num) {
327
317
  }
328
318
  const formatDateText = (dateRange, localStartDate, localEndDate) => {
329
319
  if (dateRange.length && dateRange[0] && dateRange[1]) {
330
- return ((0, date_fns_1.format)(dateRange[0], 'MMM dd, yyyy') +
320
+ return (format(dateRange[0], 'MMM dd, yyyy') +
331
321
  ' - ' +
332
- (0, date_fns_1.format)(dateRange[1], 'MMM dd, yyyy'));
322
+ format(dateRange[1], 'MMM dd, yyyy'));
333
323
  }
334
324
  if (localStartDate && localEndDate) {
335
- return ((0, date_fns_1.format)(localStartDate, 'MMM dd, yyyy') +
325
+ return (format(localStartDate, 'MMM dd, yyyy') +
336
326
  ' - ' +
337
- (0, date_fns_1.format)(localEndDate, 'MMM dd, yyyy'));
327
+ format(localEndDate, 'MMM dd, yyyy'));
338
328
  }
339
329
  return '';
340
330
  };
341
331
  function CalendarDropdown({ onChangeDateRange, dateRange }) {
342
- const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
343
- const [showModal, setShowModal] = (0, react_1.useState)(false);
344
- const modalRef = (0, react_1.useRef)(null);
345
- const parentRef = (0, react_1.useRef)(null);
346
- const handleOnChange = (0, react_1.useCallback)((event) => {
332
+ const [theme] = useContext(ThemeContext);
333
+ const [showModal, setShowModal] = useState(false);
334
+ const modalRef = useRef(null);
335
+ const parentRef = useRef(null);
336
+ const handleOnChange = useCallback((event) => {
347
337
  onChangeDateRange(event.target.value);
348
338
  }, [onChangeDateRange]);
349
- const [anchorDate, setAnchorDate] = (0, react_1.useState)(null);
350
- const [localStartDate, setLocalStartDate] = (0, react_1.useState)(null);
351
- const [localEndDate, setLocalEndDate] = (0, react_1.useState)(null);
339
+ const [anchorDate, setAnchorDate] = useState(null);
340
+ const [localStartDate, setLocalStartDate] = useState(null);
341
+ const [localEndDate, setLocalEndDate] = useState(null);
352
342
  // const firstDayOfFirstMonth = startOfMonth(value[0]);
353
343
  // const lastDayOfLastMonth = endOfMonth(value[1]);
354
344
  // const weekdays = getWeekdays(enUS).map(dayName =>
355
345
  // capitalize(dayName, locale)
356
346
  // );
357
- const prevMonthAnchor = (0, date_fns_1.subDays)((0, date_fns_1.startOfMonth)(anchorDate), 1);
347
+ const prevMonthAnchor = subDays(startOfMonth(anchorDate), 1);
358
348
  const onClickDate = (date) => {
359
- if (localStartDate && (0, date_fns_1.isBefore)(date, localStartDate)) {
349
+ if (localStartDate && isBefore(date, localStartDate)) {
360
350
  setLocalStartDate(date);
361
351
  return;
362
352
  }
363
- if (localEndDate && (0, date_fns_1.isAfter)(date, localEndDate)) {
353
+ if (localEndDate && isAfter(date, localEndDate)) {
364
354
  setLocalEndDate(date);
365
355
  return;
366
356
  }
367
- if (localEndDate && (0, date_fns_1.isBefore)(date, localEndDate)) {
357
+ if (localEndDate && isBefore(date, localEndDate)) {
368
358
  setLocalEndDate(date);
369
359
  return;
370
360
  }
371
- if ((0, date_fns_1.isEqual)(localStartDate, date) || (0, date_fns_1.isEqual)(localEndDate, date)) {
361
+ if (isEqual(localStartDate, date) || isEqual(localEndDate, date)) {
372
362
  setLocalStartDate(null);
373
363
  setLocalEndDate(null);
374
364
  }
@@ -381,19 +371,19 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
381
371
  return;
382
372
  }
383
373
  };
384
- (0, react_1.useEffect)(() => {
374
+ useEffect(() => {
385
375
  if (localEndDate &&
386
376
  localStartDate &&
387
- (0, date_fns_1.isBefore)(localStartDate, localEndDate)) {
377
+ isBefore(localStartDate, localEndDate)) {
388
378
  onChangeDateRange([localStartDate, localEndDate]);
389
379
  }
390
380
  }, [localEndDate, localStartDate]);
391
- (0, react_1.useEffect)(() => {
381
+ useEffect(() => {
392
382
  if (dateRange.length && !anchorDate) {
393
383
  setAnchorDate(dateRange[1]);
394
384
  }
395
385
  }, [dateRange, anchorDate]);
396
- (0, hooks_1.useOnClickOutside)(modalRef, (e) => {
386
+ useOnClickOutside(modalRef, (e) => {
397
387
  // Exclude click on trigger button (e.g. Dropdown Button) from outside click handler
398
388
  const isTriggerElem = parentRef
399
389
  ? parentRef.current?.contains(e.target)
@@ -402,7 +392,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
402
392
  setShowModal(false);
403
393
  }
404
394
  });
405
- return ((0, jsx_runtime_1.jsxs)("div", { ref: parentRef, style: { position: 'relative', height: 38 }, children: [(0, jsx_runtime_1.jsx)("button", {
395
+ return (_jsxs("div", { ref: parentRef, style: { position: 'relative', height: 38 }, children: [_jsx("button", {
406
396
  // onChange={handleOnChange}
407
397
  // value={value}
408
398
  onClick: () => setShowModal((showModal) => !showModal), id: 'reportbuilderdropdown', defaultValue: "Select", style: {
@@ -431,7 +421,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
431
421
  minHeight: 38,
432
422
  marginBottom: 0,
433
423
  paddingLeft: 14 + 15 + 3,
434
- }, children: formatDateText(dateRange, localStartDate, localEndDate) }), (0, jsx_runtime_1.jsx)(assets_1.CalendarNormalIcon, { style: {
424
+ }, children: formatDateText(dateRange, localStartDate, localEndDate) }), _jsx(CalendarNormalIcon, { style: {
435
425
  height: '15px',
436
426
  width: '15px',
437
427
  flex: 'none',
@@ -439,7 +429,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
439
429
  left: 12,
440
430
  top: 11,
441
431
  color: theme?.primaryTextColor,
442
- } }), showModal && ((0, jsx_runtime_1.jsxs)("div", { ref: modalRef, style: {
432
+ } }), showModal && (_jsxs("div", { ref: modalRef, style: {
443
433
  position: 'absolute',
444
434
  zIndex: 1,
445
435
  overflowY: 'auto',
@@ -469,7 +459,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
469
459
  paddingLeft: 8,
470
460
  paddingRight: 8,
471
461
  paddingBottom: 1,
472
- }, children: [(0, jsx_runtime_1.jsx)("button", { style: {
462
+ }, children: [_jsx("button", { style: {
473
463
  height: 32,
474
464
  width: 32,
475
465
  position: 'absolute',
@@ -489,11 +479,11 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
489
479
  alignItems: 'center',
490
480
  justifyContent: 'center',
491
481
  background: 'transparent',
492
- }, onClick: () => setAnchorDate((date) => (0, date_fns_1.subDays)((0, date_fns_1.startOfMonth)(date), 1)), children: (0, jsx_runtime_1.jsx)(assets_1.ArrowLeftHeadIcon, { style: {
482
+ }, onClick: () => setAnchorDate((date) => subDays(startOfMonth(date), 1)), children: _jsx(ArrowLeftHeadIcon, { style: {
493
483
  height: '20px',
494
484
  width: '20px',
495
485
  color: theme?.secondaryTextColor,
496
- }, "aria-hidden": "true" }) }), (0, jsx_runtime_1.jsx)("button", { style: {
486
+ }, "aria-hidden": "true" }) }), _jsx("button", { style: {
497
487
  height: 32,
498
488
  width: 32,
499
489
  borderColor: theme?.borderColor || '#E5E7EB',
@@ -513,33 +503,32 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
513
503
  alignItems: 'center',
514
504
  justifyContent: 'center',
515
505
  background: 'transparent',
516
- }, onClick: () => setAnchorDate((date) => (0, date_fns_1.addDays)((0, date_fns_1.endOfMonth)(date), 1)), children: (0, jsx_runtime_1.jsx)(assets_1.ArrowRightHeadIcon, { style: {
506
+ }, onClick: () => setAnchorDate((date) => addDays(endOfMonth(date), 1)), children: _jsx(ArrowRightHeadIcon, { style: {
517
507
  height: '20px',
518
508
  width: '20px',
519
509
  color: theme?.secondaryTextColor,
520
- }, "aria-hidden": "true" }) }), anchorDate && ((0, jsx_runtime_1.jsx)(Calendar, { anchorDate: prevMonthAnchor, dateRange: dateRange, theme: theme, onClickDate: onClickDate, localStartDate: localStartDate, localEndDate: localEndDate })), anchorDate && ((0, jsx_runtime_1.jsx)(Calendar, { anchorDate: anchorDate, dateRange: dateRange, theme: theme, onClickDate: onClickDate, localStartDate: localStartDate, localEndDate: localEndDate }))] }))] }));
510
+ }, "aria-hidden": "true" }) }), anchorDate && (_jsx(Calendar, { anchorDate: prevMonthAnchor, dateRange: dateRange, theme: theme, onClickDate: onClickDate, localStartDate: localStartDate, localEndDate: localEndDate })), anchorDate && (_jsx(Calendar, { anchorDate: anchorDate, dateRange: dateRange, theme: theme, onClickDate: onClickDate, localStartDate: localStartDate, localEndDate: localEndDate }))] }))] }));
521
511
  }
522
- const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, presetOptions, preset, onChangePreset, }) => {
523
- const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
524
- return ((0, jsx_runtime_1.jsxs)("div", { children: [label !== '' && ((0, jsx_runtime_1.jsx)("div", { style: {
512
+ export const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, presetOptions, preset, onChangePreset, }) => {
513
+ const [theme] = useContext(ThemeContext);
514
+ return (_jsxs("div", { children: [label !== '' && (_jsx("div", { style: {
525
515
  marginBottom: 6,
526
516
  fontWeight: theme.labelFontWeight || '600',
527
517
  color: theme.secondaryTextColor,
528
518
  fontFamily: theme.fontFamily,
529
519
  fontSize: 14,
530
- }, children: label })), (0, jsx_runtime_1.jsxs)("div", { style: {
520
+ }, children: label })), _jsxs("div", { style: {
531
521
  display: 'flex',
532
522
  flexDirection: 'row',
533
523
  alignItems: 'center',
534
524
  gap: 12,
535
- }, children: [(0, jsx_runtime_1.jsx)(MemoizedCalendarDropdown, { dateRange: dateRange, onChangeDateRange: onChangeDateRange, theme: theme }), (0, jsx_runtime_1.jsx)(MemoizedDropdown, { options: presetOptions.map((option) => ({
525
+ }, children: [_jsx(MemoizedCalendarDropdown, { dateRange: dateRange, onChangeDateRange: onChangeDateRange, theme: theme }), _jsx(MemoizedDropdown, { options: presetOptions.map((option) => ({
536
526
  label: option.text,
537
527
  value: option.value,
538
528
  })), onChange: onChangePreset, value: preset })] })] }));
539
529
  };
540
- exports.QuillDateRangePicker = QuillDateRangePicker;
541
- const MemoizedCalendarDropdown = react_1.default.memo(CalendarDropdown);
542
- const MemoizedDropdown = react_1.default.memo(QuillDropdownComponent);
530
+ const MemoizedCalendarDropdown = React.memo(CalendarDropdown);
531
+ const MemoizedDropdown = React.memo(QuillDropdownComponent);
543
532
  const areEqual = (prevProps, nextProps) => {
544
533
  // This function returns true if passing nextProps to render would return
545
534
  // the same result as passing prevProps to render, otherwise it returns false
@@ -548,41 +537,47 @@ const areEqual = (prevProps, nextProps) => {
548
537
  prevProps.dateRange[0] === nextProps.dateRange[0] &&
549
538
  prevProps.dateRange[1] === nextProps.dateRange[1]);
550
539
  };
551
- const MemoizedDateRangePicker = react_1.default.memo(exports.QuillDateRangePicker, areEqual);
552
- function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, FilterDropdownComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent, }) {
553
- const { isLoading: isDataLoading, data, reload } = (0, useDashboard_1.useDashboard)(name);
554
- const [dashboardSections, setDashboardSections] = (0, react_1.useState)(null);
555
- const { dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
556
- const [client] = (0, react_1.useContext)(Context_1.ClientContext);
557
- const [isLoading, setIsLoading] = (0, react_1.useState)(isDataLoading);
558
- const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
559
- const { dashboardFilters, dashboardFiltersDispatch } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
560
- const { setDateFilter } = (0, react_1.useContext)(Context_1.DateFilterContext);
561
- (0, react_1.useEffect)(() => {
540
+ const MemoizedDateRangePicker = React.memo(QuillDateRangePicker, areEqual);
541
+ export default function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, FilterDropdownComponent, EmptyDashboardComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent, }) {
542
+ const { dateFilter } = useDateFilter();
543
+ const { isLoading: isDataLoading, data, reload } = useDashboard(name);
544
+ const [dashboardSections, setDashboardSections] = useState(null);
545
+ const { dashboard } = useContext(DashboardContext);
546
+ const [client] = useContext(ClientContext);
547
+ const [isLoading, setIsLoading] = useState(isDataLoading);
548
+ const [theme] = useContext(ThemeContext);
549
+ const { dashboardFilters, dashboardFiltersDispatch } = useContext(DashboardFiltersContext);
550
+ const { setDateFilter } = useContext(DateFilterContext);
551
+ useEffect(() => {
562
552
  setIsLoading(isDataLoading);
563
553
  }, [isDataLoading]);
564
- (0, react_1.useEffect)(() => {
554
+ useEffect(() => {
565
555
  if (!data)
566
556
  return;
567
557
  onDashboardDataChange(data);
568
558
  }, [data]);
569
- (0, react_1.useEffect)(() => {
559
+ useEffect(() => {
570
560
  reload();
571
561
  }, [name, client]);
562
+ function hashCode(s) {
563
+ return s.split('').reduce(function (a, b) {
564
+ a = (a << 5) - a + b.charCodeAt(0);
565
+ return a & a;
566
+ }, 0);
567
+ }
572
568
  const onDashboardDataChange = (resp) => {
573
569
  setDashboardSections(resp.sections);
574
570
  const bigFilterObj = {};
575
571
  if (resp.dateFilter && Object.keys(resp.dateFilter).length) {
576
- const key = 'LAST_6_MONTHS';
577
- const code = '6m';
572
+ const key = resp.dateFilter.defaultPrimaryRange ?? 'LAST_6_MONTHS';
578
573
  const filter = {
579
- startDate: dateRangePickerUtils_1.PRIMARY_RANGE[key]?.start,
580
- endDate: dateRangePickerUtils_1.PRIMARY_RANGE[key]?.end,
574
+ startDate: PRIMARY_RANGE[key]?.start,
575
+ endDate: PRIMARY_RANGE[key]?.end,
581
576
  filterType: 'date_range',
582
577
  selectedValue: [
583
- dateRangePickerUtils_1.PRIMARY_RANGE[key]?.start,
584
- dateRangePickerUtils_1.PRIMARY_RANGE[key]?.end,
585
- code,
578
+ PRIMARY_RANGE[key]?.start,
579
+ PRIMARY_RANGE[key]?.end,
580
+ PRIMARY_CODES[key],
586
581
  ],
587
582
  options: options,
588
583
  field: 'date_range',
@@ -590,25 +585,27 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
590
585
  };
591
586
  if (resp.dateFilter.comparison) {
592
587
  filter.comparison = true;
588
+ const compKey = resp.dateFilter.defaultComparisonRange ?? 'PREV_PERIOD';
593
589
  const range = { start: filter.startDate, end: filter.endDate };
594
590
  filter.comparisonRange = {
595
- startDate: dateRangePickerUtils_1.COMPARISON_RANGE['PREV_PERIOD'](range)?.start,
596
- endDate: dateRangePickerUtils_1.COMPARISON_RANGE['PREV_PERIOD'](range)?.end,
597
- value: 'PREV_PERIOD',
591
+ startDate: COMPARISON_RANGE[compKey](range)?.start,
592
+ endDate: COMPARISON_RANGE[compKey](range)?.end,
593
+ value: compKey,
598
594
  };
599
595
  }
600
596
  else {
601
597
  filter.comparison = false;
602
598
  }
603
- dashboardFiltersDispatch({
604
- type: 'ADD_DASHBOARD_FILTER',
605
- id: 'date_range',
606
- data: {
607
- ...filter,
608
- },
609
- });
599
+ if (hashCode(JSON.stringify(dashboardFilters?.date_range ?? '')) !==
600
+ hashCode(JSON.stringify(filter))) {
601
+ dashboardFiltersDispatch({
602
+ type: 'ADD_DASHBOARD_FILTER',
603
+ id: 'date_range',
604
+ data: filter,
605
+ });
606
+ }
610
607
  bigFilterObj[filter.field] = filter;
611
- setDateFilter(resp.dateFilter);
608
+ setDateFilter(PRIMARY_OPTIONS.find((opt) => opt.value === resp.dateFilter.defaultPrimaryRange)?.text ?? null);
612
609
  }
613
610
  if (resp.filters && resp.filters.length) {
614
611
  Object.values(resp.filters)
@@ -618,12 +615,14 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
618
615
  bigFilterObj[filter.field] = processFilter(filter);
619
616
  });
620
617
  }
621
- dashboardFiltersDispatch({
622
- type: 'ADD_DASHBOARD_FILTERS',
623
- id: 'tons',
624
- data: bigFilterObj,
625
- });
626
- setDateFilter(null);
618
+ if (hashCode(JSON.stringify(dashboardFilters)) !==
619
+ hashCode(JSON.stringify(bigFilterObj))) {
620
+ dashboardFiltersDispatch({
621
+ type: 'ADD_DASHBOARD_FILTERS',
622
+ id: 'tons',
623
+ data: bigFilterObj,
624
+ });
625
+ }
627
626
  };
628
627
  const handleOnClickDashboardItem = (elem) => {
629
628
  if (dashboard[elem._id]._id) {
@@ -678,10 +677,10 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
678
677
  startDate: value ? value[0] : filter.startDate,
679
678
  endDate: value ? value[1] : filter.endDate,
680
679
  filterType: 'date_range',
680
+ label: 'Date',
681
681
  ...(selectedValue ? { selectedValue } : {}),
682
682
  field: 'date_range',
683
683
  options: options,
684
- label: 'Date',
685
684
  };
686
685
  }
687
686
  };
@@ -731,14 +730,14 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
731
730
  startDate: value ? value[0] : filter.startDate,
732
731
  endDate: value ? value[1] : filter.endDate,
733
732
  filterType: 'date_range',
733
+ label: 'Date',
734
734
  ...(selectedValue ? { selectedValue } : {}),
735
735
  field: 'date_range',
736
736
  options: options,
737
- label: 'Date',
738
737
  comparison: true,
739
738
  comparisonRange: {
740
- startDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.start,
741
- endDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.end,
739
+ startDate: COMPARISON_RANGE[key](primaryRange)?.start,
740
+ endDate: COMPARISON_RANGE[key](primaryRange)?.end,
742
741
  value: key,
743
742
  },
744
743
  },
@@ -762,7 +761,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
762
761
  }
763
762
  }
764
763
  };
765
- (0, react_1.useEffect)(() => {
764
+ useEffect(() => {
766
765
  if (dashboardSections && dashboard) {
767
766
  const totalNumberOfItems = Object.values(dashboardSections).reduce((count, arr) => count + arr.length, 0);
768
767
  const itemsLoaded = Object.keys(dashboard).length;
@@ -771,19 +770,21 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
771
770
  }
772
771
  }
773
772
  }, [dashboard, dashboardSections, isLoading]);
774
- (0, react_1.useEffect)(() => {
773
+ useEffect(() => {
775
774
  if (onChangeLoading) {
776
775
  onChangeLoading(isLoading);
777
776
  }
778
777
  }, [isLoading, onChangeLoading]);
779
- if (!dashboardSections)
778
+ if (isLoading)
780
779
  return null;
781
- return ((0, jsx_runtime_1.jsxs)("div", { style: containerStyle, children: [!hideFilters ? ((0, jsx_runtime_1.jsx)("div", { style: {
780
+ if (!dashboardSections || Object.keys(dashboardSections).length == 0)
781
+ return _jsx(EmptyDashboardComponent, {});
782
+ return (_jsxs("div", { style: containerStyle, children: [!hideFilters && (_jsx("div", { style: {
782
783
  display: 'flex',
783
784
  boxSizing: 'content-box',
784
785
  flexDirection: 'row',
785
786
  alignItems: 'center',
786
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
787
+ }, children: _jsx("div", { style: {
787
788
  width: '100%',
788
789
  marginBottom: 25,
789
790
  display: 'flex',
@@ -792,18 +793,18 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
792
793
  gap: 12,
793
794
  }, children: Object.values(dashboardFilters)
794
795
  .sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
795
- .map((filter, index) => ((0, jsx_runtime_1.jsx)(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
796
+ .map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
796
797
  ? FilterDropdownComponent
797
798
  : MemoizedDropdown, DateRangePickerComponent: DateRangePickerComponent
798
799
  ? DateRangePickerComponent
799
- : MemoizedDateRangePicker }, index))) }) })) : null, Object.keys(dashboardSections)
800
+ : MemoizedDateRangePicker }, index))) }) })), Object.keys(dashboardSections)
800
801
  .sort(function (a, b) {
801
802
  return a.length - b.length;
802
803
  })
803
804
  .map((section, sectionIndex) => {
804
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
805
+ return (_jsxs("div", { style: {
805
806
  width: '100%',
806
- }, 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: {
807
+ }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && (_jsx("h1", { style: {
807
808
  fontSize: 22,
808
809
  color: theme.primaryTextColor,
809
810
  fontFamily: theme.fontFamily,
@@ -813,7 +814,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
813
814
  // marginLeft: 25,
814
815
  textAlign: 'left',
815
816
  marginTop: 12,
816
- }, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
817
+ }, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? (_jsx("div", { style: {
817
818
  boxSizing: 'content-box',
818
819
  width: `100%`,
819
820
  listStyleType: 'none',
@@ -835,21 +836,21 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
835
836
  })
836
837
  .map((elem, index) => {
837
838
  if (DashboardItemComponent) {
838
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
839
+ return (_jsx("div", { onClick: onClickDashboardItem
839
840
  ? () => handleOnClickDashboardItem(elem)
840
- : undefined, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)("div", { style: {
841
+ : void null, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
841
842
  padding: 0,
842
843
  // height: '100%',
843
844
  boxSizing: 'content-box',
844
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
845
+ }, children: _jsx(Chart, { containerStyle: {
845
846
  display: 'flex',
846
847
  width: '100%',
847
848
  // height: '100%',
848
- }, isDateFilter: true, chartId: elem._id, colors: theme.chartColors?.length
849
+ }, chartId: elem._id, colors: theme.chartColors?.length
849
850
  ? theme.chartColors
850
851
  : undefined }) }) }) }, elem.name + '' + index));
851
852
  }
852
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
853
+ return (_jsx("div", { onClick: onClickDashboardItem
853
854
  ? () => handleOnClickDashboardItem(elem)
854
855
  : undefined, style: {
855
856
  // background: theme.elevatedCardColor,
@@ -862,22 +863,22 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
862
863
  cursor: 'pointer',
863
864
  width: '100%',
864
865
  ...metricContainerStyle,
865
- }, children: (0, jsx_runtime_1.jsx)("div", {
866
+ }, children: _jsx("div", {
866
867
  // className="group-hover:bg-black"
867
868
  style: {
868
869
  width: '100%',
869
870
  boxSizing: 'content-box',
870
871
  height: '100%',
871
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
872
+ }, children: _jsx("div", { style: {
872
873
  width: '100%',
873
874
  boxSizing: 'content-box',
874
875
  height: '100%',
875
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
876
+ }, children: _jsxs("div", { style: {
876
877
  display: 'flex',
877
878
  flexDirection: 'column',
878
879
  justifyContent: 'space-between',
879
880
  boxSizing: 'content-box',
880
- }, children: [(0, jsx_runtime_1.jsxs)("div", {
881
+ }, children: [_jsxs("div", {
881
882
  // className="group-hover:bg-black"
882
883
  style: {
883
884
  display: 'flex',
@@ -888,7 +889,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
888
889
  // paddingLeft: theme.padding,
889
890
  // paddingRight: 25,
890
891
  // paddingTop: theme.padding,
891
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
892
+ }, children: [_jsx("div", { title: elem.name, style: {
892
893
  fontFamily: theme.fontFamily,
893
894
  color: theme.primaryTextColor,
894
895
  boxSizing: 'content-box',
@@ -906,7 +907,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
906
907
  display: 'block',
907
908
  maxWidth: '100%',
908
909
  overflow: 'hidden',
909
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
910
+ }, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
910
911
  // className="hover:bg-black"
911
912
  style: {
912
913
  fontFamily: theme.fontFamily,
@@ -919,16 +920,16 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
919
920
  display: 'flex',
920
921
  alignItems: 'center',
921
922
  justifyContent: 'flex-end',
922
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: { padding: 0, paddingTop: 10 }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
923
+ }, children: 'view report →' })) : null] }), _jsx("div", { style: { padding: 0, paddingTop: 10 }, children: _jsx(Chart, { containerStyle: {
923
924
  // display: 'flex',
924
925
  // width: '100%',
925
926
  // height: 30,
926
927
  // marginBottom: 50,
927
928
  // marginTop: 50,
928
- }, isDateFilter: true,
929
+ },
929
930
  // chartFilters={elem.chartFilters}
930
931
  chartId: elem._id }) })] }) }) }) }, elem.name + '' + index));
931
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
932
+ }) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? (_jsx("div", { style: {
932
933
  listStyleType: 'none',
933
934
  display: 'grid',
934
935
  gridGap: 25,
@@ -949,20 +950,20 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
949
950
  })
950
951
  .map((elem, index) => {
951
952
  if (DashboardItemComponent) {
952
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
953
+ return (_jsx("div", { onClick: onClickDashboardItem
953
954
  ? () => handleOnClickDashboardItem(elem)
954
- : undefined, style: { height: rowHeight || 400 }, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
955
+ : undefined, style: { height: rowHeight || 400 }, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx(Chart, { containerStyle: {
955
956
  display: 'flex',
956
957
  width: '100%',
957
958
  // height: '100%',
958
959
  minHeight: 300,
959
960
  height: 300,
960
961
  // background: 'red',
961
- }, isDateFilter: true, chartId: elem._id, colors: theme.chartColors?.length
962
+ }, chartId: elem._id, colors: theme.chartColors?.length
962
963
  ? theme.chartColors
963
964
  : undefined }) }) }, elem.name + '' + index));
964
965
  }
965
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
966
+ return (_jsx("div", { onClick: onClickDashboardItem
966
967
  ? () => handleOnClickDashboardItem(elem)
967
968
  : undefined, style: {
968
969
  height: '100%',
@@ -973,26 +974,26 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
973
974
  borderRadius: 8,
974
975
  paddingTop: 20,
975
976
  ...chartContainerStyle,
976
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
977
+ }, children: _jsx("div", { style: {
977
978
  width: '100%',
978
979
  height: '100%',
979
980
  boxSizing: 'content-box',
980
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
981
+ }, children: _jsx("div", { style: {
981
982
  width: '100%',
982
983
  height: '100%',
983
984
  boxSizing: 'content-box',
984
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
985
+ }, children: _jsxs("div", { style: {
985
986
  display: 'flex',
986
987
  flexDirection: 'column',
987
988
  justifyContent: 'space-between',
988
989
  height: '100%',
989
990
  boxSizing: 'content-box',
990
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
991
+ }, children: [_jsxs("div", { style: {
991
992
  display: 'flex',
992
993
  flexDirection: 'row',
993
994
  justifyContent: 'space-between',
994
995
  boxSizing: 'content-box',
995
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
996
+ }, children: [_jsx("div", { style: {
996
997
  fontFamily: theme.fontFamily,
997
998
  color: theme.primaryTextColor,
998
999
  boxSizing: 'content-box',
@@ -1005,7 +1006,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1005
1006
  display: 'block',
1006
1007
  maxWidth: '100%',
1007
1008
  overflow: 'hidden',
1008
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", { style: {
1009
+ }, children: elem.name }), onClickDashboardItem ? (_jsx("div", { style: {
1009
1010
  fontFamily: theme.fontFamily,
1010
1011
  color: theme.primaryTextColor,
1011
1012
  boxSizing: 'content-box',
@@ -1015,27 +1016,27 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1015
1016
  display: 'flex',
1016
1017
  alignItems: 'center',
1017
1018
  justifyContent: 'flex-end',
1018
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: {
1019
+ }, children: 'view report →' })) : null] }), _jsx("div", { style: {
1019
1020
  padding: 0,
1020
1021
  height: '100%',
1021
1022
  boxSizing: 'content-box',
1022
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1023
+ }, children: _jsx(Chart, { containerStyle: {
1023
1024
  display: 'flex',
1024
1025
  width: '100%',
1025
1026
  // TODO: fix fixed height
1026
1027
  height: 300,
1027
1028
  marginBottom: 50,
1028
1029
  marginTop: 30,
1029
- }, isDateFilter: true, chartId: elem._id, colors: theme.chartColors?.length
1030
+ }, chartId: elem._id, colors: theme.chartColors?.length
1030
1031
  ? theme.chartColors
1031
1032
  : undefined }) })] }) }) }) }, elem.name + '' + index));
1032
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType === 'table').length ? ((0, jsx_runtime_1.jsxs)("div", { style: {
1033
+ }) })) : null, dashboardSections[section].filter((elem) => elem.chartType === 'table').length ? (_jsxs("div", { style: {
1033
1034
  boxSizing: 'content-box',
1034
1035
  width: `100%`,
1035
1036
  gap: 20,
1036
1037
  display: 'flex',
1037
1038
  flexDirection: 'column',
1038
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 0 } }), dashboardSections[section]
1039
+ }, children: [_jsx("div", { style: { height: 0 } }), dashboardSections[section]
1039
1040
  .filter((elem) => elem.chartType === 'table')
1040
1041
  .sort((a, b) => {
1041
1042
  if (a.order === undefined && b.order === undefined)
@@ -1048,23 +1049,23 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1048
1049
  })
1049
1050
  .map((elem, index) => {
1050
1051
  if (DashboardItemComponent) {
1051
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1052
+ return (_jsx("div", { onClick: onClickDashboardItem
1052
1053
  ? () => handleOnClickDashboardItem(elem)
1053
- : undefined, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)("div", { style: {
1054
+ : undefined, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
1054
1055
  padding: 0,
1055
1056
  height: '100%',
1056
1057
  boxSizing: 'content-box',
1057
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1058
+ }, children: _jsx(Chart, { containerStyle: {
1058
1059
  display: 'flex',
1059
1060
  width: '100%',
1060
1061
  height: '100%',
1061
- }, isDateFilter: true, chartId: elem._id, colors: theme.chartColors?.length
1062
+ }, chartId: elem._id, colors: theme.chartColors?.length
1062
1063
  ? theme.chartColors
1063
1064
  : undefined }) }) }) }, elem.name + '' + index));
1064
1065
  }
1065
- return ((0, jsx_runtime_1.jsxs)("div", { onClick: onClickDashboardItem
1066
+ return (_jsxs("div", { onClick: onClickDashboardItem
1066
1067
  ? () => handleOnClickDashboardItem(elem)
1067
- : undefined, children: [(0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1068
+ : undefined, children: [_jsx("div", { onClick: onClickDashboardItem
1068
1069
  ? () => handleOnClickDashboardItem(elem)
1069
1070
  : undefined, style: {
1070
1071
  // background: theme.elevatedCardColor,
@@ -1079,23 +1080,23 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1079
1080
  minHeight: 420,
1080
1081
  height: 420,
1081
1082
  // ...metricContainerStyle,
1082
- }, children: (0, jsx_runtime_1.jsx)("div", {
1083
+ }, children: _jsx("div", {
1083
1084
  // className="group-hover:bg-black"
1084
1085
  style: {
1085
1086
  width: '100%',
1086
1087
  boxSizing: 'content-box',
1087
1088
  height: '100%',
1088
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1089
+ }, children: _jsx("div", { style: {
1089
1090
  width: '100%',
1090
1091
  boxSizing: 'content-box',
1091
1092
  height: '100%',
1092
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1093
+ }, children: _jsxs("div", { style: {
1093
1094
  display: 'flex',
1094
1095
  flexDirection: 'column',
1095
1096
  justifyContent: 'space-between',
1096
1097
  boxSizing: 'content-box',
1097
1098
  height: '100%',
1098
- }, children: [(0, jsx_runtime_1.jsxs)("div", {
1099
+ }, children: [_jsxs("div", {
1099
1100
  // className="group-hover:bg-black"
1100
1101
  style: {
1101
1102
  display: 'flex',
@@ -1106,7 +1107,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1106
1107
  // paddingLeft: theme.padding,
1107
1108
  paddingRight: 25,
1108
1109
  // paddingTop: theme.padding,
1109
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
1110
+ }, children: [_jsx("div", { title: elem.name, style: {
1110
1111
  fontFamily: theme.fontFamily,
1111
1112
  color: theme.primaryTextColor,
1112
1113
  boxSizing: 'content-box',
@@ -1125,7 +1126,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1125
1126
  display: 'block',
1126
1127
  maxWidth: '100%',
1127
1128
  overflow: 'hidden',
1128
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
1129
+ }, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
1129
1130
  // className="hover:bg-black"
1130
1131
  style: {
1131
1132
  fontFamily: theme.fontFamily,
@@ -1138,23 +1139,22 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
1138
1139
  display: 'flex',
1139
1140
  alignItems: 'center',
1140
1141
  justifyContent: 'flex-end',
1141
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsxs)("div", { style: {
1142
+ }, children: 'view report →' })) : null] }), _jsxs("div", { style: {
1142
1143
  padding: 0,
1143
1144
  height: '400px',
1144
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1145
+ }, children: [_jsx("div", { style: { height: 20 } }), _jsx(Chart, { containerStyle: {
1145
1146
  // display: 'flex',
1146
1147
  // width: '100%',
1147
1148
  // height: 30,
1148
1149
  // marginBottom: 50,
1149
1150
  height: '100%',
1150
1151
  // paddingLeft: 25,
1151
- }, isDateFilter: true,
1152
+ },
1152
1153
  // chartFilters={elem.chartFilters}
1153
- chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), (0, jsx_runtime_1.jsx)("div", { style: { height: 40 } })] }, elem.name + '' + index));
1154
- })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: { height: 40 } })] }, section + '' + sectionIndex));
1154
+ chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), _jsx("div", { style: { height: 40 } })] }, elem.name + '' + index));
1155
+ })] })) : null, _jsx("div", { style: { height: 40 } })] }, section + '' + sectionIndex));
1155
1156
  })] }));
1156
1157
  }
1157
- exports.default = Dashboard;
1158
1158
  // ----------------------------------------------------------------
1159
1159
  // REST OF CODE NOT USED
1160
1160
  function Filter({ defaultValue, theme, onValueChange, filter }) {
@@ -1167,23 +1167,23 @@ function Filter({ defaultValue, theme, onValueChange, filter }) {
1167
1167
  { value: 'popupbagelsredding', text: 'popupbagelsredding' },
1168
1168
  { value: 'popupbagelsthompson', text: 'popupbagelsthompson' },
1169
1169
  ];
1170
- const dropdownRef = (0, react_1.useRef)(null);
1171
- const [showDropdown, setShowDropdown] = (0, react_1.useState)(false);
1172
- const [selectedValue, setSelectedValue] = (0, hooks_1.useInternalState)(defaultValue, undefined);
1170
+ const dropdownRef = useRef(null);
1171
+ const [showDropdown, setShowDropdown] = useState(false);
1172
+ const [selectedValue, setSelectedValue] = useInternalState(defaultValue, undefined);
1173
1173
  const selectedDropdownValue = selectedValue ? selectedValue[2] ?? null : null;
1174
1174
  const handleDropdownOptionClick = (dropdownValue) => {
1175
1175
  setSelectedValue([undefined, undefined, dropdownValue]);
1176
1176
  onValueChange?.([undefined, undefined, dropdownValue]);
1177
1177
  setShowDropdown(false);
1178
1178
  };
1179
- const [hoveredDropdownValue, handleDropdownKeyDown] = (0, hooks_1.useSelectOnKeyDown)(handleDropdownOptionClick, dropdownOptions.map((option) => option.value), showDropdown, setShowDropdown, selectedDropdownValue);
1180
- return ((0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative', width: '100%' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1179
+ const [hoveredDropdownValue, handleDropdownKeyDown] = useSelectOnKeyDown(handleDropdownOptionClick, dropdownOptions.map((option) => option.value), showDropdown, setShowDropdown, selectedDropdownValue);
1180
+ return (_jsxs("div", { style: { position: 'relative', width: '100%' }, children: [_jsx("div", { style: {
1181
1181
  marginBottom: 6,
1182
1182
  fontWeight: '600',
1183
1183
  color: theme.secondaryTextColor,
1184
1184
  fontSize: 14,
1185
1185
  fontFamily: theme.fontFamily,
1186
- }, 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 })] }));
1186
+ }, 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 })] }));
1187
1187
  }
1188
1188
  function removeQuotes(str) {
1189
1189
  if (str.startsWith('"') && str.endsWith('"')) {
@@ -1197,7 +1197,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
1197
1197
  const dropdownText = selectedDropdownValue
1198
1198
  ? String(dropdownOptions.find((option) => option[removeQuotes(field)] === selectedDropdownValue)[removeQuotes(label)])
1199
1199
  : dropdownPlaceholder;
1200
- return ((0, jsx_runtime_1.jsx)("div", { style: {
1200
+ return (_jsx("div", { style: {
1201
1201
  display: 'flex',
1202
1202
  alignItems: 'center',
1203
1203
  justifyContent: 'space-between',
@@ -1205,7 +1205,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
1205
1205
  background: theme?.backgroundColor,
1206
1206
  fontFamily: theme?.fontFamily,
1207
1207
  boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
1208
- }, children: (0, jsx_runtime_1.jsxs)("button", { type: "button", style: {
1208
+ }, children: _jsxs("button", { type: "button", style: {
1209
1209
  // fontFamily: theme?.fontFamily,
1210
1210
  borderColor: theme?.borderColor || '#E5E7EB',
1211
1211
  borderStyle: 'solid',
@@ -1227,7 +1227,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
1227
1227
  background: theme?.backgroundColor,
1228
1228
  fontSize: theme?.fontSizeSmall || '0.875rem',
1229
1229
  // fontWeight: theme?.fontWeightMedium || '800',
1230
- }, ref: dropdownRef, onClick: () => setShowDropdown(!showDropdown), onKeyDown: handleDropdownKeyDown, children: [(0, jsx_runtime_1.jsx)("p", { style: {
1230
+ }, ref: dropdownRef, onClick: () => setShowDropdown(!showDropdown), onKeyDown: handleDropdownKeyDown, children: [_jsx("p", { style: {
1231
1231
  margin: 0,
1232
1232
  fontFamily: theme?.fontFamily,
1233
1233
  color: theme?.primaryTextColor || '#364153',
@@ -1236,7 +1236,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
1236
1236
  whiteSpace: 'nowrap',
1237
1237
  fontWeight: theme?.fontWeightMedium || '500',
1238
1238
  fontSize: theme?.fontSizeSmall || '0.875rem',
1239
- }, children: dropdownText }), (0, jsx_runtime_1.jsx)(assets_1.ArrowDownHeadIcon, { style: {
1239
+ }, children: dropdownText }), _jsx(ArrowDownHeadIcon, { style: {
1240
1240
  height: '1.25rem',
1241
1241
  width: '1.25rem',
1242
1242
  flex: 'none',
@@ -1245,9 +1245,8 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
1245
1245
  }, "aria-hidden": "true" })] }) }));
1246
1246
  }
1247
1247
  function FilterModal({ setShowDropdown, dropdownRef, showDropdown, theme, selectedDropdownValue, hoveredDropdownValue, dropdownOptions, handleDropdownOptionClick, field, label, }) {
1248
- 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: {
1248
+ return (_jsx(Modal, { showModal: showDropdown, setShowModal: setShowDropdown, parentRef: dropdownRef, theme: theme, children: _jsx(SelectedValueContext.Provider, { value: {
1249
1249
  selectedValue: selectedDropdownValue,
1250
1250
  handleValueChange: handleDropdownOptionClick,
1251
- }, 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)]))) }) }) }));
1251
+ }, children: _jsx(HoveredValueContext.Provider, { value: { hoveredValue: hoveredDropdownValue }, children: dropdownOptions.map((row, index) => (_jsx(DropdownItem, { value: row[removeQuotes(field)], text: row[removeQuotes(label)], theme: theme, lastItem: dropdownOptions.length - 1 === index }, row[removeQuotes(field)]))) }) }) }));
1252
1252
  }
1253
- //# sourceMappingURL=Dashboard.js.map