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.
- package/all/stories/AllComponents.js +19 -126
- package/components/Accordion/stories/CustomHeader.js +3 -1
- package/components/Avatar/Avatar.js +22 -9
- package/components/Box/stories/BackgroundThemed.js +54 -0
- package/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
- package/components/Calendar/Calendar.js +2 -1
- package/components/CheckBox/StyledCheckBox.js +9 -5
- package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/components/CheckBoxGroup/index.d.ts +2 -1
- package/components/CheckBoxGroup/propTypes.js +1 -0
- package/components/DataChart/Detail.js +3 -1
- package/components/DataTable/index.d.ts +6 -6
- package/components/DateInput/DateInput.js +1 -1
- package/components/Diagram/Diagram.js +2 -1
- package/components/Drop/stories/Inline.js +1 -1
- package/components/Drop/stories/Overflow.js +1 -1
- package/components/Drop/stories/Plain.js +1 -1
- package/components/Drop/stories/Simple.js +1 -1
- package/components/Drop/stories/Styled.js +1 -1
- package/components/FormField/FormField.js +1 -1
- package/components/Heading/Heading.js +31 -2
- package/components/Heading/StyledHeading.js +1 -1
- package/components/Heading/index.d.ts +1 -0
- package/components/Heading/propTypes.js +1 -0
- package/components/Heading/stories/All.js +4 -1
- package/components/List/List.js +125 -41
- package/components/List/index.d.ts +1 -0
- package/components/List/propTypes.js +1 -0
- package/components/List/stories/Order.js +1 -0
- package/components/List/stories/Pinned.js +37 -0
- package/components/List/stories/Selection.js +1 -0
- package/components/List/stories/onClickItem.js +1 -0
- package/components/Notification/Notification.js +2 -2
- package/components/Notification/index.d.ts +1 -1
- package/components/Notification/propTypes.js +1 -1
- package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/components/RadioButton/README.md +1 -279
- package/components/RadioButton/RadioButton.js +1 -0
- package/components/Select/DefaultSelectTextInput.js +43 -0
- package/components/Select/EmptySearchOption.js +34 -0
- package/components/Select/Select.js +38 -99
- package/components/Select/SelectContainer.js +20 -60
- package/components/Select/StyledSelect.js +58 -2
- package/components/Select/index.d.ts +11 -9
- package/components/Select/propTypes.js +44 -40
- package/components/Select/utils.js +129 -3
- package/components/SelectMultiple/README.md +2 -0
- package/components/SelectMultiple/SelectMultiple.js +476 -0
- package/components/SelectMultiple/SelectMultipleContainer.js +483 -0
- package/components/SelectMultiple/SelectMultipleValue.js +163 -0
- package/components/SelectMultiple/SelectionSummary.js +104 -0
- package/components/SelectMultiple/index.d.ts +21 -0
- package/components/SelectMultiple/index.js +8 -0
- package/components/SelectMultiple/propTypes.js +28 -0
- package/components/SelectMultiple/stories/Default.js +76 -0
- package/components/SelectMultiple/stories/Disabled.js +84 -0
- package/components/SelectMultiple/stories/FormField.js +66 -0
- package/components/SelectMultiple/stories/Limited.js +68 -0
- package/components/SelectMultiple/stories/LongList.js +76 -0
- package/components/SelectMultiple/stories/ObjectOptions.js +104 -0
- package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
- package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/components/Sidebar/stories/Labels.js +4 -1
- package/components/TextArea/stories/NonResizable.js +1 -0
- package/components/TextArea/stories/Simple.js +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +8 -0
- package/es6/all/stories/AllComponents.js +21 -121
- package/es6/components/Accordion/stories/CustomHeader.js +3 -1
- package/es6/components/Avatar/Avatar.js +21 -9
- package/es6/components/Box/stories/BackgroundThemed.js +39 -0
- package/es6/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
- package/es6/components/Calendar/Calendar.js +2 -1
- package/es6/components/CheckBox/StyledCheckBox.js +9 -5
- package/es6/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/es6/components/CheckBoxGroup/index.d.ts +2 -1
- package/es6/components/CheckBoxGroup/propTypes.js +1 -0
- package/es6/components/DataChart/Detail.js +3 -1
- package/es6/components/DataTable/index.d.ts +6 -6
- package/es6/components/DateInput/DateInput.js +1 -1
- package/es6/components/Diagram/Diagram.js +2 -1
- package/es6/components/Drop/stories/Inline.js +1 -1
- package/es6/components/Drop/stories/Overflow.js +1 -1
- package/es6/components/Drop/stories/Plain.js +1 -1
- package/es6/components/Drop/stories/Simple.js +1 -1
- package/es6/components/Drop/stories/Styled.js +1 -1
- package/es6/components/FormField/FormField.js +1 -1
- package/es6/components/Heading/Heading.js +30 -3
- package/es6/components/Heading/StyledHeading.js +1 -1
- package/es6/components/Heading/index.d.ts +1 -0
- package/es6/components/Heading/propTypes.js +1 -0
- package/es6/components/Heading/stories/All.js +4 -1
- package/es6/components/List/List.js +126 -42
- package/es6/components/List/index.d.ts +1 -0
- package/es6/components/List/propTypes.js +1 -0
- package/es6/components/List/stories/Order.js +1 -0
- package/es6/components/List/stories/Pinned.js +22 -0
- package/es6/components/List/stories/Selection.js +1 -0
- package/es6/components/List/stories/onClickItem.js +1 -0
- package/es6/components/Notification/Notification.js +2 -2
- package/es6/components/Notification/index.d.ts +1 -1
- package/es6/components/Notification/propTypes.js +1 -1
- package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/es6/components/RadioButton/README.md +1 -279
- package/es6/components/RadioButton/RadioButton.js +1 -0
- package/es6/components/Select/DefaultSelectTextInput.js +31 -0
- package/es6/components/Select/EmptySearchOption.js +21 -0
- package/es6/components/Select/Select.js +34 -93
- package/es6/components/Select/SelectContainer.js +20 -59
- package/es6/components/Select/StyledSelect.js +45 -1
- package/es6/components/Select/index.d.ts +11 -9
- package/es6/components/Select/propTypes.js +41 -39
- package/es6/components/Select/utils.js +95 -1
- package/es6/components/SelectMultiple/README.md +2 -0
- package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +455 -0
- package/es6/components/SelectMultiple/SelectMultipleValue.js +149 -0
- package/es6/components/SelectMultiple/SelectionSummary.js +91 -0
- package/es6/components/SelectMultiple/index.d.ts +21 -0
- package/es6/components/SelectMultiple/index.js +1 -0
- package/es6/components/SelectMultiple/propTypes.js +18 -0
- package/es6/components/SelectMultiple/stories/Default.js +60 -0
- package/es6/components/SelectMultiple/stories/Disabled.js +68 -0
- package/es6/components/SelectMultiple/stories/FormField.js +50 -0
- package/es6/components/SelectMultiple/stories/Limited.js +53 -0
- package/es6/components/SelectMultiple/stories/LongList.js +63 -0
- package/es6/components/SelectMultiple/stories/ObjectOptions.js +88 -0
- package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
- package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/es6/components/Sidebar/stories/Labels.js +4 -1
- package/es6/components/TextArea/stories/NonResizable.js +1 -0
- package/es6/components/TextArea/stories/Simple.js +1 -0
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/index.d.ts +1 -0
- package/es6/themes/base.d.ts +16 -5
- package/es6/themes/base.js +60 -39
- package/es6/themes/grommet.js +15 -0
- package/es6/themes/hacktoberfest2022.js +129 -0
- package/es6/themes/index.js +2 -1
- package/es6/utils/background.js +65 -12
- package/es6/utils/general-prop-types.js +2 -0
- package/es6/utils/index.d.ts +2 -0
- package/es6/utils/styles.js +3 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +44 -41
- package/themes/base.d.ts +16 -5
- package/themes/base.js +61 -39
- package/themes/grommet.js +15 -0
- package/themes/hacktoberfest2022.js +137 -0
- package/themes/index.js +6 -2
- package/tools/grommet-babel-preset-es2015.js +1 -12
- package/tools/pack.js +1 -94
- package/tools/release-stable.js +1 -27
- package/utils/background.js +64 -12
- package/utils/general-prop-types.js +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/styles.js +3 -1
|
@@ -4,7 +4,7 @@ import { Box, Grommet, Notification } from 'grommet';
|
|
|
4
4
|
|
|
5
5
|
import { deepMerge } from 'grommet/utils';
|
|
6
6
|
import { grommet, ThemeType } from 'grommet/themes';
|
|
7
|
-
import {
|
|
7
|
+
import { CircleQuestion } from 'grommet-icons';
|
|
8
8
|
|
|
9
9
|
// Type annotations can only be used in TypeScript files.
|
|
10
10
|
// Remove ': ThemeType' if you are not using Typescript.
|
|
@@ -18,7 +18,6 @@ const customTheme: ThemeType = deepMerge(grommet, {
|
|
|
18
18
|
container: {
|
|
19
19
|
// any BoxProps
|
|
20
20
|
pad: { horizontal: 'large', vertical: '36px' },
|
|
21
|
-
background: '#87a200',
|
|
22
21
|
border: { color: '#000000', size: 'large' },
|
|
23
22
|
},
|
|
24
23
|
iconContainer: {
|
|
@@ -46,6 +45,7 @@ const customTheme: ThemeType = deepMerge(grommet, {
|
|
|
46
45
|
},
|
|
47
46
|
unknown: {
|
|
48
47
|
icon: CircleQuestion,
|
|
48
|
+
background: '#87a200',
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
});
|
|
@@ -1,280 +1,2 @@
|
|
|
1
1
|
## RadioButton
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
RadioButton should typically not be used directly.
|
|
5
|
-
Instead, use RadioButtonGroup.
|
|
6
|
-
|
|
7
|
-
[](https://storybook.grommet.io/?selectedKind=Input-RadioButton&full=0&stories=1&panelRight=0) [](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",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.DefaultSelectTextInput = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _StyledSelect = require("./StyledSelect");
|
|
9
|
+
|
|
10
|
+
var _excluded = ["disabled", "id"];
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
var DefaultSelectTextInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
21
|
+
var disabled = _ref.disabled,
|
|
22
|
+
id = _ref.id,
|
|
23
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
24
|
+
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement(_StyledSelect.SelectTextInput // When Select is disabled, we want to show a default cursor
|
|
26
|
+
// but not have disabled styling come from TextInput
|
|
27
|
+
// Disabled can be a bool or an array of options to disable.
|
|
28
|
+
// We only want to disable the TextInput if the control
|
|
29
|
+
// button should be disabled which occurs when disabled
|
|
30
|
+
// equals true.
|
|
31
|
+
, _extends({
|
|
32
|
+
defaultCursor: disabled === true || undefined,
|
|
33
|
+
focusIndicator: false,
|
|
34
|
+
id: id ? id + "__input" : undefined,
|
|
35
|
+
ref: ref
|
|
36
|
+
}, rest, {
|
|
37
|
+
tabIndex: "-1",
|
|
38
|
+
type: "text",
|
|
39
|
+
plain: true,
|
|
40
|
+
readOnly: true
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
exports.DefaultSelectTextInput = DefaultSelectTextInput;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.EmptySearchOption = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
|
|
8
|
+
var _Box = require("../Box");
|
|
9
|
+
|
|
10
|
+
var _Text = require("../Text");
|
|
11
|
+
|
|
12
|
+
var _StyledSelect = require("./StyledSelect");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
var EmptySearchOption = function EmptySearchOption(_ref) {
|
|
19
|
+
var emptySearchMessage = _ref.emptySearchMessage,
|
|
20
|
+
selectOptionsStyle = _ref.selectOptionsStyle,
|
|
21
|
+
theme = _ref.theme;
|
|
22
|
+
return /*#__PURE__*/_react["default"].createElement(_StyledSelect.SelectOption, {
|
|
23
|
+
key: "search_empty",
|
|
24
|
+
tabIndex: "0",
|
|
25
|
+
role: "menuitem",
|
|
26
|
+
hoverIndicator: "background",
|
|
27
|
+
disabled: true
|
|
28
|
+
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, selectOptionsStyle, /*#__PURE__*/_react["default"].createElement(_Text.Text, _extends({
|
|
29
|
+
"aria-live": "polite",
|
|
30
|
+
role: "alert"
|
|
31
|
+
}, theme.select.container.text), emptySearchMessage)));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.EmptySearchOption = EmptySearchOption;
|
|
@@ -5,7 +5,7 @@ exports.Select = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
|
-
var _styledComponents =
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
9
|
|
|
10
10
|
var _utils = require("../../utils");
|
|
11
11
|
|
|
@@ -13,18 +13,18 @@ var _defaultProps = require("../../default-props");
|
|
|
13
13
|
|
|
14
14
|
var _Box = require("../Box");
|
|
15
15
|
|
|
16
|
-
var _DropButton = require("../DropButton");
|
|
17
|
-
|
|
18
16
|
var _Keyboard = require("../Keyboard");
|
|
19
17
|
|
|
20
18
|
var _FormContext = require("../Form/FormContext");
|
|
21
19
|
|
|
22
|
-
var _TextInput = require("../TextInput");
|
|
23
|
-
|
|
24
20
|
var _SelectContainer = require("./SelectContainer");
|
|
25
21
|
|
|
22
|
+
var _StyledSelect = require("./StyledSelect");
|
|
23
|
+
|
|
26
24
|
var _utils2 = require("./utils");
|
|
27
25
|
|
|
26
|
+
var _DefaultSelectTextInput = require("./DefaultSelectTextInput");
|
|
27
|
+
|
|
28
28
|
var _MessageContext = require("../../contexts/MessageContext");
|
|
29
29
|
|
|
30
30
|
var _propTypes = require("./propTypes");
|
|
@@ -39,30 +39,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
39
39
|
|
|
40
40
|
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; }
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
componentId: "sc-17idtfo-0"
|
|
45
|
-
})(["cursor:", ";"], function (props) {
|
|
46
|
-
return props.defaultCursor ? 'default' : 'pointer';
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
var HiddenInput = _styledComponents["default"].input.withConfig({
|
|
50
|
-
displayName: "Select__HiddenInput",
|
|
51
|
-
componentId: "sc-17idtfo-1"
|
|
52
|
-
})(["display:none;"]);
|
|
53
|
-
|
|
54
|
-
var StyledSelectDropButton = (0, _styledComponents["default"])(_DropButton.DropButton).withConfig({
|
|
55
|
-
displayName: "Select__StyledSelectDropButton",
|
|
56
|
-
componentId: "sc-17idtfo-2"
|
|
57
|
-
})(["", ";", ";", ";"], function (props) {
|
|
58
|
-
return !props.callerPlain && _utils.controlBorderStyle;
|
|
59
|
-
}, function (props) {
|
|
60
|
-
return props.theme.select && props.theme.select.control && props.theme.select.control.extend;
|
|
61
|
-
}, function (props) {
|
|
62
|
-
return props.open && props.theme.select.control.open;
|
|
63
|
-
});
|
|
64
|
-
StyledSelectDropButton.defaultProps = {};
|
|
65
|
-
Object.setPrototypeOf(StyledSelectDropButton.defaultProps, _defaultProps.defaultProps);
|
|
42
|
+
_StyledSelect.StyledSelectDropButton.defaultProps = {};
|
|
43
|
+
Object.setPrototypeOf(_StyledSelect.StyledSelectDropButton.defaultProps, _defaultProps.defaultProps);
|
|
66
44
|
var defaultDropAlign = {
|
|
67
45
|
top: 'bottom',
|
|
68
46
|
left: 'left'
|
|
@@ -89,7 +67,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
89
67
|
gridArea = _ref.gridArea,
|
|
90
68
|
id = _ref.id,
|
|
91
69
|
icon = _ref.icon,
|
|
92
|
-
|
|
70
|
+
labelKeyProp = _ref.labelKey,
|
|
93
71
|
margin = _ref.margin,
|
|
94
72
|
messages = _ref.messages,
|
|
95
73
|
multiple = _ref.multiple,
|
|
@@ -112,7 +90,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
112
90
|
selected = _ref.selected,
|
|
113
91
|
size = _ref.size,
|
|
114
92
|
valueProp = _ref.value,
|
|
115
|
-
|
|
93
|
+
valueKeyProp = _ref.valueKey,
|
|
116
94
|
valueLabel = _ref.valueLabel,
|
|
117
95
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
118
96
|
|
|
@@ -122,11 +100,15 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
122
100
|
var formContext = (0, _react.useContext)(_FormContext.FormContext);
|
|
123
101
|
|
|
124
102
|
var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
|
|
125
|
-
format = _useContext.format; //
|
|
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,
|
|
126
109
|
// focus should be set on the first option when the drop opens
|
|
127
110
|
// see set initial focus code in SelectContainer.js
|
|
128
111
|
|
|
129
|
-
|
|
130
112
|
var usingKeyboard = (0, _utils.useKeyboard)(); // value is used for what we receive in valueProp and the basis for
|
|
131
113
|
// what we send with onChange
|
|
132
114
|
// When 'valueKey' sets 'reduce', the value(s) here should match
|
|
@@ -140,7 +122,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
140
122
|
initialValue: defaultValue || ''
|
|
141
123
|
}),
|
|
142
124
|
value = _formContext$useFormI[0],
|
|
143
|
-
setValue = _formContext$useFormI[1]; //
|
|
125
|
+
setValue = _formContext$useFormI[1]; // normalizedValue is the value mapped with any valueKey applied
|
|
144
126
|
// When the options array contains objects, this property indicates how
|
|
145
127
|
// to retrieve the value of each option.
|
|
146
128
|
// If a string is provided, it is used as the key to retrieve a
|
|
@@ -151,11 +133,8 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
151
133
|
// delivered via 'onChange'.
|
|
152
134
|
|
|
153
135
|
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
return valueKey && valueKey.reduce ? v : (0, _utils2.applyKey)(v, valueKey);
|
|
157
|
-
});
|
|
158
|
-
return valueKey && valueKey.reduce ? value : (0, _utils2.applyKey)(value, valueKey);
|
|
136
|
+
var normalizedValue = (0, _react.useMemo)(function () {
|
|
137
|
+
return (0, _utils2.getNormalizedValue)(value, valueKey);
|
|
159
138
|
}, [value, valueKey]); // search input value
|
|
160
139
|
|
|
161
140
|
var _useState = (0, _react.useState)(),
|
|
@@ -183,18 +162,18 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
183
162
|
} else if (index === selected) {
|
|
184
163
|
result.push(index);
|
|
185
164
|
}
|
|
186
|
-
} else if (Array.isArray(
|
|
187
|
-
if (
|
|
165
|
+
} else if (Array.isArray(normalizedValue)) {
|
|
166
|
+
if (normalizedValue.some(function (v) {
|
|
188
167
|
return v === (0, _utils2.applyKey)(option, valueKey);
|
|
189
168
|
})) {
|
|
190
169
|
result.push(index);
|
|
191
170
|
}
|
|
192
|
-
} else if (
|
|
171
|
+
} else if (normalizedValue === (0, _utils2.applyKey)(option, valueKey)) {
|
|
193
172
|
result.push(index);
|
|
194
173
|
}
|
|
195
174
|
});
|
|
196
175
|
return result;
|
|
197
|
-
}, [allOptions, selected, valueKey,
|
|
176
|
+
}, [allOptions, selected, valueKey, normalizedValue]);
|
|
198
177
|
|
|
199
178
|
var _useState3 = (0, _react.useState)(propOpen),
|
|
200
179
|
open = _useState3[0],
|
|
@@ -214,16 +193,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
214
193
|
setSearch();
|
|
215
194
|
}, [onClose]);
|
|
216
195
|
var triggerChangeEvent = (0, _react.useCallback)(function (nextValue) {
|
|
217
|
-
|
|
218
|
-
// overrides setter `event.target.value =` and loses original event
|
|
219
|
-
// target fidelity.
|
|
220
|
-
// https://stackoverflow.com/a/46012210
|
|
221
|
-
var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
222
|
-
nativeInputValueSetter.call(inputRef.current, nextValue);
|
|
223
|
-
var event = new Event('input', {
|
|
224
|
-
bubbles: true
|
|
225
|
-
});
|
|
226
|
-
inputRef.current.dispatchEvent(event);
|
|
196
|
+
return (0, _utils2.changeEvent)(inputRef, nextValue);
|
|
227
197
|
}, []);
|
|
228
198
|
var onSelectChange = (0, _react.useCallback)(function (event, _ref2) {
|
|
229
199
|
var option = _ref2.option,
|
|
@@ -233,7 +203,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
233
203
|
// input. if it is an object, then the user has not provided necessary
|
|
234
204
|
// props to reduce object option
|
|
235
205
|
|
|
236
|
-
if (typeof nextValue !== 'object' && nextValue !== event.target.value && inputRef.current) {
|
|
206
|
+
if ((typeof nextValue !== 'object' || multiple) && nextValue !== event.target.value && inputRef.current) {
|
|
237
207
|
// select registers changing option as a click event or keydown.
|
|
238
208
|
// when in a form, we need to programatically trigger a change
|
|
239
209
|
// event in order for the change event to be registered upstream
|
|
@@ -273,22 +243,8 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
273
243
|
|
|
274
244
|
onChange(adjustedEvent);
|
|
275
245
|
}
|
|
276
|
-
}, [closeOnChange, onChange, onRequestClose, setValue, triggerChangeEvent]);
|
|
277
|
-
var SelectIcon;
|
|
278
|
-
|
|
279
|
-
switch (icon) {
|
|
280
|
-
case false:
|
|
281
|
-
break;
|
|
282
|
-
|
|
283
|
-
case true:
|
|
284
|
-
case undefined:
|
|
285
|
-
SelectIcon = open && theme.select.icons.up ? theme.select.icons.up : theme.select.icons.down;
|
|
286
|
-
break;
|
|
287
|
-
|
|
288
|
-
default:
|
|
289
|
-
SelectIcon = icon;
|
|
290
|
-
} // element to show, trumps inputValue
|
|
291
|
-
|
|
246
|
+
}, [closeOnChange, multiple, onChange, onRequestClose, setValue, triggerChangeEvent]);
|
|
247
|
+
var SelectIcon = (0, _utils2.getSelectIcon)(icon, theme, open); // element to show, trumps inputValue
|
|
292
248
|
|
|
293
249
|
var selectValue = (0, _react.useMemo)(function () {
|
|
294
250
|
if (valueLabel instanceof Function) {
|
|
@@ -297,14 +253,9 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
297
253
|
|
|
298
254
|
|
|
299
255
|
return undefined;
|
|
300
|
-
}, [value, valueLabel]);
|
|
301
|
-
// we should use the labelKey function to display the
|
|
302
|
-
// selected value
|
|
303
|
-
|
|
256
|
+
}, [value, valueLabel]);
|
|
304
257
|
var displayLabelKey = (0, _react.useMemo)(function () {
|
|
305
|
-
|
|
306
|
-
if (!selectValue && optionIndexesInValue.length === 1 && typeof optionLabelKey === 'object') return optionLabelKey;
|
|
307
|
-
return undefined;
|
|
258
|
+
return (0, _utils2.getDisplayLabelKey)(labelKey, allOptions, optionIndexesInValue, selectValue);
|
|
308
259
|
}, [labelKey, allOptions, optionIndexesInValue, selectValue]); // text to show
|
|
309
260
|
// When the options array contains objects, this property indicates how
|
|
310
261
|
// to retrieve the value of each option.
|
|
@@ -327,11 +278,11 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
327
278
|
|
|
328
279
|
return undefined;
|
|
329
280
|
}, [labelKey, messages, format, optionIndexesInValue, allOptions, selectValue]);
|
|
330
|
-
var iconColor = (0,
|
|
281
|
+
var iconColor = (0, _utils2.getIconColor)(theme);
|
|
331
282
|
return /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
|
|
332
283
|
onDown: onRequestOpen,
|
|
333
284
|
onUp: onRequestOpen
|
|
334
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledSelectDropButton, {
|
|
285
|
+
}, /*#__PURE__*/_react["default"].createElement(_StyledSelect.StyledSelectDropButton, {
|
|
335
286
|
ref: ref,
|
|
336
287
|
a11yTitle: "" + (ariaLabel || a11yTitle || placeholder || 'Open Drop') + (value ? format({
|
|
337
288
|
id: 'select.selected',
|
|
@@ -383,7 +334,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
383
334
|
valueKey: valueKey
|
|
384
335
|
}, children) // StyledDropButton needs to know if the border should be shown
|
|
385
336
|
,
|
|
386
|
-
|
|
337
|
+
plainSelect: plain,
|
|
387
338
|
plain: true // Button should be plain
|
|
388
339
|
,
|
|
389
340
|
dropProps: dropProps,
|
|
@@ -397,36 +348,24 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
397
348
|
direction: "row",
|
|
398
349
|
flex: true,
|
|
399
350
|
basis: "auto"
|
|
400
|
-
}, selectValue || displayLabelKey ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, selectValue || displayLabelKey, /*#__PURE__*/_react["default"].createElement(HiddenInput, {
|
|
351
|
+
}, selectValue || displayLabelKey ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, selectValue || displayLabelKey, /*#__PURE__*/_react["default"].createElement(_StyledSelect.HiddenInput, {
|
|
401
352
|
type: "text",
|
|
402
353
|
name: name,
|
|
403
354
|
id: id ? id + "__input" : undefined,
|
|
404
355
|
value: inputValue,
|
|
405
356
|
ref: inputRef,
|
|
406
357
|
readOnly: true
|
|
407
|
-
})) : /*#__PURE__*/_react["default"].createElement(
|
|
408
|
-
a11yTitle: (ariaLabel || a11yTitle) && "" + (ariaLabel || a11yTitle) + (value && typeof value === 'string' ? ", " + value : '')
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
// We only want to disable the TextInput if the control
|
|
412
|
-
// button should be disabled which occurs when disabled
|
|
413
|
-
// equals true.
|
|
414
|
-
,
|
|
415
|
-
defaultCursor: disabled === true || undefined,
|
|
416
|
-
focusIndicator: false,
|
|
417
|
-
id: id ? id + "__input" : undefined,
|
|
358
|
+
})) : /*#__PURE__*/_react["default"].createElement(_DefaultSelectTextInput.DefaultSelectTextInput, _extends({
|
|
359
|
+
a11yTitle: (ariaLabel || a11yTitle) && "" + (ariaLabel || a11yTitle) + (value && typeof value === 'string' ? ", " + value : ''),
|
|
360
|
+
disabled: disabled,
|
|
361
|
+
id: id,
|
|
418
362
|
name: name,
|
|
419
|
-
ref: inputRef
|
|
420
|
-
}, rest, {
|
|
421
|
-
tabIndex: "-1",
|
|
422
|
-
type: "text",
|
|
363
|
+
ref: inputRef,
|
|
423
364
|
placeholder: placeholder,
|
|
424
|
-
plain: true,
|
|
425
|
-
readOnly: true,
|
|
426
365
|
value: inputValue,
|
|
427
366
|
size: size,
|
|
428
367
|
theme: theme
|
|
429
|
-
}))), SelectIcon && /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
368
|
+
}, rest))), SelectIcon && /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
430
369
|
margin: theme.select.icons.margin,
|
|
431
370
|
flex: false,
|
|
432
371
|
style: {
|