@purr-react-tailwindcss/components.button 0.0.1 → 0.0.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.
@@ -1,4 +1,4 @@
1
1
  import { default as React } from 'react';
2
2
  import { IButtonProps } from './_types';
3
3
 
4
- export declare const Button: ({ variant, size, loading, loadingComponent, classes, htmlAttributes, children, onClick, }: IButtonProps) => React.JSX.Element;
4
+ export declare const Button: ({ variant, size, loading, loadingComponent, htmlAttributes, children, onClick, }: IButtonProps) => React.JSX.Element;
package/dist/_types.d.ts CHANGED
@@ -1,19 +1,14 @@
1
- import { ClassValue } from 'clsx';
2
1
  import { ButtonHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
3
2
  import { IExtendable } from '@purr-core/utils.definitions';
4
3
 
5
4
  export type TButtonSize = "small" | "medium" | "large";
6
5
  export type TButtonVariant = "outlined" | "contained" | "text";
7
- export interface IButtonClasses {
8
- container?: ClassValue;
9
- }
10
6
  export interface IButtonProps {
11
7
  size?: TButtonSize;
12
8
  variant?: TButtonVariant;
13
9
  onClick?: MouseEventHandler<HTMLButtonElement>;
14
10
  loading?: boolean;
15
11
  loadingComponent?: ReactNode;
16
- classes?: IButtonClasses;
17
12
  children?: ReactNode;
18
13
  htmlAttributes?: ButtonHTMLAttributes<HTMLButtonElement> & IExtendable;
19
14
  }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),a=require("clsx"),d=require("react"),c=require("@purr-react-tailwindcss/components.icon"),x={container:"animate-spin text-blue-300 w-4 h-4"},m=({variant:e="text",size:t="medium",loading:n=!1,loadingComponent:o,classes:r,htmlAttributes:i,children:u,onClick:l})=>{const s=d.useMemo(()=>n?o??b.jsx(c.Icon,{name:"loader-2",classes:x}):u,[u,n,o]);return b.jsx("button",{onClick:l,className:a("flex","items-center","justify-center","transition-all","duration-200","ease-in-out","shadow-none","outline-none","overflow-hidden","rounded","min-w-16","text-sm","font-medium","cursor-pointer","button",t==="small"?"h-6 px-4":"",t==="medium"?"h-9 px-5":"",t==="large"?"h-12 px-6":"",e==="contained"?"text-gray-900 bg-blue-300 border border-blue-300 hover:bg-blue-400":"",e==="outlined"?"text-blue-300 bg-transparent border border-blue-300 hover:border-blue-200 hover:text-blue-200":"",e==="text"?"text-blue-300 bg-transparent border border-transparent hover:text-blue-200":"",r==null?void 0:r.container),...i,children:s})};exports.Button=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),i=require("clsx"),a=require("react"),d=require("@purr-react-tailwindcss/components.icon"),c={className:"animate-spin text-blue-300 w-4 h-4"},m=({variant:e="text",size:t="medium",loading:r=!1,loadingComponent:n,htmlAttributes:s,children:o,onClick:b})=>{const l=a.useMemo(()=>r?n??u.jsx(d.Icon,{name:"loader-2",htmlAttributes:c}):o,[o,r,n]);return u.jsx("button",{onClick:b,className:i("flex","items-center","justify-center","transition-all","duration-200","ease-in-out","shadow-none","outline-none","overflow-hidden","rounded","min-w-16","text-sm","font-medium","cursor-pointer","button",t==="small"?"h-6 px-4":"",t==="medium"?"h-9 px-5":"",t==="large"?"h-12 px-6":"",e==="contained"?"border border-blue-300 bg-blue-300 text-gray-900 hover:bg-blue-400":"",e==="outlined"?"border border-blue-300 bg-transparent text-blue-300 hover:border-blue-200 hover:text-blue-200":"",e==="text"?"border border-transparent bg-transparent text-blue-300 hover:text-blue-200":""),...s,children:l})};exports.Button=m;
package/dist/index.js CHANGED
@@ -1,25 +1,24 @@
1
- import { jsx as b } from "react/jsx-runtime";
2
- import i from "clsx";
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import s from "clsx";
3
3
  import { useMemo as a } from "react";
4
- import { Icon as x } from "@purr-react-tailwindcss/components.icon";
5
- const s = {
6
- container: "animate-spin text-blue-300 w-4 h-4"
7
- }, g = ({
4
+ import { Icon as d } from "@purr-react-tailwindcss/components.icon";
5
+ const i = {
6
+ className: "animate-spin text-blue-300 w-4 h-4"
7
+ }, h = ({
8
8
  variant: e = "text",
9
9
  size: t = "medium",
10
- loading: o = !1,
11
- loadingComponent: n,
12
- classes: r,
13
- htmlAttributes: m,
14
- children: u,
10
+ loading: r = !1,
11
+ loadingComponent: o,
12
+ htmlAttributes: b,
13
+ children: n,
15
14
  onClick: l
16
15
  }) => {
17
- const d = a(() => o ? n ?? /* @__PURE__ */ b(x, { name: "loader-2", classes: s }) : u, [u, o, n]);
18
- return /* @__PURE__ */ b(
16
+ const m = a(() => r ? o ?? /* @__PURE__ */ u(d, { name: "loader-2", htmlAttributes: i }) : n, [n, r, o]);
17
+ return /* @__PURE__ */ u(
19
18
  "button",
20
19
  {
21
20
  onClick: l,
22
- className: i(
21
+ className: s(
23
22
  "flex",
24
23
  "items-center",
25
24
  "justify-center",
@@ -41,16 +40,15 @@ const s = {
41
40
  // variant === "contained"
42
41
  // ? "text-gray-900 !bg-blue-300 border border-blue-300 hover:!bg-blue-400"
43
42
  // : "",
44
- e === "contained" ? "text-gray-900 bg-blue-300 border border-blue-300 hover:bg-blue-400" : "",
45
- e === "outlined" ? "text-blue-300 bg-transparent border border-blue-300 hover:border-blue-200 hover:text-blue-200" : "",
46
- e === "text" ? "text-blue-300 bg-transparent border border-transparent hover:text-blue-200" : "",
47
- r == null ? void 0 : r.container
43
+ e === "contained" ? "border border-blue-300 bg-blue-300 text-gray-900 hover:bg-blue-400" : "",
44
+ e === "outlined" ? "border border-blue-300 bg-transparent text-blue-300 hover:border-blue-200 hover:text-blue-200" : "",
45
+ e === "text" ? "border border-transparent bg-transparent text-blue-300 hover:text-blue-200" : ""
48
46
  ),
49
- ...m,
50
- children: d
47
+ ...b,
48
+ children: m
51
49
  }
52
50
  );
53
51
  };
54
52
  export {
55
- g as Button
53
+ h as Button
56
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purr-react-tailwindcss/components.button",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "typescript": "*",
25
25
  "react": "*",
26
26
  "clsx": "*",
27
- "@purr-core/utils.definitions": "0.0.5",
28
- "@purr-react-tailwindcss/components.icon": "0.0.1"
27
+ "@purr-core/utils.definitions": "0.0.6",
28
+ "@purr-react-tailwindcss/components.icon": "0.0.2"
29
29
  },
30
30
  "author": "@DinhThienPhuc",
31
31
  "license": "ISC",