@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,191 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/* Internal to the MediaViewer family: the item type, the root's context and
|
|
4
|
+
the item's More actions menu — shared by the parts in
|
|
5
|
+
components/media-viewer.tsx and the view in lib/media-viewer-content.tsx,
|
|
6
|
+
kept apart so a page without the view does not bundle it. */
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Ellipsis } from "@brightlocal/icons";
|
|
10
|
+
import { Button } from "../components/button";
|
|
11
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../components/tooltip";
|
|
12
|
+
import {
|
|
13
|
+
DropdownMenu,
|
|
14
|
+
DropdownMenuContent,
|
|
15
|
+
DropdownMenuTrigger,
|
|
16
|
+
} from "../components/dropdown-menu";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* One image in the set.
|
|
20
|
+
*/
|
|
21
|
+
export interface MediaViewerItem {
|
|
22
|
+
/**
|
|
23
|
+
* The image URL.
|
|
24
|
+
*/
|
|
25
|
+
src: string;
|
|
26
|
+
/**
|
|
27
|
+
* The image's description — alternative text for screen readers and
|
|
28
|
+
* search engines. It also names the trigger that previews it, and the
|
|
29
|
+
* view shows it under the title while the image is open.
|
|
30
|
+
*/
|
|
31
|
+
alt: string;
|
|
32
|
+
/**
|
|
33
|
+
* A smaller image for the trigger's preview. Falls back to `src`.
|
|
34
|
+
*/
|
|
35
|
+
thumbnailSrc?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The file Download saves — say, the original at full size. Falls back to
|
|
38
|
+
* `src`.
|
|
39
|
+
*/
|
|
40
|
+
downloadSrc?: string;
|
|
41
|
+
/**
|
|
42
|
+
* When the image was taken or added, shown under the title while it is
|
|
43
|
+
* open. An ISO 8601 timestamp or a Date; a plain `YYYY-MM-DD` string for a
|
|
44
|
+
* calendar date with no time of day.
|
|
45
|
+
*/
|
|
46
|
+
date?: string | Date;
|
|
47
|
+
/**
|
|
48
|
+
* Marks a capture that is no longer available. The frame shows the
|
|
49
|
+
* unavailable message instead of requesting the image. An image that fails to
|
|
50
|
+
* load is treated the same way.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
expired?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Inside MediaViewerContent: the built-in controls (Zoom in, Zoom out,
|
|
57
|
+
Download ahead of the consumer's actions; the item's menu after them),
|
|
58
|
+
and the registry that tells the view a MediaViewerActions is rendering
|
|
59
|
+
them. */
|
|
60
|
+
export const MediaViewerControlsContext = React.createContext<{
|
|
61
|
+
lead: React.ReactNode;
|
|
62
|
+
more: React.ReactNode;
|
|
63
|
+
}>({ lead: null, more: null });
|
|
64
|
+
export const MediaViewerActionsRegistry = React.createContext<
|
|
65
|
+
(() => () => void) | null
|
|
66
|
+
>(null);
|
|
67
|
+
|
|
68
|
+
export interface MediaViewerContextValue {
|
|
69
|
+
items: MediaViewerItem[];
|
|
70
|
+
index: number;
|
|
71
|
+
setIndex: (index: number) => void;
|
|
72
|
+
/** The trigger that last opened the view, for focus return. */
|
|
73
|
+
openerRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
74
|
+
open: boolean;
|
|
75
|
+
setOpen: (open: boolean) => void;
|
|
76
|
+
/** Counts openings; per-opening state in the view is keyed by it, as the
|
|
77
|
+
view's component stays mounted while closed. */
|
|
78
|
+
openCount: number;
|
|
79
|
+
/** When the opening press happened (event time), for the zoom's cutoff. */
|
|
80
|
+
openedAtRef: React.MutableRefObject<number>;
|
|
81
|
+
/** Whether the view's image has appeared this opening (its zoom has
|
|
82
|
+
started, or the reader has stepped) — only then does the preview step
|
|
83
|
+
aside, so there is never a frame with neither on screen. */
|
|
84
|
+
revealed: boolean;
|
|
85
|
+
reveal: () => void;
|
|
86
|
+
/** Mounted triggers by item index — where the image zooms from and to. */
|
|
87
|
+
triggersRef: React.MutableRefObject<Map<number, HTMLButtonElement>>;
|
|
88
|
+
/** Where the pointer last was while the view was open — the preview
|
|
89
|
+
under it when the view closes holds off its hover zoom. */
|
|
90
|
+
pointerRef: React.MutableRefObject<{ x: number; y: number } | null>;
|
|
91
|
+
/** The item's menu, as the root's `actions` builds it, or null. */
|
|
92
|
+
renderActions:
|
|
93
|
+
((item: MediaViewerItem, index: number) => React.ReactNode) | null;
|
|
94
|
+
actionsLabel: (item: MediaViewerItem, index: number) => string;
|
|
95
|
+
/** Whether the set has a full view; without one the previews only show. */
|
|
96
|
+
viewable: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const MediaViewerContext =
|
|
100
|
+
React.createContext<MediaViewerContextValue | null>(null);
|
|
101
|
+
|
|
102
|
+
export function useMediaViewerContext(part: string) {
|
|
103
|
+
const context = React.useContext(MediaViewerContext);
|
|
104
|
+
if (!context) {
|
|
105
|
+
throw new Error(`${part} must be used within <MediaViewer>`);
|
|
106
|
+
}
|
|
107
|
+
return context;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const defaultActionsLabel = (item: MediaViewerItem, index: number) =>
|
|
111
|
+
`More actions for ${item.alt || `image ${index + 1}`}`;
|
|
112
|
+
|
|
113
|
+
export const defaultTriggerLabel = (
|
|
114
|
+
item: MediaViewerItem,
|
|
115
|
+
index: number,
|
|
116
|
+
total: number
|
|
117
|
+
) => item.alt || `Image ${index + 1} of ${total}`;
|
|
118
|
+
|
|
119
|
+
/* The item's More actions button and its menu — on a preview and in the
|
|
120
|
+
view's bar. */
|
|
121
|
+
export function ItemActionsMenu({
|
|
122
|
+
dataHook,
|
|
123
|
+
label,
|
|
124
|
+
variant,
|
|
125
|
+
children,
|
|
126
|
+
}: {
|
|
127
|
+
dataHook: string;
|
|
128
|
+
label: string;
|
|
129
|
+
variant: "secondary" | "ghost";
|
|
130
|
+
children: React.ReactNode;
|
|
131
|
+
}) {
|
|
132
|
+
return (
|
|
133
|
+
<DropdownMenu>
|
|
134
|
+
<DropdownMenuTrigger asChild>
|
|
135
|
+
<Button
|
|
136
|
+
iconOnly
|
|
137
|
+
ariaLabel={label}
|
|
138
|
+
dataHook={dataHook}
|
|
139
|
+
size={variant === "secondary" ? "sm" : undefined}
|
|
140
|
+
variant={variant}
|
|
141
|
+
>
|
|
142
|
+
<Ellipsis aria-hidden />
|
|
143
|
+
</Button>
|
|
144
|
+
</DropdownMenuTrigger>
|
|
145
|
+
<DropdownMenuContent align="end" dataHook={`${dataHook}-content`}>
|
|
146
|
+
{children}
|
|
147
|
+
</DropdownMenuContent>
|
|
148
|
+
</DropdownMenu>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Renders `render(ref)` — an element that truncates to one line — inside a
|
|
154
|
+
* tooltip with the full text, which opens only when the text is actually
|
|
155
|
+
* cut at the moment the pointer or focus arrives.
|
|
156
|
+
*/
|
|
157
|
+
export function TruncatedText<T extends HTMLElement>({
|
|
158
|
+
dataHook,
|
|
159
|
+
forwardRef,
|
|
160
|
+
full,
|
|
161
|
+
render,
|
|
162
|
+
}: {
|
|
163
|
+
dataHook: string;
|
|
164
|
+
/** A ref of the caller's to set to the same element. Keep it stable. */
|
|
165
|
+
forwardRef?: (node: T | null) => void;
|
|
166
|
+
full: React.ReactNode;
|
|
167
|
+
render: (ref: (node: T | null) => void) => React.ReactElement;
|
|
168
|
+
}) {
|
|
169
|
+
const [node, setNode] = React.useState<T | null>(null);
|
|
170
|
+
const [open, setOpen] = React.useState(false);
|
|
171
|
+
const measure = React.useCallback(
|
|
172
|
+
(next: T | null) => {
|
|
173
|
+
setNode(next);
|
|
174
|
+
forwardRef?.(next);
|
|
175
|
+
},
|
|
176
|
+
[forwardRef]
|
|
177
|
+
);
|
|
178
|
+
return (
|
|
179
|
+
<Tooltip
|
|
180
|
+
open={open}
|
|
181
|
+
onOpenChange={(next) =>
|
|
182
|
+
setOpen(next && !!node && node.scrollWidth > node.clientWidth)
|
|
183
|
+
}
|
|
184
|
+
>
|
|
185
|
+
<TooltipTrigger asChild>{render(measure)}</TooltipTrigger>
|
|
186
|
+
<TooltipContent dataHook={`${dataHook}-full`} side="top">
|
|
187
|
+
{full}
|
|
188
|
+
</TooltipContent>
|
|
189
|
+
</Tooltip>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { MOTION_EASE_DECELERATE } from "@brightlocal/ui-components/lib/motion";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Motion and gesture values for MediaViewer's lightbox: the zoom between a
|
|
5
|
+
* preview and the view, the glide after a swipe, the rubber band past the
|
|
6
|
+
* ends, and the trackpad swipe thresholds. Private to MediaViewer.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** The image at its resting place, unclipped. */
|
|
10
|
+
export const ZOOM_REST: Keyframe = {
|
|
11
|
+
transform: "none",
|
|
12
|
+
transformOrigin: "0 0",
|
|
13
|
+
clipPath: "inset(0px 0px 0px 0px round 0px)",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/* The keyframe that lays the image over its preview: scaled to cover it,
|
|
17
|
+
cropped the way the preview crops (object-cover, object-top), with the
|
|
18
|
+
preview's corner radius. Measured with no transform applied. A preview
|
|
19
|
+
zoomed in on hover (its image scaled about its centre — mid-transition
|
|
20
|
+
too) is matched as it stands, so the open starts from what the reader
|
|
21
|
+
sees. */
|
|
22
|
+
export function zoomKeyframe(
|
|
23
|
+
preview: HTMLElement,
|
|
24
|
+
image: HTMLImageElement
|
|
25
|
+
): Keyframe | null {
|
|
26
|
+
const p = preview.getBoundingClientRect();
|
|
27
|
+
const i = image.getBoundingClientRect();
|
|
28
|
+
if (!p.width || !p.height || !i.width || !i.height) return null;
|
|
29
|
+
/* A preview scrolled out of sight has nowhere to zoom to: fade instead. */
|
|
30
|
+
if (
|
|
31
|
+
p.bottom <= 0 ||
|
|
32
|
+
p.right <= 0 ||
|
|
33
|
+
p.top >= window.innerHeight ||
|
|
34
|
+
p.left >= window.innerWidth
|
|
35
|
+
)
|
|
36
|
+
return null;
|
|
37
|
+
const cover = Math.max(p.width / i.width, p.height / i.height);
|
|
38
|
+
const thumb = preview.querySelector("img");
|
|
39
|
+
const hover = thumb ? parseFloat(getComputedStyle(thumb).scale) || 1 : 1;
|
|
40
|
+
const scale = cover * hover;
|
|
41
|
+
/* Where the image's top-left corner lands: the cover crop (centred
|
|
42
|
+
across, from the top), then the hover zoom about the preview's centre. */
|
|
43
|
+
const cx = p.left + p.width / 2;
|
|
44
|
+
const cy = p.top + p.height / 2;
|
|
45
|
+
const coverCrop = ((i.width - p.width / cover) / 2) * cover;
|
|
46
|
+
const originX = cx + hover * (p.left - coverCrop - cx);
|
|
47
|
+
const originY = cy + hover * (p.top - cy);
|
|
48
|
+
/* The preview's box, in the image's own pixels. */
|
|
49
|
+
const left = (p.left - originX) / scale;
|
|
50
|
+
const top = (p.top - originY) / scale;
|
|
51
|
+
const right = i.width - left - p.width / scale;
|
|
52
|
+
const bottom = i.height - top - p.height / scale;
|
|
53
|
+
const radius =
|
|
54
|
+
(parseFloat(getComputedStyle(preview).borderTopLeftRadius) || 0) / scale;
|
|
55
|
+
return {
|
|
56
|
+
transform: `translate(${originX - i.left}px, ${originY - i.top}px) scale(${scale})`,
|
|
57
|
+
transformOrigin: "0 0",
|
|
58
|
+
clipPath: `inset(${top}px ${right}px ${bottom}px ${left}px round ${radius}px)`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Share of the stage width a drag must cover to step on release… */
|
|
63
|
+
export const DRAG_STEP_SHARE = 0.2;
|
|
64
|
+
|
|
65
|
+
/** …capped, in px, so a wide screen does not ask for a long pull. */
|
|
66
|
+
export const DRAG_STEP_MAX = 160;
|
|
67
|
+
|
|
68
|
+
/** Release speed, in px/ms, that steps however short the drag. */
|
|
69
|
+
export const DRAG_STEP_SPEED = 0.5;
|
|
70
|
+
|
|
71
|
+
/* After a drag, the track glides the rest of the way at the speed it was
|
|
72
|
+
let go, decelerating — so the motion carries on rather than restarting.
|
|
73
|
+
A slow release still finishes promptly; a fast one never snaps. */
|
|
74
|
+
export const glideTiming = (distance: number, speed: number) => ({
|
|
75
|
+
duration: Math.min(
|
|
76
|
+
320,
|
|
77
|
+
Math.max(120, Math.abs(distance) / Math.max(Math.abs(speed), 0.6))
|
|
78
|
+
),
|
|
79
|
+
easing: MOTION_EASE_DECELERATE,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/* Trackpad swipes follow the approach of yet-another-react-lightbox's
|
|
83
|
+
wheel swipe, a widely used, well-tried one. */
|
|
84
|
+
|
|
85
|
+
/** Rubber band past the first or last image: the most it gives, as a share
|
|
86
|
+
of the stage, and how stiffly (Apple's scroll-view constant). */
|
|
87
|
+
export const RUBBER_BAND_SHARE = 0.1;
|
|
88
|
+
export const RUBBER_BAND_STIFFNESS = 0.55;
|
|
89
|
+
|
|
90
|
+
/** Horizontal travel, in px, before a trackpad swipe starts moving the
|
|
91
|
+
image — a resting hand's drift does nothing. */
|
|
92
|
+
export const WHEEL_INTENT = 30;
|
|
93
|
+
|
|
94
|
+
/** Share of the stage width a trackpad swipe must pull to step. */
|
|
95
|
+
export const WHEEL_STEP_SHARE = 0.2;
|
|
96
|
+
|
|
97
|
+
/** Quiet time, in ms, after which a swipe short of a step springs back —
|
|
98
|
+
long enough that a pause in the fingers is not a let-go. */
|
|
99
|
+
export const WHEEL_CANCEL_DELAY = 600;
|
|
100
|
+
|
|
101
|
+
/** After a step, the inertia that follows is recognised by size: a delta
|
|
102
|
+
no more than this many times the last one is inertia, not new fingers.
|
|
103
|
+
The record fades after WHEEL_INERTIA_TTL ms of quiet. */
|
|
104
|
+
export const WHEEL_INERTIA_RISE = 1.2;
|
|
105
|
+
export const WHEEL_INERTIA_TTL = 300;
|
|
106
|
+
|
|
107
|
+
/** Inertia only fades: once it has, a delta this many times its faintest is
|
|
108
|
+
new fingers — the next swipe, without waiting for the inertia to die. */
|
|
109
|
+
export const WHEEL_FRESH_RISE = 2;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Where a track pulled `offset` px past the first or last image stands: it
|
|
113
|
+
* gives like a rubber band, ever stiffer, approaching but never reaching
|
|
114
|
+
* `limit`.
|
|
115
|
+
*/
|
|
116
|
+
export function rubberBand(offset: number, limit: number): number {
|
|
117
|
+
if (!limit) return 0;
|
|
118
|
+
const give = 1 - 1 / ((Math.abs(offset) * RUBBER_BAND_STIFFNESS) / limit + 1);
|
|
119
|
+
return Math.sign(offset) * give * limit;
|
|
120
|
+
}
|
package/src/lib/motion.ts
CHANGED
|
@@ -28,6 +28,15 @@ export const MOTION_DURATION_FAST_MS = 150;
|
|
|
28
28
|
export const MOTION_DURATION_BASE_MS = 200;
|
|
29
29
|
export const MOTION_DURATION_SLOW_MS = 300;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Easing curves — mirror --ds-motion-ease-decelerate / -emphasized, for
|
|
33
|
+
* JS-driven animation (WAAPI `easing`) that cannot read the CSS tokens.
|
|
34
|
+
* decelerate: motion that carries on from a gesture and settles
|
|
35
|
+
* emphasized: entrances that land with a soft finish
|
|
36
|
+
*/
|
|
37
|
+
export const MOTION_EASE_DECELERATE = "cubic-bezier(0, 0, 0.2, 1)";
|
|
38
|
+
export const MOTION_EASE_EMPHASIZED = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
39
|
+
|
|
31
40
|
/**
|
|
32
41
|
* Quick and controlled, no overshoot — list reorders and other
|
|
33
42
|
* small-element layout moves.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internals shared by `Table` and `DataTable` / `VirtualizedDataTable`.
|
|
5
|
+
* This module is not in the package `exports` map, so nothing here is public
|
|
6
|
+
* API — `components/table.tsx` re-exports only what consumers need
|
|
7
|
+
* (`TableSize`).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Table density. One axis on the root (DS-556): the Table sets the row
|
|
12
|
+
* min-height for every cell and head beneath it, so a table reads as one
|
|
13
|
+
* density and sized content (Input, Button, Checkbox) never fights a per-cell
|
|
14
|
+
* size.
|
|
15
|
+
* - `default` — rows `h-12` (48px), column headers `h-12` (48px). The
|
|
16
|
+
* physical default height is unchanged from before DS-556.
|
|
17
|
+
* - `sm` — rows `h-10` (40px), column headers `h-9` (36px).
|
|
18
|
+
*/
|
|
19
|
+
export type TableSize = "default" | "sm";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Where a table's frame comes from (DS-1103).
|
|
23
|
+
* - `own` — the table draws its own 1px `border-border` frame with `rounded-md`
|
|
24
|
+
* corners; every cell keeps its `p-2`.
|
|
25
|
+
* - `container` — no border, square corners; the first and last cell of every
|
|
26
|
+
* row (head, body, footer, empty and skeleton rows alike) pad to the
|
|
27
|
+
* surrounding container's gutter, `var(--content-inset)`, which `Card`
|
|
28
|
+
* publishes per density (24px for `data`); the `content` spacing token (24px)
|
|
29
|
+
* is the fallback outside any container. Use it inside `CardContent flush`,
|
|
30
|
+
* a Sheet or a dialog body so the page shows one box, not two.
|
|
31
|
+
*/
|
|
32
|
+
export type TableFrame = "own" | "container";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Edge-cell padding for `frame="container"` — applied on the `<table>` so it
|
|
36
|
+
* reaches `TableHead`, `TableCell`, `TableEmpty`, footer and skeleton cells in
|
|
37
|
+
* both scroll-owner modes. The compound selector outranks the cells' own
|
|
38
|
+
* `p-2` / `px-2`.
|
|
39
|
+
*/
|
|
40
|
+
export const TABLE_CONTAINER_INSET =
|
|
41
|
+
"[&_tr>*:first-child]:pl-[var(--content-inset,24px)] [&_tr>*:last-child]:pr-[var(--content-inset,24px)]";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Row min-height per Table `size`, in px — the `h-12` / `h-10` the cells
|
|
45
|
+
* carry in `tableCellVariants`. Keep the two in step: DataTable's virtualizer
|
|
46
|
+
* uses this as its default row estimate.
|
|
47
|
+
*/
|
|
48
|
+
export const TABLE_ROW_MIN_HEIGHT: Record<TableSize, number> = {
|
|
49
|
+
default: 48,
|
|
50
|
+
sm: 40,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Density of the enclosing `Table`; cells and heads read it. */
|
|
54
|
+
export const TableSizeContext = React.createContext<TableSize>("default");
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Focusable scroll-region semantics for a table's scroll container:
|
|
58
|
+
* `role="region"` with an accessible name plus `tabIndex={0}`, so keyboard
|
|
59
|
+
* users can focus the container and scroll it (axe:
|
|
60
|
+
* scrollable-region-focusable).
|
|
61
|
+
*
|
|
62
|
+
* Single source of the contract and its "Scrollable table" default.
|
|
63
|
+
* `Table` applies it to its own wrapper (`scrollOwner="self"` + `minWidth`);
|
|
64
|
+
* `DataTable` / `VirtualizedDataTable` apply it to their outer wrapper,
|
|
65
|
+
* which owns scrolling instead. The caller decides *when* the container is
|
|
66
|
+
* a scroll region; this helper only says *what* that means.
|
|
67
|
+
*/
|
|
68
|
+
export function scrollRegionProps(scrollRegionLabel: string | undefined) {
|
|
69
|
+
return {
|
|
70
|
+
role: "region",
|
|
71
|
+
"aria-label": scrollRegionLabel ?? "Scrollable table",
|
|
72
|
+
tabIndex: 0,
|
|
73
|
+
} as const;
|
|
74
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Controlled/uncontrolled state helper.
|
|
5
|
+
*
|
|
6
|
+
* Resolves a "controlled or internal" value and returns a setter that takes
|
|
7
|
+
* a value or an updater (`SetStateAction<T>`, as TanStack Table expects).
|
|
8
|
+
* When the `controlled` value is defined, the parent owns state and
|
|
9
|
+
* `onChange` is called with the next value. When undefined, state is kept
|
|
10
|
+
* internally and `onChange` is still invoked (the common "notify but
|
|
11
|
+
* self-manage" pattern). Shared by DataTable and MediaViewer.
|
|
12
|
+
*/
|
|
13
|
+
export function useControllable<T>(
|
|
14
|
+
controlled: T | undefined,
|
|
15
|
+
initialValue: T,
|
|
16
|
+
onChange?: (next: T) => void
|
|
17
|
+
): [T, (updater: T | ((prev: T) => T)) => void] {
|
|
18
|
+
const [internal, setInternal] = React.useState<T>(initialValue);
|
|
19
|
+
const value = controlled !== undefined ? controlled : internal;
|
|
20
|
+
|
|
21
|
+
const valueRef = React.useRef(value);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
valueRef.current = value;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const isControlled = controlled !== undefined;
|
|
27
|
+
|
|
28
|
+
const setValue = React.useCallback(
|
|
29
|
+
(updater: T | ((prev: T) => T)) => {
|
|
30
|
+
const next =
|
|
31
|
+
typeof updater === "function"
|
|
32
|
+
? (updater as (prev: T) => T)(valueRef.current)
|
|
33
|
+
: updater;
|
|
34
|
+
if (!isControlled) {
|
|
35
|
+
setInternal(next);
|
|
36
|
+
}
|
|
37
|
+
onChange?.(next);
|
|
38
|
+
},
|
|
39
|
+
[isControlled, onChange]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return [value, setValue];
|
|
43
|
+
}
|
package/src/lib/empty-chip.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { cva } from "class-variance-authority";
|
|
2
|
-
|
|
3
|
-
/* -------------------------------------------------------------------------------------------------
|
|
4
|
-
* Empty chip (internal)
|
|
5
|
-
*
|
|
6
|
-
* The icon chip every "nothing here" moment shares — EmptyState at card
|
|
7
|
-
* scope, and CommandEmpty / ComboboxEmpty at popover scope. 40px of
|
|
8
|
-
* `bg-muted` around a 16px glyph. It lives once so the two cannot drift: the
|
|
9
|
-
* popover form used to be hand-rolled in consumer code with these classes
|
|
10
|
-
* copied in.
|
|
11
|
-
*
|
|
12
|
-
* A canvas drops the chip — but a canvas is a different component, so there
|
|
13
|
-
* is no variant for that here.
|
|
14
|
-
* -----------------------------------------------------------------------------------------------*/
|
|
15
|
-
|
|
16
|
-
export const emptyChipStyles = cva(
|
|
17
|
-
"bg-muted text-muted-foreground flex size-10 items-center justify-center rounded-full",
|
|
18
|
-
{
|
|
19
|
-
variants: {
|
|
20
|
-
align: { center: "", left: "shrink-0" },
|
|
21
|
-
},
|
|
22
|
-
defaultVariants: { align: "center" },
|
|
23
|
-
}
|
|
24
|
-
);
|