@nextime-ui/react
Version:
NeXTIME UI é uma biblioteca de componentes para React, fundamentada no Preline UI. Ela faz a inclusão do recurso 'use client' em seus componentes, uma estratégia eficaz para solucionar problemas existentes no Next.js versão 15.
144 lines (141 loc) • 5.07 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
// ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
function r(e) {
var t, f, n = "";
if ("string" == typeof e || "number" == typeof e) n += e;
else if ("object" == typeof e) if (Array.isArray(e)) {
var o = e.length;
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
} else for (f in e) e[f] && (n && (n += " "), n += f);
return n;
}
function clsx() {
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
return n;
}
var clsx_default = clsx;
// src/components/Button.tsx
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var Button = (_a) => {
var _b = _a, {
type = "button",
variant = "solid",
size = "default",
color = "blue",
isLoading = false,
isFullWidth = false,
rounded = false,
startIcon,
endIcon,
children
} = _b, props = __objRest(_b, [
"type",
"variant",
"size",
"color",
"isLoading",
"isFullWidth",
"rounded",
"startIcon",
"endIcon",
"children"
]);
var _a2;
const baseClasses = "inline-flex items-center gap-x-2 text-sm font-medium focus:outline-none disabled:opacity-50 disabled:pointer-events-none";
const sizeClasses = {
small: "py-2 px-3",
default: "py-3 px-4",
large: "py-3 px-4 sm:p-5",
icon: "flex justify-center items-center size-[46px]"
};
const variantClasses = {
solid: {
blue: "bg-blue-600 text-white hover:bg-blue-700 focus:bg-blue-700",
gray: "bg-gray-800 text-white hover:bg-gray-900 focus:bg-gray-900",
red: "bg-red-500 text-white hover:bg-red-600 focus:bg-red-600",
yellow: "bg-yellow-500 text-white hover:bg-yellow-600 focus:bg-yellow-600",
teal: "bg-teal-500 text-white hover:bg-teal-600 focus:bg-teal-600",
white: "bg-white text-gray-800 shadow-sm hover:bg-gray-50 focus:bg-gray-50"
},
outline: {
blue: "border border-blue-600 text-blue-600 hover:text-blue-500",
gray: "border border-gray-800 text-gray-800 hover:text-gray-500",
red: "border border-red-500 text-red-500 hover:text-red-400",
yellow: "border border-yellow-500 text-yellow-500 hover:text-yellow-400",
teal: "border border-teal-500 text-teal-500 hover:text-teal-400",
white: "border border-white text-white hover:text-gray-800"
},
ghost: {
blue: "text-blue-600 hover:bg-blue-100 hover:text-blue-800",
gray: "text-gray-500 hover:bg-gray-100",
red: "text-red-500 hover:bg-red-100",
yellow: "text-yellow-500 hover:bg-yellow-100",
teal: "text-teal-500 hover:bg-teal-100",
white: "text-white hover:bg-gray-800"
}
};
const roundedClasses = rounded ? "rounded-full" : "rounded-lg";
const widthClasses = isFullWidth ? "w-full" : "";
const spinnerClasses = "animate-spin inline-block size-4 border-[3px] border-current border-t-transparent rounded-full";
const computedClasses = clsx_default(
baseClasses,
sizeClasses[size],
roundedClasses,
widthClasses,
(_a2 = variantClasses[variant]) == null ? void 0 : _a2[color]
);
return /* @__PURE__ */ jsx(
"button",
__spreadProps(__spreadValues({
type,
className: computedClasses,
disabled: isLoading
}, props), {
children: isLoading ? /* @__PURE__ */ jsx(
"span",
{
className: spinnerClasses,
role: "status",
"aria-label": "loading"
}
) : /* @__PURE__ */ jsxs(Fragment, { children: [
startIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: startIcon }),
children,
endIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: endIcon })
] })
})
);
};
export {
Button
};