@atlaskit/inline-edit 13.4.1 → 13.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 +14 -1
- package/README.md +2 -1
- package/__perf__/default.tsx +10 -10
- package/__perf__/inline-edit.tsx +31 -36
- package/__perf__/inline-text-field.tsx +9 -9
- package/codemods/12.0.0-lite-mode.ts +4 -4
- package/codemods/__tests__/12.0.0-lite-mode.tsx +21 -21
- package/codemods/__tests__/add-comments-when-validate-found.ts +14 -14
- package/codemods/__tests__/lift-InlineEditStateless-to-default.ts +35 -35
- package/codemods/__tests__/lift-InlineEditableTextField-to-its-entry-point.tsx +21 -21
- package/codemods/__tests__/spread-errorMessage-out-of-fieldProps.tsx +28 -28
- package/codemods/migrates/add-comments-when-validate-found.ts +13 -23
- package/codemods/migrates/lift-InlineEditStateless-to-default.ts +43 -57
- package/codemods/migrates/lift-InlineEditableTextField-to-its-entry-point.ts +29 -42
- package/codemods/migrates/spread-errorMessage-out-of-fieldProps.ts +45 -63
- package/codemods/migrates/utils.ts +62 -70
- package/dist/cjs/inline-edit.js +4 -2
- package/dist/cjs/inline-editable-textfield.js +8 -1
- package/dist/cjs/internal/buttons.js +10 -3
- package/dist/cjs/internal/read-view.js +6 -0
- package/dist/es2019/inline-edit.js +6 -1
- package/dist/es2019/inline-editable-textfield.js +9 -1
- package/dist/es2019/internal/buttons.js +9 -3
- package/dist/es2019/internal/read-view.js +6 -0
- package/dist/esm/inline-edit.js +6 -1
- package/dist/esm/inline-editable-textfield.js +9 -1
- package/dist/esm/internal/buttons.js +9 -3
- package/dist/esm/internal/read-view.js +6 -0
- package/dist/types/internal/buttons.d.ts +3 -0
- package/dist/types/internal/read-view.d.ts +3 -0
- package/dist/types/types.d.ts +2 -2
- package/dist/types-ts4.5/internal/buttons.d.ts +3 -0
- package/dist/types-ts4.5/internal/read-view.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +2 -2
- package/extract-react-types/inline-editable-textfield-props.tsx +2 -4
- package/package.json +109 -109
- package/report.api.md +32 -37
|
@@ -8,10 +8,10 @@ jest.autoMockOff();
|
|
|
8
8
|
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
9
9
|
|
|
10
10
|
describe('spreadErrorMessage prop', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
defineInlineTest(
|
|
12
|
+
{ default: transformer, parser: 'tsx' },
|
|
13
|
+
{},
|
|
14
|
+
`
|
|
15
15
|
import React from "react";
|
|
16
16
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
17
17
|
|
|
@@ -30,7 +30,7 @@ describe('spreadErrorMessage prop', () => {
|
|
|
30
30
|
/>
|
|
31
31
|
);
|
|
32
32
|
`,
|
|
33
|
-
|
|
33
|
+
`
|
|
34
34
|
import React from "react";
|
|
35
35
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
36
36
|
|
|
@@ -54,13 +54,13 @@ describe('spreadErrorMessage prop', () => {
|
|
|
54
54
|
/>
|
|
55
55
|
);
|
|
56
56
|
`,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
'should spread errorMessage out',
|
|
58
|
+
);
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
defineInlineTest(
|
|
61
|
+
{ default: transformer, parser: 'tsx' },
|
|
62
|
+
{},
|
|
63
|
+
`
|
|
64
64
|
import React from "react";
|
|
65
65
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
66
66
|
|
|
@@ -79,7 +79,7 @@ describe('spreadErrorMessage prop', () => {
|
|
|
79
79
|
/>
|
|
80
80
|
);
|
|
81
81
|
`,
|
|
82
|
-
|
|
82
|
+
`
|
|
83
83
|
import React from "react";
|
|
84
84
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
85
85
|
|
|
@@ -103,13 +103,13 @@ describe('spreadErrorMessage prop', () => {
|
|
|
103
103
|
/>
|
|
104
104
|
);
|
|
105
105
|
`,
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
'should spread errorMessage out - with alias',
|
|
107
|
+
);
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
defineInlineTest(
|
|
110
|
+
{ default: transformer, parser: 'tsx' },
|
|
111
|
+
{},
|
|
112
|
+
`
|
|
113
113
|
import React, { PureComponent } from "react";
|
|
114
114
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
115
115
|
import TextField from "@atlaskit/textfield";
|
|
@@ -202,7 +202,7 @@ describe('spreadErrorMessage prop', () => {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
`,
|
|
205
|
-
|
|
205
|
+
`
|
|
206
206
|
import React, { PureComponent } from "react";
|
|
207
207
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
208
208
|
import TextField from "@atlaskit/textfield";
|
|
@@ -295,13 +295,13 @@ describe('spreadErrorMessage prop', () => {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
`,
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
'ColumnEditableTitle - add comment when editView is not inline',
|
|
299
|
+
);
|
|
300
300
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
301
|
+
defineInlineTest(
|
|
302
|
+
{ default: transformer, parser: 'tsx' },
|
|
303
|
+
{},
|
|
304
|
+
`
|
|
305
305
|
import React, { PureComponent } from "react";
|
|
306
306
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
307
307
|
import TextField from "@atlaskit/textfield";
|
|
@@ -393,7 +393,7 @@ describe('spreadErrorMessage prop', () => {
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
`,
|
|
396
|
-
|
|
396
|
+
`
|
|
397
397
|
import React, { PureComponent } from "react";
|
|
398
398
|
import InlineEdit from "@atlaskit/inline-edit";
|
|
399
399
|
import TextField from "@atlaskit/textfield";
|
|
@@ -488,6 +488,6 @@ describe('spreadErrorMessage prop', () => {
|
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
`,
|
|
491
|
-
|
|
492
|
-
|
|
491
|
+
'ColumnEditableTitle - convert when editView is inline',
|
|
492
|
+
);
|
|
493
493
|
});
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ASTPath, default as core, ImportDeclaration } from 'jscodeshift';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
addCommentToStartOfFile,
|
|
5
|
-
getDefaultSpecifierName,
|
|
6
|
-
hasJSXAttributesByName,
|
|
7
|
-
} from './utils';
|
|
3
|
+
import { addCommentToStartOfFile, getDefaultSpecifierName, hasJSXAttributesByName } from './utils';
|
|
8
4
|
|
|
9
5
|
const commentMessage = `We could not automatically convert this code to the new API.
|
|
10
6
|
|
|
@@ -31,24 +27,18 @@ const MyEditView = (
|
|
|
31
27
|
`;
|
|
32
28
|
|
|
33
29
|
const addCommentsWhenValidateFound = (j: core.JSCodeshift, source: any) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.forEach((element: ASTPath<ImportDeclaration>) => {
|
|
47
|
-
const isValidateDefined = hasJSXAttributesByName(j, element, 'validate');
|
|
48
|
-
if (isValidateDefined) {
|
|
49
|
-
addCommentToStartOfFile({ j, base: source, message: commentMessage });
|
|
50
|
-
}
|
|
51
|
-
});
|
|
30
|
+
const defaultSpecifier = getDefaultSpecifierName(j, source, '@atlaskit/inline-edit');
|
|
31
|
+
|
|
32
|
+
if (!defaultSpecifier) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
source.findJSXElements(defaultSpecifier).forEach((element: ASTPath<ImportDeclaration>) => {
|
|
37
|
+
const isValidateDefined = hasJSXAttributesByName(j, element, 'validate');
|
|
38
|
+
if (isValidateDefined) {
|
|
39
|
+
addCommentToStartOfFile({ j, base: source, message: commentMessage });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
52
42
|
};
|
|
53
43
|
|
|
54
44
|
export default addCommentsWhenValidateFound;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
ASTPath,
|
|
3
|
+
default as core,
|
|
4
|
+
ImportDeclaration,
|
|
5
|
+
ImportDefaultSpecifier,
|
|
6
|
+
ImportSpecifier,
|
|
7
7
|
} from 'jscodeshift';
|
|
8
8
|
|
|
9
9
|
import { addCommentToStartOfFile } from './utils';
|
|
@@ -14,58 +14,44 @@ This file uses \`InlineEdit\` and \`InlineEditStateless\` at the same time. We'v
|
|
|
14
14
|
`;
|
|
15
15
|
|
|
16
16
|
const elevateComponentToDefault =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return j.importDeclaration(
|
|
53
|
-
[j.importDefaultSpecifier(s.local)],
|
|
54
|
-
j.literal(toPkg),
|
|
55
|
-
);
|
|
56
|
-
} else {
|
|
57
|
-
return j.importDeclaration([s], j.literal(pkg));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
importDeclarations.forEach((path: ASTPath<ImportDeclaration>) => {
|
|
62
|
-
j(path).replaceWith(newDefaultSpecifier);
|
|
63
|
-
j(path).insertBefore(newOtherSpecifiers);
|
|
64
|
-
});
|
|
65
|
-
};
|
|
17
|
+
(pkg: string, toPkg: string, innerElementName: string) => (j: core.JSCodeshift, root: any) => {
|
|
18
|
+
const importDeclarations = root
|
|
19
|
+
.find(j.ImportDeclaration)
|
|
20
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === pkg);
|
|
21
|
+
|
|
22
|
+
const defaultSpecifier = importDeclarations.find(j.ImportDefaultSpecifier).nodes();
|
|
23
|
+
const otherSpecifier = importDeclarations.find(j.ImportSpecifier).nodes();
|
|
24
|
+
|
|
25
|
+
const isImportingStateless =
|
|
26
|
+
otherSpecifier.filter(
|
|
27
|
+
(s: ImportSpecifier) => s.imported && s.imported.name === innerElementName,
|
|
28
|
+
).length > 0;
|
|
29
|
+
|
|
30
|
+
if (defaultSpecifier.length > 0 && isImportingStateless) {
|
|
31
|
+
addCommentToStartOfFile({ j, base: root, message: commentMessage });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const newDefaultSpecifier = defaultSpecifier.map((s: ImportDefaultSpecifier) => {
|
|
36
|
+
return j.importDeclaration([j.importDefaultSpecifier(s.local)], j.literal(pkg));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const newOtherSpecifiers = otherSpecifier.map((s: ImportSpecifier) => {
|
|
40
|
+
if (s.imported.name === innerElementName) {
|
|
41
|
+
return j.importDeclaration([j.importDefaultSpecifier(s.local)], j.literal(toPkg));
|
|
42
|
+
} else {
|
|
43
|
+
return j.importDeclaration([s], j.literal(pkg));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
importDeclarations.forEach((path: ASTPath<ImportDeclaration>) => {
|
|
48
|
+
j(path).replaceWith(newDefaultSpecifier);
|
|
49
|
+
j(path).insertBefore(newOtherSpecifiers);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
66
52
|
|
|
67
53
|
export default elevateComponentToDefault(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
'@atlaskit/inline-edit',
|
|
55
|
+
'@atlaskit/inline-edit',
|
|
56
|
+
'InlineEditStateless',
|
|
71
57
|
);
|
|
@@ -1,53 +1,40 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
ASTPath,
|
|
3
|
+
default as core,
|
|
4
|
+
ImportDeclaration,
|
|
5
|
+
ImportDefaultSpecifier,
|
|
6
|
+
ImportSpecifier,
|
|
7
7
|
} from 'jscodeshift';
|
|
8
8
|
|
|
9
9
|
const elevateComponentToNewEntryPoint =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.filter(
|
|
15
|
-
(path: ASTPath<ImportDeclaration>) => path.node.source.value === pkg,
|
|
16
|
-
);
|
|
10
|
+
(pkg: string, toPkg: string, innerElementName: string) => (j: core.JSCodeshift, root: any) => {
|
|
11
|
+
const importDeclarations = root
|
|
12
|
+
.find(j.ImportDeclaration)
|
|
13
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === pkg);
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.nodes();
|
|
21
|
-
const otherSpecifier = importDeclarations.find(j.ImportSpecifier).nodes();
|
|
15
|
+
const defaultSpecifier = importDeclarations.find(j.ImportDefaultSpecifier).nodes();
|
|
16
|
+
const otherSpecifier = importDeclarations.find(j.ImportSpecifier).nodes();
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
[j.importDefaultSpecifier(s.local)],
|
|
27
|
-
j.literal(pkg),
|
|
28
|
-
);
|
|
29
|
-
},
|
|
30
|
-
);
|
|
18
|
+
const newDefaultSpecifier = defaultSpecifier.map((s: ImportDefaultSpecifier) => {
|
|
19
|
+
return j.importDeclaration([j.importDefaultSpecifier(s.local)], j.literal(pkg));
|
|
20
|
+
});
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return j.importDeclaration([s], j.literal(pkg));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
22
|
+
const newOtherSpecifiers = otherSpecifier.map((s: ImportSpecifier) => {
|
|
23
|
+
if (s.imported.name === innerElementName) {
|
|
24
|
+
return j.importDeclaration([j.importDefaultSpecifier(s.local)], j.literal(toPkg));
|
|
25
|
+
} else {
|
|
26
|
+
return j.importDeclaration([s], j.literal(pkg));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
42
29
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
importDeclarations.forEach((path: ASTPath<ImportDeclaration>) => {
|
|
31
|
+
j(path).replaceWith(newDefaultSpecifier);
|
|
32
|
+
j(path).insertBefore(newOtherSpecifiers);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
48
35
|
|
|
49
36
|
export default elevateComponentToNewEntryPoint(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
'@atlaskit/inline-edit',
|
|
38
|
+
'@atlaskit/inline-edit/inline-editable-textfield',
|
|
39
|
+
'InlineEditableTextfield',
|
|
53
40
|
);
|
|
@@ -1,74 +1,56 @@
|
|
|
1
1
|
import { type NodePath } from 'ast-types/lib/node-path';
|
|
2
2
|
import type { ASTPath, default as core, ImportDeclaration } from 'jscodeshift';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
getDefaultSpecifierName,
|
|
6
|
-
getJSXAttributesByName,
|
|
7
|
-
hasJSXAttributesByName,
|
|
8
|
-
} from './utils';
|
|
4
|
+
import { getDefaultSpecifierName, getJSXAttributesByName, hasJSXAttributesByName } from './utils';
|
|
9
5
|
|
|
10
6
|
const isConvertable = (arrowFunction: NodePath | null) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
return (
|
|
8
|
+
arrowFunction &&
|
|
9
|
+
arrowFunction.value.params.length === 1 &&
|
|
10
|
+
arrowFunction.value.params[0].type === 'Identifier'
|
|
11
|
+
);
|
|
16
12
|
};
|
|
17
13
|
|
|
18
14
|
const spreadErrorMessage = (j: core.JSCodeshift, source: any) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
createObjectProperty('errorMessage'),
|
|
59
|
-
j.restProperty(j.identifier(name)),
|
|
60
|
-
]),
|
|
61
|
-
],
|
|
62
|
-
arrowFunction.value.body,
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
j(editView).replaceWith(
|
|
67
|
-
j.jsxAttribute(j.jsxIdentifier('editView'), replacement),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
15
|
+
const defaultSpecifier = getDefaultSpecifierName(j, source, '@atlaskit/inline-edit');
|
|
16
|
+
|
|
17
|
+
if (!defaultSpecifier) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const createObjectProperty = (name: string) => {
|
|
22
|
+
const obj = j.objectProperty(j.identifier(name), j.identifier(name));
|
|
23
|
+
obj.shorthand = true;
|
|
24
|
+
obj.loc = null;
|
|
25
|
+
|
|
26
|
+
return obj;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
source.findJSXElements(defaultSpecifier).forEach((element: ASTPath<ImportDeclaration>) => {
|
|
30
|
+
getJSXAttributesByName(j, element, 'editView').forEach((editView) => {
|
|
31
|
+
const collection = j(editView).find(j.JSXExpressionContainer).find(j.ArrowFunctionExpression);
|
|
32
|
+
|
|
33
|
+
const isValidateDefined = hasJSXAttributesByName(j, element, 'validate');
|
|
34
|
+
const arrowFunction = collection.length > 0 ? collection.get() : null;
|
|
35
|
+
|
|
36
|
+
if (isValidateDefined && isConvertable(arrowFunction)) {
|
|
37
|
+
const name = arrowFunction.value.params[0].name;
|
|
38
|
+
const replacement = j.jsxExpressionContainer(
|
|
39
|
+
j.arrowFunctionExpression(
|
|
40
|
+
[
|
|
41
|
+
j.objectPattern([
|
|
42
|
+
createObjectProperty('errorMessage'),
|
|
43
|
+
j.restProperty(j.identifier(name)),
|
|
44
|
+
]),
|
|
45
|
+
],
|
|
46
|
+
arrowFunction.value.body,
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
j(editView).replaceWith(j.jsxAttribute(j.jsxIdentifier('editView'), replacement));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
72
54
|
};
|
|
73
55
|
|
|
74
56
|
export default spreadErrorMessage;
|
|
@@ -1,102 +1,94 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
ASTPath,
|
|
3
|
+
default as core,
|
|
4
|
+
ImportDeclaration,
|
|
5
|
+
JSXAttribute,
|
|
6
|
+
Program,
|
|
7
7
|
} from 'jscodeshift';
|
|
8
8
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
9
9
|
|
|
10
10
|
function addCommentBefore({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
j,
|
|
12
|
+
target,
|
|
13
|
+
message,
|
|
14
14
|
}: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| Collection<Program>
|
|
19
|
-
| Collection<ImportDeclaration>;
|
|
20
|
-
message: string;
|
|
15
|
+
j: core.JSCodeshift;
|
|
16
|
+
target: Collection<Node> | Collection<Program> | Collection<ImportDeclaration>;
|
|
17
|
+
message: string;
|
|
21
18
|
}) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const content: string = ` TODO: (from codemod) ${message} `;
|
|
20
|
+
target.forEach((path: ASTPath<any>) => {
|
|
21
|
+
path.value.comments = path.value.comments || [];
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
(comment: ASTPath<any>) => comment.value === content,
|
|
28
|
-
);
|
|
23
|
+
const exists = path.value.comments.find((comment: ASTPath<any>) => comment.value === content);
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// avoiding duplicates of the same comment
|
|
26
|
+
if (exists) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
path.value.comments.push(j.commentBlock(content));
|
|
31
|
+
});
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
function addCommentToStartOfFile({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
j,
|
|
36
|
+
base,
|
|
37
|
+
message,
|
|
43
38
|
}: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
j: core.JSCodeshift;
|
|
40
|
+
base: Collection<Node>;
|
|
41
|
+
message: string;
|
|
47
42
|
}) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
addCommentBefore({
|
|
44
|
+
j,
|
|
45
|
+
target: base.find(j.Program),
|
|
46
|
+
message,
|
|
47
|
+
});
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
function getJSXAttributesByName(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
j: core.JSCodeshift,
|
|
52
|
+
element: ASTPath<any>,
|
|
53
|
+
attributeName: string,
|
|
59
54
|
): Collection<JSXAttribute> {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
return j(element)
|
|
56
|
+
.find(j.JSXOpeningElement)
|
|
57
|
+
.find(j.JSXAttribute)
|
|
58
|
+
.filter((attribute) => {
|
|
59
|
+
const matches = j(attribute)
|
|
60
|
+
.find(j.JSXIdentifier)
|
|
61
|
+
.filter((identifier) => identifier.value.name === attributeName);
|
|
62
|
+
return Boolean(matches.length);
|
|
63
|
+
});
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
const getDefaultSpecifierName = (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
j: core.JSCodeshift,
|
|
68
|
+
base: Collection<any>,
|
|
69
|
+
packageName: string,
|
|
75
70
|
) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
path.node.source.value === packageName,
|
|
81
|
-
)
|
|
82
|
-
.find(j.ImportDefaultSpecifier);
|
|
71
|
+
const specifiers = base
|
|
72
|
+
.find(j.ImportDeclaration)
|
|
73
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === packageName)
|
|
74
|
+
.find(j.ImportDefaultSpecifier);
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
if (!specifiers.length) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
87
79
|
|
|
88
|
-
|
|
80
|
+
return specifiers.nodes()[0]!.local!.name;
|
|
89
81
|
};
|
|
90
82
|
|
|
91
83
|
const hasJSXAttributesByName = (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
j: core.JSCodeshift,
|
|
85
|
+
element: ASTPath<any>,
|
|
86
|
+
attributeName: string,
|
|
95
87
|
) => getJSXAttributesByName(j, element, attributeName).length > 0;
|
|
96
88
|
|
|
97
89
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
getDefaultSpecifierName,
|
|
91
|
+
getJSXAttributesByName,
|
|
92
|
+
hasJSXAttributesByName,
|
|
93
|
+
addCommentToStartOfFile,
|
|
102
94
|
};
|
package/dist/cjs/inline-edit.js
CHANGED
|
@@ -21,7 +21,9 @@ var _readView = _interopRequireDefault(require("./internal/read-view"));
|
|
|
21
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
24
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
25
|
+
* @jsxRuntime classic
|
|
26
|
+
*/ /** @jsx jsx */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
27
|
var fieldStyles = (0, _react2.css)({
|
|
26
28
|
maxWidth: '100%',
|
|
27
29
|
position: 'relative'
|
|
@@ -29,7 +31,7 @@ var fieldStyles = (0, _react2.css)({
|
|
|
29
31
|
var analyticsAttributes = {
|
|
30
32
|
componentName: 'inlineEdit',
|
|
31
33
|
packageName: "@atlaskit/inline-edit",
|
|
32
|
-
packageVersion: "13.
|
|
34
|
+
packageVersion: "13.5.0"
|
|
33
35
|
};
|
|
34
36
|
var noop = function noop() {};
|
|
35
37
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|