@marcoschwartz/lite-ui 0.18.1 → 0.19.0

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.d.mts CHANGED
@@ -220,8 +220,9 @@ interface TableProps<T = any> {
220
220
  striped?: boolean;
221
221
  hoverable?: boolean;
222
222
  className?: string;
223
+ responsive?: boolean;
223
224
  }
224
- declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
225
+ declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, responsive, }: TableProps<T>): react_jsx_runtime.JSX.Element;
225
226
 
226
227
  interface PaginationProps {
227
228
  currentPage: number;
package/dist/index.d.ts CHANGED
@@ -220,8 +220,9 @@ interface TableProps<T = any> {
220
220
  striped?: boolean;
221
221
  hoverable?: boolean;
222
222
  className?: string;
223
+ responsive?: boolean;
223
224
  }
224
- declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
225
+ declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, responsive, }: TableProps<T>): react_jsx_runtime.JSX.Element;
225
226
 
226
227
  interface PaginationProps {
227
228
  currentPage: number;
package/dist/index.js CHANGED
@@ -2078,49 +2078,79 @@ function Table({
2078
2078
  keyField = "id",
2079
2079
  striped = false,
2080
2080
  hoverable = true,
2081
- className = ""
2081
+ className = "",
2082
+ responsive = true
2082
2083
  }) {
2083
2084
  const { theme } = useTheme();
2084
- return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: `overflow-x-auto ${className}`, children: [
2085
- /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("table", { className: "w-full text-left", children: [
2086
- /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("thead", { className: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("tr", { children: columns.map((column, colIndex) => {
2087
- const isLast = colIndex === columns.length - 1;
2088
- return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
2089
- "th",
2090
- {
2091
- className: isLast ? "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider relative" : "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider",
2092
- style: { width: column.width },
2093
- children: column.title
2094
- },
2095
- column.key
2096
- );
2097
- }) }) }),
2098
- /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("tbody", { className: "bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700", children: data.map((row, rowIndex) => {
2099
- const rowClasses = [
2100
- striped && rowIndex % 2 === 1 ? "bg-gray-50 dark:bg-gray-800/50" : "",
2101
- hoverable ? "hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" : ""
2085
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
2086
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: `${responsive ? "hidden md:block" : ""} overflow-x-auto ${className}`, children: [
2087
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("table", { className: "w-full text-left", children: [
2088
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("thead", { className: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("tr", { children: columns.map((column, colIndex) => {
2089
+ const isLast = colIndex === columns.length - 1;
2090
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
2091
+ "th",
2092
+ {
2093
+ className: isLast ? "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider relative" : "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider",
2094
+ style: { width: column.width },
2095
+ children: column.title
2096
+ },
2097
+ column.key
2098
+ );
2099
+ }) }) }),
2100
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("tbody", { className: "bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700", children: data.map((row, rowIndex) => {
2101
+ const rowClasses = [
2102
+ striped && rowIndex % 2 === 1 ? "bg-gray-50 dark:bg-gray-800/50" : "",
2103
+ hoverable ? "hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" : ""
2104
+ ].filter(Boolean).join(" ");
2105
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
2106
+ "tr",
2107
+ {
2108
+ className: rowClasses,
2109
+ children: columns.map((column, colIndex) => {
2110
+ const isLast = colIndex === columns.length - 1;
2111
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
2112
+ "td",
2113
+ {
2114
+ className: isLast ? "px-6 py-4 text-sm text-gray-900 dark:text-gray-100 overflow-visible" : "px-6 py-4 text-sm text-gray-900 dark:text-gray-100",
2115
+ children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key]
2116
+ },
2117
+ column.key
2118
+ );
2119
+ })
2120
+ },
2121
+ row[keyField] || rowIndex
2122
+ );
2123
+ }) })
2124
+ ] }),
2125
+ data.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
2126
+ ] }),
2127
+ responsive && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: `md:hidden space-y-4 ${className}`, children: [
2128
+ data.map((row, rowIndex) => {
2129
+ const cardClasses = [
2130
+ "bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-4 shadow-sm",
2131
+ hoverable ? "hover:shadow-md transition-shadow" : ""
2102
2132
  ].filter(Boolean).join(" ");
2103
2133
  return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
2104
- "tr",
2134
+ "div",
2105
2135
  {
2106
- className: rowClasses,
2107
- children: columns.map((column, colIndex) => {
2108
- const isLast = colIndex === columns.length - 1;
2109
- return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
2110
- "td",
2111
- {
2112
- className: isLast ? "px-6 py-4 text-sm text-gray-900 dark:text-gray-100 overflow-visible" : "px-6 py-4 text-sm text-gray-900 dark:text-gray-100",
2113
- children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key]
2114
- },
2115
- column.key
2116
- );
2117
- })
2136
+ className: cardClasses,
2137
+ children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
2138
+ "div",
2139
+ {
2140
+ className: "flex justify-between items-start py-2 border-b border-gray-100 dark:border-gray-800 last:border-b-0",
2141
+ children: [
2142
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider flex-shrink-0 mr-4", children: column.title }),
2143
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "text-sm text-gray-900 dark:text-gray-100 text-right", children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key] })
2144
+ ]
2145
+ },
2146
+ column.key
2147
+ ))
2118
2148
  },
2119
2149
  row[keyField] || rowIndex
2120
2150
  );
2121
- }) })
2122
- ] }),
2123
- data.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
2151
+ }),
2152
+ data.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
2153
+ ] })
2124
2154
  ] });
2125
2155
  }
2126
2156