@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.
Files changed (193) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/entry-points/button-group.js +1 -1
  3. package/dist/cjs/entry-points/custom-theme-button.js +1 -1
  4. package/dist/cjs/entry-points/loading-button.js +1 -1
  5. package/dist/cjs/entry-points/new.js +34 -0
  6. package/dist/cjs/entry-points/standard-button.js +1 -1
  7. package/dist/cjs/entry-points/unsafe.js +13 -0
  8. package/dist/cjs/new-button/variants/default/button.js +100 -0
  9. package/dist/cjs/new-button/variants/default/link.js +106 -0
  10. package/dist/cjs/new-button/variants/default/use-default-button.js +90 -0
  11. package/dist/cjs/new-button/variants/icon/button.js +96 -0
  12. package/dist/cjs/new-button/variants/icon/link.js +102 -0
  13. package/dist/cjs/new-button/variants/icon/use-icon-button.js +82 -0
  14. package/dist/cjs/new-button/variants/shared/block-events.js +33 -0
  15. package/dist/cjs/new-button/variants/shared/colors.js +130 -0
  16. package/dist/cjs/new-button/variants/shared/use-button-base.js +140 -0
  17. package/dist/cjs/new-button/variants/shared/xcss.js +191 -0
  18. package/dist/cjs/new-button/variants/types.js +5 -0
  19. package/dist/cjs/old-button/custom-theme-button/custom-theme-button-types.js +5 -0
  20. package/dist/cjs/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js +2 -2
  21. package/dist/cjs/{custom-theme-button → old-button/custom-theme-button}/theme.js +2 -2
  22. package/dist/cjs/{shared → old-button/shared}/button-base.js +2 -2
  23. package/dist/cjs/{shared → old-button/shared}/css.js +2 -2
  24. package/dist/cjs/old-button/types.js +5 -0
  25. package/dist/cjs/utils/appearances.js +9 -0
  26. package/dist/cjs/utils/spacing.js +9 -0
  27. package/dist/cjs/utils/variants.js +35 -0
  28. package/dist/es2019/entry-points/button-group.js +1 -1
  29. package/dist/es2019/entry-points/custom-theme-button.js +1 -1
  30. package/dist/es2019/entry-points/loading-button.js +1 -1
  31. package/dist/es2019/entry-points/new.js +4 -0
  32. package/dist/es2019/entry-points/standard-button.js +1 -1
  33. package/dist/es2019/entry-points/unsafe.js +1 -0
  34. package/dist/es2019/new-button/variants/default/button.js +91 -0
  35. package/dist/es2019/new-button/variants/default/link.js +98 -0
  36. package/dist/es2019/new-button/variants/default/use-default-button.js +80 -0
  37. package/dist/es2019/new-button/variants/icon/button.js +87 -0
  38. package/dist/es2019/new-button/variants/icon/link.js +94 -0
  39. package/dist/es2019/new-button/variants/icon/use-icon-button.js +77 -0
  40. package/dist/es2019/new-button/variants/shared/block-events.js +27 -0
  41. package/dist/es2019/new-button/variants/shared/colors.js +120 -0
  42. package/dist/es2019/new-button/variants/shared/use-button-base.js +120 -0
  43. package/dist/es2019/new-button/variants/shared/xcss.js +182 -0
  44. package/dist/es2019/{shared → old-button/shared}/button-base.js +2 -5
  45. package/dist/es2019/old-button/types.js +1 -0
  46. package/dist/es2019/utils/appearances.js +2 -0
  47. package/dist/es2019/utils/spacing.js +2 -0
  48. package/dist/es2019/utils/variants.js +20 -0
  49. package/dist/esm/entry-points/button-group.js +1 -1
  50. package/dist/esm/entry-points/custom-theme-button.js +1 -1
  51. package/dist/esm/entry-points/loading-button.js +1 -1
  52. package/dist/esm/entry-points/new.js +4 -0
  53. package/dist/esm/entry-points/standard-button.js +1 -1
  54. package/dist/esm/entry-points/unsafe.js +1 -0
  55. package/dist/esm/new-button/variants/default/button.js +92 -0
  56. package/dist/esm/new-button/variants/default/link.js +98 -0
  57. package/dist/esm/new-button/variants/default/types.js +1 -0
  58. package/dist/esm/new-button/variants/default/use-default-button.js +79 -0
  59. package/dist/esm/new-button/variants/icon/button.js +88 -0
  60. package/dist/esm/new-button/variants/icon/link.js +94 -0
  61. package/dist/esm/new-button/variants/icon/types.js +1 -0
  62. package/dist/esm/new-button/variants/icon/use-icon-button.js +74 -0
  63. package/dist/esm/new-button/variants/shared/block-events.js +27 -0
  64. package/dist/esm/new-button/variants/shared/colors.js +120 -0
  65. package/dist/esm/new-button/variants/shared/use-button-base.js +131 -0
  66. package/dist/esm/new-button/variants/shared/xcss.js +178 -0
  67. package/dist/esm/new-button/variants/types.js +1 -0
  68. package/dist/esm/old-button/custom-theme-button/custom-theme-button-types.js +1 -0
  69. package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js +2 -2
  70. package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/theme.js +2 -2
  71. package/dist/esm/{shared → old-button/shared}/button-base.js +2 -2
  72. package/dist/esm/{shared → old-button/shared}/css.js +2 -2
  73. package/dist/esm/old-button/types.js +1 -0
  74. package/dist/esm/utils/appearances.js +2 -0
  75. package/dist/esm/utils/spacing.js +2 -0
  76. package/dist/esm/utils/variants.js +22 -0
  77. package/dist/types/{button-group.d.ts → containers/button-group.d.ts} +1 -1
  78. package/dist/types/entry-points/button-group.d.ts +1 -1
  79. package/dist/types/entry-points/custom-theme-button.d.ts +2 -2
  80. package/dist/types/entry-points/loading-button.d.ts +2 -2
  81. package/dist/types/entry-points/new.d.ts +5 -0
  82. package/dist/types/entry-points/standard-button.d.ts +2 -2
  83. package/dist/types/entry-points/types.d.ts +1 -1
  84. package/dist/types/entry-points/unsafe.d.ts +1 -0
  85. package/dist/types/new-button/variants/default/button.d.ts +19 -0
  86. package/dist/types/new-button/variants/default/link.d.ts +17 -0
  87. package/dist/types/new-button/variants/default/types.d.ts +15 -0
  88. package/dist/types/new-button/variants/default/use-default-button.d.ts +15 -0
  89. package/dist/types/new-button/variants/icon/button.d.ts +17 -0
  90. package/dist/types/new-button/variants/icon/link.d.ts +17 -0
  91. package/dist/types/new-button/variants/icon/types.d.ts +8 -0
  92. package/dist/types/new-button/variants/icon/use-icon-button.d.ts +15 -0
  93. package/dist/types/new-button/variants/shared/block-events.d.ts +2 -0
  94. package/dist/types/new-button/variants/shared/colors.d.ts +18 -0
  95. package/dist/types/new-button/variants/shared/use-button-base.d.ts +37 -0
  96. package/dist/types/new-button/variants/shared/xcss.d.ts +24 -0
  97. package/dist/types/new-button/variants/types.d.ts +69 -0
  98. package/dist/{types-ts4.5 → types/old-button}/custom-theme-button/custom-theme-button.d.ts +1 -1
  99. package/dist/types/utils/appearances.d.ts +3 -0
  100. package/dist/types/utils/spacing.d.ts +3 -0
  101. package/dist/types/utils/variants.d.ts +15 -0
  102. package/dist/types-ts4.5/{button-group.d.ts → containers/button-group.d.ts} +1 -1
  103. package/dist/types-ts4.5/entry-points/button-group.d.ts +1 -1
  104. package/dist/types-ts4.5/entry-points/custom-theme-button.d.ts +2 -2
  105. package/dist/types-ts4.5/entry-points/loading-button.d.ts +2 -2
  106. package/dist/types-ts4.5/entry-points/new.d.ts +5 -0
  107. package/dist/types-ts4.5/entry-points/standard-button.d.ts +2 -2
  108. package/dist/types-ts4.5/entry-points/types.d.ts +1 -1
  109. package/dist/types-ts4.5/entry-points/unsafe.d.ts +1 -0
  110. package/dist/types-ts4.5/new-button/variants/default/button.d.ts +19 -0
  111. package/dist/types-ts4.5/new-button/variants/default/link.d.ts +17 -0
  112. package/dist/types-ts4.5/new-button/variants/default/types.d.ts +15 -0
  113. package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +15 -0
  114. package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +17 -0
  115. package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +17 -0
  116. package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +8 -0
  117. package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +15 -0
  118. package/dist/types-ts4.5/new-button/variants/shared/block-events.d.ts +2 -0
  119. package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +18 -0
  120. package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +37 -0
  121. package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +24 -0
  122. package/dist/types-ts4.5/new-button/variants/types.d.ts +69 -0
  123. package/dist/{types → types-ts4.5/old-button}/custom-theme-button/custom-theme-button.d.ts +1 -1
  124. package/dist/types-ts4.5/utils/appearances.d.ts +3 -0
  125. package/dist/types-ts4.5/utils/spacing.d.ts +3 -0
  126. package/dist/types-ts4.5/utils/variants.d.ts +15 -0
  127. package/extract-react-types/custom-theme-button-props.tsx +1 -1
  128. package/extract-react-types/loading-button-props.tsx +1 -1
  129. package/extract-react-types/shared-props.tsx +1 -1
  130. package/package.json +9 -6
  131. package/unsafe/package.json +15 -0
  132. /package/dist/cjs/{button-group.js → containers/button-group.js} +0 -0
  133. /package/dist/cjs/{types.js → new-button/variants/default/types.js} +0 -0
  134. /package/dist/cjs/{custom-theme-button/custom-theme-button-types.js → new-button/variants/icon/types.js} +0 -0
  135. /package/dist/cjs/{button.js → old-button/button.js} +0 -0
  136. /package/dist/cjs/{custom-theme-button → old-button/custom-theme-button}/index.js +0 -0
  137. /package/dist/cjs/{loading-button.js → old-button/loading-button.js} +0 -0
  138. /package/dist/cjs/{shared → old-button/shared}/block-events.js +0 -0
  139. /package/dist/cjs/{shared → old-button/shared}/colors.js +0 -0
  140. /package/dist/cjs/{shared → old-button/shared}/get-if-visually-hidden-children.js +0 -0
  141. /package/dist/cjs/{shared → old-button/shared}/get-is-only-single-icon.js +0 -0
  142. /package/dist/cjs/{shared → old-button/shared}/loading-spinner.js +0 -0
  143. /package/dist/es2019/{button-group.js → containers/button-group.js} +0 -0
  144. /package/dist/es2019/{types.js → new-button/variants/default/types.js} +0 -0
  145. /package/dist/{esm → es2019/new-button/variants/icon}/types.js +0 -0
  146. /package/dist/es2019/{custom-theme-button/custom-theme-button-types.js → new-button/variants/types.js} +0 -0
  147. /package/dist/es2019/{button.js → old-button/button.js} +0 -0
  148. /package/dist/{esm → es2019/old-button}/custom-theme-button/custom-theme-button-types.js +0 -0
  149. /package/dist/es2019/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button.js +0 -0
  150. /package/dist/es2019/{custom-theme-button → old-button/custom-theme-button}/index.js +0 -0
  151. /package/dist/es2019/{custom-theme-button → old-button/custom-theme-button}/theme.js +0 -0
  152. /package/dist/es2019/{loading-button.js → old-button/loading-button.js} +0 -0
  153. /package/dist/es2019/{shared → old-button/shared}/block-events.js +0 -0
  154. /package/dist/es2019/{shared → old-button/shared}/colors.js +0 -0
  155. /package/dist/es2019/{shared → old-button/shared}/css.js +0 -0
  156. /package/dist/es2019/{shared → old-button/shared}/get-if-visually-hidden-children.js +0 -0
  157. /package/dist/es2019/{shared → old-button/shared}/get-is-only-single-icon.js +0 -0
  158. /package/dist/es2019/{shared → old-button/shared}/loading-spinner.js +0 -0
  159. /package/dist/esm/{button-group.js → containers/button-group.js} +0 -0
  160. /package/dist/esm/{button.js → old-button/button.js} +0 -0
  161. /package/dist/esm/{custom-theme-button → old-button/custom-theme-button}/index.js +0 -0
  162. /package/dist/esm/{loading-button.js → old-button/loading-button.js} +0 -0
  163. /package/dist/esm/{shared → old-button/shared}/block-events.js +0 -0
  164. /package/dist/esm/{shared → old-button/shared}/colors.js +0 -0
  165. /package/dist/esm/{shared → old-button/shared}/get-if-visually-hidden-children.js +0 -0
  166. /package/dist/esm/{shared → old-button/shared}/get-is-only-single-icon.js +0 -0
  167. /package/dist/esm/{shared → old-button/shared}/loading-spinner.js +0 -0
  168. /package/dist/types/{button.d.ts → old-button/button.d.ts} +0 -0
  169. /package/dist/types/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button-types.d.ts +0 -0
  170. /package/dist/types/{custom-theme-button → old-button/custom-theme-button}/index.d.ts +0 -0
  171. /package/dist/types/{custom-theme-button → old-button/custom-theme-button}/theme.d.ts +0 -0
  172. /package/dist/types/{loading-button.d.ts → old-button/loading-button.d.ts} +0 -0
  173. /package/dist/types/{shared → old-button/shared}/block-events.d.ts +0 -0
  174. /package/dist/types/{shared → old-button/shared}/button-base.d.ts +0 -0
  175. /package/dist/types/{shared → old-button/shared}/colors.d.ts +0 -0
  176. /package/dist/types/{shared → old-button/shared}/css.d.ts +0 -0
  177. /package/dist/types/{shared → old-button/shared}/get-if-visually-hidden-children.d.ts +0 -0
  178. /package/dist/types/{shared → old-button/shared}/get-is-only-single-icon.d.ts +0 -0
  179. /package/dist/types/{shared → old-button/shared}/loading-spinner.d.ts +0 -0
  180. /package/dist/types/{types.d.ts → old-button/types.d.ts} +0 -0
  181. /package/dist/types-ts4.5/{button.d.ts → old-button/button.d.ts} +0 -0
  182. /package/dist/types-ts4.5/{custom-theme-button → old-button/custom-theme-button}/custom-theme-button-types.d.ts +0 -0
  183. /package/dist/types-ts4.5/{custom-theme-button → old-button/custom-theme-button}/index.d.ts +0 -0
  184. /package/dist/types-ts4.5/{custom-theme-button → old-button/custom-theme-button}/theme.d.ts +0 -0
  185. /package/dist/types-ts4.5/{loading-button.d.ts → old-button/loading-button.d.ts} +0 -0
  186. /package/dist/types-ts4.5/{shared → old-button/shared}/block-events.d.ts +0 -0
  187. /package/dist/types-ts4.5/{shared → old-button/shared}/button-base.d.ts +0 -0
  188. /package/dist/types-ts4.5/{shared → old-button/shared}/colors.d.ts +0 -0
  189. /package/dist/types-ts4.5/{shared → old-button/shared}/css.d.ts +0 -0
  190. /package/dist/types-ts4.5/{shared → old-button/shared}/get-if-visually-hidden-children.d.ts +0 -0
  191. /package/dist/types-ts4.5/{shared → old-button/shared}/get-is-only-single-icon.d.ts +0 -0
  192. /package/dist/types-ts4.5/{shared → old-button/shared}/loading-spinner.d.ts +0 -0
  193. /package/dist/types-ts4.5/{types.d.ts → old-button/types.d.ts} +0 -0
