dibk-design 3.2.0 → 3.2.2
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/dist/components/Button.js +23 -11
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
20
20
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
21
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
22
|
var Button = function Button(props) {
|
|
23
|
-
var _props$href, _props$children, _props$children$type;
|
|
23
|
+
var _props$href, _props$href2, _props$children, _props$children$type;
|
|
24
24
|
var getArrowClass = function getArrowClass(arrow) {
|
|
25
25
|
switch (arrow) {
|
|
26
26
|
case "left":
|
|
@@ -40,7 +40,8 @@ var Button = function Button(props) {
|
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
var buttonProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
43
|
-
"aria-invalid": props.hasErrors || null
|
|
43
|
+
"aria-invalid": props.hasErrors || null,
|
|
44
|
+
href: !props.disabled && (_props$href = props.href) !== null && _props$href !== void 0 && _props$href.length ? props.href : null
|
|
44
45
|
});
|
|
45
46
|
delete buttonProps.noHover;
|
|
46
47
|
delete buttonProps.hasErrors;
|
|
@@ -52,15 +53,26 @@ var Button = function Button(props) {
|
|
|
52
53
|
var buttonColor = (props === null || props === void 0 ? void 0 : props.inputType) === "radio" ? props.defaultChecked ? "primary" : "default" : props.color;
|
|
53
54
|
var themeStyle = props.theme ? getThemeStyle(props.theme, buttonColor) : null;
|
|
54
55
|
var className = (0, _helpers.classNameArrayToClassNameString)([_ButtonModule.default.button, _ButtonModule.default[buttonColor], _ButtonModule.default[props.size], getArrowClass(props.arrow), props.theme && _ButtonModule.default.hasTheme, props.noHover || (props === null || props === void 0 ? void 0 : props.inputType) === "radio" ? _ButtonModule.default.noHover : null, props.rounded && _ButtonModule.default.rounded, props.hasErrors && _ButtonModule.default.hasErrors, props.disabled && _ButtonModule.default.disabled]);
|
|
55
|
-
var
|
|
56
|
+
var renderReactLinkElements = function renderReactLinkElements(childElements) {
|
|
56
57
|
var childElementsthroughFragments = (0, _helpers.cloneThroughFragments)(childElements);
|
|
57
58
|
return childElementsthroughFragments.map(function (childElement, index) {
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
var _childElement$props, _childElement$props$t;
|
|
60
|
+
if (!buttonProps.disabled && childElement !== null && childElement !== void 0 && (_childElement$props = childElement.props) !== null && _childElement$props !== void 0 && (_childElement$props$t = _childElement$props.to) !== null && _childElement$props$t !== void 0 && _childElement$props$t.length) {
|
|
61
|
+
var _childElement$props2, _childElement$props3;
|
|
62
|
+
var childElementCopy = _react.default.cloneElement(childElement, {
|
|
63
|
+
className: className,
|
|
64
|
+
style: themeStyle,
|
|
65
|
+
key: "button-".concat(index),
|
|
66
|
+
to: !buttonProps.disabled && childElement !== null && childElement !== void 0 && (_childElement$props2 = childElement.props) !== null && _childElement$props2 !== void 0 && _childElement$props2.to ? childElement === null || childElement === void 0 ? void 0 : (_childElement$props3 = childElement.props) === null || _childElement$props3 === void 0 ? void 0 : _childElement$props3.to : null
|
|
67
|
+
});
|
|
68
|
+
return childElementCopy;
|
|
69
|
+
} else {
|
|
70
|
+
return _react.default.createElement("button", _extends({}, buttonProps, {
|
|
71
|
+
key: "button-".concat(index),
|
|
72
|
+
className: className,
|
|
73
|
+
style: themeStyle
|
|
74
|
+
}), props.content || childElement.props.children);
|
|
75
|
+
}
|
|
64
76
|
});
|
|
65
77
|
};
|
|
66
78
|
if (props.inputType === "button") {
|
|
@@ -77,13 +89,13 @@ var Button = function Button(props) {
|
|
|
77
89
|
style: themeStyle,
|
|
78
90
|
type: "radio"
|
|
79
91
|
})), props.content);
|
|
80
|
-
} else if ((_props$
|
|
92
|
+
} else if ((_props$href2 = props.href) !== null && _props$href2 !== void 0 && _props$href2.length && !props.disabled) {
|
|
81
93
|
return _react.default.createElement("a", _extends({}, buttonProps, {
|
|
82
94
|
className: className,
|
|
83
95
|
style: themeStyle
|
|
84
96
|
}), props.content || props.children);
|
|
85
97
|
} else if ((props === null || props === void 0 ? void 0 : (_props$children = props.children) === null || _props$children === void 0 ? void 0 : (_props$children$type = _props$children.type) === null || _props$children$type === void 0 ? void 0 : _props$children$type.displayName) === "Link") {
|
|
86
|
-
return _react.default.createElement(_react.Fragment, null,
|
|
98
|
+
return _react.default.createElement(_react.Fragment, null, renderReactLinkElements(_react.default.Children.toArray(props.children)));
|
|
87
99
|
} else {
|
|
88
100
|
return _react.default.createElement("button", _extends({}, buttonProps, {
|
|
89
101
|
className: className,
|