@primer/components 0.0.0-202111136954 → 0.0.0-20211115171641

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 (174) hide show
  1. package/CHANGELOG.md +996 -0
  2. package/dist/browser.esm.js +2209 -2
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +2209 -2
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Header.js +1 -1
  7. package/lib/ActionList/Item.js +10 -10
  8. package/lib/ActionList/List.js +1 -1
  9. package/lib/ActionList2/Item.js +7 -5
  10. package/lib/ActionList2/List.js +3 -3
  11. package/lib/ActionList2/{ActionListContainerContext.d.ts → MenuContext.d.ts} +3 -3
  12. package/lib/ActionList2/{ActionListContainerContext.js → MenuContext.js} +3 -3
  13. package/lib/ActionList2/Selection.js +4 -4
  14. package/lib/ActionMenu2.d.ts +12 -19
  15. package/lib/ActionMenu2.js +29 -63
  16. package/lib/Autocomplete/Autocomplete.d.ts +1 -2
  17. package/lib/Autocomplete/AutocompleteInput.d.ts +1 -2
  18. package/lib/BaseStyles.js +20 -2
  19. package/lib/BorderBox.js +1 -1
  20. package/lib/Box.js +1 -1
  21. package/lib/BranchName.js +1 -1
  22. package/lib/Breadcrumbs.js +3 -3
  23. package/lib/Button/Button.d.ts +2 -2
  24. package/lib/Button/Button.js +1 -1
  25. package/lib/Button/ButtonClose.d.ts +2 -2
  26. package/lib/Button/ButtonDanger.d.ts +2 -2
  27. package/lib/Button/ButtonGroup.js +1 -1
  28. package/lib/Button/ButtonInvisible.d.ts +2 -2
  29. package/lib/Button/ButtonOutline.d.ts +2 -2
  30. package/lib/Button/ButtonPrimary.d.ts +2 -2
  31. package/lib/Checkbox.d.ts +1 -1
  32. package/lib/Checkbox.js +1 -1
  33. package/lib/CircleOcticon.d.ts +35 -35
  34. package/lib/Details.js +1 -1
  35. package/lib/Dialog.d.ts +37 -37
  36. package/lib/Dropdown.d.ts +6 -6
  37. package/lib/DropdownMenu/DropdownButton.d.ts +3 -6
  38. package/lib/FilterList.d.ts +1 -1
  39. package/lib/FilteredActionList/FilteredActionList.js +1 -1
  40. package/lib/Flex.js +1 -1
  41. package/lib/LabelGroup.js +1 -1
  42. package/lib/NewButton/button.d.ts +11 -2
  43. package/lib/NewButton/button.js +283 -6
  44. package/lib/NewButton/index.d.ts +11 -6
  45. package/lib/NewButton/index.js +0 -18
  46. package/lib/NewButton/types.d.ts +8 -28
  47. package/lib/NewButton/types.js +1 -19
  48. package/lib/Overlay.js +1 -1
  49. package/lib/Pagination/Pagination.js +2 -2
  50. package/lib/Position.d.ts +4 -4
  51. package/lib/Position.js +1 -1
  52. package/lib/SelectMenu/SelectMenu.d.ts +10 -11
  53. package/lib/SelectMenu/SelectMenu.js +1 -1
  54. package/lib/SelectMenu/SelectMenuFilter.js +1 -1
  55. package/lib/SelectMenu/SelectMenuFooter.js +1 -1
  56. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  57. package/lib/SelectMenu/SelectMenuItem.js +1 -1
  58. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  59. package/lib/SelectMenu/SelectMenuTab.js +1 -1
  60. package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
  61. package/lib/SelectMenu/SelectMenuTabs.js +1 -1
  62. package/lib/StateLabel.js +1 -1
  63. package/lib/StyledOcticon.js +1 -1
  64. package/lib/SubNav.js +3 -3
  65. package/lib/TextInputWithTokens.d.ts +1 -2
  66. package/lib/ThemeProvider.d.ts +0 -1
  67. package/lib/ThemeProvider.js +4 -17
  68. package/lib/Timeline.js +4 -4
  69. package/lib/Token/AvatarToken.d.ts +1 -1
  70. package/lib/Token/AvatarToken.js +1 -1
  71. package/lib/Token/IssueLabelToken.d.ts +1 -1
  72. package/lib/Token/Token.d.ts +1 -1
  73. package/lib/Token/TokenBase.js +1 -1
  74. package/lib/Tooltip.js +1 -1
  75. package/lib/UnderlineNav.js +2 -2
  76. package/lib/hooks/index.d.ts +0 -1
  77. package/lib/hooks/index.js +1 -9
  78. package/lib/index.d.ts +0 -2
  79. package/lib/index.js +0 -8
  80. package/lib-esm/ActionList/Header.js +1 -1
  81. package/lib-esm/ActionList/Item.js +10 -10
  82. package/lib-esm/ActionList/List.js +1 -1
  83. package/lib-esm/ActionList2/Item.js +7 -5
  84. package/lib-esm/ActionList2/List.js +3 -3
  85. package/lib-esm/ActionList2/{ActionListContainerContext.d.ts → MenuContext.d.ts} +3 -3
  86. package/lib-esm/ActionList2/{ActionListContainerContext.js → MenuContext.js} +1 -1
  87. package/lib-esm/ActionList2/Selection.js +4 -4
  88. package/lib-esm/ActionMenu2.d.ts +12 -19
  89. package/lib-esm/ActionMenu2.js +27 -60
  90. package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -2
  91. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -2
  92. package/lib-esm/BaseStyles.js +20 -2
  93. package/lib-esm/BorderBox.js +1 -1
  94. package/lib-esm/Box.js +1 -1
  95. package/lib-esm/BranchName.js +1 -1
  96. package/lib-esm/Breadcrumbs.js +3 -3
  97. package/lib-esm/Button/Button.d.ts +2 -2
  98. package/lib-esm/Button/Button.js +1 -1
  99. package/lib-esm/Button/ButtonClose.d.ts +2 -2
  100. package/lib-esm/Button/ButtonDanger.d.ts +2 -2
  101. package/lib-esm/Button/ButtonGroup.js +1 -1
  102. package/lib-esm/Button/ButtonInvisible.d.ts +2 -2
  103. package/lib-esm/Button/ButtonOutline.d.ts +2 -2
  104. package/lib-esm/Button/ButtonPrimary.d.ts +2 -2
  105. package/lib-esm/Checkbox.d.ts +1 -1
  106. package/lib-esm/Checkbox.js +1 -1
  107. package/lib-esm/CircleOcticon.d.ts +35 -35
  108. package/lib-esm/Details.js +1 -1
  109. package/lib-esm/Dialog.d.ts +37 -37
  110. package/lib-esm/Dropdown.d.ts +6 -6
  111. package/lib-esm/DropdownMenu/DropdownButton.d.ts +3 -6
  112. package/lib-esm/FilterList.d.ts +1 -1
  113. package/lib-esm/FilteredActionList/FilteredActionList.js +1 -1
  114. package/lib-esm/Flex.js +1 -1
  115. package/lib-esm/LabelGroup.js +1 -1
  116. package/lib-esm/NewButton/button.d.ts +11 -2
  117. package/lib-esm/NewButton/button.js +275 -4
  118. package/lib-esm/NewButton/index.d.ts +11 -6
  119. package/lib-esm/NewButton/index.js +1 -4
  120. package/lib-esm/NewButton/types.d.ts +8 -28
  121. package/lib-esm/NewButton/types.js +1 -6
  122. package/lib-esm/Overlay.js +1 -1
  123. package/lib-esm/Pagination/Pagination.js +2 -2
  124. package/lib-esm/Position.d.ts +4 -4
  125. package/lib-esm/Position.js +1 -1
  126. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -11
  127. package/lib-esm/SelectMenu/SelectMenu.js +1 -1
  128. package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
  129. package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
  130. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  131. package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
  132. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  133. package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
  134. package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
  135. package/lib-esm/SelectMenu/SelectMenuTabs.js +1 -1
  136. package/lib-esm/StateLabel.js +1 -1
  137. package/lib-esm/StyledOcticon.js +1 -1
  138. package/lib-esm/SubNav.js +3 -3
  139. package/lib-esm/TextInputWithTokens.d.ts +1 -2
  140. package/lib-esm/ThemeProvider.d.ts +0 -1
  141. package/lib-esm/ThemeProvider.js +4 -17
  142. package/lib-esm/Timeline.js +4 -4
  143. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  144. package/lib-esm/Token/AvatarToken.js +1 -1
  145. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  146. package/lib-esm/Token/Token.d.ts +1 -1
  147. package/lib-esm/Token/TokenBase.js +1 -1
  148. package/lib-esm/Tooltip.js +1 -1
  149. package/lib-esm/UnderlineNav.js +2 -2
  150. package/lib-esm/hooks/index.d.ts +0 -1
  151. package/lib-esm/hooks/index.js +1 -2
  152. package/lib-esm/index.d.ts +0 -2
  153. package/lib-esm/index.js +0 -1
  154. package/package.json +8 -14
  155. package/lib/NewButton/button-base.d.ts +0 -6
  156. package/lib/NewButton/button-base.js +0 -69
  157. package/lib/NewButton/button-link.d.ts +0 -27
  158. package/lib/NewButton/button-link.js +0 -31
  159. package/lib/NewButton/icon-button.d.ts +0 -4
  160. package/lib/NewButton/icon-button.js +0 -62
  161. package/lib/NewButton/styles.d.ts +0 -202
  162. package/lib/NewButton/styles.js +0 -248
  163. package/lib/Radio.d.ts +0 -38
  164. package/lib/Radio.js +0 -55
  165. package/lib-esm/NewButton/button-base.d.ts +0 -6
  166. package/lib-esm/NewButton/button-base.js +0 -47
  167. package/lib-esm/NewButton/button-link.d.ts +0 -27
  168. package/lib-esm/NewButton/button-link.js +0 -15
  169. package/lib-esm/NewButton/icon-button.d.ts +0 -4
  170. package/lib-esm/NewButton/icon-button.js +0 -39
  171. package/lib-esm/NewButton/styles.d.ts +0 -202
  172. package/lib-esm/NewButton/styles.js +0 -229
  173. package/lib-esm/Radio.d.ts +0 -38
  174. package/lib-esm/Radio.js +0 -40
