@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
@@ -4,5 +4,5 @@ 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:", ";text-decoration:none;", ";"], get('fontSizes.0'), get('fonts.mono'), get('colors.accent.fg'), get('colors.accent.subtle'), get('radii.2'), sx);
8
8
  export default BranchName;
@@ -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,47 @@
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, { forwardRef } from 'react';
4
+ import Box from '../Box';
5
+ import { merge } from '../sx';
6
+ import { useTheme } from '../ThemeProvider';
7
+ import { StyledButton } from './types';
8
+ import { getVariantStyles, getSizeStyles, getButtonStyles } from './styles';
9
+ const ButtonBase = /*#__PURE__*/forwardRef(({
10
+ children,
11
+ as: Component = 'button',
12
+ sx: sxProp = {},
13
+ ...props
14
+ }, forwardedRef) => {
15
+ const {
16
+ leadingIcon: LeadingIcon,
17
+ trailingIcon: TrailingIcon,
18
+ variant = 'default',
19
+ size = 'medium'
20
+ } = props;
21
+ const {
22
+ theme
23
+ } = useTheme();
24
+ const iconWrapStyles = {
25
+ display: 'inline-block'
26
+ };
27
+ const sxStyles = merge.all([getButtonStyles(theme), getSizeStyles(size, variant, false), getVariantStyles(variant, theme), sxProp]);
28
+ return /*#__PURE__*/React.createElement(StyledButton, _extends({
29
+ as: Component,
30
+ sx: sxStyles
31
+ }, props, {
32
+ ref: forwardedRef
33
+ }), LeadingIcon && /*#__PURE__*/React.createElement(Box, {
34
+ as: "span",
35
+ "data-component": "leadingIcon",
36
+ sx: iconWrapStyles
37
+ }, /*#__PURE__*/React.createElement(LeadingIcon, null)), /*#__PURE__*/React.createElement("span", {
38
+ "data-component": "text"
39
+ }, children), TrailingIcon && /*#__PURE__*/React.createElement(Box, {
40
+ as: "span",
41
+ "data-component": "trailingIcon",
42
+ sx: { ...iconWrapStyles,
43
+ ml: 2
44
+ }
45
+ }, /*#__PURE__*/React.createElement(TrailingIcon, null)));
46
+ });
47
+ export default ButtonBase;
@@ -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;
@@ -0,0 +1,15 @@
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, { forwardRef } from 'react';
4
+ import ButtonBase from './button-base';
5
+ const LinkButton = /*#__PURE__*/forwardRef(({
6
+ children,
7
+ as: Component = 'a',
8
+ ...props
9
+ }, forwardedRef) => {
10
+ return /*#__PURE__*/React.createElement(ButtonBase, _extends({
11
+ as: Component,
12
+ ref: forwardedRef
13
+ }, props), children);
14
+ });
15
+ export default LinkButton;
@@ -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 };
@@ -1,287 +1,16 @@
1
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
2
 
3
3
  import React, { forwardRef } from 'react';
