@brightlocal/ui-components 3.2.0 → 3.3.0
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/AI_USAGE.md +10 -0
- package/README.md +3 -1
- package/component-meta.json +1271 -428
- package/deprecations.json +44 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +73 -102
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +6 -4
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +85 -133
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +4 -4
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +106 -168
- package/dist/aspect-ratio.cjs +1 -1
- package/dist/aspect-ratio.js +13 -16
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +30 -45
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +23 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +90 -91
- package/dist/banner.cjs +1 -1
- package/dist/banner.js +102 -148
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +20 -3
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +73 -140
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +136 -176
- package/dist/blocks/progress-state.cjs +1 -1
- package/dist/blocks/progress-state.js +223 -347
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +11 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +763 -1092
- package/dist/brand-illustration-motif.cjs +1 -1
- package/dist/brand-illustration-motif.js +40 -61
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +62 -102
- package/dist/button-group.cjs +1 -1
- package/dist/button-group.js +23 -31
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +4 -2
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +149 -189
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +87 -3
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +116 -173
- package/dist/callout.cjs +1 -1
- package/dist/callout.js +73 -96
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +10 -4
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +233 -316
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +3 -3
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +174 -268
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.js +27 -48
- package/dist/chart-empty.cjs +1 -1
- package/dist/chart-empty.js +18 -27
- package/dist/chart.cjs +7 -7
- package/dist/chart.d.ts +23 -13
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +445 -651
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +36 -69
- package/dist/chip.cjs +1 -1
- package/dist/chip.js +116 -173
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/collapsible.js +35 -41
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +14 -4
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +439 -638
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +273 -420
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts +5 -5
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +121 -191
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +280 -129
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +687 -948
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +15 -4
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +156 -231
- package/dist/delta.cjs +1 -0
- package/dist/delta.d.ts +79 -0
- package/dist/delta.d.ts.map +1 -0
- package/dist/delta.js +62 -0
- package/dist/description.cjs +1 -1
- package/dist/description.js +11 -20
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +76 -116
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +11 -11
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +76 -134
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +6 -6
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +179 -300
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +9 -9
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +166 -286
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.js +203 -342
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +16 -29
- package/dist/header.cjs +1 -1
- package/dist/header.js +21 -38
- package/dist/height-transition.cjs +1 -1
- package/dist/height-transition.js +38 -55
- package/dist/hooks/use-breakpoint.cjs +1 -1
- package/dist/hooks/use-breakpoint.js +9 -9
- package/dist/hooks/use-debounce.cjs +1 -1
- package/dist/hooks/use-debounce.js +12 -11
- package/dist/hooks/use-delayed-pending.cjs +1 -1
- package/dist/hooks/use-delayed-pending.js +8 -9
- package/dist/hooks/use-filter-search-params.cjs +1 -0
- package/dist/hooks/use-filter-search-params.d.ts +93 -0
- package/dist/hooks/use-filter-search-params.d.ts.map +1 -0
- package/dist/hooks/use-filter-search-params.js +122 -0
- package/dist/hooks/use-mobile.cjs +1 -1
- package/dist/hooks/use-mobile.js +6 -6
- package/dist/hooks/use-overlay-pointer-lock.cjs +1 -1
- package/dist/hooks/use-overlay-pointer-lock.js +8 -9
- package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
- package/dist/hooks/use-prefers-reduced-motion.js +5 -8
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +1 -1
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +30 -62
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +630 -608
- package/dist/info-tooltip.cjs +1 -1
- package/dist/info-tooltip.js +22 -36
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +32 -3
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +181 -230
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +174 -221
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +3 -3
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +102 -146
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +12 -16
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +139 -171
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +51 -73
- package/dist/label.cjs +1 -1
- package/dist/label.js +20 -38
- package/dist/lib/block-illustration.cjs +1 -1
- package/dist/lib/block-illustration.d.ts +1 -1
- package/dist/lib/block-illustration.d.ts.map +1 -1
- package/dist/lib/block-illustration.js +16 -18
- package/dist/lib/compose-event-handlers.cjs +1 -0
- package/dist/lib/compose-event-handlers.d.ts +9 -0
- package/dist/lib/compose-event-handlers.d.ts.map +1 -0
- package/dist/lib/compose-event-handlers.js +8 -0
- package/dist/lib/download-file.cjs +1 -0
- package/dist/lib/download-file.d.ts +14 -0
- package/dist/lib/download-file.d.ts.map +1 -0
- package/dist/lib/download-file.js +40 -0
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.js +28 -56
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +14 -3
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +15 -11
- package/dist/lib/field-aria.cjs +1 -0
- package/dist/lib/field-aria.d.ts +34 -0
- package/dist/lib/field-aria.d.ts.map +1 -0
- package/dist/lib/field-aria.js +52 -0
- package/dist/lib/image-file-info.cjs +1 -0
- package/dist/lib/image-file-info.d.ts +25 -0
- package/dist/lib/image-file-info.d.ts.map +1 -0
- package/dist/lib/image-file-info.js +67 -0
- package/dist/lib/media-viewer-content.cjs +1 -0
- package/dist/lib/media-viewer-content.d.ts +102 -0
- package/dist/lib/media-viewer-content.d.ts.map +1 -0
- package/dist/lib/media-viewer-content.js +650 -0
- package/dist/lib/media-viewer-internal.cjs +1 -0
- package/dist/lib/media-viewer-internal.d.ts +98 -0
- package/dist/lib/media-viewer-internal.d.ts.map +1 -0
- package/dist/lib/media-viewer-internal.js +61 -0
- package/dist/lib/media-viewer-motion.cjs +1 -0
- package/dist/lib/media-viewer-motion.d.ts +40 -0
- package/dist/lib/media-viewer-motion.d.ts.map +1 -0
- package/dist/lib/media-viewer-motion.js +37 -0
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.d.ts +8 -0
- package/dist/lib/motion.d.ts.map +1 -1
- package/dist/lib/motion.js +11 -10
- package/dist/lib/optical-center.cjs +1 -1
- package/dist/lib/optical-center.d.ts +1 -1
- package/dist/lib/optical-center.d.ts.map +1 -1
- package/dist/lib/optical-center.js +12 -5
- package/dist/lib/spring-settle.cjs +1 -1
- package/dist/lib/spring-settle.js +1 -1
- package/dist/lib/table-internal.cjs +1 -0
- package/dist/lib/table-internal.d.ts +62 -0
- package/dist/lib/table-internal.d.ts.map +1 -0
- package/dist/lib/table-internal.js +18 -0
- package/dist/lib/use-controllable.cjs +1 -0
- package/dist/lib/use-controllable.d.ts +12 -0
- package/dist/lib/use-controllable.d.ts.map +1 -0
- package/dist/lib/use-controllable.js +15 -0
- package/dist/lib/use-dev-warning.cjs +1 -1
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.js +26 -33
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.js +78 -124
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +8 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +94 -156
- package/dist/loading.cjs +1 -1
- package/dist/loading.js +124 -151
- package/dist/logo-mark.cjs +1 -0
- package/dist/logo-mark.d.ts +79 -0
- package/dist/logo-mark.d.ts.map +1 -0
- package/dist/logo-mark.js +219 -0
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +1 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +51 -87
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +390 -586
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.js +27 -42
- package/dist/media-viewer.cjs +1 -0
- package/dist/media-viewer.d.ts +224 -0
- package/dist/media-viewer.d.ts.map +1 -0
- package/dist/media-viewer.js +295 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +14 -14
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +130 -267
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts +9 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +357 -446
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +108 -172
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +36 -12
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +208 -281
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +34 -45
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +17 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +116 -162
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +90 -146
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +80 -13
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +70 -65
- package/dist/relative-date.cjs +1 -1
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/relative-date.js +73 -89
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +39 -23
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +42 -44
- package/dist/result-count.cjs +1 -0
- package/dist/result-count.d.ts +110 -0
- package/dist/result-count.d.ts.map +1 -0
- package/dist/result-count.js +49 -0
- package/dist/route-progress.cjs +1 -1
- package/dist/route-progress.js +58 -102
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +9 -1
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +44 -79
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +10 -10
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +118 -238
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +90 -78
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +8 -5
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +250 -317
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts +32 -0
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +201 -203
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.js +24 -38
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +51 -81
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +101 -125
- package/dist/spinner.cjs +1 -1
- package/dist/spinner.js +22 -31
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.js +52 -101
- package/dist/status.cjs +1 -0
- package/dist/status.d.ts +51 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +60 -0
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +184 -316
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +17 -32
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +103 -30
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +170 -209
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +102 -147
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.js +307 -363
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +22 -35
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.js +43 -62
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +34 -46
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts +2 -2
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +157 -249
- package/dist/typography-heading.cjs +1 -1
- package/dist/typography-heading.js +25 -61
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.js +27 -57
- package/dist/typography.cjs +1 -1
- package/dist/typography.js +132 -340
- package/package.json +46 -46
- package/src/blocks/empty-state.tsx +34 -18
- package/src/blocks/sidebar.tsx +86 -31
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert-dialog.tsx +4 -2
- package/src/components/badge.tsx +127 -15
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +8 -6
- package/src/components/calendar.tsx +155 -9
- package/src/components/card.tsx +63 -10
- package/src/components/carousel.tsx +4 -1
- package/src/components/chart.tsx +151 -17
- package/src/components/checkbox.tsx +1 -1
- package/src/components/collapsible.tsx +4 -1
- package/src/components/combobox.tsx +40 -7
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +4 -4
- package/src/components/data-table.tsx +619 -237
- package/src/components/date-picker.tsx +31 -4
- package/src/components/delta.tsx +217 -0
- package/src/components/drawer.tsx +5 -5
- package/src/components/dropdown-menu.tsx +4 -4
- package/src/components/field.tsx +36 -15
- package/src/components/global-layout.tsx +1 -1
- package/src/components/input-chip.tsx +51 -7
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-password.tsx +15 -19
- package/src/components/input.tsx +10 -1
- package/src/components/list.tsx +14 -2
- package/src/components/logo-mark.tsx +345 -0
- package/src/components/map.tsx +18 -20
- package/src/components/media-viewer.tsx +908 -0
- package/src/components/multi-select-filter.tsx +255 -121
- package/src/components/navigation-menu.tsx +2 -2
- package/src/components/pagination.tsx +86 -26
- package/src/components/progress.tsx +91 -23
- package/src/components/rating.tsx +200 -74
- package/src/components/relative-date.tsx +19 -11
- package/src/components/resizable.tsx +86 -33
- package/src/components/result-count.tsx +253 -0
- package/src/components/scroll-area.tsx +31 -5
- package/src/components/select.tsx +2 -2
- package/src/components/sheet.tsx +14 -4
- package/src/components/single-select-filter.tsx +136 -41
- package/src/components/slider.tsx +2 -2
- package/src/components/status.tsx +162 -0
- package/src/components/switch.tsx +1 -1
- package/src/components/table.tsx +278 -106
- package/src/components/tabs.tsx +1 -0
- package/src/components/textarea.tsx +20 -2
- package/src/components/toggle.tsx +2 -2
- package/src/components/tooltip.tsx +11 -20
- package/src/hooks/use-filter-search-params.ts +302 -0
- package/src/index.ts +6 -0
- package/src/lib/compose-event-handlers.ts +14 -0
- package/src/lib/download-file.ts +61 -0
- package/src/lib/empty-chip.tsx +52 -0
- package/src/lib/field-aria.tsx +97 -0
- package/src/lib/image-file-info.ts +102 -0
- package/src/lib/media-viewer-content.tsx +1587 -0
- package/src/lib/media-viewer-internal.tsx +191 -0
- package/src/lib/media-viewer-motion.ts +120 -0
- package/src/lib/motion.ts +9 -0
- package/src/lib/table-internal.ts +74 -0
- package/src/lib/use-controllable.ts +43 -0
- package/src/lib/empty-chip.ts +0 -24
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { Spinner } from "@brightlocal/ui-components/spinner";
|
|
6
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
|
|
8
|
+
/* ResultCount — the one count text the DS renders for a collection
|
|
9
|
+
(Patterns/Filtering → Where controls live, part 4). It is the screen's
|
|
10
|
+
ONE live region: role="status", announced once per change — the rows
|
|
11
|
+
themselves announce nothing. During a refetch it pairs the count with a
|
|
12
|
+
spinner so a change is never dimming alone; the text swap is what
|
|
13
|
+
announces "Updating results", then the new count — once each.
|
|
14
|
+
|
|
15
|
+
Two forms, one component: the plain form ("4 of 24 locations")
|
|
16
|
+
says what the filters left; the range form ("1 to 20 of 45
|
|
17
|
+
locations") adds where the page sits in that set. DataTablePagination and
|
|
18
|
+
PaginationControls render the range form, so a paged collection shows the
|
|
19
|
+
count once — in the toolbar or in the pagination row, never both. */
|
|
20
|
+
|
|
21
|
+
interface ResultCountBaseProps extends Omit<
|
|
22
|
+
React.ComponentPropsWithoutRef<"p">,
|
|
23
|
+
"children"
|
|
24
|
+
> {
|
|
25
|
+
/**
|
|
26
|
+
* Data hook for automated testing (REQUIRED)
|
|
27
|
+
* @example "locations-result-count"
|
|
28
|
+
*/
|
|
29
|
+
dataHook: string;
|
|
30
|
+
/**
|
|
31
|
+
* Refetch in flight — the live region announces the updating message
|
|
32
|
+
* alone, while the previous count stays on screen (aria-hidden) beside
|
|
33
|
+
* the spinner. Dimming the rows is the consumer's job; this indicator is
|
|
34
|
+
* what makes dimming never the only signal.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
updating?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Text shown beside the spinner during a refetch — and, on its own, the
|
|
40
|
+
* whole of what the live region announces while it is in flight.
|
|
41
|
+
* @default "Updating results"
|
|
42
|
+
*/
|
|
43
|
+
updatingLabel?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Screen-reader-only text while the collection is empty. The visible
|
|
46
|
+
* count hides at zero — the empty state already says it — but the live
|
|
47
|
+
* region still announces the result.
|
|
48
|
+
* @default "No results"
|
|
49
|
+
*/
|
|
50
|
+
emptyLabel?: string;
|
|
51
|
+
/** Analytics element identifier. @default "result-count" */
|
|
52
|
+
trackingEl?: string;
|
|
53
|
+
/** Analytics label */
|
|
54
|
+
trackingLabel?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Plain form: how many records the filters left, out of an optional total. */
|
|
58
|
+
interface ResultCountPlainProps extends ResultCountBaseProps {
|
|
59
|
+
/** How many records the collection currently shows. */
|
|
60
|
+
count: number;
|
|
61
|
+
/** The unfiltered total. Omit when it isn't cheap to know. */
|
|
62
|
+
total?: number;
|
|
63
|
+
from?: never;
|
|
64
|
+
to?: never;
|
|
65
|
+
/**
|
|
66
|
+
* Count text while `total` is present. Supports the `{count}` and
|
|
67
|
+
* `{total}` placeholders — name the records in the product's words
|
|
68
|
+
* ("{count} of {total} locations"). i18next's `{{count}}` form is
|
|
69
|
+
* accepted too, so the untranslated `t()` string can be passed straight in.
|
|
70
|
+
* @default "{count} of {total} results"
|
|
71
|
+
*/
|
|
72
|
+
label?: string;
|
|
73
|
+
/**
|
|
74
|
+
* `label` for a total of exactly 1 — the noun follows the total ("1 of 1
|
|
75
|
+
* location"). Falls back to `label`, so a template without a singular keeps
|
|
76
|
+
* its own noun. Pair with i18next's `_one` key: `labelOne={t("count_one")}`.
|
|
77
|
+
* @default "{count} of {total} result"
|
|
78
|
+
*/
|
|
79
|
+
labelOne?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Count text while `total` is omitted. Supports the `{count}`
|
|
82
|
+
* placeholder.
|
|
83
|
+
* @default "{count} results"
|
|
84
|
+
*/
|
|
85
|
+
noTotalLabel?: string;
|
|
86
|
+
/**
|
|
87
|
+
* `noTotalLabel` for a count of exactly 1 ("1 location"). Falls back to
|
|
88
|
+
* `noTotalLabel`.
|
|
89
|
+
* @default "{count} result"
|
|
90
|
+
*/
|
|
91
|
+
noTotalLabelOne?: string;
|
|
92
|
+
rangeLabel?: never;
|
|
93
|
+
rangeLabelOne?: never;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Range form: which slice of the (filtered) set the current page shows. */
|
|
97
|
+
interface ResultCountRangeProps extends ResultCountBaseProps {
|
|
98
|
+
/** First record on this page (1-based). */
|
|
99
|
+
from: number;
|
|
100
|
+
/** Last record on this page. */
|
|
101
|
+
to: number;
|
|
102
|
+
/** Size of the set being paged — the filtered count, not the unfiltered one. */
|
|
103
|
+
total: number;
|
|
104
|
+
count?: never;
|
|
105
|
+
/**
|
|
106
|
+
* Range text. Supports the `{from}`, `{to}` and `{total}` placeholders —
|
|
107
|
+
* name the records in the product's words
|
|
108
|
+
* ("{from} to {to} of {total} locations"). i18next's `{{from}}` form
|
|
109
|
+
* is accepted too, so the untranslated `t()` string can be passed straight in.
|
|
110
|
+
* @default "{from} to {to} of {total} results"
|
|
111
|
+
*/
|
|
112
|
+
rangeLabel?: string;
|
|
113
|
+
/**
|
|
114
|
+
* `rangeLabel` for a total of exactly 1 — the noun follows the total ("1 to
|
|
115
|
+
* 1 of 1 location"). Falls back to `rangeLabel`. Pair with i18next's `_one`
|
|
116
|
+
* key: `rangeLabelOne={t("range_one")}`.
|
|
117
|
+
* @default "{from} to {to} of {total} result"
|
|
118
|
+
*/
|
|
119
|
+
rangeLabelOne?: string;
|
|
120
|
+
label?: never;
|
|
121
|
+
labelOne?: never;
|
|
122
|
+
noTotalLabel?: never;
|
|
123
|
+
noTotalLabelOne?: never;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
type ResultCountProps = ResultCountPlainProps | ResultCountRangeProps;
|
|
127
|
+
|
|
128
|
+
/* `{count}` is the DS placeholder; `{{count}}` is accepted too, so an i18next
|
|
129
|
+
string can be handed over as-is (`label={t("locations.count")}`) and the
|
|
130
|
+
count fills it in, instead of a render-prop per table. Every occurrence is
|
|
131
|
+
replaced. */
|
|
132
|
+
function format(template: string, values: Record<string, number>): string {
|
|
133
|
+
return Object.entries(values).reduce(
|
|
134
|
+
(text, [key, value]) =>
|
|
135
|
+
text
|
|
136
|
+
.replaceAll(`{{${key}}}`, String(value))
|
|
137
|
+
.replaceAll(`{${key}}`, String(value)),
|
|
138
|
+
template
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The collection's count as a `role="status"` live region — one per
|
|
144
|
+
* screen. Announces the new count once per change, "Updating results" once
|
|
145
|
+
* per refetch, and the empty label (screen-reader only) at zero.
|
|
146
|
+
*/
|
|
147
|
+
const ResultCount = React.forwardRef<HTMLParagraphElement, ResultCountProps>(
|
|
148
|
+
(
|
|
149
|
+
{
|
|
150
|
+
className,
|
|
151
|
+
dataHook,
|
|
152
|
+
count,
|
|
153
|
+
from,
|
|
154
|
+
to,
|
|
155
|
+
total,
|
|
156
|
+
updating = false,
|
|
157
|
+
label,
|
|
158
|
+
labelOne,
|
|
159
|
+
noTotalLabel,
|
|
160
|
+
noTotalLabelOne,
|
|
161
|
+
rangeLabel,
|
|
162
|
+
rangeLabelOne,
|
|
163
|
+
updatingLabel,
|
|
164
|
+
emptyLabel,
|
|
165
|
+
trackingEl,
|
|
166
|
+
trackingLabel,
|
|
167
|
+
...props
|
|
168
|
+
},
|
|
169
|
+
ref
|
|
170
|
+
) => {
|
|
171
|
+
const isRange = typeof from === "number" && typeof to === "number";
|
|
172
|
+
const isEmpty = isRange ? total === 0 : count === 0;
|
|
173
|
+
|
|
174
|
+
/* The noun follows the last number in the sentence — the total when
|
|
175
|
+
there is one, the count otherwise — so that is the number that picks
|
|
176
|
+
the singular template. A template given without its singular keeps its
|
|
177
|
+
own noun rather than falling back to the English default. */
|
|
178
|
+
let text: string;
|
|
179
|
+
if (isRange) {
|
|
180
|
+
const template =
|
|
181
|
+
total === 1
|
|
182
|
+
? (rangeLabelOne ?? rangeLabel ?? "{from} to {to} of {total} result")
|
|
183
|
+
: (rangeLabel ?? "{from} to {to} of {total} results");
|
|
184
|
+
text = format(template, { from, to, total: total ?? 0 });
|
|
185
|
+
} else if (total !== undefined) {
|
|
186
|
+
const template =
|
|
187
|
+
total === 1
|
|
188
|
+
? (labelOne ?? label ?? "{count} of {total} result")
|
|
189
|
+
: (label ?? "{count} of {total} results");
|
|
190
|
+
text = format(template, { count: count ?? 0, total });
|
|
191
|
+
} else {
|
|
192
|
+
const template =
|
|
193
|
+
count === 1
|
|
194
|
+
? (noTotalLabelOne ?? noTotalLabel ?? "{count} result")
|
|
195
|
+
: (noTotalLabel ?? "{count} results");
|
|
196
|
+
text = format(template, { count: count ?? 0 });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<p
|
|
201
|
+
ref={ref}
|
|
202
|
+
className={cn(
|
|
203
|
+
"text-muted-foreground text-body-sm relative flex items-center gap-2",
|
|
204
|
+
className
|
|
205
|
+
)}
|
|
206
|
+
data-hook={dataHook}
|
|
207
|
+
data-slot="result-count"
|
|
208
|
+
data-tracking-el={trackingEl ?? "result-count"}
|
|
209
|
+
data-tracking-label={trackingLabel}
|
|
210
|
+
role="status"
|
|
211
|
+
{...props}
|
|
212
|
+
>
|
|
213
|
+
{/* The accessibility contract is "Updating results, then the new
|
|
214
|
+
count — once each", so while a refetch is in flight the live
|
|
215
|
+
region's ENTIRE accessible text is the updating message. The
|
|
216
|
+
previous count stays visible for continuity but is aria-hidden:
|
|
217
|
+
leaving it in the announced text made a screen reader re-read the
|
|
218
|
+
stale count with a suffix ("40 of 128 results Updating…")
|
|
219
|
+
instead of the documented message. */}
|
|
220
|
+
{updating ? (
|
|
221
|
+
<>
|
|
222
|
+
{!isEmpty && (
|
|
223
|
+
<span aria-hidden="true" data-slot="result-count-text">
|
|
224
|
+
{text}
|
|
225
|
+
</span>
|
|
226
|
+
)}
|
|
227
|
+
<span
|
|
228
|
+
className="inline-flex items-center gap-1.5"
|
|
229
|
+
data-slot="result-count-updating"
|
|
230
|
+
>
|
|
231
|
+
{/* No loadingLabel: the spinner stays decorative
|
|
232
|
+
(aria-hidden) — the region's text change is the one
|
|
233
|
+
announcement. */}
|
|
234
|
+
<Spinner size="sm" />
|
|
235
|
+
{updatingLabel ?? "Updating results"}
|
|
236
|
+
</span>
|
|
237
|
+
</>
|
|
238
|
+
) : isEmpty ? (
|
|
239
|
+
<span className="sr-only" data-slot="result-count-empty">
|
|
240
|
+
{emptyLabel ?? "No results"}
|
|
241
|
+
</span>
|
|
242
|
+
) : (
|
|
243
|
+
<span data-slot="result-count-text">{text}</span>
|
|
244
|
+
)}
|
|
245
|
+
</p>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
ResultCount.displayName = "ResultCount";
|
|
251
|
+
|
|
252
|
+
export { ResultCount };
|
|
253
|
+
export type { ResultCountProps, ResultCountPlainProps, ResultCountRangeProps };
|
|
@@ -27,11 +27,19 @@ interface ScrollAreaProps extends React.ComponentProps<
|
|
|
27
27
|
* @default "vertical"
|
|
28
28
|
*/
|
|
29
29
|
scrollOrientation?: "vertical" | "both";
|
|
30
|
+
/**
|
|
31
|
+
* Reserves room for the vertical scrollbar beside the content once it
|
|
32
|
+
* overflows, so the scrollbar never draws over it.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
reserveScrollbarSpace?: boolean;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
39
|
* ScrollArea provides a styled scrollable viewport with custom scrollbars.
|
|
34
|
-
* Built on Radix UI ScrollArea primitive.
|
|
40
|
+
* Built on Radix UI ScrollArea primitive. Give it a fixed height (`h-72`) to
|
|
41
|
+
* fill a box, or a max height (`max-h-64`) to grow with its content and
|
|
42
|
+
* scroll once it reaches that height.
|
|
35
43
|
*/
|
|
36
44
|
const ScrollArea = React.forwardRef<
|
|
37
45
|
React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
|
|
@@ -45,6 +53,7 @@ const ScrollArea = React.forwardRef<
|
|
|
45
53
|
trackingEl,
|
|
46
54
|
trackingLabel,
|
|
47
55
|
scrollOrientation = "vertical",
|
|
56
|
+
reserveScrollbarSpace = false,
|
|
48
57
|
...props
|
|
49
58
|
},
|
|
50
59
|
ref
|
|
@@ -52,7 +61,14 @@ const ScrollArea = React.forwardRef<
|
|
|
52
61
|
return (
|
|
53
62
|
<ScrollAreaPrimitive.Root
|
|
54
63
|
ref={ref}
|
|
55
|
-
className={cn(
|
|
64
|
+
className={cn(
|
|
65
|
+
"relative",
|
|
66
|
+
// Pads the viewport only while the vertical scrollbar is mounted,
|
|
67
|
+
// which Radix does only when the content overflows
|
|
68
|
+
reserveScrollbarSpace &&
|
|
69
|
+
"[&:has(>[data-slot=scroll-area-scrollbar][data-orientation=vertical])>[data-slot=scroll-area-viewport]]:pr-3",
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
56
72
|
data-hook={dataHook}
|
|
57
73
|
data-slot="scroll-area"
|
|
58
74
|
data-tracking-el={trackingEl}
|
|
@@ -60,13 +76,23 @@ const ScrollArea = React.forwardRef<
|
|
|
60
76
|
{...props}
|
|
61
77
|
>
|
|
62
78
|
<ScrollAreaPrimitive.Viewport
|
|
63
|
-
|
|
79
|
+
// max-h-[inherit] lets a max height on the root bound the viewport,
|
|
80
|
+
// which a percentage height can't do without a fixed root height.
|
|
81
|
+
// Radix wraps the children in an inline `display: table; min-width:
|
|
82
|
+
// 100%` div, which sizes to the content's min-content and so widens
|
|
83
|
+
// past the container for anything with an intrinsic width (a chart
|
|
84
|
+
// frame, a long URL). Forcing it to a full-width block lets that
|
|
85
|
+
// content shrink to the container; content that is genuinely wider
|
|
86
|
+
// (a fixed-width table) still overflows and scrolls sideways.
|
|
87
|
+
className="focus-visible:shadow-default duration-fast size-full max-h-[inherit] rounded-[inherit] p-1 transition-[color,box-shadow] ease-out outline-none [&>div]:block! [&>div]:w-full [&>div]:min-w-0!"
|
|
64
88
|
data-slot="scroll-area-viewport"
|
|
65
89
|
tabIndex={0}
|
|
66
90
|
>
|
|
67
91
|
{children}
|
|
68
92
|
</ScrollAreaPrimitive.Viewport>
|
|
69
|
-
|
|
93
|
+
{/* forceMount keeps the scrollbar mounted while the pointer is away,
|
|
94
|
+
so the reserved space doesn't come and go on hover */}
|
|
95
|
+
<ScrollAreaScrollbar forceMount={reserveScrollbarSpace || undefined} />
|
|
70
96
|
{scrollOrientation === "both" && (
|
|
71
97
|
<ScrollAreaScrollbar orientation="horizontal" />
|
|
72
98
|
)}
|
|
@@ -125,7 +151,7 @@ const ScrollAreaScrollbar = React.forwardRef<
|
|
|
125
151
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
126
152
|
ref={ref}
|
|
127
153
|
className={cn(
|
|
128
|
-
"duration-fast flex touch-none p-px transition-
|
|
154
|
+
"duration-fast flex touch-none p-px transition-[color,opacity] ease-out select-none data-[state=hidden]:opacity-0",
|
|
129
155
|
orientation === "vertical" &&
|
|
130
156
|
"h-full w-2.5 border-l border-l-transparent",
|
|
131
157
|
orientation === "horizontal" &&
|
|
@@ -202,7 +202,7 @@ const selectTriggerVariants = cva([
|
|
|
202
202
|
"data-[state=open]:border-ring",
|
|
203
203
|
|
|
204
204
|
// Disabled state
|
|
205
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
205
|
+
"cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
|
|
206
206
|
|
|
207
207
|
// Icon styles (chevron and custom icons)
|
|
208
208
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
@@ -450,7 +450,7 @@ interface SelectItemProps extends React.ComponentProps<
|
|
|
450
450
|
function SelectItem({ className, children, hint, ...props }: SelectItemProps) {
|
|
451
451
|
const itemStyles = cn(
|
|
452
452
|
// Base layout
|
|
453
|
-
"relative flex w-full cursor-
|
|
453
|
+
"relative flex w-full cursor-pointer select-none items-center gap-2",
|
|
454
454
|
"rounded py-1.5 pl-2 pr-8",
|
|
455
455
|
|
|
456
456
|
// Typography
|
package/src/components/sheet.tsx
CHANGED
|
@@ -24,8 +24,10 @@ export type SheetSide = "top" | "right" | "bottom" | "left";
|
|
|
24
24
|
* - default: Panel fills 75% of the viewport up to 384px
|
|
25
25
|
* - sm: Panel hugs its content between 288 and 320px, keeping the page
|
|
26
26
|
* partly visible behind it on phones (used by the Sidebar mobile nav)
|
|
27
|
+
* - lg: Panel fills 75% of the viewport up to 512px — detail panels with
|
|
28
|
+
* dense content (date pickers, thumbnail rows)
|
|
27
29
|
*/
|
|
28
|
-
export type SheetSize = "default" | "sm";
|
|
30
|
+
export type SheetSize = "default" | "sm" | "lg";
|
|
29
31
|
|
|
30
32
|
const sheetContentVariants = cva(
|
|
31
33
|
[
|
|
@@ -87,6 +89,7 @@ const sheetContentVariants = cva(
|
|
|
87
89
|
size: {
|
|
88
90
|
default: [],
|
|
89
91
|
sm: [],
|
|
92
|
+
lg: [],
|
|
90
93
|
},
|
|
91
94
|
},
|
|
92
95
|
compoundVariants: [
|
|
@@ -109,6 +112,13 @@ const sheetContentVariants = cva(
|
|
|
109
112
|
"max-w-(--ds-container-xs)",
|
|
110
113
|
],
|
|
111
114
|
},
|
|
115
|
+
// lg side panels are the wider detail-panel width (DS-1206): same 75%
|
|
116
|
+
// phone fill as default, capped at 512px on larger viewports.
|
|
117
|
+
{
|
|
118
|
+
side: ["left", "right"],
|
|
119
|
+
size: "lg",
|
|
120
|
+
className: ["w-3/4", "sm:max-w-lg"],
|
|
121
|
+
},
|
|
112
122
|
],
|
|
113
123
|
defaultVariants: {
|
|
114
124
|
side: "right",
|
|
@@ -212,7 +222,8 @@ interface SheetContentProps
|
|
|
212
222
|
side?: SheetSide;
|
|
213
223
|
/**
|
|
214
224
|
* Width preset for side panels. `sm` hugs the content between 288 and
|
|
215
|
-
* 320px; `default` keeps the classic 75%-up-to-384px drawer width
|
|
225
|
+
* 320px; `default` keeps the classic 75%-up-to-384px drawer width; `lg`
|
|
226
|
+
* widens to 75%-up-to-512px for dense detail panels.
|
|
216
227
|
* Ignored for top/bottom sheets.
|
|
217
228
|
* @default "default"
|
|
218
229
|
*/
|
|
@@ -355,8 +366,7 @@ interface SheetPaginationProps extends Omit<
|
|
|
355
366
|
* @default Renders "{current} of {total}", or nothing when either is unset.
|
|
356
367
|
*/
|
|
357
368
|
renderPosition?:
|
|
358
|
-
|
|
359
|
-
| null;
|
|
369
|
+
((info: SheetPaginationPositionInfo) => React.ReactNode) | null;
|
|
360
370
|
/**
|
|
361
371
|
* Accessible label for the item navigation group.
|
|
362
372
|
* @default "Item navigation"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import type { VariantProps } from "class-variance-authority";
|
|
5
5
|
|
|
6
|
-
import { ChevronDown } from "@brightlocal/icons";
|
|
6
|
+
import { ChevronDown, SearchX } from "@brightlocal/icons";
|
|
7
7
|
import { Button } from "@brightlocal/ui-components/button";
|
|
8
8
|
import {
|
|
9
9
|
Drawer,
|
|
@@ -17,7 +17,13 @@ import {
|
|
|
17
17
|
DrawerTrigger,
|
|
18
18
|
} from "@brightlocal/ui-components/drawer";
|
|
19
19
|
import { useIsBelowBreakpoint } from "@brightlocal/ui-components/hooks/use-breakpoint";
|
|
20
|
+
import {
|
|
21
|
+
InputGroup,
|
|
22
|
+
InputGroupClear,
|
|
23
|
+
InputGroupInput,
|
|
24
|
+
} from "@brightlocal/ui-components/input-group";
|
|
20
25
|
import { Label } from "@brightlocal/ui-components/label";
|
|
26
|
+
import { EmptyChip } from "../lib/empty-chip";
|
|
21
27
|
import {
|
|
22
28
|
RadioGroup,
|
|
23
29
|
RadioGroupItem,
|
|
@@ -33,7 +39,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
33
39
|
import { multiSelectFilterTriggerVariants } from "@brightlocal/ui-components/multi-select-filter";
|
|
34
40
|
|
|
35
41
|
/* SingleSelectFilter — the Filtering pattern's single-value dimension
|
|
36
|
-
(Patterns/
|
|
42
|
+
(Patterns/Filtering → Which filter → 5 or more, one at a time):
|
|
37
43
|
one value from one dimension, e.g. time period, interval, source type.
|
|
38
44
|
|
|
39
45
|
Desktop. A DS Select reads its chosen label and opens a native listbox —
|
|
@@ -128,6 +134,38 @@ interface SingleSelectFilterProps<Value extends string = string>
|
|
|
128
134
|
* @default "Pick one option."
|
|
129
135
|
*/
|
|
130
136
|
drawerDescription?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Show a search field in the drawer when the list is long.
|
|
139
|
+
* `true` forces it on, `false` forces it off; leave `undefined` to show it
|
|
140
|
+
* automatically when `options.length > searchThreshold`.
|
|
141
|
+
*/
|
|
142
|
+
searchable?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Number of options above which the drawer shows a search field
|
|
145
|
+
* automatically (unless `searchable` overrides it).
|
|
146
|
+
* @default 10
|
|
147
|
+
*/
|
|
148
|
+
searchThreshold?: number;
|
|
149
|
+
/**
|
|
150
|
+
* Placeholder and aria-label for the drawer search field.
|
|
151
|
+
* @default "Search options..."
|
|
152
|
+
*/
|
|
153
|
+
searchPlaceholder?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Accessible label for the search clear button.
|
|
156
|
+
* @default "Clear search"
|
|
157
|
+
*/
|
|
158
|
+
clearSearchAriaLabel?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Heading of the empty state shown when the search matches nothing.
|
|
161
|
+
* @default "No options found."
|
|
162
|
+
*/
|
|
163
|
+
emptyLabel?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Description below the empty state heading.
|
|
166
|
+
* @default "Try another search."
|
|
167
|
+
*/
|
|
168
|
+
emptyDescription?: string;
|
|
131
169
|
/** Analytics element identifier. @default "single-select-filter" */
|
|
132
170
|
trackingEl?: string;
|
|
133
171
|
/** Analytics label */
|
|
@@ -238,6 +276,12 @@ function SingleSelectFilterInner<Value extends string = string>({
|
|
|
238
276
|
clearLabel,
|
|
239
277
|
doneLabel,
|
|
240
278
|
drawerDescription,
|
|
279
|
+
searchable,
|
|
280
|
+
searchThreshold = 10,
|
|
281
|
+
searchPlaceholder,
|
|
282
|
+
clearSearchAriaLabel,
|
|
283
|
+
emptyLabel,
|
|
284
|
+
emptyDescription,
|
|
241
285
|
trackingEl,
|
|
242
286
|
trackingLabel,
|
|
243
287
|
"aria-label": ariaLabelProp,
|
|
@@ -254,6 +298,23 @@ function SingleSelectFilterInner<Value extends string = string>({
|
|
|
254
298
|
value: controlledValue,
|
|
255
299
|
});
|
|
256
300
|
|
|
301
|
+
const [query, setQuery] = React.useState("");
|
|
302
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
303
|
+
const showSearch = searchable ?? options.length > searchThreshold;
|
|
304
|
+
const searching = showSearch && normalizedQuery.length > 0;
|
|
305
|
+
const visibleOptions = searching
|
|
306
|
+
? options.filter(
|
|
307
|
+
(option) =>
|
|
308
|
+
option.label.toLowerCase().includes(normalizedQuery) ||
|
|
309
|
+
option.value.toLowerCase().includes(normalizedQuery)
|
|
310
|
+
)
|
|
311
|
+
: options;
|
|
312
|
+
|
|
313
|
+
const handleOpenChange = (next: boolean) => {
|
|
314
|
+
if (next) setQuery("");
|
|
315
|
+
state.onOpenChange(next);
|
|
316
|
+
};
|
|
317
|
+
|
|
257
318
|
const belowMd = useIsBelowBreakpoint("md");
|
|
258
319
|
const useDrawer =
|
|
259
320
|
presentation === "drawer" || (presentation === "auto" && belowMd);
|
|
@@ -296,7 +357,7 @@ function SingleSelectFilterInner<Value extends string = string>({
|
|
|
296
357
|
);
|
|
297
358
|
|
|
298
359
|
return (
|
|
299
|
-
<Drawer open={state.open} onOpenChange={
|
|
360
|
+
<Drawer open={state.open} onOpenChange={handleOpenChange}>
|
|
300
361
|
<DrawerTrigger asChild>{triggerNode}</DrawerTrigger>
|
|
301
362
|
<DrawerContent dataHook={`${dataHook}-drawer`}>
|
|
302
363
|
<DrawerHeader>
|
|
@@ -305,44 +366,78 @@ function SingleSelectFilterInner<Value extends string = string>({
|
|
|
305
366
|
{drawerDescription ?? "Pick one option."}
|
|
306
367
|
</DrawerDescription>
|
|
307
368
|
</DrawerHeader>
|
|
308
|
-
|
|
309
|
-
<
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
369
|
+
{showSearch ? (
|
|
370
|
+
<DrawerBody className="shrink-0 pb-4">
|
|
371
|
+
<InputGroup dataHook={`${dataHook}-search`}>
|
|
372
|
+
<InputGroupInput
|
|
373
|
+
aria-label={searchPlaceholder ?? "Search options..."}
|
|
374
|
+
placeholder={searchPlaceholder ?? "Search options..."}
|
|
375
|
+
value={query}
|
|
376
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
377
|
+
/>
|
|
378
|
+
<InputGroupClear
|
|
379
|
+
clearSearchAriaLabel={clearSearchAriaLabel}
|
|
380
|
+
dataHook={`${dataHook}-search-clear`}
|
|
381
|
+
/>
|
|
382
|
+
</InputGroup>
|
|
383
|
+
</DrawerBody>
|
|
384
|
+
) : null}
|
|
385
|
+
<DrawerBody className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pt-1 pb-2">
|
|
386
|
+
{searching && visibleOptions.length === 0 ? (
|
|
387
|
+
<div
|
|
388
|
+
className="text-body-sm flex flex-col items-center gap-1 py-6 text-center"
|
|
389
|
+
data-hook={`${dataHook}-empty`}
|
|
390
|
+
>
|
|
391
|
+
<EmptyChip
|
|
392
|
+
className="mb-1"
|
|
393
|
+
dataHook={`${dataHook}-empty-icon`}
|
|
394
|
+
icon={<SearchX />}
|
|
395
|
+
slot="single-select-filter-empty-icon"
|
|
396
|
+
/>
|
|
397
|
+
<p>{emptyLabel ?? "No options found."}</p>
|
|
398
|
+
<p className="text-muted-foreground">
|
|
399
|
+
{emptyDescription ?? "Try another search."}
|
|
400
|
+
</p>
|
|
401
|
+
</div>
|
|
402
|
+
) : (
|
|
403
|
+
<RadioGroup
|
|
404
|
+
className="grid grid-cols-2 gap-x-4 gap-y-3"
|
|
405
|
+
dataHook={`${dataHook}-radio-group`}
|
|
406
|
+
value={state.value}
|
|
407
|
+
onValueChange={(next) => {
|
|
408
|
+
state.setValue(next as Value);
|
|
409
|
+
}}
|
|
410
|
+
>
|
|
411
|
+
{visibleOptions.map((option, index) => {
|
|
412
|
+
const optionDisabled = option.disabled || option.count === 0;
|
|
413
|
+
const optionId = `${idPrefix}-${index}`;
|
|
414
|
+
return (
|
|
415
|
+
<div key={option.value} className="flex items-center gap-2">
|
|
416
|
+
<RadioGroupItem
|
|
417
|
+
data-hook={`${dataHook}-option-${option.value}`}
|
|
418
|
+
disabled={optionDisabled}
|
|
419
|
+
id={optionId}
|
|
420
|
+
value={option.value}
|
|
421
|
+
/>
|
|
422
|
+
<Label className="flex-1 gap-2" htmlFor={optionId}>
|
|
423
|
+
{option.icon ? (
|
|
424
|
+
<Glyph
|
|
425
|
+
dataHook={`${dataHook}-option-${option.value}-icon`}
|
|
426
|
+
>
|
|
427
|
+
{option.icon}
|
|
428
|
+
</Glyph>
|
|
429
|
+
) : null}
|
|
430
|
+
{option.label}
|
|
431
|
+
</Label>
|
|
432
|
+
{option.count !== undefined ? (
|
|
433
|
+
<OptionCount count={option.count} />
|
|
335
434
|
) : null}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
);
|
|
343
|
-
})}
|
|
344
|
-
</RadioGroup>
|
|
345
|
-
{hasValue && state.value !== defaultValue ? (
|
|
435
|
+
</div>
|
|
436
|
+
);
|
|
437
|
+
})}
|
|
438
|
+
</RadioGroup>
|
|
439
|
+
)}
|
|
440
|
+
{hasValue && state.value !== defaultValue && !searching ? (
|
|
346
441
|
<Button
|
|
347
442
|
dataHook={`${dataHook}-clear`}
|
|
348
443
|
variant="ghost"
|
|
@@ -376,7 +471,7 @@ function SingleSelectFilterInner<Value extends string = string>({
|
|
|
376
471
|
disabled={disabled}
|
|
377
472
|
open={state.open}
|
|
378
473
|
value={state.value}
|
|
379
|
-
onOpenChange={
|
|
474
|
+
onOpenChange={handleOpenChange}
|
|
380
475
|
onValueChange={(next) => state.setValue(next as Value)}
|
|
381
476
|
>
|
|
382
477
|
<SelectTrigger
|
|
@@ -138,7 +138,7 @@ const Slider = React.forwardRef<
|
|
|
138
138
|
<SliderPrimitive.Root
|
|
139
139
|
ref={ref}
|
|
140
140
|
className={cn(
|
|
141
|
-
"relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
141
|
+
"relative flex w-full cursor-pointer touch-none items-center select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
142
142
|
className
|
|
143
143
|
)}
|
|
144
144
|
data-hook={dataHook}
|
|
@@ -169,7 +169,7 @@ const Slider = React.forwardRef<
|
|
|
169
169
|
<SliderPrimitive.Thumb
|
|
170
170
|
key={index}
|
|
171
171
|
aria-label={getThumbLabel(index)}
|
|
172
|
-
className="border-primary bg-background ring-ring/50 duration-fast block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] ease-out hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
172
|
+
className="border-primary bg-background ring-ring/50 duration-fast block size-4 shrink-0 cursor-grab rounded-full border shadow-sm transition-[color,box-shadow] ease-out hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden active:cursor-grabbing disabled:pointer-events-none disabled:opacity-50"
|
|
173
173
|
data-slot="slider-thumb"
|
|
174
174
|
/>
|
|
175
175
|
))}
|