/
TransferList.demo.controlledSearch.tsx
66 lines (58 loc) · 1.44 KB
/
TransferList.demo.controlledSearch.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React, { useState } from 'react';
import { MantineDemo } from '@mantine/ds';
import { Stack, Text } from '@mantine/core';
import { Wrapper } from './_wrapper';
const code = `
import { useState } from 'react'
import { TransferList, Stack, Text } from '@mantine/core';
function Demo() {
const [search, setSearch] = useState(['', '']);
return (
<Stack>
<Text>
<Text component="span" weight="bold">Left search: </Text>
{search[0] || '---'}
{' / '}
<Text component="span" weight="bold">Right search: </Text>
{search[1] || '---'}
</Text>
<TransferList
searchValues={search}
onSearch={setSearch}
{/* ...other props */}
/>
</Stack>
);
}
`;
function Demo() {
const [search, setSearch] = useState<[string, string]>(['', '']);
return (
<Stack>
<Text>
<Text component="span" weight="bold">
Left search:{' '}
</Text>
{search[0] || '---'}
{' / '}
<Text component="span" weight="bold">
Right search:{' '}
</Text>
{search[1] || '---'}
</Text>
<Wrapper
searchPlaceholder="Search..."
nothingFound="Nothing here"
titles={['Frameworks', 'Libraries']}
breakpoint="sm"
searchValues={search}
onSearch={setSearch}
/>
</Stack>
);
}
export const controlledSearch: MantineDemo = {
type: 'demo',
component: Demo,
code,
};