@carbon/upgrade 11.22.0 → 11.23.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.
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import { TileGroup, RadioTile, Stack } from '@carbon/react';
3
+ import { FeatureFlags } from '@carbon/feature-flags';
4
+
5
+ function TestComponent() {
6
+ return (
7
+ //prettier-ignore
8
+ (<div>
9
+ {/* Case 1: Unwrapped TileGroup */}
10
+ <FeatureFlags enableV12TileRadioIcons><TileGroup legend="TestGroup" name="test">
11
+ <RadioTile id="test-1" value="test-1">
12
+ Option 1
13
+ </RadioTile>
14
+ <RadioTile id="test-2" value="test-2">
15
+ Option 2
16
+ </RadioTile>
17
+ </TileGroup></FeatureFlags>
18
+ {/* Wrapped standalone missing flag prop */}
19
+ <FeatureFlags enableV12TileRadioIcons>
20
+ <TileGroup legend="Missing Attribute" name="wrapped">
21
+ <RadioTile id="wrapped-1" value="wrapped-1">
22
+ Already Wrapped Option 1
23
+ </RadioTile>
24
+ <RadioTile id="wrapped-2" value="wrapped-2">
25
+ Already Wrapped Option 2
26
+ </RadioTile>
27
+ </TileGroup>
28
+ </FeatureFlags>
29
+ {/* Case 3: Already wrapped with other attributes */}
30
+ <FeatureFlags enable-v12-tile-default-icons enableV12TileRadioIcons>
31
+ <TileGroup legend="Other Attribute" name="other-wrapped">
32
+ <RadioTile id="other-1" value="other-1">
33
+ Other Flag Option 1
34
+ </RadioTile>
35
+ </TileGroup>
36
+ </FeatureFlags>
37
+ {/* Case 4: Already wrapped with correct attribute */}
38
+ <FeatureFlags enableV12TileRadioIcons>
39
+ <TileGroup legend="Correct Wrapped" name="correct">
40
+ <RadioTile id="correct-1" value="correct-1">
41
+ Correctly Wrapped Option
42
+ </RadioTile>
43
+ </TileGroup>
44
+ </FeatureFlags>
45
+ {/* Case 5: Standalone RadioTiles with different scenarios */}
46
+ <Stack>
47
+ {/* Unwrapped standalone */}
48
+ <FeatureFlags enableV12TileRadioIcons><RadioTile id="standalone" value="standalone">
49
+ Standalone Tile
50
+ </RadioTile></FeatureFlags>
51
+ {/* Wrapped standalone missing flag prop */}
52
+ <FeatureFlags enableV12TileRadioIcons>
53
+ <RadioTile id="wrapped-standalone" value="wrapped-standalone">
54
+ Wrapped Standalone
55
+ </RadioTile>
56
+ </FeatureFlags>
57
+ {/* Wrapped standalone with other flag */}
58
+ <FeatureFlags enable-v12-tile-default-icons enableV12TileRadioIcons>
59
+ <RadioTile id="other-standalone" value="other-standalone">
60
+ Other Flag Standalone
61
+ </RadioTile>
62
+ </FeatureFlags>
63
+ {/* Correctly wrapped standalone */}
64
+ <FeatureFlags enableV12TileRadioIcons>
65
+ <RadioTile id="correct-standalone" value="correct-standalone">
66
+ Correct Standalone
67
+ </RadioTile>
68
+ </FeatureFlags>
69
+ </Stack>
70
+ {/* Case 6: Nested structures */}
71
+ <div className="nested">
72
+ <FeatureFlags enableV12TileRadioIcons><TileGroup legend="Nested Group" name="nested">
73
+ <div className="wrapper">
74
+ <RadioTile id="nested-1" value="nested-1">
75
+ Nested Option 1
76
+ </RadioTile>
77
+ </div>
78
+ <RadioTile id="nested-2" value="nested-2">
79
+ Nested Option 2
80
+ </RadioTile>
81
+ </TileGroup></FeatureFlags>
82
+ </div>
83
+ </div>)
84
+ );
85
+ }
86
+
87
+ export default TestComponent;
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import { TileGroup, RadioTile, Stack } from '@carbon/react';
3
+ import { FeatureFlags } from '@carbon/feature-flags';
4
+
5
+ const TestComponent: React.FC = () => {
6
+ return (
7
+ //prettier-ignore
8
+ (<div>
9
+ {/* Case 1: Unwrapped TileGroup */}
10
+ <FeatureFlags enableV12TileRadioIcons><TileGroup legend="TestGroup" name="test">
11
+ <RadioTile id="test-1" value="test-1">
12
+ Option 1
13
+ </RadioTile>
14
+ <RadioTile id="test-2" value="test-2">
15
+ Option 2
16
+ </RadioTile>
17
+ </TileGroup></FeatureFlags>
18
+ {/* Wrapped standalone missing flag prop */}
19
+ <FeatureFlags enableV12TileRadioIcons>
20
+ <TileGroup legend="Missing Attribute" name="wrapped">
21
+ <RadioTile id="wrapped-1" value="wrapped-1">
22
+ Already Wrapped Option 1
23
+ </RadioTile>
24
+ <RadioTile id="wrapped-2" value="wrapped-2">
25
+ Already Wrapped Option 2
26
+ </RadioTile>
27
+ </TileGroup>
28
+ </FeatureFlags>
29
+ {/* Case 3: Already wrapped with other flags */}
30
+ <FeatureFlags enable-v12-tile-default-icons enableV12TileRadioIcons>
31
+ <TileGroup legend="Other Attribute" name="other-wrapped">
32
+ <RadioTile id="other-1" value="other-1">
33
+ Other Flag Option 1
34
+ </RadioTile>
35
+ </TileGroup>
36
+ </FeatureFlags>
37
+ {/* Case 4: Already wrapped with correct flag */}
38
+ <FeatureFlags enableV12TileRadioIcons>
39
+ <TileGroup legend="Correct Wrapped" name="correct">
40
+ <RadioTile id="correct-1" value="correct-1">
41
+ Correctly Wrapped Option
42
+ </RadioTile>
43
+ </TileGroup>
44
+ </FeatureFlags>
45
+ {/* Case 5: Standalone RadioTiles with different scenarios */}
46
+ <Stack>
47
+ {/* Unwrapped standalone */}
48
+ <FeatureFlags enableV12TileRadioIcons><RadioTile id="standalone" value="standalone">
49
+ Standalone Tile
50
+ </RadioTile></FeatureFlags>
51
+ {/* Wrapped standalone missing flag prop */}
52
+ <FeatureFlags enableV12TileRadioIcons>
53
+ <RadioTile id="wrapped-standalone" value="wrapped-standalone">
54
+ Wrapped Standalone
55
+ </RadioTile>
56
+ </FeatureFlags>
57
+ {/* Wrapped standalone with other flag */}
58
+ <FeatureFlags enable-v12-tile-default-icons enableV12TileRadioIcons>
59
+ <RadioTile id="other-standalone" value="other-standalone">
60
+ Other Flag Standalone radio
61
+ </RadioTile>
62
+ </FeatureFlags>
63
+ {/* Correctly wrapped standalone */}
64
+ <FeatureFlags enableV12TileRadioIcons>
65
+ <RadioTile id="correct-standalone" value="correct-standalone">
66
+ Correct Standalone
67
+ </RadioTile>
68
+ </FeatureFlags>
69
+ </Stack>
70
+ {/* Case 6: Nested structures */}
71
+ <div className="nested">
72
+ <FeatureFlags enableV12TileRadioIcons><TileGroup legend="Nested Group" name="nested">
73
+ <div className="wrapper">
74
+ <RadioTile id="nested-1" value="nested-1">
75
+ Nested Option 1
76
+ </RadioTile>
77
+ </div>
78
+ <RadioTile id="nested-2" value="nested-2">
79
+ Nested Option 2
80
+ </RadioTile>
81
+ </TileGroup></FeatureFlags>
82
+ </div>
83
+ </div>)
84
+ );
85
+ };
86
+
87
+ export default TestComponent;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { Dropdown, Checkbox, Tag } from '@carbon/react';
3
+
4
+ function TestComponent() {
5
+ return (
6
+ //prettier-ignore
7
+ <div>
8
+ {/* Basic Dropdown usage */}
9
+ <Dropdown
10
+ label="Select an option"
11
+ slug="dropdown-1"
12
+ items={['Option 1', 'Option 2']}
13
+ id="dropdown-1"
14
+ titleText="Dropdown"
15
+ />
16
+ {/* Checkbox with expression */}
17
+ <Checkbox
18
+ labelText="Check me"
19
+ slug={'checkbox-1'}
20
+ id="checkbox-1"
21
+ />
22
+ {/* Tag with string literal */}
23
+ <Tag slug={'static-tag'} type="red">
24
+ Important
25
+ </Tag>
26
+ {/* Nested structure */}
27
+ <div>
28
+ <Tag slug="tag-1" type="blue">
29
+ Active
30
+ </Tag>
31
+ <Checkbox
32
+ slug="checkbox-2"
33
+ labelText="Enable feature"
34
+ id="checkbox-2"
35
+ />
36
+ </div>
37
+ </div>
38
+ );
39
+ }
40
+
41
+ export default TestComponent;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { Dropdown, Checkbox, Tag } from '@carbon/react';
3
+
4
+ const TestComponent: React.FC = () => {
5
+ return (
6
+ //prettier-ignore
7
+ <div>
8
+ {/* Basic Dropdown usage */}
9
+ <Dropdown
10
+ label="Select an option"
11
+ slug="dropdown-1"
12
+ items={['Option 1', 'Option 2']}
13
+ id="dropdown-1"
14
+ titleText="Dropdown"
15
+ />
16
+ {/* Checkbox with expression */}
17
+ <Checkbox
18
+ labelText="Check me"
19
+ slug={'checkbox-1'}
20
+ id="checkbox-1"
21
+ />
22
+ {/* Tag with string literal */}
23
+ <Tag slug={'static-tag'} type="red">
24
+ Important
25
+ </Tag>
26
+ {/* Nested structure */}
27
+ <div>
28
+ <Tag slug="tag-1" type="blue">
29
+ Active
30
+ </Tag>
31
+ <Checkbox
32
+ slug="checkbox-2"
33
+ labelText="Enable feature"
34
+ id="checkbox-2"
35
+ />
36
+ </div>
37
+ </div>
38
+ );
39
+ };
40
+
41
+ export default TestComponent;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { Dropdown, Checkbox, Tag } from '@carbon/react';
3
+
4
+ function TestComponent() {
5
+ return (
6
+ //prettier-ignore
7
+ (<div>
8
+ {/* Basic Dropdown usage */}
9
+ <Dropdown
10
+ label="Select an option"
11
+ decorator="dropdown-1"
12
+ items={['Option 1', 'Option 2']}
13
+ id="dropdown-1"
14
+ titleText="Dropdown"
15
+ />
16
+ {/* Checkbox with expression */}
17
+ <Checkbox
18
+ labelText="Check me"
19
+ decorator={'checkbox-1'}
20
+ id="checkbox-1"
21
+ />
22
+ {/* Tag with string literal */}
23
+ <Tag decorator={'static-tag'} type="red">
24
+ Important
25
+ </Tag>
26
+ {/* Nested structure */}
27
+ <div>
28
+ <Tag decorator="tag-1" type="blue">
29
+ Active
30
+ </Tag>
31
+ <Checkbox
32
+ decorator="checkbox-2"
33
+ labelText="Enable feature"
34
+ id="checkbox-2"
35
+ />
36
+ </div>
37
+ </div>)
38
+ );
39
+ }
40
+
41
+ export default TestComponent;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { Dropdown, Checkbox, Tag } from '@carbon/react';
3
+
4
+ const TestComponent: React.FC = () => {
5
+ return (
6
+ //prettier-ignore
7
+ (<div>
8
+ {/* Basic Dropdown usage */}
9
+ <Dropdown
10
+ label="Select an option"
11
+ decorator="dropdown-1"
12
+ items={['Option 1', 'Option 2']}
13
+ id="dropdown-1"
14
+ titleText="Dropdown"
15
+ />
16
+ {/* Checkbox with expression */}
17
+ <Checkbox
18
+ labelText="Check me"
19
+ decorator={'checkbox-1'}
20
+ id="checkbox-1"
21
+ />
22
+ {/* Tag with string literal */}
23
+ <Tag decorator={'static-tag'} type="red">
24
+ Important
25
+ </Tag>
26
+ {/* Nested structure */}
27
+ <div>
28
+ <Tag decorator="tag-1" type="blue">
29
+ Active
30
+ </Tag>
31
+ <Checkbox
32
+ decorator="checkbox-2"
33
+ labelText="Enable feature"
34
+ id="checkbox-2"
35
+ />
36
+ </div>
37
+ </div>)
38
+ );
39
+ };
40
+
41
+ export default TestComponent;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ const { defineTest } = require('jscodeshift/dist/testUtils');
11
+
12
+ defineTest(__dirname, 'enable-v12-tile-default-icons');
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ const { defineTest } = require('jscodeshift/dist/testUtils');
11
+
12
+ defineTest(__dirname, 'enable-v12-tile-radio-icons');
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ const { defineTest } = require('jscodeshift/dist/testUtils');
11
+
12
+ defineTest(__dirname, 'slug-prop-to-decorator-prop');
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * Migrate Tile components by wrapping them with FeatureFlags
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const defaultOptions = {
13
+ quote: 'single',
14
+ trailingComma: true,
15
+ };
16
+
17
+ function transform(fileInfo, api, options) {
18
+ const j = api.jscodeshift;
19
+ const root = j(fileInfo.source);
20
+ const printOptions = options.printOptions || defaultOptions;
21
+
22
+ // Early return if no Tile components found
23
+ if (
24
+ !root
25
+ .find(j.JSXElement, { openingElement: { name: { name: 'Tile' } } })
26
+ .size()
27
+ ) {
28
+ return null;
29
+ }
30
+
31
+ let needsFeatureFlagsImport = false;
32
+
33
+ // First update all existing FeatureFlags wrappers that need the attribute
34
+ root
35
+ .find(j.JSXElement, {
36
+ openingElement: { name: { name: 'FeatureFlags' } },
37
+ })
38
+ .forEach((path) => {
39
+ const hasTileInside =
40
+ j(path)
41
+ .find(j.JSXElement, {
42
+ openingElement: { name: { name: 'Tile' } },
43
+ })
44
+ .size() > 0;
45
+
46
+ const hasTileGroupWithTile =
47
+ j(path)
48
+ .find(j.JSXElement, {
49
+ openingElement: { name: { name: 'TileGroup' } },
50
+ })
51
+ .filter((tileGroupPath) => {
52
+ return (
53
+ j(tileGroupPath)
54
+ .find(j.JSXElement, {
55
+ openingElement: { name: { name: 'Tile' } },
56
+ })
57
+ .size() > 0
58
+ );
59
+ })
60
+ .size() > 0;
61
+
62
+ if (hasTileInside || hasTileGroupWithTile) {
63
+ const hasAttribute = path.node.openingElement.attributes.some(
64
+ (attr) =>
65
+ attr.type === 'JSXAttribute' &&
66
+ attr.name.name === 'enableV12TileDefaultIcons'
67
+ );
68
+
69
+ if (!hasAttribute) {
70
+ path.node.openingElement.attributes.push(
71
+ j.jsxAttribute(j.jsxIdentifier('enableV12TileDefaultIcons'))
72
+ );
73
+ needsFeatureFlagsImport = true;
74
+ }
75
+ }
76
+ });
77
+
78
+ // Handle Tiles within TileGroups
79
+ root
80
+ .find(j.JSXElement, {
81
+ openingElement: { name: { name: 'TileGroup' } },
82
+ })
83
+ .forEach((path) => {
84
+ const hasTile =
85
+ j(path)
86
+ .find(j.JSXElement, {
87
+ openingElement: { name: { name: 'Tile' } },
88
+ })
89
+ .size() > 0;
90
+
91
+ const wrappingFeatureFlags = j(path).closest(j.JSXElement, {
92
+ openingElement: { name: { name: 'FeatureFlags' } },
93
+ });
94
+
95
+ if (hasTile) {
96
+ if (wrappingFeatureFlags.size() === 0) {
97
+ // Not wrapped, add wrapper
98
+ const featureFlagsWrapper = j.jsxElement(
99
+ j.jsxOpeningElement(
100
+ j.jsxIdentifier('FeatureFlags'),
101
+ [j.jsxAttribute(j.jsxIdentifier('enableV12TileDefaultIcons'))],
102
+ false
103
+ ),
104
+ j.jsxClosingElement(j.jsxIdentifier('FeatureFlags')),
105
+ [path.node]
106
+ );
107
+
108
+ j(path).replaceWith(featureFlagsWrapper);
109
+ needsFeatureFlagsImport = true;
110
+ }
111
+ }
112
+ });
113
+
114
+ // Handle standalone Tiles
115
+ root
116
+ .find(j.JSXElement, {
117
+ openingElement: { name: { name: 'Tile' } },
118
+ })
119
+ .forEach((path) => {
120
+ const isInsideTileGroup =
121
+ j(path)
122
+ .closest(j.JSXElement, {
123
+ openingElement: { name: { name: 'TileGroup' } },
124
+ })
125
+ .size() > 0;
126
+
127
+ const wrappingFeatureFlags = j(path).closest(j.JSXElement, {
128
+ openingElement: { name: { name: 'FeatureFlags' } },
129
+ });
130
+
131
+ if (!isInsideTileGroup) {
132
+ if (wrappingFeatureFlags.size() === 0) {
133
+ // Not wrapped, add wrapper
134
+ const featureFlagsWrapper = j.jsxElement(
135
+ j.jsxOpeningElement(
136
+ j.jsxIdentifier('FeatureFlags'),
137
+ [j.jsxAttribute(j.jsxIdentifier('enableV12TileDefaultIcons'))],
138
+ false
139
+ ),
140
+ j.jsxClosingElement(j.jsxIdentifier('FeatureFlags')),
141
+ [path.node]
142
+ );
143
+
144
+ j(path).replaceWith(featureFlagsWrapper);
145
+ needsFeatureFlagsImport = true;
146
+ }
147
+ }
148
+ });
149
+
150
+ // Add FeatureFlags import only if we've added wrappers or attributes
151
+ if (needsFeatureFlagsImport) {
152
+ const hasFeatureFlagsImport =
153
+ root
154
+ .find(j.ImportDeclaration, {
155
+ source: { value: '@carbon/feature-flags' },
156
+ })
157
+ .size() > 0;
158
+
159
+ if (!hasFeatureFlagsImport) {
160
+ // Find the last import declaration
161
+ const lastImport = root.find(j.ImportDeclaration).at(-1);
162
+ const featureFlagsImport = j.importDeclaration(
163
+ [j.importSpecifier(j.identifier('FeatureFlags'))],
164
+ j.literal('@carbon/feature-flags')
165
+ );
166
+
167
+ if (lastImport.size() > 0) {
168
+ // Add newline after the last import
169
+ const newline = j.template.statement`\n`;
170
+ lastImport.insertAfter(newline);
171
+ lastImport.insertAfter(featureFlagsImport);
172
+ } else {
173
+ // If no imports exist, add at the beginning of the file
174
+ root.get().node.program.body.unshift(featureFlagsImport);
175
+ }
176
+ }
177
+ }
178
+
179
+ return root.toSource(printOptions);
180
+ }
181
+
182
+ module.exports = transform;
183
+ module.exports.parser = 'tsx';