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