@qoretechnologies/reqore 0.36.1 → 0.36.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 (148) hide show
  1. package/.eslintrc.js +40 -0
  2. package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
  3. package/dist/components/Breadcrumbs/item.js +1 -5
  4. package/dist/components/Breadcrumbs/item.js.map +1 -1
  5. package/dist/components/Comment/index.d.ts.map +1 -1
  6. package/dist/components/Comment/index.js +6 -5
  7. package/dist/components/Comment/index.js.map +1 -1
  8. package/dist/components/ControlGroup/index.d.ts +1 -1
  9. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  10. package/dist/components/ControlGroup/index.js +2 -2
  11. package/dist/components/ControlGroup/index.js.map +1 -1
  12. package/dist/components/Dropdown/index.d.ts +2 -2
  13. package/dist/components/Dropdown/index.d.ts.map +1 -1
  14. package/dist/components/Dropdown/index.js +1 -1
  15. package/dist/components/Dropdown/index.js.map +1 -1
  16. package/dist/components/Dropdown/list.d.ts.map +1 -1
  17. package/dist/components/Dropdown/list.js.map +1 -1
  18. package/dist/components/Input/index.d.ts.map +1 -1
  19. package/dist/components/Input/index.js +3 -2
  20. package/dist/components/Input/index.js.map +1 -1
  21. package/dist/components/InternalPopover/index.js +2 -2
  22. package/dist/components/InternalPopover/index.js.map +1 -1
  23. package/dist/components/KeyValueTable/index.d.ts +5 -2
  24. package/dist/components/KeyValueTable/index.d.ts.map +1 -1
  25. package/dist/components/KeyValueTable/index.js +33 -2
  26. package/dist/components/KeyValueTable/index.js.map +1 -1
  27. package/dist/components/Menu/index.d.ts.map +1 -1
  28. package/dist/components/Menu/index.js +8 -9
  29. package/dist/components/Menu/index.js.map +1 -1
  30. package/dist/components/Menu/item.d.ts +1 -2
  31. package/dist/components/Menu/item.d.ts.map +1 -1
  32. package/dist/components/Menu/item.js +1 -5
  33. package/dist/components/Menu/item.js.map +1 -1
  34. package/dist/components/Message/index.d.ts +1 -0
  35. package/dist/components/Message/index.d.ts.map +1 -1
  36. package/dist/components/Message/index.js.map +1 -1
  37. package/dist/components/Notifications/notification.d.ts +1 -0
  38. package/dist/components/Notifications/notification.d.ts.map +1 -1
  39. package/dist/components/Notifications/notification.js +20 -13
  40. package/dist/components/Notifications/notification.js.map +1 -1
  41. package/dist/components/Paging/index.d.ts +1 -1
  42. package/dist/components/Paging/index.d.ts.map +1 -1
  43. package/dist/components/Paging/index.js +1 -1
  44. package/dist/components/Paging/index.js.map +1 -1
  45. package/dist/components/Panel/index.d.ts.map +1 -1
  46. package/dist/components/Panel/index.js +2 -1
  47. package/dist/components/Panel/index.js.map +1 -1
  48. package/dist/components/Popover/index.d.ts.map +1 -1
  49. package/dist/components/Popover/index.js +1 -7
  50. package/dist/components/Popover/index.js.map +1 -1
  51. package/dist/components/RadioGroup/index.d.ts.map +1 -1
  52. package/dist/components/RadioGroup/index.js +3 -3
  53. package/dist/components/RadioGroup/index.js.map +1 -1
  54. package/dist/components/Sidebar/index.d.ts +2 -2
  55. package/dist/components/Sidebar/index.d.ts.map +1 -1
  56. package/dist/components/Sidebar/item.d.ts +6 -6
  57. package/dist/components/Sidebar/item.d.ts.map +1 -1
  58. package/dist/components/Sidebar/item.js +3 -9
  59. package/dist/components/Sidebar/item.js.map +1 -1
  60. package/dist/components/Table/body.d.ts +2 -0
  61. package/dist/components/Table/body.d.ts.map +1 -1
  62. package/dist/components/Table/body.js +25 -20
  63. package/dist/components/Table/body.js.map +1 -1
  64. package/dist/components/Table/cell.d.ts +3 -2
  65. package/dist/components/Table/cell.d.ts.map +1 -1
  66. package/dist/components/Table/cell.js +8 -4
  67. package/dist/components/Table/cell.js.map +1 -1
  68. package/dist/components/Table/helpers.js.map +1 -1
  69. package/dist/components/Table/index.d.ts +1 -1
  70. package/dist/components/Table/index.d.ts.map +1 -1
  71. package/dist/components/Table/index.js +13 -10
  72. package/dist/components/Table/index.js.map +1 -1
  73. package/dist/components/Table/row.d.ts +3 -1
  74. package/dist/components/Table/row.d.ts.map +1 -1
  75. package/dist/components/Table/row.js +40 -40
  76. package/dist/components/Table/row.js.map +1 -1
  77. package/dist/components/Tabs/item.d.ts.map +1 -1
  78. package/dist/components/Tabs/item.js +3 -2
  79. package/dist/components/Tabs/item.js.map +1 -1
  80. package/dist/components/TimeAgo/index.js +2 -2
  81. package/dist/components/TimeAgo/index.js.map +1 -1
  82. package/dist/components/Tree/index.d.ts +2 -2
  83. package/dist/components/Tree/index.d.ts.map +1 -1
  84. package/dist/components/Tree/index.js +6 -20
  85. package/dist/components/Tree/index.js.map +1 -1
  86. package/dist/constants/sizes.js +5 -5
  87. package/dist/containers/UIProvider.js.map +1 -1
  88. package/dist/helpers/sidebar.d.ts +3 -2
  89. package/dist/helpers/sidebar.d.ts.map +1 -1
  90. package/dist/helpers/sidebar.js +4 -2
  91. package/dist/helpers/sidebar.js.map +1 -1
  92. package/dist/helpers/utils.d.ts +1 -1
  93. package/dist/helpers/utils.d.ts.map +1 -1
  94. package/dist/helpers/utils.js.map +1 -1
  95. package/dist/hooks/usePopover.d.ts.map +1 -1
  96. package/dist/hooks/usePopover.js +1 -7
  97. package/dist/hooks/usePopover.js.map +1 -1
  98. package/dist/hooks/useTheme.js.map +1 -1
  99. package/dist/hooks/useWhyDidYouUpdate.js +1 -1
  100. package/dist/hooks/useWhyDidYouUpdate.js.map +1 -1
  101. package/package.json +7 -1
  102. package/src/components/Breadcrumbs/item.tsx +0 -1
  103. package/src/components/Comment/index.tsx +6 -4
  104. package/src/components/ControlGroup/index.tsx +1 -3
  105. package/src/components/Dropdown/index.tsx +5 -6
  106. package/src/components/Dropdown/list.tsx +6 -1
  107. package/src/components/Input/index.tsx +2 -2
  108. package/src/components/InternalPopover/index.tsx +2 -2
  109. package/src/components/KeyValueTable/index.tsx +46 -2
  110. package/src/components/Menu/index.tsx +1 -2
  111. package/src/components/Menu/item.tsx +1 -7
  112. package/src/components/Message/index.tsx +1 -0
  113. package/src/components/Notifications/notification.tsx +12 -1
  114. package/src/components/Paging/index.tsx +0 -1
  115. package/src/components/Panel/index.tsx +3 -2
  116. package/src/components/Popover/index.tsx +0 -2
  117. package/src/components/RadioGroup/index.tsx +2 -1
  118. package/src/components/Sidebar/index.tsx +2 -2
  119. package/src/components/Sidebar/item.tsx +7 -10
  120. package/src/components/Table/body.tsx +27 -18
  121. package/src/components/Table/cell.tsx +15 -4
  122. package/src/components/Table/helpers.ts +1 -1
  123. package/src/components/Table/index.tsx +59 -45
  124. package/src/components/Table/row.tsx +47 -48
  125. package/src/components/Tabs/item.tsx +2 -2
  126. package/src/components/TimeAgo/index.tsx +2 -2
  127. package/src/components/Tree/index.tsx +1 -17
  128. package/src/constants/sizes.ts +5 -5
  129. package/src/containers/UIProvider.tsx +1 -1
  130. package/src/helpers/sidebar.ts +20 -36
  131. package/src/helpers/utils.ts +1 -1
  132. package/src/hooks/usePopover.tsx +1 -7
  133. package/src/hooks/useTheme.ts +1 -1
  134. package/src/hooks/useWhyDidYouUpdate.ts +1 -1
  135. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +59 -0
  136. package/src/stories/Message/Message.stories.tsx +25 -0
  137. package/src/stories/Table/Table.stories.tsx +18 -1
  138. package/tests.json +1 -1
  139. package/dist/hooks/useShareForwardedRef.d.ts +0 -3
  140. package/dist/hooks/useShareForwardedRef.d.ts.map +0 -1
  141. package/dist/hooks/useShareForwardedRef.js +0 -25
  142. package/dist/hooks/useShareForwardedRef.js.map +0 -1
  143. package/dist/types/icons____.d.ts +0 -2
  144. package/dist/types/icons____.d.ts.map +0 -1
  145. package/dist/types/icons____.js +0 -5
  146. package/dist/types/icons____.js.map +0 -1
  147. package/src/hooks/useShareForwardedRef.ts +0 -23
  148. package/src/types/icons____.ts +0 -5
