@primer/components 0.0.0-2021111193153 → 0.0.0-202111121740

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 (171) hide show
  1. package/CHANGELOG.md +2 -12
  2. package/dist/browser.esm.js +605 -587
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +222 -204
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Divider.d.ts +2 -3
  7. package/lib/ActionList2/Divider.js +5 -10
  8. package/lib/ActionList2/Item.js +5 -21
  9. package/lib/ActionList2/List.js +1 -11
  10. package/lib/ActionList2/Selection.js +0 -11
  11. package/lib/ActionList2/index.d.ts +2 -1
  12. package/lib/Autocomplete/AutocompleteMenu.js +6 -13
  13. package/lib/Avatar.d.ts +2 -1
  14. package/lib/Avatar.js +1 -1
  15. package/lib/BranchName.d.ts +2 -1
  16. package/lib/BranchName.js +1 -1
  17. package/lib/Checkbox.d.ts +1 -1
  18. package/lib/CheckboxInputField.d.ts +11 -0
  19. package/lib/CheckboxInputField.js +73 -0
  20. package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  21. package/lib/ChoiceFieldset/ChoiceFieldCaption.js +35 -0
  22. package/lib/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  23. package/lib/ChoiceFieldset/ChoiceFieldLabel.js +35 -0
  24. package/lib/ChoiceFieldset/ChoiceFieldset.d.ts +63 -0
  25. package/lib/ChoiceFieldset/ChoiceFieldset.js +95 -0
  26. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
  27. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.js +29 -0
  28. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
  29. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +44 -0
  30. package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
  31. package/lib/ChoiceFieldset/ChoiceFieldsetList.js +80 -0
  32. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +18 -0
  33. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +15 -0
  34. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
  35. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.js +74 -0
  36. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  37. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +17 -0
  38. package/lib/ChoiceFieldset/index.d.ts +3 -0
  39. package/lib/ChoiceFieldset/index.js +23 -0
  40. package/lib/Details.d.ts +2 -1
  41. package/lib/Details.js +3 -1
  42. package/lib/Dropdown.d.ts +66 -2
  43. package/lib/Heading.d.ts +2 -1
  44. package/lib/Heading.js +6 -1
  45. package/lib/ProgressBar.d.ts +11 -16
  46. package/lib/ProgressBar.js +10 -6
  47. package/lib/RadioInputField.d.ts +9 -0
  48. package/lib/RadioInputField.js +82 -0
  49. package/lib/Spinner.d.ts +2 -1
  50. package/lib/Spinner.js +3 -1
  51. package/lib/TextInputField.d.ts +581 -0
  52. package/lib/TextInputField.js +66 -0
  53. package/lib/_InputCaption.d.ts +13 -0
  54. package/lib/_InputCaption.js +27 -0
  55. package/lib/_InputField/InputField.d.ts +39 -0
  56. package/lib/_InputField/InputField.js +90 -0
  57. package/lib/_InputField/InputFieldCaption.d.ts +3 -0
  58. package/lib/_InputField/InputFieldCaption.js +30 -0
  59. package/lib/_InputField/InputFieldLabel.d.ts +9 -0
  60. package/lib/_InputField/InputFieldLabel.js +34 -0
  61. package/lib/_InputField/InputFieldValidation.d.ts +6 -0
  62. package/lib/{ActionList2/MenuContext.js → _InputField/InputFieldValidation.js} +6 -4
  63. package/lib/_InputField/ToggleInputField.d.ts +13 -0
  64. package/lib/_InputField/ToggleInputField.js +71 -0
  65. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  66. package/lib/_InputField/ToggleInputLeadingVisual.js +22 -0
  67. package/lib/_InputField/ValidationAnimationContainer.d.ts +6 -0
  68. package/lib/_InputField/ValidationAnimationContainer.js +48 -0
  69. package/lib/_InputField/index.d.ts +1 -0
  70. package/lib/_InputField/index.js +15 -0
  71. package/lib/_InputField/slots.d.ts +13 -0
  72. package/lib/_InputField/slots.js +17 -0
  73. package/lib/_InputLabel.d.ts +8 -0
  74. package/lib/_InputLabel.js +44 -0
  75. package/lib/_InputValidation.d.ts +8 -0
  76. package/lib/_InputValidation.js +56 -0
  77. package/lib/_VisuallyHidden.d.ts +6 -0
  78. package/lib/_VisuallyHidden.js +39 -0
  79. package/lib/drafts.d.ts +0 -1
  80. package/lib/drafts.js +0 -13
  81. package/lib/index.d.ts +4 -0
  82. package/lib/index.js +38 -0
  83. package/lib/utils/types/FormValidationStatus.d.ts +1 -0
  84. package/lib/utils/types/FormValidationStatus.js +1 -0
  85. package/lib-esm/ActionList2/Divider.d.ts +2 -3
  86. package/lib-esm/ActionList2/Divider.js +5 -8
  87. package/lib-esm/ActionList2/Item.js +5 -19
  88. package/lib-esm/ActionList2/List.js +1 -9
  89. package/lib-esm/ActionList2/Selection.js +0 -9
  90. package/lib-esm/ActionList2/index.d.ts +2 -1
  91. package/lib-esm/Autocomplete/AutocompleteMenu.js +3 -13
  92. package/lib-esm/Avatar.d.ts +2 -1
  93. package/lib-esm/Avatar.js +2 -2
  94. package/lib-esm/BranchName.d.ts +2 -1
  95. package/lib-esm/BranchName.js +2 -2
  96. package/lib-esm/Checkbox.d.ts +1 -1
  97. package/lib-esm/CheckboxInputField.d.ts +11 -0
  98. package/lib-esm/CheckboxInputField.js +56 -0
  99. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  100. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +20 -0
  101. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  102. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +20 -0
  103. package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +63 -0
  104. package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +72 -0
  105. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
  106. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.js +17 -0
  107. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
  108. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +31 -0
  109. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
  110. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +63 -0
  111. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +18 -0
  112. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +5 -0
  113. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
  114. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.js +50 -0
  115. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  116. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +7 -0
  117. package/lib-esm/ChoiceFieldset/index.d.ts +3 -0
  118. package/lib-esm/ChoiceFieldset/index.js +2 -0
  119. package/lib-esm/Details.d.ts +2 -1
  120. package/lib-esm/Details.js +2 -1
  121. package/lib-esm/Dropdown.d.ts +66 -2
  122. package/lib-esm/Heading.d.ts +2 -1
  123. package/lib-esm/Heading.js +6 -2
  124. package/lib-esm/ProgressBar.d.ts +11 -16
  125. package/lib-esm/ProgressBar.js +11 -7
  126. package/lib-esm/RadioInputField.d.ts +9 -0
  127. package/lib-esm/RadioInputField.js +65 -0
  128. package/lib-esm/Spinner.d.ts +2 -1
  129. package/lib-esm/Spinner.js +2 -1
  130. package/lib-esm/TextInputField.d.ts +581 -0
  131. package/lib-esm/TextInputField.js +50 -0
  132. package/lib-esm/_InputCaption.d.ts +13 -0
  133. package/lib-esm/_InputCaption.js +16 -0
  134. package/lib-esm/_InputField/InputField.d.ts +39 -0
  135. package/lib-esm/_InputField/InputField.js +70 -0
  136. package/lib-esm/_InputField/InputFieldCaption.d.ts +3 -0
  137. package/lib-esm/_InputField/InputFieldCaption.js +18 -0
  138. package/lib-esm/_InputField/InputFieldLabel.d.ts +9 -0
  139. package/lib-esm/_InputField/InputFieldLabel.js +22 -0
  140. package/lib-esm/_InputField/InputFieldValidation.d.ts +6 -0
  141. package/lib-esm/_InputField/InputFieldValidation.js +7 -0
  142. package/lib-esm/_InputField/ToggleInputField.d.ts +13 -0
  143. package/lib-esm/_InputField/ToggleInputField.js +54 -0
  144. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  145. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +11 -0
  146. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +6 -0
  147. package/lib-esm/_InputField/ValidationAnimationContainer.js +33 -0
  148. package/lib-esm/_InputField/index.d.ts +1 -0
  149. package/lib-esm/_InputField/index.js +1 -0
  150. package/lib-esm/_InputField/slots.d.ts +13 -0
  151. package/lib-esm/_InputField/slots.js +5 -0
  152. package/lib-esm/_InputLabel.d.ts +8 -0
  153. package/lib-esm/_InputLabel.js +32 -0
  154. package/lib-esm/_InputValidation.d.ts +8 -0
  155. package/lib-esm/_InputValidation.js +43 -0
  156. package/lib-esm/_VisuallyHidden.d.ts +6 -0
  157. package/lib-esm/_VisuallyHidden.js +26 -0
  158. package/lib-esm/drafts.d.ts +0 -1
  159. package/lib-esm/drafts.js +1 -2
  160. package/lib-esm/index.d.ts +4 -0
  161. package/lib-esm/index.js +4 -0
  162. package/lib-esm/utils/types/FormValidationStatus.d.ts +1 -0
  163. package/lib-esm/utils/types/FormValidationStatus.js +1 -0
  164. package/package.json +2 -2
  165. package/lib/ActionList2/MenuContext.d.ts +0 -10
  166. package/lib/ActionMenu2.d.ts +0 -310
  167. package/lib/ActionMenu2.js +0 -91
  168. package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
  169. package/lib-esm/ActionList2/MenuContext.js +0 -3
  170. package/lib-esm/ActionMenu2.d.ts +0 -310
  171. package/lib-esm/ActionMenu2.js +0 -67
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _octiconsReact = require("@primer/octicons-react");
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _ = require(".");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const validationIconMap = {
17
+ success: _octiconsReact.CheckCircleFillIcon,
18
+ error: _octiconsReact.AlertFillIcon
19
+ };
20
+ const validationColorMap = {
21
+ success: 'success.fg',
22
+ error: 'danger.fg'
23
+ };
24
+
25
+ const InputValidation = ({
26
+ children,
27
+ id,
28
+ validationStatus
29
+ }) => {
30
+ const IconComponent = validationStatus ? validationIconMap[validationStatus] : undefined;
31
+ const fgColor = validationStatus ? validationColorMap[validationStatus] : undefined;
32
+ return /*#__PURE__*/_react.default.createElement(_.Text, {
33
+ display: "flex",
34
+ color: fgColor,
35
+ fontSize: 0,
36
+ sx: {
37
+ alignItems: 'baseline',
38
+ a: {
39
+ color: 'currentColor',
40
+ textDecoration: 'underline'
41
+ }
42
+ }
43
+ }, IconComponent && /*#__PURE__*/_react.default.createElement(_.Box, {
44
+ as: "span",
45
+ mr: 1
46
+ }, /*#__PURE__*/_react.default.createElement(IconComponent, {
47
+ size: 12,
48
+ fill: "currentColor"
49
+ })), /*#__PURE__*/_react.default.createElement("span", {
50
+ id: id
51
+ }, children));
52
+ };
53
+
54
+ InputValidation.displayName = "InputValidation";
55
+ var _default = InputValidation;
56
+ exports.default = _default;
@@ -0,0 +1,6 @@
1
+ import { SxProp } from './sx';
2
+ interface Props {
3
+ isVisible?: boolean;
4
+ }
5
+ declare const VisuallyHidden: import("styled-components").StyledComponent<"span", any, Props & SxProp, never>;
6
+ export default VisuallyHidden;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+
10
+ var _sx = _interopRequireDefault(require("./sx"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const VisuallyHidden = _styledComponents.default.span.withConfig({
15
+ displayName: "_VisuallyHidden__VisuallyHidden",
16
+ componentId: "sc-1k15c4h-0"
17
+ })(["", ""], props => {
18
+ if (props.isVisible) {
19
+ return _sx.default;
20
+ }
21
+
22
+ return `
23
+ position: absolute;
24
+ width: 1px;
25
+ height: 1px;
26
+ padding: 0;
27
+ margin: -1px;
28
+ overflow: hidden;
29
+ clip: rect(0, 0, 0, 0);
30
+ white-space: nowrap;
31
+ border-width: 0;
32
+ `;
33
+ });
34
+
35
+ VisuallyHidden.defaultProps = {
36
+ isVisible: true
37
+ };
38
+ var _default = VisuallyHidden;
39
+ exports.default = _default;
package/lib/drafts.d.ts CHANGED
@@ -6,4 +6,3 @@
6
6
  */
7
7
  export * from './ActionList2';
8
8
  export * from './NewButton';
9
- export * from './ActionMenu2';
package/lib/drafts.js CHANGED
@@ -28,17 +28,4 @@ Object.keys(_NewButton).forEach(function (key) {
28
28
  return _NewButton[key];
29
29
  }
30
30
  });
31
- });
32
-
33
- var _ActionMenu = require("./ActionMenu2");
34
-
35
- Object.keys(_ActionMenu).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (key in exports && exports[key] === _ActionMenu[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function () {
41
- return _ActionMenu[key];
42
- }
43
- });
44
31
  });
