grommet 2.25.3 → 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 (160) 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/Box/stories/BackgroundThemed.js +54 -0
  5. package/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
  6. package/components/Calendar/Calendar.js +2 -1
  7. package/components/CheckBox/StyledCheckBox.js +9 -5
  8. package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
  9. package/components/CheckBoxGroup/index.d.ts +2 -1
  10. package/components/CheckBoxGroup/propTypes.js +1 -0
  11. package/components/DataChart/Detail.js +3 -1
  12. package/components/DataTable/index.d.ts +6 -6
  13. package/components/DateInput/DateInput.js +1 -1
  14. package/components/Diagram/Diagram.js +2 -1
  15. package/components/Drop/stories/Inline.js +1 -1
  16. package/components/Drop/stories/Overflow.js +1 -1
  17. package/components/Drop/stories/Plain.js +1 -1
  18. package/components/Drop/stories/Simple.js +1 -1
  19. package/components/Drop/stories/Styled.js +1 -1
  20. package/components/FormField/FormField.js +1 -1
  21. package/components/Heading/Heading.js +31 -2
  22. package/components/Heading/StyledHeading.js +1 -1
  23. package/components/Heading/index.d.ts +1 -0
  24. package/components/Heading/propTypes.js +1 -0
  25. package/components/Heading/stories/All.js +4 -1
  26. package/components/List/List.js +125 -41
  27. package/components/List/index.d.ts +1 -0
  28. package/components/List/propTypes.js +1 -0
  29. package/components/List/stories/Order.js +1 -0
  30. package/components/List/stories/Pinned.js +37 -0
  31. package/components/List/stories/Selection.js +1 -0
  32. package/components/List/stories/onClickItem.js +1 -0
  33. package/components/Notification/Notification.js +2 -2
  34. package/components/Notification/index.d.ts +1 -1
  35. package/components/Notification/propTypes.js +1 -1
  36. package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
  37. package/components/RadioButton/README.md +1 -279
  38. package/components/RadioButton/RadioButton.js +1 -0
  39. package/components/Select/DefaultSelectTextInput.js +43 -0
  40. package/components/Select/EmptySearchOption.js +34 -0
  41. package/components/Select/Select.js +38 -99
  42. package/components/Select/SelectContainer.js +20 -60
  43. package/components/Select/StyledSelect.js +58 -2
  44. package/components/Select/index.d.ts +11 -9
  45. package/components/Select/propTypes.js +44 -40
  46. package/components/Select/utils.js +129 -3
  47. package/components/SelectMultiple/README.md +2 -0
  48. package/components/SelectMultiple/SelectMultiple.js +476 -0
  49. package/components/SelectMultiple/SelectMultipleContainer.js +483 -0
  50. package/components/SelectMultiple/SelectMultipleValue.js +163 -0
  51. package/components/SelectMultiple/SelectionSummary.js +104 -0
  52. package/components/SelectMultiple/index.d.ts +21 -0
  53. package/components/SelectMultiple/index.js +8 -0
  54. package/components/SelectMultiple/propTypes.js +28 -0
  55. package/components/SelectMultiple/stories/Default.js +76 -0
  56. package/components/SelectMultiple/stories/Disabled.js +84 -0
  57. package/components/SelectMultiple/stories/FormField.js +66 -0
  58. package/components/SelectMultiple/stories/Limited.js +68 -0
  59. package/components/SelectMultiple/stories/LongList.js +76 -0
  60. package/components/SelectMultiple/stories/ObjectOptions.js +104 -0
  61. package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
  62. package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
  63. package/components/Sidebar/stories/Labels.js +4 -1
  64. package/components/TextArea/stories/NonResizable.js +1 -0
  65. package/components/TextArea/stories/Simple.js +1 -0
  66. package/components/index.d.ts +1 -0
  67. package/components/index.js +8 -0
  68. package/es6/all/stories/AllComponents.js +21 -121
  69. package/es6/components/Accordion/stories/CustomHeader.js +3 -1
  70. package/es6/components/Avatar/Avatar.js +21 -9
  71. package/es6/components/Box/stories/BackgroundThemed.js +39 -0
  72. package/es6/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
  73. package/es6/components/Calendar/Calendar.js +2 -1
  74. package/es6/components/CheckBox/StyledCheckBox.js +9 -5
  75. package/es6/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
  76. package/es6/components/CheckBoxGroup/index.d.ts +2 -1
  77. package/es6/components/CheckBoxGroup/propTypes.js +1 -0
  78. package/es6/components/DataChart/Detail.js +3 -1
  79. package/es6/components/DataTable/index.d.ts +6 -6
  80. package/es6/components/DateInput/DateInput.js +1 -1
  81. package/es6/components/Diagram/Diagram.js +2 -1
  82. package/es6/components/Drop/stories/Inline.js +1 -1
  83. package/es6/components/Drop/stories/Overflow.js +1 -1
  84. package/es6/components/Drop/stories/Plain.js +1 -1
  85. package/es6/components/Drop/stories/Simple.js +1 -1
  86. package/es6/components/Drop/stories/Styled.js +1 -1
  87. package/es6/components/FormField/FormField.js +1 -1
  88. package/es6/components/Heading/Heading.js +30 -3
  89. package/es6/components/Heading/StyledHeading.js +1 -1
  90. package/es6/components/Heading/index.d.ts +1 -0
  91. package/es6/components/Heading/propTypes.js +1 -0
  92. package/es6/components/Heading/stories/All.js +4 -1
  93. package/es6/components/List/List.js +126 -42
  94. package/es6/components/List/index.d.ts +1 -0
  95. package/es6/components/List/propTypes.js +1 -0
  96. package/es6/components/List/stories/Order.js +1 -0
  97. package/es6/components/List/stories/Pinned.js +22 -0
  98. package/es6/components/List/stories/Selection.js +1 -0
  99. package/es6/components/List/stories/onClickItem.js +1 -0
  100. package/es6/components/Notification/Notification.js +2 -2
  101. package/es6/components/Notification/index.d.ts +1 -1
  102. package/es6/components/Notification/propTypes.js +1 -1
  103. package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
  104. package/es6/components/RadioButton/README.md +1 -279
  105. package/es6/components/RadioButton/RadioButton.js +1 -0
  106. package/es6/components/Select/DefaultSelectTextInput.js +31 -0
  107. package/es6/components/Select/EmptySearchOption.js +21 -0
  108. package/es6/components/Select/Select.js +34 -93
  109. package/es6/components/Select/SelectContainer.js +20 -59
  110. package/es6/components/Select/StyledSelect.js +45 -1
  111. package/es6/components/Select/index.d.ts +11 -9
  112. package/es6/components/Select/propTypes.js +41 -39
  113. package/es6/components/Select/utils.js +95 -1
  114. package/es6/components/SelectMultiple/README.md +2 -0
  115. package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
  116. package/es6/components/SelectMultiple/SelectMultipleContainer.js +455 -0
  117. package/es6/components/SelectMultiple/SelectMultipleValue.js +149 -0
  118. package/es6/components/SelectMultiple/SelectionSummary.js +91 -0
  119. package/es6/components/SelectMultiple/index.d.ts +21 -0
  120. package/es6/components/SelectMultiple/index.js +1 -0
  121. package/es6/components/SelectMultiple/propTypes.js +18 -0
  122. package/es6/components/SelectMultiple/stories/Default.js +60 -0
  123. package/es6/components/SelectMultiple/stories/Disabled.js +68 -0
  124. package/es6/components/SelectMultiple/stories/FormField.js +50 -0
  125. package/es6/components/SelectMultiple/stories/Limited.js +53 -0
  126. package/es6/components/SelectMultiple/stories/LongList.js +63 -0
  127. package/es6/components/SelectMultiple/stories/ObjectOptions.js +88 -0
  128. package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
  129. package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
  130. package/es6/components/Sidebar/stories/Labels.js +4 -1
  131. package/es6/components/TextArea/stories/NonResizable.js +1 -0
  132. package/es6/components/TextArea/stories/Simple.js +1 -0
  133. package/es6/components/index.d.ts +1 -0
  134. package/es6/components/index.js +1 -0
  135. package/es6/index.d.ts +1 -0
  136. package/es6/themes/base.d.ts +16 -5
  137. package/es6/themes/base.js +60 -39
  138. package/es6/themes/grommet.js +15 -0
  139. package/es6/themes/hacktoberfest2022.js +129 -0
  140. package/es6/themes/index.js +2 -1
  141. package/es6/utils/background.js +65 -12
  142. package/es6/utils/general-prop-types.js +2 -0
  143. package/es6/utils/index.d.ts +2 -0
  144. package/es6/utils/styles.js +3 -1
  145. package/grommet.min.js +1 -1
  146. package/grommet.min.js.map +1 -1
  147. package/index.d.ts +1 -0
  148. package/package.json +44 -41
  149. package/themes/base.d.ts +16 -5
  150. package/themes/base.js +61 -39
  151. package/themes/grommet.js +15 -0
  152. package/themes/hacktoberfest2022.js +137 -0
  153. package/themes/index.js +6 -2
  154. package/tools/grommet-babel-preset-es2015.js +1 -12
  155. package/tools/pack.js +1 -94
  156. package/tools/release-stable.js +1 -27
  157. package/utils/background.js +64 -12
  158. package/utils/general-prop-types.js +2 -0
  159. package/utils/index.d.ts +2 -0
  160. 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
