@atlaskit/primitives 1.0.1 → 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 +6 -0
- package/constellation/grid/code.mdx +7 -0
- package/constellation/grid/examples.mdx +38 -0
- package/dist/cjs/components/flex.js +7 -3
- 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 +13 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/xcss/xcss.js +1 -1
- package/dist/es2019/components/flex.js +6 -3
- 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 +2 -1
- package/dist/es2019/responsive/build-media-query-css.js +0 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/xcss/xcss.js +1 -1
- package/dist/esm/components/flex.js +7 -3
- 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 +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/xcss/xcss.js +1 -1
- package/dist/types/components/flex.d.ts +17 -8
- 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/index.d.ts +2 -1
- package/dist/types/xcss/xcss.d.ts +11 -14
- package/dist/types-ts4.5/components/flex.d.ts +17 -8
- 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/index.d.ts +2 -1
- package/dist/types-ts4.5/xcss/xcss.d.ts +11 -14
- package/package.json +21 -14
- package/report.api.md +270 -59
- package/tmp/api-report-tmp.d.ts +122 -37
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Grid
|
|
3
|
+
description: Grid is a primitive layout component that implements the CSS Grid API.
|
|
4
|
+
order: 0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import GridBasic from '../../examples/constellation/grid/basic';
|
|
8
|
+
import GridGap from '../../examples/constellation/grid/gap';
|
|
9
|
+
import GridTemplate from '../../examples/constellation/grid/template';
|
|
10
|
+
import GridAutoFlow from '../../examples/constellation/grid/auto-flow';
|
|
11
|
+
|
|
12
|
+
## Basic
|
|
13
|
+
|
|
14
|
+
The `Grid` component is designed as a very basic mapping to the CSS Grid API.
|
|
15
|
+
It can be used as an alternative to [Flex](/components/primitives/flex), [Inline](/components/primitives/inline) or [Stack](/components/primitives/stack).
|
|
16
|
+
|
|
17
|
+
<Example Component={GridBasic} packageName="@atlaskit/primitives/grid" />
|
|
18
|
+
|
|
19
|
+
## Gap properties
|
|
20
|
+
|
|
21
|
+
Gap properties - `rowGap`, `columnGap` and `gap` only allow token-backed values. This is to aid ergonomics
|
|
22
|
+
and keep the whitespace of the grid harmonious with our spacing system.
|
|
23
|
+
|
|
24
|
+
<Example Component={GridGap} packageName="@atlaskit/primitives/grid" />
|
|
25
|
+
|
|
26
|
+
## Template syntax
|
|
27
|
+
|
|
28
|
+
Grid-prefixed template properties in CSS do not have this prefix in the component API.
|
|
29
|
+
For example `grid-template-*` are instead applied as `templateColumns`, `templateRows` and `templateArea` properties.
|
|
30
|
+
|
|
31
|
+
<Example Component={GridTemplate} packageName="@atlaskit/primitives/grid" />
|
|
32
|
+
|
|
33
|
+
## Autoflow syntax
|
|
34
|
+
|
|
35
|
+
Grid-prefixed properties in CSS do not have this prefix in the component API. `grid-auto-flow` is instead applied via `autoFlow`.
|
|
36
|
+
|
|
37
|
+
<Example Component={GridAutoFlow} packageName="@atlaskit/primitives/grid" />
|
|
38
|
+
|
|
@@ -62,6 +62,9 @@ var alignItemsMap = {
|
|
|
62
62
|
}),
|
|
63
63
|
end: (0, _react2.css)({
|
|
64
64
|
alignItems: 'end'
|
|
65
|
+
}),
|
|
66
|
+
stretch: (0, _react2.css)({
|
|
67
|
+
alignItems: 'stretch'
|
|
65
68
|
})
|
|
66
69
|
};
|
|
67
70
|
var baseStyles = (0, _react2.css)({
|
|
@@ -90,20 +93,21 @@ var baseStyles = (0, _react2.css)({
|
|
|
90
93
|
* ```
|
|
91
94
|
*/
|
|
92
95
|
var Flex = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
93
|
-
var as = _ref.as,
|
|
96
|
+
var _ref$as = _ref.as,
|
|
97
|
+
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
94
98
|
alignItems = _ref.alignItems,
|
|
95
99
|
justifyContent = _ref.justifyContent,
|
|
96
100
|
gap = _ref.gap,
|
|
101
|
+
columnGap = _ref.columnGap,
|
|
97
102
|
rowGap = _ref.rowGap,
|
|
98
103
|
children = _ref.children,
|
|
99
104
|
testId = _ref.testId,
|
|
100
105
|
direction = _ref.direction,
|
|
101
106
|
wrap = _ref.wrap,
|
|
102
107
|
xcss = _ref.xcss;
|
|
103
|
-
var Component = as || 'div';
|
|
104
108
|
var xcssClassName = xcss && (0, _xcss.parseXcss)(xcss);
|
|
105
109
|
return (0, _react2.jsx)(Component, {
|
|
106
|
-
css: [baseStyles, gap && _styleMaps.spaceStylesMap.gap[gap], rowGap && _styleMaps.spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], direction && flexDirectionMap[direction], justifyContent && justifyContentMap[justifyContent], wrap && flexWrapMap[wrap],
|
|
110
|
+
css: [baseStyles, gap && _styleMaps.spaceStylesMap.gap[gap], columnGap && _styleMaps.spaceStylesMap.columnGap[columnGap], rowGap && _styleMaps.spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], direction && flexDirectionMap[direction], justifyContent && justifyContentMap[justifyContent], wrap && flexWrapMap[wrap],
|
|
107
111
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
108
112
|
xcssClassName && xcssClassName],
|
|
109
113
|
"data-testid": testId,
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _react2 = require("@emotion/react");
|
|
9
|
+
var _styleMaps = require("../xcss/style-maps.partial");
|
|
10
|
+
var _xcss = require("../xcss/xcss");
|
|
11
|
+
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
12
|
+
/** @jsx jsx */
|
|
13
|
+
|
|
14
|
+
var justifyContentMap = {
|
|
15
|
+
start: (0, _react2.css)({
|
|
16
|
+
justifyContent: 'start'
|
|
17
|
+
}),
|
|
18
|
+
center: (0, _react2.css)({
|
|
19
|
+
justifyContent: 'center'
|
|
20
|
+
}),
|
|
21
|
+
end: (0, _react2.css)({
|
|
22
|
+
justifyContent: 'end'
|
|
23
|
+
}),
|
|
24
|
+
'space-between': (0, _react2.css)({
|
|
25
|
+
justifyContent: 'space-between'
|
|
26
|
+
}),
|
|
27
|
+
'space-around': (0, _react2.css)({
|
|
28
|
+
justifyContent: 'space-around'
|
|
29
|
+
}),
|
|
30
|
+
'space-evenly': (0, _react2.css)({
|
|
31
|
+
justifyContent: 'space-evenly'
|
|
32
|
+
}),
|
|
33
|
+
stretch: (0, _react2.css)({
|
|
34
|
+
justifyContent: 'stretch'
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
var alignItemsMap = {
|
|
38
|
+
start: (0, _react2.css)({
|
|
39
|
+
alignItems: 'start'
|
|
40
|
+
}),
|
|
41
|
+
center: (0, _react2.css)({
|
|
42
|
+
alignItems: 'center'
|
|
43
|
+
}),
|
|
44
|
+
baseline: (0, _react2.css)({
|
|
45
|
+
alignItems: 'baseline'
|
|
46
|
+
}),
|
|
47
|
+
end: (0, _react2.css)({
|
|
48
|
+
alignItems: 'end'
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
var baseStyles = (0, _react2.css)({
|
|
52
|
+
display: 'grid',
|
|
53
|
+
boxSizing: 'border-box'
|
|
54
|
+
});
|
|
55
|
+
var gridAutoFlowMap = {
|
|
56
|
+
row: (0, _react2.css)({
|
|
57
|
+
gridAutoFlow: 'row'
|
|
58
|
+
}),
|
|
59
|
+
column: (0, _react2.css)({
|
|
60
|
+
gridAutoFlow: 'column'
|
|
61
|
+
}),
|
|
62
|
+
dense: (0, _react2.css)({
|
|
63
|
+
gridAutoFlow: 'dense'
|
|
64
|
+
}),
|
|
65
|
+
'row dense': (0, _react2.css)({
|
|
66
|
+
gridAutoFlow: 'row dense'
|
|
67
|
+
}),
|
|
68
|
+
'column dense': (0, _react2.css)({
|
|
69
|
+
gridAutoFlow: 'column dense'
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* __Grid__
|
|
75
|
+
*
|
|
76
|
+
* `Grid` is a primitive component that implements the CSS Grid API.
|
|
77
|
+
*
|
|
78
|
+
* - [Examples](https://atlassian.design/components/primitives/grid/examples)
|
|
79
|
+
* - [Code](https://atlassian.design/components/primitives/grid/code)
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { Grid, Box } from '@atlaskit/primitives'
|
|
84
|
+
*
|
|
85
|
+
* const Component = () => (
|
|
86
|
+
* <Grid gap="space.100" gridColumns="1fr 1fr">
|
|
87
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
88
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
89
|
+
* </Grid>
|
|
90
|
+
* )
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
var Grid = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
94
|
+
var as = _ref.as,
|
|
95
|
+
alignItems = _ref.alignItems,
|
|
96
|
+
justifyContent = _ref.justifyContent,
|
|
97
|
+
gap = _ref.gap,
|
|
98
|
+
columnGap = _ref.columnGap,
|
|
99
|
+
rowGap = _ref.rowGap,
|
|
100
|
+
children = _ref.children,
|
|
101
|
+
testId = _ref.testId,
|
|
102
|
+
autoFlow = _ref.autoFlow,
|
|
103
|
+
gridTemplateAreas = _ref.templateAreas,
|
|
104
|
+
gridTemplateRows = _ref.templateRows,
|
|
105
|
+
gridTemplateColumns = _ref.templateColumns,
|
|
106
|
+
xcss = _ref.xcss;
|
|
107
|
+
var Component = as || 'div';
|
|
108
|
+
var xcssClassName = xcss && (0, _xcss.parseXcss)(xcss);
|
|
109
|
+
var style = gridTemplateAreas || gridTemplateColumns || gridTemplateRows ? Object.assign({}, {
|
|
110
|
+
gridTemplateAreas: gridTemplateAreas ? gridTemplateAreas.map(function (str) {
|
|
111
|
+
return "\"".concat(str, "\"");
|
|
112
|
+
}).join('\n') : undefined,
|
|
113
|
+
gridTemplateColumns: gridTemplateColumns,
|
|
114
|
+
gridTemplateRows: gridTemplateRows
|
|
115
|
+
}) : undefined;
|
|
116
|
+
return (0, _react2.jsx)(Component, {
|
|
117
|
+
style: style,
|
|
118
|
+
css: [baseStyles, gap && _styleMaps.spaceStylesMap.gap[gap], columnGap && _styleMaps.spaceStylesMap.columnGap[columnGap], rowGap && _styleMaps.spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], justifyContent && justifyContentMap[justifyContent], autoFlow && gridAutoFlowMap[autoFlow],
|
|
119
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
120
|
+
xcssClassName && xcssClassName],
|
|
121
|
+
"data-testid": testId,
|
|
122
|
+
ref: ref
|
|
123
|
+
}, children);
|
|
124
|
+
}));
|
|
125
|
+
Grid.displayName = 'Grid';
|
|
126
|
+
var _default = Grid;
|
|
127
|
+
exports.default = _default;
|
|
@@ -1,64 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _react = require("react");
|
|
8
10
|
var _react2 = require("@emotion/react");
|
|
9
|
-
var _styleMaps = require("../xcss/style-maps.partial");
|
|
10
11
|
var _xcss = require("../xcss/xcss");
|
|
12
|
+
var _flex = _interopRequireDefault(require("./flex"));
|
|
11
13
|
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
12
14
|
/** @jsx jsx */
|
|
13
15
|
|
|
14
|
-
var alignItemsMap = {
|
|
15
|
-
center: (0, _react2.css)({
|
|
16
|
-
alignItems: 'center'
|
|
17
|
-
}),
|
|
18
|
-
baseline: (0, _react2.css)({
|
|
19
|
-
alignItems: 'baseline'
|
|
20
|
-
}),
|
|
21
|
-
start: (0, _react2.css)({
|
|
22
|
-
alignItems: 'flex-start'
|
|
23
|
-
}),
|
|
24
|
-
end: (0, _react2.css)({
|
|
25
|
-
alignItems: 'flex-end'
|
|
26
|
-
}),
|
|
27
|
-
stretch: (0, _react2.css)({
|
|
28
|
-
alignItems: 'stretch'
|
|
29
|
-
})
|
|
30
|
-
};
|
|
31
|
-
var justifyContentMap = {
|
|
32
|
-
start: (0, _react2.css)({
|
|
33
|
-
justifyContent: 'flex-start'
|
|
34
|
-
}),
|
|
35
|
-
center: (0, _react2.css)({
|
|
36
|
-
justifyContent: 'center'
|
|
37
|
-
}),
|
|
38
|
-
end: (0, _react2.css)({
|
|
39
|
-
justifyContent: 'flex-end'
|
|
40
|
-
}),
|
|
41
|
-
'space-between': (0, _react2.css)({
|
|
42
|
-
justifyContent: 'space-between'
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
16
|
var flexGrowMap = {
|
|
46
|
-
hug: (0,
|
|
17
|
+
hug: (0, _xcss.xcss)({
|
|
47
18
|
flexGrow: 0
|
|
48
19
|
}),
|
|
49
|
-
fill: (0,
|
|
20
|
+
fill: (0, _xcss.xcss)({
|
|
50
21
|
width: '100%',
|
|
51
22
|
flexGrow: 1
|
|
52
23
|
})
|
|
53
24
|
};
|
|
54
|
-
var flexWrapStyles = (0, _react2.css)({
|
|
55
|
-
flexWrap: 'wrap'
|
|
56
|
-
});
|
|
57
|
-
var baseStyles = (0, _react2.css)({
|
|
58
|
-
display: 'flex',
|
|
59
|
-
boxSizing: 'border-box',
|
|
60
|
-
flexDirection: 'row'
|
|
61
|
-
});
|
|
62
25
|
var separatorStyles = (0, _react2.css)({
|
|
63
26
|
color: "var(--ds-text-subtle, #42526E)",
|
|
64
27
|
marginBlock: "var(--ds-space-0, 0px)",
|
|
@@ -103,7 +66,6 @@ var Inline = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
103
66
|
xcss = _ref2.xcss,
|
|
104
67
|
testId = _ref2.testId,
|
|
105
68
|
rawChildren = _ref2.children;
|
|
106
|
-
var Component = as || 'div';
|
|
107
69
|
var separatorComponent = typeof separator === 'string' ? (0, _react2.jsx)(Separator, null, separator) : separator;
|
|
108
70
|
var children = separatorComponent ? _react.Children.toArray(rawChildren).filter(Boolean).map(function (child, index) {
|
|
109
71
|
return (0, _react2.jsx)(_react.Fragment, {
|
|
@@ -111,12 +73,18 @@ var Inline = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
111
73
|
}, separator && index > 0 ? separatorComponent : null, child);
|
|
112
74
|
}) : rawChildren;
|
|
113
75
|
var justifyContent = spread || alignInline;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
76
|
+
return (0, _react2.jsx)(_flex.default, {
|
|
77
|
+
as: as,
|
|
78
|
+
alignItems: alignItems,
|
|
79
|
+
justifyContent: justifyContent,
|
|
80
|
+
direction: "row",
|
|
81
|
+
gap: space,
|
|
82
|
+
rowGap: rowSpace,
|
|
83
|
+
wrap: shouldWrap ? 'wrap' : undefined,
|
|
84
|
+
xcss: grow ? [flexGrowMap[grow]].concat((0, _toConsumableArray2.default)(Array.isArray(xcss) ? xcss : [xcss])) :
|
|
117
85
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
xcss,
|
|
87
|
+
testId: testId,
|
|
120
88
|
ref: ref
|
|
121
89
|
}, children);
|
|
122
90
|
}));
|
|
@@ -1,59 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _react = require("react");
|
|
8
10
|
var _react2 = require("@emotion/react");
|
|
9
|
-
var
|
|
11
|
+
var _xcss = require("../xcss/xcss");
|
|
12
|
+
var _flex = _interopRequireDefault(require("./flex"));
|
|
10
13
|
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
11
14
|
/** @jsx jsx */
|
|
12
15
|
|
|
13
|
-
var justifyContentMap = {
|
|
14
|
-
start: (0, _react2.css)({
|
|
15
|
-
justifyContent: 'start'
|
|
16
|
-
}),
|
|
17
|
-
center: (0, _react2.css)({
|
|
18
|
-
justifyContent: 'center'
|
|
19
|
-
}),
|
|
20
|
-
end: (0, _react2.css)({
|
|
21
|
-
justifyContent: 'end'
|
|
22
|
-
}),
|
|
23
|
-
'space-between': (0, _react2.css)({
|
|
24
|
-
justifyContent: 'space-between'
|
|
25
|
-
})
|
|
26
|
-
};
|
|
27
|
-
var alignItemsMap = {
|
|
28
|
-
start: (0, _react2.css)({
|
|
29
|
-
alignItems: 'start'
|
|
30
|
-
}),
|
|
31
|
-
center: (0, _react2.css)({
|
|
32
|
-
alignItems: 'center'
|
|
33
|
-
}),
|
|
34
|
-
end: (0, _react2.css)({
|
|
35
|
-
alignItems: 'end'
|
|
36
|
-
})
|
|
37
|
-
};
|
|
38
16
|
var flexGrowMap = {
|
|
39
|
-
hug: (0,
|
|
17
|
+
hug: (0, _xcss.xcss)({
|
|
40
18
|
flexGrow: 0
|
|
41
19
|
}),
|
|
42
|
-
fill: (0,
|
|
20
|
+
fill: (0, _xcss.xcss)({
|
|
43
21
|
width: '100%',
|
|
44
22
|
flexGrow: 1
|
|
45
23
|
})
|
|
46
24
|
};
|
|
47
|
-
var baseStyles = (0, _react2.css)({
|
|
48
|
-
display: 'flex',
|
|
49
|
-
boxSizing: 'border-box',
|
|
50
|
-
flexDirection: 'column'
|
|
51
|
-
});
|
|
52
25
|
|
|
53
26
|
/**
|
|
54
27
|
* __Stack__
|
|
55
28
|
*
|
|
56
|
-
* Stack is a primitive component based on flexbox that manages the
|
|
29
|
+
* Stack is a primitive component based on flexbox that manages the block layout of direct children.
|
|
57
30
|
*
|
|
58
31
|
* @example
|
|
59
32
|
* ```tsx
|
|
@@ -72,12 +45,19 @@ var Stack = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(f
|
|
|
72
45
|
grow = _ref.grow,
|
|
73
46
|
space = _ref.space,
|
|
74
47
|
children = _ref.children,
|
|
75
|
-
testId = _ref.testId
|
|
76
|
-
|
|
48
|
+
testId = _ref.testId,
|
|
49
|
+
xcss = _ref.xcss;
|
|
77
50
|
var justifyContent = spread || alignBlock;
|
|
78
|
-
return (0, _react2.jsx)(
|
|
79
|
-
|
|
80
|
-
|
|
51
|
+
return (0, _react2.jsx)(_flex.default, {
|
|
52
|
+
as: as,
|
|
53
|
+
gap: space,
|
|
54
|
+
direction: "column",
|
|
55
|
+
alignItems: alignItems,
|
|
56
|
+
justifyContent: justifyContent,
|
|
57
|
+
xcss: grow ? [flexGrowMap[grow]].concat((0, _toConsumableArray2.default)(Array.isArray(xcss) ? xcss : [xcss])) :
|
|
58
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
59
|
+
xcss,
|
|
60
|
+
testId: testId,
|
|
81
61
|
ref: ref
|
|
82
62
|
}, children);
|
|
83
63
|
}));
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,6 +16,12 @@ Object.defineProperty(exports, "Flex", {
|
|
|
16
16
|
return _flex.default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "Grid", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _grid.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
19
25
|
Object.defineProperty(exports, "Inline", {
|
|
20
26
|
enumerable: true,
|
|
21
27
|
get: function get() {
|
|
@@ -46,6 +52,12 @@ Object.defineProperty(exports, "UNSAFE_media", {
|
|
|
46
52
|
return _responsive.UNSAFE_media;
|
|
47
53
|
}
|
|
48
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "media", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function get() {
|
|
58
|
+
return _responsive.media;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
49
61
|
Object.defineProperty(exports, "xcss", {
|
|
50
62
|
enumerable: true,
|
|
51
63
|
get: function get() {
|
|
@@ -58,4 +70,5 @@ var _inline = _interopRequireDefault(require("./components/inline"));
|
|
|
58
70
|
var _xcss = require("./xcss/xcss");
|
|
59
71
|
var _stack = _interopRequireDefault(require("./components/stack"));
|
|
60
72
|
var _flex = _interopRequireDefault(require("./components/flex"));
|
|
73
|
+
var _grid = _interopRequireDefault(require("./components/grid"));
|
|
61
74
|
var _responsive = require("./responsive");
|
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
|
/**
|
|
@@ -55,6 +55,9 @@ const alignItemsMap = {
|
|
|
55
55
|
}),
|
|
56
56
|
end: css({
|
|
57
57
|
alignItems: 'end'
|
|
58
|
+
}),
|
|
59
|
+
stretch: css({
|
|
60
|
+
alignItems: 'stretch'
|
|
58
61
|
})
|
|
59
62
|
};
|
|
60
63
|
const baseStyles = css({
|
|
@@ -83,10 +86,11 @@ const baseStyles = css({
|
|
|
83
86
|
* ```
|
|
84
87
|
*/
|
|
85
88
|
const Flex = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
86
|
-
as,
|
|
89
|
+
as: Component = 'div',
|
|
87
90
|
alignItems,
|
|
88
91
|
justifyContent,
|
|
89
92
|
gap,
|
|
93
|
+
columnGap,
|
|
90
94
|
rowGap,
|
|
91
95
|
children,
|
|
92
96
|
testId,
|
|
@@ -94,10 +98,9 @@ const Flex = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
94
98
|
wrap,
|
|
95
99
|
xcss
|
|
96
100
|
}, ref) => {
|
|
97
|
-
const Component = as || 'div';
|
|
98
101
|
const xcssClassName = xcss && parseXcss(xcss);
|
|
99
102
|
return jsx(Component, {
|
|
100
|
-
css: [baseStyles, gap && spaceStylesMap.gap[gap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], direction && flexDirectionMap[direction], justifyContent && justifyContentMap[justifyContent], wrap && flexWrapMap[wrap],
|
|
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],
|
|
101
104
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
102
105
|
xcssClassName && xcssClassName],
|
|
103
106
|
"data-testid": testId,
|
|
@@ -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;
|