bestax-migrate 2.36.6 → 2.36.7

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.
@@ -0,0 +1,25 @@
1
+ import type { ASTPath } from 'jscodeshift';
2
+ import { type TransformContext } from './jsx-utils.js';
3
+ /**
4
+ * The bestax targets whose props have no `bgColor`, keyed by the name the
5
+ * mappings and structural handlers use as their `target`, and the prop that
6
+ * renders `has-background-{color}` on each: `backgroundColor`, or null when
7
+ * the target takes neither. Every other target takes `bgColor`, which is what
8
+ * react-bulma-components' and rbx's `backgroundColor` becomes by default.
9
+ *
10
+ * bulma-ui declares these props per component, so this is a hand copy.
11
+ * `e2e/background-props.test.ts` holds each row, and every target the two
12
+ * sources name, to the library's types.
13
+ */
14
+ export declare const BACKGROUND_PROPS: Readonly<Record<string, 'backgroundColor' | null>>;
15
+ /** The TODO a target that takes no background color prop gets. */
16
+ export declare const NO_BACKGROUND_TODO = "this bestax component takes no background color prop; move the color to a `has-background-*` class in `className`";
17
+ /**
18
+ * Handle the element's `backgroundColor` where the universal rename to
19
+ * `bgColor` would write a prop `target` doesn't take: keep it where the
20
+ * target takes `backgroundColor`, and leave a TODO where it takes neither.
21
+ * Either way it's marked handled, so the universal pass leaves it alone. A
22
+ * component's own prop map runs first and wins, as it does for every prop.
23
+ */
24
+ export declare function applyBackgroundColor(ctx: TransformContext, path: ASTPath<any>, element: any, target: string, handled: Set<string>): void;
25
+ //# sourceMappingURL=background-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-props.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/background-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAY,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKjE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAwDzC,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,sHACsF,CAAC;AAEtH;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GACnB,IAAI,CASN"}
@@ -0,0 +1,91 @@
1
+ import { findAttr } from './jsx-utils.js';
2
+ import { applyPropAction } from './props.js';
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+ /**
5
+ * The bestax targets whose props have no `bgColor`, keyed by the name the
6
+ * mappings and structural handlers use as their `target`, and the prop that
7
+ * renders `has-background-{color}` on each: `backgroundColor`, or null when
8
+ * the target takes neither. Every other target takes `bgColor`, which is what
9
+ * react-bulma-components' and rbx's `backgroundColor` becomes by default.
10
+ *
11
+ * bulma-ui declares these props per component, so this is a hand copy.
12
+ * `e2e/background-props.test.ts` holds each row, and every target the two
13
+ * sources name, to the library's types.
14
+ */
15
+ export const BACKGROUND_PROPS = {
16
+ Dropdown: 'backgroundColor',
17
+ 'Dropdown.Item': 'backgroundColor',
18
+ File: 'backgroundColor',
19
+ Input: 'backgroundColor',
20
+ Menu: 'backgroundColor',
21
+ 'Menu.Item': 'backgroundColor',
22
+ 'Menu.Label': 'backgroundColor',
23
+ 'Menu.List': 'backgroundColor',
24
+ Select: 'backgroundColor',
25
+ Tag: 'backgroundColor',
26
+ TextArea: 'backgroundColor',
27
+ Breadcrumb: null,
28
+ Checkbox: null,
29
+ 'Dropdown.Divider': null,
30
+ Loading: null,
31
+ 'Message.Body': null,
32
+ 'Message.Header': null,
33
+ 'Modal.Background': null,
34
+ 'Modal.Card': null,
35
+ 'Modal.Card.Body': null,
36
+ 'Modal.Card.Foot': null,
37
+ 'Modal.Card.Head': null,
38
+ 'Modal.Card.Title': null,
39
+ 'Modal.Close': null,
40
+ 'Modal.Content': null,
41
+ 'Navbar.Brand': null,
42
+ 'Navbar.Burger': null,
43
+ 'Navbar.Divider': null,
44
+ 'Navbar.Dropdown': null,
45
+ 'Navbar.DropdownMenu': null,
46
+ 'Navbar.End': null,
47
+ 'Navbar.Menu': null,
48
+ 'Navbar.Start': null,
49
+ Notification: null,
50
+ 'Pagination.Ellipsis': null,
51
+ 'Pagination.Next': null,
52
+ 'Pagination.Previous': null,
53
+ Panel: null,
54
+ 'Panel.Block': null,
55
+ 'Panel.Heading': null,
56
+ 'Panel.Tabs': null,
57
+ Progress: null,
58
+ Radio: null,
59
+ Table: null,
60
+ 'Table.Tbody': null,
61
+ 'Table.Td': null,
62
+ 'Table.Tfoot': null,
63
+ 'Table.Th': null,
64
+ 'Table.Thead': null,
65
+ 'Table.Tr': null,
66
+ Tabs: null,
67
+ 'Tabs.Item': null,
68
+ Tags: null,
69
+ };
70
+ /** The TODO a target that takes no background color prop gets. */
71
+ export const NO_BACKGROUND_TODO = 'this bestax component takes no background color prop; move the color to a `has-background-*` class in `className`';
72
+ /**
73
+ * Handle the element's `backgroundColor` where the universal rename to
74
+ * `bgColor` would write a prop `target` doesn't take: keep it where the
75
+ * target takes `backgroundColor`, and leave a TODO where it takes neither.
76
+ * Either way it's marked handled, so the universal pass leaves it alone. A
77
+ * component's own prop map runs first and wins, as it does for every prop.
78
+ */
79
+ export function applyBackgroundColor(ctx, path, element, target, handled) {
80
+ if (handled.has('backgroundColor'))
81
+ return;
82
+ if (!Object.hasOwn(BACKGROUND_PROPS, target))
83
+ return;
84
+ const attr = findAttr(element, 'backgroundColor');
85
+ if (!attr)
86
+ return;
87
+ handled.add('backgroundColor');
88
+ if (BACKGROUND_PROPS[target] === null) {
89
+ applyPropAction(ctx, path, element, attr, { todo: NO_BACKGROUND_TODO });
90
+ }
91
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqDvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAw+BpB"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAsDvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAy+BpB"}
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import { BADGE_PROPS, MAPPING, TOOLTIP_PROPS, UNIVERSAL_PROPS, resolveMapping, } from './mapping.js';
23
23
  import { addTodo, attributesOf, findAttr, forgetJsxParens, jsxNameParts, literalValueOf, removeAttr, renameElement, reprintDirectives, } from '../_shared/jsx-utils.js';
