@zendeskgarden/react-buttons 9.0.0-next.6 → 9.0.0-next.8
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/esm/elements/Anchor.js +54 -0
- package/dist/esm/elements/Button.js +49 -0
- package/dist/esm/elements/ChevronButton.js +27 -0
- package/dist/esm/elements/IconButton.js +50 -0
- package/dist/esm/elements/SplitButton.js +29 -0
- package/dist/esm/elements/ToggleButton.js +30 -0
- package/dist/esm/elements/ToggleIconButton.js +32 -0
- package/dist/esm/elements/components/EndIcon.js +21 -0
- package/dist/esm/elements/components/StartIcon.js +21 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/styled/StyledAnchor.js +27 -0
- package/dist/esm/styled/StyledButton.js +155 -0
- package/dist/esm/styled/StyledExternalIcon.js +23 -0
- package/dist/esm/styled/StyledIcon.js +40 -0
- package/dist/esm/styled/StyledIconButton.js +39 -0
- package/dist/esm/styled/StyledSplitButton.js +22 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/utils/useSplitButtonContext.js +14 -0
- package/dist/index.cjs.js +28 -40
- package/package.json +5 -5
- package/dist/index.esm.js +0 -484
package/dist/index.esm.js
DELETED
|
@@ -1,484 +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 } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import styled, { css } from 'styled-components';
|
|
12
|
-
import { retrieveComponentStyles, DEFAULT_THEME, SELECTOR_FOCUS_VISIBLE, getColorV8, focusStyles, getFocusBoxShadow, useText } from '@zendeskgarden/react-theming';
|
|
13
|
-
import { rgba, math, em } from 'polished';
|
|
14
|
-
|
|
15
|
-
function _extends$2() {
|
|
16
|
-
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for (var key in source) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends$2.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const SIZE = ['small', 'medium', 'large'];
|
|
31
|
-
|
|
32
|
-
const COMPONENT_ID$5 = 'buttons.button_group_view';
|
|
33
|
-
const StyledSplitButton = styled.div.attrs({
|
|
34
|
-
'data-garden-id': COMPONENT_ID$5,
|
|
35
|
-
'data-garden-version': '9.0.0-next.6'
|
|
36
|
-
}).withConfig({
|
|
37
|
-
displayName: "StyledSplitButton",
|
|
38
|
-
componentId: "sc-1u4v04v-0"
|
|
39
|
-
})(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
40
|
-
StyledSplitButton.defaultProps = {
|
|
41
|
-
theme: DEFAULT_THEME
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const COMPONENT_ID$4 = 'buttons.icon';
|
|
45
|
-
const sizeStyles$1 = props => {
|
|
46
|
-
let marginProperty;
|
|
47
|
-
if (props.position === 'start') {
|
|
48
|
-
marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
|
|
49
|
-
} else if (props.position === 'end') {
|
|
50
|
-
marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
|
|
51
|
-
}
|
|
52
|
-
return marginProperty && css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
|
|
53
|
-
};
|
|
54
|
-
const StyledIcon = styled(_ref => {
|
|
55
|
-
let {
|
|
56
|
-
children,
|
|
57
|
-
isRotated,
|
|
58
|
-
theme,
|
|
59
|
-
...props
|
|
60
|
-
} = _ref;
|
|
61
|
-
return React__default.cloneElement(Children.only(children), props);
|
|
62
|
-
}).attrs({
|
|
63
|
-
'data-garden-id': COMPONENT_ID$4,
|
|
64
|
-
'data-garden-version': '9.0.0-next.6'
|
|
65
|
-
}).withConfig({
|
|
66
|
-
displayName: "StyledIcon",
|
|
67
|
-
componentId: "sc-19meqgg-0"
|
|
68
|
-
})(["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));
|
|
69
|
-
StyledIcon.defaultProps = {
|
|
70
|
-
theme: DEFAULT_THEME
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const COMPONENT_ID$3 = 'buttons.button';
|
|
74
|
-
const getBorderRadius = props => {
|
|
75
|
-
if (props.isPill) {
|
|
76
|
-
return '100px';
|
|
77
|
-
}
|
|
78
|
-
return props.theme.borderRadii.md;
|
|
79
|
-
};
|
|
80
|
-
const getDisabledBackgroundColor = props => {
|
|
81
|
-
return getColorV8('neutralHue', 200, props.theme);
|
|
82
|
-
};
|
|
83
|
-
const getHeight = props => {
|
|
84
|
-
if (props.size === 'small') {
|
|
85
|
-
return `${props.theme.space.base * 8}px`;
|
|
86
|
-
} else if (props.size === 'large') {
|
|
87
|
-
return `${props.theme.space.base * 12}px`;
|
|
88
|
-
}
|
|
89
|
-
return `${props.theme.space.base * 10}px`;
|
|
90
|
-
};
|
|
91
|
-
const colorStyles = props => {
|
|
92
|
-
let retVal;
|
|
93
|
-
let hue;
|
|
94
|
-
if (props.disabled || props.isNeutral && props.isPrimary && !props.isDanger) {
|
|
95
|
-
hue = 'neutralHue';
|
|
96
|
-
} else if (props.isDanger) {
|
|
97
|
-
hue = 'dangerHue';
|
|
98
|
-
} else {
|
|
99
|
-
hue = 'primaryHue';
|
|
100
|
-
}
|
|
101
|
-
const shade = 600;
|
|
102
|
-
const baseColor = getColorV8(hue, shade, props.theme);
|
|
103
|
-
const hoverColor = getColorV8(hue, shade + 100, props.theme);
|
|
104
|
-
const activeColor = getColorV8(hue, shade + 200, props.theme);
|
|
105
|
-
const focusColor = getColorV8('primaryHue', shade, props.theme);
|
|
106
|
-
const disabledBackgroundColor = getDisabledBackgroundColor(props);
|
|
107
|
-
const disabledForegroundColor = getColorV8(hue, shade - 200, props.theme);
|
|
108
|
-
if (props.isLink) {
|
|
109
|
-
retVal = css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], baseColor, focusStyles({
|
|
110
|
-
theme: props.theme,
|
|
111
|
-
condition: false,
|
|
112
|
-
styles: {
|
|
113
|
-
color: baseColor,
|
|
114
|
-
outlineColor: focusColor
|
|
115
|
-
}
|
|
116
|
-
}), hoverColor, activeColor, disabledForegroundColor);
|
|
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({
|
|
119
|
-
theme: props.theme,
|
|
120
|
-
inset: props.focusInset,
|
|
121
|
-
shadowWidth: props.focusInset ? 'sm' : 'md',
|
|
122
|
-
spacerWidth: props.focusInset ? 'sm' : 'xs',
|
|
123
|
-
styles: props.isDanger && props.focusInset ? {
|
|
124
|
-
borderColor: focusColor
|
|
125
|
-
} : undefined
|
|
126
|
-
}), activeColor, props.isPrimary && activeColor, disabledBackgroundColor, disabledForegroundColor);
|
|
127
|
-
} else {
|
|
128
|
-
const borderColor = props.isNeutral && !props.isDanger ? getColorV8('neutralHue', 300, props.theme) : baseColor;
|
|
129
|
-
const foregroundColor = props.isNeutral ? getColorV8('foreground', 600 , props.theme) : baseColor;
|
|
130
|
-
const hoverBorderColor = props.isNeutral && !props.isDanger ? baseColor : hoverColor;
|
|
131
|
-
const hoverForegroundColor = props.isNeutral ? foregroundColor : hoverColor;
|
|
132
|
-
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({
|
|
133
|
-
theme: props.theme,
|
|
134
|
-
inset: props.focusInset,
|
|
135
|
-
styles: props.isNeutral ? {
|
|
136
|
-
borderColor: baseColor
|
|
137
|
-
} : undefined
|
|
138
|
-
}), !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);
|
|
139
|
-
}
|
|
140
|
-
return retVal;
|
|
141
|
-
};
|
|
142
|
-
const groupStyles = props => {
|
|
143
|
-
const {
|
|
144
|
-
theme,
|
|
145
|
-
isPrimary,
|
|
146
|
-
isBasic,
|
|
147
|
-
isPill,
|
|
148
|
-
focusInset
|
|
149
|
-
} = props;
|
|
150
|
-
const {
|
|
151
|
-
rtl,
|
|
152
|
-
borderWidths,
|
|
153
|
-
borders
|
|
154
|
-
} = theme;
|
|
155
|
-
const startPosition = rtl ? 'right' : 'left';
|
|
156
|
-
const endPosition = rtl ? 'left' : 'right';
|
|
157
|
-
const marginOffset = borderWidths.sm;
|
|
158
|
-
const marginDisplacement = `${isPrimary || isBasic ? '' : '-'}${marginOffset}`;
|
|
159
|
-
const iconMarginDisplacement = isPill && '-2px';
|
|
160
|
-
const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
|
|
161
|
-
const borderColor = isBasic ? 'transparent' : 'revert';
|
|
162
|
-
const focusColor = getColorV8('primaryHue', 600, theme);
|
|
163
|
-
const focusBoxShadow = isBasic && !isPrimary && getFocusBoxShadow({
|
|
164
|
-
theme,
|
|
165
|
-
inset: focusInset,
|
|
166
|
-
spacerHue: focusColor,
|
|
167
|
-
hue: 'transparent'
|
|
168
|
-
});
|
|
169
|
-
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);
|
|
170
|
-
};
|
|
171
|
-
const iconStyles$1 = props => {
|
|
172
|
-
const size = props.size === 'small' ? props.theme.iconSizes.sm : props.theme.iconSizes.md;
|
|
173
|
-
return css(["width:", ";min-width:", ";height:", ";vertical-align:", ";"], size, size, size, props.isLink && 'middle');
|
|
174
|
-
};
|
|
175
|
-
const sizeStyles = props => {
|
|
176
|
-
let retVal;
|
|
177
|
-
if (props.isLink) {
|
|
178
|
-
retVal = css(["padding:0;font-size:inherit;"]);
|
|
179
|
-
} else {
|
|
180
|
-
const height = getHeight(props);
|
|
181
|
-
const lineHeight = math(`${height} - (${props.theme.borderWidths.sm} * 2)`);
|
|
182
|
-
let padding;
|
|
183
|
-
let fontSize;
|
|
184
|
-
if (props.size === 'small') {
|
|
185
|
-
fontSize = props.theme.fontSizes.sm;
|
|
186
|
-
padding = `${props.theme.space.base * 3}px`;
|
|
187
|
-
} else {
|
|
188
|
-
fontSize = props.theme.fontSizes.md;
|
|
189
|
-
if (props.size === 'large') {
|
|
190
|
-
padding = `${props.theme.space.base * 5}px`;
|
|
191
|
-
} else {
|
|
192
|
-
padding = `${props.theme.space.base * 4}px`;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
retVal = css(["padding:0 ", ";height:", ";line-height:", ";font-size:", ";"], em(math(`${padding} - ${props.theme.borderWidths.sm}`), fontSize), height, lineHeight, fontSize);
|
|
196
|
-
}
|
|
197
|
-
return retVal;
|
|
198
|
-
};
|
|
199
|
-
const StyledButton = styled.button.attrs(props => ({
|
|
200
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
201
|
-
'data-garden-version': '9.0.0-next.6',
|
|
202
|
-
type: props.type || 'button'
|
|
203
|
-
})).withConfig({
|
|
204
|
-
displayName: "StyledButton",
|
|
205
|
-
componentId: "sc-qe3ace-0"
|
|
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));
|
|
207
|
-
StyledButton.defaultProps = {
|
|
208
|
-
theme: DEFAULT_THEME
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const COMPONENT_ID$2 = 'buttons.anchor';
|
|
212
|
-
const StyledAnchor = styled(StyledButton).attrs(props => ({
|
|
213
|
-
'data-garden-id': COMPONENT_ID$2,
|
|
214
|
-
'data-garden-version': '9.0.0-next.6',
|
|
215
|
-
as: 'a',
|
|
216
|
-
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
217
|
-
isLink: true,
|
|
218
|
-
type: undefined
|
|
219
|
-
})).withConfig({
|
|
220
|
-
displayName: "StyledAnchor",
|
|
221
|
-
componentId: "sc-xshgmo-0"
|
|
222
|
-
})(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
223
|
-
StyledAnchor.defaultProps = {
|
|
224
|
-
theme: DEFAULT_THEME
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
var _path$1;
|
|
228
|
-
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); }
|
|
229
|
-
var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
230
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
231
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
232
|
-
width: 12,
|
|
233
|
-
height: 12,
|
|
234
|
-
focusable: "false",
|
|
235
|
-
viewBox: "0 0 12 12",
|
|
236
|
-
"aria-hidden": "true"
|
|
237
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
238
|
-
fill: "none",
|
|
239
|
-
stroke: "currentColor",
|
|
240
|
-
strokeLinecap: "round",
|
|
241
|
-
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"
|
|
242
|
-
})));
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const COMPONENT_ID$1 = 'buttons.external_icon';
|
|
246
|
-
const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
|
|
247
|
-
'data-garden-id': COMPONENT_ID$1,
|
|
248
|
-
'data-garden-version': '9.0.0-next.6'
|
|
249
|
-
}).withConfig({
|
|
250
|
-
displayName: "StyledExternalIcon",
|
|
251
|
-
componentId: "sc-16oz07e-0"
|
|
252
|
-
})(["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));
|
|
253
|
-
StyledExternalIcon.defaultProps = {
|
|
254
|
-
theme: DEFAULT_THEME
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
const COMPONENT_ID = 'buttons.icon_button';
|
|
258
|
-
const iconColorStyles = props => {
|
|
259
|
-
const shade = 600;
|
|
260
|
-
const baseColor = getColorV8('neutralHue', shade, props.theme);
|
|
261
|
-
const hoverColor = getColorV8('neutralHue', shade + 100, props.theme);
|
|
262
|
-
const activeColor = getColorV8('neutralHue', shade + 200, props.theme);
|
|
263
|
-
return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
264
|
-
};
|
|
265
|
-
const iconButtonStyles = props => {
|
|
266
|
-
const width = getHeight(props);
|
|
267
|
-
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');
|
|
268
|
-
};
|
|
269
|
-
const iconStyles = props => {
|
|
270
|
-
const size = props.theme.iconSizes.md;
|
|
271
|
-
return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
|
|
272
|
-
};
|
|
273
|
-
const StyledIconButton = styled(StyledButton).attrs({
|
|
274
|
-
'data-garden-id': COMPONENT_ID,
|
|
275
|
-
'data-garden-version': '9.0.0-next.6'
|
|
276
|
-
}).withConfig({
|
|
277
|
-
displayName: "StyledIconButton",
|
|
278
|
-
componentId: "sc-1t0ughp-0"
|
|
279
|
-
})(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
280
|
-
StyledIconButton.defaultProps = {
|
|
281
|
-
theme: DEFAULT_THEME
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
const SplitButtonContext = createContext(undefined);
|
|
285
|
-
const useSplitButtonContext = () => {
|
|
286
|
-
return useContext(SplitButtonContext);
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const StartIconComponent = props => React__default.createElement(StyledIcon, _extends$2({
|
|
290
|
-
position: "start"
|
|
291
|
-
}, props));
|
|
292
|
-
StartIconComponent.displayName = 'Button.StartIcon';
|
|
293
|
-
const StartIcon = StartIconComponent;
|
|
294
|
-
|
|
295
|
-
const EndIconComponent = props => React__default.createElement(StyledIcon, _extends$2({
|
|
296
|
-
position: "end"
|
|
297
|
-
}, props));
|
|
298
|
-
EndIconComponent.displayName = 'Button.EndIcon';
|
|
299
|
-
const EndIcon = EndIconComponent;
|
|
300
|
-
|
|
301
|
-
const ButtonComponent = forwardRef((props, ref) => {
|
|
302
|
-
const splitButtonContext = useSplitButtonContext();
|
|
303
|
-
const computedProps = {
|
|
304
|
-
...props,
|
|
305
|
-
focusInset: props.focusInset || splitButtonContext
|
|
306
|
-
};
|
|
307
|
-
return React__default.createElement(StyledButton, _extends$2({}, computedProps, {
|
|
308
|
-
ref: ref
|
|
309
|
-
}));
|
|
310
|
-
});
|
|
311
|
-
ButtonComponent.displayName = 'Button';
|
|
312
|
-
ButtonComponent.propTypes = {
|
|
313
|
-
isNeutral: PropTypes.bool,
|
|
314
|
-
isPrimary: PropTypes.bool,
|
|
315
|
-
isDanger: PropTypes.bool,
|
|
316
|
-
isPill: PropTypes.bool,
|
|
317
|
-
isBasic: PropTypes.bool,
|
|
318
|
-
focusInset: PropTypes.bool,
|
|
319
|
-
isLink: PropTypes.bool,
|
|
320
|
-
isStretched: PropTypes.bool,
|
|
321
|
-
size: PropTypes.oneOf(SIZE)
|
|
322
|
-
};
|
|
323
|
-
ButtonComponent.defaultProps = {
|
|
324
|
-
size: 'medium'
|
|
325
|
-
};
|
|
326
|
-
const Button = ButtonComponent;
|
|
327
|
-
Button.EndIcon = EndIcon;
|
|
328
|
-
Button.StartIcon = StartIcon;
|
|
329
|
-
|
|
330
|
-
const Anchor = forwardRef((_ref, ref) => {
|
|
331
|
-
let {
|
|
332
|
-
children,
|
|
333
|
-
isExternal,
|
|
334
|
-
externalIconLabel,
|
|
335
|
-
...otherProps
|
|
336
|
-
} = _ref;
|
|
337
|
-
let anchorProps = otherProps;
|
|
338
|
-
if (isExternal) {
|
|
339
|
-
anchorProps = {
|
|
340
|
-
target: '_blank',
|
|
341
|
-
rel: 'noopener noreferrer',
|
|
342
|
-
...anchorProps
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
const checkProps = isExternal ? {
|
|
346
|
-
externalIconLabel
|
|
347
|
-
} : {
|
|
348
|
-
noIconLabel: 'true'
|
|
349
|
-
};
|
|
350
|
-
const iconAriaLabel = useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
351
|
-
return React__default.createElement(StyledAnchor, _extends$2({
|
|
352
|
-
ref: ref
|
|
353
|
-
}, anchorProps), children, isExternal &&
|
|
354
|
-
React__default.createElement(StyledExternalIcon, {
|
|
355
|
-
role: "img",
|
|
356
|
-
"aria-label": iconAriaLabel,
|
|
357
|
-
"aria-hidden": undefined
|
|
358
|
-
}));
|
|
359
|
-
});
|
|
360
|
-
Anchor.displayName = 'Anchor';
|
|
361
|
-
Anchor.propTypes = {
|
|
362
|
-
isExternal: PropTypes.bool,
|
|
363
|
-
isDanger: PropTypes.bool,
|
|
364
|
-
externalIconLabel: PropTypes.string
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
const IconButton = forwardRef((_ref, ref) => {
|
|
368
|
-
let {
|
|
369
|
-
children,
|
|
370
|
-
isRotated,
|
|
371
|
-
...otherProps
|
|
372
|
-
} = _ref;
|
|
373
|
-
const focusInset = useSplitButtonContext();
|
|
374
|
-
return React__default.createElement(StyledIconButton, _extends$2({
|
|
375
|
-
ref: ref
|
|
376
|
-
}, otherProps, {
|
|
377
|
-
focusInset: otherProps.focusInset || focusInset
|
|
378
|
-
}), React__default.createElement(StyledIcon, {
|
|
379
|
-
isRotated: isRotated
|
|
380
|
-
}, children));
|
|
381
|
-
});
|
|
382
|
-
IconButton.displayName = 'IconButton';
|
|
383
|
-
IconButton.propTypes = {
|
|
384
|
-
isDanger: PropTypes.bool,
|
|
385
|
-
size: PropTypes.oneOf(SIZE),
|
|
386
|
-
isNeutral: PropTypes.bool,
|
|
387
|
-
isPrimary: PropTypes.bool,
|
|
388
|
-
isBasic: PropTypes.bool,
|
|
389
|
-
isPill: PropTypes.bool,
|
|
390
|
-
focusInset: PropTypes.bool,
|
|
391
|
-
isRotated: PropTypes.bool
|
|
392
|
-
};
|
|
393
|
-
IconButton.defaultProps = {
|
|
394
|
-
isPill: true,
|
|
395
|
-
isBasic: true,
|
|
396
|
-
size: 'medium'
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
var _path;
|
|
400
|
-
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); }
|
|
401
|
-
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
402
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
403
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
404
|
-
width: 16,
|
|
405
|
-
height: 16,
|
|
406
|
-
focusable: "false",
|
|
407
|
-
viewBox: "0 0 16 16",
|
|
408
|
-
"aria-hidden": "true"
|
|
409
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
410
|
-
fill: "currentColor",
|
|
411
|
-
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"
|
|
412
|
-
})));
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
const ChevronButton = forwardRef((_ref, ref) => {
|
|
416
|
-
let {
|
|
417
|
-
...buttonProps
|
|
418
|
-
} = _ref;
|
|
419
|
-
return React__default.createElement(IconButton, _extends$2({
|
|
420
|
-
ref: ref
|
|
421
|
-
}, buttonProps), React__default.createElement(SvgChevronDownStroke, null));
|
|
422
|
-
});
|
|
423
|
-
ChevronButton.displayName = 'ChevronButton';
|
|
424
|
-
ChevronButton.propTypes = IconButton.propTypes;
|
|
425
|
-
ChevronButton.defaultProps = {
|
|
426
|
-
isBasic: false,
|
|
427
|
-
isPill: false,
|
|
428
|
-
size: 'medium'
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
const SplitButton = forwardRef((_ref, ref) => {
|
|
432
|
-
let {
|
|
433
|
-
children,
|
|
434
|
-
...other
|
|
435
|
-
} = _ref;
|
|
436
|
-
return React__default.createElement(SplitButtonContext.Provider, {
|
|
437
|
-
value: true
|
|
438
|
-
}, React__default.createElement(StyledSplitButton, _extends$2({
|
|
439
|
-
ref: ref
|
|
440
|
-
}, other), children));
|
|
441
|
-
});
|
|
442
|
-
SplitButton.displayName = 'SplitButton';
|
|
443
|
-
|
|
444
|
-
const ToggleButton = forwardRef((_ref, ref) => {
|
|
445
|
-
let {
|
|
446
|
-
isPressed,
|
|
447
|
-
...otherProps
|
|
448
|
-
} = _ref;
|
|
449
|
-
return React__default.createElement(Button, _extends$2({
|
|
450
|
-
"aria-pressed": isPressed,
|
|
451
|
-
ref: ref
|
|
452
|
-
}, otherProps));
|
|
453
|
-
});
|
|
454
|
-
ToggleButton.displayName = 'ToggleButton';
|
|
455
|
-
ToggleButton.propTypes = {
|
|
456
|
-
...Button.propTypes,
|
|
457
|
-
isPressed: PropTypes.oneOf([true, false, 'mixed'])
|
|
458
|
-
};
|
|
459
|
-
ToggleButton.defaultProps = {
|
|
460
|
-
size: 'medium'
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
const ToggleIconButton = forwardRef((_ref, ref) => {
|
|
464
|
-
let {
|
|
465
|
-
isPressed,
|
|
466
|
-
...otherProps
|
|
467
|
-
} = _ref;
|
|
468
|
-
return React__default.createElement(IconButton, _extends$2({
|
|
469
|
-
"aria-pressed": isPressed,
|
|
470
|
-
ref: ref
|
|
471
|
-
}, otherProps));
|
|
472
|
-
});
|
|
473
|
-
ToggleIconButton.displayName = 'ToggleIconButton';
|
|
474
|
-
ToggleIconButton.propTypes = {
|
|
475
|
-
...IconButton.propTypes,
|
|
476
|
-
isPressed: PropTypes.oneOf([true, false, 'mixed'])
|
|
477
|
-
};
|
|
478
|
-
ToggleIconButton.defaultProps = {
|
|
479
|
-
isPill: true,
|
|
480
|
-
isBasic: true,
|
|
481
|
-
size: 'medium'
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
export { Anchor, Button, ChevronButton, IconButton, SplitButton, ToggleButton, ToggleIconButton };
|