@atlaskit/primitives 1.9.0 → 1.10.1

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,17 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#43018](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43018) [`3cb6a290654`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3cb6a290654) - Text component now has `margin: 0` to ensure no margins are inherited (for example from the CSS reset).
8
+
9
+ ## 1.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#42931](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42931) [`5778f757885`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5778f757885) - Added export for Text component. This component is currently in closed beta and is not intended for general use at this stage.
14
+
3
15
  ## 1.9.0
4
16
 
5
17
  ### Minor Changes
@@ -16,6 +16,12 @@ var _excluded = ["children"];
16
16
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
18
18
  var asAllowlist = ['span', 'p', 'strong', 'em'];
19
+ // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
20
+ // Long term we should remove those instances from the reset - it should be a reset to 0.
21
+ // For now, at least we know <Text> will be unaffected by this.
22
+ var resetStyles = (0, _react2.css)({
23
+ margin: 0
24
+ });
19
25
  var variantStyles = _objectSpread(_objectSpread({}, _styleMaps.bodyTextStylesMap), _styleMaps.uiTextStylesMap);
20
26
  var strongStyles = (0, _react2.css)({
21
27
  fontWeight: "var(--ds-font-weight-bold, bold)"
@@ -101,7 +107,7 @@ var Text = function Text(_ref) {
101
107
  return (0, _react2.jsx)(_react.Fragment, null, children);
102
108
  }
103
109
  var component = (0, _react2.jsx)(Component, {
104
- css: [variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
110
+ css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
105
111
  "data-testid": testId,
106
112
  id: id
107
113
  }, children);
package/dist/cjs/index.js CHANGED
@@ -40,6 +40,12 @@ Object.defineProperty(exports, "Stack", {
40
40
  return _stack.default;
41
41
  }
42
42
  });
43
+ Object.defineProperty(exports, "Text", {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _text.default;
47
+ }
48
+ });
43
49
  Object.defineProperty(exports, "UNSAFE_BREAKPOINTS_CONFIG", {
44
50
  enumerable: true,
45
51
  get: function get() {
@@ -71,4 +77,5 @@ var _stack = _interopRequireDefault(require("./components/stack"));
71
77
  var _flex = _interopRequireDefault(require("./components/flex"));
72
78
  var _grid = _interopRequireDefault(require("./components/grid"));
73
79
  var _bleed = _interopRequireDefault(require("./components/bleed"));
80
+ var _text = _interopRequireDefault(require("./components/text"));
74
81
  var _responsive = require("./responsive");
@@ -13,6 +13,8 @@ var _react = require("@emotion/react");
13
13
  var _styleMaps = require("./style-maps.partial");
14
14
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
15
15
 
16
+ // eslint-disable-next-line import/no-extraneous-dependencies
17
+
16
18
  var tokensMap = {
17
19
  backgroundColor: _styleMaps.backgroundColorMap,
18
20
  blockSize: _styleMaps.dimensionMap,
@@ -5,6 +5,12 @@ import invariant from 'tiny-invariant';
5
5
  import { bodyTextStylesMap, 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
+ // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
9
+ // Long term we should remove those instances from the reset - it should be a reset to 0.
10
+ // For now, at least we know <Text> will be unaffected by this.
11
+ const resetStyles = css({
12
+ margin: 0
13
+ });
8
14
  const variantStyles = {
9
15
  ...bodyTextStylesMap,
10
16
  ...uiTextStylesMap
@@ -92,7 +98,7 @@ const Text = ({
92
98
  return jsx(Fragment, null, children);
93
99
  }
94
100
  const component = jsx(Component, {
95
- css: [variant && variantStyles[variant], color && textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
101
+ css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
96
102
  "data-testid": testId,
97
103
  id: id
98
104
  }, children);
@@ -5,4 +5,5 @@ 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';
7
7
  export { default as Bleed } from './components/bleed';
8
+ export { default as Text } from './components/text';
8
9
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
@@ -1,5 +1,8 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
2
  import { css as cssEmotion } from '@emotion/react';
3
+
4
+ // eslint-disable-next-line import/no-extraneous-dependencies
5
+
3
6
  import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
4
7
  const tokensMap = {
5
8
  backgroundColor: backgroundColorMap,
@@ -10,6 +10,12 @@ import invariant from 'tiny-invariant';
10
10
  import { bodyTextStylesMap, 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
+ // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
14
+ // Long term we should remove those instances from the reset - it should be a reset to 0.
15
+ // For now, at least we know <Text> will be unaffected by this.
16
+ var resetStyles = css({
17
+ margin: 0
18
+ });
13
19
  var variantStyles = _objectSpread(_objectSpread({}, bodyTextStylesMap), uiTextStylesMap);
14
20
  var strongStyles = css({
15
21
  fontWeight: "var(--ds-font-weight-bold, bold)"
@@ -95,7 +101,7 @@ var Text = function Text(_ref) {
95
101
  return jsx(Fragment, null, children);
96
102
  }
97
103
  var component = jsx(Component, {
98
- css: [variant && variantStyles[variant], color && textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
104
+ css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
99
105
  "data-testid": testId,
100
106
  id: id
101
107
  }, children);
package/dist/esm/index.js CHANGED
@@ -5,4 +5,5 @@ 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';
7
7
  export { default as Bleed } from './components/bleed';
8
+ export { default as Text } from './components/text';
8
9
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
@@ -3,6 +3,9 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _typeof from "@babel/runtime/helpers/typeof";
4
4
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
5
5
  import { css as cssEmotion } from '@emotion/react';
6
+
7
+ // eslint-disable-next-line import/no-extraneous-dependencies
8
+
6
9
  import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
7
10
  var tokensMap = {
8
11
  backgroundColor: backgroundColorMap,
@@ -12,5 +12,7 @@ export { default as Grid } from './components/grid';
12
12
  export type { GridProps } from './components/grid';
13
13
  export { default as Bleed } from './components/bleed';
14
14
  export type { BleedProps } from './components/bleed';
15
+ export { default as Text } from './components/text';
16
+ export type { TextProps } from './components/text';
15
17
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
16
18
  export type { Breakpoint } from './responsive';
@@ -12,5 +12,7 @@ export { default as Grid } from './components/grid';
12
12
  export type { GridProps } from './components/grid';
13
13
  export { default as Bleed } from './components/bleed';
14
14
  export type { BleedProps } from './components/bleed';
15
+ export { default as Text } from './components/text';
16
+ export type { TextProps } from './components/text';
15
17
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
16
18
  export type { Breakpoint } from './responsive';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -191,6 +191,7 @@
191
191
  "./box": "./src/components/box.tsx",
192
192
  "./stack": "./src/components/stack.tsx",
193
193
  "./inline": "./src/components/inline.tsx",
194
+ "./text": "./src/components/text.tsx",
194
195
  "./pressable": "./src/components/pressable.tsx",
195
196
  "./link": "./src/components/link.tsx",
196
197
  "./responsive": "./src/responsive/index.tsx"
package/report.api.md CHANGED
@@ -21,6 +21,7 @@ import type * as CSS_2 from 'csstype';
21
21
  import type { CSSProperties } from 'react';
22
22
  import type { CSSPropertiesWithMultiValues } from '@emotion/serialize';
23
23
  import { ElementType } from 'react';
24
+ import { FC } from 'react';
24
25
  import { ForwardRefExoticComponent } from 'react';
25
26
  import { jsx } from '@emotion/react';
26
27
  import { MemoExoticComponent } from 'react';
@@ -84,6 +85,12 @@ type AllMedia =
84
85
  // @public (undocumented)
85
86
  type AllowedElements = Exclude<keyof JSX.IntrinsicElements, SVGElements>;
86
87
 
88
+ // @public (undocumented)
89
+ const asAllowlist: readonly ['span', 'p', 'strong', 'em'];
90
+
91
+ // @public (undocumented)
92
+ type AsElement = (typeof asAllowlist)[number];
93
+
87
94
  // @public (undocumented)
88
95
  type AtRulesWithoutMedia = Exclude<CSS_2.AtRules, '@media'>;
89
96
 
@@ -337,6 +344,16 @@ export type BleedProps = {
337
344
  block?: Space_2;
338
345
  } & BasePrimitiveProps;
339
346
 
347
+ // @public (undocumented)
348
+ type BodyText = keyof typeof bodyTextMap;
349
+
350
+ // @public (undocumented)
351
+ const bodyTextMap: {
352
+ body: 'var(--ds-font-body)';
353
+ 'body.large': 'var(--ds-font-body-large)';
354
+ 'body.small': 'var(--ds-font-body-small)';
355
+ };
356
+
340
357
  // @public (undocumented)
341
358
  export type BorderColor = keyof typeof borderColorMap;
342
359
 
@@ -1040,6 +1057,20 @@ type SVGElements =
1040
1057
  | 'use'
1041
1058
  | 'view';
1042
1059
 
1060
+ // @internal
1061
+ const Text_2: FC<TextProps>;
1062
+ export { Text_2 as Text };
1063
+
1064
+ // @public (undocumented)
1065
+ type TextAlign = keyof typeof textAlignMap;
1066
+
1067
+ // @public (undocumented)
1068
+ const textAlignMap: {
1069
+ center: SerializedStyles_2;
1070
+ end: SerializedStyles_2;
1071
+ start: SerializedStyles_2;
1072
+ };
1073
+
1043
1074
  // @public (undocumented)
1044
1075
  export type TextColor = keyof typeof textColorMap;
1045
1076
 
@@ -1083,6 +1114,17 @@ const textColorMap: {
1083
1114
  readonly 'color.link.visited': 'var(--ds-link-visited)';
1084
1115
  };
1085
1116
 
1117
+ // @public (undocumented)
1118
+ export interface TextProps extends BasePrimitiveProps {
1119
+ as?: AsElement;
1120
+ children: ReactNode;
1121
+ color?: TextColor;
1122
+ id?: string;
1123
+ shouldTruncate?: boolean;
1124
+ textAlign?: TextAlign;
1125
+ variant?: Variant;
1126
+ }
1127
+
1086
1128
  // @public (undocumented)
1087
1129
  type TokenisedProps = {
1088
1130
  backgroundColor?: BackgroundColor;
@@ -1145,6 +1187,15 @@ type TokenisedProps = {
1145
1187
  zIndex?: Layer;
1146
1188
  };
1147
1189
 
1190
+ // @public (undocumented)
1191
+ type UiText = keyof typeof uiTextMap;
1192
+
1193
+ // @public (undocumented)
1194
+ const uiTextMap: {
1195
+ ui: 'var(--ds-font-ui)';
1196
+ 'ui.small': 'var(--ds-font-ui-small)';
1197
+ };
1198
+
1148
1199
  // @public (undocumented)
1149
1200
  const uniqueSymbol: unique symbol;
1150
1201
 
@@ -1215,6 +1266,9 @@ export const UNSAFE_media: {
1215
1266
  };
1216
1267
  };
1217
1268
 
1269
+ // @public (undocumented)
1270
+ type Variant = BodyText | UiText;
1271
+
1218
1272
  // @public (undocumented)
1219
1273
  type Wrap = keyof typeof flexWrapMap;
1220
1274
 
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/primitives/text",
3
+ "main": "../dist/cjs/components/text.js",
4
+ "module": "../dist/esm/components/text.js",
5
+ "module:es2019": "../dist/es2019/components/text.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/components/text.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/components/text.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -10,6 +10,7 @@ import type * as CSS_2 from 'csstype';
10
10
  import type { CSSProperties } from 'react';
11
11
  import type { CSSPropertiesWithMultiValues } from '@emotion/serialize';
12
12
  import { ElementType } from 'react';
13
+ import { FC } from 'react';
13
14
  import { ForwardRefExoticComponent } from 'react';
14
15
  import { jsx } from '@emotion/react';
15
16
  import { MemoExoticComponent } from 'react';
@@ -68,6 +69,12 @@ type AllMedia = '@media (prefers-color-scheme: dark)' | '@media (prefers-color-s
68
69
  // @public (undocumented)
69
70
  type AllowedElements = Exclude<keyof JSX.IntrinsicElements, SVGElements>;
70
71
 
72
+ // @public (undocumented)
73
+ const asAllowlist: readonly ["span", "p", "strong", "em"];
74
+
75
+ // @public (undocumented)
76
+ type AsElement = (typeof asAllowlist)[number];
77
+
71
78
  // @public (undocumented)
72
79
  type AtRulesWithoutMedia = Exclude<CSS_2.AtRules, '@media'>;
73
80
 
@@ -312,6 +319,16 @@ export type BleedProps = {
312
319
  block?: Space_2;
313
320
  } & BasePrimitiveProps;
314
321
 
322
+ // @public (undocumented)
323
+ type BodyText = keyof typeof bodyTextMap;
324
+
325
+ // @public (undocumented)
326
+ const bodyTextMap: {
327
+ body: "var(--ds-font-body)";
328
+ 'body.large': "var(--ds-font-body-large)";
329
+ 'body.small': "var(--ds-font-body-small)";
330
+ };
331
+
315
332
  // @public (undocumented)
316
333
  export type BorderColor = keyof typeof borderColorMap;
317
334
 
@@ -694,6 +711,20 @@ type StyleProp = {
694
711
  // @public (undocumented)
695
712
  type SVGElements = 'animate' | 'animateMotion' | 'animateTransform' | 'circle' | 'clipPath' | 'defs' | 'desc' | 'ellipse' | 'feBlend' | 'feColorMatrix' | 'feComponentTransfer' | 'feComposite' | 'feConvolveMatrix' | 'feDiffuseLighting' | 'feDisplacementMap' | 'feDistantLight' | 'feDropShadow' | 'feFlood' | 'feFuncA' | 'feFuncB' | 'feFuncG' | 'feFuncR' | 'feGaussianBlur' | 'feImage' | 'feMerge' | 'feMergeNode' | 'feMorphology' | 'feOffset' | 'fePointLight' | 'feSpecularLighting' | 'feSpotLight' | 'feTile' | 'feTurbulence' | 'filter' | 'foreignObject' | 'g' | 'image' | 'line' | 'linearGradient' | 'marker' | 'mask' | 'metadata' | 'mpath' | 'path' | 'pattern' | 'polygon' | 'polyline' | 'radialGradient' | 'rect' | 'stop' | 'svg' | 'switch' | 'symbol' | 'text' | 'textPath' | 'tspan' | 'use' | 'view';
696
713
 
714
+ // @internal
715
+ const Text_2: FC<TextProps>;
716
+ export { Text_2 as Text }
717
+
718
+ // @public (undocumented)
719
+ type TextAlign = keyof typeof textAlignMap;
720
+
721
+ // @public (undocumented)
722
+ const textAlignMap: {
723
+ center: SerializedStyles_2;
724
+ end: SerializedStyles_2;
725
+ start: SerializedStyles_2;
726
+ };
727
+
697
728
  // @public (undocumented)
698
729
  export type TextColor = keyof typeof textColorMap;
699
730
 
@@ -737,6 +768,17 @@ const textColorMap: {
737
768
  readonly 'color.link.visited': "var(--ds-link-visited)";
738
769
  };
739
770
 
771
+ // @public (undocumented)
772
+ export interface TextProps extends BasePrimitiveProps {
773
+ as?: AsElement;
774
+ children: ReactNode;
775
+ color?: TextColor;
776
+ id?: string;
777
+ shouldTruncate?: boolean;
778
+ textAlign?: TextAlign;
779
+ variant?: Variant;
780
+ }
781
+
740
782
  // @public (undocumented)
741
783
  type TokenisedProps = {
742
784
  backgroundColor?: BackgroundColor;
@@ -799,6 +841,15 @@ type TokenisedProps = {
799
841
  zIndex?: Layer;
800
842
  };
801
843
 
844
+ // @public (undocumented)
845
+ type UiText = keyof typeof uiTextMap;
846
+
847
+ // @public (undocumented)
848
+ const uiTextMap: {
849
+ ui: "var(--ds-font-ui)";
850
+ 'ui.small': "var(--ds-font-ui-small)";
851
+ };
852
+
802
853
  // @public (undocumented)
803
854
  const uniqueSymbol: unique symbol;
804
855
 
@@ -869,6 +920,9 @@ export const UNSAFE_media: {
869
920
  };
870
921
  };
871
922
 
923
+ // @public (undocumented)
924
+ type Variant = BodyText | UiText;
925
+
872
926
  // @public (undocumented)
873
927
  type Wrap = keyof typeof flexWrapMap;
874
928