@atlaskit/primitives 1.0.0 → 1.0.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/constellation/flex/code.mdx +7 -0
  3. package/constellation/flex/examples.mdx +34 -0
  4. package/constellation/overview/index.mdx +20 -14
  5. package/dist/cjs/components/flex.js +115 -0
  6. package/dist/cjs/index.js +7 -0
  7. package/dist/cjs/responsive/media-helper.js +15 -0
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/es2019/components/flex.js +108 -0
  10. package/dist/es2019/index.js +1 -0
  11. package/dist/es2019/responsive/media-helper.js +15 -0
  12. package/dist/es2019/version.json +1 -1
  13. package/dist/esm/components/flex.js +107 -0
  14. package/dist/esm/index.js +1 -0
  15. package/dist/esm/responsive/media-helper.js +15 -0
  16. package/dist/esm/version.json +1 -1
  17. package/dist/types/components/box.d.ts +1 -2
  18. package/dist/types/components/flex.d.ts +128 -0
  19. package/dist/types/components/inline.d.ts +1 -1
  20. package/dist/types/components/types.d.ts +2 -6
  21. package/dist/types/index.d.ts +2 -0
  22. package/dist/types/responsive/media-helper.d.ts +30 -0
  23. package/dist/types/xcss/xcss.d.ts +4 -4
  24. package/dist/types-ts4.5/components/box.d.ts +1 -2
  25. package/dist/types-ts4.5/components/flex.d.ts +128 -0
  26. package/dist/types-ts4.5/components/inline.d.ts +1 -1
  27. package/dist/types-ts4.5/components/types.d.ts +2 -6
  28. package/dist/types-ts4.5/index.d.ts +2 -0
  29. package/dist/types-ts4.5/responsive/media-helper.d.ts +30 -0
  30. package/dist/types-ts4.5/xcss/xcss.d.ts +4 -4
  31. package/extract-react-types/box-props.tsx +1 -9
  32. package/package.json +12 -3
  33. package/report.api.md +141 -23
  34. package/tmp/api-report-tmp.d.ts +83 -20
package/report.api.md CHANGED
@@ -20,7 +20,7 @@
20
20
  import { ComponentPropsWithoutRef } from 'react';
21
21
  import type * as CSS_2 from 'csstype';
22
22
  import type { CSSProperties } from 'react';
23
- import { CSSPropertiesWithMultiValues } from '@emotion/serialize';
23
+ import type { CSSPropertiesWithMultiValues } from '@emotion/serialize';
24
24
  import { ElementType } from 'react';
25
25
  import { FC } from 'react';
26
26
  import { ForwardRefExoticComponent } from 'react';
@@ -29,7 +29,8 @@ import { MemoExoticComponent } from 'react';
29
29
  import { ReactElement } from 'react';
30
30
  import { ReactNode } from 'react';
31
31
  import { RefAttributes } from 'react';
32
- import { SerializedStyles } from '@emotion/serialize';
32
+ import type { SerializedStyles } from '@emotion/serialize';
33
+ import { SerializedStyles as SerializedStyles_2 } from '@emotion/react';
33
34
 
34
35
  // @public (undocumented)
35
36
  type AlignBlock = 'baseline' | 'center' | 'end' | 'start' | 'stretch';
@@ -43,6 +44,17 @@ type AlignInline = 'center' | 'end' | 'start';
43
44
  // @public (undocumented)
44
45
  type AlignInline_2 = 'center' | 'end' | 'start';
45
46
 
47
+ // @public (undocumented)
48
+ type AlignItems = keyof typeof alignItemsMap;
49
+
50
+ // @public (undocumented)
51
+ const alignItemsMap: {
52
+ readonly start: SerializedStyles_2;
53
+ readonly center: SerializedStyles_2;
54
+ readonly baseline: SerializedStyles_2;
55
+ readonly end: SerializedStyles_2;
56
+ };
57
+
46
58
  // @public (undocumented)
47
59
  type AllowedBoxStyles = keyof SafeCSSObject;
