grommet 2.30.0 → 2.31.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 (63) hide show
  1. package/components/Anchor/Anchor.js +3 -2
  2. package/components/Button/Badge.js +42 -43
  3. package/components/Button/Button.js +15 -12
  4. package/components/Button/StyledButton.js +4 -2
  5. package/components/Button/StyledButtonKind.js +5 -3
  6. package/components/Button/index.d.ts +2 -0
  7. package/components/Button/propTypes.js +1 -0
  8. package/components/CheckBox/index.d.ts +1 -1
  9. package/components/Data/DataForm.js +40 -34
  10. package/components/DataView/DataView.js +1 -1
  11. package/components/DateInput/DateInput.js +2 -1
  12. package/components/FormField/FormField.js +0 -1
  13. package/components/MaskedInput/MaskedInput.js +3 -2
  14. package/components/MaskedInput/StyledMaskedInput.js +2 -1
  15. package/components/Notification/Notification.js +7 -3
  16. package/components/PageHeader/PageHeader.js +6 -4
  17. package/components/Pagination/StyledPageControl.js +3 -1
  18. package/components/Paragraph/Paragraph.js +2 -2
  19. package/components/Paragraph/stories/All.js +5 -1
  20. package/components/SelectMultiple/SelectMultiple.js +11 -10
  21. package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
  22. package/components/SelectMultiple/stories/Help.js +49 -0
  23. package/components/Text/Text.js +2 -2
  24. package/components/TextInput/StyledTextInput.js +2 -1
  25. package/components/TextInput/TextInput.js +3 -2
  26. package/es6/components/Anchor/Anchor.js +4 -3
  27. package/es6/components/Button/Badge.js +43 -44
  28. package/es6/components/Button/Button.js +16 -13
  29. package/es6/components/Button/StyledButton.js +5 -3
  30. package/es6/components/Button/StyledButtonKind.js +6 -4
  31. package/es6/components/Button/index.d.ts +2 -0
  32. package/es6/components/Button/propTypes.js +2 -1
  33. package/es6/components/CheckBox/index.d.ts +1 -1
  34. package/es6/components/Data/DataForm.js +40 -34
  35. package/es6/components/DataView/DataView.js +1 -1
  36. package/es6/components/DateInput/DateInput.js +2 -1
  37. package/es6/components/FormField/FormField.js +0 -1
  38. package/es6/components/MaskedInput/MaskedInput.js +4 -3
  39. package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
  40. package/es6/components/Notification/Notification.js +7 -3
  41. package/es6/components/PageHeader/PageHeader.js +6 -4
  42. package/es6/components/Pagination/StyledPageControl.js +3 -1
  43. package/es6/components/Paragraph/Paragraph.js +2 -2
  44. package/es6/components/Paragraph/stories/All.js +5 -1
  45. package/es6/components/SelectMultiple/SelectMultiple.js +11 -10
  46. package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
  47. package/es6/components/SelectMultiple/stories/Help.js +42 -0
  48. package/es6/components/Text/Text.js +2 -2
  49. package/es6/components/TextInput/StyledTextInput.js +2 -1
  50. package/es6/components/TextInput/TextInput.js +4 -3
  51. package/es6/themes/base.d.ts +3 -0
  52. package/es6/themes/base.js +6 -0
  53. package/es6/utils/icon.js +7 -0
  54. package/es6/utils/index.js +1 -0
  55. package/es6/utils/styles.js +10 -0
  56. package/grommet.min.js +1 -1
  57. package/grommet.min.js.map +1 -1
  58. package/package.json +30 -30
  59. package/themes/base.d.ts +3 -0
  60. package/themes/base.js +6 -0
  61. package/utils/icon.js +12 -0
  62. package/utils/index.js +6 -0
  63. package/utils/styles.js +12 -1
@@ -61,8 +61,9 @@ var Anchor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
61
61
  color: (0, _utils.normalizeColor)(color || ((_theme$anchor = theme.anchor) == null ? void 0 : (_theme$anchor$size = _theme$anchor.size) == null ? void 0 : (_theme$anchor$size2 = _theme$anchor$size[sizeProp || size]) == null ? void 0 : _theme$anchor$size2.color) || theme.anchor.color, theme)
62
62
  });
63
63
  }
