@zendeskgarden/react-buttons 8.75.0 → 8.76.0

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/dist/index.esm.js DELETED
@@ -1,559 +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
-
8
- import * as React from 'react';
9
- import React__default, { Children, createContext, useContext, forwardRef, useState, useMemo, isValidElement, useCallback } from 'react';
10
- import PropTypes from 'prop-types';
11
- import mergeRefs from 'react-merge-refs';
12
- import styled, { css, ThemeContext } from 'styled-components';
13
- import { retrieveComponentStyles, DEFAULT_THEME, SELECTOR_FOCUS_VISIBLE, getColorV8, focusStyles, getFocusBoxShadow, useText } from '@zendeskgarden/react-theming';
14
- import { rgba, math, em } from 'polished';
15
- import { useSelection } from '@zendeskgarden/container-selection';
16
- import { getControlledValue } from '@zendeskgarden/container-utilities';
17
-
18
- function _extends$2() {
19
- _extends$2 = Object.assign ? Object.assign.bind() : function (target) {
20
- for (var i = 1; i < arguments.length; i++) {
21
- var source = arguments[i];
22
- for (var key in source) {
23
- if (Object.prototype.hasOwnProperty.call(source, key)) {
24
- target[key] = source[key];
25
- }
26
- }
27
- }
28
- return target;
29
- };
30
- return _extends$2.apply(this, arguments);
31
- }
32
-
33
- const SIZE = ['small', 'medium', 'large'];
34
-
35
- const COMPONENT_ID$5 = 'buttons.button_group_view';
36
- const StyledButtonGroup = styled.div.attrs({
37
- 'data-garden-id': COMPONENT_ID$5,
38
- 'data-garden-version': '8.75.0'
39
- }).withConfig({
40
- displayName: "StyledButtonGroup",
41
- componentId: "sc-1fbpzef-0"
42
- })(["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 = {
44
- theme: DEFAULT_THEME
45
- };
46
-
47
- const COMPONENT_ID$4 = 'buttons.icon';
48
- const sizeStyles$1 = props => {
49
- let marginProperty;
50
- if (props.position === 'start') {
51
- marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
52
- } else if (props.position === 'end') {
53
- marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
54
- }
55
- return marginProperty && css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
56
- };
57
- const StyledIcon = styled(_ref => {
58
- let {
59
- children,
60
- isRotated,
61
- theme,
62
- ...props
63
- } = _ref;
64
- return React__default.cloneElement(Children.only(children), props);
65
- }).attrs({
66
- 'data-garden-id': COMPONENT_ID$4,
67
- 'data-garden-version': '8.75.0'
68
- }).withConfig({
69
- displayName: "StyledIcon",
70
- componentId: "sc-19meqgg-0"
71
- })(["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 => retrieveComponentStyles(COMPONENT_ID$4, props));
72
- StyledIcon.defaultProps = {
73
- theme: DEFAULT_THEME
74
- };
75
-
76
- const COMPONENT_ID$3 = 'buttons.button';
77
- const getBorderRadius = props => {
78
- if (props.isPill) {
79
- return '100px';
80
- }
81
- return props.theme.borderRadii.md;
82
- };
83
- const getDisabledBackgroundColor = props => {
84
- return getColorV8('neutralHue', 200, props.theme);
85
- };
86
- const getHeight = props => {
87
- if (props.size === 'small') {
88
- return `${props.theme.space.base * 8}px`;
89
- } else if (props.size === 'large') {
90
- return `${props.theme.space.base * 12}px`;
91
- }
92
- return `${props.theme.space.base * 10}px`;
93
- };
94
- const colorStyles = props => {
95
- let retVal;
96
- let hue;
97
- if (props.disabled || props.isNeutral && (props.isPrimary || props.isSelected) && !props.isDanger) {
98
- hue = 'neutralHue';
99
- } else if (props.isDanger) {
100
- hue = 'dangerHue';
101
- } else {
102
- hue = 'primaryHue';
103
- }
104
- const shade = 600;
105
- const baseColor = getColorV8(hue, shade, props.theme);
106
- const hoverColor = getColorV8(hue, shade + 100, props.theme);
107
- const activeColor = getColorV8(hue, shade + 200, props.theme);
108
- const focusColor = getColorV8('primaryHue', shade, props.theme);
109
- const disabledBackgroundColor = getDisabledBackgroundColor(props);
110
- const disabledForegroundColor = getColorV8(hue, shade - 200, props.theme);
111
- if (props.isLink) {
112
- retVal = css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], baseColor, focusStyles({
113
- theme: props.theme,
114
- condition: false,
115
- styles: {
116
- color: baseColor,
117
- outlineColor: focusColor
118
- }
119
- }), 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({
122
- theme: props.theme,
123
- inset: props.focusInset,
124
- shadowWidth: props.focusInset ? 'sm' : 'md',
125
- spacerWidth: props.focusInset ? 'sm' : 'xs',
126
- styles: props.isDanger && props.focusInset ? {
127
- borderColor: focusColor
128
- } : undefined
129
- }), activeColor, props.isPrimary && activeColor, disabledBackgroundColor, disabledForegroundColor);
130
- } else {
131
- const borderColor = props.isNeutral && !props.isDanger ? getColorV8('neutralHue', 300, props.theme) : baseColor;
132
- const foregroundColor = props.isNeutral ? getColorV8('foreground', 600 , props.theme) : baseColor;
133
- const hoverBorderColor = props.isNeutral && !props.isDanger ? baseColor : hoverColor;
134
- const hoverForegroundColor = props.isNeutral ? foregroundColor : hoverColor;
135
- retVal = css(["outline-color:transparent;border-color:", ";background-color:transparent;color:", ";&:hover{border-color:", ";background-color:", ";color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{border-color:", ";background-color:", ";color:", ";}&:disabled{border-color:transparent;background-color:", ";color:", ";}& ", "{color:", ";}&:hover ", ",&:focus-visible ", ",&[data-garden-focus-visible] ", "{color:", ";}&:active ", "{color:", ";}&:disabled ", "{color:", ";}"], !props.isBasic && borderColor, foregroundColor, !props.isBasic && hoverBorderColor, rgba(baseColor, 0.08), hoverForegroundColor, focusStyles({
136
- theme: props.theme,
137
- inset: props.focusInset,
138
- styles: props.isNeutral ? {
139
- borderColor: baseColor
140
- } : undefined
141
- }), !props.isBasic && activeColor, rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && getColorV8('neutralHue', shade, props.theme), StyledIcon, StyledIcon, StyledIcon, props.isNeutral && getColorV8('neutralHue', shade + 100, props.theme), StyledIcon, props.isNeutral && foregroundColor, StyledIcon, disabledForegroundColor);
142
- }
143
- return retVal;
144
- };
145
- const groupStyles = props => {
146
- const {
147
- theme,
148
- isPrimary,
149
- isBasic,
150
- isSelected,
151
- isPill,
152
- focusInset
153
- } = props;
154
- const {
155
- rtl,
156
- borderWidths,
157
- borders
158
- } = theme;
159
- const startPosition = rtl ? 'right' : 'left';
160
- const endPosition = rtl ? 'left' : 'right';
161
- const marginOffset = borderWidths.sm;
162
- const marginDisplacement = `${isPrimary || isBasic ? '' : '-'}${marginOffset}`;
163
- const iconMarginDisplacement = isPill && '-2px';
164
- const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
165
- const borderColor = isBasic ? 'transparent' : 'revert';
166
- const focusColor = getColorV8('primaryHue', 600, theme);
167
- const focusBoxShadow = isBasic && !isSelected && !isPrimary && getFocusBoxShadow({
168
- theme,
169
- inset: focusInset,
170
- spacerHue: focusColor,
171
- hue: 'transparent'
172
- });
173
- return 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, SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
174
- };
175
- const iconStyles$1 = props => {
176
- const size = props.size === 'small' ? props.theme.iconSizes.sm : props.theme.iconSizes.md;
177
- return css(["width:", ";min-width:", ";height:", ";vertical-align:", ";"], size, size, size, props.isLink && 'middle');
178
- };
179
- const sizeStyles = props => {
180
- let retVal;
181
- if (props.isLink) {
182
- retVal = css(["padding:0;font-size:inherit;"]);
183
- } else {
184
- const height = getHeight(props);
185
- const lineHeight = math(`${height} - (${props.theme.borderWidths.sm} * 2)`);
186
- let padding;
187
- let fontSize;
188
- if (props.size === 'small') {
189
- fontSize = props.theme.fontSizes.sm;
190
- padding = `${props.theme.space.base * 3}px`;
191
- } else {
192
- fontSize = props.theme.fontSizes.md;
193
- if (props.size === 'large') {
194
- padding = `${props.theme.space.base * 5}px`;
195
- } else {
196
- padding = `${props.theme.space.base * 4}px`;
197
- }
198
- }
199
- retVal = css(["padding:0 ", ";height:", ";line-height:", ";font-size:", ";"], em(math(`${padding} - ${props.theme.borderWidths.sm}`), fontSize), height, lineHeight, fontSize);
200
- }
201
- return retVal;
202
- };
203
- const StyledButton = styled.button.attrs(props => ({
204
- 'data-garden-id': COMPONENT_ID$3,
205
- 'data-garden-version': '8.75.0',
206
- type: props.type || 'button'
207
- })).withConfig({
208
- displayName: "StyledButton",
209
- 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));
211
- StyledButton.defaultProps = {
212
- theme: DEFAULT_THEME
213
- };
214
-
215
- const COMPONENT_ID$2 = 'buttons.anchor';
216
- const StyledAnchor = styled(StyledButton).attrs(props => ({
217
- 'data-garden-id': COMPONENT_ID$2,
218
- 'data-garden-version': '8.75.0',
219
- as: 'a',
220
- dir: props.theme.rtl ? 'rtl' : undefined,
221
- isLink: true,
222
- type: undefined
223
- })).withConfig({
224
- displayName: "StyledAnchor",
225
- componentId: "sc-xshgmo-0"
226
- })(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$2, props));
227
- StyledAnchor.defaultProps = {
228
- theme: DEFAULT_THEME
229
- };
230
-
231
- var _path$1;
232
- function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : 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$1.apply(this, arguments); }
233
- var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
234
- return /*#__PURE__*/React.createElement("svg", _extends$1({
235
- xmlns: "http://www.w3.org/2000/svg",
236
- width: 12,
237
- height: 12,
238
- focusable: "false",
239
- viewBox: "0 0 12 12",
240
- "aria-hidden": "true"
241
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
242
- fill: "none",
243
- stroke: "currentColor",
244
- strokeLinecap: "round",
245
- d: "M10.5 8.5V10c0 .3-.2.5-.5.5H2c-.3 0-.5-.2-.5-.5V2c0-.3.2-.5.5-.5h1.5M6 6l4-4m-3.5-.5H10c.3 0 .5.2.5.5v3.5"
246
- })));
247
- };
248
-
249
- const COMPONENT_ID$1 = 'buttons.external_icon';
250
- const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
251
- 'data-garden-id': COMPONENT_ID$1,
252
- 'data-garden-version': '8.75.0'
253
- }).withConfig({
254
- displayName: "StyledExternalIcon",
255
- componentId: "sc-16oz07e-0"
256
- })(["transform:", ";margin-bottom:-0.085em;padding-left:0.25em;box-sizing:content-box;width:0.85em;height:0.85em;", ";"], props => props.theme.rtl && 'scaleX(-1)', props => retrieveComponentStyles(COMPONENT_ID$1, props));
257
- StyledExternalIcon.defaultProps = {
258
- theme: DEFAULT_THEME
259
- };
260
-
261
- const COMPONENT_ID = 'buttons.icon_button';
262
- const iconColorStyles = props => {
263
- const shade = 600;
264
- const baseColor = getColorV8('neutralHue', shade, props.theme);
265
- const hoverColor = getColorV8('neutralHue', shade + 100, props.theme);
266
- const activeColor = getColorV8('neutralHue', shade + 200, props.theme);
267
- return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
268
- };
269
- const iconButtonStyles = props => {
270
- const width = getHeight(props);
271
- 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');
272
- };
273
- const iconStyles = props => {
274
- const size = props.theme.iconSizes.md;
275
- return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
276
- };
277
- const StyledIconButton = styled(StyledButton).attrs({
278
- 'data-garden-id': COMPONENT_ID,
279
- 'data-garden-version': '8.75.0'
280
- }).withConfig({
281
- displayName: "StyledIconButton",
282
- componentId: "sc-1t0ughp-0"
283
- })(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
284
- StyledIconButton.defaultProps = {
285
- theme: DEFAULT_THEME
286
- };
287
-
288
- const ButtonGroupContext = createContext(undefined);
289
- const useButtonGroupContext = () => {
290
- return useContext(ButtonGroupContext);
291
- };
292
-
293
- const SplitButtonContext = createContext(undefined);
294
- const useSplitButtonContext = () => {
295
- return useContext(SplitButtonContext);
296
- };
297
-
298
- const StartIconComponent = props => React__default.createElement(StyledIcon, _extends$2({
299
- position: "start"
300
- }, props));
301
- StartIconComponent.displayName = 'Button.StartIcon';
302
- const StartIcon = StartIconComponent;
303
-
304
- const EndIconComponent = props => React__default.createElement(StyledIcon, _extends$2({
305
- position: "end"
306
- }, props));
307
- EndIconComponent.displayName = 'Button.EndIcon';
308
- const EndIcon = EndIconComponent;
309
-
310
- const ButtonComponent = forwardRef((props, ref) => {
311
- const buttonGroupContext = useButtonGroupContext();
312
- const splitButtonContext = useSplitButtonContext();
313
- let computedRef = ref;
314
- let computedProps = {
315
- ...props,
316
- focusInset: props.focusInset || buttonGroupContext !== undefined || splitButtonContext
317
- };
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
- return React__default.createElement(StyledButton, _extends$2({}, computedProps, {
330
- ref: computedRef
331
- }));
332
- });
333
- ButtonComponent.displayName = 'Button';
334
- ButtonComponent.propTypes = {
335
- isNeutral: PropTypes.bool,
336
- isPrimary: PropTypes.bool,
337
- isDanger: PropTypes.bool,
338
- isPill: PropTypes.bool,
339
- isBasic: PropTypes.bool,
340
- focusInset: PropTypes.bool,
341
- isLink: PropTypes.bool,
342
- isStretched: PropTypes.bool,
343
- isSelected: PropTypes.bool,
344
- size: PropTypes.oneOf(SIZE)
345
- };
346
- ButtonComponent.defaultProps = {
347
- size: 'medium'
348
- };
349
- const Button = ButtonComponent;
350
- Button.EndIcon = EndIcon;
351
- Button.StartIcon = StartIcon;
352
-
353
- const Anchor = forwardRef((_ref, ref) => {
354
- let {
355
- children,
356
- isExternal,
357
- externalIconLabel,
358
- ...otherProps
359
- } = _ref;
360
- let anchorProps = otherProps;
361
- if (isExternal) {
362
- anchorProps = {
363
- target: '_blank',
364
- rel: 'noopener noreferrer',
365
- ...anchorProps
366
- };
367
- }
368
- const checkProps = isExternal ? {
369
- externalIconLabel
370
- } : {
371
- noIconLabel: 'true'
372
- };
373
- const iconAriaLabel = useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
374
- return React__default.createElement(StyledAnchor, _extends$2({
375
- ref: ref
376
- }, anchorProps), children, isExternal &&
377
- React__default.createElement(StyledExternalIcon, {
378
- role: "img",
379
- "aria-label": iconAriaLabel,
380
- "aria-hidden": undefined
381
- }));
382
- });
383
- Anchor.displayName = 'Anchor';
384
- Anchor.propTypes = {
385
- isExternal: PropTypes.bool,
386
- isDanger: PropTypes.bool,
387
- externalIconLabel: PropTypes.string
388
- };
389
-
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
- const IconButton = forwardRef((_ref, ref) => {
443
- let {
444
- children,
445
- isRotated,
446
- ...otherProps
447
- } = _ref;
448
- const focusInset = useSplitButtonContext();
449
- return React__default.createElement(StyledIconButton, _extends$2({
450
- ref: ref
451
- }, otherProps, {
452
- focusInset: otherProps.focusInset || focusInset
453
- }), React__default.createElement(StyledIcon, {
454
- isRotated: isRotated
455
- }, children));
456
- });
457
- IconButton.displayName = 'IconButton';
458
- IconButton.propTypes = {
459
- isDanger: PropTypes.bool,
460
- size: PropTypes.oneOf(SIZE),
461
- isNeutral: PropTypes.bool,
462
- isPrimary: PropTypes.bool,
463
- isBasic: PropTypes.bool,
464
- isPill: PropTypes.bool,
465
- focusInset: PropTypes.bool,
466
- isRotated: PropTypes.bool
467
- };
468
- IconButton.defaultProps = {
469
- isPill: true,
470
- isBasic: true,
471
- size: 'medium'
472
- };
473
-
474
- var _path;
475
- function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
476
- var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
477
- return /*#__PURE__*/React.createElement("svg", _extends({
478
- xmlns: "http://www.w3.org/2000/svg",
479
- width: 16,
480
- height: 16,
481
- focusable: "false",
482
- viewBox: "0 0 16 16",
483
- "aria-hidden": "true"
484
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
485
- fill: "currentColor",
486
- d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
487
- })));
488
- };
489
-
490
- const ChevronButton = forwardRef((_ref, ref) => {
491
- let {
492
- ...buttonProps
493
- } = _ref;
494
- return React__default.createElement(IconButton, _extends$2({
495
- ref: ref
496
- }, buttonProps), React__default.createElement(SvgChevronDownStroke, null));
497
- });
498
- ChevronButton.displayName = 'ChevronButton';
499
- ChevronButton.propTypes = IconButton.propTypes;
500
- ChevronButton.defaultProps = {
501
- isBasic: false,
502
- isPill: false,
503
- size: 'medium'
504
- };
505
-
506
- const SplitButton = forwardRef((_ref, ref) => {
507
- let {
508
- children,
509
- ...other
510
- } = _ref;
511
- return React__default.createElement(SplitButtonContext.Provider, {
512
- value: true
513
- }, React__default.createElement(StyledButtonGroup, _extends$2({
514
- ref: ref
515
- }, other), children));
516
- });
517
- SplitButton.displayName = 'SplitButton';
518
-
519
- const ToggleButton = forwardRef((_ref, ref) => {
520
- let {
521
- isPressed,
522
- ...otherProps
523
- } = _ref;
524
- return React__default.createElement(Button, _extends$2({
525
- "aria-pressed": isPressed,
526
- ref: ref
527
- }, otherProps));
528
- });
529
- ToggleButton.displayName = 'ToggleButton';
530
- ToggleButton.propTypes = {
531
- ...Button.propTypes,
532
- isPressed: PropTypes.oneOf([true, false, 'mixed'])
533
- };
534
- ToggleButton.defaultProps = {
535
- size: 'medium'
536
- };
537
-
538
- const ToggleIconButton = forwardRef((_ref, ref) => {
539
- let {
540
- isPressed,
541
- ...otherProps
542
- } = _ref;
543
- return React__default.createElement(IconButton, _extends$2({
544
- "aria-pressed": isPressed,
545
- ref: ref
546
- }, otherProps));
547
- });
548
- ToggleIconButton.displayName = 'ToggleIconButton';
549
- ToggleIconButton.propTypes = {
550
- ...IconButton.propTypes,
551
- isPressed: PropTypes.oneOf([true, false, 'mixed'])
552
- };
553
- ToggleIconButton.defaultProps = {
554
- isPill: true,
555
- isBasic: true,
556
- size: 'medium'
557
- };
558
-
559
- export { Anchor, Button, ButtonGroup, ChevronButton, IconButton, SplitButton, ToggleButton, ToggleIconButton };