@brightlocal/ui-components 3.1.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 +8 -1
- package/component-meta.json +1591 -123
- package/deprecations.json +45 -1
- 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 +36 -5
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +83 -128
- 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 +116 -177
- 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 +32 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +90 -71
- package/dist/banner.cjs +1 -0
- package/dist/banner.d.ts +81 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +130 -0
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +24 -6
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +74 -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.d.ts +2 -2
- package/dist/blocks/progress-state.js +223 -347
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +28 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +763 -1086
- package/dist/brand-illustration-motif.cjs +1 -1
- package/dist/brand-illustration-motif.d.ts +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 +92 -6
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +240 -234
- 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 +253 -25
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +465 -511
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +37 -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 +440 -639
- 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 +442 -144
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +708 -835
- 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.d.ts +24 -1
- package/dist/grid.d.ts.map +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.d.ts +1 -1
- package/dist/hooks/use-breakpoint.d.ts.map +1 -1
- package/dist/hooks/use-breakpoint.js +10 -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 +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +636 -582
- package/dist/info-tooltip.cjs +1 -0
- package/dist/info-tooltip.d.ts +39 -0
- package/dist/info-tooltip.d.ts.map +1 -0
- package/dist/info-tooltip.js +27 -0
- 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 +182 -231
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +33 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +188 -122
- 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 +26 -8
- 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 +5 -2
- package/dist/lib/block-illustration.d.ts.map +1 -1
- package/dist/lib/block-illustration.js +16 -17
- 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.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -35
- 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 -0
- package/dist/multi-select-filter.d.ts +186 -0
- package/dist/multi-select-filter.d.ts.map +1 -0
- package/dist/multi-select-filter.js +374 -0
- 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 +139 -17
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +116 -148
- 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 -0
- package/dist/relative-date.d.ts +65 -0
- package/dist/relative-date.d.ts.map +1 -0
- package/dist/relative-date.js +112 -0
- 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 +20 -10
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +132 -236
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +90 -78
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +86 -7
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +275 -235
- package/dist/single-select-filter.cjs +1 -0
- package/dist/single-select-filter.d.ts +113 -0
- package/dist/single-select-filter.d.ts.map +1 -0
- package/dist/single-select-filter.js +224 -0
- 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 +113 -137
- package/dist/spinner.cjs +1 -1
- package/dist/spinner.js +22 -31
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +1 -1
- package/dist/split-layout.js +53 -102
- 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 +127 -13
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +170 -192
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +12 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +123 -146
- 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 +23 -36
- 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 +38 -36
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +175 -78
- 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.d.ts +1 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +27 -57
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +1 -1
- package/dist/typography.js +132 -340
- package/package.json +45 -46
- package/src/blocks/empty-state.tsx +42 -21
- package/src/blocks/progress-state.tsx +2 -2
- package/src/blocks/sidebar.tsx +111 -32
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert-dialog.tsx +52 -5
- package/src/components/alert.tsx +16 -8
- package/src/components/badge.tsx +152 -3
- package/src/components/banner.tsx +288 -0
- package/src/components/brand-illustration-motif.tsx +1 -1
- 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 +266 -26
- package/src/components/carousel.tsx +4 -1
- package/src/components/chart.tsx +664 -42
- package/src/components/checkbox.tsx +2 -2
- package/src/components/collapsible.tsx +4 -1
- package/src/components/combobox.tsx +42 -9
- package/src/components/command.tsx +10 -11
- package/src/components/context-menu.tsx +4 -4
- package/src/components/data-table.tsx +1363 -398
- 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/grid.tsx +32 -1
- package/src/components/info-tooltip.tsx +94 -0
- package/src/components/input-chip.tsx +52 -8
- package/src/components/input-group.tsx +247 -12
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +29 -11
- package/src/components/input.tsx +11 -2
- package/src/components/list.tsx +15 -3
- 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 +1046 -0
- package/src/components/navigation-menu.tsx +2 -2
- package/src/components/pagination.tsx +86 -26
- package/src/components/progress.tsx +281 -54
- package/src/components/rating.tsx +200 -74
- package/src/components/relative-date.tsx +238 -0
- 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 +37 -7
- package/src/components/sheet.tsx +252 -6
- package/src/components/single-select-filter.tsx +538 -0
- package/src/components/slider.tsx +2 -2
- package/src/components/sonner.tsx +16 -5
- package/src/components/split-layout.tsx +2 -2
- package/src/components/status.tsx +162 -0
- package/src/components/switch.tsx +1 -1
- package/src/components/table.tsx +305 -73
- package/src/components/tabs.tsx +94 -46
- package/src/components/textarea.tsx +21 -3
- package/src/components/toggle.tsx +2 -2
- package/src/components/tooltip.tsx +431 -68
- package/src/components/typography-text.tsx +1 -2
- package/src/components/typography.tsx +1 -1
- package/src/hooks/use-breakpoint.ts +2 -1
- package/src/hooks/use-filter-search-params.ts +302 -0
- package/src/index.ts +11 -0
- package/src/lib/block-illustration.tsx +5 -1
- 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/utils.ts +1 -0
- package/src/lib/empty-chip.ts +0 -24
|
@@ -247,6 +247,16 @@ const DatePickerRoot = DatePicker;
|
|
|
247
247
|
*/
|
|
248
248
|
export type DatePickerRootProps = DatePickerProps;
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Appends the text rendered inside a control to its aria-label so the
|
|
252
|
+
* accessible name contains the visible text (WCAG 2.5.3 Label in Name).
|
|
253
|
+
*/
|
|
254
|
+
function withVisibleText(label: string, visibleText?: React.ReactNode) {
|
|
255
|
+
return typeof visibleText === "string" && visibleText.length > 0
|
|
256
|
+
? `${label}: ${visibleText}`
|
|
257
|
+
: label;
|
|
258
|
+
}
|
|
259
|
+
|
|
250
260
|
// ============================================================================
|
|
251
261
|
// DatePickerTrigger
|
|
252
262
|
// ============================================================================
|
|
@@ -265,7 +275,18 @@ export interface DatePickerTriggerProps extends Omit<
|
|
|
265
275
|
*/
|
|
266
276
|
error?: boolean;
|
|
267
277
|
/**
|
|
268
|
-
*
|
|
278
|
+
* Marks this field as the one a calendar shown outside its popover is
|
|
279
|
+
* editing (e.g. a "from" / "to" pair sharing one inline calendar). Shows
|
|
280
|
+
* the same border as the open state without opening a popover, and sets
|
|
281
|
+
* `aria-current="true"` so screen readers know which field the calendar
|
|
282
|
+
* edits.
|
|
283
|
+
* @default false
|
|
284
|
+
*/
|
|
285
|
+
active?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Accessible label for the trigger button. The text shown inside the button
|
|
288
|
+
* (selected value or placeholder) is appended as `"<label>: <text>"` so the
|
|
289
|
+
* accessible name contains the visible text (WCAG 2.5.3).
|
|
269
290
|
* @default "Select date" (single) or "Select date range" (range)
|
|
270
291
|
*/
|
|
271
292
|
triggerLabel?: string;
|
|
@@ -277,7 +298,7 @@ export interface DatePickerTriggerProps extends Omit<
|
|
|
277
298
|
const DatePickerTrigger = React.forwardRef<
|
|
278
299
|
HTMLButtonElement,
|
|
279
300
|
DatePickerTriggerProps
|
|
280
|
-
>(({ className, children, id, error, triggerLabel, ...props }, ref) => {
|
|
301
|
+
>(({ className, children, id, error, active, triggerLabel, ...props }, ref) => {
|
|
281
302
|
const {
|
|
282
303
|
mode,
|
|
283
304
|
date,
|
|
@@ -328,19 +349,25 @@ const DatePickerTrigger = React.forwardRef<
|
|
|
328
349
|
<PopoverTrigger asChild>
|
|
329
350
|
<button
|
|
330
351
|
ref={combinedRef}
|
|
352
|
+
aria-current={active ? "true" : undefined}
|
|
331
353
|
aria-label={
|
|
332
354
|
props["aria-label"] ??
|
|
333
|
-
|
|
334
|
-
|
|
355
|
+
withVisibleText(
|
|
356
|
+
triggerLabel ??
|
|
357
|
+
(mode === "single" ? "Select date" : "Select date range"),
|
|
358
|
+
children === undefined ? (displayValue ?? placeholder) : undefined
|
|
359
|
+
)
|
|
335
360
|
}
|
|
336
361
|
className={cn(
|
|
337
362
|
inputVariants({ hasIcon: true }),
|
|
338
363
|
"group-hover/field:bg-accent dark:group-hover/field:bg-input/50 relative cursor-pointer justify-start pb-0 text-left",
|
|
339
364
|
!hasValue && "text-muted-foreground",
|
|
365
|
+
active && "border-ring shadow-default",
|
|
340
366
|
hasError &&
|
|
341
367
|
"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",
|
|
342
368
|
className
|
|
343
369
|
)}
|
|
370
|
+
data-active={active || undefined}
|
|
344
371
|
data-error={hasError || undefined}
|
|
345
372
|
data-hook={`${dataHook}-trigger`}
|
|
346
373
|
data-slot="date-picker-trigger"
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
import { ArrowDown, ArrowUp, Minus } from "@brightlocal/icons";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Which direction of the change shows green (good news); the other shows red.
|
|
10
|
+
* `"up"` when more is better (views, reviews, a rank phrased as places
|
|
11
|
+
* gained); `"down"` when less is better (cost, response time).
|
|
12
|
+
*/
|
|
13
|
+
type DeltaGreenWhen = "up" | "down";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* How the delta sits on the page: bare text in a line or a cell (`inline`),
|
|
17
|
+
* or on a tinted pill next to a metric (`pill`).
|
|
18
|
+
*/
|
|
19
|
+
type DeltaVariant = "inline" | "pill";
|
|
20
|
+
|
|
21
|
+
/** Direction of the change, from the sign of `value`. */
|
|
22
|
+
type DeltaDirection = "increase" | "decrease" | "none";
|
|
23
|
+
|
|
24
|
+
/** Whether the change is good news, from the direction and `greenWhen`. */
|
|
25
|
+
type DeltaTrend = "better" | "worse" | "none";
|
|
26
|
+
|
|
27
|
+
const deltaVariants = cva(
|
|
28
|
+
"relative inline-flex items-center gap-0.5 tabular-nums",
|
|
29
|
+
{
|
|
30
|
+
variants: {
|
|
31
|
+
variant: {
|
|
32
|
+
inline: "text-label [&>svg]:size-4",
|
|
33
|
+
pill: "text-label-sm rounded-full px-1.5 py-0.5 [&>svg]:size-3",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
variant: "inline",
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/* Trend is derived from `value` + `greenWhen`, never passed in, so it stays
|
|
43
|
+
out of the CVA axes (which the registry reads as props). */
|
|
44
|
+
const TREND_INK: Record<DeltaTrend, string> = {
|
|
45
|
+
better: "text-score-strong-ink",
|
|
46
|
+
worse: "text-score-poor-ink",
|
|
47
|
+
none: "text-muted-foreground",
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const PILL_TINT: Record<DeltaTrend, string> = {
|
|
51
|
+
better: "bg-score-strong/15",
|
|
52
|
+
worse: "bg-score-poor/15",
|
|
53
|
+
none: "bg-muted",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Props for the Delta component.
|
|
58
|
+
*/
|
|
59
|
+
interface DeltaProps extends Omit<
|
|
60
|
+
React.ComponentPropsWithoutRef<"span">,
|
|
61
|
+
"children"
|
|
62
|
+
> {
|
|
63
|
+
/**
|
|
64
|
+
* Required test hook identifier.
|
|
65
|
+
* @example "visibility-delta"
|
|
66
|
+
*/
|
|
67
|
+
dataHook: string;
|
|
68
|
+
/**
|
|
69
|
+
* The signed change, as the product phrases it. Rank up 8 places is
|
|
70
|
+
* `value={8}` — the arrow follows the phrasing, the colour follows
|
|
71
|
+
* `greenWhen`.
|
|
72
|
+
* @example 8
|
|
73
|
+
*/
|
|
74
|
+
value: number;
|
|
75
|
+
/**
|
|
76
|
+
* Which direction shows green: `"up"` when more is better, `"down"` when
|
|
77
|
+
* less is better (cost, response time). The other direction shows red.
|
|
78
|
+
* @default "up"
|
|
79
|
+
*/
|
|
80
|
+
greenWhen?: DeltaGreenWhen;
|
|
81
|
+
/**
|
|
82
|
+
* Inline text, or a tinted pill.
|
|
83
|
+
* @default "inline"
|
|
84
|
+
*/
|
|
85
|
+
variant?: DeltaVariant;
|
|
86
|
+
/**
|
|
87
|
+
* Overrides the displayed amount (e.g. "12%"). Pass the magnitude only —
|
|
88
|
+
* the arrow carries the sign.
|
|
89
|
+
* @default the magnitude in en-US format, up to 2 decimals ("<0.01" for a tiny non-zero change)
|
|
90
|
+
*/
|
|
91
|
+
children?: React.ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Screen-reader phrase before the amount when `value` is positive.
|
|
94
|
+
* @default "Increased by"
|
|
95
|
+
*/
|
|
96
|
+
increasedLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Screen-reader phrase before the amount when `value` is negative.
|
|
99
|
+
* @default "Decreased by"
|
|
100
|
+
*/
|
|
101
|
+
decreasedLabel?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Screen-reader phrase when `value` is zero (read on its own).
|
|
104
|
+
* @default "Unchanged"
|
|
105
|
+
*/
|
|
106
|
+
unchangedLabel?: string;
|
|
107
|
+
/** Analytics element identifier */
|
|
108
|
+
trackingEl?: string;
|
|
109
|
+
/** Analytics label */
|
|
110
|
+
trackingLabel?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The default amount: the magnitude in a fixed en-US format (up to two
|
|
115
|
+
* decimals), so server and browser render the same string whatever the
|
|
116
|
+
* runtime locale. A non-zero change that would round to 0 shows "<0.01",
|
|
117
|
+
* so the arrow never sits next to a 0. Consumers pass a localized amount
|
|
118
|
+
* through `children`.
|
|
119
|
+
*/
|
|
120
|
+
const AMOUNT_FORMAT = new Intl.NumberFormat("en-US", {
|
|
121
|
+
maximumFractionDigits: 2,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
function formatAmount(value: number): string {
|
|
125
|
+
const magnitude = Math.abs(value);
|
|
126
|
+
if (magnitude > 0 && magnitude < 0.005) return "<0.01";
|
|
127
|
+
return AMOUNT_FORMAT.format(magnitude);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const DIRECTION_ICONS = {
|
|
131
|
+
increase: ArrowUp,
|
|
132
|
+
decrease: ArrowDown,
|
|
133
|
+
none: Minus,
|
|
134
|
+
} as const;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Delta — how much a value moved between two points.
|
|
138
|
+
* The arrow follows the sign of the change; the colour comes from whether
|
|
139
|
+
* that direction is good (`greenWhen`). Screen readers hear a phrase
|
|
140
|
+
* ("Increased by 8") instead of the arrow and number.
|
|
141
|
+
*/
|
|
142
|
+
const Delta = React.forwardRef<HTMLSpanElement, DeltaProps>(
|
|
143
|
+
(
|
|
144
|
+
{
|
|
145
|
+
className,
|
|
146
|
+
value,
|
|
147
|
+
greenWhen = "up",
|
|
148
|
+
variant = "inline",
|
|
149
|
+
increasedLabel,
|
|
150
|
+
decreasedLabel,
|
|
151
|
+
unchangedLabel,
|
|
152
|
+
dataHook,
|
|
153
|
+
trackingEl,
|
|
154
|
+
trackingLabel,
|
|
155
|
+
children,
|
|
156
|
+
...props
|
|
157
|
+
},
|
|
158
|
+
ref
|
|
159
|
+
) => {
|
|
160
|
+
const direction: DeltaDirection =
|
|
161
|
+
value > 0 ? "increase" : value < 0 ? "decrease" : "none";
|
|
162
|
+
const trend: DeltaTrend =
|
|
163
|
+
direction === "none"
|
|
164
|
+
? "none"
|
|
165
|
+
: (direction === "increase") === (greenWhen === "up")
|
|
166
|
+
? "better"
|
|
167
|
+
: "worse";
|
|
168
|
+
const amount = children ?? formatAmount(value);
|
|
169
|
+
const Icon = DIRECTION_ICONS[direction];
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<span
|
|
173
|
+
ref={ref}
|
|
174
|
+
className={cn(
|
|
175
|
+
deltaVariants({ variant }),
|
|
176
|
+
TREND_INK[trend],
|
|
177
|
+
variant === "pill" && PILL_TINT[trend],
|
|
178
|
+
className
|
|
179
|
+
)}
|
|
180
|
+
data-direction={direction}
|
|
181
|
+
data-hook={dataHook}
|
|
182
|
+
data-slot="delta"
|
|
183
|
+
data-tracking-el={trackingEl}
|
|
184
|
+
data-tracking-label={trackingLabel}
|
|
185
|
+
data-trend={trend}
|
|
186
|
+
data-variant={variant}
|
|
187
|
+
{...props}
|
|
188
|
+
>
|
|
189
|
+
<Icon aria-hidden />
|
|
190
|
+
<span aria-hidden>{amount}</span>
|
|
191
|
+
<span className="sr-only">
|
|
192
|
+
{direction === "none" ? (
|
|
193
|
+
(unchangedLabel ?? "Unchanged")
|
|
194
|
+
) : (
|
|
195
|
+
<>
|
|
196
|
+
{direction === "increase"
|
|
197
|
+
? (increasedLabel ?? "Increased by")
|
|
198
|
+
: (decreasedLabel ?? "Decreased by")}{" "}
|
|
199
|
+
{amount}
|
|
200
|
+
</>
|
|
201
|
+
)}
|
|
202
|
+
</span>
|
|
203
|
+
</span>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
Delta.displayName = "Delta";
|
|
209
|
+
|
|
210
|
+
export { Delta };
|
|
211
|
+
export type {
|
|
212
|
+
DeltaProps,
|
|
213
|
+
DeltaGreenWhen,
|
|
214
|
+
DeltaVariant,
|
|
215
|
+
DeltaDirection,
|
|
216
|
+
DeltaTrend,
|
|
217
|
+
};
|
|
@@ -111,8 +111,8 @@ function DrawerContent({
|
|
|
111
111
|
<DrawerPrimitive.Content
|
|
112
112
|
className={cn(
|
|
113
113
|
"group/drawer-content bg-background border-border fixed z-50 flex h-auto flex-col",
|
|
114
|
-
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[
|
|
115
|
-
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[
|
|
114
|
+
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80svh] data-[vaul-drawer-direction=top]:rounded-b-[10px] data-[vaul-drawer-direction=top]:border-b",
|
|
115
|
+
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80svh] data-[vaul-drawer-direction=bottom]:rounded-t-[10px] data-[vaul-drawer-direction=bottom]:border-t",
|
|
116
116
|
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
117
117
|
"data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",
|
|
118
118
|
className
|
|
@@ -139,7 +139,7 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
139
139
|
return (
|
|
140
140
|
<div
|
|
141
141
|
className={cn(
|
|
142
|
-
"
|
|
142
|
+
"flex w-full shrink-0 flex-col gap-1.5 p-4 text-center sm:text-left",
|
|
143
143
|
className
|
|
144
144
|
)}
|
|
145
145
|
data-slot="drawer-header"
|
|
@@ -157,7 +157,7 @@ function DrawerBody({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
157
157
|
return (
|
|
158
158
|
<div
|
|
159
159
|
className={cn(
|
|
160
|
-
"
|
|
160
|
+
"min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto px-4",
|
|
161
161
|
"mt-4 group-has-[[data-slot=drawer-header]]/drawer-content:mt-0",
|
|
162
162
|
className
|
|
163
163
|
)}
|
|
@@ -176,7 +176,7 @@ function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
176
176
|
return (
|
|
177
177
|
<div
|
|
178
178
|
className={cn(
|
|
179
|
-
"
|
|
179
|
+
"mt-auto flex w-full shrink-0 flex-col gap-2 p-4",
|
|
180
180
|
className
|
|
181
181
|
)}
|
|
182
182
|
data-slot="drawer-footer"
|
|
@@ -194,7 +194,7 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
194
194
|
ref={ref}
|
|
195
195
|
className={cn(
|
|
196
196
|
[
|
|
197
|
-
"relative flex cursor-
|
|
197
|
+
"relative flex cursor-pointer items-center gap-2 self-stretch select-none",
|
|
198
198
|
"text-label rounded-sm px-2 py-1.5 outline-hidden",
|
|
199
199
|
// Text truncation for child text elements
|
|
200
200
|
"[&>span]:overflow-hidden [&>span]:text-ellipsis [&>span]:whitespace-nowrap",
|
|
@@ -262,7 +262,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
|
|
262
262
|
checked={checked}
|
|
263
263
|
className={cn(
|
|
264
264
|
[
|
|
265
|
-
"relative flex cursor-
|
|
265
|
+
"relative flex cursor-pointer items-center gap-2 select-none",
|
|
266
266
|
"text-label rounded-sm py-1.5 pr-2 pl-8 outline-hidden",
|
|
267
267
|
"focus:bg-accent focus:text-accent-foreground",
|
|
268
268
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -334,7 +334,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
|
|
334
334
|
ref={ref}
|
|
335
335
|
className={cn(
|
|
336
336
|
[
|
|
337
|
-
"relative flex cursor-
|
|
337
|
+
"relative flex cursor-pointer items-center gap-2 select-none",
|
|
338
338
|
"text-label rounded-sm py-1.5 pr-2 pl-8 outline-hidden",
|
|
339
339
|
"focus:bg-accent focus:text-accent-foreground",
|
|
340
340
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -496,7 +496,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
496
496
|
ref={ref}
|
|
497
497
|
className={cn(
|
|
498
498
|
[
|
|
499
|
-
"flex cursor-
|
|
499
|
+
"flex cursor-pointer items-center gap-2 select-none data-[disabled]:cursor-not-allowed",
|
|
500
500
|
"text-label rounded-sm px-2 py-1.5 outline-hidden",
|
|
501
501
|
"focus:bg-accent focus:text-accent-foreground",
|
|
502
502
|
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
package/src/components/field.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { AlertCircle, type LucideProps } from "@brightlocal/icons";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { Description } from "./description";
|
|
9
9
|
import { Label, type LabelProps } from "@brightlocal/ui-components/label";
|
|
10
|
+
import { FieldAriaProvider, useFieldAriaRegistration } from "../lib/field-aria";
|
|
10
11
|
|
|
11
12
|
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
12
13
|
return (
|
|
@@ -188,21 +189,23 @@ function Field({
|
|
|
188
189
|
...props
|
|
189
190
|
}: FieldProps) {
|
|
190
191
|
return (
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
192
|
+
<FieldAriaProvider>
|
|
193
|
+
<div
|
|
194
|
+
className={cn(
|
|
195
|
+
fieldVariants({ orientation, variant }),
|
|
196
|
+
align === "end" &&
|
|
197
|
+
orientation === "horizontal" &&
|
|
198
|
+
"grid-cols-[1fr_auto]",
|
|
199
|
+
className
|
|
200
|
+
)}
|
|
201
|
+
data-hook={dataHook}
|
|
202
|
+
data-orientation={orientation}
|
|
203
|
+
data-slot="field"
|
|
204
|
+
data-variant={variant}
|
|
205
|
+
role="group"
|
|
206
|
+
{...props}
|
|
207
|
+
/>
|
|
208
|
+
</FieldAriaProvider>
|
|
206
209
|
);
|
|
207
210
|
}
|
|
208
211
|
|
|
@@ -277,8 +280,15 @@ interface FieldDescriptionProps extends React.ComponentProps<"p"> {
|
|
|
277
280
|
function FieldDescription({
|
|
278
281
|
className,
|
|
279
282
|
dataHook,
|
|
283
|
+
id: idProp,
|
|
280
284
|
...props
|
|
281
285
|
}: FieldDescriptionProps) {
|
|
286
|
+
// The hint registers its id with the enclosing Field so a text control can
|
|
287
|
+
// point aria-describedby at it without the consumer wiring it by hand.
|
|
288
|
+
const generatedId = React.useId();
|
|
289
|
+
const id = idProp ?? generatedId;
|
|
290
|
+
useFieldAriaRegistration("description", id, true);
|
|
291
|
+
|
|
282
292
|
return (
|
|
283
293
|
<Description
|
|
284
294
|
className={cn(
|
|
@@ -290,6 +300,7 @@ function FieldDescription({
|
|
|
290
300
|
)}
|
|
291
301
|
data-hook={dataHook}
|
|
292
302
|
data-slot="field-description"
|
|
303
|
+
id={id}
|
|
293
304
|
{...props}
|
|
294
305
|
/>
|
|
295
306
|
);
|
|
@@ -427,6 +438,7 @@ function FieldError({
|
|
|
427
438
|
dataHook,
|
|
428
439
|
children,
|
|
429
440
|
errors,
|
|
441
|
+
id: idProp,
|
|
430
442
|
...props
|
|
431
443
|
}: FieldErrorProps) {
|
|
432
444
|
// Filter out undefined errors and those without messages
|
|
@@ -436,6 +448,13 @@ function FieldError({
|
|
|
436
448
|
|
|
437
449
|
const hasMessage = Boolean(children) || Boolean(errorMessages?.length);
|
|
438
450
|
|
|
451
|
+
// While a message is on screen its id is registered with the enclosing
|
|
452
|
+
// Field, so a text control points aria-describedby at it automatically. An
|
|
453
|
+
// explicit `id` is kept, so existing hand-wiring keeps working.
|
|
454
|
+
const generatedId = React.useId();
|
|
455
|
+
const id = idProp ?? generatedId;
|
|
456
|
+
useFieldAriaRegistration("error", id, hasMessage);
|
|
457
|
+
|
|
439
458
|
// Screen readers only announce live-region content that arrives *after* the
|
|
440
459
|
// region is in the accessibility tree. Consumers typically mount FieldError
|
|
441
460
|
// together with the message, so when a message appears client-side the
|
|
@@ -454,6 +473,7 @@ function FieldError({
|
|
|
454
473
|
|
|
455
474
|
React.useEffect(() => {
|
|
456
475
|
if (!hasMessage) {
|
|
476
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- derived live-region latch; refactor tracked in DS-1070
|
|
457
477
|
setDefer(true);
|
|
458
478
|
setAnnounced(false);
|
|
459
479
|
} else if (defer) {
|
|
@@ -486,6 +506,7 @@ function FieldError({
|
|
|
486
506
|
className={baseStyles}
|
|
487
507
|
data-hook={dataHook}
|
|
488
508
|
data-slot="field-error"
|
|
509
|
+
id={id}
|
|
489
510
|
role="status"
|
|
490
511
|
{...props}
|
|
491
512
|
>
|
|
@@ -54,7 +54,7 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
54
54
|
// sidebar from the viewport edge and make its 100dvh height
|
|
55
55
|
// overflow, so the page-level scroll region drops it.
|
|
56
56
|
className={cn(
|
|
57
|
-
"h-dvh w-full [&>[data-radix-scroll-area-viewport]]:p-0!
|
|
57
|
+
"h-dvh w-full [&>[data-radix-scroll-area-viewport]]:p-0!",
|
|
58
58
|
className
|
|
59
59
|
)}
|
|
60
60
|
dataHook={`${dataHook}-scroll`}
|
package/src/components/grid.tsx
CHANGED
|
@@ -31,6 +31,14 @@ import { OpticalCenter } from "../lib/optical-center";
|
|
|
31
31
|
* padding) for pages outside the app shell — auth, invites. Grid owns nothing
|
|
32
32
|
* but the position inside whatever box it is given.
|
|
33
33
|
*
|
|
34
|
+
* The flex chain (DS-1058): `centered` stretches with `flex-1`, and `flex-1`
|
|
35
|
+
* only means something inside a flex column that itself has height. Every box
|
|
36
|
+
* between the page body and the Grid must continue that chain (`flex flex-1
|
|
37
|
+
* flex-col`). A plain `<div>` in between breaks it silently: the Grid shrinks to
|
|
38
|
+
* its content, both spacers collapse to zero, and the message is centred
|
|
39
|
+
* horizontally only — it hugs the top of the body. The fix is the chain, never
|
|
40
|
+
* a top margin on the call site.
|
|
41
|
+
*
|
|
34
42
|
* The single-message blocks are deliberately NOT wired to this internally:
|
|
35
43
|
* `EmptyState size="lg"` is a pure visual block, and the page recipe is the
|
|
36
44
|
* composition `<Grid variant="centered"><EmptyState size="lg" /></Grid>` — so
|
|
@@ -64,6 +72,10 @@ interface GridBaseProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
|
64
72
|
/**
|
|
65
73
|
* One message at the page body's optical centre (38/62). Give it a page body
|
|
66
74
|
* to fill — it stretches with `flex-1` — and one message to hold.
|
|
75
|
+
*
|
|
76
|
+
* Requires an unbroken flex chain: the Grid's parent, and every wrapper up to
|
|
77
|
+
* the page body, must be a `flex flex-1 flex-col` box. Behind a non-flex
|
|
78
|
+
* wrapper it centres horizontally only — fix the wrapper, do not add a margin.
|
|
67
79
|
*/
|
|
68
80
|
interface GridCenteredProps extends GridBaseProps {
|
|
69
81
|
variant: "centered";
|
|
@@ -85,13 +97,32 @@ export type GridProps = GridCenteredProps;
|
|
|
85
97
|
* <Grid dataHook="locations-empty-center" variant="centered">
|
|
86
98
|
* <EmptyState
|
|
87
99
|
* dataHook="locations-empty"
|
|
88
|
-
* illustration={<
|
|
100
|
+
* illustration={<SmallBusiness aria-hidden />}
|
|
89
101
|
* size="lg"
|
|
90
102
|
* title={t("locations.empty.title")}
|
|
91
103
|
* />
|
|
92
104
|
* </Grid>
|
|
93
105
|
* </GlobalLayoutBody>
|
|
94
106
|
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* Wrappers between the page body and the Grid must continue the flex chain:
|
|
110
|
+
* ```tsx
|
|
111
|
+
* // Broken — the plain <div> has no height to give, so the Grid collapses to
|
|
112
|
+
* // its content and the message hugs the top (horizontal centring only).
|
|
113
|
+
* <GlobalLayoutBody dataHook="search-body">
|
|
114
|
+
* <div>
|
|
115
|
+
* <Grid dataHook="search-empty-center" variant="centered">…</Grid>
|
|
116
|
+
* </div>
|
|
117
|
+
* </GlobalLayoutBody>
|
|
118
|
+
*
|
|
119
|
+
* // Fixed — the wrapper passes the height down.
|
|
120
|
+
* <GlobalLayoutBody dataHook="search-body">
|
|
121
|
+
* <div className="flex flex-1 flex-col">
|
|
122
|
+
* <Grid dataHook="search-empty-center" variant="centered">…</Grid>
|
|
123
|
+
* </div>
|
|
124
|
+
* </GlobalLayoutBody>
|
|
125
|
+
* ```
|
|
95
126
|
*/
|
|
96
127
|
const Grid = React.forwardRef<HTMLDivElement, GridProps>(
|
|
97
128
|
(
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Info, type LucideProps } from "@brightlocal/icons";
|
|
5
|
+
import {
|
|
6
|
+
Tooltip,
|
|
7
|
+
TooltipContent,
|
|
8
|
+
TooltipTrigger,
|
|
9
|
+
} from "@brightlocal/ui-components/tooltip";
|
|
10
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props for the InfoTooltip component.
|
|
14
|
+
* Extends native button attributes so consumers can pass `id`, `disabled`, `style`, etc.
|
|
15
|
+
*/
|
|
16
|
+
interface InfoTooltipProps extends Omit<
|
|
17
|
+
React.ComponentPropsWithoutRef<"button">,
|
|
18
|
+
"content" | "children"
|
|
19
|
+
> {
|
|
20
|
+
/**
|
|
21
|
+
* Required test hook identifier.
|
|
22
|
+
* Applied to the trigger; the tooltip content receives `${dataHook}-content`.
|
|
23
|
+
* @example "credits-info"
|
|
24
|
+
*/
|
|
25
|
+
dataHook: string;
|
|
26
|
+
/** Tooltip content — a short explanation shown on hover/tap. */
|
|
27
|
+
content: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Icon component rendered inside the trigger.
|
|
30
|
+
* @default Info
|
|
31
|
+
*/
|
|
32
|
+
icon?: React.ComponentType<LucideProps>;
|
|
33
|
+
/**
|
|
34
|
+
* Icon size in pixels.
|
|
35
|
+
* @default 16
|
|
36
|
+
*/
|
|
37
|
+
iconSize?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Accessible label for the trigger button.
|
|
40
|
+
* @default "More info"
|
|
41
|
+
*/
|
|
42
|
+
ariaLabel?: string;
|
|
43
|
+
/** Analytics element identifier. */
|
|
44
|
+
trackingEl?: string;
|
|
45
|
+
/** Analytics label. */
|
|
46
|
+
trackingLabel?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const InfoTooltip = React.forwardRef<HTMLButtonElement, InfoTooltipProps>(
|
|
50
|
+
(
|
|
51
|
+
{
|
|
52
|
+
dataHook,
|
|
53
|
+
content,
|
|
54
|
+
icon: Icon = Info,
|
|
55
|
+
iconSize = 16,
|
|
56
|
+
ariaLabel,
|
|
57
|
+
trackingEl,
|
|
58
|
+
trackingLabel,
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
},
|
|
62
|
+
ref
|
|
63
|
+
) => {
|
|
64
|
+
// No TooltipProvider here on purpose: the app-level provider's
|
|
65
|
+
// delayDuration must reach this tooltip like any other.
|
|
66
|
+
return (
|
|
67
|
+
<Tooltip>
|
|
68
|
+
<TooltipTrigger
|
|
69
|
+
ref={ref}
|
|
70
|
+
aria-label={ariaLabel ?? "More info"}
|
|
71
|
+
className={cn(
|
|
72
|
+
"text-muted-foreground duration-fast hover:text-foreground focus-visible:text-foreground focus-visible:shadow-default relative inline-flex cursor-help rounded-sm transition-colors ease-out outline-none before:absolute before:-inset-1.5 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
75
|
+
data-slot="info-tooltip"
|
|
76
|
+
dataHook={dataHook}
|
|
77
|
+
trackingEl={trackingEl ?? "info-tooltip"}
|
|
78
|
+
trackingLabel={trackingLabel}
|
|
79
|
+
{...props}
|
|
80
|
+
>
|
|
81
|
+
<Icon aria-hidden size={iconSize} />
|
|
82
|
+
</TooltipTrigger>
|
|
83
|
+
<TooltipContent dataHook={`${dataHook}-content`}>
|
|
84
|
+
{content}
|
|
85
|
+
</TooltipContent>
|
|
86
|
+
</Tooltip>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
InfoTooltip.displayName = "InfoTooltip";
|
|
92
|
+
|
|
93
|
+
export { InfoTooltip };
|
|
94
|
+
export type { InfoTooltipProps };
|