@khanacademy/wonder-blocks-dropdown 2.8.3 → 2.9.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.
@@ -9,6 +9,7 @@ import DropdownCore from "./dropdown-core.js";
9
9
  import DropdownOpener from "./dropdown-opener.js";
10
10
  import SelectOpener from "./select-opener.js";
11
11
  import {
12
+ defaultLabels,
12
13
  selectDropdownStyle,
13
14
  filterableDropdownStyle,
14
15
  } from "../util/constants.js";
@@ -16,6 +17,28 @@ import {
16
17
  import typeof OptionItem from "./option-item.js";
17
18
  import type {DropdownItem, OpenerProps} from "../util/types.js";
18
19
 
20
+ export type SingleSelectLabels = {|
21
+ /**
22
+ * Label for describing the dismiss icon on the search filter.
23
+ */
24
+ clearSearch: string,
25
+
26
+ /**
27
+ * Label for the search placeholder.
28
+ */
29
+ filter: string,
30
+
31
+ /**
32
+ * Label for when the filter returns no results.
33
+ */
34
+ noResults: string,
35
+
36
+ /**
37
+ * Label for the opening component when there are some items selected.
38
+ */
39
+ someResults: (numOptions: number) => string,
40
+ |};
41
+
19
42
  type Props = {|
20
43
  ...AriaProps,
21
44
 
@@ -108,6 +131,11 @@ type Props = {|
108
131
  * top. The items will be filtered by the input.
109
132
  */
110
133
  isFilterable?: boolean,
134
+
135
+ /**
136
+ * The object containing the custom labels used inside this component.
137
+ */
138
+ labels: SingleSelectLabels,
111
139
  |};
112
140
 
113
141
  type State = {|
@@ -130,9 +158,10 @@ type State = {|
130
158
  |};
131
159
 
132
160
  type DefaultProps = {|
133
- alignment: $PropertyType<Props, "alignment">,
134
- disabled: $PropertyType<Props, "disabled">,
135
- light: $PropertyType<Props, "light">,
161
+ alignment: Props["alignment"],
162
+ disabled: Props["disabled"],
163
+ light: Props["light"],
164
+ labels: Props["labels"],
136
165
  |};
137
166
 
138
167
  /**
@@ -167,6 +196,12 @@ export default class SingleSelect extends React.Component<Props, State> {
167
196
  alignment: "left",
168
197
  disabled: false,
169
198
  light: false,
199
+ labels: {
200
+ clearSearch: defaultLabels.clearSearch,
201
+ filter: defaultLabels.filter,
202
+ noResults: defaultLabels.noResults,
203
+ someResults: defaultLabels.someSelected,
204
+ },
170
205
  };
171
206
 
172
207
  constructor(props: Props) {
@@ -318,6 +353,7 @@ export default class SingleSelect extends React.Component<Props, State> {
318
353
  alignment,
319
354
  dropdownStyle,
320
355
  isFilterable,
356
+ labels,
321
357
  onChange,
322
358
  onToggle,
323
359
  opened,
@@ -365,11 +401,12 @@ export default class SingleSelect extends React.Component<Props, State> {
365
401
  const {
366
402
  alignment,
367
403
  children,
404
+ className,
368
405
  dropdownStyle,
369
406
  isFilterable,
407
+ labels,
370
408
  light,
371
409
  style,
372
- className,
373
410
  } = this.props;
374
411
  const {searchText} = this.state;
375
412
  const allChildren = React.Children.toArray(children).filter(Boolean);
@@ -400,6 +437,7 @@ export default class SingleSelect extends React.Component<Props, State> {
400
437
  isFilterable ? this.handleSearchTextChanged : null
401
438
  }
402
439
  searchText={isFilterable ? searchText : ""}
440
+ labels={labels}
403
441
  />
404
442
  );
405
443
  }
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ import SingleSelect from "./components/single-select.js";
7
7
  import MultiSelect from "./components/multi-select.js";
8
8
 
9
9
  import type {Labels} from "./components/multi-select.js";
10
+ import type {SingleSelectLabels} from "./components/single-select.js";
10
11
 
11
12
  export {
12
13
  ActionItem,
@@ -17,4 +18,4 @@ export {
17
18
  MultiSelect,
18
19
  };
19
20
 
20
- export type {Labels};
21
+ export type {Labels, SingleSelectLabels};