@atlaskit/top-layer 4.0.0 → 4.2.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.
@@ -11,6 +11,10 @@ import type { StrictXCSSProp } from '@atlaskit/css';
11
11
  * produces. The consumer simply sets `isOpen={false}`.
12
12
  */
13
13
  export type TDialogCloseReason = 'escape' | 'overlay-click';
14
+ /**
15
+ * User interactions that are allowed to dismiss the dialog.
16
+ */
17
+ export type TDialogDismissedBy = 'none' | 'escape' | 'escape-and-outside-click';
14
18
  /**
15
19
  * Props shared across `TDialogProps` variants.
16
20
  *
@@ -40,14 +44,24 @@ type TDialogBaseProps = {
40
44
  */
41
45
  isOpen: boolean;
42
46
  /**
43
- * Called when the user triggers close via Escape or backdrop click.
47
+ * Called after the dialog closes through an allowed Escape or backdrop interaction.
44
48
  *
45
- * The dialog does **not** close itself. The consumer decides whether to
46
- * set `isOpen={false}` (e.g. gate by reason).
49
+ * User dismissal cannot be rejected from this callback. The consumer must set
50
+ * `isOpen={false}` in response to synchronize controlled state with the native dialog.
47
51
  */
48
52
  onClose: (args: {
49
53
  reason: TDialogCloseReason;
50
54
  }) => void;
55
+ /**
56
+ * Controls which user actions can dismiss the dialog.
57
+ *
58
+ * - `'escape-and-outside-click'`: Escape and outside click.
59
+ * - `'escape'`: Escape only.
60
+ * - `'none'`: no user action.
61
+ *
62
+ * Defaults to `'escape-and-outside-click'`.
63
+ */
64
+ dismissedBy?: TDialogDismissedBy;
51
65
  /**
52
66
  * Whether the dialog should animate in and out.
53
67
  *
@@ -1,2 +1,2 @@
1
1
  export { createCloseEvent, Dialog } from '../dialog';
2
- export type { TDialogCloseReason, TDialogProps } from '../dialog';
2
+ export type { TDialogCloseReason, TDialogDismissedBy, TDialogProps } from '../dialog';
@@ -42,6 +42,12 @@ type TUseAnimatedVisibilityResult = {
42
42
  * trapping, listeners that must outlive the exit).
43
43
  */
44
44
  phase: TPhase;
45
+ /**
46
+ * Notifies the visibility lifecycle after the primitive has finished its
47
+ * own native toggle handling. Closing toggles make native dismissal
48
+ * authoritative while preserving primitive-specific handler ordering.
49
+ */
50
+ onToggle: (event: ToggleEvent) => void;
45
51
  };
46
52
  /**
47
53
  * Visibility lifecycle phase shared between `useAnimatedVisibility`,
@@ -93,7 +99,7 @@ export type TPhase = 'closed' | 'entering' | 'open' | 'exiting';
93
99
  * `entering`, `open`, `exiting`). The host element is rendered while
94
100
  * `phase !== 'closed'`, so the `exiting` phase keeps the host mounted
95
101
  * while the CSS exit transition plays (or, with animation disabled,
96
- * while we wait for the browser `toggle` / `close` event to fire on the
102
+ * while we wait for the browser's closing `toggle` event to fire on the
97
103
  * still-attached element):
98
104
  *
99
105
  * ```
@@ -16,11 +16,7 @@ import { type TPopoverForwardedProps } from './types';
16
16
  * ### 📜 Browser dismiss is non-cancellable
17
17
  *
18
18
  * Per the popover spec, `beforetoggle` is cancellable on open transitions
19
- * only, not on close. Consumers that need to ignore a specific dismiss
20
- * (e.g. a click on a logically-associated external trigger) must reconcile
21
- * inside their own `onClose` handler by calling `showPopover()` again.
22
- * `Popover` does not self-heal so consumers do not pay a reconcile cost
23
- * by default.
19
+ * only, not on close.
24
20
  *
25
21
  * - Spec: <https://html.spec.whatwg.org/multipage/popover.html#the-popover-attribute>
26
22
  * - <https://github.com/whatwg/html/issues/8973>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/top-layer",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Low-level layering primitives based on popover and dialog",
5
5
  "homepage": "https://atlassian.design/components/top-layer",
6
6
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",