@@ -91,6 +91,7 @@ var RadioButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
91
91
  },
92
92
  round: theme.radioButton.check.radius
93
93
  }, checked && (Icon ? /*#__PURE__*/React.createElement(Icon, {
94
+ theme: theme,
94
95
  as: StyledRadioButtonIcon
95
96
  }) : /*#__PURE__*/React.createElement(StyledRadioButtonIcon, {
96
97
  viewBox: "0 0 24 24",
@@ -0,0 +1,31 @@
1
+ var _excluded = ["disabled", "id"];
2
+
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+
7
+ import React, { forwardRef } from 'react';
8
+ import { SelectTextInput } from './StyledSelect';
9
+ export var DefaultSelectTextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
+ var disabled = _ref.disabled,
11
+ id = _ref.id,
12
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
13
+
14
+ return /*#__PURE__*/React.createElement(SelectTextInput // When Select is disabled, we want to show a default cursor
15
+ // but not have disabled styling come from TextInput
16
+ // Disabled can be a bool or an array of options to disable.
17
+ // We only want to disable the TextInput if the control
18
+ // button should be disabled which occurs when disabled
19
+ // equals true.
20
+ , _extends({
21
+ defaultCursor: disabled === true || undefined,
22
+ focusIndicator: false,
23
+ id: id ? id + "__input" : undefined,
24
+ ref: ref
25
+ }, rest, {
26
+ tabIndex: "-1",
27
+ type: "text",
28
+ plain: true,
29
+ readOnly: true
30
+ }));
31
+ });
@@ -0,0 +1,21 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import { Box } from '../Box';
5
+ import { Text } from '../Text';
6
+ import { SelectOption } from './StyledSelect';
7
+ export var EmptySearchOption = function EmptySearchOption(_ref) {
8
+ var emptySearchMessage = _ref.emptySearchMessage,
9
+ selectOptionsStyle = _ref.selectOptionsStyle,
10
+ theme = _ref.theme;
11
+ return /*#__PURE__*/React.createElement(SelectOption, {
12
+ key: "search_empty",
13
+ tabIndex: "0",
14
+ role: "menuitem",
15
+ hoverIndicator: "background",
16
+ disabled: true
17
+ }, /*#__PURE__*/React.createElement(Box, selectOptionsStyle, /*#__PURE__*/React.createElement(Text, _extends({
18
+ "aria-live": "polite",
19
+ role: "alert"
20
+ }, theme.select.container.text), emptySearchMessage)));
21
+ };
@@ -5,38 +5,18 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
 
7
7
  import React, { forwardRef, isValidElement, useCallback, useContext, useMemo, useState, useRef, useEffect } from 'react';
8
- import styled, { ThemeContext } from 'styled-components';
9
- import { controlBorderStyle, normalizeColor, useKeyboard } from '../../utils';
8
+ import { ThemeContext } from 'styled-components';
9
+ import { useKeyboard } from '../../utils';
10
10
  import { defaultProps } from '../../default-props';
11
11
  import { Box } from '../Box';
12
- import { DropButton } from '../DropButton';
13
12
  import { Keyboard } from '../Keyboard';
14
13
  import { FormContext } from '../Form/FormContext';
15
- import { TextInput } from '../TextInput';
16
14
  import { SelectContainer } from './SelectContainer';
17
- import { applyKey } from './utils';
15
+ import { HiddenInput, StyledSelectDropButton } from './StyledSelect';
16
+ import { applyKey, getNormalizedValue, changeEvent, getSelectIcon, getDisplayLabelKey, getIconColor } from './utils';
17
+ import { DefaultSelectTextInput } from './DefaultSelectTextInput';
18
18
  import { MessageContext } from '../../contexts/MessageContext';
19
19
  import { SelectPropTypes } from './propTypes';
20
- var SelectTextInput = styled(TextInput).withConfig({
21
- displayName: "Select__SelectTextInput",
22
- componentId: "sc-17idtfo-0"
23
- })(["cursor:", ";"], function (props) {
24
- return props.defaultCursor ? 'default' : 'pointer';
25
- });
26
- var HiddenInput = styled.input.withConfig({
27
- displayName: "Select__HiddenInput",
28
- componentId: "sc-17idtfo-1"
29
- })(["display:none;"]);
30
- var StyledSelectDropButton = styled(DropButton).withConfig({
31
- displayName: "Select__StyledSelectDropButton",
32
- componentId: "sc-17idtfo-2"
33
- })(["", ";", ";", ";"], function (props) {
34
- return !props.callerPlain && controlBorderStyle;
35
- }, function (props) {
36
- return props.theme.select && props.theme.select.control && props.theme.select.control.extend;
37
- }, function (props) {
38
- return props.open && props.theme.select.control.open;
39
- });
40
20
  StyledSelectDropButton.defaultProps = {};
41
21
  Object.setPrototypeOf(StyledSelectDropButton.defaultProps, defaultProps);
42
22
  var defaultDropAlign = {
@@ -65,7 +45,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
65
45
  gridArea = _ref.gridArea,
66
46
  id = _ref.id,
67
47
  icon = _ref.icon,
68
- labelKey = _ref.labelKey,
48
+ labelKeyProp = _ref.labelKey,
69
49
  margin = _ref.margin,
70
50
  messages = _ref.messages,
71
51
  multiple = _ref.multiple,
@@ -88,7 +68,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
88
68
  selected = _ref.selected,
89
69
  size = _ref.size,
90
70
  valueProp = _ref.value,
91
- valueKey = _ref.valueKey,
71
+ valueKeyProp = _ref.valueKey,
92
72
  valueLabel = _ref.valueLabel,
93
73
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
94
74
 
@@ -97,11 +77,15 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
97
77
  var formContext = useContext(FormContext);
98
78
 
99
79
  var _useContext = useContext(MessageContext),
100
- format = _useContext.format; // Determine if the Select is opened with the keyboard. If so,
80
+ format = _useContext.format; // For greater resilience, use labelKey if valueKey isn't provided and
81
+ // vice versa. https://github.com/grommet/grommet/pull/6299
82
+
83
+
84
+ var valueKey = valueKeyProp || labelKeyProp;
85
+ var labelKey = labelKeyProp || valueKeyProp; // Determine if the Select is opened with the keyboard. If so,
101
86
  // focus should be set on the first option when the drop opens
102
87
  // see set initial focus code in SelectContainer.js
103
88
 
104
-
105
89
  var usingKeyboard = useKeyboard(); // value is used for what we receive in valueProp and the basis for
106
90
  // what we send with onChange
107
91
  // When 'valueKey' sets 'reduce', the value(s) here should match
@@ -115,7 +99,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
115
99
  initialValue: defaultValue || ''
116
100
  }),
