@atlaskit/radio 8.4.6 → 8.5.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 +24 -0
- package/codemods/add-comment-before.tsx +40 -0
- package/codemods/add-comment-to-start-of-file.tsx +20 -0
- package/codemods/add-to-import.tsx +32 -0
- package/codemods/create-remove-func-for.tsx +44 -0
- package/codemods/create-remove-imports-for.tsx +83 -0
- package/codemods/create-rename-func-for.tsx +26 -0
- package/codemods/create-rename-import-for.tsx +97 -0
- package/codemods/create-transformer.tsx +23 -0
- package/codemods/find-identifier-and-replace-attribute.tsx +27 -0
- package/codemods/get-jsx-attributes-by-name.tsx +18 -0
- package/codemods/get-named-specifier.tsx +24 -0
- package/codemods/has-import-declaration.tsx +12 -0
- package/codemods/has-variable-assignment.tsx +18 -0
- package/codemods/migrations/migrate-radio-aria-labelledby.tsx +6 -0
- package/codemods/migrations/migrate-radio-group-aria-labelledby.tsx +6 -0
- package/codemods/not-yet-migrate-aria-labelledby.tsx +3 -5
- package/codemods/try-create-import.tsx +27 -0
- package/codemods/types.tsx +1 -0
- package/dist/cjs/radio.compiled.css +3 -43
- package/dist/cjs/radio.js +3 -11
- package/dist/es2019/radio.compiled.css +3 -43
- package/dist/es2019/radio.js +3 -11
- package/dist/esm/radio.compiled.css +3 -43
- package/dist/esm/radio.js +3 -11
- package/package.json +10 -6
- package/codemods/migrations/migrate-aria-labelledby.tsx +0 -11
- package/codemods/utils.tsx +0 -479
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/radio
|
|
2
2
|
|
|
3
|
+
## 8.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e1feac98875c6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e1feac98875c6) -
|
|
8
|
+
Internal only CSS refactor to eliminate nested CSS selectors in favor of an atomic-friendly
|
|
9
|
+
styling approach. This change was previously behind the `platform-radio-atomic-styles` feature
|
|
10
|
+
gate, which has now been removed.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`02483200273ec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/02483200273ec) -
|
|
15
|
+
Enrol all Design System UI packages into the React Compiler with platform gating via
|
|
16
|
+
isReactCompilerActivePlatform.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 8.4.7
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`e2085d35701ca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e2085d35701ca) -
|
|
24
|
+
Internal changes to remove unnecessary token fallbacks and imports from `@atlaskit/theme`
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 8.4.6
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ASTPath, type ImportDeclaration, type JSCodeshift, type Program } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
// not replacing newlines (which \s does)
|
|
5
|
+
const spacesAndTabs: RegExp = /[ \t]{2,}/g;
|
|
6
|
+
const lineStartWithSpaces: RegExp = /^[ \t]*/gm;
|
|
7
|
+
|
|
8
|
+
function clean(value: string): string {
|
|
9
|
+
return (
|
|
10
|
+
value
|
|
11
|
+
.replace(spacesAndTabs, ' ')
|
|
12
|
+
.replace(lineStartWithSpaces, '')
|
|
13
|
+
// using .trim() to clear the any newlines before the first text and after last text
|
|
14
|
+
.trim()
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function addCommentBefore({
|
|
19
|
+
j,
|
|
20
|
+
target,
|
|
21
|
+
message,
|
|
22
|
+
}: {
|
|
23
|
+
j: JSCodeshift;
|
|
24
|
+
target: Collection<Program> | Collection<ImportDeclaration>;
|
|
25
|
+
message: string;
|
|
26
|
+
}): void {
|
|
27
|
+
const content: string = ` TODO: (from codemod) ${clean(message)} `;
|
|
28
|
+
target.forEach((path: ASTPath<Program | ImportDeclaration>) => {
|
|
29
|
+
path.value.comments = path.value.comments || [];
|
|
30
|
+
|
|
31
|
+
const exists = path.value.comments.find((comment) => comment.value === content);
|
|
32
|
+
|
|
33
|
+
// avoiding duplicates of the same comment
|
|
34
|
+
if (exists) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
path.value.comments.push(j.commentBlock(content));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
import { addCommentBefore } from './add-comment-before';
|
|
5
|
+
|
|
6
|
+
export function addCommentToStartOfFile({
|
|
7
|
+
j,
|
|
8
|
+
base,
|
|
9
|
+
message,
|
|
10
|
+
}: {
|
|
11
|
+
j: JSCodeshift;
|
|
12
|
+
base: Collection<Node>;
|
|
13
|
+
message: string;
|
|
14
|
+
}): void {
|
|
15
|
+
addCommentBefore({
|
|
16
|
+
j,
|
|
17
|
+
target: base.find(j.Program),
|
|
18
|
+
message,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ImportDefaultSpecifier, type ImportSpecifier, type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
export function addToImport({
|
|
5
|
+
j,
|
|
6
|
+
base,
|
|
7
|
+
importSpecifier,
|
|
8
|
+
packageName,
|
|
9
|
+
}: {
|
|
10
|
+
j: JSCodeshift;
|
|
11
|
+
base: Collection<any>;
|
|
12
|
+
importSpecifier: ImportSpecifier | ImportDefaultSpecifier;
|
|
13
|
+
packageName: string;
|
|
14
|
+
}): void {
|
|
15
|
+
base
|
|
16
|
+
.find(j.ImportDeclaration)
|
|
17
|
+
.filter((path) => path.value.source.value === packageName)
|
|
18
|
+
.replaceWith((declaration) => {
|
|
19
|
+
return j.importDeclaration(
|
|
20
|
+
[
|
|
21
|
+
// we are appending to the existing specifiers
|
|
22
|
+
// We are doing a filter hear because sometimes specifiers can be removed
|
|
23
|
+
// but they hand around in the declaration
|
|
24
|
+
...(declaration.value.specifiers || []).filter(
|
|
25
|
+
(item) => item.type === 'ImportSpecifier' && item.imported != null,
|
|
26
|
+
),
|
|
27
|
+
importSpecifier,
|
|
28
|
+
],
|
|
29
|
+
j.literal(packageName),
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ASTPath, type ImportDeclaration, type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
import { addCommentToStartOfFile } from './add-comment-to-start-of-file';
|
|
5
|
+
import { getJSXAttributesByName } from './get-jsx-attributes-by-name';
|
|
6
|
+
import { getNamedSpecifier } from './get-named-specifier';
|
|
7
|
+
|
|
8
|
+
function getDefaultSpecifier(j: JSCodeshift, source: ReturnType<typeof j>, specifier: string) {
|
|
9
|
+
const specifiers = source
|
|
10
|
+
.find(j.ImportDeclaration)
|
|
11
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
|
|
12
|
+
.find(j.ImportDefaultSpecifier);
|
|
13
|
+
|
|
14
|
+
if (!specifiers.length) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return specifiers.nodes()[0]!.local!.name;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const createRemoveFuncFor: (
|
|
21
|
+
component: string,
|
|
22
|
+
importName: string,
|
|
23
|
+
prop: string,
|
|
24
|
+
comment?: string,
|
|
25
|
+
) => (j: JSCodeshift, source: Collection<Node>) => void =
|
|
26
|
+
(component: string, importName: string, prop: string, comment?: string) =>
|
|
27
|
+
(j: JSCodeshift, source: Collection<Node>) => {
|
|
28
|
+
const specifier =
|
|
29
|
+
getNamedSpecifier(j, source, component, importName) ||
|
|
30
|
+
getDefaultSpecifier(j, source, component);
|
|
31
|
+
|
|
32
|
+
if (!specifier) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
source.findJSXElements(specifier).forEach((element) => {
|
|
37
|
+
getJSXAttributesByName(j, element, prop).forEach((attribute) => {
|
|
38
|
+
j(attribute).remove();
|
|
39
|
+
if (comment) {
|
|
40
|
+
addCommentToStartOfFile({ j, base: source, message: comment });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
import { addCommentToStartOfFile } from './add-comment-to-start-of-file';
|
|
5
|
+
import { type Nullable } from './types';
|
|
6
|
+
|
|
7
|
+
export const createRemoveImportsFor: ({
|
|
8
|
+
importsToRemove,
|
|
9
|
+
packagePath,
|
|
10
|
+
comment,
|
|
11
|
+
}: {
|
|
12
|
+
importsToRemove: string[];
|
|
13
|
+
packagePath: string;
|
|
14
|
+
comment: string;
|
|
15
|
+
}) => (j: JSCodeshift, source: Collection<Node>) => void =
|
|
16
|
+
({
|
|
17
|
+
importsToRemove,
|
|
18
|
+
packagePath,
|
|
19
|
+
comment,
|
|
20
|
+
}: {
|
|
21
|
+
importsToRemove: string[];
|
|
22
|
+
packagePath: string;
|
|
23
|
+
comment: string;
|
|
24
|
+
}) =>
|
|
25
|
+
(j: JSCodeshift, source: Collection<Node>) => {
|
|
26
|
+
const isUsingName: boolean =
|
|
27
|
+
source.find(j.ImportDeclaration).filter((path) => path.node.source.value === packagePath)
|
|
28
|
+
.length > 0;
|
|
29
|
+
if (!isUsingName) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const existingAlias: Nullable<string> =
|
|
34
|
+
source
|
|
35
|
+
.find(j.ImportDeclaration)
|
|
36
|
+
.filter((path) => path.node.source.value === packagePath)
|
|
37
|
+
.find(j.ImportSpecifier)
|
|
38
|
+
.nodes()
|
|
39
|
+
.map((specifier): Nullable<string> => {
|
|
40
|
+
if (!importsToRemove.includes(specifier.imported.name)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
// If aliased: return the alias
|
|
44
|
+
if (specifier.local && !importsToRemove.includes(specifier.local.name)) {
|
|
45
|
+
return specifier.local.name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return null;
|
|
49
|
+
})
|
|
50
|
+
.filter(Boolean)[0] || null;
|
|
51
|
+
|
|
52
|
+
// Remove imports
|
|
53
|
+
source
|
|
54
|
+
.find(j.ImportDeclaration)
|
|
55
|
+
.filter((path) => path.node.source.value === packagePath)
|
|
56
|
+
.find(j.ImportSpecifier)
|
|
57
|
+
.find(j.Identifier)
|
|
58
|
+
.filter((identifier) => {
|
|
59
|
+
if (
|
|
60
|
+
importsToRemove.includes(identifier.value.name) ||
|
|
61
|
+
identifier.value.name === existingAlias
|
|
62
|
+
) {
|
|
63
|
+
addCommentToStartOfFile({ j, base: source, message: comment });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
})
|
|
68
|
+
.remove();
|
|
69
|
+
|
|
70
|
+
// Remove entire import if it is empty
|
|
71
|
+
const isEmptyImport =
|
|
72
|
+
source
|
|
73
|
+
.find(j.ImportDeclaration)
|
|
74
|
+
.filter((path) => path.node.source.value === packagePath)
|
|
75
|
+
.find(j.ImportSpecifier)
|
|
76
|
+
.find(j.Identifier).length === 0;
|
|
77
|
+
if (isEmptyImport) {
|
|
78
|
+
source
|
|
79
|
+
.find(j.ImportDeclaration)
|
|
80
|
+
.filter((path) => path.node.source.value === packagePath)
|
|
81
|
+
.remove();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
import { getJSXAttributesByName } from './get-jsx-attributes-by-name';
|
|
5
|
+
import { getNamedSpecifier } from './get-named-specifier';
|
|
6
|
+
|
|
7
|
+
export const createRenameFuncFor: (
|
|
8
|
+
component: string,
|
|
9
|
+
importName: string,
|
|
10
|
+
from: string,
|
|
11
|
+
to: string,
|
|
12
|
+
) => (j: JSCodeshift, source: Collection<Node>) => void =
|
|
13
|
+
(component: string, importName: string, from: string, to: string) =>
|
|
14
|
+
(j: JSCodeshift, source: Collection<Node>) => {
|
|
15
|
+
const specifier = getNamedSpecifier(j, source, component, importName);
|
|
16
|
+
|
|
17
|
+
if (!specifier) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
source.findJSXElements(specifier).forEach((element) => {
|
|
22
|
+
getJSXAttributesByName(j, element, from).forEach((attribute) => {
|
|
23
|
+
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(to), attribute.node.value));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type ImportDefaultSpecifier, type ImportSpecifier, type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
import { addToImport } from './add-to-import';
|
|
5
|
+
import { tryCreateImport } from './try-create-import';
|
|
6
|
+
import { type Nullable } from './types';
|
|
7
|
+
|
|
8
|
+
export const createRenameImportFor: ({
|
|
9
|
+
componentName,
|
|
10
|
+
newComponentName,
|
|
11
|
+
oldPackagePath,
|
|
12
|
+
newPackagePath,
|
|
13
|
+
}: {
|
|
14
|
+
componentName: string;
|
|
15
|
+
newComponentName?: string;
|
|
16
|
+
oldPackagePath: string;
|
|
17
|
+
newPackagePath: string;
|
|
18
|
+
}) => (j: JSCodeshift, source: Collection<Node>) => void =
|
|
19
|
+
({
|
|
20
|
+
componentName,
|
|
21
|
+
newComponentName,
|
|
22
|
+
oldPackagePath,
|
|
23
|
+
newPackagePath,
|
|
24
|
+
}: {
|
|
25
|
+
componentName: string;
|
|
26
|
+
newComponentName?: string;
|
|
27
|
+
oldPackagePath: string;
|
|
28
|
+
newPackagePath: string;
|
|
29
|
+
}) =>
|
|
30
|
+
(j: JSCodeshift, source: Collection<Node>) => {
|
|
31
|
+
const isUsingName: boolean =
|
|
32
|
+
source
|
|
33
|
+
.find(j.ImportDeclaration)
|
|
34
|
+
.filter((path) => path.node.source.value === oldPackagePath)
|
|
35
|
+
.find(j.ImportSpecifier)
|
|
36
|
+
.nodes()
|
|
37
|
+
.filter((specifier) => specifier.imported && specifier.imported.name === componentName)
|
|
38
|
+
.length > 0;
|
|
39
|
+
if (!isUsingName) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const existingAlias: Nullable<string> =
|
|
44
|
+
source
|
|
45
|
+
.find(j.ImportDeclaration)
|
|
46
|
+
.filter((path) => path.node.source.value === oldPackagePath)
|
|
47
|
+
.find(j.ImportSpecifier)
|
|
48
|
+
.nodes()
|
|
49
|
+
.map((specifier): Nullable<string> => {
|
|
50
|
+
if (specifier.imported && specifier.imported.name !== componentName) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
// If aliased: return the alias
|
|
54
|
+
if (specifier.local && specifier.local.name !== componentName) {
|
|
55
|
+
return specifier.local.name;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return null;
|
|
59
|
+
})
|
|
60
|
+
.filter(Boolean)[0] || null;
|
|
61
|
+
|
|
62
|
+
// Check to see if need to create new package path
|
|
63
|
+
// Try create an import declaration just before the old import
|
|
64
|
+
tryCreateImport({
|
|
65
|
+
j,
|
|
66
|
+
base: source,
|
|
67
|
+
relativeToPackage: oldPackagePath,
|
|
68
|
+
packageName: newPackagePath,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const newSpecifier: ImportSpecifier | ImportDefaultSpecifier = (() => {
|
|
72
|
+
// If there's a new name use that
|
|
73
|
+
if (newComponentName) {
|
|
74
|
+
return j.importSpecifier(j.identifier(newComponentName), j.identifier(newComponentName));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (existingAlias) {
|
|
78
|
+
return j.importSpecifier(j.identifier(componentName), j.identifier(existingAlias));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Add specifier
|
|
82
|
+
return j.importSpecifier(j.identifier(componentName), j.identifier(componentName));
|
|
83
|
+
})();
|
|
84
|
+
|
|
85
|
+
addToImport({
|
|
86
|
+
j,
|
|
87
|
+
base: source,
|
|
88
|
+
importSpecifier: newSpecifier,
|
|
89
|
+
packageName: newPackagePath,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Remove old path
|
|
93
|
+
source
|
|
94
|
+
.find(j.ImportDeclaration)
|
|
95
|
+
.filter((path) => path.node.source.value === oldPackagePath)
|
|
96
|
+
.remove();
|
|
97
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type API, type FileInfo, type JSCodeshift, type Options } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
import { hasImportDeclaration } from './has-import-declaration';
|
|
5
|
+
|
|
6
|
+
export const createTransformer: (
|
|
7
|
+
component: string,
|
|
8
|
+
migrates: {
|
|
9
|
+
(j: JSCodeshift, source: Collection<Node>): void;
|
|
10
|
+
}[],
|
|
11
|
+
) => (fileInfo: FileInfo, api: API, options: Options) => string =
|
|
12
|
+
(component: string, migrates: { (j: JSCodeshift, source: Collection<Node>): void }[]) =>
|
|
13
|
+
(fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => {
|
|
14
|
+
const source: Collection<Node> = j(fileInfo.source);
|
|
15
|
+
|
|
16
|
+
if (!hasImportDeclaration(j, source, component)) {
|
|
17
|
+
return fileInfo.source;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
migrates.forEach((tf) => tf(j, source));
|
|
21
|
+
|
|
22
|
+
return source.toSource(options.printOptions || { quote: 'single' });
|
|
23
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
|
|
3
|
+
export function findIdentifierAndReplaceAttribute(
|
|
4
|
+
j: JSCodeshift,
|
|
5
|
+
source: ReturnType<typeof j>,
|
|
6
|
+
identifierName: string,
|
|
7
|
+
searchAttr: string,
|
|
8
|
+
replaceWithAttr: string,
|
|
9
|
+
): void {
|
|
10
|
+
source
|
|
11
|
+
.find(j.JSXElement)
|
|
12
|
+
.find(j.JSXOpeningElement)
|
|
13
|
+
.filter((path) => {
|
|
14
|
+
return !!j(path.node)
|
|
15
|
+
.find(j.JSXIdentifier)
|
|
16
|
+
.filter((identifier) => identifier.value.name === identifierName);
|
|
17
|
+
})
|
|
18
|
+
.forEach((element) => {
|
|
19
|
+
j(element)
|
|
20
|
+
.find(j.JSXAttribute)
|
|
21
|
+
.find(j.JSXIdentifier)
|
|
22
|
+
.filter((attr) => attr.node.name === searchAttr)
|
|
23
|
+
.forEach((attribute) => {
|
|
24
|
+
j(attribute).replaceWith(j.jsxIdentifier(replaceWithAttr));
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ASTPath, type JSCodeshift, type JSXAttribute } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
export function getJSXAttributesByName(
|
|
5
|
+
j: JSCodeshift,
|
|
6
|
+
element: ASTPath<any>,
|
|
7
|
+
attributeName: string,
|
|
8
|
+
): Collection<JSXAttribute> {
|
|
9
|
+
return j(element)
|
|
10
|
+
.find(j.JSXOpeningElement)
|
|
11
|
+
.find(j.JSXAttribute)
|
|
12
|
+
.filter((attribute) => {
|
|
13
|
+
const matches = j(attribute)
|
|
14
|
+
.find(j.JSXIdentifier)
|
|
15
|
+
.filter((identifier) => identifier.value.name === attributeName);
|
|
16
|
+
return Boolean(matches.length);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ASTPath,
|
|
3
|
+
type ImportDeclaration,
|
|
4
|
+
type ImportSpecifier,
|
|
5
|
+
type JSCodeshift,
|
|
6
|
+
} from 'jscodeshift';
|
|
7
|
+
|
|
8
|
+
export function getNamedSpecifier(
|
|
9
|
+
j: JSCodeshift,
|
|
10
|
+
source: any,
|
|
11
|
+
specifier: string,
|
|
12
|
+
importName: string,
|
|
13
|
+
): any {
|
|
14
|
+
const specifiers = source
|
|
15
|
+
.find(j.ImportDeclaration)
|
|
16
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
|
|
17
|
+
.find(j.ImportSpecifier)
|
|
18
|
+
.filter((path: ASTPath<ImportSpecifier>) => path.node.imported.name === importName);
|
|
19
|
+
|
|
20
|
+
if (!specifiers.length) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return specifiers.nodes()[0]!.local!.name;
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ASTPath, type ImportDeclaration, type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
|
|
3
|
+
export function hasImportDeclaration(j: JSCodeshift, source: any, importPath: string): boolean {
|
|
4
|
+
const imports = source
|
|
5
|
+
.find(j.ImportDeclaration)
|
|
6
|
+
.filter(
|
|
7
|
+
(path: ASTPath<ImportDeclaration>) =>
|
|
8
|
+
typeof path.node.source.value === 'string' && path.node.source.value.startsWith(importPath),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
return Boolean(imports.length);
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type JSCodeshift, type VariableDeclaration } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
export function hasVariableAssignment(
|
|
5
|
+
j: JSCodeshift,
|
|
6
|
+
source: ReturnType<typeof j>,
|
|
7
|
+
identifierName: string,
|
|
8
|
+
): Collection<VariableDeclaration> | boolean {
|
|
9
|
+
const occurance = source.find(j.VariableDeclaration).filter((path) => {
|
|
10
|
+
return !!j(path.node)
|
|
11
|
+
.find(j.VariableDeclarator)
|
|
12
|
+
.find(j.Identifier)
|
|
13
|
+
.filter((identifier) => {
|
|
14
|
+
return identifier.node.name === identifierName;
|
|
15
|
+
}).length;
|
|
16
|
+
});
|
|
17
|
+
return !!occurance.length ? occurance : false;
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRenameFuncFor } from '../create-rename-func-for';
|
|
2
|
+
|
|
3
|
+
export const migrateRadioAriaLabelledby: (
|
|
4
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
5
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
6
|
+
) => void = createRenameFuncFor('@atlaskit/radio', 'Radio', 'aria-labelledby', 'labelId');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRenameFuncFor } from '../create-rename-func-for';
|
|
2
|
+
|
|
3
|
+
export const migrateRadioGroupAriaLabelledby: (
|
|
4
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
5
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
6
|
+
) => void = createRenameFuncFor('@atlaskit/radio', 'RadioGroup', 'aria-labelledby', 'labelId');
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { API, FileInfo, Options } from 'jscodeshift';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from './migrations/migrate-aria-labelledby';
|
|
7
|
-
import { createTransformer } from './utils';
|
|
3
|
+
import { createTransformer } from './create-transformer';
|
|
4
|
+
import { migrateRadioAriaLabelledby } from './migrations/migrate-radio-aria-labelledby';
|
|
5
|
+
import { migrateRadioGroupAriaLabelledby } from './migrations/migrate-radio-group-aria-labelledby';
|
|
8
6
|
|
|
9
7
|
const transformer: (fileInfo: FileInfo, { jscodeshift }: API, options: Options) => string =
|
|
10
8
|
createTransformer('@atlaskit/radio', [
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type JSCodeshift } from 'jscodeshift';
|
|
2
|
+
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
|
|
4
|
+
export function tryCreateImport({
|
|
5
|
+
j,
|
|
6
|
+
base,
|
|
7
|
+
relativeToPackage,
|
|
8
|
+
packageName,
|
|
9
|
+
}: {
|
|
10
|
+
j: JSCodeshift;
|
|
11
|
+
base: Collection<any>;
|
|
12
|
+
relativeToPackage: string;
|
|
13
|
+
packageName: string;
|
|
14
|
+
}): void {
|
|
15
|
+
const exists: boolean =
|
|
16
|
+
base.find(j.ImportDeclaration).filter((path) => path.value.source.value === packageName)
|
|
17
|
+
.length > 0;
|
|
18
|
+
|
|
19
|
+
if (exists) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
base
|
|
24
|
+
.find(j.ImportDeclaration)
|
|
25
|
+
.filter((path) => path.value.source.value === relativeToPackage)
|
|
26
|
+
.insertBefore(j.importDeclaration([], j.literal(packageName)));
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Nullable<T> = T | null;
|
|
@@ -14,15 +14,10 @@
|
|
|
14
14
|
._12ji1r31{outline-color:currentColor}
|
|
15
15
|
._12y31o36{outline-width:medium}
|
|
16
16
|
._13diglyw{-moz-appearance:none}
|
|
17
|
-
._17a1bk0g:disabled[data-invalid]{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
18
17
|
._18postnw:after{position:absolute}
|
|
19
|
-
._19ybs4qr:checked[data-invalid]{--radio-border-color:var(--ds-icon-danger,#c9372c)}
|
|
20
18
|
._1bah1h6o{justify-content:center}
|
|
21
19
|
._1bsb1tcg{width:24px}
|
|
22
|
-
._1d7ps4qr[data-invalid]{--radio-border-color:var(--ds-icon-danger,#c9372c)}
|
|
23
20
|
._1e0c1txw{display:flex}
|
|
24
|
-
._1el2by5v:disabled[data-invalid]{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
25
|
-
._1if1bk0g:disabled:checked{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
26
21
|
._1o9zidpf{flex-shrink:0}
|
|
27
22
|
._1peq1xmd:after{opacity:var(--radio-dot-opacity)}
|
|
28
23
|
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
@@ -32,26 +27,17 @@
|
|
|
32
27
|
._1qu2glyw{outline-style:none}
|
|
33
28
|
._1s6w2sac{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
34
29
|
._1s6w5w2r{--radio-dot-color:var(--ds-icon-inverse,#fff)}
|
|
35
|
-
._2kbkby5v:disabled:checked{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
36
30
|
._4cvr1h6o{align-items:center}
|
|
37
31
|
._4cvr1y6m{align-items:flex-start}
|
|
38
|
-
._4fps13gf:disabled:checked{cursor:not-allowed}
|
|
39
|
-
._4ryaby5v:disabled{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
40
32
|
._4t3i1tcg{height:24px}
|
|
41
|
-
._6hp813gf:disabled[data-invalid]{cursor:not-allowed}
|
|
42
33
|
._80om13gf{cursor:not-allowed}
|
|
43
34
|
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
44
35
|
._aetrb3bt:after{content:""}
|
|
45
36
|
._bfhk4t47{background-color:var(--radio-background-color)}
|
|
46
37
|
._bozg1b66{padding-inline-start:var(--ds-space-050,4px)}
|
|
47
38
|
._f3ett94y:checked{--radio-dot-opacity:1px}
|
|
48
|
-
._g7st13gf[data-disabled]{cursor:not-allowed}
|
|
49
39
|
._iosijmqp:checked{--radio-background-color:var(--ds-background-selected-bold,#1868db)}
|
|
50
|
-
._j5dh13gf:disabled{cursor:not-allowed}
|
|
51
40
|
._kqswh2mm{position:relative}
|
|
52
|
-
._lekrbk0g:disabled{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
53
|
-
._mqf81gmx[data-disabled]{color:var(--ds-text-disabled,#080f214a)}
|
|
54
|
-
._pmm42sac:disabled[data-invalid]{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
55
41
|
._s7n4jp4b{vertical-align:top}
|
|
56
42
|
._syaz1gmx{color:var(--ds-text-disabled,#080f214a)}
|
|
57
43
|
._syazi7uo{color:var(--ds-text,#292a2e)}
|
|
@@ -59,44 +45,18 @@
|
|
|
59
45
|
._tqbwidpf{--radio-dot-opacity:0}
|
|
60
46
|
._tqbwt94y{--radio-dot-opacity:1px}
|
|
61
47
|
._vchhusvi{box-sizing:border-box}
|
|
62
|
-
._wml02sac:disabled:checked{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
63
48
|
._wstuglyw{-webkit-appearance:none}
|
|
64
|
-
._x48a2sac:disabled{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
65
49
|
._y4ti1b66{padding-inline-end:var(--ds-space-050,4px)}
|
|
66
50
|
._z0ai120g:after{width:.6pc}
|
|
67
|
-
.
|
|
68
|
-
.
|
|
51
|
+
._6tjkdfik:checked:focus{outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
52
|
+
._y2mvdfik:focus{outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
69
53
|
._1bg41l7b:focus{outline-offset:3px}
|
|
70
|
-
._1c6f2sac:disabled:checked:focus{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
71
|
-
._1f8cbk0g:disabled:focus{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
72
|
-
._1gcs13gf:disabled:focus{cursor:not-allowed}
|
|
73
|
-
._1yk92sac:disabled:focus{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
74
|
-
._92nabk0g:disabled:checked:focus{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
75
54
|
._awqn1l7b:checked:focus{outline-offset:3px}
|
|
76
|
-
._n8t0by5v:disabled:checked:focus{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
77
|
-
._nxi6by5v:disabled:focus{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
78
|
-
._qep213gf:disabled:checked:focus{cursor:not-allowed}
|
|
79
|
-
._180n13gf:disabled:checked:hover{cursor:not-allowed}
|
|
80
55
|
._1iwz1q28:checked:hover{--radio-border-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
81
|
-
._1o5rby5v:disabled:checked:hover{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
82
56
|
._1p9jrsbi:hover{--radio-border-color:var(--ds-border-input,#8c8f97)}
|
|
83
57
|
._1rvql4ek:hover{--radio-background-color:var(--ds-background-input-hovered,#f8f8f8)}
|
|
84
|
-
._1x1a13gf:disabled:hover{cursor:not-allowed}
|
|
85
|
-
._awurbk0g:disabled:checked:hover{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
86
|
-
._gdmb2sac:disabled:hover{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
87
|
-
._neoeby5v:disabled:hover{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
88
|
-
._qftt2sac:disabled:checked:hover{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
89
|
-
._s2ftbk0g:disabled:hover{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
90
58
|
._x2tz1q28:checked:hover{--radio-background-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
91
|
-
._11v7bk0g:disabled:active{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
92
59
|
._1dvdrsbi:checked:active{--radio-border-color:var(--ds-border-input,#8c8f97)}
|
|
93
|
-
._1ib22sac:disabled:active{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
94
|
-
._5ry313gf:disabled:checked:active{cursor:not-allowed}
|
|
95
60
|
._60ak5w2r:checked:active{--radio-dot-color:var(--ds-icon-inverse,#fff)}
|
|
96
|
-
._6cyrby5v:disabled:checked:active{--radio-background-color:var(--ds-background-disabled,#17171708)}
|
|
97
|
-
._bl0ebk0g:disabled:checked:active{--radio-border-color:var(--ds-border-disabled,#0515240f)}
|
|
98
61
|
._jcko12kk:checked:active{--radio-background-color:var(--ds-background-selected-bold-pressed,#123263)}
|
|
99
|
-
.
|
|
100
|
-
._scgf13gf:disabled:active{cursor:not-allowed}
|
|
101
|
-
._sj8yr01l:active{--radio-background-color:var(--ds-background-input-pressed,#fff)}
|
|
102
|
-
._tusm2sac:disabled:checked:active{--radio-dot-color:var(--ds-icon-disabled,#080f214a)}
|
|
62
|
+
._sj8yr01l:active{--radio-background-color:var(--ds-background-input-pressed,#fff)}
|