@atlaskit/primitives 2.1.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/anchor/package.json +15 -0
  3. package/constellation/anchor/code.mdx +21 -0
  4. package/constellation/anchor/examples.mdx +33 -0
  5. package/constellation/anchor/usage.mdx +47 -0
  6. package/constellation/box/examples.mdx +5 -3
  7. package/constellation/pressable/code.mdx +21 -0
  8. package/constellation/pressable/examples.mdx +39 -0
  9. package/constellation/pressable/usage.mdx +23 -0
  10. package/constellation/text/examples.mdx +16 -9
  11. package/constellation/xcss/examples.mdx +1 -1
  12. package/dist/cjs/components/{link.js → anchor.js} +16 -17
  13. package/dist/cjs/components/pressable.js +3 -7
  14. package/dist/cjs/components/text.js +37 -21
  15. package/dist/cjs/index.js +8 -1
  16. package/dist/es2019/components/{link.js → anchor.js} +16 -17
  17. package/dist/es2019/components/pressable.js +3 -7
  18. package/dist/es2019/components/text.js +25 -13
  19. package/dist/es2019/index.js +2 -1
  20. package/dist/esm/components/{link.js → anchor.js} +16 -17
  21. package/dist/esm/components/pressable.js +3 -7
  22. package/dist/esm/components/text.js +28 -13
  23. package/dist/esm/index.js +2 -1
  24. package/dist/{types-ts4.5/components/link.d.ts → types/components/anchor.d.ts} +12 -12
  25. package/dist/types/components/pressable.d.ts +2 -2
  26. package/dist/types/components/text.d.ts +3 -3
  27. package/dist/types/index.d.ts +3 -1
  28. package/dist/{types/components/link.d.ts → types-ts4.5/components/anchor.d.ts} +12 -12
  29. package/dist/types-ts4.5/components/pressable.d.ts +2 -2
  30. package/dist/types-ts4.5/components/text.d.ts +3 -3
  31. package/dist/types-ts4.5/index.d.ts +3 -1
  32. package/extract-react-types/anchor-props.tsx +103 -0
  33. package/extract-react-types/pressable-props.tsx +94 -0
  34. package/package.json +20 -2
  35. package/link/package.json +0 -15
