@primer/components 0.0.0-202191502023 → 0.0.0-202191514518
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/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 +52 -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-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 +52 -0
- package/lib-esm/ActionList2/Item.js +184 -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/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# @primer/components
|
2
2
|
|
3
|
-
## 0.0.0-
|
3
|
+
## 0.0.0-202191514518
|
4
4
|
|
5
5
|
### Major Changes
|
6
6
|
|
7
|
-
- [#1514](https://github.com/primer/react/pull/1514) [`
|
7
|
+
- [#1514](https://github.com/primer/react/pull/1514) [`dc789025`](https://github.com/primer/react/commit/dc789025d4976e2f0863e1f377c4a834aab88e3a) Thanks [@colebemis](https://github.com/colebemis)! - Remove deprecated color variables by upgrading to @primer/primitives [v5](https://github.com/primer/primitives/pull/251)
|
8
8
|
|
9
9
|
**Note:** Install [`eslint-plugin-primer-react`](https://primer.style/react/linting) to ensure that you're not using any deprecated or removed color variables.
|
10
10
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Description = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _Truncate = _interopRequireDefault(require("../Truncate"));
|
13
|
+
|
14
|
+
var _Item = require("./Item");
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
const Description = ({
|
19
|
+
variant = 'inline',
|
20
|
+
...props
|
21
|
+
}) => {
|
22
|
+
const {
|
23
|
+
registerSlot
|
24
|
+
} = _react.default.useContext(_Item.ItemContext);
|
25
|
+
|
26
|
+
const slotName = variant === 'block' ? 'BlockDescription' : 'InlineDescription';
|
27
|
+
const styles = {
|
28
|
+
color: 'fg.muted',
|
29
|
+
fontSize: 0,
|
30
|
+
lineHeight: '16px',
|
31
|
+
flexGrow: 1,
|
32
|
+
flexBasis: 0,
|
33
|
+
minWidth: 0,
|
34
|
+
marginLeft: variant === 'block' ? 0 : 2
|
35
|
+
};
|
36
|
+
|
37
|
+
if (variant === 'block') {
|
38
|
+
registerSlot(slotName, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
39
|
+
as: "span",
|
40
|
+
sx: styles
|
41
|
+
}, props.children));
|
42
|
+
} else {
|
43
|
+
registerSlot(slotName, /*#__PURE__*/_react.default.createElement(_Truncate.default, {
|
44
|
+
sx: styles,
|
45
|
+
title: props.children,
|
46
|
+
inline: true,
|
47
|
+
maxWidth: "100%"
|
48
|
+
}, props.children));
|
49
|
+
}
|
50
|
+
|
51
|
+
return null;
|
52
|
+
};
|
53
|
+
|
54
|
+
exports.Description = Description;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Divider = Divider;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _constants = require("../constants");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
18
|
+
*/
|
19
|
+
function Divider() {
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
21
|
+
as: "hr",
|
22
|
+
sx: {
|
23
|
+
border: 'none',
|
24
|
+
// override browser styles
|
25
|
+
height: 1,
|
26
|
+
backgroundColor: 'border.muted',
|
27
|
+
marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
|
28
|
+
marginBottom: 2
|
29
|
+
},
|
30
|
+
"data-component": "ActionList.Divider"
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
Divider.displayName = "Divider";
|
35
|
+
|
36
|
+
/**
|
37
|
+
* `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
|
38
|
+
* so it can be used inline in an `ActionList`’s `items` prop.
|
39
|
+
* In other words, `items={[ActionList.Divider]}` is supported as a concise
|
40
|
+
* alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
|
41
|
+
*/
|
42
|
+
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,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Group = Group;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _Header = require("./Header");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
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); }
|
17
|
+
|
18
|
+
function Group({
|
19
|
+
title,
|
20
|
+
variant,
|
21
|
+
auxiliaryText,
|
22
|
+
sx = {},
|
23
|
+
...props
|
24
|
+
}) {
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
26
|
+
sx: {
|
27
|
+
'&:not(:first-child)': {
|
28
|
+
marginTop: 2
|
29
|
+
},
|
30
|
+
...sx
|
31
|
+
}
|
32
|
+
}, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
|
33
|
+
title: title,
|
34
|
+
variant: variant,
|
35
|
+
auxiliaryText: auxiliaryText
|
36
|
+
}), props.children);
|
37
|
+
}
|
38
|
+
|
39
|
+
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,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Header = Header;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _List = require("./List");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
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); }
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Displays the name and description of a `Group`.
|
20
|
+
*/
|
21
|
+
function Header({
|
22
|
+
variant = 'subtle',
|
23
|
+
title,
|
24
|
+
auxiliaryText,
|
25
|
+
children: _children,
|
26
|
+
sx = {},
|
27
|
+
...props
|
28
|
+
}) {
|
29
|
+
const {
|
30
|
+
variant: listVariant
|
31
|
+
} = _react.default.useContext(_List.ListContext);
|
32
|
+
|
33
|
+
const styles = {
|
34
|
+
paddingY: '6px',
|
35
|
+
paddingX: listVariant === 'full' ? 2 : 3,
|
36
|
+
fontSize: 0,
|
37
|
+
fontWeight: 'bold',
|
38
|
+
color: 'fg.muted',
|
39
|
+
...(variant === 'filled' && {
|
40
|
+
backgroundColor: 'canvas.subtle',
|
41
|
+
marginX: 0,
|
42
|
+
marginBottom: 2,
|
43
|
+
borderTop: '1px solid',
|
44
|
+
borderBottom: '1px solid',
|
45
|
+
borderColor: 'neutral.muted'
|
46
|
+
}),
|
47
|
+
...sx
|
48
|
+
};
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
50
|
+
sx: styles,
|
51
|
+
role: "heading"
|
52
|
+
}, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, "auxiliaryText"));
|
53
|
+
}
|
54
|
+
|
55
|
+
Header.displayName = "Header";
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/**
|
2
|
+
* id, role
|
3
|
+
* text could be non-text
|
4
|
+
* activeDescendantAttribute
|
5
|
+
* deepmerge sx
|
6
|
+
* nicer name for showDivider?
|
7
|
+
* aria-label
|
8
|
+
* aria-describedby
|
9
|
+
* React.FC<Props> doesn't allow id?
|
10
|
+
* truncate description
|
11
|
+
* icon color
|
12
|
+
* disabled checkbox
|
13
|
+
* check height with divider
|
14
|
+
*
|
15
|
+
* use immediate child slot API instead of double render?
|
16
|
+
* change as= li | div based on context of menu or not?
|
17
|
+
* check if everyone accepts sx prop
|
18
|
+
* link example outside of overlay? (details)
|
19
|
+
* if one item has selected, should we give all of them selected without the need to pass prop?
|
20
|
+
* move custom item themes to primitives?
|
21
|
+
* padding: 8 or 6?
|
22
|
+
* ActionList.Selection or ActionList.Item selected?
|
23
|
+
* different size for icon and avatar, range?
|
24
|
+
* minimize number of divs?
|
25
|
+
*/
|
26
|
+
import React from 'react';
|
27
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
28
|
+
import { SxProp } from '../sx';
|
29
|
+
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
|
30
|
+
color: (props: any) => any;
|
31
|
+
iconColor: (props: any) => any;
|
32
|
+
annotationColor: (props: any) => any;
|
33
|
+
} | {
|
34
|
+
color: string;
|
35
|
+
iconColor: string;
|
36
|
+
annotationColor: string;
|
37
|
+
};
|
38
|
+
export declare type ItemProps = {
|
39
|
+
children: React.ReactNode;
|
40
|
+
onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
|
41
|
+
selected?: boolean;
|
42
|
+
variant?: 'default' | 'danger';
|
43
|
+
disabled?: boolean;
|
44
|
+
showDivider?: boolean;
|
45
|
+
} & SxProp;
|
46
|
+
declare type SlotNames = 'LeadingVisual' | 'InlineDescription' | 'BlockDescription' | 'TrailingVisual';
|
47
|
+
declare type ContextProps = {
|
48
|
+
registerSlot: (name: SlotNames, contents: React.ReactNode) => void;
|
49
|
+
};
|
50
|
+
export declare const ItemContext: React.Context<ContextProps>;
|
51
|
+
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
|
52
|
+
export {};
|
@@ -0,0 +1,188 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Item = exports.ItemContext = exports.getVariantStyles = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _ThemeProvider = require("../ThemeProvider");
|
11
|
+
|
12
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
13
|
+
|
14
|
+
var _constants = require("../constants");
|
15
|
+
|
16
|
+
var _List = require("./List");
|
17
|
+
|
18
|
+
var _hacks = require("./hacks");
|
19
|
+
|
20
|
+
var _Selection = require("./Selection");
|
21
|
+
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
+
|
24
|
+
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); }
|
25
|
+
|
26
|
+
const getVariantStyles = (variant, disabled) => {
|
27
|
+
if (disabled) {
|
28
|
+
return {
|
29
|
+
color: (0, _constants.get)('colors.fg.muted'),
|
30
|
+
iconColor: (0, _constants.get)('colors.fg.muted'),
|
31
|
+
annotationColor: (0, _constants.get)('colors.fg.muted')
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
switch (variant) {
|
36
|
+
case 'danger':
|
37
|
+
return {
|
38
|
+
color: 'danger.fg',
|
39
|
+
iconColor: 'danger.fg',
|
40
|
+
annotationColor: 'fg.muted'
|
41
|
+
};
|
42
|
+
|
43
|
+
default:
|
44
|
+
return {
|
45
|
+
color: 'fg.default',
|
46
|
+
iconColor: 'fg.muted',
|
47
|
+
annotationColor: 'fg.muted'
|
48
|
+
};
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
exports.getVariantStyles = getVariantStyles;
|
53
|
+
|
54
|
+
const ItemContext = /*#__PURE__*/_react.default.createContext({
|
55
|
+
registerSlot: () => null
|
56
|
+
});
|
57
|
+
|
58
|
+
exports.ItemContext = ItemContext;
|
59
|
+
|
60
|
+
const Item = /*#__PURE__*/_react.default.forwardRef(({
|
61
|
+
variant = 'default',
|
62
|
+
disabled = false,
|
63
|
+
selected = undefined,
|
64
|
+
showDivider = false,
|
65
|
+
onAction = () => null,
|
66
|
+
sx = {},
|
67
|
+
...props
|
68
|
+
}, forwardedRef) => {
|
69
|
+
const customItemTheme = _hacks.customItemThemes[variant];
|
70
|
+
|
71
|
+
const {
|
72
|
+
variant: listVariant
|
73
|
+
} = _react.default.useContext(_List.ListContext);
|
74
|
+
|
75
|
+
const {
|
76
|
+
theme
|
77
|
+
} = (0, _ThemeProvider.useTheme)();
|
78
|
+
|
79
|
+
const [slots, setSlots] = _react.default.useState({
|
80
|
+
LeadingVisual: null,
|
81
|
+
InlineDescription: null,
|
82
|
+
BlockDescription: null,
|
83
|
+
TrailingVisual: null
|
84
|
+
});
|
85
|
+
|
86
|
+
const registerSlot = (name, contents) => {
|
87
|
+
if (slots[name] === null) setSlots({ ...slots,
|
88
|
+
[name]: contents
|
89
|
+
});
|
90
|
+
};
|
91
|
+
|
92
|
+
const styles = {
|
93
|
+
display: 'flex',
|
94
|
+
paddingX: (0, _constants.get)('space.2'),
|
95
|
+
paddingY: '6px',
|
96
|
+
marginX: listVariant === 'inset' ? (0, _constants.get)('space.2') : 0,
|
97
|
+
minHeight: (0, _constants.get)('space.5'),
|
98
|
+
borderRadius: (0, _constants.get)('radii.2'),
|
99
|
+
transition: 'background 33.333ms linear',
|
100
|
+
color: getVariantStyles(variant, disabled).color,
|
101
|
+
textDecoration: 'none',
|
102
|
+
// for as="a"
|
103
|
+
':not(disabled)': {
|
104
|
+
cursor: 'pointer'
|
105
|
+
},
|
106
|
+
'@media (hover: hover) and (pointer: fine)': {
|
107
|
+
':hover': {
|
108
|
+
backgroundColor: (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.hover, 'inherit')
|
109
|
+
},
|
110
|
+
':focus': {
|
111
|
+
backgroundColor: (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.focus, 'inherit')
|
112
|
+
}
|
113
|
+
},
|
114
|
+
|
115
|
+
/** Divider styles */
|
116
|
+
'[data-component="ActionList.Item--Main"]': {
|
117
|
+
position: 'relative'
|
118
|
+
},
|
119
|
+
'[data-component="ActionList.Item--Main"]::before': {
|
120
|
+
content: '" "',
|
121
|
+
display: 'block',
|
122
|
+
position: 'absolute',
|
123
|
+
width: '100%',
|
124
|
+
top: '-7px',
|
125
|
+
border: '0 solid',
|
126
|
+
borderTopWidth: showDivider ? `1px` : '0',
|
127
|
+
borderColor: 'var(--divider-color, transparent)'
|
128
|
+
},
|
129
|
+
// show between 2 items
|
130
|
+
':not(:first-of-type)': {
|
131
|
+
'--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
|
132
|
+
},
|
133
|
+
// hide divider after dividers & group header
|
134
|
+
'[data-component="ActionList.Divider"] + &': {
|
135
|
+
'--divider-color': 'transparent'
|
136
|
+
},
|
137
|
+
// hide border on current and previous item
|
138
|
+
'&:hover, &:focus': {
|
139
|
+
'--divider-color': 'transparent'
|
140
|
+
},
|
141
|
+
'&:hover + &, &:focus + &': {
|
142
|
+
'--divider-color': 'transparent'
|
143
|
+
},
|
144
|
+
...sx
|
145
|
+
};
|
146
|
+
|
147
|
+
const clickHandler = _react.default.useCallback(event => {
|
148
|
+
if (disabled) return;
|
149
|
+
if (!event.defaultPrevented) onAction(event);
|
150
|
+
}, [onAction, disabled]);
|
151
|
+
|
152
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
153
|
+
as: "li",
|
154
|
+
sx: styles,
|
155
|
+
"data-component": "ActionList.Item",
|
156
|
+
onClick: clickHandler,
|
157
|
+
ref: forwardedRef
|
158
|
+
}, props), /*#__PURE__*/_react.default.createElement(ItemContext.Provider, {
|
159
|
+
value: {
|
160
|
+
registerSlot
|
161
|
+
}
|
162
|
+
}, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
|
163
|
+
selected: selected,
|
164
|
+
disabled: disabled
|
165
|
+
}), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
166
|
+
"data-component": "ActionList.Item--Main",
|
167
|
+
sx: {
|
168
|
+
display: 'flex',
|
169
|
+
flexDirection: 'column',
|
170
|
+
flexGrow: 1,
|
171
|
+
minWidth: 0
|
172
|
+
}
|
173
|
+
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
174
|
+
sx: {
|
175
|
+
display: 'flex'
|
176
|
+
}
|
177
|
+
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
178
|
+
sx: {
|
179
|
+
display: 'flex',
|
180
|
+
flexGrow: 1,
|
181
|
+
alignItems: 'baseline',
|
182
|
+
minWidth: 0
|
183
|
+
}
|
184
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
|
185
|
+
});
|
186
|
+
|
187
|
+
exports.Item = Item;
|
188
|
+
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,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.List = exports.ListContext = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _constants = require("../constants");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
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); }
|
17
|
+
|
18
|
+
const ListContext = /*#__PURE__*/_react.default.createContext({});
|
19
|
+
|
20
|
+
exports.ListContext = ListContext;
|
21
|
+
|
22
|
+
const List = /*#__PURE__*/_react.default.forwardRef(({
|
23
|
+
variant = 'inset',
|
24
|
+
selectionVariant = 'single',
|
25
|
+
sx = {},
|
26
|
+
...props
|
27
|
+
}, forwardedRef) => {
|
28
|
+
const styles = {
|
29
|
+
margin: 0,
|
30
|
+
fontSize: (0, _constants.get)('fontSizes.1'),
|
31
|
+
lineHeight: '20px',
|
32
|
+
// TODO: check if we replace this already
|
33
|
+
paddingInlineStart: 0,
|
34
|
+
// reset ul styles
|
35
|
+
paddingY: variant === 'inset' ? (0, _constants.get)('space.2') : 0,
|
36
|
+
...sx
|
37
|
+
};
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
39
|
+
as: "ul",
|
40
|
+
sx: styles
|
41
|
+
}, props, {
|
42
|
+
ref: forwardedRef
|
43
|
+
}), /*#__PURE__*/_react.default.createElement(ListContext.Provider, {
|
44
|
+
value: {
|
45
|
+
variant,
|
46
|
+
selectionVariant
|
47
|
+
}
|
48
|
+
}, props.children));
|
49
|
+
});
|
50
|
+
|
51
|
+
exports.List = List;
|
52
|
+
List.displayName = 'ActionList';
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Selection = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _octiconsReact = require("@primer/octicons-react");
|
11
|
+
|
12
|
+
var _ThemeProvider = require("../ThemeProvider");
|
13
|
+
|
14
|
+
var _List = require("./List");
|
15
|
+
|
16
|
+
var _Visuals = require("./Visuals");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
const Selection = ({
|
21
|
+
selected,
|
22
|
+
disabled
|
23
|
+
}) => {
|
24
|
+
const {
|
25
|
+
selectionVariant
|
26
|
+
} = _react.default.useContext(_List.ListContext);
|
27
|
+
|
28
|
+
const {
|
29
|
+
theme
|
30
|
+
} = (0, _ThemeProvider.useTheme)();
|
31
|
+
if (typeof selected === 'undefined') return null;
|
32
|
+
|
33
|
+
if (selectionVariant === 'single') {
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, {
|
35
|
+
fill: theme === null || theme === void 0 ? void 0 : theme.colors.text.primary
|
36
|
+
}));
|
37
|
+
}
|
38
|
+
|
39
|
+
if (selectionVariant === 'multiple') {
|
40
|
+
/**
|
41
|
+
* readOnly is required because we are doing a one-way bind to `checked`
|
42
|
+
* aria-readonly="false" tells screen that they can still interact with the checkbox
|
43
|
+
* TODO: not sure if disabled & aria-label be here or should we apply it on the instance as props
|
44
|
+
* TODO: aria-label should come from the text part of the slot
|
45
|
+
*/
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, {
|
47
|
+
sx: {
|
48
|
+
input: {
|
49
|
+
margin: 0,
|
50
|
+
pointerEvents: 'none'
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
54
|
+
type: "checkbox",
|
55
|
+
checked: selected,
|
56
|
+
disabled: disabled,
|
57
|
+
"aria-label": "TODO",
|
58
|
+
tabIndex: -1,
|
59
|
+
readOnly: true,
|
60
|
+
"aria-readonly": "false"
|
61
|
+
}));
|
62
|
+
}
|
63
|
+
|
64
|
+
return null;
|
65
|
+
};
|
66
|
+
|
67
|
+
exports.Selection = Selection;
|
@@ -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 {};
|