@qoretechnologies/reqore 0.35.1 → 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.
Files changed (77) hide show
  1. package/__tests__/helpers/table.test.tsx +20 -0
  2. package/dist/components/Collection/index.d.ts +11 -2
  3. package/dist/components/Collection/index.d.ts.map +1 -1
  4. package/dist/components/Collection/index.js +33 -7
  5. package/dist/components/Collection/index.js.map +1 -1
  6. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  7. package/dist/components/ControlGroup/index.js +1 -1
  8. package/dist/components/ControlGroup/index.js.map +1 -1
  9. package/dist/components/Dropdown/list.d.ts +1 -0
  10. package/dist/components/Dropdown/list.d.ts.map +1 -1
  11. package/dist/components/Dropdown/list.js.map +1 -1
  12. package/dist/components/Menu/divider.d.ts +1 -0
  13. package/dist/components/Menu/divider.d.ts.map +1 -1
  14. package/dist/components/Menu/divider.js +3 -2
  15. package/dist/components/Menu/divider.js.map +1 -1
  16. package/dist/components/Spacer/index.d.ts.map +1 -1
  17. package/dist/components/Spacer/index.js +1 -1
  18. package/dist/components/Spacer/index.js.map +1 -1
  19. package/dist/components/Table/body.d.ts +10 -4
  20. package/dist/components/Table/body.d.ts.map +1 -1
  21. package/dist/components/Table/body.js +44 -9
  22. package/dist/components/Table/body.js.map +1 -1
  23. package/dist/components/Table/cell.d.ts.map +1 -1
  24. package/dist/components/Table/cell.js +2 -2
  25. package/dist/components/Table/cell.js.map +1 -1
  26. package/dist/components/Table/header.d.ts +8 -7
  27. package/dist/components/Table/header.d.ts.map +1 -1
  28. package/dist/components/Table/header.js +34 -37
  29. package/dist/components/Table/header.js.map +1 -1
  30. package/dist/components/Table/headerCell.d.ts +2 -2
  31. package/dist/components/Table/headerCell.d.ts.map +1 -1
  32. package/dist/components/Table/headerCell.js +25 -7
  33. package/dist/components/Table/headerCell.js.map +1 -1
  34. package/dist/components/Table/helpers.d.ts +2 -0
  35. package/dist/components/Table/helpers.d.ts.map +1 -1
  36. package/dist/components/Table/helpers.js +28 -2
  37. package/dist/components/Table/helpers.js.map +1 -1
  38. package/dist/components/Table/index.d.ts +9 -2
  39. package/dist/components/Table/index.d.ts.map +1 -1
  40. package/dist/components/Table/index.js +175 -15
  41. package/dist/components/Table/index.js.map +1 -1
  42. package/dist/components/Table/row.d.ts.map +1 -1
  43. package/dist/components/Table/row.js +17 -28
  44. package/dist/components/Table/row.js.map +1 -1
  45. package/dist/components/Tree/index.d.ts +3 -1
  46. package/dist/components/Tree/index.d.ts.map +1 -1
  47. package/dist/components/Tree/index.js +9 -2
  48. package/dist/components/Tree/index.js.map +1 -1
  49. package/dist/constants/paging.d.ts +1 -0
  50. package/dist/constants/paging.d.ts.map +1 -1
  51. package/dist/constants/paging.js +20 -1
  52. package/dist/constants/paging.js.map +1 -1
  53. package/dist/constants/sizes.d.ts +15 -0
  54. package/dist/constants/sizes.d.ts.map +1 -1
  55. package/dist/constants/sizes.js +16 -1
  56. package/dist/constants/sizes.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/components/Collection/index.tsx +41 -6
  59. package/src/components/ControlGroup/index.tsx +1 -0
  60. package/src/components/Dropdown/list.tsx +1 -0
  61. package/src/components/Menu/divider.tsx +31 -21
  62. package/src/components/Spacer/index.tsx +2 -2
  63. package/src/components/Table/body.tsx +87 -36
  64. package/src/components/Table/cell.tsx +4 -1
  65. package/src/components/Table/header.tsx +133 -124
  66. package/src/components/Table/headerCell.tsx +34 -8
  67. package/src/components/Table/helpers.ts +42 -2
  68. package/src/components/Table/index.tsx +251 -53
  69. package/src/components/Table/row.tsx +34 -53
  70. package/src/components/Tree/index.tsx +13 -2
  71. package/src/constants/paging.ts +22 -0
  72. package/src/constants/sizes.ts +17 -0
  73. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -3
  74. package/src/stories/Collection/Collection.stories.tsx +16 -0
  75. package/src/stories/Table/Table.stories.tsx +96 -1
  76. package/src/stories/Tree/Tree.stories.tsx +13 -0
  77. package/tests.json +1 -1
