@primer/components 0.0.0-2021926104410 → 0.0.0-2021926134544
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 -14
- package/dist/browser.esm.js +610 -610
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +176 -176
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.d.ts +0 -6
- package/lib/ActionList/Item.js +1 -5
- 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 +50 -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/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/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- package/lib/utils/use-force-update.d.ts +1 -0
- package/lib/utils/use-force-update.js +19 -0
- package/lib-esm/ActionList/Item.d.ts +0 -6
- package/lib-esm/ActionList/Item.js +1 -5
- 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 +50 -0
- package/lib-esm/ActionList2/Item.js +199 -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/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/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/package.json +1 -1
@@ -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,50 @@
|
|
1
|
+
/**
|
2
|
+
* selection check color
|
3
|
+
* minimize number of divs
|
4
|
+
* docs
|
5
|
+
* docs for types
|
6
|
+
* test suite!
|
7
|
+
* ref unhappy with polymorphic
|
8
|
+
*
|
9
|
+
* check height with divider
|
10
|
+
* questions:
|
11
|
+
* nicer name for showDivider?
|
12
|
+
* change as= li | div based on context of menu or not?
|
13
|
+
* should selectionVariant be single by default or nothing. ask for explicit choice?
|
14
|
+
* selection api - if one item has selected, should we give all of them selected without the need to pass prop?
|
15
|
+
* move custom item themes to primitives?
|
16
|
+
* padding: 8 or 6?
|
17
|
+
* different size for icon and avatar, range?
|
18
|
+
* ActionList.Selection or ActionList.Item selected?
|
19
|
+
* aria-describedby empty value bad? also, 2 description = 2 values?
|
20
|
+
*
|
21
|
+
* activeDescendantAttribute (for actionMenu)
|
22
|
+
*/
|
23
|
+
import React from 'react';
|
24
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
25
|
+
import { SxProp } from '../sx';
|
26
|
+
import { AriaRole } from '../utils/types';
|
27
|
+
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
|
28
|
+
color: string;
|
29
|
+
iconColor: string;
|
30
|
+
annotationColor: string;
|
31
|
+
};
|
32
|
+
export declare type ItemProps = {
|
33
|
+
children: React.ReactNode;
|
34
|
+
onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
|
35
|
+
selected?: boolean;
|
36
|
+
variant?: 'default' | 'danger';
|
37
|
+
disabled?: boolean;
|
38
|
+
showDivider?: boolean;
|
39
|
+
role?: AriaRole;
|
40
|
+
} & SxProp;
|
41
|
+
declare const Slot: React.FC<{
|
42
|
+
name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
|
43
|
+
children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
|
44
|
+
}>;
|
45
|
+
export { Slot };
|
46
|
+
export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
|
47
|
+
inlineDescriptionId: string;
|
48
|
+
blockDescriptionId: string;
|
49
|
+
};
|
50
|
+
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
|
@@ -0,0 +1,199 @@
|
|
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
|
+
* selection check color
|
5
|
+
* minimize number of divs
|
6
|
+
* docs
|
7
|
+
* docs for types
|
8
|
+
* test suite!
|
9
|
+
* ref unhappy with polymorphic
|
10
|
+
*
|
11
|
+
* check height with divider
|
12
|
+
* questions:
|
13
|
+
* nicer name for showDivider?
|
14
|
+
* change as= li | div based on context of menu or not?
|
15
|
+
* should selectionVariant be single by default or nothing. ask for explicit choice?
|
16
|
+
* selection api - if one item has selected, should we give all of them selected without the need to pass prop?
|
17
|
+
* move custom item themes to primitives?
|
18
|
+
* padding: 8 or 6?
|
19
|
+
* different size for icon and avatar, range?
|
20
|
+
* ActionList.Selection or ActionList.Item selected?
|
21
|
+
* aria-describedby empty value bad? also, 2 description = 2 values?
|
22
|
+
*
|
23
|
+
* activeDescendantAttribute (for actionMenu)
|
24
|
+
*/
|
25
|
+
import React from 'react';
|
26
|
+
import { useSSRSafeId } from '@react-aria/ssr';
|
27
|
+
import { useColorSchemeVar, useTheme } from '../ThemeProvider';
|
28
|
+
import Box from '../Box';
|
29
|
+
import { get } from '../constants';
|
30
|
+
import { merge } from '../sx';
|
31
|
+
import createSlots from '../utils/create-slots';
|
32
|
+
import { ListContext } from './List';
|
33
|
+
import { customItemThemes } from './hacks';
|
34
|
+
import { Selection } from './Selection';
|
35
|
+
export const getVariantStyles = (variant, disabled) => {
|
36
|
+
if (disabled) {
|
37
|
+
return {
|
38
|
+
color: 'fg.muted',
|
39
|
+
iconColor: 'fg.muted',
|
40
|
+
annotationColor: 'fg.muted'
|
41
|
+
};
|
42
|
+
}
|
43
|
+
|
44
|
+
switch (variant) {
|
45
|
+
case 'danger':
|
46
|
+
return {
|
47
|
+
color: 'danger.fg',
|
48
|
+
iconColor: 'danger.fg',
|
49
|
+
annotationColor: 'fg.muted'
|
50
|
+
};
|
51
|
+
|
52
|
+
default:
|
53
|
+
return {
|
54
|
+
color: 'fg.default',
|
55
|
+
iconColor: 'fg.muted',
|
56
|
+
annotationColor: 'fg.muted'
|
57
|
+
};
|
58
|
+
}
|
59
|
+
};
|
60
|
+
const {
|
61
|
+
Slots,
|
62
|
+
Slot
|
63
|
+
} = createSlots(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
|
64
|
+
export { Slot };
|
65
|
+
export const Item = /*#__PURE__*/React.forwardRef(({
|
66
|
+
variant = 'default',
|
67
|
+
disabled = false,
|
68
|
+
selected = undefined,
|
69
|
+
showDivider = false,
|
70
|
+
onAction = () => null,
|
71
|
+
sx = {},
|
72
|
+
...props
|
73
|
+
}, forwardedRef) => {
|
74
|
+
const customItemTheme = customItemThemes[variant];
|
75
|
+
const {
|
76
|
+
variant: listVariant
|
77
|
+
} = React.useContext(ListContext);
|
78
|
+
const {
|
79
|
+
theme
|
80
|
+
} = useTheme();
|
81
|
+
const styles = {
|
82
|
+
display: 'flex',
|
83
|
+
paddingX: get('space.2'),
|
84
|
+
paddingY: '6px',
|
85
|
+
marginX: listVariant === 'inset' ? get('space.2') : 0,
|
86
|
+
minHeight: get('space.5'),
|
87
|
+
borderRadius: get('radii.2'),
|
88
|
+
transition: 'background 33.333ms linear',
|
89
|
+
color: getVariantStyles(variant, disabled).color,
|
90
|
+
textDecoration: 'none',
|
91
|
+
// for as="a"
|
92
|
+
':not([aria-disabled])': {
|
93
|
+
cursor: 'pointer'
|
94
|
+
},
|
95
|
+
'@media (hover: hover) and (pointer: fine)': {
|
96
|
+
':hover:not([aria-disabled])': {
|
97
|
+
backgroundColor: useColorSchemeVar(customItemTheme.hover, 'inherit')
|
98
|
+
},
|
99
|
+
':focus:not([aria-disabled])': {
|
100
|
+
backgroundColor: useColorSchemeVar(customItemTheme.focus, 'inherit')
|
101
|
+
}
|
102
|
+
},
|
103
|
+
|
104
|
+
/** Divider styles */
|
105
|
+
'[data-component="ActionList.Item--DividerContainer"]': {
|
106
|
+
position: 'relative'
|
107
|
+
},
|
108
|
+
'[data-component="ActionList.Item--DividerContainer"]::before': {
|
109
|
+
content: '" "',
|
110
|
+
display: 'block',
|
111
|
+
position: 'absolute',
|
112
|
+
width: '100%',
|
113
|
+
top: '-7px',
|
114
|
+
border: '0 solid',
|
115
|
+
borderTopWidth: showDivider ? `1px` : '0',
|
116
|
+
borderColor: 'var(--divider-color, transparent)'
|
117
|
+
},
|
118
|
+
// show between 2 items
|
119
|
+
':not(:first-of-type)': {
|
120
|
+
'--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
|
121
|
+
},
|
122
|
+
// hide divider after dividers & group header
|
123
|
+
'[data-component="ActionList.Divider"] + &': {
|
124
|
+
'--divider-color': 'transparent'
|
125
|
+
},
|
126
|
+
// hide border on current and previous item
|
127
|
+
'&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
|
128
|
+
'--divider-color': 'transparent'
|
129
|
+
},
|
130
|
+
'&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
|
131
|
+
'--divider-color': 'transparent'
|
132
|
+
}
|
133
|
+
};
|
134
|
+
const clickHandler = React.useCallback(event => {
|
135
|
+
if (disabled) return;
|
136
|
+
if (!event.defaultPrevented) onAction(event);
|
137
|
+
}, [onAction, disabled]);
|
138
|
+
const labelId = useSSRSafeId();
|
139
|
+
const inlineDescriptionId = useSSRSafeId();
|
140
|
+
const blockDescriptionId = useSSRSafeId();
|
141
|
+
return /*#__PURE__*/React.createElement(Slots, {
|
142
|
+
context: {
|
143
|
+
variant,
|
144
|
+
disabled,
|
145
|
+
inlineDescriptionId,
|
146
|
+
blockDescriptionId
|
147
|
+
}
|
148
|
+
}, slots => /*#__PURE__*/React.createElement(Box, _extends({
|
149
|
+
as: "li",
|
150
|
+
ref: forwardedRef,
|
151
|
+
sx: merge(styles, sx),
|
152
|
+
"data-component": "ActionList.Item",
|
153
|
+
onClick: clickHandler,
|
154
|
+
"aria-selected": selected,
|
155
|
+
"aria-disabled": disabled ? true : undefined,
|
156
|
+
"aria-labelledby": labelId,
|
157
|
+
"aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
|
158
|
+
}, props), /*#__PURE__*/React.createElement(Selection, {
|
159
|
+
selected: selected,
|
160
|
+
disabled: disabled
|
161
|
+
}), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
|
162
|
+
"data-component": "ActionList.Item--DividerContainer",
|
163
|
+
sx: {
|
164
|
+
display: 'flex',
|
165
|
+
flexDirection: 'column',
|
166
|
+
flexGrow: 1,
|
167
|
+
minWidth: 0
|
168
|
+
}
|
169
|
+
}, /*#__PURE__*/React.createElement(ConditionalBox, {
|
170
|
+
if: Boolean(slots.TrailingVisual),
|
171
|
+
sx: {
|
172
|
+
display: 'flex',
|
173
|
+
flexGrow: 1
|
174
|
+
}
|
175
|
+
}, /*#__PURE__*/React.createElement(ConditionalBox, {
|
176
|
+
if: Boolean(slots.InlineDescription),
|
177
|
+
sx: {
|
178
|
+
display: 'flex',
|
179
|
+
flexGrow: 1,
|
180
|
+
alignItems: 'baseline',
|
181
|
+
minWidth: 0
|
182
|
+
}
|
183
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
184
|
+
as: "span",
|
185
|
+
id: labelId,
|
186
|
+
sx: {
|
187
|
+
flexGrow: slots.InlineDescription ? 0 : 1
|
188
|
+
}
|
189
|
+
}, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
|
190
|
+
});
|
191
|
+
Item.displayName = 'ActionList.Item';
|
192
|
+
|
193
|
+
const ConditionalBox = props => {
|
194
|
+
const {
|
195
|
+
if: condition,
|
196
|
+
...rest
|
197
|
+
} = props;
|
198
|
+
if (condition) return /*#__PURE__*/React.createElement(Box, rest, props.children);else return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
|
199
|
+
};
|
@@ -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: "fg.muted"
|
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
|
+
});
|
package/lib-esm/index.d.ts
CHANGED
@@ -22,6 +22,7 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
|
|
22
22
|
export { useOverlay } from './hooks/useOverlay';
|
23
23
|
export { useConfirm } from './Dialog/ConfirmationDialog';
|
24
24
|
export { ActionList } from './ActionList';
|
25
|
+
export { ActionList as ActionList2 } from './ActionList2';
|
25
26
|
export { ActionMenu } from './ActionMenu';
|
26
27
|
export type { ActionMenuProps } from './ActionMenu';
|
27
28
|
export { default as Autocomplete } from './Autocomplete';
|
package/lib-esm/index.js
CHANGED
@@ -18,6 +18,7 @@ export { useOverlay } from './hooks/useOverlay';
|
|
18
18
|
export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
|
19
19
|
|
20
20
|
export { ActionList } from './ActionList';
|
21
|
+
export { ActionList as ActionList2 } from './ActionList2';
|
21
22
|
export { ActionMenu } from './ActionMenu';
|
22
23
|
export { default as Autocomplete } from './Autocomplete';
|
23
24
|
export { default as Avatar } from './Avatar';
|
package/lib-esm/sx.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import { SystemStyleObject } from '@styled-system/css';
|
2
|
+
import merge from 'deepmerge';
|
2
3
|
export interface SxProp {
|
3
4
|
sx?: SystemStyleObject;
|
4
5
|
}
|
5
6
|
declare const sx: (props: SxProp) => import("@styled-system/css").CssFunctionReturnType;
|
6
7
|
export default sx;
|
8
|
+
export { merge };
|
package/lib-esm/sx.js
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
/** createSlots is a factory that can create a
|
3
|
+
* typesafe Slots + Slot pair to use in a component definition
|
4
|
+
* For example: ActionList.Item uses createSlots to get a Slots wrapper
|
5
|
+
* + Slot component that is used by LeadingVisual, Description
|
6
|
+
*/
|
7
|
+
declare const createSlots: <SlotNames extends string>(slotNames: SlotNames[]) => {
|
8
|
+
Slots: React.FC<{
|
9
|
+
context: Record<string, unknown>;
|
10
|
+
children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
|
11
|
+
}>;
|
12
|
+
Slot: React.FC<{
|
13
|
+
name: SlotNames;
|
14
|
+
children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
|
15
|
+
}>;
|
16
|
+
};
|
17
|
+
export default createSlots;
|