bestax-migrate 2.37.0 → 2.38.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.
|
@@ -11,13 +11,37 @@ import { type TransformContext } from './jsx-utils.js';
|
|
|
11
11
|
* name, to the library's types.
|
|
12
12
|
*/
|
|
13
13
|
export declare const NO_TEXT_COLOR: ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
* The targets in `NO_TEXT_COLOR` whose `color` prop is the text color helper
|
|
16
|
+
* (`Table` and its `Thead`, `Tbody` and `Tfoot`, `Menu` and its parts, and
|
|
17
|
+
* `Dropdown` and its `Item`, but not `Table.Tr`, `Td` or `Th`, whose `color`
|
|
18
|
+
* is their own modifier),
|
|
19
|
+
* rendering `has-text-<color>` as a source's `textColor` did, so `textColor`
|
|
20
|
+
* becomes `color` there. A component's own `color` can share the helper's
|
|
21
|
+
* type and mean something else (Hero's renders `is-<color>`), so
|
|
22
|
+
* `e2e/text-color-props.test.ts` renders each one to check.
|
|
23
|
+
*/
|
|
24
|
+
export declare const TEXT_COLOR_VIA_COLOR: ReadonlySet<string>;
|
|
14
25
|
/** The TODO a target that takes no `textColor` gets. */
|
|
15
26
|
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
27
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
28
|
+
* The values the rename writes into `color`: bestax's color names, which the
|
|
29
|
+
* bulma-classes tests hold to its own, and the two keywords. The e2e checks
|
|
30
|
+
* every listed target's `color` takes all of them.
|
|
31
|
+
*/
|
|
32
|
+
export declare const HELPER_COLORS: readonly string[];
|
|
33
|
+
/** The TODO where `color` carries the text color but the element already sets it. */
|
|
34
|
+
export declare const COLOR_TAKEN_TODO = "this bestax component takes no `textColor` prop, and its `color`, which renders `has-text-*` here, is set on this element or may come from a spread; reconcile the two by hand";
|
|
35
|
+
/** The TODO where `color` carries the text color but may not take this value. */
|
|
36
|
+
export declare const COLOR_VALUE_TODO = "this bestax component takes no `textColor` prop; its `color` renders `has-text-*` for bestax's color names, with `colorShade` for a shade, so use those, or move the color to a `has-text-*` class in `className`";
|
|
37
|
+
/**
|
|
38
|
+
* Handle the element's `textColor` where `target` takes no such prop: rename
|
|
39
|
+
* it to `color` where that is the target's text color helper, the element
|
|
40
|
+
* sets no `color` of its own (nor has a spread that could) and the value is
|
|
41
|
+
* one of bestax's color names,
|
|
42
|
+
* and leave a TODO otherwise. Either way it's marked handled, so the
|
|
43
|
+
* universal pass leaves it alone. Should a component's own prop map ever
|
|
44
|
+
* claim `textColor`, it wins, as it does for every prop.
|
|
21
45
|
*/
|
|
22
46
|
export declare function applyTextColor(ctx: TransformContext, path: ASTPath<any>, element: any, target: string, handled: Set<string>): void;
|
|
23
47
|
//# sourceMappingURL=text-color-props.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAE3C,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAKxB;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAgD5C,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAWnD,CAAC;AAEH,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,2GAC2E,CAAC;AAE3G;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAI1C,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,mLACqJ,CAAC;AAEnL,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,sNACwL,CAAC;AAEtN;;;;;;;;GAQG;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,CA0BN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { COLORS } from '../bulma-classes/class-map.js';
|
|
2
|
+
import { findAttr, literalValueOf, } from './jsx-utils.js';
|
|
2
3
|
import { applyPropAction } from './props.js';
|
|
3
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
5
|
/**
|
|
@@ -60,13 +61,52 @@ export const NO_TEXT_COLOR = new Set([
|
|
|
60
61
|
'Tags',
|
|
61
62
|
'TextArea',
|
|
62
63
|
]);
|
|
64
|
+
/**
|
|
65
|
+
* The targets in `NO_TEXT_COLOR` whose `color` prop is the text color helper
|
|
66
|
+
* (`Table` and its `Thead`, `Tbody` and `Tfoot`, `Menu` and its parts, and
|
|
67
|
+
* `Dropdown` and its `Item`, but not `Table.Tr`, `Td` or `Th`, whose `color`
|
|
68
|
+
* is their own modifier),
|
|
69
|
+
* rendering `has-text-<color>` as a source's `textColor` did, so `textColor`
|
|
70
|
+
* becomes `color` there. A component's own `color` can share the helper's
|
|
71
|
+
* type and mean something else (Hero's renders `is-<color>`), so
|
|
72
|
+
* `e2e/text-color-props.test.ts` renders each one to check.
|
|
73
|
+
*/
|
|
74
|
+
export const TEXT_COLOR_VIA_COLOR = new Set([
|
|
75
|
+
'Dropdown',
|
|
76
|
+
'Dropdown.Item',
|
|
77
|
+
'Menu',
|
|
78
|
+
'Menu.Item',
|
|
79
|
+
'Menu.Label',
|
|
80
|
+
'Menu.List',
|
|
81
|
+
'Table',
|
|
82
|
+
'Table.Tbody',
|
|
83
|
+
'Table.Tfoot',
|
|
84
|
+
'Table.Thead',
|
|
85
|
+
]);
|
|
63
86
|
/** The TODO a target that takes no `textColor` gets. */
|
|
64
87
|
export const NO_TEXT_COLOR_TODO = 'this bestax component takes no `textColor` prop; move the color to a `has-text-*` class in `className`';
|
|
65
88
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
|
|
89
|
+
* The values the rename writes into `color`: bestax's color names, which the
|
|
90
|
+
* bulma-classes tests hold to its own, and the two keywords. The e2e checks
|
|
91
|
+
* every listed target's `color` takes all of them.
|
|
92
|
+
*/
|
|
93
|
+
export const HELPER_COLORS = [
|
|
94
|
+
...COLORS,
|
|
95
|
+
'inherit',
|
|
96
|
+
'current',
|
|
97
|
+
];
|
|
98
|
+
/** The TODO where `color` carries the text color but the element already sets it. */
|
|
99
|
+
export const COLOR_TAKEN_TODO = 'this bestax component takes no `textColor` prop, and its `color`, which renders `has-text-*` here, is set on this element or may come from a spread; reconcile the two by hand';
|
|
100
|
+
/** The TODO where `color` carries the text color but may not take this value. */
|
|
101
|
+
export const COLOR_VALUE_TODO = "this bestax component takes no `textColor` prop; its `color` renders `has-text-*` for bestax's color names, with `colorShade` for a shade, so use those, or move the color to a `has-text-*` class in `className`";
|
|
102
|
+
/**
|
|
103
|
+
* Handle the element's `textColor` where `target` takes no such prop: rename
|
|
104
|
+
* it to `color` where that is the target's text color helper, the element
|
|
105
|
+
* sets no `color` of its own (nor has a spread that could) and the value is
|
|
106
|
+
* one of bestax's color names,
|
|
107
|
+
* and leave a TODO otherwise. Either way it's marked handled, so the
|
|
108
|
+
* universal pass leaves it alone. Should a component's own prop map ever
|
|
109
|
+
* claim `textColor`, it wins, as it does for every prop.
|
|
70
110
|
*/
|
|
71
111
|
export function applyTextColor(ctx, path, element, target, handled) {
|
|
72
112
|
if (handled.has('textColor') || !NO_TEXT_COLOR.has(target))
|
|
@@ -75,5 +115,16 @@ export function applyTextColor(ctx, path, element, target, handled) {
|
|
|
75
115
|
if (!attr)
|
|
76
116
|
return;
|
|
77
117
|
handled.add('textColor');
|
|
78
|
-
|
|
118
|
+
if (!TEXT_COLOR_VIA_COLOR.has(target)) {
|
|
119
|
+
applyPropAction(ctx, path, element, attr, { todo: NO_TEXT_COLOR_TODO });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const spread = element.openingElement.attributes.some((a) => a.type === 'JSXSpreadAttribute');
|
|
123
|
+
if (spread || findAttr(element, 'color')) {
|
|
124
|
+
applyPropAction(ctx, path, element, attr, { todo: COLOR_TAKEN_TODO });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const literal = literalValueOf(attr);
|
|
128
|
+
const known = literal.kind === 'string' && HELPER_COLORS.includes(literal.value);
|
|
129
|
+
applyPropAction(ctx, path, element, attr, known ? { rename: 'color' } : { todo: COLOR_VALUE_TODO });
|
|
79
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.0",
|
|
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.4"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/jscodeshift": "^17.3.0",
|