@scality/core-ui 0.122.0 → 0.123.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/.storybook/preview.js +28 -8
  2. package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
  3. package/dist/components/constrainedtext/Constrainedtext.component.js +1 -4
  4. package/dist/components/emptystate/Emptystate.component.d.ts +11 -1
  5. package/dist/components/emptystate/Emptystate.component.d.ts.map +1 -1
  6. package/dist/components/emptystate/Emptystate.component.js +9 -4
  7. package/dist/components/icon/Icon.component.d.ts +2 -2
  8. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  9. package/dist/components/infomessage/InfoMessageUtils.d.ts +1 -1
  10. package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -1
  11. package/dist/components/infomessage/InfoMessageUtils.js +5 -4
  12. package/dist/components/navbar/Navbar.component.d.ts.map +1 -1
  13. package/dist/components/navbar/Navbar.component.js +1 -0
  14. package/dist/components/searchinput/SearchInput.component.d.ts +2 -1
  15. package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
  16. package/dist/components/selectv2/Selectv2.component.d.ts +1 -1
  17. package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
  18. package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -1
  19. package/dist/components/sidebar/Sidebar.component.js +2 -1
  20. package/dist/components/tablev2/MultiSelectableContent.d.ts +1 -2
  21. package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -1
  22. package/dist/components/tablev2/MultiSelectableContent.js +9 -24
  23. package/dist/components/tablev2/Search.d.ts +0 -6
  24. package/dist/components/tablev2/Search.d.ts.map +1 -1
  25. package/dist/components/tablev2/Search.js +3 -4
  26. package/dist/components/tablev2/SingleSelectableContent.d.ts +4 -5
  27. package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
  28. package/dist/components/tablev2/SingleSelectableContent.js +9 -23
  29. package/dist/components/tablev2/TableCommon.d.ts +15 -3
  30. package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
  31. package/dist/components/tablev2/TableCommon.js +37 -2
  32. package/dist/components/tablev2/TableUtils.d.ts +11 -0
  33. package/dist/components/tablev2/TableUtils.d.ts.map +1 -1
  34. package/dist/components/tablev2/TableUtils.js +23 -0
  35. package/dist/components/tablev2/Tablestyle.d.ts +6 -3
  36. package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
  37. package/dist/components/tablev2/Tablestyle.js +29 -36
  38. package/dist/components/tablev2/Tablev2.component.d.ts +24 -3
  39. package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
  40. package/dist/components/tablev2/Tablev2.component.js +3 -1
  41. package/dist/components/tabsv2/StyledTabs.d.ts.map +1 -1
  42. package/dist/components/tabsv2/StyledTabs.js +14 -14
  43. package/dist/components/toast/Toast.component.d.ts.map +1 -1
  44. package/dist/components/toast/Toast.component.js +1 -1
  45. package/dist/components/toast/useMutationsHandler.d.ts +1 -1
  46. package/dist/components/toast/useMutationsHandler.d.ts.map +1 -1
  47. package/dist/components/toast/useMutationsHandler.js +8 -6
  48. package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts.map +1 -1
  49. package/dist/organisms/attachments/AttachmentConfirmationModal.js +1 -1
  50. package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -1
  51. package/dist/organisms/attachments/AttachmentTable.js +15 -12
  52. package/package.json +1 -1
  53. package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +1 -4
  54. package/src/lib/components/emptystate/Emptystate.component.tsx +34 -10
  55. package/src/lib/components/icon/Icon.component.tsx +2 -2
  56. package/src/lib/components/infomessage/InfoMessageUtils.ts +39 -33
  57. package/src/lib/components/navbar/Navbar.component.tsx +1 -0
  58. package/src/lib/components/searchinput/SearchInput.component.tsx +1 -0
  59. package/src/lib/components/selectv2/Selectv2.component.tsx +1 -1
  60. package/src/lib/components/sidebar/Sidebar.component.tsx +3 -2
  61. package/src/lib/components/tablev2/MultiSelectableContent.tsx +13 -63
  62. package/src/lib/components/tablev2/Search.tsx +13 -24
  63. package/src/lib/components/tablev2/SingleSelectableContent.tsx +18 -71
  64. package/src/lib/components/tablev2/TableCommon.tsx +100 -1
  65. package/src/lib/components/tablev2/TableUtils.ts +37 -0
  66. package/src/lib/components/tablev2/Tablestyle.tsx +30 -37
  67. package/src/lib/components/tablev2/Tablev2.component.tsx +14 -0
  68. package/src/lib/components/tablev2/Tablev2.test.tsx +0 -3
  69. package/src/lib/components/tabsv2/StyledTabs.ts +16 -14
  70. package/src/lib/components/toast/Toast.component.tsx +1 -0
  71. package/src/lib/components/toast/useMutationsHandler.ts +4 -2
  72. package/src/lib/organisms/attachments/AttachmentConfirmationModal.tsx +0 -1
  73. package/src/lib/organisms/attachments/AttachmentTable.tsx +25 -16
  74. package/stories/Hooks/useMutationsHandler.mdx +121 -0
  75. package/stories/attachment.stories.tsx +78 -0
  76. package/stories/common.tsx +12 -6
  77. package/stories/emptystate.stories.tsx +1 -2
  78. package/stories/form.stories.tsx +1 -3
  79. package/stories/modal.stories.tsx +0 -2
  80. package/stories/tablev2.stories.tsx +131 -52
