@ornikar/kitt-universal 27.4.0 → 27.5.1-canary.eac3fc19869888632e3a59913cf9f700a72b0dad.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/CHANGELOG.md +25 -0
- package/dist/definitions/CardModal/CardModalAnimation/CardModalAnimation.web.d.ts.map +1 -1
- package/dist/definitions/DialogModal/DialogModalAnimation/DialogModalAnimation.web.d.ts.map +1 -1
- package/dist/definitions/FullscreenModal/FullscreenModalAnimation.web.d.ts.map +1 -1
- package/dist/definitions/GoogleMapsAutocompleteProvider/GoogleMapsAutocompleteProvider.d.ts.map +1 -1
- package/dist/definitions/MapMarker/MapMarker.d.ts +2 -5
- package/dist/definitions/MapMarker/MapMarker.d.ts.map +1 -1
- package/dist/definitions/MapMarker/constants.d.ts +6 -0
- package/dist/definitions/MapMarker/constants.d.ts.map +1 -0
- package/dist/definitions/MapMarker/utils/getBackgroundColor.d.ts +2 -1
- package/dist/definitions/MapMarker/utils/getBackgroundColor.d.ts.map +1 -1
- package/dist/definitions/Picker/Picker.web.d.ts.map +1 -1
- package/dist/definitions/TabBar/TabBar.d.ts.map +1 -1
- package/dist/definitions/TimePicker/TimePicker.web.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/cardModal.d.ts +21 -4
- package/dist/definitions/themes/late-ocean/cardModal.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/dialogModal.d.ts +21 -4
- package/dist/definitions/themes/late-ocean/dialogModal.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/fullscreenModal.d.ts +21 -4
- package/dist/definitions/themes/late-ocean/fullscreenModal.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/shadows.d.ts +4 -2
- package/dist/definitions/themes/late-ocean/shadows.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/skeleton.d.ts +2 -1
- package/dist/definitions/themes/late-ocean/skeleton.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +100 -39
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +100 -39
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.17.cjs.js +99 -38
- package/dist/index-node-22.17.cjs.js.map +1 -1
- package/dist/index-node-22.17.cjs.web.css +2 -2
- package/dist/index-node-22.17.cjs.web.js +66 -32
- package/dist/index-node-22.17.cjs.web.js.map +1 -1
- package/dist/index-node-22.17.es.mjs +99 -38
- package/dist/index-node-22.17.es.mjs.map +1 -1
- package/dist/index-node-22.17.es.web.css +2 -2
- package/dist/index-node-22.17.es.web.mjs +66 -32
- package/dist/index-node-22.17.es.web.mjs.map +1 -1
- package/dist/index.es.js +97 -74
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +76 -44
- package/dist/index.es.web.js.map +1 -1
- package/dist/linaria-themes-metro.es.android.js +40 -10
- package/dist/linaria-themes-metro.es.android.js.map +1 -1
- package/dist/linaria-themes-metro.es.ios.js +40 -10
- package/dist/linaria-themes-metro.es.ios.js.map +1 -1
- package/dist/linaria-themes-node-22.17.cjs.js +40 -10
- package/dist/linaria-themes-node-22.17.cjs.js.map +1 -1
- package/dist/linaria-themes-node-22.17.cjs.web.js +40 -10
- package/dist/linaria-themes-node-22.17.cjs.web.js.map +1 -1
- package/dist/linaria-themes-node-22.17.es.mjs +40 -10
- package/dist/linaria-themes-node-22.17.es.mjs.map +1 -1
- package/dist/linaria-themes-node-22.17.es.web.mjs +40 -10
- package/dist/linaria-themes-node-22.17.es.web.mjs.map +1 -1
- package/dist/linaria-themes.es.js +40 -10
- package/dist/linaria-themes.es.js.map +1 -1
- package/dist/linaria-themes.es.web.js +40 -10
- package/dist/linaria-themes.es.web.js.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/transformers/__testfixtures__/card-modal/basic.input.js +19 -0
- package/scripts/transformers/__testfixtures__/card-modal/basic.output.js +15 -0
- package/scripts/transformers/__testfixtures__/card-modal/withExpressions.input.js +23 -0
- package/scripts/transformers/__testfixtures__/card-modal/withExpressions.output.js +19 -0
- package/scripts/transformers/__testfixtures__/card-modal/wrongOrder.input.js +19 -0
- package/scripts/transformers/__testfixtures__/card-modal/wrongOrder.output.js +15 -0
- package/scripts/transformers/__testfixtures__/fullscreen-modal/basic.input.js +19 -0
- package/scripts/transformers/__testfixtures__/fullscreen-modal/basic.output.js +15 -0
- package/scripts/transformers/__testfixtures__/fullscreen-modal/withExpressions.input.js +23 -0
- package/scripts/transformers/__testfixtures__/fullscreen-modal/withExpressions.output.js +19 -0
- package/scripts/transformers/__testfixtures__/fullscreen-modal/wrongOrder.input.js +19 -0
- package/scripts/transformers/__testfixtures__/fullscreen-modal/wrongOrder.output.js +15 -0
- package/scripts/transformers/__testfixtures__/navigation-modal/basic.input.js +19 -0
- package/scripts/transformers/__testfixtures__/navigation-modal/basic.output.js +15 -0
- package/scripts/transformers/__testfixtures__/navigation-modal/withExpressions.input.js +23 -0
- package/scripts/transformers/__testfixtures__/navigation-modal/withExpressions.output.js +19 -0
- package/scripts/transformers/__testfixtures__/navigation-modal/wrongOrder.input.js +19 -0
- package/scripts/transformers/__testfixtures__/navigation-modal/wrongOrder.output.js +15 -0
- package/scripts/transformers/__tests__/card-modal.test.js +10 -0
- package/scripts/transformers/__tests__/fullscreen-modal.test.js +10 -0
- package/scripts/transformers/__tests__/navigation-modal.test.js +10 -0
- package/scripts/transformers/card-modal.js +101 -0
- package/scripts/transformers/fullscreen-modal.js +101 -0
- package/scripts/transformers/navigation-modal.js +101 -0
- package/scripts/transformers/modals.js +0 -102
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Transform NavigationModal from props-based API to children-based API
|
|
4
|
+
// Converts header, body, footer props to nested children in the correct order
|
|
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
|
+
// ----------- Start of transformer logic
|
|
18
|
+
|
|
19
|
+
// Find all NavigationModal JSX elements
|
|
20
|
+
root
|
|
21
|
+
.find(j.JSXElement, {
|
|
22
|
+
openingElement: {
|
|
23
|
+
name: {
|
|
24
|
+
name: 'NavigationModal',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
.forEach((path) => {
|
|
29
|
+
const element = path.value;
|
|
30
|
+
const { openingElement } = element;
|
|
31
|
+
|
|
32
|
+
// Extract header, body, and footer props
|
|
33
|
+
const getAttributeByName = (attributes, name) => {
|
|
34
|
+
return attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === name);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const headerProp = getAttributeByName(openingElement.attributes, 'header');
|
|
38
|
+
const bodyProp = getAttributeByName(openingElement.attributes, 'body');
|
|
39
|
+
const footerProp = getAttributeByName(openingElement.attributes, 'footer');
|
|
40
|
+
|
|
41
|
+
// If we found any of these props, transform the element
|
|
42
|
+
if (headerProp || bodyProp || footerProp) {
|
|
43
|
+
// Remove the header, body, and footer attributes
|
|
44
|
+
openingElement.attributes = openingElement.attributes.filter((attr) => {
|
|
45
|
+
if (attr.type !== 'JSXAttribute') return true;
|
|
46
|
+
return !['header', 'body', 'footer'].includes(attr.name.name);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Create children array in the correct order: header, body, footer
|
|
50
|
+
const children = [];
|
|
51
|
+
|
|
52
|
+
// Helper function to extract child from prop value
|
|
53
|
+
const extractChild = (propValue) => {
|
|
54
|
+
if (propValue.type === 'JSXExpressionContainer') {
|
|
55
|
+
// Check if the expression is a simple JSX element (not a conditional/complex expression)
|
|
56
|
+
if (propValue.expression.type === 'JSXElement') {
|
|
57
|
+
// For simple JSX elements, use them directly as children
|
|
58
|
+
return propValue.expression;
|
|
59
|
+
}
|
|
60
|
+
// For complex expressions (conditionals, etc.), keep as expression container
|
|
61
|
+
return propValue;
|
|
62
|
+
}
|
|
63
|
+
return propValue;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Add header if it exists
|
|
67
|
+
if (headerProp && headerProp.value) {
|
|
68
|
+
children.push(extractChild(headerProp.value));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Add body if it exists
|
|
72
|
+
if (bodyProp && bodyProp.value) {
|
|
73
|
+
children.push(extractChild(bodyProp.value));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Add footer if it exists
|
|
77
|
+
if (footerProp && footerProp.value) {
|
|
78
|
+
children.push(extractChild(footerProp.value));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Update the element to have children instead of being self-closing
|
|
82
|
+
if (children.length > 0) {
|
|
83
|
+
element.children = children;
|
|
84
|
+
element.closingElement = j.jsxClosingElement(j.jsxIdentifier('NavigationModal'));
|
|
85
|
+
openingElement.selfClosing = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// ----------- End of transformer logic
|
|
91
|
+
|
|
92
|
+
// Return the modified source code after transformation
|
|
93
|
+
const output = root.toSource({ quote: 'single' });
|
|
94
|
+
|
|
95
|
+
const prettierConfig = await prettier.resolveConfig(fileInfo.path);
|
|
96
|
+
|
|
97
|
+
return prettier.format(output, {
|
|
98
|
+
...prettierConfig,
|
|
99
|
+
filepath: fileInfo.path,
|
|
100
|
+
});
|
|
101
|
+
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable prefer-destructuring */
|
|
4
|
-
/* eslint-disable unicorn/no-array-method-this-argument */
|
|
5
|
-
|
|
6
|
-
// Use local jscodeshift instance directly
|
|
7
|
-
const jscodeshift = require('jscodeshift');
|
|
8
|
-
|
|
9
|
-
// List of modal component names we want to transform
|
|
10
|
-
const MODAL_COMPONENTS = ['FullscreenModal', 'CardModal', 'NavigationModal'];
|
|
11
|
-
|
|
12
|
-
module.exports = function transformer(fileInfo, api) {
|
|
13
|
-
// Use the jscodeshift API to parse the file
|
|
14
|
-
const j = api.jscodeshift || jscodeshift;
|
|
15
|
-
|
|
16
|
-
// Parse the source code of the file
|
|
17
|
-
const root = j(fileInfo.source);
|
|
18
|
-
|
|
19
|
-
// Iterate over each modal component found in the source code
|
|
20
|
-
MODAL_COMPONENTS.forEach((componentName) => {
|
|
21
|
-
// Find instances of the modal component
|
|
22
|
-
root
|
|
23
|
-
.find(j.JSXElement, {
|
|
24
|
-
openingElement: {
|
|
25
|
-
name: { type: 'JSXIdentifier', name: componentName },
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
.forEach((path) => {
|
|
29
|
-
// Get the node (the JSXElement) from the path
|
|
30
|
-
const node = path.node;
|
|
31
|
-
|
|
32
|
-
// Check if the modal component already has children or if it is self-closing
|
|
33
|
-
const hasChildren = Array.isArray(node.children) && node.children.length > 0;
|
|
34
|
-
if (!node.openingElement.selfClosing && hasChildren) {
|
|
35
|
-
// If it already has children, do nothing and skip transformation
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Extract the attributes from the JSX element (like `header`, `body`, `footer`)
|
|
40
|
-
const attributes = node.openingElement.attributes;
|
|
41
|
-
|
|
42
|
-
// Initialize a map to hold potential new children: header, body, footer
|
|
43
|
-
const newChildrenMap = {
|
|
44
|
-
header: null,
|
|
45
|
-
body: null,
|
|
46
|
-
footer: null,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// An array to keep attributes that are not `header`, `body`, or `footer`
|
|
50
|
-
const keptAttributes = [];
|
|
51
|
-
|
|
52
|
-
// Loop over the attributes to check if any match `header`, `body`, or `footer`
|
|
53
|
-
attributes.forEach((attr) => {
|
|
54
|
-
if (
|
|
55
|
-
attr.type === 'JSXAttribute' &&
|
|
56
|
-
attr.name &&
|
|
57
|
-
Object.prototype.hasOwnProperty.call(newChildrenMap, attr.name.name)
|
|
58
|
-
) {
|
|
59
|
-
const key = attr.name.name;
|
|
60
|
-
const value = attr.value;
|
|
61
|
-
|
|
62
|
-
// Check if the value of the attribute is an expression (like a ternary)
|
|
63
|
-
if (value?.type === 'JSXExpressionContainer') {
|
|
64
|
-
const expression = value.expression;
|
|
65
|
-
|
|
66
|
-
// If it's a JSXElement or JSXFragment, keep it as it is
|
|
67
|
-
if (j.JSXElement.check(expression) || j.JSXFragment.check(expression)) {
|
|
68
|
-
newChildrenMap[key] = expression;
|
|
69
|
-
} else {
|
|
70
|
-
// Otherwise, wrap it in an expression container to handle non-JSX expressions
|
|
71
|
-
newChildrenMap[key] = j.jsxExpressionContainer(expression);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
// Keep any other attributes (that are not header/body/footer)
|
|
76
|
-
keptAttributes.push(attr);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// If no new children were found (no `header`, `body`, or `footer`), do nothing
|
|
81
|
-
if (Object.values(newChildrenMap).every((v) => v === null)) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// If the modal component was self-closing, convert it to a regular JSX element with children
|
|
86
|
-
if (node.openingElement.selfClosing) {
|
|
87
|
-
node.openingElement.selfClosing = false;
|
|
88
|
-
node.closingElement = j.jsxClosingElement(j.jsxIdentifier(node.openingElement.name.name));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Retain all the other attributes and set the new ones
|
|
92
|
-
node.openingElement.attributes = keptAttributes;
|
|
93
|
-
|
|
94
|
-
// Force the order of children: header → body → footer
|
|
95
|
-
const orderedChildren = Object.values(newChildrenMap).filter(Boolean);
|
|
96
|
-
node.children = orderedChildren;
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Return the modified source code after transformation
|
|
101
|
-
return root.toSource({ quote: 'single' });
|
|
102
|
-
};
|