@scality/core-ui 0.121.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 +29 -8
- package/dist/components/card/Card.component.d.ts.map +1 -1
- package/dist/components/card/Card.component.js +7 -5
- package/dist/components/checkbox/Checkbox.component.d.ts +7 -0
- package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.component.js +2 -0
- 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/layout/v2/AppContainer.js +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.js +1 -2
- 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/selectv2/Selectv2.component.js +10 -7
- package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.component.js +2 -1
- package/dist/components/steppers/Steppers.component.d.ts.map +1 -1
- package/dist/components/steppers/Steppers.component.js +9 -3
- 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/components/vegachartv2/VegaChartV2.component.js +1 -1
- 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 +5 -3
- package/src/lib/components/card/Card.component.tsx +7 -6
- package/src/lib/components/checkbox/Checkbox.component.tsx +3 -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/layout/v2/AppContainer.tsx +1 -1
- package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +1 -2
- 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 +12 -8
- package/src/lib/components/selectv2/selectv2.test.tsx +193 -5
- package/src/lib/components/sidebar/Sidebar.component.tsx +3 -2
- package/src/lib/components/steppers/Steppers.component.tsx +13 -3
- 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/components/vegachartv2/VegaChartV2.component.tsx +1 -1
- package/src/lib/organisms/attachments/AttachmentConfirmationModal.tsx +0 -1
- package/src/lib/organisms/attachments/AttachmentTable.tsx +25 -16
- package/stories/Checkbox/checkbox.guideline.mdx +55 -0
- package/stories/Checkbox/checkbox.stories.tsx +173 -0
- 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
- package/stories/checkbox.stories.tsx +0 -63
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
screen,
|
|
3
|
+
render as testingRender,
|
|
4
|
+
within,
|
|
5
|
+
} from '@testing-library/react';
|
|
4
6
|
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import {
|
|
7
|
+
import React, { useState } from 'react';
|
|
6
8
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
9
|
+
import { debug } from 'jest-preview';
|
|
10
|
+
import { Icon } from '../icon/Icon.component';
|
|
11
|
+
import { Option, Select } from '../selectv2/Selectv2.component';
|
|
7
12
|
|
|
8
|
-
const render = (
|
|
13
|
+
const render = (args) => {
|
|
9
14
|
return testingRender(
|
|
10
15
|
<QueryClientProvider client={new QueryClient()}>
|
|
11
16
|
{args}
|
|
@@ -274,4 +279,187 @@ describe('SelectV2', () => {
|
|
|
274
279
|
);
|
|
275
280
|
expect(onChange).toBeCalledTimes(0);
|
|
276
281
|
});
|
|
282
|
+
|
|
283
|
+
it('should select with the right selector', async () => {
|
|
284
|
+
const accounts = [
|
|
285
|
+
{
|
|
286
|
+
name: 'Account 1',
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'Account 2',
|
|
290
|
+
},
|
|
291
|
+
];
|
|
292
|
+
|
|
293
|
+
const MyWrapper = () => {
|
|
294
|
+
const [value, setValue] = useState('');
|
|
295
|
+
return (
|
|
296
|
+
<Select
|
|
297
|
+
id="select-account"
|
|
298
|
+
value={value}
|
|
299
|
+
onChange={(accountName) => {
|
|
300
|
+
setValue(accountName);
|
|
301
|
+
}}
|
|
302
|
+
size="1/2"
|
|
303
|
+
placeholder="Select Account"
|
|
304
|
+
>
|
|
305
|
+
{accounts.map((account) => (
|
|
306
|
+
<Select.Option key={`${account.name}`} value={account.name}>
|
|
307
|
+
{account.name}
|
|
308
|
+
</Select.Option>
|
|
309
|
+
))}
|
|
310
|
+
</Select>
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
render(<MyWrapper />);
|
|
315
|
+
|
|
316
|
+
// If you only have one select, you can use the role, otherwise, you should use the label
|
|
317
|
+
// screen.getByLabelText(/select account/i)
|
|
318
|
+
// In a normal select, we should have a label span attach to it.
|
|
319
|
+
// It's not our case here, so it makes thing difficult to select the right select
|
|
320
|
+
// I workaround this by using setting the aria-label to the select container (cf: test below)
|
|
321
|
+
const singleSelect = screen.getByRole('listbox');
|
|
322
|
+
await userEvent.click(singleSelect);
|
|
323
|
+
|
|
324
|
+
await userEvent.click(screen.getByRole('option', { name: /account 1/i }));
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('should be testable if we have several select', async () => {
|
|
328
|
+
const MyWrapperWith2Select = () => {
|
|
329
|
+
const [value, setValue] = useState('');
|
|
330
|
+
const [value2, setValue2] = useState('');
|
|
331
|
+
const accounts = [
|
|
332
|
+
{
|
|
333
|
+
name: 'Account 1',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: 'Account 2',
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
const users = [
|
|
340
|
+
{
|
|
341
|
+
name: 'User 1',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'User 2',
|
|
345
|
+
},
|
|
346
|
+
];
|
|
347
|
+
return (
|
|
348
|
+
<div>
|
|
349
|
+
<Select
|
|
350
|
+
id="select-account"
|
|
351
|
+
value={value}
|
|
352
|
+
onChange={(accountName) => {
|
|
353
|
+
setValue(accountName);
|
|
354
|
+
}}
|
|
355
|
+
size="1/2"
|
|
356
|
+
placeholder="Select Account"
|
|
357
|
+
>
|
|
358
|
+
{accounts.map((account) => (
|
|
359
|
+
<Select.Option key={`${account.name}`} value={account.name}>
|
|
360
|
+
{account.name}
|
|
361
|
+
</Select.Option>
|
|
362
|
+
))}
|
|
363
|
+
</Select>
|
|
364
|
+
<Select
|
|
365
|
+
id="select-user"
|
|
366
|
+
value={value2}
|
|
367
|
+
onChange={(accountName) => {
|
|
368
|
+
setValue2(accountName);
|
|
369
|
+
}}
|
|
370
|
+
size="1/2"
|
|
371
|
+
placeholder="Select User"
|
|
372
|
+
>
|
|
373
|
+
{users.map((user) => (
|
|
374
|
+
<Select.Option key={`${user.name}`} value={user.name}>
|
|
375
|
+
{user.name}
|
|
376
|
+
</Select.Option>
|
|
377
|
+
))}
|
|
378
|
+
</Select>
|
|
379
|
+
</div>
|
|
380
|
+
);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
render(<MyWrapperWith2Select />);
|
|
384
|
+
|
|
385
|
+
await userEvent.click(screen.getByLabelText(/select account/i));
|
|
386
|
+
|
|
387
|
+
await userEvent.click(screen.getByRole('option', { name: /account 1/i }));
|
|
388
|
+
|
|
389
|
+
await userEvent.click(screen.getByLabelText(/select user/i));
|
|
390
|
+
|
|
391
|
+
await userEvent.click(screen.getByRole('option', { name: /user 1/i }));
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should be testable even if we have several select with the same value, the placeholder should be different', async () => {
|
|
395
|
+
const MyWrapperWith2Select = () => {
|
|
396
|
+
const [value, setValue] = useState('');
|
|
397
|
+
const [value2, setValue2] = useState('');
|
|
398
|
+
const accounts = [
|
|
399
|
+
{
|
|
400
|
+
name: 'Account 1',
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
name: 'Account 2',
|
|
404
|
+
},
|
|
405
|
+
];
|
|
406
|
+
const accounts2 = [
|
|
407
|
+
{
|
|
408
|
+
name: 'Account 1',
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: 'Account 2',
|
|
412
|
+
},
|
|
413
|
+
];
|
|
414
|
+
return (
|
|
415
|
+
<div style={{ display: 'flex' }}>
|
|
416
|
+
<Select
|
|
417
|
+
id="select-account"
|
|
418
|
+
value={value}
|
|
419
|
+
onChange={(accountName) => {
|
|
420
|
+
setValue(accountName);
|
|
421
|
+
}}
|
|
422
|
+
size="1/2"
|
|
423
|
+
placeholder="Select Account"
|
|
424
|
+
>
|
|
425
|
+
{accounts.map((account) => (
|
|
426
|
+
<Select.Option key={`${account.name}`} value={account.name}>
|
|
427
|
+
{account.name}
|
|
428
|
+
</Select.Option>
|
|
429
|
+
))}
|
|
430
|
+
</Select>
|
|
431
|
+
<Select
|
|
432
|
+
id="select-account2"
|
|
433
|
+
value={value2}
|
|
434
|
+
onChange={(accountName) => {
|
|
435
|
+
setValue2(accountName);
|
|
436
|
+
}}
|
|
437
|
+
size="1"
|
|
438
|
+
placeholder="Select Second Account"
|
|
439
|
+
>
|
|
440
|
+
{accounts2.map((user) => (
|
|
441
|
+
<Select.Option key={`${user.name}`} value={user.name}>
|
|
442
|
+
{user.name}
|
|
443
|
+
</Select.Option>
|
|
444
|
+
))}
|
|
445
|
+
</Select>
|
|
446
|
+
</div>
|
|
447
|
+
);
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
render(<MyWrapperWith2Select />);
|
|
451
|
+
|
|
452
|
+
await userEvent.click(screen.getByLabelText(/select account/i));
|
|
453
|
+
await userEvent.click(screen.getByLabelText(/Select Second Account/i));
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* This is possible because only 1 select can be open at a time
|
|
457
|
+
* If for some reason, you have multiple select open at the same time, you can select the select by its label
|
|
458
|
+
* and check the option from it parent like this :
|
|
459
|
+
* const select = screen.getByLabelText(/select account/i);
|
|
460
|
+
* const selectContainer = select?.parentElement?.parentElement;
|
|
461
|
+
* const option = within(selectContainer).getByRole('option', { name: /account 1/i });
|
|
462
|
+
*/
|
|
463
|
+
await userEvent.click(screen.getByRole('option', { name: /account 1/i }));
|
|
464
|
+
});
|
|
277
465
|
});
|
|
@@ -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
|
}
|
|
@@ -39,6 +39,7 @@ const Circle = styled.div<{
|
|
|
39
39
|
display: flex;
|
|
40
40
|
justify-content: center;
|
|
41
41
|
align-items: center;
|
|
42
|
+
line-height: 30px;
|
|
42
43
|
width: 30px;
|
|
43
44
|
height: 30px;
|
|
44
45
|
border-radius: 50%;
|
|
@@ -74,14 +75,15 @@ const Circle = styled.div<{
|
|
|
74
75
|
}};
|
|
75
76
|
`;
|
|
76
77
|
const StepHeader = styled.span<{ active?: boolean }>`
|
|
77
|
-
|
|
78
|
+
margin-left: ${spacing.r8};
|
|
79
|
+
line-height: 30px;
|
|
78
80
|
color: ${(props) =>
|
|
79
81
|
props.active
|
|
80
82
|
? getThemePropSelector('textPrimary')
|
|
81
83
|
: getThemePropSelector('textSecondary')};
|
|
82
84
|
`;
|
|
83
85
|
const StepContent = styled.div`
|
|
84
|
-
padding: ${spacing.r8};
|
|
86
|
+
padding: ${spacing.r8} 0 ${spacing.r8} ${spacing.r8};
|
|
85
87
|
`;
|
|
86
88
|
const BottomBar = styled.hr<{ completed?: boolean }>`
|
|
87
89
|
flex-grow: 1;
|
|
@@ -128,7 +130,15 @@ function Step(props: StepProps) {
|
|
|
128
130
|
{!isLast && <BottomBar completed={completed} />}
|
|
129
131
|
</Panel>
|
|
130
132
|
<Panel>
|
|
131
|
-
<
|
|
133
|
+
<div
|
|
134
|
+
style={{
|
|
135
|
+
height: '30px',
|
|
136
|
+
display: 'flex',
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<StepHeader active={active}>{title}</StepHeader>
|
|
141
|
+
</div>
|
|
132
142
|
{active && <StepContent>{content}</StepContent>}
|
|
133
143
|
</Panel>
|
|
134
144
|
</StepContainer>
|
|
@@ -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
|
}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo,
|
|
1
|
+
import React, { memo, useEffect } from 'react';
|
|
2
2
|
import { areEqual } from 'react-window';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import { useTableContext } from './Tablev2.component';
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
TableRow,
|
|
8
8
|
TableBody,
|
|
9
9
|
TableHeader,
|
|
10
|
-
NoResult,
|
|
11
10
|
SortCaret,
|
|
12
11
|
} from './Tablestyle';
|
|
13
12
|
import {
|
|
@@ -15,7 +14,7 @@ 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 { Loader } from '../loader/Loader.component';
|
|
21
20
|
import { Box } from '../box/Box';
|
|
@@ -26,28 +25,14 @@ export type SingleSelectableContentProps<
|
|
|
26
25
|
> = {
|
|
27
26
|
rowHeight: TableHeightKeyType;
|
|
28
27
|
separationLineVariant: TableVariantType;
|
|
29
|
-
|
|
28
|
+
|
|
30
29
|
onRowSelected?: (row: Row<DATA_ROW>) => void;
|
|
31
30
|
selectedId?: string;
|
|
32
31
|
locale?: TableLocalType;
|
|
33
|
-
customItemKey?: (index:
|
|
32
|
+
customItemKey?: (index: number, data: DATA_ROW) => string;
|
|
34
33
|
hasScrollbar?: boolean;
|
|
35
34
|
isLoadingMoreItems?: boolean;
|
|
36
|
-
children?: (rows: JSX.Element) => JSX.Element;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const translations = {
|
|
40
|
-
en: {
|
|
41
|
-
noResult: 'No results found',
|
|
42
|
-
},
|
|
43
|
-
fr: {
|
|
44
|
-
noResult: `Aucun résultat`,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type RenderRowType = {
|
|
49
|
-
index: number;
|
|
50
|
-
style: CSSProperties;
|
|
35
|
+
children?: (rows: React.JSX.Element) => React.JSX.Element;
|
|
51
36
|
};
|
|
52
37
|
|
|
53
38
|
export function SingleSelectableContent<
|
|
@@ -55,7 +40,7 @@ export function SingleSelectableContent<
|
|
|
55
40
|
>({
|
|
56
41
|
rowHeight = 'h40',
|
|
57
42
|
separationLineVariant = 'backgroundLevel3',
|
|
58
|
-
|
|
43
|
+
|
|
59
44
|
locale = 'en',
|
|
60
45
|
selectedId,
|
|
61
46
|
isLoadingMoreItems,
|
|
@@ -67,15 +52,9 @@ export function SingleSelectableContent<
|
|
|
67
52
|
console.error('Please specify the onRowSelected function.');
|
|
68
53
|
}
|
|
69
54
|
|
|
70
|
-
const {
|
|
71
|
-
const {
|
|
72
|
-
|
|
73
|
-
prepareRow,
|
|
74
|
-
rows,
|
|
75
|
-
onBottom,
|
|
76
|
-
onBottomOffset,
|
|
77
|
-
setRowHeight,
|
|
78
|
-
} = useTableContext<DATA_ROW>();
|
|
55
|
+
const { headerRef } = useSyncedScroll<DATA_ROW>();
|
|
56
|
+
const { headerGroups, prepareRow, rows, setRowHeight } =
|
|
57
|
+
useTableContext<DATA_ROW>();
|
|
79
58
|
|
|
80
59
|
useEffect(() => {
|
|
81
60
|
setRowHeight(rowHeight);
|
|
@@ -120,7 +99,6 @@ export function SingleSelectableContent<
|
|
|
120
99
|
isSelected={selectedId === row.id}
|
|
121
100
|
aria-selected={selectedId === row.id ? 'true' : 'false'}
|
|
122
101
|
separationLineVariant={separationLineVariant}
|
|
123
|
-
backgroundVariant={backgroundVariant}
|
|
124
102
|
selectedId={selectedId}
|
|
125
103
|
className="tr"
|
|
126
104
|
>
|
|
@@ -146,20 +124,9 @@ export function SingleSelectableContent<
|
|
|
146
124
|
);
|
|
147
125
|
}, areEqual);
|
|
148
126
|
|
|
149
|
-
const {
|
|
150
|
-
|
|
151
|
-
setHasScrollbar,
|
|
152
|
-
scrollBarWidth,
|
|
153
|
-
handleScrollbarWidth,
|
|
154
|
-
} = useTableScrollbar();
|
|
155
|
-
|
|
156
|
-
function itemKey(index, data) {
|
|
157
|
-
if (typeof customItemKey === 'function') {
|
|
158
|
-
return customItemKey(index, data);
|
|
159
|
-
}
|
|
127
|
+
const { hasScrollbar, scrollBarWidth, handleScrollbarWidth } =
|
|
128
|
+
useTableScrollbar();
|
|
160
129
|
|
|
161
|
-
return index;
|
|
162
|
-
}
|
|
163
130
|
return (
|
|
164
131
|
<>
|
|
165
132
|
<div className="thead" role="rowgroup">
|
|
@@ -167,6 +134,7 @@ export function SingleSelectableContent<
|
|
|
167
134
|
<HeadRow
|
|
168
135
|
{...headerGroup.getHeaderGroupProps()}
|
|
169
136
|
ref={headerRef}
|
|
137
|
+
separationLineVariant={separationLineVariant}
|
|
170
138
|
hasScrollBar={hasScrollbar}
|
|
171
139
|
scrollBarWidth={scrollBarWidth}
|
|
172
140
|
rowHeight={rowHeight}
|
|
@@ -207,33 +175,12 @@ export function SingleSelectableContent<
|
|
|
207
175
|
))}
|
|
208
176
|
</div>
|
|
209
177
|
<TableBody role="rowgroup" className="tbody" ref={handleScrollbarWidth}>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
rowHeight={rowHeight}
|
|
217
|
-
setHasScrollbar={setHasScrollbar}
|
|
218
|
-
onBottom={onBottom}
|
|
219
|
-
onBottomOffset={onBottomOffset}
|
|
220
|
-
RenderRow={RenderRow}
|
|
221
|
-
/>,
|
|
222
|
-
)
|
|
223
|
-
) : rows.length ? (
|
|
224
|
-
<VirtualizedRows
|
|
225
|
-
rows={rows}
|
|
226
|
-
listRef={bodyRef}
|
|
227
|
-
itemKey={itemKey}
|
|
228
|
-
rowHeight={rowHeight}
|
|
229
|
-
setHasScrollbar={setHasScrollbar}
|
|
230
|
-
onBottom={onBottom}
|
|
231
|
-
onBottomOffset={onBottomOffset}
|
|
232
|
-
RenderRow={RenderRow}
|
|
233
|
-
/>
|
|
234
|
-
) : (
|
|
235
|
-
<NoResult>{translations[locale].noResult}</NoResult>
|
|
236
|
-
)}
|
|
178
|
+
<TableRows
|
|
179
|
+
locale={locale}
|
|
180
|
+
children={children}
|
|
181
|
+
customItemKey={customItemKey}
|
|
182
|
+
RenderRow={RenderRow}
|
|
183
|
+
/>
|
|
237
184
|
</TableBody>
|
|
238
185
|
{isLoadingMoreItems && (
|
|
239
186
|
<Box
|