-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.d.ts
122 lines (101 loc) · 2.58 KB
/
index.d.ts
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import * as React from "react";
/**
* Props for custom indicator component.
*/
export type IndicatorProps = { isHighlighted?: boolean };
/**
* Props for custom check box component.
*/
export type CheckBoxProps = { isSelected?: boolean };
/**
* Props for custom item component.
*/
export type ItemProps = {
isHighlighted?: boolean;
label: string;
};
/**
* Select item definition.
*/
export type ListedItem = {
label: string;
value: React.Key;
key?: React.Key;
};
export type SelectedItem = {
label?: string;
value: React.Key;
key?: React.Key;
};
/**
* Default indicator component.
*/
export class Indicator extends React.Component<IndicatorProps> {}
/**
* Default check box component.
*/
export class CheckBox extends React.Component<CheckBoxProps> {}
/**
* Default item component.
*/
export class Item extends React.Component<ItemProps> {}
export type MultiSelectProps = {
/**
* Items to display in a list. Each item must be an object and have `label` and `value` props,
* it may also optionally have a `key` prop.
* If no `key` prop is provided, `value` will be used as the item key.
*/
items?: ListedItem[];
/**
* Items set as selected.
*/
selected?: SelectedItem[];
/**
* Items set as selected by default.
*/
defaultSelected?: SelectedItem[];
/**
* Listen to user's input. Useful in case there are multiple input components
* at the same time and input must be "routed" to a specific component.
*/
focus?: boolean;
/**
* Index of initially-selected item in `items` array.
*/
initialIndex?: number;
/**
* Function to call when user selects an item.
* Item object is passed to that function as an argument.
*/
onSelect?: (item: ListedItem) => void;
/**
* Function to call when user unselects an item.
* Item object is passed to that function as an argument.
*/
onUnselect?: (item: ListedItem) => void;
/**
* Function to call when user submits selected items.
* Selected Item list is passed to that function as an argument.
*/
onSubmit?: (item: ListedItem[]) => void;
/**
* Custom component to override the default indicator component.
*/
indicatorComponent?: React.ComponentType<IndicatorProps>;
/**
* Custom component to override the default check box component.
*/
checkboxComponent?: React.ComponentType<CheckBoxProps>;
/**
* Custom component to override the default item component.
*/
itemComponent?: React.ComponentType<ItemProps>;
/**
* Number of items to display.
*/
limit?: number;
};
/**
* Multi Select input component for Ink
*/
export default class MultiSelect extends React.Component<MultiSelectProps> {}