@@ -0,0 +1,120 @@
1
+ import React, { Fragment, useCallback, useContext, useMemo, useRef } from 'react';
2
+ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
3
+ import noop from '@atlaskit/ds-lib/noop';
4
+ import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
5
+ // eslint-disable-next-line no-duplicate-imports
6
+ import InteractionContext from '@atlaskit/interaction-context';
7
+ import { Box } from '@atlaskit/primitives';
8
+ import blockEvents from './block-events';
9
+ import { getXCSS, overlayStyles } from './xcss';
10
+
11
+ // Include modified onClick with analytics
12
+
13
+ /**
14
+ * __Use button base__
15
+ *
16
+ * A React hook that accepts a set of common Button props,
17
+ * and processes them to return consistent base props for usage
18
+ * across various Button components.
19
+ *
20
+ * It also:
21
+ * - Implements auto focus when enabled.
22
+ * - Appends the `onClick` event with UFO analytics tracking.
23
+ *
24
+ * @private
25
+ */
26
+ const useButtonBase = ({
27
+ analyticsContext,
28
+ appearance = 'default',
29
+ autoFocus = false,
30
+ buttonType,
31
+ interactionName,
32
+ isDisabled = false,
33
+ isSelected = false,
34
+ // TODO: Separate Icon Button styling from button base
35
+ isIconButton = false,
36
+ // TODO: Separate icon slot styling from button base
37
+ hasIconBefore = false,
38
+ hasIconAfter = false,
39
+ children,
40
+ onClick: providedOnClick = noop,
41
+ onMouseDownCapture,
42
+ onMouseUpCapture,
43
+ onKeyDownCapture,
44
+ onKeyUpCapture,
45
+ onTouchStartCapture,
46
+ onTouchEndCapture,
47
+ onPointerDownCapture,
48
+ onPointerUpCapture,
49
+ onClickCapture,
50
+ overlay,
51
+ ref,
52
+ shouldFitContainer = false,
53
+ spacing = 'default'
54
+ }) => {
55
+ const ourRef = useRef();
56
+ const setRef = useCallback(node => {
57
+ ourRef.current = node;
58
+ if (ref === null) {
59
+ return;
60
+ }
61
+ if (typeof ref === 'function') {
62
+ ref(node);
63
+ return;
64
+ }
65
+
66
+ // @ts-ignore
67
+ ref.current = node;
68
+ }, [ourRef, ref]);
69
+ useAutoFocus(ourRef, autoFocus);
70
+ const interactionContext = useContext(InteractionContext);
71
+ const handleClick = useCallback((e, analyticsEvent) => {
72
+ interactionContext && interactionContext.tracePress(interactionName, e.timeStamp);
73
+ providedOnClick(e, analyticsEvent);
74
+ }, [providedOnClick, interactionContext, interactionName]);
75
+ const onClick = usePlatformLeafEventHandler({
76
+ fn: handleClick,
77
+ action: 'clicked',
78
+ componentName: 'button',
79
+ packageName: "@atlaskit/button",
80
+ packageVersion: "16.9.4",
81
+ analyticsData: analyticsContext,
82
+ actionSubject: buttonType
83
+ });
84
+ const buttonXCSS = useMemo(() => getXCSS({
85
+ appearance,
86
+ spacing,
87
+ isDisabled,
88
+ isSelected,
89
+ shouldFitContainer,
90
+ isIconButton,
91
+ hasOverlay: Boolean(overlay),
92
+ isLink: buttonType === 'link',
93
+ hasIconBefore,
94
+ hasIconAfter
95
+ }), [appearance, buttonType, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter]);
96
+ const isEffectivelyDisabled = isDisabled || Boolean(overlay);
97
+ return {
98
+ ref: setRef,
99
+ xcss: buttonXCSS,
100
+ // Consider overlay buttons to be effectively disabled
101
+ isDisabled: isEffectivelyDisabled,
102
+ children: /*#__PURE__*/React.createElement(Fragment, null, children, overlay ? /*#__PURE__*/React.createElement(Box, {
103
+ as: "span",
104
+ xcss: overlayStyles
105
+ }, overlay) : null),
106
+ ...blockEvents(isEffectivelyDisabled, {
107
+ onClick,
108
+ onMouseDownCapture,
109
+ onMouseUpCapture,
110
+ onKeyDownCapture,
111
+ onKeyUpCapture,
112
+ onTouchStartCapture,
113
+ onTouchEndCapture,
114
+ onPointerDownCapture,
115
+ onPointerUpCapture,
116
+ onClickCapture
117
+ })
118
+ };
119
+ };
120
+ export default useButtonBase;
@@ -0,0 +1,182 @@
1
+ import { xcss } from '@atlaskit/primitives';
2
+ import { fontSize as getFontSize } from '@atlaskit/theme/constants';
3
+ import colors from './colors';
4
+ const fontSize = getFontSize();
5
+ const heights = {
6
+ default: `${32 / fontSize}em`,
7
+ compact: `${24 / fontSize}em`,
8
+ none: 'auto'
9
+ };
10
+ const paddingInline = {
11
+ default: {
12
+ default: 'space.150',
13
+ withIcon: 'space.100'
14
+ },
15
+ compact: {
16
+ default: 'space.150',
17
+ withIcon: 'space.100'
18
+ },
19
+ none: {
20
+ default: 'space.0',
21
+ withIcon: 'space.0'
22
+ }
23
+ };
24
+ const gap = {
25
+ compact: 'space.050',
26
+ default: 'space.050',
27
+ none: 'space.0'
28
+ };
29
+ const verticalAlign = {
30
+ default: 'middle',
31
+ compact: 'middle',
32
+ none: 'baseline'
33
+ };
34
+ function getColor({
35
+ group,
36
+ key
37
+ }) {
38
+ return group[key] || group.default;
39
+ }
40
+ function getColors({
41
+ appearance,
42
+ interactionState = 'default',
43
+ isDisabled,
44
+ isSelected,
45
+ hasOverlay
46
+ }) {
47
+ let key = interactionState;
48
+ // Overlay does not change color on interaction, revert to 'default' or resting state
49
+ key = hasOverlay ? 'default' : key;
50
+ key = isSelected ? 'selected' : key;
51
+ // Disabled colors overrule everything else
52
+ key = isDisabled ? 'disabled' : key;
53
+ return {
54
+ backgroundColor: getColor({
55
+ group: colors.background[appearance],
56
+ key
57
+ }),
58
+ color: `${getColor({
59
+ group: colors.color[appearance],
60
+ key
61
+ })}`
62
+ };
63
+ }
64
+ export function getXCSS({
65
+ appearance,
66
+ spacing,
67
+ isDisabled,
68
+ isSelected,
69
+ isIconButton,
70
+ shouldFitContainer,
71
+ isLink,
72
+ hasOverlay,
73
+ hasIconBefore,
74
+ hasIconAfter
75
+ }) {
76
+ const baseColors = getColors({
77
+ appearance,
78
+ isSelected,
79
+ isDisabled
80
+ });
81
+ const combinedBaseColorStyles = isLink ? {
82
+ ...baseColors,
83
+ textDecoration: 'none',
84
+ // Disabling visited styles (by re-declaring the base colors)
85
+ ':visited': baseColors
86
+ } : baseColors;
87
+ const height = heights[spacing];
88
+ let width = shouldFitContainer ? '100%' : 'auto';
89
+ width = isIconButton ? height : width;
90
+ const paddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
91
+ const paddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
92
+ return xcss({
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,
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,
115
+ // justifyContent required for shouldFitContainer buttons with an icon inside
116
+ justifyContent: 'center',
117
+ ...combinedBaseColorStyles,
118
+ ...(isDisabled || hasOverlay ? {
119
+ cursor: 'not-allowed'
120
+ } : {}),
121
+ ':hover': {
122
+ ...getColors({
123
+ appearance,
124
+ isSelected,
125
+ isDisabled,
126
+ interactionState: 'hover',
127
+ hasOverlay
128
+ }),
129
+ textDecoration: !isSelected && (appearance === 'link' || appearance === 'subtle-link') ? 'underline' : 'none',
130
+ // background, box-shadow
131
+ transitionDuration: '0s, 0.15s'
132
+ },
133
+ ':active': {
134
+ ...getColors({
135
+ appearance,
136
+ isSelected,
137
+ isDisabled,
138
+ interactionState: 'active',
139
+ hasOverlay
140
+ }),
141
+ // background, box-shadow
142
+ transitionDuration: '0s, 0s'
143
+ }
144
+ });
145
+ }
146
+ export const iconStyles = xcss({
147
+ display: 'flex',
148
+ // icon size cannot grow and shrink
149
+ flexGrow: 0,
150
+ flexShrink: 0,
151
+ alignSelf: 'center',
152
+ fontSize: 0,
153
+ lineHeight: 0,
154
+ userSelect: 'none'
155
+ });
156
+ export const contentStyles = xcss({
157
+ // content can grow and shrink
158
+ flexGrow: 1,
159
+ flexShrink: 1,
160
+ // ellipsis for overflow text
161
+ overflow: 'hidden',
162
+ textOverflow: 'ellipsis',
163
+ whiteSpace: 'nowrap'
164
+ });
165
+ export function getFadingStyles({
166
+ hasOverlay
167
+ }) {
168
+ return xcss({
169
+ opacity: hasOverlay ? 0 : 1,
170
+ transition: 'opacity 0.3s'
171
+ });
172
+ }
173
+ export const overlayStyles = xcss({
174
+ position: 'absolute',
175
+ left: 'space.0',
176
+ top: 'space.0',
177
+ right: 'space.0',
178
+ bottom: 'space.0',
179
+ display: 'flex',
180
+ alignItems: 'center',
181
+ justifyContent: 'center'
182
+ });
@@ -69,10 +69,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
69
69
  // Pulling out so it doesn't spread on rendered component
