bestax-migrate 2.36.5 → 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.
- package/dist/sources/_shared/background-props.d.ts +25 -0
- package/dist/sources/_shared/background-props.d.ts.map +1 -0
- package/dist/sources/_shared/background-props.js +91 -0
- package/dist/sources/_shared/text-color-props.d.ts +23 -0
- package/dist/sources/_shared/text-color-props.d.ts.map +1 -0
- package/dist/sources/_shared/text-color-props.js +79 -0
- package/dist/sources/rbx/transform.d.ts.map +1 -1
- package/dist/sources/rbx/transform.js +4 -0
- package/dist/sources/react-bulma-components/mapping.js +1 -1
- package/dist/sources/react-bulma-components/transform.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/transform.js +4 -0
- package/package.json +2 -2
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ASTPath } from 'jscodeshift';
|
|
2
|
+
import { type TransformContext } from './jsx-utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* The bestax targets whose props have no `textColor`, by the name the
|
|
5
|
+
* mappings and structural handlers use as their `target`.
|
|
6
|
+
* react-bulma-components and rbx pass `textColor` through on every
|
|
7
|
+
* component, which is right everywhere else.
|
|
8
|
+
*
|
|
9
|
+
* bulma-ui declares `textColor` per component, so this is a hand copy.
|
|
10
|
+
* `e2e/text-color-props.test.ts` holds it, and every target the two sources
|
|
11
|
+
* name, to the library's types.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NO_TEXT_COLOR: ReadonlySet<string>;
|
|
14
|
+
/** The TODO a target that takes no `textColor` gets. */
|
|
15
|
+
export declare const NO_TEXT_COLOR_TODO = "this bestax component takes no `textColor` prop; move the color to a `has-text-*` class in `className`";
|
|
16
|
+
/**
|
|
17
|
+
* Leave a TODO on the element's `textColor` where `target` takes no such
|
|
18
|
+
* prop, and mark it handled so the universal pass leaves it alone. Should a
|
|
19
|
+
* component's own prop map ever claim `textColor`, it wins, as it does for
|
|
20
|
+
* every prop.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyTextColor(ctx: TransformContext, path: ASTPath<any>, element: any, target: string, handled: Set<string>): void;
|
|
23
|
+
//# sourceMappingURL=text-color-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-color-props.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/text-color-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAY,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKjE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAgD5C,CAAC;AAEH,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,2GAC2E,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,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,CAMN"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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 `textColor`, by the name the
|
|
6
|
+
* mappings and structural handlers use as their `target`.
|
|
7
|
+
* react-bulma-components and rbx pass `textColor` through on every
|
|
8
|
+
* component, which is right everywhere else.
|
|
9
|
+
*
|
|
10
|
+
* bulma-ui declares `textColor` per component, so this is a hand copy.
|
|
11
|
+
* `e2e/text-color-props.test.ts` holds it, and every target the two sources
|
|
12
|
+
* name, to the library's types.
|
|
13
|
+
*/
|
|
14
|
+
export const NO_TEXT_COLOR = new Set([
|
|
15
|
+
'Breadcrumb',
|
|
16
|
+
'Divider',
|
|
17
|
+
'Dropdown',
|
|
18
|
+
'Dropdown.Divider',
|
|
19
|
+
'Dropdown.Item',
|
|
20
|
+
'File',
|
|
21
|
+
'Hero',
|
|
22
|
+
'Input',
|
|
23
|
+
'Loading',
|
|
24
|
+
'Menu',
|
|
25
|
+
'Menu.Item',
|
|
26
|
+
'Menu.Label',
|
|
27
|
+
'Menu.List',
|
|
28
|
+
'Message.Body',
|
|
29
|
+
'Message.Header',
|
|
30
|
+
'Modal.Background',
|
|
31
|
+
'Modal.Card',
|
|
32
|
+
'Modal.Card.Body',
|
|
33
|
+
'Modal.Card.Foot',
|
|
34
|
+
'Modal.Card.Head',
|
|
35
|
+
'Modal.Card.Title',
|
|
36
|
+
'Modal.Close',
|
|
37
|
+
'Modal.Content',
|
|
38
|
+
'Navbar.Divider',
|
|
39
|
+
'Navbar.Dropdown',
|
|
40
|
+
'Navbar.DropdownMenu',
|
|
41
|
+
'Pagination.Ellipsis',
|
|
42
|
+
'Pagination.Next',
|
|
43
|
+
'Pagination.Previous',
|
|
44
|
+
'Panel',
|
|
45
|
+
'Panel.Block',
|
|
46
|
+
'Panel.Heading',
|
|
47
|
+
'Panel.Tabs',
|
|
48
|
+
'Progress',
|
|
49
|
+
'Select',
|
|
50
|
+
'Table',
|
|
51
|
+
'Table.Tbody',
|
|
52
|
+
'Table.Td',
|
|
53
|
+
'Table.Tfoot',
|
|
54
|
+
'Table.Th',
|
|
55
|
+
'Table.Thead',
|
|
56
|
+
'Table.Tr',
|
|
57
|
+
'Tabs',
|
|
58
|
+
'Tabs.Item',
|
|
59
|
+
'Tag',
|
|
60
|
+
'Tags',
|
|
61
|
+
'TextArea',
|
|
62
|
+
]);
|
|
63
|
+
/** The TODO a target that takes no `textColor` gets. */
|
|
64
|
+
export const NO_TEXT_COLOR_TODO = 'this bestax component takes no `textColor` prop; move the color to a `has-text-*` class in `className`';
|
|
65
|
+
/**
|
|
66
|
+
* Leave a TODO on the element's `textColor` where `target` takes no such
|
|
67
|
+
* prop, and mark it handled so the universal pass leaves it alone. Should a
|
|
68
|
+
* component's own prop map ever claim `textColor`, it wins, as it does for
|
|
69
|
+
* every prop.
|
|
70
|
+
*/
|
|
71
|
+
export function applyTextColor(ctx, path, element, target, handled) {
|
|
72
|
+
if (handled.has('textColor') || !NO_TEXT_COLOR.has(target))
|
|
73
|
+
return;
|
|
74
|
+
const attr = findAttr(element, 'textColor');
|
|
75
|
+
if (!attr)
|
|
76
|
+
return;
|
|
77
|
+
handled.add('textColor');
|
|
78
|
+
applyPropAction(ctx, path, element, attr, { todo: NO_TEXT_COLOR_TODO });
|
|
79
|
+
}
|
|
@@ -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;
|
|
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,7 +21,9 @@
|
|
|
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';
|
|
26
|
+
import { applyTextColor } from '../_shared/text-color-props.js';
|
|
25
27
|
import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
|
|
26
28
|
import { BESTAX, bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
27
29
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
@@ -487,6 +489,8 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
487
489
|
applyPropAction(ctx, path, element, attr, action);
|
|
488
490
|
}
|
|
489
491
|
}
|
|
492
|
+
applyBackgroundColor(ctx, path, element, target, handled);
|
|
493
|
+
applyTextColor(ctx, path, element, target, handled);
|
|
490
494
|
applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
|
|
491
495
|
// After every prop pass: bestax's props follow `as`, so the element
|
|
492
496
|
// decides which of the props just written it can actually take. The
|
|
@@ -33,7 +33,7 @@ export const UNIVERSAL_PROPS = {
|
|
|
33
33
|
backgroundColor: { rename: 'bgColor' },
|
|
34
34
|
textColor: {},
|
|
35
35
|
colorVariant: {
|
|
36
|
-
todo: "no direct equivalent; use isLight (Button/Notification) or a color shade like bgColor='primary' backgroundColorShade='90'",
|
|
36
|
+
todo: "no direct equivalent; for 'light', use isLight (Button/Notification/Tag) or a color shade like bgColor='primary' backgroundColorShade='90'",
|
|
37
37
|
},
|
|
38
38
|
// TypographyProps
|
|
39
39
|
textSize: { numberToString: true },
|
|
@@ -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;
|
|
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,7 +15,9 @@
|
|
|
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';
|
|
20
|
+
import { applyTextColor } from '../_shared/text-color-props.js';
|
|
19
21
|
import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
|
|
20
22
|
import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
21
23
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
@@ -348,6 +350,8 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
348
350
|
applyPropAction(ctx, path, element, attr, action);
|
|
349
351
|
}
|
|
350
352
|
}
|
|
353
|
+
applyBackgroundColor(ctx, path, element, target, handled);
|
|
354
|
+
applyTextColor(ctx, path, element, target, handled);
|
|
351
355
|
applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
|
|
352
356
|
// Last: bestax's props follow `as`, so the element decides which of the
|
|
353
357
|
// props just written it can actually take.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.36.
|
|
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.
|
|
43
|
+
"@allxsmith/bestax-bulma": "^5.68.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/jscodeshift": "^17.3.0",
|