@seekalfred/primitives 0.5.1 → 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 +682 -19
- package/dist/accordion/accordion.js +10 -4
- package/dist/accordion/accordion.js.map +1 -1
- package/dist/action-button/action-button.d.ts +50 -0
- package/dist/action-button/action-button.js +159 -0
- package/dist/action-button/action-button.js.map +1 -0
- package/dist/action-button/index.d.ts +2 -0
- package/dist/action-button/index.js +2 -0
- 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 +19 -1
- package/dist/alert/alert.js +180 -23
- 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/avatar/avatar.d.ts +6 -0
- package/dist/avatar/avatar.js +47 -16
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/badge/badge.d.ts +10 -3
- package/dist/badge/badge.js +35 -5
- package/dist/badge/badge.js.map +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 -29
- package/dist/breadcrumb/breadcrumb.js +32 -9
- 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 +36 -23
- package/dist/button/button.js +198 -45
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.d.ts +76 -0
- package/dist/button-group/button-group.js +402 -0
- package/dist/button-group/button-group.js.map +1 -0
- package/dist/button-group/index.d.ts +2 -0
- package/dist/button-group/index.js +2 -0
- package/dist/calendar/calendar.d.ts +1 -1
- package/dist/calendar/calendar.js +257 -30
- package/dist/calendar/calendar.js.map +1 -1
- package/dist/card/card.d.ts +9 -2
- package/dist/card/card.js +16 -5
- 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.d.ts +0 -7
- package/dist/checkbox/checkbox.js +26 -29
- 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/confirm-morph/confirm-morph.d.ts +85 -0
- package/dist/confirm-morph/confirm-morph.js +652 -0
- package/dist/confirm-morph/confirm-morph.js.map +1 -0
- package/dist/confirm-morph/index.d.ts +2 -0
- package/dist/confirm-morph/index.js +2 -0
- package/dist/copy-button/copy-button.d.ts +32 -0
- package/dist/copy-button/copy-button.js +134 -0
- package/dist/copy-button/copy-button.js.map +1 -0
- package/dist/copy-button/index.d.ts +2 -0
- package/dist/copy-button/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/date-picker.d.ts +51 -0
- package/dist/date-picker/date-picker.js +241 -0
- package/dist/date-picker/date-picker.js.map +1 -0
- package/dist/date-picker/date-range-picker.d.ts +78 -0
- package/dist/date-picker/date-range-picker.js +1015 -0
- package/dist/date-picker/date-range-picker.js.map +1 -0
- package/dist/date-picker/index.d.ts +4 -0
- package/dist/date-picker/index.js +4 -0
- package/dist/date-picker/picker-parts.d.ts +46 -0
- package/dist/date-picker/picker-parts.js +135 -0
- package/dist/date-picker/picker-parts.js.map +1 -0
- package/dist/dialog/dialog.d.ts +10 -14
- package/dist/dialog/dialog.js +40 -12
- 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 +55 -0
- package/dist/empty-state/empty-state.js +89 -0
- package/dist/empty-state/empty-state.js.map +1 -0
- package/dist/empty-state/index.d.ts +2 -0
- package/dist/empty-state/index.js +2 -0
- package/dist/expanding-button-group/expanding-button-group.d.ts +54 -0
- package/dist/expanding-button-group/expanding-button-group.js +350 -0
- package/dist/expanding-button-group/expanding-button-group.js.map +1 -0
- package/dist/expanding-button-group/index.d.ts +2 -0
- package/dist/expanding-button-group/index.js +2 -0
- package/dist/file-drop-zone/file-drop-zone.d.ts +71 -0
- package/dist/file-drop-zone/file-drop-zone.js +116 -0
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -0
- package/dist/file-drop-zone/index.d.ts +2 -0
- package/dist/file-drop-zone/index.js +2 -0
- package/dist/filter-bar/filter-bar.d.ts +142 -0
- package/dist/filter-bar/filter-bar.js +416 -0
- package/dist/filter-bar/filter-bar.js.map +1 -0
- package/dist/filter-bar/index.d.ts +2 -0
- package/dist/filter-bar/index.js +2 -0
- package/dist/floating-button-group/floating-button-group.d.ts +61 -0
- package/dist/floating-button-group/floating-button-group.js +340 -0
- package/dist/floating-button-group/floating-button-group.js.map +1 -0
- package/dist/floating-button-group/index.d.ts +2 -0
- package/dist/floating-button-group/index.js +2 -0
- 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/icon-morph/icon-morph.d.ts +55 -0
- package/dist/icon-morph/icon-morph.js +331 -0
- package/dist/icon-morph/icon-morph.js.map +1 -0
- package/dist/icon-morph/index.d.ts +2 -0
- package/dist/icon-morph/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 +71 -6
- package/dist/index.js +73 -11
- package/dist/input/input.d.ts +22 -0
- package/dist/input/input.js +36 -12
- package/dist/input/input.js.map +1 -1
- package/dist/lib/cn.js +11 -1
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/count-to.js +113 -0
- package/dist/lib/count-to.js.map +1 -0
- package/dist/lib/eye-morph.js +62 -0
- package/dist/lib/eye-morph.js.map +1 -0
- package/dist/lib/field-message.js +354 -0
- package/dist/lib/field-message.js.map +1 -0
- package/dist/lib/field-shell.js +81 -0
- package/dist/lib/field-shell.js.map +1 -0
- package/dist/lib/field-surface.js +11 -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 +88 -0
- package/dist/lib/flip.js.map +1 -0
- package/dist/lib/height-follow.js +59 -0
- package/dist/lib/height-follow.js.map +1 -0
- package/dist/lib/icon-swap.js +47 -0
- package/dist/lib/icon-swap.js.map +1 -0
- package/dist/lib/leaving-list.js +57 -0
- package/dist/lib/leaving-list.js.map +1 -0
- package/dist/lib/menu-highlight.js +64 -0
- package/dist/lib/menu-highlight.js.map +1 -0
- package/dist/lib/merge-refs.js +3 -3
- package/dist/lib/merge-refs.js.map +1 -1
- package/dist/lib/morph-text.js +128 -0
- package/dist/lib/morph-text.js.map +1 -0
- package/dist/lib/motion.js +169 -0
- package/dist/lib/motion.js.map +1 -0
- package/dist/lib/pausable-timeout.js +67 -0
- package/dist/lib/pausable-timeout.js.map +1 -0
- package/dist/lib/rolling-value.js +31 -0
- package/dist/lib/rolling-value.js.map +1 -0
- package/dist/lib/spring-progress.js +114 -0
- package/dist/lib/spring-progress.js.map +1 -0
- package/dist/lib/spring-tween.js +500 -0
- package/dist/lib/spring-tween.js.map +1 -0
- package/dist/lib/svg-id.js +10 -0
- package/dist/lib/svg-id.js.map +1 -0
- package/dist/lib/swap-text.js +79 -0
- package/dist/lib/swap-text.js.map +1 -0
- package/dist/lib/use-copy-feedback.js +36 -0
- package/dist/lib/use-copy-feedback.js.map +1 -0
- 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/page-header/index.d.ts +2 -0
- package/dist/page-header/index.js +2 -0
- package/dist/page-header/page-header.d.ts +75 -0
- package/dist/page-header/page-header.js +83 -0
- package/dist/page-header/page-header.js.map +1 -0
- package/dist/password-field/index.d.ts +2 -0
- package/dist/password-field/index.js +2 -0
- package/dist/password-field/password-field.d.ts +37 -0
- package/dist/password-field/password-field.js +101 -0
- package/dist/password-field/password-field.js.map +1 -0
- package/dist/password-strength/index.d.ts +2 -0
- package/dist/password-strength/index.js +2 -0
- package/dist/password-strength/password-strength.d.ts +127 -0
- package/dist/password-strength/password-strength.js +455 -0
- package/dist/password-strength/password-strength.js.map +1 -0
- 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 +20 -0
- package/dist/popover/popover.js +33 -9
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.js +46 -5
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/radio-group.js +8 -7
- 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 +75 -28
- package/dist/scroll-area/scroll-area.js +212 -41
- 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/index.d.ts +2 -0
- package/dist/search-field/index.js +2 -0
- package/dist/search-field/search-field.d.ts +27 -0
- package/dist/search-field/search-field.js +155 -0
- package/dist/search-field/search-field.js.map +1 -0
- package/dist/select/select.d.ts +3 -1
- package/dist/select/select.js +95 -25
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/sheet/sheet.js +4 -2
- 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/side-nav/index.d.ts +2 -0
- package/dist/side-nav/index.js +2 -0
- package/dist/side-nav/side-nav.d.ts +72 -0
- package/dist/side-nav/side-nav.js +142 -0
- package/dist/side-nav/side-nav.js.map +1 -0
- package/dist/skeleton/skeleton.d.ts +8 -2
- package/dist/skeleton/skeleton.js +6 -2
- package/dist/skeleton/skeleton.js.map +1 -1
- package/dist/slider/index.d.ts +2 -2
- package/dist/slider/slider.d.ts +46 -14
- package/dist/slider/slider.js +188 -50
- 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/index.d.ts +2 -0
- package/dist/split-button/index.js +2 -0
- package/dist/split-button/split-button.d.ts +46 -0
- package/dist/split-button/split-button.js +123 -0
- package/dist/split-button/split-button.js.map +1 -0
- package/dist/stat-card/index.d.ts +2 -0
- package/dist/stat-card/index.js +2 -0
- package/dist/stat-card/stat-card.d.ts +101 -0
- package/dist/stat-card/stat-card.js +249 -0
- package/dist/stat-card/stat-card.js.map +1 -0
- 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 +10 -9
- 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 +87 -4
- package/dist/table/table.js +441 -165
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.js +143 -7
- 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/textarea/textarea.d.ts +23 -0
- package/dist/textarea/textarea.js +24 -2
- package/dist/textarea/textarea.js.map +1 -1
- package/dist/theme-switch/index.d.ts +2 -0
- package/dist/theme-switch/index.js +2 -0
- package/dist/theme-switch/theme-switch.d.ts +37 -0
- package/dist/theme-switch/theme-switch.js +123 -0
- package/dist/theme-switch/theme-switch.js.map +1 -0
- package/dist/time-picker/index.d.ts +2 -0
- package/dist/time-picker/index.js +2 -0
- package/dist/time-picker/time-picker.d.ts +54 -0
- package/dist/time-picker/time-picker.js +201 -0
- package/dist/time-picker/time-picker.js.map +1 -0
- 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 +98 -36
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +10 -3
- package/dist/tooltip/tooltip.js +67 -18
- 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 +245 -3
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { Key } from "react-aria-components";
|
|
3
|
+
//#region src/filter-bar/filter-bar.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* FilterBar -- a filter toolbar: one pill that shows what is filtered as
|
|
6
|
+
* removable chips ("No filters applied" while nothing is), with an "Add filter"
|
|
7
|
+
* button that opens a menu of the filters.
|
|
8
|
+
*
|
|
9
|
+
* Why it exists: list screens grew a row of four to seven dropdowns beside
|
|
10
|
+
* the search box and the status tabs. At desktop width that row wraps onto a
|
|
11
|
+
* second line; on a phone it scrolls sideways. The bar keeps the row to one
|
|
12
|
+
* line and makes what IS filtered visible as chips instead of as the
|
|
13
|
+
* resting text of a dropdown.
|
|
14
|
+
*
|
|
15
|
+
* Three regions, all inside the one pill:
|
|
16
|
+
*
|
|
17
|
+
* - `inline`: always in the pill, at its start (status tabs, a search box).
|
|
18
|
+
* - the chips, then "Clear all" once any filter is set; or the empty note.
|
|
19
|
+
* - the Add filter button, then `end`: always in the pill, at its end (a
|
|
20
|
+
* count, Export, a view toggle).
|
|
21
|
+
*
|
|
22
|
+
* The button opens a menu of the filters: each row is the filter's icon and
|
|
23
|
+
* name, the value it holds now, and a chevron. A row opens that filter's own
|
|
24
|
+
* options in the same panel (a back button returns to the list); choosing an
|
|
25
|
+
* option sets the filter and closes the menu. A custom filter shows its own
|
|
26
|
+
* control in that step.
|
|
27
|
+
*
|
|
28
|
+
* The bar holds NO filter state. Every value and every change belongs to the
|
|
29
|
+
* caller: removing a chip hands the filter's `emptyValue` back to its
|
|
30
|
+
* `onChange`; Clear all does that for each set filter, or calls
|
|
31
|
+
* `onClearAll` when the caller resets its filters in one step.
|
|
32
|
+
*
|
|
33
|
+
* Accessibility comes from the parts: the panel is a dialog named by its
|
|
34
|
+
* trigger, the trigger carries `aria-expanded`, focus moves into the panel and
|
|
35
|
+
* is contained there, Escape closes it and focus returns to the trigger, and
|
|
36
|
+
* each list is a real menu with arrow keys and type-ahead.
|
|
37
|
+
*/
|
|
38
|
+
/** The toolbar: one pill with a light border on the surface. */
|
|
39
|
+
export declare const filterBarVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
40
|
+
/** The group at the pill's end: the Add filter button and the caller's `end`. */
|
|
41
|
+
export declare const filterBarRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
42
|
+
export declare const filterBarChipVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
43
|
+
/** One option of a dropdown filter. */
|
|
44
|
+
export interface FilterBarOption {
|
|
45
|
+
/** The option's value, handed to `onChange`. */
|
|
46
|
+
id: Key;
|
|
47
|
+
/** The option's text: in the list, on the trigger and on the chip. */
|
|
48
|
+
label: string;
|
|
49
|
+
}
|
|
50
|
+
/** A dropdown filter: a row in the Add filter menu that opens its options. */
|
|
51
|
+
export interface FilterBarSelectField {
|
|
52
|
+
/** Stable identity, used as the React key. */
|
|
53
|
+
id: string;
|
|
54
|
+
/** The field's name: its row in the menu and the start of its chip. */
|
|
55
|
+
label: string;
|
|
56
|
+
/** An icon before the name in the menu row. Mark it `aria-hidden`. */
|
|
57
|
+
icon?: ReactNode;
|
|
58
|
+
/** The current value. `null` reads as not set. */
|
|
59
|
+
value: Key | null;
|
|
60
|
+
/** The value that means "not filtered" (the "All" option's id). */
|
|
61
|
+
emptyValue: Key;
|
|
62
|
+
/** The options, the "All" option included. */
|
|
63
|
+
options: readonly FilterBarOption[];
|
|
64
|
+
/** Told the chosen option's id, or `emptyValue` when the chip is removed. */
|
|
65
|
+
onChange: (value: Key) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A filter that is not a plain dropdown (a date range, a searchable picker):
|
|
69
|
+
* the caller renders the control and says what its chip reads.
|
|
70
|
+
*/
|
|
71
|
+
export interface FilterBarCustomField {
|
|
72
|
+
/** Stable identity, used as the React key. */
|
|
73
|
+
id: string;
|
|
74
|
+
/** The start of its chip, and its row in the menu. The control rendered by `render` names itself. */
|
|
75
|
+
label: string;
|
|
76
|
+
/** An icon before the name in the menu row. Mark it `aria-hidden`. */
|
|
77
|
+
icon?: ReactNode;
|
|
78
|
+
/** The control, rendered in the menu's step for this filter. */
|
|
79
|
+
render: () => ReactNode;
|
|
80
|
+
/** The chip's value text while the filter is set, or `null` while it is not. */
|
|
81
|
+
activeLabel: string | null;
|
|
82
|
+
/** Unsets the filter: the chip's remove button and Clear all call it. */
|
|
83
|
+
onClear: () => void;
|
|
84
|
+
}
|
|
85
|
+
export type FilterBarField = FilterBarSelectField | FilterBarCustomField;
|
|
86
|
+
export interface FilterBarProps {
|
|
87
|
+
/** Always in the pill, at its start: status tabs and the search box. */
|
|
88
|
+
inline?: ReactNode;
|
|
89
|
+
/** Always in the pill, at its end: a count, Export, a view toggle. */
|
|
90
|
+
end?: ReactNode;
|
|
91
|
+
/** The filters in the Add filter menu. With none, no button renders. */
|
|
92
|
+
filters: readonly FilterBarField[];
|
|
93
|
+
/** Resets every filter in one step. Without it, each set filter is handed its `emptyValue`. */
|
|
94
|
+
onClearAll?: () => void;
|
|
95
|
+
/**
|
|
96
|
+
* The button's text, and the menu's name.
|
|
97
|
+
*
|
|
98
|
+
* @default "Add filter"
|
|
99
|
+
*/
|
|
100
|
+
buttonLabel?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The text of Clear all.
|
|
103
|
+
*
|
|
104
|
+
* @default "Clear all"
|
|
105
|
+
*/
|
|
106
|
+
clearAllLabel?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Ignored: the menu has no Done button, because choosing an option closes it.
|
|
109
|
+
*
|
|
110
|
+
* @deprecated Kept so existing callers still compile.
|
|
111
|
+
*/
|
|
112
|
+
doneLabel?: string;
|
|
113
|
+
/**
|
|
114
|
+
* The note shown while no filter is set.
|
|
115
|
+
*
|
|
116
|
+
* @default "No filters applied"
|
|
117
|
+
*/
|
|
118
|
+
emptyLabel?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The accessible name of the list of chips.
|
|
121
|
+
*
|
|
122
|
+
* @default "Filters set"
|
|
123
|
+
*/
|
|
124
|
+
chipsLabel?: string;
|
|
125
|
+
/**
|
|
126
|
+
* The accessible name of a chip's remove button, given the chip's text.
|
|
127
|
+
*
|
|
128
|
+
* @default (text) => `Remove filter ${text}`
|
|
129
|
+
*/
|
|
130
|
+
removeLabel?: (chipText: string) => string;
|
|
131
|
+
/**
|
|
132
|
+
* The accessible name of the menu's back button.
|
|
133
|
+
*
|
|
134
|
+
* @default "Back to filters"
|
|
135
|
+
*/
|
|
136
|
+
backLabel?: string;
|
|
137
|
+
/** Extra classes on the root. Merged last, so they win conflicts with ours. */
|
|
138
|
+
className?: string;
|
|
139
|
+
}
|
|
140
|
+
export declare const FilterBar: import("react").ForwardRefExoticComponent<FilterBarProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
141
|
+
//#endregion
|
|
142
|
+
//# sourceMappingURL=filter-bar.d.ts.map
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn, cnAll } from "../lib/cn.js";
|
|
3
|
+
import { prefersReducedMotion, useExitBackstop, useIsomorphicLayoutEffect, useMorphWidth } from "../lib/motion.js";
|
|
4
|
+
import { Button as Button$1 } from "../button/button.js";
|
|
5
|
+
import { SwapText } from "../lib/swap-text.js";
|
|
6
|
+
import { useHeightFollow } from "../lib/height-follow.js";
|
|
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";
|
|
10
|
+
import { useLeavingList } from "../lib/leaving-list.js";
|
|
11
|
+
import { cva } from "class-variance-authority";
|
|
12
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
13
|
+
import { Menu } from "react-aria-components";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
//#region src/filter-bar/filter-bar.tsx
|
|
16
|
+
/**
|
|
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.
|
|
20
|
+
*
|
|
21
|
+
* Why it exists: list screens grew a row of four to seven dropdowns beside
|
|
22
|
+
* the search box and the status tabs. At desktop width that row wraps onto a
|
|
23
|
+
* second line; on a phone it scrolls sideways. The bar keeps the row to one
|
|
24
|
+
* line and makes what IS filtered visible as chips instead of as the
|
|
25
|
+
* resting text of a dropdown.
|
|
26
|
+
*
|
|
27
|
+
* Three regions, all inside the one pill:
|
|
28
|
+
*
|
|
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
|
+
*
|
|
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.
|
|
39
|
+
*
|
|
40
|
+
* The bar holds NO filter state. Every value and every change belongs to the
|
|
41
|
+
* caller: removing a chip hands the filter's `emptyValue` back to its
|
|
42
|
+
* `onChange`; Clear all does that for each set filter, or calls
|
|
43
|
+
* `onClearAll` when the caller resets its filters in one step.
|
|
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.
|
|
49
|
+
*/
|
|
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"]);
|
|
58
|
+
const filterBarChipVariants = cva([
|
|
59
|
+
"inline-flex items-center gap-1 rounded-full",
|
|
60
|
+
"border-(length:--border-width) border-border bg-muted",
|
|
61
|
+
"ps-3 pe-1 text-xs leading-(--leading-snug) text-foreground",
|
|
62
|
+
"box-border font-sans"
|
|
63
|
+
]);
|
|
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
|
+
}
|
|
72
|
+
/** The set filters, each with its chip text and how to unset it. */
|
|
73
|
+
function chipsFor(filters) {
|
|
74
|
+
const chips = [];
|
|
75
|
+
for (const f of filters) {
|
|
76
|
+
const value = valueOf(f);
|
|
77
|
+
if (value == null) continue;
|
|
78
|
+
chips.push({
|
|
79
|
+
id: f.id,
|
|
80
|
+
text: `${f.label}: ${value}`,
|
|
81
|
+
clear: isCustom(f) ? f.onClear : () => f.onChange(f.emptyValue)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return chips;
|
|
85
|
+
}
|
|
86
|
+
function Glyph({ path }) {
|
|
87
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
88
|
+
viewBox: "0 0 16 16",
|
|
89
|
+
fill: "none",
|
|
90
|
+
stroke: "currentColor",
|
|
91
|
+
strokeWidth: "1.5",
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
94
|
+
d: path,
|
|
95
|
+
strokeLinecap: "round",
|
|
96
|
+
strokeLinejoin: "round"
|
|
97
|
+
})
|
|
98
|
+
});
|
|
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" });
|
|
105
|
+
/**
|
|
106
|
+
* A list toolbar with its filters behind one Add filter button.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* <FilterBar
|
|
110
|
+
* end={<Button>Export</Button>}
|
|
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
|
+
* />
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* One place in the chip row, for a chip or for Clear all. A slot added after the
|
|
117
|
+
* first render opens from nothing while its content fades up and scales in, so the
|
|
118
|
+
* chips beside it glide over; one that is removed stays, shrinking and collapsing,
|
|
119
|
+
* until its exit ends. Nothing animates at first render.
|
|
120
|
+
*/
|
|
121
|
+
function Slot({ leaving, ready, onDone, id, children }) {
|
|
122
|
+
const [fresh] = useState(ready);
|
|
123
|
+
const remove = useCallback(() => onDone(id), [onDone, id]);
|
|
124
|
+
useExitBackstop(leaving, remove, 900);
|
|
125
|
+
useIsomorphicLayoutEffect(() => {
|
|
126
|
+
if (leaving && prefersReducedMotion()) remove();
|
|
127
|
+
}, [leaving, remove]);
|
|
128
|
+
return /* @__PURE__ */ jsx("li", {
|
|
129
|
+
"data-slot": leaving ? "filter-bar-leaving" : void 0,
|
|
130
|
+
"aria-hidden": leaving || void 0,
|
|
131
|
+
ref: (node) => {
|
|
132
|
+
if (!node) return;
|
|
133
|
+
if (leaving) node.setAttribute("inert", "");
|
|
134
|
+
else node.removeAttribute("inert");
|
|
135
|
+
},
|
|
136
|
+
onAnimationEnd: (event) => {
|
|
137
|
+
if (leaving && event.target === event.currentTarget && event.animationName === "chip-slot-out") remove();
|
|
138
|
+
},
|
|
139
|
+
className: cnAll("min-w-0 flex-none [interpolate-size:allow-keywords]", leaving ? "pointer-events-none motion-safe:animate-chip-out" : fresh && "motion-safe:animate-chip-in motion-reduce:animate-fade-in"),
|
|
140
|
+
children
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** A chip's text: a changed value swaps (the new text rises in) and the chip's width springs to it. */
|
|
144
|
+
function ChipText({ text }) {
|
|
145
|
+
const content = useRef(null);
|
|
146
|
+
useMorphWidth(content, text);
|
|
147
|
+
return /* @__PURE__ */ jsx("span", {
|
|
148
|
+
className: "button-slot",
|
|
149
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
150
|
+
ref: content,
|
|
151
|
+
className: "inline-flex flex-none items-center",
|
|
152
|
+
children: /* @__PURE__ */ jsx(SwapText, {
|
|
153
|
+
swapKey: text,
|
|
154
|
+
className: "inline-block",
|
|
155
|
+
children: text
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
}
|
|
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) {
|
|
308
|
+
const [open, setOpen] = useState(false);
|
|
309
|
+
const chips = chipsFor(filters);
|
|
310
|
+
const [ready, setReady] = useState(false);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
const frame = requestAnimationFrame(() => setReady(true));
|
|
313
|
+
return () => cancelAnimationFrame(frame);
|
|
314
|
+
}, []);
|
|
315
|
+
const places = useLeavingList([...chips.map((chip) => ({
|
|
316
|
+
id: chip.id,
|
|
317
|
+
chip
|
|
318
|
+
})), ...chips.length > 0 ? [{
|
|
319
|
+
id: "\0clear",
|
|
320
|
+
chip: null
|
|
321
|
+
}] : []]);
|
|
322
|
+
const frame = useRef(null);
|
|
323
|
+
const row = useRef(null);
|
|
324
|
+
useHeightFollow(frame, row, chips.map((chip) => chip.id).join());
|
|
325
|
+
const clearAll = () => {
|
|
326
|
+
if (onClearAll) onClearAll();
|
|
327
|
+
else for (const c of chips) c.clear();
|
|
328
|
+
};
|
|
329
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
330
|
+
ref,
|
|
331
|
+
"data-slot": "filter-bar",
|
|
332
|
+
className: cn(filterBarVariants(), className),
|
|
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, {
|
|
389
|
+
isOpen: open,
|
|
390
|
+
onOpenChange: setOpen,
|
|
391
|
+
children: [/* @__PURE__ */ jsx(Button$1, {
|
|
392
|
+
variant: "outlineNeutral",
|
|
393
|
+
size: "sm",
|
|
394
|
+
startIcon: /* @__PURE__ */ jsx(PlusGlyph, {}),
|
|
395
|
+
"data-slot": "filter-bar-button",
|
|
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)
|
|
406
|
+
})
|
|
407
|
+
})]
|
|
408
|
+
}) : null, end]
|
|
409
|
+
}) : null
|
|
410
|
+
]
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
//#endregion
|
|
414
|
+
export { FilterBar, filterBarChipVariants, filterBarRowVariants, filterBarVariants };
|
|
415
|
+
|
|
416
|
+
//# sourceMappingURL=filter-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;CAC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AACG,WAAD;MACE,WAAU;MACV,QAAQ;MACR,WAAU;MAEV,UAAA,oBAAC,aAAD;OACW;OACT,OAAO;OACI;OACX,eAAe,QAAQ,KAAK;MAC7B,CAAA;KACM,CAAA,CACK;IACd,CAAA,IAAA,MACH,GACE;GACH,CAAA,IAAA;EACD;;AAET,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { FilterBar, FilterBarCustomField, FilterBarField, FilterBarOption, FilterBarProps, FilterBarSelectField, filterBarChipVariants, filterBarRowVariants, filterBarVariants } from "./filter-bar.js";
|
|
2
|
+
export { FilterBar, type FilterBarCustomField, type FilterBarField, type FilterBarOption, type FilterBarProps, type FilterBarSelectField, filterBarChipVariants, filterBarRowVariants, filterBarVariants };
|