@quillsql/react 2.8.4 → 2.8.6
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.
- package/dist/AddToDashboardModal.js +146 -180
- package/dist/BarList.js +36 -43
- package/dist/Chart.js +99 -131
- package/dist/ChartBuilder.js +80 -88
- package/dist/ChartEditor.js +14 -20
- package/dist/Context.js +52 -56
- package/dist/Dashboard.d.ts.map +1 -1
- package/dist/Dashboard.js +246 -305
- package/dist/DateRangePicker/Calendar.js +41 -45
- package/dist/DateRangePicker/DateRangePicker.js +32 -60
- package/dist/DateRangePicker/DateRangePickerButton.js +14 -16
- package/dist/DateRangePicker/dateRangePickerUtils.d.ts +6 -0
- package/dist/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/DateRangePicker/dateRangePickerUtils.js +89 -89
- package/dist/DateRangePicker/index.js +1 -8
- package/dist/PieChart.js +35 -69
- package/dist/QuillProvider.js +4 -6
- package/dist/ReportBuilder.js +120 -128
- package/dist/SQLEditor.js +56 -64
- package/dist/Table.d.ts +2 -1
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +64 -68
- package/dist/TableChart.js +17 -44
- package/dist/assets/ArrowDownHeadIcon.js +3 -5
- package/dist/assets/ArrowDownIcon.js +3 -5
- package/dist/assets/ArrowDownRightIcon.js +3 -5
- package/dist/assets/ArrowLeftHeadIcon.js +3 -5
- package/dist/assets/ArrowRightHeadIcon.js +3 -5
- package/dist/assets/ArrowRightIcon.js +3 -5
- package/dist/assets/ArrowUpHeadIcon.js +3 -5
- package/dist/assets/ArrowUpIcon.js +3 -5
- package/dist/assets/ArrowUpRightIcon.js +3 -5
- package/dist/assets/CalendarIcon.js +3 -5
- package/dist/assets/CalendarNormalIcon.js +3 -5
- package/dist/assets/DoubleArrowLeftHeadIcon.js +3 -5
- package/dist/assets/DoubleArrowRightHeadIcon.js +3 -5
- package/dist/assets/ExclamationFilledIcon.js +3 -5
- package/dist/assets/FilterIcon.js +3 -5
- package/dist/assets/LoadingSpinner.js +3 -5
- package/dist/assets/RefreshIcon.js +3 -5
- package/dist/assets/SearchIcon.js +3 -5
- package/dist/assets/UpLeftArrowsIcon.js +3 -5
- package/dist/assets/XCircleIcon.js +3 -5
- package/dist/assets/XIcon.js +3 -5
- package/dist/assets/index.js +21 -48
- package/dist/components/BigModal/BigModal.js +13 -38
- package/dist/components/Dropdown/Dropdown.js +24 -52
- package/dist/components/Dropdown/DropdownItem.js +9 -34
- package/dist/components/Dropdown/index.js +2 -10
- package/dist/components/Modal/Modal.js +13 -38
- package/dist/components/Modal/index.js +1 -8
- package/dist/components/QuillCard.js +8 -12
- package/dist/components/SqlTextEditor.d.ts +7 -0
- package/dist/components/SqlTextEditor.d.ts.map +1 -0
- package/dist/components/SqlTextEditor.js +14 -0
- package/dist/components/UiComponents.js +37 -50
- package/dist/components/selectUtils.js +6 -16
- package/dist/contexts/BaseColorContext.js +3 -5
- package/dist/contexts/HoveredValueContext.js +3 -5
- package/dist/contexts/RootStylesContext.js +3 -5
- package/dist/contexts/SelectedValueContext.js +3 -5
- package/dist/contexts/index.js +4 -14
- package/dist/hooks/index.js +4 -14
- package/dist/hooks/useDashboard.d.ts +7 -0
- package/dist/hooks/useDashboard.d.ts.map +1 -0
- package/dist/hooks/useDashboard.js +48 -0
- package/dist/hooks/useInternalState.js +3 -5
- package/dist/hooks/useOnClickOutside.js +3 -5
- package/dist/hooks/useOnWindowResize.js +4 -6
- package/dist/hooks/useQuill.js +11 -15
- package/dist/hooks/useSelectOnKeyDown.js +4 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -28
- package/dist/internals/ReportBuilder/PivotList.js +14 -19
- package/dist/internals/ReportBuilder/PivotModal.js +84 -91
- package/dist/internals/ReportBuilder/PivotModal.spec.js +70 -72
- package/dist/lib/font.js +2 -5
- package/dist/lib/index.js +3 -19
- package/dist/lib/inputTypes.js +1 -2
- package/dist/lib/utils.js +8 -18
- package/dist/utils/aggregate.js +28 -34
- package/dist/utils/colorToHex.js +1 -4
- package/dist/utils/dataFetcher.js +2 -7
- package/dist/utils/downloadCSV.js +1 -5
- package/package.json +2 -4
package/dist/Dashboard.js
CHANGED
|
@@ -1,48 +1,19 @@
|
|
|
1
|
-
|
|
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, Fragment as _Fragment } from "react/jsx-runtime";
|
|
31
2
|
// @ts-nocheck
|
|
32
3
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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, } from './DateRangePicker/dateRangePickerUtils';
|
|
7
|
+
import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, DateFilterContext, } 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,10 @@ exports.COMPARISON_OPTIONS = [
|
|
|
64
35
|
text: 'No comparison',
|
|
65
36
|
},
|
|
66
37
|
];
|
|
67
|
-
function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePickerComponent, theme, }) {
|
|
68
|
-
const [comparisonValue, setComparisonValue] =
|
|
69
|
-
const [filterValue, setFilterValue] =
|
|
70
|
-
|
|
38
|
+
export function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePickerComponent, theme, }) {
|
|
39
|
+
const [comparisonValue, setComparisonValue] = useState('');
|
|
40
|
+
const [filterValue, setFilterValue] = useState(null);
|
|
41
|
+
useEffect(() => {
|
|
71
42
|
if (filter.filterType === 'date_range' &&
|
|
72
43
|
!filter.selectedValue &&
|
|
73
44
|
!filterValue) {
|
|
@@ -80,16 +51,16 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
|
|
|
80
51
|
setFilterValue(filter.selectedValue);
|
|
81
52
|
}
|
|
82
53
|
if (filter.comparison) {
|
|
83
|
-
setComparisonValue(
|
|
54
|
+
setComparisonValue(COMPARISON_OPTIONS.find((option) => {
|
|
84
55
|
return option.value === filter.comparisonRange.value;
|
|
85
56
|
}).value);
|
|
86
57
|
}
|
|
87
58
|
}, [filter]);
|
|
88
59
|
if (filter.filterType === 'string') {
|
|
89
|
-
return ((
|
|
60
|
+
return (_jsx(SelectComponent, { label: filter.label, value: filterValue, onChange: (e) => {
|
|
90
61
|
onChangeFilter(filter, e);
|
|
91
62
|
}, options: [
|
|
92
|
-
...filter.options.map(elem => {
|
|
63
|
+
...filter.options.map((elem) => {
|
|
93
64
|
return {
|
|
94
65
|
label: elem[filter.labelField],
|
|
95
66
|
value: elem[filter.field],
|
|
@@ -98,20 +69,20 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
|
|
|
98
69
|
] }));
|
|
99
70
|
}
|
|
100
71
|
if (filter.filterType == 'date_range') {
|
|
101
|
-
return ((
|
|
72
|
+
return (_jsxs("div", { style: {
|
|
102
73
|
display: 'flex',
|
|
103
74
|
flexDirection: 'row',
|
|
104
75
|
alignItems: 'flex-end',
|
|
105
|
-
}, children: [(
|
|
76
|
+
}, children: [_jsx(DateRangePickerComponent, { dateRange: filterValue ? [filterValue[0], filterValue[1]] : [null, null], label: filter.label,
|
|
106
77
|
// value={filterValue}
|
|
107
|
-
onChangeDateRange: dateRange => {
|
|
78
|
+
onChangeDateRange: (dateRange) => {
|
|
108
79
|
onChangeFilter(filter, [dateRange[0], dateRange[1], null]);
|
|
109
80
|
setFilterValue([dateRange[0], dateRange[1], null]);
|
|
110
81
|
}, preset: filterValue && filterValue.length === 3 && filterValue[2] !== null
|
|
111
82
|
? filterValue[2]
|
|
112
|
-
: '', onChangePreset: preset => {
|
|
83
|
+
: '', onChangePreset: (preset) => {
|
|
113
84
|
if (typeof preset === 'string') {
|
|
114
|
-
const fullPreset =
|
|
85
|
+
const fullPreset = getRangeFromPreset(preset);
|
|
115
86
|
onChangeFilter(filter, fullPreset);
|
|
116
87
|
setFilterValue(fullPreset);
|
|
117
88
|
return;
|
|
@@ -126,19 +97,19 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
|
|
|
126
97
|
new Date(),
|
|
127
98
|
preset?.value || '',
|
|
128
99
|
]);
|
|
129
|
-
}, presetOptions:
|
|
100
|
+
}, presetOptions: defaultOptions }), filter.comparison && (_jsx("div", { children: _jsxs("div", { style: {
|
|
130
101
|
display: 'flex',
|
|
131
102
|
flexDirection: 'row',
|
|
132
103
|
alignItems: 'center',
|
|
133
|
-
}, children: [(
|
|
104
|
+
}, children: [_jsx("div", { style: {
|
|
134
105
|
paddingLeft: 16,
|
|
135
106
|
paddingRight: 12,
|
|
136
107
|
color: theme.secondaryTextColor,
|
|
137
|
-
}, children: "compared to" }), (
|
|
138
|
-
onChangeFilter(filter, null,
|
|
108
|
+
}, children: "compared to" }), _jsx(SelectComponent, { value: comparisonValue, onChange: (e) => {
|
|
109
|
+
onChangeFilter(filter, null, COMPARISON_OPTIONS.find((option) => {
|
|
139
110
|
return option.value === e;
|
|
140
111
|
}));
|
|
141
|
-
}, options:
|
|
112
|
+
}, options: COMPARISON_OPTIONS.map((compareOption) => {
|
|
142
113
|
return {
|
|
143
114
|
value: compareOption.value,
|
|
144
115
|
label: compareOption.text,
|
|
@@ -147,45 +118,44 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
|
|
|
147
118
|
}
|
|
148
119
|
return null;
|
|
149
120
|
}
|
|
150
|
-
exports.DashboardFilter = DashboardFilter;
|
|
151
121
|
const options = [
|
|
152
122
|
{
|
|
153
|
-
date_range: [
|
|
123
|
+
date_range: [startOfWeek(startOfToday()), startOfToday(), 'wk'],
|
|
154
124
|
},
|
|
155
125
|
{
|
|
156
|
-
date_range: [
|
|
126
|
+
date_range: [sub(startOfToday(), { days: 90 }), startOfToday(), '90d'],
|
|
157
127
|
},
|
|
158
128
|
{
|
|
159
|
-
date_range: [
|
|
129
|
+
date_range: [sub(startOfToday(), { days: 30 }), startOfToday(), 't'],
|
|
160
130
|
},
|
|
161
131
|
{
|
|
162
|
-
date_range: [
|
|
132
|
+
date_range: [sub(startOfToday(), { years: 100 }), startOfToday(), 'at'],
|
|
163
133
|
},
|
|
164
134
|
{
|
|
165
|
-
date_range: [
|
|
135
|
+
date_range: [startOfYear(startOfToday()), startOfToday(), 'y'],
|
|
166
136
|
},
|
|
167
137
|
{
|
|
168
|
-
date_range: [
|
|
138
|
+
date_range: [startOfMonth(startOfToday()), startOfToday(), 'm'],
|
|
169
139
|
},
|
|
170
140
|
{
|
|
171
|
-
date_range: [
|
|
141
|
+
date_range: [sub(startOfToday(), { days: 7 }), startOfToday(), 'w'],
|
|
172
142
|
},
|
|
173
143
|
{
|
|
174
|
-
date_range: [
|
|
144
|
+
date_range: [sub(startOfToday(), { months: 6 }), startOfToday(), '6m'],
|
|
175
145
|
},
|
|
176
146
|
];
|
|
177
147
|
const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
|
|
178
|
-
const [theme] =
|
|
179
|
-
const handleOnChange =
|
|
148
|
+
const [theme] = useContext(ThemeContext);
|
|
149
|
+
const handleOnChange = useCallback((event) => {
|
|
180
150
|
onChange(event.target.value);
|
|
181
151
|
}, [onChange]);
|
|
182
|
-
return ((
|
|
152
|
+
return (_jsxs("div", { children: [label && (_jsx("div", { style: {
|
|
183
153
|
marginBottom: 6,
|
|
184
154
|
fontWeight: theme.labelFontWeight || '600',
|
|
185
155
|
color: theme.secondaryTextColor,
|
|
186
156
|
fontFamily: theme.fontFamily,
|
|
187
157
|
fontSize: 14,
|
|
188
|
-
}, children: label })), (
|
|
158
|
+
}, children: label })), _jsxs("div", { style: { position: 'relative', height: 38 }, children: [_jsxs("select", { onChange: handleOnChange, value: value ?? '', id: 'reportbuilderdropdown',
|
|
189
159
|
// defaultValue="Select"
|
|
190
160
|
style: {
|
|
191
161
|
width: '100%',
|
|
@@ -209,7 +179,7 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
|
|
|
209
179
|
fontSize: 14,
|
|
210
180
|
fontWeight: 500,
|
|
211
181
|
boxSizing: 'border-box',
|
|
212
|
-
}, children: [(
|
|
182
|
+
}, 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
183
|
height: '20px',
|
|
214
184
|
width: '20px',
|
|
215
185
|
flex: 'none',
|
|
@@ -220,27 +190,27 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
|
|
|
220
190
|
}, "aria-hidden": "true" })] })] }));
|
|
221
191
|
};
|
|
222
192
|
const isBetween = (date, startDate, endDate) => {
|
|
223
|
-
return
|
|
193
|
+
return isAfter(date, startDate) && isBefore(date, endDate);
|
|
224
194
|
};
|
|
225
195
|
function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStartDate, localEndDate, }) {
|
|
226
|
-
const firstDayOfDisplayedMonth =
|
|
227
|
-
const lastDayOfDisplayedMonth =
|
|
228
|
-
const weekdays =
|
|
229
|
-
const displayedDates =
|
|
230
|
-
start:
|
|
196
|
+
const firstDayOfDisplayedMonth = startOfMonth(anchorDate);
|
|
197
|
+
const lastDayOfDisplayedMonth = endOfMonth(anchorDate);
|
|
198
|
+
const weekdays = getWeekdays(enUS).map((dayName) => capitalize(dayName, enUS));
|
|
199
|
+
const displayedDates = eachDayOfInterval({
|
|
200
|
+
start: isSunday(firstDayOfDisplayedMonth)
|
|
231
201
|
? firstDayOfDisplayedMonth
|
|
232
|
-
:
|
|
233
|
-
end:
|
|
202
|
+
: previousSunday(firstDayOfDisplayedMonth),
|
|
203
|
+
end: isSaturday(lastDayOfDisplayedMonth)
|
|
234
204
|
? lastDayOfDisplayedMonth
|
|
235
|
-
:
|
|
205
|
+
: nextSaturday(lastDayOfDisplayedMonth),
|
|
236
206
|
});
|
|
237
|
-
const displayedTitle =
|
|
238
|
-
return ((
|
|
207
|
+
const displayedTitle = capitalize(format(firstDayOfDisplayedMonth, 'MMMM yyyy', { locale: enUS }), enUS);
|
|
208
|
+
return (_jsxs("div", { style: {
|
|
239
209
|
display: 'flex',
|
|
240
210
|
flexDirection: 'column',
|
|
241
211
|
flex: 1,
|
|
242
212
|
// alignItems: 'center',
|
|
243
|
-
}, children: [(
|
|
213
|
+
}, children: [_jsx("h2", { style: {
|
|
244
214
|
color: theme?.textColor || '#364153',
|
|
245
215
|
fontSize: '13px',
|
|
246
216
|
fontFamily: theme?.fontFamily,
|
|
@@ -254,7 +224,7 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
|
|
|
254
224
|
justifyContent: 'center',
|
|
255
225
|
marginBottom: 3,
|
|
256
226
|
marginTop: 6,
|
|
257
|
-
}, children: displayedTitle }), (
|
|
227
|
+
}, children: displayedTitle }), _jsx("div", { style: {
|
|
258
228
|
color: theme?.primaryTextColor || '#364153',
|
|
259
229
|
textAlign: 'center',
|
|
260
230
|
fontSize: 12,
|
|
@@ -262,7 +232,7 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
|
|
|
262
232
|
display: 'grid',
|
|
263
233
|
gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
|
|
264
234
|
paddingTop: 6,
|
|
265
|
-
}, children: weekdays.map(dayName => ((
|
|
235
|
+
}, children: weekdays.map((dayName) => (_jsx("div", { style: { width: '100%', display: 'flex', justifyContent: 'center' }, children: _jsx("div", { style: {
|
|
266
236
|
display: 'flex',
|
|
267
237
|
alignItems: 'center',
|
|
268
238
|
justifyContent: 'center',
|
|
@@ -271,7 +241,7 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
|
|
|
271
241
|
fontFamily: theme?.fontFamily,
|
|
272
242
|
color: theme.secondaryTextColor,
|
|
273
243
|
paddingBottom: 4,
|
|
274
|
-
}, children: dayName }) }, dayName))) }), (
|
|
244
|
+
}, children: dayName }) }, dayName))) }), _jsx("div", { style: {
|
|
275
245
|
display: 'grid',
|
|
276
246
|
gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
|
|
277
247
|
borderRadius: 3,
|
|
@@ -286,7 +256,7 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
|
|
|
286
256
|
// lastDayOfDisplayedMonth
|
|
287
257
|
// );
|
|
288
258
|
// console.log(localStartDate === date, localStartDate, date);
|
|
289
|
-
return ((
|
|
259
|
+
return (_jsx("div", { style: { width: '100%' }, children: _jsx("button", { style: {
|
|
290
260
|
border: 'none',
|
|
291
261
|
height: '34px',
|
|
292
262
|
display: 'flex',
|
|
@@ -295,22 +265,22 @@ function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStar
|
|
|
295
265
|
justifyContent: 'center',
|
|
296
266
|
fontFamily: theme?.fontFamily,
|
|
297
267
|
fontSize: 13,
|
|
298
|
-
background:
|
|
268
|
+
background: isEqual(localStartDate, date) || isEqual(localEndDate, date)
|
|
299
269
|
? theme.primaryTextColor
|
|
300
270
|
: isBetween(date, localStartDate, localEndDate)
|
|
301
271
|
? '#F4F4F5'
|
|
302
272
|
: 'transparent',
|
|
303
|
-
color:
|
|
273
|
+
color: isEqual(localStartDate, date) || isEqual(localEndDate, date)
|
|
304
274
|
? theme.backgroundColor
|
|
305
275
|
: theme.primaryTextColor,
|
|
306
|
-
borderRadius:
|
|
276
|
+
borderRadius: isEqual(localStartDate, date) || isEqual(localEndDate, date)
|
|
307
277
|
? 3
|
|
308
278
|
: 0,
|
|
309
279
|
...isBeginningOrEndOfWeek(index),
|
|
310
280
|
}, type: "button", onClick: () => {
|
|
311
281
|
onClickDate(date);
|
|
312
|
-
}, children: (
|
|
313
|
-
}) }), (
|
|
282
|
+
}, children: _jsx("time", { dateTime: format(date, 'yyyy-MM-dd', { locale: enUS }), children: format(date, 'd', { locale: enUS }) }) }) }, date.toString()));
|
|
283
|
+
}) }), _jsx("div", { style: { height: 8 } })] }));
|
|
314
284
|
}
|
|
315
285
|
function isBeginningOrEndOfWeek(num) {
|
|
316
286
|
// Check if the number is 0
|
|
@@ -327,48 +297,48 @@ function isBeginningOrEndOfWeek(num) {
|
|
|
327
297
|
}
|
|
328
298
|
const formatDateText = (dateRange, localStartDate, localEndDate) => {
|
|
329
299
|
if (dateRange.length && dateRange[0] && dateRange[1]) {
|
|
330
|
-
return (
|
|
300
|
+
return (format(dateRange[0], 'MMM dd, yyyy') +
|
|
331
301
|
' - ' +
|
|
332
|
-
|
|
302
|
+
format(dateRange[1], 'MMM dd, yyyy'));
|
|
333
303
|
}
|
|
334
304
|
if (localStartDate && localEndDate) {
|
|
335
|
-
return (
|
|
305
|
+
return (format(localStartDate, 'MMM dd, yyyy') +
|
|
336
306
|
' - ' +
|
|
337
|
-
|
|
307
|
+
format(localEndDate, 'MMM dd, yyyy'));
|
|
338
308
|
}
|
|
339
309
|
return '';
|
|
340
310
|
};
|
|
341
311
|
function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
342
|
-
const [theme] =
|
|
343
|
-
const [showModal, setShowModal] =
|
|
344
|
-
const modalRef =
|
|
345
|
-
const parentRef =
|
|
346
|
-
const handleOnChange =
|
|
312
|
+
const [theme] = useContext(ThemeContext);
|
|
313
|
+
const [showModal, setShowModal] = useState(false);
|
|
314
|
+
const modalRef = useRef(null);
|
|
315
|
+
const parentRef = useRef(null);
|
|
316
|
+
const handleOnChange = useCallback((event) => {
|
|
347
317
|
onChangeDateRange(event.target.value);
|
|
348
318
|
}, [onChangeDateRange]);
|
|
349
|
-
const [anchorDate, setAnchorDate] =
|
|
350
|
-
const [localStartDate, setLocalStartDate] =
|
|
351
|
-
const [localEndDate, setLocalEndDate] =
|
|
319
|
+
const [anchorDate, setAnchorDate] = useState(null);
|
|
320
|
+
const [localStartDate, setLocalStartDate] = useState(null);
|
|
321
|
+
const [localEndDate, setLocalEndDate] = useState(null);
|
|
352
322
|
// const firstDayOfFirstMonth = startOfMonth(value[0]);
|
|
353
323
|
// const lastDayOfLastMonth = endOfMonth(value[1]);
|
|
354
324
|
// const weekdays = getWeekdays(enUS).map(dayName =>
|
|
355
325
|
// capitalize(dayName, locale)
|
|
356
326
|
// );
|
|
357
|
-
const prevMonthAnchor =
|
|
358
|
-
const onClickDate = date => {
|
|
359
|
-
if (localStartDate &&
|
|
327
|
+
const prevMonthAnchor = subDays(startOfMonth(anchorDate), 1);
|
|
328
|
+
const onClickDate = (date) => {
|
|
329
|
+
if (localStartDate && isBefore(date, localStartDate)) {
|
|
360
330
|
setLocalStartDate(date);
|
|
361
331
|
return;
|
|
362
332
|
}
|
|
363
|
-
if (localEndDate &&
|
|
333
|
+
if (localEndDate && isAfter(date, localEndDate)) {
|
|
364
334
|
setLocalEndDate(date);
|
|
365
335
|
return;
|
|
366
336
|
}
|
|
367
|
-
if (localEndDate &&
|
|
337
|
+
if (localEndDate && isBefore(date, localEndDate)) {
|
|
368
338
|
setLocalEndDate(date);
|
|
369
339
|
return;
|
|
370
340
|
}
|
|
371
|
-
if (
|
|
341
|
+
if (isEqual(localStartDate, date) || isEqual(localEndDate, date)) {
|
|
372
342
|
setLocalStartDate(null);
|
|
373
343
|
setLocalEndDate(null);
|
|
374
344
|
}
|
|
@@ -381,19 +351,19 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
381
351
|
return;
|
|
382
352
|
}
|
|
383
353
|
};
|
|
384
|
-
|
|
354
|
+
useEffect(() => {
|
|
385
355
|
if (localEndDate &&
|
|
386
356
|
localStartDate &&
|
|
387
|
-
|
|
357
|
+
isBefore(localStartDate, localEndDate)) {
|
|
388
358
|
onChangeDateRange([localStartDate, localEndDate]);
|
|
389
359
|
}
|
|
390
360
|
}, [localEndDate, localStartDate]);
|
|
391
|
-
|
|
361
|
+
useEffect(() => {
|
|
392
362
|
if (dateRange.length && !anchorDate) {
|
|
393
363
|
setAnchorDate(dateRange[1]);
|
|
394
364
|
}
|
|
395
365
|
}, [dateRange, anchorDate]);
|
|
396
|
-
|
|
366
|
+
useOnClickOutside(modalRef, (e) => {
|
|
397
367
|
// Exclude click on trigger button (e.g. Dropdown Button) from outside click handler
|
|
398
368
|
const isTriggerElem = parentRef
|
|
399
369
|
? parentRef.current?.contains(e.target)
|
|
@@ -402,10 +372,10 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
402
372
|
setShowModal(false);
|
|
403
373
|
}
|
|
404
374
|
});
|
|
405
|
-
return ((
|
|
375
|
+
return (_jsxs("div", { ref: parentRef, style: { position: 'relative', height: 38 }, children: [_jsx("button", {
|
|
406
376
|
// onChange={handleOnChange}
|
|
407
377
|
// value={value}
|
|
408
|
-
onClick: () => setShowModal(showModal => !showModal), id: 'reportbuilderdropdown', defaultValue: "Select", style: {
|
|
378
|
+
onClick: () => setShowModal((showModal) => !showModal), id: 'reportbuilderdropdown', defaultValue: "Select", style: {
|
|
409
379
|
width: '100%',
|
|
410
380
|
WebkitAppearance: 'none',
|
|
411
381
|
minWidth: 275,
|
|
@@ -431,7 +401,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
431
401
|
minHeight: 38,
|
|
432
402
|
marginBottom: 0,
|
|
433
403
|
paddingLeft: 14 + 15 + 3,
|
|
434
|
-
}, children: formatDateText(dateRange, localStartDate, localEndDate) }), (
|
|
404
|
+
}, children: formatDateText(dateRange, localStartDate, localEndDate) }), _jsx(CalendarNormalIcon, { style: {
|
|
435
405
|
height: '15px',
|
|
436
406
|
width: '15px',
|
|
437
407
|
flex: 'none',
|
|
@@ -439,7 +409,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
439
409
|
left: 12,
|
|
440
410
|
top: 11,
|
|
441
411
|
color: theme?.primaryTextColor,
|
|
442
|
-
} }), showModal && ((
|
|
412
|
+
} }), showModal && (_jsxs("div", { ref: modalRef, style: {
|
|
443
413
|
position: 'absolute',
|
|
444
414
|
zIndex: 1,
|
|
445
415
|
overflowY: 'auto',
|
|
@@ -469,7 +439,7 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
469
439
|
paddingLeft: 8,
|
|
470
440
|
paddingRight: 8,
|
|
471
441
|
paddingBottom: 1,
|
|
472
|
-
}, children: [(
|
|
442
|
+
}, children: [_jsx("button", { style: {
|
|
473
443
|
height: 32,
|
|
474
444
|
width: 32,
|
|
475
445
|
position: 'absolute',
|
|
@@ -489,11 +459,11 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
489
459
|
alignItems: 'center',
|
|
490
460
|
justifyContent: 'center',
|
|
491
461
|
background: 'transparent',
|
|
492
|
-
}, onClick: () => setAnchorDate(date =>
|
|
462
|
+
}, onClick: () => setAnchorDate((date) => subDays(startOfMonth(date), 1)), children: _jsx(ArrowLeftHeadIcon, { style: {
|
|
493
463
|
height: '20px',
|
|
494
464
|
width: '20px',
|
|
495
465
|
color: theme?.secondaryTextColor,
|
|
496
|
-
}, "aria-hidden": "true" }) }), (
|
|
466
|
+
}, "aria-hidden": "true" }) }), _jsx("button", { style: {
|
|
497
467
|
height: 32,
|
|
498
468
|
width: 32,
|
|
499
469
|
borderColor: theme?.borderColor || '#E5E7EB',
|
|
@@ -513,33 +483,32 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
|
|
|
513
483
|
alignItems: 'center',
|
|
514
484
|
justifyContent: 'center',
|
|
515
485
|
background: 'transparent',
|
|
516
|
-
}, onClick: () => setAnchorDate(date =>
|
|
486
|
+
}, onClick: () => setAnchorDate((date) => addDays(endOfMonth(date), 1)), children: _jsx(ArrowRightHeadIcon, { style: {
|
|
517
487
|
height: '20px',
|
|
518
488
|
width: '20px',
|
|
519
489
|
color: theme?.secondaryTextColor,
|
|
520
|
-
}, "aria-hidden": "true" }) }), anchorDate && ((
|
|
490
|
+
}, "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
491
|
}
|
|
522
|
-
const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, presetOptions, preset, onChangePreset, }) => {
|
|
523
|
-
const [theme] =
|
|
524
|
-
return ((
|
|
492
|
+
export const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, presetOptions, preset, onChangePreset, }) => {
|
|
493
|
+
const [theme] = useContext(ThemeContext);
|
|
494
|
+
return (_jsxs("div", { children: [label !== '' && (_jsx("div", { style: {
|
|
525
495
|
marginBottom: 6,
|
|
526
496
|
fontWeight: theme.labelFontWeight || '600',
|
|
527
497
|
color: theme.secondaryTextColor,
|
|
528
498
|
fontFamily: theme.fontFamily,
|
|
529
499
|
fontSize: 14,
|
|
530
|
-
}, children: label })), (
|
|
500
|
+
}, children: label })), _jsxs("div", { style: {
|
|
531
501
|
display: 'flex',
|
|
532
502
|
flexDirection: 'row',
|
|
533
503
|
alignItems: 'center',
|
|
534
504
|
gap: 12,
|
|
535
|
-
}, children: [(
|
|
505
|
+
}, children: [_jsx(MemoizedCalendarDropdown, { dateRange: dateRange, onChangeDateRange: onChangeDateRange, theme: theme }), _jsx(MemoizedDropdown, { options: presetOptions.map((option) => ({
|
|
536
506
|
label: option.text,
|
|
537
507
|
value: option.value,
|
|
538
508
|
})), onChange: onChangePreset, value: preset })] })] }));
|
|
539
509
|
};
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
const MemoizedDropdown = react_1.default.memo(QuillDropdownComponent);
|
|
510
|
+
const MemoizedCalendarDropdown = React.memo(CalendarDropdown);
|
|
511
|
+
const MemoizedDropdown = React.memo(QuillDropdownComponent);
|
|
543
512
|
const areEqual = (prevProps, nextProps) => {
|
|
544
513
|
// This function returns true if passing nextProps to render would return
|
|
545
514
|
// the same result as passing prevProps to render, otherwise it returns false
|
|
@@ -548,110 +517,84 @@ const areEqual = (prevProps, nextProps) => {
|
|
|
548
517
|
prevProps.dateRange[0] === nextProps.dateRange[0] &&
|
|
549
518
|
prevProps.dateRange[1] === nextProps.dateRange[1]);
|
|
550
519
|
};
|
|
551
|
-
const MemoizedDateRangePicker =
|
|
552
|
-
function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, FilterDropdownComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent, }) {
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
const
|
|
556
|
-
const [
|
|
557
|
-
const [
|
|
558
|
-
const
|
|
559
|
-
const {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
520
|
+
const MemoizedDateRangePicker = React.memo(QuillDateRangePicker, areEqual);
|
|
521
|
+
export default function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, FilterDropdownComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent, }) {
|
|
522
|
+
const { isLoading: isDataLoading, data, error, reload } = useDashboard(name);
|
|
523
|
+
const [dashboardSections, setDashboardSections] = useState(null);
|
|
524
|
+
const { dashboard } = useContext(DashboardContext);
|
|
525
|
+
const [client] = useContext(ClientContext);
|
|
526
|
+
const [isLoading, setIsLoading] = useState(isDataLoading);
|
|
527
|
+
const [theme] = useContext(ThemeContext);
|
|
528
|
+
const { dashboardFilters, dashboardFiltersDispatch } = useContext(DashboardFiltersContext);
|
|
529
|
+
const { setDateFilter } = useContext(DateFilterContext);
|
|
530
|
+
useEffect(() => {
|
|
531
|
+
setIsLoading(isDataLoading);
|
|
532
|
+
}, [isDataLoading]);
|
|
533
|
+
useEffect(() => {
|
|
534
|
+
onDashboardDataChange(data);
|
|
535
|
+
}, [data]);
|
|
536
|
+
useEffect(() => {
|
|
537
|
+
reload();
|
|
538
|
+
}, [name, client]);
|
|
539
|
+
const onDashboardDataChange = (resp) => {
|
|
540
|
+
if (!resp)
|
|
541
|
+
return;
|
|
542
|
+
setDashboardSections(resp.sections);
|
|
543
|
+
const bigFilterObj = {};
|
|
544
|
+
if (resp.dateFilter && Object.keys(resp.dateFilter).length) {
|
|
545
|
+
const key = 'LAST_6_MONTHS';
|
|
546
|
+
const code = '6m';
|
|
547
|
+
const filter = {
|
|
548
|
+
startDate: PRIMARY_RANGE[key]?.start,
|
|
549
|
+
endDate: PRIMARY_RANGE[key]?.end,
|
|
550
|
+
filterType: 'date_range',
|
|
551
|
+
selectedValue: [
|
|
552
|
+
PRIMARY_RANGE[key]?.start,
|
|
553
|
+
PRIMARY_RANGE[key]?.end,
|
|
554
|
+
code,
|
|
555
|
+
],
|
|
556
|
+
options: options,
|
|
557
|
+
field: 'date_range',
|
|
558
|
+
label: 'Date',
|
|
559
|
+
};
|
|
560
|
+
if (resp.dateFilter.comparison) {
|
|
561
|
+
filter.comparison = true;
|
|
562
|
+
const range = { start: filter.startDate, end: filter.endDate };
|
|
563
|
+
filter.comparisonRange = {
|
|
564
|
+
startDate: COMPARISON_RANGE['PREV_PERIOD'](range)?.start,
|
|
565
|
+
endDate: COMPARISON_RANGE['PREV_PERIOD'](range)?.end,
|
|
566
|
+
value: 'PREV_PERIOD',
|
|
576
567
|
};
|
|
577
|
-
const resp = await (0, dataFetcher_1.getData)(client, `dashconfig?${searchParams}`, 'omit', hostedBody, null, 'GET');
|
|
578
|
-
setDashboardSections(resp.sections);
|
|
579
|
-
const bigFilterObj = {};
|
|
580
|
-
if (resp.dateFilter && Object.keys(resp.dateFilter).length) {
|
|
581
|
-
// const startDate = resp.dateFilter;
|
|
582
|
-
const filter = {
|
|
583
|
-
startDate: dateRangePickerUtils_1.PRIMARY_RANGE['LAST_6_MONTHS']?.start,
|
|
584
|
-
endDate: dateRangePickerUtils_1.PRIMARY_RANGE['LAST_6_MONTHS']?.end,
|
|
585
|
-
filterType: 'date_range',
|
|
586
|
-
selectedValue: [
|
|
587
|
-
dateRangePickerUtils_1.PRIMARY_RANGE['LAST_6_MONTHS']?.start,
|
|
588
|
-
dateRangePickerUtils_1.PRIMARY_RANGE['LAST_6_MONTHS']?.end,
|
|
589
|
-
'6m',
|
|
590
|
-
],
|
|
591
|
-
options: options,
|
|
592
|
-
field: 'date_range',
|
|
593
|
-
label: 'Date',
|
|
594
|
-
};
|
|
595
|
-
if (resp.dateFilter.comparison) {
|
|
596
|
-
filter.comparison = true;
|
|
597
|
-
const range = { start: filter.startDate, end: filter.endDate };
|
|
598
|
-
filter.comparisonRange = {
|
|
599
|
-
startDate: dateRangePickerUtils_1.COMPARISON_RANGE['PREV_PERIOD'](range)?.start,
|
|
600
|
-
endDate: dateRangePickerUtils_1.COMPARISON_RANGE['PREV_PERIOD'](range)?.end,
|
|
601
|
-
value: 'PREV_PERIOD',
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
else {
|
|
605
|
-
filter.comparison = false;
|
|
606
|
-
}
|
|
607
|
-
dashboardFiltersDispatch({
|
|
608
|
-
type: 'ADD_DASHBOARD_FILTER',
|
|
609
|
-
id: 'date_range',
|
|
610
|
-
data: {
|
|
611
|
-
...filter,
|
|
612
|
-
},
|
|
613
|
-
});
|
|
614
|
-
bigFilterObj[filter.field] = filter;
|
|
615
|
-
setDateFilter(resp.dateFilter);
|
|
616
|
-
}
|
|
617
|
-
if (resp.filters && resp.filters.length) {
|
|
618
|
-
Object.values(resp.filters)
|
|
619
|
-
.filter(filter => filter.filterType !== 'date')
|
|
620
|
-
.forEach(filter => {
|
|
621
|
-
// processFilter(filter);
|
|
622
|
-
bigFilterObj[filter.field] = processFilter(filter);
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
dashboardFiltersDispatch({
|
|
626
|
-
type: 'ADD_DASHBOARD_FILTERS',
|
|
627
|
-
id: 'tons',
|
|
628
|
-
data: bigFilterObj,
|
|
629
|
-
});
|
|
630
|
-
setDateFilter(null);
|
|
631
568
|
}
|
|
632
|
-
|
|
633
|
-
|
|
569
|
+
else {
|
|
570
|
+
filter.comparison = false;
|
|
634
571
|
}
|
|
572
|
+
dashboardFiltersDispatch({
|
|
573
|
+
type: 'ADD_DASHBOARD_FILTER',
|
|
574
|
+
id: 'date_range',
|
|
575
|
+
data: {
|
|
576
|
+
...filter,
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
bigFilterObj[filter.field] = filter;
|
|
580
|
+
setDateFilter(resp.dateFilter);
|
|
581
|
+
}
|
|
582
|
+
if (resp.filters && resp.filters.length) {
|
|
583
|
+
Object.values(resp.filters)
|
|
584
|
+
.filter((filter) => filter.filterType !== 'date')
|
|
585
|
+
.forEach((filter) => {
|
|
586
|
+
// processFilter(filter);
|
|
587
|
+
bigFilterObj[filter.field] = processFilter(filter);
|
|
588
|
+
});
|
|
635
589
|
}
|
|
636
|
-
getDashboards();
|
|
637
|
-
}, [name, client]);
|
|
638
|
-
// TODO: I think this can be removed
|
|
639
|
-
(0, react_1.useEffect)(() => {
|
|
640
|
-
// change to be set on the dashboard / section as default date range
|
|
641
|
-
const filter = {
|
|
642
|
-
startDate: (0, date_fns_1.sub)((0, date_fns_1.startOfToday)(), { days: 90 }),
|
|
643
|
-
endDate: new Date(),
|
|
644
|
-
filterType: 'date_range',
|
|
645
|
-
};
|
|
646
590
|
dashboardFiltersDispatch({
|
|
647
|
-
type: '
|
|
648
|
-
id: '
|
|
649
|
-
data:
|
|
650
|
-
...filter,
|
|
651
|
-
},
|
|
591
|
+
type: 'ADD_DASHBOARD_FILTERS',
|
|
592
|
+
id: 'tons',
|
|
593
|
+
data: bigFilterObj,
|
|
652
594
|
});
|
|
653
|
-
|
|
654
|
-
|
|
595
|
+
setDateFilter(null);
|
|
596
|
+
};
|
|
597
|
+
const handleOnClickDashboardItem = (elem) => {
|
|
655
598
|
if (dashboard[elem._id]._id) {
|
|
656
599
|
onClickDashboardItem(dashboard[elem._id]);
|
|
657
600
|
}
|
|
@@ -664,7 +607,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
664
607
|
});
|
|
665
608
|
}
|
|
666
609
|
};
|
|
667
|
-
const onChangeDateFilter = dateFilter => {
|
|
610
|
+
const onChangeDateFilter = (dateFilter) => {
|
|
668
611
|
// setGlobalDateFilter(dateFilter[0], dateFilter[1]);
|
|
669
612
|
dashboardFiltersDispatch({
|
|
670
613
|
type: 'ADD_DASHBOARD_FILTER',
|
|
@@ -682,7 +625,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
682
625
|
let selectedValue;
|
|
683
626
|
let selectedElem;
|
|
684
627
|
if (filter.filterType === 'string') {
|
|
685
|
-
selectedElem = filter.options.find(elem => elem[removeQuotes(filter.field)] === value);
|
|
628
|
+
selectedElem = filter.options.find((elem) => elem[removeQuotes(filter.field)] === value);
|
|
686
629
|
if (selectedElem) {
|
|
687
630
|
selectedValue = selectedElem[removeQuotes(filter.field)];
|
|
688
631
|
}
|
|
@@ -693,7 +636,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
693
636
|
}
|
|
694
637
|
if (filter.filterType === 'date' || filter.filterType === 'date_range') {
|
|
695
638
|
if (value[2]) {
|
|
696
|
-
selectedElem = filter.options.find(elem => {
|
|
639
|
+
selectedElem = filter.options.find((elem) => {
|
|
697
640
|
return value[2] === elem[removeQuotes(filter.field)][2];
|
|
698
641
|
});
|
|
699
642
|
if (selectedElem) {
|
|
@@ -717,7 +660,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
717
660
|
let selectedValue;
|
|
718
661
|
let selectedElem;
|
|
719
662
|
if (filter.filterType === 'string') {
|
|
720
|
-
selectedElem = filter.options.find(elem => elem[removeQuotes(filter.field)] === value);
|
|
663
|
+
selectedElem = filter.options.find((elem) => elem[removeQuotes(filter.field)] === value);
|
|
721
664
|
if (selectedElem) {
|
|
722
665
|
selectedValue = selectedElem[removeQuotes(filter.field)];
|
|
723
666
|
}
|
|
@@ -733,7 +676,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
733
676
|
}
|
|
734
677
|
if (filter.filterType === 'date' || filter.filterType === 'date_range') {
|
|
735
678
|
if (value && value[2]) {
|
|
736
|
-
selectedElem = filter.options.find(elem => {
|
|
679
|
+
selectedElem = filter.options.find((elem) => {
|
|
737
680
|
return value[2] === elem[removeQuotes(filter.field)][2];
|
|
738
681
|
});
|
|
739
682
|
if (selectedElem) {
|
|
@@ -763,8 +706,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
763
706
|
label: 'Date',
|
|
764
707
|
comparison: true,
|
|
765
708
|
comparisonRange: {
|
|
766
|
-
startDate:
|
|
767
|
-
endDate:
|
|
709
|
+
startDate: COMPARISON_RANGE[key](primaryRange)?.start,
|
|
710
|
+
endDate: COMPARISON_RANGE[key](primaryRange)?.end,
|
|
768
711
|
value: key,
|
|
769
712
|
},
|
|
770
713
|
},
|
|
@@ -788,7 +731,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
788
731
|
}
|
|
789
732
|
}
|
|
790
733
|
};
|
|
791
|
-
|
|
734
|
+
useEffect(() => {
|
|
792
735
|
if (dashboardSections && dashboard) {
|
|
793
736
|
const totalNumberOfItems = Object.values(dashboardSections).reduce((count, arr) => count + arr.length, 0);
|
|
794
737
|
const itemsLoaded = Object.keys(dashboard).length;
|
|
@@ -797,7 +740,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
797
740
|
}
|
|
798
741
|
}
|
|
799
742
|
}, [dashboard, dashboardSections, isLoading]);
|
|
800
|
-
|
|
743
|
+
useEffect(() => {
|
|
801
744
|
if (onChangeLoading) {
|
|
802
745
|
onChangeLoading(isLoading);
|
|
803
746
|
}
|
|
@@ -805,22 +748,21 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
805
748
|
if (!dashboardSections) {
|
|
806
749
|
return null;
|
|
807
750
|
}
|
|
808
|
-
return ((
|
|
751
|
+
return (_jsxs("div", { style: containerStyle, children: [!hideFilters ? (_jsx("div", { style: {
|
|
809
752
|
display: 'flex',
|
|
810
753
|
boxSizing: 'content-box',
|
|
811
754
|
flexDirection: 'row',
|
|
812
755
|
alignItems: 'center',
|
|
813
|
-
}, children: (
|
|
756
|
+
}, children: _jsx("div", { style: {
|
|
814
757
|
width: '100%',
|
|
815
758
|
marginBottom: 25,
|
|
816
759
|
display: 'flex',
|
|
817
760
|
flexDirection: 'row',
|
|
818
761
|
alignItems: 'center',
|
|
819
762
|
gap: 12,
|
|
820
|
-
// paddingLeft: 25,
|
|
821
763
|
}, children: Object.values(dashboardFilters)
|
|
822
|
-
.sort(filter => (filter.filterType === 'date_range' ? -1 : 1))
|
|
823
|
-
.map((filter, index) => ((
|
|
764
|
+
.sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
|
|
765
|
+
.map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
|
|
824
766
|
? FilterDropdownComponent
|
|
825
767
|
: MemoizedDropdown, DateRangePickerComponent: DateRangePickerComponent
|
|
826
768
|
? DateRangePickerComponent
|
|
@@ -829,9 +771,9 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
829
771
|
return a.length - b.length;
|
|
830
772
|
})
|
|
831
773
|
.map((section, sectionIndex) => {
|
|
832
|
-
return ((
|
|
774
|
+
return (_jsxs("div", { style: {
|
|
833
775
|
width: '100%',
|
|
834
|
-
}, children: [(
|
|
776
|
+
}, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && (_jsx("h1", { style: {
|
|
835
777
|
fontSize: 22,
|
|
836
778
|
color: theme.primaryTextColor,
|
|
837
779
|
fontFamily: theme.fontFamily,
|
|
@@ -841,7 +783,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
841
783
|
// marginLeft: 25,
|
|
842
784
|
textAlign: 'left',
|
|
843
785
|
marginTop: 12,
|
|
844
|
-
}, children: section }))] }), dashboardSections[section].filter(elem => elem.chartType === 'metric').length ? ((
|
|
786
|
+
}, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? (_jsx("div", { style: {
|
|
845
787
|
boxSizing: 'content-box',
|
|
846
788
|
width: `100%`,
|
|
847
789
|
listStyleType: 'none',
|
|
@@ -851,7 +793,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
851
793
|
gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
|
|
852
794
|
gridTemplateRows: `repeat(${170}px)`,
|
|
853
795
|
}, children: dashboardSections[section]
|
|
854
|
-
.filter(elem => elem.chartType === 'metric')
|
|
796
|
+
.filter((elem) => elem.chartType === 'metric')
|
|
855
797
|
.sort((a, b) => {
|
|
856
798
|
if (a.order === undefined && b.order === undefined)
|
|
857
799
|
return 0; // both items don't have the 'order' field
|
|
@@ -863,13 +805,13 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
863
805
|
})
|
|
864
806
|
.map((elem, index) => {
|
|
865
807
|
if (DashboardItemComponent) {
|
|
866
|
-
return ((
|
|
808
|
+
return (_jsx("div", { onClick: onClickDashboardItem
|
|
867
809
|
? () => handleOnClickDashboardItem(elem)
|
|
868
|
-
: undefined, children: (
|
|
810
|
+
: undefined, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
|
|
869
811
|
padding: 0,
|
|
870
812
|
// height: '100%',
|
|
871
813
|
boxSizing: 'content-box',
|
|
872
|
-
}, children: (
|
|
814
|
+
}, children: _jsx(Chart, { containerStyle: {
|
|
873
815
|
display: 'flex',
|
|
874
816
|
width: '100%',
|
|
875
817
|
// height: '100%',
|
|
@@ -877,7 +819,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
877
819
|
? theme.chartColors
|
|
878
820
|
: undefined }) }) }) }, elem.name + '' + index));
|
|
879
821
|
}
|
|
880
|
-
return ((
|
|
822
|
+
return (_jsx("div", { onClick: onClickDashboardItem
|
|
881
823
|
? () => handleOnClickDashboardItem(elem)
|
|
882
824
|
: undefined, style: {
|
|
883
825
|
// background: theme.elevatedCardColor,
|
|
@@ -890,22 +832,22 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
890
832
|
cursor: 'pointer',
|
|
891
833
|
width: '100%',
|
|
892
834
|
...metricContainerStyle,
|
|
893
|
-
}, children: (
|
|
835
|
+
}, children: _jsx("div", {
|
|
894
836
|
// className="group-hover:bg-black"
|
|
895
837
|
style: {
|
|
896
838
|
width: '100%',
|
|
897
839
|
boxSizing: 'content-box',
|
|
898
840
|
height: '100%',
|
|
899
|
-
}, children: (
|
|
841
|
+
}, children: _jsx("div", { style: {
|
|
900
842
|
width: '100%',
|
|
901
843
|
boxSizing: 'content-box',
|
|
902
844
|
height: '100%',
|
|
903
|
-
}, children: (
|
|
845
|
+
}, children: _jsxs("div", { style: {
|
|
904
846
|
display: 'flex',
|
|
905
847
|
flexDirection: 'column',
|
|
906
848
|
justifyContent: 'space-between',
|
|
907
849
|
boxSizing: 'content-box',
|
|
908
|
-
}, children: [(
|
|
850
|
+
}, children: [_jsxs("div", {
|
|
909
851
|
// className="group-hover:bg-black"
|
|
910
852
|
style: {
|
|
911
853
|
display: 'flex',
|
|
@@ -916,7 +858,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
916
858
|
// paddingLeft: theme.padding,
|
|
917
859
|
// paddingRight: 25,
|
|
918
860
|
// paddingTop: theme.padding,
|
|
919
|
-
}, children: [(
|
|
861
|
+
}, children: [_jsx("div", { title: elem.name, style: {
|
|
920
862
|
fontFamily: theme.fontFamily,
|
|
921
863
|
color: theme.primaryTextColor,
|
|
922
864
|
boxSizing: 'content-box',
|
|
@@ -934,7 +876,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
934
876
|
display: 'block',
|
|
935
877
|
maxWidth: '100%',
|
|
936
878
|
overflow: 'hidden',
|
|
937
|
-
}, children: elem.name }), onClickDashboardItem ? ((
|
|
879
|
+
}, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
|
|
938
880
|
// className="hover:bg-black"
|
|
939
881
|
style: {
|
|
940
882
|
fontFamily: theme.fontFamily,
|
|
@@ -947,7 +889,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
947
889
|
display: 'flex',
|
|
948
890
|
alignItems: 'center',
|
|
949
891
|
justifyContent: 'flex-end',
|
|
950
|
-
}, children: 'view report →' })) : null] }), (
|
|
892
|
+
}, children: 'view report →' })) : null] }), _jsx("div", { style: { padding: 0, paddingTop: 10 }, children: _jsx(Chart, { containerStyle: {
|
|
951
893
|
// display: 'flex',
|
|
952
894
|
// width: '100%',
|
|
953
895
|
// height: 30,
|
|
@@ -956,7 +898,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
956
898
|
}, isDateFilter: true,
|
|
957
899
|
// chartFilters={elem.chartFilters}
|
|
958
900
|
chartId: elem._id }) })] }) }) }) }, elem.name + '' + index));
|
|
959
|
-
}) })) : null, dashboardSections[section].filter(elem => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? ((
|
|
901
|
+
}) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? (_jsx("div", { style: {
|
|
960
902
|
listStyleType: 'none',
|
|
961
903
|
display: 'grid',
|
|
962
904
|
gridGap: 25,
|
|
@@ -964,7 +906,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
964
906
|
gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
|
|
965
907
|
gridTemplateRows: `repeat(auto-fill, ${rowHeight || 400}px)`,
|
|
966
908
|
}, children: dashboardSections[section]
|
|
967
|
-
.filter(elem => elem.chartType !== 'metric' &&
|
|
909
|
+
.filter((elem) => elem.chartType !== 'metric' &&
|
|
968
910
|
elem.chartType !== 'table')
|
|
969
911
|
.sort((a, b) => {
|
|
970
912
|
if (a.order === undefined && b.order === undefined)
|
|
@@ -977,9 +919,9 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
977
919
|
})
|
|
978
920
|
.map((elem, index) => {
|
|
979
921
|
if (DashboardItemComponent) {
|
|
980
|
-
return ((
|
|
922
|
+
return (_jsx("div", { onClick: onClickDashboardItem
|
|
981
923
|
? () => handleOnClickDashboardItem(elem)
|
|
982
|
-
: undefined, style: { height: rowHeight || 400 }, children: (
|
|
924
|
+
: undefined, style: { height: rowHeight || 400 }, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx(Chart, { containerStyle: {
|
|
983
925
|
display: 'flex',
|
|
984
926
|
width: '100%',
|
|
985
927
|
// height: '100%',
|
|
@@ -990,7 +932,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
990
932
|
? theme.chartColors
|
|
991
933
|
: undefined }) }) }, elem.name + '' + index));
|
|
992
934
|
}
|
|
993
|
-
return ((
|
|
935
|
+
return (_jsx("div", { onClick: onClickDashboardItem
|
|
994
936
|
? () => handleOnClickDashboardItem(elem)
|
|
995
937
|
: undefined, style: {
|
|
996
938
|
height: '100%',
|
|
@@ -1001,26 +943,26 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1001
943
|
borderRadius: 8,
|
|
1002
944
|
paddingTop: 20,
|
|
1003
945
|
...chartContainerStyle,
|
|
1004
|
-
}, children: (
|
|
946
|
+
}, children: _jsx("div", { style: {
|
|
1005
947
|
width: '100%',
|
|
1006
948
|
height: '100%',
|
|
1007
949
|
boxSizing: 'content-box',
|
|
1008
|
-
}, children: (
|
|
950
|
+
}, children: _jsx("div", { style: {
|
|
1009
951
|
width: '100%',
|
|
1010
952
|
height: '100%',
|
|
1011
953
|
boxSizing: 'content-box',
|
|
1012
|
-
}, children: (
|
|
954
|
+
}, children: _jsxs("div", { style: {
|
|
1013
955
|
display: 'flex',
|
|
1014
956
|
flexDirection: 'column',
|
|
1015
957
|
justifyContent: 'space-between',
|
|
1016
958
|
height: '100%',
|
|
1017
959
|
boxSizing: 'content-box',
|
|
1018
|
-
}, children: [(
|
|
960
|
+
}, children: [_jsxs("div", { style: {
|
|
1019
961
|
display: 'flex',
|
|
1020
962
|
flexDirection: 'row',
|
|
1021
963
|
justifyContent: 'space-between',
|
|
1022
964
|
boxSizing: 'content-box',
|
|
1023
|
-
}, children: [(
|
|
965
|
+
}, children: [_jsx("div", { style: {
|
|
1024
966
|
fontFamily: theme.fontFamily,
|
|
1025
967
|
color: theme.primaryTextColor,
|
|
1026
968
|
boxSizing: 'content-box',
|
|
@@ -1033,7 +975,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1033
975
|
display: 'block',
|
|
1034
976
|
maxWidth: '100%',
|
|
1035
977
|
overflow: 'hidden',
|
|
1036
|
-
}, children: elem.name }), onClickDashboardItem ? ((
|
|
978
|
+
}, children: elem.name }), onClickDashboardItem ? (_jsx("div", { style: {
|
|
1037
979
|
fontFamily: theme.fontFamily,
|
|
1038
980
|
color: theme.primaryTextColor,
|
|
1039
981
|
boxSizing: 'content-box',
|
|
@@ -1043,11 +985,11 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1043
985
|
display: 'flex',
|
|
1044
986
|
alignItems: 'center',
|
|
1045
987
|
justifyContent: 'flex-end',
|
|
1046
|
-
}, children: 'view report →' })) : null] }), (
|
|
988
|
+
}, children: 'view report →' })) : null] }), _jsx("div", { style: {
|
|
1047
989
|
padding: 0,
|
|
1048
990
|
height: '100%',
|
|
1049
991
|
boxSizing: 'content-box',
|
|
1050
|
-
}, children: (
|
|
992
|
+
}, children: _jsx(Chart, { containerStyle: {
|
|
1051
993
|
display: 'flex',
|
|
1052
994
|
width: '100%',
|
|
1053
995
|
// TODO: fix fixed height
|
|
@@ -1057,14 +999,14 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1057
999
|
}, isDateFilter: true, chartId: elem._id, colors: theme.chartColors?.length
|
|
1058
1000
|
? theme.chartColors
|
|
1059
1001
|
: undefined }) })] }) }) }) }, elem.name + '' + index));
|
|
1060
|
-
}) })) : null, dashboardSections[section].filter(elem => elem.chartType === 'table').length ? ((
|
|
1002
|
+
}) })) : null, dashboardSections[section].filter((elem) => elem.chartType === 'table').length ? (_jsxs("div", { style: {
|
|
1061
1003
|
boxSizing: 'content-box',
|
|
1062
1004
|
width: `100%`,
|
|
1063
1005
|
gap: 20,
|
|
1064
1006
|
display: 'flex',
|
|
1065
1007
|
flexDirection: 'column',
|
|
1066
|
-
}, children: [(
|
|
1067
|
-
.filter(elem => elem.chartType === 'table')
|
|
1008
|
+
}, children: [_jsx("div", { style: { height: 0 } }), dashboardSections[section]
|
|
1009
|
+
.filter((elem) => elem.chartType === 'table')
|
|
1068
1010
|
.sort((a, b) => {
|
|
1069
1011
|
if (a.order === undefined && b.order === undefined)
|
|
1070
1012
|
return 0; // both items don't have the 'order' field
|
|
@@ -1076,13 +1018,13 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1076
1018
|
})
|
|
1077
1019
|
.map((elem, index) => {
|
|
1078
1020
|
if (DashboardItemComponent) {
|
|
1079
|
-
return ((
|
|
1021
|
+
return (_jsx("div", { onClick: onClickDashboardItem
|
|
1080
1022
|
? () => handleOnClickDashboardItem(elem)
|
|
1081
|
-
: undefined, children: (
|
|
1023
|
+
: undefined, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
|
|
1082
1024
|
padding: 0,
|
|
1083
1025
|
height: '100%',
|
|
1084
1026
|
boxSizing: 'content-box',
|
|
1085
|
-
}, children: (
|
|
1027
|
+
}, children: _jsx(Chart, { containerStyle: {
|
|
1086
1028
|
display: 'flex',
|
|
1087
1029
|
width: '100%',
|
|
1088
1030
|
height: '100%',
|
|
@@ -1090,7 +1032,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1090
1032
|
? theme.chartColors
|
|
1091
1033
|
: undefined }) }) }) }, elem.name + '' + index));
|
|
1092
1034
|
}
|
|
1093
|
-
return ((
|
|
1035
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { onClick: onClickDashboardItem
|
|
1094
1036
|
? () => handleOnClickDashboardItem(elem)
|
|
1095
1037
|
: undefined, style: {
|
|
1096
1038
|
// background: theme.elevatedCardColor,
|
|
@@ -1105,23 +1047,23 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1105
1047
|
minHeight: 420,
|
|
1106
1048
|
height: 420,
|
|
1107
1049
|
// ...metricContainerStyle,
|
|
1108
|
-
}, children: (
|
|
1050
|
+
}, children: _jsx("div", {
|
|
1109
1051
|
// className="group-hover:bg-black"
|
|
1110
1052
|
style: {
|
|
1111
1053
|
width: '100%',
|
|
1112
1054
|
boxSizing: 'content-box',
|
|
1113
1055
|
height: '100%',
|
|
1114
|
-
}, children: (
|
|
1056
|
+
}, children: _jsx("div", { style: {
|
|
1115
1057
|
width: '100%',
|
|
1116
1058
|
boxSizing: 'content-box',
|
|
1117
1059
|
height: '100%',
|
|
1118
|
-
}, children: (
|
|
1060
|
+
}, children: _jsxs("div", { style: {
|
|
1119
1061
|
display: 'flex',
|
|
1120
1062
|
flexDirection: 'column',
|
|
1121
1063
|
justifyContent: 'space-between',
|
|
1122
1064
|
boxSizing: 'content-box',
|
|
1123
1065
|
height: '100%',
|
|
1124
|
-
}, children: [(
|
|
1066
|
+
}, children: [_jsxs("div", {
|
|
1125
1067
|
// className="group-hover:bg-black"
|
|
1126
1068
|
style: {
|
|
1127
1069
|
display: 'flex',
|
|
@@ -1132,7 +1074,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1132
1074
|
// paddingLeft: theme.padding,
|
|
1133
1075
|
paddingRight: 25,
|
|
1134
1076
|
// paddingTop: theme.padding,
|
|
1135
|
-
}, children: [(
|
|
1077
|
+
}, children: [_jsx("div", { title: elem.name, style: {
|
|
1136
1078
|
fontFamily: theme.fontFamily,
|
|
1137
1079
|
color: theme.primaryTextColor,
|
|
1138
1080
|
boxSizing: 'content-box',
|
|
@@ -1151,7 +1093,7 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1151
1093
|
display: 'block',
|
|
1152
1094
|
maxWidth: '100%',
|
|
1153
1095
|
overflow: 'hidden',
|
|
1154
|
-
}, children: elem.name }), onClickDashboardItem ? ((
|
|
1096
|
+
}, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
|
|
1155
1097
|
// className="hover:bg-black"
|
|
1156
1098
|
style: {
|
|
1157
1099
|
fontFamily: theme.fontFamily,
|
|
@@ -1164,10 +1106,10 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1164
1106
|
display: 'flex',
|
|
1165
1107
|
alignItems: 'center',
|
|
1166
1108
|
justifyContent: 'flex-end',
|
|
1167
|
-
}, children: 'view report →' })) : null] }), (
|
|
1109
|
+
}, children: 'view report →' })) : null] }), _jsxs("div", { style: {
|
|
1168
1110
|
padding: 0,
|
|
1169
1111
|
height: '400px',
|
|
1170
|
-
}, children: [(
|
|
1112
|
+
}, children: [_jsx("div", { style: { height: 20 } }), _jsx(Chart, { containerStyle: {
|
|
1171
1113
|
// display: 'flex',
|
|
1172
1114
|
// width: '100%',
|
|
1173
1115
|
// height: 30,
|
|
@@ -1176,11 +1118,10 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
|
|
|
1176
1118
|
// paddingLeft: 25,
|
|
1177
1119
|
}, isDateFilter: true,
|
|
1178
1120
|
// chartFilters={elem.chartFilters}
|
|
1179
|
-
chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), (
|
|
1180
|
-
})] })) : null, (
|
|
1121
|
+
chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), _jsx("div", { style: { height: 40 } })] }));
|
|
1122
|
+
})] })) : null, _jsx("div", { style: { height: 40 } })] }, section + '' + sectionIndex));
|
|
1181
1123
|
})] }));
|
|
1182
1124
|
}
|
|
1183
|
-
exports.default = Dashboard;
|
|
1184
1125
|
// ----------------------------------------------------------------
|
|
1185
1126
|
// REST OF CODE NOT USED
|
|
1186
1127
|
function Filter({ defaultValue, theme, onValueChange, filter }) {
|
|
@@ -1193,23 +1134,23 @@ function Filter({ defaultValue, theme, onValueChange, filter }) {
|
|
|
1193
1134
|
{ value: 'popupbagelsredding', text: 'popupbagelsredding' },
|
|
1194
1135
|
{ value: 'popupbagelsthompson', text: 'popupbagelsthompson' },
|
|
1195
1136
|
];
|
|
1196
|
-
const dropdownRef =
|
|
1197
|
-
const [showDropdown, setShowDropdown] =
|
|
1198
|
-
const [selectedValue, setSelectedValue] =
|
|
1137
|
+
const dropdownRef = useRef(null);
|
|
1138
|
+
const [showDropdown, setShowDropdown] = useState(false);
|
|
1139
|
+
const [selectedValue, setSelectedValue] = useInternalState(defaultValue, undefined);
|
|
1199
1140
|
const selectedDropdownValue = selectedValue ? selectedValue[2] ?? null : null;
|
|
1200
1141
|
const handleDropdownOptionClick = (dropdownValue) => {
|
|
1201
1142
|
setSelectedValue([undefined, undefined, dropdownValue]);
|
|
1202
1143
|
onValueChange?.([undefined, undefined, dropdownValue]);
|
|
1203
1144
|
setShowDropdown(false);
|
|
1204
1145
|
};
|
|
1205
|
-
const [hoveredDropdownValue, handleDropdownKeyDown] =
|
|
1206
|
-
return ((
|
|
1146
|
+
const [hoveredDropdownValue, handleDropdownKeyDown] = useSelectOnKeyDown(handleDropdownOptionClick, dropdownOptions.map((option) => option.value), showDropdown, setShowDropdown, selectedDropdownValue);
|
|
1147
|
+
return (_jsxs("div", { style: { position: 'relative', width: '100%' }, children: [_jsx("div", { style: {
|
|
1207
1148
|
marginBottom: 6,
|
|
1208
1149
|
fontWeight: '600',
|
|
1209
1150
|
color: theme.secondaryTextColor,
|
|
1210
1151
|
fontSize: 14,
|
|
1211
1152
|
fontFamily: theme.fontFamily,
|
|
1212
|
-
}, children: filter.label }), (
|
|
1153
|
+
}, 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 })] }));
|
|
1213
1154
|
}
|
|
1214
1155
|
function removeQuotes(str) {
|
|
1215
1156
|
if (str.startsWith('"') && str.endsWith('"')) {
|
|
@@ -1221,9 +1162,9 @@ function removeQuotes(str) {
|
|
|
1221
1162
|
}
|
|
1222
1163
|
function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDropdownKeyDown, theme, dropdownPlaceholder = 'Select', selectedDropdownValue, dropdownOptions, field, label, }) {
|
|
1223
1164
|
const dropdownText = selectedDropdownValue
|
|
1224
|
-
? String(dropdownOptions.find(option => option[removeQuotes(field)] === selectedDropdownValue)[removeQuotes(label)])
|
|
1165
|
+
? String(dropdownOptions.find((option) => option[removeQuotes(field)] === selectedDropdownValue)[removeQuotes(label)])
|
|
1225
1166
|
: dropdownPlaceholder;
|
|
1226
|
-
return ((
|
|
1167
|
+
return (_jsx("div", { style: {
|
|
1227
1168
|
display: 'flex',
|
|
1228
1169
|
alignItems: 'center',
|
|
1229
1170
|
justifyContent: 'space-between',
|
|
@@ -1231,7 +1172,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
|
|
|
1231
1172
|
background: theme?.backgroundColor,
|
|
1232
1173
|
fontFamily: theme?.fontFamily,
|
|
1233
1174
|
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
1234
|
-
}, children: (
|
|
1175
|
+
}, children: _jsxs("button", { type: "button", style: {
|
|
1235
1176
|
// fontFamily: theme?.fontFamily,
|
|
1236
1177
|
borderColor: theme?.borderColor || '#E5E7EB',
|
|
1237
1178
|
borderStyle: 'solid',
|
|
@@ -1253,7 +1194,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
|
|
|
1253
1194
|
background: theme?.backgroundColor,
|
|
1254
1195
|
fontSize: theme?.fontSizeSmall || '0.875rem',
|
|
1255
1196
|
// fontWeight: theme?.fontWeightMedium || '800',
|
|
1256
|
-
}, ref: dropdownRef, onClick: () => setShowDropdown(!showDropdown), onKeyDown: handleDropdownKeyDown, children: [(
|
|
1197
|
+
}, ref: dropdownRef, onClick: () => setShowDropdown(!showDropdown), onKeyDown: handleDropdownKeyDown, children: [_jsx("p", { style: {
|
|
1257
1198
|
margin: 0,
|
|
1258
1199
|
fontFamily: theme?.fontFamily,
|
|
1259
1200
|
color: theme?.primaryTextColor || '#364153',
|
|
@@ -1262,7 +1203,7 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
|
|
|
1262
1203
|
whiteSpace: 'nowrap',
|
|
1263
1204
|
fontWeight: theme?.fontWeightMedium || '500',
|
|
1264
1205
|
fontSize: theme?.fontSizeSmall || '0.875rem',
|
|
1265
|
-
}, children: dropdownText }), (
|
|
1206
|
+
}, children: dropdownText }), _jsx(ArrowDownHeadIcon, { style: {
|
|
1266
1207
|
height: '1.25rem',
|
|
1267
1208
|
width: '1.25rem',
|
|
1268
1209
|
flex: 'none',
|
|
@@ -1271,8 +1212,8 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
|
|
|
1271
1212
|
}, "aria-hidden": "true" })] }) }));
|
|
1272
1213
|
}
|
|
1273
1214
|
function FilterModal({ setShowDropdown, dropdownRef, showDropdown, theme, selectedDropdownValue, hoveredDropdownValue, dropdownOptions, handleDropdownOptionClick, field, label, }) {
|
|
1274
|
-
return ((
|
|
1215
|
+
return (_jsx(Modal, { showModal: showDropdown, setShowModal: setShowDropdown, parentRef: dropdownRef, theme: theme, children: _jsx(SelectedValueContext.Provider, { value: {
|
|
1275
1216
|
selectedValue: selectedDropdownValue,
|
|
1276
1217
|
handleValueChange: handleDropdownOptionClick,
|
|
1277
|
-
}, children: (
|
|
1218
|
+
}, 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)]))) }) }) }));
|
|
1278
1219
|
}
|