package/lib/index.d.ts CHANGED
@@ -46,6 +46,8 @@ export { default as CircleBadge } from './CircleBadge';
46
46
  export type { CircleBadgeProps, CircleBadgeIconProps } from './CircleBadge';
47
47
  export { default as CircleOcticon } from './CircleOcticon';
48
48
  export type { CircleOcticonProps } from './CircleOcticon';
49
+ export { default as CheckboxInputField } from './CheckboxInputField';
50
+ export { default as ChoiceFieldset, Item } from './ChoiceFieldset';
49
51
  export { default as CounterLabel } from './CounterLabel';
50
52
  export type { CounterLabelProps } from './CounterLabel';
51
53
  export { default as Details } from './Details';
@@ -86,6 +88,7 @@ export { default as Popover } from './Popover';
86
88
  export type { PopoverProps, PopoverContentProps } from './Popover';
87
89
  export { default as ProgressBar } from './ProgressBar';
88
90
  export type { ProgressBarProps } from './ProgressBar';
91
+ export { default as RadioInputField } from './RadioInputField';
89
92
  export { default as SelectMenu } from './SelectMenu';
90
93
  export type { SelectMenuProps, SelectMenuDividerProps, SelectMenuFilterProps, SelectMenuFooterProps, SelectMenuItemProps, SelectMenuListProps, SelectMenuModalProps, SelectMenuTabsProps, SelectMenuHeaderProps, SelectMenuTabProps, SelectMenuTabPanelProps, SelectMenuLoadingAnimationProps } from './SelectMenu';