48
60
 
@@ -67,7 +79,7 @@ type As =
67
79
  type AutoComplete<T extends string> = Omit<string, T> | T;
68
80
 
69
81
  // @public (undocumented)
70
- type BackgroundColor = keyof typeof backgroundColorMap;
82
+ export type BackgroundColor = keyof typeof backgroundColorMap;
71
83
 
72
84
  // @public (undocumented)
73
85
  const backgroundColorMap: {
@@ -209,10 +221,11 @@ type BaseBoxPropsFoundation<T extends ElementType = 'div'> = {
209
221
  type BasePrimitiveProps = {
210
222
  testId?: string;
211
223
  style?: CSSProperties;
224
+ xcss?: BoxXCSS | BoxXCSS[];
212
225
  };
213
226
 
214
227
  // @public (undocumented)
215
- type BorderColor = keyof typeof borderColorMap;
228
+ export type BorderColor = keyof typeof borderColorMap;
216
229
 
217
230
  // @public
218
231
  const borderColorMap: {
@@ -242,7 +255,7 @@ const borderColorMap: {
242
255
  };
243
256
 
244
257
  // @public (undocumented)
245
- type BorderRadius = keyof typeof borderRadiusMap;
258
+ export type BorderRadius = keyof typeof borderRadiusMap;
246
259
 
247
260
  // @public (undocumented)
248
261
  const borderRadiusMap: {
@@ -256,7 +269,7 @@ const borderRadiusMap: {
256
269
  };
257
270
 
258
271
  // @public (undocumented)
259
- type BorderWidth = keyof typeof borderWidthMap;
272
+ export type BorderWidth = keyof typeof borderWidthMap;
260
273
 
261
274
  // @public
262
275
  const borderWidthMap: {
@@ -281,8 +294,7 @@ type BoxComponent<T extends ElementType = 'div'> = (<
281
294
  export type BoxProps<T extends ElementType = 'div'> = Omit<
282
295
  BaseBoxProps<T>,
283
296
  'className'
284
- > &
285
- PublicBoxPropsBase;
297
+ >;
286
298
 
287
299
  // @public (undocumented)
288
300
  type BoxStyles = SerializedStyles & {
@@ -293,12 +305,11 @@ type BoxStyles = SerializedStyles & {
293
305
  const boxTag: unique symbol;
294
306
 
295
307
  // @public (undocumented)
296
- type BoxXCSS = {
297
- readonly [uniqueSymbol]: BoxStyles;
298
- };
299
-
300
- // @public (undocumented)
301
- type BoxXCSSArray = Array<BoxXCSS | BoxXCSSArray | false | undefined>;
308
+ type BoxXCSS =
309
+ | false
310
+ | {
311
+ readonly [uniqueSymbol]: BoxStyles;
312
+ };
302
313
 
303
314
  // @public
304
315
  export type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | 'xxs';
@@ -314,7 +325,7 @@ type CSSPseudos = {
314
325
  };
315
326
 
316
327
  // @public (undocumented)
317
- type Dimension = keyof typeof dimensionMap;
328
+ export type Dimension = keyof typeof dimensionMap;
318
329
 
319
330
  // @public
320
331
  const dimensionMap: {
@@ -328,6 +339,101 @@ const dimensionMap: {
328
339
  readonly 'size.1000': '12rem';
329
340
  };
330
341
 
342
+ // @public (undocumented)
343
+ type Direction = keyof typeof flexDirectionMap;
344
+
345
+ // @public
346
+ export const Flex: MemoExoticComponent<
347
+ ForwardRefExoticComponent<
348
+ Pick<
349
+ {
350
+ as?: 'div' | 'ol' | 'span' | 'ul' | undefined;
351
+ justifyContent?:
352
+ | 'center'
353
+ | 'end'
354
+ | 'space-around'
355
+ | 'space-between'
356
+ | 'space-evenly'
357
+ | 'start'
358
+ | 'stretch'
359
+ | undefined;
360
+ alignItems?: 'baseline' | 'center' | 'end' | 'start' | undefined;
361
+ gap?:
362
+ | 'space.0'
363
+ | 'space.025'
364
+ | 'space.050'
365
+ | 'space.075'
366
+ | 'space.100'
367
+ | 'space.1000'
368
+ | 'space.150'
369
+ | 'space.200'
370
+ | 'space.250'
371
+ | 'space.300'
372
+ | 'space.400'
373
+ | 'space.500'
374
+ | 'space.600'
375
+ | 'space.800'
376
+ | undefined;
377
+ rowGap?:
378
+ | 'space.0'
379
+ | 'space.025'
380
+ | 'space.050'
381
+ | 'space.075'
382
+ | 'space.100'
383
+ | 'space.1000'
384
+ | 'space.150'
385
+ | 'space.200'
386
+ | 'space.250'
387
+ | 'space.300'
388
+ | 'space.400'
389
+ | 'space.500'
390
+ | 'space.600'
391
+ | 'space.800'
392
+ | undefined;
393
+ direction?: 'column' | 'row' | undefined;
394
+ wrap?: 'nowrap' | 'wrap' | undefined;
395
+ children: ReactNode;
396
+ ref?: any;
397
+ } & BasePrimitiveProps,
398
+ | 'alignItems'
399
+ | 'as'
400
+ | 'children'
401
+ | 'direction'
402
+ | 'gap'
403
+ | 'justifyContent'
404
+ | 'rowGap'
405
+ | 'wrap'
406
+ | keyof BasePrimitiveProps
407
+ > &
408
+ RefAttributes<any>
409
+ >
410
+ >;
411
+
412
+ // @public (undocumented)
413
+ const flexDirectionMap: {
414
+ readonly column: SerializedStyles_2;
415
+ readonly row: SerializedStyles_2;
416
+ };
417
+
418
+ // @public (undocumented)
419
+ export type FlexProps<T extends ElementType = 'div'> = {
420
+ as?: 'div' | 'ol' | 'span' | 'ul';
421
+ justifyContent?: JustifyContent;
422
+ alignItems?: AlignItems;
423
+ gap?: Space;
424
+ rowGap?: Space;
425
+ direction?: Direction;
426
+ wrap?: Wrap;
427
+ children: ReactNode;
428
+ ref?: React.ComponentPropsWithRef<T>['ref'];
429
+ } & BasePrimitiveProps;
430
+
431
+ // @public (undocumented)
432
+ const flexWrapMap: {
433
+ readonly wrap: SerializedStyles_2;
434
+ readonly nowrap: SerializedStyles_2;
435
+ };
436
+
331
437
  // @public (undocumented)
332
438
  type Grow = 'fill' | 'hug';
333
439
 
@@ -387,7 +493,21 @@ type InlineXCSS = {
387
493
  };
388
494
 
389
495
  // @public (undocumented)
390
- type Layer = keyof typeof layerMap;
496
+ type JustifyContent = keyof typeof justifyContentMap;
497
+
498
+ // @public (undocumented)
499
+ const justifyContentMap: {
500
+ readonly start: SerializedStyles_2;
501
+ readonly center: SerializedStyles_2;
502
+ readonly end: SerializedStyles_2;
503
+ readonly 'space-between': SerializedStyles_2;
504
+ readonly 'space-around': SerializedStyles_2;
505
+ readonly 'space-evenly': SerializedStyles_2;
506
+ readonly stretch: SerializedStyles_2;
507
+ };
508
+
509
+ // @public (undocumented)
510
+ export type Layer = keyof typeof layerMap;
391
511
 
392
512
  // @public
393
513
  const layerMap: {
@@ -435,11 +555,6 @@ export type PressableProps = Omit<
435
555
  isDisabled?: boolean;
436
556
  };
437
557
 
438
- // @public (undocumented)
439
- type PublicBoxPropsBase = {
440
- xcss?: BoxXCSS | BoxXCSSArray;
441
- };
442
-
443
558
  // @public (undocumented)
444
559
  type SafeCSSObject = CSSPseudos &
445
560
  TokenisedProps &
@@ -453,7 +568,7 @@ type ScopedSafeCSSObject<T extends keyof SafeCSSObject> = Pick<
453
568
  >;
454
569
 
455
570
  // @public (undocumented)
456
- type Shadow = keyof typeof shadowMap;
571
+ export type Shadow = keyof typeof shadowMap;
457
572
 
458
573
  // @public (undocumented)
459
574
  const shadowMap: {
@@ -465,7 +580,7 @@ const shadowMap: {
465
580
  };
466
581
 
467
582
  // @public (undocumented)
468
- type Space = keyof typeof spaceMap;
583
+ export type Space = keyof typeof spaceMap;
469
584
 
470
585
  // @public
471
586
  const spaceMap: {
@@ -711,6 +826,9 @@ export const UNSAFE_media: {
711
826
  };
712
827
  };
713
828
 
829
+ // @public (undocumented)
830
+ type Wrap = keyof typeof flexWrapMap;
831
+
714
832
  // @public
715
833
  export function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(
716
834
  style: Primitive extends typeof Box
@@ -9,7 +9,7 @@
9
9
  import { ComponentPropsWithoutRef } from 'react';
10
10
  import type * as CSS_2 from 'csstype';
11
11
  import type { CSSProperties } from 'react';
12
- import { CSSPropertiesWithMultiValues } from '@emotion/serialize';
12
+ import type { CSSPropertiesWithMultiValues } from '@emotion/serialize';
13
13
  import { ElementType } from 'react';
14
14
  import { FC } from 'react';
15
15
  import { ForwardRefExoticComponent } from 'react';
@@ -18,7 +18,8 @@ import { MemoExoticComponent } from 'react';
18
18
  import { ReactElement } from 'react';
19
19
  import { ReactNode } from 'react';
20
20
  import { RefAttributes } from 'react';
21
- import { SerializedStyles } from '@emotion/serialize';
21
+ import type { SerializedStyles } from '@emotion/serialize';
22
+ import { SerializedStyles as SerializedStyles_2 } from '@emotion/react';
22
23
 
23
24
  // @public (undocumented)
24
25
  type AlignBlock = 'baseline' | 'center' | 'end' | 'start' | 'stretch';
@@ -32,6 +33,17 @@ type AlignInline = 'center' | 'end' | 'start';
32
33
  // @public (undocumented)
33
34
  type AlignInline_2 = 'center' | 'end' | 'start';
34
35
 
36
+ // @public (undocumented)
37
+ type AlignItems = keyof typeof alignItemsMap;
38
+
39
+ // @public (undocumented)
40
+ const alignItemsMap: {
41
+ readonly start: SerializedStyles_2;
42
+ readonly center: SerializedStyles_2;
43
+ readonly baseline: SerializedStyles_2;
44
+ readonly end: SerializedStyles_2;
45
+ };
46
+
35
47
  // @public (undocumented)
36
48
  type AllowedBoxStyles = keyof SafeCSSObject;
37
49
 
@@ -42,7 +54,7 @@ type As = 'article' | 'aside' | 'button' | 'dialog' | 'div' | 'footer' | 'header
42
54
  type AutoComplete<T extends string> = Omit<string, T> | T;
43
55
 
44
56
  // @public (undocumented)
45
- type BackgroundColor = keyof typeof backgroundColorMap;
57
+ export type BackgroundColor = keyof typeof backgroundColorMap;
46
58
 
47
59
  // @public (undocumented)
48
60
  const backgroundColorMap: {
@@ -179,10 +191,11 @@ type BaseBoxPropsFoundation<T extends ElementType = 'div'> = {
179
191
  type BasePrimitiveProps = {
180
192
  testId?: string;
181
193
  style?: CSSProperties;
194
+ xcss?: BoxXCSS | BoxXCSS[];
182
195
  };
183
196
 
184
197
  // @public (undocumented)
185
- type BorderColor = keyof typeof borderColorMap;
198
+ export type BorderColor = keyof typeof borderColorMap;
186
199
 
187
200
  // @public
188
201
  const borderColorMap: {
@@ -212,7 +225,7 @@ const borderColorMap: {
212
225
  };
213
226
 
214
227
  // @public (undocumented)
215
- type BorderRadius = keyof typeof borderRadiusMap;
228
+ export type BorderRadius = keyof typeof borderRadiusMap;
216
229
 
217
230
  // @public (undocumented)
218
231
  const borderRadiusMap: {
@@ -226,7 +239,7 @@ const borderRadiusMap: {
226
239
  };
227
240
 
228
241
  // @public (undocumented)
229
- type BorderWidth = keyof typeof borderWidthMap;
242
+ export type BorderWidth = keyof typeof borderWidthMap;
230
243
 
231
244
  // @public
232
245
  const borderWidthMap: {
@@ -243,7 +256,7 @@ export const Box: BoxComponent;
243
256
  type BoxComponent<T extends ElementType = 'div'> = (<T extends ElementType = 'div'>(props: BoxProps<T>) => ReactElement | null) & FC<BoxProps<T>>;
244
257
 
245
258
  // @public (undocumented)
246
- export type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className'> & PublicBoxPropsBase;
259
+ export type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className'>;
247
260
 
248
261
  // @public (undocumented)
249
262
  type BoxStyles = SerializedStyles & {
@@ -254,13 +267,10 @@ type BoxStyles = SerializedStyles & {
254
267
  const boxTag: unique symbol;
255
268
 
256
269
  // @public (undocumented)
257
- type BoxXCSS = {
270
+ type BoxXCSS = false | {
258
271
  readonly [uniqueSymbol]: BoxStyles;
259
272
  };
260
273
 
261
- // @public (undocumented)
262
- type BoxXCSSArray = Array<BoxXCSS | BoxXCSSArray | false | undefined>;
263
-
264
274
  // @public
265
275
  export type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | 'xxs';
266
276
 
@@ -275,7 +285,7 @@ type CSSPseudos = {
275
285
  };
276
286
 
277
287
  // @public (undocumented)
278
- type Dimension = keyof typeof dimensionMap;
288
+ export type Dimension = keyof typeof dimensionMap;
279
289
 
280
290
  // @public
281
291
  const dimensionMap: {
@@ -289,6 +299,47 @@ const dimensionMap: {
289
299
  readonly 'size.1000': "12rem";
290
300
  };
291
301
 
302
+ // @public (undocumented)
303
+ type Direction = keyof typeof flexDirectionMap;
304
+
305
+ // @public
306
+ export const Flex: MemoExoticComponent<ForwardRefExoticComponent<Pick<{
307
+ as?: "div" | "ol" | "span" | "ul" | undefined;
308
+ justifyContent?: "center" | "end" | "space-around" | "space-between" | "space-evenly" | "start" | "stretch" | undefined;
309
+ alignItems?: "baseline" | "center" | "end" | "start" | undefined;
310
+ gap?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.1000" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | undefined;
311
+ rowGap?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.1000" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | undefined;
312
+ direction?: "column" | "row" | undefined;
313
+ wrap?: "nowrap" | "wrap" | undefined;
314
+ children: ReactNode;
315
+ ref?: any;
316
+ } & BasePrimitiveProps, "alignItems" | "as" | "children" | "direction" | "gap" | "justifyContent" | "rowGap" | "wrap" | keyof BasePrimitiveProps> & RefAttributes<any>>>;
317
+
318
+ // @public (undocumented)
319
+ const flexDirectionMap: {
320
+ readonly column: SerializedStyles_2;
321
+ readonly row: SerializedStyles_2;
322
+ };
323
+
324
+ // @public (undocumented)
325
+ export type FlexProps<T extends ElementType = 'div'> = {
326
+ as?: 'div' | 'ol' | 'span' | 'ul';
327
+ justifyContent?: JustifyContent;
328
+ alignItems?: AlignItems;
329
+ gap?: Space;
330
+ rowGap?: Space;
331
+ direction?: Direction;
332
+ wrap?: Wrap;
333
+ children: ReactNode;
334
+ ref?: React.ComponentPropsWithRef<T>['ref'];
335
+ } & BasePrimitiveProps;
336
+
337
+ // @public (undocumented)
338
+ const flexWrapMap: {
339
+ readonly wrap: SerializedStyles_2;
340
+ readonly nowrap: SerializedStyles_2;
341
+ };
342
+
292
343
  // @public (undocumented)
293
344
  type Grow = 'fill' | 'hug';
294
345
 
@@ -329,7 +380,21 @@ type InlineXCSS = {
329
380
  };
330
381
 
331
382
  // @public (undocumented)
332
- type Layer = keyof typeof layerMap;
383
+ type JustifyContent = keyof typeof justifyContentMap;
384
+
385
+ // @public (undocumented)
386
+ const justifyContentMap: {
387
+ readonly start: SerializedStyles_2;
388
+ readonly center: SerializedStyles_2;
389
+ readonly end: SerializedStyles_2;
390
+ readonly 'space-between': SerializedStyles_2;
391
+ readonly 'space-around': SerializedStyles_2;
392
+ readonly 'space-evenly': SerializedStyles_2;
393
+ readonly stretch: SerializedStyles_2;
394
+ };
395
+
396
+ // @public (undocumented)
397
+ export type Layer = keyof typeof layerMap;
333
398
 
334
399
  // @public
335
400
  const layerMap: {
@@ -371,11 +436,6 @@ export type PressableProps = Omit<BaseBoxProps<'button'>, 'as' | 'children' | 'd
371
436
  isDisabled?: boolean;
372
437
  };
373
438
 
374
- // @public (undocumented)
375
- type PublicBoxPropsBase = {
376
- xcss?: BoxXCSS | BoxXCSSArray;
377
- };
378
-
379
439
  // @public (undocumented)
380
440
  type SafeCSSObject = CSSPseudos & TokenisedProps & CSSMediaQueries & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
381
441
 
@@ -383,7 +443,7 @@ type SafeCSSObject = CSSPseudos & TokenisedProps & CSSMediaQueries & Omit<CSSPro
383
443
  type ScopedSafeCSSObject<T extends keyof SafeCSSObject> = Pick<SafeCSSObject, T>;
384
444
 
385
445
  // @public (undocumented)
386
- type Shadow = keyof typeof shadowMap;
446
+ export type Shadow = keyof typeof shadowMap;
387
447
 
388
448
  // @public (undocumented)
389
449
  const shadowMap: {
@@ -395,7 +455,7 @@ const shadowMap: {
395
455
  };
396
456
 
397
457
  // @public (undocumented)
398
- type Space = keyof typeof spaceMap;
458
+ export type Space = keyof typeof spaceMap;
399
459
 
400
460
  // @public
401
461
  const spaceMap: {
@@ -597,6 +657,9 @@ export const UNSAFE_media: {
597
657
  };
598
658
  };
599
659
 
660
+ // @public (undocumented)
661
+ type Wrap = keyof typeof flexWrapMap;
662
+
600
663
  // @public
601
664
  export function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> | ScopedSafeCSSObject<AllowedBoxStyles>[] : Primitive extends typeof Inline ? ScopedSafeCSSObject<Spacing> | ScopedSafeCSSObject<Spacing>[] : never): {
602
665
  readonly [uniqueSymbol]: Primitive extends (<T extends ElementType<any> = "div">(props: BoxProps<T>) => ReactElement<any, JSXElementConstructor<any>| string> | null) & FC<BoxProps<"div">> ? BoxStyles : Primitive extends MemoExoticComponent<ForwardRefExoticComponent<Pick<InlineProps<ElementType<any>>, "alignBlock" | "alignInline" | "as" | "children" | "grow" | "rowSpace" | "separator" | "shouldWrap" | "space" | "spread" | "testId" | "xcss"> & RefAttributes<any>>> ? InlineStyles : never;