@addev-be/ui 0.2.6 → 0.2.7
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/assets/icons/arrow-down-1-9.svg +1 -0
- package/assets/icons/arrow-down-big-small.svg +1 -0
- package/assets/icons/arrow-up-9-1.svg +1 -0
- package/assets/icons/arrow-up-big-small.svg +1 -0
- package/assets/icons/chevron-down.svg +1 -0
- package/assets/icons/ellipsis.svg +1 -0
- package/assets/icons/sigma.svg +1 -0
- package/assets/icons/table-footer-slash.svg +5 -0
- package/assets/icons/table-footer.svg +4 -0
- package/assets/icons/table.svg +1 -0
- package/assets/icons/tally.svg +1 -0
- package/assets/icons/x-bar.svg +4 -0
- package/dist/Icons.d.ts +13 -1
- package/dist/Icons.js +25 -1
- package/dist/components/data/AdvancedRequestDataGrid/index.js +3 -3
- package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.js +2 -1
- package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +85 -7
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +3 -9
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +10 -37
- package/dist/components/data/DataGrid/DataGridFooter.d.ts +1 -1
- package/dist/components/data/DataGrid/DataGridFooter.js +35 -12
- package/dist/components/data/DataGrid/DataGridHeader.js +1 -1
- package/dist/components/data/DataGrid/DataGridHeaderCell.js +6 -22
- package/dist/components/data/DataGrid/helpers/columns.d.ts +1 -1
- package/dist/components/data/DataGrid/helpers/columns.js +71 -16
- package/dist/components/data/DataGrid/hooks/useDataGrid.d.ts +1 -1
- package/dist/components/data/DataGrid/hooks/useDataGrid.js +60 -30
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.d.ts +2 -2
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +41 -39
- package/dist/components/data/DataGrid/index.d.ts +4 -2
- package/dist/components/data/DataGrid/index.js +22 -12
- package/dist/components/data/DataGrid/styles.d.ts +8 -4
- package/dist/components/data/DataGrid/styles.js +27 -17
- package/dist/components/data/DataGrid/types.d.ts +8 -1
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.d.ts +1 -1
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +24 -11
- package/dist/components/data/SqlRequestDataGrid/index.js +105 -33
- package/dist/components/ui/ContextMenu/index.d.ts +11 -0
- package/dist/components/ui/ContextMenu/index.js +58 -0
- package/dist/components/ui/ContextMenu/styles.d.ts +18 -0
- package/dist/components/ui/ContextMenu/styles.js +56 -0
- package/dist/services/advancedRequests.d.ts +1 -1
- package/dist/services/sqlRequests.d.ts +9 -4
- package/dist/services/sqlRequests.js +1 -0
- package/package.json +1 -1
- package/src/Icons.tsx +24 -0
- package/src/components/data/AdvancedRequestDataGrid/index.tsx +3 -5
- package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +2 -1
- package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +173 -9
- package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +13 -64
- package/src/components/data/DataGrid/DataGridFooter.tsx +20 -22
- package/src/components/data/DataGrid/DataGridHeader.tsx +5 -5
- package/src/components/data/DataGrid/DataGridHeaderCell.tsx +3 -38
- package/src/components/data/DataGrid/helpers/columns.tsx +98 -7
- package/src/components/data/DataGrid/hooks/useDataGrid.tsx +58 -17
- package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +35 -30
- package/src/components/data/DataGrid/index.tsx +21 -14
- package/src/components/data/DataGrid/styles.ts +28 -7
- package/src/components/data/DataGrid/types.ts +20 -1
- package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +38 -3
- package/src/components/data/SqlRequestDataGrid/index.tsx +116 -21
- package/src/components/ui/ContextMenu/index.tsx +73 -0
- package/src/components/ui/ContextMenu/styles.ts +115 -0
- package/src/services/advancedRequests.ts +1 -1
- package/src/services/sqlRequests.ts +16 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -27,7 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.FilterValuesScrollerContainer = exports.ResizeBackdrop = exports.HeaderSelectionCell = exports.SelectionCell = exports.LoadingCell = exports.DataGridRow = exports.DataGridHeaderRow = exports.DataGridContainer = exports.DataGridToolsRow = exports.DataGridCell = exports.DataGridHeaderCellContainer = exports.DataGridResizeGrip = exports.VirtualScrollerRowsContainer = exports.VirtualScrollerContainer = exports.BottomPaddingRow = exports.TopPaddingRow = exports.DEFAULT_FILTER_ROW_HEIGHT = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_ROW_HEIGHT = exports.TOOLBAR_HEIGHT = exports.VIRTUAL_SCROLL_TOLERANCE = void 0;
|
|
30
|
+
exports.FilterValuesScrollerContainer = exports.ResizeBackdrop = exports.HeaderSelectionCell = exports.SelectionCell = exports.LoadingCell = exports.DataGridRow = exports.DataGridFooterRow = exports.DataGridHeaderRow = exports.DataGridContainer = exports.DataGridToolsRow = exports.DataGridCell = exports.DataGridHeaderCellContainer = exports.DataGridResizeGrip = exports.VirtualScrollerRowsContainer = exports.VirtualScrollerContainer = exports.BottomPaddingRow = exports.TopPaddingRow = exports.DEFAULT_FILTER_ROW_HEIGHT = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_ROW_HEIGHT = exports.TOOLBAR_HEIGHT = exports.VIRTUAL_SCROLL_TOLERANCE = void 0;
|
|
31
31
|
var styled_components_1 = __importStar(require("styled-components"));
|
|
32
32
|
exports.VIRTUAL_SCROLL_TOLERANCE = 20;
|
|
33
33
|
exports.TOOLBAR_HEIGHT = 40;
|
|
@@ -86,6 +86,14 @@ exports.DataGridContainer = styled_components_1.default.div(templateObject_13 ||
|
|
|
86
86
|
return "".concat($rowHeight, "px");
|
|
87
87
|
}, exports.VirtualScrollerContainer);
|
|
88
88
|
exports.DataGridContainer.displayName = 'DataGridContainer';
|
|
89
|
+
var dataGridHeaderOrFooterRowCss = (0, styled_components_1.css)(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n display: grid;\n grid-template-rows: ", ";\n z-index: 10;\n position: sticky;\n align-items: center;\n\n ", "\n"], ["\n display: grid;\n grid-template-rows: ", ";\n z-index: 10;\n position: sticky;\n align-items: center;\n\n ", "\n"])), function (_a) {
|
|
90
|
+
var _b = _a.$headerRowHeight, $headerRowHeight = _b === void 0 ? exports.DEFAULT_HEADER_ROW_HEIGHT : _b;
|
|
91
|
+
return "".concat($headerRowHeight, "px");
|
|
92
|
+
}, function (_a) {
|
|
93
|
+
var $headerColor = _a.$headerColor;
|
|
94
|
+
return $headerColor
|
|
95
|
+
? (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n background-color: var(--color-", "-100);\n color: var(--color-", "-900);\n "], ["\n background-color: var(--color-", "-100);\n color: var(--color-", "-900);\n "])), $headerColor, $headerColor) : (0, styled_components_1.css)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n background-color: var(--color-neutral-200);\n color: var(--color-neutral-900);\n "], ["\n background-color: var(--color-neutral-200);\n color: var(--color-neutral-900);\n "])));
|
|
96
|
+
});
|
|
89
97
|
exports.DataGridHeaderRow = styled_components_1.default.div.attrs(function (_a) {
|
|
90
98
|
var $gridTemplateColumns = _a.$gridTemplateColumns;
|
|
91
99
|
return ({
|
|
@@ -93,32 +101,34 @@ exports.DataGridHeaderRow = styled_components_1.default.div.attrs(function (_a)
|
|
|
93
101
|
gridTemplateColumns: $gridTemplateColumns,
|
|
94
102
|
},
|
|
95
103
|
});
|
|
96
|
-
})(
|
|
97
|
-
var _b = _a.$headerRowHeight, $headerRowHeight = _b === void 0 ? exports.DEFAULT_HEADER_ROW_HEIGHT : _b;
|
|
98
|
-
return "".concat($headerRowHeight, "px");
|
|
99
|
-
}, exports.TOOLBAR_HEIGHT, function (_a) {
|
|
100
|
-
var $headerColor = _a.$headerColor;
|
|
101
|
-
return $headerColor
|
|
102
|
-
? (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n background-color: var(--color-", "-100);\n color: var(--color-", "-900);\n "], ["\n background-color: var(--color-", "-100);\n color: var(--color-", "-900);\n "])), $headerColor, $headerColor) : (0, styled_components_1.css)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n background-color: var(--color-neutral-200);\n color: var(--color-neutral-900);\n "], ["\n background-color: var(--color-neutral-200);\n color: var(--color-neutral-900);\n "])));
|
|
103
|
-
});
|
|
104
|
+
})(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n ", "\n top: ", "px;\n"], ["\n ", "\n top: ", "px;\n"])), dataGridHeaderOrFooterRowCss, exports.TOOLBAR_HEIGHT);
|
|
104
105
|
exports.DataGridHeaderRow.displayName = 'DataGridHeaderRow';
|
|
105
|
-
exports.
|
|
106
|
+
exports.DataGridFooterRow = styled_components_1.default.div.attrs(function (_a) {
|
|
107
|
+
var $gridTemplateColumns = _a.$gridTemplateColumns;
|
|
108
|
+
return ({
|
|
109
|
+
style: {
|
|
110
|
+
gridTemplateColumns: $gridTemplateColumns,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
})(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n ", "\n bottom: 0;\n"], ["\n ", "\n bottom: 0;\n"])), dataGridHeaderOrFooterRowCss);
|
|
114
|
+
exports.DataGridFooterRow.displayName = 'DataGridFooterRow';
|
|
115
|
+
exports.DataGridRow = styled_components_1.default.div(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n display: contents;\n"], ["\n display: contents;\n"])));
|
|
106
116
|
exports.DataGridRow.displayName = 'DataGridRow';
|
|
107
|
-
exports.LoadingCell = (0, styled_components_1.default)(exports.DataGridCell)(
|
|
117
|
+
exports.LoadingCell = (0, styled_components_1.default)(exports.DataGridCell)(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n padding: var(--space-2);\n box-sizing: border-box;\n\n &.animate-pulse > div {\n background-color: var(--color-neutral-200);\n border-radius: var(--rounded-full);\n width: 100%;\n height: 100%;\n }\n"], ["\n padding: var(--space-2);\n box-sizing: border-box;\n\n &.animate-pulse > div {\n background-color: var(--color-neutral-200);\n border-radius: var(--rounded-full);\n width: 100%;\n height: 100%;\n }\n"])));
|
|
108
118
|
exports.LoadingCell.displayName = 'LoadingCell';
|
|
109
|
-
var selectionCellStyle = (0, styled_components_1.css)(
|
|
110
|
-
exports.SelectionCell = (0, styled_components_1.default)(exports.DataGridCell)(
|
|
119
|
+
var selectionCellStyle = (0, styled_components_1.css)(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--space-8);\n padding: 0 var(--space-1);\n cursor: pointer;\n\n & > input[type='checkbox'] {\n height: var(--space-4);\n width: var(--space-4);\n border-radius: var(--rounded-sm);\n border: 1px solid var(--color-neutral-300);\n color: var(--color-primary-600);\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--space-8);\n padding: 0 var(--space-1);\n cursor: pointer;\n\n & > input[type='checkbox'] {\n height: var(--space-4);\n width: var(--space-4);\n border-radius: var(--rounded-sm);\n border: 1px solid var(--color-neutral-300);\n color: var(--color-primary-600);\n }\n"])));
|
|
120
|
+
exports.SelectionCell = (0, styled_components_1.default)(exports.DataGridCell)(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), selectionCellStyle);
|
|
111
121
|
exports.SelectionCell.displayName = 'SelectionCell';
|
|
112
|
-
exports.HeaderSelectionCell = (0, styled_components_1.default)(exports.DataGridHeaderCellContainer)(
|
|
122
|
+
exports.HeaderSelectionCell = (0, styled_components_1.default)(exports.DataGridHeaderCellContainer)(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), selectionCellStyle);
|
|
113
123
|
exports.HeaderSelectionCell.displayName = 'HeaderSelectionCell';
|
|
114
124
|
exports.ResizeBackdrop = styled_components_1.default.div.attrs({
|
|
115
125
|
className: 'ResizeBackdrop',
|
|
116
|
-
})(
|
|
126
|
+
})(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0);\n cursor: col-resize;\n"], ["\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0);\n cursor: col-resize;\n"])));
|
|
117
127
|
exports.ResizeBackdrop.displayName = 'ResizeBackdrop';
|
|
118
128
|
exports.FilterValuesScrollerContainer = styled_components_1.default.div.attrs({
|
|
119
129
|
className: 'FilterValuesScrollerContainer',
|
|
120
|
-
})(
|
|
130
|
+
})(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n display: block;\n font-size: var(--text-base);\n background-color: var(--color-neutral-0);\n overflow-y: scroll;\n overflow-x: hidden;\n height: 100%;\n\n & > div {\n position: relative;\n }\n\n & .checkbox {\n position: absolute;\n display: flex;\n flex-direction: row;\n align-items: center;\n height: ", ";\n\n input[type='checkbox'] {\n margin-right: var(--space-1);\n }\n }\n"], ["\n display: block;\n font-size: var(--text-base);\n background-color: var(--color-neutral-0);\n overflow-y: scroll;\n overflow-x: hidden;\n height: 100%;\n\n & > div {\n position: relative;\n }\n\n & .checkbox {\n position: absolute;\n display: flex;\n flex-direction: row;\n align-items: center;\n height: ", ";\n\n input[type='checkbox'] {\n margin-right: var(--space-1);\n }\n }\n"])), function (_a) {
|
|
121
131
|
var _b = _a.$rowHeight, $rowHeight = _b === void 0 ? exports.DEFAULT_FILTER_ROW_HEIGHT : _b;
|
|
122
132
|
return "".concat($rowHeight, "px");
|
|
123
133
|
});
|
|
124
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23;
|
|
134
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25;
|
|
@@ -6,13 +6,15 @@ export type DataGridCellFC = FC<{
|
|
|
6
6
|
onDoubleClick?: MouseEventHandler;
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
}>;
|
|
9
|
+
export type DataGridFooterPredefinedFunction = 'average' | 'count' | 'max' | 'min' | 'sum';
|
|
10
|
+
export type DataGridFooterFunction<R> = (allRows: R[], filteredRows: R[], selectedRows: R[]) => ReactNode;
|
|
9
11
|
export type DataGridColumn<R> = {
|
|
10
12
|
component?: DataGridCellFC;
|
|
11
13
|
editable?: boolean;
|
|
12
14
|
excelFormatter?: (value: any) => string;
|
|
13
15
|
excelValue?: (value: any) => string;
|
|
14
16
|
filter?: DataGridFilter;
|
|
15
|
-
footer?:
|
|
17
|
+
footer?: DataGridFooterFunction<R> | Record<string, DataGridFooterFunction<R> | null>;
|
|
16
18
|
getter?: (row: R) => string | number;
|
|
17
19
|
name: string;
|
|
18
20
|
order?: number;
|
|
@@ -50,6 +52,8 @@ export type DataGridProps<R> = {
|
|
|
50
52
|
filter?: boolean;
|
|
51
53
|
sort?: boolean;
|
|
52
54
|
initialSorts?: Record<string, DataGridSort>;
|
|
55
|
+
initialFooters?: Record<string, string>;
|
|
56
|
+
onFootersChanged?: (footers: Record<string, string>) => void;
|
|
53
57
|
filterValuesLoader?: (columnKey: string) => Promise<(string | number | null)[]>;
|
|
54
58
|
loadCopyRows?: () => Promise<R[]>;
|
|
55
59
|
refresh?: () => void;
|
|
@@ -66,6 +70,9 @@ export type DataGridContextProps<R> = DataGridProps<R> & {
|
|
|
66
70
|
setSorts: (sorts: Record<string, DataGridSort>) => void;
|
|
67
71
|
filters?: DataGridFilters;
|
|
68
72
|
setFilters: Dispatch<SetStateAction<DataGridFilters>>;
|
|
73
|
+
footers?: Record<string, string>;
|
|
74
|
+
setFooters: Dispatch<SetStateAction<Record<string, string>>>;
|
|
75
|
+
footerFunctions?: Record<string, DataGridFooterFunction<R>>;
|
|
69
76
|
visibleColumns: DataGridColumnKeyValuePair<R>[];
|
|
70
77
|
copyTable: (includeHeaders?: boolean, includeFooters?: boolean) => Promise<void>;
|
|
71
78
|
setColumnWidth: (key: string, width: number) => void;
|
|
@@ -11,6 +11,6 @@ export declare const sqlDateColumn: <R extends Record<string, any>>(key: string,
|
|
|
11
11
|
export declare const sqlMonthColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
12
12
|
export declare const sqlNumberColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
13
13
|
export declare const sqlMoneyColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
14
|
-
export declare const sqlPercentageColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
14
|
+
export declare const sqlPercentageColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
15
15
|
export declare const sqlCheckboxColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
16
16
|
export declare const sqlColorColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<SqlRequestDataGridColumn<R>>) => SqlRequestDataGridColumns<R>;
|
|
@@ -19,7 +19,7 @@ var dates_1 = require("../../../../helpers/dates");
|
|
|
19
19
|
var sqlTextColumn = function (key, title, options) {
|
|
20
20
|
var _a;
|
|
21
21
|
return (_a = {},
|
|
22
|
-
_a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
|
|
22
|
+
_a[key] = __assign(__assign({ name: title, render: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options), { footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }),
|
|
23
23
|
_a);
|
|
24
24
|
};
|
|
25
25
|
exports.sqlTextColumn = sqlTextColumn;
|
|
@@ -37,35 +37,35 @@ var sqlComposedColumn = function (key, title, fields, options) {
|
|
|
37
37
|
{ constantValue: field },
|
|
38
38
|
{ fieldName: field },
|
|
39
39
|
]; }),
|
|
40
|
-
}, name: title, render: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(fields[0])), { getter: function (value) { var _a; return (_a = value[fields[0]]) !== null && _a !== void 0 ? _a : 0; } }), filterField: fields[0], sortField: fields[0] }, options),
|
|
40
|
+
}, name: title, render: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(fields[0])), { getter: function (value) { var _a; return (_a = value[fields[0]]) !== null && _a !== void 0 ? _a : 0; } }), filterField: fields[0], sortField: fields[0], footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }, options),
|
|
41
41
|
_a);
|
|
42
42
|
};
|
|
43
43
|
exports.sqlComposedColumn = sqlComposedColumn;
|
|
44
44
|
var sqlMailColumn = function (key, title, options) {
|
|
45
45
|
var _a;
|
|
46
46
|
return (_a = {},
|
|
47
|
-
_a[key] = __assign({ name: title, render: function (row) { var _a; return (0, jsx_runtime_1.jsx)("a", { href: "mailto:".concat(row[key]), children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
|
|
47
|
+
_a[key] = __assign({ name: title, render: function (row) { var _a; return (0, jsx_runtime_1.jsx)("a", { href: "mailto:".concat(row[key]), children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }), footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }, options),
|
|
48
48
|
_a);
|
|
49
49
|
};
|
|
50
50
|
exports.sqlMailColumn = sqlMailColumn;
|
|
51
51
|
var sqlPhoneColumn = function (key, title, options) {
|
|
52
52
|
var _a;
|
|
53
53
|
return (_a = {},
|
|
54
|
-
_a[key] = __assign({ name: title, render: function (row) { var _a; return (0, jsx_runtime_1.jsx)("a", { href: "tel:".concat(row[key]), children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
|
|
54
|
+
_a[key] = __assign({ name: title, render: function (row) { var _a; return (0, jsx_runtime_1.jsx)("a", { href: "tel:".concat(row[key]), children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }), footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }, options),
|
|
55
55
|
_a);
|
|
56
56
|
};
|
|
57
57
|
exports.sqlPhoneColumn = sqlPhoneColumn;
|
|
58
58
|
var sqlDateColumn = function (key, title, options) {
|
|
59
59
|
var _a;
|
|
60
60
|
return (_a = {},
|
|
61
|
-
_a[key] = __assign({ name: title, render: function (row) { return (0, dates_1.formatDate)(row[key]); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
|
|
61
|
+
_a[key] = __assign({ name: title, render: function (row) { return (0, dates_1.formatDate)(row[key]); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }), footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }, options),
|
|
62
62
|
_a);
|
|
63
63
|
};
|
|
64
64
|
exports.sqlDateColumn = sqlDateColumn;
|
|
65
65
|
var sqlMonthColumn = function (key, title, options) {
|
|
66
66
|
var _a;
|
|
67
67
|
return (_a = {},
|
|
68
|
-
_a[key] = __assign({ name: title, render: function (row) { return (row[key] ? "".concat(row[key], " mois ") : ''); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
|
|
68
|
+
_a[key] = __assign({ name: title, render: function (row) { return (row[key] ? "".concat(row[key], " mois ") : ''); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }), footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }, options),
|
|
69
69
|
_a);
|
|
70
70
|
};
|
|
71
71
|
exports.sqlMonthColumn = sqlMonthColumn;
|
|
@@ -73,7 +73,13 @@ var sqlNumberColumn = function (key, title, decimals, options) {
|
|
|
73
73
|
var _a;
|
|
74
74
|
if (decimals === void 0) { decimals = 2; }
|
|
75
75
|
return (_a = {},
|
|
76
|
-
_a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatNumber)(row[key], decimals)) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; }
|
|
76
|
+
_a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatNumber)(row[key], decimals)) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; }, renderer: function (value) { var _a; return (_a = (0, numbers_1.formatNumber)(value, decimals)) !== null && _a !== void 0 ? _a : ''; } }), footer: {
|
|
77
|
+
sum: null,
|
|
78
|
+
avg: null,
|
|
79
|
+
count: null,
|
|
80
|
+
max: null,
|
|
81
|
+
min: null,
|
|
82
|
+
} }, options),
|
|
77
83
|
_a);
|
|
78
84
|
};
|
|
79
85
|
exports.sqlNumberColumn = sqlNumberColumn;
|
|
@@ -81,21 +87,28 @@ var sqlMoneyColumn = function (key, title, decimals, options) {
|
|
|
81
87
|
var _a;
|
|
82
88
|
if (decimals === void 0) { decimals = 2; }
|
|
83
89
|
return (_a = {},
|
|
84
|
-
_a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatMoney)(row[key], decimals)) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#0.00'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; }
|
|
90
|
+
_a[key] = __assign({ name: title, type: 'number', render: function (row) { var _a; return (_a = (0, numbers_1.formatMoney)(row[key], decimals)) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#0.00'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; }, renderer: function (value) { var _a; return (_a = (0, numbers_1.formatMoney)(value, decimals)) !== null && _a !== void 0 ? _a : ''; } }), footer: {
|
|
91
|
+
sum: null,
|
|
92
|
+
avg: null,
|
|
93
|
+
count: null,
|
|
94
|
+
max: null,
|
|
95
|
+
min: null,
|
|
96
|
+
} }, options),
|
|
85
97
|
_a);
|
|
86
98
|
};
|
|
87
99
|
exports.sqlMoneyColumn = sqlMoneyColumn;
|
|
88
|
-
var sqlPercentageColumn = function (key, title, options) {
|
|
100
|
+
var sqlPercentageColumn = function (key, title, decimals, options) {
|
|
89
101
|
var _a;
|
|
102
|
+
if (decimals === void 0) { decimals = 2; }
|
|
90
103
|
return (_a = {},
|
|
91
|
-
_a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatPercentage)(row[key])) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#0.00'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }) }, options),
|
|
104
|
+
_a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatPercentage)(row[key])) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#0.00'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; }, renderer: function (value) { var _a; return (_a = (0, numbers_1.formatPercentage)(value, decimals)) !== null && _a !== void 0 ? _a : ''; } }) }, options),
|
|
92
105
|
_a);
|
|
93
106
|
};
|
|
94
107
|
exports.sqlPercentageColumn = sqlPercentageColumn;
|
|
95
108
|
var sqlCheckboxColumn = function (key, title, options) {
|
|
96
109
|
var _a;
|
|
97
110
|
return (_a = {},
|
|
98
|
-
_a[key] = __assign({ name: title, render: function (row) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: row[key] }), (0, jsx_runtime_1.jsx)("span", { children: row[key] ? ' Oui' : ' Non' })] })); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }) }, options),
|
|
111
|
+
_a[key] = __assign({ name: title, render: function (row) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: row[key] }), (0, jsx_runtime_1.jsx)("span", { children: row[key] ? ' Oui' : ' Non' })] })); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }), footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); } }, options),
|
|
99
112
|
_a);
|
|
100
113
|
};
|
|
101
114
|
exports.sqlCheckboxColumn = sqlCheckboxColumn;
|
|
@@ -63,24 +63,25 @@ var DataGrid_1 = require("../DataGrid");
|
|
|
63
63
|
var helpers_1 = require("./helpers");
|
|
64
64
|
var helpers_2 = require("../DataGrid/helpers");
|
|
65
65
|
var SqlRequestDataGrid = function (_a) {
|
|
66
|
-
var _b;
|
|
66
|
+
var _b, _c;
|
|
67
67
|
var onSelectionChangeFromProps = _a.onSelectionChange, props = __rest(_a, ["onSelectionChange"]);
|
|
68
68
|
var currentRows = (0, react_1.useRef)([]);
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var _b, _c;
|
|
69
|
+
var _d = (0, react_1.useState)([]), rows = _d[0], setRows = _d[1];
|
|
70
|
+
var _e = (0, react_1.useState)(0), start = _e[0], setStart = _e[1];
|
|
71
|
+
var _f = (0, react_1.useState)(50), length = _f[0], setLength = _f[1];
|
|
72
|
+
var _g = (0, react_1.useState)(-1), count = _g[0], setCount = _g[1];
|
|
73
|
+
var _h = (0, sqlRequests_1.useSqlRequestHandler)(props.type), sqlRequest = _h[0], sqlIdRequest = _h[1], sqlPartialRequest = _h[2];
|
|
74
|
+
var _j = (0, react_1.useState)({}), conditions = _j[0], setConditions = _j[1];
|
|
75
|
+
var _k = (0, react_1.useState)(Object.entries((_b = props.initialSorts) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
76
|
+
var _b, _c, _d;
|
|
77
77
|
var columnKey = _a[0], direction = _a[1];
|
|
78
78
|
return ({
|
|
79
79
|
field: (_c = (_b = props.columns[columnKey].field) === null || _b === void 0 ? void 0 : _b.fieldAlias) !== null && _c !== void 0 ? _c : columnKey,
|
|
80
|
+
type: (_d = props.columns[columnKey].type) !== null && _d !== void 0 ? _d : 'text',
|
|
80
81
|
direction: direction.toUpperCase(),
|
|
81
82
|
});
|
|
82
|
-
})), orderBy =
|
|
83
|
-
var
|
|
83
|
+
})), orderBy = _k[0], setOrderBy = _k[1];
|
|
84
|
+
var _l = (0, react_1.useMemo)(function () {
|
|
84
85
|
var _a, _b;
|
|
85
86
|
return [
|
|
86
87
|
__spreadArray(__spreadArray([], Object.keys(props.columns), true), ((_a = props.hiddenColumns) !== null && _a !== void 0 ? _a : []), true),
|
|
@@ -88,16 +89,19 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
88
89
|
return (0, helpers_2.isColumnVisible)(props.columns[key]);
|
|
89
90
|
}), true), ((_b = props.hiddenColumns) !== null && _b !== void 0 ? _b : []), true),
|
|
90
91
|
];
|
|
91
|
-
}, [props.columns, props.hiddenColumns]), columnsKeys =
|
|
92
|
+
}, [props.columns, props.hiddenColumns]), columnsKeys = _l[0], visibleColumnsKeys = _l[1];
|
|
93
|
+
var columnTypes = (0, react_1.useMemo)(function () {
|
|
94
|
+
return visibleColumnsKeys.map(function (key) { var _a; return String((_a = props.columns[key].type) !== null && _a !== void 0 ? _a : 'text'); });
|
|
95
|
+
}, [visibleColumnsKeys, props.columns]);
|
|
92
96
|
var refresh = (0, react_1.useCallback)(function () {
|
|
93
97
|
setRows([]);
|
|
94
98
|
setStart(0);
|
|
95
99
|
setLength(50);
|
|
96
|
-
|
|
100
|
+
setCount(-1);
|
|
97
101
|
}, []);
|
|
98
102
|
var onFiltersChanged = (0, react_1.useCallback)(function (filters) {
|
|
99
103
|
var newConditions = (0, helpers_1.convertSqlFiltersToConditions)(filters);
|
|
100
|
-
|
|
104
|
+
setCount(-1);
|
|
101
105
|
setConditions(newConditions);
|
|
102
106
|
}, []);
|
|
103
107
|
var onSortsChanged = (0, react_1.useCallback)(function (sorts) {
|
|
@@ -111,29 +115,32 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
111
115
|
});
|
|
112
116
|
setOrderBy(newOrderBy);
|
|
113
117
|
}, [refresh]);
|
|
114
|
-
var loadRows = (0, react_1.useRef)((0, lodash_1.debounce)(function (columns, returnColumns, conditions, orderBy, start, length,
|
|
118
|
+
var loadRows = (0, react_1.useRef)((0, lodash_1.debounce)(function (columns, returnColumns, conditions, orderBy, start, length, getCount) {
|
|
115
119
|
if (conditions === void 0) { conditions = []; }
|
|
116
120
|
if (orderBy === void 0) { orderBy = []; }
|
|
117
121
|
if (start === void 0) { start = 0; }
|
|
118
122
|
if (length === void 0) { length = 100; }
|
|
119
|
-
if (
|
|
123
|
+
if (getCount === void 0) { getCount = false; }
|
|
120
124
|
sqlRequest({
|
|
121
125
|
columns: columns.includes('Id') ? columns : __spreadArray(__spreadArray([], columns, true), ['Id'], false),
|
|
122
126
|
returnColumns: returnColumns.includes('Id')
|
|
123
127
|
? returnColumns
|
|
124
128
|
: __spreadArray(__spreadArray([], returnColumns, true), ['Id'], false),
|
|
129
|
+
columnTypes: columnTypes.includes('Id')
|
|
130
|
+
? columnTypes
|
|
131
|
+
: __spreadArray(__spreadArray([], columnTypes, true), ['Id'], false),
|
|
125
132
|
conditions: conditions,
|
|
126
133
|
orderBy: orderBy,
|
|
127
134
|
start: start,
|
|
128
135
|
length: length,
|
|
129
|
-
|
|
136
|
+
getCount: getCount,
|
|
130
137
|
}).then(function (response) {
|
|
131
138
|
var _a;
|
|
132
139
|
var _b;
|
|
133
|
-
if (
|
|
134
|
-
currentRows.current = Array(response.
|
|
135
|
-
if (
|
|
136
|
-
|
|
140
|
+
if (getCount) {
|
|
141
|
+
currentRows.current = Array(response.count).fill(null);
|
|
142
|
+
if (getCount)
|
|
143
|
+
setCount((_b = response.count) !== null && _b !== void 0 ? _b : 0);
|
|
137
144
|
}
|
|
138
145
|
var parsedRows = props.parser
|
|
139
146
|
? response.data.map(props.parser)
|
|
@@ -146,18 +153,20 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
146
153
|
trailing: true,
|
|
147
154
|
}));
|
|
148
155
|
var loadFilterValues = (0, react_1.useCallback)(function (columnKey) {
|
|
149
|
-
var _a, _b, _c, _d, _e, _f;
|
|
156
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
150
157
|
return sqlRequest({
|
|
151
158
|
columns: columnsKeys,
|
|
152
159
|
returnColumns: [columnKey],
|
|
153
|
-
|
|
160
|
+
columnTypes: [(_a = props.columns[columnKey].type) !== null && _a !== void 0 ? _a : 'text'],
|
|
161
|
+
conditions: __spreadArray(__spreadArray([], ((_b = props.conditions) !== null && _b !== void 0 ? _b : []), true), Object.values(lodash_1.default.pickBy(conditions, function (_, key) { return key !== columnKey; })), true).filter(function (condition) { return condition.field !== columnKey; }),
|
|
154
162
|
orderBy: [
|
|
155
163
|
{
|
|
156
|
-
field: (
|
|
164
|
+
field: (_g = (_e = (_c = props.columns[columnKey].filterField) !== null && _c !== void 0 ? _c : (_d = props.columns[columnKey].field) === null || _d === void 0 ? void 0 : _d.fieldAlias) !== null && _e !== void 0 ? _e : (_f = props.columns[columnKey].field) === null || _f === void 0 ? void 0 : _f.fieldName) !== null && _g !== void 0 ? _g : columnKey,
|
|
165
|
+
type: (_h = props.columns[columnKey].type) !== null && _h !== void 0 ? _h : 'text',
|
|
157
166
|
direction: 'ASC',
|
|
158
167
|
},
|
|
159
168
|
],
|
|
160
|
-
|
|
169
|
+
getCount: false,
|
|
161
170
|
unique: true,
|
|
162
171
|
}).then(function (response) {
|
|
163
172
|
return response.data.map(function (row) { var _a, _b, _c; return (_c = (_b = (_a = props.columns[columnKey].filter) === null || _a === void 0 ? void 0 : _a.getter) === null || _b === void 0 ? void 0 : _b.call(_a, row)) !== null && _c !== void 0 ? _c : null; });
|
|
@@ -165,14 +174,14 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
165
174
|
}, [columnsKeys, conditions, props.columns, props.conditions, sqlRequest]);
|
|
166
175
|
(0, react_1.useEffect)(function () {
|
|
167
176
|
var _a, _b;
|
|
168
|
-
return loadRows.current(columnsKeys, visibleColumnsKeys, __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true), orderBy, start, length,
|
|
177
|
+
return loadRows.current(columnsKeys, visibleColumnsKeys, __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true), orderBy, start, length, count < 0);
|
|
169
178
|
}, [
|
|
170
179
|
props.columns,
|
|
171
180
|
conditions,
|
|
172
181
|
orderBy,
|
|
173
182
|
start,
|
|
174
183
|
length,
|
|
175
|
-
|
|
184
|
+
count,
|
|
176
185
|
props.conditions,
|
|
177
186
|
columnsKeys,
|
|
178
187
|
visibleColumnsKeys,
|
|
@@ -182,10 +191,11 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
182
191
|
return sqlRequest({
|
|
183
192
|
columns: columnsKeys,
|
|
184
193
|
returnColumns: visibleColumnsKeys,
|
|
194
|
+
columnTypes: columnTypes,
|
|
185
195
|
conditions: __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true),
|
|
186
196
|
orderBy: orderBy,
|
|
187
197
|
start: 0,
|
|
188
|
-
length:
|
|
198
|
+
length: count,
|
|
189
199
|
}).then(function (response) {
|
|
190
200
|
return props.parser ? response.data.map(props.parser) : response.data;
|
|
191
201
|
});
|
|
@@ -193,23 +203,27 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
193
203
|
sqlRequest,
|
|
194
204
|
columnsKeys,
|
|
195
205
|
visibleColumnsKeys,
|
|
206
|
+
columnTypes,
|
|
196
207
|
props.conditions,
|
|
197
208
|
props.parser,
|
|
198
209
|
conditions,
|
|
199
210
|
orderBy,
|
|
200
|
-
|
|
211
|
+
count,
|
|
201
212
|
]);
|
|
202
213
|
var loadAllIds = (0, react_1.useCallback)(function () {
|
|
203
214
|
var _a, _b;
|
|
204
215
|
return sqlIdRequest({
|
|
205
|
-
columns: columnsKeys
|
|
216
|
+
columns: columnsKeys.includes('Id')
|
|
217
|
+
? columnsKeys
|
|
218
|
+
: __spreadArray(__spreadArray([], columnsKeys, true), ['Id'], false),
|
|
206
219
|
returnColumns: ['Id'],
|
|
220
|
+
columnTypes: ['text'],
|
|
207
221
|
conditions: __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true),
|
|
208
222
|
orderBy: orderBy,
|
|
209
223
|
start: 0,
|
|
210
|
-
length:
|
|
224
|
+
length: count,
|
|
211
225
|
}).then(function (response) { return response.data.map(function (row) { return row['Id']; }); });
|
|
212
|
-
}, [columnsKeys, conditions, orderBy, props.conditions, sqlIdRequest,
|
|
226
|
+
}, [columnsKeys, conditions, orderBy, props.conditions, sqlIdRequest, count]);
|
|
213
227
|
var onVisibleRowsChanged = (0, react_1.useCallback)(function (newStart, newLength) {
|
|
214
228
|
if (newStart !== start || newLength !== length) {
|
|
215
229
|
setStart(newStart);
|
|
@@ -219,6 +233,64 @@ var SqlRequestDataGrid = function (_a) {
|
|
|
219
233
|
var onSelectionChange = (0, react_1.useCallback)(function (selectedKeys) {
|
|
220
234
|
onSelectionChangeFromProps === null || onSelectionChangeFromProps === void 0 ? void 0 : onSelectionChangeFromProps(selectedKeys);
|
|
221
235
|
}, [onSelectionChangeFromProps]);
|
|
222
|
-
|
|
236
|
+
/** FOOTERS */
|
|
237
|
+
var _m = (0, react_1.useState)((_c = props.initialFooters) !== null && _c !== void 0 ? _c : {}), footers = _m[0], setFooters = _m[1];
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
239
|
+
var _o = (0, react_1.useState)({}), footerData = _o[0], setFooterData = _o[1];
|
|
240
|
+
var loadFooters = (0, react_1.useCallback)(function () {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
if (Object.keys(footers).length === 0) {
|
|
243
|
+
setFooterData({});
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
sqlPartialRequest({
|
|
247
|
+
columns: columnsKeys.includes('Id')
|
|
248
|
+
? columnsKeys
|
|
249
|
+
: __spreadArray(__spreadArray([], columnsKeys, true), ['Id'], false),
|
|
250
|
+
returnColumns: [],
|
|
251
|
+
columnTypes: [],
|
|
252
|
+
totalColumns: footers,
|
|
253
|
+
conditions: __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true),
|
|
254
|
+
orderBy: orderBy,
|
|
255
|
+
}).then(function (response) { var _a; return setFooterData((_a = response.totals) !== null && _a !== void 0 ? _a : {}); });
|
|
256
|
+
}
|
|
257
|
+
}, [
|
|
258
|
+
columnsKeys,
|
|
259
|
+
conditions,
|
|
260
|
+
footers,
|
|
261
|
+
orderBy,
|
|
262
|
+
props.conditions,
|
|
263
|
+
sqlPartialRequest,
|
|
264
|
+
]);
|
|
265
|
+
(0, react_1.useEffect)(function () {
|
|
266
|
+
loadFooters();
|
|
267
|
+
}, [loadFooters]);
|
|
268
|
+
var footerFunctions = (0, react_1.useMemo)(function () {
|
|
269
|
+
return !footerData
|
|
270
|
+
? {}
|
|
271
|
+
: Object.entries(footers).reduce(function (acc, _a) {
|
|
272
|
+
var _b, _c;
|
|
273
|
+
var columnKey = _a[0], footerKey = _a[1];
|
|
274
|
+
var column = props.columns[columnKey];
|
|
275
|
+
var footerFunc = typeof (column === null || column === void 0 ? void 0 : column.footer) === 'function'
|
|
276
|
+
? column.footer
|
|
277
|
+
: (_b = column === null || column === void 0 ? void 0 : column.footer) === null || _b === void 0 ? void 0 : _b[footerKey];
|
|
278
|
+
var render = footerFunc
|
|
279
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
280
|
+
function (data) { return footerFunc([data], [], []); }
|
|
281
|
+
: (_c = column === null || column === void 0 ? void 0 : column.render) !== null && _c !== void 0 ? _c : lodash_1.default.identity;
|
|
282
|
+
if (!column) {
|
|
283
|
+
return acc;
|
|
284
|
+
}
|
|
285
|
+
acc[columnKey] = function () { return render(footerData, column); };
|
|
286
|
+
return acc;
|
|
287
|
+
}, {});
|
|
288
|
+
}, [footerData, footers, props.columns]);
|
|
289
|
+
var contextOverride = (0, react_1.useMemo)(function () { return ({
|
|
290
|
+
footers: footers,
|
|
291
|
+
setFooters: setFooters,
|
|
292
|
+
footerFunctions: footerFunctions,
|
|
293
|
+
}); }, [footers, setFooters, footerFunctions]);
|
|
294
|
+
return ((0, jsx_runtime_1.jsx)(DataGrid_1.DataGrid, __assign({ onVisibleRowsChange: onVisibleRowsChanged, filter: false, sort: false, onFiltersChanged: onFiltersChanged, onSortsChanged: onSortsChanged, filterValuesLoader: loadFilterValues, rows: rows, loadCopyRows: loadCopyRows, refresh: refresh, onSelectionChange: onSelectionChange, getAllIds: loadAllIds, contextOverride: contextOverride }, props)));
|
|
223
295
|
};
|
|
224
296
|
exports.SqlRequestDataGrid = SqlRequestDataGrid;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Divider, MenuItemContainer, SubMenu } from './styles';
|
|
2
|
+
import { FC, HTMLAttributes, PropsWithChildren } from 'react';
|
|
3
|
+
type ContextMenuFC = FC<PropsWithChildren<HTMLAttributes<HTMLDivElement>>> & {
|
|
4
|
+
Item: typeof MenuItemContainer;
|
|
5
|
+
ParentItem: typeof ParentMenuItem;
|
|
6
|
+
Divider: typeof Divider;
|
|
7
|
+
SubMenu: typeof SubMenu;
|
|
8
|
+
};
|
|
9
|
+
export declare const ContextMenu: ContextMenuFC;
|
|
10
|
+
export declare const ParentMenuItem: FC<HTMLAttributes<HTMLDivElement>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ParentMenuItem = exports.ContextMenu = void 0;
|
|
26
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
var styles_1 = require("./styles");
|
|
28
|
+
var react_1 = require("react");
|
|
29
|
+
var ContextMenu = function (_a) {
|
|
30
|
+
var children = _a.children;
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.MenuContainer, { onClick: function (e) { return e.stopPropagation(); }, children: children }));
|
|
32
|
+
};
|
|
33
|
+
exports.ContextMenu = ContextMenu;
|
|
34
|
+
var ParentMenuItem = function (_a) {
|
|
35
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
36
|
+
var _b = (0, react_1.useState)(false), isOpened = _b[0], setIsOpened = _b[1];
|
|
37
|
+
var _c = (0, react_1.useState)(null), currentTimeout = _c[0], setCurrentTimeout = _c[1];
|
|
38
|
+
var stopTimeout = (0, react_1.useCallback)(function () {
|
|
39
|
+
if (currentTimeout) {
|
|
40
|
+
clearTimeout(currentTimeout);
|
|
41
|
+
}
|
|
42
|
+
setCurrentTimeout(null);
|
|
43
|
+
}, [currentTimeout]);
|
|
44
|
+
var startTimeout = (0, react_1.useCallback)(function (open) {
|
|
45
|
+
stopTimeout();
|
|
46
|
+
setCurrentTimeout(window.setTimeout(function () {
|
|
47
|
+
setIsOpened(open);
|
|
48
|
+
}, open ? 100 : 300));
|
|
49
|
+
}, [stopTimeout]);
|
|
50
|
+
var open = (0, react_1.useCallback)(function () { return startTimeout(true); }, [startTimeout]);
|
|
51
|
+
var close = (0, react_1.useCallback)(function () { return startTimeout(false); }, [startTimeout]);
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.MenuItemContainer, __assign({}, props, { className: isOpened ? 'opened' : '', onMouseEnter: open, onMouseLeave: close, "$withArrow": true, children: children })));
|
|
53
|
+
};
|
|
54
|
+
exports.ParentMenuItem = ParentMenuItem;
|
|
55
|
+
exports.ContextMenu.Item = styles_1.MenuItemContainer;
|
|
56
|
+
exports.ContextMenu.ParentItem = exports.ParentMenuItem;
|
|
57
|
+
exports.ContextMenu.Divider = styles_1.Divider;
|
|
58
|
+
exports.ContextMenu.SubMenu = styles_1.SubMenu;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ThemeColor } from '../../../providers/ThemeProvider/types';
|
|
2
|
+
export declare const MenuContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
4
|
+
}>, never>, never>> & string;
|
|
5
|
+
export declare const SubMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
6
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
7
|
+
}>, never>, never>> & string;
|
|
8
|
+
export declare const MenuItemContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
9
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
10
|
+
}>, never>, {
|
|
11
|
+
$color?: ThemeColor;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
$withArrow?: boolean;
|
|
14
|
+
$opened?: boolean;
|
|
15
|
+
}>> & string;
|
|
16
|
+
export declare const Divider: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
17
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
18
|
+
}>, never>, never>> & string;
|