bestax-migrate 2.36.7 → 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,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;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"}
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"}
@@ -22,6 +22,7 @@ import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
22
22
  import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
23
23
  import { rewriteStylesheetImports } from '../_shared/css-imports.js';
24
24
  import { collectBoundNames, makeAliasRegistry, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
25
+ import { applyColorVariant } from './color-variant.js';
25
26
  import { flattenResponsiveProps } from './responsive.js';
26
27
  import { RESPONSIVE_KINDS, runSpecial } from './specials.js';
27
28
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -350,6 +351,7 @@ export default function transform(fileInfo, api, options = {}) {
350
351
  applyPropAction(ctx, path, element, attr, action);
351
352
  }
352
353
  }
354
+ applyColorVariant(ctx, path, element, target, handled);
353
355
  applyBackgroundColor(ctx, path, element, target, handled);
354
356
  applyTextColor(ctx, path, element, target, handled);
355
357
  applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bestax-migrate",
3
- "version": "2.36.7",
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.2"
43
+ "@allxsmith/bestax-bulma": "^5.68.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/jscodeshift": "^17.3.0",