@zendeskgarden/react-buttons 9.0.0-next.1 → 9.0.0-next.3

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.
package/README.md CHANGED
@@ -57,30 +57,3 @@ const MediaButton = ({ children, ...props }) => {
57
57
  );
58
58
  };
59
59
  ```
60
-
61
- ### Button group
62
-
63
- ```jsx
64
- import React, { useState } from 'react';
65
- import { ButtonGroup, Button } from '@zendeskgarden/react-buttons';
66
-
67
- const MyButtonGroup = ({ children, initialItem, ...props }) => {
68
- const [selectedItem, setSelectedItem] = useState(initialItem);
69
-
70
- return (
71
- <ButtonGroup
72
- selectedItem={selectedItem}
73
- onSelect={selectedItem => setSelectedItem(selectedItem)}
74
- {...props}
75
- >
76
- {children}
77
- </ButtonGroup>
78
- );
79
- };
80
-
81
- <MyButtonGroup initialKey="item-1">
82
- <Button key="item-1">Item 1</Button>
83
- <Button key="item-2">Item 2</Button>
84
- <Button key="item-3">Item 3</Button>
85
- </MyButtonGroup>;
86
- ```
package/dist/index.cjs.js CHANGED
@@ -9,12 +9,9 @@
9
9
 
10
10
  var React = require('react');
11
11
  var PropTypes = require('prop-types');
12
- var reactMergeRefs = require('react-merge-refs');
13
12
  var styled = require('styled-components');
14
13
  var reactTheming = require('@zendeskgarden/react-theming');
15
14
  var polished = require('polished');
16
- var containerSelection = require('@zendeskgarden/container-selection');
17
- var containerUtilities = require('@zendeskgarden/container-utilities');
18
15
 
19
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
17
 
@@ -58,14 +55,14 @@ function _extends$2() {
58
55
  const SIZE = ['small', 'medium', 'large'];
59
56
 
60
57
  const COMPONENT_ID$5 = 'buttons.button_group_view';
61
- const StyledButtonGroup = styled__default.default.div.attrs({
58
+ const StyledSplitButton = styled__default.default.div.attrs({
62
59
  'data-garden-id': COMPONENT_ID$5,
63
- 'data-garden-version': '9.0.0-next.1'
60
+ 'data-garden-version': '9.0.0-next.3'
64
61
  }).withConfig({
65
- displayName: "StyledButtonGroup",
66
- componentId: "sc-1fbpzef-0"
62
+ displayName: "StyledSplitButton",
63
+ componentId: "sc-1u4v04v-0"
67
64
  })(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props));
68
- StyledButtonGroup.defaultProps = {
65
+ StyledSplitButton.defaultProps = {
69
66
  theme: reactTheming.DEFAULT_THEME
70
67
  };
71
68
 
@@ -89,7 +86,7 @@ const StyledIcon = styled__default.default(_ref => {
89
86
  return React__namespace.default.cloneElement(React.Children.only(children), props);
90
87
  }).attrs({
91
88
  'data-garden-id': COMPONENT_ID$4,
92
- 'data-garden-version': '9.0.0-next.1'
89
+ 'data-garden-version': '9.0.0-next.3'
93
90
  }).withConfig({
94
91
  displayName: "StyledIcon",
95
92
  componentId: "sc-19meqgg-0"
@@ -119,7 +116,7 @@ const getHeight = props => {
119
116
  const colorStyles = props => {
120
117
  let retVal;
121
118
  let hue;
122
- if (props.disabled || props.isNeutral && (props.isPrimary || props.isSelected) && !props.isDanger) {
119
+ if (props.disabled || props.isNeutral && props.isPrimary && !props.isDanger) {
123
120
  hue = 'neutralHue';
124
121
  } else if (props.isDanger) {
125
122
  hue = 'dangerHue';
@@ -142,8 +139,8 @@ const colorStyles = props => {
142
139
  outlineColor: focusColor
143
140
  }
144
141
  }), hoverColor, activeColor, disabledForegroundColor);
145
- } else if (props.isPrimary || props.isSelected) {
146
- retVal = styled.css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], props.isPrimary && props.isSelected ? activeColor : baseColor, props.theme.palette.white, hoverColor, reactTheming.focusStyles({
142
+ } else if (props.isPrimary) {
143
+ retVal = styled.css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], baseColor, props.theme.palette.white, hoverColor, reactTheming.focusStyles({
147
144
  theme: props.theme,
148
145
  inset: props.focusInset,
149
146
  shadowWidth: props.focusInset ? 'sm' : 'md',
@@ -172,7 +169,6 @@ const groupStyles = props => {
172
169
  theme,
173
170
  isPrimary,
174
171
  isBasic,
175
- isSelected,
176
172
  isPill,
177
173
  focusInset
178
174
  } = props;
@@ -189,7 +185,7 @@ const groupStyles = props => {
189
185
  const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
190
186
  const borderColor = isBasic ? 'transparent' : 'revert';
191
187
  const focusColor = reactTheming.getColor('primaryHue', 600, theme);
192
- const focusBoxShadow = isBasic && !isSelected && !isPrimary && reactTheming.getFocusBoxShadow({
188
+ const focusBoxShadow = isBasic && !isPrimary && reactTheming.getFocusBoxShadow({
193
189
  theme,
194
190
  inset: focusInset,
195
191
  spacerHue: focusColor,
@@ -227,12 +223,12 @@ const sizeStyles = props => {
227
223
  };
228
224
  const StyledButton = styled__default.default.button.attrs(props => ({
229
225
  'data-garden-id': COMPONENT_ID$3,
230
- 'data-garden-version': '9.0.0-next.1',
226
+ 'data-garden-version': '9.0.0-next.3',
231
227
  type: props.type || 'button'
232
228
  })).withConfig({
233
229
  displayName: "StyledButton",
234
230
  componentId: "sc-qe3ace-0"
235
- })(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{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,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.isLink ? 'inline' : 'inline-flex', props => !props.isLink && 'center', props => !props.isLink && 'center', props => `${props.isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.isStretched ? '100%' : '', props => !props.isLink && 'nowrap', props => props.isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.isLink && 'none', props => sizeStyles(props), reactTheming.SELECTOR_FOCUS_VISIBLE, props => props.isLink ? 'underline' : 'none', props => props.isLink ? 'underline' : 'none', props => colorStyles(props), props => props.isLink && 'none', StyledIcon, props => iconStyles$1(props), StyledButtonGroup, props => groupStyles(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
231
+ })(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{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,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.isLink ? 'inline' : 'inline-flex', props => !props.isLink && 'center', props => !props.isLink && 'center', props => `${props.isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.isStretched ? '100%' : '', props => !props.isLink && 'nowrap', props => props.isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.isLink && 'none', props => sizeStyles(props), reactTheming.SELECTOR_FOCUS_VISIBLE, props => props.isLink ? 'underline' : 'none', props => props.isLink ? 'underline' : 'none', props => colorStyles(props), props => props.isLink && 'none', StyledIcon, props => iconStyles$1(props), StyledSplitButton, props => groupStyles(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
236
232
  StyledButton.defaultProps = {
237
233
  theme: reactTheming.DEFAULT_THEME
238
234
  };
@@ -240,7 +236,7 @@ StyledButton.defaultProps = {
240
236
  const COMPONENT_ID$2 = 'buttons.anchor';
241
237
  const StyledAnchor = styled__default.default(StyledButton).attrs(props => ({
242
238
  'data-garden-id': COMPONENT_ID$2,
243
- 'data-garden-version': '9.0.0-next.1',
239
+ 'data-garden-version': '9.0.0-next.3',
244
240
  as: 'a',
245
241
  dir: props.theme.rtl ? 'rtl' : undefined,
246
242
  isLink: true,
@@ -274,7 +270,7 @@ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
274
270
  const COMPONENT_ID$1 = 'buttons.external_icon';
275
271
  const StyledExternalIcon = styled__default.default(SvgNewWindowStroke).attrs({
276
272
  'data-garden-id': COMPONENT_ID$1,
277
- 'data-garden-version': '9.0.0-next.1'
273
+ 'data-garden-version': '9.0.0-next.3'
278
274
  }).withConfig({
279
275
  displayName: "StyledExternalIcon",
280
276
  componentId: "sc-16oz07e-0"
@@ -301,7 +297,7 @@ const iconStyles = props => {
301
297
  };
302
298
  const StyledIconButton = styled__default.default(StyledButton).attrs({
303
299
  'data-garden-id': COMPONENT_ID,
304
- 'data-garden-version': '9.0.0-next.1'
300
+ 'data-garden-version': '9.0.0-next.3'
305
301
  }).withConfig({
306
302
  displayName: "StyledIconButton",
307
303
  componentId: "sc-1t0ughp-0"
@@ -310,11 +306,6 @@ StyledIconButton.defaultProps = {
310
306
  theme: reactTheming.DEFAULT_THEME
311
307
  };
312
308
 
313
- const ButtonGroupContext = React.createContext(undefined);
314
- const useButtonGroupContext = () => {
315
- return React.useContext(ButtonGroupContext);
316
- };
317
-
318
309
  const SplitButtonContext = React.createContext(undefined);
319
310
  const useSplitButtonContext = () => {
320
311
  return React.useContext(SplitButtonContext);
@@ -333,26 +324,13 @@ EndIconComponent.displayName = 'Button.EndIcon';
333
324
  const EndIcon = EndIconComponent;
334
325
 
335
326
  const ButtonComponent = React.forwardRef((props, ref) => {
336
- const buttonGroupContext = useButtonGroupContext();
337
327
  const splitButtonContext = useSplitButtonContext();
338
- let computedRef = ref;
339
- let computedProps = {
328
+ const computedProps = {
340
329
  ...props,
341
- focusInset: props.focusInset || buttonGroupContext !== undefined || splitButtonContext
330
+ focusInset: props.focusInset || splitButtonContext
342
331
  };
343
- if (buttonGroupContext && !props.disabled) {
344
- if (!props.value) {
345
- throw new Error('"value" prop must be provided to Button when used within a ButtonGroup');
346
- }
347
- computedProps = buttonGroupContext.getButtonProps({
348
- isSelected: props.value === buttonGroupContext.selectedItem,
349
- ...computedProps
350
- });
351
- computedRef = reactMergeRefs.mergeRefs([
352
- computedProps.ref, ref]);
353
- }
354
332
  return React__namespace.default.createElement(StyledButton, _extends$2({}, computedProps, {
355
- ref: computedRef
333
+ ref: ref
356
334
  }));
357
335
  });
358
336
  ButtonComponent.displayName = 'Button';
@@ -365,7 +343,6 @@ ButtonComponent.propTypes = {
365
343
  focusInset: PropTypes__default.default.bool,
366
344
  isLink: PropTypes__default.default.bool,
367
345
  isStretched: PropTypes__default.default.bool,
368
- isSelected: PropTypes__default.default.bool,
369
346
  size: PropTypes__default.default.oneOf(SIZE)
370
347
  };
371
348
  ButtonComponent.defaultProps = {
@@ -412,58 +389,6 @@ Anchor.propTypes = {
412
389
  externalIconLabel: PropTypes__default.default.string
413
390
  };
414
391
 
415
- const ButtonGroup = React.forwardRef((_ref, ref) => {
416
- let {
417
- children,
418
- onSelect,
419
- selectedItem: controlledSelectedValue,
420
- ...otherProps
421
- } = _ref;
422
- const {
423
- rtl
424
- } = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
425
- const [internalSelectedValue, setInternalSelectedValue] = React.useState();
426
- const selectedValue = containerUtilities.getControlledValue(controlledSelectedValue, internalSelectedValue);
427
- const values = React.useMemo(() => React.Children.toArray(children).reduce((buttons, child) => {
428
- if ( React.isValidElement(child) && child.type !== 'string' && !child.props.disabled) {
429
- buttons.push(child.props.value);
430
- }
431
- return buttons;
432
- }, []), [children]);
433
- const {
434
- selectedValue: selectedItem,
435
- getElementProps,
436
- getGroupProps
437
- } = containerSelection.useSelection({
438
- rtl,
439
- values,
440
- defaultSelectedValue: values[0],
441
- selectedValue,
442
- onSelect: React.useCallback(value => {
443
- onSelect && onSelect(value);
444
- setInternalSelectedValue(value);
445
- }, [onSelect])
446
- });
447
- const contextValue = React.useMemo(() => ({
448
- selectedItem,
449
- getButtonProps: props => getElementProps({
450
- role: 'button',
451
- selectedAriaKey: 'aria-pressed',
452
- ...props
453
- })
454
- }), [selectedItem, getElementProps]);
455
- return React__namespace.default.createElement(ButtonGroupContext.Provider, {
456
- value: contextValue
457
- }, React__namespace.default.createElement(StyledButtonGroup, _extends$2({
458
- ref: ref
459
- }, getGroupProps(otherProps)), children));
460
- });
461
- ButtonGroup.displayName = 'ButtonGroup';
462
- ButtonGroup.propTypes = {
463
- selectedItem: PropTypes__default.default.any,
464
- onSelect: PropTypes__default.default.func
465
- };
466
-
467
392
  const IconButton = React.forwardRef((_ref, ref) => {
468
393
  let {
469
394
  children,
@@ -535,7 +460,7 @@ const SplitButton = React.forwardRef((_ref, ref) => {
535
460
  } = _ref;
536
461
  return React__namespace.default.createElement(SplitButtonContext.Provider, {
537
462
  value: true
538
- }, React__namespace.default.createElement(StyledButtonGroup, _extends$2({
463
+ }, React__namespace.default.createElement(StyledSplitButton, _extends$2({
539
464
  ref: ref
540
465
  }, other), children));
541
466
  });
@@ -583,7 +508,6 @@ ToggleIconButton.defaultProps = {
583
508
 
584
509
  exports.Anchor = Anchor;
585
510
  exports.Button = Button;
586
- exports.ButtonGroup = ButtonGroup;
587
511
  exports.ChevronButton = ChevronButton;
588
512
  exports.IconButton = IconButton;
589
513
  exports.SplitButton = SplitButton;
package/dist/index.esm.js CHANGED
@@ -6,14 +6,11 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import React__default, { Children, createContext, useContext, forwardRef, useState, useMemo, isValidElement, useCallback } from 'react';
9
+ import React__default, { Children, createContext, useContext, forwardRef } from 'react';
10
10
  import PropTypes from 'prop-types';
11
- import { mergeRefs } from 'react-merge-refs';
12
- import styled, { css, ThemeContext } from 'styled-components';
11
+ import styled, { css } from 'styled-components';
13
12
  import { retrieveComponentStyles, DEFAULT_THEME, SELECTOR_FOCUS_VISIBLE, getColor, focusStyles, getFocusBoxShadow, useText } from '@zendeskgarden/react-theming';
14
13
  import { rgba, math, em } from 'polished';
15
- import { useSelection } from '@zendeskgarden/container-selection';
16
- import { getControlledValue } from '@zendeskgarden/container-utilities';
17
14
 
18
15
  function _extends$2() {
19
16
  _extends$2 = Object.assign ? Object.assign.bind() : function (target) {
@@ -33,14 +30,14 @@ function _extends$2() {
33
30
  const SIZE = ['small', 'medium', 'large'];
34
31
 
35
32
  const COMPONENT_ID$5 = 'buttons.button_group_view';
36
- const StyledButtonGroup = styled.div.attrs({
33
+ const StyledSplitButton = styled.div.attrs({
37
34
  'data-garden-id': COMPONENT_ID$5,
38
- 'data-garden-version': '9.0.0-next.1'
35
+ 'data-garden-version': '9.0.0-next.3'
39
36
  }).withConfig({
40
- displayName: "StyledButtonGroup",
41
- componentId: "sc-1fbpzef-0"
37
+ displayName: "StyledSplitButton",
38
+ componentId: "sc-1u4v04v-0"
42
39
  })(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$5, props));
43
- StyledButtonGroup.defaultProps = {
40
+ StyledSplitButton.defaultProps = {
44
41
  theme: DEFAULT_THEME
45
42
  };
46
43
 
@@ -64,7 +61,7 @@ const StyledIcon = styled(_ref => {
64
61
  return React__default.cloneElement(Children.only(children), props);
65
62
  }).attrs({
66
63
  'data-garden-id': COMPONENT_ID$4,
67
- 'data-garden-version': '9.0.0-next.1'
64
+ 'data-garden-version': '9.0.0-next.3'
68
65
  }).withConfig({
69
66
  displayName: "StyledIcon",
70
67
  componentId: "sc-19meqgg-0"
@@ -94,7 +91,7 @@ const getHeight = props => {
94
91
  const colorStyles = props => {
95
92
  let retVal;
96
93
  let hue;
97
- if (props.disabled || props.isNeutral && (props.isPrimary || props.isSelected) && !props.isDanger) {
94
+ if (props.disabled || props.isNeutral && props.isPrimary && !props.isDanger) {
98
95
  hue = 'neutralHue';
99
96
  } else if (props.isDanger) {
100
97
  hue = 'dangerHue';
@@ -117,8 +114,8 @@ const colorStyles = props => {
117
114
  outlineColor: focusColor
118
115
  }
119
116
  }), hoverColor, activeColor, disabledForegroundColor);
120
- } else if (props.isPrimary || props.isSelected) {
121
- retVal = css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], props.isPrimary && props.isSelected ? activeColor : baseColor, props.theme.palette.white, hoverColor, focusStyles({
117
+ } else if (props.isPrimary) {
118
+ retVal = css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], baseColor, props.theme.palette.white, hoverColor, focusStyles({
122
119
  theme: props.theme,
123
120
  inset: props.focusInset,
124
121
  shadowWidth: props.focusInset ? 'sm' : 'md',
@@ -147,7 +144,6 @@ const groupStyles = props => {
147
144
  theme,
148
145
  isPrimary,
149
146
  isBasic,
150
- isSelected,
151
147
  isPill,
152
148
  focusInset
153
149
  } = props;
@@ -164,7 +160,7 @@ const groupStyles = props => {
164
160
  const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
165
161
  const borderColor = isBasic ? 'transparent' : 'revert';
166
162
  const focusColor = getColor('primaryHue', 600, theme);
167
- const focusBoxShadow = isBasic && !isSelected && !isPrimary && getFocusBoxShadow({
163
+ const focusBoxShadow = isBasic && !isPrimary && getFocusBoxShadow({
168
164
  theme,
169
165
  inset: focusInset,
170
166
  spacerHue: focusColor,
@@ -202,12 +198,12 @@ const sizeStyles = props => {
202
198
  };
203
199
  const StyledButton = styled.button.attrs(props => ({
204
200
  'data-garden-id': COMPONENT_ID$3,
205
- 'data-garden-version': '9.0.0-next.1',
201
+ 'data-garden-version': '9.0.0-next.3',
206
202
  type: props.type || 'button'
207
203
  })).withConfig({
208
204
  displayName: "StyledButton",
209
205
  componentId: "sc-qe3ace-0"
210
- })(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{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,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.isLink ? 'inline' : 'inline-flex', props => !props.isLink && 'center', props => !props.isLink && 'center', props => `${props.isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.isStretched ? '100%' : '', props => !props.isLink && 'nowrap', props => props.isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.isLink && 'none', props => sizeStyles(props), SELECTOR_FOCUS_VISIBLE, props => props.isLink ? 'underline' : 'none', props => props.isLink ? 'underline' : 'none', props => colorStyles(props), props => props.isLink && 'none', StyledIcon, props => iconStyles$1(props), StyledButtonGroup, props => groupStyles(props), props => retrieveComponentStyles(COMPONENT_ID$3, props));
206
+ })(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{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,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.isLink ? 'inline' : 'inline-flex', props => !props.isLink && 'center', props => !props.isLink && 'center', props => `${props.isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.isStretched ? '100%' : '', props => !props.isLink && 'nowrap', props => props.isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.isLink && 'none', props => sizeStyles(props), SELECTOR_FOCUS_VISIBLE, props => props.isLink ? 'underline' : 'none', props => props.isLink ? 'underline' : 'none', props => colorStyles(props), props => props.isLink && 'none', StyledIcon, props => iconStyles$1(props), StyledSplitButton, props => groupStyles(props), props => retrieveComponentStyles(COMPONENT_ID$3, props));
211
207
  StyledButton.defaultProps = {
212
208
  theme: DEFAULT_THEME
213
209
  };
@@ -215,7 +211,7 @@ StyledButton.defaultProps = {
215
211
  const COMPONENT_ID$2 = 'buttons.anchor';
216
212
  const StyledAnchor = styled(StyledButton).attrs(props => ({
217
213
  'data-garden-id': COMPONENT_ID$2,
218
- 'data-garden-version': '9.0.0-next.1',
214
+ 'data-garden-version': '9.0.0-next.3',
219
215
  as: 'a',
220
216
  dir: props.theme.rtl ? 'rtl' : undefined,
221
217
  isLink: true,
@@ -249,7 +245,7 @@ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
249
245
  const COMPONENT_ID$1 = 'buttons.external_icon';
250
246
  const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
251
247
  'data-garden-id': COMPONENT_ID$1,
252
- 'data-garden-version': '9.0.0-next.1'
248
+ 'data-garden-version': '9.0.0-next.3'
253
249
  }).withConfig({
254
250
  displayName: "StyledExternalIcon",
255
251
  componentId: "sc-16oz07e-0"
@@ -276,7 +272,7 @@ const iconStyles = props => {
276
272
  };
277
273
  const StyledIconButton = styled(StyledButton).attrs({
278
274
  'data-garden-id': COMPONENT_ID,
279
- 'data-garden-version': '9.0.0-next.1'
275
+ 'data-garden-version': '9.0.0-next.3'
280
276
  }).withConfig({
281
277
  displayName: "StyledIconButton",
282
278
  componentId: "sc-1t0ughp-0"
@@ -285,11 +281,6 @@ StyledIconButton.defaultProps = {
285
281
  theme: DEFAULT_THEME
286
282
  };
287
283
 
288
- const ButtonGroupContext = createContext(undefined);
289
- const useButtonGroupContext = () => {
290
- return useContext(ButtonGroupContext);
291
- };
292
-
293
284
  const SplitButtonContext = createContext(undefined);
294
285
  const useSplitButtonContext = () => {
295
286
  return useContext(SplitButtonContext);
@@ -308,26 +299,13 @@ EndIconComponent.displayName = 'Button.EndIcon';
308
299
  const EndIcon = EndIconComponent;
309
300
 
310
301
  const ButtonComponent = forwardRef((props, ref) => {
311
- const buttonGroupContext = useButtonGroupContext();
312
302
  const splitButtonContext = useSplitButtonContext();
313
- let computedRef = ref;
314
- let computedProps = {
303
+ const computedProps = {
315
304
  ...props,
316
- focusInset: props.focusInset || buttonGroupContext !== undefined || splitButtonContext
305
+ focusInset: props.focusInset || splitButtonContext
317
306
  };
318
- if (buttonGroupContext && !props.disabled) {
319
- if (!props.value) {
320
- throw new Error('"value" prop must be provided to Button when used within a ButtonGroup');
321
- }
322
- computedProps = buttonGroupContext.getButtonProps({
323
- isSelected: props.value === buttonGroupContext.selectedItem,
324
- ...computedProps
325
- });
326
- computedRef = mergeRefs([
327
- computedProps.ref, ref]);
328
- }
329
307
  return React__default.createElement(StyledButton, _extends$2({}, computedProps, {
330
- ref: computedRef
308
+ ref: ref
331
309
  }));
332
310
  });
333
311
  ButtonComponent.displayName = 'Button';
@@ -340,7 +318,6 @@ ButtonComponent.propTypes = {
340
318
  focusInset: PropTypes.bool,
341
319
  isLink: PropTypes.bool,
342
320
  isStretched: PropTypes.bool,
343
- isSelected: PropTypes.bool,
344
321
  size: PropTypes.oneOf(SIZE)
345
322
  };
346
323
  ButtonComponent.defaultProps = {
@@ -387,58 +364,6 @@ Anchor.propTypes = {
387
364
  externalIconLabel: PropTypes.string
388
365
  };
389
366
 
390
- const ButtonGroup = forwardRef((_ref, ref) => {
391
- let {
392
- children,
393
- onSelect,
394
- selectedItem: controlledSelectedValue,
395
- ...otherProps
396
- } = _ref;
397
- const {
398
- rtl
399
- } = useContext(ThemeContext) || DEFAULT_THEME;
400
- const [internalSelectedValue, setInternalSelectedValue] = useState();
401
- const selectedValue = getControlledValue(controlledSelectedValue, internalSelectedValue);
402
- const values = useMemo(() => Children.toArray(children).reduce((buttons, child) => {
403
- if ( isValidElement(child) && child.type !== 'string' && !child.props.disabled) {
404
- buttons.push(child.props.value);
405
- }
406
- return buttons;
407
- }, []), [children]);
408
- const {
409
- selectedValue: selectedItem,
410
- getElementProps,
411
- getGroupProps
412
- } = useSelection({
413
- rtl,
414
- values,
415
- defaultSelectedValue: values[0],
416
- selectedValue,
417
- onSelect: useCallback(value => {
418
- onSelect && onSelect(value);
419
- setInternalSelectedValue(value);
420
- }, [onSelect])
421
- });
422
- const contextValue = useMemo(() => ({
423
- selectedItem,
424
- getButtonProps: props => getElementProps({
425
- role: 'button',
426
- selectedAriaKey: 'aria-pressed',
427
- ...props
428
- })
429
- }), [selectedItem, getElementProps]);
430
- return React__default.createElement(ButtonGroupContext.Provider, {
431
- value: contextValue
432
- }, React__default.createElement(StyledButtonGroup, _extends$2({
433
- ref: ref
434
- }, getGroupProps(otherProps)), children));
435
- });
436
- ButtonGroup.displayName = 'ButtonGroup';
437
- ButtonGroup.propTypes = {
438
- selectedItem: PropTypes.any,
439
- onSelect: PropTypes.func
440
- };
441
-
442
367
  const IconButton = forwardRef((_ref, ref) => {
443
368
  let {
444
369
  children,
@@ -510,7 +435,7 @@ const SplitButton = forwardRef((_ref, ref) => {
510
435
  } = _ref;
511
436
  return React__default.createElement(SplitButtonContext.Provider, {
512
437
  value: true
513
- }, React__default.createElement(StyledButtonGroup, _extends$2({
438
+ }, React__default.createElement(StyledSplitButton, _extends$2({
514
439
  ref: ref
515
440
  }, other), children));
516
441
  });
@@ -556,4 +481,4 @@ ToggleIconButton.defaultProps = {
556
481
  size: 'medium'
557
482
  };
558
483
 
559
- export { Anchor, Button, ButtonGroup, ChevronButton, IconButton, SplitButton, ToggleButton, ToggleIconButton };
484
+ export { Anchor, Button, ChevronButton, IconButton, SplitButton, ToggleButton, ToggleIconButton };
@@ -4,16 +4,10 @@
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
- import React, { SVGAttributes } from 'react';
7
+ import React from 'react';
8
8
  import { IButtonProps } from '../types';
9
9
  import { StartIcon } from './components/StartIcon';
10
10
  import { EndIcon } from './components/EndIcon';
11
- /**
12
- * @deprecated use IButtonStartIconProps or IButtonEndIconProps instead
13
- */
14
- export interface IIconProps extends SVGAttributes<SVGSVGElement> {
15
- isRotated?: boolean;
16
- }
17
11
  /**
18
12
  * @extends ButtonHTMLAttributes<HTMLButtonElement>
19
13
  */
@@ -4,12 +4,11 @@
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
- export { Button, type IIconProps } from './elements/Button';
7
+ export { Button } from './elements/Button';
8
8
  export { Anchor } from './elements/Anchor';
9
- export { ButtonGroup } from './elements/ButtonGroup';
10
9
  export { ChevronButton } from './elements/ChevronButton';
11
10
  export { IconButton } from './elements/IconButton';
12
11
  export { SplitButton } from './elements/SplitButton';
13
12
  export { ToggleButton } from './elements/ToggleButton';
14
13
  export { ToggleIconButton } from './elements/ToggleIconButton';
15
- export type { IButtonProps, IButtonIconProps as IButtonEndIconProps, IButtonIconProps as IButtonStartIconProps, IAnchorProps, IIconButtonProps, IIconButtonProps as IChevronButtonProps, IToggleButtonProps, IToggleIconButtonProps, IButtonGroupProps } from './types';
14
+ export type { IButtonProps, IButtonIconProps as IButtonEndIconProps, IButtonIconProps as IButtonStartIconProps, IAnchorProps, IIconButtonProps, IIconButtonProps as IChevronButtonProps, IToggleButtonProps, IToggleIconButtonProps } from './types';
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Accepts all `<div>` props
9
9
  */
10
- export declare const StyledButtonGroup: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
10
+ export declare const StyledSplitButton: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
11
11
  'data-garden-id': string;
12
12
  'data-garden-version': string;
13
13
  }, "data-garden-id" | "data-garden-version">;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  export * from './StyledAnchor';
8
8
  export * from './StyledButton';
9
- export * from './StyledButtonGroup';
9
+ export * from './StyledSplitButton';
10
10
  export * from './StyledExternalIcon';
11
11
  export * from './StyledIcon';
12
12
  export * from './StyledIconButton';
@@ -4,7 +4,7 @@
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
- import { AnchorHTMLAttributes, ButtonHTMLAttributes, HTMLAttributes, SVGAttributes } from 'react';
7
+ import { AnchorHTMLAttributes, ButtonHTMLAttributes, SVGAttributes } from 'react';
8
8
  export declare const SIZE: readonly ["small", "medium", "large"];
9
9
  export interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
10
10
  /** Applies danger styling */
@@ -25,8 +25,6 @@ export interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
25
25
  isPill?: boolean;
26
26
  /** Applies inset `box-shadow` styling on focus */
27
27
  focusInset?: boolean;
28
- /** @ignore prop used by `ButtonGroup` */
29
- isSelected?: boolean;
30
28
  }
31
29
  export interface IToggleButtonProps extends IButtonProps {
32
30
  /**
@@ -56,13 +54,3 @@ export interface IAnchorProps extends Pick<IButtonProps, 'isDanger'>, AnchorHTML
56
54
  **/
57
55
  externalIconLabel?: string;
58
56
  }
59
- export interface IButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
60
- /** Defines the currently selected button in the group */
61
- selectedItem?: any;
62
- /**
63
- * Handles button selection
64
- *
65
- * @param {any} item The selected item
66
- */
67
- onSelect?: (item: any) => void;
68
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-buttons",
3
- "version": "9.0.0-next.1",
3
+ "version": "9.0.0-next.3",
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>",
@@ -21,7 +21,6 @@
21
21
  "sideEffects": false,
22
22
  "types": "dist/typings/index.d.ts",
23
23
  "dependencies": {
24
- "@zendeskgarden/container-selection": "^3.0.0",
25
24
  "@zendeskgarden/container-utilities": "^2.0.0",
26
25
  "polished": "^4.0.0",
27
26
  "prop-types": "^15.5.7",
@@ -34,7 +33,7 @@
34
33
  "styled-components": "^5.1.0"
35
34
  },
36
35
  "devDependencies": {
37
- "@zendeskgarden/react-theming": "^9.0.0-next.1",
36
+ "@zendeskgarden/react-theming": "^9.0.0-next.3",
38
37
  "@zendeskgarden/svg-icons": "7.0.0"
39
38
  },
40
39
  "keywords": [
@@ -47,5 +46,5 @@
47
46
  "access": "public"
48
47
  },
49
48
  "zendeskgarden:src": "src/index.ts",
50
- "gitHead": "a9e4e776bf6ad8860a198fc24f27b2b5cbc83320"
49
+ "gitHead": "d5086e8a3ae0c8608361966954bf434ef03005ec"
51
50
  }
@@ -1,14 +0,0 @@
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 React from 'react';
8
- import { IButtonGroupProps } from '../types';
9
- /**
10
- * @deprecated this legacy component will be removed in a future release
11
- *
12
- * @extends HTMLAttributes<HTMLDivElement>
13
- */
14
- export declare const ButtonGroup: React.ForwardRefExoticComponent<IButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,14 +0,0 @@
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
- /// <reference types="react" />
8
- interface IButtonGroupContext {
9
- selectedItem: any;
10
- getButtonProps: (props: any) => any;
11
- }
12
- export declare const ButtonGroupContext: import("react").Context<IButtonGroupContext | undefined>;
13
- export declare const useButtonGroupContext: () => IButtonGroupContext | undefined;
14
- export {};