@@ -0,0 +1,103 @@
1
+ // TODO: Switch from ERT to ts-morph when this is completed and has reasonable adoption: https://product-fabric.atlassian.net/browse/DSP-10364
2
+ import React, { ReactNode } from 'react';
3
+
4
+ import { BasePrimitiveProps, StyleProp } from '../src/components/types';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-namespace
7
+ namespace Token {
8
+ // BoxProps['backgroundColor'] uses keyof, which ERT does not understand
9
+ export type BackgroundColor = 'BackgroundColor';
10
+ }
11
+
12
+ type Space =
13
+ | 'space.0'
14
+ | 'space.025'
15
+ | 'space.050'
16
+ | 'space.075'
17
+ | 'space.100'
18
+ | 'space.150'
19
+ | 'space.200'
20
+ | 'space.250'
21
+ | 'space.300'
22
+ | 'space.400'
23
+ | 'space.500'
24
+ | 'space.600'
25
+ | 'space.800'
26
+ | 'space.1000';
27
+
28
+ export default function Anchor<
29
+ RouterLinkConfig extends Record<string, any> = never,
30
+ >(
31
+ _: {
32
+ /**
33
+ * A link can be provided as a string. If a router link configuration is set
34
+ * it can be mapped to the underlying router link component,
35
+ * or optionally a custom object defined in the generic type for advanced use.
36
+ */
37
+ href: string | RouterLinkConfig;
38
+
39
+ /**
40
+ * The `target` attribute of the anchor HTML element. Defaults to `_blank` for external links.
41
+ */
42
+ target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
43
+
44
+ /**
45
+ * The `rel` attribute of the anchor HTML element. Defaults to `noopener noreferrer` for external links.
46
+ */
47
+ rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
48
+
49
+ /**
50
+ * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
51
+ */
52
+ padding?: Space;
53
+
54
+ /**
55
+ * Tokens representing CSS shorthand `paddingBlock`.
56
+ */
57
+ paddingBlock?: Space;
58
+
59
+ /**
60
+ * Tokens representing CSS `paddingBlockStart`.
61
+ */
62
+ paddingBlockStart?: Space;
63
+
64
+ /**
65
+ * Tokens representing CSS `paddingBlockEnd`.
66
+ */
67
+ paddingBlockEnd?: Space;
68
+
69
+ /**
70
+ * Tokens representing CSS shorthand `paddingInline`.
71
+ */
72
+ paddingInline?: Space;
73
+
74
+ /**
75
+ * Tokens representing CSS `paddingInlineStart`.
76
+ */
77
+ paddingInlineStart?: Space;
78
+
79
+ /**
80
+ * Tokens representing CSS `paddingInlineEnd`.
81
+ */
82
+ paddingInlineEnd?: Space;
83
+
84
+ /**
85
+ * A token alias for background color. See:<br>
86
+ * [https://atlassian.design/components/tokens/all-tokens#color-background](https://atlassian.design/components/tokens/all-tokens#color-background)<br>
87
+ * When the background color is set to a [surface token](/components/tokens/all-tokens#elevation-surface),
88
+ * the [current surface](/components/tokens/code#current-surface-color) CSS variable will also be set to this value in the Box styles.
89
+ */
90
+ backgroundColor?: Token.BackgroundColor;
91
+
92
+ /**
93
+ * Elements to be rendered inside the primitive.
94
+ */
95
+ children: ReactNode;
96
+
97
+ /**
98
+ * Forwarded ref element.
99
+ */
100
+ ref?: React.ComponentPropsWithRef<'a'>['ref'];
101
+ } & BasePrimitiveProps &
102
+ StyleProp,
103
+ ) {}
@@ -0,0 +1,94 @@
1
+ // TODO: Switch from ERT to ts-morph when this is completed and has reasonable adoption: https://product-fabric.atlassian.net/browse/DSP-10364
2
+ import React, { ReactNode } from 'react';
3
+
4
+ import { BasePrimitiveProps, StyleProp } from '../src/components/types';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-namespace
7
+ namespace Token {
8
+ // BoxProps['backgroundColor'] uses keyof, which ERT does not understand
9
+ export type BackgroundColor = 'BackgroundColor';
10
+ }
11
+
12
+ type Space =
13
+ | 'space.0'
14
+ | 'space.025'
15
+ | 'space.050'
16
+ | 'space.075'
17
+ | 'space.100'
18
+ | 'space.150'
19
+ | 'space.200'
20
+ | 'space.250'
21
+ | 'space.300'
22
+ | 'space.400'
23
+ | 'space.500'
24
+ | 'space.600'
25
+ | 'space.800'
26
+ | 'space.1000';
27
+
28
+ export default function Pressable(
29
+ _: {
30
+ /**
31
+ * Controls whether the button is disabled.
32
+ */
33
+ isDisabled?: boolean;
34
+
35
+ /**
36
+ * The `type` attribute of the Button HTML element. Defaults to `button`.
37
+ */
38
+ type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
39
+
40
+ /**
41
+ * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
42
+ */
43
+ padding?: Space;
44
+
45
+ /**
46
+ * Tokens representing CSS shorthand `paddingBlock`.
47
+ */
48
+ paddingBlock?: Space;
49
+
50
+ /**
51
+ * Tokens representing CSS `paddingBlockStart`.
52
+ */
53
+ paddingBlockStart?: Space;
54
+
55
+ /**
56
+ * Tokens representing CSS `paddingBlockEnd`.
57
+ */
58
+ paddingBlockEnd?: Space;
59
+
60
+ /**
61
+ * Tokens representing CSS shorthand `paddingInline`.
62
+ */
63
+ paddingInline?: Space;
64
+
65
+ /**
66
+ * Tokens representing CSS `paddingInlineStart`.
67
+ */
68
+ paddingInlineStart?: Space;
69
+
70
+ /**
71
+ * Tokens representing CSS `paddingInlineEnd`.
72
+ */
73
+ paddingInlineEnd?: Space;
74
+
75
+ /**
76
+ * A token alias for background color. See:<br>
77
+ * [https://atlassian.design/components/tokens/all-tokens#color-background](https://atlassian.design/components/tokens/all-tokens#color-background)<br>
78
+ * When the background color is set to a [surface token](/components/tokens/all-tokens#elevation-surface),
79
+ * the [current surface](/components/tokens/code#current-surface-color) CSS variable will also be set to this value in the Box styles.
80
+ */
81
+ backgroundColor?: Token.BackgroundColor;
82
+
83
+ /**
84
+ * Elements to be rendered inside the primitive.
85
+ */
86
+ children: ReactNode;
87
+
88
+ /**
89
+ * Forwarded ref element.
90
+ */
91
+ ref?: React.ComponentPropsWithRef<'button'>['ref'];
92
+ } & BasePrimitiveProps &
93
+ StyleProp,
94
+ ) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "2.1.0",
3
+ "version": "3.1.0",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -96,6 +96,24 @@
96
96
  "status": {
97
97
  "type": "closed-beta"
98
98
  }
99
+ },
100
+ {
101
+ "title": "Pressable",
102
+ "folder": "pressable",
103
+ "slug": "primitives/pressable",
104
+ "id": "@atlaskit/primitives/pressable",
105
+ "status": {
106
+ "type": "alpha"
107
+ }
108
+ },
109
+ {
110
+ "title": "Anchor",
111
+ "folder": "anchor",
112
+ "slug": "primitives/anchor",
113
+ "id": "@atlaskit/primitives/anchor",
114
+ "status": {
115
+ "type": "alpha"
116
+ }
99
117
  }
100
118
  ]
101
119
  }
@@ -174,7 +192,7 @@
174
192
  "./inline": "./src/components/inline.tsx",
175
193
  "./text": "./src/components/text.tsx",
176
194
  "./pressable": "./src/components/pressable.tsx",
177
- "./link": "./src/components/link.tsx",
195
+ "./anchor": "./src/components/anchor.tsx",
178
196
  "./responsive": "./src/responsive/index.tsx"
179
197
  },
180
198
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
package/link/package.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "name": "@atlaskit/primitives/link",
3
- "main": "../dist/cjs/components/link.js",
4
- "module": "../dist/esm/components/link.js",
5
- "module:es2019": "../dist/es2019/components/link.js",
6
- "sideEffects": false,
7
- "types": "../dist/types/components/link.d.ts",
8
- "typesVersions": {
9
- ">=4.5 <4.9": {
10
- "*": [
11
- "../dist/types-ts4.5/components/link.d.ts"
12
- ]
13
- }
14
- }
15
- }