@primer/components 0.0.0-20219283497 → 0.0.0-2021929114541
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 +17 -1
- package/dist/browser.esm.js +447 -440
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +446 -439
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Description.d.ts +6 -0
- package/lib/ActionList2/Description.js +53 -0
- package/lib/ActionList2/Divider.d.ts +5 -0
- package/lib/ActionList2/Divider.js +33 -0
- package/lib/ActionList2/Group.d.ts +11 -0
- package/lib/ActionList2/Group.js +55 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Item.d.ts +48 -0
- package/lib/ActionList2/Item.js +204 -0
- package/lib/ActionList2/List.d.ts +26 -0
- package/lib/ActionList2/List.js +56 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +73 -0
- package/lib/ActionList2/Visuals.d.ts +11 -0
- package/lib/ActionList2/Visuals.js +90 -0
- package/lib/ActionList2/hacks.d.ts +30 -0
- package/lib/ActionList2/hacks.js +38 -0
- package/lib/ActionList2/index.d.ts +28 -0
- package/lib/ActionList2/index.js +42 -0
- package/lib/ActionMenu.js +2 -2
- package/lib/Autocomplete/Autocomplete.d.ts +11 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +11 -11
- package/lib/Button/Button.d.ts +13 -13
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +16 -16
- package/lib/Button/ButtonDanger.d.ts +13 -13
- package/lib/Button/ButtonInvisible.d.ts +13 -13
- package/lib/Button/ButtonOutline.d.ts +13 -13
- package/lib/Button/ButtonPrimary.d.ts +13 -13
- package/lib/Button/ButtonStyles.js +1 -1
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +19 -19
- package/lib/Dialog/Dialog.d.ts +4 -4
- package/lib/Dialog/Dialog.js +22 -12
- package/lib/Dialog.d.ts +21 -21
- package/lib/Dropdown.d.ts +141 -63
- package/lib/Dropdown.js +5 -6
- package/lib/DropdownMenu/DropdownButton.d.ts +18 -18
- package/lib/FilterList.d.ts +12 -12
- package/lib/Label.d.ts +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +81 -81
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +15 -11
- package/lib/TextInputWithTokens.js +102 -29
- package/lib/Timeline.d.ts +19 -19
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/Token.js +13 -2
- package/lib/Token/TokenBase.js +0 -4
- package/lib/Token/_RemoveTokenButton.js +15 -2
- package/lib/_TextInputWrapper.d.ts +1 -1
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/constants.js +1 -3
- package/lib/experiments.d.ts +1 -0
- package/lib/experiments.js +13 -0
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -8
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +8 -0
- package/lib/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- package/lib/utils/testing.d.ts +1 -1
- package/lib/utils/use-force-update.d.ts +1 -0
- package/lib/utils/use-force-update.js +19 -0
- package/lib-esm/ActionList2/Description.d.ts +6 -0
- package/lib-esm/ActionList2/Description.js +37 -0
- package/lib-esm/ActionList2/Divider.d.ts +5 -0
- package/lib-esm/ActionList2/Divider.js +21 -0
- package/lib-esm/ActionList2/Group.d.ts +11 -0
- package/lib-esm/ActionList2/Group.js +38 -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 +48 -0
- package/lib-esm/ActionList2/Item.js +176 -0
- package/lib-esm/ActionList2/List.d.ts +26 -0
- package/lib-esm/ActionList2/List.js +38 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +55 -0
- package/lib-esm/ActionList2/Visuals.d.ts +11 -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 +28 -0
- package/lib-esm/ActionList2/index.js +29 -0
- package/lib-esm/ActionMenu.js +2 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +11 -11
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +11 -11
- package/lib-esm/Button/Button.d.ts +13 -13
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +16 -16
- package/lib-esm/Button/ButtonDanger.d.ts +13 -13
- package/lib-esm/Button/ButtonInvisible.d.ts +13 -13
- package/lib-esm/Button/ButtonOutline.d.ts +13 -13
- package/lib-esm/Button/ButtonPrimary.d.ts +13 -13
- package/lib-esm/Button/ButtonStyles.js +1 -1
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +19 -19
- package/lib-esm/Dialog/Dialog.d.ts +4 -4
- package/lib-esm/Dialog/Dialog.js +21 -12
- package/lib-esm/Dialog.d.ts +21 -21
- package/lib-esm/Dropdown.d.ts +141 -63
- package/lib-esm/Dropdown.js +3 -4
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +18 -18
- package/lib-esm/FilterList.d.ts +12 -12
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +81 -81
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +15 -11
- package/lib-esm/TextInputWithTokens.js +101 -30
- package/lib-esm/Timeline.d.ts +19 -19
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Token/Token.js +13 -2
- package/lib-esm/Token/TokenBase.js +0 -4
- package/lib-esm/Token/_RemoveTokenButton.js +11 -2
- package/lib-esm/_TextInputWrapper.d.ts +1 -1
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/constants.js +1 -3
- package/lib-esm/experiments.d.ts +1 -0
- package/lib-esm/experiments.js +2 -0
- package/lib-esm/index.d.ts +0 -2
- package/lib-esm/index.js +0 -1
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/testing.d.ts +1 -1
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/package.json +2 -1
- package/lib/NewButton/button.d.ts +0 -581
- package/lib/NewButton/button.js +0 -297
- package/lib/NewButton/counter.d.ts +0 -6
- package/lib/NewButton/counter.js +0 -33
- package/lib/NewButton/index.d.ts +0 -4
- package/lib/NewButton/index.js +0 -21
- package/lib-esm/NewButton/button.d.ts +0 -581
- package/lib-esm/NewButton/button.js +0 -273
- package/lib-esm/NewButton/counter.d.ts +0 -6
- package/lib-esm/NewButton/counter.js +0 -21
- package/lib-esm/NewButton/index.d.ts +0 -4
- package/lib-esm/NewButton/index.js +0 -3
@@ -0,0 +1,53 @@
|
|
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 _sx = require("../sx");
|
13
|
+
|
14
|
+
var _Truncate = _interopRequireDefault(require("../Truncate"));
|
15
|
+
|
16
|
+
var _Item = require("./Item");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
const Description = ({
|
21
|
+
variant = 'inline',
|
22
|
+
sx = {},
|
23
|
+
...props
|
24
|
+
}) => {
|
25
|
+
const styles = {
|
26
|
+
color: 'fg.muted',
|
27
|
+
fontSize: 0,
|
28
|
+
lineHeight: '16px',
|
29
|
+
flexGrow: 1,
|
30
|
+
flexBasis: 0,
|
31
|
+
minWidth: 0,
|
32
|
+
marginLeft: variant === 'block' ? 0 : 2
|
33
|
+
};
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
|
35
|
+
name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
|
36
|
+
}, ({
|
37
|
+
blockDescriptionId,
|
38
|
+
inlineDescriptionId
|
39
|
+
}) => variant === 'block' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
|
40
|
+
as: "span",
|
41
|
+
sx: (0, _sx.merge)(styles, sx),
|
42
|
+
id: blockDescriptionId
|
43
|
+
}, props.children) : /*#__PURE__*/_react.default.createElement(_Truncate.default, {
|
44
|
+
id: inlineDescriptionId,
|
45
|
+
sx: (0, _sx.merge)(styles, sx),
|
46
|
+
title: props.children,
|
47
|
+
inline: true,
|
48
|
+
maxWidth: "100%"
|
49
|
+
}, props.children));
|
50
|
+
};
|
51
|
+
|
52
|
+
exports.Description = Description;
|
53
|
+
Description.displayName = "Description";
|
@@ -0,0 +1,33 @@
|
|
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: "li",
|
22
|
+
role: "separator",
|
23
|
+
sx: {
|
24
|
+
height: 1,
|
25
|
+
backgroundColor: 'border.muted',
|
26
|
+
marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
|
27
|
+
marginBottom: 2
|
28
|
+
},
|
29
|
+
"data-component": "ActionList.Divider"
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
Divider.displayName = "Divider";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
3
|
+
import { HeaderProps } from './Header';
|
4
|
+
import { ListProps } from './List';
|
5
|
+
export declare type GroupProps = HeaderProps & SxProp & {
|
6
|
+
selectionVariant?: ListProps['selectionVariant'] | false;
|
7
|
+
};
|
8
|
+
declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
|
9
|
+
export declare const GroupContext: React.Context<ContextProps>;
|
10
|
+
export declare const Group: React.FC<GroupProps>;
|
11
|
+
export {};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Group = exports.GroupContext = void 0;
|
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
|
+
const GroupContext = /*#__PURE__*/_react.default.createContext({});
|
19
|
+
|
20
|
+
exports.GroupContext = GroupContext;
|
21
|
+
|
22
|
+
const Group = ({
|
23
|
+
title,
|
24
|
+
variant,
|
25
|
+
auxiliaryText,
|
26
|
+
selectionVariant,
|
27
|
+
sx = {},
|
28
|
+
...props
|
29
|
+
}) => {
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
31
|
+
as: "li",
|
32
|
+
sx: {
|
33
|
+
'&:not(:first-child)': {
|
34
|
+
marginTop: 2
|
35
|
+
},
|
36
|
+
...sx
|
37
|
+
}
|
38
|
+
}, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
|
39
|
+
title: title,
|
40
|
+
variant: variant,
|
41
|
+
auxiliaryText: auxiliaryText
|
42
|
+
}), /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
|
43
|
+
value: {
|
44
|
+
selectionVariant
|
45
|
+
}
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
47
|
+
as: "ul",
|
48
|
+
sx: {
|
49
|
+
paddingInlineStart: 0
|
50
|
+
}
|
51
|
+
}, props.children)));
|
52
|
+
};
|
53
|
+
|
54
|
+
exports.Group = Group;
|
55
|
+
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,48 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
3
|
+
import { SxProp } from '../sx';
|
4
|
+
import { AriaRole } from '../utils/types';
|
5
|
+
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
|
6
|
+
color: string;
|
7
|
+
iconColor: string;
|
8
|
+
annotationColor: string;
|
9
|
+
};
|
10
|
+
export declare type ItemProps = {
|
11
|
+
/**
|
12
|
+
* Primary content for an Item
|
13
|
+
*/
|
14
|
+
children: React.ReactNode;
|
15
|
+
/**
|
16
|
+
* Callback that will trigger both on click selection and keyboard selection.
|
17
|
+
*/
|
18
|
+
onSelect?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
|
19
|
+
/**
|
20
|
+
* Is the `Item` is currently selected?
|
21
|
+
*/
|
22
|
+
selected?: boolean;
|
23
|
+
/**
|
24
|
+
* Style variations associated with various `Item` types.
|
25
|
+
*
|
26
|
+
* - `"default"` - An action `Item`.
|
27
|
+
* - `"danger"` - A destructive action `Item`.
|
28
|
+
*/
|
29
|
+
variant?: 'default' | 'danger';
|
30
|
+
/**
|
31
|
+
* Items that are disabled can not be clicked, selected, or navigated through.
|
32
|
+
*/
|
33
|
+
disabled?: boolean;
|
34
|
+
/**
|
35
|
+
* The ARIA role describing the function of `Item` component. `option` is a common value. |
|
36
|
+
*/
|
37
|
+
role?: AriaRole;
|
38
|
+
} & SxProp;
|
39
|
+
declare const Slot: React.FC<{
|
40
|
+
name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
|
41
|
+
children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
|
42
|
+
}>;
|
43
|
+
export { Slot };
|
44
|
+
export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
|
45
|
+
inlineDescriptionId: string;
|
46
|
+
blockDescriptionId: string;
|
47
|
+
};
|
48
|
+
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
|
@@ -0,0 +1,204 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Item = exports.Slot = exports.getVariantStyles = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _ssr = require("@react-aria/ssr");
|
11
|
+
|
12
|
+
var _ThemeProvider = require("../ThemeProvider");
|
13
|
+
|
14
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
15
|
+
|
16
|
+
var _constants = require("../constants");
|
17
|
+
|
18
|
+
var _sx = require("../sx");
|
19
|
+
|
20
|
+
var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
|
21
|
+
|
22
|
+
var _List = require("./List");
|
23
|
+
|
24
|
+
var _hacks = require("./hacks");
|
25
|
+
|
26
|
+
var _Selection = require("./Selection");
|
27
|
+
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
|
+
|
30
|
+
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); }
|
31
|
+
|
32
|
+
const getVariantStyles = (variant, disabled) => {
|
33
|
+
if (disabled) {
|
34
|
+
return {
|
35
|
+
color: 'fg.muted',
|
36
|
+
iconColor: 'fg.muted',
|
37
|
+
annotationColor: 'fg.muted'
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
switch (variant) {
|
42
|
+
case 'danger':
|
43
|
+
return {
|
44
|
+
color: 'danger.fg',
|
45
|
+
iconColor: 'danger.fg',
|
46
|
+
annotationColor: 'fg.muted'
|
47
|
+
};
|
48
|
+
|
49
|
+
default:
|
50
|
+
return {
|
51
|
+
color: 'fg.default',
|
52
|
+
iconColor: 'fg.muted',
|
53
|
+
annotationColor: 'fg.muted'
|
54
|
+
};
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
exports.getVariantStyles = getVariantStyles;
|
59
|
+
const {
|
60
|
+
Slots,
|
61
|
+
Slot
|
62
|
+
} = (0, _createSlots.default)(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
|
63
|
+
exports.Slot = Slot;
|
64
|
+
|
65
|
+
const Item = /*#__PURE__*/_react.default.forwardRef(({
|
66
|
+
variant = 'default',
|
67
|
+
disabled = false,
|
68
|
+
selected = undefined,
|
69
|
+
onSelect = () => null,
|
70
|
+
sx = {},
|
71
|
+
...props
|
72
|
+
}, forwardedRef) => {
|
73
|
+
const customItemTheme = _hacks.customItemThemes[variant];
|
74
|
+
|
75
|
+
const {
|
76
|
+
variant: listVariant,
|
77
|
+
showDividers
|
78
|
+
} = _react.default.useContext(_List.ListContext);
|
79
|
+
|
80
|
+
const {
|
81
|
+
theme
|
82
|
+
} = (0, _ThemeProvider.useTheme)();
|
83
|
+
const styles = {
|
84
|
+
display: 'flex',
|
85
|
+
paddingX: (0, _constants.get)('space.2'),
|
86
|
+
paddingY: '6px',
|
87
|
+
marginX: listVariant === 'inset' ? (0, _constants.get)('space.2') : 0,
|
88
|
+
minHeight: (0, _constants.get)('space.5'),
|
89
|
+
borderRadius: (0, _constants.get)('radii.2'),
|
90
|
+
transition: 'background 33.333ms linear',
|
91
|
+
color: getVariantStyles(variant, disabled).color,
|
92
|
+
textDecoration: 'none',
|
93
|
+
// for as="a"
|
94
|
+
':not([aria-disabled])': {
|
95
|
+
cursor: 'pointer'
|
96
|
+
},
|
97
|
+
'@media (hover: hover) and (pointer: fine)': {
|
98
|
+
':hover:not([aria-disabled])': {
|
99
|
+
backgroundColor: (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.hover, 'inherit')
|
100
|
+
},
|
101
|
+
':focus:not([aria-disabled])': {
|
102
|
+
backgroundColor: (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.focus, 'inherit')
|
103
|
+
}
|
104
|
+
},
|
105
|
+
|
106
|
+
/** Divider styles */
|
107
|
+
'[data-component="ActionList.Item--DividerContainer"]': {
|
108
|
+
position: 'relative'
|
109
|
+
},
|
110
|
+
'[data-component="ActionList.Item--DividerContainer"]::before': {
|
111
|
+
content: '" "',
|
112
|
+
display: 'block',
|
113
|
+
position: 'absolute',
|
114
|
+
width: '100%',
|
115
|
+
top: '-7px',
|
116
|
+
border: '0 solid',
|
117
|
+
borderTopWidth: showDividers ? `1px` : '0',
|
118
|
+
borderColor: 'var(--divider-color, transparent)'
|
119
|
+
},
|
120
|
+
// show between 2 items
|
121
|
+
':not(:first-of-type)': {
|
122
|
+
'--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
|
123
|
+
},
|
124
|
+
// hide divider after dividers & group header
|
125
|
+
'[data-component="ActionList.Divider"] + &': {
|
126
|
+
'--divider-color': 'transparent'
|
127
|
+
},
|
128
|
+
// hide border on current and previous item
|
129
|
+
'&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
|
130
|
+
'--divider-color': 'transparent'
|
131
|
+
},
|
132
|
+
'&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
|
133
|
+
'--divider-color': 'transparent'
|
134
|
+
}
|
135
|
+
};
|
136
|
+
|
137
|
+
const clickHandler = _react.default.useCallback(event => {
|
138
|
+
if (disabled) return;
|
139
|
+
if (!event.defaultPrevented) onSelect(event);
|
140
|
+
}, [onSelect, disabled]);
|
141
|
+
|
142
|
+
const labelId = (0, _ssr.useSSRSafeId)();
|
143
|
+
const inlineDescriptionId = (0, _ssr.useSSRSafeId)();
|
144
|
+
const blockDescriptionId = (0, _ssr.useSSRSafeId)();
|
145
|
+
return /*#__PURE__*/_react.default.createElement(Slots, {
|
146
|
+
context: {
|
147
|
+
variant,
|
148
|
+
disabled,
|
149
|
+
inlineDescriptionId,
|
150
|
+
blockDescriptionId
|
151
|
+
}
|
152
|
+
}, slots => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
153
|
+
as: "li",
|
154
|
+
ref: forwardedRef,
|
155
|
+
sx: (0, _sx.merge)(styles, sx),
|
156
|
+
onClick: clickHandler,
|
157
|
+
"aria-selected": selected,
|
158
|
+
"aria-disabled": disabled ? true : undefined,
|
159
|
+
"aria-labelledby": labelId,
|
160
|
+
"aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
|
161
|
+
}, props), /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
|
162
|
+
selected: selected,
|
163
|
+
disabled: disabled
|
164
|
+
}), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
165
|
+
"data-component": "ActionList.Item--DividerContainer",
|
166
|
+
sx: {
|
167
|
+
display: 'flex',
|
168
|
+
flexDirection: 'column',
|
169
|
+
flexGrow: 1,
|
170
|
+
minWidth: 0
|
171
|
+
}
|
172
|
+
}, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
|
173
|
+
if: Boolean(slots.TrailingVisual),
|
174
|
+
sx: {
|
175
|
+
display: 'flex',
|
176
|
+
flexGrow: 1
|
177
|
+
}
|
178
|
+
}, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
|
179
|
+
if: Boolean(slots.InlineDescription),
|
180
|
+
sx: {
|
181
|
+
display: 'flex',
|
182
|
+
flexGrow: 1,
|
183
|
+
alignItems: 'baseline',
|
184
|
+
minWidth: 0
|
185
|
+
}
|
186
|
+
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
187
|
+
as: "span",
|
188
|
+
id: labelId,
|
189
|
+
sx: {
|
190
|
+
flexGrow: slots.InlineDescription ? 0 : 1
|
191
|
+
}
|
192
|
+
}, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
|
193
|
+
});
|
194
|
+
|
195
|
+
exports.Item = Item;
|
196
|
+
Item.displayName = 'ActionList.Item';
|
197
|
+
|
198
|
+
const ConditionalBox = props => {
|
199
|
+
const {
|
200
|
+
if: condition,
|
201
|
+
...rest
|
202
|
+
} = props;
|
203
|
+
if (condition) return /*#__PURE__*/_react.default.createElement(_Box.default, rest, props.children);else return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
|
204
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
3
|
+
import { SxProp } from '../sx';
|
4
|
+
import { AriaRole } from '../utils/types';
|
5
|
+
export declare type ListProps = {
|
6
|
+
/**
|
7
|
+
* `inset` children are offset (vertically and horizontally) from `List`’s edges, `full` children are flush (vertically and horizontally) with `List` edges
|
8
|
+
*/
|
9
|
+
variant?: 'inset' | 'full';
|
10
|
+
/**
|
11
|
+
* Whether multiple Items or a single Item can be selected.
|
12
|
+
*/
|
13
|
+
selectionVariant?: 'single' | 'multiple';
|
14
|
+
/**
|
15
|
+
* Display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`.
|
16
|
+
*/
|
17
|
+
showDividers?: boolean;
|
18
|
+
/**
|
19
|
+
* The ARIA role describing the function of `List` component. `listbox` or `menu` are a common values.
|
20
|
+
*/
|
21
|
+
role?: AriaRole;
|
22
|
+
} & SxProp;
|
23
|
+
declare type ContextProps = Omit<ListProps, 'sx'>;
|
24
|
+
export declare const ListContext: React.Context<ContextProps>;
|
25
|
+
export declare const List: PolymorphicForwardRefComponent<"ul", ListProps>;
|
26
|
+
export {};
|
@@ -0,0 +1,56 @@
|
|
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
|
+
var _sx = require("../sx");
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
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); }
|
19
|
+
|
20
|
+
const ListContext = /*#__PURE__*/_react.default.createContext({});
|
21
|
+
|
22
|
+
exports.ListContext = ListContext;
|
23
|
+
|
24
|
+
const List = /*#__PURE__*/_react.default.forwardRef(({
|
25
|
+
variant = 'inset',
|
26
|
+
selectionVariant,
|
27
|
+
showDividers = false,
|
28
|
+
sx = {},
|
29
|
+
...props
|
30
|
+
}, forwardedRef) => {
|
31
|
+
const styles = {
|
32
|
+
margin: 0,
|
33
|
+
fontSize: (0, _constants.get)('fontSizes.1'),
|
34
|
+
lineHeight: '20px',
|
35
|
+
// TODO: check if we replace this already
|
36
|
+
paddingInlineStart: 0,
|
37
|
+
// reset ul styles
|
38
|
+
paddingY: variant === 'inset' ? (0, _constants.get)('space.2') : 0
|
39
|
+
};
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
41
|
+
as: "ul",
|
42
|
+
sx: (0, _sx.merge)(styles, sx),
|
43
|
+
"aria-multiselectable": selectionVariant === 'multiple' ? true : undefined
|
44
|
+
}, props, {
|
45
|
+
ref: forwardedRef
|
46
|
+
}), /*#__PURE__*/_react.default.createElement(ListContext.Provider, {
|
47
|
+
value: {
|
48
|
+
variant,
|
49
|
+
selectionVariant,
|
50
|
+
showDividers
|
51
|
+
}
|
52
|
+
}, props.children));
|
53
|
+
});
|
54
|
+
|
55
|
+
exports.List = List;
|
56
|
+
List.displayName = 'ActionList';
|
@@ -0,0 +1,73 @@
|
|
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 _List = require("./List");
|
13
|
+
|
14
|
+
var _Group = require("./Group");
|
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: listSelectionVariant
|
26
|
+
} = _react.default.useContext(_List.ListContext);
|
27
|
+
|
28
|
+
const {
|
29
|
+
selectionVariant: groupSelectionVariant
|
30
|
+
} = _react.default.useContext(_Group.GroupContext);
|
31
|
+
/** selectionVariant in Group can override the selectionVariant in List root */
|
32
|
+
|
33
|
+
|
34
|
+
const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
|
35
|
+
|
36
|
+
if (!selectionVariant) {
|
37
|
+
// to avoid confusion, fail loudly instead of silently ignoring
|
38
|
+
if (selected) throw new Error('For Item to be selected, List needs to have a selectionVariant defined');
|
39
|
+
return null;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (selectionVariant === 'single') {
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, null));
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* selectionVariant is multiple
|
47
|
+
* readOnly is required because we are doing a one-way bind to `checked`
|
48
|
+
* aria-readonly="false" tells screen that they can still interact with the checkbox
|
49
|
+
* TODO: not sure if disabled & aria-label be here or should we apply it on the instance as props
|
50
|
+
* TODO: aria-label should come from the text part of the slot
|
51
|
+
*/
|
52
|
+
|
53
|
+
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, {
|
55
|
+
sx: {
|
56
|
+
input: {
|
57
|
+
margin: 0,
|
58
|
+
pointerEvents: 'none'
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
62
|
+
type: "checkbox",
|
63
|
+
checked: selected,
|
64
|
+
disabled: disabled,
|
65
|
+
"aria-label": "TODO",
|
66
|
+
tabIndex: -1,
|
67
|
+
readOnly: true,
|
68
|
+
"aria-readonly": "false"
|
69
|
+
}));
|
70
|
+
};
|
71
|
+
|
72
|
+
exports.Selection = Selection;
|
73
|
+
Selection.displayName = "Selection";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
3
|
+
declare type VisualProps = SxProp & {
|
4
|
+
children: React.ReactNode;
|
5
|
+
};
|
6
|
+
export declare const LeadingVisualContainer: React.FC<SxProp>;
|
7
|
+
export declare type LeadingVisualProps = VisualProps;
|
8
|
+
export declare const LeadingVisual: React.FC<VisualProps>;
|
9
|
+
export declare type TrailingVisualProps = VisualProps;
|
10
|
+
export declare const TrailingVisual: React.FC<VisualProps>;
|
11
|
+
export {};
|