64
- var first = reverse ? label : coloredIcon;
65
- var second = reverse ? coloredIcon : label;
64
+ var anchorIcon = (0, _utils.useSizedIcon)(coloredIcon, sizeProp || size, theme);
65
+ var first = reverse ? label : anchorIcon;
66
+ var second = reverse ? anchorIcon : label;
66
67
  return /*#__PURE__*/_react["default"].createElement(_StyledAnchor.StyledAnchor, _extends({}, rest, {
67
68
  ref: ref,
68
69
  "aria-label": ariaLabel || a11yTitle,
@@ -21,21 +21,13 @@ var Badge = function Badge(_ref) {
21
21
  var children = _ref.children,
22
22
  content = _ref.content;
23
23
  var theme = (0, _react.useContext)(_styledComponents.ThemeContext);
24
+ var containerRef = (0, _react.useRef)();
24
25
  var contentRef = (0, _react.useRef)();
25
26
  var stackRef = (0, _react.useRef)();
26
27
  var defaultBadgeDimension = typeof content === 'boolean' || content && content.value && typeof content.value === 'boolean' ? // empty badge should be smaller. this value was chosen as a default
27
28
  // after experimenting with various values
28
29
  (0, _utils.parseMetricToNum)(theme.button.badge.size.medium) / 2 + "px" : theme.button.badge.size.medium;
29
30
 
30
- // size should drive height, match width to height by default
31
- // allow width to grow when content is wide
32
- var _useState = (0, _react.useState)(defaultBadgeDimension),
33
- height = _useState[0],
34
- setHeight = _useState[1];
35
- var _useState2 = (0, _react.useState)(height),
36
- width = _useState2[0],
37
- setWidth = _useState2[1];
38
-
39
31
  // scale badge to fit its contents, leaving space horizontally
40
32
  // that is proportional to vertical space
41
33
  (0, _useIsomorphicLayoutEffect.useLayoutEffect)(function () {
@@ -43,26 +35,38 @@ var Badge = function Badge(_ref) {
43
35
  // can change (because pad is responsive, etc.). we want to recalculate
44
36
  // width since badge offset is reliant on its dimensions.
45
37
  var onResize = function onResize() {
46
- if (contentRef && contentRef.current) {
47
- if (typeof content === 'number' || typeof content === 'object' && content.value) {
48
- var _contentRef$current$g = contentRef.current.getBoundingClientRect(),
49
- contentHeight = _contentRef$current$g.height,
50
- contentWidth = _contentRef$current$g.width;
38
+ if (containerRef != null && containerRef.current) {
39
+ containerRef.current.style.minHeight = '';
40
+ containerRef.current.style.minWidth = '';
41
+ if (contentRef != null && contentRef.current) {
42
+ if (typeof content === 'number' || typeof content === 'object' && content.value) {
43
+ containerRef.current.style.minHeight = defaultBadgeDimension;
44
+ containerRef.current.style.minWidth = defaultBadgeDimension;
45
+ var _contentRef$current$g = contentRef.current.getBoundingClientRect(),
46
+ contentHeight = _contentRef$current$g.height,
47
+ contentWidth = _contentRef$current$g.width;
51
48
 
52
- // only adjust the width if contentHeight > 0
53
- // jest returns 0 for all getBoundingClientRect values,
54
- // so this ensures snapshots are closer to correct values
55
- if (contentHeight) {
56
- // height of content includes extra space around font from
57
- // line-height. account for this extra space with 2.5 multiplier
58
- // to add proportional horizontal space
59
- var verticalSpace = ((0, _utils.parseMetricToNum)(height) - contentHeight) * 2.5;
60
- setWidth(Math.max((0, _utils.parseMetricToNum)(width), Math.ceil(contentWidth + verticalSpace)) + "px");
49
+ // only adjust the width if contentHeight > 0
50
+ // jest returns 0 for all getBoundingClientRect values,
51
+ // so this ensures snapshots are closer to correct values
52
+ if (contentHeight) {
53
+ // height of content includes extra space around font from
54
+ // line-height. account for this extra space with 2.5 multiplier
55
+ // to add proportional horizontal space
56
+ var height = defaultBadgeDimension;
57
+ var width = defaultBadgeDimension;
58
+ var verticalSpace = ((0, _utils.parseMetricToNum)(height) - contentHeight) * 2.5;
59
+ containerRef.current.style.minHeight = height;
60
+ containerRef.current.style.minWidth = Math.max((0, _utils.parseMetricToNum)(width), Math.ceil(contentWidth + verticalSpace)) + "px";
61
+ }
62
+ } else {
63
+ // caller has provided custom JSX
64
+ containerRef.current.style.minHeight = contentRef.current.getBoundingClientRect().width;
65
+ containerRef.current.style.minWidth = contentRef.current.getBoundingClientRect().height;
61
66
  }
62
67
  } else {
63
- // caller has provided custom JSX
64
- setWidth(contentRef.current.getBoundingClientRect().width + "px");
65
- setHeight(contentRef.current.getBoundingClientRect().height + "px");
68
+ containerRef.current.style.minHeight = defaultBadgeDimension;
69
+ containerRef.current.style.minWidth = defaultBadgeDimension;
66
70
  }
67
71
  }
68
72
  };
@@ -71,26 +75,26 @@ var Badge = function Badge(_ref) {
71
75
  return function () {
72
76
  window.removeEventListener('resize', onResize);
73
77
  };
74
- }, [content, height, width]);
78
+ }, [content, defaultBadgeDimension]);
75
79
 
76
80
  // offset the badge so it overlaps content
77
81
  (0, _useIsomorphicLayoutEffect.useLayoutEffect)(function () {
78
- if (stackRef && stackRef.current) {
82
+ if (stackRef != null && stackRef.current) {
79
83
  // when badge has content, offset should be 50%.
80
84
  // when badge is empty, offset by a smaller amount to keep the badge
81
85
  // closer to the content. this value was chosen as a reasonable default
82
86
  // after testing with various grommet icons.
83
- var divisor = typeof content === 'boolean' || content && content.value === true ? 3.5 : 2;
84
- var offset = {
85
- right: "-" + Math.round((0, _utils.parseMetricToNum)(width) / divisor) + "px",
86
- top: "-" + Math.round((0, _utils.parseMetricToNum)(height) / divisor) + "px"
87
- };
87
+ var offset = typeof content === 'boolean' || content && content.value === true ? '25%' : '50%';
88
+
88
89
  // second child of Stack is the div that receives absolute positioning
89
90
  // and contains our badge content
90
- stackRef.current.children[1].style.top = offset.top;
91
- stackRef.current.children[1].style.right = offset.right;
91
+ stackRef.current.children[1].style.top = 0;
92
+ stackRef.current.children[1].style.right = 0;
93
+ // eslint-disable-next-line max-len
94
+ stackRef.current.children[1].style.transform = "translate(" + offset + ", -" + offset + ")";
95
+ stackRef.current.children[1].style.transformOrigin = '100% 0%';
92
96
  }
93
- }, [content, height, width]);
97
+ }, [content]);
94
98
  var value;
95
99
  if (typeof content === 'number') value = content;else if (typeof content === 'object') value = content.value;
96
100
  var badge;
@@ -105,18 +109,13 @@ var Badge = function Badge(_ref) {
105
109
  }, value > max ? max + "+" : value);
106
110
  }
107
111
  badge = /*#__PURE__*/_react["default"].createElement(StyledBadgeContainer, {
112
+ ref: containerRef,
108
113
  align: "center",
109
114
  background: content.background || theme.button.badge.container.background,
110
115
  flex: false,
111
- height: {
112
- min: height
113
- },
114
116
  justify: "center",
115
117
  round: true,
116
- pad: !(typeof value === 'boolean' || typeof content === 'boolean') ? theme.button.badge.container.pad : undefined,
117
- width: {
118
- min: width
119
- }
118
+ pad: !(typeof value === 'boolean' || typeof content === 'boolean') ? theme.button.badge.container.pad : undefined
120
119
  }, badge);
121
120
  // caller has provided their own JSX and we will just render that
122
121
  } else badge = /*#__PURE__*/_react["default"].createElement(_Box.Box, {
@@ -14,7 +14,7 @@ var _StyledButton = require("./StyledButton");
14
14
  var _StyledButtonKind = require("./StyledButtonKind");
15
15
  var _AnalyticsContext = require("../../contexts/AnalyticsContext");
16
16
  var _Skeleton = require("../Skeleton");
17
- var _excluded = ["active", "align", "aria-label", "badge", "color", "children", "disabled", "icon", "focusIndicator", "gap", "fill", "href", "justify", "kind", "label", "onBlur", "onClick", "onFocus", "onMouseOut", "onMouseOver", "plain", "primary", "reverse", "secondary", "selected", "size", "tip", "type", "a11yTitle", "as"];
17
+ var _excluded = ["active", "align", "aria-label", "badge", "color", "children", "disabled", "icon", "focusIndicator", "gap", "fill", "href", "justify", "kind", "label", "onBlur", "onClick", "onFocus", "onMouseOut", "onMouseOver", "pad", "plain", "primary", "reverse", "secondary", "selected", "size", "tip", "type", "a11yTitle", "as"];
18
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
20
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -137,7 +137,7 @@ var getPropertyColor = function getPropertyColor(property, paths, theme, kind, p
137
137
  return result;
138
138
  };
139
139
  var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
140
- var _theme$button$kind;
140
+ var _theme$button$kind, _theme$button2, _theme$button2$badge;
141
141
  var active = _ref.active,
142
142
  _ref$align = _ref.align,
143
143
  align = _ref$align === void 0 ? 'center' : _ref$align,
@@ -160,6 +160,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
160
160
  _onFocus = _ref.onFocus,
161
161
  onMouseOut = _ref.onMouseOut,
162
162
  onMouseOver = _ref.onMouseOver,
163
+ pad = _ref.pad,
163
164
  plain = _ref.plain,
164
165
  primary = _ref.primary,
165
166
  reverseProp = _ref.reverse,
@@ -250,14 +251,6 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
250
251
  }
251
252
  return result;
252
253
  }, [active, disabled, kind, kindObj, plain, selected]);
253
- if (skeleton) {
254
- var _theme$text, _theme$button$size;
255
- return /*#__PURE__*/_react["default"].createElement(_Skeleton.Skeleton, _extends({
256
- ref: ref,
257
- height: ((_theme$text = theme.text[size || 'medium']) == null ? void 0 : _theme$text.height) || size,
258
- a11yTitle: a11yTitle
259
- }, rest, (_theme$button$size = theme.button.size) == null ? void 0 : _theme$button$size[size || 'medium'], theme.button.skeleton));
260
- }
261
254
 
262
255
  // only used when theme does not have button.default
263
256
  var isDarkBackground = function isDarkBackground() {
@@ -299,6 +292,15 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
299
292
  color: _iconColor
300
293
  });
301
294
  }