@@ -17,6 +17,8 @@ export interface IReqoreTableSectionBodyProps extends IReqoreTableRowOptions {
17
17
  };
18
18
  type: 'left' | 'right' | 'main';
19
19
  onScrollChange?: (isScrolled: boolean) => void;
20
+ setHoveredRow?: (index: number) => void;
21
+ hoveredRow?: number;
20
22
  }
21
23
 
22
24
  const StyledList = styled(List)`
@@ -42,29 +44,32 @@ const ReqoreTableBody = forwardRef<HTMLDivElement, IReqoreTableSectionBodyProps>
42
44
 
43
45
  useMount(() => {
44
46
  targetRef.current?.addEventListener('wheel', (e) => {
45
- if (e.deltaY) {
46
- e.preventDefault();
47
+ // Only scroll if the element is scrollable
48
+ if (refs[type].current?.scrollHeight > refs[type].current?.clientHeight) {
49
+ if (e.deltaY) {
50
+ e.preventDefault();
47
51
 
48
- const currentScroll = refs[type].current?.scrollTop + e.deltaY;
52
+ const currentScroll = refs[type].current?.scrollTop + e.deltaY;
49
53
 
50
- onScrollChange?.(currentScroll > 0);
54
+ onScrollChange?.(currentScroll > 0);
51
55
 
52
- refs[type].current?.scrollTo({ top: currentScroll });
56
+ refs[type].current?.scrollTo({ top: currentScroll });
53
57
 
54
- if (type === 'left') {
55
- refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
56
- refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
57
- } else if (type === 'main') {
58
- refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
59
- refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
60
- } else if (type === 'right') {
61
- refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
62
- refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
58
+ if (type === 'left') {
59
+ refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
60
+ refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
61
+ } else if (type === 'main') {
62
+ refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
63
+ refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
64
+ } else if (type === 'right') {
65
+ refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
66
+ refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
67
+ }
63
68
  }
64
- }
65
69
 
66
- if (e.deltaX && type === 'main') {
67
- refs.header.current?.scrollTo({ left: refs.main.current?.scrollLeft + e.deltaX });
70
+ if (e.deltaX && type === 'main') {
71
+ refs.header.current?.scrollTo({ left: refs.main.current?.scrollLeft + e.deltaX });
72
+ }
68
73
  }
69
74
  });
70
75
  });
@@ -82,7 +87,11 @@ const ReqoreTableBody = forwardRef<HTMLDivElement, IReqoreTableSectionBodyProps>
82
87
  itemCount={itemCount}
83
88
  // If the defined height is less than the count of items' height
84
89
  // use that height instead
85
- height={height > itemCount * rowHeight ? itemCount * rowHeight : height}
90
+ height={
91
+ (!height && height !== 0) || height > itemCount * rowHeight
92
+ ? itemCount * rowHeight
93
+ : height
94
+ }
86
95
  className='reqore-table-body'
87
96
  itemSize={rest.flat ? TABLE_SIZE_TO_PX[size] : TABLE_SIZE_TO_PX[size] + 1}
88
97
  itemData={{
@@ -1,9 +1,13 @@
1
1
  import { lighten, rgba } from 'polished';
2
+ import { forwardRef } from 'react';
2
3
  import styled, { css } from 'styled-components';
3
4
  import { IReqoreTableColumn } from '.';
4
5
  import { TEXT_FROM_SIZE } from '../../constants/sizes';
5
6
  import { changeLightness, getReadableColorFrom } from '../../helpers/colors';
6
7
  import { alignToFlexAlign } from '../../helpers/utils';
8
+ import { useCombinedRefs } from '../../hooks/useCombinedRefs';
9
+ import { useTooltip } from '../../hooks/useTooltip';
10
+ import { IWithReqoreTooltip } from '../../types/global';
7
11
  import { TReqoreColor } from '../Effect';
8
12
  import { IReqoreTableCellStyle } from './row';
9
13
 
@@ -11,7 +15,8 @@ export interface IReqoreCustomTableBodyCellProps extends IReqoreTableBodyCellPro
11
15
  export interface IReqoreCustomTableBodyCell extends React.FC<IReqoreCustomTableBodyCellProps> {}
12
16
  export interface IReqoreTableBodyCellProps
13
17
  extends Partial<IReqoreTableColumn>,
14
- React.HTMLAttributes<HTMLDivElement> {
18
+ React.HTMLAttributes<HTMLDivElement>,
19
+ IWithReqoreTooltip {
15
20
  children?: React.ReactNode;
16
21
  padded?: IReqoreTableColumn['cell']['padded'];
17
22
  }
@@ -118,6 +123,12 @@ export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
118
123
  }}
119
124
  `;
