@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
94 lines (93 loc) • 4.36 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__, {
default: ()=>components_ActionDropdownItem
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const outline_namespaceObject = require("@heroicons/react/24/outline");
const external_clsx_namespaceObject = require("clsx");
var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject);
const external_tailwind_merge_namespaceObject = require("tailwind-merge");
const ClientActionDialogContext_js_namespaceObject = require("../context/ClientActionDialogContext.js");
const I18nContext_js_namespaceObject = require("../context/I18nContext.js");
const useAction_js_namespaceObject = require("../hooks/useAction.js");
const Dropdown_js_namespaceObject = require("./radix/Dropdown.js");
const Tooltip_js_namespaceObject = require("./radix/Tooltip.js");
const ActionDropdownItem = ({ action, resource, resourceIds })=>{
const { t } = (0, I18nContext_js_namespaceObject.useI18n)();
const { runAction } = (0, useAction_js_namespaceObject.useAction)(resource, resourceIds);
const { open: openActionDialog } = (0, ClientActionDialogContext_js_namespaceObject.useClientActionDialog)();
const isClientAction = "component" in action && "type" in action && "dialog" === action.type;
const Icon = action.icon && outline_namespaceObject[action.icon];
const enabledAction = void 0 === action.allowedIds || action.allowedIds.length > 0 && resourceIds.every((id)=>action.allowedIds?.includes(id));
if (!enabledAction && 1 === resourceIds.length) return null;
const component = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Dropdown_js_namespaceObject.DropdownItem, {
disabled: !enabledAction,
className: (0, external_tailwind_merge_namespaceObject.twMerge)(external_clsx_default()("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1", {
"text-red-700 dark:text-red-400": "destructive" === action.style,
"hover:bg-red-50": "destructive" === action.style,
"text-nextadmin-content-emphasis/50 dark:text-dark-nextadmin-content-emphasis/50 cursor-not-allowed": !enabledAction
})),
onClick: (evt)=>{
if (!enabledAction) return;
evt.stopPropagation();
if (isClientAction) openActionDialog({
action: action,
resource,
resourceIds
});
else runAction(action);
},
children: [
Icon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Icon, {
className: "h-5 w-5"
}),
t(action.title)
]
}, action.title);
if (!enabledAction && resourceIds.length > 1) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Tooltip_js_namespaceObject.SimpleTooltip, {
text: t("actions.some_failed_condition"),
children: component
});
return component;
};
const components_ActionDropdownItem = ActionDropdownItem;
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
});