UNPKG

@premieroctet/next-admin

Version:

Next-Admin provides a customizable and turnkey admin dashboard for applications built with Next.js and powered by the Prisma ORM. It aims to simplify the development process by providing a turnkey admin system that can be easily integrated into your proje

148 lines (147 loc) 8.11 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.n = (module)=>{ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module; __webpack_require__.d(getter, { a: getter }); return getter; }; })(); (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { default: ()=>Cell }); const jsx_runtime_namespaceObject = require("react/jsx-runtime"); const external_react_namespaceObject = require("react"); var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject); const external_clsx_namespaceObject = require("clsx"); var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject); const Link_js_namespaceObject = require("./common/Link.js"); var Link_js_default = /*#__PURE__*/ __webpack_require__.n(Link_js_namespaceObject); const ConfigContext_js_namespaceObject = require("../context/ConfigContext.js"); const tools_js_namespaceObject = require("../utils/tools.js"); const Clipboard_js_namespaceObject = require("./common/Clipboard.js"); var Clipboard_js_default = /*#__PURE__*/ __webpack_require__.n(Clipboard_js_namespaceObject); function Cell({ cell, formatter, copyable, getRawData }) { const { basePath, nextAdminContext } = (0, ConfigContext_js_namespaceObject.useConfig)(); let cellValue = cell?.__nextadmin_formatted; const renderCustomElement = (val)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "flex gap-1", children: [ val, copyable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Clipboard_js_default(), { value: (0, tools_js_namespaceObject.getDisplayedValue)(val) }) ] }); const isReactNode = (cell)=>/*#__PURE__*/ external_react_default().isValidElement(cell); if (cell && null !== cell) { if (/*#__PURE__*/ external_react_default().isValidElement(cellValue)) return renderCustomElement(cellValue); if ("object" == typeof cell && !isReactNode(cellValue)) { if (formatter) { cellValue = formatter(getRawData?.(), nextAdminContext); if (/*#__PURE__*/ external_react_default().isValidElement(cellValue)) return renderCustomElement(cellValue); } if ("link" === cell.type) { const url = cell.isOverridden ? cell.value.url : `${basePath}/${cell.value.url}`; return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Link_js_default(), { onClick: (e)=>e.stopPropagation(), href: url, className: "text-nextadmin-brand-emphasis dark:text-dark-nextadmin-brand-subtle hover:text-nextadmin-brand-emphasis dark:hover:text-dark-nextadmin-brand-emphasis flex cursor-pointer items-center gap-1 font-semibold hover:underline", children: [ cellValue, copyable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Clipboard_js_default(), { value: url }) ] }); } if ("count" === cell.type) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", { className: "bg-nextadmin-background-subtle dark:bg-dark-nextadmin-background-subtle text-nextadmin-content-subtle dark:text-dark-nextadmin-content-subtle ring-nextadmin-border-default dark:ring-dark-nextadmin-border-strong inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset", children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", { children: cellValue }) }); if ("date" === cell.type) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "text-nextadmin-content-subtle dark:text-dark-nextadmin-content-subtle flex max-w-[20ch] items-center gap-1 overflow-hidden text-ellipsis whitespace-nowrap", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", { children: cellValue }), copyable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Clipboard_js_default(), { value: cellValue?.toString() ?? "" }) ] }); else if ("scalar" === cell.type && "string" == typeof cell.value) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "text-nextadmin-content-subtle dark:text-dark-nextadmin-content-subtle flex items-center gap-1 overflow-hidden text-ellipsis whitespace-nowrap", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", { children: cellValue }), copyable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Clipboard_js_default(), { value: cellValue?.toString() ?? "" }) ] }); else if ("scalar" === cell.type && "number" == typeof cell.value) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "text-nextadmin-content-subtle dark:text-dark-nextadmin-content-subtle flex max-w-[20ch] items-center gap-1 overflow-hidden text-ellipsis whitespace-nowrap", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", { children: cellValue }), copyable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Clipboard_js_default(), { value: cellValue?.toString() ?? "" }) ] }); else if ("scalar" === cell.type && "boolean" == typeof cell.value) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", { className: external_clsx_default()("inline-flex items-center rounded-md px-2 py-1 text-xs font-medium", "bg-nextadmin-background-subtle dark:bg-dark-nextadmin-background-subtle text-nextadmin-brand-subtle dark:text-dark-nextadmin-content-subtle"), children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", { children: cellValue?.toString() }) }); } return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "text-nextadmin-brand-subtle dark:text-dark-nextadmin-content-subtle flex items-center gap-1", children: [ JSON.stringify(cellValue), copyable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Clipboard_js_default(), { value: JSON.stringify(cellValue) }) ] }); } return null; } exports["default"] = __webpack_exports__["default"]; for(var __webpack_i__ in __webpack_exports__)if (-1 === [ "default" ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; Object.defineProperty(exports, '__esModule', { value: true });