grommet 2.26.0 → 2.27.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.
Files changed (86) hide show
  1. package/all/stories/AllComponents.js +19 -126
  2. package/components/Accordion/stories/CustomHeader.js +3 -1
  3. package/components/Avatar/Avatar.js +22 -9
  4. package/components/CheckBox/StyledCheckBox.js +9 -5
  5. package/components/DataChart/Detail.js +3 -1
  6. package/components/DataTable/index.d.ts +6 -6
  7. package/components/DateInput/DateInput.js +1 -1
  8. package/components/Diagram/Diagram.js +2 -1
  9. package/components/Drop/stories/Inline.js +1 -1
  10. package/components/Drop/stories/Overflow.js +1 -1
  11. package/components/Drop/stories/Plain.js +1 -1
  12. package/components/Drop/stories/Simple.js +1 -1
  13. package/components/Drop/stories/Styled.js +1 -1
  14. package/components/List/List.js +16 -13
  15. package/components/List/stories/Order.js +1 -0
  16. package/components/List/stories/Pinned.js +1 -0
  17. package/components/List/stories/Selection.js +1 -0
  18. package/components/List/stories/onClickItem.js +1 -0
  19. package/components/Notification/Notification.js +2 -2
  20. package/components/Notification/index.d.ts +1 -1
  21. package/components/Notification/propTypes.js +1 -1
  22. package/components/RadioButton/README.md +1 -279
  23. package/components/RadioButton/RadioButton.js +1 -0
  24. package/components/Select/Select.js +8 -4
  25. package/components/Select/SelectContainer.js +4 -4
  26. package/components/Select/utils.js +28 -2
  27. package/components/SelectMultiple/SelectMultiple.js +4 -4
  28. package/components/SelectMultiple/SelectMultipleContainer.js +10 -8
  29. package/components/SelectMultiple/SelectMultipleValue.js +18 -21
  30. package/components/SelectMultiple/SelectionSummary.js +1 -1
  31. package/components/SelectMultiple/stories/ObjectOptions.js +25 -1
  32. package/components/Sidebar/stories/Labels.js +4 -1
  33. package/components/TextArea/stories/NonResizable.js +1 -0
  34. package/components/TextArea/stories/Simple.js +1 -0
  35. package/es6/all/stories/AllComponents.js +21 -121
  36. package/es6/components/Accordion/stories/CustomHeader.js +3 -1
  37. package/es6/components/Avatar/Avatar.js +21 -9
  38. package/es6/components/CheckBox/StyledCheckBox.js +9 -5
  39. package/es6/components/DataChart/Detail.js +3 -1
  40. package/es6/components/DataTable/index.d.ts +6 -6
  41. package/es6/components/DateInput/DateInput.js +1 -1
  42. package/es6/components/Diagram/Diagram.js +2 -1
  43. package/es6/components/Drop/stories/Inline.js +1 -1
  44. package/es6/components/Drop/stories/Overflow.js +1 -1
  45. package/es6/components/Drop/stories/Plain.js +1 -1
  46. package/es6/components/Drop/stories/Simple.js +1 -1
  47. package/es6/components/Drop/stories/Styled.js +1 -1
  48. package/es6/components/List/List.js +16 -13
  49. package/es6/components/List/stories/Order.js +1 -0
  50. package/es6/components/List/stories/Pinned.js +1 -0
  51. package/es6/components/List/stories/Selection.js +1 -0
  52. package/es6/components/List/stories/onClickItem.js +1 -0
  53. package/es6/components/Notification/Notification.js +2 -2
  54. package/es6/components/Notification/index.d.ts +1 -1
  55. package/es6/components/Notification/propTypes.js +1 -1
  56. package/es6/components/RadioButton/README.md +1 -279
  57. package/es6/components/RadioButton/RadioButton.js +1 -0
  58. package/es6/components/Select/Select.js +8 -4
  59. package/es6/components/Select/SelectContainer.js +4 -4
  60. package/es6/components/Select/utils.js +21 -1
  61. package/es6/components/SelectMultiple/SelectMultiple.js +5 -5
  62. package/es6/components/SelectMultiple/SelectMultipleContainer.js +11 -9
  63. package/es6/components/SelectMultiple/SelectMultipleValue.js +19 -22
  64. package/es6/components/SelectMultiple/SelectionSummary.js +2 -2
  65. package/es6/components/SelectMultiple/stories/ObjectOptions.js +25 -1
  66. package/es6/components/Sidebar/stories/Labels.js +4 -1
  67. package/es6/components/TextArea/stories/NonResizable.js +1 -0
  68. package/es6/components/TextArea/stories/Simple.js +1 -0
  69. package/es6/themes/base.d.ts +8 -3
  70. package/es6/themes/base.js +6 -1
  71. package/es6/themes/hacktoberfest2022.js +129 -0
  72. package/es6/themes/index.js +2 -1
  73. package/es6/utils/background.js +4 -4
  74. package/es6/utils/styles.js +3 -1
  75. package/grommet.min.js +1 -1
  76. package/grommet.min.js.map +1 -1
  77. package/package.json +45 -43
  78. package/themes/base.d.ts +8 -3
  79. package/themes/base.js +6 -1
  80. package/themes/hacktoberfest2022.js +137 -0
  81. package/themes/index.js +6 -2
  82. package/tools/grommet-babel-preset-es2015.js +1 -12
  83. package/tools/pack.js +1 -94
  84. package/tools/release-stable.js +1 -27
  85. package/utils/background.js +4 -4
  86. package/utils/styles.js +3 -1
