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

127 lines (126 loc) 5.36 kB
"use strict"; 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__, { default: ()=>AdvancedSearchFieldCondition }); const jsx_runtime_namespaceObject = require("react/jsx-runtime"); const external_react_namespaceObject = require("react"); const I18nContext_js_namespaceObject = require("../../context/I18nContext.js"); const Button_js_namespaceObject = require("../radix/Button.js"); const Dropdown_js_namespaceObject = require("../radix/Dropdown.js"); const external_AdvancedSearchContext_js_namespaceObject = require("./AdvancedSearchContext.js"); const AdvancedSearchFieldCondition_AdvancedSearchFieldCondition = ({ uiBlock })=>{ const { t } = (0, I18nContext_js_namespaceObject.useI18n)(); const { updateUiBlock } = (0, external_AdvancedSearchContext_js_namespaceObject.useAdvancedSearchContext)(); (0, external_react_namespaceObject.useEffect)(()=>{ if ("filter" === uiBlock.type) { const condition = uiBlock.condition; if (("equals" === condition || "not" === condition) && uiBlock.enum) updateUiBlock({ ...uiBlock, condition, value: Boolean(uiBlock.value) ? String(uiBlock.value)?.split(",").map((v)=>v.trim())[0] : uiBlock.defaultValue ?? null }); } }, [ uiBlock.condition ]); if ("filter" !== uiBlock.type) return null; const conditionToText = (condition)=>t("search.advanced.conditions." + condition); const renderDropdownItems = ()=>{ const commonValidConditions = [ "equals", "not" ]; const extraConditions = [ "null", "nnull" ]; const nonBooleanConditions = [ "in", "notIn" ]; const textConditions = [ "search", "startsWith", "endsWith" ]; const numberConditions = [ "lt", "lte", "gt", "gte" ]; if ("boolean" !== uiBlock.contentType && "datetime" !== uiBlock.contentType) commonValidConditions.push(...nonBooleanConditions); if ("text" === uiBlock.contentType) commonValidConditions.push(...textConditions); else if ("number" === uiBlock.contentType || "datetime" === uiBlock.contentType) commonValidConditions.push(...numberConditions); const conditions = [ ...commonValidConditions ]; if (uiBlock.nullable) conditions.push(...extraConditions); return conditions.map((condition)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dropdown_js_namespaceObject.DropdownItem, { className: "cursor-pointer rounded-md p-2", onClick: (e)=>{ e.stopPropagation(); "null" === condition || "nnull" === condition ? updateUiBlock({ ...uiBlock, condition, value: null }) : updateUiBlock({ ...uiBlock, condition }); }, children: conditionToText(condition) }, condition)); }; return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Dropdown_js_namespaceObject.Dropdown, { children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dropdown_js_namespaceObject.DropdownTrigger, { asChild: true, children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Button_js_namespaceObject.Button, { variant: "ghost", size: "sm", children: conditionToText(uiBlock.condition) }) }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dropdown_js_namespaceObject.DropdownBody, { children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Dropdown_js_namespaceObject.DropdownContent, { className: "z-[999] p-2", align: "start", children: renderDropdownItems() }) }) ] }); }; const AdvancedSearchFieldCondition = AdvancedSearchFieldCondition_AdvancedSearchFieldCondition; 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 });