@atlaskit/primitives 0.2.1 → 0.3.0
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/dist/cjs/components/inline.partial.js +46 -22
- package/dist/cjs/components/internal/base-box.partial.js +99 -78
- package/dist/cjs/components/internal/types.js +8 -0
- package/dist/cjs/components/internal/utils.js +16 -0
- package/dist/cjs/components/stack.partial.js +46 -22
- package/dist/cjs/constants.js +13 -0
- package/dist/cjs/helpers/responsive/build-media-query-css.js +88 -0
- package/dist/cjs/helpers/responsive/constants.js +85 -0
- package/dist/cjs/helpers/responsive/index.js +38 -0
- package/dist/cjs/helpers/responsive/media-helper.js +84 -0
- package/dist/cjs/helpers/responsive/types.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/inline.partial.js +18 -18
- package/dist/es2019/components/internal/base-box.partial.js +75 -70
- package/dist/es2019/components/internal/types.js +1 -0
- package/dist/es2019/components/internal/utils.js +2 -0
- package/dist/es2019/components/stack.partial.js +18 -18
- package/dist/es2019/constants.js +3 -1
- package/dist/es2019/helpers/responsive/build-media-query-css.js +85 -0
- package/dist/es2019/helpers/responsive/constants.js +74 -0
- package/dist/es2019/helpers/responsive/index.js +3 -0
- package/dist/es2019/helpers/responsive/media-helper.js +78 -0
- package/dist/es2019/helpers/responsive/types.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/inline.partial.js +46 -21
- package/dist/esm/components/internal/base-box.partial.js +100 -79
- package/dist/esm/components/internal/types.js +1 -0
- package/dist/esm/components/internal/utils.js +7 -0
- package/dist/esm/components/stack.partial.js +46 -21
- package/dist/esm/constants.js +3 -1
- package/dist/esm/helpers/responsive/build-media-query-css.js +79 -0
- package/dist/esm/helpers/responsive/constants.js +76 -0
- package/dist/esm/helpers/responsive/index.js +3 -0
- package/dist/esm/helpers/responsive/media-helper.js +78 -0
- package/dist/esm/helpers/responsive/types.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.d.ts +3 -5
- package/dist/types/components/inline.partial.d.ts +16 -18
- package/dist/types/components/internal/base-box.partial.d.ts +49 -50
- package/dist/types/components/internal/types.d.ts +6 -0
- package/dist/types/components/internal/utils.d.ts +3 -0
- package/dist/types/components/stack.partial.d.ts +16 -18
- package/dist/types/components/types.d.ts +49 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/helpers/responsive/build-media-query-css.d.ts +57 -0
- package/dist/types/helpers/responsive/constants.d.ts +23 -0
- package/dist/types/helpers/responsive/index.d.ts +4 -0
- package/dist/types/helpers/responsive/media-helper.d.ts +45 -0
- package/dist/types/helpers/responsive/types.d.ts +47 -0
- package/package.json +6 -3
- package/report.api.md +111 -78
- package/responsive/package.json +15 -0
- package/scripts/spacing-codegen-template.tsx +29 -24
- package/scripts/utils.tsx +4 -1
- package/tmp/api-report-tmp.d.ts +88 -77
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { SMALLEST_BREAKPOINT, UNSAFE_BREAKPOINTS_ORDERED_LIST } from './constants';
|
|
3
|
+
import { UNSAFE_media } from './media-helper';
|
|
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 const UNSAFE_buildAboveMediaQueryCSS = input => {
|
|
29
|
+
return UNSAFE_BREAKPOINTS_ORDERED_LIST.reduce((acc, breakpoint) => ({
|
|
30
|
+
...acc,
|
|
31
|
+
[breakpoint]: css({
|
|
32
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
33
|
+
[UNSAFE_media.above[breakpoint]]: typeof input === 'function' ? input(breakpoint) : input
|
|
34
|
+
})
|
|
35
|
+
}), {});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Build a map of breakpoints to css with media queries and nested styles.
|
|
40
|
+
*
|
|
41
|
+
* WARNING: The smallest breakpoint is not a valid key as a media query below 0px is misleading.
|
|
42
|
+
* This is separated from `buildAboveMediaQueryCSS` for that specific reason, you cannot have type safety with this variance.
|
|
43
|
+
*
|
|
44
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
48
|
+
* ```ts
|
|
49
|
+
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
50
|
+
*
|
|
51
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
52
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
57
|
+
* ```ts
|
|
58
|
+
* {
|
|
59
|
+
* xs: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
60
|
+
* sm: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
65
|
+
*/
|
|
66
|
+
export const UNSAFE_buildBelowMediaQueryCSS = input => {
|
|
67
|
+
/**
|
|
68
|
+
* WARNING: it's very important that these are in the correct order.
|
|
69
|
+
* If they are not, cascading is not in the order higher/low breakpoints do not override as expected.
|
|
70
|
+
*/
|
|
71
|
+
const reversedBreakpoints = [...UNSAFE_BREAKPOINTS_ORDERED_LIST].reverse();
|
|
72
|
+
return reversedBreakpoints.reduce((acc, breakpoint) => {
|
|
73
|
+
// Omit `media.below.xxs` as it's not available as that would be `<0px`…
|
|
74
|
+
if (breakpoint === SMALLEST_BREAKPOINT) {
|
|
75
|
+
return acc;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...acc,
|
|
79
|
+
[breakpoint]: css({
|
|
80
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
81
|
+
[UNSAFE_media.below[breakpoint]]: typeof input === 'function' ? input(breakpoint) : input
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
}, {});
|
|
85
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Our internal configuration for breakpoints configuration.
|
|
3
|
+
*
|
|
4
|
+
* @experimental Unsafe for consumption outside of the design system itself.
|
|
5
|
+
*/
|
|
6
|
+
export const UNSAFE_BREAKPOINTS_CONFIG = {
|
|
7
|
+
// mobile
|
|
8
|
+
xxs: {
|
|
9
|
+
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
10
|
+
gridMargin: "var(--ds-space-200, 16px)",
|
|
11
|
+
min: 0,
|
|
12
|
+
max: 479
|
|
13
|
+
},
|
|
14
|
+
// phablet
|
|
15
|
+
xs: {
|
|
16
|
+
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
17
|
+
gridMargin: "var(--ds-space-200, 16px)",
|
|
18
|
+
min: 480,
|
|
19
|
+
max: 767
|
|
20
|
+
},
|
|
21
|
+
// tablet
|
|
22
|
+
sm: {
|
|
23
|
+
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
24
|
+
gridMargin: "var(--ds-space-300, 24px)",
|
|
25
|
+
min: 768,
|
|
26
|
+
max: 1023
|
|
27
|
+
},
|
|
28
|
+
// laptop desktop
|
|
29
|
+
md: {
|
|
30
|
+
gridItemGutter: "var(--ds-space-300, 24px)",
|
|
31
|
+
gridMargin: "var(--ds-space-400, 32px)",
|
|
32
|
+
min: 1024,
|
|
33
|
+
max: 1439
|
|
34
|
+
},
|
|
35
|
+
// monitor
|
|
36
|
+
lg: {
|
|
37
|
+
gridItemGutter: "var(--ds-space-400, 32px)",
|
|
38
|
+
gridMargin: "var(--ds-space-400, 32px)",
|
|
39
|
+
min: 1440,
|
|
40
|
+
max: 1767
|
|
41
|
+
},
|
|
42
|
+
// large high res
|
|
43
|
+
xl: {
|
|
44
|
+
gridItemGutter: "var(--ds-space-400, 32px)",
|
|
45
|
+
gridMargin: "var(--ds-space-500, 40px)",
|
|
46
|
+
min: 1768,
|
|
47
|
+
max: 2159
|
|
48
|
+
},
|
|
49
|
+
// extra large high res
|
|
50
|
+
xxl: {
|
|
51
|
+
gridItemGutter: "var(--ds-space-500, 40px)",
|
|
52
|
+
gridMargin: "var(--ds-space-500, 40px)",
|
|
53
|
+
min: 2160,
|
|
54
|
+
max: Number.MAX_SAFE_INTEGER
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The list of breakpoints in order from smallest to largest. You may need to clone and reverse this list if you want the opposite.
|
|
60
|
+
*
|
|
61
|
+
* This is intentional for cascading with `min-width` or `media.above`. Media queries go from lowest width to highest.
|
|
62
|
+
*
|
|
63
|
+
* @experimental Unsafe for consumption outside of the design system itself.
|
|
64
|
+
*/
|
|
65
|
+
export const UNSAFE_BREAKPOINTS_ORDERED_LIST = Object.keys(UNSAFE_BREAKPOINTS_CONFIG).sort((a, b) => UNSAFE_BREAKPOINTS_CONFIG[a].min - UNSAFE_BREAKPOINTS_CONFIG[b].min);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* This is our smallest breakpoint with a few nuances to it:
|
|
69
|
+
* 1. It is the default value for shorthands, eg. `<GridItem span={6} />` maps to `{ [SMALLEST_BREAKPOINT]: props.span }`
|
|
70
|
+
* 2. It's omitted in `media.below` as there's nothing below `0px`.
|
|
71
|
+
*
|
|
72
|
+
* @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.
|
|
73
|
+
*/
|
|
74
|
+
export const SMALLEST_BREAKPOINT = UNSAFE_BREAKPOINTS_ORDERED_LIST[0];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { UNSAFE_BREAKPOINTS_CONFIG } from './constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* To ensure min-width and max-width do both target at the same time, we subtract a value.
|
|
5
|
+
* 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…"
|
|
6
|
+
*/
|
|
7
|
+
const BELOW_PRECISION = 0.02;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This is the full internal version. The import has been separated to only expose as-needed.
|
|
11
|
+
*/
|
|
12
|
+
const internalMedia = {
|
|
13
|
+
/**
|
|
14
|
+
* A media query to target viewports above the min width of a given breakpoint.
|
|
15
|
+
* Note that `media.above.xs` is redundant and should not be used, but it's included for programatic purposes.
|
|
16
|
+
*/
|
|
17
|
+
above: {
|
|
18
|
+
/**
|
|
19
|
+
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
20
|
+
*
|
|
21
|
+
* Eg. this is `@media (min-width: 0px)`
|
|
22
|
+
*/
|
|
23
|
+
xxs: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxs.min}px)`,
|
|
24
|
+
xs: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xs.min}px)`,
|
|
25
|
+
sm: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.sm.min}px)`,
|
|
26
|
+
md: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.md.min}px)`,
|
|
27
|
+
lg: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.lg.min}px)`,
|
|
28
|
+
xl: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xl.min}px)`,
|
|
29
|
+
xxl: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxl.min}px)`
|
|
30
|
+
},
|
|
31
|
+
below: {
|
|
32
|
+
/**
|
|
33
|
+
* A media query to target viewports below the min width of a given breakpoint.
|
|
34
|
+
* Note that `media.below.xxs` is intentionally omitted as this would be `@media (max-width: 0px)`
|
|
35
|
+
*/
|
|
36
|
+
xs: `@media (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xs.min - BELOW_PRECISION}px)`,
|
|
37
|
+
sm: `@media (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.sm.min - BELOW_PRECISION}px)`,
|
|
38
|
+
md: `@media (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.md.min - BELOW_PRECISION}px)`,
|
|
39
|
+
lg: `@media (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.lg.min - BELOW_PRECISION}px)`,
|
|
40
|
+
xl: `@media (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xl.min - BELOW_PRECISION}px)`,
|
|
41
|
+
xxl: `@media (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxl.min - BELOW_PRECISION}px)`
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* A media query to target viewports exactly between the min and max of a given breakpoint.
|
|
45
|
+
*/
|
|
46
|
+
only: {
|
|
47
|
+
xxs: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxs.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxs.max}px)`,
|
|
48
|
+
xs: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xs.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xs.max}px)`,
|
|
49
|
+
sm: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.sm.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.sm.max}px)`,
|
|
50
|
+
md: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.md.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.md.max}px)`,
|
|
51
|
+
lg: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.lg.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.lg.max}px)`,
|
|
52
|
+
xl: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xl.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xl.max}px)`,
|
|
53
|
+
xxl: `@media (min-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxl.min}px) and (max-width: ${UNSAFE_BREAKPOINTS_CONFIG.xxl.max}px)`
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
59
|
+
*
|
|
60
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
61
|
+
*/
|
|
62
|
+
export const UNSAFE_media = {
|
|
63
|
+
above: internalMedia.above,
|
|
64
|
+
below: internalMedia.below
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* With these types:
|
|
69
|
+
* ```
|
|
70
|
+
* type MediaQuery = `@media (${string})`;
|
|
71
|
+
* type ResponsiveMediaObject = Record<Breakpoint, MediaQuery>;
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* TODO: This `media` object as of typescript@4.9, would benefit from satisfies, eg.:
|
|
75
|
+
* ```
|
|
76
|
+
* const UNSAFE_media = { … } satisfies Record<'above' | 'only', ResponsiveMediaObject> & { below: Omit<ResponsiveMediaObject, 'xxs'> }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
/** @jsx jsx */
|
|
3
2
|
import { Children, forwardRef, Fragment, memo } from 'react';
|
|
4
3
|
import { css, jsx } from '@emotion/react';
|
|
@@ -44,30 +43,56 @@ var flexWrapStyles = css({
|
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
47
|
-
* @codegen <<SignedSource::
|
|
46
|
+
* @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
|
|
48
47
|
* @codegenId spacing
|
|
49
48
|
* @codegenCommand yarn codegen-styles
|
|
50
49
|
* @codegenParams ["space"]
|
|
51
50
|
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
|
|
52
51
|
*/
|
|
53
|
-
var spaceMap =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
var spaceMap = {
|
|
53
|
+
'0': css({
|
|
54
|
+
gap: "var(--ds-space-0, 0px)"
|
|
55
|
+
}),
|
|
56
|
+
'025': css({
|
|
57
|
+
gap: "var(--ds-space-025, 2px)"
|
|
58
|
+
}),
|
|
59
|
+
'050': css({
|
|
60
|
+
gap: "var(--ds-space-050, 4px)"
|
|
61
|
+
}),
|
|
62
|
+
'075': css({
|
|
63
|
+
gap: "var(--ds-space-075, 6px)"
|
|
64
|
+
}),
|
|
65
|
+
'100': css({
|
|
66
|
+
gap: "var(--ds-space-100, 8px)"
|
|
67
|
+
}),
|
|
68
|
+
'150': css({
|
|
69
|
+
gap: "var(--ds-space-150, 12px)"
|
|
70
|
+
}),
|
|
71
|
+
'200': css({
|
|
72
|
+
gap: "var(--ds-space-200, 16px)"
|
|
73
|
+
}),
|
|
74
|
+
'250': css({
|
|
75
|
+
gap: "var(--ds-space-250, 20px)"
|
|
76
|
+
}),
|
|
77
|
+
'300': css({
|
|
78
|
+
gap: "var(--ds-space-300, 24px)"
|
|
79
|
+
}),
|
|
80
|
+
'400': css({
|
|
81
|
+
gap: "var(--ds-space-400, 32px)"
|
|
82
|
+
}),
|
|
83
|
+
'500': css({
|
|
84
|
+
gap: "var(--ds-space-500, 40px)"
|
|
85
|
+
}),
|
|
86
|
+
'600': css({
|
|
87
|
+
gap: "var(--ds-space-600, 48px)"
|
|
88
|
+
}),
|
|
89
|
+
'800': css({
|
|
90
|
+
gap: "var(--ds-space-800, 64px)"
|
|
91
|
+
}),
|
|
92
|
+
'1000': css({
|
|
93
|
+
gap: "var(--ds-space-1000, 80px)"
|
|
94
|
+
})
|
|
95
|
+
};
|
|
71
96
|
/**
|
|
72
97
|
* @codegenEnd
|
|
73
98
|
*/
|
|
@@ -125,7 +150,7 @@ var Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
125
150
|
}) : rawChildren;
|
|
126
151
|
var justifyContent = spread || alignInline;
|
|
127
152
|
return jsx("div", {
|
|
128
|
-
css: [baseStyles, space && spaceMap
|
|
153
|
+
css: [baseStyles, space && spaceMap[space], justifyContent && justifyContentMap[justifyContent], grow && flexGrowMap[grow], alignItems && alignItemsMap[alignItems], shouldWrap && flexWrapStyles],
|
|
129
154
|
"data-testid": testId,
|
|
130
155
|
ref: ref
|
|
131
156
|
}, children);
|
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
var _excluded = ["as", "className", "children", "color", "backgroundColor", "shadow", "borderStyle", "borderWidth", "borderRadius", "borderColor", "layer", "flex", "flexGrow", "flexShrink", "alignSelf", "overflow", "overflowInline", "overflowBlock", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "height", "width", "display", "position", "UNSAFE_style", "testId"];
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
7
|
/** @jsx jsx */
|
|
6
8
|
import { forwardRef } from 'react';
|
|
7
9
|
import { css, jsx } from '@emotion/react';
|
|
8
|
-
import
|
|
10
|
+
import invariant from 'tiny-invariant';
|
|
11
|
+
import { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, LAYERS } from '../../constants';
|
|
12
|
+
import { BOX_RESPONSIVE_PROPS } from './types';
|
|
13
|
+
import { isResponsiveStyleProp, isStaticStyleProp } from './utils';
|
|
14
|
+
var responsiveRules = BOX_RESPONSIVE_PROPS.reduce(function (mapping, cssProperty) {
|
|
15
|
+
return Object.assign(mapping, _defineProperty({}, cssProperty, BREAKPOINTS_LIST.reduce(function (configs, breakpoint) {
|
|
16
|
+
var config = BREAKPOINTS_CONFIG[breakpoint];
|
|
17
|
+
return Object.assign(configs, _defineProperty({}, breakpoint, css(_defineProperty({}, "@media (min-width: ".concat(config.min, "px)"), _defineProperty({}, cssProperty, "var(--ds-box-responsive-".concat(cssProperty, "-").concat(breakpoint, ")"))))));
|
|
18
|
+
}, {
|
|
19
|
+
static: css(_defineProperty({}, cssProperty, "var(--ds-box-static-".concat(cssProperty, ")")))
|
|
20
|
+
})));
|
|
21
|
+
}, {});
|
|
22
|
+
var getResponsiveVars = function getResponsiveVars(propertyName, propertyValue, mapping) {
|
|
23
|
+
if (isResponsiveStyleProp(propertyValue)) {
|
|
24
|
+
return Object.keys(propertyValue).reduce(function (vars, breakpoint) {
|
|
25
|
+
return _objectSpread(_objectSpread({}, vars), {}, _defineProperty({}, "--ds-box-responsive-".concat(propertyName, "-").concat(breakpoint), mapping[propertyValue[breakpoint]]));
|
|
26
|
+
}, {});
|
|
27
|
+
} else if (isStaticStyleProp(propertyValue)) {
|
|
28
|
+
return _defineProperty({}, "--ds-box-static-".concat(propertyName), mapping[propertyValue]);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var getResponsiveStyles = function getResponsiveStyles(propertyName, propertyValue) {
|
|
32
|
+
invariant(typeof responsiveRules[propertyName] !== 'undefined', "Responsive rules for \"".concat(propertyName, "\" have not been statically defined."));
|
|
33
|
+
if (isResponsiveStyleProp(propertyValue)) {
|
|
34
|
+
return Object.keys(propertyValue).map(function (responsiveProp) {
|
|
35
|
+
return responsiveRules[propertyName][responsiveProp];
|
|
36
|
+
});
|
|
37
|
+
} else if (isStaticStyleProp(propertyValue)) {
|
|
38
|
+
return responsiveRules[propertyName].static;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Without this type annotation on Box we don't get autocomplete for props due to forwardRef types
|
|
43
|
+
|
|
9
44
|
/**
|
|
10
45
|
* __Box__
|
|
11
46
|
*
|
|
@@ -14,49 +49,50 @@ import { LAYERS } from '../../constants';
|
|
|
14
49
|
*
|
|
15
50
|
* @internal
|
|
16
51
|
*/
|
|
17
|
-
export var BaseBox = /*#__PURE__*/forwardRef(function (
|
|
18
|
-
var as =
|
|
19
|
-
className =
|
|
20
|
-
children =
|
|
21
|
-
color =
|
|
22
|
-
backgroundColor =
|
|
23
|
-
shadow =
|
|
24
|
-
borderStyle =
|
|
25
|
-
borderWidth =
|
|
26
|
-
borderRadius =
|
|
27
|
-
borderColor =
|
|
28
|
-
layer =
|
|
29
|
-
flex =
|
|
30
|
-
flexGrow =
|
|
31
|
-
flexShrink =
|
|
32
|
-
alignSelf =
|
|
33
|
-
overflow =
|
|
34
|
-
overflowInline =
|
|
35
|
-
overflowBlock =
|
|
36
|
-
padding =
|
|
37
|
-
paddingBlock =
|
|
38
|
-
paddingBlockStart =
|
|
39
|
-
paddingBlockEnd =
|
|
40
|
-
paddingInline =
|
|
41
|
-
paddingInlineStart =
|
|
42
|
-
paddingInlineEnd =
|
|
43
|
-
height =
|
|
44
|
-
width =
|
|
45
|
-
|
|
46
|
-
display =
|
|
47
|
-
|
|
48
|
-
position =
|
|
49
|
-
UNSAFE_style =
|
|
50
|
-
testId =
|
|
51
|
-
htmlAttributes = _objectWithoutProperties(
|
|
52
|
+
export var BaseBox = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
53
|
+
var as = _ref2.as,
|
|
54
|
+
className = _ref2.className,
|
|
55
|
+
children = _ref2.children,
|
|
56
|
+
color = _ref2.color,
|
|
57
|
+
backgroundColor = _ref2.backgroundColor,
|
|
58
|
+
shadow = _ref2.shadow,
|
|
59
|
+
borderStyle = _ref2.borderStyle,
|
|
60
|
+
borderWidth = _ref2.borderWidth,
|
|
61
|
+
borderRadius = _ref2.borderRadius,
|
|
62
|
+
borderColor = _ref2.borderColor,
|
|
63
|
+
layer = _ref2.layer,
|
|
64
|
+
flex = _ref2.flex,
|
|
65
|
+
flexGrow = _ref2.flexGrow,
|
|
66
|
+
flexShrink = _ref2.flexShrink,
|
|
67
|
+
alignSelf = _ref2.alignSelf,
|
|
68
|
+
overflow = _ref2.overflow,
|
|
69
|
+
overflowInline = _ref2.overflowInline,
|
|
70
|
+
overflowBlock = _ref2.overflowBlock,
|
|
71
|
+
padding = _ref2.padding,
|
|
72
|
+
paddingBlock = _ref2.paddingBlock,
|
|
73
|
+
paddingBlockStart = _ref2.paddingBlockStart,
|
|
74
|
+
paddingBlockEnd = _ref2.paddingBlockEnd,
|
|
75
|
+
paddingInline = _ref2.paddingInline,
|
|
76
|
+
paddingInlineStart = _ref2.paddingInlineStart,
|
|
77
|
+
paddingInlineEnd = _ref2.paddingInlineEnd,
|
|
78
|
+
height = _ref2.height,
|
|
79
|
+
width = _ref2.width,
|
|
80
|
+
_ref2$display = _ref2.display,
|
|
81
|
+
display = _ref2$display === void 0 ? displayMap.block : _ref2$display,
|
|
82
|
+
_ref2$position = _ref2.position,
|
|
83
|
+
position = _ref2$position === void 0 ? 'static' : _ref2$position,
|
|
84
|
+
UNSAFE_style = _ref2.UNSAFE_style,
|
|
85
|
+
testId = _ref2.testId,
|
|
86
|
+
htmlAttributes = _objectWithoutProperties(_ref2, _excluded);
|
|
52
87
|
var Component = as || 'div';
|
|
88
|
+
var inlineStyles = Object.assign({}, UNSAFE_style, getResponsiveVars('borderWidth', borderWidth, borderWidthMap), getResponsiveVars('display', display, displayMap), getResponsiveVars('padding', padding, paddingMap), getResponsiveVars('paddingBlock', paddingBlock, paddingMap), getResponsiveVars('paddingBlockStart', paddingBlockStart, paddingMap), getResponsiveVars('paddingBlockEnd', paddingBlockEnd, paddingMap), getResponsiveVars('paddingInline', paddingInline, paddingMap), getResponsiveVars('paddingInlineStart', paddingInlineStart, paddingMap), getResponsiveVars('paddingInlineEnd', paddingInlineEnd, paddingMap));
|
|
53
89
|
var node = jsx(Component, _extends({
|
|
54
|
-
style:
|
|
90
|
+
style: inlineStyles,
|
|
55
91
|
ref: ref
|
|
56
92
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
57
93
|
}, htmlAttributes, {
|
|
58
94
|
className: className,
|
|
59
|
-
css: [baseStyles, display
|
|
95
|
+
css: [baseStyles].concat([getResponsiveStyles('borderWidth', borderWidth), getResponsiveStyles('display', display), getResponsiveStyles('padding', padding), getResponsiveStyles('paddingBlock', paddingBlock), getResponsiveStyles('paddingBlockStart', paddingBlockStart), getResponsiveStyles('paddingBlockEnd', paddingBlockEnd), getResponsiveStyles('paddingInline', paddingInline), getResponsiveStyles('paddingInlineStart', paddingInlineStart), getResponsiveStyles('paddingInlineEnd', paddingInlineEnd)], [backgroundColor && backgroundColorMap[backgroundColor], borderColor && borderColorMap[borderColor], color && textColorMap[color], flex && flexMap[flex], flexGrow && flexGrowMap[flexGrow], flexShrink && flexShrinkMap[flexShrink], alignSelf && alignSelfMap[alignSelf], overflow && overflowMap[overflow], overflowInline && overflowInlineMap[overflowInline], overflowBlock && overflowBlockMap[overflowBlock], position && positionMap[position], borderStyle && borderStyleMap[borderStyle], borderRadius && borderRadiusMap[borderRadius], shadow && shadowMap[shadow], layer && layerMap[layer], overflow && overflowMap[overflow], width && widthMap[width], height && heightMap[height]]),
|
|
60
96
|
"data-testid": testId
|
|
61
97
|
}), children);
|
|
62
98
|
return node;
|
|
@@ -75,12 +111,9 @@ var borderStyleMap = {
|
|
|
75
111
|
})
|
|
76
112
|
};
|
|
77
113
|
var borderWidthMap = {
|
|
78
|
-
'size.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'size.100': css({
|
|
82
|
-
borderWidth: "var(--ds-width-100, 2px)"
|
|
83
|
-
})
|
|
114
|
+
'size.0': "var(--ds-width-0, 0)",
|
|
115
|
+
'size.050': "var(--ds-width-050, 1px)",
|
|
116
|
+
'size.100': "var(--ds-width-100, 2px)"
|
|
84
117
|
};
|
|
85
118
|
var borderRadiusMap = {
|
|
86
119
|
'radius.100': css({
|
|
@@ -138,21 +171,11 @@ var alignSelfMap = {
|
|
|
138
171
|
})
|
|
139
172
|
};
|
|
140
173
|
var displayMap = {
|
|
141
|
-
block:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
inline:
|
|
145
|
-
|
|
146
|
-
}),
|
|
147
|
-
flex: css({
|
|
148
|
-
display: 'flex'
|
|
149
|
-
}),
|
|
150
|
-
'inline-flex': css({
|
|
151
|
-
display: 'inline-flex'
|
|
152
|
-
}),
|
|
153
|
-
'inline-block': css({
|
|
154
|
-
display: 'inline-block'
|
|
155
|
-
})
|
|
174
|
+
block: 'block',
|
|
175
|
+
inline: 'inline',
|
|
176
|
+
flex: 'flex',
|
|
177
|
+
'inline-flex': 'inline-flex',
|
|
178
|
+
'inline-block': 'inline-block'
|
|
156
179
|
};
|
|
157
180
|
var positionMap = {
|
|
158
181
|
absolute: css({
|
|
@@ -367,30 +390,28 @@ var maxHeightMap = {
|
|
|
367
390
|
|
|
368
391
|
/**
|
|
369
392
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
370
|
-
* @codegen <<SignedSource::
|
|
393
|
+
* @codegen <<SignedSource::84fd352b0e6509d380a0dcf8ad023ca2>>
|
|
371
394
|
* @codegenId spacing
|
|
372
395
|
* @codegenCommand yarn codegen-styles
|
|
373
396
|
* @codegenParams ["padding"]
|
|
374
397
|
* @codegenDependency ../../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
|
|
375
398
|
*/
|
|
376
|
-
var paddingMap =
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}];
|
|
393
|
-
}));
|
|
399
|
+
var paddingMap = {
|
|
400
|
+
'space.0': "var(--ds-space-0, 0px)",
|
|
401
|
+
'space.025': "var(--ds-space-025, 2px)",
|
|
402
|
+
'space.050': "var(--ds-space-050, 4px)",
|
|
403
|
+
'space.075': "var(--ds-space-075, 6px)",
|
|
404
|
+
'space.100': "var(--ds-space-100, 8px)",
|
|
405
|
+
'space.150': "var(--ds-space-150, 12px)",
|
|
406
|
+
'space.200': "var(--ds-space-200, 16px)",
|
|
407
|
+
'space.250': "var(--ds-space-250, 20px)",
|
|
408
|
+
'space.300': "var(--ds-space-300, 24px)",
|
|
409
|
+
'space.400': "var(--ds-space-400, 32px)",
|
|
410
|
+
'space.500': "var(--ds-space-500, 40px)",
|
|
411
|
+
'space.600': "var(--ds-space-600, 48px)",
|
|
412
|
+
'space.800': "var(--ds-space-800, 64px)",
|
|
413
|
+
'space.1000': "var(--ds-space-1000, 80px)"
|
|
414
|
+
};
|
|
394
415
|
/**
|
|
395
416
|
* @codegenEnd
|
|
396
417
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var BOX_RESPONSIVE_PROPS = ['borderWidth', 'display', 'padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd'];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
export var isResponsiveStyleProp = function isResponsiveStyleProp(propertyValue) {
|
|
3
|
+
return _typeof(propertyValue) === 'object';
|
|
4
|
+
};
|
|
5
|
+
export var isStaticStyleProp = function isStaticStyleProp(propertyValue) {
|
|
6
|
+
return typeof propertyValue === 'string';
|
|
7
|
+
};
|