@primer/components 0.0.0-2021103235619 → 0.0.0-2021104151625

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 (192) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/dist/browser.esm.js +509 -505
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +112 -108
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Header.js +1 -1
  7. package/lib/ActionList/Item.d.ts +6 -0
  8. package/lib/ActionList/Item.js +5 -1
  9. package/lib/ActionList2/Description.d.ts +12 -0
  10. package/lib/ActionList2/Description.js +53 -0
  11. package/lib/ActionList2/Divider.d.ts +5 -0
  12. package/lib/ActionList2/Divider.js +35 -0
  13. package/lib/ActionList2/Group.d.ts +11 -0
  14. package/lib/ActionList2/Group.js +57 -0
  15. package/lib/ActionList2/Header.d.ts +26 -0
  16. package/lib/ActionList2/Header.js +55 -0
  17. package/lib/ActionList2/Item.d.ts +67 -0
  18. package/lib/ActionList2/Item.js +221 -0
  19. package/lib/ActionList2/LinkItem.d.ts +17 -0
  20. package/lib/ActionList2/LinkItem.js +57 -0
  21. package/lib/ActionList2/List.d.ts +26 -0
  22. package/lib/ActionList2/List.js +51 -0
  23. package/lib/ActionList2/Selection.d.ts +5 -0
  24. package/lib/ActionList2/Selection.js +70 -0
  25. package/lib/ActionList2/Visuals.d.ts +11 -0
  26. package/lib/ActionList2/Visuals.js +90 -0
  27. package/lib/ActionList2/index.d.ts +40 -0
  28. package/lib/ActionList2/index.js +47 -0
  29. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  30. package/lib/Autocomplete/Autocomplete.d.ts +30 -32
  31. package/lib/Autocomplete/AutocompleteInput.d.ts +30 -32
  32. package/lib/Button/Button.d.ts +27 -27
  33. package/lib/Button/ButtonBase.d.ts +1 -1
  34. package/lib/Button/ButtonClose.d.ts +45 -45
  35. package/lib/Button/ButtonDanger.d.ts +27 -27
  36. package/lib/Button/ButtonInvisible.d.ts +27 -27
  37. package/lib/Button/ButtonOutline.d.ts +27 -27
  38. package/lib/Button/ButtonPrimary.d.ts +27 -27
  39. package/lib/CircleBadge.d.ts +2 -2
  40. package/lib/CircleOcticon.d.ts +43 -43
  41. package/lib/Dialog.d.ts +46 -46
  42. package/lib/Dropdown.d.ts +178 -178
  43. package/lib/DropdownMenu/DropdownButton.d.ts +47 -47
  44. package/lib/FilterList.d.ts +42 -42
  45. package/lib/Flash.d.ts +1 -1
  46. package/lib/Label.d.ts +1 -1
  47. package/lib/Position.d.ts +4 -4
  48. package/lib/ProgressBar.d.ts +1 -1
  49. package/lib/SelectMenu/SelectMenu.d.ts +246 -248
  50. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  51. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  52. package/lib/TextInputWithTokens.d.ts +34 -32
  53. package/lib/TextInputWithTokens.js +102 -29
  54. package/lib/Timeline.d.ts +44 -44
  55. package/lib/Token/AvatarToken.d.ts +1 -1
  56. package/lib/Token/IssueLabelToken.d.ts +1 -1
  57. package/lib/Token/Token.d.ts +1 -1
  58. package/lib/Token/Token.js +13 -2
  59. package/lib/Token/TokenBase.js +0 -4
  60. package/lib/Token/_RemoveTokenButton.js +15 -2
  61. package/lib/_TextInputWrapper.d.ts +1 -1
  62. package/lib/_TextInputWrapper.js +1 -1
  63. package/lib/experiments.d.ts +1 -0
  64. package/lib/experiments.js +18 -0
  65. package/lib/hooks/useResizeObserver.d.ts +1 -1
  66. package/lib/hooks/useResizeObserver.js +1 -1
  67. package/lib/sx.d.ts +10 -2
  68. package/lib/sx.js +8 -0
  69. package/lib/theme-preval.js +79 -0
  70. package/lib/theme.d.ts +78 -0
  71. package/lib/theme.js +3 -1
  72. package/lib/utils/create-slots.d.ts +17 -0
  73. package/lib/utils/create-slots.js +105 -0
  74. package/lib/utils/testing.d.ts +13 -0
  75. package/lib/utils/types/KeyPaths.d.ts +3 -0
  76. package/lib/utils/types/KeyPaths.js +1 -0
  77. package/lib/utils/use-force-update.d.ts +1 -0
  78. package/lib/utils/use-force-update.js +19 -0
  79. package/lib-esm/ActionList/Header.js +1 -1
  80. package/lib-esm/ActionList/Item.d.ts +6 -0
  81. package/lib-esm/ActionList/Item.js +5 -1
  82. package/lib-esm/ActionList2/Description.d.ts +12 -0
  83. package/lib-esm/ActionList2/Description.js +37 -0
  84. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  85. package/lib-esm/ActionList2/Divider.js +23 -0
  86. package/lib-esm/ActionList2/Group.d.ts +11 -0
  87. package/lib-esm/ActionList2/Group.js +40 -0
  88. package/lib-esm/ActionList2/Header.d.ts +26 -0
  89. package/lib-esm/ActionList2/Header.js +44 -0
  90. package/lib-esm/ActionList2/Item.d.ts +67 -0
  91. package/lib-esm/ActionList2/Item.js +195 -0
  92. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  93. package/lib-esm/ActionList2/LinkItem.js +43 -0
  94. package/lib-esm/ActionList2/List.d.ts +26 -0
  95. package/lib-esm/ActionList2/List.js +34 -0
  96. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  97. package/lib-esm/ActionList2/Selection.js +52 -0
  98. package/lib-esm/ActionList2/Visuals.d.ts +11 -0
  99. package/lib-esm/ActionList2/Visuals.js +68 -0
  100. package/lib-esm/ActionList2/index.d.ts +40 -0
  101. package/lib-esm/ActionList2/index.js +33 -0
  102. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  103. package/lib-esm/Autocomplete/Autocomplete.d.ts +30 -32
  104. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +30 -32
  105. package/lib-esm/Button/Button.d.ts +27 -27
  106. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  107. package/lib-esm/Button/ButtonClose.d.ts +45 -45
  108. package/lib-esm/Button/ButtonDanger.d.ts +27 -27
  109. package/lib-esm/Button/ButtonInvisible.d.ts +27 -27
  110. package/lib-esm/Button/ButtonOutline.d.ts +27 -27
  111. package/lib-esm/Button/ButtonPrimary.d.ts +27 -27
  112. package/lib-esm/CircleBadge.d.ts +2 -2
  113. package/lib-esm/CircleOcticon.d.ts +43 -43
  114. package/lib-esm/Dialog.d.ts +46 -46
  115. package/lib-esm/Dropdown.d.ts +178 -178
  116. package/lib-esm/DropdownMenu/DropdownButton.d.ts +47 -47
  117. package/lib-esm/FilterList.d.ts +42 -42
  118. package/lib-esm/Flash.d.ts +1 -1
  119. package/lib-esm/Label.d.ts +1 -1
  120. package/lib-esm/Position.d.ts +4 -4
  121. package/lib-esm/ProgressBar.d.ts +1 -1
  122. package/lib-esm/SelectMenu/SelectMenu.d.ts +246 -248
  123. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  124. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  125. package/lib-esm/TextInputWithTokens.d.ts +34 -32
  126. package/lib-esm/TextInputWithTokens.js +101 -30
  127. package/lib-esm/Timeline.d.ts +44 -44
  128. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  129. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  130. package/lib-esm/Token/Token.d.ts +1 -1
  131. package/lib-esm/Token/Token.js +13 -2
  132. package/lib-esm/Token/TokenBase.js +0 -4
  133. package/lib-esm/Token/_RemoveTokenButton.js +11 -2
  134. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  135. package/lib-esm/_TextInputWrapper.js +1 -1
  136. package/lib-esm/experiments.d.ts +1 -0
  137. package/lib-esm/experiments.js +2 -0
  138. package/lib-esm/hooks/useResizeObserver.d.ts +1 -1
  139. package/lib-esm/hooks/useResizeObserver.js +1 -1
  140. package/lib-esm/sx.d.ts +10 -2
  141. package/lib-esm/sx.js +3 -1
  142. package/lib-esm/theme-preval.js +79 -0
  143. package/lib-esm/theme.d.ts +78 -0
  144. package/lib-esm/theme.js +2 -1
  145. package/lib-esm/utils/create-slots.d.ts +17 -0
  146. package/lib-esm/utils/create-slots.js +84 -0
  147. package/lib-esm/utils/testing.d.ts +13 -0
  148. package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
  149. package/lib-esm/utils/types/KeyPaths.js +1 -0
  150. package/lib-esm/utils/use-force-update.d.ts +1 -0
  151. package/lib-esm/utils/use-force-update.js +6 -0
  152. package/package.json +12 -9
  153. package/lib/DatePicker/DatePicker.d.ts +0 -52
  154. package/lib/DatePicker/DatePicker.js +0 -109
  155. package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
  156. package/lib/DatePicker/DatePickerAnchor.js +0 -202
  157. package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
  158. package/lib/DatePicker/DatePickerOverlay.js +0 -55
  159. package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
  160. package/lib/DatePicker/DatePickerPanel.js +0 -363
  161. package/lib/DatePicker/Day.d.ts +0 -15
  162. package/lib/DatePicker/Day.js +0 -206
  163. package/lib/DatePicker/Month.d.ts +0 -8
  164. package/lib/DatePicker/Month.js +0 -122
  165. package/lib/DatePicker/dateParser.d.ts +0 -12
  166. package/lib/DatePicker/dateParser.js +0 -192
  167. package/lib/DatePicker/index.d.ts +0 -2
  168. package/lib/DatePicker/index.js +0 -13
  169. package/lib/DatePicker/useDatePicker.d.ts +0 -107
  170. package/lib/DatePicker/useDatePicker.js +0 -558
  171. package/lib/hooks/useDebounce.d.ts +0 -2
  172. package/lib/hooks/useDebounce.js +0 -24
  173. package/lib-esm/DatePicker/DatePicker.d.ts +0 -52
  174. package/lib-esm/DatePicker/DatePicker.js +0 -92
  175. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
  176. package/lib-esm/DatePicker/DatePickerAnchor.js +0 -174
  177. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
  178. package/lib-esm/DatePicker/DatePickerOverlay.js +0 -40
  179. package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
  180. package/lib-esm/DatePicker/DatePickerPanel.js +0 -332
  181. package/lib-esm/DatePicker/Day.d.ts +0 -15
  182. package/lib-esm/DatePicker/Day.js +0 -182
  183. package/lib-esm/DatePicker/Month.d.ts +0 -8
  184. package/lib-esm/DatePicker/Month.js +0 -98
  185. package/lib-esm/DatePicker/dateParser.d.ts +0 -12
  186. package/lib-esm/DatePicker/dateParser.js +0 -178
  187. package/lib-esm/DatePicker/index.d.ts +0 -2
  188. package/lib-esm/DatePicker/index.js +0 -1
  189. package/lib-esm/DatePicker/useDatePicker.d.ts +0 -107
  190. package/lib-esm/DatePicker/useDatePicker.js +0 -523
  191. package/lib-esm/hooks/useDebounce.d.ts +0 -2
  192. package/lib-esm/hooks/useDebounce.js +0 -16