70
70
  shouldFitContainer,
71
71
  spacing = 'default',
72
- // Don't set unnecessary tabIndex for focus if using standard <button> or <a>
73
- // html elements. Set to `0` for custom components to ensure other elements can
74
- // be focused (although the custom component could be a <button> or <a>...)
75
- tabIndex = !props.component && getBooleanFF('platform.design-system-team.clove-sprint-a11y-button_5rz5j') ? undefined : 0,
72
+ tabIndex = 0,
76
73
  type = !href ? 'button' : undefined,
77
74
  testId,
78
75
  ...rest
@@ -105,7 +102,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
105
102
  action: 'clicked',
106
103
  componentName: 'button',
107
104
  packageName: "@atlaskit/button",
108
- packageVersion: "16.9.3",
105
+ packageVersion: "16.9.4",
109
106
  analyticsData: analyticsContext
110
107
  });
111
108
 
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ const appearances = ['default', 'primary', 'link', 'subtle', 'subtle-link', 'warning', 'danger'];
2
+ export default appearances;
@@ -0,0 +1,2 @@
1
+ const spacing = ['default', 'compact', 'none'];
2
+ export default spacing;
@@ -0,0 +1,20 @@
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
+ const LinkButtonRender = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/React.createElement(LinkButton, _extends({
8
+ ref: ref,
9
+ href: "#"
10
+ }, props), props.children));
11
+ export const variants = [{
12
+ name: 'Button',
13
+ Component: Button,
14
+ elementType: HTMLButtonElement
15
+ }, {
16
+ name: 'LinkButton',
17
+ Component: LinkButtonRender,
18
+ elementType: HTMLAnchorElement
19
+ }];
20
+ export default variants;
@@ -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';
@@ -3,4 +3,4 @@
3
3
  * https://product-fabric.atlassian.net/browse/DSP-3222
