@aristobyte-ui/button 2.3.5 → 2.4.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.
@@ -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,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,2 @@
1
+ export * from "./Button";
2
+ export * from "./ButtonGroup";
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.Button = void 0;
49
+ var React = __importStar(require("react"));
50
+ var spinner_1 = require("@aristobyte-ui/spinner");
51
+ var utils_1 = require("@aristobyte-ui/utils");
52
+ require("./Button.scss");
53
+ var Button = function (_a) {
54
+ 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;
55
+ var uniqueId = React.useId();
56
+ var ref = React.useRef(null);
57
+ var handleClick = function (e) {
58
+ var clientX = e.clientX, clientY = e.clientY;
59
+ (0, utils_1.renderRipple)({
60
+ ref: ref,
61
+ clientX: clientX,
62
+ clientY: clientY,
63
+ });
64
+ if (onClick) {
65
+ onClick(e);
66
+ }
67
+ };
68
+ var getCommonProps = function () { return ({
69
+ onClick: handleClick,
70
+ disabled: disabled || isLoading,
71
+ style: style,
72
+ 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),
73
+ }); };
74
+ var renderChildren = function () {
75
+ var _a;
76
+ return (React.createElement(React.Fragment, null,
77
+ isLoading && React.createElement(spinner_1.Spinner, { size: size, variant: variant, type: spinnerType, className: "spinner" }),
78
+ 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 }))),
79
+ text || children));
80
+ };
81
+ if (type === 'link') {
82
+ return (React.createElement("a", __assign({ key: uniqueId, ref: ref, target: target, href: href }, getCommonProps()), renderChildren()));
83
+ }
84
+ return (React.createElement("button", __assign({ key: uniqueId, ref: ref }, getCommonProps()), renderChildren()));
85
+ };
86
+ exports.Button = Button;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.ButtonGroup = void 0;
38
+ var React = __importStar(require("react"));
39
+ var Button_1 = require("../Button");
40
+ require("./ButtonGroup.scss");
41
+ var ButtonGroup = function (_a) {
42
+ 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;
43
+ 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)
44
+ .filter(function (child) {
45
+ return React.isValidElement(child) && child.type === Button_1.Button;
46
+ })
47
+ .map(function (child, index) {
48
+ return React.cloneElement(child, {
49
+ key: index || child.key,
50
+ size: size || child.props.size,
51
+ disabled: disabled || child.props.disabled,
52
+ variant: variant || child.props.variant,
53
+ radius: 'none',
54
+ });
55
+ })));
56
+ };
57
+ exports.ButtonGroup = ButtonGroup;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Button"), exports);
18
+ __exportStar(require("./ButtonGroup"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aristobyte-ui/button",
3
- "version": "2.3.5",
3
+ "version": "2.4.0",
4
4
  "description": "react button and buttongroup components with multiple variants, appearances, sizes, radius options, icons, ripple feedback, and fully typed typescript support",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -52,7 +52,7 @@
52
52
  "react-dom": "^19.1.0"
53
53
  },
54
54
  "dependencies": {
55
- "@aristobyte-ui/spinner": "2.3.5",
56
- "@aristobyte-ui/utils": "2.3.5"
55
+ "@aristobyte-ui/spinner": "2.4.0",
56
+ "@aristobyte-ui/utils": "2.4.0"
57
57
  }
58
58
  }
