grommet 2.29.1 → 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 (197) hide show
  1. package/components/Anchor/Anchor.js +12 -5
  2. package/components/Anchor/StyledAnchor.js +6 -3
  3. package/components/Button/Badge.js +42 -43
  4. package/components/Button/Button.js +21 -14
  5. package/components/Button/StyledButton.js +4 -2
  6. package/components/Button/StyledButtonKind.js +25 -9
  7. package/components/Button/index.d.ts +2 -0
  8. package/components/Button/propTypes.js +1 -0
  9. package/components/Calendar/Calendar.js +14 -6
  10. package/components/CheckBox/index.d.ts +1 -1
  11. package/components/Data/DataForm.js +97 -26
  12. package/components/Data/stories/Cards.js +1 -1
  13. package/components/Data/stories/Complex.js +84 -0
  14. package/components/Data/stories/Controlled.js +1 -1
  15. package/components/Data/stories/DataTable.js +11 -4
  16. package/components/Data/stories/Infinite.js +1 -1
  17. package/components/Data/stories/Inline.js +7 -2
  18. package/components/Data/stories/List.js +1 -1
  19. package/components/Data/stories/Simple.js +1 -1
  20. package/components/Data/stories/SpaceX.js +1 -1
  21. package/components/Data/stories/StarWars.js +18 -24
  22. package/components/Data/stories/Views.js +1 -1
  23. package/components/DataFilter/DataFilter.js +32 -42
  24. package/components/DataFilter/stories/Simple.js +7 -4
  25. package/components/DataFilters/DataFilters.js +76 -32
  26. package/components/DataFilters/index.d.ts +1 -0
  27. package/components/DataFilters/propTypes.js +2 -1
  28. package/components/DataFilters/stories/Drop.js +7 -4
  29. package/components/DataFilters/stories/Inline.js +24 -6
  30. package/components/DataFilters/stories/Layer.js +46 -0
  31. package/components/DataFilters/stories/Simple.js +7 -4
  32. package/components/DataSearch/DataSearch.js +57 -9
  33. package/components/DataSearch/index.d.ts +10 -1
  34. package/components/DataSearch/propTypes.js +6 -1
  35. package/components/DataSearch/stories/Drop.js +42 -0
  36. package/components/DataSearch/stories/Responsive.js +42 -0
  37. package/components/DataSearch/stories/Simple.js +5 -2
  38. package/components/DataSort/DataSort.js +61 -12
  39. package/components/DataSort/index.d.ts +4 -8
  40. package/components/DataSort/propTypes.js +9 -2
  41. package/components/DataSort/stories/Drop.js +41 -0
  42. package/components/DataSort/stories/Simple.js +9 -5
  43. package/components/DataSummary/stories/Simple.js +7 -4
  44. package/components/DataTable/GroupedBody.js +1 -0
  45. package/components/DataTable/StyledDataTable.js +2 -2
  46. package/components/DataTableColumns/DataTableColumns.js +2 -1
  47. package/components/DataTableColumns/stories/Simple.js +9 -5
  48. package/components/DataView/DataView.js +22 -7
  49. package/components/DataView/stories/Simple.js +8 -5
  50. package/components/DateInput/DateInput.js +2 -1
  51. package/components/Distribution/Distribution.js +1 -1
  52. package/components/Drop/DropContainer.js +32 -79
  53. package/components/Drop/stories/Overflow.js +1 -0
  54. package/components/DropButton/DropButton.js +1 -1
  55. package/components/Form/stories/Controlled.js +11 -2
  56. package/components/Form/stories/ControlledInput.js +13 -2
  57. package/components/Form/stories/ControlledInputLazy.js +13 -2
  58. package/components/Form/stories/ControlledLazy.js +13 -2
  59. package/components/Form/stories/FieldWithChildren.js +13 -2
  60. package/components/Form/stories/FieldWithComponentProp.js +17 -1
  61. package/components/Form/stories/Uncontrolled.js +15 -2
  62. package/components/Form/stories/ValidateOnChange.js +6 -0
  63. package/components/Form/stories/ValidateOnMount.js +4 -0
  64. package/components/Form/stories/typescript/TypedForm.tsx +25 -3
  65. package/components/Layer/LayerContainer.js +1 -1
  66. package/components/Layer/StyledLayer.js +3 -1
  67. package/components/MaskedInput/MaskedInput.js +3 -2
  68. package/components/MaskedInput/StyledMaskedInput.js +2 -1
  69. package/components/Notification/Notification.js +7 -3
  70. package/components/PageHeader/PageHeader.js +6 -4
  71. package/components/Pagination/Pagination.js +8 -0
  72. package/components/Pagination/StyledPageControl.js +3 -1
  73. package/components/Paragraph/Paragraph.js +18 -6
  74. package/components/Paragraph/stories/All.js +5 -1
  75. package/components/SelectMultiple/SelectMultiple.js +11 -10
  76. package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
  77. package/components/SelectMultiple/stories/Help.js +49 -0
  78. package/components/Tabs/Tabs.js +2 -1
  79. package/components/Text/Text.js +9 -1
  80. package/components/Text/TextContext.js +8 -0
  81. package/components/TextInput/StyledTextInput.js +5 -2
  82. package/components/TextInput/TextInput.js +7 -4
  83. package/components/TextInput/index.d.ts +3 -1
  84. package/components/TextInput/propTypes.js +3 -1
  85. package/components/Toolbar/stories/Simple.js +1 -1
  86. package/components/WorldMap/WorldMap.js +17 -14
  87. package/es6/components/Anchor/Anchor.js +13 -6
  88. package/es6/components/Anchor/StyledAnchor.js +6 -3
  89. package/es6/components/Button/Badge.js +43 -44
  90. package/es6/components/Button/Button.js +22 -15
  91. package/es6/components/Button/StyledButton.js +5 -3
  92. package/es6/components/Button/StyledButtonKind.js +26 -10
  93. package/es6/components/Button/index.d.ts +2 -0
  94. package/es6/components/Button/propTypes.js +2 -1
  95. package/es6/components/Calendar/Calendar.js +14 -6
  96. package/es6/components/CheckBox/index.d.ts +1 -1
  97. package/es6/components/Data/DataForm.js +97 -26
  98. package/es6/components/Data/stories/Cards.js +1 -1
  99. package/es6/components/Data/stories/Complex.js +78 -0
  100. package/es6/components/Data/stories/Controlled.js +1 -1
  101. package/es6/components/Data/stories/DataTable.js +12 -5
  102. package/es6/components/Data/stories/Infinite.js +1 -1
  103. package/es6/components/Data/stories/Inline.js +7 -2
  104. package/es6/components/Data/stories/List.js +1 -1
  105. package/es6/components/Data/stories/Simple.js +1 -1
  106. package/es6/components/Data/stories/SpaceX.js +1 -1
  107. package/es6/components/Data/stories/StarWars.js +18 -24
  108. package/es6/components/Data/stories/Views.js +1 -1
  109. package/es6/components/DataFilter/DataFilter.js +32 -42
  110. package/es6/components/DataFilter/stories/Simple.js +8 -5
  111. package/es6/components/DataFilters/DataFilters.js +76 -32
  112. package/es6/components/DataFilters/index.d.ts +1 -0
  113. package/es6/components/DataFilters/propTypes.js +2 -1
  114. package/es6/components/DataFilters/stories/Drop.js +8 -5
  115. package/es6/components/DataFilters/stories/Inline.js +25 -7
  116. package/es6/components/DataFilters/stories/Layer.js +40 -0
  117. package/es6/components/DataFilters/stories/Simple.js +8 -5
  118. package/es6/components/DataSearch/DataSearch.js +58 -10
  119. package/es6/components/DataSearch/index.d.ts +10 -1
  120. package/es6/components/DataSearch/propTypes.js +5 -1
  121. package/es6/components/DataSearch/stories/Drop.js +36 -0
  122. package/es6/components/DataSearch/stories/Responsive.js +36 -0
  123. package/es6/components/DataSearch/stories/Simple.js +6 -3
  124. package/es6/components/DataSort/DataSort.js +62 -13
  125. package/es6/components/DataSort/index.d.ts +4 -8
  126. package/es6/components/DataSort/propTypes.js +8 -2
  127. package/es6/components/DataSort/stories/Drop.js +35 -0
  128. package/es6/components/DataSort/stories/Simple.js +10 -6
  129. package/es6/components/DataSummary/stories/Simple.js +8 -5
  130. package/es6/components/DataTable/GroupedBody.js +1 -0
  131. package/es6/components/DataTable/StyledDataTable.js +2 -2
  132. package/es6/components/DataTableColumns/DataTableColumns.js +2 -1
  133. package/es6/components/DataTableColumns/stories/Simple.js +10 -6
  134. package/es6/components/DataView/DataView.js +22 -7
  135. package/es6/components/DataView/stories/Simple.js +9 -6
  136. package/es6/components/DateInput/DateInput.js +2 -1
  137. package/es6/components/Distribution/Distribution.js +1 -1
  138. package/es6/components/Drop/DropContainer.js +34 -81
  139. package/es6/components/Drop/stories/Overflow.js +1 -0
  140. package/es6/components/DropButton/DropButton.js +1 -1
  141. package/es6/components/Form/stories/Controlled.js +11 -2
  142. package/es6/components/Form/stories/ControlledInput.js +13 -2
  143. package/es6/components/Form/stories/ControlledInputLazy.js +13 -2
  144. package/es6/components/Form/stories/ControlledLazy.js +13 -2
  145. package/es6/components/Form/stories/FieldWithChildren.js +13 -2
  146. package/es6/components/Form/stories/FieldWithComponentProp.js +17 -1
  147. package/es6/components/Form/stories/Uncontrolled.js +15 -2
  148. package/es6/components/Form/stories/ValidateOnChange.js +6 -0
  149. package/es6/components/Form/stories/ValidateOnMount.js +4 -0
  150. package/es6/components/Form/stories/typescript/TypedForm.tsx +25 -3
  151. package/es6/components/Layer/LayerContainer.js +1 -1
  152. package/es6/components/Layer/StyledLayer.js +3 -1
  153. package/es6/components/MaskedInput/MaskedInput.js +4 -3
  154. package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
  155. package/es6/components/Notification/Notification.js +7 -3
  156. package/es6/components/PageHeader/PageHeader.js +6 -4
  157. package/es6/components/Pagination/Pagination.js +8 -0
  158. package/es6/components/Pagination/StyledPageControl.js +3 -1
  159. package/es6/components/Paragraph/Paragraph.js +19 -7
  160. package/es6/components/Paragraph/stories/All.js +5 -1
  161. package/es6/components/SelectMultiple/SelectMultiple.js +11 -10
  162. package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
  163. package/es6/components/SelectMultiple/stories/Help.js +42 -0
  164. package/es6/components/Tabs/Tabs.js +2 -1
  165. package/es6/components/Text/Text.js +10 -2
  166. package/es6/components/Text/TextContext.js +2 -0
  167. package/es6/components/TextInput/StyledTextInput.js +6 -3
  168. package/es6/components/TextInput/TextInput.js +8 -5
  169. package/es6/components/TextInput/index.d.ts +3 -1
  170. package/es6/components/TextInput/propTypes.js +3 -1
  171. package/es6/components/Toolbar/stories/Simple.js +1 -1
  172. package/es6/components/WorldMap/WorldMap.js +17 -14
  173. package/es6/languages/default.json +7 -2
  174. package/es6/themes/base.d.ts +34 -0
  175. package/es6/themes/base.js +37 -1
  176. package/es6/utils/DOM.js +1 -1
  177. package/es6/utils/background.js +9 -1
  178. package/es6/utils/colors.js +2 -2
  179. package/es6/utils/general-prop-types.js +1 -1
  180. package/es6/utils/icon.js +7 -0
  181. package/es6/utils/index.d.ts +7 -1
  182. package/es6/utils/index.js +1 -0
  183. package/es6/utils/styles.js +10 -0
  184. package/grommet.min.js +1 -1
  185. package/grommet.min.js.map +1 -1
  186. package/languages/default.json +7 -2
  187. package/package.json +41 -39
  188. package/themes/base.d.ts +34 -0
  189. package/themes/base.js +37 -1
  190. package/utils/DOM.js +1 -1
  191. package/utils/background.js +8 -0
  192. package/utils/colors.js +3 -1
  193. package/utils/general-prop-types.js +1 -1
  194. package/utils/icon.js +12 -0
  195. package/utils/index.d.ts +7 -1
  196. package/utils/index.js +6 -0
  197. package/utils/styles.js +12 -1