@@ -1,8 +1,10 @@
1
1
  /* @flow */
2
2
  import { size as count, isArray } from 'lodash';
3
- import React, { useCallback, useMemo, useState } from 'react';
3
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
4
4
  import { useMeasure, useUpdateEffect } from 'react-use';
5
- import { ReqoreMessage, ReqorePanel, ReqoreVerticalSpacer } from '../..';
5
+ import styled, { css } from 'styled-components';
6
+ import { ReqoreMessage, ReqorePaginationContainer, ReqorePanel, ReqoreVerticalSpacer } from '../..';
7
+ import { TReqorePaginationType, getPagingObjectFromType } from '../../constants/paging';
6
8
  import { TABLE_SIZE_TO_PX, TSizes } from '../../constants/sizes';
7
9
  import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
8
10
  import { useQueryWithDelay } from '../../hooks/useQueryWithDelay';
@@ -17,9 +19,11 @@ import { IReqoreTableHeaderCellProps } from './headerCell';
17
19
  import {
18
20
  fixSort,
19
21
  flipSortDirection,
22
+ getColumnsByPinType,
20
23
  getColumnsCount,
21
24
  getOnlyShownColumns,
22
25
  getZoomActions,
26
+ hasGroupedColumns,
23
27
  hasHiddenColumns,
24
28
  prepareColumns,
25
29
  sizeToZoom,
@@ -44,12 +48,16 @@ export interface IReqoreTableColumn extends IReqoreIntent {
44
48
  show?: boolean;
45
49
  grow?: 1 | 2 | 3 | 4;
46
50
  width?: number;
51
+ minWidth?: number;
52
+ maxWidth?: number;
47
53
  resizedWidth?: number;
48
54
  align?: 'center' | 'left' | 'right';
55
+ pin?: 'left' | 'right';
49
56
 
50
57
  resizable?: boolean;
51
58
  sortable?: boolean;
52
59
  hideable?: boolean;
60
+ pinnable?: boolean;
53
61
 
54
62
  filterable?: boolean;
55
63
  filterPlaceholder?: string;
@@ -59,12 +67,13 @@ export interface IReqoreTableColumn extends IReqoreIntent {
59
67
  columns?: IReqoreTableColumn[];
60
68
  component?: React.FC<IReqoreTableHeaderCellProps>;
61
69
  actions?: IReqoreDropdownItem[];
62
- } & IReqoreButtonProps;
70
+ } & Omit<IReqoreButtonProps, 'maxWidth'>;
63
71
 
64
72
  cell?: {
65
73
  onClick?: (cellValue: any) => void;
66
74
  tooltip?: (cellValue: any) => string | IReqoreTooltip;
67
75
  content?: TReqoreTableColumnContent;
76
+ actions?: (data: IReqoreTableRowData) => IReqoreButtonProps[];
68
77
  intent?: TReqoreIntent;
69
78
  padded?: 'both' | 'horizontal' | 'vertical' | 'none';
70
79
  };
@@ -88,6 +97,8 @@ export interface IReqoreTableProps extends IReqorePanelProps {
88
97
  height?: number;
89
98
  wrapperSize?: TSizes;
90
99
 
100
+ paging?: TReqorePaginationType<IReqoreTableRowData>;
101
+
91
102
  sort?: IReqoreTableSort;
92
103
  onSortChange?: (sort?: IReqoreTableSort) => void;
93
104
 
@@ -131,6 +142,30 @@ export interface IReqoreTableSort {
131
142
  direction?: 'asc' | 'desc';
132
143
  }
133
144
 
145
+ const StyledTableWrapper = styled.div`
146
+ overflow: hidden;
147
+ display: flex;
148
+ flex-flow: column;
149
+
150
+ ${({ isPinned }) =>
151
+ isPinned
152
+ ? css`
153
+ flex-shrink: 0;
154
+ z-index: 1;
155
+ box-shadow: 1px -1px 20px -2px rgba(0, 0, 0, 0.8);
156
+ `
157
+ : css`
158
+ width: 100%;
159
+ flex: 1;
160
+ `};
161
+ `;
162
+
163
+ const StyledTablesWrapper = styled.div`
164
+ display: flex;
165
+ flex-flow: row;
166
+ overflow: hidden;
167
+ `;
168
+
134
169
  const ReqoreTable = ({
135
170
  className,
136
171
  height = 300,
@@ -146,7 +181,7 @@ const ReqoreTable = ({
146
181
  customTheme,
147
182
  onRowClick,
148
183
  striped,
149
- selectedRowIntent,
184
+ selectedRowIntent = 'info',
150
185
  size = 'normal',
151
186
  wrapperSize = 'normal',
152
187
  intent,
@@ -162,15 +197,21 @@ const ReqoreTable = ({
162
197
  rowComponent,
163
198
  bodyCellComponent,
164
199
  onSelectClick,
200
+ paging,
165
201
  ...rest
166
202
  }: IReqoreTableProps) => {
167
- const [leftScroll, setLeftScroll] = useState<number>(0);
203
+ const leftTableRef = useRef<HTMLDivElement>(undefined);
204
+ const rightTableRef = useRef<HTMLDivElement>(undefined);
205
+ const mainTableRef = useRef<HTMLDivElement>(undefined);
206
+ const mainHeaderRef = useRef<HTMLDivElement>(undefined);
207
+
208
+ const [isScrolled, setIsScrolled] = useState<boolean>(false);
168
209
  const [_data, setData] = useState<IReqoreTableData>(data || []);
169
210
  const [_sort, setSort] = useState<IReqoreTableSort>(fixSort(sort));
170
- const [_selected, setSelected] = useState<(string | number)[]>([]);
211
+ const [_selected, setSelected] = useState<(string | number)[]>(selected || []);
171
212
  const [_selectedQuant, setSelectedQuant] = useState<'all' | 'none' | 'some'>('none');
172
213
  const [columnModifiers, setColumnModifiers] = useState<{
173
- [key: string]: { [dataId: string]: any };
214
+ [dataId: string]: { [modifier: string]: any };
174
215
  }>({});
175
216
  const [_internalColumns, setColumns] = useState<IReqoreTableColumn[]>(columns);
176
217
  const [zoom, setZoom] = useState<number>(sizeToZoom[size]);
@@ -178,10 +219,74 @@ const ReqoreTable = ({
178
219
  const [wrapperRef, sizes] = useMeasure();
179
220
  const { query, preQuery, setQuery, setPreQuery } = useQueryWithDelay(filter, 300, onFilterChange);
180
221
 
181
- const finalColumns = useMemo(
182
- () => prepareColumns(_internalColumns, columnModifiers, size),
183
- [_internalColumns, columnModifiers]
184
- );
222
+ const selectedIcon = useMemo(() => {
223
+ switch (_selectedQuant) {
224
+ case 'all':
225
+ return 'CheckboxCircleLine';
226
+ case 'some':
227
+ return 'IndeterminateCircleLine';
228
+ default:
229
+ return 'CheckboxBlankCircleLine';
230
+ }
231
+ }, [_selectedQuant]);
232
+
233
+ const finalColumns = useMemo(() => {
234
+ let fullColumns = [..._internalColumns];
235
+
236
+ if (selectable) {
237
+ fullColumns.unshift({
238
+ dataId: 'selectbox',
239
+ width: 50,
240
+ sortable: false,
241
+ hideable: false,
242
+ filterable: false,
243
+ resizable: false,
244
+ pin: 'left',
245
+ pinnable: false,
246
+ align: 'center',
247
+
248
+ header: {
249
+ icon: selectedIcon,
250
+ tooltip: 'Toggle selection on all data',
251
+ onClick: () => {
252
+ handleToggleSelectClick();
253
+ },
254
+ },
255
+
256
+ cell: {
257
+ padded: 'none',
258
+ actions: ({ _selectId }) => [
259
+ {
260
+ tooltip: selectToggleTooltip,
261
+ icon: !_selectId
262
+ ? 'Forbid2Line'
263
+ : _selected?.find((s) => s === _selectId)
264
+ ? 'CheckboxCircleLine'
265
+ : 'CheckboxBlankCircleLine',
266
+ intent: !_selectId
267
+ ? 'muted'
268
+ : _selected?.find((s) => s === _selectId)
269
+ ? selectedRowIntent
270
+ : undefined,
271
+ onClick: () => handleSelectClick(_selectId),
272
+ },
273
+ ],
274
+ },
275
+ });
276
+ }
277
+
278
+ return prepareColumns(fullColumns, columnModifiers, zoomToSize[zoom]);
279
+ }, [
280
+ _internalColumns,
281
+ columnModifiers,
282
+ zoom,
283
+ selectable,
284
+ _selectedQuant,
285
+ selectedIcon,
286
+ selectToggleTooltip,
287
+ _selected,
288
+ selectedRowIntent,
289
+ ]);
185
290
 
186
291
  const filters: { [key: string]: string } = useMemo(() => {
187
292
  const getFilters = (columnsToTransform: IReqoreTableColumn[]) =>
@@ -353,6 +458,10 @@ const ReqoreTable = ({
353
458
  };
354
459
 
355
460
  finalColumns.forEach((column) => {
461
+ if (column.hideable === false) {
462
+ return;
463
+ }
464
+
356
465
  if (column.header?.columns) {
357
466
  column.header?.columns.forEach((subColumn) => {
358
467
  addColumn(subColumn);
@@ -365,6 +474,23 @@ const ReqoreTable = ({
365
474
  return _columnsList;
366
475
  }, [finalColumns]);
367
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
+
368
494
  const tableActions = useMemo<IReqorePanelAction[]>(() => {
369
495
  const finalActions: IReqorePanelAction[] = [...actions];
370
496
 
@@ -406,6 +532,16 @@ const ReqoreTable = ({
406
532
  });
407
533
  }
408
534
 
535
+ if (isScrolled) {
536
+ finalActions.push({
537
+ icon: 'ArrowUpSFill',
538
+ tooltip: 'Scroll to top',
539
+ className: 'reqore-table-columns-scroll-top',
540
+ responsive: true,
541
+ onClick: handleScrollToTop,
542
+ });
543
+ }
544
+
409
545
  if (count(columnModifiers) || zoomable || filterable) {
410
546
  finalActions.push({
411
547
  icon: 'MoreLine',
@@ -437,6 +573,7 @@ const ReqoreTable = ({
437
573
  zoomable,
438
574
  zoom,
439
575
  columnsList,
576
+ isScrolled,
440
577
  ]);
441
578
 
442
579
  const badge = useMemo(() => {
@@ -453,12 +590,82 @@ const ReqoreTable = ({
453
590
  return badgeList;
454
591
  }, [transformedData, rest.badge]);
455
592
 
593
+ const refs = {
594
+ left: leftTableRef,
595
+ right: rightTableRef,
596
+ main: mainTableRef,
597
+ header: mainHeaderRef,
598
+ };
599
+
600
+ const columnsByType = useMemo(
601
+ () => ({
602
+ left: getColumnsByPinType(finalColumns, 'left'),
603
+ right: getColumnsByPinType(finalColumns, 'right'),
604
+ main: getColumnsByPinType(finalColumns, 'main'),
605
+ }),
606
+ [finalColumns]
607
+ );
608
+
609
+ const renderTable = (type: 'left' | 'main' | 'right' = 'main', items: IReqoreTableRowData[]) => {
610
+ const tableColumns = columnsByType[type];
611
+ const isPinned = type === 'left' || type === 'right';
612
+
613
+ if (count(tableColumns) === 0) {
614
+ return null;
615
+ }
616
+
617
+ return (
618
+ <StyledTableWrapper isPinned={isPinned}>
619
+ <ReqoreTableHeader
620
+ size={zoomToSize[zoom]}
621
+ columns={tableColumns}
622
+ scrollable={type === 'main'}
623
+ ref={type === 'main' ? mainHeaderRef : undefined}
624
+ bodyRef={mainTableRef}
625
+ onSortChange={handleSortChange}
626
+ heightAsGroup={hasGroupedColumns(finalColumns)}
627
+ sortData={_sort}
628
+ hasVerticalScroll={count(items) * TABLE_SIZE_TO_PX[size] > height}
629
+ onColumnsUpdate={handleColumnsUpdate}
630
+ onFilterChange={(dataId: string, value: any) => {
631
+ handleColumnsUpdate(dataId, 'filter', value);
632
+ }}
633
+ component={headerCellComponent}
634
+ />
635
+ {count(items) === 0 ? null : (
636
+ <ReqoreTableBody
637
+ ref={refs[type]}
638
+ refs={refs}
639
+ type={type}
640
+ data={items}
641
+ columns={tableColumns}
642
+ height={fill ? sizes.height : height}
643
+ selectable={selectable}
644
+ onSelectClick={handleSelectClick}
645
+ onRowClick={onRowClick}
646
+ onScrollChange={(isScrolled) => setIsScrolled(isScrolled)}
647
+ selected={_selected}
648
+ selectedRowIntent={selectedRowIntent}
649
+ size={zoomToSize[zoom]}
650
+ striped={striped}
651
+ flat={rest.flat}
652
+ rowComponent={rowComponent}
653
+ cellComponent={bodyCellComponent}
654
+ />
655
+ )}
656
+ </StyledTableWrapper>
657
+ );
658
+ };
659
+
660
+ const pagingOptions = useMemo(() => getPagingObjectFromType(paging), [paging]);
661
+
456
662
  return (
457
663
  <ReqorePanel
458
664
  transparent
459
665
  flat
460
666
  padded={false}
461
667
  contentStyle={{ display: 'flex', flexFlow: 'column', overflow: 'hidden' }}
668
+ responsiveActions={false}
462
669
  {...rest}
463
670
  size={wrapperSize}
464
671
  actions={tableActions}
@@ -468,48 +675,39 @@ const ReqoreTable = ({
468
675
  getContentRef={wrapperRef}
469
676
  badge={badge}
470
677
  >
471
- <ReqoreTableHeader
472
- size={zoomToSize[zoom]}
473
- columns={finalColumns}
474
- leftScroll={leftScroll}
475
- onSortChange={handleSortChange}
476
- sortData={_sort}
477
- selectable={selectable}
478
- selectedQuant={_selectedQuant}
479
- onToggleSelectClick={handleToggleSelectClick}
480
- hasVerticalScroll={count(transformedData) * TABLE_SIZE_TO_PX[size] > height}
481
- selectToggleTooltip={selectToggleTooltip}
482
- onColumnsUpdate={handleColumnsUpdate}
483
- onFilterChange={(dataId: string, value: any) => {
484
- handleColumnsUpdate(dataId, 'filter', value);
485
- }}
486
- component={headerCellComponent}
487
- />
488
- {count(transformedData) === 0 ? (
489
- <>
490
- <ReqoreVerticalSpacer height={10} />
491
- <ReqoreMessage flat size={size} icon='Search2Line'>
492
- {emptyMessage}
493
- </ReqoreMessage>
494
- </>
495
- ) : (
496
- <ReqoreTableBody
497
- data={transformedData}
498
- columns={finalColumns}
499
- setLeftScroll={setLeftScroll}
500
- height={fill ? sizes.height : height}
501
- selectable={selectable}
502
- onSelectClick={handleSelectClick}
503
- onRowClick={onRowClick}
504
- selected={_selected}
505
- selectedRowIntent={selectedRowIntent}
506
- size={zoomToSize[zoom]}
507
- striped={striped}
508
- flat={rest.flat}
509
- rowComponent={rowComponent}
510
- cellComponent={bodyCellComponent}
511
- />
512
- )}
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>
513
711
  </ReqorePanel>
514
712
  );
515
713
  };
@@ -2,24 +2,18 @@
2
2
  import { isFunction, isString } from 'lodash';
3
3
  import React, { ReactElement, useState } from 'react';
4
4
  import styled, { css } from 'styled-components';
5
- import {
6
- IReqoreTableColumn,
7
- IReqoreTableData,
8
- IReqoreTableRowClick,
9
- TReqoreTableColumnContent,
10
- } from '.';
11
- import { ReqorePopover } from '../..';
5
+ import { IReqoreTableColumn, IReqoreTableData, IReqoreTableRowClick } from '.';
6
+ import { ReqoreButton, ReqoreControlGroup, ReqorePopover } from '../..';
12
7
  import { SIZE_TO_PX, TSizes } from '../../constants/sizes';
13
8
  import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
14
9
  import { IReqoreTooltip } from '../../types/global';
15
10
  import { TReqoreHexColor } from '../Effect';
16
11
  import { ReqoreH4 } from '../Header';
17
- import ReqoreIcon from '../Icon';
18
12
  import { ReqoreP } from '../Paragraph';
19
13
  import ReqoreTag from '../Tag';
20
14
  import { TimeAgo } from '../TimeAgo';
21
15
  import { IReqoreCustomTableBodyCell, ReqoreTableBodyCell } from './cell';
22
- import { calculateMinimumCellWidth, getOnlyShownColumns } from './helpers';
16
+ import { getOnlyShownColumns } from './helpers';
23
17
 
24
18
  export interface IReqoreTableRowOptions {
25
19
  columns: IReqoreTableColumn[];
@@ -89,7 +83,7 @@ const ReqoreTableRow = ({
89
83
  onRowClick,
90
84
  striped,
91
85
  size,
92
- selectedRowIntent = 'info',
86
+ selectedRowIntent,
93
87
  flat,
94
88
  cellComponent,
95
89
  rowComponent,
@@ -104,10 +98,34 @@ const ReqoreTableRow = ({
104
98
  const RowComponent = rowComponent || StyledTableRow;
105
99
 
106
100
  const renderContent = (
107
- content: TReqoreTableColumnContent,
101
+ cell: IReqoreTableColumn['cell'],
108
102
  data: any,
109
- dataId: string
103
+ dataId: string,
104
+ align?: 'center' | 'left' | 'right'
110
105
  ): ReactElement<any, any> => {
106
+ if (cell?.actions) {
107
+ return (
108
+ <ReqoreControlGroup size={size} stack fill fluid style={{ height: '100%' }} rounded={false}>
109
+ {cell.actions(data).map((action, index) => (
110
+ <ReqoreButton
111
+ key={index}
112
+ rounded={false}
113
+ iconsAlign={align === 'center' ? 'center' : 'sides'}
114
+ textAlign={align}
115
+ {...action}
116
+ onClick={(e) => {
117
+ e.stopPropagation();
118
+
119
+ action.onClick?.(e);
120
+ }}
121
+ />
122
+ ))}
123
+ </ReqoreControlGroup>
124
+ );
125
+ }
126
+
127
+ const content = cell?.content;
128
+
111
129
  if (isFunction(content)) {
112
130
  const Content = content;
113
131
 
@@ -156,7 +174,7 @@ const ReqoreTableRow = ({
156
174
 
157
175
  const renderCells = (columns: IReqoreTableColumn[], data: IReqoreTableData) =>
158
176
  getOnlyShownColumns(columns).map(
159
- ({ width, resizedWidth, grow, dataId, cell, header, align, intent }) => {
177
+ ({ width, minWidth, maxWidth, resizedWidth, grow, dataId, cell, header, align, intent }) => {
160
178
  if (header.columns) {
161
179
  return renderCells(header.columns, data);
162
180
  }
@@ -178,6 +196,8 @@ const ReqoreTableRow = ({
178
196
  componentProps={
179
197
  {
180
198
  width: resizedWidth || width,
199
+ minWidth,
200
+ maxWidth,
181
201
  grow,
182
202
  align,
183
203
  size,
@@ -209,7 +229,7 @@ const ReqoreTableRow = ({
209
229
  }
210
230
  {...tooltip}
211
231
  >
212
- {renderContent(cell?.content, data[index], dataId)}
232
+ {renderContent(cell, data[index], dataId, align)}
213
233
  </ReqorePopover>
214
234
  );
215
235
  }
@@ -230,45 +250,6 @@ const ReqoreTableRow = ({
230
250
  setIsHovered(false);
231
251
  }}
232
252
  >
233
- {selectable && (
234
- <CellComponent
235
- align='center'
236
- width={calculateMinimumCellWidth(50, size)}
237
- className='reqore-table-cell'
238
- {...{
239
- size,
240
- striped,
241
- disabled: data[index]._disabled,
242
- selected: !!isSelected,
243
- selectedIntent: selectedRowIntent,
244
- flat,
245
- even: index % 2 === 0 ? true : false,
246
- intent: data[index]._intent,
247
- hovered: isHovered,
248
- interactiveCell: data[index]._selectId,
249
- }}
250
- onClick={
251
- data[index]._selectId
252
- ? (e: React.MouseEvent<HTMLDivElement>) => {
253
- e.stopPropagation();
254
- onSelectClick(data[index]._selectId);
255
- }
256
- : undefined
257
- }
258
- >
259
- <ReqoreIcon
260
- icon={
261
- !data[index]._selectId
262
- ? 'Forbid2Line'
263
- : isSelected
264
- ? 'CheckboxCircleLine'
265
- : 'CheckboxBlankCircleLine'
266
- }
267
- size={size}
268
- style={{ opacity: !data[index]._selectId || !isSelected ? 0.4 : 1 }}
269
- />
270
- </CellComponent>
271
- )}
272
253
  {renderCells(columns, data)}
273
254
  </RowComponent>
274
255
  );
@@ -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={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={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',
@@ -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> {
@@ -11,6 +11,23 @@ export const ReqoreSizes = {
11
11
 
12
12
  export const SIZES = ['tiny', 'small', 'normal', 'big', 'huge'] as const;
13
13
 
14
+ export const SIZE_TO_MODIFIER = {
15
+ tiny: 0.6,
16
+ small: 0.8,
17
+ normal: 1,
18
+ big: 1.2,
19
+ huge: 1.4,
20
+ };
21
+
22
+ export const LINE_SIZE_TO_NUMBER = {
23
+ none: 0,
24
+ tiny: 1,
25
+ small: 1,
26
+ normal: 1.5,
27
+ big: 2,
28
+ huge: 3,
29
+ };
30
+
14
31
  export const SIZE_TO_NUMBER = {
15
32
  none: 0,
16
33
  tiny: 1,
@@ -16,9 +16,6 @@ export default {
16
16
  },
17
17
  ...SizeArg,
18
18
  },
19
- parameters: {
20
- jest: ['breadcrumbs.test.tsx'],
21
- },
22
19
  } as ComponentMeta<typeof ReqoreBreadcrumbs & { withTabs?: boolean }>;
23
20
 
24
21
  const Template: ComponentStory<typeof ReqoreBreadcrumbs & { withTabs?: boolean }> = (