@atlaskit/top-layer 3.2.0 → 4.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.
Files changed (50) hide show
  1. package/AGENTS.md +3 -1
  2. package/CHANGELOG.md +18 -0
  3. package/README.md +0 -14
  4. package/dist/cjs/dialog/dialog-content.js +47 -20
  5. package/dist/cjs/focus/is-in-same-layer.js +1 -7
  6. package/dist/cjs/focus/selectors.js +1 -1
  7. package/dist/cjs/internal/get-aria-for-trigger.js +23 -9
  8. package/dist/cjs/internal/role-types.js +1 -64
  9. package/dist/cjs/internal/use-anchor-position.js +2 -3
  10. package/dist/cjs/internal/use-animated-visibility.js +36 -39
  11. package/dist/cjs/popover/popover.js +18 -20
  12. package/dist/es2019/dialog/dialog-content.js +48 -22
  13. package/dist/es2019/focus/is-in-same-layer.js +1 -7
  14. package/dist/es2019/focus/selectors.js +1 -1
  15. package/dist/es2019/internal/get-aria-for-trigger.js +23 -10
  16. package/dist/es2019/internal/role-types.js +0 -59
  17. package/dist/es2019/internal/use-anchor-position.js +2 -3
  18. package/dist/es2019/internal/use-animated-visibility.js +38 -39
  19. package/dist/es2019/popover/popover.js +15 -17
  20. package/dist/esm/dialog/dialog-content.js +49 -22
  21. package/dist/esm/focus/is-in-same-layer.js +1 -7
  22. package/dist/esm/focus/selectors.js +1 -1
  23. package/dist/esm/internal/get-aria-for-trigger.js +23 -10
  24. package/dist/esm/internal/role-types.js +0 -58
  25. package/dist/esm/internal/use-anchor-position.js +2 -3
  26. package/dist/esm/internal/use-animated-visibility.js +38 -41
  27. package/dist/esm/popover/popover.js +17 -19
  28. package/dist/types/dialog/dialog-content.d.ts +2 -2
  29. package/dist/types/dialog/index.d.ts +1 -1
  30. package/dist/types/dialog/types.d.ts +17 -3
  31. package/dist/types/entry-points/dialog.d.ts +1 -1
  32. package/dist/types/internal/get-aria-for-trigger.d.ts +21 -7
  33. package/dist/types/internal/role-types.d.ts +0 -32
  34. package/dist/types/internal/use-animated-visibility.d.ts +7 -1
  35. package/dist/types/popover/popover.d.ts +1 -5
  36. package/dist/types/popover/types.d.ts +1 -1
  37. package/package.json +3 -30
  38. package/animations/package.json +0 -10
  39. package/dist/cjs/entry-points/animations.js +0 -1
  40. package/dist/cjs/internal/role-to-aria-has-popup.js +0 -37
  41. package/dist/cjs/internal/slot.js +0 -65
  42. package/dist/es2019/entry-points/animations.js +0 -0
  43. package/dist/es2019/internal/role-to-aria-has-popup.js +0 -32
  44. package/dist/es2019/internal/slot.js +0 -57
  45. package/dist/esm/entry-points/animations.js +0 -0
  46. package/dist/esm/internal/role-to-aria-has-popup.js +0 -31
  47. package/dist/esm/internal/slot.js +0 -59
  48. package/dist/types/entry-points/animations.d.ts +0 -0
  49. package/dist/types/internal/role-to-aria-has-popup.d.ts +0 -13
  50. package/dist/types/internal/slot.d.ts +0 -29
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Slot = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _react = require("react");
11
- var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
12
- var _excluded = ["children"];
13
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
- /**
16
- * Extra DOM/event props are passed through to the cloned child.
17
- */
18
-
19
- /**
20
- * Single element child: merge the caller ref with `child.ref`.
21
- *
22
- * Do not read `child.props.ref`: React keeps a `ref` key on `props` for
23
- * host elements but accessing it logs a warning and returns `undefined`
24
- * (ref lives on the element as `child.ref`).
25
- */
26
-
27
- function isSlotChild(child) {
28
- return /*#__PURE__*/(0, _react.isValidElement)(child);
29
- }
30
-
31
- /**
32
- * Merges props (including ref) onto a single React element child.
33
- *
34
- * A safer alternative to raw `cloneElement` that:
35
- * 1. Guards with `isValidElement` - non-element children (strings,
36
- * fragments, null) are returned as-is instead of crashing.
37
- * 2. Merges refs via `mergeRefs` so both the caller's ref and the
38
- * child's existing ref are honoured.
39
- * 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
40
- * onto the child element.
41
- *
42
- * Event handlers (e.g. `onClick`) are **not** auto-merged - the caller's
43
- * handler replaces the child's. Compose handlers before passing them in.
44
- *
45
- * @example
46
- * ```tsx
47
- * <Slot ref={triggerRef} onClick={handleClick} aria-expanded={isOpen}>
48
- * <button>Open</button>
49
- * </Slot>
50
- * ```
51
- */
52
- var Slot = exports.Slot = /*#__PURE__*/(0, _react.forwardRef)(function Slot(slotProps, ref) {
53
- var rawChildren = slotProps.children,
54
- props = (0, _objectWithoutProperties2.default)(slotProps, _excluded);
55
- // `TSlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
56
- var children = rawChildren;
57
- if (!isSlotChild(children)) {
58
- return children;
59
- }
60
-
61
- // eslint-disable-next-line @repo/internal/react/no-clone-element -- Slot is a controlled wrapper around cloneElement with isValidElement guard
62
- return /*#__PURE__*/(0, _react.cloneElement)(children, _objectSpread(_objectSpread({}, props), {}, {
63
- ref: (0, _mergeRefs.default)([ref, children.ref])
64
- }));
65
- });
File without changes
@@ -1,32 +0,0 @@
1
- /**
2
- * Maps a popover content role to the correct `aria-haspopup` value
3
- * for its trigger element.
4
- *
5
- * Returns `undefined` for roles that are not popups in the ARIA sense
6
- * (`tooltip`, `note`, `status`, `alert`, `log`). Triggers for those roles
7
- * should not announce a popup at all - emitting `aria-haspopup="dialog"`
8
- * on a tooltip trigger would mislead assistive technology.
9
- */
10
- export function roleToAriaHasPopup({
11
- role
12
- }) {
13
- if (role === 'menu') {
14
- return 'menu';
15
- }
16
- if (role === 'listbox') {
17
- return 'listbox';
18
- }
19
- if (role === 'tree') {
20
- return 'tree';
21
- }
22
- if (role === 'grid') {
23
- return 'grid';
24
- }
25
- if (role === 'dialog' || role === 'alertdialog') {
26
- return 'dialog';
27
- }
28
- // Non-popup roles (tooltip, note, status, alert, log) and the
29
- // no-role case: omit `aria-haspopup` entirely. React drops the
30
- // attribute when the value is `undefined`.
31
- return undefined;
32
- }
@@ -1,57 +0,0 @@
1
- import { cloneElement, forwardRef, isValidElement } from 'react';
2
- import mergeRefs from '@atlaskit/ds-lib/merge-refs';
3
-
4
- /**
5
- * Extra DOM/event props are passed through to the cloned child.
6
- */
7
-
8
- /**
9
- * Single element child: merge the caller ref with `child.ref`.
10
- *
11
- * Do not read `child.props.ref`: React keeps a `ref` key on `props` for
12
- * host elements but accessing it logs a warning and returns `undefined`
13
- * (ref lives on the element as `child.ref`).
14
- */
15
-
16
- function isSlotChild(child) {
17
- return /*#__PURE__*/isValidElement(child);
18
- }
19
-
20
- /**
21
- * Merges props (including ref) onto a single React element child.
22
- *
23
- * A safer alternative to raw `cloneElement` that:
24
- * 1. Guards with `isValidElement` - non-element children (strings,
25
- * fragments, null) are returned as-is instead of crashing.
26
- * 2. Merges refs via `mergeRefs` so both the caller's ref and the
27
- * child's existing ref are honoured.
28
- * 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
29
- * onto the child element.
30
- *
31
- * Event handlers (e.g. `onClick`) are **not** auto-merged - the caller's
32
- * handler replaces the child's. Compose handlers before passing them in.
33
- *
34
- * @example
35
- * ```tsx
36
- * <Slot ref={triggerRef} onClick={handleClick} aria-expanded={isOpen}>
37
- * <button>Open</button>
38
- * </Slot>
39
- * ```
40
- */
41
- export const Slot = /*#__PURE__*/forwardRef(function Slot(slotProps, ref) {
42
- const {
43
- children: rawChildren,
44
- ...props
45
- } = slotProps;
46
- // `TSlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
47
- const children = rawChildren;
48
- if (!isSlotChild(children)) {
49
- return children;
50
- }
51
-
52
- // eslint-disable-next-line @repo/internal/react/no-clone-element -- Slot is a controlled wrapper around cloneElement with isValidElement guard
53
- return /*#__PURE__*/cloneElement(children, {
54
- ...props,
55
- ref: mergeRefs([ref, children.ref])
56
- });
57
- });
File without changes
@@ -1,31 +0,0 @@
1
- /**
2
- * Maps a popover content role to the correct `aria-haspopup` value
3
- * for its trigger element.
4
- *
5
- * Returns `undefined` for roles that are not popups in the ARIA sense
6
- * (`tooltip`, `note`, `status`, `alert`, `log`). Triggers for those roles
7
- * should not announce a popup at all - emitting `aria-haspopup="dialog"`
8
- * on a tooltip trigger would mislead assistive technology.
9
- */
10
- export function roleToAriaHasPopup(_ref) {
11
- var role = _ref.role;
12
- if (role === 'menu') {
13
- return 'menu';
14
- }
15
- if (role === 'listbox') {
16
- return 'listbox';
17
- }
18
- if (role === 'tree') {
19
- return 'tree';
20
- }
21
- if (role === 'grid') {
22
- return 'grid';
23
- }
24
- if (role === 'dialog' || role === 'alertdialog') {
25
- return 'dialog';
26
- }
27
- // Non-popup roles (tooltip, note, status, alert, log) and the
28
- // no-role case: omit `aria-haspopup` entirely. React drops the
29
- // attribute when the value is `undefined`.
30
- return undefined;
31
- }
@@ -1,59 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children"];
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import { cloneElement, forwardRef, isValidElement } from 'react';
7
- import mergeRefs from '@atlaskit/ds-lib/merge-refs';
8
-
9
- /**
10
- * Extra DOM/event props are passed through to the cloned child.
11
- */
12
-
13
- /**
14
- * Single element child: merge the caller ref with `child.ref`.
15
- *
16
- * Do not read `child.props.ref`: React keeps a `ref` key on `props` for
17
- * host elements but accessing it logs a warning and returns `undefined`
18
- * (ref lives on the element as `child.ref`).
19
- */
20
-
21
- function isSlotChild(child) {
22
- return /*#__PURE__*/isValidElement(child);
23
- }
24
-
25
- /**
26
- * Merges props (including ref) onto a single React element child.
27
- *
28
- * A safer alternative to raw `cloneElement` that:
29
- * 1. Guards with `isValidElement` - non-element children (strings,
30
- * fragments, null) are returned as-is instead of crashing.
31
- * 2. Merges refs via `mergeRefs` so both the caller's ref and the
32
- * child's existing ref are honoured.
33
- * 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
34
- * onto the child element.
35
- *
36
- * Event handlers (e.g. `onClick`) are **not** auto-merged - the caller's
37
- * handler replaces the child's. Compose handlers before passing them in.
38
- *
39
- * @example
40
- * ```tsx
41
- * <Slot ref={triggerRef} onClick={handleClick} aria-expanded={isOpen}>
42
- * <button>Open</button>
43
- * </Slot>
44
- * ```
45
- */
46
- export var Slot = /*#__PURE__*/forwardRef(function Slot(slotProps, ref) {
47
- var rawChildren = slotProps.children,
48
- props = _objectWithoutProperties(slotProps, _excluded);
49
- // `TSlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
50
- var children = rawChildren;
51
- if (!isSlotChild(children)) {
52
- return children;
53
- }
54
-
55
- // eslint-disable-next-line @repo/internal/react/no-clone-element -- Slot is a controlled wrapper around cloneElement with isValidElement guard
56
- return /*#__PURE__*/cloneElement(children, _objectSpread(_objectSpread({}, props), {}, {
57
- ref: mergeRefs([ref, children.ref])
58
- }));
59
- });
File without changes
@@ -1,13 +0,0 @@
1
- import type { TAriaHasPopupValue, TRoleRequiringAccessibleName, TRoleWithImplicitName } from './role-types';
2
- /**
3
- * Maps a popover content role to the correct `aria-haspopup` value
4
- * for its trigger element.
5
- *
6
- * Returns `undefined` for roles that are not popups in the ARIA sense
7
- * (`tooltip`, `note`, `status`, `alert`, `log`). Triggers for those roles
8
- * should not announce a popup at all - emitting `aria-haspopup="dialog"`
9
- * on a tooltip trigger would mislead assistive technology.
10
- */
11
- export declare function roleToAriaHasPopup({ role, }: {
12
- role: TRoleRequiringAccessibleName | TRoleWithImplicitName | undefined;
13
- }): TAriaHasPopupValue;
@@ -1,29 +0,0 @@
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 TSlotProps = {
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<TSlotProps & RefAttributes<HTMLElement>>;