@atlaskit/primitives 1.18.0 → 1.20.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 +21 -0
- package/dist/cjs/components/text.js +25 -21
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/xcss/style-maps.partial.js +6 -6
- package/dist/cjs/xcss/xcss.js +2 -2
- package/dist/es2019/components/text.js +25 -22
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +6 -6
- package/dist/es2019/xcss/xcss.js +1 -1
- package/dist/esm/components/text.js +26 -22
- package/dist/esm/index.js +1 -1
- package/dist/esm/xcss/style-maps.partial.js +6 -6
- package/dist/esm/xcss/xcss.js +1 -1
- package/dist/types/components/text.d.ts +10 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/types/responsive/index.d.ts +1 -1
- package/dist/types/xcss/style-maps.partial.d.ts +5 -5
- package/dist/types/xcss/xcss.d.ts +1622 -0
- package/dist/types-ts4.5/components/text.d.ts +10 -4
- 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/style-maps.partial.d.ts +5 -5
- package/dist/types-ts4.5/xcss/xcss.d.ts +1622 -0
- package/package.json +2 -2
- package/scripts/typography-codegen-template.tsx +9 -2
- package/extract-react-types/text-props.tsx +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#68163](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68163) [`67d09e3f972d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/67d09e3f972d) - `weight` property added to `Text` to allow overriding text variant default font weight.
|
|
8
|
+
- [#69343](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69343) [`77249f536425`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77249f536425) - `Text` color prop defaults to `color.text` if not provided.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 1.19.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [#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.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#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
|
|
23
|
+
|
|
3
24
|
## 1.18.0
|
|
4
25
|
|
|
5
26
|
### 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.
|
|
@@ -78,29 +83,25 @@ var Text = function Text(_ref) {
|
|
|
78
83
|
var children = _ref.children,
|
|
79
84
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
80
85
|
var asElement = props.as,
|
|
81
|
-
|
|
86
|
+
_props$color = props.color,
|
|
87
|
+
colorProp = _props$color === void 0 ? 'color.text' : _props$color,
|
|
82
88
|
textAlign = props.textAlign,
|
|
83
89
|
testId = props.testId,
|
|
84
90
|
id = props.id,
|
|
85
91
|
_props$variant = props.variant,
|
|
86
|
-
variant = _props$variant === void 0 ? 'body' : _props$variant
|
|
87
|
-
|
|
88
|
-
if (!Component) {
|
|
89
|
-
if (variant.includes('body')) {
|
|
90
|
-
Component = 'p';
|
|
91
|
-
} else {
|
|
92
|
-
// ui text and default => span
|
|
93
|
-
Component = 'span';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
92
|
+
variant = _props$variant === void 0 ? 'body' : _props$variant,
|
|
93
|
+
weight = props.weight;
|
|
96
94
|
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var _props$shouldTruncate;
|
|
101
|
-
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
102
|
-
}
|
|
95
|
+
// body variants -> p
|
|
96
|
+
// ui variants -> span
|
|
97
|
+
var Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
103
98
|
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
99
|
+
|
|
100
|
+
// Remove the ability to bypass typescript errors for maxLines
|
|
101
|
+
var maxLines;
|
|
102
|
+
if ('maxLines' in props && variant.includes('body')) {
|
|
103
|
+
maxLines = props.maxLines;
|
|
104
|
+
}
|
|
104
105
|
var color = useColor(colorProp);
|
|
105
106
|
var isWrapped = useHasTextAncestor();
|
|
106
107
|
|
|
@@ -112,7 +113,10 @@ var Text = function Text(_ref) {
|
|
|
112
113
|
return (0, _react2.jsx)(_react.Fragment, null, children);
|
|
113
114
|
}
|
|
114
115
|
var component = (0, _react2.jsx)(Component, {
|
|
115
|
-
css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color],
|
|
116
|
+
css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && _styleMaps.fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
117
|
+
style: {
|
|
118
|
+
WebkitLineClamp: maxLines
|
|
119
|
+
},
|
|
116
120
|
"data-testid": testId,
|
|
117
121
|
id: id
|
|
118
122
|
}, 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() {
|
|
@@ -496,7 +496,7 @@ var borderRadiusMap = exports.borderRadiusMap = {
|
|
|
496
496
|
|
|
497
497
|
/**
|
|
498
498
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
499
|
-
* @codegen <<SignedSource::
|
|
499
|
+
* @codegen <<SignedSource::402816562c359603300fda81596a2978>>
|
|
500
500
|
* @codegenId typography
|
|
501
501
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
502
502
|
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
|
|
@@ -514,10 +514,10 @@ var fontSizeMap = exports.fontSizeMap = {
|
|
|
514
514
|
'font.size.600': "var(--ds-font-size-600, 35px)"
|
|
515
515
|
};
|
|
516
516
|
var fontWeightMap = exports.fontWeightMap = {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
517
|
+
bold: "var(--ds-font-weight-bold, 700)",
|
|
518
|
+
medium: "var(--ds-font-weight-medium, 500)",
|
|
519
|
+
regular: "var(--ds-font-weight-regular, 400)",
|
|
520
|
+
semibold: "var(--ds-font-weight-semibold, 600)"
|
|
521
521
|
};
|
|
522
522
|
var fontFamilyMap = exports.fontFamilyMap = {
|
|
523
523
|
'font.family.body': "var(--ds-font-family-body, ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
@@ -542,7 +542,7 @@ var bodyTextMap = exports.bodyTextMap = {
|
|
|
542
542
|
'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
543
543
|
};
|
|
544
544
|
var uiTextMap = exports.uiTextMap = {
|
|
545
|
-
ui: "var(--ds-font-ui, normal
|
|
545
|
+
ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
546
546
|
'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
547
547
|
};
|
|
548
548
|
|
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,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createContext, Fragment, useContext } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import invariant from 'tiny-invariant';
|
|
5
|
-
import { bodyTextStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
5
|
+
import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
6
6
|
import { useSurface } from './internal/surface-provider';
|
|
7
7
|
const asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
8
8
|
// We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
|
|
@@ -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.
|
|
@@ -70,29 +75,24 @@ const Text = ({
|
|
|
70
75
|
}) => {
|
|
71
76
|
const {
|
|
72
77
|
as: asElement,
|
|
73
|
-
color: colorProp,
|
|
78
|
+
color: colorProp = 'color.text',
|
|
74
79
|
textAlign,
|
|
75
80
|
testId,
|
|
76
81
|
id,
|
|
77
|
-
variant = 'body'
|
|
82
|
+
variant = 'body',
|
|
83
|
+
weight
|
|
78
84
|
} = props;
|
|
79
|
-
let Component = asElement;
|
|
80
|
-
if (!Component) {
|
|
81
|
-
if (variant.includes('body')) {
|
|
82
|
-
Component = 'p';
|
|
83
|
-
} else {
|
|
84
|
-
// ui text and default => span
|
|
85
|
-
Component = 'span';
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
85
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var _props$shouldTruncate;
|
|
93
|
-
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
94
|
-
}
|
|
86
|
+
// body variants -> p
|
|
87
|
+
// ui variants -> span
|
|
88
|
+
const Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
95
89
|
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
90
|
+
|
|
91
|
+
// Remove the ability to bypass typescript errors for maxLines
|
|
92
|
+
let maxLines;
|
|
93
|
+
if ('maxLines' in props && variant.includes('body')) {
|
|
94
|
+
maxLines = props.maxLines;
|
|
95
|
+
}
|
|
96
96
|
const color = useColor(colorProp);
|
|
97
97
|
const isWrapped = useHasTextAncestor();
|
|
98
98
|
|
|
@@ -104,7 +104,10 @@ const Text = ({
|
|
|
104
104
|
return jsx(Fragment, null, children);
|
|
105
105
|
}
|
|
106
106
|
const component = jsx(Component, {
|
|
107
|
-
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color],
|
|
107
|
+
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
108
|
+
style: {
|
|
109
|
+
WebkitLineClamp: maxLines
|
|
110
|
+
},
|
|
108
111
|
"data-testid": testId,
|
|
109
112
|
id: id
|
|
110
113
|
}, 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';
|
|
@@ -484,7 +484,7 @@ export const borderRadiusMap = {
|
|
|
484
484
|
*/
|
|
485
485
|
/**
|
|
486
486
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
487
|
-
* @codegen <<SignedSource::
|
|
487
|
+
* @codegen <<SignedSource::402816562c359603300fda81596a2978>>
|
|
488
488
|
* @codegenId typography
|
|
489
489
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
490
490
|
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
|
|
@@ -502,10 +502,10 @@ export const fontSizeMap = {
|
|
|
502
502
|
'font.size.600': "var(--ds-font-size-600, 35px)"
|
|
503
503
|
};
|
|
504
504
|
export const fontWeightMap = {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
505
|
+
bold: "var(--ds-font-weight-bold, 700)",
|
|
506
|
+
medium: "var(--ds-font-weight-medium, 500)",
|
|
507
|
+
regular: "var(--ds-font-weight-regular, 400)",
|
|
508
|
+
semibold: "var(--ds-font-weight-semibold, 600)"
|
|
509
509
|
};
|
|
510
510
|
export const fontFamilyMap = {
|
|
511
511
|
'font.family.body': "var(--ds-font-family-body, ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
@@ -530,7 +530,7 @@ export const bodyTextMap = {
|
|
|
530
530
|
'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
531
531
|
};
|
|
532
532
|
export const uiTextMap = {
|
|
533
|
-
ui: "var(--ds-font-ui, normal
|
|
533
|
+
ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
534
534
|
'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
535
535
|
};
|
|
536
536
|
|
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,
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { createContext, Fragment, useContext } from 'react';
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import invariant from 'tiny-invariant';
|
|
10
|
-
import { bodyTextStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
10
|
+
import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
11
11
|
import { useSurface } from './internal/surface-provider';
|
|
12
12
|
var asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
13
13
|
// We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
|
|
@@ -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.
|
|
@@ -72,29 +77,25 @@ var Text = function Text(_ref) {
|
|
|
72
77
|
var children = _ref.children,
|
|
73
78
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
74
79
|
var asElement = props.as,
|
|
75
|
-
|
|
80
|
+
_props$color = props.color,
|
|
81
|
+
colorProp = _props$color === void 0 ? 'color.text' : _props$color,
|
|
76
82
|
textAlign = props.textAlign,
|
|
77
83
|
testId = props.testId,
|
|
78
84
|
id = props.id,
|
|
79
85
|
_props$variant = props.variant,
|
|
80
|
-
variant = _props$variant === void 0 ? 'body' : _props$variant
|
|
81
|
-
|
|
82
|
-
if (!Component) {
|
|
83
|
-
if (variant.includes('body')) {
|
|
84
|
-
Component = 'p';
|
|
85
|
-
} else {
|
|
86
|
-
// ui text and default => span
|
|
87
|
-
Component = 'span';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
86
|
+
variant = _props$variant === void 0 ? 'body' : _props$variant,
|
|
87
|
+
weight = props.weight;
|
|
90
88
|
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var _props$shouldTruncate;
|
|
95
|
-
shouldTruncate = (_props$shouldTruncate = props.shouldTruncate) !== null && _props$shouldTruncate !== void 0 ? _props$shouldTruncate : false;
|
|
96
|
-
}
|
|
89
|
+
// body variants -> p
|
|
90
|
+
// ui variants -> span
|
|
91
|
+
var Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
97
92
|
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
93
|
+
|
|
94
|
+
// Remove the ability to bypass typescript errors for maxLines
|
|
95
|
+
var maxLines;
|
|
96
|
+
if ('maxLines' in props && variant.includes('body')) {
|
|
97
|
+
maxLines = props.maxLines;
|
|
98
|
+
}
|
|
98
99
|
var color = useColor(colorProp);
|
|
99
100
|
var isWrapped = useHasTextAncestor();
|
|
100
101
|
|
|
@@ -106,7 +107,10 @@ var Text = function Text(_ref) {
|
|
|
106
107
|
return jsx(Fragment, null, children);
|
|
107
108
|
}
|
|
108
109
|
var component = jsx(Component, {
|
|
109
|
-
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color],
|
|
110
|
+
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
111
|
+
style: {
|
|
112
|
+
WebkitLineClamp: maxLines
|
|
113
|
+
},
|
|
110
114
|
"data-testid": testId,
|
|
111
115
|
id: id
|
|
112
116
|
}, 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';
|
|
@@ -484,7 +484,7 @@ export var borderRadiusMap = {
|
|
|
484
484
|
*/
|
|
485
485
|
/**
|
|
486
486
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
487
|
-
* @codegen <<SignedSource::
|
|
487
|
+
* @codegen <<SignedSource::402816562c359603300fda81596a2978>>
|
|
488
488
|
* @codegenId typography
|
|
489
489
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
490
490
|
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
|
|
@@ -502,10 +502,10 @@ export var fontSizeMap = {
|
|
|
502
502
|
'font.size.600': "var(--ds-font-size-600, 35px)"
|
|
503
503
|
};
|
|
504
504
|
export var fontWeightMap = {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
505
|
+
bold: "var(--ds-font-weight-bold, 700)",
|
|
506
|
+
medium: "var(--ds-font-weight-medium, 500)",
|
|
507
|
+
regular: "var(--ds-font-weight-regular, 400)",
|
|
508
|
+
semibold: "var(--ds-font-weight-semibold, 600)"
|
|
509
509
|
};
|
|
510
510
|
export var fontFamilyMap = {
|
|
511
511
|
'font.family.body': "var(--ds-font-family-body, ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
@@ -530,7 +530,7 @@ export var bodyTextMap = {
|
|
|
530
530
|
'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
531
531
|
};
|
|
532
532
|
export var uiTextMap = {
|
|
533
|
-
ui: "var(--ds-font-ui, normal
|
|
533
|
+
ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
534
534
|
'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
535
535
|
};
|
|
536
536
|
|
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,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { FC, ReactNode } from 'react';
|
|
3
|
-
import { BodyText, TextColor, UiText } from '../xcss/style-maps.partial';
|
|
3
|
+
import { BodyText, FontWeight, 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];
|
|
@@ -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
|
/**
|
|
@@ -46,6 +48,10 @@ type TextPropsBase = {
|
|
|
46
48
|
* Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
|
47
49
|
*/
|
|
48
50
|
textAlign?: TextAlign;
|
|
51
|
+
/**
|
|
52
|
+
* Font weight https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
|
|
53
|
+
*/
|
|
54
|
+
weight?: FontWeight;
|
|
49
55
|
};
|
|
50
56
|
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
|
|
51
57
|
type TextAlign = keyof typeof textAlignMap;
|
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';
|
|
@@ -515,7 +515,7 @@ export type BorderRadius = keyof typeof borderRadiusMap;
|
|
|
515
515
|
*/
|
|
516
516
|
/**
|
|
517
517
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
518
|
-
* @codegen <<SignedSource::
|
|
518
|
+
* @codegen <<SignedSource::402816562c359603300fda81596a2978>>
|
|
519
519
|
* @codegenId typography
|
|
520
520
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
521
521
|
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
|
|
@@ -534,10 +534,10 @@ export declare const fontSizeMap: {
|
|
|
534
534
|
};
|
|
535
535
|
export type FontSize = keyof typeof fontSizeMap;
|
|
536
536
|
export declare const fontWeightMap: {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
537
|
+
bold: "var(--ds-font-weight-bold)";
|
|
538
|
+
medium: "var(--ds-font-weight-medium)";
|
|
539
|
+
regular: "var(--ds-font-weight-regular)";
|
|
540
|
+
semibold: "var(--ds-font-weight-semibold)";
|
|
541
541
|
};
|
|
542
542
|
export type FontWeight = keyof typeof fontWeightMap;
|
|
543
543
|
export declare const fontFamilyMap: {
|