@xipkg/button 3.0.6 → 3.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.
@@ -0,0 +1,14 @@
1
+ import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
2
+ import { VariantProps } from 'class-variance-authority';
3
+ import * as React from 'react';
4
+
5
+ declare const buttonVariants: (props?: ({
6
+ variant?: "default" | "secondary" | "ghost" | "error" | "success" | "secondary-error" | "default-spinner" | "secondary-spinner" | "ghost-spinner" | null | undefined;
7
+ size?: "l" | "m" | "s" | null | undefined;
8
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
9
+ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
10
+ asChild?: boolean;
11
+ }
12
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
13
+
14
+ export { Button, type ButtonProps, buttonVariants };
package/dist/index.mjs ADDED
@@ -0,0 +1,95 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // Button.tsx
34
+ import { Slot } from "@radix-ui/react-slot";
35
+ import { cva } from "class-variance-authority";
36
+ import * as React from "react";
37
+ import { cn } from "@xipkg/utils";
38
+ import { jsx } from "react/jsx-runtime";
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
+ var buttonVariants = cva(
41
+ "inline-flex border-box justify-center items-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
42
+ {
43
+ variants: {
44
+ variant: {
45
+ default: "text-gray-0 dark:text-gray-100 bg-brand-80 hover:bg-brand-100 active:bg-brand-100 focus:bg-brand-100",
46
+ secondary: "bg-gray-0 text-gray-100 border-gray-30 border-2 hover:bg-gray-5 active:bg-gray-5 focus:bg-gray-5",
47
+ ghost: "text-gray-100 bg-gray-0 border-0 hover:bg-gray-5 active:bg-gray-5 focus:bg-gray-5",
48
+ error: "bg-red-80 text-gray-0 hover:bg-red-100 active:bg-red-100 focus:bg-red-100",
49
+ success: "bg-green-80 text-gray-0 hover:bg-green-100 active:bg-green-100 focus:bg-green-100",
50
+ "secondary-error": "bg-red-0 text-red-100 border-2 border-red-100 disabled:text-red-20 disabled:border-red-20 hover:bg-red-20 active:bg-red-20 focus:bg-red-20",
51
+ "default-spinner": `bg-gray-10 ${spinner}`,
52
+ "secondary-spinner": `bg-gray-0 border-gray-30 border-2 ${spinner}`,
53
+ "ghost-spinner": `bg-gray-0 border-0 ${spinner}`
54
+ },
55
+ size: {
56
+ l: "h-14 rounded-xl px-8 text-[20px] pb-[3px]",
57
+ m: "h-12 rounded-lg px-4 text-[16px] pb-[2px]",
58
+ s: "h-8 rounded-md px-3 text-[14px] pb-[2px]"
59
+ }
60
+ },
61
+ compoundVariants: [
62
+ {
63
+ variant: ["default-spinner", "secondary-spinner", "ghost-spinner"],
64
+ size: "l",
65
+ class: "before:w-8 before:h-8 p-0"
66
+ },
67
+ {
68
+ variant: ["default-spinner", "secondary-spinner", "ghost-spinner"],
69
+ size: "m",
70
+ class: "before:w-6 before:h-6 p-0"
71
+ },
72
+ {
73
+ variant: ["default-spinner", "secondary-spinner", "ghost-spinner"],
74
+ size: "s",
75
+ class: "before:w-4 before:h-4 p-0"
76
+ }
77
+ ],
78
+ defaultVariants: {
79
+ variant: "default",
80
+ size: "m"
81
+ }
82
+ }
83
+ );
84
+ var Button = React.forwardRef(
85
+ (_a, ref) => {
86
+ var _b = _a, { className, variant, size, asChild = false, children } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild", "children"]);
87
+ const Comp = asChild ? Slot : "button";
88
+ return /* @__PURE__ */ jsx(Comp, __spreadProps(__spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props), { children }));
89
+ }
90
+ );
91
+ Button.displayName = "Button";
92
+ export {
93
+ Button,
94
+ buttonVariants
95
+ };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@xipkg/button",
3
- "version": "3.0.6",
4
- "main": "./dist/index.js",
5
- "module": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
3
+ "version": "3.0.8",
4
+ "main": "./dist/index.mjs",
5
+ "module": "./dist/index.mjs",
6
+ "types": "./dist/index.d.mts",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/index.js",
10
- "default": "./dist/index.js"
9
+ "import": "./dist/index.mjs",
10
+ "default": "./dist/index.mjs"
11
11
  }
12
12
  },
13
13
  "license": "MIT",