UNPKG

@llamaindex/ui

Version:

A comprehensive UI component library built with React, TypeScript, and Tailwind CSS for LlamaIndex applications

56 lines (52 loc) 2.06 kB
'use strict'; var chunkKRF4WMPE_js = require('./chunk-KRF4WMPE.js'); var chunk64FRNQ3S_js = require('./chunk-64FRNQ3S.js'); var chunkHK7TFVDA_js = require('./chunk-HK7TFVDA.js'); var lucideReact = require('lucide-react'); var jsxRuntime = require('react/jsx-runtime'); var ColumnFilter = ({ options, selectedValues, onFilterChange }) => { const handleToggleOption = (option, checked) => { const newValues = checked ? [...selectedValues, option] : selectedValues.filter((value) => value !== option); onFilterChange(newValues); }; const handleClearAll = () => { onFilterChange([]); }; if (options.length === 0) { return null; } return /* @__PURE__ */ jsxRuntime.jsxs(chunkKRF4WMPE_js.DropdownMenu, { children: [ /* @__PURE__ */ jsxRuntime.jsx(chunkKRF4WMPE_js.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx( chunk64FRNQ3S_js.Button, { variant: "ghost", size: "icon", className: chunkHK7TFVDA_js.cn( "h-6 w-6 p-0", selectedValues.length > 0 ? "text-primary" : "text-muted-foreground" ), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: "h-3 w-3" }) } ) }), /* @__PURE__ */ jsxRuntime.jsxs(chunkKRF4WMPE_js.DropdownMenuContent, { align: "start", className: "w-48", children: [ options.map((option) => /* @__PURE__ */ jsxRuntime.jsx( chunkKRF4WMPE_js.DropdownMenuCheckboxItem, { checked: selectedValues.includes(option), onCheckedChange: (checked) => handleToggleOption(option, checked), children: option }, option )), selectedValues.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ /* @__PURE__ */ jsxRuntime.jsx(chunkKRF4WMPE_js.DropdownMenuSeparator, {}), /* @__PURE__ */ jsxRuntime.jsx(chunkKRF4WMPE_js.DropdownMenuItem, { onClick: handleClearAll, children: "Clear filters" }) ] }) ] }) ] }); }; exports.ColumnFilter = ColumnFilter;