@atlaskit/primitives 0.2.0 → 0.2.2

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 (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/box.js +14 -2
  3. package/dist/cjs/components/inline.partial.js +47 -23
  4. package/dist/cjs/components/internal/base-box.partial.js +99 -78
  5. package/dist/cjs/components/internal/types.js +8 -0
  6. package/dist/cjs/components/internal/utils.js +16 -0
  7. package/dist/cjs/components/stack.partial.js +46 -22
  8. package/dist/cjs/constants.js +13 -0
  9. package/dist/cjs/index.js +2 -2
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/components/box.js +12 -1
  12. package/dist/es2019/components/inline.partial.js +19 -19
  13. package/dist/es2019/components/internal/base-box.partial.js +75 -70
  14. package/dist/es2019/components/internal/types.js +1 -0
  15. package/dist/es2019/components/internal/utils.js +2 -0
  16. package/dist/es2019/components/stack.partial.js +18 -18
  17. package/dist/es2019/constants.js +3 -1
  18. package/dist/es2019/index.js +1 -1
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/components/box.js +12 -1
  21. package/dist/esm/components/inline.partial.js +47 -22
  22. package/dist/esm/components/internal/base-box.partial.js +100 -79
  23. package/dist/esm/components/internal/types.js +1 -0
  24. package/dist/esm/components/internal/utils.js +7 -0
  25. package/dist/esm/components/stack.partial.js +46 -21
  26. package/dist/esm/constants.js +3 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/components/box.d.ts +13 -6
  30. package/dist/types/components/inline.partial.d.ts +16 -18
  31. package/dist/types/components/internal/base-box.partial.d.ts +50 -51
  32. package/dist/types/components/internal/types.d.ts +6 -0
  33. package/dist/types/components/internal/utils.d.ts +3 -0
  34. package/dist/types/components/stack.partial.d.ts +16 -18
  35. package/dist/types/components/types.d.ts +49 -0
  36. package/dist/types/constants.d.ts +2 -0
  37. package/dist/types/index.d.ts +1 -1
  38. package/package.json +4 -2
  39. package/report.api.md +112 -79
  40. package/scripts/spacing-codegen-template.tsx +29 -24
  41. package/scripts/utils.tsx +4 -1
  42. package/tmp/api-report-tmp.d.ts +89 -78
@@ -36,31 +36,29 @@ export declare type Spread = 'space-between';
36
36
  export declare type Grow = 'hug' | 'fill';
37
37
  /**
38
38
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
39
- * @codegen <<SignedSource::0e30ffcc6aef7932f9d8ff2543327236>>
39
+ * @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
40
40
  * @codegenId spacing
41
41
  * @codegenCommand yarn codegen-styles
42
42
  * @codegenParams ["space"]
43
43
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
44
44
  */
45
45
  declare const spaceMap: {
46
- [k: string]: {
47
- readonly '0': import("@emotion/react").SerializedStyles;
48
- readonly '025': import("@emotion/react").SerializedStyles;
49
- readonly '050': import("@emotion/react").SerializedStyles;
50
- readonly '075': import("@emotion/react").SerializedStyles;
51
- readonly '100': import("@emotion/react").SerializedStyles;
52
- readonly '150': import("@emotion/react").SerializedStyles;
53
- readonly '200': import("@emotion/react").SerializedStyles;
54
- readonly '250': import("@emotion/react").SerializedStyles;
55
- readonly '300': import("@emotion/react").SerializedStyles;
56
- readonly '400': import("@emotion/react").SerializedStyles;
57
- readonly '500': import("@emotion/react").SerializedStyles;
58
- readonly '600': import("@emotion/react").SerializedStyles;
59
- readonly '800': import("@emotion/react").SerializedStyles;
60
- readonly '1000': import("@emotion/react").SerializedStyles;
61
- };
46
+ readonly '0': import("@emotion/react").SerializedStyles;
47
+ readonly '025': import("@emotion/react").SerializedStyles;
48
+ readonly '050': import("@emotion/react").SerializedStyles;
49
+ readonly '075': import("@emotion/react").SerializedStyles;
50
+ readonly '100': import("@emotion/react").SerializedStyles;
51
+ readonly '150': import("@emotion/react").SerializedStyles;
52
+ readonly '200': import("@emotion/react").SerializedStyles;
53
+ readonly '250': import("@emotion/react").SerializedStyles;
54
+ readonly '300': import("@emotion/react").SerializedStyles;
55
+ readonly '400': import("@emotion/react").SerializedStyles;
56
+ readonly '500': import("@emotion/react").SerializedStyles;
57
+ readonly '600': import("@emotion/react").SerializedStyles;
58
+ readonly '800': import("@emotion/react").SerializedStyles;
59
+ readonly '1000': import("@emotion/react").SerializedStyles;
62
60
  };
63
- export declare type Space = keyof typeof spaceMap.gap;
61
+ export declare type Space = keyof typeof spaceMap;
64
62
  /**
65
63
  * __Stack__
66
64
  *
@@ -1,4 +1,5 @@
1
1
  import type { CSSProperties } from 'react';
2
+ import { BorderWidth, Display, Padding, PaddingBlock, PaddingBlockEnd, PaddingBlockStart, PaddingInline, PaddingInlineEnd, PaddingInlineStart } from './internal/base-box.partial';
2
3
  /**
3
4
  * Restricted set of inline styles to be applied to the primitive.
4
5
  * Should be avoided where possible, in favor of the pre-defined props and values on the primitive itself.
@@ -18,3 +19,51 @@ export interface BasePrimitiveProps {
18
19
  */
19
20
  UNSAFE_style?: CSSProperties;
20
21
  }
