@zendeskgarden/react-buttons 9.0.0-next.7 → 9.0.0-next.9

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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
9
+ import { StyledButton, getHeight } from './StyledButton.js';
10
+ import { StyledIcon } from './StyledIcon.js';
11
+
12
+ const COMPONENT_ID = 'buttons.icon_button';
13
+ const iconColorStyles = props => {
14
+ const shade = 600;
15
+ const baseColor = getColorV8('neutralHue', shade, props.theme);
16
+ const hoverColor = getColorV8('neutralHue', shade + 100, props.theme);
17
+ const activeColor = getColorV8('neutralHue', shade + 200, props.theme);
18
+ return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
19
+ };
20
+ const iconButtonStyles = props => {
21
+ const width = getHeight(props);
22
+ return css(["border:", ";padding:0;width:", ";min-width:", ";", ";&:disabled{background-color:", ";}"], props.isBasic && 'none', width, width, props.isBasic && !(props.isPrimary || props.isDanger || props.disabled) && iconColorStyles(props), !props.isPrimary && 'transparent');
23
+ };
24
+ const iconStyles = props => {
25
+ const size = props.theme.iconSizes.md;
26
+ return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
27
+ };
28
+ const StyledIconButton = styled(StyledButton).attrs({
29
+ 'data-garden-id': COMPONENT_ID,
30
+ 'data-garden-version': '9.0.0-next.9'
31
+ }).withConfig({
32
+ displayName: "StyledIconButton",
33
+ componentId: "sc-1t0ughp-0"
34
+ })(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
35
+ StyledIconButton.defaultProps = {
36
+ theme: DEFAULT_THEME
37
+ };
38
+
39
+ export { StyledIconButton };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'buttons.button_group_view';
11
+ const StyledSplitButton = styled.div.attrs({
12
+ 'data-garden-id': COMPONENT_ID,
13
+ 'data-garden-version': '9.0.0-next.9'
14
+ }).withConfig({
15
+ displayName: "StyledSplitButton",
16
+ componentId: "sc-1u4v04v-0"
17
+ })(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
18
+ StyledSplitButton.defaultProps = {
19
+ theme: DEFAULT_THEME
20
+ };
21
+
22
+ export { StyledSplitButton };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ const SIZE = ['small', 'medium', 'large'];
8
+
9
+ export { SIZE };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { createContext, useContext } from 'react';
8
+
9
+ const SplitButtonContext = createContext(undefined);
10
+ const useSplitButtonContext = () => {
11
+ return useContext(SplitButtonContext);
12
+ };
13
+
14
+ export { SplitButtonContext, useSplitButtonContext };
package/dist/index.cjs.js CHANGED
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Copyright Zendesk, Inc.
3
- *
4
- * Use of this source code is governed under the Apache License, Version 2.0
5
- * found at http://www.apache.org/licenses/LICENSE-2.0.
6
- */
7
-
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
8
7
  'use strict';
9
8
 
10
9
  var React = require('react');
@@ -37,27 +36,12 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
36
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
38
37
  var styled__default = /*#__PURE__*/_interopDefault(styled);
39
38
 
40
- function _extends$2() {
41
- _extends$2 = Object.assign ? Object.assign.bind() : function (target) {
42
- for (var i = 1; i < arguments.length; i++) {
43
- var source = arguments[i];
44
- for (var key in source) {
45
- if (Object.prototype.hasOwnProperty.call(source, key)) {
46
- target[key] = source[key];
47
- }
48
- }
49
- }
50
- return target;
51
- };
52
- return _extends$2.apply(this, arguments);
53
- }
54
-
55
39
  const SIZE = ['small', 'medium', 'large'];
56
40
 
57
41
  const COMPONENT_ID$5 = 'buttons.button_group_view';
58
42
  const StyledSplitButton = styled__default.default.div.attrs({
59
43
  'data-garden-id': COMPONENT_ID$5,
60
- 'data-garden-version': '9.0.0-next.7'
44
+ 'data-garden-version': '9.0.0-next.9'
61
45
  }).withConfig({
62
46
  displayName: "StyledSplitButton",
63
47
  componentId: "sc-1u4v04v-0"
@@ -69,28 +53,20 @@ StyledSplitButton.defaultProps = {
69
53
  const COMPONENT_ID$4 = 'buttons.icon';
70
54
  const sizeStyles$1 = props => {
71
55
  let marginProperty;
72
- if (props.position === 'start') {
56
+ if (props.$position === 'start') {
73
57
  marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
74
- } else if (props.position === 'end') {
58
+ } else if (props.$position === 'end') {
75
59
  marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
76
60
  }
77
61
  return marginProperty && styled.css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
78
62
  };
79
- const StyledIcon = styled__default.default(_ref => {
80
- let {
81
- children,
82
- isRotated,
83
- theme,
84
- ...props
85
- } = _ref;
86
- return React__namespace.default.cloneElement(React.Children.only(children), props);
87
- }).attrs({
63
+ const StyledIcon = styled__default.default(reactTheming.StyledBaseIcon).attrs({
88
64
  'data-garden-id': COMPONENT_ID$4,
89
- 'data-garden-version': '9.0.0-next.7'
65
+ 'data-garden-version': '9.0.0-next.9'
90
66
  }).withConfig({
91
67
  displayName: "StyledIcon",
92
68
  componentId: "sc-19meqgg-0"
93
- })(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => props.isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, props => sizeStyles$1(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
69
+ })(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => props.$isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, props => sizeStyles$1(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
94
70
  StyledIcon.defaultProps = {
95
71
  theme: reactTheming.DEFAULT_THEME
96
72
  };
@@ -188,8 +164,12 @@ const groupStyles = props => {
188
164
  const focusBoxShadow = isBasic && !isPrimary && reactTheming.getFocusBoxShadow({
189
165
  theme,
190
166
  inset: focusInset,
191
- spacerHue: focusColor,
192
- hue: 'transparent'
167
+ spacerColor: {
168
+ hue: focusColor
169
+ },
170
+ color: {
171
+ hue: 'transparent'
172
+ }
193
173
  });
194
174
  return styled.css(["position:relative;transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,margin-", " 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;border:", " ", ";", "{border-color:", ";box-shadow:", ";}&:hover,&:active,", "{z-index:1;}&:disabled{z-index:-1;background-color:", ";}&:not(:first-of-type){margin-", ":", ";}&:not(:first-of-type):disabled{margin-", ":", ";}&:not(:first-of-type):not(:last-of-type){border-radius:0;}&:first-of-type:not(:last-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:last-of-type:not(:first-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:first-of-type:not(:last-of-type) ", "{margin-", ":", ";}&:last-of-type:not(:first-of-type) ", "{margin-", ":", ";}"], startPosition, borders.sm, borderColor, reactTheming.SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, reactTheming.SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
195
175
  };
@@ -223,7 +203,7 @@ const sizeStyles = props => {
223
203
  };
224
204
  const StyledButton = styled__default.default.button.attrs(props => ({
225
205
  'data-garden-id': COMPONENT_ID$3,
226
- 'data-garden-version': '9.0.0-next.7',
206
+ 'data-garden-version': '9.0.0-next.9',
227
207
  type: props.type || 'button'
228
208
  })).withConfig({
229
209
  displayName: "StyledButton",
@@ -236,7 +216,7 @@ StyledButton.defaultProps = {
236
216
  const COMPONENT_ID$2 = 'buttons.anchor';
237
217
  const StyledAnchor = styled__default.default(StyledButton).attrs(props => ({
238
218
  'data-garden-id': COMPONENT_ID$2,
239
- 'data-garden-version': '9.0.0-next.7',
219
+ 'data-garden-version': '9.0.0-next.9',
240
220
  as: 'a',
241
221
  dir: props.theme.rtl ? 'rtl' : undefined,
242
222
  isLink: true,
@@ -270,7 +250,7 @@ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
270
250
  const COMPONENT_ID$1 = 'buttons.external_icon';
271
251
  const StyledExternalIcon = styled__default.default(SvgNewWindowStroke).attrs({
272
252
  'data-garden-id': COMPONENT_ID$1,
273
- 'data-garden-version': '9.0.0-next.7'
253
+ 'data-garden-version': '9.0.0-next.9'
274
254
  }).withConfig({
275
255
  displayName: "StyledExternalIcon",
276
256
  componentId: "sc-16oz07e-0"
@@ -297,7 +277,7 @@ const iconStyles = props => {
297
277
  };
298
278
  const StyledIconButton = styled__default.default(StyledButton).attrs({
299
279
  'data-garden-id': COMPONENT_ID,
300
- 'data-garden-version': '9.0.0-next.7'
280
+ 'data-garden-version': '9.0.0-next.9'
301
281
  }).withConfig({
302
282
  displayName: "StyledIconButton",
303
283
  componentId: "sc-1t0ughp-0"
@@ -311,15 +291,29 @@ const useSplitButtonContext = () => {
311
291
  return React.useContext(SplitButtonContext);
312
292
  };
313
293
 
314
- const StartIconComponent = props => React__namespace.default.createElement(StyledIcon, _extends$2({
315
- position: "start"
316
- }, props));
294
+ const StartIconComponent = _ref => {
295
+ let {
296
+ isRotated,
297
+ ...props
298
+ } = _ref;
299
+ return React__namespace.default.createElement(StyledIcon, Object.assign({
300
+ $position: "start",
301
+ $isRotated: isRotated
302
+ }, props));
303
+ };
317
304
  StartIconComponent.displayName = 'Button.StartIcon';
318
305
  const StartIcon = StartIconComponent;
319
306
 
320
- const EndIconComponent = props => React__namespace.default.createElement(StyledIcon, _extends$2({
321
- position: "end"
322
- }, props));
307
+ const EndIconComponent = _ref => {
308
+ let {
309
+ isRotated,
310
+ ...props
311
+ } = _ref;
312
+ return React__namespace.default.createElement(StyledIcon, Object.assign({
313
+ $position: "end",
314
+ $isRotated: isRotated
315
+ }, props));
316
+ };
323
317
  EndIconComponent.displayName = 'Button.EndIcon';
324
318
  const EndIcon = EndIconComponent;
325
319
 
@@ -329,7 +323,7 @@ const ButtonComponent = React.forwardRef((props, ref) => {
329
323
  ...props,
330
324
  focusInset: props.focusInset || splitButtonContext
331
325
  };
332
- return React__namespace.default.createElement(StyledButton, _extends$2({}, computedProps, {
326
+ return React__namespace.default.createElement(StyledButton, Object.assign({}, computedProps, {
333
327
  ref: ref
334
328
  }));
335
329
  });
@@ -373,7 +367,7 @@ const Anchor = React.forwardRef((_ref, ref) => {
373
367
  noIconLabel: 'true'
374
368
  };
375
369
  const iconAriaLabel = reactTheming.useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
376
- return React__namespace.default.createElement(StyledAnchor, _extends$2({
370
+ return React__namespace.default.createElement(StyledAnchor, Object.assign({
377
371
  ref: ref
378
372
  }, anchorProps), children, isExternal &&
379
373
  React__namespace.default.createElement(StyledExternalIcon, {
@@ -396,12 +390,12 @@ const IconButton = React.forwardRef((_ref, ref) => {
396
390
  ...otherProps
397
391
  } = _ref;
398
392
  const focusInset = useSplitButtonContext();
399
- return React__namespace.default.createElement(StyledIconButton, _extends$2({
393
+ return React__namespace.default.createElement(StyledIconButton, Object.assign({
400
394
  ref: ref
401
395
  }, otherProps, {
402
396
  focusInset: otherProps.focusInset || focusInset
403
397
  }), React__namespace.default.createElement(StyledIcon, {
404
- isRotated: isRotated
398
+ $isRotated: isRotated
405
399
  }, children));
406
400
  });
407
401
  IconButton.displayName = 'IconButton';
@@ -441,7 +435,7 @@ const ChevronButton = React.forwardRef((_ref, ref) => {
441
435
  let {
442
436
  ...buttonProps
443
437
  } = _ref;
444
- return React__namespace.default.createElement(IconButton, _extends$2({
438
+ return React__namespace.default.createElement(IconButton, Object.assign({
445
439
  ref: ref
446
440
  }, buttonProps), React__namespace.default.createElement(SvgChevronDownStroke, null));
447
441
  });
@@ -460,7 +454,7 @@ const SplitButton = React.forwardRef((_ref, ref) => {
460
454
  } = _ref;
461
455
  return React__namespace.default.createElement(SplitButtonContext.Provider, {
462
456
  value: true
463
- }, React__namespace.default.createElement(StyledSplitButton, _extends$2({
457
+ }, React__namespace.default.createElement(StyledSplitButton, Object.assign({
464
458
  ref: ref
465
459
  }, other), children));
466
460
  });
@@ -471,7 +465,7 @@ const ToggleButton = React.forwardRef((_ref, ref) => {
471
465
  isPressed,
472
466
  ...otherProps
473
467
  } = _ref;
474
- return React__namespace.default.createElement(Button, _extends$2({
468
+ return React__namespace.default.createElement(Button, Object.assign({
475
469
  "aria-pressed": isPressed,
476
470
  ref: ref
477
471
  }, otherProps));
@@ -490,7 +484,7 @@ const ToggleIconButton = React.forwardRef((_ref, ref) => {
490
484
  isPressed,
491
485
  ...otherProps
492
486
  } = _ref;
493
- return React__namespace.default.createElement(IconButton, _extends$2({
487
+ return React__namespace.default.createElement(IconButton, Object.assign({
494
488
  "aria-pressed": isPressed,
495
489
  ref: ref
496
490
  }, otherProps));
@@ -10,6 +10,6 @@ import { IButtonIconProps } from '../../types';
10
10
  * @extends SVGAttributes<SVGElement>
11
11
  */
12
12
  export declare const EndIcon: {
13
- (props: IButtonIconProps): React.JSX.Element;
13
+ ({ isRotated, ...props }: IButtonIconProps): React.JSX.Element;
14
14
  displayName: string;
15
15
  };
@@ -10,6 +10,6 @@ import { IButtonIconProps } from '../../types';
10
10
  * @extends SVGAttributes<SVGElement>
11
11
  */
12
12
  export declare const StartIcon: {
13
- (props: IButtonIconProps): React.JSX.Element;
13
+ ({ isRotated, ...props }: IButtonIconProps): React.JSX.Element;
14
14
  displayName: string;
15
15
  };
@@ -4,13 +4,13 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
+ /// <reference types="react" />
7
8
  import { DefaultTheme } from 'styled-components';
8
- import React from 'react';
9
9
  interface IStyledIconProps {
10
- isRotated: boolean;
11
- position?: 'start' | 'end';
10
+ $isRotated: boolean;
11
+ $position?: 'start' | 'end';
12
12
  }
13
- export declare const StyledIcon: import("styled-components").StyledComponent<({ children, isRotated, theme, ...props }: any) => React.DetailedReactHTMLElement<any, HTMLElement>, DefaultTheme, {
13
+ export declare const StyledIcon: import("styled-components").StyledComponent<({ children, theme, ...props }: any) => import("react").DetailedReactHTMLElement<any, HTMLElement>, DefaultTheme, {
14
14
  'data-garden-id': string;
15
15
  'data-garden-version': string;
16
16
  } & IStyledIconProps, "data-garden-id" | "data-garden-version">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-buttons",
3
- "version": "9.0.0-next.7",
3
+ "version": "9.0.0-next.9",
4
4
  "description": "Components relating to buttons in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/zendeskgarden/react-components/issues"
11
11
  },
12
12
  "main": "dist/index.cjs.js",
13
- "module": "dist/index.esm.js",
13
+ "module": "dist/esm/index.js",
14
14
  "files": [
15
15
  "dist"
16
16
  ],
@@ -27,13 +27,13 @@
27
27
  "react-merge-refs": "^2.0.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@zendeskgarden/react-theming": "^9.0.0",
30
+ "@zendeskgarden/react-theming": ">=9.0.0-next",
31
31
  "react": ">=16.8.0",
32
32
  "react-dom": ">=16.8.0",
33
33
  "styled-components": "^5.3.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@zendeskgarden/react-theming": "^9.0.0-next.7",
36
+ "@zendeskgarden/react-theming": "^9.0.0-next.9",
37
37
  "@zendeskgarden/svg-icons": "7.0.0"
38
38
  },
39
39
  "keywords": [
@@ -46,5 +46,5 @@
46
46
  "access": "public"
47
47
  },
48
48
  "zendeskgarden:src": "src/index.ts",
49
- "gitHead": "50a2b45b2e237a490a6d460818d33498b92479ec"
49
+ "gitHead": "771281b562d376a6aee04b0cd71dd888b3ae4a1d"
50
50
  }