@primer/components 0.0.0-202191914226 → 0.0.0-2021919184749

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 (72) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/dist/browser.esm.js +605 -604
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +179 -178
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Item.js +3 -3
  7. package/lib/Button/Button.js +1 -1
  8. package/lib/Button/ButtonTableList.js +1 -1
  9. package/lib/Pagination/Pagination.js +1 -1
  10. package/lib/TextInputWithTokens.d.ts +4 -0
  11. package/lib/TextInputWithTokens.js +61 -8
  12. package/lib/_TextInputWrapper.js +2 -2
  13. package/lib/index.d.ts +0 -1
  14. package/lib/index.js +0 -8
  15. package/lib-esm/ActionList/Item.js +3 -3
  16. package/lib-esm/Button/Button.js +1 -1
  17. package/lib-esm/Button/ButtonTableList.js +1 -1
  18. package/lib-esm/Pagination/Pagination.js +1 -1
  19. package/lib-esm/TextInputWithTokens.d.ts +4 -0
  20. package/lib-esm/TextInputWithTokens.js +61 -9
  21. package/lib-esm/_TextInputWrapper.js +2 -2
  22. package/lib-esm/index.d.ts +0 -1
  23. package/lib-esm/index.js +0 -1
  24. package/package.json +1 -1
  25. package/lib/ActionList2/Description.d.ts +0 -5
  26. package/lib/ActionList2/Description.js +0 -45
  27. package/lib/ActionList2/Divider.d.ts +0 -8
  28. package/lib/ActionList2/Divider.js +0 -42
  29. package/lib/ActionList2/Group.d.ts +0 -8
  30. package/lib/ActionList2/Group.js +0 -39
  31. package/lib/ActionList2/Header.d.ts +0 -26
  32. package/lib/ActionList2/Header.js +0 -55
  33. package/lib/ActionList2/Item.d.ts +0 -52
  34. package/lib/ActionList2/Item.js +0 -171
  35. package/lib/ActionList2/List.d.ts +0 -18
  36. package/lib/ActionList2/List.js +0 -52
  37. package/lib/ActionList2/Selection.d.ts +0 -5
  38. package/lib/ActionList2/Selection.js +0 -67
  39. package/lib/ActionList2/Visuals.d.ts +0 -12
  40. package/lib/ActionList2/Visuals.js +0 -87
  41. package/lib/ActionList2/hacks.d.ts +0 -30
  42. package/lib/ActionList2/hacks.js +0 -38
  43. package/lib/ActionList2/index.d.ts +0 -26
  44. package/lib/ActionList2/index.js +0 -36
  45. package/lib/utils/create-slots.d.ts +0 -15
  46. package/lib/utils/create-slots.js +0 -101
  47. package/lib/utils/use-force-update.d.ts +0 -1
  48. package/lib/utils/use-force-update.js +0 -19
  49. package/lib-esm/ActionList2/Description.d.ts +0 -5
  50. package/lib-esm/ActionList2/Description.js +0 -30
  51. package/lib-esm/ActionList2/Divider.d.ts +0 -8
  52. package/lib-esm/ActionList2/Divider.js +0 -30
  53. package/lib-esm/ActionList2/Group.d.ts +0 -8
  54. package/lib-esm/ActionList2/Group.js +0 -29
  55. package/lib-esm/ActionList2/Header.d.ts +0 -26
  56. package/lib-esm/ActionList2/Header.js +0 -45
  57. package/lib-esm/ActionList2/Item.d.ts +0 -52
  58. package/lib-esm/ActionList2/Item.js +0 -172
  59. package/lib-esm/ActionList2/List.d.ts +0 -18
  60. package/lib-esm/ActionList2/List.js +0 -42
  61. package/lib-esm/ActionList2/Selection.d.ts +0 -5
  62. package/lib-esm/ActionList2/Selection.js +0 -50
  63. package/lib-esm/ActionList2/Visuals.d.ts +0 -12
  64. package/lib-esm/ActionList2/Visuals.js +0 -66
  65. package/lib-esm/ActionList2/hacks.d.ts +0 -30
  66. package/lib-esm/ActionList2/hacks.js +0 -30
  67. package/lib-esm/ActionList2/index.d.ts +0 -26
  68. package/lib-esm/ActionList2/index.js +0 -23
  69. package/lib-esm/utils/create-slots.d.ts +0 -15
  70. package/lib-esm/utils/create-slots.js +0 -80
  71. package/lib-esm/utils/use-force-update.d.ts +0 -1
  72. package/lib-esm/utils/use-force-update.js +0 -6
