bestax-migrate 2.38.0 → 2.38.2
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/display.d.ts +27 -0
- package/dist/sources/_shared/display.d.ts.map +1 -0
- package/dist/sources/_shared/display.js +123 -0
- package/dist/sources/bloomer/mapping.d.ts.map +1 -1
- package/dist/sources/bloomer/mapping.js +3 -10
- package/dist/sources/bloomer/responsive.d.ts +4 -2
- package/dist/sources/bloomer/responsive.d.ts.map +1 -1
- package/dist/sources/bloomer/responsive.js +4 -2
- package/dist/sources/bloomer/specials.d.ts +1 -1
- package/dist/sources/bloomer/specials.d.ts.map +1 -1
- package/dist/sources/bloomer/specials.js +60 -2
- package/dist/sources/bloomer/transform.d.ts.map +1 -1
- package/dist/sources/bloomer/transform.js +4 -0
- package/dist/sources/bulma-classes/class-map.d.ts +8 -2
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -1
- package/dist/sources/bulma-classes/class-map.js +33 -5
- package/dist/sources/bulma-classes/plan.js +10 -5
- package/dist/sources/rbx/mapping.js +1 -1
- package/dist/sources/rbx/specials.d.ts.map +1 -1
- package/dist/sources/rbx/specials.js +7 -9
- package/dist/sources/react-bulma-components/mapping.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/mapping.js +4 -2
- package/dist/sources/react-bulma-components/specials.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/specials.js +7 -4
- 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,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps a base `display` that a source wrote beside a per-viewport one.
|
|
3
|
+
*
|
|
4
|
+
* bestax leaves the base `display`'s class out once any per-viewport display
|
|
5
|
+
* prop is set (`useVisibilityClasses` in bestax-bulma, which #1748 proposes to
|
|
6
|
+
* change in the next major), so a source that flattened
|
|
7
|
+
* `isDisplay={['inline-block', 'flex-desktop']}` or
|
|
8
|
+
* `display="flex" mobile={{ display: 'block' }}` into `display` plus
|
|
9
|
+
* `display<Viewport>` lost the base value: the source rendered
|
|
10
|
+
* `is-inline-block is-flex-desktop`, and bestax only `is-flex-desktop`.
|
|
11
|
+
*
|
|
12
|
+
* So the base value stays the class it stood for, in `className`, as the
|
|
13
|
+
* bulma-classes source keeps one. The flex container props render only beside
|
|
14
|
+
* a flex `display` prop, so when the base value was the flex display and no
|
|
15
|
+
* per-viewport one is, they go into `className` the same way. A value bestax
|
|
16
|
+
* doesn't take is left where it was, as the source left it: the lists are the
|
|
17
|
+
* class map's, which its value-union test holds to bestax-bulma's constants.
|
|
18
|
+
*
|
|
19
|
+
* Where a per-viewport display, the base value, the `className` or a
|
|
20
|
+
* container prop it would move is dynamic, or the element takes a spread,
|
|
21
|
+
* which could hold any of them, it changes nothing and leaves a TODO naming
|
|
22
|
+
* what to move.
|
|
23
|
+
*/
|
|
24
|
+
import type { ASTPath } from 'jscodeshift';
|
|
25
|
+
import { type TransformContext } from './jsx-utils.js';
|
|
26
|
+
export declare function keepBaseDisplay(ctx: TransformContext, path: ASTPath<any>, element: any): void;
|
|
27
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAS3C,OAAO,EAOL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AA6BxB,wBAAgB,eAAe,CAC7B,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,GACX,IAAI,CA4FN"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps a base `display` that a source wrote beside a per-viewport one.
|
|
3
|
+
*
|
|
4
|
+
* bestax leaves the base `display`'s class out once any per-viewport display
|
|
5
|
+
* prop is set (`useVisibilityClasses` in bestax-bulma, which #1748 proposes to
|
|
6
|
+
* change in the next major), so a source that flattened
|
|
7
|
+
* `isDisplay={['inline-block', 'flex-desktop']}` or
|
|
8
|
+
* `display="flex" mobile={{ display: 'block' }}` into `display` plus
|
|
9
|
+
* `display<Viewport>` lost the base value: the source rendered
|
|
10
|
+
* `is-inline-block is-flex-desktop`, and bestax only `is-flex-desktop`.
|
|
11
|
+
*
|
|
12
|
+
* So the base value stays the class it stood for, in `className`, as the
|
|
13
|
+
* bulma-classes source keeps one. The flex container props render only beside
|
|
14
|
+
* a flex `display` prop, so when the base value was the flex display and no
|
|
15
|
+
* per-viewport one is, they go into `className` the same way. A value bestax
|
|
16
|
+
* doesn't take is left where it was, as the source left it: the lists are the
|
|
17
|
+
* class map's, which its value-union test holds to bestax-bulma's constants.
|
|
18
|
+
*
|
|
19
|
+
* Where a per-viewport display, the base value, the `className` or a
|
|
20
|
+
* container prop it would move is dynamic, or the element takes a spread,
|
|
21
|
+
* which could hold any of them, it changes nothing and leaves a TODO naming
|
|
22
|
+
* what to move.
|
|
23
|
+
*/
|
|
24
|
+
import { ALIGN_CONTENTS, ALIGN_ITEMS, DISPLAYS, FLEX_DIRECTIONS, FLEX_WRAPS, JUSTIFY_CONTENTS, } from '../bulma-classes/class-map.js';
|
|
25
|
+
import { addTodo, findAttr, jsxStringValue, literalValueOf, makeAttr, removeAttr, } from './jsx-utils.js';
|
|
26
|
+
import { VIEWPORT_SUFFIX } from './viewports.js';
|
|
27
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
+
/** bestax's per-viewport display props. */
|
|
29
|
+
const VIEWPORT_DISPLAYS = Object.values(VIEWPORT_SUFFIX).map(suffix => `display${suffix}`);
|
|
30
|
+
/** The class a bestax display value writes, or none for a value it doesn't take. */
|
|
31
|
+
const displayClass = (value) => value === 'none'
|
|
32
|
+
? 'is-hidden'
|
|
33
|
+
: DISPLAYS.includes(value)
|
|
34
|
+
? `is-${value}`
|
|
35
|
+
: undefined;
|
|
36
|
+
/** The flex container props: the class prefix, and the values bestax takes. */
|
|
37
|
+
const FLEX_CONTAINER = {
|
|
38
|
+
flexDirection: ['is-flex-direction-', FLEX_DIRECTIONS],
|
|
39
|
+
flexWrap: ['is-flex-wrap-', FLEX_WRAPS],
|
|
40
|
+
justifyContent: ['is-justify-content-', JUSTIFY_CONTENTS],
|
|
41
|
+
alignContent: ['is-align-content-', ALIGN_CONTENTS],
|
|
42
|
+
alignItems: ['is-align-items-', ALIGN_ITEMS],
|
|
43
|
+
};
|
|
44
|
+
const isFlex = (value) => value === 'flex' || value === 'inline-flex';
|
|
45
|
+
export function keepBaseDisplay(ctx, path, element) {
|
|
46
|
+
const display = findAttr(element, 'display');
|
|
47
|
+
if (!display)
|
|
48
|
+
return;
|
|
49
|
+
const perViewport = VIEWPORT_DISPLAYS.map(name => findAttr(element, name)).filter(Boolean);
|
|
50
|
+
if (!perViewport.length)
|
|
51
|
+
return;
|
|
52
|
+
const todo = (message) => addTodo(ctx, path, 'prop:display-base', `bestax leaves \`display\` out beside a per-viewport display prop; ${message}`);
|
|
53
|
+
const base = literalValueOf(display);
|
|
54
|
+
if (base.kind !== 'string') {
|
|
55
|
+
todo('put the class it stands for in `className` by hand');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const baseClass = displayClass(base.value);
|
|
59
|
+
if (!baseClass)
|
|
60
|
+
return;
|
|
61
|
+
// The container props that go with a flex base: every one written, since
|
|
62
|
+
// bestax drops all of them once no `display` prop is flex.
|
|
63
|
+
const values = perViewport.map(attr => literalValueOf(attr));
|
|
64
|
+
const flexBeside = values.some(value => value.kind === 'string' && isFlex(value.value));
|
|
65
|
+
const container = isFlex(base.value) && !flexBeside
|
|
66
|
+
? Object.keys(FLEX_CONTAINER)
|
|
67
|
+
.map(name => findAttr(element, name))
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
: [];
|
|
70
|
+
const moving = [display, ...container];
|
|
71
|
+
const names = moving.map(attr => `\`${attr.name.name}\``).join(', ');
|
|
72
|
+
const refuse = (why) => todo(`${why}, so move ${names} into \`className\` as classes by hand`);
|
|
73
|
+
if (values.some(value => value.kind !== 'string')) {
|
|
74
|
+
refuse('a per-viewport display is dynamic');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const classes = [baseClass];
|
|
78
|
+
const moved = [display];
|
|
79
|
+
for (const attr of container) {
|
|
80
|
+
const value = literalValueOf(attr);
|
|
81
|
+
if (value.kind !== 'string') {
|
|
82
|
+
refuse(`\`${attr.name.name}\` is dynamic`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const [prefix, allowed] = FLEX_CONTAINER[attr.name.name];
|
|
86
|
+
// bestax ignored a value it doesn't take, and the typecheck still flags it.
|
|
87
|
+
if (!allowed.includes(value.value))
|
|
88
|
+
continue;
|
|
89
|
+
classes.push(`${prefix}${value.value}`);
|
|
90
|
+
moved.push(attr);
|
|
91
|
+
}
|
|
92
|
+
const { j } = ctx;
|
|
93
|
+
const attributes = element.openingElement.attributes;
|
|
94
|
+
const className = findAttr(element, 'className');
|
|
95
|
+
// A spread could hold any prop this reads, before the written one or after
|
|
96
|
+
// it, so the pass leaves an element that takes one to the reader.
|
|
97
|
+
if (attributes.some((attr) => attr.type === 'JSXSpreadAttribute')) {
|
|
98
|
+
refuse('the element takes a spread, which could hold any of them');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (className) {
|
|
102
|
+
const value = literalValueOf(className);
|
|
103
|
+
if (value.kind !== 'string') {
|
|
104
|
+
refuse('the `className` is dynamic');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const written = value.value.split(/\s+/).filter(Boolean);
|
|
108
|
+
const merged = [
|
|
109
|
+
...classes.filter(cls => !written.includes(cls)),
|
|
110
|
+
...written,
|
|
111
|
+
];
|
|
112
|
+
className.value = jsxStringValue(j, merged.join(' '));
|
|
113
|
+
for (const attr of moved)
|
|
114
|
+
removeAttr(element, attr);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// In the place of `display`.
|
|
118
|
+
attributes[attributes.indexOf(display)] = makeAttr(j, 'className', classes.join(' '));
|
|
119
|
+
for (const attr of moved.slice(1))
|
|
120
|
+
removeAttr(element, attr);
|
|
121
|
+
}
|
|
122
|
+
ctx.dirty = true;
|
|
123
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAkBnE;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,UAEzB,CAAC;AA8CF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAsBtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG1D,CAAC;AAEF;;;;;GAKG;AACH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,aAG/B,CAAC;AAEH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAkBnE;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,UAEzB,CAAC;AA8CF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAsBtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG1D,CAAC;AAEF;;;;;GAKG;AACH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,aAG/B,CAAC;AAEH,eAAO,MAAM,kBAAkB,aAoB7B,CAAC;AAEH,8EAA8E;AAC9E,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAC3C,MAAM,GAAG,IAAI,CA0Bf;AAED,iFAAiF;AACjF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOlD,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA4nBpD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAiIpD,CAAC;AAEF,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAM3E"}
|
|
@@ -148,7 +148,6 @@ export const HELPERLESS_TARGETS = new Set([
|
|
|
148
148
|
'Panel.Heading',
|
|
149
149
|
'Panel.Tabs',
|
|
150
150
|
'Panel.Block',
|
|
151
|
-
'Tabs.List',
|
|
152
151
|
'Tabs.Item',
|
|
153
152
|
'Message.Header',
|
|
154
153
|
'Message.Body',
|
|
@@ -759,15 +758,9 @@ export const MAPPING = {
|
|
|
759
758
|
isFullWidth: FULLWIDTH,
|
|
760
759
|
},
|
|
761
760
|
},
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
props: {
|
|
766
|
-
isAlign: {
|
|
767
|
-
todo: "Bulma aligns tabs on the `.tabs` container, not the list (bloomer's `is-center` on the <ul> did nothing); set `align` on the `<Tabs>` instead",
|
|
768
|
-
},
|
|
769
|
-
},
|
|
770
|
-
},
|
|
761
|
+
// A plain <ul>, as bloomer rendered: bestax's `Tabs.List` renders
|
|
762
|
+
// `role="tablist"`, which the `Tabs.Item`s inside are not the tabs of (#1961).
|
|
763
|
+
TabList: { status: 'mapped', special: 'tab-list' },
|
|
771
764
|
// bestax's `Tabs.Tab` is the controlled API and requires an `index`;
|
|
772
765
|
// `Tabs.Item` is the plain <li> that bloomer's Tab actually is.
|
|
773
766
|
Tab: { status: 'mapped', target: 'Tabs.Item', props: { isActive: active } },
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
* 1. `isDisplay` — a display, optionally suffixed with a viewport; an array
|
|
11
11
|
* of those; or an object keyed by display whose values are viewports:
|
|
12
12
|
* <Box isDisplay="flex-tablet" /> → displayTablet="flex"
|
|
13
|
-
* <Box isDisplay={['flex', 'block-mobile']} /> →
|
|
13
|
+
* <Box isDisplay={['flex', 'block-mobile']} /> → className="is-flex" displayMobile="block"
|
|
14
14
|
* <Box isDisplay={{ flex: ['default', 'desktop'] }} />
|
|
15
|
-
* →
|
|
15
|
+
* → className="is-flex" displayDesktop="flex"
|
|
16
|
+
* A plain display beside a per-viewport one stays its class, since
|
|
17
|
+
* bestax leaves `display` out beside one (`_shared/display.ts`).
|
|
16
18
|
* 2. `isHidden` — a boolean, a viewport, or an array of viewports:
|
|
17
19
|
* <Box isHidden /> → visibility="hidden"
|
|
18
20
|
* <Box isHidden="touch" /> → visibilityTouch="hidden"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/responsive.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/responsive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAKjC,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,CAAC;AAElD,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAE3D,CAAC;AAmSF,qEAAqE;AACrE,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,cAAc,GACnB,IAAI,CAIN"}
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
* 1. `isDisplay` — a display, optionally suffixed with a viewport; an array
|
|
11
11
|
* of those; or an object keyed by display whose values are viewports:
|
|
12
12
|
* <Box isDisplay="flex-tablet" /> → displayTablet="flex"
|
|
13
|
-
* <Box isDisplay={['flex', 'block-mobile']} /> →
|
|
13
|
+
* <Box isDisplay={['flex', 'block-mobile']} /> → className="is-flex" displayMobile="block"
|
|
14
14
|
* <Box isDisplay={{ flex: ['default', 'desktop'] }} />
|
|
15
|
-
* →
|
|
15
|
+
* → className="is-flex" displayDesktop="flex"
|
|
16
|
+
* A plain display beside a per-viewport one stays its class, since
|
|
17
|
+
* bestax leaves `display` out beside one (`_shared/display.ts`).
|
|
16
18
|
* 2. `isHidden` — a boolean, a viewport, or an array of viewports:
|
|
17
19
|
* <Box isHidden /> → visibility="hidden"
|
|
18
20
|
* <Box isHidden="touch" /> → visibilityTouch="hidden"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* `hasDropdown`), wrappers bestax renders itself (Page, whose Pagination.Link
|
|
5
5
|
* child renders its own <li>), replacement with plain HTML where bestax has
|
|
6
6
|
* no component (Help, Label, Heading, BreadcrumbItem, PanelTab, TabLink,
|
|
7
|
-
* HeroVideo), and the two props whose bloomer shape has no single bestax
|
|
7
|
+
* HeroVideo) or where its part would add a role (TabList), and the two props whose bloomer shape has no single bestax
|
|
8
8
|
* prop (Icon's className, Control's hasIcons).
|
|
9
9
|
*
|
|
10
10
|
* A handler may return a `target` override for the rename step, or mark the
|
|
@@ -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;
|
|
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;AAO3C,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAWL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,aAAa,EAAE,CAAC;AAmtC9B,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"}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* `hasDropdown`), wrappers bestax renders itself (Page, whose Pagination.Link
|
|
5
5
|
* child renders its own <li>), replacement with plain HTML where bestax has
|
|
6
6
|
* no component (Help, Label, Heading, BreadcrumbItem, PanelTab, TabLink,
|
|
7
|
-
* HeroVideo), and the two props whose bloomer shape has no single bestax
|
|
7
|
+
* HeroVideo) or where its part would add a role (TabList), and the two props whose bloomer shape has no single bestax
|
|
8
8
|
* prop (Icon's className, Control's hasIcons).
|
|
9
9
|
*
|
|
10
10
|
* A handler may return a `target` override for the rename step, or mark the
|
|
11
11
|
* element `replaced` when it substituted the node itself.
|
|
12
12
|
*/
|
|
13
|
-
import { RENDER_TODO, RESPONSIVE_PROPS, UNIVERSAL_PROPS } from './mapping.js';
|
|
13
|
+
import { helperClassHint, 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
16
|
import { aTag } from '../_shared/articles.js';
|
|
@@ -810,6 +810,64 @@ const SPECIALS = {
|
|
|
810
810
|
const tag = plainTag(ctx, path, element, 'tag', 'a', 'PanelTab');
|
|
811
811
|
return replaceWithPlain(ctx, path, element, tag, cls, 'PanelTab');
|
|
812
812
|
},
|
|
813
|
+
/**
|
|
814
|
+
* bloomer's TabList is the tabs' <ul>, and stays one: bestax's `Tabs.List`
|
|
815
|
+
* renders `role="tablist"`, which the `Tabs.Item`s inside are not the tabs
|
|
816
|
+
* of (#1961).
|
|
817
|
+
*/
|
|
818
|
+
'tab-list'(ctx, path, element) {
|
|
819
|
+
const align = findAttr(element, 'isAlign');
|
|
820
|
+
if (align) {
|
|
821
|
+
removeAttr(element, align);
|
|
822
|
+
ctx.dirty = true;
|
|
823
|
+
addTodo(ctx, path, 'prop:isAlign', "`isAlign` — Bulma aligns tabs on the `.tabs` container, not the list (bloomer's `is-center` on the <ul> did nothing); set `align` on the `<Tabs>` instead");
|
|
824
|
+
}
|
|
825
|
+
// A helper whose literal value stands for one Bulma class becomes that
|
|
826
|
+
// class, as it did when this was a `Tabs.List`, a part that takes no
|
|
827
|
+
// helper props. Any other helper is left to `replaceWithPlain`, which
|
|
828
|
+
// drops it with a `plain-element` TODO, as on every plain element.
|
|
829
|
+
const classes = [];
|
|
830
|
+
for (const attr of attributesOf(element)) {
|
|
831
|
+
const literal = literalValueOf(attr);
|
|
832
|
+
if (literal.kind !== 'string' && literal.kind !== 'boolean')
|
|
833
|
+
continue;
|
|
834
|
+
const cls = helperClassHint(attr.name.name, literal.value);
|
|
835
|
+
if (!cls)
|
|
836
|
+
continue;
|
|
837
|
+
// A helper set to false did nothing in bloomer, and a bare boolean on
|
|
838
|
+
// one that takes a value hints a placeholder rather than a class.
|
|
839
|
+
if (literal.value !== false && cls.includes('<'))
|
|
840
|
+
continue;
|
|
841
|
+
removeAttr(element, attr);
|
|
842
|
+
ctx.dirty = true;
|
|
843
|
+
if (literal.value !== false)
|
|
844
|
+
classes.push(cls);
|
|
845
|
+
}
|
|
846
|
+
// A dynamic `className` stays as written. `replaceWithPlain` would drop
|
|
847
|
+
// it, since it can merge only a literal one with a class of its own.
|
|
848
|
+
const className = findAttr(element, 'className');
|
|
849
|
+
const dynamic = className && literalValueOf(className).kind !== 'string'
|
|
850
|
+
? className
|
|
851
|
+
: undefined;
|
|
852
|
+
const attrs = element.openingElement.attributes ?? [];
|
|
853
|
+
const before = dynamic ? attrs.slice(0, attrs.indexOf(dynamic)) : [];
|
|
854
|
+
if (dynamic) {
|
|
855
|
+
removeAttr(element, dynamic);
|
|
856
|
+
if (classes.length > 0) {
|
|
857
|
+
addTodo(ctx, path, 'prop:className', `dynamic TabList className; merge it with the \`${classes.join(' ')}\` class by hand`);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
const tag = plainTag(ctx, path, element, 'tag', 'ul', 'TabList');
|
|
861
|
+
const result = replaceWithPlain(ctx, path, element, tag, dynamic ? undefined : join(...classes), 'TabList');
|
|
862
|
+
if (dynamic) {
|
|
863
|
+
// Back in its place: after the last attribute before it that the
|
|
864
|
+
// plain element kept, so a spread keeps the precedence it had.
|
|
865
|
+
const now = path.node.openingElement.attributes;
|
|
866
|
+
const anchor = [...before].reverse().find(a => now.includes(a));
|
|
867
|
+
now.splice(anchor ? now.indexOf(anchor) + 1 : 0, 0, dynamic);
|
|
868
|
+
}
|
|
869
|
+
return result;
|
|
870
|
+
},
|
|
813
871
|
/** bestax's Tabs.Item is the <li>; the anchor inside it is plain markup. */
|
|
814
872
|
'tab-link'(ctx, path, element) {
|
|
815
873
|
const tag = plainTag(ctx, path, element, 'tag', 'a', 'TabLink');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;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/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAiDvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAkvBpB"}
|
|
@@ -25,6 +25,7 @@ import { HELPERLESS_TARGETS, MAPPING, NO_CLASSNAME_TARGETS, UNIVERSAL_PROPS, hel
|
|
|
25
25
|
import { addTodo, attributesOf, forgetJsxParens, jsxNameParts, literalValueOf, removeAttr, renameElement, reprintDirectives, } from '../_shared/jsx-utils.js';
|
|
26
26
|
import { applyPropAction, applyUniversalProps, mergeClass, } from '../_shared/props.js';
|
|
27
27
|
import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
|
|
28
|
+
import { keepBaseDisplay } from '../_shared/display.js';
|
|
28
29
|
import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
29
30
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
30
31
|
import { collectBoundNames, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
@@ -351,6 +352,9 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
351
352
|
}
|
|
352
353
|
}
|
|
353
354
|
applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
|
|
355
|
+
// bestax leaves a base `display` out beside a per-viewport one, so it
|
|
356
|
+
// stays the class it stood for.
|
|
357
|
+
keepBaseDisplay(ctx, path, element);
|
|
354
358
|
// Last: bestax's props follow `as`, so the element decides which of the
|
|
355
359
|
// props just written it can actually take.
|
|
356
360
|
enforcePolymorphicProps(ctx, path, element, target);
|
|
@@ -205,12 +205,18 @@ export interface RootEntry {
|
|
|
205
205
|
/**
|
|
206
206
|
* What the target renders in place of `defaults` once the element names
|
|
207
207
|
* itself through one of `by`, set to anything but an empty string (`Icon`
|
|
208
|
-
* makes a named icon an image and hides any other
|
|
209
|
-
*
|
|
208
|
+
* makes a named icon an image and hides any other, and a pagination link
|
|
209
|
+
* with an `href` is a link, and a button without one). A name given as an
|
|
210
|
+
* expression may render as none, so the element then sets both. `what`
|
|
211
|
+
* says what one of `by` gives the element, in the TODO for that case:
|
|
212
|
+
* `a name` unless it says otherwise. With `emptyCounts`, an empty value
|
|
213
|
+
* gives it too: `href=""` is still a link.
|
|
210
214
|
*/
|
|
211
215
|
readonly namedDefaults?: {
|
|
212
216
|
readonly by: readonly string[];
|
|
213
217
|
readonly defaults: Readonly<Record<string, string>>;
|
|
218
|
+
readonly what?: string;
|
|
219
|
+
readonly emptyCounts?: boolean;
|
|
214
220
|
};
|
|
215
221
|
/**
|
|
216
222
|
* Attributes that stop the target rendering `defaults` when the element sets
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;G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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"}
|
|
@@ -1766,7 +1766,8 @@ export const ROOTS = {
|
|
|
1766
1766
|
ownProps: ['textColor', 'color', 'bgColor'],
|
|
1767
1767
|
},
|
|
1768
1768
|
// The previous and next links write `tabIndex` before the props they're
|
|
1769
|
-
// given, and take no helper props.
|
|
1769
|
+
// given, and take no helper props. Without an `href` each is a button, and
|
|
1770
|
+
// writes `role="button"` too.
|
|
1770
1771
|
'pagination-previous': {
|
|
1771
1772
|
status: 'mapped',
|
|
1772
1773
|
target: 'Pagination.Previous',
|
|
@@ -1774,7 +1775,13 @@ export const ROOTS = {
|
|
|
1774
1775
|
textColor: null,
|
|
1775
1776
|
bgColor: null,
|
|
1776
1777
|
noHelpers: true,
|
|
1777
|
-
defaults: { tabIndex: '0' },
|
|
1778
|
+
defaults: { tabIndex: '0', role: 'button' },
|
|
1779
|
+
namedDefaults: {
|
|
1780
|
+
by: ['href'],
|
|
1781
|
+
defaults: { tabIndex: '0' },
|
|
1782
|
+
what: 'an `href`',
|
|
1783
|
+
emptyCounts: true,
|
|
1784
|
+
},
|
|
1778
1785
|
omits: {
|
|
1779
1786
|
'is-disabled': '`disabled` also writes `aria-disabled` and `tabIndex="-1"`',
|
|
1780
1787
|
},
|
|
@@ -1787,7 +1794,13 @@ export const ROOTS = {
|
|
|
1787
1794
|
textColor: null,
|
|
1788
1795
|
bgColor: null,
|
|
1789
1796
|
noHelpers: true,
|
|
1790
|
-
defaults: { tabIndex: '0' },
|
|
1797
|
+
defaults: { tabIndex: '0', role: 'button' },
|
|
1798
|
+
namedDefaults: {
|
|
1799
|
+
by: ['href'],
|
|
1800
|
+
defaults: { tabIndex: '0' },
|
|
1801
|
+
what: 'an `href`',
|
|
1802
|
+
emptyCounts: true,
|
|
1803
|
+
},
|
|
1791
1804
|
omits: {
|
|
1792
1805
|
'is-disabled': '`disabled` also writes `aria-disabled` and `tabIndex="-1"`',
|
|
1793
1806
|
},
|
|
@@ -1796,6 +1809,7 @@ export const ROOTS = {
|
|
|
1796
1809
|
// A page link and the ellipsis each render the bare `<li>` around them, so
|
|
1797
1810
|
// each converts in its `<li>`'s place. A link writes `tabIndex` before the
|
|
1798
1811
|
// props it's given, and `active` writes `aria-current="page"` the same way.
|
|
1812
|
+
// Without an `href` it's a button, and writes `role="button"` too.
|
|
1799
1813
|
'pagination-link': {
|
|
1800
1814
|
...BASE,
|
|
1801
1815
|
target: 'Pagination.Link',
|
|
@@ -1807,7 +1821,13 @@ export const ROOTS = {
|
|
|
1807
1821
|
needsAttr: { name: 'aria-current', value: 'page' },
|
|
1808
1822
|
},
|
|
1809
1823
|
},
|
|
1810
|
-
defaults: { tabIndex: '0' },
|
|
1824
|
+
defaults: { tabIndex: '0', role: 'button' },
|
|
1825
|
+
namedDefaults: {
|
|
1826
|
+
by: ['href'],
|
|
1827
|
+
defaults: { tabIndex: '0' },
|
|
1828
|
+
what: 'an `href`',
|
|
1829
|
+
emptyCounts: true,
|
|
1830
|
+
},
|
|
1811
1831
|
omits: {
|
|
1812
1832
|
'is-disabled': '`disabled` also writes `aria-disabled` and `tabIndex="-1"`',
|
|
1813
1833
|
},
|
|
@@ -1868,7 +1888,15 @@ export const ROOTS = {
|
|
|
1868
1888
|
textColor: null,
|
|
1869
1889
|
bgColor: null,
|
|
1870
1890
|
noHelpers: true,
|
|
1871
|
-
|
|
1891
|
+
// `active` writes `aria-current="page"` unless the block has its own, the
|
|
1892
|
+
// way `Navbar.Item` does, so `is-active` converts only beside one and
|
|
1893
|
+
// stays a class otherwise.
|
|
1894
|
+
modifiers: {
|
|
1895
|
+
'is-active': {
|
|
1896
|
+
writes: [{ prop: 'active' }],
|
|
1897
|
+
needsAttr: { name: 'aria-current', value: 'page' },
|
|
1898
|
+
},
|
|
1899
|
+
},
|
|
1872
1900
|
// The anchor attributes, and `rel`, reach only an <a>, and the label's
|
|
1873
1901
|
// only a <label> (`STRIP_FROM_NON_ANCHOR` and `STRIP_FROM_NON_LABEL` in
|
|
1874
1902
|
// bulma-ui's Panel.tsx).
|
|
@@ -560,13 +560,16 @@ function planElement(facts) {
|
|
|
560
560
|
if (counts && !counted) {
|
|
561
561
|
return refuse('children', target, `bestax \`${target}\` renders this element's children itself, \`${counts.prop}\` bare, empty <${counts.tag}>s, so it converts only when its children are just that; keep it as markup`);
|
|
562
562
|
}
|
|
563
|
-
|
|
563
|
+
// An attribute the target writes alike with a name and without one is no
|
|
564
|
+
// question of the name, so the plain TODO below asks for it.
|
|
565
|
+
const varies = ([name]) => entry.namedDefaults?.defaults[name] !== entry.defaults?.[name];
|
|
566
|
+
if (naming === 'unsure' && missing.some(varies)) {
|
|
564
567
|
const list = (set = {}) => Object.entries(set)
|
|
565
568
|
.map(([name, value]) => `\`${name}="${value}"\``)
|
|
566
569
|
.join(' and ');
|
|
567
570
|
const by = entry.namedDefaults.by.find(name => attributes.has(name));
|
|
568
571
|
const add = missing.map(([name]) => `\`${name}\``).join(' and ');
|
|
569
|
-
return refuse('defaults', target, `bestax \`${target}\` renders ${list(entry.namedDefaults.defaults)} when it has a name and ${list(entry.defaults)} when it has none, and this element's \`${by}\` is an expression that may render as either; set ${add} here to what you want
|
|
572
|
+
return refuse('defaults', target, `bestax \`${target}\` renders ${list(entry.namedDefaults.defaults)} when it has ${entry.namedDefaults.what ?? 'a name'} and ${list(entry.defaults)} when it has none, and this element's \`${by}\` is an expression that may render as either; set ${add} here to what you want and re-run, or convert it by hand`);
|
|
570
573
|
}
|
|
571
574
|
if (missing.length > 0) {
|
|
572
575
|
const list = missing.map(([name, value]) => `\`${name}="${value}"\``);
|
|
@@ -794,14 +797,16 @@ function buildFile(children, entry, hasName) {
|
|
|
794
797
|
/**
|
|
795
798
|
* Whether the element names itself through one of `entry.namedDefaults.by`,
|
|
796
799
|
* which picks the defaults its target renders: a string written out names
|
|
797
|
-
* it unless empty
|
|
798
|
-
* not. An entry with no `namedDefaults`
|
|
800
|
+
* it unless empty (or even then, with `emptyCounts`), as a bare attribute
|
|
801
|
+
* does, and an expression may or may not. An entry with no `namedDefaults`
|
|
802
|
+
* is never named.
|
|
799
803
|
*/
|
|
800
804
|
function namingOf(entry, attributes) {
|
|
801
805
|
const given = (entry.namedDefaults?.by ?? [])
|
|
802
806
|
.filter(name => attributes.has(name))
|
|
803
807
|
.map(name => attributes.get(name));
|
|
804
|
-
|
|
808
|
+
const emptyCounts = entry.namedDefaults?.emptyCounts ?? false;
|
|
809
|
+
if (given.some(value => value === true || (value !== null && (value !== '' || emptyCounts)))) {
|
|
805
810
|
return 'named';
|
|
806
811
|
}
|
|
807
812
|
return given.includes(null) ? 'unsure' : 'unnamed';
|
|
@@ -129,7 +129,7 @@ export const MAPPING = {
|
|
|
129
129
|
},
|
|
130
130
|
forwardRefAs: {
|
|
131
131
|
status: 'todo',
|
|
132
|
-
todo: '`forwardRefAs` is rbx-internal and has no counterpart. bestax forwards a ref from the form controls, plus `Affix`, `AppFrame`, `AppFrame.Aside`, `AppFrame.Burger`, `AppFrame.Footer`, `AppFrame.Header`, `AppFrame.Main`, `AppFrame.Nav`, `Avatar`, `Button`, `Carousel`, `CarouselItem`, `Center`, `ColorSwatch`, `Command`, `Command.Dialog`, `Command.Input`, `CopyButton`, `DataTable`, `DescriptionList`, `DescriptionList.Item`, `DescriptionList.Label`, `DescriptionList.Value`, `Dialog`, `Dropdown`, `EmptyState`, `Flex`, `Group`, `IconButton`, `Kbd`, `Kbd.Group`, `Lightbox`, `Lightbox.Trigger`, `Link`, `LinkButton`, `Loader`, `LocaleProvider`, `Menu.Item`, `Modal`, `Navbar`, `Navbar.Burger`, `Navbar.Dropdown`, `Navbar.Item`, `Navbar.Link`, `NumberFormatter`, `RingProgress`, `ScrollArea`, `SegmentedControl`, `SegmentedControl.Segment`, `Sidebar`, `Splitter`, `Splitter.Pane`, `Stack`, `Stat`, `Stat.Change`, `Stat.Description`, `Stat.Label`, `Stat.Value`, `Stats`, `TableOfContents`, `Timeline`, `Timeline.Item`, `Toast`, `ToggleButton`, `TreeView` and `TreeView.Item` — pass `ref` directly on those, though not on the `Field`, `Field.Label`, `Field.Body`, `Checkboxes` and `Radios` wrappers, which forward none. Mind the `Navbar.Dropdown` collision: your rbx `Navbar.Dropdown` is the menu and becomes `Navbar.DropdownMenu`, which forwards no ref, while bestax `Navbar.Dropdown` — the container your `<Navbar.Item dropdown>` becomes — does. The rest, `Box` included, forward no ref: React 18 drops it with a warning, React 19 leaves it wherever the rest props go, so put the ref on a wrapping element you control',
|
|
132
|
+
todo: '`forwardRefAs` is rbx-internal and has no counterpart. bestax forwards a ref from the form controls, plus `Affix`, `AppFrame`, `AppFrame.Aside`, `AppFrame.Burger`, `AppFrame.Footer`, `AppFrame.Header`, `AppFrame.Main`, `AppFrame.Nav`, `Avatar`, `Button`, `Carousel`, `CarouselItem`, `Center`, `ColorSwatch`, `Command`, `Command.Dialog`, `Command.Input`, `CopyButton`, `DataTable`, `DescriptionList`, `DescriptionList.Item`, `DescriptionList.Label`, `DescriptionList.Value`, `Dialog`, `Dropdown`, `EmptyState`, `Flex`, `FloatButton`, `FloatButton.BackToTop`, `FloatButton.SpeedDial`, `FloatButtons`, `Group`, `IconButton`, `Kbd`, `Kbd.Group`, `Lightbox`, `Lightbox.Trigger`, `Link`, `LinkButton`, `Loader`, `LocaleProvider`, `Menu.Item`, `Modal`, `Navbar`, `Navbar.Burger`, `Navbar.Dropdown`, `Navbar.Item`, `Navbar.Link`, `NumberFormatter`, `RingProgress`, `ScrollArea`, `SegmentedControl`, `SegmentedControl.Segment`, `Sidebar`, `Splitter`, `Splitter.Pane`, `Stack`, `Stat`, `Stat.Change`, `Stat.Description`, `Stat.Label`, `Stat.Value`, `Stats`, `TableOfContents`, `Timeline`, `Timeline.Item`, `Toast`, `ToggleButton`, `Tour`, `Tour.Back`, `Tour.Next`, `Tour.Skip`, `Tour.Step`, `TreeView` and `TreeView.Item` — pass `ref` directly on those, though not on the `Field`, `Field.Label`, `Field.Body`, `Checkboxes` and `Radios` wrappers, which forward none. Mind the `Navbar.Dropdown` collision: your rbx `Navbar.Dropdown` is the menu and becomes `Navbar.DropdownMenu`, which forwards no ref, while bestax `Navbar.Dropdown` — the container your `<Navbar.Item dropdown>` becomes — does. The rest, `Box` included, forward no ref: React 18 drops it with a warning, React 19 leaves it wherever the rest props go, so put the ref on a wrapping element you control',
|
|
133
133
|
},
|
|
134
134
|
// ---- elements -----------------------------------------------------------
|
|
135
135
|
Block: { status: 'mapped', target: 'Block' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQ3C,OAAO,
|
|
1
|
+
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQ3C,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAeL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,aAAa,EAAE,CAAC;AAq8B9B,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,GACX,aAAa,CAIf"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* element `replaced` when it substituted the node itself.
|
|
15
15
|
*/
|
|
16
16
|
import { BADGE_PROPS, RESPONSIVE_BREAKPOINTS, resolveMapping, TOOLTIP_PROPS, UNIVERSAL_PROPS, } from './mapping.js';
|
|
17
|
-
import { addAttr, addTodo,
|
|
17
|
+
import { addAttr, addTodo, attributesOf, findAttr, jsxNameParts, literalValueOf, makeAttr, plainElement, removeAttr, resolveBooleanish, } from '../_shared/jsx-utils.js';
|
|
18
18
|
import { alignTarget, applyIconProps, dropLinkAttrsForPlainTag, FIELD_SCOPED, flagDroppedHeading, keepTitleLevel, makeStripModifierProps, makeStructuralHelpers, mergeClassName, modifierClass, parseIconClasses, plainTag, restrictAsToTargets, } from '../_shared/specials-utils.js';
|
|
19
19
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
20
|
const stripModifierProps = makeStripModifierProps(UNIVERSAL_PROPS, RESPONSIVE_BREAKPOINTS, 'innerRef');
|
|
@@ -701,9 +701,11 @@ const SPECIALS = {
|
|
|
701
701
|
},
|
|
702
702
|
/**
|
|
703
703
|
* rbx's `Tab.Group` renders `div.tabs > ul > li`; bestax's `Tabs` renders
|
|
704
|
-
* only the `div.tabs
|
|
705
|
-
*
|
|
706
|
-
*
|
|
704
|
+
* only the `div.tabs`. Renaming straight across put the `<li>` items
|
|
705
|
+
* directly inside the div, which is not valid Bulma tabs markup, so the
|
|
706
|
+
* children go in a plain `<ul>`. Not a `Tabs.List`: it renders
|
|
707
|
+
* `role="tablist"`, which the migrated `Tabs.Item`s are not the tabs of
|
|
708
|
+
* (#1961). A `.List` the caller already put there is left alone.
|
|
707
709
|
*/
|
|
708
710
|
'tab-group'(ctx, _path, element) {
|
|
709
711
|
const children = element.children ?? [];
|
|
@@ -714,11 +716,7 @@ const SPECIALS = {
|
|
|
714
716
|
/(^|\.)List$/.test((jsxNameParts(solid[0].openingElement?.name) ?? []).join('.'));
|
|
715
717
|
if (solid.length === 0 || alreadyList)
|
|
716
718
|
return { target: 'Tabs' };
|
|
717
|
-
|
|
718
|
-
const listName = `${local}.List`;
|
|
719
|
-
element.children = [
|
|
720
|
-
ctx.j.jsxElement(ctx.j.jsxOpeningElement(buildJsxName(ctx.j, listName), [], false), ctx.j.jsxClosingElement(buildJsxName(ctx.j, listName)), children),
|
|
721
|
-
];
|
|
719
|
+
element.children = [plainElement(ctx.j, 'ul', undefined, [], children)];
|
|
722
720
|
ctx.dirty = true;
|
|
723
721
|
return { target: 'Tabs' };
|
|
724
722
|
},
|
|
@@ -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;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAI7C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,
|
|
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,CAorBpD,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"}
|
|
@@ -27,7 +27,7 @@ export const UNIVERSAL_PROPS = {
|
|
|
27
27
|
todo: 'this bestax component has no `as` prop; restructure the element instead',
|
|
28
28
|
},
|
|
29
29
|
domRef: {
|
|
30
|
-
todo: 'bestax-bulma has no `domRef`. The form controls, plus `Affix`, `AppFrame`, `AppFrame.Aside`, `AppFrame.Burger`, `AppFrame.Footer`, `AppFrame.Header`, `AppFrame.Main`, `AppFrame.Nav`, `Avatar`, `Button`, `Carousel`, `CarouselItem`, `Center`, `ColorSwatch`, `Command`, `Command.Dialog`, `Command.Input`, `CopyButton`, `DataTable`, `DescriptionList`, `DescriptionList.Item`, `DescriptionList.Label`, `DescriptionList.Value`, `Dialog`, `Dropdown`, `EmptyState`, `Flex`, `Group`, `IconButton`, `Kbd`, `Kbd.Group`, `Lightbox`, `Lightbox.Trigger`, `Link`, `LinkButton`, `Loader`, `LocaleProvider`, `Menu.Item`, `Modal`, `Navbar`, `Navbar.Burger`, `Navbar.Dropdown`, `Navbar.Item`, `Navbar.Link`, `NumberFormatter`, `RingProgress`, `ScrollArea`, `SegmentedControl`, `SegmentedControl.Segment`, `Sidebar`, `Splitter`, `Splitter.Pane`, `Stack`, `Stat`, `Stat.Change`, `Stat.Description`, `Stat.Label`, `Stat.Value`, `Stats`, `TableOfContents`, `Timeline`, `Timeline.Item`, `Toast`, `ToggleButton`, `TreeView` and `TreeView.Item` forward a ref — on those, rename `domRef` to `ref`, though not on the `Field`, `Field.Label`, `Field.Body`, `Checkboxes` and `Radios` wrappers, which forward none. Mind the `Navbar.Dropdown` collision: the `Navbar.Item` that wrapped your dropdown became bestax `Navbar.Dropdown` and forwards one, while your `Navbar.Dropdown` became `Navbar.DropdownMenu` and does not. The rest forward no ref: React 18 drops it with a warning, React 19 leaves it wherever the rest props go, so put the ref on a DOM child or wrap the component',
|
|
30
|
+
todo: 'bestax-bulma has no `domRef`. The form controls, plus `Affix`, `AppFrame`, `AppFrame.Aside`, `AppFrame.Burger`, `AppFrame.Footer`, `AppFrame.Header`, `AppFrame.Main`, `AppFrame.Nav`, `Avatar`, `Button`, `Carousel`, `CarouselItem`, `Center`, `ColorSwatch`, `Command`, `Command.Dialog`, `Command.Input`, `CopyButton`, `DataTable`, `DescriptionList`, `DescriptionList.Item`, `DescriptionList.Label`, `DescriptionList.Value`, `Dialog`, `Dropdown`, `EmptyState`, `Flex`, `FloatButton`, `FloatButton.BackToTop`, `FloatButton.SpeedDial`, `FloatButtons`, `Group`, `IconButton`, `Kbd`, `Kbd.Group`, `Lightbox`, `Lightbox.Trigger`, `Link`, `LinkButton`, `Loader`, `LocaleProvider`, `Menu.Item`, `Modal`, `Navbar`, `Navbar.Burger`, `Navbar.Dropdown`, `Navbar.Item`, `Navbar.Link`, `NumberFormatter`, `RingProgress`, `ScrollArea`, `SegmentedControl`, `SegmentedControl.Segment`, `Sidebar`, `Splitter`, `Splitter.Pane`, `Stack`, `Stat`, `Stat.Change`, `Stat.Description`, `Stat.Label`, `Stat.Value`, `Stats`, `TableOfContents`, `Timeline`, `Timeline.Item`, `Toast`, `ToggleButton`, `Tour`, `Tour.Back`, `Tour.Next`, `Tour.Skip`, `Tour.Step`, `TreeView` and `TreeView.Item` forward a ref — on those, rename `domRef` to `ref`, though not on the `Field`, `Field.Label`, `Field.Body`, `Checkboxes` and `Radios` wrappers, which forward none. Mind the `Navbar.Dropdown` collision: the `Navbar.Item` that wrapped your dropdown became bestax `Navbar.Dropdown` and forwards one, while your `Navbar.Dropdown` became `Navbar.DropdownMenu` and does not. The rest forward no ref: React 18 drops it with a warning, React 19 leaves it wherever the rest props go, so put the ref on a DOM child or wrap the component',
|
|
31
31
|
},
|
|
32
32
|
// ColorProps
|
|
33
33
|
backgroundColor: { rename: 'bgColor' },
|
|
@@ -290,7 +290,9 @@ export const MAPPING = {
|
|
|
290
290
|
target: 'Dropdown',
|
|
291
291
|
props: {
|
|
292
292
|
label: {},
|
|
293
|
-
color: {
|
|
293
|
+
color: {
|
|
294
|
+
todo: "react-bulma-components colored the dropdown's trigger button with it, and bestax's Dropdown has no prop for that: its own `color` is the text color helper on the root, so remove it",
|
|
295
|
+
},
|
|
294
296
|
hoverable: {},
|
|
295
297
|
right: {},
|
|
296
298
|
up: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAYL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,aAAa,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAYL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,aAAa,EAAE,CAAC;AA86B9B,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,GACX,aAAa,CAIf;AAED,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAGjE,CAAC"}
|
|
@@ -643,16 +643,19 @@ const SPECIALS = {
|
|
|
643
643
|
ctx.dirty = true;
|
|
644
644
|
return {};
|
|
645
645
|
},
|
|
646
|
-
/**
|
|
646
|
+
/**
|
|
647
|
+
* RBC's Tabs renders `div.tabs > ul` around its children, and bestax's
|
|
648
|
+
* renders only the `div.tabs`, so the children go in a plain `<ul>`.
|
|
649
|
+
* Not a `Tabs.List`: it renders `role="tablist"`, which the migrated
|
|
650
|
+
* `Tabs.Item`s, plain `<li>`s, are not the tabs of (#1961).
|
|
651
|
+
*/
|
|
647
652
|
tabs(ctx, _path, element) {
|
|
648
653
|
const children = element.children ?? [];
|
|
649
654
|
const hasContent = children.some((c) => c.type !== 'JSXText' || c.value.trim() !== '');
|
|
650
655
|
if (!hasContent)
|
|
651
656
|
return {};
|
|
652
657
|
const j = ctx.j;
|
|
653
|
-
const
|
|
654
|
-
const listName = () => j.jsxMemberExpression(j.jsxIdentifier(tabsLocal), j.jsxIdentifier('List'));
|
|
655
|
-
const list = j.jsxElement(j.jsxOpeningElement(listName(), []), j.jsxClosingElement(listName()), children);
|
|
658
|
+
const list = plainElement(j, 'ul', undefined, [], children);
|
|
656
659
|
element.children = [j.jsxText('\n'), list, j.jsxText('\n')];
|
|
657
660
|
ctx.dirty = true;
|
|
658
661
|
return {};
|
|
@@ -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;AAwCvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAoxBpB"}
|
|
@@ -19,6 +19,7 @@ import { applyBackgroundColor } from '../_shared/background-props.js';
|
|
|
19
19
|
import { applyPropAction, applyUniversalProps } from '../_shared/props.js';
|
|
20
20
|
import { applyTextColor } from '../_shared/text-color-props.js';
|
|
21
21
|
import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
|
|
22
|
+
import { keepBaseDisplay } from '../_shared/display.js';
|
|
22
23
|
import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
23
24
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
24
25
|
import { collectBoundNames, makeAliasRegistry, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
@@ -355,6 +356,9 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
355
356
|
applyBackgroundColor(ctx, path, element, target, handled);
|
|
356
357
|
applyTextColor(ctx, path, element, target, handled);
|
|
357
358
|
applyUniversalProps(ctx, path, element, handled, UNIVERSAL_PROPS);
|
|
359
|
+
// bestax leaves a base `display` out beside a per-viewport one, so it
|
|
360
|
+
// stays the class it stood for.
|
|
361
|
+
keepBaseDisplay(ctx, path, element);
|
|
358
362
|
// Last: bestax's props follow `as`, so the element decides which of the
|
|
359
363
|
// props just written it can actually take.
|
|
360
364
|
enforcePolymorphicProps(ctx, path, element, target);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.38.
|
|
3
|
+
"version": "2.38.2",
|
|
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.
|
|
43
|
+
"@allxsmith/bestax-bulma": "^5.73.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/jscodeshift": "^17.3.0",
|