@@ -8,6 +8,7 @@ import { spacing, Stack, Wrap } from '../../spacing';
8
8
  import { AttachmentAction, } from './AttachmentTypes';
9
9
  import { useQuery } from 'react-query';
10
10
  import { EmptyCell } from '../../components/tablev2/Tablev2.component';
11
+ import { tableRowHeight } from '../../components/tablev2/TableUtils';
11
12
  const rowHeight = 'h48';
12
13
  const MenuContainer = styled.ul `
13
14
  background-color: ${(props) => props.theme.backgroundLevel1};
@@ -43,11 +44,7 @@ const MenuContainer = styled.ul `
43
44
  }
44
45
  `;
45
46
  const SearchBoxContainer = styled.div `
46
- margin-bottom: ${spacing.r24};
47
- width: 78%;
48
- .sc-tooltip {
49
- width: 100%;
50
- }
47
+ padding: ${spacing.r16};
51
48
  `;
52
49
  const StyledSearchInput = styled(SearchInput) `
53
50
  flex-grow: 1;
@@ -69,6 +66,7 @@ const StyledTable = styled.div `
69
66
  const CenterredSecondaryText = styled(SecondaryText) `
70
67
  display: block;
71
68
  text-align: center;
69
+ line-height: ${tableRowHeight[rowHeight]}rem;
72
70
  `;
73
71
  const PrivateAttachmentContext = createContext(null);
74
72
  const AttachmentContext = createContext(null);
@@ -264,10 +262,12 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
264
262
  const [searchWidth, setSearchWidth] = useState('0px');
265
263
  const [searchInputIsFocused, setSearchInputIsFocused] = useState(false);
266
264
  return (_jsxs(AttachmentTableContainer, { children: [_jsx(SearchBoxContainer, { ref: (element) => {
267
- if (element) {
268
- setSearchWidth(element.getBoundingClientRect().width - 2 + 'px');
265
+ if (element === null || element === void 0 ? void 0 : element.firstElementChild) {
266
+ setSearchWidth(element.firstElementChild.getBoundingClientRect().width -
267
+ 2 +
268
+ 'px');
269
269
  }
270
- }, children: filteredEntities.status === 'error' ? (_jsx(Tooltip, { overlay: _jsx(_Fragment, { children: "We failed to load the entities, hence search is disabled" }), children: _jsxs(Box, { display: "flex", alignItems: "center", width: "100%", gap: 8, children: [_jsx(StyledSearchInput, { placeholder: searchEntityPlaceholder, ...getInputProps({
270
+ }, children: filteredEntities.status === 'error' ? (_jsx(Tooltip, { overlay: _jsx(_Fragment, { children: "We failed to load the entities, hence search is disabled" }), children: _jsxs(Stack, { children: [_jsx(StyledSearchInput, { placeholder: searchEntityPlaceholder, ...getInputProps({
271
271
  ref: (element) => {
272
272
  if (element)
273
273
  searchInputRef.current = element;
@@ -305,7 +305,7 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
305
305
  filteredEntities.status === 'success' &&
306
306
  ((_k = filteredEntities.data) === null || _k === void 0 ? void 0 : _k.entities.length) === 0 && (_jsx("li", { children: _jsxs(Text, { isGentleEmphazed: true, color: "textSecondary", children: ["No ", entityName.plural, " found matching your search."] }) }))] }), _jsx(StyledTable, { children: _jsx(Table, { columns: [
307
307
  {
308
- Header: _jsx(Box, { flex: 1.5, children: "Name" }),
308
+ Header: 'Name',
309
309
  accessor: 'name',
310
310
  cellStyle: {
311
311
  flex: 1.5,
@@ -337,7 +337,7 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
337
337
  },
338
338
  },
339
339
  {
340
- Header: _jsx(Box, { flex: 0.5, children: "Attachment status" }),
340
+ Header: 'Attachment',
341
341
  accessor: 'isPending',
342
342
  cellStyle: {
343
343
  flex: 0.5,
@@ -370,6 +370,9 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
370
370
  ...entity,
371
371
  isPending: entity.isPending || false,
372
372
  action: null,
373
- })), defaultSortingKey: "name", children: _jsx(Table.SingleSelectableContent, { backgroundVariant: "backgroundLevel4", rowHeight: rowHeight, separationLineVariant: "backgroundLevel2", children: (rows) => (_jsxs(_Fragment, { children: [initiallyAttachedEntitiesStatus === 'idle' ||
374
- initiallyAttachedEntitiesStatus === 'loading' ? (_jsxs(Wrap, { children: [_jsx("p", {}), _jsxs(Stack, { children: [_jsx(Loader, {}), _jsxs(Text, { children: ["Loading ", entityName.plural, "..."] })] }), _jsx("p", {})] })) : initiallyAttachedEntitiesStatus === 'error' ? (_jsxs(CenterredSecondaryText, { children: ["Failed to load ", entityName.plural] })) : (desiredAttachedEntities.length === 0 && (_jsxs(CenterredSecondaryText, { children: ["No ", entityName.plural, " attached"] }))), desiredAttachedEntities.length > 0 && rows] })) }) }) })] }));
373
+ })), defaultSortingKey: "name", children: _jsx(Table.SingleSelectableContent, { rowHeight: rowHeight, separationLineVariant: "backgroundLevel2", children: (rows) => (_jsxs(_Fragment, { children: [initiallyAttachedEntitiesStatus === 'idle' ||
374
+ initiallyAttachedEntitiesStatus === 'loading' ? (_jsxs(Wrap, { style: { height: `${tableRowHeight[rowHeight]}rem` }, children: [_jsx("p", {}), _jsxs(Stack, { children: [_jsx(Loader, {}), _jsxs(Text, { children: ["Loading ", entityName.plural, "..."] })] }), _jsx("p", {})] })) : initiallyAttachedEntitiesStatus === 'error' ? (_jsxs(Stack, { style: {
375
+ justifyContent: 'center',
376
+ height: `${tableRowHeight[rowHeight]}rem`,
377
+ }, children: [_jsx(Icon, { name: "Exclamation-circle", color: "statusWarning" }), _jsxs(Text, { color: "textSecondary", children: ["Failed to load attached ", entityName.plural, "."] })] })) : (desiredAttachedEntities.length === 0 && (_jsxs(CenterredSecondaryText, { children: ["No ", entityName.plural, " attached"] }))), desiredAttachedEntities.length > 0 && rows] })) }) }) })] }));
375
378
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scality/core-ui",
3
- "version": "0.122.0",
3
+ "version": "0.123.0",
4
4
  "description": "Scality common React component library",
5
5
  "author": "Scality Engineering",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -28,10 +28,7 @@ const ConstrainedTextContainer = styled.div`
