@atlaskit/ds-explorations 0.1.3 → 0.1.5

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 (56) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/components/box.partial.js +7 -1
  3. package/dist/cjs/components/inline.partial.js +42 -17
  4. package/dist/cjs/components/interaction-surface.partial.js +3 -2
  5. package/dist/cjs/components/stack.partial.js +44 -17
  6. package/dist/cjs/components/text.partial.js +2 -0
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/components/box.partial.js +6 -0
  9. package/dist/es2019/components/inline.partial.js +37 -16
  10. package/dist/es2019/components/interaction-surface.partial.js +3 -2
  11. package/dist/es2019/components/stack.partial.js +37 -16
  12. package/dist/es2019/components/text.partial.js +2 -0
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/components/box.partial.js +7 -1
  15. package/dist/esm/components/inline.partial.js +42 -16
  16. package/dist/esm/components/interaction-surface.partial.js +3 -2
  17. package/dist/esm/components/stack.partial.js +42 -16
  18. package/dist/esm/components/text.partial.js +2 -0
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/components/box.partial.d.ts +11 -3
  21. package/dist/types/components/inline.partial.d.ts +14 -2
  22. package/dist/types/components/interaction-surface.partial.d.ts +4 -3
  23. package/dist/types/components/stack.partial.d.ts +15 -4
  24. package/dist/types/components/types.d.ts +1 -0
  25. package/dist/types-ts4.0/components/box.partial.d.ts +221 -0
  26. package/dist/types-ts4.0/components/inline.partial.d.ts +64 -0
  27. package/dist/types-ts4.0/components/interaction-surface.partial.d.ts +46 -0
  28. package/dist/types-ts4.0/components/stack.partial.d.ts +58 -0
  29. package/dist/types-ts4.0/components/surface-provider.d.ts +15 -0
  30. package/dist/types-ts4.0/components/text.partial.d.ts +132 -0
  31. package/dist/types-ts4.0/components/types.d.ts +14 -0
  32. package/dist/types-ts4.0/constants.d.ts +15 -0
  33. package/dist/types-ts4.0/index.d.ts +8 -0
  34. package/dist/types-ts4.0/internal/color-map.d.ts +34 -0
  35. package/dist/types-ts4.0/internal/role-to-element.d.ts +32 -0
  36. package/examples/03-stack.tsx +43 -30
  37. package/examples/04-inline.tsx +43 -30
  38. package/examples/06-section-message.tsx +1 -1
  39. package/examples/99-interactions.tsx +33 -26
  40. package/package.json +10 -3
  41. package/report.api.md +191 -268
  42. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +18 -0
  43. package/scripts/spacing-codegen-template.tsx +6 -0
  44. package/src/components/__tests__/unit/box.test.tsx +10 -2
  45. package/src/components/__tests__/unit/inline.test.tsx +7 -7
  46. package/src/components/__tests__/unit/interaction-suface.test.tsx +13 -7
  47. package/src/components/__tests__/unit/stack.test.tsx +5 -5
  48. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +2 -2
  49. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +2 -2
  50. package/src/components/box.partial.tsx +13 -9
  51. package/src/components/inline.partial.tsx +46 -19
  52. package/src/components/interaction-surface.partial.tsx +23 -4
  53. package/src/components/stack.partial.tsx +46 -20
  54. package/src/components/text.partial.tsx +2 -0
  55. package/src/components/types.tsx +2 -0
  56. package/tmp/api-report-tmp.d.ts +450 -0
