neogestify-ui-components 2.2.2 → 2.3.1
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/LICENSE +21 -0
- package/README.md +803 -349
- package/dist/components/ElementLibraryBuilder/index.js +299 -120
- package/dist/components/ElementLibraryBuilder/index.js.map +1 -1
- package/dist/components/ElementLibraryBuilder/index.mjs +300 -121
- package/dist/components/ElementLibraryBuilder/index.mjs.map +1 -1
- package/dist/components/VenueMapEditor/index.js.map +1 -1
- package/dist/components/VenueMapEditor/index.mjs.map +1 -1
- package/dist/components/alerts/index.js +108 -51
- package/dist/components/alerts/index.js.map +1 -1
- package/dist/components/alerts/index.mjs +109 -52
- package/dist/components/alerts/index.mjs.map +1 -1
- package/dist/components/html/index.d.mts +101 -22
- package/dist/components/html/index.d.ts +101 -22
- package/dist/components/html/index.js +506 -166
- package/dist/components/html/index.js.map +1 -1
- package/dist/components/html/index.mjs +507 -167
- package/dist/components/html/index.mjs.map +1 -1
- package/dist/components/icons/index.d.mts +5 -1
- package/dist/components/icons/index.d.ts +5 -1
- package/dist/components/icons/index.js +16 -0
- package/dist/components/icons/index.js.map +1 -1
- package/dist/components/icons/index.mjs +13 -1
- package/dist/components/icons/index.mjs.map +1 -1
- package/dist/context/theme/index.js +59 -37
- package/dist/context/theme/index.js.map +1 -1
- package/dist/context/theme/index.mjs +59 -37
- package/dist/context/theme/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +510 -166
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +508 -168
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/html/Button.tsx +84 -38
- package/src/components/html/Form.tsx +33 -13
- package/src/components/html/Input.tsx +110 -31
- package/src/components/html/Loading.tsx +58 -33
- package/src/components/html/Modal.tsx +67 -20
- package/src/components/html/Select.tsx +92 -39
- package/src/components/html/Table.tsx +274 -50
- package/src/components/html/TextArea.tsx +81 -31
- package/src/components/icons/icons.tsx +32 -0
|
@@ -38,56 +38,92 @@ function CloseIcon({ className }) {
|
|
|
38
38
|
}
|
|
39
39
|
) });
|
|
40
40
|
}
|
|
41
|
+
function ChevronDownIcon({ className }) {
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", className, fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.516 7.548c.436-.446 1.043-.481 1.576 0L8 9.747l1.908-2.199c.533-.481 1.14-.446 1.576 0 .436.445.408 1.197 0 1.615-.408.418-2.695 2.977-2.695 2.977-.27.282-.64.423-1.01.423s-.74-.14-1.01-.423c0 0-2.287-2.559-2.695-2.977-.408-.418-.436-1.17 0-1.615z" }) });
|
|
43
|
+
}
|
|
44
|
+
var BASE = "transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer inline-flex items-center gap-2";
|
|
45
|
+
var SIZE_PAD = {
|
|
46
|
+
sm: "px-2.5 py-1.5 text-xs",
|
|
47
|
+
md: "px-3 py-2 text-sm",
|
|
48
|
+
lg: "px-4 py-2.5 text-base"
|
|
49
|
+
};
|
|
50
|
+
var SIZE_ICON_PAD = {
|
|
51
|
+
sm: "p-1.5",
|
|
52
|
+
md: "p-2",
|
|
53
|
+
lg: "p-2.5"
|
|
54
|
+
};
|
|
55
|
+
var SHAPE_CLASS = {
|
|
56
|
+
rounded: "rounded-md",
|
|
57
|
+
pill: "rounded-full",
|
|
58
|
+
square: "rounded-none"
|
|
59
|
+
};
|
|
60
|
+
var VARIANT_STYLE = {
|
|
61
|
+
primary: "border border-indigo-600/20 dark:border-indigo-500/20 font-medium text-white bg-indigo-600 hover:bg-indigo-700 dark:bg-indigo-500 dark:hover:bg-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
62
|
+
secondary: "font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-800 border border-gray-300 dark:border-gray-600 shadow-sm hover:shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
63
|
+
icon: "text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
64
|
+
danger: "border border-red-600/20 dark:border-red-500/20 font-medium text-white bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 dark:focus:ring-red-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
65
|
+
success: "border border-green-600/20 dark:border-green-500/20 font-medium text-white bg-green-600 hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
66
|
+
outline: "border border-gray-300 dark:border-gray-600 font-medium text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
67
|
+
nav: "w-full px-4 py-2 text-sm font-medium hover:scale-105 text-gray-700 dark:text-gray-300 dark:hover:text-white hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
68
|
+
custom: "",
|
|
69
|
+
link: "text-sm text-indigo-600 dark:text-indigo-400 hover:text-indigo-700 dark:hover:text-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900 rounded-lg px-2",
|
|
70
|
+
warning: "border border-yellow-600/20 dark:border-yellow-500/20 font-medium text-white bg-yellow-600 hover:bg-yellow-700 dark:bg-yellow-500 dark:hover:bg-yellow-600 focus:outline-none focus:ring-2 focus:ring-yellow-500 dark:focus:ring-yellow-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
71
|
+
toggle: "font-medium border-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
72
|
+
ghost: "font-medium text-indigo-600 dark:text-indigo-400 bg-transparent border border-indigo-200 dark:border-indigo-800 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900"
|
|
73
|
+
};
|
|
41
74
|
var Button = ({
|
|
42
75
|
variant = "primary",
|
|
43
76
|
children,
|
|
44
77
|
isLoading = false,
|
|
45
78
|
loadingText,
|
|
46
79
|
isActive = false,
|
|
80
|
+
size = "md",
|
|
81
|
+
leftIcon,
|
|
82
|
+
rightIcon,
|
|
83
|
+
fullWidth = false,
|
|
84
|
+
shape,
|
|
47
85
|
className = "",
|
|
48
86
|
disabled,
|
|
49
87
|
...props
|
|
50
88
|
}) => {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
success: "py-2 px-2 border border-green-600/20 dark:border-green-500/20 text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
58
|
-
outline: "py-2 px-2 border border-gray-300 dark:border-gray-600 text-sm font-medium rounded-md text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
59
|
-
nav: "w-full flex items-center px-4 py-2 text-sm font-medium rounded-md transition-all duration-200 hover:scale-105 text-gray-700 dark:text-gray-300 dark:hover:text-white hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
60
|
-
custom: "",
|
|
61
|
-
link: "text-sm text-indigo-600 dark:text-indigo-400 hover:text-indigo-700 dark:hover:text-indigo-300 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900 rounded-lg px-2",
|
|
62
|
-
warning: "py-2 px-2 border border-yellow-600/20 dark:border-yellow-500/20 text-sm font-medium rounded-md text-white bg-yellow-600 hover:bg-yellow-700 dark:bg-yellow-500 dark:hover:bg-yellow-600 focus:outline-none focus:ring-2 focus:ring-yellow-500 dark:focus:ring-yellow-400 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900",
|
|
63
|
-
toggle: "px-2 py-2 rounded-lg font-medium transition-all duration-200 disabled:cursor-not-allowed border-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-50 dark:focus:ring-offset-gray-900"
|
|
64
|
-
};
|
|
65
|
-
let classes = `${baseClasses} ${variantClasses[variant]} ${className}`;
|
|
66
|
-
if (variant === "nav" && isActive) {
|
|
67
|
-
classes += " bg-indigo-600 dark:bg-indigo-500 hover:bg-indigo-700 dark:hover:bg-indigo-600 text-white shadow-lg scale-105";
|
|
68
|
-
}
|
|
69
|
-
if (variant === "nav" && !isActive) {
|
|
70
|
-
classes += " hover:bg-white dark:hover:bg-gray-700 hover:shadow-lg";
|
|
89
|
+
const sizeCls = variant === "icon" ? SIZE_ICON_PAD[size] : variant === "nav" || variant === "link" || variant === "custom" ? "" : SIZE_PAD[size];
|
|
90
|
+
const defaultShape = variant === "icon" ? "pill" : "rounded";
|
|
91
|
+
const shapeCls = variant === "link" || variant === "custom" ? "" : SHAPE_CLASS[shape ?? defaultShape];
|
|
92
|
+
let stateCls = "";
|
|
93
|
+
if (variant === "nav") {
|
|
94
|
+
stateCls = isActive ? "bg-indigo-600 dark:bg-indigo-500 hover:bg-indigo-700 dark:hover:bg-indigo-600 text-white shadow-lg scale-105" : "hover:bg-white dark:hover:bg-gray-700";
|
|
71
95
|
}
|
|
72
96
|
if (variant === "toggle") {
|
|
73
|
-
|
|
74
|
-
classes += " bg-indigo-600 text-white border-indigo-600/30 dark:border-indigo-500/30 hover:bg-indigo-700";
|
|
75
|
-
} else {
|
|
76
|
-
classes += " bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-300 dark:hover:bg-gray-600 hover:border-gray-400 dark:hover:border-gray-500";
|
|
77
|
-
}
|
|
97
|
+
stateCls = isActive ? "bg-indigo-600 text-white border-indigo-600/30 dark:border-indigo-500/30 hover:bg-indigo-700" : "bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-300 dark:hover:bg-gray-600";
|
|
78
98
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
99
|
+
const classes = [
|
|
100
|
+
BASE,
|
|
101
|
+
VARIANT_STYLE[variant],
|
|
102
|
+
sizeCls,
|
|
103
|
+
shapeCls,
|
|
104
|
+
stateCls,
|
|
105
|
+
fullWidth ? "w-full justify-center" : "",
|
|
106
|
+
className
|
|
107
|
+
].filter(Boolean).join(" ");
|
|
108
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { className: classes, disabled: disabled || isLoading, ...props, children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(AnimateSpin, { className: "h-4 w-4 shrink-0 text-current" }),
|
|
110
|
+
loadingText ?? "Cargando..."
|
|
111
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
112
|
+
leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: leftIcon }),
|
|
113
|
+
children,
|
|
114
|
+
rightIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: rightIcon })
|
|
115
|
+
] }) });
|
|
116
|
+
};
|
|
117
|
+
var SIZE_CLASSES = {
|
|
118
|
+
sm: "px-2.5 py-1.5 text-xs",
|
|
119
|
+
md: "px-3 py-2 text-sm",
|
|
120
|
+
lg: "px-4 py-2.5 text-base"
|
|
121
|
+
};
|
|
122
|
+
var VARIANT_CLASSES = {
|
|
123
|
+
default: "border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",
|
|
124
|
+
outline: "border-2 border-indigo-300 dark:border-indigo-600 bg-transparent",
|
|
125
|
+
filled: "border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700",
|
|
126
|
+
minimal: "border-0 border-b border-gray-300 dark:border-gray-600 bg-transparent rounded-none focus:ring-0"
|
|
91
127
|
};
|
|
92
128
|
var Input = ({
|
|
93
129
|
label,
|
|
@@ -95,34 +131,63 @@ var Input = ({
|
|
|
95
131
|
helperText,
|
|
96
132
|
icon,
|
|
97
133
|
iconSide = "left",
|
|
134
|
+
variant = "default",
|
|
135
|
+
size = "md",
|
|
136
|
+
prefix,
|
|
137
|
+
suffix,
|
|
138
|
+
clearable = false,
|
|
139
|
+
onClear,
|
|
98
140
|
className = "",
|
|
99
141
|
id,
|
|
100
142
|
type,
|
|
101
143
|
...props
|
|
102
144
|
}) => {
|
|
103
145
|
const inputId = id || `input-${Math.random().toString(36).substring(2, 9)}`;
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
146
|
+
const errorCls = error ? "border-red-300 dark:border-red-600 focus:ring-red-500 dark:focus:ring-red-400 focus:border-red-500" : "";
|
|
147
|
+
const showClear = clearable && !props.disabled && props.value !== void 0 && props.value !== "";
|
|
148
|
+
const hasRightSlot = icon && iconSide === "right" || showClear;
|
|
149
|
+
const baseCls = "appearance-none relative block w-full placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:border-indigo-500 focus:z-10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200";
|
|
150
|
+
const inputCls = [
|
|
151
|
+
baseCls,
|
|
152
|
+
SIZE_CLASSES[size],
|
|
153
|
+
VARIANT_CLASSES[variant],
|
|
154
|
+
errorCls,
|
|
155
|
+
icon && iconSide === "left" ? "pl-9" : "",
|
|
156
|
+
hasRightSlot ? "pr-9" : "",
|
|
157
|
+
prefix ? "rounded-l-none" : "",
|
|
158
|
+
suffix ? "rounded-r-none" : "",
|
|
159
|
+
className
|
|
160
|
+
].filter(Boolean).join(" ");
|
|
161
|
+
const toggleCls = [
|
|
162
|
+
`h-4 w-4 ${type === "radio" ? "rounded-full" : "rounded"} border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800`,
|
|
163
|
+
"text-indigo-600 dark:text-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400",
|
|
164
|
+
"focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-900",
|
|
165
|
+
"disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200 cursor-pointer",
|
|
166
|
+
error ? "border-red-300 dark:border-red-600 focus:ring-red-500 dark:focus:ring-red-400" : ""
|
|
167
|
+
].filter(Boolean).join(" ");
|
|
168
|
+
const fileCls = [
|
|
169
|
+
"block w-full text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 border rounded-md",
|
|
170
|
+
"focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:border-indigo-500",
|
|
171
|
+
"disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
|
|
172
|
+
"file:mr-4 file:py-2 file:px-4 file:rounded-l-md file:border-0 file:text-sm file:font-medium",
|
|
173
|
+
"file:bg-indigo-50 file:text-indigo-700 dark:file:bg-indigo-900/50 dark:file:text-indigo-300",
|
|
174
|
+
"hover:file:bg-indigo-100 dark:hover:file:bg-indigo-800/50 file:transition-colors file:duration-200 file:cursor-pointer",
|
|
175
|
+
SIZE_CLASSES[size],
|
|
176
|
+
error ? "border-red-300 dark:border-red-600 focus:ring-red-500 dark:focus:ring-red-400" : "border-gray-300 dark:border-gray-600",
|
|
177
|
+
className
|
|
178
|
+
].filter(Boolean).join(" ");
|
|
116
179
|
const hasHidden = Boolean(className && /\bhidden\b/.test(className));
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
180
|
+
const wrapperCls = `space-y-1 w-full${hasHidden ? " hidden" : ""}`;
|
|
181
|
+
const labelNode = label && (typeof label === "string" ? /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, className: "block text-sm font-medium text-gray-700 dark:text-gray-300", children: [
|
|
182
|
+
label,
|
|
183
|
+
props.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", "aria-hidden": "true", children: "*" })
|
|
184
|
+
] }) : label);
|
|
120
185
|
const errorNode = error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600 dark:text-red-400", role: "alert", children: error });
|
|
121
186
|
const helperNode = helperText && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: helperText });
|
|
122
187
|
if (type === "checkbox" || type === "radio") {
|
|
123
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
188
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperCls, children: [
|
|
124
189
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
125
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { id: inputId, type, className:
|
|
190
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { id: inputId, type, className: toggleCls, ...props }),
|
|
126
191
|
labelNode
|
|
127
192
|
] }),
|
|
128
193
|
errorNode,
|
|
@@ -130,63 +195,108 @@ var Input = ({
|
|
|
130
195
|
] });
|
|
131
196
|
}
|
|
132
197
|
if (type === "file") {
|
|
133
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
198
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperCls, children: [
|
|
134
199
|
labelNode,
|
|
135
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { id: inputId, type: "file", className:
|
|
200
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { id: inputId, type: "file", className: fileCls, ...props }),
|
|
136
201
|
errorNode,
|
|
137
202
|
helperNode
|
|
138
203
|
] });
|
|
139
204
|
}
|
|
140
|
-
|
|
205
|
+
const prefixBorderCls = error ? "border-red-300 dark:border-red-600" : "border-gray-300 dark:border-gray-600";
|
|
206
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperCls, children: [
|
|
141
207
|
labelNode,
|
|
142
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
143
|
-
|
|
144
|
-
/* @__PURE__ */ jsxRuntime.
|
|
145
|
-
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex", children: [
|
|
209
|
+
prefix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `inline-flex shrink-0 items-center px-3 border border-r-0 ${prefixBorderCls} bg-gray-50 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded-l-md text-sm`, children: prefix }),
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1", children: [
|
|
211
|
+
icon && iconSide === "left" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-y-0 left-0 z-10 flex items-center pl-3 text-gray-400 dark:text-gray-500", children: icon }),
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { id: inputId, className: inputCls, type, ...props }),
|
|
213
|
+
icon && iconSide === "right" && !showClear && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-y-0 right-0 z-10 flex items-center pr-3 text-gray-400 dark:text-gray-500", children: icon }),
|
|
214
|
+
showClear && /* @__PURE__ */ jsxRuntime.jsx(
|
|
215
|
+
"button",
|
|
216
|
+
{
|
|
217
|
+
type: "button",
|
|
218
|
+
onClick: onClear,
|
|
219
|
+
tabIndex: -1,
|
|
220
|
+
"aria-label": "Limpiar",
|
|
221
|
+
className: "absolute inset-y-0 right-0 z-10 flex items-center pr-3 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300",
|
|
222
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { className: "w-4 h-4" })
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] }),
|
|
226
|
+
suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `inline-flex shrink-0 items-center px-3 border border-l-0 ${prefixBorderCls} bg-gray-50 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded-r-md text-sm`, children: suffix })
|
|
146
227
|
] }),
|
|
147
228
|
errorNode,
|
|
148
229
|
helperNode
|
|
149
230
|
] });
|
|
150
231
|
};
|
|
232
|
+
var SIZE_CLASSES2 = {
|
|
233
|
+
small: "px-2 py-1 text-xs",
|
|
234
|
+
medium: "px-3 py-2 text-sm",
|
|
235
|
+
large: "px-4 py-3 text-base"
|
|
236
|
+
};
|
|
237
|
+
var VARIANT_CLASSES2 = {
|
|
238
|
+
default: "border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",
|
|
239
|
+
outline: "border-2 border-indigo-300 dark:border-indigo-600 bg-transparent",
|
|
240
|
+
filled: "border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700",
|
|
241
|
+
minimal: "border-0 border-b border-gray-300 dark:border-gray-600 bg-transparent rounded-none focus:ring-0"
|
|
242
|
+
};
|
|
243
|
+
var RESIZE_CLASSES = {
|
|
244
|
+
vertical: "resize-y",
|
|
245
|
+
horizontal: "resize-x",
|
|
246
|
+
both: "resize",
|
|
247
|
+
none: "resize-none"
|
|
248
|
+
};
|
|
151
249
|
var TextArea = ({
|
|
152
250
|
label,
|
|
153
251
|
error,
|
|
154
252
|
helperText,
|
|
155
253
|
variant = "default",
|
|
156
254
|
size = "medium",
|
|
255
|
+
autoResize = false,
|
|
256
|
+
showCount = false,
|
|
257
|
+
resize = "vertical",
|
|
157
258
|
className = "",
|
|
158
259
|
id,
|
|
260
|
+
onInput: propsOnInput,
|
|
159
261
|
...props
|
|
160
262
|
}) => {
|
|
161
263
|
const textAreaId = id || `textarea-${Math.random().toString(36).substring(2, 9)}`;
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
264
|
+
const textareaRef = react.useRef(null);
|
|
265
|
+
const adjustHeight = () => {
|
|
266
|
+
const el = textareaRef.current;
|
|
267
|
+
if (!el) return;
|
|
268
|
+
el.style.height = "auto";
|
|
269
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
166
270
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
271
|
+
react.useEffect(() => {
|
|
272
|
+
if (autoResize) adjustHeight();
|
|
273
|
+
}, [autoResize, props.value]);
|
|
274
|
+
const handleInput = (e) => {
|
|
275
|
+
if (autoResize) adjustHeight();
|
|
276
|
+
propsOnInput?.(e);
|
|
172
277
|
};
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
const
|
|
278
|
+
const baseCls = "appearance-none relative block w-full placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white rounded-md border focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:border-indigo-500 focus:z-10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200";
|
|
279
|
+
const errorCls = error ? "border-red-300 dark:border-red-600 focus:ring-red-500 dark:focus:ring-red-400 focus:border-red-500" : "";
|
|
280
|
+
const resizeCls = autoResize ? "resize-none overflow-hidden" : RESIZE_CLASSES[resize];
|
|
281
|
+
const classes = [baseCls, SIZE_CLASSES2[size], VARIANT_CLASSES2[variant], errorCls, resizeCls, className].filter(Boolean).join(" ");
|
|
282
|
+
const maxLength = typeof props.maxLength === "number" ? props.maxLength : void 0;
|
|
283
|
+
const currentLength = typeof props.value === "string" ? props.value.length : typeof props.value === "number" ? String(props.value).length : 0;
|
|
284
|
+
const overLimit = maxLength !== void 0 && currentLength > maxLength;
|
|
176
285
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 w-full", children: [
|
|
177
|
-
label
|
|
178
|
-
"label",
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
) : label,
|
|
286
|
+
(label || showCount) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-2", children: [
|
|
287
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: label && (typeof label === "string" ? /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: textAreaId, className: "block text-sm font-medium text-gray-700 dark:text-gray-300", children: [
|
|
288
|
+
label,
|
|
289
|
+
props.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", "aria-hidden": "true", children: "*" })
|
|
290
|
+
] }) : label) }),
|
|
291
|
+
showCount && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `text-xs shrink-0 tabular-nums ${overLimit ? "text-red-500" : "text-gray-400 dark:text-gray-500"}`, children: maxLength ? `${currentLength} / ${maxLength}` : currentLength })
|
|
292
|
+
] }),
|
|
185
293
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
186
294
|
"textarea",
|
|
187
295
|
{
|
|
296
|
+
ref: textareaRef,
|
|
188
297
|
id: textAreaId,
|
|
189
298
|
className: classes,
|
|
299
|
+
onInput: handleInput,
|
|
190
300
|
...props
|
|
191
301
|
}
|
|
192
302
|
),
|
|
@@ -194,84 +304,153 @@ var TextArea = ({
|
|
|
194
304
|
helperText && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: helperText })
|
|
195
305
|
] });
|
|
196
306
|
};
|
|
307
|
+
var SIZE_CLASSES3 = {
|
|
308
|
+
sm: "py-1.5 text-xs",
|
|
309
|
+
md: "py-2 text-sm",
|
|
310
|
+
lg: "py-2.5 text-base"
|
|
311
|
+
};
|
|
312
|
+
var VARIANT_CLASSES3 = {
|
|
313
|
+
default: "border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",
|
|
314
|
+
outline: "border-2 border-indigo-300 dark:border-indigo-600 bg-transparent",
|
|
315
|
+
filled: "border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700",
|
|
316
|
+
minimal: "border-0 border-b border-gray-300 dark:border-gray-600 bg-transparent rounded-none focus:ring-0",
|
|
317
|
+
custom: ""
|
|
318
|
+
};
|
|
197
319
|
var Select = ({
|
|
198
320
|
options,
|
|
199
321
|
placeholder,
|
|
200
322
|
variant = "default",
|
|
323
|
+
size = "md",
|
|
201
324
|
error = false,
|
|
202
325
|
helperText,
|
|
203
326
|
label,
|
|
327
|
+
icon,
|
|
204
328
|
className = "",
|
|
205
329
|
id,
|
|
206
330
|
...props
|
|
207
331
|
}) => {
|
|
208
332
|
const selectId = id || `select-${Math.random().toString(36).substring(2, 9)}`;
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
333
|
+
const effectiveSize = variant === "small" ? "sm" : size;
|
|
334
|
+
const effectiveVariant = variant === "small" ? "default" : variant;
|
|
335
|
+
const hasError = Boolean(error);
|
|
336
|
+
const errorMsg = typeof error === "string" ? error : "";
|
|
337
|
+
const computedDefaultValue = props.value === void 0 && props.defaultValue === void 0 ? options.find((o) => o.selected)?.value?.toString() : void 0;
|
|
338
|
+
const baseCls = "appearance-none relative block w-full pl-3 pr-9 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:border-indigo-500 focus:z-10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200";
|
|
339
|
+
const errorCls = hasError ? "border-red-300 dark:border-red-600 focus:ring-red-500 dark:focus:ring-red-400 focus:border-red-500" : "";
|
|
340
|
+
const selectCls = [
|
|
341
|
+
baseCls,
|
|
342
|
+
SIZE_CLASSES3[effectiveSize],
|
|
343
|
+
VARIANT_CLASSES3[effectiveVariant],
|
|
344
|
+
errorCls,
|
|
345
|
+
icon ? "pl-9" : "",
|
|
346
|
+
className
|
|
347
|
+
].filter(Boolean).join(" ");
|
|
220
348
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 w-full", children: [
|
|
221
|
-
label && typeof label === "string" ? /* @__PURE__ */ jsxRuntime.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
349
|
+
label && (typeof label === "string" ? /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: selectId, className: "block text-sm font-medium text-gray-700 dark:text-gray-300", children: [
|
|
350
|
+
label,
|
|
351
|
+
props.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", "aria-hidden": "true", children: "*" })
|
|
352
|
+
] }) : label),
|
|
353
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
354
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-y-0 left-0 z-10 flex items-center pl-3 text-gray-400 dark:text-gray-500", children: icon }),
|
|
355
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
356
|
+
"select",
|
|
226
357
|
{
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
children:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
358
|
+
id: selectId,
|
|
359
|
+
className: selectCls,
|
|
360
|
+
defaultValue: computedDefaultValue,
|
|
361
|
+
...props,
|
|
362
|
+
children: [
|
|
363
|
+
placeholder && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, className: "bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400", children: placeholder }),
|
|
364
|
+
options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
365
|
+
"option",
|
|
366
|
+
{
|
|
367
|
+
value: option.value,
|
|
368
|
+
disabled: option.disabled,
|
|
369
|
+
className: `bg-white dark:bg-gray-800 text-gray-900 dark:text-white${option.disabled ? " opacity-50" : ""}`,
|
|
370
|
+
children: option.label
|
|
371
|
+
},
|
|
372
|
+
option.value
|
|
373
|
+
))
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
),
|
|
377
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2.5 text-gray-400 dark:text-gray-500", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, { className: "w-4 h-4" }) })
|
|
235
378
|
] }),
|
|
236
|
-
|
|
379
|
+
errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600 dark:text-red-400", role: "alert", children: errorMsg }),
|
|
380
|
+
helperText && !errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `text-sm ${hasError ? "text-red-600 dark:text-red-400" : "text-gray-500 dark:text-gray-400"}`, children: helperText })
|
|
237
381
|
] });
|
|
238
382
|
};
|
|
383
|
+
var SIZE_CLASS = {
|
|
384
|
+
sm: "max-w-sm",
|
|
385
|
+
md: "max-w-md",
|
|
386
|
+
lg: "max-w-2xl",
|
|
387
|
+
xl: "max-w-4xl",
|
|
388
|
+
full: "max-w-[95vw] w-[95vw]"
|
|
389
|
+
};
|
|
390
|
+
var VARIANT_HEADER = {
|
|
391
|
+
default: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",
|
|
392
|
+
danger: "bg-red-50 dark:bg-red-900/30 border-b border-red-200 dark:border-red-800",
|
|
393
|
+
success: "bg-green-50 dark:bg-green-900/30 border-b border-green-200 dark:border-green-800",
|
|
394
|
+
warning: "bg-yellow-50 dark:bg-yellow-900/30 border-b border-yellow-200 dark:border-yellow-800"
|
|
395
|
+
};
|
|
396
|
+
var VARIANT_TITLE = {
|
|
397
|
+
default: "text-gray-900 dark:text-white",
|
|
398
|
+
danger: "text-red-700 dark:text-red-300",
|
|
399
|
+
success: "text-green-700 dark:text-green-300",
|
|
400
|
+
warning: "text-yellow-700 dark:text-yellow-300"
|
|
401
|
+
};
|
|
239
402
|
var Modal = react.forwardRef(({
|
|
240
403
|
onClose,
|
|
241
404
|
title,
|
|
242
405
|
children,
|
|
243
406
|
footer,
|
|
244
|
-
maxWidth
|
|
407
|
+
maxWidth,
|
|
408
|
+
size,
|
|
245
409
|
showCloseButton = true,
|
|
246
|
-
zIndex = 50
|
|
410
|
+
zIndex = 50,
|
|
411
|
+
closeOnBackdrop = false,
|
|
412
|
+
closeOnEsc = false,
|
|
413
|
+
variant = "default"
|
|
247
414
|
}, ref) => {
|
|
248
415
|
const [show, setShow] = react.useState(false);
|
|
416
|
+
const handleCloseRef = react.useRef(() => {
|
|
417
|
+
});
|
|
418
|
+
const handleClose = () => {
|
|
419
|
+
setShow(false);
|
|
420
|
+
setTimeout(() => onClose(), 300);
|
|
421
|
+
};
|
|
422
|
+
handleCloseRef.current = handleClose;
|
|
249
423
|
react.useEffect(() => {
|
|
250
424
|
setShow(true);
|
|
251
425
|
}, []);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
426
|
+
react.useEffect(() => {
|
|
427
|
+
if (!closeOnEsc) return;
|
|
428
|
+
const handler = (e) => {
|
|
429
|
+
if (e.key === "Escape") handleCloseRef.current();
|
|
430
|
+
};
|
|
431
|
+
document.addEventListener("keydown", handler);
|
|
432
|
+
return () => document.removeEventListener("keydown", handler);
|
|
433
|
+
}, [closeOnEsc]);
|
|
434
|
+
react.useImperativeHandle(ref, () => ({ handleClose }));
|
|
435
|
+
const widthCls = size ? SIZE_CLASS[size] : maxWidth ?? "max-w-2xl";
|
|
436
|
+
const handleBackdropClick = (e) => {
|
|
437
|
+
if (closeOnBackdrop && e.target === e.currentTarget) handleClose();
|
|
257
438
|
};
|
|
258
|
-
react.useImperativeHandle(ref, () => ({
|
|
259
|
-
handleClose
|
|
260
|
-
}));
|
|
261
439
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
262
440
|
"dialog",
|
|
263
441
|
{
|
|
264
442
|
open: show,
|
|
265
|
-
className: `fixed inset-0 w-full h-full flex items-center justify-center p-4
|
|
443
|
+
className: `fixed inset-0 w-full h-full flex items-center justify-center p-4 transition-opacity duration-300 bg-gray-900/60 backdrop-blur-sm ${show ? "opacity-100" : "opacity-0"}`,
|
|
266
444
|
style: { zIndex: zIndex - 10 },
|
|
445
|
+
onClick: handleBackdropClick,
|
|
267
446
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
268
447
|
"article",
|
|
269
448
|
{
|
|
270
|
-
className: `relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-2xl w-full ${
|
|
449
|
+
className: `relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-2xl w-full ${widthCls} max-h-[90vh] flex flex-col overflow-hidden`,
|
|
271
450
|
style: { zIndex },
|
|
272
451
|
children: [
|
|
273
|
-
/* @__PURE__ */ jsxRuntime.jsxs("header", { className:
|
|
274
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { className:
|
|
452
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: `shrink-0 px-6 py-4 flex items-center justify-between ${VARIANT_HEADER[variant]}`, children: [
|
|
453
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: `text-2xl font-bold ${VARIANT_TITLE[variant]}`, children: title }),
|
|
275
454
|
showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
276
455
|
Button,
|
|
277
456
|
{
|