@primer/components 0.0.0-202192602912 → 0.0.0-2021926114132
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 +4 -8
- package/dist/browser.esm.js +616 -616
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +177 -177
- 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 +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 +49 -0
- package/lib/ActionList2/Item.js +205 -0
- package/lib/ActionList2/List.d.ts +11 -0
- package/lib/ActionList2/List.js +53 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +67 -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 +26 -0
- package/lib/ActionList2/index.js +36 -0
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
- package/lib/Autocomplete/Autocomplete.d.ts +2 -4
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -4
- package/lib/SelectMenu/SelectMenu.d.ts +2 -4
- package/lib/TextInputWithTokens.d.ts +2 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -0
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +8 -0
- package/lib/theme-preval.js +2 -2
- 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 +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 +49 -0
- package/lib-esm/ActionList2/Item.js +198 -0
- package/lib-esm/ActionList2/List.d.ts +11 -0
- package/lib-esm/ActionList2/List.js +35 -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 +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 +26 -0
- package/lib-esm/ActionList2/index.js +23 -0
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -4
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -4
- package/lib-esm/TextInputWithTokens.d.ts +2 -4
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/theme-preval.js +2 -2
- 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 +8 -9
- package/lib/DatePicker/DatePicker.d.ts +0 -48
- package/lib/DatePicker/DatePicker.js +0 -92
- package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
- package/lib/DatePicker/DatePickerAnchor.js +0 -158
- package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
- package/lib/DatePicker/DatePickerOverlay.js +0 -39
- package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
- package/lib/DatePicker/DatePickerPanel.js +0 -126
- package/lib/DatePicker/Day.d.ts +0 -14
- package/lib/DatePicker/Day.js +0 -174
- package/lib/DatePicker/Month.d.ts +0 -9
- package/lib/DatePicker/Month.js +0 -107
- package/lib/DatePicker/index.d.ts +0 -2
- package/lib/DatePicker/index.js +0 -13
- package/lib/DatePicker/useDatePicker.d.ts +0 -83
- package/lib/DatePicker/useDatePicker.js +0 -375
- package/lib/hooks/useDebounce.d.ts +0 -2
- package/lib/hooks/useDebounce.js +0 -24
- package/lib-esm/DatePicker/DatePicker.d.ts +0 -48
- package/lib-esm/DatePicker/DatePicker.js +0 -75
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
- package/lib-esm/DatePicker/DatePickerAnchor.js +0 -132
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
- package/lib-esm/DatePicker/DatePickerOverlay.js +0 -24
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
- package/lib-esm/DatePicker/DatePickerPanel.js +0 -100
- package/lib-esm/DatePicker/Day.d.ts +0 -14
- package/lib-esm/DatePicker/Day.js +0 -151
- package/lib-esm/DatePicker/Month.d.ts +0 -9
- package/lib-esm/DatePicker/Month.js +0 -83
- package/lib-esm/DatePicker/index.d.ts +0 -2
- package/lib-esm/DatePicker/index.js +0 -1
- package/lib-esm/DatePicker/useDatePicker.d.ts +0 -83
- package/lib-esm/DatePicker/useDatePicker.js +0 -347
- package/lib-esm/hooks/useDebounce.d.ts +0 -2
- package/lib-esm/hooks/useDebounce.js +0 -16
@@ -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,49 @@
|
|
1
|
+
/**
|
2
|
+
* minimize number of divs
|
3
|
+
* docs
|
4
|
+
* docs for types
|
5
|
+
* test suite!
|
6
|
+
* ref unhappy with polymorphic
|
7
|
+
*
|
8
|
+
* check height with divider
|
9
|
+
* questions:
|
10
|
+
* nicer name for showDivider?
|
11
|
+
* change as= li | div based on context of menu or not?
|
12
|
+
* should selectionVariant be single by default or nothing. ask for explicit choice?
|
13
|
+
* selection api - if one item has selected, should we give all of them selected without the need to pass prop?
|
14
|
+
* move custom item themes to primitives?
|
15
|
+
* padding: 8 or 6?
|
16
|
+
* different size for icon and avatar, range?
|
17
|
+
* ActionList.Selection or ActionList.Item selected?
|
18
|
+
* aria-describedby empty value bad? also, 2 description = 2 values?
|
19
|
+
*
|
20
|
+
* activeDescendantAttribute (for actionMenu)
|
21
|
+
*/
|
22
|
+
import React from 'react';
|
23
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
24
|
+
import { SxProp } from '../sx';
|
25
|
+
import { AriaRole } from '../utils/types';
|
26
|
+
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
|
27
|
+
color: string;
|
28
|
+
iconColor: string;
|
29
|
+
annotationColor: string;
|
30
|
+
};
|
31
|
+
export declare type ItemProps = {
|
32
|
+
children: React.ReactNode;
|
33
|
+
onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
|
34
|
+
selected?: boolean;
|
35
|
+
variant?: 'default' | 'danger';
|
36
|
+
disabled?: boolean;
|
37
|
+
showDivider?: boolean;
|
38
|
+
role?: AriaRole;
|
39
|
+
} & SxProp;
|
40
|
+
declare const Slot: React.FC<{
|
41
|
+
name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
|
42
|
+
children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
|
43
|
+
}>;
|
44
|
+
export { Slot };
|
45
|
+
export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
|
46
|
+
inlineDescriptionId: string;
|
47
|
+
blockDescriptionId: string;
|
48
|
+
};
|
49
|
+
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
|
@@ -0,0 +1,198 @@
|
|
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
|
+
* minimize number of divs
|
5
|
+
* docs
|
6
|
+
* docs for types
|
7
|
+
* test suite!
|
8
|
+
* ref unhappy with polymorphic
|
9
|
+
*
|
10
|
+
* check height with divider
|
11
|
+
* questions:
|
12
|
+
* nicer name for showDivider?
|
13
|
+
* change as= li | div based on context of menu or not?
|
14
|
+
* should selectionVariant be single by default or nothing. ask for explicit choice?
|
15
|
+
* selection api - if one item has selected, should we give all of them selected without the need to pass prop?
|
16
|
+
* move custom item themes to primitives?
|
17
|
+
* padding: 8 or 6?
|
18
|
+
* different size for icon and avatar, range?
|
19
|
+
* ActionList.Selection or ActionList.Item selected?
|
20
|
+
* aria-describedby empty value bad? also, 2 description = 2 values?
|
21
|
+
*
|
22
|
+
* activeDescendantAttribute (for actionMenu)
|
23
|
+
*/
|
24
|
+
import React from 'react';
|
25
|
+
import { useSSRSafeId } from '@react-aria/ssr';
|
26
|
+
import { useColorSchemeVar, useTheme } from '../ThemeProvider';
|
27
|
+
import Box from '../Box';
|
28
|
+
import { get } from '../constants';
|
29
|
+
import { merge } from '../sx';
|
30
|
+
import createSlots from '../utils/create-slots';
|
31
|
+
import { ListContext } from './List';
|
32
|
+
import { customItemThemes } from './hacks';
|
33
|
+
import { Selection } from './Selection';
|
34
|
+
export const getVariantStyles = (variant, disabled) => {
|
35
|
+
if (disabled) {
|
36
|
+
return {
|
37
|
+
color: 'fg.muted',
|
38
|
+
iconColor: 'fg.muted',
|
39
|
+
annotationColor: 'fg.muted'
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
switch (variant) {
|
44
|
+
case 'danger':
|
45
|
+
return {
|
46
|
+
color: 'danger.fg',
|
47
|
+
iconColor: 'danger.fg',
|
48
|
+
annotationColor: 'fg.muted'
|
49
|
+
};
|
50
|
+
|
51
|
+
default:
|
52
|
+
return {
|
53
|
+
color: 'fg.default',
|
54
|
+
iconColor: 'fg.muted',
|
55
|
+
annotationColor: 'fg.muted'
|
56
|
+
};
|
57
|
+
}
|
58
|
+
};
|
59
|
+
const {
|
60
|
+
Slots,
|
61
|
+
Slot
|
62
|
+
} = createSlots(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
|
63
|
+
export { Slot };
|
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 styles = {
|
81
|
+
display: 'flex',
|
82
|
+
paddingX: get('space.2'),
|
83
|
+
paddingY: '6px',
|
84
|
+
marginX: listVariant === 'inset' ? get('space.2') : 0,
|
85
|
+
minHeight: get('space.5'),
|
86
|
+
borderRadius: get('radii.2'),
|
87
|
+
transition: 'background 33.333ms linear',
|
88
|
+
color: getVariantStyles(variant, disabled).color,
|
89
|
+
textDecoration: 'none',
|
90
|
+
// for as="a"
|
91
|
+
':not([aria-disabled])': {
|
92
|
+
cursor: 'pointer'
|
93
|
+
},
|
94
|
+
'@media (hover: hover) and (pointer: fine)': {
|
95
|
+
':hover:not([aria-disabled])': {
|
96
|
+
backgroundColor: useColorSchemeVar(customItemTheme.hover, 'inherit')
|
97
|
+
},
|
98
|
+
':focus:not([aria-disabled])': {
|
99
|
+
backgroundColor: useColorSchemeVar(customItemTheme.focus, 'inherit')
|
100
|
+
}
|
101
|
+
},
|
102
|
+
|
103
|
+
/** Divider styles */
|
104
|
+
'[data-component="ActionList.Item--DividerContainer"]': {
|
105
|
+
position: 'relative'
|
106
|
+
},
|
107
|
+
'[data-component="ActionList.Item--DividerContainer"]::before': {
|
108
|
+
content: '" "',
|
109
|
+
display: 'block',
|
110
|
+
position: 'absolute',
|
111
|
+
width: '100%',
|
112
|
+
top: '-7px',
|
113
|
+
border: '0 solid',
|
114
|
+
borderTopWidth: showDivider ? `1px` : '0',
|
115
|
+
borderColor: 'var(--divider-color, transparent)'
|
116
|
+
},
|
117
|
+
// show between 2 items
|
118
|
+
':not(:first-of-type)': {
|
119
|
+
'--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
|
120
|
+
},
|
121
|
+
// hide divider after dividers & group header
|
122
|
+
'[data-component="ActionList.Divider"] + &': {
|
123
|
+
'--divider-color': 'transparent'
|
124
|
+
},
|
125
|
+
// hide border on current and previous item
|
126
|
+
'&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
|
127
|
+
'--divider-color': 'transparent'
|
128
|
+
},
|
129
|
+
'&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
|
130
|
+
'--divider-color': 'transparent'
|
131
|
+
}
|
132
|
+
};
|
133
|
+
const clickHandler = React.useCallback(event => {
|
134
|
+
if (disabled) return;
|
135
|
+
if (!event.defaultPrevented) onAction(event);
|
136
|
+
}, [onAction, disabled]);
|
137
|
+
const labelId = useSSRSafeId();
|
138
|
+
const inlineDescriptionId = useSSRSafeId();
|
139
|
+
const blockDescriptionId = useSSRSafeId();
|
140
|
+
return /*#__PURE__*/React.createElement(Slots, {
|
141
|
+
context: {
|
142
|
+
variant,
|
143
|
+
disabled,
|
144
|
+
inlineDescriptionId,
|
145
|
+
blockDescriptionId
|
146
|
+
}
|
147
|
+
}, slots => /*#__PURE__*/React.createElement(Box, _extends({
|
148
|
+
as: "li",
|
149
|
+
ref: forwardedRef,
|
150
|
+
sx: merge(styles, sx),
|
151
|
+
"data-component": "ActionList.Item",
|
152
|
+
onClick: clickHandler,
|
153
|
+
"aria-selected": selected,
|
154
|
+
"aria-disabled": disabled ? true : undefined,
|
155
|
+
"aria-labelledby": labelId,
|
156
|
+
"aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
|
157
|
+
}, props), /*#__PURE__*/React.createElement(Selection, {
|
158
|
+
selected: selected,
|
159
|
+
disabled: disabled
|
160
|
+
}), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
|
161
|
+
"data-component": "ActionList.Item--DividerContainer",
|
162
|
+
sx: {
|
163
|
+
display: 'flex',
|
164
|
+
flexDirection: 'column',
|
165
|
+
flexGrow: 1,
|
166
|
+
minWidth: 0
|
167
|
+
}
|
168
|
+
}, /*#__PURE__*/React.createElement(ConditionalBox, {
|
169
|
+
if: Boolean(slots.TrailingVisual),
|
170
|
+
sx: {
|
171
|
+
display: 'flex',
|
172
|
+
flexGrow: 1
|
173
|
+
}
|
174
|
+
}, /*#__PURE__*/React.createElement(ConditionalBox, {
|
175
|
+
if: Boolean(slots.InlineDescription),
|
176
|
+
sx: {
|
177
|
+
display: 'flex',
|
178
|
+
flexGrow: 1,
|
179
|
+
alignItems: 'baseline',
|
180
|
+
minWidth: 0
|
181
|
+
}
|
182
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
183
|
+
as: "span",
|
184
|
+
id: labelId,
|
185
|
+
sx: {
|
186
|
+
flexGrow: slots.InlineDescription ? 0 : 1
|
187
|
+
}
|
188
|
+
}, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
|
189
|
+
});
|
190
|
+
Item.displayName = 'ActionList.Item';
|
191
|
+
|
192
|
+
const ConditionalBox = props => {
|
193
|
+
const {
|
194
|
+
if: condition,
|
195
|
+
...rest
|
196
|
+
} = props;
|
197
|
+
if (condition) return /*#__PURE__*/React.createElement(Box, rest, props.children);else return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
|
198
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
3
|
+
import { SxProp } from '../sx';
|
4
|
+
export declare type ListProps = {
|
5
|
+
variant?: 'inset' | 'full';
|
6
|
+
selectionVariant?: 'single' | 'multiple';
|
7
|
+
} & SxProp;
|
8
|
+
declare type ContextProps = Pick<ListProps, 'selectionVariant' | 'variant'>;
|
9
|
+
export declare const ListContext: React.Context<ContextProps>;
|
10
|
+
export declare const List: PolymorphicForwardRefComponent<"ul", ListProps>;
|
11
|
+
export {};
|
@@ -0,0 +1,35 @@
|
|
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 { merge } from '../sx';
|
7
|
+
export const ListContext = /*#__PURE__*/React.createContext({});
|
8
|
+
export const List = /*#__PURE__*/React.forwardRef(({
|
9
|
+
variant = 'inset',
|
10
|
+
selectionVariant = 'single',
|
11
|
+
sx = {},
|
12
|
+
...props
|
13
|
+
}, forwardedRef) => {
|
14
|
+
const styles = {
|
15
|
+
margin: 0,
|
16
|
+
fontSize: get('fontSizes.1'),
|
17
|
+
lineHeight: '20px',
|
18
|
+
// TODO: check if we replace this already
|
19
|
+
paddingInlineStart: 0,
|
20
|
+
// reset ul styles
|
21
|
+
paddingY: variant === 'inset' ? get('space.2') : 0
|
22
|
+
};
|
23
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
24
|
+
as: "ul",
|
25
|
+
sx: merge(styles, sx)
|
26
|
+
}, props, {
|
27
|
+
ref: forwardedRef
|
28
|
+
}), /*#__PURE__*/React.createElement(ListContext.Provider, {
|
29
|
+
value: {
|
30
|
+
variant,
|
31
|
+
selectionVariant
|
32
|
+
}
|
33
|
+
}, props.children));
|
34
|
+
});
|
35
|
+
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,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 {};
|
@@ -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 { merge } from '../sx';
|
6
|
+
import { get } from '../constants';
|
7
|
+
import { getVariantStyles, Slot } from './Item';
|
8
|
+
export const LeadingVisualContainer = ({
|
9
|
+
sx = {},
|
10
|
+
...props
|
11
|
+
}) => {
|
12
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
13
|
+
as: "span",
|
14
|
+
sx: merge({
|
15
|
+
height: '20px',
|
16
|
+
// match height of text row
|
17
|
+
minWidth: get('space.3'),
|
18
|
+
maxWidth: '20px',
|
19
|
+
// square (same as height)
|
20
|
+
display: 'flex',
|
21
|
+
justifyContent: 'center',
|
22
|
+
alignItems: 'center',
|
23
|
+
flexShrink: 0,
|
24
|
+
marginRight: 2
|
25
|
+
}, sx)
|
26
|
+
}, props));
|
27
|
+
};
|
28
|
+
LeadingVisualContainer.displayName = "LeadingVisualContainer";
|
29
|
+
export const LeadingVisual = ({
|
30
|
+
sx = {},
|
31
|
+
...props
|
32
|
+
}) => {
|
33
|
+
return /*#__PURE__*/React.createElement(Slot, {
|
34
|
+
name: "LeadingVisual"
|
35
|
+
}, ({
|
36
|
+
variant,
|
37
|
+
disabled
|
38
|
+
}) => /*#__PURE__*/React.createElement(LeadingVisualContainer, _extends({
|
39
|
+
sx: merge({
|
40
|
+
color: getVariantStyles(variant, disabled).iconColor,
|
41
|
+
svg: {
|
42
|
+
fontSize: 0
|
43
|
+
}
|
44
|
+
}, sx)
|
45
|
+
}, props), props.children));
|
46
|
+
};
|
47
|
+
LeadingVisual.displayName = "LeadingVisual";
|
48
|
+
export const TrailingVisual = ({
|
49
|
+
sx = {},
|
50
|
+
...props
|
51
|
+
}) => {
|
52
|
+
return /*#__PURE__*/React.createElement(Slot, {
|
53
|
+
name: "TrailingVisual"
|
54
|
+
}, ({
|
55
|
+
variant,
|
56
|
+
disabled
|
57
|
+
}) => /*#__PURE__*/React.createElement(Box, _extends({
|
58
|
+
as: "span",
|
59
|
+
sx: merge({
|
60
|
+
height: '20px',
|
61
|
+
// match height of text row
|
62
|
+
flexShrink: 0,
|
63
|
+
color: getVariantStyles(variant, disabled).annotationColor,
|
64
|
+
marginLeft: 2
|
65
|
+
}, sx)
|
66
|
+
}, props), props.children));
|
67
|
+
};
|
68
|
+
TrailingVisual.displayName = "TrailingVisual";
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* These colors are not yet in our default theme.
|
3
|
+
* TODO: Need to remove this once they are added.
|
4
|
+
*/
|
5
|
+
export declare const customItemThemes: {
|
6
|
+
default: {
|
7
|
+
hover: {
|
8
|
+
light: string;
|
9
|
+
dark: string;
|
10
|
+
dark_dimmed: string;
|
11
|
+
};
|
12
|
+
focus: {
|
13
|
+
light: string;
|
14
|
+
dark: string;
|
15
|
+
dark_dimmed: string;
|
16
|
+
};
|
17
|
+
};
|
18
|
+
danger: {
|
19
|
+
hover: {
|
20
|
+
light: string;
|
21
|
+
dark: string;
|
22
|
+
dark_dimmed: string;
|
23
|
+
};
|
24
|
+
focus: {
|
25
|
+
light: string;
|
26
|
+
dark: string;
|
27
|
+
dark_dimmed: string;
|
28
|
+
};
|
29
|
+
};
|
30
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* These colors are not yet in our default theme.
|
3
|
+
* TODO: Need to remove this once they are added.
|
4
|
+
*/
|
5
|
+
export const customItemThemes = {
|
6
|
+
default: {
|
7
|
+
hover: {
|
8
|
+
light: 'rgba(46, 77, 108, 0.06)',
|
9
|
+
dark: 'rgba(201, 206, 212, 0.12)',
|
10
|
+
dark_dimmed: 'rgba(201, 206, 212, 0.12)'
|
11
|
+
},
|
12
|
+
focus: {
|
13
|
+
light: 'rgba(54, 77, 100, 0.16)',
|
14
|
+
dark: 'rgba(201, 206, 212, 0.24)',
|
15
|
+
dark_dimmed: 'rgba(201, 206, 212, 0.24)'
|
16
|
+
}
|
17
|
+
},
|
18
|
+
danger: {
|
19
|
+
hover: {
|
20
|
+
light: 'rgba(234, 74, 90, 0.08)',
|
21
|
+
dark: 'rgba(248, 81, 73, 0.16)',
|
22
|
+
dark_dimmed: 'rgba(248, 81, 73, 0.16)'
|
23
|
+
},
|
24
|
+
focus: {
|
25
|
+
light: 'rgba(234, 74, 90, 0.14)',
|
26
|
+
dark: 'rgba(248, 81, 73, 0.24)',
|
27
|
+
dark_dimmed: 'rgba(248, 81, 73, 0.24)'
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { Group } from './Group';
|
3
|
+
import { Divider } from './Divider';
|
4
|
+
export type { ListProps as ActionListProps } from './List';
|
5
|
+
export type { GroupProps } from './Group';
|
6
|
+
export type { ItemProps } from './Item';
|
7
|
+
export type { DescriptionProps } from './Description';
|
8
|
+
export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
|
9
|
+
/**
|
10
|
+
* Collection of list-related components.
|
11
|
+
*/
|
12
|
+
export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
|
13
|
+
/** Collects related `Items` in an `ActionList`. */
|
14
|
+
Group: typeof Group;
|
15
|
+
/** An actionable or selectable `Item` with an optional icon and description. */
|
16
|
+
Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
|
17
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
18
|
+
Divider: typeof Divider;
|
19
|
+
Description: import("react").FC<import("./Description").DescriptionProps>;
|
20
|
+
LeadingVisual: import("react").FC<import("../sx").SxProp & {
|
21
|
+
children: import("react").ReactNode;
|
22
|
+
}>;
|
23
|
+
TrailingVisual: import("react").FC<import("../sx").SxProp & {
|
24
|
+
children: import("react").ReactNode;
|
25
|
+
}>;
|
26
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { List } from './List';
|
2
|
+
import { Group } from './Group';
|
3
|
+
import { Item } from './Item';
|
4
|
+
import { Divider } from './Divider';
|
5
|
+
import { Description } from './Description';
|
6
|
+
import { LeadingVisual, TrailingVisual } from './Visuals';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Collection of list-related components.
|
10
|
+
*/
|
11
|
+
export const ActionList = Object.assign(List, {
|
12
|
+
/** Collects related `Items` in an `ActionList`. */
|
13
|
+
Group,
|
14
|
+
|
15
|
+
/** An actionable or selectable `Item` with an optional icon and description. */
|
16
|
+
Item,
|
17
|
+
|
18
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
19
|
+
Divider,
|
20
|
+
Description,
|
21
|
+
LeadingVisual,
|
22
|
+
TrailingVisual
|
23
|
+
});
|
@@ -26,8 +26,6 @@ interface AnchoredOverlayPropsWithoutAnchor {
|
|
26
26
|
*/
|
27
27
|
anchorRef: React.RefObject<HTMLElement>;
|
28
28
|
}
|
29
|
-
export declare type OverlayOpenGesture = 'anchor-click' | 'anchor-key-press';
|
30
|
-
export declare type OverlayCloseGesture = 'anchor-click' | 'click-outside' | 'escape';
|
31
29
|
export declare type AnchoredOverlayWrapperAnchorProps = Partial<AnchoredOverlayPropsWithAnchor> | AnchoredOverlayPropsWithoutAnchor;
|
32
30
|
interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'> {
|
33
31
|
/**
|
@@ -37,11 +35,11 @@ interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'
|
|
37
35
|
/**
|
38
36
|
* A callback which is called whenever the overlay is currently closed and an "open gesture" is detected.
|
39
37
|
*/
|
40
|
-
onOpen?: (gesture:
|
38
|
+
onOpen?: (gesture: 'anchor-click' | 'anchor-key-press') => unknown;
|
41
39
|
/**
|
42
40
|
* A callback which is called whenever the overlay is currently open and a "close gesture" is detected.
|
43
41
|
*/
|
44
|
-
onClose?: (gesture:
|
42
|
+
onClose?: (gesture: 'anchor-click' | 'click-outside' | 'escape') => unknown;
|
45
43
|
/**
|
46
44
|
* Props to be spread on the internal `Overlay` component.
|
47
45
|
*/
|