295
+ buttonIcon = (0, _utils.useSizedIcon)(buttonIcon, size, theme);
296
+ if (skeleton) {
297
+ var _theme$text, _theme$button$size;
298
+ return /*#__PURE__*/_react["default"].createElement(_Skeleton.Skeleton, _extends({
299
+ ref: ref,
300
+ height: ((_theme$text = theme.text[size || 'medium']) == null ? void 0 : _theme$text.height) || size,
301
+ a11yTitle: a11yTitle
302
+ }, rest, (_theme$button$size = theme.button.size) == null ? void 0 : _theme$button$size[size || 'medium'], theme.button.skeleton));
303
+ }
302
304
  var reverse = reverseProp != null ? reverseProp : (_theme$button$kind = theme.button[kind]) == null ? void 0 : _theme$button$kind.reverse;
303
305
  var domTag = !as && href ? 'a' : as;
304
306
  var first = reverse ? label : buttonIcon;
@@ -329,7 +331,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
329
331
  // (!kind && icon && !label) is necessary because for old button logic,
330
332
  // if button has icon but not label, it will be considered "plain",
331
333
  // so no border or background will be applied
332
- var innerBadge = !background && !border || !kind && icon && !label;
334
+ var innerBadge = ((_theme$button2 = theme.button) == null ? void 0 : (_theme$button2$badge = _theme$button2.badge) == null ? void 0 : _theme$button2$badge.align) !== 'container' && (!background && !border || !kind && icon && !label);
333
335
  if (badgeProp && innerBadge) {
334
336
  contents = /*#__PURE__*/_react["default"].createElement(_Badge.Badge, {
335
337
  content: badgeProp
@@ -367,6 +369,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
367
369
  },
368
370
  onMouseOver: onMouseOverButton,
369
371
  onMouseOut: onMouseOutButton,
372
+ pad: pad,
370
373
  plain: plain || _react.Children.count(children) > 0,
371
374
  primary: primary,
372
375
  sizeProp: size,
@@ -401,7 +404,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
401
404
  },
402
405
  onMouseOver: onMouseOverButton,
403
406
  onMouseOut: onMouseOutButton,
404
- pad: !plain,
407
+ pad: pad || !plain,
405
408
  plain: typeof plain !== 'undefined' ? plain : _react.Children.count(children) > 0 || icon && !label,
406
409
  primary: primary,
407
410
  sizeProp: size,
@@ -77,7 +77,7 @@ var disabledButtonStyle = function disabledButtonStyle(props) {
77
77
  var StyledButton = _styledComponents["default"].button.withConfig({
78
78
  displayName: "StyledButton",
79
79
  componentId: "sc-323bzc-0"
80
- })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", " ", " ", ""], _utils.genericStyles, function (props) {
80
+ })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", " ", " ", " ", ""], _utils.genericStyles, function (props) {
81
81
  return props.plain && plainStyle(props);
