@primer/components 0.0.0-202111845030 → 0.0.0-202111885047

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 (148) hide show
  1. package/dist/browser.esm.js +2 -2
  2. package/dist/browser.esm.js.map +1 -1
  3. package/dist/browser.umd.js +2 -2
  4. package/dist/browser.umd.js.map +1 -1
  5. package/lib/Autocomplete/AutocompleteMenu.js +17 -11
  6. package/lib/BranchName.js +1 -1
  7. package/lib/NewButton/button-base.d.ts +6 -0
  8. package/lib/NewButton/button-base.js +69 -0
  9. package/lib/NewButton/button-link.d.ts +27 -0
  10. package/lib/{ChoiceFieldset/ChoiceFieldLabel.js → NewButton/button-link.js} +14 -18
  11. package/lib/NewButton/button.d.ts +2 -11
  12. package/lib/NewButton/button.js +6 -283
  13. package/lib/NewButton/icon-button.d.ts +4 -0
  14. package/lib/NewButton/icon-button.js +57 -0
  15. package/lib/NewButton/index.d.ts +6 -11
  16. package/lib/NewButton/index.js +18 -0
  17. package/lib/NewButton/styles.d.ts +202 -0
  18. package/lib/NewButton/styles.js +248 -0
  19. package/lib/NewButton/types.d.ts +28 -8
  20. package/lib/NewButton/types.js +19 -1
  21. package/lib/index.d.ts +0 -4
  22. package/lib/index.js +0 -38
  23. package/lib-esm/Autocomplete/AutocompleteMenu.js +16 -7
  24. package/lib-esm/BranchName.js +1 -1
  25. package/lib-esm/NewButton/button-base.d.ts +6 -0
  26. package/lib-esm/NewButton/button-base.js +47 -0
  27. package/lib-esm/NewButton/button-link.d.ts +27 -0
  28. package/lib-esm/NewButton/button-link.js +15 -0
  29. package/lib-esm/NewButton/button.d.ts +2 -11
  30. package/lib-esm/NewButton/button.js +4 -275
  31. package/lib-esm/NewButton/icon-button.d.ts +4 -0
  32. package/lib-esm/NewButton/icon-button.js +35 -0
  33. package/lib-esm/NewButton/index.d.ts +6 -11
  34. package/lib-esm/NewButton/index.js +4 -1
  35. package/lib-esm/NewButton/styles.d.ts +202 -0
  36. package/lib-esm/NewButton/styles.js +229 -0
  37. package/lib-esm/NewButton/types.d.ts +28 -8
  38. package/lib-esm/NewButton/types.js +6 -1
  39. package/lib-esm/index.d.ts +0 -4
  40. package/lib-esm/index.js +0 -4
  41. package/package.json +2 -2
  42. package/lib/CheckboxInputField.d.ts +0 -11
  43. package/lib/CheckboxInputField.js +0 -73
  44. package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +0 -3
  45. package/lib/ChoiceFieldset/ChoiceFieldCaption.js +0 -35
  46. package/lib/ChoiceFieldset/ChoiceFieldLabel.d.ts +0 -3
  47. package/lib/ChoiceFieldset/ChoiceFieldset.d.ts +0 -65
  48. package/lib/ChoiceFieldset/ChoiceFieldset.js +0 -93
  49. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +0 -3
  50. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.js +0 -29
  51. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +0 -9
  52. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +0 -44
  53. package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +0 -9
  54. package/lib/ChoiceFieldset/ChoiceFieldsetList.js +0 -71
  55. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +0 -19
  56. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +0 -15
  57. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +0 -25
  58. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.js +0 -75
  59. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +0 -6
  60. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +0 -17
  61. package/lib/ChoiceFieldset/index.d.ts +0 -3
  62. package/lib/ChoiceFieldset/index.js +0 -23
  63. package/lib/RadioInputField.d.ts +0 -10
  64. package/lib/RadioInputField.js +0 -74
  65. package/lib/TextInputField.d.ts +0 -583
  66. package/lib/TextInputField.js +0 -66
  67. package/lib/_InputCaption.d.ts +0 -13
  68. package/lib/_InputCaption.js +0 -27
  69. package/lib/_InputField/InputField.d.ts +0 -39
  70. package/lib/_InputField/InputField.js +0 -88
  71. package/lib/_InputField/InputFieldCaption.d.ts +0 -3
  72. package/lib/_InputField/InputFieldCaption.js +0 -30
  73. package/lib/_InputField/InputFieldLabel.d.ts +0 -9
  74. package/lib/_InputField/InputFieldLabel.js +0 -34
  75. package/lib/_InputField/InputFieldValidation.d.ts +0 -6
  76. package/lib/_InputField/InputFieldValidation.js +0 -17
  77. package/lib/_InputField/ToggleInputField.d.ts +0 -13
  78. package/lib/_InputField/ToggleInputField.js +0 -75
  79. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
  80. package/lib/_InputField/ToggleInputLeadingVisual.js +0 -22
  81. package/lib/_InputField/ValidationAnimationContainer.d.ts +0 -6
  82. package/lib/_InputField/ValidationAnimationContainer.js +0 -48
  83. package/lib/_InputField/index.d.ts +0 -1
  84. package/lib/_InputField/index.js +0 -15
  85. package/lib/_InputField/slots.d.ts +0 -13
  86. package/lib/_InputField/slots.js +0 -17
  87. package/lib/_InputLabel.d.ts +0 -8
  88. package/lib/_InputLabel.js +0 -45
  89. package/lib/_InputValidation.d.ts +0 -8
  90. package/lib/_InputValidation.js +0 -59
  91. package/lib/_VisuallyHidden.d.ts +0 -6
  92. package/lib/_VisuallyHidden.js +0 -39
  93. package/lib/utils/types/FormValidationStatus.d.ts +0 -1
  94. package/lib/utils/types/FormValidationStatus.js +0 -1
  95. package/lib-esm/CheckboxInputField.d.ts +0 -11
  96. package/lib-esm/CheckboxInputField.js +0 -56
  97. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +0 -3
  98. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +0 -20
  99. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +0 -3
  100. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +0 -20
  101. package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +0 -65
  102. package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +0 -71
  103. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +0 -3
  104. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.js +0 -17
  105. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +0 -9
  106. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +0 -31
  107. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +0 -9
  108. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +0 -55
  109. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +0 -19
  110. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +0 -5
  111. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +0 -25
  112. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.js +0 -51
  113. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +0 -6
  114. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +0 -7
  115. package/lib-esm/ChoiceFieldset/index.d.ts +0 -3
  116. package/lib-esm/ChoiceFieldset/index.js +0 -2
  117. package/lib-esm/RadioInputField.d.ts +0 -10
  118. package/lib-esm/RadioInputField.js +0 -56
  119. package/lib-esm/TextInputField.d.ts +0 -583
  120. package/lib-esm/TextInputField.js +0 -50
  121. package/lib-esm/_InputCaption.d.ts +0 -13
  122. package/lib-esm/_InputCaption.js +0 -16
  123. package/lib-esm/_InputField/InputField.d.ts +0 -39
  124. package/lib-esm/_InputField/InputField.js +0 -69
  125. package/lib-esm/_InputField/InputFieldCaption.d.ts +0 -3
  126. package/lib-esm/_InputField/InputFieldCaption.js +0 -18
  127. package/lib-esm/_InputField/InputFieldLabel.d.ts +0 -9
  128. package/lib-esm/_InputField/InputFieldLabel.js +0 -22
  129. package/lib-esm/_InputField/InputFieldValidation.d.ts +0 -6
  130. package/lib-esm/_InputField/InputFieldValidation.js +0 -7
  131. package/lib-esm/_InputField/ToggleInputField.d.ts +0 -13
  132. package/lib-esm/_InputField/ToggleInputField.js +0 -58
  133. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
  134. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +0 -11
  135. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +0 -6
  136. package/lib-esm/_InputField/ValidationAnimationContainer.js +0 -33
  137. package/lib-esm/_InputField/index.d.ts +0 -1
  138. package/lib-esm/_InputField/index.js +0 -1
  139. package/lib-esm/_InputField/slots.d.ts +0 -13
  140. package/lib-esm/_InputField/slots.js +0 -5
  141. package/lib-esm/_InputLabel.d.ts +0 -8
  142. package/lib-esm/_InputLabel.js +0 -33
  143. package/lib-esm/_InputValidation.d.ts +0 -8
  144. package/lib-esm/_InputValidation.js +0 -46
  145. package/lib-esm/_VisuallyHidden.d.ts +0 -6
  146. package/lib-esm/_VisuallyHidden.js +0 -26
  147. package/lib-esm/utils/types/FormValidationStatus.d.ts +0 -1
  148. package/lib-esm/utils/types/FormValidationStatus.js +0 -1