package/README.md DELETED
@@ -1,94 +0,0 @@
1
- # @aristobyte-ui/button
2
-
3
- <p align="center">
4
- <img src="https://img.shields.io/badge/TypeScript-5.8-blue?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" />
5
- <img src="https://img.shields.io/badge/Build-Turbo-green?style=for-the-badge&logo=turbo&logoColor=white" alt="TurboRepo" />
6
- <img src="https://img.shields.io/badge/Lint-Strict-red?style=for-the-badge&logo=eslint&logoColor=white" alt="ESLint" />
7
- <img src="https://img.shields.io/badge/License-MIT-black?style=for-the-badge&logo=open-source-initiative&logoColor=white" alt="License" />
8
- <img src="https://img.shields.io/badge/AristoByte-UI-purple?style=for-the-badge&logo=react&logoColor=white" alt="AristoByte UI" />
9
- <img src="https://img.shields.io/badge/Node-20.17.0+-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js >=20.17.0" />
10
- <img src="https://img.shields.io/badge/Yarn-1.22+-2C8EBB?style=for-the-badge&logo=yarn&logoColor=white" alt="Yarn >=1.22" />
11
- <img src="https://img.shields.io/badge/NPM-10.8+-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="NPM >=10.8" />
12
- </p>
13
-
14
- Fully-featured, modular Button components for AristoByteUI with ripple effects, composable groups, variants, appearances, sizes, radius options, icons, and loading states.
15
-
16
- ## 📦 Installation
17
-
18
- ```bash
19
- # Install via Yarn
20
- yarn add -D @aristobyte-ui/button
21
-
22
- # Or via npm
23
- npm install -D @aristobyte-ui/button
24
-
25
- # Or via pnpm
26
- pnpm add -D @aristobyte-ui/button
27
- ```
28
-
29
- ## 🛠 Usage
30
-
31
- ```tsx
32
- import { Button, ButtonGroup } from "@aristobyte-ui/button";
33
- import { IconSample } from "@aristobyte-ui/icons";
34
-
35
- <Button variant="primary" appearance="solid" size="md" radius="md" icon={{ component: IconSample, align: "left" }}>
36
- Click Me
37
- </Button>
38
-
39
- <ButtonGroup variant="secondary" size="md" align="horizontal">
40
- <Button>One</Button>
41
- <Button>Two</Button>
42
- <Button>Three</Button>
43
- </ButtonGroup>
44
- ```
45
-
46
- ## 📂 Presets Available
47
-
48
- - **Button Variants**: `default`, `primary`, `secondary`, `success`, `error`, `warning`
49
- - **Button Appearances**: `solid`, `outline`,`outline-dashed`, `no-outline`, `glowing`
50
- - **Button Sizes**: `xsm`, `sm`, `md`, `lg`, `xlg`
51
- - **Button Radius**: `none`, `sm`, `md`, `lg`, `full`
52
- - **ButtonGroup Alignment**: `horizontal`, `vertical`
53
-
54
- ## 🔧 Example in a Package
55
-
56
- ```tsx
57
- <Button variant="success" appearance="glowing" size="lg" radius="full" isLoading spinnerType="duo">
58
- Submit
59
- </Button>
60
-
61
- <ButtonGroup variant="primary" size="sm" align="vertical">
62
- <Button>Save</Button>
63
- <Button>Cancel</Button>
64
- </ButtonGroup>
65
- ```
66
-
67
- ## 📊 Why This Matters
68
-
69
- - **Performance-first:** Lightweight CSS ensures fast rendering and smooth transitions.
70
- - **Fully typed:** TypeScript-first API ensures predictable usage and IDE autocomplete.
71
- - **AristoByteUI ready:** Seamlessly integrates with design tokens and SCSS modules.
72
- - **Flexible:** Supports multiple variants, appearances, sizes, radius options, icons, ripple-enabled interactive feedback, and composable groups.
73
-
74
- ## 🏆 Philosophy
75
-
76
- - **Modular architecture:** Button and ButtonGroup components are fully composable.
77
- - **Declarative styling:** SCSS modules keep styles maintainable and scoped.
78
- - **Strict typing & runtime flexibility:** Props fully typed while allowing runtime overrides.
79
- - **Developer experience optimized:** Easy to use with predictable behavior and minimal boilerplate.
80
-
81
- ## 📜 License
82
-
83
- [MIT](./LICENSE) © AristoByte
84
-
85
- ## 🛡 Shields Showcase
86
-
87
- <p align="center">
88
- <img src="https://img.shields.io/badge/Consistency-100%25-green?style=for-the-badge&logo=typescript" />
89
- <img src="https://img.shields.io/badge/Maintained-Active-brightgreen?style=for-the-badge&logo=github" />
90
- <img src="https://img.shields.io/badge/Strictness-High-critical?style=for-the-badge&logo=eslint" />
91
- <img src="https://img.shields.io/badge/Declarations-Enabled-blue?style=for-the-badge&logo=typescript" />
92
- <img src="https://img.shields.io/badge/Monorepo-Turbo-green?style=for-the-badge&logo=monorepo" />
93
- <img src="https://img.shields.io/badge/Interop-ESM%2FCJS-orange?style=for-the-badge&logo=javascript" />
94
- </p>