@primer/components 0.0.0-202111885047 → 0.0.0-2021119104340

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.
@@ -1,16 +1,287 @@
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 ButtonBase from './button-base';
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);
5
201
  const Button = /*#__PURE__*/forwardRef(({
6
202
  children,
203
+ sx: sxProp = {},
7
204
  ...props
8
205
  }, 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]);
9
258
  return /*#__PURE__*/React.createElement(ButtonBase, _extends({
259
+ sx: sxStyles,
10
260
  ref: forwardedRef
11
- }, props, {
12
- as: "button"
13
- }), children);
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)));
14
284
  });
15
285
  Button.displayName = 'Button';
286
+ Object.assign(Button, {});
16
287
  export { Button };
@@ -1,9 +1,14 @@
1
1
  /// <reference types="react" />
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>> & {
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>> & {
7
13
  Counter: ({ children, sx: sxProp, ...props }: import("./button-counter").CounterProps) => JSX.Element;
8
14
  };
9
- export { IconButton, ButtonLink };
@@ -1,8 +1,5 @@
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';
5
3
  export const NewButton = Object.assign(Button, {
6
4
  Counter
7
- });
8
- export { IconButton, ButtonLink };
5
+ });
@@ -1,11 +1,9 @@
1
- import React, { HTMLAttributes, ComponentPropsWithRef } from 'react';
1
+ import React, { HTMLAttributes } from 'react';
2
2
  import { IconProps } from '@primer/octicons-react';
3
3
  import { SxProp } from '../sx';
4
- export declare const StyledButton: import("styled-components").StyledComponent<"button", any, SxProp, never>;
5
4
  export declare type VariantType = 'default' | 'primary' | 'invisible' | 'danger' | 'outline';
6
5
  export declare type Size = 'small' | 'medium' | 'large';
7
- declare type StyledButtonProps = ComponentPropsWithRef<typeof StyledButton>;
8
- export declare type ButtonBaseProps = {
6
+ export declare type ButtonProps = {
9
7
  /**
10
8
  * Determine's the styles on a button one of 'default' | 'primary' | 'invisible' | 'danger'
11
9
  */
@@ -15,11 +13,9 @@ export declare type ButtonBaseProps = {
15
13
  */
16
14
  size?: Size;
17
15
  /**
18
- * Items that are disabled can not be clicked, selected, or navigated through.
16
+ * This is to be used if it is an icon-only button. Will make text visually hidden
19
17
  */
20
- disabled?: boolean;
21
- } & SxProp & HTMLAttributes<HTMLButtonElement> & StyledButtonProps;
22
- export declare type ButtonProps = {
18
+ icon?: React.FunctionComponent<IconProps>;
23
19
  /**
24
20
  * The leading icon comes before button content
25
21
  */
@@ -28,25 +24,9 @@ export declare type ButtonProps = {
28
24
  * The trailing icon comes after button content
29
25
  */
30
26
  trailingIcon?: React.FunctionComponent<IconProps>;
31
- children: React.ReactNode;
32
- } & ButtonBaseProps;
33
- export declare type IconButtonProps = {
34
27
  /**
35
- * This is to be used if it is an icon-only button. Will make text visually hidden
28
+ * Items that are disabled can not be clicked, selected, or navigated through.
36
29
  */
37
- icon: React.FunctionComponent<IconProps>;
38
- iconLabel: string;
39
- } & ButtonBaseProps;
40
- export declare type LinkButtonProps = {
41
- underline?: boolean;
42
- download?: string;
43
- href?: string;
44
- hrefLang?: string;
45
- media?: string;
46
- ping?: string;
47
- rel?: string;
48
- target?: string;
49
- type?: string;
50
- referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>['referrerPolicy'];
51
- };
52
- export {};
30
+ disabled?: boolean;
31
+ children: React.ReactNode;
32
+ } & SxProp & HTMLAttributes<HTMLButtonElement>;
@@ -1,6 +1 @@
1
- import styled from 'styled-components';
2
- import sx from '../sx';
3
- export const StyledButton = styled.button.withConfig({
4
- displayName: "types__StyledButton",
5
- componentId: "sc-1sm8kx1-0"
6
- })(sx);
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-202111885047",
3
+ "version": "0.0.0-2021119104340",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -1,6 +0,0 @@
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;
@@ -1,69 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;
@@ -1,31 +0,0 @@
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 _buttonBase = _interopRequireDefault(require("./button-base"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- 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); }
15
-
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
-
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;
31
- exports.default = _default;
@@ -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,57 +0,0 @@
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;