@primer/components 0.0.0-2021829163659 → 0.0.0-20218292130
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 +5 -1
- package/dist/browser.esm.js +9 -10
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +24 -25
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.d.ts +16 -4
- package/lib/ActionList/Item.js +9 -6
- package/lib/ActionList/List.d.ts +11 -7
- package/lib/ActionList/List.js +2 -2
- package/lib/ActionList/index.d.ts +1 -2
- package/lib/FilteredActionList/FilteredActionList.js +31 -5
- package/lib/Overlay.d.ts +1 -2
- package/lib/Overlay.js +5 -10
- package/lib/SelectMenu/SelectMenu.d.ts +2 -8
- package/lib/TextInput.d.ts +3 -6
- package/lib/TextInput.js +10 -9
- package/lib/hooks/useOverlay.d.ts +1 -2
- package/lib/hooks/useOverlay.js +6 -11
- package/lib/utils/types.d.ts +0 -3
- package/lib-esm/ActionList/Item.d.ts +16 -4
- package/lib-esm/ActionList/Item.js +8 -5
- package/lib-esm/ActionList/List.d.ts +11 -7
- package/lib-esm/ActionList/List.js +2 -2
- package/lib-esm/ActionList/index.d.ts +1 -2
- package/lib-esm/FilteredActionList/FilteredActionList.js +31 -3
- package/lib-esm/Overlay.d.ts +1 -2
- package/lib-esm/Overlay.js +5 -8
- package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -8
- package/lib-esm/TextInput.d.ts +3 -6
- package/lib-esm/TextInput.js +9 -8
- package/lib-esm/hooks/useOverlay.d.ts +1 -2
- package/lib-esm/hooks/useOverlay.js +6 -11
- package/lib-esm/utils/types.d.ts +0 -3
- package/package.json +3 -5
- package/lib/Autocomplete/Autocomplete.d.ts +0 -31
- package/lib/Autocomplete/Autocomplete.js +0 -60
- package/lib/Autocomplete/AutocompleteContext.d.ts +0 -14
- package/lib/Autocomplete/AutocompleteContext.js +0 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib/Autocomplete/AutocompleteInput.js +0 -148
- package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -70
- package/lib/Autocomplete/AutocompleteMenu.js +0 -250
- package/lib/Autocomplete/index.d.ts +0 -2
- package/lib/Autocomplete/index.js +0 -15
- package/lib/Badge/Badge.d.ts +0 -8
- package/lib/Badge/Badge.js +0 -59
- package/lib/Badge/BadgeState.d.ts +0 -13
- package/lib/Badge/BadgeState.js +0 -51
- package/lib/Badge/_badgeStyleUtils.d.ts +0 -3
- package/lib/Badge/_badgeStyleUtils.js +0 -39
- package/lib/TextInputTokens.d.ts +0 -43
- package/lib/TextInputTokens.js +0 -237
- package/lib/Token/Token.d.ts +0 -14
- package/lib/Token/Token.js +0 -75
- package/lib/Token/TokenBase.d.ts +0 -16
- package/lib/Token/TokenBase.js +0 -90
- package/lib/Token/TokenLabel.d.ts +0 -14
- package/lib/Token/TokenLabel.js +0 -135
- package/lib/Token/TokenProfile.d.ts +0 -7
- package/lib/Token/TokenProfile.js +0 -50
- package/lib/Token/_RemoveTokenButton.d.ts +0 -3
- package/lib/Token/_RemoveTokenButton.js +0 -45
- package/lib/Token/_tokenButtonUtils.d.ts +0 -10
- package/lib/Token/_tokenButtonUtils.js +0 -42
- package/lib/_UnstyledTextInput.d.ts +0 -2
- package/lib/_UnstyledTextInput.js +0 -20
- package/lib/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib/utils/scrollIntoViewingArea.js +0 -39
- package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -31
- package/lib-esm/Autocomplete/Autocomplete.js +0 -40
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -14
- package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib-esm/Autocomplete/AutocompleteInput.js +0 -129
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -70
- package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -224
- package/lib-esm/Autocomplete/index.d.ts +0 -2
- package/lib-esm/Autocomplete/index.js +0 -1
- package/lib-esm/Badge/Badge.d.ts +0 -8
- package/lib-esm/Badge/Badge.js +0 -44
- package/lib-esm/Badge/BadgeState.d.ts +0 -13
- package/lib-esm/Badge/BadgeState.js +0 -40
- package/lib-esm/Badge/_badgeStyleUtils.d.ts +0 -3
- package/lib-esm/Badge/_badgeStyleUtils.js +0 -29
- package/lib-esm/TextInputTokens.d.ts +0 -43
- package/lib-esm/TextInputTokens.js +0 -210
- package/lib-esm/Token/Token.d.ts +0 -14
- package/lib-esm/Token/Token.js +0 -56
- package/lib-esm/Token/TokenBase.d.ts +0 -16
- package/lib-esm/Token/TokenBase.js +0 -70
- package/lib-esm/Token/TokenLabel.d.ts +0 -14
- package/lib-esm/Token/TokenLabel.js +0 -115
- package/lib-esm/Token/TokenProfile.d.ts +0 -7
- package/lib-esm/Token/TokenProfile.js +0 -29
- package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -3
- package/lib-esm/Token/_RemoveTokenButton.js +0 -30
- package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -10
- package/lib-esm/Token/_tokenButtonUtils.js +0 -26
- package/lib-esm/_UnstyledTextInput.d.ts +0 -2
- package/lib-esm/_UnstyledTextInput.js +0 -7
- package/lib-esm/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/utils/scrollIntoViewingArea.js +0 -30
package/lib/ActionList/Item.d.ts
CHANGED
@@ -2,10 +2,12 @@ import { IconProps } from '@primer/octicons-react';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { SxProp } from '../sx';
|
4
4
|
import { ItemInput } from './List';
|
5
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
6
|
+
import { AriaRole } from '../utils/types';
|
5
7
|
/**
|
6
8
|
* Contract for props passed to the `Item` component.
|
7
9
|
*/
|
8
|
-
export interface ItemProps extends
|
10
|
+
export interface ItemProps extends SxProp {
|
9
11
|
/**
|
10
12
|
* Primary text which names an `Item`.
|
11
13
|
*/
|
@@ -68,6 +70,18 @@ export interface ItemProps extends Omit<React.ComponentPropsWithoutRef<'div'>, '
|
|
68
70
|
* An id associated with this item. Should be unique between items
|
69
71
|
*/
|
70
72
|
id?: number | string;
|
73
|
+
/**
|
74
|
+
* Node to be included inside the item before the text.
|
75
|
+
*/
|
76
|
+
children?: React.ReactNode;
|
77
|
+
/**
|
78
|
+
* The ARIA role describing the function of `List` component. `option` is a common value.
|
79
|
+
*/
|
80
|
+
role?: AriaRole;
|
81
|
+
/**
|
82
|
+
* An item to pass back in the `onAction` callback, meant as
|
83
|
+
*/
|
84
|
+
item?: ItemInput;
|
71
85
|
}
|
72
86
|
export declare const TextContainer: import("styled-components").StyledComponent<"span", any, {
|
73
87
|
dangerouslySetInnerHtml?: React.DOMAttributes<HTMLDivElement>['dangerouslySetInnerHTML'];
|
@@ -75,6 +89,4 @@ export declare const TextContainer: import("styled-components").StyledComponent<
|
|
75
89
|
/**
|
76
90
|
* An actionable or selectable `Item` with an optional icon and description.
|
77
91
|
*/
|
78
|
-
export declare
|
79
|
-
item?: ItemInput;
|
80
|
-
}): JSX.Element;
|
92
|
+
export declare const Item: PolymorphicForwardRefComponent<"div", ItemProps>;
|
package/lib/ActionList/Item.js
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.Item =
|
7
|
-
exports.TextContainer = void 0;
|
6
|
+
exports.Item = exports.TextContainer = void 0;
|
8
7
|
|
9
8
|
var _octiconsReact = require("@primer/octicons-react");
|
10
9
|
|
@@ -111,7 +110,7 @@ const MainContent = _styledComponents.default.div.withConfig({
|
|
111
110
|
const StyledItem = _styledComponents.default.div.withConfig({
|
112
111
|
displayName: "Item__StyledItem",
|
113
112
|
componentId: "jqpvy8-2"
|
114
|
-
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], (0, _constants.get)('space.2'), (0, _constants.get)('radii.2'), ({
|
113
|
+
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;text-decoration:none;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], (0, _constants.get)('space.2'), (0, _constants.get)('radii.2'), ({
|
115
114
|
variant,
|
116
115
|
item
|
117
116
|
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
|
@@ -178,8 +177,9 @@ const MultiSelectInput = _styledComponents.default.input.withConfig({
|
|
178
177
|
*/
|
179
178
|
|
180
179
|
|
181
|
-
|
180
|
+
const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
182
181
|
const {
|
182
|
+
as: Component,
|
183
183
|
text,
|
184
184
|
description,
|
185
185
|
descriptionVariant = 'inline',
|
@@ -235,6 +235,8 @@ function Item(itemProps) {
|
|
235
235
|
theme
|
236
236
|
} = (0, _ThemeProvider.useTheme)();
|
237
237
|
return /*#__PURE__*/_react.default.createElement(StyledItem, _extends({
|
238
|
+
ref: ref,
|
239
|
+
as: Component,
|
238
240
|
tabIndex: disabled ? undefined : -1,
|
239
241
|
variant: variant,
|
240
242
|
showDivider: showDivider,
|
@@ -280,6 +282,7 @@ function Item(itemProps) {
|
|
280
282
|
variant: variant,
|
281
283
|
disabled: disabled
|
282
284
|
}, trailingText, TrailingIcon && /*#__PURE__*/_react.default.createElement(TrailingIcon, null)) : null));
|
283
|
-
}
|
285
|
+
});
|
284
286
|
|
285
|
-
Item
|
287
|
+
exports.Item = Item;
|
288
|
+
Item.displayName = 'Item';
|
package/lib/ActionList/List.d.ts
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { Key } from 'react';
|
2
2
|
import type { AriaRole } from '../utils/types';
|
3
3
|
import { Group, GroupProps } from './Group';
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
4
|
+
import { ItemProps } from './Item';
|
5
|
+
declare type RenderItemFn = (props: ItemProps) => React.ReactElement;
|
6
|
+
export declare type ItemInput = ItemProps | ((Partial<ItemProps> & {
|
7
|
+
renderItem: RenderItemFn;
|
8
|
+
}) & {
|
9
|
+
key?: Key;
|
7
10
|
});
|
8
11
|
/**
|
9
12
|
* Contract for props passed to the `List` component.
|
@@ -26,7 +29,7 @@ export interface ListPropsBase {
|
|
26
29
|
* without a `Group`-level or `Item`-level custom `Item` renderer will be
|
27
30
|
* rendered using this function component.
|
28
31
|
*/
|
29
|
-
renderItem?:
|
32
|
+
renderItem?: RenderItemFn;
|
30
33
|
/**
|
31
34
|
* A `List`-level custom `Group` renderer. Every `Group` within this `List`
|
32
35
|
* without a `Group`-level custom `Item` renderer will be rendered using
|
@@ -58,7 +61,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
58
61
|
* and `Group`-level custom `Item` or `Group` renderers.
|
59
62
|
*/
|
60
63
|
groupMetadata: ((Omit<GroupProps, 'items'> | Omit<Partial<GroupProps> & {
|
61
|
-
renderItem?:
|
64
|
+
renderItem?: RenderItemFn;
|
62
65
|
renderGroup?: typeof Group;
|
63
66
|
}, 'items'>) & {
|
64
67
|
groupId: string;
|
@@ -68,7 +71,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
68
71
|
* and `Item`-level custom `Item` renderers.
|
69
72
|
*/
|
70
73
|
items: ((ItemProps | (Partial<ItemProps> & {
|
71
|
-
renderItem:
|
74
|
+
renderItem: RenderItemFn;
|
72
75
|
})) & {
|
73
76
|
groupId: string;
|
74
77
|
})[];
|
@@ -81,3 +84,4 @@ export declare type ListProps = ListPropsBase | GroupedListProps;
|
|
81
84
|
* Lists `Item`s, either grouped or ungrouped, with a `Divider` between each `Group`.
|
82
85
|
*/
|
83
86
|
export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLDivElement>>;
|
87
|
+
export {};
|
package/lib/ActionList/List.js
CHANGED
@@ -106,11 +106,11 @@ const List = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) => {
|
|
106
106
|
|
107
107
|
|
108
108
|
const renderItem = (itemProps, item, itemIndex) => {
|
109
|
-
var _ref2,
|
109
|
+
var _ref2, _ref3, _itemProps$id;
|
110
110
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
112
112
|
const ItemComponent = 'renderItem' in itemProps && itemProps.renderItem || props.renderItem || _Item.Item;
|
113
|
-
const key = (_ref2 = (
|
113
|
+
const key = (_ref2 = (_ref3 = 'key' in itemProps ? itemProps.key : undefined) !== null && _ref3 !== void 0 ? _ref3 : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
|
114
114
|
return /*#__PURE__*/_react.default.createElement(ItemComponent, _extends({
|
115
115
|
showDivider: props.showItemDividers,
|
116
116
|
selectionVariant: props.selectionVariant
|
@@ -1,6 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Group } from './Group';
|
3
|
-
import { Item } from './Item';
|
4
3
|
import { Divider } from './Divider';
|
5
4
|
export type { ListProps as ActionListProps } from './List';
|
6
5
|
export type { GroupProps } from './Group';
|
@@ -12,7 +11,7 @@ export declare const ActionList: import("react").ForwardRefExoticComponent<impor
|
|
12
11
|
/** Collects related `Items` in an `ActionList`. */
|
13
12
|
Group: typeof Group;
|
14
13
|
/** An actionable or selectable `Item` with an optional icon and description. */
|
15
|
-
Item:
|
14
|
+
Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"div", import("./Item").ItemProps>;
|
16
15
|
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
17
16
|
Divider: typeof Divider;
|
18
17
|
};
|
@@ -7,8 +7,6 @@ exports.FilteredActionList = FilteredActionList;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
-
var _ssr = require("@react-aria/ssr");
|
11
|
-
|
12
10
|
var _TextInput = _interopRequireDefault(require("../TextInput"));
|
13
11
|
|
14
12
|
var _Box = _interopRequireDefault(require("../Box"));
|
@@ -29,7 +27,7 @@ var _useProvidedRefOrCreate = require("../hooks/useProvidedRefOrCreate");
|
|
29
27
|
|
30
28
|
var _useScrollFlash = _interopRequireDefault(require("../hooks/useScrollFlash"));
|
31
29
|
|
32
|
-
var
|
30
|
+
var _ssr = require("@react-aria/ssr");
|
33
31
|
|
34
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
33
|
|
@@ -39,6 +37,34 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
39
37
|
|
40
38
|
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); }
|
41
39
|
|
40
|
+
function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
|
41
|
+
const {
|
42
|
+
top: childTop,
|
43
|
+
bottom: childBottom
|
44
|
+
} = child.getBoundingClientRect();
|
45
|
+
const {
|
46
|
+
top: containerTop,
|
47
|
+
bottom: containerBottom
|
48
|
+
} = container.getBoundingClientRect();
|
49
|
+
const isChildTopAboveViewingArea = childTop < containerTop + margin;
|
50
|
+
const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
|
51
|
+
|
52
|
+
if (isChildTopAboveViewingArea) {
|
53
|
+
const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
|
54
|
+
container.scrollTo({
|
55
|
+
behavior,
|
56
|
+
top: scrollHeightToChildTop - margin
|
57
|
+
});
|
58
|
+
} else if (isChildBottomBelowViewingArea) {
|
59
|
+
const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
|
60
|
+
container.scrollTo({
|
61
|
+
behavior,
|
62
|
+
top: scrollHeightToChildBottom + margin
|
63
|
+
});
|
64
|
+
} // either completely in view or outside viewing area on both ends, don't scroll
|
65
|
+
|
66
|
+
}
|
67
|
+
|
42
68
|
const StyledHeader = _styledComponents.default.div.withConfig({
|
43
69
|
displayName: "FilteredActionList__StyledHeader",
|
44
70
|
componentId: "yg3jkv-0"
|
@@ -85,7 +111,7 @@ function FilteredActionList({
|
|
85
111
|
activeDescendantRef.current = current;
|
86
112
|
|
87
113
|
if (current && scrollContainerRef.current && directlyActivated) {
|
88
|
-
|
114
|
+
scrollIntoViewingArea(current, scrollContainerRef.current);
|
89
115
|
}
|
90
116
|
}
|
91
117
|
}, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
|
@@ -93,7 +119,7 @@ function FilteredActionList({
|
|
93
119
|
(0, _react.useEffect)(() => {
|
94
120
|
// if items changed, we want to instantly move active descendant into view
|
95
121
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
96
|
-
|
122
|
+
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
|
97
123
|
}
|
98
124
|
}, [items]);
|
99
125
|
(0, _useScrollFlash.default)(scrollContainerRef);
|
package/lib/Overlay.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { ComponentProps } from './utils/types';
|
|
4
4
|
import { TouchOrMouseEvent } from './hooks';
|
5
5
|
import { SxProp } from './sx';
|
6
6
|
import { AnchorSide } from './behaviors/anchoredPosition';
|
7
|
-
|
7
|
+
declare type StyledOverlayProps = {
|
8
8
|
width?: keyof typeof widthMap;
|
9
9
|
height?: keyof typeof heightMap;
|
10
10
|
maxHeight?: keyof Omit<typeof heightMap, 'auto' | 'initial'>;
|
@@ -40,7 +40,6 @@ export declare type OverlayProps = {
|
|
40
40
|
top: number;
|
41
41
|
left: number;
|
42
42
|
portalContainerName?: string;
|
43
|
-
preventFocusOnOpen?: boolean;
|
44
43
|
} & Omit<ComponentProps<typeof StyledOverlay>, 'visibility' | keyof SystemPositionProps>;
|
45
44
|
/**
|
46
45
|
* An `Overlay` is a flexible floating surface, used to display transient content such as menus,
|
package/lib/Overlay.js
CHANGED
@@ -113,7 +113,6 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
113
113
|
left,
|
114
114
|
anchorSide,
|
115
115
|
portalContainerName,
|
116
|
-
preventFocusOnOpen,
|
117
116
|
...rest
|
118
117
|
}, forwardedRef) => {
|
119
118
|
const overlayRef = (0, _react.useRef)(null);
|
@@ -129,8 +128,7 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
129
128
|
onEscape,
|
130
129
|
ignoreClickRefs,
|
131
130
|
onClickOutside,
|
132
|
-
initialFocusRef
|
133
|
-
preventFocusOnOpen
|
131
|
+
initialFocusRef
|
134
132
|
});
|
135
133
|
(0, _react.useEffect)(() => {
|
136
134
|
var _combinedRef$current;
|
@@ -159,8 +157,9 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
159
157
|
easing: slideAnimationEasing
|
160
158
|
});
|
161
159
|
}, [anchorSide, slideAnimationDistance, slideAnimationEasing, visibility]);
|
162
|
-
|
163
|
-
|
160
|
+
return /*#__PURE__*/_react.default.createElement(_Portal.default, {
|
161
|
+
containerName: portalContainerName
|
162
|
+
}, /*#__PURE__*/_react.default.createElement(StyledOverlay, _extends({
|
164
163
|
height: height,
|
165
164
|
role: role
|
166
165
|
}, rest, {
|
@@ -171,11 +170,7 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
171
170
|
...rest.style,
|
172
171
|
'--styled-overlay-visibility': visibility
|
173
172
|
}
|
174
|
-
}));
|
175
|
-
|
176
|
-
return /*#__PURE__*/_react.default.createElement(_Portal.default, {
|
177
|
-
containerName: portalContainerName
|
178
|
-
}, styledOverlay);
|
173
|
+
})));
|
179
174
|
});
|
180
175
|
|
181
176
|
Overlay.defaultProps = {
|
@@ -32,15 +32,11 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
32
32
|
Divider: import("styled-components").StyledComponent<"div", any, SystemCommonProps & SxProp, never>;
|
33
33
|
Filter: React.ForwardRefExoticComponent<Pick<{
|
34
34
|
value?: string | undefined;
|
35
|
-
} &
|
36
|
-
ref?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
|
37
|
-
}, string | number | symbol> & {
|
35
|
+
} & Pick<{
|
38
36
|
className?: string | undefined;
|
39
37
|
icon?: React.ComponentType<{
|
40
38
|
className?: string | undefined;
|
41
39
|
}> | undefined;
|
42
|
-
inputComponent?: React.ComponentType<HTMLInputElement> | undefined;
|
43
|
-
wrapperRef?: React.RefObject<HTMLSpanElement> | undefined;
|
44
40
|
} & Pick<{
|
45
41
|
color?: string | undefined;
|
46
42
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -319,9 +315,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
319
315
|
} & {
|
320
316
|
as?: string | React.ComponentType<any> | undefined;
|
321
317
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
322
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast" |
|
323
|
-
as?: "input" | undefined;
|
324
|
-
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
318
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
325
319
|
Footer: import("styled-components").StyledComponent<"footer", any, SystemCommonProps & SxProp, never>;
|
326
320
|
Item: React.ForwardRefExoticComponent<Pick<{
|
327
321
|
as?: React.ElementType<any> | undefined;
|
package/lib/TextInput.d.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
|
3
|
-
import type * as Polymorphic from "@radix-ui/react-polymorphic";
|
4
3
|
import { SxProp } from './sx';
|
5
4
|
import { ComponentProps } from './utils/types';
|
6
|
-
import
|
5
|
+
declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
|
7
6
|
declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
|
8
7
|
disabled?: boolean | undefined;
|
9
8
|
hasIcon?: boolean | undefined;
|
@@ -16,10 +15,8 @@ declare type NonPassthroughProps = {
|
|
16
15
|
icon?: React.ComponentType<{
|
17
16
|
className?: string;
|
18
17
|
}>;
|
19
|
-
inputComponent?: React.ComponentType<HTMLInputElement>;
|
20
|
-
wrapperRef?: React.RefObject<HTMLSpanElement>;
|
21
18
|
} & Pick<ComponentProps<typeof Wrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
|
22
|
-
declare type TextInputInternalProps = NonPassthroughProps & Omit<React.ComponentPropsWithoutRef<typeof
|
23
|
-
declare const TextInput:
|
19
|
+
declare type TextInputInternalProps = NonPassthroughProps & Omit<React.ComponentPropsWithoutRef<typeof Input>, keyof NonPassthroughProps>;
|
20
|
+
declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
24
21
|
export declare type TextInputProps = ComponentProps<typeof TextInput>;
|
25
22
|
export default TextInput;
|
package/lib/TextInput.js
CHANGED
@@ -17,8 +17,6 @@ var _constants = require("./constants");
|
|
17
17
|
|
18
18
|
var _sx = _interopRequireDefault(require("./sx"));
|
19
19
|
|
20
|
-
var _UnstyledTextInput = _interopRequireDefault(require("./_UnstyledTextInput"));
|
21
|
-
|
22
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
23
21
|
|
24
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -44,20 +42,25 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
44
42
|
}
|
45
43
|
});
|
46
44
|
|
45
|
+
const Input = _styledComponents.default.input.withConfig({
|
46
|
+
displayName: "TextInput__Input",
|
47
|
+
componentId: "sc-1apmpmt-0"
|
48
|
+
})(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;width:100%;&:focus{outline:0;}"]);
|
49
|
+
|
47
50
|
const Wrapper = _styledComponents.default.span.withConfig({
|
48
51
|
displayName: "TextInput__Wrapper",
|
49
|
-
componentId: "sc-1apmpmt-
|
52
|
+
componentId: "sc-1apmpmt-1"
|
50
53
|
})(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
51
54
|
if (props.hasIcon) {
|
52
55
|
return (0, _styledComponents.css)(["padding:0;"]);
|
53
56
|
} else {
|
54
57
|
return (0, _styledComponents.css)(["padding:6px 12px;"]);
|
55
58
|
}
|
56
|
-
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
59
|
+
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default); // Props that are not passed through to Input:
|
60
|
+
|
57
61
|
|
58
62
|
// using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
|
59
63
|
const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
60
|
-
inputComponent: InputComponent,
|
61
64
|
icon: IconComponent,
|
62
65
|
block,
|
63
66
|
className,
|
@@ -69,7 +72,6 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
69
72
|
minWidth: minWidthProp,
|
70
73
|
maxWidth: maxWidthProp,
|
71
74
|
variant: variantProp,
|
72
|
-
wrapperRef,
|
73
75
|
...inputProps
|
74
76
|
}, ref) => {
|
75
77
|
// this class is necessary to style FilterSearch, plz no touchy!
|
@@ -85,11 +87,10 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
85
87
|
width: widthProp,
|
86
88
|
minWidth: minWidthProp,
|
87
89
|
maxWidth: maxWidthProp,
|
88
|
-
variant: variantProp
|
89
|
-
ref: wrapperRef
|
90
|
+
variant: variantProp
|
90
91
|
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
|
91
92
|
className: "TextInput-icon"
|
92
|
-
}), /*#__PURE__*/_react.default.createElement(
|
93
|
+
}), /*#__PURE__*/_react.default.createElement(Input, _extends({
|
93
94
|
ref: ref,
|
94
95
|
disabled: disabled
|
95
96
|
}, inputProps)));
|
@@ -7,9 +7,8 @@ export declare type UseOverlaySettings = {
|
|
7
7
|
onEscape: (e: KeyboardEvent) => void;
|
8
8
|
onClickOutside: (e: TouchOrMouseEvent) => void;
|
9
9
|
overlayRef?: React.RefObject<HTMLDivElement>;
|
10
|
-
preventFocusOnOpen?: boolean;
|
11
10
|
};
|
12
11
|
export declare type OverlayReturnProps = {
|
13
12
|
ref: React.RefObject<HTMLDivElement>;
|
14
13
|
};
|
15
|
-
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside
|
14
|
+
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside }: UseOverlaySettings) => OverlayReturnProps;
|
package/lib/hooks/useOverlay.js
CHANGED
@@ -19,19 +19,14 @@ const useOverlay = ({
|
|
19
19
|
initialFocusRef,
|
20
20
|
onEscape,
|
21
21
|
ignoreClickRefs,
|
22
|
-
onClickOutside
|
23
|
-
preventFocusOnOpen
|
22
|
+
onClickOutside
|
24
23
|
}) => {
|
25
24
|
const overlayRef = (0, _useProvidedRefOrCreate.useProvidedRefOrCreate)(_overlayRef);
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
initialFocusRef
|
32
|
-
});
|
33
|
-
}
|
34
|
-
|
25
|
+
(0, _useOpenAndCloseFocus.useOpenAndCloseFocus)({
|
26
|
+
containerRef: overlayRef,
|
27
|
+
returnFocusRef,
|
28
|
+
initialFocusRef
|
29
|
+
});
|
35
30
|
(0, _useOnOutsideClick.useOnOutsideClick)({
|
36
31
|
containerRef: overlayRef,
|
37
32
|
ignoreClickRefs,
|
package/lib/utils/types.d.ts
CHANGED
@@ -12,6 +12,3 @@ export declare type ComponentProps<T> = T extends React.ComponentType<infer Prop
|
|
12
12
|
*/
|
13
13
|
export declare type Flatten<T extends unknown> = T extends (infer U)[] ? U : never;
|
14
14
|
export declare type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox ' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
15
|
-
export declare type MandateProps<T extends {}, K extends keyof T> = Omit<T, K> & {
|
16
|
-
[MK in K]-?: NonNullable<T[MK]>;
|
17
|
-
};
|
@@ -2,10 +2,12 @@ import { IconProps } from '@primer/octicons-react';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { SxProp } from '../sx';
|
4
4
|
import { ItemInput } from './List';
|
5
|
+
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
6
|
+
import { AriaRole } from '../utils/types';
|
5
7
|
/**
|
6
8
|
* Contract for props passed to the `Item` component.
|
7
9
|
*/
|
8
|
-
export interface ItemProps extends
|
10
|
+
export interface ItemProps extends SxProp {
|
9
11
|
/**
|
10
12
|
* Primary text which names an `Item`.
|
11
13
|
*/
|
@@ -68,6 +70,18 @@ export interface ItemProps extends Omit<React.ComponentPropsWithoutRef<'div'>, '
|
|
68
70
|
* An id associated with this item. Should be unique between items
|
69
71
|
*/
|
70
72
|
id?: number | string;
|
73
|
+
/**
|
74
|
+
* Node to be included inside the item before the text.
|
75
|
+
*/
|
76
|
+
children?: React.ReactNode;
|
77
|
+
/**
|
78
|
+
* The ARIA role describing the function of `List` component. `option` is a common value.
|
79
|
+
*/
|
80
|
+
role?: AriaRole;
|
81
|
+
/**
|
82
|
+
* An item to pass back in the `onAction` callback, meant as
|
83
|
+
*/
|
84
|
+
item?: ItemInput;
|
71
85
|
}
|
72
86
|
export declare const TextContainer: import("styled-components").StyledComponent<"span", any, {
|
73
87
|
dangerouslySetInnerHtml?: React.DOMAttributes<HTMLDivElement>['dangerouslySetInnerHTML'];
|
@@ -75,6 +89,4 @@ export declare const TextContainer: import("styled-components").StyledComponent<
|
|
75
89
|
/**
|
76
90
|
* An actionable or selectable `Item` with an optional icon and description.
|
77
91
|
*/
|
78
|
-
export declare
|
79
|
-
item?: ItemInput;
|
80
|
-
}): JSX.Element;
|
92
|
+
export declare const Item: PolymorphicForwardRefComponent<"div", ItemProps>;
|
@@ -11,10 +11,10 @@ import { StyledDivider } from './Divider';
|
|
11
11
|
import { useColorSchemeVar, useTheme } from '../ThemeProvider';
|
12
12
|
import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '../behaviors/focusZone';
|
13
13
|
import { useSSRSafeId } from '@react-aria/ssr';
|
14
|
+
|
14
15
|
/**
|
15
16
|
* These colors are not yet in our default theme. Need to remove this once they are added.
|
16
17
|
*/
|
17
|
-
|
18
18
|
const customItemThemes = {
|
19
19
|
default: {
|
20
20
|
hover: {
|
@@ -85,7 +85,7 @@ const MainContent = styled.div.withConfig({
|
|
85
85
|
const StyledItem = styled.div.withConfig({
|
86
86
|
displayName: "Item__StyledItem",
|
87
87
|
componentId: "jqpvy8-2"
|
88
|
-
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], get('space.2'), get('radii.2'), ({
|
88
|
+
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;text-decoration:none;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], get('space.2'), get('radii.2'), ({
|
89
89
|
variant,
|
90
90
|
item
|
91
91
|
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
|
@@ -144,8 +144,9 @@ const MultiSelectInput = styled.input.withConfig({
|
|
144
144
|
* An actionable or selectable `Item` with an optional icon and description.
|
145
145
|
*/
|
146
146
|
|
147
|
-
export
|
147
|
+
export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
148
148
|
const {
|
149
|
+
as: Component,
|
149
150
|
text,
|
150
151
|
description,
|
151
152
|
descriptionVariant = 'inline',
|
@@ -201,6 +202,8 @@ export function Item(itemProps) {
|
|
201
202
|
theme
|
202
203
|
} = useTheme();
|
203
204
|
return /*#__PURE__*/React.createElement(StyledItem, _extends({
|
205
|
+
ref: ref,
|
206
|
+
as: Component,
|
204
207
|
tabIndex: disabled ? undefined : -1,
|
205
208
|
variant: variant,
|
206
209
|
showDivider: showDivider,
|
@@ -246,5 +249,5 @@ export function Item(itemProps) {
|
|
246
249
|
variant: variant,
|
247
250
|
disabled: disabled
|
248
251
|
}, trailingText, TrailingIcon && /*#__PURE__*/React.createElement(TrailingIcon, null)) : null));
|
249
|
-
}
|
250
|
-
Item.displayName =
|
252
|
+
});
|
253
|
+
Item.displayName = 'Item';
|
@@ -1,9 +1,12 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { Key } from 'react';
|
2
2
|
import type { AriaRole } from '../utils/types';
|
3
3
|
import { Group, GroupProps } from './Group';
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
4
|
+
import { ItemProps } from './Item';
|
5
|
+
declare type RenderItemFn = (props: ItemProps) => React.ReactElement;
|
6
|
+
export declare type ItemInput = ItemProps | ((Partial<ItemProps> & {
|
7
|
+
renderItem: RenderItemFn;
|
8
|
+
}) & {
|
9
|
+
key?: Key;
|
7
10
|
});
|
8
11
|
/**
|
9
12
|
* Contract for props passed to the `List` component.
|
@@ -26,7 +29,7 @@ export interface ListPropsBase {
|
|
26
29
|
* without a `Group`-level or `Item`-level custom `Item` renderer will be
|
27
30
|
* rendered using this function component.
|
28
31
|
*/
|
29
|
-
renderItem?:
|
32
|
+
renderItem?: RenderItemFn;
|
30
33
|
/**
|
31
34
|
* A `List`-level custom `Group` renderer. Every `Group` within this `List`
|
32
35
|
* without a `Group`-level custom `Item` renderer will be rendered using
|
@@ -58,7 +61,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
58
61
|
* and `Group`-level custom `Item` or `Group` renderers.
|
59
62
|
*/
|
60
63
|
groupMetadata: ((Omit<GroupProps, 'items'> | Omit<Partial<GroupProps> & {
|
61
|
-
renderItem?:
|
64
|
+
renderItem?: RenderItemFn;
|
62
65
|
renderGroup?: typeof Group;
|
63
66
|
}, 'items'>) & {
|
64
67
|
groupId: string;
|
@@ -68,7 +71,7 @@ export interface GroupedListProps extends ListPropsBase {
|
|
68
71
|
* and `Item`-level custom `Item` renderers.
|
69
72
|
*/
|
70
73
|
items: ((ItemProps | (Partial<ItemProps> & {
|
71
|
-
renderItem:
|
74
|
+
renderItem: RenderItemFn;
|
72
75
|
})) & {
|
73
76
|
groupId: string;
|
74
77
|
})[];
|
@@ -81,3 +84,4 @@ export declare type ListProps = ListPropsBase | GroupedListProps;
|
|
81
84
|
* Lists `Item`s, either grouped or ungrouped, with a `Divider` between each `Group`.
|
82
85
|
*/
|
83
86
|
export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLDivElement>>;
|
87
|
+
export {};
|
@@ -90,11 +90,11 @@ export const List = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
90
90
|
|
91
91
|
|
92
92
|
const renderItem = (itemProps, item, itemIndex) => {
|
93
|
-
var _ref2,
|
93
|
+
var _ref2, _ref3, _itemProps$id;
|
94
94
|
|
95
95
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
96
96
|
const ItemComponent = 'renderItem' in itemProps && itemProps.renderItem || props.renderItem || Item;
|
97
|
-
const key = (_ref2 = (
|
97
|
+
const key = (_ref2 = (_ref3 = 'key' in itemProps ? itemProps.key : undefined) !== null && _ref3 !== void 0 ? _ref3 : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
|
98
98
|
return /*#__PURE__*/React.createElement(ItemComponent, _extends({
|
99
99
|
showDivider: props.showItemDividers,
|
100
100
|
selectionVariant: props.selectionVariant
|
@@ -1,6 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Group } from './Group';
|
3
|
-
import { Item } from './Item';
|
4
3
|
import { Divider } from './Divider';
|
5
4
|
export type { ListProps as ActionListProps } from './List';
|
6
5
|
export type { GroupProps } from './Group';
|
@@ -12,7 +11,7 @@ export declare const ActionList: import("react").ForwardRefExoticComponent<impor
|
|
12
11
|
/** Collects related `Items` in an `ActionList`. */
|
13
12
|
Group: typeof Group;
|
14
13
|
/** An actionable or selectable `Item` with an optional icon and description. */
|
15
|
-
Item:
|
14
|
+
Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"div", import("./Item").ItemProps>;
|
16
15
|
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
17
16
|
Divider: typeof Divider;
|
18
17
|
};
|