@atlaskit/primitives 2.1.0 → 3.0.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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#58240](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58240) [`a45d2049a22c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a45d2049a22c) - The "Link" primitive has been renamed to "Anchor" to avoid confusion with the upcoming "Link" component. Since Link is still in Alpha this should not cause any upgrade friction.
8
+
9
+ ### Minor Changes
10
+
11
+ - [#58240](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58240) [`75b2ade8b254`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/75b2ade8b254) - Both the Pressable and Anchor primitives now support analytics tracking by default.
12
+ - [#58240](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58240) [`39f3c929f0c4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/39f3c929f0c4) - Add Pressable and Anchor primitives (in Alpha) to root export as `UNSAFE_PRESSABLE` and `UNSAFE_LINK`.
13
+
14
+ ### Patch Changes
15
+
16
+ - [#58240](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58240) [`4951390bc0ae`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4951390bc0ae) - [ux] Adds a default underline style to the Anchor primitive (Alpha)
17
+
3
18
  ## 2.1.0
4
19
 
5
20
  ### Minor Changes
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/primitives/anchor",
3
+ "main": "../dist/cjs/components/anchor.js",
4
+ "module": "../dist/esm/components/anchor.js",
5
+ "module:es2019": "../dist/es2019/components/anchor.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/components/anchor.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/components/anchor.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Anchor
3
+ description: An anchor is a primitive for building custom links.
4
+ order: 1
5
+ ---
6
+
7
+ import { CodeDocsHeader } from '@af/design-system-docs-ui';
8
+
9
+ <CodeDocsHeader
10
+ name="@atlaskit/primitives"
11
+ repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
12
+ directoryName="primitives"
13
+ />
14
+
15
+ import ERTAnchor from '!!extract-react-types-loader!../../extract-react-types/anchor-props';
16
+
17
+ ## Props
18
+
19
+ Anchor also supports all valid `HTMLAnchorElement` props.
20
+
21
+ <PropsTable heading="" props={ERTAnchor} />
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: Anchor
3
+ description: An anchor is a primitive for building custom links.
4
+ order: 0
5
+ ---
6
+
7
+ import AnchorDefault from '../../examples/constellation/anchor/default';
8
+ import AnchorStyled from '../../examples/constellation/anchor/styled';
9
+
10
+ import { CodeDocsHeader } from '@af/design-system-docs-ui';
11
+ import SectionMessage from '@atlaskit/section-message';
12
+
13
+ <CodeDocsHeader
14
+ name="@atlaskit/primitives"
15
+ repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
16
+ directoryName="primitives"
17
+ />
18
+
19
+ Anchor is a primitive used for building custom anchor links, with support for client-side routing and Atlassian Design System styling. This component is used by other design system components, such as the [Link component](/components/link/examples).
20
+
21
+ For most links, use the [Link component](/components/link/examples) wherever possible, and use [XCSS](/components/primitives/xcss/usage) for any necessary customization. Only use Anchor if you aren't able to use Link.
22
+
23
+ ## Default
24
+
25
+ Anchor comes unstyled, ready for styles to be applied. Note if you are using the [CSS reset](/components/css-reset/examples), anchor will inherit some default styles.
26
+
27
+ <Example Component={AnchorDefault} packageName="@atlaskit/primitives/anchor" />
28
+
29
+ ## Styling
30
+
31
+ Anchor consumes the Box primitive to provide a consistent styling API that supports design tokens. See [Box](/components/primitives/box/examples) for complete styling documentation and examples.
32
+
33
+ <Example Component={AnchorStyled} packageName="@atlaskit/primitives/anchor" />
@@ -0,0 +1,47 @@
1
+ ---
2
+ title: Anchor
3
+ description: An anchor is a primitive for building custom links.
4
+ order: 2
5
+ ---
6
+
7
+ ## When not to use Anchor
8
+
9
+ The [Link component](/components/link/usage) should be used whenever possible for links to maintain visual consistency. Only use Anchor when building custom links beyond the capabilities of the Link component. The decision to use Anchor should involve checking if the Link component can be customized to fit your needs using [XCSS](/components/primitives/XCSS/usage).
10
+
11
+ Do not use Anchor for buttons that perform actions rather than navigation. Use the equivalent [Pressable primitive](/components/primitives/pressable/usage) instead.
12
+
13
+ ## Link types
14
+
15
+ External links starting with `http://` or `https://` will automatically render with `target="_blank"` and `rel="noopener noreferrer"` attributes.
16
+
17
+ ### Router links
18
+
19
+ Anchor supports automatic consumption of configured router link components through the [App Provider](/components/app-provider/examples#router-links). If an App Provider is not present or a router link component is not configured, the link will render as a standard anchor link.
20
+
21
+ External links and non-HTTP-based links such as `tel:` and `mailto:` will not use router links and always render as standard anchor links.
22
+
23
+ Anchor accepts a generic type object matching the router link configuration, allowing advanced usage of `href` prop. These values can be mapped to the underlying router link component in the App Provider.
24
+
25
+ ```jsx
26
+ <Anchor<MyRouterLinkConfig>
27
+ href={{
28
+ to: '/home',
29
+ replace: true
30
+ }}
31
+ >
32
+ Home
33
+ </Anchor>
34
+ ```
35
+
36
+ ## Styling
37
+
38
+ Display behavior follows the same patterns as [Box](/components/primitives/box/usage). Use available props or [XCSS](/components/primitives/xcss/usage) to customize padding options, background color, and other styles.
39
+
40
+ ## Related
41
+
42
+ - [Configuring router link components with AppProvider](/components/app-provider/examples#router-links)
43
+ - [The underlying box component](/components/primitives/box/usage)
44
+ - [Counterpart pressable primitive for button tags](/components/primitives/button/usage)
45
+ - [Manage horizontal layout using an inline component](/components/primitives/inline/usage)
46
+ - [Manage vertical layout using a stack component](/components/primitives/stack/usage)
47
+ - [Use design tokens in code with XCSS](/components/primitives/XCSS/usage)
@@ -53,13 +53,15 @@ For more information on XCSS, see the dedicated [XCSS documentation](/components
53
53
 
54
54
  ## Conditional styles
55
55
 
56
- To achieve conditional styles, it is usually simpler to apply conditional behavior at the `xcss` object level, rather than applying conditional behavior to individual properties.
56
+ To achieve conditional styles, we suggest composing conditional styles via the `props.xcss` API rather than applying conditional behaviour to individual props.
57
57
 
58
58
  <Example Component={BoxConditional} packageName="@atlaskit/primitives/box" />
59
59
 
60
- ## Practical use case
60
+ ## Practical card example
61
61
 
62
- Box is designed to be used in conjunction with the inline and stack components to create layouts. This example demonstrates how these can be used to create familiar components and patterns.
62
+ Box is designed to be composed with inline, stack, and other components to create layouts.
63
+
64
+ Atlassian uses dozens of distinct card-like components across products. Therefore, rather than providing a strict component, the Atlassian Design System empowers and supports you to build your own card components in ways that are consistent and will scale over time.
63
65
 
64
66
  <Example
65
67
  Component={BoxPracticalUseCase}
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Pressable
3
+ description: A pressable is a primitive used for building custom buttons.
4
+ order: 1
5
+ ---
6
+
7
+ import { CodeDocsHeader } from '@af/design-system-docs-ui';
8
+
9
+ <CodeDocsHeader
10
+ name="@atlaskit/primitives"
11
+ repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
12
+ directoryName="primitives"
13
+ />
14
+
15
+ import ERTPressable from '!!extract-react-types-loader!../../extract-react-types/pressable-props';
16
+
17
+ ## Props
18
+
19
+ Pressable also supports all valid `HTMLButtonElement` props, except for `disabled` which is replaced by the `isDisabled` prop.
20
+
21
+ <PropsTable heading="" props={ERTPressable} />
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Pressable
3
+ description: A pressable is a primitive used for building custom buttons.
4
+ order: 0
5
+ ---
6
+
7
+ import PressableDefault from '../../examples/constellation/pressable/default';
8
+ import PressableStyled from '../../examples/constellation/pressable/styled';
9
+
10
+ import { CodeDocsHeader } from '@af/design-system-docs-ui';
11
+ import SectionMessage from '@atlaskit/section-message';
12
+
13
+ <CodeDocsHeader
14
+ name="@atlaskit/primitives"
15
+ repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
16
+ directoryName="primitives"
17
+ />
18
+
19
+ Pressable is a primitive used for building custom buttons with Atlassian Design System styling. This component is used by other design system components, such as the [Button component](/components/button/examples).
20
+
21
+ For most buttons, use the [Button component](/components/button/examples) wherever possible, and use [XCSS](/components/primitives/xcss/usage) for any necessary customization. Only use pressable if you aren't able to use the button component.
22
+
23
+ ## Default
24
+
25
+ Pressable comes unstyled, ready for styles to be applied.
26
+
27
+ <Example
28
+ Component={PressableDefault}
29
+ packageName="@atlaskit/primitives/pressable"
30
+ />
31
+
32
+ ## Styling
33
+
34
+ Pressable consumes the Box primitive to provide a consistent styling API that supports design tokens. See [Box](/components/primitives/box/examples) for complete styling documentation and examples.
35
+
36
+ <Example
37
+ Component={PressableStyled}
38
+ packageName="@atlaskit/primitives/pressable"
39
+ />
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Pressable
3
+ description: A pressable is a primitive used for building custom buttons.
4
+ order: 2
5
+ ---
6
+
7
+ ## When not to use pressable
8
+
9
+ The [Button component](/components/button/usage) should be used whenever possible for buttons to maintain visual consistency. Only use pressable when building custom buttons beyond the capabilities of the button component. The decision to use pressable should involve checking if the button component can be customized to fit your needs using [XCSS](/components/primitives/XCSS/usage).
10
+
11
+ Do not use Pressable for links (anchor tags). Use the equivalent [Anchor primitive](/components/primitives/anchor/usage) instead.
12
+
13
+ ## Styling
14
+
15
+ Display behavior follows the same patterns as [Box](/components/primitives/box/usage). Use available props or [XCSS](/components/primitives/xcss/usage) to customize padding options, background color, and other styles.
16
+
17
+ ## Related
18
+
19
+ - [The underlying box component](/components/primitives/box/usage)
20
+ - [Counterpart anchor primitive for anchor tags](/components/primitives/anchor/usage)
21
+ - [Manage horizontal layout using an inline component](/components/primitives/inline/usage)
22
+ - [Manage vertical layout using a stack component](/components/primitives/stack/usage)
23
+ - [Use design tokens in code with XCSS](/components/primitives/XCSS/usage)
@@ -37,6 +37,6 @@ XCSS also accepts a subset of media queries at [predefined breakpoints](/compone
37
37
 
38
38
  ## Conditional styles
39
39
 
40
- To achieve conditional styles, it is usually simpler to apply conditional behavior at the `xcss` object level, rather than applying conditional behavior to individual properties.
40
+ For conditional styles, try composing styles together via the array with ternary or boolean operators.
41
41
 
42
42
  <Example Component={xcssConditional} packageName="@atlaskit/primitives/xcss" />
@@ -29,6 +29,9 @@ var baseFocusRingStyles = {
29
29
  outlineStyle: 'solid',
30
30
  outlineOffset: 'space.025'
31
31
  };
32
+ var defaultStyles = (0, _xcss.xcss)({
33
+ textDecoration: 'underline'
34
+ });
32
35
  var focusRingStyles = (0, _xcss.xcss)({
33
36
  ':focus-visible': baseFocusRingStyles,
34
37
  '@supports not selector(*:focus-visible)': {
@@ -42,7 +45,7 @@ var focusRingStyles = (0, _xcss.xcss)({
42
45
  });
43
46
  var IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
44
47
  var IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
45
- var Link = function Link(_ref, ref) {
48
+ var Anchor = function Anchor(_ref, ref) {
46
49
  var href = _ref.href,
47
50
  children = _ref.children,
48
51
  backgroundColor = _ref.backgroundColor,
@@ -73,14 +76,14 @@ var Link = function Link(_ref, ref) {
73
76
  action: 'clicked',
74
77
  componentName: componentName || 'Anchor',
75
78
  packageName: "@atlaskit/primitives",
76
- packageVersion: "2.1.0",
79
+ packageVersion: "3.0.0",
77
80
  analyticsData: analyticsContext,
78
81
  actionSubject: 'link'
79
82
  });
80
83
  var RouterLink = (0, _appProvider.useRouterLink)();
81
84
 
82
85
  // Combine default styles with supplied styles. XCSS does not support deep nested arrays
83
- var styles = Array.isArray(xcssStyles) ? [focusRingStyles].concat((0, _toConsumableArray2.default)(xcssStyles)) : [focusRingStyles, xcssStyles];
86
+ var styles = Array.isArray(xcssStyles) ? [defaultStyles, focusRingStyles].concat((0, _toConsumableArray2.default)(xcssStyles)) : [defaultStyles, focusRingStyles, xcssStyles];
84
87
  var isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
85
88
  var isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
86
89
 
@@ -93,7 +96,7 @@ var Link = function Link(_ref, ref) {
93
96
  */
94
97
  var isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
95
98
  var hrefObjectUsedWithoutRouterLink = RouterLink === undefined && (0, _typeof2.default)(href) === 'object';
96
- (0, _tinyInvariant.default)(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Link primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
99
+ (0, _tinyInvariant.default)(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Anchor primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
97
100
  return /*#__PURE__*/_react.default.createElement(_box.default
98
101
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
99
102
  , (0, _extends2.default)({}, htmlAttributes, {
@@ -112,12 +115,8 @@ var Link = function Link(_ref, ref) {
112
115
  paddingBlockEnd: paddingBlockEnd,
113
116
  paddingInline: paddingInline,
114
117
  paddingInlineStart: paddingInlineStart,
115
- paddingInlineEnd: paddingInlineEnd
116
- // TODO: This only tracks events if componentName is supplied, which makes tracking opt-in during
117
- // the transition period. This will be removed once `@atlaskit/button` is bumped to use the latest
118
- // version of primitives
119
- ,
120
- onClick: componentName ? onClick : providedOnClick
118
+ paddingInlineEnd: paddingInlineEnd,
119
+ onClick: onClick
121
120
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
122
121
  ,
123
122
  xcss: styles
@@ -126,17 +125,17 @@ var Link = function Link(_ref, ref) {
126
125
 
127
126
  // Workarounds to support generic types with forwardRef
128
127
  /**
129
- * __UNSAFE_LINK__
128
+ * __UNSAFE_ANCHOR__
130
129
  *
131
130
  * @internal Still under development. Do not use.
132
131
  *
133
- * Link is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
132
+ * Anchor is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
134
133
  *
135
134
  * This component is mostly used by other design system components, such as the [link component](/components/link/usage).
136
135
  *
137
- * - [Examples](https://atlassian.design/components/primitives/link/examples)
138
- * - [Code](https://atlassian.design/components/primitives/link/code)
139
- * - [Usage](https://atlassian.design/components/primitives/link/usage)
136
+ * - [Examples](https://atlassian.design/components/primitives/anchor/examples)
137
+ * - [Code](https://atlassian.design/components/primitives/anchor/code)
138
+ * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
140
139
  */
141
- var UNSAFE_LINK = /*#__PURE__*/(0, _react.forwardRef)(Link);
142
- var _default = exports.default = UNSAFE_LINK;
140
+ var UNSAFE_ANCHOR = /*#__PURE__*/(0, _react.forwardRef)(Anchor);
141
+ var _default = exports.default = UNSAFE_ANCHOR;
@@ -80,7 +80,7 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
80
80
  action: 'clicked',
81
81
  componentName: componentName || 'Pressable',
82
82
  packageName: "@atlaskit/primitives",
83
- packageVersion: "2.1.0",
83
+ packageVersion: "3.0.0",
84
84
  analyticsData: analyticsContext,
85
85
  actionSubject: 'button'
86
86
  });
@@ -94,12 +94,8 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
94
94
  as: "button",
95
95
  ref: ref,
96
96
  testId: testId,
97
- type: type
98
- // TODO: This only tracks events if componentName is supplied, which makes tracking opt-in during
99
- // the transition period. This will be removed once `@atlaskit/button` is bumped to use the latest
100
- // version of primitives
101
- ,
102
- onClick: componentName ? onClick : providedOnClick,
97
+ type: type,
98
+ onClick: onClick,
103
99
  backgroundColor: backgroundColor,
104
100
  padding: padding,
105
101
  paddingBlock: paddingBlock,
package/dist/cjs/index.js CHANGED
@@ -46,13 +46,19 @@ Object.defineProperty(exports, "Text", {
46
46
  return _text.default;
47
47
  }
48
48
  });
49
+ Object.defineProperty(exports, "UNSAFE_ANCHOR", {
50
+ enumerable: true,
51
+ get: function get() {
52
+ return _anchor.default;
53
+ }
54
+ });
49
55
  Object.defineProperty(exports, "UNSAFE_BREAKPOINTS_CONFIG", {
50
56
  enumerable: true,
51
57
  get: function get() {
52
58
  return _responsive.UNSAFE_BREAKPOINTS_CONFIG;
53
59
  }
54
60
  });
55
- Object.defineProperty(exports, "UNSAFE_Pressable", {
61
+ Object.defineProperty(exports, "UNSAFE_PRESSABLE", {
56
62
  enumerable: true,
57
63
  get: function get() {
58
64
  return _pressable.default;
@@ -91,4 +97,5 @@ var _grid = _interopRequireDefault(require("./components/grid"));
91
97
  var _bleed = _interopRequireDefault(require("./components/bleed"));
92
98
  var _text = _interopRequireDefault(require("./components/text"));
93
99
  var _pressable = _interopRequireDefault(require("./components/pressable"));
100
+ var _anchor = _interopRequireDefault(require("./components/anchor"));
94
101
  var _responsive = require("./responsive");
@@ -15,6 +15,9 @@ const baseFocusRingStyles = {
15
15
  outlineStyle: 'solid',
16
16
  outlineOffset: 'space.025'
17
17
  };
18
+ const defaultStyles = xcss({
19
+ textDecoration: 'underline'
20
+ });
18
21
  const focusRingStyles = xcss({
19
22
  ':focus-visible': baseFocusRingStyles,
20
23
  '@supports not selector(*:focus-visible)': {
@@ -28,7 +31,7 @@ const focusRingStyles = xcss({
28
31
  });
29
32
  const IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
30
33
  const IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
31
- const Link = ({
34
+ const Anchor = ({
32
35
  href,
33
36
  children,
34
37
  backgroundColor,
@@ -59,14 +62,14 @@ const Link = ({
59
62
  action: 'clicked',
60
63
  componentName: componentName || 'Anchor',
61
64
  packageName: "@atlaskit/primitives",
62
- packageVersion: "2.1.0",
65
+ packageVersion: "3.0.0",
63
66
  analyticsData: analyticsContext,
64
67
  actionSubject: 'link'
65
68
  });
66
69
  const RouterLink = useRouterLink();
67
70
 
68
71
  // Combine default styles with supplied styles. XCSS does not support deep nested arrays
69
- const styles = Array.isArray(xcssStyles) ? [focusRingStyles, ...xcssStyles] : [focusRingStyles, xcssStyles];
72
+ const styles = Array.isArray(xcssStyles) ? [defaultStyles, focusRingStyles, ...xcssStyles] : [defaultStyles, focusRingStyles, xcssStyles];
70
73
  const isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
71
74
  const isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
72
75
 
@@ -79,7 +82,7 @@ const Link = ({
79
82
  */
80
83
  const isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
81
84
  const hrefObjectUsedWithoutRouterLink = RouterLink === undefined && typeof href === 'object';
82
- invariant(!hrefObjectUsedWithoutRouterLink, `@atlaskit/primitives: Link primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider`);
85
+ invariant(!hrefObjectUsedWithoutRouterLink, `@atlaskit/primitives: Anchor primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider`);
83
86
  return /*#__PURE__*/React.createElement(Box
84
87
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
85
88
  , _extends({}, htmlAttributes, {
@@ -98,12 +101,8 @@ const Link = ({
98
101
  paddingBlockEnd: paddingBlockEnd,
99
102
  paddingInline: paddingInline,
100
103
  paddingInlineStart: paddingInlineStart,
101
- paddingInlineEnd: paddingInlineEnd
102
- // TODO: This only tracks events if componentName is supplied, which makes tracking opt-in during
103
- // the transition period. This will be removed once `@atlaskit/button` is bumped to use the latest
104
- // version of primitives
105
- ,
106
- onClick: componentName ? onClick : providedOnClick
104
+ paddingInlineEnd: paddingInlineEnd,
105
+ onClick: onClick
107
106
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
108
107
  ,
109
108
  xcss: styles
@@ -112,17 +111,17 @@ const Link = ({
112
111
 
113
112
  // Workarounds to support generic types with forwardRef
114
113
  /**
115
- * __UNSAFE_LINK__
114
+ * __UNSAFE_ANCHOR__
116
115
  *
117
116
  * @internal Still under development. Do not use.
118
117
  *
119
- * Link is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
118
+ * Anchor is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
120
119
  *
121
120
  * This component is mostly used by other design system components, such as the [link component](/components/link/usage).
122
121
  *
123
- * - [Examples](https://atlassian.design/components/primitives/link/examples)
124
- * - [Code](https://atlassian.design/components/primitives/link/code)
125
- * - [Usage](https://atlassian.design/components/primitives/link/usage)
122
+ * - [Examples](https://atlassian.design/components/primitives/anchor/examples)
123
+ * - [Code](https://atlassian.design/components/primitives/anchor/code)
124
+ * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
126
125
  */
127
- const UNSAFE_LINK = /*#__PURE__*/forwardRef(Link);
128
- export default UNSAFE_LINK;
126
+ const UNSAFE_ANCHOR = /*#__PURE__*/forwardRef(Anchor);
127
+ export default UNSAFE_ANCHOR;
@@ -66,7 +66,7 @@ const UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(({
66
66
  action: 'clicked',
67
67
  componentName: componentName || 'Pressable',
68
68
  packageName: "@atlaskit/primitives",
69
- packageVersion: "2.1.0",
69
+ packageVersion: "3.0.0",
70
70
  analyticsData: analyticsContext,
71
71
  actionSubject: 'button'
72
72
  });
@@ -80,12 +80,8 @@ const UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(({
80
80
  as: "button",
81
81
  ref: ref,
82
82
  testId: testId,
83
- type: type
84
- // TODO: This only tracks events if componentName is supplied, which makes tracking opt-in during
85
- // the transition period. This will be removed once `@atlaskit/button` is bumped to use the latest
86
- // version of primitives
87
- ,
88
- onClick: componentName ? onClick : providedOnClick,
83
+ type: type,
84
+ onClick: onClick,
89
85
  backgroundColor: backgroundColor,
90
86
  padding: padding,
91
87
  paddingBlock: paddingBlock,
@@ -6,5 +6,6 @@ export { default as Flex } from './components/flex';
6
6
  export { default as Grid } from './components/grid';
7
7
  export { default as Bleed } from './components/bleed';
8
8
  export { default as Text } from './components/text';
9
- export { default as UNSAFE_Pressable } from './components/pressable';
9
+ export { default as UNSAFE_PRESSABLE } from './components/pressable';
10
+ export { default as UNSAFE_ANCHOR } from './components/anchor';
10
11
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
@@ -19,6 +19,9 @@ var baseFocusRingStyles = {
19
19
  outlineStyle: 'solid',
20
20
  outlineOffset: 'space.025'
21
21
  };
22
+ var defaultStyles = xcss({
23
+ textDecoration: 'underline'
24
+ });
22
25
  var focusRingStyles = xcss({
23
26
  ':focus-visible': baseFocusRingStyles,
24
27
  '@supports not selector(*:focus-visible)': {
@@ -32,7 +35,7 @@ var focusRingStyles = xcss({
32
35
  });
33
36
  var IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
34
37
  var IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
35
- var Link = function Link(_ref, ref) {
38
+ var Anchor = function Anchor(_ref, ref) {
36
39
  var href = _ref.href,
37
40
  children = _ref.children,
38
41
  backgroundColor = _ref.backgroundColor,
@@ -63,14 +66,14 @@ var Link = function Link(_ref, ref) {
63
66
  action: 'clicked',
64
67
  componentName: componentName || 'Anchor',
65
68
  packageName: "@atlaskit/primitives",
66
- packageVersion: "2.1.0",
69
+ packageVersion: "3.0.0",
67
70
  analyticsData: analyticsContext,
68
71
  actionSubject: 'link'
69
72
  });
70
73
  var RouterLink = useRouterLink();
71
74
 
72
75
  // Combine default styles with supplied styles. XCSS does not support deep nested arrays
73
- var styles = Array.isArray(xcssStyles) ? [focusRingStyles].concat(_toConsumableArray(xcssStyles)) : [focusRingStyles, xcssStyles];
76
+ var styles = Array.isArray(xcssStyles) ? [defaultStyles, focusRingStyles].concat(_toConsumableArray(xcssStyles)) : [defaultStyles, focusRingStyles, xcssStyles];
74
77
  var isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
75
78
  var isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
76
79
 
@@ -83,7 +86,7 @@ var Link = function Link(_ref, ref) {
83
86
  */
84
87
  var isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
85
88
  var hrefObjectUsedWithoutRouterLink = RouterLink === undefined && _typeof(href) === 'object';
86
- invariant(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Link primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
89
+ invariant(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Anchor primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
87
90
  return /*#__PURE__*/React.createElement(Box
88
91
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
89
92
  , _extends({}, htmlAttributes, {
@@ -102,12 +105,8 @@ var Link = function Link(_ref, ref) {
102
105
  paddingBlockEnd: paddingBlockEnd,
103
106
  paddingInline: paddingInline,
104
107
  paddingInlineStart: paddingInlineStart,
105
- paddingInlineEnd: paddingInlineEnd
106
- // TODO: This only tracks events if componentName is supplied, which makes tracking opt-in during
107
- // the transition period. This will be removed once `@atlaskit/button` is bumped to use the latest
108
- // version of primitives
109
- ,
110
- onClick: componentName ? onClick : providedOnClick
108
+ paddingInlineEnd: paddingInlineEnd,
109
+ onClick: onClick
111
110
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
112
111
  ,
113
112
  xcss: styles
@@ -116,17 +115,17 @@ var Link = function Link(_ref, ref) {
116
115
 
117
116
  // Workarounds to support generic types with forwardRef
118
117
  /**
119
- * __UNSAFE_LINK__
118
+ * __UNSAFE_ANCHOR__
120
119
  *
121
120
  * @internal Still under development. Do not use.
122
121
  *
123
- * Link is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
122
+ * Anchor is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
124
123
  *
125
124
  * This component is mostly used by other design system components, such as the [link component](/components/link/usage).
126
125
  *
127
- * - [Examples](https://atlassian.design/components/primitives/link/examples)
128
- * - [Code](https://atlassian.design/components/primitives/link/code)
129
- * - [Usage](https://atlassian.design/components/primitives/link/usage)
126
+ * - [Examples](https://atlassian.design/components/primitives/anchor/examples)
127
+ * - [Code](https://atlassian.design/components/primitives/anchor/code)
128
+ * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
130
129
  */
131
- var UNSAFE_LINK = /*#__PURE__*/forwardRef(Link);
132
- export default UNSAFE_LINK;
130
+ var UNSAFE_ANCHOR = /*#__PURE__*/forwardRef(Anchor);
131
+ export default UNSAFE_ANCHOR;
@@ -70,7 +70,7 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
70
70
  action: 'clicked',
71
71
  componentName: componentName || 'Pressable',
72
72
  packageName: "@atlaskit/primitives",
73
- packageVersion: "2.1.0",
73
+ packageVersion: "3.0.0",
74
74
  analyticsData: analyticsContext,
75
75
  actionSubject: 'button'
76
76
  });
@@ -84,12 +84,8 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
84
84
  as: "button",
85
85
  ref: ref,
86
86
  testId: testId,
87
- type: type
88
- // TODO: This only tracks events if componentName is supplied, which makes tracking opt-in during
89
- // the transition period. This will be removed once `@atlaskit/button` is bumped to use the latest
90
- // version of primitives
91
- ,
92
- onClick: componentName ? onClick : providedOnClick,
87
+ type: type,
88
+ onClick: onClick,
93
89
  backgroundColor: backgroundColor,
94
90
  padding: padding,
95
91
  paddingBlock: paddingBlock,
package/dist/esm/index.js CHANGED
@@ -6,5 +6,6 @@ export { default as Flex } from './components/flex';
6
6
  export { default as Grid } from './components/grid';
7
7
  export { default as Bleed } from './components/bleed';
8
8
  export { default as Text } from './components/text';
9
- export { default as UNSAFE_Pressable } from './components/pressable';
9
+ export { default as UNSAFE_PRESSABLE } from './components/pressable';
10
+ export { default as UNSAFE_ANCHOR } from './components/anchor';
10
11
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
@@ -2,7 +2,7 @@ import React, { type ReactNode, type Ref } from 'react';
2
2
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
3
  import { type RouterLinkComponentProps } from '@atlaskit/app-provider';
4
4
  import { type BoxProps } from './box';
5
- export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<'a'>, 'href' | 'as' | 'children' | 'style' | 'onClick'> & {
5
+ export type AnchorProps<RouterLinkConfig extends Record<string, any> = never> = RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<'a'>, 'href' | 'as' | 'children' | 'style' | 'onClick'> & {
6
6
  /**
7
7
  * `children` should be defined to ensure links have text.
8
8
  */
@@ -10,7 +10,7 @@ export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = Ro
10
10
  /**
11
11
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
12
12
  */
13
- onClick?: (e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent?: UIAnalyticsEvent) => void;
13
+ onClick?: (e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent: UIAnalyticsEvent) => void;
14
14
  /**
15
15
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
16
16
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -26,21 +26,21 @@ export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = Ro
26
26
  */
27
27
  analyticsContext?: Record<string, any>;
28
28
  };
29
- declare const Link: <RouterLinkConfig extends Record<string, any> = never>({ href, children, backgroundColor, padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, testId, xcss: xcssStyles, target, rel, onClick: providedOnClick, interactionName, componentName, analyticsContext, ...htmlAttributes }: LinkProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
29
+ declare const Anchor: <RouterLinkConfig extends Record<string, any> = never>({ href, children, backgroundColor, padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, testId, xcss: xcssStyles, target, rel, onClick: providedOnClick, interactionName, componentName, analyticsContext, ...htmlAttributes }: AnchorProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
30
30
  /**
31
- * __UNSAFE_LINK__
31
+ * __UNSAFE_ANCHOR__
32
32
  *
33
33
  * @internal Still under development. Do not use.
34
34
  *
35
- * Link is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
35
+ * Anchor is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
36
36
  *
37
37
  * This component is mostly used by other design system components, such as the [link component](/components/link/usage).
38
38
  *
39
- * - [Examples](https://atlassian.design/components/primitives/link/examples)
40
- * - [Code](https://atlassian.design/components/primitives/link/code)
41
- * - [Usage](https://atlassian.design/components/primitives/link/usage)
39
+ * - [Examples](https://atlassian.design/components/primitives/anchor/examples)
40
+ * - [Code](https://atlassian.design/components/primitives/anchor/code)
41
+ * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
42
42
  */
43
- declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "onClick" | "href"> & {
43
+ declare const UNSAFE_ANCHOR: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "onClick" | "href"> & {
44
44
  /**
45
45
  * `children` should be defined to ensure links have text.
46
46
  */
@@ -48,7 +48,7 @@ declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never
48
48
  /**
49
49
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
50
50
  */
51
- onClick?: ((e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent?: UIAnalyticsEvent) => void) | undefined;
51
+ onClick?: ((e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent: UIAnalyticsEvent) => void) | undefined;
52
52
  /**
53
53
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
54
54
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -65,5 +65,5 @@ declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never
65
65
  analyticsContext?: Record<string, any> | undefined;
66
66
  } & {
67
67
  ref?: React.Ref<HTMLAnchorElement> | undefined;
68
- }) => ReturnType<typeof Link>;
69
- export default UNSAFE_LINK;
68
+ }) => ReturnType<typeof Anchor>;
69
+ export default UNSAFE_ANCHOR;
@@ -11,7 +11,7 @@ export type PressableProps = Omit<BoxProps<'button'>, 'disabled' | 'as' | 'child
11
11
  /**
12
12
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
13
13
  */
14
- onClick?: (e: React.MouseEvent<HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
14
+ onClick?: (e: React.MouseEvent<HTMLButtonElement>, analyticsEvent: UIAnalyticsEvent) => void;
15
15
  /**
16
16
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
17
17
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -48,7 +48,7 @@ declare const UNSAFE_PRESSABLE: React.ForwardRefExoticComponent<Pick<Omit<BoxPro
48
48
  /**
49
49
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
50
50
  */
51
- onClick?: ((e: React.MouseEvent<HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void) | undefined;
51
+ onClick?: ((e: React.MouseEvent<HTMLButtonElement>, analyticsEvent: UIAnalyticsEvent) => void) | undefined;
52
52
  /**
53
53
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
54
54
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -15,7 +15,9 @@ export { default as Bleed } from './components/bleed';
15
15
  export type { BleedProps } from './components/bleed';
16
16
  export { default as Text } from './components/text';
17
17
  export type { TextProps } from './components/text';
18
- export { default as UNSAFE_Pressable } from './components/pressable';
18
+ export { default as UNSAFE_PRESSABLE } from './components/pressable';
19
19
  export type { PressableProps as UNSAFE_PressableProps } from './components/pressable';
20
+ export { default as UNSAFE_ANCHOR } from './components/anchor';
21
+ export type { AnchorProps as UNSAFE_AnchorProps } from './components/anchor';
20
22
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
21
23
  export type { Breakpoint, MediaQuery } from './responsive';
@@ -2,7 +2,7 @@ import React, { type ReactNode, type Ref } from 'react';
2
2
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
3
  import { type RouterLinkComponentProps } from '@atlaskit/app-provider';
4
4
  import { type BoxProps } from './box';
5
- export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<'a'>, 'href' | 'as' | 'children' | 'style' | 'onClick'> & {
5
+ export type AnchorProps<RouterLinkConfig extends Record<string, any> = never> = RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<'a'>, 'href' | 'as' | 'children' | 'style' | 'onClick'> & {
6
6
  /**
7
7
  * `children` should be defined to ensure links have text.
8
8
  */
@@ -10,7 +10,7 @@ export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = Ro
10
10
  /**
11
11
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
12
12
  */
13
- onClick?: (e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent?: UIAnalyticsEvent) => void;
13
+ onClick?: (e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent: UIAnalyticsEvent) => void;
14
14
  /**
15
15
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
16
16
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -26,21 +26,21 @@ export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = Ro
26
26
  */
27
27
  analyticsContext?: Record<string, any>;
28
28
  };
29
- declare const Link: <RouterLinkConfig extends Record<string, any> = never>({ href, children, backgroundColor, padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, testId, xcss: xcssStyles, target, rel, onClick: providedOnClick, interactionName, componentName, analyticsContext, ...htmlAttributes }: LinkProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
29
+ declare const Anchor: <RouterLinkConfig extends Record<string, any> = never>({ href, children, backgroundColor, padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, testId, xcss: xcssStyles, target, rel, onClick: providedOnClick, interactionName, componentName, analyticsContext, ...htmlAttributes }: AnchorProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
30
30
  /**
31
- * __UNSAFE_LINK__
31
+ * __UNSAFE_ANCHOR__
32
32
  *
33
33
  * @internal Still under development. Do not use.
34
34
  *
35
- * Link is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
35
+ * Anchor is a primitive for building custom anchor links. It's a wrapper around the HTML `<a>` element that provides a consistent API for handling client-side routing and Atlassian Design System styling.
36
36
  *
37
37
  * This component is mostly used by other design system components, such as the [link component](/components/link/usage).
38
38
  *
39
- * - [Examples](https://atlassian.design/components/primitives/link/examples)
40
- * - [Code](https://atlassian.design/components/primitives/link/code)
41
- * - [Usage](https://atlassian.design/components/primitives/link/usage)
39
+ * - [Examples](https://atlassian.design/components/primitives/anchor/examples)
40
+ * - [Code](https://atlassian.design/components/primitives/anchor/code)
41
+ * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
42
42
  */
43
- declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "onClick" | "href"> & {
43
+ declare const UNSAFE_ANCHOR: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "onClick" | "href"> & {
44
44
  /**
45
45
  * `children` should be defined to ensure links have text.
46
46
  */
@@ -48,7 +48,7 @@ declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never
48
48
  /**
49
49
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
50
50
  */
51
- onClick?: ((e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent?: UIAnalyticsEvent) => void) | undefined;
51
+ onClick?: ((e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent: UIAnalyticsEvent) => void) | undefined;
52
52
  /**
53
53
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
54
54
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -65,5 +65,5 @@ declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never
65
65
  analyticsContext?: Record<string, any> | undefined;
66
66
  } & {
67
67
  ref?: React.Ref<HTMLAnchorElement> | undefined;
68
- }) => ReturnType<typeof Link>;
69
- export default UNSAFE_LINK;
68
+ }) => ReturnType<typeof Anchor>;
69
+ export default UNSAFE_ANCHOR;
@@ -11,7 +11,7 @@ export type PressableProps = Omit<BoxProps<'button'>, 'disabled' | 'as' | 'child
11
11
  /**
12
12
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
13
13
  */
14
- onClick?: (e: React.MouseEvent<HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
14
+ onClick?: (e: React.MouseEvent<HTMLButtonElement>, analyticsEvent: UIAnalyticsEvent) => void;
15
15
  /**
16
16
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
17
17
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -48,7 +48,7 @@ declare const UNSAFE_PRESSABLE: React.ForwardRefExoticComponent<Pick<Omit<BoxPro
48
48
  /**
49
49
  * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
50
50
  */
51
- onClick?: ((e: React.MouseEvent<HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void) | undefined;
51
+ onClick?: ((e: React.MouseEvent<HTMLButtonElement>, analyticsEvent: UIAnalyticsEvent) => void) | undefined;
52
52
  /**
53
53
  * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
54
54
  * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
@@ -15,7 +15,9 @@ export { default as Bleed } from './components/bleed';
15
15
  export type { BleedProps } from './components/bleed';
16
16
  export { default as Text } from './components/text';
17
17
  export type { TextProps } from './components/text';
18
- export { default as UNSAFE_Pressable } from './components/pressable';
18
+ export { default as UNSAFE_PRESSABLE } from './components/pressable';
19
19
  export type { PressableProps as UNSAFE_PressableProps } from './components/pressable';
20
+ export { default as UNSAFE_ANCHOR } from './components/anchor';
21
+ export type { AnchorProps as UNSAFE_AnchorProps } from './components/anchor';
20
22
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
21
23
  export type { Breakpoint, MediaQuery } from './responsive';
@@ -0,0 +1,103 @@
1
+ // TODO: Switch from ERT to ts-morph when this is completed and has reasonable adoption: https://product-fabric.atlassian.net/browse/DSP-10364
2
+ import React, { ReactNode } from 'react';
3
+
4
+ import { BasePrimitiveProps, StyleProp } from '../src/components/types';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-namespace
7
+ namespace Token {
8
+ // BoxProps['backgroundColor'] uses keyof, which ERT does not understand
9
+ export type BackgroundColor = 'BackgroundColor';
10
+ }
11
+
12
+ type Space =
13
+ | 'space.0'
14
+ | 'space.025'
15
+ | 'space.050'
16
+ | 'space.075'
17
+ | 'space.100'
18
+ | 'space.150'
19
+ | 'space.200'
20
+ | 'space.250'
21
+ | 'space.300'
22
+ | 'space.400'
23
+ | 'space.500'
24
+ | 'space.600'
25
+ | 'space.800'
26
+ | 'space.1000';
27
+
28
+ export default function Anchor<
29
+ RouterLinkConfig extends Record<string, any> = never,
30
+ >(
31
+ _: {
32
+ /**
33
+ * A link can be provided as a string. If a router link configuration is set
34
+ * it can be mapped to the underlying router link component,
35
+ * or optionally a custom object defined in the generic type for advanced use.
36
+ */
37
+ href: string | RouterLinkConfig;
38
+
39
+ /**
40
+ * The `target` attribute of the anchor HTML element. Defaults to `_blank` for external links.
41
+ */
42
+ target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
43
+
44
+ /**
45
+ * The `rel` attribute of the anchor HTML element. Defaults to `noopener noreferrer` for external links.
46
+ */
47
+ rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
48
+
49
+ /**
50
+ * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
51
+ */
52
+ padding?: Space;
53
+
54
+ /**
55
+ * Tokens representing CSS shorthand `paddingBlock`.
56
+ */
57
+ paddingBlock?: Space;
58
+
59
+ /**
60
+ * Tokens representing CSS `paddingBlockStart`.
61
+ */
62
+ paddingBlockStart?: Space;
63
+
64
+ /**
65
+ * Tokens representing CSS `paddingBlockEnd`.
66
+ */
67
+ paddingBlockEnd?: Space;
68
+
69
+ /**
70
+ * Tokens representing CSS shorthand `paddingInline`.
71
+ */
72
+ paddingInline?: Space;
73
+
74
+ /**
75
+ * Tokens representing CSS `paddingInlineStart`.
76
+ */
77
+ paddingInlineStart?: Space;
78
+
79
+ /**
80
+ * Tokens representing CSS `paddingInlineEnd`.
81
+ */
82
+ paddingInlineEnd?: Space;
83
+
84
+ /**
85
+ * A token alias for background color. See:<br>
86
+ * [https://atlassian.design/components/tokens/all-tokens#color-background](https://atlassian.design/components/tokens/all-tokens#color-background)<br>
87
+ * When the background color is set to a [surface token](/components/tokens/all-tokens#elevation-surface),
88
+ * the [current surface](/components/tokens/code#current-surface-color) CSS variable will also be set to this value in the Box styles.
89
+ */
90
+ backgroundColor?: Token.BackgroundColor;
91
+
92
+ /**
93
+ * Elements to be rendered inside the primitive.
94
+ */
95
+ children: ReactNode;
96
+
97
+ /**
98
+ * Forwarded ref element.
99
+ */
100
+ ref?: React.ComponentPropsWithRef<'a'>['ref'];
101
+ } & BasePrimitiveProps &
102
+ StyleProp,
103
+ ) {}
@@ -0,0 +1,94 @@
1
+ // TODO: Switch from ERT to ts-morph when this is completed and has reasonable adoption: https://product-fabric.atlassian.net/browse/DSP-10364
2
+ import React, { ReactNode } from 'react';
3
+
4
+ import { BasePrimitiveProps, StyleProp } from '../src/components/types';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-namespace
7
+ namespace Token {
8
+ // BoxProps['backgroundColor'] uses keyof, which ERT does not understand
9
+ export type BackgroundColor = 'BackgroundColor';
10
+ }
11
+
12
+ type Space =
13
+ | 'space.0'
14
+ | 'space.025'
15
+ | 'space.050'
16
+ | 'space.075'
17
+ | 'space.100'
18
+ | 'space.150'
19
+ | 'space.200'
20
+ | 'space.250'
21
+ | 'space.300'
22
+ | 'space.400'
23
+ | 'space.500'
24
+ | 'space.600'
25
+ | 'space.800'
26
+ | 'space.1000';
27
+
28
+ export default function Pressable(
29
+ _: {
30
+ /**
31
+ * Controls whether the button is disabled.
32
+ */
33
+ isDisabled?: boolean;
34
+
35
+ /**
36
+ * The `type` attribute of the Button HTML element. Defaults to `button`.
37
+ */
38
+ type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
39
+
40
+ /**
41
+ * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
42
+ */
43
+ padding?: Space;
44
+
45
+ /**
46
+ * Tokens representing CSS shorthand `paddingBlock`.
47
+ */
48
+ paddingBlock?: Space;
49
+
50
+ /**
51
+ * Tokens representing CSS `paddingBlockStart`.
52
+ */
53
+ paddingBlockStart?: Space;
54
+
55
+ /**
56
+ * Tokens representing CSS `paddingBlockEnd`.
57
+ */
58
+ paddingBlockEnd?: Space;
59
+
60
+ /**
61
+ * Tokens representing CSS shorthand `paddingInline`.
62
+ */
63
+ paddingInline?: Space;
64
+
65
+ /**
66
+ * Tokens representing CSS `paddingInlineStart`.
67
+ */
68
+ paddingInlineStart?: Space;
69
+
70
+ /**
71
+ * Tokens representing CSS `paddingInlineEnd`.
72
+ */
73
+ paddingInlineEnd?: Space;
74
+
75
+ /**
76
+ * A token alias for background color. See:<br>
77
+ * [https://atlassian.design/components/tokens/all-tokens#color-background](https://atlassian.design/components/tokens/all-tokens#color-background)<br>
78
+ * When the background color is set to a [surface token](/components/tokens/all-tokens#elevation-surface),
79
+ * the [current surface](/components/tokens/code#current-surface-color) CSS variable will also be set to this value in the Box styles.
80
+ */
81
+ backgroundColor?: Token.BackgroundColor;
82
+
83
+ /**
84
+ * Elements to be rendered inside the primitive.
85
+ */
86
+ children: ReactNode;
87
+
88
+ /**
89
+ * Forwarded ref element.
90
+ */
91
+ ref?: React.ComponentPropsWithRef<'button'>['ref'];
92
+ } & BasePrimitiveProps &
93
+ StyleProp,
94
+ ) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -96,6 +96,24 @@
96
96
  "status": {
97
97
  "type": "closed-beta"
98
98
  }
99
+ },
100
+ {
101
+ "title": "Pressable",
102
+ "folder": "pressable",
103
+ "slug": "primitives/pressable",
104
+ "id": "@atlaskit/primitives/pressable",
105
+ "status": {
106
+ "type": "alpha"
107
+ }
108
+ },
109
+ {
110
+ "title": "Anchor",
111
+ "folder": "anchor",
112
+ "slug": "primitives/anchor",
113
+ "id": "@atlaskit/primitives/anchor",
114
+ "status": {
115
+ "type": "alpha"
116
+ }
99
117
  }
100
118
  ]
101
119
  }
@@ -174,7 +192,7 @@
174
192
  "./inline": "./src/components/inline.tsx",
175
193
  "./text": "./src/components/text.tsx",
176
194
  "./pressable": "./src/components/pressable.tsx",
177
- "./link": "./src/components/link.tsx",
195
+ "./anchor": "./src/components/anchor.tsx",
178
196
  "./responsive": "./src/responsive/index.tsx"
179
197
  },
180
198
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
package/link/package.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "name": "@atlaskit/primitives/link",
3
- "main": "../dist/cjs/components/link.js",
4
- "module": "../dist/esm/components/link.js",
5
- "module:es2019": "../dist/es2019/components/link.js",
6
- "sideEffects": false,
7
- "types": "../dist/types/components/link.d.ts",
8
- "typesVersions": {
9
- ">=4.5 <4.9": {
10
- "*": [
11
- "../dist/types-ts4.5/components/link.d.ts"
12
- ]
13
- }
14
- }
15
- }