@entur/typography 1.10.0-beta.7 → 1.10.0-beta.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/typography",
3
- "version": "1.10.0-beta.7",
3
+ "version": "1.10.0-beta.9",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/typography.esm.js",
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "dts-cli": "2.0.5"
44
44
  },
45
- "gitHead": "26b5f016229bb0115d5f31ce51e15eafd015a870"
45
+ "gitHead": "6f685d2e4ac13bdaf9c6480f9e7922c9d8f4619c"
46
46
  }
@@ -349,8 +349,6 @@ const COMPONENT_MAPPING = {
349
349
  Label: { component: 'Text', variant: 'label' },
350
350
  EmphasizedText: { component: 'Text', variant: 'emphasized' },
351
351
  CodeText: { component: 'Text', variant: 'code-text' },
352
- Link: { component: 'LinkBeta' },
353
- Blockquote: { component: 'BlockquoteBeta' },
354
352
  };
355
353
 
356
354
  // Props mapping for migration
@@ -558,15 +556,37 @@ function updateImports(content) {
558
556
  updatedContent = updatedContent.replace(pattern, `from '${BETA_IMPORT}'`);
559
557
  });
560
558
 
561
- // Then, update destructured import names
562
- Object.entries(COMPONENT_MAPPING).forEach(([oldComponent, mapping]) => {
563
- // Simple approach: find and replace the component name in import statements
564
- const importRegex = new RegExp(`\\b${oldComponent}\\b(?=\\s*[,}])`, 'g');
559
+ // Then, update destructured import names - only within @entur/typography imports
560
+ // Find all import statements from @entur/typography and update component names
561
+ const importRegex =
562
+ /import\s*{([^}]+)}\s*from\s*['"']@entur\/typography['"']/g;
563
+
564
+ updatedContent = updatedContent.replace(importRegex, (match, importList) => {
565
+ let updatedImportList = importList;
566
+ let hasChanges = false;
567
+ const uniqueComponents = new Set();
568
+
569
+ // Check each component in the import list
570
+ Object.entries(COMPONENT_MAPPING).forEach(([oldComponent, mapping]) => {
571
+ const componentRegex = new RegExp(`\\b${oldComponent}\\b`, 'g');
572
+ if (componentRegex.test(updatedImportList)) {
573
+ updatedImportList = updatedImportList.replace(
574
+ componentRegex,
575
+ mapping.component,
576
+ );
577
+ uniqueComponents.add(mapping.component);
578
+ hasChanges = true;
579
+ }
580
+ });
565
581
 
566
- if (importRegex.test(updatedContent)) {
582
+ if (hasChanges) {
567
583
  changes++;
568
- updatedContent = updatedContent.replace(importRegex, mapping.component);
584
+ // Deduplicate components and create clean import statement
585
+ const finalImportList = Array.from(uniqueComponents).join(', ');
586
+ return `import {${finalImportList}} from '${BETA_IMPORT}'`;
569
587
  }
588
+
589
+ return match;
570
590
  });
571
591
 
572
592
  return { content: updatedContent, changes };