grommet 2.40.2 → 2.42.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 (139) hide show
  1. package/components/AccordionPanel/AccordionPanel.js +1 -7
  2. package/components/Box/Box.js +1 -1
  3. package/components/Box/StyledBox.js +1 -6
  4. package/components/Box/index.d.ts +1 -0
  5. package/components/Box/propTypes.js +1 -0
  6. package/components/Button/Button.js +1 -0
  7. package/components/Button/StyledButton.js +3 -2
  8. package/components/Button/StyledButtonKind.js +12 -6
  9. package/components/Calendar/Calendar.js +90 -56
  10. package/components/Calendar/StyledCalendar.js +89 -7
  11. package/components/Calendar/utils.js +16 -2
  12. package/components/Carousel/Carousel.js +1 -1
  13. package/components/Chart/Chart.js +3 -3
  14. package/components/CheckBox/CheckBox.js +3 -2
  15. package/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
  16. package/components/Clock/Digital.js +1 -1
  17. package/components/Data/stories/Infinite.js +2 -2
  18. package/components/Data/stories/OnSelect.js +2 -2
  19. package/components/Data/stories/SpaceX.js +2 -2
  20. package/components/Data/stories/StarWars.js +1 -1
  21. package/components/DataChart/Detail.js +19 -4
  22. package/components/DataFilter/DataFilter.js +6 -1
  23. package/components/DataSort/DataSort.js +46 -14
  24. package/components/DataSort/stories/Simple.js +10 -1
  25. package/components/DataTable/Body.js +14 -8
  26. package/components/DataTable/GroupedBody.js +3 -3
  27. package/components/DataTable/buildState.js +5 -1
  28. package/components/DataTable/stories/SpaceX.js +2 -2
  29. package/components/DataTable/stories/SpaceXUngrouped.js +1 -1
  30. package/components/Drop/DropContainer.js +51 -3
  31. package/components/FileInput/index.d.ts +2 -3
  32. package/components/FocusedContainer.js +134 -17
  33. package/components/Grommet/Grommet.js +11 -5
  34. package/components/Layer/Layer.js +1 -1
  35. package/components/Layer/index.d.ts +2 -0
  36. package/components/List/List.js +18 -12
  37. package/components/MaskedInput/MaskedInput.js +3 -0
  38. package/components/Menu/Menu.js +3 -3
  39. package/components/Meter/Circle.js +2 -2
  40. package/components/Notification/Notification.js +18 -6
  41. package/components/Notification/index.d.ts +1 -0
  42. package/components/Notification/propTypes.js +1 -0
  43. package/components/Pagination/Pagination.js +4 -2
  44. package/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  45. package/components/Select/Select.js +29 -18
  46. package/components/Select/SelectContainer.js +41 -34
  47. package/components/Select/index.d.ts +1 -1
  48. package/components/Select/stories/ChildrenRender.js +7 -8
  49. package/components/Select/utils.js +13 -2
  50. package/components/SelectMultiple/SelectMultiple.js +18 -6
  51. package/components/SelectMultiple/SelectMultipleContainer.js +28 -2
  52. package/components/SelectMultiple/SelectMultipleValue.js +14 -1
  53. package/components/SkipLinks/index.d.ts +1 -0
  54. package/components/SkipLinks/propTypes.js +1 -0
  55. package/components/Tab/Tab.js +1 -1
  56. package/components/Tag/Tag.js +11 -7
  57. package/components/TextInput/TextInput.js +3 -0
  58. package/components/ToggleGroup/StyledToggleGroup.js +12 -5
  59. package/components/ToggleGroup/ToggleGroup.js +21 -10
  60. package/components/WorldMap/WorldMap.js +1 -1
  61. package/contexts/RootsContext.js +23 -5
  62. package/es6/components/AccordionPanel/AccordionPanel.js +2 -9
  63. package/es6/components/Box/Box.js +1 -1
  64. package/es6/components/Box/StyledBox.js +1 -6
  65. package/es6/components/Box/index.d.ts +1 -0
  66. package/es6/components/Box/propTypes.js +1 -0
  67. package/es6/components/Button/Button.js +1 -0
  68. package/es6/components/Button/StyledButton.js +4 -3
  69. package/es6/components/Button/StyledButtonKind.js +12 -6
  70. package/es6/components/Calendar/Calendar.js +89 -56
  71. package/es6/components/Calendar/StyledCalendar.js +90 -8
  72. package/es6/components/Calendar/utils.js +15 -1
  73. package/es6/components/Carousel/Carousel.js +1 -1
  74. package/es6/components/Chart/Chart.js +3 -3
  75. package/es6/components/CheckBox/CheckBox.js +3 -2
  76. package/es6/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
  77. package/es6/components/Clock/Digital.js +1 -1
  78. package/es6/components/Data/stories/Infinite.js +2 -2
  79. package/es6/components/Data/stories/OnSelect.js +2 -2
  80. package/es6/components/Data/stories/SpaceX.js +2 -2
  81. package/es6/components/Data/stories/StarWars.js +1 -1
  82. package/es6/components/DataChart/Detail.js +20 -5
  83. package/es6/components/DataFilter/DataFilter.js +6 -1
  84. package/es6/components/DataSort/DataSort.js +46 -14
  85. package/es6/components/DataSort/stories/Simple.js +10 -1
  86. package/es6/components/DataTable/Body.js +14 -8
  87. package/es6/components/DataTable/GroupedBody.js +3 -3
  88. package/es6/components/DataTable/buildState.js +5 -1
  89. package/es6/components/DataTable/stories/SpaceX.js +2 -2
  90. package/es6/components/DataTable/stories/SpaceXUngrouped.js +1 -1
  91. package/es6/components/Drop/DropContainer.js +51 -3
  92. package/es6/components/FileInput/index.d.ts +2 -3
  93. package/es6/components/FocusedContainer.js +136 -19
  94. package/es6/components/Grommet/Grommet.js +12 -6
  95. package/es6/components/Layer/Layer.js +1 -1
  96. package/es6/components/Layer/index.d.ts +2 -0
  97. package/es6/components/List/List.js +18 -12
  98. package/es6/components/MaskedInput/MaskedInput.js +3 -0
  99. package/es6/components/Menu/Menu.js +3 -3
  100. package/es6/components/Meter/Circle.js +2 -2
  101. package/es6/components/Notification/Notification.js +18 -6
  102. package/es6/components/Notification/index.d.ts +1 -0
  103. package/es6/components/Notification/propTypes.js +1 -0
  104. package/es6/components/Pagination/Pagination.js +4 -2
  105. package/es6/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  106. package/es6/components/Select/Select.js +30 -19
  107. package/es6/components/Select/SelectContainer.js +41 -34
  108. package/es6/components/Select/index.d.ts +1 -1
  109. package/es6/components/Select/stories/ChildrenRender.js +7 -8
  110. package/es6/components/Select/utils.js +15 -3
  111. package/es6/components/SelectMultiple/SelectMultiple.js +18 -6
  112. package/es6/components/SelectMultiple/SelectMultipleContainer.js +28 -2
  113. package/es6/components/SelectMultiple/SelectMultipleValue.js +14 -1
  114. package/es6/components/SkipLinks/index.d.ts +1 -0
  115. package/es6/components/SkipLinks/propTypes.js +1 -0
  116. package/es6/components/Tab/Tab.js +1 -1
  117. package/es6/components/Tag/Tag.js +11 -7
  118. package/es6/components/TextInput/TextInput.js +3 -0
  119. package/es6/components/ToggleGroup/StyledToggleGroup.js +12 -5
  120. package/es6/components/ToggleGroup/ToggleGroup.js +22 -11
  121. package/es6/components/WorldMap/WorldMap.js +1 -1
  122. package/es6/contexts/RootsContext.js +20 -3
  123. package/es6/themes/base.d.ts +205 -6
  124. package/es6/themes/base.js +166 -1
  125. package/es6/utils/DOM.js +2 -1
  126. package/es6/utils/background.js +1 -1
  127. package/es6/utils/index.js +2 -1
  128. package/es6/utils/styles.js +8 -0
  129. package/es6/utils/useId.js +16 -0
  130. package/grommet.min.js +1 -1
  131. package/grommet.min.js.map +1 -1
  132. package/package.json +40 -40
  133. package/themes/base.d.ts +205 -6
  134. package/themes/base.js +166 -1
  135. package/utils/DOM.js +2 -1
  136. package/utils/background.js +1 -1
  137. package/utils/index.js +6 -0
  138. package/utils/styles.js +9 -1
  139. package/utils/useId.js +19 -0