28
28
  overflow-wrap: break-word;
29
29
  `
30
30
  : `overflow-wrap: break-word;
31
- white-space: nowrap;`}
32
- }
33
-
34
- ;
31
+ white-space: nowrap;`};
35
32
  `;
36
33
  const BlockTooltip = styled.div`
37
34
  width: stretch;
@@ -4,17 +4,30 @@ import { spacing } from '../../spacing';
4
4
  import { Button } from '../buttonv2/Buttonv2.component';
5
5
  import { Icon, IconName } from '../icon/Icon.component';
6
6
  import { LargeText } from '../text/Text.component';
7
+ import { CoreUITheme } from '../../style/theme';
7
8
  type Props = {
8
- label: string;
9
+ listedResource: {
10
+ singular: string;
11
+ plural: string;
12
+ };
9
13
  icon: IconName;
10
14
  link?: string;
11
15
  history?: Record<string, any>;
16
+ backgroundColor?: keyof CoreUITheme;
17
+ /**
18
+ * The resource to create before browsing the listed resource
19
+ * Only used when resource to create is different from listed resource
20
+ */
21
+ resourceToCreate?: string;
12
22
  };
13
- const EmptystateContainer = styled.div`
23
+ const EmptystateContainer = styled.div<{ backgroundColor?: keyof CoreUITheme }>`
14
24
  ${(props) => {
15
- const brand = props.theme;
25
+ const { theme, backgroundColor } = props;
16
26
  return css`
17
- color: ${brand.textSecondary};
27
+ color: ${theme.textSecondary};
28
+ background-color: ${backgroundColor
29
+ ? theme[backgroundColor]
30
+ : 'transparent'};
18
31
  `;
19
32
  }}
