@zendeskgarden/react-buttons 9.0.0-next.1 → 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
|
@@ -4,13 +4,13 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
7
8
|
import { DefaultTheme } from 'styled-components';
|
|
8
|
-
import React from 'react';
|
|
9
9
|
interface IStyledIconProps {
|
|
10
|
-
isRotated: boolean;
|
|
11
|
-
position?: 'start' | 'end';
|
|
10
|
+
$isRotated: boolean;
|
|
11
|
+
$position?: 'start' | 'end';
|
|
12
12
|
}
|
|
13
|
-
export declare const StyledIcon: import("styled-components").StyledComponent<({ children,
|
|
13
|
+
export declare const StyledIcon: import("styled-components").StyledComponent<({ children, theme, ...props }: any) => import("react").DetailedReactHTMLElement<any, HTMLElement>, DefaultTheme, {
|
|
14
14
|
'data-garden-id': string;
|
|
15
15
|
'data-garden-version': string;
|
|
16
16
|
} & IStyledIconProps, "data-garden-id" | "data-garden-version">;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Accepts all `<div>` props
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const StyledSplitButton: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
11
11
|
'data-garden-id': string;
|
|
12
12
|
'data-garden-version': string;
|
|
13
13
|
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import { AnchorHTMLAttributes, ButtonHTMLAttributes,
|
|
7
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, SVGAttributes } from 'react';
|
|
8
8
|
export declare const SIZE: readonly ["small", "medium", "large"];
|
|
9
9
|
export interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
10
|
/** Applies danger styling */
|
|
@@ -25,8 +25,6 @@ export interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
25
25
|
isPill?: boolean;
|
|
26
26
|
/** Applies inset `box-shadow` styling on focus */
|
|
27
27
|
focusInset?: boolean;
|
|
28
|
-
/** @ignore prop used by `ButtonGroup` */
|
|
29
|
-
isSelected?: boolean;
|
|
30
28
|
}
|
|
31
29
|
export interface IToggleButtonProps extends IButtonProps {
|
|
32
30
|
/**
|
|
@@ -56,13 +54,3 @@ export interface IAnchorProps extends Pick<IButtonProps, 'isDanger'>, AnchorHTML
|
|
|
56
54
|
**/
|
|
57
55
|
externalIconLabel?: string;
|
|
58
56
|
}
|
|
59
|
-
export interface IButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
60
|
-
/** Defines the currently selected button in the group */
|
|
61
|
-
selectedItem?: any;
|
|
62
|
-
/**
|
|
63
|
-
* Handles button selection
|
|
64
|
-
*
|
|
65
|
-
* @param {any} item The selected item
|
|
66
|
-
*/
|
|
67
|
-
onSelect?: (item: any) => void;
|
|
68
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-buttons",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.10",
|
|
4
4
|
"description": "Components relating to buttons in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "https://github.com/zendeskgarden/react-components/issues"
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.cjs.js",
|
|
13
|
-
"module": "dist/index.
|
|
13
|
+
"module": "dist/esm/index.js",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
@@ -21,20 +21,19 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"types": "dist/typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@zendeskgarden/container-selection": "^3.0.0",
|
|
25
24
|
"@zendeskgarden/container-utilities": "^2.0.0",
|
|
26
25
|
"polished": "^4.0.0",
|
|
27
26
|
"prop-types": "^15.5.7",
|
|
28
27
|
"react-merge-refs": "^2.0.0"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
31
|
-
"@zendeskgarden/react-theming": "
|
|
30
|
+
"@zendeskgarden/react-theming": ">=9.0.0-next",
|
|
32
31
|
"react": ">=16.8.0",
|
|
33
32
|
"react-dom": ">=16.8.0",
|
|
34
|
-
"styled-components": "^5.1
|
|
33
|
+
"styled-components": "^5.3.1"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
|
-
"@zendeskgarden/react-theming": "^9.0.0-next.
|
|
36
|
+
"@zendeskgarden/react-theming": "^9.0.0-next.10",
|
|
38
37
|
"@zendeskgarden/svg-icons": "7.0.0"
|
|
39
38
|
},
|
|
40
39
|
"keywords": [
|
|
@@ -47,5 +46,5 @@
|
|
|
47
46
|
"access": "public"
|
|
48
47
|
},
|
|
49
48
|
"zendeskgarden:src": "src/index.ts",
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "818e6100aa6676af7e972198b82516d330307d60"
|
|
51
50
|
}
|
package/dist/index.esm.js
DELETED
|
@@ -1,559 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright Zendesk, Inc.
|
|
3
|
-
*
|
|
4
|
-
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
-
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import React__default, { Children, createContext, useContext, forwardRef, useState, useMemo, isValidElement, useCallback } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { mergeRefs } from 'react-merge-refs';
|
|
12
|
-
import styled, { css, ThemeContext } from 'styled-components';
|
|
13
|
-
import { retrieveComponentStyles, DEFAULT_THEME, SELECTOR_FOCUS_VISIBLE, getColor, focusStyles, getFocusBoxShadow, useText } from '@zendeskgarden/react-theming';
|
|
14
|
-
import { rgba, math, em } from 'polished';
|
|
15
|
-
import { useSelection } from '@zendeskgarden/container-selection';
|
|
16
|
-
import { getControlledValue } from '@zendeskgarden/container-utilities';
|
|
17
|
-
|
|
18
|
-
function _extends$2() {
|
|
19
|
-
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
20
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
21
|
-
var source = arguments[i];
|
|
22
|
-
for (var key in source) {
|
|
23
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
24
|
-
target[key] = source[key];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return target;
|
|
29
|
-
};
|
|
30
|
-
return _extends$2.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const SIZE = ['small', 'medium', 'large'];
|
|
34
|
-
|
|
35
|
-
const COMPONENT_ID$5 = 'buttons.button_group_view';
|
|
36
|
-
const StyledButtonGroup = styled.div.attrs({
|
|
37
|
-
'data-garden-id': COMPONENT_ID$5,
|
|
38
|
-
'data-garden-version': '9.0.0-next.1'
|
|
39
|
-
}).withConfig({
|
|
40
|
-
displayName: "StyledButtonGroup",
|
|
41
|
-
componentId: "sc-1fbpzef-0"
|
|
42
|
-
})(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
43
|
-
StyledButtonGroup.defaultProps = {
|
|
44
|
-
theme: DEFAULT_THEME
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const COMPONENT_ID$4 = 'buttons.icon';
|
|
48
|
-
const sizeStyles$1 = props => {
|
|
49
|
-
let marginProperty;
|
|
50
|
-
if (props.position === 'start') {
|
|
51
|
-
marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
|
|
52
|
-
} else if (props.position === 'end') {
|
|
53
|
-
marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
|
|
54
|
-
}
|
|
55
|
-
return marginProperty && css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
|
|
56
|
-
};
|
|
57
|
-
const StyledIcon = styled(_ref => {
|
|
58
|
-
let {
|
|
59
|
-
children,
|
|
60
|
-
isRotated,
|
|
61
|
-
theme,
|
|
62
|
-
...props
|
|
63
|
-
} = _ref;
|
|
64
|
-
return React__default.cloneElement(Children.only(children), props);
|
|
65
|
-
}).attrs({
|
|
66
|
-
'data-garden-id': COMPONENT_ID$4,
|
|
67
|
-
'data-garden-version': '9.0.0-next.1'
|
|
68
|
-
}).withConfig({
|
|
69
|
-
displayName: "StyledIcon",
|
|
70
|
-
componentId: "sc-19meqgg-0"
|
|
71
|
-
})(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => props.isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, props => sizeStyles$1(props), props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
72
|
-
StyledIcon.defaultProps = {
|
|
73
|
-
theme: DEFAULT_THEME
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const COMPONENT_ID$3 = 'buttons.button';
|
|
77
|
-
const getBorderRadius = props => {
|
|
78
|
-
if (props.isPill) {
|
|
79
|
-
return '100px';
|
|
80
|
-
}
|
|
81
|
-
return props.theme.borderRadii.md;
|
|
82
|
-
};
|
|
83
|
-
const getDisabledBackgroundColor = props => {
|
|
84
|
-
return getColor('neutralHue', 200, props.theme);
|
|
85
|
-
};
|
|
86
|
-
const getHeight = props => {
|
|
87
|
-
if (props.size === 'small') {
|
|
88
|
-
return `${props.theme.space.base * 8}px`;
|
|
89
|
-
} else if (props.size === 'large') {
|
|
90
|
-
return `${props.theme.space.base * 12}px`;
|
|
91
|
-
}
|
|
92
|
-
return `${props.theme.space.base * 10}px`;
|
|
93
|
-
};
|
|
94
|
-
const colorStyles = props => {
|
|
95
|
-
let retVal;
|
|
96
|
-
let hue;
|
|
97
|
-
if (props.disabled || props.isNeutral && (props.isPrimary || props.isSelected) && !props.isDanger) {
|
|
98
|
-
hue = 'neutralHue';
|
|
99
|
-
} else if (props.isDanger) {
|
|
100
|
-
hue = 'dangerHue';
|
|
101
|
-
} else {
|
|
102
|
-
hue = 'primaryHue';
|
|
103
|
-
}
|
|
104
|
-
const shade = 600;
|
|
105
|
-
const baseColor = getColor(hue, shade, props.theme);
|
|
106
|
-
const hoverColor = getColor(hue, shade + 100, props.theme);
|
|
107
|
-
const activeColor = getColor(hue, shade + 200, props.theme);
|
|
108
|
-
const focusColor = getColor('primaryHue', shade, props.theme);
|
|
109
|
-
const disabledBackgroundColor = getDisabledBackgroundColor(props);
|
|
110
|
-
const disabledForegroundColor = getColor(hue, shade - 200, props.theme);
|
|
111
|
-
if (props.isLink) {
|
|
112
|
-
retVal = css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], baseColor, focusStyles({
|
|
113
|
-
theme: props.theme,
|
|
114
|
-
condition: false,
|
|
115
|
-
styles: {
|
|
116
|
-
color: baseColor,
|
|
117
|
-
outlineColor: focusColor
|
|
118
|
-
}
|
|
119
|
-
}), hoverColor, activeColor, disabledForegroundColor);
|
|
120
|
-
} else if (props.isPrimary || props.isSelected) {
|
|
121
|
-
retVal = css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], props.isPrimary && props.isSelected ? activeColor : baseColor, props.theme.palette.white, hoverColor, focusStyles({
|
|
122
|
-
theme: props.theme,
|
|
123
|
-
inset: props.focusInset,
|
|
124
|
-
shadowWidth: props.focusInset ? 'sm' : 'md',
|
|
125
|
-
spacerWidth: props.focusInset ? 'sm' : 'xs',
|
|
126
|
-
styles: props.isDanger && props.focusInset ? {
|
|
127
|
-
borderColor: focusColor
|
|
128
|
-
} : undefined
|
|
129
|
-
}), activeColor, props.isPrimary && activeColor, disabledBackgroundColor, disabledForegroundColor);
|
|
130
|
-
} else {
|
|
131
|
-
const borderColor = props.isNeutral && !props.isDanger ? getColor('neutralHue', 300, props.theme) : baseColor;
|
|
132
|
-
const foregroundColor = props.isNeutral ? props.theme.colors.foreground : baseColor;
|
|
133
|
-
const hoverBorderColor = props.isNeutral && !props.isDanger ? baseColor : hoverColor;
|
|
134
|
-
const hoverForegroundColor = props.isNeutral ? foregroundColor : hoverColor;
|
|
135
|
-
retVal = css(["outline-color:transparent;border-color:", ";background-color:transparent;color:", ";&:hover{border-color:", ";background-color:", ";color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{border-color:", ";background-color:", ";color:", ";}&:disabled{border-color:transparent;background-color:", ";color:", ";}& ", "{color:", ";}&:hover ", ",&:focus-visible ", ",&[data-garden-focus-visible] ", "{color:", ";}&:active ", "{color:", ";}&:disabled ", "{color:", ";}"], !props.isBasic && borderColor, foregroundColor, !props.isBasic && hoverBorderColor, rgba(baseColor, 0.08), hoverForegroundColor, focusStyles({
|
|
136
|
-
theme: props.theme,
|
|
137
|
-
inset: props.focusInset,
|
|
138
|
-
styles: props.isNeutral ? {
|
|
139
|
-
borderColor: baseColor
|
|
140
|
-
} : undefined
|
|
141
|
-
}), !props.isBasic && activeColor, rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && getColor('neutralHue', shade, props.theme), StyledIcon, StyledIcon, StyledIcon, props.isNeutral && getColor('neutralHue', shade + 100, props.theme), StyledIcon, props.isNeutral && foregroundColor, StyledIcon, disabledForegroundColor);
|
|
142
|
-
}
|
|
143
|
-
return retVal;
|
|
144
|
-
};
|
|
145
|
-
const groupStyles = props => {
|
|
146
|
-
const {
|
|
147
|
-
theme,
|
|
148
|
-
isPrimary,
|
|
149
|
-
isBasic,
|
|
150
|
-
isSelected,
|
|
151
|
-
isPill,
|
|
152
|
-
focusInset
|
|
153
|
-
} = props;
|
|
154
|
-
const {
|
|
155
|
-
rtl,
|
|
156
|
-
borderWidths,
|
|
157
|
-
borders
|
|
158
|
-
} = theme;
|
|
159
|
-
const startPosition = rtl ? 'right' : 'left';
|
|
160
|
-
const endPosition = rtl ? 'left' : 'right';
|
|
161
|
-
const marginOffset = borderWidths.sm;
|
|
162
|
-
const marginDisplacement = `${isPrimary || isBasic ? '' : '-'}${marginOffset}`;
|
|
163
|
-
const iconMarginDisplacement = isPill && '-2px';
|
|
164
|
-
const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
|
|
165
|
-
const borderColor = isBasic ? 'transparent' : 'revert';
|
|
166
|
-
const focusColor = getColor('primaryHue', 600, theme);
|
|
167
|
-
const focusBoxShadow = isBasic && !isSelected && !isPrimary && getFocusBoxShadow({
|
|
168
|
-
theme,
|
|
169
|
-
inset: focusInset,
|
|
170
|
-
spacerHue: focusColor,
|
|
171
|
-
hue: 'transparent'
|
|
172
|
-
});
|
|
173
|
-
return css(["position:relative;transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,margin-", " 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;border:", " ", ";", "{border-color:", ";box-shadow:", ";}&:hover,&:active,", "{z-index:1;}&:disabled{z-index:-1;background-color:", ";}&:not(:first-of-type){margin-", ":", ";}&:not(:first-of-type):disabled{margin-", ":", ";}&:not(:first-of-type):not(:last-of-type){border-radius:0;}&:first-of-type:not(:last-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:last-of-type:not(:first-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:first-of-type:not(:last-of-type) ", "{margin-", ":", ";}&:last-of-type:not(:first-of-type) ", "{margin-", ":", ";}"], startPosition, borders.sm, borderColor, SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
|
|
174
|
-
};
|
|
175
|
-
const iconStyles$1 = props => {
|
|
176
|
-
const size = props.size === 'small' ? props.theme.iconSizes.sm : props.theme.iconSizes.md;
|
|
177
|
-
return css(["width:", ";min-width:", ";height:", ";vertical-align:", ";"], size, size, size, props.isLink && 'middle');
|
|
178
|
-
};
|
|
179
|
-
const sizeStyles = props => {
|
|
180
|
-
let retVal;
|
|
181
|
-
if (props.isLink) {
|
|
182
|
-
retVal = css(["padding:0;font-size:inherit;"]);
|
|
183
|
-
} else {
|
|
184
|
-
const height = getHeight(props);
|
|
185
|
-
const lineHeight = math(`${height} - (${props.theme.borderWidths.sm} * 2)`);
|
|
186
|
-
let padding;
|
|
187
|
-
let fontSize;
|
|
188
|
-
if (props.size === 'small') {
|
|
189
|
-
fontSize = props.theme.fontSizes.sm;
|
|
190
|
-
padding = `${props.theme.space.base * 3}px`;
|
|
191
|
-
} else {
|
|
192
|
-
fontSize = props.theme.fontSizes.md;
|
|
193
|
-
if (props.size === 'large') {
|
|
194
|
-
padding = `${props.theme.space.base * 5}px`;
|
|
195
|
-
} else {
|
|
196
|
-
padding = `${props.theme.space.base * 4}px`;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
retVal = css(["padding:0 ", ";height:", ";line-height:", ";font-size:", ";"], em(math(`${padding} - ${props.theme.borderWidths.sm}`), fontSize), height, lineHeight, fontSize);
|
|
200
|
-
}
|
|
201
|
-
return retVal;
|
|
202
|
-
};
|
|
203
|
-
const StyledButton = styled.button.attrs(props => ({
|
|
204
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
205
|
-
'data-garden-version': '9.0.0-next.1',
|
|
206
|
-
type: props.type || 'button'
|
|
207
|
-
})).withConfig({
|
|
208
|
-
displayName: "StyledButton",
|
|
209
|
-
componentId: "sc-qe3ace-0"
|
|
210
|
-
})(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.isLink ? 'inline' : 'inline-flex', props => !props.isLink && 'center', props => !props.isLink && 'center', props => `${props.isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.isStretched ? '100%' : '', props => !props.isLink && 'nowrap', props => props.isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.isLink && 'none', props => sizeStyles(props), SELECTOR_FOCUS_VISIBLE, props => props.isLink ? 'underline' : 'none', props => props.isLink ? 'underline' : 'none', props => colorStyles(props), props => props.isLink && 'none', StyledIcon, props => iconStyles$1(props), StyledButtonGroup, props => groupStyles(props), props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
211
|
-
StyledButton.defaultProps = {
|
|
212
|
-
theme: DEFAULT_THEME
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const COMPONENT_ID$2 = 'buttons.anchor';
|
|
216
|
-
const StyledAnchor = styled(StyledButton).attrs(props => ({
|
|
217
|
-
'data-garden-id': COMPONENT_ID$2,
|
|
218
|
-
'data-garden-version': '9.0.0-next.1',
|
|
219
|
-
as: 'a',
|
|
220
|
-
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
221
|
-
isLink: true,
|
|
222
|
-
type: undefined
|
|
223
|
-
})).withConfig({
|
|
224
|
-
displayName: "StyledAnchor",
|
|
225
|
-
componentId: "sc-xshgmo-0"
|
|
226
|
-
})(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
227
|
-
StyledAnchor.defaultProps = {
|
|
228
|
-
theme: DEFAULT_THEME
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
var _path$1;
|
|
232
|
-
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
233
|
-
var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
234
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
235
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
236
|
-
width: 12,
|
|
237
|
-
height: 12,
|
|
238
|
-
focusable: "false",
|
|
239
|
-
viewBox: "0 0 12 12",
|
|
240
|
-
"aria-hidden": "true"
|
|
241
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
242
|
-
fill: "none",
|
|
243
|
-
stroke: "currentColor",
|
|
244
|
-
strokeLinecap: "round",
|
|
245
|
-
d: "M10.5 8.5V10c0 .3-.2.5-.5.5H2c-.3 0-.5-.2-.5-.5V2c0-.3.2-.5.5-.5h1.5M6 6l4-4m-3.5-.5H10c.3 0 .5.2.5.5v3.5"
|
|
246
|
-
})));
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
const COMPONENT_ID$1 = 'buttons.external_icon';
|
|
250
|
-
const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
|
|
251
|
-
'data-garden-id': COMPONENT_ID$1,
|
|
252
|
-
'data-garden-version': '9.0.0-next.1'
|
|
253
|
-
}).withConfig({
|
|
254
|
-
displayName: "StyledExternalIcon",
|
|
255
|
-
componentId: "sc-16oz07e-0"
|
|
256
|
-
})(["transform:", ";margin-bottom:-0.085em;padding-left:0.25em;box-sizing:content-box;width:0.85em;height:0.85em;", ";"], props => props.theme.rtl && 'scaleX(-1)', props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
257
|
-
StyledExternalIcon.defaultProps = {
|
|
258
|
-
theme: DEFAULT_THEME
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
const COMPONENT_ID = 'buttons.icon_button';
|
|
262
|
-
const iconColorStyles = props => {
|
|
263
|
-
const shade = 600;
|
|
264
|
-
const baseColor = getColor('neutralHue', shade, props.theme);
|
|
265
|
-
const hoverColor = getColor('neutralHue', shade + 100, props.theme);
|
|
266
|
-
const activeColor = getColor('neutralHue', shade + 200, props.theme);
|
|
267
|
-
return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
268
|
-
};
|
|
269
|
-
const iconButtonStyles = props => {
|
|
270
|
-
const width = getHeight(props);
|
|
271
|
-
return css(["border:", ";padding:0;width:", ";min-width:", ";", ";&:disabled{background-color:", ";}"], props.isBasic && 'none', width, width, props.isBasic && !(props.isPrimary || props.isDanger || props.disabled) && iconColorStyles(props), !props.isPrimary && 'transparent');
|
|
272
|
-
};
|
|
273
|
-
const iconStyles = props => {
|
|
274
|
-
const size = props.theme.iconSizes.md;
|
|
275
|
-
return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
|
|
276
|
-
};
|
|
277
|
-
const StyledIconButton = styled(StyledButton).attrs({
|
|
278
|
-
'data-garden-id': COMPONENT_ID,
|
|
279
|
-
'data-garden-version': '9.0.0-next.1'
|
|
280
|
-
}).withConfig({
|
|
281
|
-
displayName: "StyledIconButton",
|
|
282
|
-
componentId: "sc-1t0ughp-0"
|
|
283
|
-
})(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
284
|
-
StyledIconButton.defaultProps = {
|
|
285
|
-
theme: DEFAULT_THEME
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const ButtonGroupContext = createContext(undefined);
|
|
289
|
-
const useButtonGroupContext = () => {
|
|
290
|
-
return useContext(ButtonGroupContext);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const SplitButtonContext = createContext(undefined);
|
|
294
|
-
const useSplitButtonContext = () => {
|
|
295
|
-
return useContext(SplitButtonContext);
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
const StartIconComponent = props => React__default.createElement(StyledIcon, _extends$2({
|
|
299
|
-
position: "start"
|
|
300
|
-
}, props));
|
|
301
|
-
StartIconComponent.displayName = 'Button.StartIcon';
|
|
302
|
-
const StartIcon = StartIconComponent;
|
|
303
|
-
|
|
304
|
-
const EndIconComponent = props => React__default.createElement(StyledIcon, _extends$2({
|
|
305
|
-
position: "end"
|
|
306
|
-
}, props));
|
|
307
|
-
EndIconComponent.displayName = 'Button.EndIcon';
|
|
308
|
-
const EndIcon = EndIconComponent;
|
|
309
|
-
|
|
310
|
-
const ButtonComponent = forwardRef((props, ref) => {
|
|
311
|
-
const buttonGroupContext = useButtonGroupContext();
|
|
312
|
-
const splitButtonContext = useSplitButtonContext();
|
|
313
|
-
let computedRef = ref;
|
|
314
|
-
let computedProps = {
|
|
315
|
-
...props,
|
|
316
|
-
focusInset: props.focusInset || buttonGroupContext !== undefined || splitButtonContext
|
|
317
|
-
};
|
|
318
|
-
if (buttonGroupContext && !props.disabled) {
|
|
319
|
-
if (!props.value) {
|
|
320
|
-
throw new Error('"value" prop must be provided to Button when used within a ButtonGroup');
|
|
321
|
-
}
|
|
322
|
-
computedProps = buttonGroupContext.getButtonProps({
|
|
323
|
-
isSelected: props.value === buttonGroupContext.selectedItem,
|
|
324
|
-
...computedProps
|
|
325
|
-
});
|
|
326
|
-
computedRef = mergeRefs([
|
|
327
|
-
computedProps.ref, ref]);
|
|
328
|
-
}
|
|
329
|
-
return React__default.createElement(StyledButton, _extends$2({}, computedProps, {
|
|
330
|
-
ref: computedRef
|
|
331
|
-
}));
|
|
332
|
-
});
|
|
333
|
-
ButtonComponent.displayName = 'Button';
|
|
334
|
-
ButtonComponent.propTypes = {
|
|
335
|
-
isNeutral: PropTypes.bool,
|
|
336
|
-
isPrimary: PropTypes.bool,
|
|
337
|
-
isDanger: PropTypes.bool,
|
|
338
|
-
isPill: PropTypes.bool,
|
|
339
|
-
isBasic: PropTypes.bool,
|
|
340
|
-
focusInset: PropTypes.bool,
|
|
341
|
-
isLink: PropTypes.bool,
|
|
342
|
-
isStretched: PropTypes.bool,
|
|
343
|
-
isSelected: PropTypes.bool,
|
|
344
|
-
size: PropTypes.oneOf(SIZE)
|
|
345
|
-
};
|
|
346
|
-
ButtonComponent.defaultProps = {
|
|
347
|
-
size: 'medium'
|
|
348
|
-
};
|
|
349
|
-
const Button = ButtonComponent;
|
|
350
|
-
Button.EndIcon = EndIcon;
|
|
351
|
-
Button.StartIcon = StartIcon;
|
|
352
|
-
|
|
353
|
-
const Anchor = forwardRef((_ref, ref) => {
|
|
354
|
-
let {
|
|
355
|
-
children,
|
|
356
|
-
isExternal,
|
|
357
|
-
externalIconLabel,
|
|
358
|
-
...otherProps
|
|
359
|
-
} = _ref;
|
|
360
|
-
let anchorProps = otherProps;
|
|
361
|
-
if (isExternal) {
|
|
362
|
-
anchorProps = {
|
|
363
|
-
target: '_blank',
|
|
364
|
-
rel: 'noopener noreferrer',
|
|
365
|
-
...anchorProps
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
const checkProps = isExternal ? {
|
|
369
|
-
externalIconLabel
|
|
370
|
-
} : {
|
|
371
|
-
noIconLabel: 'true'
|
|
372
|
-
};
|
|
373
|
-
const iconAriaLabel = useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
374
|
-
return React__default.createElement(StyledAnchor, _extends$2({
|
|
375
|
-
ref: ref
|
|
376
|
-
}, anchorProps), children, isExternal &&
|
|
377
|
-
React__default.createElement(StyledExternalIcon, {
|
|
378
|
-
role: "img",
|
|
379
|
-
"aria-label": iconAriaLabel,
|
|
380
|
-
"aria-hidden": undefined
|
|
381
|
-
}));
|
|
382
|
-
});
|
|
383
|
-
Anchor.displayName = 'Anchor';
|
|
384
|
-
Anchor.propTypes = {
|
|
385
|
-
isExternal: PropTypes.bool,
|
|
386
|
-
isDanger: PropTypes.bool,
|
|
387
|
-
externalIconLabel: PropTypes.string
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
const ButtonGroup = forwardRef((_ref, ref) => {
|
|
391
|
-
let {
|
|
392
|
-
children,
|
|
393
|
-
onSelect,
|
|
394
|
-
selectedItem: controlledSelectedValue,
|
|
395
|
-
...otherProps
|
|
396
|
-
} = _ref;
|
|
397
|
-
const {
|
|
398
|
-
rtl
|
|
399
|
-
} = useContext(ThemeContext) || DEFAULT_THEME;
|
|
400
|
-
const [internalSelectedValue, setInternalSelectedValue] = useState();
|
|
401
|
-
const selectedValue = getControlledValue(controlledSelectedValue, internalSelectedValue);
|
|
402
|
-
const values = useMemo(() => Children.toArray(children).reduce((buttons, child) => {
|
|
403
|
-
if ( isValidElement(child) && child.type !== 'string' && !child.props.disabled) {
|
|
404
|
-
buttons.push(child.props.value);
|
|
405
|
-
}
|
|
406
|
-
return buttons;
|
|
407
|
-
}, []), [children]);
|
|
408
|
-
const {
|
|
409
|
-
selectedValue: selectedItem,
|
|
410
|
-
getElementProps,
|
|
411
|
-
getGroupProps
|
|
412
|
-
} = useSelection({
|
|
413
|
-
rtl,
|
|
414
|
-
values,
|
|
415
|
-
defaultSelectedValue: values[0],
|
|
416
|
-
selectedValue,
|
|
417
|
-
onSelect: useCallback(value => {
|
|
418
|
-
onSelect && onSelect(value);
|
|
419
|
-
setInternalSelectedValue(value);
|
|
420
|
-
}, [onSelect])
|
|
421
|
-
});
|
|
422
|
-
const contextValue = useMemo(() => ({
|
|
423
|
-
selectedItem,
|
|
424
|
-
getButtonProps: props => getElementProps({
|
|
425
|
-
role: 'button',
|
|
426
|
-
selectedAriaKey: 'aria-pressed',
|
|
427
|
-
...props
|
|
428
|
-
})
|
|
429
|
-
}), [selectedItem, getElementProps]);
|
|
430
|
-
return React__default.createElement(ButtonGroupContext.Provider, {
|
|
431
|
-
value: contextValue
|
|
432
|
-
}, React__default.createElement(StyledButtonGroup, _extends$2({
|
|
433
|
-
ref: ref
|
|
434
|
-
}, getGroupProps(otherProps)), children));
|
|
435
|
-
});
|
|
436
|
-
ButtonGroup.displayName = 'ButtonGroup';
|
|
437
|
-
ButtonGroup.propTypes = {
|
|
438
|
-
selectedItem: PropTypes.any,
|
|
439
|
-
onSelect: PropTypes.func
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const IconButton = forwardRef((_ref, ref) => {
|
|
443
|
-
let {
|
|
444
|
-
children,
|
|
445
|
-
isRotated,
|
|
446
|
-
...otherProps
|
|
447
|
-
} = _ref;
|
|
448
|
-
const focusInset = useSplitButtonContext();
|
|
449
|
-
return React__default.createElement(StyledIconButton, _extends$2({
|
|
450
|
-
ref: ref
|
|
451
|
-
}, otherProps, {
|
|
452
|
-
focusInset: otherProps.focusInset || focusInset
|
|
453
|
-
}), React__default.createElement(StyledIcon, {
|
|
454
|
-
isRotated: isRotated
|
|
455
|
-
}, children));
|
|
456
|
-
});
|
|
457
|
-
IconButton.displayName = 'IconButton';
|
|
458
|
-
IconButton.propTypes = {
|
|
459
|
-
isDanger: PropTypes.bool,
|
|
460
|
-
size: PropTypes.oneOf(SIZE),
|
|
461
|
-
isNeutral: PropTypes.bool,
|
|
462
|
-
isPrimary: PropTypes.bool,
|
|
463
|
-
isBasic: PropTypes.bool,
|
|
464
|
-
isPill: PropTypes.bool,
|
|
465
|
-
focusInset: PropTypes.bool,
|
|
466
|
-
isRotated: PropTypes.bool
|
|
467
|
-
};
|
|
468
|
-
IconButton.defaultProps = {
|
|
469
|
-
isPill: true,
|
|
470
|
-
isBasic: true,
|
|
471
|
-
size: 'medium'
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
var _path;
|
|
475
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
476
|
-
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
477
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
478
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
479
|
-
width: 16,
|
|
480
|
-
height: 16,
|
|
481
|
-
focusable: "false",
|
|
482
|
-
viewBox: "0 0 16 16",
|
|
483
|
-
"aria-hidden": "true"
|
|
484
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
485
|
-
fill: "currentColor",
|
|
486
|
-
d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
|
|
487
|
-
})));
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
const ChevronButton = forwardRef((_ref, ref) => {
|
|
491
|
-
let {
|
|
492
|
-
...buttonProps
|
|
493
|
-
} = _ref;
|
|
494
|
-
return React__default.createElement(IconButton, _extends$2({
|
|
495
|
-
ref: ref
|
|
496
|
-
}, buttonProps), React__default.createElement(SvgChevronDownStroke, null));
|
|
497
|
-
});
|
|
498
|
-
ChevronButton.displayName = 'ChevronButton';
|
|
499
|
-
ChevronButton.propTypes = IconButton.propTypes;
|
|
500
|
-
ChevronButton.defaultProps = {
|
|
501
|
-
isBasic: false,
|
|
502
|
-
isPill: false,
|
|
503
|
-
size: 'medium'
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
const SplitButton = forwardRef((_ref, ref) => {
|
|
507
|
-
let {
|
|
508
|
-
children,
|
|
509
|
-
...other
|
|
510
|
-
} = _ref;
|
|
511
|
-
return React__default.createElement(SplitButtonContext.Provider, {
|
|
512
|
-
value: true
|
|
513
|
-
}, React__default.createElement(StyledButtonGroup, _extends$2({
|
|
514
|
-
ref: ref
|
|
515
|
-
}, other), children));
|
|
516
|
-
});
|
|
517
|
-
SplitButton.displayName = 'SplitButton';
|
|
518
|
-
|
|
519
|
-
const ToggleButton = forwardRef((_ref, ref) => {
|
|
520
|
-
let {
|
|
521
|
-
isPressed,
|
|
522
|
-
...otherProps
|
|
523
|
-
} = _ref;
|
|
524
|
-
return React__default.createElement(Button, _extends$2({
|
|
525
|
-
"aria-pressed": isPressed,
|
|
526
|
-
ref: ref
|
|
527
|
-
}, otherProps));
|
|
528
|
-
});
|
|
529
|
-
ToggleButton.displayName = 'ToggleButton';
|
|
530
|
-
ToggleButton.propTypes = {
|
|
531
|
-
...Button.propTypes,
|
|
532
|
-
isPressed: PropTypes.oneOf([true, false, 'mixed'])
|
|
533
|
-
};
|
|
534
|
-
ToggleButton.defaultProps = {
|
|
535
|
-
size: 'medium'
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
const ToggleIconButton = forwardRef((_ref, ref) => {
|
|
539
|
-
let {
|
|
540
|
-
isPressed,
|
|
541
|
-
...otherProps
|
|
542
|
-
} = _ref;
|
|
543
|
-
return React__default.createElement(IconButton, _extends$2({
|
|
544
|
-
"aria-pressed": isPressed,
|
|
545
|
-
ref: ref
|
|
546
|
-
}, otherProps));
|
|
547
|
-
});
|
|
548
|
-
ToggleIconButton.displayName = 'ToggleIconButton';
|
|
549
|
-
ToggleIconButton.propTypes = {
|
|
550
|
-
...IconButton.propTypes,
|
|
551
|
-
isPressed: PropTypes.oneOf([true, false, 'mixed'])
|
|
552
|
-
};
|
|
553
|
-
ToggleIconButton.defaultProps = {
|
|
554
|
-
isPill: true,
|
|
555
|
-
isBasic: true,
|
|
556
|
-
size: 'medium'
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
export { Anchor, Button, ButtonGroup, ChevronButton, IconButton, SplitButton, ToggleButton, ToggleIconButton };
|