@quillsql/react 2.10.30 → 2.10.32
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/Table.d.ts +26 -0
- package/dist/cjs/Table.d.ts.map +1 -0
- package/dist/cjs/Table.js +94 -0
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +1 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +7 -3
- 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/esm/Table.d.ts +26 -0
- package/dist/esm/Table.d.ts.map +1 -0
- package/dist/esm/Table.js +89 -0
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +1 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +7 -3
- 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/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
showDownloadCsvButton?: boolean;
|
|
11
|
+
LoadingComponent?: () => JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
interface DataTableProps {
|
|
14
|
+
columns: TableColumn[];
|
|
15
|
+
rows: object[];
|
|
16
|
+
containerStyle?: React.CSSProperties;
|
|
17
|
+
csvFilename?: string;
|
|
18
|
+
showDownloadCsvButton?: boolean;
|
|
19
|
+
LoadingComponent?: () => JSX.Element;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
height?: string;
|
|
22
|
+
}
|
|
23
|
+
type TableWrapperProps = ChartIdTableProps | DataTableProps;
|
|
24
|
+
declare const Table: (data: TableWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export default Table;
|
|
26
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAY/D,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;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;CACtC;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,KAAK,iBAAiB,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAE5D,QAAA,MAAM,KAAK,SAAU,iBAAiB,4CAmCrC,CAAC;AAyKF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const Context_1 = require("./Context");
|
|
9
|
+
const dataFetcher_1 = require("./utils/dataFetcher");
|
|
10
|
+
const merge_1 = require("./utils/merge");
|
|
11
|
+
const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
12
|
+
const Table = (data) => {
|
|
13
|
+
const { dispatch, dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
14
|
+
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
15
|
+
const [client, _] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
16
|
+
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
17
|
+
if ('rows' in data && 'columns' in data) {
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(QuillTable_1.default, { showDownloadCSVButton: data.showDownloadCsvButton, downloadFileName: data.csvFilename, columns: data.columns, rows: data.rows, containerStyle: data.containerStyle, LoadingComponent: data.LoadingComponent, loading: data.loading }));
|
|
19
|
+
}
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(ChartUpdater, { showDownloadCsvButton: data.showDownloadCsvButton, dispatch: dispatch, dashboard: dashboard, chartId: data.chartId, containerStyle: data.containerStyle, dashboardFilters: dashboardFilters, client: client, theme: theme, csvFilename: data.csvFilename, LoadingComponent: data.LoadingComponent }));
|
|
21
|
+
};
|
|
22
|
+
const ChartUpdater = ({ chartId, containerStyle, dashboard, dispatch, client, dashboardFilters, theme, csvFilename, showDownloadCsvButton = true, LoadingComponent, }) => {
|
|
23
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
24
|
+
(0, react_1.useEffect)(() => {
|
|
25
|
+
let isSubscribed = true;
|
|
26
|
+
async function getChartOptions() {
|
|
27
|
+
if (isSubscribed) {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
try {
|
|
30
|
+
const hostedBody = {
|
|
31
|
+
metadata: {
|
|
32
|
+
dashboardItemId: chartId,
|
|
33
|
+
orgId: client.customerId || '*',
|
|
34
|
+
task: 'item',
|
|
35
|
+
filters: [...Object.values(dashboardFilters)],
|
|
36
|
+
clientId: client.publicKey,
|
|
37
|
+
databaseType: client?.databaseType,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const cloudBody = {
|
|
41
|
+
id: chartId,
|
|
42
|
+
filters: [...Object.values(dashboardFilters)],
|
|
43
|
+
};
|
|
44
|
+
const resp = await (0, dataFetcher_1.getData)(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
45
|
+
if (resp && resp.name !== 'error') {
|
|
46
|
+
if (resp.compareRows) {
|
|
47
|
+
(0, merge_1.mergeComparisonRange)(resp);
|
|
48
|
+
}
|
|
49
|
+
dispatch({
|
|
50
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
51
|
+
id: chartId,
|
|
52
|
+
data: {
|
|
53
|
+
...resp,
|
|
54
|
+
filtersApplied: dashboardFilters,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
setLoading(false);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.log('Error fetching chart: ', e);
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getChartOptions();
|
|
67
|
+
return () => {
|
|
68
|
+
isSubscribed = false;
|
|
69
|
+
};
|
|
70
|
+
}, [dashboardFilters, client.customerId, chartId]);
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
if (!dashboard[chartId] || loading) {
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
74
|
+
...containerStyle,
|
|
75
|
+
boxSizing: 'content-box',
|
|
76
|
+
height: '100%',
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
flex: 1,
|
|
80
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
81
|
+
height: containerStyle?.height || 300,
|
|
82
|
+
width: '100%',
|
|
83
|
+
boxSizing: 'content-box',
|
|
84
|
+
}, children: (0, jsx_runtime_1.jsxs)("svg", { width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", children: [(0, jsx_runtime_1.jsx)("rect", { width: "100%", height: "100%", fill: "#F9F9FA" }), (0, jsx_runtime_1.jsx)("defs", { fill: "#F9F9FA", children: (0, jsx_runtime_1.jsxs)("linearGradient", { id: "skeletonGradient", x1: "0%", y1: "0%", x2: "10%", y2: "0%", gradientUnits: "userSpaceOnUse", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: "rgba(255,255,255,0)" }), (0, jsx_runtime_1.jsx)("stop", { offset: "50%", stopColor: "#FEFEFE" }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: "rgba(255,255,255,0)" }), (0, jsx_runtime_1.jsx)("animate", { attributeName: "x1", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }), (0, jsx_runtime_1.jsx)("animate", { attributeName: "x2", from: "-50%", to: "150%", dur: "2s", repeatCount: "indefinite" })] }) }), (0, jsx_runtime_1.jsx)("rect", { width: "50%", height: "100%", fill: "url(#skeletonGradient)", children: (0, jsx_runtime_1.jsx)("animate", { attributeName: "x", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }) })] }) }) }));
|
|
85
|
+
}
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(QuillTable_1.default, { showDownloadCSVButton: showDownloadCsvButton,
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
downloadFileName: csvFilename || dashboard[chartId].name,
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
columns: dashboard[chartId].columns || [],
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
rows: dashboard[chartId].rows || [], containerStyle: containerStyle, LoadingComponent: LoadingComponent, loading: loading }));
|
|
93
|
+
};
|
|
94
|
+
exports.default = Table;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,iBAAiB,GAClB,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,iBAAiB,GAClB,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAkDnB"}
|
|
@@ -30,6 +30,6 @@ function DashboardItem({ dashboardItem, onClickDashboardItem, theme, style, load
|
|
|
30
30
|
height: 400,
|
|
31
31
|
borderRadius: 8,
|
|
32
32
|
...style,
|
|
33
|
-
}, rows: dashboardItem?.rows, columns: dashboardItem?.columns })) : null] }, dashboardItem?.name));
|
|
33
|
+
}, rows: dashboardItem?.rows || [], columns: dashboardItem?.columns, downloadFileName: name, showDownloadCSVButton: true })) : null] }, dashboardItem?.name));
|
|
34
34
|
}
|
|
35
35
|
exports.default = DashboardItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKrE,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAA2C,GAC5C,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKrE,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAA2C,GAC5C,EAAE,mBAAmB,2CAmbrB"}
|
|
@@ -16,6 +16,10 @@ function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFil
|
|
|
16
16
|
const [isFormatting, setIsFormatting] = (0, react_1.useState)(false);
|
|
17
17
|
const formattedRows = (0, react_1.useMemo)(() => {
|
|
18
18
|
setIsFormatting(true);
|
|
19
|
+
if (!rows || !columns) {
|
|
20
|
+
setIsFormatting(false);
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
19
23
|
return rows.map((row) => {
|
|
20
24
|
return columns.reduce((formattedRow, column) => {
|
|
21
25
|
// Apply the format function to each field in the row
|
|
@@ -103,7 +107,7 @@ function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFil
|
|
|
103
107
|
flex: '1 0 auto',
|
|
104
108
|
minWidth: '100px',
|
|
105
109
|
boxSizing: 'border-box',
|
|
106
|
-
}, children: columns.map((column, index) => ((0, jsx_runtime_1.jsxs)("div", { onClick: () => toggleSort(column), style: {
|
|
110
|
+
}, children: columns && columns.map((column, index) => ((0, jsx_runtime_1.jsxs)("div", { onClick: () => toggleSort(column), style: {
|
|
107
111
|
boxSizing: 'border-box',
|
|
108
112
|
flex: '150 0 auto',
|
|
109
113
|
minWidth: '50px',
|
|
@@ -145,7 +149,7 @@ function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFil
|
|
|
145
149
|
transform: sortDirection === 'desc'
|
|
146
150
|
? 'rotate(180deg)'
|
|
147
151
|
: undefined,
|
|
148
|
-
}, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), activeRows.length === 0 || columns.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
152
|
+
}, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (activeRows && activeRows.length === 0) || (columns && columns.length === 0) ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
149
153
|
paddingTop: '60px',
|
|
150
154
|
display: 'flex',
|
|
151
155
|
flex: '1 0 auto',
|
|
@@ -154,7 +158,7 @@ function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFil
|
|
|
154
158
|
alignItems: 'center',
|
|
155
159
|
fontSize: 13,
|
|
156
160
|
color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
|
|
157
|
-
}, children: "No results returned." })) : ((0, jsx_runtime_1.jsx)("div", { role: "rowgroup", className: "tbody", children: activeRows.map((row, rowIndex) => ((0, jsx_runtime_1.jsx)("div", { role: "row", className: "tr", style: {
|
|
161
|
+
}, children: "No results returned." })) : ((0, jsx_runtime_1.jsx)("div", { role: "rowgroup", className: "tbody", children: activeRows && activeRows.map((row, rowIndex) => ((0, jsx_runtime_1.jsx)("div", { role: "row", className: "tr", style: {
|
|
158
162
|
display: 'flex',
|
|
159
163
|
flex: '1 0 auto',
|
|
160
164
|
minWidth: '100px',
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default as Dashboard, type DashboardProps, type DashboardItemProps, type DashboardItem, type AxisFormat, } from './Dashboard';
|
|
2
2
|
export { default as QuillProvider } from './QuillProvider';
|
|
3
3
|
export { default as Chart } from './Chart';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as Table } from './Table';
|
|
5
5
|
export { default as SQLEditor, SchemaListComponent } from './SQLEditor';
|
|
6
6
|
export { default as ReportBuilder } from './ReportBuilder';
|
|
7
7
|
export { default as ChartBuilder } from './ChartBuilder';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,GACV,MAAM,mCAAmC,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ThemeContext = exports.downloadCSV = exports.useMemoizedRows = exports.useExport = exports.useQuill = exports.useDashboard = exports.format = exports.ChartEditor = exports.ChartBuilder = exports.ReportBuilder = exports.SchemaListComponent = exports.SQLEditor = exports.
|
|
6
|
+
exports.ThemeContext = exports.downloadCSV = exports.useMemoizedRows = exports.useExport = exports.useQuill = exports.useDashboard = exports.format = exports.ChartEditor = exports.ChartBuilder = exports.ReportBuilder = exports.SchemaListComponent = exports.SQLEditor = exports.Table = exports.Chart = exports.QuillProvider = exports.Dashboard = void 0;
|
|
7
7
|
// src/index.ts
|
|
8
8
|
var Dashboard_1 = require("./Dashboard");
|
|
9
9
|
Object.defineProperty(exports, "Dashboard", { enumerable: true, get: function () { return __importDefault(Dashboard_1).default; } });
|
|
@@ -11,8 +11,8 @@ var QuillProvider_1 = require("./QuillProvider");
|
|
|
11
11
|
Object.defineProperty(exports, "QuillProvider", { enumerable: true, get: function () { return __importDefault(QuillProvider_1).default; } });
|
|
12
12
|
var Chart_1 = require("./Chart");
|
|
13
13
|
Object.defineProperty(exports, "Chart", { enumerable: true, get: function () { return __importDefault(Chart_1).default; } });
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "
|
|
14
|
+
var Table_1 = require("./Table");
|
|
15
|
+
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return __importDefault(Table_1).default; } });
|
|
16
16
|
var SQLEditor_1 = require("./SQLEditor");
|
|
17
17
|
Object.defineProperty(exports, "SQLEditor", { enumerable: true, get: function () { return __importDefault(SQLEditor_1).default; } });
|
|
18
18
|
Object.defineProperty(exports, "SchemaListComponent", { enumerable: true, get: function () { return SQLEditor_1.SchemaListComponent; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
showDownloadCsvButton?: boolean;
|
|
11
|
+
LoadingComponent?: () => JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
interface DataTableProps {
|
|
14
|
+
columns: TableColumn[];
|
|
15
|
+
rows: object[];
|
|
16
|
+
containerStyle?: React.CSSProperties;
|
|
17
|
+
csvFilename?: string;
|
|
18
|
+
showDownloadCsvButton?: boolean;
|
|
19
|
+
LoadingComponent?: () => JSX.Element;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
height?: string;
|
|
22
|
+
}
|
|
23
|
+
type TableWrapperProps = ChartIdTableProps | DataTableProps;
|
|
24
|
+
declare const Table: (data: TableWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export default Table;
|
|
26
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAY/D,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;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;CACtC;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,KAAK,iBAAiB,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAE5D,QAAA,MAAM,KAAK,SAAU,iBAAiB,4CAmCrC,CAAC;AAyKF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, } from './Context';
|
|
4
|
+
import { getData } from './utils/dataFetcher';
|
|
5
|
+
import { mergeComparisonRange } from './utils/merge';
|
|
6
|
+
import QuillTable from './components/QuillTable';
|
|
7
|
+
const Table = (data) => {
|
|
8
|
+
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
9
|
+
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
10
|
+
const [client, _] = useContext(ClientContext);
|
|
11
|
+
const [theme] = useContext(ThemeContext);
|
|
12
|
+
if ('rows' in data && 'columns' in data) {
|
|
13
|
+
return (_jsx(QuillTable, { showDownloadCSVButton: data.showDownloadCsvButton, downloadFileName: data.csvFilename, columns: data.columns, rows: data.rows, containerStyle: data.containerStyle, LoadingComponent: data.LoadingComponent, loading: data.loading }));
|
|
14
|
+
}
|
|
15
|
+
return (_jsx(ChartUpdater, { showDownloadCsvButton: data.showDownloadCsvButton, dispatch: dispatch, dashboard: dashboard, chartId: data.chartId, containerStyle: data.containerStyle, dashboardFilters: dashboardFilters, client: client, theme: theme, csvFilename: data.csvFilename, LoadingComponent: data.LoadingComponent }));
|
|
16
|
+
};
|
|
17
|
+
const ChartUpdater = ({ chartId, containerStyle, dashboard, dispatch, client, dashboardFilters, theme, csvFilename, showDownloadCsvButton = true, LoadingComponent, }) => {
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
let isSubscribed = true;
|
|
21
|
+
async function getChartOptions() {
|
|
22
|
+
if (isSubscribed) {
|
|
23
|
+
setLoading(true);
|
|
24
|
+
try {
|
|
25
|
+
const hostedBody = {
|
|
26
|
+
metadata: {
|
|
27
|
+
dashboardItemId: chartId,
|
|
28
|
+
orgId: client.customerId || '*',
|
|
29
|
+
task: 'item',
|
|
30
|
+
filters: [...Object.values(dashboardFilters)],
|
|
31
|
+
clientId: client.publicKey,
|
|
32
|
+
databaseType: client?.databaseType,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const cloudBody = {
|
|
36
|
+
id: chartId,
|
|
37
|
+
filters: [...Object.values(dashboardFilters)],
|
|
38
|
+
};
|
|
39
|
+
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
40
|
+
if (resp && resp.name !== 'error') {
|
|
41
|
+
if (resp.compareRows) {
|
|
42
|
+
mergeComparisonRange(resp);
|
|
43
|
+
}
|
|
44
|
+
dispatch({
|
|
45
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
46
|
+
id: chartId,
|
|
47
|
+
data: {
|
|
48
|
+
...resp,
|
|
49
|
+
filtersApplied: dashboardFilters,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
setLoading(false);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
console.log('Error fetching chart: ', e);
|
|
57
|
+
setLoading(false);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getChartOptions();
|
|
62
|
+
return () => {
|
|
63
|
+
isSubscribed = false;
|
|
64
|
+
};
|
|
65
|
+
}, [dashboardFilters, client.customerId, chartId]);
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
if (!dashboard[chartId] || loading) {
|
|
68
|
+
return (_jsx("div", { style: {
|
|
69
|
+
...containerStyle,
|
|
70
|
+
boxSizing: 'content-box',
|
|
71
|
+
height: '100%',
|
|
72
|
+
display: 'flex',
|
|
73
|
+
flexDirection: 'column',
|
|
74
|
+
flex: 1,
|
|
75
|
+
}, children: _jsx("div", { style: {
|
|
76
|
+
height: containerStyle?.height || 300,
|
|
77
|
+
width: '100%',
|
|
78
|
+
boxSizing: 'content-box',
|
|
79
|
+
}, children: _jsxs("svg", { width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", children: [_jsx("rect", { width: "100%", height: "100%", fill: "#F9F9FA" }), _jsx("defs", { fill: "#F9F9FA", children: _jsxs("linearGradient", { id: "skeletonGradient", x1: "0%", y1: "0%", x2: "10%", y2: "0%", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { offset: "0%", stopColor: "rgba(255,255,255,0)" }), _jsx("stop", { offset: "50%", stopColor: "#FEFEFE" }), _jsx("stop", { offset: "100%", stopColor: "rgba(255,255,255,0)" }), _jsx("animate", { attributeName: "x1", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }), _jsx("animate", { attributeName: "x2", from: "-50%", to: "150%", dur: "2s", repeatCount: "indefinite" })] }) }), _jsx("rect", { width: "50%", height: "100%", fill: "url(#skeletonGradient)", children: _jsx("animate", { attributeName: "x", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }) })] }) }) }));
|
|
80
|
+
}
|
|
81
|
+
return (_jsx(QuillTable, { showDownloadCSVButton: showDownloadCsvButton,
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
downloadFileName: csvFilename || dashboard[chartId].name,
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
columns: dashboard[chartId].columns || [],
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
rows: dashboard[chartId].rows || [], containerStyle: containerStyle, LoadingComponent: LoadingComponent, loading: loading }));
|
|
88
|
+
};
|
|
89
|
+
export default Table;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,iBAAiB,GAClB,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,iBAAiB,GAClB,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAkDnB"}
|
|
@@ -25,5 +25,5 @@ export default function DashboardItem({ dashboardItem, onClickDashboardItem, the
|
|
|
25
25
|
height: 400,
|
|
26
26
|
borderRadius: 8,
|
|
27
27
|
...style,
|
|
28
|
-
}, rows: dashboardItem?.rows, columns: dashboardItem?.columns })) : null] }, dashboardItem?.name));
|
|
28
|
+
}, rows: dashboardItem?.rows || [], columns: dashboardItem?.columns, downloadFileName: name, showDownloadCSVButton: true })) : null] }, dashboardItem?.name));
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKrE,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAA2C,GAC5C,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKrE,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAA2C,GAC5C,EAAE,mBAAmB,2CAmbrB"}
|
|
@@ -14,6 +14,10 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
|
|
|
14
14
|
const [isFormatting, setIsFormatting] = useState(false);
|
|
15
15
|
const formattedRows = useMemo(() => {
|
|
16
16
|
setIsFormatting(true);
|
|
17
|
+
if (!rows || !columns) {
|
|
18
|
+
setIsFormatting(false);
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
17
21
|
return rows.map((row) => {
|
|
18
22
|
return columns.reduce((formattedRow, column) => {
|
|
19
23
|
// Apply the format function to each field in the row
|
|
@@ -101,7 +105,7 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
|
|
|
101
105
|
flex: '1 0 auto',
|
|
102
106
|
minWidth: '100px',
|
|
103
107
|
boxSizing: 'border-box',
|
|
104
|
-
}, children: columns.map((column, index) => (_jsxs("div", { onClick: () => toggleSort(column), style: {
|
|
108
|
+
}, children: columns && columns.map((column, index) => (_jsxs("div", { onClick: () => toggleSort(column), style: {
|
|
105
109
|
boxSizing: 'border-box',
|
|
106
110
|
flex: '150 0 auto',
|
|
107
111
|
minWidth: '50px',
|
|
@@ -143,7 +147,7 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
|
|
|
143
147
|
transform: sortDirection === 'desc'
|
|
144
148
|
? 'rotate(180deg)'
|
|
145
149
|
: undefined,
|
|
146
|
-
}, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), activeRows.length === 0 || columns.length === 0 ? (_jsx("div", { style: {
|
|
150
|
+
}, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (activeRows && activeRows.length === 0) || (columns && columns.length === 0) ? (_jsx("div", { style: {
|
|
147
151
|
paddingTop: '60px',
|
|
148
152
|
display: 'flex',
|
|
149
153
|
flex: '1 0 auto',
|
|
@@ -152,7 +156,7 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
|
|
|
152
156
|
alignItems: 'center',
|
|
153
157
|
fontSize: 13,
|
|
154
158
|
color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
|
|
155
|
-
}, children: "No results returned." })) : (_jsx("div", { role: "rowgroup", className: "tbody", children: activeRows.map((row, rowIndex) => (_jsx("div", { role: "row", className: "tr", style: {
|
|
159
|
+
}, children: "No results returned." })) : (_jsx("div", { role: "rowgroup", className: "tbody", children: activeRows && activeRows.map((row, rowIndex) => (_jsx("div", { role: "row", className: "tr", style: {
|
|
156
160
|
display: 'flex',
|
|
157
161
|
flex: '1 0 auto',
|
|
158
162
|
minWidth: '100px',
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default as Dashboard, type DashboardProps, type DashboardItemProps, type DashboardItem, type AxisFormat, } from './Dashboard';
|
|
2
2
|
export { default as QuillProvider } from './QuillProvider';
|
|
3
3
|
export { default as Chart } from './Chart';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as Table } from './Table';
|
|
5
5
|
export { default as SQLEditor, SchemaListComponent } from './SQLEditor';
|
|
6
6
|
export { default as ReportBuilder } from './ReportBuilder';
|
|
7
7
|
export { default as ChartBuilder } from './ChartBuilder';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,GACV,MAAM,mCAAmC,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { default as Dashboard, } from './Dashboard';
|
|
3
3
|
export { default as QuillProvider } from './QuillProvider';
|
|
4
4
|
export { default as Chart } from './Chart';
|
|
5
|
-
export { default as
|
|
5
|
+
export { default as Table } from './Table';
|
|
6
6
|
export { default as SQLEditor, SchemaListComponent } from './SQLEditor';
|
|
7
7
|
export { default as ReportBuilder } from './ReportBuilder';
|
|
8
8
|
export { default as ChartBuilder } from './ChartBuilder';
|