@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,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Header = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _List = require("./List");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ 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); }
17
+
18
+ /**
19
+ * Displays the name and description of a `Group`.
20
+ */
21
+ const Header = ({
22
+ variant = 'subtle',
23
+ title,
24
+ auxiliaryText,
25
+ sx = {},
26
+ ...props
27
+ }) => {
28
+ const {
29
+ variant: listVariant
30
+ } = _react.default.useContext(_List.ListContext);
31
+
32
+ const styles = {
33
+ paddingY: '6px',
34
+ paddingX: listVariant === 'full' ? 2 : 3,
35
+ fontSize: 0,
36
+ fontWeight: 'bold',
37
+ color: 'fg.muted',
38
+ ...(variant === 'filled' && {
39
+ backgroundColor: 'canvas.subtle',
40
+ marginX: 0,
41
+ marginBottom: 2,
42
+ borderTop: '1px solid',
43
+ borderBottom: '1px solid',
44
+ borderColor: 'neutral.muted'
45
+ }),
46
+ ...sx
47
+ };
48
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
49
+ sx: styles,
50
+ role: "heading"
51
+ }, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
52
+ };
53
+
54
+ exports.Header = Header;
55
+ 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,244 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Item = exports.TEXT_ROW_HEIGHT = exports.Slot = exports.getVariantStyles = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ssr = require("@react-aria/ssr");
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _ThemeProvider = require("../ThemeProvider");
15
+
16
+ var _Box = _interopRequireDefault(require("../Box"));
17
+
18
+ var _sx = _interopRequireWildcard(require("../sx"));
19
+
20
+ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
21
+
22
+ var _List = require("./List");
23
+
24
+ var _Selection = require("./Selection");
25
+
26
+ 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); }
27
+
28
+ 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; }
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ 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); }
33
+
34
+ const getVariantStyles = (variant, disabled) => {
35
+ if (disabled) {
36
+ return {
37
+ color: 'fg.muted',
38
+ iconColor: 'fg.muted',
39
+ annotationColor: 'fg.muted'
40
+ };
41
+ }
42
+
43
+ switch (variant) {
44
+ case 'danger':
45
+ return {
46
+ color: 'danger.fg',
47
+ iconColor: 'danger.fg',
48
+ annotationColor: 'fg.muted',
49
+ hoverColor: 'actionListItem.danger.hoverText'
50
+ };
51
+
52
+ default:
53
+ return {
54
+ color: 'fg.default',
55
+ iconColor: 'fg.muted',
56
+ annotationColor: 'fg.muted',
57
+ hoverColor: 'fg.default'
58
+ };
59
+ }
60
+ };
61
+
62
+ exports.getVariantStyles = getVariantStyles;
63
+ const {
64
+ Slots,
65
+ Slot
66
+ } = (0, _createSlots.default)(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
67
+ exports.Slot = Slot;
68
+
69
+ const LiBox = _styledComponents.default.li.withConfig({
70
+ displayName: "Item__LiBox",
71
+ componentId: "c3scat-0"
72
+ })(_sx.default);
73
+
74
+ const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
75
+
76
+ exports.TEXT_ROW_HEIGHT = TEXT_ROW_HEIGHT;
77
+
78
+ const Item = /*#__PURE__*/_react.default.forwardRef(({
79
+ variant = 'default',
80
+ disabled = false,
81
+ selected = undefined,
82
+ onSelect = () => null,
83
+ sx: sxProp = {},
84
+ id,
85
+ _PrivateItemWrapper,
86
+ ...props
87
+ }, forwardedRef) => {
88
+ const {
89
+ variant: listVariant,
90
+ showDividers
91
+ } = _react.default.useContext(_List.ListContext);
92
+
93
+ const {
94
+ theme
95
+ } = (0, _ThemeProvider.useTheme)();
96
+ const styles = {
97
+ display: 'flex',
98
+ paddingX: 2,
99
+ fontSize: 1,
100
+ paddingY: '6px',
101
+ // custom value off the scale
102
+ lineHeight: TEXT_ROW_HEIGHT,
103
+ minHeight: 5,
104
+ marginX: listVariant === 'inset' ? 2 : 0,
105
+ borderRadius: listVariant === 'inset' ? 2 : 0,
106
+ transition: 'background 33.333ms linear',
107
+ color: getVariantStyles(variant, disabled).color,
108
+ textDecoration: 'none',
109
+ // for as="a"
110
+ ':not([aria-disabled])': {
111
+ cursor: 'pointer'
112
+ },
113
+ '@media (hover: hover) and (pointer: fine)': {
114
+ ':hover:not([aria-disabled])': {
115
+ backgroundColor: `actionListItem.${variant}.hoverBg`,
116
+ color: getVariantStyles(variant, disabled).hoverColor
117
+ },
118
+ ':focus:not([data-focus-visible-added])': {
119
+ backgroundColor: `actionListItem.${variant}.selectedBg`,
120
+ color: getVariantStyles(variant, disabled).hoverColor,
121
+ outline: 'none'
122
+ },
123
+ '&[data-focus-visible-added]': {
124
+ // we don't use :focus-visible because not all browsers (safari) have it yet
125
+ outline: 'none',
126
+ border: `2 solid`,
127
+ boxShadow: `0 0 0 2px ${theme === null || theme === void 0 ? void 0 : theme.colors.accent.emphasis}`
128
+ },
129
+ ':active:not([aria-disabled])': {
130
+ backgroundColor: `actionListItem.${variant}.activeBg`,
131
+ color: getVariantStyles(variant, disabled).hoverColor
132
+ }
133
+ },
134
+
135
+ /** Divider styles */
136
+ '[data-component="ActionList.Item--DividerContainer"]': {
137
+ position: 'relative'
138
+ },
139
+ '[data-component="ActionList.Item--DividerContainer"]::before': {
140
+ content: '" "',
141
+ display: 'block',
142
+ position: 'absolute',
143
+ width: '100%',
144
+ top: '-7px',
145
+ border: '0 solid',
146
+ borderTopWidth: showDividers ? `1px` : '0',
147
+ borderColor: 'var(--divider-color, transparent)'
148
+ },
149
+ // show between 2 items
150
+ ':not(:first-of-type)': {
151
+ '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
152
+ },
153
+ // hide divider after dividers & group header, with higher importance!
154
+ '[data-component="ActionList.Divider"] + &': {
155
+ '--divider-color': 'transparent !important'
156
+ },
157
+ // hide border on current and previous item
158
+ '&:hover:not([aria-disabled]), &:focus:not([aria-disabled]), &[data-focus-visible-added]:not([aria-disabled])': {
159
+ '--divider-color': 'transparent'
160
+ },
161
+ '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &, &[data-focus-visible-added] + li': {
162
+ '--divider-color': 'transparent'
163
+ }
164
+ };
165
+
166
+ const clickHandler = _react.default.useCallback(event => {
167
+ if (disabled) return;
168
+ if (!event.defaultPrevented) onSelect(event);
169
+ }, [onSelect, disabled]);
170
+
171
+ const keyPressHandler = _react.default.useCallback(event => {
172
+ if (disabled) return;
173
+
174
+ if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
175
+ onSelect(event);
176
+ }
177
+ }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
178
+
179
+
180
+ const labelId = (0, _ssr.useSSRSafeId)(id);
181
+ const inlineDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--inline-description`);
182
+ const blockDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--block-description`);
183
+ const ItemWrapper = _PrivateItemWrapper || _react.default.Fragment;
184
+ return /*#__PURE__*/_react.default.createElement(Slots, {
185
+ context: {
186
+ variant,
187
+ disabled,
188
+ inlineDescriptionId,
189
+ blockDescriptionId
190
+ }
191
+ }, slots => /*#__PURE__*/_react.default.createElement(LiBox, _extends({
192
+ ref: forwardedRef,
193
+ sx: (0, _sx.merge)(styles, sxProp),
194
+ onClick: clickHandler,
195
+ onKeyPress: keyPressHandler,
196
+ "aria-selected": selected,
197
+ "aria-disabled": disabled ? true : undefined,
198
+ tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
199
+ "aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
200
+ "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
201
+ }, props), /*#__PURE__*/_react.default.createElement(ItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
202
+ selected: selected,
203
+ disabled: disabled
204
+ }), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
205
+ "data-component": "ActionList.Item--DividerContainer",
206
+ sx: {
207
+ display: 'flex',
208
+ flexDirection: 'column',
209
+ flexGrow: 1,
210
+ minWidth: 0
211
+ }
212
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
213
+ if: Boolean(slots.TrailingVisual),
214
+ sx: {
215
+ display: 'flex',
216
+ flexGrow: 1
217
+ }
218
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
219
+ if: Boolean(slots.InlineDescription),
220
+ sx: {
221
+ display: 'flex',
222
+ flexGrow: 1,
223
+ alignItems: 'baseline',
224
+ minWidth: 0
225
+ }
226
+ }, /*#__PURE__*/_react.default.createElement(_Box.default, {
227
+ as: "span",
228
+ id: labelId,
229
+ sx: {
230
+ flexGrow: slots.InlineDescription ? 0 : 1
231
+ }
232
+ }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
233
+ });
234
+
235
+ exports.Item = Item;
236
+ Item.displayName = 'ActionList.Item';
237
+
238
+ const ConditionalBox = props => {
239
+ const {
240
+ if: condition,
241
+ ...rest
242
+ } = props;
243
+ if (condition) return /*#__PURE__*/_react.default.createElement(_Box.default, rest, props.children);else return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
244
+ };
@@ -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,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LinkItem = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Link = _interopRequireDefault(require("../Link"));
11
+
12
+ var _sx = require("../sx");
13
+
14
+ var _Item = require("./Item");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ 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); }
19
+
20
+ const LinkItem = /*#__PURE__*/_react.default.forwardRef(({
21
+ sx = {},
22
+ as: Component,
23
+ ...props
24
+ }, forwardedRef) => {
25
+ const styles = {
26
+ // occupy full size of Item
27
+ paddingX: 2,
28
+ paddingY: '6px',
29
+ // custom value off the scale
30
+ display: 'flex',
31
+ flexGrow: 1,
32
+ // full width
33
+ borderRadius: 2,
34
+ // inherit Item styles
35
+ color: 'inherit',
36
+ '&:hover': {
37
+ color: 'inherit',
38
+ textDecoration: 'none'
39
+ }
40
+ };
41
+ return /*#__PURE__*/_react.default.createElement(_Item.Item, {
42
+ sx: {
43
+ paddingY: 0,
44
+ paddingX: 0
45
+ },
46
+ _PrivateItemWrapper: ({
47
+ children
48
+ }) => /*#__PURE__*/_react.default.createElement(_Link.default, _extends({
49
+ as: Component,
50
+ sx: (0, _sx.merge)(styles, sx)
51
+ }, props, {
52
+ ref: forwardedRef
53
+ }), children)
54
+ }, props.children);
55
+ });
56
+
57
+ exports.LinkItem = LinkItem;
@@ -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,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.List = exports.ListContext = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+
12
+ var _sx = _interopRequireWildcard(require("../sx"));
13
+
14
+ 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); }
15
+
16
+ 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; }
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ 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); }
21
+
22
+ const ListContext = /*#__PURE__*/_react.default.createContext({});
23
+
24
+ exports.ListContext = ListContext;
25
+
26
+ const ListBox = _styledComponents.default.ul.withConfig({
27
+ displayName: "List__ListBox",
28
+ componentId: "cvbq60-0"
29
+ })(_sx.default);
30
+
31
+ const List = /*#__PURE__*/_react.default.forwardRef(({
32
+ variant = 'inset',
33
+ selectionVariant,
34
+ showDividers = false,
35
+ sx: sxProp = {},
36
+ ...props
37
+ }, forwardedRef) => {
38
+ const styles = {
39
+ margin: 0,
40
+ paddingInlineStart: 0,
41
+ // reset ul styles
42
+ paddingY: variant === 'inset' ? 2 : 0
43
+ };
44
+ return /*#__PURE__*/_react.default.createElement(ListBox, _extends({
45
+ sx: (0, _sx.merge)(styles, sxProp),
46
+ "aria-multiselectable": selectionVariant === 'multiple' ? true : undefined
47
+ }, props, {
48
+ ref: forwardedRef
49
+ }), /*#__PURE__*/_react.default.createElement(ListContext.Provider, {
50
+ value: {
51
+ variant,
52
+ selectionVariant,
53
+ showDividers
54
+ }
55
+ }, props.children));
56
+ });
57
+
58
+ exports.List = List;
59
+ 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,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Selection = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _octiconsReact = require("@primer/octicons-react");
11
+
12
+ var _List = require("./List");
13
+
14
+ var _Group = require("./Group");
15
+
16
+ var _Visuals = require("./Visuals");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const Selection = ({
21
+ selected,
22
+ disabled
23
+ }) => {
24
+ const {
25
+ selectionVariant: listSelectionVariant
26
+ } = _react.default.useContext(_List.ListContext);
27
+
28
+ const {
29
+ selectionVariant: groupSelectionVariant
30
+ } = _react.default.useContext(_Group.GroupContext);
31
+ /** selectionVariant in Group can override the selectionVariant in List root */
32
+
33
+
34
+ const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
35
+
36
+ if (!selectionVariant) {
37
+ // to avoid confusion, fail loudly instead of silently ignoring
38
+ if (selected) throw new Error('For Item to be selected, ActionList or ActionList.Group needs to have a selectionVariant defined');
39
+ return null;
40
+ }
41
+
42
+ if (selectionVariant === 'single') {
43
+ return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, null));
44
+ }
45
+ /**
46
+ * selectionVariant is multiple
47
+ * readOnly is required because we are doing a one-way bind to `checked`
48
+ * aria-readonly="false" tells screen that they can still interact with the checkbox
49
+ */
50
+
51
+
52
+ return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, {
53
+ sx: {
54
+ input: {
55
+ margin: 0,
56
+ pointerEvents: 'none'
57
+ }
58
+ }
59
+ }, /*#__PURE__*/_react.default.createElement("input", {
60
+ type: "checkbox",
61
+ checked: selected,
62
+ disabled: disabled,
63
+ tabIndex: -1,
64
+ readOnly: true,
65
+ "aria-readonly": "false"
66
+ }));
67
+ };
68
+
69
+ exports.Selection = Selection;
70
+ 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 {};