grommet 2.41.0 → 2.43.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 (175) hide show
  1. package/all/stories/Colors.js +6 -6
  2. package/components/Accordion/stories/CustomThemed/Rich.tsx +1 -1
  3. package/components/AccordionPanel/AccordionPanel.js +1 -7
  4. package/components/Box/Box.js +1 -1
  5. package/components/Box/StyledBox.js +1 -6
  6. package/components/Box/index.d.ts +1 -0
  7. package/components/Box/propTypes.js +1 -0
  8. package/components/Box/stories/Background.js +4 -10
  9. package/components/Button/Button.js +1 -0
  10. package/components/Button/StyledButton.js +3 -2
  11. package/components/Calendar/Calendar.js +96 -59
  12. package/components/Calendar/StyledCalendar.js +89 -7
  13. package/components/Calendar/utils.js +16 -2
  14. package/components/Card/stories/Simple.js +2 -2
  15. package/components/Carousel/Carousel.js +1 -1
  16. package/components/Chart/Chart.js +3 -3
  17. package/components/CheckBox/CheckBox.js +3 -2
  18. package/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
  19. package/components/Clock/Digital.js +1 -1
  20. package/components/Data/stories/Cards.js +3 -2
  21. package/components/Data/stories/Infinite.js +2 -2
  22. package/components/Data/stories/OnSelect.js +2 -2
  23. package/components/Data/stories/Properties.js +3 -2
  24. package/components/Data/stories/SpaceX.js +2 -2
  25. package/components/Data/stories/StarWars.js +1 -1
  26. package/components/DataFilter/DataFilter.js +1 -1
  27. package/components/DataSort/DataSort.js +46 -14
  28. package/components/DataSort/stories/Simple.js +10 -1
  29. package/components/DataTable/Body.js +14 -8
  30. package/components/DataTable/GroupedBody.js +3 -3
  31. package/components/DataTable/buildState.js +5 -1
  32. package/components/DataTable/stories/SpaceX.js +2 -2
  33. package/components/DataTable/stories/SpaceXUngrouped.js +1 -1
  34. package/components/FileInput/index.d.ts +2 -3
  35. package/components/FormField/FormField.js +9 -2
  36. package/components/FormField/stories/ThresholdValidation.js +5 -1
  37. package/components/Grommet/index.d.ts +19 -1
  38. package/components/Grommet/propTypes.js +18 -0
  39. package/components/Grommet/stories/Theme.js +1 -1
  40. package/components/Grommet/stories/Vars.js +2 -2
  41. package/components/Layer/Layer.js +1 -1
  42. package/components/Layer/index.d.ts +2 -0
  43. package/components/List/List.js +43 -13
  44. package/components/List/stories/RenderedList.js +1 -1
  45. package/components/Meter/Circle.js +2 -2
  46. package/components/Meter/Meter.js +36 -17
  47. package/components/Meter/index.d.ts +18 -0
  48. package/components/Meter/propTypes.js +18 -0
  49. package/components/Notification/Notification.js +18 -6
  50. package/components/Notification/index.d.ts +1 -0
  51. package/components/Notification/propTypes.js +1 -0
  52. package/components/Pagination/Pagination.js +4 -2
  53. package/components/Pagination/stories/CustomThemed/Custom.tsx +8 -2
  54. package/components/Pagination/stories/NumberEdgePages.js +2 -0
  55. package/components/Pagination/stories/NumberMiddlePages.js +2 -0
  56. package/components/Pagination/stories/Simple.js +4 -2
  57. package/components/Pagination/stories/Size.js +3 -0
  58. package/components/Pagination/stories/Steps.js +3 -0
  59. package/components/RadioButton/RadioButton.js +14 -3
  60. package/components/RadioButton/stories/Children.js +16 -3
  61. package/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  62. package/components/RadioButtonGroup/stories/Children.js +13 -1
  63. package/components/Select/Select.js +7 -3
  64. package/components/Select/SelectContainer.js +41 -34
  65. package/components/Select/index.d.ts +1 -1
  66. package/components/Select/utils.js +13 -2
  67. package/components/SelectMultiple/SelectMultiple.js +10 -0
  68. package/components/SelectMultiple/SelectMultipleContainer.js +28 -2
  69. package/components/SelectMultiple/SelectMultipleValue.js +14 -1
  70. package/components/SkipLinks/index.d.ts +1 -0
  71. package/components/SkipLinks/propTypes.js +1 -0
  72. package/components/Tab/Tab.js +1 -1
  73. package/components/Tabs/stories/Scrollable.js +2 -1
  74. package/components/Tag/Tag.js +11 -7
  75. package/components/TextInput/TextInput.js +7 -2
  76. package/components/ToggleGroup/StyledToggleGroup.js +12 -5
  77. package/components/ToggleGroup/ToggleGroup.js +21 -10
  78. package/components/WorldMap/WorldMap.js +1 -1
  79. package/es6/all/stories/Colors.js +6 -6
  80. package/es6/components/Accordion/stories/CustomThemed/Rich.tsx +1 -1
  81. package/es6/components/AccordionPanel/AccordionPanel.js +2 -9
  82. package/es6/components/Box/Box.js +1 -1
  83. package/es6/components/Box/StyledBox.js +1 -6
  84. package/es6/components/Box/index.d.ts +1 -0
  85. package/es6/components/Box/propTypes.js +1 -0
  86. package/es6/components/Box/stories/Background.js +4 -10
  87. package/es6/components/Button/Button.js +1 -0
  88. package/es6/components/Button/StyledButton.js +4 -3
  89. package/es6/components/Calendar/Calendar.js +95 -59
  90. package/es6/components/Calendar/StyledCalendar.js +90 -8
  91. package/es6/components/Calendar/utils.js +15 -1
  92. package/es6/components/Card/stories/Simple.js +3 -3
  93. package/es6/components/Carousel/Carousel.js +1 -1
  94. package/es6/components/Chart/Chart.js +3 -3
  95. package/es6/components/CheckBox/CheckBox.js +3 -2
  96. package/es6/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
  97. package/es6/components/Clock/Digital.js +1 -1
  98. package/es6/components/Data/stories/Cards.js +4 -3
  99. package/es6/components/Data/stories/Infinite.js +2 -2
  100. package/es6/components/Data/stories/OnSelect.js +2 -2
  101. package/es6/components/Data/stories/Properties.js +4 -3
  102. package/es6/components/Data/stories/SpaceX.js +2 -2
  103. package/es6/components/Data/stories/StarWars.js +1 -1
  104. package/es6/components/DataFilter/DataFilter.js +1 -1
  105. package/es6/components/DataSort/DataSort.js +46 -14
  106. package/es6/components/DataSort/stories/Simple.js +10 -1
  107. package/es6/components/DataTable/Body.js +14 -8
  108. package/es6/components/DataTable/GroupedBody.js +3 -3
  109. package/es6/components/DataTable/buildState.js +5 -1
  110. package/es6/components/DataTable/stories/SpaceX.js +2 -2
  111. package/es6/components/DataTable/stories/SpaceXUngrouped.js +1 -1
  112. package/es6/components/FileInput/index.d.ts +2 -3
  113. package/es6/components/FormField/FormField.js +10 -3
  114. package/es6/components/FormField/stories/ThresholdValidation.js +5 -1
  115. package/es6/components/Grommet/index.d.ts +19 -1
  116. package/es6/components/Grommet/propTypes.js +18 -0
  117. package/es6/components/Grommet/stories/Theme.js +1 -1
  118. package/es6/components/Grommet/stories/Vars.js +2 -2
  119. package/es6/components/Layer/Layer.js +1 -1
  120. package/es6/components/Layer/index.d.ts +2 -0
  121. package/es6/components/List/List.js +43 -13
  122. package/es6/components/List/stories/RenderedList.js +1 -1
  123. package/es6/components/Meter/Circle.js +2 -2
  124. package/es6/components/Meter/Meter.js +37 -18
  125. package/es6/components/Meter/index.d.ts +18 -0
  126. package/es6/components/Meter/propTypes.js +18 -0
  127. package/es6/components/Notification/Notification.js +18 -6
  128. package/es6/components/Notification/index.d.ts +1 -0
  129. package/es6/components/Notification/propTypes.js +1 -0
  130. package/es6/components/Pagination/Pagination.js +4 -2
  131. package/es6/components/Pagination/stories/CustomThemed/Custom.tsx +8 -2
  132. package/es6/components/Pagination/stories/NumberEdgePages.js +2 -0
  133. package/es6/components/Pagination/stories/NumberMiddlePages.js +2 -0
  134. package/es6/components/Pagination/stories/Simple.js +4 -2
  135. package/es6/components/Pagination/stories/Size.js +3 -0
  136. package/es6/components/Pagination/stories/Steps.js +3 -0
  137. package/es6/components/RadioButton/RadioButton.js +15 -4
  138. package/es6/components/RadioButton/stories/Children.js +16 -3
  139. package/es6/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  140. package/es6/components/RadioButtonGroup/stories/Children.js +12 -1
  141. package/es6/components/Select/Select.js +8 -4
  142. package/es6/components/Select/SelectContainer.js +41 -34
  143. package/es6/components/Select/index.d.ts +1 -1
  144. package/es6/components/Select/utils.js +15 -3
  145. package/es6/components/SelectMultiple/SelectMultiple.js +10 -0
  146. package/es6/components/SelectMultiple/SelectMultipleContainer.js +28 -2
  147. package/es6/components/SelectMultiple/SelectMultipleValue.js +14 -1
  148. package/es6/components/SkipLinks/index.d.ts +1 -0
  149. package/es6/components/SkipLinks/propTypes.js +1 -0
  150. package/es6/components/Tab/Tab.js +1 -1
  151. package/es6/components/Tabs/stories/Scrollable.js +2 -1
  152. package/es6/components/Tag/Tag.js +11 -7
  153. package/es6/components/TextInput/TextInput.js +7 -2
  154. package/es6/components/ToggleGroup/StyledToggleGroup.js +12 -5
  155. package/es6/components/ToggleGroup/ToggleGroup.js +22 -11
  156. package/es6/components/WorldMap/WorldMap.js +1 -1
  157. package/es6/languages/default.json +18 -0
  158. package/es6/themes/base.d.ts +204 -6
  159. package/es6/themes/base.js +165 -1
  160. package/es6/utils/background.js +1 -1
  161. package/es6/utils/index.js +2 -1
  162. package/es6/utils/styles.js +8 -0
  163. package/es6/utils/useId.js +17 -0
  164. package/grommet.min.js +1 -1
  165. package/grommet.min.js.map +1 -1
  166. package/languages/default.json +18 -0
  167. package/package.json +36 -36
  168. package/themes/base.d.ts +204 -6
  169. package/themes/base.js +165 -1
  170. package/utils/background.js +1 -1
  171. package/utils/index.js +6 -0
  172. package/utils/styles.js +9 -1
  173. package/utils/useId.js +22 -0
  174. package/components/CheckBox/stories/InsideButton.js +0 -38
  175. package/es6/components/CheckBox/stories/InsideButton.js +0 -32
