@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
97 lines (96 loc) • 3.9 kB
JavaScript
"use client";
;
var __webpack_require__ = {};
(()=>{
__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__, {
NextAdminRouterAdapter: ()=>NextAdminRouterAdapter,
useNextRouter: ()=>useNextRouter,
NextAdmin: ()=>NextAdmin,
MainLayout: ()=>MainLayout
});
const navigation_namespaceObject = require("next/navigation");
const router_namespaceObject = require("next/router");
const ConfigContext_js_namespaceObject = require("../context/ConfigContext.js");
const external_context_js_namespaceObject = require("./context.js");
const external_components_js_namespaceObject = require("./components.js");
const useNextRouter = ()=>{
const { isAppDir } = (0, ConfigContext_js_namespaceObject.useConfig)();
const router = isAppDir ? (0, navigation_namespaceObject.useRouter)() : (0, router_namespaceObject.useRouter)();
const query = isAppDir ? (0, navigation_namespaceObject.useSearchParams)() : "undefined" != typeof window ? new URLSearchParams(location.search) : new URLSearchParams(router.query);
const pathname = isAppDir ? (0, navigation_namespaceObject.usePathname)() : router.asPath.split("?")[0];
const push = ({ pathname, query })=>{
if (isAppDir) router.push(pathname + (query ? "?" + new URLSearchParams(query).toString() : ""));
else router.push({
pathname,
query
});
};
const replace = ({ pathname, query })=>{
if (isAppDir) router.replace(pathname + (query ? "?" + new URLSearchParams(query).toString() : ""));
else router.replace({
pathname,
query
});
};
const refresh = ()=>{
if (isAppDir) router.refresh();
else router.replace(router.asPath);
};
const setQuery = (queryArg, merge = false)=>{
const currentQuery = Object.fromEntries(query);
const newQuery = merge ? {
...currentQuery,
...queryArg
} : queryArg;
const searchParams = new URLSearchParams();
for (const [key, value] of Object.entries(newQuery))if (value) searchParams.set(key, value);
location.search = searchParams.toString();
};
return {
router: {
push,
replace,
refresh,
setQuery
},
query: Object.fromEntries(query),
pathname
};
};
const NextAdminRouterAdapter = (0, external_context_js_namespaceObject.createRouterAdapter)(useNextRouter);
const { NextAdmin, MainLayout } = (0, external_components_js_namespaceObject.createNextAdminComponents)(NextAdminRouterAdapter);
exports.MainLayout = __webpack_exports__.MainLayout;
exports.NextAdmin = __webpack_exports__.NextAdmin;
exports.NextAdminRouterAdapter = __webpack_exports__.NextAdminRouterAdapter;
exports.useNextRouter = __webpack_exports__.useNextRouter;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"MainLayout",
"NextAdmin",
"NextAdminRouterAdapter",
"useNextRouter"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});