@@ -1,26 +0,0 @@
1
- /// <reference types="react" />
2
- import { Group } from './Group';
3
- import { Divider } from './Divider';
4
- export type { ListProps as ActionListProps } from './List';
5
- export type { GroupProps } from './Group';
6
- export type { ItemProps } from './Item';
7
- export type { DescriptionProps } from './Description';
8
- export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
9
- /**
10
- * Collection of list-related components.
11
- */
12
- export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
13
- /** Collects related `Items` in an `ActionList`. */
14
- Group: typeof Group;
15
- /** An actionable or selectable `Item` with an optional icon and description. */
16
- Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
17
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
18
- Divider: typeof Divider;
19
- Description: import("react").FC<import("./Description").DescriptionProps>;
20
- LeadingVisual: import("react").FC<Pick<import("./Item").ItemProps, "sx" | "disabled" | "variant"> & {
21
- children: import("react").ReactNode;
22
- }>;
23
- TrailingVisual: import("react").FC<Pick<import("./Item").ItemProps, "sx" | "disabled" | "variant"> & {
24
- children: import("react").ReactNode;
25
- }>;
26
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ActionList = void 0;
7
-
8
- var _List = require("./List");
9
-
10
- var _Group = require("./Group");
11
-
12
- var _Item = require("./Item");
13
-
14
- var _Divider = require("./Divider");
15
-
16
- var _Description = require("./Description");
17
-
18
- var _Visuals = require("./Visuals");
19
-
20
- /**
21
- * Collection of list-related components.
22
- */
23
- const ActionList = Object.assign(_List.List, {
24
- /** Collects related `Items` in an `ActionList`. */
25
- Group: _Group.Group,
26
-
27
- /** An actionable or selectable `Item` with an optional icon and description. */
28
- Item: _Item.Item,
29
-
30
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
31
- Divider: _Divider.Divider,
32
- Description: _Description.Description,
33
- LeadingVisual: _Visuals.LeadingVisual,
34
- TrailingVisual: _Visuals.TrailingVisual
35
- });
36
- exports.ActionList = ActionList;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- /** createSlots is a factory that can create a
3
- * typed Slots + Slot combination to use in a component definition
4
- * For example: ActionList uses createSlots to get a Slots wrapper
5
- * Slot component that can be used inside each Item
6
- */
7
- declare const createSlots: <SlotNames extends string>(slotNames: SlotNames[]) => {
8
- Slots: React.FC<{
9
- children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
10
- }>;
11
- Slot: React.FC<{
12
- name: SlotNames;
13
- }>;
14
- };
15
- export default createSlots;
@@ -1,101 +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
- * typed Slots + Slot combination to use in a component definition
16
- * For example: ActionList uses createSlots to get a Slots wrapper
17
- * Slot component that can be used inside each Item
18
- */
19
- const createSlots = slotNames => {
20
- const SlotsContext = /*#__PURE__*/_react.default.createContext({
21
- registerSlot: () => null,
22
- unregisterSlot: () => null
23
- });
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
- const Slots = ({
31
- children
32
- }) => {
33
- // initialise slots
34
- const slotsDefinition = {};
35
- slotNames.map(name => slotsDefinition[name] = null);
36
-
37
- const slotsRef = _react.default.useRef(slotsDefinition);
38
-
39
- const rerenderWithSlots = (0, _useForceUpdate.useForceUpdate)();
40
-
41
- const [isMounted, setIsMounted] = _react.default.useState(false); // fires after all the effects in children
42
-
43
-
44
- _react.default.useEffect(() => {
45
- rerenderWithSlots();
46
- setIsMounted(true);
47
- }, [rerenderWithSlots]);
48
-
49
- const slots = slotsRef.current;
50
-
51
- const registerSlot = _react.default.useCallback((name, contents) => {
52
- slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
53
-
54
- if (isMounted) rerenderWithSlots();
55
- }, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
56
- // we need to unregister them from the slot
57
-
58
-
59
- const unregisterSlot = _react.default.useCallback(name => {
60
- slotsRef.current[name] = null;
61
- rerenderWithSlots();
62
- }, [rerenderWithSlots]);
63
- /**
64
- * Slots uses a render prop API so abstract the
65
- * implementation detail of using a context provider.
66
- */
67
-
68
-
69
- return /*#__PURE__*/_react.default.createElement(SlotsContext.Provider, {
70
- value: {
71
- registerSlot,
72
- unregisterSlot
73
- }
74
- }, children(slots));
75
- };
76
-
77
- const Slot = ({
78
- name,
79
- children
80
- }) => {
81
- const {
82
- registerSlot,
83
- unregisterSlot
84
- } = _react.default.useContext(SlotsContext);
85
-
86
- _react.default.useEffect(() => {
87
- registerSlot(name, children);
88
- return () => unregisterSlot(name);
89
- }, [name, children, registerSlot, unregisterSlot]);
90
-
91
- return null;
92
- };
93
-
94
- return {
95
- Slots,
96
- Slot
97
- };
98
- };
99
-
100
- var _default = createSlots;
101
- 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,5 +0,0 @@
1
- import React from 'react';
2
- export declare type DescriptionProps = {
3
- variant?: 'inline' | 'block';
4
- };
5
- export declare const Description: React.FC<DescriptionProps>;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import Box from '../Box';
3
- import Truncate from '../Truncate';
4
- import { Slot } from './Item';
5
- export const Description = ({
6
- variant = 'inline',
7
- ...props
8
- }) => {
9
- const styles = {
10
- color: 'fg.muted',
11
- fontSize: 0,
12
- lineHeight: '16px',
13
- flexGrow: 1,
14
- flexBasis: 0,
15
- minWidth: 0,
16
- marginLeft: variant === 'block' ? 0 : 2
17
- };
18
- return /*#__PURE__*/React.createElement(Slot, {
19
- name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
20
- }, variant === 'block' ? /*#__PURE__*/React.createElement(Box, {
21
- as: "span",
22
- sx: styles
23
- }, props.children) : /*#__PURE__*/React.createElement(Truncate, {
24
- sx: styles,
25
- title: props.children,
26
- inline: true,
27
- maxWidth: "100%"
28
- }, props.children));
29
- };
30
- Description.displayName = "Description";
@@ -1,8 +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;
6
- export declare namespace Divider {
7
- var renderItem: typeof Divider;
8
- }
@@ -1,30 +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: "hr",
11
- sx: {
12
- border: 'none',
13
- // override browser styles
14
- height: 1,
15
- backgroundColor: 'border.muted',
16
- marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
17
- marginBottom: 2
18
- },
19
- "data-component": "ActionList.Divider"
20
- });
21
- }
22
- Divider.displayName = "Divider";
23
-
24
- /**
25
- * `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
26
- * so it can be used inline in an `ActionList`’s `items` prop.
27
- * In other words, `items={[ActionList.Divider]}` is supported as a concise
28
- * alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
29
- */
30
- Divider.renderItem = Divider;
@@ -1,8 +0,0 @@
1
- /**
2
- * show item dividers
3
- */
4
- /// <reference types="react" />
5
- import { SxProp } from '../sx';
6
- import { HeaderProps } from './Header';
7
- export declare type GroupProps = HeaderProps & SxProp;
8
- export declare function Group({ title, variant, auxiliaryText, sx, ...props }: GroupProps): JSX.Element;
@@ -1,29 +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
- /**
4
- * show item dividers
5
- */
6
- import React from 'react';
7
- import Box from '../Box';
8
- import { Header } from './Header';
9
- export function Group({
10
- title,
11
- variant,
12
- auxiliaryText,
13
- sx = {},
14
- ...props
15
- }) {
16
- return /*#__PURE__*/React.createElement(Box, _extends({
17
- sx: {
18
- '&:not(:first-child)': {
19
- marginTop: 2
20
- },
21
- ...sx
22
- }
23
- }, props), title && /*#__PURE__*/React.createElement(Header, {
24
- title: title,
25
- variant: variant,
26
- auxiliaryText: auxiliaryText
27
- }), props.children);
28
- }
29
- Group.displayName = "Group";
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { SxProp } from '../sx';
3
- /**
4
- * Contract for props passed to the `Header` component.
5
- */
6
- export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
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
- }
23
- /**
24
- * Displays the name and description of a `Group`.
25
- */
26
- export declare function Header({ variant, title, auxiliaryText, children: _children, sx, ...props }: HeaderProps): JSX.Element;
@@ -1,45 +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 function Header({
14
- variant = 'subtle',
15
- title,
16
- auxiliaryText,
17
- children: _children,
18
- sx = {},
19
- ...props
20
- }) {
21
- const {
22
- variant: listVariant
23
- } = React.useContext(ListContext);
24
- const styles = {
25
- paddingY: '6px',
26
- paddingX: listVariant === 'full' ? 2 : 3,
27
- fontSize: 0,
28
- fontWeight: 'bold',
29
- color: 'fg.muted',
30
- ...(variant === 'filled' && {
31
- backgroundColor: 'canvas.subtle',
32
- marginX: 0,
33
- marginBottom: 2,
34
- borderTop: '1px solid',
35
- borderBottom: '1px solid',
36
- borderColor: 'neutral.muted'
37
- }),
38
- ...sx
39
- };
40
- return /*#__PURE__*/React.createElement(Box, _extends({
41
- sx: styles,
42
- role: "heading"
43
- }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, "auxiliaryText"));
44
- }
45
- Header.displayName = "Header";
@@ -1,52 +0,0 @@
1
- /**
2
- * test suite!
3
- * id, role
4
- * text could be non-text
5
- * activeDescendantAttribute
6
- * deepmerge sx
7
- * nicer name for showDivider?
8
- * aria-label
9
- * aria-describedby
10
- * React.FC<Props> doesn't allow id?
11
- * truncate description
12
- * icon color
13
- * disabled checkbox
14
- * check height with divider
15
- *
16
- * use immediate child slot API instead of double render?
17
- * change as= li | div based on context of menu or not?
18
- * check if everyone accepts sx prop
19
- * link example outside of overlay? (details)
20
- * if one item has selected, should we give all of them selected without the need to pass prop?
21
- * move custom item themes to primitives?
22
- * padding: 8 or 6?
23
- * ActionList.Selection or ActionList.Item selected?
24
- * different size for icon and avatar, range?
25
- * minimize number of divs?
26
- * can use layoutEffect on server?
27
- */
28
- import React from 'react';
29
- import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
30
- import { SxProp } from '../sx';
31
- export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
32
- color: (props: any) => any;
33
- iconColor: (props: any) => any;
34
- annotationColor: (props: any) => any;
35
- } | {
36
- color: string;
37
- iconColor: string;
38
- annotationColor: string;
39
- };
40
- declare const Slot: React.FC<{
41
- name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
42
- }>;
43
- export { Slot };
44
- export declare type ItemProps = {
45
- children: React.ReactNode;
46
- onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
47
- selected?: boolean;
48
- variant?: 'default' | 'danger';
49
- disabled?: boolean;
50
- showDivider?: boolean;
51
- } & SxProp;
52
- export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
@@ -1,172 +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
- /**
4
- * test suite!
5
- * id, role
6
- * text could be non-text
7
- * activeDescendantAttribute
8
- * deepmerge sx
9
- * nicer name for showDivider?
10
- * aria-label
11
- * aria-describedby
12
- * React.FC<Props> doesn't allow id?
13
- * truncate description
14
- * icon color
15
- * disabled checkbox
16
- * check height with divider
17
- *
18
- * use immediate child slot API instead of double render?
19
- * change as= li | div based on context of menu or not?
20
- * check if everyone accepts sx prop
21
- * link example outside of overlay? (details)
22
- * if one item has selected, should we give all of them selected without the need to pass prop?
23
- * move custom item themes to primitives?
24
- * padding: 8 or 6?
25
- * ActionList.Selection or ActionList.Item selected?
26
- * different size for icon and avatar, range?
27
- * minimize number of divs?
28
- * can use layoutEffect on server?
29
- */
30
- import React from 'react';
31
- import { useColorSchemeVar, useTheme } from '../ThemeProvider';
32
- import Box from '../Box';
33
- import { get } from '../constants';
34
- import createSlots from '../utils/create-slots';
35
- import { ListContext } from './List';
36
- import { customItemThemes } from './hacks';
37
- import { Selection } from './Selection';
38
- export const getVariantStyles = (variant, disabled) => {
39
- if (disabled) {
40
- return {
41
- color: get('colors.fg.muted'),
42
- iconColor: get('colors.fg.muted'),
43
- annotationColor: get('colors.fg.muted')
44
- };
45
- }
46
-
47
- switch (variant) {
48
- case 'danger':
49
- return {
50
- color: 'danger.fg',
51
- iconColor: 'danger.fg',
52
- annotationColor: 'fg.muted'
53
- };
54
-
55
- default:
56
- return {
57
- color: 'fg.default',
58
- iconColor: 'fg.muted',
59
- annotationColor: 'fg.muted'
60
- };
61
- }
62
- };
63
- const {
64
- Slots,
65
- Slot
66
- } = createSlots(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
67
- export { Slot };
68
- export const Item = /*#__PURE__*/React.forwardRef(({
69
- variant = 'default',
70
- disabled = false,
71
- selected = undefined,
72
- showDivider = false,
73
- onAction = () => null,
74
- sx = {},
75
- ...props
76
- }, forwardedRef) => {
77
- const customItemTheme = customItemThemes[variant];
78
- const {
79
- variant: listVariant
80
- } = React.useContext(ListContext);
81
- const {
82
- theme
83
- } = useTheme();
84
- const styles = {
85
- display: 'flex',
86
- paddingX: get('space.2'),
87
- paddingY: '6px',
88
- marginX: listVariant === 'inset' ? get('space.2') : 0,
89
- minHeight: get('space.5'),
90
- borderRadius: get('radii.2'),
91
- transition: 'background 33.333ms linear',
92
- color: getVariantStyles(variant, disabled).color,
93
- textDecoration: 'none',
94
- // for as="a"
95
- ':not(disabled)': {
96
- cursor: 'pointer'
97
- },
98
- '@media (hover: hover) and (pointer: fine)': {
99
- ':hover': {
100
- backgroundColor: useColorSchemeVar(customItemTheme.hover, 'inherit')
101
- },
102
- ':focus': {
103
- backgroundColor: useColorSchemeVar(customItemTheme.focus, 'inherit')
104
- }
105
- },
106
-
107
- /** Divider styles */
108
- '[data-component="ActionList.Item--Main"]': {
109
- position: 'relative'
110
- },
111
- '[data-component="ActionList.Item--Main"]::before': {
112
- content: '" "',
113
- display: 'block',
114
- position: 'absolute',
115
- width: '100%',
116
- top: '-7px',
117
- border: '0 solid',
118
- borderTopWidth: showDivider ? `1px` : '0',
119
- borderColor: 'var(--divider-color, transparent)'
120
- },
121
- // show between 2 items
122
- ':not(:first-of-type)': {
123
- '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
124
- },
125
- // hide divider after dividers & group header
126
- '[data-component="ActionList.Divider"] + &': {
127
- '--divider-color': 'transparent'
128
- },
129
- // hide border on current and previous item
130
- '&:hover, &:focus': {
131
- '--divider-color': 'transparent'
132
- },
133
- '&:hover + &, &:focus + &': {
134
- '--divider-color': 'transparent'
135
- },
136
- ...sx
137
- };
138
- const clickHandler = React.useCallback(event => {
139
- if (disabled) return;
140
- if (!event.defaultPrevented) onAction(event);
141
- }, [onAction, disabled]);
142
- return /*#__PURE__*/React.createElement(Slots, null, slots => /*#__PURE__*/React.createElement(Box, _extends({
143
- as: "li",
144
- sx: styles,
145
- "data-component": "ActionList.Item",
146
- onClick: clickHandler,
147
- ref: forwardedRef
148
- }, props), /*#__PURE__*/React.createElement(Selection, {
149
- selected: selected,
150
- disabled: disabled
151
- }), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
152
- "data-component": "ActionList.Item--Main",
153
- sx: {
154
- display: 'flex',
155
- flexDirection: 'column',
156
- flexGrow: 1,
157
- minWidth: 0
158
- }
159
- }, /*#__PURE__*/React.createElement(Box, {
160
- sx: {
161
- display: 'flex'
162
- }
163
- }, /*#__PURE__*/React.createElement(Box, {
164
- sx: {
165
- display: 'flex',
166
- flexGrow: 1,
167
- alignItems: 'baseline',
168
- minWidth: 0
169
- }
170
- }, /*#__PURE__*/React.createElement("span", null, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
171
- });
172
- Item.displayName = 'ActionList.Item';
@@ -1,18 +0,0 @@
1
- /**
2
- *
3
- * showItemDividers
4
- * deepmerge sx
5
- * change as= ul | div based on context of menu or not?
6
- * should selectionVariant be single by default or nothing. ask for explicit choice?
7
- */
8
- import React from 'react';
9
- import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
10
- import { SxProp } from '../sx';
11
- export declare type ListProps = {
12
- variant?: 'inset' | 'full';
13
- selectionVariant?: 'single' | 'multiple';
14
- } & SxProp;
15
- declare type ContextProps = Pick<ListProps, 'selectionVariant' | 'variant'>;
16
- export declare const ListContext: React.Context<ContextProps>;
17
- export declare const List: PolymorphicForwardRefComponent<"ul", ListProps>;
18
- export {};
@@ -1,42 +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
- /**
4
- *
5
- * showItemDividers
6
- * deepmerge sx
7
- * change as= ul | div based on context of menu or not?
8
- * should selectionVariant be single by default or nothing. ask for explicit choice?
9
- */
10
- import React from 'react';
11
- import Box from '../Box';
12
- import { get } from '../constants';
13
- export const ListContext = /*#__PURE__*/React.createContext({});
14
- export const List = /*#__PURE__*/React.forwardRef(({
15
- variant = 'inset',
16
- selectionVariant = 'single',
17
- sx = {},
18
- ...props
19
- }, forwardedRef) => {
20
- const styles = {
21
- margin: 0,
22
- fontSize: get('fontSizes.1'),
23
- lineHeight: '20px',
24
- // TODO: check if we replace this already
25
- paddingInlineStart: 0,
26
- // reset ul styles
27
- paddingY: variant === 'inset' ? get('space.2') : 0,
28
- ...sx
29
- };
30
- return /*#__PURE__*/React.createElement(Box, _extends({
31
- as: "ul",
32
- sx: styles
33
- }, props, {
34
- ref: forwardedRef
35
- }), /*#__PURE__*/React.createElement(ListContext.Provider, {
36
- value: {
37
- variant,
38
- selectionVariant
39
- }
40
- }, props.children));
41
- });
42
- List.displayName = 'ActionList';