@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
101 lines (100 loc) • 4.05 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__, {
useClientActionDialog: ()=>useClientActionDialog,
default: ()=>ClientActionDialogContext
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const ClientActionDialog_js_namespaceObject = require("../components/ClientActionDialog.js");
var ClientActionDialog_js_default = /*#__PURE__*/ __webpack_require__.n(ClientActionDialog_js_namespaceObject);
const useRouterInternal_js_namespaceObject = require("../hooks/useRouterInternal.js");
const external_MessageContext_js_namespaceObject = require("./MessageContext.js");
const ClientActionDialogContext_ClientActionDialogContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)({});
const ClientActionDialogProvider = ({ children, componentsMap })=>{
const [isOpen, setIsOpen] = (0, external_react_namespaceObject.useState)(false);
const [dialogData, setDialogData] = (0, external_react_namespaceObject.useState)(null);
const { showMessage } = (0, external_MessageContext_js_namespaceObject.useMessage)();
const { router } = (0, useRouterInternal_js_namespaceObject.useRouterInternal)();
const onClose = (message)=>{
setIsOpen(false);
router.refresh();
if (message) showMessage({
type: message.type,
message: message.message
});
clearData();
};
const open = (0, external_react_namespaceObject.useCallback)((dialogParams)=>{
setIsOpen(true);
const component = componentsMap?.[dialogParams.action.id];
setDialogData({
...dialogParams,
action: {
...dialogParams.action,
component
}
});
}, []);
const clearData = ()=>{
setDialogData(null);
};
const contextValue = (0, external_react_namespaceObject.useMemo)(()=>({
open
}), [
open
]);
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ClientActionDialogContext_ClientActionDialogContext.Provider, {
value: contextValue,
children: [
children,
isOpen && dialogData && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ClientActionDialog_js_default(), {
...dialogData,
onClose: onClose
})
]
});
};
const useClientActionDialog = ()=>(0, external_react_namespaceObject.useContext)(ClientActionDialogContext_ClientActionDialogContext);
const ClientActionDialogContext = ClientActionDialogProvider;
exports["default"] = __webpack_exports__["default"];
exports.useClientActionDialog = __webpack_exports__.useClientActionDialog;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"default",
"useClientActionDialog"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});