@@ -1,280 +1,2 @@
1
1
  ## RadioButton
2
- A radio button control.
3
-
4
- RadioButton should typically not be used directly.
5
- Instead, use RadioButtonGroup.
6
-
7
- [![](https://cdn-images-1.medium.com/fit/c/120/120/1*TD1P0HtIH9zF0UEH28zYtw.png)](https://storybook.grommet.io/?selectedKind=Input-RadioButton&full=0&stories=1&panelRight=0) [![](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/grommet/grommet-sandbox?initialpath=/radiobutton&module=%2Fsrc%2FRadioButton.js)
8
- ## Usage
9
-
10
- ```javascript
11
- import { RadioButton } from 'grommet';
12
- <RadioButton />
13
- ```
14
-
15
- ## Properties
16
-
17
- **a11yTitle**
18
-
19
- Custom label to be used by screen readers.
20
- When provided, an aria-label will be added to the element.
21
-
22
- ```
23
- string
24
- ```
25
-
26
- **checked**
27
-
28
- Same as React <input checked={} />
29
-
30
- ```
31
- boolean
32
- ```
33
-
34
- **children**
35
-
36
- Function that will be called to render the visual representation.
37
- It will be passed an object indicating whether the button is checked. It
38
- should return a react element.
39
- For example:
40
- `children={({ checked }) => <Box ...>{...}</Box>}`
41
-
42
-
43
- ```
44
- function
45
- ```
46
-
47
- **disabled**
48
-
49
- Same as React <input disabled={} />. Also adds a hidden input element
50
- with the same name so form submissions work.
51
-
52
- ```
53
- boolean
54
- ```
55
-
56
- **id**
57
-
58
- The DOM id attribute value to use for the underlying <input/> element.
59
-
60
- ```
61
- string
62
- ```
63
-
64
- **label**
65
-
66
- Label text to place next to the control.
67
-
68
- ```
69
- node
70
- ```
71
-
72
- **name**
73
-
74
- Required. The DOM name attribute value to use for the underlying <input/>
75
- element.
76
-
77
- ```
78
- string
79
- ```
80
-
81
- **onChange**
82
-
83
- Function that will be called when the user clicks the radio button. It
84
- will be passed a React event object. The current state can be accessed
85
- via event.target.checked. Same as React <input onChange={} />.
86
-
87
- ```
88
- function
89
- ```
90
-
91
- ## Intrinsic element
92
-
93
- ```
94
- input
95
- ```
96
- ## Theme
97
-
98
- **global.colors.control**
99
-
100
- The default color of the border surrounding
101
- the checked icon in RadioButton checked state. Expects `string | { dark: string, light: string }`.
102
-
103
- Defaults to
104
-
105
- ```
106
- { dark: 'accent-1', light: 'brand'}
107
- ```
108
-
109
- **radioButton.border.color**
110
-
111
- The color of the border of the Radio Button. Expects `string | { dark: string, light: string }`.
112
-
113
- Defaults to
114
-
115
- ```
116
- {dark: 'rgba(255, 255, 255, 0.5), light: 'rgba(0, 0, 0, 0.15)}
117
- ```
118
-
119
- **radioButton.border.width**
120
-
121
- The width size of the border of the RadioButton. Expects `string`.
122
-
123
- Defaults to
124
-
125
- ```
126
- 2px
127
- ```
128
-
129
- **radioButton.check.background.color**
130
-
131
- The background color of the checked icon in the RadioButton. Expects `string | {dark: string, light: string}`.
132
-
133
- Defaults to
134
-
135
- ```
136
- undefined
137
- ```
138
-
139
- **radioButton.check.color**
140
-
141
- The color of the checked icon in the RadioButton. Expects `string | { dark: string, light: string }`.
142
-
143
- Defaults to
144
-
145
- ```
146
- undefined
147
- ```
148
-
149
- **radioButton.check.extend**
150
-
151
- Any additional style for the checked RadioButton. Expects `string | (props) => {}`.
152
-
153
- Defaults to
154
-
155
- ```
156
- undefined
157
- ```
158
-
159
- **radioButton.check.radius**
160
-
161
- The border-radius of the RadioButton. Expects `string`.
162
-
163
- Defaults to
164
-
165
- ```
166
- 100%
167
- ```
168
-
169
- **radioButton.color**
170
-
171
- The color of the border surrounding the checked
172
- icon in RadioButton checked state. Expects `string | { dark: string, light: string }`.
173
-
174
- Defaults to
175
-
176
- ```
177
- undefined
178
- ```
179
-
180
- **radioButton.container.extend**
181
-
182
- Any additional style for the container around
183
- the radio button and its label. Expects `string | (props) => {}`.
184
-
185
- Defaults to
186
-
187
- ```
188
- undefined
189
- ```
190
-
191
- **radioButton.extend**
192
-
193
- Any additional style for the radio button itself. Expects `string | (props) => {}`.
194
-
195
- Defaults to
196
-
197
- ```
198
- undefined
199
- ```
200
-
201
- **radioButton.font.weight**
202
-
203
- The font weight of the label. Expects `number | string`.
204
-
205
- Defaults to
206
-
207
- ```
208
- undefined
209
- ```
210
-
211
- **radioButton.gap**
212
-
213
- The gap between the label and the RadioButton itself. Expects `string`.
214
-
215
- Defaults to
216
-
217
- ```
218
- small
219
- ```
220
-
221
- **radioButton.hover.background.color**
222
-
223
- The background color of the Box surrounding the RadioButton
224
- when hovered over. Expects `string | { dark: string, light: string }`.
225
-
226
- Defaults to
227
-
228
- ```
229
- undefined
230
- ```
231
-
232
- **radioButton.hover.border.color**
233
-
234
- The color of the RadioButton border when hovered over. Expects `string | { dark: string, light: string }`.
235
-
236
- Defaults to
237
-
238
- ```
239
- {dark: white, light: black}
240
- ```
241
-
242
- **radioButton.icon.extend**
243
-
244
- Any additional style for the RadioButton icon. Expects `string | (props) => {}`.
245
-
246
- Defaults to
247
-
248
- ```
249
- undefined
250
- ```
251
-
252
- **radioButton.icon.size**
253
-
254
- The size of the icon in the RadioButton. Expects `string`.
255
-
256
- Defaults to
257
-
258
- ```
259
- undefined
260
- ```
261
-
262
- **radioButton.icons.circle**
263
-
264
- The icon to replace the inner checked circle. Expects `React.Element`.
265
-
266
- Defaults to
267
-
268
- ```
269
- undefined
270
- ```
271
-
272
- **radioButton.size**
273
-
274
- The size of the RadioButton. Expects `string`.
275
-
276
- Defaults to
277
-
278
- ```
279
- 24px
280
- ```
2
+ Documentation for this component: https://v2.grommet.io/radiobutton
@@ -107,6 +107,7 @@ var RadioButton = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
107
107
  },
108
108
  round: theme.radioButton.check.radius
109
109
  }, checked && (Icon ? /*#__PURE__*/_react["default"].createElement(Icon, {
110
+ theme: theme,
110
111
  as: _StyledRadioButton.StyledRadioButtonIcon
111
112
  }) : /*#__PURE__*/_react["default"].createElement(_StyledRadioButton.StyledRadioButtonIcon, {
112
113
  viewBox: "0 0 24 24",
@@ -67,7 +67,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
67
67
  gridArea = _ref.gridArea,
68
68
  id = _ref.id,
69
69
  icon = _ref.icon,
70
- labelKey = _ref.labelKey,
70
+ labelKeyProp = _ref.labelKey,
71
71
  margin = _ref.margin,
72
72
  messages = _ref.messages,
73
73
  multiple = _ref.multiple,
@@ -90,7 +90,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
90
90
  selected = _ref.selected,
91
91
  size = _ref.size,
92
92
  valueProp = _ref.value,
93
- valueKey = _ref.valueKey,
93
+ valueKeyProp = _ref.valueKey,
94
94
  valueLabel = _ref.valueLabel,
95
95
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
96
96
 
@@ -100,11 +100,15 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
100
100
  var formContext = (0, _react.useContext)(_FormContext.FormContext);
101
101
 
102
102
  var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
103
- format = _useContext.format; // Determine if the Select is opened with the keyboard. If so,
103
+ format = _useContext.format; // For greater resilience, use labelKey if valueKey isn't provided and
104
+ // vice versa. https://github.com/grommet/grommet/pull/6299
105
+
106
+
107
+ var valueKey = valueKeyProp || labelKeyProp;
108
+ var labelKey = labelKeyProp || valueKeyProp; // Determine if the Select is opened with the keyboard. If so,
104
109
  // focus should be set on the first option when the drop opens
105
110
  // see set initial focus code in SelectContainer.js
106
111
 
107
-
108
112
  var usingKeyboard = (0, _utils.useKeyboard)(); // value is used for what we receive in valueProp and the basis for
109
113
  // what we send with onChange
110
114
  // When 'valueKey' sets 'reduce', the value(s) here should match
@@ -157,7 +157,7 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
157
157
  // deprecated in favor of value
158
158
  result = selected.indexOf(index) !== -1;
159
159
  } else {
160
- var optionVal = (0, _utils2.getOptionValue)(index, options, valueKey || labelKey);
160
+ var optionVal = (0, _utils2.getOptionValue)(index, options, valueKey);
161
161
 
162
162
  if (Array.isArray(value)) {
163
163
  if (value.length === 0) {
@@ -166,7 +166,7 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
166
166
  result = value.indexOf(optionVal) !== -1;
167
167
  } else if (valueKey) {
168
168
  result = value.some(function (valueItem) {
169
- var valueValue = typeof valueKey === 'function' ? valueKey(valueItem) : valueItem[valueKey];
169
+ var valueValue = typeof valueKey === 'function' ? valueKey(valueItem) : valueItem[valueKey] || valueItem[valueKey.key];
170
170
  return valueValue === optionVal;
171
171
  });
172
172
  }
@@ -179,7 +179,7 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
179
179
  }
180
180
 
181
181
  return result;
182
- }, [selected, value, valueKey, options, labelKey]);
182
+ }, [selected, value, valueKey, options]);
183
183
  var selectOption = (0, _react.useCallback)(function (index) {
184
184
  return function (event) {
185
185
  if (onChange) {
@@ -376,7 +376,7 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
376
376
  });
377
377
  if (typeof child === 'string' || child.props && child.props.children && typeof child.props.children === 'string') textComponent = true;
378
378
  } else if (theme.select.options) {
379
- child = /*#__PURE__*/_react["default"].createElement(_Box.Box, selectOptionsStyle, /*#__PURE__*/_react["default"].createElement(_Text.Text, theme.select.options.text, (0, _utils2.getOptionLabel)(index, options, labelKey || valueKey)));
379
+ child = /*#__PURE__*/_react["default"].createElement(_Box.Box, selectOptionsStyle, /*#__PURE__*/_react["default"].createElement(_Text.Text, theme.select.options.text, (0, _utils2.getOptionLabel)(index, options, labelKey)));
380
380
  textComponent = true;
381
381
  } // if we have a child, turn on plain, and hoverIndicator
382
382
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.useDisabled = exports.getSelectIcon = exports.getOptionValue = exports.getOptionLabel = exports.getNormalizedValue = exports.getIconColor = exports.getDisplayLabelKey = exports.changeEvent = exports.applyKey = void 0;
4
+ exports.useDisabled = exports.getSelectIcon = exports.getOptionValue = exports.getOptionLabel = exports.getOptionIndex = exports.getNormalizedValue = exports.getIconColor = exports.getDisplayLabelKey = exports.changeEvent = exports.arrayIncludes = exports.applyKey = void 0;
5
5
 
6
6
  var _react = require("react");
7
7
 
@@ -30,6 +30,32 @@ var getOptionValue = function getOptionValue(index, options, valueKey) {
30
30
 
31
31
  exports.getOptionValue = getOptionValue;
32
32
 
33
+ var getOptionIndex = function getOptionIndex(options, i, valueKey) {
34
+ if (options) {
35
+ if (typeof i === 'object') return options.findIndex(function (x) {
36
+ return applyKey(x, valueKey) === applyKey(i, valueKey);
37
+ });
38
+ return options.indexOf(i);
39
+ }
40
+
41
+ return undefined;
42
+ };
43
+
44
+ exports.getOptionIndex = getOptionIndex;
45
+
46
+ var arrayIncludes = function arrayIncludes(arr, i, valueKey) {
47
+ if (arr) {
48
+ if (typeof i === 'object') return arr.some(function (x) {
49
+ return applyKey(x, valueKey) === applyKey(i, valueKey);
50
+ });
51
+ return arr.includes(i);
52
+ }
53
+
54
+ return undefined;
55
+ };
56
+
57
+ exports.arrayIncludes = arrayIncludes;
58
+
33
59
  var useDisabled = function useDisabled(disabled, disabledKey, options, valueKey) {
34
60
  return (0, _react.useCallback)(function (index) {
35
61
  var option = options[index];
@@ -42,7 +68,7 @@ var useDisabled = function useDisabled(disabled, disabledKey, options, valueKey)
42
68
  result = disabled.indexOf(index) !== -1;
43
69
  } else {
44
70
  var optionVal = getOptionValue(index, options, valueKey);
45
- result = disabled.indexOf(optionVal) !== -1;
71
+ result = getOptionIndex(disabled, options[index], valueKey) !== -1 || getOptionIndex(disabled, optionVal, valueKey) !== -1;
46
72
  }
47
73
  }
48
74
 
@@ -194,17 +194,17 @@ var SelectMultiple = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
194
194
  if (onOpen) onOpen();
195
195
  }, [onOpen, open]);
196
196
  (0, _react.useEffect)(function () {
197
- if (sortSelectedOnClose && value && (open && search || !open)) {
197
+ if (sortSelectedOnClose && (open && search || !open)) {
198
198
  var selectedOptions = optionsProp.filter(function (option) {
199
- return value.includes(valueKey && valueKey.reduce ? (0, _utils2.applyKey)(option, valueKey) : option);
199
+ return (0, _utils2.arrayIncludes)(value, valueKey && valueKey.reduce ? (0, _utils2.applyKey)(option, valueKey) : option, valueKey || labelKey);
200
200
  });
201
201
  var unselectedOptions = optionsProp.filter(function (i) {
202
- return !selectedOptions.includes(i);
202
+ return !(0, _utils2.arrayIncludes)(selectedOptions, i, valueKey || labelKey);
203
203
  });
204
204
  var nextOrderedOptions = selectedOptions.concat(unselectedOptions);
205
205
  setOrderedOptions(nextOrderedOptions);
206
206
  }
207
- }, [open, sortSelectedOnClose, optionsProp, value, valueKey, search]);
207
+ }, [labelKey, open, sortSelectedOnClose, optionsProp, value, valueKey, search]);
208
208
  var onRequestClose = (0, _react.useCallback)(function () {
209
209
  setOpen(false);
210
210
  if (onClose) onClose();
@@ -161,7 +161,7 @@ var SelectMultipleContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
161
161
  return function (event) {
162
162
  if (onChange) {
163
163
  var nextOptionIndexesInValue = optionIndexesInValue.slice(0);
164
- var allOptionsIndex = allOptions.indexOf(options[index]);
164
+ var allOptionsIndex = (0, _utils2.getOptionIndex)(allOptions, options[index], valueKey || labelKey);
165
165
  var valueIndex = optionIndexesInValue.indexOf(allOptionsIndex);
166
166
 
167
167
  if (valueIndex === -1 && (!limit || (value == null ? void 0 : value.length) < limit)) {
@@ -181,7 +181,7 @@ var SelectMultipleContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
181
181
  });
182
182
  }
183
183
  };
184
- }, [limit, onChange, optionIndexesInValue, options, allOptions, valueKey, value]);
184
+ }, [labelKey, limit, onChange, optionIndexesInValue, options, allOptions, valueKey, value]);
185
185
  var onNextOption = (0, _react.useCallback)(function (event) {
186
186
  event.preventDefault();
187
187
  var nextActiveIndex = activeIndex + 1;
@@ -261,7 +261,7 @@ var SelectMultipleContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
261
261
  if (typeof disabledProp[0] === 'number') {
262
262
  result = disabledProp.indexOf(index) !== -1;
263
263
  } else {
264
- result = disabledProp.indexOf((0, _utils2.getOptionValue)(index, options, valueKey || labelKey)) !== -1;
264
+ result = (0, _utils2.getOptionIndex)(disabledProp, (0, _utils2.getOptionValue)(index, options, valueKey || labelKey), valueKey || labelKey) !== -1;
265
265
  }
266
266
  }
267
267
 
@@ -381,7 +381,7 @@ var SelectMultipleContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
381
381
  show: activeIndex !== -1 ? activeIndex : undefined
382
382
  }, function (option, index, optionRef) {
383
383
  var optionDisabled = isDisabled(index);
384
- var optionSelected = value ? value.includes(valueKey && valueKey.reduce ? (0, _utils2.applyKey)(option, valueKey) : option) : false;
384
+ var optionSelected = value ? (0, _utils2.arrayIncludes)(value, valueKey && valueKey.reduce ? (0, _utils2.applyKey)(option, valueKey) : option, valueKey || labelKey) : false;
385
385
  var optionActive = activeIndex === index;
386
386
  var optionLabel = (0, _utils2.getOptionLabel)(index, options, labelKey || valueKey); // Determine whether the label is done as a child or
387
387
  // as an option Button kind property.
@@ -411,13 +411,15 @@ var SelectMultipleContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
411
411
  }