@@ -1,4 +1,4 @@
1
- import React, { useContext, useRef, useState } from 'react';
1
+ import React, { useContext, useRef } from 'react';
2
2
  import styled, { ThemeContext } from 'styled-components';
3
3
  import { parseMetricToNum } from '../../utils';
4
4
  import { useLayoutEffect } from '../../utils/use-isomorphic-layout-effect';
@@ -15,21 +15,13 @@ export var Badge = function Badge(_ref) {
15
15
  var children = _ref.children,
16
16
  content = _ref.content;
17
17
  var theme = useContext(ThemeContext);
18
+ var containerRef = useRef();
18
19
  var contentRef = useRef();
19
20
  var stackRef = useRef();
20
21
  var defaultBadgeDimension = typeof content === 'boolean' || content && content.value && typeof content.value === 'boolean' ? // empty badge should be smaller. this value was chosen as a default
21
22
  // after experimenting with various values
22
23
  parseMetricToNum(theme.button.badge.size.medium) / 2 + "px" : theme.button.badge.size.medium;
23
24
 
24
- // size should drive height, match width to height by default
25
- // allow width to grow when content is wide
26
- var _useState = useState(defaultBadgeDimension),
27
- height = _useState[0],
28
- setHeight = _useState[1];
29
- var _useState2 = useState(height),
30
- width = _useState2[0],
31
- setWidth = _useState2[1];
32
-
33
25
  // scale badge to fit its contents, leaving space horizontally
34
26
  // that is proportional to vertical space
35
27
  useLayoutEffect(function () {
@@ -37,26 +29,38 @@ export var Badge = function Badge(_ref) {
37
29
  // can change (because pad is responsive, etc.). we want to recalculate
38
30
  // width since badge offset is reliant on its dimensions.
39
31
  var onResize = function onResize() {
40
- if (contentRef && contentRef.current) {
41
- if (typeof content === 'number' || typeof content === 'object' && content.value) {
42
- var _contentRef$current$g = contentRef.current.getBoundingClientRect(),
43
- contentHeight = _contentRef$current$g.height,
44
- contentWidth = _contentRef$current$g.width;
32
+ if (containerRef != null && containerRef.current) {
33
+ containerRef.current.style.minHeight = '';
34
+ containerRef.current.style.minWidth = '';
35
+ if (contentRef != null && contentRef.current) {
36
+ if (typeof content === 'number' || typeof content === 'object' && content.value) {
37
+ containerRef.current.style.minHeight = defaultBadgeDimension;
38
+ containerRef.current.style.minWidth = defaultBadgeDimension;
39
+ var _contentRef$current$g = contentRef.current.getBoundingClientRect(),
40
+ contentHeight = _contentRef$current$g.height,
41
+ contentWidth = _contentRef$current$g.width;
45
42
 
46
- // only adjust the width if contentHeight > 0
47
- // jest returns 0 for all getBoundingClientRect values,
48
- // so this ensures snapshots are closer to correct values
49
- if (contentHeight) {
50
- // height of content includes extra space around font from
51
- // line-height. account for this extra space with 2.5 multiplier
52
- // to add proportional horizontal space
53
- var verticalSpace = (parseMetricToNum(height) - contentHeight) * 2.5;
54
- setWidth(Math.max(parseMetricToNum(width), Math.ceil(contentWidth + verticalSpace)) + "px");
43
+ // only adjust the width if contentHeight > 0
44
+ // jest returns 0 for all getBoundingClientRect values,
45
+ // so this ensures snapshots are closer to correct values
46
+ if (contentHeight) {
47
+ // height of content includes extra space around font from
48
+ // line-height. account for this extra space with 2.5 multiplier
49
+ // to add proportional horizontal space
50
+ var height = defaultBadgeDimension;
51
+ var width = defaultBadgeDimension;
52
+ var verticalSpace = (parseMetricToNum(height) - contentHeight) * 2.5;
53
+ containerRef.current.style.minHeight = height;
54
+ containerRef.current.style.minWidth = Math.max(parseMetricToNum(width), Math.ceil(contentWidth + verticalSpace)) + "px";
55
+ }
56
+ } else {
57
+ // caller has provided custom JSX
58
+ containerRef.current.style.minHeight = contentRef.current.getBoundingClientRect().width;
59
+ containerRef.current.style.minWidth = contentRef.current.getBoundingClientRect().height;
55
60
  }
56
61
  } else {
57
- // caller has provided custom JSX
58
- setWidth(contentRef.current.getBoundingClientRect().width + "px");
59
- setHeight(contentRef.current.getBoundingClientRect().height + "px");
62
+ containerRef.current.style.minHeight = defaultBadgeDimension;
63
+ containerRef.current.style.minWidth = defaultBadgeDimension;
60
64
  }
61
65
  }
62
66
  };
@@ -65,26 +69,26 @@ export var Badge = function Badge(_ref) {
65
69
  return function () {
66
70
  window.removeEventListener('resize', onResize);
67
71
  };
68
- }, [content, height, width]);
72
+ }, [content, defaultBadgeDimension]);
69
73
 
70
74
  // offset the badge so it overlaps content
71
75
  useLayoutEffect(function () {
72
- if (stackRef && stackRef.current) {
76
+ if (stackRef != null && stackRef.current) {
73
77
  // when badge has content, offset should be 50%.
74
78
  // when badge is empty, offset by a smaller amount to keep the badge
75
79
  // closer to the content. this value was chosen as a reasonable default
76
80
  // after testing with various grommet icons.
77
- var divisor = typeof content === 'boolean' || content && content.value === true ? 3.5 : 2;
78
- var offset = {
79
- right: "-" + Math.round(parseMetricToNum(width) / divisor) + "px",
80
- top: "-" + Math.round(parseMetricToNum(height) / divisor) + "px"
81
- };
81
+ var offset = typeof content === 'boolean' || content && content.value === true ? '25%' : '50%';
82
+
82
83
  // second child of Stack is the div that receives absolute positioning
83
84
  // and contains our badge content
84
- stackRef.current.children[1].style.top = offset.top;
85
- stackRef.current.children[1].style.right = offset.right;
85
+ stackRef.current.children[1].style.top = 0;
86
+ stackRef.current.children[1].style.right = 0;
87
+ // eslint-disable-next-line max-len
88
+ stackRef.current.children[1].style.transform = "translate(" + offset + ", -" + offset + ")";
89
+ stackRef.current.children[1].style.transformOrigin = '100% 0%';
86
90
  }
87
- }, [content, height, width]);
91
+ }, [content]);
88
92
  var value;
89
93
  if (typeof content === 'number') value = content;else if (typeof content === 'object') value = content.value;
90
94
  var badge;
@@ -99,18 +103,13 @@ export var Badge = function Badge(_ref) {
99
103
  }, value > max ? max + "+" : value);
100
104
  }
101
105
  badge = /*#__PURE__*/React.createElement(StyledBadgeContainer, {
106
+ ref: containerRef,
102
107
  align: "center",
103
108
  background: content.background || theme.button.badge.container.background,
104
109
  flex: false,
105
- height: {
106
- min: height
107
- },
108
110
  justify: "center",
109
111
  round: true,
110
- pad: !(typeof value === 'boolean' || typeof content === 'boolean') ? theme.button.badge.container.pad : undefined,
111
- width: {
112
- min: width
113
- }
112
+ pad: !(typeof value === 'boolean' || typeof content === 'boolean') ? theme.button.badge.container.pad : undefined
114
113
  }, badge);
115
114
  // caller has provided their own JSX and we will just render that
116
115
  } else badge = /*#__PURE__*/React.createElement(Box, {
@@ -1,9 +1,9 @@
1
- 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"];
1
+ 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"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
  import React, { cloneElement, Children, forwardRef, useContext, useMemo, useState, useCallback } from 'react';
5
5
  import { ThemeContext } from 'styled-components';
6
- import { backgroundAndTextColors, colorIsDark, findButtonParent, normalizeBackground, normalizeColor } from '../../utils';
6
+ import { backgroundAndTextColors, colorIsDark, findButtonParent, useSizedIcon, normalizeBackground, normalizeColor } from '../../utils';
7
7
  import { defaultProps } from '../../default-props';
8
8
  import { ButtonPropTypes } from './propTypes';
9
9
  import { Box } from '../Box';
@@ -132,7 +132,7 @@ var getPropertyColor = function getPropertyColor(property, paths, theme, kind, p
132
132
  return result;
133
133
  };
134
134
  var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
135
- var _theme$button$kind;
135
+ var _theme$button$kind, _theme$button2, _theme$button2$badge;
136
136
  var active = _ref.active,
137
137
  _ref$align = _ref.align,
138
138
  align = _ref$align === void 0 ? 'center' : _ref$align,
@@ -155,12 +155,13 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
155
155
  _onFocus = _ref.onFocus,
156
156
  onMouseOut = _ref.onMouseOut,
157
157
  onMouseOver = _ref.onMouseOver,
158
+ pad = _ref.pad,
158
159
  plain = _ref.plain,
159
160
  primary = _ref.primary,
160
161
  reverseProp = _ref.reverse,
161
162
  secondary = _ref.secondary,
162
163
  selected = _ref.selected,
163
- size = _ref.size,
164
+ sizeProp = _ref.size,
164
165
  tip = _ref.tip,
165
166
  _ref$type = _ref.type,
166
167
  type = _ref$type === void 0 ? 'button' : _ref$type,
@@ -208,6 +209,9 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
208
209
  return undefined; // pre-default, no kind
209
210
  }, [kindArg, kindObj, primary, secondary, theme]);