@@ -14,6 +14,8 @@ export type LayerPositionType =
14
14
  | 'hidden'
15
15
  | 'left'
16
16
  | 'right'
17
+ | 'start'
18
+ | 'end'
17
19
  | 'top'
18
20
  | 'top-left'
19
21
  | 'top-right';
@@ -258,22 +258,28 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
258
258
  return /*#__PURE__*/React.createElement(Container, containterProps, /*#__PURE__*/React.createElement(Keyboard, {
259
259
  onEnter: onSelectOption,
260
260
  onSpace: function onSpace(event) {
261
- event.preventDefault();
261
+ if (onClickItem || onOrder) {
262
+ event.preventDefault();
263
+ }
262
264
  onSelectOption(event);
263
265
  },
264
266
  onUp: function onUp(event) {
265
- event.preventDefault();
266
- if ((onClickItem || onOrder) && active) {
267
- var min = onOrder ? 1 : 0;
268
- updateActive(Math.max(active - 1, min));
267
+ if (onClickItem || onOrder) {
268
+ event.preventDefault();
269
+ if (active) {
270
+ var min = onOrder ? 1 : 0;
271
+ updateActive(Math.max(active - 1, min));
272
+ }
269
273
  }
270
274
  },
271
275
  onDown: function onDown(event) {
272
- event.preventDefault();
273
- if ((onClickItem || onOrder) && orderableData && orderableData.length) {
274
- var min = onOrder ? 1 : 0;
275
- var max = onOrder ? orderableData.length * 2 - 2 : data.length - 1;
276
- updateActive(active >= min ? Math.min(active + 1, max) : min);
276
+ if (onClickItem || onOrder) {
277
+ event.preventDefault();
278
+ if (orderableData && orderableData.length) {
279
+ var min = onOrder ? 1 : 0;
280
+ var max = onOrder ? orderableData.length * 2 - 2 : data.length - 1;
281
+ updateActive(active >= min ? Math.min(active + 1, max) : min);
282
+ }
277
283
  }
278
284
  },
279
285
  onKeyDown: onKeyDown
@@ -315,7 +321,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
315
321
  var isPinned;
316
322
  if (Array.isArray(pinned) && pinned.length > 0 || Array.isArray(pinned == null ? void 0 : pinned.items) && (pinned == null || (_pinned$items2 = pinned.items) == null ? void 0 : _pinned$items2.length) > 0) {
317
323
  if (typeof item === 'object' && !itemKey) {
318
- console.error( // eslint-disable-next-line max-len
324
+ console.error(// eslint-disable-next-line max-len
319
325
  "Warning: Missing prop itemKey. Prop pin requires itemKey to be specified when data is of type 'object'.");
320
326
  }
321
327
  isPinned = Array.isArray(pinned) ? pinned == null ? void 0 : pinned.includes(key) : pinned.items.some(function (pinnedItem) {
@@ -367,7 +373,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
367
373
  var isDisabled;
368
374
  if (disabledItems) {
369
375
  if (typeof item === 'object' && !itemKey) {
370
- console.error( // eslint-disable-next-line max-len
376
+ console.error(// eslint-disable-next-line max-len
371
377
  "Warning: Missing prop itemKey. Prop disabled requires itemKey to be specified when data is of type 'object'.");
372
378
  }
373
379
  isDisabled = disabledItems == null ? void 0 : disabledItems.includes(key);
@@ -380,6 +380,9 @@ var MaskedInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
380
380
  target: inputRef.current,
381
381
  onClickOutside: onHideDrop,
382
382
  onEsc: onHideDrop
383
+ // MaskedInput manages its own keyboard behavior via Keyboard
384
+ ,
385
+ trapFocus: false
383
386
  }, dropProps), /*#__PURE__*/React.createElement(ContainerBox, _extends({
384
387
  ref: dropRef,
385
388
  overflow: "auto",
@@ -390,14 +390,14 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
390
390
  ref: dropContainerRef,
391
391
  tabIndex: -1,
392
392
  background: dropBackground || theme.menu.background
393
- }, passThemeFlag), alignControlMirror === 'top' && align.top === 'top' ? controlMirror : undefined, /*#__PURE__*/React.createElement(Box, {
393
+ }, passThemeFlag), alignControlMirror === 'top' && align.bottom !== 'top' && align.top !== 'bottom' ? controlMirror : undefined, /*#__PURE__*/React.createElement(Box, {
394
394
  overflow: "auto",
395
395
  role: "menu",
396
396
  a11yTitle: a11y
397
- }, menuContent), !initialAlignTop && (
397
+ }, menuContent), !initialAlignTop &&
398
398
  // don't show controlMirror if caller is using
399
399
  // align.bottom === 'top'
400
- alignControlMirror === 'bottom' && !align.bottom === 'top' || align.bottom === 'bottom') ? controlMirror : undefined))
400
+ alignControlMirror === 'bottom' && align.bottom !== 'top' && align.top !== 'bottom' ? controlMirror : undefined))
401
401
  }), content));
