@quillsql/react 2.10.27 → 2.10.29
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/cjs/Chart.js +5 -4
- package/dist/cjs/Dashboard.d.ts +3 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +3 -10
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +1 -5
- package/dist/cjs/SQLEditor.d.ts +1 -5
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +5 -10
- package/dist/cjs/components/Chart/ChartSkeleton.d.ts +4 -1
- package/dist/cjs/components/Chart/ChartSkeleton.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +7 -2
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +28 -57
- package/dist/cjs/components/QuillTable.d.ts +3 -0
- package/dist/cjs/components/QuillTable.d.ts.map +1 -0
- package/dist/cjs/{Table.js → components/QuillTable.js} +53 -224
- package/dist/cjs/components/UiComponents.d.ts +8 -2
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +3 -1
- package/dist/cjs/hooks/useFormat.d.ts +3 -1
- package/dist/cjs/hooks/useFormat.d.ts.map +1 -1
- package/dist/cjs/hooks/useFormat.js +13 -12
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/utils/valueFormatter.d.ts +5 -0
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatter.js +59 -30
- package/dist/esm/Chart.js +5 -4
- package/dist/esm/Dashboard.d.ts +3 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +3 -10
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +1 -5
- package/dist/esm/SQLEditor.d.ts +1 -5
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +5 -10
- package/dist/esm/components/Chart/ChartSkeleton.d.ts +4 -1
- package/dist/esm/components/Chart/ChartSkeleton.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +9 -4
- package/dist/esm/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +25 -57
- package/dist/esm/components/QuillTable.d.ts +3 -0
- package/dist/esm/components/QuillTable.d.ts.map +1 -0
- package/dist/esm/{Table.js → components/QuillTable.js} +52 -222
- package/dist/esm/components/UiComponents.d.ts +8 -2
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +1 -0
- package/dist/esm/hooks/useFormat.d.ts +3 -1
- package/dist/esm/hooks/useFormat.d.ts.map +1 -1
- package/dist/esm/hooks/useFormat.js +13 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/valueFormatter.d.ts +5 -0
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatter.js +57 -29
- package/package.json +1 -1
- package/dist/cjs/Table.d.ts +0 -39
- package/dist/cjs/Table.d.ts.map +0 -1
- package/dist/esm/Table.d.ts +0 -39
- package/dist/esm/Table.d.ts.map +0 -1
|
@@ -50,6 +50,8 @@ export const valueFormatter = ({ value, field, fields }) => {
|
|
|
50
50
|
return formatString(value); // by default make this value a string
|
|
51
51
|
};
|
|
52
52
|
export const quillFormat = ({ value, format, }) => {
|
|
53
|
+
if (value === undefined || value === null)
|
|
54
|
+
return '';
|
|
53
55
|
const HANDLERS = {
|
|
54
56
|
percent: formatPercent,
|
|
55
57
|
dollar_amount: formatDollarAmount,
|
|
@@ -68,7 +70,7 @@ export const quillFormat = ({ value, format, }) => {
|
|
|
68
70
|
};
|
|
69
71
|
// try to handle this value using the associated formatType handler
|
|
70
72
|
const formatType = format;
|
|
71
|
-
if (
|
|
73
|
+
if (HANDLERS[formatType]) {
|
|
72
74
|
// if bigquery date type, we have to pull the value out of the json
|
|
73
75
|
if (DATE_FORMAT_TYPES.includes(formatType) &&
|
|
74
76
|
typeof value === 'object' &&
|
|
@@ -96,38 +98,38 @@ const formatString = (value) => {
|
|
|
96
98
|
*
|
|
97
99
|
* eg. @example format(1234.567) => "$1,235"
|
|
98
100
|
*/
|
|
101
|
+
const formatterDollar = new Intl.NumberFormat('en-US', {
|
|
102
|
+
style: 'currency',
|
|
103
|
+
currency: 'USD',
|
|
104
|
+
maximumFractionDigits: 0,
|
|
105
|
+
});
|
|
99
106
|
const formatDollarAmount = (value) => {
|
|
100
|
-
|
|
101
|
-
style: 'currency',
|
|
102
|
-
currency: 'USD',
|
|
103
|
-
maximumFractionDigits: 0,
|
|
104
|
-
});
|
|
105
|
-
return formatter.format(Number(value ?? 0));
|
|
107
|
+
return formatterDollar.format(Number(value ?? 0));
|
|
106
108
|
};
|
|
107
109
|
/**
|
|
108
110
|
* Formats the value as a (rounded) currency amount in dollars and cents.
|
|
109
111
|
*
|
|
110
112
|
* @example format(1234.567) => "$1,234.57"
|
|
111
113
|
*/
|
|
114
|
+
const formatterCentsDollar = new Intl.NumberFormat('en-US', {
|
|
115
|
+
style: 'currency',
|
|
116
|
+
currency: 'USD',
|
|
117
|
+
minimumFractionDigits: 2,
|
|
118
|
+
maximumFractionDigits: 2,
|
|
119
|
+
});
|
|
112
120
|
const formatDollarCents = (value) => {
|
|
113
|
-
|
|
114
|
-
style: 'currency',
|
|
115
|
-
currency: 'USD',
|
|
116
|
-
minimumFractionDigits: 2,
|
|
117
|
-
maximumFractionDigits: 2,
|
|
118
|
-
});
|
|
119
|
-
return formatter.format(Number(value ?? 0));
|
|
121
|
+
return formatterCentsDollar.format(Number(value ?? 0));
|
|
120
122
|
};
|
|
121
123
|
/**
|
|
122
124
|
* Formats the value as a (rounded) integer.
|
|
123
125
|
*
|
|
124
126
|
* @example format(1234.567) => "1,235"
|
|
125
127
|
*/
|
|
128
|
+
const wholeNumberFormatter = new Intl.NumberFormat('en-US', {
|
|
129
|
+
maximumFractionDigits: 0,
|
|
130
|
+
});
|
|
126
131
|
const formatWholeNumber = (value) => {
|
|
127
|
-
|
|
128
|
-
maximumFractionDigits: 0,
|
|
129
|
-
});
|
|
130
|
-
return formatter.format(Number(value));
|
|
132
|
+
return wholeNumberFormatter.format(Number(value));
|
|
131
133
|
};
|
|
132
134
|
/**
|
|
133
135
|
* Formats the value as a number rounded to exactly one decimal place.
|
|
@@ -146,12 +148,12 @@ const formatOneDecimalPlace = (value) => {
|
|
|
146
148
|
*
|
|
147
149
|
* @example format(1234.567) => "1,234.57"
|
|
148
150
|
*/
|
|
151
|
+
const formatterTwoDecimalPlaces = new Intl.NumberFormat('en-US', {
|
|
152
|
+
minimumFractionDigits: 2,
|
|
153
|
+
maximumFractionDigits: 2,
|
|
154
|
+
});
|
|
149
155
|
const formatTwoDecimalPlaces = (value) => {
|
|
150
|
-
|
|
151
|
-
minimumFractionDigits: 2,
|
|
152
|
-
maximumFractionDigits: 2,
|
|
153
|
-
});
|
|
154
|
-
return formatter.format(Number(value));
|
|
156
|
+
return formatterTwoDecimalPlaces.format(Number(value));
|
|
155
157
|
};
|
|
156
158
|
/**
|
|
157
159
|
* Formats the value as a percentage.
|
|
@@ -166,13 +168,13 @@ const formatTwoDecimalPlaces = (value) => {
|
|
|
166
168
|
* @example format(1234.567) => "123,456.70%"
|
|
167
169
|
* @example format(99) => "9,900.00%"
|
|
168
170
|
*/
|
|
171
|
+
const formatterPercent = new Intl.NumberFormat('en-US', {
|
|
172
|
+
style: 'percent',
|
|
173
|
+
minimumFractionDigits: 2,
|
|
174
|
+
maximumFractionDigits: 2,
|
|
175
|
+
});
|
|
169
176
|
const formatPercent = (value) => {
|
|
170
|
-
|
|
171
|
-
style: 'percent',
|
|
172
|
-
minimumFractionDigits: 2,
|
|
173
|
-
maximumFractionDigits: 2,
|
|
174
|
-
});
|
|
175
|
-
return formatter.format(Number(value));
|
|
177
|
+
return formatterPercent.format(Number(value));
|
|
176
178
|
};
|
|
177
179
|
// Converts the value to a UTC date with the given format string. If the
|
|
178
180
|
// resulting date is invalid, it returns "Invalid date".
|
|
@@ -216,3 +218,29 @@ const format_wo_yyyy = (value) => {
|
|
|
216
218
|
return 'Invalid date';
|
|
217
219
|
return `${getWeek(utcDate)},${utcDate.getFullYear()}`;
|
|
218
220
|
};
|
|
221
|
+
export const compareValues = (a, b, column) => {
|
|
222
|
+
const valueA = a[column];
|
|
223
|
+
const valueB = b[column];
|
|
224
|
+
// Null checks
|
|
225
|
+
if (valueA === null && valueB === null) {
|
|
226
|
+
return 0; // Both values are null, consider them equal
|
|
227
|
+
}
|
|
228
|
+
else if (valueA === null) {
|
|
229
|
+
return -1; // ValueA is null, consider it smaller
|
|
230
|
+
}
|
|
231
|
+
else if (valueB === null) {
|
|
232
|
+
return 1; // ValueB is null, consider it smaller
|
|
233
|
+
}
|
|
234
|
+
// For numbers
|
|
235
|
+
if (!isNaN(valueA) && !isNaN(valueB)) {
|
|
236
|
+
return valueA - valueB;
|
|
237
|
+
}
|
|
238
|
+
// For dates
|
|
239
|
+
const dateA = new Date(valueA);
|
|
240
|
+
const dateB = new Date(valueB);
|
|
241
|
+
if (!isNaN(dateA.getTime()) && !isNaN(dateB.getTime())) {
|
|
242
|
+
return dateA.getTime() - dateB.getTime();
|
|
243
|
+
}
|
|
244
|
+
// For strings
|
|
245
|
+
return valueA.localeCompare(valueB);
|
|
246
|
+
};
|
package/package.json
CHANGED
package/dist/cjs/Table.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface TableColumn {
|
|
3
|
-
label: string;
|
|
4
|
-
field: string;
|
|
5
|
-
}
|
|
6
|
-
interface ChartIdTableProps {
|
|
7
|
-
chartId: string;
|
|
8
|
-
containerStyle?: React.CSSProperties;
|
|
9
|
-
csvFilename?: string;
|
|
10
|
-
}
|
|
11
|
-
interface DataTableProps {
|
|
12
|
-
columns: TableColumn[];
|
|
13
|
-
rows: object[];
|
|
14
|
-
containerStyle?: React.CSSProperties;
|
|
15
|
-
csvFilename?: string;
|
|
16
|
-
showDownloadCsvButton?: boolean;
|
|
17
|
-
LoadingComponent?: () => JSX.Element;
|
|
18
|
-
loading?: boolean;
|
|
19
|
-
height?: string;
|
|
20
|
-
}
|
|
21
|
-
declare const Table: ({ chartId, columns, rows, containerStyle, csvFilename, showDownloadCsvButton, LoadingComponent, loading, height, }: ChartIdTableProps | DataTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
interface TableButtonComponentProps {
|
|
23
|
-
onClick: () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare function SpecialTable({ columns, rows, height, containerStyle, loading, LoadingComponent, theme, showDownloadCsvButton, csvFilename, DownloadCSVButtonComponent, AddToDashboardButtonComponent, }: {
|
|
26
|
-
columns: any[];
|
|
27
|
-
rows: any[];
|
|
28
|
-
height: string;
|
|
29
|
-
containerStyle?: React.CSSProperties;
|
|
30
|
-
loading?: boolean;
|
|
31
|
-
LoadingComponent?: () => JSX.Element;
|
|
32
|
-
theme?: any;
|
|
33
|
-
showDownloadCsvButton?: boolean;
|
|
34
|
-
csvFilename?: string;
|
|
35
|
-
DownloadCSVButtonComponent?: (props: TableButtonComponentProps) => JSX.Element;
|
|
36
|
-
AddToDashboardButtonComponent?: (props: TableButtonComponentProps) => JSX.Element;
|
|
37
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
-
export default Table;
|
|
39
|
-
//# sourceMappingURL=Table.d.ts.map
|
package/dist/cjs/Table.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAexE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,KAAK,uHAUR,iBAAiB,GAAG,cAAc,4CAqCpC,CAAC;AAEF,UAAU,yBAAyB;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAkCD,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,IAAI,EACJ,MAAM,EACN,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,KAAK,EACL,qBAA4B,EAC5B,WAAW,EACX,0BAA0B,EAC1B,6BAA6B,GAC9B,EAAE;IACD,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IACrC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,CAAC,EAAE,CAC3B,KAAK,EAAE,yBAAyB,KAC7B,GAAG,CAAC,OAAO,CAAC;IACjB,6BAA6B,CAAC,EAAE,CAC9B,KAAK,EAAE,yBAAyB,KAC7B,GAAG,CAAC,OAAO,CAAC;CAClB,kDAqhBA;AA6MD,eAAe,KAAK,CAAC"}
|
package/dist/esm/Table.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface TableColumn {
|
|
3
|
-
label: string;
|
|
4
|
-
field: string;
|
|
5
|
-
}
|
|
6
|
-
interface ChartIdTableProps {
|
|
7
|
-
chartId: string;
|
|
8
|
-
containerStyle?: React.CSSProperties;
|
|
9
|
-
csvFilename?: string;
|
|
10
|
-
}
|
|
11
|
-
interface DataTableProps {
|
|
12
|
-
columns: TableColumn[];
|
|
13
|
-
rows: object[];
|
|
14
|
-
containerStyle?: React.CSSProperties;
|
|
15
|
-
csvFilename?: string;
|
|
16
|
-
showDownloadCsvButton?: boolean;
|
|
17
|
-
LoadingComponent?: () => JSX.Element;
|
|
18
|
-
loading?: boolean;
|
|
19
|
-
height?: string;
|
|
20
|
-
}
|
|
21
|
-
declare const Table: ({ chartId, columns, rows, containerStyle, csvFilename, showDownloadCsvButton, LoadingComponent, loading, height, }: ChartIdTableProps | DataTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
interface TableButtonComponentProps {
|
|
23
|
-
onClick: () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare function SpecialTable({ columns, rows, height, containerStyle, loading, LoadingComponent, theme, showDownloadCsvButton, csvFilename, DownloadCSVButtonComponent, AddToDashboardButtonComponent, }: {
|
|
26
|
-
columns: any[];
|
|
27
|
-
rows: any[];
|
|
28
|
-
height: string;
|
|
29
|
-
containerStyle?: React.CSSProperties;
|
|
30
|
-
loading?: boolean;
|
|
31
|
-
LoadingComponent?: () => JSX.Element;
|
|
32
|
-
theme?: any;
|
|
33
|
-
showDownloadCsvButton?: boolean;
|
|
34
|
-
csvFilename?: string;
|
|
35
|
-
DownloadCSVButtonComponent?: (props: TableButtonComponentProps) => JSX.Element;
|
|
36
|
-
AddToDashboardButtonComponent?: (props: TableButtonComponentProps) => JSX.Element;
|
|
37
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
-
export default Table;
|
|
39
|
-
//# sourceMappingURL=Table.d.ts.map
|
package/dist/esm/Table.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAexE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,KAAK,uHAUR,iBAAiB,GAAG,cAAc,4CAqCpC,CAAC;AAEF,UAAU,yBAAyB;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAkCD,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,IAAI,EACJ,MAAM,EACN,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,KAAK,EACL,qBAA4B,EAC5B,WAAW,EACX,0BAA0B,EAC1B,6BAA6B,GAC9B,EAAE;IACD,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IACrC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,CAAC,EAAE,CAC3B,KAAK,EAAE,yBAAyB,KAC7B,GAAG,CAAC,OAAO,CAAC;IACjB,6BAA6B,CAAC,EAAE,CAC9B,KAAK,EAAE,yBAAyB,KAC7B,GAAG,CAAC,OAAO,CAAC;CAClB,kDAqhBA;AA6MD,eAAe,KAAK,CAAC"}
|