@khanacademy/wonder-blocks-dropdown 2.3.19
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/LICENSE +21 -0
- package/dist/es/index.js +3403 -0
- package/dist/index.js +3966 -0
- package/dist/index.js.flow +2 -0
- package/docs.md +12 -0
- package/package.json +44 -0
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +4054 -0
- package/src/__tests__/generated-snapshot.test.js +1612 -0
- package/src/__tests__/index.test.js +23 -0
- package/src/components/__mocks__/dropdown-core-virtualized.js +40 -0
- package/src/components/__tests__/__snapshots__/action-item.test.js.snap +63 -0
- package/src/components/__tests__/action-item.test.js +43 -0
- package/src/components/__tests__/action-menu.test.js +544 -0
- package/src/components/__tests__/dropdown-core-virtualized.test.js +119 -0
- package/src/components/__tests__/dropdown-core.test.js +659 -0
- package/src/components/__tests__/multi-select.test.js +982 -0
- package/src/components/__tests__/search-text-input.test.js +144 -0
- package/src/components/__tests__/single-select.test.js +588 -0
- package/src/components/action-item.js +270 -0
- package/src/components/action-menu-opener-core.js +203 -0
- package/src/components/action-menu.js +300 -0
- package/src/components/action-menu.md +338 -0
- package/src/components/check.js +59 -0
- package/src/components/checkbox.js +111 -0
- package/src/components/dropdown-core-virtualized-item.js +62 -0
- package/src/components/dropdown-core-virtualized.js +246 -0
- package/src/components/dropdown-core.js +770 -0
- package/src/components/dropdown-opener.js +101 -0
- package/src/components/multi-select.js +597 -0
- package/src/components/multi-select.md +718 -0
- package/src/components/multi-select.stories.js +111 -0
- package/src/components/option-item.js +239 -0
- package/src/components/search-text-input.js +227 -0
- package/src/components/select-opener.js +297 -0
- package/src/components/separator-item.js +50 -0
- package/src/components/single-select.js +418 -0
- package/src/components/single-select.md +520 -0
- package/src/components/single-select.stories.js +107 -0
- package/src/index.js +20 -0
- package/src/util/constants.js +50 -0
- package/src/util/types.js +32 -0
|
@@ -0,0 +1,1612 @@
|
|
|
1
|
+
// This file is auto-generated by gen-snapshot-tests.js
|
|
2
|
+
// Do not edit this file. To make changes to these snapshot tests:
|
|
3
|
+
// 1. edit the markdown documentation files in the package,
|
|
4
|
+
// packages/wonder-blocks-dropdown
|
|
5
|
+
// 2. Run `yarn run gen-snapshot-tests`.
|
|
6
|
+
import React from "react";
|
|
7
|
+
import renderer from "react-test-renderer";
|
|
8
|
+
|
|
9
|
+
// Mock react-dom as jest doesn't like findDOMNode.
|
|
10
|
+
jest.mock("react-dom");
|
|
11
|
+
import {
|
|
12
|
+
ActionMenu,
|
|
13
|
+
ActionItem,
|
|
14
|
+
SeparatorItem,
|
|
15
|
+
OptionItem,
|
|
16
|
+
SingleSelect,
|
|
17
|
+
MultiSelect,
|
|
18
|
+
} from "@khanacademy/wonder-blocks-dropdown";
|
|
19
|
+
import {View, Text} from "@khanacademy/wonder-blocks-core";
|
|
20
|
+
import {StyleSheet} from "aphrodite";
|
|
21
|
+
import {Spring, Strut} from "@khanacademy/wonder-blocks-layout";
|
|
22
|
+
import Button from "@khanacademy/wonder-blocks-button";
|
|
23
|
+
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
24
|
+
import Color from "@khanacademy/wonder-blocks-color";
|
|
25
|
+
import {LabelLarge, HeadingLarge} from "@khanacademy/wonder-blocks-typography";
|
|
26
|
+
import {OnePaneDialog, ModalLauncher} from "@khanacademy/wonder-blocks-modal";
|
|
27
|
+
|
|
28
|
+
describe("wonder-blocks-dropdown", () => {
|
|
29
|
+
it("example 1", () => {
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
row: {
|
|
32
|
+
flexDirection: "row",
|
|
33
|
+
justifyContent: "flex-end",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const example = (
|
|
37
|
+
<View style={styles.row}>
|
|
38
|
+
<ActionMenu
|
|
39
|
+
alignment="right"
|
|
40
|
+
menuText="Betsy Appleseed"
|
|
41
|
+
testId="teacher-menu"
|
|
42
|
+
>
|
|
43
|
+
<ActionItem
|
|
44
|
+
label="Profile"
|
|
45
|
+
href="http://khanacademy.org/profile"
|
|
46
|
+
target="_blank"
|
|
47
|
+
testId="profile"
|
|
48
|
+
/>
|
|
49
|
+
<ActionItem
|
|
50
|
+
label="Teacher dashboard"
|
|
51
|
+
href="http://khanacademy.org/coach/dashboard"
|
|
52
|
+
testId="dashboard"
|
|
53
|
+
/>
|
|
54
|
+
<ActionItem
|
|
55
|
+
label="Settings (onClick)"
|
|
56
|
+
onClick={() => console.log("user clicked on settings")}
|
|
57
|
+
testId="settings"
|
|
58
|
+
/>
|
|
59
|
+
<ActionItem
|
|
60
|
+
label="Help"
|
|
61
|
+
disabled={true}
|
|
62
|
+
onClick={() => console.log("this item is disabled...")}
|
|
63
|
+
testId="help"
|
|
64
|
+
/>
|
|
65
|
+
<ActionItem
|
|
66
|
+
label="Feedback"
|
|
67
|
+
disabled={true}
|
|
68
|
+
href="/feedback"
|
|
69
|
+
testId="feedback"
|
|
70
|
+
/>
|
|
71
|
+
<SeparatorItem />
|
|
72
|
+
<ActionItem
|
|
73
|
+
label="Log out"
|
|
74
|
+
href="http://khanacademy.org/logout"
|
|
75
|
+
testId="logout"
|
|
76
|
+
/>
|
|
77
|
+
</ActionMenu>
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
const tree = renderer.create(example).toJSON();
|
|
81
|
+
expect(tree).toMatchSnapshot();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("example 2", () => {
|
|
85
|
+
const styles = StyleSheet.create({
|
|
86
|
+
row: {
|
|
87
|
+
flexDirection: "row",
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const example = (
|
|
91
|
+
<View style={styles.row}>
|
|
92
|
+
<Spring />
|
|
93
|
+
<ActionMenu
|
|
94
|
+
menuText="Betsy Appleseed"
|
|
95
|
+
style={{
|
|
96
|
+
width: 100,
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<ActionItem
|
|
100
|
+
label="Profile"
|
|
101
|
+
href="http://khanacademy.org/profile"
|
|
102
|
+
/>
|
|
103
|
+
<ActionItem
|
|
104
|
+
label="Teacher dashboard"
|
|
105
|
+
href="http://khanacademy.org/coach/dashboard"
|
|
106
|
+
/>
|
|
107
|
+
<ActionItem
|
|
108
|
+
label="Settings (onClick)"
|
|
109
|
+
onClick={() => console.log("user clicked on settings")}
|
|
110
|
+
/>
|
|
111
|
+
<ActionItem
|
|
112
|
+
label="Help"
|
|
113
|
+
disabled={true}
|
|
114
|
+
onClick={() => console.log("this item is disabled...")}
|
|
115
|
+
/>
|
|
116
|
+
<SeparatorItem />
|
|
117
|
+
<ActionItem
|
|
118
|
+
label="Log out"
|
|
119
|
+
href="http://khanacademy.org/logout"
|
|
120
|
+
/>
|
|
121
|
+
</ActionMenu>
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
const tree = renderer.create(example).toJSON();
|
|
125
|
+
expect(tree).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("example 3", () => {
|
|
129
|
+
const styles = StyleSheet.create({
|
|
130
|
+
row: {
|
|
131
|
+
flexDirection: "row",
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
class HybridMenu extends React.Component {
|
|
136
|
+
constructor() {
|
|
137
|
+
super();
|
|
138
|
+
this.state = {
|
|
139
|
+
selectedValues: ["homework"],
|
|
140
|
+
showHiddenOption: false,
|
|
141
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
142
|
+
|
|
143
|
+
this.handleChange = this.handleChange.bind(this);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
handleChange(update) {
|
|
147
|
+
this.setState({
|
|
148
|
+
selectedValues: update,
|
|
149
|
+
showHiddenOption: update.includes("in-class"),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
render() {
|
|
154
|
+
const {showHiddenOption} = this.state;
|
|
155
|
+
return (
|
|
156
|
+
<ActionMenu
|
|
157
|
+
menuText="Assignments"
|
|
158
|
+
onChange={this.handleChange}
|
|
159
|
+
selectedValues={this.state.selectedValues}
|
|
160
|
+
>
|
|
161
|
+
<ActionItem
|
|
162
|
+
label="Create..."
|
|
163
|
+
onClick={() => console.log("create action")}
|
|
164
|
+
/>
|
|
165
|
+
<ActionItem
|
|
166
|
+
label="Edit..."
|
|
167
|
+
disabled={true}
|
|
168
|
+
onClick={() => console.log("edit action")}
|
|
169
|
+
/>
|
|
170
|
+
<ActionItem
|
|
171
|
+
label="Delete"
|
|
172
|
+
disabled={true}
|
|
173
|
+
onClick={() => console.log("delete action")}
|
|
174
|
+
/>
|
|
175
|
+
{showHiddenOption && (
|
|
176
|
+
<ActionItem
|
|
177
|
+
label="Hidden menu for class"
|
|
178
|
+
disabled={!showHiddenOption}
|
|
179
|
+
onClick={() =>
|
|
180
|
+
console.log("hidden menu is clicked!")
|
|
181
|
+
}
|
|
182
|
+
/>
|
|
183
|
+
)}
|
|
184
|
+
<SeparatorItem />
|
|
185
|
+
<OptionItem
|
|
186
|
+
label="Show homework assignments"
|
|
187
|
+
value="homework"
|
|
188
|
+
onClick={() =>
|
|
189
|
+
console.log(`Show homework assignments toggled`)
|
|
190
|
+
}
|
|
191
|
+
/>
|
|
192
|
+
<OptionItem
|
|
193
|
+
label="Show in-class assignments"
|
|
194
|
+
value="in-class"
|
|
195
|
+
onClick={() =>
|
|
196
|
+
console.log(`Show in-class assignments toggled`)
|
|
197
|
+
}
|
|
198
|
+
/>
|
|
199
|
+
</ActionMenu>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const example = (
|
|
205
|
+
<View style={styles.row}>
|
|
206
|
+
<HybridMenu />
|
|
207
|
+
</View>
|
|
208
|
+
);
|
|
209
|
+
const tree = renderer.create(example).toJSON();
|
|
210
|
+
expect(tree).toMatchSnapshot();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("example 4", () => {
|
|
214
|
+
const styles = StyleSheet.create({
|
|
215
|
+
row: {
|
|
216
|
+
flexDirection: "row",
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
const example = (
|
|
220
|
+
<View style={styles.row}>
|
|
221
|
+
<ActionMenu menuText="Empty" />
|
|
222
|
+
</View>
|
|
223
|
+
);
|
|
224
|
+
const tree = renderer.create(example).toJSON();
|
|
225
|
+
expect(tree).toMatchSnapshot();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("example 5", () => {
|
|
229
|
+
const styles = StyleSheet.create({
|
|
230
|
+
row: {
|
|
231
|
+
flexDirection: "row",
|
|
232
|
+
},
|
|
233
|
+
dropdown: {
|
|
234
|
+
maxHeight: 200,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
const example = (
|
|
238
|
+
<View style={styles.row}>
|
|
239
|
+
<ActionMenu
|
|
240
|
+
menuText="Betsy Appleseed"
|
|
241
|
+
testId="teacher-menu"
|
|
242
|
+
dropdownStyle={styles.dropdown}
|
|
243
|
+
>
|
|
244
|
+
<ActionItem
|
|
245
|
+
label="Profile"
|
|
246
|
+
href="http://khanacademy.org/profile"
|
|
247
|
+
testId="profile"
|
|
248
|
+
/>
|
|
249
|
+
<ActionItem
|
|
250
|
+
label="Teacher dashboard"
|
|
251
|
+
href="http://khanacademy.org/coach/dashboard"
|
|
252
|
+
testId="dashboard"
|
|
253
|
+
/>
|
|
254
|
+
<ActionItem
|
|
255
|
+
label="Settings (onClick)"
|
|
256
|
+
onClick={() => console.log("user clicked on settings")}
|
|
257
|
+
testId="settings"
|
|
258
|
+
/>
|
|
259
|
+
<ActionItem
|
|
260
|
+
label="Help"
|
|
261
|
+
disabled={true}
|
|
262
|
+
onClick={() => console.log("this item is disabled...")}
|
|
263
|
+
testId="help"
|
|
264
|
+
/>
|
|
265
|
+
<ActionItem
|
|
266
|
+
label="Feedback"
|
|
267
|
+
disabled={true}
|
|
268
|
+
href="/feedback"
|
|
269
|
+
testId="feedback"
|
|
270
|
+
/>
|
|
271
|
+
<SeparatorItem />
|
|
272
|
+
<ActionItem
|
|
273
|
+
label="Log out"
|
|
274
|
+
href="http://khanacademy.org/logout"
|
|
275
|
+
testId="logout"
|
|
276
|
+
/>
|
|
277
|
+
</ActionMenu>
|
|
278
|
+
</View>
|
|
279
|
+
);
|
|
280
|
+
const tree = renderer.create(example).toJSON();
|
|
281
|
+
expect(tree).toMatchSnapshot();
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it("example 6", () => {
|
|
285
|
+
const styles = StyleSheet.create({
|
|
286
|
+
row: {
|
|
287
|
+
flexDirection: "row",
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
class ControlledActionMenuExample extends React.Component {
|
|
292
|
+
constructor() {
|
|
293
|
+
super();
|
|
294
|
+
this.state = {
|
|
295
|
+
opened: false,
|
|
296
|
+
selectedValues: ["kumail"],
|
|
297
|
+
};
|
|
298
|
+
this.handleChange = this.handleChange.bind(this);
|
|
299
|
+
this.handleToggleMenu = this.handleToggleMenu.bind(this);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
handleChange(update) {
|
|
303
|
+
this.setState({
|
|
304
|
+
selectedValues: update,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
handleToggleMenu(opened) {
|
|
309
|
+
this.setState({
|
|
310
|
+
opened,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
render() {
|
|
315
|
+
return (
|
|
316
|
+
<View style={styles.row}>
|
|
317
|
+
<ActionMenu
|
|
318
|
+
menuText="Betsy Appleseed"
|
|
319
|
+
onChange={this.handleChange}
|
|
320
|
+
onToggle={(opened) => {
|
|
321
|
+
console.log("toggle called!!!! ", opened);
|
|
322
|
+
this.handleToggleMenu(opened);
|
|
323
|
+
}}
|
|
324
|
+
opened={this.state.opened}
|
|
325
|
+
selectedValues={this.state.selectedValues}
|
|
326
|
+
>
|
|
327
|
+
<ActionItem label="Add new +" />
|
|
328
|
+
<SeparatorItem />
|
|
329
|
+
<OptionItem label="Alex" value="alex" />
|
|
330
|
+
<OptionItem label="Cathy" value="cathy" />
|
|
331
|
+
<OptionItem label="Kumail" value="kumail" />
|
|
332
|
+
<OptionItem label="Salman" value="salman" />
|
|
333
|
+
<OptionItem label="Yan" value="yan" />
|
|
334
|
+
<OptionItem label="Yash" value="yash" />
|
|
335
|
+
</ActionMenu>
|
|
336
|
+
<Strut size={Spacing.medium_16} />
|
|
337
|
+
<Button onClick={() => this.handleToggleMenu(true)}>
|
|
338
|
+
Open ActionMenu programatically
|
|
339
|
+
</Button>
|
|
340
|
+
</View>
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const example = <ControlledActionMenuExample />;
|
|
346
|
+
const tree = renderer.create(example).toJSON();
|
|
347
|
+
expect(tree).toMatchSnapshot();
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("example 7", () => {
|
|
351
|
+
const styles = StyleSheet.create({
|
|
352
|
+
focused: {
|
|
353
|
+
color: Color.purple,
|
|
354
|
+
},
|
|
355
|
+
hovered: {
|
|
356
|
+
textDecoration: "underline",
|
|
357
|
+
color: Color.purple,
|
|
358
|
+
cursor: "pointer",
|
|
359
|
+
},
|
|
360
|
+
pressed: {
|
|
361
|
+
color: Color.blue,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
const example = (
|
|
365
|
+
<ActionMenu
|
|
366
|
+
disabled={false}
|
|
367
|
+
menuText="Custom opener"
|
|
368
|
+
opener={({focused, hovered, pressed, text}) => (
|
|
369
|
+
<LabelLarge
|
|
370
|
+
onClick={() => {
|
|
371
|
+
console.log("custom click!!!!!");
|
|
372
|
+
}}
|
|
373
|
+
testId="teacher-menu-custom-opener"
|
|
374
|
+
style={[
|
|
375
|
+
focused && styles.focused,
|
|
376
|
+
hovered && styles.hovered,
|
|
377
|
+
pressed && styles.pressed,
|
|
378
|
+
]}
|
|
379
|
+
>
|
|
380
|
+
{text}
|
|
381
|
+
</LabelLarge>
|
|
382
|
+
)}
|
|
383
|
+
>
|
|
384
|
+
<ActionItem
|
|
385
|
+
label="Profile"
|
|
386
|
+
href="http://khanacademy.org/profile"
|
|
387
|
+
testId="profile"
|
|
388
|
+
/>
|
|
389
|
+
<ActionItem
|
|
390
|
+
label="Settings"
|
|
391
|
+
onClick={() => console.log("user clicked on settings")}
|
|
392
|
+
testId="settings"
|
|
393
|
+
/>
|
|
394
|
+
<ActionItem
|
|
395
|
+
label="Help"
|
|
396
|
+
disabled={true}
|
|
397
|
+
onClick={() => console.log("this item is disabled...")}
|
|
398
|
+
testId="help"
|
|
399
|
+
/>
|
|
400
|
+
<SeparatorItem />
|
|
401
|
+
<ActionItem
|
|
402
|
+
label="Log out"
|
|
403
|
+
href="http://khanacademy.org/logout"
|
|
404
|
+
testId="logout"
|
|
405
|
+
/>
|
|
406
|
+
<OptionItem
|
|
407
|
+
label="Show homework assignments"
|
|
408
|
+
value="homework"
|
|
409
|
+
onClick={() =>
|
|
410
|
+
console.log(`Show homework assignments toggled`)
|
|
411
|
+
}
|
|
412
|
+
/>
|
|
413
|
+
<OptionItem
|
|
414
|
+
label="Show in-class assignments"
|
|
415
|
+
value="in-class"
|
|
416
|
+
onClick={() =>
|
|
417
|
+
console.log(`Show in-class assignments toggled`)
|
|
418
|
+
}
|
|
419
|
+
/>
|
|
420
|
+
</ActionMenu>
|
|
421
|
+
);
|
|
422
|
+
const tree = renderer.create(example).toJSON();
|
|
423
|
+
expect(tree).toMatchSnapshot();
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it("example 8", () => {
|
|
427
|
+
const styles = StyleSheet.create({
|
|
428
|
+
row: {
|
|
429
|
+
flexDirection: "row",
|
|
430
|
+
},
|
|
431
|
+
setWidth: {
|
|
432
|
+
minWidth: 170,
|
|
433
|
+
maxWidth: 190,
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
class ExampleWithPlaceholder extends React.Component {
|
|
438
|
+
constructor() {
|
|
439
|
+
super();
|
|
440
|
+
this.state = {
|
|
441
|
+
selectedValue: null,
|
|
442
|
+
};
|
|
443
|
+
this.handleChange = this.handleChange.bind(this);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
handleChange(selected) {
|
|
447
|
+
console.log(`${selected} was selected!`);
|
|
448
|
+
this.setState({
|
|
449
|
+
selectedValue: selected,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
render() {
|
|
454
|
+
return (
|
|
455
|
+
<SingleSelect
|
|
456
|
+
onChange={this.handleChange}
|
|
457
|
+
onToggle={(opened) => console.log("toggle: ", opened)}
|
|
458
|
+
placeholder="Choose a fruit"
|
|
459
|
+
selectedValue={this.state.selectedValue}
|
|
460
|
+
style={styles.setWidth}
|
|
461
|
+
testId="fruit-select"
|
|
462
|
+
>
|
|
463
|
+
<OptionItem
|
|
464
|
+
label="Vine-ripened tomatoes"
|
|
465
|
+
value="tomato"
|
|
466
|
+
testId="tomato"
|
|
467
|
+
/>
|
|
468
|
+
<OptionItem
|
|
469
|
+
label="Watermelon"
|
|
470
|
+
value="watermelon"
|
|
471
|
+
testId="watermelon"
|
|
472
|
+
/>
|
|
473
|
+
<OptionItem
|
|
474
|
+
label="Strawberry"
|
|
475
|
+
value="strawberry"
|
|
476
|
+
testId="strawberry"
|
|
477
|
+
/>
|
|
478
|
+
{false && (
|
|
479
|
+
<OptionItem
|
|
480
|
+
label="Other"
|
|
481
|
+
value="other"
|
|
482
|
+
testId="other"
|
|
483
|
+
/>
|
|
484
|
+
)}
|
|
485
|
+
</SingleSelect>
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const example = (
|
|
491
|
+
<View style={styles.row}>
|
|
492
|
+
<ExampleWithPlaceholder />
|
|
493
|
+
</View>
|
|
494
|
+
);
|
|
495
|
+
const tree = renderer.create(example).toJSON();
|
|
496
|
+
expect(tree).toMatchSnapshot();
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it("example 9", () => {
|
|
500
|
+
const styles = StyleSheet.create({
|
|
501
|
+
row: {
|
|
502
|
+
flexDirection: "row",
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
class ExampleWithStartingSelection extends React.Component {
|
|
507
|
+
constructor() {
|
|
508
|
+
super();
|
|
509
|
+
this.state = {
|
|
510
|
+
selectedValue: "banana",
|
|
511
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
512
|
+
|
|
513
|
+
this.handleChange = this.handleChange.bind(this);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
handleChange(selected) {
|
|
517
|
+
console.log(`${selected} was selected!`);
|
|
518
|
+
this.setState({
|
|
519
|
+
selectedValue: selected,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
render() {
|
|
524
|
+
return (
|
|
525
|
+
<SingleSelect
|
|
526
|
+
onChange={this.handleChange}
|
|
527
|
+
placeholder="Choose a juice"
|
|
528
|
+
selectedValue={this.state.selectedValue}
|
|
529
|
+
>
|
|
530
|
+
<OptionItem label="Banana juice" value="banana" />
|
|
531
|
+
<OptionItem
|
|
532
|
+
label="Guava juice"
|
|
533
|
+
value="guava"
|
|
534
|
+
disabled
|
|
535
|
+
/>
|
|
536
|
+
<OptionItem label="White grape juice" value="grape" />
|
|
537
|
+
</SingleSelect>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const example = (
|
|
543
|
+
<View style={styles.row}>
|
|
544
|
+
<ExampleWithStartingSelection />
|
|
545
|
+
</View>
|
|
546
|
+
);
|
|
547
|
+
const tree = renderer.create(example).toJSON();
|
|
548
|
+
expect(tree).toMatchSnapshot();
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it("example 10", () => {
|
|
552
|
+
const styles = StyleSheet.create({
|
|
553
|
+
row: {
|
|
554
|
+
flexDirection: "row",
|
|
555
|
+
},
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
class DisabledExample extends React.Component {
|
|
559
|
+
constructor() {
|
|
560
|
+
super();
|
|
561
|
+
this.state = {
|
|
562
|
+
selectedValue: "banana",
|
|
563
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
564
|
+
|
|
565
|
+
this.handleChange = this.handleChange.bind(this);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
handleChange(selected) {
|
|
569
|
+
console.log(`${selected} was selected!`);
|
|
570
|
+
this.setState({
|
|
571
|
+
selectedValue: selected,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
render() {
|
|
576
|
+
return (
|
|
577
|
+
<SingleSelect
|
|
578
|
+
disabled={true}
|
|
579
|
+
onChange={this.handleChange}
|
|
580
|
+
placeholder="Choose a juice"
|
|
581
|
+
selectedValue={this.state.selectedValue}
|
|
582
|
+
>
|
|
583
|
+
<OptionItem label="Banana juice" value="banana" />
|
|
584
|
+
<OptionItem
|
|
585
|
+
label="Guava juice"
|
|
586
|
+
value="guava"
|
|
587
|
+
disabled
|
|
588
|
+
/>
|
|
589
|
+
<OptionItem label="White grape juice" value="grape" />
|
|
590
|
+
</SingleSelect>
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const example = (
|
|
596
|
+
<View style={styles.row}>
|
|
597
|
+
<DisabledExample />
|
|
598
|
+
</View>
|
|
599
|
+
);
|
|
600
|
+
const tree = renderer.create(example).toJSON();
|
|
601
|
+
expect(tree).toMatchSnapshot();
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
it("example 11", () => {
|
|
605
|
+
const styles = StyleSheet.create({
|
|
606
|
+
row: {
|
|
607
|
+
flexDirection: "row",
|
|
608
|
+
},
|
|
609
|
+
darkBackgroundWrapper: {
|
|
610
|
+
flexDirection: "row",
|
|
611
|
+
justifyContent: "flex-end",
|
|
612
|
+
backgroundColor: Color.darkBlue,
|
|
613
|
+
width: 350,
|
|
614
|
+
height: 200,
|
|
615
|
+
paddingRight: 10,
|
|
616
|
+
paddingTop: 10,
|
|
617
|
+
},
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
class LightRightAlignedExample extends React.Component {
|
|
621
|
+
constructor() {
|
|
622
|
+
super();
|
|
623
|
+
this.state = {
|
|
624
|
+
selectedValue: null,
|
|
625
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
626
|
+
|
|
627
|
+
this.handleChange = this.handleChange.bind(this);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
handleChange(selected) {
|
|
631
|
+
console.log(`${selected} was selected!`);
|
|
632
|
+
this.setState({
|
|
633
|
+
selectedValue: selected,
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
render() {
|
|
638
|
+
return (
|
|
639
|
+
<SingleSelect
|
|
640
|
+
alignment="right"
|
|
641
|
+
light={true}
|
|
642
|
+
onChange={this.handleChange}
|
|
643
|
+
placeholder="Choose a drink"
|
|
644
|
+
selectedValue={this.state.selectedValue}
|
|
645
|
+
>
|
|
646
|
+
<OptionItem
|
|
647
|
+
label="Regular milk tea with boba"
|
|
648
|
+
value="regular"
|
|
649
|
+
/>
|
|
650
|
+
<OptionItem
|
|
651
|
+
label="Wintermelon milk tea with boba"
|
|
652
|
+
value="wintermelon"
|
|
653
|
+
/>
|
|
654
|
+
<OptionItem
|
|
655
|
+
label="Taro milk tea, half sugar"
|
|
656
|
+
value="taro"
|
|
657
|
+
/>
|
|
658
|
+
</SingleSelect>
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const example = (
|
|
664
|
+
<View style={styles.row}>
|
|
665
|
+
<View style={styles.darkBackgroundWrapper}>
|
|
666
|
+
<LightRightAlignedExample />
|
|
667
|
+
</View>
|
|
668
|
+
</View>
|
|
669
|
+
);
|
|
670
|
+
const tree = renderer.create(example).toJSON();
|
|
671
|
+
expect(tree).toMatchSnapshot();
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
it("example 12", () => {
|
|
675
|
+
const styles = StyleSheet.create({
|
|
676
|
+
row: {
|
|
677
|
+
flexDirection: "row",
|
|
678
|
+
},
|
|
679
|
+
});
|
|
680
|
+
const example = (
|
|
681
|
+
<View style={styles.row}>
|
|
682
|
+
<SingleSelect placeholder="empty" />
|
|
683
|
+
</View>
|
|
684
|
+
);
|
|
685
|
+
const tree = renderer.create(example).toJSON();
|
|
686
|
+
expect(tree).toMatchSnapshot();
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
it("example 13", () => {
|
|
690
|
+
const example = (
|
|
691
|
+
<View>
|
|
692
|
+
<LabelLarge
|
|
693
|
+
tag="label"
|
|
694
|
+
id="label-for-single-select"
|
|
695
|
+
htmlFor="unique-single-select"
|
|
696
|
+
>
|
|
697
|
+
Associated label element
|
|
698
|
+
</LabelLarge>
|
|
699
|
+
<SingleSelect
|
|
700
|
+
aria-labelledby="label-for-single-select"
|
|
701
|
+
id="unique-single-select"
|
|
702
|
+
placeholder="Accessible SingleSelect"
|
|
703
|
+
selectedValue="one"
|
|
704
|
+
>
|
|
705
|
+
<OptionItem
|
|
706
|
+
label="First element"
|
|
707
|
+
aria-label="First element, selected"
|
|
708
|
+
value="one"
|
|
709
|
+
/>
|
|
710
|
+
<OptionItem
|
|
711
|
+
label="Second element"
|
|
712
|
+
aria-label="Second element, unselelected"
|
|
713
|
+
value="two"
|
|
714
|
+
/>
|
|
715
|
+
</SingleSelect>
|
|
716
|
+
</View>
|
|
717
|
+
);
|
|
718
|
+
const tree = renderer.create(example).toJSON();
|
|
719
|
+
expect(tree).toMatchSnapshot();
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it("example 14", () => {
|
|
723
|
+
const styles = StyleSheet.create({
|
|
724
|
+
row: {
|
|
725
|
+
flexDirection: "row",
|
|
726
|
+
},
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
class ControlledSingleSelectExample extends React.Component {
|
|
730
|
+
constructor() {
|
|
731
|
+
super();
|
|
732
|
+
this.state = {
|
|
733
|
+
opened: false,
|
|
734
|
+
selectedValue: null,
|
|
735
|
+
};
|
|
736
|
+
this.handleChange = this.handleChange.bind(this);
|
|
737
|
+
this.handleToggleMenu = this.handleToggleMenu.bind(this);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
handleChange(selected) {
|
|
741
|
+
this.setState({
|
|
742
|
+
selectedValue: selected,
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
handleToggleMenu(opened) {
|
|
747
|
+
this.setState({
|
|
748
|
+
opened,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
render() {
|
|
753
|
+
return (
|
|
754
|
+
<View style={styles.row}>
|
|
755
|
+
<SingleSelect
|
|
756
|
+
opened={this.state.opened}
|
|
757
|
+
onToggle={this.handleToggleMenu}
|
|
758
|
+
onChange={this.handleChange}
|
|
759
|
+
selectedValue={this.state.selectedValue}
|
|
760
|
+
placeholder="Choose"
|
|
761
|
+
>
|
|
762
|
+
<OptionItem label="item 1" value="1" />
|
|
763
|
+
<OptionItem label="item 2" value="2" />
|
|
764
|
+
<OptionItem label="item 3" value="3" />
|
|
765
|
+
</SingleSelect>
|
|
766
|
+
<Strut size={Spacing.medium_16} />
|
|
767
|
+
<Button onClick={() => this.handleToggleMenu(true)}>
|
|
768
|
+
Open SingleSelect programatically
|
|
769
|
+
</Button>
|
|
770
|
+
</View>
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
const example = <ControlledSingleSelectExample />;
|
|
776
|
+
const tree = renderer.create(example).toJSON();
|
|
777
|
+
expect(tree).toMatchSnapshot();
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
it("example 15", () => {
|
|
781
|
+
const styles = StyleSheet.create({
|
|
782
|
+
focused: {
|
|
783
|
+
color: Color.purple,
|
|
784
|
+
},
|
|
785
|
+
hovered: {
|
|
786
|
+
textDecoration: "underline",
|
|
787
|
+
color: Color.purple,
|
|
788
|
+
cursor: "pointer",
|
|
789
|
+
},
|
|
790
|
+
pressed: {
|
|
791
|
+
color: Color.blue,
|
|
792
|
+
},
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
class SingleSelectWithCustomOpener extends React.Component {
|
|
796
|
+
constructor() {
|
|
797
|
+
super();
|
|
798
|
+
this.state = {
|
|
799
|
+
opened: false,
|
|
800
|
+
selectedValue: null,
|
|
801
|
+
};
|
|
802
|
+
this.handleChange = this.handleChange.bind(this);
|
|
803
|
+
this.handleToggleMenu = this.handleToggleMenu.bind(this);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
handleChange(selected) {
|
|
807
|
+
this.setState({
|
|
808
|
+
selectedValue: selected,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
handleToggleMenu(opened) {
|
|
813
|
+
this.setState({
|
|
814
|
+
opened,
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
render() {
|
|
819
|
+
return (
|
|
820
|
+
<SingleSelect
|
|
821
|
+
placeholder="Choose a juice"
|
|
822
|
+
opened={this.state.opened}
|
|
823
|
+
onChange={this.handleChange}
|
|
824
|
+
onToggle={this.handleToggleMenu}
|
|
825
|
+
selectedValue={this.state.selectedValue}
|
|
826
|
+
opener={({focused, hovered, pressed, text}) => (
|
|
827
|
+
<HeadingLarge
|
|
828
|
+
onClick={() => {
|
|
829
|
+
console.log("custom click!!!!!");
|
|
830
|
+
}}
|
|
831
|
+
testId="single-select-custom-opener"
|
|
832
|
+
style={[
|
|
833
|
+
focused && styles.focused,
|
|
834
|
+
hovered && styles.hovered,
|
|
835
|
+
pressed && styles.pressed,
|
|
836
|
+
]}
|
|
837
|
+
>
|
|
838
|
+
{text}
|
|
839
|
+
</HeadingLarge>
|
|
840
|
+
)}
|
|
841
|
+
>
|
|
842
|
+
<OptionItem label="Banana juice" value="banana" />
|
|
843
|
+
<OptionItem
|
|
844
|
+
label="Guava juice"
|
|
845
|
+
value="guava"
|
|
846
|
+
disabled
|
|
847
|
+
/>
|
|
848
|
+
<OptionItem label="White grape juice" value="grape" />
|
|
849
|
+
</SingleSelect>
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const example = <SingleSelectWithCustomOpener />;
|
|
855
|
+
const tree = renderer.create(example).toJSON();
|
|
856
|
+
expect(tree).toMatchSnapshot();
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
it("example 16", () => {
|
|
860
|
+
const styles = StyleSheet.create({
|
|
861
|
+
row: {
|
|
862
|
+
flexDirection: "row",
|
|
863
|
+
},
|
|
864
|
+
fullBleed: {
|
|
865
|
+
width: "100%",
|
|
866
|
+
},
|
|
867
|
+
});
|
|
868
|
+
const fruits = ["banana", "strawberry", "pear", "orange"];
|
|
869
|
+
const optionItems = new Array(1000)
|
|
870
|
+
.fill(null)
|
|
871
|
+
.map((_, i) => (
|
|
872
|
+
<OptionItem
|
|
873
|
+
key={i}
|
|
874
|
+
value={(i + 1).toString()}
|
|
875
|
+
label={`Fruit # ${i + 1} ${fruits[i % fruits.length]}`}
|
|
876
|
+
/>
|
|
877
|
+
));
|
|
878
|
+
|
|
879
|
+
class ExampleWithFilter extends React.Component {
|
|
880
|
+
constructor() {
|
|
881
|
+
super();
|
|
882
|
+
this.state = {
|
|
883
|
+
opened: true,
|
|
884
|
+
selectedValue: null,
|
|
885
|
+
};
|
|
886
|
+
this.handleChange = this.handleChange.bind(this);
|
|
887
|
+
this.handleToggleMenu = this.handleToggleMenu.bind(this);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
handleChange(selected) {
|
|
891
|
+
this.setState({
|
|
892
|
+
selectedValue: selected,
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
handleToggleMenu(opened) {
|
|
897
|
+
this.setState({
|
|
898
|
+
opened,
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
render() {
|
|
903
|
+
return (
|
|
904
|
+
<SingleSelect
|
|
905
|
+
opened={this.state.opened}
|
|
906
|
+
onToggle={this.handleToggleMenu}
|
|
907
|
+
onChange={this.handleChange}
|
|
908
|
+
isFilterable={true}
|
|
909
|
+
placeholder="Select a fruit"
|
|
910
|
+
selectedValue={this.state.selectedValue}
|
|
911
|
+
dropdownStyle={styles.fullBleed}
|
|
912
|
+
style={styles.fullBleed}
|
|
913
|
+
>
|
|
914
|
+
{optionItems}
|
|
915
|
+
</SingleSelect>
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
const example = (
|
|
921
|
+
<View style={styles.row}>
|
|
922
|
+
<ExampleWithFilter />
|
|
923
|
+
</View>
|
|
924
|
+
);
|
|
925
|
+
const tree = renderer.create(example).toJSON();
|
|
926
|
+
expect(tree).toMatchSnapshot();
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
it("example 17", () => {
|
|
930
|
+
const styles = StyleSheet.create({
|
|
931
|
+
row: {
|
|
932
|
+
flexDirection: "row",
|
|
933
|
+
},
|
|
934
|
+
setWidth: {
|
|
935
|
+
minWidth: 170,
|
|
936
|
+
},
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
class ExampleNoneSelected extends React.Component {
|
|
940
|
+
constructor() {
|
|
941
|
+
super();
|
|
942
|
+
this.state = {
|
|
943
|
+
selectedValues: [],
|
|
944
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
945
|
+
|
|
946
|
+
this.handleChange = this.handleChange.bind(this);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
handleChange(update) {
|
|
950
|
+
console.log("changes happened!");
|
|
951
|
+
this.setState({
|
|
952
|
+
selectedValues: update,
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
render() {
|
|
957
|
+
return (
|
|
958
|
+
<MultiSelect
|
|
959
|
+
onChange={this.handleChange}
|
|
960
|
+
selectedValues={this.state.selectedValues}
|
|
961
|
+
style={styles.setWidth}
|
|
962
|
+
testId="palette"
|
|
963
|
+
labels={{
|
|
964
|
+
noneSelected: "Color palette",
|
|
965
|
+
someSelected: (numSelectedValues) =>
|
|
966
|
+
`${numSelectedValues} colors`,
|
|
967
|
+
}}
|
|
968
|
+
>
|
|
969
|
+
<OptionItem
|
|
970
|
+
label="Red"
|
|
971
|
+
value="1"
|
|
972
|
+
testId="red"
|
|
973
|
+
onClick={() => console.log("Roses are red")}
|
|
974
|
+
/>
|
|
975
|
+
<OptionItem
|
|
976
|
+
label="Yellow"
|
|
977
|
+
value="2"
|
|
978
|
+
disabled
|
|
979
|
+
testId="yellow"
|
|
980
|
+
/>
|
|
981
|
+
<OptionItem label="Green" value="3" testId="green" />
|
|
982
|
+
<OptionItem label="Blue" value="4" testId="blue" />
|
|
983
|
+
{false && (
|
|
984
|
+
<OptionItem label="Pink" value="5" testId="pink" />
|
|
985
|
+
)}
|
|
986
|
+
</MultiSelect>
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
const example = (
|
|
992
|
+
<View style={styles.row}>
|
|
993
|
+
<ExampleNoneSelected />
|
|
994
|
+
</View>
|
|
995
|
+
);
|
|
996
|
+
const tree = renderer.create(example).toJSON();
|
|
997
|
+
expect(tree).toMatchSnapshot();
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
it("example 18", () => {
|
|
1001
|
+
const styles = StyleSheet.create({
|
|
1002
|
+
row: {
|
|
1003
|
+
flexDirection: "row",
|
|
1004
|
+
},
|
|
1005
|
+
setWidth: {
|
|
1006
|
+
minWidth: 170,
|
|
1007
|
+
width: "100%",
|
|
1008
|
+
},
|
|
1009
|
+
customDropdown: {
|
|
1010
|
+
maxHeight: 200,
|
|
1011
|
+
},
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
class ExampleScrolling extends React.Component {
|
|
1015
|
+
constructor() {
|
|
1016
|
+
super();
|
|
1017
|
+
this.state = {
|
|
1018
|
+
selectedValues: [],
|
|
1019
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
1020
|
+
|
|
1021
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
handleChange(update) {
|
|
1025
|
+
console.log("changes happened!");
|
|
1026
|
+
this.setState({
|
|
1027
|
+
selectedValues: update,
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
render() {
|
|
1032
|
+
return (
|
|
1033
|
+
<MultiSelect
|
|
1034
|
+
onChange={this.handleChange}
|
|
1035
|
+
selectedValues={this.state.selectedValues}
|
|
1036
|
+
style={styles.setWidth}
|
|
1037
|
+
dropdownStyle={styles.customDropdown}
|
|
1038
|
+
labels={{
|
|
1039
|
+
noneSelected: "Solar system",
|
|
1040
|
+
someSelected: (numSelectedValues) =>
|
|
1041
|
+
`${numSelectedValues} planets`,
|
|
1042
|
+
}}
|
|
1043
|
+
>
|
|
1044
|
+
<OptionItem label="Mercury" value="1" />
|
|
1045
|
+
<OptionItem label="Venus" value="2" />
|
|
1046
|
+
<OptionItem label="Earth" value="3" disabled />
|
|
1047
|
+
<OptionItem label="Mars" value="4" />
|
|
1048
|
+
<OptionItem label="Jupiter" value="5" />
|
|
1049
|
+
<OptionItem label="Saturn" value="6" />
|
|
1050
|
+
<OptionItem label="Neptune" value="7" />
|
|
1051
|
+
<OptionItem label="Uranus" value="8" />
|
|
1052
|
+
</MultiSelect>
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
const example = (
|
|
1058
|
+
<View style={styles.row}>
|
|
1059
|
+
<ExampleScrolling />
|
|
1060
|
+
</View>
|
|
1061
|
+
);
|
|
1062
|
+
const tree = renderer.create(example).toJSON();
|
|
1063
|
+
expect(tree).toMatchSnapshot();
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
it("example 19", () => {
|
|
1067
|
+
const styles = StyleSheet.create({
|
|
1068
|
+
row: {
|
|
1069
|
+
flexDirection: "row",
|
|
1070
|
+
},
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
class ExampleWithShortcuts extends React.Component {
|
|
1074
|
+
constructor() {
|
|
1075
|
+
super();
|
|
1076
|
+
this.state = {
|
|
1077
|
+
selectedValues: ["wonderblocks 4ever"],
|
|
1078
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
1079
|
+
|
|
1080
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
handleChange(update) {
|
|
1084
|
+
console.log("changes happened!");
|
|
1085
|
+
this.setState({
|
|
1086
|
+
selectedValues: update,
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
render() {
|
|
1091
|
+
return (
|
|
1092
|
+
<MultiSelect
|
|
1093
|
+
shortcuts={true}
|
|
1094
|
+
onChange={this.handleChange}
|
|
1095
|
+
selectedValues={this.state.selectedValues}
|
|
1096
|
+
labels={{
|
|
1097
|
+
selectNoneLabel: "Select none",
|
|
1098
|
+
selectAllLabel: (numOptions) =>
|
|
1099
|
+
`Select all interns (${numOptions})`,
|
|
1100
|
+
someSelected: (numSelectedValues) =>
|
|
1101
|
+
`${numSelectedValues} interns`,
|
|
1102
|
+
allSelected: "All interns selected",
|
|
1103
|
+
}}
|
|
1104
|
+
>
|
|
1105
|
+
<OptionItem label="Anesu" value="very mobile" />
|
|
1106
|
+
<OptionItem label="Ioana" value="lives in roma" />
|
|
1107
|
+
<OptionItem label="Jennie" value="master of dominion" />
|
|
1108
|
+
<OptionItem
|
|
1109
|
+
label="Kelsey"
|
|
1110
|
+
value="pipelines and kotlin"
|
|
1111
|
+
/>
|
|
1112
|
+
<OptionItem label="Mary" value="flow-distress" />
|
|
1113
|
+
<OptionItem
|
|
1114
|
+
label="Nisha"
|
|
1115
|
+
value="on the growth boat boat"
|
|
1116
|
+
/>
|
|
1117
|
+
<OptionItem label="Sophie" value="wonderblocks 4ever" />
|
|
1118
|
+
<OptionItem
|
|
1119
|
+
label="Stephanie"
|
|
1120
|
+
value="ramen izakaya fan"
|
|
1121
|
+
/>
|
|
1122
|
+
<OptionItem label="Yeva" value="boba enthusiast" />
|
|
1123
|
+
</MultiSelect>
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
const example = (
|
|
1129
|
+
<View style={styles.row}>
|
|
1130
|
+
<ExampleWithShortcuts />
|
|
1131
|
+
</View>
|
|
1132
|
+
);
|
|
1133
|
+
const tree = renderer.create(example).toJSON();
|
|
1134
|
+
expect(tree).toMatchSnapshot();
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
it("example 20", () => {
|
|
1138
|
+
const styles = StyleSheet.create({
|
|
1139
|
+
wrapper: {
|
|
1140
|
+
alignItems: "center",
|
|
1141
|
+
},
|
|
1142
|
+
scrolledWrapper: {
|
|
1143
|
+
height: 200,
|
|
1144
|
+
overflow: "auto",
|
|
1145
|
+
border: "1px solid grey",
|
|
1146
|
+
borderRadius: 4,
|
|
1147
|
+
margin: 10,
|
|
1148
|
+
padding: 20,
|
|
1149
|
+
},
|
|
1150
|
+
setWidth: {
|
|
1151
|
+
minWidth: 170,
|
|
1152
|
+
},
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
class SimpleMultiSelect extends React.Component {
|
|
1156
|
+
constructor() {
|
|
1157
|
+
super();
|
|
1158
|
+
this.state = {
|
|
1159
|
+
selectedValues: [],
|
|
1160
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
1161
|
+
|
|
1162
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
handleChange(update) {
|
|
1166
|
+
console.log("changes happened!");
|
|
1167
|
+
this.setState({
|
|
1168
|
+
selectedValues: update,
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
render() {
|
|
1173
|
+
return (
|
|
1174
|
+
<MultiSelect
|
|
1175
|
+
onChange={this.handleChange}
|
|
1176
|
+
selectedValues={this.state.selectedValues}
|
|
1177
|
+
labels={{
|
|
1178
|
+
someSelected: (numSelectedValues) =>
|
|
1179
|
+
`${numSelectedValues} great houses`,
|
|
1180
|
+
}}
|
|
1181
|
+
style={styles.setWidth}
|
|
1182
|
+
>
|
|
1183
|
+
<OptionItem label="Stark" value="1" />
|
|
1184
|
+
<OptionItem label="Arryn" value="2" />
|
|
1185
|
+
<OptionItem label="Baratheon" value="3" />
|
|
1186
|
+
<OptionItem label="Tully" value="4" />
|
|
1187
|
+
<OptionItem label="Greyjoy" value="5" />
|
|
1188
|
+
<OptionItem label="Lannister" value="6" />
|
|
1189
|
+
<OptionItem label="Tyrell" value="7" />
|
|
1190
|
+
<OptionItem label="Martell" value="8" />
|
|
1191
|
+
<OptionItem label="Targaryen" value="9" />
|
|
1192
|
+
</MultiSelect>
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
const modalContent = (
|
|
1198
|
+
<View
|
|
1199
|
+
style={{
|
|
1200
|
+
height: "200vh",
|
|
1201
|
+
}}
|
|
1202
|
+
>
|
|
1203
|
+
<View style={styles.scrolledWrapper}>
|
|
1204
|
+
<View
|
|
1205
|
+
style={{
|
|
1206
|
+
minHeight: "100vh",
|
|
1207
|
+
}}
|
|
1208
|
+
>
|
|
1209
|
+
<SimpleMultiSelect />
|
|
1210
|
+
</View>
|
|
1211
|
+
</View>
|
|
1212
|
+
</View>
|
|
1213
|
+
);
|
|
1214
|
+
const modal = (
|
|
1215
|
+
<OnePaneDialog
|
|
1216
|
+
title="Westerosi modal"
|
|
1217
|
+
footer=""
|
|
1218
|
+
content={modalContent}
|
|
1219
|
+
/>
|
|
1220
|
+
);
|
|
1221
|
+
const example = (
|
|
1222
|
+
<View style={styles.wrapper}>
|
|
1223
|
+
<ModalLauncher modal={modal}>
|
|
1224
|
+
{({openModal}) => (
|
|
1225
|
+
<Button onClick={openModal}>Open modal!</Button>
|
|
1226
|
+
)}
|
|
1227
|
+
</ModalLauncher>
|
|
1228
|
+
</View>
|
|
1229
|
+
);
|
|
1230
|
+
const tree = renderer.create(example).toJSON();
|
|
1231
|
+
expect(tree).toMatchSnapshot();
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
it("example 21", () => {
|
|
1235
|
+
const styles = StyleSheet.create({
|
|
1236
|
+
row: {
|
|
1237
|
+
flexDirection: "row",
|
|
1238
|
+
},
|
|
1239
|
+
});
|
|
1240
|
+
const example = (
|
|
1241
|
+
<View style={styles.row}>
|
|
1242
|
+
<MultiSelect
|
|
1243
|
+
labels={{
|
|
1244
|
+
noneSelected: "empty",
|
|
1245
|
+
}}
|
|
1246
|
+
/>
|
|
1247
|
+
</View>
|
|
1248
|
+
);
|
|
1249
|
+
const tree = renderer.create(example).toJSON();
|
|
1250
|
+
expect(tree).toMatchSnapshot();
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
it("example 22", () => {
|
|
1254
|
+
const example = (
|
|
1255
|
+
<View>
|
|
1256
|
+
<LabelLarge
|
|
1257
|
+
tag="label"
|
|
1258
|
+
id="label-for-multi-select"
|
|
1259
|
+
htmlFor="unique-multi-select"
|
|
1260
|
+
>
|
|
1261
|
+
Associated label element
|
|
1262
|
+
</LabelLarge>
|
|
1263
|
+
<MultiSelect
|
|
1264
|
+
aria-labelledby="label-for-multi-select"
|
|
1265
|
+
id="unique-multi-select"
|
|
1266
|
+
labels={{
|
|
1267
|
+
noneSelected: "Accessible MultiSelect",
|
|
1268
|
+
someSelected: (numSelectedValues) =>
|
|
1269
|
+
`${numSelectedValues} planets`,
|
|
1270
|
+
}}
|
|
1271
|
+
selectedValues={["one"]}
|
|
1272
|
+
>
|
|
1273
|
+
<OptionItem
|
|
1274
|
+
label="First element"
|
|
1275
|
+
aria-label="First element, selected"
|
|
1276
|
+
value="one"
|
|
1277
|
+
/>
|
|
1278
|
+
<OptionItem
|
|
1279
|
+
label="Second element"
|
|
1280
|
+
aria-label="Second element, unselelected"
|
|
1281
|
+
value="two"
|
|
1282
|
+
/>
|
|
1283
|
+
</MultiSelect>
|
|
1284
|
+
</View>
|
|
1285
|
+
);
|
|
1286
|
+
const tree = renderer.create(example).toJSON();
|
|
1287
|
+
expect(tree).toMatchSnapshot();
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
it("example 23", () => {
|
|
1291
|
+
const styles = StyleSheet.create({
|
|
1292
|
+
row: {
|
|
1293
|
+
flexDirection: "row",
|
|
1294
|
+
},
|
|
1295
|
+
});
|
|
1296
|
+
|
|
1297
|
+
class ImplicitAllEnabledExample extends React.Component {
|
|
1298
|
+
constructor() {
|
|
1299
|
+
super();
|
|
1300
|
+
this.state = {
|
|
1301
|
+
selectedValues: [],
|
|
1302
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
1303
|
+
|
|
1304
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
handleChange(update) {
|
|
1308
|
+
console.log("changes happened!");
|
|
1309
|
+
this.setState({
|
|
1310
|
+
selectedValues: update,
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
render() {
|
|
1315
|
+
return (
|
|
1316
|
+
<MultiSelect
|
|
1317
|
+
implicitAllEnabled={true}
|
|
1318
|
+
labels={{
|
|
1319
|
+
someSelected: (numSelectedValues) =>
|
|
1320
|
+
`${numSelectedValues} fruits`,
|
|
1321
|
+
allSelected: "All fruits selected",
|
|
1322
|
+
}}
|
|
1323
|
+
onChange={this.handleChange}
|
|
1324
|
+
selectedValues={this.state.selectedValues}
|
|
1325
|
+
>
|
|
1326
|
+
<OptionItem label="Nectarine" value="nectarine" />
|
|
1327
|
+
<OptionItem label="Plum" value="plum" />
|
|
1328
|
+
<OptionItem label="Cantaloupe" value="cantaloupe" />
|
|
1329
|
+
<OptionItem label="Pineapples" value="pineapples" />
|
|
1330
|
+
</MultiSelect>
|
|
1331
|
+
);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
const example = (
|
|
1336
|
+
<View style={styles.row}>
|
|
1337
|
+
<ImplicitAllEnabledExample />
|
|
1338
|
+
</View>
|
|
1339
|
+
);
|
|
1340
|
+
const tree = renderer.create(example).toJSON();
|
|
1341
|
+
expect(tree).toMatchSnapshot();
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
it("example 24", () => {
|
|
1345
|
+
const styles = StyleSheet.create({
|
|
1346
|
+
row: {
|
|
1347
|
+
flexDirection: "row",
|
|
1348
|
+
},
|
|
1349
|
+
});
|
|
1350
|
+
|
|
1351
|
+
class ControlledMultiSelectExample extends React.Component {
|
|
1352
|
+
constructor() {
|
|
1353
|
+
super();
|
|
1354
|
+
this.state = {
|
|
1355
|
+
opened: false,
|
|
1356
|
+
selectedValues: [],
|
|
1357
|
+
};
|
|
1358
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1359
|
+
this.handleToggleMenu = this.handleToggleMenu.bind(this);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
handleChange(update) {
|
|
1363
|
+
this.setState({
|
|
1364
|
+
selectedValues: update,
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
handleToggleMenu(opened) {
|
|
1369
|
+
this.setState({
|
|
1370
|
+
opened,
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
render() {
|
|
1375
|
+
return (
|
|
1376
|
+
<View style={styles.row}>
|
|
1377
|
+
<MultiSelect
|
|
1378
|
+
labels={{
|
|
1379
|
+
noneSelected: "Select one",
|
|
1380
|
+
someSelected: (numSelectedValues) =>
|
|
1381
|
+
`${numSelectedValues} fruits`,
|
|
1382
|
+
allSelected: "All fruits selected",
|
|
1383
|
+
}}
|
|
1384
|
+
onChange={this.handleChange}
|
|
1385
|
+
opened={this.state.opened}
|
|
1386
|
+
onToggle={this.handleToggleMenu}
|
|
1387
|
+
selectedValues={this.state.selectedValues}
|
|
1388
|
+
>
|
|
1389
|
+
<OptionItem label="Nectarine" value="nectarine" />
|
|
1390
|
+
<OptionItem label="Plum" value="plum" />
|
|
1391
|
+
<OptionItem label="Cantaloupe" value="cantaloupe" />
|
|
1392
|
+
<OptionItem label="Pineapples" value="pineapples" />
|
|
1393
|
+
</MultiSelect>
|
|
1394
|
+
<Strut size={Spacing.medium_16} />
|
|
1395
|
+
<Button onClick={() => this.handleToggleMenu(true)}>
|
|
1396
|
+
Open SingleSelect programatically
|
|
1397
|
+
</Button>
|
|
1398
|
+
</View>
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
const example = <ControlledMultiSelectExample />;
|
|
1404
|
+
const tree = renderer.create(example).toJSON();
|
|
1405
|
+
expect(tree).toMatchSnapshot();
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
it("example 25", () => {
|
|
1409
|
+
const styles = StyleSheet.create({
|
|
1410
|
+
row: {
|
|
1411
|
+
flexDirection: "row",
|
|
1412
|
+
},
|
|
1413
|
+
});
|
|
1414
|
+
const optionItems = new Array(1000)
|
|
1415
|
+
.fill(null)
|
|
1416
|
+
.map((_, i) => (
|
|
1417
|
+
<OptionItem
|
|
1418
|
+
key={i}
|
|
1419
|
+
value={(i + 1).toString()}
|
|
1420
|
+
label={`School ${
|
|
1421
|
+
i + 1
|
|
1422
|
+
} in Wizarding World Some more really long labels?`}
|
|
1423
|
+
/>
|
|
1424
|
+
));
|
|
1425
|
+
|
|
1426
|
+
class ExampleWithShortcuts extends React.Component {
|
|
1427
|
+
constructor() {
|
|
1428
|
+
super();
|
|
1429
|
+
this.state = {
|
|
1430
|
+
selectedValues: [],
|
|
1431
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
1432
|
+
|
|
1433
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
handleChange(selectedValues) {
|
|
1437
|
+
this.setState({
|
|
1438
|
+
selectedValues,
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
render() {
|
|
1443
|
+
return (
|
|
1444
|
+
<MultiSelect
|
|
1445
|
+
shortcuts={true}
|
|
1446
|
+
isFilterable={true}
|
|
1447
|
+
onChange={this.handleChange}
|
|
1448
|
+
selectedValues={this.state.selectedValues}
|
|
1449
|
+
labels={{
|
|
1450
|
+
noneSelected: "Select a school",
|
|
1451
|
+
someSelected: (numSelectedValues) =>
|
|
1452
|
+
`${numSelectedValues} schools`,
|
|
1453
|
+
allSelected: "All schools selected",
|
|
1454
|
+
selectAllLabel: (numOptions) =>
|
|
1455
|
+
`Select all (${numOptions})`,
|
|
1456
|
+
}}
|
|
1457
|
+
>
|
|
1458
|
+
{optionItems}
|
|
1459
|
+
</MultiSelect>
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
const example = (
|
|
1465
|
+
<View style={styles.row}>
|
|
1466
|
+
<ExampleWithShortcuts />
|
|
1467
|
+
</View>
|
|
1468
|
+
);
|
|
1469
|
+
const tree = renderer.create(example).toJSON();
|
|
1470
|
+
expect(tree).toMatchSnapshot();
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
it("example 26", () => {
|
|
1474
|
+
const styles = StyleSheet.create({
|
|
1475
|
+
focused: {
|
|
1476
|
+
color: Color.purple,
|
|
1477
|
+
},
|
|
1478
|
+
hovered: {
|
|
1479
|
+
textDecoration: "underline",
|
|
1480
|
+
color: Color.purple,
|
|
1481
|
+
cursor: "pointer",
|
|
1482
|
+
},
|
|
1483
|
+
pressed: {
|
|
1484
|
+
color: Color.blue,
|
|
1485
|
+
},
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
class CustomOpenerExample extends React.Component {
|
|
1489
|
+
constructor() {
|
|
1490
|
+
super();
|
|
1491
|
+
this.state = {
|
|
1492
|
+
opened: false,
|
|
1493
|
+
selectedValues: [],
|
|
1494
|
+
};
|
|
1495
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1496
|
+
this.handleToggleMenu = this.handleToggleMenu.bind(this);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
handleChange(update) {
|
|
1500
|
+
this.setState({
|
|
1501
|
+
selectedValues: update,
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
handleToggleMenu(opened) {
|
|
1506
|
+
this.setState({
|
|
1507
|
+
opened,
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
render() {
|
|
1512
|
+
return (
|
|
1513
|
+
<MultiSelect
|
|
1514
|
+
labels={{
|
|
1515
|
+
noneSelected: "Choose a fruit",
|
|
1516
|
+
someSelected: (numSelectedValues) =>
|
|
1517
|
+
`${numSelectedValues} fruits`,
|
|
1518
|
+
allSelected: "All fruits selected",
|
|
1519
|
+
}}
|
|
1520
|
+
onChange={this.handleChange}
|
|
1521
|
+
opened={this.state.opened}
|
|
1522
|
+
onToggle={this.handleToggleMenu}
|
|
1523
|
+
selectedValues={this.state.selectedValues}
|
|
1524
|
+
testId="multi-select-custom-opener"
|
|
1525
|
+
opener={({focused, hovered, pressed, text}) => (
|
|
1526
|
+
<HeadingLarge
|
|
1527
|
+
onClick={() => {
|
|
1528
|
+
console.log("custom click!!!!!");
|
|
1529
|
+
}}
|
|
1530
|
+
testId="multi-select-custom-opener"
|
|
1531
|
+
style={[
|
|
1532
|
+
focused && styles.focused,
|
|
1533
|
+
hovered && styles.hovered,
|
|
1534
|
+
pressed && styles.pressed,
|
|
1535
|
+
]}
|
|
1536
|
+
>
|
|
1537
|
+
{text}
|
|
1538
|
+
</HeadingLarge>
|
|
1539
|
+
)}
|
|
1540
|
+
>
|
|
1541
|
+
<OptionItem label="Nectarine" value="nectarine" />
|
|
1542
|
+
<OptionItem label="Plum" value="plum" />
|
|
1543
|
+
<OptionItem label="Cantaloupe" value="cantaloupe" />
|
|
1544
|
+
<OptionItem label="Pineapples" value="pineapples" />
|
|
1545
|
+
</MultiSelect>
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
const example = <CustomOpenerExample />;
|
|
1551
|
+
const tree = renderer.create(example).toJSON();
|
|
1552
|
+
expect(tree).toMatchSnapshot();
|
|
1553
|
+
});
|
|
1554
|
+
|
|
1555
|
+
it("example 27", () => {
|
|
1556
|
+
const optionItems = new Array(10)
|
|
1557
|
+
.fill(null)
|
|
1558
|
+
.map((_, i) => (
|
|
1559
|
+
<OptionItem
|
|
1560
|
+
key={i}
|
|
1561
|
+
value={(i + 1).toString()}
|
|
1562
|
+
label={`School ${i + 1} in Wizarding World`}
|
|
1563
|
+
/>
|
|
1564
|
+
));
|
|
1565
|
+
|
|
1566
|
+
class ExampleWithTranslatedValues extends React.Component {
|
|
1567
|
+
constructor() {
|
|
1568
|
+
super();
|
|
1569
|
+
this.state = {
|
|
1570
|
+
selectedValues: [],
|
|
1571
|
+
}; // Styleguidist doesn't support arrow functions in class field properties
|
|
1572
|
+
|
|
1573
|
+
this.handleChange = this.handleChange.bind(this);
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
handleChange(selectedValues) {
|
|
1577
|
+
this.setState({
|
|
1578
|
+
selectedValues,
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
render() {
|
|
1583
|
+
return (
|
|
1584
|
+
<MultiSelect
|
|
1585
|
+
shortcuts={true}
|
|
1586
|
+
isFilterable={true}
|
|
1587
|
+
onChange={this.handleChange}
|
|
1588
|
+
selectedValues={this.state.selectedValues}
|
|
1589
|
+
labels={{
|
|
1590
|
+
clearSearch: "Limpiar busqueda",
|
|
1591
|
+
filter: "Filtrar",
|
|
1592
|
+
noResults: "Sin resultados",
|
|
1593
|
+
selectAllLabel: (numOptions) =>
|
|
1594
|
+
`Seleccionar todas (${numOptions})`,
|
|
1595
|
+
selectNoneLabel: "No seleccionar ninguno",
|
|
1596
|
+
noneSelected: "0 escuelas seleccionadas",
|
|
1597
|
+
allSelected: "Todas las escuelas",
|
|
1598
|
+
someSelected: (numSelectedValues) =>
|
|
1599
|
+
`${numSelectedValues} escuelas seleccionadas`,
|
|
1600
|
+
}}
|
|
1601
|
+
>
|
|
1602
|
+
{optionItems}
|
|
1603
|
+
</MultiSelect>
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
const example = <ExampleWithTranslatedValues />;
|
|
1609
|
+
const tree = renderer.create(example).toJSON();
|
|
1610
|
+
expect(tree).toMatchSnapshot();
|
|
1611
|
+
});
|
|
1612
|
+
});
|