@primer/components 0.0.0-2021104225742 → 0.0.0-20211081215

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.
Files changed (114) hide show
  1. package/CHANGELOG.md +3 -5
  2. package/dist/browser.esm.js +473 -471
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +104 -102
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Description.d.ts +12 -0
  7. package/lib/ActionList2/Description.js +53 -0
  8. package/lib/ActionList2/Divider.d.ts +5 -0
  9. package/lib/ActionList2/Divider.js +35 -0
  10. package/lib/ActionList2/Group.d.ts +11 -0
  11. package/lib/ActionList2/Group.js +57 -0
  12. package/lib/ActionList2/Header.d.ts +26 -0
  13. package/lib/ActionList2/Header.js +55 -0
  14. package/lib/ActionList2/Item.d.ts +71 -0
  15. package/lib/ActionList2/Item.js +234 -0
  16. package/lib/ActionList2/LinkItem.d.ts +17 -0
  17. package/lib/ActionList2/LinkItem.js +57 -0
  18. package/lib/ActionList2/List.d.ts +26 -0
  19. package/lib/ActionList2/List.js +59 -0
  20. package/lib/ActionList2/Selection.d.ts +5 -0
  21. package/lib/ActionList2/Selection.js +70 -0
  22. package/lib/ActionList2/Visuals.d.ts +11 -0
  23. package/lib/ActionList2/Visuals.js +90 -0
  24. package/lib/ActionList2/index.d.ts +40 -0
  25. package/lib/ActionList2/index.js +47 -0
  26. package/lib/Autocomplete/Autocomplete.d.ts +28 -28
  27. package/lib/Autocomplete/AutocompleteInput.d.ts +28 -28
  28. package/lib/Button/Button.d.ts +25 -25
  29. package/lib/Button/ButtonClose.d.ts +45 -45
  30. package/lib/Button/ButtonDanger.d.ts +25 -25
  31. package/lib/Button/ButtonInvisible.d.ts +25 -25
  32. package/lib/Button/ButtonOutline.d.ts +25 -25
  33. package/lib/Button/ButtonPrimary.d.ts +25 -25
  34. package/lib/CircleOcticon.d.ts +42 -42
  35. package/lib/Dialog.d.ts +45 -45
  36. package/lib/Dropdown.d.ts +176 -176
  37. package/lib/DropdownMenu/DropdownButton.d.ts +46 -46
  38. package/lib/FilterList.d.ts +42 -42
  39. package/lib/Position.d.ts +4 -4
  40. package/lib/SelectMenu/SelectMenu.d.ts +246 -246
  41. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  42. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  43. package/lib/TextInputWithTokens.d.ts +28 -28
  44. package/lib/Timeline.d.ts +43 -43
  45. package/lib/Token/AvatarToken.d.ts +1 -1
  46. package/lib/Token/IssueLabelToken.d.ts +1 -1
  47. package/lib/Token/Token.d.ts +1 -1
  48. package/lib/Truncate.d.ts +2 -1
  49. package/lib/Truncate.js +3 -1
  50. package/lib/experiments.d.ts +1 -0
  51. package/lib/experiments.js +18 -0
  52. package/lib/sx.d.ts +2 -0
  53. package/lib/sx.js +8 -0
  54. package/lib/theme-preval.js +81 -2
  55. package/lib/utils/create-slots.d.ts +17 -0
  56. package/lib/utils/create-slots.js +105 -0
  57. package/lib/utils/testing.d.ts +14 -1
  58. package/lib/utils/use-force-update.d.ts +1 -0
  59. package/lib/utils/use-force-update.js +19 -0
  60. package/lib-esm/ActionList2/Description.d.ts +12 -0
  61. package/lib-esm/ActionList2/Description.js +37 -0
  62. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  63. package/lib-esm/ActionList2/Divider.js +23 -0
  64. package/lib-esm/ActionList2/Group.d.ts +11 -0
  65. package/lib-esm/ActionList2/Group.js +40 -0
  66. package/lib-esm/ActionList2/Header.d.ts +26 -0
  67. package/lib-esm/ActionList2/Header.js +44 -0
  68. package/lib-esm/ActionList2/Item.d.ts +71 -0
  69. package/lib-esm/ActionList2/Item.js +201 -0
  70. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  71. package/lib-esm/ActionList2/LinkItem.js +43 -0
  72. package/lib-esm/ActionList2/List.d.ts +26 -0
  73. package/lib-esm/ActionList2/List.js +37 -0
  74. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  75. package/lib-esm/ActionList2/Selection.js +52 -0
  76. package/lib-esm/ActionList2/Visuals.d.ts +11 -0
  77. package/lib-esm/ActionList2/Visuals.js +68 -0
  78. package/lib-esm/ActionList2/index.d.ts +40 -0
  79. package/lib-esm/ActionList2/index.js +33 -0
  80. package/lib-esm/Autocomplete/Autocomplete.d.ts +28 -28
  81. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +28 -28
  82. package/lib-esm/Button/Button.d.ts +25 -25
  83. package/lib-esm/Button/ButtonClose.d.ts +45 -45
  84. package/lib-esm/Button/ButtonDanger.d.ts +25 -25
  85. package/lib-esm/Button/ButtonInvisible.d.ts +25 -25
  86. package/lib-esm/Button/ButtonOutline.d.ts +25 -25
  87. package/lib-esm/Button/ButtonPrimary.d.ts +25 -25
  88. package/lib-esm/CircleOcticon.d.ts +42 -42
  89. package/lib-esm/Dialog.d.ts +45 -45
  90. package/lib-esm/Dropdown.d.ts +176 -176
  91. package/lib-esm/DropdownMenu/DropdownButton.d.ts +46 -46
  92. package/lib-esm/FilterList.d.ts +42 -42
  93. package/lib-esm/Position.d.ts +4 -4
  94. package/lib-esm/SelectMenu/SelectMenu.d.ts +246 -246
  95. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  96. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  97. package/lib-esm/TextInputWithTokens.d.ts +28 -28
  98. package/lib-esm/Timeline.d.ts +43 -43
  99. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  100. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  101. package/lib-esm/Token/Token.d.ts +1 -1
  102. package/lib-esm/Truncate.d.ts +2 -1
  103. package/lib-esm/Truncate.js +2 -1
  104. package/lib-esm/experiments.d.ts +1 -0
  105. package/lib-esm/experiments.js +2 -0
  106. package/lib-esm/sx.d.ts +2 -0
  107. package/lib-esm/sx.js +3 -1
  108. package/lib-esm/theme-preval.js +81 -2
  109. package/lib-esm/utils/create-slots.d.ts +17 -0
  110. package/lib-esm/utils/create-slots.js +84 -0
  111. package/lib-esm/utils/testing.d.ts +14 -1
  112. package/lib-esm/utils/use-force-update.d.ts +1 -0
  113. package/lib-esm/utils/use-force-update.js +6 -0
  114. package/package.json +4 -2
