@atlaskit/primitives 0.4.2 → 0.6.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/inline.partial.js +23 -91
  3. package/dist/cjs/components/internal/base-box.partial.js +81 -99
  4. package/dist/cjs/components/stack.partial.js +23 -47
  5. package/dist/cjs/internal/xcss.js +16 -4
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/es2019/components/inline.partial.js +19 -63
  8. package/dist/es2019/components/internal/base-box.partial.js +72 -68
  9. package/dist/es2019/components/stack.partial.js +19 -19
  10. package/dist/es2019/internal/xcss.js +9 -2
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/esm/components/inline.partial.js +22 -91
  13. package/dist/esm/components/internal/base-box.partial.js +81 -99
  14. package/dist/esm/components/stack.partial.js +22 -47
  15. package/dist/esm/internal/xcss.js +13 -2
  16. package/dist/esm/version.json +1 -1
  17. package/dist/types/components/box.d.ts +1 -2
  18. package/dist/types/components/inline.partial.d.ts +28 -39
  19. package/dist/types/components/internal/base-box.partial.d.ts +42 -43
  20. package/dist/types/components/stack.partial.d.ts +25 -20
  21. package/dist/types/components/types.d.ts +2 -48
  22. package/dist/types/internal/xcss.d.ts +37 -8
  23. package/package.json +2 -3
  24. package/report.api.md +160 -144
  25. package/scripts/spacing-codegen-template.tsx +30 -30
  26. package/tmp/api-report-tmp.d.ts +124 -130
  27. package/dist/cjs/components/internal/types.js +0 -8
  28. package/dist/cjs/components/internal/utils.js +0 -16
  29. package/dist/es2019/components/internal/types.js +0 -1
  30. package/dist/es2019/components/internal/utils.js +0 -2
  31. package/dist/esm/components/internal/types.js +0 -1
  32. package/dist/esm/components/internal/utils.js +0 -7
  33. package/dist/types/components/internal/types.d.ts +0 -8
  34. package/dist/types/components/internal/utils.d.ts +0 -3
@@ -1,7 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, FC, ReactElement, ReactNode } from 'react';
3
3
  import { Layer } from '../../constants';
4
- import { ResponsiveObject } from '../../helpers/responsive';
5
4
  import type { BasePrimitiveProps } from '../types';
6
5
  export declare type BaseBoxProps<T extends ElementType = 'div'> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & BaseBoxPropsFoundation<T>;