210
211
 
212
+ // for backwards compatibility, no-kind button theme did not
213
+ // default to size "medium" on buttons with no size prop
214
+ var size = sizeProp || kind && 'medium' || undefined;
211
215
  // When we have a kind and are not plain, themePaths stores the relative
212
216
  // paths within the theme for the current kind and state of the button.
213
217
  // These paths are used with getIconColor() above and kindStyle() within
@@ -242,14 +246,6 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
242
246
  }
243
247
  return result;
244
248
  }, [active, disabled, kind, kindObj, plain, selected]);
245
- if (skeleton) {
246
- var _theme$text, _theme$button$size;
247
- return /*#__PURE__*/React.createElement(Skeleton, _extends({
248
- ref: ref,
249
- height: ((_theme$text = theme.text[size || 'medium']) == null ? void 0 : _theme$text.height) || size,
250
- a11yTitle: a11yTitle
251
- }, rest, (_theme$button$size = theme.button.size) == null ? void 0 : _theme$button$size[size || 'medium'], theme.button.skeleton));
252
- }
253
249
 
254
250
  // only used when theme does not have button.default
255
251
  var isDarkBackground = function isDarkBackground() {
@@ -291,14 +287,24 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
291
287
  color: _iconColor
292
288
  });
293
289
  }