82
82
  }, function (props) {
83
83
  return !props.plain && basicStyle(props);
@@ -98,7 +98,9 @@ var StyledButton = _styledComponents["default"].button.withConfig({
98
98
  }, function (props) {
99
99
  return props.hasIcon && !props.hasLabel && "\n line-height: 0;\n ";
100
100
  }, function (props) {
101
- return props.pad && props.hasIcon && !props.hasLabel && "\n padding: " + props.theme.global.edgeSize.small + ";\n ";
101
+ return props.pad === true && props.hasIcon && !props.hasLabel && "\n padding: " + props.theme.global.edgeSize.small + ";\n ";
102
+ }, function (props) {
103
+ return !props.plain && props.pad && (0, _utils.edgeStyle)('padding', props.pad, false, undefined, props.theme);
102
104
  }, function (props) {
103
105
  return props.theme.button && props.theme.button.extend;
104
106
  });
@@ -19,7 +19,7 @@ var radiusStyle = function radiusStyle(props) {
19
19
  var fontStyle = function fontStyle(props) {
20
20
  var size = props.sizeProp || 'medium';
21
21
  var data = props.theme.text[size];
22
- return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], data.size, data.height);
22
+ return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], data.size, props.hasIcon && !props.hasLabel ? 0 : data.height);
23
23
  };
