@deviceinsight/ng-ui-components 6.19.0 → 6.20.0
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/lib/cjs/assets/style.css +3 -2
- package/lib/cjs/components/reactable/helpers/ReactableTable.d.ts +6 -8
- package/lib/cjs/components/reactable/helpers/ReactableTable.d.ts.map +1 -1
- package/lib/cjs/components/reactable/helpers/ReactableTable.js +43 -27
- package/lib/esm/assets/style.css +3 -2
- package/lib/esm/components/reactable/helpers/ReactableTable.d.ts +6 -8
- package/lib/esm/components/reactable/helpers/ReactableTable.d.ts.map +1 -1
- package/lib/esm/components/reactable/helpers/ReactableTable.js +43 -26
- package/lib/esm/src/components/reactable/helpers/ReactableTable.d.ts +6 -8
- package/lib/esm/src/components/reactable/helpers/ReactableTable.d.ts.map +1 -1
- package/lib/esm/src/components/reactable/helpers/ReactableTable.js +43 -26
- package/package.json +1 -1
package/lib/cjs/assets/style.css
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* UI Components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
/* ColorPicker */
|
|
8
7
|
.di.color-picker {margin:-5px -10px; padding:0}
|
|
9
8
|
.di.color-picker .color {width:20%; padding:15px; float:left; position:relative; transition: transform .1s ease; cursor:pointer;}
|
|
@@ -70,7 +69,6 @@
|
|
|
70
69
|
.di.reactable.sortable th.sortable:hover::after {content: url('./svg/triangle_up_and_down.svg'); position:absolute; padding:0 0 0 0px; margin-left:1px; filter:opacity(0.3); width:16px; height:16px;}
|
|
71
70
|
.di.reactable.sortable th.sortable.sortAsc::after {content: url('./svg/triangle_up.svg'); position:absolute; padding:0 0 0 0px; margin-left:2px; width:16px; height:16px;filter:none;}
|
|
72
71
|
.di.reactable.sortable th.sortable.sortDes::after {content: url('./svg/triangle_down.svg'); position:absolute; padding:0 0 0 0px; margin-left:2px; width:16px; height:16px;filter:none;}
|
|
73
|
-
/* TODO filterrow form styles */
|
|
74
72
|
|
|
75
73
|
/* Upload */
|
|
76
74
|
.di.upload,
|
|
@@ -253,3 +251,6 @@
|
|
|
253
251
|
.di.slider .rc-slider-handle {border-color: var(--primary-color, #1a8ed3);}
|
|
254
252
|
.di.slider .rc-slider-dot-active {border-color: var(--primary-color, #1a8ed3);}
|
|
255
253
|
.di.slider .rc-slider-handle:active {box-shadow: 0 0 5px var(--primary-color, #1a8ed3);}
|
|
254
|
+
|
|
255
|
+
.di.modal.scroll-horizontally-advice {padding-top: 40vh}
|
|
256
|
+
.di.modal.scroll-horizontally-advice .modal-content .scroll-horizontally-advice-buttons {text-align: right; margin-top: 16px;}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ReactableColumnDef, ReactableRowDef, ReactableFilterSettings } from '../types';
|
|
3
3
|
import { Pageable, PaginationSettings, SortDirection } from '../../../types/pagination';
|
|
4
4
|
declare type Props<T, ID extends string | number | undefined | null> = {
|
|
5
|
-
columnDefs:
|
|
6
|
-
uniqueItemKey: (
|
|
5
|
+
columnDefs: ReactableColumnDef<T>[];
|
|
6
|
+
uniqueItemKey: (item: T) => ID;
|
|
7
7
|
paginationSettings: PaginationSettings;
|
|
8
8
|
onSort: (property: string, direction: SortDirection) => void;
|
|
9
9
|
onFilter?: (filterSettings: ReactableFilterSettings) => void;
|
|
10
|
-
pageable
|
|
10
|
+
pageable?: Pageable<T> | null;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
rowDef?: ReactableRowDef<T>;
|
|
13
13
|
clickable?: boolean;
|
|
14
14
|
messageWhenEmpty?: string;
|
|
15
15
|
'data-testid'?: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
17
|
+
declare const ReactableTable: <T, ID extends string | number | null | undefined>({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, "data-testid": testId }: Props<T, ID>) => React.JSX.Element;
|
|
18
|
+
export default ReactableTable;
|
|
21
19
|
//# sourceMappingURL=ReactableTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactableTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/reactable/helpers/ReactableTable.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ReactableTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/reactable/helpers/ReactableTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAQzD,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAE,uBAAuB,EAAC,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAGtF,aAAK,KAAK,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI;IAC9D,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IAC/B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,QAAA,MAAM,cAAc,6OAgHnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -26,37 +26,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
30
|
const i18n_1 = require("../../../i18n");
|
|
31
31
|
const classnames_1 = __importDefault(require("classnames"));
|
|
32
32
|
const ng_ui_basic_components_1 = require("@deviceinsight/ng-ui-basic-components");
|
|
33
33
|
const ReactableTableRow_1 = __importDefault(require("./ReactableTableRow"));
|
|
34
34
|
const ReactableTableHeader_1 = __importDefault(require("./ReactableTableHeader"));
|
|
35
35
|
const ReactableTableFilterRow_1 = __importDefault(require("./ReactableTableFilterRow"));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
36
|
+
const ng_ui_api_client_1 = require("@deviceinsight/ng-ui-api-client");
|
|
37
|
+
const ReactableTable = ({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, 'data-testid': testId }) => {
|
|
38
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
39
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
40
|
+
const [showHorizontalScrollingAdvice, setShowHorizontalScrollingAdvice] = (0, react_1.useState)(true);
|
|
41
|
+
const HIDE_SCROLLING_ADVICE_PATH = 'uiConfigurations/hidescrollingadvice';
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
(0, ng_ui_api_client_1.readAccountObject)(HIDE_SCROLLING_ADVICE_PATH).then((value) => setShowHorizontalScrollingAdvice(value === undefined ? false : !value));
|
|
44
|
+
}, []);
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
const updateScrollingAdvice = () => {
|
|
47
|
+
if (containerRef.current && tableRef.current) {
|
|
48
|
+
setShowHorizontalScrollingAdvice(showHorizontalScrollingAdvice && tableRef.current.scrollWidth > containerRef.current.offsetWidth);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
window.addEventListener('resize', updateScrollingAdvice);
|
|
52
|
+
return () => window.removeEventListener('resize', updateScrollingAdvice);
|
|
53
|
+
}, [pageable, columnDefs, showHorizontalScrollingAdvice]);
|
|
54
|
+
const showFilterRow = columnDefs.some((col) => col.filterable);
|
|
55
|
+
return (react_1.default.createElement(ng_ui_basic_components_1.SpinnerContainer, { show: isLoading },
|
|
56
|
+
react_1.default.createElement("div", { ref: containerRef, className: "di reactable scroll-x" },
|
|
57
|
+
showHorizontalScrollingAdvice && (react_1.default.createElement(ng_ui_basic_components_1.Modal, { className: "scroll-horizontally-advice", header: react_1.default.createElement(i18n_1.Trans, { i18nKey: "reactable.scrollHorizontally.advice" }, "SHIFT + mouse wheel to scroll horizontally"), content: react_1.default.createElement("div", { className: "scroll-horizontally-advice-buttons" },
|
|
58
|
+
react_1.default.createElement(ng_ui_basic_components_1.Button, { primary: true, onClick: async () => {
|
|
59
|
+
await (0, ng_ui_api_client_1.writeAccountObject)(HIDE_SCROLLING_ADVICE_PATH, true);
|
|
60
|
+
setShowHorizontalScrollingAdvice(false);
|
|
61
|
+
} },
|
|
62
|
+
react_1.default.createElement(i18n_1.Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain" }, "Never show again")),
|
|
63
|
+
react_1.default.createElement(ng_ui_basic_components_1.Button, { onClick: () => setShowHorizontalScrollingAdvice(false) },
|
|
64
|
+
react_1.default.createElement(i18n_1.Trans, { i18nKey: "reactable.scrollHorizontally.ok" }, "OK"))), width: '40%' })),
|
|
65
|
+
react_1.default.createElement("table", { ref: tableRef, className: (0, classnames_1.default)('di reactable sortable hoverable', { selectable: clickable }), "data-testid": testId },
|
|
66
|
+
react_1.default.createElement("thead", null,
|
|
67
|
+
react_1.default.createElement(ReactableTableHeader_1.default, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
|
|
68
|
+
react_1.default.createElement("tbody", null,
|
|
69
|
+
onFilter && showFilterRow && (react_1.default.createElement(ReactableTableFilterRow_1.default, { columnDefs: columnDefs, onFilter: onFilter })),
|
|
70
|
+
pageable?.content.length
|
|
71
|
+
? pageable.content
|
|
72
|
+
.slice(0, paginationSettings.size)
|
|
73
|
+
.map((item) => (react_1.default.createElement(ReactableTableRow_1.default, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef })))
|
|
74
|
+
: !isLoading && (react_1.default.createElement("tr", null,
|
|
75
|
+
react_1.default.createElement("td", { colSpan: columnDefs.length },
|
|
76
|
+
react_1.default.createElement(i18n_1.Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
|
|
77
|
+
};
|
|
62
78
|
exports.default = ReactableTable;
|
package/lib/esm/assets/style.css
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* UI Components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
/* ColorPicker */
|
|
8
7
|
.di.color-picker {margin:-5px -10px; padding:0}
|
|
9
8
|
.di.color-picker .color {width:20%; padding:15px; float:left; position:relative; transition: transform .1s ease; cursor:pointer;}
|
|
@@ -70,7 +69,6 @@
|
|
|
70
69
|
.di.reactable.sortable th.sortable:hover::after {content: url('./svg/triangle_up_and_down.svg'); position:absolute; padding:0 0 0 0px; margin-left:1px; filter:opacity(0.3); width:16px; height:16px;}
|
|
71
70
|
.di.reactable.sortable th.sortable.sortAsc::after {content: url('./svg/triangle_up.svg'); position:absolute; padding:0 0 0 0px; margin-left:2px; width:16px; height:16px;filter:none;}
|
|
72
71
|
.di.reactable.sortable th.sortable.sortDes::after {content: url('./svg/triangle_down.svg'); position:absolute; padding:0 0 0 0px; margin-left:2px; width:16px; height:16px;filter:none;}
|
|
73
|
-
/* TODO filterrow form styles */
|
|
74
72
|
|
|
75
73
|
/* Upload */
|
|
76
74
|
.di.upload,
|
|
@@ -253,3 +251,6 @@
|
|
|
253
251
|
.di.slider .rc-slider-handle {border-color: var(--primary-color, #1a8ed3);}
|
|
254
252
|
.di.slider .rc-slider-dot-active {border-color: var(--primary-color, #1a8ed3);}
|
|
255
253
|
.di.slider .rc-slider-handle:active {box-shadow: 0 0 5px var(--primary-color, #1a8ed3);}
|
|
254
|
+
|
|
255
|
+
.di.modal.scroll-horizontally-advice {padding-top: 40vh}
|
|
256
|
+
.di.modal.scroll-horizontally-advice .modal-content .scroll-horizontally-advice-buttons {text-align: right; margin-top: 16px;}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ReactableColumnDef, ReactableRowDef, ReactableFilterSettings } from '../types';
|
|
3
3
|
import { Pageable, PaginationSettings, SortDirection } from '../../../types/pagination';
|
|
4
4
|
declare type Props<T, ID extends string | number | undefined | null> = {
|
|
5
|
-
columnDefs:
|
|
6
|
-
uniqueItemKey: (
|
|
5
|
+
columnDefs: ReactableColumnDef<T>[];
|
|
6
|
+
uniqueItemKey: (item: T) => ID;
|
|
7
7
|
paginationSettings: PaginationSettings;
|
|
8
8
|
onSort: (property: string, direction: SortDirection) => void;
|
|
9
9
|
onFilter?: (filterSettings: ReactableFilterSettings) => void;
|
|
10
|
-
pageable
|
|
10
|
+
pageable?: Pageable<T> | null;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
rowDef?: ReactableRowDef<T>;
|
|
13
13
|
clickable?: boolean;
|
|
14
14
|
messageWhenEmpty?: string;
|
|
15
15
|
'data-testid'?: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
17
|
+
declare const ReactableTable: <T, ID extends string | number | null | undefined>({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, "data-testid": testId }: Props<T, ID>) => React.JSX.Element;
|
|
18
|
+
export default ReactableTable;
|
|
21
19
|
//# sourceMappingURL=ReactableTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactableTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/reactable/helpers/ReactableTable.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ReactableTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/reactable/helpers/ReactableTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAQzD,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAE,uBAAuB,EAAC,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAGtF,aAAK,KAAK,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI;IAC9D,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IAC/B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,QAAA,MAAM,cAAc,6OAgHnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,33 +1,50 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
2
2
|
import { Trans } from '../../../i18n';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
-
import { SpinnerContainer } from '@deviceinsight/ng-ui-basic-components';
|
|
4
|
+
import { Button, Modal, SpinnerContainer } from '@deviceinsight/ng-ui-basic-components';
|
|
5
5
|
import ReactableTableRow from './ReactableTableRow';
|
|
6
6
|
import ReactableTableHeader from './ReactableTableHeader';
|
|
7
7
|
import ReactableTableFilterRow from './ReactableTableFilterRow';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
import { readAccountObject, writeAccountObject } from '@deviceinsight/ng-ui-api-client';
|
|
9
|
+
const ReactableTable = ({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, 'data-testid': testId }) => {
|
|
10
|
+
const containerRef = useRef(null);
|
|
11
|
+
const tableRef = useRef(null);
|
|
12
|
+
const [showHorizontalScrollingAdvice, setShowHorizontalScrollingAdvice] = useState(true);
|
|
13
|
+
const HIDE_SCROLLING_ADVICE_PATH = 'uiConfigurations/hidescrollingadvice';
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
readAccountObject(HIDE_SCROLLING_ADVICE_PATH).then((value) => setShowHorizontalScrollingAdvice(value === undefined ? false : !value));
|
|
16
|
+
}, []);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const updateScrollingAdvice = () => {
|
|
19
|
+
if (containerRef.current && tableRef.current) {
|
|
20
|
+
setShowHorizontalScrollingAdvice(showHorizontalScrollingAdvice && tableRef.current.scrollWidth > containerRef.current.offsetWidth);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
window.addEventListener('resize', updateScrollingAdvice);
|
|
24
|
+
return () => window.removeEventListener('resize', updateScrollingAdvice);
|
|
25
|
+
}, [pageable, columnDefs, showHorizontalScrollingAdvice]);
|
|
26
|
+
const showFilterRow = columnDefs.some((col) => col.filterable);
|
|
27
|
+
return (React.createElement(SpinnerContainer, { show: isLoading },
|
|
28
|
+
React.createElement("div", { ref: containerRef, className: "di reactable scroll-x" },
|
|
29
|
+
showHorizontalScrollingAdvice && (React.createElement(Modal, { className: "scroll-horizontally-advice", header: React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.advice" }, "SHIFT + mouse wheel to scroll horizontally"), content: React.createElement("div", { className: "scroll-horizontally-advice-buttons" },
|
|
30
|
+
React.createElement(Button, { primary: true, onClick: async () => {
|
|
31
|
+
await writeAccountObject(HIDE_SCROLLING_ADVICE_PATH, true);
|
|
32
|
+
setShowHorizontalScrollingAdvice(false);
|
|
33
|
+
} },
|
|
34
|
+
React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain" }, "Never show again")),
|
|
35
|
+
React.createElement(Button, { onClick: () => setShowHorizontalScrollingAdvice(false) },
|
|
36
|
+
React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.ok" }, "OK"))), width: '40%' })),
|
|
37
|
+
React.createElement("table", { ref: tableRef, className: cx('di reactable sortable hoverable', { selectable: clickable }), "data-testid": testId },
|
|
38
|
+
React.createElement("thead", null,
|
|
39
|
+
React.createElement(ReactableTableHeader, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
|
|
40
|
+
React.createElement("tbody", null,
|
|
41
|
+
onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow, { columnDefs: columnDefs, onFilter: onFilter })),
|
|
42
|
+
pageable?.content.length
|
|
43
|
+
? pageable.content
|
|
44
|
+
.slice(0, paginationSettings.size)
|
|
45
|
+
.map((item) => (React.createElement(ReactableTableRow, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef })))
|
|
46
|
+
: !isLoading && (React.createElement("tr", null,
|
|
30
47
|
React.createElement("td", { colSpan: columnDefs.length },
|
|
31
48
|
React.createElement(Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
};
|
|
50
|
+
export default ReactableTable;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ReactableColumnDef, ReactableRowDef, ReactableFilterSettings } from '../types';
|
|
3
3
|
import { Pageable, PaginationSettings, SortDirection } from '../../../types/pagination';
|
|
4
4
|
declare type Props<T, ID extends string | number | undefined | null> = {
|
|
5
|
-
columnDefs:
|
|
6
|
-
uniqueItemKey: (
|
|
5
|
+
columnDefs: ReactableColumnDef<T>[];
|
|
6
|
+
uniqueItemKey: (item: T) => ID;
|
|
7
7
|
paginationSettings: PaginationSettings;
|
|
8
8
|
onSort: (property: string, direction: SortDirection) => void;
|
|
9
9
|
onFilter?: (filterSettings: ReactableFilterSettings) => void;
|
|
10
|
-
pageable
|
|
10
|
+
pageable?: Pageable<T> | null;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
rowDef?: ReactableRowDef<T>;
|
|
13
13
|
clickable?: boolean;
|
|
14
14
|
messageWhenEmpty?: string;
|
|
15
15
|
'data-testid'?: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
17
|
+
declare const ReactableTable: <T, ID extends string | number | null | undefined>({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, "data-testid": testId }: Props<T, ID>) => React.JSX.Element;
|
|
18
|
+
export default ReactableTable;
|
|
21
19
|
//# sourceMappingURL=ReactableTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactableTable.d.ts","sourceRoot":"","sources":["../../../../../../src/components/reactable/helpers/ReactableTable.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ReactableTable.d.ts","sourceRoot":"","sources":["../../../../../../src/components/reactable/helpers/ReactableTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAQzD,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAE,uBAAuB,EAAC,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAGtF,aAAK,KAAK,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI;IAC9D,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IAC/B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,QAAA,MAAM,cAAc,6OAgHnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,33 +1,50 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
2
2
|
import { Trans } from '../../../i18n';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
-
import { SpinnerContainer } from '@deviceinsight/ng-ui-basic-components';
|
|
4
|
+
import { Button, Modal, SpinnerContainer } from '@deviceinsight/ng-ui-basic-components';
|
|
5
5
|
import ReactableTableRow from './ReactableTableRow';
|
|
6
6
|
import ReactableTableHeader from './ReactableTableHeader';
|
|
7
7
|
import ReactableTableFilterRow from './ReactableTableFilterRow';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
import { readAccountObject, writeAccountObject } from '@deviceinsight/ng-ui-api-client';
|
|
9
|
+
const ReactableTable = ({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, 'data-testid': testId }) => {
|
|
10
|
+
const containerRef = useRef(null);
|
|
11
|
+
const tableRef = useRef(null);
|
|
12
|
+
const [showHorizontalScrollingAdvice, setShowHorizontalScrollingAdvice] = useState(true);
|
|
13
|
+
const HIDE_SCROLLING_ADVICE_PATH = 'uiConfigurations/hidescrollingadvice';
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
readAccountObject(HIDE_SCROLLING_ADVICE_PATH).then((value) => setShowHorizontalScrollingAdvice(value === undefined ? false : !value));
|
|
16
|
+
}, []);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const updateScrollingAdvice = () => {
|
|
19
|
+
if (containerRef.current && tableRef.current) {
|
|
20
|
+
setShowHorizontalScrollingAdvice(showHorizontalScrollingAdvice && tableRef.current.scrollWidth > containerRef.current.offsetWidth);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
window.addEventListener('resize', updateScrollingAdvice);
|
|
24
|
+
return () => window.removeEventListener('resize', updateScrollingAdvice);
|
|
25
|
+
}, [pageable, columnDefs, showHorizontalScrollingAdvice]);
|
|
26
|
+
const showFilterRow = columnDefs.some((col) => col.filterable);
|
|
27
|
+
return (React.createElement(SpinnerContainer, { show: isLoading },
|
|
28
|
+
React.createElement("div", { ref: containerRef, className: "di reactable scroll-x" },
|
|
29
|
+
showHorizontalScrollingAdvice && (React.createElement(Modal, { className: "scroll-horizontally-advice", header: React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.advice" }, "SHIFT + mouse wheel to scroll horizontally"), content: React.createElement("div", { className: "scroll-horizontally-advice-buttons" },
|
|
30
|
+
React.createElement(Button, { primary: true, onClick: async () => {
|
|
31
|
+
await writeAccountObject(HIDE_SCROLLING_ADVICE_PATH, true);
|
|
32
|
+
setShowHorizontalScrollingAdvice(false);
|
|
33
|
+
} },
|
|
34
|
+
React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain" }, "Never show again")),
|
|
35
|
+
React.createElement(Button, { onClick: () => setShowHorizontalScrollingAdvice(false) },
|
|
36
|
+
React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.ok" }, "OK"))), width: '40%' })),
|
|
37
|
+
React.createElement("table", { ref: tableRef, className: cx('di reactable sortable hoverable', { selectable: clickable }), "data-testid": testId },
|
|
38
|
+
React.createElement("thead", null,
|
|
39
|
+
React.createElement(ReactableTableHeader, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
|
|
40
|
+
React.createElement("tbody", null,
|
|
41
|
+
onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow, { columnDefs: columnDefs, onFilter: onFilter })),
|
|
42
|
+
pageable?.content.length
|
|
43
|
+
? pageable.content
|
|
44
|
+
.slice(0, paginationSettings.size)
|
|
45
|
+
.map((item) => (React.createElement(ReactableTableRow, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef })))
|
|
46
|
+
: !isLoading && (React.createElement("tr", null,
|
|
30
47
|
React.createElement("td", { colSpan: columnDefs.length },
|
|
31
48
|
React.createElement(Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
};
|
|
50
|
+
export default ReactableTable;
|