@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.
- package/.storybook/preview.js +28 -8
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +1 -4
- package/dist/components/emptystate/Emptystate.component.d.ts +11 -1
- package/dist/components/emptystate/Emptystate.component.d.ts.map +1 -1
- package/dist/components/emptystate/Emptystate.component.js +9 -4
- package/dist/components/icon/Icon.component.d.ts +2 -2
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessageUtils.js +5 -4
- package/dist/components/navbar/Navbar.component.d.ts.map +1 -1
- package/dist/components/navbar/Navbar.component.js +1 -0
- package/dist/components/searchinput/SearchInput.component.d.ts +2 -1
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.component.js +2 -1
- package/dist/components/tablev2/MultiSelectableContent.d.ts +1 -2
- package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/MultiSelectableContent.js +9 -24
- package/dist/components/tablev2/Search.d.ts +0 -6
- package/dist/components/tablev2/Search.d.ts.map +1 -1
- package/dist/components/tablev2/Search.js +3 -4
- package/dist/components/tablev2/SingleSelectableContent.d.ts +4 -5
- package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/SingleSelectableContent.js +9 -23
- package/dist/components/tablev2/TableCommon.d.ts +15 -3
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.js +37 -2
- package/dist/components/tablev2/TableUtils.d.ts +11 -0
- package/dist/components/tablev2/TableUtils.d.ts.map +1 -1
- package/dist/components/tablev2/TableUtils.js +23 -0
- package/dist/components/tablev2/Tablestyle.d.ts +6 -3
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.js +29 -36
- package/dist/components/tablev2/Tablev2.component.d.ts +24 -3
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tablev2/Tablev2.component.js +3 -1
- package/dist/components/tabsv2/StyledTabs.d.ts.map +1 -1
- package/dist/components/tabsv2/StyledTabs.js +14 -14
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.js +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts.map +1 -1
- package/dist/components/toast/useMutationsHandler.js +8 -6
- package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentConfirmationModal.js +1 -1
- package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentTable.js +15 -12
- package/package.json +1 -1
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +1 -4
- package/src/lib/components/emptystate/Emptystate.component.tsx +34 -10
- package/src/lib/components/icon/Icon.component.tsx +2 -2
- package/src/lib/components/infomessage/InfoMessageUtils.ts +39 -33
- package/src/lib/components/navbar/Navbar.component.tsx +1 -0
- package/src/lib/components/searchinput/SearchInput.component.tsx +1 -0
- package/src/lib/components/selectv2/Selectv2.component.tsx +1 -1
- package/src/lib/components/sidebar/Sidebar.component.tsx +3 -2
- package/src/lib/components/tablev2/MultiSelectableContent.tsx +13 -63
- package/src/lib/components/tablev2/Search.tsx +13 -24
- package/src/lib/components/tablev2/SingleSelectableContent.tsx +18 -71
- package/src/lib/components/tablev2/TableCommon.tsx +100 -1
- package/src/lib/components/tablev2/TableUtils.ts +37 -0
- package/src/lib/components/tablev2/Tablestyle.tsx +30 -37
- package/src/lib/components/tablev2/Tablev2.component.tsx +14 -0
- package/src/lib/components/tablev2/Tablev2.test.tsx +0 -3
- package/src/lib/components/tabsv2/StyledTabs.ts +16 -14
- package/src/lib/components/toast/Toast.component.tsx +1 -0
- package/src/lib/components/toast/useMutationsHandler.ts +4 -2
- package/src/lib/organisms/attachments/AttachmentConfirmationModal.tsx +0 -1
- package/src/lib/organisms/attachments/AttachmentTable.tsx +25 -16
- package/stories/Hooks/useMutationsHandler.mdx +121 -0
- package/stories/attachment.stories.tsx +78 -0
- package/stories/common.tsx +12 -6
- package/stories/emptystate.stories.tsx +1 -2
- package/stories/form.stories.tsx +1 -3
- package/stories/modal.stories.tsx +0 -2
- 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
|
-
|
|
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 -
|
|
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(
|
|
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:
|
|
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:
|
|
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, {
|
|
374
|
-
initiallyAttachedEntitiesStatus === 'loading' ? (_jsxs(Wrap, { children: [_jsx("p", {}), _jsxs(Stack, { children: [_jsx(Loader, {}), _jsxs(Text, { children: ["Loading ", entityName.plural, "..."] })] }), _jsx("p", {})] })) : initiallyAttachedEntitiesStatus === 'error' ? (_jsxs(
|
|
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
|
@@ -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
|
-
|
|
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
|
|
25
|
+
const { theme, backgroundColor } = props;
|
|
16
26
|
return css`
|
|
17
|
-
color: ${
|
|
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 {
|
|
49
|
+
const {
|
|
50
|
+
icon,
|
|
51
|
+
listedResource,
|
|
52
|
+
link,
|
|
53
|
+
history,
|
|
54
|
+
resourceToCreate,
|
|
55
|
+
backgroundColor,
|
|
56
|
+
} = props;
|
|
37
57
|
return (
|
|
38
|
-
<EmptystateContainer
|
|
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 {
|
|
66
|
+
<LargeText>{`A list of ${listedResource.plural} will appear here.`}</LargeText>
|
|
44
67
|
</EmptyStateRow>
|
|
45
68
|
<EmptyStateRow>
|
|
46
69
|
<LargeText>
|
|
47
|
-
|
|
48
|
-
|
|
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 ${
|
|
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 {
|
|
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
|
|
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
|
|
2
|
-
import { hex2RGB } from
|
|
3
|
-
import { useEffect, useRef, useState } from
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 = (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
43
|
+
}
|
|
44
|
+
return theme.backgroundLevel2;
|
|
45
|
+
};
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
setHasScrollbar,
|
|
138
|
-
scrollBarWidth,
|
|
139
|
-
handleScrollbarWidth,
|
|
140
|
-
} = useTableScrollbar();
|
|
117
|
+
const { hasScrollbar, scrollBarWidth, handleScrollbarWidth } =
|
|
118
|
+
useTableScrollbar();
|
|
141
119
|
|
|
142
|
-
const
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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="
|
|
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
|
}}
|