@primer/components 0.0.0-202182422492 → 0.0.0-20218276039
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 +1 -5
- package/dist/browser.esm.js +2 -3
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -3
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.d.ts +4 -17
- package/lib/ActionList/Item.js +6 -8
- package/lib/ActionList/List.d.ts +5 -7
- package/lib/ActionList/List.js +2 -2
- package/lib/ActionList/index.d.ts +2 -1
- package/lib-esm/ActionList/Item.d.ts +4 -17
- package/lib-esm/ActionList/Item.js +5 -8
- package/lib-esm/ActionList/List.d.ts +5 -7
- package/lib-esm/ActionList/List.js +2 -2
- package/lib-esm/ActionList/index.d.ts +2 -1
- package/package.json +2 -3
package/lib/ActionList/Item.d.ts
CHANGED
@@ -2,12 +2,10 @@ import { IconProps } from '@primer/octicons-react';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { SxProp } from '../sx';
|
4
4
|
import { ItemInput } from './List';
|
5
|
-
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
6
|
-
import { AriaRole } from '../utils/types';
|
7
5
|
/**
|
8
6
|
* Contract for props passed to the `Item` component.
|
9
7
|
*/
|
10
|
-
export interface ItemProps extends SxProp {
|
8
|
+
export interface ItemProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'id'>, SxProp {
|
11
9
|
/**
|
12
10
|
* Primary text which names an `Item`.
|
13
11
|
*/
|
@@ -70,18 +68,6 @@ export interface ItemProps extends SxProp {
|
|
70
68
|
* An id associated with this item. Should be unique between items
|
71
69
|
*/
|
72
70
|
id?: number | string;
|
73
|
-
/**
|
74
|
-
* Node to be included inside the item before the text.
|
75
|
-
*/
|
76
|
-
children?: React.ReactNode;
|
77
|
-
/**
|
78
|
-
* The ARIA role describing the function of `List` component. `option` is a common value.
|
79
|
-
*/
|
80
|
-
role?: AriaRole;
|
81
|
-
/**
|
82
|
-
* An item to pass back in the `onAction` callback, meant as
|
83
|
-
*/
|
84
|
-
item?: ItemInput;
|
85
71
|
}
|
86
72
|
export declare const TextContainer: import("styled-components").StyledComponent<"span", any, {
|
87
73
|
dangerouslySetInnerHtml?: React.DOMAttributes<HTMLDivElement>['dangerouslySetInnerHTML'];
|
@@ -89,5 +75,6 @@ export declare const TextContainer: import("styled-components").StyledComponent<
|
|
89
75
|
/**
|
90
76
|
* An actionable or selectable `Item` with an optional icon and description.
|
91
77
|
*/
|
92
|
-
declare
|
93
|
-
|
78
|
+
export declare function Item(itemProps: Partial<ItemProps> & {
|
79
|
+
item?: ItemInput;
|
80
|
+
}): JSX.Element;
|
package/lib/ActionList/Item.js
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.Item =
|
6
|
+
exports.Item = Item;
|
7
|
+
exports.TextContainer = void 0;
|
7
8
|
|
8
9
|
var _octiconsReact = require("@primer/octicons-react");
|
9
10
|
|
@@ -110,7 +111,7 @@ const MainContent = _styledComponents.default.div.withConfig({
|
|
110
111
|
const StyledItem = _styledComponents.default.div.withConfig({
|
111
112
|
displayName: "Item__StyledItem",
|
112
113
|
componentId: "jqpvy8-2"
|
113
|
-
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear
|
114
|
+
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");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'), ({
|
114
115
|
variant,
|
115
116
|
item
|
116
117
|
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
|
@@ -177,9 +178,8 @@ const MultiSelectInput = _styledComponents.default.input.withConfig({
|
|
177
178
|
*/
|
178
179
|
|
179
180
|
|
180
|
-
|
181
|
+
function Item(itemProps) {
|
181
182
|
const {
|
182
|
-
as: Component,
|
183
183
|
text,
|
184
184
|
description,
|
185
185
|
descriptionVariant = 'inline',
|
@@ -235,8 +235,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
|
235
235
|
theme
|
236
236
|
} = (0, _ThemeProvider.useTheme)();
|
237
237
|
return /*#__PURE__*/_react.default.createElement(StyledItem, _extends({
|
238
|
-
ref: ref,
|
239
|
-
as: Component,
|
240
238
|
tabIndex: disabled ? undefined : -1,
|
241
239
|
variant: variant,
|
242
240
|
showDivider: showDivider,
|
@@ -282,6 +280,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
|
282
280
|
variant: variant,
|
283
281
|
disabled: disabled
|
284
282
|
}, trailingText, TrailingIcon && /*#__PURE__*/_react.default.createElement(TrailingIcon, null)) : null));
|
285
|
-
}
|
283
|
+
}
|
286
284
|
|
287
|
-
|
285
|
+
Item.displayName = "Item";
|
package/lib/ActionList/List.d.ts
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import type { AriaRole } from '../utils/types';
|
3
3
|
import { Group, GroupProps } from './Group';
|
4
|
-
import { ItemProps } from './Item';
|
5
|
-
declare type RenderItemFn = (props: ItemProps) => React.ReactElement;
|
4
|
+
import { Item, ItemProps } from './Item';
|
6
5
|
export declare type ItemInput = ItemProps | (Partial<ItemProps> & {
|
7
|
-
renderItem:
|
6
|
+
renderItem: typeof Item;
|
8
7
|
});
|
9
8
|
/**
|
10
9
|
* Contract for props passed to the `List` component.
|
@@ -27,7 +26,7 @@ export interface ListPropsBase {
|
|
27
26
|
* without a `Group`-level or `Item`-level custom `Item` renderer will be
|
28
27
|
* rendered using this function component.
|
29
28
|
*/
|
30
|
-
renderItem?:
|
29
|
+
renderItem?: typeof Item;
|
31
30
|
/**
|
32
31
|
* A `List`-level custom `Group` renderer. Every `Group` within this `List`
|
33
32
|
* without a `Group`-level custom `Item` renderer will be rendered using
|
@@ -59,7 +58,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
59
58
|
* and `Group`-level custom `Item` or `Group` renderers.
|
60
59
|
*/
|
61
60
|
groupMetadata: ((Omit<GroupProps, 'items'> | Omit<Partial<GroupProps> & {
|
62
|
-
renderItem?:
|
61
|
+
renderItem?: typeof Item;
|
63
62
|
renderGroup?: typeof Group;
|
64
63
|
}, 'items'>) & {
|
65
64
|
groupId: string;
|
@@ -69,7 +68,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
69
68
|
* and `Item`-level custom `Item` renderers.
|
70
69
|
*/
|
71
70
|
items: ((ItemProps | (Partial<ItemProps> & {
|
72
|
-
renderItem:
|
71
|
+
renderItem: typeof Item;
|
73
72
|
})) & {
|
74
73
|
groupId: string;
|
75
74
|
})[];
|
@@ -82,4 +81,3 @@ export declare type ListProps = ListPropsBase | GroupedListProps;
|
|
82
81
|
* Lists `Item`s, either grouped or ungrouped, with a `Divider` between each `Group`.
|
83
82
|
*/
|
84
83
|
export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLDivElement>>;
|
85
|
-
export {};
|
package/lib/ActionList/List.js
CHANGED
@@ -106,11 +106,11 @@ const List = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) => {
|
|
106
106
|
|
107
107
|
|
108
108
|
const renderItem = (itemProps, item, itemIndex) => {
|
109
|
-
var _itemProps$
|
109
|
+
var _ref2, _itemProps$key, _itemProps$id;
|
110
110
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
112
112
|
const ItemComponent = 'renderItem' in itemProps && itemProps.renderItem || props.renderItem || _Item.Item;
|
113
|
-
const key = (_itemProps$
|
113
|
+
const key = (_ref2 = (_itemProps$key = itemProps.key) !== null && _itemProps$key !== void 0 ? _itemProps$key : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
|
114
114
|
return /*#__PURE__*/_react.default.createElement(ItemComponent, _extends({
|
115
115
|
showDivider: props.showItemDividers,
|
116
116
|
selectionVariant: props.selectionVariant
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Group } from './Group';
|
3
|
+
import { Item } from './Item';
|
3
4
|
import { Divider } from './Divider';
|
4
5
|
export type { ListProps as ActionListProps } from './List';
|
5
6
|
export type { GroupProps } from './Group';
|
@@ -11,7 +12,7 @@ export declare const ActionList: import("react").ForwardRefExoticComponent<impor
|
|
11
12
|
/** Collects related `Items` in an `ActionList`. */
|
12
13
|
Group: typeof Group;
|
13
14
|
/** An actionable or selectable `Item` with an optional icon and description. */
|
14
|
-
Item:
|
15
|
+
Item: typeof Item;
|
15
16
|
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
16
17
|
Divider: typeof Divider;
|
17
18
|
};
|
@@ -2,12 +2,10 @@ import { IconProps } from '@primer/octicons-react';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { SxProp } from '../sx';
|
4
4
|
import { ItemInput } from './List';
|
5
|
-
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
6
|
-
import { AriaRole } from '../utils/types';
|
7
5
|
/**
|
8
6
|
* Contract for props passed to the `Item` component.
|
9
7
|
*/
|
10
|
-
export interface ItemProps extends SxProp {
|
8
|
+
export interface ItemProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'id'>, SxProp {
|
11
9
|
/**
|
12
10
|
* Primary text which names an `Item`.
|
13
11
|
*/
|
@@ -70,18 +68,6 @@ export interface ItemProps extends SxProp {
|
|
70
68
|
* An id associated with this item. Should be unique between items
|
71
69
|
*/
|
72
70
|
id?: number | string;
|
73
|
-
/**
|
74
|
-
* Node to be included inside the item before the text.
|
75
|
-
*/
|
76
|
-
children?: React.ReactNode;
|
77
|
-
/**
|
78
|
-
* The ARIA role describing the function of `List` component. `option` is a common value.
|
79
|
-
*/
|
80
|
-
role?: AriaRole;
|
81
|
-
/**
|
82
|
-
* An item to pass back in the `onAction` callback, meant as
|
83
|
-
*/
|
84
|
-
item?: ItemInput;
|
85
71
|
}
|
86
72
|
export declare const TextContainer: import("styled-components").StyledComponent<"span", any, {
|
87
73
|
dangerouslySetInnerHtml?: React.DOMAttributes<HTMLDivElement>['dangerouslySetInnerHTML'];
|
@@ -89,5 +75,6 @@ export declare const TextContainer: import("styled-components").StyledComponent<
|
|
89
75
|
/**
|
90
76
|
* An actionable or selectable `Item` with an optional icon and description.
|
91
77
|
*/
|
92
|
-
declare
|
93
|
-
|
78
|
+
export declare function Item(itemProps: Partial<ItemProps> & {
|
79
|
+
item?: ItemInput;
|
80
|
+
}): JSX.Element;
|
@@ -11,10 +11,10 @@ import { StyledDivider } from './Divider';
|
|
11
11
|
import { useColorSchemeVar, useTheme } from '../ThemeProvider';
|
12
12
|
import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '../behaviors/focusZone';
|
13
13
|
import { useSSRSafeId } from '@react-aria/ssr';
|
14
|
-
|
15
14
|
/**
|
16
15
|
* These colors are not yet in our default theme. Need to remove this once they are added.
|
17
16
|
*/
|
17
|
+
|
18
18
|
const customItemThemes = {
|
19
19
|
default: {
|
20
20
|
hover: {
|
@@ -85,7 +85,7 @@ const MainContent = styled.div.withConfig({
|
|
85
85
|
const StyledItem = styled.div.withConfig({
|
86
86
|
displayName: "Item__StyledItem",
|
87
87
|
componentId: "jqpvy8-2"
|
88
|
-
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear
|
88
|
+
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");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:", ";}", ""], get('space.2'), get('radii.2'), ({
|
89
89
|
variant,
|
90
90
|
item
|
91
91
|
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
|
@@ -144,9 +144,8 @@ const MultiSelectInput = styled.input.withConfig({
|
|
144
144
|
* An actionable or selectable `Item` with an optional icon and description.
|
145
145
|
*/
|
146
146
|
|
147
|
-
|
147
|
+
export function Item(itemProps) {
|
148
148
|
const {
|
149
|
-
as: Component,
|
150
149
|
text,
|
151
150
|
description,
|
152
151
|
descriptionVariant = 'inline',
|
@@ -202,8 +201,6 @@ const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
|
202
201
|
theme
|
203
202
|
} = useTheme();
|
204
203
|
return /*#__PURE__*/React.createElement(StyledItem, _extends({
|
205
|
-
ref: ref,
|
206
|
-
as: Component,
|
207
204
|
tabIndex: disabled ? undefined : -1,
|
208
205
|
variant: variant,
|
209
206
|
showDivider: showDivider,
|
@@ -249,5 +246,5 @@ const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
|
249
246
|
variant: variant,
|
250
247
|
disabled: disabled
|
251
248
|
}, trailingText, TrailingIcon && /*#__PURE__*/React.createElement(TrailingIcon, null)) : null));
|
252
|
-
}
|
253
|
-
|
249
|
+
}
|
250
|
+
Item.displayName = "Item";
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import type { AriaRole } from '../utils/types';
|
3
3
|
import { Group, GroupProps } from './Group';
|
4
|
-
import { ItemProps } from './Item';
|
5
|
-
declare type RenderItemFn = (props: ItemProps) => React.ReactElement;
|
4
|
+
import { Item, ItemProps } from './Item';
|
6
5
|
export declare type ItemInput = ItemProps | (Partial<ItemProps> & {
|
7
|
-
renderItem:
|
6
|
+
renderItem: typeof Item;
|
8
7
|
});
|
9
8
|
/**
|
10
9
|
* Contract for props passed to the `List` component.
|
@@ -27,7 +26,7 @@ export interface ListPropsBase {
|
|
27
26
|
* without a `Group`-level or `Item`-level custom `Item` renderer will be
|
28
27
|
* rendered using this function component.
|
29
28
|
*/
|
30
|
-
renderItem?:
|
29
|
+
renderItem?: typeof Item;
|
31
30
|
/**
|
32
31
|
* A `List`-level custom `Group` renderer. Every `Group` within this `List`
|
33
32
|
* without a `Group`-level custom `Item` renderer will be rendered using
|
@@ -59,7 +58,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
59
58
|
* and `Group`-level custom `Item` or `Group` renderers.
|
60
59
|
*/
|
61
60
|
groupMetadata: ((Omit<GroupProps, 'items'> | Omit<Partial<GroupProps> & {
|
62
|
-
renderItem?:
|
61
|
+
renderItem?: typeof Item;
|
63
62
|
renderGroup?: typeof Group;
|
64
63
|
}, 'items'>) & {
|
65
64
|
groupId: string;
|
@@ -69,7 +68,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
69
68
|
* and `Item`-level custom `Item` renderers.
|
70
69
|
*/
|
71
70
|
items: ((ItemProps | (Partial<ItemProps> & {
|
72
|
-
renderItem:
|
71
|
+
renderItem: typeof Item;
|
73
72
|
})) & {
|
74
73
|
groupId: string;
|
75
74
|
})[];
|
@@ -82,4 +81,3 @@ export declare type ListProps = ListPropsBase | GroupedListProps;
|
|
82
81
|
* Lists `Item`s, either grouped or ungrouped, with a `Divider` between each `Group`.
|
83
82
|
*/
|
84
83
|
export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLDivElement>>;
|
85
|
-
export {};
|
@@ -90,11 +90,11 @@ export const List = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
90
90
|
|
91
91
|
|
92
92
|
const renderItem = (itemProps, item, itemIndex) => {
|
93
|
-
var _itemProps$
|
93
|
+
var _ref2, _itemProps$key, _itemProps$id;
|
94
94
|
|
95
95
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
96
96
|
const ItemComponent = 'renderItem' in itemProps && itemProps.renderItem || props.renderItem || Item;
|
97
|
-
const key = (_itemProps$
|
97
|
+
const key = (_ref2 = (_itemProps$key = itemProps.key) !== null && _itemProps$key !== void 0 ? _itemProps$key : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
|
98
98
|
return /*#__PURE__*/React.createElement(ItemComponent, _extends({
|
99
99
|
showDivider: props.showItemDividers,
|
100
100
|
selectionVariant: props.selectionVariant
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Group } from './Group';
|
3
|
+
import { Item } from './Item';
|
3
4
|
import { Divider } from './Divider';
|
4
5
|
export type { ListProps as ActionListProps } from './List';
|
5
6
|
export type { GroupProps } from './Group';
|
@@ -11,7 +12,7 @@ export declare const ActionList: import("react").ForwardRefExoticComponent<impor
|
|
11
12
|
/** Collects related `Items` in an `ActionList`. */
|
12
13
|
Group: typeof Group;
|
13
14
|
/** An actionable or selectable `Item` with an optional icon and description. */
|
14
|
-
Item:
|
15
|
+
Item: typeof Item;
|
15
16
|
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
16
17
|
Divider: typeof Divider;
|
17
18
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-20218276039",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -45,7 +45,6 @@
|
|
45
45
|
"dependencies": {
|
46
46
|
"@primer/octicons-react": "^13.0.0",
|
47
47
|
"@primer/primitives": "4.7.1",
|
48
|
-
"@radix-ui/react-polymorphic": "0.0.14",
|
49
48
|
"@react-aria/ssr": "3.1.0",
|
50
49
|
"@styled-system/css": "5.1.5",
|
51
50
|
"@styled-system/props": "5.1.5",
|
@@ -90,7 +89,7 @@
|
|
90
89
|
"@types/jest-axe": "3.5.1",
|
91
90
|
"@types/lodash.isempty": "4.4.6",
|
92
91
|
"@types/lodash.isobject": "3.0.6",
|
93
|
-
"@typescript-eslint/eslint-plugin": "4.
|
92
|
+
"@typescript-eslint/eslint-plugin": "4.31.2",
|
94
93
|
"@typescript-eslint/parser": "4.26.1",
|
95
94
|
"@wojtekmaj/enzyme-adapter-react-17": "0.6.3",
|
96
95
|
"babel-core": "7.0.0-bridge.0",
|