290
+ buttonIcon = useSizedIcon(buttonIcon, size, theme);
291
+ if (skeleton) {
292
+ var _theme$text, _theme$button$size;
293
+ return /*#__PURE__*/React.createElement(Skeleton, _extends({
294
+ ref: ref,
295
+ height: ((_theme$text = theme.text[size || 'medium']) == null ? void 0 : _theme$text.height) || size,
296
+ a11yTitle: a11yTitle
297
+ }, rest, (_theme$button$size = theme.button.size) == null ? void 0 : _theme$button$size[size || 'medium'], theme.button.skeleton));
298
+ }
294
299
  var reverse = reverseProp != null ? reverseProp : (_theme$button$kind = theme.button[kind]) == null ? void 0 : _theme$button$kind.reverse;
295
300
  var domTag = !as && href ? 'a' : as;
296
301
  var first = reverse ? label : buttonIcon;
297
302
  var second = reverse ? buttonIcon : label;
298
303
  var contents;
299
304
  if (first && second) {
305
+ var _theme$button, _theme$button$kind2;
300
306
  contents = /*#__PURE__*/React.createElement(Box, {
301
- direction: "row",
307
+ direction: ((_theme$button = theme.button) == null ? void 0 : (_theme$button$kind2 = _theme$button[kind]) == null ? void 0 : _theme$button$kind2.direction) || 'row',
302
308
  align: "center",
303
309
  justify: justify || (align === 'center' ? 'center' : 'between'),
304
310
  gap: gap || theme.button.gap,
@@ -320,7 +326,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
320
326
  // (!kind && icon && !label) is necessary because for old button logic,
321
327
  // if button has icon but not label, it will be considered "plain",
322
328
  // so no border or background will be applied
323
- var innerBadge = !background && !border || !kind && icon && !label;
329
+ 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);
324
330
  if (badgeProp && innerBadge) {
325
331
  contents = /*#__PURE__*/React.createElement(Badge, {
326
332
  content: badgeProp
@@ -358,6 +364,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
358
364
  },
359
365
  onMouseOver: onMouseOverButton,
360
366
  onMouseOut: onMouseOutButton,
367
+ pad: pad,
361
368
  plain: plain || Children.count(children) > 0,
362
369
  primary: primary,
363
370
  sizeProp: size,
@@ -392,7 +399,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
392
399
  },
393
400
  onMouseOver: onMouseOverButton,
394
401
  onMouseOut: onMouseOutButton,
395
- pad: !plain,
402
+ pad: pad || !plain,
396
403
  plain: typeof plain !== 'undefined' ? plain : Children.count(children) > 0 || icon && !label,
397
404
  primary: primary,
398
405
  sizeProp: size,
@@ -1,5 +1,5 @@
1
1
  import styled, { css } from 'styled-components';
2
- import { activeStyle, backgroundStyle, disabledStyle, focusStyle, unfocusStyle, genericStyles, getHoverIndicatorStyle, normalizeColor } from '../../utils';
2
+ import { activeStyle, backgroundStyle, disabledStyle, edgeStyle, focusStyle, unfocusStyle, genericStyles, getHoverIndicatorStyle, normalizeColor } from '../../utils';
3
3
  import { defaultProps } from '../../default-props';
4
4
  var radiusStyle = function radiusStyle(props) {
5
5
  // border.radius shouldn't impact an only-icon rendering.
@@ -71,7 +71,7 @@ var disabledButtonStyle = function disabledButtonStyle(props) {
71
71
  var StyledButton = styled.button.withConfig({
72
72
  displayName: "StyledButton",
73
73
  componentId: "sc-323bzc-0"
74
- })(["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){", "}", " ", " ", " ", " ", ""], genericStyles, function (props) {
74
+ })(["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){", "}", " ", " ", " ", " ", " ", ""], genericStyles, function (props) {
75
75
  return props.plain && plainStyle(props);
76
76
  }, function (props) {
77
77
  return !props.plain && basicStyle(props);
@@ -92,7 +92,9 @@ var StyledButton = styled.button.withConfig({
92
92
  }, function (props) {
93
93
  return props.hasIcon && !props.hasLabel && "\n line-height: 0;\n ";
94
94
  }, function (props) {
95
- return props.pad && props.hasIcon && !props.hasLabel && "\n padding: " + props.theme.global.edgeSize.small + ";\n ";
95
+ return props.pad === true && props.hasIcon && !props.hasLabel && "\n padding: " + props.theme.global.edgeSize.small + ";\n ";
96
+ }, function (props) {
97
+ return !props.plain && props.pad && edgeStyle('padding', props.pad, false, undefined, props.theme);
96
98
  }, function (props) {
97
99
  return props.theme.button && props.theme.button.extend;
98
100
  });
@@ -1,5 +1,5 @@
1
1
  import styled, { css } from 'styled-components';
2
- import { activeStyle, disabledStyle, focusStyle, unfocusStyle, genericStyles, kindPartStyles, parseMetricToNum } from '../../utils';
2
+ import { activeStyle, disabledStyle, edgeStyle, focusStyle, unfocusStyle, genericStyles, kindPartStyles, parseMetricToNum } from '../../utils';
3
3
  import { defaultProps } from '../../default-props';
4
4
  var radiusStyle = function radiusStyle(props) {
5
5
  var size = props.sizeProp;
@@ -13,14 +13,22 @@ var radiusStyle = function radiusStyle(props) {
13
13
  var fontStyle = function fontStyle(props) {
14
14
  var size = props.sizeProp || 'medium';
15
15
  var data = props.theme.text[size];
16
- return css(["font-size:", ";line-height:", ";"], data.size, data.height);
16
+ return css(["font-size:", ";line-height:", ";"], data.size, props.hasIcon && !props.hasLabel ? 0 : data.height);
17
17
  };
18
- var padFromTheme = function padFromTheme(size, theme, themeObj, kind) {
19
- var _themeObj$size, _themeObj$size$size, _themeObj$size$size$k;
18
+ var padFromTheme = function padFromTheme(size, theme, themeObj, kind, iconOnly) {
19
+ var _themeObj$size, _themeObj$size$size, _themeObj$size$size$i, _themeObj$size3, _themeObj$size3$size, _themeObj$size3$size$;
20
20
  if (size === void 0) {
21
21
  size = 'medium';
22
22
  }
23
- if (size && themeObj != null && (_themeObj$size = themeObj.size) != null && (_themeObj$size$size = _themeObj$size[size]) != null && (_themeObj$size$size$k = _themeObj$size$size[kind]) != null && _themeObj$size$size$k.pad) {
23
+ if (size && iconOnly && themeObj != null && (_themeObj$size = themeObj.size) != null && (_themeObj$size$size = _themeObj$size[size]) != null && (_themeObj$size$size$i = _themeObj$size$size.iconOnly) != null && _themeObj$size$size$i.pad) {
24
+ var _themeObj$size2, _themeObj$size2$size, _themeObj$size2$size$;
25
+ var pad = themeObj == null ? void 0 : (_themeObj$size2 = themeObj.size) == null ? void 0 : (_themeObj$size2$size = _themeObj$size2[size]) == null ? void 0 : (_themeObj$size2$size$ = _themeObj$size2$size.iconOnly) == null ? void 0 : _themeObj$size2$size$.pad;
26
+ return {
27
+ vertical: typeof pad === 'string' ? pad : pad.vertical,
28
+ horizontal: typeof pad === 'string' ? pad : pad.horizontal
29
+ };
30
+ }
31
+ if (size && themeObj != null && (_themeObj$size3 = themeObj.size) != null && (_themeObj$size3$size = _themeObj$size3[size]) != null && (_themeObj$size3$size$ = _themeObj$size3$size[kind]) != null && _themeObj$size3$size$.pad) {
24
32
  return themeObj.size[size][kind].pad;
25
33
  }
26
34
  if (size && themeObj.size && themeObj.size[size] && themeObj.size[size].pad) {
@@ -38,13 +46,16 @@ var padFromTheme = function padFromTheme(size, theme, themeObj, kind) {
38
46
  return undefined;
39
47
  };
40
48
  var padStyle = function padStyle(_ref) {
41
- var size = _ref.sizeProp,
49
+ var hasIcon = _ref.hasIcon,
50
+ hasLabel = _ref.hasLabel,
51
+ size = _ref.sizeProp,
42
52
  theme = _ref.theme,
43
53
  kind = _ref.kind;
44
54
  // caller has specified a themeObj to use for styling
45
55
  // relevant for cases like pagination which looks to theme.pagination.button
46
56
  var themeObj = typeof kind === 'object' ? kind : theme.button;
47
- var pad = padFromTheme(size, theme, themeObj, kind);
57
+ var iconOnly = hasIcon && !hasLabel;
58
+ var pad = padFromTheme(size, theme, themeObj, kind, iconOnly);
48
59
  return pad ? css(["padding:", " ", ";"], pad.vertical, pad.horizontal) : '';
49
60
  };
50
61
  var basicStyle = function basicStyle(props) {
@@ -67,6 +78,8 @@ var adjustPadStyle = function adjustPadStyle(pad, width) {
67
78
  // build up CSS from basic to specific based on the supplied sub-object paths
68
79
  var kindStyle = function kindStyle(_ref2) {
69
80
  var colorValue = _ref2.colorValue,
81
+ hasIcon = _ref2.hasIcon,
82
+ hasLabel = _ref2.hasLabel,
70
83
  kind = _ref2.kind,
71
84
  size = _ref2.sizeProp,
72
85
  themePaths = _ref2.themePaths,
@@ -76,7 +89,8 @@ var kindStyle = function kindStyle(_ref2) {
76
89
  // caller has specified a themeObj to use for styling
77
90
  // relevant for cases like pagination which looks to theme.pagination.button
78
91
  var themeObj = typeof kind === 'object' ? kind : theme.button;
79
- var pad = padFromTheme(size, theme, themeObj, kind);
92
+ var iconOnly = hasIcon && !hasLabel;
93
+ var pad = padFromTheme(size, theme, themeObj, kind, iconOnly);
80
94
  themePaths.base.forEach(function (themePath) {
81
95
  var obj = getPath(themeObj, themePath);
82
96
  if (obj) {
@@ -146,7 +160,7 @@ var fillStyle = function fillStyle(fillContainer) {
146
160
  return undefined;
147
161
  };
148
162
  var plainStyle = function plainStyle(props) {
149
- return 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 ");
163
+ return 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;");
150
164
  };
151
165
  var StyledButtonKind = styled.button.withConfig({
152
166
  // don't let kind attribute leak to DOM
@@ -157,7 +171,7 @@ var StyledButtonKind = styled.button.withConfig({
157
171
  }).withConfig({
158
172
  displayName: "StyledButtonKind",
159
173
  componentId: "sc-1vhfpnt-0"
160
- })(["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){", "}", " ", " ", ""], genericStyles, function (props) {
174
+ })(["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){", "}", " ", " ", ""], genericStyles, function (props) {
161
175
  return props.plain && plainStyle(props);
162
176
  }, function (props) {
163
177
  return !props.disabled && props.active && activeStyle;
@@ -165,6 +179,8 @@ var StyledButtonKind = styled.button.withConfig({
165
179
  return !props.plain && basicStyle(props);
166
180
  }, function (props) {
167
181
  return !props.plain && kindStyle(props);
182
+ }, function (props) {
183
+ return !props.plain && props.pad && edgeStyle('padding', props.pad, false, undefined, props.theme);
168
184
  }, function (props) {
169
185
  return !props.plain && props.align && "\n text-align: " + props.align + ";\n ";
170
186
  }, 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;
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import PropTypes from 'prop-types';
3
- import { backgroundPropType, genericProps, colorPropType, hoverIndicatorPropType } from '../../utils/general-prop-types';
3
+ import { backgroundPropType, genericProps, colorPropType, hoverIndicatorPropType, padPropType } from '../../utils/general-prop-types';
4
4
  var PropType = {};
5
5
  if (process.env.NODE_ENV !== 'production') {
6
6
  PropType = _extends({}, genericProps, {
@@ -23,6 +23,7 @@ if (process.env.NODE_ENV !== 'production') {
23
23
  justify: PropTypes.oneOf(['around', 'between', 'center', 'end', 'evenly', 'start', 'stretch']),
24
24
  label: PropTypes.node,
25
25
  onClick: PropTypes.func,
26
+ pad: padPropType,
26
27
  plain: PropTypes.bool,
27
28
  primary: PropTypes.bool,
28
29
  reverse: PropTypes.bool,
@@ -8,8 +8,10 @@ import { MessageContext } from '../../contexts/MessageContext';
8
8
  import { defaultProps } from '../../default-props';
9
9
  import { Box } from '../Box';
10
10
  import { Button } from '../Button';
11
+ import { Header } from '../Header';
11
12
  import { Heading } from '../Heading';
12
13
  import { Keyboard } from '../Keyboard';
14
+ import { Text } from '../Text';
13
15
  import { CalendarPropTypes } from './propTypes';
14
16
  import { StyledCalendar, StyledDay, StyledDayContainer, StyledWeek, StyledWeeks, StyledWeeksContainer } from './StyledCalendar';
15
17
  import { addDays, addMonths, betweenDates, daysApart, endOfMonth, handleOffset, sameDayOrAfter, sameDayOrBefore, startOfMonth, subtractDays, subtractMonths, withinDates } from './utils';
@@ -495,26 +497,32 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
495
497
  setActive(selectedDate);
496
498
  };
497
499
  var renderCalendarHeader = function renderCalendarHeader() {
500
+ var _theme$calendar$size;
498
501
  var PreviousIcon = size === 'small' ? theme.calendar.icons.small.previous : theme.calendar.icons.previous;
499
502
  var NextIcon = size === 'small' ? theme.calendar.icons.small.next : theme.calendar.icons.next;
503
+ var monthAndYear = reference.toLocaleDateString(locale, {
504
+ month: 'long',
505
+ year: 'numeric'
506
+ });
500
507
  return /*#__PURE__*/React.createElement(Box, {
501
508
  direction: "row",
502
509
  justify: "between",
503
510
  align: "center"
504
- }, /*#__PURE__*/React.createElement(Box, {
511
+ }, /*#__PURE__*/React.createElement(Header, {
505
512
  flex: true,
506
513
  pad: {
507
514
  horizontal: headingPadMap[size] || 'small'
508
515
  }
509
- }, /*#__PURE__*/React.createElement(Heading, {
516
+ }, (_theme$calendar$size = theme.calendar[size]) != null && _theme$calendar$size.title ? /*#__PURE__*/React.createElement(Text, theme.calendar[size].title, monthAndYear) :
517
+ /*#__PURE__*/
518
+ // theme.calendar.heading.level should be removed in v3 of grommet
519
+ // theme.calendar[size].title should be used instead
520
+ React.createElement(Heading, {
510
521
  level: size === 'small' ? theme.calendar.heading && theme.calendar.heading.level || 4 : (theme.calendar.heading && theme.calendar.heading.level || 4) - 1,
511
522
  size: size,
512
523
  margin: "none",
513
524
  overflowWrap: "normal"
514
- }, reference.toLocaleDateString(locale, {
515
- month: 'long',
516
- year: 'numeric'
517
- }))), /*#__PURE__*/React.createElement(Box, {
525
+ }, monthAndYear)), /*#__PURE__*/React.createElement(Box, {
518
526
  flex: false,
519
527
  direction: "row",
520
528
  align: "center"
@@ -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;