22
+ export declare type PublicBoxPropsBase = {
23
+ /**
24
+ * Defines border width.
25
+ */
26
+ borderWidth?: BorderWidth;
27
+ /**
28
+ * Defines display type and layout. Defaults to `block`.
29
+ */
30
+ display?: Display;
31
+ /**
32
+ * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
33
+ *
34
+ * @see paddingBlock
35
+ * @see paddingInline
36
+ */
37
+ padding?: Padding;
38
+ /**
39
+ * Tokens representing CSS shorthand `paddingBlock`.
40
+ *
41
+ * @see paddingBlockStart
42
+ * @see paddingBlockEnd
43
+ */
44
+ paddingBlock?: PaddingBlock;
45
+ /**
46
+ * Tokens representing CSS `paddingBlockStart`.
47
+ */
48
+ paddingBlockStart?: PaddingBlockStart;
49
+ /**
50
+ * Tokens representing CSS `paddingBlockEnd`.
51
+ */
52
+ paddingBlockEnd?: PaddingBlockEnd;
53
+ /**
54
+ * Tokens representing CSS shorthand `paddingInline`.
55
+ *
56
+ * @see paddingInlineStart
57
+ * @see paddingInlineEnd
58
+ */
59
+ paddingInline?: PaddingInline;
60
+ /**
61
+ * Tokens representing CSS `paddingInlineStart`.
62
+ */
63
+ paddingInlineStart?: PaddingInlineStart;
64
+ /**
65
+ * Tokens representing CSS `paddingInlineEnd`.
66
+ */
67
+ paddingInlineEnd?: PaddingInlineEnd;
68
+ customStyles?: CustomStyles;
69
+ };
@@ -1,3 +1,4 @@
1
+ import { UNSAFE_Breakpoint as Breakpoint, UNSAFE_BreakpointConfig as BreakpointConfig, UNSAFE_BREAKPOINTS_CONFIG as BREAKPOINTS_CONFIG, UNSAFE_BREAKPOINTS_LIST as BREAKPOINTS_LIST } from '@atlaskit/ds-explorations';
1
2
  export declare const LAYERS: {
2
3
  readonly card: 100;
3
4
  readonly navigation: 200;
@@ -10,3 +11,4 @@ export declare const LAYERS: {
10
11
  readonly tooltip: 800;
11
12
  };
12
13
  export declare type Layer = keyof typeof LAYERS;
14
+ export { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, type Breakpoint, type BreakpointConfig, };
@@ -1,3 +1,3 @@
1
- export { Box, type BoxProps } from './components/box';
1
+ export { default as Box, type BoxProps } from './components/box';
2
2
  export { default as Inline, type InlineProps, } from './components/inline.partial';
3
3
  export { default as Stack, type StackProps } from './components/stack.partial';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,9 +37,11 @@
37
37
  "./inline": "./src/components/inline.partial.tsx"
38
38
  },
39
39
  "dependencies": {
40
+ "@atlaskit/ds-explorations": "*",
40
41
  "@atlaskit/tokens": "^1.2.0",
41
42
  "@babel/runtime": "^7.0.0",
42
- "@emotion/react": "^11.7.1"
43
+ "@emotion/react": "^11.7.1",
44
+ "tiny-invariant": "^1.2.0"
43
45
  },
