@atlaskit/lozenge 11.13.1 → 11.13.3
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 +6 -4
- package/codemods/11.0.0-lite-mode.tsx +0 -15
- package/codemods/__tests__/11.0.0-move-object-appearance-to-style.test.tsx +0 -172
- package/codemods/__tests__/11.0.0-remove-theme-prop.test.tsx +0 -93
- package/codemods/migrations/11.0.0-lite-mode/move-object-appearance-to-style.tsx +0 -69
- package/codemods/migrations/11.0.0-lite-mode/remove-theme-prop.tsx +0 -18
- package/codemods/utils.tsx +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/lozenge
|
|
2
2
|
|
|
3
|
+
## 11.13.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#113045](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113045)
|
|
8
|
+
[`2c88e65615d04`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2c88e65615d04) -
|
|
9
|
+
Update dependencies and remove old codemods.
|
|
10
|
+
|
|
11
|
+
## 11.13.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 11.13.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/lozenge",
|
|
3
|
-
"version": "11.13.
|
|
3
|
+
"version": "11.13.3",
|
|
4
4
|
"description": "A lozenge is a visual indicator used to highlight an item's status for quick recognition.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
42
42
|
"@atlaskit/css": "^0.8.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.0.0",
|
|
44
|
-
"@atlaskit/primitives": "^13.
|
|
45
|
-
"@atlaskit/theme": "^
|
|
44
|
+
"@atlaskit/primitives": "^13.5.0",
|
|
45
|
+
"@atlaskit/theme": "^15.0.0",
|
|
46
46
|
"@atlaskit/tokens": "^3.3.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"@compiled/react": "^0.18.1",
|
|
@@ -55,10 +55,12 @@
|
|
|
55
55
|
"@af/accessibility-testing": "*",
|
|
56
56
|
"@af/integration-testing": "*",
|
|
57
57
|
"@af/visual-regression": "*",
|
|
58
|
+
"@atlaskit/docs": "*",
|
|
58
59
|
"@atlaskit/ds-lib": "^3.5.0",
|
|
59
60
|
"@atlaskit/heading": "^4.1.0",
|
|
61
|
+
"@atlaskit/link": "*",
|
|
62
|
+
"@atlaskit/section-message": "*",
|
|
60
63
|
"@atlaskit/ssr": "*",
|
|
61
|
-
"@atlaskit/visual-regression": "*",
|
|
62
64
|
"@testing-library/react": "^13.4.0",
|
|
63
65
|
"jscodeshift": "^0.13.0",
|
|
64
66
|
"react-dom": "^18.2.0",
|
|
@@ -1,15 +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 moveObjectAppearanceToStyle from './migrations/11.0.0-lite-mode/move-object-appearance-to-style';
|
|
7
|
-
import removeThemeProp from './migrations/11.0.0-lite-mode/remove-theme-prop';
|
|
8
|
-
|
|
9
|
-
const transformer = createTransformer(
|
|
10
|
-
[moveObjectAppearanceToStyle, removeThemeProp],
|
|
11
|
-
(j: JSCodeshift, source: Collection<Node>) =>
|
|
12
|
-
hasImportDeclaration(j, source, '@atlaskit/lozenge'),
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export default transformer;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import transformer from '../11.0.0-lite-mode';
|
|
2
|
-
|
|
3
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
4
|
-
|
|
5
|
-
describe('Lozenge codemod', () => {
|
|
6
|
-
defineInlineTest(
|
|
7
|
-
{ default: transformer, parser: 'tsx' },
|
|
8
|
-
{},
|
|
9
|
-
`
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
12
|
-
|
|
13
|
-
const App = () => {
|
|
14
|
-
return (
|
|
15
|
-
<Lozenge
|
|
16
|
-
appearance={{ backgroundColor: 'yellow', textColor: 'blue' }}
|
|
17
|
-
>
|
|
18
|
-
Custom
|
|
19
|
-
</Lozenge>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
`,
|
|
23
|
-
`
|
|
24
|
-
import React from 'react';
|
|
25
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
26
|
-
|
|
27
|
-
const App = () => {
|
|
28
|
-
return (
|
|
29
|
-
<Lozenge
|
|
30
|
-
style={{
|
|
31
|
-
backgroundColor: { backgroundColor: 'yellow', textColor: 'blue' }["backgroundColor"],
|
|
32
|
-
color: { backgroundColor: 'yellow', textColor: 'blue' }["textColor"]
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
Custom
|
|
36
|
-
</Lozenge>
|
|
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 Lozenge from '@atlaskit/custom-lozenge';
|
|
49
|
-
|
|
50
|
-
const App = () => {
|
|
51
|
-
return (
|
|
52
|
-
<Lozenge
|
|
53
|
-
appearance={{ backgroundColor: 'yellow', textColor: 'blue' }}
|
|
54
|
-
>
|
|
55
|
-
Custom
|
|
56
|
-
</Lozenge>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
`
|
|
61
|
-
import React from 'react';
|
|
62
|
-
import Lozenge from '@atlaskit/custom-lozenge';
|
|
63
|
-
|
|
64
|
-
const App = () => {
|
|
65
|
-
return (
|
|
66
|
-
<Lozenge
|
|
67
|
-
appearance={{ backgroundColor: 'yellow', textColor: 'blue' }}
|
|
68
|
-
>
|
|
69
|
-
Custom
|
|
70
|
-
</Lozenge>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
`,
|
|
74
|
-
`should not be modified when not imported from "@atlaskit/lozenge"`,
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
defineInlineTest(
|
|
78
|
-
{ default: transformer, parser: 'tsx' },
|
|
79
|
-
{},
|
|
80
|
-
`
|
|
81
|
-
import React from 'react';
|
|
82
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
83
|
-
|
|
84
|
-
const App = () => {
|
|
85
|
-
return (
|
|
86
|
-
<Lozenge appearance='default'>
|
|
87
|
-
Custom
|
|
88
|
-
</Lozenge>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
`,
|
|
92
|
-
`
|
|
93
|
-
import React from 'react';
|
|
94
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
95
|
-
|
|
96
|
-
const App = () => {
|
|
97
|
-
return (
|
|
98
|
-
<Lozenge appearance='default'>
|
|
99
|
-
Custom
|
|
100
|
-
</Lozenge>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
`,
|
|
104
|
-
`should not be modified when appearance prop is not an object`,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
defineInlineTest(
|
|
108
|
-
{ default: transformer, parser: 'tsx' },
|
|
109
|
-
{},
|
|
110
|
-
`
|
|
111
|
-
import React from 'react';
|
|
112
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
113
|
-
|
|
114
|
-
const App = (props) => {
|
|
115
|
-
return (
|
|
116
|
-
<Lozenge appearance={props.appearance}>
|
|
117
|
-
Custom
|
|
118
|
-
</Lozenge>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
`,
|
|
122
|
-
`
|
|
123
|
-
import React from 'react';
|
|
124
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
125
|
-
|
|
126
|
-
const App = (props) => {
|
|
127
|
-
return (
|
|
128
|
-
<Lozenge appearance={props.appearance}>
|
|
129
|
-
Custom
|
|
130
|
-
</Lozenge>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
`,
|
|
134
|
-
`should not be modified when appearance prop is dynamic`,
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
defineInlineTest(
|
|
138
|
-
{ default: transformer, parser: 'tsx' },
|
|
139
|
-
{},
|
|
140
|
-
`
|
|
141
|
-
import React from 'react';
|
|
142
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
143
|
-
|
|
144
|
-
const App = () => {
|
|
145
|
-
return (
|
|
146
|
-
<Lozenge
|
|
147
|
-
appearance="default"
|
|
148
|
-
style={{ backgroundColor: 'red' }}
|
|
149
|
-
>
|
|
150
|
-
Custom
|
|
151
|
-
</Lozenge>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
`,
|
|
155
|
-
`
|
|
156
|
-
import React from 'react';
|
|
157
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
158
|
-
|
|
159
|
-
const App = () => {
|
|
160
|
-
return (
|
|
161
|
-
<Lozenge
|
|
162
|
-
appearance="default"
|
|
163
|
-
style={{ backgroundColor: 'red' }}
|
|
164
|
-
>
|
|
165
|
-
Custom
|
|
166
|
-
</Lozenge>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
`,
|
|
170
|
-
`should not be modified when appearance prop is not type of object and style prop is also present`,
|
|
171
|
-
);
|
|
172
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import transformer from '../11.0.0-lite-mode';
|
|
2
|
-
|
|
3
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
4
|
-
|
|
5
|
-
describe('remove theme prop', () => {
|
|
6
|
-
defineInlineTest(
|
|
7
|
-
{ default: transformer, parser: 'tsx' },
|
|
8
|
-
{},
|
|
9
|
-
`
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
12
|
-
import { useTheme } from '../../theme';
|
|
13
|
-
|
|
14
|
-
const LozengeTheme = (themeProps) => ({
|
|
15
|
-
dark: { backgroundColor: 'blue', color: 'white' },
|
|
16
|
-
light: { backgroundColor: 'blue', color: 'white' },
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const App = () => {
|
|
20
|
-
return (
|
|
21
|
-
<Lozenge theme={useTheme(LozengeTheme)}>
|
|
22
|
-
Custom
|
|
23
|
-
</Lozenge>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
`,
|
|
27
|
-
`
|
|
28
|
-
/* TODO: (from codemod)
|
|
29
|
-
We could not automatically convert this code to the new API.
|
|
30
|
-
|
|
31
|
-
This file uses \`Lozenge\`’s \`theme\` prop. This has been deprecated and removed.
|
|
32
|
-
|
|
33
|
-
You will have to change your usage to use the \`style\` prop.
|
|
34
|
-
See the example on https://atlaskit.atlassian.com/examples/design-system/lozenge/with-custom-theme */
|
|
35
|
-
import React from 'react';
|
|
36
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
37
|
-
import { useTheme } from '../../theme';
|
|
38
|
-
|
|
39
|
-
const LozengeTheme = (themeProps) => ({
|
|
40
|
-
dark: { backgroundColor: 'blue', color: 'white' },
|
|
41
|
-
light: { backgroundColor: 'blue', color: 'white' },
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const App = () => {
|
|
45
|
-
return (
|
|
46
|
-
<Lozenge>
|
|
47
|
-
Custom
|
|
48
|
-
</Lozenge>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
`should remove theme if it is defined inline`,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
defineInlineTest(
|
|
56
|
-
{ default: transformer, parser: 'tsx' },
|
|
57
|
-
{},
|
|
58
|
-
`
|
|
59
|
-
import React from 'react';
|
|
60
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
61
|
-
import { lozengeTheme } from '../../theme';
|
|
62
|
-
|
|
63
|
-
const App = () => {
|
|
64
|
-
return (
|
|
65
|
-
<Lozenge theme={lozengeTheme}>
|
|
66
|
-
Custom
|
|
67
|
-
</Lozenge>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
`,
|
|
71
|
-
`
|
|
72
|
-
/* TODO: (from codemod)
|
|
73
|
-
We could not automatically convert this code to the new API.
|
|
74
|
-
|
|
75
|
-
This file uses \`Lozenge\`’s \`theme\` prop. This has been deprecated and removed.
|
|
76
|
-
|
|
77
|
-
You will have to change your usage to use the \`style\` prop.
|
|
78
|
-
See the example on https://atlaskit.atlassian.com/examples/design-system/lozenge/with-custom-theme */
|
|
79
|
-
import React from 'react';
|
|
80
|
-
import Lozenge from '@atlaskit/lozenge';
|
|
81
|
-
import { lozengeTheme } from '../../theme';
|
|
82
|
-
|
|
83
|
-
const App = () => {
|
|
84
|
-
return (
|
|
85
|
-
<Lozenge>
|
|
86
|
-
Custom
|
|
87
|
-
</Lozenge>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
`,
|
|
91
|
-
`should remove theme if it is imported`,
|
|
92
|
-
);
|
|
93
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { type ASTPath, type JSCodeshift, type JSXAttribute, type JSXElement } from 'jscodeshift';
|
|
2
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
-
|
|
4
|
-
import { getDefaultSpecifier, getJSXAttributesByName } from '@atlaskit/codemod-utils';
|
|
5
|
-
|
|
6
|
-
const APPEARANCE_PROP_NAME = 'appearance';
|
|
7
|
-
|
|
8
|
-
const STYLE_PROP_NAME = 'style';
|
|
9
|
-
|
|
10
|
-
const moveObjectAppearanceToStyle = (j: JSCodeshift, source: Collection<Node>) => {
|
|
11
|
-
const defaultSpecifier = getDefaultSpecifier(j, source, '@atlaskit/lozenge');
|
|
12
|
-
|
|
13
|
-
if (!defaultSpecifier) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
source.findJSXElements(defaultSpecifier).forEach((element: ASTPath<JSXElement>) => {
|
|
18
|
-
getJSXAttributesByName(j, element, APPEARANCE_PROP_NAME).forEach(
|
|
19
|
-
(attribute: ASTPath<JSXAttribute>) => {
|
|
20
|
-
const { value } = attribute.node;
|
|
21
|
-
|
|
22
|
-
if (!value) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
switch (value.type) {
|
|
27
|
-
case 'JSXExpressionContainer':
|
|
28
|
-
const { expression: appearanceExpression } = value;
|
|
29
|
-
if (appearanceExpression.type === 'ObjectExpression') {
|
|
30
|
-
const styleAttributes = getJSXAttributesByName(j, element, STYLE_PROP_NAME);
|
|
31
|
-
|
|
32
|
-
if (styleAttributes.length === 0) {
|
|
33
|
-
j(element)
|
|
34
|
-
.find(j.JSXOpeningElement)
|
|
35
|
-
.forEach((openingElement) => {
|
|
36
|
-
openingElement.node.attributes?.push(
|
|
37
|
-
j.jsxAttribute(
|
|
38
|
-
j.jsxIdentifier(STYLE_PROP_NAME),
|
|
39
|
-
j.jsxExpressionContainer(getMappedAppearance(j, appearanceExpression)),
|
|
40
|
-
),
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
j(attribute).remove();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function getMappedAppearance(j: JSCodeshift, expression: Parameters<typeof j.memberExpression>[0]) {
|
|
54
|
-
const backgroundColorMemberExpression = j.memberExpression(
|
|
55
|
-
expression,
|
|
56
|
-
j.stringLiteral('backgroundColor'),
|
|
57
|
-
);
|
|
58
|
-
backgroundColorMemberExpression.computed = true;
|
|
59
|
-
|
|
60
|
-
const textColorMemberExpression = j.memberExpression(expression, j.stringLiteral('textColor'));
|
|
61
|
-
textColorMemberExpression.computed = true;
|
|
62
|
-
|
|
63
|
-
return j.objectExpression([
|
|
64
|
-
j.objectProperty(j.identifier('backgroundColor'), backgroundColorMemberExpression),
|
|
65
|
-
j.objectProperty(j.identifier('color'), textColorMemberExpression),
|
|
66
|
-
]);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default moveObjectAppearanceToStyle;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createRemoveFuncWithDefaultSpecifierFor } from '../../utils';
|
|
2
|
-
|
|
3
|
-
const comment = `
|
|
4
|
-
We could not automatically convert this code to the new API.
|
|
5
|
-
|
|
6
|
-
This file uses \`Lozenge\`’s \`theme\` prop. This has been deprecated and removed.
|
|
7
|
-
|
|
8
|
-
You will have to change your usage to use the \`style\` prop.
|
|
9
|
-
See the example on https://atlaskit.atlassian.com/examples/design-system/lozenge/with-custom-theme
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
const removeThemeProp = createRemoveFuncWithDefaultSpecifierFor(
|
|
13
|
-
'@atlaskit/lozenge',
|
|
14
|
-
'theme',
|
|
15
|
-
comment,
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export default removeThemeProp;
|
package/codemods/utils.tsx
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type core from 'jscodeshift';
|
|
2
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
addCommentToStartOfFile,
|
|
6
|
-
getDefaultSpecifier,
|
|
7
|
-
getJSXAttributesByName,
|
|
8
|
-
} from '@atlaskit/codemod-utils';
|
|
9
|
-
|
|
10
|
-
export const createRemoveFuncWithDefaultSpecifierFor =
|
|
11
|
-
(component: string, prop: string, comment?: string) =>
|
|
12
|
-
(j: core.JSCodeshift, source: Collection<Node>) => {
|
|
13
|
-
const specifier = getDefaultSpecifier(j, source, component);
|
|
14
|
-
|
|
15
|
-
if (!specifier) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
source.findJSXElements(specifier).forEach((element) => {
|
|
20
|
-
getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
|
|
21
|
-
if (comment) {
|
|
22
|
-
addCommentToStartOfFile({ j, base: source, message: comment });
|
|
23
|
-
}
|
|
24
|
-
j(attribute).remove();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
};
|