@atlaskit/smart-card 21.0.2 → 21.0.3
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/CHANGELOG.md +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-button/index.js +87 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-button/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +31 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/index.js +52 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +42 -104
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +44 -15
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +12 -1
- package/dist/cjs/view/FlexibleCard/components/utils.js +7 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-button/index.js +88 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-button/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +18 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/index.js +35 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +26 -110
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +31 -12
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +12 -2
- package/dist/es2019/view/FlexibleCard/components/utils.js +6 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/action-button/index.js +67 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-button/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +19 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/index.js +39 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/index.js +41 -99
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +44 -16
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +12 -1
- package/dist/esm/view/FlexibleCard/components/utils.js +3 -1
- package/dist/types/view/FlexibleCard/components/actions/action/action-button/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-button/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-dropdown-item/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-dropdown-item/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-icon/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-icon/types.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +0 -3
- package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +0 -16
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -0
- package/package.json +8 -5
- package/report.api.md +32 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DropdownItem } from '@atlaskit/dropdown-menu';
|
|
3
|
+
import { handleOnClick } from '../../../../../../utils';
|
|
4
|
+
|
|
5
|
+
const ActionDropdownItem = ({
|
|
6
|
+
content,
|
|
7
|
+
iconAfter,
|
|
8
|
+
iconBefore,
|
|
9
|
+
onClick,
|
|
10
|
+
testId
|
|
11
|
+
}) => /*#__PURE__*/React.createElement(DropdownItem, {
|
|
12
|
+
elemAfter: iconAfter,
|
|
13
|
+
elemBefore: iconBefore,
|
|
14
|
+
onClick: handleOnClick(onClick),
|
|
15
|
+
testId: testId
|
|
16
|
+
}, content);
|
|
17
|
+
|
|
18
|
+
export default ActionDropdownItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
5
|
+
import { tokens } from '../../../../../../utils/token';
|
|
6
|
+
import { getIconSizeStyles } from '../../../utils';
|
|
7
|
+
|
|
8
|
+
const getIconWidth = size => {
|
|
9
|
+
switch (size) {
|
|
10
|
+
case SmartLinkSize.XLarge:
|
|
11
|
+
case SmartLinkSize.Large:
|
|
12
|
+
return '1.5rem';
|
|
13
|
+
|
|
14
|
+
case SmartLinkSize.Medium:
|
|
15
|
+
case SmartLinkSize.Small:
|
|
16
|
+
default:
|
|
17
|
+
return '1rem';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getIconStyles = size => css`
|
|
22
|
+
color: ${tokens.actionIcon};
|
|
23
|
+
${getIconSizeStyles(getIconWidth(size))};
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const ActionIcon = ({
|
|
27
|
+
size,
|
|
28
|
+
testId,
|
|
29
|
+
icon
|
|
30
|
+
}) => jsx("span", {
|
|
31
|
+
css: getIconStyles(size),
|
|
32
|
+
"data-testid": `${testId}-icon`
|
|
33
|
+
}, icon);
|
|
34
|
+
|
|
35
|
+
export default ActionIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,88 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import Button from '@atlaskit/button/custom-theme-button';
|
|
3
|
+
import { jsx } from '@emotion/core';
|
|
5
4
|
import { SmartLinkSize } from '../../../../../constants';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { tokens } from '../../../../../utils/token';
|
|
10
|
-
import { handleOnClick } from '../../../../../utils';
|
|
11
|
-
|
|
12
|
-
const getIconWidth = size => {
|
|
13
|
-
switch (size) {
|
|
14
|
-
case SmartLinkSize.XLarge:
|
|
15
|
-
case SmartLinkSize.Large:
|
|
16
|
-
return '1.5rem';
|
|
17
|
-
|
|
18
|
-
case SmartLinkSize.Medium:
|
|
19
|
-
case SmartLinkSize.Small:
|
|
20
|
-
default:
|
|
21
|
-
return '1rem';
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getIconStyles = size => css`
|
|
26
|
-
color: ${tokens.actionIcon};
|
|
27
|
-
${getIconSizeStyles(getIconWidth(size))};
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const getButtonStyle = (size, iconOnly) => {
|
|
31
|
-
switch (size) {
|
|
32
|
-
case SmartLinkSize.Large:
|
|
33
|
-
return iconOnly ? css`
|
|
34
|
-
button,
|
|
35
|
-
button:hover,
|
|
36
|
-
button:focus,
|
|
37
|
-
button:active {
|
|
38
|
-
padding: 0;
|
|
39
|
-
> span {
|
|
40
|
-
margin: 0;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
` : '';
|
|
44
|
-
|
|
45
|
-
case SmartLinkSize.Small:
|
|
46
|
-
return css`
|
|
47
|
-
font-size: 0.75rem;
|
|
48
|
-
font-weight: 500;
|
|
49
|
-
line-height: 1rem;
|
|
50
|
-
button,
|
|
51
|
-
button:hover,
|
|
52
|
-
button:focus,
|
|
53
|
-
button:active {
|
|
54
|
-
line-height: 1rem;
|
|
55
|
-
${iconOnly ? `
|
|
56
|
-
padding: 0.125rem;
|
|
57
|
-
` : `
|
|
58
|
-
padding-left: 0.25rem;
|
|
59
|
-
padding-right: 0.25rem;
|
|
60
|
-
`}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
case SmartLinkSize.XLarge:
|
|
65
|
-
case SmartLinkSize.Medium:
|
|
66
|
-
default:
|
|
67
|
-
return '';
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const ActionIcon = ({
|
|
72
|
-
size,
|
|
73
|
-
testId,
|
|
74
|
-
icon
|
|
75
|
-
}) => jsx("span", {
|
|
76
|
-
css: getIconStyles(size),
|
|
77
|
-
"data-testid": `${testId}-icon`
|
|
78
|
-
}, icon);
|
|
79
|
-
|
|
80
|
-
export const sizeToSpacing = {
|
|
81
|
-
[SmartLinkSize.Small]: 'none',
|
|
82
|
-
[SmartLinkSize.Medium]: 'compact',
|
|
83
|
-
[SmartLinkSize.Large]: 'compact',
|
|
84
|
-
[SmartLinkSize.XLarge]: 'default'
|
|
85
|
-
};
|
|
5
|
+
import ActionButton from './action-button';
|
|
6
|
+
import ActionDropdownItem from './action-dropdown-item';
|
|
7
|
+
import ActionIcon from './action-icon';
|
|
86
8
|
/**
|
|
87
9
|
* A base action that can be triggered with an on click.
|
|
88
10
|
* @internal
|
|
@@ -108,40 +30,34 @@ const Action = ({
|
|
|
108
30
|
return null;
|
|
109
31
|
}
|
|
110
32
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
testId: testId,
|
|
114
|
-
icon: icon
|
|
115
|
-
}) : undefined;
|
|
116
|
-
const iconAfter = icon && iconPosition === 'after' ? jsx(ActionIcon, {
|
|
33
|
+
const actionIcon = icon && jsx(ActionIcon, {
|
|
34
|
+
icon: icon,
|
|
117
35
|
size: size,
|
|
118
|
-
testId: testId
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
36
|
+
testId: testId
|
|
37
|
+
});
|
|
38
|
+
const iconBefore = icon && iconPosition === 'before' ? actionIcon : undefined;
|
|
39
|
+
const iconAfter = icon && iconPosition === 'after' ? actionIcon : undefined;
|
|
122
40
|
|
|
123
41
|
if (asDropDownItem) {
|
|
124
|
-
return jsx(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
onClick:
|
|
129
|
-
|
|
42
|
+
return jsx(ActionDropdownItem, {
|
|
43
|
+
content: content,
|
|
44
|
+
iconAfter: iconAfter,
|
|
45
|
+
iconBefore: iconBefore,
|
|
46
|
+
onClick: onClick,
|
|
47
|
+
testId: testId
|
|
48
|
+
});
|
|
130
49
|
} else {
|
|
131
|
-
return jsx(
|
|
132
|
-
content: tooltipMessage,
|
|
133
|
-
testId: `${testId}-tooltip`
|
|
134
|
-
}, jsx("div", {
|
|
135
|
-
css: [getButtonStyle(size, iconOnly), overrideCss],
|
|
136
|
-
"data-testid": `${testId}-button-wrapper`
|
|
137
|
-
}, jsx(Button, {
|
|
138
|
-
spacing: sizeToSpacing[size],
|
|
50
|
+
return jsx(ActionButton, {
|
|
139
51
|
appearance: appearance,
|
|
140
|
-
|
|
141
|
-
|
|
52
|
+
content: content,
|
|
53
|
+
iconAfter: iconAfter,
|
|
142
54
|
iconBefore: iconBefore,
|
|
143
|
-
|
|
144
|
-
|
|
55
|
+
onClick: onClick,
|
|
56
|
+
overrideCss: overrideCss,
|
|
57
|
+
size: size,
|
|
58
|
+
testId: testId,
|
|
59
|
+
tooltipMessage: tooltipMessage
|
|
60
|
+
});
|
|
145
61
|
}
|
|
146
62
|
};
|
|
147
63
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { useCallback } from 'react';
|
|
4
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
5
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
6
6
|
import { css, jsx } from '@emotion/core';
|
|
7
7
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
@@ -11,7 +11,7 @@ import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
|
11
11
|
import { SmartLinkSize } from '../../../../../constants';
|
|
12
12
|
import Button from '@atlaskit/button/standard-button';
|
|
13
13
|
import MoreIcon from '@atlaskit/icon/glyph/more';
|
|
14
|
-
import {
|
|
14
|
+
import { sizeToButtonSpacing } from '../../utils';
|
|
15
15
|
import { tokens } from '../../../../../utils/token';
|
|
16
16
|
import { messages } from '../../../../../messages';
|
|
17
17
|
const styles = css`
|
|
@@ -46,35 +46,54 @@ const ActionGroup = ({
|
|
|
46
46
|
onDropdownOpenChange,
|
|
47
47
|
testId
|
|
48
48
|
}) => {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
49
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
50
|
+
const [buttonActions, dropdownItemActions] = useMemo(() => {
|
|
51
|
+
const isMoreThenTwoItems = items.length > visibleButtonsNum;
|
|
52
|
+
const buttons = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
|
|
53
|
+
const dropdownItems = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
|
|
54
|
+
return [buttons, dropdownItems];
|
|
55
|
+
}, [items, visibleButtonsNum]); // Stop AK dropdown menu to propagate event on click.
|
|
52
56
|
|
|
53
57
|
const onClick = useCallback(e => e.stopPropagation(), []);
|
|
58
|
+
const onOpenChange = useCallback(attrs => {
|
|
59
|
+
setIsOpen(attrs.isOpen);
|
|
60
|
+
|
|
61
|
+
if (onDropdownOpenChange) {
|
|
62
|
+
onDropdownOpenChange(attrs.isOpen);
|
|
63
|
+
}
|
|
64
|
+
}, [onDropdownOpenChange]);
|
|
65
|
+
const onActionClick = useCallback(() => {
|
|
66
|
+
if (isOpen) {
|
|
67
|
+
onOpenChange({
|
|
68
|
+
isOpen: false
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, [isOpen, onOpenChange]);
|
|
54
72
|
return jsx("div", {
|
|
55
73
|
css: styles,
|
|
56
74
|
className: "actions-button-group",
|
|
57
75
|
onClick: onClick
|
|
58
|
-
}, jsx(ButtonGroup, null, renderActionItems(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}) => onDropdownOpenChange && onDropdownOpenChange(isOpen),
|
|
76
|
+
}, jsx(ButtonGroup, null, renderActionItems(buttonActions, size, appearance, false, onActionClick), dropdownItemActions.length > 0 ? jsx(DropdownMenu, {
|
|
77
|
+
isOpen: isOpen,
|
|
78
|
+
onOpenChange: onOpenChange,
|
|
62
79
|
trigger: ({
|
|
63
80
|
triggerRef,
|
|
64
81
|
...props
|
|
65
82
|
}) => jsx(Tooltip, {
|
|
66
83
|
content: jsx(FormattedMessage, messages.more_actions),
|
|
84
|
+
hideTooltipOnClick: true,
|
|
67
85
|
testId: "action-group-more-button-tooltip",
|
|
68
86
|
tag: "span"
|
|
69
87
|
}, jsx(Button, _extends({}, props, {
|
|
70
|
-
spacing:
|
|
88
|
+
spacing: sizeToButtonSpacing[size],
|
|
71
89
|
testId: "action-group-more-button",
|
|
72
90
|
iconBefore: jsx(MoreIcon, {
|
|
73
91
|
label: "more"
|
|
74
92
|
}),
|
|
75
93
|
ref: triggerRef
|
|
76
|
-
})))
|
|
77
|
-
|
|
94
|
+
}))),
|
|
95
|
+
testId: "action-group-dropdown"
|
|
96
|
+
}, renderActionItems(dropdownItemActions, size, appearance, true, onActionClick)) : null));
|
|
78
97
|
};
|
|
79
98
|
|
|
80
99
|
export default ActionGroup;
|
|
@@ -138,7 +138,7 @@ export const renderElementItems = (items = [], display = 'inline') => {
|
|
|
138
138
|
return elements;
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
|
-
export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance, asDropDownItems) => {
|
|
141
|
+
export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance, asDropDownItems, onActionItemClick) => {
|
|
142
142
|
const actions = items.reduce((acc, curr, idx) => {
|
|
143
143
|
const {
|
|
144
144
|
name,
|
|
@@ -160,12 +160,22 @@ export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appea
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
if (Action) {
|
|
163
|
+
const handleOnClick = () => {
|
|
164
|
+
if (onActionItemClick) {
|
|
165
|
+
onActionItemClick();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (onClick) {
|
|
169
|
+
onClick();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
163
173
|
return [...acc, /*#__PURE__*/React.createElement(Action, _extends({
|
|
164
174
|
asDropDownItem: asDropDownItems,
|
|
165
175
|
size: size,
|
|
166
176
|
key: idx,
|
|
167
177
|
appearance: appearance,
|
|
168
|
-
onClick:
|
|
178
|
+
onClick: handleOnClick
|
|
169
179
|
}, actionProps))];
|
|
170
180
|
}
|
|
171
181
|
|
|
@@ -3,6 +3,12 @@ import React from 'react';
|
|
|
3
3
|
import { css } from '@emotion/core';
|
|
4
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
5
|
import { SmartLinkSize } from '../../../constants';
|
|
6
|
+
export const sizeToButtonSpacing = {
|
|
7
|
+
[SmartLinkSize.Small]: 'none',
|
|
8
|
+
[SmartLinkSize.Medium]: 'compact',
|
|
9
|
+
[SmartLinkSize.Large]: 'compact',
|
|
10
|
+
[SmartLinkSize.XLarge]: 'default'
|
|
11
|
+
};
|
|
6
12
|
export const getFormattedMessage = message => {
|
|
7
13
|
if (message) {
|
|
8
14
|
const {
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
8
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
9
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
10
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
11
|
+
import { sizeToButtonSpacing } from '../../../utils';
|
|
12
|
+
|
|
13
|
+
var getButtonStyle = function getButtonStyle(size, iconOnly) {
|
|
14
|
+
switch (size) {
|
|
15
|
+
case SmartLinkSize.Large:
|
|
16
|
+
return iconOnly ? css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button,\n button:hover,\n button:focus,\n button:active {\n padding: 0;\n > span {\n margin: 0;\n }\n }\n "]))) : '';
|
|
17
|
+
|
|
18
|
+
case SmartLinkSize.Small:
|
|
19
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ");
|
|
20
|
+
|
|
21
|
+
case SmartLinkSize.XLarge:
|
|
22
|
+
case SmartLinkSize.Medium:
|
|
23
|
+
default:
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var ActionButton = function ActionButton(_ref) {
|
|
29
|
+
var appearance = _ref.appearance,
|
|
30
|
+
content = _ref.content,
|
|
31
|
+
iconAfter = _ref.iconAfter,
|
|
32
|
+
iconBefore = _ref.iconBefore,
|
|
33
|
+
onClick = _ref.onClick,
|
|
34
|
+
overrideCss = _ref.overrideCss,
|
|
35
|
+
size = _ref.size,
|
|
36
|
+
testId = _ref.testId,
|
|
37
|
+
tooltipMessage = _ref.tooltipMessage;
|
|
38
|
+
var iconOnly = !content;
|
|
39
|
+
var onButtonClick = useCallback(function (handler) {
|
|
40
|
+
return function (e) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
handler();
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
var onContainerClick = useCallback(function (e) {
|
|
46
|
+
// Stop button on click event from propagate into parent container.
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
}, []);
|
|
49
|
+
return jsx("div", {
|
|
50
|
+
css: [getButtonStyle(size, iconOnly), overrideCss],
|
|
51
|
+
"data-testid": "".concat(testId, "-button-wrapper"),
|
|
52
|
+
onClick: onContainerClick
|
|
53
|
+
}, jsx(Tooltip, {
|
|
54
|
+
content: tooltipMessage,
|
|
55
|
+
hideTooltipOnClick: true,
|
|
56
|
+
testId: "".concat(testId, "-tooltip")
|
|
57
|
+
}, jsx(Button, {
|
|
58
|
+
appearance: appearance,
|
|
59
|
+
iconAfter: iconAfter,
|
|
60
|
+
iconBefore: iconBefore,
|
|
61
|
+
onClick: onButtonClick(onClick),
|
|
62
|
+
spacing: sizeToButtonSpacing[size],
|
|
63
|
+
testId: testId
|
|
64
|
+
}, content)));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default ActionButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DropdownItem } from '@atlaskit/dropdown-menu';
|
|
3
|
+
import { handleOnClick } from '../../../../../../utils';
|
|
4
|
+
|
|
5
|
+
var ActionDropdownItem = function ActionDropdownItem(_ref) {
|
|
6
|
+
var content = _ref.content,
|
|
7
|
+
iconAfter = _ref.iconAfter,
|
|
8
|
+
iconBefore = _ref.iconBefore,
|
|
9
|
+
onClick = _ref.onClick,
|
|
10
|
+
testId = _ref.testId;
|
|
11
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
12
|
+
elemAfter: iconAfter,
|
|
13
|
+
elemBefore: iconBefore,
|
|
14
|
+
onClick: handleOnClick(onClick),
|
|
15
|
+
testId: testId
|
|
16
|
+
}, content);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default ActionDropdownItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
8
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
9
|
+
import { tokens } from '../../../../../../utils/token';
|
|
10
|
+
import { getIconSizeStyles } from '../../../utils';
|
|
11
|
+
|
|
12
|
+
var getIconWidth = function getIconWidth(size) {
|
|
13
|
+
switch (size) {
|
|
14
|
+
case SmartLinkSize.XLarge:
|
|
15
|
+
case SmartLinkSize.Large:
|
|
16
|
+
return '1.5rem';
|
|
17
|
+
|
|
18
|
+
case SmartLinkSize.Medium:
|
|
19
|
+
case SmartLinkSize.Small:
|
|
20
|
+
default:
|
|
21
|
+
return '1rem';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var getIconStyles = function getIconStyles(size) {
|
|
26
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var ActionIcon = function ActionIcon(_ref) {
|
|
30
|
+
var size = _ref.size,
|
|
31
|
+
testId = _ref.testId,
|
|
32
|
+
icon = _ref.icon;
|
|
33
|
+
return jsx("span", {
|
|
34
|
+
css: getIconStyles(size),
|
|
35
|
+
"data-testid": "".concat(testId, "-icon")
|
|
36
|
+
}, icon);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default ActionIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,62 +1,10 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
-
|
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _sizeToSpacing;
|
|
5
|
-
|
|
6
1
|
/** @jsx jsx */
|
|
7
2
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import Button from '@atlaskit/button/custom-theme-button';
|
|
3
|
+
import { jsx } from '@emotion/core';
|
|
10
4
|
import { SmartLinkSize } from '../../../../../constants';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { tokens } from '../../../../../utils/token';
|
|
15
|
-
import { handleOnClick } from '../../../../../utils';
|
|
16
|
-
|
|
17
|
-
var getIconWidth = function getIconWidth(size) {
|
|
18
|
-
switch (size) {
|
|
19
|
-
case SmartLinkSize.XLarge:
|
|
20
|
-
case SmartLinkSize.Large:
|
|
21
|
-
return '1.5rem';
|
|
22
|
-
|
|
23
|
-
case SmartLinkSize.Medium:
|
|
24
|
-
case SmartLinkSize.Small:
|
|
25
|
-
default:
|
|
26
|
-
return '1rem';
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var getIconStyles = function getIconStyles(size) {
|
|
31
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
var getButtonStyle = function getButtonStyle(size, iconOnly) {
|
|
35
|
-
switch (size) {
|
|
36
|
-
case SmartLinkSize.Large:
|
|
37
|
-
return iconOnly ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n button,\n button:hover,\n button:focus,\n button:active {\n padding: 0;\n > span {\n margin: 0;\n }\n }\n "]))) : '';
|
|
38
|
-
|
|
39
|
-
case SmartLinkSize.Small:
|
|
40
|
-
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ");
|
|
41
|
-
|
|
42
|
-
case SmartLinkSize.XLarge:
|
|
43
|
-
case SmartLinkSize.Medium:
|
|
44
|
-
default:
|
|
45
|
-
return '';
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
var ActionIcon = function ActionIcon(_ref) {
|
|
50
|
-
var size = _ref.size,
|
|
51
|
-
testId = _ref.testId,
|
|
52
|
-
icon = _ref.icon;
|
|
53
|
-
return jsx("span", {
|
|
54
|
-
css: getIconStyles(size),
|
|
55
|
-
"data-testid": "".concat(testId, "-icon")
|
|
56
|
-
}, icon);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.XLarge, 'default'), _sizeToSpacing);
|
|
5
|
+
import ActionButton from './action-button';
|
|
6
|
+
import ActionDropdownItem from './action-dropdown-item';
|
|
7
|
+
import ActionIcon from './action-icon';
|
|
60
8
|
/**
|
|
61
9
|
* A base action that can be triggered with an on click.
|
|
62
10
|
* @internal
|
|
@@ -66,60 +14,54 @@ export var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing,
|
|
|
66
14
|
* @see CustomAction
|
|
67
15
|
*/
|
|
68
16
|
|
|
69
|
-
var Action = function Action(
|
|
70
|
-
var
|
|
71
|
-
appearance =
|
|
72
|
-
content =
|
|
73
|
-
onClick =
|
|
74
|
-
|
|
75
|
-
size =
|
|
76
|
-
|
|
77
|
-
testId =
|
|
78
|
-
icon =
|
|
79
|
-
|
|
80
|
-
iconPosition =
|
|
81
|
-
tooltipMessage =
|
|
82
|
-
asDropDownItem =
|
|
83
|
-
overrideCss =
|
|
17
|
+
var Action = function Action(_ref) {
|
|
18
|
+
var _ref$appearance = _ref.appearance,
|
|
19
|
+
appearance = _ref$appearance === void 0 ? 'subtle' : _ref$appearance,
|
|
20
|
+
content = _ref.content,
|
|
21
|
+
onClick = _ref.onClick,
|
|
22
|
+
_ref$size = _ref.size,
|
|
23
|
+
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
24
|
+
_ref$testId = _ref.testId,
|
|
25
|
+
testId = _ref$testId === void 0 ? 'smart-action' : _ref$testId,
|
|
26
|
+
icon = _ref.icon,
|
|
27
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
28
|
+
iconPosition = _ref$iconPosition === void 0 ? 'before' : _ref$iconPosition,
|
|
29
|
+
tooltipMessage = _ref.tooltipMessage,
|
|
30
|
+
asDropDownItem = _ref.asDropDownItem,
|
|
31
|
+
overrideCss = _ref.overrideCss;
|
|
84
32
|
|
|
85
33
|
if (!onClick) {
|
|
86
34
|
return null;
|
|
87
35
|
}
|
|
88
36
|
|
|
89
|
-
var
|
|
37
|
+
var actionIcon = icon && jsx(ActionIcon, {
|
|
38
|
+
icon: icon,
|
|
90
39
|
size: size,
|
|
91
|
-
testId: testId
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var iconAfter = icon && iconPosition === 'after' ?
|
|
95
|
-
size: size,
|
|
96
|
-
testId: testId,
|
|
97
|
-
icon: icon
|
|
98
|
-
}) : undefined;
|
|
99
|
-
var iconOnly = !content;
|
|
40
|
+
testId: testId
|
|
41
|
+
});
|
|
42
|
+
var iconBefore = icon && iconPosition === 'before' ? actionIcon : undefined;
|
|
43
|
+
var iconAfter = icon && iconPosition === 'after' ? actionIcon : undefined;
|
|
100
44
|
|
|
101
45
|
if (asDropDownItem) {
|
|
102
|
-
return jsx(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onClick:
|
|
107
|
-
|
|
46
|
+
return jsx(ActionDropdownItem, {
|
|
47
|
+
content: content,
|
|
48
|
+
iconAfter: iconAfter,
|
|
49
|
+
iconBefore: iconBefore,
|
|
50
|
+
onClick: onClick,
|
|
51
|
+
testId: testId
|
|
52
|
+
});
|
|
108
53
|
} else {
|
|
109
|
-
return jsx(
|
|
110
|
-
content: tooltipMessage,
|
|
111
|
-
testId: "".concat(testId, "-tooltip")
|
|
112
|
-
}, jsx("div", {
|
|
113
|
-
css: [getButtonStyle(size, iconOnly), overrideCss],
|
|
114
|
-
"data-testid": "".concat(testId, "-button-wrapper")
|
|
115
|
-
}, jsx(Button, {
|
|
116
|
-
spacing: sizeToSpacing[size],
|
|
54
|
+
return jsx(ActionButton, {
|
|
117
55
|
appearance: appearance,
|
|
118
|
-
|
|
119
|
-
|
|
56
|
+
content: content,
|
|
57
|
+
iconAfter: iconAfter,
|
|
120
58
|
iconBefore: iconBefore,
|
|
121
|
-
|
|
122
|
-
|
|
59
|
+
onClick: onClick,
|
|
60
|
+
overrideCss: overrideCss,
|
|
61
|
+
size: size,
|
|
62
|
+
testId: testId,
|
|
63
|
+
tooltipMessage: tooltipMessage
|
|
64
|
+
});
|
|
123
65
|
}
|
|
124
66
|
};
|
|
125
67
|
|