@atlaskit/primitives 2.1.0 → 3.1.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/anchor/package.json +15 -0
  3. package/constellation/anchor/code.mdx +21 -0
  4. package/constellation/anchor/examples.mdx +33 -0
  5. package/constellation/anchor/usage.mdx +47 -0
  6. package/constellation/box/examples.mdx +5 -3
  7. package/constellation/pressable/code.mdx +21 -0
  8. package/constellation/pressable/examples.mdx +39 -0
  9. package/constellation/pressable/usage.mdx +23 -0
  10. package/constellation/text/examples.mdx +16 -9
  11. package/constellation/xcss/examples.mdx +1 -1
  12. package/dist/cjs/components/{link.js → anchor.js} +16 -17
  13. package/dist/cjs/components/pressable.js +3 -7
  14. package/dist/cjs/components/text.js +37 -21
  15. package/dist/cjs/index.js +8 -1
  16. package/dist/es2019/components/{link.js → anchor.js} +16 -17
  17. package/dist/es2019/components/pressable.js +3 -7
  18. package/dist/es2019/components/text.js +25 -13
  19. package/dist/es2019/index.js +2 -1
  20. package/dist/esm/components/{link.js → anchor.js} +16 -17
  21. package/dist/esm/components/pressable.js +3 -7
  22. package/dist/esm/components/text.js +28 -13
  23. package/dist/esm/index.js +2 -1
  24. package/dist/{types-ts4.5/components/link.d.ts → types/components/anchor.d.ts} +12 -12
  25. package/dist/types/components/pressable.d.ts +2 -2
  26. package/dist/types/components/text.d.ts +3 -3
  27. package/dist/types/index.d.ts +3 -1
  28. package/dist/{types/components/link.d.ts → types-ts4.5/components/anchor.d.ts} +12 -12
  29. package/dist/types-ts4.5/components/pressable.d.ts +2 -2
  30. package/dist/types-ts4.5/components/text.d.ts +3 -3
  31. package/dist/types-ts4.5/index.d.ts +3 -1
  32. package/extract-react-types/anchor-props.tsx +103 -0
  33. package/extract-react-types/pressable-props.tsx +94 -0
  34. package/package.json +20 -2
  35. package/link/package.json +0 -15
@@ -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.1.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.1.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,
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
-
2
+ import { createContext, useContext } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import invariant from 'tiny-invariant';
5
5
  import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
@@ -42,19 +42,29 @@ const wordBreakMap = {
42
42
  wordBreak: 'break-all'
43
43
  })
44
44
  };
45
+ const HasTextAncestorContext = /*#__PURE__*/createContext(false);
46
+ const useHasTextAncestor = () => useContext(HasTextAncestorContext);
45
47
 
46
48
  /**
47
49
  * Custom hook designed to abstract the parsing of the color props and make it clearer in the future how color is reconciled between themes and tokens.
48
50
  */
49
- const useColor = colorProp => {
51
+ const useColor = (colorProp, hasTextAncestor) => {
50
52
  const surface = useSurface();
51
53
 
52
54
  /**
53
- * Where the color of the surface is inverted we override the user choice
55
+ * Where the color of the surface is inverted we always override the color
54
56
  * as there is no valid choice that is not covered by the override.
55
57
  */
56
- const color = inverseColorMap.hasOwnProperty(surface) ? inverseColorMap[surface] : colorProp;
57
- return color;
58
+ if (inverseColorMap.hasOwnProperty(surface)) {
59
+ return inverseColorMap[surface];
60
+ }
61
+ if (colorProp === 'inherit') {
62
+ return undefined;
63
+ }
64
+ if (!colorProp && hasTextAncestor) {
65
+ return undefined;
66
+ }
67
+ return colorProp || 'color.text';
58
68
  };
59
69
 
60
70
  /**
@@ -71,7 +81,7 @@ const Text = ({
71
81
  ...props
72
82
  }) => {
73
83
  const {
74
- as: asElement,
84
+ as: Component = 'span',
75
85
  color: colorProp,
76
86
  textAlign,
77
87
  testId,
@@ -79,10 +89,6 @@ const Text = ({
79
89
  variant = 'body',
80
90
  weight
81
91
  } = props;
82
-
83
- // body variants -> p
84
- // ui variants -> span
85
- const Component = asElement || (variant.includes('body') ? 'p' : 'span');
86
92
  invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
87
93
 
88
94
  // Remove the ability to bypass typescript errors for maxLines
@@ -90,14 +96,20 @@ const Text = ({
90
96
  if ('maxLines' in props && variant.includes('body')) {
91
97
  maxLines = props.maxLines;
92
98
  }
93
- const color = useColor(colorProp);
94
- return jsx(Component, {
95
- css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
99
+ const hasTextAncestor = useHasTextAncestor();
100
+ const color = useColor(colorProp, hasTextAncestor);
101
+ const component = jsx(Component, {
102
+ css: [resetStyles, variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
96
103
  style: {
97
104
  WebkitLineClamp: maxLines
98
105
  },
99
106
  "data-testid": testId,
100
107
  id: id
101
108
  }, children);
109
+ return hasTextAncestor ?
110
+ // no need to re-apply context if the text is already wrapped
111
+ component : jsx(HasTextAncestorContext.Provider, {
112
+ value: true
113
+ }, component);
102
114
  };
103
115
  export default Text;
@@ -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.1.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.1.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,
@@ -4,7 +4,7 @@ var _excluded = ["children"];
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  /** @jsx jsx */
7
-
7
+ import { createContext, useContext } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import invariant from 'tiny-invariant';
10
10
  import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
@@ -44,19 +44,31 @@ var wordBreakMap = {
44
44
  wordBreak: 'break-all'
45
45
  })
