@aristobyte-ui/button 1.0.112 → 2.0.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/dist/es/main/components/Button/Button.scss +881 -0
- package/dist/es/main/components/Button/index.js +49 -0
- package/dist/es/main/components/ButtonGroup/ButtonGroup.scss +66 -0
- package/dist/es/main/components/ButtonGroup/index.js +20 -0
- package/dist/es/main/components/index.js +2 -0
- package/dist/es/main/index.js +1 -0
- package/dist/lib/main/components/Button/Button.scss +881 -0
- package/dist/lib/main/components/Button/index.js +86 -0
- package/dist/lib/main/components/ButtonGroup/ButtonGroup.scss +66 -0
- package/dist/lib/main/components/ButtonGroup/index.js +57 -0
- package/dist/lib/main/components/index.js +18 -0
- package/dist/lib/main/index.js +17 -0
- package/package.json +6 -30
- package/dist/index.d.mts +0 -42
- package/dist/index.d.ts +0 -42
- package/dist/index.js +0 -191
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -154
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { Spinner } from '@aristobyte-ui/spinner';
|
|
15
|
+
import { renderRipple } from '@aristobyte-ui/utils';
|
|
16
|
+
import './Button.scss';
|
|
17
|
+
export var Button = function (_a) {
|
|
18
|
+
var onClick = _a.onClick, _b = _a.text, text = _b === void 0 ? '' : _b, _c = _a.href, href = _c === void 0 ? '' : _c, _d = _a.target, target = _d === void 0 ? '_self' : _d, _e = _a.children, children = _e === void 0 ? '' : _e, _f = _a.type, type = _f === void 0 ? 'button' : _f, _g = _a.variant, variant = _g === void 0 ? 'default' : _g, _h = _a.appearance, appearance = _h === void 0 ? 'solid' : _h, _j = _a.size, size = _j === void 0 ? 'md' : _j, _k = _a.radius, radius = _k === void 0 ? 'md' : _k, icon = _a.icon, _l = _a.spinnerType, spinnerType = _l === void 0 ? 'default' : _l, _m = _a.transparent, transparent = _m === void 0 ? false : _m, _o = _a.isLoading, isLoading = _o === void 0 ? false : _o, _p = _a.disabled, disabled = _p === void 0 ? false : _p, _q = _a.className, className = _q === void 0 ? '' : _q, _r = _a.style, style = _r === void 0 ? {} : _r;
|
|
19
|
+
var uniqueId = React.useId();
|
|
20
|
+
var ref = React.useRef(null);
|
|
21
|
+
var handleClick = function (e) {
|
|
22
|
+
var clientX = e.clientX, clientY = e.clientY;
|
|
23
|
+
renderRipple({
|
|
24
|
+
ref: ref,
|
|
25
|
+
clientX: clientX,
|
|
26
|
+
clientY: clientY,
|
|
27
|
+
});
|
|
28
|
+
if (onClick) {
|
|
29
|
+
onClick(e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var getCommonProps = function () { return ({
|
|
33
|
+
onClick: handleClick,
|
|
34
|
+
disabled: disabled || isLoading,
|
|
35
|
+
style: style,
|
|
36
|
+
className: "button ".concat(transparent ? 'button--transparent' : '', " ").concat("button-variant--".concat(variant), " ").concat("button-appearance--".concat(appearance), " ").concat("button-size--".concat(size), " ").concat("button-radius--".concat(radius), " ").concat(isLoading ? 'button--loading' : '', " ").concat(className),
|
|
37
|
+
}); };
|
|
38
|
+
var renderChildren = function () {
|
|
39
|
+
var _a;
|
|
40
|
+
return (React.createElement(React.Fragment, null,
|
|
41
|
+
isLoading && React.createElement(Spinner, { size: size, variant: variant, type: spinnerType, className: "spinner" }),
|
|
42
|
+
icon && (React.createElement("span", { className: "icon ".concat("icon--".concat((_a = icon.align) !== null && _a !== void 0 ? _a : 'left')) }, icon.component({ color: icon.color, size: icon.size }))),
|
|
43
|
+
text || children));
|
|
44
|
+
};
|
|
45
|
+
if (type === 'link') {
|
|
46
|
+
return (React.createElement("a", __assign({ key: uniqueId, ref: ref, target: target, href: href }, getCommonProps()), renderChildren()));
|
|
47
|
+
}
|
|
48
|
+
return (React.createElement("button", __assign({ key: uniqueId, ref: ref }, getCommonProps()), renderChildren()));
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
@use '@aristobyte-ui/utils/aristobyte-ui.settings' as *;
|
|
2
|
+
|
|
3
|
+
.button-group {
|
|
4
|
+
align-items: center;
|
|
5
|
+
display: flex;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
max-width: max-content;
|
|
8
|
+
|
|
9
|
+
&-align {
|
|
10
|
+
&--horizontal {
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&--vertical {
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-variant {
|
|
20
|
+
&--default {
|
|
21
|
+
background-color: $color-default;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&--primary {
|
|
25
|
+
background-color: $color-primary;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&--secondary {
|
|
29
|
+
background-color: $color-secondary;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&--success {
|
|
33
|
+
background-color: $color-success;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&--error {
|
|
37
|
+
background-color: $color-error;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&--warning {
|
|
41
|
+
background-color: $color-warning;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&-radius {
|
|
46
|
+
&--none {
|
|
47
|
+
border-radius: 0rem; // 0px
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&--sm {
|
|
51
|
+
border-radius: 0.125rem; // 2px
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&--md {
|
|
55
|
+
border-radius: 0.375rem; // 6px
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&--lg {
|
|
59
|
+
border-radius: 0.5rem; // 8px
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&--full {
|
|
63
|
+
border-radius: 1.5rem; // 24px
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button } from '../Button';
|
|
4
|
+
import './ButtonGroup.scss';
|
|
5
|
+
export var ButtonGroup = function (_a) {
|
|
6
|
+
var children = _a.children, _b = _a.align, align = _b === void 0 ? 'horizontal' : _b, _c = _a.variant, variant = _c === void 0 ? 'default' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.radius, radius = _e === void 0 ? 'md' : _e, disabled = _a.disabled, _f = _a.className, className = _f === void 0 ? '' : _f, _g = _a.style, style = _g === void 0 ? {} : _g;
|
|
7
|
+
return (React.createElement("div", { className: "button-group ".concat("button-group-variant--".concat(variant), " ").concat("button-group-size--".concat(size), " ").concat("button-group-radius--".concat(radius), " ").concat("button-group-align--".concat(align), " ").concat(className), style: style }, React.Children.toArray(children)
|
|
8
|
+
.filter(function (child) {
|
|
9
|
+
return React.isValidElement(child) && child.type === Button;
|
|
10
|
+
})
|
|
11
|
+
.map(function (child, index) {
|
|
12
|
+
return React.cloneElement(child, {
|
|
13
|
+
key: index || child.key,
|
|
14
|
+
size: size || child.props.size,
|
|
15
|
+
disabled: disabled || child.props.disabled,
|
|
16
|
+
variant: variant || child.props.variant,
|
|
17
|
+
radius: 'none',
|
|
18
|
+
});
|
|
19
|
+
})));
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|