@@ -17,13 +17,9 @@ var _AutocompleteContext = require("./AutocompleteContext");
17
17
 
18
18
  var _octiconsReact = require("@primer/octicons-react");
19
19
 
20
- var _scrollIntoViewingArea = require("../behaviors/scrollIntoViewingArea");
21
-
22
- var _VisuallyHidden = _interopRequireDefault(require("../_VisuallyHidden"));
20
+ var _uniqueId = require("../utils/uniqueId");
23
21
 
24
- var _ssr = require("@react-aria/ssr");
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ var _scrollIntoViewingArea = require("../behaviors/scrollIntoViewingArea");
27
23
 
28
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
25
 
@@ -94,7 +90,6 @@ function AutocompleteMenu(props) {
94
90
  const [sortedItemIds, setSortedItemIds] = (0, _react.useState)(items.map(({
95
91
  id: itemId
96
92
  }) => itemId));
97
- const generatedUniqueId = (0, _ssr.useSSRSafeId)(id);
98
93
  const selectableItems = (0, _react.useMemo)(() => items.map(selectableItem => {
99
94
  return { ...selectableItem,
100
95
  role: 'option',
@@ -130,7 +125,7 @@ function AutocompleteMenu(props) {
130
125
  onAction: item => {
131
126
  // TODO: make it possible to pass a leadingVisual when using `addNewItem`
132
127
  addNewItem.handleAddItem({ ...item,
133
- id: item.id || generatedUniqueId,
128
+ id: item.id || (0, _uniqueId.uniqueId)(),
134
129
  leadingVisual: undefined
135
130
  });
136
131
 
@@ -139,7 +134,7 @@ function AutocompleteMenu(props) {
139
134
  setAutocompleteSuggestion('');
140
135
  }
141
136
  }
142
- }] : [])], [sortedAndFilteredItemsToRender, addNewItem, setAutocompleteSuggestion, selectionVariant, setInputValue, generatedUniqueId]);
137
+ }] : [])], [sortedAndFilteredItemsToRender, addNewItem, setAutocompleteSuggestion, selectionVariant, setInputValue]);
143
138
  (0, _useFocusZone.useFocusZone)({
144
139
  containerRef: listContainerRef,
145
140
  focusOutBehavior: 'wrap',
@@ -187,8 +182,19 @@ function AutocompleteMenu(props) {
187
182
  setSelectedItemLength(selectedItemIds.length);
188
183
  }
189
184
  }, [selectedItemIds, setSelectedItemLength]);
