@kumix/ui 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -24
- package/dist/cascader-types-BnH6wYD-.d.ts +183 -0
- package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -0
- package/dist/components/agents/ai-sidebar.d.ts +17 -1
- package/dist/components/agents/ai-sidebar.d.ts.map +1 -1
- package/dist/components/agents/ai-sidebar.js +90 -14
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/chat-app.d.ts +10 -5
- package/dist/components/agents/chat-app.d.ts.map +1 -1
- package/dist/components/agents/chat-app.js +54 -5
- package/dist/components/agents/chat-app.js.map +1 -1
- package/dist/components/agents/citations.d.ts.map +1 -1
- package/dist/components/agents/citations.js +5 -6
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/tool-approval.d.ts.map +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-approval.js.map +1 -1
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +2 -2
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js +13 -3
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +9 -5
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.d.ts +5 -2
- package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +18 -8
- package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
- package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -1
- package/dist/components/motion/availability-scheduler/index.js +27 -5
- package/dist/components/motion/availability-scheduler/index.js.map +1 -1
- package/dist/components/motion/availability-scheduler/time-select.d.ts +3 -1
- package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -1
- package/dist/components/motion/availability-scheduler/time-select.js +3 -1
- package/dist/components/motion/availability-scheduler/time-select.js.map +1 -1
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
- package/dist/components/motion/bottom-sheet.js +78 -74
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
- package/dist/components/motion/center-morph-modal.js +82 -88
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/command-palette.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +51 -27
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.d.ts.map +1 -1
- package/dist/components/motion/context-menu.js +16 -6
- package/dist/components/motion/context-menu.js.map +1 -1
- package/dist/components/motion/cylinder-carousel.d.ts.map +1 -1
- package/dist/components/motion/cylinder-carousel.js +4 -3
- package/dist/components/motion/cylinder-carousel.js.map +1 -1
- package/dist/components/motion/drawer.d.ts.map +1 -1
- package/dist/components/motion/drawer.js +30 -30
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.d.ts +6 -0
- package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
- package/dist/components/motion/expandable-action-bar.js +38 -9
- package/dist/components/motion/expandable-action-bar.js.map +1 -1
- package/dist/components/motion/hold-action-button.d.ts +1 -1
- package/dist/components/motion/hold-action-button.d.ts.map +1 -1
- package/dist/components/motion/hold-action-button.js +64 -50
- package/dist/components/motion/hold-action-button.js.map +1 -1
- package/dist/components/motion/loader.js +20 -22
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/morphing-modal.d.ts.map +1 -1
- package/dist/components/motion/morphing-modal.js +83 -83
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.d.ts +28 -0
- package/dist/components/motion/morphing-search.d.ts.map +1 -0
- package/dist/components/motion/morphing-search.js +418 -0
- package/dist/components/motion/morphing-search.js.map +1 -0
- package/dist/components/motion/morphing-tabs.d.ts.map +1 -1
- package/dist/components/motion/morphing-tabs.js +59 -18
- package/dist/components/motion/morphing-tabs.js.map +1 -1
- package/dist/components/motion/notification-stack.d.ts.map +1 -1
- package/dist/components/motion/notification-stack.js +28 -11
- package/dist/components/motion/notification-stack.js.map +1 -1
- package/dist/components/motion/popover-morph.d.ts.map +1 -1
- package/dist/components/motion/popover-morph.js +26 -11
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.d.ts.map +1 -1
- package/dist/components/motion/popover.js +39 -28
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/preview-rail.d.ts.map +1 -1
- package/dist/components/motion/preview-rail.js +42 -13
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/project-folder.js +20 -20
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/pull-to-refresh.d.ts.map +1 -1
- package/dist/components/motion/pull-to-refresh.js +8 -7
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/range-slider-bubble.d.ts.map +1 -1
- package/dist/components/motion/range-slider-bubble.js +2 -1
- package/dist/components/motion/range-slider-bubble.js.map +1 -1
- package/dist/components/motion/range-slider-fluid.d.ts.map +1 -1
- package/dist/components/motion/range-slider-fluid.js +2 -1
- package/dist/components/motion/range-slider-fluid.js.map +1 -1
- package/dist/components/motion/range-slider-ruler.d.ts.map +1 -1
- package/dist/components/motion/range-slider-ruler.js +2 -1
- package/dist/components/motion/range-slider-ruler.js.map +1 -1
- package/dist/components/motion/range-slider-wave.d.ts.map +1 -1
- package/dist/components/motion/range-slider-wave.js +2 -1
- package/dist/components/motion/range-slider-wave.js.map +1 -1
- package/dist/components/motion/range-slider.d.ts.map +1 -1
- package/dist/components/motion/range-slider.js +2 -1
- package/dist/components/motion/range-slider.js.map +1 -1
- package/dist/components/motion/select.d.ts +15 -1
- package/dist/components/motion/select.d.ts.map +1 -1
- package/dist/components/motion/select.js +15 -4
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/slide-action-button.d.ts.map +1 -1
- package/dist/components/motion/slide-action-button.js +3 -2
- package/dist/components/motion/slide-action-button.js.map +1 -1
- package/dist/components/motion/swipeable-list.d.ts.map +1 -1
- package/dist/components/motion/swipeable-list.js +2 -1
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/table/index.d.ts.map +1 -1
- package/dist/components/motion/table/index.js +64 -6
- package/dist/components/motion/table/index.js.map +1 -1
- package/dist/components/motion/table/table-header.d.ts.map +1 -1
- package/dist/components/motion/table/table-header.js +3 -2
- package/dist/components/motion/table/table-header.js.map +1 -1
- package/dist/components/motion/text-reveal.d.ts.map +1 -1
- package/dist/components/motion/text-reveal.js +72 -48
- package/dist/components/motion/text-reveal.js.map +1 -1
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +35 -15
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wheel-picker.d.ts.map +1 -1
- package/dist/components/motion/wheel-picker.js +4 -3
- package/dist/components/motion/wheel-picker.js.map +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-async.js +549 -0
- package/dist/components/reui/cascader/cascader-async.js.map +1 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-columns.js +135 -0
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
- package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-context.js +59 -0
- package/dist/components/reui/cascader/cascader-context.js.map +1 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-footer.js +456 -0
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-i18n.js +68 -0
- package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
- package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
- package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-item.js +530 -0
- package/dist/components/reui/cascader/cascader-item.js.map +1 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-lib.js +576 -0
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-nav.js +312 -0
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
- package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
- package/dist/components/reui/cascader/cascader-types.js +2 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-virtual.js +240 -0
- package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
- package/dist/components/reui/cascader/cascader.d.ts +322 -0
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader.js +1459 -0
- package/dist/components/reui/cascader/cascader.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
- package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-advanced.js +1191 -0
- package/dist/components/reui/filters/filters-advanced.js.map +1 -0
- package/dist/components/reui/filters/filters-builder.d.ts +43 -0
- package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-builder.js +152 -0
- package/dist/components/reui/filters/filters-builder.js.map +1 -0
- package/dist/components/reui/filters/filters-chip.d.ts +79 -0
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-chip.js +553 -0
- package/dist/components/reui/filters/filters-chip.js.map +1 -0
- package/dist/components/reui/filters/filters-context.d.ts +290 -0
- package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-context.js +277 -0
- package/dist/components/reui/filters/filters-context.js.map +1 -0
- package/dist/components/reui/filters/filters-date.d.ts +43 -0
- package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-date.js +143 -0
- package/dist/components/reui/filters/filters-date.js.map +1 -0
- package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
- package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-dnd.js +454 -0
- package/dist/components/reui/filters/filters-dnd.js.map +1 -0
- package/dist/components/reui/filters/filters-draft.d.ts +2 -0
- package/dist/components/reui/filters/filters-draft.js +128 -0
- package/dist/components/reui/filters/filters-draft.js.map +1 -0
- package/dist/components/reui/filters/filters-editors.d.ts +91 -0
- package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-editors.js +773 -0
- package/dist/components/reui/filters/filters-editors.js.map +1 -0
- package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
- package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-i18n.js +127 -0
- package/dist/components/reui/filters/filters-i18n.js.map +1 -0
- package/dist/components/reui/filters/filters-lib.d.ts +171 -0
- package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-lib.js +336 -0
- package/dist/components/reui/filters/filters-lib.js.map +1 -0
- package/dist/components/reui/filters/filters-operators.d.ts +49 -0
- package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-operators.js +300 -0
- package/dist/components/reui/filters/filters-operators.js.map +1 -0
- package/dist/components/reui/filters/filters-query.d.ts +132 -0
- package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-query.js +476 -0
- package/dist/components/reui/filters/filters-query.js.map +1 -0
- package/dist/components/reui/filters/filters-types.d.ts +452 -0
- package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-types.js +2 -0
- package/dist/components/reui/filters/filters.d.ts +114 -0
- package/dist/components/reui/filters/filters.d.ts.map +1 -0
- package/dist/components/reui/filters/filters.js +638 -0
- package/dist/components/reui/filters/filters.js.map +1 -0
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
- package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/field.js +2 -2
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/{copy-menu-Bk5GP9Gp.js → copy-menu-1FKoMc9o.js} +9 -2
- package/dist/copy-menu-1FKoMc9o.js.map +1 -0
- package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
- package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
- package/dist/hooks/use-dismiss.d.ts +34 -0
- package/dist/hooks/use-dismiss.d.ts.map +1 -0
- package/dist/hooks/use-dismiss.js +78 -0
- package/dist/hooks/use-dismiss.js.map +1 -0
- package/dist/hooks/use-favicon.d.ts +17 -0
- package/dist/hooks/use-favicon.d.ts.map +1 -0
- package/dist/hooks/use-favicon.js +35 -0
- package/dist/hooks/use-favicon.js.map +1 -0
- package/dist/hooks/use-hover-gesture.d.ts +38 -0
- package/dist/hooks/use-hover-gesture.d.ts.map +1 -0
- package/dist/hooks/use-hover-gesture.js +46 -0
- package/dist/hooks/use-hover-gesture.js.map +1 -0
- package/dist/hooks/use-slider.d.ts.map +1 -1
- package/dist/hooks/use-slider.js +3 -2
- package/dist/hooks/use-slider.js.map +1 -1
- package/dist/hooks/use-tap-gesture.d.ts +47 -0
- package/dist/hooks/use-tap-gesture.d.ts.map +1 -0
- package/dist/hooks/use-tap-gesture.js +51 -0
- package/dist/hooks/use-tap-gesture.js.map +1 -0
- package/dist/hooks/use-touch-capable.d.ts +15 -0
- package/dist/hooks/use-touch-capable.d.ts.map +1 -0
- package/dist/hooks/use-touch-capable.js +29 -0
- package/dist/hooks/use-touch-capable.js.map +1 -0
- package/dist/lib/text-shimmer.d.ts +2 -2
- package/dist/lib/text-shimmer.d.ts.map +1 -1
- package/dist/lib/text-shimmer.js +2 -2
- package/dist/lib/text-shimmer.js.map +1 -1
- package/dist/lib/touch.d.ts +66 -0
- package/dist/lib/touch.d.ts.map +1 -0
- package/dist/lib/touch.js +79 -0
- package/dist/lib/touch.js.map +1 -0
- package/dist/presence-gate-BekdC4Bo.js +24 -0
- package/dist/presence-gate-BekdC4Bo.js.map +1 -0
- package/dist/types-smkWN_7x.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/components/reui/filters.d.ts +0 -176
- package/dist/components/reui/filters.d.ts.map +0 -1
- package/dist/components/reui/filters.js +0 -1223
- package/dist/components/reui/filters.js.map +0 -1
- package/dist/copy-menu-Bk5GP9Gp.js.map +0 -1
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../../ui/button.js";
|
|
3
|
+
import { ButtonGroup, ButtonGroupText } from "../../ui/button-group.js";
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../ui/dropdown-menu.js";
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
6
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip.js";
|
|
7
|
+
import { filterControlSizes, filterReadOnlyProps, isFilterLocked, useFilterActions, useFilterChipAutoOpen, useFilterChipFocused, useFilterFocusEmpty, useFilterFocusStore, useFilterRender, useFilterReorderable } from "./filters-context.js";
|
|
8
|
+
import { FILTER_MENU_CLASS, FILTER_MENU_LABEL_CLASS, collapseFilterPath, formatFilterPath, getFilterField, getFilterFieldChain } from "./filters-lib.js";
|
|
9
|
+
import { coerceFilterValue, getFilterArity, getFilterOperator, operatorTakesValue, visibleFilterOperators } from "./filters-operators.js";
|
|
10
|
+
import { FilterMenu, useFilterOptions, useFilterValueResolution } from "./filters-editors.js";
|
|
11
|
+
import { findFilterNode, isFilterGroup } from "./filters-query.js";
|
|
12
|
+
import * as React$1 from "react";
|
|
13
|
+
import { cn } from "@kumix/utils";
|
|
14
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { ArrowLeftRightIcon, ChevronRightIcon, CopyIcon, CornerDownRightIcon, EllipsisVerticalIcon, LayersIcon, SlidersHorizontalIcon, Trash2Icon, XIcon } from "lucide-react";
|
|
16
|
+
//#region src/components/reui/filters/filters-chip.tsx
|
|
17
|
+
/** The ref half of `autoFocusProps`: a CALLBACK ref, the one shape an editor
|
|
18
|
+
* can spread onto any element without a cast, and a no-op here. */
|
|
19
|
+
const noopAutoFocusRef = () => {};
|
|
20
|
+
function defaultValueDisplay(value, operator, resolveOption, labels, fieldPlaceholder, optionBacked) {
|
|
21
|
+
const emptyLabel = optionBacked ? labels.selectPlaceholder : fieldPlaceholder ?? labels.valuePlaceholder;
|
|
22
|
+
if (value === void 0 || value === null || value === "") return emptyLabel;
|
|
23
|
+
if (getFilterArity(operator) === "range" && Array.isArray(value)) {
|
|
24
|
+
const [from, to] = value;
|
|
25
|
+
return labels.valueRange(String(from ?? ""), String(to ?? ""));
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
const values = value;
|
|
29
|
+
if (values.length === 0) return emptyLabel;
|
|
30
|
+
if (values.length === 1) return resolveOption(values[0])?.label ?? String(values[0]);
|
|
31
|
+
return labels.valueCount(values.length);
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "boolean") return value ? "True" : "False";
|
|
34
|
+
return resolveOption(String(value))?.label ?? String(value);
|
|
35
|
+
}
|
|
36
|
+
/** The same display with the option's own icon in front. A status filter reads
|
|
37
|
+
* as its colour before its word, so dropping the swatch the picker showed
|
|
38
|
+
* makes the chip harder to scan than the list it came from. */
|
|
39
|
+
function valueWithIcon(value, text, resolveOption) {
|
|
40
|
+
const single = value === void 0 || value === null || Array.isArray(value) ? Array.isArray(value) && value.length === 1 ? String(value[0]) : null : String(value);
|
|
41
|
+
const icon = single ? resolveOption(single)?.icon : null;
|
|
42
|
+
if (!icon) return text;
|
|
43
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
44
|
+
className: "flex items-center gap-1.5",
|
|
45
|
+
children: [icon, text]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** The glyph between two ancestors in a nested attribute path, a chevron
|
|
49
|
+
* because the `pathSeparator` string read as loud as the names it parts.
|
|
50
|
+
* DECORATIVE: `aria-hidden`, and the plain string is still what
|
|
51
|
+
* `formatFilterPath` joins for the chip's accessible name and `title`. */
|
|
52
|
+
function FilterPathSeparator() {
|
|
53
|
+
return /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
54
|
+
"aria-hidden": "true",
|
|
55
|
+
"data-slot": "filter-path-separator",
|
|
56
|
+
className: "mx-[3px] inline-block size-3 shrink-0 self-center align-[calc(0.3635em-0.375rem)] text-muted-foreground"
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** The elided run of a collapsed path, with the FULL path behind it. THE
|
|
60
|
+
* TOOLTIP IS NOT THE ACCESSIBLE ROUTE: it is hover and focus, so the segment
|
|
61
|
+
* is `aria-hidden` and the whole path stays in the control's NAME. The host's
|
|
62
|
+
* own `title` is dropped while collapsed (`pathCollapsed`) or both fire. */
|
|
63
|
+
function FilterPathEllipsis({ full }) {
|
|
64
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx("span", {
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
"data-slot": "filter-path-ellipsis",
|
|
67
|
+
className: "shrink-0 self-center text-muted-foreground",
|
|
68
|
+
children: "..."
|
|
69
|
+
}) }), /* @__PURE__ */ jsx(TooltipContent, { children: full })] }) });
|
|
70
|
+
}
|
|
71
|
+
/** How one rule reads, resolved once and shared by both chromes, so a consumer
|
|
72
|
+
* `renderValue`, the field's own and the built-in cannot disagree. */
|
|
73
|
+
function useFilterRuleDisplay(rule, field, operator) {
|
|
74
|
+
const actions = useFilterActions();
|
|
75
|
+
const render = useFilterRender();
|
|
76
|
+
const optionsState = useFilterOptions(field, false);
|
|
77
|
+
const values = rule.value === void 0 || rule.value === null ? [] : Array.isArray(rule.value) ? rule.value : [rule.value];
|
|
78
|
+
useFilterValueResolution(field, values);
|
|
79
|
+
const pathText = formatFilterPath(actions.index, rule.path, actions.labels.pathSeparator);
|
|
80
|
+
const chain = getFilterFieldChain(actions.index, rule.path);
|
|
81
|
+
const segments = collapseFilterPath(chain, {
|
|
82
|
+
maxSegments: actions.maxPathSegments,
|
|
83
|
+
collapse: actions.pathCollapse
|
|
84
|
+
});
|
|
85
|
+
const pathCollapsed = segments.some((segment) => segment.type === "ellipsis");
|
|
86
|
+
const pathLabel = chain.length ? segments.map((segment, index) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [index > 0 ? /* @__PURE__ */ jsx(FilterPathSeparator, {}) : null, segment.type === "field" ? /* @__PURE__ */ jsx("span", { children: segment.field.label }) : /* @__PURE__ */ jsx(FilterPathEllipsis, { full: pathText })] }, segment.type === "field" ? `${index}:${segment.field.id}` : `${index}:ellipsis`)) : pathText;
|
|
87
|
+
const operatorLabel = operator ? rule.negated ? actions.labels.negated(operator.label) : operator.label : rule.operator || actions.labels.selectCondition;
|
|
88
|
+
const valueEmpty = rule.value === void 0 || rule.value === null || rule.value === "" || values.length === 0;
|
|
89
|
+
if (!field) return {
|
|
90
|
+
pathText,
|
|
91
|
+
pathLabel,
|
|
92
|
+
pathCollapsed,
|
|
93
|
+
operatorLabel,
|
|
94
|
+
valueLabel: "",
|
|
95
|
+
valueText: "",
|
|
96
|
+
valueFullText: "",
|
|
97
|
+
valueEmpty
|
|
98
|
+
};
|
|
99
|
+
const valueContext = {
|
|
100
|
+
value: rule.value,
|
|
101
|
+
values,
|
|
102
|
+
field,
|
|
103
|
+
operator: operator ?? {
|
|
104
|
+
value: rule.operator,
|
|
105
|
+
label: rule.operator
|
|
106
|
+
},
|
|
107
|
+
options: values.map((entry) => optionsState.resolve(String(entry))).filter(Boolean),
|
|
108
|
+
labels: actions.labels
|
|
109
|
+
};
|
|
110
|
+
const valueText = field.valueText ? field.valueText(valueContext) : defaultValueDisplay(rule.value, operator, optionsState.resolve, actions.labels, field.placeholder, field.type === "select" || field.type === "multiselect" || Boolean(field.options?.length) || Boolean(field.loadOptions));
|
|
111
|
+
return {
|
|
112
|
+
pathText,
|
|
113
|
+
pathLabel,
|
|
114
|
+
pathCollapsed,
|
|
115
|
+
operatorLabel,
|
|
116
|
+
valueLabel: render.renderValue ? render.renderValue(valueContext) : field.renderValue ? field.renderValue(valueContext) : valueWithIcon(rule.value, valueText, optionsState.resolve),
|
|
117
|
+
valueText,
|
|
118
|
+
valueFullText: field.valueText || !Array.isArray(rule.value) || getFilterArity(operator) === "range" || values.length < 2 ? valueText : actions.labels.valueDetail(valueText, values.map((entry) => optionsState.resolve(String(entry))?.label ?? String(entry))),
|
|
119
|
+
valueEmpty
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** The value editor - draft, option service, commit - with NO surface of its
|
|
123
|
+
* own, so surface and wiring can be replaced independently. The draft lives
|
|
124
|
+
* here, so a text filter dispatches once on commit, not once per keystroke. */
|
|
125
|
+
function FilterValueEditor({ rule, field, operator, open, onClose }) {
|
|
126
|
+
const actions = useFilterActions();
|
|
127
|
+
const [draft, setDraft] = React$1.useState(rule.value);
|
|
128
|
+
React$1.useEffect(() => {
|
|
129
|
+
if (open) setDraft(rule.value);
|
|
130
|
+
}, [open, rule.value]);
|
|
131
|
+
const options = useFilterOptions(field, open);
|
|
132
|
+
const editor = React$1.useMemo(() => actions.resolveEditor(field, operator), [
|
|
133
|
+
actions,
|
|
134
|
+
field,
|
|
135
|
+
operator
|
|
136
|
+
]);
|
|
137
|
+
if (!editor) return null;
|
|
138
|
+
const editorProps = {
|
|
139
|
+
field,
|
|
140
|
+
operator,
|
|
141
|
+
value: draft,
|
|
142
|
+
onValueChange: (next) => setDraft(next),
|
|
143
|
+
host: "amend",
|
|
144
|
+
autoFocusProps: {
|
|
145
|
+
ref: noopAutoFocusRef,
|
|
146
|
+
autoFocus: true
|
|
147
|
+
},
|
|
148
|
+
commit: (next, commitOptions) => {
|
|
149
|
+
actions.updateRule(rule.id, { value: next === void 0 ? draft : next });
|
|
150
|
+
if (commitOptions?.close === false) return;
|
|
151
|
+
onClose();
|
|
152
|
+
},
|
|
153
|
+
cancel: onClose,
|
|
154
|
+
back: onClose,
|
|
155
|
+
options,
|
|
156
|
+
labels: actions.labels
|
|
157
|
+
};
|
|
158
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: React$1.createElement(editor, editorProps) });
|
|
159
|
+
}
|
|
160
|
+
/** One step of the flow, released when the panel that owes it has LEFT THE
|
|
161
|
+
* DOM: both popovers keep portal content mounted through the exit transition,
|
|
162
|
+
* so this unmount IS that moment and nothing is timed. `onRelease` is used AS
|
|
163
|
+
* the cleanup, so an unmemoized callback fires its step early. */
|
|
164
|
+
function FilterStepHandoff({ onRelease }) {
|
|
165
|
+
React$1.useEffect(() => onRelease, [onRelease]);
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
function FilterValuePopover({ rule, field, operator, trigger, className }) {
|
|
169
|
+
const actions = useFilterActions();
|
|
170
|
+
const focusStore = useFilterFocusStore();
|
|
171
|
+
const autoOpen = useFilterChipAutoOpen(rule.id) === "value";
|
|
172
|
+
const [open, setOpen] = React$1.useState(false);
|
|
173
|
+
const locked = isFilterLocked(actions);
|
|
174
|
+
React$1.useEffect(() => {
|
|
175
|
+
if (!autoOpen || open) return;
|
|
176
|
+
if (!locked) setOpen(true);
|
|
177
|
+
focusStore.set({
|
|
178
|
+
id: rule.id,
|
|
179
|
+
segment: "value",
|
|
180
|
+
autoOpen: false
|
|
181
|
+
});
|
|
182
|
+
}, [
|
|
183
|
+
autoOpen,
|
|
184
|
+
open,
|
|
185
|
+
focusStore,
|
|
186
|
+
rule.id,
|
|
187
|
+
locked
|
|
188
|
+
]);
|
|
189
|
+
if (!operator || !actions.resolveEditor(field, operator)) return React$1.cloneElement(trigger, {
|
|
190
|
+
disabled: actions.disabled,
|
|
191
|
+
...filterReadOnlyProps(actions)
|
|
192
|
+
});
|
|
193
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
194
|
+
open,
|
|
195
|
+
onOpenChange: (next) => {
|
|
196
|
+
if (next && locked) return;
|
|
197
|
+
setOpen(next);
|
|
198
|
+
},
|
|
199
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
200
|
+
render: trigger,
|
|
201
|
+
disabled: actions.disabled,
|
|
202
|
+
...filterReadOnlyProps(actions)
|
|
203
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
204
|
+
align: "start",
|
|
205
|
+
className: cn("w-auto p-0", className),
|
|
206
|
+
children: /* @__PURE__ */ jsx(FilterValueEditor, {
|
|
207
|
+
rule,
|
|
208
|
+
field,
|
|
209
|
+
operator,
|
|
210
|
+
open,
|
|
211
|
+
onClose: () => {
|
|
212
|
+
setOpen(false);
|
|
213
|
+
focusStore.set({
|
|
214
|
+
id: rule.id,
|
|
215
|
+
segment: "value",
|
|
216
|
+
autoOpen: false
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
})]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function FilterOperatorPopover({ rule, field, trigger, className }) {
|
|
224
|
+
const actions = useFilterActions();
|
|
225
|
+
const focusStore = useFilterFocusStore();
|
|
226
|
+
const autoOpen = useFilterChipAutoOpen(rule.id) === "operator";
|
|
227
|
+
const [open, setOpen] = React$1.useState(false);
|
|
228
|
+
const locked = isFilterLocked(actions);
|
|
229
|
+
/** Whether the close this panel is going through IS the step being handed
|
|
230
|
+
* on. A ref, so it survives the render that closes the popover. Every OPEN
|
|
231
|
+
* clears it, so an Escape or an outside press finds it already lowered and
|
|
232
|
+
* spends nothing; `release` leaves it standing because one twin asks again
|
|
233
|
+
* later: Radix reads it from `onCloseAutoFocus`, a macrotask after the
|
|
234
|
+
* unmount. Clearing it in `release` would break that twin only. */
|
|
235
|
+
const handoff = React$1.useRef(false);
|
|
236
|
+
const operators = actions.resolveOperators(field);
|
|
237
|
+
const items = React$1.useMemo(() => visibleFilterOperators(operators).map((entry) => ({
|
|
238
|
+
value: entry.value,
|
|
239
|
+
label: entry.label
|
|
240
|
+
})), [operators]);
|
|
241
|
+
React$1.useEffect(() => {
|
|
242
|
+
if (!autoOpen || open) return;
|
|
243
|
+
handoff.current = false;
|
|
244
|
+
if (!locked) setOpen(true);
|
|
245
|
+
focusStore.set({
|
|
246
|
+
id: rule.id,
|
|
247
|
+
segment: "operator",
|
|
248
|
+
autoOpen: false
|
|
249
|
+
});
|
|
250
|
+
}, [
|
|
251
|
+
autoOpen,
|
|
252
|
+
open,
|
|
253
|
+
focusStore,
|
|
254
|
+
rule.id,
|
|
255
|
+
locked
|
|
256
|
+
]);
|
|
257
|
+
const close = () => {
|
|
258
|
+
handoff.current = false;
|
|
259
|
+
setOpen(false);
|
|
260
|
+
focusStore.set({
|
|
261
|
+
id: rule.id,
|
|
262
|
+
segment: "operator",
|
|
263
|
+
autoOpen: false
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
/** The parked step, spent on the frame this panel stops existing. Memoized
|
|
267
|
+
* on nothing that changes, and load bearing: `FilterStepHandoff` uses this
|
|
268
|
+
* AS its cleanup, so a new identity mid-flow fires the step too early. */
|
|
269
|
+
const release = React$1.useCallback(() => {
|
|
270
|
+
if (!handoff.current) return;
|
|
271
|
+
focusStore.set({
|
|
272
|
+
id: rule.id,
|
|
273
|
+
segment: "value",
|
|
274
|
+
autoOpen: true
|
|
275
|
+
});
|
|
276
|
+
}, [focusStore, rule.id]);
|
|
277
|
+
React$1.useEffect(() => () => {
|
|
278
|
+
handoff.current = false;
|
|
279
|
+
}, []);
|
|
280
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
281
|
+
open,
|
|
282
|
+
onOpenChange: (next) => {
|
|
283
|
+
if (next && locked) return;
|
|
284
|
+
if (next) handoff.current = false;
|
|
285
|
+
setOpen(next);
|
|
286
|
+
},
|
|
287
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
288
|
+
render: trigger,
|
|
289
|
+
disabled: actions.disabled,
|
|
290
|
+
...filterReadOnlyProps(actions)
|
|
291
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
292
|
+
align: "start",
|
|
293
|
+
finalFocus: () => !handoff.current,
|
|
294
|
+
className: cn("w-auto min-w-40 p-0", className),
|
|
295
|
+
children: [/* @__PURE__ */ jsx(FilterStepHandoff, { onRelease: release }), /* @__PURE__ */ jsx(FilterMenu, {
|
|
296
|
+
items,
|
|
297
|
+
selected: rule.operator ? [rule.operator] : [],
|
|
298
|
+
onSelectionChange: (values) => {
|
|
299
|
+
const value = values[0];
|
|
300
|
+
if (value === void 0) {
|
|
301
|
+
close();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const chosen = getFilterOperator(operators, value);
|
|
305
|
+
const building = !rule.operator;
|
|
306
|
+
actions.updateRule(rule.id, {
|
|
307
|
+
operator: value,
|
|
308
|
+
value: coerceFilterValue(rule.value, getFilterOperator(operators, rule.operator), chosen)
|
|
309
|
+
});
|
|
310
|
+
if (building && operatorTakesValue(chosen)) {
|
|
311
|
+
handoff.current = true;
|
|
312
|
+
setOpen(false);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
close();
|
|
316
|
+
},
|
|
317
|
+
labels: actions.labels,
|
|
318
|
+
ariaLabel: field.label,
|
|
319
|
+
searchPlaceholder: actions.labels.searchOperators,
|
|
320
|
+
searchable: false,
|
|
321
|
+
maxHeight: 320
|
|
322
|
+
})]
|
|
323
|
+
})]
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/** The keyboard path to a CROSS-GROUP move: Alt+Arrow reorders within the
|
|
327
|
+
* owning group only and Wrap creates a NEW group, so the drag layer's
|
|
328
|
+
* cross-group move had no keyboard parity. Numbered in document order. */
|
|
329
|
+
function FilterMoveToMenuItems({ nodeId }) {
|
|
330
|
+
const actions = useFilterActions();
|
|
331
|
+
const reorderable = useFilterReorderable();
|
|
332
|
+
const locked = isFilterLocked(actions);
|
|
333
|
+
const query = actions.getQuery();
|
|
334
|
+
const found = findFilterNode(query, nodeId);
|
|
335
|
+
if (!found?.parent) return null;
|
|
336
|
+
const destinations = [];
|
|
337
|
+
if (found.parent.id !== query.id) destinations.push({
|
|
338
|
+
id: query.id,
|
|
339
|
+
label: actions.labels.moveToTopLevel,
|
|
340
|
+
size: query.rules.length
|
|
341
|
+
});
|
|
342
|
+
let position = 0;
|
|
343
|
+
const visit = (group, inside) => {
|
|
344
|
+
for (const child of group.rules) {
|
|
345
|
+
if (!isFilterGroup(child)) continue;
|
|
346
|
+
position += 1;
|
|
347
|
+
const within = inside || child.id === nodeId;
|
|
348
|
+
if (!within && child.id !== found.parent.id) destinations.push({
|
|
349
|
+
id: child.id,
|
|
350
|
+
label: actions.labels.moveToGroup(position),
|
|
351
|
+
size: child.rules.length
|
|
352
|
+
});
|
|
353
|
+
visit(child, within);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
visit(query, false);
|
|
357
|
+
if (destinations.length === 0) return null;
|
|
358
|
+
if (!reorderable) return null;
|
|
359
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: destinations.map((destination) => /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
360
|
+
disabled: locked,
|
|
361
|
+
onClick: () => actions.moveNodeTo(nodeId, destination.id, destination.size),
|
|
362
|
+
children: [/* @__PURE__ */ jsx(CornerDownRightIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
363
|
+
className: FILTER_MENU_LABEL_CLASS,
|
|
364
|
+
children: destination.label
|
|
365
|
+
})]
|
|
366
|
+
}, destination.id)) });
|
|
367
|
+
}
|
|
368
|
+
/** The per-rule actions, without the trigger: the chip's kebab and a builder
|
|
369
|
+
* row's kebab act on the same rule. `allowGrouping` is the CHROME's answer;
|
|
370
|
+
* "Convert to advanced filter" is the CONSUMER's, and hides itself there. */
|
|
371
|
+
function FilterRuleMenuItems({ ruleId, allowGrouping = false }) {
|
|
372
|
+
const actions = useFilterActions();
|
|
373
|
+
const locked = isFilterLocked(actions);
|
|
374
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
375
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
376
|
+
disabled: locked,
|
|
377
|
+
onClick: () => actions.duplicateNode(ruleId),
|
|
378
|
+
children: [/* @__PURE__ */ jsx(CopyIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
379
|
+
className: FILTER_MENU_LABEL_CLASS,
|
|
380
|
+
children: actions.labels.duplicate
|
|
381
|
+
})]
|
|
382
|
+
}),
|
|
383
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
384
|
+
disabled: locked,
|
|
385
|
+
onClick: () => actions.negateRule(ruleId),
|
|
386
|
+
children: [/* @__PURE__ */ jsx(ArrowLeftRightIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
387
|
+
className: FILTER_MENU_LABEL_CLASS,
|
|
388
|
+
children: actions.labels.negate
|
|
389
|
+
})]
|
|
390
|
+
}),
|
|
391
|
+
allowGrouping ? /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
392
|
+
disabled: locked,
|
|
393
|
+
onClick: () => actions.wrapNodeInGroup(ruleId),
|
|
394
|
+
children: [/* @__PURE__ */ jsx(LayersIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
395
|
+
className: FILTER_MENU_LABEL_CLASS,
|
|
396
|
+
children: actions.labels.wrapInGroup
|
|
397
|
+
})]
|
|
398
|
+
}) : null,
|
|
399
|
+
allowGrouping ? /* @__PURE__ */ jsx(FilterMoveToMenuItems, { nodeId: ruleId }) : null,
|
|
400
|
+
actions.convertToAdvanced && actions.variant !== "advanced" ? /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
401
|
+
onClick: () => actions.convertToAdvanced?.(),
|
|
402
|
+
children: [/* @__PURE__ */ jsx(SlidersHorizontalIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
403
|
+
className: FILTER_MENU_LABEL_CLASS,
|
|
404
|
+
children: actions.labels.convertToAdvanced
|
|
405
|
+
})]
|
|
406
|
+
}) : null,
|
|
407
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
408
|
+
variant: "destructive",
|
|
409
|
+
disabled: locked,
|
|
410
|
+
onClick: () => actions.removeNode(ruleId),
|
|
411
|
+
children: [/* @__PURE__ */ jsx(Trash2Icon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
412
|
+
className: FILTER_MENU_LABEL_CLASS,
|
|
413
|
+
children: actions.labels.remove
|
|
414
|
+
})]
|
|
415
|
+
})
|
|
416
|
+
] });
|
|
417
|
+
}
|
|
418
|
+
/** One filter, as a chip. Memoization means something here: the actions
|
|
419
|
+
* context is stable, the focus store is subscribed to a boolean and the query
|
|
420
|
+
* shares structure, so editing one filter of forty re-renders one chip. */
|
|
421
|
+
function FilterChipImpl({ rule, index }) {
|
|
422
|
+
const actions = useFilterActions();
|
|
423
|
+
const render = useFilterRender();
|
|
424
|
+
const focusStore = useFilterFocusStore();
|
|
425
|
+
const focused = useFilterChipFocused(rule.id);
|
|
426
|
+
const noFocus = useFilterFocusEmpty();
|
|
427
|
+
const locked = isFilterLocked(actions);
|
|
428
|
+
const sizes = filterControlSizes(actions);
|
|
429
|
+
const [menuOpen, setMenuOpen] = React$1.useState(false);
|
|
430
|
+
const isTabStop = focused || noFocus && index === 0;
|
|
431
|
+
const field = getFilterField(actions.index, rule.path);
|
|
432
|
+
const operators = field ? actions.resolveOperators(field) : [];
|
|
433
|
+
const operator = getFilterOperator(operators, rule.operator);
|
|
434
|
+
const { pathText, pathLabel, pathCollapsed, operatorLabel, valueLabel, valueText, valueFullText, valueEmpty } = useFilterRuleDisplay(rule, field, operator);
|
|
435
|
+
if (!field) return /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
436
|
+
"data-slot": "filter-chip",
|
|
437
|
+
"data-unknown": "",
|
|
438
|
+
role: "group",
|
|
439
|
+
"aria-label": actions.labels.filterLabel(rule.path.join(actions.labels.pathSeparator)),
|
|
440
|
+
"data-focused": focused || void 0,
|
|
441
|
+
"data-rule-id": rule.id,
|
|
442
|
+
"data-index": index,
|
|
443
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
444
|
+
onFocusCapture: () => {
|
|
445
|
+
if (!focused) focusStore.set({
|
|
446
|
+
id: rule.id,
|
|
447
|
+
segment: null,
|
|
448
|
+
autoOpen: false
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
children: [/* @__PURE__ */ jsx(ButtonGroupText, {
|
|
452
|
+
className: "bg-background text-muted-foreground dark:bg-input/30",
|
|
453
|
+
children: rule.path.join(actions.labels.pathSeparator)
|
|
454
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
455
|
+
variant: "outline",
|
|
456
|
+
size: sizes.icon,
|
|
457
|
+
className: "bg-background dark:bg-input/30",
|
|
458
|
+
"aria-label": actions.labels.remove,
|
|
459
|
+
disabled: actions.disabled,
|
|
460
|
+
...filterReadOnlyProps(actions),
|
|
461
|
+
onClick: () => actions.removeNode(rule.id),
|
|
462
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
463
|
+
})]
|
|
464
|
+
});
|
|
465
|
+
if (render.renderChip) return /* @__PURE__ */ jsx(Fragment$1, { children: render.renderChip(rule) });
|
|
466
|
+
const focusSegment = (segment) => focusStore.set({
|
|
467
|
+
id: rule.id,
|
|
468
|
+
segment,
|
|
469
|
+
autoOpen: false
|
|
470
|
+
});
|
|
471
|
+
const incomplete = !rule.operator;
|
|
472
|
+
const hasValue = Boolean(rule.operator) && operatorTakesValue(operator);
|
|
473
|
+
const valueName = valueEmpty && !field.valueText ? actions.labels.noValue : valueText;
|
|
474
|
+
return /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
475
|
+
"data-slot": "filter-chip",
|
|
476
|
+
role: "group",
|
|
477
|
+
"aria-label": actions.labels.filterLabel(`${pathText} ${operatorLabel}${hasValue ? ` ${valueName}` : ""}`.trim() + (incomplete ? `, ${actions.labels.incomplete}` : "")),
|
|
478
|
+
"data-focused": focused || void 0,
|
|
479
|
+
"data-incomplete": incomplete || void 0,
|
|
480
|
+
"data-rule-id": rule.id,
|
|
481
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
482
|
+
className: cn(""),
|
|
483
|
+
onFocusCapture: () => {
|
|
484
|
+
if (!focused) focusStore.set({
|
|
485
|
+
id: rule.id,
|
|
486
|
+
segment: null,
|
|
487
|
+
autoOpen: false
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
"data-index": index,
|
|
491
|
+
children: [
|
|
492
|
+
/* @__PURE__ */ jsxs(ButtonGroupText, {
|
|
493
|
+
title: pathCollapsed ? void 0 : pathText,
|
|
494
|
+
className: "cursor-default gap-1.5 bg-background dark:bg-input/30",
|
|
495
|
+
children: [field.icon, /* @__PURE__ */ jsx("span", {
|
|
496
|
+
className: "flex items-center",
|
|
497
|
+
children: pathLabel
|
|
498
|
+
})]
|
|
499
|
+
}),
|
|
500
|
+
/* @__PURE__ */ jsx(FilterOperatorPopover, {
|
|
501
|
+
rule,
|
|
502
|
+
field,
|
|
503
|
+
trigger: /* @__PURE__ */ jsx(ButtonGroupText, {
|
|
504
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
505
|
+
className: cn("cursor-default bg-background hover:bg-accent dark:bg-input/30", incomplete ? "text-foreground" : "text-muted-foreground"),
|
|
506
|
+
onPointerDown: () => focusSegment("operator"),
|
|
507
|
+
children: operatorLabel
|
|
508
|
+
})
|
|
509
|
+
}),
|
|
510
|
+
hasValue ? /* @__PURE__ */ jsx(FilterValuePopover, {
|
|
511
|
+
rule,
|
|
512
|
+
field,
|
|
513
|
+
operator,
|
|
514
|
+
trigger: /* @__PURE__ */ jsx(ButtonGroupText, {
|
|
515
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
516
|
+
"aria-label": locked ? valueFullText : valueText,
|
|
517
|
+
title: valueFullText === valueText ? void 0 : valueFullText,
|
|
518
|
+
className: cn("cursor-default bg-background hover:bg-accent dark:bg-input/30", valueEmpty && "text-muted-foreground"),
|
|
519
|
+
onPointerDown: () => focusSegment("value"),
|
|
520
|
+
children: valueLabel
|
|
521
|
+
})
|
|
522
|
+
}) : null,
|
|
523
|
+
/* @__PURE__ */ jsxs(DropdownMenu, {
|
|
524
|
+
open: menuOpen,
|
|
525
|
+
onOpenChange: (next) => {
|
|
526
|
+
if (next && locked) return;
|
|
527
|
+
setMenuOpen(next);
|
|
528
|
+
},
|
|
529
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
530
|
+
disabled: actions.disabled,
|
|
531
|
+
...filterReadOnlyProps(actions),
|
|
532
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
533
|
+
variant: "outline",
|
|
534
|
+
size: sizes.icon,
|
|
535
|
+
className: "bg-background dark:bg-input/30",
|
|
536
|
+
"aria-label": actions.labels.chipMenu(field.label),
|
|
537
|
+
onPointerDown: () => focusSegment("menu")
|
|
538
|
+
}),
|
|
539
|
+
children: /* @__PURE__ */ jsx(EllipsisVerticalIcon, {})
|
|
540
|
+
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
541
|
+
align: "end",
|
|
542
|
+
className: cn(FILTER_MENU_CLASS, actions.menuClassName),
|
|
543
|
+
children: /* @__PURE__ */ jsx(FilterRuleMenuItems, { ruleId: rule.id })
|
|
544
|
+
})]
|
|
545
|
+
})
|
|
546
|
+
]
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
const FilterChip = React$1.memo(FilterChipImpl);
|
|
550
|
+
//#endregion
|
|
551
|
+
export { FilterChip, FilterMoveToMenuItems, FilterOperatorPopover, FilterRuleMenuItems, FilterValuePopover, useFilterRuleDisplay };
|
|
552
|
+
|
|
553
|
+
//# sourceMappingURL=filters-chip.js.map
|