@zealakit/overlay-react 0.0.0-stage → 1.0.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.
Files changed (185) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +547 -2
  3. package/dist/animation/index.d.ts +1 -0
  4. package/dist/animation/index.js +1 -0
  5. package/dist/animation/presence.d.ts +31 -0
  6. package/dist/animation/presence.js +104 -0
  7. package/dist/components/arrow.d.ts +30 -0
  8. package/dist/components/arrow.js +58 -0
  9. package/dist/components/context-menu/content.d.ts +37 -0
  10. package/dist/components/context-menu/content.js +52 -0
  11. package/dist/components/context-menu/context-menu.d.ts +20 -0
  12. package/dist/components/context-menu/context-menu.js +78 -0
  13. package/dist/components/context-menu/context.d.ts +47 -0
  14. package/dist/components/context-menu/context.js +27 -0
  15. package/dist/components/context-menu/index.d.ts +7 -0
  16. package/dist/components/context-menu/index.js +6 -0
  17. package/dist/components/context-menu/items.d.ts +71 -0
  18. package/dist/components/context-menu/items.js +207 -0
  19. package/dist/components/context-menu/menu-navigation.d.ts +3 -0
  20. package/dist/components/context-menu/menu-navigation.js +42 -0
  21. package/dist/components/context-menu/menu-surface.d.ts +58 -0
  22. package/dist/components/context-menu/menu-surface.js +172 -0
  23. package/dist/components/context-menu/sub.d.ts +45 -0
  24. package/dist/components/context-menu/sub.js +180 -0
  25. package/dist/components/context-menu/trigger.d.ts +17 -0
  26. package/dist/components/context-menu/trigger.js +62 -0
  27. package/dist/components/context-menu/types.d.ts +9 -0
  28. package/dist/components/context-menu/types.js +1 -0
  29. package/dist/components/dialog/content.d.ts +87 -0
  30. package/dist/components/dialog/content.js +238 -0
  31. package/dist/components/dialog/context.d.ts +41 -0
  32. package/dist/components/dialog/context.js +26 -0
  33. package/dist/components/dialog/dialog.d.ts +27 -0
  34. package/dist/components/dialog/dialog.js +88 -0
  35. package/dist/components/dialog/helpers.d.ts +24 -0
  36. package/dist/components/dialog/helpers.js +59 -0
  37. package/dist/components/dialog/index.d.ts +5 -0
  38. package/dist/components/dialog/index.js +5 -0
  39. package/dist/components/dialog/modal-background.d.ts +7 -0
  40. package/dist/components/dialog/modal-background.js +21 -0
  41. package/dist/components/dialog/trigger.d.ts +11 -0
  42. package/dist/components/dialog/trigger.js +29 -0
  43. package/dist/components/overlay-context.d.ts +13 -0
  44. package/dist/components/overlay-context.js +10 -0
  45. package/dist/components/popover/content.d.ts +131 -0
  46. package/dist/components/popover/content.js +261 -0
  47. package/dist/components/popover/context.d.ts +27 -0
  48. package/dist/components/popover/context.js +18 -0
  49. package/dist/components/popover/helpers.d.ts +23 -0
  50. package/dist/components/popover/helpers.js +58 -0
  51. package/dist/components/popover/index.d.ts +4 -0
  52. package/dist/components/popover/index.js +4 -0
  53. package/dist/components/popover/popover.d.ts +39 -0
  54. package/dist/components/popover/popover.js +98 -0
  55. package/dist/components/portal.d.ts +14 -0
  56. package/dist/components/portal.js +19 -0
  57. package/dist/components/slot.d.ts +12 -0
  58. package/dist/components/slot.js +60 -0
  59. package/dist/components/tooltip/content.d.ts +21 -0
  60. package/dist/components/tooltip/content.js +95 -0
  61. package/dist/components/tooltip/context.d.ts +22 -0
  62. package/dist/components/tooltip/context.js +10 -0
  63. package/dist/components/tooltip/index.d.ts +5 -0
  64. package/dist/components/tooltip/index.js +5 -0
  65. package/dist/components/tooltip/provider.d.ts +29 -0
  66. package/dist/components/tooltip/provider.js +29 -0
  67. package/dist/components/tooltip/tooltip.d.ts +25 -0
  68. package/dist/components/tooltip/tooltip.js +268 -0
  69. package/dist/components/tooltip/trigger.d.ts +11 -0
  70. package/dist/components/tooltip/trigger.js +67 -0
  71. package/dist/hooks/use-escape-key.d.ts +12 -0
  72. package/dist/hooks/use-escape-key.js +30 -0
  73. package/dist/hooks/use-layer.d.ts +33 -0
  74. package/dist/hooks/use-layer.js +84 -0
  75. package/dist/hooks/use-overlay.d.ts +31 -0
  76. package/dist/hooks/use-overlay.js +69 -0
  77. package/dist/hooks/use-positioner.d.ts +28 -0
  78. package/dist/hooks/use-positioner.js +127 -0
  79. package/dist/index.d.ts +12 -0
  80. package/dist/index.js +12 -0
  81. package/dist/vendor/core/animation/index.d.ts +2 -0
  82. package/dist/vendor/core/animation/index.js +2 -0
  83. package/dist/vendor/core/animation/keyframes.d.ts +47 -0
  84. package/dist/vendor/core/animation/keyframes.js +105 -0
  85. package/dist/vendor/core/animation/run-animation.d.ts +27 -0
  86. package/dist/vendor/core/animation/run-animation.js +175 -0
  87. package/dist/vendor/core/controller/animator.d.ts +19 -0
  88. package/dist/vendor/core/controller/animator.js +117 -0
  89. package/dist/vendor/core/controller/context-menu-behavior.d.ts +15 -0
  90. package/dist/vendor/core/controller/context-menu-behavior.js +123 -0
  91. package/dist/vendor/core/controller/host.d.ts +10 -0
  92. package/dist/vendor/core/controller/host.js +1 -0
  93. package/dist/vendor/core/controller/index.d.ts +2 -0
  94. package/dist/vendor/core/controller/index.js +1 -0
  95. package/dist/vendor/core/controller/overlay-controller.d.ts +9 -0
  96. package/dist/vendor/core/controller/overlay-controller.js +723 -0
  97. package/dist/vendor/core/controller/tooltip-behavior.d.ts +9 -0
  98. package/dist/vendor/core/controller/tooltip-behavior.js +123 -0
  99. package/dist/vendor/core/controller/types.d.ts +92 -0
  100. package/dist/vendor/core/controller/types.js +1 -0
  101. package/dist/vendor/core/events/index.d.ts +3 -0
  102. package/dist/vendor/core/events/index.js +3 -0
  103. package/dist/vendor/core/events/keyboard.d.ts +2 -0
  104. package/dist/vendor/core/events/keyboard.js +4 -0
  105. package/dist/vendor/core/events/outside.d.ts +8 -0
  106. package/dist/vendor/core/events/outside.js +33 -0
  107. package/dist/vendor/core/events/pointer.d.ts +13 -0
  108. package/dist/vendor/core/events/pointer.js +18 -0
  109. package/dist/vendor/core/focus/focus.d.ts +73 -0
  110. package/dist/vendor/core/focus/focus.js +312 -0
  111. package/dist/vendor/core/focus/index.d.ts +1 -0
  112. package/dist/vendor/core/focus/index.js +1 -0
  113. package/dist/vendor/core/index.d.ts +13 -0
  114. package/dist/vendor/core/index.js +13 -0
  115. package/dist/vendor/core/layer/create-layer-stack.d.ts +25 -0
  116. package/dist/vendor/core/layer/create-layer-stack.js +247 -0
  117. package/dist/vendor/core/layer/create-layer.d.ts +10 -0
  118. package/dist/vendor/core/layer/create-layer.js +78 -0
  119. package/dist/vendor/core/layer/index.d.ts +3 -0
  120. package/dist/vendor/core/layer/index.js +3 -0
  121. package/dist/vendor/core/layer/manager.d.ts +9 -0
  122. package/dist/vendor/core/layer/manager.js +157 -0
  123. package/dist/vendor/core/lifecycle/events.d.ts +8 -0
  124. package/dist/vendor/core/lifecycle/events.js +21 -0
  125. package/dist/vendor/core/lifecycle/index.d.ts +1 -0
  126. package/dist/vendor/core/lifecycle/index.js +1 -0
  127. package/dist/vendor/core/menu/index.d.ts +1 -0
  128. package/dist/vendor/core/menu/index.js +1 -0
  129. package/dist/vendor/core/menu/navigation.d.ts +22 -0
  130. package/dist/vendor/core/menu/navigation.js +107 -0
  131. package/dist/vendor/core/modal/background.d.ts +10 -0
  132. package/dist/vendor/core/modal/background.js +115 -0
  133. package/dist/vendor/core/modal/index.d.ts +1 -0
  134. package/dist/vendor/core/modal/index.js +1 -0
  135. package/dist/vendor/core/portal/index.d.ts +1 -0
  136. package/dist/vendor/core/portal/index.js +1 -0
  137. package/dist/vendor/core/portal/portal.d.ts +13 -0
  138. package/dist/vendor/core/portal/portal.js +25 -0
  139. package/dist/vendor/core/positioning/arrow.d.ts +34 -0
  140. package/dist/vendor/core/positioning/arrow.js +142 -0
  141. package/dist/vendor/core/positioning/compute.d.ts +9 -0
  142. package/dist/vendor/core/positioning/compute.js +22 -0
  143. package/dist/vendor/core/positioning/coordinates.d.ts +11 -0
  144. package/dist/vendor/core/positioning/coordinates.js +45 -0
  145. package/dist/vendor/core/positioning/create-positioner.d.ts +8 -0
  146. package/dist/vendor/core/positioning/create-positioner.js +251 -0
  147. package/dist/vendor/core/positioning/index.d.ts +6 -0
  148. package/dist/vendor/core/positioning/index.js +6 -0
  149. package/dist/vendor/core/positioning/placement.d.ts +8 -0
  150. package/dist/vendor/core/positioning/placement.js +30 -0
  151. package/dist/vendor/core/positioning/same-result.d.ts +8 -0
  152. package/dist/vendor/core/positioning/same-result.js +13 -0
  153. package/dist/vendor/core/positioning/strategy.d.ts +12 -0
  154. package/dist/vendor/core/positioning/strategy.js +46 -0
  155. package/dist/vendor/core/scroll-lock/index.d.ts +1 -0
  156. package/dist/vendor/core/scroll-lock/index.js +1 -0
  157. package/dist/vendor/core/scroll-lock/scroll-lock.d.ts +12 -0
  158. package/dist/vendor/core/scroll-lock/scroll-lock.js +68 -0
  159. package/dist/vendor/core/types/animation.d.ts +81 -0
  160. package/dist/vendor/core/types/animation.js +93 -0
  161. package/dist/vendor/core/types/dismissal.d.ts +2 -0
  162. package/dist/vendor/core/types/dismissal.js +1 -0
  163. package/dist/vendor/core/types/element.d.ts +20 -0
  164. package/dist/vendor/core/types/element.js +1 -0
  165. package/dist/vendor/core/types/geometry.d.ts +22 -0
  166. package/dist/vendor/core/types/geometry.js +1 -0
  167. package/dist/vendor/core/types/index.d.ts +9 -0
  168. package/dist/vendor/core/types/index.js +8 -0
  169. package/dist/vendor/core/types/layer.d.ts +126 -0
  170. package/dist/vendor/core/types/layer.js +1 -0
  171. package/dist/vendor/core/types/lifecycle.d.ts +2 -0
  172. package/dist/vendor/core/types/lifecycle.js +1 -0
  173. package/dist/vendor/core/types/positioner.d.ts +74 -0
  174. package/dist/vendor/core/types/positioner.js +1 -0
  175. package/dist/vendor/core/types/positioning.d.ts +23 -0
  176. package/dist/vendor/core/types/positioning.js +1 -0
  177. package/dist/vendor/core/utils/dom.d.ts +11 -0
  178. package/dist/vendor/core/utils/dom.js +21 -0
  179. package/dist/vendor/core/utils/element.d.ts +15 -0
  180. package/dist/vendor/core/utils/element.js +21 -0
  181. package/dist/vendor/core/utils/global-state.d.ts +1 -0
  182. package/dist/vendor/core/utils/global-state.js +24 -0
  183. package/dist/vendor/core/utils/index.d.ts +2 -0
  184. package/dist/vendor/core/utils/index.js +2 -0
  185. package/package.json +74 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zealakit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,548 @@
