grommet 2.41.0 → 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 (117) 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/Calendar/Calendar.js +90 -56
  9. package/components/Calendar/StyledCalendar.js +89 -7
  10. package/components/Calendar/utils.js +16 -2
  11. package/components/Carousel/Carousel.js +1 -1
  12. package/components/Chart/Chart.js +3 -3
  13. package/components/CheckBox/CheckBox.js +3 -2
  14. package/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
  15. package/components/Clock/Digital.js +1 -1
  16. package/components/Data/stories/Infinite.js +2 -2
  17. package/components/Data/stories/OnSelect.js +2 -2
  18. package/components/Data/stories/SpaceX.js +2 -2
  19. package/components/Data/stories/StarWars.js +1 -1
  20. package/components/DataFilter/DataFilter.js +1 -1
  21. package/components/DataSort/DataSort.js +46 -14
  22. package/components/DataSort/stories/Simple.js +10 -1
  23. package/components/DataTable/Body.js +14 -8
  24. package/components/DataTable/GroupedBody.js +3 -3
  25. package/components/DataTable/buildState.js +5 -1
  26. package/components/DataTable/stories/SpaceX.js +2 -2
  27. package/components/DataTable/stories/SpaceXUngrouped.js +1 -1
  28. package/components/FileInput/index.d.ts +2 -3
  29. package/components/Layer/Layer.js +1 -1
  30. package/components/Layer/index.d.ts +2 -0
  31. package/components/List/List.js +18 -12
  32. package/components/Meter/Circle.js +2 -2
  33. package/components/Notification/Notification.js +18 -6
  34. package/components/Notification/index.d.ts +1 -0
  35. package/components/Notification/propTypes.js +1 -0
  36. package/components/Pagination/Pagination.js +4 -2
  37. package/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  38. package/components/Select/Select.js +7 -3
  39. package/components/Select/SelectContainer.js +41 -34
  40. package/components/Select/index.d.ts +1 -1
  41. package/components/Select/utils.js +13 -2
  42. package/components/SelectMultiple/SelectMultiple.js +10 -0
  43. package/components/SelectMultiple/SelectMultipleContainer.js +28 -2
  44. package/components/SelectMultiple/SelectMultipleValue.js +14 -1
  45. package/components/SkipLinks/index.d.ts +1 -0
  46. package/components/SkipLinks/propTypes.js +1 -0
  47. package/components/Tab/Tab.js +1 -1
  48. package/components/Tag/Tag.js +11 -7
  49. package/components/ToggleGroup/StyledToggleGroup.js +12 -5
  50. package/components/ToggleGroup/ToggleGroup.js +21 -10
  51. package/components/WorldMap/WorldMap.js +1 -1
  52. package/es6/components/AccordionPanel/AccordionPanel.js +2 -9
  53. package/es6/components/Box/Box.js +1 -1
  54. package/es6/components/Box/StyledBox.js +1 -6
  55. package/es6/components/Box/index.d.ts +1 -0
  56. package/es6/components/Box/propTypes.js +1 -0
  57. package/es6/components/Button/Button.js +1 -0
  58. package/es6/components/Button/StyledButton.js +4 -3
  59. package/es6/components/Calendar/Calendar.js +89 -56
  60. package/es6/components/Calendar/StyledCalendar.js +90 -8
  61. package/es6/components/Calendar/utils.js +15 -1
  62. package/es6/components/Carousel/Carousel.js +1 -1
  63. package/es6/components/Chart/Chart.js +3 -3
  64. package/es6/components/CheckBox/CheckBox.js +3 -2
  65. package/es6/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
  66. package/es6/components/Clock/Digital.js +1 -1
  67. package/es6/components/Data/stories/Infinite.js +2 -2
  68. package/es6/components/Data/stories/OnSelect.js +2 -2
  69. package/es6/components/Data/stories/SpaceX.js +2 -2
  70. package/es6/components/Data/stories/StarWars.js +1 -1
  71. package/es6/components/DataFilter/DataFilter.js +1 -1
  72. package/es6/components/DataSort/DataSort.js +46 -14
  73. package/es6/components/DataSort/stories/Simple.js +10 -1
  74. package/es6/components/DataTable/Body.js +14 -8
  75. package/es6/components/DataTable/GroupedBody.js +3 -3
  76. package/es6/components/DataTable/buildState.js +5 -1
  77. package/es6/components/DataTable/stories/SpaceX.js +2 -2
  78. package/es6/components/DataTable/stories/SpaceXUngrouped.js +1 -1
  79. package/es6/components/FileInput/index.d.ts +2 -3
  80. package/es6/components/Layer/Layer.js +1 -1
  81. package/es6/components/Layer/index.d.ts +2 -0
  82. package/es6/components/List/List.js +18 -12
  83. package/es6/components/Meter/Circle.js +2 -2
  84. package/es6/components/Notification/Notification.js +18 -6
  85. package/es6/components/Notification/index.d.ts +1 -0
  86. package/es6/components/Notification/propTypes.js +1 -0
  87. package/es6/components/Pagination/Pagination.js +4 -2
  88. package/es6/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  89. package/es6/components/Select/Select.js +8 -4
  90. package/es6/components/Select/SelectContainer.js +41 -34
  91. package/es6/components/Select/index.d.ts +1 -1
  92. package/es6/components/Select/utils.js +15 -3
  93. package/es6/components/SelectMultiple/SelectMultiple.js +10 -0
  94. package/es6/components/SelectMultiple/SelectMultipleContainer.js +28 -2
  95. package/es6/components/SelectMultiple/SelectMultipleValue.js +14 -1
  96. package/es6/components/SkipLinks/index.d.ts +1 -0
  97. package/es6/components/SkipLinks/propTypes.js +1 -0
  98. package/es6/components/Tab/Tab.js +1 -1
  99. package/es6/components/Tag/Tag.js +11 -7
  100. package/es6/components/ToggleGroup/StyledToggleGroup.js +12 -5
  101. package/es6/components/ToggleGroup/ToggleGroup.js +22 -11
  102. package/es6/components/WorldMap/WorldMap.js +1 -1
  103. package/es6/themes/base.d.ts +204 -6
  104. package/es6/themes/base.js +165 -1
  105. package/es6/utils/background.js +1 -1
  106. package/es6/utils/index.js +2 -1
  107. package/es6/utils/styles.js +8 -0
  108. package/es6/utils/useId.js +16 -0
  109. package/grommet.min.js +1 -1
  110. package/grommet.min.js.map +1 -1
  111. package/package.json +33 -33
  112. package/themes/base.d.ts +204 -6
  113. package/themes/base.js +165 -1
  114. package/utils/background.js +1 -1
  115. package/utils/index.js +6 -0
  116. package/utils/styles.js +9 -1
  117. package/utils/useId.js +19 -0