412
412
 
413
413
  if (!children && search) {
414
- if (typeof optionLabel === 'string' && optionLabel.toLowerCase().indexOf(search) >= 0) {
414
+ var searchText = search.toLowerCase();
415
+
416
+ if (typeof optionLabel === 'string' && optionLabel.toLowerCase().indexOf(searchText) >= 0) {
415
417
  // code to bold search term in matching options
416
- var boldIndex = optionLabel.toLowerCase().indexOf(search);
418
+ var boldIndex = optionLabel.toLowerCase().indexOf(searchText);
417
419
  var childBeginning = optionLabel.substring(0, boldIndex);
418
- var childBold = optionLabel.substring(boldIndex, boldIndex + search.length);
420
+ var childBold = optionLabel.substring(boldIndex, boldIndex + searchText.length);
419
421
  childBold = /*#__PURE__*/_react["default"].createElement("b", null, childBold);
420
- var childEnd = optionLabel.substring(boldIndex + search.length);
422
+ var childEnd = optionLabel.substring(boldIndex + searchText.length);
421
423
  child = /*#__PURE__*/_react["default"].createElement(_CheckBox.CheckBox, {
422
424
  label: /*#__PURE__*/_react["default"].createElement(_Box.Box, {
423
425
  alignSelf: "center",
@@ -39,11 +39,13 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
39
39
  var isDisabled = (0, _utils.useDisabled)(disabled, disabledKey, allOptions, valueKey || labelKey);
40
40
  var visibleValue = (0, _react.useCallback)(function (i) {
41
41
  var optionValue = valueKey && valueKey.reduce ? (0, _utils.applyKey)(i, valueKey) : i;
42
- var indexOptions = allOptions.indexOf(i);
42
+ var optionSelected = (0, _utils.arrayIncludes)(value, optionValue, valueKey || labelKey);
43
+ var indexOptions = (0, _utils.getOptionIndex)(allOptions, i, valueKey || labelKey);
43
44
  var optionLabel = (0, _utils.getOptionLabel)(indexOptions, allOptions, labelKey || valueKey);
44
45
  var optionDisabled = isDisabled(indexOptions);
46
+ var valueIndex = (0, _utils.getOptionIndex)(value, optionValue, valueKey || labelKey);
45
47
 
46
- if (value.indexOf(optionValue) < theme.selectMultiple.maxInline) {
48
+ if (valueIndex < theme.selectMultiple.maxInline) {
47
49
  var child;
48
50
 
49
51
  if (children) {
@@ -56,10 +58,10 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
56
58
 
57
59
  return /*#__PURE__*/_react["default"].createElement(_StyledSelect.SelectOption, {
58
60
  role: "option",
59
- a11yTitle: value.includes(optionValue) ? optionLabel + " selected" : optionLabel + " not selected",
61
+ a11yTitle: optionSelected ? optionLabel + " selected" : optionLabel + " not selected",
60
62
  "aria-setsize": value.length,
61
- "aria-posinset": value.indexOf(optionValue) + 1,
62
- "aria-selected": value.includes(optionValue),
63
+ "aria-posinset": valueIndex + 1,
64
+ "aria-selected": optionSelected,
63
65
  "aria-disabled": optionDisabled,
64
66
  plain: true,
65
67
  hoverIndicator: !optionDisabled,
@@ -68,35 +70,30 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
68
70
  onClick: function onClick(event) {
69
71
  if (!optionDisabled) {
70
72
  var intermediate = [].concat(value);
71
- var index = value.indexOf(optionValue);
72
73
 
73
- if (intermediate.includes(optionValue)) {
74
+ if ((0, _utils.arrayIncludes)(intermediate, optionValue, valueKey || labelKey)) {
74
75
  onSelectChange(event, {
75
76
  option: optionValue,
76
77
  value: intermediate.filter(function (v) {
77
- return v !== optionValue;
78
+ return typeof v === 'object' ? (0, _utils.applyKey)(v, valueKey || labelKey) === (0, _utils.applyKey)(optionValue, valueKey || labelKey) : v !== optionValue;
78
79
  })
79
80
  });
80
81
 
81
- if (index !== intermediate.length - 1) {
82
+ if (valueIndex !== intermediate.length - 1) {
82
83
  setTimeout(function () {
83
- var nextFocus = document.getElementById("selected-" + intermediate[index + 1]);
84
+ var nextFocus = document.getElementById("selected-" + intermediate[valueIndex + 1]);
84
85
  if (nextFocus) nextFocus.focus();
85
- var result = allOptions.find(function (obj, j) {
86
- return (0, _utils.getOptionValue)(j, allOptions, valueKey || labelKey) === intermediate[index + 1];
87
- });
88
- setShowA11yDiv("Unselected " + optionLabel + ". \n Focus moved to " + (0, _utils.getOptionLabel)(allOptions.indexOf(result), allOptions, labelKey || valueKey));
86
+ var result = intermediate[valueIndex + 1];
87
+ setShowA11yDiv("Unselected " + optionLabel + ". \n Focus moved to " + (0, _utils.getOptionLabel)((0, _utils.getOptionIndex)(allOptions, result, valueKey || labelKey), allOptions, labelKey || valueKey));
89
88
  }, 200); // Timeout needed to allow screen reader
90
89
  // time to announce and next item to display on
91
90
  // screen. Based on testing, 200ms is enough time
92
91
  } else if (intermediate.length !== 1) {
93
92
  setTimeout(function () {
94
- var nextFocus = document.getElementById("selected-" + intermediate[index - 1]);
93
+ var nextFocus = document.getElementById("selected-" + intermediate[valueIndex - 1]);
95
94
  if (nextFocus) nextFocus.focus();
96
- var result = allOptions.find(function (obj, j) {
97
- return (0, _utils.getOptionValue)(j, allOptions, valueKey || labelKey) === intermediate[index - 1];
98
- });
99
- setShowA11yDiv("Unselected " + optionLabel + ". Focus moved to \n " + (0, _utils.getOptionLabel)(allOptions.indexOf(result), allOptions, labelKey || valueKey));
95
+ var result = intermediate[valueIndex - 1];
96
+ setShowA11yDiv("Unselected " + optionLabel + ". Focus moved to \n " + (0, _utils.getOptionLabel)((0, _utils.getOptionIndex)(allOptions, result, valueKey || labelKey), allOptions, labelKey || valueKey));
100
97
  }, 200); // Timeout needed to allow screen reader
101
98
  // time to announce and next item to display on
102
99
  // screen. Based on testing, 200ms is enough time
@@ -115,7 +112,7 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
115
112
  key: optionLabel,
116
113
  pad: "xsmall",
117
114
  tabIndex: "-1",
118
- checked: value.includes(optionValue)
115
+ checked: optionSelected
119
116
  }));
120
117
  }
121
118
 
@@ -136,7 +133,7 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
136
133
  "aria-multiselectable": true,
137
134
  a11yTitle: "Selected Options"
138
135
  }, value && allOptions.filter(function (i) {
139
- return value.indexOf(valueKey && valueKey.reduce ? (0, _utils.applyKey)(i, valueKey) : i) !== -1;
136
+ return (0, _utils.arrayIncludes)(value, valueKey && valueKey.reduce ? (0, _utils.applyKey)(i, valueKey) : i, valueKey || labelKey);
140
137
  })
141
138
  /* eslint-disable-next-line array-callback-return,
142
139
  consistent-return */
@@ -39,7 +39,7 @@ var SelectionSummary = function SelectionSummary(_ref) {
39
39
 
40
40
  if (value) {
41
41
  for (var i = 0; i < allOptions.length; i += 1) {
42
- if (value.includes((0, _utils.getOptionValue)(i, options, valueKey || labelKey)) && isDisabled(i)) disabledSelected += 1;
42
+ if ((0, _utils.arrayIncludes)(value, (0, _utils.getOptionValue)(i, options, valueKey || labelKey), valueKey || labelKey) && isDisabled(i)) disabledSelected += 1;
43
43
  }
44
44
 
45
45
  if (value.length === disabledSelected) return true;
@@ -25,6 +25,12 @@ var objectOptions = [{
25
25
  }, {
26
26
  label: 'Purple',
27
27
  value: 4
28
+ }, {
29
+ label: 'Pink',
30
+ value: 5
31
+ }, {
32
+ label: 'Grey',
33
+ value: 6
28
34
  }];
29
35
 
30
36
  var ObjectOptions = function ObjectOptions() {
@@ -32,6 +38,16 @@ var ObjectOptions = function ObjectOptions() {
32
38
  options = _useState[0],
33
39
  setOptions = _useState[1];
34
40
 
41
+ var _useState2 = (0, _react.useState)([{
42
+ label: 'Red',
43
+ value: 1
44
+ }, {
45
+ label: 'Grey',
46
+ value: 6
47
+ }]),
48
+ value = _useState2[0],
49
+ setValue = _useState2[1];
50
+
35
51
  return (
36
52
  /*#__PURE__*/
37
53
  // Uncomment <Grommet> lines when using outside of storybook
@@ -43,6 +59,7 @@ var ObjectOptions = function ObjectOptions() {
43
59
  justify: "start",
44
60
  pad: "large"
45
61
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "SelectMultiple with Object Options"), /*#__PURE__*/_react["default"].createElement(_SelectMultiple.SelectMultiple, {
62
+ value: value,
46
63
  onSearch: function onSearch(text) {
47
64
  var escapedText = text.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&'); // Create the regular expression with modified value which
48
65
  // handles escaping special characters. Without escaping special
@@ -61,7 +78,14 @@ var ObjectOptions = function ObjectOptions() {
61
78
  valueKey: {
62
79
  key: 'value'
63
80
  },
64
- options: options
81
+ options: options,
82
+ onClose: function onClose() {
83
+ setOptions(objectOptions);
84
+ },
85
+ onChange: function onChange(_ref) {
86
+ var nextValue = _ref.value;
87
+ setValue(nextValue);
88
+ }
65
89
  })) // </Grommet>
66
90
 
67
91
  );
@@ -60,7 +60,9 @@ var SidebarButton = function SidebarButton(_ref) {
60
60
  };
61
61
 
62
62
  var SidebarFooter = function SidebarFooter() {
63
- return /*#__PURE__*/_react["default"].createElement(_grommet.Nav, null, /*#__PURE__*/_react["default"].createElement(SidebarButton, {
63
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Nav, {
64
+ "aria-label": "sidebar footer"
65
+ }, /*#__PURE__*/_react["default"].createElement(SidebarButton, {
64
66
  icon: /*#__PURE__*/_react["default"].createElement(_grommetIcons.Chat, null)
65
67
  }), /*#__PURE__*/_react["default"].createElement(SidebarButton, {
66
68
  icon: /*#__PURE__*/_react["default"].createElement(_grommetIcons.Help, null)
@@ -69,6 +71,7 @@ var SidebarFooter = function SidebarFooter() {
69
71
 
70
72
  var MainNavigation = function MainNavigation() {
71
73
  return /*#__PURE__*/_react["default"].createElement(_grommet.Nav, {
74
+ "aria-label": "main navigation",
72
75
  gap: "large",
73
76
  responsive: false
74
77
  }, /*#__PURE__*/_react["default"].createElement(SidebarButton, {
@@ -30,6 +30,7 @@ var Resize = function Resize(props) {
30
30
  align: "center",
31
31
  pad: "large"
32
32
  }, /*#__PURE__*/_react["default"].createElement(_grommet.TextArea, _extends({
33
+ "aria-label": "text area",
33
34
  value: value,
34
35
  onChange: onChange
35
36
  }, props))) // </Grommet>