bestax-migrate 2.36.6 → 2.37.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.
@@ -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
@@ -0,0 +1,14 @@
1
+ import type { ASTPath } from 'jscodeshift';
2
+ import { type TransformContext } from '../_shared/jsx-utils.js';
3
+ /**
4
+ * react-bulma-components renders `colorVariant` as the `is-light` or
5
+ * `is-dark` class, whatever else the element sets. On a target in
6
+ * `IS_LIGHT_TARGETS`, a literal `light` becomes a bare `isLight`, which
7
+ * renders `is-light`, in place of any `isLight` the element already has
8
+ * (Notification's own `light`, converted before this runs). Anything else is
9
+ * left to the universal `colorVariant` TODO: another value, a dynamic one,
10
+ * one a later spread could override, and another target, a Button that
11
+ * becomes `Delete` included.
12
+ */
13
+ export declare function applyColorVariant(ctx: TransformContext, path: ASTPath<any>, element: any, target: string, handled: Set<string>): void;
14
+ //# sourceMappingURL=color-variant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-variant.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/color-variant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,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,CAoBN"}
@@ -0,0 +1,37 @@
1
+ import { findAttr, literalValueOf, removeAttr, } from '../_shared/jsx-utils.js';
2
+ import { addConverted } from '../_shared/props.js';
3
+ import { IS_LIGHT_TARGETS } from './mapping.js';
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ /**
6
+ * react-bulma-components renders `colorVariant` as the `is-light` or
7
+ * `is-dark` class, whatever else the element sets. On a target in
8
+ * `IS_LIGHT_TARGETS`, a literal `light` becomes a bare `isLight`, which
9
+ * renders `is-light`, in place of any `isLight` the element already has
10
+ * (Notification's own `light`, converted before this runs). Anything else is
11
+ * left to the universal `colorVariant` TODO: another value, a dynamic one,
12
+ * one a later spread could override, and another target, a Button that
13
+ * becomes `Delete` included.
14
+ */
15
+ export function applyColorVariant(ctx, path, element, target, handled) {
16
+ if (!IS_LIGHT_TARGETS.includes(target))
17
+ return;
18
+ const attr = findAttr(element, 'colorVariant');
19
+ if (!attr)
20
+ return;
21
+ const literal = literalValueOf(attr);
22
+ if (literal.kind !== 'string' || literal.value !== 'light')
23
+ return;
24
+ const attrs = element.openingElement.attributes;
25
+ if (attrs
26
+ .slice(attrs.indexOf(attr) + 1)
27
+ .some(a => a.type === 'JSXSpreadAttribute')) {
28
+ return;
29
+ }
30
+ handled.add('colorVariant');
31
+ removeAttr(element, attr);
32
+ const isLight = findAttr(element, 'isLight');
33
+ if (isLight)
34
+ removeAttr(element, isLight);
35
+ addConverted(ctx, path, element, 'colorVariant', 'isLight', undefined);
36
+ ctx.dirty = true;
37
+ }
@@ -19,6 +19,13 @@ import type { ComponentMapping, PropAction } from '../../types.js';
19
19
  export declare const UNIVERSAL_PROPS: Record<string, PropAction>;
20
20
  /** Breakpoint-object props flattened by the responsive pass. */
21
21
  export declare const RESPONSIVE_BREAKPOINTS: Record<string, string | null>;
22
+ /**
23
+ * The targets whose bestax component renders `is-light` from `isLight`, the
24
+ * class react-bulma-components renders for `colorVariant="light"`.
25
+ * `color-variant.ts` converts a literal `light` there; everything else keeps
26
+ * the universal `colorVariant` TODO.
27
+ */
28
+ export declare const IS_LIGHT_TARGETS: readonly string[];
22
29
  export declare const MAPPING: Record<string, ComponentMapping>;
23
30
  /**
24
31
  * The complete react-bulma-components v4.1.0 public surface, vendored from its
@@ -1 +1 @@
1
- {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQnE;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAgFtD,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAUhE,CAAC;AAIF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAkrBpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAsEhD,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAM3E"}
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQnE;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAgFtD,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAUhE,CAAC;AAIF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAI7C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAkrBpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAsEhD,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAM3E"}
@@ -113,6 +113,17 @@ export const RESPONSIVE_BREAKPOINTS = {
113
113
  untilFullhd: null,
114
114
  };
115
115
  const activeKept = { active: {} };
116
+ /**
117
+ * The targets whose bestax component renders `is-light` from `isLight`, the
118
+ * class react-bulma-components renders for `colorVariant="light"`.
119
+ * `color-variant.ts` converts a literal `light` there; everything else keeps
120
+ * the universal `colorVariant` TODO.
121
+ */
122
+ export const IS_LIGHT_TARGETS = [
123
+ 'Button',
124
+ 'Notification',
125
+ 'Tag',
126
+ ];
116
127
  export const MAPPING = {
117
128
  Block: { status: 'mapped', target: 'Block' },
118
129
  Box: { status: 'mapped', target: 'Box' },
@@ -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;AAuCvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAgxBpB"}
@@ -15,12 +15,14 @@
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';
21
22
  import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
22
23
  import { rewriteStylesheetImports } from '../_shared/css-imports.js';
23
24
  import { collectBoundNames, makeAliasRegistry, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
25
+ import { applyColorVariant } from './color-variant.js';
24
26
  import { flattenResponsiveProps } from './responsive.js';
25
27
  import { RESPONSIVE_KINDS, runSpecial } from './specials.js';
26
28
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -349,6 +351,8 @@ export default function transform(fileInfo, api, options = {}) {
349
351
  applyPropAction(ctx, path, element, attr, action);
350
352
  }
351
353
  }
354
+ applyColorVariant(ctx, path, element, target, handled);
355
+ applyBackgroundColor(ctx, path, element, target, handled);
352
356
  applyTextColor(ctx, path, element, target, handled);
353
357
  applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
354
358
  // 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.37.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.1"
43
+ "@allxsmith/bestax-bulma": "^5.68.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/jscodeshift": "^17.3.0",