4
- import Box from '../Box';
5
- import styled from 'styled-components';
6
- import sx, { merge } from '../sx';
7
- import { useTheme } from '../ThemeProvider';
8
- const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
9
-
10
- const getVariantStyles = (variant = 'default', theme) => {
11
- const style = {
12
- default: {
13
- color: 'btn.text',
14
- backgroundColor: 'btn.bg',
15
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
16
- '&:hover:not([disabled])': {
17
- backgroundColor: 'btn.hoverBg'
18
- },
19
- // focus must come before :active so that the active box shadow overrides
20
- '&:focus:not([disabled])': {
21
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
22
- },
23
- '&:active:not([disabled])': {
24
- backgroundColor: 'btn.selectedBg',
25
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
26
- },
27
- '&:disabled': {
28
- color: 'primer.fg.disabled',
29
- backgroundColor: 'btn.disabledBg'
30
- }
31
- },
32
- primary: {
33
- color: 'btn.primary.text',
34
- backgroundColor: 'btn.primary.bg',
35
- borderColor: 'border.subtle',
36
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
37
- '&:hover:not([disabled])': {
38
- color: 'btn.primary.hoverText',
39
- backgroundColor: 'btn.primary.hoverBg'
40
- },
41
- // focus must come before :active so that the active box shadow overrides
42
- '&:focus:not([disabled])': {
43
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
44
- },
45
- '&:active:not([disabled])': {
46
- backgroundColor: 'btn.primary.selectedBg',
47
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
48
- },
49
- '&:disabled': {
50
- color: 'btn.primary.disabledText',
51
- backgroundColor: 'btn.primary.disabledBg'
52
- },
53
- '[data-component="ButtonCounter"]': {
54
- backgroundColor: 'btn.primary.counterBg',
55
- color: 'btn.primary.text'
56
- }
57
- },
58
- danger: {
59
- color: 'btn.danger.text',
60
- backgroundColor: 'btn.bg',
61
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
62
- '&:hover:not([disabled])': {
63
- color: 'btn.danger.hoverText',
64
- backgroundColor: 'btn.danger.hoverBg',
65
- borderColor: 'btn.danger.hoverBorder',
66
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
67
- '[data-component="ButtonCounter"]': {
68
- backgroundColor: 'btn.danger.hoverCounterBg',
69
- color: 'btn.danger.hoverText'
70
- }
71
- },
72
- // focus must come before :active so that the active box shadow overrides
73
- '&:focus:not([disabled])': {
74
- borderColor: 'btn.danger.focusBorder',
75
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
76
- },
77
- '&:active:not([disabled])': {
78
- color: 'btn.danger.selectedText',
79
- backgroundColor: 'btn.danger.selectedBg',
80
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
81
- borderColor: 'btn.danger.selectedBorder'
82
- },
83
- '&:disabled': {
84
- color: 'btn.danger.disabledText',
85
- backgroundColor: 'btn.danger.disabledBg',
86
- borderColor: 'btn.danger.disabledBorder',
87
- '[data-component="ButtonCounter"]': {
88
- backgroundColor: 'btn.danger.disabledCounterBg'
89
- }
90
- },
91
- '[data-component="ButtonCounter"]': {
92
- color: 'btn.danger.text',
93
- backgroundColor: 'btn.danger.counterBg'
94
- }
95
- },
96
- invisible: {
97
- color: 'accent.fg',
98
- backgroundColor: 'transparent',
99
- border: '0',
100
- boxShadow: 'none',
101
- '&:hover:not([disabled])': {
102
- backgroundColor: 'btn.hoverBg'
103
- },
104
- // focus must come before :active so that the active box shadow overrides
105
- '&:focus:not([disabled])': {
106
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
107
- },
108
- '&:active:not([disabled])': {
109
- backgroundColor: 'btn.selectedBg'
110
- },
111
- '&:disabled': {
112
- color: 'primer.fg.disabled'
113
- }
114
- },
115
- outline: {
116
- color: 'btn.outline.text',
117
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
118
- '&:hover': {
119
- color: 'btn.outline.hoverText',
120
- backgroundColor: 'btn.outline.hoverBg',
121
- borderColor: 'outline.hoverBorder',
122
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
123
- '[data-component="ButtonCounter"]': {
124
- backgroundColor: 'btn.outline.hoverCounterBg',
125
- color: 'btn.outline.hoverText'
126
- }
127
- },
128
- // focus must come before :active so that the active box shadow overrides
129
- '&:focus': {
130
- borderColor: 'btn.outline.focusBorder',
131
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
132
- },
133
- '&:active:not([disabled])': {
134
- color: 'btn.outline.selectedText',
135
- backgroundColor: 'btn.outline.selectedBg',
136
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
137
- borderColor: 'btn.outline.selectedBorder'
138
- },
139
- '&:disabled': {
140
- color: 'btn.outline.disabledText',
141
- backgroundColor: 'btn.outline.disabledBg',
142
- borderColor: 'btn.border',
143
- '[data-component="ButtonCounter"]': {
144
- backgroundColor: 'btn.outline.disabledCounterBg'
145
- }
146
- },
147
- '[data-component="ButtonCounter"]': {
148
- backgroundColor: 'btn.outline.counterBg',
149
- color: 'btn.outline.text'
150
- }
151
- }
152
- };
153
- return style[variant];
154
- };
155
-
156
- const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
157
- let paddingY, paddingX, fontSize;
158
-
159
- switch (size) {
160
- case 'small':
161
- paddingY = 3;
162
- paddingX = 12;
163
- fontSize = 0;
164
- break;
165
-
166
- case 'large':
167
- paddingY = 9;
168
- paddingX = 20;
169
- fontSize = 2;
170
- break;
171
-
172
- case 'medium':
173
- default:
174
- paddingY = 5;
175
- paddingX = 16;
176
- fontSize = 1;
177
- }
178
-
179
- if (iconOnly) {
180
- paddingX = paddingY + 2;
181
- }
182
-
183
- if (variant === 'invisible') {
184
- paddingY = paddingY + 1;
185
- }
186
-
187
- return {
188
- paddingY: `${paddingY}px`,
189
- paddingX: `${paddingX}px`,
190
- fontSize,
191
- '[data-component="ButtonCounter"]': {
192
- fontSize
193
- }
194
- };
195
- };
196
-
197
- const ButtonBase = styled.button.withConfig({
198
- displayName: "button__ButtonBase",
199
- componentId: "sc-15k5iqk-0"
200
- })(sx);
4
+ import ButtonBase from './button-base';
201
5
  const Button = /*#__PURE__*/forwardRef(({
202
6
  children,
203
- sx: sxProp = {},
204
7
  ...props
205
8
  }, forwardedRef) => {
206
- const {
207
- icon: Icon,
208
- leadingIcon: LeadingIcon,
209
- trailingIcon: TrailingIcon,
210
- variant = 'default',
211
- size = 'medium'
212
- } = props;
213
- const iconOnly = !!Icon;
214
- const {
215
- theme
216
- } = useTheme();
217
- const styles = {
218
- borderRadius: '2',
219
- border: '1px solid',
220
- borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
221
- display: 'grid',
222
- gridTemplateAreas: '"leadingIcon text trailingIcon"',
223
- fontWeight: 'bold',
224
- lineHeight: TEXT_ROW_HEIGHT,
225
- whiteSpace: 'nowrap',
226
- verticalAlign: 'middle',
227
- cursor: 'pointer',
228
- appearance: 'none',
229
- userSelect: 'none',
230
- textDecoration: 'none',
231
- textAlign: 'center',
232
- '& > :not(:last-child)': {
233
- mr: '2'
234
- },
235
- '&:focus': {
236
- outline: 'none'
237
- },
238
- '&:disabled': {
239
- cursor: 'default'
240
- },
241
- '&:disabled svg': {
242
- opacity: '0.6'
243
- },
244
- '[data-component="leadingIcon"]': {
245
- gridArea: 'leadingIcon'
246
- },
247
- '[data-component="text"]': {
248
- gridArea: 'text'
249
- },
250
- '[data-component="trailingIcon"]': {
251
- gridArea: 'trailingIcon'
252
- }
253
- };
254
- const iconWrapStyles = {
255
- display: 'inline-block'
256
- };
257
- const sxStyles = merge.all([styles, getSizeStyles(size, variant, iconOnly), getVariantStyles(variant, theme), sxProp]);
258
9
  return /*#__PURE__*/React.createElement(ButtonBase, _extends({
259
- sx: sxStyles,
260
10
  ref: forwardedRef
261
- }, props), LeadingIcon && /*#__PURE__*/React.createElement(Box, {
262
- as: "span",
263
- "data-component": "leadingIcon",
264
- sx: iconWrapStyles,
265
- "aria-hidden": !iconOnly
266
- }, /*#__PURE__*/React.createElement(LeadingIcon, null)), /*#__PURE__*/React.createElement("span", {
267
- "data-component": "text",
268
- hidden: Icon ? true : false
269
- }, children), Icon && /*#__PURE__*/React.createElement(Box, {
270
- "data-component": "icon-only",
271
- as: "span",
272
- sx: {
273
- display: 'inline-block'
274
- },
275
- "aria-hidden": !iconOnly
276
- }, /*#__PURE__*/React.createElement(Icon, null)), TrailingIcon && /*#__PURE__*/React.createElement(Box, {
277
- as: "span",
278
- "data-component": "trailingIcon",
279
- sx: { ...iconWrapStyles,
280
- ml: 2
281
- },
282
- "aria-hidden": !iconOnly
283
- }, /*#__PURE__*/React.createElement(TrailingIcon, null)));
11
+ }, props, {
12
+ as: "button"
13
+ }), children);
284
14
  });
