@atlaskit/top-layer 3.1.0 → 4.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 (38) hide show
  1. package/AGENTS.md +3 -1
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +0 -14
  4. package/dist/cjs/focus/is-in-same-layer.js +1 -7
  5. package/dist/cjs/focus/selectors.js +1 -1
  6. package/dist/cjs/internal/get-aria-for-trigger.js +23 -9
  7. package/dist/cjs/internal/role-types.js +1 -64
  8. package/dist/cjs/internal/use-anchor-position.js +53 -19
  9. package/dist/cjs/popover/popover.js +2 -2
  10. package/dist/es2019/focus/is-in-same-layer.js +1 -7
  11. package/dist/es2019/focus/selectors.js +1 -1
  12. package/dist/es2019/internal/get-aria-for-trigger.js +23 -10
  13. package/dist/es2019/internal/role-types.js +0 -59
  14. package/dist/es2019/internal/use-anchor-position.js +53 -19
  15. package/dist/es2019/popover/popover.js +1 -1
  16. package/dist/esm/focus/is-in-same-layer.js +1 -7
  17. package/dist/esm/focus/selectors.js +1 -1
  18. package/dist/esm/internal/get-aria-for-trigger.js +23 -10
  19. package/dist/esm/internal/role-types.js +0 -58
  20. package/dist/esm/internal/use-anchor-position.js +53 -19
  21. package/dist/esm/popover/popover.js +1 -1
  22. package/dist/types/internal/get-aria-for-trigger.d.ts +21 -7
  23. package/dist/types/internal/role-types.d.ts +0 -32
  24. package/dist/types/popover/types.d.ts +1 -1
  25. package/package.json +3 -30
  26. package/animations/package.json +0 -10
  27. package/dist/cjs/entry-points/animations.js +0 -1
  28. package/dist/cjs/internal/role-to-aria-has-popup.js +0 -37
  29. package/dist/cjs/internal/slot.js +0 -65
  30. package/dist/es2019/entry-points/animations.js +0 -0
  31. package/dist/es2019/internal/role-to-aria-has-popup.js +0 -32
  32. package/dist/es2019/internal/slot.js +0 -57
  33. package/dist/esm/entry-points/animations.js +0 -0
  34. package/dist/esm/internal/role-to-aria-has-popup.js +0 -31
  35. package/dist/esm/internal/slot.js +0 -59
  36. package/dist/types/entry-points/animations.d.ts +0 -0
  37. package/dist/types/internal/role-to-aria-has-popup.d.ts +0 -13
  38. package/dist/types/internal/slot.d.ts +0 -29
@@ -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>>;