UNPKG

nextjs-table

Version:

Modern, customizable data table component for Next.js with CRUD operations

103 lines (84 loc) 5.04 kB
import { jsx } from 'react/jsx-runtime'; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; 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} function Table$1(_a) { var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]); return (jsx("div", { className: "overflow-x-auto", children: jsx("table", __assign({ className: clsx("min-w-full divide-y divide-gray-200", className) }, props, { children: children })) })); } function TableHeader(_a) { var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]); return (jsx("thead", __assign({ className: clsx("bg-gray-50", className) }, props, { children: children }))); } function TableBody(_a) { var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]); return (jsx("tbody", __assign({ className: clsx("bg-white divide-y divide-gray-200", className) }, props, { children: children }))); } function TableFooter(_a) { var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]); return (jsx("tfoot", __assign({ className: clsx("bg-gray-50", className) }, props, { children: children }))); } function TableRow(_a) { var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]); return (jsx("tr", __assign({ className: clsx("hover:bg-gray-50 transition-colors duration-200", className) }, props, { children: children }))); } function TableHeaderCell(_a) { var children = _a.children, className = _a.className, props = __rest(_a, ["children", "className"]); return (jsx("th", __assign({ className: clsx("px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider", className) }, props, { children: children }))); } function TableCell(_a) { var children = _a.children, className = _a.className, colSpan = _a.colSpan, props = __rest(_a, ["children", "className", "colSpan"]); return (jsx("td", __assign({ className: clsx("px-6 py-4 whitespace-nowrap text-sm text-gray-900", className), colSpan: colSpan }, props, { children: children }))); } function TableEmpty(_a) { var colSpan = _a.colSpan, children = _a.children, className = _a.className; return (jsx(TableRow, { children: jsx(TableCell, { colSpan: colSpan, className: clsx("text-center text-gray-500", className), children: children }) })); } // Compound Component Pattern var Table = Object.assign(Table$1, { Header: TableHeader, Body: TableBody, Footer: TableFooter, Row: TableRow, HeaderCell: TableHeaderCell, Cell: TableCell, Empty: TableEmpty, }); export { Table, TableBody, TableCell, TableEmpty, TableFooter, TableHeader, TableHeaderCell, TableRow, Table as default }; //# sourceMappingURL=index.esm.js.map