@purr-react-tailwindcss/components.button 0.0.6 → 0.0.8
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/index.cjs +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.js +1 -54
- package/package.json +5 -3
- package/dist/_components.d.ts +0 -4
- package/dist/_types.d.ts +0 -14
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';var s=require('clsx'),u=require('react'),components_icon=require('@purr-react-tailwindcss/components.icon');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var s__default=/*#__PURE__*/_interopDefault(s);var u__default=/*#__PURE__*/_interopDefault(u);var d={className:"animate-spin text-blue-300 w-4 h-4"},c=({variant:t="text",size:e="medium",loading:r=false,loadingComponent:o,htmlAttributes:b,children:n,onClick:m})=>{let l=u.useMemo(()=>r?o??u__default.default.createElement(components_icon.Icon,{name:"loader-2",htmlAttributes:d}):n,[n,r,o]);return u__default.default.createElement("button",{onClick:m,className:s__default.default("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",e==="small"?"h-6 px-4":"",e==="medium"?"h-9 px-5":"",e==="large"?"h-12 px-6":"",t==="contained"?"border border-blue-300 bg-blue-300 text-gray-900 hover:bg-blue-400":"",t==="outlined"?"border border-blue-300 bg-transparent text-blue-300 hover:border-blue-200 hover:text-blue-200":"",t==="text"?"border border-transparent bg-transparent text-blue-300 hover:text-blue-200":""),...b},l)};exports.Button=c;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { MouseEventHandler, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { IExtendable } from '@purr-core/utils.definitions';
|
|
3
|
+
|
|
4
|
+
type TButtonSize = "small" | "medium" | "large";
|
|
5
|
+
type TButtonVariant = "outlined" | "contained" | "text";
|
|
6
|
+
interface IButtonProps {
|
|
7
|
+
size?: TButtonSize;
|
|
8
|
+
variant?: TButtonVariant;
|
|
9
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
loadingComponent?: ReactNode;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
htmlAttributes?: ButtonHTMLAttributes<HTMLButtonElement> & IExtendable;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const Button: ({ variant, size, loading, loadingComponent, htmlAttributes, children, onClick, }: IButtonProps) => React.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { Button, type IButtonProps, type TButtonSize, type TButtonVariant };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React, { MouseEventHandler, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { IExtendable } from '@purr-core/utils.definitions';
|
|
3
|
+
|
|
4
|
+
type TButtonSize = "small" | "medium" | "large";
|
|
5
|
+
type TButtonVariant = "outlined" | "contained" | "text";
|
|
6
|
+
interface IButtonProps {
|
|
7
|
+
size?: TButtonSize;
|
|
8
|
+
variant?: TButtonVariant;
|
|
9
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
loadingComponent?: ReactNode;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
htmlAttributes?: ButtonHTMLAttributes<HTMLButtonElement> & IExtendable;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const Button: ({ variant, size, loading, loadingComponent, htmlAttributes, children, onClick, }: IButtonProps) => React.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { Button, type IButtonProps, type TButtonSize, type TButtonVariant };
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import s from "clsx";
|
|
3
|
-
import { useMemo as a } from "react";
|
|
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
|
-
variant: e = "text",
|
|
9
|
-
size: t = "medium",
|
|
10
|
-
loading: r = !1,
|
|
11
|
-
loadingComponent: o,
|
|
12
|
-
htmlAttributes: b,
|
|
13
|
-
children: n,
|
|
14
|
-
onClick: l
|
|
15
|
-
}) => {
|
|
16
|
-
const m = a(() => r ? o ?? /* @__PURE__ */ u(d, { name: "loader-2", htmlAttributes: i }) : n, [n, r, o]);
|
|
17
|
-
return /* @__PURE__ */ u(
|
|
18
|
-
"button",
|
|
19
|
-
{
|
|
20
|
-
onClick: l,
|
|
21
|
-
className: s(
|
|
22
|
-
"flex",
|
|
23
|
-
"items-center",
|
|
24
|
-
"justify-center",
|
|
25
|
-
"transition-all",
|
|
26
|
-
"duration-200",
|
|
27
|
-
"ease-in-out",
|
|
28
|
-
"shadow-none",
|
|
29
|
-
"outline-none",
|
|
30
|
-
"overflow-hidden",
|
|
31
|
-
"rounded",
|
|
32
|
-
"min-w-16",
|
|
33
|
-
"text-sm",
|
|
34
|
-
"font-medium",
|
|
35
|
-
"cursor-pointer",
|
|
36
|
-
"button",
|
|
37
|
-
t === "small" ? "h-6 px-4" : "",
|
|
38
|
-
t === "medium" ? "h-9 px-5" : "",
|
|
39
|
-
t === "large" ? "h-12 px-6" : "",
|
|
40
|
-
// variant === "contained"
|
|
41
|
-
// ? "text-gray-900 !bg-blue-300 border border-blue-300 hover:!bg-blue-400"
|
|
42
|
-
// : "",
|
|
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" : ""
|
|
46
|
-
),
|
|
47
|
-
...b,
|
|
48
|
-
children: m
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
export {
|
|
53
|
-
h as Button
|
|
54
|
-
};
|
|
1
|
+
import s from'clsx';import u,{useMemo}from'react';import {Icon}from'@purr-react-tailwindcss/components.icon';var d={className:"animate-spin text-blue-300 w-4 h-4"},c=({variant:t="text",size:e="medium",loading:r=false,loadingComponent:o,htmlAttributes:b,children:n,onClick:m})=>{let l=useMemo(()=>r?o??u.createElement(Icon,{name:"loader-2",htmlAttributes:d}):n,[n,r,o]);return u.createElement("button",{onClick:m,className:s("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",e==="small"?"h-6 px-4":"",e==="medium"?"h-9 px-5":"",e==="large"?"h-12 px-6":"",t==="contained"?"border border-blue-300 bg-blue-300 text-gray-900 hover:bg-blue-400":"",t==="outlined"?"border border-blue-300 bg-transparent text-blue-300 hover:border-blue-200 hover:text-blue-200":"",t==="text"?"border border-transparent bg-transparent text-blue-300 hover:text-blue-200":""),...b},l)};export{c as Button};
|
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.8",
|
|
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.12",
|
|
28
|
+
"@purr-react-tailwindcss/components.icon": "0.0.8"
|
|
29
29
|
},
|
|
30
30
|
"author": "@DinhThienPhuc",
|
|
31
31
|
"license": "ISC",
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "vite build --watch",
|
|
36
36
|
"build": "tsc && vite build",
|
|
37
|
+
"build:vite": "tsc && vite build",
|
|
38
|
+
"build:tsup": "tsup",
|
|
37
39
|
"lint": "eslint . --ext ts,tsx --max-warnings 0"
|
|
38
40
|
}
|
|
39
41
|
}
|
package/dist/_components.d.ts
DELETED
package/dist/_types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
-
import { IExtendable } from '@purr-core/utils.definitions';
|
|
3
|
-
|
|
4
|
-
export type TButtonSize = "small" | "medium" | "large";
|
|
5
|
-
export type TButtonVariant = "outlined" | "contained" | "text";
|
|
6
|
-
export interface IButtonProps {
|
|
7
|
-
size?: TButtonSize;
|
|
8
|
-
variant?: TButtonVariant;
|
|
9
|
-
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
10
|
-
loading?: boolean;
|
|
11
|
-
loadingComponent?: ReactNode;
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
htmlAttributes?: ButtonHTMLAttributes<HTMLButtonElement> & IExtendable;
|
|
14
|
-
}
|