@octanejs/shadcn 0.0.7 → 0.0.8

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.
@@ -0,0 +1,73 @@
1
+ // Base UI base tooltip — runs on @octanejs/base-ui's Tooltip.
2
+ //
3
+ // SAME TWO POSITIONING DIFFERENCES AS POPOVER: the transform-origin var is plain
4
+ // `--transform-origin` rather than radix's `--radix-tooltip-content-transform-origin`, and the
5
+ // tree gains a Positioner layer (Portal > Positioner > Popup) which owns the offset.
6
+ //
7
+ // ONE RADIX-ONLY STATE IS DROPPED. The radix base styles `data-[state=delayed-open]:` alongside
8
+ // `data-open:`, because radix distinguishes an immediate open from one that waited out the
9
+ // delay. Base UI publishes only `data-open`/`data-closed` — there is no delayed-open state to
10
+ // match, so those three utilities would be dead weight referencing an attribute that never
11
+ // appears. The `data-open:` variants they duplicate are kept and cover both cases.
12
+ //
13
+ // UNVERIFIED PROVENANCE: class strings come from this package's radix base rather than
14
+ // transcribed from upstream's Base UI source.
15
+ import { createElement, Fragment, type OctaneNode } from 'octane';
16
+ import { Tooltip as TooltipPrimitive } from '@octanejs/base-ui/tooltip';
17
+
18
+ import { cn } from '../../../lib/utils';
19
+
20
+ export interface TooltipProviderProps extends Record<string, unknown> {
21
+ delay?: number;
22
+ }
23
+
24
+ export function TooltipProvider({ delay = 0, ...props }: TooltipProviderProps) @{
25
+ <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />
26
+ }
27
+
28
+ export function Tooltip(props: Record<string, unknown>) @{
29
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
30
+ }
31
+
32
+ export function TooltipTrigger(props: Record<string, unknown>) @{
33
+ <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
34
+ }
35
+
36
+ export interface TooltipContentProps extends Record<string, unknown> {
37
+ className?: string;
38
+ sideOffset?: number;
39
+ children?: OctaneNode;
40
+ }
41
+
42
+ export function TooltipContent({
43
+ className,
44
+ sideOffset = 0,
45
+ children,
46
+ ...props
47
+ }: TooltipContentProps) {
48
+ return createElement(TooltipPrimitive.Portal, {
49
+ children: createElement(TooltipPrimitive.Positioner, {
50
+ sideOffset,
51
+ children: createElement(TooltipPrimitive.Popup, {
52
+ 'data-slot': 'tooltip-content',
53
+ className: cn(
54
+ 'z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
55
+ className,
56
+ ),
57
+ ...props,
58
+ // Octane reconciles ARRAY children as a keyed list, so every entry needs a key —
59
+ // including the consumer's. Leaving `children` bare emits the missing-key warning
60
+ // and lets the consumer node be mismatched against the arrow when its identity
61
+ // changes. The consumer may pass anything (a string, an element, an array), so it
62
+ // is wrapped in a keyed Fragment rather than keyed in place.
63
+ children: [
64
+ createElement(Fragment, { key: 'content', children }),
65
+ createElement(TooltipPrimitive.Arrow, {
66
+ key: 'arrow',
67
+ className: 'z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground',
68
+ }),
69
+ ],
70
+ }),
71
+ }),
72
+ });
73
+ }