@deviceinsight/ng-ui-components 6.19.0 → 6.21.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.
@@ -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: 24px;}
@@ -1,21 +1,19 @@
1
- import * as React from 'react';
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: Array<ReactableColumnDef<T>>;
6
- uniqueItemKey: (arg0: T) => ID;
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: Pageable<T> | null | undefined;
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
- export default class ReactableTable<T = any, ID extends string | number | undefined | null = any> extends React.Component<Props<T, ID>> {
18
- render(): React.JSX.Element;
19
- }
17
+ export default function ReactableTable<T, ID extends string | number | undefined | null>({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, 'data-testid': testId }: Props<T, ID>): React.JSX.Element;
20
18
  export {};
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,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAE,uBAAuB,EAAC,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAEtF,aAAK,KAAK,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI;IAC9D,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IAC/B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EA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Aa,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,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,EAAE,EACxF,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,aAAa,EAAE,MAAM,EACrB,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,qBA+Gd"}
@@ -26,37 +26,67 @@ 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 React = __importStar(require("react"));
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
- class ReactableTable extends React.Component {
37
- render() {
38
- const { columnDefs, rowDef, uniqueItemKey, paginationSettings, pageable, onSort, onFilter, isLoading, clickable, messageWhenEmpty } = this.props;
39
- const showFilterRow = columnDefs.some((columnDef) => !!columnDef.filterable);
40
- return (React.createElement(ng_ui_basic_components_1.SpinnerContainer, { show: isLoading },
41
- React.createElement("div", { className: "di reactable scroll-x" },
42
- React.createElement("table", { className: (0, classnames_1.default)('di reactable sortable hoverable', { selectable: clickable }), "data-testid": this.props['data-testid'] },
43
- React.createElement("thead", null,
44
- React.createElement(ReactableTableHeader_1.default, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
45
- React.createElement("tbody", null,
46
- onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow_1.default, { columnDefs: columnDefs, onFilter: onFilter })),
47
- pageable &&
48
- pageable.content.length > 0 &&
49
- pageable.content.map((item, index) => {
50
- if (paginationSettings.size > index) {
51
- return (React.createElement(ReactableTableRow_1.default, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef }));
52
- }
53
- else {
54
- return null;
55
- }
56
- }),
57
- (!pageable || !pageable.content.length) && !isLoading && (React.createElement("tr", null,
58
- React.createElement("td", { colSpan: columnDefs.length },
59
- React.createElement(i18n_1.Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
60
- }
36
+ const ng_ui_api_client_1 = require("@deviceinsight/ng-ui-api-client");
37
+ function 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 [showScrollingAdvice, setShowScrollingAdvice] = (0, react_1.useState)(false);
41
+ const [neverShowScrollingAdvice, setNeverShowScrollingAdvice] = (0, react_1.useState)(false);
42
+ const HIDE_SCROLLING_ADVICE_PATH = 'uiConfigurations/nevershowscrollingadvice';
43
+ const neverShowScrollingAdviceRef = (0, react_1.useRef)(neverShowScrollingAdvice);
44
+ (0, react_1.useEffect)(() => {
45
+ neverShowScrollingAdviceRef.current = neverShowScrollingAdvice;
46
+ }, [neverShowScrollingAdvice]);
47
+ const updateScrollingAdvice = () => {
48
+ if (containerRef.current && tableRef.current) {
49
+ setShowScrollingAdvice(!neverShowScrollingAdviceRef.current && tableRef.current.scrollWidth > containerRef.current.offsetWidth);
50
+ }
51
+ };
52
+ (0, react_1.useEffect)(() => {
53
+ (0, ng_ui_api_client_1.readAccountObject)(HIDE_SCROLLING_ADVICE_PATH).then((value) => {
54
+ setNeverShowScrollingAdvice(value === undefined ? false : value);
55
+ if (containerRef.current && tableRef.current) {
56
+ updateScrollingAdvice();
57
+ }
58
+ });
59
+ }, []);
60
+ (0, react_1.useEffect)(() => {
61
+ updateScrollingAdvice();
62
+ window.addEventListener('resize', updateScrollingAdvice);
63
+ return () => window.removeEventListener('resize', updateScrollingAdvice);
64
+ }, [pageable, columnDefs]);
65
+ const showFilterRow = columnDefs.some((col) => col.filterable);
66
+ return (react_1.default.createElement(ng_ui_basic_components_1.SpinnerContainer, { show: isLoading },
67
+ react_1.default.createElement("div", { ref: containerRef, className: "di reactable scroll-x" },
68
+ showScrollingAdvice && !isLoading && (react_1.default.createElement(ng_ui_basic_components_1.Modal, { className: "scroll-horizontally-advice", content: react_1.default.createElement("div", null,
69
+ react_1.default.createElement(i18n_1.Trans, { i18nKey: "reactable.scrollHorizontally.advice" }, "SHIFT + mouse wheel to scroll horizontally"),
70
+ react_1.default.createElement("div", { className: "scroll-horizontally-advice-buttons" },
71
+ react_1.default.createElement(ng_ui_basic_components_1.Button, { primary: true, onClick: async () => {
72
+ await (0, ng_ui_api_client_1.writeAccountObject)(HIDE_SCROLLING_ADVICE_PATH, true);
73
+ setNeverShowScrollingAdvice(true);
74
+ setShowScrollingAdvice(false);
75
+ } },
76
+ react_1.default.createElement(i18n_1.Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain" }, "Never show again")),
77
+ react_1.default.createElement(ng_ui_basic_components_1.Button, { onClick: () => setShowScrollingAdvice(false) },
78
+ react_1.default.createElement(i18n_1.Trans, { i18nKey: "reactable.scrollHorizontally.ok" }, "OK")))), width: '40%' })),
79
+ react_1.default.createElement("table", { ref: tableRef, className: (0, classnames_1.default)('di reactable sortable hoverable', { selectable: clickable }), "data-testid": testId },
80
+ react_1.default.createElement("thead", null,
81
+ react_1.default.createElement(ReactableTableHeader_1.default, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
82
+ react_1.default.createElement("tbody", null,
83
+ onFilter && showFilterRow && (react_1.default.createElement(ReactableTableFilterRow_1.default, { columnDefs: columnDefs, onFilter: onFilter })),
84
+ pageable?.content.length
85
+ ? pageable.content
86
+ .slice(0, paginationSettings.size)
87
+ .map((item) => (react_1.default.createElement(ReactableTableRow_1.default, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef })))
88
+ : !isLoading && (react_1.default.createElement("tr", null,
89
+ react_1.default.createElement("td", { colSpan: columnDefs.length },
90
+ react_1.default.createElement(i18n_1.Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
61
91
  }
62
92
  exports.default = ReactableTable;
@@ -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: 24px;}
@@ -1,21 +1,19 @@
1
- import * as React from 'react';
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: Array<ReactableColumnDef<T>>;
6
- uniqueItemKey: (arg0: T) => ID;
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: Pageable<T> | null | undefined;
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
- export default class ReactableTable<T = any, ID extends string | number | undefined | null = any> extends React.Component<Props<T, ID>> {
18
- render(): React.JSX.Element;
19
- }
17
+ export default function ReactableTable<T, ID extends string | number | undefined | null>({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, 'data-testid': testId }: Props<T, ID>): React.JSX.Element;
20
18
  export {};
21
19
  //# sourceMappingURL=ReactableTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactableTable.d.ts","sourceR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EAAE,CAAC,qBA+Gd"}
@@ -1,33 +1,63 @@
1
- import * as React from 'react';
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
- export default class ReactableTable extends React.Component {
9
- render() {
10
- const { columnDefs, rowDef, uniqueItemKey, paginationSettings, pageable, onSort, onFilter, isLoading, clickable, messageWhenEmpty } = this.props;
11
- const showFilterRow = columnDefs.some((columnDef) => !!columnDef.filterable);
12
- return (React.createElement(SpinnerContainer, { show: isLoading },
13
- React.createElement("div", { className: "di reactable scroll-x" },
14
- React.createElement("table", { className: cx('di reactable sortable hoverable', { selectable: clickable }), "data-testid": this.props['data-testid'] },
15
- React.createElement("thead", null,
16
- React.createElement(ReactableTableHeader, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
17
- React.createElement("tbody", null,
18
- onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow, { columnDefs: columnDefs, onFilter: onFilter })),
19
- pageable &&
20
- pageable.content.length > 0 &&
21
- pageable.content.map((item, index) => {
22
- if (paginationSettings.size > index) {
23
- return (React.createElement(ReactableTableRow, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef }));
24
- }
25
- else {
26
- return null;
27
- }
28
- }),
29
- (!pageable || !pageable.content.length) && !isLoading && (React.createElement("tr", null,
8
+ import { readAccountObject, writeAccountObject } from '@deviceinsight/ng-ui-api-client';
9
+ export default function 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 [showScrollingAdvice, setShowScrollingAdvice] = useState(false);
13
+ const [neverShowScrollingAdvice, setNeverShowScrollingAdvice] = useState(false);
14
+ const HIDE_SCROLLING_ADVICE_PATH = 'uiConfigurations/nevershowscrollingadvice';
15
+ const neverShowScrollingAdviceRef = useRef(neverShowScrollingAdvice);
16
+ useEffect(() => {
17
+ neverShowScrollingAdviceRef.current = neverShowScrollingAdvice;
18
+ }, [neverShowScrollingAdvice]);
19
+ const updateScrollingAdvice = () => {
20
+ if (containerRef.current && tableRef.current) {
21
+ setShowScrollingAdvice(!neverShowScrollingAdviceRef.current && tableRef.current.scrollWidth > containerRef.current.offsetWidth);
22
+ }
23
+ };
24
+ useEffect(() => {
25
+ readAccountObject(HIDE_SCROLLING_ADVICE_PATH).then((value) => {
26
+ setNeverShowScrollingAdvice(value === undefined ? false : value);
27
+ if (containerRef.current && tableRef.current) {
28
+ updateScrollingAdvice();
29
+ }
30
+ });
31
+ }, []);
32
+ useEffect(() => {
33
+ updateScrollingAdvice();
34
+ window.addEventListener('resize', updateScrollingAdvice);
35
+ return () => window.removeEventListener('resize', updateScrollingAdvice);
36
+ }, [pageable, columnDefs]);
37
+ const showFilterRow = columnDefs.some((col) => col.filterable);
38
+ return (React.createElement(SpinnerContainer, { show: isLoading },
39
+ React.createElement("div", { ref: containerRef, className: "di reactable scroll-x" },
40
+ showScrollingAdvice && !isLoading && (React.createElement(Modal, { className: "scroll-horizontally-advice", content: React.createElement("div", null,
41
+ React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.advice" }, "SHIFT + mouse wheel to scroll horizontally"),
42
+ React.createElement("div", { className: "scroll-horizontally-advice-buttons" },
43
+ React.createElement(Button, { primary: true, onClick: async () => {
44
+ await writeAccountObject(HIDE_SCROLLING_ADVICE_PATH, true);
45
+ setNeverShowScrollingAdvice(true);
46
+ setShowScrollingAdvice(false);
47
+ } },
48
+ React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain" }, "Never show again")),
49
+ React.createElement(Button, { onClick: () => setShowScrollingAdvice(false) },
50
+ React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.ok" }, "OK")))), width: '40%' })),
51
+ React.createElement("table", { ref: tableRef, className: cx('di reactable sortable hoverable', { selectable: clickable }), "data-testid": testId },
52
+ React.createElement("thead", null,
53
+ React.createElement(ReactableTableHeader, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
54
+ React.createElement("tbody", null,
55
+ onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow, { columnDefs: columnDefs, onFilter: onFilter })),
56
+ pageable?.content.length
57
+ ? pageable.content
58
+ .slice(0, paginationSettings.size)
59
+ .map((item) => (React.createElement(ReactableTableRow, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef })))
60
+ : !isLoading && (React.createElement("tr", null,
30
61
  React.createElement("td", { colSpan: columnDefs.length },
31
62
  React.createElement(Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
32
- }
33
63
  }
@@ -1,21 +1,19 @@
1
- import * as React from 'react';
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: Array<ReactableColumnDef<T>>;
6
- uniqueItemKey: (arg0: T) => ID;
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: Pageable<T> | null | undefined;
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
- export default class ReactableTable<T = any, ID extends string | number | undefined | null = any> extends React.Component<Props<T, ID>> {
18
- render(): React.JSX.Element;
19
- }
17
+ export default function ReactableTable<T, ID extends string | number | undefined | null>({ columnDefs, uniqueItemKey, paginationSettings, onSort, onFilter, pageable, isLoading, rowDef, clickable, messageWhenEmpty, 'data-testid': testId }: Props<T, ID>): React.JSX.Element;
20
18
  export {};
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,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAE,uBAAuB,EAAC,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAEtF,aAAK,KAAK,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI;IAC9D,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,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,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,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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AC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,EAAE,EACxF,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,aAAa,EAAE,MAAM,EACrB,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,qBA+Gd"}
@@ -1,33 +1,63 @@
1
- import * as React from 'react';
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
- export default class ReactableTable extends React.Component {
9
- render() {
10
- const { columnDefs, rowDef, uniqueItemKey, paginationSettings, pageable, onSort, onFilter, isLoading, clickable, messageWhenEmpty } = this.props;
11
- const showFilterRow = columnDefs.some((columnDef) => !!columnDef.filterable);
12
- return (React.createElement(SpinnerContainer, { show: isLoading },
13
- React.createElement("div", { className: "di reactable scroll-x" },
14
- React.createElement("table", { className: cx('di reactable sortable hoverable', { selectable: clickable }), "data-testid": this.props['data-testid'] },
15
- React.createElement("thead", null,
16
- React.createElement(ReactableTableHeader, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
17
- React.createElement("tbody", null,
18
- onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow, { columnDefs: columnDefs, onFilter: onFilter })),
19
- pageable &&
20
- pageable.content.length > 0 &&
21
- pageable.content.map((item, index) => {
22
- if (paginationSettings.size > index) {
23
- return (React.createElement(ReactableTableRow, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef }));
24
- }
25
- else {
26
- return null;
27
- }
28
- }),
29
- (!pageable || !pageable.content.length) && !isLoading && (React.createElement("tr", null,
8
+ import { readAccountObject, writeAccountObject } from '@deviceinsight/ng-ui-api-client';
9
+ export default function 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 [showScrollingAdvice, setShowScrollingAdvice] = useState(false);
13
+ const [neverShowScrollingAdvice, setNeverShowScrollingAdvice] = useState(false);
14
+ const HIDE_SCROLLING_ADVICE_PATH = 'uiConfigurations/nevershowscrollingadvice';
15
+ const neverShowScrollingAdviceRef = useRef(neverShowScrollingAdvice);
16
+ useEffect(() => {
17
+ neverShowScrollingAdviceRef.current = neverShowScrollingAdvice;
18
+ }, [neverShowScrollingAdvice]);
19
+ const updateScrollingAdvice = () => {
20
+ if (containerRef.current && tableRef.current) {
21
+ setShowScrollingAdvice(!neverShowScrollingAdviceRef.current && tableRef.current.scrollWidth > containerRef.current.offsetWidth);
22
+ }
23
+ };
24
+ useEffect(() => {
25
+ readAccountObject(HIDE_SCROLLING_ADVICE_PATH).then((value) => {
26
+ setNeverShowScrollingAdvice(value === undefined ? false : value);
27
+ if (containerRef.current && tableRef.current) {
28
+ updateScrollingAdvice();
29
+ }
30
+ });
31
+ }, []);
32
+ useEffect(() => {
33
+ updateScrollingAdvice();
34
+ window.addEventListener('resize', updateScrollingAdvice);
35
+ return () => window.removeEventListener('resize', updateScrollingAdvice);
36
+ }, [pageable, columnDefs]);
37
+ const showFilterRow = columnDefs.some((col) => col.filterable);
38
+ return (React.createElement(SpinnerContainer, { show: isLoading },
39
+ React.createElement("div", { ref: containerRef, className: "di reactable scroll-x" },
40
+ showScrollingAdvice && !isLoading && (React.createElement(Modal, { className: "scroll-horizontally-advice", content: React.createElement("div", null,
41
+ React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.advice" }, "SHIFT + mouse wheel to scroll horizontally"),
42
+ React.createElement("div", { className: "scroll-horizontally-advice-buttons" },
43
+ React.createElement(Button, { primary: true, onClick: async () => {
44
+ await writeAccountObject(HIDE_SCROLLING_ADVICE_PATH, true);
45
+ setNeverShowScrollingAdvice(true);
46
+ setShowScrollingAdvice(false);
47
+ } },
48
+ React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain" }, "Never show again")),
49
+ React.createElement(Button, { onClick: () => setShowScrollingAdvice(false) },
50
+ React.createElement(Trans, { i18nKey: "reactable.scrollHorizontally.ok" }, "OK")))), width: '40%' })),
51
+ React.createElement("table", { ref: tableRef, className: cx('di reactable sortable hoverable', { selectable: clickable }), "data-testid": testId },
52
+ React.createElement("thead", null,
53
+ React.createElement(ReactableTableHeader, { columnDefs: columnDefs, paginationSettings: paginationSettings, onSort: onSort })),
54
+ React.createElement("tbody", null,
55
+ onFilter && showFilterRow && (React.createElement(ReactableTableFilterRow, { columnDefs: columnDefs, onFilter: onFilter })),
56
+ pageable?.content.length
57
+ ? pageable.content
58
+ .slice(0, paginationSettings.size)
59
+ .map((item) => (React.createElement(ReactableTableRow, { key: uniqueItemKey(item), columnDefs: columnDefs, item: item, rowDef: rowDef })))
60
+ : !isLoading && (React.createElement("tr", null,
30
61
  React.createElement("td", { colSpan: columnDefs.length },
31
62
  React.createElement(Trans, { i18nKey: messageWhenEmpty ?? 'reactable.noEntriesFound' }, "No entries found")))))))));
32
- }
33
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deviceinsight/ng-ui-components",
3
- "version": "6.19.0",
3
+ "version": "6.21.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {