@quillsql/react 2.8.4 → 2.8.6

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