@react-spectrum/codemods 0.1.2-nightly.5022 → 0.1.2-nightly.5032

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.
@@ -42,6 +42,23 @@ exports.changes = {
42
42
  }
43
43
  ]
44
44
  },
45
+ Badge: {
46
+ changes: [
47
+ {
48
+ description: "Change variant='info' to variant='informative'",
49
+ reason: 'Updated naming convention',
50
+ function: {
51
+ name: 'updatePropNameAndValue',
52
+ args: {
53
+ oldProp: 'variant',
54
+ oldValue: 'info',
55
+ newProp: 'variant',
56
+ newValue: 'informative'
57
+ }
58
+ }
59
+ }
60
+ ]
61
+ },
45
62
  Breadcrumbs: {
46
63
  changes: [
47
64
  {
@@ -332,18 +349,6 @@ exports.changes = {
332
349
  }
333
350
  ]
334
351
  },
335
- Flex: {
336
- changes: [
337
- {
338
- description: 'Update Flex to be a div and apply flex styles using the style macro',
339
- reason: 'Updated API',
340
- function: {
341
- name: 'updateToNewComponent',
342
- args: { newComponent: 'div' }
343
- }
344
- }
345
- ]
346
- },
347
352
  Form: {
348
353
  changes: [
349
354
  {
@@ -366,18 +371,6 @@ exports.changes = {
366
371
  }
367
372
  ]
368
373
  },
369
- Grid: {
370
- changes: [
371
- {
372
- description: 'Update Grid to be a div and apply grid styles using the style macro',
373
- reason: 'Updated API',
374
- function: {
375
- name: 'updateToNewComponent',
376
- args: { newComponent: 'div' }
377
- }
378
- }
379
- ]
380
- },
381
374
  InlineAlert: {
382
375
  changes: [
383
376
  {
@@ -1098,17 +1091,5 @@ exports.changes = {
1098
1091
  }
1099
1092
  }
1100
1093
  ]
1101
- },
1102
- View: {
1103
- changes: [
1104
- {
1105
- description: 'Update View to be a div and apply styles using the style macro',
1106
- reason: 'Updated API',
1107
- function: {
1108
- name: 'updateToNewComponent',
1109
- args: { newComponent: 'div' }
1110
- }
1111
- }
1112
- ]
1113
1094
  }
1114
1095
  };
@@ -41,6 +41,7 @@ let availableComponents = (0, getComponents_1.getComponents)();
41
41
  availableComponents.add('View');
42
42
  availableComponents.add('Flex');
43
43
  availableComponents.add('Grid');
44
+ availableComponents.add('Well');
44
45
  // Replaced by collection component-specific items
45
46
  availableComponents.add('Item');
46
47
  availableComponents.add('Section');
@@ -196,9 +197,11 @@ function transformer(file, api, options) {
196
197
  if (t.isImportSpecifier(b.path.node) &&
197
198
  t.isIdentifier(b.path.node.imported) &&
198
199
  (b.path.node.imported.name === 'Item' || b.path.node.imported.name === 'Section')) {
199
- // Keep Item and Section imports
200
- // TODO: remove if they are unused
201
- return;
200
+ // Keep Item and Section imports if they are still used
201
+ bindings[0]?.path.scope.crawl();
202
+ if (bindings[0]?.path.scope.bindings[b.path.node.local.name]?.referencePaths.length > 0) {
203
+ return;
204
+ }
202
205
  }
203
206
  b.path.remove();
204
207
  // If the import statement is now empty, remove it entirely.
@@ -484,7 +484,7 @@ function handleProp(path, element, colorVersion) {
484
484
  (0, utils_1.addComment)(path.node, ' TODO(S2-upgrade): check this UNSAFE_style');
485
485
  break;
486
486
  case 'UNSAFE_className':
487
- if (element === 'Flex' || element === 'Grid' || element === 'View') {
487
+ if (element === 'Flex' || element === 'Grid' || element === 'View' || element === 'Well') {
488
488
  path.get('name').replaceWith(t.jsxIdentifier('className'));
489
489
  }
490
490
  else {
@@ -508,13 +508,26 @@ function transformStyleProps(path, element) {
508
508
  let macroValues = new Map;
509
509
  let dynamicValues = new Map;
510
510
  let conditions = new Map;
511
- let isDOMElement = element === 'Flex' || element === 'Grid' || element === 'View';
511
+ let isDOMElement = element === 'Flex' || element === 'Grid' || element === 'View' || element === 'Well';
512
512
  if (element === 'Flex') {
513
513
  macroValues.set('display', 'flex');
514
514
  }
515
515
  else if (element === 'Grid') {
516
516
  macroValues.set('display', 'grid');
517
517
  }
518
+ else if (element === 'Well') {
519
+ macroValues.set('display', 'block');
520
+ macroValues.set('textAlign', 'start');
521
+ macroValues.set('minWidth', 160);
522
+ macroValues.set('padding', 16);
523
+ macroValues.set('marginTop', 4);
524
+ macroValues.set('borderWidth', 1);
525
+ macroValues.set('borderRadius', 'sm');
526
+ macroValues.set('backgroundColor', 'layer-1');
527
+ macroValues.set('borderStyle', 'solid');
528
+ macroValues.set('borderColor', 'transparent-black-75');
529
+ macroValues.set('font', 'body-sm');
530
+ }
518
531
  let attrs = path.get('openingElement').get('attributes');
519
532
  // Find the color version in use.
520
533
  let colorVersion = 5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/codemods",
3
- "version": "0.1.2-nightly.5022+b4093dfef",
3
+ "version": "0.1.2-nightly.5032+bb05fdc36",
4
4
  "main": "dist/index.js",
5
5
  "source": "src/index.ts",
6
6
  "bin": "dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "@babel/parser": "^7.24.5",
25
25
  "@babel/traverse": "^7.24.5",
26
26
  "@babel/types": "^7.24.5",
27
- "@react-spectrum/s2": "0.3.2-nightly.5022+b4093dfef",
28
- "@react-types/shared": "3.0.0-nightly.3094+b4093dfef",
27
+ "@react-spectrum/s2": "0.3.2-nightly.5032+bb05fdc36",
28
+ "@react-types/shared": "3.0.0-nightly.3104+bb05fdc36",
29
29
  "@types/node": "^20",
30
30
  "boxen": "^5.1.2",
31
31
  "build": "^0.1.4",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "b4093dfef3eff0e5fe60d00c53fe2478b96e662f"
50
+ "gitHead": "bb05fdc361ef3b536a63479c29cc86f90c097a10"
51
51
  }