@atlaskit/dropdown-menu 16.10.5 → 17.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/CHANGELOG.md +32 -0
- package/__tests__/playwright/top-layer-focus.spec.tsx +165 -0
- package/dropdown-item-checkbox/package.json +1 -8
- package/dropdown-item-checkbox-group/package.json +1 -8
- package/dropdown-item-radio/package.json +1 -8
- package/dropdown-item-radio-group/package.json +1 -8
- package/dropdown-menu/package.json +1 -8
- package/dropdown-menu-item/package.json +1 -8
- package/dropdown-menu-item-group/package.json +1 -8
- package/package.json +30 -37
- package/types/package.json +1 -8
- package/dist/types-ts4.5/checkbox/dropdown-item-checkbox-group.d.ts +0 -16
- package/dist/types-ts4.5/checkbox/dropdown-item-checkbox.d.ts +0 -13
- package/dist/types-ts4.5/dropdown-menu-item-group.d.ts +0 -10
- package/dist/types-ts4.5/dropdown-menu-item.d.ts +0 -13
- package/dist/types-ts4.5/dropdown-menu-top-layer.d.ts +0 -18
- package/dist/types-ts4.5/dropdown-menu.d.ts +0 -13
- package/dist/types-ts4.5/index.d.ts +0 -8
- package/dist/types-ts4.5/internal/components/checkbox-icon.d.ts +0 -17
- package/dist/types-ts4.5/internal/components/focus-manager-context.d.ts +0 -12
- package/dist/types-ts4.5/internal/components/focus-manager.d.ts +0 -9
- package/dist/types-ts4.5/internal/components/group-title.d.ts +0 -18
- package/dist/types-ts4.5/internal/components/menu-wrapper.d.ts +0 -10
- package/dist/types-ts4.5/internal/components/radio-icon.d.ts +0 -17
- package/dist/types-ts4.5/internal/context/checkbox-group-context.d.ts +0 -4
- package/dist/types-ts4.5/internal/context/selection-store-context.d.ts +0 -16
- package/dist/types-ts4.5/internal/context/selection-store.d.ts +0 -11
- package/dist/types-ts4.5/internal/hooks/use-checkbox-state.d.ts +0 -17
- package/dist/types-ts4.5/internal/hooks/use-radio-state.d.ts +0 -12
- package/dist/types-ts4.5/internal/hooks/use-register-item-with-focus-manager.d.ts +0 -3
- package/dist/types-ts4.5/internal/use-arrow-navigation/index.d.ts +0 -2
- package/dist/types-ts4.5/internal/use-arrow-navigation/use-arrow-navigation.d.ts +0 -1
- package/dist/types-ts4.5/internal/utils/handle-focus.d.ts +0 -3
- package/dist/types-ts4.5/internal/utils/is-checkbox-item.d.ts +0 -1
- package/dist/types-ts4.5/internal/utils/is-radio-item.d.ts +0 -1
- package/dist/types-ts4.5/internal/utils/is-voice-over-supported.d.ts +0 -2
- package/dist/types-ts4.5/internal/utils/reset-options-in-group.d.ts +0 -4
- package/dist/types-ts4.5/internal/utils/use-generated-id.d.ts +0 -6
- package/dist/types-ts4.5/radio/dropdown-item-radio-group.d.ts +0 -13
- package/dist/types-ts4.5/radio/dropdown-item-radio.d.ts +0 -13
- package/dist/types-ts4.5/radio/radio-group-context.d.ts +0 -14
- package/dist/types-ts4.5/types.d.ts +0 -435
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 17.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
|
+
## 16.10.6
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
|
|
3
35
|
## 16.10.5
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import invariant from 'tiny-invariant';
|
|
2
|
+
|
|
3
|
+
import { expect, test } from '@af/integration-testing';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dropdown menu: focus contract on the top-layer code path.
|
|
7
|
+
*
|
|
8
|
+
* `DropdownMenu` renders a `role="menu"` popover. The focus contract is:
|
|
9
|
+
*
|
|
10
|
+
* 1. Initial focus moves to the first menu item on open.
|
|
11
|
+
* 2. Escape closes the menu and restores focus to the trigger.
|
|
12
|
+
* 3. ArrowDown moves focus to the next menu item within the menu.
|
|
13
|
+
*
|
|
14
|
+
* `DropdownMenu` also exposes an `autoFocus` boolean prop that overrides
|
|
15
|
+
* the trigger-source heuristic (focus the first item only when the
|
|
16
|
+
* trigger was activated via the keyboard) and forces focus to the first
|
|
17
|
+
* menu item whenever the menu opens. This spec exercises both variants.
|
|
18
|
+
*
|
|
19
|
+
* See: `platform/packages/design-system/top-layer/notes/architecture/focus.md`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const featureFlag = 'platform-dst-top-layer';
|
|
23
|
+
|
|
24
|
+
test.describe('Dropdown menu: top-layer focus contract', () => {
|
|
25
|
+
test('initial focus: focus moves to the first menu item on open', async ({ page }) => {
|
|
26
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
27
|
+
'design-system',
|
|
28
|
+
'dropdown-menu',
|
|
29
|
+
'testing-top-layer-focus',
|
|
30
|
+
{ featureFlag },
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
await page.getByTestId('dropdown--trigger').click();
|
|
34
|
+
|
|
35
|
+
await expect(page.getByTestId('dropdown-item-1')).toBeFocused();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('focus restoration: Escape restores focus to the trigger', async ({ page }) => {
|
|
39
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
40
|
+
'design-system',
|
|
41
|
+
'dropdown-menu',
|
|
42
|
+
'testing-top-layer-focus',
|
|
43
|
+
{ featureFlag },
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const trigger = page.getByTestId('dropdown--trigger');
|
|
47
|
+
await trigger.click();
|
|
48
|
+
await expect(page.getByTestId('dropdown-item-1')).toBeFocused();
|
|
49
|
+
|
|
50
|
+
await page.keyboard.press('Escape');
|
|
51
|
+
await expect(trigger).toBeFocused();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('focus movement: ArrowDown moves focus between menu items', async ({ page }) => {
|
|
55
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
56
|
+
'design-system',
|
|
57
|
+
'dropdown-menu',
|
|
58
|
+
'testing-top-layer-focus',
|
|
59
|
+
{ featureFlag },
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
await page.getByTestId('dropdown--trigger').click();
|
|
63
|
+
await expect(page.getByTestId('dropdown-item-1')).toBeFocused();
|
|
64
|
+
|
|
65
|
+
await page.keyboard.press('ArrowDown');
|
|
66
|
+
await expect(page.getByTestId('dropdown-item-2')).toBeFocused();
|
|
67
|
+
|
|
68
|
+
await page.keyboard.press('ArrowDown');
|
|
69
|
+
await expect(page.getByTestId('dropdown-item-3')).toBeFocused();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// WCAG 2.4.3 Focus Order + WAI-ARIA APG Menu Button pattern
|
|
73
|
+
// (https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/).
|
|
74
|
+
// "Enter / Space / Down Arrow: Opens the menu and moves focus to the
|
|
75
|
+
// first menu item." Keyboard activation must move focus to the
|
|
76
|
+
// first menu item even when `autoFocus` is left at its default.
|
|
77
|
+
test('initial focus: keyboard-triggered open focuses the first menu item (default `autoFocus={false}`)', async ({
|
|
78
|
+
page,
|
|
79
|
+
}) => {
|
|
80
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
81
|
+
'design-system',
|
|
82
|
+
'dropdown-menu',
|
|
83
|
+
'testing-top-layer-focus',
|
|
84
|
+
{ featureFlag },
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const trigger = page.getByTestId('dropdown--trigger');
|
|
88
|
+
await trigger.focus();
|
|
89
|
+
await page.keyboard.press('Enter');
|
|
90
|
+
|
|
91
|
+
await expect(page.getByTestId('dropdown-item-1')).toBeFocused();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// WCAG 2.4.3 Focus Order + WAI-ARIA APG Menu Button pattern. The
|
|
95
|
+
// `defaultOpen` prop mounts the menu in the open state, so there is
|
|
96
|
+
// no trigger interaction to source focus from. The menu must still
|
|
97
|
+
// move focus to the first menu item on mount, exercising the
|
|
98
|
+
// mount-time open path of `useInitialFocus`.
|
|
99
|
+
test('initial focus: `defaultOpen` focuses the first menu item on mount', async ({ page }) => {
|
|
100
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
101
|
+
'design-system',
|
|
102
|
+
'dropdown-menu',
|
|
103
|
+
'testing-top-layer-focus',
|
|
104
|
+
{ featureFlag },
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
await expect(page.getByTestId('dropdown-default-open-item-1')).toBeFocused();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// WCAG 2.4.3 Focus Order. `returnFocusRef` lets a consumer redirect
|
|
111
|
+
// Escape-restoration to a different element than the trigger. The
|
|
112
|
+
// dropdown's focus-restoration code runs after the browser's native
|
|
113
|
+
// trigger restoration, so the consumer-supplied target must win.
|
|
114
|
+
test('focus restoration: `returnFocusRef` redirects Escape focus to a sibling element', async ({
|
|
115
|
+
page,
|
|
116
|
+
}) => {
|
|
117
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
118
|
+
'design-system',
|
|
119
|
+
'dropdown-menu',
|
|
120
|
+
'testing-top-layer-focus',
|
|
121
|
+
{ featureFlag },
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const trigger = page.getByTestId('dropdown-return-focus-ref--trigger');
|
|
125
|
+
await trigger.focus();
|
|
126
|
+
await page.keyboard.press('Enter');
|
|
127
|
+
|
|
128
|
+
await expect(page.getByTestId('dropdown-return-focus-ref-item-1')).toBeFocused();
|
|
129
|
+
|
|
130
|
+
await page.keyboard.press('Escape');
|
|
131
|
+
|
|
132
|
+
// Focus must land on the consumer-supplied target, not on the
|
|
133
|
+
// trigger that opened the menu.
|
|
134
|
+
await expect(page.getByTestId('dropdown-return-focus-ref-target')).toBeFocused();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// WCAG 2.4.3 Focus Order + WAI-ARIA APG Menu Button pattern. The
|
|
138
|
+
// `autoFocus` prop is an opt-in override of the default
|
|
139
|
+
// trigger-source heuristic (focus the first item only on keyboard
|
|
140
|
+
// open). With `autoFocus={true}`, focus must move to the first
|
|
141
|
+
// menu item regardless of how the trigger was activated, which is
|
|
142
|
+
// the strict APG behaviour.
|
|
143
|
+
test('initial focus: `autoFocus={true}` focuses the first menu item even on real mouse open', async ({
|
|
144
|
+
page,
|
|
145
|
+
}) => {
|
|
146
|
+
await page.visitExample<typeof import('../../examples/testing-top-layer-focus.tsx')>(
|
|
147
|
+
'design-system',
|
|
148
|
+
'dropdown-menu',
|
|
149
|
+
'testing-top-layer-focus',
|
|
150
|
+
{ featureFlag },
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const trigger = page.getByTestId('dropdown-autofocus--trigger');
|
|
154
|
+
const box = await trigger.boundingBox();
|
|
155
|
+
invariant(box, 'autoFocus dropdown trigger should have a bounding box');
|
|
156
|
+
|
|
157
|
+
// Drive a real mouse click with non-zero coordinates so the
|
|
158
|
+
// dropdown's trigger-source heuristic classifies it as a mouse
|
|
159
|
+
// (not keyboard) activation. `autoFocus={true}` must still
|
|
160
|
+
// pull focus onto the first menu item.
|
|
161
|
+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
|
162
|
+
|
|
163
|
+
await expect(page.getByTestId('dropdown-autofocus-item-1')).toBeFocused();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/checkbox/dropdown-item-checkbox.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/checkbox/dropdown-item-checkbox.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/checkbox/dropdown-item-checkbox.d.ts"
|
|
17
10
|
}
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/checkbox/dropdown-item-checkbox-group.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/checkbox/dropdown-item-checkbox-group.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/checkbox/dropdown-item-checkbox-group.d.ts"
|
|
17
10
|
}
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/radio/dropdown-item-radio.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/radio/dropdown-item-radio.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/radio/dropdown-item-radio.d.ts"
|
|
17
10
|
}
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/radio/dropdown-item-radio-group.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/radio/dropdown-item-radio-group.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/radio/dropdown-item-radio-group.d.ts"
|
|
17
10
|
}
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/dropdown-menu-item.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/dropdown-menu-item.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/dropdown-menu-item.d.ts"
|
|
17
10
|
}
|
|
@@ -6,12 +6,5 @@
|
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.compiled.css"
|
|
8
8
|
],
|
|
9
|
-
"types": "../dist/types/dropdown-menu-item-group.d.ts"
|
|
10
|
-
"typesVersions": {
|
|
11
|
-
">=4.5 <5.9": {
|
|
12
|
-
"*": [
|
|
13
|
-
"../dist/types-ts4.5/dropdown-menu-item-group.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
"types": "../dist/types/dropdown-menu-item-group.d.ts"
|
|
17
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"description": "A dropdown menu displays a list of actions or options to a user.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/button": "^
|
|
35
|
-
"@atlaskit/css": "^0.
|
|
36
|
-
"@atlaskit/ds-lib": "^
|
|
37
|
-
"@atlaskit/icon": "^
|
|
38
|
-
"@atlaskit/layering": "^
|
|
39
|
-
"@atlaskit/menu": "^
|
|
40
|
-
"@atlaskit/platform-feature-flags": "^
|
|
41
|
-
"@atlaskit/popup": "^
|
|
42
|
-
"@atlaskit/primitives": "^
|
|
43
|
-
"@atlaskit/spinner": "^
|
|
44
|
-
"@atlaskit/theme": "^
|
|
45
|
-
"@atlaskit/tokens": "^
|
|
46
|
-
"@atlaskit/top-layer": "^0.
|
|
47
|
-
"@atlaskit/visually-hidden": "^
|
|
34
|
+
"@atlaskit/button": "^24.0.0",
|
|
35
|
+
"@atlaskit/css": "^1.0.0",
|
|
36
|
+
"@atlaskit/ds-lib": "^8.0.0",
|
|
37
|
+
"@atlaskit/icon": "^36.0.0",
|
|
38
|
+
"@atlaskit/layering": "^4.0.0",
|
|
39
|
+
"@atlaskit/menu": "^9.0.0",
|
|
40
|
+
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
41
|
+
"@atlaskit/popup": "^5.0.0",
|
|
42
|
+
"@atlaskit/primitives": "^20.0.0",
|
|
43
|
+
"@atlaskit/spinner": "^20.0.0",
|
|
44
|
+
"@atlaskit/theme": "^26.0.0",
|
|
45
|
+
"@atlaskit/tokens": "^14.0.0",
|
|
46
|
+
"@atlaskit/top-layer": "^1.0.0",
|
|
47
|
+
"@atlaskit/visually-hidden": "^4.0.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
49
49
|
"@compiled/react": "^0.20.0",
|
|
50
50
|
"bind-event-listener": "^3.0.0"
|
|
@@ -57,19 +57,19 @@
|
|
|
57
57
|
"@af/accessibility-testing": "workspace:^",
|
|
58
58
|
"@af/integration-testing": "workspace:^",
|
|
59
59
|
"@af/visual-regression": "workspace:^",
|
|
60
|
-
"@atlaskit/app-provider": "^
|
|
61
|
-
"@atlaskit/atlassian-navigation": "^
|
|
62
|
-
"@atlaskit/avatar": "^
|
|
63
|
-
"@atlaskit/checkbox": "^
|
|
64
|
-
"@atlaskit/docs": "^
|
|
65
|
-
"@atlaskit/form": "^
|
|
66
|
-
"@atlaskit/heading": "^
|
|
67
|
-
"@atlaskit/link": "^
|
|
68
|
-
"@atlaskit/lozenge": "^
|
|
69
|
-
"@atlaskit/modal-dialog": "^
|
|
70
|
-
"@atlaskit/section-message": "^
|
|
71
|
-
"@atlaskit/textfield": "^
|
|
72
|
-
"@atlaskit/toggle": "^
|
|
60
|
+
"@atlaskit/app-provider": "^5.0.0",
|
|
61
|
+
"@atlaskit/atlassian-navigation": "^6.0.0",
|
|
62
|
+
"@atlaskit/avatar": "^26.0.0",
|
|
63
|
+
"@atlaskit/checkbox": "^18.0.0",
|
|
64
|
+
"@atlaskit/docs": "^12.0.0",
|
|
65
|
+
"@atlaskit/form": "^16.0.0",
|
|
66
|
+
"@atlaskit/heading": "^6.0.0",
|
|
67
|
+
"@atlaskit/link": "^4.0.0",
|
|
68
|
+
"@atlaskit/lozenge": "^14.0.0",
|
|
69
|
+
"@atlaskit/modal-dialog": "^16.0.0",
|
|
70
|
+
"@atlaskit/section-message": "^9.0.0",
|
|
71
|
+
"@atlaskit/textfield": "^9.0.0",
|
|
72
|
+
"@atlaskit/toggle": "^17.0.0",
|
|
73
73
|
"@atlassian/a11y-jest-testing": "^0.12.0",
|
|
74
74
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|
|
75
75
|
"@atlassian/react-compiler-gating": "workspace:^",
|
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
"jest-in-case": "^1.0.2",
|
|
80
80
|
"raf-stub": "^2.0.1",
|
|
81
81
|
"react": "^18.2.0",
|
|
82
|
-
"react-dom": "^18.2.0"
|
|
82
|
+
"react-dom": "^18.2.0",
|
|
83
|
+
"tiny-invariant": "^1.2.0"
|
|
83
84
|
},
|
|
84
85
|
"keywords": [
|
|
85
86
|
"atlaskit",
|
|
@@ -129,13 +130,5 @@
|
|
|
129
130
|
"deprecation": "no-deprecated-imports"
|
|
130
131
|
}
|
|
131
132
|
},
|
|
132
|
-
"typesVersions": {
|
|
133
|
-
">=4.5 <4.9": {
|
|
134
|
-
"*": [
|
|
135
|
-
"dist/types-ts4.5/*",
|
|
136
|
-
"dist/types-ts4.5/index.d.ts"
|
|
137
|
-
]
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
133
|
"homepage": "https://atlassian.design/components/dropdown-menu/"
|
|
141
134
|
}
|
package/types/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { SectionProps } from '@atlaskit/menu';
|
|
3
|
-
interface DropdownItemCheckboxGroupProps extends SectionProps {
|
|
4
|
-
/**
|
|
5
|
-
* Unique identifier for the checkbox group.
|
|
6
|
-
*/
|
|
7
|
-
id: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* __Dropdown item checkbox group__
|
|
11
|
-
*
|
|
12
|
-
* A wrapping element for dropdown menu checkbox items.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
declare const DropdownItemCheckboxGroup: ({ children, hasSeparator, id, isList, isScrollable, testId, title, ...rest }: DropdownItemCheckboxGroupProps) => React.JSX.Element;
|
|
16
|
-
export default DropdownItemCheckboxGroup;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type DropdownItemCheckboxProps } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* __Dropdown item checkbox__
|
|
5
|
-
*
|
|
6
|
-
* A dropdown item checkbox creates groups that have multiple selections.
|
|
7
|
-
*
|
|
8
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/examples)
|
|
9
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
|
|
10
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
|
|
11
|
-
*/
|
|
12
|
-
declare const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, interactionName, ...rest }: DropdownItemCheckboxProps) => React.JSX.Element;
|
|
13
|
-
export default DropdownItemCheckbox;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type SectionProps } from '@atlaskit/menu';
|
|
3
|
-
/**
|
|
4
|
-
* __Dropdown item checkbox group__
|
|
5
|
-
*
|
|
6
|
-
* A wrapping element for dropdown menu items.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
declare const DropdownMenuItemGroup: React.ForwardRefExoticComponent<React.PropsWithoutRef<SectionProps> & React.RefAttributes<HTMLElement>>;
|
|
10
|
-
export default DropdownMenuItemGroup;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type DropdownItemProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* __Dropdown menu item__
|
|
5
|
-
*
|
|
6
|
-
* A dropdown item populates the dropdown menu with items. Every item should be inside a dropdown item group.
|
|
7
|
-
*
|
|
8
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item/examples)
|
|
9
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item/code)
|
|
10
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item/usage)
|
|
11
|
-
*/
|
|
12
|
-
declare const DropdownMenuItem: React.ForwardRefExoticComponent<React.PropsWithoutRef<DropdownItemProps> & React.RefAttributes<HTMLElement>>;
|
|
13
|
-
export default DropdownMenuItem;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { DropdownMenuProps } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Top-layer implementation of DropdownMenu.
|
|
4
|
-
*
|
|
5
|
-
* Replaces the legacy `@atlaskit/popup` + `@atlaskit/portal` + `@atlaskit/layering` pipeline
|
|
6
|
-
* with the native Popover API via `@atlaskit/top-layer`.
|
|
7
|
-
*
|
|
8
|
-
* What is no longer needed:
|
|
9
|
-
* - Portal: top layer handles stacking natively
|
|
10
|
-
* - FocusLock / react-focus-lock: popover=auto provides light dismiss
|
|
11
|
-
* - z-index: top layer is always above everything
|
|
12
|
-
* - FocusManager (ref registration): replaced by DOM-query-based `useArrowNavigation`
|
|
13
|
-
* - handle-focus.tsx: replaced by `useArrowNavigation`
|
|
14
|
-
* - Layering context: top layer nesting is handled by the browser
|
|
15
|
-
* - Fallback placements / Popper: CSS Anchor Positioning handles positioning
|
|
16
|
-
*/
|
|
17
|
-
declare function DropdownMenuTopLayer({ autoFocus, children, defaultOpen, isLoading, isOpen: isOpenProp, onOpenChange, placement, shouldFitContainer, returnFocusRef, spacing, statusLabel, testId, trigger, label, interactionName, menuLabel, }: DropdownMenuProps): React.JSX.Element;
|
|
18
|
-
export default DropdownMenuTopLayer;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { DropdownMenuProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* __Dropdown menu__
|
|
5
|
-
*
|
|
6
|
-
* A dropdown menu displays a list of actions or options to a user.
|
|
7
|
-
*
|
|
8
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/examples)
|
|
9
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/code)
|
|
10
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/usage)
|
|
11
|
-
*/
|
|
12
|
-
declare const DropdownMenu: <T extends HTMLElement = any>(props: DropdownMenuProps<T>) => React.JSX.Element;
|
|
13
|
-
export default DropdownMenu;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { default } from './dropdown-menu';
|
|
2
|
-
export { default as DropdownItemGroup } from './dropdown-menu-item-group';
|
|
3
|
-
export { default as DropdownItem } from './dropdown-menu-item';
|
|
4
|
-
export { default as DropdownItemCheckbox } from './checkbox/dropdown-item-checkbox';
|
|
5
|
-
export { default as DropdownItemCheckboxGroup } from './checkbox/dropdown-item-checkbox-group';
|
|
6
|
-
export { default as DropdownItemRadio } from './radio/dropdown-item-radio';
|
|
7
|
-
export { default as DropdownItemRadioGroup } from './radio/dropdown-item-radio-group';
|
|
8
|
-
export type { DropdownMenuProps, DropdownMenuGroupProps, DropdownItemProps, OnOpenChangeArgs, CustomTriggerProps, } from './types';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
* @jsxFrag jsx
|
|
5
|
-
*/
|
|
6
|
-
import React from 'react';
|
|
7
|
-
/**
|
|
8
|
-
* __Checkbox icon__
|
|
9
|
-
*
|
|
10
|
-
* Used to visually represent the selected state in DropdownItemCheckbox
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
declare const CheckboxIcon: ({ checked }: {
|
|
15
|
-
checked: boolean;
|
|
16
|
-
}) => React.JSX.Element;
|
|
17
|
-
export default CheckboxIcon;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type FocusableElementRef } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* __Focus manager context__
|
|
5
|
-
*
|
|
6
|
-
* A context that stores dropdown menu item refs and provides a way to register
|
|
7
|
-
* them for focus management within the dropdown menu.
|
|
8
|
-
*/
|
|
9
|
-
export declare const FocusManagerContext: React.Context<{
|
|
10
|
-
menuItemRefs: FocusableElementRef[];
|
|
11
|
-
registerRef(ref: FocusableElementRef): void;
|
|
12
|
-
}>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* __Group title__
|
|
4
|
-
*
|
|
5
|
-
* Used to visually represent the title for DropdownMenu groups.
|
|
6
|
-
*
|
|
7
|
-
* Pre-existing a11y note: uses `role="menuitem"` with `aria-hidden="true"`.
|
|
8
|
-
* WAI-ARIA APG recommends `role="presentation"` for non-interactive group
|
|
9
|
-
* headings, with the group linked via `aria-labelledby`. Out of scope for
|
|
10
|
-
* the top-layer migration — this is legacy behavior.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
declare const GroupTitle: ({ id, title }: {
|
|
15
|
-
id: string;
|
|
16
|
-
title: string;
|
|
17
|
-
}) => React.JSX.Element;
|
|
18
|
-
export default GroupTitle;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type MenuWrapperProps } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* MenuWrapper wraps all the menu items.
|
|
5
|
-
* It handles the logic to close the menu when a MenuItem is clicked, but leaves it open
|
|
6
|
-
* if a CheckboxItem or RadioItem is clicked.
|
|
7
|
-
* It also sets focus to the first menu item when opened.
|
|
8
|
-
*/
|
|
9
|
-
declare const MenuWrapper: ({ children, isLoading, maxHeight, maxWidth, onClose, onUpdate, statusLabel, setInitialFocusRef, shouldRenderToParent, spacing, testId, isTriggeredUsingKeyboard, autoFocus, menuLabel, }: MenuWrapperProps) => JSX.Element;
|
|
10
|
-
export default MenuWrapper;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
* @jsxFrag jsx
|
|
5
|
-
*/
|
|
6
|
-
import React from 'react';
|
|
7
|
-
/**
|
|
8
|
-
* __Radio icon__
|
|
9
|
-
*
|
|
10
|
-
* Used to visually represent the selected state in DropdownItemRadio
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
declare const RadioIcon: ({ checked }: {
|
|
15
|
-
checked: boolean;
|
|
16
|
-
}) => React.JSX.Element;
|
|
17
|
-
export default RadioIcon;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export type OptionsInGroup = {
|
|
3
|
-
[key: string]: boolean | undefined;
|
|
4
|
-
};
|
|
5
|
-
export type SelectionStoreContextProps = {
|
|
6
|
-
setItemState: (group: string, id: string, value: boolean | undefined) => void;
|
|
7
|
-
getItemState: (group: string, id: string) => boolean | undefined;
|
|
8
|
-
setGroupState: (group: string, value: OptionsInGroup) => void;
|
|
9
|
-
getGroupState: (group: string) => OptionsInGroup;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* __Selection store context__
|
|
13
|
-
*
|
|
14
|
-
* A context that stores the selection state of the dropdown menu items.
|
|
15
|
-
*/
|
|
16
|
-
export declare const SelectionStoreContext: React.Context<SelectionStoreContextProps>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
type SelectionStoreProps = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Selection store will persist data as long as it remains mounted.
|
|
7
|
-
* It handles the uncontrolled story for dropdown menu when the menu
|
|
8
|
-
* items can be mounted/unmounted depending if the menu is open or closed.
|
|
9
|
-
*/
|
|
10
|
-
declare const SelectionStore: (props: SelectionStoreProps) => React.JSX.Element;
|
|
11
|
-
export default SelectionStore;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type CheckboxStateArgs = {
|
|
2
|
-
id: string;
|
|
3
|
-
isSelected: boolean | undefined;
|
|
4
|
-
defaultSelected: boolean | undefined;
|
|
5
|
-
};
|
|
6
|
-
type SetStateCallback = (value: boolean | undefined) => boolean;
|
|
7
|
-
type CheckboxStateValue = [
|
|
8
|
-
boolean,
|
|
9
|
-
(newValue: SetStateCallback) => void
|
|
10
|
-
];
|
|
11
|
-
/**
|
|
12
|
-
* Custom hook to handle checkbox state for dropdown menu.
|
|
13
|
-
* It works in tandem with the selection store context when the
|
|
14
|
-
* component is uncontrolled.
|
|
15
|
-
*/
|
|
16
|
-
declare const useCheckboxState: ({ isSelected, id, defaultSelected, }: CheckboxStateArgs) => CheckboxStateValue;
|
|
17
|
-
export default useCheckboxState;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type RadioStateArgs = {
|
|
2
|
-
id: string;
|
|
3
|
-
isSelected: boolean | undefined;
|
|
4
|
-
defaultSelected: boolean | undefined;
|
|
5
|
-
};
|
|
6
|
-
type SetStateCallback = (value: boolean | undefined) => boolean;
|
|
7
|
-
type RadioStateValue = [
|
|
8
|
-
boolean,
|
|
9
|
-
(newValue: SetStateCallback) => void
|
|
10
|
-
];
|
|
11
|
-
declare function useRadioState({ id, isSelected, defaultSelected }: RadioStateArgs): RadioStateValue;
|
|
12
|
-
export default useRadioState;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useArrowNavigation, isAtCurrentMenuLevel, type TUseArrowNavigationArgs, } from '@atlaskit/top-layer/use-arrow-navigation';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
|
-
import { type FocusableElementRef } from '../../types';
|
|
3
|
-
export default function handleFocus(refs: RefObject<FocusableElementRef[]>, isLayerDisabled: () => boolean, onClose: (e: KeyboardEvent) => void, isNestedMenu?: boolean): (e: KeyboardEvent) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function isCheckboxItem(element: HTMLElement): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function isCheckboxItem(element: HTMLElement): boolean;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type SectionProps } from '@atlaskit/menu';
|
|
3
|
-
interface DropdownItemRadioGroupProps extends SectionProps {
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* __Dropdown item radio group__
|
|
8
|
-
* Store which manages the selection state for each DropdownItemRadio
|
|
9
|
-
* across mount and unmounts.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
declare const DropdownItemRadioGroup: ({ children, hasSeparator, id, isList, isScrollable, testId, title, ...rest }: DropdownItemRadioGroupProps) => React.JSX.Element;
|
|
13
|
-
export default DropdownItemRadioGroup;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type DropdownItemRadioProps } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* __Dropdown item radio__
|
|
5
|
-
*
|
|
6
|
-
* A dropdown item radio displays groups that have a single selection.
|
|
7
|
-
*
|
|
8
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/examples)
|
|
9
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
|
|
10
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
|
|
11
|
-
*/
|
|
12
|
-
declare const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, interactionName, ...rest }: DropdownItemRadioProps) => React.JSX.Element;
|
|
13
|
-
export default DropdownItemRadio;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface RadioGroupContextProps {
|
|
3
|
-
id: string;
|
|
4
|
-
radioGroupState: {
|
|
5
|
-
[key: string]: boolean | undefined;
|
|
6
|
-
};
|
|
7
|
-
selectRadioItem: (id: string, value: boolean) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* __Radio group context__
|
|
11
|
-
* Context provider that wraps each DropdownItemRadioGroup
|
|
12
|
-
*/
|
|
13
|
-
export declare const RadioGroupContext: React.Context<RadioGroupContextProps>;
|
|
14
|
-
export {};
|
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
import { type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type Ref, type RefObject } from 'react';
|
|
2
|
-
import type { CustomItemComponentProps, CustomItemProps, MenuGroupProps, SectionProps } from '@atlaskit/menu/types';
|
|
3
|
-
import type { ContentProps, TriggerProps } from '@atlaskit/popup/types';
|
|
4
|
-
export type FocusableElementRef = RefObject<HTMLAnchorElement | HTMLButtonElement>;
|
|
5
|
-
export type Action = 'next' | 'prev' | 'first' | 'last' | 'tab';
|
|
6
|
-
export type Placement = 'auto-start' | 'auto' | 'auto-end' | 'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-end' | 'bottom' | 'bottom-start' | 'left-end' | 'left' | 'left-start';
|
|
7
|
-
export type ItemId = string;
|
|
8
|
-
export type GroupId = string;
|
|
9
|
-
export type CachedItem = {
|
|
10
|
-
id: ItemId;
|
|
11
|
-
groupId: GroupId;
|
|
12
|
-
};
|
|
13
|
-
export type FocusItem = {
|
|
14
|
-
itemId: ItemId;
|
|
15
|
-
itemNode: HTMLElement;
|
|
16
|
-
};
|
|
17
|
-
export type Behaviors = 'checkbox' | 'radio' | 'menuitemcheckbox' | 'menuitemradio';
|
|
18
|
-
export interface CustomTriggerProps<TriggerElement extends HTMLElement = any> extends Omit<TriggerProps, 'ref'> {
|
|
19
|
-
/**
|
|
20
|
-
* Ref that should be applied to the trigger. This is used to calculate the menu position.
|
|
21
|
-
*/
|
|
22
|
-
triggerRef: Ref<TriggerElement>;
|
|
23
|
-
/**
|
|
24
|
-
* Makes the trigger appear selected.
|
|
25
|
-
*/
|
|
26
|
-
isSelected?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Event that is triggered when the element is clicked.
|
|
29
|
-
*/
|
|
30
|
-
onClick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
31
|
-
/**
|
|
32
|
-
* onFocus handler that should be applied to the trigger. Used to bind onKeyDown listener
|
|
33
|
-
* to the window object to track ArrowDown events.
|
|
34
|
-
*/
|
|
35
|
-
onFocus?: () => void;
|
|
36
|
-
/**
|
|
37
|
-
* onBlur handler that should be applied to the trigger. Used to unbind onKeyDown listener
|
|
38
|
-
* from the window object.
|
|
39
|
-
*/
|
|
40
|
-
onBlur?: () => void;
|
|
41
|
-
/**
|
|
42
|
-
* A `testId` prop is provided for specified elements, which is a unique
|
|
43
|
-
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
44
|
-
* serving as a hook for automated tests.
|
|
45
|
-
*
|
|
46
|
-
* As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
|
|
47
|
-
* - `testId--trigger` to get the menu trigger.
|
|
48
|
-
* - `testId--content` to get the dropdown content trigger.
|
|
49
|
-
*/
|
|
50
|
-
testId?: string;
|
|
51
|
-
}
|
|
52
|
-
export interface OnOpenChangeArgs {
|
|
53
|
-
isOpen: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* The event that triggered the close.
|
|
56
|
-
* The value will be `null` when the dropdown is closed programatically and has no corresponding event.
|
|
57
|
-
*/
|
|
58
|
-
event: Event | MouseEvent | KeyboardEvent | null;
|
|
59
|
-
}
|
|
60
|
-
export interface MenuWrapperProps extends MenuGroupProps {
|
|
61
|
-
setInitialFocusRef?: ContentProps['setInitialFocusRef'];
|
|
62
|
-
onClose?: ContentProps['onClose'];
|
|
63
|
-
onUpdate: ContentProps['update'];
|
|
64
|
-
isLoading?: InternalDropdownMenuProps['isLoading'];
|
|
65
|
-
statusLabel?: InternalDropdownMenuProps['statusLabel'];
|
|
66
|
-
shouldRenderToParent?: boolean;
|
|
67
|
-
isTriggeredUsingKeyboard?: boolean;
|
|
68
|
-
autoFocus?: boolean;
|
|
69
|
-
}
|
|
70
|
-
export interface DropdownMenuGroupProps extends SectionProps {
|
|
71
|
-
}
|
|
72
|
-
interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
|
|
73
|
-
/**
|
|
74
|
-
* Controls the appearance of the menu.
|
|
75
|
-
* The default menu will scroll after its height exceeds the pre-defined amount.
|
|
76
|
-
* The tall menu won't scroll until the height exceeds the height of the viewport.
|
|
77
|
-
*/
|
|
78
|
-
appearance?: 'default' | 'tall';
|
|
79
|
-
/**
|
|
80
|
-
* Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
|
|
81
|
-
* which traps the focus within the menu. The first item gets focus automatically
|
|
82
|
-
* if the menu is triggered using the keyboard.
|
|
83
|
-
*
|
|
84
|
-
*/
|
|
85
|
-
autoFocus?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Content that will be rendered inside the layer element. Should typically be
|
|
88
|
-
* `DropdownItemGroup` or `DropdownItem`, or the checkbox and radio variants of those.
|
|
89
|
-
*/
|
|
90
|
-
children?: ReactNode;
|
|
91
|
-
/**
|
|
92
|
-
* If true, a spinner is rendered instead of the items.
|
|
93
|
-
*/
|
|
94
|
-
isLoading?: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Text to be used as status for assistive technologies. Defaults to "Loading".
|
|
97
|
-
*/
|
|
98
|
-
statusLabel?: string;
|
|
99
|
-
/**
|
|
100
|
-
* Controls the open state of the dropdown.
|
|
101
|
-
*/
|
|
102
|
-
isOpen?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Position of the menu.
|
|
105
|
-
*/
|
|
106
|
-
placement?: Placement;
|
|
107
|
-
/**
|
|
108
|
-
* This fits the dropdown menu width to its parent's width.
|
|
109
|
-
* When set to `true`, the trigger and dropdown menu elements will be wrapped in a `div` with `position: relative`.
|
|
110
|
-
* The dropdown menu will be rendered as a sibling to the trigger element, and will be full width.
|
|
111
|
-
* The default is `false`.
|
|
112
|
-
*/
|
|
113
|
-
shouldFitContainer?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
|
|
116
|
-
* fit in the viewport.
|
|
117
|
-
*
|
|
118
|
-
* @private
|
|
119
|
-
* @deprecated No-op when `platform-dst-top-layer` is enabled — CSS Anchor Positioning
|
|
120
|
-
* handles flipping natively via `position-try-fallbacks`.
|
|
121
|
-
*/
|
|
122
|
-
shouldFlip?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Controls whether the popup is rendered inline within its parent component or in a portal at the document root.
|
|
125
|
-
* `true` renders the dropdown menu in the DOM node closest to the trigger; focus is not trapped inside the element.
|
|
126
|
-
* `false` renders the dropdown menu in React.Portal and focus is trapped inside the element.
|
|
127
|
-
* Defaults to `false`.
|
|
128
|
-
*
|
|
129
|
-
* @private
|
|
130
|
-
* @deprecated No-op when `platform-dst-top-layer` is enabled — content always
|
|
131
|
-
* renders in the browser's top layer.
|
|
132
|
-
*/
|
|
133
|
-
shouldRenderToParent?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Controls the spacing density of the menu.
|
|
136
|
-
*/
|
|
137
|
-
spacing?: Extract<MenuGroupProps['spacing'], 'cozy' | 'compact'>;
|
|
138
|
-
/**
|
|
139
|
-
* Content that triggers the dropdown menu to open and close. Use with
|
|
140
|
-
* `triggerType` to get a button trigger. To customize the trigger element,
|
|
141
|
-
* provide a function to this prop. You can find
|
|
142
|
-
* [examples for custom triggers](https://atlassian.design/components/dropdown-menu/examples#custom-triggers)
|
|
143
|
-
* in our documentation.
|
|
144
|
-
*/
|
|
145
|
-
trigger?: string | ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement);
|
|
146
|
-
/**
|
|
147
|
-
* A `testId` prop is provided for specified elements, which is a unique
|
|
148
|
-
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
149
|
-
* serving as a hook for automated tests.
|
|
150
|
-
*
|
|
151
|
-
* As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
|
|
152
|
-
* - `testId--trigger` to get the menu trigger.
|
|
153
|
-
* - `testId--content` to get the dropdown content trigger.
|
|
154
|
-
*/
|
|
155
|
-
testId?: string;
|
|
156
|
-
/**
|
|
157
|
-
* Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
|
|
158
|
-
* which means that the user is responsible for managing the open and close state of the menu.
|
|
159
|
-
* Using `defaultOpen` may cause accessiblity issues because it will automatically shift focus to the first menu item; which can be disorienting.
|
|
160
|
-
* Only use this if action on the menu is required to proceed.
|
|
161
|
-
*/
|
|
162
|
-
defaultOpen?: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Called when the menu should be open/closed. Receives an object with `isOpen` state.
|
|
165
|
-
*
|
|
166
|
-
* If the dropdown was closed programatically, the `event` parameter will be `null`.
|
|
167
|
-
*/
|
|
168
|
-
onOpenChange?: (args: OnOpenChangeArgs) => void;
|
|
169
|
-
/**
|
|
170
|
-
* Z-index that the popup should be displayed in.
|
|
171
|
-
* This is passed to the portal component.
|
|
172
|
-
* Defaults to `layers.modal()` from `@atlaskit/theme` which is 510.
|
|
173
|
-
*
|
|
174
|
-
* @private
|
|
175
|
-
* @deprecated No-op when `platform-dst-top-layer` is enabled — the browser's
|
|
176
|
-
* top layer manages stacking without z-index.
|
|
177
|
-
*/
|
|
178
|
-
zIndex?: number;
|
|
179
|
-
/**
|
|
180
|
-
* Provide an accessible label via `aria-label` for assistive technology.
|
|
181
|
-
*/
|
|
182
|
-
label?: string;
|
|
183
|
-
/**
|
|
184
|
-
* If ref is passed, focus returns to that specific ref element after dropdown dismissed.
|
|
185
|
-
*/
|
|
186
|
-
returnFocusRef?: RefObject<HTMLElement>;
|
|
187
|
-
/**
|
|
188
|
-
* An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
|
|
189
|
-
*/
|
|
190
|
-
interactionName?: string;
|
|
191
|
-
/**
|
|
192
|
-
* This controls the positioning strategy to use. Can vary between `absolute` and `fixed`.
|
|
193
|
-
* The default is `fixed`.
|
|
194
|
-
*
|
|
195
|
-
* @private
|
|
196
|
-
* @deprecated No-op when `platform-dst-top-layer` is enabled — CSS Anchor Positioning
|
|
197
|
-
* replaces Popper's positioning strategy.
|
|
198
|
-
*/
|
|
199
|
-
strategy?: 'absolute' | 'fixed';
|
|
200
|
-
/**
|
|
201
|
-
* Provide an accessible label for the menu element for assistive technology.
|
|
202
|
-
*/
|
|
203
|
-
menuLabel?: string;
|
|
204
|
-
/**
|
|
205
|
-
* Allows consumers to ignore specific close events, for example when an external overlay
|
|
206
|
-
* should be treated as part of the dropdown interaction.
|
|
207
|
-
*/
|
|
208
|
-
shouldIgnoreCloseEvent?: (event: Event | MouseEvent | KeyboardEvent) => boolean;
|
|
209
|
-
/**
|
|
210
|
-
* When set to true, will call stopPropagation on the ESCAPE key event.
|
|
211
|
-
* This prevents the ESCAPE event from bubbling up to parent elements.
|
|
212
|
-
*
|
|
213
|
-
* @private
|
|
214
|
-
* @deprecated No-op when `platform-dst-top-layer` is enabled — the native
|
|
215
|
-
* popover dismiss handles Escape propagation.
|
|
216
|
-
*/
|
|
217
|
-
shouldPreventEscapePropagation?: boolean;
|
|
218
|
-
}
|
|
219
|
-
type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
|
|
220
|
-
shouldFitContainer?: false;
|
|
221
|
-
};
|
|
222
|
-
type ShouldFitContainerDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
|
|
223
|
-
shouldFitContainer: true;
|
|
224
|
-
shouldRenderToParent?: true;
|
|
225
|
-
strategy?: 'absolute';
|
|
226
|
-
};
|
|
227
|
-
export type DropdownMenuProps<TriggerElement extends HTMLElement = any> = StandardDropdownMenuProps<TriggerElement> | ShouldFitContainerDropdownMenuProps<TriggerElement>;
|
|
228
|
-
export interface DropdownItemProps {
|
|
229
|
-
/**
|
|
230
|
-
* Primary content for the item.
|
|
231
|
-
*/
|
|
232
|
-
children: React.ReactNode;
|
|
233
|
-
/**
|
|
234
|
-
* Custom component to render as an item.
|
|
235
|
-
* Should be wrapped in `forwardRef` to avoid accessibility issues when controlling keyboard focus.
|
|
236
|
-
*/
|
|
237
|
-
component?: CustomItemProps['component'];
|
|
238
|
-
/**
|
|
239
|
-
* Description of the item.
|
|
240
|
-
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
241
|
-
*/
|
|
242
|
-
description?: string | JSX.Element;
|
|
243
|
-
/**
|
|
244
|
-
* Makes the element appear disabled. This will remove interactivity and the item won't appear in the focus order.
|
|
245
|
-
*/
|
|
246
|
-
isDisabled?: boolean;
|
|
247
|
-
/**
|
|
248
|
-
* When `true` the title of the item will wrap multiple lines if it exceeds the width of the dropdown menu.
|
|
249
|
-
*/
|
|
250
|
-
shouldTitleWrap?: boolean;
|
|
251
|
-
/**
|
|
252
|
-
* When `true` the description of the item will wrap multiple lines if it exceeds the width of the dropdown menu.
|
|
253
|
-
*/
|
|
254
|
-
shouldDescriptionWrap?: boolean;
|
|
255
|
-
/**
|
|
256
|
-
* Event that is triggered when the element is clicked.
|
|
257
|
-
*/
|
|
258
|
-
onClick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
259
|
-
/**
|
|
260
|
-
* Makes the element appear selected.
|
|
261
|
-
*/
|
|
262
|
-
isSelected?: boolean;
|
|
263
|
-
/**
|
|
264
|
-
* Link to another page.
|
|
265
|
-
*/
|
|
266
|
-
href?: string;
|
|
267
|
-
/**
|
|
268
|
-
* Where to display the linked URL,
|
|
269
|
-
* see [anchor information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) on mdn for more information.
|
|
270
|
-
*/
|
|
271
|
-
target?: string;
|
|
272
|
-
/**
|
|
273
|
-
* Adds a title attribute to the root item element.
|
|
274
|
-
*/
|
|
275
|
-
title?: string;
|
|
276
|
-
/**
|
|
277
|
-
* Element to render before the item text.
|
|
278
|
-
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
279
|
-
*/
|
|
280
|
-
elemBefore?: React.ReactNode;
|
|
281
|
-
/**
|
|
282
|
-
* Element to render after the item text.
|
|
283
|
-
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
284
|
-
*/
|
|
285
|
-
elemAfter?: React.ReactNode;
|
|
286
|
-
/**
|
|
287
|
-
* The relationship of the linked URL as space-separated link types.
|
|
288
|
-
* Generally you'll want to set this to "noopener noreferrer" when `target` is "_blank".
|
|
289
|
-
*/
|
|
290
|
-
rel?: string;
|
|
291
|
-
/**
|
|
292
|
-
* A `testId` prop is provided for specified elements,
|
|
293
|
-
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
294
|
-
* serving as a hook for automated tests.
|
|
295
|
-
*/
|
|
296
|
-
testId?: string;
|
|
297
|
-
/**
|
|
298
|
-
* Use this to opt out of using a router link and instead use a regular anchor element when
|
|
299
|
-
* using the `href` prop.
|
|
300
|
-
* Marked as "unsafe" because ideally, router links should be used for all internal links.
|
|
301
|
-
*/
|
|
302
|
-
UNSAFE_shouldDisableRouterLink?: boolean;
|
|
303
|
-
/**
|
|
304
|
-
* If ref is passed, focus returns to that specific ref element after dropdown item clicked.
|
|
305
|
-
*/
|
|
306
|
-
returnFocusRef?: RefObject<HTMLElement>;
|
|
307
|
-
/**
|
|
308
|
-
* An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
|
|
309
|
-
*/
|
|
310
|
-
interactionName?: string;
|
|
311
|
-
/**
|
|
312
|
-
* An optional boolean value used to indicate if the dropdown item has popup or not.
|
|
313
|
-
*/
|
|
314
|
-
'aria-haspopup'?: boolean | 'dialog';
|
|
315
|
-
/**
|
|
316
|
-
* An optional string value that specifies the role of the dropdown item.
|
|
317
|
-
* Use this to indicate whether the item is
|
|
318
|
-
* or presentational (e.g., 'presentation') for accessibility purposes.
|
|
319
|
-
* If not specified, it defaults to role="menuitem".
|
|
320
|
-
*/
|
|
321
|
-
role?: string;
|
|
322
|
-
}
|
|
323
|
-
export interface DropdownItemCheckboxProps {
|
|
324
|
-
/**
|
|
325
|
-
* Primary content for the item.
|
|
326
|
-
*/
|
|
327
|
-
children: React.ReactNode;
|
|
328
|
-
/**
|
|
329
|
-
* Description of the item.
|
|
330
|
-
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
331
|
-
*/
|
|
332
|
-
description?: string | JSX.Element;
|
|
333
|
-
/**
|
|
334
|
-
* Makes the checkbox appear disabled as well as removing interactivity.
|
|
335
|
-
*/
|
|
336
|
-
isDisabled?: boolean;
|
|
337
|
-
/**
|
|
338
|
-
* When `true` the title of the item will wrap multiple lines if it's long enough.
|
|
339
|
-
*/
|
|
340
|
-
shouldTitleWrap?: boolean;
|
|
341
|
-
/**
|
|
342
|
-
* When `true` the description of the item will wrap multiple lines if it's long enough.
|
|
343
|
-
*/
|
|
344
|
-
shouldDescriptionWrap?: boolean;
|
|
345
|
-
/**
|
|
346
|
-
* Event that is triggered when the checkbox is clicked.
|
|
347
|
-
*/
|
|
348
|
-
onClick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
349
|
-
/**
|
|
350
|
-
* Sets whether the checkbox is checked or unchecked.
|
|
351
|
-
*/
|
|
352
|
-
isSelected?: boolean;
|
|
353
|
-
/**
|
|
354
|
-
* Sets whether the checkbox begins selected.
|
|
355
|
-
*/
|
|
356
|
-
defaultSelected?: boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Unique id of a checkbox.
|
|
359
|
-
*/
|
|
360
|
-
id: string;
|
|
361
|
-
/**
|
|
362
|
-
* Adds a title attribute to the root item element.
|
|
363
|
-
*/
|
|
364
|
-
title?: string;
|
|
365
|
-
/**
|
|
366
|
-
* A `testId` prop is provided for specified elements,
|
|
367
|
-
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
368
|
-
* serving as a hook for automated tests.
|
|
369
|
-
*/
|
|
370
|
-
testId?: string;
|
|
371
|
-
/**
|
|
372
|
-
* An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
|
|
373
|
-
*/
|
|
374
|
-
interactionName?: string;
|
|
375
|
-
}
|
|
376
|
-
export interface DropdownItemRadioProps {
|
|
377
|
-
/**
|
|
378
|
-
* Primary content for the item.
|
|
379
|
-
*/
|
|
380
|
-
children: React.ReactNode;
|
|
381
|
-
/**
|
|
382
|
-
* Description of the item.
|
|
383
|
-
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
384
|
-
*/
|
|
385
|
-
description?: string | JSX.Element;
|
|
386
|
-
/**
|
|
387
|
-
* Makes the checkbox appear disabled as well as removing interactivity.
|
|
388
|
-
*/
|
|
389
|
-
isDisabled?: boolean;
|
|
390
|
-
/**
|
|
391
|
-
* When `true` the title of the item will wrap multiple lines if it's long enough.
|
|
392
|
-
*/
|
|
393
|
-
shouldTitleWrap?: boolean;
|
|
394
|
-
/**
|
|
395
|
-
* When `true` the description of the item will wrap multiple lines if it's long enough.
|
|
396
|
-
*/
|
|
397
|
-
shouldDescriptionWrap?: boolean;
|
|
398
|
-
/**
|
|
399
|
-
* Event that is triggered when the checkbox is clicked.
|
|
400
|
-
*/
|
|
401
|
-
onClick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
402
|
-
/**
|
|
403
|
-
* Sets whether the checkbox is checked or unchecked.
|
|
404
|
-
*/
|
|
405
|
-
isSelected?: boolean;
|
|
406
|
-
/**
|
|
407
|
-
* Sets whether the checkbox begins selected.
|
|
408
|
-
*/
|
|
409
|
-
defaultSelected?: boolean;
|
|
410
|
-
/**
|
|
411
|
-
* Unique ID of the checkbox.
|
|
412
|
-
*/
|
|
413
|
-
id: string;
|
|
414
|
-
/**
|
|
415
|
-
* Adds a title attribute to the root item element.
|
|
416
|
-
*/
|
|
417
|
-
title?: string;
|
|
418
|
-
/**
|
|
419
|
-
* A `testId` prop is provided for specified elements,
|
|
420
|
-
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
421
|
-
* serving as a hook for automated tests.
|
|
422
|
-
*/
|
|
423
|
-
testId?: string;
|
|
424
|
-
/**
|
|
425
|
-
* An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
|
|
426
|
-
*/
|
|
427
|
-
interactionName?: string;
|
|
428
|
-
}
|
|
429
|
-
export interface CustomItemHtmlProps extends CustomItemComponentProps {
|
|
430
|
-
/**
|
|
431
|
-
* Link to another page.
|
|
432
|
-
*/
|
|
433
|
-
href?: string;
|
|
434
|
-
}
|
|
435
|
-
export {};
|