@ornikar/kitt-universal 27.5.1-canary.4d3ec9b2bbb3371c254ae88141f81bb445a59f73.0 → 27.5.1-canary.74b3661a3818b6b6b6cd66a9bf11ce3340651bb8.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/AGENTS.md +30 -0
- package/CHANGELOG.md +9 -5
- package/dist/definitions/TabBar/TabBar.d.ts +6 -4
- package/dist/definitions/TabBar/TabBar.d.ts.map +1 -1
- package/dist/definitions/TabBar/TabBarItem.d.ts +11 -1
- package/dist/definitions/TabBar/TabBarItem.d.ts.map +1 -1
- package/dist/definitions/native-base/KittNativeBaseProvider.d.ts +180 -12
- package/dist/definitions/native-base/KittNativeBaseProvider.d.ts.map +1 -1
- package/dist/definitions/themes/default.d.ts +1 -12
- package/dist/definitions/themes/default.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/icon.d.ts +0 -20
- package/dist/definitions/themes/late-ocean/icon.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/tabBar.d.ts +34 -0
- package/dist/definitions/themes/late-ocean/tabBar.d.ts.map +1 -0
- package/dist/definitions/typography/Typography.d.ts.map +1 -1
- package/dist/definitions/typography/TypographyIcon.d.ts.map +1 -1
- package/dist/definitions/typography/utils/getTypographyFamily.d.ts +2 -1
- package/dist/definitions/typography/utils/getTypographyFamily.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +565 -250
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +565 -250
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.17.cjs.js +456 -140
- package/dist/index-node-22.17.cjs.js.map +1 -1
- package/dist/index-node-22.17.cjs.web.js +457 -141
- package/dist/index-node-22.17.cjs.web.js.map +1 -1
- package/dist/index-node-22.17.es.mjs +456 -140
- package/dist/index-node-22.17.es.mjs.map +1 -1
- package/dist/index-node-22.17.es.web.mjs +457 -141
- package/dist/index-node-22.17.es.web.mjs.map +1 -1
- package/dist/index.es.js +567 -242
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +566 -241
- package/dist/index.es.web.js.map +1 -1
- package/dist/linaria-themes-metro.es.android.js +179 -36
- package/dist/linaria-themes-metro.es.android.js.map +1 -1
- package/dist/linaria-themes-metro.es.ios.js +179 -36
- package/dist/linaria-themes-metro.es.ios.js.map +1 -1
- package/dist/linaria-themes-node-22.17.cjs.js +179 -36
- package/dist/linaria-themes-node-22.17.cjs.js.map +1 -1
- package/dist/linaria-themes-node-22.17.cjs.web.js +179 -36
- package/dist/linaria-themes-node-22.17.cjs.web.js.map +1 -1
- package/dist/linaria-themes-node-22.17.es.mjs +179 -36
- package/dist/linaria-themes-node-22.17.es.mjs.map +1 -1
- package/dist/linaria-themes-node-22.17.es.web.mjs +179 -36
- package/dist/linaria-themes-node-22.17.es.web.mjs.map +1 -1
- package/dist/linaria-themes.es.js +179 -36
- package/dist/linaria-themes.es.js.map +1 -1
- package/dist/linaria-themes.es.web.js +179 -36
- package/dist/linaria-themes.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +2 -2
- package/scripts/codemods/__testfixtures__/csf1-csf2/decorator.input.tsx +11 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/decorator.output.tsx +17 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/default.input.tsx +88 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/default.output.tsx +94 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/new.input.tsx +77 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/new.output.tsx +92 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/parameters.input.tsx +21 -0
- package/scripts/codemods/__testfixtures__/csf1-csf2/parameters.output.tsx +28 -0
- package/scripts/codemods/__tests__/csf1-csf2.test.ts +10 -0
- package/scripts/codemods/card-modal.js +155 -0
- package/scripts/codemods/csf1-csf2.js +323 -0
- package/scripts/codemods/fullscreen-modal.js +155 -0
- package/scripts/codemods/navigation-modal.js +155 -0
- package/scripts/{run-transformers.js → run-codemods.js} +12 -12
- package/scripts/transformers/card-modal.js +0 -136
- package/scripts/transformers/fullscreen-modal.js +0 -138
- package/scripts/transformers/navigation-modal.js +0 -138
- /package/scripts/{transformers → codemods}/__testfixtures__/card-modal/basic.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/card-modal/basic.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/card-modal/withExpressions.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/card-modal/withExpressions.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/card-modal/wrongOrder.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/card-modal/wrongOrder.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/basic.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/basic.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/withExpressions.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/withExpressions.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/wrongOrder.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/wrongOrder.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/basic.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/basic.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/withExpressions.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/withExpressions.output.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/wrongOrder.input.js +0 -0
- /package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/wrongOrder.output.js +0 -0
- /package/scripts/{transformers → codemods}/__tests__/card-modal.test.js +0 -0
- /package/scripts/{transformers → codemods}/__tests__/fullscreen-modal.test.js +0 -0
- /package/scripts/{transformers → codemods}/__tests__/navigation-modal.test.js +0 -0
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Transform CardModal components from prop-based API to children-based API
|
|
4
|
-
// Converts header, body, and footer props to direct children elements
|
|
5
|
-
|
|
6
|
-
// Use local jscodeshift instance directly
|
|
7
|
-
const jscodeshift = require('jscodeshift');
|
|
8
|
-
const prettier = require('prettier');
|
|
9
|
-
|
|
10
|
-
module.exports = async function transformer(fileInfo, api) {
|
|
11
|
-
// Use the jscodeshift API to parse the file
|
|
12
|
-
const j = api.jscodeshift || jscodeshift;
|
|
13
|
-
|
|
14
|
-
// Parse the source code of the file
|
|
15
|
-
const root = j(fileInfo.source);
|
|
16
|
-
|
|
17
|
-
let hasChanges = false;
|
|
18
|
-
|
|
19
|
-
// ----------- Start of transformer logic
|
|
20
|
-
|
|
21
|
-
// Find all JSX elements with the name CardModal
|
|
22
|
-
root
|
|
23
|
-
.find(j.JSXElement, {
|
|
24
|
-
openingElement: {
|
|
25
|
-
name: {
|
|
26
|
-
name: 'CardModal',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
.forEach((path) => {
|
|
31
|
-
const element = path.value;
|
|
32
|
-
const openingElement = element.openingElement;
|
|
33
|
-
|
|
34
|
-
// Check if this CardModal has header, body, or footer props
|
|
35
|
-
const headerProp = openingElement.attributes.find(
|
|
36
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'header',
|
|
37
|
-
);
|
|
38
|
-
const bodyProp = openingElement.attributes.find(
|
|
39
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'body',
|
|
40
|
-
);
|
|
41
|
-
const footerProp = openingElement.attributes.find(
|
|
42
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'footer',
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
// Only transform if we have at least one of these props
|
|
46
|
-
if (!headerProp && !bodyProp && !footerProp) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
hasChanges = true;
|
|
51
|
-
|
|
52
|
-
// Create new children array in the correct order: header, body, footer
|
|
53
|
-
const newChildren = [];
|
|
54
|
-
|
|
55
|
-
// Add header child if it exists
|
|
56
|
-
if (headerProp && headerProp.value) {
|
|
57
|
-
if (headerProp.value.type === 'JSXExpressionContainer') {
|
|
58
|
-
const expression = headerProp.value.expression;
|
|
59
|
-
if (expression.type === 'JSXElement') {
|
|
60
|
-
// If it's a direct JSX element, add it as a direct child
|
|
61
|
-
newChildren.push(expression);
|
|
62
|
-
} else {
|
|
63
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
64
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
// If it's a direct JSX element, add it directly
|
|
68
|
-
newChildren.push(headerProp.value);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Add body child if it exists
|
|
73
|
-
if (bodyProp && bodyProp.value) {
|
|
74
|
-
if (bodyProp.value.type === 'JSXExpressionContainer') {
|
|
75
|
-
const expression = bodyProp.value.expression;
|
|
76
|
-
if (expression.type === 'JSXElement') {
|
|
77
|
-
// If it's a direct JSX element, add it as a direct child
|
|
78
|
-
newChildren.push(expression);
|
|
79
|
-
} else {
|
|
80
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
81
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
// If it's a direct JSX element, add it directly
|
|
85
|
-
newChildren.push(bodyProp.value);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Add footer child if it exists
|
|
90
|
-
if (footerProp && footerProp.value) {
|
|
91
|
-
if (footerProp.value.type === 'JSXExpressionContainer') {
|
|
92
|
-
const expression = footerProp.value.expression;
|
|
93
|
-
if (expression.type === 'JSXElement') {
|
|
94
|
-
// If it's a direct JSX element, add it as a direct child
|
|
95
|
-
newChildren.push(expression);
|
|
96
|
-
} else {
|
|
97
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
98
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
// If it's a direct JSX element, add it directly
|
|
102
|
-
newChildren.push(footerProp.value);
|
|
103
|
-
}
|
|
104
|
-
} // Remove the header, body, and footer attributes
|
|
105
|
-
openingElement.attributes = openingElement.attributes.filter((attr) => {
|
|
106
|
-
if (attr.type !== 'JSXAttribute') return true;
|
|
107
|
-
const name = attr.name.name;
|
|
108
|
-
return name !== 'header' && name !== 'body' && name !== 'footer';
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Update the element's children
|
|
112
|
-
element.children = newChildren;
|
|
113
|
-
|
|
114
|
-
// If the element was self-closing, make it a regular element
|
|
115
|
-
if (openingElement.selfClosing) {
|
|
116
|
-
openingElement.selfClosing = false;
|
|
117
|
-
element.closingElement = j.jsxClosingElement(j.jsxIdentifier('CardModal'));
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// ----------- End of transformer logic
|
|
122
|
-
|
|
123
|
-
// Return the modified source code after transformation
|
|
124
|
-
if (!hasChanges) {
|
|
125
|
-
return fileInfo.source;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const output = root.toSource({ quote: 'single' });
|
|
129
|
-
|
|
130
|
-
const prettierConfig = await prettier.resolveConfig(fileInfo.path);
|
|
131
|
-
|
|
132
|
-
return prettier.format(output, {
|
|
133
|
-
...prettierConfig,
|
|
134
|
-
filepath: fileInfo.path,
|
|
135
|
-
});
|
|
136
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Transform FullscreenModal components from prop-based API to children-based API
|
|
4
|
-
// Converts header, body, and footer props to direct children elements
|
|
5
|
-
|
|
6
|
-
// Use local jscodeshift instance directly
|
|
7
|
-
const jscodeshift = require('jscodeshift');
|
|
8
|
-
const prettier = require('prettier');
|
|
9
|
-
|
|
10
|
-
module.exports = async function transformer(fileInfo, api) {
|
|
11
|
-
// Use the jscodeshift API to parse the file
|
|
12
|
-
const j = api.jscodeshift || jscodeshift;
|
|
13
|
-
|
|
14
|
-
// Parse the source code of the file
|
|
15
|
-
const root = j(fileInfo.source);
|
|
16
|
-
|
|
17
|
-
let hasChanges = false;
|
|
18
|
-
|
|
19
|
-
// ----------- Start of transformer logic
|
|
20
|
-
|
|
21
|
-
// Find all JSX elements with the name FullscreenModal
|
|
22
|
-
root
|
|
23
|
-
.find(j.JSXElement, {
|
|
24
|
-
openingElement: {
|
|
25
|
-
name: {
|
|
26
|
-
name: 'FullscreenModal',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
.forEach((path) => {
|
|
31
|
-
const element = path.value;
|
|
32
|
-
const openingElement = element.openingElement;
|
|
33
|
-
|
|
34
|
-
// Check if this FullscreenModal has header, body, or footer props
|
|
35
|
-
const headerProp = openingElement.attributes.find(
|
|
36
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'header',
|
|
37
|
-
);
|
|
38
|
-
const bodyProp = openingElement.attributes.find(
|
|
39
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'body',
|
|
40
|
-
);
|
|
41
|
-
const footerProp = openingElement.attributes.find(
|
|
42
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'footer',
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
// Only transform if we have at least one of these props
|
|
46
|
-
if (!headerProp && !bodyProp && !footerProp) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
hasChanges = true;
|
|
51
|
-
|
|
52
|
-
// Create new children array in the correct order: header, body, footer
|
|
53
|
-
const newChildren = [];
|
|
54
|
-
|
|
55
|
-
// Add header child if it exists
|
|
56
|
-
if (headerProp && headerProp.value) {
|
|
57
|
-
if (headerProp.value.type === 'JSXExpressionContainer') {
|
|
58
|
-
const expression = headerProp.value.expression;
|
|
59
|
-
if (expression.type === 'JSXElement') {
|
|
60
|
-
// If it's a direct JSX element, add it as a direct child
|
|
61
|
-
newChildren.push(expression);
|
|
62
|
-
} else {
|
|
63
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
64
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
// If it's a direct JSX element, add it directly
|
|
68
|
-
newChildren.push(headerProp.value);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Add body child if it exists
|
|
73
|
-
if (bodyProp && bodyProp.value) {
|
|
74
|
-
if (bodyProp.value.type === 'JSXExpressionContainer') {
|
|
75
|
-
const expression = bodyProp.value.expression;
|
|
76
|
-
if (expression.type === 'JSXElement') {
|
|
77
|
-
// If it's a direct JSX element, add it as a direct child
|
|
78
|
-
newChildren.push(expression);
|
|
79
|
-
} else {
|
|
80
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
81
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
// If it's a direct JSX element, add it directly
|
|
85
|
-
newChildren.push(bodyProp.value);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Add footer child if it exists
|
|
90
|
-
if (footerProp && footerProp.value) {
|
|
91
|
-
if (footerProp.value.type === 'JSXExpressionContainer') {
|
|
92
|
-
const expression = footerProp.value.expression;
|
|
93
|
-
if (expression.type === 'JSXElement') {
|
|
94
|
-
// If it's a direct JSX element, add it as a direct child
|
|
95
|
-
newChildren.push(expression);
|
|
96
|
-
} else {
|
|
97
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
98
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
// If it's a direct JSX element, add it directly
|
|
102
|
-
newChildren.push(footerProp.value);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Remove the header, body, and footer attributes
|
|
107
|
-
openingElement.attributes = openingElement.attributes.filter((attr) => {
|
|
108
|
-
if (attr.type !== 'JSXAttribute') return true;
|
|
109
|
-
const name = attr.name.name;
|
|
110
|
-
return name !== 'header' && name !== 'body' && name !== 'footer';
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// Update the element's children
|
|
114
|
-
element.children = newChildren;
|
|
115
|
-
|
|
116
|
-
// If the element was self-closing, make it a regular element
|
|
117
|
-
if (openingElement.selfClosing) {
|
|
118
|
-
openingElement.selfClosing = false;
|
|
119
|
-
element.closingElement = j.jsxClosingElement(j.jsxIdentifier('FullscreenModal'));
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// ----------- End of transformer logic
|
|
124
|
-
|
|
125
|
-
// Return the modified source code after transformation
|
|
126
|
-
if (!hasChanges) {
|
|
127
|
-
return fileInfo.source;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const output = root.toSource({ quote: 'single' });
|
|
131
|
-
|
|
132
|
-
const prettierConfig = await prettier.resolveConfig(fileInfo.path);
|
|
133
|
-
|
|
134
|
-
return prettier.format(output, {
|
|
135
|
-
...prettierConfig,
|
|
136
|
-
filepath: fileInfo.path,
|
|
137
|
-
});
|
|
138
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Transform NavigationModal components from prop-based API to children-based API
|
|
4
|
-
// Converts header, body, and footer props to direct children elements
|
|
5
|
-
|
|
6
|
-
// Use local jscodeshift instance directly
|
|
7
|
-
const jscodeshift = require('jscodeshift');
|
|
8
|
-
const prettier = require('prettier');
|
|
9
|
-
|
|
10
|
-
module.exports = async function transformer(fileInfo, api) {
|
|
11
|
-
// Use the jscodeshift API to parse the file
|
|
12
|
-
const j = api.jscodeshift || jscodeshift;
|
|
13
|
-
|
|
14
|
-
// Parse the source code of the file
|
|
15
|
-
const root = j(fileInfo.source);
|
|
16
|
-
|
|
17
|
-
let hasChanges = false;
|
|
18
|
-
|
|
19
|
-
// ----------- Start of transformer logic
|
|
20
|
-
|
|
21
|
-
// Find all JSX elements with the name NavigationModal
|
|
22
|
-
root
|
|
23
|
-
.find(j.JSXElement, {
|
|
24
|
-
openingElement: {
|
|
25
|
-
name: {
|
|
26
|
-
name: 'NavigationModal',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
.forEach((path) => {
|
|
31
|
-
const element = path.value;
|
|
32
|
-
const openingElement = element.openingElement;
|
|
33
|
-
|
|
34
|
-
// Check if this NavigationModal has header, body, or footer props
|
|
35
|
-
const headerProp = openingElement.attributes.find(
|
|
36
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'header',
|
|
37
|
-
);
|
|
38
|
-
const bodyProp = openingElement.attributes.find(
|
|
39
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'body',
|
|
40
|
-
);
|
|
41
|
-
const footerProp = openingElement.attributes.find(
|
|
42
|
-
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'footer',
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
// Only transform if we have at least one of these props
|
|
46
|
-
if (!headerProp && !bodyProp && !footerProp) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
hasChanges = true;
|
|
51
|
-
|
|
52
|
-
// Create new children array in the correct order: header, body, footer
|
|
53
|
-
const newChildren = [];
|
|
54
|
-
|
|
55
|
-
// Add header child if it exists
|
|
56
|
-
if (headerProp && headerProp.value) {
|
|
57
|
-
if (headerProp.value.type === 'JSXExpressionContainer') {
|
|
58
|
-
const expression = headerProp.value.expression;
|
|
59
|
-
if (expression.type === 'JSXElement') {
|
|
60
|
-
// If it's a direct JSX element, add it as a direct child
|
|
61
|
-
newChildren.push(expression);
|
|
62
|
-
} else {
|
|
63
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
64
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
// If it's a direct JSX element, add it directly
|
|
68
|
-
newChildren.push(headerProp.value);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Add body child if it exists
|
|
73
|
-
if (bodyProp && bodyProp.value) {
|
|
74
|
-
if (bodyProp.value.type === 'JSXExpressionContainer') {
|
|
75
|
-
const expression = bodyProp.value.expression;
|
|
76
|
-
if (expression.type === 'JSXElement') {
|
|
77
|
-
// If it's a direct JSX element, add it as a direct child
|
|
78
|
-
newChildren.push(expression);
|
|
79
|
-
} else {
|
|
80
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
81
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
// If it's a direct JSX element, add it directly
|
|
85
|
-
newChildren.push(bodyProp.value);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Add footer child if it exists
|
|
90
|
-
if (footerProp && footerProp.value) {
|
|
91
|
-
if (footerProp.value.type === 'JSXExpressionContainer') {
|
|
92
|
-
const expression = footerProp.value.expression;
|
|
93
|
-
if (expression.type === 'JSXElement') {
|
|
94
|
-
// If it's a direct JSX element, add it as a direct child
|
|
95
|
-
newChildren.push(expression);
|
|
96
|
-
} else {
|
|
97
|
-
// If it's a conditional or other expression, keep it wrapped
|
|
98
|
-
newChildren.push(j.jsxExpressionContainer(expression));
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
// If it's a direct JSX element, add it directly
|
|
102
|
-
newChildren.push(footerProp.value);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Remove the header, body, and footer attributes
|
|
107
|
-
openingElement.attributes = openingElement.attributes.filter((attr) => {
|
|
108
|
-
if (attr.type !== 'JSXAttribute') return true;
|
|
109
|
-
const name = attr.name.name;
|
|
110
|
-
return name !== 'header' && name !== 'body' && name !== 'footer';
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// Update the element's children
|
|
114
|
-
element.children = newChildren;
|
|
115
|
-
|
|
116
|
-
// If the element was self-closing, make it a regular element
|
|
117
|
-
if (openingElement.selfClosing) {
|
|
118
|
-
openingElement.selfClosing = false;
|
|
119
|
-
element.closingElement = j.jsxClosingElement(j.jsxIdentifier('NavigationModal'));
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// ----------- End of transformer logic
|
|
124
|
-
|
|
125
|
-
// Return the modified source code after transformation
|
|
126
|
-
if (!hasChanges) {
|
|
127
|
-
return fileInfo.source;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const output = root.toSource({ quote: 'single' });
|
|
131
|
-
|
|
132
|
-
const prettierConfig = await prettier.resolveConfig(fileInfo.path);
|
|
133
|
-
|
|
134
|
-
return prettier.format(output, {
|
|
135
|
-
...prettierConfig,
|
|
136
|
-
filepath: fileInfo.path,
|
|
137
|
-
});
|
|
138
|
-
};
|
|
File without changes
|
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/card-modal/withExpressions.input.js
RENAMED
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/card-modal/withExpressions.output.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/basic.output.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/wrongOrder.input.js
RENAMED
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/fullscreen-modal/wrongOrder.output.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/basic.output.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/wrongOrder.input.js
RENAMED
|
File without changes
|
/package/scripts/{transformers → codemods}/__testfixtures__/navigation-modal/wrongOrder.output.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|