@@ -120,6 +120,24 @@ export interface GrommetProps {
120
120
  openMenu?: string;
121
121
  closeMenu?: string;
122
122
  };
123
+ meter?: {
124
+ bar?: {
125
+ singular?: string;
126
+ plural?: string;
127
+ };
128
+ circle?: {
129
+ singular?: string;
130
+ plural?: string;
131
+ };
132
+ pie?: {
133
+ singular?: string;
134
+ plural?: string;
135
+ };
136
+ semicircle?: {
137
+ singular?: string;
138
+ plural?: string;
139
+ };
140
+ };
123
141
  rangeSelector?: {
124
142
  lower?: string;
125
143
  upper?: string;
@@ -171,7 +189,7 @@ export interface GrommetProps {
171
189
  volumeUp?: string;
172
190
  };
173
191
  };
174
- format: (...args: any[]) => void;
192
+ format?: (...args: any[]) => void;
175
193
  };
176
194
  onAnalytics?: (data: any) => void;
177
195
  plain?: boolean;
@@ -127,6 +127,24 @@ if (process.env.NODE_ENV !== 'production') {
127
127
  openMenu: _propTypes["default"].string,
128
128
  closeMenu: _propTypes["default"].string
129
129
  }),
130
+ meter: _propTypes["default"].shape({
131
+ bar: _propTypes["default"].shape({
132
+ singular: _propTypes["default"].string,
133
+ plural: _propTypes["default"].string
134
+ }),
135
+ circle: _propTypes["default"].shape({
136
+ singular: _propTypes["default"].string,
137
+ plural: _propTypes["default"].string
138
+ }),
139
+ pie: _propTypes["default"].shape({
140
+ singular: _propTypes["default"].string,
141
+ plural: _propTypes["default"].string
142
+ }),
143
+ semicirlce: _propTypes["default"].shape({
144
+ singular: _propTypes["default"].string,
145
+ plural: _propTypes["default"].string
146
+ })
147
+ }),
130
148
  rangeSelector: _propTypes["default"].shape({
131
149
  lower: _propTypes["default"].string,
132
150
  upper: _propTypes["default"].string
@@ -9,7 +9,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
9
9
  var customTheme = {
10
10
  global: {
11
11
  colors: {
12
- custom: '#cc6633'
12
+ custom: '#a35200'
13
13
  }
14
14
  }
15
15
  };
@@ -11,11 +11,11 @@ var Vars = exports.Vars = function Vars() {
11
11
  cssVars: true
12
12
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
13
13
  pad: "medium",
14
- background: "var(--accent-2)",
14
+ background: "var(--light-6)",
15
15
  gap: "medium"
16
16
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, "Checkout Grommet variables, you can find them in the StyledGrommet DOM."), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
17
17
  "with": true
18
- }, "For example, the background color in this Box is using var(--accent-2)")));
18
+ }, "For example, the background color in this Box is using var(--light-6)")));
19
19
  };
