@primer/components 0.0.0-202111255030 → 0.0.0-202111301520
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/dist/browser.esm.js +2 -2209
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -2209
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Header.js +1 -1
- package/lib/ActionList/Item.js +10 -10
- package/lib/ActionList/List.js +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +22 -6
- package/lib/ActionList2/List.js +12 -2
- package/lib/ActionList2/MenuContext.d.ts +10 -0
- package/lib/ActionList2/MenuContext.js +15 -0
- package/lib/ActionList2/Selection.js +11 -0
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +313 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Autocomplete/Autocomplete.d.ts +2 -1
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -1
- package/lib/BaseStyles.js +2 -20
- package/lib/BorderBox.js +1 -1
- package/lib/Box.js +1 -1
- package/lib/Breadcrumbs.js +3 -3
- package/lib/Button/Button.d.ts +2 -2
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonClose.d.ts +2 -2
- package/lib/Button/ButtonDanger.d.ts +2 -2
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Button/ButtonInvisible.d.ts +2 -2
- package/lib/Button/ButtonOutline.d.ts +2 -2
- package/lib/Button/ButtonPrimary.d.ts +2 -2
- package/lib/Checkbox.js +1 -1
- package/lib/CircleOcticon.d.ts +35 -35
- package/lib/Details.js +1 -1
- package/lib/Dialog.d.ts +37 -37
- package/lib/Dropdown.d.ts +6 -6
- package/lib/DropdownMenu/DropdownButton.d.ts +6 -3
- package/lib/FilterList.d.ts +1 -1
- package/lib/FilteredActionList/FilteredActionList.js +1 -1
- package/lib/Flex.js +1 -1
- package/lib/LabelGroup.js +1 -1
- package/lib/NewButton/button.d.ts +11 -2
- package/lib/NewButton/button.js +283 -6
- package/lib/NewButton/index.d.ts +11 -6
- package/lib/NewButton/index.js +0 -18
- package/lib/NewButton/types.d.ts +8 -28
- package/lib/NewButton/types.js +1 -19
- package/lib/Overlay.js +1 -1
- package/lib/Pagination/Pagination.js +2 -2
- package/lib/Position.d.ts +4 -4
- package/lib/Position.js +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +11 -10
- package/lib/SelectMenu/SelectMenu.js +1 -1
- package/lib/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib/SelectMenu/SelectMenuTabs.js +1 -1
- package/lib/StateLabel.js +1 -1
- package/lib/StyledOcticon.js +1 -1
- package/lib/SubNav.js +3 -3
- package/lib/TextInputWithTokens.d.ts +2 -1
- package/lib/ThemeProvider.d.ts +1 -0
- package/lib/ThemeProvider.js +17 -4
- package/lib/Timeline.js +4 -4
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/AvatarToken.js +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/TokenBase.js +1 -1
- package/lib/Tooltip.js +1 -1
- package/lib/UnderlineNav.js +2 -2
- package/lib/drafts.d.ts +1 -0
- package/lib/drafts.js +13 -0
- package/lib-esm/ActionList/Header.js +1 -1
- package/lib-esm/ActionList/Item.js +10 -10
- package/lib-esm/ActionList/List.js +1 -1
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +20 -6
- package/lib-esm/ActionList2/List.js +10 -2
- 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 +313 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -1
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -1
- package/lib-esm/BaseStyles.js +2 -20
- package/lib-esm/BorderBox.js +1 -1
- package/lib-esm/Box.js +1 -1
- package/lib-esm/Breadcrumbs.js +3 -3
- package/lib-esm/Button/Button.d.ts +2 -2
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +2 -2
- package/lib-esm/Button/ButtonDanger.d.ts +2 -2
- package/lib-esm/Button/ButtonGroup.js +1 -1
- package/lib-esm/Button/ButtonInvisible.d.ts +2 -2
- package/lib-esm/Button/ButtonOutline.d.ts +2 -2
- package/lib-esm/Button/ButtonPrimary.d.ts +2 -2
- package/lib-esm/Checkbox.js +1 -1
- package/lib-esm/CircleOcticon.d.ts +35 -35
- package/lib-esm/Details.js +1 -1
- package/lib-esm/Dialog.d.ts +37 -37
- package/lib-esm/Dropdown.d.ts +6 -6
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -3
- package/lib-esm/FilterList.d.ts +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +1 -1
- package/lib-esm/Flex.js +1 -1
- package/lib-esm/LabelGroup.js +1 -1
- package/lib-esm/NewButton/button.d.ts +11 -2
- package/lib-esm/NewButton/button.js +275 -4
- package/lib-esm/NewButton/index.d.ts +11 -6
- package/lib-esm/NewButton/index.js +1 -4
- package/lib-esm/NewButton/types.d.ts +8 -28
- package/lib-esm/NewButton/types.js +1 -6
- package/lib-esm/Overlay.js +1 -1
- package/lib-esm/Pagination/Pagination.js +2 -2
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/Position.js +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -10
- package/lib-esm/SelectMenu/SelectMenu.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTabs.js +1 -1
- package/lib-esm/StateLabel.js +1 -1
- package/lib-esm/StyledOcticon.js +1 -1
- package/lib-esm/SubNav.js +3 -3
- package/lib-esm/TextInputWithTokens.d.ts +2 -1
- package/lib-esm/ThemeProvider.d.ts +1 -0
- package/lib-esm/ThemeProvider.js +17 -4
- package/lib-esm/Timeline.js +4 -4
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/AvatarToken.js +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Token/TokenBase.js +1 -1
- package/lib-esm/Tooltip.js +1 -1
- package/lib-esm/UnderlineNav.js +2 -2
- package/lib-esm/drafts.d.ts +1 -0
- package/lib-esm/drafts.js +2 -1
- package/package.json +14 -8
- package/CHANGELOG.md +0 -992
- package/lib/NewButton/button-base.d.ts +0 -6
- package/lib/NewButton/button-base.js +0 -69
- package/lib/NewButton/button-link.d.ts +0 -26
- package/lib/NewButton/button-link.js +0 -31
- package/lib/NewButton/icon-button.d.ts +0 -4
- package/lib/NewButton/icon-button.js +0 -57
- package/lib/NewButton/styles.d.ts +0 -202
- package/lib/NewButton/styles.js +0 -248
- package/lib-esm/NewButton/button-base.d.ts +0 -6
- package/lib-esm/NewButton/button-base.js +0 -47
- package/lib-esm/NewButton/button-link.d.ts +0 -26
- package/lib-esm/NewButton/button-link.js +0 -15
- package/lib-esm/NewButton/icon-button.d.ts +0 -4
- package/lib-esm/NewButton/icon-button.js +0 -35
- package/lib-esm/NewButton/styles.d.ts +0 -202
- package/lib-esm/NewButton/styles.js +0 -229
package/lib/ActionList/Header.js
CHANGED
@@ -24,7 +24,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
24
24
|
|
25
25
|
const StyledHeader = _styledComponents.default.div.withConfig({
|
26
26
|
displayName: "Header__StyledHeader",
|
27
|
-
componentId: "qmofje-0"
|
27
|
+
componentId: "sc-qmofje-0"
|
28
28
|
})(["{}padding:6px ", ";font-size:", ";font-weight:", ";color:", ";", " ", ""], (0, _constants.get)('space.3'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('colors.fg.muted'), ({
|
29
29
|
variant
|
30
30
|
}) => variant === 'filled' && (0, _styledComponents.css)(["background:", ";margin:", " 0;border-top:1px solid ", ";border-bottom:1px solid ", ";&:first-child{margin-top:0;}"], (0, _constants.get)('colors.canvas.subtle'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.neutral.muted'), (0, _constants.get)('colors.neutral.muted')), _sx.default);
|
package/lib/ActionList/Item.js
CHANGED
@@ -71,17 +71,17 @@ const getItemVariant = (variant = 'default', disabled) => {
|
|
71
71
|
|
72
72
|
const DividedContent = _styledComponents.default.div.withConfig({
|
73
73
|
displayName: "Item__DividedContent",
|
74
|
-
componentId: "jqpvy8-0"
|
74
|
+
componentId: "sc-jqpvy8-0"
|
75
75
|
})(["display:flex;min-width:0;position:relative;flex-grow:1;"]);
|
76
76
|
|
77
77
|
const MainContent = _styledComponents.default.div.withConfig({
|
78
78
|
displayName: "Item__MainContent",
|
79
|
-
componentId: "jqpvy8-1"
|
79
|
+
componentId: "sc-jqpvy8-1"
|
80
80
|
})(["align-items:baseline;display:flex;min-width:0;flex-direction:var(--main-content-flex-direction);flex-grow:1;"]);
|
81
81
|
|
82
82
|
const StyledItem = _styledComponents.default.div.withConfig({
|
83
83
|
displayName: "Item__StyledItem",
|
84
|
-
componentId: "jqpvy8-2"
|
84
|
+
componentId: "sc-jqpvy8-2"
|
85
85
|
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;text-decoration:none;@media (hover:hover) and (pointer:fine){:hover{background:var( --item-hover-bg-override,", " );color:", ";cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], (0, _constants.get)('space.2'), (0, _constants.get)('radii.2'), ({
|
86
86
|
variant,
|
87
87
|
item
|
@@ -114,30 +114,30 @@ const StyledItem = _styledComponents.default.div.withConfig({
|
|
114
114
|
|
115
115
|
const TextContainer = _styledComponents.default.span.withConfig({
|
116
116
|
displayName: "Item__TextContainer",
|
117
|
-
componentId: "jqpvy8-3"
|
117
|
+
componentId: "sc-jqpvy8-3"
|
118
118
|
})([""]);
|
119
119
|
|
120
120
|
exports.TextContainer = TextContainer;
|
121
121
|
|
122
122
|
const BaseVisualContainer = _styledComponents.default.div.withConfig({
|
123
123
|
displayName: "Item__BaseVisualContainer",
|
124
|
-
componentId: "jqpvy8-4"
|
124
|
+
componentId: "sc-jqpvy8-4"
|
125
125
|
})(["height:20px;width:", ";margin-right:", ";display:flex;justify-content:center;align-items:center;flex-shrink:0;"], (0, _constants.get)('space.3'), (0, _constants.get)('space.2'));
|
126
126
|
|
127
127
|
const ColoredVisualContainer = (0, _styledComponents.default)(BaseVisualContainer).withConfig({
|
128
128
|
displayName: "Item__ColoredVisualContainer",
|
129
|
-
componentId: "jqpvy8-5"
|
129
|
+
componentId: "sc-jqpvy8-5"
|
130
130
|
})(["svg{fill:", ";font-size:", ";}"], ({
|
131
131
|
variant,
|
132
132
|
disabled
|
133
133
|
}) => getItemVariant(variant, disabled).iconColor, (0, _constants.get)('fontSizes.0'));
|
134
134
|
const LeadingVisualContainer = (0, _styledComponents.default)(ColoredVisualContainer).withConfig({
|
135
135
|
displayName: "Item__LeadingVisualContainer",
|
136
|
-
componentId: "jqpvy8-6"
|
136
|
+
componentId: "sc-jqpvy8-6"
|
137
137
|
})(["display:flex;flex-direction:column;justify-content:center;"]);
|
138
138
|
const TrailingContent = (0, _styledComponents.default)(ColoredVisualContainer).withConfig({
|
139
139
|
displayName: "Item__TrailingContent",
|
140
|
-
componentId: "jqpvy8-7"
|
140
|
+
componentId: "sc-jqpvy8-7"
|
141
141
|
})(["color:", "};margin-left:", ";margin-right:0;width:auto;div:nth-child(2){margin-left:", ";}"], ({
|
142
142
|
variant,
|
143
143
|
disabled
|
@@ -145,12 +145,12 @@ const TrailingContent = (0, _styledComponents.default)(ColoredVisualContainer).w
|
|
145
145
|
|
146
146
|
const DescriptionContainer = _styledComponents.default.span.withConfig({
|
147
147
|
displayName: "Item__DescriptionContainer",
|
148
|
-
componentId: "jqpvy8-8"
|
148
|
+
componentId: "sc-jqpvy8-8"
|
149
149
|
})(["color:", ";font-size:", ";line-height:16px;margin-left:var(--description-container-margin-left);min-width:0;flex-grow:1;flex-basis:var(--description-container-flex-basis);"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('fontSizes.0'));
|
150
150
|
|
151
151
|
const MultiSelectIcon = _styledComponents.default.svg.withConfig({
|
152
152
|
displayName: "Item__MultiSelectIcon",
|
153
|
-
componentId: "jqpvy8-9"
|
153
|
+
componentId: "sc-jqpvy8-9"
|
154
154
|
})(["rect{fill:", ";stroke:", ";shape-rendering:auto;}path{fill:", ";boxshadow:", ";opacity:", ";}"], ({
|
155
155
|
selected
|
156
156
|
}) => selected ? (0, _constants.get)('colors.accent.fg') : (0, _constants.get)('colors.canvas.default'), ({
|
package/lib/ActionList/List.js
CHANGED
@@ -37,7 +37,7 @@ function isGroupedListProps(props) {
|
|
37
37
|
|
38
38
|
const StyledList = _styledComponents.default.div.withConfig({
|
39
39
|
displayName: "List__StyledList",
|
40
|
-
componentId: "yr2k7d-0"
|
40
|
+
componentId: "sc-yr2k7d-0"
|
41
41
|
})(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], (0, _constants.get)('fontSizes.1'), _focusZone.hasActiveDescendantAttribute, (0, _constants.get)('colors.border.muted'));
|
42
42
|
/**
|
43
43
|
* Returns `sx` prop values for `List` children matching the given `List` style variation.
|
@@ -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>;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.Divider =
|
6
|
+
exports.Divider = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -11,25 +11,30 @@ var _Box = _interopRequireDefault(require("../Box"));
|
|
11
11
|
|
12
12
|
var _constants = require("../constants");
|
13
13
|
|
14
|
+
var _sx = require("../sx");
|
15
|
+
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
16
18
|
/**
|
17
19
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
18
20
|
*/
|
19
|
-
|
21
|
+
const Divider = ({
|
22
|
+
sx = {}
|
23
|
+
}) => {
|
20
24
|
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
21
25
|
as: "li",
|
22
26
|
role: "separator",
|
23
|
-
sx: {
|
27
|
+
sx: (0, _sx.merge)({
|
24
28
|
height: 1,
|
25
29
|
backgroundColor: 'actionListItem.inlineDivider',
|
26
30
|
marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
|
27
31
|
marginBottom: 2,
|
28
32
|
listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
|
29
33
|
|
30
|
-
},
|
34
|
+
}, sx),
|
31
35
|
"data-component": "ActionList.Divider"
|
32
36
|
});
|
33
|
-
}
|
37
|
+
};
|
34
38
|
|
39
|
+
exports.Divider = Divider;
|
35
40
|
Divider.displayName = "Divider";
|
package/lib/ActionList2/Item.js
CHANGED
@@ -21,6 +21,8 @@ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
|
|
21
21
|
|
22
22
|
var _List = require("./List");
|
23
23
|
|
24
|
+
var _MenuContext = require("./MenuContext");
|
25
|
+
|
24
26
|
var _Selection = require("./Selection");
|
25
27
|
|
26
28
|
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); }
|
@@ -68,7 +70,7 @@ exports.Slot = Slot;
|
|
68
70
|
|
69
71
|
const LiBox = _styledComponents.default.li.withConfig({
|
70
72
|
displayName: "Item__LiBox",
|
71
|
-
componentId: "c3scat-0"
|
73
|
+
componentId: "sc-c3scat-0"
|
72
74
|
})(_sx.default);
|
73
75
|
|
74
76
|
const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
|
@@ -82,6 +84,7 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
82
84
|
onSelect,
|
83
85
|
sx: sxProp = {},
|
84
86
|
id,
|
87
|
+
role,
|
85
88
|
_PrivateItemWrapper,
|
86
89
|
...props
|
87
90
|
}, forwardedRef) => {
|
@@ -90,6 +93,11 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
90
93
|
showDividers
|
91
94
|
} = _react.default.useContext(_List.ListContext);
|
92
95
|
|
96
|
+
const {
|
97
|
+
itemRole,
|
98
|
+
afterSelect
|
99
|
+
} = _react.default.useContext(_MenuContext.MenuContext);
|
100
|
+
|
93
101
|
const {
|
94
102
|
theme
|
95
103
|
} = (0, _ThemeProvider.useTheme)();
|
@@ -165,17 +173,24 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
165
173
|
const clickHandler = _react.default.useCallback(event => {
|
166
174
|
if (typeof onSelect !== 'function') return;
|
167
175
|
if (disabled) return;
|
168
|
-
|
169
|
-
|
176
|
+
|
177
|
+
if (!event.defaultPrevented) {
|
178
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
179
|
+
|
180
|
+
if (typeof afterSelect === 'function') afterSelect();
|
181
|
+
}
|
182
|
+
}, [onSelect, disabled, afterSelect]);
|
170
183
|
|
171
184
|
const keyPressHandler = _react.default.useCallback(event => {
|
172
185
|
if (typeof onSelect !== 'function') return;
|
173
186
|
if (disabled) return;
|
174
187
|
|
175
188
|
if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
|
176
|
-
onSelect(event);
|
189
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
190
|
+
|
191
|
+
if (typeof afterSelect === 'function') afterSelect();
|
177
192
|
}
|
178
|
-
}, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
|
193
|
+
}, [onSelect, disabled, afterSelect]); // use props.id if provided, otherwise generate one.
|
179
194
|
|
180
195
|
|
181
196
|
const labelId = (0, _ssr.useSSRSafeId)(id);
|
@@ -198,7 +213,8 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
198
213
|
"aria-disabled": disabled ? true : undefined,
|
199
214
|
tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
|
200
215
|
"aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
|
201
|
-
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
|
216
|
+
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined,
|
217
|
+
role: role || itemRole
|
202
218
|
}, props), /*#__PURE__*/_react.default.createElement(ItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
|
203
219
|
selected: selected
|
204
220
|
}), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
package/lib/ActionList2/List.js
CHANGED
@@ -11,6 +11,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
|
12
12
|
var _sx = _interopRequireWildcard(require("../sx"));
|
13
13
|
|
14
|
+
var _MenuContext = require("./MenuContext");
|
15
|
+
|
14
16
|
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); }
|
15
17
|
|
16
18
|
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; }
|
@@ -25,13 +27,14 @@ exports.ListContext = ListContext;
|
|
25
27
|
|
26
28
|
const ListBox = _styledComponents.default.ul.withConfig({
|
27
29
|
displayName: "List__ListBox",
|
28
|
-
componentId: "cvbq60-0"
|
30
|
+
componentId: "sc-cvbq60-0"
|
29
31
|
})(_sx.default);
|
30
32
|
|
31
33
|
const List = /*#__PURE__*/_react.default.forwardRef(({
|
32
34
|
variant = 'inset',
|
33
35
|
selectionVariant,
|
34
36
|
showDividers = false,
|
37
|
+
role,
|
35
38
|
sx: sxProp = {},
|
36
39
|
...props
|
37
40
|
}, forwardedRef) => {
|
@@ -41,8 +44,15 @@ const List = /*#__PURE__*/_react.default.forwardRef(({
|
|
41
44
|
// reset ul styles
|
42
45
|
paddingY: variant === 'inset' ? 2 : 0
|
43
46
|
};
|
47
|
+
/** if list is inside a Menu, it will get a role from the Menu */
|
48
|
+
|
49
|
+
const {
|
50
|
+
listRole
|
51
|
+
} = _react.default.useContext(_MenuContext.MenuContext);
|
52
|
+
|
44
53
|
return /*#__PURE__*/_react.default.createElement(ListBox, _extends({
|
45
|
-
sx: (0, _sx.merge)(styles, sxProp)
|
54
|
+
sx: (0, _sx.merge)(styles, sxProp),
|
55
|
+
role: role || listRole
|
46
56
|
}, props, {
|
47
57
|
ref: forwardedRef
|
48
58
|
}), /*#__PURE__*/_react.default.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 {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.MenuContext = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
/** This context can be used by components that compose ActionList inside a Menu */
|
13
|
+
const MenuContext = /*#__PURE__*/_react.default.createContext({});
|
14
|
+
|
15
|
+
exports.MenuContext = MenuContext;
|
@@ -13,6 +13,8 @@ var _List = require("./List");
|
|
13
13
|
|
14
14
|
var _Group = require("./Group");
|
15
15
|
|
16
|
+
var _MenuContext = require("./MenuContext");
|
17
|
+
|
16
18
|
var _Visuals = require("./Visuals");
|
17
19
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -27,6 +29,10 @@ const Selection = ({
|
|
27
29
|
const {
|
28
30
|
selectionVariant: groupSelectionVariant
|
29
31
|
} = _react.default.useContext(_Group.GroupContext);
|
32
|
+
|
33
|
+
const {
|
34
|
+
parent
|
35
|
+
} = _react.default.useContext(_MenuContext.MenuContext);
|
30
36
|
/** selectionVariant in Group can override the selectionVariant in List root */
|
31
37
|
|
32
38
|
|
@@ -38,6 +44,11 @@ const Selection = ({
|
|
38
44
|
return null;
|
39
45
|
}
|
40
46
|
|
47
|
+
if (parent === 'ActionMenu') {
|
48
|
+
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');
|
49
|
+
return null;
|
50
|
+
}
|
51
|
+
|
41
52
|
if (selectionVariant === 'single') {
|
42
53
|
return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, null));
|
43
54
|
}
|
@@ -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. */
|