7
6
  declare type BaseBoxPropsFoundation<T extends ElementType> = {
@@ -32,9 +31,7 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
32
31
  */
33
32
  color?: TextColor;
34
33
  /**
35
- * @private
36
- * @deprecated Use `xcss` to achieve this functionality.
37
- * Token representing background color with a fallback.
34
+ * Token representing background color with a built-in fallback value.
38
35
  */
39
36
  backgroundColor?: BackgroundColor;
40
37
  /**
@@ -54,7 +51,7 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
54
51
  * @deprecated Use `xcss` to achieve this functionality.
55
52
  * Defines border width.
56
53
  */
57
- borderWidth?: BorderWidth | ResponsiveObject<BorderWidth>;
54
+ borderWidth?: BorderWidth;
58
55
  /**
59
56
  * @private
60
57
  * @deprecated Use `xcss` to achieve this functionality.
@@ -125,37 +122,37 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
125
122
  * @see paddingBlock
126
123
  * @see paddingInline
127
124
  */
128
- padding?: Padding | ResponsiveObject<Padding>;
125
+ padding?: Padding;
129
126
  /**
130
127
  * Tokens representing CSS shorthand `paddingBlock`.
131
128
  *
132
129
  * @see paddingBlockStart
133
130
  * @see paddingBlockEnd
134
131
  */
135
- paddingBlock?: PaddingBlock | ResponsiveObject<PaddingBlock>;
132
+ paddingBlock?: PaddingBlock;
136
133
  /**
137
134
  * Tokens representing CSS `paddingBlockStart`.
138
135
  */
139
- paddingBlockStart?: PaddingBlockStart | ResponsiveObject<PaddingBlockStart>;
136
+ paddingBlockStart?: PaddingBlockStart;
140
137
  /**
141
138
  * Tokens representing CSS `paddingBlockEnd`.
142
139
  */
143
- paddingBlockEnd?: PaddingBlockEnd | ResponsiveObject<PaddingBlockEnd>;
140
+ paddingBlockEnd?: PaddingBlockEnd;
144
141
  /**
145
142
  * Tokens representing CSS shorthand `paddingInline`.
146
143
  *
147
144
  * @see paddingInlineStart
148
145
  * @see paddingInlineEnd
149
146
  */
150
- paddingInline?: PaddingInline | ResponsiveObject<PaddingInline>;
147
+ paddingInline?: PaddingInline;
151
148
  /**
152
149
  * Tokens representing CSS `paddingInlineStart`.
153
150
  */
154
- paddingInlineStart?: PaddingInlineStart | ResponsiveObject<PaddingInlineStart>;
151
+ paddingInlineStart?: PaddingInlineStart;
155
152
  /**
156
153
  * Tokens representing CSS `paddingInlineEnd`.
157
154
  */
158
- paddingInlineEnd?: PaddingInlineEnd | ResponsiveObject<PaddingInlineEnd>;
155
+ paddingInlineEnd?: PaddingInlineEnd;
159
156
  /**
160
157
  * @private
161
158
  * @deprecated Use `xcss` to achieve this functionality.
@@ -173,7 +170,7 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
173
170
  * @deprecated Use `xcss` to achieve this functionality.
174
171
  * Defines display type and layout. Defaults to `block`.
175
172
  */
176
- display?: Display | ResponsiveObject<Display>;
173
+ display?: Display;
177
174
  /**
178
175
  * @private
179
176
  * @deprecated Use `xcss` to achieve this functionality.
@@ -203,9 +200,9 @@ declare const borderStyleMap: {
203
200
  };
204
201
  export declare type BorderWidth = keyof typeof borderWidthMap;
205
202
  declare const borderWidthMap: {
206
- readonly 'size.0': "var(--ds-width-0)";
207
- readonly 'size.050': "var(--ds-width-050)";
208
- readonly 'size.100': "var(--ds-width-100)";
203
+ readonly 'size.0': import("@emotion/react").SerializedStyles;
204
+ readonly 'size.050': import("@emotion/react").SerializedStyles;
205
+ readonly 'size.100': import("@emotion/react").SerializedStyles;
209
206
  };
210
207
  declare type BorderRadius = keyof typeof borderRadiusMap;
211
208
  declare const borderRadiusMap: {
@@ -239,11 +236,11 @@ declare const alignSelfMap: {
239
236
  };
240
237
  export declare type Display = keyof typeof displayMap;
241
238
  declare const displayMap: {
242
- readonly block: "block";
243
- readonly inline: "inline";
244
- readonly flex: "flex";
245
- readonly 'inline-flex': "inline-flex";
246
- readonly 'inline-block': "inline-block";
239
+ readonly block: import("@emotion/react").SerializedStyles;
240
+ readonly inline: import("@emotion/react").SerializedStyles;
241
+ readonly flex: import("@emotion/react").SerializedStyles;
242
+ readonly 'inline-flex': import("@emotion/react").SerializedStyles;
243
+ readonly 'inline-block': import("@emotion/react").SerializedStyles;
247
244
  };
248
245
  declare type Position = keyof typeof positionMap;
249
246
  declare const positionMap: {
@@ -345,35 +342,37 @@ export declare type MaxHeight = keyof typeof maxHeightMap;
345
342
  */
346
343
  /**
347
344
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
348
- * @codegen <<SignedSource::84fd352b0e6509d380a0dcf8ad023ca2>>
345
+ * @codegen <<SignedSource::6da0ceaa2c227230e3a93bc724ff8648>>
349
346
  * @codegenId spacing
350
347
  * @codegenCommand yarn codegen-styles
351
348
  * @codegenParams ["padding"]
352
349
  * @codegenDependency ../../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
353
350
  */
354
351
  declare const paddingMap: {
355
- readonly 'space.0': "var(--ds-space-0)";
356
- readonly 'space.025': "var(--ds-space-025)";
357
- readonly 'space.050': "var(--ds-space-050)";
358
- readonly 'space.075': "var(--ds-space-075)";
359
- readonly 'space.100': "var(--ds-space-100)";
360
- readonly 'space.150': "var(--ds-space-150)";
361
- readonly 'space.200': "var(--ds-space-200)";
362
- readonly 'space.250': "var(--ds-space-250)";
363
- readonly 'space.300': "var(--ds-space-300)";
364
- readonly 'space.400': "var(--ds-space-400)";
365
- readonly 'space.500': "var(--ds-space-500)";
366
- readonly 'space.600': "var(--ds-space-600)";
367
- readonly 'space.800': "var(--ds-space-800)";
368
- readonly 'space.1000': "var(--ds-space-1000)";
352
+ [k: string]: {
353
+ readonly 'space.0': import("@emotion/react").SerializedStyles;
354
+ readonly 'space.025': import("@emotion/react").SerializedStyles;
355
+ readonly 'space.050': import("@emotion/react").SerializedStyles;
356
+ readonly 'space.075': import("@emotion/react").SerializedStyles;
357
+ readonly 'space.100': import("@emotion/react").SerializedStyles;
358
+ readonly 'space.150': import("@emotion/react").SerializedStyles;
359
+ readonly 'space.200': import("@emotion/react").SerializedStyles;
360
+ readonly 'space.250': import("@emotion/react").SerializedStyles;
361
+ readonly 'space.300': import("@emotion/react").SerializedStyles;
362
+ readonly 'space.400': import("@emotion/react").SerializedStyles;
363
+ readonly 'space.500': import("@emotion/react").SerializedStyles;
364
+ readonly 'space.600': import("@emotion/react").SerializedStyles;
365
+ readonly 'space.800': import("@emotion/react").SerializedStyles;
366
+ readonly 'space.1000': import("@emotion/react").SerializedStyles;
367
+ };
369
368
  };
370
- export declare type Padding = keyof typeof paddingMap;
371
- export declare type PaddingBlock = keyof typeof paddingMap;
372
- export declare type PaddingBlockStart = keyof typeof paddingMap;
373
- export declare type PaddingBlockEnd = keyof typeof paddingMap;
374
- export declare type PaddingInline = keyof typeof paddingMap;
375
- export declare type PaddingInlineStart = keyof typeof paddingMap;
376
- export declare type PaddingInlineEnd = keyof typeof paddingMap;
369
+ export declare type Padding = keyof typeof paddingMap.padding;
370
+ export declare type PaddingBlock = keyof typeof paddingMap.paddingBlock;
371
+ export declare type PaddingBlockStart = keyof typeof paddingMap.paddingBlockStart;
372
+ export declare type PaddingBlockEnd = keyof typeof paddingMap.paddingBlockEnd;
373
+ export declare type PaddingInline = keyof typeof paddingMap.paddingInline;
374
+ export declare type PaddingInlineStart = keyof typeof paddingMap.paddingInlineStart;
375
+ export declare type PaddingInlineEnd = keyof typeof paddingMap.paddingInlineEnd;
377
376
  /**
378
377
  * @codegenEnd
379
378
  */
@@ -24,7 +24,7 @@ export interface StackProps<T extends ElementType = 'div'> {
24
24
  /**
25
25
  * Represents the space between each child.
26
26
  */
27
- space?: Space;
27
+ space?: Gap;
28
28
  /**
29
29
  * A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests.
30
30
  */
@@ -33,6 +33,9 @@ export interface StackProps<T extends ElementType = 'div'> {
33
33
  * Elements to be rendered inside the Stack.
34
34
  */
35
35
  children: ReactNode;
36
+ /**
37
+ * Forwarded ref element
38
+ */
36
39
  ref?: ComponentPropsWithRef<T>['ref'];
37
40
  }
38
41
  export declare type AlignInline = 'start' | 'center' | 'end';
@@ -41,29 +44,31 @@ export declare type Spread = 'space-between';
41
44
  export declare type Grow = 'hug' | 'fill';
42
45
  /**
43
46
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
44
- * @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
47
+ * @codegen <<SignedSource::4eb2c996d6ce5791acad51e2b226635f>>
45
48
  * @codegenId spacing
46
49
  * @codegenCommand yarn codegen-styles
47
- * @codegenParams ["space"]
50
+ * @codegenParams ["stackSpace"]
48
51
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
49
52
  */
50
- declare const spaceMap: {
51
- readonly '0': import("@emotion/react").SerializedStyles;
52
- readonly '025': import("@emotion/react").SerializedStyles;
53
- readonly '050': import("@emotion/react").SerializedStyles;
54
- readonly '075': import("@emotion/react").SerializedStyles;
55
- readonly '100': import("@emotion/react").SerializedStyles;
56
- readonly '150': import("@emotion/react").SerializedStyles;
57
- readonly '200': import("@emotion/react").SerializedStyles;
58
- readonly '250': import("@emotion/react").SerializedStyles;
59
- readonly '300': import("@emotion/react").SerializedStyles;
60
- readonly '400': import("@emotion/react").SerializedStyles;
61
- readonly '500': import("@emotion/react").SerializedStyles;
62
- readonly '600': import("@emotion/react").SerializedStyles;
63
- readonly '800': import("@emotion/react").SerializedStyles;
64
- readonly '1000': import("@emotion/react").SerializedStyles;
53
+ declare const stackSpaceMap: {
54
+ [k: string]: {
55
+ readonly '0': import("@emotion/react").SerializedStyles;
56
+ readonly '025': import("@emotion/react").SerializedStyles;
57
+ readonly '050': import("@emotion/react").SerializedStyles;
58
+ readonly '075': import("@emotion/react").SerializedStyles;
59
+ readonly '100': import("@emotion/react").SerializedStyles;
60
+ readonly '150': import("@emotion/react").SerializedStyles;
61
+ readonly '200': import("@emotion/react").SerializedStyles;
62
+ readonly '250': import("@emotion/react").SerializedStyles;
63
+ readonly '300': import("@emotion/react").SerializedStyles;
64
+ readonly '400': import("@emotion/react").SerializedStyles;
65
+ readonly '500': import("@emotion/react").SerializedStyles;
66
+ readonly '600': import("@emotion/react").SerializedStyles;
67
+ readonly '800': import("@emotion/react").SerializedStyles;
68
+ readonly '1000': import("@emotion/react").SerializedStyles;
69
+ };
65
70
  };
66
- export declare type Space = keyof typeof spaceMap;
71
+ export declare type Gap = keyof typeof stackSpaceMap.gap;
67
72
  /**
68
73
  * __Stack__
69
74
  *
@@ -78,5 +83,5 @@ export declare type Space = keyof typeof spaceMap;
78
83
  * ```
79
84
  *
80
85
  */
81
- declare const Stack: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<StackProps<ElementType<any>>, "space" | "as" | "children" | "testId" | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
86
+ declare const Stack: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<StackProps<ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "spread" | "grow" | "space"> & import("react").RefAttributes<any>>>;
82
87
  export default Stack;
@@ -1,6 +1,5 @@
1
1
  import type { CSSProperties } from 'react';
2
- import type { SafeCSS } from '../internal/xcss';
3
- import type { BorderWidth, Display, Padding, PaddingBlock, PaddingBlockEnd, PaddingBlockStart, PaddingInline, PaddingInlineEnd, PaddingInlineStart } from './internal/base-box.partial';
2
+ import { type BoxXCSS } from '../internal/xcss';
4
3
  export declare type BasePrimitiveProps = {
5
4
  /**
6
5
  * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
@@ -12,53 +11,8 @@ export declare type BasePrimitiveProps = {
12
11
  style?: CSSProperties;
13
12
  };
14
13
  export declare type PublicBoxPropsBase = {
15
- /**
16
- * Defines border width.
17
- */
18
- borderWidth?: BorderWidth;
19
- /**
20
- * Defines display type and layout. Defaults to `block`.
21
- */
22
- display?: Display;
23
- /**
24
- * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
25
- *
26
- * @see paddingBlock
27
- * @see paddingInline
28
- */
29
- padding?: Padding;
30
- /**
31
- * Tokens representing CSS shorthand `paddingBlock`.
32
- *
33
- * @see paddingBlockStart
34
- * @see paddingBlockEnd
35
- */
36
- paddingBlock?: PaddingBlock;
37
- /**
38
- * Tokens representing CSS `paddingBlockStart`.
39
- */
40
- paddingBlockStart?: PaddingBlockStart;
41
- /**
42
- * Tokens representing CSS `paddingBlockEnd`.
43
- */
44
- paddingBlockEnd?: PaddingBlockEnd;
45
- /**
46
- * Tokens representing CSS shorthand `paddingInline`.
47
- *
48
- * @see paddingInlineStart
49
- * @see paddingInlineEnd
50
- */
51
- paddingInline?: PaddingInline;
52
- /**
53
- * Tokens representing CSS `paddingInlineStart`.
54
- */
55
- paddingInlineStart?: PaddingInlineStart;
56
- /**
57
- * Tokens representing CSS `paddingInlineEnd`.
58
- */
59
- paddingInlineEnd?: PaddingInlineEnd;
60
14
  /**
61
15
  * Safe subset of styles that can be applied as a classname.
62
16
  */
63
- xcss?: SafeCSS;
17
+ xcss?: BoxXCSS;
64
18
  };
@@ -1,5 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { css as cssEmotion } from '@emotion/react';
2
- import { CSSObject, CSSPropertiesWithMultiValues, CSSPseudos } from '@emotion/serialize';
3
+ import { CSSObject, CSSPropertiesWithMultiValues, CSSPseudos, SerializedStyles } from '@emotion/serialize';
4
+ import { Box, Inline } from '../index';
3
5
  import { TokenisedProps } from './style-maps';
4
6
  declare const uniqueSymbol: unique symbol;
5
7
  /**
@@ -7,16 +9,43 @@ declare const uniqueSymbol: unique symbol;
7
9
  * @internal
8
10
  */
9
11
  export declare const transformStyles: (styleObj?: CSSObject | CSSObject[] | undefined) => CSSObject | CSSObject[] | undefined;
10
- declare type XCSS = ReturnType<typeof xcss>;
11
- export declare type SafeCSS = XCSS | XCSS[];
12
- export declare type SafeCSSObject = CSSPseudos & TokenisedProps & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
13
- export declare const xcss: (style?: SafeCSSObject | SafeCSSObject[] | undefined) => {
14
- readonly symbol: typeof uniqueSymbol;
15
- readonly styles: import("@emotion/react").SerializedStyles;
16
- };
17
12
  /**
18
13
  * @internal used in primitives
19
14
  * @returns
20
15
  */
21
16
  export declare const parseXcss: (args: SafeCSS) => ReturnType<typeof cssEmotion>;
17
+ declare type SafeCSSObject = CSSPseudos & TokenisedProps & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
18
+ declare type ScopedSafeCSSObject<T extends keyof SafeCSSObject> = Pick<SafeCSSObject, T>;
19
+ declare const boxWrapper: (style: any) => {
20
+ readonly symbol: typeof uniqueSymbol;
21
+ readonly styles: BoxStyles;
22
+ };
23
+ declare const inlineWrapper: (style: any) => {
24
+ readonly symbol: typeof uniqueSymbol;
25
+ readonly styles: InlineStyles;
26
+ };
27
+ declare type XCSS = ReturnType<typeof boxWrapper> | ReturnType<typeof inlineWrapper>;
28
+ declare type SafeCSS = XCSS | XCSS[];
29
+ declare type AllowedBoxStyles = keyof SafeCSSObject;
30
+ declare type AllowedInlineStyles = 'backgroundColor' | 'padding';
31
+ export declare function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> : Primitive extends typeof Inline ? ScopedSafeCSSObject<AllowedInlineStyles> : never): {
32
+ readonly symbol: typeof uniqueSymbol;
33
+ readonly styles: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>> ? InlineStyles : never;
34
+ };
35
+ declare const boxTag: unique symbol;
36
+ export declare type BoxStyles = SerializedStyles & {
37
+ [boxTag]: true;
38
+ };
39
+ export declare type BoxXCSS = {
40
+ readonly symbol: typeof uniqueSymbol;
41
+ readonly styles: BoxStyles;
42
+ };
43
+ declare const inlineTag: unique symbol;
44
+ export declare type InlineStyles = SerializedStyles & {
45
+ [inlineTag]: true;
46
+ };
47
+ export declare type InlineXCSS = {
48
+ readonly symbol: typeof uniqueSymbol;
49
+ readonly styles: InlineStyles;
50
+ };
22
51
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,8 +41,7 @@
41
41
  "@atlaskit/tokens": "^1.2.0",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "@emotion/react": "^11.7.1",
44
- "@emotion/serialize": "^1.1.0",
45
- "tiny-invariant": "^1.2.0"
44
+ "@emotion/serialize": "^1.1.0"
46
45
  },
47
46
  "peerDependencies": {
48
47
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"