@atlaskit/dropdown-menu 12.11.1 → 12.13.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 +23 -1
- package/README.md +2 -1
- package/__perf__/default.tsx +12 -12
- package/__perf__/dropdown-menu.tsx +165 -195
- package/codemods/11.0.0-lite-mode.tsx +23 -23
- package/codemods/__tests__/11.0.0-lite-mode.test.tsx +7 -7
- package/codemods/__tests__/convert-position.test.tsx +70 -70
- package/codemods/__tests__/convert-triggerType.test.tsx +35 -35
- package/codemods/__tests__/deprecate-items.test.tsx +28 -28
- package/codemods/__tests__/deprecate-onItemActivated.test.tsx +28 -28
- package/codemods/__tests__/deprecate-onPositioned.test.tsx +28 -28
- package/codemods/__tests__/deprecate-shouldFitContainer.tsx +28 -28
- package/codemods/__tests__/rename-imports.tsx +48 -54
- package/codemods/__tests__/replace-position-to-placement.test.tsx +21 -21
- package/codemods/__tests__/replace-shouldAllowMultipleLine.test.tsx +28 -28
- package/codemods/__tests__/update-component-callsites.tsx +18 -20
- package/codemods/migrates/convert-trigger-type.tsx +35 -49
- package/codemods/migrates/deprecate-autoFocus.tsx +3 -11
- package/codemods/migrates/deprecate-boundariesElement.tsx +2 -2
- package/codemods/migrates/deprecate-isCompact.tsx +3 -11
- package/codemods/migrates/deprecate-isHidden.tsx +3 -11
- package/codemods/migrates/deprecate-isMenuFixed.tsx +1 -4
- package/codemods/migrates/deprecate-items.tsx +1 -4
- package/codemods/migrates/deprecate-onItemActivated.tsx +2 -2
- package/codemods/migrates/deprecate-onPositioned.tsx +2 -2
- package/codemods/migrates/deprecate-shouldFitContainer.tsx +2 -2
- package/codemods/migrates/rename-imports.tsx +12 -12
- package/codemods/migrates/replace-position-to-placement.tsx +15 -26
- package/codemods/migrates/replace-shouldAllowMultiline.tsx +21 -35
- package/codemods/migrates/update-component-callsites.tsx +6 -6
- package/codemods/utils/convert-position.tsx +14 -14
- package/codemods/utils/create-rename-import.tsx +32 -37
- package/codemods/utils/create-update-callsite.tsx +25 -28
- package/dist/cjs/dropdown-menu.js +26 -6
- package/dist/cjs/internal/components/group-title.js +7 -0
- package/dist/cjs/internal/components/menu-wrapper.js +5 -0
- package/dist/es2019/dropdown-menu.js +25 -6
- package/dist/es2019/internal/components/group-title.js +6 -0
- package/dist/es2019/internal/components/menu-wrapper.js +5 -0
- package/dist/esm/dropdown-menu.js +26 -6
- package/dist/esm/internal/components/group-title.js +6 -0
- package/dist/esm/internal/components/menu-wrapper.js +5 -0
- package/dist/types/dropdown-menu.d.ts +1 -1
- package/dist/types/internal/components/group-title.d.ts +3 -0
- package/dist/types/internal/hooks/use-radio-state.d.ts +1 -1
- package/dist/types/types.d.ts +19 -3
- package/dist/types-ts4.5/dropdown-menu.d.ts +1 -1
- package/dist/types-ts4.5/internal/components/group-title.d.ts +3 -0
- package/dist/types-ts4.5/internal/hooks/use-radio-state.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +19 -3
- package/package.json +110 -110
- package/report.api.md +141 -145
|
@@ -85,6 +85,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
85
85
|
onOpenChange = _ref$onOpenChange === void 0 ? _noop.default : _ref$onOpenChange,
|
|
86
86
|
_ref$placement = _ref.placement,
|
|
87
87
|
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement,
|
|
88
|
+
_ref$shouldFitContain = _ref.shouldFitContainer,
|
|
89
|
+
shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
|
|
88
90
|
_ref$shouldFlip = _ref.shouldFlip,
|
|
89
91
|
shouldFlip = _ref$shouldFlip === void 0 ? true : _ref$shouldFlip,
|
|
90
92
|
_ref$shouldRenderToPa = _ref.shouldRenderToParent,
|
|
@@ -203,7 +205,25 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
203
205
|
}
|
|
204
206
|
});
|
|
205
207
|
}, [isFocused, isLocalOpen, handleTriggerClicked, handleOnClose]);
|
|
206
|
-
|
|
208
|
+
|
|
209
|
+
/*
|
|
210
|
+
* The Popup component requires either:
|
|
211
|
+
* - shouldFitContainer={true} and shouldRenderToParent={true | undefined}
|
|
212
|
+
* or
|
|
213
|
+
* - shouldFitContainer={false | undefined} and shouldRenderToParent={true | false | undefined}
|
|
214
|
+
*
|
|
215
|
+
* But not:
|
|
216
|
+
* - shouldFitContainer={true} and shouldRenderToParent={false}
|
|
217
|
+
*
|
|
218
|
+
* By only including either shouldFitContainer or shouldRenderToParent, we can ensure that the Popup component
|
|
219
|
+
* types are satisfied.
|
|
220
|
+
*/
|
|
221
|
+
var conditionalProps = shouldFitContainer ? {
|
|
222
|
+
shouldFitContainer: shouldFitContainer
|
|
223
|
+
} : {
|
|
224
|
+
shouldRenderToParent: shouldRenderToParent
|
|
225
|
+
};
|
|
226
|
+
return /*#__PURE__*/_react.default.createElement(_selectionStore.default, null, /*#__PURE__*/_react.default.createElement(_popup.default, (0, _extends2.default)({
|
|
207
227
|
id: isLocalOpen ? id : undefined,
|
|
208
228
|
shouldFlip: shouldFlip,
|
|
209
229
|
isOpen: isLocalOpen,
|
|
@@ -212,8 +232,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
212
232
|
placement: placement,
|
|
213
233
|
fallbackPlacements: fallbackPlacements,
|
|
214
234
|
testId: testId && "".concat(testId, "--content"),
|
|
215
|
-
shouldUseCaptureOnOutsideClick: true
|
|
216
|
-
|
|
235
|
+
shouldUseCaptureOnOutsideClick: true
|
|
236
|
+
}, conditionalProps, {
|
|
217
237
|
shouldDisableFocusLock: true,
|
|
218
238
|
trigger: function trigger(_ref2) {
|
|
219
239
|
var ref = _ref2.ref,
|
|
@@ -253,18 +273,18 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
253
273
|
}, /*#__PURE__*/_react.default.createElement(_menuWrapper.default, {
|
|
254
274
|
spacing: spacing,
|
|
255
275
|
maxHeight: MAX_HEIGHT,
|
|
256
|
-
maxWidth: 800,
|
|
276
|
+
maxWidth: shouldFitContainer ? undefined : 800,
|
|
257
277
|
onClose: handleOnClose,
|
|
258
278
|
onUpdate: update,
|
|
259
279
|
isLoading: isLoading,
|
|
260
280
|
statusLabel: statusLabel,
|
|
261
281
|
setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined,
|
|
262
|
-
shouldRenderToParent: shouldRenderToParent,
|
|
282
|
+
shouldRenderToParent: shouldRenderToParent || shouldFitContainer,
|
|
263
283
|
isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
|
|
264
284
|
autoFocus: autoFocus,
|
|
265
285
|
testId: testId && "".concat(testId, "--menu-wrapper")
|
|
266
286
|
}, children));
|
|
267
287
|
}
|
|
268
|
-
}));
|
|
288
|
+
})));
|
|
269
289
|
};
|
|
270
290
|
var _default = exports.default = DropdownMenu;
|
|
@@ -7,14 +7,21 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
9
|
var _typography = require("@atlaskit/theme/typography");
|
|
10
|
+
/**
|
|
11
|
+
* @jsxRuntime classic
|
|
12
|
+
*/
|
|
10
13
|
/** @jsx jsx */
|
|
11
14
|
|
|
15
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
16
|
+
|
|
12
17
|
var itemHeadingContentHeight = _typography.headingSizes.h100.lineHeight;
|
|
13
18
|
var itemHeadingFontSize = _typography.headingSizes.h100.size;
|
|
14
19
|
var headingStyles = (0, _react.css)({
|
|
15
20
|
color: "var(--ds-text-subtle, ".concat(_colors.N300, ")"),
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
16
22
|
fontSize: itemHeadingFontSize,
|
|
17
23
|
fontWeight: "var(--ds-font-weight-bold, 700)",
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
18
25
|
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
19
26
|
paddingBlock: "var(--ds-space-0, 0px)",
|
|
20
27
|
paddingInline: "var(--ds-space-200, 16px)",
|
|
@@ -13,8 +13,13 @@ var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
|
13
13
|
var _focusManager = require("../components/focus-manager");
|
|
14
14
|
var _isCheckboxItem = _interopRequireDefault(require("../utils/is-checkbox-item"));
|
|
15
15
|
var _isRadioItem = _interopRequireDefault(require("../utils/is-radio-item"));
|
|
16
|
+
/**
|
|
17
|
+
* @jsxRuntime classic
|
|
18
|
+
*/
|
|
16
19
|
/** @jsx jsx */
|
|
17
20
|
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
22
|
+
|
|
18
23
|
var spinnerContainerStyles = (0, _primitives.xcss)({
|
|
19
24
|
display: 'flex',
|
|
20
25
|
minWidth: '160px',
|
|
@@ -64,6 +64,7 @@ const DropdownMenu = ({
|
|
|
64
64
|
isOpen,
|
|
65
65
|
onOpenChange = noop,
|
|
66
66
|
placement = 'bottom-start',
|
|
67
|
+
shouldFitContainer = false,
|
|
67
68
|
shouldFlip = true,
|
|
68
69
|
shouldRenderToParent = false,
|
|
69
70
|
spacing,
|
|
@@ -173,7 +174,25 @@ const DropdownMenu = ({
|
|
|
173
174
|
}
|
|
174
175
|
});
|
|
175
176
|
}, [isFocused, isLocalOpen, handleTriggerClicked, handleOnClose]);
|
|
176
|
-
|
|
177
|
+
|
|
178
|
+
/*
|
|
179
|
+
* The Popup component requires either:
|
|
180
|
+
* - shouldFitContainer={true} and shouldRenderToParent={true | undefined}
|
|
181
|
+
* or
|
|
182
|
+
* - shouldFitContainer={false | undefined} and shouldRenderToParent={true | false | undefined}
|
|
183
|
+
*
|
|
184
|
+
* But not:
|
|
185
|
+
* - shouldFitContainer={true} and shouldRenderToParent={false}
|
|
186
|
+
*
|
|
187
|
+
* By only including either shouldFitContainer or shouldRenderToParent, we can ensure that the Popup component
|
|
188
|
+
* types are satisfied.
|
|
189
|
+
*/
|
|
190
|
+
const conditionalProps = shouldFitContainer ? {
|
|
191
|
+
shouldFitContainer
|
|
192
|
+
} : {
|
|
193
|
+
shouldRenderToParent
|
|
194
|
+
};
|
|
195
|
+
return /*#__PURE__*/React.createElement(SelectionStore, null, /*#__PURE__*/React.createElement(Popup, _extends({
|
|
177
196
|
id: isLocalOpen ? id : undefined,
|
|
178
197
|
shouldFlip: shouldFlip,
|
|
179
198
|
isOpen: isLocalOpen,
|
|
@@ -182,8 +201,8 @@ const DropdownMenu = ({
|
|
|
182
201
|
placement: placement,
|
|
183
202
|
fallbackPlacements: fallbackPlacements,
|
|
184
203
|
testId: testId && `${testId}--content`,
|
|
185
|
-
shouldUseCaptureOnOutsideClick: true
|
|
186
|
-
|
|
204
|
+
shouldUseCaptureOnOutsideClick: true
|
|
205
|
+
}, conditionalProps, {
|
|
187
206
|
shouldDisableFocusLock: true,
|
|
188
207
|
trigger: ({
|
|
189
208
|
ref,
|
|
@@ -226,17 +245,17 @@ const DropdownMenu = ({
|
|
|
226
245
|
}, /*#__PURE__*/React.createElement(MenuWrapper, {
|
|
227
246
|
spacing: spacing,
|
|
228
247
|
maxHeight: MAX_HEIGHT,
|
|
229
|
-
maxWidth: 800,
|
|
248
|
+
maxWidth: shouldFitContainer ? undefined : 800,
|
|
230
249
|
onClose: handleOnClose,
|
|
231
250
|
onUpdate: update,
|
|
232
251
|
isLoading: isLoading,
|
|
233
252
|
statusLabel: statusLabel,
|
|
234
253
|
setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined,
|
|
235
|
-
shouldRenderToParent: shouldRenderToParent,
|
|
254
|
+
shouldRenderToParent: shouldRenderToParent || shouldFitContainer,
|
|
236
255
|
isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
|
|
237
256
|
autoFocus: autoFocus,
|
|
238
257
|
testId: testId && `${testId}--menu-wrapper`
|
|
239
258
|
}, children))
|
|
240
|
-
}));
|
|
259
|
+
})));
|
|
241
260
|
};
|
|
242
261
|
export default DropdownMenu;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
7
|
import { css, jsx } from '@emotion/react';
|
|
4
8
|
import { N300 } from '@atlaskit/theme/colors';
|
|
5
9
|
import { headingSizes } from '@atlaskit/theme/typography';
|
|
@@ -7,8 +11,10 @@ const itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
|
7
11
|
const itemHeadingFontSize = headingSizes.h100.size;
|
|
8
12
|
const headingStyles = css({
|
|
9
13
|
color: `var(--ds-text-subtle, ${N300})`,
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
10
15
|
fontSize: itemHeadingFontSize,
|
|
11
16
|
fontWeight: "var(--ds-font-weight-bold, 700)",
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
12
18
|
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
13
19
|
paddingBlock: "var(--ds-space-0, 0px)",
|
|
14
20
|
paddingInline: "var(--ds-space-200, 16px)",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { useContext, useEffect, useLayoutEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { jsx } from '@emotion/react';
|
|
4
9
|
import MenuGroup from '@atlaskit/menu/menu-group';
|
|
5
10
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
@@ -75,6 +75,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
75
75
|
onOpenChange = _ref$onOpenChange === void 0 ? noop : _ref$onOpenChange,
|
|
76
76
|
_ref$placement = _ref.placement,
|
|
77
77
|
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement,
|
|
78
|
+
_ref$shouldFitContain = _ref.shouldFitContainer,
|
|
79
|
+
shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
|
|
78
80
|
_ref$shouldFlip = _ref.shouldFlip,
|
|
79
81
|
shouldFlip = _ref$shouldFlip === void 0 ? true : _ref$shouldFlip,
|
|
80
82
|
_ref$shouldRenderToPa = _ref.shouldRenderToParent,
|
|
@@ -193,7 +195,25 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
193
195
|
}
|
|
194
196
|
});
|
|
195
197
|
}, [isFocused, isLocalOpen, handleTriggerClicked, handleOnClose]);
|
|
196
|
-
|
|
198
|
+
|
|
199
|
+
/*
|
|
200
|
+
* The Popup component requires either:
|
|
201
|
+
* - shouldFitContainer={true} and shouldRenderToParent={true | undefined}
|
|
202
|
+
* or
|
|
203
|
+
* - shouldFitContainer={false | undefined} and shouldRenderToParent={true | false | undefined}
|
|
204
|
+
*
|
|
205
|
+
* But not:
|
|
206
|
+
* - shouldFitContainer={true} and shouldRenderToParent={false}
|
|
207
|
+
*
|
|
208
|
+
* By only including either shouldFitContainer or shouldRenderToParent, we can ensure that the Popup component
|
|
209
|
+
* types are satisfied.
|
|
210
|
+
*/
|
|
211
|
+
var conditionalProps = shouldFitContainer ? {
|
|
212
|
+
shouldFitContainer: shouldFitContainer
|
|
213
|
+
} : {
|
|
214
|
+
shouldRenderToParent: shouldRenderToParent
|
|
215
|
+
};
|
|
216
|
+
return /*#__PURE__*/React.createElement(SelectionStore, null, /*#__PURE__*/React.createElement(Popup, _extends({
|
|
197
217
|
id: isLocalOpen ? id : undefined,
|
|
198
218
|
shouldFlip: shouldFlip,
|
|
199
219
|
isOpen: isLocalOpen,
|
|
@@ -202,8 +222,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
202
222
|
placement: placement,
|
|
203
223
|
fallbackPlacements: fallbackPlacements,
|
|
204
224
|
testId: testId && "".concat(testId, "--content"),
|
|
205
|
-
shouldUseCaptureOnOutsideClick: true
|
|
206
|
-
|
|
225
|
+
shouldUseCaptureOnOutsideClick: true
|
|
226
|
+
}, conditionalProps, {
|
|
207
227
|
shouldDisableFocusLock: true,
|
|
208
228
|
trigger: function trigger(_ref2) {
|
|
209
229
|
var ref = _ref2.ref,
|
|
@@ -243,18 +263,18 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
243
263
|
}, /*#__PURE__*/React.createElement(MenuWrapper, {
|
|
244
264
|
spacing: spacing,
|
|
245
265
|
maxHeight: MAX_HEIGHT,
|
|
246
|
-
maxWidth: 800,
|
|
266
|
+
maxWidth: shouldFitContainer ? undefined : 800,
|
|
247
267
|
onClose: handleOnClose,
|
|
248
268
|
onUpdate: update,
|
|
249
269
|
isLoading: isLoading,
|
|
250
270
|
statusLabel: statusLabel,
|
|
251
271
|
setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined,
|
|
252
|
-
shouldRenderToParent: shouldRenderToParent,
|
|
272
|
+
shouldRenderToParent: shouldRenderToParent || shouldFitContainer,
|
|
253
273
|
isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
|
|
254
274
|
autoFocus: autoFocus,
|
|
255
275
|
testId: testId && "".concat(testId, "--menu-wrapper")
|
|
256
276
|
}, children));
|
|
257
277
|
}
|
|
258
|
-
}));
|
|
278
|
+
})));
|
|
259
279
|
};
|
|
260
280
|
export default DropdownMenu;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
7
|
import { css, jsx } from '@emotion/react';
|
|
4
8
|
import { N300 } from '@atlaskit/theme/colors';
|
|
5
9
|
import { headingSizes } from '@atlaskit/theme/typography';
|
|
@@ -7,8 +11,10 @@ var itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
|
7
11
|
var itemHeadingFontSize = headingSizes.h100.size;
|
|
8
12
|
var headingStyles = css({
|
|
9
13
|
color: "var(--ds-text-subtle, ".concat(N300, ")"),
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
10
15
|
fontSize: itemHeadingFontSize,
|
|
11
16
|
fontWeight: "var(--ds-font-weight-bold, 700)",
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
12
18
|
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
13
19
|
paddingBlock: "var(--ds-space-0, 0px)",
|
|
14
20
|
paddingInline: "var(--ds-space-200, 16px)",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { useContext, useEffect, useLayoutEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { jsx } from '@emotion/react';
|
|
4
9
|
import MenuGroup from '@atlaskit/menu/menu-group';
|
|
5
10
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
@@ -9,5 +9,5 @@ import type { DropdownMenuProps } from './types';
|
|
|
9
9
|
* - [Code](https://atlassian.design/components/dropdown-menu/code)
|
|
10
10
|
* - [Usage](https://atlassian.design/components/dropdown-menu/usage)
|
|
11
11
|
*/
|
|
12
|
-
declare const DropdownMenu: <T extends HTMLElement = HTMLElement>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFlip, shouldRenderToParent, spacing, statusLabel, testId, trigger, zIndex, label, }: DropdownMenuProps<T>) => JSX.Element;
|
|
12
|
+
declare const DropdownMenu: <T extends HTMLElement = HTMLElement>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFitContainer, shouldFlip, shouldRenderToParent, spacing, statusLabel, testId, trigger, zIndex, label, }: DropdownMenuProps<T>) => JSX.Element;
|
|
13
13
|
export default DropdownMenu;
|
|
@@ -5,5 +5,5 @@ type RadioStateArgs = {
|
|
|
5
5
|
};
|
|
6
6
|
type SetStateCallback = (value: boolean | undefined) => boolean;
|
|
7
7
|
type RadioStateValue = [boolean, (newValue: SetStateCallback) => void];
|
|
8
|
-
declare function useRadioState({ id, isSelected, defaultSelected
|
|
8
|
+
declare function useRadioState({ id, isSelected, defaultSelected }: RadioStateArgs): RadioStateValue;
|
|
9
9
|
export default useRadioState;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -47,15 +47,15 @@ export interface MenuWrapperProps extends MenuGroupProps {
|
|
|
47
47
|
setInitialFocusRef?: ContentProps['setInitialFocusRef'];
|
|
48
48
|
onClose?: ContentProps['onClose'];
|
|
49
49
|
onUpdate: ContentProps['update'];
|
|
50
|
-
isLoading?:
|
|
51
|
-
statusLabel?:
|
|
50
|
+
isLoading?: InternalDropdownMenuProps['isLoading'];
|
|
51
|
+
statusLabel?: InternalDropdownMenuProps['statusLabel'];
|
|
52
52
|
shouldRenderToParent?: boolean;
|
|
53
53
|
isTriggeredUsingKeyboard?: boolean;
|
|
54
54
|
autoFocus?: boolean;
|
|
55
55
|
}
|
|
56
56
|
export interface DropdownMenuGroupProps extends SectionProps {
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
|
|
59
59
|
/**
|
|
60
60
|
* Controls the appearance of the menu.
|
|
61
61
|
* The default menu will scroll after its height exceeds the pre-defined amount.
|
|
@@ -90,6 +90,13 @@ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElem
|
|
|
90
90
|
* Position of the menu.
|
|
91
91
|
*/
|
|
92
92
|
placement?: Placement;
|
|
93
|
+
/**
|
|
94
|
+
* This fits the dropdown menu width to its parent's width.
|
|
95
|
+
* When set to `true`, the trigger and dropdown menu elements will be wrapped in a `div` with `position: relative`.
|
|
96
|
+
* The dropdown menu will be rendered as a sibling to the trigger element, and will be full width.
|
|
97
|
+
* The default is `false`.
|
|
98
|
+
*/
|
|
99
|
+
shouldFitContainer?: boolean;
|
|
93
100
|
/**
|
|
94
101
|
* Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
|
|
95
102
|
* fit in the viewport.
|
|
@@ -144,6 +151,14 @@ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElem
|
|
|
144
151
|
*/
|
|
145
152
|
label?: string;
|
|
146
153
|
}
|
|
154
|
+
type StandardDropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> = InternalDropdownMenuProps<TriggerElement> & {
|
|
155
|
+
shouldFitContainer?: false;
|
|
156
|
+
};
|
|
157
|
+
type ShouldFitContainerDropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> = InternalDropdownMenuProps<TriggerElement> & {
|
|
158
|
+
shouldFitContainer: true;
|
|
159
|
+
shouldRenderToParent?: true;
|
|
160
|
+
};
|
|
161
|
+
export type DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> = StandardDropdownMenuProps<TriggerElement> | ShouldFitContainerDropdownMenuProps<TriggerElement>;
|
|
147
162
|
export interface DropdownItemProps {
|
|
148
163
|
/**
|
|
149
164
|
* Primary content for the item.
|
|
@@ -318,3 +333,4 @@ export interface CustomItemHtmlProps extends CustomItemComponentProps {
|
|
|
318
333
|
*/
|
|
319
334
|
href?: string;
|
|
320
335
|
}
|
|
336
|
+
export {};
|
|
@@ -9,5 +9,5 @@ import type { DropdownMenuProps } from './types';
|
|
|
9
9
|
* - [Code](https://atlassian.design/components/dropdown-menu/code)
|
|
10
10
|
* - [Usage](https://atlassian.design/components/dropdown-menu/usage)
|
|
11
11
|
*/
|
|
12
|
-
declare const DropdownMenu: <T extends HTMLElement = HTMLElement>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFlip, shouldRenderToParent, spacing, statusLabel, testId, trigger, zIndex, label, }: DropdownMenuProps<T>) => JSX.Element;
|
|
12
|
+
declare const DropdownMenu: <T extends HTMLElement = HTMLElement>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFitContainer, shouldFlip, shouldRenderToParent, spacing, statusLabel, testId, trigger, zIndex, label, }: DropdownMenuProps<T>) => JSX.Element;
|
|
13
13
|
export default DropdownMenu;
|
|
@@ -8,5 +8,5 @@ type RadioStateValue = [
|
|
|
8
8
|
boolean,
|
|
9
9
|
(newValue: SetStateCallback) => void
|
|
10
10
|
];
|
|
11
|
-
declare function useRadioState({ id, isSelected, defaultSelected
|
|
11
|
+
declare function useRadioState({ id, isSelected, defaultSelected }: RadioStateArgs): RadioStateValue;
|
|
12
12
|
export default useRadioState;
|
|
@@ -47,15 +47,15 @@ export interface MenuWrapperProps extends MenuGroupProps {
|
|
|
47
47
|
setInitialFocusRef?: ContentProps['setInitialFocusRef'];
|
|
48
48
|
onClose?: ContentProps['onClose'];
|
|
49
49
|
onUpdate: ContentProps['update'];
|
|
50
|
-
isLoading?:
|
|
51
|
-
statusLabel?:
|
|
50
|
+
isLoading?: InternalDropdownMenuProps['isLoading'];
|
|
51
|
+
statusLabel?: InternalDropdownMenuProps['statusLabel'];
|
|
52
52
|
shouldRenderToParent?: boolean;
|
|
53
53
|
isTriggeredUsingKeyboard?: boolean;
|
|
54
54
|
autoFocus?: boolean;
|
|
55
55
|
}
|
|
56
56
|
export interface DropdownMenuGroupProps extends SectionProps {
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
|
|
59
59
|
/**
|
|
60
60
|
* Controls the appearance of the menu.
|
|
61
61
|
* The default menu will scroll after its height exceeds the pre-defined amount.
|
|
@@ -90,6 +90,13 @@ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElem
|
|
|
90
90
|
* Position of the menu.
|
|
91
91
|
*/
|
|
92
92
|
placement?: Placement;
|
|
93
|
+
/**
|
|
94
|
+
* This fits the dropdown menu width to its parent's width.
|
|
95
|
+
* When set to `true`, the trigger and dropdown menu elements will be wrapped in a `div` with `position: relative`.
|
|
96
|
+
* The dropdown menu will be rendered as a sibling to the trigger element, and will be full width.
|
|
97
|
+
* The default is `false`.
|
|
98
|
+
*/
|
|
99
|
+
shouldFitContainer?: boolean;
|
|
93
100
|
/**
|
|
94
101
|
* Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
|
|
95
102
|
* fit in the viewport.
|
|
@@ -144,6 +151,14 @@ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElem
|
|
|
144
151
|
*/
|
|
145
152
|
label?: string;
|
|
146
153
|
}
|
|
154
|
+
type StandardDropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> = InternalDropdownMenuProps<TriggerElement> & {
|
|
155
|
+
shouldFitContainer?: false;
|
|
156
|
+
};
|
|
157
|
+
type ShouldFitContainerDropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> = InternalDropdownMenuProps<TriggerElement> & {
|
|
158
|
+
shouldFitContainer: true;
|
|
159
|
+
shouldRenderToParent?: true;
|
|
160
|
+
};
|
|
161
|
+
export type DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> = StandardDropdownMenuProps<TriggerElement> | ShouldFitContainerDropdownMenuProps<TriggerElement>;
|
|
147
162
|
export interface DropdownItemProps {
|
|
148
163
|
/**
|
|
149
164
|
* Primary content for the item.
|
|
@@ -318,3 +333,4 @@ export interface CustomItemHtmlProps extends CustomItemComponentProps {
|
|
|
318
333
|
*/
|
|
319
334
|
href?: string;
|
|
320
335
|
}
|
|
336
|
+
export {};
|