24
+ import { applyBackgroundColor } from '../_shared/background-props.js';
24
25
  import { applyPropAction, applyUniversalProps } from '../_shared/props.js';
25
26
  import { applyTextColor } from '../_shared/text-color-props.js';
26
27
  import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
@@ -488,6 +489,7 @@ export default function transform(fileInfo, api, options = {}) {
488
489
  applyPropAction(ctx, path, element, attr, action);
489
490
  }
490
491
  }
492
+ applyBackgroundColor(ctx, path, element, target, handled);
491
493
  applyTextColor(ctx, path, element, target, handled);
492
494
  applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
493
495
  // After every prop pass: bestax's props follow `as`, so the element
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqCvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA8wBpB"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAsCvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA+wBpB"}
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { MAPPING, UNIVERSAL_PROPS, resolveMapping } from './mapping.js';
17
17
  import { addTodo, attributesOf, forgetJsxParens, jsxNameParts, renameElement, reprintDirectives, } from '../_shared/jsx-utils.js';
18
+ import { applyBackgroundColor } from '../_shared/background-props.js';
18
19
  import { applyPropAction, applyUniversalProps } from '../_shared/props.js';
19
20
  import { applyTextColor } from '../_shared/text-color-props.js';
20
21
  import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
@@ -349,6 +350,7 @@ export default function transform(fileInfo, api, options = {}) {
349
350
  applyPropAction(ctx, path, element, attr, action);
350
351
  }
351
352
  }
353
+ applyBackgroundColor(ctx, path, element, target, handled);
352
354
  applyTextColor(ctx, path, element, target, handled);
353
355
  applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
354
356
  // Last: bestax's props follow `as`, so the element decides which of the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bestax-migrate",
3
- "version": "2.36.6",
3
+ "version": "2.36.7",
4
4
  "description": "Codemods for migrating existing React apps from other Bulma libraries to @allxsmith/bestax-bulma",
5
5
  "type": "module",
6
6
  "bin": {
@@ -40,7 +40,7 @@
40
40
  "jscodeshift": "^17.3.0",
41
41
  "parse5": "^8.1.1",
42
42
  "property-information": "^7.2.0",
43
- "@allxsmith/bestax-bulma": "^5.68.1"
43
+ "@allxsmith/bestax-bulma": "^5.68.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/jscodeshift": "^17.3.0",