24
24
  var padFromTheme = function padFromTheme(size, theme, themeObj, kind, iconOnly) {
25
25
  var _themeObj$size, _themeObj$size$size, _themeObj$size$size$i, _themeObj$size3, _themeObj$size3$size, _themeObj$size3$size$;
@@ -166,7 +166,7 @@ var fillStyle = function fillStyle(fillContainer) {
166
166
  return undefined;
167
167
  };
168
168
  var plainStyle = function plainStyle(props) {
169
- return (0, _styledComponents.css)(["outline:none;border:none;padding:0;text-align:inherit;color:inherit;", ""], props.icon && "\n > svg {\n display: flex;\n align-self: center;\n vertical-align: middle;\n }\n ");
169
+ return (0, _styledComponents.css)(["outline:none;border:none;padding:0;text-align:inherit;color:inherit;", " ", ""], props.icon && "\n > svg {\n display: flex;\n align-self: center;\n vertical-align: middle;\n }\n ", props.hasIcon && !props.hasLabel && "line-height: 0;");
170
170
  };
171
171
  var StyledButtonKind = _styledComponents["default"].button.withConfig({
172
172
  // don't let kind attribute leak to DOM
@@ -177,7 +177,7 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
177
177
  }).withConfig({
178
178
  displayName: "StyledButtonKind",
179
179
  componentId: "sc-1vhfpnt-0"
180
- })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", ""], _utils.genericStyles, function (props) {
180
+ })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", ""], _utils.genericStyles, function (props) {
181
181
  return props.plain && plainStyle(props);
182
182
  }, function (props) {
183
183
  return !props.disabled && props.active && _utils.activeStyle;
@@ -185,6 +185,8 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
185
185
  return !props.plain && basicStyle(props);
186
186
  }, function (props) {
187
187
  return !props.plain && kindStyle(props);
188
+ }, function (props) {
189
+ return !props.plain && props.pad && (0, _utils.edgeStyle)('padding', props.pad, false, undefined, props.theme);
188
190
  }, function (props) {
189
191
  return !props.plain && props.align && "\n text-align: " + props.align + ";\n ";
190
192
  }, function (props) {
@@ -10,6 +10,7 @@ import {
10
10
  HoverIndicatorType,
11
11
  MarginType,
12
12
  Omit,
13
+ PadType,
13
14
  PolymorphicType,
14
15
  } from '../../utils';
15
16
 
@@ -60,6 +61,7 @@ export interface ButtonProps {
60
61
  icon?: JSX.Element;
61
62
  kind?: string;
62
63
  label?: React.ReactNode;
64
+ pad?: PadType;
63
65
  plain?: boolean;
64
66
  primary?: boolean;
65
67
  reverse?: boolean;
@@ -28,6 +28,7 @@ if (process.env.NODE_ENV !== 'production') {
28
28
  justify: _propTypes["default"].oneOf(['around', 'between', 'center', 'end', 'evenly', 'start', 'stretch']),
29
29
  label: _propTypes["default"].node,
30
30
  onClick: _propTypes["default"].func,
31
+ pad: _generalPropTypes.padPropType,
31
32
  plain: _propTypes["default"].bool,
32
33
  primary: _propTypes["default"].bool,
33
34
  reverse: _propTypes["default"].bool,
@@ -4,7 +4,7 @@ import { A11yTitleType, PadType } from '../../utils';
4
4
  export interface CheckBoxProps {
5
5
  a11yTitle?: A11yTitleType;
6
6
  checked?: boolean;
7
- children?: Function;
7
+ children?: React.ReactNode | Function;
8
8
  disabled?: boolean;
9
9
  fill?: boolean;
10
10
  id?: string;
@@ -266,43 +266,49 @@ var DataForm = function DataForm(_ref) {
266
266
  (0, _react.useEffect)(function () {
267
267
  return setFormValue(viewToFormValue(view));
268
268
  }, [view]);
269
+ var content = children;
270
+ if (footer !== false || pad) {
271
+ content = /*#__PURE__*/_react["default"].createElement(_Box.Box, {
272
+ fill: "vertical"
273
+ }, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
274
+ flex: true,
275
+ overflow: "auto",
276
+ pad: {
277
+ horizontal: pad,
278
+ top: pad
279
+ }
280
+ }, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
281
+ flex: false
282
+ }, content)), footer !== false && updateOn === 'submit' && /*#__PURE__*/_react["default"].createElement(_Footer.Footer, {
283
+ flex: false,
284
+ margin: {
285
+ top: 'small'
286
+ },
287
+ pad: {
288
+ horizontal: pad,
289
+ bottom: pad
290
+ },
291
+ gap: "small"
292
+ }, /*#__PURE__*/_react["default"].createElement(_Button.Button, {
293
+ label: format({
294
+ id: 'dataForm.submit',
295
+ messages: messages == null ? void 0 : messages.dataForm
296
+ }),
297
+ type: "submit",
298
+ primary: true
299
+ }), /*#__PURE__*/_react["default"].createElement(HideableButton, _extends({
300
+ label: format({
301
+ id: 'dataForm.reset',
302
+ messages: messages == null ? void 0 : messages.dataForm
303
+ }),
304
+ type: "reset",
305
+ onClick: onReset
306
+ }, !changed ? hideButtonProps : {}))));
307
+ }
269
308
  return /*#__PURE__*/_react["default"].createElement(MaxForm, _extends({}, rest, {
270
309
  value: formValue,
271
310
  onSubmit: updateOn === 'submit' ? onSubmit : undefined,
272
311
  onChange: onChange
273
- }), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
274
- fill: "vertical"
275
- }, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
276
- flex: true,
277
- overflow: "auto",
278
- pad: {
279
- horizontal: pad,
280
- top: pad
281
- }
282
- }, children), footer !== false && updateOn === 'submit' && /*#__PURE__*/_react["default"].createElement(_Footer.Footer, {
283
- flex: false,
284
- margin: {
285
- top: 'small'
286
- },
287
- pad: {
288
- horizontal: pad,
289
- bottom: pad
290
- },
291
- gap: "small"
292
- }, /*#__PURE__*/_react["default"].createElement(_Button.Button, {
293
- label: format({
294
- id: 'dataForm.submit',
295
- messages: messages == null ? void 0 : messages.dataForm
296
- }),
297
- type: "submit",
298
- primary: true
299
- }), /*#__PURE__*/_react["default"].createElement(HideableButton, _extends({
300
- label: format({
301
- id: 'dataForm.reset',
302
- messages: messages == null ? void 0 : messages.dataForm
303
- }),
304
- type: "reset",
305
- onClick: onReset
306
- }, !changed ? hideButtonProps : {})))));
312
+ }), content);
307
313
  };
