neogestify-ui-components 2.2.1 → 2.2.2
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/components/html/index.d.mts +37 -4
- package/dist/components/html/index.d.ts +37 -4
- package/dist/components/html/index.js +135 -12
- package/dist/components/html/index.js.map +1 -1
- package/dist/components/html/index.mjs +135 -12
- package/dist/components/html/index.mjs.map +1 -1
- package/dist/index.js +135 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/html/Table.tsx +205 -38
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { FC, ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, FormHTMLAttributes, FormEvent, SelectHTMLAttributes } from 'react';
|
|
1
|
+
import React__default, { FC, ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, FormHTMLAttributes, FormEvent, SelectHTMLAttributes, CSSProperties } from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -51,15 +51,48 @@ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'siz
|
|
|
51
51
|
}
|
|
52
52
|
declare const Select: FC<SelectProps>;
|
|
53
53
|
|
|
54
|
+
type TableVariant = 'default' | 'striped' | 'bordered' | 'minimal' | 'custom';
|
|
55
|
+
type TableSize = 'sm' | 'md' | 'lg';
|
|
56
|
+
interface ColumnDef {
|
|
57
|
+
/** Contenido del encabezado */
|
|
58
|
+
header: ReactNode;
|
|
59
|
+
/** Clase CSS adicional para toda la columna (th + td) */
|
|
60
|
+
className?: string;
|
|
61
|
+
/** Alinear el contenido de esta columna */
|
|
62
|
+
align?: 'left' | 'center' | 'right';
|
|
63
|
+
}
|
|
54
64
|
interface TableProps {
|
|
55
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Definición de columnas con encabezado y opciones por columna.
|
|
67
|
+
* Si pasas strings simples, los usa como encabezados sin configuración extra.
|
|
68
|
+
*/
|
|
69
|
+
columns: (ColumnDef | ReactNode)[];
|
|
70
|
+
/** Filas de la tabla. Cada fila es un arreglo de celdas. */
|
|
56
71
|
rows: ReactNode[][];
|
|
57
|
-
|
|
72
|
+
/** Estilo visual de la tabla. Default: 'default' */
|
|
73
|
+
variant?: TableVariant;
|
|
74
|
+
/** Tamaño de padding de celdas. Default: 'md' */
|
|
75
|
+
size?: TableSize;
|
|
76
|
+
/** Clase CSS adicional para el wrapper `<div>` externo */
|
|
58
77
|
className?: string;
|
|
78
|
+
/** Clase CSS adicional para el `<table>` */
|
|
79
|
+
tableClassName?: string;
|
|
80
|
+
/** Clase CSS adicional para cada `<th>` */
|
|
59
81
|
thClassName?: string;
|
|
82
|
+
/** Clase CSS adicional para cada `<td>` */
|
|
60
83
|
tdClassName?: string;
|
|
84
|
+
/** Clase CSS adicional para cada `<tr>` del body */
|
|
85
|
+
trClassName?: string | ((rowIndex: number) => string);
|
|
86
|
+
/** Texto o nodo a mostrar cuando `rows` está vacío */
|
|
87
|
+
emptyState?: ReactNode;
|
|
88
|
+
/** Callback al hacer click en una fila */
|
|
89
|
+
onRowClick?: (rowIndex: number) => void;
|
|
90
|
+
/** Si true, no muestra thead */
|
|
91
|
+
hideHeader?: boolean;
|
|
92
|
+
/** Estilos inline para el `<table>` */
|
|
93
|
+
style?: CSSProperties;
|
|
61
94
|
}
|
|
62
|
-
declare function Table({
|
|
95
|
+
declare function Table({ columns, rows, variant, size, className, tableClassName, thClassName, tdClassName, trClassName, emptyState, onRowClick, hideHeader, style, }: TableProps): react_jsx_runtime.JSX.Element;
|
|
63
96
|
|
|
64
97
|
interface ModalProps {
|
|
65
98
|
onClose: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { FC, ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, FormHTMLAttributes, FormEvent, SelectHTMLAttributes } from 'react';
|
|
1
|
+
import React__default, { FC, ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, FormHTMLAttributes, FormEvent, SelectHTMLAttributes, CSSProperties } from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -51,15 +51,48 @@ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'siz
|
|
|
51
51
|
}
|
|
52
52
|
declare const Select: FC<SelectProps>;
|
|
53
53
|
|
|
54
|
+
type TableVariant = 'default' | 'striped' | 'bordered' | 'minimal' | 'custom';
|
|
55
|
+
type TableSize = 'sm' | 'md' | 'lg';
|
|
56
|
+
interface ColumnDef {
|
|
57
|
+
/** Contenido del encabezado */
|
|
58
|
+
header: ReactNode;
|
|
59
|
+
/** Clase CSS adicional para toda la columna (th + td) */
|
|
60
|
+
className?: string;
|
|
61
|
+
/** Alinear el contenido de esta columna */
|
|
62
|
+
align?: 'left' | 'center' | 'right';
|
|
63
|
+
}
|
|
54
64
|
interface TableProps {
|
|
55
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Definición de columnas con encabezado y opciones por columna.
|
|
67
|
+
* Si pasas strings simples, los usa como encabezados sin configuración extra.
|
|
68
|
+
*/
|
|
69
|
+
columns: (ColumnDef | ReactNode)[];
|
|
70
|
+
/** Filas de la tabla. Cada fila es un arreglo de celdas. */
|
|
56
71
|
rows: ReactNode[][];
|
|
57
|
-
|
|
72
|
+
/** Estilo visual de la tabla. Default: 'default' */
|
|
73
|
+
variant?: TableVariant;
|
|
74
|
+
/** Tamaño de padding de celdas. Default: 'md' */
|
|
75
|
+
size?: TableSize;
|
|
76
|
+
/** Clase CSS adicional para el wrapper `<div>` externo */
|
|
58
77
|
className?: string;
|
|
78
|
+
/** Clase CSS adicional para el `<table>` */
|
|
79
|
+
tableClassName?: string;
|
|
80
|
+
/** Clase CSS adicional para cada `<th>` */
|
|
59
81
|
thClassName?: string;
|
|
82
|
+
/** Clase CSS adicional para cada `<td>` */
|
|
60
83
|
tdClassName?: string;
|
|
84
|
+
/** Clase CSS adicional para cada `<tr>` del body */
|
|
85
|
+
trClassName?: string | ((rowIndex: number) => string);
|
|
86
|
+
/** Texto o nodo a mostrar cuando `rows` está vacío */
|
|
87
|
+
emptyState?: ReactNode;
|
|
88
|
+
/** Callback al hacer click en una fila */
|
|
89
|
+
onRowClick?: (rowIndex: number) => void;
|
|
90
|
+
/** Si true, no muestra thead */
|
|
91
|
+
hideHeader?: boolean;
|
|
92
|
+
/** Estilos inline para el `<table>` */
|
|
93
|
+
style?: CSSProperties;
|
|
61
94
|
}
|
|
62
|
-
declare function Table({
|
|
95
|
+
declare function Table({ columns, rows, variant, size, className, tableClassName, thClassName, tdClassName, trClassName, emptyState, onRowClick, hideHeader, style, }: TableProps): react_jsx_runtime.JSX.Element;
|
|
63
96
|
|
|
64
97
|
interface ModalProps {
|
|
65
98
|
onClose: () => void;
|
|
@@ -261,24 +261,147 @@ var Select = ({
|
|
|
261
261
|
helperText && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `text-sm ${error ? "text-red-600 dark:text-red-400" : "text-gray-500 dark:text-gray-400"}`, children: helperText })
|
|
262
262
|
] });
|
|
263
263
|
};
|
|
264
|
+
function isColumnDef(col) {
|
|
265
|
+
return typeof col === "object" && col !== null && "header" in col;
|
|
266
|
+
}
|
|
267
|
+
function resolveColumn(col) {
|
|
268
|
+
if (isColumnDef(col)) return col;
|
|
269
|
+
return { header: col };
|
|
270
|
+
}
|
|
271
|
+
var ALIGN_CLASS = {
|
|
272
|
+
left: "text-left",
|
|
273
|
+
center: "text-center",
|
|
274
|
+
right: "text-right"
|
|
275
|
+
};
|
|
276
|
+
var SIZE_TH = {
|
|
277
|
+
sm: "px-2 py-1.5 text-xs",
|
|
278
|
+
md: "px-3 py-2.5 text-xs",
|
|
279
|
+
lg: "px-4 py-3.5 text-sm"
|
|
280
|
+
};
|
|
281
|
+
var SIZE_TD = {
|
|
282
|
+
sm: "px-2 py-1.5 text-xs",
|
|
283
|
+
md: "px-3 py-2.5 text-sm",
|
|
284
|
+
lg: "px-4 py-3.5 text-sm"
|
|
285
|
+
};
|
|
286
|
+
var VARIANT_TABLE = {
|
|
287
|
+
default: "w-full min-w-full table-auto",
|
|
288
|
+
striped: "w-full min-w-full table-auto",
|
|
289
|
+
bordered: "w-full min-w-full table-auto border border-gray-300 dark:border-gray-600",
|
|
290
|
+
minimal: "w-full min-w-full table-auto",
|
|
291
|
+
custom: "w-full min-w-full table-auto"
|
|
292
|
+
};
|
|
293
|
+
var VARIANT_THEAD = {
|
|
294
|
+
default: "bg-gray-100 dark:bg-gray-700",
|
|
295
|
+
striped: "bg-gray-100 dark:bg-gray-700",
|
|
296
|
+
bordered: "bg-gray-100 dark:bg-gray-700",
|
|
297
|
+
minimal: "",
|
|
298
|
+
custom: ""
|
|
299
|
+
};
|
|
300
|
+
var VARIANT_TH = {
|
|
301
|
+
default: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300",
|
|
302
|
+
striped: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300",
|
|
303
|
+
bordered: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300 border border-gray-300 dark:border-gray-600",
|
|
304
|
+
minimal: "font-semibold text-gray-500 dark:text-gray-400 border-b border-gray-200 dark:border-gray-700",
|
|
305
|
+
custom: ""
|
|
306
|
+
};
|
|
307
|
+
var VARIANT_TR = {
|
|
308
|
+
default: () => "bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 transition-colors",
|
|
309
|
+
striped: (i) => `${i % 2 === 0 ? "bg-white dark:bg-gray-800" : "bg-gray-50 dark:bg-gray-700/40"} hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors`,
|
|
310
|
+
bordered: () => "bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 transition-colors",
|
|
311
|
+
minimal: () => "hover:bg-gray-50 dark:hover:bg-gray-800/60 transition-colors",
|
|
312
|
+
custom: () => ""
|
|
313
|
+
};
|
|
314
|
+
var VARIANT_TD = {
|
|
315
|
+
default: "text-gray-700 dark:text-gray-300",
|
|
316
|
+
striped: "text-gray-700 dark:text-gray-300",
|
|
317
|
+
bordered: "text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700",
|
|
318
|
+
minimal: "text-gray-700 dark:text-gray-300 border-b border-gray-100 dark:border-gray-800",
|
|
319
|
+
custom: ""
|
|
320
|
+
};
|
|
321
|
+
var VARIANT_TBODY_DIVIDER = {
|
|
322
|
+
default: "divide-y divide-gray-200 dark:divide-gray-700",
|
|
323
|
+
striped: "",
|
|
324
|
+
bordered: "",
|
|
325
|
+
minimal: "",
|
|
326
|
+
custom: ""
|
|
327
|
+
};
|
|
264
328
|
function Table({
|
|
265
|
-
|
|
329
|
+
columns,
|
|
266
330
|
rows,
|
|
267
331
|
variant = "default",
|
|
332
|
+
size = "md",
|
|
268
333
|
className = "",
|
|
334
|
+
tableClassName = "",
|
|
269
335
|
thClassName = "",
|
|
270
|
-
tdClassName = ""
|
|
336
|
+
tdClassName = "",
|
|
337
|
+
trClassName,
|
|
338
|
+
emptyState,
|
|
339
|
+
onRowClick,
|
|
340
|
+
hideHeader = false,
|
|
341
|
+
style
|
|
271
342
|
}) {
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
343
|
+
const cols = columns.map(resolveColumn);
|
|
344
|
+
const resolvedTrClass = (i) => {
|
|
345
|
+
const variantCls = VARIANT_TR[variant](i);
|
|
346
|
+
const clickCls = onRowClick ? "cursor-pointer" : "";
|
|
347
|
+
const customCls = typeof trClassName === "function" ? trClassName(i) : trClassName ?? "";
|
|
348
|
+
return `${variantCls} ${clickCls} ${customCls}`.trim();
|
|
349
|
+
};
|
|
350
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `overflow-x-auto w-full ${className}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
351
|
+
"table",
|
|
352
|
+
{
|
|
353
|
+
className: `${VARIANT_TABLE[variant]} ${tableClassName}`.trim(),
|
|
354
|
+
style,
|
|
355
|
+
children: [
|
|
356
|
+
!hideHeader && /* @__PURE__ */ jsxRuntime.jsx("thead", { className: VARIANT_THEAD[variant], children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: cols.map((col, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
357
|
+
"th",
|
|
358
|
+
{
|
|
359
|
+
className: [
|
|
360
|
+
SIZE_TH[size],
|
|
361
|
+
VARIANT_TH[variant],
|
|
362
|
+
ALIGN_CLASS[col.align ?? "left"],
|
|
363
|
+
col.className ?? "",
|
|
364
|
+
thClassName
|
|
365
|
+
].filter(Boolean).join(" "),
|
|
366
|
+
children: col.header
|
|
367
|
+
},
|
|
368
|
+
i
|
|
369
|
+
)) }) }),
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: VARIANT_TBODY_DIVIDER[variant], children: rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
371
|
+
"td",
|
|
372
|
+
{
|
|
373
|
+
colSpan: cols.length,
|
|
374
|
+
className: `${SIZE_TD[size]} text-center text-gray-400 dark:text-gray-500 py-8`,
|
|
375
|
+
children: emptyState ?? "Sin datos"
|
|
376
|
+
}
|
|
377
|
+
) }) : rows.map((row, rowIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
378
|
+
"tr",
|
|
379
|
+
{
|
|
380
|
+
className: resolvedTrClass(rowIndex),
|
|
381
|
+
onClick: onRowClick ? () => onRowClick(rowIndex) : void 0,
|
|
382
|
+
children: row.map((cell, cellIndex) => {
|
|
383
|
+
const col = cols[cellIndex];
|
|
384
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
385
|
+
"td",
|
|
386
|
+
{
|
|
387
|
+
className: [
|
|
388
|
+
SIZE_TD[size],
|
|
389
|
+
VARIANT_TD[variant],
|
|
390
|
+
ALIGN_CLASS[col?.align ?? "left"],
|
|
391
|
+
col?.className ?? "",
|
|
392
|
+
tdClassName
|
|
393
|
+
].filter(Boolean).join(" "),
|
|
394
|
+
children: cell
|
|
395
|
+
},
|
|
396
|
+
cellIndex
|
|
397
|
+
);
|
|
398
|
+
})
|
|
399
|
+
},
|
|
400
|
+
rowIndex
|
|
401
|
+
)) })
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
) });
|
|
282
405
|
}
|
|
283
406
|
var Modal = react.forwardRef(({
|
|
284
407
|
onClose,
|