@atlaskit/button 16.9.2 → 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 +13 -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,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;
@@ -0,0 +1,88 @@
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", "icon", "children", "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 useIconButton from './use-icon-button';
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
+ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button(_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
+ icon = _ref.icon,
24
+ children = _ref.children,
25
+ interactionName = _ref.interactionName,
26
+ overlay = _ref.overlay,
27
+ onClick = _ref.onClick,
28
+ onMouseDownCapture = _ref.onMouseDownCapture,
29
+ onMouseUpCapture = _ref.onMouseUpCapture,
30
+ onKeyDownCapture = _ref.onKeyDownCapture,
31
+ onKeyUpCapture = _ref.onKeyUpCapture,
32
+ onTouchStartCapture = _ref.onTouchStartCapture,
33
+ onTouchEndCapture = _ref.onTouchEndCapture,
34
+ onPointerDownCapture = _ref.onPointerDownCapture,
35
+ onPointerUpCapture = _ref.onPointerUpCapture,
36
+ onClickCapture = _ref.onClickCapture,
37
+ _ref$type = _ref.type,
38
+ type = _ref$type === void 0 ? 'button' : _ref$type,
39
+ testId = _ref.testId,
40
+ rest = _objectWithoutProperties(_ref, _excluded);
41
+ /**
42
+ * TODO: At some stage I'll look into re-using more logic across 'default' and 'icon'
43
+ * buttons. It's currently duplicated and mostly the same.
44
+ */
45
+ var baseProps = useIconButton({
46
+ analyticsContext: analyticsContext,
47
+ appearance: appearance,
48
+ autoFocus: autoFocus,
49
+ buttonType: 'button',
50
+ children: children,
51
+ icon: icon,
52
+ interactionName: interactionName,
53
+ isDisabled: isDisabled,
54
+ isSelected: isSelected,
55
+ onClick: onClick,
56
+ onMouseDownCapture: onMouseDownCapture,
57
+ onMouseUpCapture: onMouseUpCapture,
58
+ onKeyDownCapture: onKeyDownCapture,
59
+ onKeyUpCapture: onKeyUpCapture,
60
+ onTouchStartCapture: onTouchStartCapture,
61
+ onTouchEndCapture: onTouchEndCapture,
62
+ onPointerDownCapture: onPointerDownCapture,
63
+ onPointerUpCapture: onPointerUpCapture,
64
+ onClickCapture: onClickCapture,
65
+ overlay: overlay,
66
+ ref: ref,
67
+ spacing: spacing
68
+ });
69
+ return /*#__PURE__*/React.createElement(UNSAFE_PRESSABLE, _extends({}, rest, {
70
+ ref: baseProps.ref,
71
+ xcss: baseProps.xcss,
72
+ isDisabled: baseProps.isDisabled,
73
+ onClick: baseProps.onClick,
74
+ onMouseDownCapture: baseProps.onMouseDownCapture,
75
+ onMouseUpCapture: baseProps.onMouseUpCapture,
76
+ onKeyDownCapture: baseProps.onKeyDownCapture,
77
+ onKeyUpCapture: baseProps.onKeyUpCapture,
78
+ onTouchStartCapture: baseProps.onTouchStartCapture,
79
+ onTouchEndCapture: baseProps.onTouchEndCapture,
80
+ onPointerDownCapture: baseProps.onPointerDownCapture,
81
+ onPointerUpCapture: baseProps.onPointerUpCapture,
82
+ onClickCapture: baseProps.onClickCapture,
83
+ type: type,
84
+ testId: testId
85
+ }), baseProps.children);
86
+ }));
87
+ IconButton.displayName = 'IconButton';
88
+ export default IconButton;
@@ -0,0 +1,94 @@
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", "icon", "children", "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 useIconButton from './use-icon-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 LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkIconButton(_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
+ icon = _ref.icon,
24
+ children = _ref.children,
25
+ interactionName = _ref.interactionName,
26
+ overlay = _ref.overlay,
27
+ onClick = _ref.onClick,
28
+ onMouseDownCapture = _ref.onMouseDownCapture,
29
+ onMouseUpCapture = _ref.onMouseUpCapture,
30
+ onKeyDownCapture = _ref.onKeyDownCapture,
31
+ onKeyUpCapture = _ref.onKeyUpCapture,
32
+ onTouchStartCapture = _ref.onTouchStartCapture,
33
+ onTouchEndCapture = _ref.onTouchEndCapture,
34
+ onPointerDownCapture = _ref.onPointerDownCapture,
35
+ onPointerUpCapture = _ref.onPointerUpCapture,
36
+ onClickCapture = _ref.onClickCapture,
37
+ testId = _ref.testId,
38
+ href = _ref.href,
39
+ rest = _objectWithoutProperties(_ref, _excluded);
40
+ var baseProps = useIconButton({
41
+ analyticsContext: analyticsContext,
42
+ appearance: appearance,
43
+ autoFocus: autoFocus,
44
+ buttonType: 'link',
45
+ children: children,
46
+ icon: icon,
47
+ interactionName: interactionName,
48
+ isDisabled: isDisabled,
49
+ isSelected: isSelected,
50
+ onClick: onClick,
51
+ onMouseDownCapture: onMouseDownCapture,
52
+ onMouseUpCapture: onMouseUpCapture,
53
+ onKeyDownCapture: onKeyDownCapture,
54
+ onKeyUpCapture: onKeyUpCapture,
55
+ onTouchStartCapture: onTouchStartCapture,
56
+ onTouchEndCapture: onTouchEndCapture,
57
+ onPointerDownCapture: onPointerDownCapture,
58
+ onPointerUpCapture: onPointerUpCapture,
59
+ onClickCapture: onClickCapture,
60
+ overlay: overlay,
61
+ ref: ref,
62
+ spacing: 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 @@
1
+ export {};
@@ -0,0 +1,74 @@
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
+ var useIconButton = function useIconButton(_ref) {
15
+ var analyticsContext = _ref.analyticsContext,
16
+ appearance = _ref.appearance,
17
+ autoFocus = _ref.autoFocus,
18
+ buttonType = _ref.buttonType,
19
+ icon = _ref.icon,
20
+ interactionName = _ref.interactionName,
21
+ isDisabled = _ref.isDisabled,
22
+ isSelected = _ref.isSelected,
23
+ onClick = _ref.onClick,
24
+ onMouseDownCapture = _ref.onMouseDownCapture,
25
+ onMouseUpCapture = _ref.onMouseUpCapture,
26
+ onKeyDownCapture = _ref.onKeyDownCapture,
27
+ onKeyUpCapture = _ref.onKeyUpCapture,
28
+ onTouchStartCapture = _ref.onTouchStartCapture,
29
+ onTouchEndCapture = _ref.onTouchEndCapture,
30
+ onPointerDownCapture = _ref.onPointerDownCapture,
31
+ onPointerUpCapture = _ref.onPointerUpCapture,
32
+ onClickCapture = _ref.onClickCapture,
33
+ overlay = _ref.overlay,
34
+ ref = _ref.ref,
35
+ shouldFitContainer = _ref.shouldFitContainer,
36
+ spacing = _ref.spacing;
37
+ var fadeStyles = getFadingStyles({
38
+ hasOverlay: Boolean(overlay)
39
+ });
40
+ var baseProps = useButtonBase({
41
+ analyticsContext: analyticsContext,
42
+ appearance: appearance,
43
+ autoFocus: autoFocus,
44
+ buttonType: buttonType,
45
+ /**
46
+ * TODO: Have not finished IconButton yet. It also needs a required accessible
47
+ * label - likely implemented using VisuallyHidden
48
+ */
49
+ children: /*#__PURE__*/React.createElement(Box, {
50
+ as: "span",
51
+ xcss: [fadeStyles, iconStyles]
52
+ }, icon),
53
+ interactionName: interactionName,
54
+ isDisabled: isDisabled,
55
+ isSelected: isSelected,
56
+ isIconButton: true,
57
+ onClick: onClick,
58
+ onMouseDownCapture: onMouseDownCapture,
59
+ onMouseUpCapture: onMouseUpCapture,
60
+ onKeyDownCapture: onKeyDownCapture,
61
+ onKeyUpCapture: onKeyUpCapture,
62
+ onTouchStartCapture: onTouchStartCapture,
63
+ onTouchEndCapture: onTouchEndCapture,
64
+ onPointerDownCapture: onPointerDownCapture,
65
+ onPointerUpCapture: onPointerUpCapture,
66
+ onClickCapture: onClickCapture,
67
+ overlay: overlay,
68
+ ref: ref,
69
+ shouldFitContainer: shouldFitContainer,
70
+ spacing: spacing
71
+ });
72
+ return baseProps;
73
+ };
74
+ export default useIconButton;
@@ -0,0 +1,27 @@
1
+ function abort(event) {
2
+ event.preventDefault();
3
+ event.stopPropagation();
4
+ }
5
+ var 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
+ }
@@ -0,0 +1,120 @@
1
+ import * as colors from '@atlaskit/theme/colors';
2
+ var values = {
3
+ // Default appearance
4
+ background: {
5
+ default: {
6
+ /**
7
+ * Some colors need specific fallback colors specified
8
+ * to match the original Button when no theme is active.
9
+ *
10
+ * This is because the `xcss` automatic token fallbacks use
11
+ * the legacy themes, which do not match original colors.
12
+ */
13
+ // @ts-expect-error
14
+ default: "var(--ds-background-neutral, ".concat(colors.N20A, ")"),
15
+ hover: 'color.background.neutral.hovered',
16
+ active: 'color.background.neutral.pressed',
17
+ // @ts-expect-error
18
+ disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
19
+ // @ts-expect-error
20
+ selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
21
+ },
22
+ primary: {
23
+ default: 'color.background.brand.bold',
24
+ hover: 'color.background.brand.bold.hovered',
25
+ active: 'color.background.brand.bold.pressed',
26
+ // @ts-expect-error
27
+ disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
28
+ // @ts-expect-error
29
+ selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
30
+ },
31
+ warning: {
32
+ default: 'color.background.warning.bold',
33
+ hover: 'color.background.warning.bold.hovered',
34
+ active: 'color.background.warning.bold.pressed',
35
+ // @ts-expect-error
36
+ disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
37
+ // @ts-expect-error
38
+ selected: "var(--ds-background-selected, ".concat(colors.Y400, ")")
39
+ },
40
+ danger: {
41
+ default: 'color.background.danger.bold',
42
+ hover: 'color.background.danger.bold.hovered',
43
+ active: 'color.background.danger.bold.pressed',
44
+ // @ts-expect-error
45
+ disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
46
+ // @ts-expect-error
47
+ selected: "var(--ds-background-selected, ".concat(colors.R500, ")")
48
+ },
49
+ link: {
50
+ default: 'color.background.neutral.subtle',
51
+ // @ts-expect-error
52
+ selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
53
+ },
54
+ subtle: {
55
+ default: 'color.background.neutral.subtle',
56
+ hover: 'color.background.neutral.subtle.hovered',
57
+ active: 'color.background.neutral.subtle.pressed',
58
+ // @ts-expect-error
59
+ disabled: "var(--ds-background-neutral-subtle, none)",
60
+ // @ts-expect-error
61
+ selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
62
+ },
63
+ 'subtle-link': {
64
+ default: 'color.background.neutral.subtle',
65
+ // @ts-expect-error
66
+ selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
67
+ }
68
+ },
69
+ color: {
70
+ default: {
71
+ default: 'color.text',
72
+ active: 'color.text',
73
+ disabled: 'color.text.disabled',
74
+ // @ts-expect-error
75
+ selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
76
+ },
77
+ primary: {
78
+ default: 'color.text.inverse',
79
+ disabled: 'color.text.disabled',
80
+ // @ts-expect-error
81
+ selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
82
+ },
83
+ warning: {
84
+ default: 'color.text.warning.inverse',
85
+ disabled: 'color.text.disabled',
86
+ // @ts-expect-error
87
+ selected: "var(--ds-text-selected, ".concat(colors.N800, ")")
88
+ },
89
+ danger: {
90
+ default: 'color.text.inverse',
91
+ disabled: 'color.text.disabled',
92
+ // @ts-expect-error
93
+ selected: "var(--ds-text-selected, ".concat(colors.N0, ")")
94
+ },
95
+ link: {
96
+ default: 'color.link',
97
+ hover: 'color.link',
98
+ active: 'color.link.pressed',
99
+ disabled: 'color.text.disabled',
100
+ // @ts-expect-error
101
+ selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
102
+ },
103
+ subtle: {
104
+ default: 'color.text',
105
+ active: 'color.text',
106
+ disabled: 'color.text.disabled',
107
+ // @ts-expect-error
108
+ selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
109
+ },
110
+ 'subtle-link': {
111
+ default: 'color.text.subtle',
112
+ hover: 'color.text.subtle',
113
+ active: 'color.text',
114
+ disabled: 'color.text.disabled',
115
+ // @ts-expect-error
116
+ selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
117
+ }
118
+ }
119
+ };
120
+ export default values;