@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
129 lines (128 loc) • 6.3 kB
JavaScript
;
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__, {
NextAdmin: ()=>NextAdmin
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_lodash_merge_namespaceObject = require("lodash.merge");
var external_lodash_merge_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_merge_namespaceObject);
const jsonSchema_js_namespaceObject = require("../utils/jsonSchema.js");
const options_js_namespaceObject = require("../utils/options.js");
const external_Dashboard_js_namespaceObject = require("./Dashboard.js");
var external_Dashboard_js_default = /*#__PURE__*/ __webpack_require__.n(external_Dashboard_js_namespaceObject);
const external_Form_js_namespaceObject = require("./Form.js");
var external_Form_js_default = /*#__PURE__*/ __webpack_require__.n(external_Form_js_namespaceObject);
const external_List_js_namespaceObject = require("./List.js");
var external_List_js_default = /*#__PURE__*/ __webpack_require__.n(external_List_js_namespaceObject);
const external_MainLayout_js_namespaceObject = require("./MainLayout.js");
function NextAdmin({ basePath, apiBasePath, data, resource, schema, resources, slug, total, dashboard, validation, isAppDir, options, resourcesTitles, resourcesIdProperty, customInputs: customInputsProp, dialogComponents: dialogComponentsProp, customPages, actions, translations, locale, title, sidebar, resourcesIcons, user, externalLinks, pageLoader, rawData, relationshipsRawData, listFilterOptions }) {
if (!isAppDir && !options) throw new Error("You must provide the options prop when using next-admin with page router");
let mergedActions = external_lodash_merge_default()(actions ?? [], resource ? options?.model?.[resource]?.actions : []);
const modelSchema = resource && schema ? (0, jsonSchema_js_namespaceObject.getSchemaForResource)(schema, resource) : void 0;
const resourceTitle = resourcesTitles?.[resource] ?? resource;
const resourceIcon = resourcesIcons?.[resource];
const dialogComponents = resource ? isAppDir ? dialogComponentsProp : (0, options_js_namespaceObject.getClientActionsComponents)(resource, options) : void 0;
const renderMainComponent = ()=>{
if (Array.isArray(data) && resource && void 0 !== total) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_List_js_default(), {
resource: resource,
data: data,
total: total,
title: resourceTitle,
resourcesIdProperty: resourcesIdProperty,
actions: mergedActions,
icon: resourceIcon,
schema: schema,
clientActionsComponents: dialogComponents,
rawData: rawData,
listFilterOptions: listFilterOptions
}, resource);
if (data && !Array.isArray(data) || modelSchema && !data) {
const customInputs = isAppDir ? customInputsProp : (0, options_js_namespaceObject.getCustomInputs)(resource, options);
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Form_js_default(), {
data: data,
slug: slug,
schema: modelSchema,
resource: resource,
validation: validation,
title: resourceTitle,
customInputs: customInputs,
actions: mergedActions,
icon: resourceIcon,
resourcesIdProperty: resourcesIdProperty,
clientActionsComponents: dialogComponents,
relationshipsRawData: relationshipsRawData
});
}
if (resources) {
if (dashboard && "function" == typeof dashboard) return dashboard();
return dashboard || /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Dashboard_js_default(), {
resources: resources
});
}
};
const titleElement = isAppDir ? title : options?.title;
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
children: [
pageLoader,
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_MainLayout_js_namespaceObject.MainLayout, {
resource: resource,
resources: resources,
resourcesTitles: resourcesTitles,
customPages: customPages,
basePath: basePath,
apiBasePath: apiBasePath,
isAppDir: isAppDir,
translations: translations,
locale: locale,
title: titleElement,
sidebar: sidebar,
resourcesIcons: resourcesIcons,
user: user,
externalLinks: externalLinks,
options: options,
resourcesIdProperty: resourcesIdProperty,
schema: schema,
children: renderMainComponent()
})
]
});
}
exports.NextAdmin = __webpack_exports__.NextAdmin;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"NextAdmin"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});