@primer/components 0.0.0-20219150508 → 0.0.0-202191514926
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 -1
- package/dist/browser.esm.js +69 -69
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +28 -28
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Header.js +1 -1
- package/lib/ActionList/Item.js +7 -7
- package/lib/ActionList2/Description.d.ts +5 -0
- package/lib/ActionList2/Description.js +54 -0
- package/lib/ActionList2/Divider.d.ts +8 -0
- package/lib/ActionList2/Divider.js +42 -0
- package/lib/ActionList2/Group.d.ts +8 -0
- package/lib/ActionList2/Group.js +39 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Item.d.ts +53 -0
- package/lib/ActionList2/Item.js +188 -0
- package/lib/ActionList2/List.d.ts +18 -0
- package/lib/ActionList2/List.js +52 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +67 -0
- package/lib/ActionList2/Visuals.d.ts +12 -0
- package/lib/ActionList2/Visuals.js +91 -0
- package/lib/ActionList2/hacks.d.ts +30 -0
- package/lib/ActionList2/hacks.js +38 -0
- package/lib/ActionList2/index.d.ts +26 -0
- package/lib/ActionList2/index.js +36 -0
- package/lib/BranchName.js +1 -1
- package/lib/Breadcrumbs.js +1 -1
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonClose.js +1 -1
- package/lib/Button/ButtonInvisible.js +1 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Dialog/ConfirmationDialog.js +1 -1
- package/lib/Dialog/Dialog.js +2 -2
- package/lib/FilterList.js +1 -1
- package/lib/Label.js +1 -1
- package/lib/Link.js +1 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SubNav.js +1 -1
- package/lib/Timeline.js +2 -2
- package/lib/Token/Token.js +1 -1
- package/lib/UnderlineNav.js +1 -1
- package/lib/_TextInputWrapper.js +1 -1
- package/lib-esm/ActionList/Header.js +1 -1
- package/lib-esm/ActionList/Item.js +7 -7
- package/lib-esm/ActionList2/Description.d.ts +5 -0
- package/lib-esm/ActionList2/Description.js +38 -0
- package/lib-esm/ActionList2/Divider.d.ts +8 -0
- package/lib-esm/ActionList2/Divider.js +30 -0
- package/lib-esm/ActionList2/Group.d.ts +8 -0
- package/lib-esm/ActionList2/Group.js +29 -0
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +45 -0
- package/lib-esm/ActionList2/Item.d.ts +53 -0
- package/lib-esm/ActionList2/Item.js +185 -0
- package/lib-esm/ActionList2/List.d.ts +18 -0
- package/lib-esm/ActionList2/List.js +42 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +50 -0
- package/lib-esm/ActionList2/Visuals.d.ts +12 -0
- package/lib-esm/ActionList2/Visuals.js +68 -0
- package/lib-esm/ActionList2/hacks.d.ts +30 -0
- package/lib-esm/ActionList2/hacks.js +30 -0
- package/lib-esm/ActionList2/index.d.ts +26 -0
- package/lib-esm/ActionList2/index.js +23 -0
- package/lib-esm/BranchName.js +1 -1
- package/lib-esm/Breadcrumbs.js +1 -1
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonClose.js +1 -1
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
- package/lib-esm/Dialog/Dialog.js +2 -2
- package/lib-esm/FilterList.js +1 -1
- package/lib-esm/Label.js +1 -1
- package/lib-esm/Link.js +1 -1
- package/lib-esm/Pagination/Pagination.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
- package/lib-esm/SubNav.js +1 -1
- package/lib-esm/Timeline.js +2 -2
- package/lib-esm/Token/Token.js +1 -1
- package/lib-esm/UnderlineNav.js +1 -1
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/package.json +1 -1
@@ -48,9 +48,9 @@ const customItemThemes = {
|
|
48
48
|
const getItemVariant = (variant = 'default', disabled) => {
|
49
49
|
if (disabled) {
|
50
50
|
return {
|
51
|
-
color: get('colors.
|
52
|
-
iconColor: get('colors.
|
53
|
-
annotationColor: get('colors.
|
51
|
+
color: get('colors.fg.muted'),
|
52
|
+
iconColor: get('colors.fg.muted'),
|
53
|
+
annotationColor: get('colors.fg.muted'),
|
54
54
|
hoverCursor: 'default'
|
55
55
|
};
|
56
56
|
}
|
@@ -60,15 +60,15 @@ const getItemVariant = (variant = 'default', disabled) => {
|
|
60
60
|
return {
|
61
61
|
color: get('colors.danger.fg'),
|
62
62
|
iconColor: get('colors.danger.fg'),
|
63
|
-
annotationColor: get('colors.
|
63
|
+
annotationColor: get('colors.fg.muted'),
|
64
64
|
hoverCursor: 'pointer'
|
65
65
|
};
|
66
66
|
|
67
67
|
default:
|
68
68
|
return {
|
69
69
|
color: get('colors.fg.default'),
|
70
|
-
iconColor: get('colors.
|
71
|
-
annotationColor: get('colors.
|
70
|
+
iconColor: get('colors.fg.muted'),
|
71
|
+
annotationColor: get('colors.fg.muted'),
|
72
72
|
hoverCursor: 'pointer'
|
73
73
|
};
|
74
74
|
}
|
@@ -135,7 +135,7 @@ const TrailingContent = styled(ColoredVisualContainer).withConfig({
|
|
135
135
|
const DescriptionContainer = styled.span.withConfig({
|
136
136
|
displayName: "Item__DescriptionContainer",
|
137
137
|
componentId: "jqpvy8-8"
|
138
|
-
})(["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);"], get('colors.
|
138
|
+
})(["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);"], get('colors.fg.muted'), get('fontSizes.0'));
|
139
139
|
const MultiSelectInput = styled.input.withConfig({
|
140
140
|
displayName: "Item__MultiSelectInput",
|
141
141
|
componentId: "jqpvy8-9"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Box from '../Box';
|
3
|
+
import Truncate from '../Truncate';
|
4
|
+
import { ItemContext } from './Item';
|
5
|
+
export const Description = ({
|
6
|
+
variant = 'inline',
|
7
|
+
...props
|
8
|
+
}) => {
|
9
|
+
const {
|
10
|
+
registerSlot
|
11
|
+
} = React.useContext(ItemContext);
|
12
|
+
const slotName = variant === 'block' ? 'BlockDescription' : 'InlineDescription';
|
13
|
+
const styles = {
|
14
|
+
color: 'fg.muted',
|
15
|
+
fontSize: 0,
|
16
|
+
lineHeight: '16px',
|
17
|
+
flexGrow: 1,
|
18
|
+
flexBasis: 0,
|
19
|
+
minWidth: 0,
|
20
|
+
marginLeft: variant === 'block' ? 0 : 2
|
21
|
+
};
|
22
|
+
|
23
|
+
if (variant === 'block') {
|
24
|
+
registerSlot(slotName, /*#__PURE__*/React.createElement(Box, {
|
25
|
+
as: "span",
|
26
|
+
sx: styles
|
27
|
+
}, props.children));
|
28
|
+
} else {
|
29
|
+
registerSlot(slotName, /*#__PURE__*/React.createElement(Truncate, {
|
30
|
+
sx: styles,
|
31
|
+
title: props.children,
|
32
|
+
inline: true,
|
33
|
+
maxWidth: "100%"
|
34
|
+
}, props.children));
|
35
|
+
}
|
36
|
+
|
37
|
+
return null;
|
38
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Box from '../Box';
|
3
|
+
import { get } from '../constants';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
7
|
+
*/
|
8
|
+
export function Divider() {
|
9
|
+
return /*#__PURE__*/React.createElement(Box, {
|
10
|
+
as: "hr",
|
11
|
+
sx: {
|
12
|
+
border: 'none',
|
13
|
+
// override browser styles
|
14
|
+
height: 1,
|
15
|
+
backgroundColor: 'border.muted',
|
16
|
+
marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
|
17
|
+
marginBottom: 2
|
18
|
+
},
|
19
|
+
"data-component": "ActionList.Divider"
|
20
|
+
});
|
21
|
+
}
|
22
|
+
Divider.displayName = "Divider";
|
23
|
+
|
24
|
+
/**
|
25
|
+
* `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
|
26
|
+
* so it can be used inline in an `ActionList`’s `items` prop.
|
27
|
+
* In other words, `items={[ActionList.Divider]}` is supported as a concise
|
28
|
+
* alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
|
29
|
+
*/
|
30
|
+
Divider.renderItem = Divider;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* show item dividers
|
3
|
+
*/
|
4
|
+
/// <reference types="react" />
|
5
|
+
import { SxProp } from '../sx';
|
6
|
+
import { HeaderProps } from './Header';
|
7
|
+
export declare type GroupProps = HeaderProps & SxProp;
|
8
|
+
export declare function Group({ title, variant, auxiliaryText, sx, ...props }: GroupProps): JSX.Element;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
/**
|
4
|
+
* show item dividers
|
5
|
+
*/
|
6
|
+
import React from 'react';
|
7
|
+
import Box from '../Box';
|
8
|
+
import { Header } from './Header';
|
9
|
+
export function Group({
|
10
|
+
title,
|
11
|
+
variant,
|
12
|
+
auxiliaryText,
|
13
|
+
sx = {},
|
14
|
+
...props
|
15
|
+
}) {
|
16
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
17
|
+
sx: {
|
18
|
+
'&:not(:first-child)': {
|
19
|
+
marginTop: 2
|
20
|
+
},
|
21
|
+
...sx
|
22
|
+
}
|
23
|
+
}, props), title && /*#__PURE__*/React.createElement(Header, {
|
24
|
+
title: title,
|
25
|
+
variant: variant,
|
26
|
+
auxiliaryText: auxiliaryText
|
27
|
+
}), props.children);
|
28
|
+
}
|
29
|
+
Group.displayName = "Group";
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
3
|
+
/**
|
4
|
+
* Contract for props passed to the `Header` component.
|
5
|
+
*/
|
6
|
+
export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
|
7
|
+
/**
|
8
|
+
* Style variations. Usage is discretionary.
|
9
|
+
*
|
10
|
+
* - `"filled"` - Superimposed on a background, offset from nearby content
|
11
|
+
* - `"subtle"` - Relatively less offset from nearby content
|
12
|
+
*/
|
13
|
+
variant?: 'subtle' | 'filled';
|
14
|
+
/**
|
15
|
+
* Primary text which names a `Group`.
|
16
|
+
*/
|
17
|
+
title?: string;
|
18
|
+
/**
|
19
|
+
* Secondary text which provides additional information about a `Group`.
|
20
|
+
*/
|
21
|
+
auxiliaryText?: string;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Displays the name and description of a `Group`.
|
25
|
+
*/
|
26
|
+
export declare function Header({ variant, title, auxiliaryText, children: _children, sx, ...props }: HeaderProps): JSX.Element;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
import React from 'react';
|
4
|
+
import Box from '../Box';
|
5
|
+
import { ListContext } from './List';
|
6
|
+
/**
|
7
|
+
* Contract for props passed to the `Header` component.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Displays the name and description of a `Group`.
|
12
|
+
*/
|
13
|
+
export function Header({
|
14
|
+
variant = 'subtle',
|
15
|
+
title,
|
16
|
+
auxiliaryText,
|
17
|
+
children: _children,
|
18
|
+
sx = {},
|
19
|
+
...props
|
20
|
+
}) {
|
21
|
+
const {
|
22
|
+
variant: listVariant
|
23
|
+
} = React.useContext(ListContext);
|
24
|
+
const styles = {
|
25
|
+
paddingY: '6px',
|
26
|
+
paddingX: listVariant === 'full' ? 2 : 3,
|
27
|
+
fontSize: 0,
|
28
|
+
fontWeight: 'bold',
|
29
|
+
color: 'fg.muted',
|
30
|
+
...(variant === 'filled' && {
|
31
|
+
backgroundColor: 'canvas.subtle',
|
32
|
+
marginX: 0,
|
33
|
+
marginBottom: 2,
|
34
|
+
borderTop: '1px solid',
|
35
|
+
borderBottom: '1px solid',
|
36
|
+
borderColor: 'neutral.muted'
|
37
|
+
}),
|
38
|
+
...sx
|
39
|
+
};
|
40
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
41
|
+
sx: styles,
|
42
|
+
role: "heading"
|
43
|
+
}, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, "auxiliaryText"));
|
44
|
+
}
|
45
|
+
Header.displayName = "Header";
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/**
|
2
|
+
* test suite!
|
3
|
+
* id, role
|
4
|
+
* text could be non-text
|
5
|
+
* activeDescendantAttribute
|
6
|
+
* deepmerge sx
|
7
|
+
* nicer name for showDivider?
|
8
|
+
* aria-label
|
9
|
+
* aria-describedby
|
10
|
+
* React.FC<Props> doesn't allow id?
|
11
|
+
* truncate description
|
12
|
+
* icon color
|
13
|
+
* disabled checkbox
|
14
|
+
* check height with divider
|
15
|
+
*
|
16
|
+
* use immediate child slot API instead of double render?
|
17
|
+
* change as= li | div based on context of menu or not?
|
18
|
+
* check if everyone accepts sx prop
|
19
|
+
* link example outside of overlay? (details)
|
20
|
+
* if one item has selected, should we give all of them selected without the need to pass prop?
|
21
|
+
* move custom item themes to primitives?
|
22
|
+
* padding: 8 or 6?
|
23
|
+
* ActionList.Selection or ActionList.Item selected?
|
24
|
+
* different size for icon and avatar, range?
|
25
|
+
* minimize number of divs?
|
26
|
+
*/
|
27
|
+
import React from 'react';
|
28
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
29
|
+
import { SxProp } from '../sx';
|
30
|
+
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
|
31
|
+
color: (props: any) => any;
|
32
|
+
iconColor: (props: any) => any;
|
33
|
+
annotationColor: (props: any) => any;
|
34
|
+
} | {
|
35
|
+
color: string;
|
36
|
+
iconColor: string;
|
37
|
+
annotationColor: string;
|
38
|
+
};
|
39
|
+
export declare type ItemProps = {
|
40
|
+
children: React.ReactNode;
|
41
|
+
onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
|
42
|
+
selected?: boolean;
|
43
|
+
variant?: 'default' | 'danger';
|
44
|
+
disabled?: boolean;
|
45
|
+
showDivider?: boolean;
|
46
|
+
} & SxProp;
|
47
|
+
declare type SlotNames = 'LeadingVisual' | 'InlineDescription' | 'BlockDescription' | 'TrailingVisual';
|
48
|
+
declare type ContextProps = {
|
49
|
+
registerSlot: (name: SlotNames, contents: React.ReactNode) => void;
|
50
|
+
};
|
51
|
+
export declare const ItemContext: React.Context<ContextProps>;
|
52
|
+
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
|
53
|
+
export {};
|
@@ -0,0 +1,185 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
/**
|
4
|
+
* test suite!
|
5
|
+
* id, role
|
6
|
+
* text could be non-text
|
7
|
+
* activeDescendantAttribute
|
8
|
+
* deepmerge sx
|
9
|
+
* nicer name for showDivider?
|
10
|
+
* aria-label
|
11
|
+
* aria-describedby
|
12
|
+
* React.FC<Props> doesn't allow id?
|
13
|
+
* truncate description
|
14
|
+
* icon color
|
15
|
+
* disabled checkbox
|
16
|
+
* check height with divider
|
17
|
+
*
|
18
|
+
* use immediate child slot API instead of double render?
|
19
|
+
* change as= li | div based on context of menu or not?
|
20
|
+
* check if everyone accepts sx prop
|
21
|
+
* link example outside of overlay? (details)
|
22
|
+
* if one item has selected, should we give all of them selected without the need to pass prop?
|
23
|
+
* move custom item themes to primitives?
|
24
|
+
* padding: 8 or 6?
|
25
|
+
* ActionList.Selection or ActionList.Item selected?
|
26
|
+
* different size for icon and avatar, range?
|
27
|
+
* minimize number of divs?
|
28
|
+
*/
|
29
|
+
import React from 'react';
|
30
|
+
import { useColorSchemeVar, useTheme } from '../ThemeProvider';
|
31
|
+
import Box from '../Box';
|
32
|
+
import { get } from '../constants';
|
33
|
+
import { ListContext } from './List';
|
34
|
+
import { customItemThemes } from './hacks';
|
35
|
+
import { Selection } from './Selection';
|
36
|
+
export const getVariantStyles = (variant, disabled) => {
|
37
|
+
if (disabled) {
|
38
|
+
return {
|
39
|
+
color: get('colors.fg.muted'),
|
40
|
+
iconColor: get('colors.fg.muted'),
|
41
|
+
annotationColor: get('colors.fg.muted')
|
42
|
+
};
|
43
|
+
}
|
44
|
+
|
45
|
+
switch (variant) {
|
46
|
+
case 'danger':
|
47
|
+
return {
|
48
|
+
color: 'danger.fg',
|
49
|
+
iconColor: 'danger.fg',
|
50
|
+
annotationColor: 'fg.muted'
|
51
|
+
};
|
52
|
+
|
53
|
+
default:
|
54
|
+
return {
|
55
|
+
color: 'fg.default',
|
56
|
+
iconColor: 'fg.muted',
|
57
|
+
annotationColor: 'fg.muted'
|
58
|
+
};
|
59
|
+
}
|
60
|
+
};
|
61
|
+
export const ItemContext = /*#__PURE__*/React.createContext({
|
62
|
+
registerSlot: () => null
|
63
|
+
});
|
64
|
+
export const Item = /*#__PURE__*/React.forwardRef(({
|
65
|
+
variant = 'default',
|
66
|
+
disabled = false,
|
67
|
+
selected = undefined,
|
68
|
+
showDivider = false,
|
69
|
+
onAction = () => null,
|
70
|
+
sx = {},
|
71
|
+
...props
|
72
|
+
}, forwardedRef) => {
|
73
|
+
const customItemTheme = customItemThemes[variant];
|
74
|
+
const {
|
75
|
+
variant: listVariant
|
76
|
+
} = React.useContext(ListContext);
|
77
|
+
const {
|
78
|
+
theme
|
79
|
+
} = useTheme();
|
80
|
+
const [slots, setSlots] = React.useState({
|
81
|
+
LeadingVisual: null,
|
82
|
+
InlineDescription: null,
|
83
|
+
BlockDescription: null,
|
84
|
+
TrailingVisual: null
|
85
|
+
});
|
86
|
+
|
87
|
+
const registerSlot = (name, contents) => {
|
88
|
+
if (slots[name] === null) setSlots({ ...slots,
|
89
|
+
[name]: contents
|
90
|
+
});
|
91
|
+
};
|
92
|
+
|
93
|
+
const styles = {
|
94
|
+
display: 'flex',
|
95
|
+
paddingX: get('space.2'),
|
96
|
+
paddingY: '6px',
|
97
|
+
marginX: listVariant === 'inset' ? get('space.2') : 0,
|
98
|
+
minHeight: get('space.5'),
|
99
|
+
borderRadius: get('radii.2'),
|
100
|
+
transition: 'background 33.333ms linear',
|
101
|
+
color: getVariantStyles(variant, disabled).color,
|
102
|
+
textDecoration: 'none',
|
103
|
+
// for as="a"
|
104
|
+
':not(disabled)': {
|
105
|
+
cursor: 'pointer'
|
106
|
+
},
|
107
|
+
'@media (hover: hover) and (pointer: fine)': {
|
108
|
+
':hover': {
|
109
|
+
backgroundColor: useColorSchemeVar(customItemTheme.hover, 'inherit')
|
110
|
+
},
|
111
|
+
':focus': {
|
112
|
+
backgroundColor: useColorSchemeVar(customItemTheme.focus, 'inherit')
|
113
|
+
}
|
114
|
+
},
|
115
|
+
|
116
|
+
/** Divider styles */
|
117
|
+
'[data-component="ActionList.Item--Main"]': {
|
118
|
+
position: 'relative'
|
119
|
+
},
|
120
|
+
'[data-component="ActionList.Item--Main"]::before': {
|
121
|
+
content: '" "',
|
122
|
+
display: 'block',
|
123
|
+
position: 'absolute',
|
124
|
+
width: '100%',
|
125
|
+
top: '-7px',
|
126
|
+
border: '0 solid',
|
127
|
+
borderTopWidth: showDivider ? `1px` : '0',
|
128
|
+
borderColor: 'var(--divider-color, transparent)'
|
129
|
+
},
|
130
|
+
// show between 2 items
|
131
|
+
':not(:first-of-type)': {
|
132
|
+
'--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
|
133
|
+
},
|
134
|
+
// hide divider after dividers & group header
|
135
|
+
'[data-component="ActionList.Divider"] + &': {
|
136
|
+
'--divider-color': 'transparent'
|
137
|
+
},
|
138
|
+
// hide border on current and previous item
|
139
|
+
'&:hover, &:focus': {
|
140
|
+
'--divider-color': 'transparent'
|
141
|
+
},
|
142
|
+
'&:hover + &, &:focus + &': {
|
143
|
+
'--divider-color': 'transparent'
|
144
|
+
},
|
145
|
+
...sx
|
146
|
+
};
|
147
|
+
const clickHandler = React.useCallback(event => {
|
148
|
+
if (disabled) return;
|
149
|
+
if (!event.defaultPrevented) onAction(event);
|
150
|
+
}, [onAction, disabled]);
|
151
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
152
|
+
as: "li",
|
153
|
+
sx: styles,
|
154
|
+
"data-component": "ActionList.Item",
|
155
|
+
onClick: clickHandler,
|
156
|
+
ref: forwardedRef
|
157
|
+
}, props), /*#__PURE__*/React.createElement(ItemContext.Provider, {
|
158
|
+
value: {
|
159
|
+
registerSlot
|
160
|
+
}
|
161
|
+
}, /*#__PURE__*/React.createElement(Selection, {
|
162
|
+
selected: selected,
|
163
|
+
disabled: disabled
|
164
|
+
}), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
|
165
|
+
"data-component": "ActionList.Item--Main",
|
166
|
+
sx: {
|
167
|
+
display: 'flex',
|
168
|
+
flexDirection: 'column',
|
169
|
+
flexGrow: 1,
|
170
|
+
minWidth: 0
|
171
|
+
}
|
172
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
173
|
+
sx: {
|
174
|
+
display: 'flex'
|
175
|
+
}
|
176
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
177
|
+
sx: {
|
178
|
+
display: 'flex',
|
179
|
+
flexGrow: 1,
|
180
|
+
alignItems: 'baseline',
|
181
|
+
minWidth: 0
|
182
|
+
}
|
183
|
+
}, /*#__PURE__*/React.createElement("span", null, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
|
184
|
+
});
|
185
|
+
Item.displayName = 'ActionList.Item';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* showItemDividers
|
4
|
+
* deepmerge sx
|
5
|
+
* change as= ul | div based on context of menu or not?
|
6
|
+
* should selectionVariant be single by default or nothing. ask for explicit choice?
|
7
|
+
*/
|
8
|
+
import React from 'react';
|
9
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
10
|
+
import { SxProp } from '../sx';
|
11
|
+
export declare type ListProps = {
|
12
|
+
variant?: 'inset' | 'full';
|
13
|
+
selectionVariant?: 'single' | 'multiple';
|
14
|
+
} & SxProp;
|
15
|
+
declare type ContextProps = Pick<ListProps, 'selectionVariant' | 'variant'>;
|
16
|
+
export declare const ListContext: React.Context<ContextProps>;
|
17
|
+
export declare const List: PolymorphicForwardRefComponent<"ul", ListProps>;
|
18
|
+
export {};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
/**
|
4
|
+
*
|
5
|
+
* showItemDividers
|
6
|
+
* deepmerge sx
|
7
|
+
* change as= ul | div based on context of menu or not?
|
8
|
+
* should selectionVariant be single by default or nothing. ask for explicit choice?
|
9
|
+
*/
|
10
|
+
import React from 'react';
|
11
|
+
import Box from '../Box';
|
12
|
+
import { get } from '../constants';
|
13
|
+
export const ListContext = /*#__PURE__*/React.createContext({});
|
14
|
+
export const List = /*#__PURE__*/React.forwardRef(({
|
15
|
+
variant = 'inset',
|
16
|
+
selectionVariant = 'single',
|
17
|
+
sx = {},
|
18
|
+
...props
|
19
|
+
}, forwardedRef) => {
|
20
|
+
const styles = {
|
21
|
+
margin: 0,
|
22
|
+
fontSize: get('fontSizes.1'),
|
23
|
+
lineHeight: '20px',
|
24
|
+
// TODO: check if we replace this already
|
25
|
+
paddingInlineStart: 0,
|
26
|
+
// reset ul styles
|
27
|
+
paddingY: variant === 'inset' ? get('space.2') : 0,
|
28
|
+
...sx
|
29
|
+
};
|
30
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
31
|
+
as: "ul",
|
32
|
+
sx: styles
|
33
|
+
}, props, {
|
34
|
+
ref: forwardedRef
|
35
|
+
}), /*#__PURE__*/React.createElement(ListContext.Provider, {
|
36
|
+
value: {
|
37
|
+
variant,
|
38
|
+
selectionVariant
|
39
|
+
}
|
40
|
+
}, props.children));
|
41
|
+
});
|
42
|
+
List.displayName = 'ActionList';
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { CheckIcon } from '@primer/octicons-react';
|
3
|
+
import { useTheme } from '../ThemeProvider';
|
4
|
+
import { ListContext } from './List';
|
5
|
+
import { LeadingVisualContainer } from './Visuals';
|
6
|
+
export const Selection = ({
|
7
|
+
selected,
|
8
|
+
disabled
|
9
|
+
}) => {
|
10
|
+
const {
|
11
|
+
selectionVariant
|
12
|
+
} = React.useContext(ListContext);
|
13
|
+
const {
|
14
|
+
theme
|
15
|
+
} = useTheme();
|
16
|
+
if (typeof selected === 'undefined') return null;
|
17
|
+
|
18
|
+
if (selectionVariant === 'single') {
|
19
|
+
return /*#__PURE__*/React.createElement(LeadingVisualContainer, null, selected && /*#__PURE__*/React.createElement(CheckIcon, {
|
20
|
+
fill: theme === null || theme === void 0 ? void 0 : theme.colors.text.primary
|
21
|
+
}));
|
22
|
+
}
|
23
|
+
|
24
|
+
if (selectionVariant === 'multiple') {
|
25
|
+
/**
|
26
|
+
* readOnly is required because we are doing a one-way bind to `checked`
|
27
|
+
* aria-readonly="false" tells screen that they can still interact with the checkbox
|
28
|
+
* TODO: not sure if disabled & aria-label be here or should we apply it on the instance as props
|
29
|
+
* TODO: aria-label should come from the text part of the slot
|
30
|
+
*/
|
31
|
+
return /*#__PURE__*/React.createElement(LeadingVisualContainer, {
|
32
|
+
sx: {
|
33
|
+
input: {
|
34
|
+
margin: 0,
|
35
|
+
pointerEvents: 'none'
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}, /*#__PURE__*/React.createElement("input", {
|
39
|
+
type: "checkbox",
|
40
|
+
checked: selected,
|
41
|
+
disabled: disabled,
|
42
|
+
"aria-label": "TODO",
|
43
|
+
tabIndex: -1,
|
44
|
+
readOnly: true,
|
45
|
+
"aria-readonly": "false"
|
46
|
+
}));
|
47
|
+
}
|
48
|
+
|
49
|
+
return null;
|
50
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
3
|
+
import { ItemProps } from './Item';
|
4
|
+
declare type VisualProps = Pick<ItemProps, 'variant' | 'disabled' | 'sx'> & {
|
5
|
+
children: React.ReactNode;
|
6
|
+
};
|
7
|
+
export declare const LeadingVisualContainer: React.FC<SxProp>;
|
8
|
+
export declare type LeadingVisualProps = VisualProps;
|
9
|
+
export declare const LeadingVisual: React.FC<VisualProps>;
|
10
|
+
export declare type TrailingVisualProps = VisualProps;
|
11
|
+
export declare const TrailingVisual: React.FC<VisualProps>;
|
12
|
+
export {};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
import React from 'react';
|
4
|
+
import Box from '../Box';
|
5
|
+
import { get } from '../constants';
|
6
|
+
import { ItemContext, getVariantStyles } from './Item';
|
7
|
+
export const LeadingVisualContainer = ({
|
8
|
+
sx = {},
|
9
|
+
...props
|
10
|
+
}) => {
|
11
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
12
|
+
as: "span",
|
13
|
+
sx: {
|
14
|
+
height: '20px',
|
15
|
+
// match height of text row
|
16
|
+
minWidth: get('space.3'),
|
17
|
+
maxWidth: '20px',
|
18
|
+
// square (same as height)
|
19
|
+
display: 'flex',
|
20
|
+
justifyContent: 'center',
|
21
|
+
alignItems: 'center',
|
22
|
+
flexShrink: 0,
|
23
|
+
marginRight: 2,
|
24
|
+
...sx
|
25
|
+
}
|
26
|
+
}, props));
|
27
|
+
};
|
28
|
+
LeadingVisualContainer.displayName = "LeadingVisualContainer";
|
29
|
+
export const LeadingVisual = ({
|
30
|
+
variant,
|
31
|
+
disabled,
|
32
|
+
sx = {},
|
33
|
+
...props
|
34
|
+
}) => {
|
35
|
+
const {
|
36
|
+
registerSlot
|
37
|
+
} = React.useContext(ItemContext);
|
38
|
+
registerSlot('LeadingVisual', /*#__PURE__*/React.createElement(LeadingVisualContainer, _extends({
|
39
|
+
sx: {
|
40
|
+
color: getVariantStyles(variant, disabled).iconColor,
|
41
|
+
svg: {
|
42
|
+
fontSize: 0
|
43
|
+
},
|
44
|
+
...sx
|
45
|
+
}
|
46
|
+
}, props), props.children));
|
47
|
+
return null;
|
48
|
+
};
|
49
|
+
export const TrailingVisual = ({
|
50
|
+
variant,
|
51
|
+
disabled,
|
52
|
+
...props
|
53
|
+
}) => {
|
54
|
+
const {
|
55
|
+
registerSlot
|
56
|
+
} = React.useContext(ItemContext);
|
57
|
+
registerSlot('TrailingVisual', /*#__PURE__*/React.createElement(Box, _extends({
|
58
|
+
as: "span",
|
59
|
+
sx: {
|
60
|
+
height: '20px',
|
61
|
+
// match height of text row
|
62
|
+
flexShrink: 0,
|
63
|
+
color: getVariantStyles(variant, disabled).annotationColor,
|
64
|
+
marginLeft: 2
|
65
|
+
}
|
66
|
+
}, props), props.children));
|
67
|
+
return null;
|
68
|
+
};
|