@@ -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 };
@@ -402,6 +402,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
402
402
  defaultCursor: disabled === true || undefined,
403
403
  focusIndicator: false,
404
404
  id: id ? id + "__input" : undefined,
405
+ inert: "" // revisit for React 19
406
+ ,
405
407
  name: name,
406
408
  width: "100%"
407
409
  }, rest, {
@@ -426,6 +428,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
426
428
  type: "text",
427
429
  name: name,
428
430
  id: id ? id + "__input" : undefined,
431
+ inert: "" // revisit for React 19
432
+ ,
429
433
  value: inputValue,
430
434
  ref: inputRef,
431
435
  readOnly: true
@@ -435,6 +439,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
435
439
  a11yTitle: ariaLabel || a11yTitle,
436
440
  disabled: disabled,
437
441
  id: id,
442
+ inert: "" // revisit for React 19
443
+ ,
438
444
  name: name,
439
445
  ref: inputRef,
440
446
  placeholder: placeholder || 'Select',
@@ -461,6 +467,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
461
467
  type: "text",
462
468
  name: name,
463
469
  id: id ? id + "__input" : undefined,
470
+ inert: "" // revisit for React 19
471
+ ,
464
472
  value: inputValue,
465
473
  ref: inputRef,
466
474
  readOnly: true
@@ -468,6 +476,8 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
468
476
  a11yTitle: ariaLabel || a11yTitle,
469
477
  disabled: disabled,
470
478
  id: id,
479
+ inert: "" // revisit for React 19
480
+ ,
471
481
  name: name,
472
482
  ref: inputRef,
473
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;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  export interface SkipLinksProps {
4
+ id?: string;
4
5
  children: React.ReactNode;
5
6
  messages?: { skipTo?: string };
6
7
  }
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
2
2
  var PropType = {};
3
3
  if (process.env.NODE_ENV !== 'production') {
4
4
  PropType = {
5
+ id: PropTypes.string,
5
6
  children: PropTypes.node.isRequired,
6
7
  messages: PropTypes.shape({
7
8
  skipTo: PropTypes.string
@@ -89,7 +89,7 @@ var Tab = /*#__PURE__*/forwardRef(function (_ref, ref) {
89
89
  }
90
90
  };
91
91
  if (active && disabled) {
92
- console.warn( // eslint-disable-next-line max-len
92
+ console.warn(// eslint-disable-next-line max-len
93
93
  "Warning: Tab props 'active' and 'disabled' have both been set to TRUE on the same Tab resulting in an interesting Tab state. Is this your intent?");
94
94
  }
95
95
  if (!plain) {
@@ -9,10 +9,11 @@ import { Text } from '../Text';
9
9
  import { StyledRemoveButton, StyledTagButton } from './StyledTag';
10
10
  import { useThemeValue } from '../../utils/useThemeValue';
11
11
  var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
12
- var _theme$tag$icons, _theme$tag$size, _theme$tag$size2, _theme$tag$size3, _theme$tag$size4;
12
+ var _theme$tag$icons, _theme$tag$size, _theme$tag$size2, _theme$tag$size3, _theme$tag$size4, _theme$tag$size5;
13
13
  var name = _ref.name,
14
14
  value = _ref.value,
15
- size = _ref.size,
15
+ _ref$size = _ref.size,
16
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
16
17
  onRemove = _ref.onRemove,
17
18
  onClick = _ref.onClick,
18
19
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
@@ -44,6 +45,11 @@ var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
44
45
  if (onClick && onRemove) {
45
46
  console.warn('Tag cannot combine "onClick" and "onRemove".');
46
47
  }
48
+ var removeProps = !theme.tag.remove.kind ? {
49
+ plain: true,
50
+ hoverIndicator: true,
51
+ focusIndicator: true
52
+ } : {};
47
53
  return onRemove || !onClick ? /*#__PURE__*/React.createElement(Box, _extends({
48
54
  flex: false,
49
55
  direction: "row",
@@ -51,13 +57,11 @@ var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
51
57
  min: 'min-content'
52
58
  }
53
59
  }, containerProps), contents, onRemove && /*#__PURE__*/React.createElement(StyledRemoveButton, _extends({
54
- onClick: onRemove,
55
- plain: true,
56
- hoverIndicator: true,
57
- focusIndicator: true,
60
+ onClick: onRemove
61
+ }, removeProps, {
58
62
  icon: /*#__PURE__*/React.createElement(RemoveIcon, (_theme$tag$size3 = theme.tag.size) == null || (_theme$tag$size3 = _theme$tag$size3[size]) == null ? void 0 : _theme$tag$size3.icon),
59
63
  round: ((_theme$tag$size4 = theme.tag.size) == null || (_theme$tag$size4 = _theme$tag$size4[size]) == null ? void 0 : _theme$tag$size4.round) || theme.tag.round
60
- }, theme.tag.remove, passThemeFlag))) : /*#__PURE__*/React.createElement(StyledTagButton, _extends({
64
+ }, theme.tag.remove, (_theme$tag$size5 = theme.tag.size) == null || (_theme$tag$size5 = _theme$tag$size5[size]) == null ? void 0 : _theme$tag$size5.remove, passThemeFlag))) : /*#__PURE__*/React.createElement(StyledTagButton, _extends({
61
65
  flex: false,
62
66
  plain: true,
63
67
  onClick: onClick,
@@ -18,14 +18,21 @@ var adjustPad = function adjustPad(value, theme) {
18
18
  export var StyledButton = styled(Button).withConfig({
19
19
  displayName: "StyledToggleGroup__StyledButton",
20
20
  componentId: "sc-13k5sx8-0"
21
- })(["border-radius:0;border:none;", ";", " &:hover{border:none;box-shadow:none;}"], function (props) {
22
- return roundStyle(props.round, false, props.theme);
21
+ })(["", " ", ";", " &:hover{", "}"], function (props) {
22
+ return !props.kind && "border: none;";
23
23
  }, function (props) {
24
- var _props$theme, _props$theme2, _props$theme3, _props$theme4;
24
+ return !props.kind && ['border-radius: 0;', props.round && roundStyle(props.round, false, props.theme)];
25
+ }, function (props) {
26
+ var _props$theme, _props$theme2, _props$theme3, _props$theme4, _props$theme5;
25
27
  var themePad = props.icon && !props.label && (_props$theme = props.theme) != null && (_props$theme = _props$theme.toggleGroup) != null && (_props$theme = _props$theme.button) != null && (_props$theme = _props$theme.iconOnly) != null && _props$theme.pad ? (_props$theme2 = props.theme) == null || (_props$theme2 = _props$theme2.toggleGroup) == null || (_props$theme2 = _props$theme2.button) == null || (_props$theme2 = _props$theme2.iconOnly) == null ? void 0 : _props$theme2.pad : (_props$theme3 = props.theme) == null || (_props$theme3 = _props$theme3.toggleGroup.button) == null ? void 0 : _props$theme3.pad;
26
28
 
27
29
  // adjust pad for "kind" themes to align with how "kind" themes
28
30
  // manages this calculation
29
- var pad = (_props$theme4 = props.theme) != null && (_props$theme4 = _props$theme4.button) != null && _props$theme4["default"] ? adjustPad(themePad, props.theme) : themePad;
30
- return edgeStyle('padding', pad, false, undefined, props.theme);
31
+ var pad = (_props$theme4 = props.theme) != null && (_props$theme4 = _props$theme4.button) != null && _props$theme4["default"] && (_props$theme5 = props.theme) != null && (_props$theme5 = _props$theme5.button) != null && _props$theme5.intelligentPad ? adjustPad(themePad, props.theme) : themePad;
32
+ return !props.kind && edgeStyle('padding', pad, false, undefined, props.theme);
33
+ }, function (props) {
34
+ return (
35
+ // remove hover style from StyledButton/StyledButtonKind theme
36
+ !props.kind && "border: none;\n box-shadow: none;"
37
+ );
31
38
  });
@@ -1,7 +1,7 @@
1
1
  var _excluded = ["defaultValue", "multiple", "options", "onToggle", "value"];
2
2
  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); }
3
3
  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; }
4
- import React, { useCallback, useState, useRef } from 'react';
4
+ import React, { useCallback, useState, useRef, useMemo } from 'react';
5
5
  import { Box } from '../Box';
6
6
  import { Keyboard } from '../Keyboard';
7
7
  import { ToggleGroupPropTypes } from './propTypes';
@@ -93,6 +93,11 @@ var ToggleGroup = function ToggleGroup(_ref2) {
93
93
  adjustedEvent.value = nextValue;
94
94
  setValue(adjustedEvent);
95
95
  };
96
+
97
+ // if caller defines a button "kind", respect that kind style
98
+ var kind = useMemo(function () {
99
+ return theme.toggleGroup.button.kind;
100
+ }, [theme.toggleGroup.button]);
96
101
  return /*#__PURE__*/React.createElement(Keyboard, {
97
102
  onUp: onPrevious,
98
103
  onDown: onNext,
@@ -127,25 +132,31 @@ var ToggleGroup = function ToggleGroup(_ref2) {
127
132
  optionValue = option;
128
133
  }
129
134
  var active = Array.isArray(value) ? !!value.includes(optionValue) : value === optionValue;
130
- var round = 0;
131
- // round corners of first and last buttons to match container
132
- if (typeof theme.toggleGroup.container.round === 'string' && (index === 0 || index === options.length - 1)) {
133
- round = {
134
- corner: index === 0 ? 'left' : 'right',
135
- size: theme.toggleGroup.container.round
136
- };
135
+ var round;
136
+ if (!kind) {
137
+ var _theme$toggleGroup$bu;
138
+ if ((_theme$toggleGroup$bu = theme.toggleGroup.button.border) != null && _theme$toggleGroup$bu.radius) {
139
+ round = theme.toggleGroup.button.border.radius;
140
+ } else if (typeof theme.toggleGroup.container.round === 'string' && (index === 0 || index === options.length - 1)) {
141
+ // round corners of first and last buttons to match container
142
+ round = {
143
+ corner: index === 0 ? 'left' : 'right',
144
+ size: theme.toggleGroup.container.round
145
+ };
146
+ } else round = 0;
137
147
  }
138
148
  return /*#__PURE__*/React.createElement(Box, {
139
- border: index < options.length - 1 ? {
149
+ border: index < options.length - 1 && theme.toggleGroup.divider ? {
140
150
  side: 'right',
141
151
  color: theme.toggleGroup.divider.color
142
152
  } : undefined,
143
153
  key: optionValue || index
144
154
  }, /*#__PURE__*/React.createElement(StyledButton, _extends({
145
155
  active: active,
146
- "aria-pressed": multiple && active,
147
- "aria-checked": !multiple && active,
156
+ "aria-pressed": multiple ? active : undefined,
157
+ "aria-checked": !multiple ? active : undefined,
148
158
  icon: icon,
159
+ kind: kind,
149
160
  label: label,
150
161
  tip: tip,
151
162
  onClick: function onClick(event) {
@@ -321,7 +321,7 @@ var WorldMap = /*#__PURE__*/forwardRef(function (_ref5, ref) {
321
321
  }, active);
322
322
  }
323
323
  if (content && targets[index]) {
324
- placesContent.push( /*#__PURE__*/React.createElement(Drop, _extends({
324
+ placesContent.push(/*#__PURE__*/React.createElement(Drop, _extends({
325
325
  key: key || name
326
326
  }, dropProps, {
327
327
  target: targets[index]