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.
- package/components/Anchor/Anchor.js +12 -5
- package/components/Anchor/StyledAnchor.js +6 -3
- package/components/Button/Badge.js +42 -43
- package/components/Button/Button.js +21 -14
- package/components/Button/StyledButton.js +4 -2
- package/components/Button/StyledButtonKind.js +25 -9
- package/components/Button/index.d.ts +2 -0
- package/components/Button/propTypes.js +1 -0
- package/components/Calendar/Calendar.js +14 -6
- package/components/CheckBox/index.d.ts +1 -1
- package/components/Data/DataForm.js +97 -26
- package/components/Data/stories/Cards.js +1 -1
- package/components/Data/stories/Complex.js +84 -0
- package/components/Data/stories/Controlled.js +1 -1
- package/components/Data/stories/DataTable.js +11 -4
- package/components/Data/stories/Infinite.js +1 -1
- package/components/Data/stories/Inline.js +7 -2
- package/components/Data/stories/List.js +1 -1
- package/components/Data/stories/Simple.js +1 -1
- package/components/Data/stories/SpaceX.js +1 -1
- package/components/Data/stories/StarWars.js +18 -24
- package/components/Data/stories/Views.js +1 -1
- package/components/DataFilter/DataFilter.js +32 -42
- package/components/DataFilter/stories/Simple.js +7 -4
- package/components/DataFilters/DataFilters.js +76 -32
- package/components/DataFilters/index.d.ts +1 -0
- package/components/DataFilters/propTypes.js +2 -1
- package/components/DataFilters/stories/Drop.js +7 -4
- package/components/DataFilters/stories/Inline.js +24 -6
- package/components/DataFilters/stories/Layer.js +46 -0
- package/components/DataFilters/stories/Simple.js +7 -4
- package/components/DataSearch/DataSearch.js +57 -9
- package/components/DataSearch/index.d.ts +10 -1
- package/components/DataSearch/propTypes.js +6 -1
- package/components/DataSearch/stories/Drop.js +42 -0
- package/components/DataSearch/stories/Responsive.js +42 -0
- package/components/DataSearch/stories/Simple.js +5 -2
- package/components/DataSort/DataSort.js +61 -12
- package/components/DataSort/index.d.ts +4 -8
- package/components/DataSort/propTypes.js +9 -2
- package/components/DataSort/stories/Drop.js +41 -0
- package/components/DataSort/stories/Simple.js +9 -5
- package/components/DataSummary/stories/Simple.js +7 -4
- package/components/DataTable/GroupedBody.js +1 -0
- package/components/DataTable/StyledDataTable.js +2 -2
- package/components/DataTableColumns/DataTableColumns.js +2 -1
- package/components/DataTableColumns/stories/Simple.js +9 -5
- package/components/DataView/DataView.js +22 -7
- package/components/DataView/stories/Simple.js +8 -5
- package/components/DateInput/DateInput.js +2 -1
- package/components/Distribution/Distribution.js +1 -1
- package/components/Drop/DropContainer.js +32 -79
- package/components/Drop/stories/Overflow.js +1 -0
- package/components/DropButton/DropButton.js +1 -1
- package/components/Form/stories/Controlled.js +11 -2
- package/components/Form/stories/ControlledInput.js +13 -2
- package/components/Form/stories/ControlledInputLazy.js +13 -2
- package/components/Form/stories/ControlledLazy.js +13 -2
- package/components/Form/stories/FieldWithChildren.js +13 -2
- package/components/Form/stories/FieldWithComponentProp.js +17 -1
- package/components/Form/stories/Uncontrolled.js +15 -2
- package/components/Form/stories/ValidateOnChange.js +6 -0
- package/components/Form/stories/ValidateOnMount.js +4 -0
- package/components/Form/stories/typescript/TypedForm.tsx +25 -3
- package/components/Layer/LayerContainer.js +1 -1
- package/components/Layer/StyledLayer.js +3 -1
- package/components/MaskedInput/MaskedInput.js +3 -2
- package/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/components/Notification/Notification.js +7 -3
- package/components/PageHeader/PageHeader.js +6 -4
- package/components/Pagination/Pagination.js +8 -0
- package/components/Pagination/StyledPageControl.js +3 -1
- package/components/Paragraph/Paragraph.js +18 -6
- package/components/Paragraph/stories/All.js +5 -1
- package/components/SelectMultiple/SelectMultiple.js +11 -10
- package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/components/SelectMultiple/stories/Help.js +49 -0
- package/components/Tabs/Tabs.js +2 -1
- package/components/Text/Text.js +9 -1
- package/components/Text/TextContext.js +8 -0
- package/components/TextInput/StyledTextInput.js +5 -2
- package/components/TextInput/TextInput.js +7 -4
- package/components/TextInput/index.d.ts +3 -1
- package/components/TextInput/propTypes.js +3 -1
- package/components/Toolbar/stories/Simple.js +1 -1
- package/components/WorldMap/WorldMap.js +17 -14
- package/es6/components/Anchor/Anchor.js +13 -6
- package/es6/components/Anchor/StyledAnchor.js +6 -3
- package/es6/components/Button/Badge.js +43 -44
- package/es6/components/Button/Button.js +22 -15
- package/es6/components/Button/StyledButton.js +5 -3
- package/es6/components/Button/StyledButtonKind.js +26 -10
- package/es6/components/Button/index.d.ts +2 -0
- package/es6/components/Button/propTypes.js +2 -1
- package/es6/components/Calendar/Calendar.js +14 -6
- package/es6/components/CheckBox/index.d.ts +1 -1
- package/es6/components/Data/DataForm.js +97 -26
- package/es6/components/Data/stories/Cards.js +1 -1
- package/es6/components/Data/stories/Complex.js +78 -0
- package/es6/components/Data/stories/Controlled.js +1 -1
- package/es6/components/Data/stories/DataTable.js +12 -5
- package/es6/components/Data/stories/Infinite.js +1 -1
- package/es6/components/Data/stories/Inline.js +7 -2
- package/es6/components/Data/stories/List.js +1 -1
- package/es6/components/Data/stories/Simple.js +1 -1
- package/es6/components/Data/stories/SpaceX.js +1 -1
- package/es6/components/Data/stories/StarWars.js +18 -24
- package/es6/components/Data/stories/Views.js +1 -1
- package/es6/components/DataFilter/DataFilter.js +32 -42
- package/es6/components/DataFilter/stories/Simple.js +8 -5
- package/es6/components/DataFilters/DataFilters.js +76 -32
- package/es6/components/DataFilters/index.d.ts +1 -0
- package/es6/components/DataFilters/propTypes.js +2 -1
- package/es6/components/DataFilters/stories/Drop.js +8 -5
- package/es6/components/DataFilters/stories/Inline.js +25 -7
- package/es6/components/DataFilters/stories/Layer.js +40 -0
- package/es6/components/DataFilters/stories/Simple.js +8 -5
- package/es6/components/DataSearch/DataSearch.js +58 -10
- package/es6/components/DataSearch/index.d.ts +10 -1
- package/es6/components/DataSearch/propTypes.js +5 -1
- package/es6/components/DataSearch/stories/Drop.js +36 -0
- package/es6/components/DataSearch/stories/Responsive.js +36 -0
- package/es6/components/DataSearch/stories/Simple.js +6 -3
- package/es6/components/DataSort/DataSort.js +62 -13
- package/es6/components/DataSort/index.d.ts +4 -8
- package/es6/components/DataSort/propTypes.js +8 -2
- package/es6/components/DataSort/stories/Drop.js +35 -0
- package/es6/components/DataSort/stories/Simple.js +10 -6
- package/es6/components/DataSummary/stories/Simple.js +8 -5
- package/es6/components/DataTable/GroupedBody.js +1 -0
- package/es6/components/DataTable/StyledDataTable.js +2 -2
- package/es6/components/DataTableColumns/DataTableColumns.js +2 -1
- package/es6/components/DataTableColumns/stories/Simple.js +10 -6
- package/es6/components/DataView/DataView.js +22 -7
- package/es6/components/DataView/stories/Simple.js +9 -6
- package/es6/components/DateInput/DateInput.js +2 -1
- package/es6/components/Distribution/Distribution.js +1 -1
- package/es6/components/Drop/DropContainer.js +34 -81
- package/es6/components/Drop/stories/Overflow.js +1 -0
- package/es6/components/DropButton/DropButton.js +1 -1
- package/es6/components/Form/stories/Controlled.js +11 -2
- package/es6/components/Form/stories/ControlledInput.js +13 -2
- package/es6/components/Form/stories/ControlledInputLazy.js +13 -2
- package/es6/components/Form/stories/ControlledLazy.js +13 -2
- package/es6/components/Form/stories/FieldWithChildren.js +13 -2
- package/es6/components/Form/stories/FieldWithComponentProp.js +17 -1
- package/es6/components/Form/stories/Uncontrolled.js +15 -2
- package/es6/components/Form/stories/ValidateOnChange.js +6 -0
- package/es6/components/Form/stories/ValidateOnMount.js +4 -0
- package/es6/components/Form/stories/typescript/TypedForm.tsx +25 -3
- package/es6/components/Layer/LayerContainer.js +1 -1
- package/es6/components/Layer/StyledLayer.js +3 -1
- package/es6/components/MaskedInput/MaskedInput.js +4 -3
- package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/es6/components/Notification/Notification.js +7 -3
- package/es6/components/PageHeader/PageHeader.js +6 -4
- package/es6/components/Pagination/Pagination.js +8 -0
- package/es6/components/Pagination/StyledPageControl.js +3 -1
- package/es6/components/Paragraph/Paragraph.js +19 -7
- package/es6/components/Paragraph/stories/All.js +5 -1
- package/es6/components/SelectMultiple/SelectMultiple.js +11 -10
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/es6/components/SelectMultiple/stories/Help.js +42 -0
- package/es6/components/Tabs/Tabs.js +2 -1
- package/es6/components/Text/Text.js +10 -2
- package/es6/components/Text/TextContext.js +2 -0
- package/es6/components/TextInput/StyledTextInput.js +6 -3
- package/es6/components/TextInput/TextInput.js +8 -5
- package/es6/components/TextInput/index.d.ts +3 -1
- package/es6/components/TextInput/propTypes.js +3 -1
- package/es6/components/Toolbar/stories/Simple.js +1 -1
- package/es6/components/WorldMap/WorldMap.js +17 -14
- package/es6/languages/default.json +7 -2
- package/es6/themes/base.d.ts +34 -0
- package/es6/themes/base.js +37 -1
- package/es6/utils/DOM.js +1 -1
- package/es6/utils/background.js +9 -1
- package/es6/utils/colors.js +2 -2
- package/es6/utils/general-prop-types.js +1 -1
- package/es6/utils/icon.js +7 -0
- package/es6/utils/index.d.ts +7 -1
- package/es6/utils/index.js +1 -0
- package/es6/utils/styles.js +10 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +7 -2
- package/package.json +41 -39
- package/themes/base.d.ts +34 -0
- package/themes/base.js +37 -1
- package/utils/DOM.js +1 -1
- package/utils/background.js +8 -0
- package/utils/colors.js +3 -1
- package/utils/general-prop-types.js +1 -1
- package/utils/icon.js +12 -0
- package/utils/index.d.ts +7 -1
- package/utils/index.js +6 -0
- package/utils/styles.js +12 -1
|
@@ -10,7 +10,8 @@ var _Box = require("../Box");
|
|
|
10
10
|
var _StyledAnchor = require("./StyledAnchor");
|
|
11
11
|
var _propTypes = require("./propTypes");
|
|
12
12
|
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
13
|
-
var
|
|
13
|
+
var _TextContext = require("../Text/TextContext");
|
|
14
|
+
var _excluded = ["a11yTitle", "aria-label", "children", "color", "disabled", "gap", "href", "icon", "label", "onBlur", "onClick", "onFocus", "reverse", "size"];
|
|
14
15
|
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); }
|
|
15
16
|
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
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); }
|
|
@@ -29,11 +30,14 @@ var Anchor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
29
30
|
onClickProp = _ref.onClick,
|
|
30
31
|
_onFocus = _ref.onFocus,
|
|
31
32
|
reverse = _ref.reverse,
|
|
33
|
+
sizeProp = _ref.size,
|
|
32
34
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
33
35
|
var theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _defaultProps.defaultProps.theme;
|
|
34
36
|
var _useState = (0, _react.useState)(),
|
|
35
37
|
focus = _useState[0],
|
|
36
38
|
setFocus = _useState[1];
|
|
39
|
+
var _useContext = (0, _react.useContext)(_TextContext.TextContext),
|
|
40
|
+
size = _useContext.size;
|
|
37
41
|
var sendAnalytics = (0, _AnalyticsContext.useAnalytics)();
|
|
38
42
|
var onClick = (0, _react.useCallback)(function (event) {
|
|
39
43
|
sendAnalytics({
|
|
@@ -52,12 +56,14 @@ var Anchor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
52
56
|
}, [children, icon, label]);
|
|
53
57
|
var coloredIcon = icon;
|
|
54
58
|
if (icon && !icon.props.color) {
|
|
59
|
+
var _theme$anchor, _theme$anchor$size, _theme$anchor$size2;
|
|
55
60
|
coloredIcon = /*#__PURE__*/(0, _react.cloneElement)(icon, {
|
|
56
|
-
color: (0, _utils.normalizeColor)(color || theme.anchor.color, theme)
|
|
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)
|
|
57
62
|
});
|
|
58
63
|
}
|
|
59
|
-
var
|
|
60
|
-
var
|
|
64
|
+
var anchorIcon = (0, _utils.useSizedIcon)(coloredIcon, sizeProp || size, theme);
|
|
65
|
+
var first = reverse ? label : anchorIcon;
|
|
66
|
+
var second = reverse ? anchorIcon : label;
|
|
61
67
|
return /*#__PURE__*/_react["default"].createElement(_StyledAnchor.StyledAnchor, _extends({}, rest, {
|
|
62
68
|
ref: ref,
|
|
63
69
|
"aria-label": ariaLabel || a11yTitle,
|
|
@@ -76,7 +82,8 @@ var Anchor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
76
82
|
onBlur: function onBlur(event) {
|
|
77
83
|
setFocus(false);
|
|
78
84
|
if (_onBlur) _onBlur(event);
|
|
79
|
-
}
|
|
85
|
+
},
|
|
86
|
+
size: sizeProp || size
|
|
80
87
|
}), first && second ? /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
81
88
|
as: "span",
|
|
82
89
|
direction: "row",
|
|
@@ -28,11 +28,14 @@ var StyledAnchor = _styledComponents["default"].a.withConfig({
|
|
|
28
28
|
})(["box-sizing:border-box;", " color:", ";", " text-decoration:", ";cursor:pointer;", " ", " ", " ", " ", " ", ""], function (props) {
|
|
29
29
|
return sizeStyle(props);
|
|
30
30
|
}, function (props) {
|
|
31
|
-
|
|
31
|
+
var _props$theme$anchor, _props$theme$anchor$s, _props$theme$anchor$s2;
|
|
32
|
+
return (0, _utils.normalizeColor)(props.colorProp || ((_props$theme$anchor = props.theme.anchor) == null ? void 0 : (_props$theme$anchor$s = _props$theme$anchor.size) == null ? void 0 : (_props$theme$anchor$s2 = _props$theme$anchor$s[props.size]) == null ? void 0 : _props$theme$anchor$s2.color) || props.theme.anchor.color, props.theme);
|
|
32
33
|
}, function (props) {
|
|
33
|
-
|
|
34
|
+
var _props$theme$anchor2, _props$theme$anchor2$, _props$theme$anchor2$2, _props$theme$anchor3, _props$theme$anchor3$, _props$theme$anchor3$2;
|
|
35
|
+
return props.weight ? "font-weight: " + props.weight + ";" : (((_props$theme$anchor2 = props.theme.anchor) == null ? void 0 : (_props$theme$anchor2$ = _props$theme$anchor2.size) == null ? void 0 : (_props$theme$anchor2$2 = _props$theme$anchor2$[props.size]) == null ? void 0 : _props$theme$anchor2$2.fontWeight) || props.theme.anchor.fontWeight) && "font-weight: " + (((_props$theme$anchor3 = props.theme.anchor) == null ? void 0 : (_props$theme$anchor3$ = _props$theme$anchor3.size) == null ? void 0 : (_props$theme$anchor3$2 = _props$theme$anchor3$[props.size]) == null ? void 0 : _props$theme$anchor3$2.fontWeight) || props.theme.anchor.fontWeight) + ";";
|
|
34
36
|
}, function (props) {
|
|
35
|
-
|
|
37
|
+
var _props$theme$anchor4, _props$theme$anchor4$, _props$theme$anchor4$2;
|
|
38
|
+
return props.hasIcon ? 'none' : ((_props$theme$anchor4 = props.theme.anchor) == null ? void 0 : (_props$theme$anchor4$ = _props$theme$anchor4.size) == null ? void 0 : (_props$theme$anchor4$2 = _props$theme$anchor4$[props.size]) == null ? void 0 : _props$theme$anchor4$2.textDecoration) || props.theme.anchor.textDecoration;
|
|
36
39
|
}, _utils.genericStyles, function (props) {
|
|
37
40
|
return !props.disabled && props.theme.anchor.hover && (0, _styledComponents.css)(["&:hover{", " ", " ", "}"], props.theme.anchor.hover.textDecoration && "text-decoration: " + props.theme.anchor.hover.textDecoration + ";", props.theme.anchor.hover.fontWeight && "font-weight: " + props.theme.anchor.hover.fontWeight + ";", props.theme.anchor.hover.extend);
|
|
38
41
|
}, function (props) {
|
|
@@ -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 (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
64
|
-
|
|
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,
|
|
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
|
|
84
|
-
|
|
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 =
|
|
91
|
-
stackRef.current.children[1].style.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
|
|
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,12 +160,13 @@ 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,
|
|
166
167
|
secondary = _ref.secondary,
|
|
167
168
|
selected = _ref.selected,
|
|
168
|
-
|
|
169
|
+
sizeProp = _ref.size,
|
|
169
170
|
tip = _ref.tip,
|
|
170
171
|
_ref$type = _ref.type,
|
|
171
172
|
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
@@ -213,6 +214,9 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
213
214
|
return undefined; // pre-default, no kind
|
|
214
215
|
}, [kindArg, kindObj, primary, secondary, theme]);
|
|
215
216
|
|
|
217
|
+
// for backwards compatibility, no-kind button theme did not
|
|
218
|
+
// default to size "medium" on buttons with no size prop
|
|
219
|
+
var size = sizeProp || kind && 'medium' || undefined;
|
|
216
220
|
// When we have a kind and are not plain, themePaths stores the relative
|
|
217
221
|
// paths within the theme for the current kind and state of the button.
|
|
218
222
|
// These paths are used with getIconColor() above and kindStyle() within
|
|
@@ -247,14 +251,6 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
247
251
|
}
|
|
248
252
|
return result;
|
|
249
253
|
}, [active, disabled, kind, kindObj, plain, selected]);
|
|
250
|
-
if (skeleton) {
|
|
251
|
-
var _theme$text, _theme$button$size;
|
|
252
|
-
return /*#__PURE__*/_react["default"].createElement(_Skeleton.Skeleton, _extends({
|
|
253
|
-
ref: ref,
|
|
254
|
-
height: ((_theme$text = theme.text[size || 'medium']) == null ? void 0 : _theme$text.height) || size,
|
|
255
|
-
a11yTitle: a11yTitle
|
|
256
|
-
}, rest, (_theme$button$size = theme.button.size) == null ? void 0 : _theme$button$size[size || 'medium'], theme.button.skeleton));
|
|
257
|
-
}
|
|
258
254
|
|
|
259
255
|
// only used when theme does not have button.default
|
|
260
256
|
var isDarkBackground = function isDarkBackground() {
|
|
@@ -296,14 +292,24 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
296
292
|
color: _iconColor
|
|
297
293
|
});
|
|
298
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
|
+
}
|
|
299
304
|
var reverse = reverseProp != null ? reverseProp : (_theme$button$kind = theme.button[kind]) == null ? void 0 : _theme$button$kind.reverse;
|
|
300
305
|
var domTag = !as && href ? 'a' : as;
|
|
301
306
|
var first = reverse ? label : buttonIcon;
|
|
302
307
|
var second = reverse ? buttonIcon : label;
|
|
303
308
|
var contents;
|
|
304
309
|
if (first && second) {
|
|
310
|
+
var _theme$button, _theme$button$kind2;
|
|
305
311
|
contents = /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
306
|
-
direction:
|
|
312
|
+
direction: ((_theme$button = theme.button) == null ? void 0 : (_theme$button$kind2 = _theme$button[kind]) == null ? void 0 : _theme$button$kind2.direction) || 'row',
|
|
307
313
|
align: "center",
|
|
308
314
|
justify: justify || (align === 'center' ? 'center' : 'between'),
|
|
309
315
|
gap: gap || theme.button.gap,
|
|
@@ -325,7 +331,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
325
331
|
// (!kind && icon && !label) is necessary because for old button logic,
|
|
326
332
|
// if button has icon but not label, it will be considered "plain",
|
|
327
333
|
// so no border or background will be applied
|
|
328
|
-
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);
|
|
329
335
|
if (badgeProp && innerBadge) {
|
|
330
336
|
contents = /*#__PURE__*/_react["default"].createElement(_Badge.Badge, {
|
|
331
337
|
content: badgeProp
|
|
@@ -363,6 +369,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
363
369
|
},
|
|
364
370
|
onMouseOver: onMouseOverButton,
|
|
365
371
|
onMouseOut: onMouseOutButton,
|
|
372
|
+
pad: pad,
|
|
366
373
|
plain: plain || _react.Children.count(children) > 0,
|
|
367
374
|
primary: primary,
|
|
368
375
|
sizeProp: size,
|
|
@@ -397,7 +404,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
397
404
|
},
|
|
398
405
|
onMouseOver: onMouseOverButton,
|
|
399
406
|
onMouseOut: onMouseOutButton,
|
|
400
|
-
pad: !plain,
|
|
407
|
+
pad: pad || !plain,
|
|
401
408
|
plain: typeof plain !== 'undefined' ? plain : _react.Children.count(children) > 0 || icon && !label,
|
|
402
409
|
primary: primary,
|
|
403
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,14 +19,22 @@ 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
|
-
var padFromTheme = function padFromTheme(size, theme, themeObj, kind) {
|
|
25
|
-
var _themeObj$size, _themeObj$size$size, _themeObj$size$size$
|
|
24
|
+
var padFromTheme = function padFromTheme(size, theme, themeObj, kind, iconOnly) {
|
|
25
|
+
var _themeObj$size, _themeObj$size$size, _themeObj$size$size$i, _themeObj$size3, _themeObj$size3$size, _themeObj$size3$size$;
|
|
26
26
|
if (size === void 0) {
|
|
27
27
|
size = 'medium';
|
|
28
28
|
}
|
|
29
|
-
if (size && themeObj != null && (_themeObj$size = themeObj.size) != null && (_themeObj$size$size = _themeObj$size[size]) != null && (_themeObj$size$size$
|
|
29
|
+
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) {
|
|
30
|
+
var _themeObj$size2, _themeObj$size2$size, _themeObj$size2$size$;
|
|
31
|
+
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;
|
|
32
|
+
return {
|
|
33
|
+
vertical: typeof pad === 'string' ? pad : pad.vertical,
|
|
34
|
+
horizontal: typeof pad === 'string' ? pad : pad.horizontal
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
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) {
|
|
30
38
|
return themeObj.size[size][kind].pad;
|
|
31
39
|
}
|
|
32
40
|
if (size && themeObj.size && themeObj.size[size] && themeObj.size[size].pad) {
|
|
@@ -44,13 +52,16 @@ var padFromTheme = function padFromTheme(size, theme, themeObj, kind) {
|
|
|
44
52
|
return undefined;
|
|
45
53
|
};
|
|
46
54
|
var padStyle = function padStyle(_ref) {
|
|
47
|
-
var
|
|
55
|
+
var hasIcon = _ref.hasIcon,
|
|
56
|
+
hasLabel = _ref.hasLabel,
|
|
57
|
+
size = _ref.sizeProp,
|
|
48
58
|
theme = _ref.theme,
|
|
49
59
|
kind = _ref.kind;
|
|
50
60
|
// caller has specified a themeObj to use for styling
|
|
51
61
|
// relevant for cases like pagination which looks to theme.pagination.button
|
|
52
62
|
var themeObj = typeof kind === 'object' ? kind : theme.button;
|
|
53
|
-
var
|
|
63
|
+
var iconOnly = hasIcon && !hasLabel;
|
|
64
|
+
var pad = padFromTheme(size, theme, themeObj, kind, iconOnly);
|
|
54
65
|
return pad ? (0, _styledComponents.css)(["padding:", " ", ";"], pad.vertical, pad.horizontal) : '';
|
|
55
66
|
};
|
|
56
67
|
var basicStyle = function basicStyle(props) {
|
|
@@ -73,6 +84,8 @@ var adjustPadStyle = function adjustPadStyle(pad, width) {
|
|
|
73
84
|
// build up CSS from basic to specific based on the supplied sub-object paths
|
|
74
85
|
var kindStyle = function kindStyle(_ref2) {
|
|
75
86
|
var colorValue = _ref2.colorValue,
|
|
87
|
+
hasIcon = _ref2.hasIcon,
|
|
88
|
+
hasLabel = _ref2.hasLabel,
|
|
76
89
|
kind = _ref2.kind,
|
|
77
90
|
size = _ref2.sizeProp,
|
|
78
91
|
themePaths = _ref2.themePaths,
|
|
@@ -82,7 +95,8 @@ var kindStyle = function kindStyle(_ref2) {
|
|
|
82
95
|
// caller has specified a themeObj to use for styling
|
|
83
96
|
// relevant for cases like pagination which looks to theme.pagination.button
|
|
84
97
|
var themeObj = typeof kind === 'object' ? kind : theme.button;
|
|
85
|
-
var
|
|
98
|
+
var iconOnly = hasIcon && !hasLabel;
|
|
99
|
+
var pad = padFromTheme(size, theme, themeObj, kind, iconOnly);
|
|
86
100
|
themePaths.base.forEach(function (themePath) {
|
|
87
101
|
var obj = getPath(themeObj, themePath);
|
|
88
102
|
if (obj) {
|
|
@@ -152,7 +166,7 @@ var fillStyle = function fillStyle(fillContainer) {
|
|
|
152
166
|
return undefined;
|
|
153
167
|
};
|
|
154
168
|
var plainStyle = function plainStyle(props) {
|
|
155
|
-
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;");
|
|
156
170
|
};
|
|
157
171
|
var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
158
172
|
// don't let kind attribute leak to DOM
|
|
@@ -163,7 +177,7 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
|
163
177
|
}).withConfig({
|
|
164
178
|
displayName: "StyledButtonKind",
|
|
165
179
|
componentId: "sc-1vhfpnt-0"
|
|
166
|
-
})(["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) {
|
|
167
181
|
return props.plain && plainStyle(props);
|
|
168
182
|
}, function (props) {
|
|
169
183
|
return !props.disabled && props.active && _utils.activeStyle;
|
|
@@ -171,6 +185,8 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
|
171
185
|
return !props.plain && basicStyle(props);
|
|
172
186
|
}, function (props) {
|
|
173
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);
|
|
174
190
|
}, function (props) {
|
|
175
191
|
return !props.plain && props.align && "\n text-align: " + props.align + ";\n ";
|
|
176
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,
|
|
@@ -9,8 +9,10 @@ var _MessageContext = require("../../contexts/MessageContext");
|
|
|
9
9
|
var _defaultProps = require("../../default-props");
|
|
10
10
|
var _Box = require("../Box");
|
|
11
11
|
var _Button = require("../Button");
|
|
12
|
+
var _Header = require("../Header");
|
|
12
13
|
var _Heading = require("../Heading");
|
|
13
14
|
var _Keyboard = require("../Keyboard");
|
|
15
|
+
var _Text = require("../Text");
|
|
14
16
|
var _propTypes = require("./propTypes");
|
|
15
17
|
var _StyledCalendar = require("./StyledCalendar");
|
|
16
18
|
var _utils = require("./utils");
|
|
@@ -502,26 +504,32 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
502
504
|
setActive(selectedDate);
|
|
503
505
|
};
|
|
504
506
|
var renderCalendarHeader = function renderCalendarHeader() {
|
|
507
|
+
var _theme$calendar$size;
|
|
505
508
|
var PreviousIcon = size === 'small' ? theme.calendar.icons.small.previous : theme.calendar.icons.previous;
|
|
506
509
|
var NextIcon = size === 'small' ? theme.calendar.icons.small.next : theme.calendar.icons.next;
|
|
510
|
+
var monthAndYear = reference.toLocaleDateString(locale, {
|
|
511
|
+
month: 'long',
|
|
512
|
+
year: 'numeric'
|
|
513
|
+
});
|
|
507
514
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
508
515
|
direction: "row",
|
|
509
516
|
justify: "between",
|
|
510
517
|
align: "center"
|
|
511
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
518
|
+
}, /*#__PURE__*/_react["default"].createElement(_Header.Header, {
|
|
512
519
|
flex: true,
|
|
513
520
|
pad: {
|
|
514
521
|
horizontal: headingPadMap[size] || 'small'
|
|
515
522
|
}
|
|
516
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
523
|
+
}, (_theme$calendar$size = theme.calendar[size]) != null && _theme$calendar$size.title ? /*#__PURE__*/_react["default"].createElement(_Text.Text, theme.calendar[size].title, monthAndYear) :
|
|
524
|
+
/*#__PURE__*/
|
|
525
|
+
// theme.calendar.heading.level should be removed in v3 of grommet
|
|
526
|
+
// theme.calendar[size].title should be used instead
|
|
527
|
+
_react["default"].createElement(_Heading.Heading, {
|
|
517
528
|
level: size === 'small' ? theme.calendar.heading && theme.calendar.heading.level || 4 : (theme.calendar.heading && theme.calendar.heading.level || 4) - 1,
|
|
518
529
|
size: size,
|
|
519
530
|
margin: "none",
|
|
520
531
|
overflowWrap: "normal"
|
|
521
|
-
},
|
|
522
|
-
month: 'long',
|
|
523
|
-
year: 'numeric'
|
|
524
|
-
}))), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
532
|
+
}, monthAndYear)), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
525
533
|
flex: false,
|
|
526
534
|
direction: "row",
|
|
527
535
|
align: "center"
|