@primer/components 0.0.0-202192602912 → 0.0.0-2021926114132

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 (112) hide show
  1. package/CHANGELOG.md +4 -8
  2. package/dist/browser.esm.js +616 -616
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +177 -177
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Description.d.ts +6 -0
  7. package/lib/ActionList2/Description.js +53 -0
  8. package/lib/ActionList2/Divider.d.ts +8 -0
  9. package/lib/ActionList2/Divider.js +42 -0
  10. package/lib/ActionList2/Group.d.ts +8 -0
  11. package/lib/ActionList2/Group.js +39 -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 +49 -0
  15. package/lib/ActionList2/Item.js +205 -0
  16. package/lib/ActionList2/List.d.ts +11 -0
  17. package/lib/ActionList2/List.js +53 -0
  18. package/lib/ActionList2/Selection.d.ts +5 -0
  19. package/lib/ActionList2/Selection.js +67 -0
  20. package/lib/ActionList2/Visuals.d.ts +11 -0
  21. package/lib/ActionList2/Visuals.js +90 -0
  22. package/lib/ActionList2/hacks.d.ts +30 -0
  23. package/lib/ActionList2/hacks.js +38 -0
  24. package/lib/ActionList2/index.d.ts +26 -0
  25. package/lib/ActionList2/index.js +36 -0
  26. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  27. package/lib/Autocomplete/Autocomplete.d.ts +2 -4
  28. package/lib/Autocomplete/AutocompleteInput.d.ts +2 -4
  29. package/lib/SelectMenu/SelectMenu.d.ts +2 -4
  30. package/lib/TextInputWithTokens.d.ts +2 -4
  31. package/lib/index.d.ts +1 -0
  32. package/lib/index.js +8 -0
  33. package/lib/sx.d.ts +2 -0
  34. package/lib/sx.js +8 -0
  35. package/lib/theme-preval.js +2 -2
  36. package/lib/utils/create-slots.d.ts +17 -0
  37. package/lib/utils/create-slots.js +105 -0
  38. package/lib/utils/testing.d.ts +1 -1
  39. package/lib/utils/use-force-update.d.ts +1 -0
  40. package/lib/utils/use-force-update.js +19 -0
  41. package/lib-esm/ActionList2/Description.d.ts +6 -0
  42. package/lib-esm/ActionList2/Description.js +37 -0
  43. package/lib-esm/ActionList2/Divider.d.ts +8 -0
  44. package/lib-esm/ActionList2/Divider.js +30 -0
  45. package/lib-esm/ActionList2/Group.d.ts +8 -0
  46. package/lib-esm/ActionList2/Group.js +29 -0
  47. package/lib-esm/ActionList2/Header.d.ts +26 -0
  48. package/lib-esm/ActionList2/Header.js +45 -0
  49. package/lib-esm/ActionList2/Item.d.ts +49 -0
  50. package/lib-esm/ActionList2/Item.js +198 -0
  51. package/lib-esm/ActionList2/List.d.ts +11 -0
  52. package/lib-esm/ActionList2/List.js +35 -0
  53. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  54. package/lib-esm/ActionList2/Selection.js +50 -0
  55. package/lib-esm/ActionList2/Visuals.d.ts +11 -0
  56. package/lib-esm/ActionList2/Visuals.js +68 -0
  57. package/lib-esm/ActionList2/hacks.d.ts +30 -0
  58. package/lib-esm/ActionList2/hacks.js +30 -0
  59. package/lib-esm/ActionList2/index.d.ts +26 -0
  60. package/lib-esm/ActionList2/index.js +23 -0
  61. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  62. package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -4
  63. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -4
  64. package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -4
  65. package/lib-esm/TextInputWithTokens.d.ts +2 -4
  66. package/lib-esm/index.d.ts +1 -0
  67. package/lib-esm/index.js +1 -0
  68. package/lib-esm/sx.d.ts +2 -0
  69. package/lib-esm/sx.js +3 -1
  70. package/lib-esm/theme-preval.js +2 -2
  71. package/lib-esm/utils/create-slots.d.ts +17 -0
  72. package/lib-esm/utils/create-slots.js +84 -0
  73. package/lib-esm/utils/testing.d.ts +1 -1
  74. package/lib-esm/utils/use-force-update.d.ts +1 -0
  75. package/lib-esm/utils/use-force-update.js +6 -0
  76. package/package.json +8 -9
  77. package/lib/DatePicker/DatePicker.d.ts +0 -48
  78. package/lib/DatePicker/DatePicker.js +0 -92
  79. package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
  80. package/lib/DatePicker/DatePickerAnchor.js +0 -158
  81. package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
  82. package/lib/DatePicker/DatePickerOverlay.js +0 -39
  83. package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
  84. package/lib/DatePicker/DatePickerPanel.js +0 -126
  85. package/lib/DatePicker/Day.d.ts +0 -14
  86. package/lib/DatePicker/Day.js +0 -174
  87. package/lib/DatePicker/Month.d.ts +0 -9
  88. package/lib/DatePicker/Month.js +0 -107
  89. package/lib/DatePicker/index.d.ts +0 -2
  90. package/lib/DatePicker/index.js +0 -13
  91. package/lib/DatePicker/useDatePicker.d.ts +0 -83
  92. package/lib/DatePicker/useDatePicker.js +0 -375
  93. package/lib/hooks/useDebounce.d.ts +0 -2
  94. package/lib/hooks/useDebounce.js +0 -24
  95. package/lib-esm/DatePicker/DatePicker.d.ts +0 -48
  96. package/lib-esm/DatePicker/DatePicker.js +0 -75
  97. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
  98. package/lib-esm/DatePicker/DatePickerAnchor.js +0 -132
  99. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
  100. package/lib-esm/DatePicker/DatePickerOverlay.js +0 -24
  101. package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
  102. package/lib-esm/DatePicker/DatePickerPanel.js +0 -100
  103. package/lib-esm/DatePicker/Day.d.ts +0 -14
  104. package/lib-esm/DatePicker/Day.js +0 -151
  105. package/lib-esm/DatePicker/Month.d.ts +0 -9
  106. package/lib-esm/DatePicker/Month.js +0 -83
  107. package/lib-esm/DatePicker/index.d.ts +0 -2
  108. package/lib-esm/DatePicker/index.js +0 -1
  109. package/lib-esm/DatePicker/useDatePicker.d.ts +0 -83
  110. package/lib-esm/DatePicker/useDatePicker.js +0 -347
  111. package/lib-esm/hooks/useDebounce.d.ts +0 -2
  112. package/lib-esm/hooks/useDebounce.js +0 -16
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ export declare type DescriptionProps = {
4
+ variant?: 'inline' | 'block';
5
+ } & SxProp;
6
+ 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,8 @@
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
+ }
@@ -0,0 +1,42 @@
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: "hr",
22
+ sx: {
23
+ border: 'none',
24
+ // override browser styles
25
+ height: 1,
26
+ backgroundColor: 'border.muted',
27
+ marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
28
+ marginBottom: 2
29
+ },
30
+ "data-component": "ActionList.Divider"
31
+ });
32
+ }
33
+
34
+ Divider.displayName = "Divider";
35
+
36
+ /**
37
+ * `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
38
+ * so it can be used inline in an `ActionList`’s `items` prop.
39
+ * In other words, `items={[ActionList.Divider]}` is supported as a concise
40
+ * alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
41
+ */
42
+ Divider.renderItem = Divider;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Group = Group;
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
+ function Group({
19
+ title,
20
+ variant,
21
+ auxiliaryText,
22
+ sx = {},
23
+ ...props
24
+ }) {
25
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
26
+ sx: {
27
+ '&:not(:first-child)': {
28
+ marginTop: 2
29
+ },
30
+ ...sx
31
+ }
32
+ }, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
33
+ title: title,
34
+ variant: variant,
35
+ auxiliaryText: auxiliaryText
36
+ }), props.children);
37
+ }
38
+
39
+ Group.displayName = "Group";
@@ -0,0 +1,26 @@
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;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Header = Header;
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
+ function Header({
22
+ variant = 'subtle',
23
+ title,
24
+ auxiliaryText,
25
+ children: _children,
26
+ sx = {},
27
+ ...props
28
+ }) {
29
+ const {
30
+ variant: listVariant
31
+ } = _react.default.useContext(_List.ListContext);
32
+
33
+ const styles = {
34
+ paddingY: '6px',
35
+ paddingX: listVariant === 'full' ? 2 : 3,
36
+ fontSize: 0,
37
+ fontWeight: 'bold',
38
+ color: 'fg.muted',
39
+ ...(variant === 'filled' && {
40
+ backgroundColor: 'canvas.subtle',
41
+ marginX: 0,
42
+ marginBottom: 2,
43
+ borderTop: '1px solid',
44
+ borderBottom: '1px solid',
45
+ borderColor: 'neutral.muted'
46
+ }),
47
+ ...sx
48
+ };
49
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
50
+ sx: styles,
51
+ role: "heading"
52
+ }, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, "auxiliaryText"));
53
+ }
54
+
55
+ Header.displayName = "Header";
@@ -0,0 +1,49 @@
1
+ /**
2
+ * minimize number of divs
3
+ * docs
4
+ * docs for types
5
+ * test suite!
6
+ * ref unhappy with polymorphic
7
+ *
8
+ * check height with divider
9
+ * questions:
10
+ * nicer name for showDivider?
11
+ * change as= li | div based on context of menu or not?
12
+ * should selectionVariant be single by default or nothing. ask for explicit choice?
13
+ * selection api - if one item has selected, should we give all of them selected without the need to pass prop?
14
+ * move custom item themes to primitives?
15
+ * padding: 8 or 6?
16
+ * different size for icon and avatar, range?
17
+ * ActionList.Selection or ActionList.Item selected?
18
+ * aria-describedby empty value bad? also, 2 description = 2 values?
19
+ *
20
+ * activeDescendantAttribute (for actionMenu)
21
+ */
22
+ import React from 'react';
23
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
24
+ import { SxProp } from '../sx';
25
+ import { AriaRole } from '../utils/types';
26
+ export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
27
+ color: string;
28
+ iconColor: string;
29
+ annotationColor: string;
30
+ };
31
+ export declare type ItemProps = {
32
+ children: React.ReactNode;
33
+ onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
34
+ selected?: boolean;
35
+ variant?: 'default' | 'danger';
36
+ disabled?: boolean;
37
+ showDivider?: boolean;
38
+ role?: AriaRole;
39
+ } & SxProp;
40
+ declare const Slot: React.FC<{
41
+ name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
42
+ children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
43
+ }>;
44
+ export { Slot };
45
+ export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
46
+ inlineDescriptionId: string;
47
+ blockDescriptionId: string;
48
+ };
49
+ export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Item = 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 _constants = require("../constants");
17
+
18
+ var _sx = require("../sx");
19
+
20
+ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
21
+
22
+ var _List = require("./List");
23
+
24
+ var _hacks = require("./hacks");
25
+
26
+ var _Selection = require("./Selection");
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ 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); }
31
+
32
+ const getVariantStyles = (variant, disabled) => {
33
+ if (disabled) {
34
+ return {
35
+ color: 'fg.muted',
36
+ iconColor: 'fg.muted',
37
+ annotationColor: 'fg.muted'
38
+ };
39
+ }
40
+
41
+ switch (variant) {
42
+ case 'danger':
43
+ return {
44
+ color: 'danger.fg',
45
+ iconColor: 'danger.fg',
46
+ annotationColor: 'fg.muted'
47
+ };
48
+
49
+ default:
50
+ return {
51
+ color: 'fg.default',
52
+ iconColor: 'fg.muted',
53
+ annotationColor: 'fg.muted'
54
+ };
55
+ }
56
+ };
57
+
58
+ exports.getVariantStyles = getVariantStyles;
59
+ const {
60
+ Slots,
61
+ Slot
62
+ } = (0, _createSlots.default)(['LeadingVisual', 'InlineDescription', 'BlockDescription', 'TrailingVisual']);
63
+ exports.Slot = Slot;
64
+
65
+ const Item = /*#__PURE__*/_react.default.forwardRef(({
66
+ variant = 'default',
67
+ disabled = false,
68
+ selected = undefined,
69
+ showDivider = false,
70
+ onAction = () => null,
71
+ sx = {},
72
+ ...props
73
+ }, forwardedRef) => {
74
+ const customItemTheme = _hacks.customItemThemes[variant];
75
+
76
+ const {
77
+ variant: listVariant
78
+ } = _react.default.useContext(_List.ListContext);
79
+
80
+ const {
81
+ theme
82
+ } = (0, _ThemeProvider.useTheme)();
83
+ const styles = {
84
+ display: 'flex',
85
+ paddingX: (0, _constants.get)('space.2'),
86
+ paddingY: '6px',
87
+ marginX: listVariant === 'inset' ? (0, _constants.get)('space.2') : 0,
88
+ minHeight: (0, _constants.get)('space.5'),
89
+ borderRadius: (0, _constants.get)('radii.2'),
90
+ transition: 'background 33.333ms linear',
91
+ color: getVariantStyles(variant, disabled).color,
92
+ textDecoration: 'none',
93
+ // for as="a"
94
+ ':not([aria-disabled])': {
95
+ cursor: 'pointer'
96
+ },
97
+ '@media (hover: hover) and (pointer: fine)': {
98
+ ':hover:not([aria-disabled])': {
99
+ backgroundColor: (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.hover, 'inherit')
100
+ },
101
+ ':focus:not([aria-disabled])': {
102
+ backgroundColor: (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.focus, 'inherit')
103
+ }
104
+ },
105
+
106
+ /** Divider styles */
107
+ '[data-component="ActionList.Item--DividerContainer"]': {
108
+ position: 'relative'
109
+ },
110
+ '[data-component="ActionList.Item--DividerContainer"]::before': {
111
+ content: '" "',
112
+ display: 'block',
113
+ position: 'absolute',
114
+ width: '100%',
115
+ top: '-7px',
116
+ border: '0 solid',
117
+ borderTopWidth: showDivider ? `1px` : '0',
118
+ borderColor: 'var(--divider-color, transparent)'
119
+ },
120
+ // show between 2 items
121
+ ':not(:first-of-type)': {
122
+ '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.border.muted
123
+ },
124
+ // hide divider after dividers & group header
125
+ '[data-component="ActionList.Divider"] + &': {
126
+ '--divider-color': 'transparent'
127
+ },
128
+ // hide border on current and previous item
129
+ '&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
130
+ '--divider-color': 'transparent'
131
+ },
132
+ '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
133
+ '--divider-color': 'transparent'
134
+ }
135
+ };
136
+
137
+ const clickHandler = _react.default.useCallback(event => {
138
+ if (disabled) return;
139
+ if (!event.defaultPrevented) onAction(event);
140
+ }, [onAction, disabled]);
141
+
142
+ const labelId = (0, _ssr.useSSRSafeId)();
143
+ const inlineDescriptionId = (0, _ssr.useSSRSafeId)();
144
+ const blockDescriptionId = (0, _ssr.useSSRSafeId)();
145
+ return /*#__PURE__*/_react.default.createElement(Slots, {
146
+ context: {
147
+ variant,
148
+ disabled,
149
+ inlineDescriptionId,
150
+ blockDescriptionId
151
+ }
152
+ }, slots => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
153
+ as: "li",
154
+ ref: forwardedRef,
155
+ sx: (0, _sx.merge)(styles, sx),
156
+ "data-component": "ActionList.Item",
157
+ onClick: clickHandler,
158
+ "aria-selected": selected,
159
+ "aria-disabled": disabled ? true : undefined,
160
+ "aria-labelledby": labelId,
161
+ "aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
162
+ }, props), /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
163
+ selected: selected,
164
+ disabled: disabled
165
+ }), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
166
+ "data-component": "ActionList.Item--DividerContainer",
167
+ sx: {
168
+ display: 'flex',
169
+ flexDirection: 'column',
170
+ flexGrow: 1,
171
+ minWidth: 0
172
+ }
173
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
174
+ if: Boolean(slots.TrailingVisual),
175
+ sx: {
176
+ display: 'flex',
177
+ flexGrow: 1
178
+ }
179
+ }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
180
+ if: Boolean(slots.InlineDescription),
181
+ sx: {
182
+ display: 'flex',
183
+ flexGrow: 1,
184
+ alignItems: 'baseline',
185
+ minWidth: 0
186
+ }
187
+ }, /*#__PURE__*/_react.default.createElement(_Box.default, {
188
+ as: "span",
189
+ id: labelId,
190
+ sx: {
191
+ flexGrow: slots.InlineDescription ? 0 : 1
192
+ }
193
+ }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription)));
194
+ });
195
+
196
+ exports.Item = Item;
197
+ Item.displayName = 'ActionList.Item';
198
+
199
+ const ConditionalBox = props => {
200
+ const {
201
+ if: condition,
202
+ ...rest
203
+ } = props;
204
+ if (condition) return /*#__PURE__*/_react.default.createElement(_Box.default, rest, props.children);else return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
205
+ };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ import { SxProp } from '../sx';
4
+ export declare type ListProps = {
5
+ variant?: 'inset' | 'full';
6
+ selectionVariant?: 'single' | 'multiple';
7
+ } & SxProp;
8
+ declare type ContextProps = Pick<ListProps, 'selectionVariant' | 'variant'>;
9
+ export declare const ListContext: React.Context<ContextProps>;
10
+ export declare const List: PolymorphicForwardRefComponent<"ul", ListProps>;
11
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.List = exports.ListContext = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _constants = require("../constants");
13
+
14
+ var _sx = require("../sx");
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 ListContext = /*#__PURE__*/_react.default.createContext({});
21
+
22
+ exports.ListContext = ListContext;
23
+
24
+ const List = /*#__PURE__*/_react.default.forwardRef(({
25
+ variant = 'inset',
26
+ selectionVariant = 'single',
27
+ sx = {},
28
+ ...props
29
+ }, forwardedRef) => {
30
+ const styles = {
31
+ margin: 0,
32
+ fontSize: (0, _constants.get)('fontSizes.1'),
33
+ lineHeight: '20px',
34
+ // TODO: check if we replace this already
35
+ paddingInlineStart: 0,
36
+ // reset ul styles
37
+ paddingY: variant === 'inset' ? (0, _constants.get)('space.2') : 0
38
+ };
39
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
40
+ as: "ul",
41
+ sx: (0, _sx.merge)(styles, sx)
42
+ }, props, {
43
+ ref: forwardedRef
44
+ }), /*#__PURE__*/_react.default.createElement(ListContext.Provider, {
45
+ value: {
46
+ variant,
47
+ selectionVariant
48
+ }
49
+ }, props.children));
50
+ });
51
+
52
+ exports.List = List;
53
+ List.displayName = 'ActionList';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ItemProps } from './Item';
3
+ declare type SelectionProps = Pick<ItemProps, 'selected' | 'disabled'>;
4
+ export declare const Selection: React.FC<SelectionProps>;
5
+ export {};
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Selection = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _octiconsReact = require("@primer/octicons-react");
11
+
12
+ var _ThemeProvider = require("../ThemeProvider");
13
+
14
+ var _List = require("./List");
15
+
16
+ var _Visuals = require("./Visuals");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const Selection = ({
21
+ selected,
22
+ disabled
23
+ }) => {
24
+ const {
25
+ selectionVariant
26
+ } = _react.default.useContext(_List.ListContext);
27
+
28
+ const {
29
+ theme
30
+ } = (0, _ThemeProvider.useTheme)();
31
+ if (typeof selected === 'undefined') return null;
32
+
33
+ if (selectionVariant === 'single') {
34
+ return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, {
35
+ fill: theme === null || theme === void 0 ? void 0 : theme.colors.text.primary
36
+ }));
37
+ }
38
+
39
+ if (selectionVariant === 'multiple') {
40
+ /**
41
+ * readOnly is required because we are doing a one-way bind to `checked`
42
+ * aria-readonly="false" tells screen that they can still interact with the checkbox
43
+ * TODO: not sure if disabled & aria-label be here or should we apply it on the instance as props
44
+ * TODO: aria-label should come from the text part of the slot
45
+ */
46
+ return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, {
47
+ sx: {
48
+ input: {
49
+ margin: 0,
50
+ pointerEvents: 'none'
51
+ }
52
+ }
53
+ }, /*#__PURE__*/_react.default.createElement("input", {
54
+ type: "checkbox",
55
+ checked: selected,
56
+ disabled: disabled,
57
+ "aria-label": "TODO",
58
+ tabIndex: -1,
59
+ readOnly: true,
60
+ "aria-readonly": "false"
61
+ }));
62
+ }
63
+
64
+ return null;
65
+ };
66
+
67
+ exports.Selection = Selection;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ declare type VisualProps = SxProp & {
4
+ children: React.ReactNode;
5
+ };
6
+ export declare const LeadingVisualContainer: React.FC<SxProp>;
7
+ export declare type LeadingVisualProps = VisualProps;
8
+ export declare const LeadingVisual: React.FC<VisualProps>;
9
+ export declare type TrailingVisualProps = VisualProps;
10
+ export declare const TrailingVisual: React.FC<VisualProps>;
11
+ export {};