@primer/components 31.0.2-rc.c7dafefb → 31.2.0-rc.25d7c83f

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 (230) hide show
  1. package/.storybook/main.js +7 -9
  2. package/.storybook/preview.js +5 -1
  3. package/CHANGELOG.md +23 -1
  4. package/dist/browser.esm.js +623 -620
  5. package/dist/browser.esm.js.map +1 -1
  6. package/dist/browser.umd.js +164 -161
  7. package/dist/browser.umd.js.map +1 -1
  8. package/docs/content/ActionList2.mdx +354 -0
  9. package/docs/content/FilterList.md +2 -2
  10. package/docs/content/TextInputWithTokens.mdx +114 -0
  11. package/docs/content/getting-started.md +1 -1
  12. package/docs/content/theming.md +23 -0
  13. package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +1 -3
  14. package/docs/src/@primer/gatsby-theme-doctocat/components/live-preview-wrapper.js +1 -1
  15. package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +17 -0
  16. package/lib/ActionList/Header.js +1 -1
  17. package/lib/ActionList2/Description.d.ts +12 -0
  18. package/lib/ActionList2/Description.js +53 -0
  19. package/lib/ActionList2/Divider.d.ts +5 -0
  20. package/lib/ActionList2/Divider.js +35 -0
  21. package/lib/ActionList2/Group.d.ts +11 -0
  22. package/lib/ActionList2/Group.js +57 -0
  23. package/lib/ActionList2/Header.d.ts +26 -0
  24. package/lib/ActionList2/Header.js +55 -0
  25. package/lib/ActionList2/Item.d.ts +63 -0
  26. package/lib/ActionList2/Item.js +234 -0
  27. package/lib/ActionList2/LinkItem.d.ts +17 -0
  28. package/lib/ActionList2/LinkItem.js +57 -0
  29. package/lib/ActionList2/List.d.ts +26 -0
  30. package/lib/ActionList2/List.js +59 -0
  31. package/lib/ActionList2/Selection.d.ts +5 -0
  32. package/lib/ActionList2/Selection.js +70 -0
  33. package/lib/ActionList2/Visuals.d.ts +9 -0
  34. package/lib/ActionList2/Visuals.js +90 -0
  35. package/lib/ActionList2/index.d.ts +36 -0
  36. package/lib/ActionList2/index.js +47 -0
  37. package/lib/Autocomplete/Autocomplete.d.ts +4 -4
  38. package/lib/Autocomplete/AutocompleteInput.d.ts +4 -4
  39. package/lib/Button/Button.d.ts +5 -5
  40. package/lib/Button/ButtonBase.d.ts +1 -1
  41. package/lib/Button/ButtonClose.d.ts +3 -3
  42. package/lib/Button/ButtonDanger.d.ts +5 -5
  43. package/lib/Button/ButtonInvisible.d.ts +5 -5
  44. package/lib/Button/ButtonOutline.d.ts +5 -5
  45. package/lib/Button/ButtonPrimary.d.ts +5 -5
  46. package/lib/CircleBadge.d.ts +2 -2
  47. package/lib/CircleOcticon.d.ts +4 -4
  48. package/lib/Dialog.d.ts +4 -4
  49. package/lib/Dropdown.d.ts +16 -16
  50. package/lib/DropdownMenu/DropdownButton.d.ts +6 -6
  51. package/lib/FilterList.d.ts +3 -3
  52. package/lib/Flash.d.ts +1 -1
  53. package/lib/Label.d.ts +1 -1
  54. package/lib/Overlay.js +3 -1
  55. package/lib/Portal/Portal.js +3 -2
  56. package/lib/Position.d.ts +4 -4
  57. package/lib/ProgressBar.d.ts +1 -1
  58. package/lib/SelectMenu/SelectMenu.d.ts +24 -24
  59. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  60. package/lib/TextInputWithTokens.d.ts +8 -4
  61. package/lib/TextInputWithTokens.js +61 -8
  62. package/lib/Timeline.d.ts +4 -4
  63. package/lib/Token/AvatarToken.d.ts +1 -1
  64. package/lib/Token/IssueLabelToken.d.ts +1 -1
  65. package/lib/Token/Token.d.ts +1 -1
  66. package/lib/_TextInputWrapper.d.ts +1 -1
  67. package/lib/_TextInputWrapper.js +2 -2
  68. package/lib/__tests__/ActionList2.test.d.ts +1 -0
  69. package/lib/__tests__/ActionList2.test.js +53 -0
  70. package/lib/__tests__/AnchoredOverlay.test.js +4 -2
  71. package/lib/__tests__/KeyPaths.types.test.d.ts +11 -0
  72. package/lib/__tests__/KeyPaths.types.test.js +10 -0
  73. package/lib/__tests__/TextInputWithTokens.test.js +138 -7
  74. package/lib/__tests__/utils/createSlots.test.d.ts +1 -0
  75. package/lib/__tests__/utils/createSlots.test.js +75 -0
  76. package/lib/hooks/useAnchoredPosition.js +3 -2
  77. package/lib/hooks/useCombinedRefs.d.ts +2 -2
  78. package/lib/hooks/useCombinedRefs.js +4 -6
  79. package/lib/hooks/useResizeObserver.js +2 -2
  80. package/lib/stories/ActionList2.stories.js +907 -0
  81. package/lib/stories/TextInput.stories.js +144 -0
  82. package/lib/stories/TextInputWithTokens.stories.js +18 -1
  83. package/lib/stories/Token.stories.js +19 -2
  84. package/lib/sx.d.ts +10 -2
  85. package/lib/sx.js +8 -0
  86. package/lib/theme-preval.js +81 -2
  87. package/lib/theme.d.ts +78 -0
  88. package/lib/theme.js +3 -1
  89. package/lib/unreleased.d.ts +7 -0
  90. package/lib/unreleased.js +18 -0
  91. package/lib/utils/create-slots.d.ts +17 -0
  92. package/lib/utils/create-slots.js +105 -0
  93. package/lib/utils/testing.d.ts +14 -1
  94. package/lib/utils/types/KeyPaths.d.ts +3 -0
  95. package/lib/utils/types/KeyPaths.js +1 -0
  96. package/lib/utils/use-force-update.d.ts +1 -0
  97. package/lib/utils/use-force-update.js +19 -0
  98. package/lib/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  99. package/lib/utils/useIsomorphicLayoutEffect.js +12 -0
  100. package/lib-esm/ActionList/Header.js +1 -1
  101. package/lib-esm/ActionList2/Description.d.ts +12 -0
  102. package/lib-esm/ActionList2/Description.js +37 -0
  103. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  104. package/lib-esm/ActionList2/Divider.js +23 -0
  105. package/lib-esm/ActionList2/Group.d.ts +11 -0
  106. package/lib-esm/ActionList2/Group.js +40 -0
  107. package/lib-esm/ActionList2/Header.d.ts +26 -0
  108. package/lib-esm/ActionList2/Header.js +44 -0
  109. package/lib-esm/ActionList2/Item.d.ts +63 -0
  110. package/lib-esm/ActionList2/Item.js +201 -0
  111. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  112. package/lib-esm/ActionList2/LinkItem.js +43 -0
  113. package/lib-esm/ActionList2/List.d.ts +26 -0
  114. package/lib-esm/ActionList2/List.js +37 -0
  115. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  116. package/lib-esm/ActionList2/Selection.js +52 -0
  117. package/lib-esm/ActionList2/Visuals.d.ts +9 -0
  118. package/lib-esm/ActionList2/Visuals.js +68 -0
  119. package/lib-esm/ActionList2/index.d.ts +36 -0
  120. package/lib-esm/ActionList2/index.js +33 -0
  121. package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -4
  122. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -4
  123. package/lib-esm/Button/Button.d.ts +5 -5
  124. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  125. package/lib-esm/Button/ButtonClose.d.ts +3 -3
  126. package/lib-esm/Button/ButtonDanger.d.ts +5 -5
  127. package/lib-esm/Button/ButtonInvisible.d.ts +5 -5
  128. package/lib-esm/Button/ButtonOutline.d.ts +5 -5
  129. package/lib-esm/Button/ButtonPrimary.d.ts +5 -5
  130. package/lib-esm/CircleBadge.d.ts +2 -2
  131. package/lib-esm/CircleOcticon.d.ts +4 -4
  132. package/lib-esm/Dialog.d.ts +4 -4
  133. package/lib-esm/Dropdown.d.ts +16 -16
  134. package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -6
  135. package/lib-esm/FilterList.d.ts +3 -3
  136. package/lib-esm/Flash.d.ts +1 -1
  137. package/lib-esm/Label.d.ts +1 -1
  138. package/lib-esm/Overlay.js +2 -1
  139. package/lib-esm/Portal/Portal.js +2 -1
  140. package/lib-esm/Position.d.ts +4 -4
  141. package/lib-esm/ProgressBar.d.ts +1 -1
  142. package/lib-esm/SelectMenu/SelectMenu.d.ts +24 -24
  143. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  144. package/lib-esm/TextInputWithTokens.d.ts +8 -4
  145. package/lib-esm/TextInputWithTokens.js +60 -8
  146. package/lib-esm/Timeline.d.ts +4 -4
  147. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  148. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  149. package/lib-esm/Token/Token.d.ts +1 -1
  150. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  151. package/lib-esm/_TextInputWrapper.js +2 -2
  152. package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
  153. package/lib-esm/__tests__/ActionList2.test.js +41 -0
  154. package/lib-esm/__tests__/AnchoredOverlay.test.js +4 -2
  155. package/lib-esm/__tests__/KeyPaths.types.test.d.ts +11 -0
  156. package/lib-esm/__tests__/KeyPaths.types.test.js +3 -0
  157. package/lib-esm/__tests__/TextInputWithTokens.test.js +132 -8
  158. package/lib-esm/__tests__/utils/createSlots.test.d.ts +1 -0
  159. package/lib-esm/__tests__/utils/createSlots.test.js +67 -0
  160. package/lib-esm/hooks/useAnchoredPosition.js +2 -1
  161. package/lib-esm/hooks/useCombinedRefs.d.ts +2 -2
  162. package/lib-esm/hooks/useCombinedRefs.js +3 -2
  163. package/lib-esm/hooks/useResizeObserver.js +2 -2
  164. package/lib-esm/stories/ActionList2.stories.js +796 -0
  165. package/lib-esm/stories/TextInput.stories.js +117 -0
  166. package/lib-esm/stories/TextInputWithTokens.stories.js +14 -0
  167. package/lib-esm/stories/Token.stories.js +14 -1
  168. package/lib-esm/sx.d.ts +10 -2
  169. package/lib-esm/sx.js +3 -1
  170. package/lib-esm/theme-preval.js +81 -2
  171. package/lib-esm/theme.d.ts +78 -0
  172. package/lib-esm/theme.js +2 -1
  173. package/lib-esm/unreleased.d.ts +7 -0
  174. package/lib-esm/unreleased.js +8 -0
  175. package/lib-esm/utils/create-slots.d.ts +17 -0
  176. package/lib-esm/utils/create-slots.js +84 -0
  177. package/lib-esm/utils/testing.d.ts +14 -1
  178. package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
  179. package/lib-esm/utils/types/KeyPaths.js +1 -0
  180. package/lib-esm/utils/use-force-update.d.ts +1 -0
  181. package/lib-esm/utils/use-force-update.js +6 -0
  182. package/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  183. package/lib-esm/utils/useIsomorphicLayoutEffect.js +3 -0
  184. package/migrating.md +1 -1
  185. package/package-lock.json +38098 -45
  186. package/package.json +7 -3
  187. package/script/build +2 -0
  188. package/src/ActionList/Header.tsx +1 -1
  189. package/src/ActionList2/Description.tsx +49 -0
  190. package/src/ActionList2/Divider.tsx +24 -0
  191. package/src/ActionList2/Group.tsx +34 -0
  192. package/src/ActionList2/Header.tsx +58 -0
  193. package/src/ActionList2/Item.tsx +223 -0
  194. package/src/ActionList2/LinkItem.tsx +49 -0
  195. package/src/ActionList2/List.tsx +55 -0
  196. package/src/ActionList2/Selection.tsx +40 -0
  197. package/src/ActionList2/Visuals.tsx +76 -0
  198. package/src/ActionList2/index.ts +39 -0
  199. package/src/Overlay.tsx +2 -1
  200. package/src/Portal/Portal.tsx +2 -1
  201. package/src/TextInputWithTokens.tsx +64 -8
  202. package/src/_TextInputWrapper.tsx +8 -0
  203. package/src/__tests__/ActionList2.test.tsx +47 -0
  204. package/src/__tests__/AnchoredOverlay.test.tsx +2 -2
  205. package/src/__tests__/KeyPaths.types.test.ts +14 -0
  206. package/src/__tests__/TextInputWithTokens.test.tsx +123 -1
  207. package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
  208. package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +35 -135
  209. package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +7 -0
  210. package/src/__tests__/__snapshots__/TextInput.test.tsx.snap +6 -0
  211. package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +463 -0
  212. package/src/__tests__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
  213. package/src/__tests__/utils/createSlots.test.tsx +74 -0
  214. package/src/hooks/useAnchoredPosition.ts +2 -1
  215. package/src/hooks/useCombinedRefs.ts +3 -3
  216. package/src/hooks/useResizeObserver.ts +2 -2
  217. package/src/stories/ActionList2.stories.tsx +1290 -0
  218. package/src/stories/Button.stories.tsx +1 -1
  219. package/src/stories/TextInput.stories.tsx +113 -0
  220. package/src/stories/TextInputWithTokens.stories.tsx +9 -0
  221. package/src/stories/Token.stories.tsx +12 -1
  222. package/src/sx.ts +17 -2
  223. package/src/theme-preval.js +1 -0
  224. package/src/theme.ts +86 -0
  225. package/src/unreleased.ts +9 -0
  226. package/src/utils/create-slots.tsx +96 -0
  227. package/src/utils/types/KeyPaths.ts +10 -0
  228. package/src/utils/use-force-update.ts +7 -0
  229. package/src/utils/useIsomorphicLayoutEffect.ts +10 -0
  230. package/stats.html +1 -1
