@purr-react-tailwindcss/components.button 0.0.1 → 0.0.3
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/_components.d.ts +1 -1
- package/dist/_types.d.ts +0 -5
- package/dist/index.cjs +1 -1
- package/dist/index.js +19 -21
- package/package.json +3 -3
package/dist/_components.d.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
},
|
|
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:
|
|
11
|
-
loadingComponent:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
children: u,
|
|
10
|
+
loading: r = !1,
|
|
11
|
+
loadingComponent: o,
|
|
12
|
+
htmlAttributes: b,
|
|
13
|
+
children: n,
|
|
15
14
|
onClick: l
|
|
16
15
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
return /* @__PURE__ */
|
|
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:
|
|
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" ? "
|
|
45
|
-
e === "outlined" ? "
|
|
46
|
-
e === "text" ? "
|
|
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
|
-
...
|
|
50
|
-
children:
|
|
47
|
+
...b,
|
|
48
|
+
children: m
|
|
51
49
|
}
|
|
52
50
|
);
|
|
53
51
|
};
|
|
54
52
|
export {
|
|
55
|
-
|
|
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.
|
|
3
|
+
"version": "0.0.3",
|
|
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.
|
|
28
|
-
"@purr-react-tailwindcss/components.icon": "0.0.
|
|
27
|
+
"@purr-core/utils.definitions": "0.0.7",
|
|
28
|
+
"@purr-react-tailwindcss/components.icon": "0.0.3"
|
|
29
29
|
},
|
|
30
30
|
"author": "@DinhThienPhuc",
|
|
31
31
|
"license": "ISC",
|