@qoretechnologies/reqore 0.36.0 → 0.36.2
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/__tests__/collection.test.tsx +1 -22
- package/__tests__/table.test.tsx +1 -1
- package/__tests__/tree.test.tsx +0 -18
- package/dist/components/Breadcrumbs/index.js +1 -1
- package/dist/components/Breadcrumbs/index.js.map +1 -1
- package/dist/components/Button/index.d.ts +1 -4
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +11 -26
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Collection/index.d.ts +2 -2
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +10 -10
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Collection/item.d.ts +3 -3
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Columns/index.d.ts +1 -1
- package/dist/components/Columns/index.d.ts.map +1 -1
- package/dist/components/Comment/index.d.ts +1 -1
- package/dist/components/Comment/index.d.ts.map +1 -1
- package/dist/components/CommentFeed/index.d.ts +1 -1
- package/dist/components/CommentFeed/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.d.ts +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.d.ts +1 -1
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/item.d.ts +2 -2
- package/dist/components/Dropdown/item.d.ts.map +1 -1
- package/dist/components/Dropdown/list.d.ts +1 -1
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Effect/index.d.ts +2 -2
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/ExportModal/index.d.ts +11 -0
- package/dist/components/ExportModal/index.d.ts.map +1 -0
- package/dist/components/ExportModal/index.js +91 -0
- package/dist/components/ExportModal/index.js.map +1 -0
- package/dist/components/Header/index.d.ts +7 -7
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/InputClearButton/index.d.ts +1 -0
- package/dist/components/InputClearButton/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +2 -2
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/KeyValueTable/index.d.ts +7 -4
- package/dist/components/KeyValueTable/index.d.ts.map +1 -1
- package/dist/components/KeyValueTable/index.js +32 -2
- package/dist/components/KeyValueTable/index.js.map +1 -1
- package/dist/components/Layout/content.d.ts +1 -1
- package/dist/components/Layout/content.d.ts.map +1 -1
- package/dist/components/Layout/index.d.ts +1 -1
- package/dist/components/Layout/index.d.ts.map +1 -1
- package/dist/components/Menu/item.d.ts +1 -1
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +3 -3
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts +1 -0
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +2 -2
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/Notifications/notification.d.ts +1 -0
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +23 -16
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Paging/index.d.ts +1 -1
- package/dist/components/Paging/index.d.ts.map +1 -1
- package/dist/components/Panel/NonResponsiveActions.d.ts +1 -1
- package/dist/components/Panel/NonResponsiveActions.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -1
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Panel/panel.screenshot.d.ts +1 -1
- package/dist/components/Panel/panel.screenshot.d.ts.map +1 -1
- package/dist/components/Paragraph/index.d.ts +1 -1
- package/dist/components/Paragraph/index.d.ts.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +2 -0
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RadioGroup/index.d.ts +1 -1
- package/dist/components/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/Sidebar/item.d.ts +1 -1
- package/dist/components/Sidebar/item.d.ts.map +1 -1
- package/dist/components/Spacer/index.d.ts +3 -3
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spinner/index.d.ts +1 -1
- package/dist/components/Spinner/index.d.ts.map +1 -1
- package/dist/components/Table/body.d.ts +1 -1
- package/dist/components/Table/body.d.ts.map +1 -1
- package/dist/components/Table/body.js +26 -21
- package/dist/components/Table/body.js.map +1 -1
- package/dist/components/Table/cell.d.ts +3 -2
- package/dist/components/Table/cell.d.ts.map +1 -1
- package/dist/components/Table/cell.js +8 -4
- package/dist/components/Table/cell.js.map +1 -1
- package/dist/components/Table/headerCell.d.ts +1 -1
- package/dist/components/Table/headerCell.d.ts.map +1 -1
- package/dist/components/Table/helpers.d.ts +8 -6
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +49 -16
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts +5 -4
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +47 -38
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts +7 -5
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +38 -36
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Table/value.d.ts +1 -1
- package/dist/components/Table/value.d.ts.map +1 -1
- package/dist/components/Tabs/content.d.ts +1 -1
- package/dist/components/Tabs/content.d.ts.map +1 -1
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/list.d.ts +1 -1
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +1 -1
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/group.d.ts +1 -1
- package/dist/components/Tag/group.d.ts.map +1 -1
- package/dist/components/Tree/index.d.ts +2 -1
- package/dist/components/Tree/index.d.ts.map +1 -1
- package/dist/components/Tree/index.js +35 -31
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/constants/sizes.js +5 -5
- package/dist/containers/Paging.d.ts +1 -1
- package/dist/containers/Paging.d.ts.map +1 -1
- package/dist/containers/ThemeProvider.d.ts +1 -1
- package/dist/containers/ThemeProvider.d.ts.map +1 -1
- package/dist/helpers/utils.d.ts +2 -1
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +20 -2
- package/dist/helpers/utils.js.map +1 -1
- package/dist/hooks/useAutoFocus.d.ts +1 -1
- package/dist/hooks/useAutoFocus.d.ts.map +1 -1
- package/dist/hooks/usePopover.d.ts +1 -0
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.d.ts +3 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +49 -11
- package/dist/styles.js.map +1 -1
- package/migration-storybook.log +88 -0
- package/package.json +26 -20
- package/src/components/Breadcrumbs/index.tsx +1 -1
- package/src/components/Button/index.tsx +3 -54
- package/src/components/Collection/index.tsx +18 -15
- package/src/components/Collection/item.tsx +2 -1
- package/src/components/ExportModal/index.tsx +98 -0
- package/src/components/InternalPopover/index.tsx +2 -2
- package/src/components/KeyValueTable/index.tsx +59 -11
- package/src/components/Menu/item.tsx +4 -4
- package/src/components/Message/index.tsx +1 -0
- package/src/components/Notifications/notification.tsx +14 -3
- package/src/components/Panel/index.tsx +2 -2
- package/src/components/Popover/index.tsx +3 -0
- package/src/components/Table/body.tsx +26 -20
- package/src/components/Table/cell.tsx +15 -4
- package/src/components/Table/helpers.ts +52 -21
- package/src/components/Table/index.tsx +119 -75
- package/src/components/Table/row.tsx +47 -46
- package/src/components/Tabs/list.tsx +1 -1
- package/src/components/Tree/index.tsx +82 -75
- package/src/constants/sizes.ts +5 -5
- package/src/helpers/utils.ts +10 -2
- package/src/hooks/useAutoFocus.ts +1 -1
- package/src/index.tsx +1 -1
- package/src/mock/tableData.ts +12 -0
- package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +11 -23
- package/src/stories/Button/Button.stories.tsx +83 -47
- package/src/stories/Checkbox/Checkbox.stories.tsx +19 -9
- package/src/stories/Collection/Collection.stories.tsx +195 -171
- package/src/stories/Columns/Columns.stories.tsx +38 -24
- package/src/stories/Comment/Comment.stories.tsx +15 -6
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +102 -48
- package/src/stories/Drawer/Drawer.stories.tsx +52 -17
- package/src/stories/Dropdown/Dropdown.stories.tsx +184 -152
- package/src/stories/ExportModal/ExportModal.stories.tsx +18 -0
- package/src/stories/Header/Header.stories.tsx +65 -31
- package/src/stories/Icon/Icon.stories.tsx +139 -133
- package/src/stories/Input/Input.stories.tsx +68 -31
- package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +183 -117
- package/src/stories/Menu/Menu.stories.tsx +56 -20
- package/src/stories/Message/Message.stories.tsx +96 -37
- package/src/stories/Modal/Modal.stories.tsx +28 -8
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +66 -35
- package/src/stories/Navbar/Navbar.stories.tsx +15 -5
- package/src/stories/Notifications/Interactive.stories.tsx +40 -28
- package/src/stories/Notifications/Notification.stories.tsx +55 -41
- package/src/stories/Notifications/Notifications.stories.tsx +45 -29
- package/src/stories/Paging/Paging.stories.tsx +206 -177
- package/src/stories/Panel/Panel.stories.tsx +238 -168
- package/src/stories/Paragraph/Paragraph.stories.tsx +66 -31
- package/src/stories/Popover/Popover.stories.tsx +62 -40
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +41 -19
- package/src/stories/Sidebar/Sidebar.stories.tsx +29 -10
- package/src/stories/Spacer/Spacer.stories.tsx +13 -5
- package/src/stories/Spinner/Spinner.stories.tsx +26 -12
- package/src/stories/Table/Table.stories.tsx +200 -144
- package/src/stories/Table/Tests.stories.tsx +9 -0
- package/src/stories/Tabs/Tabs.stories.tsx +82 -46
- package/src/stories/Tag/Tag.stories.tsx +56 -37
- package/src/stories/Tag/TagGroup.stories.tsx +297 -0
- package/src/stories/TextArea/TextArea.stories.tsx +82 -40
- package/src/stories/Tree/Tree.stories.tsx +84 -22
- package/src/stories/utils.ts +22 -1
- package/src/styles.ts +55 -2
- package/tests.json +1 -1
|
@@ -3,14 +3,22 @@ import { size as count, isArray } from 'lodash';
|
|
|
3
3
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useMeasure, useUpdateEffect } from 'react-use';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ReqoreMessage,
|
|
8
|
+
ReqorePaginationContainer,
|
|
9
|
+
ReqorePanel,
|
|
10
|
+
ReqoreVerticalSpacer,
|
|
11
|
+
useReqoreTheme,
|
|
12
|
+
} from '../..';
|
|
7
13
|
import { TReqorePaginationType, getPagingObjectFromType } from '../../constants/paging';
|
|
8
14
|
import { TABLE_SIZE_TO_PX, TSizes } from '../../constants/sizes';
|
|
9
15
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
16
|
+
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
10
17
|
import { useQueryWithDelay } from '../../hooks/useQueryWithDelay';
|
|
11
18
|
import { IReqoreIntent, IReqoreTooltip } from '../../types/global';
|
|
12
19
|
import { IReqoreButtonProps, TReqoreBadge } from '../Button';
|
|
13
20
|
import { IReqoreDropdownItem } from '../Dropdown/list';
|
|
21
|
+
import { ReqoreExportModal } from '../ExportModal';
|
|
14
22
|
import ReqoreInput, { IReqoreInputProps } from '../Input';
|
|
15
23
|
import { IReqorePanelAction, IReqorePanelProps, IReqorePanelSubAction } from '../Panel';
|
|
16
24
|
import ReqoreTableBody from './body';
|
|
@@ -21,11 +29,13 @@ import {
|
|
|
21
29
|
flipSortDirection,
|
|
22
30
|
getColumnsByPinType,
|
|
23
31
|
getColumnsCount,
|
|
32
|
+
getExportActions,
|
|
24
33
|
getOnlyShownColumns,
|
|
25
34
|
getZoomActions,
|
|
26
35
|
hasGroupedColumns,
|
|
27
36
|
hasHiddenColumns,
|
|
28
37
|
prepareColumns,
|
|
38
|
+
removeInternalData,
|
|
29
39
|
sizeToZoom,
|
|
30
40
|
sortTableData,
|
|
31
41
|
zoomToSize,
|
|
@@ -104,8 +114,10 @@ export interface IReqoreTableProps extends IReqorePanelProps {
|
|
|
104
114
|
|
|
105
115
|
filterable?: boolean;
|
|
106
116
|
filterProps?: (data: IReqoreTableData) => IReqoreInputProps;
|
|
107
|
-
filter?: string;
|
|
108
|
-
onFilterChange?: (query: string) => void;
|
|
117
|
+
filter?: string | number;
|
|
118
|
+
onFilterChange?: (query: string | number) => void;
|
|
119
|
+
|
|
120
|
+
exportable?: boolean;
|
|
109
121
|
|
|
110
122
|
zoomable?: boolean;
|
|
111
123
|
defaultZoom?: number;
|
|
@@ -137,7 +149,7 @@ export interface IReqoreTableStyle {
|
|
|
137
149
|
}
|
|
138
150
|
|
|
139
151
|
export interface IReqoreTableSort {
|
|
140
|
-
by
|
|
152
|
+
by: string;
|
|
141
153
|
thenBy?: string;
|
|
142
154
|
direction?: 'asc' | 'desc';
|
|
143
155
|
}
|
|
@@ -178,7 +190,6 @@ const ReqoreTable = ({
|
|
|
178
190
|
selected,
|
|
179
191
|
onSelectedChange,
|
|
180
192
|
selectToggleTooltip,
|
|
181
|
-
customTheme,
|
|
182
193
|
onRowClick,
|
|
183
194
|
striped,
|
|
184
195
|
selectedRowIntent = 'info',
|
|
@@ -188,7 +199,7 @@ const ReqoreTable = ({
|
|
|
188
199
|
fill,
|
|
189
200
|
filterable,
|
|
190
201
|
zoomable,
|
|
191
|
-
filter,
|
|
202
|
+
filter = '',
|
|
192
203
|
actions = [],
|
|
193
204
|
onFilterChange,
|
|
194
205
|
filterProps,
|
|
@@ -198,16 +209,17 @@ const ReqoreTable = ({
|
|
|
198
209
|
bodyCellComponent,
|
|
199
210
|
onSelectClick,
|
|
200
211
|
paging,
|
|
212
|
+
exportable,
|
|
201
213
|
...rest
|
|
202
214
|
}: IReqoreTableProps) => {
|
|
203
|
-
const leftTableRef = useRef<HTMLDivElement>(
|
|
204
|
-
const rightTableRef = useRef<HTMLDivElement>(
|
|
205
|
-
const mainTableRef = useRef<HTMLDivElement>(
|
|
206
|
-
const mainHeaderRef = useRef<HTMLDivElement>(
|
|
215
|
+
const leftTableRef = useRef<HTMLDivElement>(null);
|
|
216
|
+
const rightTableRef = useRef<HTMLDivElement>(null);
|
|
217
|
+
const mainTableRef = useRef<HTMLDivElement>(null);
|
|
218
|
+
const mainHeaderRef = useRef<HTMLDivElement>(null);
|
|
207
219
|
|
|
208
220
|
const [isScrolled, setIsScrolled] = useState<boolean>(false);
|
|
209
221
|
const [_data, setData] = useState<IReqoreTableData>(data || []);
|
|
210
|
-
const [_sort, setSort] = useState<IReqoreTableSort>(fixSort(sort));
|
|
222
|
+
const [_sort, setSort] = useState<IReqoreTableSort | undefined>(fixSort(sort));
|
|
211
223
|
const [_selected, setSelected] = useState<(string | number)[]>(selected || []);
|
|
212
224
|
const [_selectedQuant, setSelectedQuant] = useState<'all' | 'none' | 'some'>('none');
|
|
213
225
|
const [columnModifiers, setColumnModifiers] = useState<{
|
|
@@ -215,9 +227,15 @@ const ReqoreTable = ({
|
|
|
215
227
|
}>({});
|
|
216
228
|
const [_internalColumns, setColumns] = useState<IReqoreTableColumn[]>(columns);
|
|
217
229
|
const [zoom, setZoom] = useState<number>(sizeToZoom[size]);
|
|
230
|
+
const [showExportModal, setShowExportModal] = useState<'full' | 'current' | undefined>(undefined);
|
|
231
|
+
const theme = useReqoreTheme('main', rest.customTheme, intent);
|
|
218
232
|
|
|
219
233
|
const [wrapperRef, sizes] = useMeasure();
|
|
220
|
-
const { query, preQuery, setQuery, setPreQuery } = useQueryWithDelay(
|
|
234
|
+
const { query, preQuery, setQuery, setPreQuery } = useQueryWithDelay(
|
|
235
|
+
filter.toString(),
|
|
236
|
+
300,
|
|
237
|
+
onFilterChange
|
|
238
|
+
);
|
|
221
239
|
|
|
222
240
|
const selectedIcon = useMemo(() => {
|
|
223
241
|
switch (_selectedQuant) {
|
|
@@ -260,15 +278,15 @@ const ReqoreTable = ({
|
|
|
260
278
|
tooltip: selectToggleTooltip,
|
|
261
279
|
icon: !_selectId
|
|
262
280
|
? 'Forbid2Line'
|
|
263
|
-
: _selected?.find((s) => s === _selectId)
|
|
281
|
+
: _selected?.find((s) => s.toString() === _selectId.toString())
|
|
264
282
|
? 'CheckboxCircleLine'
|
|
265
283
|
: 'CheckboxBlankCircleLine',
|
|
266
284
|
intent: !_selectId
|
|
267
285
|
? 'muted'
|
|
268
|
-
: _selected?.find((s) => s === _selectId)
|
|
286
|
+
: _selected?.find((s) => s.toString() === _selectId.toString())
|
|
269
287
|
? selectedRowIntent
|
|
270
288
|
: undefined,
|
|
271
|
-
onClick: () => handleSelectClick(_selectId),
|
|
289
|
+
onClick: _selectId ? () => handleSelectClick(_selectId) : undefined,
|
|
272
290
|
},
|
|
273
291
|
],
|
|
274
292
|
},
|
|
@@ -345,7 +363,7 @@ const ReqoreTable = ({
|
|
|
345
363
|
}, [data]);
|
|
346
364
|
|
|
347
365
|
useUpdateEffect(() => {
|
|
348
|
-
if (selectable) {
|
|
366
|
+
if (selectable && selected) {
|
|
349
367
|
setSelected(selected);
|
|
350
368
|
}
|
|
351
369
|
}, [selected]);
|
|
@@ -370,7 +388,7 @@ const ReqoreTable = ({
|
|
|
370
388
|
}
|
|
371
389
|
}, [_selected]);
|
|
372
390
|
|
|
373
|
-
const handleSortChange = (by
|
|
391
|
+
const handleSortChange = (by: string) => {
|
|
374
392
|
setSort((currentSort: IReqoreTableSort) => {
|
|
375
393
|
const newSort: IReqoreTableSort = { ...currentSort };
|
|
376
394
|
|
|
@@ -444,7 +462,7 @@ const ReqoreTable = ({
|
|
|
444
462
|
|
|
445
463
|
const addColumn = (column: IReqoreTableColumn) => {
|
|
446
464
|
_columnsList.push({
|
|
447
|
-
label: typeof column.header
|
|
465
|
+
label: typeof column.header?.label === 'string' ? column.header.label : column.dataId,
|
|
448
466
|
selected: column.show !== false,
|
|
449
467
|
onClick: () =>
|
|
450
468
|
handleColumnsUpdate(column.dataId, 'show', column.show !== false ? false : true),
|
|
@@ -498,7 +516,6 @@ const ReqoreTable = ({
|
|
|
498
516
|
|
|
499
517
|
if (count(columnsList)) {
|
|
500
518
|
finalActions.push({
|
|
501
|
-
label: 'Columns',
|
|
502
519
|
icon: 'LayoutColumnLine',
|
|
503
520
|
className: 'reqore-table-columns-options',
|
|
504
521
|
badge: getColumnsCount(getOnlyShownColumns(finalColumns)),
|
|
@@ -529,13 +546,6 @@ const ReqoreTable = ({
|
|
|
529
546
|
});
|
|
530
547
|
}
|
|
531
548
|
|
|
532
|
-
if (zoomable) {
|
|
533
|
-
finalActions.push({
|
|
534
|
-
fluid: false,
|
|
535
|
-
group: getZoomActions('reqore-table', zoom, setZoom),
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
|
|
539
549
|
if (isScrolled) {
|
|
540
550
|
finalActions.push({
|
|
541
551
|
icon: 'ArrowUpSFill',
|
|
@@ -546,11 +556,30 @@ const ReqoreTable = ({
|
|
|
546
556
|
});
|
|
547
557
|
}
|
|
548
558
|
|
|
549
|
-
if (count(columnModifiers) || zoomable || filterable) {
|
|
559
|
+
if (count(columnModifiers) || zoomable || filterable || exportable) {
|
|
560
|
+
let moreActions: IReqorePanelSubAction[] = [];
|
|
561
|
+
|
|
562
|
+
if (exportable) {
|
|
563
|
+
moreActions = [
|
|
564
|
+
...moreActions,
|
|
565
|
+
...getExportActions((type) => setShowExportModal(type)),
|
|
566
|
+
{ divider: true, line: true },
|
|
567
|
+
];
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (zoomable) {
|
|
571
|
+
moreActions = [
|
|
572
|
+
...moreActions,
|
|
573
|
+
...getZoomActions('reqore-table', zoom, setZoom, true),
|
|
574
|
+
{ divider: true, line: true },
|
|
575
|
+
];
|
|
576
|
+
}
|
|
577
|
+
|
|
550
578
|
finalActions.push({
|
|
551
579
|
icon: 'MoreLine',
|
|
552
580
|
className: 'reqore-table-more',
|
|
553
581
|
actions: [
|
|
582
|
+
...moreActions,
|
|
554
583
|
{
|
|
555
584
|
label: 'Reset table',
|
|
556
585
|
icon: 'RestartLine',
|
|
@@ -581,7 +610,7 @@ const ReqoreTable = ({
|
|
|
581
610
|
]);
|
|
582
611
|
|
|
583
612
|
const badge = useMemo(() => {
|
|
584
|
-
const badgeList: TReqoreBadge[] = rest.label ? [count(transformedData)] :
|
|
613
|
+
const badgeList: TReqoreBadge[] = rest.label ? [count(transformedData)] : [];
|
|
585
614
|
|
|
586
615
|
if (rest.badge) {
|
|
587
616
|
if (isArray(rest.badge)) {
|
|
@@ -661,58 +690,73 @@ const ReqoreTable = ({
|
|
|
661
690
|
);
|
|
662
691
|
};
|
|
663
692
|
|
|
664
|
-
const pagingOptions = useMemo(
|
|
693
|
+
const pagingOptions = useMemo(
|
|
694
|
+
() => (paging ? getPagingObjectFromType(paging) : undefined),
|
|
695
|
+
[paging]
|
|
696
|
+
);
|
|
665
697
|
|
|
666
698
|
return (
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
<ReqorePaginationContainer<IReqoreTableRowData>
|
|
683
|
-
items={transformedData}
|
|
684
|
-
type={
|
|
685
|
-
paging
|
|
686
|
-
? {
|
|
687
|
-
...pagingOptions,
|
|
688
|
-
onPageChange: () => {
|
|
689
|
-
if (!pagingOptions.infinite) {
|
|
690
|
-
handleScrollToTop();
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
}
|
|
694
|
-
: undefined
|
|
695
|
-
}
|
|
699
|
+
<>
|
|
700
|
+
<ReqorePanel
|
|
701
|
+
transparent
|
|
702
|
+
flat
|
|
703
|
+
padded={false}
|
|
704
|
+
contentStyle={{ display: 'flex', flexFlow: 'column', overflow: 'hidden' }}
|
|
705
|
+
responsiveActions={false}
|
|
706
|
+
{...rest}
|
|
707
|
+
size={wrapperSize}
|
|
708
|
+
actions={tableActions}
|
|
709
|
+
fill={fill}
|
|
710
|
+
className={`${className || ''} reqore-table`}
|
|
711
|
+
style={{ width, ...(rest.style || {}) }}
|
|
712
|
+
getContentRef={wrapperRef}
|
|
713
|
+
badge={badge}
|
|
696
714
|
>
|
|
697
|
-
{
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
715
|
+
<ReqoreThemeProvider theme={theme}>
|
|
716
|
+
<ReqorePaginationContainer<IReqoreTableRowData>
|
|
717
|
+
items={transformedData}
|
|
718
|
+
type={
|
|
719
|
+
pagingOptions
|
|
720
|
+
? {
|
|
721
|
+
...pagingOptions,
|
|
722
|
+
onPageChange: () => {
|
|
723
|
+
if (!pagingOptions.infinite) {
|
|
724
|
+
handleScrollToTop();
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
}
|
|
728
|
+
: undefined
|
|
729
|
+
}
|
|
730
|
+
>
|
|
731
|
+
{(pagedData) => (
|
|
705
732
|
<>
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
733
|
+
{showExportModal && (
|
|
734
|
+
<ReqoreExportModal
|
|
735
|
+
data={removeInternalData(
|
|
736
|
+
showExportModal === 'current' ? pagedData : transformedData
|
|
737
|
+
)}
|
|
738
|
+
onClose={() => setShowExportModal(undefined)}
|
|
739
|
+
/>
|
|
740
|
+
)}
|
|
741
|
+
<StyledTablesWrapper className='reqore-table-wrapper'>
|
|
742
|
+
{renderTable('left', pagedData)}
|
|
743
|
+
{renderTable('main', pagedData)}
|
|
744
|
+
{renderTable('right', pagedData)}
|
|
745
|
+
</StyledTablesWrapper>
|
|
746
|
+
{count(pagedData) === 0 ? (
|
|
747
|
+
<>
|
|
748
|
+
<ReqoreVerticalSpacer height={10} />
|
|
749
|
+
<ReqoreMessage flat size={size} icon='Search2Line'>
|
|
750
|
+
{emptyMessage}
|
|
751
|
+
</ReqoreMessage>
|
|
752
|
+
</>
|
|
753
|
+
) : null}
|
|
710
754
|
</>
|
|
711
|
-
)
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
</
|
|
715
|
-
|
|
755
|
+
)}
|
|
756
|
+
</ReqorePaginationContainer>
|
|
757
|
+
</ReqoreThemeProvider>
|
|
758
|
+
</ReqorePanel>
|
|
759
|
+
</>
|
|
716
760
|
);
|
|
717
761
|
};
|
|
718
762
|
|
|
@@ -3,7 +3,7 @@ import { isFunction, isString } from 'lodash';
|
|
|
3
3
|
import React, { ReactElement, useState } from 'react';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import { IReqoreTableColumn, IReqoreTableData, IReqoreTableRowClick } from '.';
|
|
6
|
-
import { ReqoreButton, ReqoreControlGroup
|
|
6
|
+
import { ReqoreButton, ReqoreControlGroup } from '../..';
|
|
7
7
|
import { SIZE_TO_PX, TSizes } from '../../constants/sizes';
|
|
8
8
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
9
9
|
import { IReqoreTooltip } from '../../types/global';
|
|
@@ -17,10 +17,10 @@ import { getOnlyShownColumns } from './helpers';
|
|
|
17
17
|
|
|
18
18
|
export interface IReqoreTableRowOptions {
|
|
19
19
|
columns: IReqoreTableColumn[];
|
|
20
|
-
data
|
|
20
|
+
data: IReqoreTableData;
|
|
21
21
|
selectable?: boolean;
|
|
22
|
-
onSelectClick
|
|
23
|
-
selected
|
|
22
|
+
onSelectClick: (selectId: string | number) => void;
|
|
23
|
+
selected: (string | number)[];
|
|
24
24
|
onRowClick?: IReqoreTableRowClick;
|
|
25
25
|
striped?: boolean;
|
|
26
26
|
selectedRowIntent?: TReqoreIntent;
|
|
@@ -29,7 +29,10 @@ export interface IReqoreTableRowOptions {
|
|
|
29
29
|
cellComponent?: IReqoreCustomTableBodyCell;
|
|
30
30
|
rowComponent?: IReqoreCustomTableRow;
|
|
31
31
|
}
|
|
32
|
-
export interface IReqoreCustomTableRowProps extends IReqoreTableRowOptions {
|
|
32
|
+
export interface IReqoreCustomTableRowProps extends IReqoreTableRowOptions {
|
|
33
|
+
style?: React.CSSProperties;
|
|
34
|
+
children?: ReactElement;
|
|
35
|
+
}
|
|
33
36
|
export interface IReqoreCustomTableRow extends React.FC<IReqoreCustomTableRowProps> {}
|
|
34
37
|
export interface IReqoreTableRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
35
38
|
data: IReqoreTableRowOptions;
|
|
@@ -92,7 +95,9 @@ const ReqoreTableRow = ({
|
|
|
92
95
|
index,
|
|
93
96
|
}: IReqoreTableRowProps) => {
|
|
94
97
|
const [isHovered, setIsHovered] = useState<boolean>(false);
|
|
95
|
-
const isSelected =
|
|
98
|
+
const isSelected =
|
|
99
|
+
data[index]._selectId &&
|
|
100
|
+
selected.find((selectId) => selectId.toString() === data[index]._selectId.toString());
|
|
96
101
|
|
|
97
102
|
const CellComponent = cellComponent || ReqoreTableBodyCell;
|
|
98
103
|
const RowComponent = rowComponent || StyledTableRow;
|
|
@@ -181,7 +186,7 @@ const ReqoreTableRow = ({
|
|
|
181
186
|
const renderCells = (columns: IReqoreTableColumn[], data: IReqoreTableData) =>
|
|
182
187
|
getOnlyShownColumns(columns).map(
|
|
183
188
|
({ width, minWidth, maxWidth, resizedWidth, grow, dataId, cell, header, align, intent }) => {
|
|
184
|
-
if (header
|
|
189
|
+
if (header?.columns) {
|
|
185
190
|
return renderCells(header.columns, data);
|
|
186
191
|
}
|
|
187
192
|
|
|
@@ -195,48 +200,44 @@ const ReqoreTableRow = ({
|
|
|
195
200
|
: {};
|
|
196
201
|
|
|
197
202
|
return (
|
|
198
|
-
<
|
|
203
|
+
<CellComponent
|
|
199
204
|
key={dataId}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
className: 'reqore-table-cell',
|
|
234
|
-
} as IReqoreTableCellStyle
|
|
235
|
-
}
|
|
236
|
-
{...tooltip}
|
|
205
|
+
{...({
|
|
206
|
+
width: resizedWidth || width,
|
|
207
|
+
minWidth,
|
|
208
|
+
maxWidth,
|
|
209
|
+
grow,
|
|
210
|
+
align,
|
|
211
|
+
size,
|
|
212
|
+
striped,
|
|
213
|
+
tooltip,
|
|
214
|
+
padded: cell?.padded,
|
|
215
|
+
disabled: data[index]._disabled,
|
|
216
|
+
selected: !!isSelected,
|
|
217
|
+
selectedIntent: selectedRowIntent,
|
|
218
|
+
flat,
|
|
219
|
+
even: index % 2 === 0 ? true : false,
|
|
220
|
+
intent: cell?.intent || data[index]._intent || intent,
|
|
221
|
+
hovered: isHovered,
|
|
222
|
+
interactive: !!cell?.onClick || !!onRowClick,
|
|
223
|
+
interactiveCell: !!cell?.onClick,
|
|
224
|
+
onClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
|
225
|
+
if (cell?.onClick) {
|
|
226
|
+
e.stopPropagation();
|
|
227
|
+
cell.onClick(data[index]);
|
|
228
|
+
} else if (onRowClick) {
|
|
229
|
+
e.stopPropagation();
|
|
230
|
+
onRowClick(data[index]);
|
|
231
|
+
} else if (selectable && data[index]._selectId) {
|
|
232
|
+
// Otherwise select the row if selectable
|
|
233
|
+
onSelectClick(data[index]._selectId!);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
className: 'reqore-table-cell',
|
|
237
|
+
} as IReqoreTableCellStyle)}
|
|
237
238
|
>
|
|
238
239
|
{renderContent(cell, data[index], dataId, align)}
|
|
239
|
-
</
|
|
240
|
+
</CellComponent>
|
|
240
241
|
);
|
|
241
242
|
}
|
|
242
243
|
);
|