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

217 lines (216 loc) 11.8 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: ()=>advancedSearch_AdvancedSearchModal }); const jsx_runtime_namespaceObject = require("react/jsx-runtime"); const react_namespaceObject = require("@headlessui/react"); const external_dnd_kit_sortable_tree_namespaceObject = require("dnd-kit-sortable-tree"); const external_lodash_unset_namespaceObject = require("lodash.unset"); var external_lodash_unset_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_unset_namespaceObject); const external_lodash_update_namespaceObject = require("lodash.update"); var external_lodash_update_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_update_namespaceObject); const external_react_namespaceObject = require("react"); const I18nContext_js_namespaceObject = require("../../context/I18nContext.js"); const useAdvancedSearch_js_namespaceObject = require("../../hooks/useAdvancedSearch.js"); var useAdvancedSearch_js_default = /*#__PURE__*/ __webpack_require__.n(useAdvancedSearch_js_namespaceObject); const advancedSearch_js_namespaceObject = require("../../utils/advancedSearch.js"); const Button_js_namespaceObject = require("../radix/Button.js"); var Button_js_default = /*#__PURE__*/ __webpack_require__.n(Button_js_namespaceObject); const Dialog_js_namespaceObject = require("../radix/Dialog.js"); const external_AdvancedSearchContext_js_namespaceObject = require("./AdvancedSearchContext.js"); const external_AdvancedSearchDropdown_js_namespaceObject = require("./AdvancedSearchDropdown.js"); var external_AdvancedSearchDropdown_js_default = /*#__PURE__*/ __webpack_require__.n(external_AdvancedSearchDropdown_js_namespaceObject); const external_AdvancedSearchTreeItem_js_namespaceObject = require("./AdvancedSearchTreeItem.js"); var external_AdvancedSearchTreeItem_js_default = /*#__PURE__*/ __webpack_require__.n(external_AdvancedSearchTreeItem_js_namespaceObject); const AdvancedSearchModal = ({ isOpen, onClose, resource, schema })=>{ const { uiBlocks, setUiBlocks, submitSearch } = useAdvancedSearch_js_default()({ resource, schema }); const { t } = (0, I18nContext_js_namespaceObject.useI18n)(); const addUiBlock = (0, external_react_namespaceObject.useCallback)((uiBlock)=>{ setUiBlocks((prev)=>{ const newBlocks = prev ? prev.slice() : []; newBlocks.push(uiBlock); (0, advancedSearch_js_namespaceObject.setInternalPathToBlocks)(newBlocks); return newBlocks; }); }, [ setUiBlocks ]); const removeUiBlock = (0, external_react_namespaceObject.useCallback)((path)=>{ setUiBlocks((prev)=>{ if (!prev) return prev; const newBlocks = prev.slice(); external_lodash_unset_default()(newBlocks, path); (0, advancedSearch_js_namespaceObject.cleanEmptyBlocks)(newBlocks); (0, advancedSearch_js_namespaceObject.setInternalPathToBlocks)(newBlocks); return newBlocks; }); }, [ setUiBlocks ]); const updateUiBlock = (0, external_react_namespaceObject.useCallback)((uiBlock)=>{ setUiBlocks((prev)=>{ if (!prev) return prev; const newBlocks = prev.slice(); external_lodash_update_default()(newBlocks, uiBlock.internalPath, ()=>uiBlock); return newBlocks; }); }, [ setUiBlocks ]); const contextValue = (0, external_react_namespaceObject.useMemo)(()=>({ addUiBlock, removeUiBlock, updateUiBlock, resource, schema }), [ addUiBlock, removeUiBlock, updateUiBlock, resource, schema ]); const onClear = ()=>{ setUiBlocks(null); }; return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dialog_js_namespaceObject.DialogRoot, { open: isOpen, onOpenChange: (open)=>{ if (!open) onClose(); }, modal: true, children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dialog_js_namespaceObject.DialogPortal, { forceMount: true, children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_namespaceObject.Transition, { show: isOpen, as: "div", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.TransitionChild, { as: external_react_namespaceObject.Fragment, enter: "transition-opacity ease-in-out duration-300", enterFrom: "opacity-0", enterTo: "opacity-100", leaveFrom: "opacity-100", leaveTo: "opacity-0", leave: "transition-opacity ease-in-out duration-300", children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dialog_js_namespaceObject.DialogOverlay, { forceMount: true }) }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.TransitionChild, { as: external_react_namespaceObject.Fragment, enter: "transition-opacity ease-in-out duration-300", enterFrom: "opacity-0", enterTo: "opacity-100", leaveFrom: "opacity-100", leaveTo: "opacity-0", leave: "transition-opacity ease-in-out duration-300", children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dialog_js_namespaceObject.DialogContent, { forceMount: true, className: "max-w-xl md:left-[50%] md:top-[50%]", children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "flex flex-col gap-4", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dialog_js_namespaceObject.DialogTitle, { children: t("search.advanced.title") }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_AdvancedSearchContext_js_namespaceObject.AdvancedSearchContext.Provider, { value: contextValue, children: [ uiBlocks && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dnd_kit_sortable_tree_namespaceObject.SortableTree, { items: uiBlocks, onItemsChanged: (items, reason)=>{ const newItems = items.slice(); (0, advancedSearch_js_namespaceObject.setInternalPathToBlocks)(newItems); setUiBlocks(newItems); }, TreeItemComponent: external_AdvancedSearchTreeItem_js_default() }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_AdvancedSearchDropdown_js_default(), { resource: resource, schema: schema, onAddBlock: addUiBlock }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "flex justify-between", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Button_js_default(), { variant: "destructiveOutline", onClick: onClear, children: t("search.advanced.clear") }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", { className: "flex justify-end gap-4", children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Button_js_default(), { variant: "ghost", onClick: onClose, children: t("search.advanced.cancel") }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Button_js_default(), { variant: "default", onClick: ()=>{ submitSearch(); onClose(); }, children: t("search.advanced.save") }) ] }) ] }) ] }) ] }) }) }) ] }) }) }); }; const advancedSearch_AdvancedSearchModal = AdvancedSearchModal; 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 });