bestax-migrate 2.3.8 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -17
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +45 -11
- package/dist/sources/_shared/bestax-import.d.ts +48 -0
- package/dist/sources/_shared/bestax-import.d.ts.map +1 -0
- package/dist/sources/_shared/bestax-import.js +142 -0
- package/dist/sources/_shared/css-imports.d.ts +33 -0
- package/dist/sources/_shared/css-imports.d.ts.map +1 -0
- package/dist/sources/_shared/css-imports.js +103 -0
- package/dist/sources/_shared/deps-common.d.ts +51 -0
- package/dist/sources/_shared/deps-common.d.ts.map +1 -0
- package/dist/sources/_shared/deps-common.js +115 -0
- package/dist/sources/_shared/jsx-utils.d.ts +28 -0
- package/dist/sources/_shared/jsx-utils.d.ts.map +1 -1
- package/dist/sources/_shared/jsx-utils.js +59 -1
- package/dist/sources/_shared/make-styles-transform.d.ts +6 -2
- package/dist/sources/_shared/make-styles-transform.d.ts.map +1 -1
- package/dist/sources/_shared/make-styles-transform.js +12 -4
- package/dist/sources/_shared/props.d.ts.map +1 -1
- package/dist/sources/_shared/props.js +2 -2
- package/dist/sources/_shared/specials-utils.d.ts +1 -1
- package/dist/sources/_shared/specials-utils.d.ts.map +1 -1
- package/dist/sources/_shared/specials-utils.js +19 -1
- package/dist/sources/bloomer/deps.d.ts.map +1 -1
- package/dist/sources/bloomer/deps.js +14 -89
- package/dist/sources/bloomer/transform.d.ts.map +1 -1
- package/dist/sources/bloomer/transform.js +12 -186
- package/dist/sources/bulma-classes/class-map.d.ts +161 -0
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -0
- package/dist/sources/bulma-classes/class-map.js +1046 -0
- package/dist/sources/bulma-classes/deps.d.ts +14 -0
- package/dist/sources/bulma-classes/deps.d.ts.map +1 -0
- package/dist/sources/bulma-classes/deps.js +56 -0
- package/dist/sources/bulma-classes/index.d.ts +3 -0
- package/dist/sources/bulma-classes/index.d.ts.map +1 -0
- package/dist/sources/bulma-classes/index.js +35 -0
- package/dist/sources/bulma-classes/plan.d.ts +53 -0
- package/dist/sources/bulma-classes/plan.d.ts.map +1 -0
- package/dist/sources/bulma-classes/plan.js +231 -0
- package/dist/sources/bulma-classes/project.d.ts +40 -0
- package/dist/sources/bulma-classes/project.d.ts.map +1 -0
- package/dist/sources/bulma-classes/project.js +203 -0
- package/dist/sources/bulma-classes/rules.d.ts +16 -0
- package/dist/sources/bulma-classes/rules.d.ts.map +1 -0
- package/dist/sources/bulma-classes/rules.js +53 -0
- package/dist/sources/bulma-classes/styles.d.ts +13 -0
- package/dist/sources/bulma-classes/styles.d.ts.map +1 -0
- package/dist/sources/bulma-classes/styles.js +18 -0
- package/dist/sources/bulma-classes/transform.d.ts +21 -0
- package/dist/sources/bulma-classes/transform.d.ts.map +1 -0
- package/dist/sources/bulma-classes/transform.js +486 -0
- package/dist/sources/rbx/deps.d.ts.map +1 -1
- package/dist/sources/rbx/deps.js +29 -117
- package/dist/sources/rbx/mapping.d.ts.map +1 -1
- package/dist/sources/rbx/mapping.js +9 -1
- package/dist/sources/rbx/specials.d.ts.map +1 -1
- package/dist/sources/rbx/specials.js +20 -10
- package/dist/sources/rbx/transform.d.ts.map +1 -1
- package/dist/sources/rbx/transform.js +22 -204
- package/dist/sources/react-bulma-components/deps.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/deps.js +12 -87
- package/dist/sources/react-bulma-components/mapping.js +1 -1
- package/dist/sources/react-bulma-components/specials.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/specials.js +42 -4
- package/dist/sources/react-bulma-components/transform.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/transform.js +16 -187
- package/dist/sources/registry.d.ts.map +1 -1
- package/dist/sources/registry.js +2 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -22,31 +22,16 @@
|
|
|
22
22
|
* value-reference passes below build those from the mapping's `target`.
|
|
23
23
|
*/
|
|
24
24
|
import { HELPERLESS_TARGETS, MAPPING, NO_CLASSNAME_TARGETS, UNIVERSAL_PROPS, helperClassHint, resolveMapping, } from './mapping.js';
|
|
25
|
-
import { addTodo, attributesOf, jsxNameParts, literalValueOf, removeAttr, renameElement, } from '../_shared/jsx-utils.js';
|
|
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 { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
29
|
+
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
28
30
|
import { collectBoundNames, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
29
31
|
import { flattenResponsiveProps, RESPONSIVE_KINDS } from './responsive.js';
|
|
30
32
|
import { runSpecial } from './specials.js';
|
|
31
33
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
32
34
|
const BLOOMER = 'bloomer';
|
|
33
|
-
const BESTAX = '@allxsmith/bestax-bulma';
|
|
34
|
-
const BESTAX_CSS = '@allxsmith/bestax-bulma/bestax.css';
|
|
35
|
-
const EXTRAS_CSS = '@allxsmith/bestax-bulma/extras.css';
|
|
36
|
-
const BULMA_CSS_SPECIFIERS = new Set([
|
|
37
|
-
'bulma/css/bulma.css',
|
|
38
|
-
'bulma/css/bulma.min.css',
|
|
39
|
-
]);
|
|
40
|
-
const BESTAX_CSS_SPECIFIERS = new Set([
|
|
41
|
-
BESTAX_CSS,
|
|
42
|
-
'@allxsmith/bestax-bulma/bestax.min.css',
|
|
43
|
-
'@allxsmith/bestax-bulma/dist/bestax.css',
|
|
44
|
-
'@allxsmith/bestax-bulma/dist/bestax.min.css',
|
|
45
|
-
]);
|
|
46
|
-
const EXTRAS_CSS_SPECIFIERS = new Set([
|
|
47
|
-
EXTRAS_CSS,
|
|
48
|
-
'@allxsmith/bestax-bulma/dist/extras.css',
|
|
49
|
-
]);
|
|
50
35
|
export default function transform(fileInfo, api, options = {}) {
|
|
51
36
|
const j = api.jscodeshift;
|
|
52
37
|
const root = j(fileInfo.source);
|
|
@@ -116,61 +101,8 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
116
101
|
addTodo(ctx, p, 'imports', `\`export * from '${BLOOMER}'\` was not migrated; re-export the bestax components you need by hand`);
|
|
117
102
|
});
|
|
118
103
|
// ---- 1a. Stylesheet imports (mode-driven) -----------------------------
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
// `keep`: nothing to do — bloomer has no stylesheet of its own.
|
|
122
|
-
const cssMode = options.cssMode ?? 'bestax';
|
|
123
|
-
let sawBestaxCss = root
|
|
124
|
-
.find(j.ImportDeclaration)
|
|
125
|
-
.paths()
|
|
126
|
-
.some(p => BESTAX_CSS_SPECIFIERS.has(String(p.node.source.value)));
|
|
127
|
-
// Whether some import in this file will become bestax.css, regardless of
|
|
128
|
-
// where it sits relative to an existing extras import.
|
|
129
|
-
const willAdoptBestaxCss = cssMode === 'bestax' &&
|
|
130
|
-
root
|
|
131
|
-
.find(j.ImportDeclaration)
|
|
132
|
-
.paths()
|
|
133
|
-
.some(p => BULMA_CSS_SPECIFIERS.has(String(p.node.source.value)));
|
|
134
|
-
root.find(j.ImportDeclaration).forEach(path => {
|
|
135
|
-
const source = String(path.node.source.value);
|
|
136
|
-
const isBulmaCss = BULMA_CSS_SPECIFIERS.has(source);
|
|
137
|
-
const isExtrasCss = EXTRAS_CSS_SPECIFIERS.has(source);
|
|
138
|
-
if (!isBulmaCss && !isExtrasCss)
|
|
139
|
-
return;
|
|
140
|
-
if (cssMode === 'bestax') {
|
|
141
|
-
if (isBulmaCss) {
|
|
142
|
-
if (sawBestaxCss) {
|
|
143
|
-
path.prune(); // bestax.css already imported elsewhere in this file
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
path.node.source = j.stringLiteral(BESTAX_CSS);
|
|
147
|
-
sawBestaxCss = true;
|
|
148
|
-
}
|
|
149
|
-
ctx.dirty = true;
|
|
150
|
-
}
|
|
151
|
-
else if (isExtrasCss && (sawBestaxCss || willAdoptBestaxCss)) {
|
|
152
|
-
// bestax.css already contains the extras. `willAdoptBestaxCss` covers
|
|
153
|
-
// the case where the extras import comes FIRST in the file and the
|
|
154
|
-
// bulma import that becomes bestax.css has not been visited yet —
|
|
155
|
-
// previously the extras survived alongside it and double-loaded.
|
|
156
|
-
path.prune();
|
|
157
|
-
ctx.dirty = true;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
else if (cssMode === 'bulma') {
|
|
161
|
-
if (isBulmaCss && !sawBestaxCss) {
|
|
162
|
-
const hasExtras = root
|
|
163
|
-
.find(j.ImportDeclaration)
|
|
164
|
-
.paths()
|
|
165
|
-
.some(p => EXTRAS_CSS_SPECIFIERS.has(String(p.node.source.value)));
|
|
166
|
-
if (!hasExtras) {
|
|
167
|
-
// Themed Radio/Checkbox need the bestax extras next to plain Bulma.
|
|
168
|
-
path.insertAfter(j.importDeclaration([], j.stringLiteral(EXTRAS_CSS)));
|
|
169
|
-
ctx.dirty = true;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
104
|
+
// bloomer has no stylesheet of its own, so `keep` has nothing to do.
|
|
105
|
+
rewriteStylesheetImports(ctx, root, options.cssMode ?? 'bestax');
|
|
174
106
|
if (imports.size === 0 && !ctx.dirty) {
|
|
175
107
|
return undefined;
|
|
176
108
|
}
|
|
@@ -283,45 +215,7 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
283
215
|
bound.add(head);
|
|
284
216
|
});
|
|
285
217
|
ctx.reserve = makeReserve(ctx, bound);
|
|
286
|
-
|
|
287
|
-
// existing bestax import's specifiers below (so JSX reuses their locals),
|
|
288
|
-
// and that seeding alone must not turn a type-only specifier into a value
|
|
289
|
-
// import nobody needed.
|
|
290
|
-
const requested = new Set();
|
|
291
|
-
const baseReserve = ctx.reserve;
|
|
292
|
-
ctx.reserve = root => {
|
|
293
|
-
requested.add(root);
|
|
294
|
-
return baseReserve(root);
|
|
295
|
-
};
|
|
296
|
-
// Merge with an existing bestax import: reuse its locals verbatim.
|
|
297
|
-
// Only a declaration that already uses NAMED specifiers can absorb more of
|
|
298
|
-
// them. `import * as Bestax from '…'` cannot: a namespace specifier may not
|
|
299
|
-
// share a declaration with named ones, and appending to it emits a file
|
|
300
|
-
// that does not parse.
|
|
301
|
-
const existingBestax = root
|
|
302
|
-
.find(j.ImportDeclaration, { source: { value: BESTAX } })
|
|
303
|
-
.paths()
|
|
304
|
-
.find(p =>
|
|
305
|
-
// A type-only declaration cannot take a value specifier: merging a
|
|
306
|
-
// component into `import type { … }` erases it at runtime.
|
|
307
|
-
p.node.importKind !== 'type' &&
|
|
308
|
-
(p.node.specifiers ?? []).every((spec) => spec.type === 'ImportSpecifier'));
|
|
309
|
-
const preExistingImports = new Set();
|
|
310
|
-
if (existingBestax) {
|
|
311
|
-
for (const spec of existingBestax.node.specifiers ?? []) {
|
|
312
|
-
if (spec.type === 'ImportSpecifier' && spec.local) {
|
|
313
|
-
// The local name is reused either way, so the JSX never needs an
|
|
314
|
-
// alias. But an inline `type` specifier (`import { type Box }`) is
|
|
315
|
-
// not a value binding: it is not counted as already imported, so the
|
|
316
|
-
// component is written as a value below — onto this specifier, which
|
|
317
|
-
// keeps its name, rather than as a duplicate.
|
|
318
|
-
ctx.needed.set(nameOf(spec.imported), nameOf(spec.local));
|
|
319
|
-
if (spec.importKind !== 'type') {
|
|
320
|
-
preExistingImports.add(nameOf(spec.imported));
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
218
|
+
const bestaxImportState = seedBestaxImport(ctx, root);
|
|
325
219
|
// ---- 2. Transform JSX elements ----------------------------------------
|
|
326
220
|
root.find(j.JSXElement).forEach(path => {
|
|
327
221
|
const element = path.node;
|
|
@@ -693,62 +587,13 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
693
587
|
// ---- 3. Rewrite imports -----------------------------------------------
|
|
694
588
|
if (imports.size > 0) {
|
|
695
589
|
const retainedNames = [...ctx.retained].sort((a, b) => a.localeCompare(b));
|
|
696
|
-
const
|
|
697
|
-
.filter(([imported]) => requested.has(imported) && !preExistingImports.has(imported))
|
|
698
|
-
.sort((a, b) => a[0].localeCompare(b[0]));
|
|
699
|
-
const bestaxImport = freshNames.length > 0
|
|
700
|
-
? j.importDeclaration(freshNames.map(([imported, local]) => j.importSpecifier(j.identifier(imported), j.identifier(local))), j.stringLiteral(BESTAX))
|
|
701
|
-
: null;
|
|
702
|
-
/**
|
|
703
|
-
|
|
704
|
-
* A pruned declaration takes its comments with it — a licence header, an
|
|
705
|
-
|
|
706
|
-
* eslint directive. Hand them to what replaces it, or to the next statement.
|
|
707
|
-
|
|
708
|
-
*/
|
|
709
|
-
const carryComments = (node, importPath) => {
|
|
710
|
-
const comments = node.comments ?? [];
|
|
711
|
-
if (comments.length === 0)
|
|
712
|
-
return;
|
|
713
|
-
const body = importPath.parent?.node?.body ?? [];
|
|
714
|
-
const index = body.indexOf(node);
|
|
715
|
-
// The fresh specifiers are merged INTO an existing bestax import when there
|
|
716
|
-
// is one, and the `bestaxImport` node is then discarded — so the comments
|
|
717
|
-
// have to follow the declaration that survives, not the one that does not.
|
|
718
|
-
const carrier = (existingBestax ? existingBestax.node : bestaxImport) ??
|
|
719
|
-
(index >= 0 ? body[index + 1] : undefined);
|
|
720
|
-
if (carrier) {
|
|
721
|
-
carrier.comments = [...comments, ...(carrier.comments ?? [])];
|
|
722
|
-
}
|
|
723
|
-
else if (index > 0) {
|
|
724
|
-
// The import was the last statement: the comments stay where they
|
|
725
|
-
// were, after what precedes it.
|
|
726
|
-
const previous = body[index - 1];
|
|
727
|
-
previous.comments = [
|
|
728
|
-
...(previous.comments ?? []),
|
|
729
|
-
...comments.map((c) => ({
|
|
730
|
-
...c,
|
|
731
|
-
leading: false,
|
|
732
|
-
trailing: true,
|
|
733
|
-
})),
|
|
734
|
-
];
|
|
735
|
-
}
|
|
736
|
-
else {
|
|
737
|
-
// The import was the only statement: the comments become the file's.
|
|
738
|
-
const program = importPath.parent?.node;
|
|
739
|
-
if (program)
|
|
740
|
-
program.comments = [...comments, ...(program.comments ?? [])];
|
|
741
|
-
}
|
|
742
|
-
node.comments = [];
|
|
743
|
-
};
|
|
590
|
+
const bestaxImport = buildBestaxImport(ctx, bestaxImportState);
|
|
744
591
|
let inserted = false;
|
|
745
592
|
// A retained bloomer specifier must never collide with a bestax import local
|
|
746
593
|
// (possible when one component is both JSX-migrated and value-retained).
|
|
747
594
|
// Only a VALUE local can collide at runtime: a type-only specifier the
|
|
748
595
|
// seeding above recorded, and nothing promoted, binds no value.
|
|
749
|
-
const bestaxLocals =
|
|
750
|
-
.filter(([imported]) => requested.has(imported) || preExistingImports.has(imported))
|
|
751
|
-
.map(([, local]) => local));
|
|
596
|
+
const bestaxLocals = bestaxValueLocals(ctx, bestaxImportState);
|
|
752
597
|
for (const path of sourceImportPaths) {
|
|
753
598
|
const node = path.node;
|
|
754
599
|
const keepSpecifiers = (node.specifiers ?? []).filter((spec) => {
|
|
@@ -766,28 +611,7 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
766
611
|
!bestaxLocals.has(nameOf(spec.local)));
|
|
767
612
|
});
|
|
768
613
|
if (!inserted) {
|
|
769
|
-
|
|
770
|
-
const current = existingBestax.node.specifiers ?? [];
|
|
771
|
-
const appended = [];
|
|
772
|
-
for (const fresh of bestaxImport.specifiers) {
|
|
773
|
-
// A type-only specifier for the same name becomes the value
|
|
774
|
-
// import (a value import carries the type too); appending a
|
|
775
|
-
// second `Box` beside `type Box` would be a duplicate identifier.
|
|
776
|
-
const typeOnly = current.find((spec) => spec.type === 'ImportSpecifier' &&
|
|
777
|
-
spec.importKind === 'type' &&
|
|
778
|
-
nameOf(spec.imported) === nameOf(fresh.imported));
|
|
779
|
-
if (typeOnly) {
|
|
780
|
-
typeOnly.importKind = null;
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
783
|
-
appended.push(fresh);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
existingBestax.node.specifiers = [...current, ...appended];
|
|
787
|
-
}
|
|
788
|
-
else if (bestaxImport) {
|
|
789
|
-
path.insertBefore(bestaxImport);
|
|
790
|
-
}
|
|
614
|
+
placeBestaxImport(bestaxImportState, bestaxImport, path);
|
|
791
615
|
inserted = true;
|
|
792
616
|
}
|
|
793
617
|
const droppedOnCollision = (node.specifiers ?? []).filter((spec) => spec.type === 'ImportSpecifier' &&
|
|
@@ -810,7 +634,7 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
810
634
|
}
|
|
811
635
|
}
|
|
812
636
|
else {
|
|
813
|
-
|
|
637
|
+
carryPrunedComments(node, path, bestaxImportState.existing?.node ?? bestaxImport);
|
|
814
638
|
path.prune();
|
|
815
639
|
}
|
|
816
640
|
ctx.dirty = true;
|
|
@@ -820,6 +644,8 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
820
644
|
// import rewrite, so the drop is visible in the file and not only the report.
|
|
821
645
|
if (!ctx.dirty)
|
|
822
646
|
return undefined;
|
|
647
|
+
forgetJsxParens(j, root);
|
|
648
|
+
reprintDirectives(j, root);
|
|
823
649
|
// Double quotes match the dominant JSX-attribute convention; users run
|
|
824
650
|
// their own formatter afterwards anyway. Tab-indented sources keep tabs so
|
|
825
651
|
// reprinted nodes don't drift from the untouched lines around them.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bulma-classes table: for a Bulma class on a plain JSX element, which
|
|
3
|
+
* bestax component renders that element, and which prop renders each of its
|
|
4
|
+
* other classes.
|
|
5
|
+
*
|
|
6
|
+
* Every conversion this table allows must render exactly the HTML the raw
|
|
7
|
+
* element rendered. That is a claim about bestax, and the render tests hold
|
|
8
|
+
* it: each root, modifier and helper here is rendered through the built
|
|
9
|
+
* library and compared with the raw markup it replaces.
|
|
10
|
+
*
|
|
11
|
+
* Data only, and written so a generator in another package can import it
|
|
12
|
+
* directly: nothing Node cannot strip, so no enums, no namespaces, type
|
|
13
|
+
* imports only.
|
|
14
|
+
*/
|
|
15
|
+
export interface PropWrite {
|
|
16
|
+
readonly prop: string;
|
|
17
|
+
/** Omitted for a bare boolean prop. */
|
|
18
|
+
readonly value?: string;
|
|
19
|
+
}
|
|
20
|
+
export type TagSet = {
|
|
21
|
+
readonly on: readonly string[];
|
|
22
|
+
} | {
|
|
23
|
+
readonly except: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export declare function inTagSet(set: TagSet, tag: string): boolean;
|
|
26
|
+
export interface Modifier {
|
|
27
|
+
readonly writes: readonly PropWrite[];
|
|
28
|
+
/** The raw tags the writes are exact on (Title's size picks its heading). */
|
|
29
|
+
readonly tagIn?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* - `mapped`: converts to `target`.
|
|
33
|
+
* - `todo`: bestax has a component, but the markup does not map element by
|
|
34
|
+
* element yet; the family's outermost class gets a TODO.
|
|
35
|
+
* - `plain`: valid Bulma with nothing to convert to; left alone, no TODO.
|
|
36
|
+
*/
|
|
37
|
+
export type RootStatus = 'mapped' | 'todo' | 'plain';
|
|
38
|
+
export interface RootEntry {
|
|
39
|
+
readonly status: RootStatus;
|
|
40
|
+
/** bestax JSX name, dotted for a part (`Hero.Body`). */
|
|
41
|
+
readonly target?: string;
|
|
42
|
+
/** The tag the target renders with no `as`. */
|
|
43
|
+
readonly tag?: string;
|
|
44
|
+
/** Tags `as` can reach: a list, any tag, or none (fixed). */
|
|
45
|
+
readonly as?: readonly string[] | 'any';
|
|
46
|
+
/** Title and SubTitle render `h{size}` whatever `as` says, unless `as="p"`. */
|
|
47
|
+
readonly sizeDrivesTag?: boolean;
|
|
48
|
+
readonly modifiers?: Readonly<Record<string, Modifier>>;
|
|
49
|
+
/** The prop that renders `has-text-{color}` here, or null when none does. */
|
|
50
|
+
readonly textColor?: 'textColor' | 'color' | null;
|
|
51
|
+
/** The prop that renders `has-background-{color}` here, or null when none does. */
|
|
52
|
+
readonly bgColor?: 'bgColor' | 'backgroundColor' | null;
|
|
53
|
+
/** Attributes the target renders when the element does not set them. */
|
|
54
|
+
readonly defaults?: Readonly<Record<string, string>>;
|
|
55
|
+
/**
|
|
56
|
+
* Attributes the element may carry that the target's props type rejects.
|
|
57
|
+
* One that is also a default converts at exactly its default value (the
|
|
58
|
+
* target renders it anyway, so it is dropped); otherwise it refuses.
|
|
59
|
+
*/
|
|
60
|
+
readonly untypedAttrs?: readonly string[];
|
|
61
|
+
/** The target's props type requires children. */
|
|
62
|
+
readonly requiresChildren?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Attributes the target types as numbers. A numeric string (`value="40"`)
|
|
65
|
+
* becomes a number, which renders the same; any other string refuses.
|
|
66
|
+
*/
|
|
67
|
+
readonly numberAttrs?: readonly string[];
|
|
68
|
+
/** Attributes the target drops: on these tags, or on all tags except these. */
|
|
69
|
+
readonly dropsAttr?: Readonly<Record<string, TagSet>>;
|
|
70
|
+
/**
|
|
71
|
+
* The target's props a raw attribute of the same name would be read as,
|
|
72
|
+
* and the ones that reach the DOM unchanged. Together they are every prop
|
|
73
|
+
* the target declares; a test holds that.
|
|
74
|
+
*/
|
|
75
|
+
readonly ownProps?: readonly string[];
|
|
76
|
+
readonly passThrough?: readonly string[];
|
|
77
|
+
/** For `todo` roots: a part, whose family root carries the TODO. */
|
|
78
|
+
readonly part?: boolean;
|
|
79
|
+
/** Why a `todo` or `plain` root is what it is; `todo` messages quote it. */
|
|
80
|
+
readonly why?: string;
|
|
81
|
+
}
|
|
82
|
+
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"];
|
|
83
|
+
export declare const SIZES: readonly ["0", "1", "2", "3", "4", "5", "6", "auto"];
|
|
84
|
+
export declare const TEXT_SIZES: readonly ["1", "2", "3", "4", "5", "6", "7"];
|
|
85
|
+
export declare const ALIGNMENTS: readonly ["centered", "justified", "left", "right"];
|
|
86
|
+
export declare const TEXT_TRANSFORMS: readonly ["capitalized", "lowercase", "uppercase", "italic"];
|
|
87
|
+
export declare const TEXT_WEIGHTS: readonly ["light", "normal", "medium", "semibold", "bold"];
|
|
88
|
+
export declare const FONT_FAMILIES: readonly ["sans-serif", "monospace", "primary", "secondary", "code"];
|
|
89
|
+
export declare const DISPLAYS: readonly ["block", "flex", "inline", "inline-block", "inline-flex", "grid"];
|
|
90
|
+
export declare const FLEX_DIRECTIONS: readonly ["row", "row-reverse", "column", "column-reverse"];
|
|
91
|
+
export declare const FLEX_WRAPS: readonly ["nowrap", "wrap", "wrap-reverse"];
|
|
92
|
+
export declare const JUSTIFY_CONTENTS: readonly ["flex-start", "flex-end", "center", "space-between", "space-around", "space-evenly", "start", "end", "left", "right"];
|
|
93
|
+
export declare const ALIGN_CONTENTS: readonly ["flex-start", "flex-end", "center", "space-between", "space-around", "space-evenly", "stretch"];
|
|
94
|
+
export declare const ALIGN_ITEMS: readonly ["stretch", "flex-start", "flex-end", "center", "baseline", "start", "end"];
|
|
95
|
+
export declare const ALIGN_SELFS: readonly ["auto", "flex-start", "flex-end", "center", "baseline", "stretch"];
|
|
96
|
+
export declare const FLEX_GROW_SHRINK: readonly ["0", "1", "2", "3", "4", "5"];
|
|
97
|
+
export declare const VIEWPORTS: readonly ["mobile", "tablet", "tablet-only", "touch", "desktop", "desktop-only", "widescreen", "widescreen-only", "fullhd"];
|
|
98
|
+
/** `tablet-only` → `TabletOnly`: the suffix bestax puts on per-viewport props. */
|
|
99
|
+
export declare function viewportSuffix(viewport: string): string;
|
|
100
|
+
export declare const ROOTS: Readonly<Record<string, RootEntry>>;
|
|
101
|
+
/**
|
|
102
|
+
* Which root wins when an element carries two (`column box`): layout before
|
|
103
|
+
* surface, so the element keeps the role that decides where it sits. The
|
|
104
|
+
* other root stays in `className`, which renders the same either way.
|
|
105
|
+
*/
|
|
106
|
+
export declare const PRECEDENCE: readonly string[];
|
|
107
|
+
/** Refs reach the element only through these targets. */
|
|
108
|
+
export declare const FORWARDS_REF: readonly string[];
|
|
109
|
+
/**
|
|
110
|
+
* Plain tags bestax wraps, for an element with helper classes and no root
|
|
111
|
+
* (`<p className="has-text-centered">` → `<Paragraph textAlign="centered">`).
|
|
112
|
+
*/
|
|
113
|
+
export declare const WRAPPERS: Readonly<Record<string, string>>;
|
|
114
|
+
/** The wrappers' own props, as `ROOTS` lists them for the components. */
|
|
115
|
+
export declare const WRAPPER_OWN_PROPS: Readonly<Record<string, readonly string[]>>;
|
|
116
|
+
/** Bulma 0.9 classes v1 dropped, with what replaced them. */
|
|
117
|
+
export declare const LEGACY_09: Readonly<Record<string, string>>;
|
|
118
|
+
/**
|
|
119
|
+
* `text-color` and `background` resolve to a per-target prop (`RootEntry`'s
|
|
120
|
+
* `textColor`/`bgColor`); `flex-container` only renders beside a flex
|
|
121
|
+
* `display`; `display` cannot mix a base value with per-viewport ones.
|
|
122
|
+
*/
|
|
123
|
+
export type HelperGroup = 'text-color' | 'background' | 'spacing' | 'typography' | 'display' | 'visibility' | 'flex-container' | 'flex-item' | 'other';
|
|
124
|
+
export interface HelperToken {
|
|
125
|
+
readonly group: HelperGroup;
|
|
126
|
+
readonly write: PropWrite;
|
|
127
|
+
}
|
|
128
|
+
export declare const HELPER_TOKENS: ReadonlyMap<string, HelperToken>;
|
|
129
|
+
/** Every helper prop name, for the attribute-collision check. */
|
|
130
|
+
export declare const HELPER_PROPS: ReadonlySet<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Bulma classes this source never turns into a prop, grouped by why. Any
|
|
133
|
+
* class not named above stays in `className` anyway; this list exists so
|
|
134
|
+
* every class in Bulma's stylesheet is accounted for, and a Bulma release
|
|
135
|
+
* that adds one fails a test until someone decides what it is.
|
|
136
|
+
*/
|
|
137
|
+
export declare const PASSTHROUGH: ReadonlyArray<{
|
|
138
|
+
readonly why: string;
|
|
139
|
+
readonly match: RegExp;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* Why a class stays a class. Consult it only for a class nothing above
|
|
143
|
+
* converts: a modifier converts on its own root and nowhere else, so the same
|
|
144
|
+
* class can be both (`is-narrow-touch` is a Column prop, and a breakpoint
|
|
145
|
+
* bestax has no prop for on anything else).
|
|
146
|
+
*/
|
|
147
|
+
export declare function passthroughReason(token: string): string | undefined;
|
|
148
|
+
/** The table's entry for a class. */
|
|
149
|
+
export declare function rootFor(token: string): RootEntry | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* A class that decides what its element is, for a TODO: a root the table
|
|
152
|
+
* converts or a family's outermost class. Parts and `plain` roots are not.
|
|
153
|
+
*/
|
|
154
|
+
export declare function flaggableRoot(token: string): RootEntry | undefined;
|
|
155
|
+
/** A root's modifier for a class. */
|
|
156
|
+
export declare function modifierFor(entry: RootEntry, token: string): Modifier | undefined;
|
|
157
|
+
/** What replaced a Bulma 0.9 class v1 removed. */
|
|
158
|
+
export declare function legacyHint(token: string): string | undefined;
|
|
159
|
+
/** The bestax wrapper for a plain tag. */
|
|
160
|
+
export declare function wrapperFor(tag: string): string | undefined;
|
|
161
|
+
//# sourceMappingURL=class-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM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