@atlaskit/button 16.9.3 → 16.10.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 +16 -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,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var appearances = ['default', 'primary', 'link', 'subtle', 'subtle-link', 'warning', 'danger'];
|
|
8
|
+
var _default = appearances;
|
|
9
|
+
exports.default = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.variants = exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
|
|
12
|
+
var _link = _interopRequireDefault(require("../new-button/variants/default/link"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
/* eslint-disable @repo/internal/react/no-unsafe-spread-props */
|
|
16
|
+
|
|
17
|
+
// Add required default props to variants
|
|
18
|
+
var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(_link.default, (0, _extends2.default)({
|
|
20
|
+
ref: ref,
|
|
21
|
+
href: "#"
|
|
22
|
+
}, props), props.children);
|
|
23
|
+
});
|
|
24
|
+
var variants = [{
|
|
25
|
+
name: 'Button',
|
|
26
|
+
Component: _button.default,
|
|
27
|
+
elementType: HTMLButtonElement
|
|
28
|
+
}, {
|
|
29
|
+
name: 'LinkButton',
|
|
30
|
+
Component: LinkButtonRender,
|
|
31
|
+
elementType: HTMLAnchorElement
|
|
32
|
+
}];
|
|
33
|
+
exports.variants = variants;
|
|
34
|
+
var _default = variants;
|
|
35
|
+
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '../button-group';
|
|
1
|
+
export { default } from '../containers/button-group';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default, Theme } from '../custom-theme-button';
|
|
1
|
+
export { default, Theme } from '../old-button/custom-theme-button';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '../loading-button';
|
|
1
|
+
export { default } from '../old-button/loading-button';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default } from '../new-button/variants/default/button';
|
|
2
|
+
export { default as LinkButton } from '../new-button/variants/default/link';
|
|
3
|
+
export { default as IconButton } from '../new-button/variants/icon/button';
|
|
4
|
+
export { default as LinkIconButton } from '../new-button/variants/icon/link';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import UNSAFE_PRESSABLE from '@atlaskit/primitives/pressable';
|
|
4
|
+
import useDefaultButton from './use-default-button';
|
|
5
|
+
/**
|
|
6
|
+
* __Button__
|
|
7
|
+
*
|
|
8
|
+
* @warning __UNSAFE__ Button is not yet safe for production use.
|
|
9
|
+
*
|
|
10
|
+
* A button triggers an event or action.
|
|
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
|
+
const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
17
|
+
// Button base
|
|
18
|
+
analyticsContext,
|
|
19
|
+
autoFocus,
|
|
20
|
+
appearance,
|
|
21
|
+
spacing,
|
|
22
|
+
isDisabled,
|
|
23
|
+
isSelected,
|
|
24
|
+
iconBefore,
|
|
25
|
+
iconAfter,
|
|
26
|
+
children,
|
|
27
|
+
shouldFitContainer,
|
|
28
|
+
interactionName,
|
|
29
|
+
overlay,
|
|
30
|
+
onClick,
|
|
31
|
+
onMouseDownCapture,
|
|
32
|
+
onMouseUpCapture,
|
|
33
|
+
onKeyDownCapture,
|
|
34
|
+
onKeyUpCapture,
|
|
35
|
+
onTouchStartCapture,
|
|
36
|
+
onTouchEndCapture,
|
|
37
|
+
onPointerDownCapture,
|
|
38
|
+
onPointerUpCapture,
|
|
39
|
+
onClickCapture,
|
|
40
|
+
type = 'button',
|
|
41
|
+
testId,
|
|
42
|
+
...rest
|
|
43
|
+
}, ref) {
|
|
44
|
+
const baseProps = useDefaultButton({
|
|
45
|
+
analyticsContext,
|
|
46
|
+
appearance,
|
|
47
|
+
autoFocus,
|
|
48
|
+
buttonType: 'button',
|
|
49
|
+
children,
|
|
50
|
+
iconBefore,
|
|
51
|
+
iconAfter,
|
|
52
|
+
interactionName,
|
|
53
|
+
isDisabled,
|
|
54
|
+
isSelected,
|
|
55
|
+
onClick,
|
|
56
|
+
onMouseDownCapture,
|
|
57
|
+
onMouseUpCapture,
|
|
58
|
+
onKeyDownCapture,
|
|
59
|
+
onKeyUpCapture,
|
|
60
|
+
onTouchStartCapture,
|
|
61
|
+
onTouchEndCapture,
|
|
62
|
+
onPointerDownCapture,
|
|
63
|
+
onPointerUpCapture,
|
|
64
|
+
onClickCapture,
|
|
65
|
+
overlay,
|
|
66
|
+
ref,
|
|
67
|
+
shouldFitContainer,
|
|
68
|
+
spacing
|
|
69
|
+
});
|
|
70
|
+
return /*#__PURE__*/React.createElement(UNSAFE_PRESSABLE
|
|
71
|
+
// TODO: Remove spread props
|
|
72
|
+
, _extends({}, rest, {
|
|
73
|
+
ref: baseProps.ref,
|
|
74
|
+
xcss: baseProps.xcss,
|
|
75
|
+
isDisabled: baseProps.isDisabled,
|
|
76
|
+
onClick: baseProps.onClick,
|
|
77
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
78
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
79
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
80
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
81
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
82
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
83
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
84
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
85
|
+
onClickCapture: baseProps.onClickCapture,
|
|
86
|
+
type: type,
|
|
87
|
+
testId: testId
|
|
88
|
+
}), baseProps.children);
|
|
89
|
+
}));
|
|
90
|
+
Button.displayName = 'Button';
|
|
91
|
+
export default Button;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Box } from '@atlaskit/primitives';
|
|
4
|
+
import useDefaultButton from './use-default-button';
|
|
5
|
+
/**
|
|
6
|
+
* __Link Button__
|
|
7
|
+
*
|
|
8
|
+
* A link button renders a link in the style of a button.
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
+
*/
|
|
14
|
+
const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkButton({
|
|
15
|
+
// Button base
|
|
16
|
+
analyticsContext,
|
|
17
|
+
autoFocus,
|
|
18
|
+
appearance,
|
|
19
|
+
spacing,
|
|
20
|
+
isDisabled,
|
|
21
|
+
isSelected,
|
|
22
|
+
iconBefore,
|
|
23
|
+
iconAfter,
|
|
24
|
+
children,
|
|
25
|
+
shouldFitContainer,
|
|
26
|
+
interactionName,
|
|
27
|
+
overlay,
|
|
28
|
+
onClick,
|
|
29
|
+
onMouseDownCapture,
|
|
30
|
+
onMouseUpCapture,
|
|
31
|
+
onKeyDownCapture,
|
|
32
|
+
onKeyUpCapture,
|
|
33
|
+
onTouchStartCapture,
|
|
34
|
+
onTouchEndCapture,
|
|
35
|
+
onPointerDownCapture,
|
|
36
|
+
onPointerUpCapture,
|
|
37
|
+
onClickCapture,
|
|
38
|
+
testId,
|
|
39
|
+
href,
|
|
40
|
+
...rest
|
|
41
|
+
}, ref) {
|
|
42
|
+
const baseProps = useDefaultButton({
|
|
43
|
+
analyticsContext,
|
|
44
|
+
appearance,
|
|
45
|
+
autoFocus,
|
|
46
|
+
buttonType: 'link',
|
|
47
|
+
children,
|
|
48
|
+
iconBefore,
|
|
49
|
+
iconAfter,
|
|
50
|
+
interactionName,
|
|
51
|
+
isDisabled,
|
|
52
|
+
isSelected,
|
|
53
|
+
onClick,
|
|
54
|
+
onMouseDownCapture,
|
|
55
|
+
onMouseUpCapture,
|
|
56
|
+
onKeyDownCapture,
|
|
57
|
+
onKeyUpCapture,
|
|
58
|
+
onTouchStartCapture,
|
|
59
|
+
onTouchEndCapture,
|
|
60
|
+
onPointerDownCapture,
|
|
61
|
+
onPointerUpCapture,
|
|
62
|
+
onClickCapture,
|
|
63
|
+
overlay,
|
|
64
|
+
ref,
|
|
65
|
+
shouldFitContainer,
|
|
66
|
+
spacing
|
|
67
|
+
});
|
|
68
|
+
return (
|
|
69
|
+
/*#__PURE__*/
|
|
70
|
+
// TODO: Use Link primitive to allow custom components for routing (with context)
|
|
71
|
+
// https://product-fabric.atlassian.net/browse/DSP-12505
|
|
72
|
+
React.createElement(Box, _extends({}, rest, {
|
|
73
|
+
ref: baseProps.ref,
|
|
74
|
+
xcss: baseProps.xcss,
|
|
75
|
+
onClick: baseProps.onClick,
|
|
76
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
77
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
78
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
79
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
80
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
81
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
82
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
83
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
84
|
+
onClickCapture: baseProps.onClickCapture,
|
|
85
|
+
as: "a",
|
|
86
|
+
testId: testId
|
|
87
|
+
/**
|
|
88
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
89
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
90
|
+
*/,
|
|
91
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
92
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
93
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
94
|
+
}), baseProps.children)
|
|
95
|
+
);
|
|
96
|
+
}));
|
|
97
|
+
LinkButton.displayName = 'LinkButton';
|
|
98
|
+
export default LinkButton;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { Box } from '@atlaskit/primitives';
|
|
3
|
+
import useButtonBase from '../shared/use-button-base';
|
|
4
|
+
import { contentStyles, getFadingStyles, iconStyles } from '../shared/xcss';
|
|
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
|
+
const useDefaultButton = ({
|
|
15
|
+
analyticsContext,
|
|
16
|
+
appearance,
|
|
17
|
+
autoFocus,
|
|
18
|
+
buttonType,
|
|
19
|
+
iconBefore,
|
|
20
|
+
iconAfter,
|
|
21
|
+
interactionName,
|
|
22
|
+
isDisabled,
|
|
23
|
+
isSelected,
|
|
24
|
+
children,
|
|
25
|
+
onClick,
|
|
26
|
+
onMouseDownCapture,
|
|
27
|
+
onMouseUpCapture,
|
|
28
|
+
onKeyDownCapture,
|
|
29
|
+
onKeyUpCapture,
|
|
30
|
+
onTouchStartCapture,
|
|
31
|
+
onTouchEndCapture,
|
|
32
|
+
onPointerDownCapture,
|
|
33
|
+
onPointerUpCapture,
|
|
34
|
+
onClickCapture,
|
|
35
|
+
overlay,
|
|
36
|
+
ref,
|
|
37
|
+
shouldFitContainer,
|
|
38
|
+
spacing
|
|
39
|
+
}) => {
|
|
40
|
+
const fadeStyles = getFadingStyles({
|
|
41
|
+
hasOverlay: Boolean(overlay)
|
|
42
|
+
});
|
|
43
|
+
const baseProps = useButtonBase({
|
|
44
|
+
analyticsContext,
|
|
45
|
+
appearance,
|
|
46
|
+
autoFocus,
|
|
47
|
+
buttonType,
|
|
48
|
+
children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Box, {
|
|
49
|
+
as: "span",
|
|
50
|
+
xcss: [fadeStyles, iconStyles]
|
|
51
|
+
}, iconBefore), children && /*#__PURE__*/React.createElement(Box, {
|
|
52
|
+
as: "span",
|
|
53
|
+
xcss: [fadeStyles, contentStyles]
|
|
54
|
+
}, children), iconAfter && /*#__PURE__*/React.createElement(Box, {
|
|
55
|
+
as: "span",
|
|
56
|
+
xcss: [fadeStyles, iconStyles]
|
|
57
|
+
}, iconAfter)),
|
|
58
|
+
interactionName,
|
|
59
|
+
isDisabled,
|
|
60
|
+
isSelected,
|
|
61
|
+
onClick,
|
|
62
|
+
onMouseDownCapture,
|
|
63
|
+
onMouseUpCapture,
|
|
64
|
+
onKeyDownCapture,
|
|
65
|
+
onKeyUpCapture,
|
|
66
|
+
onTouchStartCapture,
|
|
67
|
+
onTouchEndCapture,
|
|
68
|
+
onPointerDownCapture,
|
|
69
|
+
onPointerUpCapture,
|
|
70
|
+
onClickCapture,
|
|
71
|
+
overlay,
|
|
72
|
+
ref,
|
|
73
|
+
shouldFitContainer,
|
|
74
|
+
spacing,
|
|
75
|
+
hasIconBefore: Boolean(iconBefore),
|
|
76
|
+
hasIconAfter: Boolean(iconAfter)
|
|
77
|
+
});
|
|
78
|
+
return baseProps;
|
|
79
|
+
};
|
|
80
|
+
export default useDefaultButton;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import UNSAFE_PRESSABLE from '@atlaskit/primitives/pressable';
|
|
4
|
+
import useIconButton from './use-icon-button';
|
|
5
|
+
/**
|
|
6
|
+
* __Icon Button__
|
|
7
|
+
*
|
|
8
|
+
* TODO: Description
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
+
*/
|
|
14
|
+
const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
15
|
+
// Button base
|
|
16
|
+
analyticsContext,
|
|
17
|
+
autoFocus,
|
|
18
|
+
appearance,
|
|
19
|
+
spacing,
|
|
20
|
+
isDisabled,
|
|
21
|
+
isSelected,
|
|
22
|
+
icon,
|
|
23
|
+
children,
|
|
24
|
+
interactionName,
|
|
25
|
+
overlay,
|
|
26
|
+
onClick,
|
|
27
|
+
onMouseDownCapture,
|
|
28
|
+
onMouseUpCapture,
|
|
29
|
+
onKeyDownCapture,
|
|
30
|
+
onKeyUpCapture,
|
|
31
|
+
onTouchStartCapture,
|
|
32
|
+
onTouchEndCapture,
|
|
33
|
+
onPointerDownCapture,
|
|
34
|
+
onPointerUpCapture,
|
|
35
|
+
onClickCapture,
|
|
36
|
+
type = 'button',
|
|
37
|
+
testId,
|
|
38
|
+
...rest
|
|
39
|
+
}, ref) {
|
|
40
|
+
/**
|
|
41
|
+
* TODO: At some stage I'll look into re-using more logic across 'default' and 'icon'
|
|
42
|
+
* buttons. It's currently duplicated and mostly the same.
|
|
43
|
+
*/
|
|
44
|
+
const baseProps = useIconButton({
|
|
45
|
+
analyticsContext,
|
|
46
|
+
appearance,
|
|
47
|
+
autoFocus,
|
|
48
|
+
buttonType: 'button',
|
|
49
|
+
children,
|
|
50
|
+
icon,
|
|
51
|
+
interactionName,
|
|
52
|
+
isDisabled,
|
|
53
|
+
isSelected,
|
|
54
|
+
onClick,
|
|
55
|
+
onMouseDownCapture,
|
|
56
|
+
onMouseUpCapture,
|
|
57
|
+
onKeyDownCapture,
|
|
58
|
+
onKeyUpCapture,
|
|
59
|
+
onTouchStartCapture,
|
|
60
|
+
onTouchEndCapture,
|
|
61
|
+
onPointerDownCapture,
|
|
62
|
+
onPointerUpCapture,
|
|
63
|
+
onClickCapture,
|
|
64
|
+
overlay,
|
|
65
|
+
ref,
|
|
66
|
+
spacing
|
|
67
|
+
});
|
|
68
|
+
return /*#__PURE__*/React.createElement(UNSAFE_PRESSABLE, _extends({}, rest, {
|
|
69
|
+
ref: baseProps.ref,
|
|
70
|
+
xcss: baseProps.xcss,
|
|
71
|
+
isDisabled: baseProps.isDisabled,
|
|
72
|
+
onClick: baseProps.onClick,
|
|
73
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
74
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
75
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
76
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
77
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
78
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
79
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
80
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
81
|
+
onClickCapture: baseProps.onClickCapture,
|
|
82
|
+
type: type,
|
|
83
|
+
testId: testId
|
|
84
|
+
}), baseProps.children);
|
|
85
|
+
}));
|
|
86
|
+
IconButton.displayName = 'IconButton';
|
|
87
|
+
export default IconButton;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Box } from '@atlaskit/primitives';
|
|
4
|
+
import useIconButton from './use-icon-button';
|
|
5
|
+
/**
|
|
6
|
+
* __Link Button__
|
|
7
|
+
*
|
|
8
|
+
* A link button renders a link in the style of a button.
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
+
*/
|
|
14
|
+
const LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkIconButton({
|
|
15
|
+
// Button base
|
|
16
|
+
analyticsContext,
|
|
17
|
+
autoFocus,
|
|
18
|
+
appearance,
|
|
19
|
+
spacing,
|
|
20
|
+
isDisabled,
|
|
21
|
+
isSelected,
|
|
22
|
+
icon,
|
|
23
|
+
children,
|
|
24
|
+
interactionName,
|
|
25
|
+
overlay,
|
|
26
|
+
onClick,
|
|
27
|
+
onMouseDownCapture,
|
|
28
|
+
onMouseUpCapture,
|
|
29
|
+
onKeyDownCapture,
|
|
30
|
+
onKeyUpCapture,
|
|
31
|
+
onTouchStartCapture,
|
|
32
|
+
onTouchEndCapture,
|
|
33
|
+
onPointerDownCapture,
|
|
34
|
+
onPointerUpCapture,
|
|
35
|
+
onClickCapture,
|
|
36
|
+
testId,
|
|
37
|
+
href,
|
|
38
|
+
...rest
|
|
39
|
+
}, ref) {
|
|
40
|
+
const baseProps = useIconButton({
|
|
41
|
+
analyticsContext,
|
|
42
|
+
appearance,
|
|
43
|
+
autoFocus,
|
|
44
|
+
buttonType: 'link',
|
|
45
|
+
children,
|
|
46
|
+
icon,
|
|
47
|
+
interactionName,
|
|
48
|
+
isDisabled,
|
|
49
|
+
isSelected,
|
|
50
|
+
onClick,
|
|
51
|
+
onMouseDownCapture,
|
|
52
|
+
onMouseUpCapture,
|
|
53
|
+
onKeyDownCapture,
|
|
54
|
+
onKeyUpCapture,
|
|
55
|
+
onTouchStartCapture,
|
|
56
|
+
onTouchEndCapture,
|
|
57
|
+
onPointerDownCapture,
|
|
58
|
+
onPointerUpCapture,
|
|
59
|
+
onClickCapture,
|
|
60
|
+
overlay,
|
|
61
|
+
ref,
|
|
62
|
+
spacing
|
|
63
|
+
});
|
|
64
|
+
return (
|
|
65
|
+
/*#__PURE__*/
|
|
66
|
+
// TODO: Allow custom components for routing (with context)
|
|
67
|
+
// https://product-fabric.atlassian.net/browse/DSP-12505
|
|
68
|
+
React.createElement(Box, _extends({}, rest, {
|
|
69
|
+
ref: baseProps.ref,
|
|
70
|
+
xcss: baseProps.xcss,
|
|
71
|
+
onClick: baseProps.onClick,
|
|
72
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
73
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
74
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
75
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
76
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
77
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
78
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
79
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
80
|
+
onClickCapture: baseProps.onClickCapture,
|
|
81
|
+
as: "a",
|
|
82
|
+
testId: testId
|
|
83
|
+
/**
|
|
84
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
85
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
86
|
+
*/,
|
|
87
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
88
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
89
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
90
|
+
}), baseProps.children)
|
|
91
|
+
);
|
|
92
|
+
}));
|
|
93
|
+
LinkIconButton.displayName = 'LinkIconButton';
|
|
94
|
+
export default LinkIconButton;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from '@atlaskit/primitives';
|
|
3
|
+
import useButtonBase from '../shared/use-button-base';
|
|
4
|
+
import { getFadingStyles, iconStyles } from '../shared/xcss';
|
|
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
|
+
const useIconButton = ({
|
|
15
|
+
analyticsContext,
|
|
16
|
+
appearance,
|
|
17
|
+
autoFocus,
|
|
18
|
+
buttonType,
|
|
19
|
+
icon,
|
|
20
|
+
interactionName,
|
|
21
|
+
isDisabled,
|
|
22
|
+
isSelected,
|
|
23
|
+
// TODO: Will potentially remove children prop from IconButton
|
|
24
|
+
// children,
|
|
25
|
+
onClick,
|
|
26
|
+
onMouseDownCapture,
|
|
27
|
+
onMouseUpCapture,
|
|
28
|
+
onKeyDownCapture,
|
|
29
|
+
onKeyUpCapture,
|
|
30
|
+
onTouchStartCapture,
|
|
31
|
+
onTouchEndCapture,
|
|
32
|
+
onPointerDownCapture,
|
|
33
|
+
onPointerUpCapture,
|
|
34
|
+
onClickCapture,
|
|
35
|
+
overlay,
|
|
36
|
+
ref,
|
|
37
|
+
shouldFitContainer,
|
|
38
|
+
spacing
|
|
39
|
+
}) => {
|
|
40
|
+
const fadeStyles = getFadingStyles({
|
|
41
|
+
hasOverlay: Boolean(overlay)
|
|
42
|
+
});
|
|
43
|
+
const baseProps = useButtonBase({
|
|
44
|
+
analyticsContext,
|
|
45
|
+
appearance,
|
|
46
|
+
autoFocus,
|
|
47
|
+
buttonType,
|
|
48
|
+
/**
|
|
49
|
+
* TODO: Have not finished IconButton yet. It also needs a required accessible
|
|
50
|
+
* label - likely implemented using VisuallyHidden
|
|
51
|
+
*/
|
|
52
|
+
children: /*#__PURE__*/React.createElement(Box, {
|
|
53
|
+
as: "span",
|
|
54
|
+
xcss: [fadeStyles, iconStyles]
|
|
55
|
+
}, icon),
|
|
56
|
+
interactionName,
|
|
57
|
+
isDisabled,
|
|
58
|
+
isSelected,
|
|
59
|
+
isIconButton: true,
|
|
60
|
+
onClick,
|
|
61
|
+
onMouseDownCapture,
|
|
62
|
+
onMouseUpCapture,
|
|
63
|
+
onKeyDownCapture,
|
|
64
|
+
onKeyUpCapture,
|
|
65
|
+
onTouchStartCapture,
|
|
66
|
+
onTouchEndCapture,
|
|
67
|
+
onPointerDownCapture,
|
|
68
|
+
onPointerUpCapture,
|
|
69
|
+
onClickCapture,
|
|
70
|
+
overlay,
|
|
71
|
+
ref,
|
|
72
|
+
shouldFitContainer,
|
|
73
|
+
spacing
|
|
74
|
+
});
|
|
75
|
+
return baseProps;
|
|
76
|
+
};
|
|
77
|
+
export default useIconButton;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function abort(event) {
|
|
2
|
+
event.preventDefault();
|
|
3
|
+
event.stopPropagation();
|
|
4
|
+
}
|
|
5
|
+
const tabKeyCode = 9;
|
|
6
|
+
function onKey(event) {
|
|
7
|
+
// Allowing tab so that a user can move focus away
|
|
8
|
+
if (event.keyCode === tabKeyCode) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
abort(event);
|
|
12
|
+
}
|
|
13
|
+
export default function blockEvents(shouldBlockEvents, events) {
|
|
14
|
+
return shouldBlockEvents ? {
|
|
15
|
+
onMouseDownCapture: abort,
|
|
16
|
+
onMouseUpCapture: abort,
|
|
17
|
+
onKeyDownCapture: onKey,
|
|
18
|
+
onKeyUpCapture: onKey,
|
|
19
|
+
onTouchStartCapture: abort,
|
|
20
|
+
onTouchEndCapture: abort,
|
|
21
|
+
onPointerDownCapture: abort,
|
|
22
|
+
onPointerUpCapture: abort,
|
|
23
|
+
onClickCapture: abort,
|
|
24
|
+
// Just smashing the existing onClick for good measure
|
|
25
|
+
onClick: abort
|
|
26
|
+
} : events;
|
|
27
|
+
}
|