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/index.mjs CHANGED
@@ -647,24 +647,147 @@ var Select = ({
647
647
  helperText && /* @__PURE__ */ jsx("p", { className: `text-sm ${error ? "text-red-600 dark:text-red-400" : "text-gray-500 dark:text-gray-400"}`, children: helperText })
648
648
  ] });
649
649
  };
650
+ function isColumnDef(col) {
651
+ return typeof col === "object" && col !== null && "header" in col;
652
+ }
653
+ function resolveColumn(col) {
654
+ if (isColumnDef(col)) return col;
655
+ return { header: col };
656
+ }
657
+ var ALIGN_CLASS = {
658
+ left: "text-left",
659
+ center: "text-center",
660
+ right: "text-right"
661
+ };
662
+ var SIZE_TH = {
663
+ sm: "px-2 py-1.5 text-xs",
664
+ md: "px-3 py-2.5 text-xs",
665
+ lg: "px-4 py-3.5 text-sm"
666
+ };
667
+ var SIZE_TD = {
668
+ sm: "px-2 py-1.5 text-xs",
669
+ md: "px-3 py-2.5 text-sm",
670
+ lg: "px-4 py-3.5 text-sm"
671
+ };
672
+ var VARIANT_TABLE = {
673
+ default: "w-full min-w-full table-auto",
674
+ striped: "w-full min-w-full table-auto",
675
+ bordered: "w-full min-w-full table-auto border border-gray-300 dark:border-gray-600",
676
+ minimal: "w-full min-w-full table-auto",
677
+ custom: "w-full min-w-full table-auto"
678
+ };
679
+ var VARIANT_THEAD = {
680
+ default: "bg-gray-100 dark:bg-gray-700",
681
+ striped: "bg-gray-100 dark:bg-gray-700",
682
+ bordered: "bg-gray-100 dark:bg-gray-700",
683
+ minimal: "",
684
+ custom: ""
685
+ };
686
+ var VARIANT_TH = {
687
+ default: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300",
688
+ striped: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300",
689
+ bordered: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300 border border-gray-300 dark:border-gray-600",
690
+ minimal: "font-semibold text-gray-500 dark:text-gray-400 border-b border-gray-200 dark:border-gray-700",
691
+ custom: ""
692
+ };
693
+ var VARIANT_TR = {
694
+ default: () => "bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 transition-colors",
695
+ 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`,
696
+ bordered: () => "bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 transition-colors",
697
+ minimal: () => "hover:bg-gray-50 dark:hover:bg-gray-800/60 transition-colors",
698
+ custom: () => ""
699
+ };
700
+ var VARIANT_TD = {
701
+ default: "text-gray-700 dark:text-gray-300",
702
+ striped: "text-gray-700 dark:text-gray-300",
703
+ bordered: "text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700",
704
+ minimal: "text-gray-700 dark:text-gray-300 border-b border-gray-100 dark:border-gray-800",
705
+ custom: ""
706
+ };
707
+ var VARIANT_TBODY_DIVIDER = {
708
+ default: "divide-y divide-gray-200 dark:divide-gray-700",
709
+ striped: "",
710
+ bordered: "",
711
+ minimal: "",
712
+ custom: ""
713
+ };
650
714
  function Table({
651
- headers,
715
+ columns,
652
716
  rows,
653
717
  variant = "default",
718
+ size = "md",
654
719
  className = "",
720
+ tableClassName = "",
655
721
  thClassName = "",
656
- tdClassName = ""
722
+ tdClassName = "",
723
+ trClassName,
724
+ emptyState,
725
+ onRowClick,
726
+ hideHeader = false,
727
+ style
657
728
  }) {
658
- const baseTableClass = variant === "default" ? "w-full table-auto border-collapse border border-gray-300 dark:border-gray-600 min-w-full" : "";
659
- const baseThClass = variant === "default" ? "border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-gray-900 dark:text-white" : "";
660
- const baseTdClass = variant === "default" ? "border border-gray-300 dark:border-gray-600 px-4 py-2 text-gray-900 dark:text-white" : "";
661
- const tableClass = `${baseTableClass} ${className}`.trim();
662
- const thClass = `${baseThClass} ${thClassName}`.trim();
663
- const tdClass = `${baseTdClass} ${tdClassName}`.trim();
664
- return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto w-full", children: /* @__PURE__ */ jsxs("table", { className: tableClass, children: [
665
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: variant === "default" ? "bg-gray-100 dark:bg-gray-700" : "", children: headers.map((header, index) => /* @__PURE__ */ jsx("th", { className: thClass, children: header }, index)) }) }),
666
- /* @__PURE__ */ jsx("tbody", { children: rows.map((row, rowIndex) => /* @__PURE__ */ jsx("tr", { className: variant === "default" ? "hover:bg-gray-50 dark:hover:bg-gray-600" : "", children: row.map((cell, cellIndex) => /* @__PURE__ */ jsx("td", { className: tdClass, children: cell }, cellIndex)) }, rowIndex)) })
667
- ] }) });
729
+ const cols = columns.map(resolveColumn);
730
+ const resolvedTrClass = (i) => {
731
+ const variantCls = VARIANT_TR[variant](i);
732
+ const clickCls = onRowClick ? "cursor-pointer" : "";
733
+ const customCls = typeof trClassName === "function" ? trClassName(i) : trClassName ?? "";
734
+ return `${variantCls} ${clickCls} ${customCls}`.trim();
735
+ };
736
+ return /* @__PURE__ */ jsx("div", { className: `overflow-x-auto w-full ${className}`.trim(), children: /* @__PURE__ */ jsxs(
737
+ "table",
738
+ {
739
+ className: `${VARIANT_TABLE[variant]} ${tableClassName}`.trim(),
740
+ style,
741
+ children: [
742
+ !hideHeader && /* @__PURE__ */ jsx("thead", { className: VARIANT_THEAD[variant], children: /* @__PURE__ */ jsx("tr", { children: cols.map((col, i) => /* @__PURE__ */ jsx(
743
+ "th",
744
+ {
745
+ className: [
746
+ SIZE_TH[size],
747
+ VARIANT_TH[variant],
748
+ ALIGN_CLASS[col.align ?? "left"],
749
+ col.className ?? "",
750
+ thClassName
751
+ ].filter(Boolean).join(" "),
752
+ children: col.header
753
+ },
754
+ i
755
+ )) }) }),
756
+ /* @__PURE__ */ jsx("tbody", { className: VARIANT_TBODY_DIVIDER[variant], children: rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
757
+ "td",
758
+ {
759
+ colSpan: cols.length,
760
+ className: `${SIZE_TD[size]} text-center text-gray-400 dark:text-gray-500 py-8`,
761
+ children: emptyState ?? "Sin datos"
762
+ }
763
+ ) }) : rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
764
+ "tr",
765
+ {
766
+ className: resolvedTrClass(rowIndex),
767
+ onClick: onRowClick ? () => onRowClick(rowIndex) : void 0,
768
+ children: row.map((cell, cellIndex) => {
769
+ const col = cols[cellIndex];
770
+ return /* @__PURE__ */ jsx(
771
+ "td",
772
+ {
773
+ className: [
774
+ SIZE_TD[size],
775
+ VARIANT_TD[variant],
776
+ ALIGN_CLASS[col?.align ?? "left"],
777
+ col?.className ?? "",
778
+ tdClassName
779
+ ].filter(Boolean).join(" "),
780
+ children: cell
781
+ },
782
+ cellIndex
783
+ );
784
+ })
785
+ },
786
+ rowIndex
787
+ )) })
788
+ ]
789
+ }
790
+ ) });
668
791
  }
669
792
  var Modal = forwardRef(({
670
793
  onClose,