@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,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/reui/filters/filters-operators.tsx
|
|
3
|
+
const DEFAULT_FILTER_OPERATOR_LABELS = {
|
|
4
|
+
contains: "contains",
|
|
5
|
+
not_contains: "does not contain",
|
|
6
|
+
starts_with: "starts with",
|
|
7
|
+
ends_with: "ends with",
|
|
8
|
+
is: "is",
|
|
9
|
+
is_not: "is not",
|
|
10
|
+
is_any_of: "is any of",
|
|
11
|
+
is_none_of: "is none of",
|
|
12
|
+
has_any_of: "has any of",
|
|
13
|
+
has_all_of: "has all of",
|
|
14
|
+
has_none_of: "has none of",
|
|
15
|
+
eq: "equals",
|
|
16
|
+
neq: "does not equal",
|
|
17
|
+
gt: "is greater than",
|
|
18
|
+
gte: "is greater than or equal to",
|
|
19
|
+
lt: "is less than",
|
|
20
|
+
lte: "is less than or equal to",
|
|
21
|
+
between: "is between",
|
|
22
|
+
not_between: "is not between",
|
|
23
|
+
is_before: "is before",
|
|
24
|
+
is_after: "is after",
|
|
25
|
+
is_on_or_before: "is on or before",
|
|
26
|
+
is_on_or_after: "is on or after",
|
|
27
|
+
empty: "is empty",
|
|
28
|
+
not_empty: "is not empty"
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Operator catalog per value type: value, arity, inverse, labels resolved at
|
|
32
|
+
* build time so translating one operator never restates the catalog. `arity`
|
|
33
|
+
* of "none" drops the chip's value segment and the wizard's value step, in a
|
|
34
|
+
* consumer's own `operators` array as much as in this catalog.
|
|
35
|
+
*/
|
|
36
|
+
const CATALOG = {
|
|
37
|
+
text: [
|
|
38
|
+
{
|
|
39
|
+
value: "contains",
|
|
40
|
+
inverse: "not_contains"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
value: "not_contains",
|
|
44
|
+
inverse: "contains"
|
|
45
|
+
},
|
|
46
|
+
{ value: "starts_with" },
|
|
47
|
+
{ value: "ends_with" },
|
|
48
|
+
{
|
|
49
|
+
value: "is",
|
|
50
|
+
inverse: "is_not"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: "is_not",
|
|
54
|
+
inverse: "is"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: "empty",
|
|
58
|
+
arity: "none",
|
|
59
|
+
inverse: "not_empty"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: "not_empty",
|
|
63
|
+
arity: "none",
|
|
64
|
+
inverse: "empty"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
number: [
|
|
68
|
+
{
|
|
69
|
+
value: "eq",
|
|
70
|
+
inverse: "neq"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
value: "neq",
|
|
74
|
+
inverse: "eq"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: "gt",
|
|
78
|
+
inverse: "lte"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "gte",
|
|
82
|
+
inverse: "lt"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
value: "lt",
|
|
86
|
+
inverse: "gte"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
value: "lte",
|
|
90
|
+
inverse: "gt"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
value: "between",
|
|
94
|
+
arity: "range",
|
|
95
|
+
inverse: "not_between"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
value: "not_between",
|
|
99
|
+
arity: "range",
|
|
100
|
+
inverse: "between"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "empty",
|
|
104
|
+
arity: "none",
|
|
105
|
+
inverse: "not_empty"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
value: "not_empty",
|
|
109
|
+
arity: "none",
|
|
110
|
+
inverse: "empty"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
range: [
|
|
114
|
+
{
|
|
115
|
+
value: "between",
|
|
116
|
+
arity: "range",
|
|
117
|
+
inverse: "not_between"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
value: "not_between",
|
|
121
|
+
arity: "range",
|
|
122
|
+
inverse: "between"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
value: "empty",
|
|
126
|
+
arity: "none",
|
|
127
|
+
inverse: "not_empty"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
value: "not_empty",
|
|
131
|
+
arity: "none",
|
|
132
|
+
inverse: "empty"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
select: [
|
|
136
|
+
{
|
|
137
|
+
value: "is",
|
|
138
|
+
inverse: "is_not"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
value: "is_not",
|
|
142
|
+
inverse: "is"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
value: "is_any_of",
|
|
146
|
+
arity: "many",
|
|
147
|
+
inverse: "is_none_of"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: "is_none_of",
|
|
151
|
+
arity: "many",
|
|
152
|
+
inverse: "is_any_of"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
value: "empty",
|
|
156
|
+
arity: "none",
|
|
157
|
+
inverse: "not_empty"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
value: "not_empty",
|
|
161
|
+
arity: "none",
|
|
162
|
+
inverse: "empty"
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
multiselect: [
|
|
166
|
+
{
|
|
167
|
+
value: "has_any_of",
|
|
168
|
+
arity: "many",
|
|
169
|
+
inverse: "has_none_of"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
value: "has_all_of",
|
|
173
|
+
arity: "many"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
value: "has_none_of",
|
|
177
|
+
arity: "many",
|
|
178
|
+
inverse: "has_any_of"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
value: "empty",
|
|
182
|
+
arity: "none",
|
|
183
|
+
inverse: "not_empty"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
value: "not_empty",
|
|
187
|
+
arity: "none",
|
|
188
|
+
inverse: "empty"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
boolean: [
|
|
192
|
+
{
|
|
193
|
+
value: "is",
|
|
194
|
+
inverse: "is_not"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: "is_not",
|
|
198
|
+
inverse: "is"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
value: "empty",
|
|
202
|
+
arity: "none",
|
|
203
|
+
inverse: "not_empty"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
value: "not_empty",
|
|
207
|
+
arity: "none",
|
|
208
|
+
inverse: "empty"
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
};
|
|
212
|
+
const DEFAULT_FILTER_VALUE_TYPE = "text";
|
|
213
|
+
/**
|
|
214
|
+
* Builds the operator catalog for one set of labels. Callers memoize on the
|
|
215
|
+
* label object: the old primitive built its equivalent inside
|
|
216
|
+
* `getOperatorsForField`, keyed on a `values` array that was fresh after every
|
|
217
|
+
* filter update, so every miss reallocated four arrays of 27 objects each.
|
|
218
|
+
*/
|
|
219
|
+
function createFilterOperators(labels) {
|
|
220
|
+
const built = {};
|
|
221
|
+
for (const type of Object.keys(CATALOG)) built[type] = CATALOG[type].map((entry) => ({
|
|
222
|
+
value: entry.value,
|
|
223
|
+
label: labels[entry.value] ?? entry.value,
|
|
224
|
+
arity: entry.arity ?? "one",
|
|
225
|
+
inverse: entry.inverse
|
|
226
|
+
}));
|
|
227
|
+
return built;
|
|
228
|
+
}
|
|
229
|
+
const DEFAULT_FILTER_OPERATORS = createFilterOperators(DEFAULT_FILTER_OPERATOR_LABELS);
|
|
230
|
+
/**
|
|
231
|
+
* The operators for a field: its own `operators` wins, array or function,
|
|
232
|
+
* otherwise the catalog entry for its `type`. No implicit select to multiselect
|
|
233
|
+
* promotion by selection count: that changed the list as the user picked.
|
|
234
|
+
*/
|
|
235
|
+
function resolveFilterOperators(field, catalog = DEFAULT_FILTER_OPERATORS) {
|
|
236
|
+
if (typeof field.operators === "function") return field.operators(field);
|
|
237
|
+
if (field.operators) return field.operators;
|
|
238
|
+
return catalog[field.type ?? "text"] ?? catalog.text;
|
|
239
|
+
}
|
|
240
|
+
function visibleFilterOperators(operators) {
|
|
241
|
+
return operators.filter((operator) => !operator.hidden);
|
|
242
|
+
}
|
|
243
|
+
function getFilterOperator(operators, value) {
|
|
244
|
+
if (!value) return void 0;
|
|
245
|
+
return operators.find((operator) => operator.value === value);
|
|
246
|
+
}
|
|
247
|
+
function getFilterArity(operator) {
|
|
248
|
+
return operator?.arity ?? "one";
|
|
249
|
+
}
|
|
250
|
+
function operatorTakesValue(operator) {
|
|
251
|
+
return getFilterArity(operator) !== "none";
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The operator a field starts with: `defaultOperator` when it names one the
|
|
255
|
+
* field offers, otherwise the first visible operator. Falling back rather than
|
|
256
|
+
* trusting the schema keeps the rule out of a state its own list cannot show.
|
|
257
|
+
*/
|
|
258
|
+
function getDefaultFilterOperator(field, operators) {
|
|
259
|
+
if (field.defaultOperator) {
|
|
260
|
+
const named = getFilterOperator(operators, field.defaultOperator);
|
|
261
|
+
if (named) return named.value;
|
|
262
|
+
}
|
|
263
|
+
return visibleFilterOperators(operators)[0]?.value ?? operators[0]?.value ?? null;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Negating a rule: swap to the declared `inverse` so the chip reads "does not
|
|
267
|
+
* contain", else toggle `negated` so Negate still works without an inverse.
|
|
268
|
+
*/
|
|
269
|
+
function negateFilterOperator(operator, operators, negated) {
|
|
270
|
+
if (operator?.inverse) {
|
|
271
|
+
const inverse = getFilterOperator(operators, operator.inverse);
|
|
272
|
+
if (inverse) return {
|
|
273
|
+
operator: inverse.value,
|
|
274
|
+
negated: Boolean(negated)
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
operator: operator?.value ?? null,
|
|
279
|
+
negated: !negated
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Reshapes a value when arity changes: widening "is" to "is any of" keeps what
|
|
284
|
+
* the user picked, narrowing keeps the first of them, `"none"` always drops it.
|
|
285
|
+
*/
|
|
286
|
+
function coerceFilterValue(value, from, to) {
|
|
287
|
+
const nextArity = getFilterArity(to);
|
|
288
|
+
if (nextArity === "none") return void 0;
|
|
289
|
+
if (value === void 0 || value === null) return value;
|
|
290
|
+
if (getFilterArity(from) === nextArity) return value;
|
|
291
|
+
const asArray = Array.isArray(value) ? value : [value];
|
|
292
|
+
if (nextArity === "many") return asArray;
|
|
293
|
+
if (nextArity === "one") return asArray[0];
|
|
294
|
+
if (nextArity === "range") return [asArray[0], asArray[1]];
|
|
295
|
+
return value;
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
export { DEFAULT_FILTER_OPERATORS, DEFAULT_FILTER_OPERATOR_LABELS, DEFAULT_FILTER_VALUE_TYPE, coerceFilterValue, createFilterOperators, getDefaultFilterOperator, getFilterArity, getFilterOperator, negateFilterOperator, operatorTakesValue, resolveFilterOperators, visibleFilterOperators };
|
|
299
|
+
|
|
300
|
+
//# sourceMappingURL=filters-operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters-operators.js","names":[],"sources":["../../../../src/components/reui/filters/filters-operators.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FilterField, FilterOperator, FilterValueType } from \"./filters-types\";\n\n/**\n * Every operator label, keyed by value. Split from `FilterLabels`: operator\n * wording is reworded per domain, chrome copy is translated once per app.\n */\nexport type FilterOperatorLabels = Record<string, string>;\n\nexport const DEFAULT_FILTER_OPERATOR_LABELS: FilterOperatorLabels = {\n contains: \"contains\",\n not_contains: \"does not contain\",\n starts_with: \"starts with\",\n ends_with: \"ends with\",\n is: \"is\",\n is_not: \"is not\",\n is_any_of: \"is any of\",\n is_none_of: \"is none of\",\n has_any_of: \"has any of\",\n has_all_of: \"has all of\",\n has_none_of: \"has none of\",\n eq: \"equals\",\n neq: \"does not equal\",\n gt: \"is greater than\",\n gte: \"is greater than or equal to\",\n lt: \"is less than\",\n lte: \"is less than or equal to\",\n between: \"is between\",\n not_between: \"is not between\",\n is_before: \"is before\",\n is_after: \"is after\",\n is_on_or_before: \"is on or before\",\n is_on_or_after: \"is on or after\",\n empty: \"is empty\",\n not_empty: \"is not empty\",\n};\n\n/**\n * Operator catalog per value type: value, arity, inverse, labels resolved at\n * build time so translating one operator never restates the catalog. `arity`\n * of \"none\" drops the chip's value segment and the wizard's value step, in a\n * consumer's own `operators` array as much as in this catalog.\n */\nconst CATALOG: Record<\n FilterValueType,\n { value: string; arity?: FilterOperator[\"arity\"]; inverse?: string }[]\n> = {\n text: [\n { value: \"contains\", inverse: \"not_contains\" },\n { value: \"not_contains\", inverse: \"contains\" },\n { value: \"starts_with\" },\n { value: \"ends_with\" },\n { value: \"is\", inverse: \"is_not\" },\n { value: \"is_not\", inverse: \"is\" },\n { value: \"empty\", arity: \"none\", inverse: \"not_empty\" },\n { value: \"not_empty\", arity: \"none\", inverse: \"empty\" },\n ],\n number: [\n { value: \"eq\", inverse: \"neq\" },\n { value: \"neq\", inverse: \"eq\" },\n { value: \"gt\", inverse: \"lte\" },\n { value: \"gte\", inverse: \"lt\" },\n { value: \"lt\", inverse: \"gte\" },\n { value: \"lte\", inverse: \"gt\" },\n { value: \"between\", arity: \"range\", inverse: \"not_between\" },\n { value: \"not_between\", arity: \"range\", inverse: \"between\" },\n { value: \"empty\", arity: \"none\", inverse: \"not_empty\" },\n { value: \"not_empty\", arity: \"none\", inverse: \"empty\" },\n ],\n range: [\n { value: \"between\", arity: \"range\", inverse: \"not_between\" },\n { value: \"not_between\", arity: \"range\", inverse: \"between\" },\n { value: \"empty\", arity: \"none\", inverse: \"not_empty\" },\n { value: \"not_empty\", arity: \"none\", inverse: \"empty\" },\n ],\n select: [\n { value: \"is\", inverse: \"is_not\" },\n { value: \"is_not\", inverse: \"is\" },\n { value: \"is_any_of\", arity: \"many\", inverse: \"is_none_of\" },\n { value: \"is_none_of\", arity: \"many\", inverse: \"is_any_of\" },\n { value: \"empty\", arity: \"none\", inverse: \"not_empty\" },\n { value: \"not_empty\", arity: \"none\", inverse: \"empty\" },\n ],\n multiselect: [\n { value: \"has_any_of\", arity: \"many\", inverse: \"has_none_of\" },\n { value: \"has_all_of\", arity: \"many\" },\n { value: \"has_none_of\", arity: \"many\", inverse: \"has_any_of\" },\n { value: \"empty\", arity: \"none\", inverse: \"not_empty\" },\n { value: \"not_empty\", arity: \"none\", inverse: \"empty\" },\n ],\n boolean: [\n { value: \"is\", inverse: \"is_not\" },\n { value: \"is_not\", inverse: \"is\" },\n { value: \"empty\", arity: \"none\", inverse: \"not_empty\" },\n { value: \"not_empty\", arity: \"none\", inverse: \"empty\" },\n ],\n};\n\nexport const DEFAULT_FILTER_VALUE_TYPE: FilterValueType = \"text\";\n\n/**\n * Builds the operator catalog for one set of labels. Callers memoize on the\n * label object: the old primitive built its equivalent inside\n * `getOperatorsForField`, keyed on a `values` array that was fresh after every\n * filter update, so every miss reallocated four arrays of 27 objects each.\n */\nexport function createFilterOperators(\n labels: FilterOperatorLabels,\n): Record<FilterValueType, FilterOperator[]> {\n const built = {} as Record<FilterValueType, FilterOperator[]>;\n for (const type of Object.keys(CATALOG) as FilterValueType[]) {\n built[type] = CATALOG[type].map((entry) => ({\n value: entry.value,\n label: labels[entry.value] ?? entry.value,\n arity: entry.arity ?? \"one\",\n inverse: entry.inverse,\n }));\n }\n return built;\n}\n\nexport const DEFAULT_FILTER_OPERATORS: Record<FilterValueType, FilterOperator[]> =\n createFilterOperators(DEFAULT_FILTER_OPERATOR_LABELS);\n\n/**\n * The operators for a field: its own `operators` wins, array or function,\n * otherwise the catalog entry for its `type`. No implicit select to multiselect\n * promotion by selection count: that changed the list as the user picked.\n */\nexport function resolveFilterOperators<V, O>(\n field: FilterField<V, O>,\n catalog: Record<FilterValueType, FilterOperator[]> = DEFAULT_FILTER_OPERATORS,\n): FilterOperator[] {\n if (typeof field.operators === \"function\") return field.operators(field);\n if (field.operators) return field.operators;\n return catalog[field.type ?? DEFAULT_FILTER_VALUE_TYPE] ?? catalog.text;\n}\n\nexport function visibleFilterOperators(operators: readonly FilterOperator[]): FilterOperator[] {\n return operators.filter((operator) => !operator.hidden);\n}\n\nexport function getFilterOperator(\n operators: readonly FilterOperator[],\n value: string | null | undefined,\n): FilterOperator | undefined {\n if (!value) return undefined;\n return operators.find((operator) => operator.value === value);\n}\n\nexport function getFilterArity(operator: FilterOperator | undefined): FilterOperator[\"arity\"] {\n return operator?.arity ?? \"one\";\n}\n\nexport function operatorTakesValue(operator: FilterOperator | undefined): boolean {\n return getFilterArity(operator) !== \"none\";\n}\n\n/**\n * The operator a field starts with: `defaultOperator` when it names one the\n * field offers, otherwise the first visible operator. Falling back rather than\n * trusting the schema keeps the rule out of a state its own list cannot show.\n */\nexport function getDefaultFilterOperator<V, O>(\n field: FilterField<V, O>,\n operators: readonly FilterOperator[],\n): string | null {\n if (field.defaultOperator) {\n const named = getFilterOperator(operators, field.defaultOperator);\n if (named) return named.value;\n }\n const visible = visibleFilterOperators(operators);\n return visible[0]?.value ?? operators[0]?.value ?? null;\n}\n\n/**\n * Negating a rule: swap to the declared `inverse` so the chip reads \"does not\n * contain\", else toggle `negated` so Negate still works without an inverse.\n */\nexport function negateFilterOperator(\n operator: FilterOperator | undefined,\n operators: readonly FilterOperator[],\n negated: boolean | undefined,\n): { operator: string | null; negated: boolean } {\n if (operator?.inverse) {\n const inverse = getFilterOperator(operators, operator.inverse);\n if (inverse) return { operator: inverse.value, negated: Boolean(negated) };\n }\n return { operator: operator?.value ?? null, negated: !negated };\n}\n\n/**\n * Reshapes a value when arity changes: widening \"is\" to \"is any of\" keeps what\n * the user picked, narrowing keeps the first of them, `\"none\"` always drops it.\n */\nexport function coerceFilterValue(\n value: unknown,\n from: FilterOperator | undefined,\n to: FilterOperator | undefined,\n): unknown {\n const nextArity = getFilterArity(to);\n if (nextArity === \"none\") return undefined;\n if (value === undefined || value === null) return value;\n\n const previousArity = getFilterArity(from);\n if (previousArity === nextArity) return value;\n\n const asArray = Array.isArray(value) ? value : [value];\n\n if (nextArity === \"many\") return asArray;\n if (nextArity === \"one\") return asArray[0];\n if (nextArity === \"range\") {\n return [asArray[0], asArray[1]] as [unknown, unknown];\n }\n return value;\n}\n"],"mappings":";;AAUA,MAAa,iCAAuD;CAClE,UAAU;CACV,cAAc;CACd,aAAa;CACb,WAAW;CACX,IAAI;CACJ,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,SAAS;CACT,aAAa;CACb,WAAW;CACX,UAAU;CACV,iBAAiB;CACjB,gBAAgB;CAChB,OAAO;CACP,WAAW;AACb;;;;;;;AAQA,MAAM,UAGF;CACF,MAAM;EACJ;GA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AU,SAAS;AAC5B;AAEA,SAAgB,mBAAmB,UAA+C;CAChF,OAAO,eAAe,QAAQ,MAAM;AACtC;;;;;;AAOA,SAAgB,yBACd,OACA,WACe;CACf,IAAI,MAAM,iBAAiB;EACzB,MAAM,QAAQ,kBAAkB,WAAW,MAAM,eAAe;EAChE,IAAI,OAAO,OAAO,MAAM;CAC1B;CAEA,OADgB,uBAAuB,SAC1B,CAAC,CAAC,EAAE,EAAE,SAAS,UAAU,EAAE,EAAE,SAAS;AACrD;;;;;AAMA,SAAgB,qBACd,UACA,WACA,SAC+C;CAC/C,IAAI,UAAU,SAAS;EACrB,MAAM,UAAU,kBAAkB,WAAW,SAAS,OAAO;EAC7D,IAAI,SAAS,OAAO;GAAE,UAAU,QAAQ;GAAO,SAAS,QAAQ,OAAO;EAAE;CAC3E;CACA,OAAO;EAAE,UAAU,UAAU,SAAS;EAAM,SAAS,CAAC;CAAQ;AAChE;;;;;AAMA,SAAgB,kBACd,OACA,MACA,IACS;CACT,MAAM,YAAY,eAAe,EAAE;CACnC,IAAI,cAAc,QAAQ,OAAO,KAAA;CACjC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAGlD,IADsB,eAAe,IACrB,MAAM,WAAW,OAAO;CAExC,MAAM,UAAU,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;CAErD,IAAI,cAAc,QAAQ,OAAO;CACjC,IAAI,cAAc,OAAO,OAAO,QAAQ;CACxC,IAAI,cAAc,SAChB,OAAO,CAAC,QAAQ,IAAI,QAAQ,EAAE;CAEhC,OAAO;AACT"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { FilterCombinator, FilterGroupNode, FilterIssue, FilterNode, FilterOperator, FilterQuery, FilterRule } from "./filters-types.js";
|
|
2
|
+
//#region src/components/reui/filters/filters-query.d.ts
|
|
3
|
+
declare function isFilterRule<V>(node: FilterNode<V>): node is FilterRule<V>;
|
|
4
|
+
declare function isFilterGroup<V>(node: FilterNode<V>): node is FilterGroupNode<V>;
|
|
5
|
+
/**
|
|
6
|
+
* A rule. `id` is passed in, never generated here: a non-deterministic value in
|
|
7
|
+
* a pure function broke hydration. Callers use `createFilterIdFactory`.
|
|
8
|
+
*/
|
|
9
|
+
declare function createFilterRule<V = unknown>(input: {
|
|
10
|
+
id: string;
|
|
11
|
+
path: string[];
|
|
12
|
+
operator: string;
|
|
13
|
+
value?: V;
|
|
14
|
+
negated?: boolean;
|
|
15
|
+
}): FilterRule<V>;
|
|
16
|
+
declare function createFilterGroup<V = unknown>(input: {
|
|
17
|
+
id: string;
|
|
18
|
+
combinator?: FilterCombinator;
|
|
19
|
+
rules?: FilterNode<V>[];
|
|
20
|
+
}): FilterGroupNode<V>;
|
|
21
|
+
/** An empty query. The root is always a group, never a bare array. */
|
|
22
|
+
declare function createFilterQuery<V = unknown>(rules?: FilterNode<V>[], combinator?: FilterCombinator, id?: string): FilterQuery<V>;
|
|
23
|
+
/** Every rule in the tree, depth first. Groups are flattened away. */
|
|
24
|
+
declare function flattenFilterRules<V>(query: FilterQuery<V>): FilterRule<V>[];
|
|
25
|
+
/**
|
|
26
|
+
* One rule, flattened for a predicate. `values` is always an array even though
|
|
27
|
+
* `FilterRule.value` is singular, so no caller re-derives arity.
|
|
28
|
+
*/
|
|
29
|
+
interface FilterCondition {
|
|
30
|
+
/** Full field path, `["name", "first"]`. */
|
|
31
|
+
path: string[];
|
|
32
|
+
/** First path segment, for the common flat-schema case. */
|
|
33
|
+
field: string;
|
|
34
|
+
operator: string;
|
|
35
|
+
/** `[]` for an operator that takes no value. */
|
|
36
|
+
values: unknown[];
|
|
37
|
+
negated: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether a rule says anything yet. A rule exists as soon as an attribute is
|
|
41
|
+
* picked, so `operator: ""` is a real state: `flattenFilterConditions` leaves
|
|
42
|
+
* it out, `countFilterRules` still counts it, and `collectFilterIssues` reports
|
|
43
|
+
* it as `missing-operator`.
|
|
44
|
+
*/
|
|
45
|
+
declare function isFilterRuleComplete<V>(rule: FilterRule<V>): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Flattens a query to conditions. Lossy: safe only when the query is flat or
|
|
48
|
+
* every group shares the root's combinator. Read `query.combinator` and walk
|
|
49
|
+
* the tree yourself for anything else. Incomplete rules are left out.
|
|
50
|
+
*/
|
|
51
|
+
declare function flattenFilterConditions<V>(query: FilterQuery<V>): FilterCondition[];
|
|
52
|
+
/** How many rules the query holds, at any depth. */
|
|
53
|
+
declare function countFilterRules<V>(query: FilterQuery<V>): number;
|
|
54
|
+
/** Whether the query would match everything. */
|
|
55
|
+
declare function isFilterQueryEmpty<V>(query: FilterQuery<V>): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* How an arity is answered for one rule. The caller resolves it, since arity
|
|
58
|
+
* lives on the FIELD's operator list. `null` is a rule it cannot judge.
|
|
59
|
+
*/
|
|
60
|
+
type FilterArityResolver<V> = (rule: FilterRule<V>) => FilterOperator["arity"] | null;
|
|
61
|
+
/** Runs a field's own `validate`. A resolver like `arityOf`: no schema here. */
|
|
62
|
+
type FilterValidateResolver<V> = (rule: FilterRule<V>) => string | null | undefined | false;
|
|
63
|
+
/**
|
|
64
|
+
* Every reason a query cannot be run as written, in document order: the five
|
|
65
|
+
* ways this builder can hold a condition that SILENTLY does the wrong thing.
|
|
66
|
+
* `missing-operator` and `empty-group` carry no predicate and are dropped by
|
|
67
|
+
* `flattenFilterConditions`; `missing-value` reaches the consumer with a
|
|
68
|
+
* `values` array that is empty or all blank, which most backends read as
|
|
69
|
+
* "match nothing"; `incomplete-range` is the same for a range and often
|
|
70
|
+
* arrives with one bound FILLED, so an emptiness check will not catch it;
|
|
71
|
+
* `reversed-range` is legal and matches nothing anywhere. A group of exactly
|
|
72
|
+
* ONE node is NOT an issue (it is what "Convert to group" produces), and the
|
|
73
|
+
* root is exempt from `empty-group`.
|
|
74
|
+
*/
|
|
75
|
+
declare function collectFilterIssues<V>(query: FilterQuery<V>, arityOf: FilterArityResolver<V>, validateOf?: FilterValidateResolver<V>): FilterIssue[];
|
|
76
|
+
/** Locates a node and its parent. Returns null when the id is unknown. */
|
|
77
|
+
declare function findFilterNode<V>(query: FilterQuery<V>, id: string): {
|
|
78
|
+
node: FilterNode<V>;
|
|
79
|
+
parent: FilterGroupNode<V> | null;
|
|
80
|
+
index: number;
|
|
81
|
+
} | null;
|
|
82
|
+
/** The rule with this id, or null when the id names a group or is unknown. */
|
|
83
|
+
declare function findFilterRule<V>(query: FilterQuery<V>, id: string): FilterRule<V> | null;
|
|
84
|
+
/** Replaces a rule's fields. Unknown ids return the query unchanged. */
|
|
85
|
+
declare function updateFilterRule<V>(query: FilterQuery<V>, id: string, updates: Partial<Omit<FilterRule<V>, "id" | "type">>): FilterQuery<V>;
|
|
86
|
+
/**
|
|
87
|
+
* Removes a node, plus any group it empties, all the way up (not the root): an
|
|
88
|
+
* empty group is invisible in the flat UI yet still compiles to parentheses.
|
|
89
|
+
*/
|
|
90
|
+
declare function removeFilterNode<V>(query: FilterQuery<V>, id: string): FilterQuery<V>;
|
|
91
|
+
/** Appends a node to a group, defaulting to the root. */
|
|
92
|
+
declare function insertFilterNode<V>(query: FilterQuery<V>, node: FilterNode<V>, parentId?: string, index?: number): FilterQuery<V>;
|
|
93
|
+
/** Copies a node in beside the original. */
|
|
94
|
+
declare function duplicateFilterNode<V>(query: FilterQuery<V>, id: string, nextId: () => string): FilterQuery<V>;
|
|
95
|
+
declare function setFilterCombinator<V>(query: FilterQuery<V>, groupId: string, combinator: FilterCombinator): FilterQuery<V>;
|
|
96
|
+
declare function toggleFilterCombinator<V>(query: FilterQuery<V>, groupId: string): FilterQuery<V>;
|
|
97
|
+
/** Moves a node within its own group. Out of range moves are no-ops. */
|
|
98
|
+
declare function moveFilterNode<V>(query: FilterQuery<V>, id: string, delta: number): FilterQuery<V>;
|
|
99
|
+
/**
|
|
100
|
+
* Moves a node into another group, at an index: the cross-parent form of
|
|
101
|
+
* `moveFilterNode`, which only reorders within one parent. Refuses a group into
|
|
102
|
+
* itself or a descendant, which would leave a cycle, and refuses the root.
|
|
103
|
+
*/
|
|
104
|
+
declare function moveFilterNodeTo<V>(query: FilterQuery<V>, id: string, parentId: string, index: number): FilterQuery<V>;
|
|
105
|
+
/**
|
|
106
|
+
* Copies a node into a group at a position: the Alt path of the drag layer. Not
|
|
107
|
+
* `duplicateFilterNode` then `moveFilterNodeTo`, which emits two queries for one
|
|
108
|
+
* gesture and needs the id the first step minted and never returned. The clone
|
|
109
|
+
* is taken BEFORE the insert, so copying a group into itself stays finite.
|
|
110
|
+
*/
|
|
111
|
+
declare function copyFilterNodeTo<V>(query: FilterQuery<V>, id: string, parentId: string, index: number, nextId: () => string): FilterQuery<V>;
|
|
112
|
+
/**
|
|
113
|
+
* Wraps a node in a new group: the "Wrap in condition group" action, and the
|
|
114
|
+
* keyboard path to nesting for a user who cannot drag.
|
|
115
|
+
*/
|
|
116
|
+
declare function wrapFilterNodeInGroup<V>(query: FilterQuery<V>, id: string, groupId: string, combinator?: FilterCombinator): FilterQuery<V>;
|
|
117
|
+
/**
|
|
118
|
+
* Dissolves a group into its parent, splicing its rules in at the position the
|
|
119
|
+
* group held so wrap and unwrap round-trip. The root, a rule id and an unknown
|
|
120
|
+
* id each return the query unchanged.
|
|
121
|
+
*/
|
|
122
|
+
declare function unwrapFilterGroup<V>(query: FilterQuery<V>, groupId: string): FilterQuery<V>;
|
|
123
|
+
/** Empties the query, keeping the root's identity fields. */
|
|
124
|
+
declare function clearFilterQuery<V>(query: FilterQuery<V>): FilterQuery<V>;
|
|
125
|
+
/**
|
|
126
|
+
* Drops empty groups and collapses a group whose only child is a group. Not
|
|
127
|
+
* automatic: a user mid-edit may hold an almost-empty group. Call on persist.
|
|
128
|
+
*/
|
|
129
|
+
declare function pruneFilterQuery<V>(query: FilterQuery<V>): FilterQuery<V>;
|
|
130
|
+
//#endregion
|
|
131
|
+
export { FilterArityResolver, FilterCondition, FilterValidateResolver, clearFilterQuery, collectFilterIssues, copyFilterNodeTo, countFilterRules, createFilterGroup, createFilterQuery, createFilterRule, duplicateFilterNode, findFilterNode, findFilterRule, flattenFilterConditions, flattenFilterRules, insertFilterNode, isFilterGroup, isFilterQueryEmpty, isFilterRule, isFilterRuleComplete, moveFilterNode, moveFilterNodeTo, pruneFilterQuery, removeFilterNode, setFilterCombinator, toggleFilterCombinator, unwrapFilterGroup, updateFilterRule, wrapFilterNodeInGroup };
|
|
132
|
+
//# sourceMappingURL=filters-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters-query.d.ts","names":[],"sources":["../../../../src/components/reui/filters/filters-query.tsx"],"mappings":";;iBAYgB,aAAa,GAAG,MAAM,WAAW,KAAK,QAAQ,WAAW;iBAIzD,cAAc,GAAG,MAAM,WAAW,KAAK,QAAQ,gBAAgB;;;;;iBAQ/D,iBAAiB,aAAa;EAC5C;EACA;EACA;EACA,QAAQ;EACR;IACE,WAAW;iBAYC,kBAAkB,aAAa;EAC7C;EACA,aAAa;EACb,QAAQ,WAAW;IACjB,gBAAgB;;iBAUJ,kBAAkB,aAChC,QAAO,WAAW,MAClB,aAAY,kBACZ,cACC,YAAY;;iBAKC,mBAAmB,GAAG,OAAO,YAAY,KAAK,WAAW;;;;;UAiBxD;;EAEf;;EAEA;EACA;;EAEA;EACA;;;;;;;;iBASc,qBAAqB,GAAG,MAAM,WAAW;;;;;;iBASzC,wBAAwB,GAAG,OAAO,YAAY,KAAK;;iBAkBnD,iBAAiB,GAAG,OAAO,YAAY;;iBAcvC,mBAAmB,GAAG,OAAO,YAAY;;;;;KAQ7C,oBAAoB,MAAM,MAAM,WAAW,OAAO;;KAGlD,uBAAuB,MAAM,MAAM,WAAW;;;;;;;;;;;;;iBAyC1C,oBAAoB,GAClC,OAAO,YAAY,IACnB,SAAS,oBAAoB,IAC7B,aAAa,uBAAuB,KACnC;;iBA0Fa,eAAe,GAC7B,OAAO,YAAY,IACnB;EAEA,MAAM,WAA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