@@ -0,0 +1,201 @@
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 { useSSRSafeId } from '@react-aria/ssr';
5
+ import styled from 'styled-components';
6
+ import { useTheme } from '../ThemeProvider';
7
+ import Box from '../Box';
8
+ import sx, { merge } from '../sx';
9
+ import createSlots from '../utils/create-slots';
10
+ import { ListContext } from './List';
11
+ import { Selection } from './Selection';
12
+ export const getVariantStyles = (variant, disabled) => {
13
+ if (disabled) {
14
+ return {
15
+ color: 'fg.muted',
16
+ iconColor: 'fg.muted',
17
+ annotationColor: 'fg.muted'
18
+ };
19
+ }
20
+
21
+ switch (variant) {
22
+ case 'danger':
23
+ return {
24
+ color: 'danger.fg',
25
+ iconColor: 'danger.fg',
26
+ annotationColor: 'fg.muted',
27
+ hoverColor: 'actionListItem.danger.hoverText'
28
+ };
29
+
30
+ default:
31
+ return {
32
+ color: 'fg.default',
33
+ iconColor: 'fg.muted',
34
+ annotationColor: 'fg.muted',
35
+ hoverColor: 'fg.default',
36
+ selectedBg: 'actionListItem.default.selectedBg'
37
+ };
38
+ }
39
+ };
40
+ const {
41
+ Slots,
42
+ Slot
43
+ } = createSlots(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
44
+ export { Slot };
45
+ const LiBox = styled.li.withConfig({
46
+ displayName: "Item__LiBox",
47
+ componentId: "c3scat-0"
48
+ })(sx);
49
+ export const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
50
+
51
+ export const Item = /*#__PURE__*/React.forwardRef(({
52
+ variant = 'default',
53
+ disabled = false,
54
+ selected = undefined,
55
+ onSelect = () => null,
56
+ sx: propsSx = {},
57
+ id,
58
+ _PrivateItemWrapper = ({
59
+ children
60
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, children),
61
+ ...props
62
+ }, forwardedRef) => {
63
+ const {
64
+ variant: listVariant,
65
+ showDividers
66
+ } = React.useContext(ListContext);
67
+ const {
68
+ theme
69
+ } = useTheme();
70
+ const styles = {
71
+ display: 'flex',
72
+ paddingX: 2,
73
+ fontSize: 1,
74
+ paddingY: '6px',
75
+ // custom value off the scale
76
+ lineHeight: TEXT_ROW_HEIGHT,
77
+ marginX: listVariant === 'inset' ? 2 : 0,
78
+ minHeight: 5,
79
+ borderRadius: 2,
80
+ transition: 'background 33.333ms linear',
81
+ color: getVariantStyles(variant, disabled).color,
82
+ textDecoration: 'none',
83
+ // for as="a"
84
+ '&[aria-selected=true]': {
85
+ backgroundColor: getVariantStyles(variant, disabled).selectedBg
86
+ },
87
+ ':not([aria-disabled])': {
88
+ cursor: 'pointer'
89
+ },
90
+ '@media (hover: hover) and (pointer: fine)': {
91
+ ':hover:not([aria-disabled])': {
92
+ backgroundColor: `actionListItem.${variant}.hoverBg`,
93
+ color: getVariantStyles(variant, disabled).hoverColor
94
+ },
95
+ ':focus:not([aria-disabled])': {
96
+ backgroundColor: `actionListItem.${variant}.activeBg`,
97
+ color: getVariantStyles(variant, disabled).hoverColor,
98
+ outline: 'none'
99
+ }
100
+ },
101
+
102
+ /** Divider styles */
103
+ '[data-component="ActionList.Item--DividerContainer"]': {
104
+ position: 'relative'
105
+ },
106
+ '[data-component="ActionList.Item--DividerContainer"]::before': {
107
+ content: '" "',
108
+ display: 'block',
109
+ position: 'absolute',
110
+ width: '100%',
111
+ top: '-7px',
112
+ border: '0 solid',
113
+ borderTopWidth: showDividers ? `1px` : '0',
114
+ borderColor: 'var(--divider-color, transparent)'
115
+ },
116
+ // show between 2 items
117
+ ':not(:first-of-type):not([aria-selected=true])': {
118
+ '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
119
+ },
120
+ // hide divider after dividers & group header, with higher importance!
121
+ '[data-component="ActionList.Divider"] + &': {
122
+ '--divider-color': 'transparent !important'
123
+ },
124
+ // hide border on current and previous item
125
+ '&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
126
+ '--divider-color': 'transparent'
127
+ },
128
+ '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
129
+ '--divider-color': 'transparent'
130
+ },
131
+ // hide border around selected item
132
+ '&[aria-selected=true] + &': {
133
+ '--divider-color': 'transparent'
134
+ }
135
+ };
136
+ const clickHandler = React.useCallback(event => {
137
+ if (disabled) return;
138
+ if (!event.defaultPrevented) onSelect(event);
139
+ }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
140
+
141
+ const labelId = useSSRSafeId(id);
142
+ const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
143
+ const blockDescriptionId = useSSRSafeId(id && `${id}--block-description`);
144
+ return /*#__PURE__*/React.createElement(Slots, {
145
+ context: {
146
+ variant,
147
+ disabled,
148
+ inlineDescriptionId,
149
+ blockDescriptionId
150
+ }
151
+ }, slots => /*#__PURE__*/React.createElement(LiBox, _extends({
152
+ ref: forwardedRef,
153
+ sx: merge(styles, propsSx),
154
+ onClick: clickHandler,
155
+ "aria-selected": selected,
156
+ "aria-disabled": disabled ? true : undefined,
157
+ tabIndex: disabled ? undefined : -1,
158
+ "aria-labelledby": labelId,
159
+ "aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
160
+ }, props), /*#__PURE__*/React.createElement(_PrivateItemWrapper, null, /*#__PURE__*/React.createElement(Selection, {
161
+ selected: selected,
162
+ disabled: disabled
163
+ }), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
164
+ "data-component": "ActionList.Item--DividerContainer",
165
+ sx: {
166
+ display: 'flex',
167
+ flexDirection: 'column',
168
+ flexGrow: 1,
169
+ minWidth: 0
170
+ }
171
+ }, /*#__PURE__*/React.createElement(ConditionalBox, {
172
+ if: Boolean(slots.TrailingVisual),
173
+ sx: {
174
+ display: 'flex',
175
+ flexGrow: 1
176
+ }
177
+ }, /*#__PURE__*/React.createElement(ConditionalBox, {
178
+ if: Boolean(slots.InlineDescription),
179
+ sx: {
180
+ display: 'flex',
181
+ flexGrow: 1,
182
+ alignItems: 'baseline',
183
+ minWidth: 0
184
+ }
185
+ }, /*#__PURE__*/React.createElement(Box, {
186
+ as: "span",
187
+ id: labelId,
188
+ sx: {
189
+ flexGrow: slots.InlineDescription ? 0 : 1
190
+ }
191
+ }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
192
+ });
193
+ Item.displayName = 'ActionList.Item';
194
+
195
+ const ConditionalBox = props => {
196
+ const {
197
+ if: condition,
198
+ ...rest
199
+ } = props;
200
+ if (condition) return /*#__PURE__*/React.createElement(Box, rest, props.children);else return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
201
+ };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ import { ItemProps } from './Item';
4
+ declare type LinkProps = {
5
+ download?: string;
6
+ href?: string;
7
+ hrefLang?: string;
8
+ media?: string;
9
+ ping?: string;
10
+ rel?: string;
11
+ target?: string;
12
+ type?: string;
13
+ referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>['referrerPolicy'];
14
+ };
15
+ declare type LinkItemProps = Pick<ItemProps, 'children' | 'sx'> & LinkProps;
16
+ export declare const LinkItem: PolymorphicForwardRefComponent<"a", LinkItemProps>;
17
+ export {};
@@ -0,0 +1,43 @@
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 Link from '../Link';
5
+ import { merge } from '../sx';
6
+ import { Item } from './Item'; // adopted from React.AnchorHTMLAttributes
7
+
8
+ export const LinkItem = /*#__PURE__*/React.forwardRef(({
9
+ sx = {},
10
+ as: Component,
11
+ ...props
12
+ }, forwardedRef) => {
13
+ const styles = {
14
+ // occupy full size of Item
15
+ paddingX: 2,
16
+ paddingY: '6px',
17
+ // custom value off the scale
18
+ display: 'flex',
19
+ flexGrow: 1,
20
+ // full width
21
+ borderRadius: 2,
22
+ // inherit Item styles
23
+ color: 'inherit',
24
+ '&:hover': {
25
+ color: 'inherit',
26
+ textDecoration: 'none'
27
+ }
28
+ };
29
+ return /*#__PURE__*/React.createElement(Item, {
30
+ sx: {
31
+ paddingY: 0,
32
+ paddingX: 0
33
+ },
34
+ _PrivateItemWrapper: ({
35
+ children
36
+ }) => /*#__PURE__*/React.createElement(Link, _extends({
37
+ as: Component,
38
+ sx: merge(styles, sx)
39
+ }, props, {
40
+ ref: forwardedRef
41
+ }), children)
42
+ }, props.children);
43
+ });
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ import { SxProp } from '../sx';
4
+ import { AriaRole } from '../utils/types';
5
+ export declare type ListProps = {
6
+ /**
7
+ * `inset` children are offset (vertically and horizontally) from `List`’s edges, `full` children are flush (vertically and horizontally) with `List` edges
8
+ */
9
+ variant?: 'inset' | 'full';
10
+ /**
11
+ * Whether multiple Items or a single Item can be selected.
12
+ */
13
+ selectionVariant?: 'single' | 'multiple';
14
+ /**
15
+ * Display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`.
16
+ */
17
+ showDividers?: boolean;
18
+ /**
19
+ * The ARIA role describing the function of `List` component. `listbox` or `menu` are a common values.
20
+ */
21
+ role?: AriaRole;
22
+ } & SxProp;
23
+ declare type ContextProps = Omit<ListProps, 'sx'>;
24
+ export declare const ListContext: React.Context<ContextProps>;
25
+ export declare const List: PolymorphicForwardRefComponent<"ul", ListProps>;
26
+ export {};
@@ -0,0 +1,37 @@
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 styled from 'styled-components';
5
+ import sx, { merge } from '../sx';
6
+ export const ListContext = /*#__PURE__*/React.createContext({});
7
+ const ListBox = styled.ul.withConfig({
8
+ displayName: "List__ListBox",
9
+ componentId: "cvbq60-0"
10
+ })(sx);
11
+ export const List = /*#__PURE__*/React.forwardRef(({
12
+ variant = 'inset',
13
+ selectionVariant,
14
+ showDividers = false,
15
+ sx: propsSx = {},
16
+ ...props
17
+ }, forwardedRef) => {
18
+ const styles = {
19
+ margin: 0,
20
+ paddingInlineStart: 0,
21
+ // reset ul styles
22
+ paddingY: variant === 'inset' ? 2 : 0
23
+ };
24
+ return /*#__PURE__*/React.createElement(ListBox, _extends({
25
+ sx: merge(styles, propsSx),
26
+ "aria-multiselectable": selectionVariant === 'multiple' ? true : undefined
27
+ }, props, {
28
+ ref: forwardedRef
29
+ }), /*#__PURE__*/React.createElement(ListContext.Provider, {
30
+ value: {
31
+ variant,
32
+ selectionVariant,
33
+ showDividers
34
+ }
35
+ }, props.children));
36
+ });
37
+ List.displayName = 'ActionList';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ItemProps } from './Item';
3
+ declare type SelectionProps = Pick<ItemProps, 'selected' | 'disabled'>;
4
+ export declare const Selection: React.FC<SelectionProps>;
5
+ export {};
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { CheckIcon } from '@primer/octicons-react';
3
+ import { ListContext } from './List';
4
+ import { GroupContext } from './Group';
5
+ import { LeadingVisualContainer } from './Visuals';
6
+ export const Selection = ({
7
+ selected,
8
+ disabled
9
+ }) => {
10
+ const {
11
+ selectionVariant: listSelectionVariant
12
+ } = React.useContext(ListContext);
13
+ const {
14
+ selectionVariant: groupSelectionVariant
15
+ } = React.useContext(GroupContext);
16
+ /** selectionVariant in Group can override the selectionVariant in List root */
17
+
18
+ const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
19
+
20
+ if (!selectionVariant) {
21
+ // to avoid confusion, fail loudly instead of silently ignoring
22
+ if (selected) throw new Error('For Item to be selected, ActionList or ActionList.Group needs to have a selectionVariant defined');
23
+ return null;
24
+ }
25
+
26
+ if (selectionVariant === 'single') {
27
+ return /*#__PURE__*/React.createElement(LeadingVisualContainer, null, selected && /*#__PURE__*/React.createElement(CheckIcon, null));
28
+ }
29
+ /**
30
+ * selectionVariant is multiple
31
+ * readOnly is required because we are doing a one-way bind to `checked`
32
+ * aria-readonly="false" tells screen that they can still interact with the checkbox
33
+ */
34
+
35
+
36
+ return /*#__PURE__*/React.createElement(LeadingVisualContainer, {
37
+ sx: {
38
+ input: {
39
+ margin: 0,
40
+ pointerEvents: 'none'
41
+ }
42
+ }
43
+ }, /*#__PURE__*/React.createElement("input", {
44
+ type: "checkbox",
45
+ checked: selected,
46
+ disabled: disabled,
47
+ tabIndex: -1,
48
+ readOnly: true,
49
+ "aria-readonly": "false"
50
+ }));
51
+ };
52
+ Selection.displayName = "Selection";
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ declare type VisualProps = SxProp & {
4
+ children: React.ReactNode;
5
+ };
6
+ export declare const LeadingVisualContainer: React.FC<SxProp>;
7
+ export declare type LeadingVisualProps = VisualProps;
8
+ export declare const LeadingVisual: React.FC<VisualProps>;
9
+ export declare type TrailingVisualProps = VisualProps;
10
+ export declare const TrailingVisual: React.FC<VisualProps>;
11
+ export {};
@@ -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, TEXT_ROW_HEIGHT } 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: TEXT_ROW_HEIGHT,
16
+ // match height of text row
17
+ minWidth: get('space.3'),
18
+ maxWidth: TEXT_ROW_HEIGHT,
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,40 @@
1
+ /// <reference types="react" />
2
+ import { Divider } from './Divider';
3
+ export type { ListProps as ActionListProps } from './List';
4
+ export type { GroupProps } from './Group';
5
+ export type { ItemProps } from './Item';
6
+ export type { DescriptionProps } from './Description';
7
+ export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
8
+ /**
9
+ * Collection of list-related components.
10
+ */
11
+ export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
12
+ /** Collects related `Items` in an `ActionList`. */
13
+ Group: import("react").FC<import("./Group").GroupProps>;
14
+ /** An actionable or selectable `Item` */
15
+ Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
16
+ /** A `Item` that renders a full-size anchor inside ListItem */
17
+ LinkItem: import("@radix-ui/react-polymorphic").ForwardRefComponent<"a", Pick<import("./Item").ItemProps, "children" | "sx"> & {
18
+ download?: string | undefined;
19
+ href?: string | undefined;
20
+ hrefLang?: string | undefined;
21
+ media?: string | undefined;
22
+ ping?: string | undefined;
23
+ rel?: string | undefined;
24
+ target?: string | undefined;
25
+ type?: string | undefined;
26
+ referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
27
+ }>;
28
+ /** Visually separates `Item`s or `Group`s in an `ActionList`. */
29
+ Divider: typeof Divider;
30
+ /** Secondary text which provides additional information about an `Item`. */
31
+ Description: import("react").FC<import("./Description").DescriptionProps>;
32
+ /** Icon (or similar) positioned before `Item` text. */
33
+ LeadingVisual: import("react").FC<import("../sx").SxProp & {
34
+ children: import("react").ReactNode;
35
+ }>;
36
+ /** Icon (or similar) positioned after `Item` text. */
37
+ TrailingVisual: import("react").FC<import("../sx").SxProp & {
38
+ children: import("react").ReactNode;
39
+ }>;
40
+ };
@@ -0,0 +1,33 @@
1
+ import { List } from './List';
2
+ import { Group } from './Group';
3
+ import { Item } from './Item';
4
+ import { LinkItem } from './LinkItem';
5
+ import { Divider } from './Divider';
6
+ import { Description } from './Description';
7
+ import { LeadingVisual, TrailingVisual } from './Visuals';
8
+
9
+ /**
10
+ * Collection of list-related components.
11
+ */
12
+ export const ActionList = Object.assign(List, {
13
+ /** Collects related `Items` in an `ActionList`. */
14
+ Group,
15
+
16
+ /** An actionable or selectable `Item` */
17
+ Item,
18
+
19
+ /** A `Item` that renders a full-size anchor inside ListItem */
20
+ LinkItem,
21
+
22
+ /** Visually separates `Item`s or `Group`s in an `ActionList`. */
23
+ Divider,
24
+
25
+ /** Secondary text which provides additional information about an `Item`. */
26
+ Description,
27
+
28
+ /** Icon (or similar) positioned before `Item` text. */
29
+ LeadingVisual,
30
+
31
+ /** Icon (or similar) positioned after `Item` text. */
32
+ TrailingVisual
33
+ });