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

123 lines (122 loc) 5.93 kB
"use client"; "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: ()=>FormHeader }); const jsx_runtime_namespaceObject = require("react/jsx-runtime"); const outline_namespaceObject = require("@heroicons/react/24/outline"); 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 I18nContext_js_namespaceObject = require("../context/I18nContext.js"); const external_types_js_namespaceObject = require("../types.js"); const jsonSchema_js_namespaceObject = require("../utils/jsonSchema.js"); const tools_js_namespaceObject = require("../utils/tools.js"); const external_ActionsDropdown_js_namespaceObject = require("./ActionsDropdown.js"); var external_ActionsDropdown_js_default = /*#__PURE__*/ __webpack_require__.n(external_ActionsDropdown_js_namespaceObject); const external_Breadcrumb_js_namespaceObject = require("./Breadcrumb.js"); var external_Breadcrumb_js_default = /*#__PURE__*/ __webpack_require__.n(external_Breadcrumb_js_namespaceObject); const Button_js_namespaceObject = require("./radix/Button.js"); function FormHeader({ title, slug, icon, actions, resource, data, schema }) { const { t } = (0, I18nContext_js_namespaceObject.useI18n)(); const { basePath, options } = (0, ConfigContext_js_namespaceObject.useConfig)(); const modelOptions = options?.model?.[resource]; const canCreate = !modelOptions?.permissions || modelOptions?.permissions?.includes(external_types_js_namespaceObject.Permission.CREATE); const { edit, id } = (0, jsonSchema_js_namespaceObject.getSchemas)(data, schema, modelOptions?.edit?.fields); const breadcrumItems = [ { label: t(`model.${resource}.plural`, {}, title), href: `${basePath}/${(0, tools_js_namespaceObject.slugify)(resource)}`, icon }, { label: edit ? t("actions.edit.label") : t("actions.create.label"), href: `${basePath}/${(0, tools_js_namespaceObject.slugify)(resource)}/${id}`, current: !edit } ]; if (edit && id) breadcrumItems.push({ label: slug ?? id.toString(), href: `${basePath}/${(0, tools_js_namespaceObject.slugify)(resource)}/${id}`, current: true }); return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "bg-nextadmin-background-default dark:bg-dark-nextadmin-background-default dark:border-b-dark-nextadmin-border-default border-b-nextadmin-border-default sticky top-14 z-20 flex flex-row flex-wrap items-center justify-between gap-3 gap-4 border-b px-4 py-3 shadow-sm lg:top-0", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Breadcrumb_js_default(), { breadcrumbItems: breadcrumItems }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "flex items-center gap-2", children: [ !!actions && actions.length > 0 && !!id && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ActionsDropdown_js_default(), { actions: actions, resource: resource, selectedIds: [ id ], selectedCount: 1 }), canCreate && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Link_js_default(), { href: `${basePath}/${(0, tools_js_namespaceObject.slugify)(resource)}/new`, role: "button", "data-testid": "add-new-button", className: (0, Button_js_namespaceObject.buttonVariants)({ variant: "default", size: "sm" }), children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", { children: t("list.header.add.label") }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(outline_namespaceObject.PlusSmallIcon, { className: "ml-2 h-5 w-5", "aria-hidden": "true" }) ] }) ] }) ] }); } 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 });