285
15
  Button.displayName = 'Button';
286
- Object.assign(Button, {});
287
16
  export { 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,35 @@
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, { forwardRef } from 'react';
4
+ import { merge } from '../sx';
5
+ import { useTheme } from '../ThemeProvider';
6
+ import Box from '../Box';
7
+ import { StyledButton } from './types';
8
+ import { getBaseStyles, getSizeStyles, getVariantStyles } from './styles';
9
+ const IconButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
10
+ const {
11
+ variant = 'default',
12
+ size = 'medium',
13
+ sx: sxProp = {},
14
+ icon: Icon,
15
+ iconLabel
16
+ } = props;
17
+ const {
18
+ theme
19
+ } = useTheme();
20
+ const styles = { ...getBaseStyles(theme)
21
+ };
22
+ const sxStyles = merge.all([styles, getSizeStyles(size, variant, true), getVariantStyles(variant, theme), sxProp]);
23
+ return /*#__PURE__*/React.createElement(StyledButton, _extends({
24
+ sx: sxStyles,
25
+ ref: forwardedRef
26
+ }, props), /*#__PURE__*/React.createElement("span", {
27
+ hidden: true
28
+ }, iconLabel), /*#__PURE__*/React.createElement(Box, {
29
+ as: "span",
30
+ sx: {
31
+ display: 'inline-block'
32
+ }
33
+ }, /*#__PURE__*/React.createElement(Icon, null)));
34
+ });
35
+ export default IconButton;
@@ -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 };
@@ -1,5 +1,8 @@
1
1
  import { Button } from './button';
2
2
  import { Counter } from './button-counter';
3
+ import IconButton from './icon-button';
4
+ import ButtonLink from './button-link';
3
5
  export const NewButton = Object.assign(Button, {
4
6
  Counter
5
- });
7
+ });
8
+ export { IconButton, ButtonLink };