@@ -223,6 +223,15 @@ exports[`@atlaskit/design-system-explorations border styles are generated correc
223
223
  backgroundColor: token('color.background.information.bold.pressed'),
224
224
  },
225
225
  }),
226
+ 'elevation.surface': css({
227
+ ':active': { backgroundColor: token('elevation.surface.pressed') },
228
+ }),
229
+ 'elevation.surface.raised': css({
230
+ ':active': { backgroundColor: token('elevation.surface.raised.pressed') },
231
+ }),
232
+ 'elevation.surface.overlay': css({
233
+ ':active': { backgroundColor: token('elevation.surface.overlay.pressed') },
234
+ }),
226
235
  };
227
236
 
228
237
  const backgroundHoverColorMap = {
@@ -300,6 +309,15 @@ const backgroundHoverColorMap = {
300
309
  backgroundColor: token('color.background.information.bold.hovered'),
301
310
  },
302
311
  }),
312
+ 'elevation.surface': css({
313
+ ':hover': { backgroundColor: token('elevation.surface.hovered') },
314
+ }),
315
+ 'elevation.surface.raised': css({
316
+ ':hover': { backgroundColor: token('elevation.surface.raised.hovered') },
317
+ }),
318
+ 'elevation.surface.overlay': css({
319
+ ':hover': { backgroundColor: token('elevation.surface.overlay.hovered') },
320
+ }),
303
321
  };
304
322
 
305
323
  type InteractionBackgroundColor = keyof typeof backgroundHoverColorMap;
@@ -22,6 +22,12 @@ const spacingProperties = {
22
22
  gap: {
23
23
  cssProperty: 'gap',
24
24
  },
25
+ columnGap: {
26
+ cssProperty: 'columnGap',
27
+ },
28
+ rowGap: {
29
+ cssProperty: 'rowGap',
30
+ },
25
31
  } as const;
26
32
 
27
33
  export const createSpacingStylesFromTemplate = (
@@ -10,7 +10,11 @@ describe('Box component', () => {
10
10
  const testId = 'test';
11
11
 
12
12
  it('should render box', () => {
13
- const { getByText } = render(<Box>Box</Box>);
13
+ const { getByText } = render(
14
+ <Box>
15
+ <Text>Box</Text>
16
+ </Box>,
17
+ );
14
18
  expect(getByText('Box')).toBeInTheDocument();
15
19
  });
16
20
 
@@ -43,7 +47,11 @@ describe('Box component', () => {
43
47
  });
44
48
 
45
49
  it('should render with a given test id', () => {
46
- const { getByTestId } = render(<Box testId={testId}>Box with testid</Box>);
50
+ const { getByTestId } = render(
51
+ <Box testId={testId}>
52
+ <Text>Box with testid</Text>
53
+ </Box>,
54
+ );
47
55
  const element = getByTestId(testId);
48
56
  expect(element).toBeInTheDocument();
49
57
  });
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import { render } from '@testing-library/react';
4
4
 
5
- import { UNSAFE_Box as Box, UNSAFE_Inline as Inline } from '../../../index';
5
+ import { UNSAFE_Inline as Inline, UNSAFE_Text as Text } from '../../../index';
6
6
 
7
7
  describe('Inline component', () => {
8
8
  const testId = 'test';
@@ -10,8 +10,8 @@ describe('Inline component', () => {
10
10
  it('should render inline', () => {
11
11
  const { getByText } = render(
12
12
  <Inline gap="sp-50">
13
- <Box>1</Box>
14
- <Box>2</Box>
13
+ <Text>1</Text>
14
+ <Text>2</Text>
15
15
  </Inline>,
16
16
  );
17
17
  expect(getByText('1')).toBeInTheDocument();
@@ -21,8 +21,8 @@ describe('Inline component', () => {
21
21
  it('should render inline with dividers', () => {
22
22
  const { getByText } = render(
23
23
  <Inline gap="sp-50" divider="/">
24
- <Box>1</Box>
25
- <Box>2</Box>
24
+ <Text>1</Text>
25
+ <Text>2</Text>
26
26
  </Inline>,
27
27
  );
28
28
  expect(getByText('1')).toBeInTheDocument();
@@ -33,8 +33,8 @@ describe('Inline component', () => {
33
33
  it('should render with a given test id', () => {
34
34
  const { getByTestId } = render(
35
35
  <Inline gap="sp-50" testId={testId}>
36
- <Box>1</Box>
37
- <Box>2</Box>
36
+ <Text>1</Text>
37
+ <Text>2</Text>
38
38
  </Inline>,
39
39
  );
40
40
  const element = getByTestId(testId);
@@ -7,18 +7,22 @@ import { token } from '@atlaskit/tokens';
7
7
  import {
8
8
  UNSAFE_Box as Box,
9
9
  UNSAFE_InteractionSurface as InteractionSurface,
10
+ UNSAFE_Text as Text,
10
11
  } from '../../../index';
11
12
 
12
13
  describe('InteractionSurface component', () => {
13
14
  it('should render by itself', () => {
14
- const { getByTestId } = render(<InteractionSurface testId="basic" />);
15
+ const { getByTestId } = render(
16
+ <InteractionSurface testId="basic">
17
+ <></>
18
+ </InteractionSurface>,
19
+ );
15
20
  expect(getByTestId('basic')).toBeInTheDocument();
16
21
  });
17
22
  it('should render given a neutral hover interaction by default', () => {
18
23
  const { getByTestId } = render(
19
24
  <div style={{ position: 'relative' }}>
20
- <InteractionSurface testId="surface" />
21
- hello
25
+ <InteractionSurface testId="surface">hello</InteractionSurface>
22
26
  </div>,
23
27
  );
24
28
 
@@ -35,8 +39,9 @@ describe('InteractionSurface component', () => {
35
39
  it('should render given a brand hover interaction by if set as brand', () => {
36
40
  const { getByTestId } = render(
37
41
  <div style={{ position: 'relative' }}>
38
- <InteractionSurface appearance="brand.bold" testId="surface" />
39
- hello
42
+ <InteractionSurface appearance="brand.bold" testId="surface">
43
+ hello
44
+ </InteractionSurface>
40
45
  </div>,
41
46
  );
42
47
 
@@ -53,8 +58,9 @@ describe('InteractionSurface component', () => {
53
58
  it('should render an inherited hover state if a Box context is present', () => {
54
59
  const { getByTestId } = render(
55
60
  <Box backgroundColor={['brand.bold', '']}>
56
- <InteractionSurface testId="surface" />
57
- hello
61
+ <InteractionSurface testId="surface">
62
+ <Text>hello</Text>
63
+ </InteractionSurface>
58
64
  </Box>,
59
65
  );
60
66
 
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import { render } from '@testing-library/react';
4
4
 
5
- import { UNSAFE_Box as Box, UNSAFE_Stack as Stack } from '../../../index';
5
+ import { UNSAFE_Stack as Stack, UNSAFE_Text as Text } from '../../../index';
6
6
 
7
7
  describe('Stack component', () => {
8
8
  const testId = 'test';
@@ -10,8 +10,8 @@ describe('Stack component', () => {
10
10
  it('should render stack', () => {
11
11
  const { getByText } = render(
12
12
  <Stack gap="sp-50">
13
- <Box>1</Box>
14
- <Box>2</Box>
13
+ <Text>1</Text>
14
+ <Text>2</Text>
15
15
  </Stack>,
16
16
  );
17
17
  expect(getByText('1')).toBeInTheDocument();
@@ -21,8 +21,8 @@ describe('Stack component', () => {
21
21
  it('should render with a given test id', () => {
22
22
  const { getByTestId } = render(
23
23
  <Stack gap="sp-50" testId={testId}>
24
- <Box>1</Box>
25
- <Box>2</Box>
24
+ <Text>1</Text>
25
+ <Text>2</Text>
26
26
  </Stack>,
27
27
  );
28
28
  const element = getByTestId(testId);
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:eb39d049b365eb764d234de27fd8c49646213232ae31347dc846a23924f10776
3
- size 16922
2
+ oid sha256:7cb6c27a507db62fd86112957d61a1e179013d3ca020a61e91064a33447a7271
3
+ size 23986
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3f907bdcd1449e0444850ddeb4301d6fa1fad478b4c8743d6aec32ceadf2f544
3
- size 19305
2
+ oid sha256:3a37629aa269d2b05af02d0203219d88df7319357a88dab893c4ed9286dd6e9f
3
+ size 26608
@@ -1,11 +1,5 @@
1
1
  /** @jsx jsx */
2
- import {
3
- CSSProperties,
4
- ElementType,
5
- forwardRef,
6
- HTMLAttributes,
7
- ReactNode,
8
- } from 'react';
2
+ import { CSSProperties, ElementType, forwardRef, HTMLAttributes } from 'react';
9
3
 
10
4
  import { css, jsx } from '@emotion/react';
11
5
 
@@ -14,7 +8,7 @@ import { token } from '@atlaskit/tokens';
14
8
  import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
15
9
 
16
10
  import { SurfaceContext } from './surface-provider';
17
- import { BasePrimitiveProps } from './types';
11
+ import type { BasePrimitiveProps, NonTextChildren } from './types';
18
12
 
19
13
  export interface BoxProps<T extends HTMLElement = HTMLElement>
20
14
  extends Omit<HTMLAttributes<T>, 'style' | 'as' | 'className'>,
@@ -26,7 +20,7 @@ export interface BoxProps<T extends HTMLElement = HTMLElement>
26
20
  /**
27
21
  * Elements to be rendered inside the Box.
28
22
  */
29
- children?: ReactNode;
23
+ children?: NonTextChildren | boolean | null | undefined;
30
24
  /**
31
25
  * The html className attribute.
32
26
  *
@@ -71,6 +65,10 @@ export interface BoxProps<T extends HTMLElement = HTMLElement>
71
65
  * Used to align children along the main axis.
72
66
  */
73
67
  justifyContent?: FlexJustifyContent;
68
+ /**
69
+ * Defines what happens if content overflows the box.
70
+ */
71
+ overflow?: Overflow;
74
72
  /**
75
73
  * Shorthand for `paddingBlock` and `paddingInline` together.
76
74
  *
@@ -132,6 +130,7 @@ const Box = forwardRef<HTMLElement, BoxProps>(
132
130
  paddingInline,
133
131
  position = 'relative',
134
132
  height,
133
+ overflow,
135
134
  width,
136
135
  UNSAFE_style,
137
136
  testId,
@@ -254,6 +253,11 @@ const baseStyles = css({
254
253
  border: 'none',
255
254
  });
256
255
 
256
+ type Overflow = keyof typeof overflowMap;
257
+ const overflowMap = {
258
+ auto: css({ overflow: 'auto' }),
259
+ };
260
+
257
261
  const positionMap = {
258
262
  absolute: css({ position: 'absolute' }),
259
263
  relative: css({ position: 'relative' }),
@@ -6,7 +6,7 @@ import { css, jsx } from '@emotion/react';
6
6
  import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
7
7
 
8
8
  import Text from './text.partial';
9
- import { BasePrimitiveProps } from './types';
9
+ import { BasePrimitiveProps, NonTextChildren } from './types';
10
10
 
11
11
  interface InlineProps extends BasePrimitiveProps {
12
12
  /**
@@ -17,6 +17,10 @@ interface InlineProps extends BasePrimitiveProps {
17
17
  * Used to align children along the main axis.
18
18
  */
19
19
  justifyContent?: FlexJustifyContent;
20
+ /**
21
+ * Sets whether children are forced onto one line or can wrap onto multiple lines
22
+ */
23
+ flexWrap?: FlexWrap;
20
24
  /**
21
25
  * Token representing gap between children.
22
26
  */
@@ -29,7 +33,7 @@ interface InlineProps extends BasePrimitiveProps {
29
33
  /**
30
34
  * Elements to be rendered inside the Inline.
31
35
  */
32
- children: ReactNode;
36
+ children: NonTextChildren;
33
37
  }
34
38
 
35
39
  type FlexAlignItems = keyof typeof flexAlignItemsMap;
@@ -38,6 +42,8 @@ const flexAlignItemsMap = {
38
42
  baseline: css({ alignItems: 'baseline' }),
39
43
  flexStart: css({ alignItems: 'flex-start' }),
40
44
  flexEnd: css({ alignItems: 'flex-end' }),
45
+ start: css({ alignItems: 'start' }),
46
+ end: css({ alignItems: 'end' }),
41
47
  };
42
48
 
43
49
  type FlexJustifyContent = keyof typeof flexJustifyContentMap;
@@ -45,6 +51,13 @@ const flexJustifyContentMap = {
45
51
  center: css({ justifyContent: 'center' }),
46
52
  flexStart: css({ justifyContent: 'flex-start' }),
47
53
  flexEnd: css({ justifyContent: 'flex-end' }),
54
+ start: css({ justifyContent: 'start' }),
55
+ end: css({ justifyContent: 'end' }),
56
+ };
57
+
58
+ type FlexWrap = keyof typeof flexWrapMap;
59
+ const flexWrapMap = {
60
+ wrap: css({ flexWrap: 'wrap' }),
48
61
  };
49
62
 
50
63
  const baseStyles = css({
@@ -61,17 +74,31 @@ const baseStyles = css({
61
74
  *
62
75
  */
63
76
  const Inline = forwardRef<HTMLDivElement, InlineProps>(
64
- ({ gap, alignItems, justifyContent, divider, children, testId }, ref) => {
77
+ (
78
+ {
79
+ gap,
80
+ alignItems,
81
+ justifyContent,
82
+ flexWrap,
83
+ divider,
84
+ UNSAFE_style,
85
+ children,
86
+ testId,
87
+ },
88
+ ref,
89
+ ) => {
65
90
  const dividerComponent =
66
91
  typeof divider === 'string' ? <Text>{divider}</Text> : divider;
67
92
 
68
93
  return (
69
94
  <div
95
+ style={{ ...UNSAFE_style }}
70
96
  css={[
71
97
  baseStyles,
72
- gap && gapMap[gap],
98
+ gap && columnGapMap[gap],
73
99
  alignItems && flexAlignItemsMap[alignItems],
74
100
  justifyContent && flexJustifyContentMap[justifyContent],
101
+ flexWrap && flexWrapMap[flexWrap],
75
102
  ]}
76
103
  data-testid={testId}
77
104
  ref={ref}
@@ -95,24 +122,24 @@ export default Inline;
95
122
 
96
123
  /**
97
124
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
98
- * @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
125
+ * @codegen <<SignedSource::7a985afa5e15ffd4f6f9c0db0e99ceb6>>
99
126
  * @codegenId spacing
100
127
  * @codegenCommand yarn codegen-styles
101
- * @codegenParams ["gap"]
128
+ * @codegenParams ["columnGap"]
102
129
  */
103
- const gapMap = {
104
- 'sp-0': css({ gap: SPACING_SCALE['sp-0'] }),
105
- 'sp-25': css({ gap: SPACING_SCALE['sp-25'] }),
106
- 'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
107
- 'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
108
- 'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
109
- 'sp-150': css({ gap: SPACING_SCALE['sp-150'] }),
110
- 'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
111
- 'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
112
- 'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
113
- 'sp-500': css({ gap: SPACING_SCALE['sp-500'] }),
114
- 'sp-600': css({ gap: SPACING_SCALE['sp-600'] }),
115
- 'sp-800': css({ gap: SPACING_SCALE['sp-800'] }),
130
+ const columnGapMap = {
131
+ 'sp-0': css({ columnGap: SPACING_SCALE['sp-0'] }),
132
+ 'sp-25': css({ columnGap: SPACING_SCALE['sp-25'] }),
133
+ 'sp-50': css({ columnGap: SPACING_SCALE['sp-50'] }),
134
+ 'sp-75': css({ columnGap: SPACING_SCALE['sp-75'] }),
135
+ 'sp-100': css({ columnGap: SPACING_SCALE['sp-100'] }),
136
+ 'sp-150': css({ columnGap: SPACING_SCALE['sp-150'] }),
137
+ 'sp-200': css({ columnGap: SPACING_SCALE['sp-200'] }),
138
+ 'sp-300': css({ columnGap: SPACING_SCALE['sp-300'] }),
139
+ 'sp-400': css({ columnGap: SPACING_SCALE['sp-400'] }),
140
+ 'sp-500': css({ columnGap: SPACING_SCALE['sp-500'] }),
141
+ 'sp-600': css({ columnGap: SPACING_SCALE['sp-600'] }),
142
+ 'sp-800': css({ columnGap: SPACING_SCALE['sp-800'] }),
116
143
  };
117
144
 
118
145
  /**
@@ -21,7 +21,7 @@ const baseStyles = css({
21
21
  });
22
22
 
23
23
  interface InteractionSurfaceProps extends BasePrimitiveProps {
24
- children?: ReactNode;
24
+ children: ReactNode;
25
25
  appearance?: InteractionBackgroundColor;
26
26
  }
27
27
 
@@ -31,8 +31,9 @@ interface InteractionSurfaceProps extends BasePrimitiveProps {
31
31
  * ```js
32
32
  * // a minimal icon button
33
33
  * <Box as="button">
34
- * <InteractionSurface />
35
- * <WarningIcon label="icon button" />
34
+ * <InteractionSurface>
35
+ * <WarningIcon label="icon button" />
36
+ * </InteractionSurface>
36
37
  * </Box>
37
38
  * ```
38
39
  */
@@ -69,7 +70,7 @@ export default InteractionSurface;
69
70
 
70
71
  /**
71
72
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
72
- * @codegen <<SignedSource::45000716488a9f41306a232c1f4c9f8d>>
73
+ * @codegen <<SignedSource::6d0e1f52b0e3002ea607eb6a00d90b03>>
73
74
  * @codegenId interactions
74
75
  * @codegenCommand yarn codegen-styles
75
76
  * @codegenParams ["background"]
@@ -151,6 +152,15 @@ const backgroundActiveColorMap = {
151
152
  backgroundColor: token('color.background.information.bold.pressed'),
152
153
  },
153
154
  }),
155
+ 'elevation.surface': css({
156
+ ':active': { backgroundColor: token('elevation.surface.pressed') },
157
+ }),
158
+ 'elevation.surface.raised': css({
159
+ ':active': { backgroundColor: token('elevation.surface.raised.pressed') },
160
+ }),
161
+ 'elevation.surface.overlay': css({
162
+ ':active': { backgroundColor: token('elevation.surface.overlay.pressed') },
163
+ }),
154
164
  };
155
165
 
156
166
  const backgroundHoverColorMap = {
@@ -228,6 +238,15 @@ const backgroundHoverColorMap = {
228
238
  backgroundColor: token('color.background.information.bold.hovered'),
229
239
  },
230
240
  }),
241
+ 'elevation.surface': css({
242
+ ':hover': { backgroundColor: token('elevation.surface.hovered') },
243
+ }),
244
+ 'elevation.surface.raised': css({
245
+ ':hover': { backgroundColor: token('elevation.surface.raised.hovered') },
246
+ }),
247
+ 'elevation.surface.overlay': css({
248
+ ':hover': { backgroundColor: token('elevation.surface.overlay.hovered') },
249
+ }),
231
250
  };
232
251
 
233
252
  type InteractionBackgroundColor = keyof typeof backgroundHoverColorMap;
@@ -1,11 +1,11 @@
1
1
  /** @jsx jsx */
2
- import { forwardRef, ReactNode } from 'react';
2
+ import { forwardRef } from 'react';
3
3
 
4
4
  import { css, jsx } from '@emotion/react';
5
5
 
6
6
  import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
7
7
 
8
- import { BasePrimitiveProps } from './types';
8
+ import { BasePrimitiveProps, NonTextChildren } from './types';
9
9
 
10
10
  interface StackProps extends BasePrimitiveProps {
11
11
  /**
@@ -16,6 +16,10 @@ interface StackProps extends BasePrimitiveProps {
16
16
  * Used to align children along the main axis.
17
17
  */
18
18
  justifyContent?: FlexJustifyContent;
19
+ /**
20
+ * Sets whether children are forced onto one line or can wrap onto multiple lines
21
+ */
22
+ flexWrap?: FlexWrap;
19
23
  /**
20
24
  * Token representing gap between children.
21
25
  */
@@ -23,7 +27,7 @@ interface StackProps extends BasePrimitiveProps {
23
27
  /**
24
28
  * Elements to be rendered inside the Stack.
25
29
  */
26
- children: ReactNode;
30
+ children: NonTextChildren;
27
31
  }
28
32
 
29
33
  type FlexAlignItems = keyof typeof flexAlignItemsMap;
@@ -32,6 +36,8 @@ const flexAlignItemsMap = {
32
36
  baseline: css({ alignItems: 'baseline' }),
33
37
  flexStart: css({ alignItems: 'flex-start' }),
34
38
  flexEnd: css({ alignItems: 'flex-end' }),
39
+ start: css({ alignItems: 'start' }),
40
+ end: css({ alignItems: 'end' }),
35
41
  };
36
42
 
37
43
  type FlexJustifyContent = keyof typeof flexJustifyContentMap;
@@ -39,6 +45,13 @@ const flexJustifyContentMap = {
39
45
  center: css({ justifyContent: 'center' }),
40
46
  flexStart: css({ justifyContent: 'flex-start' }),
41
47
  flexEnd: css({ justifyContent: 'flex-end' }),
48
+ start: css({ justifyContent: 'start' }),
49
+ end: css({ justifyContent: 'end' }),
50
+ };
51
+
52
+ type FlexWrap = keyof typeof flexWrapMap;
53
+ const flexWrapMap = {
54
+ wrap: css({ flexWrap: 'wrap' }),
42
55
  };
43
56
 
44
57
  const baseStyles = css({
@@ -55,14 +68,27 @@ const baseStyles = css({
55
68
  *
56
69
  */
57
70
  const Stack = forwardRef<HTMLDivElement, StackProps>(
58
- ({ gap, alignItems, justifyContent, children, testId }, ref) => {
71
+ (
72
+ {
73
+ gap,
74
+ alignItems,
75
+ justifyContent,
76
+ flexWrap,
77
+ children,
78
+ UNSAFE_style,
79
+ testId,
80
+ },
81
+ ref,
82
+ ) => {
59
83
  return (
60
84
  <div
85
+ style={{ ...UNSAFE_style }}
61
86
  css={[
62
87
  baseStyles,
63
- gap && gapMap[gap],
88
+ gap && rowGapMap[gap],
64
89
  alignItems && flexAlignItemsMap[alignItems],
65
90
  justifyContent && flexJustifyContentMap[justifyContent],
91
+ flexWrap && flexWrapMap[flexWrap],
66
92
  ]}
67
93
  data-testid={testId}
68
94
  ref={ref}
@@ -79,24 +105,24 @@ export default Stack;
79
105
 
80
106
  /**
81
107
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
82
- * @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
108
+ * @codegen <<SignedSource::13c9344cdb18845e176c0ca78b2972d3>>
83
109
  * @codegenId spacing
84
110
  * @codegenCommand yarn codegen-styles
85
- * @codegenParams ["gap"]
111
+ * @codegenParams ["rowGap"]
86
112
  */
87
- const gapMap = {
88
- 'sp-0': css({ gap: SPACING_SCALE['sp-0'] }),
89
- 'sp-25': css({ gap: SPACING_SCALE['sp-25'] }),
90
- 'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
91
- 'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
92
- 'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
93
- 'sp-150': css({ gap: SPACING_SCALE['sp-150'] }),
94
- 'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
95
- 'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
96
- 'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
97
- 'sp-500': css({ gap: SPACING_SCALE['sp-500'] }),
98
- 'sp-600': css({ gap: SPACING_SCALE['sp-600'] }),
99
- 'sp-800': css({ gap: SPACING_SCALE['sp-800'] }),
113
+ const rowGapMap = {
114
+ 'sp-0': css({ rowGap: SPACING_SCALE['sp-0'] }),
115
+ 'sp-25': css({ rowGap: SPACING_SCALE['sp-25'] }),
116
+ 'sp-50': css({ rowGap: SPACING_SCALE['sp-50'] }),
117
+ 'sp-75': css({ rowGap: SPACING_SCALE['sp-75'] }),
118
+ 'sp-100': css({ rowGap: SPACING_SCALE['sp-100'] }),
119
+ 'sp-150': css({ rowGap: SPACING_SCALE['sp-150'] }),
120
+ 'sp-200': css({ rowGap: SPACING_SCALE['sp-200'] }),
121
+ 'sp-300': css({ rowGap: SPACING_SCALE['sp-300'] }),
122
+ 'sp-400': css({ rowGap: SPACING_SCALE['sp-400'] }),
123
+ 'sp-500': css({ rowGap: SPACING_SCALE['sp-500'] }),
124
+ 'sp-600': css({ rowGap: SPACING_SCALE['sp-600'] }),
125
+ 'sp-800': css({ rowGap: SPACING_SCALE['sp-800'] }),
100
126
  };
101
127
 
102
128
  /**
@@ -108,6 +108,8 @@ const verticalAlignMap = {
108
108
 
109
109
  const baseStyles = css({
110
110
  boxSizing: 'border-box',
111
+ margin: '0px',
112
+ padding: '0px',
111
113
  fontFamily,
112
114
  });
113
115
 
@@ -13,3 +13,5 @@ export interface BasePrimitiveProps {
13
13
  */
14
14
  UNSAFE_style?: CSSProperties;
15
15
  }
16
+
17
+ export type NonTextChildren = JSX.Element | (JSX.Element | null | false)[];