@quillsql/react 2.8.7 → 2.8.8
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/Chart.js +132 -99
- package/dist/ChartBuilder.js +89 -80
- package/dist/ChartEditor.js +21 -14
- package/dist/Context.js +57 -52
- package/dist/Dashboard.js +211 -178
- package/dist/Dashboard.js.map +1 -1
- package/dist/DateRangePicker/Calendar.js +46 -41
- package/dist/DateRangePicker/DateRangePicker.js +61 -32
- package/dist/DateRangePicker/DateRangePickerButton.js +17 -14
- package/dist/DateRangePicker/dateRangePickerUtils.js +90 -76
- package/dist/DateRangePicker/dateRangePickerUtils.js.map +1 -1
- 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/Table.js +64 -59
- package/dist/Table.js.map +1 -1
- package/dist/TableChart.js +45 -17
- package/dist/assets/ArrowDownHeadIcon.js +6 -3
- 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/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 -0
- package/dist/components/UiComponents.js +51 -37
- 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/useDashboard.js.map +1 -0
- 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/index.js.map +1 -1
- package/dist/internals/ReportBuilder/PivotList.js +20 -14
- package/dist/internals/ReportBuilder/PivotModal.js +92 -84
- 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/colorToHex.js +5 -1
- package/dist/utils/dataFetcher.js +8 -2
- package/dist/utils/downloadCSV.js +6 -1
- package/package.json +2 -1
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePivotTable = exports.isDateField = exports.generatePivotTableYAxis = exports.PivotModal = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
5
|
// @ts-nocheck
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const Context_1 = require("../../Context");
|
|
8
|
+
const dataFetcher_1 = require("../../utils/dataFetcher");
|
|
9
|
+
const assets_1 = require("../../assets");
|
|
10
|
+
const PivotList_1 = require("./PivotList");
|
|
11
|
+
const date_fns_1 = require("date-fns");
|
|
12
|
+
const Chart_1 = require("../../Chart");
|
|
13
|
+
const ChartBuilder_1 = require("../../ChartBuilder");
|
|
14
|
+
const QuillCard_1 = require("../../components/QuillCard");
|
|
12
15
|
const QuillHover = () => {
|
|
13
|
-
return (
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)("style", { children: `
|
|
14
17
|
.quill-hover {
|
|
15
18
|
background-color: white;
|
|
16
19
|
}
|
|
@@ -22,8 +25,8 @@ const QuillHover = () => {
|
|
|
22
25
|
}
|
|
23
26
|
` }));
|
|
24
27
|
};
|
|
25
|
-
|
|
26
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
28
|
+
const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotValueField, setPivotValueField, pivotAggregation, setPivotAggregation, popUpTitle, setPopUpTitle, selectedTable, SelectComponent, ButtonComponent, PopoverComponent, HeaderComponent, LabelComponent, TextComponent, selectedPivotIndex, setSelectedPivotIndex, removePivot, selectPivot, showUpdatePivot, setShowUpdatePivot, data, columns, theme, isOpen, setIsOpen, dateRange, createdPivots, setCreatedPivots, recommendedPivots, setRecommendedPivots, triggerButtonText = 'Pivot', showPivotEditButton = false, showEditOnPivotClick = true, selectPivotOnEdit = false, showTrigger = true, rightAlign = false, parentRef, }) => {
|
|
29
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
27
30
|
// for testing
|
|
28
31
|
// const [createdPivots, setCreatedPivots] = useState<Pivot[]>([
|
|
29
32
|
// {
|
|
@@ -54,16 +57,16 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
54
57
|
// title: 'sum of amount by created_at and merchant',
|
|
55
58
|
// },
|
|
56
59
|
// ]);
|
|
57
|
-
const [pivotUpdateIndex, setPivotUpdateIndex] = useState(null);
|
|
58
|
-
const [selectedPivotType, setSelectedPivotType] = useState('recommended');
|
|
59
|
-
const [errors, setErrors] = useState([]);
|
|
60
|
-
const [client] = useContext(ClientContext);
|
|
61
|
-
const [divWidth, setDivWidth] = useState(0);
|
|
62
|
-
const editModalRef = useRef();
|
|
60
|
+
const [pivotUpdateIndex, setPivotUpdateIndex] = (0, react_1.useState)(null);
|
|
61
|
+
const [selectedPivotType, setSelectedPivotType] = (0, react_1.useState)('recommended');
|
|
62
|
+
const [errors, setErrors] = (0, react_1.useState)([]);
|
|
63
|
+
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
64
|
+
const [divWidth, setDivWidth] = (0, react_1.useState)(0);
|
|
65
|
+
const editModalRef = (0, react_1.useRef)();
|
|
63
66
|
const calculateWidth = () => {
|
|
64
67
|
return editModalRef.current.offsetWidth;
|
|
65
68
|
};
|
|
66
|
-
useEffect(() => {
|
|
69
|
+
(0, react_1.useEffect)(() => {
|
|
67
70
|
// Measure the width of the div and update state
|
|
68
71
|
if (editModalRef.current) {
|
|
69
72
|
setDivWidth(calculateWidth());
|
|
@@ -80,13 +83,13 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
80
83
|
window.removeEventListener('resize', handleResize);
|
|
81
84
|
};
|
|
82
85
|
}, []);
|
|
83
|
-
useEffect(() => {
|
|
86
|
+
(0, react_1.useEffect)(() => {
|
|
84
87
|
// Measure the width of the div and update state
|
|
85
88
|
if (editModalRef.current) {
|
|
86
89
|
setDivWidth(calculateWidth());
|
|
87
90
|
}
|
|
88
91
|
}, [editModalRef.current, showUpdatePivot]);
|
|
89
|
-
useEffect(() => {
|
|
92
|
+
(0, react_1.useEffect)(() => {
|
|
90
93
|
setSelectedPivotIndex(-1);
|
|
91
94
|
setPivotUpdateIndex(null);
|
|
92
95
|
setSelectedPivotType(undefined);
|
|
@@ -97,7 +100,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
97
100
|
setIsOpen(false);
|
|
98
101
|
setErrors([]);
|
|
99
102
|
}, [selectedTable]);
|
|
100
|
-
const columnsToShow = useMemo(() => {
|
|
103
|
+
const columnsToShow = (0, react_1.useMemo)(() => {
|
|
101
104
|
return (columns || []).reduce((map, col) => {
|
|
102
105
|
// only use columns shown in the report builder's table
|
|
103
106
|
// also filter out id
|
|
@@ -107,7 +110,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
107
110
|
return map;
|
|
108
111
|
}, {});
|
|
109
112
|
}, [columns]);
|
|
110
|
-
const selectedPivotTable = useMemo(() => {
|
|
113
|
+
const selectedPivotTable = (0, react_1.useMemo)(() => {
|
|
111
114
|
if (selectedPivotIndex === -1) {
|
|
112
115
|
return null;
|
|
113
116
|
}
|
|
@@ -119,7 +122,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
119
122
|
columns: columns,
|
|
120
123
|
};
|
|
121
124
|
}, [selectedPivotIndex, data, dateRange, createdPivots]);
|
|
122
|
-
const columnSelectOptions = useMemo(() => {
|
|
125
|
+
const columnSelectOptions = (0, react_1.useMemo)(() => {
|
|
123
126
|
return [
|
|
124
127
|
{ label: 'Select', value: '' },
|
|
125
128
|
...Object.keys(columnsToShow).map(key => {
|
|
@@ -158,7 +161,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
158
161
|
const onEditRecommendedPivot = (pivot, index) => {
|
|
159
162
|
onEditPivot(pivot, null);
|
|
160
163
|
};
|
|
161
|
-
const refreshPivots = useCallback(async () => {
|
|
164
|
+
const refreshPivots = (0, react_1.useCallback)(async () => {
|
|
162
165
|
if (isLoading || Object.keys(columnsToShow).length === 0) {
|
|
163
166
|
return;
|
|
164
167
|
}
|
|
@@ -175,7 +178,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
175
178
|
}, {}),
|
|
176
179
|
};
|
|
177
180
|
try {
|
|
178
|
-
const resp = await getDataFromCloud(client, 'pivotai', cloudBody);
|
|
181
|
+
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, 'pivotai', cloudBody);
|
|
179
182
|
const recommendedPivots = resp?.data?.pivotTables || [];
|
|
180
183
|
// for testing if needed
|
|
181
184
|
// const recommendedPivots = [
|
|
@@ -238,26 +241,26 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
238
241
|
}
|
|
239
242
|
setIsLoading(false);
|
|
240
243
|
}, [selectedTable, data, columnsToShow, isLoading]);
|
|
241
|
-
useEffect(() => {
|
|
244
|
+
(0, react_1.useEffect)(() => {
|
|
242
245
|
if (recommendedPivots.length === 0) {
|
|
243
246
|
refreshPivots();
|
|
244
247
|
}
|
|
245
248
|
}, [refreshPivots]);
|
|
246
|
-
const recommendedPivotTables = useMemo(() => {
|
|
249
|
+
const recommendedPivotTables = (0, react_1.useMemo)(() => {
|
|
247
250
|
const pts = recommendedPivots.map(p => {
|
|
248
251
|
const { rows, columns } = generatePivotTable(p, data, dateRange, 6);
|
|
249
252
|
return { pivot: p, rows, columns };
|
|
250
253
|
});
|
|
251
254
|
return pts;
|
|
252
255
|
}, [recommendedPivots, data]);
|
|
253
|
-
const createdPivotTables = useMemo(() => {
|
|
256
|
+
const createdPivotTables = (0, react_1.useMemo)(() => {
|
|
254
257
|
const pts = createdPivots.map(p => {
|
|
255
258
|
const { rows, columns } = generatePivotTable(p, data, dateRange, 6);
|
|
256
259
|
return { pivot: p, rows, columns };
|
|
257
260
|
});
|
|
258
261
|
return pts;
|
|
259
262
|
}, [createdPivots, data]);
|
|
260
|
-
const samplePivotTable = useMemo(() => {
|
|
263
|
+
const samplePivotTable = (0, react_1.useMemo)(() => {
|
|
261
264
|
if (!pivotAggregation || !pivotRowField) {
|
|
262
265
|
return null;
|
|
263
266
|
}
|
|
@@ -278,15 +281,15 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
278
281
|
pivotColumnField,
|
|
279
282
|
columnsToShow,
|
|
280
283
|
]);
|
|
281
|
-
return (
|
|
284
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column' }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
282
285
|
position: 'relative',
|
|
283
286
|
display: 'inline-block',
|
|
284
287
|
textAlign: 'left',
|
|
285
|
-
}, children: [
|
|
288
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
286
289
|
display: 'flex',
|
|
287
290
|
flexDirection: 'row',
|
|
288
291
|
alignItems: 'center',
|
|
289
|
-
}, children: selectedPivotIndex !== -1 && (
|
|
292
|
+
}, children: selectedPivotIndex !== -1 && ((0, jsx_runtime_1.jsx)("span", { style: {
|
|
290
293
|
height: 10,
|
|
291
294
|
width: 10,
|
|
292
295
|
backgroundColor: theme.primaryButtonColor,
|
|
@@ -294,7 +297,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
294
297
|
position: 'absolute',
|
|
295
298
|
top: -2,
|
|
296
299
|
right: -2,
|
|
297
|
-
} })) }),
|
|
300
|
+
} })) }), (0, jsx_runtime_1.jsx)(PopoverComponent, { onClose: () => {
|
|
298
301
|
setShowUpdatePivot(false);
|
|
299
302
|
setPopUpTitle('Add Pivot');
|
|
300
303
|
}, style: rightAlign ? { right: 0 } : {}, parentRef: parentRef, showTrigger: showTrigger, label: triggerButtonText, isOpen: isOpen, setIsOpen: setIsOpen, onClick: () => {
|
|
@@ -306,53 +309,53 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
306
309
|
refreshPivots();
|
|
307
310
|
}
|
|
308
311
|
setShowUpdatePivot(false);
|
|
309
|
-
}, children:
|
|
312
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { children: showUpdatePivot ? ((0, jsx_runtime_1.jsxs)("div", { className: "ref-in-use", ref: editModalRef, style: {
|
|
310
313
|
backgroundColor: 'rgb(255, 255, 255)',
|
|
311
314
|
display: 'flex',
|
|
312
315
|
flexDirection: 'column',
|
|
313
|
-
}, children: [
|
|
316
|
+
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { children: popUpTitle }), (0, jsx_runtime_1.jsx)("div", { style: { height: 12 } }), (0, jsx_runtime_1.jsx)("div", { style: { width: divWidth }, children: samplePivotTable ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
314
317
|
marginBottom: 20,
|
|
315
318
|
minHeight: 160,
|
|
316
|
-
}, children:
|
|
319
|
+
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: samplePivotTable, theme: theme, index: 0, onSelectPivot: () => { }, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, clickable: false, minHeight: 140, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) })) : ((0, jsx_runtime_1.jsx)("div", { style: { marginBottom: 20, maxWidth: 470 }, children: (0, jsx_runtime_1.jsx)(QuillCard_1.QuillCard, { theme: theme, clickable: false, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
317
320
|
color: theme.secondaryTextColor,
|
|
318
|
-
}, children: "Select a row field and aggregation type to see a preview" }) }) })) }),
|
|
321
|
+
}, children: "Select a row field and aggregation type to see a preview" }) }) })) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
319
322
|
display: 'flex',
|
|
320
323
|
flexDirection: 'column',
|
|
321
324
|
gap: 10,
|
|
322
325
|
alignItems: 'center',
|
|
323
326
|
justifyContent: 'space-between',
|
|
324
|
-
}, children: [
|
|
327
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
325
328
|
display: 'flex',
|
|
326
329
|
flexDirection: 'row',
|
|
327
330
|
gap: 20,
|
|
328
331
|
marginBottom: 5,
|
|
329
|
-
}, children: [
|
|
332
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Row Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: 'Row Field', id: "pivot-row-field", value: pivotRowField, onChange: e => {
|
|
330
333
|
setPivotRowField(e === '' ? undefined : e);
|
|
331
|
-
}, options: columnSelectOptions, theme: theme })] }),
|
|
334
|
+
}, options: columnSelectOptions, theme: theme })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Column Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: 'Column Field', id: "pivot-row-field", value: pivotColumnField, onChange: e => {
|
|
332
335
|
setPivotColumnField(e === '' ? undefined : e);
|
|
333
|
-
}, options: columnSelectOptions, theme: theme })] })] }),
|
|
336
|
+
}, options: columnSelectOptions, theme: theme })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
334
337
|
display: 'flex',
|
|
335
338
|
flexDirection: 'row',
|
|
336
339
|
gap: 20,
|
|
337
340
|
marginBottom: 20,
|
|
338
|
-
}, children: [
|
|
341
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Value Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: 'Value Field', id: "pivot-row-field", value: pivotValueField, onChange: e => {
|
|
339
342
|
setPivotValueField(e === '' ? undefined : e);
|
|
340
343
|
}, options: pivotAggregation === 'count'
|
|
341
344
|
? columnSelectOptions
|
|
342
345
|
: columnSelectOptions.filter(option => {
|
|
343
346
|
return (option.value === '' ||
|
|
344
|
-
numberFormatOptions.includes(columns.find(col => col.field === option.value)?.format));
|
|
345
|
-
}), theme: theme })] }),
|
|
347
|
+
ChartBuilder_1.numberFormatOptions.includes(columns.find(col => col.field === option.value)?.format));
|
|
348
|
+
}), theme: theme })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Aggregation Type" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: 'Aggregation Type', id: "pivot-row-field", value: pivotAggregation, theme: theme, onChange: e => {
|
|
346
349
|
if (e !== 'count' &&
|
|
347
350
|
pivotValueField &&
|
|
348
|
-
!numberFormatOptions.includes(columns.find(col => col.field === pivotValueField)
|
|
351
|
+
!ChartBuilder_1.numberFormatOptions.includes(columns.find(col => col.field === pivotValueField)
|
|
349
352
|
?.format)) {
|
|
350
353
|
setPivotValueField(null);
|
|
351
354
|
}
|
|
352
355
|
setPivotAggregation(e === '' ? undefined : e);
|
|
353
356
|
}, options: ['', 'sum', 'average', 'count'].map(option => {
|
|
354
357
|
return { label: option || 'Select', value: option };
|
|
355
|
-
}) })] })] })] }),
|
|
358
|
+
}) })] })] })] }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "custom-button", onClick: () => {
|
|
356
359
|
const errors = [];
|
|
357
360
|
if (!pivotRowField) {
|
|
358
361
|
errors.push('Row field cannot be empty');
|
|
@@ -379,13 +382,13 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
379
382
|
setPopUpTitle('Add Pivot');
|
|
380
383
|
}
|
|
381
384
|
setErrors(errors);
|
|
382
|
-
}, label: popUpTitle }) }),
|
|
385
|
+
}, label: popUpTitle }) }), (0, jsx_runtime_1.jsx)("div", { children: errors.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
383
386
|
fontSize: 14,
|
|
384
387
|
marginBottom: '6px',
|
|
385
388
|
marginTop: '12px',
|
|
386
389
|
fontWeight: '600',
|
|
387
390
|
color: theme.secondaryTextColor,
|
|
388
|
-
}, children: "Pivot Errors" }), errors.map((error, index) => (
|
|
391
|
+
}, children: "Pivot Errors" }), errors.map((error, index) => ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
389
392
|
borderRadius: 8,
|
|
390
393
|
backgroundColor: '#FF9494',
|
|
391
394
|
paddingLeft: '12px',
|
|
@@ -398,7 +401,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
398
401
|
fontFamily: theme?.fontFamily,
|
|
399
402
|
color: 'white',
|
|
400
403
|
marginBottom: 5,
|
|
401
|
-
}, children: error }, index)))] })) })] })) : (
|
|
404
|
+
}, children: error }, index)))] })) })] })) : ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
402
405
|
display: 'flex',
|
|
403
406
|
flexDirection: 'column',
|
|
404
407
|
fontFamily: theme?.fontFamily,
|
|
@@ -406,20 +409,20 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
406
409
|
width: selectedPivotTable ? 500 : 600,
|
|
407
410
|
maxHeight: 600,
|
|
408
411
|
overflowY: 'scroll',
|
|
409
|
-
}, children: selectedPivotIndex >= 0 ? (
|
|
412
|
+
}, children: selectedPivotIndex >= 0 ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("div", { onClick: () => {
|
|
410
413
|
setPopUpTitle('Edit Pivot');
|
|
411
414
|
onEditPivot(createdPivots[0], 0);
|
|
412
|
-
}, children:
|
|
415
|
+
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: {
|
|
413
416
|
pivot: selectedPivotTable?.pivot,
|
|
414
417
|
rows: selectedPivotTable?.rows,
|
|
415
418
|
columns: selectedPivotTable?.columns,
|
|
416
419
|
}, theme: theme, index: 0, onSelectPivot: () => { }, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, onClose: () => {
|
|
417
420
|
removePivot();
|
|
418
|
-
}, clickable: true, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }) })) : (
|
|
421
|
+
}, clickable: true, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }) })) : ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
419
422
|
fontWeight: '600',
|
|
420
423
|
marginBottom: 5,
|
|
421
424
|
fontSize: 18,
|
|
422
|
-
}, children: "Recommended Pivots" }),
|
|
425
|
+
}, children: "Recommended Pivots" }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { onClick: refreshPivots, style: {
|
|
423
426
|
color: theme?.secondaryTextColor,
|
|
424
427
|
cursor: 'pointer',
|
|
425
428
|
marginTop: 0,
|
|
@@ -434,7 +437,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
434
437
|
paddingTop: 6,
|
|
435
438
|
paddingBottom: 6,
|
|
436
439
|
borderRadius: 5,
|
|
437
|
-
}, className: "quill-hover", children: [
|
|
440
|
+
}, className: "quill-hover", children: [(0, jsx_runtime_1.jsx)(QuillHover, {}), (0, jsx_runtime_1.jsx)(assets_1.RefreshIcon, { style: { marginRight: 5 } }), "Refresh"] }) }), isLoading ? ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
438
441
|
background: theme.backgroundColor,
|
|
439
442
|
width: 250,
|
|
440
443
|
minWidth: 250,
|
|
@@ -445,9 +448,10 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
445
448
|
display: 'flex',
|
|
446
449
|
margin: '0px auto',
|
|
447
450
|
justifyContent: 'center',
|
|
448
|
-
}, children: [
|
|
451
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 100 } }), (0, jsx_runtime_1.jsxs)("svg", { width: "24", height: "24", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "9.375", strokeWidth: "3.75", strokeDasharray: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 2 / 3)", strokeDashoffset: "calc(2 * 3.14 * 9.375 / 6)", stroke: theme?.primaryTextColor || '#364153', fill: "none", transform: "rotate(-90 12 12)", children: (0, jsx_runtime_1.jsx)("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "-180 12 12", to: "180 12 12", dur: "0.8s", repeatCount: "indefinite" }) }), (0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "9.375", strokeWidth: "3.75", strokeDasharray: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 1 / 3)", strokeDashoffset: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 2 / 3)", stroke: '#ADB1B9', fill: "none", transform: "rotate(90 12 12)", children: (0, jsx_runtime_1.jsx)("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "0 12 12", to: "360 12 12", dur: "0.8s", repeatCount: "indefinite" }) })] })] })) : ((0, jsx_runtime_1.jsxs)("div", { children: [recommendedPivotTables.length == 0 && ((0, jsx_runtime_1.jsx)("div", { style: { marginBottom: 20 }, children: "There are currently no recommended pivots available." })), (0, jsx_runtime_1.jsx)(PivotList_1.PivotList, { recommendedPivotTables: recommendedPivotTables, createdPivotTables: createdPivotTables, theme: theme, onSelectRecommendedPivot: onSelectRecommendedPivot, onSelectCreatedPivot: onSelectCreatedPivot, selectedPivotIndex: selectedPivotIndex, selectedPivotType: selectedPivotType, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, onEditRecommendedPivot: onEditRecommendedPivot, onEditCreatedPivot: onEditPivot, showCreatePivot: true, showPivotEditButton: showPivotEditButton, LabelComponent: LabelComponent, TextComponent: TextComponent })] }))] })) })) }) })] }) }));
|
|
449
452
|
};
|
|
450
|
-
|
|
453
|
+
exports.PivotModal = PivotModal;
|
|
454
|
+
function generatePivotTableYAxis(pivot, pivotColumns, format) {
|
|
451
455
|
return pivot.columnField
|
|
452
456
|
? pivotColumns.slice(1).map(col => {
|
|
453
457
|
return {
|
|
@@ -464,8 +468,9 @@ export function generatePivotTableYAxis(pivot, pivotColumns, format) {
|
|
|
464
468
|
},
|
|
465
469
|
];
|
|
466
470
|
}
|
|
471
|
+
exports.generatePivotTableYAxis = generatePivotTableYAxis;
|
|
467
472
|
function generatePivotTitle(pivot) {
|
|
468
|
-
return snakeCaseToTitleCase(`${pivot.aggregationType} of ${pivot.valueField} by ${pivot.rowField}${pivot.columnField ? ` and ${pivot.columnField}` : ''}`);
|
|
473
|
+
return (0, ChartBuilder_1.snakeCaseToTitleCase)(`${pivot.aggregationType} of ${pivot.valueField} by ${pivot.rowField}${pivot.columnField ? ` and ${pivot.columnField}` : ''}`);
|
|
469
474
|
}
|
|
470
475
|
function getDateRange(dateRange, column, data) {
|
|
471
476
|
if (!dateRange || !dateRange[0]) {
|
|
@@ -484,9 +489,9 @@ function getDateRange(dateRange, column, data) {
|
|
|
484
489
|
for (let i = 0; i < data.length; i++) {
|
|
485
490
|
if (data[i][column]) {
|
|
486
491
|
const value = new Date(data[i][column]);
|
|
487
|
-
lastestDate = lastestDate === null ? value : max([lastestDate, value]);
|
|
492
|
+
lastestDate = lastestDate === null ? value : (0, date_fns_1.max)([lastestDate, value]);
|
|
488
493
|
earliestDate =
|
|
489
|
-
earliestDate === null ? value : min([earliestDate, value]);
|
|
494
|
+
earliestDate === null ? value : (0, date_fns_1.min)([earliestDate, value]);
|
|
490
495
|
}
|
|
491
496
|
}
|
|
492
497
|
return { start: earliestDate, end: lastestDate };
|
|
@@ -497,20 +502,20 @@ function getDateRange(dateRange, column, data) {
|
|
|
497
502
|
}
|
|
498
503
|
function getDateBuckets(dateRange, column, data) {
|
|
499
504
|
if (!dateRange || !dateRange[0]) {
|
|
500
|
-
return eachMonthOfInterval(getDateRange(dateRange, column, data));
|
|
505
|
+
return (0, date_fns_1.eachMonthOfInterval)(getDateRange(dateRange, column, data));
|
|
501
506
|
}
|
|
502
|
-
const dayDifference = differenceInDays(new Date(dateRange[1]), new Date(dateRange[0]));
|
|
507
|
+
const dayDifference = (0, date_fns_1.differenceInDays)(new Date(dateRange[1]), new Date(dateRange[0]));
|
|
503
508
|
if (dayDifference < 14) {
|
|
504
|
-
return eachDayOfInterval({ start: dateRange[0], end: dateRange[1] });
|
|
509
|
+
return (0, date_fns_1.eachDayOfInterval)({ start: dateRange[0], end: dateRange[1] });
|
|
505
510
|
}
|
|
506
511
|
else if (dayDifference < 60) {
|
|
507
|
-
return eachWeekOfInterval({ start: dateRange[0], end: dateRange[1] }, { weekStartsOn: 1 });
|
|
512
|
+
return (0, date_fns_1.eachWeekOfInterval)({ start: dateRange[0], end: dateRange[1] }, { weekStartsOn: 1 });
|
|
508
513
|
}
|
|
509
514
|
else if (dayDifference < 365 * 3) {
|
|
510
|
-
return eachMonthOfInterval({ start: dateRange[0], end: dateRange[1] });
|
|
515
|
+
return (0, date_fns_1.eachMonthOfInterval)({ start: dateRange[0], end: dateRange[1] });
|
|
511
516
|
}
|
|
512
517
|
else {
|
|
513
|
-
return eachYearOfInterval({ start: dateRange[0], end: dateRange[1] });
|
|
518
|
+
return (0, date_fns_1.eachYearOfInterval)({ start: dateRange[0], end: dateRange[1] });
|
|
514
519
|
}
|
|
515
520
|
}
|
|
516
521
|
function getDateString(value, dateRange) {
|
|
@@ -519,7 +524,7 @@ function getDateString(value, dateRange) {
|
|
|
519
524
|
format = 'MMM_yyyy';
|
|
520
525
|
}
|
|
521
526
|
else {
|
|
522
|
-
const dayDifference = differenceInDays(new Date(dateRange[1]), new Date(dateRange[0]));
|
|
527
|
+
const dayDifference = (0, date_fns_1.differenceInDays)(new Date(dateRange[1]), new Date(dateRange[0]));
|
|
523
528
|
if (dayDifference < 14) {
|
|
524
529
|
format = 'MMM_dd_yyyy';
|
|
525
530
|
}
|
|
@@ -533,19 +538,20 @@ function getDateString(value, dateRange) {
|
|
|
533
538
|
format = 'yyyy';
|
|
534
539
|
}
|
|
535
540
|
}
|
|
536
|
-
return valueFormatter({
|
|
541
|
+
return (0, Chart_1.valueFormatter)({
|
|
537
542
|
value,
|
|
538
543
|
field: 'date',
|
|
539
544
|
fields: [{ field: 'date', format }],
|
|
540
545
|
});
|
|
541
546
|
}
|
|
542
|
-
|
|
547
|
+
function isDateField(fieldType) {
|
|
543
548
|
return (fieldType === 'date' ||
|
|
544
549
|
fieldType === 'datetime' ||
|
|
545
550
|
fieldType === 'timestamp' ||
|
|
546
551
|
fieldType === 'timestamptz');
|
|
547
552
|
}
|
|
548
|
-
|
|
553
|
+
exports.isDateField = isDateField;
|
|
554
|
+
function generatePivotTable(pivot, data, dateRange, rowLimit = -1) {
|
|
549
555
|
const pivotRows = [];
|
|
550
556
|
const uniqueRows = isDateField(pivot.rowFieldType)
|
|
551
557
|
? getDateBuckets(dateRange, pivot.rowField, data)
|
|
@@ -581,23 +587,23 @@ export function generatePivotTable(pivot, data, dateRange, rowLimit = -1) {
|
|
|
581
587
|
let filteredData;
|
|
582
588
|
let value;
|
|
583
589
|
const nextRowValue = isDateField(pivot.rowFieldType)
|
|
584
|
-
? uniqueRows[rowIndex + 1] || endOfDay(rowDateRange.end)
|
|
590
|
+
? uniqueRows[rowIndex + 1] || (0, date_fns_1.endOfDay)(rowDateRange.end)
|
|
585
591
|
: null;
|
|
586
592
|
if (pivot.columnField) {
|
|
587
593
|
const nextColumnValue = isDateField(pivot.columnFieldType)
|
|
588
|
-
? uniqueColumns[colIndex + 1] || endOfDay(columnDateRange.end)
|
|
594
|
+
? uniqueColumns[colIndex + 1] || (0, date_fns_1.endOfDay)(columnDateRange.end)
|
|
589
595
|
: null;
|
|
590
596
|
// If columnField is provided, filter by both rowField and columnField
|
|
591
597
|
if (isDateField(pivot.columnFieldType) &&
|
|
592
598
|
isDateField(pivot.rowFieldType)) {
|
|
593
599
|
filteredData = data.filter((item) => {
|
|
594
|
-
return (isWithinInterval(new Date(item[pivot.rowField]), {
|
|
600
|
+
return ((0, date_fns_1.isWithinInterval)(new Date(item[pivot.rowField]), {
|
|
595
601
|
start: rowValue,
|
|
596
|
-
end: subMilliseconds(nextRowValue, 1),
|
|
602
|
+
end: (0, date_fns_1.subMilliseconds)(nextRowValue, 1),
|
|
597
603
|
}) &&
|
|
598
|
-
isWithinInterval(new Date(item[pivot.columnField]), {
|
|
604
|
+
(0, date_fns_1.isWithinInterval)(new Date(item[pivot.columnField]), {
|
|
599
605
|
start: colValue,
|
|
600
|
-
end: subMilliseconds(nextColumnValue, 1),
|
|
606
|
+
end: (0, date_fns_1.subMilliseconds)(nextColumnValue, 1),
|
|
601
607
|
}));
|
|
602
608
|
});
|
|
603
609
|
}
|
|
@@ -605,18 +611,18 @@ export function generatePivotTable(pivot, data, dateRange, rowLimit = -1) {
|
|
|
605
611
|
!isDateField(pivot.rowFieldType)) {
|
|
606
612
|
filteredData = data.filter((item) => {
|
|
607
613
|
return (item[pivot.rowField] === rowValue &&
|
|
608
|
-
isWithinInterval(new Date(item[pivot.columnField]), {
|
|
614
|
+
(0, date_fns_1.isWithinInterval)(new Date(item[pivot.columnField]), {
|
|
609
615
|
start: colValue,
|
|
610
|
-
end: subMilliseconds(nextColumnValue, 1),
|
|
616
|
+
end: (0, date_fns_1.subMilliseconds)(nextColumnValue, 1),
|
|
611
617
|
}));
|
|
612
618
|
});
|
|
613
619
|
}
|
|
614
620
|
else if (!isDateField(pivot.columnFieldType) &&
|
|
615
621
|
isDateField(pivot.rowFieldType)) {
|
|
616
622
|
filteredData = data.filter((item) => {
|
|
617
|
-
return (isWithinInterval(new Date(item[pivot.rowField]), {
|
|
623
|
+
return ((0, date_fns_1.isWithinInterval)(new Date(item[pivot.rowField]), {
|
|
618
624
|
start: rowValue,
|
|
619
|
-
end: subMilliseconds(nextRowValue, 1),
|
|
625
|
+
end: (0, date_fns_1.subMilliseconds)(nextRowValue, 1),
|
|
620
626
|
}) && item[pivot.columnField || ''] === colValue);
|
|
621
627
|
});
|
|
622
628
|
}
|
|
@@ -631,9 +637,9 @@ export function generatePivotTable(pivot, data, dateRange, rowLimit = -1) {
|
|
|
631
637
|
// If columnField is not provided, filter by rowField only
|
|
632
638
|
filteredData = isDateField(pivot.rowFieldType)
|
|
633
639
|
? data.filter(item => {
|
|
634
|
-
return isWithinInterval(new Date(item[pivot.rowField]), {
|
|
640
|
+
return (0, date_fns_1.isWithinInterval)(new Date(item[pivot.rowField]), {
|
|
635
641
|
start: rowValue,
|
|
636
|
-
end: subMilliseconds(nextRowValue, 1),
|
|
642
|
+
end: (0, date_fns_1.subMilliseconds)(nextRowValue, 1),
|
|
637
643
|
});
|
|
638
644
|
})
|
|
639
645
|
: data.filter(item => item[pivot.rowField] === rowValue);
|
|
@@ -680,9 +686,11 @@ export function generatePivotTable(pivot, data, dateRange, rowLimit = -1) {
|
|
|
680
686
|
!pivot.columnField &&
|
|
681
687
|
index === 1
|
|
682
688
|
? 'Count'
|
|
683
|
-
: snakeCaseToTitleCase(columnName),
|
|
689
|
+
: (0, ChartBuilder_1.snakeCaseToTitleCase)(columnName),
|
|
684
690
|
field: columnName,
|
|
685
691
|
};
|
|
686
692
|
}),
|
|
687
693
|
};
|
|
688
694
|
}
|
|
695
|
+
exports.generatePivotTable = generatePivotTable;
|
|
696
|
+
//# sourceMappingURL=PivotModal.js.map
|