@atlaskit/primitives 1.16.0 → 1.17.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 +6 -0
- package/dist/cjs/components/text.js +8 -3
- package/dist/es2019/components/text.js +8 -2
- package/dist/esm/components/text.js +8 -3
- package/dist/types/components/text.d.ts +22 -12
- package/dist/types-ts4.5/components/text.d.ts +22 -12
- package/package.json +1 -1
- package/scripts/typography-codegen-template.tsx +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#65770](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65770) [`1e2db2714522`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1e2db2714522) - The `shouldTruncate` prop on `Text` is now only available for `body` variants and cannot be used with `ui` variants.
|
|
8
|
+
|
|
3
9
|
## 1.16.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -24,7 +24,7 @@ var resetStyles = (0, _react2.css)({
|
|
|
24
24
|
});
|
|
25
25
|
var variantStyles = _objectSpread(_objectSpread({}, _styleMaps.bodyTextStylesMap), _styleMaps.uiTextStylesMap);
|
|
26
26
|
var strongStyles = (0, _react2.css)({
|
|
27
|
-
fontWeight:
|
|
27
|
+
fontWeight: 'bold'
|
|
28
28
|
});
|
|
29
29
|
var emStyles = (0, _react2.css)({
|
|
30
30
|
fontStyle: 'italic'
|
|
@@ -79,8 +79,6 @@ var Text = function Text(_ref) {
|
|
|
79
79
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
80
80
|
var asElement = props.as,
|
|
81
81
|
colorProp = props.color,
|
|
82
|
-
_props$shouldTruncate = props.shouldTruncate,
|
|
83
|
-
shouldTruncate = _props$shouldTruncate === void 0 ? false : _props$shouldTruncate,
|
|
84
82
|
textAlign = props.textAlign,
|
|
85
83
|
testId = props.testId,
|
|
86
84
|
id = props.id,
|
|
@@ -95,6 +93,13 @@ var Text = function Text(_ref) {
|
|
|
95
93
|
Component = 'span';
|
|
96
94
|
}
|
|
97
95
|
}
|
|
96
|
+
|
|
97
|
+
// Remove the ability to bypass typescript errors for shouldTruncate
|
|
98
|
+
var shouldTruncate = false;
|
|
99
|
+
if ('shouldTruncate' in props && variant.includes('body')) {
|
|
100
|
+
var _props$shouldTruncate;
|
|
101
|
+
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
102
|
+
}
|
|
98
103
|
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
99
104
|
var color = useColor(colorProp);
|
|
100
105
|
var isWrapped = useHasTextAncestor();
|
|
@@ -16,7 +16,7 @@ const variantStyles = {
|
|
|
16
16
|
...uiTextStylesMap
|
|
17
17
|
};
|
|
18
18
|
const strongStyles = css({
|
|
19
|
-
fontWeight:
|
|
19
|
+
fontWeight: 'bold'
|
|
20
20
|
});
|
|
21
21
|
const emStyles = css({
|
|
22
22
|
fontStyle: 'italic'
|
|
@@ -71,7 +71,6 @@ const Text = ({
|
|
|
71
71
|
const {
|
|
72
72
|
as: asElement,
|
|
73
73
|
color: colorProp,
|
|
74
|
-
shouldTruncate = false,
|
|
75
74
|
textAlign,
|
|
76
75
|
testId,
|
|
77
76
|
id,
|
|
@@ -86,6 +85,13 @@ const Text = ({
|
|
|
86
85
|
Component = 'span';
|
|
87
86
|
}
|
|
88
87
|
}
|
|
88
|
+
|
|
89
|
+
// Remove the ability to bypass typescript errors for shouldTruncate
|
|
90
|
+
let shouldTruncate = false;
|
|
91
|
+
if ('shouldTruncate' in props && variant.includes('body')) {
|
|
92
|
+
var _props$shouldTruncate;
|
|
93
|
+
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
94
|
+
}
|
|
89
95
|
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
90
96
|
const color = useColor(colorProp);
|
|
91
97
|
const isWrapped = useHasTextAncestor();
|
|
@@ -18,7 +18,7 @@ var resetStyles = css({
|
|
|
18
18
|
});
|
|
19
19
|
var variantStyles = _objectSpread(_objectSpread({}, bodyTextStylesMap), uiTextStylesMap);
|
|
20
20
|
var strongStyles = css({
|
|
21
|
-
fontWeight:
|
|
21
|
+
fontWeight: 'bold'
|
|
22
22
|
});
|
|
23
23
|
var emStyles = css({
|
|
24
24
|
fontStyle: 'italic'
|
|
@@ -73,8 +73,6 @@ var Text = function Text(_ref) {
|
|
|
73
73
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
74
74
|
var asElement = props.as,
|
|
75
75
|
colorProp = props.color,
|
|
76
|
-
_props$shouldTruncate = props.shouldTruncate,
|
|
77
|
-
shouldTruncate = _props$shouldTruncate === void 0 ? false : _props$shouldTruncate,
|
|
78
76
|
textAlign = props.textAlign,
|
|
79
77
|
testId = props.testId,
|
|
80
78
|
id = props.id,
|
|
@@ -89,6 +87,13 @@ var Text = function Text(_ref) {
|
|
|
89
87
|
Component = 'span';
|
|
90
88
|
}
|
|
91
89
|
}
|
|
90
|
+
|
|
91
|
+
// Remove the ability to bypass typescript errors for shouldTruncate
|
|
92
|
+
var shouldTruncate = false;
|
|
93
|
+
if ('shouldTruncate' in props && variant.includes('body')) {
|
|
94
|
+
var _props$shouldTruncate;
|
|
95
|
+
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
96
|
+
}
|
|
92
97
|
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
93
98
|
var color = useColor(colorProp);
|
|
94
99
|
var isWrapped = useHasTextAncestor();
|
|
@@ -4,8 +4,26 @@ import { BodyText, TextColor, UiText } from '../xcss/style-maps.partial';
|
|
|
4
4
|
import type { BasePrimitiveProps } from './types';
|
|
5
5
|
declare const asAllowlist: readonly ["span", "p", "strong", "em"];
|
|
6
6
|
type AsElement = (typeof asAllowlist)[number];
|
|
7
|
-
type
|
|
8
|
-
|
|
7
|
+
type TextPropsBody = {
|
|
8
|
+
/**
|
|
9
|
+
* Text variant
|
|
10
|
+
*/
|
|
11
|
+
variant?: BodyText;
|
|
12
|
+
/**
|
|
13
|
+
* Truncates text with an ellipsis when text overflows its parent container
|
|
14
|
+
* (i.e. `width` has been set on parent that is shorter than text length).
|
|
15
|
+
*
|
|
16
|
+
* Only available for `body` text variants.
|
|
17
|
+
*/
|
|
18
|
+
shouldTruncate?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type TextPropsUi = {
|
|
21
|
+
/**
|
|
22
|
+
* Text variant
|
|
23
|
+
*/
|
|
24
|
+
variant: UiText;
|
|
25
|
+
};
|
|
26
|
+
type TextPropsBase = {
|
|
9
27
|
/**
|
|
10
28
|
* HTML tag to be rendered. Defaults to `span`.
|
|
11
29
|
*/
|
|
@@ -14,10 +32,6 @@ export interface TextProps extends Omit<BasePrimitiveProps, 'xcss'> {
|
|
|
14
32
|
* Elements rendered within the Text element
|
|
15
33
|
*/
|
|
16
34
|
children: ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* Text variant
|
|
19
|
-
*/
|
|
20
|
-
variant?: Variant;
|
|
21
35
|
/**
|
|
22
36
|
* Token representing text color with a built-in fallback value.
|
|
23
37
|
* Will apply inverse text color automatically if placed within a Box with backgroundColor.
|
|
@@ -28,16 +42,12 @@ export interface TextProps extends Omit<BasePrimitiveProps, 'xcss'> {
|
|
|
28
42
|
* The HTML id attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
|
|
29
43
|
*/
|
|
30
44
|
id?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Truncates text with an ellipsis when text overflows its parent container
|
|
33
|
-
* (i.e. `width` has been set on parent that is shorter than text length).
|
|
34
|
-
*/
|
|
35
|
-
shouldTruncate?: boolean;
|
|
36
45
|
/**
|
|
37
46
|
* Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
|
38
47
|
*/
|
|
39
48
|
textAlign?: TextAlign;
|
|
40
|
-
}
|
|
49
|
+
};
|
|
50
|
+
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
|
|
41
51
|
type TextAlign = keyof typeof textAlignMap;
|
|
42
52
|
declare const textAlignMap: {
|
|
43
53
|
center: import("@emotion/react").SerializedStyles;
|
|
@@ -9,8 +9,26 @@ declare const asAllowlist: readonly [
|
|
|
9
9
|
"em"
|
|
10
10
|
];
|
|
11
11
|
type AsElement = (typeof asAllowlist)[number];
|
|
12
|
-
type
|
|
13
|
-
|
|
12
|
+
type TextPropsBody = {
|
|
13
|
+
/**
|
|
14
|
+
* Text variant
|
|
15
|
+
*/
|
|
16
|
+
variant?: BodyText;
|
|
17
|
+
/**
|
|
18
|
+
* Truncates text with an ellipsis when text overflows its parent container
|
|
19
|
+
* (i.e. `width` has been set on parent that is shorter than text length).
|
|
20
|
+
*
|
|
21
|
+
* Only available for `body` text variants.
|
|
22
|
+
*/
|
|
23
|
+
shouldTruncate?: boolean;
|
|
24
|
+
};
|
|
25
|
+
type TextPropsUi = {
|
|
26
|
+
/**
|
|
27
|
+
* Text variant
|
|
28
|
+
*/
|
|
29
|
+
variant: UiText;
|
|
30
|
+
};
|
|
31
|
+
type TextPropsBase = {
|
|
14
32
|
/**
|
|
15
33
|
* HTML tag to be rendered. Defaults to `span`.
|
|
16
34
|
*/
|
|
@@ -19,10 +37,6 @@ export interface TextProps extends Omit<BasePrimitiveProps, 'xcss'> {
|
|
|
19
37
|
* Elements rendered within the Text element
|
|
20
38
|
*/
|
|
21
39
|
children: ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* Text variant
|
|
24
|
-
*/
|
|
25
|
-
variant?: Variant;
|
|
26
40
|
/**
|
|
27
41
|
* Token representing text color with a built-in fallback value.
|
|
28
42
|
* Will apply inverse text color automatically if placed within a Box with backgroundColor.
|
|
@@ -33,16 +47,12 @@ export interface TextProps extends Omit<BasePrimitiveProps, 'xcss'> {
|
|
|
33
47
|
* The HTML id attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
|
|
34
48
|
*/
|
|
35
49
|
id?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Truncates text with an ellipsis when text overflows its parent container
|
|
38
|
-
* (i.e. `width` has been set on parent that is shorter than text length).
|
|
39
|
-
*/
|
|
40
|
-
shouldTruncate?: boolean;
|
|
41
50
|
/**
|
|
42
51
|
* Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
|
43
52
|
*/
|
|
44
53
|
textAlign?: TextAlign;
|
|
45
|
-
}
|
|
54
|
+
};
|
|
55
|
+
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
|
|
46
56
|
type TextAlign = keyof typeof textAlignMap;
|
|
47
57
|
declare const textAlignMap: {
|
|
48
58
|
center: import("@emotion/react").SerializedStyles;
|
package/package.json
CHANGED
|
@@ -81,19 +81,19 @@ export const createTypographyStylesFromTemplate = (
|
|
|
81
81
|
prettier.format(
|
|
82
82
|
`
|
|
83
83
|
export const ${objectName}Map = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
${activeTokens
|
|
85
|
+
.filter(filterFn)
|
|
86
|
+
.map(t => ({ ...t, name: t.name.replace(/\.\[default\]/g, '') }))
|
|
87
|
+
.sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
88
|
+
.map(token => {
|
|
89
|
+
return `
|
|
90
|
+
'${removeVerbosity(token.name)}': ${constructTokenFunctionCall(
|
|
91
|
+
token.name,
|
|
92
|
+
token.fallback,
|
|
93
|
+
)}
|
|
94
|
+
`.trim();
|
|
95
|
+
})
|
|
96
|
+
.join(',\n\t')}
|
|
97
97
|
};`,
|
|
98
98
|
{
|
|
99
99
|
singleQuote: true,
|