@entur/typography 2.0.1 → 2.0.2-beta.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/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/typography",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2-beta.0",
|
|
4
4
|
"license": "SEE LICENSE IN README.md",
|
|
5
5
|
"main": "./dist/typography.cjs.js",
|
|
6
6
|
"module": "./dist/typography.esm.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"migrate": "scripts/migrate-typography.
|
|
9
|
+
"migrate": "scripts/migrate-typography.mjs"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"vite": "^7.1.3",
|
|
84
84
|
"vite-plugin-dts": "^4.5.4"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "4b9f4e324e6efef2fd56407909a5da32bcdf7662"
|
|
87
87
|
}
|
|
@@ -799,14 +799,20 @@ function updateComponents(content) {
|
|
|
799
799
|
let warnings = [];
|
|
800
800
|
|
|
801
801
|
Object.entries(COMPONENT_MAPPING).forEach(([oldComponent, mapping]) => {
|
|
802
|
-
// More robust regex to handle complex JSX
|
|
803
|
-
const componentRegex = new RegExp(
|
|
802
|
+
// More robust regex to handle complex JSX including self-closing tags
|
|
803
|
+
const componentRegex = new RegExp(
|
|
804
|
+
`<${oldComponent}(\\s+[^>]*?)?(?:/>|>)`,
|
|
805
|
+
'g',
|
|
806
|
+
);
|
|
804
807
|
|
|
805
808
|
updatedContent = updatedContent.replace(
|
|
806
809
|
componentRegex,
|
|
807
810
|
(match, propsString) => {
|
|
808
811
|
changes++;
|
|
809
812
|
|
|
813
|
+
// Check if this is a self-closing tag
|
|
814
|
+
const isSelfClosing = match.endsWith('/>');
|
|
815
|
+
|
|
810
816
|
// Parse existing props
|
|
811
817
|
const {
|
|
812
818
|
props: existingProps,
|
|
@@ -862,7 +868,8 @@ function updateComponents(content) {
|
|
|
862
868
|
);
|
|
863
869
|
const spreadPropsString =
|
|
864
870
|
spreadProps.length > 0 ? ` {...${spreadProps.join(', ...')}}` : '';
|
|
865
|
-
|
|
871
|
+
const closingTag = isSelfClosing ? '/>' : '>';
|
|
872
|
+
return `<Heading${propsString}${spreadPropsString}${closingTag}`;
|
|
866
873
|
}
|
|
867
874
|
|
|
868
875
|
// Handle Label components with special case for htmlFor prop
|
|
@@ -892,7 +899,8 @@ function updateComponents(content) {
|
|
|
892
899
|
|
|
893
900
|
// Only add as prop if it has a value
|
|
894
901
|
const asProp = asValue ? ` as="${asValue}"` : '';
|
|
895
|
-
|
|
902
|
+
const closingTag = isSelfClosing ? '/>' : '>';
|
|
903
|
+
return `<Text${asProp} variant="${variantValue}"${propsString}${spreadPropsString}${closingTag}`;
|
|
896
904
|
}
|
|
897
905
|
|
|
898
906
|
// Handle other components
|
|
@@ -917,11 +925,12 @@ function updateComponents(content) {
|
|
|
917
925
|
const otherPropsString = propsToString(finalProps, originalSyntax);
|
|
918
926
|
const spreadPropsString =
|
|
919
927
|
spreadProps.length > 0 ? ` {...${spreadProps.join(', ...')}}` : '';
|
|
920
|
-
|
|
928
|
+
const closingTag = isSelfClosing ? '/>' : '>';
|
|
929
|
+
return `<${componentName}${otherPropsString}${spreadPropsString}${closingTag}`;
|
|
921
930
|
},
|
|
922
931
|
);
|
|
923
932
|
|
|
924
|
-
// Update closing tags
|
|
933
|
+
// Update closing tags (only for non-self-closing tags)
|
|
925
934
|
const closingTagRegex = new RegExp(`</${oldComponent}>`, 'g');
|
|
926
935
|
const componentName = mapping.component;
|
|
927
936
|
updatedContent = updatedContent.replace(
|