@atlaskit/primitives 12.2.6 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/compiled/package.json +15 -0
- package/dist/cjs/compiled/components/anchor.compiled.css +12 -0
- package/dist/cjs/compiled/components/anchor.js +130 -0
- package/dist/cjs/compiled/components/bleed.compiled.css +11 -0
- package/dist/cjs/compiled/components/bleed.js +49 -0
- package/dist/cjs/compiled/components/box.compiled.css +266 -0
- package/dist/cjs/compiled/components/box.js +367 -0
- package/dist/cjs/compiled/components/flex.compiled.css +46 -0
- package/dist/cjs/compiled/components/flex.js +119 -0
- package/dist/cjs/compiled/components/grid.compiled.css +54 -0
- package/dist/cjs/compiled/components/grid.js +129 -0
- package/dist/cjs/compiled/components/inline.compiled.css +8 -0
- package/dist/cjs/compiled/components/inline.js +83 -0
- package/dist/cjs/compiled/components/internal/surface-provider.js +25 -0
- package/dist/cjs/compiled/components/internal/types.js +1 -0
- package/dist/cjs/compiled/components/pressable.compiled.css +13 -0
- package/dist/cjs/compiled/components/pressable.js +87 -0
- package/dist/cjs/compiled/components/stack.compiled.css +3 -0
- package/dist/cjs/compiled/components/stack.js +64 -0
- package/dist/cjs/compiled/components/text.compiled.css +60 -0
- package/dist/cjs/compiled/components/text.js +177 -0
- package/dist/cjs/compiled/components/types.js +5 -0
- package/dist/cjs/compiled/index.js +83 -0
- package/dist/cjs/compiled/responsive/hide.compiled.css +11 -0
- package/dist/cjs/compiled/responsive/hide.js +46 -0
- package/dist/cjs/compiled/responsive/index.js +33 -0
- package/dist/cjs/compiled/responsive/media-helper.js +42 -0
- package/dist/cjs/compiled/responsive/show.compiled.css +11 -0
- package/dist/cjs/compiled/responsive/show.js +47 -0
- package/dist/cjs/compiled/responsive/types.js +5 -0
- package/dist/cjs/compiled/responsive/use-media-query.js +77 -0
- package/dist/cjs/components/anchor.js +1 -1
- package/dist/cjs/components/pressable.js +1 -1
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/xcss/style-maps.partial.js +7 -6
- package/dist/es2019/compiled/components/anchor.compiled.css +12 -0
- package/dist/es2019/compiled/components/anchor.js +117 -0
- package/dist/es2019/compiled/components/bleed.compiled.css +11 -0
- package/dist/es2019/compiled/components/bleed.js +43 -0
- package/dist/es2019/compiled/components/box.compiled.css +266 -0
- package/dist/es2019/compiled/components/box.js +351 -0
- package/dist/es2019/compiled/components/flex.compiled.css +46 -0
- package/dist/es2019/compiled/components/flex.js +110 -0
- package/dist/es2019/compiled/components/grid.compiled.css +54 -0
- package/dist/es2019/compiled/components/grid.js +121 -0
- package/dist/es2019/compiled/components/inline.compiled.css +8 -0
- package/dist/es2019/compiled/components/inline.js +71 -0
- package/dist/es2019/compiled/components/internal/surface-provider.js +19 -0
- package/dist/es2019/compiled/components/internal/types.js +0 -0
- package/dist/es2019/compiled/components/pressable.compiled.css +13 -0
- package/dist/es2019/compiled/components/pressable.js +75 -0
- package/dist/es2019/compiled/components/stack.compiled.css +3 -0
- package/dist/es2019/compiled/components/stack.js +54 -0
- package/dist/es2019/compiled/components/text.compiled.css +60 -0
- package/dist/es2019/compiled/components/text.js +164 -0
- package/dist/es2019/compiled/components/types.js +1 -0
- package/dist/es2019/compiled/index.js +13 -0
- package/dist/es2019/compiled/responsive/hide.compiled.css +11 -0
- package/dist/es2019/compiled/responsive/hide.js +37 -0
- package/dist/es2019/compiled/responsive/index.js +4 -0
- package/dist/es2019/compiled/responsive/media-helper.js +36 -0
- package/dist/es2019/compiled/responsive/show.compiled.css +11 -0
- package/dist/es2019/compiled/responsive/show.js +38 -0
- package/dist/es2019/compiled/responsive/types.js +1 -0
- package/dist/es2019/compiled/responsive/use-media-query.js +71 -0
- package/dist/es2019/components/anchor.js +1 -1
- package/dist/es2019/components/pressable.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +7 -6
- package/dist/esm/compiled/components/anchor.compiled.css +12 -0
- package/dist/esm/compiled/components/anchor.js +120 -0
- package/dist/esm/compiled/components/bleed.compiled.css +11 -0
- package/dist/esm/compiled/components/bleed.js +42 -0
- package/dist/esm/compiled/components/box.compiled.css +266 -0
- package/dist/esm/compiled/components/box.js +358 -0
- package/dist/esm/compiled/components/flex.compiled.css +46 -0
- package/dist/esm/compiled/components/flex.js +110 -0
- package/dist/esm/compiled/components/grid.compiled.css +54 -0
- package/dist/esm/compiled/components/grid.js +120 -0
- package/dist/esm/compiled/components/inline.compiled.css +8 -0
- package/dist/esm/compiled/components/inline.js +73 -0
- package/dist/esm/compiled/components/internal/surface-provider.js +19 -0
- package/dist/esm/compiled/components/internal/types.js +0 -0
- package/dist/esm/compiled/components/pressable.compiled.css +13 -0
- package/dist/esm/compiled/components/pressable.js +77 -0
- package/dist/esm/compiled/components/stack.compiled.css +3 -0
- package/dist/esm/compiled/components/stack.js +54 -0
- package/dist/esm/compiled/components/text.compiled.css +60 -0
- package/dist/esm/compiled/components/text.js +167 -0
- package/dist/esm/compiled/components/types.js +1 -0
- package/dist/esm/compiled/index.js +13 -0
- package/dist/esm/compiled/responsive/hide.compiled.css +11 -0
- package/dist/esm/compiled/responsive/hide.js +37 -0
- package/dist/esm/compiled/responsive/index.js +4 -0
- package/dist/esm/compiled/responsive/media-helper.js +36 -0
- package/dist/esm/compiled/responsive/show.compiled.css +11 -0
- package/dist/esm/compiled/responsive/show.js +38 -0
- package/dist/esm/compiled/responsive/types.js +1 -0
- package/dist/esm/compiled/responsive/use-media-query.js +71 -0
- package/dist/esm/components/anchor.js +1 -1
- package/dist/esm/components/pressable.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/xcss/style-maps.partial.js +7 -6
- package/dist/types/compiled/components/anchor.d.ts +63 -0
- package/dist/types/compiled/components/bleed.d.ts +34 -0
- package/dist/types/compiled/components/box.d.ts +105 -0
- package/dist/types/compiled/components/flex.d.ts +111 -0
- package/dist/types/compiled/components/grid.d.ts +131 -0
- package/dist/types/compiled/components/inline.d.ts +116 -0
- package/dist/types/compiled/components/internal/surface-provider.d.ts +16 -0
- package/dist/types/compiled/components/internal/types.d.ts +5 -0
- package/dist/types/compiled/components/pressable.d.ts +49 -0
- package/dist/types/compiled/components/stack.d.ts +90 -0
- package/dist/types/compiled/components/text.d.ts +91 -0
- package/dist/types/compiled/components/types.d.ts +45 -0
- package/dist/types/compiled/index.d.ts +12 -0
- package/dist/types/compiled/responsive/hide.d.ts +39 -0
- package/dist/types/compiled/responsive/index.d.ts +5 -0
- package/dist/types/compiled/responsive/media-helper.d.ts +35 -0
- package/dist/types/compiled/responsive/show.d.ts +39 -0
- package/dist/types/compiled/responsive/types.d.ts +10 -0
- package/dist/types/compiled/responsive/use-media-query.d.ts +23 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/xcss/style-maps.partial.d.ts +7 -6
- package/dist/types/xcss/xcss.d.ts +1 -0
- package/dist/types-ts4.5/compiled/components/anchor.d.ts +63 -0
- package/dist/types-ts4.5/compiled/components/bleed.d.ts +34 -0
- package/dist/types-ts4.5/compiled/components/box.d.ts +105 -0
- package/dist/types-ts4.5/compiled/components/flex.d.ts +111 -0
- package/dist/types-ts4.5/compiled/components/grid.d.ts +131 -0
- package/dist/types-ts4.5/compiled/components/inline.d.ts +116 -0
- package/dist/types-ts4.5/compiled/components/internal/surface-provider.d.ts +16 -0
- package/dist/types-ts4.5/compiled/components/internal/types.d.ts +5 -0
- package/dist/types-ts4.5/compiled/components/pressable.d.ts +49 -0
- package/dist/types-ts4.5/compiled/components/stack.d.ts +90 -0
- package/dist/types-ts4.5/compiled/components/text.d.ts +96 -0
- package/dist/types-ts4.5/compiled/components/types.d.ts +45 -0
- package/dist/types-ts4.5/compiled/index.d.ts +12 -0
- package/dist/types-ts4.5/compiled/responsive/hide.d.ts +39 -0
- package/dist/types-ts4.5/compiled/responsive/index.d.ts +5 -0
- package/dist/types-ts4.5/compiled/responsive/media-helper.d.ts +35 -0
- package/dist/types-ts4.5/compiled/responsive/show.d.ts +39 -0
- package/dist/types-ts4.5/compiled/responsive/types.d.ts +10 -0
- package/dist/types-ts4.5/compiled/responsive/use-media-query.d.ts +23 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +7 -6
- package/dist/types-ts4.5/xcss/xcss.d.ts +1 -0
- package/package.json +4 -2
- package/scripts/codegen-file-templates/layer.tsx +1 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* text.tsx generated by @compiled/babel-plugin v0.32.2 */
|
|
2
|
+
import "./text.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { createContext, forwardRef, useContext } from 'react';
|
|
6
|
+
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useSurface } from './internal/surface-provider';
|
|
8
|
+
const asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
9
|
+
const HasTextAncestorContext = /*#__PURE__*/createContext(false);
|
|
10
|
+
const useHasTextAncestor = () => useContext(HasTextAncestorContext);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 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.
|
|
14
|
+
*/
|
|
15
|
+
const useColor = (colorProp, hasTextAncestor) => {
|
|
16
|
+
const surface = useSurface();
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* Where the color of the surface is inverted we always override the color
|
|
20
|
+
* as there is no valid choice that is not covered by the override.
|
|
21
|
+
*/
|
|
22
|
+
if (surface in inverseColorMap) {
|
|
23
|
+
return inverseColorMap[surface];
|
|
24
|
+
}
|
|
25
|
+
if (colorProp === 'inherit') {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
if (!colorProp && hasTextAncestor) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return colorProp || 'color.text';
|
|
32
|
+
};
|
|
33
|
+
const styles = {
|
|
34
|
+
root: "_19pkidpf _2hwxidpf _otyridpf _18u0idpf _1i4qfg65",
|
|
35
|
+
'as.strong': "_k48p8n31",
|
|
36
|
+
'as.em': "_zg8l1m30",
|
|
37
|
+
'textAlign.center': "_y3gn1h6o",
|
|
38
|
+
'textAlign.end': "_y3gnh9n0",
|
|
39
|
+
'textAlign.start': "_y3gnv2br",
|
|
40
|
+
truncation: "_1e0ccj1k _1reo15vq _18m915vq _sudp1e54",
|
|
41
|
+
breakAll: "_1nmz9jpi"
|
|
42
|
+
};
|
|
43
|
+
const fontSizeMap = {
|
|
44
|
+
medium: "_11c81oud",
|
|
45
|
+
UNSAFE_small: "_11c8qk37",
|
|
46
|
+
large: "_11c81doa",
|
|
47
|
+
small: "_11c81vlj"
|
|
48
|
+
};
|
|
49
|
+
const fontWeightMap = {
|
|
50
|
+
bold: "_k48pmoej",
|
|
51
|
+
medium: "_k48p1wq8",
|
|
52
|
+
regular: "_k48pi7a9",
|
|
53
|
+
semibold: "_k48p1pd9"
|
|
54
|
+
};
|
|
55
|
+
const textColorMap = {
|
|
56
|
+
'color.text': "_syaz1fxt",
|
|
57
|
+
'color.text.accent.lime': "_syaz1tco",
|
|
58
|
+
'color.text.accent.lime.bolder': "_syaz1ik3",
|
|
59
|
+
'color.text.accent.red': "_syaz9lu1",
|
|
60
|
+
'color.text.accent.red.bolder': "_syazhwvp",
|
|
61
|
+
'color.text.accent.orange': "_syaz1q28",
|
|
62
|
+
'color.text.accent.orange.bolder': "_syaz1vps",
|
|
63
|
+
'color.text.accent.yellow': "_syazfb2s",
|
|
64
|
+
'color.text.accent.yellow.bolder': "_syazekll",
|
|
65
|
+
'color.text.accent.green': "_syazh55r",
|
|
66
|
+
'color.text.accent.green.bolder': "_syaz1y78",
|
|
67
|
+
'color.text.accent.teal': "_syaz17qg",
|
|
68
|
+
'color.text.accent.teal.bolder': "_syaz12v7",
|
|
69
|
+
'color.text.accent.blue': "_syazpnps",
|
|
70
|
+
'color.text.accent.blue.bolder': "_syazsc1o",
|
|
71
|
+
'color.text.accent.purple': "_syaz10m5",
|
|
72
|
+
'color.text.accent.purple.bolder': "_syaz2ibx",
|
|
73
|
+
'color.text.accent.magenta': "_syaz1s8m",
|
|
74
|
+
'color.text.accent.magenta.bolder': "_syaz1qur",
|
|
75
|
+
'color.text.accent.gray': "_syaz1dyx",
|
|
76
|
+
'color.text.accent.gray.bolder': "_syaz1x9z",
|
|
77
|
+
'color.text.disabled': "_syaz1lh4",
|
|
78
|
+
'color.text.inverse': "_syaz15cr",
|
|
79
|
+
'color.text.selected': "_syazaqb7",
|
|
80
|
+
'color.text.brand': "_syaz1e6v",
|
|
81
|
+
'color.text.danger': "_syaz1tmw",
|
|
82
|
+
'color.text.warning': "_syazwx40",
|
|
83
|
+
'color.text.warning.inverse': "_syazal3n",
|
|
84
|
+
'color.text.success': "_syazy73q",
|
|
85
|
+
'color.text.discovery': "_syazzjem",
|
|
86
|
+
'color.text.information': "_syaze0os",
|
|
87
|
+
'color.text.subtlest': "_syaz131l",
|
|
88
|
+
'color.text.subtle': "_syaz1gjq",
|
|
89
|
+
'color.link': "_syaz14q2",
|
|
90
|
+
'color.link.pressed': "_syaz16c2",
|
|
91
|
+
'color.link.visited': "_syazw7te",
|
|
92
|
+
'color.link.visited.pressed': "_syazg3x0"
|
|
93
|
+
};
|
|
94
|
+
export const inverseColorMap = {
|
|
95
|
+
'color.background.neutral.bold': 'color.text.inverse',
|
|
96
|
+
'color.background.neutral.bold.hovered': 'color.text.inverse',
|
|
97
|
+
'color.background.neutral.bold.pressed': 'color.text.inverse',
|
|
98
|
+
'color.background.selected.bold': 'color.text.inverse',
|
|
99
|
+
'color.background.selected.bold.hovered': 'color.text.inverse',
|
|
100
|
+
'color.background.selected.bold.pressed': 'color.text.inverse',
|
|
101
|
+
'color.background.brand.bold': 'color.text.inverse',
|
|
102
|
+
'color.background.brand.bold.hovered': 'color.text.inverse',
|
|
103
|
+
'color.background.brand.bold.pressed': 'color.text.inverse',
|
|
104
|
+
'color.background.brand.boldest': 'color.text.inverse',
|
|
105
|
+
'color.background.brand.boldest.hovered': 'color.text.inverse',
|
|
106
|
+
'color.background.brand.boldest.pressed': 'color.text.inverse',
|
|
107
|
+
'color.background.danger.bold': 'color.text.inverse',
|
|
108
|
+
'color.background.danger.bold.hovered': 'color.text.inverse',
|
|
109
|
+
'color.background.danger.bold.pressed': 'color.text.inverse',
|
|
110
|
+
'color.background.warning.bold': 'color.text.warning.inverse',
|
|
111
|
+
'color.background.warning.bold.hovered': 'color.text.warning.inverse',
|
|
112
|
+
'color.background.warning.bold.pressed': 'color.text.warning.inverse',
|
|
113
|
+
'color.background.success.bold': 'color.text.inverse',
|
|
114
|
+
'color.background.success.bold.hovered': 'color.text.inverse',
|
|
115
|
+
'color.background.success.bold.pressed': 'color.text.inverse',
|
|
116
|
+
'color.background.discovery.bold': 'color.text.inverse',
|
|
117
|
+
'color.background.discovery.bold.hovered': 'color.text.inverse',
|
|
118
|
+
'color.background.discovery.bold.pressed': 'color.text.inverse',
|
|
119
|
+
'color.background.information.bold': 'color.text.inverse',
|
|
120
|
+
'color.background.information.bold.hovered': 'color.text.inverse',
|
|
121
|
+
'color.background.information.bold.pressed': 'color.text.inverse'
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* __Text__
|
|
126
|
+
*
|
|
127
|
+
* Text is a primitive component that has the Atlassian Design System's design guidelines baked in.
|
|
128
|
+
* This includes considerations for text attributes such as color, font size, font weight, and line height.
|
|
129
|
+
* It renders a `span` by default.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
const Text = /*#__PURE__*/forwardRef(({
|
|
134
|
+
as: Component = 'span',
|
|
135
|
+
color: colorProp,
|
|
136
|
+
align,
|
|
137
|
+
testId,
|
|
138
|
+
id,
|
|
139
|
+
size = 'medium',
|
|
140
|
+
weight,
|
|
141
|
+
maxLines,
|
|
142
|
+
children
|
|
143
|
+
}, ref) => {
|
|
144
|
+
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
145
|
+
const hasTextAncestor = useHasTextAncestor();
|
|
146
|
+
const color = useColor(colorProp, hasTextAncestor);
|
|
147
|
+
const component = /*#__PURE__*/React.createElement(Component, {
|
|
148
|
+
id: id,
|
|
149
|
+
style: {
|
|
150
|
+
WebkitLineClamp: maxLines
|
|
151
|
+
},
|
|
152
|
+
"data-testid": testId,
|
|
153
|
+
ref: ref,
|
|
154
|
+
className: ax([styles.root, fontSizeMap[size], color && textColorMap[color], maxLines && styles.truncation, maxLines === 1 && styles.breakAll, align && styles[`textAlign.${align}`], weight && fontWeightMap[weight], Component === 'em' && styles['as.em'], Component === 'strong' && styles['as.strong']])
|
|
155
|
+
}, children);
|
|
156
|
+
if (hasTextAncestor) {
|
|
157
|
+
// no need to re-apply context if the text is already wrapped
|
|
158
|
+
return component;
|
|
159
|
+
}
|
|
160
|
+
return /*#__PURE__*/React.createElement(HasTextAncestorContext.Provider, {
|
|
161
|
+
value: true
|
|
162
|
+
}, component);
|
|
163
|
+
});
|
|
164
|
+
export default Text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as Box } from './components/box';
|
|
2
|
+
export { default as Inline } from './components/inline';
|
|
3
|
+
export { default as Stack } from './components/stack';
|
|
4
|
+
export { default as Flex } from './components/flex';
|
|
5
|
+
export { default as Grid } from './components/grid';
|
|
6
|
+
export { default as Bleed } from './components/bleed';
|
|
7
|
+
export { default as Text } from './components/text';
|
|
8
|
+
export { default as Pressable } from './components/pressable';
|
|
9
|
+
export { default as Anchor } from './components/anchor';
|
|
10
|
+
export { media } from './responsive';
|
|
11
|
+
|
|
12
|
+
// TODO: This is still not figured out from before…
|
|
13
|
+
export { useSurface as UNSAFE_useSurface } from './components/internal/surface-provider';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
@media (min-width:30rem){._114bglyw{display:none}}
|
|
3
|
+
@media not all and (min-width:30rem){._1m0aglyw{display:none}}
|
|
4
|
+
@media (min-width:48rem){._181nglyw{display:none}}
|
|
5
|
+
@media not all and (min-width:48rem){._sugaglyw{display:none}}
|
|
6
|
+
@media (min-width:64rem){._dm25glyw{display:none}}
|
|
7
|
+
@media not all and (min-width:64rem){._1mjbglyw{display:none}}
|
|
8
|
+
@media (min-width:90rem){._je3oglyw{display:none}}
|
|
9
|
+
@media not all and (min-width:90rem){._liwcglyw{display:none}}
|
|
10
|
+
@media (min-width:110.5rem){._1uxvglyw{display:none}}
|
|
11
|
+
@media not all and (min-width:110.5rem){._14wzglyw{display:none}}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* hide.tsx generated by @compiled/babel-plugin v0.32.2 */
|
|
2
|
+
import "./hide.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
const styles = {
|
|
6
|
+
'above.xs': "_114bglyw",
|
|
7
|
+
'above.sm': "_181nglyw",
|
|
8
|
+
'above.md': "_dm25glyw",
|
|
9
|
+
'above.lg': "_je3oglyw",
|
|
10
|
+
'above.xl': "_1uxvglyw",
|
|
11
|
+
'below.xs': "_1m0aglyw",
|
|
12
|
+
'below.sm': "_sugaglyw",
|
|
13
|
+
'below.md': "_1mjbglyw",
|
|
14
|
+
'below.lg': "_liwcglyw",
|
|
15
|
+
'below.xl': "_14wzglyw"
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Hides the content at a given breakpoint. By default, content is shown. The primary use case is for visual presentation.
|
|
19
|
+
* Mix `<Hide above="md">` with `<Show above="md">` to achieve content that shifts at a breakpoint.
|
|
20
|
+
*
|
|
21
|
+
* Please note:
|
|
22
|
+
* - This only uses `display: none` hide, it does not skip rendering of children trees.
|
|
23
|
+
* - As this is rendered at all times, there is little performance savings here (just that this is not painted).
|
|
24
|
+
*/
|
|
25
|
+
export const Hide = ({
|
|
26
|
+
above,
|
|
27
|
+
below,
|
|
28
|
+
children,
|
|
29
|
+
as: AsElement = 'div',
|
|
30
|
+
xcss
|
|
31
|
+
}) => {
|
|
32
|
+
return /*#__PURE__*/React.createElement(AsElement
|
|
33
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- TODO: Allow pass-through from `props.xcss`
|
|
34
|
+
, {
|
|
35
|
+
className: ax([above && styles[`above.${above}`], below && styles[`below.${below}`], xcss])
|
|
36
|
+
}, children);
|
|
37
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
3
|
+
*
|
|
4
|
+
* When using Compiled CSS-in-JS, please ensure that only a single declaration can take effect at a time.
|
|
5
|
+
* This means that you should avoid multiple breakpoints taking effect at the same time,
|
|
6
|
+
* eg. ```{ [media.above.xs]: { color: 'red' }, [media.above.sm]: { color: 'green' }}```.
|
|
7
|
+
* Instead, make sure that only one breakpoint can take effect at a time,
|
|
8
|
+
* e.g, ```{ [media.only.xs]: { color: 'red' }, [media.above.sm]: { color: 'green' }}```.
|
|
9
|
+
* For more details, please see <https://compiledcssinjs.com/docs/atomic-css#selector-specificity>.
|
|
10
|
+
*/
|
|
11
|
+
export const media = {
|
|
12
|
+
above: {
|
|
13
|
+
// TODO: Should this even exist, we don't want `css({ [media.above.xxs]: { … } })` because that just adds duplicates styles!
|
|
14
|
+
xxs: '@media all',
|
|
15
|
+
xs: '@media (min-width: 30rem)',
|
|
16
|
+
sm: '@media (min-width: 48rem)',
|
|
17
|
+
md: '@media (min-width: 64rem)',
|
|
18
|
+
lg: '@media (min-width: 90rem)',
|
|
19
|
+
xl: '@media (min-width: 110.5rem)'
|
|
20
|
+
},
|
|
21
|
+
only: {
|
|
22
|
+
xxs: '@media (min-width: 0rem) and (max-width: 29.99rem)',
|
|
23
|
+
xs: '@media (min-width: 30rem) and (max-width: 47.99rem)',
|
|
24
|
+
sm: '@media (min-width: 48rem) and (max-width: 63.99rem)',
|
|
25
|
+
md: '@media (min-width: 64rem) and (max-width: 89.99rem)',
|
|
26
|
+
lg: '@media (min-width: 90rem) and (max-width: 110.49rem)',
|
|
27
|
+
xl: '@media (min-width: 110.5rem)'
|
|
28
|
+
},
|
|
29
|
+
below: {
|
|
30
|
+
xs: '@media not all and (min-width: 30rem)',
|
|
31
|
+
sm: '@media not all and (min-width: 48rem)',
|
|
32
|
+
md: '@media not all and (min-width: 64rem)',
|
|
33
|
+
lg: '@media not all and (min-width: 90rem)',
|
|
34
|
+
xl: '@media not all and (min-width: 110.5rem)'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
._1e0cglyw{display:none}
|
|
2
|
+
@media (min-width:30rem){._114b19ly{display:revert}}
|
|
3
|
+
@media not all and (min-width:30rem){._1m0a19ly{display:revert}}
|
|
4
|
+
@media (min-width:48rem){._181n19ly{display:revert}}
|
|
5
|
+
@media not all and (min-width:48rem){._suga19ly{display:revert}}
|
|
6
|
+
@media (min-width:64rem){._dm2519ly{display:revert}}
|
|
7
|
+
@media not all and (min-width:64rem){._1mjb19ly{display:revert}}
|
|
8
|
+
@media (min-width:90rem){._je3o19ly{display:revert}}
|
|
9
|
+
@media not all and (min-width:90rem){._liwc19ly{display:revert}}
|
|
10
|
+
@media (min-width:110.5rem){._1uxv19ly{display:revert}}
|
|
11
|
+
@media not all and (min-width:110.5rem){._14wz19ly{display:revert}}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* show.tsx generated by @compiled/babel-plugin v0.32.2 */
|
|
2
|
+
import "./show.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
const styles = {
|
|
6
|
+
default: "_1e0cglyw",
|
|
7
|
+
'above.xs': "_114b19ly",
|
|
8
|
+
'above.sm': "_181n19ly",
|
|
9
|
+
'above.md': "_dm2519ly",
|
|
10
|
+
'above.lg': "_je3o19ly",
|
|
11
|
+
'above.xl': "_1uxv19ly",
|
|
12
|
+
'below.xs': "_1m0a19ly",
|
|
13
|
+
'below.sm': "_suga19ly",
|
|
14
|
+
'below.md': "_1mjb19ly",
|
|
15
|
+
'below.lg': "_liwc19ly",
|
|
16
|
+
'below.xl': "_14wz19ly"
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Shows the content at a given breakpoint. By default, content is hidden. The primary use case is for visual presentation.
|
|
20
|
+
* Mix `<Show above="md">` with `<Hide above="md">` to achieve content that shifts at a breakpoint.
|
|
21
|
+
*
|
|
22
|
+
* Please note:
|
|
23
|
+
* - This only uses `display: none` and `display: revert` to show/hide, it does not skip rendering of children trees.
|
|
24
|
+
* - As this is rendered at all times, there is little performance savings here (just that this is not painted).
|
|
25
|
+
*/
|
|
26
|
+
export const Show = ({
|
|
27
|
+
above,
|
|
28
|
+
below,
|
|
29
|
+
children,
|
|
30
|
+
as: AsElement = 'div',
|
|
31
|
+
xcss
|
|
32
|
+
}) => {
|
|
33
|
+
return /*#__PURE__*/React.createElement(AsElement
|
|
34
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- TODO: Allow pass-through from `props.xcss`
|
|
35
|
+
, {
|
|
36
|
+
className: ax([styles.default, above && styles[`above.${above}`], below && styles[`below.${below}`], xcss])
|
|
37
|
+
}, children);
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var _window, _window$matchMedia, _window2, _window2$matchMedia, _window3, _window3$matchMedia, _window4, _window4$matchMedia, _window5, _window5$matchMedia, _window6, _window6$matchMedia, _window7, _window7$matchMedia, _window8, _window8$matchMedia, _window9, _window9$matchMedia, _window10, _window10$matchMedia, _window11, _window11$matchMedia;
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
3
|
+
import { bind } from 'bind-event-listener';
|
|
4
|
+
import { media } from './media-helper';
|
|
5
|
+
const queries = {
|
|
6
|
+
'above.xxs': typeof window === 'undefined' ? undefined : (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, media.above.xxs.replace('@media ', '').trim()),
|
|
7
|
+
'above.xs': typeof window === 'undefined' ? undefined : (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$matchMedia = _window2.matchMedia) === null || _window2$matchMedia === void 0 ? void 0 : _window2$matchMedia.call(_window2, media.above.xs.replace('@media ', '').trim()),
|
|
8
|
+
'above.sm': typeof window === 'undefined' ? undefined : (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$matchMedia = _window3.matchMedia) === null || _window3$matchMedia === void 0 ? void 0 : _window3$matchMedia.call(_window3, media.above.sm.replace('@media ', '').trim()),
|
|
9
|
+
'above.md': typeof window === 'undefined' ? undefined : (_window4 = window) === null || _window4 === void 0 ? void 0 : (_window4$matchMedia = _window4.matchMedia) === null || _window4$matchMedia === void 0 ? void 0 : _window4$matchMedia.call(_window4, media.above.md.replace('@media ', '').trim()),
|
|
10
|
+
'above.lg': typeof window === 'undefined' ? undefined : (_window5 = window) === null || _window5 === void 0 ? void 0 : (_window5$matchMedia = _window5.matchMedia) === null || _window5$matchMedia === void 0 ? void 0 : _window5$matchMedia.call(_window5, media.above.lg.replace('@media ', '').trim()),
|
|
11
|
+
'above.xl': typeof window === 'undefined' ? undefined : (_window6 = window) === null || _window6 === void 0 ? void 0 : (_window6$matchMedia = _window6.matchMedia) === null || _window6$matchMedia === void 0 ? void 0 : _window6$matchMedia.call(_window6, media.above.xl.replace('@media ', '').trim()),
|
|
12
|
+
'below.xs': typeof window === 'undefined' ? undefined : (_window7 = window) === null || _window7 === void 0 ? void 0 : (_window7$matchMedia = _window7.matchMedia) === null || _window7$matchMedia === void 0 ? void 0 : _window7$matchMedia.call(_window7, media.below.xs.replace('@media ', '').trim()),
|
|
13
|
+
'below.sm': typeof window === 'undefined' ? undefined : (_window8 = window) === null || _window8 === void 0 ? void 0 : (_window8$matchMedia = _window8.matchMedia) === null || _window8$matchMedia === void 0 ? void 0 : _window8$matchMedia.call(_window8, media.below.sm.replace('@media ', '').trim()),
|
|
14
|
+
'below.md': typeof window === 'undefined' ? undefined : (_window9 = window) === null || _window9 === void 0 ? void 0 : (_window9$matchMedia = _window9.matchMedia) === null || _window9$matchMedia === void 0 ? void 0 : _window9$matchMedia.call(_window9, media.below.md.replace('@media ', '').trim()),
|
|
15
|
+
'below.lg': typeof window === 'undefined' ? undefined : (_window10 = window) === null || _window10 === void 0 ? void 0 : (_window10$matchMedia = _window10.matchMedia) === null || _window10$matchMedia === void 0 ? void 0 : _window10$matchMedia.call(_window10, media.below.lg.replace('@media ', '').trim()),
|
|
16
|
+
'below.xl': typeof window === 'undefined' ? undefined : (_window11 = window) === null || _window11 === void 0 ? void 0 : (_window11$matchMedia = _window11.matchMedia) === null || _window11$matchMedia === void 0 ? void 0 : _window11$matchMedia.call(_window11, media.below.xl.replace('@media ', '').trim())
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A hook which returnes a `window.matchMedia` result to help you build responsively around breakpoints in JavaScript.
|
|
21
|
+
*
|
|
22
|
+
* The returning value **WILL NOT** update or react to change. You can use `mq.matches` to get the latest version and you can use the optional listener argument to react to changes as desired.
|
|
23
|
+
*
|
|
24
|
+
* @important
|
|
25
|
+
* - This will always be `null` in SSR and the event listener should not fire on SSR => clientside hydration.
|
|
26
|
+
* - `above.xxs` will always be truthy, your listener should never fire.
|
|
27
|
+
*
|
|
28
|
+
* @experimental This hook only works on the client-side and is not safe in an SSR environment as `window` is unavailable (and the user's viewport would be unknown)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const mq = useMediaQuery('below.md', useCallback((event) => console.log('changed', event.matches)), []))
|
|
32
|
+
* const isMobile = mq?.matches;
|
|
33
|
+
*
|
|
34
|
+
* @returns
|
|
35
|
+
* - `MediaQueryList`, primarily used to get if that media query is currently
|
|
36
|
+
* - `null` when `matchMedia` is unavailable, eg. in SSR.
|
|
37
|
+
*/
|
|
38
|
+
export const UNSAFE_useMediaQuery = (queryString, listener) => {
|
|
39
|
+
const listenerRef = useRef(listener);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
// Bind the listener if changed so it's called on the next change event; no guarantee on timing.
|
|
42
|
+
listenerRef.current = listener;
|
|
43
|
+
}, [listener]);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* We explicitly only react to boolean changes for binding our listener
|
|
47
|
+
* Changes to the functional reference are ignored.
|
|
48
|
+
*/
|
|
49
|
+
const hasListener = !!listener;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The `matchMedia(…)` return value for our breakpoint query.
|
|
53
|
+
*/
|
|
54
|
+
const mq = queries[queryString];
|
|
55
|
+
useLayoutEffect(() => {
|
|
56
|
+
listenerRef.current = listener; // Bind the listener now in case the `useEffect` hasn't fired above yet
|
|
57
|
+
if (!mq || !hasListener || !listenerRef.current) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return bind(mq, {
|
|
61
|
+
type: 'change',
|
|
62
|
+
listener: event => {
|
|
63
|
+
// We explicitly call the current version of the function
|
|
64
|
+
return listenerRef.current(event);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- explicitly do not trigger the effect on `listener` reference change, only on a boolean representation of it.
|
|
69
|
+
[mq, hasListener]);
|
|
70
|
+
return mq || null;
|
|
71
|
+
};
|
|
@@ -85,7 +85,7 @@ const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
85
85
|
action: 'clicked',
|
|
86
86
|
componentName: componentName || 'Pressable',
|
|
87
87
|
packageName: "@atlaskit/primitives",
|
|
88
|
-
packageVersion: "
|
|
88
|
+
packageVersion: "13.0.0",
|
|
89
89
|
analyticsData: analyticsContext,
|
|
90
90
|
actionSubject: 'button'
|
|
91
91
|
});
|
package/dist/es2019/index.js
CHANGED
|
@@ -13,5 +13,5 @@ export {
|
|
|
13
13
|
*/
|
|
14
14
|
default as UNSAFE_ANCHOR, default as Anchor } from './components/anchor';
|
|
15
15
|
export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
|
|
16
|
-
export { useSurface as UNSAFE_useSurface
|
|
16
|
+
export { useSurface as UNSAFE_useSurface } from './components/internal/surface-provider';
|
|
17
17
|
export { inverseColorMap as UNSAFE_inverseColorMap } from './xcss/style-maps.partial';
|
|
@@ -443,14 +443,15 @@ export const fillMap = {
|
|
|
443
443
|
|
|
444
444
|
/**
|
|
445
445
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
446
|
-
* @codegen <<SignedSource::
|
|
446
|
+
* @codegen <<SignedSource::042cbfe8041c09e3817ae74154994f32>>
|
|
447
447
|
* @codegenId misc
|
|
448
448
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
449
449
|
* @codegenParams ["layer"]
|
|
450
450
|
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/dimensions.tsx <<SignedSource::cc9b3f12104c6ede803da6a42daac0b0>>
|
|
451
|
-
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/layer.tsx <<SignedSource::
|
|
451
|
+
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/layer.tsx <<SignedSource::92793ca02dbfdad66e53ffbe9f0baa0a>>
|
|
452
452
|
*/
|
|
453
453
|
export const layerMap = {
|
|
454
|
+
'1': 1,
|
|
454
455
|
card: 100,
|
|
455
456
|
navigation: 200,
|
|
456
457
|
dialog: 300,
|
|
@@ -494,12 +495,12 @@ export const borderRadiusMap = {
|
|
|
494
495
|
|
|
495
496
|
/**
|
|
496
497
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
497
|
-
* @codegen <<SignedSource::
|
|
498
|
+
* @codegen <<SignedSource::96d9a841cb440c2bd770d0af5c670f10>>
|
|
498
499
|
* @codegenId typography
|
|
499
500
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
500
501
|
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
|
|
501
502
|
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/dimensions.tsx <<SignedSource::cc9b3f12104c6ede803da6a42daac0b0>>
|
|
502
|
-
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/layer.tsx <<SignedSource::
|
|
503
|
+
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/layer.tsx <<SignedSource::92793ca02dbfdad66e53ffbe9f0baa0a>>
|
|
503
504
|
*/
|
|
504
505
|
export const fontMap = {
|
|
505
506
|
'font.body': "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
@@ -534,11 +535,11 @@ export const fontFamilyMap = {
|
|
|
534
535
|
|
|
535
536
|
/**
|
|
536
537
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
537
|
-
* @codegen <<SignedSource::
|
|
538
|
+
* @codegen <<SignedSource::ae96213e36b930556f9ad18382088ff8>>
|
|
538
539
|
* @codegenId text
|
|
539
540
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
540
541
|
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/dimensions.tsx <<SignedSource::cc9b3f12104c6ede803da6a42daac0b0>>
|
|
541
|
-
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/layer.tsx <<SignedSource::
|
|
542
|
+
* @codegenDependency ../../../primitives/scripts/codegen-file-templates/layer.tsx <<SignedSource::92793ca02dbfdad66e53ffbe9f0baa0a>>
|
|
542
543
|
*/
|
|
543
544
|
export const textSizeMap = {
|
|
544
545
|
medium: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
._1hms8stv{text-decoration-line:underline}
|
|
3
|
+
._4bfu18uv{text-decoration-color:initial}
|
|
4
|
+
._ajmmnqa1{text-decoration-style:solid}
|
|
5
|
+
._vchhusvi{box-sizing:border-box}
|
|
6
|
+
._ymio1r31:focus:not(:focus-visible){outline-color:currentColor}
|
|
7
|
+
._ypr0glyw:focus:not(:focus-visible){outline-style:none}
|
|
8
|
+
._zcxs1o36:focus:not(:focus-visible){outline-width:medium}._1bg4v77o:focus, ._1ah3v77o:focus-visible{outline-offset:var(--ds-space-025,2px)}
|
|
9
|
+
._1hvw1bk5:focus, ._128m1bk5:focus-visible{outline-width:var(--ds-border-width-outline,2px)}
|
|
10
|
+
._49pcnqa1:focus, ._ra3xnqa1:focus-visible{outline-style:solid}
|
|
11
|
+
._nt751p6i:focus, ._mizu1p6i:focus-visible{outline-color:var(--ds-border-focused,#388bff)}
|
|
12
|
+
@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){._qa7m1r31:focus-visible{outline-color:currentColor}._1cvmnqa1:focus-visible{outline-style:solid}._4davt94y:focus-visible{outline-width:1px}}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* anchor.tsx generated by @compiled/babel-plugin v0.32.2 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["href", "children", "onClick", "interactionName", "componentName", "analyticsContext", "aria-label", "aria-labelledby", "style", "target", "testId", "xcss", "opensInNewWindowLabel"],
|
|
6
|
+
_excluded2 = ["className"];
|
|
7
|
+
import "./anchor.compiled.css";
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
10
|
+
import { forwardRef, useCallback, useContext } from 'react';
|
|
11
|
+
import invariant from 'tiny-invariant';
|
|
12
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
13
|
+
import { useRouterLink } from '@atlaskit/app-provider';
|
|
14
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
15
|
+
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
16
|
+
import InteractionContext from '@atlaskit/interaction-context';
|
|
17
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
18
|
+
var styles = {
|
|
19
|
+
root: "_vchhusvi _4bfu18uv _1hms8stv _ajmmnqa1",
|
|
20
|
+
focusRing: "_ymio1r31 _ypr0glyw _zcxs1o36 _nt751p6i _mizu1p6i _1bg4v77o _1ah3v77o _49pcnqa1 _ra3xnqa1 _1hvw1bk5 _128m1bk5 _qa7m1r31 _1cvmnqa1 _4davt94y"
|
|
21
|
+
};
|
|
22
|
+
var IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
|
|
23
|
+
var IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* __Anchor__
|
|
27
|
+
*
|
|
28
|
+
* A primitive for building custom anchor links.
|
|
29
|
+
*
|
|
30
|
+
* - [Examples](https://atlassian.design/components/primitives/anchor/examples)
|
|
31
|
+
* - [Code](https://atlassian.design/components/primitives/anchor/code)
|
|
32
|
+
* - [Usage](https://atlassian.design/components/primitives/anchor/usage)
|
|
33
|
+
*/
|
|
34
|
+
var AnchorNoRef = function AnchorNoRef(_ref, ref) {
|
|
35
|
+
var href = _ref.href,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
_ref$onClick = _ref.onClick,
|
|
38
|
+
providedOnClick = _ref$onClick === void 0 ? noop : _ref$onClick,
|
|
39
|
+
interactionName = _ref.interactionName,
|
|
40
|
+
componentName = _ref.componentName,
|
|
41
|
+
analyticsContext = _ref.analyticsContext,
|
|
42
|
+
ariaLabel = _ref['aria-label'],
|
|
43
|
+
ariaLabelledBy = _ref['aria-labelledby'],
|
|
44
|
+
style = _ref.style,
|
|
45
|
+
target = _ref.target,
|
|
46
|
+
testId = _ref.testId,
|
|
47
|
+
xcss = _ref.xcss,
|
|
48
|
+
_ref$opensInNewWindow = _ref.opensInNewWindowLabel,
|
|
49
|
+
opensInNewWindowLabel = _ref$opensInNewWindow === void 0 ? '(opens new window)' : _ref$opensInNewWindow,
|
|
50
|
+
htmlAttributes = _objectWithoutProperties(_ref, _excluded);
|
|
51
|
+
var interactionContext = useContext(InteractionContext);
|
|
52
|
+
var handleClick = useCallback(function (e, analyticsEvent) {
|
|
53
|
+
interactionContext && interactionContext.tracePress(interactionName, e.timeStamp);
|
|
54
|
+
providedOnClick(e, analyticsEvent);
|
|
55
|
+
}, [providedOnClick, interactionContext, interactionName]);
|
|
56
|
+
var opensNewWindowLabelId = useId();
|
|
57
|
+
var onClick = usePlatformLeafEventHandler({
|
|
58
|
+
fn: handleClick,
|
|
59
|
+
action: 'clicked',
|
|
60
|
+
componentName: componentName || 'Anchor',
|
|
61
|
+
packageName: "@atlaskit/primitives",
|
|
62
|
+
packageVersion: "13.0.0",
|
|
63
|
+
analyticsData: analyticsContext,
|
|
64
|
+
actionSubject: 'link'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// This is to remove className from safeHtmlAttributes
|
|
68
|
+
// @ts-expect-error className doesn't exist in the prop definition but we want to ensure it cannot be applied even if types are bypassed
|
|
69
|
+
var _spreadClass = htmlAttributes.className,
|
|
70
|
+
safeHtmlAttributes = _objectWithoutProperties(htmlAttributes, _excluded2);
|
|
71
|
+
var RouterLink = useRouterLink();
|
|
72
|
+
var isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
|
|
73
|
+
var isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Renders a router link if:
|
|
77
|
+
*
|
|
78
|
+
* - a link component is set in the app provider
|
|
79
|
+
* - it's not an external link (starting with `http://` or `https://`)
|
|
80
|
+
* - it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.).
|
|
81
|
+
*/
|
|
82
|
+
var isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
|
|
83
|
+
var hrefObjectUsedWithoutRouterLink = RouterLink === undefined && _typeof(href) === 'object';
|
|
84
|
+
invariant(!hrefObjectUsedWithoutRouterLink, "@atlaskit/primitives: Anchor primitive cannot pass an object to 'href' unless a router link is configured in the AppProvider");
|
|
85
|
+
var Component = isRouterLink ? RouterLink : 'a';
|
|
86
|
+
return /*#__PURE__*/React.createElement(Component
|
|
87
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- TODO: Allow pass-through from `props.xcss`
|
|
88
|
+
, _extends({
|
|
89
|
+
className: ax([styles.root, styles.focusRing, xcss])
|
|
90
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- TODO: Properly type this and allow pass-through if we can determine the type
|
|
91
|
+
,
|
|
92
|
+
style: style,
|
|
93
|
+
ref: ref
|
|
94
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
95
|
+
}, safeHtmlAttributes, {
|
|
96
|
+
// @ts-expect-error
|
|
97
|
+
href: !isRouterLink && typeof href !== 'string' ? undefined : href,
|
|
98
|
+
target: target,
|
|
99
|
+
onClick: onClick,
|
|
100
|
+
"aria-label": ariaLabel && target === '_blank' && !ariaLabelledBy ? "".concat(ariaLabel, " ").concat(opensInNewWindowLabel) : ariaLabel,
|
|
101
|
+
"aria-labelledby": ariaLabelledBy && target === '_blank' ? "".concat(ariaLabelledBy, " ").concat(opensNewWindowLabelId) : ariaLabelledBy,
|
|
102
|
+
"data-testid": testId,
|
|
103
|
+
"data-is-router-link": testId ? isRouterLink ? 'true' : 'false' : undefined
|
|
104
|
+
}), children, target === '_blank' && (children && !ariaLabel && !ariaLabelledBy || ariaLabelledBy) && /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
105
|
+
id: opensNewWindowLabelId
|
|
106
|
+
}, opensInNewWindowLabel));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Workarounds to support generic types with forwardRef
|
|
110
|
+
/**
|
|
111
|
+
* __Anchor__
|
|
112
|
+
*
|
|
113
|
+
* 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.
|
|
114
|
+
*
|
|
115
|
+
* - [Examples](https://atlassian.design/components/primitives/anchor/examples)
|
|
116
|
+
* - [Code](https://atlassian.design/components/primitives/anchor/code)
|
|
117
|
+
* - [Usage](https://atlassian.design/components/primitives/anchor/usage)
|
|
118
|
+
*/
|
|
119
|
+
var Anchor = /*#__PURE__*/forwardRef(AnchorNoRef);
|
|
120
|
+
export default Anchor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
._195g1e8l{margin-inline:var(--ds-space-negative-200,-1rem)}
|
|
2
|
+
._195g4pxn{margin-inline:var(--ds-space-negative-025,-.125rem)}
|
|
3
|
+
._195ggp71{margin-inline:var(--ds-space-negative-050,-.25rem)}
|
|
4
|
+
._195gkqjj{margin-inline:var(--ds-space-negative-150,-.75rem)}
|
|
5
|
+
._195gtdkl{margin-inline:var(--ds-space-negative-100,-.5rem)}
|
|
6
|
+
._1mou1e8l{margin-block:var(--ds-space-negative-200,-1rem)}
|
|
7
|
+
._1mou4pxn{margin-block:var(--ds-space-negative-025,-.125rem)}
|
|
8
|
+
._1mougp71{margin-block:var(--ds-space-negative-050,-.25rem)}
|
|
9
|
+
._1moukqjj{margin-block:var(--ds-space-negative-150,-.75rem)}
|
|
10
|
+
._1moutdkl{margin-block:var(--ds-space-negative-100,-.5rem)}
|
|
11
|
+
._vchhusvi{box-sizing:border-box}
|