@cripty2001/utils 0.0.154 → 0.0.156

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.
@@ -1,8 +1,6 @@
1
- import { LucideIcon } from "lucide-react";
2
1
  export type ButtonProps = {
3
- title: string;
4
- icon?: React.ReactElement<LucideIcon>;
5
2
  onClick: () => void | Promise<void>;
3
+ children: React.ReactElement;
6
4
  className?: string;
7
5
  };
8
- export default function Button({ title, onClick, className, icon }: ButtonProps): import("react/jsx-runtime").JSX.Element;
6
+ export default function Button({ onClick, children, className }: ButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ exports.default = Button;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const lucide_react_1 = require("lucide-react");
6
6
  const react_1 = require("react");
7
- function Button({ title, onClick, className, icon }) {
7
+ function Button({ onClick, children, className }) {
8
8
  const [loading, setLoading] = (0, react_1.useState)(false);
9
9
  const [error, setError] = (0, react_1.useState)(null);
10
10
  const handleClick = async () => {
@@ -21,19 +21,19 @@ function Button({ title, onClick, className, icon }) {
21
21
  .catch(e => setError(e instanceof Error ? e.message : "Unknown error"))
22
22
  .finally(() => setLoading(false));
23
23
  };
24
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { onClick: handleClick, className: className, style: {
25
- display: 'flex',
26
- alignItems: 'center',
27
- justifyContent: 'center',
28
- textAlign: 'center',
29
- cursor: 'pointer',
30
- }, children: loading ?
31
- (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { style: {
32
- width: '1rem',
33
- height: '1rem',
34
- animation: 'spin 1s linear infinite',
35
- } }) :
36
- (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row gap-4 items-center justify-center", children: [icon, title] }) }), error && (0, jsx_runtime_1.jsx)("div", { style: {
37
- color: '#ef4444'
38
- }, children: error })] }));
24
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2", children: [(0, jsx_runtime_1.jsx)("div", { onClick: handleClick, className: className, style: {
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ justifyContent: 'center',
28
+ textAlign: 'center',
29
+ cursor: 'pointer',
30
+ }, children: loading ?
31
+ (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { style: {
32
+ width: '1rem',
33
+ height: '1rem',
34
+ animation: 'spin 1s linear infinite',
35
+ } }) :
36
+ children }), error && (0, jsx_runtime_1.jsx)("div", { style: {
37
+ color: '#ef4444'
38
+ }, children: error })] }) }));
39
39
  }
@@ -7,8 +7,8 @@ exports.default = FormComponent;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("react");
9
9
  const react_2 = require("react");
10
- const button_1 = __importDefault(require("./button"));
11
10
  const input_1 = __importDefault(require("./input"));
11
+ const textButton_1 = __importDefault(require("./textButton"));
12
12
  function FormComponent(props) {
13
13
  const variants = (0, react_2.useMemo)(() => ({
14
14
  default: props.variant
@@ -43,5 +43,5 @@ function FormComponent(props) {
43
43
  return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444', backgroundColor: 'white' }, children: "Unknown input type" });
44
44
  }
45
45
  })()), props.submit &&
46
- (0, jsx_runtime_1.jsx)(button_1.default, { className: variants.default.button, title: props.submit.label, onClick: () => props.submit?.callback(props.value) })] }));
46
+ (0, jsx_runtime_1.jsx)(textButton_1.default, { className: variants.default.button, title: props.submit.label, onClick: () => props.submit?.callback(props.value) })] }));
47
47
  }
@@ -5,4 +5,5 @@ import BaseInput, { type InputComponentProps as BaseInputProps } from './input';
5
5
  import BaseLoader, { type LoaderProps as BaseLoaderProps } from './loader';
6
6
  import BaseModal, { type ModalComponentProps as BaseModalProps } from './modal';
7
7
  import BaseTable, { type TableProps as BaseTableProps } from './table';
8
- export { BaseButton, BaseButtonProps, BaseCopiable, BaseCopiableProps, BaseForm, BaseFormProps, BaseInput, BaseInputProps, BaseLoader, BaseLoaderProps, BaseModal, BaseModalProps, BaseTable, BaseTableProps };
8
+ import BaseTextButton, { type TextButtonProps as BaseTextButtonProps } from './textButton';
9
+ export { BaseButton, BaseButtonProps, BaseCopiable, BaseCopiableProps, BaseForm, BaseFormProps, BaseInput, BaseInputProps, BaseLoader, BaseLoaderProps, BaseModal, BaseModalProps, BaseTable, BaseTableProps, BaseTextButton, BaseTextButtonProps };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BaseTable = exports.BaseModal = exports.BaseLoader = exports.BaseInput = exports.BaseForm = exports.BaseCopiable = exports.BaseButton = void 0;
6
+ exports.BaseTextButton = exports.BaseTable = exports.BaseModal = exports.BaseLoader = exports.BaseInput = exports.BaseForm = exports.BaseCopiable = exports.BaseButton = void 0;
7
7
  const button_1 = __importDefault(require("./button"));
8
8
  exports.BaseButton = button_1.default;
9
9
  const copiable_1 = __importDefault(require("./copiable"));
@@ -18,3 +18,5 @@ const modal_1 = __importDefault(require("./modal"));
18
18
  exports.BaseModal = modal_1.default;
19
19
  const table_1 = __importDefault(require("./table"));
20
20
  exports.BaseTable = table_1.default;
21
+ const textButton_1 = __importDefault(require("./textButton"));
22
+ exports.BaseTextButton = textButton_1.default;
@@ -0,0 +1,7 @@
1
+ import { LucideIcon } from "lucide-react";
2
+ import { ButtonProps } from "./button";
3
+ export type TextButtonProps = Omit<ButtonProps, 'children'> & {
4
+ title: string;
5
+ icon?: React.ReactElement<LucideIcon>;
6
+ };
7
+ export default function TextButton({ title, onClick, className, icon }: TextButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = TextButton;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const button_1 = __importDefault(require("./button"));
9
+ function TextButton({ title, onClick, className, icon }) {
10
+ return ((0, jsx_runtime_1.jsx)(button_1.default, { onClick: onClick, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row gap-4 items-center justify-center", children: [icon, title] }) }));
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.154",
3
+ "version": "0.0.156",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {