@atlaskit/primitives 1.18.0 → 1.19.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 +10 -0
- package/dist/cjs/components/text.js +17 -10
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/xcss/xcss.js +2 -2
- package/dist/es2019/components/text.js +17 -10
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/xcss/xcss.js +1 -1
- package/dist/esm/components/text.js +17 -10
- package/dist/esm/index.js +1 -1
- package/dist/esm/xcss/xcss.js +1 -1
- package/dist/types/components/text.d.ts +5 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/responsive/index.d.ts +1 -1
- package/dist/types/xcss/xcss.d.ts +1622 -0
- package/dist/types-ts4.5/components/text.d.ts +5 -3
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/responsive/index.d.ts +1 -1
- package/dist/types-ts4.5/xcss/xcss.d.ts +1622 -0
- package/package.json +1 -1
- package/extract-react-types/text-props.tsx +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#66702](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66702) [`5b6bbaf2d5fc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5b6bbaf2d5fc) - Added `maxLines` prop to `Text` component, allowing truncation at a certain number of lines. This prop replaces `shouldTruncate` prop.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#67698](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67698) [`175c07b58c52`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/175c07b58c52) - Export tokensMap object
|
|
12
|
+
|
|
3
13
|
## 1.18.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -40,11 +40,16 @@ var textAlignMap = {
|
|
|
40
40
|
textAlign: 'start'
|
|
41
41
|
})
|
|
42
42
|
};
|
|
43
|
-
var
|
|
43
|
+
var truncationStyles = (0, _react2.css)({
|
|
44
|
+
display: '-webkit-box',
|
|
44
45
|
overflow: 'hidden',
|
|
45
|
-
|
|
46
|
-
whiteSpace: 'nowrap'
|
|
46
|
+
WebkitBoxOrient: 'vertical'
|
|
47
47
|
});
|
|
48
|
+
var wordBreakMap = {
|
|
49
|
+
breakAll: (0, _react2.css)({
|
|
50
|
+
wordBreak: 'break-all'
|
|
51
|
+
})
|
|
52
|
+
};
|
|
48
53
|
|
|
49
54
|
/**
|
|
50
55
|
* 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.
|
|
@@ -93,14 +98,13 @@ var Text = function Text(_ref) {
|
|
|
93
98
|
Component = 'span';
|
|
94
99
|
}
|
|
95
100
|
}
|
|
101
|
+
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
96
102
|
|
|
97
|
-
// Remove the ability to bypass typescript errors for
|
|
98
|
-
var
|
|
99
|
-
if ('
|
|
100
|
-
|
|
101
|
-
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
103
|
+
// Remove the ability to bypass typescript errors for maxLines
|
|
104
|
+
var maxLines;
|
|
105
|
+
if ('maxLines' in props && variant.includes('body')) {
|
|
106
|
+
maxLines = props.maxLines;
|
|
102
107
|
}
|
|
103
|
-
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
104
108
|
var color = useColor(colorProp);
|
|
105
109
|
var isWrapped = useHasTextAncestor();
|
|
106
110
|
|
|
@@ -112,7 +116,10 @@ var Text = function Text(_ref) {
|
|
|
112
116
|
return (0, _react2.jsx)(_react.Fragment, null, children);
|
|
113
117
|
}
|
|
114
118
|
var component = (0, _react2.jsx)(Component, {
|
|
115
|
-
css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color],
|
|
119
|
+
css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
120
|
+
style: {
|
|
121
|
+
WebkitLineClamp: maxLines
|
|
122
|
+
},
|
|
116
123
|
"data-testid": testId,
|
|
117
124
|
id: id
|
|
118
125
|
}, children);
|
package/dist/cjs/index.js
CHANGED
|
@@ -64,6 +64,12 @@ Object.defineProperty(exports, "media", {
|
|
|
64
64
|
return _responsive.media;
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
+
Object.defineProperty(exports, "tokensMap", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function get() {
|
|
70
|
+
return _xcss.tokensMap;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
67
73
|
Object.defineProperty(exports, "xcss", {
|
|
68
74
|
enumerable: true,
|
|
69
75
|
get: function get() {
|
package/dist/cjs/xcss/xcss.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.parseXcss = void 0;
|
|
7
|
+
exports.tokensMap = exports.parseXcss = void 0;
|
|
8
8
|
exports.xcss = xcss;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -15,7 +15,7 @@ var _styleMaps = require("./style-maps.partial");
|
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
17
17
|
|
|
18
|
-
var tokensMap = {
|
|
18
|
+
var tokensMap = exports.tokensMap = {
|
|
19
19
|
backgroundColor: _styleMaps.backgroundColorMap,
|
|
20
20
|
blockSize: _styleMaps.dimensionMap,
|
|
21
21
|
borderBlockColor: _styleMaps.borderColorMap,
|
|
@@ -32,11 +32,16 @@ const textAlignMap = {
|
|
|
32
32
|
textAlign: 'start'
|
|
33
33
|
})
|
|
34
34
|
};
|
|
35
|
-
const
|
|
35
|
+
const truncationStyles = css({
|
|
36
|
+
display: '-webkit-box',
|
|
36
37
|
overflow: 'hidden',
|
|
37
|
-
|
|
38
|
-
whiteSpace: 'nowrap'
|
|
38
|
+
WebkitBoxOrient: 'vertical'
|
|
39
39
|
});
|
|
40
|
+
const wordBreakMap = {
|
|
41
|
+
breakAll: css({
|
|
42
|
+
wordBreak: 'break-all'
|
|
43
|
+
})
|
|
44
|
+
};
|
|
40
45
|
|
|
41
46
|
/**
|
|
42
47
|
* 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.
|
|
@@ -85,14 +90,13 @@ const Text = ({
|
|
|
85
90
|
Component = 'span';
|
|
86
91
|
}
|
|
87
92
|
}
|
|
93
|
+
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
88
94
|
|
|
89
|
-
// Remove the ability to bypass typescript errors for
|
|
90
|
-
let
|
|
91
|
-
if ('
|
|
92
|
-
|
|
93
|
-
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
95
|
+
// Remove the ability to bypass typescript errors for maxLines
|
|
96
|
+
let maxLines;
|
|
97
|
+
if ('maxLines' in props && variant.includes('body')) {
|
|
98
|
+
maxLines = props.maxLines;
|
|
94
99
|
}
|
|
95
|
-
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
96
100
|
const color = useColor(colorProp);
|
|
97
101
|
const isWrapped = useHasTextAncestor();
|
|
98
102
|
|
|
@@ -104,7 +108,10 @@ const Text = ({
|
|
|
104
108
|
return jsx(Fragment, null, children);
|
|
105
109
|
}
|
|
106
110
|
const component = jsx(Component, {
|
|
107
|
-
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color],
|
|
111
|
+
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
112
|
+
style: {
|
|
113
|
+
WebkitLineClamp: maxLines
|
|
114
|
+
},
|
|
108
115
|
"data-testid": testId,
|
|
109
116
|
id: id
|
|
110
117
|
}, children);
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as Box } from './components/box';
|
|
2
2
|
export { default as Inline } from './components/inline';
|
|
3
|
-
export { xcss } from './xcss/xcss';
|
|
3
|
+
export { xcss, tokensMap } from './xcss/xcss';
|
|
4
4
|
export { default as Stack } from './components/stack';
|
|
5
5
|
export { default as Flex } from './components/flex';
|
|
6
6
|
export { default as Grid } from './components/grid';
|
package/dist/es2019/xcss/xcss.js
CHANGED
|
@@ -4,7 +4,7 @@ import { css as cssEmotion } from '@emotion/react';
|
|
|
4
4
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
5
|
|
|
6
6
|
import { allSpaceMap, backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, opacityMap, positiveSpaceMap, shadowMap, textColorMap } from './style-maps.partial';
|
|
7
|
-
const tokensMap = {
|
|
7
|
+
export const tokensMap = {
|
|
8
8
|
backgroundColor: backgroundColorMap,
|
|
9
9
|
blockSize: dimensionMap,
|
|
10
10
|
borderBlockColor: borderColorMap,
|
|
@@ -34,11 +34,16 @@ var textAlignMap = {
|
|
|
34
34
|
textAlign: 'start'
|
|
35
35
|
})
|
|
36
36
|
};
|
|
37
|
-
var
|
|
37
|
+
var truncationStyles = css({
|
|
38
|
+
display: '-webkit-box',
|
|
38
39
|
overflow: 'hidden',
|
|
39
|
-
|
|
40
|
-
whiteSpace: 'nowrap'
|
|
40
|
+
WebkitBoxOrient: 'vertical'
|
|
41
41
|
});
|
|
42
|
+
var wordBreakMap = {
|
|
43
|
+
breakAll: css({
|
|
44
|
+
wordBreak: 'break-all'
|
|
45
|
+
})
|
|
46
|
+
};
|
|
42
47
|
|
|
43
48
|
/**
|
|
44
49
|
* 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.
|
|
@@ -87,14 +92,13 @@ var Text = function Text(_ref) {
|
|
|
87
92
|
Component = 'span';
|
|
88
93
|
}
|
|
89
94
|
}
|
|
95
|
+
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
90
96
|
|
|
91
|
-
// Remove the ability to bypass typescript errors for
|
|
92
|
-
var
|
|
93
|
-
if ('
|
|
94
|
-
|
|
95
|
-
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
97
|
+
// Remove the ability to bypass typescript errors for maxLines
|
|
98
|
+
var maxLines;
|
|
99
|
+
if ('maxLines' in props && variant.includes('body')) {
|
|
100
|
+
maxLines = props.maxLines;
|
|
96
101
|
}
|
|
97
|
-
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
98
102
|
var color = useColor(colorProp);
|
|
99
103
|
var isWrapped = useHasTextAncestor();
|
|
100
104
|
|
|
@@ -106,7 +110,10 @@ var Text = function Text(_ref) {
|
|
|
106
110
|
return jsx(Fragment, null, children);
|
|
107
111
|
}
|
|
108
112
|
var component = jsx(Component, {
|
|
109
|
-
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color],
|
|
113
|
+
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
114
|
+
style: {
|
|
115
|
+
WebkitLineClamp: maxLines
|
|
116
|
+
},
|
|
110
117
|
"data-testid": testId,
|
|
111
118
|
id: id
|
|
112
119
|
}, children);
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as Box } from './components/box';
|
|
2
2
|
export { default as Inline } from './components/inline';
|
|
3
|
-
export { xcss } from './xcss/xcss';
|
|
3
|
+
export { xcss, tokensMap } from './xcss/xcss';
|
|
4
4
|
export { default as Stack } from './components/stack';
|
|
5
5
|
export { default as Flex } from './components/flex';
|
|
6
6
|
export { default as Grid } from './components/grid';
|
package/dist/esm/xcss/xcss.js
CHANGED
|
@@ -7,7 +7,7 @@ import { css as cssEmotion } from '@emotion/react';
|
|
|
7
7
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
8
|
|
|
9
9
|
import { allSpaceMap, backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, opacityMap, positiveSpaceMap, shadowMap, textColorMap } from './style-maps.partial';
|
|
10
|
-
var tokensMap = {
|
|
10
|
+
export var tokensMap = {
|
|
11
11
|
backgroundColor: backgroundColorMap,
|
|
12
12
|
blockSize: dimensionMap,
|
|
13
13
|
borderBlockColor: borderColorMap,
|
|
@@ -10,18 +10,20 @@ type TextPropsBody = {
|
|
|
10
10
|
*/
|
|
11
11
|
variant?: BodyText;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* The number of lines to limit the provided text to. Text will be truncated with an ellipsis.
|
|
14
|
+
*
|
|
15
|
+
* When `maxLines={1}`, `wordBreak` defaults to `break-all` to match the behaviour of `text-overflow: ellipsis`.
|
|
15
16
|
*
|
|
16
17
|
* Only available for `body` text variants.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
maxLines?: number;
|
|
19
20
|
};
|
|
20
21
|
type TextPropsUi = {
|
|
21
22
|
/**
|
|
22
23
|
* Text variant
|
|
23
24
|
*/
|
|
24
25
|
variant: UiText;
|
|
26
|
+
maxLines?: never;
|
|
25
27
|
};
|
|
26
28
|
type TextPropsBase = {
|
|
27
29
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { default as Box } from './components/box';
|
|
|
3
3
|
export type { BoxProps } from './components/box';
|
|
4
4
|
export { default as Inline } from './components/inline';
|
|
5
5
|
export type { InlineProps } from './components/inline';
|
|
6
|
-
export { xcss } from './xcss/xcss';
|
|
6
|
+
export { xcss, tokensMap } from './xcss/xcss';
|
|
7
7
|
export type { XCSS } from './xcss/xcss';
|
|
8
8
|
export { default as Stack } from './components/stack';
|
|
9
9
|
export type { StackProps } from './components/stack';
|
|
@@ -16,4 +16,4 @@ export type { BleedProps } from './components/bleed';
|
|
|
16
16
|
export { default as Text } from './components/text';
|
|
17
17
|
export type { TextProps } from './components/text';
|
|
18
18
|
export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
|
|
19
|
-
export type { Breakpoint } from './responsive';
|
|
19
|
+
export type { Breakpoint, MediaQuery } from './responsive';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { media, UNSAFE_media } from './media-helper';
|
|
2
2
|
export { UNSAFE_buildAboveMediaQueryCSS } from './build-media-query-css';
|
|
3
3
|
export { UNSAFE_BREAKPOINTS_ORDERED_LIST, UNSAFE_BREAKPOINTS_CONFIG, } from './constants';
|
|
4
|
-
export type { Breakpoint, ResponsiveObject, ResponsiveCSSObject, } from './types';
|
|
4
|
+
export type { Breakpoint, ResponsiveObject, ResponsiveCSSObject, MediaQuery, } from './types';
|
|
5
5
|
export { UNSAFE_useMediaQuery } from './use-media-query';
|
|
6
6
|
export { Show } from './show';
|
|
7
7
|
export { Hide } from './hide';
|