@qoretechnologies/reqore 0.35.2 → 0.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Collection/index.d.ts +11 -2
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +33 -7
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Table/body.d.ts +0 -1
- package/dist/components/Table/body.d.ts.map +1 -1
- package/dist/components/Table/body.js +6 -2
- package/dist/components/Table/body.js.map +1 -1
- package/dist/components/Table/index.d.ts +3 -1
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +31 -23
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Tree/index.d.ts +3 -1
- package/dist/components/Tree/index.d.ts.map +1 -1
- package/dist/components/Tree/index.js +9 -2
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/constants/paging.d.ts +1 -0
- package/dist/constants/paging.d.ts.map +1 -1
- package/dist/constants/paging.js +20 -1
- package/dist/constants/paging.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Collection/index.tsx +41 -6
- package/src/components/Table/body.tsx +9 -4
- package/src/components/Table/index.tsx +66 -36
- package/src/components/Tree/index.tsx +13 -2
- package/src/constants/paging.ts +22 -0
- package/src/stories/Collection/Collection.stories.tsx +16 -0
- package/src/stories/Table/Table.stories.tsx +18 -1
- package/src/stories/Tree/Tree.stories.tsx +13 -0
- package/tests.json +1 -1
package/dist/constants/paging.js
CHANGED
|
@@ -11,7 +11,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
exports.__esModule = true;
|
|
14
|
-
exports.getPaginationOptionsFromType = void 0;
|
|
14
|
+
exports.getPaginationOptionsFromType = exports.getPagingObjectFromType = void 0;
|
|
15
|
+
function getPagingObjectFromType(type) {
|
|
16
|
+
if (typeof type === 'object') {
|
|
17
|
+
return type;
|
|
18
|
+
}
|
|
19
|
+
switch (type) {
|
|
20
|
+
case 'buttons':
|
|
21
|
+
return {};
|
|
22
|
+
case 'list':
|
|
23
|
+
return {
|
|
24
|
+
showPagesAs: 'list'
|
|
25
|
+
};
|
|
26
|
+
case 'infinite':
|
|
27
|
+
case 'auto-load':
|
|
28
|
+
return { infinite: true };
|
|
29
|
+
default:
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.getPagingObjectFromType = getPagingObjectFromType;
|
|
15
34
|
function getPaginationOptionsFromType(type) {
|
|
16
35
|
if (!type)
|
|
17
36
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paging.js","sourceRoot":"","sources":["../../src/constants/paging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA0BA,SAAgB,4BAA4B,CAC1C,IAA8B;IAE9B,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAE1B,IAAA,QAAQ,GAWN,IAAI,SAXE,EACR,YAAY,GAUV,IAAI,aAVM,EACZ,WAAW,GAST,IAAI,YATK,EACX,SAAS,GAQP,IAAI,UARG,EACT,OAAO,GAOL,IAAI,QAPC,EACP,YAAY,GAMV,IAAI,aANM,EACZ,KAKE,IAAI,qBALyB,EAA/B,oBAAoB,mBAAG,QAAQ,KAAA,EAC/B,qBAAqB,GAInB,IAAI,sBAJe,EACrB,kBAAkB,GAGhB,IAAI,mBAHY,EAEf,gBAAgB,UACjB,IAAI,EAZF,0JAYL,CADoB,CACZ;QAET,OAAO;YACL,aAAa,EAAE,EAAE,QAAQ,UAAA,EAAE,YAAY,cAAA,EAAE,WAAW,aAAA,EAAE,SAAS,WAAA,EAAE,OAAO,SAAA,EAAE,YAAY,cAAA,EAAE;YACxF,oBAAoB,sBAAA;YACpB,gBAAgB,kBAAA;YAChB,qBAAqB,uBAAA;YACrB,kBAAkB,oBAAA;SACnB,CAAC;KACH;IAED,QAAQ,IAAI,EAAE;QACZ,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO;gBACL,gBAAgB,EAAE;oBAChB,WAAW,EAAE,MAAM;iBACpB;aACF,CAAC;QACJ,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QAC/C;YACE,OAAO,EAAE,CAAC;KACb;AACH,CAAC;AA5CD,oEA4CC"}
|
|
1
|
+
{"version":3,"file":"paging.js","sourceRoot":"","sources":["../../src/constants/paging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA0BA,SAAgB,uBAAuB,CACrC,IAA8B;IAE9B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IAED,QAAQ,IAAI,EAAE;QACZ,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO;gBACL,WAAW,EAAE,MAAM;aACpB,CAAC;QACJ,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC5B;YACE,OAAO,EAAE,CAAC;KACb;AACH,CAAC;AApBD,0DAoBC;AAED,SAAgB,4BAA4B,CAC1C,IAA8B;IAE9B,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAE1B,IAAA,QAAQ,GAWN,IAAI,SAXE,EACR,YAAY,GAUV,IAAI,aAVM,EACZ,WAAW,GAST,IAAI,YATK,EACX,SAAS,GAQP,IAAI,UARG,EACT,OAAO,GAOL,IAAI,QAPC,EACP,YAAY,GAMV,IAAI,aANM,EACZ,KAKE,IAAI,qBALyB,EAA/B,oBAAoB,mBAAG,QAAQ,KAAA,EAC/B,qBAAqB,GAInB,IAAI,sBAJe,EACrB,kBAAkB,GAGhB,IAAI,mBAHY,EAEf,gBAAgB,UACjB,IAAI,EAZF,0JAYL,CADoB,CACZ;QAET,OAAO;YACL,aAAa,EAAE,EAAE,QAAQ,UAAA,EAAE,YAAY,cAAA,EAAE,WAAW,aAAA,EAAE,SAAS,WAAA,EAAE,OAAO,SAAA,EAAE,YAAY,cAAA,EAAE;YACxF,oBAAoB,sBAAA;YACpB,gBAAgB,kBAAA;YAChB,qBAAqB,uBAAA;YACrB,kBAAkB,oBAAA;SACnB,CAAC;KACH;IAED,QAAQ,IAAI,EAAE;QACZ,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO;gBACL,gBAAgB,EAAE;oBAChB,WAAW,EAAE,MAAM;iBACpB;aACF,CAAC;QACJ,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QAC/C;YACE,OAAO,EAAE,CAAC;KACb;AACH,CAAC;AA5CD,oEA4CC"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ import ReqoreInput, { IReqoreInputProps } from '../Input';
|
|
|
14
14
|
import ReqoreMessage from '../Message';
|
|
15
15
|
import { IReqorePanelAction, IReqorePanelProps, ReqorePanel, TReqorePanelActions } from '../Panel';
|
|
16
16
|
import { ReqoreVerticalSpacer } from '../Spacer';
|
|
17
|
-
import { sortTableData } from '../Table/helpers';
|
|
17
|
+
import { getZoomActions, sizeToZoom, sortTableData, zoomToSize } from '../Table/helpers';
|
|
18
18
|
import { IReqoreCollectionItemProps, ReqoreCollectionItem } from './item';
|
|
19
19
|
|
|
20
20
|
export interface IReqoreCollectionProps extends IReqorePanelProps, IReqoreColumnsProps {
|
|
@@ -29,9 +29,14 @@ export interface IReqoreCollectionProps extends IReqorePanelProps, IReqoreColumn
|
|
|
29
29
|
height?: string;
|
|
30
30
|
fill?: boolean;
|
|
31
31
|
maxItemHeight?: number;
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
defaultQuery?: string;
|
|
34
|
+
defaultZoom?: 0 | 0.5 | 1 | 1.5 | 2;
|
|
35
|
+
|
|
36
|
+
filterable?: boolean;
|
|
34
37
|
sortable?: boolean;
|
|
38
|
+
zoomable?: boolean;
|
|
39
|
+
|
|
35
40
|
showAs?: 'list' | 'grid';
|
|
36
41
|
showSelectedFirst?: boolean;
|
|
37
42
|
selectedIcon?: IReqoreIconName;
|
|
@@ -67,6 +72,14 @@ export const StyledCollectionWrapper = styled(StyledColumns)`
|
|
|
67
72
|
position: relative;
|
|
68
73
|
`;
|
|
69
74
|
|
|
75
|
+
export const zoomToWidth = {
|
|
76
|
+
0: '200px',
|
|
77
|
+
0.5: '300px',
|
|
78
|
+
1: '400px',
|
|
79
|
+
1.5: '500px',
|
|
80
|
+
2: '600px',
|
|
81
|
+
};
|
|
82
|
+
|
|
70
83
|
export const ReqoreCollection = ({
|
|
71
84
|
items,
|
|
72
85
|
stacked,
|
|
@@ -76,6 +89,8 @@ export const ReqoreCollection = ({
|
|
|
76
89
|
filterable,
|
|
77
90
|
inputInTitle = true,
|
|
78
91
|
sortable,
|
|
92
|
+
zoomable,
|
|
93
|
+
defaultZoom,
|
|
79
94
|
showSelectedFirst,
|
|
80
95
|
inputProps,
|
|
81
96
|
sortButtonProps,
|
|
@@ -116,6 +131,7 @@ export const ReqoreCollection = ({
|
|
|
116
131
|
const [sort, setSort] = useState<'asc' | 'desc'>('asc');
|
|
117
132
|
const [contentRef, setContentRef] = useState<HTMLDivElement>(undefined);
|
|
118
133
|
const isMobile = useReqoreProperty('isMobile');
|
|
134
|
+
const [zoom, setZoom] = useState<number>(defaultZoom || sizeToZoom.normal);
|
|
119
135
|
const { query, setQuery, preQuery, setPreQuery } = useQueryWithDelay(
|
|
120
136
|
defaultQuery,
|
|
121
137
|
searchDelay,
|
|
@@ -197,6 +213,13 @@ export const ReqoreCollection = ({
|
|
|
197
213
|
],
|
|
198
214
|
};
|
|
199
215
|
|
|
216
|
+
if (zoomable) {
|
|
217
|
+
actions.push({
|
|
218
|
+
fluid: false,
|
|
219
|
+
group: getZoomActions('reqore-collection', zoom, setZoom),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
200
223
|
if (sortable) {
|
|
201
224
|
toolbarGroup.group.push({
|
|
202
225
|
icon: sort === 'desc' ? 'SortDesc' : 'SortAsc',
|
|
@@ -233,7 +256,19 @@ export const ReqoreCollection = ({
|
|
|
233
256
|
}
|
|
234
257
|
|
|
235
258
|
return [...actions, toolbarGroup];
|
|
236
|
-
}, [
|
|
259
|
+
}, [
|
|
260
|
+
filterable,
|
|
261
|
+
preQuery,
|
|
262
|
+
query,
|
|
263
|
+
rest.actions,
|
|
264
|
+
_showAs,
|
|
265
|
+
sort,
|
|
266
|
+
sortable,
|
|
267
|
+
filteredItems,
|
|
268
|
+
isMobile,
|
|
269
|
+
zoom,
|
|
270
|
+
zoomable,
|
|
271
|
+
]);
|
|
237
272
|
|
|
238
273
|
const renderContent = useCallback(() => {
|
|
239
274
|
return contentRenderer(
|
|
@@ -261,13 +296,13 @@ export const ReqoreCollection = ({
|
|
|
261
296
|
ref={setContentRef}
|
|
262
297
|
height={height}
|
|
263
298
|
alignItems={alignItems}
|
|
264
|
-
minColumnWidth={minColumnWidth}
|
|
299
|
+
minColumnWidth={minColumnWidth || zoomToWidth[zoom]}
|
|
265
300
|
maxColumnWidth={maxColumnWidth}
|
|
266
301
|
className='reqore-collection-content'
|
|
267
302
|
>
|
|
268
303
|
{finalItems?.map((item, index) => (
|
|
269
304
|
<ReqoreCollectionItem
|
|
270
|
-
size={
|
|
305
|
+
size={zoomToSize[zoom]}
|
|
271
306
|
responsiveTitle={false}
|
|
272
307
|
{...item}
|
|
273
308
|
icon={item.icon || (item.selected ? selectedIcon : undefined)}
|
|
@@ -313,8 +348,8 @@ export const ReqoreCollection = ({
|
|
|
313
348
|
rest,
|
|
314
349
|
rounded,
|
|
315
350
|
selectedIcon,
|
|
316
|
-
size,
|
|
317
351
|
stacked,
|
|
352
|
+
zoom,
|
|
318
353
|
]);
|
|
319
354
|
|
|
320
355
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
2
|
import { useMount } from 'react-use';
|
|
3
3
|
import { FixedSizeList as List } from 'react-window';
|
|
4
4
|
import styled from 'styled-components';
|
|
@@ -7,7 +7,6 @@ import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
|
7
7
|
import ReqoreTableRow, { IReqoreTableRowOptions } from './row';
|
|
8
8
|
|
|
9
9
|
export interface IReqoreTableSectionBodyProps extends IReqoreTableRowOptions {
|
|
10
|
-
rowHeight?: number;
|
|
11
10
|
height: number;
|
|
12
11
|
refs: {
|
|
13
12
|
left: React.RefObject<HTMLDivElement>;
|
|
@@ -30,7 +29,6 @@ const ReqoreTableBody = forwardRef<HTMLDivElement, IReqoreTableSectionBodyProps>
|
|
|
30
29
|
{
|
|
31
30
|
data,
|
|
32
31
|
height,
|
|
33
|
-
rowHeight,
|
|
34
32
|
size = 'normal',
|
|
35
33
|
refs,
|
|
36
34
|
type,
|
|
@@ -70,11 +68,18 @@ const ReqoreTableBody = forwardRef<HTMLDivElement, IReqoreTableSectionBodyProps>
|
|
|
70
68
|
});
|
|
71
69
|
});
|
|
72
70
|
|
|
71
|
+
const rowHeight = useMemo(
|
|
72
|
+
() => (rest.flat ? TABLE_SIZE_TO_PX[size] : TABLE_SIZE_TO_PX[size] + 1),
|
|
73
|
+
[size, rest.flat]
|
|
74
|
+
);
|
|
75
|
+
|
|
73
76
|
return (
|
|
74
77
|
<StyledList
|
|
75
78
|
outerRef={targetRef}
|
|
76
79
|
itemCount={data.length}
|
|
77
|
-
height
|
|
80
|
+
// If the defined height is less than the count of items' height
|
|
81
|
+
// use that height instead
|
|
82
|
+
height={height > data.length * rowHeight ? data.length * rowHeight : height}
|
|
78
83
|
className='reqore-table-body'
|
|
79
84
|
itemSize={rest.flat ? TABLE_SIZE_TO_PX[size] : TABLE_SIZE_TO_PX[size] + 1}
|
|
80
85
|
itemData={{
|
|
@@ -3,7 +3,8 @@ 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 { ReqoreMessage, ReqorePanel, ReqoreVerticalSpacer } from '../..';
|
|
6
|
+
import { ReqoreMessage, ReqorePaginationContainer, ReqorePanel, ReqoreVerticalSpacer } from '../..';
|
|
7
|
+
import { TReqorePaginationType, getPagingObjectFromType } from '../../constants/paging';
|
|
7
8
|
import { TABLE_SIZE_TO_PX, TSizes } from '../../constants/sizes';
|
|
8
9
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
9
10
|
import { useQueryWithDelay } from '../../hooks/useQueryWithDelay';
|
|
@@ -96,6 +97,8 @@ export interface IReqoreTableProps extends IReqorePanelProps {
|
|
|
96
97
|
height?: number;
|
|
97
98
|
wrapperSize?: TSizes;
|
|
98
99
|
|
|
100
|
+
paging?: TReqorePaginationType<IReqoreTableRowData>;
|
|
101
|
+
|
|
99
102
|
sort?: IReqoreTableSort;
|
|
100
103
|
onSortChange?: (sort?: IReqoreTableSort) => void;
|
|
101
104
|
|
|
@@ -141,16 +144,18 @@ export interface IReqoreTableSort {
|
|
|
141
144
|
|
|
142
145
|
const StyledTableWrapper = styled.div`
|
|
143
146
|
overflow: hidden;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex-flow: column;
|
|
144
149
|
|
|
145
150
|
${({ isPinned }) =>
|
|
146
151
|
isPinned
|
|
147
152
|
? css`
|
|
148
153
|
flex-shrink: 0;
|
|
154
|
+
z-index: 1;
|
|
155
|
+
box-shadow: 1px -1px 20px -2px rgba(0, 0, 0, 0.8);
|
|
149
156
|
`
|
|
150
157
|
: css`
|
|
151
158
|
width: 100%;
|
|
152
|
-
display: flex;
|
|
153
|
-
flex-flow: column;
|
|
154
159
|
flex: 1;
|
|
155
160
|
`};
|
|
156
161
|
`;
|
|
@@ -192,6 +197,7 @@ const ReqoreTable = ({
|
|
|
192
197
|
rowComponent,
|
|
193
198
|
bodyCellComponent,
|
|
194
199
|
onSelectClick,
|
|
200
|
+
paging,
|
|
195
201
|
...rest
|
|
196
202
|
}: IReqoreTableProps) => {
|
|
197
203
|
const leftTableRef = useRef<HTMLDivElement>(undefined);
|
|
@@ -468,6 +474,23 @@ const ReqoreTable = ({
|
|
|
468
474
|
return _columnsList;
|
|
469
475
|
}, [finalColumns]);
|
|
470
476
|
|
|
477
|
+
const handleScrollToTop = () => {
|
|
478
|
+
mainTableRef.current?.scrollTo({
|
|
479
|
+
top: 0,
|
|
480
|
+
behavior: 'smooth',
|
|
481
|
+
});
|
|
482
|
+
leftTableRef.current?.scrollTo({
|
|
483
|
+
top: 0,
|
|
484
|
+
behavior: 'smooth',
|
|
485
|
+
});
|
|
486
|
+
rightTableRef.current?.scrollTo({
|
|
487
|
+
top: 0,
|
|
488
|
+
behavior: 'smooth',
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
setIsScrolled(false);
|
|
492
|
+
};
|
|
493
|
+
|
|
471
494
|
const tableActions = useMemo<IReqorePanelAction[]>(() => {
|
|
472
495
|
const finalActions: IReqorePanelAction[] = [...actions];
|
|
473
496
|
|
|
@@ -515,22 +538,7 @@ const ReqoreTable = ({
|
|
|
515
538
|
tooltip: 'Scroll to top',
|
|
516
539
|
className: 'reqore-table-columns-scroll-top',
|
|
517
540
|
responsive: true,
|
|
518
|
-
onClick:
|
|
519
|
-
mainTableRef.current?.scrollTo({
|
|
520
|
-
top: 0,
|
|
521
|
-
behavior: 'smooth',
|
|
522
|
-
});
|
|
523
|
-
leftTableRef.current?.scrollTo({
|
|
524
|
-
top: 0,
|
|
525
|
-
behavior: 'smooth',
|
|
526
|
-
});
|
|
527
|
-
rightTableRef.current?.scrollTo({
|
|
528
|
-
top: 0,
|
|
529
|
-
behavior: 'smooth',
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
setIsScrolled(false);
|
|
533
|
-
},
|
|
541
|
+
onClick: handleScrollToTop,
|
|
534
542
|
});
|
|
535
543
|
}
|
|
536
544
|
|
|
@@ -598,7 +606,7 @@ const ReqoreTable = ({
|
|
|
598
606
|
[finalColumns]
|
|
599
607
|
);
|
|
600
608
|
|
|
601
|
-
const renderTable = (type: 'left' | 'main' | 'right' = 'main') => {
|
|
609
|
+
const renderTable = (type: 'left' | 'main' | 'right' = 'main', items: IReqoreTableRowData[]) => {
|
|
602
610
|
const tableColumns = columnsByType[type];
|
|
603
611
|
const isPinned = type === 'left' || type === 'right';
|
|
604
612
|
|
|
@@ -617,19 +625,19 @@ const ReqoreTable = ({
|
|
|
617
625
|
onSortChange={handleSortChange}
|
|
618
626
|
heightAsGroup={hasGroupedColumns(finalColumns)}
|
|
619
627
|
sortData={_sort}
|
|
620
|
-
hasVerticalScroll={count(
|
|
628
|
+
hasVerticalScroll={count(items) * TABLE_SIZE_TO_PX[size] > height}
|
|
621
629
|
onColumnsUpdate={handleColumnsUpdate}
|
|
622
630
|
onFilterChange={(dataId: string, value: any) => {
|
|
623
631
|
handleColumnsUpdate(dataId, 'filter', value);
|
|
624
632
|
}}
|
|
625
633
|
component={headerCellComponent}
|
|
626
634
|
/>
|
|
627
|
-
{count(
|
|
635
|
+
{count(items) === 0 ? null : (
|
|
628
636
|
<ReqoreTableBody
|
|
629
637
|
ref={refs[type]}
|
|
630
638
|
refs={refs}
|
|
631
639
|
type={type}
|
|
632
|
-
data={
|
|
640
|
+
data={items}
|
|
633
641
|
columns={tableColumns}
|
|
634
642
|
height={fill ? sizes.height : height}
|
|
635
643
|
selectable={selectable}
|
|
@@ -649,6 +657,8 @@ const ReqoreTable = ({
|
|
|
649
657
|
);
|
|
650
658
|
};
|
|
651
659
|
|
|
660
|
+
const pagingOptions = useMemo(() => getPagingObjectFromType(paging), [paging]);
|
|
661
|
+
|
|
652
662
|
return (
|
|
653
663
|
<ReqorePanel
|
|
654
664
|
transparent
|
|
@@ -665,19 +675,39 @@ const ReqoreTable = ({
|
|
|
665
675
|
getContentRef={wrapperRef}
|
|
666
676
|
badge={badge}
|
|
667
677
|
>
|
|
668
|
-
<
|
|
669
|
-
{
|
|
670
|
-
{
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
678
|
+
<ReqorePaginationContainer<IReqoreTableRowData>
|
|
679
|
+
items={transformedData}
|
|
680
|
+
type={
|
|
681
|
+
paging
|
|
682
|
+
? {
|
|
683
|
+
...pagingOptions,
|
|
684
|
+
onPageChange: () => {
|
|
685
|
+
if (!pagingOptions.infinite) {
|
|
686
|
+
handleScrollToTop();
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
}
|
|
690
|
+
: undefined
|
|
691
|
+
}
|
|
692
|
+
>
|
|
693
|
+
{(pagedData) => (
|
|
694
|
+
<>
|
|
695
|
+
<StyledTablesWrapper className='reqore-table-wrapper'>
|
|
696
|
+
{renderTable('left', pagedData)}
|
|
697
|
+
{renderTable('main', pagedData)}
|
|
698
|
+
{renderTable('right', pagedData)}
|
|
699
|
+
</StyledTablesWrapper>
|
|
700
|
+
{count(pagedData) === 0 ? (
|
|
701
|
+
<>
|
|
702
|
+
<ReqoreVerticalSpacer height={10} />
|
|
703
|
+
<ReqoreMessage flat size={size} icon='Search2Line'>
|
|
704
|
+
{emptyMessage}
|
|
705
|
+
</ReqoreMessage>
|
|
706
|
+
</>
|
|
707
|
+
) : null}
|
|
708
|
+
</>
|
|
709
|
+
)}
|
|
710
|
+
</ReqorePaginationContainer>
|
|
681
711
|
</ReqorePanel>
|
|
682
712
|
);
|
|
683
713
|
};
|
|
@@ -8,6 +8,7 @@ import { IWithReqoreSize } from '../../types/global';
|
|
|
8
8
|
import ReqoreButton from '../Button';
|
|
9
9
|
import ReqoreControlGroup from '../ControlGroup';
|
|
10
10
|
import { IReqorePanelProps } from '../Panel';
|
|
11
|
+
import { getZoomActions, sizeToZoom, zoomToSize } from '../Table/helpers';
|
|
11
12
|
import ReqoreTag from '../Tag';
|
|
12
13
|
|
|
13
14
|
export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
|
|
@@ -18,6 +19,8 @@ export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
|
|
|
18
19
|
onItemClick?: (value: any, path?: string[]) => void;
|
|
19
20
|
withLabelCopy?: boolean;
|
|
20
21
|
showControls?: boolean;
|
|
22
|
+
zoomable?: boolean;
|
|
23
|
+
defaultZoom?: 0 | 0.5 | 1 | 1.5 | 2;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface ITreeStyle {
|
|
@@ -38,6 +41,8 @@ export const ReqoreTree = ({
|
|
|
38
41
|
onItemClick,
|
|
39
42
|
withLabelCopy,
|
|
40
43
|
showControls = true,
|
|
44
|
+
zoomable,
|
|
45
|
+
defaultZoom,
|
|
41
46
|
...rest
|
|
42
47
|
}: IReqoreTreeProps) => {
|
|
43
48
|
const [_mode, setMode] = useState<'tree' | 'copy'>(mode);
|
|
@@ -45,6 +50,7 @@ export const ReqoreTree = ({
|
|
|
45
50
|
const [allExpanded, setAllExpanded] = useState(expanded || !showControls);
|
|
46
51
|
const [_showTypes, setShowTypes] = useState(showTypes);
|
|
47
52
|
const addNotification = useReqoreProperty('addNotification');
|
|
53
|
+
const [zoom, setZoom] = useState(defaultZoom || sizeToZoom[size]);
|
|
48
54
|
|
|
49
55
|
const handleCopyClick = () => {
|
|
50
56
|
setMode('copy');
|
|
@@ -99,7 +105,7 @@ export const ReqoreTree = ({
|
|
|
99
105
|
return (
|
|
100
106
|
<div key={index} style={{ margin: level === 1 ? '15px 0' : `15px` }}>
|
|
101
107
|
{isObject ? (
|
|
102
|
-
<ReqoreControlGroup size={
|
|
108
|
+
<ReqoreControlGroup size={zoomToSize[zoom]}>
|
|
103
109
|
<ReqoreButton
|
|
104
110
|
className='reqore-tree-toggle'
|
|
105
111
|
icon={isExpandable ? 'ArrowDownSFill' : 'ArrowRightSFill'}
|
|
@@ -112,7 +118,7 @@ export const ReqoreTree = ({
|
|
|
112
118
|
{_showTypes ? <ReqoreTag label={dataType} className='reqore-tree-type' /> : null}
|
|
113
119
|
</ReqoreControlGroup>
|
|
114
120
|
) : (
|
|
115
|
-
<ReqoreControlGroup size={
|
|
121
|
+
<ReqoreControlGroup size={zoomToSize[zoom]}>
|
|
116
122
|
<ReqoreTag
|
|
117
123
|
label={displayKey}
|
|
118
124
|
actions={
|
|
@@ -184,6 +190,11 @@ export const ReqoreTree = ({
|
|
|
184
190
|
actions={
|
|
185
191
|
showControls
|
|
186
192
|
? [
|
|
193
|
+
{
|
|
194
|
+
fluid: false,
|
|
195
|
+
group: getZoomActions('reqore-tree', zoom, setZoom),
|
|
196
|
+
show: !!zoomable,
|
|
197
|
+
},
|
|
187
198
|
{
|
|
188
199
|
className: 'reqore-tree-expand-all',
|
|
189
200
|
icon: 'ArrowDownFill',
|
package/src/constants/paging.ts
CHANGED
|
@@ -24,6 +24,28 @@ export type TReqorePaginationTypeResult<T> = {
|
|
|
24
24
|
includeBottomControls?: boolean;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
export function getPagingObjectFromType<T>(
|
|
28
|
+
type: TReqorePaginationType<T>
|
|
29
|
+
): IReqoreComponentPagingOptions<T> {
|
|
30
|
+
if (typeof type === 'object') {
|
|
31
|
+
return type;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
switch (type) {
|
|
35
|
+
case 'buttons':
|
|
36
|
+
return {};
|
|
37
|
+
case 'list':
|
|
38
|
+
return {
|
|
39
|
+
showPagesAs: 'list',
|
|
40
|
+
};
|
|
41
|
+
case 'infinite':
|
|
42
|
+
case 'auto-load':
|
|
43
|
+
return { infinite: true };
|
|
44
|
+
default:
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
27
49
|
export function getPaginationOptionsFromType<T>(
|
|
28
50
|
type: TReqorePaginationType<T>
|
|
29
51
|
): TReqorePaginationTypeResult<T> {
|
|
@@ -125,6 +125,22 @@ SelectedFirst.args = {
|
|
|
125
125
|
showSelectedFirst: true,
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
+
export const Zoomable = Template.bind({});
|
|
129
|
+
Zoomable.args = {
|
|
130
|
+
label: 'Collection of items',
|
|
131
|
+
items,
|
|
132
|
+
zoomable: true,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const WithDefaultZoom = Template.bind({});
|
|
136
|
+
WithDefaultZoom.args = {
|
|
137
|
+
label: 'Collection of items',
|
|
138
|
+
items,
|
|
139
|
+
zoomable: true,
|
|
140
|
+
size: 'tiny',
|
|
141
|
+
defaultZoom: 2,
|
|
142
|
+
};
|
|
143
|
+
|
|
128
144
|
export const CustomColumnsData = Template.bind({});
|
|
129
145
|
CustomColumnsData.args = {
|
|
130
146
|
columns: 2,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
2
|
import { StyledEffect } from '../../components/Effect';
|
|
3
|
-
import { IReqoreTableColumn, IReqoreTableProps } from '../../components/Table';
|
|
3
|
+
import { IReqoreTableColumn, IReqoreTableProps, IReqoreTableRowData } from '../../components/Table';
|
|
4
4
|
import { IReqoreCustomTableBodyCellProps } from '../../components/Table/cell';
|
|
5
5
|
import { IReqoreCustomHeaderCellProps } from '../../components/Table/header';
|
|
6
|
+
import { TReqorePaginationType } from '../../constants/paging';
|
|
6
7
|
import {
|
|
7
8
|
ReqoreH3,
|
|
8
9
|
ReqoreH4,
|
|
@@ -430,6 +431,22 @@ Sizes.args = {
|
|
|
430
431
|
wrapperSize: 'big',
|
|
431
432
|
};
|
|
432
433
|
|
|
434
|
+
export const DefaultPaging = Template.bind({});
|
|
435
|
+
DefaultPaging.args = {
|
|
436
|
+
paging: 'buttons',
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
export const CustomPaging = Template.bind({});
|
|
440
|
+
CustomPaging.args = {
|
|
441
|
+
paging: {
|
|
442
|
+
fluid: true,
|
|
443
|
+
loadMoreLabel: 'Load more rows...',
|
|
444
|
+
showLabels: true,
|
|
445
|
+
infinite: true,
|
|
446
|
+
itemsPerPage: 100,
|
|
447
|
+
} as TReqorePaginationType<IReqoreTableRowData>,
|
|
448
|
+
};
|
|
449
|
+
|
|
433
450
|
const CustomHeaderCell = (props: IReqoreCustomHeaderCellProps) => {
|
|
434
451
|
if (props.hasColumns) {
|
|
435
452
|
return <ReqoreH3 intent='success'>{props.label}</ReqoreH3>;
|
|
@@ -47,3 +47,16 @@ export const NoControls = Template.bind({});
|
|
|
47
47
|
NoControls.args = {
|
|
48
48
|
showControls: false,
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
export const Zoomable = Template.bind({});
|
|
52
|
+
Zoomable.args = {
|
|
53
|
+
zoomable: true,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const WithDefaultZoom = Template.bind({});
|
|
57
|
+
WithDefaultZoom.args = {
|
|
58
|
+
label: 'Collection of items',
|
|
59
|
+
zoomable: true,
|
|
60
|
+
size: 'tiny',
|
|
61
|
+
defaultZoom: 2,
|
|
62
|
+
};
|