4
4
  */
5
5
  import '@emotion/react';
6
- export { default } from '../button';
6
+ export { default } from '../old-button/button';
@@ -0,0 +1 @@
1
+ export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
@@ -0,0 +1,92 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "iconBefore", "iconAfter", "children", "shouldFitContainer", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId"];
4
+ import React from 'react';
5
+ import UNSAFE_PRESSABLE from '@atlaskit/primitives/pressable';
6
+ import useDefaultButton from './use-default-button';
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
+ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
19
+ var analyticsContext = _ref.analyticsContext,
20
+ autoFocus = _ref.autoFocus,
21
+ appearance = _ref.appearance,
22
+ spacing = _ref.spacing,
23
+ isDisabled = _ref.isDisabled,
24
+ isSelected = _ref.isSelected,
25
+ iconBefore = _ref.iconBefore,
26
+ iconAfter = _ref.iconAfter,
27
+ children = _ref.children,
28
+ shouldFitContainer = _ref.shouldFitContainer,
29
+ interactionName = _ref.interactionName,
30
+ overlay = _ref.overlay,
31
+ onClick = _ref.onClick,
32
+ onMouseDownCapture = _ref.onMouseDownCapture,
33
+ onMouseUpCapture = _ref.onMouseUpCapture,
34
+ onKeyDownCapture = _ref.onKeyDownCapture,
35
+ onKeyUpCapture = _ref.onKeyUpCapture,
36
+ onTouchStartCapture = _ref.onTouchStartCapture,
37
+ onTouchEndCapture = _ref.onTouchEndCapture,
38
+ onPointerDownCapture = _ref.onPointerDownCapture,
39
+ onPointerUpCapture = _ref.onPointerUpCapture,
40
+ onClickCapture = _ref.onClickCapture,
41
+ _ref$type = _ref.type,
42
+ type = _ref$type === void 0 ? 'button' : _ref$type,
43
+ testId = _ref.testId,
44
+ rest = _objectWithoutProperties(_ref, _excluded);
45
+ var baseProps = useDefaultButton({
46
+ analyticsContext: analyticsContext,
47
+ appearance: appearance,
48
+ autoFocus: autoFocus,
49
+ buttonType: 'button',
50
+ children: children,
51
+ iconBefore: iconBefore,
52
+ iconAfter: iconAfter,
53
+ interactionName: interactionName,
54
+ isDisabled: isDisabled,
55
+ isSelected: isSelected,
56
+ onClick: onClick,
57
+ onMouseDownCapture: onMouseDownCapture,
58
+ onMouseUpCapture: onMouseUpCapture,
59
+ onKeyDownCapture: onKeyDownCapture,
60
+ onKeyUpCapture: onKeyUpCapture,
61
+ onTouchStartCapture: onTouchStartCapture,
62
+ onTouchEndCapture: onTouchEndCapture,
63
+ onPointerDownCapture: onPointerDownCapture,
64
+ onPointerUpCapture: onPointerUpCapture,
65
+ onClickCapture: onClickCapture,
66
+ overlay: overlay,
67
+ ref: ref,
68
+ shouldFitContainer: shouldFitContainer,
69
+ spacing: spacing
70
+ });
71
+ return /*#__PURE__*/React.createElement(UNSAFE_PRESSABLE
72
+ // TODO: Remove spread props
73
+ , _extends({}, rest, {
74
+ ref: baseProps.ref,
75
+ xcss: baseProps.xcss,
76
+ isDisabled: baseProps.isDisabled,
77
+ onClick: baseProps.onClick,
78
+ onMouseDownCapture: baseProps.onMouseDownCapture,
79
+ onMouseUpCapture: baseProps.onMouseUpCapture,
80
+ onKeyDownCapture: baseProps.onKeyDownCapture,
81
+ onKeyUpCapture: baseProps.onKeyUpCapture,
82
+ onTouchStartCapture: baseProps.onTouchStartCapture,
83
+ onTouchEndCapture: baseProps.onTouchEndCapture,
84
+ onPointerDownCapture: baseProps.onPointerDownCapture,
85
+ onPointerUpCapture: baseProps.onPointerUpCapture,
86
+ onClickCapture: baseProps.onClickCapture,
87
+ type: type,
88
+ testId: testId
89
+ }), baseProps.children);
90
+ }));
91
+ Button.displayName = 'Button';
92
+ export default Button;
@@ -0,0 +1,98 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "iconBefore", "iconAfter", "children", "shouldFitContainer", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
4
+ import React from 'react';
5
+ import { Box } from '@atlaskit/primitives';
6
+ import useDefaultButton from './use-default-button';
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
+ var LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkButton(_ref, ref) {
17
+ var analyticsContext = _ref.analyticsContext,
18
+ autoFocus = _ref.autoFocus,
19
+ appearance = _ref.appearance,
20
+ spacing = _ref.spacing,
21
+ isDisabled = _ref.isDisabled,
22
+ isSelected = _ref.isSelected,
23
+ iconBefore = _ref.iconBefore,
24
+ iconAfter = _ref.iconAfter,
25
+ children = _ref.children,
26
+ shouldFitContainer = _ref.shouldFitContainer,
27
+ interactionName = _ref.interactionName,
28
+ overlay = _ref.overlay,
29
+ onClick = _ref.onClick,
30
+ onMouseDownCapture = _ref.onMouseDownCapture,
31
+ onMouseUpCapture = _ref.onMouseUpCapture,
32
+ onKeyDownCapture = _ref.onKeyDownCapture,
33
+ onKeyUpCapture = _ref.onKeyUpCapture,
34
+ onTouchStartCapture = _ref.onTouchStartCapture,
35
+ onTouchEndCapture = _ref.onTouchEndCapture,
36
+ onPointerDownCapture = _ref.onPointerDownCapture,
37
+ onPointerUpCapture = _ref.onPointerUpCapture,
38
+ onClickCapture = _ref.onClickCapture,
39
+ testId = _ref.testId,
40
+ href = _ref.href,
41
+ rest = _objectWithoutProperties(_ref, _excluded);
42
+ var baseProps = useDefaultButton({
43
+ analyticsContext: analyticsContext,
44
+ appearance: appearance,
45
+ autoFocus: autoFocus,
46
+ buttonType: 'link',
47
+ children: children,
48
+ iconBefore: iconBefore,
49
+ iconAfter: iconAfter,
50
+ interactionName: interactionName,
51
+ isDisabled: isDisabled,
52
+ isSelected: isSelected,
53
+ onClick: onClick,
54
+ onMouseDownCapture: onMouseDownCapture,
55
+ onMouseUpCapture: onMouseUpCapture,
56
+ onKeyDownCapture: onKeyDownCapture,
57
+ onKeyUpCapture: onKeyUpCapture,
58
+ onTouchStartCapture: onTouchStartCapture,
59
+ onTouchEndCapture: onTouchEndCapture,
60
+ onPointerDownCapture: onPointerDownCapture,
61
+ onPointerUpCapture: onPointerUpCapture,
62
+ onClickCapture: onClickCapture,
63
+ overlay: overlay,
64
+ ref: ref,
65
+ shouldFitContainer: shouldFitContainer,
66
+ spacing: 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 @@
1
+ export {};
@@ -0,0 +1,79 @@
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
+ var useDefaultButton = function useDefaultButton(_ref) {
15
+ var analyticsContext = _ref.analyticsContext,
16
+ appearance = _ref.appearance,
17
+ autoFocus = _ref.autoFocus,
18
+ buttonType = _ref.buttonType,
19
+ iconBefore = _ref.iconBefore,
20
+ iconAfter = _ref.iconAfter,
21
+ interactionName = _ref.interactionName,
22
+ isDisabled = _ref.isDisabled,
23
+ isSelected = _ref.isSelected,
24
+ children = _ref.children,
25
+ onClick = _ref.onClick,
26
+ onMouseDownCapture = _ref.onMouseDownCapture,
27
+ onMouseUpCapture = _ref.onMouseUpCapture,
28
+ onKeyDownCapture = _ref.onKeyDownCapture,
29
+ onKeyUpCapture = _ref.onKeyUpCapture,
30
+ onTouchStartCapture = _ref.onTouchStartCapture,
31
+ onTouchEndCapture = _ref.onTouchEndCapture,
32
+ onPointerDownCapture = _ref.onPointerDownCapture,
33
+ onPointerUpCapture = _ref.onPointerUpCapture,
34
+ onClickCapture = _ref.onClickCapture,
35
+ overlay = _ref.overlay,
36
+ ref = _ref.ref,
37
+ shouldFitContainer = _ref.shouldFitContainer,
38
+ spacing = _ref.spacing;
39
+ var fadeStyles = getFadingStyles({
40
+ hasOverlay: Boolean(overlay)
41
+ });
42
+ var baseProps = useButtonBase({
43
+ analyticsContext: analyticsContext,
44
+ appearance: appearance,
45
+ autoFocus: autoFocus,
46
+ buttonType: buttonType,
47
+ children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Box, {
48
+ as: "span",
49
+ xcss: [fadeStyles, iconStyles]
50
+ }, iconBefore), children && /*#__PURE__*/React.createElement(Box, {
51
+ as: "span",
52
+ xcss: [fadeStyles, contentStyles]
53
+ }, children), iconAfter && /*#__PURE__*/React.createElement(Box, {
54
+ as: "span",
55
+ xcss: [fadeStyles, iconStyles]
56
+ }, iconAfter)),
57
+ interactionName: interactionName,
58
+ isDisabled: isDisabled,
59
+ isSelected: isSelected,
60
+ onClick: onClick,
61
+ onMouseDownCapture: onMouseDownCapture,
62
+ onMouseUpCapture: onMouseUpCapture,
63
+ onKeyDownCapture: onKeyDownCapture,
64
+ onKeyUpCapture: onKeyUpCapture,
65
+ onTouchStartCapture: onTouchStartCapture,
66
+ onTouchEndCapture: onTouchEndCapture,
67
+ onPointerDownCapture: onPointerDownCapture,
68
+ onPointerUpCapture: onPointerUpCapture,
69
+ onClickCapture: onClickCapture,
70
+ overlay: overlay,
71
+ ref: ref,
72
+ shouldFitContainer: shouldFitContainer,
73
+ spacing: spacing,
74
+ hasIconBefore: Boolean(iconBefore),
75
+ hasIconAfter: Boolean(iconAfter)
76
+ });
77
+ return baseProps;
78
+ };
79
+ export default useDefaultButton;