@quillsql/react 2.8.7 → 2.8.9

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 (59) hide show
  1. package/dist/BarList.js +1 -1
  2. package/dist/Chart.d.ts +0 -5
  3. package/dist/Chart.d.ts.map +1 -1
  4. package/dist/Chart.js +19 -168
  5. package/dist/ChartBuilder.d.ts +1 -0
  6. package/dist/ChartBuilder.d.ts.map +1 -1
  7. package/dist/ChartBuilder.js +18 -6
  8. package/dist/ChartEditor.d.ts +2 -1
  9. package/dist/ChartEditor.d.ts.map +1 -1
  10. package/dist/ChartEditor.js +2 -2
  11. package/dist/Dashboard.d.ts.map +1 -1
  12. package/dist/Dashboard.js +7 -6
  13. package/dist/Dashboard.js.map +1 -1
  14. package/dist/DateRangePicker/DateRangePicker.d.ts.map +1 -1
  15. package/dist/DateRangePicker/DateRangePicker.js +1 -1
  16. package/dist/DateRangePicker/dateRangePickerUtils.js.map +1 -1
  17. package/dist/SQLEditor.d.ts +5 -1
  18. package/dist/SQLEditor.d.ts.map +1 -1
  19. package/dist/SQLEditor.js +34 -32
  20. package/dist/Table.d.ts.map +1 -1
  21. package/dist/Table.js +7 -4
  22. package/dist/Table.js.map +1 -1
  23. package/dist/TableChart.js +1 -1
  24. package/dist/assets/ArrowDownHeadIcon.js +2 -2
  25. package/dist/components/Banner/index.d.ts +3 -0
  26. package/dist/components/Banner/index.d.ts.map +1 -0
  27. package/dist/components/Banner/index.js +24 -0
  28. package/dist/components/ReportBuilder/ColumnSelector.d.ts +19 -0
  29. package/dist/components/ReportBuilder/ColumnSelector.d.ts.map +1 -0
  30. package/dist/components/ReportBuilder/ColumnSelector.js +87 -0
  31. package/dist/components/SqlTextEditor.d.ts.map +1 -1
  32. package/dist/components/SqlTextEditor.js +27 -3
  33. package/dist/components/SqlTextEditor.js.map +1 -0
  34. package/dist/components/UiComponents.d.ts.map +1 -1
  35. package/dist/components/UiComponents.js +7 -6
  36. package/dist/hooks/useDashboard.js.map +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/internals/ReportBuilder/PivotModal.d.ts +2 -2
  39. package/dist/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
  40. package/dist/internals/ReportBuilder/PivotModal.js +40 -35
  41. package/dist/test-data/tables.d.ts +2 -0
  42. package/dist/test-data/tables.d.ts.map +1 -0
  43. package/dist/test-data/tables.js +621 -0
  44. package/dist/utils/axisFormatter.d.ts +20 -0
  45. package/dist/utils/axisFormatter.d.ts.map +1 -0
  46. package/dist/utils/axisFormatter.js +185 -0
  47. package/dist/utils/schema.d.ts +22 -0
  48. package/dist/utils/schema.d.ts.map +1 -0
  49. package/dist/utils/schema.js +134 -0
  50. package/dist/utils/textFormatting.d.ts +4 -0
  51. package/dist/utils/textFormatting.d.ts.map +1 -0
  52. package/dist/utils/textFormatting.js +38 -0
  53. package/dist/utils/valueFormatter.d.ts +17 -0
  54. package/dist/utils/valueFormatter.d.ts.map +1 -0
  55. package/dist/utils/valueFormatter.js +166 -0
  56. package/dist/utils/valueFormatterCSV.d.ts +17 -0
  57. package/dist/utils/valueFormatterCSV.d.ts.map +1 -0
  58. package/dist/utils/valueFormatterCSV.js +90 -0
  59. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ import { endOfWeek, format, getWeek, isValid, startOfWeek } from 'date-fns';
