@atlaskit/code 15.1.2 → 15.2.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 +444 -183
- package/__perf__/source-code-examples/100-line-example.tsx +49 -40
- package/codemods/13.0.0-remove-unnecessary-code-props.tsx +61 -75
- package/codemods/13.0.0-rename-imports.tsx +214 -251
- package/codemods/14.0.0-lite-mode.tsx +5 -9
- package/codemods/__tests__/13.0.0-remove-unnecessary-code-props.tsx +43 -43
- package/codemods/__tests__/13.0.0-rename-imports.tsx +143 -143
- package/codemods/__tests__/14.0.0-lite-mode/14.0.0-lite-mode.tsx +35 -35
- package/codemods/__tests__/14.0.0-lite-mode/remove-language.tsx +21 -21
- package/codemods/__tests__/14.0.0-lite-mode/text-to-child.tsx +35 -35
- package/codemods/migrations/14.0.0-lite-mode/remove-language.tsx +1 -6
- package/codemods/migrations/14.0.0-lite-mode/text-to-child.tsx +53 -61
- package/codemods/utils/helpers.tsx +161 -201
- package/dist/cjs/internal/theme/styles.js +2 -1
- package/dist/es2019/internal/theme/styles.js +2 -1
- package/dist/esm/internal/theme/styles.js +2 -1
- package/dist/types/bidi-warning/ui/index.d.ts +1 -1
- package/dist/types/bidi-warning/ui/styled.d.ts +1 -1
- package/dist/types/extract-react-types/code-block.d.ts +16 -16
- package/dist/types/internal/hooks/use-highlight.d.ts +1 -1
- package/dist/types/internal/utils/get-normalized-language.d.ts +1 -1
- package/dist/types/syntax-highlighter/async.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/highlight.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/create-line.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/index.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
- package/dist/types/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
- package/dist/types/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
- package/dist/types/syntax-highlighter/types.d.ts +2 -2
- package/dist/types/types.d.ts +1 -1
- package/dist/types-ts4.5/bidi-warning/ui/index.d.ts +1 -1
- package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +1 -1
- package/dist/types-ts4.5/extract-react-types/code-block.d.ts +16 -16
- package/dist/types-ts4.5/internal/hooks/use-highlight.d.ts +1 -1
- package/dist/types-ts4.5/internal/utils/get-normalized-language.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/async.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/highlight.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/index.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/types.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/package.json +11 -11
- package/report.api.md +807 -807
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
// eslint-disable-file
|
|
2
2
|
export const hundredLineExample = `/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { CSSProperties, forwardRef } from 'react';
|
|
5
5
|
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { BackgroundColor, Box, Inline, xcss } from '@atlaskit/primitives';
|
|
9
9
|
import { N0, N500, N700, R400, Y300 } from '@atlaskit/theme/colors';
|
|
10
10
|
import { token } from '@atlaskit/tokens';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const CSS_VAR_TEXT_COLOR = '--banner-text-color';
|
|
13
|
+
|
|
14
|
+
const textStyles = css({
|
|
15
|
+
color: \`var(\${CSS_VAR_TEXT_COLOR})\`,
|
|
16
|
+
fontWeight: token('font.weight.medium', '500'),
|
|
17
|
+
lineHeight: token('font.lineHeight.300', '24px'),
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
textOverflow: 'ellipsis',
|
|
20
|
+
whiteSpace: 'nowrap',
|
|
14
21
|
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
15
22
|
'a, a:visited, a:hover, a:focus, a:active': {
|
|
16
23
|
color: 'currentColor',
|
|
@@ -18,10 +25,10 @@ const nestedLinkStyles = css({
|
|
|
18
25
|
},
|
|
19
26
|
});
|
|
20
27
|
|
|
21
|
-
const backgroundColors: Record<Appearance,
|
|
22
|
-
warning: 'warning.bold',
|
|
23
|
-
error: 'danger.bold',
|
|
24
|
-
announcement: 'neutral.bold',
|
|
28
|
+
const backgroundColors: Record<Appearance, BackgroundColor> = {
|
|
29
|
+
warning: 'color.background.warning.bold',
|
|
30
|
+
error: 'color.background.danger.bold',
|
|
31
|
+
announcement: 'color.background.neutral.bold',
|
|
25
32
|
};
|
|
26
33
|
|
|
27
34
|
const tokenBackgroundColors: Record<Appearance, string> = {
|
|
@@ -30,12 +37,6 @@ const tokenBackgroundColors: Record<Appearance, string> = {
|
|
|
30
37
|
announcement: token('color.background.neutral.bold', N500),
|
|
31
38
|
};
|
|
32
39
|
|
|
33
|
-
const textColors: Record<Appearance, TextProps['color']> = {
|
|
34
|
-
warning: 'warning.inverse',
|
|
35
|
-
error: 'inverse',
|
|
36
|
-
announcement: 'inverse',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
40
|
const tokenTextColors: Record<Appearance, string> = {
|
|
40
41
|
warning: token('color.text.warning.inverse', N700),
|
|
41
42
|
error: token('color.text.inverse', N0),
|
|
@@ -44,7 +45,19 @@ const tokenTextColors: Record<Appearance, string> = {
|
|
|
44
45
|
|
|
45
46
|
type Appearance = 'warning' | 'error' | 'announcement';
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
const containerStyles = xcss({
|
|
49
|
+
overflow: 'hidden',
|
|
50
|
+
maxHeight: 'size.500',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const iconWrapperStyles = xcss({
|
|
54
|
+
display: 'block',
|
|
55
|
+
width: 'size.200',
|
|
56
|
+
height: 'size.200', // This matches Icon's "medium" size, without this the (line-)height is greater than that of the Icon
|
|
57
|
+
flexShrink: '0',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export interface BannerProps {
|
|
48
61
|
appearance?: Appearance;
|
|
49
62
|
children?: React.ReactNode;
|
|
50
63
|
icon?: React.ReactElement;
|
|
@@ -56,42 +69,38 @@ const Banner = forwardRef<HTMLDivElement, BannerProps>(
|
|
|
56
69
|
const appearanceType =
|
|
57
70
|
appearance in backgroundColors ? appearance : 'warning';
|
|
58
71
|
|
|
59
|
-
const accessibilityProps = useMemo(() => {
|
|
60
|
-
const baseProps = {
|
|
61
|
-
role: 'alert',
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
if (appearance === 'announcement') {
|
|
65
|
-
return {
|
|
66
|
-
...baseProps,
|
|
67
|
-
'aria-label': 'announcement',
|
|
68
|
-
tabIndex: 0,
|
|
69
|
-
role: 'region',
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return baseProps;
|
|
74
|
-
}, [appearance]);
|
|
75
|
-
|
|
76
72
|
return (
|
|
77
|
-
<Box
|
|
78
|
-
|
|
73
|
+
<Box
|
|
74
|
+
xcss={containerStyles}
|
|
75
|
+
backgroundColor={backgroundColors[appearanceType]}
|
|
76
|
+
padding="space.150"
|
|
77
|
+
testId={testId}
|
|
78
|
+
ref={ref}
|
|
79
|
+
role="alert"
|
|
80
|
+
>
|
|
81
|
+
<Inline space="space.050" alignBlock="center" alignInline="start">
|
|
79
82
|
{icon ? (
|
|
80
83
|
<Box
|
|
81
84
|
as="span"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
height="size.300" // This matches Icon's "medium" size, without this the (line-)height is greater than that of the Icon
|
|
85
|
-
UNSAFE_style={{
|
|
85
|
+
xcss={iconWrapperStyles}
|
|
86
|
+
style={{
|
|
86
87
|
fill: tokenBackgroundColors[appearanceType],
|
|
87
88
|
color: tokenTextColors[appearanceType],
|
|
88
|
-
flexShrink: 0,
|
|
89
89
|
}}
|
|
90
90
|
>
|
|
91
91
|
{icon}
|
|
92
92
|
</Box>
|
|
93
93
|
) : null}
|
|
94
|
-
<
|
|
94
|
+
<span
|
|
95
|
+
style={
|
|
96
|
+
{
|
|
97
|
+
[CSS_VAR_TEXT_COLOR]: tokenTextColors[appearanceType],
|
|
98
|
+
} as CSSProperties
|
|
99
|
+
}
|
|
100
|
+
css={textStyles}
|
|
101
|
+
>
|
|
102
|
+
{children}
|
|
103
|
+
</span>
|
|
95
104
|
</Inline>
|
|
96
105
|
</Box>
|
|
97
106
|
);
|
|
@@ -1,98 +1,84 @@
|
|
|
1
|
-
import { API, FileInfo, JSCodeshift, Options } from 'jscodeshift';
|
|
2
|
-
import { Collection } from 'jscodeshift/src/Collection';
|
|
1
|
+
import { type API, type FileInfo, type JSCodeshift, type Options } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
getImportDeclarationCollection,
|
|
6
|
+
getImportSpecifierCollection,
|
|
7
|
+
getImportSpecifierName,
|
|
8
|
+
getJSXAttributesByName,
|
|
9
|
+
getJSXSpreadIdentifierAttributesByName,
|
|
10
|
+
getJSXSpreadObjectExpressionAttributesByName,
|
|
11
|
+
hasImportDeclaration,
|
|
12
12
|
} from './utils/helpers';
|
|
13
13
|
|
|
14
14
|
const importPath = '@atlaskit/code';
|
|
15
15
|
const importName = 'Code';
|
|
16
|
-
const propsToBeRemoved = [
|
|
17
|
-
'lineNumberContainerStyle',
|
|
18
|
-
'showLineNumbers',
|
|
19
|
-
'highlight',
|
|
20
|
-
];
|
|
16
|
+
const propsToBeRemoved = ['lineNumberContainerStyle', 'showLineNumbers', 'highlight'];
|
|
21
17
|
|
|
22
18
|
function removeProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
j: JSCodeshift,
|
|
20
|
+
collection: Collection<any>,
|
|
21
|
+
elementName: string,
|
|
22
|
+
propName: string,
|
|
27
23
|
) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
if (jsxAttributeCollection) {
|
|
35
|
-
jsxAttributeCollection.remove();
|
|
36
|
-
}
|
|
24
|
+
collection.findJSXElements(elementName).forEach((jsxElementPath) => {
|
|
25
|
+
const jsxAttributeCollection = getJSXAttributesByName(j, jsxElementPath, propName);
|
|
26
|
+
if (jsxAttributeCollection) {
|
|
27
|
+
jsxAttributeCollection.remove();
|
|
28
|
+
}
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
30
|
+
const jsxSpreadIdentifierPropertyCollection = getJSXSpreadIdentifierAttributesByName(
|
|
31
|
+
j,
|
|
32
|
+
collection,
|
|
33
|
+
jsxElementPath,
|
|
34
|
+
propName,
|
|
35
|
+
);
|
|
36
|
+
if (jsxSpreadIdentifierPropertyCollection) {
|
|
37
|
+
jsxSpreadIdentifierPropertyCollection.remove();
|
|
38
|
+
}
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
const jsxSpreadExpressionPropertyCollection = getJSXSpreadObjectExpressionAttributesByName(
|
|
41
|
+
j,
|
|
42
|
+
jsxElementPath,
|
|
43
|
+
propName,
|
|
44
|
+
);
|
|
45
|
+
if (jsxSpreadExpressionPropertyCollection) {
|
|
46
|
+
jsxSpreadExpressionPropertyCollection.remove();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
function removePropsForImportSpecifiers(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
j: JSCodeshift,
|
|
53
|
+
collection: Collection<any>,
|
|
54
|
+
propName: string,
|
|
61
55
|
) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
importDeclarationCollection,
|
|
70
|
-
importName,
|
|
71
|
-
);
|
|
72
|
-
const importSpecifierName = getImportSpecifierName(importSpecifierCollection);
|
|
56
|
+
const importDeclarationCollection = getImportDeclarationCollection(j, collection, importPath);
|
|
57
|
+
const importSpecifierCollection = getImportSpecifierCollection(
|
|
58
|
+
j,
|
|
59
|
+
importDeclarationCollection,
|
|
60
|
+
importName,
|
|
61
|
+
);
|
|
62
|
+
const importSpecifierName = getImportSpecifierName(importSpecifierCollection);
|
|
73
63
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
if (importSpecifierName === null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
removeProps(j, collection, importSpecifierName, propName);
|
|
79
69
|
}
|
|
80
70
|
|
|
81
|
-
export default function transformer(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
options: Options,
|
|
85
|
-
) {
|
|
86
|
-
const { source } = fileInfo;
|
|
87
|
-
const collection = j(source);
|
|
71
|
+
export default function transformer(fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) {
|
|
72
|
+
const { source } = fileInfo;
|
|
73
|
+
const collection = j(source);
|
|
88
74
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
if (!hasImportDeclaration(j, collection, importPath)) {
|
|
76
|
+
return source;
|
|
77
|
+
}
|
|
92
78
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
propsToBeRemoved.forEach((propToRemove) => {
|
|
80
|
+
removePropsForImportSpecifiers(j, collection, propToRemove);
|
|
81
|
+
});
|
|
96
82
|
|
|
97
|
-
|
|
83
|
+
return collection.toSource(options.printOptions || { quote: 'single' });
|
|
98
84
|
}
|