@atlaskit/button 17.22.2 → 18.0.0
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 +25 -0
- package/dist/cjs/new-button/variants/default/button.js +11 -4
- package/dist/cjs/new-button/variants/default/link.js +13 -6
- package/dist/cjs/new-button/variants/default/use-default-button.js +4 -13
- package/dist/cjs/new-button/variants/icon/button.js +14 -7
- package/dist/cjs/new-button/variants/icon/link.js +11 -4
- package/dist/cjs/new-button/variants/icon/use-icon-button.js +5 -13
- package/dist/cjs/new-button/variants/shared/content.js +2 -2
- package/dist/cjs/new-button/variants/shared/use-button-base.js +19 -15
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/es2019/new-button/variants/default/button.js +11 -3
- package/dist/es2019/new-button/variants/default/link.js +13 -5
- package/dist/es2019/new-button/variants/default/use-default-button.js +4 -13
- package/dist/es2019/new-button/variants/icon/button.js +14 -6
- package/dist/es2019/new-button/variants/icon/link.js +11 -3
- package/dist/es2019/new-button/variants/icon/use-icon-button.js +4 -13
- package/dist/es2019/new-button/variants/shared/content.js +2 -2
- package/dist/es2019/new-button/variants/shared/use-button-base.js +19 -15
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/esm/new-button/variants/default/button.js +11 -4
- package/dist/esm/new-button/variants/default/link.js +13 -6
- package/dist/esm/new-button/variants/default/use-default-button.js +4 -13
- package/dist/esm/new-button/variants/icon/button.js +14 -7
- package/dist/esm/new-button/variants/icon/link.js +11 -4
- package/dist/esm/new-button/variants/icon/use-icon-button.js +5 -13
- package/dist/esm/new-button/variants/shared/content.js +2 -2
- package/dist/esm/new-button/variants/shared/use-button-base.js +19 -15
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/types/new-button/variants/default/link.d.ts +1 -1
- package/dist/types/new-button/variants/default/use-default-button.d.ts +1 -1
- package/dist/types/new-button/variants/icon/link.d.ts +1 -1
- package/dist/types/new-button/variants/icon/use-icon-button.d.ts +1 -1
- package/dist/types/new-button/variants/shared/content.d.ts +2 -2
- package/dist/types/new-button/variants/shared/use-button-base.d.ts +2 -2
- package/dist/types/new-button/variants/types.d.ts +0 -6
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +2 -2
- package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +2 -2
- package/dist/types-ts4.5/new-button/variants/types.d.ts +0 -6
- package/package.json +5 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import Pressable from '@atlaskit/primitives/pressable';
|
|
4
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
6
|
import useIconButton from './use-icon-button';
|
|
@@ -36,15 +37,24 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
36
37
|
onPointerUpCapture,
|
|
37
38
|
onTouchEndCapture,
|
|
38
39
|
onTouchStartCapture,
|
|
39
|
-
overlay,
|
|
40
40
|
shape,
|
|
41
41
|
spacing,
|
|
42
42
|
testId,
|
|
43
43
|
tooltip,
|
|
44
44
|
type = 'button',
|
|
45
45
|
UNSAFE_size,
|
|
46
|
-
...
|
|
46
|
+
...unsafeRest
|
|
47
47
|
}, ref) {
|
|
48
|
+
// @ts-expect-error
|
|
49
|
+
const {
|
|
50
|
+
className: _className,
|
|
51
|
+
css: _css,
|
|
52
|
+
as: _as,
|
|
53
|
+
style: _style,
|
|
54
|
+
...saferRest
|
|
55
|
+
} = unsafeRest;
|
|
56
|
+
const rest = getBooleanFF('platform.design-system-team.remove-unsafe-spread-from-new-button_a2xhw') ? saferRest : unsafeRest;
|
|
57
|
+
|
|
48
58
|
/**
|
|
49
59
|
* TODO: At some stage I'll look into re-using more logic across 'default' and 'icon'
|
|
50
60
|
* buttons. It's currently duplicated and mostly the same.
|
|
@@ -71,7 +81,6 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
71
81
|
onPointerUpCapture,
|
|
72
82
|
onTouchEndCapture,
|
|
73
83
|
onTouchStartCapture,
|
|
74
|
-
overlay,
|
|
75
84
|
ref,
|
|
76
85
|
shape,
|
|
77
86
|
spacing,
|
|
@@ -95,9 +104,8 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
95
104
|
component: tooltip === null || tooltip === void 0 ? void 0 : tooltip.component,
|
|
96
105
|
hideTooltipOnClick: tooltip === null || tooltip === void 0 ? void 0 : tooltip.hideTooltipOnClick,
|
|
97
106
|
hideTooltipOnMouseDown: tooltip === null || tooltip === void 0 ? void 0 : tooltip.hideTooltipOnMouseDown
|
|
98
|
-
}, triggerProps => /*#__PURE__*/React.createElement(Pressable
|
|
99
|
-
|
|
100
|
-
, _extends({}, rest, {
|
|
107
|
+
}, triggerProps => /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {
|
|
108
|
+
// Top level props
|
|
101
109
|
"aria-labelledby": baseProps['aria-labelledby'],
|
|
102
110
|
type: type,
|
|
103
111
|
testId: testId,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { forwardRef, memo } from 'react';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import Anchor from '@atlaskit/primitives/anchor';
|
|
4
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
6
|
import useIconButton from './use-icon-button';
|
|
@@ -27,14 +28,22 @@ const LinkIconButtonBase = ({
|
|
|
27
28
|
onPointerUpCapture,
|
|
28
29
|
onTouchEndCapture,
|
|
29
30
|
onTouchStartCapture,
|
|
30
|
-
overlay,
|
|
31
31
|
shape,
|
|
32
32
|
spacing,
|
|
33
33
|
testId,
|
|
34
34
|
tooltip,
|
|
35
35
|
UNSAFE_size,
|
|
36
|
-
...
|
|
36
|
+
...unsafeRest
|
|
37
37
|
}, ref) => {
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
const {
|
|
40
|
+
className: _className,
|
|
41
|
+
css: _css,
|
|
42
|
+
as: _as,
|
|
43
|
+
style: _style,
|
|
44
|
+
...saferRest
|
|
45
|
+
} = unsafeRest;
|
|
46
|
+
const rest = getBooleanFF('platform.design-system-team.remove-unsafe-spread-from-new-button_a2xhw') ? saferRest : unsafeRest;
|
|
38
47
|
const baseProps = useIconButton({
|
|
39
48
|
analyticsContext,
|
|
40
49
|
appearance,
|
|
@@ -56,7 +65,6 @@ const LinkIconButtonBase = ({
|
|
|
56
65
|
onPointerUpCapture,
|
|
57
66
|
onTouchEndCapture,
|
|
58
67
|
onTouchStartCapture,
|
|
59
|
-
overlay,
|
|
60
68
|
ref,
|
|
61
69
|
shape,
|
|
62
70
|
spacing,
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
3
3
|
import Content from '../shared/content';
|
|
4
4
|
import IconRenderer from '../shared/icon-renderer';
|
|
5
|
-
import renderLoadingOverlay from '../shared/loading-overlay';
|
|
6
5
|
import useButtonBase from '../shared/use-button-base';
|
|
7
6
|
/**
|
|
8
7
|
* __Use icon button__
|
|
@@ -23,7 +22,7 @@ const useIconButton = ({
|
|
|
23
22
|
icon,
|
|
24
23
|
interactionName,
|
|
25
24
|
isDisabled,
|
|
26
|
-
isLoading,
|
|
25
|
+
isLoading = false,
|
|
27
26
|
isSelected,
|
|
28
27
|
label,
|
|
29
28
|
onClick,
|
|
@@ -36,7 +35,6 @@ const useIconButton = ({
|
|
|
36
35
|
onPointerUpCapture,
|
|
37
36
|
onTouchEndCapture,
|
|
38
37
|
onTouchStartCapture,
|
|
39
|
-
overlay,
|
|
40
38
|
ref,
|
|
41
39
|
shape,
|
|
42
40
|
shouldFitContainer,
|
|
@@ -44,7 +42,6 @@ const useIconButton = ({
|
|
|
44
42
|
testId,
|
|
45
43
|
UNSAFE_size
|
|
46
44
|
}) => {
|
|
47
|
-
const hasOverlay = Boolean(overlay || isLoading);
|
|
48
45
|
const isCircle = shape === 'circle';
|
|
49
46
|
const baseProps = useButtonBase({
|
|
50
47
|
analyticsContext,
|
|
@@ -55,7 +52,7 @@ const useIconButton = ({
|
|
|
55
52
|
buttonType,
|
|
56
53
|
children: /*#__PURE__*/React.createElement(Content, {
|
|
57
54
|
type: "icon",
|
|
58
|
-
|
|
55
|
+
isLoading: isLoading
|
|
59
56
|
}, /*#__PURE__*/React.createElement(IconRenderer, {
|
|
60
57
|
icon: icon,
|
|
61
58
|
size: UNSAFE_size
|
|
@@ -76,16 +73,10 @@ const useIconButton = ({
|
|
|
76
73
|
onPointerDownCapture,
|
|
77
74
|
onPointerUpCapture,
|
|
78
75
|
onClickCapture,
|
|
79
|
-
overlay: isLoading ? renderLoadingOverlay({
|
|
80
|
-
spacing,
|
|
81
|
-
appearance,
|
|
82
|
-
isDisabled,
|
|
83
|
-
isSelected,
|
|
84
|
-
testId
|
|
85
|
-
}) : overlay,
|
|
86
76
|
ref,
|
|
87
77
|
shouldFitContainer,
|
|
88
|
-
spacing
|
|
78
|
+
spacing,
|
|
79
|
+
testId
|
|
89
80
|
});
|
|
90
81
|
return baseProps;
|
|
91
82
|
};
|
|
@@ -54,12 +54,12 @@ const afterIconStyles = xcss({
|
|
|
54
54
|
const Content = ({
|
|
55
55
|
children,
|
|
56
56
|
type = 'text',
|
|
57
|
-
|
|
57
|
+
isLoading,
|
|
58
58
|
position
|
|
59
59
|
}) => {
|
|
60
60
|
return /*#__PURE__*/React.createElement(Box, {
|
|
61
61
|
as: "span",
|
|
62
|
-
xcss: [commonStyles, ...(type === 'text' ? [textStyles] : [iconStyles]), ...(
|
|
62
|
+
xcss: [commonStyles, ...(type === 'text' ? [textStyles] : [iconStyles]), ...(isLoading ? [fadeStyles] : []), ...(position === 'before' ? [beforeIconStyles] : []), ...(position === 'after' ? [afterIconStyles] : [])]
|
|
63
63
|
}, children);
|
|
64
64
|
};
|
|
65
65
|
export default Content;
|
|
@@ -9,6 +9,7 @@ import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
|
9
9
|
import { useSplitButtonContext } from '../../containers/split-button/split-button-context';
|
|
10
10
|
import blockEvents from './block-events';
|
|
11
11
|
import { LOADING_LABEL } from './constants';
|
|
12
|
+
import renderLoadingOverlay from './loading-overlay';
|
|
12
13
|
const buttonStyles = xcss({
|
|
13
14
|
display: 'inline-flex',
|
|
14
15
|
boxSizing: 'border-box',
|
|
@@ -281,6 +282,7 @@ const linkDecorationStyles = xcss({
|
|
|
281
282
|
}
|
|
282
283
|
});
|
|
283
284
|
const disabledStyles = xcss({
|
|
285
|
+
cursor: 'not-allowed',
|
|
284
286
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
285
287
|
background: `var(--ds-background-disabled, ${colors.N20A})`,
|
|
286
288
|
// @ts-expect-error
|
|
@@ -436,12 +438,9 @@ const circleStyles = xcss({
|
|
|
436
438
|
const fullWidthStyles = xcss({
|
|
437
439
|
width: '100%'
|
|
438
440
|
});
|
|
439
|
-
const
|
|
441
|
+
const loadingStyles = xcss({
|
|
440
442
|
cursor: 'progress'
|
|
441
443
|
});
|
|
442
|
-
const nonInteractiveStyles = xcss({
|
|
443
|
-
cursor: 'not-allowed'
|
|
444
|
-
});
|
|
445
444
|
const iconButtonStyles = xcss({
|
|
446
445
|
height: `${32 / 14}em`,
|
|
447
446
|
width: `${32 / 14}em`,
|
|
@@ -469,7 +468,7 @@ const navigationSplitButtonStyles = xcss({
|
|
|
469
468
|
paddingInlineEnd: 'space.075',
|
|
470
469
|
paddingInlineStart: 'space.075'
|
|
471
470
|
});
|
|
472
|
-
const
|
|
471
|
+
const loadingOverlayStyles = xcss({
|
|
473
472
|
display: 'flex',
|
|
474
473
|
position: 'absolute',
|
|
475
474
|
alignItems: 'center',
|
|
@@ -516,10 +515,10 @@ const useButtonBase = ({
|
|
|
516
515
|
onPointerDownCapture,
|
|
517
516
|
onPointerUpCapture,
|
|
518
517
|
onClickCapture,
|
|
519
|
-
overlay,
|
|
520
518
|
ref,
|
|
521
519
|
shouldFitContainer = false,
|
|
522
520
|
spacing: propSpacing = 'default',
|
|
521
|
+
testId,
|
|
523
522
|
ariaLabel,
|
|
524
523
|
ariaLabelledBy
|
|
525
524
|
}) => {
|
|
@@ -536,9 +535,9 @@ const useButtonBase = ({
|
|
|
536
535
|
const appearance = getBooleanFF('platform.design-system-team.component-visual-refresh_t8zbo') && isDefaultAppearanceSplitButton ? 'subtle' : (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
|
|
537
536
|
const spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
|
|
538
537
|
const isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const isEffectivelyDisabled = isDisabled ||
|
|
538
|
+
const isInteractive = !isDisabled && !isLoading;
|
|
539
|
+
// Also treat loading buttons as disabled
|
|
540
|
+
const isEffectivelyDisabled = isDisabled || isLoading;
|
|
542
541
|
const isSelected = propIsSelected && !isDisabled;
|
|
543
542
|
useAutoFocus(localRef, autoFocus);
|
|
544
543
|
return {
|
|
@@ -549,15 +548,20 @@ const useButtonBase = ({
|
|
|
549
548
|
// TODO: remove me once we kill color fallbacks
|
|
550
549
|
isSelected && appearance === 'warning' && selectedWarningStyles,
|
|
551
550
|
// TODO: remove me once we kill color fallbacks
|
|
552
|
-
isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, spacing === 'compact' && (getBooleanFF('platform.design-system-team.button-tokenised-typography-styles') ? tokenizedSpacingCompactStyles : baseSpacingCompactStyles), spacing === 'none' && spacingNoneStyles, spacing === 'none' && getBooleanFF('platform.design-system-team.button-tokenised-typography-styles') && tokenizedSpacingNoneStyles, spacing !== 'none' && hasIconBefore && buttonIconBeforeStyles, spacing !== 'none' && hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading &&
|
|
553
|
-
// Consider overlay buttons to be effectively disabled
|
|
551
|
+
isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, spacing === 'compact' && (getBooleanFF('platform.design-system-team.button-tokenised-typography-styles') ? tokenizedSpacingCompactStyles : baseSpacingCompactStyles), spacing === 'none' && spacingNoneStyles, spacing === 'none' && getBooleanFF('platform.design-system-team.button-tokenised-typography-styles') && tokenizedSpacingNoneStyles, spacing !== 'none' && hasIconBefore && buttonIconBeforeStyles, spacing !== 'none' && hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading && loadingStyles, isSplitButton && splitButtonStyles, isNavigationSplitButton && navigationSplitButtonStyles],
|
|
554
552
|
isDisabled: isEffectivelyDisabled,
|
|
555
|
-
children: /*#__PURE__*/React.createElement(Fragment, null, children,
|
|
553
|
+
children: /*#__PURE__*/React.createElement(Fragment, null, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
|
|
556
554
|
as: "span",
|
|
557
|
-
xcss:
|
|
558
|
-
},
|
|
555
|
+
xcss: loadingOverlayStyles
|
|
556
|
+
}, renderLoadingOverlay({
|
|
557
|
+
spacing,
|
|
558
|
+
appearance,
|
|
559
|
+
isDisabled,
|
|
560
|
+
isSelected,
|
|
561
|
+
testId
|
|
562
|
+
})) : null, isLoading && (children && !ariaLabel && !ariaLabelledBy || ariaLabelledBy) && /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
559
563
|
id: loadingLabelId
|
|
560
|
-
},
|
|
564
|
+
}, LOADING_LABEL)),
|
|
561
565
|
'aria-label': isLoading && ariaLabel && !ariaLabelledBy ? `${ariaLabel} ${LOADING_LABEL}` : ariaLabel,
|
|
562
566
|
'aria-labelledby': isLoading && ariaLabelledBy ? `${ariaLabelledBy} ${loadingLabelId}` : ariaLabelledBy,
|
|
563
567
|
...blockEvents(isEffectivelyDisabled, {
|
|
@@ -119,7 +119,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
119
119
|
action: 'clicked',
|
|
120
120
|
componentName: 'button',
|
|
121
121
|
packageName: "@atlaskit/button",
|
|
122
|
-
packageVersion: "
|
|
122
|
+
packageVersion: "18.0.0",
|
|
123
123
|
analyticsData: analyticsContext
|
|
124
124
|
});
|
|
125
125
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["analyticsContext", "appearance", "aria-label", "aria-labelledby", "autoFocus", "children", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isLoading", "isSelected", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "
|
|
3
|
+
var _excluded = ["analyticsContext", "appearance", "aria-label", "aria-labelledby", "autoFocus", "children", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isLoading", "isSelected", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "shouldFitContainer", "spacing", "testId", "type", "UNSAFE_iconAfter_size", "UNSAFE_iconBefore_size"],
|
|
4
|
+
_excluded2 = ["className", "css", "as", "style"];
|
|
4
5
|
import React from 'react';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
import Pressable from '@atlaskit/primitives/pressable';
|
|
6
8
|
import useDefaultButton from './use-default-button';
|
|
7
9
|
/**
|
|
@@ -36,7 +38,6 @@ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function But
|
|
|
36
38
|
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
37
39
|
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
38
40
|
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
39
|
-
overlay = _ref.overlay,
|
|
40
41
|
shouldFitContainer = _ref.shouldFitContainer,
|
|
41
42
|
spacing = _ref.spacing,
|
|
42
43
|
testId = _ref.testId,
|
|
@@ -44,7 +45,14 @@ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function But
|
|
|
44
45
|
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
45
46
|
UNSAFE_iconAfter_size = _ref.UNSAFE_iconAfter_size,
|
|
46
47
|
UNSAFE_iconBefore_size = _ref.UNSAFE_iconBefore_size,
|
|
47
|
-
|
|
48
|
+
unsafeRest = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
+
// @ts-expect-error
|
|
50
|
+
var _className = unsafeRest.className,
|
|
51
|
+
_css = unsafeRest.css,
|
|
52
|
+
_as = unsafeRest.as,
|
|
53
|
+
_style = unsafeRest.style,
|
|
54
|
+
saferRest = _objectWithoutProperties(unsafeRest, _excluded2);
|
|
55
|
+
var rest = getBooleanFF('platform.design-system-team.remove-unsafe-spread-from-new-button_a2xhw') ? saferRest : unsafeRest;
|
|
48
56
|
var baseProps = useDefaultButton({
|
|
49
57
|
ariaLabel: ariaLabel,
|
|
50
58
|
ariaLabelledBy: ariaLabelledBy,
|
|
@@ -69,7 +77,6 @@ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function But
|
|
|
69
77
|
onPointerUpCapture: onPointerUpCapture,
|
|
70
78
|
onTouchEndCapture: onTouchEndCapture,
|
|
71
79
|
onTouchStartCapture: onTouchStartCapture,
|
|
72
|
-
overlay: overlay,
|
|
73
80
|
ref: ref,
|
|
74
81
|
shouldFitContainer: shouldFitContainer,
|
|
75
82
|
spacing: spacing,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["analyticsContext", "appearance", "aria-label", "aria-labelledby", "autoFocus", "children", "href", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isSelected", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "
|
|
3
|
+
var _excluded = ["analyticsContext", "appearance", "aria-label", "aria-labelledby", "autoFocus", "children", "href", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isSelected", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "shouldFitContainer", "spacing", "testId", "UNSAFE_iconAfter_size", "UNSAFE_iconBefore_size"],
|
|
4
|
+
_excluded2 = ["className", "css", "as", "style"];
|
|
4
5
|
import React, { forwardRef, memo } from 'react';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
import Anchor from '@atlaskit/primitives/anchor';
|
|
6
8
|
import useDefaultButton from './use-default-button';
|
|
7
9
|
var LinkButtonBase = function LinkButtonBase(_ref, ref) {
|
|
@@ -27,18 +29,24 @@ var LinkButtonBase = function LinkButtonBase(_ref, ref) {
|
|
|
27
29
|
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
28
30
|
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
29
31
|
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
30
|
-
overlay = _ref.overlay,
|
|
31
32
|
shouldFitContainer = _ref.shouldFitContainer,
|
|
32
33
|
spacing = _ref.spacing,
|
|
33
34
|
testId = _ref.testId,
|
|
34
35
|
UNSAFE_iconAfter_size = _ref.UNSAFE_iconAfter_size,
|
|
35
36
|
UNSAFE_iconBefore_size = _ref.UNSAFE_iconBefore_size,
|
|
36
|
-
|
|
37
|
+
unsafeRest = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
var _className = unsafeRest.className,
|
|
40
|
+
_css = unsafeRest.css,
|
|
41
|
+
_as = unsafeRest.as,
|
|
42
|
+
_style = unsafeRest.style,
|
|
43
|
+
saferRest = _objectWithoutProperties(unsafeRest, _excluded2);
|
|
44
|
+
var rest = getBooleanFF('platform.design-system-team.remove-unsafe-spread-from-new-button_a2xhw') ? saferRest : unsafeRest;
|
|
37
45
|
var baseProps = useDefaultButton({
|
|
38
|
-
ariaLabel: ariaLabel,
|
|
39
|
-
ariaLabelledBy: ariaLabelledBy,
|
|
40
46
|
analyticsContext: analyticsContext,
|
|
41
47
|
appearance: appearance,
|
|
48
|
+
ariaLabel: ariaLabel,
|
|
49
|
+
ariaLabelledBy: ariaLabelledBy,
|
|
42
50
|
autoFocus: autoFocus,
|
|
43
51
|
buttonType: 'link',
|
|
44
52
|
children: children,
|
|
@@ -57,7 +65,6 @@ var LinkButtonBase = function LinkButtonBase(_ref, ref) {
|
|
|
57
65
|
onPointerUpCapture: onPointerUpCapture,
|
|
58
66
|
onTouchEndCapture: onTouchEndCapture,
|
|
59
67
|
onTouchStartCapture: onTouchStartCapture,
|
|
60
|
-
overlay: overlay,
|
|
61
68
|
ref: ref,
|
|
62
69
|
shouldFitContainer: shouldFitContainer,
|
|
63
70
|
spacing: spacing,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import Content from '../shared/content';
|
|
3
3
|
import IconRenderer from '../shared/icon-renderer';
|
|
4
|
-
import renderLoadingOverlay from '../shared/loading-overlay';
|
|
5
4
|
import useButtonBase from '../shared/use-button-base';
|
|
6
5
|
/**
|
|
7
6
|
* __Use default button base__
|
|
@@ -37,14 +36,12 @@ var useDefaultButton = function useDefaultButton(_ref) {
|
|
|
37
36
|
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
38
37
|
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
39
38
|
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
40
|
-
overlay = _ref.overlay,
|
|
41
39
|
ref = _ref.ref,
|
|
42
40
|
shouldFitContainer = _ref.shouldFitContainer,
|
|
43
41
|
spacing = _ref.spacing,
|
|
44
42
|
testId = _ref.testId,
|
|
45
43
|
UNSAFE_iconAfter_size = _ref.UNSAFE_iconAfter_size,
|
|
46
44
|
UNSAFE_iconBefore_size = _ref.UNSAFE_iconBefore_size;
|
|
47
|
-
var hasOverlay = Boolean(overlay || isLoading);
|
|
48
45
|
var baseProps = useButtonBase({
|
|
49
46
|
analyticsContext: analyticsContext,
|
|
50
47
|
appearance: appearance,
|
|
@@ -55,16 +52,16 @@ var useDefaultButton = function useDefaultButton(_ref) {
|
|
|
55
52
|
children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Content, {
|
|
56
53
|
type: "icon",
|
|
57
54
|
position: "before",
|
|
58
|
-
|
|
55
|
+
isLoading: isLoading
|
|
59
56
|
}, /*#__PURE__*/React.createElement(IconRenderer, {
|
|
60
57
|
icon: iconBefore,
|
|
61
58
|
size: UNSAFE_iconBefore_size
|
|
62
59
|
})), children && /*#__PURE__*/React.createElement(Content, {
|
|
63
|
-
|
|
60
|
+
isLoading: isLoading
|
|
64
61
|
}, children), iconAfter && /*#__PURE__*/React.createElement(Content, {
|
|
65
62
|
type: "icon",
|
|
66
63
|
position: "after",
|
|
67
|
-
|
|
64
|
+
isLoading: isLoading
|
|
68
65
|
}, /*#__PURE__*/React.createElement(IconRenderer, {
|
|
69
66
|
icon: iconAfter,
|
|
70
67
|
size: UNSAFE_iconAfter_size
|
|
@@ -83,16 +80,10 @@ var useDefaultButton = function useDefaultButton(_ref) {
|
|
|
83
80
|
onPointerDownCapture: onPointerDownCapture,
|
|
84
81
|
onPointerUpCapture: onPointerUpCapture,
|
|
85
82
|
onClickCapture: onClickCapture,
|
|
86
|
-
overlay: isLoading ? renderLoadingOverlay({
|
|
87
|
-
spacing: spacing,
|
|
88
|
-
appearance: appearance,
|
|
89
|
-
isDisabled: isDisabled,
|
|
90
|
-
isSelected: isSelected,
|
|
91
|
-
testId: testId
|
|
92
|
-
}) : overlay,
|
|
93
83
|
ref: ref,
|
|
94
84
|
shouldFitContainer: shouldFitContainer,
|
|
95
85
|
spacing: spacing,
|
|
86
|
+
testId: testId,
|
|
96
87
|
hasIconBefore: Boolean(iconBefore),
|
|
97
88
|
hasIconAfter: Boolean(iconAfter)
|
|
98
89
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["aria-label", "aria-labelledby", "analyticsContext", "appearance", "autoFocus", "icon", "interactionName", "isDisabled", "isLoading", "isSelected", "isTooltipDisabled", "label", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "
|
|
3
|
+
var _excluded = ["aria-label", "aria-labelledby", "analyticsContext", "appearance", "autoFocus", "icon", "interactionName", "isDisabled", "isLoading", "isSelected", "isTooltipDisabled", "label", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "shape", "spacing", "testId", "tooltip", "type", "UNSAFE_size"],
|
|
4
|
+
_excluded2 = ["className", "css", "as", "style"];
|
|
4
5
|
import React from 'react';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
import Pressable from '@atlaskit/primitives/pressable';
|
|
6
8
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
9
|
import useIconButton from './use-icon-button';
|
|
@@ -38,7 +40,6 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
38
40
|
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
39
41
|
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
40
42
|
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
41
|
-
overlay = _ref.overlay,
|
|
42
43
|
shape = _ref.shape,
|
|
43
44
|
spacing = _ref.spacing,
|
|
44
45
|
testId = _ref.testId,
|
|
@@ -46,7 +47,15 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
46
47
|
_ref$type = _ref.type,
|
|
47
48
|
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
48
49
|
UNSAFE_size = _ref.UNSAFE_size,
|
|
49
|
-
|
|
50
|
+
unsafeRest = _objectWithoutProperties(_ref, _excluded);
|
|
51
|
+
// @ts-expect-error
|
|
52
|
+
var _className = unsafeRest.className,
|
|
53
|
+
_css = unsafeRest.css,
|
|
54
|
+
_as = unsafeRest.as,
|
|
55
|
+
_style = unsafeRest.style,
|
|
56
|
+
saferRest = _objectWithoutProperties(unsafeRest, _excluded2);
|
|
57
|
+
var rest = getBooleanFF('platform.design-system-team.remove-unsafe-spread-from-new-button_a2xhw') ? saferRest : unsafeRest;
|
|
58
|
+
|
|
50
59
|
/**
|
|
51
60
|
* TODO: At some stage I'll look into re-using more logic across 'default' and 'icon'
|
|
52
61
|
* buttons. It's currently duplicated and mostly the same.
|
|
@@ -73,7 +82,6 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
73
82
|
onPointerUpCapture: onPointerUpCapture,
|
|
74
83
|
onTouchEndCapture: onTouchEndCapture,
|
|
75
84
|
onTouchStartCapture: onTouchStartCapture,
|
|
76
|
-
overlay: overlay,
|
|
77
85
|
ref: ref,
|
|
78
86
|
shape: shape,
|
|
79
87
|
spacing: spacing,
|
|
@@ -98,9 +106,8 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
98
106
|
hideTooltipOnClick: tooltip === null || tooltip === void 0 ? void 0 : tooltip.hideTooltipOnClick,
|
|
99
107
|
hideTooltipOnMouseDown: tooltip === null || tooltip === void 0 ? void 0 : tooltip.hideTooltipOnMouseDown
|
|
100
108
|
}, function (triggerProps) {
|
|
101
|
-
return /*#__PURE__*/React.createElement(Pressable
|
|
102
|
-
|
|
103
|
-
, _extends({}, rest, {
|
|
109
|
+
return /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {
|
|
110
|
+
// Top level props
|
|
104
111
|
"aria-labelledby": baseProps['aria-labelledby'],
|
|
105
112
|
type: type,
|
|
106
113
|
testId: testId,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["aria-label", "aria-labelledby", "analyticsContext", "appearance", "autoFocus", "href", "icon", "interactionName", "isDisabled", "isSelected", "isTooltipDisabled", "label", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "
|
|
3
|
+
var _excluded = ["aria-label", "aria-labelledby", "analyticsContext", "appearance", "autoFocus", "href", "icon", "interactionName", "isDisabled", "isSelected", "isTooltipDisabled", "label", "onClick", "onClickCapture", "onKeyDownCapture", "onKeyUpCapture", "onMouseDownCapture", "onMouseUpCapture", "onPointerDownCapture", "onPointerUpCapture", "onTouchEndCapture", "onTouchStartCapture", "shape", "spacing", "testId", "tooltip", "UNSAFE_size"],
|
|
4
|
+
_excluded2 = ["className", "css", "as", "style"];
|
|
4
5
|
import React, { forwardRef, memo } from 'react';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
import Anchor from '@atlaskit/primitives/anchor';
|
|
6
8
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
9
|
import useIconButton from './use-icon-button';
|
|
@@ -29,13 +31,19 @@ var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
|
|
|
29
31
|
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
30
32
|
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
31
33
|
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
32
|
-
overlay = _ref.overlay,
|
|
33
34
|
shape = _ref.shape,
|
|
34
35
|
spacing = _ref.spacing,
|
|
35
36
|
testId = _ref.testId,
|
|
36
37
|
tooltip = _ref.tooltip,
|
|
37
38
|
UNSAFE_size = _ref.UNSAFE_size,
|
|
38
|
-
|
|
39
|
+
unsafeRest = _objectWithoutProperties(_ref, _excluded);
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
var _className = unsafeRest.className,
|
|
42
|
+
_css = unsafeRest.css,
|
|
43
|
+
_as = unsafeRest.as,
|
|
44
|
+
_style = unsafeRest.style,
|
|
45
|
+
saferRest = _objectWithoutProperties(unsafeRest, _excluded2);
|
|
46
|
+
var rest = getBooleanFF('platform.design-system-team.remove-unsafe-spread-from-new-button_a2xhw') ? saferRest : unsafeRest;
|
|
39
47
|
var baseProps = useIconButton({
|
|
40
48
|
analyticsContext: analyticsContext,
|
|
41
49
|
appearance: appearance,
|
|
@@ -57,7 +65,6 @@ var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
|
|
|
57
65
|
onPointerUpCapture: onPointerUpCapture,
|
|
58
66
|
onTouchEndCapture: onTouchEndCapture,
|
|
59
67
|
onTouchStartCapture: onTouchStartCapture,
|
|
60
|
-
overlay: overlay,
|
|
61
68
|
ref: ref,
|
|
62
69
|
shape: shape,
|
|
63
70
|
spacing: spacing,
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
3
3
|
import Content from '../shared/content';
|
|
4
4
|
import IconRenderer from '../shared/icon-renderer';
|
|
5
|
-
import renderLoadingOverlay from '../shared/loading-overlay';
|
|
6
5
|
import useButtonBase from '../shared/use-button-base';
|
|
7
6
|
/**
|
|
8
7
|
* __Use icon button__
|
|
@@ -23,7 +22,8 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
23
22
|
icon = _ref.icon,
|
|
24
23
|
interactionName = _ref.interactionName,
|
|
25
24
|
isDisabled = _ref.isDisabled,
|
|
26
|
-
isLoading = _ref.isLoading,
|
|
25
|
+
_ref$isLoading = _ref.isLoading,
|
|
26
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
27
27
|
isSelected = _ref.isSelected,
|
|
28
28
|
label = _ref.label,
|
|
29
29
|
onClick = _ref.onClick,
|
|
@@ -36,14 +36,12 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
36
36
|
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
37
37
|
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
38
38
|
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
39
|
-
overlay = _ref.overlay,
|
|
40
39
|
ref = _ref.ref,
|
|
41
40
|
shape = _ref.shape,
|
|
42
41
|
shouldFitContainer = _ref.shouldFitContainer,
|
|
43
42
|
spacing = _ref.spacing,
|
|
44
43
|
testId = _ref.testId,
|
|
45
44
|
UNSAFE_size = _ref.UNSAFE_size;
|
|
46
|
-
var hasOverlay = Boolean(overlay || isLoading);
|
|
47
45
|
var isCircle = shape === 'circle';
|
|
48
46
|
var baseProps = useButtonBase({
|
|
49
47
|
analyticsContext: analyticsContext,
|
|
@@ -54,7 +52,7 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
54
52
|
buttonType: buttonType,
|
|
55
53
|
children: /*#__PURE__*/React.createElement(Content, {
|
|
56
54
|
type: "icon",
|
|
57
|
-
|
|
55
|
+
isLoading: isLoading
|
|
58
56
|
}, /*#__PURE__*/React.createElement(IconRenderer, {
|
|
59
57
|
icon: icon,
|
|
60
58
|
size: UNSAFE_size
|
|
@@ -75,16 +73,10 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
75
73
|
onPointerDownCapture: onPointerDownCapture,
|
|
76
74
|
onPointerUpCapture: onPointerUpCapture,
|
|
77
75
|
onClickCapture: onClickCapture,
|
|
78
|
-
overlay: isLoading ? renderLoadingOverlay({
|
|
79
|
-
spacing: spacing,
|
|
80
|
-
appearance: appearance,
|
|
81
|
-
isDisabled: isDisabled,
|
|
82
|
-
isSelected: isSelected,
|
|
83
|
-
testId: testId
|
|
84
|
-
}) : overlay,
|
|
85
76
|
ref: ref,
|
|
86
77
|
shouldFitContainer: shouldFitContainer,
|
|
87
|
-
spacing: spacing
|
|
78
|
+
spacing: spacing,
|
|
79
|
+
testId: testId
|
|
88
80
|
});
|
|
89
81
|
return baseProps;
|
|
90
82
|
};
|
|
@@ -56,11 +56,11 @@ var Content = function Content(_ref) {
|
|
|
56
56
|
var children = _ref.children,
|
|
57
57
|
_ref$type = _ref.type,
|
|
58
58
|
type = _ref$type === void 0 ? 'text' : _ref$type,
|
|
59
|
-
|
|
59
|
+
isLoading = _ref.isLoading,
|
|
60
60
|
position = _ref.position;
|
|
61
61
|
return /*#__PURE__*/React.createElement(Box, {
|
|
62
62
|
as: "span",
|
|
63
|
-
xcss: [commonStyles].concat(_toConsumableArray(type === 'text' ? [textStyles] : [iconStyles]), _toConsumableArray(
|
|
63
|
+
xcss: [commonStyles].concat(_toConsumableArray(type === 'text' ? [textStyles] : [iconStyles]), _toConsumableArray(isLoading ? [fadeStyles] : []), _toConsumableArray(position === 'before' ? [beforeIconStyles] : []), _toConsumableArray(position === 'after' ? [afterIconStyles] : []))
|
|
64
64
|
}, children);
|
|
65
65
|
};
|
|
66
66
|
export default Content;
|