@atlaskit/primitives 1.16.0 → 1.18.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#67463](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67463) [`adf1c3ebf0fd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/adf1c3ebf0fd) - Fixed an issue with `Text` where text could render incorrectly if a typography token theme was not present on a page.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 1.17.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#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.
18
+
3
19
  ## 1.16.0
4
20
 
5
21
  ### Minor Changes
@@ -2,6 +2,10 @@
2
2
  title: Text
3
3
  description: Text is a token-backed typography component to display body and UI text.
4
4
  order: 1
5
+ props:
6
+ packageName: '@atlaskit/primitives'
7
+ exports:
8
+ - Text
5
9
  ---
6
10
 
7
11
  import { CodeDocsHeader } from '@af/design-system-docs-ui';
@@ -12,8 +16,6 @@ import { CodeDocsHeader } from '@af/design-system-docs-ui';
12
16
  directoryName="primitives"
13
17
  />
14
18
 
15
- import ERTText from '!!extract-react-types-loader!../../extract-react-types/text-props';
16
-
17
19
  ## Props
18
20
 
19
- <PropsTable heading="" props={ERTText} />
21
+ <TSMorphProps exportName="Text" packageName="@atlaskit/primitives" />
@@ -6,7 +6,7 @@ order: 0
6
6
 
7
7
  import { MediaQueriesTable } from '@af/design-system-docs-ui';
8
8
 
9
- XCSS is an Atlassian Design System styling API that natively integrates with Atlassian's [design tokens](/tokens) and [primitives](/components/primitives).
9
+ XCSS is an Atlassian Design System styling API that natively integrates with Atlassian's [design tokens](/tokens) and [primitives](/components/primitives/overview).
10
10
 
11
11
  The XCSS utility behaves similarly to the `css` utility in libraries like `styled-components`, `@compiled` or `@emotion`. If you've used these libraries, XCSS will feel familiar, with a few additional features and constraints.
12
12
 
@@ -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: "var(--ds-font-weight-bold, bold)"
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();
@@ -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::739812ebd4363d1b1782332b2ebffd2c>>
499
+ * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
500
500
  * @codegenId typography
501
501
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
502
502
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -537,13 +537,13 @@ var lineHeightMap = exports.lineHeightMap = {
537
537
  'font.lineHeight.600': "var(--ds-font-lineHeight-600, 40px)"
538
538
  };
539
539
  var bodyTextMap = exports.bodyTextMap = {
540
- body: "var(--ds-font-body, normal 400 14px/20px var(--ds-font-family-body))",
541
- 'body.large': "var(--ds-font-body-large, normal 400 16px/24px var(--ds-font-family-body))",
542
- 'body.small': "var(--ds-font-body-small, normal 400 11px/16px var(--ds-font-family-body))"
540
+ body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
541
+ 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
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 400 14px/1 var(--ds-font-family-body))",
546
- 'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 var(--ds-font-family-body))"
545
+ ui: "var(--ds-font-ui, normal 400 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
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
 
549
549
  /**
@@ -16,7 +16,7 @@ const variantStyles = {
16
16
  ...uiTextStylesMap
17
17
  };
18
18
  const strongStyles = css({
19
- fontWeight: "var(--ds-font-weight-bold, bold)"
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();
@@ -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::739812ebd4363d1b1782332b2ebffd2c>>
487
+ * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
488
488
  * @codegenId typography
489
489
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
490
490
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -525,13 +525,13 @@ export const lineHeightMap = {
525
525
  'font.lineHeight.600': "var(--ds-font-lineHeight-600, 40px)"
526
526
  };
527
527
  export const bodyTextMap = {
528
- body: "var(--ds-font-body, normal 400 14px/20px var(--ds-font-family-body))",
529
- 'body.large': "var(--ds-font-body-large, normal 400 16px/24px var(--ds-font-family-body))",
530
- 'body.small': "var(--ds-font-body-small, normal 400 11px/16px var(--ds-font-family-body))"
528
+ body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
529
+ 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
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 400 14px/1 var(--ds-font-family-body))",
534
- 'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 var(--ds-font-family-body))"
533
+ ui: "var(--ds-font-ui, normal 400 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
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
 
537
537
  /**
@@ -18,7 +18,7 @@ var resetStyles = css({
18
18
  });
19
19
  var variantStyles = _objectSpread(_objectSpread({}, bodyTextStylesMap), uiTextStylesMap);
20
20
  var strongStyles = css({
21
- fontWeight: "var(--ds-font-weight-bold, bold)"
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();
@@ -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::739812ebd4363d1b1782332b2ebffd2c>>
487
+ * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
488
488
  * @codegenId typography
489
489
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
490
490
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -525,13 +525,13 @@ export var lineHeightMap = {
525
525
  'font.lineHeight.600': "var(--ds-font-lineHeight-600, 40px)"
526
526
  };
527
527
  export var bodyTextMap = {
528
- body: "var(--ds-font-body, normal 400 14px/20px var(--ds-font-family-body))",
529
- 'body.large': "var(--ds-font-body-large, normal 400 16px/24px var(--ds-font-family-body))",
530
- 'body.small': "var(--ds-font-body-small, normal 400 11px/16px var(--ds-font-family-body))"
528
+ body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
529
+ 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
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 400 14px/1 var(--ds-font-family-body))",
534
- 'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 var(--ds-font-family-body))"
533
+ ui: "var(--ds-font-ui, normal 400 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
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
 
537
537
  /**
@@ -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 Variant = BodyText | UiText;
8
- export interface TextProps extends Omit<BasePrimitiveProps, 'xcss'> {
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;
@@ -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::739812ebd4363d1b1782332b2ebffd2c>>
518
+ * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
519
519
  * @codegenId typography
520
520
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
521
521
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -9,8 +9,26 @@ declare const asAllowlist: readonly [
9
9
  "em"
10
10
  ];
11
11
  type AsElement = (typeof asAllowlist)[number];
12
- type Variant = BodyText | UiText;
13
- export interface TextProps extends Omit<BasePrimitiveProps, 'xcss'> {
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;
@@ -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::739812ebd4363d1b1782332b2ebffd2c>>
518
+ * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
519
519
  * @codegenId typography
520
520
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
521
521
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.16.0",
3
+ "version": "1.18.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.33.0",
108
+ "@atlaskit/tokens": "^1.34.0",
109
109
  "@babel/runtime": "^7.0.0",
110
110
  "@emotion/react": "^11.7.1",
111
111
  "@emotion/serialize": "^1.1.0",
@@ -81,19 +81,19 @@ export const createTypographyStylesFromTemplate = (
81
81
  prettier.format(
82
82
  `
83
83
  export const ${objectName}Map = {
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')}
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,