banhaten 0.3.0 → 0.5.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/CHANGELOG.md +139 -73
- package/CONTRIBUTING.md +46 -44
- package/README.md +192 -190
- package/SECURITY.md +15 -15
- package/banhaten.config.example.json +11 -11
- package/docs/design-spacing.md +13 -0
- package/docs/design-system/README.md +22 -20
- package/docs/design-system/adoption-quality-remediation.md +87 -87
- package/docs/design-system/agent-usage.md +13 -13
- package/docs/design-system/appearance-presets.md +189 -189
- package/docs/design-system/appearances/default.md +94 -94
- package/docs/design-system/appearances/rounded.md +95 -95
- package/docs/design-system/appearances/sharp.md +95 -95
- package/docs/design-system/component-docs-pattern.md +81 -81
- package/docs/design-system/component-implementation-ownership-audit.md +245 -244
- package/docs/design-system/component-quality-audit-2026-08-20.md +225 -223
- package/docs/design-system/component-showcase-consistency-report.md +219 -219
- package/docs/design-system/component-token-consistency-audit.md +173 -173
- package/docs/design-system/components/README.md +90 -76
- package/docs/design-system/components/accordion.md +53 -53
- package/docs/design-system/components/activity-feed.md +94 -94
- package/docs/design-system/components/activity-heatmap.md +57 -57
- package/docs/design-system/components/agent-input.md +85 -0
- package/docs/design-system/components/alert-dialog.md +72 -72
- package/docs/design-system/components/alert.md +98 -98
- package/docs/design-system/components/approval-card.md +134 -0
- package/docs/design-system/components/aspect-ratio.md +45 -45
- package/docs/design-system/components/attribute.md +89 -89
- package/docs/design-system/components/autocomplete.md +75 -75
- package/docs/design-system/components/avatar.md +54 -54
- package/docs/design-system/components/badge.md +54 -54
- package/docs/design-system/components/banner.md +87 -87
- package/docs/design-system/components/breadcrumbs.md +177 -176
- package/docs/design-system/components/button-group.md +98 -98
- package/docs/design-system/components/button.md +83 -80
- package/docs/design-system/components/card.md +88 -88
- package/docs/design-system/components/carousel.md +46 -46
- package/docs/design-system/components/catalog-components.md +47 -47
- package/docs/design-system/components/chart.md +95 -24
- package/docs/design-system/components/checkbox.md +54 -54
- package/docs/design-system/components/collapsible.md +67 -53
- package/docs/design-system/components/command.md +62 -62
- package/docs/design-system/components/context-menu.md +46 -46
- package/docs/design-system/components/date-picker.md +81 -79
- package/docs/design-system/components/divider.md +102 -102
- package/docs/design-system/components/empty-state.md +56 -56
- package/docs/design-system/components/field.md +70 -70
- package/docs/design-system/components/file-upload.md +187 -187
- package/docs/design-system/components/hover-card.md +48 -48
- package/docs/design-system/components/icons.md +48 -48
- package/docs/design-system/components/inline-citations.md +93 -0
- package/docs/design-system/components/input-group.md +58 -58
- package/docs/design-system/components/input-otp.md +56 -56
- package/docs/design-system/components/input.md +117 -61
- package/docs/design-system/components/item.md +59 -57
- package/docs/design-system/components/kbd.md +54 -49
- package/docs/design-system/components/label.md +49 -49
- package/docs/design-system/components/menu.md +71 -61
- package/docs/design-system/components/menubar.md +47 -47
- package/docs/design-system/components/modal.md +105 -105
- package/docs/design-system/components/native-select.md +54 -54
- package/docs/design-system/components/navigation-menu.md +50 -50
- package/docs/design-system/components/onboarding-step-list-item.md +82 -82
- package/docs/design-system/components/page-header.md +93 -86
- package/docs/design-system/components/pagination.md +57 -57
- package/docs/design-system/components/popover.md +60 -60
- package/docs/design-system/components/progress-slider.md +50 -50
- package/docs/design-system/components/progress.md +76 -76
- package/docs/design-system/components/radio-card.md +51 -51
- package/docs/design-system/components/radio-group.md +57 -57
- package/docs/design-system/components/resizable.md +44 -44
- package/docs/design-system/components/rolling-count.md +61 -0
- package/docs/design-system/components/scroll-area.md +51 -51
- package/docs/design-system/components/segmented-control.md +54 -54
- package/docs/design-system/components/select.md +68 -62
- package/docs/design-system/components/sheet.md +67 -67
- package/docs/design-system/components/shimmer-text.md +67 -0
- package/docs/design-system/components/sidebar.md +127 -76
- package/docs/design-system/components/skeleton.md +75 -75
- package/docs/design-system/components/slideout.md +65 -65
- package/docs/design-system/components/slider.md +63 -63
- package/docs/design-system/components/social-button.md +50 -50
- package/docs/design-system/components/spinner.md +62 -62
- package/docs/design-system/components/steps.md +65 -65
- package/docs/design-system/components/streaming-text.md +82 -0
- package/docs/design-system/components/table.md +419 -414
- package/docs/design-system/components/tabs.md +59 -55
- package/docs/design-system/components/tag.md +80 -80
- package/docs/design-system/components/task-list.md +95 -0
- package/docs/design-system/components/textarea.md +50 -50
- package/docs/design-system/components/thinking-reasoning.md +72 -0
- package/docs/design-system/components/thinking-state.md +67 -0
- package/docs/design-system/components/timeline.md +83 -83
- package/docs/design-system/components/toast.md +58 -58
- package/docs/design-system/components/toggle.md +81 -81
- package/docs/design-system/components/toolbar.md +92 -87
- package/docs/design-system/components/tooltip.md +94 -92
- package/docs/design-system/components/typography.md +18 -18
- package/docs/design-system/density-and-elevation.md +65 -61
- package/docs/design-system/design-system-test-missing-items.md +368 -368
- package/docs/design-system/direction-and-localization.md +23 -23
- package/docs/design-system/form-recipes.md +73 -73
- package/docs/design-system/gap-promotion-policy.md +21 -21
- package/docs/design-system/icons.md +74 -69
- package/docs/design-system/installation.md +70 -68
- package/docs/design-system/launch-comparison-shadcn.md +98 -98
- package/docs/design-system/registry-and-cli.md +64 -64
- package/docs/design-system/release-policy.md +30 -30
- package/docs/design-system/roadmap.md +14 -14
- package/docs/design-system/support-matrix.md +23 -23
- package/docs/design-system/tabs.md +54 -53
- package/docs/design-system/template-gap-audit.md +32 -0
- package/docs/design-system/templates.md +59 -0
- package/docs/design-system/token-governance.md +72 -60
- package/package.json +98 -98
- package/registry/component-contract.json +40 -40
- package/registry/components/accordion.tsx +155 -155
- package/registry/components/agent-input-parts.tsx +552 -0
- package/registry/components/agent-input-state.ts +156 -0
- package/registry/components/agent-input.css +307 -0
- package/registry/components/agent-input.tsx +382 -0
- package/registry/components/alert-dialog.tsx +297 -297
- package/registry/components/alert.tsx +293 -293
- package/registry/components/approval-card.css +409 -0
- package/registry/components/approval-card.tsx +401 -0
- package/registry/components/approval-frame.tsx +108 -0
- package/registry/components/approval-questions.tsx +559 -0
- package/registry/components/aspect-ratio.tsx +30 -30
- package/registry/components/attribute.tsx +454 -448
- package/registry/components/autocomplete.tsx +598 -651
- package/registry/components/avatar.tsx +385 -381
- package/registry/components/badge.tsx +629 -629
- package/registry/components/button-group.tsx +565 -565
- package/registry/components/button.tsx +127 -123
- package/registry/components/card.tsx +638 -638
- package/registry/components/carousel.tsx +296 -296
- package/registry/components/chart-block-data.ts +177 -0
- package/registry/components/chart-block.css +171 -0
- package/registry/components/chart-block.tsx +260 -0
- package/registry/components/chart-interactions.ts +123 -0
- package/registry/components/chart-options.cartesian.ts +162 -0
- package/registry/components/chart-options.paint.ts +99 -0
- package/registry/components/chart-options.parts.ts +72 -0
- package/registry/components/chart-options.radial.ts +109 -0
- package/registry/components/chart-options.ts +44 -0
- package/registry/components/chart-options.types.ts +67 -0
- package/registry/components/chart.tsx +203 -203
- package/registry/components/checkbox.tsx +247 -247
- package/registry/components/collapsible.tsx +109 -69
- package/registry/components/command.tsx +208 -208
- package/registry/components/context-menu.tsx +236 -236
- package/registry/components/data-chart.tsx +40 -0
- package/registry/components/date-picker.tsx +1289 -1277
- package/registry/components/echart-theme.ts +246 -0
- package/registry/components/echart.css +49 -0
- package/registry/components/echart.tsx +178 -0
- package/registry/components/expanded/ActivityFeed.tsx +227 -227
- package/registry/components/expanded/ActivityHeatmap.tsx +64 -64
- package/registry/components/expanded/Banner.tsx +179 -179
- package/registry/components/expanded/Breadcrumbs.tsx +131 -131
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +205 -205
- package/registry/components/expanded/CatalogDivider.tsx +49 -49
- package/registry/components/expanded/EmptyState.tsx +155 -155
- package/registry/components/expanded/FileUpload.tsx +543 -543
- package/registry/components/expanded/OnboardingStepListItem.tsx +60 -59
- package/registry/components/expanded/PageHeader.tsx +179 -166
- package/registry/components/expanded/Slideout.tsx +108 -108
- package/registry/components/expanded/Steps.tsx +402 -402
- package/registry/components/expanded/Table.tsx +1092 -1071
- package/registry/components/expanded/Timeline.tsx +203 -203
- package/registry/components/expanded/activityFeed.css +248 -248
- package/registry/components/expanded/activityHeatmap.css +66 -66
- package/registry/components/expanded/banner.css +260 -255
- package/registry/components/expanded/breadcrumbs.css +140 -140
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -87
- package/registry/components/expanded/divider.css +75 -75
- package/registry/components/expanded/emptyState.css +111 -111
- package/registry/components/expanded/fileUpload.css +457 -457
- package/registry/components/expanded/onboardingStepListItem.css +135 -126
- package/registry/components/expanded/pageHeader.css +248 -290
- package/registry/components/expanded/slideout.css +276 -276
- package/registry/components/expanded/steps.css +356 -356
- package/registry/components/expanded/table.css +606 -603
- package/registry/components/expanded/timeline.css +286 -286
- package/registry/components/field.tsx +283 -283
- package/registry/components/hover-card.tsx +48 -48
- package/registry/components/inline-citations.css +126 -0
- package/registry/components/inline-citations.tsx +292 -0
- package/registry/components/input-content.ts +107 -107
- package/registry/components/input-group.tsx +130 -130
- package/registry/components/input-otp.tsx +584 -584
- package/registry/components/input.tsx +990 -972
- package/registry/components/item.tsx +189 -189
- package/registry/components/kbd.tsx +246 -151
- package/registry/components/label.tsx +78 -78
- package/registry/components/menu.tsx +978 -986
- package/registry/components/menubar.tsx +226 -226
- package/registry/components/modal.tsx +872 -872
- package/registry/components/native-select.tsx +205 -205
- package/registry/components/navigation-menu.tsx +171 -171
- package/registry/components/pagination.css +36 -36
- package/registry/components/pagination.tsx +560 -555
- package/registry/components/popover.tsx +338 -338
- package/registry/components/progress-slider.tsx +216 -216
- package/registry/components/radio-card.tsx +676 -677
- package/registry/components/radio-group.tsx +570 -570
- package/registry/components/resizable.tsx +108 -108
- package/registry/components/rolling-count.css +37 -0
- package/registry/components/rolling-count.tsx +110 -0
- package/registry/components/scroll-area.tsx +91 -91
- package/registry/components/segmented-control.tsx +87 -87
- package/registry/components/select-content.tsx +218 -218
- package/registry/components/select.tsx +937 -932
- package/registry/components/sheet.tsx +305 -305
- package/registry/components/shimmer-text.css +69 -0
- package/registry/components/shimmer-text.tsx +43 -0
- package/registry/components/sidebar.tsx +1433 -358
- package/registry/components/skeleton.css +54 -54
- package/registry/components/skeleton.tsx +482 -482
- package/registry/components/slider.tsx +380 -380
- package/registry/components/social-button.tsx +387 -387
- package/registry/components/spinner.tsx +78 -78
- package/registry/components/streaming-text.css +45 -0
- package/registry/components/streaming-text.tsx +165 -0
- package/registry/components/table-elements.tsx +128 -128
- package/registry/components/tabs.css +222 -218
- package/registry/components/tabs.tsx +241 -241
- package/registry/components/tag.tsx +423 -423
- package/registry/components/task-list.css +328 -0
- package/registry/components/task-list.tsx +429 -0
- package/registry/components/textarea.tsx +610 -610
- package/registry/components/thinking-reasoning.css +178 -0
- package/registry/components/thinking-reasoning.tsx +253 -0
- package/registry/components/thinking-state.css +8 -0
- package/registry/components/thinking-state.tsx +46 -0
- package/registry/components/toast.tsx +136 -136
- package/registry/components/toggle.tsx +256 -256
- package/registry/components/toolbar.tsx +539 -539
- package/registry/components/tooltip.tsx +433 -431
- package/registry/examples/agent-input-demo.tsx +90 -0
- package/registry/examples/alert-demo.tsx +34 -34
- package/registry/examples/alert-dialog-demo.tsx +42 -42
- package/registry/examples/approval-card-demo.tsx +83 -0
- package/registry/examples/aspect-ratio-demo.tsx +11 -11
- package/registry/examples/attribute-demo.tsx +65 -65
- package/registry/examples/autocomplete-demo.tsx +109 -109
- package/registry/examples/avatar-demo.tsx +132 -132
- package/registry/examples/badge-demo.tsx +69 -69
- package/registry/examples/button-demo.tsx +86 -83
- package/registry/examples/button-group-demo.tsx +63 -63
- package/registry/examples/card-demo.tsx +86 -86
- package/registry/examples/carousel-demo.tsx +43 -43
- package/registry/examples/chart-block-demo.tsx +5 -0
- package/registry/examples/chart-demo.tsx +18 -33
- package/registry/examples/checkbox-demo.tsx +62 -62
- package/registry/examples/collapsible-demo.tsx +16 -16
- package/registry/examples/collection-filter-bar-demo.tsx +135 -135
- package/registry/examples/command-demo.tsx +42 -42
- package/registry/examples/command-palette-demo.tsx +235 -236
- package/registry/examples/context-menu-demo.tsx +29 -29
- package/registry/examples/control-density-contract-demo.tsx +65 -61
- package/registry/examples/date-picker-demo.tsx +127 -127
- package/registry/examples/divider-demo.tsx +17 -17
- package/registry/examples/expanded/activity-heatmap-demo.tsx +29 -29
- package/registry/examples/expanded/banner-demo.tsx +48 -48
- package/registry/examples/expanded/breadcrumbs-demo.tsx +59 -59
- package/registry/examples/expanded/empty-state-demo.tsx +39 -39
- package/registry/examples/expanded/file-upload-demo.tsx +60 -60
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -11
- package/registry/examples/expanded/slideout-demo.tsx +15 -15
- package/registry/examples/expanded/steps-demo.tsx +29 -29
- package/registry/examples/expanded/tabs-demo.tsx +13 -13
- package/registry/examples/expanded/timeline-demo.tsx +18 -18
- package/registry/examples/field-demo.tsx +51 -51
- package/registry/examples/hover-card-demo.tsx +23 -23
- package/registry/examples/inline-citations-demo.tsx +31 -0
- package/registry/examples/input-actions-demo.tsx +36 -0
- package/registry/examples/input-demo.tsx +87 -87
- package/registry/examples/input-group-demo.tsx +16 -16
- package/registry/examples/input-otp-demo.tsx +72 -72
- package/registry/examples/item-demo.tsx +46 -46
- package/registry/examples/kbd-demo.tsx +12 -11
- package/registry/examples/label-demo.tsx +20 -20
- package/registry/examples/menu-demo.tsx +122 -122
- package/registry/examples/menubar-demo.tsx +34 -34
- package/registry/examples/modal-demo.tsx +74 -74
- package/registry/examples/native-select-demo.tsx +16 -16
- package/registry/examples/navigation-menu-demo.tsx +29 -29
- package/registry/examples/pagination-demo.tsx +20 -20
- package/registry/examples/popover-demo.tsx +547 -546
- package/registry/examples/progress-demo.tsx +37 -37
- package/registry/examples/progress-slider-demo.tsx +29 -29
- package/registry/examples/radio-card-demo.tsx +51 -51
- package/registry/examples/radio-group-demo.tsx +62 -62
- package/registry/examples/resizable-demo.tsx +22 -22
- package/registry/examples/results-toolbar-demo.tsx +44 -44
- package/registry/examples/rolling-count-demo.tsx +39 -0
- package/registry/examples/scroll-area-demo.tsx +15 -15
- package/registry/examples/segmented-control-demo.tsx +39 -39
- package/registry/examples/select-demo.tsx +87 -87
- package/registry/examples/sheet-demo.tsx +47 -47
- package/registry/examples/shimmer-text-demo.tsx +20 -0
- package/registry/examples/sidebar-demo.tsx +101 -57
- package/registry/examples/slider-demo.tsx +31 -31
- package/registry/examples/social-button-demo.tsx +61 -61
- package/registry/examples/spinner-demo.tsx +59 -59
- package/registry/examples/streaming-text-demo.tsx +28 -0
- package/registry/examples/tabs-demo.tsx +13 -13
- package/registry/examples/tag-demo.tsx +29 -29
- package/registry/examples/task-list-demo.tsx +74 -0
- package/registry/examples/textarea-demo.tsx +79 -79
- package/registry/examples/thinking-reasoning-demo.tsx +74 -0
- package/registry/examples/thinking-state-demo.tsx +13 -0
- package/registry/examples/toast-demo.tsx +35 -35
- package/registry/examples/toggle-demo.tsx +59 -59
- package/registry/examples/tooltip-demo.tsx +115 -115
- package/registry/guidance/USAGE.md +27 -27
- package/registry/guidance/charts.LICENSE.txt +24 -0
- package/registry/hooks/use-controllable-state.ts +33 -0
- package/registry/hooks/use-direction.ts +207 -207
- package/registry/hooks/use-listbox-navigation.ts +73 -0
- package/registry/hooks/use-motion-end.ts +55 -0
- package/registry/hooks/use-reduced-motion.ts +28 -0
- package/registry/index.json +1634 -184
- package/registry/styles/globals.css +1462 -1570
- package/registry.json +364 -10
- package/schema/config.schema.json +51 -51
- package/schema/registry.schema.json +194 -190
- package/schema/tokens.schema.json +167 -163
- package/src/cli/command-line.js +194 -194
- package/src/cli/config-editors.js +9 -9
- package/src/cli/doctor.js +399 -399
- package/src/cli/file-transaction.js +302 -295
- package/src/cli/global-css.js +153 -153
- package/src/cli/index.js +1002 -1009
- package/src/cli/install-plan.js +592 -592
- package/src/cli/install-receipt.js +171 -171
- package/src/cli/jsonc.js +203 -203
- package/src/cli/package-install-state.js +254 -254
- package/src/cli/package-manager.js +238 -238
- package/src/cli/package-plan.js +185 -185
- package/src/cli/package-version.js +97 -97
- package/src/cli/registry-query.js +207 -207
- package/src/cli/reporting.js +55 -55
- package/src/cli/schema-validation.js +19 -19
- package/src/cli/source-scanner.js +686 -686
- package/src/cli/vite-config.js +478 -478
- package/tokens/banhaten.tokens.json +458 -224
|
@@ -1,431 +1,433 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
|
3
|
-
import { XIcon } from "lucide-react"
|
|
4
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
-
|
|
6
|
-
import { cn } from "@/lib/utils"
|
|
7
|
-
|
|
8
|
-
type TooltipVariant = "dark" | "default"
|
|
9
|
-
type TooltipSize = "sm" | "lg"
|
|
10
|
-
type TooltipPointerPosition =
|
|
11
|
-
| "top-left"
|
|
12
|
-
| "top-center"
|
|
13
|
-
| "top-right"
|
|
14
|
-
| "bottom-left"
|
|
15
|
-
| "bottom-center"
|
|
16
|
-
| "bottom-right"
|
|
17
|
-
| "center-right"
|
|
18
|
-
| "center-left"
|
|
19
|
-
| "none"
|
|
20
|
-
|
|
21
|
-
const defaultTooltipLabel = "More information"
|
|
22
|
-
const defaultTooltipSupportText =
|
|
23
|
-
"You may notice that we've made some updates to our look and feel."
|
|
24
|
-
// Radix sideOffset requires numbers; these mirror the tooltip spacing aliases.
|
|
25
|
-
const TOOLTIP_POINTER_SIDE_OFFSET_PX = 7
|
|
26
|
-
const TOOLTIP_POINTERLESS_SIDE_OFFSET_PX = 6
|
|
27
|
-
// Radix collisionPadding requires a number; this mirrors --bh-space-md-8.
|
|
28
|
-
const TOOLTIP_COLLISION_PADDING_PX = 8
|
|
29
|
-
|
|
30
|
-
const tooltipContentVariants = cva(
|
|
31
|
-
[
|
|
32
|
-
"z-[var(--bh-z-overlay)] overflow-visible bg-[var(--bh-tooltip-bg)] text-[var(--bh-tooltip-fg)] shadow-[var(--bh-tooltip-
|
|
33
|
-
"font-[var(--bh-font-family)] tracking-[var(--bh-text-base-letter-spacing)]",
|
|
34
|
-
],
|
|
35
|
-
{
|
|
36
|
-
variants: {
|
|
37
|
-
variant: {
|
|
38
|
-
dark:
|
|
39
|
-
"[--bh-tooltip-bg:var(--bh-bg-always-dark)] [--bh-tooltip-border:transparent] [--bh-tooltip-close-fg:var(--bh-content-on-color)] [--bh-tooltip-fg:var(--bh-content-on-color)] [--bh-tooltip-
|
|
40
|
-
default:
|
|
41
|
-
"[--bh-tooltip-bg:var(--bh-bg-raised)] [--bh-tooltip-border:var(--bh-border-subtle)] [--bh-tooltip-close-fg:var(--bh-content-subtle)] [--bh-tooltip-fg:var(--bh-content-default)] [--bh-tooltip-
|
|
42
|
-
},
|
|
43
|
-
size: {
|
|
44
|
-
sm:
|
|
45
|
-
"inline-flex max-w-[var(--bh-tooltip-max-width)] items-center gap-[var(--bh-space-xs-4)] rounded-[var(--bh-tooltip-sm-radius)] px-[var(--bh-tooltip-sm-padding-x)] py-[var(--bh-tooltip-sm-padding-y)]",
|
|
46
|
-
lg:
|
|
47
|
-
"flex w-[var(--bh-tooltip-lg-width)] max-w-[var(--bh-tooltip-max-width)] items-start gap-[var(--bh-space-md-8)] rounded-[var(--bh-tooltip-lg-radius)] p-[var(--bh-tooltip-lg-padding)]",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
defaultVariants: {
|
|
51
|
-
variant: "dark",
|
|
52
|
-
size: "sm",
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
type TooltipContentProps = Omit<
|
|
58
|
-
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>,
|
|
59
|
-
"asChild"
|
|
60
|
-
> &
|
|
61
|
-
VariantProps<typeof tooltipContentVariants> & {
|
|
62
|
-
closeLabel?: string
|
|
63
|
-
onCloseClick?: React.MouseEventHandler<HTMLButtonElement>
|
|
64
|
-
pointerPosition?: TooltipPointerPosition
|
|
65
|
-
shortcut?: React.ReactNode
|
|
66
|
-
showCloseButton?: boolean
|
|
67
|
-
showPointer?: boolean
|
|
68
|
-
showShortcut?: boolean
|
|
69
|
-
supportText?: React.ReactNode
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type TooltipShortcutProps = React.ComponentProps<"span">
|
|
73
|
-
type TooltipCloseButtonProps = React.ComponentProps<"button"> & {
|
|
74
|
-
label?: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const TooltipProvider = TooltipPrimitive.Provider
|
|
78
|
-
const Tooltip = TooltipPrimitive.Root
|
|
79
|
-
const TooltipRoot = TooltipPrimitive.Root
|
|
80
|
-
const TooltipTrigger = TooltipPrimitive.Trigger
|
|
81
|
-
const TooltipPortal = TooltipPrimitive.Portal
|
|
82
|
-
|
|
83
|
-
const TooltipContent = React.forwardRef<
|
|
84
|
-
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
85
|
-
TooltipContentProps
|
|
86
|
-
>(function TooltipContent(
|
|
87
|
-
{
|
|
88
|
-
align,
|
|
89
|
-
children,
|
|
90
|
-
className,
|
|
91
|
-
closeLabel,
|
|
92
|
-
collisionPadding = TOOLTIP_COLLISION_PADDING_PX,
|
|
93
|
-
onCloseClick,
|
|
94
|
-
pointerPosition = "top-left",
|
|
95
|
-
shortcut,
|
|
96
|
-
showCloseButton,
|
|
97
|
-
showPointer = true,
|
|
98
|
-
showShortcut,
|
|
99
|
-
side,
|
|
100
|
-
sideOffset,
|
|
101
|
-
size = "sm",
|
|
102
|
-
supportText,
|
|
103
|
-
variant = "dark",
|
|
104
|
-
...props
|
|
105
|
-
},
|
|
106
|
-
ref
|
|
107
|
-
) {
|
|
108
|
-
const resolvedPointerPosition = pointerPosition ?? "top-left"
|
|
109
|
-
const resolvedSize = (size ?? "sm") as TooltipSize
|
|
110
|
-
const resolvedVariant = (variant ?? "dark") as TooltipVariant
|
|
111
|
-
const placement = getTooltipPlacement(resolvedPointerPosition)
|
|
112
|
-
const label = children ?? defaultTooltipLabel
|
|
113
|
-
const renderedSupportText =
|
|
114
|
-
supportText ??
|
|
115
|
-
(children === undefined && resolvedSize === "lg"
|
|
116
|
-
? defaultTooltipSupportText
|
|
117
|
-
: undefined)
|
|
118
|
-
const shouldShowCloseButton = showCloseButton ?? resolvedSize === "lg"
|
|
119
|
-
const shouldShowShortcut = showShortcut ?? resolvedSize === "sm"
|
|
120
|
-
const shouldShowPointer =
|
|
121
|
-
showPointer && resolvedPointerPosition !== "none"
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<TooltipPrimitive.Portal>
|
|
125
|
-
<TooltipPrimitive.Content
|
|
126
|
-
data-pointer-position={resolvedPointerPosition}
|
|
127
|
-
data-size={resolvedSize}
|
|
128
|
-
data-slot="tooltip-content"
|
|
129
|
-
data-variant={resolvedVariant}
|
|
130
|
-
ref={ref}
|
|
131
|
-
side={side ?? placement.side}
|
|
132
|
-
align={align ?? placement.align}
|
|
133
|
-
collisionPadding={collisionPadding}
|
|
134
|
-
sideOffset={
|
|
135
|
-
sideOffset ??
|
|
136
|
-
(shouldShowPointer
|
|
137
|
-
? TOOLTIP_POINTER_SIDE_OFFSET_PX
|
|
138
|
-
: TOOLTIP_POINTERLESS_SIDE_OFFSET_PX)
|
|
139
|
-
}
|
|
140
|
-
className={cn(
|
|
141
|
-
tooltipContentVariants({
|
|
142
|
-
variant: resolvedVariant,
|
|
143
|
-
size: resolvedSize,
|
|
144
|
-
}),
|
|
145
|
-
className
|
|
146
|
-
)}
|
|
147
|
-
{...props}
|
|
148
|
-
>
|
|
149
|
-
{resolvedSize === "lg" ? (
|
|
150
|
-
<TooltipLargeContent
|
|
151
|
-
closeLabel={closeLabel}
|
|
152
|
-
onCloseClick={onCloseClick}
|
|
153
|
-
showCloseButton={shouldShowCloseButton}
|
|
154
|
-
supportText={renderedSupportText}
|
|
155
|
-
>
|
|
156
|
-
{label}
|
|
157
|
-
</TooltipLargeContent>
|
|
158
|
-
) : (
|
|
159
|
-
<TooltipSmallContent
|
|
160
|
-
shortcut={shortcut}
|
|
161
|
-
showShortcut={shouldShowShortcut}
|
|
162
|
-
>
|
|
163
|
-
{label}
|
|
164
|
-
</TooltipSmallContent>
|
|
165
|
-
)}
|
|
166
|
-
|
|
167
|
-
{shouldShowPointer ? (
|
|
168
|
-
<TooltipPointer
|
|
169
|
-
pointerPosition={resolvedPointerPosition}
|
|
170
|
-
variant={resolvedVariant}
|
|
171
|
-
/>
|
|
172
|
-
) : null}
|
|
173
|
-
</TooltipPrimitive.Content>
|
|
174
|
-
</TooltipPrimitive.Portal>
|
|
175
|
-
)
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
function TooltipSmallContent({
|
|
179
|
-
children,
|
|
180
|
-
shortcut,
|
|
181
|
-
showShortcut,
|
|
182
|
-
}: {
|
|
183
|
-
children: React.ReactNode
|
|
184
|
-
shortcut?: React.ReactNode
|
|
185
|
-
showShortcut: boolean
|
|
186
|
-
}) {
|
|
187
|
-
return (
|
|
188
|
-
<>
|
|
189
|
-
<span
|
|
190
|
-
data-slot="tooltip-label"
|
|
191
|
-
dir="auto"
|
|
192
|
-
className="min-w-0 whitespace-nowrap text-start text-[length:var(--bh-text-body-2xs-medium-font-size)] font-[var(--bh-text-body-2xs-medium-font-weight)] leading-[var(--bh-text-body-2xs-medium-line-height)] tracking-[var(--bh-text-body-2xs-medium-letter-spacing)]"
|
|
193
|
-
>
|
|
194
|
-
{children}
|
|
195
|
-
</span>
|
|
196
|
-
{showShortcut ? <TooltipShortcut>{shortcut ?? "/"}</TooltipShortcut> : null}
|
|
197
|
-
</>
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function TooltipLargeContent({
|
|
202
|
-
children,
|
|
203
|
-
closeLabel,
|
|
204
|
-
onCloseClick,
|
|
205
|
-
showCloseButton,
|
|
206
|
-
supportText,
|
|
207
|
-
}: {
|
|
208
|
-
children: React.ReactNode
|
|
209
|
-
closeLabel?: string
|
|
210
|
-
onCloseClick?: React.MouseEventHandler<HTMLButtonElement>
|
|
211
|
-
showCloseButton: boolean
|
|
212
|
-
supportText?: React.ReactNode
|
|
213
|
-
}) {
|
|
214
|
-
return (
|
|
215
|
-
<>
|
|
216
|
-
<span
|
|
217
|
-
data-slot="tooltip-text"
|
|
218
|
-
className="flex min-w-0 flex-1 flex-col items-start gap-[var(--bh-space-xs-4)] text-start rtl:items-end rtl:text-right"
|
|
219
|
-
>
|
|
220
|
-
<span
|
|
221
|
-
data-slot="tooltip-label"
|
|
222
|
-
dir="auto"
|
|
223
|
-
className="w-full min-w-0 text-[length:var(--bh-text-body-sm-medium-font-size)] font-[var(--bh-text-body-sm-medium-font-weight)] leading-[var(--bh-text-body-sm-medium-line-height)] tracking-[var(--bh-text-body-sm-medium-letter-spacing)]"
|
|
224
|
-
>
|
|
225
|
-
{children}
|
|
226
|
-
</span>
|
|
227
|
-
{hasRenderableContent(supportText) ? (
|
|
228
|
-
<span
|
|
229
|
-
data-slot="tooltip-support-text"
|
|
230
|
-
dir="auto"
|
|
231
|
-
className="w-full min-w-0 text-[length:var(--bh-text-body-2xs-regular-font-size)] font-[var(--bh-text-body-2xs-regular-font-weight)] leading-[var(--bh-text-body-2xs-regular-line-height)] tracking-[var(--bh-text-body-2xs-regular-letter-spacing)]"
|
|
232
|
-
>
|
|
233
|
-
{supportText}
|
|
234
|
-
</span>
|
|
235
|
-
) : null}
|
|
236
|
-
</span>
|
|
237
|
-
{showCloseButton ? (
|
|
238
|
-
<TooltipCloseButton label={closeLabel} onClick={onCloseClick} />
|
|
239
|
-
) : null}
|
|
240
|
-
</>
|
|
241
|
-
)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function TooltipShortcut({
|
|
245
|
-
children = "/",
|
|
246
|
-
className,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (pointerPosition
|
|
358
|
-
if (pointerPosition
|
|
359
|
-
|
|
360
|
-
return
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
content !==
|
|
368
|
-
content !==
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
"top-
|
|
376
|
-
"top-[var(--bh-tooltip-pointer-offset)]
|
|
377
|
-
"top-
|
|
378
|
-
"top-[var(--bh-tooltip-pointer-offset)] h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)]
|
|
379
|
-
"
|
|
380
|
-
"
|
|
381
|
-
"bottom-
|
|
382
|
-
"bottom-[var(--bh-tooltip-pointer-offset)]
|
|
383
|
-
"bottom-
|
|
384
|
-
"bottom-[var(--bh-tooltip-pointer-offset)] h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)]
|
|
385
|
-
"
|
|
386
|
-
"
|
|
387
|
-
"center-
|
|
388
|
-
"
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
"
|
|
396
|
-
|
|
397
|
-
"
|
|
398
|
-
|
|
399
|
-
"
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
"
|
|
407
|
-
|
|
408
|
-
"
|
|
409
|
-
|
|
410
|
-
"top-[var(--bh-tooltip-pointer-border-offset)]
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
|
3
|
+
import { XIcon } from "lucide-react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
type TooltipVariant = "dark" | "default"
|
|
9
|
+
type TooltipSize = "sm" | "lg"
|
|
10
|
+
type TooltipPointerPosition =
|
|
11
|
+
| "top-left"
|
|
12
|
+
| "top-center"
|
|
13
|
+
| "top-right"
|
|
14
|
+
| "bottom-left"
|
|
15
|
+
| "bottom-center"
|
|
16
|
+
| "bottom-right"
|
|
17
|
+
| "center-right"
|
|
18
|
+
| "center-left"
|
|
19
|
+
| "none"
|
|
20
|
+
|
|
21
|
+
const defaultTooltipLabel = "More information"
|
|
22
|
+
const defaultTooltipSupportText =
|
|
23
|
+
"You may notice that we've made some updates to our look and feel."
|
|
24
|
+
// Radix sideOffset requires numbers; these mirror the tooltip spacing aliases.
|
|
25
|
+
const TOOLTIP_POINTER_SIDE_OFFSET_PX = 7
|
|
26
|
+
const TOOLTIP_POINTERLESS_SIDE_OFFSET_PX = 6
|
|
27
|
+
// Radix collisionPadding requires a number; this mirrors --bh-space-md-8.
|
|
28
|
+
const TOOLTIP_COLLISION_PADDING_PX = 8
|
|
29
|
+
|
|
30
|
+
const tooltipContentVariants = cva(
|
|
31
|
+
[
|
|
32
|
+
"z-[var(--bh-z-overlay)] overflow-visible bg-[var(--bh-tooltip-bg)] text-[var(--bh-tooltip-fg)] shadow-[var(--bh-tooltip-elevation)] outline-none",
|
|
33
|
+
"font-[var(--bh-font-family)] tracking-[var(--bh-text-base-letter-spacing)]",
|
|
34
|
+
],
|
|
35
|
+
{
|
|
36
|
+
variants: {
|
|
37
|
+
variant: {
|
|
38
|
+
dark:
|
|
39
|
+
"[--bh-tooltip-bg:var(--bh-bg-always-dark)] [--bh-tooltip-border:transparent] [--bh-tooltip-close-fg:var(--bh-content-on-color)] [--bh-tooltip-fg:var(--bh-content-on-color)] [--bh-tooltip-elevation:none] [--bh-tooltip-shortcut-bg:var(--bh-bg-neutral-soft)] [--bh-tooltip-shortcut-border:var(--bh-border-inverse-subtle)]",
|
|
40
|
+
default:
|
|
41
|
+
"[--bh-tooltip-bg:var(--bh-bg-raised)] [--bh-tooltip-border:var(--bh-border-subtle)] [--bh-tooltip-close-fg:var(--bh-content-subtle)] [--bh-tooltip-fg:var(--bh-content-default)] [--bh-tooltip-elevation:inset_0px_0px_0px_var(--bh-border-width-default)_var(--bh-tooltip-border),var(--elevation-04)] [--bh-tooltip-shortcut-bg:var(--bh-bg-neutral-subtle)] [--bh-tooltip-shortcut-border:var(--bh-border-subtle)]",
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
sm:
|
|
45
|
+
"inline-flex max-w-[var(--bh-tooltip-max-width)] items-center gap-[var(--bh-space-xs-4)] rounded-[var(--bh-tooltip-sm-radius)] px-[var(--bh-tooltip-sm-padding-x)] py-[var(--bh-tooltip-sm-padding-y)]",
|
|
46
|
+
lg:
|
|
47
|
+
"flex w-[var(--bh-tooltip-lg-width)] max-w-[var(--bh-tooltip-max-width)] items-start gap-[var(--bh-space-md-8)] rounded-[var(--bh-tooltip-lg-radius)] p-[var(--bh-tooltip-lg-padding)]",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
variant: "dark",
|
|
52
|
+
size: "sm",
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
type TooltipContentProps = Omit<
|
|
58
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>,
|
|
59
|
+
"asChild"
|
|
60
|
+
> &
|
|
61
|
+
VariantProps<typeof tooltipContentVariants> & {
|
|
62
|
+
closeLabel?: string
|
|
63
|
+
onCloseClick?: React.MouseEventHandler<HTMLButtonElement>
|
|
64
|
+
pointerPosition?: TooltipPointerPosition
|
|
65
|
+
shortcut?: React.ReactNode
|
|
66
|
+
showCloseButton?: boolean
|
|
67
|
+
showPointer?: boolean
|
|
68
|
+
showShortcut?: boolean
|
|
69
|
+
supportText?: React.ReactNode
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type TooltipShortcutProps = React.ComponentProps<"span">
|
|
73
|
+
type TooltipCloseButtonProps = React.ComponentProps<"button"> & {
|
|
74
|
+
label?: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const TooltipProvider = TooltipPrimitive.Provider
|
|
78
|
+
const Tooltip = TooltipPrimitive.Root
|
|
79
|
+
const TooltipRoot = TooltipPrimitive.Root
|
|
80
|
+
const TooltipTrigger = TooltipPrimitive.Trigger
|
|
81
|
+
const TooltipPortal = TooltipPrimitive.Portal
|
|
82
|
+
|
|
83
|
+
const TooltipContent = React.forwardRef<
|
|
84
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
85
|
+
TooltipContentProps
|
|
86
|
+
>(function TooltipContent(
|
|
87
|
+
{
|
|
88
|
+
align,
|
|
89
|
+
children,
|
|
90
|
+
className,
|
|
91
|
+
closeLabel,
|
|
92
|
+
collisionPadding = TOOLTIP_COLLISION_PADDING_PX,
|
|
93
|
+
onCloseClick,
|
|
94
|
+
pointerPosition = "top-left",
|
|
95
|
+
shortcut,
|
|
96
|
+
showCloseButton,
|
|
97
|
+
showPointer = true,
|
|
98
|
+
showShortcut,
|
|
99
|
+
side,
|
|
100
|
+
sideOffset,
|
|
101
|
+
size = "sm",
|
|
102
|
+
supportText,
|
|
103
|
+
variant = "dark",
|
|
104
|
+
...props
|
|
105
|
+
},
|
|
106
|
+
ref
|
|
107
|
+
) {
|
|
108
|
+
const resolvedPointerPosition = pointerPosition ?? "top-left"
|
|
109
|
+
const resolvedSize = (size ?? "sm") as TooltipSize
|
|
110
|
+
const resolvedVariant = (variant ?? "dark") as TooltipVariant
|
|
111
|
+
const placement = getTooltipPlacement(resolvedPointerPosition)
|
|
112
|
+
const label = children ?? defaultTooltipLabel
|
|
113
|
+
const renderedSupportText =
|
|
114
|
+
supportText ??
|
|
115
|
+
(children === undefined && resolvedSize === "lg"
|
|
116
|
+
? defaultTooltipSupportText
|
|
117
|
+
: undefined)
|
|
118
|
+
const shouldShowCloseButton = showCloseButton ?? resolvedSize === "lg"
|
|
119
|
+
const shouldShowShortcut = showShortcut ?? resolvedSize === "sm"
|
|
120
|
+
const shouldShowPointer =
|
|
121
|
+
showPointer && resolvedPointerPosition !== "none"
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<TooltipPrimitive.Portal>
|
|
125
|
+
<TooltipPrimitive.Content
|
|
126
|
+
data-pointer-position={resolvedPointerPosition}
|
|
127
|
+
data-size={resolvedSize}
|
|
128
|
+
data-slot="tooltip-content"
|
|
129
|
+
data-variant={resolvedVariant}
|
|
130
|
+
ref={ref}
|
|
131
|
+
side={side ?? placement.side}
|
|
132
|
+
align={align ?? placement.align}
|
|
133
|
+
collisionPadding={collisionPadding}
|
|
134
|
+
sideOffset={
|
|
135
|
+
sideOffset ??
|
|
136
|
+
(shouldShowPointer
|
|
137
|
+
? TOOLTIP_POINTER_SIDE_OFFSET_PX
|
|
138
|
+
: TOOLTIP_POINTERLESS_SIDE_OFFSET_PX)
|
|
139
|
+
}
|
|
140
|
+
className={cn(
|
|
141
|
+
tooltipContentVariants({
|
|
142
|
+
variant: resolvedVariant,
|
|
143
|
+
size: resolvedSize,
|
|
144
|
+
}),
|
|
145
|
+
className
|
|
146
|
+
)}
|
|
147
|
+
{...props}
|
|
148
|
+
>
|
|
149
|
+
{resolvedSize === "lg" ? (
|
|
150
|
+
<TooltipLargeContent
|
|
151
|
+
closeLabel={closeLabel}
|
|
152
|
+
onCloseClick={onCloseClick}
|
|
153
|
+
showCloseButton={shouldShowCloseButton}
|
|
154
|
+
supportText={renderedSupportText}
|
|
155
|
+
>
|
|
156
|
+
{label}
|
|
157
|
+
</TooltipLargeContent>
|
|
158
|
+
) : (
|
|
159
|
+
<TooltipSmallContent
|
|
160
|
+
shortcut={shortcut}
|
|
161
|
+
showShortcut={shouldShowShortcut}
|
|
162
|
+
>
|
|
163
|
+
{label}
|
|
164
|
+
</TooltipSmallContent>
|
|
165
|
+
)}
|
|
166
|
+
|
|
167
|
+
{shouldShowPointer ? (
|
|
168
|
+
<TooltipPointer
|
|
169
|
+
pointerPosition={resolvedPointerPosition}
|
|
170
|
+
variant={resolvedVariant}
|
|
171
|
+
/>
|
|
172
|
+
) : null}
|
|
173
|
+
</TooltipPrimitive.Content>
|
|
174
|
+
</TooltipPrimitive.Portal>
|
|
175
|
+
)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
function TooltipSmallContent({
|
|
179
|
+
children,
|
|
180
|
+
shortcut,
|
|
181
|
+
showShortcut,
|
|
182
|
+
}: {
|
|
183
|
+
children: React.ReactNode
|
|
184
|
+
shortcut?: React.ReactNode
|
|
185
|
+
showShortcut: boolean
|
|
186
|
+
}) {
|
|
187
|
+
return (
|
|
188
|
+
<>
|
|
189
|
+
<span
|
|
190
|
+
data-slot="tooltip-label"
|
|
191
|
+
dir="auto"
|
|
192
|
+
className="min-w-0 whitespace-nowrap text-start text-[length:var(--bh-text-body-2xs-medium-font-size)] font-[var(--bh-text-body-2xs-medium-font-weight)] leading-[var(--bh-text-body-2xs-medium-line-height)] tracking-[var(--bh-text-body-2xs-medium-letter-spacing)]"
|
|
193
|
+
>
|
|
194
|
+
{children}
|
|
195
|
+
</span>
|
|
196
|
+
{showShortcut ? <TooltipShortcut>{shortcut ?? "/"}</TooltipShortcut> : null}
|
|
197
|
+
</>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function TooltipLargeContent({
|
|
202
|
+
children,
|
|
203
|
+
closeLabel,
|
|
204
|
+
onCloseClick,
|
|
205
|
+
showCloseButton,
|
|
206
|
+
supportText,
|
|
207
|
+
}: {
|
|
208
|
+
children: React.ReactNode
|
|
209
|
+
closeLabel?: string
|
|
210
|
+
onCloseClick?: React.MouseEventHandler<HTMLButtonElement>
|
|
211
|
+
showCloseButton: boolean
|
|
212
|
+
supportText?: React.ReactNode
|
|
213
|
+
}) {
|
|
214
|
+
return (
|
|
215
|
+
<>
|
|
216
|
+
<span
|
|
217
|
+
data-slot="tooltip-text"
|
|
218
|
+
className="flex min-w-0 flex-1 flex-col items-start gap-[var(--bh-space-xs-4)] text-start rtl:items-end rtl:text-right"
|
|
219
|
+
>
|
|
220
|
+
<span
|
|
221
|
+
data-slot="tooltip-label"
|
|
222
|
+
dir="auto"
|
|
223
|
+
className="w-full min-w-0 text-[length:var(--bh-text-body-sm-medium-font-size)] font-[var(--bh-text-body-sm-medium-font-weight)] leading-[var(--bh-text-body-sm-medium-line-height)] tracking-[var(--bh-text-body-sm-medium-letter-spacing)]"
|
|
224
|
+
>
|
|
225
|
+
{children}
|
|
226
|
+
</span>
|
|
227
|
+
{hasRenderableContent(supportText) ? (
|
|
228
|
+
<span
|
|
229
|
+
data-slot="tooltip-support-text"
|
|
230
|
+
dir="auto"
|
|
231
|
+
className="w-full min-w-0 text-[length:var(--bh-text-body-2xs-regular-font-size)] font-[var(--bh-text-body-2xs-regular-font-weight)] leading-[var(--bh-text-body-2xs-regular-line-height)] tracking-[var(--bh-text-body-2xs-regular-letter-spacing)]"
|
|
232
|
+
>
|
|
233
|
+
{supportText}
|
|
234
|
+
</span>
|
|
235
|
+
) : null}
|
|
236
|
+
</span>
|
|
237
|
+
{showCloseButton ? (
|
|
238
|
+
<TooltipCloseButton label={closeLabel} onClick={onCloseClick} />
|
|
239
|
+
) : null}
|
|
240
|
+
</>
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function TooltipShortcut({
|
|
245
|
+
children = "/",
|
|
246
|
+
className,
|
|
247
|
+
dir = "ltr",
|
|
248
|
+
...props
|
|
249
|
+
}: TooltipShortcutProps) {
|
|
250
|
+
return (
|
|
251
|
+
<span
|
|
252
|
+
data-slot="tooltip-shortcut"
|
|
253
|
+
dir={dir}
|
|
254
|
+
className={cn(
|
|
255
|
+
"flex h-[var(--bh-tooltip-shortcut-height)] min-w-[var(--bh-tooltip-shortcut-min-width)] shrink-0 items-center justify-center rounded-[var(--bh-radius-sm-4)] border border-[var(--bh-tooltip-shortcut-border)] bg-[var(--bh-tooltip-shortcut-bg)] px-[var(--bh-space-xs-4)] text-center text-[length:var(--bh-text-body-2xs-medium-font-size)] font-[var(--bh-text-body-2xs-medium-font-weight)] leading-[var(--bh-text-body-2xs-medium-line-height)] tracking-[var(--bh-text-body-2xs-medium-letter-spacing)]",
|
|
256
|
+
className
|
|
257
|
+
)}
|
|
258
|
+
{...props}
|
|
259
|
+
>
|
|
260
|
+
{children}
|
|
261
|
+
</span>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function TooltipCloseButton({
|
|
266
|
+
className,
|
|
267
|
+
label = "Close tooltip",
|
|
268
|
+
type,
|
|
269
|
+
...props
|
|
270
|
+
}: TooltipCloseButtonProps) {
|
|
271
|
+
return (
|
|
272
|
+
<button
|
|
273
|
+
aria-label={label}
|
|
274
|
+
data-slot="tooltip-close"
|
|
275
|
+
type={type || "button"}
|
|
276
|
+
className={cn(
|
|
277
|
+
"inline-flex size-[var(--bh-tooltip-close-size)] shrink-0 items-center justify-center rounded-[var(--bh-radius-full)] border-0 bg-transparent p-0 text-[var(--bh-tooltip-close-fg)] outline-none transition-[background-color,box-shadow] hover:bg-[var(--bh-interactive-ghost-hover)] focus-visible:shadow-[var(--elevation-button-focus)]",
|
|
278
|
+
className
|
|
279
|
+
)}
|
|
280
|
+
{...props}
|
|
281
|
+
>
|
|
282
|
+
<XIcon
|
|
283
|
+
aria-hidden="true"
|
|
284
|
+
className="size-[var(--bh-tooltip-close-icon-size)]"
|
|
285
|
+
strokeWidth="var(--bh-icon-stroke-200)"
|
|
286
|
+
/>
|
|
287
|
+
</button>
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function TooltipPointer({
|
|
292
|
+
pointerPosition,
|
|
293
|
+
variant,
|
|
294
|
+
}: {
|
|
295
|
+
pointerPosition: TooltipPointerPosition
|
|
296
|
+
variant: TooltipVariant
|
|
297
|
+
}) {
|
|
298
|
+
const side = getPointerSide(pointerPosition)
|
|
299
|
+
if (!side) return null
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<span
|
|
303
|
+
aria-hidden="true"
|
|
304
|
+
data-pointer-side={side}
|
|
305
|
+
data-slot="tooltip-pointer"
|
|
306
|
+
className={cn(
|
|
307
|
+
"pointer-events-none absolute z-[var(--bh-z-raised)]",
|
|
308
|
+
pointerPlacement[pointerPosition as Exclude<TooltipPointerPosition, "none">]
|
|
309
|
+
)}
|
|
310
|
+
>
|
|
311
|
+
{variant === "default" ? (
|
|
312
|
+
<span className={cn("absolute size-[var(--bh-space-none)]", pointerBorderShape[side])} />
|
|
313
|
+
) : null}
|
|
314
|
+
<span className={cn("absolute size-[var(--bh-space-none)]", pointerFillShape[side])} />
|
|
315
|
+
</span>
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function getTooltipPlacement(pointerPosition: TooltipPointerPosition): {
|
|
320
|
+
align: React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>["align"]
|
|
321
|
+
side: React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>["side"]
|
|
322
|
+
} {
|
|
323
|
+
if (pointerPosition.startsWith("bottom")) {
|
|
324
|
+
return {
|
|
325
|
+
side: "top",
|
|
326
|
+
align: pointerPosition.endsWith("left")
|
|
327
|
+
? "start"
|
|
328
|
+
: pointerPosition.endsWith("right")
|
|
329
|
+
? "end"
|
|
330
|
+
: "center",
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (pointerPosition === "center-left") {
|
|
335
|
+
return { side: "right", align: "center" }
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (pointerPosition === "center-right") {
|
|
339
|
+
return { side: "left", align: "center" }
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (pointerPosition === "none") {
|
|
343
|
+
return { side: "top", align: "center" }
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
side: "bottom",
|
|
348
|
+
align: pointerPosition.endsWith("left")
|
|
349
|
+
? "start"
|
|
350
|
+
: pointerPosition.endsWith("right")
|
|
351
|
+
? "end"
|
|
352
|
+
: "center",
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function getPointerSide(pointerPosition: TooltipPointerPosition) {
|
|
357
|
+
if (pointerPosition.startsWith("top")) return "top"
|
|
358
|
+
if (pointerPosition.startsWith("bottom")) return "bottom"
|
|
359
|
+
if (pointerPosition === "center-left") return "left"
|
|
360
|
+
if (pointerPosition === "center-right") return "right"
|
|
361
|
+
|
|
362
|
+
return null
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function hasRenderableContent(content: React.ReactNode) {
|
|
366
|
+
return (
|
|
367
|
+
content !== undefined &&
|
|
368
|
+
content !== null &&
|
|
369
|
+
content !== false &&
|
|
370
|
+
content !== ""
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const pointerPlacement: Record<Exclude<TooltipPointerPosition, "none">, string> = {
|
|
375
|
+
"top-left":
|
|
376
|
+
"top-[var(--bh-tooltip-pointer-offset)] h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)] [inset-inline-start:var(--bh-tooltip-pointer-inline-offset)]",
|
|
377
|
+
"top-center":
|
|
378
|
+
"top-[var(--bh-tooltip-pointer-offset)] left-1/2 h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)] -translate-x-1/2 rtl:translate-x-1/2",
|
|
379
|
+
"top-right":
|
|
380
|
+
"top-[var(--bh-tooltip-pointer-offset)] h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)] [inset-inline-end:var(--bh-tooltip-pointer-inline-offset)]",
|
|
381
|
+
"bottom-left":
|
|
382
|
+
"bottom-[var(--bh-tooltip-pointer-offset)] h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)] [inset-inline-start:var(--bh-tooltip-pointer-inline-offset)]",
|
|
383
|
+
"bottom-center":
|
|
384
|
+
"bottom-[var(--bh-tooltip-pointer-offset)] left-1/2 h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)] -translate-x-1/2 rtl:translate-x-1/2",
|
|
385
|
+
"bottom-right":
|
|
386
|
+
"bottom-[var(--bh-tooltip-pointer-offset)] h-[var(--bh-tooltip-pointer-depth)] w-[var(--bh-tooltip-pointer-width)] [inset-inline-end:var(--bh-tooltip-pointer-inline-offset)]",
|
|
387
|
+
"center-right":
|
|
388
|
+
"right-[var(--bh-tooltip-pointer-offset)] top-1/2 h-[var(--bh-tooltip-pointer-width)] w-[var(--bh-tooltip-pointer-depth)] -translate-y-1/2",
|
|
389
|
+
"center-left":
|
|
390
|
+
"left-[var(--bh-tooltip-pointer-offset)] top-1/2 h-[var(--bh-tooltip-pointer-width)] w-[var(--bh-tooltip-pointer-depth)] -translate-y-1/2",
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const pointerFillShape = {
|
|
394
|
+
top:
|
|
395
|
+
"left-0 top-[var(--bh-space-xxxs-1)] border-x-[length:var(--bh-tooltip-pointer-half-width)] border-b-[length:var(--bh-tooltip-pointer-depth)] border-x-[color:transparent] border-b-[color:var(--bh-tooltip-bg)]",
|
|
396
|
+
bottom:
|
|
397
|
+
"bottom-[var(--bh-space-xxxs-1)] left-0 border-x-[length:var(--bh-tooltip-pointer-half-width)] border-t-[length:var(--bh-tooltip-pointer-depth)] border-x-[color:transparent] border-t-[color:var(--bh-tooltip-bg)]",
|
|
398
|
+
right:
|
|
399
|
+
"left-[calc(var(--bh-space-xxxs-1)*-1)] top-0 border-y-[length:var(--bh-tooltip-pointer-half-width)] border-l-[length:var(--bh-tooltip-pointer-depth)] border-y-[color:transparent] border-l-[color:var(--bh-tooltip-bg)]",
|
|
400
|
+
left:
|
|
401
|
+
"right-[calc(var(--bh-space-xxxs-1)*-1)] top-0 border-y-[length:var(--bh-tooltip-pointer-half-width)] border-r-[length:var(--bh-tooltip-pointer-depth)] border-y-[color:transparent] border-r-[color:var(--bh-tooltip-bg)]",
|
|
402
|
+
} as const
|
|
403
|
+
|
|
404
|
+
const pointerBorderShape = {
|
|
405
|
+
top:
|
|
406
|
+
"left-[var(--bh-tooltip-pointer-border-offset)] top-[var(--bh-tooltip-pointer-border-offset)] border-x-[length:var(--bh-tooltip-pointer-border-half-width)] border-b-[length:var(--bh-tooltip-pointer-border-depth)] border-x-[color:transparent] border-b-[color:var(--bh-tooltip-border)]",
|
|
407
|
+
bottom:
|
|
408
|
+
"bottom-[var(--bh-tooltip-pointer-border-offset)] left-[var(--bh-tooltip-pointer-border-offset)] border-x-[length:var(--bh-tooltip-pointer-border-half-width)] border-t-[length:var(--bh-tooltip-pointer-border-depth)] border-x-[color:transparent] border-t-[color:var(--bh-tooltip-border)]",
|
|
409
|
+
right:
|
|
410
|
+
"top-[var(--bh-tooltip-pointer-border-offset)] left-0 border-y-[length:var(--bh-tooltip-pointer-border-half-width)] border-l-[length:var(--bh-tooltip-pointer-border-depth)] border-y-[color:transparent] border-l-[color:var(--bh-tooltip-border)]",
|
|
411
|
+
left:
|
|
412
|
+
"top-[var(--bh-tooltip-pointer-border-offset)] right-0 border-y-[length:var(--bh-tooltip-pointer-border-half-width)] border-r-[length:var(--bh-tooltip-pointer-border-depth)] border-y-[color:transparent] border-r-[color:var(--bh-tooltip-border)]",
|
|
413
|
+
} as const
|
|
414
|
+
|
|
415
|
+
export {
|
|
416
|
+
Tooltip,
|
|
417
|
+
TooltipCloseButton,
|
|
418
|
+
TooltipContent,
|
|
419
|
+
TooltipPortal,
|
|
420
|
+
TooltipProvider,
|
|
421
|
+
TooltipRoot,
|
|
422
|
+
TooltipShortcut,
|
|
423
|
+
TooltipTrigger,
|
|
424
|
+
tooltipContentVariants,
|
|
425
|
+
}
|
|
426
|
+
export type {
|
|
427
|
+
TooltipCloseButtonProps,
|
|
428
|
+
TooltipContentProps,
|
|
429
|
+
TooltipPointerPosition,
|
|
430
|
+
TooltipShortcutProps,
|
|
431
|
+
TooltipSize,
|
|
432
|
+
TooltipVariant,
|
|
433
|
+
}
|