@entur/button 3.3.13-beta.0 → 3.3.13-beta.10
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/Button.d.ts +42 -0
- package/dist/ButtonGroup.d.ts +14 -0
- package/dist/FloatingButton.d.ts +18 -0
- package/dist/IconButton.d.ts +32 -0
- package/dist/NegativeButton.d.ts +29 -0
- package/dist/PrimaryButton.d.ts +29 -0
- package/dist/SecondaryButton.d.ts +29 -0
- package/dist/SecondarySquareButton.d.ts +21 -0
- package/dist/SquareButton.d.ts +26 -0
- package/dist/SuccessButton.d.ts +29 -0
- package/dist/SuccessSquareButton.d.ts +21 -0
- package/dist/TertiaryButton.d.ts +30 -0
- package/dist/TertiarySquareButton.d.ts +23 -0
- package/dist/button.cjs.development.js +309 -0
- package/dist/button.cjs.development.js.map +1 -0
- package/dist/button.cjs.production.min.js +2 -0
- package/dist/button.cjs.production.min.js.map +1 -0
- package/dist/button.esm.js +268 -311
- package/dist/button.esm.js.map +1 -1
- package/dist/index.d.ts +13 -383
- package/dist/index.js +8 -0
- package/dist/styles.css +426 -408
- package/package.json +13 -31
- package/dist/button.cjs.js +0 -335
- package/dist/button.cjs.js.map +0 -1
package/dist/button.esm.js
CHANGED
|
@@ -1,319 +1,276 @@
|
|
|
1
|
-
import { warnAboutMissingStyles } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { LoadingDots } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var hasRequiredClassnames;
|
|
16
|
-
function requireClassnames() {
|
|
17
|
-
if (hasRequiredClassnames) return classnames.exports;
|
|
18
|
-
hasRequiredClassnames = 1;
|
|
19
|
-
(function(module) {
|
|
20
|
-
(function() {
|
|
21
|
-
var hasOwn = {}.hasOwnProperty;
|
|
22
|
-
function classNames2() {
|
|
23
|
-
var classes = "";
|
|
24
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
25
|
-
var arg = arguments[i];
|
|
26
|
-
if (arg) {
|
|
27
|
-
classes = appendClass(classes, parseValue(arg));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return classes;
|
|
31
|
-
}
|
|
32
|
-
function parseValue(arg) {
|
|
33
|
-
if (typeof arg === "string" || typeof arg === "number") {
|
|
34
|
-
return arg;
|
|
35
|
-
}
|
|
36
|
-
if (typeof arg !== "object") {
|
|
37
|
-
return "";
|
|
38
|
-
}
|
|
39
|
-
if (Array.isArray(arg)) {
|
|
40
|
-
return classNames2.apply(null, arg);
|
|
41
|
-
}
|
|
42
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
43
|
-
return arg.toString();
|
|
44
|
-
}
|
|
45
|
-
var classes = "";
|
|
46
|
-
for (var key in arg) {
|
|
47
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
48
|
-
classes = appendClass(classes, key);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return classes;
|
|
52
|
-
}
|
|
53
|
-
function appendClass(value, newClass) {
|
|
54
|
-
if (!newClass) {
|
|
55
|
-
return value;
|
|
56
|
-
}
|
|
57
|
-
if (value) {
|
|
58
|
-
return value + " " + newClass;
|
|
59
|
-
}
|
|
60
|
-
return value + newClass;
|
|
61
|
-
}
|
|
62
|
-
if (module.exports) {
|
|
63
|
-
classNames2.default = classNames2;
|
|
64
|
-
module.exports = classNames2;
|
|
65
|
-
} else {
|
|
66
|
-
window.classNames = classNames2;
|
|
67
|
-
}
|
|
68
|
-
})();
|
|
69
|
-
})(classnames);
|
|
70
|
-
return classnames.exports;
|
|
1
|
+
import { warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { LoadingDots } from '@entur/loader';
|
|
6
|
+
|
|
7
|
+
function _extends() {
|
|
8
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
9
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
10
|
+
var t = arguments[e];
|
|
11
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
12
|
+
}
|
|
13
|
+
return n;
|
|
14
|
+
}, _extends.apply(null, arguments);
|
|
71
15
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
children,
|
|
79
|
-
variant = "primary",
|
|
80
|
-
size = "medium",
|
|
81
|
-
loading,
|
|
82
|
-
className,
|
|
83
|
-
disabled = false,
|
|
84
|
-
width = "auto",
|
|
85
|
-
"aria-label": ariaLabel,
|
|
86
|
-
...rest
|
|
87
|
-
}, ref) => {
|
|
88
|
-
const Element = as || defaultElement$9;
|
|
89
|
-
const childrenArray = React.Children.toArray(children);
|
|
90
|
-
const hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== "string";
|
|
91
|
-
const hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== "string";
|
|
92
|
-
const ariaLabelWhenLoading = childrenArray.filter((child) => typeof child === "string").join(" ");
|
|
93
|
-
const ariaLabelValue = () => {
|
|
94
|
-
if (ariaLabel) return ariaLabel;
|
|
95
|
-
if (loading) return ariaLabelWhenLoading;
|
|
96
|
-
return void 0;
|
|
97
|
-
};
|
|
98
|
-
return /* @__PURE__ */ jsx(
|
|
99
|
-
Element,
|
|
100
|
-
{
|
|
101
|
-
className: classNames(
|
|
102
|
-
"eds-button",
|
|
103
|
-
{
|
|
104
|
-
[`eds-button--variant-${variant}`]: variant,
|
|
105
|
-
[`eds-button--size-${size}`]: size,
|
|
106
|
-
"eds-button--width-fluid": width === "fluid",
|
|
107
|
-
"eds-button--loading": loading,
|
|
108
|
-
"eds-button--leading-icon": hasLeadingIcon,
|
|
109
|
-
"eds-button--trailing-icon": hasTrailingIcon
|
|
110
|
-
},
|
|
111
|
-
className
|
|
112
|
-
),
|
|
113
|
-
ref,
|
|
114
|
-
"aria-busy": loading,
|
|
115
|
-
disabled,
|
|
116
|
-
"aria-disabled": disabled,
|
|
117
|
-
"aria-label": ariaLabelValue(),
|
|
118
|
-
...rest,
|
|
119
|
-
children: loading ? /* @__PURE__ */ jsx(LoadingDots, { className: "eds-button__loading-dots" }) : children
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
const defaultElement$8 = "button";
|
|
125
|
-
const PrimaryButton = React__default.forwardRef(
|
|
126
|
-
(props, ref) => {
|
|
127
|
-
const Element = props.as || defaultElement$8;
|
|
128
|
-
return /* @__PURE__ */ jsx(Button, { as: Element, ...props, ref, variant: "primary" });
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
const defaultElement$7 = "button";
|
|
132
|
-
const SecondaryButton = React__default.forwardRef(
|
|
133
|
-
(props, ref) => {
|
|
134
|
-
const Element = props.as || defaultElement$7;
|
|
135
|
-
return /* @__PURE__ */ jsx(Button, { as: Element, ...props, ref, variant: "secondary" });
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
17
|
+
if (null == r) return {};
|
|
18
|
+
var t = {};
|
|
19
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
20
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
21
|
+
t[n] = r[n];
|
|
136
22
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var _excluded$4 = ["as", "children", "variant", "size", "loading", "className", "disabled", "width", "aria-label"];
|
|
27
|
+
var defaultElement$9 = 'button';
|
|
28
|
+
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
29
|
+
var _cx;
|
|
30
|
+
var as = _ref.as,
|
|
31
|
+
children = _ref.children,
|
|
32
|
+
_ref$variant = _ref.variant,
|
|
33
|
+
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
34
|
+
_ref$size = _ref.size,
|
|
35
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
36
|
+
loading = _ref.loading,
|
|
37
|
+
className = _ref.className,
|
|
38
|
+
_ref$disabled = _ref.disabled,
|
|
39
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
40
|
+
_ref$width = _ref.width,
|
|
41
|
+
width = _ref$width === void 0 ? 'auto' : _ref$width,
|
|
42
|
+
ariaLabel = _ref['aria-label'],
|
|
43
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
44
|
+
var Element = as || defaultElement$9;
|
|
45
|
+
var childrenArray = React.Children.toArray(children);
|
|
46
|
+
var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
|
|
47
|
+
var hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== 'string';
|
|
48
|
+
var ariaLabelWhenLoading = childrenArray.filter(function (child) {
|
|
49
|
+
return typeof child === 'string';
|
|
50
|
+
}).join(' ');
|
|
51
|
+
var ariaLabelValue = function ariaLabelValue() {
|
|
52
|
+
if (ariaLabel) return ariaLabel;
|
|
53
|
+
if (loading) return ariaLabelWhenLoading;
|
|
54
|
+
return undefined;
|
|
55
|
+
};
|
|
56
|
+
return React.createElement(Element, _extends({
|
|
57
|
+
className: classNames('eds-button', (_cx = {}, _cx["eds-button--variant-" + variant] = variant, _cx["eds-button--size-" + size] = size, _cx['eds-button--width-fluid'] = width === 'fluid', _cx['eds-button--loading'] = loading, _cx['eds-button--leading-icon'] = hasLeadingIcon, _cx['eds-button--trailing-icon'] = hasTrailingIcon, _cx), className),
|
|
58
|
+
ref: ref,
|
|
59
|
+
"aria-busy": loading,
|
|
60
|
+
disabled: disabled,
|
|
61
|
+
"aria-disabled": disabled,
|
|
62
|
+
"aria-label": ariaLabelValue()
|
|
63
|
+
}, rest), loading ? React.createElement(LoadingDots, {
|
|
64
|
+
className: "eds-button__loading-dots"
|
|
65
|
+
}) : children);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
var defaultElement$8 = 'button';
|
|
69
|
+
var PrimaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
70
|
+
var Element = props.as || defaultElement$8;
|
|
71
|
+
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
72
|
+
return React__default.createElement(Button, _extends({
|
|
73
|
+
as: Element
|
|
74
|
+
}, props, {
|
|
75
|
+
ref: ref,
|
|
76
|
+
variant: "primary"
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
var defaultElement$7 = 'button';
|
|
81
|
+
var SecondaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
82
|
+
var Element = props.as || defaultElement$7;
|
|
83
|
+
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
84
|
+
return React__default.createElement(Button, _extends({
|
|
85
|
+
as: Element
|
|
86
|
+
}, props, {
|
|
87
|
+
ref: ref,
|
|
88
|
+
variant: "secondary"
|
|
89
|
+
}));
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
var defaultElement$6 = 'button';
|
|
93
|
+
var SuccessButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
94
|
+
var Element = props.as || defaultElement$6;
|
|
95
|
+
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
96
|
+
return React__default.createElement(Button, _extends({
|
|
97
|
+
as: Element
|
|
98
|
+
}, props, {
|
|
99
|
+
ref: ref,
|
|
100
|
+
variant: "success"
|
|
101
|
+
}));
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
var defaultElement$5 = 'button';
|
|
105
|
+
var NegativeButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
106
|
+
var Element = props.as || defaultElement$5;
|
|
107
|
+
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
108
|
+
return React__default.createElement(Button, _extends({
|
|
109
|
+
as: Element
|
|
110
|
+
}, props, {
|
|
111
|
+
ref: ref,
|
|
112
|
+
variant: "negative"
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
var defaultElement$4 = 'button';
|
|
117
|
+
/** @deprecated use SecondaryButton size="small" instead */
|
|
118
|
+
var TertiaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
119
|
+
var Element = props.as || defaultElement$4;
|
|
120
|
+
return React__default.createElement(Button, _extends({
|
|
121
|
+
as: Element
|
|
122
|
+
}, props, {
|
|
123
|
+
ref: ref,
|
|
124
|
+
variant: "tertiary",
|
|
125
|
+
size: "small"
|
|
126
|
+
}));
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
var _excluded$3 = ["as", "className"];
|
|
130
|
+
var ButtonGroup = function ButtonGroup(_ref) {
|
|
131
|
+
var _ref$as = _ref.as,
|
|
132
|
+
Element = _ref$as === void 0 ? 'div' : _ref$as,
|
|
133
|
+
className = _ref.className,
|
|
134
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
135
|
+
return React__default.createElement(Element, _extends({
|
|
136
|
+
className: classNames('eds-button-group', className)
|
|
137
|
+
}, rest));
|
|
174
138
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
139
|
+
|
|
140
|
+
var _excluded$2 = ["className", "children", "size"];
|
|
141
|
+
var FloatingButton = function FloatingButton(_ref) {
|
|
142
|
+
var className = _ref.className,
|
|
143
|
+
children = _ref.children,
|
|
144
|
+
_ref$size = _ref.size,
|
|
145
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
146
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
147
|
+
return React__default.createElement("button", _extends({
|
|
148
|
+
className: classNames('eds-floating-button', {
|
|
149
|
+
'eds-floating-button--extended': React__default.Children.count(children) > 1
|
|
150
|
+
}, {
|
|
151
|
+
'eds-floating-button--small': size === 'small'
|
|
152
|
+
}, className),
|
|
153
|
+
type: "button"
|
|
154
|
+
}, rest), wrapStringsInSpans(children));
|
|
155
|
+
};
|
|
156
|
+
var wrapStringsInSpans = function wrapStringsInSpans(children) {
|
|
157
|
+
return React__default.Children.map(children, function (child) {
|
|
158
|
+
return typeof child === 'string' ? React__default.createElement("span", null, child) : child;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var _excluded$1 = ["as", "children", "className", "disabled", "loading", "variant"];
|
|
163
|
+
var defaultElement$3 = 'button';
|
|
164
|
+
var SquareButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
165
|
+
var as = _ref.as,
|
|
166
|
+
children = _ref.children,
|
|
167
|
+
className = _ref.className,
|
|
168
|
+
_ref$disabled = _ref.disabled,
|
|
169
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
170
|
+
_ref$loading = _ref.loading,
|
|
171
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
172
|
+
_ref$variant = _ref.variant,
|
|
173
|
+
variant = _ref$variant === void 0 ? 'secondary' : _ref$variant,
|
|
174
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
175
|
+
var Element = as || defaultElement$3;
|
|
176
|
+
return React.createElement(Element, _extends({
|
|
177
|
+
className: classNames('eds-square-button', "eds-square-button--" + variant, {
|
|
178
|
+
'eds-square-button--loading': loading
|
|
179
|
+
}, className),
|
|
180
|
+
"aria-busy": loading,
|
|
181
|
+
disabled: disabled,
|
|
182
|
+
"aria-disabled": disabled,
|
|
183
|
+
ref: ref
|
|
184
|
+
}, rest), React.Children.map(children, function (child) {
|
|
185
|
+
if (typeof child === 'string') {
|
|
186
|
+
return React.createElement("span", {
|
|
187
|
+
className: "eds-square-button__label"
|
|
188
|
+
}, child);
|
|
193
189
|
}
|
|
190
|
+
return React.createElement("span", {
|
|
191
|
+
className: "eds-square-button__button"
|
|
192
|
+
}, loading ? React.createElement(LoadingDots, {
|
|
193
|
+
className: "eds-square-button__loading-dots"
|
|
194
|
+
}) : child);
|
|
195
|
+
}));
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
var defaultElement$2 = 'button';
|
|
199
|
+
var SecondarySquareButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
200
|
+
var Element = props.as || defaultElement$2;
|
|
201
|
+
return (
|
|
202
|
+
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
203
|
+
React__default.createElement(SquareButton, _extends({
|
|
204
|
+
as: Element,
|
|
205
|
+
ref: ref
|
|
206
|
+
}, props, {
|
|
207
|
+
variant: "secondary"
|
|
208
|
+
}))
|
|
194
209
|
);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
);
|
|
238
|
-
const defaultElement$2 = "button";
|
|
239
|
-
const SecondarySquareButton = React__default.forwardRef(
|
|
240
|
-
(props, ref) => {
|
|
241
|
-
const Element = props.as || defaultElement$2;
|
|
242
|
-
return (
|
|
243
|
-
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
244
|
-
/* @__PURE__ */ jsx(SquareButton, { as: Element, ref, ...props, variant: "secondary" })
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
);
|
|
248
|
-
const defaultElement$1 = "button";
|
|
249
|
-
const SuccessSquareButton = React__default.forwardRef(
|
|
250
|
-
(props, ref) => {
|
|
251
|
-
const Element = props.as || defaultElement$1;
|
|
252
|
-
return (
|
|
253
|
-
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
254
|
-
/* @__PURE__ */ jsx(SquareButton, { as: Element, ref, ...props, variant: "success" })
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
const TertiarySquareButton = React__default.forwardRef(
|
|
259
|
-
(props, ref) => /* @__PURE__ */ jsx(SquareButton, { ref, ...props, variant: "tertiary" })
|
|
260
|
-
);
|
|
261
|
-
const defaultElement = "button";
|
|
262
|
-
const IconButton = React__default.forwardRef(
|
|
263
|
-
({
|
|
264
|
-
children,
|
|
265
|
-
className,
|
|
266
|
-
disabled = false,
|
|
267
|
-
size = "medium",
|
|
268
|
-
as,
|
|
269
|
-
loading,
|
|
270
|
-
...rest
|
|
271
|
-
}, ref) => {
|
|
272
|
-
const Element = as || defaultElement;
|
|
273
|
-
const IconWithAriaHidden = React__default.Children.map(children, (child) => {
|
|
274
|
-
if (React__default.isValidElement(child)) {
|
|
275
|
-
return React__default.cloneElement(child, { "aria-hidden": true });
|
|
276
|
-
}
|
|
277
|
-
return child;
|
|
278
|
-
});
|
|
279
|
-
const iconButtonElement = /* @__PURE__ */ jsx(
|
|
280
|
-
Element,
|
|
281
|
-
{
|
|
282
|
-
className: classNames(
|
|
283
|
-
"eds-icon-button",
|
|
284
|
-
className,
|
|
285
|
-
{
|
|
286
|
-
"eds-icon-button--disabled": disabled
|
|
287
|
-
},
|
|
288
|
-
`eds-icon-button--size-${size}`
|
|
289
|
-
),
|
|
290
|
-
disabled,
|
|
291
|
-
"aria-disabled": disabled,
|
|
292
|
-
"aria-busy": loading,
|
|
293
|
-
ref,
|
|
294
|
-
...rest,
|
|
295
|
-
children: loading ? /* @__PURE__ */ jsx(LoadingDots, {}) : /* @__PURE__ */ jsx(Fragment, { children: IconWithAriaHidden })
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
if (disabled) {
|
|
299
|
-
return /* @__PURE__ */ jsx("div", { className: "eds-icon-button--disabled__wrapper", children: iconButtonElement });
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
var defaultElement$1 = 'button';
|
|
213
|
+
var SuccessSquareButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
214
|
+
var Element = props.as || defaultElement$1;
|
|
215
|
+
return (
|
|
216
|
+
// @ts-expect-error type error due to props not being BaseButtonProps
|
|
217
|
+
React__default.createElement(SquareButton, _extends({
|
|
218
|
+
as: Element,
|
|
219
|
+
ref: ref
|
|
220
|
+
}, props, {
|
|
221
|
+
variant: "success"
|
|
222
|
+
}))
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
var TertiarySquareButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
227
|
+
return React__default.createElement(SquareButton, _extends({
|
|
228
|
+
ref: ref
|
|
229
|
+
}, props, {
|
|
230
|
+
variant: "tertiary"
|
|
231
|
+
}));
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
var _excluded = ["children", "className", "disabled", "size", "as", "loading"];
|
|
235
|
+
var defaultElement = 'button';
|
|
236
|
+
var IconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
237
|
+
var children = _ref.children,
|
|
238
|
+
className = _ref.className,
|
|
239
|
+
_ref$disabled = _ref.disabled,
|
|
240
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
241
|
+
_ref$size = _ref.size,
|
|
242
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
243
|
+
as = _ref.as,
|
|
244
|
+
loading = _ref.loading,
|
|
245
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
246
|
+
var Element = as || defaultElement;
|
|
247
|
+
var IconWithAriaHidden = React__default.Children.map(children, function (child) {
|
|
248
|
+
if (React__default.isValidElement(child)) {
|
|
249
|
+
// @ts-expect-error aria-hidden does, in fact, exist
|
|
250
|
+
return React__default.cloneElement(child, {
|
|
251
|
+
'aria-hidden': true
|
|
252
|
+
});
|
|
300
253
|
}
|
|
301
|
-
return
|
|
254
|
+
return child;
|
|
255
|
+
});
|
|
256
|
+
var iconButtonElement = React__default.createElement(Element, _extends({
|
|
257
|
+
className: classNames('eds-icon-button', className, {
|
|
258
|
+
'eds-icon-button--disabled': disabled
|
|
259
|
+
}, "eds-icon-button--size-" + size),
|
|
260
|
+
disabled: disabled,
|
|
261
|
+
"aria-disabled": disabled,
|
|
262
|
+
"aria-busy": loading,
|
|
263
|
+
ref: ref
|
|
264
|
+
}, rest), loading ? React__default.createElement(LoadingDots, null) : React__default.createElement(React__default.Fragment, null, IconWithAriaHidden));
|
|
265
|
+
if (disabled) {
|
|
266
|
+
return React__default.createElement("div", {
|
|
267
|
+
className: "eds-icon-button--disabled__wrapper"
|
|
268
|
+
}, iconButtonElement);
|
|
302
269
|
}
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
IconButton,
|
|
310
|
-
NegativeButton,
|
|
311
|
-
PrimaryButton,
|
|
312
|
-
SecondaryButton,
|
|
313
|
-
SecondarySquareButton,
|
|
314
|
-
SuccessButton,
|
|
315
|
-
SuccessSquareButton,
|
|
316
|
-
TertiaryButton,
|
|
317
|
-
TertiarySquareButton
|
|
318
|
-
};
|
|
270
|
+
return React__default.createElement(React__default.Fragment, null, iconButtonElement);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
warnAboutMissingStyles('button');
|
|
274
|
+
|
|
275
|
+
export { Button, ButtonGroup, FloatingButton, IconButton, NegativeButton, PrimaryButton, SecondaryButton, SecondarySquareButton, SuccessButton, SuccessSquareButton, TertiaryButton, TertiarySquareButton };
|
|
319
276
|
//# sourceMappingURL=button.esm.js.map
|