190
- return /*#__PURE__*/_react.default.createElement(_VisuallyHidden.default, {
191
- isVisible: showMenu
185
+ return /*#__PURE__*/_react.default.createElement(_.Box, {
186
+ sx: !showMenu ? {
187
+ // visually hides this label for sighted users
188
+ position: 'absolute',
189
+ width: '1px',
190
+ height: '1px',
191
+ padding: '0',
192
+ margin: '-1px',
193
+ overflow: 'hidden',
194
+ clip: 'rect(0, 0, 0, 0)',
195
+ whiteSpace: 'nowrap',
196
+ borderWidth: '0'
197
+ } : {}
192
198
  }, loading ? /*#__PURE__*/_react.default.createElement(_.Box, {
193
199
  p: 3,
194
200
  display: "flex",
package/lib/BranchName.js CHANGED
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
16
  const BranchName = _styledComponents.default.a.withConfig({
17
17
  displayName: "BranchName",
18
18
  componentId: "sc-167ouzm-0"
19
- })(["display:inline-block;padding:2px 6px;font-size:", ";font-family:", ";color:", ";background-color:", ";border-radius:", ";", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fonts.mono'), (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('colors.accent.subtle'), (0, _constants.get)('radii.2'), _sx.default);
19
+ })(["display:inline-block;padding:2px 6px;font-size:", ";font-family:", ";color:", ";background-color:", ";border-radius:", ";text-decoration:none;", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fonts.mono'), (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('colors.accent.subtle'), (0, _constants.get)('radii.2'), _sx.default);
20
20
 
21
21
  var _default = BranchName;
22
22
  exports.default = _default;
@@ -0,0 +1,6 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ import { ButtonProps } from './types';
4
+ declare const ButtonBase: PolymorphicForwardRefComponent<"a" | "button", ButtonProps>;
5
+ export declare type ButtonBaseProps = ComponentPropsWithRef<typeof ButtonBase>;
6
+ export default ButtonBase;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _sx = require("../sx");
13
+
14
+ var _ThemeProvider = require("../ThemeProvider");
15
+
16
+ var _types = require("./types");
17
+
18
+ var _styles = require("./styles");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 ButtonBase = /*#__PURE__*/(0, _react.forwardRef)(({
29
+ children,
30
+ as: Component = 'button',
31
+ sx: sxProp = {},
32
+ ...props
33
+ }, forwardedRef) => {
34
+ const {
35
+ leadingIcon: LeadingIcon,
36
+ trailingIcon: TrailingIcon,
37
+ variant = 'default',
38
+ size = 'medium'
39
+ } = props;
40
+ const {
41
+ theme
42
+ } = (0, _ThemeProvider.useTheme)();
43
+ const iconWrapStyles = {
44
+ display: 'inline-block'
45
+ };
46
+
47
+ const sxStyles = _sx.merge.all([(0, _styles.getButtonStyles)(theme), (0, _styles.getSizeStyles)(size, variant, false), (0, _styles.getVariantStyles)(variant, theme), sxProp]);
48
+
49
+ return /*#__PURE__*/_react.default.createElement(_types.StyledButton, _extends({
50
+ as: Component,
51
+ sx: sxStyles
52
+ }, props, {
53
+ ref: forwardedRef
54
+ }), LeadingIcon && /*#__PURE__*/_react.default.createElement(_Box.default, {
55
+ as: "span",
56
+ "data-component": "leadingIcon",
57
+ sx: iconWrapStyles
58
+ }, /*#__PURE__*/_react.default.createElement(LeadingIcon, null)), /*#__PURE__*/_react.default.createElement("span", {
59
+ "data-component": "text"
60
+ }, children), TrailingIcon && /*#__PURE__*/_react.default.createElement(_Box.default, {
61
+ as: "span",
62
+ "data-component": "trailingIcon",
63
+ sx: { ...iconWrapStyles,
64
+ ml: 2
65
+ }
66
+ }, /*#__PURE__*/_react.default.createElement(TrailingIcon, null)));
67
+ });
68
+ var _default = ButtonBase;
69
+ exports.default = _default;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ declare const LinkButton: PolymorphicForwardRefComponent<"a", Omit<(Pick<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>> & {
4
+ ref?: ((instance: HTMLAnchorElement | null) => void) | React.RefObject<HTMLAnchorElement> | null | undefined;
5
+ }) | (Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
6
+ ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
7
+ }), string | number | symbol> & {
8
+ leadingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
+ trailingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
+ children: React.ReactNode;
11
+ } & {
12
+ variant?: import("./types").VariantType | undefined;
13
+ size?: import("./types").Size | undefined;
14
+ disabled?: boolean | undefined;
15
+ } & import("../sx").SxProp & React.HTMLAttributes<HTMLButtonElement> & {
16
+ [x: string]: any;
17
+ [x: number]: any;
18
+ [x: symbol]: any;
19
+ } & {
20
+ theme?: any;
21
+ } & {
22
+ as?: string | React.ComponentType<any> | undefined;
23
+ forwardedAs?: string | React.ComponentType<any> | undefined;
24
+ } & {
25
+ as?: "a" | "button" | undefined;
26
+ }>;
27
+ export default LinkButton;
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _ChoiceFieldsetListContext = _interopRequireDefault(require("./ChoiceFieldsetListContext"));
10
+ var _buttonBase = _interopRequireDefault(require("./button-base"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
@@ -15,21 +15,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
- const ChoiceFieldLabel = ({
19
- children
20
- }) => {
21
- const choiceFieldsetListContext = (0, _react.useContext)(_ChoiceFieldsetListContext.default);
22
-
23
- if (choiceFieldsetListContext === null) {
24
- throw new Error('ChoiceFieldsetListContext returned null');
25
- }
26
-
27
- const {
28
- fieldComponent: FieldComponent
29
- } = choiceFieldsetListContext;
30
- return /*#__PURE__*/_react.default.createElement(FieldComponent.Label, null, children);
31
- };
32
-
33
- ChoiceFieldLabel.displayName = "ChoiceFieldLabel";
34
- var _default = ChoiceFieldLabel;
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 LinkButton = /*#__PURE__*/(0, _react.forwardRef)(({
21
+ children,
22
+ as: Component = 'a',
23
+ ...props
24
+ }, forwardedRef) => {
25
+ return /*#__PURE__*/_react.default.createElement(_buttonBase.default, _extends({
26
+ as: Component,
27
+ ref: forwardedRef
28
+ }, props), children);
29
+ });
30
+ var _default = LinkButton;
35
31
  exports.default = _default;
@@ -1,13 +1,4 @@
1
1
  import React from 'react';
2
- import { SxProp } from '../sx';
3
- import { VariantType } from './types';
4
- declare const Button: React.ForwardRefExoticComponent<{
5
- variant?: VariantType | undefined;
6
- size?: import("./types").Size | undefined;
7
- icon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
8
- leadingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
- trailingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
- disabled?: boolean | undefined;
11
- children: React.ReactNode;
12
- } & SxProp & React.HTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
2
+ import { ButtonProps } from './types';
3
+ declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, string | number | symbol> & React.RefAttributes<HTMLButtonElement>>;
13
4
  export { Button };
@@ -7,13 +7,7 @@ exports.Button = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _Box = _interopRequireDefault(require("../Box"));
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- var _sx = _interopRequireWildcard(require("../sx"));
15
-
16
- var _ThemeProvider = require("../ThemeProvider");
10
+ var _buttonBase = _interopRequireDefault(require("./button-base"));
17
11
 
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
13
 
@@ -23,286 +17,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
17
 
24
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); }
25
19
 
26
- const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
27
-
28
- const getVariantStyles = (variant = 'default', theme) => {
29
- const style = {
30
- default: {
31
- color: 'btn.text',
32
- backgroundColor: 'btn.bg',
33
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
34
- '&:hover:not([disabled])': {
35
- backgroundColor: 'btn.hoverBg'
36
- },
37
- // focus must come before :active so that the active box shadow overrides
38
- '&:focus:not([disabled])': {
39
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
40
- },
41
- '&:active:not([disabled])': {
42
- backgroundColor: 'btn.selectedBg',
43
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
44
- },
45
- '&:disabled': {
46
- color: 'primer.fg.disabled',
47
- backgroundColor: 'btn.disabledBg'
48
- }
49
- },
50
- primary: {
51
- color: 'btn.primary.text',
52
- backgroundColor: 'btn.primary.bg',
53
- borderColor: 'border.subtle',
54
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
55
- '&:hover:not([disabled])': {
56
- color: 'btn.primary.hoverText',
57
- backgroundColor: 'btn.primary.hoverBg'
58
- },
59
- // focus must come before :active so that the active box shadow overrides
60
- '&:focus:not([disabled])': {
61
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
62
- },
63
- '&:active:not([disabled])': {
64
- backgroundColor: 'btn.primary.selectedBg',
65
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
66
- },
67
- '&:disabled': {
68
- color: 'btn.primary.disabledText',
69
- backgroundColor: 'btn.primary.disabledBg'
70
- },
71
- '[data-component="ButtonCounter"]': {
72
- backgroundColor: 'btn.primary.counterBg',
73
- color: 'btn.primary.text'
74
- }
75
- },
76
- danger: {
77
- color: 'btn.danger.text',
78
- backgroundColor: 'btn.bg',
79
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
80
- '&:hover:not([disabled])': {
81
- color: 'btn.danger.hoverText',
82
- backgroundColor: 'btn.danger.hoverBg',
83
- borderColor: 'btn.danger.hoverBorder',
84
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
85
- '[data-component="ButtonCounter"]': {
86
- backgroundColor: 'btn.danger.hoverCounterBg',
87
- color: 'btn.danger.hoverText'
88
- }
89
- },
90
- // focus must come before :active so that the active box shadow overrides
91
- '&:focus:not([disabled])': {
92
- borderColor: 'btn.danger.focusBorder',
93
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
94
- },
95
- '&:active:not([disabled])': {
96
- color: 'btn.danger.selectedText',
97
- backgroundColor: 'btn.danger.selectedBg',
98
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
99
- borderColor: 'btn.danger.selectedBorder'
100
- },
101
- '&:disabled': {
102
- color: 'btn.danger.disabledText',
103
- backgroundColor: 'btn.danger.disabledBg',
104
- borderColor: 'btn.danger.disabledBorder',
105
- '[data-component="ButtonCounter"]': {
106
- backgroundColor: 'btn.danger.disabledCounterBg'
107
- }
108
- },
109
- '[data-component="ButtonCounter"]': {
110
- color: 'btn.danger.text',
111
- backgroundColor: 'btn.danger.counterBg'
112
- }
113
- },
114
- invisible: {
115
- color: 'accent.fg',
116
- backgroundColor: 'transparent',
117
- border: '0',
118
- boxShadow: 'none',
119
- '&:hover:not([disabled])': {
120
- backgroundColor: 'btn.hoverBg'
121
- },
122
- // focus must come before :active so that the active box shadow overrides
123
- '&:focus:not([disabled])': {
124
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
125
- },
126
- '&:active:not([disabled])': {
127
- backgroundColor: 'btn.selectedBg'
128
- },
129
- '&:disabled': {
130
- color: 'primer.fg.disabled'
131
- }
132
- },
133
- outline: {
134
- color: 'btn.outline.text',
135
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
136
- '&:hover': {
137
- color: 'btn.outline.hoverText',
138
- backgroundColor: 'btn.outline.hoverBg',
139
- borderColor: 'outline.hoverBorder',
140
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
141
- '[data-component="ButtonCounter"]': {
142
- backgroundColor: 'btn.outline.hoverCounterBg',
143
- color: 'btn.outline.hoverText'
144
- }
145
- },
146
- // focus must come before :active so that the active box shadow overrides
147
- '&:focus': {
148
- borderColor: 'btn.outline.focusBorder',
149
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
150
- },
151
- '&:active:not([disabled])': {
152
- color: 'btn.outline.selectedText',
153
- backgroundColor: 'btn.outline.selectedBg',
154
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
155
- borderColor: 'btn.outline.selectedBorder'
156
- },
157
- '&:disabled': {
158
- color: 'btn.outline.disabledText',
159
- backgroundColor: 'btn.outline.disabledBg',
160
- borderColor: 'btn.border',
161
- '[data-component="ButtonCounter"]': {
162
- backgroundColor: 'btn.outline.disabledCounterBg'
163
- }
164
- },
165
- '[data-component="ButtonCounter"]': {
166
- backgroundColor: 'btn.outline.counterBg',
167
- color: 'btn.outline.text'
168
- }
169
- }
170
- };
171
- return style[variant];
172
- };
173
-
174
- const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
175
- let paddingY, paddingX, fontSize;
176
-
177
- switch (size) {
178
- case 'small':
179
- paddingY = 3;
180
- paddingX = 12;
181
- fontSize = 0;
182
- break;
183
-
184
- case 'large':
185
- paddingY = 9;
186
- paddingX = 20;
187
- fontSize = 2;
188
- break;
189
-
190
- case 'medium':
191
- default:
192
- paddingY = 5;
193
- paddingX = 16;
194
- fontSize = 1;
195
- }
196
-
197
- if (iconOnly) {
198
- paddingX = paddingY + 2;
199
- }
200
-
201
- if (variant === 'invisible') {
202
- paddingY = paddingY + 1;
203
- }
204
-
205
- return {
206
- paddingY: `${paddingY}px`,
207
- paddingX: `${paddingX}px`,
208
- fontSize,
209
- '[data-component="ButtonCounter"]': {
210
- fontSize
211
- }
212
- };
213
- };
214
-
215
- const ButtonBase = _styledComponents.default.button.withConfig({
216
- displayName: "button__ButtonBase",
217
- componentId: "sc-15k5iqk-0"
218
- })(_sx.default);
219
-
220
20
  const Button = /*#__PURE__*/(0, _react.forwardRef)(({
221
21
  children,
222
- sx: sxProp = {},
223
22
  ...props
224
23
  }, forwardedRef) => {
225
- const {
226
- icon: Icon,
227
- leadingIcon: LeadingIcon,
228
- trailingIcon: TrailingIcon,
229
- variant = 'default',
230
- size = 'medium'
231
- } = props;
232
- const iconOnly = !!Icon;
233
- const {
234
- theme
235
- } = (0, _ThemeProvider.useTheme)();
236
- const styles = {
237
- borderRadius: '2',
238
- border: '1px solid',
239
- borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
240
- display: 'grid',
241
- gridTemplateAreas: '"leadingIcon text trailingIcon"',
242
- fontWeight: 'bold',
243
- lineHeight: TEXT_ROW_HEIGHT,
244
- whiteSpace: 'nowrap',
245
- verticalAlign: 'middle',
246
- cursor: 'pointer',
247
- appearance: 'none',
248
- userSelect: 'none',
249
- textDecoration: 'none',
250
- textAlign: 'center',
251
- '& > :not(:last-child)': {
252
- mr: '2'
253
- },
254
- '&:focus': {
255
- outline: 'none'
256
- },
257
- '&:disabled': {
258
- cursor: 'default'
259
- },
260
- '&:disabled svg': {
261
- opacity: '0.6'
262
- },
263
- '[data-component="leadingIcon"]': {
264
- gridArea: 'leadingIcon'
265
- },
266
- '[data-component="text"]': {
267
- gridArea: 'text'
268
- },
269
- '[data-component="trailingIcon"]': {
270
- gridArea: 'trailingIcon'
271
- }
272
- };
273
- const iconWrapStyles = {
274
- display: 'inline-block'
275
- };
276
-
277
- const sxStyles = _sx.merge.all([styles, getSizeStyles(size, variant, iconOnly), getVariantStyles(variant, theme), sxProp]);
278
-
279
- return /*#__PURE__*/_react.default.createElement(ButtonBase, _extends({
280
- sx: sxStyles,
24
+ return /*#__PURE__*/_react.default.createElement(_buttonBase.default, _extends({
281
25
  ref: forwardedRef
282
- }, props), LeadingIcon && /*#__PURE__*/_react.default.createElement(_Box.default, {
283
- as: "span",
284
- "data-component": "leadingIcon",
285
- sx: iconWrapStyles,
286
- "aria-hidden": !iconOnly
287
- }, /*#__PURE__*/_react.default.createElement(LeadingIcon, null)), /*#__PURE__*/_react.default.createElement("span", {
288
- "data-component": "text",
289
- hidden: Icon ? true : false
290
- }, children), Icon && /*#__PURE__*/_react.default.createElement(_Box.default, {
291
- "data-component": "icon-only",
292
- as: "span",
293
- sx: {
294
- display: 'inline-block'
295
- },
296
- "aria-hidden": !iconOnly
297
- }, /*#__PURE__*/_react.default.createElement(Icon, null)), TrailingIcon && /*#__PURE__*/_react.default.createElement(_Box.default, {
298
- as: "span",
299
- "data-component": "trailingIcon",
300
- sx: { ...iconWrapStyles,
301
- ml: 2
302
- },
303
- "aria-hidden": !iconOnly
304
- }, /*#__PURE__*/_react.default.createElement(TrailingIcon, null)));
26
+ }, props, {
27
+ as: "button"
28
+ }), children);
305
29
  });
306
30
  exports.Button = Button;
307
- Button.displayName = 'Button';
308
- Object.assign(Button, {});
31
+ Button.displayName = 'Button';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IconButtonProps } from './types';
3
+ declare const IconButton: React.ForwardRefExoticComponent<Pick<IconButtonProps, string | number | symbol> & React.RefAttributes<HTMLButtonElement>>;
4
+ export default IconButton;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _sx = require("../sx");
11
+
12
+ var _ThemeProvider = require("../ThemeProvider");
13
+
14
+ var _Box = _interopRequireDefault(require("../Box"));
15
+
16
+ var _types = require("./types");
17
+
18
+ var _styles = require("./styles");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 IconButton = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
29
+ const {
30
+ variant = 'default',
31
+ size = 'medium',
32
+ sx: sxProp = {},
33
+ icon: Icon,
34
+ iconLabel
35
+ } = props;
36
+ const {
37
+ theme
38
+ } = (0, _ThemeProvider.useTheme)();
39
+ const styles = { ...(0, _styles.getBaseStyles)(theme)
40
+ };
41
+
42
+ const sxStyles = _sx.merge.all([styles, (0, _styles.getSizeStyles)(size, variant, true), (0, _styles.getVariantStyles)(variant, theme), sxProp]);
43
+
44
+ return /*#__PURE__*/_react.default.createElement(_types.StyledButton, _extends({
45
+ sx: sxStyles,
46
+ ref: forwardedRef
47
+ }, props), /*#__PURE__*/_react.default.createElement("span", {
48
+ hidden: true
49
+ }, iconLabel), /*#__PURE__*/_react.default.createElement(_Box.default, {
50
+ as: "span",
51
+ sx: {
52
+ display: 'inline-block'
53
+ }
54
+ }, /*#__PURE__*/_react.default.createElement(Icon, null)));
55
+ });
56
+ var _default = IconButton;
57
+ exports.default = _default;
@@ -1,14 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { ButtonProps } from './types';
3
- export type { ButtonProps as NewButtonProps };
4
- export declare const NewButton: import("react").ForwardRefExoticComponent<{
5
- variant?: import("./types").VariantType | undefined;
6
- size?: import("./types").Size | undefined;
7
- icon?: import("react").FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
8
- leadingIcon?: import("react").FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
- trailingIcon?: import("react").FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
- disabled?: boolean | undefined;
11
- children: import("react").ReactNode;
12
- } & import("../sx").SxProp & import("react").HTMLAttributes<HTMLButtonElement> & import("react").RefAttributes<HTMLButtonElement>> & {
2
+ import IconButton from './icon-button';
3
+ import ButtonLink from './button-link';
4
+ import { ButtonProps, IconButtonProps } from './types';
5
+ export type { ButtonProps as NewButtonProps, IconButtonProps };
6
+ export declare const NewButton: import("react").ForwardRefExoticComponent<Pick<ButtonProps, string | number | symbol> & import("react").RefAttributes<HTMLButtonElement>> & {
13
7
  Counter: ({ children, sx: sxProp, ...props }: import("./button-counter").CounterProps) => JSX.Element;
14
8
  };
9
+ export { IconButton, ButtonLink };
@@ -3,12 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "IconButton", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _iconButton.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ButtonLink", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _buttonLink.default;
16
+ }
17
+ });
6
18
  exports.NewButton = void 0;
7
19
 
8
20
  var _button = require("./button");
9
21
 
10
22
  var _buttonCounter = require("./button-counter");
11
23
 
24
+ var _iconButton = _interopRequireDefault(require("./icon-button"));
25
+
26
+ var _buttonLink = _interopRequireDefault(require("./button-link"));
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
12
30
  const NewButton = Object.assign(_button.Button, {
13
31
  Counter: _buttonCounter.Counter
14
32
  });