grommet 2.34.2 → 2.35.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/components/CheckBox/CheckBox.js +1 -1
- package/components/CheckBox/StyledCheckBox.js +1 -1
- package/components/Data/Data.js +26 -8
- package/components/Data/DataForm.js +42 -83
- package/components/Data/index.d.ts +27 -3
- package/components/Data/propTypes.js +53 -2
- package/components/DataClearFilters/stories/Simple.js +45 -9
- package/components/DataFilter/DataFilter.js +1 -1
- package/components/DataFilters/DataFilters.js +22 -24
- package/components/DataFilters/index.d.ts +1 -1
- package/components/DataFilters/propTypes.js +1 -1
- package/components/DataSearch/DataSearch.js +54 -9
- package/components/DataSearch/index.d.ts +1 -0
- package/components/DataSearch/propTypes.js +2 -1
- package/components/DataSearch/stories/UpdateOnSubmit.js +42 -0
- package/components/DataSort/DataSort.js +6 -4
- package/components/DataSummary/DataSummary.js +12 -1
- package/components/DataSummary/index.d.ts +9 -1
- package/components/DataSummary/propTypes.js +7 -2
- package/components/DataTable/DataTable.js +14 -2
- package/components/DataTable/GroupedBody.js +1 -1
- package/components/DataTable/buildState.js +1 -1
- package/components/DataTableColumns/DataTableColumns.js +4 -3
- package/components/FormField/FormField.js +5 -20
- package/components/Grommet/index.d.ts +20 -1
- package/components/Grommet/propTypes.js +21 -2
- package/components/Image/stories/Fill.js +2 -1
- package/components/Image/stories/Fit.js +4 -2
- package/components/Image/stories/Opacity.js +14 -7
- package/components/Image/stories/Simple.js +2 -1
- package/components/RangeSelector/RangeSelector.js +15 -1
- package/components/SelectMultiple/SelectMultiple.js +48 -8
- package/components/SelectMultiple/SelectMultipleContainer.js +20 -3
- package/components/SelectMultiple/SelectMultipleValue.js +23 -4
- package/components/SelectMultiple/SelectionSummary.js +30 -3
- package/components/SelectMultiple/index.d.ts +17 -0
- package/components/SelectMultiple/propTypes.js +21 -2
- package/components/SelectMultiple/stories/CustomMessages.js +71 -0
- package/components/StarRating/StarRating.js +17 -6
- package/components/StarRating/index.d.ts +2 -2
- package/components/Tag/index.d.ts +2 -11
- package/components/Tag/propTypes.js +2 -5
- package/es6/components/CheckBox/CheckBox.js +1 -1
- package/es6/components/CheckBox/StyledCheckBox.js +1 -1
- package/es6/components/Data/Data.js +26 -8
- package/es6/components/Data/DataForm.js +43 -84
- package/es6/components/Data/index.d.ts +27 -3
- package/es6/components/Data/propTypes.js +53 -2
- package/es6/components/DataClearFilters/stories/Simple.js +46 -10
- package/es6/components/DataFilter/DataFilter.js +1 -1
- package/es6/components/DataFilters/DataFilters.js +22 -24
- package/es6/components/DataFilters/index.d.ts +1 -1
- package/es6/components/DataFilters/propTypes.js +1 -1
- package/es6/components/DataSearch/DataSearch.js +54 -9
- package/es6/components/DataSearch/index.d.ts +1 -0
- package/es6/components/DataSearch/propTypes.js +2 -1
- package/es6/components/DataSearch/stories/UpdateOnSubmit.js +37 -0
- package/es6/components/DataSort/DataSort.js +6 -4
- package/es6/components/DataSummary/DataSummary.js +12 -1
- package/es6/components/DataSummary/index.d.ts +9 -1
- package/es6/components/DataSummary/propTypes.js +7 -2
- package/es6/components/DataTable/DataTable.js +14 -2
- package/es6/components/DataTable/GroupedBody.js +1 -1
- package/es6/components/DataTable/buildState.js +1 -1
- package/es6/components/DataTableColumns/DataTableColumns.js +4 -3
- package/es6/components/FormField/FormField.js +5 -20
- package/es6/components/Grommet/index.d.ts +20 -1
- package/es6/components/Grommet/propTypes.js +21 -2
- package/es6/components/Image/stories/Fill.js +2 -1
- package/es6/components/Image/stories/Fit.js +4 -2
- package/es6/components/Image/stories/Opacity.js +14 -7
- package/es6/components/Image/stories/Simple.js +2 -1
- package/es6/components/RangeSelector/RangeSelector.js +15 -1
- package/es6/components/SelectMultiple/SelectMultiple.js +48 -8
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +20 -3
- package/es6/components/SelectMultiple/SelectMultipleValue.js +24 -5
- package/es6/components/SelectMultiple/SelectionSummary.js +31 -4
- package/es6/components/SelectMultiple/index.d.ts +17 -0
- package/es6/components/SelectMultiple/propTypes.js +21 -2
- package/es6/components/SelectMultiple/stories/CustomMessages.js +65 -0
- package/es6/components/StarRating/StarRating.js +18 -7
- package/es6/components/StarRating/index.d.ts +2 -2
- package/es6/components/Tag/index.d.ts +2 -11
- package/es6/components/Tag/propTypes.js +2 -5
- package/es6/languages/default.json +17 -1
- package/es6/themes/base.js +3 -12
- package/es6/utils/use-debounce.js +21 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +17 -1
- package/package.json +10 -10
- package/themes/base.js +3 -12
- package/utils/use-debounce.js +25 -0
|
@@ -141,6 +141,17 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
141
141
|
useEffect(function () {
|
|
142
142
|
if (!search) setAllOptions(optionsProp);
|
|
143
143
|
}, [optionsProp, search]);
|
|
144
|
+
useEffect(function () {
|
|
145
|
+
if (search && optionsProp && optionsProp.length > 0) {
|
|
146
|
+
var additionalOptions = [].concat(allOptions);
|
|
147
|
+
optionsProp.forEach(function (i) {
|
|
148
|
+
return !additionalOptions.some(function (j) {
|
|
149
|
+
return typeof i === 'object' ? applyKey(i, valueKey) === applyKey(j, valueKey) : i === j;
|
|
150
|
+
}) && additionalOptions.push(i);
|
|
151
|
+
});
|
|
152
|
+
if (allOptions.length !== additionalOptions.length) setAllOptions(additionalOptions);
|
|
153
|
+
}
|
|
154
|
+
}, [allOptions, optionsProp, search, valueKey]);
|
|
144
155
|
useEffect(function () {
|
|
145
156
|
if (sortSelectedOnClose) setOrderedOptions(optionsProp);
|
|
146
157
|
}, [optionsProp, sortSelectedOnClose]);
|
|
@@ -245,6 +256,7 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
245
256
|
disabledKey: disabledKey,
|
|
246
257
|
dropButtonRef: dropButtonRef,
|
|
247
258
|
labelKey: labelKey,
|
|
259
|
+
messages: messages,
|
|
248
260
|
onRequestOpen: onRequestOpen,
|
|
249
261
|
onSelectChange: onSelectChange,
|
|
250
262
|
theme: theme,
|
|
@@ -253,7 +265,7 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
253
265
|
}, children);
|
|
254
266
|
}
|
|
255
267
|
return result;
|
|
256
|
-
}, [
|
|
268
|
+
}, [allOptions, children, disabled, disabledKey, dropButtonRef, labelKey, messages, onRequestOpen, onSelectChange, showSelectedInline, theme, value, valueKey, valueLabel]);
|
|
257
269
|
var displayLabelKey = useMemo(function () {
|
|
258
270
|
return getDisplayLabelKey(labelKey, allOptions, optionIndexesInValue, selectValue);
|
|
259
271
|
}, [labelKey, allOptions, optionIndexesInValue, selectValue]);
|
|
@@ -271,14 +283,24 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
271
283
|
if (!selectValue) {
|
|
272
284
|
if (optionIndexesInValue.length === 0) return '';
|
|
273
285
|
if (optionIndexesInValue.length === 1) return applyKey(allOptions[optionIndexesInValue[0]], labelKey);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
// keeping messages.multiple for backwards compatibility
|
|
287
|
+
if (messages != null && messages.multiple && !messages.summarizedValue) {
|
|
288
|
+
return format({
|
|
289
|
+
id: 'select.multiple',
|
|
290
|
+
messages: messages
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return format({
|
|
294
|
+
id: 'selectMultiple.summarizedValue',
|
|
295
|
+
messages: messages,
|
|
296
|
+
values: {
|
|
297
|
+
selected: optionIndexesInValue.length,
|
|
298
|
+
total: allOptions.length
|
|
299
|
+
}
|
|
277
300
|
});
|
|
278
|
-
return optionIndexesInValue.length + " selected";
|
|
279
301
|
}
|
|
280
302
|
return undefined;
|
|
281
|
-
}, [
|
|
303
|
+
}, [selectValue, optionIndexesInValue, allOptions, labelKey, format, messages]);
|
|
282
304
|
var iconColor = getIconColor(theme);
|
|
283
305
|
var displaySelectIcon = SelectIcon && /*#__PURE__*/React.createElement(Box, {
|
|
284
306
|
alignSelf: "center",
|
|
@@ -301,6 +323,7 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
301
323
|
id: id,
|
|
302
324
|
labelKey: labelKey,
|
|
303
325
|
limit: limit,
|
|
326
|
+
messages: messages,
|
|
304
327
|
onChange: onSelectChange,
|
|
305
328
|
onClose: onRequestClose,
|
|
306
329
|
onKeyDown: onKeyDown,
|
|
@@ -319,7 +342,16 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
319
342
|
}, children);
|
|
320
343
|
var dropButtonProps = {
|
|
321
344
|
ref: dropButtonRef,
|
|
322
|
-
a11yTitle: (ariaLabel || a11yTitle || placeholder ||
|
|
345
|
+
a11yTitle: (ariaLabel || a11yTitle || placeholder || format({
|
|
346
|
+
id: 'selectMultiple.open',
|
|
347
|
+
messages: messages
|
|
348
|
+
})) + ". " + format({
|
|
349
|
+
id: 'selectMultiple.selected',
|
|
350
|
+
values: {
|
|
351
|
+
selected: (value == null ? void 0 : value.length) || 0,
|
|
352
|
+
total: allOptions.length
|
|
353
|
+
}
|
|
354
|
+
}),
|
|
323
355
|
'aria-expanded': Boolean(open),
|
|
324
356
|
'aria-haspopup': 'listbox',
|
|
325
357
|
id: id,
|
|
@@ -375,7 +407,15 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
375
407
|
type: "text",
|
|
376
408
|
placeholder:
|
|
377
409
|
// eslint-disable-next-line no-nested-ternary
|
|
378
|
-
!value || (value == null ? void 0 : value.length) === 0 ? placeholder || selectValue || displayLabelKey :
|
|
410
|
+
!value || (value == null ? void 0 : value.length) === 0 ? placeholder || selectValue || displayLabelKey : format({
|
|
411
|
+
id: onMore ? 'selectMultiple.selected' : 'selectMultiple.selectedOfTotal',
|
|
412
|
+
messages: messages,
|
|
413
|
+
values: _extends({
|
|
414
|
+
selected: (value == null ? void 0 : value.length) || 0
|
|
415
|
+
}, !onMore ? {
|
|
416
|
+
total: allOptions.length
|
|
417
|
+
} : {})
|
|
418
|
+
}),
|
|
379
419
|
plain: true,
|
|
380
420
|
readOnly: true,
|
|
381
421
|
value: "",
|
|
@@ -14,6 +14,7 @@ import { SelectionSummary } from './SelectionSummary';
|
|
|
14
14
|
import { StyledContainer, OptionsContainer, SelectOption } from '../Select/StyledSelect';
|
|
15
15
|
import { applyKey, getOptionLabel, getOptionValue, useDisabled, getOptionIndex, arrayIncludes } from '../Select/utils';
|
|
16
16
|
import { EmptySearchOption } from '../Select/EmptySearchOption';
|
|
17
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
17
18
|
var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
18
19
|
var _optionsRef$current;
|
|
19
20
|
var allOptions = _ref.allOptions,
|
|
@@ -29,6 +30,7 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
29
30
|
id = _ref.id,
|
|
30
31
|
labelKey = _ref.labelKey,
|
|
31
32
|
limit = _ref.limit,
|
|
33
|
+
messages = _ref.messages,
|
|
32
34
|
onChange = _ref.onChange,
|
|
33
35
|
onClose = _ref.onClose,
|
|
34
36
|
onKeyDown = _ref.onKeyDown,
|
|
@@ -53,6 +55,8 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
53
55
|
var _useState2 = useState(usingKeyboard),
|
|
54
56
|
keyboardNavigation = _useState2[0],
|
|
55
57
|
setKeyboardNavigation = _useState2[1];
|
|
58
|
+
var _useContext = useContext(MessageContext),
|
|
59
|
+
format = _useContext.format;
|
|
56
60
|
var searchRef = useRef();
|
|
57
61
|
var optionsRef = useRef();
|
|
58
62
|
var _useState3 = useState(disabledProp),
|
|
@@ -249,6 +253,7 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
249
253
|
isSelected: isSelected,
|
|
250
254
|
labelKey: labelKey,
|
|
251
255
|
limit: limit,
|
|
256
|
+
messages: messages,
|
|
252
257
|
onChange: onChange,
|
|
253
258
|
onMore: onMore,
|
|
254
259
|
options: options,
|
|
@@ -290,7 +295,10 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
290
295
|
as: Box,
|
|
291
296
|
id: id ? id + "__select-drop" : undefined,
|
|
292
297
|
dropHeight: dropHeight,
|
|
293
|
-
a11yTitle:
|
|
298
|
+
a11yTitle: format({
|
|
299
|
+
id: 'selectMultiple.selectDrop',
|
|
300
|
+
messages: messages
|
|
301
|
+
})
|
|
294
302
|
}, summaryContent, onSearch && /*#__PURE__*/React.createElement(Box, {
|
|
295
303
|
pad: !customSearchInput ? 'xsmall' : undefined,
|
|
296
304
|
flex: false
|
|
@@ -299,7 +307,10 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
299
307
|
onNextOption(event);
|
|
300
308
|
}
|
|
301
309
|
}, /*#__PURE__*/React.createElement(SelectTextInput, {
|
|
302
|
-
a11yTitle:
|
|
310
|
+
a11yTitle: format({
|
|
311
|
+
id: 'selectMultiple.search',
|
|
312
|
+
messages: messages
|
|
313
|
+
}),
|
|
303
314
|
focusIndicator: !customSearchInput,
|
|
304
315
|
size: "small",
|
|
305
316
|
ref: searchRef,
|
|
@@ -383,7 +394,13 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
383
394
|
|
|
384
395
|
// if we have a child, turn on plain, and hoverIndicator
|
|
385
396
|
return /*#__PURE__*/React.createElement(SelectOption, {
|
|
386
|
-
a11yTitle:
|
|
397
|
+
a11yTitle: format({
|
|
398
|
+
id: optionSelected ? 'selectMultiple.optionSelected' : 'selectMultiple.optionNotSelected',
|
|
399
|
+
messages: messages,
|
|
400
|
+
values: {
|
|
401
|
+
optionLabel: optionLabel
|
|
402
|
+
}
|
|
403
|
+
})
|
|
387
404
|
// eslint-disable-next-line react/no-array-index-key
|
|
388
405
|
,
|
|
389
406
|
key: index
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
|
2
2
|
import { Box } from '../Box';
|
|
3
3
|
import { Button } from '../Button';
|
|
4
4
|
import { CheckBox } from '../CheckBox';
|
|
5
5
|
import { SelectOption } from '../Select/StyledSelect';
|
|
6
6
|
import { applyKey, getOptionLabel, useDisabled, arrayIncludes, getOptionIndex } from '../Select/utils';
|
|
7
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
7
8
|
var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
8
9
|
var allOptions = _ref.allOptions,
|
|
9
10
|
children = _ref.children,
|
|
@@ -11,6 +12,7 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
11
12
|
disabledKey = _ref.disabledKey,
|
|
12
13
|
dropButtonRef = _ref.dropButtonRef,
|
|
13
14
|
labelKey = _ref.labelKey,
|
|
15
|
+
messages = _ref.messages,
|
|
14
16
|
onRequestOpen = _ref.onRequestOpen,
|
|
15
17
|
onSelectChange = _ref.onSelectChange,
|
|
16
18
|
theme = _ref.theme,
|
|
@@ -19,6 +21,8 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
19
21
|
var _useState = useState(false),
|
|
20
22
|
showA11yDiv = _useState[0],
|
|
21
23
|
setShowA11yDiv = _useState[1];
|
|
24
|
+
var _useContext = useContext(MessageContext),
|
|
25
|
+
format = _useContext.format;
|
|
22
26
|
var isDisabled = useDisabled(disabled, disabledKey, allOptions, valueKey || labelKey);
|
|
23
27
|
var visibleValue = useCallback(function (i) {
|
|
24
28
|
var optionValue = valueKey && valueKey.reduce ? applyKey(i, valueKey) : i;
|
|
@@ -38,7 +42,13 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
38
42
|
}
|
|
39
43
|
return /*#__PURE__*/React.createElement(SelectOption, {
|
|
40
44
|
role: "option",
|
|
41
|
-
a11yTitle:
|
|
45
|
+
a11yTitle: format({
|
|
46
|
+
id: optionSelected ? 'selectMultiple.optionSelected' : 'selectMultiple.optionNotSelected',
|
|
47
|
+
messages: messages,
|
|
48
|
+
values: {
|
|
49
|
+
optionLabel: optionLabel
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
42
52
|
"aria-setsize": value.length,
|
|
43
53
|
"aria-posinset": valueIndex + 1,
|
|
44
54
|
"aria-selected": optionSelected,
|
|
@@ -94,7 +104,7 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
94
104
|
}));
|
|
95
105
|
}
|
|
96
106
|
return undefined;
|
|
97
|
-
}, [
|
|
107
|
+
}, [allOptions, children, dropButtonRef, format, isDisabled, labelKey, messages, onSelectChange, theme.selectMultiple.maxInline, value, valueKey]);
|
|
98
108
|
|
|
99
109
|
// After announcing set showA11yDiv to undefined so it won't
|
|
100
110
|
// be read out again
|
|
@@ -109,7 +119,10 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
109
119
|
width: "100%",
|
|
110
120
|
role: "listbox",
|
|
111
121
|
"aria-multiselectable": true,
|
|
112
|
-
a11yTitle:
|
|
122
|
+
a11yTitle: format({
|
|
123
|
+
id: 'selectMultiple.selectedOptions',
|
|
124
|
+
messages: messages
|
|
125
|
+
})
|
|
113
126
|
}, value && allOptions.filter(function (i) {
|
|
114
127
|
return arrayIncludes(value, valueKey && valueKey.reduce ? applyKey(i, valueKey) : i, valueKey || labelKey);
|
|
115
128
|
})
|
|
@@ -134,7 +147,13 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
134
147
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
135
148
|
onClick: onRequestOpen,
|
|
136
149
|
size: "small",
|
|
137
|
-
label:
|
|
150
|
+
label: format({
|
|
151
|
+
id: 'selectMultiple.showMore',
|
|
152
|
+
messages: messages,
|
|
153
|
+
values: {
|
|
154
|
+
remaining: value.length - theme.selectMultiple.maxInline
|
|
155
|
+
}
|
|
156
|
+
})
|
|
138
157
|
})));
|
|
139
158
|
};
|
|
140
159
|
export { SelectMultipleValue };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
2
|
import { Box } from '../Box';
|
|
3
3
|
import { Button } from '../Button';
|
|
4
4
|
import { Text } from '../Text';
|
|
5
5
|
import { applyKey, getOptionValue, useDisabled, arrayIncludes } from '../Select/utils';
|
|
6
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
6
7
|
var SelectionSummary = function SelectionSummary(_ref) {
|
|
7
8
|
var allOptions = _ref.allOptions,
|
|
8
9
|
clearRef = _ref.clearRef,
|
|
@@ -11,6 +12,7 @@ var SelectionSummary = function SelectionSummary(_ref) {
|
|
|
11
12
|
isSelected = _ref.isSelected,
|
|
12
13
|
labelKey = _ref.labelKey,
|
|
13
14
|
limit = _ref.limit,
|
|
15
|
+
messages = _ref.messages,
|
|
14
16
|
onChange = _ref.onChange,
|
|
15
17
|
onMore = _ref.onMore,
|
|
16
18
|
options = _ref.options,
|
|
@@ -19,6 +21,8 @@ var SelectionSummary = function SelectionSummary(_ref) {
|
|
|
19
21
|
showSelectedInline = _ref.showSelectedInline,
|
|
20
22
|
value = _ref.value,
|
|
21
23
|
valueKey = _ref.valueKey;
|
|
24
|
+
var _useContext = useContext(MessageContext),
|
|
25
|
+
format = _useContext.format;
|
|
22
26
|
var isDisabled = useDisabled(disabled, disabledKey, options, valueKey || labelKey);
|
|
23
27
|
var selectedValuesDisabled = useCallback(function () {
|
|
24
28
|
var disabledSelected = 0;
|
|
@@ -36,7 +40,15 @@ var SelectionSummary = function SelectionSummary(_ref) {
|
|
|
36
40
|
});
|
|
37
41
|
}, [options, value, valueKey, labelKey]);
|
|
38
42
|
var showSelectAll = !!((value == null ? void 0 : value.length) === 0 || selectedValuesDisabled() || !value || selectedInSearch().length === 0);
|
|
39
|
-
var
|
|
43
|
+
var messageId = (value == null ? void 0 : value.length) === 0 || onMore || !value || search !== '' && search !== undefined ? 'selectMultiple.selected' : 'selectMultiple.selectedOfTotal';
|
|
44
|
+
var summaryText = format({
|
|
45
|
+
id: messageId,
|
|
46
|
+
messages: messages,
|
|
47
|
+
values: {
|
|
48
|
+
selected: (value == null ? void 0 : value.length) || 0,
|
|
49
|
+
total: options.length
|
|
50
|
+
}
|
|
51
|
+
});
|
|
40
52
|
var summaryButtonClick = function summaryButtonClick(event) {
|
|
41
53
|
if (onChange) {
|
|
42
54
|
var nextSelected = options.filter(function (i, index) {
|
|
@@ -81,8 +93,23 @@ var SelectionSummary = function SelectionSummary(_ref) {
|
|
|
81
93
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
82
94
|
size: "small"
|
|
83
95
|
}, summaryText), (options.length && (!limit || !(!value || (value == null ? void 0 : value.length) === 0 && selectedValuesDisabled()))) > 0 && (!onMore || onMore && (value == null ? void 0 : value.length) !== 0) && /*#__PURE__*/React.createElement(Button, {
|
|
84
|
-
a11yTitle: showSelectAll ?
|
|
85
|
-
|
|
96
|
+
a11yTitle: showSelectAll ? format({
|
|
97
|
+
id: 'selectMultiple.selectAllA11y',
|
|
98
|
+
messages: messages,
|
|
99
|
+
values: {
|
|
100
|
+
total: options.length
|
|
101
|
+
}
|
|
102
|
+
}) : format({
|
|
103
|
+
id: 'selectMultiple.clearAllA11y',
|
|
104
|
+
messages: messages,
|
|
105
|
+
values: {
|
|
106
|
+
selected: (value == null ? void 0 : value.length) || 0
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
label: format({
|
|
110
|
+
id: showSelectAll ? 'selectMultiple.selectAll' : 'selectMultiple.clearAll',
|
|
111
|
+
messages: messages
|
|
112
|
+
}),
|
|
86
113
|
onClick: function onClick(event) {
|
|
87
114
|
return summaryButtonClick(event);
|
|
88
115
|
},
|
|
@@ -8,6 +8,23 @@ export interface SelectMultipleProps extends BasicSelectProps {
|
|
|
8
8
|
value?: (string | number | object)[];
|
|
9
9
|
showSelectedInline?: boolean;
|
|
10
10
|
sortSelectedOnClose?: boolean;
|
|
11
|
+
messages?: {
|
|
12
|
+
clearAll?: string;
|
|
13
|
+
clearAllA11y?: string;
|
|
14
|
+
multiple?: string; // kept for backwards compatibility, but summarizedValue should be used instead
|
|
15
|
+
open?: string;
|
|
16
|
+
optionNotSelected?: string;
|
|
17
|
+
optionSelected?: string;
|
|
18
|
+
search?: string;
|
|
19
|
+
selectAll?: string;
|
|
20
|
+
selectAllA11y?: string;
|
|
21
|
+
selectDrop?: string;
|
|
22
|
+
selected?: string;
|
|
23
|
+
selectedOfTotal?: string;
|
|
24
|
+
selectedOptions?: string;
|
|
25
|
+
showMore?: string;
|
|
26
|
+
summarizedValue?: string;
|
|
27
|
+
};
|
|
11
28
|
}
|
|
12
29
|
|
|
13
30
|
// Try without Omit<> to see where we define our own attributes for overrides
|
|
@@ -7,9 +7,28 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
7
7
|
defaultValue: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])),
|
|
8
8
|
help: PropTypes.node,
|
|
9
9
|
limit: PropTypes.number,
|
|
10
|
-
|
|
10
|
+
messages: PropTypes.shape({
|
|
11
|
+
clearAll: PropTypes.string,
|
|
12
|
+
clearAllA11y: PropTypes.string,
|
|
13
|
+
// "multiple" kept for backwards compatibility,
|
|
14
|
+
// but summarizedValue should be used instead
|
|
15
|
+
multiple: PropTypes.string,
|
|
16
|
+
open: PropTypes.string,
|
|
17
|
+
optionNotSelected: PropTypes.string,
|
|
18
|
+
optionSelected: PropTypes.string,
|
|
19
|
+
search: PropTypes.string,
|
|
20
|
+
selectAll: PropTypes.string,
|
|
21
|
+
selectAllA11y: PropTypes.string,
|
|
22
|
+
selectDrop: PropTypes.string,
|
|
23
|
+
selected: PropTypes.string,
|
|
24
|
+
selectedOfTotal: PropTypes.string,
|
|
25
|
+
selectedOptions: PropTypes.string,
|
|
26
|
+
showMore: PropTypes.string,
|
|
27
|
+
summarizedValue: PropTypes.string
|
|
28
|
+
}),
|
|
11
29
|
showSelectedInline: PropTypes.bool,
|
|
12
|
-
sortSelectedOnClose: PropTypes.bool
|
|
30
|
+
sortSelectedOnClose: PropTypes.bool,
|
|
31
|
+
value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number]))
|
|
13
32
|
});
|
|
14
33
|
}
|
|
15
34
|
export var SelectMultiplePropTypes = PropType;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Text } from 'grommet';
|
|
3
|
+
import { SelectMultiple } from '../SelectMultiple';
|
|
4
|
+
var defaultOptions = ['Apple', 'Orange', 'Banana', 'Grape', 'Melon', 'Strawberry', 'Kiwi', 'Mango', 'Raspberry', 'Rhubarb'];
|
|
5
|
+
export var CustomMessages = function CustomMessages() {
|
|
6
|
+
var _useState = useState(defaultOptions),
|
|
7
|
+
options = _useState[0],
|
|
8
|
+
setOptions = _useState[1];
|
|
9
|
+
var _useState2 = useState([]),
|
|
10
|
+
valueMultiple = _useState2[0],
|
|
11
|
+
setValueMultiple = _useState2[1];
|
|
12
|
+
return (
|
|
13
|
+
/*#__PURE__*/
|
|
14
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
15
|
+
// <Grommet theme={...}>
|
|
16
|
+
React.createElement(Box, {
|
|
17
|
+
fill: true,
|
|
18
|
+
align: "center",
|
|
19
|
+
pad: "large",
|
|
20
|
+
gap: "large"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Text, null, "SelectMultiple Custom messages"), /*#__PURE__*/React.createElement(SelectMultiple, {
|
|
22
|
+
value: valueMultiple,
|
|
23
|
+
placeholder: "Select",
|
|
24
|
+
options: options,
|
|
25
|
+
onSearch: function onSearch(text) {
|
|
26
|
+
// The line below escapes regular expression special characters:
|
|
27
|
+
// [ \ ^ $ . | ? * + ( )
|
|
28
|
+
var escapedText = text.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
29
|
+
|
|
30
|
+
// Create the regular expression with modified value which
|
|
31
|
+
// handles escaping special characters. Without escaping special
|
|
32
|
+
// characters, errors will appear in the console
|
|
33
|
+
var exp = new RegExp(escapedText, 'i');
|
|
34
|
+
setOptions(defaultOptions.filter(function (o) {
|
|
35
|
+
return exp.test(o);
|
|
36
|
+
}));
|
|
37
|
+
},
|
|
38
|
+
onClose: function onClose() {
|
|
39
|
+
return setOptions(defaultOptions);
|
|
40
|
+
},
|
|
41
|
+
onChange: function onChange(_ref) {
|
|
42
|
+
var value = _ref.value;
|
|
43
|
+
setValueMultiple(value);
|
|
44
|
+
},
|
|
45
|
+
messages: {
|
|
46
|
+
clearAll: 'Clear ALL!',
|
|
47
|
+
selectAll: 'Select ALL!',
|
|
48
|
+
selected: '{selected} SELECTED',
|
|
49
|
+
summarizedValue: '{selected} of {total} SELECTED'
|
|
50
|
+
}
|
|
51
|
+
}))
|
|
52
|
+
// </Grommet>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
CustomMessages.parameters = {
|
|
56
|
+
chromatic: {
|
|
57
|
+
disable: true
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
CustomMessages.args = {
|
|
61
|
+
full: true
|
|
62
|
+
};
|
|
63
|
+
export default {
|
|
64
|
+
title: 'Input/SelectMultiple/CustomMessages'
|
|
65
|
+
};
|
|
@@ -1,25 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["name", "defaultValue", "value"];
|
|
2
2
|
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); }
|
|
3
|
-
|
|
3
|
+
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; }
|
|
4
|
+
import React, { useContext } from 'react';
|
|
4
5
|
import { ThemeContext } from 'styled-components';
|
|
5
6
|
import { Star } from 'grommet-icons/icons/Star';
|
|
6
7
|
import { StarOutline } from 'grommet-icons/icons/StarOutline';
|
|
8
|
+
import { FormContext } from '../Form/FormContext';
|
|
7
9
|
import { RadioButtonGroup } from '../RadioButtonGroup';
|
|
8
10
|
var StarRating = function StarRating(_ref) {
|
|
9
|
-
var
|
|
11
|
+
var name = _ref.name,
|
|
12
|
+
defaultValue = _ref.defaultValue,
|
|
13
|
+
valueProp = _ref.value,
|
|
14
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
|
+
var formContext = useContext(FormContext);
|
|
10
16
|
var theme = useContext(ThemeContext);
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
var _formContext$useFormI = formContext.useFormInput({
|
|
18
|
+
name: name,
|
|
19
|
+
value: valueProp,
|
|
20
|
+
initialValue: defaultValue != null ? defaultValue : 0
|
|
21
|
+
}),
|
|
22
|
+
value = _formContext$useFormI[0],
|
|
23
|
+
setValue = _formContext$useFormI[1];
|
|
14
24
|
var options = [];
|
|
15
25
|
for (var i = 1; i < 6; i += 1) {
|
|
16
26
|
options.push(i);
|
|
17
27
|
}
|
|
18
28
|
return /*#__PURE__*/React.createElement(RadioButtonGroup, _extends({
|
|
29
|
+
name: name,
|
|
19
30
|
direction: "row",
|
|
20
31
|
options: options,
|
|
21
32
|
onChange: function onChange(event) {
|
|
22
|
-
setValue(event.
|
|
33
|
+
setValue(event.value);
|
|
23
34
|
}
|
|
24
35
|
}, rest), function (option) {
|
|
25
36
|
var _theme$starRating, _theme$starRating2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RadioButtonGroupExtendedProps } from '../RadioButtonGroup/index';
|
|
3
3
|
|
|
4
|
-
type RadioButtonGroup = Omit<
|
|
4
|
+
type RadioButtonGroup = Omit<RadioButtonGroupExtendedProps, 'options'>;
|
|
5
5
|
declare const StarRating: React.FC<RadioButtonGroup>;
|
|
6
6
|
|
|
7
7
|
export { StarRating };
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
A11yTitleType,
|
|
4
|
-
AlignSelfType,
|
|
5
|
-
GridAreaType,
|
|
6
|
-
PolymorphicType,
|
|
7
|
-
} from '../../utils';
|
|
2
|
+
import { BoxProps } from '../Box';
|
|
8
3
|
|
|
9
4
|
export interface TagProps {
|
|
10
|
-
a11yTitle?: A11yTitleType;
|
|
11
|
-
alignSelf?: AlignSelfType;
|
|
12
|
-
as?: PolymorphicType;
|
|
13
|
-
gridArea?: GridAreaType;
|
|
14
5
|
name?: string;
|
|
15
6
|
onClick?: (...args: any[]) => any;
|
|
16
7
|
onRemove?: (...args: any[]) => any;
|
|
@@ -25,7 +16,7 @@ export interface TagProps {
|
|
|
25
16
|
value: string | number;
|
|
26
17
|
}
|
|
27
18
|
|
|
28
|
-
export interface TagExtendedProps extends TagProps {}
|
|
19
|
+
export interface TagExtendedProps extends BoxProps, TagProps {}
|
|
29
20
|
|
|
30
21
|
// Keep type alias for backwards compatibility.
|
|
31
22
|
export type TagType = TagProps;
|
|
@@ -1,15 +1,12 @@
|
|
|
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
1
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { genericProps } from '../../utils/general-prop-types';
|
|
4
2
|
var PropType = {};
|
|
5
3
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
|
-
PropType =
|
|
7
|
-
as: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
4
|
+
PropType = {
|
|
8
5
|
name: PropTypes.string,
|
|
9
6
|
value: PropTypes.string.isRequired,
|
|
10
7
|
onClick: PropTypes.func,
|
|
11
8
|
onRemove: PropTypes.func,
|
|
12
9
|
size: PropTypes.oneOfType([PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge']), PropTypes.string])
|
|
13
|
-
}
|
|
10
|
+
};
|
|
14
11
|
}
|
|
15
12
|
export var TagPropTypes = PropType;
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dataForm": {
|
|
32
|
-
"reset": "Undo changes",
|
|
33
32
|
"submit": "Apply filters"
|
|
34
33
|
},
|
|
35
34
|
"dataSearch": {
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
"filteredSingle": "{filteredTotal} result of {total} {items}",
|
|
49
48
|
"items": "items",
|
|
50
49
|
"itemsSingle": "item",
|
|
50
|
+
"selected": "{selected} selected",
|
|
51
51
|
"total": "{total} {items}",
|
|
52
52
|
"totalSingle": "{total} {items}"
|
|
53
53
|
},
|
|
@@ -94,6 +94,22 @@
|
|
|
94
94
|
"multiple": "multiple",
|
|
95
95
|
"selected": "; Selected: {currentSelectedValue}"
|
|
96
96
|
},
|
|
97
|
+
"selectMultiple": {
|
|
98
|
+
"clearAll": "Clear All",
|
|
99
|
+
"clearAllA11y": "{selected} options selected. Clear all?",
|
|
100
|
+
"open": "Open drop",
|
|
101
|
+
"optionNotSelected": "{optionLabel} not selected",
|
|
102
|
+
"optionSelected": "{optionLabel} selected",
|
|
103
|
+
"search": "Search to filter options",
|
|
104
|
+
"selectAll": "Select All",
|
|
105
|
+
"selectAllA11y": "Select all {total} options",
|
|
106
|
+
"selectDrop": "Select dropdown",
|
|
107
|
+
"selected": "{selected} selected",
|
|
108
|
+
"selectedOfTotal": "{selected} selected of {total}",
|
|
109
|
+
"selectedOptions": "Selected options",
|
|
110
|
+
"showMore": "+ {remaining} more",
|
|
111
|
+
"summarizedValue": "{selected} selected"
|
|
112
|
+
},
|
|
97
113
|
"skipLinks": {
|
|
98
114
|
"skipTo": "Skip To:"
|
|
99
115
|
},
|
package/es6/themes/base.js
CHANGED
|
@@ -879,18 +879,9 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
879
879
|
// extend: undefined,
|
|
880
880
|
},
|
|
881
881
|
groupHeader: {
|
|
882
|
-
background:
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
},
|
|
886
|
-
border: {
|
|
887
|
-
side: 'bottom',
|
|
888
|
-
size: 'xsmall'
|
|
889
|
-
},
|
|
890
|
-
pad: {
|
|
891
|
-
horizontal: 'small',
|
|
892
|
-
vertical: 'xsmall'
|
|
893
|
-
}
|
|
882
|
+
// background: undefined,
|
|
883
|
+
// border: undefined,
|
|
884
|
+
// pad: undefined,
|
|
894
885
|
},
|
|
895
886
|
groupEnd: {
|
|
896
887
|
border: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { ThemeContext } from 'styled-components';
|
|
3
|
+
import { defaultProps } from '../default-props';
|
|
4
|
+
export var useDebounce = function useDebounce(debounceDelay) {
|
|
5
|
+
var _useState = useState(),
|
|
6
|
+
func = _useState[0],
|
|
7
|
+
setFunc = _useState[1];
|
|
8
|
+
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
9
|
+
var delay = debounceDelay || theme.global.debounceDelay;
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
var timer;
|
|
12
|
+
if (func) timer = setTimeout(function () {
|
|
13
|
+
return func();
|
|
14
|
+
}, delay);
|
|
15
|
+
return function () {
|
|
16
|
+
return clearTimeout(timer);
|
|
17
|
+
};
|
|
18
|
+
}, [func, delay]);
|
|
19
|
+
return setFunc;
|
|
20
|
+
};
|
|
21
|
+
export default useDebounce;
|