20
20
  var _default = exports["default"] = {
21
21
  title: 'Utilities/Grommet/Vars'
@@ -74,7 +74,7 @@ var Layer = exports.Layer = /*#__PURE__*/(0, _react.forwardRef)(function (props,
74
74
  }
75
75
  };
76
76
  }, [animate, animation, containerTarget, layerContainer, originalFocusedElement]);
77
- return layerContainer ? /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react["default"].createElement(_LayerContainer.LayerContainer, _extends({
77
+ return layerContainer ? /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react["default"].createElement(_LayerContainer.LayerContainer, _extends({
78
78
  ref: ref
79
79
  }, props)), layerContainer) : null;
80
80
  });
@@ -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';
@@ -215,7 +215,7 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
215
215
  var draggingRef = (0, _react.useRef)();
216
216
  var sendAnalytics = (0, _AnalyticsContext.useAnalytics)();
217
217
  var ariaProps = {
218
- role: onClickItem || onOrder ? 'listbox' : 'list'
218
+ role: onClickItem ? 'listbox' : 'list'
219
219
  };
220
220
  if (active >= 0) {
221
221
  var activeId;
@@ -265,22 +265,52 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
265
265
  return /*#__PURE__*/_react["default"].createElement(Container, containterProps, /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
266
266
  onEnter: onSelectOption,
267
267
  onSpace: function onSpace(event) {
268
- event.preventDefault();
268
+ if (onClickItem || onOrder) {
269
+ event.preventDefault();
270
+ }
269
271
  onSelectOption(event);
270
272
  },
271
273
  onUp: function onUp(event) {
272
- event.preventDefault();
273
- if ((onClickItem || onOrder) && active) {
274
- var min = onOrder ? 1 : 0;
275
- updateActive(Math.max(active - 1, min));
274
+ if (onClickItem || onOrder) {
275
+ event.preventDefault();
276
+ if (active) {
277
+ var min = onOrder ? 1 : 0;
278
+ var activeElementIndex = Math.max(active - 1, min);
279
+ updateActive(activeElementIndex);
280
+
281
+ // Ensure the active item is in view
282
+ // setTimeout for activeElement to be updated
283
+ setTimeout(function () {
284
+ var _listRef$current;
285
+ // eslint-disable max-len
286
+ (_listRef$current = listRef.current) == null || (_listRef$current = _listRef$current.children[activeElementIndex]) == null || _listRef$current.scrollIntoView({
287
+ behavior: 'smooth',
288
+ block: 'nearest'
289
+ });
290
+ }, 0);
291
+ }
276
292
  }
277
293
  },
278
294
  onDown: function onDown(event) {
279
- event.preventDefault();
280
- if ((onClickItem || onOrder) && orderableData && orderableData.length) {
281
- var min = onOrder ? 1 : 0;
282
- var max = onOrder ? orderableData.length * 2 - 2 : data.length - 1;
283
- updateActive(active >= min ? Math.min(active + 1, max) : min);
295
+ if (onClickItem || onOrder) {
296
+ event.preventDefault();
297
+ if (orderableData && orderableData.length) {
298
+ var min = onOrder ? 1 : 0;
299
+ var max = onOrder ? orderableData.length * 2 - 2 : data.length - 1;
300
+ var activeElementIndex = active >= min ? Math.min(active + 1, max) : min;
301
+ updateActive(activeElementIndex);
302
+
303
+ // Ensure the active item is in view
304
+ // setTimeout for activeElement to be updated
305
+ setTimeout(function () {
306
+ var _listRef$current2;
307
+ // eslint-disable max-len
308
+ (_listRef$current2 = listRef.current) == null || (_listRef$current2 = _listRef$current2.children[activeElementIndex]) == null || _listRef$current2.scrollIntoView({
309
+ behavior: 'smooth',
310
+ block: 'nearest'
311
+ });
312
+ }, 0);
313
+ }
284
314
  }
285
315
  },
286
316
  onKeyDown: onKeyDown
@@ -322,7 +352,7 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
322
352
  var isPinned;
323
353
  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) {
324
354
  if (typeof item === 'object' && !itemKey) {
325
- console.error( // eslint-disable-next-line max-len
355
+ console.error(// eslint-disable-next-line max-len
326
356
  "Warning: Missing prop itemKey. Prop pin requires itemKey to be specified when data is of type 'object'.");
327
357
  }
328
358
  isPinned = Array.isArray(pinned) ? pinned == null ? void 0 : pinned.includes(key) : pinned.items.some(function (pinnedItem) {
@@ -374,7 +404,7 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
374
404
  var isDisabled;
375
405
  if (disabledItems) {
376
406
  if (typeof item === 'object' && !itemKey) {
377
- console.error( // eslint-disable-next-line max-len
407
+ console.error(// eslint-disable-next-line max-len
378
408
  "Warning: Missing prop itemKey. Prop disabled requires itemKey to be specified when data is of type 'object'.");
379
409
  }
380
410
  isDisabled = disabledItems == null ? void 0 : disabledItems.includes(key);
@@ -30,7 +30,7 @@ var RenderedList = exports.RenderedList = function RenderedList() {
30
30
  return /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
31
31
  key: item.location,
32
32
  size: "small",
33
- color: "dark-4"
33
+ color: "dark-2"
34
34
  }, item.location);
35
35
  },
36
36
  itemKey: function itemKey(item) {
@@ -75,7 +75,7 @@ var Circle = exports.Circle = /*#__PURE__*/(0, _react.forwardRef)(function (prop
75
75
  var stroke = (0, _utils2.strokeProps)(someHighlight && !highlight ? background : colorName, theme);
76
76
  if (round) {
77
77
  var d1 = (0, _utils.arcCommands)(centerX, centerY, radius, startAngle, endAngle);
78
- paths.unshift( /*#__PURE__*/_react["default"].createElement("path", _extends({
78
+ paths.unshift(/*#__PURE__*/_react["default"].createElement("path", _extends({
79
79
  key: key,
80
80
  d: d1,
81
81
  fill: "none"
@@ -104,7 +104,7 @@ var Circle = exports.Circle = /*#__PURE__*/(0, _react.forwardRef)(function (prop
104
104
  pathCaps.unshift(pathCap);
105
105
  } else {
106
106
  var d = (0, _utils.arcCommands)(centerX, centerY, radius, startAngle, endAngle);
107
- paths.push( /*#__PURE__*/_react["default"].createElement("path", _extends({
107
+ paths.push(/*#__PURE__*/_react["default"].createElement("path", _extends({
108
108
  key: key,
109
109
  d: d,
110
110
  fill: "none"
@@ -7,23 +7,16 @@ var _Bar = require("./Bar");
7
7
  var _Circle = require("./Circle");
8
8
  var _propTypes = require("./propTypes");
9
9
  var _useThemeValue2 = require("../../utils/useThemeValue");
10
- var _excluded = ["background", "color", "direction", "size", "thickness", "type", "reverse", "value", "values"];
10
+ var _MessageContext = require("../../contexts/MessageContext");
11
+ var _excluded = ["aria-label", "background", "color", "direction", "max", "messages", "size", "thickness", "type", "reverse", "value", "values"];
11
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
13
14
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
14
15
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
15
- var deriveMax = function deriveMax(values) {
16
- var max = 100;
17
- if (values && values.length > 1) {
18
- max = 0;
19
- values.forEach(function (v) {
20
- max += v.value;
21
- });
22
- }
23
- return max;
24
- };
25
16
  var Meter = exports.Meter = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
26
- var _ref$background = _ref.background,
17
+ var _messages$meter;
18
+ var ariaLabel = _ref['aria-label'],
19
+ _ref$background = _ref.background,
27
20
  background = _ref$background === void 0 ? {
28
21
  color: 'light-2',
29
22
  opacity: 'medium'
@@ -31,6 +24,8 @@ var Meter = exports.Meter = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
31
24
  color = _ref.color,
32
25
  _ref$direction = _ref.direction,
33
26
  direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
27
+ maxProp = _ref.max,
28
+ messages = _ref.messages,
34
29
  _ref$size = _ref.size,
35
30
  size = _ref$size === void 0 ? 'medium' : _ref$size,
36
31
  _ref$thickness = _ref.thickness,
@@ -43,6 +38,8 @@ var Meter = exports.Meter = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
43
38
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
44
39
  var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
45
40
  theme = _useThemeValue.theme;
41
+ var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
42
+ format = _useContext.format;
46
43
 
47
44
  // normalize values to an array of objects
48
45
  var values = (0, _react.useMemo)(function () {
@@ -54,14 +51,35 @@ var Meter = exports.Meter = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
54
51
  return [];
55
52
  }, [color, value, valuesProp]);
56
53
  var reverse = direction === 'horizontal' && (theme.dir === 'rtl' || reverseProp) && !(theme.dir === 'rtl' && reverseProp);
57
- var memoizedMax = (0, _react.useMemo)(function () {
58
- return deriveMax(values);
59
- }, [values]);
54
+ var max = (0, _react.useMemo)(function () {
55
+ var maxValue = 100;
56
+ if ((values == null ? void 0 : values.length) > 1) {
57
+ maxValue = values.reduce(function (total, currentValue) {
58
+ return total + currentValue.value;
59
+ }, 0);
60
+ }
61
+ return maxProp || maxValue || 100;
62
+ }, [maxProp, values]);
63
+ var messageId = (values == null ? void 0 : values.length) === 1 ? 'singular' : 'plural';
64
+ var meterType = type || 'bar';
65
+ var meterAriaLabel = ariaLabel || format({
66
+ id: "meter." + meterType + "." + messageId,
67
+ messages: messages == null || (_messages$meter = messages.meter) == null ? void 0 : _messages$meter[meterType],
68
+ values: {
69
+ meterValue: value || values.map(function (item) {
70
+ var _item$value;
71
+ return (_item$value = item.value) != null ? _item$value : 0;
72
+ }).join(', ') || 0,
73
+ type: type,
74
+ max: max
75
+ }
76
+ });
60
77
  var content;
61
78
  if (type === 'bar') {
62
79
  content = /*#__PURE__*/_react["default"].createElement(_Bar.Bar, _extends({
63
80
  ref: ref,
64
- max: memoizedMax,
81
+ "aria-label": meterAriaLabel,
82
+ max: max,
65
83
  values: values,
66
84
  size: size,
67
85
  thickness: thickness,
@@ -71,8 +89,9 @@ var Meter = exports.Meter = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
71
89
  }, rest));
72
90
  } else if (type === 'circle' || type === 'pie' || type === 'semicircle') {
73
91
  content = /*#__PURE__*/_react["default"].createElement(_Circle.Circle, _extends({
92
+ "aria-label": meterAriaLabel,
74
93
  ref: ref,
75
- max: memoizedMax,
94
+ max: max,
76
95
  values: values,
77
96
  size: size,
78
97
  thickness: thickness,
@@ -16,6 +16,24 @@ export interface MeterProps {
16
16
  gridArea?: GridAreaType;
17
17
  margin?: MarginType;
18
18
  max?: number;
19
+ messages?: {
20
+ bar?: {
21
+ singular?: string;
22
+ plural?: string;
23
+ };
24
+ circle?: {
25
+ singular?: string;
26
+ plural?: string;
27
+ };
28
+ pie?: {
29
+ singular?: string;
30
+ plural?: string;
31
+ };
32
+ semicircle?: {
33
+ singular?: string;
34
+ plural?: string;
35
+ };
36
+ };
19
37
  reverse?: boolean;
20
38
  round?: boolean;
21
39
  size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'full' | string;
@@ -15,6 +15,24 @@ if (process.env.NODE_ENV !== 'production') {
15
15
  })]),
16
16
  color: _propTypes["default"].string,
17
17
  max: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
18
+ messages: _propTypes["default"].shape({
19
+ bar: _propTypes["default"].shape({
20
+ singular: _propTypes["default"].string,
21
+ plural: _propTypes["default"].string
22
+ }),
23
+ circle: _propTypes["default"].shape({
24
+ singular: _propTypes["default"].string,
25
+ plural: _propTypes["default"].string
26
+ }),
27
+ pie: _propTypes["default"].shape({
28
+ singular: _propTypes["default"].string,
29
+ plural: _propTypes["default"].string
30
+ }),
31
+ semicirlce: _propTypes["default"].shape({
32
+ singular: _propTypes["default"].string,
33
+ plural: _propTypes["default"].string
34
+ })
35
+ }),
18
36
  reverse: _propTypes["default"].bool,
19
37
  round: _propTypes["default"].bool,
20
38
  size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'full']), _propTypes["default"].string]),
@@ -52,12 +52,18 @@ var adaptThemeStyle = function adaptThemeStyle(value, theme) {
52
52
  }
53
53
  return [textStyle, closeButtonStyle];
54
54
  };
55
+ var getTextColor = function getTextColor(part, status, kind, theme) {
56
+ var _theme$notification, _theme$notification2, _theme$notification3, _theme$notification4, _theme$notification5;
57
+ var color;
58
+ 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;
59
+ return color;
60
+ };
55
61
  var NotificationAnchor = (0, _styledComponents["default"])(_Anchor.Anchor).withConfig({
56
62
  displayName: "Notification__NotificationAnchor",
57
63
  componentId: "sc-1yq09yz-0"
58
64
  })(["white-space:nowrap;"]);
59
65
  var Notification = exports.Notification = function Notification(_ref) {
60
- var _theme$notification, _theme$notification2, _theme$notification3, _theme$notification4, _theme$notification5;
66
+ var _theme$notification6, _theme$notification7, _theme$notification8, _theme$notification9, _theme$notification10;
61
67
  var actionsProp = _ref.actions,
62
68
  messageProp = _ref.message,
63
69
  onClose = _ref.onClose,
@@ -94,7 +100,7 @@ var Notification = exports.Notification = function Notification(_ref) {
94
100
  return undefined;
95
101
  }, [autoClose, close, theme.notification.toast.time, theme.notification.time, time]);
96
102
  var CloseIcon = theme.notification.close.icon;
97
- var _ref2 = ((_theme$notification = theme.notification) == null ? void 0 : _theme$notification[status]) || theme.notification.unknown,
103
+ var _ref2 = ((_theme$notification6 = theme.notification) == null ? void 0 : _theme$notification6[status]) || theme.notification.unknown,
98
104
  StatusIcon = _ref2.icon,
99
105
  color = _ref2.color;
100
106
  var closeIconColor = theme.notification.close.color;
@@ -106,7 +112,7 @@ var Notification = exports.Notification = function Notification(_ref) {
106
112
  var direction;
107
113
  if (kind && theme.notification[kind].direction) direction = theme.notification[kind].direction;else direction = theme.notification.direction;
108
114
  var background;
109
- 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;
115
+ 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;
110
116
  var TextWrapper = direction === 'row' ? _Text.Text : _react.Fragment;
111
117
 
112
118
  // notification is built with two child boxes that contain:
@@ -125,6 +131,8 @@ var Notification = exports.Notification = function Notification(_ref) {
125
131
  } else textPad = pad;
126
132
  var actions;
127
133
  var message = messageProp;
134
+ var messageColor = getTextColor('message', status, kind, theme);
135
+ var titleColor = getTextColor('title', status, kind, theme);
128
136
  if (actionsProp) actions = actionsProp.map(function (action) {
129
137
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
130
138
  key: action.label
@@ -138,12 +146,14 @@ var Notification = exports.Notification = function Notification(_ref) {
138
146
  }, action, theme.notification.actions)), ' ');
139
147
  });
140
148
  var Message = direction !== 'row' ? _Paragraph.Paragraph : _Text.Text;
141
- if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/_react["default"].createElement(Message, theme.notification.message, /*#__PURE__*/_react["default"].createElement(_Text.Text, {
149
+ if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/_react["default"].createElement(Message, _extends({}, theme.notification.message, {
150
+ color: messageColor
151
+ }), /*#__PURE__*/_react["default"].createElement(_Text.Text, {
142
152
  margin: {
143
153
  right: 'xsmall'
144
154
  }
145
155
  }, message), actions) : message;
146
- var iconDimension = ((_theme$notification5 = theme.notification) == null || (_theme$notification5 = _theme$notification5.message) == null ? void 0 : _theme$notification5.size) || 'medium';
156
+ var iconDimension = ((_theme$notification10 = theme.notification) == null || (_theme$notification10 = _theme$notification10.message) == null ? void 0 : _theme$notification10.size) || 'medium';
147
157
  var content = /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({}, theme.notification.container, global ? _extends({}, theme.notification.global.container) : {}, toast ? _extends({}, theme.notification.toast.container) : {}, {
148
158
  background: background
149
159
  // let internal box control pad
@@ -159,7 +169,9 @@ var Notification = exports.Notification = function Notification(_ref) {
159
169
  }, /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.iconContainer, icon || /*#__PURE__*/_react["default"].createElement(StatusIcon, {
160
170
  color: color,
161
171
  height: iconDimension
162
- })), /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.textContainer, /*#__PURE__*/_react["default"].createElement(TextWrapper, null, title && /*#__PURE__*/_react["default"].createElement(_Text.Text, theme.notification.title, title), message && title && direction === 'row' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, "\xA0"), message))), onClose &&
172
+ })), /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.textContainer, /*#__PURE__*/_react["default"].createElement(TextWrapper, null, title && /*#__PURE__*/_react["default"].createElement(_Text.Text, _extends({}, theme.notification.title, {
173
+ color: titleColor
174
+ }), title), message && title && direction === 'row' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, "\xA0"), message))), onClose &&
163
175
  /*#__PURE__*/
164
176
  // theme.notification.container and textContainer may both have pad,
165
177
  // 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;
@@ -8,6 +8,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
8
8
  var PropType = {};
9
9
  if (process.env.NODE_ENV !== 'production') {
10
10
  PropType = {
11
+ id: _propTypes["default"].string,
11
12
  actions: _propTypes["default"].arrayOf(_propTypes["default"].shape(_propTypes2.AnchorPropTypes)),
12
13
  global: _propTypes["default"].bool,
13
14
  title: _propTypes["default"].string,
@@ -89,7 +89,7 @@ var Pagination = exports.Pagination = /*#__PURE__*/(0, _react.forwardRef)(functi
89
89
  var numberMiddlePages;
90
90
  if (numberMiddlePagesProp < 1) {
91
91
  numberMiddlePages = 1;
92
- console.warn( // eslint-disable-next-line max-len
92
+ console.warn(// eslint-disable-next-line max-len
93
93
  "Property \"numberMiddlePages\" should not be < 1. One middle page button will be shown. Set \"numberMiddlePages\" >= 1 to remove this warning.");
94
94
  } else numberMiddlePages = numberMiddlePagesProp;
95
95
  var startingMiddlePages;
@@ -188,7 +188,9 @@ var Pagination = exports.Pagination = /*#__PURE__*/(0, _react.forwardRef)(functi
188
188
  ref: ref
189
189
  }, /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
190
190
  as: "ul"
191
- }, theme.pagination.controls), controls.map(function (control, index) {
191
+ }, theme.pagination.controls, {
192
+ cssGap: true
193
+ }), controls.map(function (control, index) {
192
194
  return (
193
195
  /*#__PURE__*/
194
196
  /* Using index as key (as opposed to a unique id) seems to
@@ -52,7 +52,10 @@ export const Custom = () => (
52
52
  <Text margin={{ bottom: 'small' }}>
53
53
  Custom Theme via theme.pagination.button
54
54
  </Text>
55
- <Pagination numberItems={237} />
55
+ <Pagination
56
+ aria-label="Pagination with custom button theme"
57
+ numberItems={237}
58
+ />
56
59
  </Box>
57
60
  <Box
58
61
  align="start"
@@ -62,7 +65,10 @@ export const Custom = () => (
62
65
  <Text margin={{ bottom: 'small' }}>
63
66
  Custom Theme via theme.pagination.button
64
67
  </Text>
65
- <Pagination numberItems={237} />
68
+ <Pagination
69
+ aria-label="Pagination with custom button theme and black background"
70
+ numberItems={237}
71
+ />
66
72
  </Box>
67
73
  </Box>
68
74
  </Grommet>
@@ -14,10 +14,12 @@ var NumberEdgePages = exports.NumberEdgePages = function NumberEdgePages() {
14
14
  pad: "small",
15
15
  gap: "medium"
16
16
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "numberEdgePages = 2 (number of pages on start/end)"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
17
+ "aria-label": "Pagination with 2 pages at the start and end",
17
18
  numberItems: 237,
18
19
  page: 10,
19
20
  numberEdgePages: 2
20
21
  })), /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "numberEdgePages = 0"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
22
+ "aria-label": "Pagination with no pages at the start and end",
21
23
  numberItems: 237,
22
24
  page: 10,
23
25
  numberEdgePages: 0
@@ -14,10 +14,12 @@ var NumberMiddlePages = exports.NumberMiddlePages = function NumberMiddlePages()
14
14
  pad: "small",
15
15
  gap: "medium"
16
16
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "numberMiddlePages = 4 (number of pages in the middle)"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
17
+ "aria-label": "Pagination with 4 pages in the middle",
17
18
  numberItems: 237,
18
19
  page: 10,
19
20
  numberMiddlePages: 4
20
21
  })), /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "numberMiddlePages = 5 (number of pages in the middle)"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
22
+ "aria-label": "Pagination with 5 pages in the middle",
21
23
  numberItems: 237,
22
24
  page: 10,
23
25
  numberMiddlePages: 5
@@ -15,13 +15,15 @@ var Simple = exports.Simple = function Simple() {
15
15
  pad: "small",
16
16
  gap: "medium"
17
17
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Default"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
18
+ "aria-label": "Pagination with default settings",
18
19
  numberItems: 237
19
20
  })), /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Box Props"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
20
21
  numberItems: 1237,
21
22
  page: 24,
22
- background: "brand",
23
+ background: "dark-1",
23
24
  pad: "medium",
24
- margin: "small"
25
+ margin: "small",
26
+ "aria-label": "Pagination with custom background and spacing"
25
27
  })))
26
28
  // </Grommet>
27
29
  );
@@ -15,12 +15,15 @@ var Size = exports.Size = function Size() {
15
15
  pad: "small",
16
16
  gap: "medium"
17
17
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Small"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
18
+ "aria-label": "Pagination with small size",
18
19
  numberItems: 237,
19
20
  size: "small"
20
21
  }), /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Medium (Default)"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
22
+ "aria-label": "Pagination with medium size",
21
23
  numberItems: 237,
22
24
  size: "medium"
23
25
  }), /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Large"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
26
+ "aria-label": "Pagination with large size",
24
27
  numberItems: 237,
25
28
  size: "large"
26
29
  }))
@@ -17,17 +17,20 @@ var Steps = exports.Steps = function Steps() {
17
17
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
18
18
  fill: "horizontal"
19
19
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Pagination with stepOptions"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
20
+ "aria-label": "Pagination with step options to change items per page",
20
21
  numberItems: 237,
21
22
  stepOptions: true
22
23
  })), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
23
24
  fill: "horizontal"
24
25
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Pagination with stepOptions and summary"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
26
+ "aria-label": "Pagination with step options and summary of items per page",
25
27
  numberItems: 237,
26
28
  stepOptions: true,
27
29
  summary: true
28
30
  })), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
29
31
  fill: "horizontal"
30
32
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Pagination with custom step sizes"), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, {
33
+ "aria-label": "Pagination with custom step sizes and summary",
31
34
  numberItems: 237,
32
35
  stepOptions: [10, 20, 30, 1000],
33
36
  summary: true