@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(n,o){return e=>{n?.(e),e.defaultPrevented||o(e)}}exports.composeEventHandlers=r;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls the consumer's handler first, then ours — unless the consumer called
|
|
3
|
+
* `preventDefault()`. Mirrors Radix's `composeEventHandlers` without adding
|
|
4
|
+
* `@radix-ui/primitive` as a direct dependency.
|
|
5
|
+
*/
|
|
6
|
+
export declare function composeEventHandlers<E extends {
|
|
7
|
+
defaultPrevented: boolean;
|
|
8
|
+
}>(theirs: ((event: E) => void) | undefined, ours: (event: E) => void): (event: E) => void;
|
|
9
|
+
//# sourceMappingURL=compose-event-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-event-handlers.d.ts","sourceRoot":"","sources":["../../src/lib/compose-event-handlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAAE,EAC1E,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,EACxC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,IAEhB,OAAO,CAAC,UAIjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l={"image/jpeg":"jpg","image/png":"png","image/webp":"webp","image/gif":"gif","image/avif":"avif","image/svg+xml":"svg"};function i(t,o=""){const a=l[o.split(";")[0]?.trim()??""];if(t.startsWith("data:")){const n=t.slice(5,t.indexOf(";"));return`image.${l[n]??a??"png"}`}let e="image";try{const n=new URL(t,window.location.href).pathname;e=decodeURIComponent(n.split("/").filter(Boolean).pop()??e)}catch{}return/\.[a-z0-9]{2,5}$/i.test(e)?e:`${e}.${a??"jpg"}`}function m(t,o,a=!1){const e=document.createElement("a");e.href=t,e.download=o,e.rel="noopener",a&&(e.target="_blank"),document.body.appendChild(e),e.click(),e.remove()}async function r(t){try{const o=await fetch(t,{mode:"cors"});if(!o.ok)throw new Error(`HTTP ${o.status}`);const a=await o.blob(),e=URL.createObjectURL(a);m(e,i(t,a.type)),window.setTimeout(()=>URL.revokeObjectURL(e),1e3)}catch{m(t,i(t),!0)}}exports.downloadFile=r;exports.fileNameFor=i;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file name for `src`: its last path segment, with an extension from the
|
|
3
|
+
* file's type when the URL has none (an image CDN path often does not).
|
|
4
|
+
*/
|
|
5
|
+
export declare function fileNameFor(src: string, type?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Saves the file at `src` to the reader's device. The file is fetched and
|
|
8
|
+
* saved from a blob, so a cross-origin image downloads rather than opening
|
|
9
|
+
* (`<a download>` alone is ignored across origins). If the fetch fails — the
|
|
10
|
+
* host sends no CORS headers — it falls back to a plain download link, which
|
|
11
|
+
* still saves same-origin files and opens a cross-origin one in a new tab.
|
|
12
|
+
*/
|
|
13
|
+
export declare function downloadFile(src: string): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=download-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-file.d.ts","sourceRoot":"","sources":["../../src/lib/download-file.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAc1D;AAeD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW7D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var i = {
|
|
2
|
+
"image/jpeg": "jpg",
|
|
3
|
+
"image/png": "png",
|
|
4
|
+
"image/webp": "webp",
|
|
5
|
+
"image/gif": "gif",
|
|
6
|
+
"image/avif": "avif",
|
|
7
|
+
"image/svg+xml": "svg"
|
|
8
|
+
};
|
|
9
|
+
function r(t, o = "") {
|
|
10
|
+
const n = i[o.split(";")[0]?.trim() ?? ""];
|
|
11
|
+
if (t.startsWith("data:")) {
|
|
12
|
+
const a = t.slice(5, t.indexOf(";"));
|
|
13
|
+
return `image.${i[a] ?? n ?? "png"}`;
|
|
14
|
+
}
|
|
15
|
+
let e = "image";
|
|
16
|
+
try {
|
|
17
|
+
const a = new URL(t, window.location.href).pathname;
|
|
18
|
+
e = decodeURIComponent(a.split("/").filter(Boolean).pop() ?? e);
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
return /\.[a-z0-9]{2,5}$/i.test(e) ? e : `${e}.${n ?? "jpg"}`;
|
|
22
|
+
}
|
|
23
|
+
function m(t, o, n = !1) {
|
|
24
|
+
const e = document.createElement("a");
|
|
25
|
+
e.href = t, e.download = o, e.rel = "noopener", n && (e.target = "_blank"), document.body.appendChild(e), e.click(), e.remove();
|
|
26
|
+
}
|
|
27
|
+
async function c(t) {
|
|
28
|
+
try {
|
|
29
|
+
const o = await fetch(t, { mode: "cors" });
|
|
30
|
+
if (!o.ok) throw new Error(`HTTP ${o.status}`);
|
|
31
|
+
const n = await o.blob(), e = URL.createObjectURL(n);
|
|
32
|
+
m(e, r(t, n.type)), window.setTimeout(() => URL.revokeObjectURL(e), 1e3);
|
|
33
|
+
} catch {
|
|
34
|
+
m(t, r(t), !0);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
c as downloadFile,
|
|
39
|
+
r as fileNameFor
|
|
40
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const _=require("../_virtual/_rolldown/runtime.cjs"),g=require("../typography-text.cjs");let e=require("react");e=_.__toESM(e,1);let p=require("@brightlocal/ui-components/lib/utils"),s=require("react/jsx-runtime");var y=32,i=e.forwardRef(({className:n,dataHook:r,icon:t,message:l,slot:a,trackingEl:c,trackingLabel:d,...m},o)=>{const u=e.isValidElement(t)&&typeof t.type!="string"&&t.type!==e.Fragment?e.cloneElement(t,{size:y}):t;return(0,s.jsxs)("div",{ref:o,className:(0,p.cn)("bg-muted flex flex-col items-center justify-center gap-2 text-center",n),"data-hook":r,"data-slot":a,"data-tracking-el":c??a,"data-tracking-label":d,...m,children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground flex items-center justify-center [&_svg:not([class*='size-'])]:size-8","data-hook":`${r}-icon`,"data-slot":`${a}-icon`,children:u}),(0,s.jsx)(g.TypographyText,{align:"center",color:"muted","data-slot":`${a}-message`,dataHook:`${r}-message`,variant:"body-sm",children:l})]})});i.displayName="EmptyCanvas";exports.EmptyCanvas=i;
|
package/dist/lib/empty-canvas.js
CHANGED
|
@@ -1,61 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypographyText as p } from "../typography-text.js";
|
|
2
2
|
import * as a from "react";
|
|
3
3
|
import { cn as f } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
slot: t,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
size:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
...d,
|
|
32
|
-
children: [
|
|
33
|
-
/* @__PURE__ */ s(
|
|
34
|
-
"span",
|
|
35
|
-
{
|
|
36
|
-
"aria-hidden": "true",
|
|
37
|
-
className: "text-muted-foreground flex items-center justify-center [&_svg:not([class*='size-'])]:size-8",
|
|
38
|
-
"data-hook": `${r}-icon`,
|
|
39
|
-
"data-slot": `${t}-icon`,
|
|
40
|
-
children: l
|
|
41
|
-
}
|
|
42
|
-
),
|
|
43
|
-
/* @__PURE__ */ s(
|
|
44
|
-
g,
|
|
45
|
-
{
|
|
46
|
-
align: "center",
|
|
47
|
-
color: "muted",
|
|
48
|
-
"data-slot": `${t}-message`,
|
|
49
|
-
dataHook: `${r}-message`,
|
|
50
|
-
variant: "body-sm",
|
|
51
|
-
children: i
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
4
|
+
import { jsx as s, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
var y = 32, x = a.forwardRef(({ className: n, dataHook: r, icon: e, message: i, slot: t, trackingEl: m, trackingLabel: d, ...o }, l) => {
|
|
6
|
+
const c = a.isValidElement(e) && typeof e.type != "string" && e.type !== a.Fragment ? a.cloneElement(e, { size: y }) : e;
|
|
7
|
+
return /* @__PURE__ */ g("div", {
|
|
8
|
+
ref: l,
|
|
9
|
+
className: f("bg-muted flex flex-col items-center justify-center gap-2 text-center", n),
|
|
10
|
+
"data-hook": r,
|
|
11
|
+
"data-slot": t,
|
|
12
|
+
"data-tracking-el": m ?? t,
|
|
13
|
+
"data-tracking-label": d,
|
|
14
|
+
...o,
|
|
15
|
+
children: [/* @__PURE__ */ s("span", {
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
className: "text-muted-foreground flex items-center justify-center [&_svg:not([class*='size-'])]:size-8",
|
|
18
|
+
"data-hook": `${r}-icon`,
|
|
19
|
+
"data-slot": `${t}-icon`,
|
|
20
|
+
children: c
|
|
21
|
+
}), /* @__PURE__ */ s(p, {
|
|
22
|
+
align: "center",
|
|
23
|
+
color: "muted",
|
|
24
|
+
"data-slot": `${t}-message`,
|
|
25
|
+
dataHook: `${r}-message`,
|
|
26
|
+
variant: "body-sm",
|
|
27
|
+
children: i
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
});
|
|
59
31
|
x.displayName = "EmptyCanvas";
|
|
60
32
|
export {
|
|
61
33
|
x as EmptyCanvas
|
package/dist/lib/empty-chip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const l=require("../_virtual/_rolldown/runtime.cjs"),n=require("../logo-mark.cjs");let e=require("react");e=l.__toESM(e,1);let _=require("@brightlocal/ui-components/lib/utils"),a=require("react/jsx-runtime");function s({dataHook:r,icon:t,variant:i="filled",slot:u,className:o}){return(0,a.jsx)(n.LogoMark,{className:(0,_.cn)("text-muted-foreground",o),"data-slot":u,dataHook:r,name:t,size:"lg",variant:i})}exports.EmptyChip=s;
|
package/dist/lib/empty-chip.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { LogoMarkVariant } from '../components/logo-mark';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface EmptyChipProps {
|
|
4
|
+
dataHook: string;
|
|
5
|
+
/** The glyph. Decorative — the chip is aria-hidden. */
|
|
6
|
+
icon: React.ReactNode;
|
|
7
|
+
/** @default "filled" */
|
|
8
|
+
variant?: LogoMarkVariant;
|
|
9
|
+
/** Overrides LogoMark's own `logo-mark` slot, so each host keeps its name. */
|
|
10
|
+
slot: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function EmptyChip({ dataHook, icon, variant, slot, className, }: EmptyChipProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
4
15
|
//# sourceMappingURL=empty-chip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty-chip.d.ts","sourceRoot":"","sources":["../../src/lib/empty-chip.
|
|
1
|
+
{"version":3,"file":"empty-chip.d.ts","sourceRoot":"","sources":["../../src/lib/empty-chip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAoBzE,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,wBAAwB;IACxB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,IAAI,EACJ,OAAkB,EAClB,IAAI,EACJ,SAAS,GACV,EAAE,cAAc,qBAWhB"}
|
package/dist/lib/empty-chip.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { LogoMark as i } from "../logo-mark.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { cn as p } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
5
|
+
function d({ dataHook: o, icon: r, variant: t = "filled", slot: m, className: e }) {
|
|
6
|
+
return /* @__PURE__ */ a(i, {
|
|
7
|
+
className: p("text-muted-foreground", e),
|
|
8
|
+
"data-slot": m,
|
|
9
|
+
dataHook: o,
|
|
10
|
+
name: r,
|
|
11
|
+
size: "lg",
|
|
12
|
+
variant: t
|
|
13
|
+
});
|
|
14
|
+
}
|
|
11
15
|
export {
|
|
12
|
-
|
|
16
|
+
d as EmptyChip
|
|
13
17
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const d=require("../_virtual/_rolldown/runtime.cjs");let i=require("react");i=d.__toESM(i,1);let f=require("react/jsx-runtime");var g={description:[],error:[]},c=i.createContext(null);function x({children:s}){const[e,n]=i.useState(g),t=i.useCallback((o,u)=>(n(r=>r[o].includes(u)?r:{...r,[o]:[...r[o],u]}),()=>{n(r=>r[o].includes(u)?{...r,[o]:r[o].filter(a=>a!==u)}:r)}),[]),l=i.useMemo(()=>({ids:e,register:t}),[e,t]);return(0,f.jsx)(c.Provider,{value:l,children:s})}function F(s,e,n){const t=i.useContext(c)?.register;i.useEffect(()=>{if(!(!t||!n))return t(s,e)},[t,s,e,n])}function _(s){const e=i.useContext(c);if(!e)return s;const n=s?.split(/\s+/).filter(Boolean)??[],t=[...new Set([...e.ids.error,...e.ids.description,...n])];return t.length>0?t.join(" "):void 0}exports.FieldAriaProvider=x;exports.useFieldAriaRegistration=F;exports.useFieldDescribedBy=_;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Wires a Field's hint and error message to the control inside it.
|
|
4
|
+
*
|
|
5
|
+
* `Field` provides the context. `FieldDescription` and `FieldError` register
|
|
6
|
+
* the id they render while they are on screen. Text controls (`Input`,
|
|
7
|
+
* `Textarea`) read the registered ids and point `aria-describedby` at them, so
|
|
8
|
+
* a screen reader hears the message together with the field. Outside a Field
|
|
9
|
+
* the hooks do nothing and a control behaves exactly as before.
|
|
10
|
+
*
|
|
11
|
+
* Registration happens in an effect, after hydration. The hint and error sit
|
|
12
|
+
* after the control in the markup, so the control cannot know about them while
|
|
13
|
+
* it renders on the server. Server-rendered markup therefore has no wired
|
|
14
|
+
* `aria-describedby` until hydration; a consumer that needs it before that
|
|
15
|
+
* passes `id` on the message and `aria-describedby` on the control by hand.
|
|
16
|
+
*/
|
|
17
|
+
type FieldAriaKind = "description" | "error";
|
|
18
|
+
declare function FieldAriaProvider({ children }: {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}): React.JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Registers `id` as the Field's hint or error element while `present` is true.
|
|
23
|
+
* A no-op outside a Field.
|
|
24
|
+
*/
|
|
25
|
+
declare function useFieldAriaRegistration(kind: FieldAriaKind, id: string, present: boolean): void;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the `aria-describedby` value for a control: the Field's error, then
|
|
28
|
+
* its hint, then whatever the consumer passed. Ids are de-duplicated, so a
|
|
29
|
+
* consumer that already wires the same id by hand is unaffected. Outside a
|
|
30
|
+
* Field it returns `describedBy` unchanged.
|
|
31
|
+
*/
|
|
32
|
+
declare function useFieldDescribedBy(describedBy?: string): string | undefined;
|
|
33
|
+
export { FieldAriaProvider, useFieldAriaRegistration, useFieldDescribedBy };
|
|
34
|
+
//# sourceMappingURL=field-aria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-aria.d.ts","sourceRoot":"","sources":["../../src/lib/field-aria.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;;;;;;;;;GAcG;AAEH,KAAK,aAAa,GAAG,aAAa,GAAG,OAAO,CAAC;AAiB7C,iBAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAuBrE;AAED;;;GAGG;AACH,iBAAS,wBAAwB,CAC/B,IAAI,EAAE,aAAa,EACnB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,QAQjB;AAED;;;;;GAKG;AACH,iBAAS,mBAAmB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASrE;AAED,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
4
|
+
var x = {
|
|
5
|
+
description: [],
|
|
6
|
+
error: []
|
|
7
|
+
}, c = n.createContext(null);
|
|
8
|
+
function m({ children: o }) {
|
|
9
|
+
const [e, s] = n.useState(x), t = n.useCallback((i, u) => (s((r) => r[i].includes(u) ? r : {
|
|
10
|
+
...r,
|
|
11
|
+
[i]: [...r[i], u]
|
|
12
|
+
}), () => {
|
|
13
|
+
s((r) => r[i].includes(u) ? {
|
|
14
|
+
...r,
|
|
15
|
+
[i]: r[i].filter((a) => a !== u)
|
|
16
|
+
} : r);
|
|
17
|
+
}), []), l = n.useMemo(() => ({
|
|
18
|
+
ids: e,
|
|
19
|
+
register: t
|
|
20
|
+
}), [e, t]);
|
|
21
|
+
return /* @__PURE__ */ f(c.Provider, {
|
|
22
|
+
value: l,
|
|
23
|
+
children: o
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function d(o, e, s) {
|
|
27
|
+
const t = n.useContext(c)?.register;
|
|
28
|
+
n.useEffect(() => {
|
|
29
|
+
if (!(!t || !s))
|
|
30
|
+
return t(o, e);
|
|
31
|
+
}, [
|
|
32
|
+
t,
|
|
33
|
+
o,
|
|
34
|
+
e,
|
|
35
|
+
s
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
function C(o) {
|
|
39
|
+
const e = n.useContext(c);
|
|
40
|
+
if (!e) return o;
|
|
41
|
+
const s = o?.split(/\s+/).filter(Boolean) ?? [], t = [.../* @__PURE__ */ new Set([
|
|
42
|
+
...e.ids.error,
|
|
43
|
+
...e.ids.description,
|
|
44
|
+
...s
|
|
45
|
+
])];
|
|
46
|
+
return t.length > 0 ? t.join(" ") : void 0;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
m as FieldAriaProvider,
|
|
50
|
+
d as useFieldAriaRegistration,
|
|
51
|
+
C as useFieldDescribedBy
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const f=require("../_virtual/_rolldown/runtime.cjs");let r=require("react");r=f.__toESM(r,1);var g={"image/jpeg":"JPEG","image/png":"PNG","image/webp":"WebP","image/gif":"GIF","image/avif":"AVIF","image/svg+xml":"SVG"};function m(e,t){const o=t?g[t.split(";")[0]?.trim()??""]:void 0;if(o)return o;if(e.startsWith("data:"))return g[e.slice(5,e.indexOf(";"))];try{const h=new URL(e,window.location.href).pathname,n=/\.([a-z0-9]{2,5})$/i.exec(h)?.[1];if(n)return n.toLowerCase()==="jpg"?"JPEG":n.toUpperCase()}catch{}}function s(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1).replace(/\.0$/,"")} MB`}function l(e){if(!e)return"—";const t=[m(e.src,e.type),e.width&&e.height?`${e.width} × ${e.height} px`:void 0,e.bytes?s(e.bytes):void 0].filter(Boolean);return t.length?t.join(" · "):"—"}function p(e,t){const[o,h]=r.useState(()=>new Map),n=r.useRef(new Set);r.useEffect(()=>{if(!t||!e||n.current.has(e))return;n.current.add(e);const d=i=>h(a=>new Map(a).set(e,{...a.get(e),...i})),u=new Image;u.src=e,u.decode().then(()=>d({width:u.naturalWidth,height:u.naturalHeight})).catch(()=>{}),!e.startsWith("data:")&&fetch(e,{method:"HEAD",mode:"cors"}).then(i=>{if(!i.ok)return;const a=Number(i.headers.get("content-length"));d({type:i.headers.get("content-type")??void 0,bytes:a>0?a:void 0})}).catch(()=>{})},[e,t]);const c=e?o.get(e):void 0;return e?{src:e,...c}:void 0}exports.describeImageFile=l;exports.useImageFileInfo=p;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** What the view knows about an image file. */
|
|
2
|
+
export interface ImageFileInfo {
|
|
3
|
+
/** MIME type, from the response — e.g. "image/jpeg". */
|
|
4
|
+
type?: string;
|
|
5
|
+
/** File size in bytes, from the response. */
|
|
6
|
+
bytes?: number;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One line for the details tooltip: "JPEG · 1600 × 1067 px · 245 KB". Only
|
|
12
|
+
* what is known; a dash while nothing is.
|
|
13
|
+
*/
|
|
14
|
+
export declare function describeImageFile(info: (ImageFileInfo & {
|
|
15
|
+
src: string;
|
|
16
|
+
}) | undefined): string;
|
|
17
|
+
/**
|
|
18
|
+
* Looks up the file at `src` while `enabled`: its size in pixels from the
|
|
19
|
+
* image itself, its type and weight from a HEAD request (left out when the
|
|
20
|
+
* host does not allow it). Each file is looked up once.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useImageFileInfo(src: string | undefined, enabled: boolean): (ImageFileInfo & {
|
|
23
|
+
src: string;
|
|
24
|
+
}) | undefined;
|
|
25
|
+
//# sourceMappingURL=image-file-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-file-info.d.ts","sourceRoot":"","sources":["../../src/lib/image-file-info.ts"],"names":[],"mappings":"AAEA,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA+BD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,CAAC,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,GAClD,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,OAAO,GACf,CAAC,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CAoC/C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as d from "react";
|
|
2
|
+
var g = {
|
|
3
|
+
"image/jpeg": "JPEG",
|
|
4
|
+
"image/png": "PNG",
|
|
5
|
+
"image/webp": "WebP",
|
|
6
|
+
"image/gif": "GIF",
|
|
7
|
+
"image/avif": "AVIF",
|
|
8
|
+
"image/svg+xml": "SVG"
|
|
9
|
+
};
|
|
10
|
+
function c(t, e) {
|
|
11
|
+
const o = e ? g[e.split(";")[0]?.trim() ?? ""] : void 0;
|
|
12
|
+
if (o) return o;
|
|
13
|
+
if (t.startsWith("data:")) return g[t.slice(5, t.indexOf(";"))];
|
|
14
|
+
try {
|
|
15
|
+
const h = new URL(t, window.location.href).pathname, n = /\.([a-z0-9]{2,5})$/i.exec(h)?.[1];
|
|
16
|
+
if (n) return n.toLowerCase() === "jpg" ? "JPEG" : n.toUpperCase();
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function m(t) {
|
|
21
|
+
return t < 1024 ? `${t} B` : t < 1048576 ? `${Math.round(t / 1024)} KB` : `${(t / 1048576).toFixed(1).replace(/\.0$/, "")} MB`;
|
|
22
|
+
}
|
|
23
|
+
function s(t) {
|
|
24
|
+
if (!t) return "—";
|
|
25
|
+
const e = [
|
|
26
|
+
c(t.src, t.type),
|
|
27
|
+
t.width && t.height ? `${t.width} × ${t.height} px` : void 0,
|
|
28
|
+
t.bytes ? m(t.bytes) : void 0
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
return e.length ? e.join(" · ") : "—";
|
|
31
|
+
}
|
|
32
|
+
function p(t, e) {
|
|
33
|
+
const [o, h] = d.useState(() => /* @__PURE__ */ new Map()), n = d.useRef(/* @__PURE__ */ new Set());
|
|
34
|
+
d.useEffect(() => {
|
|
35
|
+
if (!e || !t || n.current.has(t)) return;
|
|
36
|
+
n.current.add(t);
|
|
37
|
+
const u = (a) => h((i) => new Map(i).set(t, {
|
|
38
|
+
...i.get(t),
|
|
39
|
+
...a
|
|
40
|
+
})), r = new Image();
|
|
41
|
+
r.src = t, r.decode().then(() => u({
|
|
42
|
+
width: r.naturalWidth,
|
|
43
|
+
height: r.naturalHeight
|
|
44
|
+
})).catch(() => {
|
|
45
|
+
}), !t.startsWith("data:") && fetch(t, {
|
|
46
|
+
method: "HEAD",
|
|
47
|
+
mode: "cors"
|
|
48
|
+
}).then((a) => {
|
|
49
|
+
if (!a.ok) return;
|
|
50
|
+
const i = Number(a.headers.get("content-length"));
|
|
51
|
+
u({
|
|
52
|
+
type: a.headers.get("content-type") ?? void 0,
|
|
53
|
+
bytes: i > 0 ? i : void 0
|
|
54
|
+
});
|
|
55
|
+
}).catch(() => {
|
|
56
|
+
});
|
|
57
|
+
}, [t, e]);
|
|
58
|
+
const f = t ? o.get(t) : void 0;
|
|
59
|
+
return t ? {
|
|
60
|
+
src: t,
|
|
61
|
+
...f
|
|
62
|
+
} : void 0;
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
s as describeImageFile,
|
|
66
|
+
p as useImageFileInfo
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const ye=require("../_virtual/_rolldown/runtime.cjs"),J=require("../button.cjs"),pe=require("../dialog.cjs"),He=require("../info-tooltip.cjs"),Ge=require("../media-empty.cjs"),Z=require("./compose-event-handlers.cjs"),V=require("./media-viewer-internal.cjs"),D=require("./media-viewer-motion.cjs"),Je=require("./download-file.cjs"),he=require("./image-file-info.cjs"),Qe=require("../relative-date.cjs");let c=require("react");c=ye.__toESM(c,1);let Y=require("@brightlocal/icons"),C=require("@brightlocal/ui-components/lib/utils"),i=require("react/jsx-runtime"),et=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock"),te=require("@radix-ui/react-dialog");te=ye.__toESM(te,1);let W=require("@brightlocal/ui-components/lib/motion"),tt=require("@brightlocal/ui-components/hooks/use-prefers-reduced-motion");var G=[1,1.5,2,3],ge=2.5,we=(0,C.cn)("group/nav absolute inset-y-0 flex w-16 items-center justify-center outline-none sm:w-20","duration-fast opacity-0 transition-opacity ease-out","group-hover/stage:opacity-100 focus-visible:opacity-100","disabled:invisible pointer-coarse:hidden"),xe=(0,C.cn)(J.ButtonVariants({variant:"ghost"}),"pointer-events-none size-9 p-0 group-hover/nav:bg-accent group-hover/nav:text-accent-foreground group-focus-visible/nav:shadow-default"),nt=(t,d)=>`${t} of ${d}`;function rt(t,d,g){const[p,b]=c.useState(()=>new Set),[x,R]=c.useState(()=>new Map),[_,e]=c.useState(()=>new Set),[l,s]=c.useState(()=>new Map),v=c.useCallback((m,n,f)=>{if(!n||!f)return null;const u=n/f;return R(h=>h.get(m)===u?h:new Map(h).set(m,u)),u},[]),o=c.useCallback(m=>{b(n=>new Set(n).add(m))},[]);return c.useEffect(()=>{if(!g)return;let m=!1;for(const n of[t[d],t[d+1],t[d-1]]){if(!n||n.expired)continue;const f=new Image;f.src=n.src,f.decode().then(()=>{m||(v(n.src,f.naturalWidth,f.naturalHeight),s(u=>u.get(n.src)===f.naturalWidth?u:new Map(u).set(n.src,f.naturalWidth)),e(u=>u.has(n.src)?u:new Set(u).add(n.src)))}).catch(()=>{})}return()=>{m=!0}},[g,t,d,v]),{failed:p,ratios:x,widths:l,ready:_,noteRatio:v,markFailed:o}}function at({index:t,openCount:d,openedAtRef:g,triggersRef:p,reducedMotion:b,setOpen:x,revealed:R,reveal:_}){const e=c.useRef(null),l=c.useRef(null),s=c.useRef(null),v=c.useRef(0),o=c.useRef(0),m=u=>{const h=p.current.get(u);return h?.isConnected?h:null};return{imageRef:e,overlayRef:l,barRef:s,revealed:R,reveal:_,zoomIn:(u,h,k)=>{if(v.current===d||(v.current=d,u.style.visibility="visible",_(),k-g.current>500))return;const E=b||h?null:m(t),T=E?D.zoomKeyframe(E,u):null;T?u.animate([T,D.ZOOM_REST],{duration:W.MOTION_DURATION_SLOW_MS,easing:W.MOTION_EASE_EMPHASIZED}):u.animate([{opacity:0},{opacity:1}],{duration:W.MOTION_DURATION_SLOW_MS,easing:"ease-out"})},requestClose:({fade:u=!1}={})=>{if(o.current===d)return;const h=e.current,k=b||u?null:m(t);h?.getAnimations().forEach(r=>r.cancel());const E=h&&k?D.zoomKeyframe(k,h):null;if(!h||!E){x(!1);return}o.current=d;const T={duration:W.MOTION_DURATION_BASE_MS,easing:"ease-in-out",fill:"forwards"};for(const r of[l.current,s.current])r?.animate([{opacity:1},{opacity:0}],T);h.animate([D.ZOOM_REST,E],T).finished.catch(()=>{}).finally(()=>x(!1))}}}function it({index:t,total:d,reducedMotion:g,onStep:p}){const b=c.useRef(null),x=c.useRef(null),R=c.useRef(null),_=c.useRef(null),e=()=>b.current?.clientWidth??0,l=r=>{const y=x.current;y&&(y.style.transform=r?`translateX(${r}px)`:"")},s=r=>r>0&&t===0||r<0&&t===d-1,v=r=>s(r)?D.rubberBand(r,e()*D.RUBBER_BAND_SHARE):r,o=(r,y)=>{const S=x.current?.animate([{transform:`translateX(${r}px)`},{transform:"none"}],D.glideTiming(r,y));_.current=S?{from:r,animation:S}:null},m=(r,y=0)=>{l(0),!(!r||g)&&o(r,y)},n=()=>{const r=_.current?.animation.playState;return r==="running"||r==="paused"},f=()=>{const r=_.current;if(_.current=null,!r||r.animation.playState==="finished")return 0;const y=r.animation.effect?.getComputedTiming().progress,S=r.from*(1-(y??0));return r.animation.cancel(),l(S),S},u=(r,y=0,S=0)=>{if(r===t||r<0||r>=d)return;const X=e();y&&!g&&X&&Math.abs(r-t)===1&&(R.current={from:(r>t?1:-1)*X+y,speed:S}),p(r)},h=r=>u(t+r),k=()=>Math.min(e()*D.DRAG_STEP_SHARE,160),E=(r,y=k())=>{const S=t+(r<0?1:-1);return Math.abs(r)>y&&S>=0&&S<d},T=(r,y,S=0)=>{const X=y<0?1:-1,Q=!(S*y<0&&Math.abs(S)>.2)&&(Math.abs(y)>k()||Math.abs(S)>.5),L=t+X;Q&&L>=0&&L<d?u(L,r,S):m(r,S)};return c.useLayoutEffect(()=>{const r=R.current;R.current=null,_.current?.animation.cancel(),_.current=null,l(0),r?.from&&o(r.from,r.speed)},[t]),{frameRef:b,trackRef:x,moveTrack:l,pastEnd:s,resist:v,settle:m,gliding:n,stopGlide:f,goTo:u,step:h,canStep:E,release:T}}function ot(t,d,g){const p=c.useRef({x:0,y:0}),b=c.useRef(t),x=c.useRef(null),R=c.useRef(!1),_=n=>{const f=d.current,u=g.current;if(!f||!u)return;const h=b.current,k=Math.max(0,(f.offsetWidth*h-u.clientWidth)/2),E=Math.max(0,(f.offsetHeight*h-u.clientHeight)/2),T=p.current;T.x=Math.min(k,Math.max(-k,T.x)),T.y=Math.min(E,Math.max(-E,T.y)),f.style.transition=n?`transform ${W.MOTION_DURATION_BASE_MS}ms ${W.MOTION_EASE_DECELERATE}`:"none",f.style.transform=h===1?"":`translate(${T.x}px, ${T.y}px) scale(${h})`};c.useLayoutEffect(()=>{const n=t/b.current;b.current=t,p.current=t===1?{x:0,y:0}:{x:p.current.x*n,y:p.current.y*n},_(!0)},[t]);const e=(n,f)=>{p.current.x+=n,p.current.y+=f,_(!1)};return{panBy:e,reset:()=>{const n=d.current;p.current={x:0,y:0},b.current=1,n&&(n.style.transition="none",n.style.transform="")},onPointerDown:n=>{n.pointerType==="mouse"&&n.button!==0||(R.current=!1,n.target instanceof Node&&d.current?.contains(n.target)&&(x.current={x:n.clientX,y:n.clientY,moved:!1},n.currentTarget.setPointerCapture?.(n.pointerId)))},onPointerMove:n=>{const f=x.current;if(!f)return;const u=n.clientX-f.x,h=n.clientY-f.y;!f.moved&&Math.hypot(u,h)<4||(f.moved=!0,f.x=n.clientX,f.y=n.clientY,e(u,h))},onPointerUp:()=>{R.current=!!x.current?.moved,x.current=null},consumePan:()=>{const n=R.current;return R.current=!1,n}}}function st(t,d){const g=c.useRef(!1),p=c.useRef(null);return{consumeSwipe:()=>{const l=g.current;return g.current=!1,l},onPointerDown:l=>{g.current=!1,!(l.pointerType==="mouse"||!d)&&(p.current={x:l.clientX,y:l.clientY,axis:null,base:0,offset:0,speed:0,lastX:l.clientX,lastTime:l.timeStamp})},onPointerMove:l=>{const s=p.current;if(!s)return;const v=l.clientX-s.x,o=l.clientY-s.y;if(!s.axis){if(Math.hypot(v,o)<8)return;s.axis=Math.abs(v)>Math.abs(o)?"x":"y",s.axis==="x"&&(s.base=t.stopGlide())}if(s.axis!=="x")return;const m=l.timeStamp-s.lastTime;if(m>0){const n=(l.clientX-s.lastX)/m;s.speed=s.speed*.3+n*.7}s.lastX=l.clientX,s.lastTime=l.timeStamp,s.offset=t.resist(s.base+v),t.moveTrack(s.offset)},onPointerUp:l=>{const s=p.current;if(p.current=null,!s||s.axis!=="x")return;g.current=!0;const v=l.timeStamp-s.lastTime>80?0:s.speed;t.release(s.offset,l.clientX-s.x,v)},onPointerCancel:()=>{const l=p.current;p.current=null,l?.axis==="x"&&t.settle(l.offset)}}}function ct(t,d,g,p){const b=c.useRef(d),x=c.useRef(g),R=c.useRef(p);c.useLayoutEffect(()=>{b.current=d,x.current=g,R.current=p});const _=c.useRef({swiping:!1,intent:0,offset:0,pull:0,previous:0,fading:0,speed:0,last:0,inertia:0,inertiaTimer:0,inertiaPrevious:0,inertiaFaintest:0,inertiaFading:!1,cancelTimer:0});c.useEffect(()=>{if(!t)return;const e=_.current,l=o=>{e.inertia=o,window.clearTimeout(e.inertiaTimer),e.inertiaTimer=window.setTimeout(()=>{e.inertia=0},300)},s=o=>{l(o),e.inertiaPrevious=Math.abs(o),e.inertiaFaintest=Math.abs(o),e.inertiaFading=!1},v=o=>{if(o.ctrlKey)return;if(!x.current){o.preventDefault(),R.current(-o.deltaX,-o.deltaY);return}if(Math.abs(o.deltaY)>Math.abs(o.deltaX)||o.target instanceof Element&&o.target.closest('[data-slot="media-viewer-thumbnails"]'))return;o.preventDefault();const m=b.current,n=Math.abs(o.deltaX),f=o.timeStamp-e.last;if(e.last=o.timeStamp,e.swiping)f>0&&(e.speed=e.speed*.3+-o.deltaX/f*.7);else{window.clearTimeout(e.cancelTimer);const h=e.inertia!==0&&Math.sign(o.deltaX)===Math.sign(e.inertia);h&&(n<e.inertiaPrevious&&(e.inertiaFading||(e.inertiaFaintest=n),e.inertiaFading=!0),e.inertiaFading&&(e.inertiaFaintest=Math.min(e.inertiaFaintest,n)),e.inertiaPrevious=n);const k=e.inertiaFading&&n>=e.inertiaFaintest*2;if(h&&!k&&(m.gliding()||n<=Math.abs(e.inertia)*1.2)){l(o.deltaX),e.intent=0;return}if(e.intent+=o.deltaX,Math.abs(e.intent)<=30){e.cancelTimer=window.setTimeout(()=>{e.intent=0},600);return}e.intent=0,e.swiping=!0,e.inertia=0,e.inertiaFading=!1,e.offset=m.stopGlide(),e.pull=0,e.speed=0,e.fading=0}window.clearTimeout(e.cancelTimer);const u=t.clientWidth;if(e.offset=Math.max(-u,Math.min(u,e.offset-o.deltaX)),e.pull-=o.deltaX,m.moveTrack(m.resist(e.offset)),e.fading=n<e.previous?e.fading+1:0,e.previous=n,m.pastEnd(e.offset)&&e.fading>=2){e.swiping=!1,s(o.deltaX),m.release(m.resist(e.offset),0);return}if(m.canStep(e.pull,u*.2)){e.swiping=!1,s(o.deltaX),m.release(m.resist(e.offset),e.pull,e.speed);return}e.cancelTimer=window.setTimeout(()=>{e.swiping=!1,m.release(m.resist(e.offset),0)},600)};return t.addEventListener("wheel",v,{passive:!1}),()=>{t.removeEventListener("wheel",v),window.clearTimeout(e.cancelTimer),window.clearTimeout(e.inertiaTimer)}},[t])}function lt({dataHook:t,hasPrevious:d,hasNext:g,previousLabel:p,nextLabel:b,onStep:x}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{"aria-label":p??"Previous",className:(0,C.cn)(we,"left-0"),"data-hook":`${t}-previous`,"data-slot":"media-viewer-previous",disabled:!d,type:"button",onClick:()=>x(-1),children:(0,i.jsx)("span",{"aria-hidden":!0,className:xe,children:(0,i.jsx)(Y.ChevronLeft,{})})}),(0,i.jsx)("button",{"aria-label":b??"Next",className:(0,C.cn)(we,"right-0"),"data-hook":`${t}-next`,"data-slot":"media-viewer-next",disabled:!g,type:"button",onClick:()=>x(1),children:(0,i.jsx)("span",{"aria-hidden":!0,className:xe,children:(0,i.jsx)(Y.ChevronRight,{})})})]})}function ut({dataHook:t,items:d,index:g,failed:p,label:b,onSelect:x,onRatio:R}){const _=c.useRef(null);return c.useEffect(()=>{_.current?.querySelector('[aria-current="true"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[g]),(0,i.jsx)("div",{ref:_,"aria-label":b??"Images",className:"mb-2 flex max-w-full gap-1.5 justify-self-center overflow-x-auto p-1 [grid-area:strip] sm:mb-0","data-hook":`${t}-thumbnails`,"data-slot":"media-viewer-thumbnails",role:"group",children:d.map((e,l)=>{const s=l===g,v=e.expired||p.has(e.src);return(0,i.jsx)("button",{"aria-current":s?"true":void 0,"aria-label":e.alt,className:(0,C.cn)("bg-muted relative size-12 shrink-0 overflow-hidden rounded-md outline-none","duration-fast focus-visible:shadow-default transition-opacity ease-out",s?"opacity-100":"opacity-50 hover:opacity-100"),"data-hook":`${t}-thumbnail-${l}`,"data-slot":"media-viewer-thumbnail",type:"button",onClick:()=>x(l),children:v?null:(0,i.jsx)("img",{alt:"",className:"size-full object-cover object-top",decoding:"async",draggable:!1,loading:"lazy",src:e.thumbnailSrc??e.src,onLoad:o=>R(e.src,o.currentTarget.naturalWidth,o.currentTarget.naturalHeight)})},e.src)})})}var be=c.forwardRef(({dataHook:t,children:d,formatPosition:g,previousLabel:p,nextLabel:b,thumbnailsLabel:x,unavailableMessage:R,zoomInLabel:_,zoomOutLabel:e,downloadLabel:l,infoLabel:s,dateLabels:v,className:o,trackingEl:m,trackingLabel:n,onClick:f,onCloseAutoFocus:u,onEscapeKeyDown:h,onKeyDown:k,onOpenAutoFocus:E,...T},r)=>{const{items:y,index:S,setIndex:X,openerRef:Q,open:L,setOpen:ve,openCount:ne,openedAtRef:Me,revealed:Re,reveal:Se,triggersRef:Te,renderActions:re,actionsLabel:je}=V.useMediaViewerContext("MediaViewerContent"),ae=(0,tt.usePrefersReducedMotion)();(0,et.useOverlayPointerLock)();const F=y.length,j=Math.min(Math.max(S,0),Math.max(F-1,0)),Pe=j>0,ke=j<F-1,K=`${ne}:${j}`,[ie,Ee]=c.useState({key:"",level:0}),B=ie.key===K?ie.level:0,N=B>0,H=a=>Ee(w=>{const M=w.key===K?w.level:0,q=Math.min(Math.max(M+a,0),G.length-1);return q===M&&w.key===K?w:{key:K,level:q}}),{failed:ee,ratios:Ne,widths:oe,ready:qe,noteRatio:se,markFailed:Ce}=rt(y,j,L),z=at({index:j,openCount:ne,openedAtRef:Me,triggersRef:Te,reducedMotion:ae,setOpen:ve,revealed:Re,reveal:Se}),I=it({index:j,total:F,reducedMotion:ae,onStep:a=>{z.reveal(),A.reset(),X(a)}}),U=st(I,!N),{frameRef:ce,trackRef:Oe}=I,{imageRef:le,overlayRef:De,barRef:Fe}=z,A=ot(G[B]??1,le,ce),[Ie,Ae]=c.useState(null),$e=c.useCallback(a=>{Ae(a),typeof r=="function"?r(a):r&&(r.current=a)},[r]);ct(Ie,I,!N,A.panBy);const P=y[j],$=!!(P&&!P.expired&&!ee.has(P.src)),Xe=he.useImageFileInfo($?P?.downloadSrc??P?.src:void 0,L),Le=(a,w,M)=>{const q=a.currentTarget,O=se(w,q.naturalWidth,q.naturalHeight);M&&(O&&q.style.setProperty("--media-ratio",String(O)),z.zoomIn(q,O!==null&&1/O>ge,a.timeStamp))},ze=a=>{a.defaultPrevented||a.target.closest('[role="menu"]')||(a.key==="ArrowLeft"?(a.preventDefault(),I.step(-1)):a.key==="ArrowRight"?(a.preventDefault(),I.step(1)):(a.key==="+"||a.key==="=")&&$?(a.preventDefault(),H(1)):a.key==="-"&&$&&(a.preventDefault(),H(-1)))},Ve=a=>{const w=Q.current;w?.isConnected&&(a.preventDefault(),w.focus())},We=a=>{a.preventDefault(),a.currentTarget?.focus()},Be=a=>{U.consumeSwipe()||A.consumePan()||a.target instanceof HTMLElement&&a.target.hasAttribute("data-media-viewer-backdrop")&&z.requestClose({fade:N})},ue=(0,i.jsxs)(i.Fragment,{children:[P&&re?(0,i.jsx)(V.ItemActionsMenu,{dataHook:`${t}-actions-menu`,label:je(P,j),variant:"ghost",children:re(P,j)}):null,(0,i.jsx)(He.InfoTooltip,{ariaLabel:s??"Image details",className:"text-foreground hover:bg-accent size-9 items-center justify-center rounded-md",content:he.describeImageFile(Xe),dataHook:`${t}-info`,disabled:!$})]}),de=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(J.Button,{iconOnly:!0,ariaLabel:l??"Download",dataHook:`${t}-download`,disabled:!$,variant:"ghost",onClick:()=>{P&&Je.downloadFile(P.downloadSrc??P.src)},children:(0,i.jsx)(Y.Download,{"aria-hidden":!0})}),(0,i.jsx)(J.Button,{iconOnly:!0,ariaLabel:_??"Zoom in",dataHook:`${t}-zoom-in`,disabled:!$||B===G.length-1,variant:"ghost",onClick:()=>H(1),children:(0,i.jsx)(Y.ZoomIn,{"aria-hidden":!0})}),(0,i.jsx)(J.Button,{iconOnly:!0,ariaLabel:e??"Zoom out",dataHook:`${t}-zoom-out`,disabled:!$||B===0,variant:"ghost",onClick:()=>H(-1),children:(0,i.jsx)(Y.ZoomOut,{"aria-hidden":!0})})]}),[Ue,fe]=c.useState(0),Ze=c.useMemo(()=>()=>(fe(a=>a+1),()=>fe(a=>a-1)),[]),Ye=a=>{const w=y[a];if(!w)return null;const M=a===j,q=w.expired||ee.has(w.src);if(q&&!M)return null;const O=Ne.get(w.src),me=O!==void 0&&1/O>ge;return(0,i.jsx)("div",{"aria-hidden":M?void 0:!0,className:(0,C.cn)("[container-type:size] absolute inset-0 flex px-4 pt-8 pb-4 sm:px-20",M&&!N?"overflow-auto":"overflow-hidden"),"data-media-viewer-backdrop":M?"":void 0,"data-slot":M?"media-viewer-slide":"media-viewer-peek",style:M?void 0:{transform:`translateX(${(a-j)*100}%)`},children:q?(0,i.jsx)("div",{className:"m-auto w-full max-w-3xl",children:(0,i.jsx)("div",{className:"aspect-[4/3] w-full",children:(0,i.jsx)(Ge.MediaEmpty,{dataHook:`${t}-empty`,message:R??"Image no longer available"})})}):(0,i.jsx)("img",{ref:M?le:void 0,alt:M?w.alt:"",className:(0,C.cn)("m-auto block h-auto",M&&N&&"cursor-grab active:cursor-grabbing",me?"w-full max-w-(--media-natural-width)":"w-[min(100cqw,calc(100cqh*var(--media-ratio,1)),var(--media-natural-width,100cqw))]"),"data-fit":M?me?"width":"contain":void 0,"data-hook":M?`${t}-image`:void 0,"data-media-viewer-backdrop":M&&!N?"":void 0,"data-slot":M?"media-viewer-image":void 0,"data-zoom":M?G[B]:void 0,decoding:"sync",draggable:!1,src:qe.has(w.src)?w.src:w.thumbnailSrc??w.src,style:{"--media-ratio":O,"--media-natural-width":oe.has(w.src)?`${oe.get(w.src)}px`:void 0,visibility:M&&!z.revealed?"hidden":void 0},onError:()=>Ce(w.src),onLoad:Ke=>Le(Ke,w.src,M)})},w.src)};return(0,i.jsxs)(pe.DialogPortal,{children:[(0,i.jsx)(pe.DialogOverlay,{ref:De,className:"data-[state=closed]:duration-fast bg-black/85 data-[state=closed]:ease-out"}),(0,i.jsxs)(te.Content,{ref:$e,"aria-describedby":void 0,className:(0,C.cn)("dark text-foreground group/viewer data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-fast fixed inset-0 z-50 grid h-dvh w-screen grid-rows-[minmax(0,1fr)_auto] ease-out outline-none",o),"data-hook":t,"data-media-viewer-backdrop":"","data-slot":"media-viewer-content","data-tracking-el":m??"media-viewer","data-tracking-label":n,...T,onClick:a=>Z.composeEventHandlers(f,Be)(a),onCloseAutoFocus:a=>Z.composeEventHandlers(u,Ve)(a),onEscapeKeyDown:a=>Z.composeEventHandlers(h,w=>{w.preventDefault(),z.requestClose({fade:N})})(a),onKeyDown:a=>Z.composeEventHandlers(k,ze)(a),onOpenAutoFocus:a=>Z.composeEventHandlers(E,We)(a),children:[(0,i.jsxs)("div",{ref:ce,className:(0,C.cn)("group/stage relative min-h-0 overflow-hidden select-none",N?"touch-none":"touch-pan-y"),"data-hook":`${t}-frame`,"data-slot":"media-viewer-frame",onPointerCancel:N?A.onPointerUp:U.onPointerCancel,onPointerDown:N?A.onPointerDown:U.onPointerDown,onPointerMove:N?A.onPointerMove:U.onPointerMove,onPointerUp:N?A.onPointerUp:U.onPointerUp,children:[(0,i.jsx)("div",{ref:Oe,className:"relative size-full",children:[j-1,j,j+1].map(Ye)}),F>1?(0,i.jsx)(lt,{dataHook:t,hasNext:ke,hasPrevious:Pe,nextLabel:b,previousLabel:p,onStep:I.step}):null]}),(0,i.jsxs)("div",{ref:Fe,className:(0,C.cn)("grid items-center gap-x-4 gap-y-1 px-4 pt-6 pb-3 sm:px-8","grid-cols-[minmax(0,1fr)_auto] [grid-template-areas:'strip_strip'_'title_actions'_'caption_actions'_'date_actions']","sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)_minmax(0,1fr)] sm:[grid-template-areas:'title_strip_actions'_'caption_strip_actions'_'date_strip_actions']"),"data-media-viewer-backdrop":"","data-slot":"media-viewer-bar",children:[F>1?(0,i.jsx)("span",{"aria-atomic":"true","aria-live":"polite",className:"sr-only","data-hook":`${t}-position`,"data-slot":"media-viewer-position",role:"status",children:(g??nt)(j+1,F)}):null,F>1?(0,i.jsx)(ut,{dataHook:t,failed:ee,index:j,items:y,label:x,onRatio:se,onSelect:I.goTo}):null,P?.alt?(0,i.jsx)(V.TruncatedText,{dataHook:`${t}-caption`,full:P.alt,render:a=>(0,i.jsx)("p",{ref:a,"aria-hidden":!0,className:"text-body-xs truncate [grid-area:caption]","data-hook":`${t}-caption`,"data-slot":"media-viewer-caption",children:P.alt})}):null,P?.date?(0,i.jsx)(Qe.RelativeDate,{className:"truncate [grid-area:date]",dataHook:`${t}-date`,labels:v,value:P.date}):null,(0,i.jsx)(V.MediaViewerControlsContext.Provider,{value:{lead:de,more:ue},children:(0,i.jsxs)(V.MediaViewerActionsRegistry.Provider,{value:Ze,children:[Ue?null:(0,i.jsxs)("div",{className:"flex items-center justify-end gap-1 [grid-area:actions]","data-hook":`${t}-actions`,"data-slot":"media-viewer-actions",children:[de,ue]}),d]})})]})]})]})});be.displayName="MediaViewerView";var _e=c.forwardRef((t,d)=>{const{viewable:g}=V.useMediaViewerContext("MediaViewerContent");return g?(0,i.jsx)(be,{ref:d,...t}):null});_e.displayName="MediaViewerContent";exports.MediaViewerContent=_e;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { RelativeDateLabels } from '../components/relative-date';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
4
|
+
/**
|
|
5
|
+
* Props for MediaViewerContent.
|
|
6
|
+
*/
|
|
7
|
+
export interface MediaViewerContentProps extends Omit<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, "children" | "asChild"> {
|
|
8
|
+
/**
|
|
9
|
+
* Required data-hook attribute for automated testing. The parts derive
|
|
10
|
+
* theirs from it: `-frame`, `-image`, `-empty`, `-position`, `-previous`,
|
|
11
|
+
* `-next`, `-thumbnails`, `-thumbnail-<index>`.
|
|
12
|
+
* @example "photo-viewer"
|
|
13
|
+
*/
|
|
14
|
+
dataHook: string;
|
|
15
|
+
/**
|
|
16
|
+
* `MediaViewerTitle` (required — it names the dialog) and, optionally,
|
|
17
|
+
* `MediaViewerActions`. They go in the bottom bar: the title on the left,
|
|
18
|
+
* over the open image's description (`alt`) and `date`; the actions on the right.
|
|
19
|
+
*/
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Builds the "2 of 5" text from the position and the total.
|
|
23
|
+
* @default (current, total) => `${current} of ${total}`
|
|
24
|
+
*/
|
|
25
|
+
formatPosition?: (current: number, total: number) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Accessible label for the Previous button.
|
|
28
|
+
* @default "Previous"
|
|
29
|
+
*/
|
|
30
|
+
previousLabel?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Accessible label for the Next button.
|
|
33
|
+
* @default "Next"
|
|
34
|
+
*/
|
|
35
|
+
nextLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Accessible name for the strip of thumbnails.
|
|
38
|
+
* @default "Images"
|
|
39
|
+
*/
|
|
40
|
+
thumbnailsLabel?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The line shown when an image has expired or cannot be loaded.
|
|
43
|
+
* @default "Image no longer available"
|
|
44
|
+
*/
|
|
45
|
+
unavailableMessage?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Accessible label for the Zoom in button.
|
|
48
|
+
* @default "Zoom in"
|
|
49
|
+
*/
|
|
50
|
+
zoomInLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Accessible label for the Zoom out button.
|
|
53
|
+
* @default "Zoom out"
|
|
54
|
+
*/
|
|
55
|
+
zoomOutLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible label for the Download button.
|
|
58
|
+
* @default "Download"
|
|
59
|
+
*/
|
|
60
|
+
downloadLabel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Accessible label for the image details button — its format, size in
|
|
63
|
+
* pixels and file size, in a tooltip.
|
|
64
|
+
* @default "Image details"
|
|
65
|
+
*/
|
|
66
|
+
infoLabel?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Words for the open image's date ("3 days ago", "today"). Each key
|
|
69
|
+
* defaults to its English value.
|
|
70
|
+
* @default DEFAULT_RELATIVE_DATE_LABELS
|
|
71
|
+
*/
|
|
72
|
+
dateLabels?: Partial<RelativeDateLabels>;
|
|
73
|
+
/**
|
|
74
|
+
* Tracking element identifier for analytics.
|
|
75
|
+
* @default "media-viewer"
|
|
76
|
+
*/
|
|
77
|
+
trackingEl?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Tracking label for analytics context.
|
|
80
|
+
*/
|
|
81
|
+
trackingLabel?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The full view, a lightbox that fills the window: the image with Previous /
|
|
85
|
+
* Next at its sides, and a bottom bar with the title, a strip of thumbnails and
|
|
86
|
+
* the actions; the arrow keys and Esc; an empty state for an expired image.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <MediaViewerContent dataHook="photo-viewer">
|
|
91
|
+
* <MediaViewerTitle>Riverside Plumbing</MediaViewerTitle>
|
|
92
|
+
* <MediaViewerActions>
|
|
93
|
+
* <Button iconOnly variant="ghost" dataHook="photo-share" ariaLabel="Share" onClick={share}>
|
|
94
|
+
* <Share2 aria-hidden />
|
|
95
|
+
* </Button>
|
|
96
|
+
* </MediaViewerActions>
|
|
97
|
+
* </MediaViewerContent>
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare const MediaViewerContent: React.ForwardRefExoticComponent<MediaViewerContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
101
|
+
export { MediaViewerContent };
|
|
102
|
+
//# sourceMappingURL=media-viewer-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-viewer-content.d.ts","sourceRoot":"","sources":["../../src/lib/media-viewer-content.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAwC1D,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6BAA6B,CAAC;AAiBrC;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CACnD,KAAK,CAAC,wBAAwB,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,EAC9D,UAAU,GAAG,SAAS,CACvB;IACC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5D;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACzC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAk4CD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,kBAAkB,gGAMtB,CAAC;AAIH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|