bestax-migrate 2.28.0 → 2.29.1
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/articles.d.ts +8 -0
- package/dist/sources/_shared/articles.d.ts.map +1 -0
- package/dist/sources/_shared/articles.js +9 -0
- package/dist/sources/_shared/polymorphic.d.ts.map +1 -1
- package/dist/sources/_shared/polymorphic.js +6 -5
- package/dist/sources/bloomer/specials.d.ts.map +1 -1
- package/dist/sources/bloomer/specials.js +3 -2
- package/dist/sources/bulma-classes/class-map.d.ts +28 -5
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -1
- package/dist/sources/bulma-classes/class-map.js +54 -7
- package/dist/sources/bulma-classes/plan.d.ts +12 -5
- package/dist/sources/bulma-classes/plan.d.ts.map +1 -1
- package/dist/sources/bulma-classes/plan.js +103 -36
- package/dist/sources/bulma-classes/rules.d.ts.map +1 -1
- package/dist/sources/bulma-classes/rules.js +1 -0
- package/dist/sources/bulma-classes/transform.d.ts +2 -1
- package/dist/sources/bulma-classes/transform.d.ts.map +1 -1
- package/dist/sources/bulma-classes/transform.js +10 -6
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tag with the article it takes in a TODO message, read aloud: "an <a>",
|
|
3
|
+
* "an <input>", "an <h2>", "a <button>", "a <ul>". A tag starting with a
|
|
4
|
+
* vowel letter takes "an", but `<u>` and `<ul>` (read "you"), and so does a
|
|
5
|
+
* heading (read "aitch").
|
|
6
|
+
*/
|
|
7
|
+
export declare function aTag(tag: string): string;
|
|
8
|
+
//# sourceMappingURL=articles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"articles.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/articles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tag with the article it takes in a TODO message, read aloud: "an <a>",
|
|
3
|
+
* "an <input>", "an <h2>", "a <button>", "a <ul>". A tag starting with a
|
|
4
|
+
* vowel letter takes "an", but `<u>` and `<ul>` (read "you"), and so does a
|
|
5
|
+
* heading (read "aitch").
|
|
6
|
+
*/
|
|
7
|
+
export function aTag(tag) {
|
|
8
|
+
return `${/^(?:[aeio]|h\d$)/.test(tag) ? 'an' : 'a'} <${tag}>`;
|
|
9
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polymorphic.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/polymorphic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"polymorphic.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/polymorphic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAyCxB,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAkB,CAAC;AAmK3E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,GAAG,SAAS,EAC5B,eAAa,KACZ,MAmBF,CAAC;AAMF,oDAAoD;AACpD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD;AAQD,mDAAmD;AACnD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAW,CAAC;AAC1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAAuB,CAAC;AAkEpE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAAkC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAwH5C,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AASD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED,0DAA0D;AAC1D,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAoC,CAAC;AAE7E,6CAA6C;AAC7C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAC1C,CAAC;AAqPrB;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM;AACd;;;;;;;;;GASG;AACH,gBAAgB,UAAQ,GACvB,IAAI,CAuEN"}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* Source-agnostic: what it knows is bestax's side of the rename, so all three
|
|
26
26
|
* sources run it over every element after their prop passes.
|
|
27
27
|
*/
|
|
28
|
+
import { aTag } from './articles.js';
|
|
28
29
|
import { addTodo, attrSource, findAttr, literalValueOf, removeAttr, } from './jsx-utils.js';
|
|
29
30
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
30
31
|
/**
|
|
@@ -506,7 +507,7 @@ function restrictAsValue(ctx, path, element, target, attr, literal) {
|
|
|
506
507
|
return;
|
|
507
508
|
const offered = allowed.map(a => `\`${a}\``).join(' / ');
|
|
508
509
|
removeAttr(element, attr);
|
|
509
|
-
addTodo(ctx, path, 'prop:as', `bestax \`${target}\` renders only ${offered}, so \`as="${literal.value}"\` cannot carry across — wrap it in
|
|
510
|
+
addTodo(ctx, path, 'prop:as', `bestax \`${target}\` renders only ${offered}, so \`as="${literal.value}"\` cannot carry across — wrap it in ${aTag(String(literal.value))} or restructure`);
|
|
510
511
|
ctx.dirty = true;
|
|
511
512
|
}
|
|
512
513
|
/**
|
|
@@ -550,7 +551,7 @@ function dropInertHref(ctx, path, element, target, literal, elementKnown) {
|
|
|
550
551
|
if (rendered === undefined) {
|
|
551
552
|
if (defaultEl === ANCHOR)
|
|
552
553
|
return;
|
|
553
|
-
drop(`bestax \`${target}\` renders
|
|
554
|
+
drop(`bestax \`${target}\` renders ${aTag(defaultEl)} unless \`as\` says otherwise, and only its <a> form carries an \`href\` -- set \`as="a"\` to make this a link, or ${nestOrClick(defaultEl)}`);
|
|
554
555
|
return;
|
|
555
556
|
}
|
|
556
557
|
if (rendered === ANCHOR)
|
|
@@ -561,8 +562,8 @@ function dropInertHref(ctx, path, element, target, literal, elementKnown) {
|
|
|
561
562
|
// `Level.Item` a <div> that compiles and quietly is not a link.
|
|
562
563
|
const remedy = defaultEl === ANCHOR
|
|
563
564
|
? `drop the \`as\` to make this a link, or ${nestOrClick(rendered)}`
|
|
564
|
-
: `set \`as="a"\` to make this a link -- dropping the \`as\` gives you
|
|
565
|
-
drop(`\`href\` on \`as="${rendered}"\`: bestax gives an element the attributes of the tag \`as\` names, and
|
|
565
|
+
: `set \`as="a"\` to make this a link -- dropping the \`as\` gives you ${aTag(defaultEl)} -- or ${nestOrClick(rendered)}`;
|
|
566
|
+
drop(`\`href\` on \`as="${rendered}"\`: bestax gives an element the attributes of the tag \`as\` names, and ${aTag(rendered)} takes no \`href\` (it navigated nowhere in the source either) -- ${remedy}`);
|
|
566
567
|
}
|
|
567
568
|
/**
|
|
568
569
|
* Drop a link attribute the rendered element does not take.
|
|
@@ -601,7 +602,7 @@ function dropInertLinkAttrs(ctx, path, element, target, rendered) {
|
|
|
601
602
|
const was = attrSource(ctx.j, attr);
|
|
602
603
|
removeAttr(element, attr);
|
|
603
604
|
const because = rejectedBy === 'element'
|
|
604
|
-
? `\`${name}\` needs an element that takes it, and \`${target}\` renders
|
|
605
|
+
? `\`${name}\` needs an element that takes it, and \`${target}\` renders ${aTag(rendered)} here`
|
|
605
606
|
: `bestax \`${target}\` is not a link at any \`as\`, so it takes no \`${name}\` either`;
|
|
606
607
|
addTodo(ctx, path, `prop:${name}`, `${because} -- ${was ? `it read \`${was}\`; ` : ''}${remedyFor(target, rendered)}`);
|
|
607
608
|
ctx.dirty = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EASL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,aAAa,EAAE,CAAC;AAyqC9B,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,GACX,aAAa,CAQf;AAED,eAAO,MAAM,aAAa,UAAwB,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { RENDER_TODO, RESPONSIVE_PROPS, UNIVERSAL_PROPS } from './mapping.js';
|
|
14
14
|
import { addAttr, attrSource, addTodo, attributesOf, findAttr, literalValueOf, makeAttr, removeAttr, resolveBooleanish, } from '../_shared/jsx-utils.js';
|
|
15
15
|
import { applyPropAction } from '../_shared/props.js';
|
|
16
|
+
import { aTag } from '../_shared/articles.js';
|
|
16
17
|
import { AS_UNIONS } from '../_shared/polymorphic.js';
|
|
17
18
|
import { applyIconProps, keepTitleLevel, makeStripModifierProps, makeStructuralHelpers, modifierClass, parseIconClasses, restrictAsToTargets, } from '../_shared/specials-utils.js';
|
|
18
19
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -190,9 +191,9 @@ function anchorWhenHref(ctx, path, element, options = {}) {
|
|
|
190
191
|
const other = dynamicTag
|
|
191
192
|
? 'the element `tag` named'
|
|
192
193
|
: tagValue?.kind === 'string'
|
|
193
|
-
?
|
|
194
|
+
? aTag(tagValue.value)
|
|
194
195
|
: options.bareAs
|
|
195
|
-
?
|
|
196
|
+
? aTag(options.bareAs)
|
|
196
197
|
: 'its default tag';
|
|
197
198
|
addTodo(ctx, path, 'prop:href', `bloomer chose the element at runtime — an <a> when \`href\` had a value, ${other} when it did not. bestax's \`as\` is one element or the other, and this is the anchor; render the other by hand where the \`href\` is empty`);
|
|
198
199
|
}
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* Every conversion this table allows must render exactly the HTML the raw
|
|
7
7
|
* element rendered. That is a claim about bestax, and the render tests hold
|
|
8
8
|
* it: each root, modifier and helper here is rendered through the built
|
|
9
|
-
* library and compared with the raw markup it replaces.
|
|
10
|
-
* purpose
|
|
9
|
+
* library and compared with the raw markup it replaces. The exceptions are
|
|
10
|
+
* on purpose. Font Awesome's own `<i aria-hidden="true">` alone in a `.icon`
|
|
11
11
|
* that carries nothing assistive tech reads converts to `Icon`, which writes
|
|
12
12
|
* the attribute on the `.icon` instead, since the glyph is hidden either way
|
|
13
|
-
* (see `readsGlyph`).
|
|
13
|
+
* (see `readsGlyph`). And a Bulma 0.9 helper v1 removed, which styles
|
|
14
|
+
* nothing under v1, converts as the v1 helper that does its job (see
|
|
15
|
+
* `REPLACED_IN_V1`).
|
|
14
16
|
*
|
|
15
17
|
* Data only: `scripts/gen-mcp-index.mjs` imports it directly for the MCP
|
|
16
18
|
* server's `lookup_bulma_classes`, so nothing Node cannot strip (no enums, no
|
|
@@ -301,8 +303,8 @@ export interface RootEntry {
|
|
|
301
303
|
* else, the target renders its children as given. An `<i>` that carries
|
|
302
304
|
* the `aria-hidden` the target writes, as Font Awesome's own markup does,
|
|
303
305
|
* reads too when the element carries nothing assistive tech reads: the
|
|
304
|
-
* attribute moves up onto it,
|
|
305
|
-
*
|
|
306
|
+
* attribute moves up onto it, a difference in markup a conversion makes
|
|
307
|
+
* on purpose.
|
|
306
308
|
*/
|
|
307
309
|
readonly readsGlyph?: ReadsGlyph;
|
|
308
310
|
/**
|
|
@@ -349,6 +351,12 @@ export interface RootEntry {
|
|
|
349
351
|
* no prop for them.
|
|
350
352
|
*/
|
|
351
353
|
readonly omits?: Readonly<Record<string, string>>;
|
|
354
|
+
/**
|
|
355
|
+
* Bulma styles this root's modifiers, and the classes it omits, only on
|
|
356
|
+
* the element that carries the root itself (`.image.is-64x64`), so on an
|
|
357
|
+
* element without it they do nothing, and the planner flags them.
|
|
358
|
+
*/
|
|
359
|
+
readonly modifiersNeedRoot?: boolean;
|
|
352
360
|
}
|
|
353
361
|
export declare const COLORS: readonly ["primary", "link", "info", "success", "warning", "danger", "black", "black-bis", "black-ter", "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", "white", "white-bis", "white-ter", "light", "dark"];
|
|
354
362
|
export declare const SIZES: readonly ["0", "1", "2", "3", "4", "5", "6", "auto"];
|
|
@@ -416,6 +424,15 @@ export declare const WRAPPER_OWN_PROPS: Readonly<Record<string, readonly string[
|
|
|
416
424
|
export declare const REMOVED_IN_V1: readonly string[];
|
|
417
425
|
/** Bulma 0.9 classes v1 dropped, with what replaced them. */
|
|
418
426
|
export declare const LEGACY_09: Readonly<Record<string, string>>;
|
|
427
|
+
/**
|
|
428
|
+
* Bulma 0.9 helpers v1 removed whose job a v1 helper does, with that helper.
|
|
429
|
+
* Each is a helper token for the v1 helper's prop, so wherever its element
|
|
430
|
+
* converts it becomes that prop, which renders the v1 class in its place:
|
|
431
|
+
* the conversion here that changes a class, since the class it replaces
|
|
432
|
+
* styles nothing under v1. Where its element stays markup, or the prop is
|
|
433
|
+
* not written, it gets its `LEGACY_09` TODO instead.
|
|
434
|
+
*/
|
|
435
|
+
export declare const REPLACED_IN_V1: Readonly<Record<string, string>>;
|
|
419
436
|
/**
|
|
420
437
|
* `text-color` and `background` resolve to a per-target prop (`RootEntry`'s
|
|
421
438
|
* `textColor`/`bgColor`); `flex-container` only renders beside a flex
|
|
@@ -460,8 +477,14 @@ export declare function placedFor(list: string): RootEntry | undefined;
|
|
|
460
477
|
export declare function flaggableRoot(token: string): RootEntry | undefined;
|
|
461
478
|
/** A root's modifier for a class. */
|
|
462
479
|
export declare function modifierFor(entry: RootEntry, token: string): Modifier | undefined;
|
|
480
|
+
/** Whether a root takes a class as a modifier, or omits it on purpose. */
|
|
481
|
+
export declare function modifiesRoot(entry: RootEntry, token: string): boolean;
|
|
482
|
+
/** The root a class modifies when Bulma styles it only on that root. */
|
|
483
|
+
export declare function rootItNeeds(token: string): string | undefined;
|
|
463
484
|
/** What replaced a Bulma 0.9 class v1 removed. */
|
|
464
485
|
export declare function legacyHint(token: string): string | undefined;
|
|
486
|
+
/** The v1 helper a removed Bulma 0.9 helper converts as. */
|
|
487
|
+
export declare function replacedBy(token: string): string | undefined;
|
|
465
488
|
/** The bestax wrapper for a plain tag. */
|
|
466
489
|
export declare function wrapperFor(tag: string): string | undefined;
|
|
467
490
|
//# sourceMappingURL=class-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class-map.ts"],"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,qCAAqC;AACrC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE5D;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE7D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAGlE;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,GACZ,QAAQ,GAAG,SAAS,CAEtB;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAKrE;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI7D;AAED,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5D;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5D;AAED,0CAA0C;AAC1C,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1D"}
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* Every conversion this table allows must render exactly the HTML the raw
|
|
7
7
|
* element rendered. That is a claim about bestax, and the render tests hold
|
|
8
8
|
* it: each root, modifier and helper here is rendered through the built
|
|
9
|
-
* library and compared with the raw markup it replaces.
|
|
10
|
-
* purpose
|
|
9
|
+
* library and compared with the raw markup it replaces. The exceptions are
|
|
10
|
+
* on purpose. Font Awesome's own `<i aria-hidden="true">` alone in a `.icon`
|
|
11
11
|
* that carries nothing assistive tech reads converts to `Icon`, which writes
|
|
12
12
|
* the attribute on the `.icon` instead, since the glyph is hidden either way
|
|
13
|
-
* (see `readsGlyph`).
|
|
13
|
+
* (see `readsGlyph`). And a Bulma 0.9 helper v1 removed, which styles
|
|
14
|
+
* nothing under v1, converts as the v1 helper that does its job (see
|
|
15
|
+
* `REPLACED_IN_V1`).
|
|
14
16
|
*
|
|
15
17
|
* Data only: `scripts/gen-mcp-index.mjs` imports it directly for the MCP
|
|
16
18
|
* server's `lookup_bulma_classes`, so nothing Node cannot strip (no enums, no
|
|
@@ -1072,10 +1074,22 @@ export const ROOTS = {
|
|
|
1072
1074
|
modifiers: {
|
|
1073
1075
|
...tokens('is-', COMPONENT_COLORS, 'color'),
|
|
1074
1076
|
...tokens('is-fixed-', ['top', 'bottom'], 'fixed'),
|
|
1075
|
-
...flags({
|
|
1077
|
+
...flags({
|
|
1078
|
+
'is-transparent': 'transparent',
|
|
1079
|
+
'is-spaced': 'isSpaced',
|
|
1080
|
+
'has-shadow': 'hasShadow',
|
|
1081
|
+
}),
|
|
1076
1082
|
},
|
|
1077
1083
|
defaults: { role: 'navigation', 'aria-label': 'main navigation' },
|
|
1078
|
-
ownProps: [
|
|
1084
|
+
ownProps: [
|
|
1085
|
+
'textColor',
|
|
1086
|
+
'color',
|
|
1087
|
+
'bgColor',
|
|
1088
|
+
'transparent',
|
|
1089
|
+
'isSpaced',
|
|
1090
|
+
'hasShadow',
|
|
1091
|
+
'fixed',
|
|
1092
|
+
],
|
|
1079
1093
|
},
|
|
1080
1094
|
// No background prop on these parts.
|
|
1081
1095
|
'navbar-brand': {
|
|
@@ -1464,6 +1478,7 @@ export const ROOTS = {
|
|
|
1464
1478
|
`is-${ratio}`,
|
|
1465
1479
|
'`size` renders `has-ratio` beside it as well',
|
|
1466
1480
|
])),
|
|
1481
|
+
modifiersNeedRoot: true,
|
|
1467
1482
|
absorbs: {
|
|
1468
1483
|
tag: 'img',
|
|
1469
1484
|
attributesOn: 'element',
|
|
@@ -1850,8 +1865,6 @@ export const ROOTS = {
|
|
|
1850
1865
|
'theme-dark': plain('a theme scope; bestax sets themes through `Theme`'),
|
|
1851
1866
|
'theme-light': plain('a theme scope; bestax sets themes through `Theme`'),
|
|
1852
1867
|
fa: plain("Font Awesome's own class, styled by Bulma inside `.icon`"),
|
|
1853
|
-
marginless: plain('a Bulma helper with no bestax prop'),
|
|
1854
|
-
paddingless: plain('a Bulma helper with no bestax prop'),
|
|
1855
1868
|
};
|
|
1856
1869
|
function todo(target, why) {
|
|
1857
1870
|
return { status: 'todo', target, why };
|
|
@@ -2035,6 +2048,20 @@ export const REMOVED_IN_V1 = [
|
|
|
2035
2048
|
/** Bulma 0.9 classes v1 dropped, with what replaced them. */
|
|
2036
2049
|
export const LEGACY_09 = {
|
|
2037
2050
|
tile: 'Bulma v1 removed tiles; rebuild the layout with `Grid` and `Cell` (see the Bulma 0.9 to 1 guide)',
|
|
2051
|
+
'is-marginless': 'Bulma v1 removed `is-marginless`, so it styles nothing now; write v1\'s `m-0` in its place, or `m="0"` on a bestax component. The codemod does that itself wherever the element converts',
|
|
2052
|
+
'is-paddingless': 'Bulma v1 removed `is-paddingless`, so it styles nothing now; write v1\'s `p-0` in its place, or `p="0"` on a bestax component. The codemod does that itself wherever the element converts',
|
|
2053
|
+
};
|
|
2054
|
+
/**
|
|
2055
|
+
* Bulma 0.9 helpers v1 removed whose job a v1 helper does, with that helper.
|
|
2056
|
+
* Each is a helper token for the v1 helper's prop, so wherever its element
|
|
2057
|
+
* converts it becomes that prop, which renders the v1 class in its place:
|
|
2058
|
+
* the conversion here that changes a class, since the class it replaces
|
|
2059
|
+
* styles nothing under v1. Where its element stays markup, or the prop is
|
|
2060
|
+
* not written, it gets its `LEGACY_09` TODO instead.
|
|
2061
|
+
*/
|
|
2062
|
+
export const REPLACED_IN_V1 = {
|
|
2063
|
+
'is-marginless': 'm-0',
|
|
2064
|
+
'is-paddingless': 'p-0',
|
|
2038
2065
|
};
|
|
2039
2066
|
function helperTokens(group, prefix, values, prop, suffix = '') {
|
|
2040
2067
|
return values.map(value => [
|
|
@@ -2071,6 +2098,9 @@ export const HELPER_TOKENS = new Map([
|
|
|
2071
2098
|
...helperTokens('text-color', 'has-text-', HELPER_COLORS, 'textColor'),
|
|
2072
2099
|
...helperTokens('background', 'has-background-', HELPER_COLORS, 'bgColor'),
|
|
2073
2100
|
...SPACING_PROPS.flatMap(prop => helperTokens('spacing', `${prop}-`, SIZES, prop)),
|
|
2101
|
+
// Bulma 0.9's, as the v1 helper that replaced each (`REPLACED_IN_V1`).
|
|
2102
|
+
['is-marginless', { group: 'spacing', write: { prop: 'm', value: '0' } }],
|
|
2103
|
+
['is-paddingless', { group: 'spacing', write: { prop: 'p', value: '0' } }],
|
|
2074
2104
|
...helperTokens('typography', 'is-size-', TEXT_SIZES, 'textSize'),
|
|
2075
2105
|
...helperPerViewport('typography', 'is-size-', TEXT_SIZES, 'textSize', SIZE_VIEWPORTS),
|
|
2076
2106
|
...helperTokens('typography', 'has-text-', ALIGNMENTS, 'textAlign'),
|
|
@@ -2173,6 +2203,10 @@ export const PASSTHROUGH = [
|
|
|
2173
2203
|
why: 'a Bulma helper with no bestax prop',
|
|
2174
2204
|
match: /^(?:is-display-.+|is-visibility-.+|is-float-.+|is-clear-.+|has-text-weight-extrabold|is-align-content-(?:baseline|start|end)|is-align-items-self-(?:start|end)|is-offset-0(?:-[a-z]+)?)$/,
|
|
2175
2205
|
},
|
|
2206
|
+
{
|
|
2207
|
+
why: 'Bulma\'s other name for `m-0` or `p-0`, with the same rule; bestax writes that rule as `m="0"` or `p="0"`, which renders `m-0` or `p-0`, so the class stays as it is',
|
|
2208
|
+
match: /^(?:marginless|paddingless)$/,
|
|
2209
|
+
},
|
|
2176
2210
|
{
|
|
2177
2211
|
why: 'a `.breadcrumb` separator, which converts only on its own `.breadcrumb`',
|
|
2178
2212
|
match: /^has-[a-z]+-separator$/,
|
|
@@ -2224,10 +2258,23 @@ export function flaggableRoot(token) {
|
|
|
2224
2258
|
export function modifierFor(entry, token) {
|
|
2225
2259
|
return entry.modifiers ? own(entry.modifiers, token) : undefined;
|
|
2226
2260
|
}
|
|
2261
|
+
/** Whether a root takes a class as a modifier, or omits it on purpose. */
|
|
2262
|
+
export function modifiesRoot(entry, token) {
|
|
2263
|
+
return (modifierFor(entry, token) !== undefined ||
|
|
2264
|
+
(entry.omits !== undefined && own(entry.omits, token) !== undefined));
|
|
2265
|
+
}
|
|
2266
|
+
/** The root a class modifies when Bulma styles it only on that root. */
|
|
2267
|
+
export function rootItNeeds(token) {
|
|
2268
|
+
return Object.keys(ROOTS).find(root => ROOTS[root].modifiersNeedRoot && modifiesRoot(ROOTS[root], token));
|
|
2269
|
+
}
|
|
2227
2270
|
/** What replaced a Bulma 0.9 class v1 removed. */
|
|
2228
2271
|
export function legacyHint(token) {
|
|
2229
2272
|
return own(LEGACY_09, token);
|
|
2230
2273
|
}
|
|
2274
|
+
/** The v1 helper a removed Bulma 0.9 helper converts as. */
|
|
2275
|
+
export function replacedBy(token) {
|
|
2276
|
+
return own(REPLACED_IN_V1, token);
|
|
2277
|
+
}
|
|
2231
2278
|
/** The bestax wrapper for a plain tag. */
|
|
2232
2279
|
export function wrapperFor(tag) {
|
|
2233
2280
|
return own(WRAPPERS, tag);
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* renders exactly the markup the element did. Anything that would change the
|
|
8
8
|
* markup is either left in `className` (a class with no prop here) or refuses
|
|
9
9
|
* the whole element with a TODO (an attribute or tag the component would
|
|
10
|
-
* render differently).
|
|
10
|
+
* render differently). The exceptions are on purpose. Font Awesome's own
|
|
11
11
|
* `<i aria-hidden="true">` alone in a `.icon` that carries nothing assistive
|
|
12
12
|
* tech reads (the table's `hiddenMovesBeside`) converts to `Icon`, which writes that attribute
|
|
13
13
|
* on the `.icon` instead (`movesHidden`), since the glyph is hidden either
|
|
14
|
-
* way.
|
|
14
|
+
* way. And a Bulma 0.9 helper v1 removed (`REPLACED_IN_V1`), which styles
|
|
15
|
+
* nothing under v1, converts as the v1 helper that does its job.
|
|
15
16
|
*/
|
|
16
17
|
import { type Glyph } from './glyph.js';
|
|
17
18
|
export interface ElementFacts {
|
|
@@ -107,6 +108,12 @@ export interface ElementFacts {
|
|
|
107
108
|
* The string the element's content renders, when it is one static text.
|
|
108
109
|
*/
|
|
109
110
|
text?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The element's `className` is computed in a way the codemod doesn't read
|
|
113
|
+
* whole (anything but a `clsx` or `classnames` call of parts it reads), so
|
|
114
|
+
* it may carry classes `tokens` doesn't hold.
|
|
115
|
+
*/
|
|
116
|
+
unreadClasses?: boolean;
|
|
110
117
|
/**
|
|
111
118
|
* The classes the element directly around this one renders: its static
|
|
112
119
|
* ones, or for a bestax component already in the file, its root class and
|
|
@@ -211,9 +218,9 @@ export interface Conversion {
|
|
|
211
218
|
glyph?: Glyph;
|
|
212
219
|
/**
|
|
213
220
|
* That child carried the `aria-hidden` the target writes on the element
|
|
214
|
-
* (Font Awesome's own `<i aria-hidden="true">`), so it moves up:
|
|
215
|
-
*
|
|
216
|
-
*
|
|
221
|
+
* (Font Awesome's own `<i aria-hidden="true">`), so it moves up: a way a
|
|
222
|
+
* conversion's markup differs from the element's on purpose, since the
|
|
223
|
+
* glyph is hidden either way. The render tests compare it with the
|
|
217
224
|
* attribute moved up, and nothing else.
|
|
218
225
|
*/
|
|
219
226
|
movesHidden?: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/plan.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,WA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,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACvE,0EAA0E;IAC1E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yDAAyD;IACzD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,2DAA2D;IAC3D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IACF,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAqDD,wBAAgB,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAsB9C"}
|
|
@@ -7,14 +7,16 @@
|
|
|
7
7
|
* renders exactly the markup the element did. Anything that would change the
|
|
8
8
|
* markup is either left in `className` (a class with no prop here) or refuses
|
|
9
9
|
* the whole element with a TODO (an attribute or tag the component would
|
|
10
|
-
* render differently).
|
|
10
|
+
* render differently). The exceptions are on purpose. Font Awesome's own
|
|
11
11
|
* `<i aria-hidden="true">` alone in a `.icon` that carries nothing assistive
|
|
12
12
|
* tech reads (the table's `hiddenMovesBeside`) converts to `Icon`, which writes that attribute
|
|
13
13
|
* on the `.icon` instead (`movesHidden`), since the glyph is hidden either
|
|
14
|
-
* way.
|
|
14
|
+
* way. And a Bulma 0.9 helper v1 removed (`REPLACED_IN_V1`), which styles
|
|
15
|
+
* nothing under v1, converts as the v1 helper that does its job.
|
|
15
16
|
*/
|
|
16
|
-
import { FORWARDS_REF, HELPER_PROPS, HELPER_TOKENS, inTagSet, legacyHint, modifierFor, numberAttrsOf, placedFor, PRECEDENCE, rootFor, WRAPPER_OWN_PROPS, wrapperFor, } from './class-map.js';
|
|
17
|
+
import { FORWARDS_REF, HELPER_PROPS, HELPER_TOKENS, inTagSet, legacyHint, modifierFor, modifiesRoot, numberAttrsOf, placedFor, PRECEDENCE, replacedBy, rootFor, rootItNeeds, WRAPPER_OWN_PROPS, wrapperFor, } from './class-map.js';
|
|
17
18
|
import { glyphProps, readDrawnGlyph, readGlyph, readHiddenGlyph, } from './glyph.js';
|
|
19
|
+
import { aTag } from '../_shared/articles.js';
|
|
18
20
|
import { ruleId } from './rules.js';
|
|
19
21
|
/** The button text `File` renders when it's given none. */
|
|
20
22
|
const DEFAULT_FILE_LABEL = 'Choose a file\u2026';
|
|
@@ -52,6 +54,13 @@ function precedence(token) {
|
|
|
52
54
|
function rootLabel(tokens) {
|
|
53
55
|
return tokens.find(token => rootFor(token)?.status === 'mapped') ?? 'button';
|
|
54
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether the target renders this tag: the one it renders by itself (or the
|
|
59
|
+
* heading its size picks), or one its `as` takes.
|
|
60
|
+
*/
|
|
61
|
+
function reachesTag(entry, tag, renders = entry.tag) {
|
|
62
|
+
return (tag === renders || entry.as === 'any' || (entry.as?.includes(tag) ?? false));
|
|
63
|
+
}
|
|
55
64
|
function tagsItReaches(entry) {
|
|
56
65
|
if (entry.as === 'any')
|
|
57
66
|
return 'any tag through `as`';
|
|
@@ -59,19 +68,66 @@ function tagsItReaches(entry) {
|
|
|
59
68
|
return entry.as.map(tag => `<${tag}>`).join(', ');
|
|
60
69
|
return `only <${entry.tag}>`;
|
|
61
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Every class the element may carry: its fixed ones, and any a condition
|
|
73
|
+
* adds, which the element has to be right with as well as without.
|
|
74
|
+
*/
|
|
75
|
+
function carriedBy(facts) {
|
|
76
|
+
return [...new Set([...facts.tokens, ...(facts.conditional ?? []).flat()])];
|
|
77
|
+
}
|
|
62
78
|
export function plan(facts) {
|
|
79
|
+
const result = planElement(facts);
|
|
80
|
+
// A Bulma 0.9 helper v1 removed converts as the v1 helper that replaced
|
|
81
|
+
// it, and only one that stays a class gets the TODO naming that helper:
|
|
82
|
+
// where it converted, nothing is left to do.
|
|
83
|
+
const kept = new Set(result.conversion?.className?.split(' ') ?? []);
|
|
84
|
+
const stays = carriedBy(facts).filter(token => replacedBy(token) &&
|
|
85
|
+
(!result.conversion || !facts.tokens.includes(token) || kept.has(token)));
|
|
86
|
+
if (stays.length === 0)
|
|
87
|
+
return result;
|
|
88
|
+
return {
|
|
89
|
+
...result,
|
|
90
|
+
todos: [
|
|
91
|
+
...result.todos,
|
|
92
|
+
...stays.map(token => ({
|
|
93
|
+
rule: ruleId('legacy', token),
|
|
94
|
+
message: legacyHint(token),
|
|
95
|
+
})),
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function planElement(facts) {
|
|
63
100
|
const todos = [];
|
|
64
101
|
const { tag, tokens } = facts;
|
|
65
|
-
|
|
66
|
-
// adds, which the element has to be right with as well as without.
|
|
67
|
-
const carried = [
|
|
68
|
-
...new Set([...tokens, ...(facts.conditional ?? []).flat()]),
|
|
69
|
-
];
|
|
102
|
+
const carried = carriedBy(facts);
|
|
70
103
|
const mayCarry = (token) => carried.includes(token);
|
|
71
104
|
for (const token of carried) {
|
|
72
|
-
|
|
105
|
+
// One that converts says so only if it stays, which `plan` knows.
|
|
106
|
+
const hint = replacedBy(token) ? undefined : legacyHint(token);
|
|
73
107
|
if (hint)
|
|
74
108
|
todos.push({ rule: ruleId('legacy', token), message: hint });
|
|
109
|
+
// A modifier Bulma styles only on its own root does nothing on an element
|
|
110
|
+
// with no root it modifies. That's a claim about every class the element
|
|
111
|
+
// carries, and the remedy drops one, so it's made only when the codemod
|
|
112
|
+
// reads them all. A re-run converts the element only on a tag the root's
|
|
113
|
+
// target renders, so only there does the advice promise one.
|
|
114
|
+
const root = rootItNeeds(token);
|
|
115
|
+
if (root &&
|
|
116
|
+
!facts.unreadClasses &&
|
|
117
|
+
!carried.some(other => {
|
|
118
|
+
const entry = rootFor(other);
|
|
119
|
+
return entry !== undefined && modifiesRoot(entry, token);
|
|
120
|
+
})) {
|
|
121
|
+
const needed = rootFor(root);
|
|
122
|
+
const article = /^[aeiou]/.test(root) ? 'an' : 'a';
|
|
123
|
+
const fix = reachesTag(needed, tag)
|
|
124
|
+
? `add \`${root}\`, which bestax \`${needed.target}\` renders, then re-run`
|
|
125
|
+
: `add \`${root}\` for Bulma to style it, though bestax \`${needed.target}\` renders ${tagsItReaches(needed)}, not ${aTag(tag)}, so the element stays markup`;
|
|
126
|
+
todos.push({
|
|
127
|
+
rule: ruleId('modifier', root),
|
|
128
|
+
message: `\`${token}\` is ${article} \`.${root}\` modifier, and Bulma styles it only on the element that carries \`.${root}\`, so on this one it styles nothing unless the project's own CSS gives it a rule; if this element is the ${root}, ${fix}, and otherwise drop the class`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
75
131
|
}
|
|
76
132
|
// A family this source leaves as markup keeps its element as markup, even
|
|
77
133
|
// beside a class it would convert (`navbar box`): the family's parts carry no
|
|
@@ -129,6 +185,23 @@ export function plan(facts) {
|
|
|
129
185
|
conversion: null,
|
|
130
186
|
todos: [...todos, { rule: ruleId(kind, token), message }],
|
|
131
187
|
});
|
|
188
|
+
// ---- The tag, first ------------------------------------------------------
|
|
189
|
+
// On a tag the target can't render, the tag is the work that comes first:
|
|
190
|
+
// any other refusal would ask for work (an attribute added or dropped, a
|
|
191
|
+
// child moved) that a re-run then refuses on the tag anyway.
|
|
192
|
+
let renders = entry.tag;
|
|
193
|
+
if (entry.sizeDrivesTag && tag !== 'p') {
|
|
194
|
+
const size = propsFrom(entry, tokens, tag, root, facts.attributes).writes.get('size');
|
|
195
|
+
if (size !== undefined)
|
|
196
|
+
renders = `h${size}`;
|
|
197
|
+
}
|
|
198
|
+
let as;
|
|
199
|
+
if (renders !== tag) {
|
|
200
|
+
if (!reachesTag(entry, tag, renders)) {
|
|
201
|
+
return refuse('tag', target, `bestax \`${target}\` renders ${tagsItReaches(entry)}, not ${aTag(tag)}; keep the markup, or change the tag and re-run`);
|
|
202
|
+
}
|
|
203
|
+
as = tag;
|
|
204
|
+
}
|
|
132
205
|
// ---- Refusals: the component would render something else ---------------
|
|
133
206
|
if (facts.hasSpread) {
|
|
134
207
|
return refuse('spread', target, `this element spreads props, which bestax \`${target}\` may read differently than the element did (a spread \`className\` merges with its classes instead of replacing them); convert it to \`${target}\` by hand`);
|
|
@@ -234,7 +307,7 @@ export function plan(facts) {
|
|
|
234
307
|
// Font Awesome's own markup hides the <i> rather than the element around
|
|
235
308
|
// it, and a target that renders the glyph from props writes the same
|
|
236
309
|
// `aria-hidden` on the element in its place: it moves up, and the glyph is
|
|
237
|
-
// hidden either way.
|
|
310
|
+
// hidden either way. A difference in markup a conversion makes on
|
|
238
311
|
// purpose; the render tests compare it with the attribute moved up. Only
|
|
239
312
|
// onto an element that carries nothing assistive tech reads, by name and
|
|
240
313
|
// whatever the value: an expression may render as anything.
|
|
@@ -342,46 +415,27 @@ export function plan(facts) {
|
|
|
342
415
|
if (!rule.on.includes(tag) || value === undefined)
|
|
343
416
|
continue;
|
|
344
417
|
if (typeof value !== 'string' || !rule.keeps.includes(value)) {
|
|
345
|
-
return refuse('attr', name, `bestax \`${target}\` keeps
|
|
418
|
+
return refuse('attr', name, `bestax \`${target}\` keeps ${aTag(tag)}'s \`${name}\` only as ${orList(rule.keeps)}, and writes \`${name}="${rule.fallback}"\` in place of anything else, so this one converts only ${rule.implicit ? `with no \`${name}\` or as one of those` : 'as one of those, written out'}; keep this element as markup`);
|
|
346
419
|
}
|
|
347
420
|
}
|
|
348
|
-
// Only on a tag the target renders: on any other, the tag check below is
|
|
349
|
-
// the refusal, and a `drops` one would call an attribute inert that may not
|
|
350
|
-
// be (`type` on a <button>) and promise a conversion a re-run still refuses.
|
|
351
|
-
const tagReached = tag === entry.tag ||
|
|
352
|
-
entry.as === 'any' ||
|
|
353
|
-
(entry.as?.includes(tag) ?? false);
|
|
354
421
|
for (const [name, tags] of Object.entries(entry.dropsAttr ?? {})) {
|
|
355
|
-
if (
|
|
422
|
+
if (attributes.has(name) && inTagSet(tags, tag)) {
|
|
356
423
|
// Bulma greys out `.button[disabled]` on any tag, so there it is not
|
|
357
424
|
// inert: dropping it changes how the element looks.
|
|
358
425
|
const visible = name === 'disabled' && target === 'Button';
|
|
359
426
|
// A `name` on an <a> still names the target of a `#fragment` link.
|
|
360
427
|
const anchored = name === 'name' && tag === 'a';
|
|
361
428
|
return refuse('drops', target, visible
|
|
362
|
-
? `bestax \`${target}\` drops \`disabled\` on
|
|
429
|
+
? `bestax \`${target}\` drops \`disabled\` on ${aTag(tag)}, and Bulma styles a disabled \`.${rootLabel(facts.tokens)}\` on any tag, so converting would change how it looks; keep this element as markup`
|
|
363
430
|
: anchored
|
|
364
431
|
? `bestax \`${target}\` drops \`name\` on an <a>, where it still names the target of a \`#fragment\` link; keep this element as markup, or move the target to an \`id\`, then re-run`
|
|
365
|
-
: `bestax \`${target}\` drops \`${name}\` on
|
|
432
|
+
: `bestax \`${target}\` drops \`${name}\` on ${aTag(tag)}, where it does nothing anyway; remove it, then re-run`);
|
|
366
433
|
}
|
|
367
434
|
}
|
|
368
435
|
// ---- Tokens → props ---------------------------------------------------------
|
|
369
436
|
const fromTokens = propsFrom(entry, tokens, tag, root, attributes);
|
|
370
437
|
const { writes, converted } = fromTokens;
|
|
371
438
|
numbers.push(...fromTokens.numbers);
|
|
372
|
-
// ---- The tag ------------------------------------------------------------
|
|
373
|
-
let renders = entry.tag;
|
|
374
|
-
if (entry.sizeDrivesTag && tag !== 'p' && writes.has('size')) {
|
|
375
|
-
renders = `h${writes.get('size')}`;
|
|
376
|
-
}
|
|
377
|
-
let as;
|
|
378
|
-
if (renders !== tag) {
|
|
379
|
-
const reachable = entry.as === 'any' || (entry.as?.includes(tag) ?? false);
|
|
380
|
-
if (!reachable) {
|
|
381
|
-
return refuse('tag', target, `bestax \`${target}\` renders ${tagsItReaches(entry)}, not a <${tag}>; keep the markup, or change the tag and re-run`);
|
|
382
|
-
}
|
|
383
|
-
as = tag;
|
|
384
|
-
}
|
|
385
439
|
// Last, since what the children are can change once a refusal leaves
|
|
386
440
|
// them to convert on their own, and a re-run has to find the same reason.
|
|
387
441
|
let icons;
|
|
@@ -646,7 +700,7 @@ function hiddenAdvice(facts, entry, usual) {
|
|
|
646
700
|
}
|
|
647
701
|
const around = facts.clickableAround;
|
|
648
702
|
const label = around?.label;
|
|
649
|
-
const tag = around &&
|
|
703
|
+
const tag = around && aTag(around.tag);
|
|
650
704
|
if (label && label !== 'none') {
|
|
651
705
|
const by = label === 'text' ? 'its own text' : `its \`${label}\``;
|
|
652
706
|
return `this \`.icon\` sits in ${tag} that ${by} names, so the icon is decoration there, and bestax \`${target}\` writes \`aria-hidden="true"\` on an icon with no name of its own, which this one doesn't carry; add it, then re-run${outcome}${hint}`;
|
|
@@ -765,6 +819,15 @@ function buildIcons(children, target) {
|
|
|
765
819
|
* base `display` beside a per-viewport one, a flex-container helper with no
|
|
766
820
|
* flex `display`, `gapless` beside a `gap`) stays a class, as does one it
|
|
767
821
|
* leaves out, and so does a modifier missing the attribute it needs.
|
|
822
|
+
*
|
|
823
|
+
* The first class to claim a prop keeps it, but a Bulma 0.9 class v1 removed
|
|
824
|
+
* claims one only after every other class has: whatever the order, a live
|
|
825
|
+
* class beside it for the same prop (`p-2 is-paddingless`) is what the page
|
|
826
|
+
* renders today and keeps the prop, and the removed one stays a class, with
|
|
827
|
+
* the TODO `plan` gives it. Beside a class for a different prop, such as an
|
|
828
|
+
* axis (`px-2 is-paddingless`), it still converts: the two render `px-2` and
|
|
829
|
+
* `p-0`, and v1's stylesheet puts every side and axis class after `p-0`, so
|
|
830
|
+
* the axis keeps its sides and `p-0` zeroes the rest.
|
|
768
831
|
*/
|
|
769
832
|
function propsFrom(entry, tokens, tag, root, attributes) {
|
|
770
833
|
const numbers = [];
|
|
@@ -774,7 +837,11 @@ function propsFrom(entry, tokens, tag, root, attributes) {
|
|
|
774
837
|
const sourceOf = new Map();
|
|
775
838
|
const groupOf = new Map();
|
|
776
839
|
const converted = new Set(root ? [root] : []);
|
|
777
|
-
|
|
840
|
+
const claiming = [
|
|
841
|
+
...tokens.filter(token => !replacedBy(token)),
|
|
842
|
+
...tokens.filter(token => replacedBy(token)),
|
|
843
|
+
];
|
|
844
|
+
for (const token of claiming) {
|
|
778
845
|
if (converted.has(token))
|
|
779
846
|
continue;
|
|
780
847
|
const modifier = modifierFor(entry, token);
|
|
@@ -1026,7 +1093,7 @@ function planFold(facts, wrapper, todos) {
|
|
|
1026
1093
|
todos: [...todos, { rule: ruleId(kind, token), message }],
|
|
1027
1094
|
});
|
|
1028
1095
|
if (facts.tag !== entry.tag) {
|
|
1029
|
-
return refuse('tag', target, `bestax ${renders} renders \`.${wrapper}\` on
|
|
1096
|
+
return refuse('tag', target, `bestax ${renders} renders \`.${wrapper}\` on ${aTag(entry.tag)}, not ${aTag(facts.tag)}; keep the markup, or change the tag and re-run`);
|
|
1030
1097
|
}
|
|
1031
1098
|
if (facts.hasSpread) {
|
|
1032
1099
|
return refuse('spread', target, `this element spreads props, and bestax ${renders} renders \`.${wrapper}\` with none of its own; keep it as markup`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,MAAM,CAcpC,CAAC;AAqCH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK1D"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* scope when a lowercase JSX element carries a `className` with a Bulma class
|
|
6
6
|
* `class-map.ts` knows. Each such element goes through `plan()`, which
|
|
7
7
|
* converts it only when the component renders exactly the same markup, but
|
|
8
|
-
* for the
|
|
8
|
+
* for the exceptions it states (Font Awesome's hidden `<i>`, and a Bulma 0.9
|
|
9
|
+
* helper v1 removed).
|
|
9
10
|
*
|
|
10
11
|
* Passes, in order:
|
|
11
12
|
* 1. the shared stylesheet-import pass (a no-op under the default `keep`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/transform.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAkiCvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAy9BpB"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* scope when a lowercase JSX element carries a `className` with a Bulma class
|
|
6
6
|
* `class-map.ts` knows. Each such element goes through `plan()`, which
|
|
7
7
|
* converts it only when the component renders exactly the same markup, but
|
|
8
|
-
* for the
|
|
8
|
+
* for the exceptions it states (Font Awesome's hidden `<i>`, and a Bulma 0.9
|
|
9
|
+
* helper v1 removed).
|
|
9
10
|
*
|
|
10
11
|
* Passes, in order:
|
|
11
12
|
* 1. the shared stylesheet-import pass (a no-op under the default `keep`)
|
|
@@ -1246,6 +1247,11 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
1246
1247
|
const className = classAttr ? staticClassName(classAttr) : '';
|
|
1247
1248
|
const surrounding = around(elementPath);
|
|
1248
1249
|
const sole = soleChild(element);
|
|
1250
|
+
// A joiner call the codemod can read converts exactly: its fixed classes
|
|
1251
|
+
// as for a static className, and each condition on a flag as its prop.
|
|
1252
|
+
const joined = className === null
|
|
1253
|
+
? readJoiner(classAttr.value, callee => isJoiner(callee, elementPath))
|
|
1254
|
+
: undefined;
|
|
1249
1255
|
const facts = {
|
|
1250
1256
|
tag: name.name,
|
|
1251
1257
|
tokens: className === null
|
|
@@ -1271,15 +1277,13 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
1271
1277
|
holderOnlyChildOf: onlyChildOf(elementPath.parent, bestaxLocals),
|
|
1272
1278
|
}),
|
|
1273
1279
|
...(textOf(element) !== undefined && { text: textOf(element) }),
|
|
1280
|
+
// Any other computed className may carry classes its strings don't
|
|
1281
|
+
// show (a variable, a call).
|
|
1282
|
+
...(className === null && !joined && { unreadClasses: true }),
|
|
1274
1283
|
};
|
|
1275
1284
|
if (facts.tokens.some(token => rootFor(token)?.readsGlyph)) {
|
|
1276
1285
|
Object.assign(facts, glyphPlace(elementPath));
|
|
1277
1286
|
}
|
|
1278
|
-
// A joiner call the codemod can read converts exactly: its fixed classes
|
|
1279
|
-
// as for a static className, and each condition on a flag as its prop.
|
|
1280
|
-
const joined = className === null
|
|
1281
|
-
? readJoiner(classAttr.value, callee => isJoiner(callee, elementPath))
|
|
1282
|
-
: undefined;
|
|
1283
1287
|
let exact;
|
|
1284
1288
|
if (joined) {
|
|
1285
1289
|
exact = plan({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.1",
|
|
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": "^7.3.0",
|
|
42
42
|
"property-information": "^7.2.0",
|
|
43
|
-
"@allxsmith/bestax-bulma": "^5.
|
|
43
|
+
"@allxsmith/bestax-bulma": "^5.39.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@jest/globals": "^30.0.0",
|