@atlaskit/primitives 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/constellation/flex/code.mdx +7 -0
- package/constellation/flex/examples.mdx +34 -0
- package/constellation/overview/index.mdx +20 -14
- package/dist/cjs/components/flex.js +115 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/responsive/media-helper.js +15 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/flex.js +108 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/responsive/media-helper.js +15 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/flex.js +107 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/responsive/media-helper.js +15 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.d.ts +1 -2
- package/dist/types/components/flex.d.ts +128 -0
- package/dist/types/components/inline.d.ts +1 -1
- package/dist/types/components/types.d.ts +2 -6
- package/dist/types/index.d.ts +2 -0
- package/dist/types/responsive/media-helper.d.ts +30 -0
- package/dist/types/xcss/xcss.d.ts +4 -4
- package/dist/types-ts4.5/components/box.d.ts +1 -2
- package/dist/types-ts4.5/components/flex.d.ts +128 -0
- package/dist/types-ts4.5/components/inline.d.ts +1 -1
- package/dist/types-ts4.5/components/types.d.ts +2 -6
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/responsive/media-helper.d.ts +30 -0
- package/dist/types-ts4.5/xcss/xcss.d.ts +4 -4
- package/extract-react-types/box-props.tsx +1 -9
- package/package.json +12 -3
- package/report.api.md +141 -23
- package/tmp/api-report-tmp.d.ts +83 -20
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ElementType, ReactNode } from 'react';
|
|
3
|
+
import { type Space } from '../xcss/style-maps.partial';
|
|
4
|
+
import type { BasePrimitiveProps } from './types';
|
|
5
|
+
export type FlexProps<T extends ElementType = 'div'> = {
|
|
6
|
+
/**
|
|
7
|
+
* The DOM element to render as the Flex. Defaults to `div`.
|
|
8
|
+
*/
|
|
9
|
+
as?: 'div' | 'span' | 'ul' | 'ol';
|
|
10
|
+
/**
|
|
11
|
+
* Used to align children along the main axis.
|
|
12
|
+
*/
|
|
13
|
+
justifyContent?: JustifyContent;
|
|
14
|
+
/**
|
|
15
|
+
* Used to align children along the cross axis.
|
|
16
|
+
*/
|
|
17
|
+
alignItems?: AlignItems;
|
|
18
|
+
/**
|
|
19
|
+
* Represents the space between each child.
|
|
20
|
+
*/
|
|
21
|
+
gap?: Space;
|
|
22
|
+
/**
|
|
23
|
+
* Represents the space between each child.
|
|
24
|
+
*/
|
|
25
|
+
rowGap?: Space;
|
|
26
|
+
/**
|
|
27
|
+
* Represents the flex direction property of CSS flexbox.
|
|
28
|
+
*/
|
|
29
|
+
direction?: Direction;
|
|
30
|
+
/**
|
|
31
|
+
* Represents the flex wrap property of CSS flexbox.
|
|
32
|
+
*/
|
|
33
|
+
wrap?: Wrap;
|
|
34
|
+
/**
|
|
35
|
+
* Elements to be rendered inside the Stack.
|
|
36
|
+
*/
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Forwarded ref element
|
|
40
|
+
*/
|
|
41
|
+
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
42
|
+
} & BasePrimitiveProps;
|
|
43
|
+
export type AlignItems = keyof typeof alignItemsMap;
|
|
44
|
+
export type JustifyContent = keyof typeof justifyContentMap;
|
|
45
|
+
export type Direction = keyof typeof flexDirectionMap;
|
|
46
|
+
export type Wrap = keyof typeof flexWrapMap;
|
|
47
|
+
declare const justifyContentMap: {
|
|
48
|
+
readonly start: import("@emotion/react").SerializedStyles;
|
|
49
|
+
readonly center: import("@emotion/react").SerializedStyles;
|
|
50
|
+
readonly end: import("@emotion/react").SerializedStyles;
|
|
51
|
+
readonly 'space-between': import("@emotion/react").SerializedStyles;
|
|
52
|
+
readonly 'space-around': import("@emotion/react").SerializedStyles;
|
|
53
|
+
readonly 'space-evenly': import("@emotion/react").SerializedStyles;
|
|
54
|
+
readonly stretch: import("@emotion/react").SerializedStyles;
|
|
55
|
+
};
|
|
56
|
+
declare const flexDirectionMap: {
|
|
57
|
+
readonly column: import("@emotion/react").SerializedStyles;
|
|
58
|
+
readonly row: import("@emotion/react").SerializedStyles;
|
|
59
|
+
};
|
|
60
|
+
declare const flexWrapMap: {
|
|
61
|
+
readonly wrap: import("@emotion/react").SerializedStyles;
|
|
62
|
+
readonly nowrap: import("@emotion/react").SerializedStyles;
|
|
63
|
+
};
|
|
64
|
+
declare const alignItemsMap: {
|
|
65
|
+
readonly start: import("@emotion/react").SerializedStyles;
|
|
66
|
+
readonly center: import("@emotion/react").SerializedStyles;
|
|
67
|
+
readonly baseline: import("@emotion/react").SerializedStyles;
|
|
68
|
+
readonly end: import("@emotion/react").SerializedStyles;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* __Flex__
|
|
72
|
+
*
|
|
73
|
+
* `Flex` is a primitive component that implements the CSS Flexbox API.
|
|
74
|
+
*
|
|
75
|
+
* - [Examples](https://atlassian.design/components/primitives/flex/examples)
|
|
76
|
+
* - [Code](https://atlassian.design/components/primitives/flex/code)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* import { Flex, Box } from '@atlaskit/primitives'
|
|
81
|
+
*
|
|
82
|
+
* const Component = () => (
|
|
83
|
+
* <Flex direction="column">
|
|
84
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
85
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
86
|
+
* </Flex>
|
|
87
|
+
* )
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare const Flex: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<{
|
|
91
|
+
/**
|
|
92
|
+
* The DOM element to render as the Flex. Defaults to `div`.
|
|
93
|
+
*/
|
|
94
|
+
as?: "div" | "ol" | "span" | "ul" | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Used to align children along the main axis.
|
|
97
|
+
*/
|
|
98
|
+
justifyContent?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Used to align children along the cross axis.
|
|
101
|
+
*/
|
|
102
|
+
alignItems?: "start" | "center" | "end" | "baseline" | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Represents the space between each child.
|
|
105
|
+
*/
|
|
106
|
+
gap?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Represents the space between each child.
|
|
109
|
+
*/
|
|
110
|
+
rowGap?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Represents the flex direction property of CSS flexbox.
|
|
113
|
+
*/
|
|
114
|
+
direction?: "column" | "row" | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Represents the flex wrap property of CSS flexbox.
|
|
117
|
+
*/
|
|
118
|
+
wrap?: "wrap" | "nowrap" | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Elements to be rendered inside the Stack.
|
|
121
|
+
*/
|
|
122
|
+
children: ReactNode;
|
|
123
|
+
/**
|
|
124
|
+
* Forwarded ref element
|
|
125
|
+
*/
|
|
126
|
+
ref?: any;
|
|
127
|
+
} & BasePrimitiveProps, "gap" | "rowGap" | "alignItems" | "direction" | "justifyContent" | "as" | "children" | keyof BasePrimitiveProps | "wrap"> & import("react").RefAttributes<any>>>;
|
|
128
|
+
export default Flex;
|
|
@@ -76,5 +76,5 @@ export type Grow = 'hug' | 'fill';
|
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
78
|
*/
|
|
79
|
-
declare const Inline: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<InlineProps<ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"
|
|
79
|
+
declare const Inline: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<InlineProps<ElementType<any>>, "as" | "children" | "testId" | "xcss" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>>;
|
|
80
80
|
export default Inline;
|
|
@@ -9,12 +9,8 @@ export type BasePrimitiveProps = {
|
|
|
9
9
|
* Inline styles to be applied to the primitive.
|
|
10
10
|
*/
|
|
11
11
|
style?: CSSProperties;
|
|
12
|
-
};
|
|
13
|
-
type BoxXCSSArray = Array<BoxXCSSArray | BoxXCSS | false | undefined>;
|
|
14
|
-
export type PublicBoxPropsBase = {
|
|
15
12
|
/**
|
|
16
|
-
*
|
|
13
|
+
* Apply a subset of permitted styles, powered by Atlassian Design System tokens.
|
|
17
14
|
*/
|
|
18
|
-
xcss?: BoxXCSS |
|
|
15
|
+
xcss?: BoxXCSS | BoxXCSS[];
|
|
19
16
|
};
|
|
20
|
-
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export type { Dimension, BackgroundColor, Space, BorderColor, BorderRadius, BorderWidth, Layer, Shadow, } from './xcss/style-maps.partial';
|
|
1
2
|
export { default as Box, type BoxProps } from './components/box';
|
|
2
3
|
export { default as Pressable, type PressableProps, } from './components/pressable';
|
|
3
4
|
export { default as Inline, type InlineProps } from './components/inline';
|
|
4
5
|
export { xcss } from './xcss/xcss';
|
|
5
6
|
export { default as Stack, type StackProps } from './components/stack';
|
|
7
|
+
export { default as Flex, type FlexProps } from './components/flex';
|
|
6
8
|
export { UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG, type Breakpoint, } from './responsive';
|
|
@@ -13,10 +13,25 @@ export declare const UNSAFE_media: {
|
|
|
13
13
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
14
14
|
*/
|
|
15
15
|
readonly xxs: "@media all";
|
|
16
|
+
/**
|
|
17
|
+
* Used for mobile viewports.
|
|
18
|
+
*/
|
|
16
19
|
readonly xs: "@media (min-width: 30rem)";
|
|
20
|
+
/**
|
|
21
|
+
* Used for tablet viewports.
|
|
22
|
+
*/
|
|
17
23
|
readonly sm: "@media (min-width: 48rem)";
|
|
24
|
+
/**
|
|
25
|
+
* Used for laptop viewports.
|
|
26
|
+
*/
|
|
18
27
|
readonly md: "@media (min-width: 64rem)";
|
|
28
|
+
/**
|
|
29
|
+
* Used for desktop viewports.
|
|
30
|
+
*/
|
|
19
31
|
readonly lg: "@media (min-width: 90rem)";
|
|
32
|
+
/**
|
|
33
|
+
* Used for wide screen desktop viewports.
|
|
34
|
+
*/
|
|
20
35
|
readonly xl: "@media (min-width: 110rem)";
|
|
21
36
|
};
|
|
22
37
|
/**
|
|
@@ -66,10 +81,25 @@ export declare const media: {
|
|
|
66
81
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
67
82
|
*/
|
|
68
83
|
readonly xxs: "@media all";
|
|
84
|
+
/**
|
|
85
|
+
* Used for mobile viewports.
|
|
86
|
+
*/
|
|
69
87
|
readonly xs: "@media (min-width: 30rem)";
|
|
88
|
+
/**
|
|
89
|
+
* Used for tablet viewports.
|
|
90
|
+
*/
|
|
70
91
|
readonly sm: "@media (min-width: 48rem)";
|
|
92
|
+
/**
|
|
93
|
+
* Used for laptop viewports.
|
|
94
|
+
*/
|
|
71
95
|
readonly md: "@media (min-width: 64rem)";
|
|
96
|
+
/**
|
|
97
|
+
* Used for desktop viewports.
|
|
98
|
+
*/
|
|
72
99
|
readonly lg: "@media (min-width: 90rem)";
|
|
100
|
+
/**
|
|
101
|
+
* Used for wide screen desktop viewports.
|
|
102
|
+
*/
|
|
73
103
|
readonly xl: "@media (min-width: 110rem)";
|
|
74
104
|
};
|
|
75
105
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { css as cssEmotion } from '@emotion/react';
|
|
3
|
-
import { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
|
|
3
|
+
import type { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
|
|
4
4
|
import type * as CSS from 'csstype';
|
|
5
5
|
import { Box, Inline } from '../index';
|
|
6
6
|
import type { MediaQuery } from '../responsive/types';
|
|
@@ -27,7 +27,7 @@ declare const inlineWrapper: (style: any) => {
|
|
|
27
27
|
readonly [uniqueSymbol]: InlineStyles;
|
|
28
28
|
};
|
|
29
29
|
type XCSS = ReturnType<typeof boxWrapper> | ReturnType<typeof inlineWrapper>;
|
|
30
|
-
type XCSSArray = Array<XCSS |
|
|
30
|
+
type XCSSArray = Array<XCSS | false | undefined>;
|
|
31
31
|
type AllowedBoxStyles = keyof SafeCSSObject;
|
|
32
32
|
type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' | 'insetBlockStart' | 'insetInline' | 'insetInlineEnd' | 'insetInlineStart' | 'margin' | 'marginBlock' | 'marginBlockEnd' | 'marginBlockStart' | 'marginInline' | 'marginInlineEnd' | 'marginInlineStart' | 'outlineOffset' | 'padding' | 'paddingBlock' | 'paddingBlockEnd' | 'paddingBlockStart' | 'paddingBottom' | 'paddingInline' | 'paddingInlineEnd' | 'paddingInlineStart' | 'paddingLeft' | 'paddingRight' | 'paddingTop' | 'rowGap';
|
|
33
33
|
/**
|
|
@@ -43,7 +43,7 @@ type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' |
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> | ScopedSafeCSSObject<AllowedBoxStyles>[] : Primitive extends typeof Inline ? ScopedSafeCSSObject<Spacing> | ScopedSafeCSSObject<Spacing>[] : never): {
|
|
46
|
-
readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"
|
|
46
|
+
readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "xcss" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>> ? InlineStyles : never;
|
|
47
47
|
};
|
|
48
48
|
declare const boxTag: unique symbol;
|
|
49
49
|
export type BoxStyles = SerializedStyles & {
|
|
@@ -51,7 +51,7 @@ export type BoxStyles = SerializedStyles & {
|
|
|
51
51
|
};
|
|
52
52
|
export type BoxXCSS = {
|
|
53
53
|
readonly [uniqueSymbol]: BoxStyles;
|
|
54
|
-
};
|
|
54
|
+
} | false;
|
|
55
55
|
declare const inlineTag: unique symbol;
|
|
56
56
|
export type InlineStyles = SerializedStyles & {
|
|
57
57
|
[inlineTag]: true;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { ElementType, FC, ReactElement } from 'react';
|
|
3
3
|
import { BaseBoxProps } from './internal/base-box';
|
|
4
|
-
|
|
5
|
-
export type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className'> & PublicBoxPropsBase;
|
|
4
|
+
export type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className'>;
|
|
6
5
|
type BoxComponent<T extends ElementType = 'div'> = (<T extends ElementType = 'div'>(props: BoxProps<T>) => ReactElement | null) & FC<BoxProps<T>>;
|
|
7
6
|
/**
|
|
8
7
|
* __Box__
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ElementType, ReactNode } from 'react';
|
|
3
|
+
import { type Space } from '../xcss/style-maps.partial';
|
|
4
|
+
import type { BasePrimitiveProps } from './types';
|
|
5
|
+
export type FlexProps<T extends ElementType = 'div'> = {
|
|
6
|
+
/**
|
|
7
|
+
* The DOM element to render as the Flex. Defaults to `div`.
|
|
8
|
+
*/
|
|
9
|
+
as?: 'div' | 'span' | 'ul' | 'ol';
|
|
10
|
+
/**
|
|
11
|
+
* Used to align children along the main axis.
|
|
12
|
+
*/
|
|
13
|
+
justifyContent?: JustifyContent;
|
|
14
|
+
/**
|
|
15
|
+
* Used to align children along the cross axis.
|
|
16
|
+
*/
|
|
17
|
+
alignItems?: AlignItems;
|
|
18
|
+
/**
|
|
19
|
+
* Represents the space between each child.
|
|
20
|
+
*/
|
|
21
|
+
gap?: Space;
|
|
22
|
+
/**
|
|
23
|
+
* Represents the space between each child.
|
|
24
|
+
*/
|
|
25
|
+
rowGap?: Space;
|
|
26
|
+
/**
|
|
27
|
+
* Represents the flex direction property of CSS flexbox.
|
|
28
|
+
*/
|
|
29
|
+
direction?: Direction;
|
|
30
|
+
/**
|
|
31
|
+
* Represents the flex wrap property of CSS flexbox.
|
|
32
|
+
*/
|
|
33
|
+
wrap?: Wrap;
|
|
34
|
+
/**
|
|
35
|
+
* Elements to be rendered inside the Stack.
|
|
36
|
+
*/
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Forwarded ref element
|
|
40
|
+
*/
|
|
41
|
+
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
42
|
+
} & BasePrimitiveProps;
|
|
43
|
+
export type AlignItems = keyof typeof alignItemsMap;
|
|
44
|
+
export type JustifyContent = keyof typeof justifyContentMap;
|
|
45
|
+
export type Direction = keyof typeof flexDirectionMap;
|
|
46
|
+
export type Wrap = keyof typeof flexWrapMap;
|
|
47
|
+
declare const justifyContentMap: {
|
|
48
|
+
readonly start: import("@emotion/react").SerializedStyles;
|
|
49
|
+
readonly center: import("@emotion/react").SerializedStyles;
|
|
50
|
+
readonly end: import("@emotion/react").SerializedStyles;
|
|
51
|
+
readonly 'space-between': import("@emotion/react").SerializedStyles;
|
|
52
|
+
readonly 'space-around': import("@emotion/react").SerializedStyles;
|
|
53
|
+
readonly 'space-evenly': import("@emotion/react").SerializedStyles;
|
|
54
|
+
readonly stretch: import("@emotion/react").SerializedStyles;
|
|
55
|
+
};
|
|
56
|
+
declare const flexDirectionMap: {
|
|
57
|
+
readonly column: import("@emotion/react").SerializedStyles;
|
|
58
|
+
readonly row: import("@emotion/react").SerializedStyles;
|
|
59
|
+
};
|
|
60
|
+
declare const flexWrapMap: {
|
|
61
|
+
readonly wrap: import("@emotion/react").SerializedStyles;
|
|
62
|
+
readonly nowrap: import("@emotion/react").SerializedStyles;
|
|
63
|
+
};
|
|
64
|
+
declare const alignItemsMap: {
|
|
65
|
+
readonly start: import("@emotion/react").SerializedStyles;
|
|
66
|
+
readonly center: import("@emotion/react").SerializedStyles;
|
|
67
|
+
readonly baseline: import("@emotion/react").SerializedStyles;
|
|
68
|
+
readonly end: import("@emotion/react").SerializedStyles;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* __Flex__
|
|
72
|
+
*
|
|
73
|
+
* `Flex` is a primitive component that implements the CSS Flexbox API.
|
|
74
|
+
*
|
|
75
|
+
* - [Examples](https://atlassian.design/components/primitives/flex/examples)
|
|
76
|
+
* - [Code](https://atlassian.design/components/primitives/flex/code)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* import { Flex, Box } from '@atlaskit/primitives'
|
|
81
|
+
*
|
|
82
|
+
* const Component = () => (
|
|
83
|
+
* <Flex direction="column">
|
|
84
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
85
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
86
|
+
* </Flex>
|
|
87
|
+
* )
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare const Flex: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<{
|
|
91
|
+
/**
|
|
92
|
+
* The DOM element to render as the Flex. Defaults to `div`.
|
|
93
|
+
*/
|
|
94
|
+
as?: "div" | "ol" | "span" | "ul" | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Used to align children along the main axis.
|
|
97
|
+
*/
|
|
98
|
+
justifyContent?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Used to align children along the cross axis.
|
|
101
|
+
*/
|
|
102
|
+
alignItems?: "start" | "center" | "end" | "baseline" | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Represents the space between each child.
|
|
105
|
+
*/
|
|
106
|
+
gap?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Represents the space between each child.
|
|
109
|
+
*/
|
|
110
|
+
rowGap?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Represents the flex direction property of CSS flexbox.
|
|
113
|
+
*/
|
|
114
|
+
direction?: "column" | "row" | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Represents the flex wrap property of CSS flexbox.
|
|
117
|
+
*/
|
|
118
|
+
wrap?: "wrap" | "nowrap" | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Elements to be rendered inside the Stack.
|
|
121
|
+
*/
|
|
122
|
+
children: ReactNode;
|
|
123
|
+
/**
|
|
124
|
+
* Forwarded ref element
|
|
125
|
+
*/
|
|
126
|
+
ref?: any;
|
|
127
|
+
} & BasePrimitiveProps, "gap" | "rowGap" | "alignItems" | "direction" | "justifyContent" | "as" | "children" | keyof BasePrimitiveProps | "wrap"> & import("react").RefAttributes<any>>>;
|
|
128
|
+
export default Flex;
|
|
@@ -76,5 +76,5 @@ export type Grow = 'hug' | 'fill';
|
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
78
|
*/
|
|
79
|
-
declare const Inline: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<InlineProps<ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"
|
|
79
|
+
declare const Inline: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<InlineProps<ElementType<any>>, "as" | "children" | "testId" | "xcss" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>>;
|
|
80
80
|
export default Inline;
|
|
@@ -9,12 +9,8 @@ export type BasePrimitiveProps = {
|
|
|
9
9
|
* Inline styles to be applied to the primitive.
|
|
10
10
|
*/
|
|
11
11
|
style?: CSSProperties;
|
|
12
|
-
};
|
|
13
|
-
type BoxXCSSArray = Array<BoxXCSSArray | BoxXCSS | false | undefined>;
|
|
14
|
-
export type PublicBoxPropsBase = {
|
|
15
12
|
/**
|
|
16
|
-
*
|
|
13
|
+
* Apply a subset of permitted styles, powered by Atlassian Design System tokens.
|
|
17
14
|
*/
|
|
18
|
-
xcss?: BoxXCSS |
|
|
15
|
+
xcss?: BoxXCSS | BoxXCSS[];
|
|
19
16
|
};
|
|
20
|
-
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export type { Dimension, BackgroundColor, Space, BorderColor, BorderRadius, BorderWidth, Layer, Shadow, } from './xcss/style-maps.partial';
|
|
1
2
|
export { default as Box, type BoxProps } from './components/box';
|
|
2
3
|
export { default as Pressable, type PressableProps, } from './components/pressable';
|
|
3
4
|
export { default as Inline, type InlineProps } from './components/inline';
|
|
4
5
|
export { xcss } from './xcss/xcss';
|
|
5
6
|
export { default as Stack, type StackProps } from './components/stack';
|
|
7
|
+
export { default as Flex, type FlexProps } from './components/flex';
|
|
6
8
|
export { UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG, type Breakpoint, } from './responsive';
|
|
@@ -13,10 +13,25 @@ export declare const UNSAFE_media: {
|
|
|
13
13
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
14
14
|
*/
|
|
15
15
|
readonly xxs: "@media all";
|
|
16
|
+
/**
|
|
17
|
+
* Used for mobile viewports.
|
|
18
|
+
*/
|
|
16
19
|
readonly xs: "@media (min-width: 30rem)";
|
|
20
|
+
/**
|
|
21
|
+
* Used for tablet viewports.
|
|
22
|
+
*/
|
|
17
23
|
readonly sm: "@media (min-width: 48rem)";
|
|
24
|
+
/**
|
|
25
|
+
* Used for laptop viewports.
|
|
26
|
+
*/
|
|
18
27
|
readonly md: "@media (min-width: 64rem)";
|
|
28
|
+
/**
|
|
29
|
+
* Used for desktop viewports.
|
|
30
|
+
*/
|
|
19
31
|
readonly lg: "@media (min-width: 90rem)";
|
|
32
|
+
/**
|
|
33
|
+
* Used for wide screen desktop viewports.
|
|
34
|
+
*/
|
|
20
35
|
readonly xl: "@media (min-width: 110rem)";
|
|
21
36
|
};
|
|
22
37
|
/**
|
|
@@ -66,10 +81,25 @@ export declare const media: {
|
|
|
66
81
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
67
82
|
*/
|
|
68
83
|
readonly xxs: "@media all";
|
|
84
|
+
/**
|
|
85
|
+
* Used for mobile viewports.
|
|
86
|
+
*/
|
|
69
87
|
readonly xs: "@media (min-width: 30rem)";
|
|
88
|
+
/**
|
|
89
|
+
* Used for tablet viewports.
|
|
90
|
+
*/
|
|
70
91
|
readonly sm: "@media (min-width: 48rem)";
|
|
92
|
+
/**
|
|
93
|
+
* Used for laptop viewports.
|
|
94
|
+
*/
|
|
71
95
|
readonly md: "@media (min-width: 64rem)";
|
|
96
|
+
/**
|
|
97
|
+
* Used for desktop viewports.
|
|
98
|
+
*/
|
|
72
99
|
readonly lg: "@media (min-width: 90rem)";
|
|
100
|
+
/**
|
|
101
|
+
* Used for wide screen desktop viewports.
|
|
102
|
+
*/
|
|
73
103
|
readonly xl: "@media (min-width: 110rem)";
|
|
74
104
|
};
|
|
75
105
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { css as cssEmotion } from '@emotion/react';
|
|
3
|
-
import { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
|
|
3
|
+
import type { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
|
|
4
4
|
import type * as CSS from 'csstype';
|
|
5
5
|
import { Box, Inline } from '../index';
|
|
6
6
|
import type { MediaQuery } from '../responsive/types';
|
|
@@ -27,7 +27,7 @@ declare const inlineWrapper: (style: any) => {
|
|
|
27
27
|
readonly [uniqueSymbol]: InlineStyles;
|
|
28
28
|
};
|
|
29
29
|
type XCSS = ReturnType<typeof boxWrapper> | ReturnType<typeof inlineWrapper>;
|
|
30
|
-
type XCSSArray = Array<XCSS |
|
|
30
|
+
type XCSSArray = Array<XCSS | false | undefined>;
|
|
31
31
|
type AllowedBoxStyles = keyof SafeCSSObject;
|
|
32
32
|
type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' | 'insetBlockStart' | 'insetInline' | 'insetInlineEnd' | 'insetInlineStart' | 'margin' | 'marginBlock' | 'marginBlockEnd' | 'marginBlockStart' | 'marginInline' | 'marginInlineEnd' | 'marginInlineStart' | 'outlineOffset' | 'padding' | 'paddingBlock' | 'paddingBlockEnd' | 'paddingBlockStart' | 'paddingBottom' | 'paddingInline' | 'paddingInlineEnd' | 'paddingInlineStart' | 'paddingLeft' | 'paddingRight' | 'paddingTop' | 'rowGap';
|
|
33
33
|
/**
|
|
@@ -43,7 +43,7 @@ type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' |
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> | ScopedSafeCSSObject<AllowedBoxStyles>[] : Primitive extends typeof Inline ? ScopedSafeCSSObject<Spacing> | ScopedSafeCSSObject<Spacing>[] : never): {
|
|
46
|
-
readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"
|
|
46
|
+
readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "xcss" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>> ? InlineStyles : never;
|
|
47
47
|
};
|
|
48
48
|
declare const boxTag: unique symbol;
|
|
49
49
|
export type BoxStyles = SerializedStyles & {
|
|
@@ -51,7 +51,7 @@ export type BoxStyles = SerializedStyles & {
|
|
|
51
51
|
};
|
|
52
52
|
export type BoxXCSS = {
|
|
53
53
|
readonly [uniqueSymbol]: BoxStyles;
|
|
54
|
-
};
|
|
54
|
+
} | false;
|
|
55
55
|
declare const inlineTag: unique symbol;
|
|
56
56
|
export type InlineStyles = SerializedStyles & {
|
|
57
57
|
[inlineTag]: true;
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
import { As } from '../src/components/internal/base-box';
|
|
5
|
-
import {
|
|
6
|
-
BasePrimitiveProps,
|
|
7
|
-
PublicBoxPropsBase,
|
|
8
|
-
} from '../src/components/types';
|
|
5
|
+
import { BasePrimitiveProps } from '../src/components/types';
|
|
9
6
|
|
|
10
7
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
11
8
|
namespace Token {
|
|
@@ -82,11 +79,6 @@ export default function Box(
|
|
|
82
79
|
*/
|
|
83
80
|
children?: ReactNode;
|
|
84
81
|
|
|
85
|
-
/**
|
|
86
|
-
* Apply a subset of permitted styles, powered by Atlassian Design System tokens.
|
|
87
|
-
*/
|
|
88
|
-
xcss?: PublicBoxPropsBase['xcss'];
|
|
89
|
-
|
|
90
82
|
/**
|
|
91
83
|
* Forwarded ref element.
|
|
92
84
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"category": "Primitives",
|
|
18
18
|
"name": "Primitives",
|
|
19
19
|
"status": {
|
|
20
|
-
"type": "
|
|
20
|
+
"type": "closed-beta"
|
|
21
21
|
},
|
|
22
22
|
"pages": [
|
|
23
23
|
{
|
|
@@ -38,6 +38,15 @@
|
|
|
38
38
|
"type": "closed-beta"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
+
{
|
|
42
|
+
"title": "Flex",
|
|
43
|
+
"folder": "flex",
|
|
44
|
+
"slug": "primitives/flex",
|
|
45
|
+
"id": "@atlaskit/primitives/flex",
|
|
46
|
+
"status": {
|
|
47
|
+
"type": "closed-beta"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
41
50
|
{
|
|
42
51
|
"title": "Inline",
|
|
43
52
|
"folder": "inline",
|
|
@@ -156,4 +165,4 @@
|
|
|
156
165
|
}
|
|
157
166
|
},
|
|
158
167
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
159
|
-
}
|
|
168
|
+
}
|