@primer/components 0.0.0-20211030164933 → 0.0.0-20211030172251
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 +2 -2
- package/dist/browser.esm.js +581 -585
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +199 -203
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +21 -5
- package/lib/ActionList2/List.js +11 -1
- package/lib/ActionList2/MenuContext.d.ts +10 -0
- package/lib/{_InputField/InputFieldValidation.js → ActionList2/MenuContext.js} +4 -6
- package/lib/ActionList2/Selection.js +11 -0
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +310 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Autocomplete/AutocompleteMenu.js +13 -6
- package/lib/Checkbox.d.ts +1 -1
- package/lib/drafts.d.ts +1 -0
- package/lib/drafts.js +13 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -24
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +19 -5
- package/lib-esm/ActionList2/List.js +9 -1
- package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
- package/lib-esm/ActionList2/MenuContext.js +3 -0
- package/lib-esm/ActionList2/Selection.js +9 -0
- package/lib-esm/ActionList2/index.d.ts +1 -2
- package/lib-esm/ActionMenu2.d.ts +310 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.js +13 -3
- package/lib-esm/Checkbox.d.ts +1 -1
- package/lib-esm/drafts.d.ts +1 -0
- package/lib-esm/drafts.js +2 -1
- package/lib-esm/index.d.ts +0 -3
- package/lib-esm/index.js +0 -3
- package/package.json +2 -2
- package/lib/CheckboxInputField.d.ts +0 -10
- package/lib/CheckboxInputField.js +0 -73
- package/lib/RadioInputField.d.ts +0 -8
- package/lib/RadioInputField.js +0 -82
- package/lib/TextInputField.d.ts +0 -581
- package/lib/TextInputField.js +0 -66
- package/lib/_InputCaption.d.ts +0 -13
- package/lib/_InputCaption.js +0 -26
- package/lib/_InputField/InputField.d.ts +0 -39
- package/lib/_InputField/InputField.js +0 -90
- package/lib/_InputField/InputFieldCaption.d.ts +0 -3
- package/lib/_InputField/InputFieldCaption.js +0 -30
- package/lib/_InputField/InputFieldLabel.d.ts +0 -9
- package/lib/_InputField/InputFieldLabel.js +0 -34
- package/lib/_InputField/InputFieldValidation.d.ts +0 -6
- package/lib/_InputField/ToggleInputField.d.ts +0 -13
- package/lib/_InputField/ToggleInputField.js +0 -71
- package/lib/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
- package/lib/_InputField/ToggleInputLeadingVisual.js +0 -22
- package/lib/_InputField/ValidationAnimationContainer.d.ts +0 -6
- package/lib/_InputField/ValidationAnimationContainer.js +0 -48
- package/lib/_InputField/index.d.ts +0 -1
- package/lib/_InputField/index.js +0 -15
- package/lib/_InputField/slots.d.ts +0 -13
- package/lib/_InputField/slots.js +0 -17
- package/lib/_InputLabel.d.ts +0 -8
- package/lib/_InputLabel.js +0 -44
- package/lib/_InputValidation.d.ts +0 -8
- package/lib/_InputValidation.js +0 -56
- package/lib/_VisuallyHidden.d.ts +0 -6
- package/lib/_VisuallyHidden.js +0 -39
- package/lib/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib/utils/types/FormValidationStatus.js +0 -1
- package/lib-esm/CheckboxInputField.d.ts +0 -10
- package/lib-esm/CheckboxInputField.js +0 -56
- package/lib-esm/RadioInputField.d.ts +0 -8
- package/lib-esm/RadioInputField.js +0 -65
- package/lib-esm/TextInputField.d.ts +0 -581
- package/lib-esm/TextInputField.js +0 -50
- package/lib-esm/_InputCaption.d.ts +0 -13
- package/lib-esm/_InputCaption.js +0 -15
- package/lib-esm/_InputField/InputField.d.ts +0 -39
- package/lib-esm/_InputField/InputField.js +0 -70
- package/lib-esm/_InputField/InputFieldCaption.d.ts +0 -3
- package/lib-esm/_InputField/InputFieldCaption.js +0 -18
- package/lib-esm/_InputField/InputFieldLabel.d.ts +0 -9
- package/lib-esm/_InputField/InputFieldLabel.js +0 -22
- package/lib-esm/_InputField/InputFieldValidation.d.ts +0 -6
- package/lib-esm/_InputField/InputFieldValidation.js +0 -7
- package/lib-esm/_InputField/ToggleInputField.d.ts +0 -13
- package/lib-esm/_InputField/ToggleInputField.js +0 -54
- package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
- package/lib-esm/_InputField/ToggleInputLeadingVisual.js +0 -11
- package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +0 -6
- package/lib-esm/_InputField/ValidationAnimationContainer.js +0 -33
- package/lib-esm/_InputField/index.d.ts +0 -1
- package/lib-esm/_InputField/index.js +0 -1
- package/lib-esm/_InputField/slots.d.ts +0 -13
- package/lib-esm/_InputField/slots.js +0 -5
- package/lib-esm/_InputLabel.d.ts +0 -8
- package/lib-esm/_InputLabel.js +0 -32
- package/lib-esm/_InputValidation.d.ts +0 -8
- package/lib-esm/_InputValidation.js +0 -43
- package/lib-esm/_VisuallyHidden.d.ts +0 -6
- package/lib-esm/_VisuallyHidden.js +0 -26
- package/lib-esm/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib-esm/utils/types/FormValidationStatus.js +0 -1
@@ -21,10 +21,6 @@ var _uniqueId = require("../utils/uniqueId");
|
|
21
21
|
|
22
22
|
var _scrollIntoViewingArea = require("../behaviors/scrollIntoViewingArea");
|
23
23
|
|
24
|
-
var _VisuallyHidden = _interopRequireDefault(require("../_VisuallyHidden"));
|
25
|
-
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
|
-
|
28
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
29
25
|
|
30
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -186,8 +182,19 @@ function AutocompleteMenu(props) {
|
|
186
182
|
setSelectedItemLength(selectedItemIds.length);
|
187
183
|
}
|
188
184
|
}, [selectedItemIds, setSelectedItemLength]);
|
189
|
-
return /*#__PURE__*/_react.default.createElement(
|
190
|
-
|
185
|
+
return /*#__PURE__*/_react.default.createElement(_.Box, {
|
186
|
+
sx: !showMenu ? {
|
187
|
+
// visually hides this label for sighted users
|
188
|
+
position: 'absolute',
|
189
|
+
width: '1px',
|
190
|
+
height: '1px',
|
191
|
+
padding: '0',
|
192
|
+
margin: '-1px',
|
193
|
+
overflow: 'hidden',
|
194
|
+
clip: 'rect(0, 0, 0, 0)',
|
195
|
+
whiteSpace: 'nowrap',
|
196
|
+
borderWidth: '0'
|
197
|
+
} : {}
|
191
198
|
}, loading ? /*#__PURE__*/_react.default.createElement(_.Box, {
|
192
199
|
p: 3,
|
193
200
|
display: "flex",
|
package/lib/Checkbox.d.ts
CHANGED
@@ -25,5 +25,5 @@ export declare type CheckboxProps = {
|
|
25
25
|
/**
|
26
26
|
* An accessible, native checkbox component
|
27
27
|
*/
|
28
|
-
declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "
|
28
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "indeterminate" | "validationStatus"> & React.RefAttributes<HTMLInputElement>>;
|
29
29
|
export default Checkbox;
|
package/lib/drafts.d.ts
CHANGED
package/lib/drafts.js
CHANGED
@@ -28,4 +28,17 @@ Object.keys(_NewButton).forEach(function (key) {
|
|
28
28
|
return _NewButton[key];
|
29
29
|
}
|
30
30
|
});
|
31
|
+
});
|
32
|
+
|
33
|
+
var _ActionMenu = require("./ActionMenu2");
|
34
|
+
|
35
|
+
Object.keys(_ActionMenu).forEach(function (key) {
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
37
|
+
if (key in exports && exports[key] === _ActionMenu[key]) return;
|
38
|
+
Object.defineProperty(exports, key, {
|
39
|
+
enumerable: true,
|
40
|
+
get: function () {
|
41
|
+
return _ActionMenu[key];
|
42
|
+
}
|
43
|
+
});
|
31
44
|
});
|
package/lib/index.d.ts
CHANGED
@@ -46,7 +46,6 @@ export { default as CircleBadge } from './CircleBadge';
|
|
46
46
|
export type { CircleBadgeProps, CircleBadgeIconProps } from './CircleBadge';
|
47
47
|
export { default as CircleOcticon } from './CircleOcticon';
|
48
48
|
export type { CircleOcticonProps } from './CircleOcticon';
|
49
|
-
export { default as CheckboxInputField } from './CheckboxInputField';
|
50
49
|
export { default as CounterLabel } from './CounterLabel';
|
51
50
|
export type { CounterLabelProps } from './CounterLabel';
|
52
51
|
export { default as Details } from './Details';
|
@@ -87,7 +86,6 @@ export { default as Popover } from './Popover';
|
|
87
86
|
export type { PopoverProps, PopoverContentProps } from './Popover';
|
88
87
|
export { default as ProgressBar } from './ProgressBar';
|
89
88
|
export type { ProgressBarProps } from './ProgressBar';
|
90
|
-
export { default as RadioInputField } from './RadioInputField';
|
91
89
|
export { default as SelectMenu } from './SelectMenu';
|
92
90
|
export type { SelectMenuProps, SelectMenuDividerProps, SelectMenuFilterProps, SelectMenuFooterProps, SelectMenuItemProps, SelectMenuListProps, SelectMenuModalProps, SelectMenuTabsProps, SelectMenuHeaderProps, SelectMenuTabProps, SelectMenuTabPanelProps, SelectMenuLoadingAnimationProps } from './SelectMenu';
|
93
91
|
export { default as SideNav } from './SideNav';
|
@@ -104,7 +102,6 @@ export { default as TabNav } from './TabNav';
|
|
104
102
|
export type { TabNavProps, TabNavLinkProps } from './TabNav';
|
105
103
|
export { default as TextInput } from './TextInput';
|
106
104
|
export type { TextInputProps } from './TextInput';
|
107
|
-
export { default as TextInputField } from './TextInputField';
|
108
105
|
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
109
106
|
export type { TextInputWithTokensProps } from './TextInputWithTokens';
|
110
107
|
export { default as Text } from './Text';
|
package/lib/index.js
CHANGED
@@ -267,12 +267,6 @@ Object.defineProperty(exports, "CircleOcticon", {
|
|
267
267
|
return _CircleOcticon.default;
|
268
268
|
}
|
269
269
|
});
|
270
|
-
Object.defineProperty(exports, "CheckboxInputField", {
|
271
|
-
enumerable: true,
|
272
|
-
get: function () {
|
273
|
-
return _CheckboxInputField.default;
|
274
|
-
}
|
275
|
-
});
|
276
270
|
Object.defineProperty(exports, "CounterLabel", {
|
277
271
|
enumerable: true,
|
278
272
|
get: function () {
|
@@ -399,12 +393,6 @@ Object.defineProperty(exports, "ProgressBar", {
|
|
399
393
|
return _ProgressBar.default;
|
400
394
|
}
|
401
395
|
});
|
402
|
-
Object.defineProperty(exports, "RadioInputField", {
|
403
|
-
enumerable: true,
|
404
|
-
get: function () {
|
405
|
-
return _RadioInputField.default;
|
406
|
-
}
|
407
|
-
});
|
408
396
|
Object.defineProperty(exports, "SelectMenu", {
|
409
397
|
enumerable: true,
|
410
398
|
get: function () {
|
@@ -453,12 +441,6 @@ Object.defineProperty(exports, "TextInput", {
|
|
453
441
|
return _TextInput.default;
|
454
442
|
}
|
455
443
|
});
|
456
|
-
Object.defineProperty(exports, "TextInputField", {
|
457
|
-
enumerable: true,
|
458
|
-
get: function () {
|
459
|
-
return _TextInputField.default;
|
460
|
-
}
|
461
|
-
});
|
462
444
|
Object.defineProperty(exports, "TextInputWithTokens", {
|
463
445
|
enumerable: true,
|
464
446
|
get: function () {
|
@@ -590,8 +572,6 @@ var _CircleBadge = _interopRequireDefault(require("./CircleBadge"));
|
|
590
572
|
|
591
573
|
var _CircleOcticon = _interopRequireDefault(require("./CircleOcticon"));
|
592
574
|
|
593
|
-
var _CheckboxInputField = _interopRequireDefault(require("./CheckboxInputField"));
|
594
|
-
|
595
575
|
var _CounterLabel = _interopRequireDefault(require("./CounterLabel"));
|
596
576
|
|
597
577
|
var _Details = _interopRequireDefault(require("./Details"));
|
@@ -632,8 +612,6 @@ var _Popover = _interopRequireDefault(require("./Popover"));
|
|
632
612
|
|
633
613
|
var _ProgressBar = _interopRequireDefault(require("./ProgressBar"));
|
634
614
|
|
635
|
-
var _RadioInputField = _interopRequireDefault(require("./RadioInputField"));
|
636
|
-
|
637
615
|
var _SelectMenu = _interopRequireDefault(require("./SelectMenu"));
|
638
616
|
|
639
617
|
var _SideNav = _interopRequireDefault(require("./SideNav"));
|
@@ -650,8 +628,6 @@ var _TabNav = _interopRequireDefault(require("./TabNav"));
|
|
650
628
|
|
651
629
|
var _TextInput = _interopRequireDefault(require("./TextInput"));
|
652
630
|
|
653
|
-
var _TextInputField = _interopRequireDefault(require("./TextInputField"));
|
654
|
-
|
655
631
|
var _TextInputWithTokens = _interopRequireDefault(require("./TextInputWithTokens"));
|
656
632
|
|
657
633
|
var _Text = _interopRequireDefault(require("./Text"));
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
2
3
|
/**
|
3
4
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
4
5
|
*/
|
5
|
-
export declare
|
6
|
+
export declare const Divider: React.FC<SxProp>;
|
@@ -1,23 +1,26 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import Box from '../Box';
|
3
3
|
import { get } from '../constants';
|
4
|
-
|
4
|
+
import { merge } from '../sx';
|
5
5
|
/**
|
6
6
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
7
7
|
*/
|
8
|
-
|
8
|
+
|
9
|
+
export const Divider = ({
|
10
|
+
sx = {}
|
11
|
+
}) => {
|
9
12
|
return /*#__PURE__*/React.createElement(Box, {
|
10
13
|
as: "li",
|
11
14
|
role: "separator",
|
12
|
-
sx: {
|
15
|
+
sx: merge({
|
13
16
|
height: 1,
|
14
17
|
backgroundColor: 'actionListItem.inlineDivider',
|
15
18
|
marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
|
16
19
|
marginBottom: 2,
|
17
20
|
listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
|
18
21
|
|
19
|
-
},
|
22
|
+
}, sx),
|
20
23
|
"data-component": "ActionList.Divider"
|
21
24
|
});
|
22
|
-
}
|
25
|
+
};
|
23
26
|
Divider.displayName = "Divider";
|
@@ -8,6 +8,7 @@ import Box from '../Box';
|
|
8
8
|
import sx, { merge } from '../sx';
|
9
9
|
import createSlots from '../utils/create-slots';
|
10
10
|
import { ListContext } from './List';
|
11
|
+
import { MenuContext } from './MenuContext';
|
11
12
|
import { Selection } from './Selection';
|
12
13
|
export const getVariantStyles = (variant, disabled) => {
|
13
14
|
if (disabled) {
|
@@ -54,6 +55,7 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
54
55
|
onSelect,
|
55
56
|
sx: sxProp = {},
|
56
57
|
id,
|
58
|
+
role,
|
57
59
|
_PrivateItemWrapper,
|
58
60
|
...props
|
59
61
|
}, forwardedRef) => {
|
@@ -61,6 +63,10 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
61
63
|
variant: listVariant,
|
62
64
|
showDividers
|
63
65
|
} = React.useContext(ListContext);
|
66
|
+
const {
|
67
|
+
itemRole,
|
68
|
+
afterSelect
|
69
|
+
} = React.useContext(MenuContext);
|
64
70
|
const {
|
65
71
|
theme
|
66
72
|
} = useTheme();
|
@@ -135,16 +141,23 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
135
141
|
const clickHandler = React.useCallback(event => {
|
136
142
|
if (typeof onSelect !== 'function') return;
|
137
143
|
if (disabled) return;
|
138
|
-
|
139
|
-
|
144
|
+
|
145
|
+
if (!event.defaultPrevented) {
|
146
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
147
|
+
|
148
|
+
if (typeof afterSelect === 'function') afterSelect();
|
149
|
+
}
|
150
|
+
}, [onSelect, disabled, afterSelect]);
|
140
151
|
const keyPressHandler = React.useCallback(event => {
|
141
152
|
if (typeof onSelect !== 'function') return;
|
142
153
|
if (disabled) return;
|
143
154
|
|
144
155
|
if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
|
145
|
-
onSelect(event);
|
156
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
157
|
+
|
158
|
+
if (typeof afterSelect === 'function') afterSelect();
|
146
159
|
}
|
147
|
-
}, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
|
160
|
+
}, [onSelect, disabled, afterSelect]); // use props.id if provided, otherwise generate one.
|
148
161
|
|
149
162
|
const labelId = useSSRSafeId(id);
|
150
163
|
const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
|
@@ -166,7 +179,8 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
166
179
|
"aria-disabled": disabled ? true : undefined,
|
167
180
|
tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
|
168
181
|
"aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
|
169
|
-
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
|
182
|
+
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined,
|
183
|
+
role: role || itemRole
|
170
184
|
}, props), /*#__PURE__*/React.createElement(ItemWrapper, null, /*#__PURE__*/React.createElement(Selection, {
|
171
185
|
selected: selected
|
172
186
|
}), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
|
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
3
3
|
import React from 'react';
|
4
4
|
import styled from 'styled-components';
|
5
5
|
import sx, { merge } from '../sx';
|
6
|
+
import { MenuContext } from './MenuContext';
|
6
7
|
export const ListContext = /*#__PURE__*/React.createContext({});
|
7
8
|
const ListBox = styled.ul.withConfig({
|
8
9
|
displayName: "List__ListBox",
|
@@ -12,6 +13,7 @@ export const List = /*#__PURE__*/React.forwardRef(({
|
|
12
13
|
variant = 'inset',
|
13
14
|
selectionVariant,
|
14
15
|
showDividers = false,
|
16
|
+
role,
|
15
17
|
sx: sxProp = {},
|
16
18
|
...props
|
17
19
|
}, forwardedRef) => {
|
@@ -21,8 +23,14 @@ export const List = /*#__PURE__*/React.forwardRef(({
|
|
21
23
|
// reset ul styles
|
22
24
|
paddingY: variant === 'inset' ? 2 : 0
|
23
25
|
};
|
26
|
+
/** if list is inside a Menu, it will get a role from the Menu */
|
27
|
+
|
28
|
+
const {
|
29
|
+
listRole
|
30
|
+
} = React.useContext(MenuContext);
|
24
31
|
return /*#__PURE__*/React.createElement(ListBox, _extends({
|
25
|
-
sx: merge(styles, sxProp)
|
32
|
+
sx: merge(styles, sxProp),
|
33
|
+
role: role || listRole
|
26
34
|
}, props, {
|
27
35
|
ref: forwardedRef
|
28
36
|
}), /*#__PURE__*/React.createElement(ListContext.Provider, {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/** This context can be used by components that compose ActionList inside a Menu */
|
2
|
+
import React from 'react';
|
3
|
+
declare type ContextProps = {
|
4
|
+
parent?: string;
|
5
|
+
listRole?: string;
|
6
|
+
itemRole?: string;
|
7
|
+
afterSelect?: () => void;
|
8
|
+
};
|
9
|
+
export declare const MenuContext: React.Context<ContextProps>;
|
10
|
+
export {};
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { CheckIcon } from '@primer/octicons-react';
|
3
3
|
import { ListContext } from './List';
|
4
4
|
import { GroupContext } from './Group';
|
5
|
+
import { MenuContext } from './MenuContext';
|
5
6
|
import { LeadingVisualContainer } from './Visuals';
|
6
7
|
export const Selection = ({
|
7
8
|
selected
|
@@ -12,6 +13,9 @@ export const Selection = ({
|
|
12
13
|
const {
|
13
14
|
selectionVariant: groupSelectionVariant
|
14
15
|
} = React.useContext(GroupContext);
|
16
|
+
const {
|
17
|
+
parent
|
18
|
+
} = React.useContext(MenuContext);
|
15
19
|
/** selectionVariant in Group can override the selectionVariant in List root */
|
16
20
|
|
17
21
|
const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
|
@@ -22,6 +26,11 @@ export const Selection = ({
|
|
22
26
|
return null;
|
23
27
|
}
|
24
28
|
|
29
|
+
if (parent === 'ActionMenu') {
|
30
|
+
throw new Error('ActionList cannot have a selectionVariant inside ActionMenu, please use DropdownMenu or SelectPanel instead. More information: https://primer.style/design/components/action-list#application');
|
31
|
+
return null;
|
32
|
+
}
|
33
|
+
|
25
34
|
if (selectionVariant === 'single') {
|
26
35
|
return /*#__PURE__*/React.createElement(LeadingVisualContainer, null, selected && /*#__PURE__*/React.createElement(CheckIcon, null));
|
27
36
|
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { Divider } from './Divider';
|
3
2
|
export type { ListProps as ActionListProps } from './List';
|
4
3
|
export type { GroupProps } from './Group';
|
5
4
|
export type { ItemProps } from './Item';
|
@@ -26,7 +25,7 @@ export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRe
|
|
26
25
|
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
27
26
|
}>;
|
28
27
|
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
29
|
-
Divider:
|
28
|
+
Divider: import("react").FC<import("../sx").SxProp>;
|
30
29
|
/** Secondary text which provides additional information about an `Item`. */
|
31
30
|
Description: import("react").FC<import("./Description").DescriptionProps>;
|
32
31
|
/** Icon (or similar) positioned before `Item` text. */
|