120
125
 
121
- export const ReqoreTableBodyCell = (props: IReqoreTableBodyCellProps) => {
122
- return <StyledTableCell {...props} />;
123
- };
126
+ export const ReqoreTableBodyCell = forwardRef<HTMLButtonElement, IReqoreTableBodyCellProps>(
127
+ (props: IReqoreTableBodyCellProps, ref) => {
128
+ const { targetRef } = useCombinedRefs(ref);
129
+
130
+ useTooltip(targetRef.current, props.tooltip);
131
+
132
+ return <StyledTableCell {...props} ref={targetRef} />;
133
+ }
134
+ );
@@ -249,7 +249,7 @@ export const prepareColumns = (
249
249
  };
250
250
  }
251
251
 
252
- let newWidth = calculateMinimumCellWidth(
252
+ const newWidth = calculateMinimumCellWidth(
253
253
  column.width || 50,
254
254
  size,
255
255
  column.header?.icon,
@@ -3,10 +3,17 @@ 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, ReqorePaginationContainer, ReqorePanel, ReqoreVerticalSpacer } from '../..';
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';
@@ -173,7 +180,7 @@ const StyledTablesWrapper = styled.div`
173
180
 
174
181
  const ReqoreTable = ({
175
182
  className,
176
- height = 300,
183
+ height,
177
184
  width,
178
185
  columns,
179
186
  data = [],
@@ -183,7 +190,6 @@ const ReqoreTable = ({
183
190
  selected,
184
191
  onSelectedChange,
185
192
  selectToggleTooltip,
186
- customTheme,
187
193
  onRowClick,
188
194
  striped,
189
195
  selectedRowIntent = 'info',
@@ -211,6 +217,7 @@ const ReqoreTable = ({
211
217
  const mainTableRef = useRef<HTMLDivElement>(null);
212
218
  const mainHeaderRef = useRef<HTMLDivElement>(null);
213
219
 
220
+ const [hoveredRow, setHoveredRow] = useState<number>();
214
221
  const [isScrolled, setIsScrolled] = useState<boolean>(false);
215
222
  const [_data, setData] = useState<IReqoreTableData>(data || []);
216
223
  const [_sort, setSort] = useState<IReqoreTableSort | undefined>(fixSort(sort));
@@ -222,6 +229,7 @@ const ReqoreTable = ({
222
229
  const [_internalColumns, setColumns] = useState<IReqoreTableColumn[]>(columns);
223
230
  const [zoom, setZoom] = useState<number>(sizeToZoom[size]);
224
231
  const [showExportModal, setShowExportModal] = useState<'full' | 'current' | undefined>(undefined);
232
+ const theme = useReqoreTheme('main', rest.customTheme, intent);
225
233
 
226
234
  const [wrapperRef, sizes] = useMeasure();
227
235
  const { query, preQuery, setQuery, setPreQuery } = useQueryWithDelay(
@@ -242,7 +250,7 @@ const ReqoreTable = ({
242
250
  }, [_selectedQuant]);
243
251
 
244
252
  const finalColumns = useMemo(() => {
245
- let fullColumns = [..._internalColumns];
253
+ const fullColumns = [..._internalColumns];
246
254
 
247
255
  if (selectable) {
248
256
  fullColumns.unshift({
@@ -554,6 +562,7 @@ const ReqoreTable = ({
554
562
 
555
563
  if (exportable) {
556
564
  moreActions = [
565
+ ...moreActions,
557
566
  ...getExportActions((type) => setShowExportModal(type)),
558
567
  { divider: true, line: true },
559
568
  ];
@@ -561,6 +570,7 @@ const ReqoreTable = ({
561
570
 
562
571
  if (zoomable) {
563
572
  moreActions = [
573
+ ...moreActions,
564
574
  ...getZoomActions('reqore-table', zoom, setZoom, true),
565
575
  { divider: true, line: true },
566
576
  ];
@@ -660,6 +670,8 @@ const ReqoreTable = ({
660
670
  <ReqoreTableBody
661
671
  ref={refs[type]}
662
672
  refs={refs}
673
+ hoveredRow={hoveredRow}
674
+ setHoveredRow={setHoveredRow}
663
675
  type={type}
664
676
  data={items}
665
677
  columns={tableColumns}
@@ -703,47 +715,49 @@ const ReqoreTable = ({
703
715
  getContentRef={wrapperRef}
704
716
  badge={badge}
705
717
  >
706
- <ReqorePaginationContainer<IReqoreTableRowData>
707
- items={transformedData}
708
- type={
709
- pagingOptions
710
- ? {
711
- ...pagingOptions,
712
- onPageChange: () => {
713
- if (!pagingOptions.infinite) {
714
- handleScrollToTop();
715
- }
716
- },
717
- }
718
- : undefined
719
- }
720
- >
721
- {(pagedData) => (
722
- <>
723
- {showExportModal && (
724
- <ReqoreExportModal
725
- data={removeInternalData(
726
- showExportModal === 'current' ? pagedData : transformedData
727
- )}
728
- onClose={() => setShowExportModal(undefined)}
729
- />
730
- )}
731
- <StyledTablesWrapper className='reqore-table-wrapper'>
732
- {renderTable('left', pagedData)}
733
- {renderTable('main', pagedData)}
734
- {renderTable('right', pagedData)}
735
- </StyledTablesWrapper>
736
- {count(pagedData) === 0 ? (
737
- <>
738
- <ReqoreVerticalSpacer height={10} />
739
- <ReqoreMessage flat size={size} icon='Search2Line'>
740
- {emptyMessage}
741
- </ReqoreMessage>
742
- </>
743
- ) : null}
744
- </>
745
- )}
746
- </ReqorePaginationContainer>
718
+ <ReqoreThemeProvider theme={theme}>
719
+ <ReqorePaginationContainer<IReqoreTableRowData>
720
+ items={transformedData}
721
+ type={
722
+ pagingOptions
723
+ ? {
724
+ ...pagingOptions,
725
+ onPageChange: () => {
726
+ if (!pagingOptions.infinite) {
727
+ handleScrollToTop();
728
+ }
729
+ },
730
+ }
731
+ : undefined
732
+ }
733
+ >
734
+ {(pagedData) => (
735
+ <>
736
+ {showExportModal && (
737
+ <ReqoreExportModal
738
+ data={removeInternalData(
739
+ showExportModal === 'current' ? pagedData : transformedData
740
+ )}
741
+ onClose={() => setShowExportModal(undefined)}
742
+ />
743
+ )}
744
+ <StyledTablesWrapper className='reqore-table-wrapper'>
745
+ {renderTable('left', pagedData)}
746
+ {renderTable('main', pagedData)}
747
+ {renderTable('right', pagedData)}
748
+ </StyledTablesWrapper>
749
+ {count(pagedData) === 0 ? (
750
+ <>
751
+ <ReqoreVerticalSpacer height={10} />
752
+ <ReqoreMessage flat size={size} icon='Search2Line'>
753
+ {emptyMessage}
754
+ </ReqoreMessage>
755
+ </>
756
+ ) : null}
757
+ </>
758
+ )}
759
+ </ReqorePaginationContainer>
760
+ </ReqoreThemeProvider>
747
761
  </ReqorePanel>
748
762
  </>
749
763
  );
@@ -1,9 +1,9 @@
1
1
  /* @flow */
2
2
  import { isFunction, isString } from 'lodash';
3
- import React, { ReactElement, useState } from 'react';
3
+ import React, { ReactElement } from 'react';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { IReqoreTableColumn, IReqoreTableData, IReqoreTableRowClick } from '.';
6
- import { ReqoreButton, ReqoreControlGroup, ReqorePopover } from '../..';
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';
@@ -28,6 +28,8 @@ export interface IReqoreTableRowOptions {
28
28
  flat?: boolean;
29
29
  cellComponent?: IReqoreCustomTableBodyCell;
30
30
  rowComponent?: IReqoreCustomTableRow;
31
+ setHoveredRow?: (index: number) => void;
32
+ hoveredRow?: number;
31
33
  }
32
34
  export interface IReqoreCustomTableRowProps extends IReqoreTableRowOptions {
33
35
  style?: React.CSSProperties;
@@ -90,11 +92,12 @@ const ReqoreTableRow = ({
90
92
  flat,
91
93
  cellComponent,
92
94
  rowComponent,
95
+ setHoveredRow,
96
+ hoveredRow,
93
97
  },
94
98
  style,
95
99
  index,
96
100
  }: IReqoreTableRowProps) => {
97
- const [isHovered, setIsHovered] = useState<boolean>(false);
98
101
  const isSelected =
99
102
  data[index]._selectId &&
100
103
  selected.find((selectId) => selectId.toString() === data[index]._selectId.toString());
@@ -145,12 +148,12 @@ const ReqoreTableRow = ({
145
148
 
146
149
  if (isString(content)) {
147
150
  // Separate the content string by colon
148
- let [type, intentOrColor] = content.split(':');
151
+ const [type, intentOrColor] = content.split(':');
149
152
  // Check if the intent starts with hash for tags
150
- let intent: TReqoreIntent = intentOrColor?.startsWith('#')
153
+ const intent: TReqoreIntent = intentOrColor?.startsWith('#')
151
154
  ? undefined
152
155
  : (intentOrColor as TReqoreIntent);
153
- let color: TReqoreHexColor =
156
+ const color: TReqoreHexColor =
154
157
  intentOrColor?.startsWith('#') && type === 'tag'
155
158
  ? (intentOrColor as TReqoreHexColor)
156
159
  : undefined;
@@ -200,48 +203,44 @@ const ReqoreTableRow = ({
200
203
  : {};
201
204
 
202
205
  return (
203
- <ReqorePopover
206
+ <CellComponent
204
207
  key={dataId}
205
- component={CellComponent}
206
- isReqoreComponent
207
- componentProps={
208
- {
209
- width: resizedWidth || width,
210
- minWidth,
211
- maxWidth,
212
- grow,
213
- align,
214
- size,
215
- striped,
216
- padded: cell?.padded,
217
- disabled: data[index]._disabled,
218
- selected: !!isSelected,
219
- selectedIntent: selectedRowIntent,
220
- flat,
221
- even: index % 2 === 0 ? true : false,
222
- intent: cell?.intent || data[index]._intent || intent,
223
- hovered: isHovered,
224
- interactive: !!cell?.onClick || !!onRowClick,
225
- interactiveCell: !!cell?.onClick,
226
- onClick: (e: React.MouseEvent<HTMLDivElement>) => {
227
- if (cell?.onClick) {
228
- e.stopPropagation();
229
- cell.onClick(data[index]);
230
- } else if (onRowClick) {
231
- e.stopPropagation();
232
- onRowClick(data[index]);
233
- } else if (selectable && data[index]._selectId) {
234
- // Otherwise select the row if selectable
235
- onSelectClick(data[index]._selectId!);
236
- }
237
- },
238
- className: 'reqore-table-cell',
239
- } as IReqoreTableCellStyle
240
- }
241
- {...tooltip}
208
+ {...({
209
+ width: resizedWidth || width,
210
+ minWidth,
211
+ maxWidth,
212
+ grow,
213
+ align,
214
+ size,
215
+ striped,
216
+ tooltip,
217
+ padded: cell?.padded,
218
+ disabled: data[index]._disabled,
219
+ selected: !!isSelected,
220
+ selectedIntent: selectedRowIntent,
221
+ flat,
222
+ even: index % 2 === 0 ? true : false,
223
+ intent: cell?.intent || data[index]._intent || intent,
224
+ hovered: hoveredRow === index,
225
+ interactive: !!cell?.onClick || !!onRowClick,
226
+ interactiveCell: !!cell?.onClick,
227
+ onClick: (e: React.MouseEvent<HTMLDivElement>) => {
228
+ if (cell?.onClick) {
229
+ e.stopPropagation();
230
+ cell.onClick(data[index]);
231
+ } else if (onRowClick) {
232
+ e.stopPropagation();
233
+ onRowClick(data[index]);
234
+ } else if (selectable && data[index]._selectId) {
235
+ // Otherwise select the row if selectable
236
+ onSelectClick(data[index]._selectId!);
237
+ }
238
+ },
239
+ className: 'reqore-table-cell',
240
+ } as IReqoreTableCellStyle)}
242
241
  >
243
242
  {renderContent(cell, data[index], dataId, align)}
244
- </ReqorePopover>
243
+ </CellComponent>
245
244
  );
246
245
  }
247
246
  );
@@ -250,15 +249,15 @@ const ReqoreTableRow = ({
250
249
  <RowComponent
251
250
  style={style}
252
251
  className='reqore-table-row'
253
- interactive={!!onRowClick}
252
+ interactive={!!onRowClick && !data[index]._disabled}
254
253
  onMouseEnter={() => {
255
254
  // Set hovered is this row is interactive
256
255
  if (onRowClick || (selectable && data[index]._selectId && !data[index]._disabled)) {
257
- setIsHovered(true);
256
+ setHoveredRow(index);
258
257
  }
259
258
  }}
260
259
  onMouseLeave={() => {
261
- setIsHovered(false);
260
+ setHoveredRow(undefined);
262
261
  }}
263
262
  >
264
263
  {renderCells(columns, data)}
@@ -1,3 +1,4 @@
1
+ import { omit } from 'lodash';
1
2
  import { forwardRef, memo } from 'react';
2
3
  import styled, { css } from 'styled-components';
3
4
  import { IReqoreTabsListItem } from '.';
@@ -129,7 +130,6 @@ const ReqoreTabsListItem = memo(
129
130
  className,
130
131
  flat = true,
131
132
  wrapTabNames,
132
- id,
133
133
  padded,
134
134
  ...rest
135
135
  }: IReqoreTabListItemProps,
@@ -168,7 +168,7 @@ const ReqoreTabsListItem = memo(
168
168
  tooltip={tooltip}
169
169
  customTheme={theme}
170
170
  className={`reqore-tabs-list-item ${active ? 'reqore-tabs-list-item-active' : ''}`}
171
- {...rest}
171
+ {...omit(rest, ['id'])}
172
172
  >
173
173
  {label}
174
174
  </ReqoreButton>
@@ -4,11 +4,11 @@ import { useInterval } from 'react-use';
4
4
  import { getTimeAgoIntervalDelay } from '../../helpers/time';
5
5
 
6
6
  export const TimeAgo = ({ time }: { time: number | string }) => {
7
- const [_lastUpdate, _setLastUpdate] = useState<number>(Date.now());
7
+ const setUpdate = useState<number>(Date.now());
8
8
  const _time = typeof time === 'number' ? time : Date.parse(time);
9
9
 
10
10
  useInterval(() => {
11
- _setLastUpdate(Date.now());
11
+ setUpdate[1](Date.now());
12
12
  }, getTimeAgoIntervalDelay(_time));
13
13
 
14
14
  return timeago(_time);
@@ -13,7 +13,7 @@ import { getExportActions, getZoomActions, sizeToZoom, zoomToSize } from '../Tab
13
13
  import ReqoreTag from '../Tag';
14
14
 
15
15
  export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
16
- data: Object | Array<any>;
16
+ data: Record<string, unknown> | Array<any>;
17
17
  mode?: 'tree' | 'copy';
18
18
  expanded?: boolean;
19
19
  showTypes?: boolean;
@@ -36,7 +36,6 @@ export const StyledTreeLabel = styled(ReqoreMessage)`
36
36
 
37
37
  export const ReqoreTree = ({
38
38
  data,
39
- mode = 'tree',
40
39
  size = 'normal',
41
40
  expanded,
42
41
  showTypes,
@@ -154,21 +153,6 @@ export const ReqoreTree = ({
154
153
  });
155
154
  };
156
155
 
157
- const renderText = (data, tabs = '') => {
158
- let text = '';
159
-
160
- Object.keys(data).forEach((key) => {
161
- if (typeof data[key] !== 'object' || !data[key]) {
162
- text += `${tabs}${key}: ${data[key]}\r\n`;
163
- } else {
164
- text += `${tabs}${key}:\r\n`;
165
- text += renderText(data[key], `${tabs}\t`);
166
- }
167
- });
168
-
169
- return text;
170
- };
171
-
172
156
  const actions = useMemo(() => {
173
157
  let _actions: IReqorePanelAction[] = [];
174
158
 
@@ -110,11 +110,11 @@ export const TEXT_FROM_SIZE = {
110
110
  };
111
111
 
112
112
  export const ICON_FROM_SIZE = {
113
- tiny: 11,
114
- small: 14,
115
- normal: 17,
116
- big: 20,
117
- huge: 23,
113
+ tiny: 13,
114
+ small: 17,
115
+ normal: 20,
116
+ big: 26,
117
+ huge: 33,
118
118
  };
119
119
 
120
120
  export const PADDING_FROM_SIZE = {
@@ -66,7 +66,7 @@ const StyledPortal = styled.div`
66
66
  `}
67
67
  `;
68
68
 
69
- const ReqorePortal = forwardRef<HTMLDivElement, {}>((_props, ref) => {
69
+ const ReqorePortal = forwardRef<HTMLDivElement, object>((_props, ref) => {
70
70
  return (
71
71
  <ReqoreThemeProvider>
72
72
  <StyledPortal id='reqore-portal' ref={ref} />
@@ -1,47 +1,42 @@
1
- import { reduce, size } from "lodash";
2
- import {
3
- IQorusSidebarCustomItem,
4
- IQorusSidebarItems,
5
- } from "../components/Sidebar";
1
+ import { reduce, size } from 'lodash';
2
+ import { IQorusSidebarCustomItem, IQorusSidebarItems } from '../components/Sidebar';
6
3
 
7
- export const transformMenu: Function = (
4
+ export const transformMenu = (
8
5
  menu: IQorusSidebarItems,
9
6
  bookmarks: string[],
10
7
  customItems?: IQorusSidebarCustomItem[]
11
- ): Object => {
8
+ ) => {
12
9
  let newMenu: IQorusSidebarItems = { ...menu };
13
10
  let _qorusCustomElements;
14
11
  let _qorusBookmarks;
15
12
 
16
13
  if (size(bookmarks)) {
17
14
  _qorusBookmarks = {
18
- title: "Bookmarks",
15
+ title: 'Bookmarks',
19
16
  items: [],
20
17
  };
21
18
 
22
19
  newMenu = reduce(
23
20
  newMenu,
24
21
  (cur, menuSection, name: string) => {
25
- let newSection = { ...menuSection };
22
+ const newSection = { ...menuSection };
26
23
 
27
24
  newSection.items = [...newSection.items]
28
25
  .map((newSectionItem) => {
29
26
  const copySectionItem = { ...newSectionItem };
30
27
 
31
28
  if (copySectionItem.submenu) {
32
- copySectionItem.submenu = copySectionItem.submenu.filter(
33
- (submenuItem) => {
34
- const isItemInSubmenu = bookmarks.find(
35
- (favoriteItem) => favoriteItem === submenuItem.id
36
- );
29
+ copySectionItem.submenu = copySectionItem.submenu.filter((submenuItem) => {
30
+ const isItemInSubmenu = bookmarks.find(
31
+ (favoriteItem) => favoriteItem === submenuItem.id
32
+ );
37
33
 
38
- if (isItemInSubmenu) {
39
- _qorusBookmarks.items.push(submenuItem);
40
- }
41
-
42
- return !isItemInSubmenu;
34
+ if (isItemInSubmenu) {
35
+ _qorusBookmarks.items.push(submenuItem);
43
36
  }
44
- );
37
+
38
+ return !isItemInSubmenu;
39
+ });
45
40
 
46
41
  if (size(copySectionItem.submenu)) {
47
42
  return copySectionItem;
@@ -49,11 +44,7 @@ export const transformMenu: Function = (
49
44
  return undefined;
50
45
  }
51
46
  } else {
52
- if (
53
- !bookmarks.find(
54
- (favoriteItem) => favoriteItem === copySectionItem.id
55
- )
56
- ) {
47
+ if (!bookmarks.find((favoriteItem) => favoriteItem === copySectionItem.id)) {
57
48
  return copySectionItem;
58
49
  } else {
59
50
  _qorusBookmarks.items.push(copySectionItem);
@@ -82,17 +73,10 @@ export const transformMenu: Function = (
82
73
  return newMenu;
83
74
  };
84
75
 
85
- export const isActive = (
86
- to: string,
87
- currentPath: string,
88
- exact?: boolean
89
- ): boolean => (exact ? currentPath === to : currentPath.startsWith(to));
90
-
91
- export const isActiveMulti: Function = (
92
- to: string[],
93
- currentPath: string,
94
- exact?: boolean
95
- ): boolean => {
76
+ export const isActive = (to: string, currentPath: string, exact?: boolean): boolean =>
77
+ exact ? currentPath === to : currentPath.startsWith(to);
78
+
79
+ export const isActiveMulti = (to: string[], currentPath: string, exact?: boolean): boolean => {
96
80
  let active: boolean = false;
97
81
 
98
82
  to.forEach((path: string) => {
@@ -13,7 +13,7 @@ import { NUMBER_TO_SIZE, SIZES, SIZE_TO_NUMBER, TSizes } from '../constants/size
13
13
 
14
14
  export const sleep = async (ms: number) => await new Promise((r) => setTimeout(r, ms));
15
15
 
16
- export const getTypeFromValue: Function = (item: any): string => {
16
+ export const getTypeFromValue = (item: any): string => {
17
17
  if (isBoolean(item)) {
18
18
  return 'boolean';
19
19
  }