@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.
- package/CHANGELOG.md +21 -0
- package/anchor/package.json +15 -0
- package/constellation/anchor/code.mdx +21 -0
- package/constellation/anchor/examples.mdx +33 -0
- package/constellation/anchor/usage.mdx +47 -0
- package/constellation/box/examples.mdx +5 -3
- package/constellation/pressable/code.mdx +21 -0
- package/constellation/pressable/examples.mdx +39 -0
- package/constellation/pressable/usage.mdx +23 -0
- package/constellation/text/examples.mdx +16 -9
- package/constellation/xcss/examples.mdx +1 -1
- package/dist/cjs/components/{link.js → anchor.js} +16 -17
- package/dist/cjs/components/pressable.js +3 -7
- package/dist/cjs/components/text.js +37 -21
- package/dist/cjs/index.js +8 -1
- package/dist/es2019/components/{link.js → anchor.js} +16 -17
- package/dist/es2019/components/pressable.js +3 -7
- package/dist/es2019/components/text.js +25 -13
- package/dist/es2019/index.js +2 -1
- package/dist/esm/components/{link.js → anchor.js} +16 -17
- package/dist/esm/components/pressable.js +3 -7
- package/dist/esm/components/text.js +28 -13
- package/dist/esm/index.js +2 -1
- package/dist/{types-ts4.5/components/link.d.ts → types/components/anchor.d.ts} +12 -12
- package/dist/types/components/pressable.d.ts +2 -2
- package/dist/types/components/text.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/{types/components/link.d.ts → types-ts4.5/components/anchor.d.ts} +12 -12
- package/dist/types-ts4.5/components/pressable.d.ts +2 -2
- package/dist/types-ts4.5/components/text.d.ts +3 -3
- package/dist/types-ts4.5/index.d.ts +3 -1
- package/extract-react-types/anchor-props.tsx +103 -0
- package/extract-react-types/pressable-props.tsx +94 -0
- package/package.json +20 -2
- package/link/package.json +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#76431](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76431) [`c6819de73d02`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c6819de73d02) - Default text color + allow color inheritance if explicitly defined
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#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.
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#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.
|
|
18
|
+
- [#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`.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#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)
|
|
23
|
+
|
|
3
24
|
## 2.1.0
|
|
4
25
|
|
|
5
26
|
### 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,
|
|
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
|
|
60
|
+
## Practical card example
|
|
61
61
|
|
|
62
|
-
Box is designed to be
|
|
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)
|
|
@@ -4,9 +4,10 @@ description: Text is a token-backed typography component to display body and UI
|
|
|
4
4
|
order: 0
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import TextAsElement from '../../examples/constellation/text/as-element';
|
|
7
|
+
import Basic from '../../examples/constellation/text/basic';
|
|
9
8
|
import ColorInverse from '../../examples/constellation/text/color-inverse';
|
|
9
|
+
import Weight from '../../examples/constellation/text/weight';
|
|
10
|
+
import AsElement from '../../examples/constellation/text/as-element';
|
|
10
11
|
|
|
11
12
|
## Basic
|
|
12
13
|
|
|
@@ -14,16 +15,22 @@ Implements the [Atlassian typography system](/foundations/typography/) as a comp
|
|
|
14
15
|
|
|
15
16
|
The `variant` prop expresses the visual appearance of the text element.
|
|
16
17
|
|
|
17
|
-
<Example Component={
|
|
18
|
+
<Example Component={Basic} pacckageName="@atlaskit/primitives" />
|
|
18
19
|
|
|
19
|
-
##
|
|
20
|
+
## Color
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
Set `color` to change the text color, defaults to `text.color` if not nested in other Text components. When used within a [box component](/components/primitives/box) that has a bold background color, the text color will automatically be inverted.
|
|
22
23
|
|
|
23
|
-
<Example Component={
|
|
24
|
+
<Example Component={ColorInverse} pacckageName="@atlaskit/primitives" />
|
|
24
25
|
|
|
25
|
-
##
|
|
26
|
+
## Weight
|
|
26
27
|
|
|
27
|
-
Set `
|
|
28
|
+
Set `weight` to change the front weight.
|
|
28
29
|
|
|
29
|
-
<Example Component={
|
|
30
|
+
<Example Component={Weight} pacckageName="@atlaskit/primitives" />
|
|
31
|
+
|
|
32
|
+
## Rendered HTML tag
|
|
33
|
+
|
|
34
|
+
Set `as` to change the rendered HTML element, defaults to `span`.
|
|
35
|
+
|
|
36
|
+
<Example Component={AsElement} packageName="@atlaskit/primitives" />
|
|
@@ -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
|
-
|
|
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
|
|
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: "
|
|
79
|
+
packageVersion: "3.1.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:
|
|
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
|
-
|
|
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
|
-
*
|
|
128
|
+
* __UNSAFE_ANCHOR__
|
|
130
129
|
*
|
|
131
130
|
* @internal Still under development. Do not use.
|
|
132
131
|
*
|
|
133
|
-
*
|
|
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/
|
|
138
|
-
* - [Code](https://atlassian.design/components/primitives/
|
|
139
|
-
* - [Usage](https://atlassian.design/components/primitives/
|
|
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
|
|
142
|
-
var _default = exports.default =
|
|
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: "
|
|
83
|
+
packageVersion: "3.1.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
|
-
|
|
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,
|
|
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _react = require("
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
11
12
|
var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
|
|
12
13
|
var _styleMaps = require("../xcss/style-maps.partial");
|
|
13
14
|
var _surfaceProvider = require("./internal/surface-provider");
|
|
@@ -18,50 +19,62 @@ var asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
|
18
19
|
// We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
|
|
19
20
|
// Long term we should remove those instances from the reset - it should be a reset to 0.
|
|
20
21
|
// For now, at least we know <Text> will be unaffected by this.
|
|
21
|
-
var resetStyles = (0,
|
|
22
|
+
var resetStyles = (0, _react2.css)({
|
|
22
23
|
margin: 0
|
|
23
24
|
});
|
|
24
25
|
var variantStyles = _objectSpread(_objectSpread({}, _styleMaps.bodyTextStylesMap), _styleMaps.uiTextStylesMap);
|
|
25
|
-
var strongStyles = (0,
|
|
26
|
+
var strongStyles = (0, _react2.css)({
|
|
26
27
|
fontWeight: 'bold'
|
|
27
28
|
});
|
|
28
|
-
var emStyles = (0,
|
|
29
|
+
var emStyles = (0, _react2.css)({
|
|
29
30
|
fontStyle: 'italic'
|
|
30
31
|
});
|
|
31
32
|
var textAlignMap = {
|
|
32
|
-
center: (0,
|
|
33
|
+
center: (0, _react2.css)({
|
|
33
34
|
textAlign: 'center'
|
|
34
35
|
}),
|
|
35
|
-
end: (0,
|
|
36
|
+
end: (0, _react2.css)({
|
|
36
37
|
textAlign: 'end'
|
|
37
38
|
}),
|
|
38
|
-
start: (0,
|
|
39
|
+
start: (0, _react2.css)({
|
|
39
40
|
textAlign: 'start'
|
|
40
41
|
})
|
|
41
42
|
};
|
|
42
|
-
var truncationStyles = (0,
|
|
43
|
+
var truncationStyles = (0, _react2.css)({
|
|
43
44
|
display: '-webkit-box',
|
|
44
45
|
overflow: 'hidden',
|
|
45
46
|
WebkitBoxOrient: 'vertical'
|
|
46
47
|
});
|
|
47
48
|
var wordBreakMap = {
|
|
48
|
-
breakAll: (0,
|
|
49
|
+
breakAll: (0, _react2.css)({
|
|
49
50
|
wordBreak: 'break-all'
|
|
50
51
|
})
|
|
51
52
|
};
|
|
53
|
+
var HasTextAncestorContext = /*#__PURE__*/(0, _react.createContext)(false);
|
|
54
|
+
var useHasTextAncestor = function useHasTextAncestor() {
|
|
55
|
+
return (0, _react.useContext)(HasTextAncestorContext);
|
|
56
|
+
};
|
|
52
57
|
|
|
53
58
|
/**
|
|
54
59
|
* 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.
|
|
55
60
|
*/
|
|
56
|
-
var useColor = function useColor(colorProp) {
|
|
61
|
+
var useColor = function useColor(colorProp, hasTextAncestor) {
|
|
57
62
|
var surface = (0, _surfaceProvider.useSurface)();
|
|
58
63
|
|
|
59
64
|
/**
|
|
60
|
-
* Where the color of the surface is inverted we override the
|
|
65
|
+
* Where the color of the surface is inverted we always override the color
|
|
61
66
|
* as there is no valid choice that is not covered by the override.
|
|
62
67
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
if (_styleMaps.inverseColorMap.hasOwnProperty(surface)) {
|
|
69
|
+
return _styleMaps.inverseColorMap[surface];
|
|
70
|
+
}
|
|
71
|
+
if (colorProp === 'inherit') {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
if (!colorProp && hasTextAncestor) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return colorProp || 'color.text';
|
|
65
78
|
};
|
|
66
79
|
|
|
67
80
|
/**
|
|
@@ -76,7 +89,8 @@ var useColor = function useColor(colorProp) {
|
|
|
76
89
|
var Text = function Text(_ref) {
|
|
77
90
|
var children = _ref.children,
|
|
78
91
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
79
|
-
var
|
|
92
|
+
var _props$as = props.as,
|
|
93
|
+
Component = _props$as === void 0 ? 'span' : _props$as,
|
|
80
94
|
colorProp = props.color,
|
|
81
95
|
textAlign = props.textAlign,
|
|
82
96
|
testId = props.testId,
|
|
@@ -84,10 +98,6 @@ var Text = function Text(_ref) {
|
|
|
84
98
|
_props$variant = props.variant,
|
|
85
99
|
variant = _props$variant === void 0 ? 'body' : _props$variant,
|
|
86
100
|
weight = props.weight;
|
|
87
|
-
|
|
88
|
-
// body variants -> p
|
|
89
|
-
// ui variants -> span
|
|
90
|
-
var Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
91
101
|
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
92
102
|
|
|
93
103
|
// Remove the ability to bypass typescript errors for maxLines
|
|
@@ -95,14 +105,20 @@ var Text = function Text(_ref) {
|
|
|
95
105
|
if ('maxLines' in props && variant.includes('body')) {
|
|
96
106
|
maxLines = props.maxLines;
|
|
97
107
|
}
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
var hasTextAncestor = useHasTextAncestor();
|
|
109
|
+
var color = useColor(colorProp, hasTextAncestor);
|
|
110
|
+
var component = (0, _react2.jsx)(Component, {
|
|
111
|
+
css: [resetStyles, variantStyles[variant], color && _styleMaps.textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && _styleMaps.fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
|
|
101
112
|
style: {
|
|
102
113
|
WebkitLineClamp: maxLines
|
|
103
114
|
},
|
|
104
115
|
"data-testid": testId,
|
|
105
116
|
id: id
|
|
106
117
|
}, children);
|
|
118
|
+
return hasTextAncestor ?
|
|
119
|
+
// no need to re-apply context if the text is already wrapped
|
|
120
|
+
component : (0, _react2.jsx)(HasTextAncestorContext.Provider, {
|
|
121
|
+
value: true
|
|
122
|
+
}, component);
|
|
107
123
|
};
|
|
108
124
|
var _default = exports.default = Text;
|
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, "
|
|
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");
|