@primer/components 0.0.0-2021104155729 → 0.0.0-20211086336

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 (126) hide show
  1. package/CHANGELOG.md +5 -5
  2. package/dist/browser.esm.js +616 -616
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +196 -196
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/Autocomplete/Autocomplete.d.ts +26 -26
  7. package/lib/Autocomplete/AutocompleteInput.d.ts +26 -26
  8. package/lib/Button/Button.d.ts +24 -24
  9. package/lib/Button/ButtonClose.d.ts +43 -43
  10. package/lib/Button/ButtonDanger.d.ts +24 -24
  11. package/lib/Button/ButtonInvisible.d.ts +24 -24
  12. package/lib/Button/ButtonOutline.d.ts +24 -24
  13. package/lib/Button/ButtonPrimary.d.ts +24 -24
  14. package/lib/CircleOcticon.d.ts +40 -40
  15. package/lib/Dialog.d.ts +43 -43
  16. package/lib/Dropdown.d.ts +168 -168
  17. package/lib/DropdownMenu/DropdownButton.d.ts +44 -44
  18. package/lib/FilterList.d.ts +40 -40
  19. package/lib/Overlay.js +3 -1
  20. package/lib/Portal/Portal.js +4 -3
  21. package/lib/Position.d.ts +4 -4
  22. package/lib/SelectMenu/SelectMenu.d.ts +235 -235
  23. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  24. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  25. package/lib/TextInputWithTokens.d.ts +26 -26
  26. package/lib/Timeline.d.ts +41 -41
  27. package/lib/Token/AvatarToken.d.ts +1 -1
  28. package/lib/Token/IssueLabelToken.d.ts +1 -1
  29. package/lib/Token/Token.d.ts +1 -1
  30. package/lib/hooks/useAnchoredPosition.js +3 -2
  31. package/lib/hooks/useCombinedRefs.d.ts +2 -2
  32. package/lib/hooks/useCombinedRefs.js +4 -9
  33. package/lib/hooks/useResizeObserver.js +2 -4
  34. package/lib/sx.d.ts +0 -2
  35. package/lib/sx.js +0 -8
  36. package/lib/theme-preval.js +2 -81
  37. package/lib/utils/testing.d.ts +1 -14
  38. package/lib/utils/useIsomorphicLayoutEffect.d.ts +2 -0
  39. package/lib/utils/useIsomorphicLayoutEffect.js +14 -0
  40. package/lib-esm/Autocomplete/Autocomplete.d.ts +26 -26
  41. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +26 -26
  42. package/lib-esm/Button/Button.d.ts +24 -24
  43. package/lib-esm/Button/ButtonClose.d.ts +43 -43
  44. package/lib-esm/Button/ButtonDanger.d.ts +24 -24
  45. package/lib-esm/Button/ButtonInvisible.d.ts +24 -24
  46. package/lib-esm/Button/ButtonOutline.d.ts +24 -24
  47. package/lib-esm/Button/ButtonPrimary.d.ts +24 -24
  48. package/lib-esm/CircleOcticon.d.ts +40 -40
  49. package/lib-esm/Dialog.d.ts +43 -43
  50. package/lib-esm/Dropdown.d.ts +168 -168
  51. package/lib-esm/DropdownMenu/DropdownButton.d.ts +44 -44
  52. package/lib-esm/FilterList.d.ts +40 -40
  53. package/lib-esm/Overlay.js +2 -1
  54. package/lib-esm/Portal/Portal.js +3 -2
  55. package/lib-esm/Position.d.ts +4 -4
  56. package/lib-esm/SelectMenu/SelectMenu.d.ts +235 -235
  57. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  58. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  59. package/lib-esm/TextInputWithTokens.d.ts +26 -26
  60. package/lib-esm/Timeline.d.ts +41 -41
  61. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  62. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  63. package/lib-esm/Token/Token.d.ts +1 -1
  64. package/lib-esm/hooks/useAnchoredPosition.js +2 -1
  65. package/lib-esm/hooks/useCombinedRefs.d.ts +2 -2
  66. package/lib-esm/hooks/useCombinedRefs.js +4 -4
  67. package/lib-esm/hooks/useResizeObserver.js +2 -2
  68. package/lib-esm/sx.d.ts +0 -2
  69. package/lib-esm/sx.js +1 -3
  70. package/lib-esm/theme-preval.js +2 -81
  71. package/lib-esm/utils/testing.d.ts +1 -14
  72. package/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +2 -0
  73. package/lib-esm/utils/useIsomorphicLayoutEffect.js +4 -0
  74. package/package.json +2 -4
  75. package/lib/ActionList2/Description.d.ts +0 -12
  76. package/lib/ActionList2/Description.js +0 -53
  77. package/lib/ActionList2/Divider.d.ts +0 -5
  78. package/lib/ActionList2/Divider.js +0 -35
  79. package/lib/ActionList2/Group.d.ts +0 -11
  80. package/lib/ActionList2/Group.js +0 -57
  81. package/lib/ActionList2/Header.d.ts +0 -26
  82. package/lib/ActionList2/Header.js +0 -55
  83. package/lib/ActionList2/Item.d.ts +0 -71
  84. package/lib/ActionList2/Item.js +0 -223
  85. package/lib/ActionList2/LinkItem.d.ts +0 -17
  86. package/lib/ActionList2/LinkItem.js +0 -57
  87. package/lib/ActionList2/List.d.ts +0 -26
  88. package/lib/ActionList2/List.js +0 -51
  89. package/lib/ActionList2/Selection.d.ts +0 -5
  90. package/lib/ActionList2/Selection.js +0 -70
  91. package/lib/ActionList2/Visuals.d.ts +0 -11
  92. package/lib/ActionList2/Visuals.js +0 -90
  93. package/lib/ActionList2/index.d.ts +0 -40
  94. package/lib/ActionList2/index.js +0 -47
  95. package/lib/experiments.d.ts +0 -1
  96. package/lib/experiments.js +0 -18
  97. package/lib/utils/create-slots.d.ts +0 -17
  98. package/lib/utils/create-slots.js +0 -105
  99. package/lib/utils/use-force-update.d.ts +0 -1
  100. package/lib/utils/use-force-update.js +0 -19
  101. package/lib-esm/ActionList2/Description.d.ts +0 -12
  102. package/lib-esm/ActionList2/Description.js +0 -37
  103. package/lib-esm/ActionList2/Divider.d.ts +0 -5
  104. package/lib-esm/ActionList2/Divider.js +0 -23
  105. package/lib-esm/ActionList2/Group.d.ts +0 -11
  106. package/lib-esm/ActionList2/Group.js +0 -40
  107. package/lib-esm/ActionList2/Header.d.ts +0 -26
  108. package/lib-esm/ActionList2/Header.js +0 -44
  109. package/lib-esm/ActionList2/Item.d.ts +0 -71
  110. package/lib-esm/ActionList2/Item.js +0 -197
  111. package/lib-esm/ActionList2/LinkItem.d.ts +0 -17
  112. package/lib-esm/ActionList2/LinkItem.js +0 -43
  113. package/lib-esm/ActionList2/List.d.ts +0 -26
  114. package/lib-esm/ActionList2/List.js +0 -34
  115. package/lib-esm/ActionList2/Selection.d.ts +0 -5
  116. package/lib-esm/ActionList2/Selection.js +0 -52
  117. package/lib-esm/ActionList2/Visuals.d.ts +0 -11
  118. package/lib-esm/ActionList2/Visuals.js +0 -68
  119. package/lib-esm/ActionList2/index.d.ts +0 -40
  120. package/lib-esm/ActionList2/index.js +0 -33
  121. package/lib-esm/experiments.d.ts +0 -1
  122. package/lib-esm/experiments.js +0 -2
  123. package/lib-esm/utils/create-slots.d.ts +0 -17
  124. package/lib-esm/utils/create-slots.js +0 -84
  125. package/lib-esm/utils/use-force-update.d.ts +0 -1
  126. package/lib-esm/utils/use-force-update.js +0 -6
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _useForceUpdate = require("./use-force-update");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- /** createSlots is a factory that can create a
15
- * typesafe Slots + Slot pair to use in a component definition
16
- * For example: ActionList.Item uses createSlots to get a Slots wrapper
17
- * + Slot component that is used by LeadingVisual, Description
18
- */
19
- const createSlots = slotNames => {
20
- const SlotsContext = /*#__PURE__*/_react.default.createContext({
21
- registerSlot: () => null,
22
- unregisterSlot: () => null,
23
- context: {}
24
- });
25
- /** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
26
- * Slot registers themself with the Slots parent.
27
- * When all the children have mounted = registered themselves in slot,
28
- * we re-render the parent component to render with slots
29
- */
30
-
31
-
32
- const Slots = ({
33
- context = {},
34
- children
35
- }) => {
36
- // initialise slots
37
- const slotsDefinition = {};
38
- slotNames.map(name => slotsDefinition[name] = null);
39
-
40
- const slotsRef = _react.default.useRef(slotsDefinition);
41
-
42
- const rerenderWithSlots = (0, _useForceUpdate.useForceUpdate)();
43
-
44
- const [isMounted, setIsMounted] = _react.default.useState(false); // fires after all the effects in children
45
-
46
-
47
- _react.default.useEffect(() => {
48
- rerenderWithSlots();
49
- setIsMounted(true);
50
- }, [rerenderWithSlots]);
51
-
52
- const registerSlot = _react.default.useCallback((name, contents) => {
53
- slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
54
-
55
- if (isMounted) rerenderWithSlots();
56
- }, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
57
- // we need to unregister them from the slot
58
-
59
-
60
- const unregisterSlot = _react.default.useCallback(name => {
61
- slotsRef.current[name] = null;
62
- rerenderWithSlots();
63
- }, [rerenderWithSlots]);
64
- /**
65
- * Slots uses a render prop API so abstract the
66
- * implementation detail of using a context provider.
67
- */
68
-
69
-
70
- const slots = slotsRef.current;
71
- return /*#__PURE__*/_react.default.createElement(SlotsContext.Provider, {
72
- value: {
73
- registerSlot,
74
- unregisterSlot,
75
- context
76
- }
77
- }, children(slots));
78
- };
79
-
80
- const Slot = ({
81
- name,
82
- children
83
- }) => {
84
- const {
85
- registerSlot,
86
- unregisterSlot,
87
- context
88
- } = _react.default.useContext(SlotsContext);
89
-
90
- _react.default.useEffect(() => {
91
- registerSlot(name, typeof children === 'function' ? children(context) : children);
92
- return () => unregisterSlot(name);
93
- }, [name, children, registerSlot, unregisterSlot, context]);
94
-
95
- return null;
96
- };
97
-
98
- return {
99
- Slots,
100
- Slot
101
- };
102
- };
103
-
104
- var _default = createSlots;
105
- exports.default = _default;
@@ -1 +0,0 @@
1
- export declare const useForceUpdate: () => () => void;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useForceUpdate = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- // Inspired from reach-ui: https://github.com/reach/reach-ui/blob/develop/packages/utils/src/use-force-update.ts
13
- const useForceUpdate = () => {
14
- const [, rerender] = _react.default.useState({});
15
-
16
- return _react.default.useCallback(() => rerender({}), []);
17
- };
18
-
19
- exports.useForceUpdate = useForceUpdate;
@@ -1,12 +0,0 @@
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>;
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import Box from '../Box';
3
- import { merge } from '../sx';
4
- import Truncate from '../Truncate';
5
- import { Slot } from './Item';
6
- export const Description = ({
7
- variant = 'inline',
8
- sx = {},
9
- ...props
10
- }) => {
11
- const styles = {
12
- color: 'fg.muted',
13
- fontSize: 0,
14
- lineHeight: '16px',
15
- flexGrow: 1,
16
- flexBasis: 0,
17
- minWidth: 0,
18
- marginLeft: variant === 'block' ? 0 : 2
19
- };
20
- return /*#__PURE__*/React.createElement(Slot, {
21
- name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
22
- }, ({
23
- blockDescriptionId,
24
- inlineDescriptionId
25
- }) => variant === 'block' ? /*#__PURE__*/React.createElement(Box, {
26
- as: "span",
27
- sx: merge(styles, sx),
28
- id: blockDescriptionId
29
- }, props.children) : /*#__PURE__*/React.createElement(Truncate, {
30
- id: inlineDescriptionId,
31
- sx: merge(styles, sx),
32
- title: props.children,
33
- inline: true,
34
- maxWidth: "100%"
35
- }, props.children));
36
- };
37
- Description.displayName = "Description";
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Visually separates `Item`s or `Group`s in an `ActionList`.
4
- */
5
- export declare function Divider(): JSX.Element;
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import Box from '../Box';
3
- import { get } from '../constants';
4
-
5
- /**
6
- * Visually separates `Item`s or `Group`s in an `ActionList`.
7
- */
8
- export function Divider() {
9
- return /*#__PURE__*/React.createElement(Box, {
10
- as: "li",
11
- role: "separator",
12
- sx: {
13
- height: 1,
14
- backgroundColor: 'actionListItem.inlineDivider',
15
- marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
16
- marginBottom: 2,
17
- listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
18
-
19
- },
20
- "data-component": "ActionList.Divider"
21
- });
22
- }
23
- Divider.displayName = "Divider";
@@ -1,11 +0,0 @@
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 {};
@@ -1,40 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import Box from '../Box';
5
- import { Header } from './Header';
6
- export const GroupContext = /*#__PURE__*/React.createContext({});
7
- export const Group = ({
8
- title,
9
- variant,
10
- auxiliaryText,
11
- selectionVariant,
12
- sx = {},
13
- ...props
14
- }) => {
15
- return /*#__PURE__*/React.createElement(Box, _extends({
16
- as: "li",
17
- sx: {
18
- '&:not(:first-child)': {
19
- marginTop: 2
20
- },
21
- listStyle: 'none',
22
- // hide the ::marker inserted by browser's stylesheet
23
- ...sx
24
- }
25
- }, props), title && /*#__PURE__*/React.createElement(Header, {
26
- title: title,
27
- variant: variant,
28
- auxiliaryText: auxiliaryText
29
- }), /*#__PURE__*/React.createElement(GroupContext.Provider, {
30
- value: {
31
- selectionVariant
32
- }
33
- }, /*#__PURE__*/React.createElement(Box, {
34
- as: "ul",
35
- sx: {
36
- paddingInlineStart: 0
37
- }
38
- }, props.children)));
39
- };
40
- Group.displayName = "Group";
@@ -1,26 +0,0 @@
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;
@@ -1,44 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import Box from '../Box';
5
- import { ListContext } from './List';
6
- /**
7
- * Contract for props passed to the `Header` component.
8
- */
9
-
10
- /**
11
- * Displays the name and description of a `Group`.
12
- */
13
- export const Header = ({
14
- variant = 'subtle',
15
- title,
16
- auxiliaryText,
17
- sx = {},
18
- ...props
19
- }) => {
20
- const {
21
- variant: listVariant
22
- } = React.useContext(ListContext);
23
- const styles = {
24
- paddingY: '6px',
25
- paddingX: listVariant === 'full' ? 2 : 3,
26
- fontSize: 0,
27
- fontWeight: 'bold',
28
- color: 'fg.muted',
29
- ...(variant === 'filled' && {
30
- backgroundColor: 'canvas.subtle',
31
- marginX: 0,
32
- marginBottom: 2,
33
- borderTop: '1px solid',
34
- borderBottom: '1px solid',
35
- borderColor: 'neutral.muted'
36
- }),
37
- ...sx
38
- };
39
- return /*#__PURE__*/React.createElement(Box, _extends({
40
- sx: styles,
41
- role: "heading"
42
- }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
43
- };
44
- Header.displayName = "Header";
@@ -1,71 +0,0 @@
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
- * id to attach to the root element of the Item
54
- */
55
- id?: string;
56
- /**
57
- * Private API for use internally only. Used by LinkItem to wrap contents in an anchor
58
- */
59
- _PrivateItemWrapper?: React.FC;
60
- } & SxProp;
61
- declare const Slot: React.FC<{
62
- name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
63
- children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
64
- }>;
65
- export { Slot };
66
- export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
67
- inlineDescriptionId: string;
68
- blockDescriptionId: string;
69
- };
70
- export declare const TEXT_ROW_HEIGHT = "20px";
71
- export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
@@ -1,197 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import { useSSRSafeId } from '@react-aria/ssr';
5
- import { useTheme } from '../ThemeProvider';
6
- import Box from '../Box';
7
- import { merge } from '../sx';
8
- import createSlots from '../utils/create-slots';
9
- import { ListContext } from './List';
10
- import { Selection } from './Selection';
11
- export const getVariantStyles = (variant, disabled) => {
12
- if (disabled) {
13
- return {
14
- color: 'fg.muted',
15
- iconColor: 'fg.muted',
16
- annotationColor: 'fg.muted'
17
- };
18
- }
19
-
20
- switch (variant) {
21
- case 'danger':
22
- return {
23
- color: 'danger.fg',
24
- iconColor: 'danger.fg',
25
- annotationColor: 'fg.muted',
26
- hoverColor: 'actionListItem.danger.hoverText'
27
- };
28
-
29
- default:
30
- return {
31
- color: 'fg.default',
32
- iconColor: 'fg.muted',
33
- annotationColor: 'fg.muted',
34
- hoverColor: 'fg.default',
35
- selectedBg: 'actionListItem.default.selectedBg'
36
- };
37
- }
38
- };
39
- const {
40
- Slots,
41
- Slot
42
- } = createSlots(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
43
- export { Slot };
44
- export const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
45
-
46
- export const Item = /*#__PURE__*/React.forwardRef(({
47
- variant = 'default',
48
- disabled = false,
49
- selected = undefined,
50
- onSelect = () => null,
51
- sx = {},
52
- id,
53
- _PrivateItemWrapper = ({
54
- children
55
- }) => /*#__PURE__*/React.createElement(React.Fragment, null, children),
56
- ...props
57
- }, forwardedRef) => {
58
- const {
59
- variant: listVariant,
60
- showDividers
61
- } = React.useContext(ListContext);
62
- const {
63
- theme
64
- } = useTheme();
65
- const styles = {
66
- display: 'flex',
67
- paddingX: 2,
68
- fontSize: 1,
69
- paddingY: '6px',
70
- // custom value off the scale
71
- lineHeight: TEXT_ROW_HEIGHT,
72
- marginX: listVariant === 'inset' ? 2 : 0,
73
- minHeight: 5,
74
- borderRadius: 2,
75
- transition: 'background 33.333ms linear',
76
- color: getVariantStyles(variant, disabled).color,
77
- textDecoration: 'none',
78
- // for as="a"
79
- '&[aria-selected=true]': {
80
- backgroundColor: getVariantStyles(variant, disabled).selectedBg
81
- },
82
- ':not([aria-disabled])': {
83
- cursor: 'pointer'
84
- },
85
- '@media (hover: hover) and (pointer: fine)': {
86
- ':hover:not([aria-disabled])': {
87
- backgroundColor: `actionListItem.${variant}.hoverBg`,
88
- color: getVariantStyles(variant, disabled).hoverColor
89
- },
90
- ':focus:not([aria-disabled])': {
91
- backgroundColor: `actionListItem.${variant}.activeBg`,
92
- color: getVariantStyles(variant, disabled).hoverColor,
93
- outline: 'none'
94
- }
95
- },
96
-
97
- /** Divider styles */
98
- '[data-component="ActionList.Item--DividerContainer"]': {
99
- position: 'relative'
100
- },
101
- '[data-component="ActionList.Item--DividerContainer"]::before': {
102
- content: '" "',
103
- display: 'block',
104
- position: 'absolute',
105
- width: '100%',
106
- top: '-7px',
107
- border: '0 solid',
108
- borderTopWidth: showDividers ? `1px` : '0',
109
- borderColor: 'var(--divider-color, transparent)'
110
- },
111
- // show between 2 items
112
- ':not(:first-of-type):not([aria-selected=true])': {
113
- '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
114
- },
115
- // hide divider after dividers & group header, with higher importance!
116
- '[data-component="ActionList.Divider"] + &': {
117
- '--divider-color': 'transparent !important'
118
- },
119
- // hide border on current and previous item
120
- '&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
121
- '--divider-color': 'transparent'
122
- },
123
- '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
124
- '--divider-color': 'transparent'
125
- },
126
- // hide border around selected item
127
- '&[aria-selected=true] + &': {
128
- '--divider-color': 'transparent'
129
- }
130
- };
131
- const clickHandler = React.useCallback(event => {
132
- if (disabled) return;
133
- if (!event.defaultPrevented) onSelect(event);
134
- }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
135
-
136
- const labelId = useSSRSafeId(id);
137
- const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
138
- const blockDescriptionId = useSSRSafeId(id && `${id}--block-description`);
139
- return /*#__PURE__*/React.createElement(Slots, {
140
- context: {
141
- variant,
142
- disabled,
143
- inlineDescriptionId,
144
- blockDescriptionId
145
- }
146
- }, slots => /*#__PURE__*/React.createElement(Box, _extends({
147
- as: "li",
148
- ref: forwardedRef,
149
- sx: merge(styles, sx),
150
- onClick: clickHandler,
151
- "aria-selected": selected,
152
- "aria-disabled": disabled ? true : undefined,
153
- tabIndex: disabled ? undefined : -1,
154
- "aria-labelledby": labelId,
155
- "aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
156
- }, props), /*#__PURE__*/React.createElement(_PrivateItemWrapper, null, /*#__PURE__*/React.createElement(Selection, {
157
- selected: selected,
158
- disabled: disabled
159
- }), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
160
- "data-component": "ActionList.Item--DividerContainer",
161
- sx: {
162
- display: 'flex',
163
- flexDirection: 'column',
164
- flexGrow: 1,
165
- minWidth: 0
166
- }
167
- }, /*#__PURE__*/React.createElement(ConditionalBox, {
168
- if: Boolean(slots.TrailingVisual),
169
- sx: {
170
- display: 'flex',
171
- flexGrow: 1
172
- }
173
- }, /*#__PURE__*/React.createElement(ConditionalBox, {
174
- if: Boolean(slots.InlineDescription),
175
- sx: {
176
- display: 'flex',
177
- flexGrow: 1,
178
- alignItems: 'baseline',
179
- minWidth: 0
180
- }
181
- }, /*#__PURE__*/React.createElement(Box, {
182
- as: "span",
183
- id: labelId,
184
- sx: {
185
- flexGrow: slots.InlineDescription ? 0 : 1
186
- }
187
- }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
188
- });
189
- Item.displayName = 'ActionList.Item';
190
-
191
- const ConditionalBox = props => {
192
- const {
193
- if: condition,
194
- ...rest
195
- } = props;
196
- if (condition) return /*#__PURE__*/React.createElement(Box, rest, props.children);else return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
197
- };
@@ -1,17 +0,0 @@
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 {};
@@ -1,43 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import Link from '../Link';
5
- import { merge } from '../sx';
6
- import { Item } from './Item'; // adopted from React.AnchorHTMLAttributes
7
-
8
- export const LinkItem = /*#__PURE__*/React.forwardRef(({
9
- sx = {},
10
- as: Component,
11
- ...props
12
- }, forwardedRef) => {
13
- const styles = {
14
- // occupy full size of Item
15
- paddingX: 2,
16
- paddingY: '6px',
17
- // custom value off the scale
18
- display: 'flex',
19
- flexGrow: 1,
20
- // full width
21
- borderRadius: 2,
22
- // inherit Item styles
23
- color: 'inherit',
24
- '&:hover': {
25
- color: 'inherit',
26
- textDecoration: 'none'
27
- }
28
- };
29
- return /*#__PURE__*/React.createElement(Item, {
30
- sx: {
31
- paddingY: 0,
32
- paddingX: 0
33
- },
34
- _PrivateItemWrapper: ({
35
- children
36
- }) => /*#__PURE__*/React.createElement(Link, _extends({
37
- as: Component,
38
- sx: merge(styles, sx)
39
- }, props, {
40
- ref: forwardedRef
41
- }), children)
42
- }, props.children);
43
- });