117
101
  value = _formContext$useFormI[0],
118
- setValue = _formContext$useFormI[1]; // valuedValue is the value mapped with any valueKey applied
102
+ setValue = _formContext$useFormI[1]; // normalizedValue is the value mapped with any valueKey applied
119
103
  // When the options array contains objects, this property indicates how
120
104
  // to retrieve the value of each option.
121
105
  // If a string is provided, it is used as the key to retrieve a
@@ -126,11 +110,8 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
126
110
  // delivered via 'onChange'.
127
111
 
128
112
 
129
- var valuedValue = useMemo(function () {
130
- if (Array.isArray(value)) return value.map(function (v) {
131
- return valueKey && valueKey.reduce ? v : applyKey(v, valueKey);
132
- });
133
- return valueKey && valueKey.reduce ? value : applyKey(value, valueKey);
113
+ var normalizedValue = useMemo(function () {
114
+ return getNormalizedValue(value, valueKey);
134
115
  }, [value, valueKey]); // search input value
135
116
 
136
117
  var _useState = useState(),
@@ -158,18 +139,18 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
158
139
  } else if (index === selected) {
159
140
  result.push(index);
160
141
  }
161
- } else if (Array.isArray(valuedValue)) {
162
- if (valuedValue.some(function (v) {
142
+ } else if (Array.isArray(normalizedValue)) {
143
+ if (normalizedValue.some(function (v) {
163
144
  return v === applyKey(option, valueKey);
164
145
  })) {
165
146
  result.push(index);
166
147
  }
167
- } else if (valuedValue === applyKey(option, valueKey)) {
148
+ } else if (normalizedValue === applyKey(option, valueKey)) {
168
149
  result.push(index);
169
150
  }
170
151
  });
171
152
  return result;
172
- }, [allOptions, selected, valueKey, valuedValue]);
153
+ }, [allOptions, selected, valueKey, normalizedValue]);
173
154
 