1
- # Temporary Holding Version
1
+ # @zealakit/overlay-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [English](https://github.com/zealakit/overlay/blob/main/packages/react/README.md) | [Tiếng Việt](https://github.com/zealakit/overlay/blob/main/packages/react/README_VI.md) | [中文](https://github.com/zealakit/overlay/blob/main/packages/react/README_CN.md)
4
+
5
+ ![Zealakit Overlay cover](https://github.com/zealakit/overlay/blob/main/assets/images/overlay-cover.jpg?raw=true)
6
+
7
+ Headless Popover, Tooltip, Dialog, and ContextMenu for React. Provides compound components, positioning, layered dismissal, focus management, and low-level hooks. You own visual styling.
8
+
9
+ Style the parts through `className`, `style`, and the `data-*` hooks below. Closed content is unmounted (or kept with `keepMounted`), so exit animations need the `animation` prop to collapse cleanly.
10
+
11
+ > **Note**
12
+ > Overlay is a focused, headless set of primitives for Popover, Tooltip, Dialog, and ContextMenu. It ships no CSS and renders no styled markup, so you keep full control of the visuals. Select, Combobox, DatePicker, DropdownMenu, Menubar, and command palette are not implemented.
13
+ >
14
+ > Overlay is not a replacement for a full UI library or design system. Use it when you need accessible overlay primitives without adopting a large kit, or when your current library's overlays are hard to restyle.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @zealakit/overlay-react
20
+
21
+ # or yarn, pnpm, ...
22
+ ```
23
+
24
+ Peer dependencies: `react` and `react-dom` `^18.0.0 || ^19.0.0`; a React app already provides them. ESM only. Entries carry `"use client"` for Next.js App Router. The internal `@zealakit/overlay-core` kernel is bundled inside this package and is not published to npm; there is nothing else to install.
25
+
26
+ ## Popover
27
+
28
+ ### Quick start
29
+
30
+ ```tsx
31
+ import {
32
+ Popover,
33
+ PopoverClose,
34
+ PopoverContent,
35
+ PopoverDescription,
36
+ PopoverHeader,
37
+ PopoverTitle,
38
+ PopoverTrigger,
39
+ } from "@zealakit/overlay-react";
40
+
41
+ export function EditProfile() {
42
+ return (
43
+ <Popover>
44
+ <PopoverTrigger>Edit profile</PopoverTrigger>
45
+ <PopoverContent side="bottom" align="start" sideOffset={8}>
46
+ <PopoverHeader>
47
+ <PopoverTitle>Edit profile</PopoverTitle>
48
+ <PopoverDescription>Update your profile information.</PopoverDescription>
49
+ </PopoverHeader>
50
+ <PopoverClose>Close</PopoverClose>
51
+ </PopoverContent>
52
+ </Popover>
53
+ );
54
+ }
55
+ ```
56
+
57
+ ### `Popover` props
58
+
59
+ | Prop | Type | Default | Description |
60
+ | --- | --- | --- | --- |
61
+ | `open` | `boolean` | — | Controlled visibility. |
62
+ | `defaultOpen` | `boolean` | `false` | Initial visibility when uncontrolled. |
63
+ | `onOpenChange` | `(open: boolean, reason) => void` | — | `reason` is `trigger`, `outside-press`, `escape`, `close-button`, or `programmatic`. |
64
+ | `dismissOnEscape` | `boolean` | `true` | Close on Escape. |
65
+ | `dismissOnOutsidePress` | `boolean` | `true` | Close on a primary press outside. |
66
+ | `dir` | `"ltr" \| "rtl"` | `"ltr"` | Direction for start/end alignment. |
67
+ | `parentLayer` | `LayerStackHandle \| null` | — | Parent layer when nested in a custom layer. |
68
+ | `children` | `ReactNode` | — | `Popover` renders no element, so no other props are forwarded. |
69
+
70
+ The root owns state and the generated ids. Nested Popovers inherit the parent layer, so Escape closes the child first.
71
+
72
+ ### `PopoverTrigger` props
73
+
74
+ | Prop | Type | Default | Description |
75
+ | --- | --- | --- | --- |
76
+ | `asChild` | `boolean` | `false` | Merge trigger behavior onto the single child instead of wrapping it. |
77
+ | `...button props` | `ComponentPropsWithoutRef<"button">` | — | Forwarded to the native `button`. Sets `aria-expanded` and, while open, `aria-controls`. |
78
+
79
+ Your `onClick` runs first; calling `event.preventDefault()` suppresses the toggle. A disabled trigger does not open.
80
+
81
+ ### `PopoverContent` props
82
+
83
+ | Prop | Type | Default | Description |
84
+ | --- | --- | --- | --- |
85
+ | `anchor` | `Element \| null` | trigger | Explicit reference element. |
86
+ | `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | Physical side of the anchor. |
87
+ | `align` | `"start" \| "center" \| "end"` | `"center"` | Follows `dir` for top and bottom sides. |
88
+ | `sideOffset` | `number` | `0` | Main-axis gap in pixels. |
89
+ | `alignOffset` | `number` | `0` | Cross-axis offset in pixels. |
90
+ | `collisionBoundary` | `Element \| "clippingAncestors" \| "viewport"` | `"clippingAncestors"` | Collision boundary. |
91
+ | `collisionPadding` | `number` | `0` | Gap from the boundary. |
92
+ | `collisionAvoidance` | `{ flip?: boolean; shift?: boolean }` | `{ flip: true, shift: true }` | Toggle flip and shift independently. |
93
+ | `positionMethod` | `"absolute" \| "fixed"` | automatic | Automatic: `absolute`, or `fixed` for fixed/sticky anchors. |
94
+ | `arrow` | `boolean` | `false` | Render a default arrow part. |
95
+ | `arrowSize` | `number` | `8` | Arrow edge length in pixels. |
96
+ | `arrowPadding` | `number` | `0` | Gap between the arrow and the popup edges. |
97
+ | `arrowClassName` / `arrowStyle` | `string` / `CSSProperties` | — | Class and inline style for the default arrow. |
98
+ | `initialFocus` | `boolean` | `false` | Focus the first focusable element on open. |
99
+ | `trapFocus` | `boolean` | `false` | Contain focus while this layer is topmost. |
100
+ | `restoreFocus` | `boolean` | `true` | Return focus to the trigger when closing from inside. |
101
+ | `animation` | `boolean \| AnimationConfig` | — | Off unless `true` or a config is passed. |
102
+ | `portal` | `boolean \| Element \| null` | `true` | `true` portals to `document.body`, an element selects a container, `false` renders in place. |
103
+ | `...div props` | `HTMLAttributes<HTMLDivElement>` | — | Forwarded to the popup `div`; positioning props are consumed and never reach the DOM. |
104
+
105
+ No `role`, `aria-modal`, or focus trap is added by default; choose the role that fits your content. `PopoverTitle` and `PopoverDescription` wire `aria-labelledby` and `aria-describedby`. `PopoverPortal`, `PopoverPositioner`, and `PopoverPopup` are exported for advanced composition.
106
+
107
+ ### Controlled usage
108
+
109
+ ```tsx
110
+ const [open, setOpen] = useState(false);
111
+
112
+ <Popover open={open} onOpenChange={(next, reason) => setOpen(next)}>
113
+ <PopoverTrigger>Edit profile</PopoverTrigger>
114
+ <PopoverContent>Update your profile information.</PopoverContent>
115
+ </Popover>;
116
+ ```
117
+
118
+ ### Arrow and animation configuration
119
+
120
+ ```tsx
121
+ <PopoverContent
122
+ arrow
123
+ arrowSize={10}
124
+ animation={{ type: "expand", duration: 220 }}
125
+ className="panel"
126
+ >
127
+ Update your profile information.
128
+ </PopoverContent>
129
+ ```
130
+
131
+ | Prop | Type | Default | Description |
132
+ | --- | --- | --- | --- |
133
+ | `enabled` | `boolean` | `true` with a config | Set `false` to turn the animation off. |
134
+ | `type` | `"fade" \| "expand" \| "custom"` | `"fade"` | `expand` grows out of the anchor edge; `custom` is inferred when `custom` is set. |
135
+ | `direction` | `"up" \| "down" \| "left" \| "right" \| "auto"` | `"auto"` | Travel direction; `auto` follows the resolved placement. |
136
+ | `duration` | `number` | `160` | Milliseconds. |
137
+ | `delay` | `number` | `0` | Milliseconds. |
138
+ | `easing` | `string` | `"ease-in-out"` | `ease-in-out`, `linear`, or any CSS timing function. |
139
+ | `custom` | `{ enter, exit } \| keyframes` | — | CSS classes or Web Animations keyframes (array or function). |
140
+ | `...` | — | — | Pass `true` for the defaults. Exit replays enter in reverse; reduced motion keeps only opacity. |
141
+
142
+ ```css
143
+ .panel {
144
+ --overlay-arrow-background: #121a27;
145
+ --overlay-arrow-border-width: 1px;
146
+ --overlay-arrow-border-color: #3d5478;
147
+ }
148
+ ```
149
+
150
+ ### `asChild`
151
+
152
+ ```tsx
153
+ <PopoverTrigger asChild>
154
+ <MyButton>Edit profile</MyButton>
155
+ </PopoverTrigger>
156
+ ```
157
+
158
+ `asChild` clones exactly one child and keeps your refs and handlers. Custom components must forward refs so the popup can position against them.
159
+
160
+ ## Tooltip
161
+
162
+ ### Quick start
163
+
164
+ ```tsx
165
+ import {
166
+ Tooltip,
167
+ TooltipContent,
168
+ TooltipProvider,
169
+ TooltipTrigger,
170
+ } from "@zealakit/overlay-react";
171
+
172
+ export function SaveButton() {
173
+ return (
174
+ <TooltipProvider delay={500}>
175
+ <Tooltip>
176
+ <TooltipTrigger>Edit profile</TooltipTrigger>
177
+ <TooltipContent side="top">Update your profile information.</TooltipContent>
178
+ </Tooltip>
179
+ </TooltipProvider>
180
+ );
181
+ }
182
+ ```
183
+
184
+ ### `TooltipProvider` props
185
+
186
+ | Prop | Type | Default | Description |
187
+ | --- | --- | --- | --- |
188
+ | `delay` | `number` | `500` | Hover opening delay in milliseconds. |
189
+ | `closeDelay` | `number` | `100` | Delay before closing after pointer or focus leaves. |
190
+ | `skipDelayDuration` | `number` | `300` | Window after opening where the next Tooltip opens immediately. |
191
+ | `disableHoverableContent` | `boolean` | `false` | Close when leaving the trigger even if the pointer enters the content. |
192
+ | `children` | `ReactNode` | — | The provider renders no element. It is optional; a Tooltip without one uses the defaults. |
193
+
194
+ ### `Tooltip` props
195
+
196
+ | Prop | Type | Default | Description |
197
+ | --- | --- | --- | --- |
198
+ | `open` | `boolean` | — | Controlled visibility. |
199
+ | `defaultOpen` | `boolean` | `false` | Initial visibility when uncontrolled. |
200
+ | `onOpenChange` | `(open: boolean, reason) => void` | — | `reason` is `hover`, `focus`, `escape`, `outside-press`, `trigger`, or `programmatic`. |
201
+ | `disabled` | `boolean` | `false` | Never opens. |
202
+ | `delay` / `closeDelay` / `disableHoverableContent` | — | provider value | Override the provider for this Tooltip. |
203
+ | `dir` | `"ltr" \| "rtl"` | `"ltr"` | Direction for start/end alignment. |
204
+ | `children` | `ReactNode` | — | `Tooltip` renders no element, so no other props are forwarded. |
205
+
206
+ Hover opens after `delay`, focus opens immediately, and Escape or an outside press closes. Touch hover is ignored. A Tooltip registers no layer, so it never blocks a parent Popover or Dialog.
207
+
208
+ ### `TooltipTrigger` props
209
+
210
+ | Prop | Type | Default | Description |
211
+ | --- | --- | --- | --- |
212
+ | `asChild` | `boolean` | `false` | Merge trigger behavior onto the single child. |
213
+ | `...button props` | `ComponentPropsWithoutRef<"button">` | — | Forwarded to the native `button`. While open it gets `aria-describedby`; clicking closes but never opens. |
214
+
215
+ ### `TooltipContent` props
216
+
217
+ | Prop | Type | Default | Description |
218
+ | --- | --- | --- | --- |
219
+ | `anchor` | `Element \| null` | trigger | Explicit reference element. |
220
+ | `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | Physical side of the anchor. |
221
+ | `align` | `"start" \| "center" \| "end"` | `"center"` | Follows `dir` for top and bottom sides. |
222
+ | `sideOffset` | `number` | `0` | Main-axis gap in pixels. |
223
+ | `alignOffset` | `number` | `0` | Cross-axis offset in pixels. |
224
+ | `collisionBoundary` | `Element \| "clippingAncestors" \| "viewport"` | `"clippingAncestors"` | Collision boundary. |
225
+ | `collisionPadding` | `number` | `0` | Gap from the boundary. |
226
+ | `collisionAvoidance` | `{ flip?: boolean; shift?: boolean }` | `{ flip: true, shift: true }` | Toggle flip and shift independently. |
227
+ | `positionMethod` | `"absolute" \| "fixed"` | automatic | Automatic: `absolute`, or `fixed` for fixed/sticky anchors. |
228
+ | `arrow` | `boolean` | `false` | Render a default arrow part. |
229
+ | `arrowSize` | `number` | `8` | Arrow edge length in pixels. |
230
+ | `arrowPadding` | `number` | `0` | Gap between the arrow and the popup edges. |
231
+ | `arrowClassName` / `arrowStyle` | `string` / `CSSProperties` | — | Class and inline style for the default arrow. |
232
+ | `animation` | `boolean \| AnimationConfig` | — | Off unless `true` or a config is passed. |
233
+ | `portal` | `boolean \| Element \| null` | `true` | `true` portals to `document.body`, an element selects a container, `false` renders in place. |
234
+ | `...div props` | `HTMLAttributes<HTMLDivElement>` | — | Forwarded to the popup `div` with `role="tooltip"`. The popup is not focusable. |
235
+
236
+ ### Controlled usage
237
+
238
+ ```tsx
239
+ const [open, setOpen] = useState(false);
240
+
241
+ <Tooltip open={open} onOpenChange={(next, reason) => setOpen(next)}>
242
+ <TooltipTrigger>Edit profile</TooltipTrigger>
243
+ <TooltipContent>Update your profile information.</TooltipContent>
244
+ </Tooltip>;
245
+ ```
246
+
247
+ ### Arrow and animation configuration
248
+
249
+ ```tsx
250
+ <TooltipContent arrow arrowSize={6} animation={{ duration: 120 }}>
251
+ Update your profile information.
252
+ </TooltipContent>
253
+ ```
254
+
255
+ Options are the same as [Popover](https://github.com/zealakit/overlay/blob/main/packages/react/README.md#arrow-and-animation-configuration).
256
+
257
+ ### Disabled triggers
258
+
259
+ ```tsx
260
+ <Tooltip>
261
+ <TooltipTrigger asChild>
262
+ <span tabIndex={0}>
263
+ <button type="button" disabled>Edit profile</button>
264
+ </span>
265
+ </TooltipTrigger>
266
+ <TooltipContent>Editing is unavailable.</TooltipContent>
267
+ </Tooltip>
268
+ ```
269
+
270
+ A native disabled button cannot take focus, so wrap it in a focusable element. Use Popover instead when the content is interactive.
271
+
272
+ ## Dialog
273
+
274
+ ### Quick start
275
+
276
+ ```tsx
277
+ import {
278
+ Dialog,
279
+ DialogClose,
280
+ DialogContent,
281
+ DialogDescription,
282
+ DialogFooter,
283
+ DialogHeader,
284
+ DialogTitle,
285
+ DialogTrigger,
286
+ } from "@zealakit/overlay-react";
287
+
288
+ export function EditProfile() {
289
+ return (
290
+ <Dialog>
291
+ <DialogTrigger>Edit profile</DialogTrigger>
292
+ <DialogContent>
293
+ <DialogHeader>
294
+ <DialogTitle>Edit profile</DialogTitle>
295
+ <DialogDescription>Update your profile information.</DialogDescription>
296
+ </DialogHeader>
297
+ <DialogFooter>
298
+ <DialogClose>Cancel</DialogClose>
299
+ <button type="submit">Save</button>
300
+ </DialogFooter>
301
+ </DialogContent>
302
+ </Dialog>
303
+ );
304
+ }
305
+ ```
306
+
307
+ ### `Dialog` props
308
+
309
+ | Prop | Type | Default | Description |
310
+ | --- | --- | --- | --- |
311
+ | `open` | `boolean` | — | Controlled visibility. |
312
+ | `defaultOpen` | `boolean` | `false` | Initial visibility when uncontrolled. |
313
+ | `onOpenChange` | `(open: boolean, reason) => void` | — | `reason` is `trigger`, `outside-press`, `escape`, `close-button`, or `programmatic`. |
314
+ | `modal` | `boolean` | `true` | Modal: `aria-modal`, focus containment, inert background, scroll lock. |
315
+ | `lockScroll` | `boolean` | `modal` | Lock document scrolling while open. |
316
+ | `dismissOnEscape` | `boolean` | `true` | Close on Escape. |
317
+ | `dismissOnOutsidePress` | `boolean` | `true` | Close on a backdrop or outside press. |
318
+ | `dir` | `"ltr" \| "rtl"` | `"ltr"` | Direction passed to the popup. |
319
+ | `parentLayer` | `LayerStackHandle \| null` | — | Parent layer when nested in a custom layer. |
320
+ | `children` | `ReactNode` | — | `Dialog` renders no element, so no other props are forwarded. |
321
+
322
+ ### `DialogTrigger` props
323
+
324
+ | Prop | Type | Default | Description |
325
+ | --- | --- | --- | --- |
326
+ | `asChild` | `boolean` | `false` | Merge trigger behavior onto the single child. |
327
+ | `...button props` | `ComponentPropsWithoutRef<"button">` | — | Forwarded to the native `button`. Sets `aria-haspopup="dialog"`, `aria-expanded`, and `aria-controls`. |
328
+
329
+ ### `DialogContent` props
330
+
331
+ | Prop | Type | Default | Description |
332
+ | --- | --- | --- | --- |
333
+ | `backdrop` | `boolean` | `modal` | Render the structural backdrop. |
334
+ | `initialFocus` | `"container" \| "first" \| Element \| (() => Element \| null) \| null` | `"container"` when modal | Where focus lands on open; `null` keeps focus in place. |
335
+ | `finalFocus` | `Element \| (() => Element \| null) \| null` | — | Where focus returns on close; defaults to the trigger. |
336
+ | `restoreFocus` | `boolean` | `true` | Restore focus on close. |
337
+ | `keepMounted` | `boolean` | `false` | Keep closed content in the DOM as `hidden` for consumer transitions. |
338
+ | `animation` | `boolean \| AnimationConfig` | — | Off unless `true` or a config is passed. |
339
+ | `portal` | `boolean \| Element \| null` | `true` | `true` portals to `document.body`, an element selects a container, `false` renders in place. |
340
+ | `...div props` | `HTMLAttributes<HTMLDivElement>` | — | Forwarded to the popup `div` with `role="dialog"`. |
341
+
342
+ Add a `DialogTitle` or an `aria-label`; the dialog has no accessible name without one. `DialogHeader`, `DialogFooter`, and `DialogClose` are layout and close helpers; no close button is injected. `DialogPortal`, `DialogBackdrop`, `DialogViewport`, and `DialogPopup` are exported for advanced composition.
343
+
344
+ ### Controlled usage
345
+
346
+ ```tsx
347
+ const [open, setOpen] = useState(false);
348
+
349
+ <Dialog open={open} onOpenChange={(next, reason) => setOpen(next)}>
350
+ <DialogContent>
351
+ <DialogTitle>Edit profile</DialogTitle>
352
+ </DialogContent>
353
+ </Dialog>;
354
+ ```
355
+
356
+ ### Animation configuration
357
+
358
+ ```tsx
359
+ <DialogContent animation={{ duration: 200 }}>
360
+ <DialogTitle>Edit profile</DialogTitle>
361
+ </DialogContent>
362
+ ```
363
+
364
+ Options are the same as [Popover](https://github.com/zealakit/overlay/blob/main/packages/react/README.md#arrow-and-animation-configuration). The dialog zooms from the centre and the backdrop only fades.
365
+
366
+ ### `keepMounted`
367
+
368
+ Closed content unmounts by default. With `keepMounted` it stays as `hidden` with `data-state="closed"`. Focus containment and scroll lock release the moment the dialog closes, so exit transitions never leave the page modal.
369
+
370
+ ## ContextMenu
371
+
372
+ ### Quick start
373
+
374
+ ```tsx
375
+ import {
376
+ ContextMenu,
377
+ ContextMenuContent,
378
+ ContextMenuItem,
379
+ ContextMenuSeparator,
380
+ ContextMenuTrigger,
381
+ } from "@zealakit/overlay-react";
382
+
383
+ export function ProfileCard() {
384
+ return (
385
+ <ContextMenu>
386
+ <ContextMenuTrigger>Edit profile</ContextMenuTrigger>
387
+ <ContextMenuContent>
388
+ <ContextMenuItem onSelect={() => console.log("edit")}>Edit</ContextMenuItem>
389
+ <ContextMenuSeparator />
390
+ <ContextMenuItem disabled>Delete</ContextMenuItem>
391
+ </ContextMenuContent>
392
+ </ContextMenu>
393
+ );
394
+ }
395
+ ```
396
+
397
+ ### `ContextMenu` props
398
+
399
+ | Prop | Type | Default | Description |
400
+ | --- | --- | --- | --- |
401
+ | `open` | `boolean` | — | Controlled visibility. |
402
+ | `defaultOpen` | `boolean` | `false` | Initial visibility when uncontrolled. |
403
+ | `onOpenChange` | `(open: boolean, reason) => void` | — | `reason` is `trigger`, `outside-press`, `escape`, `select`, or `programmatic`. |
404
+ | `disabled` | `boolean` | `false` | Leaves the native browser menu untouched. |
405
+ | `dir` | `"ltr" \| "rtl"` | `"ltr"` | Direction; reverses submenu side and arrow keys. |
406
+ | `parentLayer` | `LayerStackHandle \| null` | — | Parent layer when nested in a custom layer. |
407
+ | `children` | `ReactNode` | — | `ContextMenu` renders no element, so no other props are forwarded. |
408
+
409
+ ### `ContextMenuTrigger` props
410
+
411
+ | Prop | Type | Default | Description |
412
+ | --- | --- | --- | --- |
413
+ | `asChild` | `boolean` | `false` | Use an existing element as the target. |
414
+ | `disabled` | `boolean` | `false` | Ignore invocation. |
415
+ | `...div props` | `ComponentPropsWithoutRef<"div">` | — | Forwarded to a focusable `div`. Right-click, the Context Menu key, and Shift+F10 open the menu. |
416
+
417
+ Pointer invocation anchors at the cursor; keyboard invocation anchors at the trigger. Give the trigger a role or label that fits your target.
418
+
419
+ ### `ContextMenuContent` props
420
+
421
+ | Prop | Type | Default | Description |
422
+ | --- | --- | --- | --- |
423
+ | `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | Physical side of the anchor. |
424
+ | `align` | `"start" \| "center" \| "end"` | `"start"` | Follows `dir` for top and bottom sides. |
425
+ | `sideOffset` / `alignOffset` / `collisionPadding` | `number` | `0` | Offsets and boundary gap in pixels. |
426
+ | `collisionBoundary` / `collisionAvoidance` / `positionMethod` | — | — | Same as Popover. |
427
+ | `animation` | `boolean \| AnimationConfig` | — | Off unless `true` or a config is passed. |
428
+ | `portal` | `boolean \| Element \| null` | `true` | `true` portals to `document.body`, an element selects a container, `false` renders in place. |
429
+ | `...div props` | `HTMLAttributes<HTMLDivElement>` | — | Forwarded to the popup `div` with `role="menu"`. Arrow keys, Home, End, and typeahead move focus; the menu is not focus-trapped. |
430
+
431
+ ### `ContextMenuItem` props
432
+
433
+ | Prop | Type | Default | Description |
434
+ | --- | --- | --- | --- |
435
+ | `disabled` | `boolean` | `false` | Skipped by keyboard navigation and never activates. |
436
+ | `onSelect` | `(event) => void` | — | Receives an event with `preventDefault()` and `originalEvent`. |
437
+ | `closeOnSelect` | `boolean` | `true` | Set `false` or call `event.preventDefault()` to keep the menu open. |
438
+ | `asChild` | `boolean` | `false` | Use your own element as the item. |
439
+ | `...div props` | `ComponentPropsWithoutRef<"div">` | — | Forwarded to the item `div` with `role="menuitem"`. |
440
+
441
+ ### `ContextMenuCheckboxItem` / `ContextMenuRadioGroup` / `ContextMenuRadioItem` props
442
+
443
+ | Prop | Type | Default | Description |
444
+ | --- | --- | --- | --- |
445
+ | `checked` / `defaultChecked` | `boolean` | — | Checkbox item state, controlled or uncontrolled. |
446
+ | `onCheckedChange` | `(checked: boolean) => void` | — | Called when a checkbox item toggles. |
447
+ | `value` / `defaultValue` | `string` | — | `RadioGroup` selected value; `RadioItem` requires `value`. |
448
+ | `onValueChange` | `(value: string) => void` | — | Called when the radio selection changes. |
449
+ | `closeOnSelect` | `boolean` | `false` | Checkbox and radio items keep the menu open by default. |
450
+ | `...div props` | `ComponentPropsWithoutRef<"div">` | — | Forwarded with `role="menuitemcheckbox"` or `role="menuitemradio"` and `aria-checked`. |
451
+
452
+ `ContextMenuGroup`, `ContextMenuLabel`, `ContextMenuSeparator`, and `ContextMenuShortcut` are structural. Submenus use `ContextMenuSub` (`defaultOpen`, uncontrolled), `ContextMenuSubTrigger`, and `ContextMenuSubContent`, which takes the same positioning props as `ContextMenuContent` and opens to the right in LTR and left in RTL.
453
+
454
+ ### Controlled usage
455
+
456
+ ```tsx
457
+ const [open, setOpen] = useState(false);
458
+
459
+ <ContextMenu open={open} onOpenChange={(next, reason) => setOpen(next)}>
460
+ <ContextMenuTrigger>Edit profile</ContextMenuTrigger>
461
+ <ContextMenuContent>
462
+ <ContextMenuItem>Edit</ContextMenuItem>
463
+ </ContextMenuContent>
464
+ </ContextMenu>;
465
+ ```
466
+
467
+ ### Animation configuration
468
+
469
+ ```tsx
470
+ <ContextMenuContent animation={{ type: "expand", duration: 160 }}>
471
+ <ContextMenuItem>Edit</ContextMenuItem>
472
+ </ContextMenuContent>
473
+ ```
474
+
475
+ Options are the same as [Popover](https://github.com/zealakit/overlay/blob/main/packages/react/README.md#arrow-and-animation-configuration). ContextMenu has no arrow.
476
+
477
+ ### `onSelect`
478
+
479
+ ```tsx
480
+ <ContextMenuItem
481
+ onSelect={(event) => {
482
+ event.preventDefault(); // keep the menu open
483
+ console.log(event.originalEvent);
484
+ }}
485
+ >
486
+ Edit
487
+ </ContextMenuItem>
488
+ ```
489
+
490
+ Selecting an item closes the whole menu tree. Escape and outside presses close only the topmost submenu first.
491
+
492
+ ## Hooks
493
+
494
+ | Export | Purpose |
495
+ | --- | --- |
496
+ | `usePositioner(options)` | Callback refs plus the latest `PositionerResult`; accepts core positioner options and an explicit `reference`. |
497
+ | `useLayer(options)` | Register a layer while mounted: `element`, `reference`, `parent`, `boundaries`, `dismissOnEscape`, `dismissOnOutsidePress`, `onDismiss`. |
498
+ | `useOverlay(options)` | Uncontrolled open state composed from the two hooks above; returns `isOpen`, `open`, `close`, `toggle`, refs, and `floatingStyles`. |
499
+ | `useEscapeKey(handler, options?)` | Escape listener with `enabled` and `target`. |
500
+ | `Portal` | Render children into `document.body` or a container after mount; renders `null` on the server. |
501
+
502
+ ```tsx
503
+ const { referenceRef, floatingRef, result } = usePositioner({
504
+ placement: "bottom-start",
505
+ offset: 8,
506
+ });
507
+
508
+ <button ref={referenceRef}>Edit profile</button>;
509
+ <div
510
+ ref={floatingRef}
511
+ style={{ position: result?.strategy ?? "fixed", left: result?.x ?? 0, top: result?.y ?? 0 }}
512
+ />;
513
+ ```
514
+
515
+ Hooks create core objects in effects, never during render, and are safe under Strict Mode. Core focus helpers (`createFocusContainment`, `focusElement`, `focusFirst`, `getFocusableElements`, `isFocusable`, `getActiveElement`, `restoreFocus`) are re-exported.
516
+
517
+ ## Styling hooks
518
+
519
+ | Attribute | Where | Purpose |
520
+ | --- | --- | --- |
521
+ | `data-state` | Popup, trigger | `"open"` or `"closed"`; `"closed"` is observable with `keepMounted` or `animation`. |
522
+ | `data-open` / `data-closed` | Popup | Presence flags for CSS selectors. |
523
+ | `data-side` / `data-align` | Popup, arrow | Resolved placement after flip and shift. |
524
+ | `data-animating` | Popup | `"enter"` or `"exit"` while an animation runs. |
525
+ | `data-modal` / `data-non-modal` / `data-nested` / `data-nested-dialog-open` | Dialog popup | Mode and nesting state. |
526
+ | `data-disabled` | Menu items | Set on disabled items. |
527
+ | `--popover-anchor-width` / `--popover-anchor-height` | Popover popup | Trigger size, for matching widths. |
528
+ | `--tooltip-anchor-width` / `--tooltip-anchor-height` | Tooltip popup | Trigger size. |
529
+ | `--overlay-transform-origin` | Popup | Anchor-edge origin for class-based animation. |
530
+ | `--overlay-arrow-*` | Panel or ancestor | Arrow background, border width, and border color. |
531
+
532
+ ## Next.js App Router
533
+
534
+ Every entry carries `"use client"`, so import the components from client components. Importing is safe on the server, and overlay content renders only after mount.
535
+
536
+ ```tsx
537
+ "use client";
538
+
539
+ import { Popover, PopoverContent, PopoverTrigger } from "@zealakit/overlay-react";
540
+ ```
541
+
542
+ ## Agent Skill
543
+
544
+ Add the [Overlay React skill](https://github.com/zealakit/overlay/blob/main/skills/overlay-react.md) to your agent's skills directory so it can follow the component, styling, and accessibility rules for this package.
545
+
546
+ ## License
547
+
548
+ MIT © Zealakit
@@ -0,0 +1 @@
1
+ export { OverlayPresenceContext, useOverlayElementAnimation, useOverlayPresence, useOverlayPresenceContext, type OverlayPresence, type OverlayPresenceContextValue, type OverlayPresentationPhase, } from "./presence.js";
@@ -0,0 +1 @@
1
+ export { OverlayPresenceContext, useOverlayElementAnimation, useOverlayPresence, useOverlayPresenceContext, } from "./presence.js";
@@ -0,0 +1,31 @@
1
+ import { type AnimationSetting, type ResolvedAnimationConfig } from "../vendor/core/index.js";
2
+ export type OverlayPresentationPhase = "idle" | "enter" | "exit";
3
+ export type OverlayPresence = {
4
+ present: boolean;
5
+ phase: OverlayPresentationPhase;
6
+ animation: ResolvedAnimationConfig;
7
+ finishExit(): void;
8
+ };
9
+ export type OverlayPresenceContextValue = OverlayPresence;
10
+ /** Internal context shared by convenience Content trees and advanced parts. */
11
+ export declare const OverlayPresenceContext: import("react").Context<OverlayPresence | null>;
12
+ export declare function useOverlayPresenceContext(): OverlayPresenceContextValue | null;
13
+ /**
14
+ * Hold a popup in the DOM while its exit animation runs. The element animation
15
+ * is owned by useOverlayElementAnimation; this hook only owns open/exit state.
16
+ */
17
+ export declare function useOverlayPresence(open: boolean, setting: AnimationSetting | undefined): OverlayPresence;
18
+ type ElementAnimationOptions = {
19
+ element: HTMLElement | null;
20
+ phase: OverlayPresentationPhase;
21
+ animation: ResolvedAnimationConfig;
22
+ placement?: string;
23
+ onExitComplete: () => void;
24
+ };
25
+ /**
26
+ * Drive the core animation runner for the floating element. Positioning uses
27
+ * left/top; the runner uses opacity/translate or CSS animation, so the two
28
+ * never compete.
29
+ */
30
+ export declare function useOverlayElementAnimation({ element, phase, animation, placement, onExitComplete, }: ElementAnimationOptions): void;
31
+ export {};