@atlaskit/top-layer 0.1.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 +44 -0
- package/README.md +151 -0
- package/animations/package.json +17 -0
- package/arrow/package.json +17 -0
- package/create-close-event/package.json +17 -0
- package/dialog/package.json +17 -0
- package/dialog-scroll-lock/package.json +17 -0
- package/dist/cjs/animations/presets.js +199 -0
- package/dist/cjs/animations/types.js +5 -0
- package/dist/cjs/arrow/index.js +130 -0
- package/dist/cjs/arrow/types.js +5 -0
- package/dist/cjs/dialog/create-close-event.js +39 -0
- package/dist/cjs/dialog/dialog-content.compiled.css +14 -0
- package/dist/cjs/dialog/dialog-content.js +144 -0
- package/dist/cjs/dialog/index.js +19 -0
- package/dist/cjs/dialog/types.js +5 -0
- package/dist/cjs/dialog-scroll-lock/index.js +46 -0
- package/dist/cjs/entry-points/animations.js +36 -0
- package/dist/cjs/entry-points/arrow.js +12 -0
- package/dist/cjs/entry-points/create-close-event.js +19 -0
- package/dist/cjs/entry-points/dialog-scroll-lock.js +12 -0
- package/dist/cjs/entry-points/dialog.js +12 -0
- package/dist/cjs/entry-points/focus.js +24 -0
- package/dist/cjs/entry-points/placement-map.js +18 -0
- package/dist/cjs/entry-points/popover.js +12 -0
- package/dist/cjs/entry-points/popup-surface.js +12 -0
- package/dist/cjs/entry-points/popup.js +12 -0
- package/dist/cjs/entry-points/use-anchor-position.js +12 -0
- package/dist/cjs/entry-points/use-arrow-navigation.js +18 -0
- package/dist/cjs/entry-points/use-simple-light-dismiss.js +12 -0
- package/dist/cjs/focus/focus.js +115 -0
- package/dist/cjs/focus/index.js +24 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/internal/anchor-positioning-fallback.js +154 -0
- package/dist/cjs/internal/combine.js +29 -0
- package/dist/cjs/internal/ensure-preset-styles.js +34 -0
- package/dist/cjs/internal/reduced-motion.js +27 -0
- package/dist/cjs/internal/resolve-placement.js +24 -0
- package/dist/cjs/internal/role-types.js +66 -0
- package/dist/cjs/internal/set-style.js +42 -0
- package/dist/cjs/internal/slot.js +65 -0
- package/dist/cjs/internal/use-anchor-positioning.js +336 -0
- package/dist/cjs/internal/use-animated-visibility.js +169 -0
- package/dist/cjs/internal/use-animation-preset.js +24 -0
- package/dist/cjs/internal/use-focus-wrap.js +94 -0
- package/dist/cjs/internal/use-initial-focus.js +112 -0
- package/dist/cjs/internal/use-preset-styles.js +27 -0
- package/dist/cjs/placement-map/index.js +147 -0
- package/dist/cjs/popover/create-close-event.js +44 -0
- package/dist/cjs/popover/index.js +19 -0
- package/dist/cjs/popover/popover.compiled.css +13 -0
- package/dist/cjs/popover/popover.js +251 -0
- package/dist/cjs/popover/types.js +5 -0
- package/dist/cjs/popup/index.js +37 -0
- package/dist/cjs/popup/popup-content.js +201 -0
- package/dist/cjs/popup/popup-context.js +42 -0
- package/dist/cjs/popup/popup-surface.compiled.css +5 -0
- package/dist/cjs/popup/popup-surface.js +30 -0
- package/dist/cjs/popup/popup-trigger-function.js +74 -0
- package/dist/cjs/popup/popup-trigger.js +82 -0
- package/dist/cjs/popup/popup.js +70 -0
- package/dist/cjs/popup/types.js +5 -0
- package/dist/cjs/use-arrow-navigation/index.js +18 -0
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +245 -0
- package/dist/cjs/use-simple-light-dismiss/index.js +84 -0
- package/dist/es2019/animations/presets.js +375 -0
- package/dist/es2019/animations/types.js +1 -0
- package/dist/es2019/arrow/index.js +249 -0
- package/dist/es2019/arrow/types.js +1 -0
- package/dist/es2019/dialog/create-close-event.js +34 -0
- package/dist/es2019/dialog/dialog-content.compiled.css +14 -0
- package/dist/es2019/dialog/dialog-content.js +138 -0
- package/dist/es2019/dialog/index.js +2 -0
- package/dist/es2019/dialog/types.js +1 -0
- package/dist/es2019/dialog-scroll-lock/index.js +41 -0
- package/dist/es2019/entry-points/animations.js +1 -0
- package/dist/es2019/entry-points/arrow.js +1 -0
- package/dist/es2019/entry-points/create-close-event.js +2 -0
- package/dist/es2019/entry-points/dialog-scroll-lock.js +1 -0
- package/dist/es2019/entry-points/dialog.js +1 -0
- package/dist/es2019/entry-points/focus.js +1 -0
- package/dist/es2019/entry-points/placement-map.js +1 -0
- package/dist/es2019/entry-points/popover.js +1 -0
- package/dist/es2019/entry-points/popup-surface.js +1 -0
- package/dist/es2019/entry-points/popup.js +1 -0
- package/dist/es2019/entry-points/use-anchor-position.js +1 -0
- package/dist/es2019/entry-points/use-arrow-navigation.js +1 -0
- package/dist/es2019/entry-points/use-simple-light-dismiss.js +1 -0
- package/dist/es2019/focus/focus.js +107 -0
- package/dist/es2019/focus/index.js +1 -0
- package/dist/es2019/index.js +7 -0
- package/dist/es2019/internal/anchor-positioning-fallback.js +153 -0
- package/dist/es2019/internal/combine.js +18 -0
- package/dist/es2019/internal/ensure-preset-styles.js +29 -0
- package/dist/es2019/internal/reduced-motion.js +21 -0
- package/dist/es2019/internal/resolve-placement.js +19 -0
- package/dist/es2019/internal/role-types.js +61 -0
- package/dist/es2019/internal/set-style.js +39 -0
- package/dist/es2019/internal/slot.js +57 -0
- package/dist/es2019/internal/use-anchor-positioning.js +330 -0
- package/dist/es2019/internal/use-animated-visibility.js +159 -0
- package/dist/es2019/internal/use-animation-preset.js +18 -0
- package/dist/es2019/internal/use-focus-wrap.js +90 -0
- package/dist/es2019/internal/use-initial-focus.js +109 -0
- package/dist/es2019/internal/use-preset-styles.js +22 -0
- package/dist/es2019/placement-map/index.js +142 -0
- package/dist/es2019/popover/create-close-event.js +39 -0
- package/dist/es2019/popover/index.js +2 -0
- package/dist/es2019/popover/popover.compiled.css +13 -0
- package/dist/es2019/popover/popover.js +240 -0
- package/dist/es2019/popover/types.js +1 -0
- package/dist/es2019/popup/index.js +33 -0
- package/dist/es2019/popup/popup-content.js +192 -0
- package/dist/es2019/popup/popup-context.js +34 -0
- package/dist/es2019/popup/popup-surface.compiled.css +5 -0
- package/dist/es2019/popup/popup-surface.js +24 -0
- package/dist/es2019/popup/popup-trigger-function.js +69 -0
- package/dist/es2019/popup/popup-trigger.js +76 -0
- package/dist/es2019/popup/popup.js +56 -0
- package/dist/es2019/popup/types.js +1 -0
- package/dist/es2019/use-arrow-navigation/index.js +1 -0
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +238 -0
- package/dist/es2019/use-simple-light-dismiss/index.js +79 -0
- package/dist/esm/animations/presets.js +190 -0
- package/dist/esm/animations/types.js +1 -0
- package/dist/esm/arrow/index.js +123 -0
- package/dist/esm/arrow/types.js +1 -0
- package/dist/esm/dialog/create-close-event.js +33 -0
- package/dist/esm/dialog/dialog-content.compiled.css +14 -0
- package/dist/esm/dialog/dialog-content.js +135 -0
- package/dist/esm/dialog/index.js +2 -0
- package/dist/esm/dialog/types.js +1 -0
- package/dist/esm/dialog-scroll-lock/index.js +41 -0
- package/dist/esm/entry-points/animations.js +1 -0
- package/dist/esm/entry-points/arrow.js +1 -0
- package/dist/esm/entry-points/create-close-event.js +2 -0
- package/dist/esm/entry-points/dialog-scroll-lock.js +1 -0
- package/dist/esm/entry-points/dialog.js +1 -0
- package/dist/esm/entry-points/focus.js +1 -0
- package/dist/esm/entry-points/placement-map.js +1 -0
- package/dist/esm/entry-points/popover.js +1 -0
- package/dist/esm/entry-points/popup-surface.js +1 -0
- package/dist/esm/entry-points/popup.js +1 -0
- package/dist/esm/entry-points/use-anchor-position.js +1 -0
- package/dist/esm/entry-points/use-arrow-navigation.js +1 -0
- package/dist/esm/entry-points/use-simple-light-dismiss.js +1 -0
- package/dist/esm/focus/focus.js +107 -0
- package/dist/esm/focus/index.js +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/internal/anchor-positioning-fallback.js +147 -0
- package/dist/esm/internal/combine.js +23 -0
- package/dist/esm/internal/ensure-preset-styles.js +28 -0
- package/dist/esm/internal/reduced-motion.js +21 -0
- package/dist/esm/internal/resolve-placement.js +18 -0
- package/dist/esm/internal/role-types.js +60 -0
- package/dist/esm/internal/set-style.js +36 -0
- package/dist/esm/internal/slot.js +59 -0
- package/dist/esm/internal/use-anchor-positioning.js +323 -0
- package/dist/esm/internal/use-animated-visibility.js +162 -0
- package/dist/esm/internal/use-animation-preset.js +18 -0
- package/dist/esm/internal/use-focus-wrap.js +89 -0
- package/dist/esm/internal/use-initial-focus.js +107 -0
- package/dist/esm/internal/use-preset-styles.js +21 -0
- package/dist/esm/placement-map/index.js +141 -0
- package/dist/esm/popover/create-close-event.js +38 -0
- package/dist/esm/popover/index.js +2 -0
- package/dist/esm/popover/popover.compiled.css +13 -0
- package/dist/esm/popover/popover.js +242 -0
- package/dist/esm/popover/types.js +1 -0
- package/dist/esm/popup/index.js +33 -0
- package/dist/esm/popup/popup-content.js +192 -0
- package/dist/esm/popup/popup-context.js +34 -0
- package/dist/esm/popup/popup-surface.compiled.css +5 -0
- package/dist/esm/popup/popup-surface.js +23 -0
- package/dist/esm/popup/popup-trigger-function.js +69 -0
- package/dist/esm/popup/popup-trigger.js +74 -0
- package/dist/esm/popup/popup.js +61 -0
- package/dist/esm/popup/types.js +1 -0
- package/dist/esm/use-arrow-navigation/index.js +1 -0
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +238 -0
- package/dist/esm/use-simple-light-dismiss/index.js +78 -0
- package/dist/types/animations/presets.d.ts +94 -0
- package/dist/types/animations/types.d.ts +42 -0
- package/dist/types/arrow/index.d.ts +24 -0
- package/dist/types/arrow/types.d.ts +29 -0
- package/dist/types/dialog/create-close-event.d.ts +24 -0
- package/dist/types/dialog/dialog-content.d.ts +20 -0
- package/dist/types/dialog/index.d.ts +3 -0
- package/dist/types/dialog/types.d.ts +92 -0
- package/dist/types/dialog-scroll-lock/index.d.ts +24 -0
- package/dist/types/entry-points/animations.d.ts +2 -0
- package/dist/types/entry-points/arrow.d.ts +2 -0
- package/dist/types/entry-points/create-close-event.d.ts +4 -0
- package/dist/types/entry-points/dialog-scroll-lock.d.ts +1 -0
- package/dist/types/entry-points/dialog.d.ts +2 -0
- package/dist/types/entry-points/focus.d.ts +2 -0
- package/dist/types/entry-points/placement-map.d.ts +2 -0
- package/dist/types/entry-points/popover.d.ts +2 -0
- package/dist/types/entry-points/popup-surface.d.ts +2 -0
- package/dist/types/entry-points/popup.d.ts +2 -0
- package/dist/types/entry-points/use-anchor-position.d.ts +1 -0
- package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -0
- package/dist/types/entry-points/use-simple-light-dismiss.d.ts +2 -0
- package/dist/types/focus/focus.d.ts +42 -0
- package/dist/types/focus/index.d.ts +2 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/internal/anchor-positioning-fallback.d.ts +24 -0
- package/dist/types/internal/combine.d.ts +14 -0
- package/dist/types/internal/ensure-preset-styles.d.ts +6 -0
- package/dist/types/internal/reduced-motion.d.ts +14 -0
- package/dist/types/internal/resolve-placement.d.ts +16 -0
- package/dist/types/internal/role-types.d.ts +62 -0
- package/dist/types/internal/set-style.d.ts +28 -0
- package/dist/types/internal/slot.d.ts +29 -0
- package/dist/types/internal/use-anchor-positioning.d.ts +95 -0
- package/dist/types/internal/use-animated-visibility.d.ts +74 -0
- package/dist/types/internal/use-animation-preset.d.ts +11 -0
- package/dist/types/internal/use-focus-wrap.d.ts +20 -0
- package/dist/types/internal/use-initial-focus.d.ts +21 -0
- package/dist/types/internal/use-preset-styles.d.ts +15 -0
- package/dist/types/placement-map/index.d.ts +55 -0
- package/dist/types/popover/create-close-event.d.ts +26 -0
- package/dist/types/popover/index.d.ts +3 -0
- package/dist/types/popover/popover.d.ts +22 -0
- package/dist/types/popover/types.d.ts +153 -0
- package/dist/types/popup/index.d.ts +34 -0
- package/dist/types/popup/popup-content.d.ts +14 -0
- package/dist/types/popup/popup-context.d.ts +96 -0
- package/dist/types/popup/popup-surface.d.ts +16 -0
- package/dist/types/popup/popup-trigger-function.d.ts +108 -0
- package/dist/types/popup/popup-trigger.d.ts +23 -0
- package/dist/types/popup/popup.d.ts +14 -0
- package/dist/types/popup/types.d.ts +289 -0
- package/dist/types/use-arrow-navigation/index.d.ts +2 -0
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +136 -0
- package/dist/types/use-simple-light-dismiss/index.d.ts +45 -0
- package/dist/types-ts4.5/animations/presets.d.ts +94 -0
- package/dist/types-ts4.5/animations/types.d.ts +42 -0
- package/dist/types-ts4.5/arrow/index.d.ts +24 -0
- package/dist/types-ts4.5/arrow/types.d.ts +29 -0
- package/dist/types-ts4.5/dialog/create-close-event.d.ts +24 -0
- package/dist/types-ts4.5/dialog/dialog-content.d.ts +20 -0
- package/dist/types-ts4.5/dialog/index.d.ts +3 -0
- package/dist/types-ts4.5/dialog/types.d.ts +92 -0
- package/dist/types-ts4.5/dialog-scroll-lock/index.d.ts +24 -0
- package/dist/types-ts4.5/entry-points/animations.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/arrow.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/create-close-event.d.ts +4 -0
- package/dist/types-ts4.5/entry-points/dialog-scroll-lock.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/dialog.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/focus.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/placement-map.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popover.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popup-surface.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popup.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/use-anchor-position.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/use-simple-light-dismiss.d.ts +2 -0
- package/dist/types-ts4.5/focus/focus.d.ts +42 -0
- package/dist/types-ts4.5/focus/index.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +0 -0
- package/dist/types-ts4.5/internal/anchor-positioning-fallback.d.ts +24 -0
- package/dist/types-ts4.5/internal/combine.d.ts +14 -0
- package/dist/types-ts4.5/internal/ensure-preset-styles.d.ts +6 -0
- package/dist/types-ts4.5/internal/reduced-motion.d.ts +14 -0
- package/dist/types-ts4.5/internal/resolve-placement.d.ts +16 -0
- package/dist/types-ts4.5/internal/role-types.d.ts +62 -0
- package/dist/types-ts4.5/internal/set-style.d.ts +28 -0
- package/dist/types-ts4.5/internal/slot.d.ts +29 -0
- package/dist/types-ts4.5/internal/use-anchor-positioning.d.ts +95 -0
- package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +74 -0
- package/dist/types-ts4.5/internal/use-animation-preset.d.ts +11 -0
- package/dist/types-ts4.5/internal/use-focus-wrap.d.ts +20 -0
- package/dist/types-ts4.5/internal/use-initial-focus.d.ts +21 -0
- package/dist/types-ts4.5/internal/use-preset-styles.d.ts +15 -0
- package/dist/types-ts4.5/placement-map/index.d.ts +55 -0
- package/dist/types-ts4.5/popover/create-close-event.d.ts +26 -0
- package/dist/types-ts4.5/popover/index.d.ts +3 -0
- package/dist/types-ts4.5/popover/popover.d.ts +22 -0
- package/dist/types-ts4.5/popover/types.d.ts +153 -0
- package/dist/types-ts4.5/popup/index.d.ts +34 -0
- package/dist/types-ts4.5/popup/popup-content.d.ts +14 -0
- package/dist/types-ts4.5/popup/popup-context.d.ts +96 -0
- package/dist/types-ts4.5/popup/popup-surface.d.ts +16 -0
- package/dist/types-ts4.5/popup/popup-trigger-function.d.ts +108 -0
- package/dist/types-ts4.5/popup/popup-trigger.d.ts +23 -0
- package/dist/types-ts4.5/popup/popup.d.ts +14 -0
- package/dist/types-ts4.5/popup/types.d.ts +289 -0
- package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -0
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +136 -0
- package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +45 -0
- package/focus/package.json +17 -0
- package/package.json +95 -0
- package/placement-map/package.json +17 -0
- package/popover/package.json +17 -0
- package/popup/package.json +17 -0
- package/popup-surface/package.json +17 -0
- package/use-anchor-position/package.json +17 -0
- package/use-arrow-navigation/package.json +17 -0
- package/use-simple-light-dismiss/package.json +17 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type TDialogProps } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Low-level `<dialog>` primitive. No visual opinions — no width, height,
|
|
9
|
+
* background, border-radius, or layout. Consumers provide their own styling.
|
|
10
|
+
*
|
|
11
|
+
* Visibility is controlled declaratively via `isOpen`:
|
|
12
|
+
* - `isOpen={true}` calls `.showModal()` (entry animation via `@starting-style`)
|
|
13
|
+
* - `isOpen={false}` calls `.close()` (exit animation via `allow-discrete`)
|
|
14
|
+
*
|
|
15
|
+
* Handles native `cancel` event (Escape) and backdrop click detection.
|
|
16
|
+
*
|
|
17
|
+
* Close flow: we never call `dialog.close()` from event handlers. We always call
|
|
18
|
+
* `onClose`; the consumer decides whether to set `isOpen={false}`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const Dialog: React.ForwardRefExoticComponent<TDialogProps & React.RefAttributes<HTMLDialogElement>>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type TAnimationPreset } from '../animations/types';
|
|
3
|
+
/**
|
|
4
|
+
* Close reasons produced by the Dialog primitive.
|
|
5
|
+
*
|
|
6
|
+
* - `'escape'` — user pressed Escape (native `cancel` event on `<dialog>`).
|
|
7
|
+
* - `'overlay-click'` — user clicked the backdrop / overlay area.
|
|
8
|
+
*
|
|
9
|
+
* Consumer-initiated ("programmatic") close is not a reason the primitive
|
|
10
|
+
* produces — the consumer simply sets `isOpen={false}`.
|
|
11
|
+
*/
|
|
12
|
+
export type TDialogCloseReason = 'escape' | 'overlay-click';
|
|
13
|
+
/**
|
|
14
|
+
* Props for the `Dialog` primitive.
|
|
15
|
+
*
|
|
16
|
+
* Low-level wrapper around the native `<dialog>` element.
|
|
17
|
+
* Manages visibility (`showModal()` / `close()`), animation, Escape handling,
|
|
18
|
+
* and backdrop-click detection. Has no visual opinions — no width, height,
|
|
19
|
+
* background, border-radius, or layout. Consumers (e.g. `@atlaskit/modal-dialog`)
|
|
20
|
+
* provide their own visual styling.
|
|
21
|
+
*/
|
|
22
|
+
export type TDialogProps = {
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the dialog is open.
|
|
26
|
+
*
|
|
27
|
+
* - `true`: calls `showModal()`, entry animation plays via `@starting-style`.
|
|
28
|
+
* - `false`: calls `close()`. When an `animate` preset is provided, the exit
|
|
29
|
+
* animation plays (via `allow-discrete`) before the dialog becomes logically closed.
|
|
30
|
+
*
|
|
31
|
+
* The element stays mounted in the DOM — visibility is controlled declaratively.
|
|
32
|
+
*/
|
|
33
|
+
isOpen: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Called when the user triggers close via Escape or backdrop click.
|
|
36
|
+
*
|
|
37
|
+
* The dialog does **not** close itself — the consumer decides whether to
|
|
38
|
+
* set `isOpen={false}` (e.g. gate by reason).
|
|
39
|
+
*/
|
|
40
|
+
onClose: (args: {
|
|
41
|
+
reason: TDialogCloseReason;
|
|
42
|
+
}) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Animation preset for entry/exit transitions.
|
|
45
|
+
*
|
|
46
|
+
* Pass an `TAnimationPreset` (e.g. `dialogSlideUpAndFade()`) to enable
|
|
47
|
+
* CSS-based entry and exit animation. Pass `false` (or omit) to disable.
|
|
48
|
+
*/
|
|
49
|
+
animate?: TAnimationPreset | false;
|
|
50
|
+
/**
|
|
51
|
+
* Additional inline styles applied to the `<dialog>` element.
|
|
52
|
+
*
|
|
53
|
+
* Use for custom width, height, transform, or other overrides.
|
|
54
|
+
*/
|
|
55
|
+
style?: CSSProperties;
|
|
56
|
+
/**
|
|
57
|
+
* Test ID applied to the `<dialog>` element.
|
|
58
|
+
*/
|
|
59
|
+
testId?: string;
|
|
60
|
+
/**
|
|
61
|
+
* HTML `id` attribute for the `<dialog>` element.
|
|
62
|
+
*/
|
|
63
|
+
id?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Accessible label (`aria-label`).
|
|
66
|
+
*
|
|
67
|
+
* When provided, `aria-labelledby` is not set.
|
|
68
|
+
* Use when there is no visible title element to reference.
|
|
69
|
+
*/
|
|
70
|
+
label?: string;
|
|
71
|
+
/**
|
|
72
|
+
* ID of the element that labels the dialog (`aria-labelledby`).
|
|
73
|
+
*
|
|
74
|
+
* Ignored when `label` is provided.
|
|
75
|
+
*/
|
|
76
|
+
labelledBy?: string;
|
|
77
|
+
/**
|
|
78
|
+
* When true, the `::backdrop` pseudo-element is rendered transparent.
|
|
79
|
+
*
|
|
80
|
+
* Useful for stacked dialogs where only the foreground dialog should
|
|
81
|
+
* show a visible backdrop, or when the consumer wants no overlay.
|
|
82
|
+
*/
|
|
83
|
+
shouldHideBackdrop?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Called after the exit animation completes (or immediately on close when
|
|
86
|
+
* there is no animation or reduced motion is active).
|
|
87
|
+
*
|
|
88
|
+
* Use this for external lifecycle coordination — e.g. firing an
|
|
89
|
+
* `onCloseComplete` callback or notifying ExitingPersistence.
|
|
90
|
+
*/
|
|
91
|
+
onExitFinish?: () => void;
|
|
92
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* __DialogScrollLock__
|
|
3
|
+
*
|
|
4
|
+
* Prevents background page scrolling while mounted. Designed to be rendered
|
|
5
|
+
* inside a `Dialog` so that the scroll lock is automatically removed when the
|
|
6
|
+
* dialog closes (unmounts its children).
|
|
7
|
+
*
|
|
8
|
+
* Native `<dialog>.showModal()` makes background content _inert_ (not
|
|
9
|
+
* focusable/clickable), but does **not** prevent scroll events from reaching
|
|
10
|
+
* the document body. This component fills that gap by setting
|
|
11
|
+
* `overflow: hidden` on `document.body`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { Dialog } from '@atlaskit/top-layer/dialog';
|
|
16
|
+
* import { DialogScrollLock } from '@atlaskit/top-layer/dialog-scroll-lock';
|
|
17
|
+
*
|
|
18
|
+
* <Dialog isOpen={isOpen} onClose={onClose}>
|
|
19
|
+
* <DialogScrollLock />
|
|
20
|
+
* {children}
|
|
21
|
+
* </Dialog>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function DialogScrollLock(): null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DialogScrollLock } from '../dialog-scroll-lock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAnchorPosition } from '../internal/use-anchor-positioning';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focusable element selectors and navigation helpers.
|
|
3
|
+
*
|
|
4
|
+
* Uses CSS selectors to discover focusable elements within a container,
|
|
5
|
+
* avoiding the need for a manual registration system. Disabled elements
|
|
6
|
+
* (both HTML `disabled` attribute and `aria-disabled="true"`) and elements
|
|
7
|
+
* with `tabindex="-1"` are excluded automatically.
|
|
8
|
+
*
|
|
9
|
+
* All public functions accept an optional `filter` callback to further
|
|
10
|
+
* restrict which focusable elements are included.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* An optional callback to restrict which focusable elements are included.
|
|
14
|
+
* Return `true` to include the element, `false` to skip it.
|
|
15
|
+
*/
|
|
16
|
+
export type TFocusableFilter = (element: HTMLElement, container: HTMLElement) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the first focusable element within the container.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getFirstFocusable({ container, filter, }: {
|
|
21
|
+
container: HTMLElement;
|
|
22
|
+
filter?: TFocusableFilter;
|
|
23
|
+
}): HTMLElement | null;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the last focusable element within the container.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getLastFocusable({ container, filter, }: {
|
|
28
|
+
container: HTMLElement;
|
|
29
|
+
filter?: TFocusableFilter;
|
|
30
|
+
}): HTMLElement | null;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the next focusable element in the given direction relative to the
|
|
33
|
+
* currently focused element within the container. Wraps around at both ends.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` if there is no focused element within the container or if
|
|
36
|
+
* the focused element is not in the list of focusable elements.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getNextFocusable({ container, direction, filter, }: {
|
|
39
|
+
container: HTMLElement;
|
|
40
|
+
direction: 'forwards' | 'backwards';
|
|
41
|
+
filter?: TFocusableFilter;
|
|
42
|
+
}): HTMLElement | null;
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type TPlacement } from './resolve-placement';
|
|
2
|
+
/**
|
|
3
|
+
* JS fallback: compute popover position from trigger rect and viewport.
|
|
4
|
+
*
|
|
5
|
+
* Placement algorithm (from the document):
|
|
6
|
+
* - "block" placement: show above/below, picking the side with more space if flipping needed
|
|
7
|
+
* - "inline" placement: show left/right, picking the side with more space if flipping needed
|
|
8
|
+
* - "auto" placement: show on the edge with the most available space
|
|
9
|
+
*
|
|
10
|
+
* Re-runs on scroll (capture on window) and resize events.
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeFallbackPosition({ triggerRect, popoverEl, placement, viewport, offset, }: {
|
|
13
|
+
triggerRect: DOMRect;
|
|
14
|
+
popoverEl: HTMLElement;
|
|
15
|
+
placement: TPlacement;
|
|
16
|
+
viewport: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
offset: number;
|
|
21
|
+
}): {
|
|
22
|
+
top: number;
|
|
23
|
+
left: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combine multiple cleanup functions into a single cleanup function.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* useEffect(() => {
|
|
7
|
+
* return combine(
|
|
8
|
+
* bind(window, { type: 'resize', listener: onResize }),
|
|
9
|
+
* bind(window, { type: 'scroll', listener: onScroll, options: { capture: true } }),
|
|
10
|
+
* );
|
|
11
|
+
* }, []);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function combine(...cleanupFns: ((() => void) | undefined)[]): () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the user prefers reduced motion.
|
|
3
|
+
*
|
|
4
|
+
* Safe for SSR (returns `false` when `window` is unavailable).
|
|
5
|
+
*
|
|
6
|
+
* The result is cached after the first call via `once`. This avoids
|
|
7
|
+
* calling `matchMedia` on every render. The trade-off is that if a user
|
|
8
|
+
* toggles the OS reduced-motion setting mid-session, the change won't
|
|
9
|
+
* take effect until the next page load. This is acceptable because
|
|
10
|
+
* toggling this system-level preference mid-session is extremely rare,
|
|
11
|
+
* and a page refresh is a reasonable expectation for system accessibility
|
|
12
|
+
* settings to take effect.
|
|
13
|
+
*/
|
|
14
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fully-resolved placement (internal). All fields are required.
|
|
3
|
+
* Use getPlacement({ placement: partial }) to obtain from partial input.
|
|
4
|
+
*/
|
|
5
|
+
export type TPlacement = {
|
|
6
|
+
axis: 'block' | 'inline';
|
|
7
|
+
edge: 'start' | 'end';
|
|
8
|
+
align: 'start' | 'center' | 'end';
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a partial placement to its fully-specified form.
|
|
12
|
+
* Defaults: `axis: 'block'`, `edge: 'end'`, `align: 'center'`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPlacement({ placement }: {
|
|
15
|
+
placement: Partial<TPlacement>;
|
|
16
|
+
}): TPlacement;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valid values for the `aria-haspopup` attribute.
|
|
3
|
+
* Derived from the HTML spec — maps popover roles to what the trigger announces.
|
|
4
|
+
*/
|
|
5
|
+
export type TAriaHasPopupValue = 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid' | true;
|
|
6
|
+
/**
|
|
7
|
+
* Roles that require an accessible name (`label` or `labelledBy`) per WCAG 4.1.2.
|
|
8
|
+
* Without a name, assistive technology cannot identify these landmarks.
|
|
9
|
+
*/
|
|
10
|
+
export type TRoleRequiringAccessibleName = 'dialog' | 'alertdialog' | 'menu';
|
|
11
|
+
/**
|
|
12
|
+
* Roles where the accessible name is derived from content or provided externally
|
|
13
|
+
* (e.g. a combobox labels its listbox, tooltip content IS the accessible name).
|
|
14
|
+
*/
|
|
15
|
+
export type TRoleWithImplicitName = 'tooltip' | 'listbox' | 'tree' | 'grid' | 'note' | 'status' | 'alert' | 'log';
|
|
16
|
+
type TAccessibleNameRequired = {
|
|
17
|
+
/**
|
|
18
|
+
* Accessible name via `aria-label`.
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
labelledBy?: string;
|
|
22
|
+
} | {
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Accessible name via `aria-labelledby`.
|
|
26
|
+
*/
|
|
27
|
+
labelledBy: string;
|
|
28
|
+
};
|
|
29
|
+
type TAccessibleNameOptional = {
|
|
30
|
+
label?: string;
|
|
31
|
+
labelledBy?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* ARIA role props where a role is always required.
|
|
35
|
+
*
|
|
36
|
+
* Used by `TPopupContentProps` — popup content must always declare
|
|
37
|
+
* its role so assistive technology can identify the layer.
|
|
38
|
+
*/
|
|
39
|
+
export type TAriaRoleRequired = ({
|
|
40
|
+
role: TRoleRequiringAccessibleName;
|
|
41
|
+
} & TAccessibleNameRequired) | ({
|
|
42
|
+
role: TRoleWithImplicitName;
|
|
43
|
+
} & TAccessibleNameOptional);
|
|
44
|
+
/**
|
|
45
|
+
* ARIA role props where a role is optional.
|
|
46
|
+
*
|
|
47
|
+
* Used by `TPopoverProps` — the low-level primitive allows omitting
|
|
48
|
+
* the role for cases where it is set externally or not needed.
|
|
49
|
+
*/
|
|
50
|
+
export type TAriaRoleOptional = ({
|
|
51
|
+
role: TRoleRequiringAccessibleName;
|
|
52
|
+
} & TAccessibleNameRequired) | ({
|
|
53
|
+
role?: TRoleWithImplicitName;
|
|
54
|
+
} & TAccessibleNameOptional);
|
|
55
|
+
/**
|
|
56
|
+
* Maps a popover content role to the correct `aria-haspopup` value
|
|
57
|
+
* for its trigger element.
|
|
58
|
+
*/
|
|
59
|
+
export declare function roleToAriaHasPopup({ role, }: {
|
|
60
|
+
role: TRoleRequiringAccessibleName | TRoleWithImplicitName | undefined;
|
|
61
|
+
}): TAriaHasPopupValue;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets inline styles on an element and returns a cleanup function
|
|
3
|
+
* that removes only the styles that were applied.
|
|
4
|
+
*
|
|
5
|
+
* Uses `style.setProperty()` / `style.removeProperty()` so that
|
|
6
|
+
* hyphenated CSS property names (e.g. `position-area`, `anchor-name`)
|
|
7
|
+
* work correctly. These newer properties do not have camelCase
|
|
8
|
+
* mappings in `CSSStyleDeclaration` yet.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const cleanup = setStyle({ el: popover, styles: [
|
|
13
|
+
* { property: 'position-anchor', value: '--my-anchor' },
|
|
14
|
+
* { property: 'position-area', value: 'block-end' },
|
|
15
|
+
* { property: 'margin', value: '0' },
|
|
16
|
+
* ] });
|
|
17
|
+
*
|
|
18
|
+
* // Later: removes all three properties
|
|
19
|
+
* cleanup();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function setStyle({ el, styles, }: {
|
|
23
|
+
el: HTMLElement;
|
|
24
|
+
styles: Array<{
|
|
25
|
+
property: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}>;
|
|
28
|
+
}): () => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ForwardRefExoticComponent, type ReactNode, type RefAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Extra DOM/event props are passed through to the cloned child.
|
|
4
|
+
*/
|
|
5
|
+
export type SlotProps = {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
} & Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Merges props (including ref) onto a single React element child.
|
|
10
|
+
*
|
|
11
|
+
* A safer alternative to raw `cloneElement` that:
|
|
12
|
+
* 1. Guards with `isValidElement` — non-element children (strings,
|
|
13
|
+
* fragments, null) are returned as-is instead of crashing.
|
|
14
|
+
* 2. Merges refs via `mergeRefs` so both the caller's ref and the
|
|
15
|
+
* child's existing ref are honoured.
|
|
16
|
+
* 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
|
|
17
|
+
* onto the child element.
|
|
18
|
+
*
|
|
19
|
+
* Event handlers (e.g. `onClick`) are **not** auto-merged — the caller's
|
|
20
|
+
* handler replaces the child's. Compose handlers before passing them in.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Slot ref={triggerRef} onClick={handleClick} aria-expanded={isOpen}>
|
|
25
|
+
* <button>Open</button>
|
|
26
|
+
* </Slot>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const Slot: ForwardRefExoticComponent<SlotProps & RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type TArrowPreset } from '../arrow/types';
|
|
3
|
+
import { type TPlacementOptions } from '../popup/types';
|
|
4
|
+
export { getPlacement } from './resolve-placement';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves placement options to CSS `position-area` syntax.
|
|
7
|
+
*
|
|
8
|
+
* The `align` field represents the *visual* alignment:
|
|
9
|
+
* - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
|
|
10
|
+
* - `align: 'end'` means "aligned to the trigger's end edge"
|
|
11
|
+
* - `align: 'center'` means centered (single-axis position-area)
|
|
12
|
+
*
|
|
13
|
+
* CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
|
|
14
|
+
* Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
|
|
15
|
+
* This function handles the inversion internally.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
|
|
19
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
|
|
20
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
|
|
21
|
+
*/
|
|
22
|
+
export declare function placementToPositionArea({ placement }: {
|
|
23
|
+
placement: TPlacementOptions;
|
|
24
|
+
}): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns `position-try-fallbacks` value based on placement.
|
|
27
|
+
*
|
|
28
|
+
* For centered placements, includes cross-axis aligned position-area
|
|
29
|
+
* values so the browser can shift the popover along the cross-axis
|
|
30
|
+
* when the centered position would overflow the viewport edge.
|
|
31
|
+
*
|
|
32
|
+
* Fallback order for centered placements (e.g. `block-end`):
|
|
33
|
+
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
34
|
+
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
35
|
+
* 3. Flipped edge, centered
|
|
36
|
+
* 4. Flipped edge, start-aligned
|
|
37
|
+
* 5. Flipped edge, end-aligned
|
|
38
|
+
*
|
|
39
|
+
* For aligned placements (start/end), includes the same-edge centered
|
|
40
|
+
* position as fallbacks so the browser can try centering when the aligned
|
|
41
|
+
* position would overflow, before flipping to the opposite edge.
|
|
42
|
+
*/
|
|
43
|
+
export declare function placementToTryFallbacks({ placement }: {
|
|
44
|
+
placement: TPlacementOptions;
|
|
45
|
+
}): string;
|
|
46
|
+
/**
|
|
47
|
+
* Hook that positions an element relative to an anchor element using
|
|
48
|
+
* CSS Anchor Positioning (with a JS fallback for older browsers).
|
|
49
|
+
*
|
|
50
|
+
* This hook is the positioning primitive — it has no knowledge of popovers,
|
|
51
|
+
* visibility, or animation. Compose it with `Popover` for anchor-positioned
|
|
52
|
+
* top-layer content.
|
|
53
|
+
*
|
|
54
|
+
* When CSS Anchor Positioning is supported, it sets CSS properties
|
|
55
|
+
* (`anchor-name`, `position-anchor`, `position-area`, `position-try-fallbacks`)
|
|
56
|
+
* directly on the elements via `el.style.setProperty()`.
|
|
57
|
+
*
|
|
58
|
+
* When not supported, it falls back to JavaScript-based positioning using
|
|
59
|
+
* `position: fixed` with measured coordinates, re-running on scroll (capture)
|
|
60
|
+
* and resize events.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useAnchorPosition({ anchorRef, popoverRef, placement, offset, forceFallbackPositioning, arrow, }: {
|
|
63
|
+
/**
|
|
64
|
+
* Element to position relative to.
|
|
65
|
+
*/
|
|
66
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Element being positioned (typically a popover).
|
|
69
|
+
*/
|
|
70
|
+
popoverRef: RefObject<HTMLElement | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Where to place the element relative to the anchor.
|
|
73
|
+
*/
|
|
74
|
+
placement: TPlacementOptions;
|
|
75
|
+
/**
|
|
76
|
+
* Gap between the positioned element and the anchor, in pixels.
|
|
77
|
+
* Defaults to 8 (`space.100`). Tooltip uses 4.
|
|
78
|
+
*/
|
|
79
|
+
offset?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Forces the JavaScript positioning fallback even when the browser
|
|
82
|
+
* supports CSS Anchor Positioning. Useful for testing fallback
|
|
83
|
+
* behavior in any environment, including production.
|
|
84
|
+
*/
|
|
85
|
+
forceFallbackPositioning?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Arrow preset from `@atlaskit/top-layer/arrow`. When provided, uses
|
|
88
|
+
* the preset's named `@position-try` rules (which update both
|
|
89
|
+
* `position-area` and `margin` on flip) and sets `--ds-arrow-size`.
|
|
90
|
+
*
|
|
91
|
+
* Pass `null` to disable. Has no effect in the JS fallback path —
|
|
92
|
+
* arrows are CSS-only.
|
|
93
|
+
*/
|
|
94
|
+
arrow?: TArrowPreset | null;
|
|
95
|
+
}): void;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type TAnimationPreset } from '../animations/types';
|
|
3
|
+
type TUseAnimatedVisibilityArgs = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the element is logically open.
|
|
6
|
+
*/
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Animation preset for entry/exit transitions.
|
|
10
|
+
* Pass `false` or `undefined` to disable animation.
|
|
11
|
+
*/
|
|
12
|
+
animate: TAnimationPreset | false | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Ref to the DOM element that plays the exit transition.
|
|
15
|
+
* Used to listen for `transitionend`.
|
|
16
|
+
*/
|
|
17
|
+
elementRef: RefObject<HTMLElement | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Called after the exit animation completes (or immediately on close
|
|
20
|
+
* when there is no animation or reduced motion is active).
|
|
21
|
+
*/
|
|
22
|
+
onExitFinish?: () => void;
|
|
23
|
+
};
|
|
24
|
+
type TUseAnimatedVisibilityResult = {
|
|
25
|
+
/**
|
|
26
|
+
* Whether children should be rendered. Stays `true` during exit
|
|
27
|
+
* animations so content remains visible while transitioning out.
|
|
28
|
+
*/
|
|
29
|
+
showChildren: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Resolved animation preset (with CSS injected), or `null` if
|
|
32
|
+
* animation is disabled.
|
|
33
|
+
*/
|
|
34
|
+
preset: TAnimationPreset | null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Manages the children mount/unmount lifecycle around CSS exit transitions.
|
|
38
|
+
*
|
|
39
|
+
* Used by both `Popover` and `Dialog` to share the same animation lifecycle
|
|
40
|
+
* logic. Those components own their own show/hide mechanisms (showPopover /
|
|
41
|
+
* hidePopover vs showModal / close) and event handling — this hook only
|
|
42
|
+
* manages the relationship between `isOpen` and when children are rendered.
|
|
43
|
+
*
|
|
44
|
+
* ## Problem
|
|
45
|
+
*
|
|
46
|
+
* We want to delay the unmount of children until a CSS exit transition has
|
|
47
|
+
* finished playing. If we unmount children the moment `isOpen` becomes
|
|
48
|
+
* `false`, the exit animation is never visible — the content just disappears.
|
|
49
|
+
*
|
|
50
|
+
* ## How it works
|
|
51
|
+
*
|
|
52
|
+
* `showChildren` tracks whether the consumer's children should be in the DOM.
|
|
53
|
+
* It does not mirror `isOpen` exactly — it intentionally lags behind during
|
|
54
|
+
* exit animations:
|
|
55
|
+
*
|
|
56
|
+
* ```
|
|
57
|
+
* isOpen: true ──────────────── false
|
|
58
|
+
* showChildren: true ──────────────── true ─── (exit animation) ─── false
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* Two close paths exist:
|
|
62
|
+
*
|
|
63
|
+
* 1. **Animated close** (`willAnimate === true`):
|
|
64
|
+
* `isOpen` goes `false` → `showChildren` stays `true` → the CSS exit
|
|
65
|
+
* transition plays → `transitionend` fires → `showChildren` → `false`
|
|
66
|
+
* → `onExitFinish` fires. A timeout fallback ensures we still unmount
|
|
67
|
+
* if `transitionend` never fires (e.g. browser quirks, zero-duration).
|
|
68
|
+
*
|
|
69
|
+
* 2. **Non-animated close** (`willAnimate === false`):
|
|
70
|
+
* `isOpen` goes `false` → `showChildren` → `false` synchronously during
|
|
71
|
+
* the same render → `onExitFinish` fires in a follow-up effect.
|
|
72
|
+
*/
|
|
73
|
+
export declare function useAnimatedVisibility({ isOpen, animate, elementRef, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type TPresetWithCssAndName = {
|
|
2
|
+
css: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes the `animate` prop to a preset (or null) and ensures its CSS
|
|
7
|
+
* is injected once into document.head. Used by PopupContent, Popover, and
|
|
8
|
+
* DialogContent so they don't duplicate this logic.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAnimationPreset<T extends TPresetWithCssAndName>(animate: T | false | null | undefined): T | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps Tab/Shift+Tab focus within a popover element when its role
|
|
4
|
+
* semantically requires it (dialog, alertdialog).
|
|
5
|
+
*
|
|
6
|
+
* While the popover is open, Tab and Shift+Tab are intercepted
|
|
7
|
+
* (via `preventDefault`) and remapped to cycle through focusable
|
|
8
|
+
* elements within the container using wrapping navigation.
|
|
9
|
+
*
|
|
10
|
+
* Light dismiss (Escape, click outside) continues to work natively
|
|
11
|
+
* via `popover="auto"` — this hook only intercepts Tab.
|
|
12
|
+
*
|
|
13
|
+
* Always call this hook unconditionally. The listener is only
|
|
14
|
+
* attached when the role requires focus wrapping, and is cleaned
|
|
15
|
+
* up and re-evaluated when the role changes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useFocusWrap({ elementRef, role, }: {
|
|
18
|
+
elementRef: RefObject<HTMLElement | null>;
|
|
19
|
+
role: string | undefined;
|
|
20
|
+
}): void;
|