308
314
  exports.DataForm = DataForm;
@@ -50,7 +50,7 @@ var DataView = function DataView(_ref) {
50
50
  id: id,
51
51
  name: "_view",
52
52
  showSelectedInline: true,
53
- placeholder: noForm ? 'Select view ...' : undefined,
53
+ placeholder: noForm ? 'Select view' : undefined,
54
54
  options: names,
55
55
  value: view == null ? void 0 : view.name
56
56
  }, rest));
@@ -40,6 +40,7 @@ var getReference = function getReference(value) {
40
40
  return adjustedDate;
41
41
  };
42
42
  var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
43
+ var _theme$icon, _theme$dateInput$icon;
43
44
  var buttonProps = _ref.buttonProps,
44
45
  calendarProps = _ref.calendarProps,
45
46
  defaultValue = _ref.defaultValue,
@@ -64,7 +65,7 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
64
65
  var announce = (0, _react.useContext)(_AnnounceContext.AnnounceContext);
65
66
  var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
66
67
  formatMessage = _useContext.format;
67
- var iconSize = theme.dateInput.icon && theme.dateInput.icon.size || 'medium';
68
+ var iconSize = ((_theme$icon = theme.icon) == null ? void 0 : _theme$icon.matchSize) && rest.size || ((_theme$dateInput$icon = theme.dateInput.icon) == null ? void 0 : _theme$dateInput$icon.size) || 'medium';
68
69
  var _useContext2 = (0, _react.useContext)(_Form.FormContext),
69
70
  useFormInput = _useContext2.useFormInput;
70
71
  var ref = (0, _utils.useForwardedRef)(refArg);
@@ -338,7 +338,6 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
338
338
  return /*#__PURE__*/_react["default"].createElement(FormFieldBox, _extends({
339
339
  ref: formFieldRef,
340
340
  className: className,
341
- flex: false,
342
341
  background: outerBackground,
343
342
  margin: abut ? abutMargin : margin || _extends({}, formFieldTheme.margin)
344
343
  }, outerProps, {
@@ -326,12 +326,13 @@ var MaskedInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
326
326
  return item.placeholder || item.fixed;
327
327
  }).join('');
328
328
  };
329
+ var maskedInputIcon = (0, _utils.useSizedIcon)(icon, rest.size, theme);
329
330
  return /*#__PURE__*/_react["default"].createElement(_StyledMaskedInput.StyledMaskedInputContainer, {
330
331
  plain: plain
331
- }, icon && /*#__PURE__*/_react["default"].createElement(_StyledMaskedInput.StyledIcon, {
332
+ }, maskedInputIcon && /*#__PURE__*/_react["default"].createElement(_StyledMaskedInput.StyledIcon, {
332
333
  reverse: reverse,
333
334
  theme: theme
334
- }, icon), /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
335
+ }, maskedInputIcon), /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
335
336
  onEsc: onEsc,