174
155
  var _useState3 = useState(propOpen),
175
156
  open = _useState3[0],
@@ -189,16 +170,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
189
170
  setSearch();
190
171
  }, [onClose]);
191
172
  var triggerChangeEvent = useCallback(function (nextValue) {
192
- // Calling set value function directly on input because React library
193
- // overrides setter `event.target.value =` and loses original event
194
- // target fidelity.
195
- // https://stackoverflow.com/a/46012210
196
- var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
197
- nativeInputValueSetter.call(inputRef.current, nextValue);
198
- var event = new Event('input', {
199
- bubbles: true
200
- });
201
- inputRef.current.dispatchEvent(event);
173
+ return changeEvent(inputRef, nextValue);
202
174
  }, []);
203
175
  var onSelectChange = useCallback(function (event, _ref2) {
204
176
  var option = _ref2.option,
@@ -208,7 +180,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
208
180
  // input. if it is an object, then the user has not provided necessary
209
181
  // props to reduce object option
210
182
 
211
- if (typeof nextValue !== 'object' && nextValue !== event.target.value && inputRef.current) {
183
+ if ((typeof nextValue !== 'object' || multiple) && nextValue !== event.target.value && inputRef.current) {
212
184
  // select registers changing option as a click event or keydown.
213
185
  // when in a form, we need to programatically trigger a change
214
186
  // event in order for the change event to be registered upstream
@@ -248,22 +220,8 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
248
220
 
249
221
  onChange(adjustedEvent);
250
222
  }
251
- }, [closeOnChange, onChange, onRequestClose, setValue, triggerChangeEvent]);
252
- var SelectIcon;
253
-
254
- switch (icon) {
255
- case false:
256
- break;
257
-
258
- case true:
259
- case undefined:
260
- SelectIcon = open && theme.select.icons.up ? theme.select.icons.up : theme.select.icons.down;
261
- break;
262
-
263
- default:
264
- SelectIcon = icon;
265
- } // element to show, trumps inputValue
266
-
223
+ }, [closeOnChange, multiple, onChange, onRequestClose, setValue, triggerChangeEvent]);
224
+ var SelectIcon = getSelectIcon(icon, theme, open); // element to show, trumps inputValue
267
225
 
