@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,223 +0,0 @@
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
- id,
74
- _PrivateItemWrapper = ({
75
- children
76
- }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children),
77
- ...props
78
- }, forwardedRef) => {
79
- const {
80
- variant: listVariant,
81
- showDividers
82
- } = _react.default.useContext(_List.ListContext);
83
-
84
- const {
85
- theme
86
- } = (0, _ThemeProvider.useTheme)();
87
- const styles = {
88
- display: 'flex',
89
- paddingX: 2,
90
- fontSize: 1,
91
- paddingY: '6px',
92
- // custom value off the scale
93
- lineHeight: TEXT_ROW_HEIGHT,
94
- marginX: listVariant === 'inset' ? 2 : 0,
95
- minHeight: 5,
96
- borderRadius: 2,
97
- transition: 'background 33.333ms linear',
98
- color: getVariantStyles(variant, disabled).color,
99
- textDecoration: 'none',
100
- // for as="a"
101
- '&[aria-selected=true]': {
102
- backgroundColor: getVariantStyles(variant, disabled).selectedBg
103
- },
104
- ':not([aria-disabled])': {
105
- cursor: 'pointer'
106
- },
107
- '@media (hover: hover) and (pointer: fine)': {
108
- ':hover:not([aria-disabled])': {
109
- backgroundColor: `actionListItem.${variant}.hoverBg`,
110
- color: getVariantStyles(variant, disabled).hoverColor
111
- },
112
- ':focus:not([aria-disabled])': {
113
- backgroundColor: `actionListItem.${variant}.activeBg`,
114
- color: getVariantStyles(variant, disabled).hoverColor,
115
- outline: 'none'
116
- }
117
- },
118
-
119
- /** Divider styles */
120
- '[data-component="ActionList.Item--DividerContainer"]': {
121
- position: 'relative'
122
- },
123
- '[data-component="ActionList.Item--DividerContainer"]::before': {
124
- content: '" "',
125
- display: 'block',
126
- position: 'absolute',
127
- width: '100%',
128
- top: '-7px',
129
- border: '0 solid',
130
- borderTopWidth: showDividers ? `1px` : '0',
131
- borderColor: 'var(--divider-color, transparent)'
132
- },
133
- // show between 2 items
134
- ':not(:first-of-type):not([aria-selected=true])': {
135
- '--divider-color': theme === null || theme === void 0 ? void 0 : theme.colors.actionListItem.inlineDivider
136
- },
137
- // hide divider after dividers & group header, with higher importance!
138
- '[data-component="ActionList.Divider"] + &': {
139
- '--divider-color': 'transparent !important'
140
- },
141
- // hide border on current and previous item
142
- '&:hover:not([aria-disabled]), &:focus:not([aria-disabled])': {
143
- '--divider-color': 'transparent'
144
- },
145
- '&:hover:not([aria-disabled]) + &, &:focus:not([aria-disabled]) + &': {
146
- '--divider-color': 'transparent'
147
- },
148
- // hide border around selected item
149
- '&[aria-selected=true] + &': {
150
- '--divider-color': 'transparent'
151
- }
152
- };
153
-
154
- const clickHandler = _react.default.useCallback(event => {
155
- if (disabled) return;
156
- if (!event.defaultPrevented) onSelect(event);
157
- }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
158
-
159
-
160
- const labelId = (0, _ssr.useSSRSafeId)(id);
161
- const inlineDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--inline-description`);
162
- const blockDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--block-description`);
163
- return /*#__PURE__*/_react.default.createElement(Slots, {
164
- context: {
165
- variant,
166
- disabled,
167
- inlineDescriptionId,
168
- blockDescriptionId
169
- }
170
- }, slots => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
171
- as: "li",
172
- ref: forwardedRef,
173
- sx: (0, _sx.merge)(styles, sx),
174
- onClick: clickHandler,
175
- "aria-selected": selected,
176
- "aria-disabled": disabled ? true : undefined,
177
- tabIndex: disabled ? undefined : -1,
178
- "aria-labelledby": labelId,
179
- "aria-describedby": [slots.InlineDescription && inlineDescriptionId, slots.BlockDescription && blockDescriptionId].filter(Boolean).join(' ')
180
- }, props), /*#__PURE__*/_react.default.createElement(_PrivateItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
181
- selected: selected,
182
- disabled: disabled
183
- }), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
184
- "data-component": "ActionList.Item--DividerContainer",
185
- sx: {
186
- display: 'flex',
187
- flexDirection: 'column',
188
- flexGrow: 1,
189
- minWidth: 0
190
- }
191
- }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
192
- if: Boolean(slots.TrailingVisual),
193
- sx: {
194
- display: 'flex',
195
- flexGrow: 1
196
- }
197
- }, /*#__PURE__*/_react.default.createElement(ConditionalBox, {
198
- if: Boolean(slots.InlineDescription),
199
- sx: {
200
- display: 'flex',
201
- flexGrow: 1,
202
- alignItems: 'baseline',
203
- minWidth: 0
204
- }
205
- }, /*#__PURE__*/_react.default.createElement(_Box.default, {
206
- as: "span",
207
- id: labelId,
208
- sx: {
209
- flexGrow: slots.InlineDescription ? 0 : 1
210
- }
211
- }, props.children), slots.InlineDescription), slots.TrailingVisual), slots.BlockDescription))));
212
- });
213
-
214
- exports.Item = Item;
215
- Item.displayName = 'ActionList.Item';
216
-
217
- const ConditionalBox = props => {
218
- const {
219
- if: condition,
220
- ...rest
221
- } = props;
222
- if (condition) return /*#__PURE__*/_react.default.createElement(_Box.default, rest, props.children);else return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
223
- };
@@ -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,57 +0,0 @@
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;
@@ -1,26 +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 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 {};
@@ -1,51 +0,0 @@
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 _sx = require("../sx");
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 ListContext = /*#__PURE__*/_react.default.createContext({});
19
-
20
- exports.ListContext = ListContext;
21
-
22
- const List = /*#__PURE__*/_react.default.forwardRef(({
23
- variant = 'inset',
24
- selectionVariant,
25
- showDividers = false,
26
- sx = {},
27
- ...props
28
- }, forwardedRef) => {
29
- const styles = {
30
- margin: 0,
31
- paddingInlineStart: 0,
32
- // reset ul styles
33
- paddingY: variant === 'inset' ? 2 : 0
34
- };
35
- return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
36
- as: "ul",
37
- sx: (0, _sx.merge)(styles, sx),
38
- "aria-multiselectable": selectionVariant === 'multiple' ? true : undefined
39
- }, props, {
40
- ref: forwardedRef
41
- }), /*#__PURE__*/_react.default.createElement(ListContext.Provider, {
42
- value: {
43
- variant,
44
- selectionVariant,
45
- showDividers
46
- }
47
- }, props.children));
48
- });
49
-
50
- exports.List = List;
51
- List.displayName = 'ActionList';
@@ -1,5 +0,0 @@
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 {};
@@ -1,70 +0,0 @@
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 _List = require("./List");
13
-
14
- var _Group = require("./Group");
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: listSelectionVariant
26
- } = _react.default.useContext(_List.ListContext);
27
-
28
- const {
29
- selectionVariant: groupSelectionVariant
30
- } = _react.default.useContext(_Group.GroupContext);
31
- /** selectionVariant in Group can override the selectionVariant in List root */
32
-
33
-
34
- const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
35
-
36
- if (!selectionVariant) {
37
- // to avoid confusion, fail loudly instead of silently ignoring
38
- if (selected) throw new Error('For Item to be selected, ActionList or ActionList.Group needs to have a selectionVariant defined');
39
- return null;
40
- }
41
-
42
- if (selectionVariant === 'single') {
43
- return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, null));
44
- }
45
- /**
46
- * selectionVariant is multiple
47
- * readOnly is required because we are doing a one-way bind to `checked`
48
- * aria-readonly="false" tells screen that they can still interact with the checkbox
49
- */
50
-
51
-
52
- return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, {
53
- sx: {
54
- input: {
55
- margin: 0,
56
- pointerEvents: 'none'
57
- }
58
- }
59
- }, /*#__PURE__*/_react.default.createElement("input", {
60
- type: "checkbox",
61
- checked: selected,
62
- disabled: disabled,
63
- tabIndex: -1,
64
- readOnly: true,
65
- "aria-readonly": "false"
66
- }));
67
- };
68
-
69
- exports.Selection = Selection;
70
- Selection.displayName = "Selection";
@@ -1,11 +0,0 @@
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 {};
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TrailingVisual = exports.LeadingVisual = exports.LeadingVisualContainer = 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 _constants = require("../constants");
15
-
16
- var _Item = require("./Item");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- 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); }
21
-
22
- const LeadingVisualContainer = ({
23
- sx = {},
24
- ...props
25
- }) => {
26
- return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
27
- as: "span",
28
- sx: (0, _sx.merge)({
29
- height: _Item.TEXT_ROW_HEIGHT,
30
- // match height of text row
31
- minWidth: (0, _constants.get)('space.3'),
32
- maxWidth: _Item.TEXT_ROW_HEIGHT,
33
- // square (same as height)
34
- display: 'flex',
35
- justifyContent: 'center',
36
- alignItems: 'center',
37
- flexShrink: 0,
38
- marginRight: 2
39
- }, sx)
40
- }, props));
41
- };
42
-
43
- exports.LeadingVisualContainer = LeadingVisualContainer;
44
- LeadingVisualContainer.displayName = "LeadingVisualContainer";
45
-
46
- const LeadingVisual = ({
47
- sx = {},
48
- ...props
49
- }) => {
50
- return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
51
- name: "LeadingVisual"
52
- }, ({
53
- variant,
54
- disabled
55
- }) => /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, _extends({
56
- sx: (0, _sx.merge)({
57
- color: (0, _Item.getVariantStyles)(variant, disabled).iconColor,
58
- svg: {
59
- fontSize: 0
60
- }
61
- }, sx)
62
- }, props), props.children));
63
- };
64
-
65
- exports.LeadingVisual = LeadingVisual;
66
- LeadingVisual.displayName = "LeadingVisual";
67
-
68
- const TrailingVisual = ({
69
- sx = {},
70
- ...props
71
- }) => {
72
- return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
73
- name: "TrailingVisual"
74
- }, ({
75
- variant,
76
- disabled
77
- }) => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
78
- as: "span",
79
- sx: (0, _sx.merge)({
80
- height: '20px',
81
- // match height of text row
82
- flexShrink: 0,
83
- color: (0, _Item.getVariantStyles)(variant, disabled).annotationColor,
84
- marginLeft: 2
85
- }, sx)
86
- }, props), props.children));
87
- };
88
-
89
- exports.TrailingVisual = TrailingVisual;
90
- TrailingVisual.displayName = "TrailingVisual";
@@ -1,40 +0,0 @@
1
- /// <reference types="react" />
2
- import { Divider } from './Divider';
3
- export type { ListProps as ActionListProps } from './List';
4
- export type { GroupProps } from './Group';
5
- export type { ItemProps } from './Item';
6
- export type { DescriptionProps } from './Description';
7
- export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
8
- /**
9
- * Collection of list-related components.
10
- */
11
- export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
12
- /** Collects related `Items` in an `ActionList`. */
13
- Group: import("react").FC<import("./Group").GroupProps>;
14
- /** An actionable or selectable `Item` */
15
- Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
16
- /** A `Item` that renders a full-size anchor inside ListItem */
17
- LinkItem: import("@radix-ui/react-polymorphic").ForwardRefComponent<"a", Pick<import("./Item").ItemProps, "children" | "sx"> & {
18
- download?: string | undefined;
19
- href?: string | undefined;
20
- hrefLang?: string | undefined;
21
- media?: string | undefined;
22
- ping?: string | undefined;
23
- rel?: string | undefined;
24
- target?: string | undefined;
25
- type?: string | undefined;
26
- referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
27
- }>;
28
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
29
- Divider: typeof Divider;
30
- /** Secondary text which provides additional information about an `Item`. */
31
- Description: import("react").FC<import("./Description").DescriptionProps>;
32
- /** Icon (or similar) positioned before `Item` text. */
33
- LeadingVisual: import("react").FC<import("../sx").SxProp & {
34
- children: import("react").ReactNode;
35
- }>;
36
- /** Icon (or similar) positioned after `Item` text. */
37
- TrailingVisual: import("react").FC<import("../sx").SxProp & {
38
- children: import("react").ReactNode;
39
- }>;
40
- };
@@ -1,47 +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 _LinkItem = require("./LinkItem");
15
-
16
- var _Divider = require("./Divider");
17
-
18
- var _Description = require("./Description");
19
-
20
- var _Visuals = require("./Visuals");
21
-
22
- /**
23
- * Collection of list-related components.
24
- */
25
- const ActionList = Object.assign(_List.List, {
26
- /** Collects related `Items` in an `ActionList`. */
27
- Group: _Group.Group,
28
-
29
- /** An actionable or selectable `Item` */
30
- Item: _Item.Item,
31
-
32
- /** A `Item` that renders a full-size anchor inside ListItem */
33
- LinkItem: _LinkItem.LinkItem,
34
-
35
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
36
- Divider: _Divider.Divider,
37
-
38
- /** Secondary text which provides additional information about an `Item`. */
39
- Description: _Description.Description,
40
-
41
- /** Icon (or similar) positioned before `Item` text. */
42
- LeadingVisual: _Visuals.LeadingVisual,
43
-
44
- /** Icon (or similar) positioned after `Item` text. */
45
- TrailingVisual: _Visuals.TrailingVisual
46
- });
47
- exports.ActionList = ActionList;
@@ -1 +0,0 @@
1
- export * from './ActionList2';
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _ActionList = require("./ActionList2");
8
-
9
- Object.keys(_ActionList).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _ActionList[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _ActionList[key];
16
- }
17
- });
18
- });
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- /** createSlots is a factory that can create a
3
- * typesafe Slots + Slot pair to use in a component definition
4
- * For example: ActionList.Item uses createSlots to get a Slots wrapper
5
- * + Slot component that is used by LeadingVisual, Description
6
- */
7
- declare const createSlots: <SlotNames extends string>(slotNames: SlotNames[]) => {
8
- Slots: React.FC<{
9
- context?: Record<string, unknown> | undefined;
10
- children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
11
- }>;
12
- Slot: React.FC<{
13
- name: SlotNames;
14
- children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
15
- }>;
16
- };
17
- export default createSlots;