@atlaskit/top-layer 0.17.0 → 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.
- package/AGENTS.md +113 -0
- package/CHANGELOG.md +33 -0
- package/animations/package.json +1 -8
- package/dialog/package.json +1 -8
- package/dialog-scroll-lock/package.json +1 -8
- package/dist/cjs/dialog/dialog-content.js +12 -30
- package/dist/cjs/internal/set-style.js +5 -5
- package/dist/cjs/internal/slot.js +1 -1
- package/dist/cjs/internal/use-anchor-position-at-point.js +8 -8
- package/dist/cjs/internal/use-anchor-position.js +19 -40
- package/dist/cjs/internal/use-animated-visibility.js +31 -61
- package/dist/cjs/internal/use-initial-focus.js +9 -13
- package/dist/cjs/internal/use-width-from-anchor.js +6 -6
- package/dist/cjs/popover/popover.js +30 -58
- package/dist/cjs/popover-surface/popover-surface.js +4 -3
- package/dist/cjs/testing/polyfill.js +9 -9
- package/dist/cjs/use-simple-light-dismiss/index.js +3 -3
- package/dist/es2019/dialog/dialog-content.js +12 -30
- package/dist/es2019/internal/set-style.js +5 -5
- package/dist/es2019/internal/slot.js +1 -1
- package/dist/es2019/internal/use-anchor-position-at-point.js +8 -8
- package/dist/es2019/internal/use-anchor-position.js +19 -40
- package/dist/es2019/internal/use-animated-visibility.js +31 -61
- package/dist/es2019/internal/use-initial-focus.js +9 -13
- package/dist/es2019/internal/use-width-from-anchor.js +6 -6
- package/dist/es2019/popover/popover.js +30 -58
- package/dist/es2019/popover-surface/popover-surface.js +1 -1
- package/dist/es2019/testing/polyfill.js +7 -11
- package/dist/es2019/use-simple-light-dismiss/index.js +3 -3
- package/dist/esm/dialog/dialog-content.js +12 -30
- package/dist/esm/internal/set-style.js +5 -5
- package/dist/esm/internal/slot.js +1 -1
- package/dist/esm/internal/use-anchor-position-at-point.js +8 -8
- package/dist/esm/internal/use-anchor-position.js +19 -40
- package/dist/esm/internal/use-animated-visibility.js +31 -61
- package/dist/esm/internal/use-initial-focus.js +9 -13
- package/dist/esm/internal/use-width-from-anchor.js +6 -6
- package/dist/esm/popover/popover.js +30 -58
- package/dist/esm/popover-surface/popover-surface.js +1 -1
- package/dist/esm/testing/polyfill.js +9 -9
- package/dist/esm/use-simple-light-dismiss/index.js +3 -3
- package/dist/types/internal/set-style.d.ts +2 -2
- package/dist/types/internal/slot.d.ts +2 -2
- package/dist/types/internal/use-anchor-position-at-point.d.ts +2 -2
- package/dist/types/internal/use-anchor-position.d.ts +0 -4
- package/dist/types/internal/use-initial-focus.d.ts +1 -1
- package/dist/types/popover/types.d.ts +5 -7
- package/dist/types/popover-surface/popover-surface.d.ts +2 -2
- package/focus/package.json +1 -8
- package/get-aria-for-trigger/package.json +1 -8
- package/open-layer-observer/package.json +1 -8
- package/package.json +11 -19
- package/placement-map/package.json +1 -8
- package/popover/package.json +1 -8
- package/popover-surface/package.json +1 -8
- package/testing/polyfill/package.json +1 -8
- package/testing/to-be-visible/package.json +1 -8
- package/use-anchor-position/package.json +1 -8
- package/use-anchor-position-at-point/package.json +1 -8
- package/use-arrow-navigation/package.json +1 -8
- package/use-popover-id/package.json +1 -8
- package/use-simple-light-dismiss/package.json +1 -8
- package/use-width-from-anchor/package.json +1 -8
- package/dist/types-ts4.5/animations/presets.d.ts +0 -110
- package/dist/types-ts4.5/animations/types.d.ts +0 -38
- package/dist/types-ts4.5/dialog/create-close-event.d.ts +0 -23
- package/dist/types-ts4.5/dialog/dialog-content.d.ts +0 -24
- package/dist/types-ts4.5/dialog/index.d.ts +0 -3
- package/dist/types-ts4.5/dialog/types.d.ts +0 -126
- package/dist/types-ts4.5/dialog-scroll-lock/index.d.ts +0 -40
- package/dist/types-ts4.5/entry-points/animations.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/dialog-scroll-lock.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/dialog.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/focus.d.ts +0 -4
- package/dist/types-ts4.5/entry-points/get-aria-for-trigger.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/open-layer-observer.d.ts +0 -5
- package/dist/types-ts4.5/entry-points/placement-map.d.ts +0 -3
- package/dist/types-ts4.5/entry-points/popover-surface.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/popover.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/use-anchor-position-at-point.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/use-anchor-position.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +0 -3
- package/dist/types-ts4.5/entry-points/use-popover-id.d.ts +0 -11
- package/dist/types-ts4.5/entry-points/use-simple-light-dismiss.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/use-width-from-anchor.d.ts +0 -1
- package/dist/types-ts4.5/focus/get-first-focusable.d.ts +0 -8
- package/dist/types-ts4.5/focus/get-focusables.d.ts +0 -13
- package/dist/types-ts4.5/focus/get-last-focusable.d.ts +0 -8
- package/dist/types-ts4.5/focus/get-next-focusable.d.ts +0 -13
- package/dist/types-ts4.5/focus/is-in-same-layer.d.ts +0 -8
- package/dist/types-ts4.5/focus/is-nested-layer-focused.d.ts +0 -8
- package/dist/types-ts4.5/focus/selectors.d.ts +0 -4
- package/dist/types-ts4.5/focus/types.d.ts +0 -5
- package/dist/types-ts4.5/index.d.ts +0 -0
- package/dist/types-ts4.5/internal/anchor-positioning-fallback.d.ts +0 -26
- package/dist/types-ts4.5/internal/combine.d.ts +0 -14
- package/dist/types-ts4.5/internal/ensure-preset-styles.d.ts +0 -6
- package/dist/types-ts4.5/internal/get-aria-for-trigger.d.ts +0 -93
- package/dist/types-ts4.5/internal/placement-to-position-area.d.ts +0 -21
- package/dist/types-ts4.5/internal/placement-to-try-fallbacks.d.ts +0 -36
- package/dist/types-ts4.5/internal/reduced-motion.d.ts +0 -14
- package/dist/types-ts4.5/internal/resolve-css-length-to-pixels.d.ts +0 -20
- package/dist/types-ts4.5/internal/resolve-css-length.d.ts +0 -8
- package/dist/types-ts4.5/internal/resolve-placement.d.ts +0 -58
- package/dist/types-ts4.5/internal/role-to-aria-has-popup.d.ts +0 -13
- package/dist/types-ts4.5/internal/role-types.d.ts +0 -71
- package/dist/types-ts4.5/internal/set-style.d.ts +0 -11
- package/dist/types-ts4.5/internal/should-focus-into-popover.d.ts +0 -8
- package/dist/types-ts4.5/internal/slot.d.ts +0 -29
- package/dist/types-ts4.5/internal/use-anchor-position-at-point.d.ts +0 -67
- package/dist/types-ts4.5/internal/use-anchor-position.d.ts +0 -91
- package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +0 -109
- package/dist/types-ts4.5/internal/use-animation-preset.d.ts +0 -11
- package/dist/types-ts4.5/internal/use-focus-wrap.d.ts +0 -25
- package/dist/types-ts4.5/internal/use-initial-focus.d.ts +0 -73
- package/dist/types-ts4.5/internal/use-preset-styles.d.ts +0 -15
- package/dist/types-ts4.5/internal/use-width-from-anchor.d.ts +0 -21
- package/dist/types-ts4.5/placement-map/index.d.ts +0 -51
- package/dist/types-ts4.5/placement-map/legacy-placements.d.ts +0 -27
- package/dist/types-ts4.5/placement-map/placement-mapping.d.ts +0 -13
- package/dist/types-ts4.5/popover/create-close-event.d.ts +0 -25
- package/dist/types-ts4.5/popover/index.d.ts +0 -3
- package/dist/types-ts4.5/popover/popover.d.ts +0 -17
- package/dist/types-ts4.5/popover/types.d.ts +0 -193
- package/dist/types-ts4.5/popover-surface/index.d.ts +0 -2
- package/dist/types-ts4.5/popover-surface/popover-surface.d.ts +0 -21
- package/dist/types-ts4.5/testing/polyfill.d.ts +0 -25
- package/dist/types-ts4.5/testing/to-be-visible.d.ts +0 -23
- package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +0 -3
- package/dist/types-ts4.5/use-arrow-navigation/is-at-current-menu-level.d.ts +0 -48
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +0 -102
- package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +0 -45
package/AGENTS.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
## General
|
|
2
|
+
|
|
3
|
+
In your language in comments, and user facing copy, please avoid em-dashes and contractions (prefer
|
|
4
|
+
"do not" over "don't")
|
|
5
|
+
|
|
6
|
+
## TypeScript authoring patterns:
|
|
7
|
+
|
|
8
|
+
- Avoid `any`. Always look for opportunities to have more accurate types
|
|
9
|
+
- Avoid `switch` statements, prefer `if` statements in functions with early returns
|
|
10
|
+
- Avoid conditional assignment of variables. (Use functions, IIFE, etc. to avoid needing to use
|
|
11
|
+
`let`)
|
|
12
|
+
- Avoid nested ternaries. Extract to a function with early returns instead.
|
|
13
|
+
- Prefer explicit conversions for types (e.g. `Boolean(value)` and not `!!value` for booleans,
|
|
14
|
+
`Number(value)` for numbers, and `String(value)` for strings. For strings you can also use
|
|
15
|
+
template literals)
|
|
16
|
+
- Never use `for` with missing parameters, e.g. `for(;;)`. Use other clearer patterns (`while(true)`
|
|
17
|
+
in this case)
|
|
18
|
+
- Prefer function definitions `function getName(){}` over function assignment
|
|
19
|
+
`const getName = function(){}`.
|
|
20
|
+
- Do not author `class`. For stateful constructs, use a factory function that closes over its state
|
|
21
|
+
and returns a plain object (e.g. `createClaudeClient({ apiKey })` instead of
|
|
22
|
+
`new ClaudeClient(apiKey)`). Third-party classes you must instantiate (e.g. SDK clients) are fine
|
|
23
|
+
to `new` inside the factory.
|
|
24
|
+
- Prefer inline exports (`export function`, `export const`) over grouped `export { ... }` blocks at
|
|
25
|
+
the bottom of a file. This is also true for default exports (eg
|
|
26
|
+
`default export function hello(){}`)
|
|
27
|
+
- Prefer discriminated unions for result types `{type: 'error', message: string}` over
|
|
28
|
+
`{error: true, message?: string}`
|
|
29
|
+
- Avoid the `void` keyword: do not use `void` as a return type annotation (use explicit return types
|
|
30
|
+
or omit), and do not use the `void` operator (e.g. `void someExpression()`). You can use
|
|
31
|
+
`Promise<void>` though.
|
|
32
|
+
- For functions that might return values, prefer functions that return an explicit `null` over
|
|
33
|
+
`undefined`.
|
|
34
|
+
- For function parameters, prefer named arguments (e.g. a single destructured options object) over
|
|
35
|
+
positional parameters, even for single-parameter functions
|
|
36
|
+
- Avoid regex when a clearer approach exists; use it when it would greatly simplify things.
|
|
37
|
+
- If a module needs a helper function, put it above the caller. Ideally do not rely on hoisting
|
|
38
|
+
- Always use blocks for conditions, do not do inline conditionals like
|
|
39
|
+
`if(condition) doSomething();`
|
|
40
|
+
- Do not use non null assertions (e.g. `value!.condition`). Use `invariant` from `tiny-invariant`
|
|
41
|
+
(if the value should be there), or optional chaining (if it legitimately could be `null`)
|
|
42
|
+
- When adding listeners to raw `EventTarget` objects (outside JSX), use `bind-event-listener`
|
|
43
|
+
- When a function has cleanup actions (unsubscribe, cancel, teardown), return a cleanup function
|
|
44
|
+
(`TCleanupFn` from `@/types`). This mirrors the `useEffect` cleanup pattern
|
|
45
|
+
- Use optional chaining
|
|
46
|
+
- For arrays, prefer array methods (eg `map`, `filter` and `reduce`) over manual looping
|
|
47
|
+
- Start type names with a `T` to make it clear they are types.
|
|
48
|
+
- Avoid abbreviated variable names. Use descriptive names that read clearly (e.g. `transaction` not
|
|
49
|
+
`tx`, `user` not `u`, `config` not `cfg`, `event` not `e`). This applies to all variables
|
|
50
|
+
including lambda/callback parameters. Exceptions: `ctx` for canvas/React contexts, and `a`/`b` in
|
|
51
|
+
sort comparators.
|
|
52
|
+
- For unused parameters or variables, prefix with `_` (e.g. `(_, index) => ...`, or `_unusedName` if
|
|
53
|
+
a descriptive marker reads better). ESLint accepts this via `argsIgnorePattern: '^_'`. Do not
|
|
54
|
+
invent placeholder names like `unused`.
|
|
55
|
+
- When making functions that return booleans, always prefer function names that express a positive.
|
|
56
|
+
`function isValidUser():boolean {}` and not `function isInvalidUser(): boolean {}`
|
|
57
|
+
- Prefer TypeScript `type` over `interface` unless there is functionality that requires an
|
|
58
|
+
`interface`
|
|
59
|
+
|
|
60
|
+
## In code comments
|
|
61
|
+
|
|
62
|
+
- Place comments on the line directly above the code they describe. Never place comments to the
|
|
63
|
+
right of code on the same line.
|
|
64
|
+
- Code comments should be minimal, clear and accurate
|
|
65
|
+
- Add code comments for anything that is non-obvious by looking at the code
|
|
66
|
+
- Use `// comment` for single-line comments. Use JSDoc-style for multi-line documentation comments
|
|
67
|
+
(markdown is encouraged inside)
|
|
68
|
+
- Do not use decorative separator comments (e.g. `// ── Section ──`, `// ───────...`). Use a plain
|
|
69
|
+
`// Section` comment instead or JSDoc blocks for larger comments:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
/**
|
|
73
|
+
* **Bold title**
|
|
74
|
+
*
|
|
75
|
+
* Some more content goes here
|
|
76
|
+
*/`
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## React rules
|
|
80
|
+
|
|
81
|
+
- Always use named functions for components (eg `export function App() {})`
|
|
82
|
+
- Prefer discriminated unions to model state, rather than having disconnected pieces of state. This
|
|
83
|
+
is the React embodiment of the discriminated unions rule in the TypeScript section above
|
|
84
|
+
- Do not add `className` or `style` props to components as they are unbounded APIs
|
|
85
|
+
- `forwardRef` is needed as this is a `react@18+` project.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// Do not do this:
|
|
89
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
90
|
+
const [loaded, setLoaded] = useState(false);
|
|
91
|
+
|
|
92
|
+
// Prefer discriminated unions, which makes illegal states impossible:
|
|
93
|
+
type TState =
|
|
94
|
+
| { type: 'idle' }
|
|
95
|
+
| {
|
|
96
|
+
type: 'loading';
|
|
97
|
+
}
|
|
98
|
+
| {
|
|
99
|
+
type: 'loaded';
|
|
100
|
+
};
|
|
101
|
+
const [state, setState] = useState<TState>({ type: 'idle' });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- Do not export class name strings from files (e.g. no `export const cardClasses = '...'`)
|
|
105
|
+
- Never call a function from a parent context (e.g. a context action, a prop callback) during render
|
|
106
|
+
to update that parent's state. This causes React's "Cannot update a component while rendering a
|
|
107
|
+
different component" error. Use `useEffect` instead. Updating local state during render (the
|
|
108
|
+
getDerivedStateFromProps pattern) is fine.
|
|
109
|
+
- If a react component needs to return a type, it should be `ReactNode` and not a JSX type.
|
|
110
|
+
|
|
111
|
+
## Versioning
|
|
112
|
+
|
|
113
|
+
This package is still on `0.x` releases. All changes should be a `minor` (`0.x`) release.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @atlaskit/top-layer
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
|
|
8
|
+
Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
|
|
9
|
+
|
|
10
|
+
Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
|
|
11
|
+
|
|
12
|
+
Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
|
|
13
|
+
|
|
14
|
+
```diff
|
|
15
|
+
- "typesVersions": {
|
|
16
|
+
- ">=4.5 <4.9": {
|
|
17
|
+
- "*": [
|
|
18
|
+
- "dist/types-ts4.5/*",
|
|
19
|
+
- "dist/types-ts4.5/index.d.ts"
|
|
20
|
+
- ]
|
|
21
|
+
- }
|
|
22
|
+
- },
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
29
|
+
## 0.18.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- [`b7ed2b39d3ef8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b7ed2b39d3ef8) -
|
|
34
|
+
Internal: align code with package conventions. No functional changes
|
|
35
|
+
|
|
3
36
|
## 0.17.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/animations/package.json
CHANGED
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/entry-points/animations.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/entry-points/animations.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/entry-points/animations.d.ts"
|
|
17
10
|
}
|
package/dialog/package.json
CHANGED
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/entry-points/dialog.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/entry-points/dialog.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/entry-points/dialog.d.ts"
|
|
17
10
|
}
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/entry-points/dialog-scroll-lock.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/entry-points/dialog-scroll-lock.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/entry-points/dialog-scroll-lock.d.ts"
|
|
17
10
|
}
|
|
@@ -57,8 +57,6 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
|
|
|
57
57
|
var dialogId = providedId !== null && providedId !== void 0 ? providedId : generatedId;
|
|
58
58
|
var ownRef = (0, _react.useRef)(null);
|
|
59
59
|
var combinedRef = (0, _mergeRefs.default)([ownRef, ref]);
|
|
60
|
-
|
|
61
|
-
// Animation lifecycle
|
|
62
60
|
var _useAnimatedVisibilit = (0, _useAnimatedVisibility.useAnimatedVisibility)({
|
|
63
61
|
isOpen: isOpen,
|
|
64
62
|
animate: animate,
|
|
@@ -68,31 +66,22 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
|
|
|
68
66
|
phase = _useAnimatedVisibilit.phase,
|
|
69
67
|
preset = _useAnimatedVisibilit.preset;
|
|
70
68
|
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// signal for the backdrop-click rebind effect so it re-attaches to
|
|
74
|
-
// the fresh <dialog> element after a close → reopen unmount/remount
|
|
75
|
-
// cycle.
|
|
69
|
+
// True while the host element is mounted (any phase except `closed`).
|
|
70
|
+
// Used as a dep so listener-rebind effects re-attach after a remount.
|
|
76
71
|
var isVisible = phase !== 'closed';
|
|
77
72
|
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
// Takes `phase` directly: the listener stays attached while
|
|
84
|
-
// `phase !== 'closed'`, i.e. through the animated-exit window.
|
|
85
|
-
// Gating on `isOpen` would unbind the listener at the start of an
|
|
86
|
-
// exit animation while the dialog is still visible, letting focus
|
|
87
|
-
// escape (WCAG 2.4.3 Focus Order regression).
|
|
73
|
+
// Native `<dialog>.showModal()` traps focus but wraps through `<body>` at
|
|
74
|
+
// the boundary (A → B → C → body → A). This hook intercepts Tab to wrap
|
|
75
|
+
// directly (A → B → C → A), matching the WAI-ARIA APG pattern. Passing
|
|
76
|
+
// `phase` keeps the listener attached through the animated-exit window
|
|
77
|
+
// (WCAG 2.4.3 Focus Order regression guard).
|
|
88
78
|
(0, _useFocusWrap.useFocusWrap)({
|
|
89
79
|
elementRef: ownRef,
|
|
90
80
|
role: 'dialog',
|
|
91
81
|
phase: phase
|
|
92
82
|
});
|
|
93
83
|
|
|
94
|
-
//
|
|
95
|
-
// Notifies the open layer observer so app-coordination features
|
|
84
|
+
// Notify the open layer observer so app-coordination features
|
|
96
85
|
// (open-count subscriptions) work with top-layer dialogs.
|
|
97
86
|
(0, _openLayerObserver.useNotifyOpenLayerObserver)({
|
|
98
87
|
type: 'modal',
|
|
@@ -100,8 +89,6 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
|
|
|
100
89
|
// No-op: no current use case for programmatic close via OpenLayerObserver.
|
|
101
90
|
onClose: _noop.default
|
|
102
91
|
});
|
|
103
|
-
|
|
104
|
-
// Show/hide the dialog in response to isOpen changes.
|
|
105
92
|
(0, _react.useLayoutEffect)(function () {
|
|
106
93
|
var dialog = ownRef.current;
|
|
107
94
|
if (!dialog) {
|
|
@@ -159,15 +146,10 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
|
|
|
159
146
|
// any atomic class, so the override always wins.
|
|
160
147
|
var escapedId = CSS.escape(dialogId);
|
|
161
148
|
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
// re-mounts on the next `isOpen=true` commit; `showModal()` is called
|
|
167
|
-
// from the existing `useLayoutEffect([isOpen])` on that same commit,
|
|
168
|
-
// and listeners (cancel, click) re-bind via the `[onClose, isVisible]`
|
|
169
|
-
// effect re-running after remount (React clears the ref on unmount, so
|
|
170
|
-
// we need the listener effect to re-run with the fresh element).
|
|
149
|
+
// Unmount the `<dialog>` once exit completes so it does not leave an
|
|
150
|
+
// empty `role="dialog"` element in the accessibility tree. On the next
|
|
151
|
+
// open the element remounts and the `[isOpen]` and `[onClose, isVisible]`
|
|
152
|
+
// effects re-run against the fresh element.
|
|
171
153
|
if (!isVisible) {
|
|
172
154
|
return null;
|
|
173
155
|
}
|
|
@@ -9,7 +9,7 @@ exports.setStyle = setStyle;
|
|
|
9
9
|
* restores the prior inline values (so we do not stomp consumer styles).
|
|
10
10
|
*/
|
|
11
11
|
function setStyle(_ref) {
|
|
12
|
-
var
|
|
12
|
+
var element = _ref.element,
|
|
13
13
|
styles = _ref.styles;
|
|
14
14
|
// Snapshot the prior inline value (NOT the computed style - we only want
|
|
15
15
|
// to restore values that the consumer/our previous run inlined). An empty
|
|
@@ -18,23 +18,23 @@ function setStyle(_ref) {
|
|
|
18
18
|
var property = _ref2.property;
|
|
19
19
|
return {
|
|
20
20
|
property: property,
|
|
21
|
-
value:
|
|
21
|
+
value: element.style.getPropertyValue(property)
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
24
|
styles.forEach(function (_ref3) {
|
|
25
25
|
var property = _ref3.property,
|
|
26
26
|
value = _ref3.value;
|
|
27
|
-
|
|
27
|
+
element.style.setProperty(property, value);
|
|
28
28
|
});
|
|
29
29
|
return function cleanup() {
|
|
30
30
|
priorValues.forEach(function (_ref4) {
|
|
31
31
|
var property = _ref4.property,
|
|
32
32
|
value = _ref4.value;
|
|
33
33
|
if (value === '') {
|
|
34
|
-
|
|
34
|
+
element.style.removeProperty(property);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
element.style.setProperty(property, value);
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -52,7 +52,7 @@ function isSlotChild(child) {
|
|
|
52
52
|
var Slot = exports.Slot = /*#__PURE__*/(0, _react.forwardRef)(function Slot(slotProps, ref) {
|
|
53
53
|
var rawChildren = slotProps.children,
|
|
54
54
|
props = (0, _objectWithoutProperties2.default)(slotProps, _excluded);
|
|
55
|
-
// `
|
|
55
|
+
// `TSlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
|
|
56
56
|
var children = rawChildren;
|
|
57
57
|
if (!isSlotChild(children)) {
|
|
58
58
|
return children;
|
|
@@ -11,7 +11,7 @@ var _useAnchorPosition = require("./use-anchor-position");
|
|
|
11
11
|
* anchor should be placed.
|
|
12
12
|
*
|
|
13
13
|
* Axis-named (`x`/`y`) rather than edge-named (`left`/`top`) so the
|
|
14
|
-
* shape is unambiguous in RTL writing modes
|
|
14
|
+
* shape is unambiguous in RTL writing modes - there is no ambiguity
|
|
15
15
|
* about whether a coordinate is logical (`inline-start`/`block-start`)
|
|
16
16
|
* or physical (`left`/`top`). Viewport coordinates are always
|
|
17
17
|
* physical, so we name them with the physical axis labels.
|
|
@@ -22,19 +22,19 @@ var _useAnchorPosition = require("./use-anchor-position");
|
|
|
22
22
|
* Dynamic `inset-*` overrides are written by the positioning effect.
|
|
23
23
|
*
|
|
24
24
|
* Uses `Object.assign` rather than Compiled CSS (element is outside the React tree)
|
|
25
|
-
* or the internal `setStyle` helper (we own this element entirely
|
|
26
|
-
* and removed by this hook
|
|
25
|
+
* or the internal `setStyle` helper (we own this element entirely - it is created
|
|
26
|
+
* and removed by this hook - so the snapshot/restore semantics `setStyle`
|
|
27
27
|
* provides for caller-owned elements would be dead work here).
|
|
28
28
|
*/
|
|
29
|
-
function applyStaticAnchorStyles(
|
|
30
|
-
Object.assign(
|
|
29
|
+
function applyStaticAnchorStyles(element) {
|
|
30
|
+
Object.assign(element.style, {
|
|
31
31
|
position: 'fixed',
|
|
32
32
|
// `top`/`left` rather than `inset-block-start`/`inset-inline-start`
|
|
33
33
|
// for consistency with the dynamic positioning effect below, which
|
|
34
34
|
// uses physical properties (see comment there for the rationale).
|
|
35
35
|
top: '0',
|
|
36
36
|
left: '0',
|
|
37
|
-
// Zero size
|
|
37
|
+
// Zero size - placement decides which side the popover sits on.
|
|
38
38
|
width: '0',
|
|
39
39
|
height: '0',
|
|
40
40
|
// Prevent the overlay from intercepting pointer events.
|
|
@@ -80,7 +80,7 @@ function useAnchorPositionAtPoint(_ref) {
|
|
|
80
80
|
var syntheticAnchorRef = (0, _react.useRef)(null);
|
|
81
81
|
|
|
82
82
|
// `getPoint` is kept in a ref so the layout effect can call the
|
|
83
|
-
// latest version without listing it as a dep
|
|
83
|
+
// latest version without listing it as a dep - that would re-fire
|
|
84
84
|
// on every render and re-latch the point.
|
|
85
85
|
var getPointRef = (0, _react.useRef)(getPoint);
|
|
86
86
|
getPointRef.current = getPoint;
|
|
@@ -116,7 +116,7 @@ function useAnchorPositionAtPoint(_ref) {
|
|
|
116
116
|
};
|
|
117
117
|
}, [isEnabled]);
|
|
118
118
|
|
|
119
|
-
// Mirror `isEnabled` so both hooks stay in sync
|
|
119
|
+
// Mirror `isEnabled` so both hooks stay in sync - when disabled,
|
|
120
120
|
// neither this hook nor the inner one touches the popover, leaving
|
|
121
121
|
// any other positioning the consumer has set up free to take effect.
|
|
122
122
|
(0, _useAnchorPosition.useAnchorPosition)({
|
|
@@ -152,17 +152,11 @@ function crossAxisShiftMargin(_ref2) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* Returns a referentially-stable, fully-resolved `TPlacement`.
|
|
156
|
-
* keyed on the primitive fields
|
|
157
|
-
*
|
|
158
|
-
* `getPlacement` and the equality check are skipped when the inputs are
|
|
159
|
-
* unchanged.
|
|
155
|
+
* Returns a referentially-stable, fully-resolved `TPlacement`. The memo is
|
|
156
|
+
* keyed on the resolved primitive fields so a fresh inline `placement` object
|
|
157
|
+
* (or undefined fields vs explicit defaults) does not produce a fresh result.
|
|
160
158
|
*/
|
|
161
159
|
function useStablePlacement(placement) {
|
|
162
|
-
// Resolve to the fully-defaulted primitives BEFORE the memo so the deps
|
|
163
|
-
// array sees the same key for `{}`, `undefined` fields, and explicit
|
|
164
|
-
// defaults. Otherwise `axis: undefined` and `axis: 'block'` would be
|
|
165
|
-
// treated as different inputs and re-run the downstream effect.
|
|
166
160
|
var resolved = (0, _resolvePlacement.getPlacement)({
|
|
167
161
|
placement: placement
|
|
168
162
|
});
|
|
@@ -172,10 +166,8 @@ function useStablePlacement(placement) {
|
|
|
172
166
|
var gap = resolved.offset.gap;
|
|
173
167
|
var shiftValue = resolved.offset.crossAxisShift.value;
|
|
174
168
|
var shiftDirection = resolved.offset.crossAxisShift.direction;
|
|
175
|
-
// Rebuild
|
|
176
|
-
//
|
|
177
|
-
// `resolved` reference, and `react-hooks/exhaustive-deps` can verify the
|
|
178
|
-
// deps array.
|
|
169
|
+
// Rebuild inside the memo from primitive deps so the factory does not
|
|
170
|
+
// close over the outer `resolved` reference and exhaustive-deps can verify.
|
|
179
171
|
return (0, _react.useMemo)(function () {
|
|
180
172
|
return {
|
|
181
173
|
axis: axis,
|
|
@@ -207,10 +199,6 @@ function useStablePlacement(placement) {
|
|
|
207
199
|
* When not supported, it falls back to JavaScript-based positioning using
|
|
208
200
|
* `position: fixed` with measured coordinates, re-running on scroll (capture)
|
|
209
201
|
* and resize events.
|
|
210
|
-
*
|
|
211
|
-
* `placement` may be a fresh inline object on every render: a structural
|
|
212
|
-
* comparison is used internally so re-runs are skipped when the resolved
|
|
213
|
-
* placement shape is unchanged.
|
|
214
202
|
*/
|
|
215
203
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
216
204
|
function useAnchorPosition(_ref3) {
|
|
@@ -224,8 +212,6 @@ function useAnchorPosition(_ref3) {
|
|
|
224
212
|
isEnabled = _ref3$isEnabled === void 0 ? true : _ref3$isEnabled,
|
|
225
213
|
isOpen = _ref3.isOpen;
|
|
226
214
|
var id = (0, _react.useId)();
|
|
227
|
-
// Stabilize `placement` object so the same object literal
|
|
228
|
-
// value returns an object with the same reference
|
|
229
215
|
var stablePlacement = useStablePlacement(placement);
|
|
230
216
|
(0, _react.useLayoutEffect)(function () {
|
|
231
217
|
if (!isEnabled) {
|
|
@@ -247,9 +233,9 @@ function useAnchorPosition(_ref3) {
|
|
|
247
233
|
placement: stablePlacement,
|
|
248
234
|
offset: gapCssValue
|
|
249
235
|
});
|
|
250
|
-
//
|
|
251
|
-
//
|
|
252
|
-
//
|
|
236
|
+
// Computed once; reused below to populate the active
|
|
237
|
+
// `--ds-cross-axis-shift-margin-*` custom property for the
|
|
238
|
+
// named arrow @position-try rules.
|
|
253
239
|
var crossAxisShift = crossAxisShiftMargin({
|
|
254
240
|
placement: stablePlacement,
|
|
255
241
|
crossAxisShiftCssValue: crossAxisShiftCssValue,
|
|
@@ -277,22 +263,17 @@ function useAnchorPosition(_ref3) {
|
|
|
277
263
|
}, {
|
|
278
264
|
property: 'inset',
|
|
279
265
|
value: 'auto'
|
|
280
|
-
},
|
|
281
|
-
// Main-axis gap between the popover and its trigger
|
|
282
|
-
{
|
|
266
|
+
}, {
|
|
283
267
|
property: gap.property,
|
|
284
268
|
value: gap.value
|
|
285
|
-
},
|
|
286
|
-
// Cross-axis shift
|
|
287
|
-
{
|
|
269
|
+
}, {
|
|
288
270
|
property: crossAxisShift.property,
|
|
289
271
|
value: crossAxisShift.value
|
|
290
272
|
}];
|
|
291
273
|
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
// at a time.
|
|
274
|
+
// Expose the active cross-axis shift via custom properties so each
|
|
275
|
+
// named arrow @position-try rule can re-apply it after a flip.
|
|
276
|
+
// One of the four (cross-axis, side) properties is non-zero at a time.
|
|
296
277
|
popoverStyles.push({
|
|
297
278
|
property: '--ds-cross-axis-shift-margin-start',
|
|
298
279
|
value: '0px'
|
|
@@ -309,9 +290,8 @@ function useAnchorPosition(_ref3) {
|
|
|
309
290
|
property: '--ds-cross-axis-shift-margin-block-end',
|
|
310
291
|
value: '0px'
|
|
311
292
|
});
|
|
312
|
-
// `crossAxisShift` IS the active margin
|
|
293
|
+
// `crossAxisShift` IS the active margin; reuse instead of recomputing.
|
|
313
294
|
var crossAxisShiftActive = crossAxisShift;
|
|
314
|
-
// Map margin property to its corresponding custom property name.
|
|
315
295
|
var customPropertyByMarginProperty = {
|
|
316
296
|
'margin-inline-start': '--ds-cross-axis-shift-margin-start',
|
|
317
297
|
'margin-inline-end': '--ds-cross-axis-shift-margin-end',
|
|
@@ -345,18 +325,17 @@ function useAnchorPosition(_ref3) {
|
|
|
345
325
|
*/
|
|
346
326
|
trigger.style.setProperty('anchor-name', anchorName);
|
|
347
327
|
var _undoPositioning = (0, _combine.combine)((0, _setStyle.setStyle)({
|
|
348
|
-
|
|
328
|
+
element: popover,
|
|
349
329
|
styles: popoverStyles
|
|
350
330
|
}));
|
|
351
331
|
return _undoPositioning;
|
|
352
332
|
}
|
|
353
333
|
|
|
354
|
-
// JS fallback
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
// (inset: 0; margin: auto) and set top/left based on measurements.
|
|
334
|
+
// JS fallback. The popover is already in the top layer via
|
|
335
|
+
// popover="auto", so we only reset UA defaults and set top/left
|
|
336
|
+
// based on measurements.
|
|
358
337
|
var cleanupBaseStyles = (0, _setStyle.setStyle)({
|
|
359
|
-
|
|
338
|
+
element: popover,
|
|
360
339
|
styles: [{
|
|
361
340
|
property: 'margin',
|
|
362
341
|
value: '0'
|