336
337
  onTab: showDrop ? function () {
337
338
  return setShowDrop(false);
@@ -4,6 +4,7 @@ exports.__esModule = true;
4
4
  exports.StyledMaskedInputContainer = exports.StyledMaskedInput = exports.StyledIcon = void 0;
5
5
  var _styledComponents = _interopRequireDefault(require("styled-components"));
6
6
  var _utils = require("../../utils");
7
+ var _styles = require("../../utils/styles");
7
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
9
  var StyledMaskedInput = _styledComponents["default"].input.withConfig({
9
10
  displayName: "StyledMaskedInput",
@@ -11,7 +12,7 @@ var StyledMaskedInput = _styledComponents["default"].input.withConfig({
11
12
  })(["", " ", " ", " ", " ", " ", ";"], _utils.inputStyle, function (props) {
12
13
  return props.plain && _utils.plainInputStyle;
13
14
  }, function (props) {
14
- return props.icon && (props.reverse ? "padding-right: " + props.theme.global.edgeSize.large + ";" : "padding-left: " + props.theme.global.edgeSize.large + ";");
15
+ return props.icon && _styles.inputPadForIcon;
15
16
  }, function (props) {
16
17
  return props.disabled && (0, _utils.disabledStyle)(props.theme.maskedInput.disabled && props.theme.maskedInput.disabled.opacity);
17
18
  }, function (props) {
@@ -56,7 +56,7 @@ var NotificationAnchor = (0, _styledComponents["default"])(_Anchor.Anchor).withC
56
56
  componentId: "sc-1yq09yz-0"
57
57
  })(["white-space:nowrap;"]);
58
58
  var Notification = function Notification(_ref) {
59
- var _theme$notification, _theme$notification2, _theme$notification2$, _theme$notification2$2, _theme$notification3, _theme$notification3$, _theme$notification4, _theme$notification4$, _theme$notification4$2;
59
+ var _theme$notification, _theme$notification2, _theme$notification2$, _theme$notification2$2, _theme$notification3, _theme$notification3$, _theme$notification4, _theme$notification4$, _theme$notification4$2, _theme$notification5, _theme$notification5$;
60
60
  var actionsProp = _ref.actions,
61
61
  messageProp = _ref.message,
62
62
  onClose = _ref.onClose,
@@ -139,6 +139,7 @@ var Notification = function Notification(_ref) {
139
139
  right: 'xsmall'
140
140
  }
141
141
  }, message), actions) : message;
142
+ var iconDimension = ((_theme$notification5 = theme.notification) == null ? void 0 : (_theme$notification5$ = _theme$notification5.message) == null ? void 0 : _theme$notification5$.size) || 'medium';
142
143
  var content = /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({}, theme.notification.container, global ? _extends({}, theme.notification.global.container) : {}, toast ? _extends({}, theme.notification.toast.container) : {}, {
143
144
  background: background
144
145
  // let internal box control pad
@@ -152,7 +153,8 @@ var Notification = function Notification(_ref) {
152
153
  pad: textPad,
153
154
  flex: true
154
155
  }, /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.iconContainer, icon || /*#__PURE__*/_react["default"].createElement(StatusIcon, {
155
- color: color
156
+ color: color,
157
+ height: iconDimension
156
158
  })), /*#__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 &&
157
159
  /*#__PURE__*/
158
160
  // theme.notification.container and textContainer may both have pad,
@@ -161,7 +163,9 @@ var Notification = function Notification(_ref) {
161
163
  pad: closeButtonPad
162
164
  }, /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.textContainer, /*#__PURE__*/_react["default"].createElement(_Button.Button, {
163
165
  icon: /*#__PURE__*/_react["default"].createElement(CloseIcon, {
164
- color: closeIconColor
166
+ color: closeIconColor,
167
+ height: iconDimension,
168
+ width: iconDimension
165
169
  }),
166
170
  onClick: close,
167
171
  hoverIndicator: true,
@@ -15,9 +15,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
16
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
17
17
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
- var sizeStyle = function sizeStyle(size, feature, theme) {
19
- var _ref, _theme$pageHeader$siz;
20
- var style = _extends({}, theme.pageHeader[feature], (_ref = size && ((_theme$pageHeader$siz = theme.pageHeader.size[size]) == null ? void 0 : _theme$pageHeader$siz[feature])) != null ? _ref : theme.pageHeader[feature]);
18
+ var sizeStyle = function sizeStyle(size, feature, theme, breakpoint) {
19
+ var _ref, _theme$pageHeader$siz, _theme$global$breakpo, _theme$global$breakpo2;
20
+ var style = _extends({}, theme.pageHeader[feature], (_ref = size && ((_theme$pageHeader$siz = theme.pageHeader.size[size]) == null ? void 0 : _theme$pageHeader$siz[feature])) != null ? _ref : theme.pageHeader[feature], (!size || size === 'medium') && feature === 'subtitle' && ((_theme$global$breakpo = theme.global.breakpoints[breakpoint]) == null ? void 0 : _theme$global$breakpo.value) <= ((_theme$global$breakpo2 = theme.global.breakpoints.small) == null ? void 0 : _theme$global$breakpo2.value) && {
21
+ size: 'medium'
22
+ });
21
23
  return style;
22
24
  };
23
25
  var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
@@ -59,7 +61,7 @@ var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
59
61
  gridArea: "title"
60
62
  }, typeof title === 'string' ? /*#__PURE__*/_react["default"].createElement(_Heading.Heading, sizeStyle(size, 'title', theme), title) : title), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
61
63
  gridArea: "subtitle"
62
- }, typeof subtitle === 'string' ? /*#__PURE__*/_react["default"].createElement(_Paragraph.Paragraph, sizeStyle(size, 'subtitle', theme), subtitle) : subtitle), /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
64
+ }, typeof subtitle === 'string' ? /*#__PURE__*/_react["default"].createElement(_Paragraph.Paragraph, sizeStyle(size, 'subtitle', theme, breakpoint), subtitle) : subtitle), /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
63
65
  gridArea: "actions"
