@atlaskit/primitives 1.19.0 → 2.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 +19 -0
- package/dist/cjs/components/grid.js +24 -8
- package/dist/cjs/components/text.js +9 -12
- package/dist/cjs/xcss/style-maps.partial.js +6 -6
- package/dist/es2019/components/grid.js +23 -8
- package/dist/es2019/components/text.js +9 -13
- package/dist/es2019/xcss/style-maps.partial.js +6 -6
- package/dist/esm/components/grid.js +24 -9
- package/dist/esm/components/text.js +10 -13
- package/dist/esm/xcss/style-maps.partial.js +6 -6
- package/dist/types/components/grid.d.ts +5 -5
- package/dist/types/components/text.d.ts +5 -1
- package/dist/types/xcss/style-maps.partial.d.ts +5 -5
- package/dist/types-ts4.5/components/grid.d.ts +5 -5
- package/dist/types-ts4.5/components/text.d.ts +5 -1
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +5 -5
- package/package.json +2 -2
- package/scripts/typography-codegen-template.tsx +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#68009](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68009) [`1168354ed6ef`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1168354ed6ef) - We now ensure the specificity of our `xcss`-based overrides are consistent across all primitives so `xcss` will always override props.
|
|
8
|
+
|
|
9
|
+
This resulted in a breaking change wtih Grid. For example, `<Grid templateAreas="…" xcss({ gridTemplateAreas: "…" })>` will result in different styles resolution before and after this version. This applies to `templateAreas`, `templateColumns`, and `templateRows`). From static analysis, we found only one known usage of this and it has been resolved.
|
|
10
|
+
|
|
11
|
+
## 1.20.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#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.
|
|
16
|
+
- [#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.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 1.19.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _react = require("react");
|
|
8
10
|
var _react2 = require("@emotion/react");
|
|
9
11
|
var _styleMaps = require("../xcss/style-maps.partial");
|
|
10
12
|
var _xcss = require("../xcss/xcss");
|
|
11
13
|
/** @jsx jsx */
|
|
12
14
|
|
|
15
|
+
var gridTemplateAreasVar = '--ds-grid--grid-template-areas';
|
|
16
|
+
var gridTemplateColumnsVar = '--ds-grid--grid-template-columns';
|
|
17
|
+
var gridTemplateRowsVar = '--ds-grid--grid-template-rows';
|
|
13
18
|
var justifyContentMap = {
|
|
14
19
|
start: (0, _react2.css)({
|
|
15
20
|
justifyContent: 'start'
|
|
@@ -86,7 +91,10 @@ var alignItemsMap = {
|
|
|
86
91
|
};
|
|
87
92
|
var baseStyles = (0, _react2.css)({
|
|
88
93
|
display: 'grid',
|
|
89
|
-
boxSizing: 'border-box'
|
|
94
|
+
boxSizing: 'border-box',
|
|
95
|
+
gridTemplateAreas: "var(".concat(gridTemplateAreasVar, ")"),
|
|
96
|
+
gridTemplateColumns: "var(".concat(gridTemplateColumnsVar, ")"),
|
|
97
|
+
gridTemplateRows: "var(".concat(gridTemplateRowsVar, ")")
|
|
90
98
|
});
|
|
91
99
|
var gridAutoFlowMap = {
|
|
92
100
|
row: (0, _react2.css)({
|
|
@@ -145,20 +153,28 @@ var Grid = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
145
153
|
xcss = _ref.xcss;
|
|
146
154
|
var Component = as || 'div';
|
|
147
155
|
var xcssClassName = xcss && (0, _xcss.parseXcss)(xcss);
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* We use CSS variables to allow for dynamic grid templates instead of dynamically setting to `props.style`
|
|
159
|
+
* This allows `props.xcss` to override them as `style={{ gridTemplateAreas }}` would have higher specificity.
|
|
160
|
+
*
|
|
161
|
+
* This must be reset to `initial` if `gridTemplateAreas` is not set, otherwise nested grids will break!
|
|
162
|
+
*
|
|
163
|
+
* NOTE: If we disallow `grid-template-areas` (etc) to be set via `props.xcss`, we can remove this.
|
|
164
|
+
*/
|
|
165
|
+
var style = (0, _react.useMemo)(function () {
|
|
166
|
+
var _ref2;
|
|
167
|
+
return _ref2 = {}, (0, _defineProperty2.default)(_ref2, gridTemplateAreasVar, gridTemplateAreas ? gridTemplateAreas.map(function (str) {
|
|
150
168
|
return "\"".concat(str, "\"");
|
|
151
|
-
}).join('\n') :
|
|
152
|
-
|
|
153
|
-
gridTemplateRows: gridTemplateRows
|
|
154
|
-
}) : undefined;
|
|
169
|
+
}).join('\n') || 'initial' : 'initial'), (0, _defineProperty2.default)(_ref2, gridTemplateColumnsVar, gridTemplateColumns || 'initial'), (0, _defineProperty2.default)(_ref2, gridTemplateRowsVar, gridTemplateRows || 'initial'), _ref2;
|
|
170
|
+
}, [gridTemplateAreas, gridTemplateColumns, gridTemplateRows]);
|
|
155
171
|
return (0, _react2.jsx)(Component, {
|
|
156
172
|
id: id,
|
|
157
173
|
role: role,
|
|
158
174
|
style: style,
|
|
159
175
|
css: [baseStyles, gap && _styleMaps.spaceStylesMap.gap[gap], columnGap && _styleMaps.spaceStylesMap.columnGap[columnGap], rowGap && _styleMaps.spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], alignContent && alignContentMap[alignContent], justifyContent && justifyContentMap[justifyContent], autoFlow && gridAutoFlowMap[autoFlow],
|
|
160
176
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
161
|
-
xcssClassName
|
|
177
|
+
xcssClassName],
|
|
162
178
|
"data-testid": testId,
|
|
163
179
|
ref: ref
|
|
164
180
|
}, children);
|
|
@@ -83,21 +83,18 @@ var Text = function Text(_ref) {
|
|
|
83
83
|
var children = _ref.children,
|
|
84
84
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
85
85
|
var asElement = props.as,
|
|
86
|
-
|
|
86
|
+
_props$color = props.color,
|
|
87
|
+
colorProp = _props$color === void 0 ? 'color.text' : _props$color,
|
|
87
88
|
textAlign = props.textAlign,
|
|
88
89
|
testId = props.testId,
|
|
89
90
|
id = props.id,
|
|
90
91
|
_props$variant = props.variant,
|
|
91
|
-
variant = _props$variant === void 0 ? 'body' : _props$variant
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// ui text and default => span
|
|
98
|
-
Component = 'span';
|
|
99
|
-
}
|
|
100
|
-
}
|
|
92
|
+
variant = _props$variant === void 0 ? 'body' : _props$variant,
|
|
93
|
+
weight = props.weight;
|
|
94
|
+
|
|
95
|
+
// body variants -> p
|
|
96
|
+
// ui variants -> span
|
|
97
|
+
var Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
101
98
|
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
102
99
|
|
|
103
100
|
// Remove the ability to bypass typescript errors for maxLines
|
|
@@ -116,7 +113,7 @@ var Text = function Text(_ref) {
|
|
|
116
113
|
return (0, _react2.jsx)(_react.Fragment, null, children);
|
|
117
114
|
}
|
|
118
115
|
var component = (0, _react2.jsx)(Component, {
|
|
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],
|
|
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],
|
|
120
117
|
style: {
|
|
121
118
|
WebkitLineClamp: maxLines
|
|
122
119
|
},
|
|
@@ -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
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { forwardRef, memo } from 'react';
|
|
2
|
+
import { forwardRef, memo, useMemo } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { spaceStylesMap } from '../xcss/style-maps.partial';
|
|
5
5
|
import { parseXcss } from '../xcss/xcss';
|
|
6
|
+
const gridTemplateAreasVar = '--ds-grid--grid-template-areas';
|
|
7
|
+
const gridTemplateColumnsVar = '--ds-grid--grid-template-columns';
|
|
8
|
+
const gridTemplateRowsVar = '--ds-grid--grid-template-rows';
|
|
6
9
|
const justifyContentMap = {
|
|
7
10
|
start: css({
|
|
8
11
|
justifyContent: 'start'
|
|
@@ -79,7 +82,10 @@ const alignItemsMap = {
|
|
|
79
82
|
};
|
|
80
83
|
const baseStyles = css({
|
|
81
84
|
display: 'grid',
|
|
82
|
-
boxSizing: 'border-box'
|
|
85
|
+
boxSizing: 'border-box',
|
|
86
|
+
gridTemplateAreas: `var(${gridTemplateAreasVar})`,
|
|
87
|
+
gridTemplateColumns: `var(${gridTemplateColumnsVar})`,
|
|
88
|
+
gridTemplateRows: `var(${gridTemplateRowsVar})`
|
|
83
89
|
});
|
|
84
90
|
const gridAutoFlowMap = {
|
|
85
91
|
row: css({
|
|
@@ -139,18 +145,27 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
139
145
|
}, ref) => {
|
|
140
146
|
const Component = as || 'div';
|
|
141
147
|
const xcssClassName = xcss && parseXcss(xcss);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* We use CSS variables to allow for dynamic grid templates instead of dynamically setting to `props.style`
|
|
151
|
+
* This allows `props.xcss` to override them as `style={{ gridTemplateAreas }}` would have higher specificity.
|
|
152
|
+
*
|
|
153
|
+
* This must be reset to `initial` if `gridTemplateAreas` is not set, otherwise nested grids will break!
|
|
154
|
+
*
|
|
155
|
+
* NOTE: If we disallow `grid-template-areas` (etc) to be set via `props.xcss`, we can remove this.
|
|
156
|
+
*/
|
|
157
|
+
const style = useMemo(() => ({
|
|
158
|
+
[gridTemplateAreasVar]: gridTemplateAreas ? gridTemplateAreas.map(str => `"${str}"`).join('\n') || 'initial' : 'initial',
|
|
159
|
+
[gridTemplateColumnsVar]: gridTemplateColumns || 'initial',
|
|
160
|
+
[gridTemplateRowsVar]: gridTemplateRows || 'initial'
|
|
161
|
+
}), [gridTemplateAreas, gridTemplateColumns, gridTemplateRows]);
|
|
147
162
|
return jsx(Component, {
|
|
148
163
|
id: id,
|
|
149
164
|
role: role,
|
|
150
165
|
style: style,
|
|
151
166
|
css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], alignContent && alignContentMap[alignContent], justifyContent && justifyContentMap[justifyContent], autoFlow && gridAutoFlowMap[autoFlow],
|
|
152
167
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
153
|
-
xcssClassName
|
|
168
|
+
xcssClassName],
|
|
154
169
|
"data-testid": testId,
|
|
155
170
|
ref: ref
|
|
156
171
|
}, children);
|
|
@@ -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.
|
|
@@ -75,21 +75,17 @@ const Text = ({
|
|
|
75
75
|
}) => {
|
|
76
76
|
const {
|
|
77
77
|
as: asElement,
|
|
78
|
-
color: colorProp,
|
|
78
|
+
color: colorProp = 'color.text',
|
|
79
79
|
textAlign,
|
|
80
80
|
testId,
|
|
81
81
|
id,
|
|
82
|
-
variant = 'body'
|
|
82
|
+
variant = 'body',
|
|
83
|
+
weight
|
|
83
84
|
} = props;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
// ui text and default => span
|
|
90
|
-
Component = 'span';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
85
|
+
|
|
86
|
+
// body variants -> p
|
|
87
|
+
// ui variants -> span
|
|
88
|
+
const Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
93
89
|
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
94
90
|
|
|
95
91
|
// Remove the ability to bypass typescript errors for maxLines
|
|
@@ -108,7 +104,7 @@ const Text = ({
|
|
|
108
104
|
return jsx(Fragment, null, children);
|
|
109
105
|
}
|
|
110
106
|
const component = jsx(Component, {
|
|
111
|
-
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
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],
|
|
112
108
|
style: {
|
|
113
109
|
WebkitLineClamp: maxLines
|
|
114
110
|
},
|
|
@@ -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
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
/** @jsx jsx */
|
|
2
|
-
import { forwardRef, memo } from 'react';
|
|
3
|
+
import { forwardRef, memo, useMemo } from 'react';
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import { spaceStylesMap } from '../xcss/style-maps.partial';
|
|
5
6
|
import { parseXcss } from '../xcss/xcss';
|
|
7
|
+
var gridTemplateAreasVar = '--ds-grid--grid-template-areas';
|
|
8
|
+
var gridTemplateColumnsVar = '--ds-grid--grid-template-columns';
|
|
9
|
+
var gridTemplateRowsVar = '--ds-grid--grid-template-rows';
|
|
6
10
|
var justifyContentMap = {
|
|
7
11
|
start: css({
|
|
8
12
|
justifyContent: 'start'
|
|
@@ -79,7 +83,10 @@ var alignItemsMap = {
|
|
|
79
83
|
};
|
|
80
84
|
var baseStyles = css({
|
|
81
85
|
display: 'grid',
|
|
82
|
-
boxSizing: 'border-box'
|
|
86
|
+
boxSizing: 'border-box',
|
|
87
|
+
gridTemplateAreas: "var(".concat(gridTemplateAreasVar, ")"),
|
|
88
|
+
gridTemplateColumns: "var(".concat(gridTemplateColumnsVar, ")"),
|
|
89
|
+
gridTemplateRows: "var(".concat(gridTemplateRowsVar, ")")
|
|
83
90
|
});
|
|
84
91
|
var gridAutoFlowMap = {
|
|
85
92
|
row: css({
|
|
@@ -138,20 +145,28 @@ var Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
138
145
|
xcss = _ref.xcss;
|
|
139
146
|
var Component = as || 'div';
|
|
140
147
|
var xcssClassName = xcss && parseXcss(xcss);
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* We use CSS variables to allow for dynamic grid templates instead of dynamically setting to `props.style`
|
|
151
|
+
* This allows `props.xcss` to override them as `style={{ gridTemplateAreas }}` would have higher specificity.
|
|
152
|
+
*
|
|
153
|
+
* This must be reset to `initial` if `gridTemplateAreas` is not set, otherwise nested grids will break!
|
|
154
|
+
*
|
|
155
|
+
* NOTE: If we disallow `grid-template-areas` (etc) to be set via `props.xcss`, we can remove this.
|
|
156
|
+
*/
|
|
157
|
+
var style = useMemo(function () {
|
|
158
|
+
var _ref2;
|
|
159
|
+
return _ref2 = {}, _defineProperty(_ref2, gridTemplateAreasVar, gridTemplateAreas ? gridTemplateAreas.map(function (str) {
|
|
143
160
|
return "\"".concat(str, "\"");
|
|
144
|
-
}).join('\n') :
|
|
145
|
-
|
|
146
|
-
gridTemplateRows: gridTemplateRows
|
|
147
|
-
}) : undefined;
|
|
161
|
+
}).join('\n') || 'initial' : 'initial'), _defineProperty(_ref2, gridTemplateColumnsVar, gridTemplateColumns || 'initial'), _defineProperty(_ref2, gridTemplateRowsVar, gridTemplateRows || 'initial'), _ref2;
|
|
162
|
+
}, [gridTemplateAreas, gridTemplateColumns, gridTemplateRows]);
|
|
148
163
|
return jsx(Component, {
|
|
149
164
|
id: id,
|
|
150
165
|
role: role,
|
|
151
166
|
style: style,
|
|
152
167
|
css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], alignContent && alignContentMap[alignContent], justifyContent && justifyContentMap[justifyContent], autoFlow && gridAutoFlowMap[autoFlow],
|
|
153
168
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
154
|
-
xcssClassName
|
|
169
|
+
xcssClassName],
|
|
155
170
|
"data-testid": testId,
|
|
156
171
|
ref: ref
|
|
157
172
|
}, children);
|
|
@@ -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.
|
|
@@ -77,21 +77,18 @@ var Text = function Text(_ref) {
|
|
|
77
77
|
var children = _ref.children,
|
|
78
78
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
79
79
|
var asElement = props.as,
|
|
80
|
-
|
|
80
|
+
_props$color = props.color,
|
|
81
|
+
colorProp = _props$color === void 0 ? 'color.text' : _props$color,
|
|
81
82
|
textAlign = props.textAlign,
|
|
82
83
|
testId = props.testId,
|
|
83
84
|
id = props.id,
|
|
84
85
|
_props$variant = props.variant,
|
|
85
|
-
variant = _props$variant === void 0 ? 'body' : _props$variant
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// ui text and default => span
|
|
92
|
-
Component = 'span';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
86
|
+
variant = _props$variant === void 0 ? 'body' : _props$variant,
|
|
87
|
+
weight = props.weight;
|
|
88
|
+
|
|
89
|
+
// body variants -> p
|
|
90
|
+
// ui variants -> span
|
|
91
|
+
var Component = asElement || (variant.includes('body') ? 'p' : 'span');
|
|
95
92
|
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
96
93
|
|
|
97
94
|
// Remove the ability to bypass typescript errors for maxLines
|
|
@@ -110,7 +107,7 @@ var Text = function Text(_ref) {
|
|
|
110
107
|
return jsx(Fragment, null, children);
|
|
111
108
|
}
|
|
112
109
|
var component = jsx(Component, {
|
|
113
|
-
css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
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],
|
|
114
111
|
style: {
|
|
115
112
|
WebkitLineClamp: maxLines
|
|
116
113
|
},
|
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { type ElementType, type ReactNode } from 'react';
|
|
3
3
|
import { type Space } from '../xcss/style-maps.partial';
|
|
4
4
|
import type { BasePrimitiveProps } from './types';
|
|
5
5
|
export type GridProps<T extends ElementType = 'div'> = {
|
|
@@ -58,11 +58,11 @@ export type GridProps<T extends ElementType = 'div'> = {
|
|
|
58
58
|
*/
|
|
59
59
|
children: ReactNode;
|
|
60
60
|
/**
|
|
61
|
-
* HTML id attrubute
|
|
61
|
+
* HTML id attrubute.
|
|
62
62
|
*/
|
|
63
63
|
id?: string;
|
|
64
64
|
/**
|
|
65
|
-
* Forwarded ref element
|
|
65
|
+
* Forwarded ref element.
|
|
66
66
|
*/
|
|
67
67
|
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
68
68
|
} & BasePrimitiveProps;
|
|
@@ -184,11 +184,11 @@ declare const Grid: import("react").MemoExoticComponent<import("react").ForwardR
|
|
|
184
184
|
*/
|
|
185
185
|
children: ReactNode;
|
|
186
186
|
/**
|
|
187
|
-
* HTML id attrubute
|
|
187
|
+
* HTML id attrubute.
|
|
188
188
|
*/
|
|
189
189
|
id?: string | undefined;
|
|
190
190
|
/**
|
|
191
|
-
* Forwarded ref element
|
|
191
|
+
* Forwarded ref element.
|
|
192
192
|
*/
|
|
193
193
|
ref?: any;
|
|
194
194
|
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignContent" | "alignItems" | "justifyContent" | "justifyItems" | "children" | "as" | "id" | keyof BasePrimitiveProps | "autoFlow" | "templateAreas" | "templateRows" | "templateColumns"> & import("react").RefAttributes<any>>>;
|
|
@@ -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];
|
|
@@ -48,6 +48,10 @@ type TextPropsBase = {
|
|
|
48
48
|
* Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
|
49
49
|
*/
|
|
50
50
|
textAlign?: TextAlign;
|
|
51
|
+
/**
|
|
52
|
+
* Font weight https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
|
|
53
|
+
*/
|
|
54
|
+
weight?: FontWeight;
|
|
51
55
|
};
|
|
52
56
|
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
|
|
53
57
|
type TextAlign = keyof typeof textAlignMap;
|
|
@@ -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: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { type ElementType, type ReactNode } from 'react';
|
|
3
3
|
import { type Space } from '../xcss/style-maps.partial';
|
|
4
4
|
import type { BasePrimitiveProps } from './types';
|
|
5
5
|
export type GridProps<T extends ElementType = 'div'> = {
|
|
@@ -58,11 +58,11 @@ export type GridProps<T extends ElementType = 'div'> = {
|
|
|
58
58
|
*/
|
|
59
59
|
children: ReactNode;
|
|
60
60
|
/**
|
|
61
|
-
* HTML id attrubute
|
|
61
|
+
* HTML id attrubute.
|
|
62
62
|
*/
|
|
63
63
|
id?: string;
|
|
64
64
|
/**
|
|
65
|
-
* Forwarded ref element
|
|
65
|
+
* Forwarded ref element.
|
|
66
66
|
*/
|
|
67
67
|
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
68
68
|
} & BasePrimitiveProps;
|
|
@@ -184,11 +184,11 @@ declare const Grid: import("react").MemoExoticComponent<import("react").ForwardR
|
|
|
184
184
|
*/
|
|
185
185
|
children: ReactNode;
|
|
186
186
|
/**
|
|
187
|
-
* HTML id attrubute
|
|
187
|
+
* HTML id attrubute.
|
|
188
188
|
*/
|
|
189
189
|
id?: string | undefined;
|
|
190
190
|
/**
|
|
191
|
-
* Forwarded ref element
|
|
191
|
+
* Forwarded ref element.
|
|
192
192
|
*/
|
|
193
193
|
ref?: any;
|
|
194
194
|
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignContent" | "alignItems" | "justifyContent" | "justifyItems" | "children" | "as" | "id" | keyof BasePrimitiveProps | "autoFlow" | "templateAreas" | "templateRows" | "templateColumns"> & import("react").RefAttributes<any>>>;
|
|
@@ -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 [
|
|
6
6
|
"span",
|
|
@@ -53,6 +53,10 @@ type TextPropsBase = {
|
|
|
53
53
|
* Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
|
54
54
|
*/
|
|
55
55
|
textAlign?: TextAlign;
|
|
56
|
+
/**
|
|
57
|
+
* Font weight https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
|
|
58
|
+
*/
|
|
59
|
+
weight?: FontWeight;
|
|
56
60
|
};
|
|
57
61
|
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
|
|
58
62
|
type TextAlign = keyof typeof textAlignMap;
|
|
@@ -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: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
107
|
"@atlaskit/app-provider": "^0.4.0",
|
|
108
|
-
"@atlaskit/tokens": "^1.
|
|
108
|
+
"@atlaskit/tokens": "^1.35.0",
|
|
109
109
|
"@babel/runtime": "^7.0.0",
|
|
110
110
|
"@emotion/react": "^11.7.1",
|
|
111
111
|
"@emotion/serialize": "^1.1.0",
|
|
@@ -61,10 +61,17 @@ const activeTokens: Token[] = tokens.map(t => ({
|
|
|
61
61
|
}));
|
|
62
62
|
|
|
63
63
|
const removeVerbosity = (name: string): string => {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
64
|
+
const partialRemove = ['font.heading', 'font.ui', 'font.body'];
|
|
65
|
+
if (partialRemove.some(s => name.includes(s))) {
|
|
66
66
|
return name.replace('font.', '');
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
const fullRemove = ['font.weight'];
|
|
70
|
+
const removeIndex = fullRemove.findIndex(s => name.includes(s));
|
|
71
|
+
if (removeIndex > -1) {
|
|
72
|
+
return name.replace(`${fullRemove[removeIndex]}.`, '');
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
return name;
|
|
69
76
|
};
|
|
70
77
|
|