@primer/components 0.0.0-20211040541 → 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 (158) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/dist/browser.esm.js +473 -474
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +97 -98
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Description.d.ts +12 -0
  7. package/lib/ActionList2/Description.js +53 -0
  8. package/lib/ActionList2/Divider.d.ts +5 -0
  9. package/lib/ActionList2/Divider.js +35 -0
  10. package/lib/ActionList2/Group.d.ts +11 -0
  11. package/lib/ActionList2/Group.js +57 -0
  12. package/lib/ActionList2/Header.d.ts +26 -0
  13. package/lib/ActionList2/Header.js +55 -0
  14. package/lib/ActionList2/Item.d.ts +67 -0
  15. package/lib/ActionList2/Item.js +221 -0
  16. package/lib/ActionList2/LinkItem.d.ts +17 -0
  17. package/lib/ActionList2/LinkItem.js +57 -0
  18. package/lib/ActionList2/List.d.ts +26 -0
  19. package/lib/ActionList2/List.js +51 -0
  20. package/lib/ActionList2/Selection.d.ts +5 -0
  21. package/lib/ActionList2/Selection.js +70 -0
  22. package/lib/ActionList2/Visuals.d.ts +11 -0
  23. package/lib/ActionList2/Visuals.js +90 -0
  24. package/lib/ActionList2/index.d.ts +40 -0
  25. package/lib/ActionList2/index.js +47 -0
  26. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  27. package/lib/Autocomplete/Autocomplete.d.ts +28 -30
  28. package/lib/Autocomplete/AutocompleteInput.d.ts +28 -30
  29. package/lib/Button/Button.d.ts +24 -24
  30. package/lib/Button/Button.js +1 -1
  31. package/lib/Button/ButtonClose.d.ts +43 -43
  32. package/lib/Button/ButtonDanger.d.ts +24 -24
  33. package/lib/Button/ButtonInvisible.d.ts +24 -24
  34. package/lib/Button/ButtonOutline.d.ts +24 -24
  35. package/lib/Button/ButtonPrimary.d.ts +24 -24
  36. package/lib/CircleOcticon.d.ts +40 -40
  37. package/lib/Dialog.d.ts +43 -43
  38. package/lib/Dropdown.d.ts +168 -168
  39. package/lib/DropdownMenu/DropdownButton.d.ts +44 -44
  40. package/lib/FilterList.d.ts +40 -40
  41. package/lib/Position.d.ts +4 -4
  42. package/lib/SelectMenu/SelectMenu.d.ts +237 -239
  43. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  44. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  45. package/lib/TextInputWithTokens.d.ts +28 -30
  46. package/lib/Timeline.d.ts +41 -41
  47. package/lib/Token/AvatarToken.d.ts +1 -1
  48. package/lib/Token/IssueLabelToken.d.ts +1 -1
  49. package/lib/Token/Token.d.ts +1 -1
  50. package/lib/experiments.d.ts +1 -0
  51. package/lib/experiments.js +18 -0
  52. package/lib/hooks/useResizeObserver.d.ts +1 -1
  53. package/lib/hooks/useResizeObserver.js +1 -1
  54. package/lib/sx.d.ts +2 -0
  55. package/lib/sx.js +8 -0
  56. package/lib/theme-preval.js +79 -0
  57. package/lib/utils/create-slots.d.ts +17 -0
  58. package/lib/utils/create-slots.js +105 -0
  59. package/lib/utils/testing.d.ts +13 -0
  60. package/lib/utils/use-force-update.d.ts +1 -0
  61. package/lib/utils/use-force-update.js +19 -0
  62. package/lib-esm/ActionList2/Description.d.ts +12 -0
  63. package/lib-esm/ActionList2/Description.js +37 -0
  64. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  65. package/lib-esm/ActionList2/Divider.js +23 -0
  66. package/lib-esm/ActionList2/Group.d.ts +11 -0
  67. package/lib-esm/ActionList2/Group.js +40 -0
  68. package/lib-esm/ActionList2/Header.d.ts +26 -0
  69. package/lib-esm/ActionList2/Header.js +44 -0
  70. package/lib-esm/ActionList2/Item.d.ts +67 -0
  71. package/lib-esm/ActionList2/Item.js +195 -0
  72. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  73. package/lib-esm/ActionList2/LinkItem.js +43 -0
  74. package/lib-esm/ActionList2/List.d.ts +26 -0
  75. package/lib-esm/ActionList2/List.js +34 -0
  76. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  77. package/lib-esm/ActionList2/Selection.js +52 -0
  78. package/lib-esm/ActionList2/Visuals.d.ts +11 -0
  79. package/lib-esm/ActionList2/Visuals.js +68 -0
  80. package/lib-esm/ActionList2/index.d.ts +40 -0
  81. package/lib-esm/ActionList2/index.js +33 -0
  82. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  83. package/lib-esm/Autocomplete/Autocomplete.d.ts +28 -30
  84. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +28 -30
  85. package/lib-esm/Button/Button.d.ts +24 -24
  86. package/lib-esm/Button/Button.js +1 -1
  87. package/lib-esm/Button/ButtonClose.d.ts +43 -43
  88. package/lib-esm/Button/ButtonDanger.d.ts +24 -24
  89. package/lib-esm/Button/ButtonInvisible.d.ts +24 -24
  90. package/lib-esm/Button/ButtonOutline.d.ts +24 -24
  91. package/lib-esm/Button/ButtonPrimary.d.ts +24 -24
  92. package/lib-esm/CircleOcticon.d.ts +40 -40
  93. package/lib-esm/Dialog.d.ts +43 -43
  94. package/lib-esm/Dropdown.d.ts +168 -168
  95. package/lib-esm/DropdownMenu/DropdownButton.d.ts +44 -44
  96. package/lib-esm/FilterList.d.ts +40 -40
  97. package/lib-esm/Position.d.ts +4 -4
  98. package/lib-esm/SelectMenu/SelectMenu.d.ts +237 -239
  99. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  100. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  101. package/lib-esm/TextInputWithTokens.d.ts +28 -30
  102. package/lib-esm/Timeline.d.ts +41 -41
  103. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  104. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  105. package/lib-esm/Token/Token.d.ts +1 -1
  106. package/lib-esm/experiments.d.ts +1 -0
  107. package/lib-esm/experiments.js +2 -0
  108. package/lib-esm/hooks/useResizeObserver.d.ts +1 -1
  109. package/lib-esm/hooks/useResizeObserver.js +1 -1
  110. package/lib-esm/sx.d.ts +2 -0
  111. package/lib-esm/sx.js +3 -1
  112. package/lib-esm/theme-preval.js +79 -0
  113. package/lib-esm/utils/create-slots.d.ts +17 -0
  114. package/lib-esm/utils/create-slots.js +84 -0
  115. package/lib-esm/utils/testing.d.ts +13 -0
  116. package/lib-esm/utils/use-force-update.d.ts +1 -0
  117. package/lib-esm/utils/use-force-update.js +6 -0
  118. package/package.json +10 -9
  119. package/lib/DatePicker/DatePicker.d.ts +0 -52
  120. package/lib/DatePicker/DatePicker.js +0 -109
  121. package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
  122. package/lib/DatePicker/DatePickerAnchor.js +0 -202
  123. package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
  124. package/lib/DatePicker/DatePickerOverlay.js +0 -55
  125. package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
  126. package/lib/DatePicker/DatePickerPanel.js +0 -363
  127. package/lib/DatePicker/Day.d.ts +0 -15
  128. package/lib/DatePicker/Day.js +0 -206
  129. package/lib/DatePicker/Month.d.ts +0 -8
  130. package/lib/DatePicker/Month.js +0 -122
  131. package/lib/DatePicker/dateParser.d.ts +0 -12
  132. package/lib/DatePicker/dateParser.js +0 -192
  133. package/lib/DatePicker/index.d.ts +0 -2
  134. package/lib/DatePicker/index.js +0 -13
  135. package/lib/DatePicker/useDatePicker.d.ts +0 -107
  136. package/lib/DatePicker/useDatePicker.js +0 -558
  137. package/lib/hooks/useDebounce.d.ts +0 -2
  138. package/lib/hooks/useDebounce.js +0 -24
  139. package/lib-esm/DatePicker/DatePicker.d.ts +0 -52
  140. package/lib-esm/DatePicker/DatePicker.js +0 -92
  141. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
  142. package/lib-esm/DatePicker/DatePickerAnchor.js +0 -174
  143. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
  144. package/lib-esm/DatePicker/DatePickerOverlay.js +0 -40
  145. package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
  146. package/lib-esm/DatePicker/DatePickerPanel.js +0 -332
  147. package/lib-esm/DatePicker/Day.d.ts +0 -15
  148. package/lib-esm/DatePicker/Day.js +0 -182
  149. package/lib-esm/DatePicker/Month.d.ts +0 -8
  150. package/lib-esm/DatePicker/Month.js +0 -98
  151. package/lib-esm/DatePicker/dateParser.d.ts +0 -12
  152. package/lib-esm/DatePicker/dateParser.js +0 -178
  153. package/lib-esm/DatePicker/index.d.ts +0 -2
  154. package/lib-esm/DatePicker/index.js +0 -1
  155. package/lib-esm/DatePicker/useDatePicker.d.ts +0 -107
  156. package/lib-esm/DatePicker/useDatePicker.js +0 -523
  157. package/lib-esm/hooks/useDebounce.d.ts +0 -2
  158. package/lib-esm/hooks/useDebounce.js +0 -16
@@ -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;
@@ -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 {};