@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`45ff2cd234f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45ff2cd234f) - Fixes missing type in `Flex` component, adds `Grid` component.
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`cac98ccfb7d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cac98ccfb7d) - Introduces Flex component as common component for Stack, Inline.
|
|
14
|
+
|
|
3
15
|
## 1.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Flex
|
|
3
|
+
description: Flex is a primitive layout component that implements the CSS Flexbox API.
|
|
4
|
+
order: 0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import FlexDirection from '../../examples/constellation/flex/direction';
|
|
8
|
+
import FlexAlignItems from '../../examples/constellation/flex/align-items';
|
|
9
|
+
import FlexJustifyContent from '../../examples/constellation/flex/justify-content';
|
|
10
|
+
import FlexWrap from '../../examples/constellation/flex/wrap';
|
|
11
|
+
|
|
12
|
+
## Basic
|
|
13
|
+
|
|
14
|
+
The `Flex` component is designed as a very basic mapping to the CSS Flexbox API.
|
|
15
|
+
It can be used as a less richly-configured `Inline` or `Stack`.
|
|
16
|
+
|
|
17
|
+
<Example Component={FlexJustifyContent} packageName="@atlaskit/primitives/flex" />
|
|
18
|
+
|
|
19
|
+
## Align items
|
|
20
|
+
|
|
21
|
+
<Example Component={FlexAlignItems} packageName="@atlaskit/primitives/flex" />
|
|
22
|
+
|
|
23
|
+
## Wrap
|
|
24
|
+
|
|
25
|
+
Flex-prefixed properties in CSS do not have this prefix in the component API.
|
|
26
|
+
For example `flex-wrap` is instead applied as the `wrap` property.
|
|
27
|
+
|
|
28
|
+
<Example Component={FlexWrap} packageName="@atlaskit/primitives/flex" />
|
|
29
|
+
|
|
30
|
+
## Direction
|
|
31
|
+
|
|
32
|
+
Flex direction is applied via the `direction` property.
|
|
33
|
+
|
|
34
|
+
<Example Component={FlexDirection} packageName="@atlaskit/primitives/flex" />
|
|
@@ -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
|
+
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Primitives
|
|
3
3
|
description: Primitives are composable components that solve common layout problems.
|
|
4
|
-
|
|
5
4
|
order: 1
|
|
6
5
|
---
|
|
7
6
|
|
|
@@ -12,25 +11,30 @@ import boxUsageExample from './images/box-usage-example.png';
|
|
|
12
11
|
import inlineUsageExample from './images/inline-usage-example.png';
|
|
13
12
|
import stackUsageExample from './images/stack-usage-example.png';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Primitive components are a new type of component for layouts and placement of elements. They act as building blocks to compose different parts of the user experience, from the smallest design decisions (for example, the spacing around an icon) to larger layout decisions (for example, how a page is structured).
|
|
14
|
+
Primitive components are a new type of component for layouts and placement of elements.
|
|
15
|
+
They act as building blocks to compose different parts of the user experience,
|
|
16
|
+
from the smallest design decisions (for example, the spacing around an icon) to larger layout decisions (for example, how a page is structured).
|
|
20
17
|
|
|
21
|
-
Primitives are designed to work hand in hand with design tokens,
|
|
18
|
+
Primitives are designed to work hand in hand with design tokens,
|
|
19
|
+
to provide opinionated solutions for common low-level design decisions that engineers often have to make.
|
|
20
|
+
They are designed to reduce cognitive overhead for engineers by providing guardrails around what is recommended within our design system.
|
|
22
21
|
|
|
23
|
-
A primitive component is a pre-built solution in that they will only accept values that are valid in the Atlassian Design System, and help to implement common layout patterns. This reduces the need to look up documentation and write custom CSS.
|
|
22
|
+
A primitive component is a pre-built solution in that they will only accept values that are valid in the Atlassian Design System, and help to implement common layout patterns. This reduces the need to look up documentation and write custom CSS.
|
|
24
23
|
|
|
25
24
|
## Available Primitives
|
|
26
25
|
|
|
27
|
-
Each primitive is designed to have a single responsibility, and it should be immediately clear where each primitive should be used. However, they are also flexible enough that they should be able to be used to compose complex designs not otherwise covered in the Design Systems.
|
|
26
|
+
Each primitive is designed to have a single responsibility, and it should be immediately clear where each primitive should be used. However, they are also flexible enough that they should be able to be used to compose complex designs not otherwise covered in the Design Systems.
|
|
28
27
|
|
|
29
|
-
Currently, three primitive components are available
|
|
28
|
+
Currently, three core primitive components are available - Box, Inline and Stack. A large amount of layout problems can be reduced to laying out content:
|
|
30
29
|
- in a container (see [box](/components/primitives/box))
|
|
31
30
|
- horizontally (see [inline](/components/primitives/inline))
|
|
32
31
|
- vertically (see [stack](/components/primitives/stack))
|
|
33
32
|
|
|
33
|
+
Additional layouts not well-expressed by these core primitives can also be composed using:
|
|
34
|
+
- CSS Flexbox (see [flex](/components/primitives/flex))
|
|
35
|
+
- CSS Grid (see [grid](/components/primitives/grid))
|
|
36
|
+
- Divider (see [divider](/components/primitives/divider))
|
|
37
|
+
|
|
34
38
|
## Installation
|
|
35
39
|
|
|
36
40
|
To install primitive components, add @atlaskit/primitives as a dependency on your project:
|
|
@@ -40,17 +44,19 @@ $ yarn add @atlaskit/primitives
|
|
|
40
44
|
|
|
41
45
|
## Using Primitives
|
|
42
46
|
|
|
43
|
-
Use primitives for general layout styles for components.
|
|
47
|
+
Use primitives for general layout styles for components.
|
|
48
|
+
Primitives are not currently available in Figma, so the first step in implementing primitive components is identifying where they might fit in a given design.
|
|
49
|
+
This involves breaking down a design into its core layout components to as granular level as is useful.
|
|
44
50
|
|
|
45
51
|
<SectionMessage appearance="warning">
|
|
46
|
-
Primitives
|
|
52
|
+
Primitives should be avoided where absolute DOM control is required or very specific styling values are needed, however, this approach is more likely to produce visual elements that fail to adhere to the guidelines of the Atlassian Design System.
|
|
47
53
|
</SectionMessage>
|
|
48
54
|
|
|
49
|
-
You might like to think first about breaking down a page into Box containers, identifying larger pieces of a design that function in a similar manner or fulfill a singular purpose in a layout and grouping them together under a Box.
|
|
55
|
+
You might like to think first about breaking down a page into `Box` containers, identifying larger pieces of a design that function in a similar manner or fulfill a singular purpose in a layout and grouping them together under a Box.
|
|
50
56
|
|
|
51
57
|
<Image src={boxUsageExample} />
|
|
52
58
|
|
|
53
|
-
The behavior within and around these boxes can then be broken down into their horizontal Inline and vertical Stack components.
|
|
59
|
+
The behavior within and around these boxes can then be broken down into their horizontal `Inline` and vertical `Stack` components.
|
|
54
60
|
|
|
55
61
|
<SectionMessage>
|
|
56
62
|
The ESLint rule use-primitives offers suggestions for possible primitives in a layout.
|
|
@@ -0,0 +1,119 @@
|
|
|
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 flexDirectionMap = {
|
|
38
|
+
column: (0, _react2.css)({
|
|
39
|
+
flexDirection: 'column'
|
|
40
|
+
}),
|
|
41
|
+
row: (0, _react2.css)({
|
|
42
|
+
flexDirection: 'row'
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
var flexWrapMap = {
|
|
46
|
+
wrap: (0, _react2.css)({
|
|
47
|
+
flexWrap: 'wrap'
|
|
48
|
+
}),
|
|
49
|
+
nowrap: (0, _react2.css)({
|
|
50
|
+
flexWrap: 'nowrap'
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
var alignItemsMap = {
|
|
54
|
+
start: (0, _react2.css)({
|
|
55
|
+
alignItems: 'start'
|
|
56
|
+
}),
|
|
57
|
+
center: (0, _react2.css)({
|
|
58
|
+
alignItems: 'center'
|
|
59
|
+
}),
|
|
60
|
+
baseline: (0, _react2.css)({
|
|
61
|
+
alignItems: 'baseline'
|
|
62
|
+
}),
|
|
63
|
+
end: (0, _react2.css)({
|
|
64
|
+
alignItems: 'end'
|
|
65
|
+
}),
|
|
66
|
+
stretch: (0, _react2.css)({
|
|
67
|
+
alignItems: 'stretch'
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
var baseStyles = (0, _react2.css)({
|
|
71
|
+
display: 'flex',
|
|
72
|
+
boxSizing: 'border-box'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* __Flex__
|
|
77
|
+
*
|
|
78
|
+
* `Flex` is a primitive component that implements the CSS Flexbox API.
|
|
79
|
+
*
|
|
80
|
+
* - [Examples](https://atlassian.design/components/primitives/flex/examples)
|
|
81
|
+
* - [Code](https://atlassian.design/components/primitives/flex/code)
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* import { Flex, Box } from '@atlaskit/primitives'
|
|
86
|
+
*
|
|
87
|
+
* const Component = () => (
|
|
88
|
+
* <Flex direction="column">
|
|
89
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
90
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
91
|
+
* </Flex>
|
|
92
|
+
* )
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
var Flex = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
96
|
+
var _ref$as = _ref.as,
|
|
97
|
+
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
98
|
+
alignItems = _ref.alignItems,
|
|
99
|
+
justifyContent = _ref.justifyContent,
|
|
100
|
+
gap = _ref.gap,
|
|
101
|
+
columnGap = _ref.columnGap,
|
|
102
|
+
rowGap = _ref.rowGap,
|
|
103
|
+
children = _ref.children,
|
|
104
|
+
testId = _ref.testId,
|
|
105
|
+
direction = _ref.direction,
|
|
106
|
+
wrap = _ref.wrap,
|
|
107
|
+
xcss = _ref.xcss;
|
|
108
|
+
var xcssClassName = xcss && (0, _xcss.parseXcss)(xcss);
|
|
109
|
+
return (0, _react2.jsx)(Component, {
|
|
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],
|
|
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
|
+
Flex.displayName = 'Flex';
|
|
118
|
+
var _default = Flex;
|
|
119
|
+
exports.default = _default;
|
|
@@ -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
|
@@ -10,6 +10,18 @@ Object.defineProperty(exports, "Box", {
|
|
|
10
10
|
return _box.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
+
Object.defineProperty(exports, "Flex", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _flex.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "Grid", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _grid.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
13
25
|
Object.defineProperty(exports, "Inline", {
|
|
14
26
|
enumerable: true,
|
|
15
27
|
get: function get() {
|
|
@@ -40,6 +52,12 @@ Object.defineProperty(exports, "UNSAFE_media", {
|
|
|
40
52
|
return _responsive.UNSAFE_media;
|
|
41
53
|
}
|
|
42
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "media", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function get() {
|
|
58
|
+
return _responsive.media;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
43
61
|
Object.defineProperty(exports, "xcss", {
|
|
44
62
|
enumerable: true,
|
|
45
63
|
get: function get() {
|
|
@@ -51,4 +69,6 @@ var _pressable = _interopRequireDefault(require("./components/pressable"));
|
|
|
51
69
|
var _inline = _interopRequireDefault(require("./components/inline"));
|
|
52
70
|
var _xcss = require("./xcss/xcss");
|
|
53
71
|
var _stack = _interopRequireDefault(require("./components/stack"));
|
|
72
|
+
var _flex = _interopRequireDefault(require("./components/flex"));
|
|
73
|
+
var _grid = _interopRequireDefault(require("./components/grid"));
|
|
54
74
|
var _responsive = require("./responsive");
|