@@ -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,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,234 @@
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
+ children
87
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children),
88
+ ...props
89
+ }, forwardedRef) => {
90
+ const {
91
+ variant: listVariant,
92
+ showDividers
93
+ } = _react.default.useContext(_List.ListContext);
94
+
95
+ const {
96
+ theme
97
+ } = (0, _ThemeProvider.useTheme)();
98
+ const styles = {
99
+ display: 'flex',
100
+ paddingX: 2,
101
+ fontSize: 1,
102
+ paddingY: '6px',
103
+ // custom value off the scale
104
+ lineHeight: TEXT_ROW_HEIGHT,
105
+ marginX: listVariant === 'inset' ? 2 : 0,
106
+ minHeight: 5,
107
+ borderRadius: 2,
108
+ transition: 'background 33.333ms linear',
109
+ color: getVariantStyles(variant, disabled).color,
110
+ textDecoration: 'none',
111
+ // for as="a"
112
+ ':not([aria-disabled])': {
113
+ cursor: 'pointer'
114
+ },
115
+ '@media (hover: hover) and (pointer: fine)': {
116
+ ':hover:not([aria-disabled])': {
117
+ backgroundColor: `actionListItem.${variant}.hoverBg`,
118
+ color: getVariantStyles(variant, disabled).hoverColor
119
+ },
120
+ ':focus:not([aria-disabled])': {
121
+ backgroundColor: `actionListItem.${variant}.selectedBg`,
122
+ color: getVariantStyles(variant, disabled).hoverColor,
123
+ outline: 'none'
124
+ },
125
+ ':active:not([aria-disabled])': {
126
+ backgroundColor: `actionListItem.${variant}.activeBg`,
127
+ color: getVariantStyles(variant, disabled).hoverColor
128
+ }
129
+ },
130
+
131
+ /** Divider styles */
132
+ '[data-component="ActionList.Item--DividerContainer"]': {
133
+ position: 'relative'
134
+ },
135
+ '[data-component="ActionList.Item--DividerContainer"]::before': {
136
+ content: '" "',
137
+ display: 'block',
138
+ position: 'absolute',
139
+ width: '100%',
140
+ top: '-7px',
141
+ border: '0 solid',
142
+ borderTopWidth: showDividers ? `1px` : '0',
143
+ borderColor: 'var(--divider-color, transparent)'
144
+ },
145
+ // show between 2 items
146
+ ':not(:first-of-type):not([aria-selected=true])': {
147
+ '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
148
+ },
149
+ // hide divider after dividers & group header, with higher importance!
150
+ '[data-component="ActionList.Divider"] + &': {
151
+ '--divider-color': 'transparent !important'
152
+ },
153
+ // hide border on current and previous item
154
+ '&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
155
+ '--divider-color': 'transparent'
156
+ },
157
+ '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
158
+ '--divider-color': 'transparent'
159
+ },
160
+ // hide border around selected item
161
+ '&[aria-selected=true] + &': {
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]); // use props.id if provided, otherwise generate one.
170
+
171
+
172
+ const labelId = (0, _ssr.useSSRSafeId)(id);
173
+ const inlineDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--inline-description`);
174
+ const blockDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--block-description`);
175
+ return /*#__PURE__*/_react.default.createElement(Slots, {
176
+ context: {
177
+ variant,
178
+ disabled,
179
+ inlineDescriptionId,
180
+ blockDescriptionId
181
+ }
182
+ }, slots => /*#__PURE__*/_react.default.createElement(LiBox, _extends({
183
+ ref: forwardedRef,
184
+ sx: (0, _sx.merge)(styles, sxProp),
185
+ onClick: clickHandler,
186
+ "aria-selected": selected,
187
+ "aria-disabled": disabled ? true : undefined,
188
+ tabIndex: disabled ? undefined : -1,
189
+ "aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
190
+ "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
191
+ }, props), /*#__PURE__*/_react.default.createElement(_PrivateItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
192
+ selected: selected,
193
+ disabled: disabled
194
+ }), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
195
+ "data-component": "ActionList.Item--DividerContainer",
196
+ sx: {
197
+ display: 'flex',
198
+ flexDirection: 'column',
199
+ flexGrow: 1,
200
+ minWidth: 0
201
+ }
202
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
203
+ if: Boolean(slots.TrailingVisual),
204
+ sx: {
205
+ display: 'flex',
206
+ flexGrow: 1
207
+ }
208
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
209
+ if: Boolean(slots.InlineDescription),
210
+ sx: {
211
+ display: 'flex',
212
+ flexGrow: 1,
213
+ alignItems: 'baseline',
214
+ minWidth: 0
215
+ }
216
+ }, /*#__PURE__*/_react.default.createElement(_Box.default, {
217
+ as: "span",
218
+ id: labelId,
219
+ sx: {
220
+ flexGrow: slots.InlineDescription ? 0 : 1
221
+ }
222
+ }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
223
+ });
224
+
225
+ exports.Item = Item;
226
+ Item.displayName = 'ActionList.Item';
227
+
228
+ const ConditionalBox = props => {
229
+ const {
230
+ if: condition,
231
+ ...rest
232
+ } = props;
233
+ if (condition) return /*#__PURE__*/_react.default.createElement(_Box.default, rest, props.children);else return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
234
+ };
@@ -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 {};