402
402
  });
403
403
  Menu.displayName = 'Menu';
@@ -69,7 +69,7 @@ var Circle = /*#__PURE__*/forwardRef(function (props, ref) {
69
69
  var stroke = strokeProps(someHighlight && !highlight ? background : colorName, theme);
70
70
  if (round) {
71
71
  var d1 = arcCommands(centerX, centerY, radius, startAngle, endAngle);
72
- paths.unshift( /*#__PURE__*/React.createElement("path", _extends({
72
+ paths.unshift(/*#__PURE__*/React.createElement("path", _extends({
73
73
  key: key,
74
74
  d: d1,
75
75
  fill: "none"
@@ -98,7 +98,7 @@ var Circle = /*#__PURE__*/forwardRef(function (props, ref) {
98
98
  pathCaps.unshift(pathCap);
99
99
  } else {
100
100
  var d = arcCommands(centerX, centerY, radius, startAngle, endAngle);
101
- paths.push( /*#__PURE__*/React.createElement("path", _extends({
101
+ paths.push(/*#__PURE__*/React.createElement("path", _extends({
102
102
  key: key,
103
103
  d: d,
104
104
  fill: "none"
@@ -45,12 +45,18 @@ var adaptThemeStyle = function adaptThemeStyle(value, theme) {
45
45
  }
46
46
  return [textStyle, closeButtonStyle];
47
47
  };
48
+ var getTextColor = function getTextColor(part, status, kind, theme) {
49
+ var _theme$notification, _theme$notification2, _theme$notification3, _theme$notification4, _theme$notification5;
50
+ var color;
51
+ if ((_theme$notification = theme.notification) != null && (_theme$notification = _theme$notification[status]) != null && (_theme$notification = _theme$notification[kind]) != null && (_theme$notification = _theme$notification[part]) != null && _theme$notification.color) color = (_theme$notification2 = theme.notification) == null || (_theme$notification2 = _theme$notification2[status]) == null || (_theme$notification2 = _theme$notification2[kind]) == null || (_theme$notification2 = _theme$notification2[part]) == null ? void 0 : _theme$notification2.color;else if ((_theme$notification3 = theme.notification) != null && (_theme$notification3 = _theme$notification3[status]) != null && (_theme$notification3 = _theme$notification3[part]) != null && _theme$notification3.color) color = (_theme$notification4 = theme.notification) == null || (_theme$notification4 = _theme$notification4[status]) == null || (_theme$notification4 = _theme$notification4[part]) == null ? void 0 : _theme$notification4.color;else color = (_theme$notification5 = theme.notification) == null || (_theme$notification5 = _theme$notification5[part]) == null ? void 0 : _theme$notification5.color;
52
+ return color;
53
+ };
48
54
  var NotificationAnchor = styled(Anchor).withConfig({
49
55
  displayName: "Notification__NotificationAnchor",
50
56
  componentId: "sc-1yq09yz-0"
51
57
  })(["white-space:nowrap;"]);
52
58
  var Notification = function Notification(_ref) {
53
- var _theme$notification, _theme$notification2, _theme$notification3, _theme$notification4, _theme$notification5;
59
+ var _theme$notification6, _theme$notification7, _theme$notification8, _theme$notification9, _theme$notification10;
54
60
  var actionsProp = _ref.actions,
55
61
  messageProp = _ref.message,
56
62
  onClose = _ref.onClose,
@@ -87,7 +93,7 @@ var Notification = function Notification(_ref) {
87
93
  return undefined;
88
94
  }, [autoClose, close, theme.notification.toast.time, theme.notification.time, time]);
89
95
  var CloseIcon = theme.notification.close.icon;
90
- var _ref2 = ((_theme$notification = theme.notification) == null ? void 0 : _theme$notification[status]) || theme.notification.unknown,
96
+ var _ref2 = ((_theme$notification6 = theme.notification) == null ? void 0 : _theme$notification6[status]) || theme.notification.unknown,
91
97
  StatusIcon = _ref2.icon,
92
98
  color = _ref2.color;
93
99
  var closeIconColor = theme.notification.close.color;
@@ -99,7 +105,7 @@ var Notification = function Notification(_ref) {
99
105
  var direction;
100
106
  if (kind && theme.notification[kind].direction) direction = theme.notification[kind].direction;else direction = theme.notification.direction;
101
107
  var background;
102
- if (kind && (_theme$notification2 = theme.notification) != null && (_theme$notification2 = _theme$notification2[status]) != null && (_theme$notification2 = _theme$notification2[kind]) != null && _theme$notification2.background) background = theme.notification[status][kind].background;else if ((_theme$notification3 = theme.notification) != null && (_theme$notification3 = _theme$notification3[status]) != null && _theme$notification3.background) background = theme.notification[status].background;else background = ((_theme$notification4 = theme.notification) == null || (_theme$notification4 = _theme$notification4[kind]) == null || (_theme$notification4 = _theme$notification4.container) == null ? void 0 : _theme$notification4.background) || theme.notification.container.background;
108
+ if (kind && (_theme$notification7 = theme.notification) != null && (_theme$notification7 = _theme$notification7[status]) != null && (_theme$notification7 = _theme$notification7[kind]) != null && _theme$notification7.background) background = theme.notification[status][kind].background;else if ((_theme$notification8 = theme.notification) != null && (_theme$notification8 = _theme$notification8[status]) != null && _theme$notification8.background) background = theme.notification[status].background;else background = ((_theme$notification9 = theme.notification) == null || (_theme$notification9 = _theme$notification9[kind]) == null || (_theme$notification9 = _theme$notification9.container) == null ? void 0 : _theme$notification9.background) || theme.notification.container.background;
103
109
  var TextWrapper = direction === 'row' ? Text : Fragment;
104
110
 
105
111
  // notification is built with two child boxes that contain:
@@ -118,6 +124,8 @@ var Notification = function Notification(_ref) {
118
124
  } else textPad = pad;
119
125
  var actions;
120
126
  var message = messageProp;
127
+ var messageColor = getTextColor('message', status, kind, theme);
128
+ var titleColor = getTextColor('title', status, kind, theme);
121
129
  if (actionsProp) actions = actionsProp.map(function (action) {
122
130
  return /*#__PURE__*/React.createElement(Fragment, {
123
131
  key: action.label
@@ -131,12 +139,14 @@ var Notification = function Notification(_ref) {
131
139
  }, action, theme.notification.actions)), ' ');
132
140
  });
133
141
  var Message = direction !== 'row' ? Paragraph : Text;
134
- if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/React.createElement(Message, theme.notification.message, /*#__PURE__*/React.createElement(Text, {
142
+ if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/React.createElement(Message, _extends({}, theme.notification.message, {
143
+ color: messageColor
144
+ }), /*#__PURE__*/React.createElement(Text, {
135
145
  margin: {
136
146
  right: 'xsmall'
137
147
  }
138
148
  }, message), actions) : message;
139
- var iconDimension = ((_theme$notification5 = theme.notification) == null || (_theme$notification5 = _theme$notification5.message) == null ? void 0 : _theme$notification5.size) || 'medium';
149
+ var iconDimension = ((_theme$notification10 = theme.notification) == null || (_theme$notification10 = _theme$notification10.message) == null ? void 0 : _theme$notification10.size) || 'medium';
140
150
  var content = /*#__PURE__*/React.createElement(Box, _extends({}, theme.notification.container, global ? _extends({}, theme.notification.global.container) : {}, toast ? _extends({}, theme.notification.toast.container) : {}, {
141
151
  background: background
142
152
  // let internal box control pad
@@ -152,7 +162,9 @@ var Notification = function Notification(_ref) {
152
162
  }, /*#__PURE__*/React.createElement(Box, theme.notification.iconContainer, icon || /*#__PURE__*/React.createElement(StatusIcon, {
153
163
  color: color,
154
164
  height: iconDimension
155
- })), /*#__PURE__*/React.createElement(Box, theme.notification.textContainer, /*#__PURE__*/React.createElement(TextWrapper, null, title && /*#__PURE__*/React.createElement(Text, theme.notification.title, title), message && title && direction === 'row' && /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0"), message))), onClose &&
165
+ })), /*#__PURE__*/React.createElement(Box, theme.notification.textContainer, /*#__PURE__*/React.createElement(TextWrapper, null, title && /*#__PURE__*/React.createElement(Text, _extends({}, theme.notification.title, {
166
+ color: titleColor
167
+ }), title), message && title && direction === 'row' && /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0"), message))), onClose &&
156
168
  /*#__PURE__*/
157
169
  // theme.notification.container and textContainer may both have pad,
158
170
  // account for both
@@ -4,6 +4,7 @@ import { AnchorType } from '..';
4
4
  export type StatusType = 'critical' | 'warning' | 'normal' | 'info' | 'unknown';
5
5
 
6
6
  export interface NotificationProps {
7
+ id?: string;
7
8
  actions?: AnchorType[];
8
9
  global?: boolean;
9
10
  title?: string;
@@ -3,6 +3,7 @@ import { AnchorPropTypes } from '../Anchor/propTypes';
3
3
  var PropType = {};
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  PropType = {
6
+ id: PropTypes.string,
6
7
  actions: PropTypes.arrayOf(PropTypes.shape(AnchorPropTypes)),
7
8
  global: PropTypes.bool,
8
9
  title: PropTypes.string,
@@ -82,7 +82,7 @@ var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
82
82
  var numberMiddlePages;
83
83
  if (numberMiddlePagesProp < 1) {
84
84
  numberMiddlePages = 1;
85
- console.warn( // eslint-disable-next-line max-len
85
+ console.warn(// eslint-disable-next-line max-len
86
86
  "Property \"numberMiddlePages\" should not be < 1. One middle page button will be shown. Set \"numberMiddlePages\" >= 1 to remove this warning.");
87
87
  } else numberMiddlePages = numberMiddlePagesProp;
88
88
  var startingMiddlePages;
@@ -181,7 +181,9 @@ var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
181
181
  ref: ref
182
182
  }, /*#__PURE__*/React.createElement(Box, _extends({
183
183
  as: "ul"
184
- }, theme.pagination.controls), controls.map(function (control, index) {
184
+ }, theme.pagination.controls, {
185
+ cssGap: true
186
+ }), controls.map(function (control, index) {
185
187
  return (
186
188
  /*#__PURE__*/
187
189
  /* Using index as key (as opposed to a unique id) seems to
@@ -122,7 +122,7 @@ var RadioButtonGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
122
122
  // on the first radiobutton
123
123
  value === '' && index === 0;
124
124
  if (optionRest.checked) {
125
- console.warn( // eslint-disable-next-line max-len
125
+ console.warn(// eslint-disable-next-line max-len
126
126
  "'checked' prop of an individual RadioButton shouldn't be used in a RadioButtonGroup component. Use the RadioButtonGroup 'value' prop instead.");
127
127
  }
128
128
  return /*#__PURE__*/React.createElement(RadioButton, _extends({
@@ -8,7 +8,7 @@ import { Keyboard } from '../Keyboard';
8
8
  import { FormContext } from '../Form/FormContext';
9
9
  import { SelectContainer } from './SelectContainer';
10
10
  import { HiddenInput, StyledSelectDropButton } from './StyledSelect';
11
- import { applyKey, getNormalizedValue, changeEvent, getSelectIcon, getDisplayLabelKey, getIconColor } from './utils';
11
+ import { applyKey, getNormalizedValue, changeEvent, getSelectIcon, getDisplayLabelKey, getIconColor, formatValueForA11y } from './utils';
12
12
  import { DefaultSelectTextInput } from './DefaultSelectTextInput';
13
13
  import { MessageContext } from '../../contexts/MessageContext';
14
14
  import { SelectPropTypes } from './propTypes';
@@ -126,23 +126,30 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
126
126
  // the option indexes present in the value
127
127
  var optionIndexesInValue = useMemo(function () {
128
128
  var result = [];
129
- allOptions.forEach(function (option, index) {
130
- if (selected !== undefined) {
131
- if (Array.isArray(selected)) {
132
- if (selected.indexOf(index) !== -1) result.push(index);
133
- } else if (index === selected) {
134
- result.push(index);
135
- }
136
- } else if (Array.isArray(normalizedValue)) {
137
- if (normalizedValue.some(function (v) {
138
- return v === applyKey(option, valueKey);
139
- })) {
140
- result.push(index);
141
- }
142
- } else if (normalizedValue === applyKey(option, valueKey)) {
129
+ if (selected !== undefined) {
130
+ if (Array.isArray(selected)) {
131
+ var validSelections = selected.filter(function (i) {
132
+ return i in allOptions;
133
+ });
134
+ result.push.apply(result, validSelections);
135
+ } else if (selected in allOptions) {
136
+ result.push(selected);
137
+ }
138
+ } else if (Array.isArray(normalizedValue)) {
139
+ normalizedValue.forEach(function (v) {
140
+ var index = allOptions.map(function (option) {
141
+ return applyKey(option, valueKey);
142
+ }).indexOf(v);
143
+ if (index !== -1) result.push(index);
144
+ });
145
+ } else {
146
+ var index = allOptions.map(function (option) {
147
+ return applyKey(option, valueKey);
148
+ }).indexOf(normalizedValue);
149
+ if (index !== -1) {
143
150
  result.push(index);
144
151
  }
145
- });
152
+ }
146
153
  return result;
147
154
  }, [allOptions, selected, valueKey, normalizedValue]);
148
155
  var _useState3 = useState(propOpen),
@@ -216,7 +223,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
216
223
  var selectValue = useMemo(function () {
217
224
  if (valueLabel instanceof Function) {
218
225
  if (value || value === 0 || value === false) return valueLabel(value);
219
- } else if (valueLabel) return valueLabel;else if ( /*#__PURE__*/React.isValidElement(value)) return value; // deprecated
226
+ } else if (valueLabel) return valueLabel;else if (/*#__PURE__*/React.isValidElement(value)) return value; // deprecated
220
227
  return undefined;
221
228
  }, [value, valueLabel]);
222
229
  var displayLabelKey = useMemo(function () {
@@ -253,7 +260,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
253
260
  id: 'select.selected',
254
261
  messages: messages,
255
262
  values: {
256
- currentSelectedValue: value
263
+ currentSelectedValue: formatValueForA11y(value, labelKey)
257
264
  }
258
265
  }) : ''),
259
266
  "aria-expanded": Boolean(open),
@@ -264,7 +271,7 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
264
271
  dropTarget: dropTarget,
265
272
  open: open,
266
273
  alignSelf: alignSelf,
267
- focusIndicator: focusIndicator,
274
+ focusIndicator: plain ? focusIndicator : true,
268
275
  onFocus: onFocus,
269
276
  onBlur: onBlur,
270
277
  gridArea: gridArea,
@@ -318,6 +325,8 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
318
325
  type: "text",
319
326
  name: name,
320
327
  id: id ? id + "__input" : undefined,
328
+ inert: "" // revisit for React 19
329
+ ,
321
330
  value: inputValue,
322
331
  ref: inputRef,
323
332
  readOnly: true
@@ -325,6 +334,8 @@ var Select = /*#__PURE__*/forwardRef(function (_ref, ref) {
325
334
  a11yTitle: (ariaLabel || a11yTitle) && "" + (ariaLabel || a11yTitle) + (value && typeof value === 'string' ? ", " + value : ''),
326
335
  disabled: disabled,
327
336
  id: id,
337
+ inert: "" // revisit for React 19
338
+ ,
328
339
  name: name,
329
340
  ref: inputRef,
330
341
  placeholder: placeholder,
@@ -39,41 +39,48 @@ var ClearButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
39
  fill: "horizontal",
40
40
  ref: ref,
41
41
  onClick: onClear,
42
- focusIndicator: false
43
- }, passThemeFlag, rest), /*#__PURE__*/React.createElement(Box, _extends({}, theme.select.clear.container, {
44
- align: align
45
- }), /*#__PURE__*/React.createElement(Text, theme.select.clear.text, buttonLabel)));
42
+ focusIndicator: false,
43
+ plain: true
44
+ }, passThemeFlag, rest), function (_ref2) {
45
+ var _theme$select$clear;
46
+ var hover = _ref2.hover;
47
+ var boxProps = _extends({}, theme.select.clear.container);
48
+ delete boxProps.hover; // avoid passing hover object to Box
49
+ return /*#__PURE__*/React.createElement(Box, _extends({}, boxProps, hover ? (_theme$select$clear = theme.select.clear) == null || (_theme$select$clear = _theme$select$clear.container) == null ? void 0 : _theme$select$clear.hover : {}, {
50
+ align: align
51
+ }), /*#__PURE__*/React.createElement(Text, theme.select.clear.text, buttonLabel));
52
+ });
46
53
  });
47
- var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
48
- var clear = _ref2.clear,
49
- _ref2$children = _ref2.children,
50
- children = _ref2$children === void 0 ? null : _ref2$children,
51
- disabled = _ref2.disabled,
52
- disabledKey = _ref2.disabledKey,
53
- dropHeight = _ref2.dropHeight,
54
- _ref2$emptySearchMess = _ref2.emptySearchMessage,
55
- emptySearchMessage = _ref2$emptySearchMess === void 0 ? 'No matches found' : _ref2$emptySearchMess,
56
- id = _ref2.id,
57
- labelKey = _ref2.labelKey,
58
- multiple = _ref2.multiple,
59
- name = _ref2.name,
60
- onChange = _ref2.onChange,
61
- onKeyDown = _ref2.onKeyDown,
62
- onMore = _ref2.onMore,
63
- onSearch = _ref2.onSearch,
64
- optionIndexesInValue = _ref2.optionIndexesInValue,
65
- options = _ref2.options,
66
- allOptions = _ref2.allOptions,
67
- searchPlaceholder = _ref2.searchPlaceholder,
68
- search = _ref2.search,
69
- setSearch = _ref2.setSearch,
70
- selected = _ref2.selected,
71
- usingKeyboard = _ref2.usingKeyboard,
72
- _ref2$value = _ref2.value,
73
- value = _ref2$value === void 0 ? '' : _ref2$value,
74
- valueKey = _ref2.valueKey,
75
- _ref2$replace = _ref2.replace,
76
- replace = _ref2$replace === void 0 ? true : _ref2$replace;
54
+ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
55
+ var clear = _ref3.clear,
56
+ _ref3$children = _ref3.children,
57
+ children = _ref3$children === void 0 ? null : _ref3$children,
58
+ disabled = _ref3.disabled,
59
+ disabledKey = _ref3.disabledKey,
60
+ dropHeight = _ref3.dropHeight,
61
+ _ref3$emptySearchMess = _ref3.emptySearchMessage,
62
+ emptySearchMessage = _ref3$emptySearchMess === void 0 ? 'No matches found' : _ref3$emptySearchMess,
63
+ id = _ref3.id,
64
+ labelKey = _ref3.labelKey,
65
+ multiple = _ref3.multiple,
66
+ name = _ref3.name,
67
+ onChange = _ref3.onChange,
68
+ onKeyDown = _ref3.onKeyDown,
69
+ onMore = _ref3.onMore,
70
+ onSearch = _ref3.onSearch,
71
+ optionIndexesInValue = _ref3.optionIndexesInValue,
72
+ options = _ref3.options,
73
+ allOptions = _ref3.allOptions,
74
+ searchPlaceholder = _ref3.searchPlaceholder,
75
+ search = _ref3.search,
76
+ setSearch = _ref3.setSearch,
77
+ selected = _ref3.selected,
78
+ usingKeyboard = _ref3.usingKeyboard,
79
+ _ref3$value = _ref3.value,
80
+ value = _ref3$value === void 0 ? '' : _ref3$value,
81
+ valueKey = _ref3.valueKey,
82
+ _ref3$replace = _ref3.replace,
83
+ replace = _ref3$replace === void 0 ? true : _ref3$replace;
77
84
  var _useThemeValue2 = useThemeValue(),
78
85
  theme = _useThemeValue2.theme,
79
86
  passThemeFlag = _useThemeValue2.passThemeFlag;
@@ -34,7 +34,7 @@ export interface BasicSelectProps {
34
34
  name?: string;
35
35
  onChange?: (...args: any[]) => void;
36
36
  onClose?: (...args: any[]) => any;
37
- onMore?: (...args: any[]) => any;
37
+ onMore?: () => void;
38
38
  onOpen?: (...args: any[]) => any;
39
39
  onSearch?: (search: string) => void;
40
40
  options: (string | boolean | number | JSX.Element | object)[];
@@ -7,9 +7,8 @@ export var Children = function Children() {
7
7
  selected = _useState[0],
8
8
  setSelected = _useState[1];
9
9
  var onRemoveSeason = function onRemoveSeason(season) {
10
- var seasonIndex = allSeasons.indexOf(season);
11
10
  setSelected(selected.filter(function (selectedSeason) {
12
- return selectedSeason !== seasonIndex;
11
+ return selectedSeason !== season;
13
12
  }));
14
13
  };
15
14
  var renderSeason = function renderSeason(season) {
@@ -67,12 +66,12 @@ export var Children = function Children() {
67
66
  }, /*#__PURE__*/React.createElement(Select, {
68
67
  closeOnChange: false,
69
68
  multiple: true,
70
- value: /*#__PURE__*/React.createElement(Box, {
69
+ valueLabel: /*#__PURE__*/React.createElement(Box, {
71
70
  wrap: true,
72
71
  direction: "row",
73
72
  width: "small"
74
- }, selected && selected.length ? selected.map(function (index) {
75
- return renderSeason(allSeasons[index]);
73
+ }, selected && selected.length ? selected.map(function (value) {
74
+ return renderSeason(value);
76
75
  }) : /*#__PURE__*/React.createElement(Box, {
77
76
  pad: {
78
77
  vertical: 'xsmall',
@@ -81,11 +80,11 @@ export var Children = function Children() {
81
80
  margin: "xsmall"
82
81
  }, "Select Season")),
83
82
  options: allSeasons,
84
- selected: selected,
83
+ value: selected,
85
84
  disabled: [2, 6],
86
85
  onChange: function onChange(_ref) {
87
- var nextSelected = _ref.selected;
88
- setSelected([].concat(nextSelected).sort());
86
+ var nextSelected = _ref.value;
87
+ setSelected(nextSelected);
89
88
  }
90
89
  }, renderOption))
91
90
  // </Grommet>
@@ -1,11 +1,12 @@
1
- import { useCallback } from 'react';
1
+ import { useCallback, isValidElement } from 'react';
2
2
  import { normalizeColor } from '../../utils';
3
3
  var _applyKey = function applyKey(option, key) {
4
+ if (/*#__PURE__*/isValidElement(option)) return option;
4
5
  if (option === undefined || option === null) return undefined;
5
6
  if (typeof key === 'object') return _applyKey(option, key.key);
6
7
  if (typeof key === 'function') return key(option);
7
8
  if (key !== undefined && typeof option === 'object') return option[key];
8
- if (typeof option === 'object' && Object.keys(option)) return option[Object.keys(option)[0]];
9
+ if (typeof option === 'object' && Object.keys(option).length > 0) return option[Object.keys(option)[0]];
9
10
  return option;
10
11
  };
11
12
  export { _applyKey as applyKey };
@@ -93,4 +94,15 @@ export var getDisplayLabelKey = function getDisplayLabelKey(labelKey, allOptions
93
94
  };
94
95
  export var getIconColor = function getIconColor(theme) {
95
96
  return normalizeColor(theme.select.icons.color || 'control', theme);
96
- };
97
+ };
98
+ var _formatValueForA11y = function formatValueForA11y(value, labelKey) {
99
+ if (typeof value === 'string') return value;
100
+ if (/*#__PURE__*/isValidElement(value)) return value.toString();
101
+ if (Array.isArray(value)) {
102
+ return value.map(function (item) {
103
+ return _formatValueForA11y(item, labelKey);
104
+ }).join(', ');
105
+ }
106
+ return _applyKey(value, labelKey);
107
+ };
108
+ export { _formatValueForA11y as formatValueForA11y };
@@ -159,12 +159,14 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
159
159
  // the option indexes present in the value
160
160
  var optionIndexesInValue = useMemo(function () {
161
161
  var result = [];
162
- allOptions.forEach(function (option, index) {
163
- if (normalizedValue != null && normalizedValue.some != null && normalizedValue.some(function (v) {
164
- return v === applyKey(option, valueKey);
165
- })) {
166
- result.push(index);
167
- }
162
+ if (!Array.isArray(normalizedValue)) {
163
+ return result;
164
+ }
165
+ normalizedValue.forEach(function (v) {
166
+ var index = allOptions.map(function (option) {
167
+ return applyKey(option, valueKey);
168
+ }).indexOf(v);
169
+ if (index !== -1) result.push(index);
168
170
  });
169
171
  return result;
170
172
  }, [allOptions, valueKey, normalizedValue]);
@@ -400,6 +402,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
400
402
  defaultCursor: disabled === true || undefined,
401
403
  focusIndicator: false,
402
404
  id: id ? id + "__input" : undefined,
405
+ inert: "" // revisit for React 19
406
+ ,
403
407
  name: name,
404
408
  width: "100%"
405
409
  }, rest, {
@@ -424,6 +428,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
424
428
  type: "text",
425
429
  name: name,
426
430
  id: id ? id + "__input" : undefined,
431
+ inert: "" // revisit for React 19
432
+ ,
427
433
  value: inputValue,
428
434
  ref: inputRef,
429
435
  readOnly: true
@@ -433,6 +439,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
433
439
  a11yTitle: ariaLabel || a11yTitle,
434
440
  disabled: disabled,
435
441
  id: id,
442
+ inert: "" // revisit for React 19
443
+ ,
436
444
  name: name,
437
445
  ref: inputRef,
438
446
  placeholder: placeholder || 'Select',
@@ -459,6 +467,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
459
467
  type: "text",
460
468
  name: name,
461
469
  id: id ? id + "__input" : undefined,
470
+ inert: "" // revisit for React 19
471
+ ,
462
472
  value: inputValue,
463
473
  ref: inputRef,
464
474
  readOnly: true
@@ -466,6 +476,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
466
476
  a11yTitle: ariaLabel || a11yTitle,
467
477
  disabled: disabled,
468
478
  id: id,
479
+ inert: "" // revisit for React 19
480
+ ,
469
481
  name: name,
470
482
  ref: inputRef,
471
483
  placeholder: placeholder,
@@ -364,7 +364,20 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
364
364
  pad: "xsmall",
365
365
  tabIndex: "-1",
366
366
  checked: optionSelected,
367
- disabled: optionDisabled
367
+ disabled: optionDisabled,
368
+ inert: "" // revisit for React 19
369
+ ,
370
+ containerProps: {
371
+ // in Firefox when we have inert set, the checkbox
372
+ // click event gets swallowed by the checkbox.
373
+ // We need the click event to go the the button
374
+ // around the checkbox so we use pointerEvents =
375
+ // none. For code clarity we decided an inline
376
+ // style made sense here.
377
+ style: {
378
+ pointerEvents: 'none'
379
+ }
380
+ }
368
381
  });
369
382
  }
370
383
  if (!children && search) {
@@ -386,7 +399,20 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
386
399
  pad: "xsmall",
387
400
  tabIndex: "-1",
388
401
  checked: optionSelected,
389
- disabled: optionDisabled
402
+ disabled: optionDisabled,
403
+ inert: "" // revisit for React 19
404
+ ,
405
+ containerProps: {
406
+ // in Firefox when we have inert set, the checkbox
407
+ // click event gets swallowed by the checkbox.
408
+ // We need the click event to go the the button
409
+ // around the checkbox so we use pointerEvents =
410
+ // none. For code clarity we decided an inline
411
+ // style made sense here.
412
+ style: {
413
+ pointerEvents: 'none'
414
+ }
415
+ }
390
416
  });
391
417
  }
392
418
  }
@@ -100,7 +100,20 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
100
100
  key: optionLabel,
101
101
  pad: "xsmall",
102
102
  tabIndex: "-1",
103
- checked: optionSelected
103
+ checked: optionSelected,
104
+ inert: "" // revisit for React 19
105
+ ,
106
+ containerProps: {
107
+ // in Firefox when we have inert set, the checkbox
108
+ // click event gets swallowed by the checkbox.
109
+ // We need the click event to go the the button
110
+ // around the checkbox so we use pointerEvents =
111
+ // none. For code clarity we decided an inline
112
+ // style made sense here.
113
+ style: {
114
+ pointerEvents: 'none'
115
+ }
116
+ }
104
117
  }));
105
118
  }
106
119
  return undefined;