@atlaskit/primitives 1.6.8 → 1.8.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 +17 -0
- package/dist/cjs/components/link.js +113 -0
- package/dist/es2019/components/link.js +100 -0
- package/dist/esm/components/link.js +103 -0
- package/dist/types/components/link.d.ts +31 -0
- package/dist/types-ts4.5/components/link.d.ts +31 -0
- package/link/package.json +15 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#42305](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42305) [`4c9d4a7be34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c9d4a7be34) - - Link primitive will now throw an error if a router link configuration object is passed to the `href` prop when there is not a router link component set in the AppProvider
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#42305](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42305) [`4c9d4a7be34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c9d4a7be34) - - Fixes a bug where Link primitive was not passing through router link configuration objects
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 1.7.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [#42130](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42130) [`a64dc3026de`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a64dc3026de) - Create the new Link primitive (Unsafe to use, still in Alpha)
|
|
19
|
+
|
|
3
20
|
## 1.6.8
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
|
|
15
|
+
var _appProvider = require("@atlaskit/app-provider");
|
|
16
|
+
var _xcss = require("../xcss/xcss");
|
|
17
|
+
var _box = _interopRequireDefault(require("./box"));
|
|
18
|
+
var _excluded = ["href", "children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "testId", "xcss", "target", "rel"];
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
// TODO: Duplicated FocusRing styles due to lack of `xcss` support
|
|
22
|
+
// and to prevent additional dependency
|
|
23
|
+
var baseFocusRingStyles = {
|
|
24
|
+
outlineColor: 'color.border.focused',
|
|
25
|
+
outlineWidth: 'border.width.outline',
|
|
26
|
+
outlineStyle: 'solid',
|
|
27
|
+
outlineOffset: 'space.025'
|
|
28
|
+
};
|
|
29
|
+
var focusRingStyles = (0, _xcss.xcss)({
|
|
30
|
+
':focus-visible': baseFocusRingStyles,
|
|
31
|
+
'@supports not selector(*:focus-visible)': {
|
|
32
|
+
':focus': baseFocusRingStyles
|
|
33
|
+
},
|
|
34
|
+
'@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
|
|
35
|
+
':focus-visible': {
|
|
36
|
+
outline: '1px solid'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
var IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
|
|
41
|
+
var IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
|
|
42
|
+
var Link = function Link(_ref, ref) {
|
|
43
|
+
var href = _ref.href,
|
|
44
|
+
children = _ref.children,
|
|
45
|
+
backgroundColor = _ref.backgroundColor,
|
|
46
|
+
padding = _ref.padding,
|
|
47
|
+
paddingBlock = _ref.paddingBlock,
|
|
48
|
+
paddingBlockStart = _ref.paddingBlockStart,
|
|
49
|
+
paddingBlockEnd = _ref.paddingBlockEnd,
|
|
50
|
+
paddingInline = _ref.paddingInline,
|
|
51
|
+
paddingInlineStart = _ref.paddingInlineStart,
|
|
52
|
+
paddingInlineEnd = _ref.paddingInlineEnd,
|
|
53
|
+
testId = _ref.testId,
|
|
54
|
+
xcssStyles = _ref.xcss,
|
|
55
|
+
target = _ref.target,
|
|
56
|
+
rel = _ref.rel,
|
|
57
|
+
htmlAttributes = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
58
|
+
var RouterLink = (0, _appProvider.useRouterLink)();
|
|
59
|
+
|
|
60
|
+
// Combine default styles with supplied styles. XCSS does not support deep nested arrays
|
|
61
|
+
var styles = Array.isArray(xcssStyles) ? [focusRingStyles].concat((0, _toConsumableArray2.default)(xcssStyles)) : [focusRingStyles, xcssStyles];
|
|
62
|
+
var isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
|
|
63
|
+
var isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Renders a router link if:
|
|
67
|
+
* - a link component is set in the app provider
|
|
68
|
+
* - it's not an external link (starting with http:// or https://)
|
|
69
|
+
* - it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.)
|
|
70
|
+
*/
|
|
71
|
+
var isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
|
|
72
|
+
var hrefObjectUsedWithoutRouterLink = RouterLink === undefined && (0, _typeof2.default)(href) === 'object';
|
|
73
|
+
(0, _tinyInvariant.default)(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Link primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_box.default
|
|
75
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
76
|
+
, (0, _extends2.default)({}, htmlAttributes, {
|
|
77
|
+
// @ts-expect-error (TODO: Box doesn't allow `as` components)
|
|
78
|
+
as: isRouterLink ? RouterLink : 'a',
|
|
79
|
+
ref: ref,
|
|
80
|
+
testId: testId,
|
|
81
|
+
"data-is-router-link": testId ? isRouterLink ? 'true' : 'false' : undefined,
|
|
82
|
+
href: !isRouterLink && typeof href !== 'string' ? undefined : href,
|
|
83
|
+
target: isExternal && target === undefined ? '_blank' : target,
|
|
84
|
+
rel: isExternal && rel === undefined ? 'noopener noreferrer' : rel,
|
|
85
|
+
backgroundColor: backgroundColor,
|
|
86
|
+
padding: padding,
|
|
87
|
+
paddingBlock: paddingBlock,
|
|
88
|
+
paddingBlockStart: paddingBlockStart,
|
|
89
|
+
paddingBlockEnd: paddingBlockEnd,
|
|
90
|
+
paddingInline: paddingInline,
|
|
91
|
+
paddingInlineStart: paddingInlineStart,
|
|
92
|
+
paddingInlineEnd: paddingInlineEnd
|
|
93
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
94
|
+
,
|
|
95
|
+
xcss: styles
|
|
96
|
+
}), children);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Workarounds to support generic types with forwardRef
|
|
100
|
+
/**
|
|
101
|
+
* __UNSAFE_LINK__
|
|
102
|
+
*
|
|
103
|
+
* @internal Still under development. Do not use.
|
|
104
|
+
*
|
|
105
|
+
* A Link is a primitive component that renders an `<a>` anchor. It utilizes
|
|
106
|
+
* the configured router link component in the AppProvider if set.
|
|
107
|
+
*
|
|
108
|
+
* - [Examples](https://atlassian.design/components/primitives/link/examples)
|
|
109
|
+
* - [Code](https://atlassian.design/components/primitives/link/code)
|
|
110
|
+
* - [Usage](https://atlassian.design/components/primitives/link/usage)
|
|
111
|
+
*/
|
|
112
|
+
var UNSAFE_LINK = /*#__PURE__*/(0, _react.forwardRef)(Link);
|
|
113
|
+
var _default = exports.default = UNSAFE_LINK;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import invariant from 'tiny-invariant';
|
|
4
|
+
import { useRouterLink } from '@atlaskit/app-provider';
|
|
5
|
+
import { xcss } from '../xcss/xcss';
|
|
6
|
+
import Box from './box';
|
|
7
|
+
// TODO: Duplicated FocusRing styles due to lack of `xcss` support
|
|
8
|
+
// and to prevent additional dependency
|
|
9
|
+
const baseFocusRingStyles = {
|
|
10
|
+
outlineColor: 'color.border.focused',
|
|
11
|
+
outlineWidth: 'border.width.outline',
|
|
12
|
+
outlineStyle: 'solid',
|
|
13
|
+
outlineOffset: 'space.025'
|
|
14
|
+
};
|
|
15
|
+
const focusRingStyles = xcss({
|
|
16
|
+
':focus-visible': baseFocusRingStyles,
|
|
17
|
+
'@supports not selector(*:focus-visible)': {
|
|
18
|
+
':focus': baseFocusRingStyles
|
|
19
|
+
},
|
|
20
|
+
'@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
|
|
21
|
+
':focus-visible': {
|
|
22
|
+
outline: '1px solid'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
|
|
27
|
+
const IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
|
|
28
|
+
const Link = ({
|
|
29
|
+
href,
|
|
30
|
+
children,
|
|
31
|
+
backgroundColor,
|
|
32
|
+
padding,
|
|
33
|
+
paddingBlock,
|
|
34
|
+
paddingBlockStart,
|
|
35
|
+
paddingBlockEnd,
|
|
36
|
+
paddingInline,
|
|
37
|
+
paddingInlineStart,
|
|
38
|
+
paddingInlineEnd,
|
|
39
|
+
testId,
|
|
40
|
+
xcss: xcssStyles,
|
|
41
|
+
target,
|
|
42
|
+
rel,
|
|
43
|
+
...htmlAttributes
|
|
44
|
+
}, ref) => {
|
|
45
|
+
const RouterLink = useRouterLink();
|
|
46
|
+
|
|
47
|
+
// Combine default styles with supplied styles. XCSS does not support deep nested arrays
|
|
48
|
+
const styles = Array.isArray(xcssStyles) ? [focusRingStyles, ...xcssStyles] : [focusRingStyles, xcssStyles];
|
|
49
|
+
const isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
|
|
50
|
+
const isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Renders a router link if:
|
|
54
|
+
* - a link component is set in the app provider
|
|
55
|
+
* - it's not an external link (starting with http:// or https://)
|
|
56
|
+
* - it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.)
|
|
57
|
+
*/
|
|
58
|
+
const isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
|
|
59
|
+
const hrefObjectUsedWithoutRouterLink = RouterLink === undefined && typeof href === 'object';
|
|
60
|
+
invariant(!hrefObjectUsedWithoutRouterLink, `@atlaskit/primitives: Link primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider`);
|
|
61
|
+
return /*#__PURE__*/React.createElement(Box
|
|
62
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
63
|
+
, _extends({}, htmlAttributes, {
|
|
64
|
+
// @ts-expect-error (TODO: Box doesn't allow `as` components)
|
|
65
|
+
as: isRouterLink ? RouterLink : 'a',
|
|
66
|
+
ref: ref,
|
|
67
|
+
testId: testId,
|
|
68
|
+
"data-is-router-link": testId ? isRouterLink ? 'true' : 'false' : undefined,
|
|
69
|
+
href: !isRouterLink && typeof href !== 'string' ? undefined : href,
|
|
70
|
+
target: isExternal && target === undefined ? '_blank' : target,
|
|
71
|
+
rel: isExternal && rel === undefined ? 'noopener noreferrer' : rel,
|
|
72
|
+
backgroundColor: backgroundColor,
|
|
73
|
+
padding: padding,
|
|
74
|
+
paddingBlock: paddingBlock,
|
|
75
|
+
paddingBlockStart: paddingBlockStart,
|
|
76
|
+
paddingBlockEnd: paddingBlockEnd,
|
|
77
|
+
paddingInline: paddingInline,
|
|
78
|
+
paddingInlineStart: paddingInlineStart,
|
|
79
|
+
paddingInlineEnd: paddingInlineEnd
|
|
80
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
81
|
+
,
|
|
82
|
+
xcss: styles
|
|
83
|
+
}), children);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Workarounds to support generic types with forwardRef
|
|
87
|
+
/**
|
|
88
|
+
* __UNSAFE_LINK__
|
|
89
|
+
*
|
|
90
|
+
* @internal Still under development. Do not use.
|
|
91
|
+
*
|
|
92
|
+
* A Link is a primitive component that renders an `<a>` anchor. It utilizes
|
|
93
|
+
* the configured router link component in the AppProvider if set.
|
|
94
|
+
*
|
|
95
|
+
* - [Examples](https://atlassian.design/components/primitives/link/examples)
|
|
96
|
+
* - [Code](https://atlassian.design/components/primitives/link/code)
|
|
97
|
+
* - [Usage](https://atlassian.design/components/primitives/link/usage)
|
|
98
|
+
*/
|
|
99
|
+
const UNSAFE_LINK = /*#__PURE__*/forwardRef(Link);
|
|
100
|
+
export default UNSAFE_LINK;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["href", "children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "testId", "xcss", "target", "rel"];
|
|
6
|
+
import React, { forwardRef } from 'react';
|
|
7
|
+
import invariant from 'tiny-invariant';
|
|
8
|
+
import { useRouterLink } from '@atlaskit/app-provider';
|
|
9
|
+
import { xcss } from '../xcss/xcss';
|
|
10
|
+
import Box from './box';
|
|
11
|
+
// TODO: Duplicated FocusRing styles due to lack of `xcss` support
|
|
12
|
+
// and to prevent additional dependency
|
|
13
|
+
var baseFocusRingStyles = {
|
|
14
|
+
outlineColor: 'color.border.focused',
|
|
15
|
+
outlineWidth: 'border.width.outline',
|
|
16
|
+
outlineStyle: 'solid',
|
|
17
|
+
outlineOffset: 'space.025'
|
|
18
|
+
};
|
|
19
|
+
var focusRingStyles = xcss({
|
|
20
|
+
':focus-visible': baseFocusRingStyles,
|
|
21
|
+
'@supports not selector(*:focus-visible)': {
|
|
22
|
+
':focus': baseFocusRingStyles
|
|
23
|
+
},
|
|
24
|
+
'@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
|
|
25
|
+
':focus-visible': {
|
|
26
|
+
outline: '1px solid'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
|
|
31
|
+
var IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
|
|
32
|
+
var Link = function Link(_ref, ref) {
|
|
33
|
+
var href = _ref.href,
|
|
34
|
+
children = _ref.children,
|
|
35
|
+
backgroundColor = _ref.backgroundColor,
|
|
36
|
+
padding = _ref.padding,
|
|
37
|
+
paddingBlock = _ref.paddingBlock,
|
|
38
|
+
paddingBlockStart = _ref.paddingBlockStart,
|
|
39
|
+
paddingBlockEnd = _ref.paddingBlockEnd,
|
|
40
|
+
paddingInline = _ref.paddingInline,
|
|
41
|
+
paddingInlineStart = _ref.paddingInlineStart,
|
|
42
|
+
paddingInlineEnd = _ref.paddingInlineEnd,
|
|
43
|
+
testId = _ref.testId,
|
|
44
|
+
xcssStyles = _ref.xcss,
|
|
45
|
+
target = _ref.target,
|
|
46
|
+
rel = _ref.rel,
|
|
47
|
+
htmlAttributes = _objectWithoutProperties(_ref, _excluded);
|
|
48
|
+
var RouterLink = useRouterLink();
|
|
49
|
+
|
|
50
|
+
// Combine default styles with supplied styles. XCSS does not support deep nested arrays
|
|
51
|
+
var styles = Array.isArray(xcssStyles) ? [focusRingStyles].concat(_toConsumableArray(xcssStyles)) : [focusRingStyles, xcssStyles];
|
|
52
|
+
var isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
|
|
53
|
+
var isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Renders a router link if:
|
|
57
|
+
* - a link component is set in the app provider
|
|
58
|
+
* - it's not an external link (starting with http:// or https://)
|
|
59
|
+
* - it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.)
|
|
60
|
+
*/
|
|
61
|
+
var isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
|
|
62
|
+
var hrefObjectUsedWithoutRouterLink = RouterLink === undefined && _typeof(href) === 'object';
|
|
63
|
+
invariant(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Link primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
|
|
64
|
+
return /*#__PURE__*/React.createElement(Box
|
|
65
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
66
|
+
, _extends({}, htmlAttributes, {
|
|
67
|
+
// @ts-expect-error (TODO: Box doesn't allow `as` components)
|
|
68
|
+
as: isRouterLink ? RouterLink : 'a',
|
|
69
|
+
ref: ref,
|
|
70
|
+
testId: testId,
|
|
71
|
+
"data-is-router-link": testId ? isRouterLink ? 'true' : 'false' : undefined,
|
|
72
|
+
href: !isRouterLink && typeof href !== 'string' ? undefined : href,
|
|
73
|
+
target: isExternal && target === undefined ? '_blank' : target,
|
|
74
|
+
rel: isExternal && rel === undefined ? 'noopener noreferrer' : rel,
|
|
75
|
+
backgroundColor: backgroundColor,
|
|
76
|
+
padding: padding,
|
|
77
|
+
paddingBlock: paddingBlock,
|
|
78
|
+
paddingBlockStart: paddingBlockStart,
|
|
79
|
+
paddingBlockEnd: paddingBlockEnd,
|
|
80
|
+
paddingInline: paddingInline,
|
|
81
|
+
paddingInlineStart: paddingInlineStart,
|
|
82
|
+
paddingInlineEnd: paddingInlineEnd
|
|
83
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
84
|
+
,
|
|
85
|
+
xcss: styles
|
|
86
|
+
}), children);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Workarounds to support generic types with forwardRef
|
|
90
|
+
/**
|
|
91
|
+
* __UNSAFE_LINK__
|
|
92
|
+
*
|
|
93
|
+
* @internal Still under development. Do not use.
|
|
94
|
+
*
|
|
95
|
+
* A Link is a primitive component that renders an `<a>` anchor. It utilizes
|
|
96
|
+
* the configured router link component in the AppProvider if set.
|
|
97
|
+
*
|
|
98
|
+
* - [Examples](https://atlassian.design/components/primitives/link/examples)
|
|
99
|
+
* - [Code](https://atlassian.design/components/primitives/link/code)
|
|
100
|
+
* - [Usage](https://atlassian.design/components/primitives/link/usage)
|
|
101
|
+
*/
|
|
102
|
+
var UNSAFE_LINK = /*#__PURE__*/forwardRef(Link);
|
|
103
|
+
export default UNSAFE_LINK;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type RouterLinkComponentProps } from '@atlaskit/app-provider';
|
|
3
|
+
import { type BoxProps } from './box';
|
|
4
|
+
export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<'a'>, 'href' | 'as' | 'children' | 'style'> & {
|
|
5
|
+
/**
|
|
6
|
+
* `children` should be defined to ensure links have text
|
|
7
|
+
*/
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare const Link: <RouterLinkConfig extends Record<string, any> = never>({ href, children, backgroundColor, padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, testId, xcss: xcssStyles, target, rel, ...htmlAttributes }: LinkProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* __UNSAFE_LINK__
|
|
13
|
+
*
|
|
14
|
+
* @internal Still under development. Do not use.
|
|
15
|
+
*
|
|
16
|
+
* A Link is a primitive component that renders an `<a>` anchor. It utilizes
|
|
17
|
+
* the configured router link component in the AppProvider if set.
|
|
18
|
+
*
|
|
19
|
+
* - [Examples](https://atlassian.design/components/primitives/link/examples)
|
|
20
|
+
* - [Code](https://atlassian.design/components/primitives/link/code)
|
|
21
|
+
* - [Usage](https://atlassian.design/components/primitives/link/usage)
|
|
22
|
+
*/
|
|
23
|
+
declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "href"> & {
|
|
24
|
+
/**
|
|
25
|
+
* `children` should be defined to ensure links have text
|
|
26
|
+
*/
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
} & {
|
|
29
|
+
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
30
|
+
}) => ReturnType<typeof Link>;
|
|
31
|
+
export default UNSAFE_LINK;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type RouterLinkComponentProps } from '@atlaskit/app-provider';
|
|
3
|
+
import { type BoxProps } from './box';
|
|
4
|
+
export type LinkProps<RouterLinkConfig extends Record<string, any> = never> = RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<'a'>, 'href' | 'as' | 'children' | 'style'> & {
|
|
5
|
+
/**
|
|
6
|
+
* `children` should be defined to ensure links have text
|
|
7
|
+
*/
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare const Link: <RouterLinkConfig extends Record<string, any> = never>({ href, children, backgroundColor, padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, testId, xcss: xcssStyles, target, rel, ...htmlAttributes }: LinkProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* __UNSAFE_LINK__
|
|
13
|
+
*
|
|
14
|
+
* @internal Still under development. Do not use.
|
|
15
|
+
*
|
|
16
|
+
* A Link is a primitive component that renders an `<a>` anchor. It utilizes
|
|
17
|
+
* the configured router link component in the AppProvider if set.
|
|
18
|
+
*
|
|
19
|
+
* - [Examples](https://atlassian.design/components/primitives/link/examples)
|
|
20
|
+
* - [Code](https://atlassian.design/components/primitives/link/code)
|
|
21
|
+
* - [Usage](https://atlassian.design/components/primitives/link/usage)
|
|
22
|
+
*/
|
|
23
|
+
declare const UNSAFE_LINK: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "href"> & {
|
|
24
|
+
/**
|
|
25
|
+
* `children` should be defined to ensure links have text
|
|
26
|
+
*/
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
} & {
|
|
29
|
+
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
30
|
+
}) => ReturnType<typeof Link>;
|
|
31
|
+
export default UNSAFE_LINK;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -125,6 +125,7 @@
|
|
|
125
125
|
"codegen-styles": "ts-node -r tsconfig-paths/register ./scripts/codegen-styles.tsx"
|
|
126
126
|
},
|
|
127
127
|
"dependencies": {
|
|
128
|
+
"@atlaskit/app-provider": "^0.4.0",
|
|
128
129
|
"@atlaskit/tokens": "^1.28.0",
|
|
129
130
|
"@babel/runtime": "^7.0.0",
|
|
130
131
|
"@emotion/react": "^11.7.1",
|
|
@@ -191,6 +192,7 @@
|
|
|
191
192
|
"./stack": "./src/components/stack.tsx",
|
|
192
193
|
"./inline": "./src/components/inline.tsx",
|
|
193
194
|
"./pressable": "./src/components/pressable.tsx",
|
|
195
|
+
"./link": "./src/components/link.tsx",
|
|
194
196
|
"./responsive": "./src/responsive/index.tsx"
|
|
195
197
|
},
|
|
196
198
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|