@atlaskit/primitives 18.0.0 → 18.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 +8 -0
- package/codemods/hypermod.config.tsx +5 -1
- package/constellation/anchor/usage.mdx +40 -38
- package/constellation/pressable/usage.mdx +23 -22
- package/dist/cjs/compiled/components/anchor.js +2 -4
- package/dist/cjs/compiled/components/box.js +1 -3
- package/dist/cjs/compiled/components/focusable.js +1 -3
- package/dist/cjs/compiled/components/pressable.js +2 -4
- package/dist/cjs/components/anchor.js +3 -5
- package/dist/cjs/components/bleed.js +1 -1
- package/dist/cjs/components/box.js +1 -3
- package/dist/cjs/components/pressable.js +1 -2
- package/dist/cjs/responsive/hide.js +1 -1
- package/dist/es2019/compiled/components/anchor.js +2 -4
- package/dist/es2019/compiled/components/box.js +1 -3
- package/dist/es2019/compiled/components/focusable.js +1 -3
- package/dist/es2019/compiled/components/pressable.js +2 -4
- package/dist/es2019/components/anchor.js +3 -5
- package/dist/es2019/components/bleed.js +1 -1
- package/dist/es2019/components/box.js +1 -3
- package/dist/es2019/components/pressable.js +1 -2
- package/dist/es2019/responsive/hide.js +1 -1
- package/dist/esm/compiled/components/anchor.js +2 -4
- package/dist/esm/compiled/components/box.js +1 -3
- package/dist/esm/compiled/components/focusable.js +1 -3
- package/dist/esm/compiled/components/pressable.js +2 -4
- package/dist/esm/components/anchor.js +3 -5
- package/dist/esm/components/bleed.js +1 -1
- package/dist/esm/components/box.js +1 -3
- package/dist/esm/components/pressable.js +1 -2
- package/dist/esm/responsive/hide.js +1 -1
- package/dist/types/compiled/components/flex.d.ts +2 -2
- package/dist/types/compiled/components/grid.d.ts +2 -2
- package/dist/types/compiled/components/inline.d.ts +2 -2
- package/dist/types/compiled/components/stack.d.ts +2 -2
- package/dist/types/compiled/index.d.ts +1 -1
- package/dist/types/components/flex.d.ts +19 -18
- package/dist/types/components/grid.d.ts +30 -29
- package/dist/types/components/inline.d.ts +1 -1
- package/dist/types/components/stack.d.ts +2 -2
- package/dist/types/components/text.d.ts +4 -3
- package/dist/types/responsive/build-media-query-css.d.ts +3 -3
- package/dist/types/responsive/media-helper.d.ts +17 -17
- package/dist/types/utils/has-text-ancestor-context.d.ts +2 -1
- package/dist/types/utils/surface-provider.d.ts +2 -1
- package/dist/types-ts4.5/compiled/components/flex.d.ts +2 -2
- package/dist/types-ts4.5/compiled/components/grid.d.ts +2 -2
- package/dist/types-ts4.5/compiled/components/inline.d.ts +2 -2
- package/dist/types-ts4.5/compiled/components/stack.d.ts +2 -2
- package/dist/types-ts4.5/compiled/index.d.ts +1 -1
- package/dist/types-ts4.5/components/flex.d.ts +19 -18
- package/dist/types-ts4.5/components/grid.d.ts +30 -29
- package/dist/types-ts4.5/components/inline.d.ts +1 -1
- package/dist/types-ts4.5/components/stack.d.ts +2 -2
- package/dist/types-ts4.5/components/text.d.ts +4 -3
- package/dist/types-ts4.5/responsive/build-media-query-css.d.ts +3 -3
- package/dist/types-ts4.5/responsive/media-helper.d.ts +17 -17
- package/dist/types-ts4.5/utils/has-text-ancestor-context.d.ts +2 -1
- package/dist/types-ts4.5/utils/surface-provider.d.ts +2 -1
- package/package.json +7 -7
- package/scripts/codegen-styles.tsx +6 -9
- package/scripts/color-codegen-template.tsx +3 -1
- package/scripts/elevation-codegen-template.tsx +3 -1
- package/scripts/inverse-color-map-template.tsx +1 -1
- package/scripts/misc-codegen-template.tsx +3 -1
- package/scripts/shape-codegen-template.tsx +3 -1
- package/scripts/spacing-codegen-template.tsx +1 -1
- package/scripts/text-codegen-template.tsx +1 -1
- package/scripts/typography-codegen-template.tsx +1 -1
- package/scripts/utils.tsx +17 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CSSObject } from '@emotion/react';
|
|
1
|
+
import { type CSSObject, type SerializedStyles } from '@emotion/react';
|
|
2
2
|
import type { Breakpoint } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Build a map of breakpoints to css with media queries and nested styles.
|
|
@@ -30,7 +30,7 @@ export declare const UNSAFE_buildAboveMediaQueryCSS: (
|
|
|
30
30
|
* The desired CSS to place inside of the media query.
|
|
31
31
|
* This can either be a css object directly or functional with `breakpoint` as the arg to return a css object.
|
|
32
32
|
*/
|
|
33
|
-
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint,
|
|
33
|
+
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, SerializedStyles>>>;
|
|
34
34
|
/**
|
|
35
35
|
* Build a map of breakpoints to css with media queries and nested styles.
|
|
36
36
|
*
|
|
@@ -60,4 +60,4 @@ export declare const UNSAFE_buildBelowMediaQueryCSS: (
|
|
|
60
60
|
* The desired CSS to place inside of the media query.
|
|
61
61
|
* This can either be a css object directly or functional with `breakpoint` as the arg to return a css object.
|
|
62
62
|
*/
|
|
63
|
-
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint,
|
|
63
|
+
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, SerializedStyles>>>;
|
|
@@ -38,26 +38,26 @@ export declare const media: {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const UNSAFE_media: {
|
|
40
40
|
above: {
|
|
41
|
-
readonly xxs:
|
|
42
|
-
readonly xs:
|
|
43
|
-
readonly sm:
|
|
44
|
-
readonly md:
|
|
45
|
-
readonly lg:
|
|
46
|
-
readonly xl:
|
|
41
|
+
readonly xxs: '@media all';
|
|
42
|
+
readonly xs: '@media (min-width: 30rem)';
|
|
43
|
+
readonly sm: '@media (min-width: 48rem)';
|
|
44
|
+
readonly md: '@media (min-width: 64rem)';
|
|
45
|
+
readonly lg: '@media (min-width: 90rem)';
|
|
46
|
+
readonly xl: '@media (min-width: 110.5rem)';
|
|
47
47
|
};
|
|
48
48
|
only: {
|
|
49
|
-
readonly xxs:
|
|
50
|
-
readonly xs:
|
|
51
|
-
readonly sm:
|
|
52
|
-
readonly md:
|
|
53
|
-
readonly lg:
|
|
54
|
-
readonly xl:
|
|
49
|
+
readonly xxs: '@media (min-width: 0rem) and (max-width: 29.99rem)';
|
|
50
|
+
readonly xs: '@media (min-width: 30rem) and (max-width: 47.99rem)';
|
|
51
|
+
readonly sm: '@media (min-width: 48rem) and (max-width: 63.99rem)';
|
|
52
|
+
readonly md: '@media (min-width: 64rem) and (max-width: 89.99rem)';
|
|
53
|
+
readonly lg: '@media (min-width: 90rem) and (max-width: 110.49rem)';
|
|
54
|
+
readonly xl: '@media (min-width: 110.5rem)';
|
|
55
55
|
};
|
|
56
56
|
below: {
|
|
57
|
-
readonly xs:
|
|
58
|
-
readonly sm:
|
|
59
|
-
readonly md:
|
|
60
|
-
readonly lg:
|
|
61
|
-
readonly xl:
|
|
57
|
+
readonly xs: '@media not all and (min-width: 30rem)';
|
|
58
|
+
readonly sm: '@media not all and (min-width: 48rem)';
|
|
59
|
+
readonly md: '@media not all and (min-width: 64rem)';
|
|
60
|
+
readonly lg: '@media not all and (min-width: 90rem)';
|
|
61
|
+
readonly xl: '@media not all and (min-width: 110.5rem)';
|
|
62
62
|
};
|
|
63
63
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Provider } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* @internal
|
|
3
4
|
*/
|
|
@@ -5,4 +6,4 @@ export declare const useHasTextAncestor: () => boolean;
|
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
|
-
export declare const HasTextAncestorProvider:
|
|
9
|
+
export declare const HasTextAncestorProvider: Provider<boolean>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type Context } from 'react';
|
|
1
2
|
import type { BackgroundColorToken } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* __Surface context__
|
|
4
5
|
*
|
|
5
6
|
* A surface context provides context information on the current background (if set).
|
|
6
7
|
*/
|
|
7
|
-
export declare const SurfaceContext:
|
|
8
|
+
export declare const SurfaceContext: Context<BackgroundColorToken>;
|
|
8
9
|
/**
|
|
9
10
|
* __useSurface__
|
|
10
11
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.1",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
135
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
136
|
-
"@atlaskit/app-provider": "^4.
|
|
136
|
+
"@atlaskit/app-provider": "^4.1.0",
|
|
137
137
|
"@atlaskit/css": "^0.19.0",
|
|
138
138
|
"@atlaskit/ds-lib": "^5.3.0",
|
|
139
139
|
"@atlaskit/interaction-context": "^3.1.0",
|
|
@@ -154,21 +154,21 @@
|
|
|
154
154
|
"@af/formatting": "workspace:^",
|
|
155
155
|
"@af/integration-testing": "workspace:^",
|
|
156
156
|
"@af/visual-regression": "workspace:^",
|
|
157
|
-
"@atlaskit/avatar": "^25.
|
|
157
|
+
"@atlaskit/avatar": "^25.8.0",
|
|
158
158
|
"@atlaskit/button": "^23.9.0",
|
|
159
159
|
"@atlaskit/checkbox": "^17.3.0",
|
|
160
160
|
"@atlaskit/code": "^17.4.0",
|
|
161
|
-
"@atlaskit/docs": "^11.
|
|
161
|
+
"@atlaskit/docs": "^11.4.0",
|
|
162
162
|
"@atlaskit/dropdown-menu": "^16.4.0",
|
|
163
163
|
"@atlaskit/flag": "^17.8.0",
|
|
164
164
|
"@atlaskit/form": "^15.3.0",
|
|
165
|
-
"@atlaskit/heading": "^5.
|
|
166
|
-
"@atlaskit/icon": "^
|
|
165
|
+
"@atlaskit/heading": "^5.3.0",
|
|
166
|
+
"@atlaskit/icon": "^31.0.0",
|
|
167
167
|
"@atlaskit/icon-object": "^7.4.0",
|
|
168
168
|
"@atlaskit/image": "^3.0.0",
|
|
169
169
|
"@atlaskit/link": "^3.3.0",
|
|
170
170
|
"@atlaskit/logo": "^19.10.0",
|
|
171
|
-
"@atlaskit/lozenge": "^13.
|
|
171
|
+
"@atlaskit/lozenge": "^13.4.0",
|
|
172
172
|
"@atlaskit/motion": "^5.3.0",
|
|
173
173
|
"@atlaskit/range": "^9.3.0",
|
|
174
174
|
"@atlaskit/section-message": "^8.12.0",
|
|
@@ -13,15 +13,12 @@ import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
|
|
|
13
13
|
import { createTextStylesFromTemplate } from './text-codegen-template';
|
|
14
14
|
import { createTypographyStylesFromTemplate } from './typography-codegen-template';
|
|
15
15
|
|
|
16
|
-
const colorTokensDependencyPath =
|
|
17
|
-
'../../tokens/src/artifacts/tokens-raw/atlassian-light'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
const shapeTokensDependencyPath = require.resolve(
|
|
23
|
-
'../../tokens/src/artifacts/tokens-raw/atlassian-shape',
|
|
24
|
-
);
|
|
16
|
+
const colorTokensDependencyPath =
|
|
17
|
+
require.resolve('../../tokens/src/artifacts/tokens-raw/atlassian-light');
|
|
18
|
+
const spacingTokensDependencyPath =
|
|
19
|
+
require.resolve('../../tokens/src/artifacts/tokens-raw/atlassian-spacing');
|
|
20
|
+
const shapeTokensDependencyPath =
|
|
21
|
+
require.resolve('../../tokens/src/artifacts/tokens-raw/atlassian-shape');
|
|
25
22
|
|
|
26
23
|
const templateFiles = readdirSync(join(__dirname, 'codegen-file-templates'), {
|
|
27
24
|
withFileTypes: true,
|
|
@@ -58,7 +58,9 @@ const activeTokens = tokens
|
|
|
58
58
|
}),
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
export const createColorStylesFromTemplate
|
|
61
|
+
export const createColorStylesFromTemplate: (colorProperty: keyof typeof tokenStyles) => string = (
|
|
62
|
+
colorProperty: keyof typeof tokenStyles,
|
|
63
|
+
) => {
|
|
62
64
|
if (!tokenStyles[colorProperty]) {
|
|
63
65
|
throw new Error(`[codegen] Unknown option found "${colorProperty}"`);
|
|
64
66
|
}
|
|
@@ -47,7 +47,9 @@ const activeTokens = tokens
|
|
|
47
47
|
}),
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
export const createElevationStylesFromTemplate
|
|
50
|
+
export const createElevationStylesFromTemplate: (property: keyof typeof tokenStyles) => string = (
|
|
51
|
+
property: keyof typeof tokenStyles,
|
|
52
|
+
) => {
|
|
51
53
|
if (!tokenStyles[property]) {
|
|
52
54
|
throw new Error(`[codegen] Unknown option found "${property}"`);
|
|
53
55
|
}
|
|
@@ -22,7 +22,7 @@ const activeTokens = tokens
|
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
.map((t) => ({ ...t, token: t.token.replaceAll('.[default]', '') }));
|
|
24
24
|
|
|
25
|
-
export const createInverseColorMapTemplate = () => {
|
|
25
|
+
export const createInverseColorMapTemplate: () => string = () => {
|
|
26
26
|
const propMap = activeTokens.map((t) => {
|
|
27
27
|
// handle the default case eg color.border or color.text
|
|
28
28
|
const propName = t.token;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
|
|
4
|
-
export const createStylesFromFileTemplate
|
|
4
|
+
export const createStylesFromFileTemplate: (
|
|
5
|
+
property: 'border-color' | 'border-radius' | 'border-width' | 'dimensions' | 'layer',
|
|
6
|
+
) => NonSharedBuffer = (
|
|
5
7
|
property: 'border-color' | 'border-radius' | 'border-width' | 'dimensions' | 'layer',
|
|
6
8
|
) => {
|
|
7
9
|
const path = join(__dirname, './codegen-file-templates', `${property}.tsx`);
|
|
@@ -35,7 +35,9 @@ const activeTokens = shapeTokens
|
|
|
35
35
|
}),
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
export const createShapeStylesFromTemplate
|
|
38
|
+
export const createShapeStylesFromTemplate: (property: keyof typeof tokenStyles) => string = (
|
|
39
|
+
property: keyof typeof tokenStyles,
|
|
40
|
+
): string => {
|
|
39
41
|
if (!tokenStyles[property]) {
|
|
40
42
|
throw new Error(`[codegen] Unknown option found "${property}"`);
|
|
41
43
|
}
|
|
@@ -21,7 +21,7 @@ const negativeSpaceTokens = tokens
|
|
|
21
21
|
fallback: t.value,
|
|
22
22
|
}));
|
|
23
23
|
|
|
24
|
-
export const createSpacingStylesFromTemplate = () => {
|
|
24
|
+
export const createSpacingStylesFromTemplate: () => string = () => {
|
|
25
25
|
const output = [
|
|
26
26
|
`export const positiveSpaceMap: {
|
|
27
27
|
${generateTypeDefs(positiveSpaceTokens.map((t) => t.name))}
|
|
@@ -62,7 +62,7 @@ const removeVerbosity = (name: string): string => {
|
|
|
62
62
|
return name;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
export const createTextStylesFromTemplate = () => {
|
|
65
|
+
export const createTextStylesFromTemplate: () => string = () => {
|
|
66
66
|
return textProperties
|
|
67
67
|
.map((textProperty) => {
|
|
68
68
|
const { filterFn, objectName } = textProperty;
|
|
@@ -42,7 +42,7 @@ const typographyProperties = [
|
|
|
42
42
|
},
|
|
43
43
|
] as const;
|
|
44
44
|
|
|
45
|
-
export const createTypographyStylesFromTemplate = () => {
|
|
45
|
+
export const createTypographyStylesFromTemplate: () => string = () => {
|
|
46
46
|
return typographyProperties
|
|
47
47
|
.map((typographyProperty) => {
|
|
48
48
|
const { filterFn, objectName } = typographyProperty;
|
package/scripts/utils.tsx
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import tokens from '@atlaskit/tokens/token-names';
|
|
2
2
|
|
|
3
|
-
export const constructTokenFunctionCall
|
|
3
|
+
export const constructTokenFunctionCall: (
|
|
4
|
+
token: string,
|
|
5
|
+
fallback: string | ShadowDefinition,
|
|
6
|
+
) => string = (token: string, fallback: string | ShadowDefinition) => {
|
|
4
7
|
if (Array.isArray(fallback)) {
|
|
5
8
|
fallback = constructShadow(fallback);
|
|
6
9
|
}
|
|
@@ -26,28 +29,32 @@ const constructShadow = (shadowObject: ShadowDefinition) => {
|
|
|
26
29
|
|
|
27
30
|
type BooleanCallback<T> = (args: T) => boolean;
|
|
28
31
|
|
|
29
|
-
export const compose =
|
|
32
|
+
export const compose: (...fns: ((...any: any[]) => any)[]) => (x: any) => any =
|
|
30
33
|
(...fns: ((...any: any[]) => any)[]) =>
|
|
31
34
|
(x: any) =>
|
|
32
35
|
fns.reduce((res, fn) => fn(res), x);
|
|
33
|
-
export const pick =
|
|
36
|
+
export const pick: <T extends any>(key: keyof T) => (obj: T) => T[keyof T] =
|
|
34
37
|
<T extends any>(key: keyof T) =>
|
|
35
38
|
(obj: T) =>
|
|
36
39
|
obj[key];
|
|
37
|
-
export const isAccent = (str: string) => str.includes('accent');
|
|
38
|
-
export const isPressed = (str: string) => str.includes('pressed');
|
|
39
|
-
export const isHovered = (str: string) => str.includes('hovered');
|
|
40
|
-
export const not =
|
|
40
|
+
export const isAccent: (str: string) => boolean = (str: string) => str.includes('accent');
|
|
41
|
+
export const isPressed: (str: string) => boolean = (str: string) => str.includes('pressed');
|
|
42
|
+
export const isHovered: (str: string) => boolean = (str: string) => str.includes('hovered');
|
|
43
|
+
export const not: <T extends any>(cb: BooleanCallback<T>) => (val: T) => boolean =
|
|
41
44
|
<T extends any>(cb: BooleanCallback<T>) =>
|
|
42
45
|
(val: T) =>
|
|
43
46
|
!cb(val);
|
|
44
|
-
export const or =
|
|
47
|
+
export const or: <T extends any>(...fns: BooleanCallback<T>[]) => (val: T) => boolean =
|
|
45
48
|
<T extends any>(...fns: BooleanCallback<T>[]) =>
|
|
46
49
|
(val: T) =>
|
|
47
50
|
fns.some((fn) => fn(val));
|
|
48
|
-
export const capitalize
|
|
51
|
+
export const capitalize: (str: string) => string = (str: string) =>
|
|
52
|
+
str.charAt(0).toUpperCase() + str.slice(1);
|
|
49
53
|
|
|
50
|
-
export const generateTypeDefs
|
|
54
|
+
export const generateTypeDefs: (typedTokens: string[], tokenNames?: string[]) => string = (
|
|
55
|
+
typedTokens: string[],
|
|
56
|
+
tokenNames?: string[],
|
|
57
|
+
) => {
|
|
51
58
|
return typedTokens
|
|
52
59
|
.map((t, i) => {
|
|
53
60
|
return `'${Array.isArray(tokenNames) ? tokenNames[i] : t}': 'var(${tokens[t as keyof typeof tokens]})'`;
|