@primer/components 31.2.0-rc.5ccefd7d → 31.2.0-rc.6afeaa37

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 (143) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/browser.esm.js +622 -620
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +163 -161
  5. package/dist/browser.umd.js.map +1 -1
  6. package/docs/content/ActionList2.mdx +354 -0
  7. package/docs/content/getting-started.md +1 -1
  8. package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +1 -3
  9. package/docs/src/@primer/gatsby-theme-doctocat/components/live-preview-wrapper.js +1 -1
  10. package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +17 -0
  11. package/lib/ActionList2/Description.d.ts +12 -0
  12. package/lib/ActionList2/Description.js +53 -0
  13. package/lib/ActionList2/Divider.d.ts +5 -0
  14. package/lib/ActionList2/Divider.js +35 -0
  15. package/lib/ActionList2/Group.d.ts +11 -0
  16. package/lib/ActionList2/Group.js +57 -0
  17. package/lib/ActionList2/Header.d.ts +26 -0
  18. package/lib/ActionList2/Header.js +55 -0
  19. package/lib/ActionList2/Item.d.ts +63 -0
  20. package/lib/ActionList2/Item.js +244 -0
  21. package/lib/ActionList2/LinkItem.d.ts +17 -0
  22. package/lib/ActionList2/LinkItem.js +57 -0
  23. package/lib/ActionList2/List.d.ts +26 -0
  24. package/lib/ActionList2/List.js +59 -0
  25. package/lib/ActionList2/Selection.d.ts +5 -0
  26. package/lib/ActionList2/Selection.js +70 -0
  27. package/lib/ActionList2/Visuals.d.ts +9 -0
  28. package/lib/ActionList2/Visuals.js +90 -0
  29. package/lib/ActionList2/index.d.ts +36 -0
  30. package/lib/ActionList2/index.js +47 -0
  31. package/lib/Overlay.js +3 -1
  32. package/lib/Portal/Portal.js +3 -2
  33. package/lib/_TextInputWrapper.js +2 -2
  34. package/lib/__tests__/ActionList2.test.d.ts +1 -0
  35. package/lib/__tests__/ActionList2.test.js +53 -0
  36. package/lib/__tests__/AnchoredOverlay.test.js +4 -2
  37. package/lib/__tests__/TextInputWithTokens.test.js +1 -10
  38. package/lib/__tests__/utils/createSlots.test.d.ts +1 -0
  39. package/lib/__tests__/utils/createSlots.test.js +75 -0
  40. package/lib/hooks/useAnchoredPosition.js +3 -2
  41. package/lib/hooks/useCombinedRefs.d.ts +2 -2
  42. package/lib/hooks/useCombinedRefs.js +4 -6
  43. package/lib/hooks/useResizeObserver.js +2 -2
  44. package/lib/stories/ActionList2.stories.js +907 -0
  45. package/lib/stories/TextInput.stories.js +144 -0
  46. package/lib/stories/Token.stories.js +19 -2
  47. package/lib/sx.d.ts +2 -0
  48. package/lib/sx.js +8 -0
  49. package/lib/theme-preval.js +81 -2
  50. package/lib/unreleased.d.ts +7 -0
  51. package/lib/unreleased.js +18 -0
  52. package/lib/utils/create-slots.d.ts +17 -0
  53. package/lib/utils/create-slots.js +105 -0
  54. package/lib/utils/testing.d.ts +14 -1
  55. package/lib/utils/use-force-update.d.ts +1 -0
  56. package/lib/utils/use-force-update.js +19 -0
  57. package/lib/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  58. package/lib/utils/useIsomorphicLayoutEffect.js +12 -0
  59. package/lib-esm/ActionList2/Description.d.ts +12 -0
  60. package/lib-esm/ActionList2/Description.js +37 -0
  61. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  62. package/lib-esm/ActionList2/Divider.js +23 -0
  63. package/lib-esm/ActionList2/Group.d.ts +11 -0
  64. package/lib-esm/ActionList2/Group.js +40 -0
  65. package/lib-esm/ActionList2/Header.d.ts +26 -0
  66. package/lib-esm/ActionList2/Header.js +44 -0
  67. package/lib-esm/ActionList2/Item.d.ts +63 -0
  68. package/lib-esm/ActionList2/Item.js +210 -0
  69. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  70. package/lib-esm/ActionList2/LinkItem.js +43 -0
  71. package/lib-esm/ActionList2/List.d.ts +26 -0
  72. package/lib-esm/ActionList2/List.js +37 -0
  73. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  74. package/lib-esm/ActionList2/Selection.js +52 -0
  75. package/lib-esm/ActionList2/Visuals.d.ts +9 -0
  76. package/lib-esm/ActionList2/Visuals.js +68 -0
  77. package/lib-esm/ActionList2/index.d.ts +36 -0
  78. package/lib-esm/ActionList2/index.js +33 -0
  79. package/lib-esm/Overlay.js +2 -1
  80. package/lib-esm/Portal/Portal.js +2 -1
  81. package/lib-esm/_TextInputWrapper.js +2 -2
  82. package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
  83. package/lib-esm/__tests__/ActionList2.test.js +41 -0
  84. package/lib-esm/__tests__/AnchoredOverlay.test.js +4 -2
  85. package/lib-esm/__tests__/TextInputWithTokens.test.js +1 -10
  86. package/lib-esm/__tests__/utils/createSlots.test.d.ts +1 -0
  87. package/lib-esm/__tests__/utils/createSlots.test.js +67 -0
  88. package/lib-esm/hooks/useAnchoredPosition.js +2 -1
  89. package/lib-esm/hooks/useCombinedRefs.d.ts +2 -2
  90. package/lib-esm/hooks/useCombinedRefs.js +3 -2
  91. package/lib-esm/hooks/useResizeObserver.js +2 -2
  92. package/lib-esm/stories/ActionList2.stories.js +796 -0
  93. package/lib-esm/stories/TextInput.stories.js +117 -0
  94. package/lib-esm/stories/Token.stories.js +14 -1
  95. package/lib-esm/sx.d.ts +2 -0
  96. package/lib-esm/sx.js +3 -1
  97. package/lib-esm/theme-preval.js +81 -2
  98. package/lib-esm/unreleased.d.ts +7 -0
  99. package/lib-esm/unreleased.js +8 -0
  100. package/lib-esm/utils/create-slots.d.ts +17 -0
  101. package/lib-esm/utils/create-slots.js +84 -0
  102. package/lib-esm/utils/testing.d.ts +14 -1
  103. package/lib-esm/utils/use-force-update.d.ts +1 -0
  104. package/lib-esm/utils/use-force-update.js +6 -0
  105. package/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  106. package/lib-esm/utils/useIsomorphicLayoutEffect.js +3 -0
  107. package/migrating.md +1 -1
  108. package/package-lock.json +146 -7
  109. package/package.json +5 -3
  110. package/script/build +2 -0
  111. package/src/ActionList2/Description.tsx +49 -0
  112. package/src/ActionList2/Divider.tsx +24 -0
  113. package/src/ActionList2/Group.tsx +34 -0
  114. package/src/ActionList2/Header.tsx +58 -0
  115. package/src/ActionList2/Item.tsx +245 -0
  116. package/src/ActionList2/LinkItem.tsx +49 -0
  117. package/src/ActionList2/List.tsx +55 -0
  118. package/src/ActionList2/Selection.tsx +40 -0
  119. package/src/ActionList2/Visuals.tsx +76 -0
  120. package/src/ActionList2/index.ts +39 -0
  121. package/src/Overlay.tsx +2 -1
  122. package/src/Portal/Portal.tsx +2 -1
  123. package/src/_TextInputWrapper.tsx +7 -0
  124. package/src/__tests__/ActionList2.test.tsx +47 -0
  125. package/src/__tests__/AnchoredOverlay.test.tsx +2 -2
  126. package/src/__tests__/TextInputWithTokens.test.tsx +0 -10
  127. package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
  128. package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +35 -135
  129. package/src/__tests__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
  130. package/src/__tests__/utils/createSlots.test.tsx +74 -0
  131. package/src/hooks/useAnchoredPosition.ts +2 -1
  132. package/src/hooks/useCombinedRefs.ts +3 -3
  133. package/src/hooks/useResizeObserver.ts +2 -2
  134. package/src/stories/ActionList2.stories.tsx +1288 -0
  135. package/src/stories/TextInput.stories.tsx +113 -0
  136. package/src/stories/Token.stories.tsx +12 -1
  137. package/src/sx.ts +3 -0
  138. package/src/theme-preval.js +1 -0
  139. package/src/unreleased.ts +9 -0
  140. package/src/utils/create-slots.tsx +96 -0
  141. package/src/utils/use-force-update.ts +7 -0
  142. package/src/utils/useIsomorphicLayoutEffect.ts +10 -0
  143. package/stats.html +1 -1
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ import { HeaderProps } from './Header';
4
+ import { ListProps } from './List';
5
+ export declare type GroupProps = HeaderProps & SxProp & {
6
+ selectionVariant?: ListProps['selectionVariant'] | false;
7
+ };
8
+ declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
9
+ export declare const GroupContext: React.Context<ContextProps>;
10
+ export declare const Group: React.FC<GroupProps>;
11
+ export {};
@@ -0,0 +1,40 @@
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 { Header } from './Header';
6
+ export const GroupContext = /*#__PURE__*/React.createContext({});
7
+ export const Group = ({
8
+ title,
9
+ variant,
10
+ auxiliaryText,
11
+ selectionVariant,
12
+ sx = {},
13
+ ...props
14
+ }) => {
15
+ return /*#__PURE__*/React.createElement(Box, _extends({
16
+ as: "li",
17
+ sx: {
18
+ '&:not(:first-child)': {
19
+ marginTop: 2
20
+ },
21
+ listStyle: 'none',
22
+ // hide the ::marker inserted by browser's stylesheet
23
+ ...sx
24
+ }
25
+ }, props), title && /*#__PURE__*/React.createElement(Header, {
26
+ title: title,
27
+ variant: variant,
28
+ auxiliaryText: auxiliaryText
29
+ }), /*#__PURE__*/React.createElement(GroupContext.Provider, {
30
+ value: {
31
+ selectionVariant
32
+ }
33
+ }, /*#__PURE__*/React.createElement(Box, {
34
+ as: "ul",
35
+ sx: {
36
+ paddingInlineStart: 0
37
+ }
38
+ }, props.children)));
39
+ };
40
+ Group.displayName = "Group";
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import { SxProp } from '../sx';
3
+ /**
4
+ * Contract for props passed to the `Header` component.
5
+ */
6
+ export declare type HeaderProps = {
7
+ /**
8
+ * Style variations. Usage is discretionary.
9
+ *
10
+ * - `"filled"` - Superimposed on a background, offset from nearby content
11
+ * - `"subtle"` - Relatively less offset from nearby content
12
+ */
13
+ variant?: 'subtle' | 'filled';
14
+ /**
15
+ * Primary text which names a `Group`.
16
+ */
17
+ title?: string;
18
+ /**
19
+ * Secondary text which provides additional information about a `Group`.
20
+ */
21
+ auxiliaryText?: string;
22
+ } & SxProp;
23
+ /**
24
+ * Displays the name and description of a `Group`.
25
+ */
26
+ export declare const Header: ({ variant, title, auxiliaryText, sx, ...props }: HeaderProps) => JSX.Element;
@@ -0,0 +1,44 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import Box from '../Box';
5
+ import { ListContext } from './List';
6
+ /**
7
+ * Contract for props passed to the `Header` component.
8
+ */
9
+
10
+ /**
11
+ * Displays the name and description of a `Group`.
12
+ */
13
+ export const Header = ({
14
+ variant = 'subtle',
15
+ title,
16
+ auxiliaryText,
17
+ sx = {},
18
+ ...props
19
+ }) => {
20
+ const {
21
+ variant: listVariant
22
+ } = React.useContext(ListContext);
23
+ const styles = {
24
+ paddingY: '6px',
25
+ paddingX: listVariant === 'full' ? 2 : 3,
26
+ fontSize: 0,
27
+ fontWeight: 'bold',
28
+ color: 'fg.muted',
29
+ ...(variant === 'filled' && {
30
+ backgroundColor: 'canvas.subtle',
31
+ marginX: 0,
32
+ marginBottom: 2,
33
+ borderTop: '1px solid',
34
+ borderBottom: '1px solid',
35
+ borderColor: 'neutral.muted'
36
+ }),
37
+ ...sx
38
+ };
39
+ return /*#__PURE__*/React.createElement(Box, _extends({
40
+ sx: styles,
41
+ role: "heading"
42
+ }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
43
+ };
44
+ Header.displayName = "Header";
@@ -0,0 +1,63 @@
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 const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
6
+ color: string;
7
+ iconColor: string;
8
+ annotationColor: string;
9
+ hoverColor?: undefined;
10
+ } | {
11
+ color: string;
12
+ iconColor: string;
13
+ annotationColor: string;
14
+ hoverColor: string;
15
+ };
16
+ export declare type ItemProps = {
17
+ /**
18
+ * Primary content for an Item
19
+ */
20
+ children?: React.ReactNode;
21
+ /**
22
+ * Callback that will trigger both on click selection and keyboard selection.
23
+ */
24
+ onSelect?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
25
+ /**
26
+ * Is the `Item` is currently selected?
27
+ */
28
+ selected?: boolean;
29
+ /**
30
+ * Style variations associated with various `Item` types.
31
+ *
32
+ * - `"default"` - An action `Item`.
33
+ * - `"danger"` - A destructive action `Item`.
34
+ */
35
+ variant?: 'default' | 'danger';
36
+ /**
37
+ * Items that are disabled can not be clicked, selected, or navigated through.
38
+ */
39
+ disabled?: boolean;
40
+ /**
41
+ * The ARIA role describing the function of `Item` component. `option` is a common value.
42
+ */
43
+ role?: AriaRole;
44
+ /**
45
+ * id to attach to the root element of the Item
46
+ */
47
+ id?: string;
48
+ /**
49
+ * Private API for use internally only. Used by LinkItem to wrap contents in an anchor
50
+ */
51
+ _PrivateItemWrapper?: React.FC;
52
+ } & SxProp;
53
+ declare const Slot: React.FC<{
54
+ name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
55
+ children: React.ReactNode;
56
+ }>;
57
+ export { Slot };
58
+ export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
59
+ inlineDescriptionId: string;
60
+ blockDescriptionId: string;
61
+ };
62
+ export declare const TEXT_ROW_HEIGHT = "20px";
63
+ export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
@@ -0,0 +1,210 @@
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
+ };
37
+ }
38
+ };
39
+ const {
40
+ Slots,
41
+ Slot
42
+ } = createSlots(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
43
+ export { Slot };
44
+ const LiBox = styled.li.withConfig({
45
+ displayName: "Item__LiBox",
46
+ componentId: "c3scat-0"
47
+ })(sx);
48
+ export const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
49
+
50
+ export const Item = /*#__PURE__*/React.forwardRef(({
51
+ variant = 'default',
52
+ disabled = false,
53
+ selected = undefined,
54
+ onSelect = () => null,
55
+ sx: sxProp = {},
56
+ id,
57
+ _PrivateItemWrapper,
58
+ ...props
59
+ }, forwardedRef) => {
60
+ const {
61
+ variant: listVariant,
62
+ showDividers
63
+ } = React.useContext(ListContext);
64
+ const {
65
+ theme
66
+ } = useTheme();
67
+ const styles = {
68
+ display: 'flex',
69
+ paddingX: 2,
70
+ fontSize: 1,
71
+ paddingY: '6px',
72
+ // custom value off the scale
73
+ lineHeight: TEXT_ROW_HEIGHT,
74
+ minHeight: 5,
75
+ marginX: listVariant === 'inset' ? 2 : 0,
76
+ borderRadius: listVariant === 'inset' ? 2 : 0,
77
+ transition: 'background 33.333ms linear',
78
+ color: getVariantStyles(variant, disabled).color,
79
+ textDecoration: 'none',
80
+ // for as="a"
81
+ ':not([aria-disabled])': {
82
+ cursor: 'pointer'
83
+ },
84
+ '@media (hover: hover) and (pointer: fine)': {
85
+ ':hover:not([aria-disabled])': {
86
+ backgroundColor: `actionListItem.${variant}.hoverBg`,
87
+ color: getVariantStyles(variant, disabled).hoverColor
88
+ },
89
+ ':focus:not([data-focus-visible-added])': {
90
+ backgroundColor: `actionListItem.${variant}.selectedBg`,
91
+ color: getVariantStyles(variant, disabled).hoverColor,
92
+ outline: 'none'
93
+ },
94
+ '&[data-focus-visible-added]': {
95
+ // we don't use :focus-visible because not all browsers (safari) have it yet
96
+ outline: 'none',
97
+ border: `2 solid`,
98
+ boxShadow: `0 0 0 2px ${theme === null || theme === void 0 ? void 0 : theme.colors.accent.emphasis}`
99
+ },
100
+ ':active:not([aria-disabled])': {
101
+ backgroundColor: `actionListItem.${variant}.activeBg`,
102
+ color: getVariantStyles(variant, disabled).hoverColor
103
+ }
104
+ },
105
+
106
+ /** Divider styles */
107
+ '[data-component="ActionList.Item--DividerContainer"]': {
108
+ position: 'relative'
109
+ },
110
+ '[data-component="ActionList.Item--DividerContainer"]::before': {
111
+ content: '" "',
112
+ display: 'block',
113
+ position: 'absolute',
114
+ width: '100%',
115
+ top: '-7px',
116
+ border: '0 solid',
117
+ borderTopWidth: showDividers ? `1px` : '0',
118
+ borderColor: 'var(--divider-color, transparent)'
119
+ },
120
+ // show between 2 items
121
+ ':not(:first-of-type)': {
122
+ '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
123
+ },
124
+ // hide divider after dividers & group header, with higher importance!
125
+ '[data-component="ActionList.Divider"] + &': {
126
+ '--divider-color': 'transparent !important'
127
+ },
128
+ // hide border on current and previous item
129
+ '&:hover:not([aria-disabled]), &:focus:not([aria-disabled]), &[data-focus-visible-added]:not([aria-disabled])': {
130
+ '--divider-color': 'transparent'
131
+ },
132
+ '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &, &[data-focus-visible-added] + li': {
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]);
140
+ const keyPressHandler = React.useCallback(event => {
141
+ if (disabled) return;
142
+
143
+ if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
144
+ onSelect(event);
145
+ }
146
+ }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
147
+
148
+ const labelId = useSSRSafeId(id);
149
+ const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
150
+ const blockDescriptionId = useSSRSafeId(id && `${id}--block-description`);
151
+ const ItemWrapper = _PrivateItemWrapper || React.Fragment;
152
+ return /*#__PURE__*/React.createElement(Slots, {
153
+ context: {
154
+ variant,
155
+ disabled,
156
+ inlineDescriptionId,
157
+ blockDescriptionId
158
+ }
159
+ }, slots => /*#__PURE__*/React.createElement(LiBox, _extends({
160
+ ref: forwardedRef,
161
+ sx: merge(styles, sxProp),
162
+ onClick: clickHandler,
163
+ onKeyPress: keyPressHandler,
164
+ "aria-selected": selected,
165
+ "aria-disabled": disabled ? true : undefined,
166
+ tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
167
+ "aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
168
+ "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
169
+ }, props), /*#__PURE__*/React.createElement(ItemWrapper, null, /*#__PURE__*/React.createElement(Selection, {
170
+ selected: selected,
171
+ disabled: disabled
172
+ }), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
173
+ "data-component": "ActionList.Item--DividerContainer",
174
+ sx: {
175
+ display: 'flex',
176
+ flexDirection: 'column',
177
+ flexGrow: 1,
178
+ minWidth: 0
179
+ }
180
+ }, /*#__PURE__*/React.createElement(ConditionalBox, {
181
+ if: Boolean(slots.TrailingVisual),
182
+ sx: {
183
+ display: 'flex',
184
+ flexGrow: 1
185
+ }
186
+ }, /*#__PURE__*/React.createElement(ConditionalBox, {
187
+ if: Boolean(slots.InlineDescription),
188
+ sx: {
189
+ display: 'flex',
190
+ flexGrow: 1,
191
+ alignItems: 'baseline',
192
+ minWidth: 0
193
+ }
194
+ }, /*#__PURE__*/React.createElement(Box, {
195
+ as: "span",
196
+ id: labelId,
197
+ sx: {
198
+ flexGrow: slots.InlineDescription ? 0 : 1
199
+ }
200
+ }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
201
+ });
202
+ Item.displayName = 'ActionList.Item';
203
+
204
+ const ConditionalBox = props => {
205
+ const {
206
+ if: condition,
207
+ ...rest
208
+ } = props;
209
+ if (condition) return /*#__PURE__*/React.createElement(Box, rest, props.children);else return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
210
+ };
@@ -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: sxProp = {},
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, sxProp),
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,9 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ declare type VisualProps = SxProp & React.HTMLAttributes<HTMLSpanElement>;
4
+ export declare const LeadingVisualContainer: React.FC<VisualProps>;
5
+ export declare type LeadingVisualProps = VisualProps;
6
+ export declare const LeadingVisual: React.FC<VisualProps>;
7
+ export declare type TrailingVisualProps = VisualProps;
8
+ export declare const TrailingVisual: React.FC<VisualProps>;
9
+ 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";