2
+ import { utcToZonedTime } from 'date-fns-tz';
3
+ /**
4
+ * Formats a value to CSV-format.
5
+ */
6
+ export const valueFormatterCSV = ({ value, field, fields, }) => {
7
+ if (field === undefined || field === null)
8
+ return '';
9
+ if (value === undefined || value === null)
10
+ return '';
11
+ const fieldInfo = fields.find((f) => f.field === field);
12
+ if (!fieldInfo)
13
+ return '';
14
+ const HANDLERS = {
15
+ percent: formatPercent,
16
+ dollar_amount: formatDollarAmount,
17
+ dollar_cents: formatDollarCents,
18
+ whole_number: formatWholeNumber,
19
+ one_decimal_place: formatOneDecimalPlace,
20
+ two_decimal_places: formatTwoDecimalPlaces,
21
+ string: formatString,
22
+ yyyy: format_YYYY,
23
+ MMM_yyyy: format_MMM_yyyy,
24
+ MMM_dd_yyyy: format_MMM_dd_yyyy,
25
+ hh_ap_pm: format_hh_ap_pm,
26
+ 'MMM_dd-MMM_dd': format_MMM_dd_MMM_dd,
27
+ 'MMM_dd_hh:mm_ap_pm': format_MMM_dd_hh_mm_ap_pm,
28
+ 'wo, yyyy': format_wo_yyyy,
29
+ };
30
+ // try to handle this value using the associated formatType handler
31
+ const formatType = fieldInfo.format;
32
+ if (Object.keys(HANDLERS).includes(formatType)) {
33
+ return HANDLERS[formatType](value);
34
+ }
35
+ return value.toString(); // by default make this value a string
36
+ };
37
+ /**
38
+ * HELPER FUNCTION DEFINITIONS
39
+ */
40
+ const formatString = (value) => value.toString();
41
+ const formatDollarAmount = (value) => Number(value ?? 0);
42
+ const formatDollarCents = (value) => Number(value ?? 0);
43
+ const formatWholeNumber = (value) => Math.round(Number(value));
44
+ const formatOneDecimalPlace = (value) => Number(value).toFixed(1);
45
+ const formatTwoDecimalPlaces = (value) => Number(value).toFixed(2);
46
+ const formatPercent = (value) => {
47
+ const absoluteValue = isNaN(Number(value)) ? 0 : Math.abs(Number(value));
48
+ if (absoluteValue < 1.0) {
49
+ return Number(value);
50
+ }
51
+ return Number(value) / 100.0;
52
+ };
53
+ const _getUTCDateHelper = (value, fmt) => {
54
+ const utcDate = utcToZonedTime(new Date(value), 'UTC');
55
+ if (!isValid(utcDate))
56
+ return 'Invalid date';
57
+ return format(utcDate, fmt);
58
+ };
59
+ const format_YYYY = (value) => _getUTCDateHelper(value, 'yyyy');
60
+ const format_MMM_yyyy = (value) => _getUTCDateHelper(value, 'MMM yyyy');
61
+ const format_hh_ap_pm = (value) => _getUTCDateHelper(value, 'hh:mm aa');
62
+ const format_MMM_dd_yyyy = (value) => _getUTCDateHelper(value, 'dd MMM yyyy');
63
+ const format_MMM_dd_MMM_dd = (value) => {
64
+ const utcDate = utcToZonedTime(new Date(value), 'UTC');
65
+ if (!isValid(utcDate))
66
+ return 'Invalid date';
67
+ const monday = startOfWeek(utcDate, { weekStartsOn: 1 });
68
+ const sunday = endOfWeek(utcDate, { weekStartsOn: 1 });
69
+ // Check if start and end are in the same month
70
+ if (format(monday, 'MMM') === format(sunday, 'MMM')) {
71
+ return `${format(monday, 'MMM dd')} - ${format(sunday, 'dd')}`;
72
+ }
73
+ else {
74
+ return `${format(monday, 'MMM dd')} - ${format(sunday, 'MMM dd')}`;
75
+ }
76
+ };
77
+ const format_MMM_dd_hh_mm_ap_pm = (value) => {
78
+ const utcDate = utcToZonedTime(new Date(value), 'UTC');
79
+ if (!isValid(utcDate))
80
+ return 'Invalid date';
81
+ const formatStr = utcDate.getMinutes() === 0 ? 'MMM do h a' : 'MMM do h:mm a';
82
+ const res = format(utcDate, formatStr);
83
+ return res.slice(0, -2) + res.slice(-2).toLowerCase();
84
+ };
85
+ const format_wo_yyyy = (value) => {
86
+ const utcDate = utcToZonedTime(new Date(value), 'UTC');
87
+ if (!isValid(utcDate))
88
+ return 'Invalid date';
89
+ return `${getWeek(utcDate)},${utcDate.getFullYear()}`;
90
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.8.7",
3
+ "version": "2.8.9",
4
4
  "description": "Quill React components for building dashboards and reporting.",
5
5
  "main": "dist/index.js",
6
6
  "files": [