@cdx-ui/primitives 0.0.1-beta.144 → 0.0.1-beta.146
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/README.md +3 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/overlay/useAnchorPosition.js +13 -23
- package/lib/commonjs/overlay/useAnchorPosition.js.map +1 -1
- package/lib/commonjs/tooltip/TooltipContent.js +106 -0
- package/lib/commonjs/tooltip/TooltipContent.js.map +1 -0
- package/lib/commonjs/tooltip/TooltipRoot.js +128 -0
- package/lib/commonjs/tooltip/TooltipRoot.js.map +1 -0
- package/lib/commonjs/tooltip/TooltipTrigger.js +132 -0
- package/lib/commonjs/tooltip/TooltipTrigger.js.map +1 -0
- package/lib/commonjs/tooltip/context.js +11 -0
- package/lib/commonjs/tooltip/context.js.map +1 -0
- package/lib/commonjs/tooltip/getTooltipPosition.js +124 -0
- package/lib/commonjs/tooltip/getTooltipPosition.js.map +1 -0
- package/lib/commonjs/tooltip/index.js +53 -0
- package/lib/commonjs/tooltip/index.js.map +1 -0
- package/lib/commonjs/tooltip/types.js +6 -0
- package/lib/commonjs/tooltip/types.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/overlay/useAnchorPosition.js +13 -23
- package/lib/module/overlay/useAnchorPosition.js.map +1 -1
- package/lib/module/tooltip/TooltipContent.js +102 -0
- package/lib/module/tooltip/TooltipContent.js.map +1 -0
- package/lib/module/tooltip/TooltipRoot.js +124 -0
- package/lib/module/tooltip/TooltipRoot.js.map +1 -0
- package/lib/module/tooltip/TooltipTrigger.js +128 -0
- package/lib/module/tooltip/TooltipTrigger.js.map +1 -0
- package/lib/module/tooltip/context.js +5 -0
- package/lib/module/tooltip/context.js.map +1 -0
- package/lib/module/tooltip/getTooltipPosition.js +119 -0
- package/lib/module/tooltip/getTooltipPosition.js.map +1 -0
- package/lib/module/tooltip/index.js +8 -0
- package/lib/module/tooltip/index.js.map +1 -0
- package/lib/module/tooltip/types.js +4 -0
- package/lib/module/tooltip/types.js.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/overlay/useAnchorPosition.d.ts.map +1 -1
- package/lib/typescript/tooltip/TooltipContent.d.ts +6 -0
- package/lib/typescript/tooltip/TooltipContent.d.ts.map +1 -0
- package/lib/typescript/tooltip/TooltipRoot.d.ts +7 -0
- package/lib/typescript/tooltip/TooltipRoot.d.ts.map +1 -0
- package/lib/typescript/tooltip/TooltipTrigger.d.ts +5 -0
- package/lib/typescript/tooltip/TooltipTrigger.d.ts.map +1 -0
- package/lib/typescript/tooltip/context.d.ts +6 -0
- package/lib/typescript/tooltip/context.d.ts.map +1 -0
- package/lib/typescript/tooltip/getTooltipPosition.d.ts +20 -0
- package/lib/typescript/tooltip/getTooltipPosition.d.ts.map +1 -0
- package/lib/typescript/tooltip/index.d.ts +7 -0
- package/lib/typescript/tooltip/index.d.ts.map +1 -0
- package/lib/typescript/tooltip/types.d.ts +78 -0
- package/lib/typescript/tooltip/types.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/overlay/useAnchorPosition.ts +15 -20
- package/src/tooltip/TooltipContent.tsx +119 -0
- package/src/tooltip/TooltipRoot.tsx +187 -0
- package/src/tooltip/TooltipTrigger.tsx +160 -0
- package/src/tooltip/context.tsx +5 -0
- package/src/tooltip/getTooltipPosition.ts +147 -0
- package/src/tooltip/index.ts +19 -0
- package/src/tooltip/types.ts +85 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ComponentRef, ReactNode, RefObject } from 'react';
|
|
2
|
+
import type { PressableProps, View, ViewProps } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
ResolvedTooltipPlacement,
|
|
5
|
+
TooltipPlacement,
|
|
6
|
+
TooltipTriggerMode,
|
|
7
|
+
} from './getTooltipPosition';
|
|
8
|
+
|
|
9
|
+
export interface ITooltipProps extends Omit<ViewProps, 'children'> {
|
|
10
|
+
readonly children?: ReactNode;
|
|
11
|
+
readonly isDisabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Milliseconds to wait before showing the tooltip.
|
|
14
|
+
* @default `0`
|
|
15
|
+
*/
|
|
16
|
+
readonly enterDelay?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Milliseconds to wait before hiding the tooltip.
|
|
19
|
+
* @default `0`
|
|
20
|
+
*/
|
|
21
|
+
readonly leaveDelay?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Controlled open state.
|
|
24
|
+
*/
|
|
25
|
+
readonly isOpen?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Uncontrolled initial open state.
|
|
28
|
+
* @default `false`
|
|
29
|
+
*/
|
|
30
|
+
readonly defaultOpen?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Called when the tooltip opens.
|
|
33
|
+
*/
|
|
34
|
+
readonly onOpen?: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Called when the tooltip closes.
|
|
37
|
+
*/
|
|
38
|
+
readonly onClose?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Preferred placement relative to the trigger.
|
|
41
|
+
* @default `'top'`
|
|
42
|
+
*/
|
|
43
|
+
readonly placement?: TooltipPlacement;
|
|
44
|
+
/**
|
|
45
|
+
* Distance in pixels between the tooltip and the trigger.
|
|
46
|
+
* @default `8`
|
|
47
|
+
*/
|
|
48
|
+
readonly offset?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Interaction that opens the tooltip. On web, `hover` opens on hover and focus; on native, long press.
|
|
51
|
+
* `focus` opens on focus (web) or long press (native). `click` toggles on press — on web, dismisses on outside click or Escape.
|
|
52
|
+
* @default `'hover'`
|
|
53
|
+
*/
|
|
54
|
+
readonly trigger?: TooltipTriggerMode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface TooltipContextValue {
|
|
58
|
+
readonly open: boolean;
|
|
59
|
+
readonly setOpen: (open: boolean) => void;
|
|
60
|
+
readonly requestOpen: () => void;
|
|
61
|
+
readonly requestClose: () => void;
|
|
62
|
+
readonly clearTimers: () => void;
|
|
63
|
+
readonly isDisabled: boolean;
|
|
64
|
+
readonly enterDelay: number;
|
|
65
|
+
readonly leaveDelay: number;
|
|
66
|
+
readonly placement: TooltipPlacement;
|
|
67
|
+
readonly offset: number;
|
|
68
|
+
readonly trigger: TooltipTriggerMode;
|
|
69
|
+
readonly triggerRef: RefObject<ComponentRef<typeof View> | null>;
|
|
70
|
+
readonly contentId: string;
|
|
71
|
+
readonly triggerId: string;
|
|
72
|
+
readonly resolvedPlacement: ResolvedTooltipPlacement | null;
|
|
73
|
+
readonly setResolvedPlacement: (placement: ResolvedTooltipPlacement) => void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ITooltipTriggerProps extends PressableProps {
|
|
77
|
+
/** When true, merges trigger props onto the single child element. */
|
|
78
|
+
readonly asChild?: boolean;
|
|
79
|
+
readonly children?: ReactNode;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ITooltipContentProps extends ViewProps {
|
|
83
|
+
readonly asChild?: boolean;
|
|
84
|
+
readonly children?: ReactNode;
|
|
85
|
+
}
|