@atlaskit/primitives 1.8.0 → 1.10.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,17 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ ## 1.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#42494](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42494) [`8cc2926465e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2926465e) - Removed the ability to use the `style` prop on primitives such as Inline, Stack, and Flex. This prop previously had no effect on these components and is now only allowed on Box.
14
+
3
15
  ## 1.8.0
4
16
 
5
17
  ### Minor Changes
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");
@@ -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';
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';
@@ -2,12 +2,12 @@
2
2
  import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
3
3
  import { BackgroundColor, type Space } from '../xcss/style-maps.partial';
4
4
  import { SVGElements } from './internal/types';
5
- import type { BasePrimitiveProps } from './types';
5
+ import type { BasePrimitiveProps, StyleProp } from './types';
6
6
  type AllowedElements = Exclude<keyof JSX.IntrinsicElements, SVGElements>;
7
7
  type CustomElementType<P = any> = {
8
8
  [K in AllowedElements]: P extends JSX.IntrinsicElements[K] ? K : never;
9
9
  }[AllowedElements];
10
- export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & BaseBoxProps<T>;
10
+ export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & StyleProp & BaseBoxProps<T>;
11
11
  type BaseBoxProps<T extends CustomElementType> = {
12
12
  /**
13
13
  * The DOM element to render as the Box. Defaults to `div`.
@@ -5,11 +5,6 @@ export type BasePrimitiveProps = {
5
5
  * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
6
6
  */
7
7
  testId?: string;
8
- /**
9
- * Inline styles to be applied to the primitive. Only apply as a last resort, or where
10
- * styles cannot otherwise be calculated outside of the runtime of the component they're applied.
11
- */
12
- style?: CSSProperties;
13
8
  /**
14
9
  * Apply a subset of permitted styles, powered by Atlassian Design System tokens.
15
10
  */
@@ -19,6 +14,13 @@ export type BasePrimitiveProps = {
19
14
  */
20
15
  role?: string;
21
16
  };
17
+ export type StyleProp = {
18
+ /**
19
+ * Inline styles to be applied to the primitive. Only apply as a last resort, or where
20
+ * styles cannot otherwise be calculated outside of the runtime of the component they're applied.
21
+ */
22
+ style?: CSSProperties;
23
+ };
22
24
  export type AlignInline = 'start' | 'center' | 'end' | 'stretch';
23
25
  export type AlignBlock = 'start' | 'center' | 'end' | 'baseline' | 'stretch';
24
26
  export type Spread = 'space-between';
@@ -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';
@@ -2,12 +2,12 @@
2
2
  import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
3
3
  import { BackgroundColor, type Space } from '../xcss/style-maps.partial';
4
4
  import { SVGElements } from './internal/types';
5
- import type { BasePrimitiveProps } from './types';
5
+ import type { BasePrimitiveProps, StyleProp } from './types';
6
6
  type AllowedElements = Exclude<keyof JSX.IntrinsicElements, SVGElements>;
7
7
  type CustomElementType<P = any> = {
8
8
  [K in AllowedElements]: P extends JSX.IntrinsicElements[K] ? K : never;
9
9
  }[AllowedElements];
10
- export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & BaseBoxProps<T>;
10
+ export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & StyleProp & BaseBoxProps<T>;
11
11
  type BaseBoxProps<T extends CustomElementType> = {
12
12
  /**
13
13
  * The DOM element to render as the Box. Defaults to `div`.
@@ -5,11 +5,6 @@ export type BasePrimitiveProps = {
5
5
  * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
6
6
  */
7
7
  testId?: string;
8
- /**
9
- * Inline styles to be applied to the primitive. Only apply as a last resort, or where
10
- * styles cannot otherwise be calculated outside of the runtime of the component they're applied.
11
- */
12
- style?: CSSProperties;
13
8
  /**
14
9
  * Apply a subset of permitted styles, powered by Atlassian Design System tokens.
15
10
  */
@@ -19,6 +14,13 @@ export type BasePrimitiveProps = {
19
14
  */
20
15
  role?: string;
21
16
  };
17
+ export type StyleProp = {
18
+ /**
19
+ * Inline styles to be applied to the primitive. Only apply as a last resort, or where
20
+ * styles cannot otherwise be calculated outside of the runtime of the component they're applied.
21
+ */
22
+ style?: CSSProperties;
23
+ };
22
24
  export type AlignInline = 'start' | 'center' | 'end' | 'stretch';
23
25
  export type AlignBlock = 'start' | 'center' | 'end' | 'baseline' | 'stretch';
24
26
  export type Spread = 'space-between';
@@ -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';
@@ -1,7 +1,7 @@
1
1
  // TODO: Switch from ERT to ts-morph when this is completed and has reasonable adoption: https://product-fabric.atlassian.net/browse/DSP-10364
2
2
  import React, { ElementType, ReactNode } from 'react';
3
3
 
4
- import { BasePrimitiveProps } from '../src/components/types';
4
+ import { BasePrimitiveProps, StyleProp } from '../src/components/types';
5
5
 
6
6
  // eslint-disable-next-line @typescript-eslint/no-namespace
7
7
  namespace Token {
@@ -84,5 +84,6 @@ export default function Box(
84
84
  * Forwarded ref element.
85
85
  */
86
86
  ref?: React.ComponentPropsWithRef<ElementType>['ref'];
87
- } & BasePrimitiveProps,
87
+ } & BasePrimitiveProps &
88
+ StyleProp,
88
89
  ) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
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
 
@@ -313,7 +320,6 @@ type BaseBoxProps<T extends CustomElementType> = {
313
320
  // @public (undocumented)
314
321
  type BasePrimitiveProps = {
315
322
  testId?: string;
316
- style?: CSSProperties;
317
323
  xcss?: Array<XCSS | false | undefined> | XCSS;
318
324
  role?: string;
319
325
  };
@@ -338,6 +344,16 @@ export type BleedProps = {
338
344
  block?: Space_2;
339
345
  } & BasePrimitiveProps;
340
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
+
341
357
  // @public (undocumented)
342
358
  export type BorderColor = keyof typeof borderColorMap;
343
359
 
@@ -407,6 +423,7 @@ export type BoxProps<T extends CustomElementType> = Omit<
407
423
  'as' | 'className'
408
424
  > &
409
425
  BasePrimitiveProps &
426
+ StyleProp &
410
427
  BaseBoxProps<T>;
411
428
 
412
429
  // @public
@@ -974,6 +991,11 @@ export type StackProps<T extends ElementType = 'div'> = {
974
991
  ref?: React.ComponentPropsWithRef<T>['ref'];
975
992
  } & BasePrimitiveProps;
976
993
 
994
+ // @public (undocumented)
995
+ type StyleProp = {
996
+ style?: CSSProperties;
997
+ };
998
+
977
999
  // @public (undocumented)
978
1000
  type SVGElements =
979
1001
  | 'animate'
@@ -1035,6 +1057,20 @@ type SVGElements =
1035
1057
  | 'use'
1036
1058
  | 'view';
1037
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
+
1038
1074
  // @public (undocumented)
1039
1075
  export type TextColor = keyof typeof textColorMap;
1040
1076
 
@@ -1078,6 +1114,17 @@ const textColorMap: {
1078
1114
  readonly 'color.link.visited': 'var(--ds-link-visited)';
1079
1115
  };
1080
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
+
1081
1128
  // @public (undocumented)
1082
1129
  type TokenisedProps = {
1083
1130
  backgroundColor?: BackgroundColor;
@@ -1140,6 +1187,15 @@ type TokenisedProps = {
1140
1187
  zIndex?: Layer;
1141
1188
  };
1142
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
+
1143
1199
  // @public (undocumented)
1144
1200
  const uniqueSymbol: unique symbol;
1145
1201
 
@@ -1210,6 +1266,9 @@ export const UNSAFE_media: {
1210
1266
  };
1211
1267
  };
1212
1268
 
1269
+ // @public (undocumented)
1270
+ type Variant = BodyText | UiText;
1271
+
1213
1272
  // @public (undocumented)
1214
1273
  type Wrap = keyof typeof flexWrapMap;
1215
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
 
@@ -297,7 +304,6 @@ type BaseBoxProps<T extends CustomElementType> = {
297
304
  // @public (undocumented)
298
305
  type BasePrimitiveProps = {
299
306
  testId?: string;
300
- style?: CSSProperties;
301
307
  xcss?: Array<XCSS | false | undefined> | XCSS;
302
308
  role?: string;
303
309
  };
@@ -313,6 +319,16 @@ export type BleedProps = {
313
319
  block?: Space_2;
314
320
  } & BasePrimitiveProps;
315
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
+
316
332
  // @public (undocumented)
317
333
  export type BorderColor = keyof typeof borderColorMap;
318
334
 
@@ -375,7 +391,7 @@ export const Box: BoxComponent;
375
391
  type BoxComponent = <T extends CustomElementType>(props: BoxProps<T>) => ReactElement | null;
376
392
 
377
393
  // @public (undocumented)
378
- export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & BaseBoxProps<T>;
394
+ export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & StyleProp & BaseBoxProps<T>;
379
395
 
380
396
  // @public
381
397
  export type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | 'xxs';
@@ -687,9 +703,28 @@ export type StackProps<T extends ElementType = 'div'> = {
687
703
  ref?: React.ComponentPropsWithRef<T>['ref'];
688
704
  } & BasePrimitiveProps;
689
705
 
706
+ // @public (undocumented)
707
+ type StyleProp = {
708
+ style?: CSSProperties;
709
+ };
710
+
690
711
  // @public (undocumented)
691
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';
692
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
+
693
728
  // @public (undocumented)
694
729
  export type TextColor = keyof typeof textColorMap;
695
730
 
@@ -733,6 +768,17 @@ const textColorMap: {
733
768
  readonly 'color.link.visited': "var(--ds-link-visited)";
734
769
  };
735
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
+
736
782
  // @public (undocumented)
737
783
  type TokenisedProps = {
738
784
  backgroundColor?: BackgroundColor;
@@ -795,6 +841,15 @@ type TokenisedProps = {
795
841
  zIndex?: Layer;
796
842
  };
797
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
+
798
853
  // @public (undocumented)
799
854
  const uniqueSymbol: unique symbol;
800
855
 
@@ -865,6 +920,9 @@ export const UNSAFE_media: {
865
920
  };
866
921
  };
867
922
 
923
+ // @public (undocumented)
924
+ type Variant = BodyText | UiText;
925
+
868
926
  // @public (undocumented)
869
927
  type Wrap = keyof typeof flexWrapMap;
870
928