@xipkg/button 3.1.8 → 4.0.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.
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +64 -24
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,9 @@ import { VariantProps } from 'class-variance-authority';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
|
-
variant?: "
|
|
6
|
+
variant?: "primary" | "secondary" | "ghost" | "error" | "success" | null | undefined;
|
|
7
7
|
size?: "l" | "m" | "s" | null | undefined;
|
|
8
|
+
loading?: boolean | null | undefined;
|
|
8
9
|
} & class_variance_authority_dist_types.ClassProp) | undefined) => string;
|
|
9
10
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
10
11
|
asChild?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -33,59 +33,99 @@ var __objRest = (source, exclude) => {
|
|
|
33
33
|
// Button.tsx
|
|
34
34
|
import { Slot } from "@radix-ui/react-slot";
|
|
35
35
|
import { cva } from "class-variance-authority";
|
|
36
|
-
import * as React from "react";
|
|
37
36
|
import { cn } from "@xipkg/utils";
|
|
37
|
+
import * as React from "react";
|
|
38
38
|
import { jsx } from "react/jsx-runtime";
|
|
39
39
|
var spinner = 'before:content-[""] before:animate-spin before:rounded-full before:border-gray-60 before:border-2 before:border-t-transparent disabled:opacity-100';
|
|
40
40
|
var buttonVariants = cva(
|
|
41
|
-
|
|
41
|
+
`
|
|
42
|
+
inline-flex border-box justify-center items-center whitespace-nowrap font-medium ring-offset-background transition-colors duration-300 ease-out
|
|
43
|
+
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
44
|
+
disabled:pointer-events-none disabled:bg-gray-5 disabled:text-gray-30
|
|
45
|
+
data-[loading=true]:pointer-events-none
|
|
46
|
+
data-[loading=true]:cursor-not-allowed
|
|
47
|
+
data-[loading=true]:hover:bg-inherit
|
|
48
|
+
data-[loading=true]:active:bg-inherit
|
|
49
|
+
data-[loading=true]:focus:bg-inherit
|
|
50
|
+
data-[loading=true]:focus-visible:ring-0
|
|
51
|
+
`,
|
|
42
52
|
{
|
|
43
53
|
variants: {
|
|
44
54
|
variant: {
|
|
45
|
-
|
|
46
|
-
secondary:
|
|
47
|
-
ghost:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
primary: `text-brand-0 bg-brand-80 hover:bg-brand-60 active:bg-brand-100 focus:bg-brand-100`,
|
|
56
|
+
secondary: `text-brand-100 bg-gray-10 hover:text-brand-0 hover:bg-brand-60 active:text-brand-0 active:bg-brand-100 focus:text-brand-0 focus:bg-brand-100`,
|
|
57
|
+
ghost: `
|
|
58
|
+
text-gray-100 bg-brand-0 border border-transparent
|
|
59
|
+
hover:border-[1px] hover:border-brand-80
|
|
60
|
+
active:bg-gray-5 active:border-0
|
|
61
|
+
focus:bg-gray-5 focus:border-0
|
|
62
|
+
disabled:bg-gray-0
|
|
63
|
+
dark:bg-brand-0
|
|
64
|
+
dark:hover:border-[1px] dark:hover:border-brand-80
|
|
65
|
+
dark:active:border-0
|
|
66
|
+
dark:focus:border-0
|
|
67
|
+
dark:disabled:bg-gray-0
|
|
68
|
+
`,
|
|
69
|
+
error: `text-red-0 bg-red-80 hover:bg-red-100 active:bg-red-100 focus:bg-red-100`,
|
|
70
|
+
success: `text-green-0 bg-green-80 hover:bg-green-100 active:bg-green-100 focus:bg-green-100`
|
|
54
71
|
},
|
|
55
72
|
size: {
|
|
56
|
-
l: "h-14
|
|
57
|
-
m: "h-12
|
|
58
|
-
s: "h-8
|
|
73
|
+
l: "h-14 text-[20px] px-8 rounded-2xl",
|
|
74
|
+
m: "h-12 text-[16px] px-6 rounded-xl",
|
|
75
|
+
s: "h-8 text-[14px] px-4 rounded-lg"
|
|
76
|
+
},
|
|
77
|
+
loading: {
|
|
78
|
+
true: spinner
|
|
59
79
|
}
|
|
60
80
|
},
|
|
61
81
|
compoundVariants: [
|
|
62
82
|
{
|
|
63
|
-
variant: ["
|
|
83
|
+
variant: ["primary", "error", "success", "secondary"],
|
|
84
|
+
loading: true,
|
|
85
|
+
class: "bg-gray-5"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
variant: "ghost",
|
|
89
|
+
loading: true,
|
|
90
|
+
class: "bg-gray-0 dark:bg-gray-0"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
loading: true,
|
|
64
94
|
size: "l",
|
|
65
|
-
class: "before:w-8 before:h-8
|
|
95
|
+
class: "before:w-8 before:h-8"
|
|
66
96
|
},
|
|
67
97
|
{
|
|
68
|
-
|
|
98
|
+
loading: true,
|
|
69
99
|
size: "m",
|
|
70
|
-
class: "before:w-6 before:h-6
|
|
100
|
+
class: "before:w-6 before:h-6"
|
|
71
101
|
},
|
|
72
102
|
{
|
|
73
|
-
|
|
103
|
+
loading: true,
|
|
74
104
|
size: "s",
|
|
75
|
-
class: "before:w-4 before:h-4
|
|
105
|
+
class: "before:w-4 before:h-4"
|
|
76
106
|
}
|
|
77
107
|
],
|
|
78
108
|
defaultVariants: {
|
|
79
|
-
variant: "
|
|
80
|
-
size: "m"
|
|
109
|
+
variant: "primary",
|
|
110
|
+
size: "m",
|
|
111
|
+
loading: false
|
|
81
112
|
}
|
|
82
113
|
}
|
|
83
114
|
);
|
|
84
115
|
var Button = React.forwardRef(
|
|
85
116
|
(_a, ref) => {
|
|
86
|
-
var _b = _a, { className, variant, size, asChild = false, children } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild", "children"]);
|
|
117
|
+
var _b = _a, { className, variant, size, loading = false, asChild = false, children } = _b, props = __objRest(_b, ["className", "variant", "size", "loading", "asChild", "children"]);
|
|
87
118
|
const Comp = asChild ? Slot : "button";
|
|
88
|
-
return /* @__PURE__ */ jsx(
|
|
119
|
+
return /* @__PURE__ */ jsx(
|
|
120
|
+
Comp,
|
|
121
|
+
__spreadProps(__spreadValues({
|
|
122
|
+
className: cn(buttonVariants({ variant, size, loading, className })),
|
|
123
|
+
ref,
|
|
124
|
+
"data-loading": loading
|
|
125
|
+
}, props), {
|
|
126
|
+
children: loading ? /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430..." }) : children
|
|
127
|
+
})
|
|
128
|
+
);
|
|
89
129
|
}
|
|
90
130
|
);
|
|
91
131
|
Button.displayName = "Button";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xipkg/button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@radix-ui/react-slot": "^1.1.2",
|
|
26
|
-
"@xipkg/utils": "^1.
|
|
26
|
+
"@xipkg/utils": "^1.8.0",
|
|
27
27
|
"class-variance-authority": "^0.7.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|