@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,131 @@
|
|
|
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 React, { Fragment, useCallback, useContext, useMemo, useRef } from 'react';
|
|
5
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
6
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
7
|
+
import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
8
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
9
|
+
import InteractionContext from '@atlaskit/interaction-context';
|
|
10
|
+
import { Box } from '@atlaskit/primitives';
|
|
11
|
+
import blockEvents from './block-events';
|
|
12
|
+
import { getXCSS, overlayStyles } from './xcss';
|
|
13
|
+
|
|
14
|
+
// Include modified onClick with analytics
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* __Use button base__
|
|
18
|
+
*
|
|
19
|
+
* A React hook that accepts a set of common Button props,
|
|
20
|
+
* and processes them to return consistent base props for usage
|
|
21
|
+
* across various Button components.
|
|
22
|
+
*
|
|
23
|
+
* It also:
|
|
24
|
+
* - Implements auto focus when enabled.
|
|
25
|
+
* - Appends the `onClick` event with UFO analytics tracking.
|
|
26
|
+
*
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
var useButtonBase = function useButtonBase(_ref) {
|
|
30
|
+
var analyticsContext = _ref.analyticsContext,
|
|
31
|
+
_ref$appearance = _ref.appearance,
|
|
32
|
+
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
33
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
34
|
+
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
|
|
35
|
+
buttonType = _ref.buttonType,
|
|
36
|
+
interactionName = _ref.interactionName,
|
|
37
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
38
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
39
|
+
_ref$isSelected = _ref.isSelected,
|
|
40
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
41
|
+
_ref$isIconButton = _ref.isIconButton,
|
|
42
|
+
isIconButton = _ref$isIconButton === void 0 ? false : _ref$isIconButton,
|
|
43
|
+
_ref$hasIconBefore = _ref.hasIconBefore,
|
|
44
|
+
hasIconBefore = _ref$hasIconBefore === void 0 ? false : _ref$hasIconBefore,
|
|
45
|
+
_ref$hasIconAfter = _ref.hasIconAfter,
|
|
46
|
+
hasIconAfter = _ref$hasIconAfter === void 0 ? false : _ref$hasIconAfter,
|
|
47
|
+
children = _ref.children,
|
|
48
|
+
_ref$onClick = _ref.onClick,
|
|
49
|
+
providedOnClick = _ref$onClick === void 0 ? noop : _ref$onClick,
|
|
50
|
+
onMouseDownCapture = _ref.onMouseDownCapture,
|
|
51
|
+
onMouseUpCapture = _ref.onMouseUpCapture,
|
|
52
|
+
onKeyDownCapture = _ref.onKeyDownCapture,
|
|
53
|
+
onKeyUpCapture = _ref.onKeyUpCapture,
|
|
54
|
+
onTouchStartCapture = _ref.onTouchStartCapture,
|
|
55
|
+
onTouchEndCapture = _ref.onTouchEndCapture,
|
|
56
|
+
onPointerDownCapture = _ref.onPointerDownCapture,
|
|
57
|
+
onPointerUpCapture = _ref.onPointerUpCapture,
|
|
58
|
+
onClickCapture = _ref.onClickCapture,
|
|
59
|
+
overlay = _ref.overlay,
|
|
60
|
+
ref = _ref.ref,
|
|
61
|
+
_ref$shouldFitContain = _ref.shouldFitContainer,
|
|
62
|
+
shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
|
|
63
|
+
_ref$spacing = _ref.spacing,
|
|
64
|
+
spacing = _ref$spacing === void 0 ? 'default' : _ref$spacing;
|
|
65
|
+
var ourRef = useRef();
|
|
66
|
+
var setRef = useCallback(function (node) {
|
|
67
|
+
ourRef.current = node;
|
|
68
|
+
if (ref === null) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (typeof ref === 'function') {
|
|
72
|
+
ref(node);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
ref.current = node;
|
|
78
|
+
}, [ourRef, ref]);
|
|
79
|
+
useAutoFocus(ourRef, autoFocus);
|
|
80
|
+
var interactionContext = useContext(InteractionContext);
|
|
81
|
+
var handleClick = useCallback(function (e, analyticsEvent) {
|
|
82
|
+
interactionContext && interactionContext.tracePress(interactionName, e.timeStamp);
|
|
83
|
+
providedOnClick(e, analyticsEvent);
|
|
84
|
+
}, [providedOnClick, interactionContext, interactionName]);
|
|
85
|
+
var onClick = usePlatformLeafEventHandler({
|
|
86
|
+
fn: handleClick,
|
|
87
|
+
action: 'clicked',
|
|
88
|
+
componentName: 'button',
|
|
89
|
+
packageName: "@atlaskit/button",
|
|
90
|
+
packageVersion: "16.10.0",
|
|
91
|
+
analyticsData: analyticsContext,
|
|
92
|
+
actionSubject: buttonType
|
|
93
|
+
});
|
|
94
|
+
var buttonXCSS = useMemo(function () {
|
|
95
|
+
return getXCSS({
|
|
96
|
+
appearance: appearance,
|
|
97
|
+
spacing: spacing,
|
|
98
|
+
isDisabled: isDisabled,
|
|
99
|
+
isSelected: isSelected,
|
|
100
|
+
shouldFitContainer: shouldFitContainer,
|
|
101
|
+
isIconButton: isIconButton,
|
|
102
|
+
hasOverlay: Boolean(overlay),
|
|
103
|
+
isLink: buttonType === 'link',
|
|
104
|
+
hasIconBefore: hasIconBefore,
|
|
105
|
+
hasIconAfter: hasIconAfter
|
|
106
|
+
});
|
|
107
|
+
}, [appearance, buttonType, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter]);
|
|
108
|
+
var isEffectivelyDisabled = isDisabled || Boolean(overlay);
|
|
109
|
+
return _objectSpread({
|
|
110
|
+
ref: setRef,
|
|
111
|
+
xcss: buttonXCSS,
|
|
112
|
+
// Consider overlay buttons to be effectively disabled
|
|
113
|
+
isDisabled: isEffectivelyDisabled,
|
|
114
|
+
children: /*#__PURE__*/React.createElement(Fragment, null, children, overlay ? /*#__PURE__*/React.createElement(Box, {
|
|
115
|
+
as: "span",
|
|
116
|
+
xcss: overlayStyles
|
|
117
|
+
}, overlay) : null)
|
|
118
|
+
}, blockEvents(isEffectivelyDisabled, {
|
|
119
|
+
onClick: onClick,
|
|
120
|
+
onMouseDownCapture: onMouseDownCapture,
|
|
121
|
+
onMouseUpCapture: onMouseUpCapture,
|
|
122
|
+
onKeyDownCapture: onKeyDownCapture,
|
|
123
|
+
onKeyUpCapture: onKeyUpCapture,
|
|
124
|
+
onTouchStartCapture: onTouchStartCapture,
|
|
125
|
+
onTouchEndCapture: onTouchEndCapture,
|
|
126
|
+
onPointerDownCapture: onPointerDownCapture,
|
|
127
|
+
onPointerUpCapture: onPointerUpCapture,
|
|
128
|
+
onClickCapture: onClickCapture
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
export default useButtonBase;
|
|
@@ -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.
|
|
111
|
+
packageVersion: "16.10.0",
|
|
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;
|