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

86 lines (85 loc) 4.05 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { Bars2Icon, XMarkIcon } from "@heroicons/react/24/outline"; import { SimpleTreeItemWrapper } from "dnd-kit-sortable-tree"; import { forwardRef } from "react"; import Button_mjs_default from "../radix/Button.mjs"; import { useAdvancedSearchContext } from "./AdvancedSearchContext.mjs"; import external_AdvancedSearchDropdown_mjs_default from "./AdvancedSearchDropdown.mjs"; import external_AdvancedSearchFieldCondition_mjs_default from "./AdvancedSearchFieldCondition.mjs"; import external_AdvancedSearchInput_mjs_default from "./AdvancedSearchInput.mjs"; const AdvancedSearchTree = /*#__PURE__*/ forwardRef((props, ref)=>{ const { updateUiBlock, removeUiBlock, resource, schema } = useAdvancedSearchContext(); const onSwitchBranchType = (evt)=>{ evt.stopPropagation(); updateUiBlock({ ...props.item, type: "and" === props.item.type ? "or" : "and" }); }; const onRemove = (evt)=>{ evt.stopPropagation(); removeUiBlock(props.item.internalPath); }; return /*#__PURE__*/ jsxs(SimpleTreeItemWrapper, { ...props, showDragHandle: false, hideCollapseButton: true, ref: ref, disableCollapseOnItemClick: true, className: "flex max-w-full flex-col", contentClassName: "max-w-full text-nextadmin-content-default dark:text-dark-nextadmin-content-default bg-nextadmin-background-muted dark:bg-dark-nextadmin-background-emphasis relative flex cursor-default gap-2 rounded-md !px-3 !py-1 text-sm !border-none", children: [ /*#__PURE__*/ jsxs("div", { className: "flex max-w-full flex-1 items-center gap-2", children: [ /*#__PURE__*/ jsx("div", { ...props.handleProps, children: /*#__PURE__*/ jsx(Bars2Icon, { className: "h-4 w-4 cursor-grab" }) }), "filter" === props.item.type && /*#__PURE__*/ jsx(external_AdvancedSearchDropdown_mjs_default, { trigger: /*#__PURE__*/ jsx(Button_mjs_default, { variant: "ghost", size: "sm", className: "block max-w-[100px] overflow-x-hidden truncate text-left md:max-w-[200px]", title: props.item.displayPath, children: props.item.displayPath }), resource: resource, schema: schema, showBranching: false, onAddBlock: (uiBlock)=>{ updateUiBlock({ ...uiBlock, internalPath: props.item.internalPath }); } }), "filter" !== props.item.type && /*#__PURE__*/ jsx(Button_mjs_default, { variant: "ghost", size: "sm", onClick: onSwitchBranchType, children: "and" === props.item.type ? "AND" : "OR" }), /*#__PURE__*/ jsx(external_AdvancedSearchFieldCondition_mjs_default, { uiBlock: props.item }), /*#__PURE__*/ jsx(external_AdvancedSearchInput_mjs_default, { uiBlock: props.item }) ] }), /*#__PURE__*/ jsx(Button_mjs_default, { variant: "ghost", size: "sm", onClick: onRemove, children: /*#__PURE__*/ jsx(XMarkIcon, { className: "h-4 w-4" }) }) ] }); }); const AdvancedSearchTreeItem = AdvancedSearchTree; export { AdvancedSearchTreeItem as default };