-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.test-d.tsx
50 lines (43 loc) · 1.51 KB
/
index.test-d.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
import * as React from "react";
import MultiSelect, {
ListedItem,
IndicatorProps,
ItemProps,
CheckBoxProps
} from ".";
const items: ListedItem[] = [
{ label: "label 1", value: "label 1" },
{ label: "label 2", value: "label 2" }
];
const keyedItems: ListedItem[] = [
{ label: "label 1", value: "label 1", key: 1 },
{ label: "label 2", value: "label 2", key: 2 }
];
const plain = () => <MultiSelect />;
const withProps = () => <MultiSelect focus={false} limit={10} />;
const selectWithItems = () => <MultiSelect items={items} />;
const selectWithKeyedItems = () => <MultiSelect items={keyedItems} />;
const onSelect = (item: ListedItem) => console.log(item);
const withSelectHandler = () => <MultiSelect onSelect={onSelect} />;
const onUnselect = (item: ListedItem) => console.log(item);
const withUnselectHandler = () => <MultiSelect onUnselect={onUnselect} />;
const onSubmit = (items: ListedItem[]) => console.log(items);
const withSubmitHandler = () => <MultiSelect onSubmit={onSubmit} />;
const CustomIndikator: React.FC<IndicatorProps> = ({ isHighlighted }) => (
<div>{isHighlighted ? "✓" : ""}</div>
);
const CustomCheckBox: React.FC<CheckBoxProps> = ({ isSelected }) => (
<div>{isSelected ? "✓" : ""}</div>
);
const CustomItemComponent: React.FC<ItemProps> = ({ isHighlighted, label }) => (
<div>
{isHighlighted ? "✓" : ""} {label}
</div>
);
const overrideComponents = () => (
<MultiSelect
indicatorComponent={CustomIndikator}
itemComponent={CustomItemComponent}
checkboxComponent={CustomCheckBox}
/>
);