grommet 2.30.0 → 2.32.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/Accordion/Accordion.js +4 -2
- package/components/Accordion/index.d.ts +1 -0
- package/components/Accordion/propTypes.js +1 -0
- package/components/AccordionPanel/AccordionPanel.js +2 -1
- package/components/Anchor/Anchor.js +3 -2
- package/components/Box/Box.js +14 -4
- package/components/Box/stories/Border.js +15 -1
- package/components/Button/Badge.js +42 -43
- package/components/Button/BusyAnimation.js +51 -0
- package/components/Button/Button.js +78 -15
- package/components/Button/StyledButton.js +7 -3
- package/components/Button/StyledButtonKind.js +12 -6
- package/components/Button/index.d.ts +9 -0
- package/components/Button/propTypes.js +7 -0
- package/components/Button/stories/Busy.js +45 -0
- package/components/Calendar/stories/Dual.js +4 -6
- package/components/CheckBox/index.d.ts +1 -1
- package/components/Data/DataForm.js +45 -35
- package/components/Data/filter.js +9 -1
- package/components/Data/stories/Complex.js +63 -6
- package/components/Data/stories/Inline.js +19 -2
- package/components/DataFilter/DataFilter.js +11 -1
- package/components/DataFilters/DataFilters.js +13 -10
- package/components/DataTable/Body.js +16 -13
- package/components/DataTable/DataTable.js +4 -1
- package/components/DataTable/GroupedBody.js +1 -0
- package/components/DataTable/Header.js +1 -0
- package/components/DataTable/buildState.js +12 -10
- package/components/DataTable/stories/Controlled.js +2 -1
- package/components/DataTable/stories/ControlledGrouped.js +2 -1
- package/components/DataTable/stories/CustomThemed/Custom.js +0 -1
- package/components/DataTable/stories/CustomThemed/Fill.js +2 -1
- package/components/DataTable/stories/GroupedOnSelect.js +2 -1
- package/components/DataTable/stories/NoPrimary.js +0 -1
- package/components/DataTable/stories/OnUpdate.js +2 -1
- package/components/DataTable/stories/Served.js +2 -1
- package/components/DataTable/stories/Tunable.js +2 -1
- package/components/DataTable/stories/rowDetails.js +2 -1
- package/components/DataTableColumns/DataTableColumns.js +5 -0
- package/components/DataTableColumns/stories/Simple.js +4 -3
- package/components/DataTableGroupBy/DataTableGroupBy.js +67 -0
- package/components/DataTableGroupBy/README.md +2 -0
- package/components/DataTableGroupBy/index.d.ts +20 -0
- package/components/DataTableGroupBy/index.js +6 -0
- package/components/DataTableGroupBy/propTypes.js +17 -0
- package/components/DataTableGroupBy/stories/Simple.js +50 -0
- package/components/DataView/DataView.js +1 -1
- package/components/DateInput/DateInput.js +3 -2
- package/components/Drop/DropContainer.js +2 -2
- package/components/DropButton/DropButton.js +2 -2
- package/components/FileInput/FileInput.js +82 -53
- package/components/Form/Form.js +95 -44
- package/components/Form/stories/TriggerValidationUsingFormField.js +109 -0
- package/components/FormField/FormField.js +4 -3
- package/components/FormField/index.d.ts +1 -0
- package/components/FormField/propTypes.js +2 -1
- package/components/Grid/stories/CustomThemed/Responsive.js +0 -1
- package/components/InfiniteScroll/InfiniteScroll.js +1 -0
- package/components/Layer/Layer.js +1 -1
- package/components/Layer/LayerContainer.js +2 -2
- package/components/List/index.d.ts +2 -2
- package/components/MaskedInput/MaskedInput.js +3 -2
- package/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/components/NameValueList/NameValueList.js +1 -1
- package/components/Notification/Notification.js +7 -3
- package/components/PageHeader/PageHeader.js +6 -4
- package/components/Pagination/StyledPageControl.js +3 -1
- package/components/Paragraph/Paragraph.js +2 -2
- package/components/Paragraph/stories/All.js +5 -1
- package/components/SelectMultiple/SelectMultiple.js +24 -20
- package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/components/SelectMultiple/SelectMultipleValue.js +1 -1
- package/components/SelectMultiple/stories/Help.js +49 -0
- package/components/Text/Text.js +2 -2
- package/components/TextInput/StyledTextInput.js +2 -1
- package/components/TextInput/TextInput.js +3 -2
- package/components/Tip/stories/HeaderActions.js +0 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +6 -0
- package/es6/components/Accordion/Accordion.js +4 -2
- package/es6/components/Accordion/index.d.ts +1 -0
- package/es6/components/Accordion/propTypes.js +1 -0
- package/es6/components/AccordionPanel/AccordionPanel.js +2 -1
- package/es6/components/Anchor/Anchor.js +4 -3
- package/es6/components/Box/Box.js +14 -4
- package/es6/components/Box/stories/Border.js +15 -1
- package/es6/components/Button/Badge.js +43 -44
- package/es6/components/Button/BusyAnimation.js +41 -0
- package/es6/components/Button/Button.js +79 -17
- package/es6/components/Button/StyledButton.js +8 -4
- package/es6/components/Button/StyledButtonKind.js +13 -7
- package/es6/components/Button/index.d.ts +9 -0
- package/es6/components/Button/propTypes.js +8 -1
- package/es6/components/Button/stories/Busy.js +37 -0
- package/es6/components/Calendar/stories/Dual.js +4 -6
- package/es6/components/CheckBox/index.d.ts +1 -1
- package/es6/components/Data/DataForm.js +43 -34
- package/es6/components/Data/filter.js +9 -1
- package/es6/components/Data/stories/Complex.js +64 -7
- package/es6/components/Data/stories/Inline.js +20 -3
- package/es6/components/DataFilter/DataFilter.js +11 -1
- package/es6/components/DataFilters/DataFilters.js +13 -10
- package/es6/components/DataTable/Body.js +15 -13
- package/es6/components/DataTable/DataTable.js +4 -1
- package/es6/components/DataTable/GroupedBody.js +1 -0
- package/es6/components/DataTable/buildState.js +12 -10
- package/es6/components/DataTableColumns/DataTableColumns.js +5 -0
- package/es6/components/DataTableColumns/stories/Simple.js +5 -4
- package/es6/components/DataTableGroupBy/DataTableGroupBy.js +60 -0
- package/es6/components/DataTableGroupBy/README.md +2 -0
- package/es6/components/DataTableGroupBy/index.d.ts +20 -0
- package/es6/components/DataTableGroupBy/index.js +1 -0
- package/es6/components/DataTableGroupBy/propTypes.js +11 -0
- package/es6/components/DataTableGroupBy/stories/Simple.js +45 -0
- package/es6/components/DataView/DataView.js +1 -1
- package/es6/components/DateInput/DateInput.js +3 -2
- package/es6/components/Drop/DropContainer.js +2 -2
- package/es6/components/DropButton/DropButton.js +2 -2
- package/es6/components/FileInput/FileInput.js +83 -53
- package/es6/components/Form/Form.js +95 -44
- package/es6/components/Form/stories/TriggerValidationUsingFormField.js +102 -0
- package/es6/components/FormField/FormField.js +4 -3
- package/es6/components/FormField/index.d.ts +1 -0
- package/es6/components/FormField/propTypes.js +2 -1
- package/es6/components/InfiniteScroll/InfiniteScroll.js +1 -0
- package/es6/components/Layer/Layer.js +1 -1
- package/es6/components/Layer/LayerContainer.js +2 -2
- package/es6/components/List/index.d.ts +2 -2
- package/es6/components/MaskedInput/MaskedInput.js +4 -3
- package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/es6/components/NameValueList/NameValueList.js +1 -1
- package/es6/components/Notification/Notification.js +7 -3
- package/es6/components/PageHeader/PageHeader.js +6 -4
- package/es6/components/Pagination/StyledPageControl.js +3 -1
- package/es6/components/Paragraph/Paragraph.js +2 -2
- package/es6/components/Paragraph/stories/All.js +5 -1
- package/es6/components/SelectMultiple/SelectMultiple.js +24 -20
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/es6/components/SelectMultiple/SelectMultipleValue.js +1 -1
- package/es6/components/SelectMultiple/stories/Help.js +42 -0
- package/es6/components/Text/Text.js +2 -2
- package/es6/components/TextInput/StyledTextInput.js +2 -1
- package/es6/components/TextInput/TextInput.js +4 -3
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/index.d.ts +1 -0
- package/es6/languages/default.json +15 -2
- package/es6/themes/base.d.ts +3 -0
- package/es6/themes/base.js +7 -1
- package/es6/utils/icon.js +7 -0
- 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/index.d.ts +1 -0
- package/languages/default.json +15 -2
- package/package.json +49 -48
- package/themes/base.d.ts +3 -0
- package/themes/base.js +7 -1
- package/utils/icon.js +12 -0
- package/utils/index.js +6 -0
- package/utils/styles.js +12 -1
|
@@ -6,7 +6,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
6
6
|
var _propTypes = require("./propTypes");
|
|
7
7
|
var _Box = require("../Box");
|
|
8
8
|
var _AccordionContext = require("./AccordionContext");
|
|
9
|
-
var _excluded = ["activeIndex", "animate", "children", "multiple", "onActive"];
|
|
9
|
+
var _excluded = ["activeIndex", "animate", "children", "level", "multiple", "onActive"];
|
|
10
10
|
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); }
|
|
11
11
|
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; }
|
|
12
12
|
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); }
|
|
@@ -19,6 +19,7 @@ var Accordion = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
19
19
|
_ref$animate = _ref.animate,
|
|
20
20
|
animate = _ref$animate === void 0 ? true : _ref$animate,
|
|
21
21
|
children = _ref.children,
|
|
22
|
+
level = _ref.level,
|
|
22
23
|
multiple = _ref.multiple,
|
|
23
24
|
onActive = _ref.onActive,
|
|
24
25
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -55,11 +56,12 @@ var Accordion = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
55
56
|
return {
|
|
56
57
|
active: activeIndexes.indexOf(index) > -1,
|
|
57
58
|
animate: animate,
|
|
59
|
+
level: level,
|
|
58
60
|
onPanelChange: function onPanelChange() {
|
|
59
61
|
return _onPanelChange(index);
|
|
60
62
|
}
|
|
61
63
|
};
|
|
62
|
-
}, [activeIndexes, animate, multiple, onActive]);
|
|
64
|
+
}, [activeIndexes, animate, level, multiple, onActive]);
|
|
63
65
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
|
|
64
66
|
ref: ref
|
|
65
67
|
}, rest), _react.Children.toArray(children).filter(function (child) {
|
|
@@ -12,6 +12,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
12
12
|
activeIndex: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].arrayOf(_propTypes["default"].number)]),
|
|
13
13
|
animate: _propTypes["default"].bool,
|
|
14
14
|
children: _propTypes["default"].node,
|
|
15
|
+
level: _propTypes["default"].number,
|
|
15
16
|
onActive: _propTypes["default"].func,
|
|
16
17
|
multiple: _propTypes["default"].bool,
|
|
17
18
|
messages: _propTypes["default"].shape({
|
|
@@ -31,6 +31,7 @@ var AccordionPanel = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
31
31
|
var _useContext = (0, _react.useContext)(_AccordionContext.AccordionContext),
|
|
32
32
|
active = _useContext.active,
|
|
33
33
|
animate = _useContext.animate,
|
|
34
|
+
level = _useContext.level,
|
|
34
35
|
onPanelChange = _useContext.onPanelChange;
|
|
35
36
|
var _useState = (0, _react.useState)(undefined),
|
|
36
37
|
hover = _useState[0],
|
|
@@ -110,7 +111,7 @@ var AccordionPanel = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
110
111
|
horizontal: 'xsmall'
|
|
111
112
|
}
|
|
112
113
|
}, /*#__PURE__*/_react["default"].createElement(_Heading.Heading, {
|
|
113
|
-
level: theme.accordion.heading && theme.accordion.heading.level || 4,
|
|
114
|
+
level: level || theme.accordion.heading && theme.accordion.heading.level || 4,
|
|
114
115
|
margin: theme.accordion.heading && theme.accordion.heading.margin || undefined,
|
|
115
116
|
color: hover
|
|
116
117
|
}, label)) : label, AccordionIcon && /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
@@ -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
|
|
65
|
-
var
|
|
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,
|
package/components/Box/Box.js
CHANGED
|
@@ -91,13 +91,21 @@ var Box = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
91
91
|
if (focusable) return 0;
|
|
92
92
|
return undefined;
|
|
93
93
|
}, [focusable, tabIndex]);
|
|
94
|
-
if ((border === 'between' || border && border.side === 'between') &&
|
|
94
|
+
if ((border === 'between' || border && border.side === 'between' || Array.isArray(border) && border.find(function (b) {
|
|
95
|
+
return b.side === 'between';
|
|
96
|
+
})) && !gap) {
|
|
95
97
|
console.warn('Box must have a gap to use border between');
|
|
96
98
|
}
|
|
97
99
|
var contents = children;
|
|
98
100
|
if (gap && gap !== 'none' && (!(boxOptions != null && boxOptions.cssGap || cssGap) ||
|
|
99
101
|
// need this approach to show border between
|
|
100
|
-
border === 'between' || (border == null ? void 0 : border.side) === 'between')) {
|
|
102
|
+
border === 'between' || (border == null ? void 0 : border.side) === 'between' || Array.isArray(border) && border.find(function (b) {
|
|
103
|
+
return b.side === 'between';
|
|
104
|
+
}))) {
|
|
105
|
+
// if border is an array, we need to extract the border between object
|
|
106
|
+
var styledBoxGapBorder = Array.isArray(border) ? border.find(function (b) {
|
|
107
|
+
return b.side === 'between';
|
|
108
|
+
}) : border;
|
|
101
109
|
var boxAs = !as && tag ? tag : as;
|
|
102
110
|
contents = [];
|
|
103
111
|
var firstIndex;
|
|
@@ -114,7 +122,7 @@ var Box = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
114
122
|
gap: gap,
|
|
115
123
|
directionProp: direction,
|
|
116
124
|
responsive: responsive,
|
|
117
|
-
border:
|
|
125
|
+
border: styledBoxGapBorder
|
|
118
126
|
}));
|
|
119
127
|
}
|
|
120
128
|
}
|
|
@@ -183,7 +191,9 @@ var Box = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
183
191
|
elevationProp: elevation,
|
|
184
192
|
fillProp: fill,
|
|
185
193
|
focus: focus,
|
|
186
|
-
gap: ((boxOptions == null ? void 0 : boxOptions.cssGap) || cssGap) && gap && gap !== 'none' && border !== 'between' && (border == null ? void 0 : border.side) !== 'between' &&
|
|
194
|
+
gap: ((boxOptions == null ? void 0 : boxOptions.cssGap) || cssGap) && gap && gap !== 'none' && border !== 'between' && (border == null ? void 0 : border.side) !== 'between' && (!Array.isArray(border) || !border.find(function (b) {
|
|
195
|
+
return b.side === 'between';
|
|
196
|
+
})) && gap,
|
|
187
197
|
kindProp: kind,
|
|
188
198
|
overflowProp: overflow,
|
|
189
199
|
wrapProp: wrap,
|
|
@@ -98,7 +98,21 @@ var BorderBox = function BorderBox() {
|
|
|
98
98
|
size: 'large'
|
|
99
99
|
}
|
|
100
100
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "between"), /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, direction));
|
|
101
|
-
}))
|
|
101
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
102
|
+
direction: "row",
|
|
103
|
+
gap: "small",
|
|
104
|
+
border: [{
|
|
105
|
+
side: 'between'
|
|
106
|
+
}, {
|
|
107
|
+
side: 'top'
|
|
108
|
+
}, {
|
|
109
|
+
side: 'right'
|
|
110
|
+
}, {
|
|
111
|
+
side: 'bottom'
|
|
112
|
+
}, {
|
|
113
|
+
side: 'left'
|
|
114
|
+
}]
|
|
115
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "Multiple Border"), /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, "With Between")))
|
|
102
116
|
// </Grommet>
|
|
103
117
|
);
|
|
104
118
|
};
|
|
@@ -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, {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.StyledBusyContents = exports.GrowCheckmark = exports.EllipsisAnimation = void 0;
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
7
|
+
var _Checkmark = require("grommet-icons/icons/Checkmark");
|
|
8
|
+
var _Box = require("../Box");
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
var bounceDelay = (0, _styledComponents.keyframes)(["0%,80%,100%{transform:scale(0.4);}40%{transform:scale(0.8);}"]);
|
|
13
|
+
var bounceDelayRule = (0, _styledComponents.css)(["animation:", " 1.4s infinite ease-in-out both;"], bounceDelay);
|
|
14
|
+
var Dot = (0, _styledComponents["default"])(_Box.Box).withConfig({
|
|
15
|
+
displayName: "BusyAnimation__Dot",
|
|
16
|
+
componentId: "sc-feuivs-0"
|
|
17
|
+
})(["background-color:currentColor;width:8px;height:8px;border-radius:100%;display:inline-block;", " ", ""], bounceDelayRule, function (props) {
|
|
18
|
+
return props.delay && "animation-delay: " + props.delay + ";";
|
|
19
|
+
});
|
|
20
|
+
var EllipsisAnimation = function EllipsisAnimation() {
|
|
21
|
+
return /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
22
|
+
style: {
|
|
23
|
+
position: 'absolute'
|
|
24
|
+
},
|
|
25
|
+
fill: true,
|
|
26
|
+
alignContent: "center",
|
|
27
|
+
justify: "center"
|
|
28
|
+
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
29
|
+
alignSelf: "center",
|
|
30
|
+
direction: "row",
|
|
31
|
+
gap: "small"
|
|
32
|
+
}, /*#__PURE__*/_react["default"].createElement(Dot, {
|
|
33
|
+
delay: "-0.32s"
|
|
34
|
+
}), /*#__PURE__*/_react["default"].createElement(Dot, {
|
|
35
|
+
delay: "-0.16s"
|
|
36
|
+
}), /*#__PURE__*/_react["default"].createElement(Dot, null)));
|
|
37
|
+
};
|
|
38
|
+
exports.EllipsisAnimation = EllipsisAnimation;
|
|
39
|
+
var grow = (0, _styledComponents.keyframes)(["0%{opacity:0;transform:scale(.3);}20%{opacity:1;transform:scale(1.15);}30%{transform:scale(.9);}45%{transform:scale(1.05);}55%{transform:scale(1);}100%{transform:scale(1);}"]);
|
|
40
|
+
var GrowCheckmark = (0, _styledComponents["default"])(_Checkmark.Checkmark).withConfig({
|
|
41
|
+
displayName: "BusyAnimation__GrowCheckmark",
|
|
42
|
+
componentId: "sc-feuivs-1"
|
|
43
|
+
})(["position:absolute;align-self:center;animation:", " 0.9s ease-in-out;"], grow);
|
|
44
|
+
exports.GrowCheckmark = GrowCheckmark;
|
|
45
|
+
var StyledBusyContents = _styledComponents["default"].div.withConfig({
|
|
46
|
+
displayName: "BusyAnimation__StyledBusyContents",
|
|
47
|
+
componentId: "sc-feuivs-2"
|
|
48
|
+
})(["opacity:", ";}"], function (props) {
|
|
49
|
+
return props.animating ? 0 : 1;
|
|
50
|
+
});
|
|
51
|
+
exports.StyledBusyContents = StyledBusyContents;
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Button = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
-
var _styledComponents = require("styled-components");
|
|
6
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
7
7
|
var _utils = require("../../utils");
|
|
8
8
|
var _defaultProps = require("../../default-props");
|
|
9
9
|
var _propTypes = require("./propTypes");
|
|
10
|
+
var _AnnounceContext = require("../../contexts/AnnounceContext");
|
|
11
|
+
var _MessageContext = require("../../contexts/MessageContext");
|
|
10
12
|
var _Box = require("../Box");
|
|
11
13
|
var _Tip = require("../Tip");
|
|
12
14
|
var _Badge = require("./Badge");
|
|
@@ -14,11 +16,17 @@ var _StyledButton = require("./StyledButton");
|
|
|
14
16
|
var _StyledButtonKind = require("./StyledButtonKind");
|
|
15
17
|
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
16
18
|
var _Skeleton = require("../Skeleton");
|
|
17
|
-
var
|
|
19
|
+
var _BusyAnimation = require("./BusyAnimation");
|
|
20
|
+
var _excluded = ["active", "align", "aria-label", "badge", "busy", "color", "children", "disabled", "icon", "focusIndicator", "gap", "fill", "href", "justify", "kind", "label", "messages", "onBlur", "onClick", "onFocus", "onMouseOut", "onMouseOver", "pad", "plain", "primary", "reverse", "secondary", "selected", "size", "success", "tip", "type", "a11yTitle", "as"];
|
|
18
21
|
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
22
|
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
23
|
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); }
|
|
21
24
|
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; }
|
|
25
|
+
var RelativeBox = (0, _styledComponents["default"])(_Box.Box).withConfig({
|
|
26
|
+
displayName: "Button__RelativeBox",
|
|
27
|
+
componentId: "sc-zuqsuw-0"
|
|
28
|
+
})(["position:relative;"]);
|
|
29
|
+
|
|
22
30
|
// We have two Styled* components to separate
|
|
23
31
|
// the newer default|primary|secondary approach,
|
|
24
32
|
// which we use the term "kind" to refer to,
|
|
@@ -137,12 +145,13 @@ var getPropertyColor = function getPropertyColor(property, paths, theme, kind, p
|
|
|
137
145
|
return result;
|
|
138
146
|
};
|
|
139
147
|
var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
140
|
-
var _theme$button$kind;
|
|
148
|
+
var _theme$button$kind, _theme$button2, _theme$button2$badge;
|
|
141
149
|
var active = _ref.active,
|
|
142
150
|
_ref$align = _ref.align,
|
|
143
151
|
align = _ref$align === void 0 ? 'center' : _ref$align,
|
|
144
152
|
ariaLabel = _ref['aria-label'],
|
|
145
153
|
badgeProp = _ref.badge,
|
|
154
|
+
busy = _ref.busy,
|
|
146
155
|
color = _ref.color,
|
|
147
156
|
children = _ref.children,
|
|
148
157
|
disabled = _ref.disabled,
|
|
@@ -155,17 +164,20 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
155
164
|
justify = _ref.justify,
|
|
156
165
|
kindArg = _ref.kind,
|
|
157
166
|
label = _ref.label,
|
|
167
|
+
messages = _ref.messages,
|
|
158
168
|
_onBlur = _ref.onBlur,
|
|
159
169
|
onClickProp = _ref.onClick,
|
|
160
170
|
_onFocus = _ref.onFocus,
|
|
161
171
|
onMouseOut = _ref.onMouseOut,
|
|
162
172
|
onMouseOver = _ref.onMouseOver,
|
|
173
|
+
pad = _ref.pad,
|
|
163
174
|
plain = _ref.plain,
|
|
164
175
|
primary = _ref.primary,
|
|
165
176
|
reverseProp = _ref.reverse,
|
|
166
177
|
secondary = _ref.secondary,
|
|
167
178
|
selected = _ref.selected,
|
|
168
179
|
sizeProp = _ref.size,
|
|
180
|
+
success = _ref.success,
|
|
169
181
|
tip = _ref.tip,
|
|
170
182
|
_ref$type = _ref.type,
|
|
171
183
|
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
@@ -180,6 +192,21 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
180
192
|
var _useState2 = (0, _react.useState)(false),
|
|
181
193
|
hover = _useState2[0],
|
|
182
194
|
setHover = _useState2[1];
|
|
195
|
+
var announce = (0, _react.useContext)(_AnnounceContext.AnnounceContext);
|
|
196
|
+
var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
|
|
197
|
+
format = _useContext.format;
|
|
198
|
+
if (busy && success) {
|
|
199
|
+
console.warn('Button cannot have both busy and success set to true.');
|
|
200
|
+
}
|
|
201
|
+
(0, _react.useEffect)(function () {
|
|
202
|
+
if (busy) announce(format({
|
|
203
|
+
id: 'button.busy',
|
|
204
|
+
messages: messages
|
|
205
|
+
}));else if (success) announce(format({
|
|
206
|
+
id: 'button.success',
|
|
207
|
+
messages: messages
|
|
208
|
+
}));
|
|
209
|
+
}, [announce, busy, format, messages, success]);
|
|
183
210
|
if ((icon || label) && children) {
|
|
184
211
|
console.warn('Button should not have children if icon or label is provided');
|
|
185
212
|
}
|
|
@@ -250,14 +277,6 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
250
277
|
}
|
|
251
278
|
return result;
|
|
252
279
|
}, [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
280
|
|
|
262
281
|
// only used when theme does not have button.default
|
|
263
282
|
var isDarkBackground = function isDarkBackground() {
|
|
@@ -299,6 +318,15 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
299
318
|
color: _iconColor
|
|
300
319
|
});
|
|
301
320
|
}
|
|
321
|
+
buttonIcon = (0, _utils.useSizedIcon)(buttonIcon, size, theme);
|
|
322
|
+
if (skeleton) {
|
|
323
|
+
var _theme$text, _theme$button$size;
|
|
324
|
+
return /*#__PURE__*/_react["default"].createElement(_Skeleton.Skeleton, _extends({
|
|
325
|
+
ref: ref,
|
|
326
|
+
height: ((_theme$text = theme.text[size || 'medium']) == null ? void 0 : _theme$text.height) || size,
|
|
327
|
+
a11yTitle: a11yTitle
|
|
328
|
+
}, rest, (_theme$button$size = theme.button.size) == null ? void 0 : _theme$button$size[size || 'medium'], theme.button.skeleton));
|
|
329
|
+
}
|
|
302
330
|
var reverse = reverseProp != null ? reverseProp : (_theme$button$kind = theme.button[kind]) == null ? void 0 : _theme$button$kind.reverse;
|
|
303
331
|
var domTag = !as && href ? 'a' : as;
|
|
304
332
|
var first = reverse ? label : buttonIcon;
|
|
@@ -329,12 +357,42 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
329
357
|
// (!kind && icon && !label) is necessary because for old button logic,
|
|
330
358
|
// if button has icon but not label, it will be considered "plain",
|
|
331
359
|
// so no border or background will be applied
|
|
332
|
-
var innerBadge = !background && !border || !kind && icon && !label;
|
|
360
|
+
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
361
|
if (badgeProp && innerBadge) {
|
|
334
362
|
contents = /*#__PURE__*/_react["default"].createElement(_Badge.Badge, {
|
|
335
363
|
content: badgeProp
|
|
336
364
|
}, contents);
|
|
337
365
|
}
|
|
366
|
+
if (busy || success) {
|
|
367
|
+
// match what the label will use
|
|
368
|
+
var animationColor;
|
|
369
|
+
if (kind) {
|
|
370
|
+
if (!plain) {
|
|
371
|
+
animationColor = hover && getIconColor(themePaths.hover, theme) || getIconColor(themePaths.base, theme, color, kind);
|
|
372
|
+
}
|
|
373
|
+
} else if (primary) {
|
|
374
|
+
animationColor = theme.global.colors.text[isDarkBackground() ? 'dark' : 'light'];
|
|
375
|
+
}
|
|
376
|
+
contents =
|
|
377
|
+
/*#__PURE__*/
|
|
378
|
+
// position relative is necessary to have the animation
|
|
379
|
+
// display over the button content
|
|
380
|
+
_react["default"].createElement(RelativeBox, {
|
|
381
|
+
flex: false
|
|
382
|
+
}, busy && /*#__PURE__*/_react["default"].createElement(_BusyAnimation.EllipsisAnimation, null), success && /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
383
|
+
style: {
|
|
384
|
+
position: 'absolute'
|
|
385
|
+
},
|
|
386
|
+
fill: true,
|
|
387
|
+
alignContent: "center",
|
|
388
|
+
justify: "center"
|
|
389
|
+
}, /*#__PURE__*/_react["default"].createElement(_BusyAnimation.GrowCheckmark, {
|
|
390
|
+
color: animationColor,
|
|
391
|
+
"aria-hidden": true
|
|
392
|
+
})), /*#__PURE__*/_react["default"].createElement(_BusyAnimation.StyledBusyContents, {
|
|
393
|
+
animating: busy || success
|
|
394
|
+
}, contents));
|
|
395
|
+
}
|
|
338
396
|
var styledButtonResult;
|
|
339
397
|
if (kind) {
|
|
340
398
|
styledButtonResult = /*#__PURE__*/_react["default"].createElement(_StyledButtonKind.StyledButtonKind, _extends({}, rest, {
|
|
@@ -343,6 +401,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
343
401
|
active: active,
|
|
344
402
|
align: align,
|
|
345
403
|
"aria-label": ariaLabel || a11yTitle,
|
|
404
|
+
busy: busy,
|
|
346
405
|
badge: badgeProp,
|
|
347
406
|
colorValue: color,
|
|
348
407
|
disabled: disabled,
|
|
@@ -356,7 +415,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
356
415
|
href: href,
|
|
357
416
|
kind: kind,
|
|
358
417
|
themePaths: themePaths,
|
|
359
|
-
onClick: onClick,
|
|
418
|
+
onClick: !busy && !success ? onClick : undefined,
|
|
360
419
|
onFocus: function onFocus(event) {
|
|
361
420
|
setFocus(true);
|
|
362
421
|
if (_onFocus) _onFocus(event);
|
|
@@ -367,9 +426,11 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
367
426
|
},
|
|
368
427
|
onMouseOver: onMouseOverButton,
|
|
369
428
|
onMouseOut: onMouseOutButton,
|
|
429
|
+
pad: pad,
|
|
370
430
|
plain: plain || _react.Children.count(children) > 0,
|
|
371
431
|
primary: primary,
|
|
372
432
|
sizeProp: size,
|
|
433
|
+
success: success,
|
|
373
434
|
type: !href ? type : undefined
|
|
374
435
|
}), contents);
|
|
375
436
|
} else {
|
|
@@ -377,6 +438,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
377
438
|
as: domTag,
|
|
378
439
|
ref: ref,
|
|
379
440
|
"aria-label": ariaLabel || a11yTitle,
|
|
441
|
+
busy: busy,
|
|
380
442
|
colorValue: color,
|
|
381
443
|
active: active,
|
|
382
444
|
selected: selected,
|
|
@@ -390,7 +452,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
390
452
|
href: href,
|
|
391
453
|
kind: kind,
|
|
392
454
|
themePaths: themePaths,
|
|
393
|
-
onClick: onClick,
|
|
455
|
+
onClick: !busy && !success ? onClick : undefined,
|
|
394
456
|
onFocus: function onFocus(event) {
|
|
395
457
|
setFocus(true);
|
|
396
458
|
if (_onFocus) _onFocus(event);
|
|
@@ -401,10 +463,11 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
401
463
|
},
|
|
402
464
|
onMouseOver: onMouseOverButton,
|
|
403
465
|
onMouseOut: onMouseOutButton,
|
|
404
|
-
pad: !plain,
|
|
466
|
+
pad: pad || !plain,
|
|
405
467
|
plain: typeof plain !== 'undefined' ? plain : _react.Children.count(children) > 0 || icon && !label,
|
|
406
468
|
primary: primary,
|
|
407
469
|
sizeProp: size,
|
|
470
|
+
success: success,
|
|
408
471
|
type: !href ? type : undefined
|
|
409
472
|
}), contents);
|
|
410
473
|
}
|
|
@@ -77,14 +77,14 @@ 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);
|
|
84
84
|
}, function (props) {
|
|
85
85
|
return props.primary && primaryStyle(props);
|
|
86
86
|
}, function (props) {
|
|
87
|
-
return !props.disabled && !props.selected && !props.focus && hoverStyle;
|
|
87
|
+
return !props.disabled && !props.selected && !props.focus && !props.busy && !props.success && hoverStyle;
|
|
88
88
|
}, function (props) {
|
|
89
89
|
return !props.disabled && props.active && activeButtonStyle(props);
|
|
90
90
|
}, function (props) {
|
|
@@ -98,9 +98,13 @@ 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;
|
|
106
|
+
}, function (props) {
|
|
107
|
+
return (props.busy || props.success) && "\n cursor: default;\n ";
|
|
104
108
|
});
|
|
105
109
|
exports.StyledButton = StyledButton;
|
|
106
110
|
StyledButton.defaultProps = {};
|