@atlaskit/primitives 0.9.2 → 0.9.4
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 +15 -0
- package/dist/cjs/helpers/responsive/constants.js +24 -17
- package/dist/cjs/helpers/responsive/media-helper.js +21 -27
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/xcss/style-maps.partial.js +50 -26
- package/dist/cjs/xcss/xcss.js +1 -0
- package/dist/es2019/helpers/responsive/constants.js +24 -15
- package/dist/es2019/helpers/responsive/media-helper.js +21 -27
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +48 -25
- package/dist/es2019/xcss/xcss.js +2 -1
- package/dist/esm/helpers/responsive/constants.js +24 -17
- package/dist/esm/helpers/responsive/media-helper.js +21 -27
- package/dist/esm/version.json +1 -1
- package/dist/esm/xcss/style-maps.partial.js +48 -25
- package/dist/esm/xcss/xcss.js +2 -1
- package/dist/types/helpers/responsive/constants.d.ts +2 -0
- package/dist/types/helpers/responsive/media-helper.d.ts +14 -14
- package/dist/types/helpers/responsive/types.d.ts +7 -2
- package/dist/types/xcss/style-maps.partial.d.ts +42 -17
- package/dist/types-ts4.5/components/box.d.ts +18 -0
- package/dist/types-ts4.5/components/inline.d.ts +75 -0
- package/dist/types-ts4.5/components/internal/base-box.d.ts +84 -0
- package/dist/types-ts4.5/components/stack.d.ts +61 -0
- package/dist/types-ts4.5/components/types.d.ts +18 -0
- package/dist/types-ts4.5/constants.d.ts +12 -0
- package/dist/types-ts4.5/helpers/responsive/build-media-query-css.d.ts +57 -0
- package/dist/types-ts4.5/helpers/responsive/constants.d.ts +33 -0
- package/dist/types-ts4.5/helpers/responsive/index.d.ts +4 -0
- package/dist/types-ts4.5/helpers/responsive/media-helper.d.ts +45 -0
- package/dist/types-ts4.5/helpers/responsive/types.d.ts +52 -0
- package/dist/types-ts4.5/index.d.ts +4 -0
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +474 -0
- package/dist/types-ts4.5/xcss/xcss.d.ts +57 -0
- package/package.json +5 -5
- package/report.api.md +36 -7
- package/scripts/codegen-file-templates/dimensions.tsx +7 -7
- package/scripts/color-codegen-template.tsx +7 -0
- package/scripts/spacing-codegen-template.tsx +1 -1
- package/tmp/api-report-tmp.d.ts +36 -7
- package/tsconfig.node.json +7 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
2
|
/**
|
|
3
3
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
4
|
-
* @codegen <<SignedSource::
|
|
4
|
+
* @codegen <<SignedSource::2c35cc3f884146ac8ccdf053bf413481>>
|
|
5
5
|
* @codegenId dimensions
|
|
6
6
|
* @codegenCommand yarn codegen-styles
|
|
7
7
|
* @codegenParams ["dimensions"]
|
|
8
|
-
* @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::
|
|
8
|
+
* @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::01143ff41135244db1d8ec2efe4339d6>>
|
|
9
9
|
*/
|
|
10
10
|
export declare const dimensionMap: {
|
|
11
11
|
readonly '100%': "100%";
|
|
12
|
-
readonly 'size.100': "
|
|
13
|
-
readonly 'size.200': "
|
|
14
|
-
readonly 'size.300': "
|
|
15
|
-
readonly 'size.400': "
|
|
16
|
-
readonly 'size.500': "
|
|
17
|
-
readonly 'size.600': "
|
|
18
|
-
readonly 'size.1000': "
|
|
12
|
+
readonly 'size.100': "1rem";
|
|
13
|
+
readonly 'size.200': "1.5rem";
|
|
14
|
+
readonly 'size.300': "2rem";
|
|
15
|
+
readonly 'size.400': "2.5rem";
|
|
16
|
+
readonly 'size.500': "3rem";
|
|
17
|
+
readonly 'size.600': "6rem";
|
|
18
|
+
readonly 'size.1000': "12rem";
|
|
19
19
|
};
|
|
20
20
|
type Dimension = keyof typeof dimensionMap;
|
|
21
21
|
export type Width = Dimension;
|
|
@@ -39,10 +39,10 @@ export type MinInlineSize = Dimension;
|
|
|
39
39
|
*/
|
|
40
40
|
/**
|
|
41
41
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
42
|
-
* @codegen <<SignedSource::
|
|
42
|
+
* @codegen <<SignedSource::c32ec2103b151d3533775390e92f0f03>>
|
|
43
43
|
* @codegenId spacing
|
|
44
44
|
* @codegenCommand yarn codegen-styles
|
|
45
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::
|
|
45
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::86e173b0e020fe5d091fdf4bff023711>>
|
|
46
46
|
*/
|
|
47
47
|
export declare const spaceMap: {
|
|
48
48
|
'space.0': "var(--ds-space-0)";
|
|
@@ -66,10 +66,10 @@ export type Space = keyof typeof spaceMap;
|
|
|
66
66
|
*/
|
|
67
67
|
/**
|
|
68
68
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
69
|
-
* @codegen <<SignedSource::
|
|
69
|
+
* @codegen <<SignedSource::aa1cfa3cd24f141a85ac1e0b70dbd8a8>>
|
|
70
70
|
* @codegenId colors
|
|
71
71
|
* @codegenCommand yarn codegen-styles
|
|
72
|
-
* @codegenParams ["border", "background", "shadow", "text"]
|
|
72
|
+
* @codegenParams ["border", "background", "shadow", "text", "fill"]
|
|
73
73
|
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::10aa7e87eca39e4d6594a764e78e0698>>
|
|
74
74
|
*/
|
|
75
75
|
export declare const borderColorMap: {
|
|
@@ -246,18 +246,42 @@ export declare const textColorMap: {
|
|
|
246
246
|
readonly subtle: "var(--ds-text-subtle)";
|
|
247
247
|
};
|
|
248
248
|
export type TextColor = keyof typeof textColorMap;
|
|
249
|
+
export declare const fillMap: {
|
|
250
|
+
readonly 'color.icon': "var(--ds-icon)";
|
|
251
|
+
readonly 'accent.red': "var(--ds-icon-accent-red)";
|
|
252
|
+
readonly 'accent.orange': "var(--ds-icon-accent-orange)";
|
|
253
|
+
readonly 'accent.yellow': "var(--ds-icon-accent-yellow)";
|
|
254
|
+
readonly 'accent.green': "var(--ds-icon-accent-green)";
|
|
255
|
+
readonly 'accent.teal': "var(--ds-icon-accent-teal)";
|
|
256
|
+
readonly 'accent.blue': "var(--ds-icon-accent-blue)";
|
|
257
|
+
readonly 'accent.purple': "var(--ds-icon-accent-purple)";
|
|
258
|
+
readonly 'accent.magenta': "var(--ds-icon-accent-magenta)";
|
|
259
|
+
readonly 'accent.gray': "var(--ds-icon-accent-gray)";
|
|
260
|
+
readonly disabled: "var(--ds-icon-disabled)";
|
|
261
|
+
readonly inverse: "var(--ds-icon-inverse)";
|
|
262
|
+
readonly selected: "var(--ds-icon-selected)";
|
|
263
|
+
readonly brand: "var(--ds-icon-brand)";
|
|
264
|
+
readonly danger: "var(--ds-icon-danger)";
|
|
265
|
+
readonly warning: "var(--ds-icon-warning)";
|
|
266
|
+
readonly 'warning.inverse': "var(--ds-icon-warning-inverse)";
|
|
267
|
+
readonly success: "var(--ds-icon-success)";
|
|
268
|
+
readonly discovery: "var(--ds-icon-discovery)";
|
|
269
|
+
readonly information: "var(--ds-icon-information)";
|
|
270
|
+
readonly subtle: "var(--ds-icon-subtle)";
|
|
271
|
+
};
|
|
272
|
+
export type Fill = keyof typeof fillMap;
|
|
249
273
|
/**
|
|
250
274
|
* @codegenEnd
|
|
251
275
|
*/
|
|
252
276
|
/**
|
|
253
277
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
254
|
-
* @codegen <<SignedSource::
|
|
278
|
+
* @codegen <<SignedSource::e63fc5ff12523b2d49dc72925e1648e6>>
|
|
255
279
|
* @codegenId misc
|
|
256
280
|
* @codegenCommand yarn codegen-styles
|
|
257
281
|
* @codegenParams ["align-self", "border-style", "display", "flex-direction", "flex-grow", "flex-shrink", "flex", "layer", "overflow", "position"]
|
|
258
282
|
* @codegenDependency ../../scripts/codegen-file-templates/align-self.tsx <<SignedSource::074079802534462de54bf882bb2073e5>>
|
|
259
283
|
* @codegenDependency ../../scripts/codegen-file-templates/border-style.tsx <<SignedSource::87e7e289ffeaac901997c4af98084a5f>>
|
|
260
|
-
* @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::
|
|
284
|
+
* @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::01143ff41135244db1d8ec2efe4339d6>>
|
|
261
285
|
* @codegenDependency ../../scripts/codegen-file-templates/display.tsx <<SignedSource::04ea30fcb3c02f2545af7fdc0206e645>>
|
|
262
286
|
* @codegenDependency ../../scripts/codegen-file-templates/flex-direction.tsx <<SignedSource::19809ba11675679c188b0d98fb651dc1>>
|
|
263
287
|
* @codegenDependency ../../scripts/codegen-file-templates/flex-grow.tsx <<SignedSource::b8a06b122cb609170f1f42778a6c270e>>
|
|
@@ -346,11 +370,11 @@ export type Position = keyof typeof positionMap;
|
|
|
346
370
|
*/
|
|
347
371
|
/**
|
|
348
372
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
349
|
-
* @codegen <<SignedSource::
|
|
373
|
+
* @codegen <<SignedSource::80ae367205568f9ca76d35f0cbc9d127>>
|
|
350
374
|
* @codegenId border
|
|
351
375
|
* @codegenCommand yarn codegen-styles
|
|
352
376
|
* @codegenParams ["width", "radius"]
|
|
353
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-shape.tsx <<SignedSource::
|
|
377
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-shape.tsx <<SignedSource::81055547b21306c07a3e8a3c734a2f1c>>
|
|
354
378
|
*/
|
|
355
379
|
export declare const borderWidthMap: {
|
|
356
380
|
readonly 'width.0': "var(--ds-width-0)";
|
|
@@ -383,6 +407,7 @@ export type TokenisedProps = {
|
|
|
383
407
|
color?: TextColor;
|
|
384
408
|
columnGap?: Space;
|
|
385
409
|
display?: Display;
|
|
410
|
+
fill?: Fill;
|
|
386
411
|
flex?: Flex;
|
|
387
412
|
flexDirection?: FlexDirection;
|
|
388
413
|
flexGrow?: FlexGrow;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ElementType, FC, ReactElement } from 'react';
|
|
3
|
+
import { BaseBoxProps } from './internal/base-box';
|
|
4
|
+
import type { PublicBoxPropsBase } from './types';
|
|
5
|
+
export type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className'> & PublicBoxPropsBase;
|
|
6
|
+
type BoxComponent<T extends ElementType = 'div'> = (<T extends ElementType = 'div'>(props: BoxProps<T>) => ReactElement | null) & FC<BoxProps<T>>;
|
|
7
|
+
/**
|
|
8
|
+
* __Box__
|
|
9
|
+
*
|
|
10
|
+
* A Box is a primitive component that has the design decisions of the Atlassian Design System baked in.
|
|
11
|
+
* Renders a `div` by default.
|
|
12
|
+
*
|
|
13
|
+
* - [Examples](https://atlassian.design/components/primitives/box/examples)
|
|
14
|
+
* - [Code](https://atlassian.design/components/primitives/box/code)
|
|
15
|
+
* - [Usage](https://atlassian.design/components/primitives/box/usage)
|
|
16
|
+
*/
|
|
17
|
+
declare const Box: BoxComponent;
|
|
18
|
+
export default Box;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ElementType, ReactNode } from 'react';
|
|
3
|
+
import { type Space } from '../xcss/style-maps.partial';
|
|
4
|
+
export interface InlineProps<T extends ElementType = 'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* The DOM element to render as the Inline. Defaults to `div`.
|
|
7
|
+
*/
|
|
8
|
+
as?: 'div' | 'span' | 'ul' | 'ol';
|
|
9
|
+
/**
|
|
10
|
+
* Used to align children along the main axis.
|
|
11
|
+
*/
|
|
12
|
+
alignBlock?: AlignBlock;
|
|
13
|
+
/**
|
|
14
|
+
* Used to align children along the cross axis.
|
|
15
|
+
*/
|
|
16
|
+
alignInline?: AlignInline;
|
|
17
|
+
/**
|
|
18
|
+
* Used to set whether children are forced onto one line or will wrap onto multiple lines.
|
|
19
|
+
*/
|
|
20
|
+
shouldWrap?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Used to distribute the children along the main axis.
|
|
23
|
+
*/
|
|
24
|
+
spread?: Spread;
|
|
25
|
+
/**
|
|
26
|
+
* Used to set whether the container should grow to fill the available space.
|
|
27
|
+
*/
|
|
28
|
+
grow?: Grow;
|
|
29
|
+
/**
|
|
30
|
+
* Represents the space between each child.
|
|
31
|
+
*/
|
|
32
|
+
space?: Space;
|
|
33
|
+
/**
|
|
34
|
+
* Represents the space between rows when content wraps.
|
|
35
|
+
* Used to override the `space` value in between rows.
|
|
36
|
+
*/
|
|
37
|
+
rowSpace?: Space;
|
|
38
|
+
/**
|
|
39
|
+
* Renders a separator string between each child.
|
|
40
|
+
*/
|
|
41
|
+
separator?: string;
|
|
42
|
+
/**
|
|
43
|
+
* A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests.
|
|
44
|
+
*/
|
|
45
|
+
testId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Elements to be rendered inside the Inline.
|
|
48
|
+
*/
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Forwarded ref element
|
|
52
|
+
*/
|
|
53
|
+
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
54
|
+
}
|
|
55
|
+
export type AlignInline = 'start' | 'center' | 'end';
|
|
56
|
+
export type AlignBlock = 'start' | 'center' | 'end' | 'baseline';
|
|
57
|
+
export type Spread = 'space-between';
|
|
58
|
+
export type Grow = 'hug' | 'fill';
|
|
59
|
+
/**
|
|
60
|
+
* __Inline__
|
|
61
|
+
*
|
|
62
|
+
* Inline is a primitive component based on flexbox that manages the horizontal layout of direct children.
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Inline>
|
|
68
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
69
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
70
|
+
* </Inline>
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
declare const Inline: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<InlineProps<ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>>;
|
|
75
|
+
export default Inline;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ComponentPropsWithoutRef, ElementType, FC, ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { BackgroundColor, type Space } from '../../xcss/style-maps.partial';
|
|
4
|
+
import type { BasePrimitiveProps } from '../types';
|
|
5
|
+
export type BaseBoxProps<T extends ElementType = 'div'> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & BaseBoxPropsFoundation<T>;
|
|
6
|
+
export type As = 'article' | 'aside' | 'dialog' | 'div' | 'footer' | 'header' | 'li' | 'main' | 'nav' | 'ol' | 'section' | 'span' | 'ul';
|
|
7
|
+
type BaseBoxPropsFoundation<T extends ElementType = 'div'> = {
|
|
8
|
+
/**
|
|
9
|
+
* The DOM element to render as the Box. Defaults to `div`.
|
|
10
|
+
*/
|
|
11
|
+
as?: As;
|
|
12
|
+
/**
|
|
13
|
+
* The HTML className attribute.
|
|
14
|
+
*
|
|
15
|
+
* Before using this prop please ensure:
|
|
16
|
+
* - The styles cannot otherwise be achieved through `Box` directly.
|
|
17
|
+
* - The use case needs custom styles that cannot be designed or implemented differently
|
|
18
|
+
*
|
|
19
|
+
* Ensure you're using the `@atlaskit/eslint-plugin-design-system` with this prop to prevent unbounded usage.
|
|
20
|
+
*
|
|
21
|
+
* @see `@atlaskit/eslint-plugin-design-system`
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Elements to be rendered inside the Box.
|
|
26
|
+
*/
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Token representing background color with a built-in fallback value.
|
|
30
|
+
*/
|
|
31
|
+
backgroundColor?: BackgroundColor;
|
|
32
|
+
/**
|
|
33
|
+
* Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
|
|
34
|
+
*
|
|
35
|
+
* @see paddingBlock
|
|
36
|
+
* @see paddingInline
|
|
37
|
+
*/
|
|
38
|
+
padding?: Space;
|
|
39
|
+
/**
|
|
40
|
+
* Tokens representing CSS shorthand `paddingBlock`.
|
|
41
|
+
*
|
|
42
|
+
* @see paddingBlockStart
|
|
43
|
+
* @see paddingBlockEnd
|
|
44
|
+
*/
|
|
45
|
+
paddingBlock?: Space;
|
|
46
|
+
/**
|
|
47
|
+
* Tokens representing CSS `paddingBlockStart`.
|
|
48
|
+
*/
|
|
49
|
+
paddingBlockStart?: Space;
|
|
50
|
+
/**
|
|
51
|
+
* Tokens representing CSS `paddingBlockEnd`.
|
|
52
|
+
*/
|
|
53
|
+
paddingBlockEnd?: Space;
|
|
54
|
+
/**
|
|
55
|
+
* Tokens representing CSS shorthand `paddingInline`.
|
|
56
|
+
*
|
|
57
|
+
* @see paddingInlineStart
|
|
58
|
+
* @see paddingInlineEnd
|
|
59
|
+
*/
|
|
60
|
+
paddingInline?: Space;
|
|
61
|
+
/**
|
|
62
|
+
* Tokens representing CSS `paddingInlineStart`.
|
|
63
|
+
*/
|
|
64
|
+
paddingInlineStart?: Space;
|
|
65
|
+
/**
|
|
66
|
+
* Tokens representing CSS `paddingInlineEnd`.
|
|
67
|
+
*/
|
|
68
|
+
paddingInlineEnd?: Space;
|
|
69
|
+
/**
|
|
70
|
+
* Forwarded ref element
|
|
71
|
+
*/
|
|
72
|
+
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
73
|
+
};
|
|
74
|
+
export type BaseBoxComponent<T extends ElementType = 'div'> = (<T extends ElementType = 'div'>(props: BaseBoxProps<T>) => ReactElement | null) & FC<BaseBoxProps<T>>;
|
|
75
|
+
/**
|
|
76
|
+
* __Box__
|
|
77
|
+
*
|
|
78
|
+
* Box is a primitive component that has the design decisions of the Atlassian Design System baked in.
|
|
79
|
+
* Renders a `div` by default.
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export declare const BaseBox: BaseBoxComponent;
|
|
84
|
+
export default BaseBox;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ElementType, ReactNode } from 'react';
|
|
3
|
+
import { type Space } from '../xcss/style-maps.partial';
|
|
4
|
+
export interface StackProps<T extends ElementType = 'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* The DOM element to render as the Stack. Defaults to `div`.
|
|
7
|
+
*/
|
|
8
|
+
as?: 'div' | 'span' | 'ul' | 'ol';
|
|
9
|
+
/**
|
|
10
|
+
* Used to align children along the main axis.
|
|
11
|
+
*/
|
|
12
|
+
alignBlock?: AlignBlock;
|
|
13
|
+
/**
|
|
14
|
+
* Used to align children along the cross axis.
|
|
15
|
+
*/
|
|
16
|
+
alignInline?: AlignInline;
|
|
17
|
+
/**
|
|
18
|
+
* Used to distribute the children along the main axis.
|
|
19
|
+
*/
|
|
20
|
+
spread?: Spread;
|
|
21
|
+
/**
|
|
22
|
+
* Used to set whether the container should grow to fill the available space.
|
|
23
|
+
*/
|
|
24
|
+
grow?: Grow;
|
|
25
|
+
/**
|
|
26
|
+
* Represents the space between each child.
|
|
27
|
+
*/
|
|
28
|
+
space?: Space;
|
|
29
|
+
/**
|
|
30
|
+
* A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests.
|
|
31
|
+
*/
|
|
32
|
+
testId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Elements to be rendered inside the Stack.
|
|
35
|
+
*/
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Forwarded ref element
|
|
39
|
+
*/
|
|
40
|
+
ref?: React.ComponentPropsWithRef<T>['ref'];
|
|
41
|
+
}
|
|
42
|
+
export type AlignInline = 'start' | 'center' | 'end';
|
|
43
|
+
export type AlignBlock = 'start' | 'center' | 'end';
|
|
44
|
+
export type Spread = 'space-between';
|
|
45
|
+
export type Grow = 'hug' | 'fill';
|
|
46
|
+
/**
|
|
47
|
+
* __Stack__
|
|
48
|
+
*
|
|
49
|
+
* Stack is a primitive component based on flexbox that manages the vertical layout of direct children.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <Stack>
|
|
54
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
55
|
+
* <Box padding="space.100" backgroundColor="neutral"></Box>
|
|
56
|
+
* </Stack>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
declare const Stack: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<StackProps<ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "spread" | "grow" | "space"> & import("react").RefAttributes<any>>>;
|
|
61
|
+
export default Stack;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type BoxXCSS } from '../xcss/xcss';
|
|
3
|
+
export type BasePrimitiveProps = {
|
|
4
|
+
/**
|
|
5
|
+
* A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
|
|
6
|
+
*/
|
|
7
|
+
testId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Inline styles to be applied to the primitive.
|
|
10
|
+
*/
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
};
|
|
13
|
+
export type PublicBoxPropsBase = {
|
|
14
|
+
/**
|
|
15
|
+
* Safe subset of styles that can be applied as a classname.
|
|
16
|
+
*/
|
|
17
|
+
xcss?: BoxXCSS | Array<BoxXCSS | false | undefined>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const LAYERS: {
|
|
2
|
+
readonly card: 100;
|
|
3
|
+
readonly navigation: 200;
|
|
4
|
+
readonly dialog: 300;
|
|
5
|
+
readonly layer: 400;
|
|
6
|
+
readonly blanket: 500;
|
|
7
|
+
readonly modal: 510;
|
|
8
|
+
readonly flag: 600;
|
|
9
|
+
readonly spotlight: 700;
|
|
10
|
+
readonly tooltip: 800;
|
|
11
|
+
};
|
|
12
|
+
export type Layer = keyof typeof LAYERS;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CSSObject } from '@emotion/react';
|
|
2
|
+
import { SMALLEST_BREAKPOINT } from './constants';
|
|
3
|
+
import type { Breakpoint } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Build a map of breakpoints to css with media queries and nested styles.
|
|
6
|
+
*
|
|
7
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
11
|
+
* ```ts
|
|
12
|
+
* const hideMediaQueries = buildAboveMediaQueryCSS({ display: 'none' });
|
|
13
|
+
*
|
|
14
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
15
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
20
|
+
* ```ts
|
|
21
|
+
* {
|
|
22
|
+
* xxs: css({ '@media (min-width: 0px)': { display: 'none' } }),
|
|
23
|
+
* xs: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
24
|
+
* sm: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const UNSAFE_buildAboveMediaQueryCSS: (input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
29
|
+
/**
|
|
30
|
+
* Build a map of breakpoints to css with media queries and nested styles.
|
|
31
|
+
*
|
|
32
|
+
* WARNING: The smallest breakpoint is not a valid key as a media query below 0px is misleading.
|
|
33
|
+
* This is separated from `buildAboveMediaQueryCSS` for that specific reason, you cannot have type safety with this variance.
|
|
34
|
+
*
|
|
35
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
39
|
+
* ```ts
|
|
40
|
+
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
41
|
+
*
|
|
42
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
43
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
48
|
+
* ```ts
|
|
49
|
+
* {
|
|
50
|
+
* xs: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
51
|
+
* sm: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
56
|
+
*/
|
|
57
|
+
export declare const UNSAFE_buildBelowMediaQueryCSS: (input: CSSObject | ((breakpoint: Exclude<Breakpoint, typeof SMALLEST_BREAKPOINT>) => CSSObject)) => Required<Omit<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>, "xxs">>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Breakpoint, BreakpointConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Our internal configuration for breakpoints configuration.
|
|
4
|
+
*
|
|
5
|
+
* These are `rem` based multiples.
|
|
6
|
+
*
|
|
7
|
+
* @experimental Unsafe for consumption outside of the design system itself.
|
|
8
|
+
*/
|
|
9
|
+
export declare const UNSAFE_BREAKPOINTS_CONFIG: Record<Breakpoint, BreakpointConfig>;
|
|
10
|
+
/**
|
|
11
|
+
* The list of breakpoints in order from smallest to largest. You may need to clone and reverse this list if you want the opposite.
|
|
12
|
+
*
|
|
13
|
+
* This is intentional for cascading with `min-width` or `media.above`. Media queries go from lowest width to highest.
|
|
14
|
+
*
|
|
15
|
+
* @experimental Unsafe for consumption outside of the design system itself.
|
|
16
|
+
*/
|
|
17
|
+
export declare const UNSAFE_BREAKPOINTS_ORDERED_LIST: [
|
|
18
|
+
"xxs",
|
|
19
|
+
"xs",
|
|
20
|
+
"sm",
|
|
21
|
+
"md",
|
|
22
|
+
"lg",
|
|
23
|
+
"xl",
|
|
24
|
+
"xxl"
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* This is our smallest breakpoint with a few nuances to it:
|
|
28
|
+
* 1. It is the default value for shorthands, eg. `<GridItem span={6} />` maps to `{ [SMALLEST_BREAKPOINT]: props.span }`
|
|
29
|
+
* 2. It's omitted in `media.below` as there's nothing below `0px`.
|
|
30
|
+
*
|
|
31
|
+
* @experimental There's a chance this will change in _value_, but should only be used in a way that it will not matter if this value changes.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SMALLEST_BREAKPOINT: "xxs";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { UNSAFE_media } from './media-helper';
|
|
2
|
+
export { UNSAFE_buildAboveMediaQueryCSS, UNSAFE_buildBelowMediaQueryCSS, } from './build-media-query-css';
|
|
3
|
+
export { UNSAFE_BREAKPOINTS_ORDERED_LIST, UNSAFE_BREAKPOINTS_CONFIG, } from './constants';
|
|
4
|
+
export type { Breakpoint, ResponsiveObject, ResponsiveCSSObject, } from './types';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
3
|
+
*
|
|
4
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
5
|
+
*/
|
|
6
|
+
export declare const UNSAFE_media: {
|
|
7
|
+
readonly above: {
|
|
8
|
+
/**
|
|
9
|
+
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
10
|
+
*
|
|
11
|
+
* Eg. this is `@media (min-width: 0px)`
|
|
12
|
+
*/
|
|
13
|
+
readonly xxs: `@media (min-width: ${number}rem)`;
|
|
14
|
+
readonly xs: `@media (min-width: ${number}rem)`;
|
|
15
|
+
readonly sm: `@media (min-width: ${number}rem)`;
|
|
16
|
+
readonly md: `@media (min-width: ${number}rem)`;
|
|
17
|
+
readonly lg: `@media (min-width: ${number}rem)`;
|
|
18
|
+
readonly xl: `@media (min-width: ${number}rem)`;
|
|
19
|
+
readonly xxl: `@media (min-width: ${number}rem)`;
|
|
20
|
+
};
|
|
21
|
+
readonly below: {
|
|
22
|
+
/**
|
|
23
|
+
* A media query to target viewports below the min width of a given breakpoint.
|
|
24
|
+
* Note that `media.below.xxs` is intentionally omitted as this would be `@media (max-width: 0rem)`
|
|
25
|
+
*/
|
|
26
|
+
readonly xs: `@media (max-width: ${number}rem)`;
|
|
27
|
+
readonly sm: `@media (max-width: ${number}rem)`;
|
|
28
|
+
readonly md: `@media (max-width: ${number}rem)`;
|
|
29
|
+
readonly lg: `@media (max-width: ${number}rem)`;
|
|
30
|
+
readonly xl: `@media (max-width: ${number}rem)`;
|
|
31
|
+
readonly xxl: `@media (max-width: ${number}rem)`;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* With these types:
|
|
36
|
+
* ```
|
|
37
|
+
* type MediaQuery = `@media (${string})`;
|
|
38
|
+
* type ResponsiveMediaObject = Record<Breakpoint, MediaQuery>;
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* TODO: This `media` object as of typescript@4.9, would benefit from satisfies, eg.:
|
|
42
|
+
* ```
|
|
43
|
+
* const UNSAFE_media = { … } satisfies Record<'above' | 'only', ResponsiveMediaObject> & { below: Omit<ResponsiveMediaObject, 'xxs'> }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import { token } from '@atlaskit/tokens';
|
|
3
|
+
/**
|
|
4
|
+
* The breakpoints we have for responsiveness.
|
|
5
|
+
*/
|
|
6
|
+
export type Breakpoint = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
7
|
+
/**
|
|
8
|
+
* An object type mapping a value to each breakpoint (optionally)
|
|
9
|
+
*/
|
|
10
|
+
export type ResponsiveObject<T> = Partial<Record<Breakpoint, T>>;
|
|
11
|
+
/**
|
|
12
|
+
* A map of breakpoints to CSS, commonly used to build maps given a responsive object
|
|
13
|
+
* so we can statically compile CSS upfront, but dynamically apply it.
|
|
14
|
+
*
|
|
15
|
+
* @example Here we could conditionally load margins based a `setMarginBreakpoints={['xs', 'md']}` type prop.
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const marginMediaQueries = {
|
|
18
|
+
* xxs: css({ [media.above.xxs]: margin: 0 } }),
|
|
19
|
+
* xs: css({ [media.above.xs]: margin: 4 } }),
|
|
20
|
+
* //…
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* return <div css={setMarginBreakpoints.map(breakpoint => marginMediaQueries[breakpoint])} />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type ResponsiveCSSObject = ResponsiveObject<SerializedStyles>;
|
|
27
|
+
/**
|
|
28
|
+
* Our internal breakpoint config used to build media queries and define attributes for certain components.
|
|
29
|
+
*/
|
|
30
|
+
export type BreakpointConfig = {
|
|
31
|
+
/**
|
|
32
|
+
* The gap between a `GridItem`.
|
|
33
|
+
*/
|
|
34
|
+
gridItemGutter: ReturnType<typeof token>;
|
|
35
|
+
/**
|
|
36
|
+
* The outer whitespace of a `Grid` item.
|
|
37
|
+
*/
|
|
38
|
+
gridMargin: ReturnType<typeof token>;
|
|
39
|
+
/**
|
|
40
|
+
* The min-width used in media queries
|
|
41
|
+
*/
|
|
42
|
+
min: `${number}rem`;
|
|
43
|
+
/**
|
|
44
|
+
* The max-width used in media queries
|
|
45
|
+
*/
|
|
46
|
+
max: `${number}rem`;
|
|
47
|
+
/**
|
|
48
|
+
* To ensure min-width and max-width do both target at the same time, we subtract a value.
|
|
49
|
+
* We use a fractional value here as used in other libraries and described in @link https://www.w3.org/TR/mediaqueries-4/#mq-min-max: "…possibility of fractional viewport sizes which can occur as a result of non-integer pixel densities…"
|
|
50
|
+
*/
|
|
51
|
+
below: `${number}rem`;
|
|
52
|
+
};
|