@atlaskit/badge 17.1.0 → 17.1.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 +14 -0
- package/package.json +4 -6
- package/codemods/15.0.0-lite-mode.tsx +0 -14
- package/codemods/__tests__/15.0.0-lite-mode.test.tsx +0 -76
- package/codemods/__tests__/move-object-appearance-to-style.test.tsx +0 -184
- package/codemods/internal/constants.tsx +0 -3
- package/codemods/internal/move-object-appearance-to-style.tsx +0 -70
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/badge
|
|
2
2
|
|
|
3
|
+
## 17.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#111665](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111665)
|
|
8
|
+
[`5d898c3d9c9dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d898c3d9c9dc) -
|
|
9
|
+
Remove old codemods and update dependencies.
|
|
10
|
+
|
|
11
|
+
## 17.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 17.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/badge",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.2",
|
|
4
4
|
"description": "A badge is a visual indicator for numeric values such as tallies and scores.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
41
|
-
"@atlaskit/platform-feature-flags": "^0.
|
|
42
|
-
"@atlaskit/primitives": "^13.
|
|
41
|
+
"@atlaskit/platform-feature-flags": "^1.0.0",
|
|
42
|
+
"@atlaskit/primitives": "^13.5.0",
|
|
43
43
|
"@atlaskit/tokens": "^3.3.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@compiled/react": "^0.18.1"
|
|
@@ -56,12 +56,10 @@
|
|
|
56
56
|
"@atlaskit/link": "*",
|
|
57
57
|
"@atlaskit/section-message": "*",
|
|
58
58
|
"@atlaskit/ssr": "*",
|
|
59
|
-
"@atlaskit/theme": "^
|
|
59
|
+
"@atlaskit/theme": "^15.0.0",
|
|
60
60
|
"@atlassian/feature-flags-test-utils": "*",
|
|
61
61
|
"@testing-library/react": "^13.4.0",
|
|
62
|
-
"jscodeshift": "^0.13.0",
|
|
63
62
|
"react-dom": "^18.2.0",
|
|
64
|
-
"storybook-addon-performance": "^0.17.3",
|
|
65
63
|
"typescript": "~5.4.2"
|
|
66
64
|
},
|
|
67
65
|
"techstack": {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type JSCodeshift } from 'jscodeshift';
|
|
2
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
-
|
|
4
|
-
import { createTransformer, hasImportDeclaration } from '@atlaskit/codemod-utils';
|
|
5
|
-
|
|
6
|
-
import { BADGE_PACKAGE_NAME } from './internal/constants';
|
|
7
|
-
import { moveObjectAppearanceToStyle } from './internal/move-object-appearance-to-style';
|
|
8
|
-
|
|
9
|
-
const transformer = createTransformer(
|
|
10
|
-
[moveObjectAppearanceToStyle],
|
|
11
|
-
(j: JSCodeshift, source: Collection<Node>) => hasImportDeclaration(j, source, BADGE_PACKAGE_NAME),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export default transformer;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import transformer from '../15.0.0-lite-mode';
|
|
2
|
-
|
|
3
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
4
|
-
|
|
5
|
-
describe('badge codemod', () => {
|
|
6
|
-
defineInlineTest(
|
|
7
|
-
{ default: transformer, parser: 'tsx' },
|
|
8
|
-
{},
|
|
9
|
-
`
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import Badge from '@atlaskit/badge';
|
|
12
|
-
|
|
13
|
-
const App = () => {
|
|
14
|
-
return (
|
|
15
|
-
<Badge
|
|
16
|
-
appearance={{ backgroundColor: 'red' }}
|
|
17
|
-
>
|
|
18
|
-
{10}
|
|
19
|
-
</Badge>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
`,
|
|
23
|
-
`
|
|
24
|
-
import React from 'react';
|
|
25
|
-
import Badge from '@atlaskit/badge';
|
|
26
|
-
|
|
27
|
-
const App = () => {
|
|
28
|
-
return (
|
|
29
|
-
<Badge
|
|
30
|
-
style={{
|
|
31
|
-
backgroundColor: { backgroundColor: 'red' }["backgroundColor"],
|
|
32
|
-
color: { backgroundColor: 'red' }["textColor"]
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
{10}
|
|
36
|
-
</Badge>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
`,
|
|
40
|
-
`should move object appearance values to style prop`,
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
defineInlineTest(
|
|
44
|
-
{ default: transformer, parser: 'tsx' },
|
|
45
|
-
{},
|
|
46
|
-
`
|
|
47
|
-
import React from 'react';
|
|
48
|
-
import Badge from '@atlaskit/custom-badge';
|
|
49
|
-
|
|
50
|
-
const App = () => {
|
|
51
|
-
return (
|
|
52
|
-
<Badge
|
|
53
|
-
appearance={{ backgroundColor: 'red' }}
|
|
54
|
-
>
|
|
55
|
-
{10}
|
|
56
|
-
</Badge>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
`
|
|
61
|
-
import React from 'react';
|
|
62
|
-
import Badge from '@atlaskit/custom-badge';
|
|
63
|
-
|
|
64
|
-
const App = () => {
|
|
65
|
-
return (
|
|
66
|
-
<Badge
|
|
67
|
-
appearance={{ backgroundColor: 'red' }}
|
|
68
|
-
>
|
|
69
|
-
{10}
|
|
70
|
-
</Badge>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
`,
|
|
74
|
-
`should should not make modifications when not imported from "@atlaskit/badge"`,
|
|
75
|
-
);
|
|
76
|
-
});
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
-
|
|
3
|
-
import { moveObjectAppearanceToStyle } from '../internal/move-object-appearance-to-style';
|
|
4
|
-
|
|
5
|
-
const transformer = createTransformer([moveObjectAppearanceToStyle]);
|
|
6
|
-
|
|
7
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
-
|
|
9
|
-
describe('#moveObjectAppearanceToStyle', () => {
|
|
10
|
-
defineInlineTest(
|
|
11
|
-
{ default: transformer, parser: 'tsx' },
|
|
12
|
-
{},
|
|
13
|
-
`
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import Badge from '@atlaskit/badge';
|
|
16
|
-
|
|
17
|
-
const App = () => {
|
|
18
|
-
return (
|
|
19
|
-
<Badge
|
|
20
|
-
appearance={{ backgroundColor: 'red' }}
|
|
21
|
-
>
|
|
22
|
-
{10}
|
|
23
|
-
</Badge>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
`,
|
|
27
|
-
`
|
|
28
|
-
import React from 'react';
|
|
29
|
-
import Badge from '@atlaskit/badge';
|
|
30
|
-
|
|
31
|
-
const App = () => {
|
|
32
|
-
return (
|
|
33
|
-
<Badge
|
|
34
|
-
style={{
|
|
35
|
-
backgroundColor: { backgroundColor: 'red' }["backgroundColor"],
|
|
36
|
-
color: { backgroundColor: 'red' }["textColor"]
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
{10}
|
|
40
|
-
</Badge>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
`should move object appearance values to style prop`,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
defineInlineTest(
|
|
48
|
-
{ default: transformer, parser: 'tsx' },
|
|
49
|
-
{},
|
|
50
|
-
`
|
|
51
|
-
import React from 'react';
|
|
52
|
-
import Badge from '@atlaskit/badge';
|
|
53
|
-
|
|
54
|
-
const App = () => {
|
|
55
|
-
return (
|
|
56
|
-
<Badge
|
|
57
|
-
appearance="default"
|
|
58
|
-
>
|
|
59
|
-
{10}
|
|
60
|
-
</Badge>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
`,
|
|
64
|
-
`
|
|
65
|
-
import React from 'react';
|
|
66
|
-
import Badge from '@atlaskit/badge';
|
|
67
|
-
|
|
68
|
-
const App = () => {
|
|
69
|
-
return (
|
|
70
|
-
<Badge
|
|
71
|
-
appearance="default"
|
|
72
|
-
>
|
|
73
|
-
{10}
|
|
74
|
-
</Badge>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
`,
|
|
78
|
-
`should not make modifications when appearance prop is not type of object`,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
defineInlineTest(
|
|
82
|
-
{ default: transformer, parser: 'tsx' },
|
|
83
|
-
{},
|
|
84
|
-
`
|
|
85
|
-
import React from 'react';
|
|
86
|
-
import Badge from '@atlaskit/badge';
|
|
87
|
-
|
|
88
|
-
const App = (props) => {
|
|
89
|
-
return (
|
|
90
|
-
<Badge
|
|
91
|
-
appearance={props.appearance}
|
|
92
|
-
>
|
|
93
|
-
{10}
|
|
94
|
-
</Badge>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
`,
|
|
98
|
-
`
|
|
99
|
-
import React from 'react';
|
|
100
|
-
import Badge from '@atlaskit/badge';
|
|
101
|
-
|
|
102
|
-
const App = (props) => {
|
|
103
|
-
return (
|
|
104
|
-
<Badge
|
|
105
|
-
appearance={props.appearance}
|
|
106
|
-
>
|
|
107
|
-
{10}
|
|
108
|
-
</Badge>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
`,
|
|
112
|
-
`should not make modifications when appearance prop is dynamic`,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
defineInlineTest(
|
|
116
|
-
{ default: transformer, parser: 'tsx' },
|
|
117
|
-
{},
|
|
118
|
-
`
|
|
119
|
-
import React from 'react';
|
|
120
|
-
import Badge from '@atlaskit/badge';
|
|
121
|
-
|
|
122
|
-
const App = () => {
|
|
123
|
-
return (
|
|
124
|
-
<Badge
|
|
125
|
-
style={{ backgroundColor: 'red' }}
|
|
126
|
-
>
|
|
127
|
-
{10}
|
|
128
|
-
</Badge>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
`,
|
|
132
|
-
`
|
|
133
|
-
import React from 'react';
|
|
134
|
-
import Badge from '@atlaskit/badge';
|
|
135
|
-
|
|
136
|
-
const App = () => {
|
|
137
|
-
return (
|
|
138
|
-
<Badge
|
|
139
|
-
style={{ backgroundColor: 'red' }}
|
|
140
|
-
>
|
|
141
|
-
{10}
|
|
142
|
-
</Badge>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
`,
|
|
146
|
-
`should not make modifications when appearance prop is not present`,
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
defineInlineTest(
|
|
150
|
-
{ default: transformer, parser: 'tsx' },
|
|
151
|
-
{},
|
|
152
|
-
`
|
|
153
|
-
import React from 'react';
|
|
154
|
-
import Badge from '@atlaskit/badge';
|
|
155
|
-
|
|
156
|
-
const App = () => {
|
|
157
|
-
return (
|
|
158
|
-
<Badge
|
|
159
|
-
appearance="default"
|
|
160
|
-
style={{ backgroundColor: 'red' }}
|
|
161
|
-
>
|
|
162
|
-
{10}
|
|
163
|
-
</Badge>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
`,
|
|
167
|
-
`
|
|
168
|
-
import React from 'react';
|
|
169
|
-
import Badge from '@atlaskit/badge';
|
|
170
|
-
|
|
171
|
-
const App = () => {
|
|
172
|
-
return (
|
|
173
|
-
<Badge
|
|
174
|
-
appearance="default"
|
|
175
|
-
style={{ backgroundColor: 'red' }}
|
|
176
|
-
>
|
|
177
|
-
{10}
|
|
178
|
-
</Badge>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
`,
|
|
182
|
-
`should not make modifications when appearance prop is not type of object and style prop is also present`,
|
|
183
|
-
);
|
|
184
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { ASTPath, default as core, JSXAttribute, JSXElement } from 'jscodeshift';
|
|
2
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
-
|
|
4
|
-
import { getDefaultSpecifier, getJSXAttributesByName } from '@atlaskit/codemod-utils';
|
|
5
|
-
|
|
6
|
-
import { APPEARANCE_PROP_NAME, BADGE_PACKAGE_NAME, STYLE_PROP_NAME } from './constants';
|
|
7
|
-
|
|
8
|
-
export const moveObjectAppearanceToStyle = (j: core.JSCodeshift, source: Collection<Node>) => {
|
|
9
|
-
const defaultSpecifier = getDefaultSpecifier(j, source, BADGE_PACKAGE_NAME);
|
|
10
|
-
|
|
11
|
-
if (!defaultSpecifier) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
source.findJSXElements(defaultSpecifier).forEach((element: ASTPath<JSXElement>) => {
|
|
16
|
-
getJSXAttributesByName(j, element, APPEARANCE_PROP_NAME).forEach(
|
|
17
|
-
(attribute: ASTPath<JSXAttribute>) => {
|
|
18
|
-
const { value } = attribute.node;
|
|
19
|
-
if (!value) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
switch (value.type) {
|
|
24
|
-
case 'JSXExpressionContainer':
|
|
25
|
-
const { expression: appearanceExpression } = value;
|
|
26
|
-
|
|
27
|
-
if (appearanceExpression.type === 'ObjectExpression') {
|
|
28
|
-
const styleAttributes = getJSXAttributesByName(j, element, STYLE_PROP_NAME);
|
|
29
|
-
|
|
30
|
-
if (styleAttributes.length === 0) {
|
|
31
|
-
j(element)
|
|
32
|
-
.find(j.JSXOpeningElement)
|
|
33
|
-
.forEach((openingElement) => {
|
|
34
|
-
openingElement.node.attributes?.push(
|
|
35
|
-
j.jsxAttribute(
|
|
36
|
-
j.jsxIdentifier(STYLE_PROP_NAME),
|
|
37
|
-
j.jsxExpressionContainer(getMappedAppearance(j, appearanceExpression)),
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
j(attribute).remove();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function getMappedAppearance(
|
|
54
|
-
j: core.JSCodeshift,
|
|
55
|
-
expression: Parameters<typeof j.memberExpression>[0],
|
|
56
|
-
) {
|
|
57
|
-
const backgroundColorMemberExpression = j.memberExpression(
|
|
58
|
-
expression,
|
|
59
|
-
j.stringLiteral('backgroundColor'),
|
|
60
|
-
);
|
|
61
|
-
backgroundColorMemberExpression.computed = true;
|
|
62
|
-
|
|
63
|
-
const textColorMemberExpression = j.memberExpression(expression, j.stringLiteral('textColor'));
|
|
64
|
-
textColorMemberExpression.computed = true;
|
|
65
|
-
|
|
66
|
-
return j.objectExpression([
|
|
67
|
-
j.objectProperty(j.identifier('backgroundColor'), backgroundColorMemberExpression),
|
|
68
|
-
j.objectProperty(j.identifier('color'), textColorMemberExpression),
|
|
69
|
-
]);
|
|
70
|
-
}
|