268
226
  var selectValue = useMemo(function () {
269
227
  if (valueLabel instanceof Function) {
@@ -272,14 +230,9 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
272
230
 
273
231
 
274
232
  return undefined;
275
- }, [value, valueLabel]); // if labelKey is a function and valueLabel is not defined
276
- // we should use the labelKey function to display the
277
- // selected value
278
-
233
+ }, [value, valueLabel]);
279
234
  var displayLabelKey = useMemo(function () {
280
- var optionLabelKey = applyKey(allOptions[optionIndexesInValue[0]], labelKey);
281
- if (!selectValue && optionIndexesInValue.length === 1 && typeof optionLabelKey === 'object') return optionLabelKey;
282
- return undefined;
235
+ return getDisplayLabelKey(labelKey, allOptions, optionIndexesInValue, selectValue);
283
236
  }, [labelKey, allOptions, optionIndexesInValue, selectValue]); // text to show
284
237
  // When the options array contains objects, this property indicates how
285
238
  // to retrieve the value of each option.
@@ -302,7 +255,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
302
255
 
303
256
  return undefined;
304
257
  }, [labelKey, messages, format, optionIndexesInValue, allOptions, selectValue]);
305
- var iconColor = normalizeColor(theme.select.icons.color || 'control', theme);
258
+ var iconColor = getIconColor(theme);
306
259
  return /*#__PURE__*/React.createElement(Keyboard, {
307
260
  onDown: onRequestOpen,
308
261
  onUp: onRequestOpen
@@ -358,7 +311,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
358
311
  valueKey: valueKey
359
312
  }, children) // StyledDropButton needs to know if the border should be shown
