@atlaskit/button 16.9.3 → 16.9.4
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/entry-points/button-group.js +1 -1
- package/dist/cjs/entry-points/custom-theme-button.js +1 -1
- package/dist/cjs/entry-points/loading-button.js +1 -1
- package/dist/cjs/entry-points/new.js +34 -0
- package/dist/cjs/entry-points/standard-button.js +1 -1
- package/dist/cjs/entry-points/unsafe.js +13 -0
- package/dist/cjs/new-button/variants/default/button.js +100 -0
- package/dist/cjs/new-button/variants/default/link.js +106 -0
- package/dist/cjs/new-button/variants/default/use-default-button.js +90 -0
- package/dist/cjs/new-button/variants/icon/button.js +96 -0
- package/dist/cjs/new-button/variants/icon/link.js +102 -0
- package/dist/cjs/new-button/variants/icon/use-icon-button.js +82 -0
- package/dist/cjs/new-button/variants/shared/block-events.js +33 -0
- package/dist/cjs/new-button/variants/shared/colors.js +130 -0
- package/dist/cjs/new-button/variants/shared/use-button-base.js +140 -0
- package/dist/cjs/new-button/variants/shared/xcss.js +191 -0
- package/dist/cjs/new-button/variants/types.js +5 -0
- package/dist/cjs/old-button/custom-theme-button/custom-theme-button-types.js +5 -0
- package/dist/cjs/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js +2 -2
- package/dist/cjs/{custom-theme-button → old-button/custom-theme-button}/theme.js +2 -2
- package/dist/cjs/{shared → old-button/shared}/button-base.js +2 -2
- package/dist/cjs/{shared → old-button/shared}/css.js +2 -2
- package/dist/cjs/old-button/types.js +5 -0
- package/dist/cjs/utils/appearances.js +9 -0
- package/dist/cjs/utils/spacing.js +9 -0
- package/dist/cjs/utils/variants.js +35 -0
- package/dist/es2019/entry-points/button-group.js +1 -1
- package/dist/es2019/entry-points/custom-theme-button.js +1 -1
- package/dist/es2019/entry-points/loading-button.js +1 -1
- package/dist/es2019/entry-points/new.js +4 -0
- package/dist/es2019/entry-points/standard-button.js +1 -1
- package/dist/es2019/entry-points/unsafe.js +1 -0
- package/dist/es2019/new-button/variants/default/button.js +91 -0
- package/dist/es2019/new-button/variants/default/link.js +98 -0
- package/dist/es2019/new-button/variants/default/use-default-button.js +80 -0
- package/dist/es2019/new-button/variants/icon/button.js +87 -0
- package/dist/es2019/new-button/variants/icon/link.js +94 -0
- package/dist/es2019/new-button/variants/icon/use-icon-button.js +77 -0
- package/dist/es2019/new-button/variants/shared/block-events.js +27 -0
- package/dist/es2019/new-button/variants/shared/colors.js +120 -0
- package/dist/es2019/new-button/variants/shared/use-button-base.js +120 -0
- package/dist/es2019/new-button/variants/shared/xcss.js +182 -0
- package/dist/es2019/{shared → old-button/shared}/button-base.js +2 -5
- package/dist/es2019/old-button/types.js +1 -0
- package/dist/es2019/utils/appearances.js +2 -0
- package/dist/es2019/utils/spacing.js +2 -0
- package/dist/es2019/utils/variants.js +20 -0
- package/dist/esm/entry-points/button-group.js +1 -1
- package/dist/esm/entry-points/custom-theme-button.js +1 -1
- package/dist/esm/entry-points/loading-button.js +1 -1
- package/dist/esm/entry-points/new.js +4 -0
- package/dist/esm/entry-points/standard-button.js +1 -1
- package/dist/esm/entry-points/unsafe.js +1 -0
- package/dist/esm/new-button/variants/default/button.js +92 -0
- package/dist/esm/new-button/variants/default/link.js +98 -0
- package/dist/esm/new-button/variants/default/types.js +1 -0
- package/dist/esm/new-button/variants/default/use-default-button.js +79 -0
- package/dist/esm/new-button/variants/icon/button.js +88 -0
- package/dist/esm/new-button/variants/icon/link.js +94 -0
- package/dist/esm/new-button/variants/icon/types.js +1 -0
- package/dist/esm/new-button/variants/icon/use-icon-button.js +74 -0
- package/dist/esm/new-button/variants/shared/block-events.js +27 -0
- package/dist/esm/new-button/variants/shared/colors.js +120 -0
- package/dist/esm/new-button/variants/shared/use-button-base.js +131 -0
- package/dist/esm/new-button/variants/shared/xcss.js +178 -0
- package/dist/esm/new-button/variants/types.js +1 -0
- package/dist/esm/old-button/custom-theme-button/custom-theme-button-types.js +1 -0
- package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js +2 -2
- package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/theme.js +2 -2
- package/dist/esm/{shared → old-button/shared}/button-base.js +2 -2
- package/dist/esm/{shared → old-button/shared}/css.js +2 -2
- package/dist/esm/old-button/types.js +1 -0
- package/dist/esm/utils/appearances.js +2 -0
- package/dist/esm/utils/spacing.js +2 -0
- package/dist/esm/utils/variants.js +22 -0
- package/dist/types/{button-group.d.ts → containers/button-group.d.ts} +1 -1
- package/dist/types/entry-points/button-group.d.ts +1 -1
- package/dist/types/entry-points/custom-theme-button.d.ts +2 -2
- package/dist/types/entry-points/loading-button.d.ts +2 -2
- package/dist/types/entry-points/new.d.ts +5 -0
- package/dist/types/entry-points/standard-button.d.ts +2 -2
- package/dist/types/entry-points/types.d.ts +1 -1
- package/dist/types/entry-points/unsafe.d.ts +1 -0
- package/dist/types/new-button/variants/default/button.d.ts +19 -0
- package/dist/types/new-button/variants/default/link.d.ts +17 -0
- package/dist/types/new-button/variants/default/types.d.ts +15 -0
- package/dist/types/new-button/variants/default/use-default-button.d.ts +15 -0
- package/dist/types/new-button/variants/icon/button.d.ts +17 -0
- package/dist/types/new-button/variants/icon/link.d.ts +17 -0
- package/dist/types/new-button/variants/icon/types.d.ts +8 -0
- package/dist/types/new-button/variants/icon/use-icon-button.d.ts +15 -0
- package/dist/types/new-button/variants/shared/block-events.d.ts +2 -0
- package/dist/types/new-button/variants/shared/colors.d.ts +18 -0
- package/dist/types/new-button/variants/shared/use-button-base.d.ts +37 -0
- package/dist/types/new-button/variants/shared/xcss.d.ts +24 -0
- package/dist/types/new-button/variants/types.d.ts +69 -0
- package/dist/{types-ts4.5 → types/old-button}/custom-theme-button/custom-theme-button.d.ts +1 -1
- package/dist/types/utils/appearances.d.ts +3 -0
- package/dist/types/utils/spacing.d.ts +3 -0
- package/dist/types/utils/variants.d.ts +15 -0
- package/dist/types-ts4.5/{button-group.d.ts → containers/button-group.d.ts} +1 -1
- package/dist/types-ts4.5/entry-points/button-group.d.ts +1 -1
- package/dist/types-ts4.5/entry-points/custom-theme-button.d.ts +2 -2
- package/dist/types-ts4.5/entry-points/loading-button.d.ts +2 -2
- package/dist/types-ts4.5/entry-points/new.d.ts +5 -0
- package/dist/types-ts4.5/entry-points/standard-button.d.ts +2 -2
- package/dist/types-ts4.5/entry-points/types.d.ts +1 -1
- package/dist/types-ts4.5/entry-points/unsafe.d.ts +1 -0
- package/dist/types-ts4.5/new-button/variants/default/button.d.ts +19 -0
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +17 -0
- package/dist/types-ts4.5/new-button/variants/default/types.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +17 -0
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +17 -0
- package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +8 -0
- package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/shared/block-events.d.ts +2 -0
- package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +18 -0
- package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +37 -0
- package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +24 -0
- package/dist/types-ts4.5/new-button/variants/types.d.ts +69 -0
- package/dist/{types → types-ts4.5/old-button}/custom-theme-button/custom-theme-button.d.ts +1 -1
- package/dist/types-ts4.5/utils/appearances.d.ts +3 -0
- package/dist/types-ts4.5/utils/spacing.d.ts +3 -0
- package/dist/types-ts4.5/utils/variants.d.ts +15 -0
- package/extract-react-types/custom-theme-button-props.tsx +1 -1
- package/extract-react-types/loading-button-props.tsx +1 -1
- package/extract-react-types/shared-props.tsx +1 -1
- package/package.json +9 -6
- package/unsafe/package.json +15 -0
- /package/dist/cjs/{button-group.js → containers/button-group.js} +0 -0
- /package/dist/cjs/{types.js → new-button/variants/default/types.js} +0 -0
- /package/dist/cjs/{custom-theme-button/custom-theme-button-types.js → new-button/variants/icon/types.js} +0 -0
- /package/dist/cjs/{button.js → old-button/button.js} +0 -0
- /package/dist/cjs/{custom-theme-button → old-button/custom-theme-button}/index.js +0 -0
- /package/dist/cjs/{loading-button.js → old-button/loading-button.js} +0 -0
- /package/dist/cjs/{shared → old-button/shared}/block-events.js +0 -0
- /package/dist/cjs/{shared → old-button/shared}/colors.js +0 -0
- /package/dist/cjs/{shared → old-button/shared}/get-if-visually-hidden-children.js +0 -0
- /package/dist/cjs/{shared → old-button/shared}/get-is-only-single-icon.js +0 -0
- /package/dist/cjs/{shared → old-button/shared}/loading-spinner.js +0 -0
- /package/dist/es2019/{button-group.js → containers/button-group.js} +0 -0
- /package/dist/es2019/{types.js → new-button/variants/default/types.js} +0 -0
- /package/dist/{esm → es2019/new-button/variants/icon}/types.js +0 -0
- /package/dist/es2019/{custom-theme-button/custom-theme-button-types.js → new-button/variants/types.js} +0 -0
- /package/dist/es2019/{button.js → old-button/button.js} +0 -0
- /package/dist/{esm → es2019/old-button}/custom-theme-button/custom-theme-button-types.js +0 -0
- /package/dist/es2019/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js +0 -0
- /package/dist/es2019/{custom-theme-button → old-button/custom-theme-button}/index.js +0 -0
- /package/dist/es2019/{custom-theme-button → old-button/custom-theme-button}/theme.js +0 -0
- /package/dist/es2019/{loading-button.js → old-button/loading-button.js} +0 -0
- /package/dist/es2019/{shared → old-button/shared}/block-events.js +0 -0
- /package/dist/es2019/{shared → old-button/shared}/colors.js +0 -0
- /package/dist/es2019/{shared → old-button/shared}/css.js +0 -0
- /package/dist/es2019/{shared → old-button/shared}/get-if-visually-hidden-children.js +0 -0
- /package/dist/es2019/{shared → old-button/shared}/get-is-only-single-icon.js +0 -0
- /package/dist/es2019/{shared → old-button/shared}/loading-spinner.js +0 -0
- /package/dist/esm/{button-group.js → containers/button-group.js} +0 -0
- /package/dist/esm/{button.js → old-button/button.js} +0 -0
- /package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/index.js +0 -0
- /package/dist/esm/{loading-button.js → old-button/loading-button.js} +0 -0
- /package/dist/esm/{shared → old-button/shared}/block-events.js +0 -0
- /package/dist/esm/{shared → old-button/shared}/colors.js +0 -0
- /package/dist/esm/{shared → old-button/shared}/get-if-visually-hidden-children.js +0 -0
- /package/dist/esm/{shared → old-button/shared}/get-is-only-single-icon.js +0 -0
- /package/dist/esm/{shared → old-button/shared}/loading-spinner.js +0 -0
- /package/dist/types/{button.d.ts → old-button/button.d.ts} +0 -0
- /package/dist/types/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button-types.d.ts +0 -0
- /package/dist/types/{custom-theme-button → old-button/custom-theme-button}/index.d.ts +0 -0
- /package/dist/types/{custom-theme-button → old-button/custom-theme-button}/theme.d.ts +0 -0
- /package/dist/types/{loading-button.d.ts → old-button/loading-button.d.ts} +0 -0
- /package/dist/types/{shared → old-button/shared}/block-events.d.ts +0 -0
- /package/dist/types/{shared → old-button/shared}/button-base.d.ts +0 -0
- /package/dist/types/{shared → old-button/shared}/colors.d.ts +0 -0
- /package/dist/types/{shared → old-button/shared}/css.d.ts +0 -0
- /package/dist/types/{shared → old-button/shared}/get-if-visually-hidden-children.d.ts +0 -0
- /package/dist/types/{shared → old-button/shared}/get-is-only-single-icon.d.ts +0 -0
- /package/dist/types/{shared → old-button/shared}/loading-spinner.d.ts +0 -0
- /package/dist/types/{types.d.ts → old-button/types.d.ts} +0 -0
- /package/dist/types-ts4.5/{button.d.ts → old-button/button.d.ts} +0 -0
- /package/dist/types-ts4.5/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button-types.d.ts +0 -0
- /package/dist/types-ts4.5/{custom-theme-button → old-button/custom-theme-button}/index.d.ts +0 -0
- /package/dist/types-ts4.5/{custom-theme-button → old-button/custom-theme-button}/theme.d.ts +0 -0
- /package/dist/types-ts4.5/{loading-button.d.ts → old-button/loading-button.d.ts} +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/block-events.d.ts +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/button-base.d.ts +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/colors.d.ts +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/css.d.ts +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/get-if-visually-hidden-children.d.ts +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/get-is-only-single-icon.d.ts +0 -0
- /package/dist/types-ts4.5/{shared → old-button/shared}/loading-spinner.d.ts +0 -0
- /package/dist/types-ts4.5/{types.d.ts → old-button/types.d.ts} +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { xcss } from '@atlaskit/primitives';
|
|
5
|
+
import { fontSize as getFontSize } from '@atlaskit/theme/constants';
|
|
6
|
+
import colors from './colors';
|
|
7
|
+
var fontSize = getFontSize();
|
|
8
|
+
var heights = {
|
|
9
|
+
default: "".concat(32 / fontSize, "em"),
|
|
10
|
+
compact: "".concat(24 / fontSize, "em"),
|
|
11
|
+
none: 'auto'
|
|
12
|
+
};
|
|
13
|
+
var paddingInline = {
|
|
14
|
+
default: {
|
|
15
|
+
default: 'space.150',
|
|
16
|
+
withIcon: 'space.100'
|
|
17
|
+
},
|
|
18
|
+
compact: {
|
|
19
|
+
default: 'space.150',
|
|
20
|
+
withIcon: 'space.100'
|
|
21
|
+
},
|
|
22
|
+
none: {
|
|
23
|
+
default: 'space.0',
|
|
24
|
+
withIcon: 'space.0'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var gap = {
|
|
28
|
+
compact: 'space.050',
|
|
29
|
+
default: 'space.050',
|
|
30
|
+
none: 'space.0'
|
|
31
|
+
};
|
|
32
|
+
var verticalAlign = {
|
|
33
|
+
default: 'middle',
|
|
34
|
+
compact: 'middle',
|
|
35
|
+
none: 'baseline'
|
|
36
|
+
};
|
|
37
|
+
function getColor(_ref) {
|
|
38
|
+
var group = _ref.group,
|
|
39
|
+
key = _ref.key;
|
|
40
|
+
return group[key] || group.default;
|
|
41
|
+
}
|
|
42
|
+
function getColors(_ref2) {
|
|
43
|
+
var appearance = _ref2.appearance,
|
|
44
|
+
_ref2$interactionStat = _ref2.interactionState,
|
|
45
|
+
interactionState = _ref2$interactionStat === void 0 ? 'default' : _ref2$interactionStat,
|
|
46
|
+
isDisabled = _ref2.isDisabled,
|
|
47
|
+
isSelected = _ref2.isSelected,
|
|
48
|
+
hasOverlay = _ref2.hasOverlay;
|
|
49
|
+
var key = interactionState;
|
|
50
|
+
// Overlay does not change color on interaction, revert to 'default' or resting state
|
|
51
|
+
key = hasOverlay ? 'default' : key;
|
|
52
|
+
key = isSelected ? 'selected' : key;
|
|
53
|
+
// Disabled colors overrule everything else
|
|
54
|
+
key = isDisabled ? 'disabled' : key;
|
|
55
|
+
return {
|
|
56
|
+
backgroundColor: getColor({
|
|
57
|
+
group: colors.background[appearance],
|
|
58
|
+
key: key
|
|
59
|
+
}),
|
|
60
|
+
color: "".concat(getColor({
|
|
61
|
+
group: colors.color[appearance],
|
|
62
|
+
key: key
|
|
63
|
+
}))
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function getXCSS(_ref3) {
|
|
67
|
+
var appearance = _ref3.appearance,
|
|
68
|
+
spacing = _ref3.spacing,
|
|
69
|
+
isDisabled = _ref3.isDisabled,
|
|
70
|
+
isSelected = _ref3.isSelected,
|
|
71
|
+
isIconButton = _ref3.isIconButton,
|
|
72
|
+
shouldFitContainer = _ref3.shouldFitContainer,
|
|
73
|
+
isLink = _ref3.isLink,
|
|
74
|
+
hasOverlay = _ref3.hasOverlay,
|
|
75
|
+
hasIconBefore = _ref3.hasIconBefore,
|
|
76
|
+
hasIconAfter = _ref3.hasIconAfter;
|
|
77
|
+
var baseColors = getColors({
|
|
78
|
+
appearance: appearance,
|
|
79
|
+
isSelected: isSelected,
|
|
80
|
+
isDisabled: isDisabled
|
|
81
|
+
});
|
|
82
|
+
var combinedBaseColorStyles = isLink ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
83
|
+
textDecoration: 'none',
|
|
84
|
+
// Disabling visited styles (by re-declaring the base colors)
|
|
85
|
+
':visited': baseColors
|
|
86
|
+
}) : baseColors;
|
|
87
|
+
var height = heights[spacing];
|
|
88
|
+
var width = shouldFitContainer ? '100%' : 'auto';
|
|
89
|
+
width = isIconButton ? height : width;
|
|
90
|
+
var paddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
|
|
91
|
+
var paddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
|
|
92
|
+
return xcss(_objectSpread(_objectSpread(_objectSpread({
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
borderWidth: 'border.width.0',
|
|
95
|
+
borderRadius: 'border.radius.100',
|
|
96
|
+
boxSizing: 'border-box',
|
|
97
|
+
display: 'inline-flex',
|
|
98
|
+
fontSize: 'inherit',
|
|
99
|
+
fontStyle: 'normal',
|
|
100
|
+
fontFamily: 'inherit',
|
|
101
|
+
fontWeight: 500,
|
|
102
|
+
maxWidth: '100%',
|
|
103
|
+
// Needed to position overlay
|
|
104
|
+
position: 'relative',
|
|
105
|
+
textAlign: 'center',
|
|
106
|
+
transition: 'background 0.1s ease-out, box-shadow 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38)',
|
|
107
|
+
whiteSpace: 'nowrap',
|
|
108
|
+
height: height,
|
|
109
|
+
paddingBlock: 'space.0',
|
|
110
|
+
paddingInlineStart: isIconButton ? 'space.0' : paddingInlineStart,
|
|
111
|
+
paddingInlineEnd: isIconButton ? 'space.0' : paddingInlineEnd,
|
|
112
|
+
columnGap: gap[spacing],
|
|
113
|
+
verticalAlign: verticalAlign[spacing],
|
|
114
|
+
width: width,
|
|
115
|
+
// justifyContent required for shouldFitContainer buttons with an icon inside
|
|
116
|
+
justifyContent: 'center'
|
|
117
|
+
}, combinedBaseColorStyles), isDisabled || hasOverlay ? {
|
|
118
|
+
cursor: 'not-allowed'
|
|
119
|
+
} : {}), {}, {
|
|
120
|
+
':hover': _objectSpread(_objectSpread({}, getColors({
|
|
121
|
+
appearance: appearance,
|
|
122
|
+
isSelected: isSelected,
|
|
123
|
+
isDisabled: isDisabled,
|
|
124
|
+
interactionState: 'hover',
|
|
125
|
+
hasOverlay: hasOverlay
|
|
126
|
+
})), {}, {
|
|
127
|
+
textDecoration: !isSelected && (appearance === 'link' || appearance === 'subtle-link') ? 'underline' : 'none',
|
|
128
|
+
// background, box-shadow
|
|
129
|
+
transitionDuration: '0s, 0.15s'
|
|
130
|
+
}),
|
|
131
|
+
':active': _objectSpread(_objectSpread({}, getColors({
|
|
132
|
+
appearance: appearance,
|
|
133
|
+
isSelected: isSelected,
|
|
134
|
+
isDisabled: isDisabled,
|
|
135
|
+
interactionState: 'active',
|
|
136
|
+
hasOverlay: hasOverlay
|
|
137
|
+
})), {}, {
|
|
138
|
+
// background, box-shadow
|
|
139
|
+
transitionDuration: '0s, 0s'
|
|
140
|
+
})
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
export var iconStyles = xcss({
|
|
144
|
+
display: 'flex',
|
|
145
|
+
// icon size cannot grow and shrink
|
|
146
|
+
flexGrow: 0,
|
|
147
|
+
flexShrink: 0,
|
|
148
|
+
alignSelf: 'center',
|
|
149
|
+
fontSize: 0,
|
|
150
|
+
lineHeight: 0,
|
|
151
|
+
userSelect: 'none'
|
|
152
|
+
});
|
|
153
|
+
export var contentStyles = xcss({
|
|
154
|
+
// content can grow and shrink
|
|
155
|
+
flexGrow: 1,
|
|
156
|
+
flexShrink: 1,
|
|
157
|
+
// ellipsis for overflow text
|
|
158
|
+
overflow: 'hidden',
|
|
159
|
+
textOverflow: 'ellipsis',
|
|
160
|
+
whiteSpace: 'nowrap'
|
|
161
|
+
});
|
|
162
|
+
export function getFadingStyles(_ref4) {
|
|
163
|
+
var hasOverlay = _ref4.hasOverlay;
|
|
164
|
+
return xcss({
|
|
165
|
+
opacity: hasOverlay ? 0 : 1,
|
|
166
|
+
transition: 'opacity 0.3s'
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export var overlayStyles = xcss({
|
|
170
|
+
position: 'absolute',
|
|
171
|
+
left: 'space.0',
|
|
172
|
+
top: 'space.0',
|
|
173
|
+
right: 'space.0',
|
|
174
|
+
bottom: 'space.0',
|
|
175
|
+
display: 'flex',
|
|
176
|
+
alignItems: 'center',
|
|
177
|
+
justifyContent: 'center'
|
|
178
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js
RENAMED
|
@@ -3,8 +3,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["appearance", "autoFocus", "isDisabled", "isSelected", "shouldFitContainer", "spacing", "isLoading", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "theme"];
|
|
6
|
-
function ownKeys(
|
|
7
|
-
function _objectSpread(
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import React, { useCallback, useState } from 'react';
|
|
9
9
|
import GlobalTheme from '@atlaskit/theme/components';
|
|
10
10
|
import ButtonBase from '../shared/button-base';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { createTheme } from '@atlaskit/theme/components';
|
|
5
5
|
import { getCss } from '../shared/css';
|
|
6
6
|
var stateToSelectorMap = {
|
|
@@ -75,7 +75,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
75
75
|
_props$spacing = props.spacing,
|
|
76
76
|
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
77
77
|
_props$tabIndex = props.tabIndex,
|
|
78
|
-
tabIndex = _props$tabIndex === void 0 ?
|
|
78
|
+
tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
|
|
79
79
|
_props$type = props.type,
|
|
80
80
|
type = _props$type === void 0 ? !href ? 'button' : undefined : _props$type,
|
|
81
81
|
testId = props.testId,
|
|
@@ -108,7 +108,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
108
108
|
action: 'clicked',
|
|
109
109
|
componentName: 'button',
|
|
110
110
|
packageName: "@atlaskit/button",
|
|
111
|
-
packageVersion: "16.9.
|
|
111
|
+
packageVersion: "16.9.4",
|
|
112
112
|
analyticsData: analyticsContext
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { fontSize as getFontSize,
|
|
6
6
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/* eslint-disable @repo/internal/react/no-unsafe-spread-props */
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import Button from '../new-button/variants/default/button';
|
|
5
|
+
import LinkButton from '../new-button/variants/default/link';
|
|
6
|
+
// Add required default props to variants
|
|
7
|
+
var LinkButtonRender = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
8
|
+
return /*#__PURE__*/React.createElement(LinkButton, _extends({
|
|
9
|
+
ref: ref,
|
|
10
|
+
href: "#"
|
|
11
|
+
}, props), props.children);
|
|
12
|
+
});
|
|
13
|
+
export var variants = [{
|
|
14
|
+
name: 'Button',
|
|
15
|
+
Component: Button,
|
|
16
|
+
elementType: HTMLButtonElement
|
|
17
|
+
}, {
|
|
18
|
+
name: 'LinkButton',
|
|
19
|
+
Component: LinkButtonRender,
|
|
20
|
+
elementType: HTMLAnchorElement
|
|
21
|
+
}];
|
|
22
|
+
export default variants;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '../button-group';
|
|
1
|
+
export { default } from '../containers/button-group';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default, Theme } from '../custom-theme-button';
|
|
2
|
-
export type { ThemeTokens, ThemeProps, InteractionState, CustomThemeButtonProps, CustomThemeButtonOwnProps, } from '../custom-theme-button/custom-theme-button-types';
|
|
1
|
+
export { default, Theme } from '../old-button/custom-theme-button';
|
|
2
|
+
export type { ThemeTokens, ThemeProps, InteractionState, CustomThemeButtonProps, CustomThemeButtonOwnProps, } from '../old-button/custom-theme-button/custom-theme-button-types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from '../loading-button';
|
|
2
|
-
export type { LoadingButtonProps, LoadingButtonOwnProps, } from '../loading-button';
|
|
1
|
+
export { default } from '../old-button/loading-button';
|
|
2
|
+
export type { LoadingButtonProps, LoadingButtonOwnProps, } from '../old-button/loading-button';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default, type ButtonProps, } from '../new-button/variants/default/button';
|
|
2
|
+
export { default as LinkButton, type LinkButtonProps, } from '../new-button/variants/default/link';
|
|
3
|
+
export { default as IconButton, type IconButtonProps, } from '../new-button/variants/icon/button';
|
|
4
|
+
export { default as LinkIconButton, type LinkIconButtonProps, } from '../new-button/variants/icon/link';
|
|
5
|
+
export type { Appearance, Spacing } from '../new-button/variants/types';
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* https://product-fabric.atlassian.net/browse/DSP-3222
|
|
4
4
|
*/
|
|
5
5
|
import '@emotion/react';
|
|
6
|
-
export { default } from '../button';
|
|
7
|
-
export type { ButtonProps } from '../button';
|
|
6
|
+
export { default } from '../old-button/button';
|
|
7
|
+
export type { ButtonProps } from '../old-button/button';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Appearance, Spacing, BaseOwnProps, BaseProps } from '../types';
|
|
1
|
+
export type { Appearance, Spacing, BaseOwnProps, BaseProps, } from '../old-button/types';
|
|
2
2
|
export type { ButtonProps } from './standard-button';
|
|
3
3
|
export type { LoadingButtonProps, LoadingButtonOwnProps, } from './loading-button';
|
|
4
4
|
export type { ThemeTokens, ThemeProps, InteractionState, CustomThemeButtonProps, CustomThemeButtonOwnProps, } from './custom-theme-button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AdditionalHTMLElementPropsExtender, type CombinedButtonProps } from '../types';
|
|
3
|
+
import { type CommonDefaultButtonProps } from './types';
|
|
4
|
+
type Element = HTMLButtonElement;
|
|
5
|
+
type AdditionalHTMLElementProps = AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<Element>>;
|
|
6
|
+
export type ButtonProps = CommonDefaultButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
7
|
+
/**
|
|
8
|
+
* __Button__
|
|
9
|
+
*
|
|
10
|
+
* @warning __UNSAFE__ Button is not yet safe for production use.
|
|
11
|
+
*
|
|
12
|
+
* A button triggers an event or action.
|
|
13
|
+
*
|
|
14
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
15
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
16
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
17
|
+
*/
|
|
18
|
+
declare const Button: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonDefaultButtonProps & Omit<AdditionalHTMLElementProps, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
|
|
19
|
+
export default Button;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AdditionalHTMLElementPropsExtender, type CombinedButtonProps } from '../types';
|
|
3
|
+
import { type CommonDefaultButtonProps } from './types';
|
|
4
|
+
type Element = HTMLAnchorElement;
|
|
5
|
+
type AdditionalHTMLElementProps = AdditionalHTMLElementPropsExtender<React.AnchorHTMLAttributes<Element>>;
|
|
6
|
+
export type LinkButtonProps = CommonDefaultButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
7
|
+
/**
|
|
8
|
+
* __Link Button__
|
|
9
|
+
*
|
|
10
|
+
* A link button renders a link in the style of a button.
|
|
11
|
+
*
|
|
12
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
14
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
|
+
*/
|
|
16
|
+
declare const LinkButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonDefaultButtonProps & Omit<AdditionalHTMLElementProps, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & React.RefAttributes<HTMLAnchorElement>>>;
|
|
17
|
+
export default LinkButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type CommonDefaultButtonProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Places an icon within the button, after the button's text
|
|
5
|
+
*/
|
|
6
|
+
iconAfter?: React.ReactChild;
|
|
7
|
+
/**
|
|
8
|
+
* Places an icon within the button, before the button's text
|
|
9
|
+
*/
|
|
10
|
+
iconBefore?: React.ReactChild;
|
|
11
|
+
/**
|
|
12
|
+
* Option to fit button width to its parent width
|
|
13
|
+
*/
|
|
14
|
+
shouldFitContainer?: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type UseButtonBaseArgs, type UseButtonBaseReturn } from '../shared/use-button-base';
|
|
2
|
+
import { type CommonDefaultButtonProps } from './types';
|
|
3
|
+
type UseDefaultButtonArgs<TagName extends HTMLElement> = UseButtonBaseArgs<TagName> & CommonDefaultButtonProps;
|
|
4
|
+
type UseButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagName>;
|
|
5
|
+
/**
|
|
6
|
+
* __Use default button base__
|
|
7
|
+
*
|
|
8
|
+
* A React hook that accepts a set of default Button props,
|
|
9
|
+
* and processes them to return consistent base props for usage
|
|
10
|
+
* across Button and LinkButton variants.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const useDefaultButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, iconBefore, iconAfter, interactionName, isDisabled, isSelected, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseDefaultButtonArgs<TagName>) => UseButtonReturn<TagName>;
|
|
15
|
+
export default useDefaultButton;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AdditionalHTMLElementPropsExtender, type CombinedButtonProps } from '../types';
|
|
3
|
+
import { type CommonIconButtonProps } from './types';
|
|
4
|
+
type Element = HTMLButtonElement;
|
|
5
|
+
type AdditionalHTMLElementProps = AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<Element>>;
|
|
6
|
+
export type IconButtonProps = CommonIconButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
7
|
+
/**
|
|
8
|
+
* __Icon Button__
|
|
9
|
+
*
|
|
10
|
+
* TODO: Description
|
|
11
|
+
*
|
|
12
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
14
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
|
+
*/
|
|
16
|
+
declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<AdditionalHTMLElementProps, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
|
|
17
|
+
export default IconButton;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AdditionalHTMLElementPropsExtender, type CombinedButtonProps } from '../types';
|
|
3
|
+
import { type CommonIconButtonProps } from './types';
|
|
4
|
+
type Element = HTMLAnchorElement;
|
|
5
|
+
type AdditionalHTMLElementProps = AdditionalHTMLElementPropsExtender<React.AnchorHTMLAttributes<Element>>;
|
|
6
|
+
export type LinkIconButtonProps = CommonIconButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
7
|
+
/**
|
|
8
|
+
* __Link Button__
|
|
9
|
+
*
|
|
10
|
+
* A link button renders a link in the style of a button.
|
|
11
|
+
*
|
|
12
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
14
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
|
+
*/
|
|
16
|
+
declare const LinkIconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<AdditionalHTMLElementProps, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & React.RefAttributes<HTMLAnchorElement>>>;
|
|
17
|
+
export default LinkIconButton;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type CommonIconButtonProps = {
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Consider locking-down icon props by converting from slot props to component props
|
|
5
|
+
* Places an icon within the button, after the button's text
|
|
6
|
+
*/
|
|
7
|
+
icon: React.ReactChild;
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type UseButtonBaseArgs, type UseButtonBaseReturn } from '../shared/use-button-base';
|
|
2
|
+
import { type CommonIconButtonProps } from './types';
|
|
3
|
+
type UseIconButtonArgs<TagName extends HTMLElement> = UseButtonBaseArgs<TagName> & CommonIconButtonProps;
|
|
4
|
+
type UseIconButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagName>;
|
|
5
|
+
/**
|
|
6
|
+
* __Use icon button__
|
|
7
|
+
*
|
|
8
|
+
* A React hook that accepts a set of icon Button props,
|
|
9
|
+
* and processes them to return consistent base props for usage
|
|
10
|
+
* across IconButton and LinkIconButton variants.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const useIconButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, icon, interactionName, isDisabled, isSelected, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseIconButtonArgs<TagName>) => UseIconButtonReturn<TagName>;
|
|
15
|
+
export default useIconButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BackgroundColor, type TextColor } from '@atlaskit/primitives';
|
|
2
|
+
import { type Appearance } from '../types';
|
|
3
|
+
export type ColorGroup<T extends BackgroundColor | TextColor> = {
|
|
4
|
+
default: T;
|
|
5
|
+
hover?: T;
|
|
6
|
+
active?: T;
|
|
7
|
+
disabled?: T;
|
|
8
|
+
selected?: T;
|
|
9
|
+
};
|
|
10
|
+
export type ColorPreset<T extends BackgroundColor | TextColor> = {
|
|
11
|
+
[key in Appearance]: ColorGroup<T>;
|
|
12
|
+
};
|
|
13
|
+
type Values = {
|
|
14
|
+
background: ColorPreset<BackgroundColor>;
|
|
15
|
+
color: ColorPreset<TextColor>;
|
|
16
|
+
};
|
|
17
|
+
declare const values: Values;
|
|
18
|
+
export default values;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { xcss } from '@atlaskit/primitives';
|
|
3
|
+
import { type CommonButtonProps } from '../types';
|
|
4
|
+
export type ControlledEvents<TagName extends HTMLElement> = Pick<React.DOMAttributes<TagName>, 'onMouseDownCapture' | 'onMouseUpCapture' | 'onKeyDownCapture' | 'onKeyUpCapture' | 'onTouchStartCapture' | 'onTouchEndCapture' | 'onPointerDownCapture' | 'onPointerUpCapture' | 'onClickCapture' | 'onClick'>;
|
|
5
|
+
export type ControlledEventsPassed<TagName extends HTMLElement> = Omit<ControlledEvents<TagName>, 'onClick'> & Pick<CommonButtonProps<TagName>, 'onClick'>;
|
|
6
|
+
export type UseButtonBaseArgs<TagName extends HTMLElement> = {
|
|
7
|
+
ref: React.Ref<TagName>;
|
|
8
|
+
/**
|
|
9
|
+
* The type of button. Used to pass action subject context to analytics.
|
|
10
|
+
*/
|
|
11
|
+
buttonType: 'button' | 'link';
|
|
12
|
+
isIconButton?: boolean;
|
|
13
|
+
hasIconBefore?: boolean;
|
|
14
|
+
hasIconAfter?: boolean;
|
|
15
|
+
shouldFitContainer?: boolean;
|
|
16
|
+
} & Pick<CommonButtonProps<TagName>, 'analyticsContext' | 'appearance' | 'autoFocus' | 'children' | 'interactionName' | 'isDisabled' | 'isSelected' | 'overlay' | 'spacing'> & ControlledEventsPassed<TagName>;
|
|
17
|
+
export type UseButtonBaseReturn<TagName extends HTMLElement> = {
|
|
18
|
+
xcss: ReturnType<typeof xcss>;
|
|
19
|
+
ref(node: TagName | null): void;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
isDisabled: boolean;
|
|
22
|
+
} & ControlledEvents<TagName>;
|
|
23
|
+
/**
|
|
24
|
+
* __Use button base__
|
|
25
|
+
*
|
|
26
|
+
* A React hook that accepts a set of common Button props,
|
|
27
|
+
* and processes them to return consistent base props for usage
|
|
28
|
+
* across various Button components.
|
|
29
|
+
*
|
|
30
|
+
* It also:
|
|
31
|
+
* - Implements auto focus when enabled.
|
|
32
|
+
* - Appends the `onClick` event with UFO analytics tracking.
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, interactionName, isDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
37
|
+
export default useButtonBase;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { xcss } from '@atlaskit/primitives';
|
|
2
|
+
import { type Appearance, type Spacing } from '../types';
|
|
3
|
+
export type GetXCSSArgs = {
|
|
4
|
+
appearance: Appearance;
|
|
5
|
+
spacing: Spacing;
|
|
6
|
+
isDisabled: boolean;
|
|
7
|
+
isSelected: boolean;
|
|
8
|
+
shouldFitContainer: boolean;
|
|
9
|
+
hasOverlay: boolean;
|
|
10
|
+
isIconButton: boolean;
|
|
11
|
+
hasIconBefore: boolean;
|
|
12
|
+
hasIconAfter: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If the button is a LinkButton
|
|
15
|
+
*/
|
|
16
|
+
isLink: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, isLink, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
19
|
+
export declare const iconStyles: ReturnType<typeof xcss>;
|
|
20
|
+
export declare const contentStyles: ReturnType<typeof xcss>;
|
|
21
|
+
export declare function getFadingStyles({ hasOverlay, }: {
|
|
22
|
+
hasOverlay: boolean;
|
|
23
|
+
}): ReturnType<typeof xcss>;
|
|
24
|
+
export declare const overlayStyles: ReturnType<typeof xcss>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
|
+
export type Appearance = 'default' | 'danger' | 'link' | 'primary' | 'subtle' | 'subtle-link' | 'warning';
|
|
4
|
+
export type Spacing = 'compact' | 'default' | 'none';
|
|
5
|
+
type Combine<First, Second> = Omit<First, keyof Second> & Second;
|
|
6
|
+
export type CommonButtonProps<TagName extends HTMLElement> = {
|
|
7
|
+
/**
|
|
8
|
+
* The base styling to apply to the button
|
|
9
|
+
*/
|
|
10
|
+
appearance?: Appearance;
|
|
11
|
+
/**
|
|
12
|
+
* Set the button to autofocus on mount
|
|
13
|
+
*/
|
|
14
|
+
autoFocus?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Used to 'overlay' something over a button. This is commonly used to display a loading spinner
|
|
17
|
+
*/
|
|
18
|
+
overlay?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Set if the button is disabled
|
|
21
|
+
*/
|
|
22
|
+
isDisabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Change the style to indicate the button is selected
|
|
25
|
+
*/
|
|
26
|
+
isSelected?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Handler to be called on blur
|
|
29
|
+
*/
|
|
30
|
+
onBlur?: React.FocusEventHandler<TagName>;
|
|
31
|
+
/**
|
|
32
|
+
* Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details
|
|
33
|
+
*/
|
|
34
|
+
onClick?: (e: React.MouseEvent<TagName>, analyticsEvent: UIAnalyticsEvent) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Handler to be called on focus
|
|
37
|
+
*/
|
|
38
|
+
onFocus?: React.FocusEventHandler<TagName>;
|
|
39
|
+
/**
|
|
40
|
+
* Set the amount of padding in the button
|
|
41
|
+
*/
|
|
42
|
+
spacing?: Spacing;
|
|
43
|
+
/**
|
|
44
|
+
* Text content to be rendered in the button
|
|
45
|
+
*/
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
|
|
49
|
+
*/
|
|
50
|
+
testId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* An optional name used to identify this component to press listeners. E.g. interaction tracing
|
|
53
|
+
* @see https://hello.atlassian.net/wiki/spaces/UFO/pages/2010358949/UFO+Integration+into+Design+System+components
|
|
54
|
+
*/
|
|
55
|
+
interactionName?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Additional information to be included in the `context` of analytics events that come from button
|
|
58
|
+
*/
|
|
59
|
+
analyticsContext?: Record<string, any>;
|
|
60
|
+
};
|
|
61
|
+
type SupportedElementAttributes = React.ButtonHTMLAttributes<HTMLButtonElement> | React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
62
|
+
export type AdditionalHTMLElementPropsExtender<Props extends SupportedElementAttributes> = Combine<Omit<Props, 'className' | 'style' | 'role' | 'disabled'>, {
|
|
63
|
+
'data-testid'?: never;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Combines common buttom props with additional HTML attributes.
|
|
67
|
+
*/
|
|
68
|
+
export type CombinedButtonProps<TagName extends HTMLElement, HTMLAttributes extends SupportedElementAttributes> = Combine<HTMLAttributes, CommonButtonProps<TagName>>;
|
|
69
|
+
export {};
|
|
@@ -6,5 +6,5 @@ import React from 'react';
|
|
|
6
6
|
*
|
|
7
7
|
* - [Examples](https://atlassian.design/components/button/examples#custom-theme-button)
|
|
8
8
|
*/
|
|
9
|
-
declare const CustomThemeButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<import("
|
|
9
|
+
declare const CustomThemeButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<import("../types").BaseProps, "overlay"> & import("./custom-theme-button-types").CustomThemeButtonOwnProps & React.RefAttributes<HTMLElement>>>;
|
|
10
10
|
export default CustomThemeButton;
|