46
46
  };
47
+ var HasTextAncestorContext = /*#__PURE__*/createContext(false);
48
+ var useHasTextAncestor = function useHasTextAncestor() {
49
+ return useContext(HasTextAncestorContext);
50
+ };
47
51
 
48
52
  /**
49
53
  * Custom hook designed to abstract the parsing of the color props and make it clearer in the future how color is reconciled between themes and tokens.
50
54
  */
51
- var useColor = function useColor(colorProp) {
55
+ var useColor = function useColor(colorProp, hasTextAncestor) {
52
56
  var surface = useSurface();
53
57
 
54
58
  /**
55
- * Where the color of the surface is inverted we override the user choice
59
+ * Where the color of the surface is inverted we always override the color
56
60
  * as there is no valid choice that is not covered by the override.
57
61
  */
58
- var color = inverseColorMap.hasOwnProperty(surface) ? inverseColorMap[surface] : colorProp;
59
- return color;
62
+ if (inverseColorMap.hasOwnProperty(surface)) {
63
+ return inverseColorMap[surface];
64
+ }
65
+ if (colorProp === 'inherit') {
66
+ return undefined;
67
+ }
68
+ if (!colorProp && hasTextAncestor) {
69
+ return undefined;
70
+ }
71
+ return colorProp || 'color.text';
60
72
  };
61
73
 
62
74
  /**
@@ -71,7 +83,8 @@ var useColor = function useColor(colorProp) {
71
83
  var Text = function Text(_ref) {
72
84
  var children = _ref.children,
73
85
  props = _objectWithoutProperties(_ref, _excluded);
74
- var asElement = props.as,
86
+ var _props$as = props.as,
87
+ Component = _props$as === void 0 ? 'span' : _props$as,
75
88
  colorProp = props.color,
76
89
  textAlign = props.textAlign,
77
90
  testId = props.testId,
@@ -79,10 +92,6 @@ var Text = function Text(_ref) {
79
92
  _props$variant = props.variant,
80
93
  variant = _props$variant === void 0 ? 'body' : _props$variant,
81
94
  weight = props.weight;
82
-
83
- // body variants -> p
84
- // ui variants -> span
85
- var Component = asElement || (variant.includes('body') ? 'p' : 'span');
86
95
  invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
87
96
 
88
97
  // Remove the ability to bypass typescript errors for maxLines
@@ -90,14 +99,20 @@ var Text = function Text(_ref) {
90
99
  if ('maxLines' in props && variant.includes('body')) {
91
100
  maxLines = props.maxLines;
92
101
  }
93
- var color = useColor(colorProp);
94
- return jsx(Component, {
95
- css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
102
+ var hasTextAncestor = useHasTextAncestor();
103
+ var color = useColor(colorProp, hasTextAncestor);
104
+ var component = jsx(Component, {
105
+ css: [resetStyles, variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
96
106
  style: {
97
107
  WebkitLineClamp: maxLines
98
108
  },
99
109
  "data-testid": testId,
100
110
  id: id
101
111
  }, children);
112
+ return hasTextAncestor ?
113
+ // no need to re-apply context if the text is already wrapped
114
+ component : jsx(HasTextAncestorContext.Provider, {
115
+ value: true
116
+ }, component);
102
117
  };
103
118
  export default Text;
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).
@@ -36,10 +36,10 @@ type TextPropsBase = {
36
36
  children: ReactNode;
37
37
  /**
38
38
  * Token representing text color with a built-in fallback value.
39
- * Will apply inverse text color automatically if placed within a Box with backgroundColor.
40
- *
39
+ * Will apply inverse text color automatically if placed within a Box with bold background color.
40
+ * Defaults to `text.color` if not nested in other Text components.
41
41
  */
42
- color?: TextColor;
42
+ color?: TextColor | 'inherit';
43
43
  /**
44
44
  * The [HTML `id` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
45
45
  */
@@ -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).
@@ -41,10 +41,10 @@ type TextPropsBase = {
41
41
  children: ReactNode;
42
42
  /**
43
43
  * Token representing text color with a built-in fallback value.
44
- * Will apply inverse text color automatically if placed within a Box with backgroundColor.
45
- *
44
+ * Will apply inverse text color automatically if placed within a Box with bold background color.
45
+ * Defaults to `text.color` if not nested in other Text components.
46
46
  */
47
- color?: TextColor;
47
+ color?: TextColor | 'inherit';
48
48
  /**
49
49
  * The [HTML `id` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
50
50
  */
@@ -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';