@primer/components 0.0.0-2021827223713 → 0.0.0-2021828162730

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.
@@ -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 Omit<React.ComponentPropsWithoutRef<'div'>, 'id'>, SxProp {
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,5 @@ 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 function Item(itemProps: Partial<ItemProps> & {
79
- item?: ItemInput;
80
- }): JSX.Element;
92
+ declare const Item: PolymorphicForwardRefComponent<"div", ItemProps>;
93
+ export { Item };
@@ -3,8 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Item = 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
 
@@ -90,7 +89,7 @@ const getItemVariant = (variant = 'default', disabled) => {
90
89
 
91
90
  default:
92
91
  return {
93
- color: 'inherit',
92
+ color: (0, _constants.get)('colors.fg.default'),
94
93
  iconColor: (0, _constants.get)('colors.fg.muted'),
95
94
  annotationColor: (0, _constants.get)('colors.fg.muted'),
96
95
  hoverCursor: 'pointer'
@@ -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
- function Item(itemProps) {
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,6 @@ 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.displayName = "Item";
287
+ exports.Item = 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 { Item, ItemProps } from './Item';
5
- export declare type ItemInput = ItemProps | (Partial<ItemProps> & {
6
- renderItem: typeof Item;
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?: typeof Item;
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?: typeof Item;
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: typeof Item;
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 {};
@@ -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, _itemProps$key, _itemProps$id;
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 = (_itemProps$key = itemProps.key) !== null && _itemProps$key !== void 0 ? _itemProps$key : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
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: typeof 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
  };
@@ -1,25 +1,24 @@
1
1
  import * as History from 'history';
2
2
  import React from 'react';
3
+ import { SystemCommonProps, SystemFlexProps } from './constants';
3
4
  import { SxProp } from './sx';
4
5
  import { ComponentProps } from './utils/types';
5
- declare const BreadcrumbsBase: import("styled-components").StyledComponent<"nav", any, SxProp, never>;
6
- export declare type BreadcrumbsProps = React.PropsWithChildren<{
7
- className?: string;
8
- } & SxProp>;
9
- declare function Breadcrumbs({ className, children, sx: sxProp }: React.PropsWithChildren<BreadcrumbsProps>): JSX.Element;
6
+ declare const BreadcrumbsBase: import("styled-components").StyledComponent<"nav", any, SystemFlexProps & SystemCommonProps & SxProp, never>;
7
+ export declare type BreadcrumbsProps = ComponentProps<typeof BreadcrumbsBase>;
8
+ declare function Breadcrumbs({ className, children, theme, ...rest }: React.PropsWithChildren<BreadcrumbsProps>): JSX.Element;
10
9
  declare namespace Breadcrumbs {
11
10
  var displayName: string;
12
11
  }
13
12
  declare const BreadcrumbsItem: import("styled-components").StyledComponent<"a", any, {
14
13
  to?: History.LocationDescriptor<unknown> | undefined;
15
14
  selected?: boolean | undefined;
16
- } & SxProp, never>;
15
+ } & SystemCommonProps & SxProp, never>;
17
16
  export declare type BreadcrumbsItemProps = ComponentProps<typeof BreadcrumbsItem>;
18
17
  declare const _default: typeof Breadcrumbs & {
19
18
  Item: import("styled-components").StyledComponent<"a", any, {
20
19
  to?: History.LocationDescriptor<unknown> | undefined;
21
20
  selected?: boolean | undefined;
22
- } & SxProp, never>;
21
+ } & SystemCommonProps & SxProp, never>;
23
22
  };
24
23
  export default _default;
25
24
  /**
@@ -29,7 +28,7 @@ export declare const Breadcrumb: typeof Breadcrumbs & {
29
28
  Item: import("styled-components").StyledComponent<"a", any, {
30
29
  to?: History.LocationDescriptor<unknown> | undefined;
31
30
  selected?: boolean | undefined;
32
- } & SxProp, never>;
31
+ } & SystemCommonProps & SxProp, never>;
33
32
  };
34
33
  /**
35
34
  * @deprecated Use the `BreadcrumbsProps` type instead
@@ -19,6 +19,8 @@ var _sx = _interopRequireDefault(require("./sx"));
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
+ 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); }
23
+
22
24
  const SELECTED_CLASS = 'selected';
23
25
 
24
26
  const Wrapper = _styledComponents.default.li.withConfig({
@@ -29,20 +31,23 @@ const Wrapper = _styledComponents.default.li.withConfig({
29
31
  const BreadcrumbsBase = _styledComponents.default.nav.withConfig({
30
32
  displayName: "Breadcrumbs__BreadcrumbsBase",
31
33
  componentId: "hwwoo0-1"
32
- })(["display:flex;justify-content:space-between;", ";"], _sx.default);
34
+ })(["display:flex;justify-content:space-between;", ";", ";", ";"], _constants.COMMON, _constants.FLEX, _sx.default);
33
35
 
34
36
  function Breadcrumbs({
35
37
  className,
36
38
  children,
37
- sx: sxProp
39
+ theme,
40
+ ...rest
38
41
  }) {
39
- const wrappedChildren = _react.default.Children.map(children, child => /*#__PURE__*/_react.default.createElement(Wrapper, null, child));
42
+ const wrappedChildren = _react.default.Children.map(children, child => /*#__PURE__*/_react.default.createElement(Wrapper, {
43
+ theme: theme
44
+ }, child));
40
45
 
41
- return /*#__PURE__*/_react.default.createElement(BreadcrumbsBase, {
46
+ return /*#__PURE__*/_react.default.createElement(BreadcrumbsBase, _extends({
42
47
  className: className,
43
48
  "aria-label": "Breadcrumbs",
44
- sx: sxProp
45
- }, /*#__PURE__*/_react.default.createElement(_Box.default, {
49
+ theme: theme
50
+ }, rest), /*#__PURE__*/_react.default.createElement(_Box.default, {
46
51
  as: "ol",
47
52
  my: 0,
48
53
  pl: 0
@@ -58,7 +63,7 @@ const BreadcrumbsItem = _styledComponents.default.a.attrs(props => ({
58
63
  })).withConfig({
59
64
  displayName: "Breadcrumbs__BreadcrumbsItem",
60
65
  componentId: "hwwoo0-2"
61
- })(["color:", ";display:inline-block;font-size:", ";text-decoration:none;&:hover{text-decoration:underline;}&.selected{color:", ";pointer-events:none;}", ";"], (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), _sx.default);
66
+ })(["color:", ";display:inline-block;font-size:", ";text-decoration:none;&:hover{text-decoration:underline;}&.selected{color:", ";pointer-events:none;}", " ", ";"], (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), _constants.COMMON, _sx.default);
62
67
 
63
68
  Breadcrumbs.displayName = 'Breadcrumbs';
64
69
  BreadcrumbsItem.displayName = 'Breadcrumbs.Item';
@@ -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 Omit<React.ComponentPropsWithoutRef<'div'>, 'id'>, SxProp {
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,5 @@ 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 function Item(itemProps: Partial<ItemProps> & {
79
- item?: ItemInput;
80
- }): JSX.Element;
92
+ declare const Item: PolymorphicForwardRefComponent<"div", ItemProps>;
93
+ export { Item };
@@ -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: {
@@ -66,7 +66,7 @@ const getItemVariant = (variant = 'default', disabled) => {
66
66
 
67
67
  default:
68
68
  return {
69
- color: 'inherit',
69
+ color: get('colors.fg.default'),
70
70
  iconColor: get('colors.fg.muted'),
71
71
  annotationColor: get('colors.fg.muted'),
72
72
  hoverCursor: 'pointer'
@@ -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 function Item(itemProps) {
147
+ 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 = "Item";
252
+ });
253
+ export { 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 { Item, ItemProps } from './Item';
5
- export declare type ItemInput = ItemProps | (Partial<ItemProps> & {
6
- renderItem: typeof Item;
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?: typeof Item;
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?: typeof Item;
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: typeof Item;
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, _itemProps$key, _itemProps$id;
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 = (_itemProps$key = itemProps.key) !== null && _itemProps$key !== void 0 ? _itemProps$key : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
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: typeof 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
  };
@@ -1,25 +1,24 @@
1
1
  import * as History from 'history';
2
2
  import React from 'react';
3
+ import { SystemCommonProps, SystemFlexProps } from './constants';
3
4
  import { SxProp } from './sx';
4
5
  import { ComponentProps } from './utils/types';
5
- declare const BreadcrumbsBase: import("styled-components").StyledComponent<"nav", any, SxProp, never>;
6
- export declare type BreadcrumbsProps = React.PropsWithChildren<{
7
- className?: string;
8
- } & SxProp>;
9
- declare function Breadcrumbs({ className, children, sx: sxProp }: React.PropsWithChildren<BreadcrumbsProps>): JSX.Element;
6
+ declare const BreadcrumbsBase: import("styled-components").StyledComponent<"nav", any, SystemFlexProps & SystemCommonProps & SxProp, never>;
7
+ export declare type BreadcrumbsProps = ComponentProps<typeof BreadcrumbsBase>;
8
+ declare function Breadcrumbs({ className, children, theme, ...rest }: React.PropsWithChildren<BreadcrumbsProps>): JSX.Element;
10
9
  declare namespace Breadcrumbs {
11
10
  var displayName: string;
12
11
  }
13
12
  declare const BreadcrumbsItem: import("styled-components").StyledComponent<"a", any, {
14
13
  to?: History.LocationDescriptor<unknown> | undefined;
15
14
  selected?: boolean | undefined;
16
- } & SxProp, never>;
15
+ } & SystemCommonProps & SxProp, never>;
17
16
  export declare type BreadcrumbsItemProps = ComponentProps<typeof BreadcrumbsItem>;
18
17
  declare const _default: typeof Breadcrumbs & {
19
18
  Item: import("styled-components").StyledComponent<"a", any, {
20
19
  to?: History.LocationDescriptor<unknown> | undefined;
21
20
  selected?: boolean | undefined;
22
- } & SxProp, never>;
21
+ } & SystemCommonProps & SxProp, never>;
23
22
  };
24
23
  export default _default;
25
24
  /**
@@ -29,7 +28,7 @@ export declare const Breadcrumb: typeof Breadcrumbs & {
29
28
  Item: import("styled-components").StyledComponent<"a", any, {
30
29
  to?: History.LocationDescriptor<unknown> | undefined;
31
30
  selected?: boolean | undefined;
32
- } & SxProp, never>;
31
+ } & SystemCommonProps & SxProp, never>;
33
32
  };
34
33
  /**
35
34
  * @deprecated Use the `BreadcrumbsProps` type instead
@@ -1,9 +1,11 @@
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
+
1
3
  import classnames from 'classnames'; // eslint-disable-next-line import/no-namespace
2
4
 
3
5
  import React from 'react';
4
6
  import styled from 'styled-components';
5
7
  import Box from './Box';
6
- import { get } from './constants';
8
+ import { COMMON, FLEX, get } from './constants';
7
9
  import sx from './sx';
8
10
  const SELECTED_CLASS = 'selected';
9
11
  const Wrapper = styled.li.withConfig({
@@ -13,19 +15,22 @@ const Wrapper = styled.li.withConfig({
13
15
  const BreadcrumbsBase = styled.nav.withConfig({
14
16
  displayName: "Breadcrumbs__BreadcrumbsBase",
15
17
  componentId: "hwwoo0-1"
16
- })(["display:flex;justify-content:space-between;", ";"], sx);
18
+ })(["display:flex;justify-content:space-between;", ";", ";", ";"], COMMON, FLEX, sx);
17
19
 
18
20
  function Breadcrumbs({
19
21
  className,
20
22
  children,
21
- sx: sxProp
23
+ theme,
24
+ ...rest
22
25
  }) {
23
- const wrappedChildren = React.Children.map(children, child => /*#__PURE__*/React.createElement(Wrapper, null, child));
24
- return /*#__PURE__*/React.createElement(BreadcrumbsBase, {
26
+ const wrappedChildren = React.Children.map(children, child => /*#__PURE__*/React.createElement(Wrapper, {
27
+ theme: theme
28
+ }, child));
29
+ return /*#__PURE__*/React.createElement(BreadcrumbsBase, _extends({
25
30
  className: className,
26
31
  "aria-label": "Breadcrumbs",
27
- sx: sxProp
28
- }, /*#__PURE__*/React.createElement(Box, {
32
+ theme: theme
33
+ }, rest), /*#__PURE__*/React.createElement(Box, {
29
34
  as: "ol",
30
35
  my: 0,
31
36
  pl: 0
@@ -40,7 +45,7 @@ const BreadcrumbsItem = styled.a.attrs(props => ({
40
45
  })).withConfig({
41
46
  displayName: "Breadcrumbs__BreadcrumbsItem",
42
47
  componentId: "hwwoo0-2"
43
- })(["color:", ";display:inline-block;font-size:", ";text-decoration:none;&:hover{text-decoration:underline;}&.selected{color:", ";pointer-events:none;}", ";"], get('colors.accent.fg'), get('fontSizes.1'), get('colors.fg.default'), sx);
48
+ })(["color:", ";display:inline-block;font-size:", ";text-decoration:none;&:hover{text-decoration:underline;}&.selected{color:", ";pointer-events:none;}", " ", ";"], get('colors.accent.fg'), get('fontSizes.1'), get('colors.fg.default'), COMMON, sx);
44
49
  Breadcrumbs.displayName = 'Breadcrumbs';
45
50
  BreadcrumbsItem.displayName = 'Breadcrumbs.Item';
46
51
  export default Object.assign(Breadcrumbs, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-2021827223713",
3
+ "version": "0.0.0-2021828162730",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -45,6 +45,7 @@
45
45
  "dependencies": {
46
46
  "@primer/octicons-react": "^13.0.0",
47
47
  "@primer/primitives": "4.7.1",
48
+ "@radix-ui/react-polymorphic": "0.0.14",
48
49
  "@react-aria/ssr": "3.1.0",
49
50
  "@styled-system/css": "5.1.5",
50
51
  "@styled-system/props": "5.1.5",