@aristobyte-ui/button 2.6.0 → 2.6.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.
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+ import { type IconPropsType } from '@aristobyte-ui/utils';
3
+ import './Button.scss';
4
+ export interface IButton {
5
+ type?: 'button' | 'link';
6
+ text?: string;
7
+ children?: React.ReactElement | React.JSX.Element | React.ReactNode | string;
8
+ href?: string;
9
+ target?: '_self' | '_blank' | '_parent' | '_top';
10
+ onClick?: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement, MouseEvent>) => void | Promise<void>;
11
+ disabled?: boolean;
12
+ transparent?: boolean;
13
+ variant?: 'default' | 'primary' | 'secondary' | 'success' | 'error' | 'warning';
14
+ appearance?: 'solid' | 'outline' | 'outline-dashed' | 'no-outline' | 'glowing';
15
+ size?: 'xsm' | 'sm' | 'md' | 'lg' | 'xlg';
16
+ radius?: 'none' | 'sm' | 'md' | 'lg' | 'full';
17
+ icon?: {
18
+ component: (props: IconPropsType) => React.JSX.Element;
19
+ color?: string;
20
+ size?: number;
21
+ align?: 'left' | 'right';
22
+ };
23
+ isLoading?: boolean;
24
+ spinnerType?: 'default' | 'duo' | 'gradient' | 'pulse' | 'pulse-duo';
25
+ className?: string;
26
+ style?: React.CSSProperties;
27
+ }
28
+ export declare const Button: React.FC<IButton>;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/components/Button/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AAExE,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC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E,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CAwEpC,CAAC"}
@@ -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/styles' 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,15 @@
1
+ import * as React from 'react';
2
+ import { type IButton, Button } from '../Button';
3
+ import './ButtonGroup.scss';
4
+ export interface IButtonGroup {
5
+ children: React.ReactElement<IButton, typeof Button> | React.ReactElement<IButton, typeof Button>[];
6
+ align?: 'vertical' | 'horizontal';
7
+ variant?: 'default' | 'primary' | 'secondary' | 'success' | 'error' | 'warning';
8
+ size?: 'xsm' | 'sm' | 'md' | 'lg' | 'xlg';
9
+ radius?: 'none' | 'sm' | 'md' | 'lg' | 'full';
10
+ disabled?: boolean;
11
+ className?: string;
12
+ style?: React.CSSProperties;
13
+ }
14
+ export declare const ButtonGroup: React.FC<IButtonGroup>;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/components/ButtonGroup/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;IACpG,KAAK,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAClC,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAChF,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+B9C,CAAC"}
@@ -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,3 @@
1
+ export * from "./Button";
2
+ export * from "./ButtonGroup";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./Button";
2
+ export * from "./ButtonGroup";
package/es/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
package/es/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './components';