91
94
  export { default as SideNav } from './SideNav';
@@ -102,6 +105,7 @@ export { default as TabNav } from './TabNav';
102
105
  export type { TabNavProps, TabNavLinkProps } from './TabNav';
103
106
  export { default as TextInput } from './TextInput';
104
107
  export type { TextInputProps } from './TextInput';
108
+ export { default as TextInputField } from './TextInputField';
105
109
  export { default as TextInputWithTokens } from './TextInputWithTokens';
106
110
  export type { TextInputWithTokensProps } from './TextInputWithTokens';
107
111
  export { default as Text } from './Text';
package/lib/index.js CHANGED
@@ -267,6 +267,24 @@ Object.defineProperty(exports, "CircleOcticon", {
267
267
  return _CircleOcticon.default;
268
268
  }
269
269
  });
270
+ Object.defineProperty(exports, "CheckboxInputField", {
271
+ enumerable: true,
272
+ get: function () {
273
+ return _CheckboxInputField.default;
274
+ }
275
+ });
276
+ Object.defineProperty(exports, "ChoiceFieldset", {
277
+ enumerable: true,
278
+ get: function () {
279
+ return _ChoiceFieldset.default;
280
+ }
281
+ });
282
+ Object.defineProperty(exports, "Item", {
283
+ enumerable: true,
284
+ get: function () {
285
+ return _ChoiceFieldset.Item;
286
+ }
287
+ });
270
288
  Object.defineProperty(exports, "CounterLabel", {
271
289
  enumerable: true,
272
290
  get: function () {
@@ -393,6 +411,12 @@ Object.defineProperty(exports, "ProgressBar", {
393
411
  return _ProgressBar.default;
394
412
  }
395
413
  });
414
+ Object.defineProperty(exports, "RadioInputField", {
415
+ enumerable: true,
416
+ get: function () {
417
+ return _RadioInputField.default;
418
+ }
419
+ });
396
420
  Object.defineProperty(exports, "SelectMenu", {
397
421
  enumerable: true,
398
422
  get: function () {
@@ -441,6 +465,12 @@ Object.defineProperty(exports, "TextInput", {
441
465
  return _TextInput.default;
442
466
  }
443
467
  });
468
+ Object.defineProperty(exports, "TextInputField", {
469
+ enumerable: true,
470
+ get: function () {
471
+ return _TextInputField.default;
472
+ }
473
+ });
444
474
  Object.defineProperty(exports, "TextInputWithTokens", {
445
475
  enumerable: true,
446
476
  get: function () {
@@ -572,6 +602,10 @@ var _CircleBadge = _interopRequireDefault(require("./CircleBadge"));
572
602
 
573
603
  var _CircleOcticon = _interopRequireDefault(require("./CircleOcticon"));
574
604
 
605
+ var _CheckboxInputField = _interopRequireDefault(require("./CheckboxInputField"));
606
+
607
+ var _ChoiceFieldset = _interopRequireWildcard(require("./ChoiceFieldset"));
608
+
575
609
  var _CounterLabel = _interopRequireDefault(require("./CounterLabel"));
576
610
 
577
611
  var _Details = _interopRequireDefault(require("./Details"));
@@ -612,6 +646,8 @@ var _Popover = _interopRequireDefault(require("./Popover"));
612
646
 
613
647
  var _ProgressBar = _interopRequireDefault(require("./ProgressBar"));
614
648
 
649
+ var _RadioInputField = _interopRequireDefault(require("./RadioInputField"));
650
+
615
651
  var _SelectMenu = _interopRequireDefault(require("./SelectMenu"));
616
652
 
617
653
  var _SideNav = _interopRequireDefault(require("./SideNav"));
@@ -628,6 +664,8 @@ var _TabNav = _interopRequireDefault(require("./TabNav"));
628
664
 
629
665
  var _TextInput = _interopRequireDefault(require("./TextInput"));
630
666
 
667
+ var _TextInputField = _interopRequireDefault(require("./TextInputField"));
668
+
631
669
  var _TextInputWithTokens = _interopRequireDefault(require("./TextInputWithTokens"));
632
670
 
633
671
  var _Text = _interopRequireDefault(require("./Text"));
@@ -0,0 +1 @@
1
+ export declare type FormValidationStatus = 'error' | 'success';
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,6 +1,5 @@
1
- import React from 'react';
2
- import { SxProp } from '../sx';
1
+ /// <reference types="react" />
3
2
  /**
4
3
  * Visually separates `Item`s or `Group`s in an `ActionList`.
5
4
  */
6
- export declare const Divider: React.FC<SxProp>;
5
+ export declare function Divider(): JSX.Element;
@@ -1,26 +1,23 @@
1
1
  import React from 'react';
2
2
  import Box from '../Box';
3
3
  import { get } from '../constants';
4
- import { merge } from '../sx';
4
+
5
5
  /**
6
6
  * Visually separates `Item`s or `Group`s in an `ActionList`.
7
7
  */
8
-
9
- export const Divider = ({
10
- sx = {}
11
- }) => {
8
+ export function Divider() {
12
9
  return /*#__PURE__*/React.createElement(Box, {
13
10
  as: "li",
14
11
  role: "separator",
15
- sx: merge({
12
+ sx: {
16
13
  height: 1,
17
14
  backgroundColor: 'actionListItem.inlineDivider',
18
15
  marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
19
16
  marginBottom: 2,
20
17
  listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
21
18
 
22
- }, sx),
19
+ },
23
20
  "data-component": "ActionList.Divider"
24
21
  });
25
- };
22
+ }
26
23
  Divider.displayName = "Divider";
@@ -8,7 +8,6 @@ import Box from '../Box';
8
8
  import sx, { merge } from '../sx';
9
9
  import createSlots from '../utils/create-slots';
10
10
  import { ListContext } from './List';
11
- import { MenuContext } from './MenuContext';
12
11
  import { Selection } from './Selection';
13
12
  export const getVariantStyles = (variant, disabled) => {
14
13
  if (disabled) {
@@ -55,7 +54,6 @@ export const Item = /*#__PURE__*/React.forwardRef(({
55
54
  onSelect,
56
55
  sx: sxProp = {},
57
56
  id,
58
- role,
59
57
  _PrivateItemWrapper,
60
58
  ...props
61
59
  }, forwardedRef) => {
@@ -63,10 +61,6 @@ export const Item = /*#__PURE__*/React.forwardRef(({
63
61
  variant: listVariant,
64
62
  showDividers
65
63
  } = React.useContext(ListContext);
66
- const {
67
- itemRole,
68
- afterSelect
69
- } = React.useContext(MenuContext);
70
64
  const {
71
65
  theme
72
66
  } = useTheme();
@@ -141,23 +135,16 @@ export const Item = /*#__PURE__*/React.forwardRef(({
141
135
  const clickHandler = React.useCallback(event => {
142
136
  if (typeof onSelect !== 'function') return;
143
137
  if (disabled) return;
144
-
145
- if (!event.defaultPrevented) {
146
- onSelect(event); // if this Item is inside a Menu, close the Menu
147
-
148
- if (typeof afterSelect === 'function') afterSelect();
149
- }
150
- }, [onSelect, disabled, afterSelect]);
138
+ if (!event.defaultPrevented) onSelect(event);
139
+ }, [onSelect, disabled]);
151
140
  const keyPressHandler = React.useCallback(event => {
152
141
  if (typeof onSelect !== 'function') return;
153
142
  if (disabled) return;
154
143
 
155
144
  if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
156
- onSelect(event); // if this Item is inside a Menu, close the Menu
157
-
158
- if (typeof afterSelect === 'function') afterSelect();
145
+ onSelect(event);
159
146
  }
160
- }, [onSelect, disabled, afterSelect]); // use props.id if provided, otherwise generate one.
147
+ }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
161
148
 
162
149
  const labelId = useSSRSafeId(id);
163
150
  const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
@@ -179,8 +166,7 @@ export const Item = /*#__PURE__*/React.forwardRef(({
179
166
  "aria-disabled": disabled ? true : undefined,
180
167
  tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
181
168
  "aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
182
- "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined,
183
- role: role || itemRole
169
+ "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
184
170
  }, props), /*#__PURE__*/React.createElement(ItemWrapper, null, /*#__PURE__*/React.createElement(Selection, {
185
171
  selected: selected
186
172
  }), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
@@ -3,7 +3,6 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import React from 'react';
4
4
  import styled from 'styled-components';
5
5
  import sx, { merge } from '../sx';
6
- import { MenuContext } from './MenuContext';
7
6
  export const ListContext = /*#__PURE__*/React.createContext({});
8
7
  const ListBox = styled.ul.withConfig({
9
8
  displayName: "List__ListBox",
@@ -13,7 +12,6 @@ export const List = /*#__PURE__*/React.forwardRef(({
13
12
  variant = 'inset',
14
13
  selectionVariant,
15
14
  showDividers = false,
16
- role,
17
15
  sx: sxProp = {},
18
16
  ...props
19
17
  }, forwardedRef) => {
@@ -23,14 +21,8 @@ export const List = /*#__PURE__*/React.forwardRef(({
23
21
  // reset ul styles
24
22
  paddingY: variant === 'inset' ? 2 : 0
25
23
  };
26
- /** if list is inside a Menu, it will get a role from the Menu */
27
-
28
- const {
29
- listRole
30
- } = React.useContext(MenuContext);
31
24
  return /*#__PURE__*/React.createElement(ListBox, _extends({
32
- sx: merge(styles, sxProp),
33
- role: role || listRole
25
+ sx: merge(styles, sxProp)
34
26
  }, props, {
35
27
  ref: forwardedRef
36
28
  }), /*#__PURE__*/React.createElement(ListContext.Provider, {
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { CheckIcon } from '@primer/octicons-react';
3
3
  import { ListContext } from './List';
4
4
  import { GroupContext } from './Group';
5
- import { MenuContext } from './MenuContext';
6
5
  import { LeadingVisualContainer } from './Visuals';
7
6
  export const Selection = ({
8
7
  selected
@@ -13,9 +12,6 @@ export const Selection = ({
13
12
  const {
14
13
  selectionVariant: groupSelectionVariant
15
14
  } = React.useContext(GroupContext);
16
- const {
17
- parent
18
- } = React.useContext(MenuContext);
19
15
  /** selectionVariant in Group can override the selectionVariant in List root */
20
16
 
21
17
  const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
@@ -26,11 +22,6 @@ export const Selection = ({
26
22
  return null;
27
23
  }
28
24
 
29
- if (parent === 'ActionMenu') {
30
- throw new Error('ActionList cannot have a selectionVariant inside ActionMenu, please use DropdownMenu or SelectPanel instead. More information: https://primer.style/design/components/action-list#application');
31
- return null;
32
- }
33
-
34
25
  if (selectionVariant === 'single') {
35
26
  return /*#__PURE__*/React.createElement(LeadingVisualContainer, null, selected && /*#__PURE__*/React.createElement(CheckIcon, null));
36
27
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { Divider } from './Divider';
2
3
  export type { ListProps as ActionListProps } from './List';
3
4
  export type { GroupProps } from './Group';
4
5
  export type { ItemProps } from './Item';
@@ -25,7 +26,7 @@ export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRe
25
26
  referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
26
27
  }>;
27
28
  /** Visually separates `Item`s or `Group`s in an `ActionList`. */
28
- Divider: import("react").FC<import("../sx").SxProp>;
29
+ Divider: typeof Divider;
29
30
  /** Secondary text which provides additional information about an `Item`. */
30
31
  Description: import("react").FC<import("./Description").DescriptionProps>;
31
32
  /** Icon (or similar) positioned before `Item` text. */
@@ -6,6 +6,7 @@ import { AutocompleteContext } from './AutocompleteContext';
6
6
  import { PlusIcon } from '@primer/octicons-react';
7
7
  import { uniqueId } from '../utils/uniqueId';
8
8
  import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
9
+ import VisuallyHidden from '../_VisuallyHidden';
9
10
 
10
11
  const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
11
12
 
@@ -164,19 +165,8 @@ function AutocompleteMenu(props) {
164
165
  setSelectedItemLength(selectedItemIds.length);
165
166
  }
166
167
  }, [selectedItemIds, setSelectedItemLength]);
167
- return /*#__PURE__*/React.createElement(Box, {
168
- sx: !showMenu ? {
169
- // visually hides this label for sighted users
170
- position: 'absolute',
171
- width: '1px',
172
- height: '1px',
173
- padding: '0',
174
- margin: '-1px',
175
- overflow: 'hidden',
176
- clip: 'rect(0, 0, 0, 0)',
177
- whiteSpace: 'nowrap',
178
- borderWidth: '0'
179
- } : {}
168
+ return /*#__PURE__*/React.createElement(VisuallyHidden, {
169
+ isVisible: showMenu
180
170
  }, loading ? /*#__PURE__*/React.createElement(Box, {
181
171
  p: 3,
182
172
  display: "flex",
@@ -1,3 +1,4 @@
1
+ import { SystemCommonProps } from './constants';
1
2
  import { SxProp } from './sx';
2
3
  import { ComponentProps } from './utils/types';
3
4
  declare const Avatar: import("styled-components").StyledComponent<"img", any, {
@@ -9,6 +10,6 @@ declare const Avatar: import("styled-components").StyledComponent<"img", any, {
9
10
  src: string;
10
11
  /** Provide alt text when the Avatar is used without the user's name next to it. */
11
12
  alt?: string | undefined;
12
- } & SxProp, never>;
13
+ } & SystemCommonProps & SxProp, never>;
13
14
  export declare type AvatarProps = ComponentProps<typeof Avatar>;
14
15
  export default Avatar;
package/lib-esm/Avatar.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import styled from 'styled-components';
2
- import { get } from './constants';
2
+ import { COMMON, get } from './constants';
3
3
  import sx from './sx';
4
4
 
5
5
  function getBorderRadius({
@@ -19,7 +19,7 @@ const Avatar = styled.img.attrs(props => ({
19
19
  })).withConfig({
20
20
  displayName: "Avatar",
21
21
  componentId: "sc-1waaaky-0"
22
- })(["display:inline-block;overflow:hidden;line-height:", ";vertical-align:middle;border-radius:", ";", ""], get('lineHeights.condensedUltra'), props => getBorderRadius(props), sx);
22
+ })(["display:inline-block;overflow:hidden;line-height:", ";vertical-align:middle;border-radius:", ";", ";", ""], get('lineHeights.condensedUltra'), props => getBorderRadius(props), COMMON, sx);
23
23
  Avatar.defaultProps = {
24
24
  size: 20,
25
25
  alt: '',
@@ -1,5 +1,6 @@
1
+ import { SystemCommonProps } from './constants';
1
2
  import { SxProp } from './sx';
2
3
  import { ComponentProps } from './utils/types';
3
- declare const BranchName: import("styled-components").StyledComponent<"a", any, SxProp, never>;
4
+ declare const BranchName: import("styled-components").StyledComponent<"a", any, SystemCommonProps & SxProp, never>;
4
5
  export declare type BranchNameProps = ComponentProps<typeof BranchName>;
5
6
  export default BranchName;
@@ -1,8 +1,8 @@
1
1
  import styled from 'styled-components';
2
- import { get } from './constants';
2
+ import { COMMON, get } from './constants';
3
3
  import sx from './sx';
4
4
  const BranchName = styled.a.withConfig({
5
5
  displayName: "BranchName",
6
6
  componentId: "sc-167ouzm-0"
7
- })(["display:inline-block;padding:2px 6px;font-size:", ";font-family:", ";color:", ";background-color:", ";border-radius:", ";", ";"], get('fontSizes.0'), get('fonts.mono'), get('colors.fg.muted'), get('colors.accent.subtle'), get('radii.2'), sx);
7
+ })(["display:inline-block;padding:2px 6px;font-size:", ";font-family:", ";color:", ";background-color:", ";border-radius:", ";", ";", ";"], get('fontSizes.0'), get('fonts.mono'), get('colors.fg.muted'), get('colors.accent.subtle'), get('radii.2'), COMMON, sx);
8
8
  export default BranchName;
@@ -25,5 +25,5 @@ export declare type CheckboxProps = {
25
25
  /**
26
26
  * An accessible, native checkbox component
27
27
  */
28
- declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "indeterminate" | "validationStatus"> & React.RefAttributes<HTMLInputElement>>;
28
+ declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "validationStatus" | "indeterminate"> & React.RefAttributes<HTMLInputElement>>;
29
29
  export default Checkbox;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { ToggleInputFieldProps } from './_InputField/ToggleInputField';
3
+ declare const _default: React.FC<ToggleInputFieldProps> & {
4
+ Input: React.FC<React.HTMLProps<HTMLInputElement> & {
5
+ ref?: React.Ref<HTMLInputElement> | undefined;
6
+ }>;
7
+ Caption: React.FC<{}>;
8
+ Label: React.FC<import("./_InputField/InputFieldLabel").Props>;
9
+ LeadingVisual: React.FC<{}>;
10
+ };
11
+ export default _default;
@@ -0,0 +1,56 @@
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 { Checkbox } from '.';
5
+ import InputField from './_InputField/InputField';
6
+ import { Slot } from './_InputField/slots';
7
+ import ToggleInputField from './_InputField/ToggleInputField';
8
+ import ToggleInputLeadingVisual from './_InputField/ToggleInputLeadingVisual';
9
+
10
+ const Input = ({
11
+ id: idProp,
12
+ required: requiredProp,
13
+ disabled: disabledProp,
14
+ ...rest
15
+ }) => {
16
+ if (idProp) {
17
+ // eslint-disable-next-line no-console
18
+ console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
19
+ }
20
+
21
+ if (disabledProp) {
22
+ // eslint-disable-next-line no-console
23
+ console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
24
+ }
25
+
26
+ if (requiredProp) {
27
+ // eslint-disable-next-line no-console
28
+ console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
29
+ }
30
+
31
+ return /*#__PURE__*/React.createElement(Slot, {
32
+ name: "Input"
33
+ }, ({
34
+ disabled,
35
+ id,
36
+ required,
37
+ captionId
38
+ }) => /*#__PURE__*/React.createElement(Checkbox, _extends({
39
+ "aria-describedby": captionId,
40
+ id: id,
41
+ required: required,
42
+ disabled: disabled
43
+ }, rest)));
44
+ };
45
+
46
+ Input.displayName = "Input";
47
+
48
+ const CheckboxInputField = props => /*#__PURE__*/React.createElement(ToggleInputField, props);
49
+
50
+ CheckboxInputField.displayName = "CheckboxInputField";
51
+ export default Object.assign(CheckboxInputField, {
52
+ Input,
53
+ Caption: InputField.Caption,
54
+ Label: InputField.Label,
55
+ LeadingVisual: ToggleInputLeadingVisual
56
+ });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ChoiceFieldCaption: React.FC;
3
+ export default ChoiceFieldCaption;
@@ -0,0 +1,20 @@
1
+ import React, { useContext } from 'react';
2
+ import ChoiceFieldsetListContext from './ChoiceFieldsetListContext';
3
+
4
+ const ChoiceFieldCaption = ({
5
+ children
6
+ }) => {
7
+ const choiceFieldsetListContext = useContext(ChoiceFieldsetListContext);
8
+
9
+ if (choiceFieldsetListContext === null) {
10
+ throw new Error('ChoiceFieldsetListContext returned null');
11
+ }
12
+
13
+ const {
14
+ fieldComponent: FieldComponent
15
+ } = choiceFieldsetListContext;
16
+ return /*#__PURE__*/React.createElement(FieldComponent.Caption, null, children);
17
+ };
18
+
19
+ ChoiceFieldCaption.displayName = "ChoiceFieldCaption";
20
+ export default ChoiceFieldCaption;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ChoiceFieldLabel: React.FC;
3
+ export default ChoiceFieldLabel;
@@ -0,0 +1,20 @@
1
+ import React, { useContext } from 'react';
2
+ import ChoiceFieldsetListContext from './ChoiceFieldsetListContext';
3
+
4
+ const ChoiceFieldLabel = ({
5
+ children
6
+ }) => {
7
+ const choiceFieldsetListContext = useContext(ChoiceFieldsetListContext);
8
+
9
+ if (choiceFieldsetListContext === null) {
10
+ throw new Error('ChoiceFieldsetListContext returned null');
11
+ }
12
+
13
+ const {
14
+ fieldComponent: FieldComponent
15
+ } = choiceFieldsetListContext;
16
+ return /*#__PURE__*/React.createElement(FieldComponent.Label, null, children);
17
+ };
18
+
19
+ ChoiceFieldLabel.displayName = "ChoiceFieldLabel";
20
+ export default ChoiceFieldLabel;