64
66
  }, actionsProps), actions)));
65
67
  });
@@ -11,7 +11,9 @@ var sizeStyle = function sizeStyle(props) {
11
11
  return style ? {
12
12
  content: {
13
13
  fontSize: style.font && style.font.size,
14
- lineHeight: style.font && style.font.height
14
+ // fix for safari, apply line-height 0 on next/previous
15
+ // icon-only buttons
16
+ lineHeight: style.font && props.hasLabel ? style.font.height : 0
15
17
  },
16
18
  container: {
17
19
  height: style.height,
@@ -37,9 +37,9 @@ var Paragraph = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
37
37
  colorProp: color,
38
38
  fillProp: fill,
39
39
  size: size
40
- }, rest), /*#__PURE__*/_react["default"].createElement(_TextContext.TextContext.Provider, {
40
+ }, rest), children !== undefined ? /*#__PURE__*/_react["default"].createElement(_TextContext.TextContext.Provider, {
41
41
  value: textContextValue
42
- }, children));
42
+ }, children) : undefined);
43
43
  });
44
44
  exports.Paragraph = Paragraph;
45
45
  Paragraph.displayName = 'Paragraph';
@@ -17,7 +17,11 @@ var All = function All() {
17
17
  color: "status-critical"
18
18
  }, "This is an error message."), /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, {
19
19
  fill: true
20
- }, "This is a full-width paragraph, using the \"fill\" property:", ' ', paragraphFiller));
20
+ }, "This is a full-width paragraph, using the \"fill\" property:", ' ', paragraphFiller), /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, {
21
+ dangerouslySetInnerHTML: {
22
+ __html: 'This is a dangerouslySetInnerHTML!'
23
+ }
24
+ }));
21
25
  };
22
26
  exports.All = All;
23
27
  var _default = {
@@ -276,6 +276,16 @@ var SelectMultiple = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
276
276
  return undefined;
277
277
  }, [labelKey, messages, format, optionIndexesInValue, allOptions, selectValue]);
278
278
  var iconColor = (0, _utils2.getIconColor)(theme);
279
+ var displaySelectIcon = SelectIcon && /*#__PURE__*/_react["default"].createElement(_Box.Box, {
280
+ alignSelf: "center",
281
+ margin: theme.select.icons.margin,
282
+ width: {
283
+ min: 'auto'
284
+ }
285
+ }, /*#__PURE__*/(0, _react.isValidElement)(SelectIcon) ? SelectIcon : /*#__PURE__*/_react["default"].createElement(SelectIcon, {
286
+ color: iconColor,
287
+ size: size
288
+ }));
279
289
  var dropContent = /*#__PURE__*/_react["default"].createElement(_SelectMultipleContainer.SelectMultipleContainer, {
280
290
  allOptions: allOptions,
281
291
  disabled: disabled,
@@ -283,6 +293,7 @@ var SelectMultiple = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
283
293
  dropHeight: dropHeight,
284
294
  emptySearchMessage: emptySearchMessage,
285
295
  help: help,
296
+ icon: displaySelectIcon,
286
297
  id: id,
287
298
  labelKey: labelKey,
288
299
  limit: limit,
@@ -325,16 +336,6 @@ var SelectMultiple = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
325
336
  dropContent: dropContent,
326
337
  theme: theme
327
338
  };
328
- var displaySelectIcon = SelectIcon && /*#__PURE__*/_react["default"].createElement(_Box.Box, {
329
- alignSelf: "center",
330
- margin: theme.select.icons.margin,
331
- width: {
332
- min: 'auto'
333
- }
334
- }, /*#__PURE__*/(0, _react.isValidElement)(SelectIcon) ? SelectIcon : /*#__PURE__*/_react["default"].createElement(SelectIcon, {
335
- color: iconColor,
336
- size: size
337
- }));
338
339
  return /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
339
340
  onDown: onRequestOpen,
340
341
  onUp: onRequestOpen