@zendeskgarden/react-buttons 9.0.0-next.1 → 9.0.0-next.11
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 +0 -27
- 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 +28 -0
- package/dist/esm/elements/components/StartIcon.js +28 -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 +316 -0
- package/dist/esm/styled/StyledExternalIcon.js +23 -0
- package/dist/esm/styled/StyledIcon.js +31 -0
- package/dist/esm/styled/StyledIconButton.js +61 -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 +296 -195
- package/dist/typings/elements/Button.d.ts +1 -7
- package/dist/typings/elements/components/EndIcon.d.ts +1 -1
- package/dist/typings/elements/components/StartIcon.d.ts +1 -1
- package/dist/typings/index.d.ts +2 -3
- package/dist/typings/styled/StyledAnchor.d.ts +1 -1
- package/dist/typings/styled/StyledIcon.d.ts +4 -4
- package/dist/typings/styled/{StyledButtonGroup.d.ts → StyledSplitButton.d.ts} +1 -1
- package/dist/typings/styled/index.d.ts +1 -1
- package/dist/typings/types/index.d.ts +1 -13
- package/package.json +6 -7
- package/dist/index.esm.js +0 -559
- package/dist/typings/elements/ButtonGroup.d.ts +0 -14
- package/dist/typings/utils/useButtonGroupContext.d.ts +0 -14
package/dist/index.cjs.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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');
|
|
11
10
|
var PropTypes = require('prop-types');
|
|
12
|
-
var reactMergeRefs = require('react-merge-refs');
|
|
13
11
|
var styled = require('styled-components');
|
|
14
12
|
var reactTheming = require('@zendeskgarden/react-theming');
|
|
15
13
|
var polished = require('polished');
|
|
16
|
-
var containerSelection = require('@zendeskgarden/container-selection');
|
|
17
|
-
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
18
14
|
|
|
19
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
16
|
|
|
@@ -40,60 +36,37 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
40
36
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
41
37
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
42
38
|
|
|
43
|
-
function _extends$2() {
|
|
44
|
-
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
45
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
46
|
-
var source = arguments[i];
|
|
47
|
-
for (var key in source) {
|
|
48
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
49
|
-
target[key] = source[key];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return target;
|
|
54
|
-
};
|
|
55
|
-
return _extends$2.apply(this, arguments);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
39
|
const SIZE = ['small', 'medium', 'large'];
|
|
59
40
|
|
|
60
41
|
const COMPONENT_ID$5 = 'buttons.button_group_view';
|
|
61
|
-
const
|
|
42
|
+
const StyledSplitButton = styled__default.default.div.attrs({
|
|
62
43
|
'data-garden-id': COMPONENT_ID$5,
|
|
63
|
-
'data-garden-version': '9.0.0-next.
|
|
44
|
+
'data-garden-version': '9.0.0-next.11'
|
|
64
45
|
}).withConfig({
|
|
65
|
-
displayName: "
|
|
66
|
-
componentId: "sc-
|
|
46
|
+
displayName: "StyledSplitButton",
|
|
47
|
+
componentId: "sc-1u4v04v-0"
|
|
67
48
|
})(["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
|
-
|
|
49
|
+
StyledSplitButton.defaultProps = {
|
|
69
50
|
theme: reactTheming.DEFAULT_THEME
|
|
70
51
|
};
|
|
71
52
|
|
|
72
53
|
const COMPONENT_ID$4 = 'buttons.icon';
|
|
73
54
|
const sizeStyles$1 = props => {
|
|
74
55
|
let marginProperty;
|
|
75
|
-
if (props
|
|
56
|
+
if (props.$position === 'start') {
|
|
76
57
|
marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
|
|
77
|
-
} else if (props
|
|
58
|
+
} else if (props.$position === 'end') {
|
|
78
59
|
marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
|
|
79
60
|
}
|
|
80
61
|
return marginProperty && styled.css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
|
|
81
62
|
};
|
|
82
|
-
const StyledIcon = styled__default.default(
|
|
83
|
-
let {
|
|
84
|
-
children,
|
|
85
|
-
isRotated,
|
|
86
|
-
theme,
|
|
87
|
-
...props
|
|
88
|
-
} = _ref;
|
|
89
|
-
return React__namespace.default.cloneElement(React.Children.only(children), props);
|
|
90
|
-
}).attrs({
|
|
63
|
+
const StyledIcon = styled__default.default(reactTheming.StyledBaseIcon).attrs({
|
|
91
64
|
'data-garden-id': COMPONENT_ID$4,
|
|
92
|
-
'data-garden-version': '9.0.0-next.
|
|
65
|
+
'data-garden-version': '9.0.0-next.11'
|
|
93
66
|
}).withConfig({
|
|
94
67
|
displayName: "StyledIcon",
|
|
95
68
|
componentId: "sc-19meqgg-0"
|
|
96
|
-
})(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => 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));
|
|
97
70
|
StyledIcon.defaultProps = {
|
|
98
71
|
theme: reactTheming.DEFAULT_THEME
|
|
99
72
|
};
|
|
@@ -105,9 +78,6 @@ const getBorderRadius = props => {
|
|
|
105
78
|
}
|
|
106
79
|
return props.theme.borderRadii.md;
|
|
107
80
|
};
|
|
108
|
-
const getDisabledBackgroundColor = props => {
|
|
109
|
-
return reactTheming.getColor('neutralHue', 200, props.theme);
|
|
110
|
-
};
|
|
111
81
|
const getHeight = props => {
|
|
112
82
|
if (props.size === 'small') {
|
|
113
83
|
return `${props.theme.space.base * 8}px`;
|
|
@@ -116,66 +86,223 @@ const getHeight = props => {
|
|
|
116
86
|
}
|
|
117
87
|
return `${props.theme.space.base * 10}px`;
|
|
118
88
|
};
|
|
119
|
-
const colorStyles =
|
|
89
|
+
const colorStyles = _ref => {
|
|
90
|
+
let {
|
|
91
|
+
theme,
|
|
92
|
+
isLink,
|
|
93
|
+
isBasic,
|
|
94
|
+
isDanger,
|
|
95
|
+
isNeutral,
|
|
96
|
+
isPrimary,
|
|
97
|
+
focusInset
|
|
98
|
+
} = _ref;
|
|
120
99
|
let retVal;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
100
|
+
const disabledBackgroundColor = reactTheming.getColor({
|
|
101
|
+
theme,
|
|
102
|
+
variable: 'background.disabled'
|
|
103
|
+
});
|
|
104
|
+
const disabledForegroundColor = reactTheming.getColor({
|
|
105
|
+
theme,
|
|
106
|
+
variable: 'foreground.disabled'
|
|
107
|
+
});
|
|
108
|
+
const offset100 = {
|
|
109
|
+
dark: {
|
|
110
|
+
offset: -100
|
|
111
|
+
},
|
|
112
|
+
light: {
|
|
113
|
+
offset: 100
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const offset200 = {
|
|
117
|
+
dark: {
|
|
118
|
+
offset: -200
|
|
119
|
+
},
|
|
120
|
+
light: {
|
|
121
|
+
offset: 200
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
if (isLink) {
|
|
125
|
+
const options = {
|
|
126
|
+
theme,
|
|
127
|
+
variable: isDanger ? 'foreground.danger' : 'foreground.primary'
|
|
128
|
+
};
|
|
129
|
+
const foregroundColor = reactTheming.getColor(options);
|
|
130
|
+
const hoverForegroundColor = reactTheming.getColor({
|
|
131
|
+
...options,
|
|
132
|
+
...offset100
|
|
133
|
+
});
|
|
134
|
+
const activeForegroundColor = reactTheming.getColor({
|
|
135
|
+
...options,
|
|
136
|
+
...offset200
|
|
137
|
+
});
|
|
138
|
+
const focusOutlineColor = reactTheming.getColor({
|
|
139
|
+
theme,
|
|
140
|
+
variable: 'border.primaryEmphasis'
|
|
141
|
+
});
|
|
142
|
+
retVal = styled.css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], foregroundColor, reactTheming.focusStyles({
|
|
143
|
+
theme,
|
|
139
144
|
condition: false,
|
|
140
145
|
styles: {
|
|
141
|
-
color:
|
|
142
|
-
outlineColor:
|
|
146
|
+
color: foregroundColor ,
|
|
147
|
+
outlineColor: focusOutlineColor
|
|
143
148
|
}
|
|
144
|
-
}),
|
|
145
|
-
} else if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
}), hoverForegroundColor, activeForegroundColor, disabledForegroundColor);
|
|
150
|
+
} else if (isPrimary) {
|
|
151
|
+
let backgroundVariable;
|
|
152
|
+
if (isDanger) {
|
|
153
|
+
backgroundVariable = 'background.dangerEmphasis';
|
|
154
|
+
} else if (isNeutral) {
|
|
155
|
+
backgroundVariable = 'background.emphasis';
|
|
156
|
+
} else {
|
|
157
|
+
backgroundVariable = 'background.primaryEmphasis';
|
|
158
|
+
}
|
|
159
|
+
const options = {
|
|
160
|
+
theme,
|
|
161
|
+
variable: backgroundVariable
|
|
162
|
+
};
|
|
163
|
+
const backgroundColor = reactTheming.getColor(options);
|
|
164
|
+
const hoverBackgroundColor = reactTheming.getColor({
|
|
165
|
+
...options,
|
|
166
|
+
...offset100
|
|
167
|
+
});
|
|
168
|
+
const activeBackgroundColor = reactTheming.getColor({
|
|
169
|
+
...options,
|
|
170
|
+
...offset200
|
|
171
|
+
});
|
|
172
|
+
const foregroundColor = reactTheming.getColor({
|
|
173
|
+
theme,
|
|
174
|
+
variable: 'foreground.onEmphasis'
|
|
175
|
+
});
|
|
176
|
+
retVal = styled.css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], backgroundColor, foregroundColor, hoverBackgroundColor, reactTheming.focusStyles({
|
|
177
|
+
theme,
|
|
178
|
+
inset: focusInset,
|
|
179
|
+
shadowWidth: focusInset ? 'sm' : 'md',
|
|
180
|
+
spacerWidth: focusInset ? 'sm' : 'xs',
|
|
181
|
+
styles: (isDanger || isNeutral) && focusInset ? {
|
|
182
|
+
borderColor: reactTheming.getColor({
|
|
183
|
+
theme,
|
|
184
|
+
variable: 'border.primaryEmphasis'
|
|
185
|
+
})
|
|
153
186
|
} : undefined
|
|
154
|
-
}),
|
|
187
|
+
}), activeBackgroundColor, disabledBackgroundColor, disabledForegroundColor);
|
|
155
188
|
} else {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
189
|
+
let borderColor;
|
|
190
|
+
let hoverBorderColor;
|
|
191
|
+
let activeBorderColor;
|
|
192
|
+
let focusBorderColor;
|
|
193
|
+
let backgroundVariable;
|
|
194
|
+
let foregroundVariable;
|
|
195
|
+
if (isDanger) {
|
|
196
|
+
if (!isBasic) {
|
|
197
|
+
const borderOptions = {
|
|
198
|
+
theme,
|
|
199
|
+
variable: 'border.dangerEmphasis'
|
|
200
|
+
};
|
|
201
|
+
borderColor = reactTheming.getColor(borderOptions);
|
|
202
|
+
hoverBorderColor = reactTheming.getColor({
|
|
203
|
+
...borderOptions,
|
|
204
|
+
...offset100
|
|
205
|
+
});
|
|
206
|
+
activeBorderColor = reactTheming.getColor({
|
|
207
|
+
...borderOptions,
|
|
208
|
+
...offset200
|
|
209
|
+
});
|
|
210
|
+
if (isNeutral) {
|
|
211
|
+
focusBorderColor = reactTheming.getColor(borderOptions);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
backgroundVariable = 'background.dangerEmphasis';
|
|
215
|
+
foregroundVariable = isNeutral ? 'foreground.default' : 'foreground.danger';
|
|
216
|
+
} else {
|
|
217
|
+
if (!isBasic) {
|
|
218
|
+
const borderOptions = {
|
|
219
|
+
theme,
|
|
220
|
+
variable: 'border.primaryEmphasis'
|
|
221
|
+
};
|
|
222
|
+
if (isNeutral) {
|
|
223
|
+
borderColor = reactTheming.getColor({
|
|
224
|
+
theme,
|
|
225
|
+
variable: 'border.default',
|
|
226
|
+
...offset100
|
|
227
|
+
});
|
|
228
|
+
focusBorderColor = reactTheming.getColor(borderOptions);
|
|
229
|
+
} else {
|
|
230
|
+
borderColor = reactTheming.getColor(borderOptions);
|
|
231
|
+
}
|
|
232
|
+
hoverBorderColor = reactTheming.getColor({
|
|
233
|
+
...borderOptions,
|
|
234
|
+
...offset100
|
|
235
|
+
});
|
|
236
|
+
activeBorderColor = reactTheming.getColor({
|
|
237
|
+
...borderOptions,
|
|
238
|
+
...offset200
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
backgroundVariable = 'background.primaryEmphasis';
|
|
242
|
+
foregroundVariable = isNeutral ? 'foreground.default' : 'foreground.primary';
|
|
243
|
+
}
|
|
244
|
+
const hoverBackgroundColor = reactTheming.getColor({
|
|
245
|
+
theme,
|
|
246
|
+
variable: backgroundVariable,
|
|
247
|
+
transparency: theme.opacity[100]
|
|
248
|
+
});
|
|
249
|
+
const activeBackgroundColor = reactTheming.getColor({
|
|
250
|
+
theme,
|
|
251
|
+
variable: backgroundVariable,
|
|
252
|
+
transparency: theme.opacity[200]
|
|
253
|
+
});
|
|
254
|
+
const foregroundOptions = {
|
|
255
|
+
theme,
|
|
256
|
+
variable: foregroundVariable
|
|
257
|
+
};
|
|
258
|
+
const foregroundColor = reactTheming.getColor(foregroundOptions);
|
|
259
|
+
let hoverForegroundColor;
|
|
260
|
+
let activeForegroundColor;
|
|
261
|
+
let iconForegroundColor;
|
|
262
|
+
let hoverIconForegroundColor;
|
|
263
|
+
let activeIconForegroundColor;
|
|
264
|
+
if (isNeutral) {
|
|
265
|
+
const iconOptions = {
|
|
266
|
+
theme,
|
|
267
|
+
variable: 'foreground.subtle'
|
|
268
|
+
};
|
|
269
|
+
iconForegroundColor = reactTheming.getColor(iconOptions);
|
|
270
|
+
hoverIconForegroundColor = reactTheming.getColor({
|
|
271
|
+
...iconOptions,
|
|
272
|
+
...offset100
|
|
273
|
+
});
|
|
274
|
+
activeIconForegroundColor = reactTheming.getColor({
|
|
275
|
+
...iconOptions,
|
|
276
|
+
...offset200
|
|
277
|
+
});
|
|
278
|
+
} else {
|
|
279
|
+
hoverForegroundColor = reactTheming.getColor({
|
|
280
|
+
...foregroundOptions,
|
|
281
|
+
...offset100
|
|
282
|
+
});
|
|
283
|
+
activeForegroundColor = reactTheming.getColor({
|
|
284
|
+
...foregroundOptions,
|
|
285
|
+
...offset200
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
retVal = styled.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 ", "{color:", ";}&:active ", "{color:", ";}&:disabled ", "{color:", ";}"], borderColor, foregroundColor, hoverBorderColor, hoverBackgroundColor, hoverForegroundColor, reactTheming.focusStyles({
|
|
289
|
+
theme,
|
|
290
|
+
inset: focusInset,
|
|
291
|
+
styles: {
|
|
292
|
+
borderColor: focusBorderColor
|
|
293
|
+
}
|
|
294
|
+
}), activeBorderColor, activeBackgroundColor, activeForegroundColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, iconForegroundColor, StyledIcon, StyledIcon, hoverIconForegroundColor, StyledIcon, activeIconForegroundColor, StyledIcon, disabledForegroundColor);
|
|
167
295
|
}
|
|
168
296
|
return retVal;
|
|
169
297
|
};
|
|
170
|
-
const groupStyles =
|
|
171
|
-
|
|
298
|
+
const groupStyles = _ref2 => {
|
|
299
|
+
let {
|
|
172
300
|
theme,
|
|
173
301
|
isPrimary,
|
|
174
302
|
isBasic,
|
|
175
|
-
isSelected,
|
|
176
303
|
isPill,
|
|
177
304
|
focusInset
|
|
178
|
-
} =
|
|
305
|
+
} = _ref2;
|
|
179
306
|
const {
|
|
180
307
|
rtl,
|
|
181
308
|
borderWidths,
|
|
@@ -186,14 +313,24 @@ const groupStyles = props => {
|
|
|
186
313
|
const marginOffset = borderWidths.sm;
|
|
187
314
|
const marginDisplacement = `${isPrimary || isBasic ? '' : '-'}${marginOffset}`;
|
|
188
315
|
const iconMarginDisplacement = isPill && '-2px';
|
|
189
|
-
const disabledBackgroundColor = !isPrimary &&
|
|
316
|
+
const disabledBackgroundColor = !isPrimary && reactTheming.getColor({
|
|
317
|
+
theme,
|
|
318
|
+
variable: 'background.disabled'
|
|
319
|
+
});
|
|
190
320
|
const borderColor = isBasic ? 'transparent' : 'revert';
|
|
191
|
-
const focusColor = reactTheming.getColor(
|
|
192
|
-
|
|
321
|
+
const focusColor = reactTheming.getColor({
|
|
322
|
+
theme,
|
|
323
|
+
variable: 'border.primaryEmphasis'
|
|
324
|
+
});
|
|
325
|
+
const focusBoxShadow = isBasic && !isPrimary && reactTheming.getFocusBoxShadow({
|
|
193
326
|
theme,
|
|
194
327
|
inset: focusInset,
|
|
195
|
-
|
|
196
|
-
|
|
328
|
+
spacerColor: {
|
|
329
|
+
hue: focusColor
|
|
330
|
+
},
|
|
331
|
+
color: {
|
|
332
|
+
hue: 'transparent'
|
|
333
|
+
}
|
|
197
334
|
});
|
|
198
335
|
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);
|
|
199
336
|
};
|
|
@@ -227,12 +364,12 @@ const sizeStyles = props => {
|
|
|
227
364
|
};
|
|
228
365
|
const StyledButton = styled__default.default.button.attrs(props => ({
|
|
229
366
|
'data-garden-id': COMPONENT_ID$3,
|
|
230
|
-
'data-garden-version': '9.0.0-next.
|
|
367
|
+
'data-garden-version': '9.0.0-next.11',
|
|
231
368
|
type: props.type || 'button'
|
|
232
369
|
})).withConfig({
|
|
233
370
|
displayName: "StyledButton",
|
|
234
371
|
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),
|
|
372
|
+
})(["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
373
|
StyledButton.defaultProps = {
|
|
237
374
|
theme: reactTheming.DEFAULT_THEME
|
|
238
375
|
};
|
|
@@ -240,7 +377,7 @@ StyledButton.defaultProps = {
|
|
|
240
377
|
const COMPONENT_ID$2 = 'buttons.anchor';
|
|
241
378
|
const StyledAnchor = styled__default.default(StyledButton).attrs(props => ({
|
|
242
379
|
'data-garden-id': COMPONENT_ID$2,
|
|
243
|
-
'data-garden-version': '9.0.0-next.
|
|
380
|
+
'data-garden-version': '9.0.0-next.11',
|
|
244
381
|
as: 'a',
|
|
245
382
|
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
246
383
|
isLink: true,
|
|
@@ -274,7 +411,7 @@ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
|
274
411
|
const COMPONENT_ID$1 = 'buttons.external_icon';
|
|
275
412
|
const StyledExternalIcon = styled__default.default(SvgNewWindowStroke).attrs({
|
|
276
413
|
'data-garden-id': COMPONENT_ID$1,
|
|
277
|
-
'data-garden-version': '9.0.0-next.
|
|
414
|
+
'data-garden-version': '9.0.0-next.11'
|
|
278
415
|
}).withConfig({
|
|
279
416
|
displayName: "StyledExternalIcon",
|
|
280
417
|
componentId: "sc-16oz07e-0"
|
|
@@ -284,11 +421,33 @@ StyledExternalIcon.defaultProps = {
|
|
|
284
421
|
};
|
|
285
422
|
|
|
286
423
|
const COMPONENT_ID = 'buttons.icon_button';
|
|
287
|
-
const iconColorStyles =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const
|
|
424
|
+
const iconColorStyles = _ref => {
|
|
425
|
+
let {
|
|
426
|
+
theme
|
|
427
|
+
} = _ref;
|
|
428
|
+
const options = {
|
|
429
|
+
theme,
|
|
430
|
+
variable: 'foreground.default'
|
|
431
|
+
};
|
|
432
|
+
const baseColor = reactTheming.getColor(options);
|
|
433
|
+
const hoverColor = reactTheming.getColor({
|
|
434
|
+
...options,
|
|
435
|
+
dark: {
|
|
436
|
+
offset: -100
|
|
437
|
+
},
|
|
438
|
+
light: {
|
|
439
|
+
offset: 100
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
const activeColor = reactTheming.getColor({
|
|
443
|
+
...options,
|
|
444
|
+
dark: {
|
|
445
|
+
offset: -200
|
|
446
|
+
},
|
|
447
|
+
light: {
|
|
448
|
+
offset: 200
|
|
449
|
+
}
|
|
450
|
+
});
|
|
292
451
|
return styled.css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
293
452
|
};
|
|
294
453
|
const iconButtonStyles = props => {
|
|
@@ -301,7 +460,7 @@ const iconStyles = props => {
|
|
|
301
460
|
};
|
|
302
461
|
const StyledIconButton = styled__default.default(StyledButton).attrs({
|
|
303
462
|
'data-garden-id': COMPONENT_ID,
|
|
304
|
-
'data-garden-version': '9.0.0-next.
|
|
463
|
+
'data-garden-version': '9.0.0-next.11'
|
|
305
464
|
}).withConfig({
|
|
306
465
|
displayName: "StyledIconButton",
|
|
307
466
|
componentId: "sc-1t0ughp-0"
|
|
@@ -310,49 +469,45 @@ StyledIconButton.defaultProps = {
|
|
|
310
469
|
theme: reactTheming.DEFAULT_THEME
|
|
311
470
|
};
|
|
312
471
|
|
|
313
|
-
const ButtonGroupContext = React.createContext(undefined);
|
|
314
|
-
const useButtonGroupContext = () => {
|
|
315
|
-
return React.useContext(ButtonGroupContext);
|
|
316
|
-
};
|
|
317
|
-
|
|
318
472
|
const SplitButtonContext = React.createContext(undefined);
|
|
319
473
|
const useSplitButtonContext = () => {
|
|
320
474
|
return React.useContext(SplitButtonContext);
|
|
321
475
|
};
|
|
322
476
|
|
|
323
|
-
const StartIconComponent =
|
|
324
|
-
|
|
325
|
-
|
|
477
|
+
const StartIconComponent = _ref => {
|
|
478
|
+
let {
|
|
479
|
+
isRotated,
|
|
480
|
+
...props
|
|
481
|
+
} = _ref;
|
|
482
|
+
return React__namespace.default.createElement(StyledIcon, Object.assign({
|
|
483
|
+
$position: "start",
|
|
484
|
+
$isRotated: isRotated
|
|
485
|
+
}, props));
|
|
486
|
+
};
|
|
326
487
|
StartIconComponent.displayName = 'Button.StartIcon';
|
|
327
488
|
const StartIcon = StartIconComponent;
|
|
328
489
|
|
|
329
|
-
const EndIconComponent =
|
|
330
|
-
|
|
331
|
-
|
|
490
|
+
const EndIconComponent = _ref => {
|
|
491
|
+
let {
|
|
492
|
+
isRotated,
|
|
493
|
+
...props
|
|
494
|
+
} = _ref;
|
|
495
|
+
return React__namespace.default.createElement(StyledIcon, Object.assign({
|
|
496
|
+
$position: "end",
|
|
497
|
+
$isRotated: isRotated
|
|
498
|
+
}, props));
|
|
499
|
+
};
|
|
332
500
|
EndIconComponent.displayName = 'Button.EndIcon';
|
|
333
501
|
const EndIcon = EndIconComponent;
|
|
334
502
|
|
|
335
503
|
const ButtonComponent = React.forwardRef((props, ref) => {
|
|
336
|
-
const buttonGroupContext = useButtonGroupContext();
|
|
337
504
|
const splitButtonContext = useSplitButtonContext();
|
|
338
|
-
|
|
339
|
-
let computedProps = {
|
|
505
|
+
const computedProps = {
|
|
340
506
|
...props,
|
|
341
|
-
focusInset: props.focusInset ||
|
|
507
|
+
focusInset: props.focusInset || splitButtonContext
|
|
342
508
|
};
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
return React__namespace.default.createElement(StyledButton, _extends$2({}, computedProps, {
|
|
355
|
-
ref: computedRef
|
|
509
|
+
return React__namespace.default.createElement(StyledButton, Object.assign({}, computedProps, {
|
|
510
|
+
ref: ref
|
|
356
511
|
}));
|
|
357
512
|
});
|
|
358
513
|
ButtonComponent.displayName = 'Button';
|
|
@@ -365,7 +520,6 @@ ButtonComponent.propTypes = {
|
|
|
365
520
|
focusInset: PropTypes__default.default.bool,
|
|
366
521
|
isLink: PropTypes__default.default.bool,
|
|
367
522
|
isStretched: PropTypes__default.default.bool,
|
|
368
|
-
isSelected: PropTypes__default.default.bool,
|
|
369
523
|
size: PropTypes__default.default.oneOf(SIZE)
|
|
370
524
|
};
|
|
371
525
|
ButtonComponent.defaultProps = {
|
|
@@ -396,7 +550,7 @@ const Anchor = React.forwardRef((_ref, ref) => {
|
|
|
396
550
|
noIconLabel: 'true'
|
|
397
551
|
};
|
|
398
552
|
const iconAriaLabel = reactTheming.useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
399
|
-
return React__namespace.default.createElement(StyledAnchor,
|
|
553
|
+
return React__namespace.default.createElement(StyledAnchor, Object.assign({
|
|
400
554
|
ref: ref
|
|
401
555
|
}, anchorProps), children, isExternal &&
|
|
402
556
|
React__namespace.default.createElement(StyledExternalIcon, {
|
|
@@ -412,58 +566,6 @@ Anchor.propTypes = {
|
|
|
412
566
|
externalIconLabel: PropTypes__default.default.string
|
|
413
567
|
};
|
|
414
568
|
|
|
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
569
|
const IconButton = React.forwardRef((_ref, ref) => {
|
|
468
570
|
let {
|
|
469
571
|
children,
|
|
@@ -471,12 +573,12 @@ const IconButton = React.forwardRef((_ref, ref) => {
|
|
|
471
573
|
...otherProps
|
|
472
574
|
} = _ref;
|
|
473
575
|
const focusInset = useSplitButtonContext();
|
|
474
|
-
return React__namespace.default.createElement(StyledIconButton,
|
|
576
|
+
return React__namespace.default.createElement(StyledIconButton, Object.assign({
|
|
475
577
|
ref: ref
|
|
476
578
|
}, otherProps, {
|
|
477
579
|
focusInset: otherProps.focusInset || focusInset
|
|
478
580
|
}), React__namespace.default.createElement(StyledIcon, {
|
|
479
|
-
isRotated: isRotated
|
|
581
|
+
$isRotated: isRotated
|
|
480
582
|
}, children));
|
|
481
583
|
});
|
|
482
584
|
IconButton.displayName = 'IconButton';
|
|
@@ -516,7 +618,7 @@ const ChevronButton = React.forwardRef((_ref, ref) => {
|
|
|
516
618
|
let {
|
|
517
619
|
...buttonProps
|
|
518
620
|
} = _ref;
|
|
519
|
-
return React__namespace.default.createElement(IconButton,
|
|
621
|
+
return React__namespace.default.createElement(IconButton, Object.assign({
|
|
520
622
|
ref: ref
|
|
521
623
|
}, buttonProps), React__namespace.default.createElement(SvgChevronDownStroke, null));
|
|
522
624
|
});
|
|
@@ -535,7 +637,7 @@ const SplitButton = React.forwardRef((_ref, ref) => {
|
|
|
535
637
|
} = _ref;
|
|
536
638
|
return React__namespace.default.createElement(SplitButtonContext.Provider, {
|
|
537
639
|
value: true
|
|
538
|
-
}, React__namespace.default.createElement(
|
|
640
|
+
}, React__namespace.default.createElement(StyledSplitButton, Object.assign({
|
|
539
641
|
ref: ref
|
|
540
642
|
}, other), children));
|
|
541
643
|
});
|
|
@@ -546,7 +648,7 @@ const ToggleButton = React.forwardRef((_ref, ref) => {
|
|
|
546
648
|
isPressed,
|
|
547
649
|
...otherProps
|
|
548
650
|
} = _ref;
|
|
549
|
-
return React__namespace.default.createElement(Button,
|
|
651
|
+
return React__namespace.default.createElement(Button, Object.assign({
|
|
550
652
|
"aria-pressed": isPressed,
|
|
551
653
|
ref: ref
|
|
552
654
|
}, otherProps));
|
|
@@ -565,7 +667,7 @@ const ToggleIconButton = React.forwardRef((_ref, ref) => {
|
|
|
565
667
|
isPressed,
|
|
566
668
|
...otherProps
|
|
567
669
|
} = _ref;
|
|
568
|
-
return React__namespace.default.createElement(IconButton,
|
|
670
|
+
return React__namespace.default.createElement(IconButton, Object.assign({
|
|
569
671
|
"aria-pressed": isPressed,
|
|
570
672
|
ref: ref
|
|
571
673
|
}, otherProps));
|
|
@@ -583,7 +685,6 @@ ToggleIconButton.defaultProps = {
|
|
|
583
685
|
|
|
584
686
|
exports.Anchor = Anchor;
|
|
585
687
|
exports.Button = Button;
|
|
586
|
-
exports.ButtonGroup = ButtonGroup;
|
|
587
688
|
exports.ChevronButton = ChevronButton;
|
|
588
689
|
exports.IconButton = IconButton;
|
|
589
690
|
exports.SplitButton = SplitButton;
|