@@ -1,15 +0,0 @@
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,4 +0,0 @@
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;
@@ -1,39 +0,0 @@
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
- import { useSSRSafeId } from '@react-aria/ssr';
10
- const IconButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
11
- const {
12
- variant = 'default',
13
- size = 'medium',
14
- sx: sxProp = {},
15
- icon: Icon,
16
- iconLabel
17
- } = props;
18
- const iconLabelId = useSSRSafeId();
19
- const {
20
- theme
21
- } = useTheme();
22
- const styles = { ...getBaseStyles(theme)
23
- };
24
- const sxStyles = merge.all([styles, getSizeStyles(size, variant, true), getVariantStyles(variant, theme), sxProp]);
25
- return /*#__PURE__*/React.createElement(StyledButton, _extends({
26
- "aria-labelledBy": iconLabelId,
27
- sx: sxStyles,
28
- ref: forwardedRef
29
- }, props), /*#__PURE__*/React.createElement("span", {
30
- id: iconLabelId,
31
- hidden: true
32
- }, iconLabel), /*#__PURE__*/React.createElement(Box, {
33
- as: "span",
34
- sx: {
35
- display: 'inline-block'
36
- }
37
- }, /*#__PURE__*/React.createElement(Icon, null)));
38
- });
39
- export default IconButton;
@@ -1,202 +0,0 @@
1
- import { VariantType } from './types';
2
- import { Theme } from '../ThemeProvider';
3
- export declare const TEXT_ROW_HEIGHT = "20px";
4
- export declare const getVariantStyles: (variant?: VariantType, theme?: Theme | undefined) => {
5
- color: string;
6
- backgroundColor: string;
7
- boxShadow: string;
8
- '&:hover:not([disabled])': {
9
- backgroundColor: string;
10
- };
11
- '&:focus:not([disabled])': {
12
- boxShadow: string;
13
- };
14
- '&:active:not([disabled])': {
15
- backgroundColor: string;
16
- boxShadow: string;
17
- };
18
- '&:disabled': {
19
- color: string;
20
- backgroundColor: string;
21
- };
22
- } | {
23
- color: string;
24
- backgroundColor: string;
25
- borderColor: string;
26
- boxShadow: string;
27
- '&:hover:not([disabled])': {
28
- color: string;
29
- backgroundColor: string;
30
- };
31
- '&:focus:not([disabled])': {
32
- boxShadow: string;
33
- };
34
- '&:active:not([disabled])': {
35
- backgroundColor: string;
36
- boxShadow: string;
37
- };
38
- '&:disabled': {
39
- color: string;
40
- backgroundColor: string;
41
- };
42
- '[data-component="ButtonCounter"]': {
43
- backgroundColor: string;
44
- color: string;
45
- };
46
- } | {
47
- color: string;
48
- backgroundColor: string;
49
- boxShadow: string;
50
- '&:hover:not([disabled])': {
51
- color: string;
52
- backgroundColor: string;
53
- borderColor: string;
54
- boxShadow: string;
55
- '[data-component="ButtonCounter"]': {
56
- backgroundColor: string;
57
- color: string;
58
- };
59
- };
60
- '&:focus:not([disabled])': {
61
- borderColor: string;
62
- boxShadow: string;
63
- };
64
- '&:active:not([disabled])': {
65
- color: string;
66
- backgroundColor: string;
67
- boxShadow: string;
68
- borderColor: string;
69
- };
70
- '&:disabled': {
71
- color: string;
72
- backgroundColor: string;
73
- borderColor: string;
74
- '[data-component="ButtonCounter"]': {
75
- backgroundColor: string;
76
- };
77
- };
78
- '[data-component="ButtonCounter"]': {
79
- color: string;
80
- backgroundColor: string;
81
- };
82
- } | {
83
- color: string;
84
- backgroundColor: string;
85
- border: string;
86
- boxShadow: string;
87
- '&:hover:not([disabled])': {
88
- backgroundColor: string;
89
- };
90
- '&:focus:not([disabled])': {
91
- boxShadow: string;
92
- };
93
- '&:active:not([disabled])': {
94
- backgroundColor: string;
95
- };
96
- '&:disabled': {
97
- color: string;
98
- };
99
- } | {
100
- color: string;
101
- boxShadow: string;
102
- '&:hover:not([disabled])': {
103
- color: string;
104
- backgroundColor: string;
105
- borderColor: string;
106
- boxShadow: string;
107
- '[data-component="ButtonCounter"]': {
108
- backgroundColor: string;
109
- color: string;
110
- };
111
- };
112
- '&:focus:not([disabled])': {
113
- borderColor: string;
114
- boxShadow: string;
115
- };
116
- '&:active:not([disabled])': {
117
- color: string;
118
- backgroundColor: string;
119
- boxShadow: string;
120
- borderColor: string;
121
- };
122
- '&:disabled': {
123
- color: string;
124
- backgroundColor: string;
125
- borderColor: string;
126
- '[data-component="ButtonCounter"]': {
127
- backgroundColor: string;
128
- };
129
- };
130
- '[data-component="ButtonCounter"]': {
131
- backgroundColor: string;
132
- color: string;
133
- };
134
- };
135
- export declare const getSizeStyles: (size: string | undefined, variant: VariantType | undefined, iconOnly: boolean) => {
136
- paddingY: string;
137
- paddingX: string;
138
- fontSize: number;
139
- '[data-component="ButtonCounter"]': {
140
- fontSize: number;
141
- };
142
- };
143
- export declare const getBaseStyles: (theme?: Theme | undefined) => {
144
- borderRadius: string;
145
- border: string;
146
- borderColor: any;
147
- fontWeight: string;
148
- lineHeight: string;
149
- whiteSpace: string;
150
- verticalAlign: string;
151
- cursor: string;
152
- appearance: string;
153
- userSelect: string;
154
- textDecoration: string;
155
- textAlign: string;
156
- '&:focus': {
157
- outline: string;
158
- };
159
- '&:disabled': {
160
- cursor: string;
161
- };
162
- '&:disabled svg': {
163
- opacity: string;
164
- };
165
- };
166
- export declare const getButtonStyles: (theme?: Theme | undefined) => {
167
- display: string;
168
- gridTemplateAreas: string;
169
- '& > :not(:last-child)': {
170
- mr: string;
171
- };
172
- '[data-component="leadingIcon"]': {
173
- gridArea: string;
174
- };
175
- '[data-component="text"]': {
176
- gridArea: string;
177
- };
178
- '[data-component="trailingIcon"]': {
179
- gridArea: string;
180
- };
181
- borderRadius: string;
182
- border: string;
183
- borderColor: any;
184
- fontWeight: string;
185
- lineHeight: string;
186
- whiteSpace: string;
187
- verticalAlign: string;
188
- cursor: string;
189
- appearance: string;
190
- userSelect: string;
191
- textDecoration: string;
192
- textAlign: string;
193
- '&:focus': {
194
- outline: string;
195
- };
196
- '&:disabled': {
197
- cursor: string;
198
- };
199
- '&:disabled svg': {
200
- opacity: string;
201
- };
202
- };
@@ -1,229 +0,0 @@
1
- export const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
2
-
3
- export const getVariantStyles = (variant = 'default', theme) => {
4
- const style = {
5
- default: {
6
- color: 'btn.text',
7
- backgroundColor: 'btn.bg',
8
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
9
- '&:hover:not([disabled])': {
10
- backgroundColor: 'btn.hoverBg'
11
- },
12
- // focus must come before :active so that the active box shadow overrides
13
- '&:focus:not([disabled])': {
14
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
15
- },
16
- '&:active:not([disabled])': {
17
- backgroundColor: 'btn.selectedBg',
18
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
19
- },
20
- '&:disabled': {
21
- color: 'primer.fg.disabled',
22
- backgroundColor: 'btn.disabledBg'
23
- }
24
- },
25
- primary: {
26
- color: 'btn.primary.text',
27
- backgroundColor: 'btn.primary.bg',
28
- borderColor: 'border.subtle',
29
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
30
- '&:hover:not([disabled])': {
31
- color: 'btn.primary.hoverText',
32
- backgroundColor: 'btn.primary.hoverBg'
33
- },
34
- // focus must come before :active so that the active box shadow overrides
35
- '&:focus:not([disabled])': {
36
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
37
- },
38
- '&:active:not([disabled])': {
39
- backgroundColor: 'btn.primary.selectedBg',
40
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
41
- },
42
- '&:disabled': {
43
- color: 'btn.primary.disabledText',
44
- backgroundColor: 'btn.primary.disabledBg'
45
- },
46
- '[data-component="ButtonCounter"]': {
47
- backgroundColor: 'btn.primary.counterBg',
48
- color: 'btn.primary.text'
49
- }
50
- },
51
- danger: {
52
- color: 'btn.danger.text',
53
- backgroundColor: 'btn.bg',
54
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
55
- '&:hover:not([disabled])': {
56
- color: 'btn.danger.hoverText',
57
- backgroundColor: 'btn.danger.hoverBg',
58
- borderColor: 'btn.danger.hoverBorder',
59
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
60
- '[data-component="ButtonCounter"]': {
61
- backgroundColor: 'btn.danger.hoverCounterBg',
62
- color: 'btn.danger.hoverText'
63
- }
64
- },
65
- // focus must come before :active so that the active box shadow overrides
66
- '&:focus:not([disabled])': {
67
- borderColor: 'btn.danger.focusBorder',
68
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
69
- },
70
- '&:active:not([disabled])': {
71
- color: 'btn.danger.selectedText',
72
- backgroundColor: 'btn.danger.selectedBg',
73
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
74
- borderColor: 'btn.danger.selectedBorder'
75
- },
76
- '&:disabled': {
77
- color: 'btn.danger.disabledText',
78
- backgroundColor: 'btn.danger.disabledBg',
79
- borderColor: 'btn.danger.disabledBorder',
80
- '[data-component="ButtonCounter"]': {
81
- backgroundColor: 'btn.danger.disabledCounterBg'
82
- }
83
- },
84
- '[data-component="ButtonCounter"]': {
85
- color: 'btn.danger.text',
86
- backgroundColor: 'btn.danger.counterBg'
87
- }
88
- },
89
- invisible: {
90
- color: 'accent.fg',
91
- backgroundColor: 'transparent',
92
- border: '0',
93
- boxShadow: 'none',
94
- '&:hover:not([disabled])': {
95
- backgroundColor: 'btn.hoverBg'
96
- },
97
- // focus must come before :active so that the active box shadow overrides
98
- '&:focus:not([disabled])': {
99
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
100
- },
101
- '&:active:not([disabled])': {
102
- backgroundColor: 'btn.selectedBg'
103
- },
104
- '&:disabled': {
105
- color: 'primer.fg.disabled'
106
- }
107
- },
108
- outline: {
109
- color: 'btn.outline.text',
110
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
111
- '&:hover:not([disabled])': {
112
- color: 'btn.outline.hoverText',
113
- backgroundColor: 'btn.outline.hoverBg',
114
- borderColor: 'outline.hoverBorder',
115
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
116
- '[data-component="ButtonCounter"]': {
117
- backgroundColor: 'btn.outline.hoverCounterBg',
118
- color: 'btn.outline.hoverText'
119
- }
120
- },
121
- // focus must come before :active so that the active box shadow overrides
122
- '&:focus:not([disabled])': {
123
- borderColor: 'btn.outline.focusBorder',
124
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
125
- },
126
- '&:active:not([disabled])': {
127
- color: 'btn.outline.selectedText',
128
- backgroundColor: 'btn.outline.selectedBg',
129
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
130
- borderColor: 'btn.outline.selectedBorder'
131
- },
132
- '&:disabled': {
133
- color: 'btn.outline.disabledText',
134
- backgroundColor: 'btn.outline.disabledBg',
135
- borderColor: 'btn.border',
136
- '[data-component="ButtonCounter"]': {
137
- backgroundColor: 'btn.outline.disabledCounterBg'
138
- }
139
- },
140
- '[data-component="ButtonCounter"]': {
141
- backgroundColor: 'btn.outline.counterBg',
142
- color: 'btn.outline.text'
143
- }
144
- }
145
- };
146
- return style[variant];
147
- };
148
- export const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
149
- let paddingY, paddingX, fontSize;
150
-
151
- switch (size) {
152
- case 'small':
153
- paddingY = 3;
154
- paddingX = 12;
155
- fontSize = 0;
156
- break;
157
-
158
- case 'large':
159
- paddingY = 9;
160
- paddingX = 20;
161
- fontSize = 2;
162
- break;
163
-
164
- case 'medium':
165
- default:
166
- paddingY = 5;
167
- paddingX = 16;
168
- fontSize = 1;
169
- }
170
-
171
- if (iconOnly) {
172
- paddingX = paddingY + 2;
173
- }
174
-
175
- if (variant === 'invisible') {
176
- paddingY = paddingY + 1;
177
- }
178
-
179
- return {
180
- paddingY: `${paddingY}px`,
181
- paddingX: `${paddingX}px`,
182
- fontSize,
183
- '[data-component="ButtonCounter"]': {
184
- fontSize
185
- }
186
- };
187
- };
188
- export const getBaseStyles = theme => ({
189
- borderRadius: '2',
190
- border: '1px solid',
191
- borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
192
- fontWeight: 'bold',
193
- lineHeight: TEXT_ROW_HEIGHT,
194
- whiteSpace: 'nowrap',
195
- verticalAlign: 'middle',
196
- cursor: 'pointer',
197
- appearance: 'none',
198
- userSelect: 'none',
199
- textDecoration: 'none',
200
- textAlign: 'center',
201
- '&:focus': {
202
- outline: 'none'
203
- },
204
- '&:disabled': {
205
- cursor: 'default'
206
- },
207
- '&:disabled svg': {
208
- opacity: '0.6'
209
- }
210
- });
211
- export const getButtonStyles = theme => {
212
- const styles = { ...getBaseStyles(theme),
213
- display: 'grid',
214
- gridTemplateAreas: '"leadingIcon text trailingIcon"',
215
- '& > :not(:last-child)': {
216
- mr: '2'
217
- },
218
- '[data-component="leadingIcon"]': {
219
- gridArea: 'leadingIcon'
220
- },
221
- '[data-component="text"]': {
222
- gridArea: 'text'
223
- },
224
- '[data-component="trailingIcon"]': {
225
- gridArea: 'trailingIcon'
226
- }
227
- };
228
- return styles;
229
- };
@@ -1,38 +0,0 @@
1
- import React, { InputHTMLAttributes } from 'react';
2
- import { SxProp } from './sx';
3
- export declare type RadioProps = {
4
- /**
5
- * A unique value that is never shown to the user.
6
- * Used during form submission and to identify which radio button in a group is selected
7
- */
8
- value: string;
9
- /**
10
- * Name attribute of the input element. Required for grouping radio inputs
11
- */
12
- name: string;
13
- /**
14
- * Apply inactive visual appearance to the radio button
15
- */
16
- disabled?: boolean;
17
- /**
18
- * Indicates whether the radio button is selected
19
- */
20
- checked?: boolean;
21
- /**
22
- * Forward a ref to the underlying input element
23
- */
24
- ref?: React.RefObject<HTMLInputElement>;
25
- /**
26
- * Indicates whether the radio button must be checked before the form can be submitted
27
- */
28
- required?: boolean;
29
- /**
30
- * Indicates whether the radio button validation state is non-standard
31
- */
32
- validationStatus?: 'error' | 'success';
33
- } & InputHTMLAttributes<HTMLInputElement> & SxProp;
34
- /**
35
- * An accessible, native radio component for selecting one option from a list.
36
- */
37
- declare const Radio: React.ForwardRefExoticComponent<Pick<RadioProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "validationStatus"> & React.RefAttributes<HTMLInputElement>>;
38
- export default Radio;
package/lib-esm/Radio.js DELETED
@@ -1,40 +0,0 @@
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 styled from 'styled-components';
4
- import React from 'react';
5
- import sx from './sx';
6
- const StyledRadio = styled.input.withConfig({
7
- displayName: "Radio__StyledRadio",
8
- componentId: "sc-1ak1fjg-0"
9
- })(["cursor:pointer;", " ", ""], props => props.disabled && `cursor: not-allowed;`, sx);
10
- /**
11
- * An accessible, native radio component for selecting one option from a list.
12
- */
13
-
14
- const Radio = /*#__PURE__*/React.forwardRef(({
15
- checked,
16
- disabled,
17
- sx: sxProp,
18
- required,
19
- validationStatus,
20
- value,
21
- name,
22
- ...rest
23
- }, ref) => {
24
- return /*#__PURE__*/React.createElement(StyledRadio, _extends({
25
- type: "radio",
26
- value: value,
27
- name: name,
28
- ref: ref,
29
- disabled: disabled,
30
- "aria-disabled": disabled ? 'true' : 'false',
31
- checked: checked,
32
- "aria-checked": checked ? 'true' : 'false',
33
- required: required,
34
- "aria-required": required ? 'true' : 'false',
35
- "aria-invalid": validationStatus === 'error' ? 'true' : 'false',
36
- sx: sxProp
37
- }, rest));
38
- });
39
- Radio.displayName = 'Radio';
40
- export default Radio;