@zendeskgarden/react-buttons 9.0.0-next.0 → 9.0.0-next.10
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 +155 -0
- package/dist/esm/styled/StyledExternalIcon.js +23 -0
- package/dist/esm/styled/StyledIcon.js +31 -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 +75 -157
- 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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { StyledBaseIcon, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'buttons.icon';
|
|
11
|
+
const sizeStyles = props => {
|
|
12
|
+
let marginProperty;
|
|
13
|
+
if (props.$position === 'start') {
|
|
14
|
+
marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
|
|
15
|
+
} else if (props.$position === 'end') {
|
|
16
|
+
marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
|
|
17
|
+
}
|
|
18
|
+
return marginProperty && css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
|
|
19
|
+
};
|
|
20
|
+
const StyledIcon = styled(StyledBaseIcon).attrs({
|
|
21
|
+
'data-garden-id': COMPONENT_ID,
|
|
22
|
+
'data-garden-version': '9.0.0-next.10'
|
|
23
|
+
}).withConfig({
|
|
24
|
+
displayName: "StyledIcon",
|
|
25
|
+
componentId: "sc-19meqgg-0"
|
|
26
|
+
})(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => props.$isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
27
|
+
StyledIcon.defaultProps = {
|
|
28
|
+
theme: DEFAULT_THEME
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { StyledIcon };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledButton, getHeight } from './StyledButton.js';
|
|
10
|
+
import { StyledIcon } from './StyledIcon.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'buttons.icon_button';
|
|
13
|
+
const iconColorStyles = props => {
|
|
14
|
+
const shade = 600;
|
|
15
|
+
const baseColor = getColorV8('neutralHue', shade, props.theme);
|
|
16
|
+
const hoverColor = getColorV8('neutralHue', shade + 100, props.theme);
|
|
17
|
+
const activeColor = getColorV8('neutralHue', shade + 200, props.theme);
|
|
18
|
+
return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
19
|
+
};
|
|
20
|
+
const iconButtonStyles = props => {
|
|
21
|
+
const width = getHeight(props);
|
|
22
|
+
return css(["border:", ";padding:0;width:", ";min-width:", ";", ";&:disabled{background-color:", ";}"], props.isBasic && 'none', width, width, props.isBasic && !(props.isPrimary || props.isDanger || props.disabled) && iconColorStyles(props), !props.isPrimary && 'transparent');
|
|
23
|
+
};
|
|
24
|
+
const iconStyles = props => {
|
|
25
|
+
const size = props.theme.iconSizes.md;
|
|
26
|
+
return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
|
|
27
|
+
};
|
|
28
|
+
const StyledIconButton = styled(StyledButton).attrs({
|
|
29
|
+
'data-garden-id': COMPONENT_ID,
|
|
30
|
+
'data-garden-version': '9.0.0-next.10'
|
|
31
|
+
}).withConfig({
|
|
32
|
+
displayName: "StyledIconButton",
|
|
33
|
+
componentId: "sc-1t0ughp-0"
|
|
34
|
+
})(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
35
|
+
StyledIconButton.defaultProps = {
|
|
36
|
+
theme: DEFAULT_THEME
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { StyledIconButton };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'buttons.button_group_view';
|
|
11
|
+
const StyledSplitButton = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.10'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledSplitButton",
|
|
16
|
+
componentId: "sc-1u4v04v-0"
|
|
17
|
+
})(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledSplitButton.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledSplitButton };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const SplitButtonContext = createContext(undefined);
|
|
10
|
+
const useSplitButtonContext = () => {
|
|
11
|
+
return useContext(SplitButtonContext);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { SplitButtonContext, useSplitButtonContext };
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,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.10'
|
|
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.10'
|
|
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
|
};
|
|
@@ -106,7 +79,7 @@ const getBorderRadius = props => {
|
|
|
106
79
|
return props.theme.borderRadii.md;
|
|
107
80
|
};
|
|
108
81
|
const getDisabledBackgroundColor = props => {
|
|
109
|
-
return reactTheming.
|
|
82
|
+
return reactTheming.getColorV8('neutralHue', 200, props.theme);
|
|
110
83
|
};
|
|
111
84
|
const getHeight = props => {
|
|
112
85
|
if (props.size === 'small') {
|
|
@@ -119,7 +92,7 @@ const getHeight = props => {
|
|
|
119
92
|
const colorStyles = props => {
|
|
120
93
|
let retVal;
|
|
121
94
|
let hue;
|
|
122
|
-
if (props.disabled || props.isNeutral &&
|
|
95
|
+
if (props.disabled || props.isNeutral && props.isPrimary && !props.isDanger) {
|
|
123
96
|
hue = 'neutralHue';
|
|
124
97
|
} else if (props.isDanger) {
|
|
125
98
|
hue = 'dangerHue';
|
|
@@ -127,12 +100,12 @@ const colorStyles = props => {
|
|
|
127
100
|
hue = 'primaryHue';
|
|
128
101
|
}
|
|
129
102
|
const shade = 600;
|
|
130
|
-
const baseColor = reactTheming.
|
|
131
|
-
const hoverColor = reactTheming.
|
|
132
|
-
const activeColor = reactTheming.
|
|
133
|
-
const focusColor = reactTheming.
|
|
103
|
+
const baseColor = reactTheming.getColorV8(hue, shade, props.theme);
|
|
104
|
+
const hoverColor = reactTheming.getColorV8(hue, shade + 100, props.theme);
|
|
105
|
+
const activeColor = reactTheming.getColorV8(hue, shade + 200, props.theme);
|
|
106
|
+
const focusColor = reactTheming.getColorV8('primaryHue', shade, props.theme);
|
|
134
107
|
const disabledBackgroundColor = getDisabledBackgroundColor(props);
|
|
135
|
-
const disabledForegroundColor = reactTheming.
|
|
108
|
+
const disabledForegroundColor = reactTheming.getColorV8(hue, shade - 200, props.theme);
|
|
136
109
|
if (props.isLink) {
|
|
137
110
|
retVal = styled.css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], baseColor, reactTheming.focusStyles({
|
|
138
111
|
theme: props.theme,
|
|
@@ -142,8 +115,8 @@ const colorStyles = props => {
|
|
|
142
115
|
outlineColor: focusColor
|
|
143
116
|
}
|
|
144
117
|
}), hoverColor, activeColor, disabledForegroundColor);
|
|
145
|
-
} else if (props.isPrimary
|
|
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:", ";}"],
|
|
118
|
+
} else if (props.isPrimary) {
|
|
119
|
+
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
120
|
theme: props.theme,
|
|
148
121
|
inset: props.focusInset,
|
|
149
122
|
shadowWidth: props.focusInset ? 'sm' : 'md',
|
|
@@ -153,17 +126,17 @@ const colorStyles = props => {
|
|
|
153
126
|
} : undefined
|
|
154
127
|
}), activeColor, props.isPrimary && activeColor, disabledBackgroundColor, disabledForegroundColor);
|
|
155
128
|
} else {
|
|
156
|
-
const borderColor = props.isNeutral && !props.isDanger ? reactTheming.
|
|
157
|
-
const foregroundColor = props.isNeutral ? props.theme
|
|
129
|
+
const borderColor = props.isNeutral && !props.isDanger ? reactTheming.getColorV8('neutralHue', 300, props.theme) : baseColor;
|
|
130
|
+
const foregroundColor = props.isNeutral ? reactTheming.getColorV8('foreground', 600 , props.theme) : baseColor;
|
|
158
131
|
const hoverBorderColor = props.isNeutral && !props.isDanger ? baseColor : hoverColor;
|
|
159
132
|
const hoverForegroundColor = props.isNeutral ? foregroundColor : hoverColor;
|
|
160
|
-
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 ", "
|
|
133
|
+
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:", ";}"], !props.isBasic && borderColor, foregroundColor, !props.isBasic && hoverBorderColor, polished.rgba(baseColor, 0.08), hoverForegroundColor, reactTheming.focusStyles({
|
|
161
134
|
theme: props.theme,
|
|
162
135
|
inset: props.focusInset,
|
|
163
136
|
styles: props.isNeutral ? {
|
|
164
137
|
borderColor: baseColor
|
|
165
138
|
} : undefined
|
|
166
|
-
}), !props.isBasic && activeColor, polished.rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && reactTheming.
|
|
139
|
+
}), !props.isBasic && activeColor, polished.rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && reactTheming.getColorV8('neutralHue', shade, props.theme), StyledIcon, StyledIcon, props.isNeutral && reactTheming.getColorV8('neutralHue', shade + 100, props.theme), StyledIcon, props.isNeutral && foregroundColor, StyledIcon, disabledForegroundColor);
|
|
167
140
|
}
|
|
168
141
|
return retVal;
|
|
169
142
|
};
|
|
@@ -172,7 +145,6 @@ const groupStyles = props => {
|
|
|
172
145
|
theme,
|
|
173
146
|
isPrimary,
|
|
174
147
|
isBasic,
|
|
175
|
-
isSelected,
|
|
176
148
|
isPill,
|
|
177
149
|
focusInset
|
|
178
150
|
} = props;
|
|
@@ -188,12 +160,16 @@ const groupStyles = props => {
|
|
|
188
160
|
const iconMarginDisplacement = isPill && '-2px';
|
|
189
161
|
const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
|
|
190
162
|
const borderColor = isBasic ? 'transparent' : 'revert';
|
|
191
|
-
const focusColor = reactTheming.
|
|
192
|
-
const focusBoxShadow = isBasic && !
|
|
163
|
+
const focusColor = reactTheming.getColorV8('primaryHue', 600, theme);
|
|
164
|
+
const focusBoxShadow = isBasic && !isPrimary && reactTheming.getFocusBoxShadow({
|
|
193
165
|
theme,
|
|
194
166
|
inset: focusInset,
|
|
195
|
-
|
|
196
|
-
|
|
167
|
+
spacerColor: {
|
|
168
|
+
hue: focusColor
|
|
169
|
+
},
|
|
170
|
+
color: {
|
|
171
|
+
hue: 'transparent'
|
|
172
|
+
}
|
|
197
173
|
});
|
|
198
174
|
return styled.css(["position:relative;transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,margin-", " 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;border:", " ", ";", "{border-color:", ";box-shadow:", ";}&:hover,&:active,", "{z-index:1;}&:disabled{z-index:-1;background-color:", ";}&:not(:first-of-type){margin-", ":", ";}&:not(:first-of-type):disabled{margin-", ":", ";}&:not(:first-of-type):not(:last-of-type){border-radius:0;}&:first-of-type:not(:last-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:last-of-type:not(:first-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:first-of-type:not(:last-of-type) ", "{margin-", ":", ";}&:last-of-type:not(:first-of-type) ", "{margin-", ":", ";}"], startPosition, borders.sm, borderColor, reactTheming.SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, reactTheming.SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
|
|
199
175
|
};
|
|
@@ -227,12 +203,12 @@ const sizeStyles = props => {
|
|
|
227
203
|
};
|
|
228
204
|
const StyledButton = styled__default.default.button.attrs(props => ({
|
|
229
205
|
'data-garden-id': COMPONENT_ID$3,
|
|
230
|
-
'data-garden-version': '9.0.0-next.
|
|
206
|
+
'data-garden-version': '9.0.0-next.10',
|
|
231
207
|
type: props.type || 'button'
|
|
232
208
|
})).withConfig({
|
|
233
209
|
displayName: "StyledButton",
|
|
234
210
|
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),
|
|
211
|
+
})(["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
212
|
StyledButton.defaultProps = {
|
|
237
213
|
theme: reactTheming.DEFAULT_THEME
|
|
238
214
|
};
|
|
@@ -240,7 +216,7 @@ StyledButton.defaultProps = {
|
|
|
240
216
|
const COMPONENT_ID$2 = 'buttons.anchor';
|
|
241
217
|
const StyledAnchor = styled__default.default(StyledButton).attrs(props => ({
|
|
242
218
|
'data-garden-id': COMPONENT_ID$2,
|
|
243
|
-
'data-garden-version': '9.0.0-next.
|
|
219
|
+
'data-garden-version': '9.0.0-next.10',
|
|
244
220
|
as: 'a',
|
|
245
221
|
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
246
222
|
isLink: true,
|
|
@@ -274,7 +250,7 @@ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
|
274
250
|
const COMPONENT_ID$1 = 'buttons.external_icon';
|
|
275
251
|
const StyledExternalIcon = styled__default.default(SvgNewWindowStroke).attrs({
|
|
276
252
|
'data-garden-id': COMPONENT_ID$1,
|
|
277
|
-
'data-garden-version': '9.0.0-next.
|
|
253
|
+
'data-garden-version': '9.0.0-next.10'
|
|
278
254
|
}).withConfig({
|
|
279
255
|
displayName: "StyledExternalIcon",
|
|
280
256
|
componentId: "sc-16oz07e-0"
|
|
@@ -286,9 +262,9 @@ StyledExternalIcon.defaultProps = {
|
|
|
286
262
|
const COMPONENT_ID = 'buttons.icon_button';
|
|
287
263
|
const iconColorStyles = props => {
|
|
288
264
|
const shade = 600;
|
|
289
|
-
const baseColor = reactTheming.
|
|
290
|
-
const hoverColor = reactTheming.
|
|
291
|
-
const activeColor = reactTheming.
|
|
265
|
+
const baseColor = reactTheming.getColorV8('neutralHue', shade, props.theme);
|
|
266
|
+
const hoverColor = reactTheming.getColorV8('neutralHue', shade + 100, props.theme);
|
|
267
|
+
const activeColor = reactTheming.getColorV8('neutralHue', shade + 200, props.theme);
|
|
292
268
|
return styled.css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
293
269
|
};
|
|
294
270
|
const iconButtonStyles = props => {
|
|
@@ -301,7 +277,7 @@ const iconStyles = props => {
|
|
|
301
277
|
};
|
|
302
278
|
const StyledIconButton = styled__default.default(StyledButton).attrs({
|
|
303
279
|
'data-garden-id': COMPONENT_ID,
|
|
304
|
-
'data-garden-version': '9.0.0-next.
|
|
280
|
+
'data-garden-version': '9.0.0-next.10'
|
|
305
281
|
}).withConfig({
|
|
306
282
|
displayName: "StyledIconButton",
|
|
307
283
|
componentId: "sc-1t0ughp-0"
|
|
@@ -310,49 +286,45 @@ StyledIconButton.defaultProps = {
|
|
|
310
286
|
theme: reactTheming.DEFAULT_THEME
|
|
311
287
|
};
|
|
312
288
|
|
|
313
|
-
const ButtonGroupContext = React.createContext(undefined);
|
|
314
|
-
const useButtonGroupContext = () => {
|
|
315
|
-
return React.useContext(ButtonGroupContext);
|
|
316
|
-
};
|
|
317
|
-
|
|
318
289
|
const SplitButtonContext = React.createContext(undefined);
|
|
319
290
|
const useSplitButtonContext = () => {
|
|
320
291
|
return React.useContext(SplitButtonContext);
|
|
321
292
|
};
|
|
322
293
|
|
|
323
|
-
const StartIconComponent =
|
|
324
|
-
|
|
325
|
-
|
|
294
|
+
const StartIconComponent = _ref => {
|
|
295
|
+
let {
|
|
296
|
+
isRotated,
|
|
297
|
+
...props
|
|
298
|
+
} = _ref;
|
|
299
|
+
return React__namespace.default.createElement(StyledIcon, Object.assign({
|
|
300
|
+
$position: "start",
|
|
301
|
+
$isRotated: isRotated
|
|
302
|
+
}, props));
|
|
303
|
+
};
|
|
326
304
|
StartIconComponent.displayName = 'Button.StartIcon';
|
|
327
305
|
const StartIcon = StartIconComponent;
|
|
328
306
|
|
|
329
|
-
const EndIconComponent =
|
|
330
|
-
|
|
331
|
-
|
|
307
|
+
const EndIconComponent = _ref => {
|
|
308
|
+
let {
|
|
309
|
+
isRotated,
|
|
310
|
+
...props
|
|
311
|
+
} = _ref;
|
|
312
|
+
return React__namespace.default.createElement(StyledIcon, Object.assign({
|
|
313
|
+
$position: "end",
|
|
314
|
+
$isRotated: isRotated
|
|
315
|
+
}, props));
|
|
316
|
+
};
|
|
332
317
|
EndIconComponent.displayName = 'Button.EndIcon';
|
|
333
318
|
const EndIcon = EndIconComponent;
|
|
334
319
|
|
|
335
320
|
const ButtonComponent = React.forwardRef((props, ref) => {
|
|
336
|
-
const buttonGroupContext = useButtonGroupContext();
|
|
337
321
|
const splitButtonContext = useSplitButtonContext();
|
|
338
|
-
|
|
339
|
-
let computedProps = {
|
|
322
|
+
const computedProps = {
|
|
340
323
|
...props,
|
|
341
|
-
focusInset: props.focusInset ||
|
|
324
|
+
focusInset: props.focusInset || splitButtonContext
|
|
342
325
|
};
|
|
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
|
|
326
|
+
return React__namespace.default.createElement(StyledButton, Object.assign({}, computedProps, {
|
|
327
|
+
ref: ref
|
|
356
328
|
}));
|
|
357
329
|
});
|
|
358
330
|
ButtonComponent.displayName = 'Button';
|
|
@@ -365,7 +337,6 @@ ButtonComponent.propTypes = {
|
|
|
365
337
|
focusInset: PropTypes__default.default.bool,
|
|
366
338
|
isLink: PropTypes__default.default.bool,
|
|
367
339
|
isStretched: PropTypes__default.default.bool,
|
|
368
|
-
isSelected: PropTypes__default.default.bool,
|
|
369
340
|
size: PropTypes__default.default.oneOf(SIZE)
|
|
370
341
|
};
|
|
371
342
|
ButtonComponent.defaultProps = {
|
|
@@ -396,7 +367,7 @@ const Anchor = React.forwardRef((_ref, ref) => {
|
|
|
396
367
|
noIconLabel: 'true'
|
|
397
368
|
};
|
|
398
369
|
const iconAriaLabel = reactTheming.useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
399
|
-
return React__namespace.default.createElement(StyledAnchor,
|
|
370
|
+
return React__namespace.default.createElement(StyledAnchor, Object.assign({
|
|
400
371
|
ref: ref
|
|
401
372
|
}, anchorProps), children, isExternal &&
|
|
402
373
|
React__namespace.default.createElement(StyledExternalIcon, {
|
|
@@ -412,58 +383,6 @@ Anchor.propTypes = {
|
|
|
412
383
|
externalIconLabel: PropTypes__default.default.string
|
|
413
384
|
};
|
|
414
385
|
|
|
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
386
|
const IconButton = React.forwardRef((_ref, ref) => {
|
|
468
387
|
let {
|
|
469
388
|
children,
|
|
@@ -471,12 +390,12 @@ const IconButton = React.forwardRef((_ref, ref) => {
|
|
|
471
390
|
...otherProps
|
|
472
391
|
} = _ref;
|
|
473
392
|
const focusInset = useSplitButtonContext();
|
|
474
|
-
return React__namespace.default.createElement(StyledIconButton,
|
|
393
|
+
return React__namespace.default.createElement(StyledIconButton, Object.assign({
|
|
475
394
|
ref: ref
|
|
476
395
|
}, otherProps, {
|
|
477
396
|
focusInset: otherProps.focusInset || focusInset
|
|
478
397
|
}), React__namespace.default.createElement(StyledIcon, {
|
|
479
|
-
isRotated: isRotated
|
|
398
|
+
$isRotated: isRotated
|
|
480
399
|
}, children));
|
|
481
400
|
});
|
|
482
401
|
IconButton.displayName = 'IconButton';
|
|
@@ -516,7 +435,7 @@ const ChevronButton = React.forwardRef((_ref, ref) => {
|
|
|
516
435
|
let {
|
|
517
436
|
...buttonProps
|
|
518
437
|
} = _ref;
|
|
519
|
-
return React__namespace.default.createElement(IconButton,
|
|
438
|
+
return React__namespace.default.createElement(IconButton, Object.assign({
|
|
520
439
|
ref: ref
|
|
521
440
|
}, buttonProps), React__namespace.default.createElement(SvgChevronDownStroke, null));
|
|
522
441
|
});
|
|
@@ -535,7 +454,7 @@ const SplitButton = React.forwardRef((_ref, ref) => {
|
|
|
535
454
|
} = _ref;
|
|
536
455
|
return React__namespace.default.createElement(SplitButtonContext.Provider, {
|
|
537
456
|
value: true
|
|
538
|
-
}, React__namespace.default.createElement(
|
|
457
|
+
}, React__namespace.default.createElement(StyledSplitButton, Object.assign({
|
|
539
458
|
ref: ref
|
|
540
459
|
}, other), children));
|
|
541
460
|
});
|
|
@@ -546,7 +465,7 @@ const ToggleButton = React.forwardRef((_ref, ref) => {
|
|
|
546
465
|
isPressed,
|
|
547
466
|
...otherProps
|
|
548
467
|
} = _ref;
|
|
549
|
-
return React__namespace.default.createElement(Button,
|
|
468
|
+
return React__namespace.default.createElement(Button, Object.assign({
|
|
550
469
|
"aria-pressed": isPressed,
|
|
551
470
|
ref: ref
|
|
552
471
|
}, otherProps));
|
|
@@ -565,7 +484,7 @@ const ToggleIconButton = React.forwardRef((_ref, ref) => {
|
|
|
565
484
|
isPressed,
|
|
566
485
|
...otherProps
|
|
567
486
|
} = _ref;
|
|
568
|
-
return React__namespace.default.createElement(IconButton,
|
|
487
|
+
return React__namespace.default.createElement(IconButton, Object.assign({
|
|
569
488
|
"aria-pressed": isPressed,
|
|
570
489
|
ref: ref
|
|
571
490
|
}, otherProps));
|
|
@@ -583,7 +502,6 @@ ToggleIconButton.defaultProps = {
|
|
|
583
502
|
|
|
584
503
|
exports.Anchor = Anchor;
|
|
585
504
|
exports.Button = Button;
|
|
586
|
-
exports.ButtonGroup = ButtonGroup;
|
|
587
505
|
exports.ChevronButton = ChevronButton;
|
|
588
506
|
exports.IconButton = IconButton;
|
|
589
507
|
exports.SplitButton = SplitButton;
|
|
@@ -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
|
|
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
|
*/
|
|
@@ -10,6 +10,6 @@ import { IButtonIconProps } from '../../types';
|
|
|
10
10
|
* @extends SVGAttributes<SVGElement>
|
|
11
11
|
*/
|
|
12
12
|
export declare const EndIcon: {
|
|
13
|
-
(props: IButtonIconProps): React.JSX.Element;
|
|
13
|
+
({ isRotated, ...props }: IButtonIconProps): React.JSX.Element;
|
|
14
14
|
displayName: string;
|
|
15
15
|
};
|
|
@@ -10,6 +10,6 @@ import { IButtonIconProps } from '../../types';
|
|
|
10
10
|
* @extends SVGAttributes<SVGElement>
|
|
11
11
|
*/
|
|
12
12
|
export declare const StartIcon: {
|
|
13
|
-
(props: IButtonIconProps): React.JSX.Element;
|
|
13
|
+
({ isRotated, ...props }: IButtonIconProps): React.JSX.Element;
|
|
14
14
|
displayName: string;
|
|
15
15
|
};
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
14
|
+
export type { IButtonProps, IButtonIconProps as IButtonEndIconProps, IButtonIconProps as IButtonStartIconProps, IAnchorProps, IIconButtonProps, IIconButtonProps as IChevronButtonProps, IToggleButtonProps, IToggleIconButtonProps } from './types';
|
|
@@ -14,4 +14,4 @@ export declare const StyledAnchor: import("styled-components").StyledComponent<"
|
|
|
14
14
|
dir: "rtl" | undefined;
|
|
15
15
|
isLink: boolean;
|
|
16
16
|
type: undefined;
|
|
17
|
-
}, "type" | "dir" | "data-garden-id" | "data-garden-version" | "
|
|
17
|
+
}, "type" | "dir" | "as" | "data-garden-id" | "data-garden-version" | "isLink">;
|