@@ -45,7 +45,7 @@ function Header({
45
45
  return /*#__PURE__*/_react.default.createElement(StyledHeader, _extends({
46
46
  role: "heading",
47
47
  variant: variant
48
- }, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, "auxiliaryText"));
48
+ }, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
49
49
  }
50
50
 
51
51
  Header.displayName = "Header";
@@ -28,13 +28,19 @@ export interface ItemProps extends SxProp {
28
28
  */
29
29
  leadingVisual?: React.FunctionComponent<IconProps>;
30
30
  /**
31
+ * @deprecated Use `trailingVisual` instead
31
32
  * Icon (or similar) positioned after `Item` text.
32
33
  */
33
34
  trailingIcon?: React.FunctionComponent<IconProps>;
34
35
  /**
36
+ * @deprecated Use `trailingVisual` instead
35
37
  * Text positioned after `Item` text and optional trailing icon.
36
38
  */
37
39
  trailingText?: string;
40
+ /**
41
+ * Icon or text positioned after `Item` text.
42
+ */
43
+ trailingVisual?: React.ReactNode;
38
44
  /**
39
45
  * Style variations associated with various `Item` types.
40
46
  *
@@ -187,6 +187,7 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
187
187
  selectionVariant,
188
188
  leadingVisual: LeadingVisual,
189
189
  trailingIcon: TrailingIcon,
190
+ trailingVisual: TrailingVisual,
190
191
  trailingText,
191
192
  variant = 'default',
192
193
  showDivider,
@@ -278,7 +279,10 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
278
279
  title: description,
279
280
  inline: true,
280
281
  maxWidth: "100%"
281
- }, description)) : null), TrailingIcon || trailingText ? /*#__PURE__*/_react.default.createElement(TrailingContent, {
282
+ }, description)) : null), TrailingVisual ? /*#__PURE__*/_react.default.createElement(TrailingContent, {
283
+ variant: variant,
284
+ disabled: disabled
285
+ }, typeof TrailingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(TrailingVisual, null) : TrailingVisual) : TrailingIcon || trailingText ? /*#__PURE__*/_react.default.createElement(TrailingContent, {
282
286
  variant: variant,
283
287
  disabled: disabled
284
288
  }, trailingText, TrailingIcon && /*#__PURE__*/_react.default.createElement(TrailingIcon, null)) : null));
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ export declare type DescriptionProps = {
4
+ /**
5
+ * Secondary text style variations.
6
+ *
7
+ * - `"inline"` - Secondary text is positioned beside primary text.
8
+ * - `"block"` - Secondary text is positioned below primary text.
9
+ */
10
+ variant?: 'inline' | 'block';
11
+ } & SxProp;
12
+ export declare const Description: React.FC<DescriptionProps>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Description = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _sx = require("../sx");
13
+
14
+ var _Truncate = _interopRequireDefault(require("../Truncate"));
15
+
16
+ var _Item = require("./Item");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const Description = ({
21
+ variant = 'inline',
22
+ sx = {},
23
+ ...props
24
+ }) => {
25
+ const styles = {
26
+ color: 'fg.muted',
27
+ fontSize: 0,
28
+ lineHeight: '16px',
29
+ flexGrow: 1,
30
+ flexBasis: 0,
31
+ minWidth: 0,
32
+ marginLeft: variant === 'block' ? 0 : 2
33
+ };
34
+ return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
35
+ name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
36
+ }, ({
37
+ blockDescriptionId,
38
+ inlineDescriptionId
39
+ }) => variant === 'block' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
40
+ as: "span",
41
+ sx: (0, _sx.merge)(styles, sx),
42
+ id: blockDescriptionId
43
+ }, props.children) : /*#__PURE__*/_react.default.createElement(_Truncate.default, {
44
+ id: inlineDescriptionId,
45
+ sx: (0, _sx.merge)(styles, sx),
46
+ title: props.children,
47
+ inline: true,
48
+ maxWidth: "100%"
49
+ }, props.children));
50
+ };
51
+
52
+ exports.Description = Description;
53
+ Description.displayName = "Description";
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Visually separates `Item`s or `Group`s in an `ActionList`.
4
+ */
5
+ export declare function Divider(): JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Divider = Divider;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _constants = require("../constants");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ /**
17
+ * Visually separates `Item`s or `Group`s in an `ActionList`.
18
+ */
19
+ function Divider() {
20
+ return /*#__PURE__*/_react.default.createElement(_Box.default, {
21
+ as: "li",
22
+ role: "separator",
23
+ sx: {
24
+ height: 1,
25
+ backgroundColor: 'actionListItem.inlineDivider',
26
+ marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
27
+ marginBottom: 2,
28
+ listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
29
+
30
+ },
31
+ "data-component": "ActionList.Divider"
32
+ });
33
+ }
34
+
35
+ Divider.displayName = "Divider";
@@ -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,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Group = exports.GroupContext = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _Header = require("./Header");
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
+ const GroupContext = /*#__PURE__*/_react.default.createContext({});
19
+
20
+ exports.GroupContext = GroupContext;
21
+
22
+ const Group = ({
23
+ title,
24
+ variant,
25
+ auxiliaryText,
26
+ selectionVariant,
27
+ sx = {},
28
+ ...props
29
+ }) => {
30
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
31
+ as: "li",
32
+ sx: {
33
+ '&:not(:first-child)': {
34
+ marginTop: 2
35
+ },
36
+ listStyle: 'none',
37
+ // hide the ::marker inserted by browser's stylesheet
38
+ ...sx
39
+ }
40
+ }, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
41
+ title: title,
42
+ variant: variant,
43
+ auxiliaryText: auxiliaryText
44
+ }), /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
45
+ value: {
46
+ selectionVariant
47
+ }
48
+ }, /*#__PURE__*/_react.default.createElement(_Box.default, {
49
+ as: "ul",
50
+ sx: {
51
+ paddingInlineStart: 0
52
+ }
53
+ }, props.children)));
54
+ };
55
+
56
+ exports.Group = Group;
57
+ 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,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,67 @@
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
+ selectedBg?: undefined;
11
+ } | {
12
+ color: string;
13
+ iconColor: string;
14
+ annotationColor: string;
15
+ hoverColor: string;
16
+ selectedBg?: undefined;
17
+ } | {
18
+ color: string;
19
+ iconColor: string;
20
+ annotationColor: string;
21
+ hoverColor: string;
22
+ selectedBg: string;
23
+ };
24
+ export declare type ItemProps = {
25
+ /**
26
+ * Primary content for an Item
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Callback that will trigger both on click selection and keyboard selection.
31
+ */
32
+ onSelect?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
33
+ /**
34
+ * Is the `Item` is currently selected?
35
+ */
36
+ selected?: boolean;
37
+ /**
38
+ * Style variations associated with various `Item` types.
39
+ *
40
+ * - `"default"` - An action `Item`.
41
+ * - `"danger"` - A destructive action `Item`.
42
+ */
43
+ variant?: 'default' | 'danger';
44
+ /**
45
+ * Items that are disabled can not be clicked, selected, or navigated through.
46
+ */
47
+ disabled?: boolean;
48
+ /**
49
+ * The ARIA role describing the function of `Item` component. `option` is a common value. |
50
+ */
51
+ role?: AriaRole;
52
+ /**
53
+ * Private API for use internally only. Used by LinkItem to wrap contents in an anchor
54
+ */
55
+ _PrivateItemWrapper?: React.FC;
56
+ } & SxProp;
57
+ declare const Slot: React.FC<{
58
+ name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
59
+ children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
60
+ }>;
61
+ export { Slot };
62
+ export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
63
+ inlineDescriptionId: string;
64
+ blockDescriptionId: string;
65
+ };
66
+ export declare const TEXT_ROW_HEIGHT = "20px";
67
+ export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
@@ -0,0 +1,221 @@
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 _ThemeProvider = require("../ThemeProvider");
13
+
14
+ var _Box = _interopRequireDefault(require("../Box"));
15
+
16
+ var _sx = require("../sx");
17
+
18
+ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
19
+
20
+ var _List = require("./List");
21
+
22
+ var _Selection = require("./Selection");
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ 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); }
27
+
28
+ const getVariantStyles = (variant, disabled) => {
29
+ if (disabled) {
30
+ return {
31
+ color: 'fg.muted',
32
+ iconColor: 'fg.muted',
33
+ annotationColor: 'fg.muted'
34
+ };
35
+ }
36
+
37
+ switch (variant) {
38
+ case 'danger':
39
+ return {
40
+ color: 'danger.fg',
41
+ iconColor: 'danger.fg',
42
+ annotationColor: 'fg.muted',
43
+ hoverColor: 'actionListItem.danger.hoverText'
44
+ };
45
+
46
+ default:
47
+ return {
48
+ color: 'fg.default',
49
+ iconColor: 'fg.muted',
50
+ annotationColor: 'fg.muted',
51
+ hoverColor: 'fg.default',
52
+ selectedBg: 'actionListItem.default.selectedBg'
53
+ };
54
+ }
55
+ };
56
+
57
+ exports.getVariantStyles = getVariantStyles;
58
+ const {
59
+ Slots,
60
+ Slot
61
+ } = (0, _createSlots.default)(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
62
+ exports.Slot = Slot;
63
+ const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
64
+
65
+ exports.TEXT_ROW_HEIGHT = TEXT_ROW_HEIGHT;
66
+
67
+ const Item = /*#__PURE__*/_react.default.forwardRef(({
68
+ variant = 'default',
69
+ disabled = false,
70
+ selected = undefined,
71
+ onSelect = () => null,
72
+ sx = {},
73
+ _PrivateItemWrapper = ({
74
+ children
75
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children),
76
+ ...props
77
+ }, forwardedRef) => {
78
+ const {
79
+ variant: listVariant,
80
+ showDividers
81
+ } = _react.default.useContext(_List.ListContext);
82
+
83
+ const {
84
+ theme
85
+ } = (0, _ThemeProvider.useTheme)();
86
+ const styles = {
87
+ display: 'flex',
88
+ paddingX: 2,
89
+ fontSize: 1,
90
+ paddingY: '6px',
91
+ // custom value off the scale
92
+ lineHeight: TEXT_ROW_HEIGHT,
93
+ marginX: listVariant === 'inset' ? 2 : 0,
94
+ minHeight: 5,
95
+ borderRadius: 2,
96
+ transition: 'background 33.333ms linear',
97
+ color: getVariantStyles(variant, disabled).color,
98
+ textDecoration: 'none',
99
+ // for as="a"
100
+ '&[aria-selected=true]': {
101
+ backgroundColor: getVariantStyles(variant, disabled).selectedBg
102
+ },
103
+ ':not([aria-disabled])': {
104
+ cursor: 'pointer'
105
+ },
106
+ '@media (hover: hover) and (pointer: fine)': {
107
+ ':hover:not([aria-disabled])': {
108
+ backgroundColor: `actionListItem.${variant}.hoverBg`,
109
+ color: getVariantStyles(variant, disabled).hoverColor
110
+ },
111
+ ':focus:not([aria-disabled])': {
112
+ backgroundColor: `actionListItem.${variant}.activeBg`,
113
+ color: getVariantStyles(variant, disabled).hoverColor,
114
+ outline: 'none'
115
+ }
116
+ },
117
+
118
+ /** Divider styles */
119
+ '[data-component="ActionList.Item--DividerContainer"]': {
120
+ position: 'relative'
121
+ },
122
+ '[data-component="ActionList.Item--DividerContainer"]::before': {
123
+ content: '" "',
124
+ display: 'block',
125
+ position: 'absolute',
126
+ width: '100%',
127
+ top: '-7px',
128
+ border: '0 solid',
129
+ borderTopWidth: showDividers ? `1px` : '0',
130
+ borderColor: 'var(--divider-color, transparent)'
131
+ },
132
+ // show between 2 items
133
+ ':not(:first-of-type):not([aria-selected=true])': {
134
+ '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
135
+ },
136
+ // hide divider after dividers & group header, with higher importance!
137
+ '[data-component="ActionList.Divider"] + &': {
138
+ '--divider-color': 'transparent !important'
139
+ },
140
+ // hide border on current and previous item
141
+ '&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
142
+ '--divider-color': 'transparent'
143
+ },
144
+ '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
145
+ '--divider-color': 'transparent'
146
+ },
147
+ // hide border around selected item
148
+ '&[aria-selected=true] + &': {
149
+ '--divider-color': 'transparent'
150
+ }
151
+ };
152
+
153
+ const clickHandler = _react.default.useCallback(event => {
154
+ if (disabled) return;
155
+ if (!event.defaultPrevented) onSelect(event);
156
+ }, [onSelect, disabled]);
157
+
158
+ const labelId = (0, _ssr.useSSRSafeId)();
159
+ const inlineDescriptionId = (0, _ssr.useSSRSafeId)();
160
+ const blockDescriptionId = (0, _ssr.useSSRSafeId)();
161
+ return /*#__PURE__*/_react.default.createElement(Slots, {
162
+ context: {
163
+ variant,
164
+ disabled,
165
+ inlineDescriptionId,
166
+ blockDescriptionId
167
+ }
168
+ }, slots => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
169
+ as: "li",
170
+ ref: forwardedRef,
171
+ sx: (0, _sx.merge)(styles, sx),
172
+ onClick: clickHandler,
173
+ "aria-selected": selected,
174
+ "aria-disabled": disabled ? true : undefined,
175
+ tabIndex: disabled ? undefined : -1,
176
+ "aria-labelledby": labelId,
177
+ "aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
178
+ }, props), /*#__PURE__*/_react.default.createElement(_PrivateItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
179
+ selected: selected,
180
+ disabled: disabled
181
+ }), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
182
+ "data-component": "ActionList.Item--DividerContainer",
183
+ sx: {
184
+ display: 'flex',
185
+ flexDirection: 'column',
186
+ flexGrow: 1,
187
+ minWidth: 0
188
+ }
189
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
190
+ if: Boolean(slots.TrailingVisual),
191
+ sx: {
192
+ display: 'flex',
193
+ flexGrow: 1
194
+ }
195
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
196
+ if: Boolean(slots.InlineDescription),
197
+ sx: {
198
+ display: 'flex',
199
+ flexGrow: 1,
200
+ alignItems: 'baseline',
201
+ minWidth: 0
202
+ }
203
+ }, /*#__PURE__*/_react.default.createElement(_Box.default, {
204
+ as: "span",
205
+ id: labelId,
206
+ sx: {
207
+ flexGrow: slots.InlineDescription ? 0 : 1
208
+ }
209
+ }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
210
+ });
211
+
212
+ exports.Item = Item;
213
+ Item.displayName = 'ActionList.Item';
214
+
215
+ const ConditionalBox = props => {
216
+ const {
217
+ if: condition,
218
+ ...rest
219
+ } = props;
220
+ if (condition) return /*#__PURE__*/_react.default.createElement(_Box.default, rest, props.children);else return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
221
+ };
@@ -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;