20
33
  display: flex;
@@ -33,25 +46,36 @@ export const ActionWrapper = styled.div`
33
46
  `;
34
47
 
35
48
  function EmptyState(props: Props) {
36
- const { icon, label, link, history } = props;
49
+ const {
50
+ icon,
51
+ listedResource,
52
+ link,
53
+ history,
54
+ resourceToCreate,
55
+ backgroundColor,
56
+ } = props;
37
57
  return (
38
- <EmptystateContainer className="sc-emptystate">
58
+ <EmptystateContainer
59
+ className="sc-emptystate"
60
+ backgroundColor={backgroundColor}
61
+ >
39
62
  <EmptyStateRow>
40
63
  <Icon name={icon} color="infoPrimary" size="5x" withWrapper />
41
64
  </EmptyStateRow>
42
65
  <EmptyStateRow>
43
- <LargeText>A list of {`${label}s`} will appear here.</LargeText>
66
+ <LargeText>{`A list of ${listedResource.plural} will appear here.`}</LargeText>
44
67
  </EmptyStateRow>
45
68
  <EmptyStateRow>
46
69
  <LargeText>
47
- There are no {`${label}s`} created yet, let's create your first{' '}
48
- {label}.
70
+ {!resourceToCreate
71
+ ? `There are no ${listedResource.plural} created yet, let's create your first ${listedResource.singular}.`
72
+ : `Before browsing your ${listedResource.plural}, create your first ${resourceToCreate}.`}
49
73
  </LargeText>
50
74
  </EmptyStateRow>
51
75
  {history && (
52
76
  <ActionWrapper>
53
77
  <Button
54
- label={`Create ${label}`}
78
+ label={`Create ${resourceToCreate || listedResource.singular}`}
55
79
  icon={<Icon name="Create-add" />}
56
80
  type="button"
57
81
  variant="primary"
@@ -6,7 +6,7 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import styled, { css } from 'styled-components';
9
- import { brand } from '../../style/theme';
9
+ import { CoreUITheme } from '../../style/theme';
10
10
 
11
11
  import { Loader } from '../loader/Loader.component';
12
12
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -142,7 +142,7 @@ const IconStyled = styled(FontAwesomeIcon)`
142
142
  `;
143
143
 
144
144
  export type IconName = keyof typeof iconTable;
145
- export type IconColor = keyof typeof brand;
145
+ export type IconColor = keyof CoreUITheme;
146
146
  type Props = {
147
147
  name: IconName;
148
148
  size?: SizeProp;
@@ -1,39 +1,45 @@
1
- import { DefaultTheme, useTheme } from "styled-components";
2
- import { hex2RGB } from "../../utils";
3
- import { useEffect, useRef, useState } from "react";
1
+ import { DefaultTheme, useTheme } from 'styled-components';
2
+ import { hex2RGB } from '../../utils';
3
+ import { useEffect, useRef, useState } from 'react';
4
4
 
5
5
  export const useComputeBackgroundColor = () => {
6
- const theme = useTheme();
7
- const containerRef = useRef<HTMLDivElement | null>(null);
8
- const [backgroundColor, setBackgroundColor] = useState('');
9
-
10
- useEffect(() => {
11
- containerRef.current &&
12
- setBackgroundColor(getBackgroundColor(containerRef.current, theme));
13
- }, [containerRef,theme]);
14
-
15
- return {
16
- containerRef,
17
- backgroundColor,
18
- };
6
+ const theme = useTheme();
7
+ const containerRef = useRef<HTMLDivElement | null>(null);
8
+ const [backgroundColor, setBackgroundColor] = useState('');
9
+
10
+ useEffect(() => {
11
+ containerRef.current &&
12
+ setBackgroundColor(getBackgroundColor(containerRef.current, theme));
13
+ }, [containerRef, theme]);
14
+
15
+ return {
16
+ containerRef,
17
+ backgroundColor,
19
18
  };
19
+ };
20
20
 
21
- export const getBackgroundColor = (element: HTMLElement, theme: DefaultTheme) => {
22
- if (element.parentElement) {
23
- const parentElementBackgroundColor = window.getComputedStyle(
24
- element.parentElement,
25
- )['background-color'];
26
- if (/rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/.test(parentElementBackgroundColor) || !window.getComputedStyle(element.parentElement,)['background-color']) {
27
- return getBackgroundColor(element.parentElement, theme);
28
- } else {
29
- const rgbArray = hex2RGB(theme.backgroundLevel2);
30
- if (
31
- `rgb(${rgbArray[0]}, ${rgbArray[1]}, ${rgbArray[2]})` ===
32
- parentElementBackgroundColor
33
- ) {
34
- return theme.backgroundLevel3;
35
- }
21
+ export const getBackgroundColor = (
22
+ element: HTMLElement,
23
+ theme: DefaultTheme,
24
+ ) => {
25
+ if (element.parentElement) {
26
+ const parentElementBackgroundColor = window.getComputedStyle(
27
+ element.parentElement,
28
+ )['background-color'];
29
+ if (
30
+ /rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/.test(parentElementBackgroundColor) ||
31
+ !window.getComputedStyle(element.parentElement)['background-color']
32
+ ) {
33
+ return getBackgroundColor(element.parentElement, theme);
34
+ } else {
35
+ const rgbArray = hex2RGB(theme.backgroundLevel2);
36
+ if (
37
+ `rgb(${rgbArray[0]}, ${rgbArray[1]}, ${rgbArray[2]})` ===
38
+ parentElementBackgroundColor
39
+ ) {
40
+ return theme.backgroundLevel3;
36
41
  }
37
42
  }
38
- return theme.backgroundLevel2;
39
- };
43
+ }
44
+ return theme.backgroundLevel2;
45
+ };
@@ -37,6 +37,7 @@ const NavbarContainer = styled.div`
37
37
  color: ${getThemePropSelector('textPrimary')};
38
38
  }
39
39
  border-bottom: 0.5px solid ${(props) => props.theme.backgroundLevel3};
40
+ box-sizing: border-box;
40
41
  `};
41
42
  `;
42
43
  const NavbarMenu = styled.div`
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { ChangeEvent, forwardRef, useEffect, useRef, useState } from 'react';
2
3
  import styled, { css } from 'styled-components';
3
4
  import { Icon } from '../icon/Icon.component';
@@ -24,7 +24,7 @@ export type OptionProps = {
24
24
  icon?: React.ReactNode;
25
25
  children?: React.ReactNode;
26
26
  value: string;
27
- disabledReason?: JSX.Element;
27
+ disabledReason?: React.ReactNode;
28
28
  };
29
29
  const usePreviousValue = (value) => {
30
30
  const ref = useRef(null);
@@ -1,4 +1,4 @@
1
- import { useState } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
 
4
4
  import {
@@ -30,6 +30,7 @@ export type WrapperProps = {
30
30
  hovered?: boolean;
31
31
  };
32
32
  const Wrapper = styled.div<WrapperProps>`
33
+ margin-top: 1px;
33
34
  flex-shrink: 0;
34
35
  ${(props) => {
35
36
  const { backgroundLevel1, textPrimary } = props.theme;
@@ -41,7 +42,6 @@ const Wrapper = styled.div<WrapperProps>`
41
42
  }
42
43
  `;
43
44
  }}
44
- margin-top: 1px;
45
45
  border-right: 1px solid ${(props) => props.theme.backgroundLevel3};
46
46
  ${(props) => {
47
47
  if (props.expanded) {
@@ -66,6 +66,7 @@ const Wrapper = styled.div<WrapperProps>`
66
66
  height: 100%;
67
67
  background-color: ${backgroundLevel1};
68
68
  z-index: ${zIndex.sidebar};
69
+ border-right: 1px solid ${(props) => props.theme.backgroundLevel3};
69
70
  }
70
71
  `;
71
72
  }
@@ -4,7 +4,6 @@ import { areEqual } from 'react-window';
4
4
  import { useTableContext } from './Tablev2.component';
5
5
  import {
6
6
  HeadRow,
7
- NoResult,
8
7
  SortCaret,
9
8
  TableBody,
10
9
  TableHeader,
@@ -15,26 +14,12 @@ import {
15
14
  TableLocalType,
16
15
  TableVariantType,
17
16
  } from './TableUtils';
18
- import { useTableScrollbar, VirtualizedRows } from './TableCommon';
17
+ import { RenderRowType, TableRows, useTableScrollbar } from './TableCommon';
19
18
  import useSyncedScroll from './useSyncedScroll';
20
19
  import { Box } from '../box/Box';
21
20
  import { Loader } from '../loader/Loader.component';
22
21
  import { spacing } from '../../spacing';
23
22
 
24
- const translations = {
25
- en: {
26
- noResult: 'No results found',
27
- },
28
- fr: {
29
- noResult: `Aucun résultat`,
30
- },
31
- };
32
-
33
- type RenderRowType = {
34
- index: number;
35
- style: CSSProperties;
36
- };
37
-
38
23
  type MultiSelectableContentProps<
39
24
  DATA_ROW extends Record<string, unknown> = Record<string, unknown>,
40
25
  > = {
@@ -43,7 +28,7 @@ type MultiSelectableContentProps<
43
28
  onToggleAll?: (selected: boolean) => void;
44
29
  rowHeight?: TableHeightKeyType;
45
30
  separationLineVariant?: TableVariantType;
46
- backgroundVariant?: TableVariantType;
31
+
47
32
  locale?: TableLocalType;
48
33
  customItemKey?: (index: number, data: DATA_ROW) => string;
49
34
  hasScrollbar?: boolean;
@@ -59,7 +44,6 @@ type MultiSelectableContentProps<
59
44
  // onMultiSelectionChanged: (rows: Row<ENTRY>[]) => void;
60
45
  // rowHeight?: TableHeightKeyType;
61
46
  // separationLineVariant?: TableVariantType;
62
- // backgroundVariant?: TableVariantType;
63
47
  // customItemKey?: (index: Number, data: ENTRY) => string;
64
48
  // } & ({
65
49
  // locale: TableLocalType;
@@ -75,7 +59,7 @@ export const MultiSelectableContent = <
75
59
  onToggleAll,
76
60
  rowHeight = 'h40',
77
61
  separationLineVariant = 'backgroundLevel3',
78
- backgroundVariant = 'backgroundLevel1',
62
+
79
63
  locale = 'en',
80
64
  customItemKey,
81
65
  isLoadingMoreItems,
@@ -88,8 +72,6 @@ export const MultiSelectableContent = <
88
72
  setRowHeight,
89
73
  setHiddenColumns,
90
74
  selectedRowIds,
91
- onBottom,
92
- onBottomOffset,
93
75
  isAllRowsSelected,
94
76
  toggleAllRowsSelected,
95
77
  } = useTableContext<DATA_ROW>();
@@ -132,21 +114,10 @@ export const MultiSelectableContent = <
132
114
  currentRow.toggleRowSelected(!currentRow.isSelected);
133
115
  };
134
116
 
135
- const {
136
- hasScrollbar,
137
- setHasScrollbar,
138
- scrollBarWidth,
139
- handleScrollbarWidth,
140
- } = useTableScrollbar();
117
+ const { hasScrollbar, scrollBarWidth, handleScrollbarWidth } =
118
+ useTableScrollbar();
141
119
 
142
- const itemKey = (index, data) => {
143
- if (typeof customItemKey === 'function') {
144
- return customItemKey(index, data);
145
- }
146
- return index;
147
- };
148
-
149
- const { bodyRef, headerRef } = useSyncedScroll<DATA_ROW>();
120
+ const { headerRef } = useSyncedScroll<DATA_ROW>();
150
121
 
151
122
  const RenderRow = memo(({ index, style }: RenderRowType) => {
152
123
  const row = rows[index];
@@ -175,7 +146,6 @@ export const MultiSelectableContent = <
175
146
  {...rowProps}
176
147
  isSelected={row.isSelected}
177
148
  separationLineVariant={separationLineVariant}
178
- backgroundVariant={backgroundVariant}
179
149
  className="tr"
180
150
  >
181
151
  {row.cells.map((cell) => {
@@ -232,6 +202,7 @@ export const MultiSelectableContent = <
232
202
  hasScrollBar={hasScrollbar}
233
203
  scrollBarWidth={scrollBarWidth}
234
204
  rowHeight={rowHeight}
205
+ separationLineVariant={separationLineVariant}
235
206
  ref={headerRef}
236
207
  >
237
208
  {headerGroup.headers.map((column) => {
@@ -291,33 +262,12 @@ export const MultiSelectableContent = <
291
262
  </div>
292
263
 
293
264
  <TableBody role="rowgroup" className="tbody" ref={handleScrollbarWidth}>
294
- {typeof children === 'function' ? (
295
- children(
296
- <VirtualizedRows
297
- rows={rows}
298
- listRef={bodyRef}
299
- itemKey={itemKey}
300
- rowHeight={rowHeight}
301
- setHasScrollbar={setHasScrollbar}
302
- onBottom={onBottom}
303
- onBottomOffset={onBottomOffset}
304
- RenderRow={RenderRow}
305
- />,
306
- )
307
- ) : rows.length ? (
308
- <VirtualizedRows
309
- rows={rows}
310
- listRef={bodyRef}
311
- itemKey={itemKey}
312
- rowHeight={rowHeight}
313
- setHasScrollbar={setHasScrollbar}
314
- onBottom={onBottom}
315
- onBottomOffset={onBottomOffset}
316
- RenderRow={RenderRow}
317
- />
318
- ) : (
319
- <NoResult>{translations[locale].noResult}</NoResult>
320
- )}
265
+ <TableRows
266
+ locale={locale}
267
+ children={children}
268
+ customItemKey={customItemKey}
269
+ RenderRow={RenderRow}
270
+ />
321
271
  </TableBody>
322
272
  {isLoadingMoreItems && (
323
273
  <Box
@@ -15,12 +15,6 @@ export type DisplayedName = {
15
15
  export type SearchProps = {
16
16
  onChange: (arg0: string) => void;
17
17
  value?: string;
18
- /**
19
- * @deprecated
20
- * All the Table should display the Total Number of Entity.
21
- */
22
- displayTotalOf?: boolean;
23
- displayedName: DisplayedName;
24
18
  locale?: TableLocalType;
25
19
  totalCount?: number;
26
20
  } & Omit<Props, 'disableToggle' | 'onChange'>;
@@ -72,37 +66,32 @@ export const TableItemCount = ({
72
66
  };
73
67
 
74
68
  export function TableSearch(props: SearchProps) {
69
+ const { onChange, value = '', locale = 'en', totalCount, ...rest } = props;
75
70
  const {
76
- onChange,
77
- value = '',
78
- displayTotalOf = true,
79
- displayedName,
80
- locale = 'en',
81
- totalCount,
82
- ...rest
83
- } = props;
84
- const { setGlobalFilter, rows, preGlobalFilteredRows } = useTableContext();
71
+ setGlobalFilter,
72
+ rows,
73
+ preGlobalFilteredRows,
74
+ entityName = { en: { singular: 'result', plural: 'results' } },
75
+ } = useTableContext();
85
76
  const totalDispayedRows = totalCount ? totalCount : rows.length;
86
77
  React.useEffect(() => {
87
78
  setGlobalFilter(value);
88
79
  }, [value, setGlobalFilter, preGlobalFilteredRows]);
89
80
  return (
90
81
  <SearchContainer>
91
- {displayTotalOf && (
92
- <TableItemCount
93
- entity={displayedName}
94
- count={totalDispayedRows}
95
- locale={locale}
96
- ></TableItemCount>
97
- )}
82
+ <TableItemCount
83
+ entity={entityName[locale] || entityName.en}
84
+ count={totalDispayedRows}
85
+ locale={locale}
86
+ ></TableItemCount>
87
+
98
88
  <SearchInput
99
89
  value={value}
100
90
  placeholder={translations[locale].search}
101
91
  disableToggle
102
- size="2/3"
92
+ size="1"
103
93
  onChange={(evt) => {
104
94
  if (typeof onChange === 'function') {
105
- // @ts-ignore
106
95
  onChange(evt.target.value);
107
96
  }
108
97
  }}