360
313
  ,
361
- callerPlain: plain,
314
+ plainSelect: plain,
362
315
  plain: true // Button should be plain
363
316
  ,
364
317
  dropProps: dropProps,
@@ -379,29 +332,17 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
379
332
  value: inputValue,
380
333
  ref: inputRef,
381
334
  readOnly: true
382
- })) : /*#__PURE__*/React.createElement(SelectTextInput, _extends({
383
- a11yTitle: (ariaLabel || a11yTitle) && "" + (ariaLabel || a11yTitle) + (value && typeof value === 'string' ? ", " + value : '') // When Select is disabled, we want to show a default cursor
384
- // but not have disabled styling come from TextInput
385
- // Disabled can be a bool or an array of options to disable.
386
- // We only want to disable the TextInput if the control
387
- // button should be disabled which occurs when disabled
388
- // equals true.
389
- ,
390
- defaultCursor: disabled === true || undefined,
391
- focusIndicator: false,
392
- id: id ? id + "__input" : undefined,
335
+ })) : /*#__PURE__*/React.createElement(DefaultSelectTextInput, _extends({
336
+ a11yTitle: (ariaLabel || a11yTitle) && "" + (ariaLabel || a11yTitle) + (value && typeof value === 'string' ? ", " + value : ''),
337
+ disabled: disabled,
338
+ id: id,
393
339
  name: name,
394
- ref: inputRef
395
- }, rest, {
396
- tabIndex: "-1",
397
- type: "text",
340
+ ref: inputRef,
398
341
  placeholder: placeholder,
399
- plain: true,
400
- readOnly: true,
401
342
  value: inputValue,
402
343
  size: size,
403
344
  theme: theme
404
- }))), SelectIcon && /*#__PURE__*/React.createElement(Box, {
345
+ }, rest))), SelectIcon && /*#__PURE__*/React.createElement(Box, {
405
346
  margin: theme.select.icons.margin,
406
347
  flex: false,
407
348
  style: {