@seekalfred/primitives 0.6.0 → 0.7.1
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 +19 -11
- package/dist/activity-heatmap/activity-heatmap.d.ts +92 -0
- package/dist/activity-heatmap/activity-heatmap.js +699 -0
- package/dist/activity-heatmap/activity-heatmap.js.map +1 -0
- package/dist/activity-heatmap/index.d.ts +2 -0
- package/dist/activity-heatmap/index.js +2 -0
- package/dist/alert/alert.d.ts +5 -1
- package/dist/alert/alert.js +68 -7
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +45 -18
- package/dist/alert-dialog/alert-dialog.js +128 -9
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/alert-dialog/index.d.ts +2 -2
- package/dist/alert-dialog/index.js +2 -2
- package/dist/animated-counter/animated-counter.d.ts +38 -0
- package/dist/animated-counter/animated-counter.js +230 -0
- package/dist/animated-counter/animated-counter.js.map +1 -0
- package/dist/animated-counter/index.d.ts +2 -0
- package/dist/animated-counter/index.js +2 -0
- package/dist/announcement-bar/announcement-bar.d.ts +67 -0
- package/dist/announcement-bar/announcement-bar.js +364 -0
- package/dist/announcement-bar/announcement-bar.js.map +1 -0
- package/dist/announcement-bar/index.d.ts +2 -0
- package/dist/announcement-bar/index.js +2 -0
- package/dist/badge/badge.d.ts +1 -1
- package/dist/bar-chart/bar-chart.d.ts +51 -0
- package/dist/bar-chart/bar-chart.js +565 -0
- package/dist/bar-chart/bar-chart.js.map +1 -0
- package/dist/bar-chart/index.d.ts +2 -0
- package/dist/bar-chart/index.js +2 -0
- package/dist/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/breadcrumb/breadcrumb.js +12 -3
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/brush-chart/brush-chart.d.ts +64 -0
- package/dist/brush-chart/brush-chart.js +1056 -0
- package/dist/brush-chart/brush-chart.js.map +1 -0
- package/dist/brush-chart/index.d.ts +2 -0
- package/dist/brush-chart/index.js +2 -0
- package/dist/button/button.d.ts +2 -2
- package/dist/button/button.js +31 -21
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.js +3 -4
- package/dist/button-group/button-group.js.map +1 -1
- package/dist/card/card.js +1 -1
- package/dist/card/card.js.map +1 -1
- package/dist/card-stack/card-stack.d.ts +54 -0
- package/dist/card-stack/card-stack.js +492 -0
- package/dist/card-stack/card-stack.js.map +1 -0
- package/dist/card-stack/index.d.ts +2 -0
- package/dist/card-stack/index.js +2 -0
- package/dist/carousel/carousel.d.ts +56 -0
- package/dist/carousel/carousel.js +389 -0
- package/dist/carousel/carousel.js.map +1 -0
- package/dist/carousel/index.d.ts +2 -0
- package/dist/carousel/index.js +2 -0
- package/dist/checkbox/checkbox.js +4 -4
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/chip-group/chip-group.d.ts +37 -0
- package/dist/chip-group/chip-group.js +148 -0
- package/dist/chip-group/chip-group.js.map +1 -0
- package/dist/chip-group/index.d.ts +2 -0
- package/dist/chip-group/index.js +2 -0
- package/dist/countdown/countdown.d.ts +45 -0
- package/dist/countdown/countdown.js +298 -0
- package/dist/countdown/countdown.js.map +1 -0
- package/dist/countdown/index.d.ts +2 -0
- package/dist/countdown/index.js +2 -0
- package/dist/date-picker/picker-parts.js +1 -1
- package/dist/date-picker/picker-parts.js.map +1 -1
- package/dist/dialog/dialog.js +1 -1
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/donut-chart/donut-chart.d.ts +64 -0
- package/dist/donut-chart/donut-chart.js +576 -0
- package/dist/donut-chart/donut-chart.js.map +1 -0
- package/dist/donut-chart/index.d.ts +2 -0
- package/dist/donut-chart/index.js +2 -0
- package/dist/empty-state/empty-state.d.ts +21 -10
- package/dist/empty-state/empty-state.js +32 -26
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/empty-state/index.d.ts +2 -2
- package/dist/empty-state/index.js +2 -2
- package/dist/file-drop-zone/file-drop-zone.js +1 -1
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/filter-bar/filter-bar.d.ts +47 -26
- package/dist/filter-bar/filter-bar.js +272 -156
- package/dist/filter-bar/filter-bar.js.map +1 -1
- package/dist/gauge/gauge.d.ts +45 -0
- package/dist/gauge/gauge.js +219 -0
- package/dist/gauge/gauge.js.map +1 -0
- package/dist/gauge/index.d.ts +2 -0
- package/dist/gauge/index.js +2 -0
- package/dist/in-view-title/in-view-title.d.ts +33 -0
- package/dist/in-view-title/in-view-title.js +119 -0
- package/dist/in-view-title/in-view-title.js.map +1 -0
- package/dist/in-view-title/index.d.ts +2 -0
- package/dist/in-view-title/index.js +2 -0
- package/dist/index.d.ts +49 -6
- package/dist/index.js +48 -8
- package/dist/lib/cn.js +11 -1
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/field-message.js +28 -10
- package/dist/lib/field-message.js.map +1 -1
- package/dist/lib/field-surface.js +9 -8
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/flag-emoji.js +50 -0
- package/dist/lib/flag-emoji.js.map +1 -0
- package/dist/lib/flip.js +11 -3
- package/dist/lib/flip.js.map +1 -1
- package/dist/lib/menu-highlight.js +64 -0
- package/dist/lib/menu-highlight.js.map +1 -0
- package/dist/lib/motion.js +9 -2
- package/dist/lib/motion.js.map +1 -1
- package/dist/lib/rolling-value.js +1 -1
- package/dist/lib/rolling-value.js.map +1 -1
- package/dist/lib/spring-tween.js +500 -0
- package/dist/lib/spring-tween.js.map +1 -0
- package/dist/lib/swap-text.js +3 -1
- package/dist/lib/swap-text.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -0
- package/dist/line-chart/index.js +2 -0
- package/dist/line-chart/line-chart.d.ts +76 -0
- package/dist/line-chart/line-chart.js +611 -0
- package/dist/line-chart/line-chart.js.map +1 -0
- package/dist/mention-input/index.d.ts +2 -0
- package/dist/mention-input/index.js +2 -0
- package/dist/mention-input/mention-input.d.ts +98 -0
- package/dist/mention-input/mention-input.js +576 -0
- package/dist/mention-input/mention-input.js.map +1 -0
- package/dist/menu/menu.d.ts +2 -0
- package/dist/menu/menu.js +23 -12
- package/dist/menu/menu.js.map +1 -1
- package/dist/money-input/index.d.ts +2 -0
- package/dist/money-input/index.js +2 -0
- package/dist/money-input/money-input.d.ts +65 -0
- package/dist/money-input/money-input.js +607 -0
- package/dist/money-input/money-input.js.map +1 -0
- package/dist/morph-select/index.d.ts +2 -0
- package/dist/morph-select/index.js +2 -0
- package/dist/morph-select/morph-select.d.ts +71 -0
- package/dist/morph-select/morph-select.js +693 -0
- package/dist/morph-select/morph-select.js.map +1 -0
- package/dist/multi-select/index.d.ts +2 -0
- package/dist/multi-select/index.js +2 -0
- package/dist/multi-select/multi-select.d.ts +36 -0
- package/dist/multi-select/multi-select.js +152 -0
- package/dist/multi-select/multi-select.js.map +1 -0
- package/dist/number-field/index.d.ts +2 -0
- package/dist/number-field/index.js +2 -0
- package/dist/number-field/number-field.d.ts +42 -0
- package/dist/number-field/number-field.js +199 -0
- package/dist/number-field/number-field.js.map +1 -0
- package/dist/onboarding-checklist/index.d.ts +2 -0
- package/dist/onboarding-checklist/index.js +2 -0
- package/dist/onboarding-checklist/onboarding-checklist.d.ts +55 -0
- package/dist/onboarding-checklist/onboarding-checklist.js +577 -0
- package/dist/onboarding-checklist/onboarding-checklist.js.map +1 -0
- package/dist/password-field/password-field.js +2 -2
- package/dist/password-field/password-field.js.map +1 -1
- package/dist/phone-input/index.d.ts +3 -0
- package/dist/phone-input/index.js +3 -0
- package/dist/phone-input/phone-countries.d.ts +29 -0
- package/dist/phone-input/phone-countries.js +170 -0
- package/dist/phone-input/phone-countries.js.map +1 -0
- package/dist/phone-input/phone-input.d.ts +66 -0
- package/dist/phone-input/phone-input.js +440 -0
- package/dist/phone-input/phone-input.js.map +1 -0
- package/dist/popover/popover.d.ts +12 -0
- package/dist/popover/popover.js +31 -7
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.js +1 -1
- package/dist/radio-group/radio-group.js +1 -1
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/reactions/index.d.ts +2 -0
- package/dist/reactions/index.js +2 -0
- package/dist/reactions/reactions.d.ts +50 -0
- package/dist/reactions/reactions.js +315 -0
- package/dist/reactions/reactions.js.map +1 -0
- package/dist/rich-text-editor/index.d.ts +3 -0
- package/dist/rich-text-editor/index.js +2 -0
- package/dist/rich-text-editor/rich-text-editor.d.ts +70 -0
- package/dist/rich-text-editor/rich-text-editor.js +909 -0
- package/dist/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/rich-text-editor/rich-text-engine.d.ts +16 -0
- package/dist/rich-text-editor/rich-text-engine.js +366 -0
- package/dist/rich-text-editor/rich-text-engine.js.map +1 -0
- package/dist/rich-text-editor/rich-text-html.js +174 -0
- package/dist/rich-text-editor/rich-text-html.js.map +1 -0
- package/dist/rich-text-editor/rich-text-icons.js +43 -0
- package/dist/rich-text-editor/rich-text-icons.js.map +1 -0
- package/dist/ridgeline/index.d.ts +2 -0
- package/dist/ridgeline/index.js +2 -0
- package/dist/ridgeline/ridgeline.d.ts +55 -0
- package/dist/ridgeline/ridgeline.js +701 -0
- package/dist/ridgeline/ridgeline.js.map +1 -0
- package/dist/scroll-area/index.d.ts +2 -2
- package/dist/scroll-area/index.js +2 -2
- package/dist/scroll-area/scroll-area.d.ts +68 -31
- package/dist/scroll-area/scroll-area.js +208 -59
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/scrub-input/evaluate.d.ts +14 -0
- package/dist/scrub-input/evaluate.js +72 -0
- package/dist/scrub-input/evaluate.js.map +1 -0
- package/dist/scrub-input/index.d.ts +3 -0
- package/dist/scrub-input/index.js +3 -0
- package/dist/scrub-input/scrub-input.d.ts +74 -0
- package/dist/scrub-input/scrub-input.js +486 -0
- package/dist/scrub-input/scrub-input.js.map +1 -0
- package/dist/search-field/search-field.d.ts +2 -1
- package/dist/search-field/search-field.js +4 -4
- package/dist/search-field/search-field.js.map +1 -1
- package/dist/select/select.d.ts +3 -1
- package/dist/select/select.js +20 -8
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/sheet/sheet.js +2 -1
- package/dist/sheet/sheet.js.map +1 -1
- package/dist/shortcut-recorder/index.d.ts +3 -0
- package/dist/shortcut-recorder/index.js +3 -0
- package/dist/shortcut-recorder/shortcut-model.d.ts +27 -0
- package/dist/shortcut-recorder/shortcut-model.js +206 -0
- package/dist/shortcut-recorder/shortcut-model.js.map +1 -0
- package/dist/shortcut-recorder/shortcut-recorder.d.ts +93 -0
- package/dist/shortcut-recorder/shortcut-recorder.js +489 -0
- package/dist/shortcut-recorder/shortcut-recorder.js.map +1 -0
- package/dist/slider/index.d.ts +2 -2
- package/dist/slider/slider.d.ts +46 -14
- package/dist/slider/slider.js +151 -67
- package/dist/slider/slider.js.map +1 -1
- package/dist/slope-chart/index.d.ts +2 -0
- package/dist/slope-chart/index.js +2 -0
- package/dist/slope-chart/slope-chart.d.ts +54 -0
- package/dist/slope-chart/slope-chart.js +568 -0
- package/dist/slope-chart/slope-chart.js.map +1 -0
- package/dist/sparkline/index.d.ts +2 -0
- package/dist/sparkline/index.js +2 -0
- package/dist/sparkline/sparkline.d.ts +46 -0
- package/dist/sparkline/sparkline.js +390 -0
- package/dist/sparkline/sparkline.js.map +1 -0
- package/dist/split-bar/index.d.ts +2 -0
- package/dist/split-bar/index.js +2 -0
- package/dist/split-bar/split-bar.d.ts +62 -0
- package/dist/split-bar/split-bar.js +513 -0
- package/dist/split-bar/split-bar.js.map +1 -0
- package/dist/split-button/split-button.d.ts +1 -1
- package/dist/split-button/split-button.js +12 -11
- package/dist/split-button/split-button.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +24 -4
- package/dist/stat-card/stat-card.js +114 -17
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/stepper/index.d.ts +2 -0
- package/dist/stepper/index.js +2 -0
- package/dist/stepper/stepper.d.ts +51 -0
- package/dist/stepper/stepper.js +215 -0
- package/dist/stepper/stepper.js.map +1 -0
- package/dist/streamgraph/index.d.ts +2 -0
- package/dist/streamgraph/index.js +2 -0
- package/dist/streamgraph/streamgraph.d.ts +70 -0
- package/dist/streamgraph/streamgraph.js +613 -0
- package/dist/streamgraph/streamgraph.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/swipe-actions/index.d.ts +2 -0
- package/dist/swipe-actions/index.js +2 -0
- package/dist/swipe-actions/swipe-actions.d.ts +67 -0
- package/dist/swipe-actions/swipe-actions.js +552 -0
- package/dist/swipe-actions/swipe-actions.js.map +1 -0
- package/dist/switch/switch.js +2 -2
- package/dist/switch/switch.js.map +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +56 -4
- package/dist/table/table.js +340 -165
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.js +2 -2
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/index.d.ts +2 -0
- package/dist/tag-input/index.js +2 -0
- package/dist/tag-input/tag-input.d.ts +40 -0
- package/dist/tag-input/tag-input.js +269 -0
- package/dist/tag-input/tag-input.js.map +1 -0
- package/dist/text-morph/index.d.ts +2 -0
- package/dist/text-morph/index.js +2 -0
- package/dist/text-morph/text-morph.d.ts +23 -0
- package/dist/text-morph/text-morph.js +21 -0
- package/dist/text-morph/text-morph.js.map +1 -0
- package/dist/text-reveal/index.d.ts +2 -0
- package/dist/text-reveal/index.js +2 -0
- package/dist/text-reveal/text-reveal.d.ts +27 -0
- package/dist/text-reveal/text-reveal.js +51 -0
- package/dist/text-reveal/text-reveal.js.map +1 -0
- package/dist/text-shimmer/index.d.ts +2 -0
- package/dist/text-shimmer/index.js +2 -0
- package/dist/text-shimmer/text-shimmer.d.ts +29 -0
- package/dist/text-shimmer/text-shimmer.js +29 -0
- package/dist/text-shimmer/text-shimmer.js.map +1 -0
- package/dist/time-picker/time-picker.js +2 -2
- package/dist/time-picker/time-picker.js.map +1 -1
- package/dist/toast/index.d.ts +2 -2
- package/dist/toast/index.js +2 -2
- package/dist/toast/toast.d.ts +6 -0
- package/dist/toast/toast.js +82 -40
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +9 -2
- package/dist/tooltip/tooltip.js +7 -7
- package/dist/tooltip/tooltip.js.map +1 -1
- package/dist/treemap/index.d.ts +2 -0
- package/dist/treemap/index.js +2 -0
- package/dist/treemap/treemap.d.ts +53 -0
- package/dist/treemap/treemap.js +699 -0
- package/dist/treemap/treemap.js.map +1 -0
- package/dist/usage-meter/index.d.ts +2 -0
- package/dist/usage-meter/index.js +2 -0
- package/dist/usage-meter/usage-meter.d.ts +50 -0
- package/dist/usage-meter/usage-meter.js +440 -0
- package/dist/usage-meter/usage-meter.js.map +1 -0
- package/dist/waffle-chart/index.d.ts +2 -0
- package/dist/waffle-chart/index.js +2 -0
- package/dist/waffle-chart/waffle-chart.d.ts +57 -0
- package/dist/waffle-chart/waffle-chart.js +426 -0
- package/dist/waffle-chart/waffle-chart.js.map +1 -0
- package/package.json +165 -3
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn, cnAll } from "../lib/cn.js";
|
|
3
3
|
import { prefersReducedMotion, useExitBackstop, useIsomorphicLayoutEffect, useMorphWidth } from "../lib/motion.js";
|
|
4
|
-
import { Button } from "../button/button.js";
|
|
4
|
+
import { Button as Button$1 } from "../button/button.js";
|
|
5
5
|
import { SwapText } from "../lib/swap-text.js";
|
|
6
6
|
import { useHeightFollow } from "../lib/height-follow.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useMenuHighlight } from "../lib/menu-highlight.js";
|
|
8
|
+
import { MenuItem as MenuItem$1, menuVariants } from "../menu/menu.js";
|
|
9
|
+
import { Popover as Popover$1, PopoverTrigger } from "../popover/popover.js";
|
|
9
10
|
import { useLeavingList } from "../lib/leaving-list.js";
|
|
10
|
-
import { Select, SelectItem } from "../select/select.js";
|
|
11
11
|
import { cva } from "class-variance-authority";
|
|
12
12
|
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
13
|
+
import { Menu } from "react-aria-components";
|
|
13
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
15
|
//#region src/filter-bar/filter-bar.tsx
|
|
15
16
|
/**
|
|
16
|
-
* FilterBar -- a
|
|
17
|
-
*
|
|
18
|
-
* button.
|
|
17
|
+
* FilterBar -- a filter toolbar: one pill that shows what is filtered as
|
|
18
|
+
* removable chips ("No filters applied" while nothing is), with an "Add filter"
|
|
19
|
+
* button that opens a menu of the filters.
|
|
19
20
|
*
|
|
20
21
|
* Why it exists: list screens grew a row of four to seven dropdowns beside
|
|
21
22
|
* the search box and the status tabs. At desktop width that row wraps onto a
|
|
@@ -23,28 +24,37 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
23
24
|
* line and makes what IS filtered visible as chips instead of as the
|
|
24
25
|
* resting text of a dropdown.
|
|
25
26
|
*
|
|
26
|
-
* Three regions:
|
|
27
|
+
* Three regions, all inside the one pill:
|
|
27
28
|
*
|
|
28
|
-
* - `inline`: always in the
|
|
29
|
-
* - the
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* - `end`: always in the row, at its end (a count, Export, a view toggle).
|
|
29
|
+
* - `inline`: always in the pill, at its start (status tabs, a search box).
|
|
30
|
+
* - the chips, then "Clear all" once any filter is set; or the empty note.
|
|
31
|
+
* - the Add filter button, then `end`: always in the pill, at its end (a
|
|
32
|
+
* count, Export, a view toggle).
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* The button opens a menu of the filters: each row is the filter's icon and
|
|
35
|
+
* name, the value it holds now, and a chevron. A row opens that filter's own
|
|
36
|
+
* options in the same panel (a back button returns to the list); choosing an
|
|
37
|
+
* option sets the filter and closes the menu. A custom filter shows its own
|
|
38
|
+
* control in that step.
|
|
36
39
|
*
|
|
37
40
|
* The bar holds NO filter state. Every value and every change belongs to the
|
|
38
41
|
* caller: removing a chip hands the filter's `emptyValue` back to its
|
|
39
42
|
* `onChange`; Clear all does that for each set filter, or calls
|
|
40
43
|
* `onClearAll` when the caller resets its filters in one step.
|
|
41
44
|
*
|
|
42
|
-
* Accessibility comes from the parts: the
|
|
43
|
-
* trigger, the trigger carries `aria-expanded`, focus moves into the
|
|
44
|
-
*
|
|
45
|
+
* Accessibility comes from the parts: the panel is a dialog named by its
|
|
46
|
+
* trigger, the trigger carries `aria-expanded`, focus moves into the panel and
|
|
47
|
+
* is contained there, Escape closes it and focus returns to the trigger, and
|
|
48
|
+
* each list is a real menu with arrow keys and type-ahead.
|
|
45
49
|
*/
|
|
46
|
-
|
|
47
|
-
const
|
|
50
|
+
/** The toolbar: one pill with a light border on the surface. */
|
|
51
|
+
const filterBarVariants = cva([
|
|
52
|
+
"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-full",
|
|
53
|
+
"border-(length:--border-width) border-border bg-surface",
|
|
54
|
+
"px-4 py-2 box-border font-sans"
|
|
55
|
+
]);
|
|
56
|
+
/** The group at the pill's end: the Add filter button and the caller's `end`. */
|
|
57
|
+
const filterBarRowVariants = cva(["ms-auto flex flex-wrap items-center gap-2"]);
|
|
48
58
|
const filterBarChipVariants = cva([
|
|
49
59
|
"inline-flex items-center gap-1 rounded-full",
|
|
50
60
|
"border-(length:--border-width) border-border bg-muted",
|
|
@@ -52,43 +62,28 @@ const filterBarChipVariants = cva([
|
|
|
52
62
|
"box-border font-sans"
|
|
53
63
|
]);
|
|
54
64
|
const isCustom = (f) => "render" in f;
|
|
65
|
+
/** What a filter holds now, for its menu row and its chip: `null` while it is not set. */
|
|
66
|
+
function valueOf(f) {
|
|
67
|
+
if (isCustom(f)) return f.activeLabel;
|
|
68
|
+
if (f.value == null || f.value === f.emptyValue) return null;
|
|
69
|
+
const option = f.options.find((o) => o.id === f.value);
|
|
70
|
+
return option ? option.label : String(f.value);
|
|
71
|
+
}
|
|
55
72
|
/** The set filters, each with its chip text and how to unset it. */
|
|
56
73
|
function chipsFor(filters) {
|
|
57
74
|
const chips = [];
|
|
58
75
|
for (const f of filters) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
id: f.id,
|
|
62
|
-
text: `${f.label}: ${f.activeLabel}`,
|
|
63
|
-
clear: f.onClear
|
|
64
|
-
});
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (f.value == null || f.value === f.emptyValue) continue;
|
|
68
|
-
const option = f.options.find((o) => o.id === f.value);
|
|
76
|
+
const value = valueOf(f);
|
|
77
|
+
if (value == null) continue;
|
|
69
78
|
chips.push({
|
|
70
79
|
id: f.id,
|
|
71
|
-
text: `${f.label}: ${
|
|
72
|
-
clear: () => f.onChange(f.emptyValue)
|
|
80
|
+
text: `${f.label}: ${value}`,
|
|
81
|
+
clear: isCustom(f) ? f.onClear : () => f.onChange(f.emptyValue)
|
|
73
82
|
});
|
|
74
83
|
}
|
|
75
84
|
return chips;
|
|
76
85
|
}
|
|
77
|
-
|
|
78
|
-
function FunnelGlyph() {
|
|
79
|
-
return /* @__PURE__ */ jsx("svg", {
|
|
80
|
-
viewBox: "0 0 16 16",
|
|
81
|
-
fill: "none",
|
|
82
|
-
stroke: "currentColor",
|
|
83
|
-
strokeWidth: "1.5",
|
|
84
|
-
"aria-hidden": "true",
|
|
85
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
86
|
-
d: "M2 3h12M4.5 8h7M7 13h2",
|
|
87
|
-
strokeLinecap: "round"
|
|
88
|
-
})
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function CrossGlyph() {
|
|
86
|
+
function Glyph({ path }) {
|
|
92
87
|
return /* @__PURE__ */ jsx("svg", {
|
|
93
88
|
viewBox: "0 0 16 16",
|
|
94
89
|
fill: "none",
|
|
@@ -96,20 +91,25 @@ function CrossGlyph() {
|
|
|
96
91
|
strokeWidth: "1.5",
|
|
97
92
|
"aria-hidden": "true",
|
|
98
93
|
children: /* @__PURE__ */ jsx("path", {
|
|
99
|
-
d:
|
|
100
|
-
strokeLinecap: "round"
|
|
94
|
+
d: path,
|
|
95
|
+
strokeLinecap: "round",
|
|
96
|
+
strokeLinejoin: "round"
|
|
101
97
|
})
|
|
102
98
|
});
|
|
103
99
|
}
|
|
100
|
+
const PlusGlyph = () => /* @__PURE__ */ jsx(Glyph, { path: "M8 3v10M3 8h10" });
|
|
101
|
+
const CrossGlyph = () => /* @__PURE__ */ jsx(Glyph, { path: "M4 4l8 8M12 4l-8 8" });
|
|
102
|
+
const ChevronRightGlyph = () => /* @__PURE__ */ jsx(Glyph, { path: "M6 3l5 5-5 5" });
|
|
103
|
+
const ChevronLeftGlyph = () => /* @__PURE__ */ jsx(Glyph, { path: "M10 3 5 8l5 5" });
|
|
104
|
+
const CheckGlyph = () => /* @__PURE__ */ jsx(Glyph, { path: "M3 8.5l3.5 3.5L13 4.5" });
|
|
104
105
|
/**
|
|
105
|
-
* A list toolbar with its
|
|
106
|
+
* A list toolbar with its filters behind one Add filter button.
|
|
106
107
|
*
|
|
107
108
|
* @example
|
|
108
109
|
* <FilterBar
|
|
109
|
-
* inline={<SearchField aria-label="Search" />}
|
|
110
110
|
* end={<Button>Export</Button>}
|
|
111
|
-
* filters={[{ id: "
|
|
112
|
-
* options: [{ id: "all", label: "
|
|
111
|
+
* filters={[{ id: "status", label: "Status", icon: <StatusIcon aria-hidden />, value, emptyValue: "all",
|
|
112
|
+
* onChange: setValue, options: [{ id: "all", label: "Any status" }, { id: "open", label: "Open" }] }]}
|
|
113
113
|
* />
|
|
114
114
|
*/
|
|
115
115
|
/**
|
|
@@ -157,7 +157,154 @@ function ChipText({ text }) {
|
|
|
157
157
|
})
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
/** A filter's icon, drawn at the control icon size in the secondary ink. */
|
|
161
|
+
function RowIcon({ icon }) {
|
|
162
|
+
return icon ? /* @__PURE__ */ jsx("span", {
|
|
163
|
+
"aria-hidden": "true",
|
|
164
|
+
className: "inline-flex text-text-secondary",
|
|
165
|
+
children: icon
|
|
166
|
+
}) : null;
|
|
167
|
+
}
|
|
168
|
+
/** The note for no filters. Arriving after the first render (the last chip has gone) it fades in; at first render it does not. */
|
|
169
|
+
function EmptyNote({ ready, children }) {
|
|
170
|
+
const [fresh] = useState(ready);
|
|
171
|
+
return /* @__PURE__ */ jsx("span", {
|
|
172
|
+
"data-slot": "filter-bar-empty",
|
|
173
|
+
className: cn("text-sm text-text-secondary" + (fresh ? " motion-safe:animate-fade-in" : "")),
|
|
174
|
+
children
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const STEP = "motion-safe:animate-filter-step-in motion-reduce:animate-fade-in";
|
|
178
|
+
/**
|
|
179
|
+
* The Add filter menu's panel, in two steps: the list of filters, then the
|
|
180
|
+
* chosen filter's options (or its own control). A step arrives from the side it
|
|
181
|
+
* was reached from; the first one, on open, does not animate by itself (the
|
|
182
|
+
* popover grows from the button instead).
|
|
183
|
+
*/
|
|
184
|
+
function FilterPanel({ filters, label, backLabel, onClose }) {
|
|
185
|
+
const [fieldId, setFieldId] = useState(null);
|
|
186
|
+
const [dir, setDir] = useState(null);
|
|
187
|
+
const [returnTo, setReturnTo] = useState(null);
|
|
188
|
+
const listRef = useRef(null);
|
|
189
|
+
const bindFields = useMenuHighlight();
|
|
190
|
+
const bindOptions = useMenuHighlight();
|
|
191
|
+
const field = filters.find((f) => f.id === fieldId) ?? null;
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (field || returnTo === null) return;
|
|
194
|
+
const id = returnTo;
|
|
195
|
+
let frame = 0;
|
|
196
|
+
let tries = 0;
|
|
197
|
+
const focusRow = () => {
|
|
198
|
+
const row = Array.from(listRef.current?.querySelectorAll("[data-slot='menu-item']") ?? []).find((node) => node.dataset.key === id);
|
|
199
|
+
if (row) row.focus();
|
|
200
|
+
else if (tries++ < 20) frame = requestAnimationFrame(focusRow);
|
|
201
|
+
};
|
|
202
|
+
focusRow();
|
|
203
|
+
return () => cancelAnimationFrame(frame);
|
|
204
|
+
}, [field, returnTo]);
|
|
205
|
+
const open = (id) => {
|
|
206
|
+
setDir(1);
|
|
207
|
+
setFieldId(String(id));
|
|
208
|
+
};
|
|
209
|
+
const back = () => {
|
|
210
|
+
if (!field) return;
|
|
211
|
+
setReturnTo(field.id);
|
|
212
|
+
setDir(-1);
|
|
213
|
+
setFieldId(null);
|
|
214
|
+
};
|
|
215
|
+
const stepClass = dir === null ? "" : cn(STEP + (dir === 1 ? " [--step-dir:1]" : " [--step-dir:-1]"));
|
|
216
|
+
return /* @__PURE__ */ jsx("div", {
|
|
217
|
+
"data-slot": "filter-bar-panel",
|
|
218
|
+
className: "overflow-x-clip",
|
|
219
|
+
children: field ? /* @__PURE__ */ jsxs("div", {
|
|
220
|
+
className: stepClass,
|
|
221
|
+
onKeyDown: (event) => {
|
|
222
|
+
if (event.key === "ArrowLeft" && !isCustom(field)) {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
back();
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: "flex items-center gap-1 px-1 pb-1",
|
|
229
|
+
children: [/* @__PURE__ */ jsx(Button$1, {
|
|
230
|
+
variant: "ghost",
|
|
231
|
+
size: "icon",
|
|
232
|
+
"aria-label": backLabel,
|
|
233
|
+
onPress: back,
|
|
234
|
+
className: "size-8 flex-none rounded-full",
|
|
235
|
+
children: /* @__PURE__ */ jsx(ChevronLeftGlyph, {})
|
|
236
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
237
|
+
className: "min-w-0 truncate text-sm font-medium text-foreground",
|
|
238
|
+
children: field.label
|
|
239
|
+
})]
|
|
240
|
+
}), isCustom(field) ? /* @__PURE__ */ jsx("div", {
|
|
241
|
+
className: "p-1.5",
|
|
242
|
+
children: field.render()
|
|
243
|
+
}) : /* @__PURE__ */ jsx(Menu, {
|
|
244
|
+
ref: bindOptions,
|
|
245
|
+
"aria-label": field.label,
|
|
246
|
+
"data-slot": "filter-bar-options",
|
|
247
|
+
autoFocus: "first",
|
|
248
|
+
selectionMode: "single",
|
|
249
|
+
disallowEmptySelection: true,
|
|
250
|
+
selectedKeys: field.value == null ? [] : [field.value],
|
|
251
|
+
onAction: (key) => {
|
|
252
|
+
field.onChange(key);
|
|
253
|
+
onClose();
|
|
254
|
+
},
|
|
255
|
+
className: menuVariants(),
|
|
256
|
+
children: field.options.map((o) => /* @__PURE__ */ jsxs(MenuItem$1, {
|
|
257
|
+
id: o.id,
|
|
258
|
+
textValue: o.label,
|
|
259
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
260
|
+
className: "min-w-0 flex-1 truncate",
|
|
261
|
+
children: o.label
|
|
262
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
263
|
+
"aria-hidden": "true",
|
|
264
|
+
className: o.id === field.value ? "inline-flex text-foreground" : "inline-flex text-foreground opacity-0",
|
|
265
|
+
children: /* @__PURE__ */ jsx(CheckGlyph, {})
|
|
266
|
+
})]
|
|
267
|
+
}, o.id))
|
|
268
|
+
})]
|
|
269
|
+
}, field.id) : /* @__PURE__ */ jsx("div", {
|
|
270
|
+
ref: listRef,
|
|
271
|
+
className: stepClass,
|
|
272
|
+
children: /* @__PURE__ */ jsx(Menu, {
|
|
273
|
+
ref: bindFields,
|
|
274
|
+
"aria-label": label,
|
|
275
|
+
"data-slot": "filter-bar-fields",
|
|
276
|
+
autoFocus: returnTo === null ? "first" : false,
|
|
277
|
+
onAction: open,
|
|
278
|
+
onClose: () => {},
|
|
279
|
+
className: menuVariants(),
|
|
280
|
+
children: filters.map((f) => {
|
|
281
|
+
const value = valueOf(f);
|
|
282
|
+
return /* @__PURE__ */ jsxs(MenuItem$1, {
|
|
283
|
+
id: f.id,
|
|
284
|
+
textValue: f.label,
|
|
285
|
+
children: [
|
|
286
|
+
/* @__PURE__ */ jsx(RowIcon, { icon: f.icon }),
|
|
287
|
+
/* @__PURE__ */ jsx("span", {
|
|
288
|
+
className: "min-w-0 flex-1 truncate",
|
|
289
|
+
children: f.label
|
|
290
|
+
}),
|
|
291
|
+
value ? /* @__PURE__ */ jsx("span", {
|
|
292
|
+
className: "max-w-24 truncate text-xs text-text-secondary",
|
|
293
|
+
children: value
|
|
294
|
+
}) : null,
|
|
295
|
+
/* @__PURE__ */ jsx("span", {
|
|
296
|
+
"aria-hidden": "true",
|
|
297
|
+
className: "inline-flex text-text-secondary",
|
|
298
|
+
children: /* @__PURE__ */ jsx(ChevronRightGlyph, {})
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
}, f.id);
|
|
302
|
+
})
|
|
303
|
+
})
|
|
304
|
+
}, "fields")
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const FilterBar = forwardRef(function FilterBar({ inline, end, filters, onClearAll, buttonLabel = "Add filter", clearAllLabel = "Clear all", emptyLabel = "No filters applied", chipsLabel = "Filters set", removeLabel = (text) => `Remove filter ${text}`, backLabel = "Back to filters", className }, ref) {
|
|
161
308
|
const [open, setOpen] = useState(false);
|
|
162
309
|
const chips = chipsFor(filters);
|
|
163
310
|
const [ready, setReady] = useState(false);
|
|
@@ -183,115 +330,84 @@ const FilterBar = forwardRef(function FilterBar({ inline, end, filters, onClearA
|
|
|
183
330
|
ref,
|
|
184
331
|
"data-slot": "filter-bar",
|
|
185
332
|
className: cn(filterBarVariants(), className),
|
|
186
|
-
children: [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
333
|
+
children: [
|
|
334
|
+
inline ? /* @__PURE__ */ jsx("div", {
|
|
335
|
+
className: "flex flex-wrap items-center gap-2",
|
|
336
|
+
children: inline
|
|
337
|
+
}) : null,
|
|
338
|
+
/* @__PURE__ */ jsx("div", {
|
|
339
|
+
"data-slot": "filter-bar-chips-area",
|
|
340
|
+
className: "flex min-h-(--density-control-h-sm) min-w-0 flex-[1_1_8rem] items-center",
|
|
341
|
+
children: places.list.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
342
|
+
ref: frame,
|
|
343
|
+
"data-slot": "filter-bar-chips-frame",
|
|
344
|
+
className: "height-follow min-w-0",
|
|
345
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
346
|
+
ref: row,
|
|
347
|
+
"aria-label": chipsLabel,
|
|
348
|
+
"data-slot": "filter-bar-chips",
|
|
349
|
+
className: "m-0 flex list-none flex-wrap items-center gap-2 p-0",
|
|
350
|
+
children: places.list.map(({ item, leaving }) => item.chip ? /* @__PURE__ */ jsx(Slot, {
|
|
351
|
+
id: item.id,
|
|
352
|
+
leaving,
|
|
353
|
+
ready,
|
|
354
|
+
onDone: places.done,
|
|
355
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
356
|
+
"data-slot": "filter-bar-chip",
|
|
357
|
+
className: filterBarChipVariants(),
|
|
358
|
+
children: [/* @__PURE__ */ jsx(ChipText, { text: item.chip.text }), /* @__PURE__ */ jsx(Button$1, {
|
|
359
|
+
variant: "ghost",
|
|
360
|
+
size: "sm",
|
|
361
|
+
"aria-label": removeLabel(item.chip.text),
|
|
362
|
+
onPress: item.chip.clear,
|
|
363
|
+
className: "h-6 px-1",
|
|
364
|
+
children: /* @__PURE__ */ jsx(CrossGlyph, {})
|
|
365
|
+
})]
|
|
366
|
+
})
|
|
367
|
+
}, item.id) : /* @__PURE__ */ jsx(Slot, {
|
|
368
|
+
id: item.id,
|
|
369
|
+
leaving,
|
|
370
|
+
ready,
|
|
371
|
+
onDone: places.done,
|
|
372
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
373
|
+
variant: "link",
|
|
374
|
+
size: "sm",
|
|
375
|
+
onPress: clearAll,
|
|
376
|
+
children: clearAllLabel
|
|
377
|
+
})
|
|
378
|
+
}, item.id))
|
|
379
|
+
})
|
|
380
|
+
}) : /* @__PURE__ */ jsx(EmptyNote, {
|
|
381
|
+
ready,
|
|
382
|
+
children: emptyLabel
|
|
383
|
+
})
|
|
384
|
+
}),
|
|
385
|
+
filters.length > 0 || end ? /* @__PURE__ */ jsxs("div", {
|
|
386
|
+
"data-slot": "filter-bar-actions",
|
|
387
|
+
className: filterBarRowVariants(),
|
|
388
|
+
children: [filters.length > 0 ? /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
192
389
|
isOpen: open,
|
|
193
390
|
onOpenChange: setOpen,
|
|
194
|
-
children: [/* @__PURE__ */
|
|
391
|
+
children: [/* @__PURE__ */ jsx(Button$1, {
|
|
195
392
|
variant: "outlineNeutral",
|
|
196
393
|
size: "sm",
|
|
197
|
-
startIcon: /* @__PURE__ */ jsx(
|
|
394
|
+
startIcon: /* @__PURE__ */ jsx(PlusGlyph, {}),
|
|
198
395
|
"data-slot": "filter-bar-button",
|
|
199
|
-
children:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
className: "w-80 max-w-[calc(100vw-2rem)]",
|
|
210
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
211
|
-
"data-slot": "filter-bar-panel",
|
|
212
|
-
className: "flex flex-col gap-3",
|
|
213
|
-
children: [
|
|
214
|
-
/* @__PURE__ */ jsx("p", {
|
|
215
|
-
className: "m-0 text-sm font-semibold",
|
|
216
|
-
children: buttonLabel
|
|
217
|
-
}),
|
|
218
|
-
filters.map((f) => isCustom(f) ? /* @__PURE__ */ jsx("div", { children: f.render() }, f.id) : /* @__PURE__ */ jsx(Select, {
|
|
219
|
-
label: f.label,
|
|
220
|
-
size: "sm",
|
|
221
|
-
selectedKey: f.value,
|
|
222
|
-
onSelectionChange: (key) => {
|
|
223
|
-
if (key != null) f.onChange(key);
|
|
224
|
-
},
|
|
225
|
-
children: f.options.map((o) => /* @__PURE__ */ jsx(SelectItem, {
|
|
226
|
-
id: o.id,
|
|
227
|
-
textValue: o.label,
|
|
228
|
-
children: o.label
|
|
229
|
-
}, o.id))
|
|
230
|
-
}, f.id)),
|
|
231
|
-
/* @__PURE__ */ jsxs("div", {
|
|
232
|
-
className: "flex items-center justify-between gap-2 pt-1",
|
|
233
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
234
|
-
variant: "ghost",
|
|
235
|
-
size: "sm",
|
|
236
|
-
onPress: clearAll,
|
|
237
|
-
isDisabled: chips.length === 0,
|
|
238
|
-
children: clearAllLabel
|
|
239
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
240
|
-
variant: "primary",
|
|
241
|
-
size: "sm",
|
|
242
|
-
onPress: () => setOpen(false),
|
|
243
|
-
children: doneLabel
|
|
244
|
-
})]
|
|
245
|
-
})
|
|
246
|
-
]
|
|
396
|
+
children: buttonLabel
|
|
397
|
+
}), /* @__PURE__ */ jsx(Popover$1, {
|
|
398
|
+
placement: "bottom end",
|
|
399
|
+
offset: 8,
|
|
400
|
+
className: "w-64 max-w-[calc(100vw-2rem)] p-1.5",
|
|
401
|
+
children: /* @__PURE__ */ jsx(FilterPanel, {
|
|
402
|
+
filters,
|
|
403
|
+
label: buttonLabel,
|
|
404
|
+
backLabel,
|
|
405
|
+
onClose: () => setOpen(false)
|
|
247
406
|
})
|
|
248
407
|
})]
|
|
249
|
-
}) : null,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
children: end
|
|
253
|
-
}) : null
|
|
254
|
-
]
|
|
255
|
-
}), places.list.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
256
|
-
ref: frame,
|
|
257
|
-
"data-slot": "filter-bar-chips-frame",
|
|
258
|
-
className: "height-follow",
|
|
259
|
-
children: /* @__PURE__ */ jsx("ul", {
|
|
260
|
-
ref: row,
|
|
261
|
-
"aria-label": chipsLabel,
|
|
262
|
-
"data-slot": "filter-bar-chips",
|
|
263
|
-
className: "m-0 flex list-none flex-wrap items-center gap-2 p-0",
|
|
264
|
-
children: places.list.map(({ item, leaving }) => item.chip ? /* @__PURE__ */ jsx(Slot, {
|
|
265
|
-
id: item.id,
|
|
266
|
-
leaving,
|
|
267
|
-
ready,
|
|
268
|
-
onDone: places.done,
|
|
269
|
-
children: /* @__PURE__ */ jsxs("span", {
|
|
270
|
-
"data-slot": "filter-bar-chip",
|
|
271
|
-
className: filterBarChipVariants(),
|
|
272
|
-
children: [/* @__PURE__ */ jsx(ChipText, { text: item.chip.text }), /* @__PURE__ */ jsx(Button, {
|
|
273
|
-
variant: "ghost",
|
|
274
|
-
size: "sm",
|
|
275
|
-
"aria-label": removeLabel(item.chip.text),
|
|
276
|
-
onPress: item.chip.clear,
|
|
277
|
-
className: "h-6 px-1",
|
|
278
|
-
children: /* @__PURE__ */ jsx(CrossGlyph, {})
|
|
279
|
-
})]
|
|
280
|
-
})
|
|
281
|
-
}, item.id) : /* @__PURE__ */ jsx(Slot, {
|
|
282
|
-
id: item.id,
|
|
283
|
-
leaving,
|
|
284
|
-
ready,
|
|
285
|
-
onDone: places.done,
|
|
286
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
287
|
-
variant: "link",
|
|
288
|
-
size: "sm",
|
|
289
|
-
onPress: clearAll,
|
|
290
|
-
children: clearAllLabel
|
|
291
|
-
})
|
|
292
|
-
}, item.id))
|
|
293
|
-
})
|
|
294
|
-
}) : null]
|
|
408
|
+
}) : null, end]
|
|
409
|
+
}) : null
|
|
410
|
+
]
|
|
295
411
|
});
|
|
296
412
|
});
|
|
297
413
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-bar.js","names":[],"sources":["../../src/filter-bar/filter-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef, useCallback, useEffect, useRef, useState, type ReactNode } from \"react\";\nimport type { Key } from \"react-aria-components\";\n\nimport { Badge } from \"../badge/badge.js\";\nimport { Button } from \"../button/button.js\";\nimport { cn, cnAll } from \"../lib/cn.js\";\nimport { useHeightFollow } from \"../lib/height-follow.js\";\nimport { useLeavingList } from \"../lib/leaving-list.js\";\nimport { prefersReducedMotion, useExitBackstop, useIsomorphicLayoutEffect, useMorphWidth } from \"../lib/motion.js\";\nimport { SwapText } from \"../lib/swap-text.js\";\nimport { Popover, PopoverTrigger } from \"../popover/popover.js\";\nimport { Select, SelectItem } from \"../select/select.js\";\n\n/**\n * FilterBar -- a list toolbar that keeps the controls people use every time\n * in the row and puts every other dropdown filter behind ONE \"Filters\"\n * button.\n *\n * Why it exists: list screens grew a row of four to seven dropdowns beside\n * the search box and the status tabs. At desktop width that row wraps onto a\n * second line; on a phone it scrolls sideways. The bar keeps the row to one\n * line and makes what IS filtered visible as chips instead of as the\n * resting text of a dropdown.\n *\n * Three regions:\n *\n * - `inline`: always in the row, at its start (status tabs, the search box).\n * - the Filters button: a popover with a one-column form, one full-width\n * Select per filter with its label above. The button carries a count badge\n * of the filters that are set.\n * - `end`: always in the row, at its end (a count, Export, a view toggle).\n *\n * While any filter is set, a list of chips sits under the row, each reading\n * \"Label: option label\" with its own remove button, plus \"Clear all\".\n *\n * The bar holds NO filter state. Every value and every change belongs to the\n * caller: removing a chip hands the filter's `emptyValue` back to its\n * `onChange`; Clear all does that for each set filter, or calls\n * `onClearAll` when the caller resets its filters in one step.\n *\n * Accessibility comes from the parts: the popover is a dialog named by its\n * trigger, the trigger carries `aria-expanded`, focus moves into the popover\n * and is contained there, Escape closes it and focus returns to the trigger.\n */\n\nexport const filterBarVariants = cva([\"flex flex-col gap-2 box-border font-sans\"]);\n\nexport const filterBarRowVariants = cva([\"flex flex-wrap items-center gap-2\"]);\n\nexport const filterBarChipVariants = cva([\n \"inline-flex items-center gap-1 rounded-full\",\n \"border-(length:--border-width) border-border bg-muted\",\n \"ps-3 pe-1 text-xs leading-(--leading-snug) text-foreground\",\n \"box-border font-sans\",\n]);\n\n/** One option of a dropdown filter. */\nexport interface FilterBarOption {\n /** The option's value, handed to `onChange`. */\n id: Key;\n /** The option's text: in the list, on the trigger and on the chip. */\n label: string;\n}\n\n/** A dropdown filter, rendered as a Select in the popover. */\nexport interface FilterBarSelectField {\n /** Stable identity, used as the React key. */\n id: string;\n /** The field's name: the label above the dropdown and the start of its chip. */\n label: string;\n /** The current value. `null` reads as not set. */\n value: Key | null;\n /** The value that means \"not filtered\" (the \"All\" option's id). */\n emptyValue: Key;\n /** The options, the \"All\" option included. */\n options: readonly FilterBarOption[];\n /** Told the chosen option's id, or `emptyValue` when the chip is removed. */\n onChange: (value: Key) => void;\n}\n\n/**\n * A filter that is not a plain dropdown (a date range, a searchable picker):\n * the caller renders the control and says what its chip reads.\n */\nexport interface FilterBarCustomField {\n /** Stable identity, used as the React key. */\n id: string;\n /** The start of its chip. The control rendered by `render` names itself. */\n label: string;\n /** The control, rendered in the popover. */\n render: () => ReactNode;\n /** The chip's value text while the filter is set, or `null` while it is not. */\n activeLabel: string | null;\n /** Unsets the filter: the chip's remove button and Clear all call it. */\n onClear: () => void;\n}\n\nexport type FilterBarField = FilterBarSelectField | FilterBarCustomField;\n\nexport interface FilterBarProps {\n /** Always in the row, at its start: status tabs and the search box. */\n inline?: ReactNode;\n /** Always in the row, at its end: a count, Export, a view toggle. */\n end?: ReactNode;\n /** The filters behind the Filters button. With none, no button renders. */\n filters: readonly FilterBarField[];\n /** Resets every filter in one step. Without it, each set filter is handed its `emptyValue`. */\n onClearAll?: () => void;\n /**\n * The button's text, and the popover's name.\n *\n * @default \"Filters\"\n */\n buttonLabel?: string;\n /**\n * The text of both Clear all buttons.\n *\n * @default \"Clear all\"\n */\n clearAllLabel?: string;\n /**\n * The text of the button that closes the popover.\n *\n * @default \"Done\"\n */\n doneLabel?: string;\n /**\n * The accessible name of the list of chips.\n *\n * @default \"Filters set\"\n */\n chipsLabel?: string;\n /**\n * The accessible name of a chip's remove button, given the chip's text.\n *\n * @default (text) => `Remove filter ${text}`\n */\n removeLabel?: (chipText: string) => string;\n /** Extra classes on the root. Merged last, so they win conflicts with ours. */\n className?: string;\n}\n\nconst isCustom = (f: FilterBarField): f is FilterBarCustomField => \"render\" in f;\n\ninterface Chip {\n id: string;\n text: string;\n clear: () => void;\n}\n\n/** The set filters, each with its chip text and how to unset it. */\nfunction chipsFor(filters: readonly FilterBarField[]): Chip[] {\n const chips: Chip[] = [];\n for (const f of filters) {\n if (isCustom(f)) {\n if (f.activeLabel != null) chips.push({ id: f.id, text: `${f.label}: ${f.activeLabel}`, clear: f.onClear });\n continue;\n }\n if (f.value == null || f.value === f.emptyValue) continue;\n const option = f.options.find((o) => o.id === f.value);\n chips.push({\n id: f.id,\n text: `${f.label}: ${option ? option.label : String(f.value)}`,\n clear: () => f.onChange(f.emptyValue),\n });\n }\n return chips;\n}\n\n/** A funnel, drawn inline: this package ships no icon dependency. */\nfunction FunnelGlyph() {\n return (\n <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" aria-hidden=\"true\">\n <path d=\"M2 3h12M4.5 8h7M7 13h2\" strokeLinecap=\"round\" />\n </svg>\n );\n}\n\nfunction CrossGlyph() {\n return (\n <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" aria-hidden=\"true\">\n <path d=\"M4 4l8 8M12 4l-8 8\" strokeLinecap=\"round\" />\n </svg>\n );\n}\n\n/**\n * A list toolbar with its dropdown filters behind one Filters button.\n *\n * @example\n * <FilterBar\n * inline={<SearchField aria-label=\"Search\" />}\n * end={<Button>Export</Button>}\n * filters={[{ id: \"region\", label: \"Region\", value, emptyValue: \"all\", onChange: setValue,\n * options: [{ id: \"all\", label: \"All regions\" }, { id: \"nsw\", label: \"NSW\" }] }]}\n * />\n */\n/**\n * One place in the chip row, for a chip or for Clear all. A slot added after the\n * first render opens from nothing while its content fades up and scales in, so the\n * chips beside it glide over; one that is removed stays, shrinking and collapsing,\n * until its exit ends. Nothing animates at first render.\n */\nfunction Slot({\n leaving,\n ready,\n onDone,\n id,\n children,\n}: {\n leaving: boolean;\n ready: boolean;\n onDone: (id: string) => void;\n id: string;\n children: ReactNode;\n}) {\n // Decided once, at this slot's own mount.\n const [fresh] = useState(ready);\n const remove = useCallback(() => onDone(id), [onDone, id]);\n useExitBackstop(leaving, remove, 900);\n // Reduced motion removes it at once: an animation that is switched off never ends.\n useIsomorphicLayoutEffect(() => {\n if (leaving && prefersReducedMotion()) remove();\n }, [leaving, remove]);\n return (\n <li\n data-slot={leaving ? \"filter-bar-leaving\" : undefined}\n aria-hidden={leaving || undefined}\n ref={(node) => {\n if (!node) return;\n if (leaving) node.setAttribute(\"inert\", \"\");\n else node.removeAttribute(\"inert\");\n }}\n onAnimationEnd={(event) => {\n if (leaving && event.target === event.currentTarget && event.animationName === \"chip-slot-out\")\n remove();\n }}\n className={cnAll(\n \"min-w-0 flex-none [interpolate-size:allow-keywords]\",\n leaving\n ? \"pointer-events-none motion-safe:animate-chip-out\"\n : fresh && \"motion-safe:animate-chip-in motion-reduce:animate-fade-in\",\n )}\n >\n {children}\n </li>\n );\n}\n\n/** A chip's text: a changed value swaps (the new text rises in) and the chip's width springs to it. */\nfunction ChipText({ text }: { text: string }) {\n const content = useRef<HTMLSpanElement>(null);\n useMorphWidth(content, text);\n return (\n <span className=\"button-slot\">\n <span ref={content} className=\"inline-flex flex-none items-center\">\n <SwapText swapKey={text} className=\"inline-block\">\n {text}\n </SwapText>\n </span>\n </span>\n );\n}\n\nexport const FilterBar = forwardRef<HTMLDivElement, FilterBarProps>(function FilterBar(\n {\n inline,\n end,\n filters,\n onClearAll,\n buttonLabel = \"Filters\",\n clearAllLabel = \"Clear all\",\n doneLabel = \"Done\",\n chipsLabel = \"Filters set\",\n removeLabel = (text) => `Remove filter ${text}`,\n className,\n },\n ref,\n) {\n const [open, setOpen] = useState(false);\n const chips = chipsFor(filters);\n const [ready, setReady] = useState(false);\n useEffect(() => {\n // A frame after mount: chips added from then on arrive animated, the first ones do not.\n const frame = requestAnimationFrame(() => setReady(true));\n return () => cancelAnimationFrame(frame);\n }, []);\n // The chips, with Clear all as the row's last place, each kept on screen while it leaves.\n const places = useLeavingList([\n ...chips.map((chip) => ({ id: chip.id, chip })),\n ...(chips.length > 0 ? [{ id: \"\\u0000clear\", chip: null }] : []),\n ]);\n const frame = useRef<HTMLDivElement>(null);\n const row = useRef<HTMLUListElement>(null);\n // The row follows its height when a chip makes a line wrap or unwrap.\n useHeightFollow(frame, row, chips.map((chip) => chip.id).join());\n const clearAll = () => {\n if (onClearAll) onClearAll();\n else for (const c of chips) c.clear();\n };\n\n return (\n <div ref={ref} data-slot=\"filter-bar\" className={cn(filterBarVariants(), className)}>\n <div data-slot=\"filter-bar-row\" className={filterBarRowVariants()}>\n {inline}\n {filters.length > 0 ? (\n <PopoverTrigger isOpen={open} onOpenChange={setOpen}>\n <Button variant=\"outlineNeutral\" size=\"sm\" startIcon={<FunnelGlyph />} data-slot=\"filter-bar-button\">\n {buttonLabel}\n {chips.length > 0 ? (\n <Badge tone=\"primary\" appearance=\"solid\" size=\"sm\" shape=\"pill\" data-slot=\"filter-bar-count\">\n {chips.length}\n </Badge>\n ) : null}\n </Button>\n <Popover placement=\"bottom start\" className=\"w-80 max-w-[calc(100vw-2rem)]\">\n <div data-slot=\"filter-bar-panel\" className=\"flex flex-col gap-3\">\n <p className=\"m-0 text-sm font-semibold\">{buttonLabel}</p>\n {filters.map((f) =>\n isCustom(f) ? (\n <div key={f.id}>{f.render()}</div>\n ) : (\n <Select\n key={f.id}\n label={f.label}\n size=\"sm\"\n selectedKey={f.value}\n onSelectionChange={(key) => {\n if (key != null) f.onChange(key);\n }}\n >\n {f.options.map((o) => (\n <SelectItem key={o.id} id={o.id} textValue={o.label}>\n {o.label}\n </SelectItem>\n ))}\n </Select>\n ),\n )}\n <div className=\"flex items-center justify-between gap-2 pt-1\">\n <Button variant=\"ghost\" size=\"sm\" onPress={clearAll} isDisabled={chips.length === 0}>\n {clearAllLabel}\n </Button>\n <Button variant=\"primary\" size=\"sm\" onPress={() => setOpen(false)}>\n {doneLabel}\n </Button>\n </div>\n </div>\n </Popover>\n </PopoverTrigger>\n ) : null}\n {end ? <div className=\"ms-auto flex flex-wrap items-center gap-2\">{end}</div> : null}\n </div>\n {places.list.length > 0 ? (\n <div ref={frame} data-slot=\"filter-bar-chips-frame\" className=\"height-follow\">\n <ul\n ref={row}\n aria-label={chipsLabel}\n data-slot=\"filter-bar-chips\"\n className=\"m-0 flex list-none flex-wrap items-center gap-2 p-0\"\n >\n {places.list.map(({ item, leaving }) =>\n item.chip ? (\n <Slot key={item.id} id={item.id} leaving={leaving} ready={ready} onDone={places.done}>\n <span data-slot=\"filter-bar-chip\" className={filterBarChipVariants()}>\n <ChipText text={item.chip.text} />\n <Button\n variant=\"ghost\"\n size=\"sm\"\n aria-label={removeLabel(item.chip.text)}\n onPress={item.chip.clear}\n className=\"h-6 px-1\"\n >\n <CrossGlyph />\n </Button>\n </span>\n </Slot>\n ) : (\n <Slot key={item.id} id={item.id} leaving={leaving} ready={ready} onDone={places.done}>\n <Button variant=\"link\" size=\"sm\" onPress={clearAll}>\n {clearAllLabel}\n </Button>\n </Slot>\n ),\n )}\n </ul>\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,oBAAoB,IAAI,CAAC,0CAA0C,CAAC;AAEjF,MAAa,uBAAuB,IAAI,CAAC,mCAAmC,CAAC;AAE7E,MAAa,wBAAwB,IAAI;CACvC;CACA;CACA;CACA;AACF,CAAC;AAwFD,MAAM,YAAY,MAAiD,YAAY;;AAS/E,SAAS,SAAS,SAA4C;CAC5D,MAAM,QAAgB,CAAC;CACvB,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,SAAS,CAAC,GAAG;GACf,IAAI,EAAE,eAAe,MAAM,MAAM,KAAK;IAAE,IAAI,EAAE;IAAI,MAAM,GAAG,EAAE,MAAM,IAAI,EAAE;IAAe,OAAO,EAAE;GAAQ,CAAC;GAC1G;EACF;EACA,IAAI,EAAE,SAAS,QAAQ,EAAE,UAAU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A,CACK;IACd,CAAA,IAAA;IACH,MAAM,oBAAC,OAAD;KAAK,WAAU;KAA6C,UAAA;IAAS,CAAA,IAAI;GAC7E;EACJ,CAAA,GAAA,OAAO,KAAK,SAAS,IACpB,oBAAC,OAAD;GAAK,KAAK;GAAO,aAAU;GAAyB,WAAU;GAC5D,UAAA,oBAAC,MAAD;IACE,KAAK;IACL,cAAY;IACZ,aAAU;IACV,WAAU;IAET,UAAA,OAAO,KAAK,KAAK,EAAE,MAAM,cACxB,KAAK,OACH,oBAAC,MAAD;KAAoB,IAAI,KAAK;KAAa;KAAgB;KAAO,QAAQ,OAAO;KAC9E,UAAA,qBAAC,QAAD;MAAM,aAAU;MAAkB,WAAW,sBAAsB;MAAnE,UAAA,CACE,oBAAC,UAAD,EAAU,MAAM,KAAK,KAAK,KAAO,CAAA,GACjC,oBAAC,QAAD;OACE,SAAQ;OACR,MAAK;OACL,cAAY,YAAY,KAAK,KAAK,IAAI;OACtC,SAAS,KAAK,KAAK;OACnB,WAAU;OAEV,UAAA,oBAAC,YAAD,CAAa,CAAA;MACP,CAAA,CACJ;;IACF,GAbK,KAAK,EAaV,IAEN,oBAAC,MAAD;KAAoB,IAAI,KAAK;KAAa;KAAgB;KAAO,QAAQ,OAAO;KAC9E,UAAA,oBAAC,QAAD;MAAQ,SAAQ;MAAO,MAAK;MAAK,SAAS;MACvC,UAAA;KACK,CAAA;IACJ,GAJK,KAAK,EAIV,CAEV;GACE,CAAA;EACD,CAAA,IACH,IACD;;AAET,CAAC"}
|
|
1
|
+
{"version":3,"file":"filter-bar.js","names":["Button","AriaMenu","MenuItem","Popover"],"sources":["../../src/filter-bar/filter-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef, useCallback, useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { Menu as AriaMenu, type Key } from \"react-aria-components\";\n\nimport { Button } from \"../button/button.js\";\nimport { cn, cnAll } from \"../lib/cn.js\";\nimport { useHeightFollow } from \"../lib/height-follow.js\";\nimport { useLeavingList } from \"../lib/leaving-list.js\";\nimport { useMenuHighlight } from \"../lib/menu-highlight.js\";\nimport { prefersReducedMotion, useExitBackstop, useIsomorphicLayoutEffect, useMorphWidth } from \"../lib/motion.js\";\nimport { SwapText } from \"../lib/swap-text.js\";\nimport { MenuItem, menuVariants } from \"../menu/menu.js\";\nimport { Popover, PopoverTrigger } from \"../popover/popover.js\";\n\n/**\n * FilterBar -- a filter toolbar: one pill that shows what is filtered as\n * removable chips (\"No filters applied\" while nothing is), with an \"Add filter\"\n * button that opens a menu of the filters.\n *\n * Why it exists: list screens grew a row of four to seven dropdowns beside\n * the search box and the status tabs. At desktop width that row wraps onto a\n * second line; on a phone it scrolls sideways. The bar keeps the row to one\n * line and makes what IS filtered visible as chips instead of as the\n * resting text of a dropdown.\n *\n * Three regions, all inside the one pill:\n *\n * - `inline`: always in the pill, at its start (status tabs, a search box).\n * - the chips, then \"Clear all\" once any filter is set; or the empty note.\n * - the Add filter button, then `end`: always in the pill, at its end (a\n * count, Export, a view toggle).\n *\n * The button opens a menu of the filters: each row is the filter's icon and\n * name, the value it holds now, and a chevron. A row opens that filter's own\n * options in the same panel (a back button returns to the list); choosing an\n * option sets the filter and closes the menu. A custom filter shows its own\n * control in that step.\n *\n * The bar holds NO filter state. Every value and every change belongs to the\n * caller: removing a chip hands the filter's `emptyValue` back to its\n * `onChange`; Clear all does that for each set filter, or calls\n * `onClearAll` when the caller resets its filters in one step.\n *\n * Accessibility comes from the parts: the panel is a dialog named by its\n * trigger, the trigger carries `aria-expanded`, focus moves into the panel and\n * is contained there, Escape closes it and focus returns to the trigger, and\n * each list is a real menu with arrow keys and type-ahead.\n */\n\n/** The toolbar: one pill with a light border on the surface. */\nexport const filterBarVariants = cva([\n \"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-full\",\n \"border-(length:--border-width) border-border bg-surface\",\n \"px-4 py-2 box-border font-sans\",\n]);\n\n/** The group at the pill's end: the Add filter button and the caller's `end`. */\nexport const filterBarRowVariants = cva([\"ms-auto flex flex-wrap items-center gap-2\"]);\n\nexport const filterBarChipVariants = cva([\n \"inline-flex items-center gap-1 rounded-full\",\n \"border-(length:--border-width) border-border bg-muted\",\n \"ps-3 pe-1 text-xs leading-(--leading-snug) text-foreground\",\n \"box-border font-sans\",\n]);\n\n/** One option of a dropdown filter. */\nexport interface FilterBarOption {\n /** The option's value, handed to `onChange`. */\n id: Key;\n /** The option's text: in the list, on the trigger and on the chip. */\n label: string;\n}\n\n/** A dropdown filter: a row in the Add filter menu that opens its options. */\nexport interface FilterBarSelectField {\n /** Stable identity, used as the React key. */\n id: string;\n /** The field's name: its row in the menu and the start of its chip. */\n label: string;\n /** An icon before the name in the menu row. Mark it `aria-hidden`. */\n icon?: ReactNode;\n /** The current value. `null` reads as not set. */\n value: Key | null;\n /** The value that means \"not filtered\" (the \"All\" option's id). */\n emptyValue: Key;\n /** The options, the \"All\" option included. */\n options: readonly FilterBarOption[];\n /** Told the chosen option's id, or `emptyValue` when the chip is removed. */\n onChange: (value: Key) => void;\n}\n\n/**\n * A filter that is not a plain dropdown (a date range, a searchable picker):\n * the caller renders the control and says what its chip reads.\n */\nexport interface FilterBarCustomField {\n /** Stable identity, used as the React key. */\n id: string;\n /** The start of its chip, and its row in the menu. The control rendered by `render` names itself. */\n label: string;\n /** An icon before the name in the menu row. Mark it `aria-hidden`. */\n icon?: ReactNode;\n /** The control, rendered in the menu's step for this filter. */\n render: () => ReactNode;\n /** The chip's value text while the filter is set, or `null` while it is not. */\n activeLabel: string | null;\n /** Unsets the filter: the chip's remove button and Clear all call it. */\n onClear: () => void;\n}\n\nexport type FilterBarField = FilterBarSelectField | FilterBarCustomField;\n\nexport interface FilterBarProps {\n /** Always in the pill, at its start: status tabs and the search box. */\n inline?: ReactNode;\n /** Always in the pill, at its end: a count, Export, a view toggle. */\n end?: ReactNode;\n /** The filters in the Add filter menu. With none, no button renders. */\n filters: readonly FilterBarField[];\n /** Resets every filter in one step. Without it, each set filter is handed its `emptyValue`. */\n onClearAll?: () => void;\n /**\n * The button's text, and the menu's name.\n *\n * @default \"Add filter\"\n */\n buttonLabel?: string;\n /**\n * The text of Clear all.\n *\n * @default \"Clear all\"\n */\n clearAllLabel?: string;\n /**\n * Ignored: the menu has no Done button, because choosing an option closes it.\n *\n * @deprecated Kept so existing callers still compile.\n */\n doneLabel?: string;\n /**\n * The note shown while no filter is set.\n *\n * @default \"No filters applied\"\n */\n emptyLabel?: string;\n /**\n * The accessible name of the list of chips.\n *\n * @default \"Filters set\"\n */\n chipsLabel?: string;\n /**\n * The accessible name of a chip's remove button, given the chip's text.\n *\n * @default (text) => `Remove filter ${text}`\n */\n removeLabel?: (chipText: string) => string;\n /**\n * The accessible name of the menu's back button.\n *\n * @default \"Back to filters\"\n */\n backLabel?: string;\n /** Extra classes on the root. Merged last, so they win conflicts with ours. */\n className?: string;\n}\n\nconst isCustom = (f: FilterBarField): f is FilterBarCustomField => \"render\" in f;\n\ninterface Chip {\n id: string;\n text: string;\n clear: () => void;\n}\n\n/** What a filter holds now, for its menu row and its chip: `null` while it is not set. */\nfunction valueOf(f: FilterBarField): string | null {\n if (isCustom(f)) return f.activeLabel;\n if (f.value == null || f.value === f.emptyValue) return null;\n const option = f.options.find((o) => o.id === f.value);\n return option ? option.label : String(f.value);\n}\n\n/** The set filters, each with its chip text and how to unset it. */\nfunction chipsFor(filters: readonly FilterBarField[]): Chip[] {\n const chips: Chip[] = [];\n for (const f of filters) {\n const value = valueOf(f);\n if (value == null) continue;\n chips.push({\n id: f.id,\n text: `${f.label}: ${value}`,\n clear: isCustom(f) ? f.onClear : () => f.onChange(f.emptyValue),\n });\n }\n return chips;\n}\n\nfunction Glyph({ path }: { path: string }) {\n return (\n <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" aria-hidden=\"true\">\n <path d={path} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n );\n}\n\nconst PlusGlyph = () => <Glyph path=\"M8 3v10M3 8h10\" />;\nconst CrossGlyph = () => <Glyph path=\"M4 4l8 8M12 4l-8 8\" />;\nconst ChevronRightGlyph = () => <Glyph path=\"M6 3l5 5-5 5\" />;\nconst ChevronLeftGlyph = () => <Glyph path=\"M10 3 5 8l5 5\" />;\nconst CheckGlyph = () => <Glyph path=\"M3 8.5l3.5 3.5L13 4.5\" />;\n\n/**\n * A list toolbar with its filters behind one Add filter button.\n *\n * @example\n * <FilterBar\n * end={<Button>Export</Button>}\n * filters={[{ id: \"status\", label: \"Status\", icon: <StatusIcon aria-hidden />, value, emptyValue: \"all\",\n * onChange: setValue, options: [{ id: \"all\", label: \"Any status\" }, { id: \"open\", label: \"Open\" }] }]}\n * />\n */\n/**\n * One place in the chip row, for a chip or for Clear all. A slot added after the\n * first render opens from nothing while its content fades up and scales in, so the\n * chips beside it glide over; one that is removed stays, shrinking and collapsing,\n * until its exit ends. Nothing animates at first render.\n */\nfunction Slot({\n leaving,\n ready,\n onDone,\n id,\n children,\n}: {\n leaving: boolean;\n ready: boolean;\n onDone: (id: string) => void;\n id: string;\n children: ReactNode;\n}) {\n // Decided once, at this slot's own mount.\n const [fresh] = useState(ready);\n const remove = useCallback(() => onDone(id), [onDone, id]);\n useExitBackstop(leaving, remove, 900);\n // Reduced motion removes it at once: an animation that is switched off never ends.\n useIsomorphicLayoutEffect(() => {\n if (leaving && prefersReducedMotion()) remove();\n }, [leaving, remove]);\n return (\n <li\n data-slot={leaving ? \"filter-bar-leaving\" : undefined}\n aria-hidden={leaving || undefined}\n ref={(node) => {\n if (!node) return;\n if (leaving) node.setAttribute(\"inert\", \"\");\n else node.removeAttribute(\"inert\");\n }}\n onAnimationEnd={(event) => {\n if (leaving && event.target === event.currentTarget && event.animationName === \"chip-slot-out\")\n remove();\n }}\n className={cnAll(\n \"min-w-0 flex-none [interpolate-size:allow-keywords]\",\n leaving\n ? \"pointer-events-none motion-safe:animate-chip-out\"\n : fresh && \"motion-safe:animate-chip-in motion-reduce:animate-fade-in\",\n )}\n >\n {children}\n </li>\n );\n}\n\n/** A chip's text: a changed value swaps (the new text rises in) and the chip's width springs to it. */\nfunction ChipText({ text }: { text: string }) {\n const content = useRef<HTMLSpanElement>(null);\n useMorphWidth(content, text);\n return (\n <span className=\"button-slot\">\n <span ref={content} className=\"inline-flex flex-none items-center\">\n <SwapText swapKey={text} className=\"inline-block\">\n {text}\n </SwapText>\n </span>\n </span>\n );\n}\n\n/** A filter's icon, drawn at the control icon size in the secondary ink. */\nfunction RowIcon({ icon }: { icon: ReactNode }) {\n return icon ? (\n <span aria-hidden=\"true\" className=\"inline-flex text-text-secondary\">\n {icon}\n </span>\n ) : null;\n}\n\n/** The note for no filters. Arriving after the first render (the last chip has gone) it fades in; at first render it does not. */\nfunction EmptyNote({ ready, children }: { ready: boolean; children: ReactNode }) {\n // Decided once, at this note's own mount: adding the class later would start the animation on a note already on screen.\n const [fresh] = useState(ready);\n return (\n <span\n data-slot=\"filter-bar-empty\"\n className={cn(\"text-sm text-text-secondary\" + (fresh ? \" motion-safe:animate-fade-in\" : \"\"))}\n >\n {children}\n </span>\n );\n}\n\nconst STEP = \"motion-safe:animate-filter-step-in motion-reduce:animate-fade-in\";\n\n/**\n * The Add filter menu's panel, in two steps: the list of filters, then the\n * chosen filter's options (or its own control). A step arrives from the side it\n * was reached from; the first one, on open, does not animate by itself (the\n * popover grows from the button instead).\n */\nfunction FilterPanel({\n filters,\n label,\n backLabel,\n onClose,\n}: {\n filters: readonly FilterBarField[];\n label: string;\n backLabel: string;\n onClose: () => void;\n}) {\n const [fieldId, setFieldId] = useState<string | null>(null);\n // null until the user has navigated: the first step does not animate by itself.\n const [dir, setDir] = useState<1 | -1 | null>(null);\n // The filter whose step we came back from: focus returns to its row.\n const [returnTo, setReturnTo] = useState<string | null>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const bindFields = useMenuHighlight();\n const bindOptions = useMenuHighlight();\n const field = filters.find((f) => f.id === fieldId) ?? null;\n\n // Coming back, focus lands on the row that was opened rather than on the first one.\n // The rows of a React Aria menu land a frame after it mounts, so this waits for the row.\n useEffect(() => {\n if (field || returnTo === null) return;\n const id = returnTo;\n let frame = 0;\n let tries = 0;\n const focusRow = () => {\n const row = Array.from(\n listRef.current?.querySelectorAll<HTMLElement>(\"[data-slot='menu-item']\") ?? [],\n ).find((node) => node.dataset.key === id);\n if (row) row.focus();\n else if (tries++ < 20) frame = requestAnimationFrame(focusRow);\n };\n focusRow();\n return () => cancelAnimationFrame(frame);\n }, [field, returnTo]);\n\n const open = (id: Key) => {\n setDir(1);\n setFieldId(String(id));\n };\n const back = () => {\n if (!field) return;\n setReturnTo(field.id);\n setDir(-1);\n setFieldId(null);\n };\n const stepClass = dir === null ? \"\" : cn(STEP + (dir === 1 ? \" [--step-dir:1]\" : \" [--step-dir:-1]\"));\n\n return (\n <div data-slot=\"filter-bar-panel\" className=\"overflow-x-clip\">\n {field ? (\n <div\n key={field.id}\n className={stepClass}\n onKeyDown={(event) => {\n // Arrow left steps back, from the options list; a custom control keeps its own keys.\n if (event.key === \"ArrowLeft\" && !isCustom(field)) {\n event.preventDefault();\n back();\n }\n }}\n >\n <div className=\"flex items-center gap-1 px-1 pb-1\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={backLabel}\n onPress={back}\n className=\"size-8 flex-none rounded-full\"\n >\n <ChevronLeftGlyph />\n </Button>\n <span className=\"min-w-0 truncate text-sm font-medium text-foreground\">{field.label}</span>\n </div>\n {isCustom(field) ? (\n <div className=\"p-1.5\">{field.render()}</div>\n ) : (\n <AriaMenu\n ref={bindOptions}\n aria-label={field.label}\n data-slot=\"filter-bar-options\"\n autoFocus=\"first\"\n selectionMode=\"single\"\n disallowEmptySelection\n selectedKeys={field.value == null ? [] : [field.value]}\n onAction={(key) => {\n field.onChange(key);\n onClose();\n }}\n className={menuVariants()}\n >\n {field.options.map((o) => (\n <MenuItem key={o.id} id={o.id} textValue={o.label}>\n <span className=\"min-w-0 flex-1 truncate\">{o.label}</span>\n <span\n aria-hidden=\"true\"\n className={\n o.id === field.value\n ? \"inline-flex text-foreground\"\n : \"inline-flex text-foreground opacity-0\"\n }\n >\n <CheckGlyph />\n </span>\n </MenuItem>\n ))}\n </AriaMenu>\n )}\n </div>\n ) : (\n <div key=\"fields\" ref={listRef} className={stepClass}>\n <AriaMenu\n ref={bindFields}\n aria-label={label}\n data-slot=\"filter-bar-fields\"\n autoFocus={returnTo === null ? \"first\" : false}\n onAction={open}\n // Choosing a filter opens its options; it must not close the panel.\n onClose={() => {}}\n className={menuVariants()}\n >\n {filters.map((f) => {\n const value = valueOf(f);\n return (\n <MenuItem key={f.id} id={f.id} textValue={f.label}>\n <RowIcon icon={f.icon} />\n <span className=\"min-w-0 flex-1 truncate\">{f.label}</span>\n {value ? (\n <span className=\"max-w-24 truncate text-xs text-text-secondary\">{value}</span>\n ) : null}\n <span aria-hidden=\"true\" className=\"inline-flex text-text-secondary\">\n <ChevronRightGlyph />\n </span>\n </MenuItem>\n );\n })}\n </AriaMenu>\n </div>\n )}\n </div>\n );\n}\n\nexport const FilterBar = forwardRef<HTMLDivElement, FilterBarProps>(function FilterBar(\n {\n inline,\n end,\n filters,\n onClearAll,\n buttonLabel = \"Add filter\",\n clearAllLabel = \"Clear all\",\n emptyLabel = \"No filters applied\",\n chipsLabel = \"Filters set\",\n removeLabel = (text) => `Remove filter ${text}`,\n backLabel = \"Back to filters\",\n className,\n },\n ref,\n) {\n const [open, setOpen] = useState(false);\n const chips = chipsFor(filters);\n const [ready, setReady] = useState(false);\n useEffect(() => {\n // A frame after mount: chips added from then on arrive animated, the first ones do not.\n const frame = requestAnimationFrame(() => setReady(true));\n return () => cancelAnimationFrame(frame);\n }, []);\n // The chips, with Clear all as the row's last place, each kept on screen while it leaves.\n const places = useLeavingList([\n ...chips.map((chip) => ({ id: chip.id, chip })),\n ...(chips.length > 0 ? [{ id: \"\\u0000clear\", chip: null }] : []),\n ]);\n const frame = useRef<HTMLDivElement>(null);\n const row = useRef<HTMLUListElement>(null);\n // The row follows its height when a chip makes a line wrap or unwrap.\n useHeightFollow(frame, row, chips.map((chip) => chip.id).join());\n const clearAll = () => {\n if (onClearAll) onClearAll();\n else for (const c of chips) c.clear();\n };\n\n return (\n <div ref={ref} data-slot=\"filter-bar\" className={cn(filterBarVariants(), className)}>\n {inline ? <div className=\"flex flex-wrap items-center gap-2\">{inline}</div> : null}\n <div\n data-slot=\"filter-bar-chips-area\"\n className=\"flex min-h-(--density-control-h-sm) min-w-0 flex-[1_1_8rem] items-center\"\n >\n {places.list.length > 0 ? (\n <div ref={frame} data-slot=\"filter-bar-chips-frame\" className=\"height-follow min-w-0\">\n <ul\n ref={row}\n aria-label={chipsLabel}\n data-slot=\"filter-bar-chips\"\n className=\"m-0 flex list-none flex-wrap items-center gap-2 p-0\"\n >\n {places.list.map(({ item, leaving }) =>\n item.chip ? (\n <Slot key={item.id} id={item.id} leaving={leaving} ready={ready} onDone={places.done}>\n <span data-slot=\"filter-bar-chip\" className={filterBarChipVariants()}>\n <ChipText text={item.chip.text} />\n <Button\n variant=\"ghost\"\n size=\"sm\"\n aria-label={removeLabel(item.chip.text)}\n onPress={item.chip.clear}\n className=\"h-6 px-1\"\n >\n <CrossGlyph />\n </Button>\n </span>\n </Slot>\n ) : (\n <Slot key={item.id} id={item.id} leaving={leaving} ready={ready} onDone={places.done}>\n <Button variant=\"link\" size=\"sm\" onPress={clearAll}>\n {clearAllLabel}\n </Button>\n </Slot>\n ),\n )}\n </ul>\n </div>\n ) : (\n <EmptyNote ready={ready}>{emptyLabel}</EmptyNote>\n )}\n </div>\n {filters.length > 0 || end ? (\n <div data-slot=\"filter-bar-actions\" className={filterBarRowVariants()}>\n {filters.length > 0 ? (\n <PopoverTrigger isOpen={open} onOpenChange={setOpen}>\n <Button\n variant=\"outlineNeutral\"\n size=\"sm\"\n startIcon={<PlusGlyph />}\n data-slot=\"filter-bar-button\"\n >\n {buttonLabel}\n </Button>\n <Popover\n placement=\"bottom end\"\n offset={8}\n className=\"w-64 max-w-[calc(100vw-2rem)] p-1.5\"\n >\n <FilterPanel\n filters={filters}\n label={buttonLabel}\n backLabel={backLabel}\n onClose={() => setOpen(false)}\n />\n </Popover>\n </PopoverTrigger>\n ) : null}\n {end}\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,oBAAoB,IAAI;CACnC;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAuB,IAAI,CAAC,2CAA2C,CAAC;AAErF,MAAa,wBAAwB,IAAI;CACvC;CACA;CACA;CACA;AACF,CAAC;AAwGD,MAAM,YAAY,MAAiD,YAAY;;AAS/E,SAAS,QAAQ,GAAkC;CACjD,IAAI,SAAS,CAAC,GAAG,OAAO,EAAE;CAC1B,IAAI,EAAE,SAAS,QAAQ,EAAE,UAAU,EAAE,YAAY,OAAO;CACxD,MAAM,SAAS,EAAE,QAAQ,MAAM,MAAM,EAAE,OAAO,EAAE,KAAK;CACrD,OAAO,SAAS,OAAO,QAAQ,OAAO,EAAE,KAAK;AAC/C;;AAGA,SAAS,SAAS,SAA4C;CAC5D,MAAM,QAAgB,CAAC;CACvB,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,QAAQ,QAAQ,CAAC;EACvB,IAAI,SAAS,MAAM;EACnB,MAAM,KAAK;GACT,IAAI,EAAE;GACN,MAAM,GAAG,EAAE,MAAM,IAAI;GACrB,OAAO,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU;EAChE,CAAC;CACH;CACA,OAAO;AACT;AAEA,SAAS,MAAM,EAAE,QAA0B;CACzC,OACE,oBAAC,OAAD;EAAK,SAAQ;EAAY,MAAK;EAAO,QAAO;EAAe,aAAY;EAAM,eAAY;EACvF,UAAA,oBAAC,QAAD;GAAM,GAAG;GAAM,eAAc;GAAQ,gBAAe;EAAS,CAAA;CAC1D,CAAA;AA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