@atlaskit/calendar 16.3.1 → 16.3.2
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/dist/cjs/calendar.js +1 -1
- package/dist/es2019/calendar.js +1 -1
- package/dist/esm/calendar.js +1 -1
- package/package.json +3 -6
- package/codemods/11.0.0-lite-mode.tsx +0 -10
- package/codemods/__tests__/11.0.0-lite-mode.tsx +0 -166
- package/codemods/__tests__/flatten-certain-inner-props-as-prop.tsx +0 -156
- package/codemods/__tests__/remove-inner-props.tsx +0 -160
- package/codemods/migrations/flatten-certain-inner-props-as-prop.tsx +0 -11
- package/codemods/migrations/remove-inner-props.tsx +0 -11
- package/codemods/utils.tsx +0 -192
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/calendar
|
|
2
2
|
|
|
3
|
+
## 16.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#114277](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114277)
|
|
8
|
+
[`f10877b44dc55`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f10877b44dc55) -
|
|
9
|
+
Update depdencies and remove old codemods.
|
|
10
|
+
|
|
3
11
|
## 16.3.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/calendar.js
CHANGED
|
@@ -38,7 +38,7 @@ var styles = {
|
|
|
38
38
|
var analyticsAttributes = {
|
|
39
39
|
componentName: 'calendar',
|
|
40
40
|
packageName: "@atlaskit/calendar",
|
|
41
|
-
packageVersion: "16.3.
|
|
41
|
+
packageVersion: "16.3.2"
|
|
42
42
|
};
|
|
43
43
|
var InnerCalendar = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_ref, ref) {
|
|
44
44
|
var day = _ref.day,
|
package/dist/es2019/calendar.js
CHANGED
package/dist/esm/calendar.js
CHANGED
|
@@ -28,7 +28,7 @@ var styles = {
|
|
|
28
28
|
var analyticsAttributes = {
|
|
29
29
|
componentName: 'calendar',
|
|
30
30
|
packageName: "@atlaskit/calendar",
|
|
31
|
-
packageVersion: "16.3.
|
|
31
|
+
packageVersion: "16.3.2"
|
|
32
32
|
};
|
|
33
33
|
var InnerCalendar = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
|
|
34
34
|
var day = _ref.day,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/calendar",
|
|
3
|
-
"version": "16.3.
|
|
3
|
+
"version": "16.3.2",
|
|
4
4
|
"description": "An interactive calendar for date selection experiences.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@atlaskit/css": "^0.8.0",
|
|
31
31
|
"@atlaskit/ds-lib": "^3.5.0",
|
|
32
32
|
"@atlaskit/heading": "^4.1.0",
|
|
33
|
-
"@atlaskit/icon": "^23.
|
|
33
|
+
"@atlaskit/icon": "^23.9.0",
|
|
34
34
|
"@atlaskit/locale": "^2.8.0",
|
|
35
35
|
"@atlaskit/platform-feature-flags": "*",
|
|
36
|
-
"@atlaskit/primitives": "^13.
|
|
36
|
+
"@atlaskit/primitives": "^13.5.0",
|
|
37
37
|
"@atlaskit/theme": "^15.0.0",
|
|
38
38
|
"@atlaskit/tokens": "^3.3.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
@@ -55,13 +55,10 @@
|
|
|
55
55
|
"@atlaskit/ssr": "*",
|
|
56
56
|
"@atlaskit/visual-regression": "*",
|
|
57
57
|
"@atlassian/feature-flags-test-utils": "*",
|
|
58
|
-
"@testing-library/dom": "^10.1.0",
|
|
59
58
|
"@testing-library/react": "^13.4.0",
|
|
60
59
|
"@testing-library/user-event": "^14.4.3",
|
|
61
60
|
"jest-in-case": "^1.0.2",
|
|
62
|
-
"jscodeshift": "^0.13.0",
|
|
63
61
|
"react-dom": "^18.2.0",
|
|
64
|
-
"storybook-addon-performance": "^0.17.3",
|
|
65
62
|
"typescript": "~5.4.2"
|
|
66
63
|
},
|
|
67
64
|
"techstack": {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { flattenCertainInnerPropsAsProp } from './migrations/flatten-certain-inner-props-as-prop';
|
|
2
|
-
import { removeInnerProps } from './migrations/remove-inner-props';
|
|
3
|
-
import { createTransformer } from './utils';
|
|
4
|
-
|
|
5
|
-
const transformer = createTransformer('@atlaskit/calendar', [
|
|
6
|
-
flattenCertainInnerPropsAsProp,
|
|
7
|
-
removeInnerProps,
|
|
8
|
-
]);
|
|
9
|
-
|
|
10
|
-
export default transformer;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
jest.autoMockOff();
|
|
2
|
-
|
|
3
|
-
import transformer from '../11.0.0-lite-mode';
|
|
4
|
-
|
|
5
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
6
|
-
|
|
7
|
-
describe('Calendar code-mods', () => {
|
|
8
|
-
defineInlineTest(
|
|
9
|
-
{ default: transformer, parser: 'tsx' },
|
|
10
|
-
{},
|
|
11
|
-
`
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import Calendar from '@atlaskit/calendar';
|
|
14
|
-
|
|
15
|
-
const SimpleCalendar= () => {
|
|
16
|
-
return (
|
|
17
|
-
<Calendar
|
|
18
|
-
defaultDisabled={['2020-12-04']}
|
|
19
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
20
|
-
defaultSelected={['2020-12-08']}
|
|
21
|
-
defaultMonth={12}
|
|
22
|
-
defaultYear={2020}
|
|
23
|
-
innerProps={{
|
|
24
|
-
className: 'myClass',
|
|
25
|
-
style: {
|
|
26
|
-
border: '1px solid red',
|
|
27
|
-
display: 'inline-block',
|
|
28
|
-
},
|
|
29
|
-
}}
|
|
30
|
-
testId="the-calendar"
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
`,
|
|
35
|
-
`
|
|
36
|
-
/* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
|
|
37
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
38
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
39
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
40
|
-
& might have to be handled manually as per need. */
|
|
41
|
-
import React from 'react';
|
|
42
|
-
import Calendar from '@atlaskit/calendar';
|
|
43
|
-
|
|
44
|
-
const SimpleCalendar= () => {
|
|
45
|
-
return (
|
|
46
|
-
<Calendar
|
|
47
|
-
defaultDisabled={['2020-12-04']}
|
|
48
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
49
|
-
defaultSelected={['2020-12-08']}
|
|
50
|
-
defaultMonth={12}
|
|
51
|
-
defaultYear={2020}
|
|
52
|
-
testId="the-calendar"
|
|
53
|
-
className={'myClass'}
|
|
54
|
-
style={{
|
|
55
|
-
border: '1px solid red',
|
|
56
|
-
display: 'inline-block',
|
|
57
|
-
}} />
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
`,
|
|
61
|
-
`should flatten style & className in innerProps as standalone prop
|
|
62
|
-
& then remove innerProps`,
|
|
63
|
-
);
|
|
64
|
-
defineInlineTest(
|
|
65
|
-
{ default: transformer, parser: 'tsx' },
|
|
66
|
-
{},
|
|
67
|
-
`
|
|
68
|
-
import React from 'react';
|
|
69
|
-
import Calendar from '@atlaskit/calendar';
|
|
70
|
-
|
|
71
|
-
const SimpleCalendar= () => {
|
|
72
|
-
return (
|
|
73
|
-
<Calendar
|
|
74
|
-
defaultDisabled={['2020-12-04']}
|
|
75
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
76
|
-
defaultSelected={['2020-12-08']}
|
|
77
|
-
defaultMonth={12}
|
|
78
|
-
defaultYear={2020}
|
|
79
|
-
innerProps={{
|
|
80
|
-
className: 'myClass',
|
|
81
|
-
theme: 'dark',
|
|
82
|
-
style: {
|
|
83
|
-
border: '1px solid red',
|
|
84
|
-
display: 'inline-block',
|
|
85
|
-
},
|
|
86
|
-
}}
|
|
87
|
-
testId="the-calendar"
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
`,
|
|
92
|
-
`
|
|
93
|
-
/* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
|
|
94
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
95
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
96
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
97
|
-
& might have to be handled manually as per need. */
|
|
98
|
-
import React from 'react';
|
|
99
|
-
import Calendar from '@atlaskit/calendar';
|
|
100
|
-
|
|
101
|
-
const SimpleCalendar= () => {
|
|
102
|
-
return (
|
|
103
|
-
<Calendar
|
|
104
|
-
defaultDisabled={['2020-12-04']}
|
|
105
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
106
|
-
defaultSelected={['2020-12-08']}
|
|
107
|
-
defaultMonth={12}
|
|
108
|
-
defaultYear={2020}
|
|
109
|
-
testId="the-calendar"
|
|
110
|
-
className={'myClass'}
|
|
111
|
-
style={{
|
|
112
|
-
border: '1px solid red',
|
|
113
|
-
display: 'inline-block',
|
|
114
|
-
}} />
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
`,
|
|
118
|
-
`should only flatten style & className in innerProps as standalone prop
|
|
119
|
-
& then remove innerProps`,
|
|
120
|
-
);
|
|
121
|
-
defineInlineTest(
|
|
122
|
-
{ default: transformer, parser: 'tsx' },
|
|
123
|
-
{},
|
|
124
|
-
`
|
|
125
|
-
import React from 'react';
|
|
126
|
-
import Calendar from '@atlaskit/calendar';
|
|
127
|
-
const SimpleCalendar= () => {
|
|
128
|
-
return (
|
|
129
|
-
<Calendar
|
|
130
|
-
defaultDisabled={['2020-12-04']}
|
|
131
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
132
|
-
defaultSelected={['2020-12-08']}
|
|
133
|
-
defaultMonth={12}
|
|
134
|
-
defaultYear={2020}
|
|
135
|
-
innerProps={{
|
|
136
|
-
dummyInnerProp: 'dummy'
|
|
137
|
-
}}
|
|
138
|
-
testId="the-calendar"
|
|
139
|
-
/>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
`,
|
|
143
|
-
`
|
|
144
|
-
/* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
|
|
145
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
146
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
147
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
148
|
-
& might have to be handled manually as per need. */
|
|
149
|
-
import React from 'react';
|
|
150
|
-
import Calendar from '@atlaskit/calendar';
|
|
151
|
-
const SimpleCalendar= () => {
|
|
152
|
-
return (
|
|
153
|
-
<Calendar
|
|
154
|
-
defaultDisabled={['2020-12-04']}
|
|
155
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
156
|
-
defaultSelected={['2020-12-08']}
|
|
157
|
-
defaultMonth={12}
|
|
158
|
-
defaultYear={2020}
|
|
159
|
-
testId="the-calendar" />
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
`,
|
|
163
|
-
`should not flatten any other prop apart from style & className in innerProps
|
|
164
|
-
& just remove innerProps`,
|
|
165
|
-
);
|
|
166
|
-
});
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
jest.autoMockOff();
|
|
2
|
-
|
|
3
|
-
import { flattenCertainInnerPropsAsProp } from '../migrations/flatten-certain-inner-props-as-prop';
|
|
4
|
-
import { createTransformer } from '../utils';
|
|
5
|
-
|
|
6
|
-
const transformer = createTransformer('@atlaskit/calendar', [flattenCertainInnerPropsAsProp]);
|
|
7
|
-
|
|
8
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
9
|
-
|
|
10
|
-
describe('Flatten Inner Prop Style As Prop', () => {
|
|
11
|
-
defineInlineTest(
|
|
12
|
-
{ default: transformer, parser: 'tsx' },
|
|
13
|
-
{},
|
|
14
|
-
`
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import Calendar from '@atlaskit/calendar';
|
|
17
|
-
const SimpleCalendar = () => {
|
|
18
|
-
return (
|
|
19
|
-
<Calendar
|
|
20
|
-
innerProps={{
|
|
21
|
-
style: {
|
|
22
|
-
border: '1px solid red',
|
|
23
|
-
display: 'inline-block',
|
|
24
|
-
},
|
|
25
|
-
className: 'abc',
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
};
|
|
30
|
-
`,
|
|
31
|
-
`
|
|
32
|
-
import React from 'react';
|
|
33
|
-
import Calendar from '@atlaskit/calendar';
|
|
34
|
-
const SimpleCalendar = () => {
|
|
35
|
-
return (
|
|
36
|
-
<Calendar
|
|
37
|
-
innerProps={{
|
|
38
|
-
style: {
|
|
39
|
-
border: '1px solid red',
|
|
40
|
-
display: 'inline-block',
|
|
41
|
-
},
|
|
42
|
-
className: 'abc',
|
|
43
|
-
}}
|
|
44
|
-
style={{
|
|
45
|
-
border: '1px solid red',
|
|
46
|
-
display: 'inline-block',
|
|
47
|
-
}}
|
|
48
|
-
className={'abc'} />
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
`,
|
|
52
|
-
'should flatten style & className properties in inner props as a new standalone props',
|
|
53
|
-
);
|
|
54
|
-
defineInlineTest(
|
|
55
|
-
{ default: transformer, parser: 'tsx' },
|
|
56
|
-
{},
|
|
57
|
-
`
|
|
58
|
-
import React from 'react';
|
|
59
|
-
import Calendar from '@atlaskit/calendar';
|
|
60
|
-
const SimpleCalendar = () => {
|
|
61
|
-
return (
|
|
62
|
-
<Calendar
|
|
63
|
-
innerProps={{
|
|
64
|
-
className: 'abc',
|
|
65
|
-
}}
|
|
66
|
-
/>
|
|
67
|
-
)
|
|
68
|
-
};
|
|
69
|
-
`,
|
|
70
|
-
`
|
|
71
|
-
import React from 'react';
|
|
72
|
-
import Calendar from '@atlaskit/calendar';
|
|
73
|
-
const SimpleCalendar = () => {
|
|
74
|
-
return (
|
|
75
|
-
<Calendar
|
|
76
|
-
innerProps={{
|
|
77
|
-
className: 'abc',
|
|
78
|
-
}}
|
|
79
|
-
className={'abc'} />
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
`,
|
|
83
|
-
'should just flatten className property in inner props as a new standalone prop',
|
|
84
|
-
);
|
|
85
|
-
defineInlineTest(
|
|
86
|
-
{ default: transformer, parser: 'tsx' },
|
|
87
|
-
{},
|
|
88
|
-
`
|
|
89
|
-
import React from 'react';
|
|
90
|
-
import Calendar from '@atlaskit/calendar';
|
|
91
|
-
const SimpleCalendar = () => {
|
|
92
|
-
return (
|
|
93
|
-
<Calendar
|
|
94
|
-
innerProps={{
|
|
95
|
-
style: {
|
|
96
|
-
border: '1px solid red',
|
|
97
|
-
display: 'inline-block',
|
|
98
|
-
},
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
)
|
|
102
|
-
};
|
|
103
|
-
`,
|
|
104
|
-
`
|
|
105
|
-
import React from 'react';
|
|
106
|
-
import Calendar from '@atlaskit/calendar';
|
|
107
|
-
const SimpleCalendar = () => {
|
|
108
|
-
return (
|
|
109
|
-
<Calendar
|
|
110
|
-
innerProps={{
|
|
111
|
-
style: {
|
|
112
|
-
border: '1px solid red',
|
|
113
|
-
display: 'inline-block',
|
|
114
|
-
},
|
|
115
|
-
}}
|
|
116
|
-
style={{
|
|
117
|
-
border: '1px solid red',
|
|
118
|
-
display: 'inline-block',
|
|
119
|
-
}} />
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
`,
|
|
123
|
-
'should just flatten style property in inner props as a new standalone prop',
|
|
124
|
-
);
|
|
125
|
-
defineInlineTest(
|
|
126
|
-
{ default: transformer, parser: 'tsx' },
|
|
127
|
-
{},
|
|
128
|
-
`
|
|
129
|
-
import React from 'react';
|
|
130
|
-
import Calendar from '@atlaskit/calendar';
|
|
131
|
-
const SimpleCalendar = () => {
|
|
132
|
-
return (
|
|
133
|
-
<Calendar
|
|
134
|
-
innerProps={{
|
|
135
|
-
theme: 'dark'
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
)
|
|
139
|
-
};
|
|
140
|
-
`,
|
|
141
|
-
`
|
|
142
|
-
import React from 'react';
|
|
143
|
-
import Calendar from '@atlaskit/calendar';
|
|
144
|
-
const SimpleCalendar = () => {
|
|
145
|
-
return (
|
|
146
|
-
<Calendar
|
|
147
|
-
innerProps={{
|
|
148
|
-
theme: 'dark'
|
|
149
|
-
}}
|
|
150
|
-
/>
|
|
151
|
-
)
|
|
152
|
-
};
|
|
153
|
-
`,
|
|
154
|
-
'should not flatten any other prop in inner props if className & style prop is not present',
|
|
155
|
-
);
|
|
156
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
jest.autoMockOff();
|
|
2
|
-
|
|
3
|
-
import { removeInnerProps } from '../migrations/remove-inner-props';
|
|
4
|
-
import { createTransformer } from '../utils';
|
|
5
|
-
|
|
6
|
-
const transformer = createTransformer('@atlaskit/calendar', [removeInnerProps]);
|
|
7
|
-
|
|
8
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
9
|
-
|
|
10
|
-
describe('Remove innerProps', () => {
|
|
11
|
-
defineInlineTest(
|
|
12
|
-
{ default: transformer, parser: 'tsx' },
|
|
13
|
-
{},
|
|
14
|
-
`
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import Calendar from '@atlaskit/calendar';
|
|
17
|
-
|
|
18
|
-
const SimpleCalendar = () => {
|
|
19
|
-
return (
|
|
20
|
-
<Calendar
|
|
21
|
-
innerProps={{
|
|
22
|
-
style: {
|
|
23
|
-
border: '1px solid red',
|
|
24
|
-
display: 'inline-block',
|
|
25
|
-
},
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
`,
|
|
31
|
-
`
|
|
32
|
-
/* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
|
|
33
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
34
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
35
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
36
|
-
& might have to be handled manually as per need. */
|
|
37
|
-
import React from 'react';
|
|
38
|
-
import Calendar from '@atlaskit/calendar';
|
|
39
|
-
|
|
40
|
-
const SimpleCalendar = () => {
|
|
41
|
-
return <Calendar />;
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
'should remove innerProps from Calendar and leave a TODO comment',
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
defineInlineTest(
|
|
48
|
-
{ default: transformer, parser: 'tsx' },
|
|
49
|
-
{},
|
|
50
|
-
`
|
|
51
|
-
import React from 'react';
|
|
52
|
-
import AkCalendar from '@atlaskit/calendar';
|
|
53
|
-
|
|
54
|
-
const SimpleCalendar = () => {
|
|
55
|
-
return (
|
|
56
|
-
<AkCalendar
|
|
57
|
-
innerProps={{
|
|
58
|
-
style: {
|
|
59
|
-
border: '1px solid red',
|
|
60
|
-
display: 'inline-block',
|
|
61
|
-
},
|
|
62
|
-
}}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
`,
|
|
67
|
-
`
|
|
68
|
-
/* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
|
|
69
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
70
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
71
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
72
|
-
& might have to be handled manually as per need. */
|
|
73
|
-
import React from 'react';
|
|
74
|
-
import AkCalendar from '@atlaskit/calendar';
|
|
75
|
-
|
|
76
|
-
const SimpleCalendar = () => {
|
|
77
|
-
return <AkCalendar />;
|
|
78
|
-
}
|
|
79
|
-
`,
|
|
80
|
-
'should also remove innerProps from some random default import name of Calendar (eg: AkCalendar) and leave a TODO comment',
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
defineInlineTest(
|
|
84
|
-
{ default: transformer, parser: 'tsx' },
|
|
85
|
-
{},
|
|
86
|
-
`
|
|
87
|
-
import React from 'react';
|
|
88
|
-
import Calendar from '@atlaskit/calendar';
|
|
89
|
-
|
|
90
|
-
const SimpleCalendar = () => {
|
|
91
|
-
return (
|
|
92
|
-
<Calendar
|
|
93
|
-
defaultDisabled={['2020-12-04']}
|
|
94
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
95
|
-
defaultSelected={['2020-12-08']}
|
|
96
|
-
innerProps={{
|
|
97
|
-
style: {
|
|
98
|
-
border: '1px solid red',
|
|
99
|
-
display: 'inline-block',
|
|
100
|
-
},
|
|
101
|
-
}}
|
|
102
|
-
/>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
`,
|
|
106
|
-
`
|
|
107
|
-
/* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
|
|
108
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
109
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
110
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
111
|
-
& might have to be handled manually as per need. */
|
|
112
|
-
import React from 'react';
|
|
113
|
-
import Calendar from '@atlaskit/calendar';
|
|
114
|
-
|
|
115
|
-
const SimpleCalendar = () => {
|
|
116
|
-
return (
|
|
117
|
-
<Calendar
|
|
118
|
-
defaultDisabled={['2020-12-04']}
|
|
119
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
120
|
-
defaultSelected={['2020-12-08']} />
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
`,
|
|
124
|
-
'should remove innerProps from Calendar, leave a TODO comment & just keep other props intact',
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
defineInlineTest(
|
|
128
|
-
{ default: transformer, parser: 'tsx' },
|
|
129
|
-
{},
|
|
130
|
-
`
|
|
131
|
-
import React from 'react';
|
|
132
|
-
import Calendar from '@atlaskit/calendar';
|
|
133
|
-
|
|
134
|
-
const SimpleCalendar = () => {
|
|
135
|
-
return (
|
|
136
|
-
<Calendar
|
|
137
|
-
defaultDisabled={['2020-12-04']}
|
|
138
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
139
|
-
defaultSelected={['2020-12-08']}
|
|
140
|
-
/>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
`,
|
|
144
|
-
`
|
|
145
|
-
import React from 'react';
|
|
146
|
-
import Calendar from '@atlaskit/calendar';
|
|
147
|
-
|
|
148
|
-
const SimpleCalendar = () => {
|
|
149
|
-
return (
|
|
150
|
-
<Calendar
|
|
151
|
-
defaultDisabled={['2020-12-04']}
|
|
152
|
-
defaultPreviouslySelected={['2020-12-06']}
|
|
153
|
-
defaultSelected={['2020-12-08']}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
`,
|
|
158
|
-
'should not remove & leave a TODO comment when innerProps is itself not present',
|
|
159
|
-
);
|
|
160
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { flattenCertainChildPropsAsProp } from '../utils';
|
|
2
|
-
|
|
3
|
-
const component = '@atlaskit/calendar';
|
|
4
|
-
const prop = 'innerProps';
|
|
5
|
-
const childProps = ['style', 'className'];
|
|
6
|
-
|
|
7
|
-
export const flattenCertainInnerPropsAsProp = flattenCertainChildPropsAsProp(
|
|
8
|
-
component,
|
|
9
|
-
prop,
|
|
10
|
-
childProps,
|
|
11
|
-
);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRemoveFuncFor } from '../utils';
|
|
2
|
-
|
|
3
|
-
const component = '@atlaskit/calendar';
|
|
4
|
-
const prop = 'innerProps';
|
|
5
|
-
const comment = `This file uses the @atlaskit/calendar \`innerProps\` which
|
|
6
|
-
has now been removed due to its poor performance characteristics. Codemod
|
|
7
|
-
has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
|
|
8
|
-
Rest other properties if any inside innerProps will get auto-removed along with it,
|
|
9
|
-
& might have to be handled manually as per need.`;
|
|
10
|
-
|
|
11
|
-
export const removeInnerProps = createRemoveFuncFor(component, prop, comment);
|
package/codemods/utils.tsx
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
API,
|
|
3
|
-
ASTPath,
|
|
4
|
-
default as core,
|
|
5
|
-
FileInfo,
|
|
6
|
-
ImportDeclaration,
|
|
7
|
-
ImportSpecifier,
|
|
8
|
-
JSXAttribute,
|
|
9
|
-
ObjectExpression,
|
|
10
|
-
Options,
|
|
11
|
-
Program,
|
|
12
|
-
} from 'jscodeshift';
|
|
13
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
14
|
-
|
|
15
|
-
export type Nullable<T> = T | null;
|
|
16
|
-
|
|
17
|
-
export function getDefaultSpecifier(j: core.JSCodeshift, source: any, specifier: string) {
|
|
18
|
-
const specifiers = source
|
|
19
|
-
.find(j.ImportDeclaration)
|
|
20
|
-
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
|
|
21
|
-
.find(j.ImportDefaultSpecifier);
|
|
22
|
-
|
|
23
|
-
if (!specifiers.length) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
return specifiers.nodes()[0]!.local!.name;
|
|
27
|
-
}
|
|
28
|
-
export function getNamedSpecifier(
|
|
29
|
-
j: core.JSCodeshift,
|
|
30
|
-
source: any,
|
|
31
|
-
specifier: string,
|
|
32
|
-
importName: string,
|
|
33
|
-
) {
|
|
34
|
-
const specifiers = source
|
|
35
|
-
.find(j.ImportDeclaration)
|
|
36
|
-
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
|
|
37
|
-
.find(j.ImportSpecifier)
|
|
38
|
-
.filter((path: ASTPath<ImportSpecifier>) => path.node.imported.name === importName);
|
|
39
|
-
|
|
40
|
-
if (!specifiers.length) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return specifiers.nodes()[0]!.local!.name;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function getJSXAttributesByName(
|
|
47
|
-
j: core.JSCodeshift,
|
|
48
|
-
element: ASTPath<any>,
|
|
49
|
-
attributeName: string,
|
|
50
|
-
): Collection<JSXAttribute> {
|
|
51
|
-
return j(element)
|
|
52
|
-
.find(j.JSXOpeningElement)
|
|
53
|
-
.find(j.JSXAttribute)
|
|
54
|
-
.filter((attribute) => {
|
|
55
|
-
const matches = j(attribute)
|
|
56
|
-
.find(j.JSXIdentifier)
|
|
57
|
-
.filter((identifier) => identifier.value.name === attributeName);
|
|
58
|
-
return Boolean(matches.length);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function hasImportDeclaration(j: core.JSCodeshift, source: any, importPath: string) {
|
|
63
|
-
const imports = source
|
|
64
|
-
.find(j.ImportDeclaration)
|
|
65
|
-
.filter(
|
|
66
|
-
(path: ASTPath<ImportDeclaration>) =>
|
|
67
|
-
typeof path.node.source.value === 'string' && path.node.source.value.startsWith(importPath),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return Boolean(imports.length);
|
|
71
|
-
}
|
|
72
|
-
// not replacing newlines (which \s does)
|
|
73
|
-
const spacesAndTabs: RegExp = /[ \t]{2,}/g;
|
|
74
|
-
const lineStartWithSpaces: RegExp = /^[ \t]*/gm;
|
|
75
|
-
|
|
76
|
-
function clean(value: string): string {
|
|
77
|
-
return (
|
|
78
|
-
value
|
|
79
|
-
.replace(spacesAndTabs, ' ')
|
|
80
|
-
.replace(lineStartWithSpaces, '')
|
|
81
|
-
// using .trim() to clear the any newlines before the first text and after last text
|
|
82
|
-
.trim()
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function addCommentToStartOfFile({
|
|
87
|
-
j,
|
|
88
|
-
base,
|
|
89
|
-
message,
|
|
90
|
-
}: {
|
|
91
|
-
j: core.JSCodeshift;
|
|
92
|
-
base: Collection<Node>;
|
|
93
|
-
message: string;
|
|
94
|
-
}) {
|
|
95
|
-
addCommentBefore({
|
|
96
|
-
j,
|
|
97
|
-
target: base.find(j.Program),
|
|
98
|
-
message,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function addCommentBefore({
|
|
103
|
-
j,
|
|
104
|
-
target,
|
|
105
|
-
message,
|
|
106
|
-
}: {
|
|
107
|
-
j: core.JSCodeshift;
|
|
108
|
-
target: Collection<Program> | Collection<ImportDeclaration>;
|
|
109
|
-
message: string;
|
|
110
|
-
}) {
|
|
111
|
-
const content: string = ` TODO: (from codemod) ${clean(message)} `;
|
|
112
|
-
target.forEach((path: ASTPath<Program | ImportDeclaration>) => {
|
|
113
|
-
path.value.comments = path.value.comments || [];
|
|
114
|
-
|
|
115
|
-
const exists = path.value.comments.find((comment) => comment.value === content);
|
|
116
|
-
|
|
117
|
-
// avoiding duplicates of the same comment
|
|
118
|
-
if (exists) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
path.value.comments.push(j.commentBlock(content));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export const createRemoveFuncFor =
|
|
127
|
-
(component: string, prop: string, comment?: string) =>
|
|
128
|
-
(j: core.JSCodeshift, source: Collection<Node>) => {
|
|
129
|
-
const defaultSpecifier = getDefaultSpecifier(j, source, component);
|
|
130
|
-
|
|
131
|
-
if (!defaultSpecifier) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
source.findJSXElements(defaultSpecifier).forEach((element) => {
|
|
136
|
-
getJSXAttributesByName(j, element, prop).forEach((attribute) => {
|
|
137
|
-
j(attribute).remove();
|
|
138
|
-
if (comment) {
|
|
139
|
-
addCommentToStartOfFile({ j, base: source, message: comment });
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export const flattenCertainChildPropsAsProp =
|
|
146
|
-
(component: string, propName: string, childProps: string[]) =>
|
|
147
|
-
(j: core.JSCodeshift, source: Collection<Node>) => {
|
|
148
|
-
const defaultSpecifier = getDefaultSpecifier(j, source, component);
|
|
149
|
-
if (!defaultSpecifier) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
source.findJSXElements(defaultSpecifier).forEach((element) => {
|
|
153
|
-
getJSXAttributesByName(j, element, propName).forEach((attribute) => {
|
|
154
|
-
j(attribute)
|
|
155
|
-
.find(j.JSXExpressionContainer)
|
|
156
|
-
.find(j.ObjectExpression)
|
|
157
|
-
.forEach((objectExpression) => {
|
|
158
|
-
objectExpression.node.properties.forEach((property) => {
|
|
159
|
-
childProps.forEach((childProp) => {
|
|
160
|
-
if (
|
|
161
|
-
property.type === 'ObjectProperty' &&
|
|
162
|
-
property.key.type === 'Identifier' &&
|
|
163
|
-
property.key.name === childProp &&
|
|
164
|
-
element.node.openingElement.attributes
|
|
165
|
-
) {
|
|
166
|
-
element.node.openingElement.attributes.push(
|
|
167
|
-
j.jsxAttribute(
|
|
168
|
-
j.jsxIdentifier(childProp),
|
|
169
|
-
j.jsxExpressionContainer(property.value as ObjectExpression),
|
|
170
|
-
),
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export const createTransformer =
|
|
181
|
-
(component: string, migrates: { (j: core.JSCodeshift, source: Collection<Node>): void }[]) =>
|
|
182
|
-
(fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => {
|
|
183
|
-
const source: Collection<Node> = j(fileInfo.source);
|
|
184
|
-
|
|
185
|
-
if (!hasImportDeclaration(j, source, component)) {
|
|
186
|
-
return fileInfo.source;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
migrates.forEach((tf) => tf(j, source));
|
|
190
|
-
|
|
191
|
-
return source.toSource(options.printOptions || { quote: 'single' });
|
|
192
|
-
};
|