@atlaskit/primitives 1.0.0 → 1.0.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.
- package/CHANGELOG.md +12 -0
- package/constellation/flex/code.mdx +7 -0
- package/constellation/flex/examples.mdx +34 -0
- package/constellation/grid/code.mdx +7 -0
- package/constellation/grid/examples.mdx +38 -0
- package/constellation/overview/index.mdx +20 -14
- package/dist/cjs/components/flex.js +119 -0
- package/dist/cjs/components/grid.js +127 -0
- package/dist/cjs/components/inline.js +16 -48
- package/dist/cjs/components/stack.js +19 -39
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/responsive/media-helper.js +15 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/xcss/xcss.js +1 -1
- package/dist/es2019/components/flex.js +111 -0
- package/dist/es2019/components/grid.js +118 -0
- package/dist/es2019/components/inline.js +15 -49
- package/dist/es2019/components/stack.js +18 -40
- package/dist/es2019/index.js +3 -1
- package/dist/es2019/responsive/build-media-query-css.js +0 -1
- package/dist/es2019/responsive/media-helper.js +15 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/xcss/xcss.js +1 -1
- package/dist/esm/components/flex.js +111 -0
- package/dist/esm/components/grid.js +119 -0
- package/dist/esm/components/inline.js +16 -49
- package/dist/esm/components/stack.js +19 -40
- package/dist/esm/index.js +3 -1
- package/dist/esm/responsive/media-helper.js +15 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/xcss/xcss.js +1 -1
- package/dist/types/components/box.d.ts +1 -2
- package/dist/types/components/flex.d.ts +137 -0
- package/dist/types/components/grid.d.ts +154 -0
- package/dist/types/components/inline.d.ts +50 -12
- package/dist/types/components/stack.d.ts +38 -8
- package/dist/types/components/types.d.ts +2 -6
- package/dist/types/index.d.ts +4 -1
- package/dist/types/responsive/media-helper.d.ts +30 -0
- package/dist/types/xcss/xcss.d.ts +13 -16
- package/dist/types-ts4.5/components/box.d.ts +1 -2
- package/dist/types-ts4.5/components/flex.d.ts +137 -0
- package/dist/types-ts4.5/components/grid.d.ts +154 -0
- package/dist/types-ts4.5/components/inline.d.ts +50 -12
- package/dist/types-ts4.5/components/stack.d.ts +38 -8
- package/dist/types-ts4.5/components/types.d.ts +2 -6
- package/dist/types-ts4.5/index.d.ts +4 -1
- package/dist/types-ts4.5/responsive/media-helper.d.ts +30 -0
- package/dist/types-ts4.5/xcss/xcss.d.ts +13 -16
- package/extract-react-types/box-props.tsx +1 -9
- package/package.json +21 -5
- package/report.api.md +404 -75
- package/tmp/api-report-tmp.d.ts +200 -52
|
@@ -20,10 +20,25 @@ var UNSAFE_media = {
|
|
|
20
20
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
21
21
|
*/
|
|
22
22
|
xxs: "@media all",
|
|
23
|
+
/**
|
|
24
|
+
* Used for mobile viewports.
|
|
25
|
+
*/
|
|
23
26
|
xs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.min, ")"),
|
|
27
|
+
/**
|
|
28
|
+
* Used for tablet viewports.
|
|
29
|
+
*/
|
|
24
30
|
sm: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min, ")"),
|
|
31
|
+
/**
|
|
32
|
+
* Used for laptop viewports.
|
|
33
|
+
*/
|
|
25
34
|
md: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min, ")"),
|
|
35
|
+
/**
|
|
36
|
+
* Used for desktop viewports.
|
|
37
|
+
*/
|
|
26
38
|
lg: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min, ")"),
|
|
39
|
+
/**
|
|
40
|
+
* Used for wide screen desktop viewports.
|
|
41
|
+
*/
|
|
27
42
|
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, ")")
|
|
28
43
|
},
|
|
29
44
|
/**
|
package/dist/cjs/version.json
CHANGED
package/dist/cjs/xcss/xcss.js
CHANGED
|
@@ -161,7 +161,7 @@ exports.parseXcss = parseXcss;
|
|
|
161
161
|
var boxWrapper = function boxWrapper(style) {
|
|
162
162
|
return xcss(style);
|
|
163
163
|
};
|
|
164
|
-
var
|
|
164
|
+
var spaceWrapper = function spaceWrapper(style) {
|
|
165
165
|
return xcss(style);
|
|
166
166
|
};
|
|
167
167
|
/**
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { forwardRef, memo } from 'react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { spaceStylesMap } from '../xcss/style-maps.partial';
|
|
6
|
+
import { parseXcss } from '../xcss/xcss';
|
|
7
|
+
const justifyContentMap = {
|
|
8
|
+
start: css({
|
|
9
|
+
justifyContent: 'start'
|
|
10
|
+
}),
|
|
11
|
+
center: css({
|
|
12
|
+
justifyContent: 'center'
|
|
13
|
+
}),
|
|
14
|
+
end: css({
|
|
15
|
+
justifyContent: 'end'
|
|
16
|
+
}),
|
|
17
|
+
'space-between': css({
|
|
18
|
+
justifyContent: 'space-between'
|
|
19
|
+
}),
|
|
20
|
+
'space-around': css({
|
|
21
|
+
justifyContent: 'space-around'
|
|
22
|
+
}),
|
|
23
|
+
'space-evenly': css({
|
|
24
|
+
justifyContent: 'space-evenly'
|
|
25
|
+
}),
|
|
26
|
+
stretch: css({
|
|
27
|
+
justifyContent: 'stretch'
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
const flexDirectionMap = {
|
|
31
|
+
column: css({
|
|
32
|
+
flexDirection: 'column'
|
|
33
|
+
}),
|
|
34
|
+
row: css({
|
|
35
|
+
flexDirection: 'row'
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
const flexWrapMap = {
|
|
39
|
+
wrap: css({
|
|
40
|
+
flexWrap: 'wrap'
|
|
41
|
+
}),
|
|
42
|
+
nowrap: css({
|
|
43
|
+
flexWrap: 'nowrap'
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
const alignItemsMap = {
|
|
47
|
+
start: css({
|
|
48
|
+
alignItems: 'start'
|
|
49
|
+
}),
|
|
50
|
+
center: css({
|
|
51
|
+
alignItems: 'center'
|
|
52
|
+
}),
|
|
53
|
+
baseline: css({
|
|
54
|
+
alignItems: 'baseline'
|
|
55
|
+
}),
|
|
56
|
+
end: css({
|
|
57
|
+
alignItems: 'end'
|
|
58
|
+
}),
|
|
59
|
+
stretch: css({
|
|
60
|
+
alignItems: 'stretch'
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
const baseStyles = css({
|
|
64
|
+
display: 'flex',
|
|
65
|
+
boxSizing: 'border-box'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* __Flex__
|
|
70
|
+
*
|
|
71
|
+
* `Flex` is a primitive component that implements the CSS Flexbox API.
|
|
72
|
+
*
|
|
73
|
+
* - [Examples](https://atlassian.design/components/primitives/flex/examples)
|
|
74
|
+
* - [Code](https://atlassian.design/components/primitives/flex/code)
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* import { Flex, Box } from '@atlaskit/primitives'
|
|
79
|
+
*
|
|
80
|
+
* const Component = () => (
|
|
81
|
+
* <Flex direction="column">
|
|
82
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
83
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
84
|
+
* </Flex>
|
|
85
|
+
* )
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
const Flex = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
89
|
+
as: Component = 'div',
|
|
90
|
+
alignItems,
|
|
91
|
+
justifyContent,
|
|
92
|
+
gap,
|
|
93
|
+
columnGap,
|
|
94
|
+
rowGap,
|
|
95
|
+
children,
|
|
96
|
+
testId,
|
|
97
|
+
direction,
|
|
98
|
+
wrap,
|
|
99
|
+
xcss
|
|
100
|
+
}, ref) => {
|
|
101
|
+
const xcssClassName = xcss && parseXcss(xcss);
|
|
102
|
+
return jsx(Component, {
|
|
103
|
+
css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], direction && flexDirectionMap[direction], justifyContent && justifyContentMap[justifyContent], wrap && flexWrapMap[wrap],
|
|
104
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
105
|
+
xcssClassName && xcssClassName],
|
|
106
|
+
"data-testid": testId,
|
|
107
|
+
ref: ref
|
|
108
|
+
}, children);
|
|
109
|
+
}));
|
|
110
|
+
Flex.displayName = 'Flex';
|
|
111
|
+
export default Flex;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { forwardRef, memo } from 'react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { spaceStylesMap } from '../xcss/style-maps.partial';
|
|
6
|
+
import { parseXcss } from '../xcss/xcss';
|
|
7
|
+
const justifyContentMap = {
|
|
8
|
+
start: css({
|
|
9
|
+
justifyContent: 'start'
|
|
10
|
+
}),
|
|
11
|
+
center: css({
|
|
12
|
+
justifyContent: 'center'
|
|
13
|
+
}),
|
|
14
|
+
end: css({
|
|
15
|
+
justifyContent: 'end'
|
|
16
|
+
}),
|
|
17
|
+
'space-between': css({
|
|
18
|
+
justifyContent: 'space-between'
|
|
19
|
+
}),
|
|
20
|
+
'space-around': css({
|
|
21
|
+
justifyContent: 'space-around'
|
|
22
|
+
}),
|
|
23
|
+
'space-evenly': css({
|
|
24
|
+
justifyContent: 'space-evenly'
|
|
25
|
+
}),
|
|
26
|
+
stretch: css({
|
|
27
|
+
justifyContent: 'stretch'
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
const alignItemsMap = {
|
|
31
|
+
start: css({
|
|
32
|
+
alignItems: 'start'
|
|
33
|
+
}),
|
|
34
|
+
center: css({
|
|
35
|
+
alignItems: 'center'
|
|
36
|
+
}),
|
|
37
|
+
baseline: css({
|
|
38
|
+
alignItems: 'baseline'
|
|
39
|
+
}),
|
|
40
|
+
end: css({
|
|
41
|
+
alignItems: 'end'
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
const baseStyles = css({
|
|
45
|
+
display: 'grid',
|
|
46
|
+
boxSizing: 'border-box'
|
|
47
|
+
});
|
|
48
|
+
const gridAutoFlowMap = {
|
|
49
|
+
row: css({
|
|
50
|
+
gridAutoFlow: 'row'
|
|
51
|
+
}),
|
|
52
|
+
column: css({
|
|
53
|
+
gridAutoFlow: 'column'
|
|
54
|
+
}),
|
|
55
|
+
dense: css({
|
|
56
|
+
gridAutoFlow: 'dense'
|
|
57
|
+
}),
|
|
58
|
+
'row dense': css({
|
|
59
|
+
gridAutoFlow: 'row dense'
|
|
60
|
+
}),
|
|
61
|
+
'column dense': css({
|
|
62
|
+
gridAutoFlow: 'column dense'
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* __Grid__
|
|
68
|
+
*
|
|
69
|
+
* `Grid` is a primitive component that implements the CSS Grid API.
|
|
70
|
+
*
|
|
71
|
+
* - [Examples](https://atlassian.design/components/primitives/grid/examples)
|
|
72
|
+
* - [Code](https://atlassian.design/components/primitives/grid/code)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* import { Grid, Box } from '@atlaskit/primitives'
|
|
77
|
+
*
|
|
78
|
+
* const Component = () => (
|
|
79
|
+
* <Grid gap="space.100" gridColumns="1fr 1fr">
|
|
80
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
81
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
82
|
+
* </Grid>
|
|
83
|
+
* )
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
87
|
+
as,
|
|
88
|
+
alignItems,
|
|
89
|
+
justifyContent,
|
|
90
|
+
gap,
|
|
91
|
+
columnGap,
|
|
92
|
+
rowGap,
|
|
93
|
+
children,
|
|
94
|
+
testId,
|
|
95
|
+
autoFlow,
|
|
96
|
+
templateAreas: gridTemplateAreas,
|
|
97
|
+
templateRows: gridTemplateRows,
|
|
98
|
+
templateColumns: gridTemplateColumns,
|
|
99
|
+
xcss
|
|
100
|
+
}, ref) => {
|
|
101
|
+
const Component = as || 'div';
|
|
102
|
+
const xcssClassName = xcss && parseXcss(xcss);
|
|
103
|
+
const style = gridTemplateAreas || gridTemplateColumns || gridTemplateRows ? Object.assign({}, {
|
|
104
|
+
gridTemplateAreas: gridTemplateAreas ? gridTemplateAreas.map(str => `"${str}"`).join('\n') : undefined,
|
|
105
|
+
gridTemplateColumns,
|
|
106
|
+
gridTemplateRows
|
|
107
|
+
}) : undefined;
|
|
108
|
+
return jsx(Component, {
|
|
109
|
+
style: style,
|
|
110
|
+
css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], justifyContent && justifyContentMap[justifyContent], autoFlow && gridAutoFlowMap[autoFlow],
|
|
111
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
112
|
+
xcssClassName && xcssClassName],
|
|
113
|
+
"data-testid": testId,
|
|
114
|
+
ref: ref
|
|
115
|
+
}, children);
|
|
116
|
+
}));
|
|
117
|
+
Grid.displayName = 'Grid';
|
|
118
|
+
export default Grid;
|
|
@@ -2,56 +2,17 @@
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { Children, forwardRef, Fragment, memo } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
const alignItemsMap = {
|
|
8
|
-
center: css({
|
|
9
|
-
alignItems: 'center'
|
|
10
|
-
}),
|
|
11
|
-
baseline: css({
|
|
12
|
-
alignItems: 'baseline'
|
|
13
|
-
}),
|
|
14
|
-
start: css({
|
|
15
|
-
alignItems: 'flex-start'
|
|
16
|
-
}),
|
|
17
|
-
end: css({
|
|
18
|
-
alignItems: 'flex-end'
|
|
19
|
-
}),
|
|
20
|
-
stretch: css({
|
|
21
|
-
alignItems: 'stretch'
|
|
22
|
-
})
|
|
23
|
-
};
|
|
24
|
-
const justifyContentMap = {
|
|
25
|
-
start: css({
|
|
26
|
-
justifyContent: 'flex-start'
|
|
27
|
-
}),
|
|
28
|
-
center: css({
|
|
29
|
-
justifyContent: 'center'
|
|
30
|
-
}),
|
|
31
|
-
end: css({
|
|
32
|
-
justifyContent: 'flex-end'
|
|
33
|
-
}),
|
|
34
|
-
'space-between': css({
|
|
35
|
-
justifyContent: 'space-between'
|
|
36
|
-
})
|
|
37
|
-
};
|
|
5
|
+
import { xcss } from '../xcss/xcss';
|
|
6
|
+
import Flex from './flex';
|
|
38
7
|
const flexGrowMap = {
|
|
39
|
-
hug:
|
|
8
|
+
hug: xcss({
|
|
40
9
|
flexGrow: 0
|
|
41
10
|
}),
|
|
42
|
-
fill:
|
|
11
|
+
fill: xcss({
|
|
43
12
|
width: '100%',
|
|
44
13
|
flexGrow: 1
|
|
45
14
|
})
|
|
46
15
|
};
|
|
47
|
-
const flexWrapStyles = css({
|
|
48
|
-
flexWrap: 'wrap'
|
|
49
|
-
});
|
|
50
|
-
const baseStyles = css({
|
|
51
|
-
display: 'flex',
|
|
52
|
-
boxSizing: 'border-box',
|
|
53
|
-
flexDirection: 'row'
|
|
54
|
-
});
|
|
55
16
|
const separatorStyles = css({
|
|
56
17
|
color: "var(--ds-text-subtle, #42526E)",
|
|
57
18
|
marginBlock: "var(--ds-space-0, 0px)",
|
|
@@ -94,7 +55,6 @@ const Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
94
55
|
testId,
|
|
95
56
|
children: rawChildren
|
|
96
57
|
}, ref) => {
|
|
97
|
-
const Component = as || 'div';
|
|
98
58
|
const separatorComponent = typeof separator === 'string' ? jsx(Separator, null, separator) : separator;
|
|
99
59
|
const children = separatorComponent ? Children.toArray(rawChildren).filter(Boolean).map((child, index) => {
|
|
100
60
|
return jsx(Fragment, {
|
|
@@ -102,12 +62,18 @@ const Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
102
62
|
}, separator && index > 0 ? separatorComponent : null, child);
|
|
103
63
|
}) : rawChildren;
|
|
104
64
|
const justifyContent = spread || alignInline;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
65
|
+
return jsx(Flex, {
|
|
66
|
+
as: as,
|
|
67
|
+
alignItems: alignItems,
|
|
68
|
+
justifyContent: justifyContent,
|
|
69
|
+
direction: "row",
|
|
70
|
+
gap: space,
|
|
71
|
+
rowGap: rowSpace,
|
|
72
|
+
wrap: shouldWrap ? 'wrap' : undefined,
|
|
73
|
+
xcss: grow ? [flexGrowMap[grow], ...(Array.isArray(xcss) ? xcss : [xcss])] :
|
|
108
74
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
109
|
-
|
|
110
|
-
|
|
75
|
+
xcss,
|
|
76
|
+
testId: testId,
|
|
111
77
|
ref: ref
|
|
112
78
|
}, children);
|
|
113
79
|
}));
|
|
@@ -1,52 +1,23 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { forwardRef, memo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
start: css({
|
|
8
|
-
justifyContent: 'start'
|
|
9
|
-
}),
|
|
10
|
-
center: css({
|
|
11
|
-
justifyContent: 'center'
|
|
12
|
-
}),
|
|
13
|
-
end: css({
|
|
14
|
-
justifyContent: 'end'
|
|
15
|
-
}),
|
|
16
|
-
'space-between': css({
|
|
17
|
-
justifyContent: 'space-between'
|
|
18
|
-
})
|
|
19
|
-
};
|
|
20
|
-
const alignItemsMap = {
|
|
21
|
-
start: css({
|
|
22
|
-
alignItems: 'start'
|
|
23
|
-
}),
|
|
24
|
-
center: css({
|
|
25
|
-
alignItems: 'center'
|
|
26
|
-
}),
|
|
27
|
-
end: css({
|
|
28
|
-
alignItems: 'end'
|
|
29
|
-
})
|
|
30
|
-
};
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { xcss } from '../xcss/xcss';
|
|
6
|
+
import Flex from './flex';
|
|
31
7
|
const flexGrowMap = {
|
|
32
|
-
hug:
|
|
8
|
+
hug: xcss({
|
|
33
9
|
flexGrow: 0
|
|
34
10
|
}),
|
|
35
|
-
fill:
|
|
11
|
+
fill: xcss({
|
|
36
12
|
width: '100%',
|
|
37
13
|
flexGrow: 1
|
|
38
14
|
})
|
|
39
15
|
};
|
|
40
|
-
const baseStyles = css({
|
|
41
|
-
display: 'flex',
|
|
42
|
-
boxSizing: 'border-box',
|
|
43
|
-
flexDirection: 'column'
|
|
44
|
-
});
|
|
45
16
|
|
|
46
17
|
/**
|
|
47
18
|
* __Stack__
|
|
48
19
|
*
|
|
49
|
-
* Stack is a primitive component based on flexbox that manages the
|
|
20
|
+
* Stack is a primitive component based on flexbox that manages the block layout of direct children.
|
|
50
21
|
*
|
|
51
22
|
* @example
|
|
52
23
|
* ```tsx
|
|
@@ -65,13 +36,20 @@ const Stack = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
65
36
|
grow,
|
|
66
37
|
space,
|
|
67
38
|
children,
|
|
68
|
-
testId
|
|
39
|
+
testId,
|
|
40
|
+
xcss
|
|
69
41
|
}, ref) => {
|
|
70
|
-
const Component = as || 'div';
|
|
71
42
|
const justifyContent = spread || alignBlock;
|
|
72
|
-
return jsx(
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
return jsx(Flex, {
|
|
44
|
+
as: as,
|
|
45
|
+
gap: space,
|
|
46
|
+
direction: "column",
|
|
47
|
+
alignItems: alignItems,
|
|
48
|
+
justifyContent: justifyContent,
|
|
49
|
+
xcss: grow ? [flexGrowMap[grow], ...(Array.isArray(xcss) ? xcss : [xcss])] :
|
|
50
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
51
|
+
xcss,
|
|
52
|
+
testId: testId,
|
|
75
53
|
ref: ref
|
|
76
54
|
}, children);
|
|
77
55
|
}));
|
package/dist/es2019/index.js
CHANGED
|
@@ -3,4 +3,6 @@ export { default as Pressable } from './components/pressable';
|
|
|
3
3
|
export { default as Inline } from './components/inline';
|
|
4
4
|
export { xcss } from './xcss/xcss';
|
|
5
5
|
export { default as Stack } from './components/stack';
|
|
6
|
-
export {
|
|
6
|
+
export { default as Flex } from './components/flex';
|
|
7
|
+
export { default as Grid } from './components/grid';
|
|
8
|
+
export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';
|
|
@@ -30,7 +30,6 @@ export const UNSAFE_buildAboveMediaQueryCSS = input => {
|
|
|
30
30
|
return UNSAFE_BREAKPOINTS_ORDERED_LIST.reduce((acc, breakpoint) => ({
|
|
31
31
|
...acc,
|
|
32
32
|
[breakpoint]: css({
|
|
33
|
-
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
34
33
|
[media.above[breakpoint]]: typeof input === 'function' ? input(breakpoint) : input
|
|
35
34
|
})
|
|
36
35
|
}), {});
|
|
@@ -15,10 +15,25 @@ export const UNSAFE_media = {
|
|
|
15
15
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
16
16
|
*/
|
|
17
17
|
xxs: `@media all`,
|
|
18
|
+
/**
|
|
19
|
+
* Used for mobile viewports.
|
|
20
|
+
*/
|
|
18
21
|
xs: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xs.min})`,
|
|
22
|
+
/**
|
|
23
|
+
* Used for tablet viewports.
|
|
24
|
+
*/
|
|
19
25
|
sm: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.sm.min})`,
|
|
26
|
+
/**
|
|
27
|
+
* Used for laptop viewports.
|
|
28
|
+
*/
|
|
20
29
|
md: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.md.min})`,
|
|
30
|
+
/**
|
|
31
|
+
* Used for desktop viewports.
|
|
32
|
+
*/
|
|
21
33
|
lg: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.lg.min})`,
|
|
34
|
+
/**
|
|
35
|
+
* Used for wide screen desktop viewports.
|
|
36
|
+
*/
|
|
22
37
|
xl: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xl.min})`
|
|
23
38
|
},
|
|
24
39
|
/**
|
package/dist/es2019/version.json
CHANGED
package/dist/es2019/xcss/xcss.js
CHANGED
|
@@ -142,7 +142,7 @@ export const parseXcss = args => {
|
|
|
142
142
|
|
|
143
143
|
// unused private functions only so we can extract the return type from a generic function
|
|
144
144
|
const boxWrapper = style => xcss(style);
|
|
145
|
-
const
|
|
145
|
+
const spaceWrapper = style => xcss(style);
|
|
146
146
|
/**
|
|
147
147
|
* ### xcss
|
|
148
148
|
*
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { forwardRef, memo } from 'react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { spaceStylesMap } from '../xcss/style-maps.partial';
|
|
6
|
+
import { parseXcss } from '../xcss/xcss';
|
|
7
|
+
var justifyContentMap = {
|
|
8
|
+
start: css({
|
|
9
|
+
justifyContent: 'start'
|
|
10
|
+
}),
|
|
11
|
+
center: css({
|
|
12
|
+
justifyContent: 'center'
|
|
13
|
+
}),
|
|
14
|
+
end: css({
|
|
15
|
+
justifyContent: 'end'
|
|
16
|
+
}),
|
|
17
|
+
'space-between': css({
|
|
18
|
+
justifyContent: 'space-between'
|
|
19
|
+
}),
|
|
20
|
+
'space-around': css({
|
|
21
|
+
justifyContent: 'space-around'
|
|
22
|
+
}),
|
|
23
|
+
'space-evenly': css({
|
|
24
|
+
justifyContent: 'space-evenly'
|
|
25
|
+
}),
|
|
26
|
+
stretch: css({
|
|
27
|
+
justifyContent: 'stretch'
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
var flexDirectionMap = {
|
|
31
|
+
column: css({
|
|
32
|
+
flexDirection: 'column'
|
|
33
|
+
}),
|
|
34
|
+
row: css({
|
|
35
|
+
flexDirection: 'row'
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
var flexWrapMap = {
|
|
39
|
+
wrap: css({
|
|
40
|
+
flexWrap: 'wrap'
|
|
41
|
+
}),
|
|
42
|
+
nowrap: css({
|
|
43
|
+
flexWrap: 'nowrap'
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
var alignItemsMap = {
|
|
47
|
+
start: css({
|
|
48
|
+
alignItems: 'start'
|
|
49
|
+
}),
|
|
50
|
+
center: css({
|
|
51
|
+
alignItems: 'center'
|
|
52
|
+
}),
|
|
53
|
+
baseline: css({
|
|
54
|
+
alignItems: 'baseline'
|
|
55
|
+
}),
|
|
56
|
+
end: css({
|
|
57
|
+
alignItems: 'end'
|
|
58
|
+
}),
|
|
59
|
+
stretch: css({
|
|
60
|
+
alignItems: 'stretch'
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
var baseStyles = css({
|
|
64
|
+
display: 'flex',
|
|
65
|
+
boxSizing: 'border-box'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* __Flex__
|
|
70
|
+
*
|
|
71
|
+
* `Flex` is a primitive component that implements the CSS Flexbox API.
|
|
72
|
+
*
|
|
73
|
+
* - [Examples](https://atlassian.design/components/primitives/flex/examples)
|
|
74
|
+
* - [Code](https://atlassian.design/components/primitives/flex/code)
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* import { Flex, Box } from '@atlaskit/primitives'
|
|
79
|
+
*
|
|
80
|
+
* const Component = () => (
|
|
81
|
+
* <Flex direction="column">
|
|
82
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
83
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
84
|
+
* </Flex>
|
|
85
|
+
* )
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
var Flex = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
89
|
+
var _ref$as = _ref.as,
|
|
90
|
+
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
91
|
+
alignItems = _ref.alignItems,
|
|
92
|
+
justifyContent = _ref.justifyContent,
|
|
93
|
+
gap = _ref.gap,
|
|
94
|
+
columnGap = _ref.columnGap,
|
|
95
|
+
rowGap = _ref.rowGap,
|
|
96
|
+
children = _ref.children,
|
|
97
|
+
testId = _ref.testId,
|
|
98
|
+
direction = _ref.direction,
|
|
99
|
+
wrap = _ref.wrap,
|
|
100
|
+
xcss = _ref.xcss;
|
|
101
|
+
var xcssClassName = xcss && parseXcss(xcss);
|
|
102
|
+
return jsx(Component, {
|
|
103
|
+
css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], direction && flexDirectionMap[direction], justifyContent && justifyContentMap[justifyContent], wrap && flexWrapMap[wrap],
|
|
104
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
105
|
+
xcssClassName && xcssClassName],
|
|
106
|
+
"data-testid": testId,
|
|
107
|
+
ref: ref
|
|
108
|
+
}, children);
|
|
109
|
+
}));
|
|
110
|
+
Flex.displayName = 'Flex';
|
|
111
|
+
export default Flex;
|