44
46
  "peerDependencies": {
45
47
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
package/report.api.md CHANGED
@@ -26,6 +26,7 @@ import { ReactElement } from 'react';
26
26
  import { ReactNode } from 'react';
27
27
  import { RefAttributes } from 'react';
28
28
  import { SerializedStyles } from '@emotion/react';
29
+ import { UNSAFE_Breakpoint } from '@atlaskit/ds-explorations';
29
30
 
30
31
  // @public (undocumented)
31
32
  type AlignBlock = 'baseline' | 'center' | 'end' | 'start';
@@ -137,7 +138,7 @@ type BaseBoxPropsFoundation<T extends ElementType> = {
137
138
  backgroundColor?: BackgroundColor;
138
139
  shadow?: Shadow;
139
140
  borderStyle?: BorderStyle;
140
- borderWidth?: BorderWidth;
141
+ borderWidth?: BorderWidth | Partial<Record<UNSAFE_Breakpoint, BorderWidth>>;
141
142
  borderColor?: BorderColor;
142
143
  borderRadius?: BorderRadius;
143
144
  layer?: Layer;
@@ -148,16 +149,28 @@ type BaseBoxPropsFoundation<T extends ElementType> = {
148
149
  overflow?: Overflow;
149
150
  overflowInline?: OverflowInline;
150
151
  overflowBlock?: OverflowBlock;
151
- padding?: Padding;
152
- paddingBlock?: PaddingBlock;
153
- paddingBlockStart?: PaddingBlockStart;
154
- paddingBlockEnd?: PaddingBlockEnd;
155
- paddingInline?: PaddingInline;
156
- paddingInlineStart?: PaddingInlineStart;
157
- paddingInlineEnd?: PaddingInlineEnd;
152
+ padding?: Padding | Partial<Record<UNSAFE_Breakpoint, Padding>>;
153
+ paddingBlock?:
154
+ | PaddingBlock
155
+ | Partial<Record<UNSAFE_Breakpoint, PaddingBlock>>;
156
+ paddingBlockStart?:
157
+ | PaddingBlockStart
158
+ | Partial<Record<UNSAFE_Breakpoint, PaddingBlockStart>>;
159
+ paddingBlockEnd?:
160
+ | PaddingBlockEnd
161
+ | Partial<Record<UNSAFE_Breakpoint, PaddingBlockEnd>>;
162
+ paddingInline?:
163
+ | PaddingInline
164
+ | Partial<Record<UNSAFE_Breakpoint, PaddingInline>>;
165
+ paddingInlineStart?:
166
+ | PaddingInlineStart
167
+ | Partial<Record<UNSAFE_Breakpoint, PaddingInlineStart>>;
168
+ paddingInlineEnd?:
169
+ | PaddingInlineEnd
170
+ | Partial<Record<UNSAFE_Breakpoint, PaddingInlineEnd>>;
158
171
  width?: Width;
159
172
  height?: Height;
160
- display?: Display;
173
+ display?: Display | Partial<Record<UNSAFE_Breakpoint, Display>>;
161
174
  position?: Position;
162
175
  ref?: ComponentPropsWithRef<T>['ref'];
163
176
  };
@@ -223,13 +236,27 @@ type BorderWidth = keyof typeof borderWidthMap;
223
236
 
224
237
  // @public (undocumented)
225
238
  const borderWidthMap: {
226
- readonly 'size.050': SerializedStyles;
227
- readonly 'size.100': SerializedStyles;
239
+ readonly 'size.0': 'var(--ds-width-0)';
240
+ readonly 'size.050': 'var(--ds-width-050)';
241
+ readonly 'size.100': 'var(--ds-width-100)';
228
242
  };
229
243
 
230
- // @public (undocumented)
244
+ // @public
231
245
  export const Box: BoxComponent;
232
246
 
247
+ // @public (undocumented)
248
+ const BOX_RESPONSIVE_PROPS: readonly [
249
+ 'borderWidth',
250
+ 'display',
251
+ 'padding',
252
+ 'paddingBlock',
253
+ 'paddingBlockStart',
254
+ 'paddingBlockEnd',
255
+ 'paddingInline',
256
+ 'paddingInlineStart',
257
+ 'paddingInlineEnd',
258
+ ];
259
+
233
260
  // @public (undocumented)
234
261
  type BoxComponent<T extends ElementType = 'div'> = (<
235
262
  T extends ElementType = 'div',
@@ -241,14 +268,12 @@ type BoxComponent<T extends ElementType = 'div'> = (<
241
268
  // @public (undocumented)
242
269
  export type BoxProps<T extends ElementType = 'div'> = Omit<
243
270
  BaseBoxProps<T>,
244
- 'UNSAFE_style' | 'className'
271
+ 'UNSAFE_style' | 'className' | BoxResponsiveProp
245
272
  > &
246
- BoxPropsBase;
273
+ PublicBoxPropsBase;
247
274
 
248
275
  // @public (undocumented)
249
- type BoxPropsBase = {
250
- customStyles?: CustomStyles;
251
- };
276
+ type BoxResponsiveProp = typeof BOX_RESPONSIVE_PROPS[number];
252
277
 
253
278
  // @public
254
279
  type CustomStyles = Pick<
@@ -283,11 +308,11 @@ type Display = keyof typeof displayMap;
283
308
 
284
309
  // @public (undocumented)
285
310
  const displayMap: {
286
- readonly block: SerializedStyles;
287
- readonly inline: SerializedStyles;
288
- readonly flex: SerializedStyles;
289
- readonly 'inline-flex': SerializedStyles;
290
- readonly 'inline-block': SerializedStyles;
311
+ readonly block: 'block';
312
+ readonly inline: 'inline';
313
+ readonly flex: 'flex';
314
+ readonly 'inline-flex': 'inline-flex';
315
+ readonly 'inline-block': 'inline-block';
291
316
  };
292
317
 
293
318
  // @public (undocumented)
@@ -399,44 +424,42 @@ const overflowMap: {
399
424
  };
400
425
 
401
426
  // @public (undocumented)
402
- type Padding = keyof typeof paddingMap.padding;
427
+ type Padding = keyof typeof paddingMap;
403
428
 
404
429
  // @public (undocumented)
405
- type PaddingBlock = keyof typeof paddingMap.paddingBlock;
430
+ type PaddingBlock = keyof typeof paddingMap;
406
431
 
407
432
  // @public (undocumented)
408
- type PaddingBlockEnd = keyof typeof paddingMap.paddingBlockEnd;
433
+ type PaddingBlockEnd = keyof typeof paddingMap;
409
434
 
410
435
  // @public (undocumented)
411
- type PaddingBlockStart = keyof typeof paddingMap.paddingBlockStart;
436
+ type PaddingBlockStart = keyof typeof paddingMap;
412
437
 
413
438
  // @public (undocumented)
414
- type PaddingInline = keyof typeof paddingMap.paddingInline;
439
+ type PaddingInline = keyof typeof paddingMap;
415
440
 
416
441
  // @public (undocumented)
417
- type PaddingInlineEnd = keyof typeof paddingMap.paddingInlineEnd;
442
+ type PaddingInlineEnd = keyof typeof paddingMap;
418
443
 
419
444
  // @public (undocumented)
420
- type PaddingInlineStart = keyof typeof paddingMap.paddingInlineStart;
445
+ type PaddingInlineStart = keyof typeof paddingMap;
421
446
 
422
447
  // @public
423
448
  const paddingMap: {
424
- [k: string]: {
425
- readonly 'space.0': SerializedStyles;
426
- readonly 'space.025': SerializedStyles;
427
- readonly 'space.050': SerializedStyles;
428
- readonly 'space.075': SerializedStyles;
429
- readonly 'space.100': SerializedStyles;
430
- readonly 'space.150': SerializedStyles;
431
- readonly 'space.200': SerializedStyles;
432
- readonly 'space.250': SerializedStyles;
433
- readonly 'space.300': SerializedStyles;
434
- readonly 'space.400': SerializedStyles;
435
- readonly 'space.500': SerializedStyles;
436
- readonly 'space.600': SerializedStyles;
437
- readonly 'space.800': SerializedStyles;
438
- readonly 'space.1000': SerializedStyles;
439
- };
449
+ readonly 'space.0': 'var(--ds-space-0)';
450
+ readonly 'space.025': 'var(--ds-space-025)';
451
+ readonly 'space.050': 'var(--ds-space-050)';
452
+ readonly 'space.075': 'var(--ds-space-075)';
453
+ readonly 'space.100': 'var(--ds-space-100)';
454
+ readonly 'space.150': 'var(--ds-space-150)';
455
+ readonly 'space.200': 'var(--ds-space-200)';
456
+ readonly 'space.250': 'var(--ds-space-250)';
457
+ readonly 'space.300': 'var(--ds-space-300)';
458
+ readonly 'space.400': 'var(--ds-space-400)';
459
+ readonly 'space.500': 'var(--ds-space-500)';
460
+ readonly 'space.600': 'var(--ds-space-600)';
461
+ readonly 'space.800': 'var(--ds-space-800)';
462
+ readonly 'space.1000': 'var(--ds-space-1000)';
440
463
  };
441
464
 
442
465
  // @public (undocumented)
@@ -450,6 +473,20 @@ const positionMap: {
450
473
  readonly static: SerializedStyles;
451
474
  };
452
475
 
476
+ // @public (undocumented)
477
+ type PublicBoxPropsBase = {
478
+ borderWidth?: BorderWidth;
479
+ display?: Display;
480
+ padding?: Padding;
481
+ paddingBlock?: PaddingBlock;
482
+ paddingBlockStart?: PaddingBlockStart;
483
+ paddingBlockEnd?: PaddingBlockEnd;
484
+ paddingInline?: PaddingInline;
485
+ paddingInlineStart?: PaddingInlineStart;
486
+ paddingInlineEnd?: PaddingInlineEnd;
487
+ customStyles?: CustomStyles;
488
+ };
489
+
453
490
  // @public (undocumented)
454
491
  type Shadow = keyof typeof shadowMap;
455
492
 
@@ -463,49 +500,45 @@ const shadowMap: {
463
500
  };
464
501
 
465
502
  // @public (undocumented)
466
- type Space = keyof typeof spaceMap.gap;
503
+ type Space = keyof typeof spaceMap;
467
504
 
468
505
  // @public (undocumented)
469
- type Space_2 = keyof typeof spaceMap_2.gap;
506
+ type Space_2 = keyof typeof spaceMap_2;
470
507
 
471
508
  // @public
472
509
  const spaceMap: {
473
- [k: string]: {
474
- readonly '0': SerializedStyles;
475
- readonly '025': SerializedStyles;
476
- readonly '050': SerializedStyles;
477
- readonly '075': SerializedStyles;
478
- readonly '100': SerializedStyles;
479
- readonly '150': SerializedStyles;
480
- readonly '200': SerializedStyles;
481
- readonly '250': SerializedStyles;
482
- readonly '300': SerializedStyles;
483
- readonly '400': SerializedStyles;
484
- readonly '500': SerializedStyles;
485
- readonly '600': SerializedStyles;
486
- readonly '800': SerializedStyles;
487
- readonly '1000': SerializedStyles;
488
- };
510
+ readonly '0': SerializedStyles;
511
+ readonly '025': SerializedStyles;
512
+ readonly '050': SerializedStyles;
513
+ readonly '075': SerializedStyles;
514
+ readonly '100': SerializedStyles;
515
+ readonly '150': SerializedStyles;
516
+ readonly '200': SerializedStyles;
517
+ readonly '250': SerializedStyles;
518
+ readonly '300': SerializedStyles;
519
+ readonly '400': SerializedStyles;
520
+ readonly '500': SerializedStyles;
521
+ readonly '600': SerializedStyles;
522
+ readonly '800': SerializedStyles;
523
+ readonly '1000': SerializedStyles;
489
524
  };
490
525
 
491
526
  // @public
492
527
  const spaceMap_2: {
493
- [k: string]: {
494
- readonly '0': SerializedStyles;
495
- readonly '025': SerializedStyles;
496
- readonly '050': SerializedStyles;
497
- readonly '075': SerializedStyles;
498
- readonly '100': SerializedStyles;
499
- readonly '150': SerializedStyles;
500
- readonly '200': SerializedStyles;
501
- readonly '250': SerializedStyles;
502
- readonly '300': SerializedStyles;
503
- readonly '400': SerializedStyles;
504
- readonly '500': SerializedStyles;
505
- readonly '600': SerializedStyles;
506
- readonly '800': SerializedStyles;
507
- readonly '1000': SerializedStyles;
508
- };
528
+ readonly '0': SerializedStyles;
529
+ readonly '025': SerializedStyles;
530
+ readonly '050': SerializedStyles;
531
+ readonly '075': SerializedStyles;
532
+ readonly '100': SerializedStyles;
533
+ readonly '150': SerializedStyles;
534
+ readonly '200': SerializedStyles;
535
+ readonly '250': SerializedStyles;
536
+ readonly '300': SerializedStyles;
537
+ readonly '400': SerializedStyles;
538
+ readonly '500': SerializedStyles;
539
+ readonly '600': SerializedStyles;
540
+ readonly '800': SerializedStyles;
541
+ readonly '1000': SerializedStyles;
509
542
  };
510
543
 
511
544
  // @public (undocumented)
@@ -3,9 +3,15 @@ import parserTypeScript from 'prettier/parser-typescript';
3
3
 
4
4
  import { spacing as tokens } from '@atlaskit/tokens/tokens-raw';
5
5
 
6
- import { capitalize, tokenToStyle } from './utils';
6
+ import { capitalize, tokenCall, tokenToStyle } from './utils';
7
7
 
8
- const spacingProperties = {
8
+ const spacingProperties: Record<
9
+ string,
10
+ {
11
+ cssProperties: readonly string[];
12
+ responsiveOutput?: boolean;
13
+ }
14
+ > = {
9
15
  padding: {
10
16
  cssProperties: [
11
17
  'padding',
@@ -16,6 +22,7 @@ const spacingProperties = {
16
22
  'paddingInlineStart',
17
23
  'paddingInlineEnd',
18
24
  ],
25
+ responsiveOutput: true,
19
26
  },
20
27
  gap: {
21
28
  cssProperties: ['gap'],
@@ -48,17 +55,13 @@ export const createSpacingStylesFromTemplate = (
48
55
  throw new Error(`[codegen] Unknown option found "${spacingProperty}"`);
49
56
  }
50
57
 
51
- const { cssProperties } = spacingProperties[spacingProperty];
58
+ const { cssProperties, responsiveOutput } =
59
+ spacingProperties[spacingProperty]!;
52
60
 
53
61
  return (
54
62
  prettier.format(
55
63
  `
56
- const ${spacingProperty}Map = Object.fromEntries(
57
- [
58
- '${cssProperties.join("','")}',
59
- ].map((property: string) => [
60
- property,
61
- {
64
+ const ${spacingProperty}Map = {
62
65
  ${activeTokens
63
66
  .sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }))
64
67
  .map(token => {
@@ -66,14 +69,19 @@ const ${spacingProperty}Map = Object.fromEntries(
66
69
  spacingProperty === 'space'
67
70
  ? token.name.replace(spacingTokenPrefix, '')
68
71
  : token.name;
72
+
73
+ // a responsive output simply prints out a mapping of tokens
74
+ if (responsiveOutput) {
75
+ return `'${token.name}': ${tokenCall(token.name, token.fallback)}`;
76
+ }
77
+
69
78
  return `'${propName}': ${tokenToStyle(
70
- '[property]' as any,
79
+ [cssProperties] as any,
71
80
  token.name,
72
81
  token.fallback,
73
82
  )}`;
74
83
  })}
75
- } as const,
76
- ]));`,
84
+ } as const;`,
77
85
  {
78
86
  singleQuote: true,
79
87
  trailingComma: 'all',
@@ -81,17 +89,14 @@ const ${spacingProperty}Map = Object.fromEntries(
81
89
  plugins: [parserTypeScript],
82
90
  },
83
91
  ) +
84
- (cssProperties.length === 1
85
- ? `\nexport type ${capitalize(
86
- spacingProperty,
87
- )} = keyof typeof ${spacingProperty}Map.${cssProperties[0]};\n`
88
- : cssProperties
89
- .map(
90
- cssProperty =>
91
- `\nexport type ${capitalize(
92
- cssProperty,
93
- )} = keyof typeof ${spacingProperty}Map.${cssProperty};`,
94
- )
95
- .join('') + '\n')
92
+ (cssProperties
93
+ .map(
94
+ cssProperty =>
95
+ `\nexport type ${capitalize(
96
+ cssProperties.length === 1 ? spacingProperty : cssProperty,
97
+ )} = keyof typeof ${spacingProperty}Map;`,
98
+ )
99
+ .join('') +
100
+ '\n')
96
101
  );
97
102
  };
package/scripts/utils.tsx CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { CSSProperties } from 'react';
2
2
 
3
+ export const tokenCall = (token: string, fallback: string | ShadowDefintion) =>
4
+ `token('${token}', '${fallback}')`;
5
+
3
6
  export const tokenToStyle = (
4
7
  prop: keyof CSSProperties,
5
8
  token: string,
@@ -8,7 +11,7 @@ export const tokenToStyle = (
8
11
  if (Array.isArray(fallback)) {
9
12
  fallback = constructShadow(fallback);
10
13
  }
11
- return `css({\n\t${prop}: token('${token}', '${fallback}')\n})`;
14
+ return `css({\n\t${prop}: ${tokenCall(token, fallback)}\n})`;
12
15
  };
13
16
 
14
17
  export type ShadowDefintion = Array<{