@react-x11/components 0.4.0 → 0.5.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 +125 -4
- package/dist/charts/components.d.ts +3 -1
- package/dist/charts/components.d.ts.map +1 -1
- package/dist/charts/components.js +8 -4
- package/dist/charts/components.js.map +1 -1
- package/dist/charts/node.d.ts +13 -6
- package/dist/charts/node.d.ts.map +1 -1
- package/dist/charts/node.js +75 -24
- package/dist/charts/node.js.map +1 -1
- package/dist/charts/render.d.ts +4 -0
- package/dist/charts/render.d.ts.map +1 -1
- package/dist/charts/render.js +11 -6
- package/dist/charts/render.js.map +1 -1
- package/dist/code-editor/node.d.ts +47 -16
- package/dist/code-editor/node.d.ts.map +1 -1
- package/dist/code-editor/node.js +121 -51
- package/dist/code-editor/node.js.map +1 -1
- package/dist/flow/draw.d.ts +19 -1
- package/dist/flow/draw.d.ts.map +1 -1
- package/dist/flow/draw.js +64 -35
- package/dist/flow/draw.js.map +1 -1
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +24 -8
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/model.d.ts +4 -2
- package/dist/flow/model.d.ts.map +1 -1
- package/dist/flow/model.js +4 -2
- package/dist/flow/model.js.map +1 -1
- package/dist/flow/node.d.ts +40 -9
- package/dist/flow/node.d.ts.map +1 -1
- package/dist/flow/node.js +142 -53
- package/dist/flow/node.js.map +1 -1
- package/dist/flow/types.d.ts +46 -21
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/formula/index.d.ts +4 -2
- package/dist/formula/index.d.ts.map +1 -1
- package/dist/formula/index.js.map +1 -1
- package/dist/formula/node.d.ts +5 -1
- package/dist/formula/node.d.ts.map +1 -1
- package/dist/formula/node.js +19 -3
- package/dist/formula/node.js.map +1 -1
- package/dist/html/controls.d.ts +4 -1
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/cascade.d.ts +11 -5
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +18 -8
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/parse.d.ts +15 -10
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +41 -16
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +3 -0
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +3 -1
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/values.d.ts +14 -1
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +11 -8
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +1 -0
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +12 -5
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +7 -4
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +22 -1
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/node.d.ts +22 -8
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +97 -15
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +3 -0
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +2 -2
- package/dist/html/paint.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/maps/clip.d.ts +43 -0
- package/dist/maps/clip.d.ts.map +1 -0
- package/dist/maps/clip.js +171 -0
- package/dist/maps/clip.js.map +1 -0
- package/dist/maps/gzip.d.ts +15 -0
- package/dist/maps/gzip.d.ts.map +1 -0
- package/dist/maps/gzip.js +56 -0
- package/dist/maps/gzip.js.map +1 -0
- package/dist/maps/index.d.ts +55 -0
- package/dist/maps/index.d.ts.map +1 -0
- package/dist/maps/index.js +141 -0
- package/dist/maps/index.js.map +1 -0
- package/dist/maps/labels.d.ts +123 -0
- package/dist/maps/labels.d.ts.map +1 -0
- package/dist/maps/labels.js +323 -0
- package/dist/maps/labels.js.map +1 -0
- package/dist/maps/mvt.d.ts +244 -0
- package/dist/maps/mvt.d.ts.map +1 -0
- package/dist/maps/mvt.js +820 -0
- package/dist/maps/mvt.js.map +1 -0
- package/dist/maps/node.d.ts +278 -0
- package/dist/maps/node.d.ts.map +1 -0
- package/dist/maps/node.js +1459 -0
- package/dist/maps/node.js.map +1 -0
- package/dist/maps/overlay.d.ts +157 -0
- package/dist/maps/overlay.d.ts.map +1 -0
- package/dist/maps/overlay.js +472 -0
- package/dist/maps/overlay.js.map +1 -0
- package/dist/maps/paint.d.ts +226 -0
- package/dist/maps/paint.d.ts.map +1 -0
- package/dist/maps/paint.js +705 -0
- package/dist/maps/paint.js.map +1 -0
- package/dist/maps/proj.d.ts +281 -0
- package/dist/maps/proj.d.ts.map +1 -0
- package/dist/maps/proj.js +451 -0
- package/dist/maps/proj.js.map +1 -0
- package/dist/maps/sources.d.ts +256 -0
- package/dist/maps/sources.d.ts.map +1 -0
- package/dist/maps/sources.js +210 -0
- package/dist/maps/sources.js.map +1 -0
- package/dist/maps/style.d.ts +141 -0
- package/dist/maps/style.d.ts.map +1 -0
- package/dist/maps/style.js +147 -0
- package/dist/maps/style.js.map +1 -0
- package/dist/maps/styles.d.ts +82 -0
- package/dist/maps/styles.d.ts.map +1 -0
- package/dist/maps/styles.js +898 -0
- package/dist/maps/styles.js.map +1 -0
- package/dist/maps/tiles.d.ts +283 -0
- package/dist/maps/tiles.d.ts.map +1 -0
- package/dist/maps/tiles.js +469 -0
- package/dist/maps/tiles.js.map +1 -0
- package/dist/maps/types.d.ts +244 -0
- package/dist/maps/types.d.ts.map +1 -0
- package/dist/maps/types.js +2 -0
- package/dist/maps/types.js.map +1 -0
- package/dist/reorder/hx.d.ts +18 -0
- package/dist/reorder/hx.d.ts.map +1 -0
- package/dist/reorder/hx.js +10 -0
- package/dist/reorder/hx.js.map +1 -0
- package/dist/reorder/index.d.ts +314 -0
- package/dist/reorder/index.d.ts.map +1 -0
- package/dist/reorder/index.js +1539 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/model.d.ts +107 -0
- package/dist/reorder/model.d.ts.map +1 -0
- package/dist/reorder/model.js +162 -0
- package/dist/reorder/model.js.map +1 -0
- package/dist/richtext/node.d.ts +15 -5
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js +40 -11
- package/dist/richtext/node.js.map +1 -1
- package/dist/richtext/runs.d.ts +35 -13
- package/dist/richtext/runs.d.ts.map +1 -1
- package/dist/richtext/runs.js +83 -27
- package/dist/richtext/runs.js.map +1 -1
- package/dist/tabs/index.d.ts +17 -0
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +849 -186
- package/dist/tabs/index.js.map +1 -1
- package/dist/terminal/vt/fonts.d.ts +45 -15
- package/dist/terminal/vt/fonts.d.ts.map +1 -1
- package/dist/terminal/vt/fonts.js +89 -19
- package/dist/terminal/vt/fonts.js.map +1 -1
- package/dist/terminal/vt/node.d.ts +42 -0
- package/dist/terminal/vt/node.d.ts.map +1 -1
- package/dist/terminal/vt/node.js +95 -11
- package/dist/terminal/vt/node.js.map +1 -1
- package/dist/terminal/vt/renderer.d.ts.map +1 -1
- package/dist/terminal/vt/renderer.js +13 -3
- package/dist/terminal/vt/renderer.js.map +1 -1
- package/package.json +13 -3
- package/src/charts/components.ts +14 -7
- package/src/charts/node.ts +81 -26
- package/src/charts/render.ts +16 -6
- package/src/code-editor/node.ts +147 -53
- package/src/flow/draw.ts +104 -35
- package/src/flow/index.ts +33 -13
- package/src/flow/model.ts +4 -2
- package/src/flow/node.ts +158 -59
- package/src/flow/types.ts +46 -21
- package/src/formula/index.ts +4 -2
- package/src/formula/node.ts +24 -5
- package/src/html/controls.ts +4 -1
- package/src/html/css/cascade.ts +18 -7
- package/src/html/css/parse.ts +46 -21
- package/src/html/css/style.ts +6 -1
- package/src/html/css/values.ts +25 -9
- package/src/html/index.ts +1 -0
- package/src/html/layout/boxes.ts +19 -9
- package/src/html/layout/inline.ts +23 -1
- package/src/html/node.ts +110 -17
- package/src/html/paint.ts +17 -2
- package/src/index.ts +98 -0
- package/src/maps/clip.ts +184 -0
- package/src/maps/gzip.ts +66 -0
- package/src/maps/index.ts +316 -0
- package/src/maps/labels.ts +442 -0
- package/src/maps/mvt.ts +857 -0
- package/src/maps/node.ts +1819 -0
- package/src/maps/overlay.ts +639 -0
- package/src/maps/paint.ts +978 -0
- package/src/maps/proj.ts +641 -0
- package/src/maps/sources.ts +425 -0
- package/src/maps/style.ts +309 -0
- package/src/maps/styles.ts +1040 -0
- package/src/maps/tiles.ts +676 -0
- package/src/maps/types.ts +260 -0
- package/src/reorder/hx.ts +31 -0
- package/src/reorder/index.ts +2223 -0
- package/src/reorder/model.ts +232 -0
- package/src/richtext/node.ts +49 -14
- package/src/richtext/runs.ts +115 -30
- package/src/tabs/index.ts +1040 -204
- package/src/terminal/vt/fonts.ts +128 -36
- package/src/terminal/vt/node.ts +105 -12
- package/src/terminal/vt/renderer.ts +13 -3
package/dist/richtext/runs.d.ts
CHANGED
|
@@ -9,15 +9,26 @@ export interface FillContext {
|
|
|
9
9
|
fillRect(x: number, y: number, w: number, h: number): void;
|
|
10
10
|
}
|
|
11
11
|
export declare function canFill(ctx: unknown): ctx is FillContext;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* One run of one laid-out line, as much of it as decoration reads.
|
|
14
|
+
*
|
|
15
|
+
* `span` and `run` are what ntk's layout hands back and what every
|
|
16
|
+
* decoration is read from: the span the run came from, markers and all, and
|
|
17
|
+
* the face it was shaped with. Both are optional because react-x11's Cocoa
|
|
18
|
+
* engine (2.3.x) reports only a run's geometry — `{ x, width, start, end }`
|
|
19
|
+
* — and a paint that assumed the rest threw on the first paragraph on
|
|
20
|
+
* macOS. A run without its span has no decoration to draw; a run without
|
|
21
|
+
* its face takes its vertical extent from the line, which both engines
|
|
22
|
+
* report.
|
|
23
|
+
*/
|
|
13
24
|
export interface LaidRun {
|
|
14
25
|
x: number;
|
|
15
26
|
width: number;
|
|
16
27
|
/** Extent within the laid-out text, in **code units** (ntk's vocabulary). */
|
|
17
28
|
start: number;
|
|
18
29
|
end: number;
|
|
19
|
-
span
|
|
20
|
-
run
|
|
30
|
+
span?: TextRun;
|
|
31
|
+
run?: {
|
|
21
32
|
font: {
|
|
22
33
|
metrics(size: number): {
|
|
23
34
|
ascent: number;
|
|
@@ -34,6 +45,11 @@ export interface LaidLine {
|
|
|
34
45
|
y: number;
|
|
35
46
|
height: number;
|
|
36
47
|
baseline: number;
|
|
48
|
+
/** The tallest face on the line, above and below `baseline`. Both engines
|
|
49
|
+
* report them; they stand in for a run's own metrics when the engine did
|
|
50
|
+
* not hand the run's face back. */
|
|
51
|
+
ascent?: number;
|
|
52
|
+
descent?: number;
|
|
37
53
|
start: number;
|
|
38
54
|
end: number;
|
|
39
55
|
runs: LaidRun[];
|
|
@@ -52,21 +68,27 @@ export interface CaretSource {
|
|
|
52
68
|
* terminal's cell backgrounds, a highlighted `<span>`.
|
|
53
69
|
*
|
|
54
70
|
* `dx`/`dy` translate the line's own coordinates into the target space, so a
|
|
55
|
-
* caller that placed this line itself passes where it placed it.
|
|
71
|
+
* caller that placed this line itself passes where it placed it. `scale` is
|
|
72
|
+
* the display scale: the chip's two-pixel inset is a logical length that
|
|
73
|
+
* never passes through a style, and grows with it.
|
|
56
74
|
*/
|
|
57
|
-
export declare function paintRunBackgrounds(ctx: FillContext, line: LaidLine, dx: number, dy: number): void;
|
|
58
|
-
/** The rules that sit **over** the glyphs: link underlines, strikethrough.
|
|
59
|
-
|
|
75
|
+
export declare function paintRunBackgrounds(ctx: FillContext, line: LaidLine, dx: number, dy: number, scale?: number): void;
|
|
76
|
+
/** The rules that sit **over** the glyphs: link underlines, strikethrough.
|
|
77
|
+
* A rule is one logical pixel thick — `scale` device pixels, so a link on a
|
|
78
|
+
* 2x panel is underlined as heavily as on a 1x one, not with a hairline. */
|
|
79
|
+
export declare function paintRunRules(ctx: FillContext, line: LaidLine, dx: number, dy: number, scale?: number): void;
|
|
60
80
|
/**
|
|
61
81
|
* The rule under a run, in one of SGR 4's five styles.
|
|
62
82
|
*
|
|
63
|
-
* All five are built from
|
|
64
|
-
* backend has no path API, and a
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* job.
|
|
83
|
+
* All five are built from rectangles `t` pixels thick — one logical pixel —
|
|
84
|
+
* rather than a stroked path: the mock backend has no path API, and a
|
|
85
|
+
* hairline stroke on a text baseline is not worth an antialiased path even
|
|
86
|
+
* where there is one. The curl is a two-level square wave — at a text size
|
|
87
|
+
* it reads as a squiggle, which is the entire job. The dot pitch and the
|
|
88
|
+
* dash length scale with the thickness, so the pattern is the pattern at
|
|
89
|
+
* any display scale.
|
|
68
90
|
*/
|
|
69
|
-
export declare function underlineRule(ctx: FillContext, x: number, y: number, width: number, style: NonNullable<TextRun['underlineStyle']
|
|
91
|
+
export declare function underlineRule(ctx: FillContext, x: number, y: number, width: number, style: NonNullable<TextRun['underlineStyle']>, t?: number): void;
|
|
70
92
|
/** A selected empty line still shows as a sliver, so a selection spanning a
|
|
71
93
|
* blank line does not appear to skip it. Core's own width for the same. */
|
|
72
94
|
export declare const EMPTY_LINE_BAND = 4;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/richtext/runs.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;mEACmE;AACnE,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,IAAI,IAAI,CAAC;IACb,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,CAA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,WAAW,EACnB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CA0ChC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/richtext/runs.js
CHANGED
|
@@ -17,20 +17,63 @@ import { codePointAtOffset, codeUnitOffsets } from '../internal/text.js';
|
|
|
17
17
|
export function canFill(ctx) {
|
|
18
18
|
return typeof ctx?.fillRect === 'function';
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The vertical extent of a run's ink, above and below the baseline: the
|
|
22
|
+
* run's own face when the engine handed it back, otherwise the line's.
|
|
23
|
+
*/
|
|
24
|
+
function inkExtent(r, line) {
|
|
25
|
+
if (r.run)
|
|
26
|
+
return r.run.font.metrics(r.run.size);
|
|
27
|
+
return {
|
|
28
|
+
ascent: line.ascent ?? line.baseline - line.y,
|
|
29
|
+
descent: line.descent ?? line.y + line.height - line.baseline,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
let warnedSpanless = false;
|
|
33
|
+
/**
|
|
34
|
+
* Say so, once, when a laid-out run arrives without the span it came from:
|
|
35
|
+
* every decoration is read off that span, so none will be drawn, and a
|
|
36
|
+
* document that suddenly has no code chips or link underlines should not be
|
|
37
|
+
* a mystery. react-x11's Cocoa engine (2.3.x) is the one that does this.
|
|
38
|
+
*
|
|
39
|
+
* `process` and `console` come off `globalThis` because `src/` compiles
|
|
40
|
+
* with `types: []` — a Node global that wandered in would fail the build
|
|
41
|
+
* rather than become an implicit `@types/node` dependency.
|
|
42
|
+
*/
|
|
43
|
+
function warnSpanless() {
|
|
44
|
+
if (warnedSpanless)
|
|
45
|
+
return;
|
|
46
|
+
warnedSpanless = true;
|
|
47
|
+
const g = globalThis;
|
|
48
|
+
if (g.process?.env?.NODE_ENV === 'production')
|
|
49
|
+
return;
|
|
50
|
+
g.console?.warn('@react-x11/components: the text engine handed back laid-out runs ' +
|
|
51
|
+
'without their spans, so run decorations (backgrounds, underlines, ' +
|
|
52
|
+
"strikethrough) and inline link hit-testing are off. react-x11's " +
|
|
53
|
+
"Cocoa text engine (2.3.x) does this; ntk's does not.");
|
|
54
|
+
}
|
|
20
55
|
/**
|
|
21
56
|
* The fills that sit **under** the glyphs: the inline-code chip, a
|
|
22
57
|
* terminal's cell backgrounds, a highlighted `<span>`.
|
|
23
58
|
*
|
|
24
59
|
* `dx`/`dy` translate the line's own coordinates into the target space, so a
|
|
25
|
-
* caller that placed this line itself passes where it placed it.
|
|
60
|
+
* caller that placed this line itself passes where it placed it. `scale` is
|
|
61
|
+
* the display scale: the chip's two-pixel inset is a logical length that
|
|
62
|
+
* never passes through a style, and grows with it.
|
|
26
63
|
*/
|
|
27
|
-
export function paintRunBackgrounds(ctx, line, dx, dy) {
|
|
64
|
+
export function paintRunBackgrounds(ctx, line, dx, dy, scale = 1) {
|
|
65
|
+
const inset = Math.round(2 * scale);
|
|
28
66
|
for (const r of line.runs) {
|
|
29
|
-
const
|
|
67
|
+
const span = r.span;
|
|
68
|
+
if (!span) {
|
|
69
|
+
warnSpanless();
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const bg = span.bg;
|
|
30
73
|
if (!bg)
|
|
31
74
|
continue;
|
|
32
75
|
ctx.fillStyle = bg;
|
|
33
|
-
if (
|
|
76
|
+
if (span.bgFill === 'line') {
|
|
34
77
|
// Both edges are rounded from absolute positions rather than the left
|
|
35
78
|
// being rounded and the width ceiled, so two adjacent runs agree on the
|
|
36
79
|
// pixel between them: no seam, and no overlap either.
|
|
@@ -39,55 +82,68 @@ export function paintRunBackgrounds(ctx, line, dx, dy) {
|
|
|
39
82
|
ctx.fillRect(left, Math.round(dy + line.y), Math.max(0, right - left), Math.ceil(line.height));
|
|
40
83
|
continue;
|
|
41
84
|
}
|
|
42
|
-
const m =
|
|
43
|
-
ctx.fillRect(Math.round(dx + line.x + r.x -
|
|
85
|
+
const m = inkExtent(r, line);
|
|
86
|
+
ctx.fillRect(Math.round(dx + line.x + r.x - inset), Math.round(dy + line.baseline - m.ascent), Math.ceil(r.width + inset * 2), Math.ceil(m.ascent + m.descent));
|
|
44
87
|
}
|
|
45
88
|
}
|
|
46
|
-
/** The rules that sit **over** the glyphs: link underlines, strikethrough.
|
|
47
|
-
|
|
89
|
+
/** The rules that sit **over** the glyphs: link underlines, strikethrough.
|
|
90
|
+
* A rule is one logical pixel thick — `scale` device pixels, so a link on a
|
|
91
|
+
* 2x panel is underlined as heavily as on a 1x one, not with a hairline. */
|
|
92
|
+
export function paintRunRules(ctx, line, dx, dy, scale = 1) {
|
|
93
|
+
const t = ruleThickness(scale);
|
|
48
94
|
for (const r of line.runs) {
|
|
49
|
-
const
|
|
95
|
+
const span = r.span;
|
|
96
|
+
if (!span)
|
|
97
|
+
continue;
|
|
98
|
+
const { underline, strike } = span;
|
|
50
99
|
if (underline) {
|
|
51
100
|
ctx.fillStyle = underline;
|
|
52
|
-
underlineRule(ctx, Math.round(dx + line.x + r.x), Math.round(dy + line.baseline + 2), Math.ceil(r.width),
|
|
101
|
+
underlineRule(ctx, Math.round(dx + line.x + r.x), Math.round(dy + line.baseline + 2 * t), Math.ceil(r.width), span.underlineStyle ?? 'single', t);
|
|
53
102
|
}
|
|
54
103
|
if (strike) {
|
|
55
|
-
const m =
|
|
104
|
+
const m = inkExtent(r, line);
|
|
56
105
|
ctx.fillStyle = strike;
|
|
57
|
-
ctx.fillRect(Math.round(dx + line.x + r.x), Math.round(dy + line.baseline - m.ascent * 0.38), Math.ceil(r.width),
|
|
106
|
+
ctx.fillRect(Math.round(dx + line.x + r.x), Math.round(dy + line.baseline - m.ascent * 0.38), Math.ceil(r.width), t);
|
|
58
107
|
}
|
|
59
108
|
}
|
|
60
109
|
}
|
|
110
|
+
/** One logical pixel on the device grid, never less than one device pixel. */
|
|
111
|
+
function ruleThickness(scale) {
|
|
112
|
+
return Math.max(1, Math.round(scale));
|
|
113
|
+
}
|
|
61
114
|
/**
|
|
62
115
|
* The rule under a run, in one of SGR 4's five styles.
|
|
63
116
|
*
|
|
64
|
-
* All five are built from
|
|
65
|
-
* backend has no path API, and a
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* job.
|
|
117
|
+
* All five are built from rectangles `t` pixels thick — one logical pixel —
|
|
118
|
+
* rather than a stroked path: the mock backend has no path API, and a
|
|
119
|
+
* hairline stroke on a text baseline is not worth an antialiased path even
|
|
120
|
+
* where there is one. The curl is a two-level square wave — at a text size
|
|
121
|
+
* it reads as a squiggle, which is the entire job. The dot pitch and the
|
|
122
|
+
* dash length scale with the thickness, so the pattern is the pattern at
|
|
123
|
+
* any display scale.
|
|
69
124
|
*/
|
|
70
|
-
export function underlineRule(ctx, x, y, width, style) {
|
|
125
|
+
export function underlineRule(ctx, x, y, width, style, t = 1) {
|
|
71
126
|
switch (style) {
|
|
72
127
|
case 'double':
|
|
73
|
-
ctx.fillRect(x, y, width,
|
|
74
|
-
ctx.fillRect(x, y + 2, width,
|
|
128
|
+
ctx.fillRect(x, y, width, t);
|
|
129
|
+
ctx.fillRect(x, y + 2 * t, width, t);
|
|
75
130
|
return;
|
|
76
131
|
case 'dotted':
|
|
77
|
-
for (let i = 0; i < width; i += 2)
|
|
78
|
-
ctx.fillRect(x + i, y,
|
|
132
|
+
for (let i = 0; i < width; i += 2 * t) {
|
|
133
|
+
ctx.fillRect(x + i, y, Math.min(t, width - i), t);
|
|
134
|
+
}
|
|
79
135
|
return;
|
|
80
136
|
case 'dashed':
|
|
81
|
-
for (let i = 0; i < width; i += 6)
|
|
82
|
-
ctx.fillRect(x + i, y, Math.min(3, width - i),
|
|
137
|
+
for (let i = 0; i < width; i += 6 * t)
|
|
138
|
+
ctx.fillRect(x + i, y, Math.min(3 * t, width - i), t);
|
|
83
139
|
return;
|
|
84
140
|
case 'curly':
|
|
85
|
-
for (let i = 0; i < width; i += 2) {
|
|
86
|
-
ctx.fillRect(x + i, y + (i % 4 === 0 ? 0 :
|
|
141
|
+
for (let i = 0; i < width; i += 2 * t) {
|
|
142
|
+
ctx.fillRect(x + i, y + (i % (4 * t) === 0 ? 0 : t), Math.min(2 * t, width - i), t);
|
|
87
143
|
}
|
|
88
144
|
return;
|
|
89
145
|
default:
|
|
90
|
-
ctx.fillRect(x, y, width,
|
|
146
|
+
ctx.fillRect(x, y, width, t);
|
|
91
147
|
return;
|
|
92
148
|
}
|
|
93
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/richtext/runs.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,oEAAoE;AACpE,6EAA6E;AAC7E,UAAU;AACV,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,8EAA8E;AAC9E,mCAAmC;AACnC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAYzE,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,OAAO,OAAQ,GAAmC,EAAE,QAAQ,KAAK,UAAU,CAAC;AAC9E,CAAC;
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/richtext/runs.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,oEAAoE;AACpE,6EAA6E;AAC7E,UAAU;AACV,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,8EAA8E;AAC9E,mCAAmC;AACnC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAYzE,MAAM,UAAU,OAAO,CAAC,GAAY;IA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,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;YACnC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACjC,SAAS;QACX,CAAC;QACD,IAAI,KAAK,GAAG,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC7D,IAAI,IAAI;YAAE,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/tabs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Style } from 'react-x11/style';
|
|
|
4
4
|
type StyleInput = Style | Style[];
|
|
5
5
|
export type TabsVariant = 'line' | 'subtle' | 'enclosed' | 'outline' | 'plain';
|
|
6
6
|
export type TabsSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
export type TabsOverflow = 'menu' | 'clip';
|
|
7
8
|
/** What `onValueChange` reports — Chakra's `details` object, so a handler
|
|
8
9
|
* written for Chakra (`(e) => setValue(e.value)`) transfers unchanged. */
|
|
9
10
|
export interface TabsValueChange {
|
|
@@ -39,6 +40,18 @@ export interface TabsProps {
|
|
|
39
40
|
fitted?: boolean;
|
|
40
41
|
/** Where the triggers sit along the strip. Default `'start'`. */
|
|
41
42
|
justify?: 'start' | 'center' | 'end';
|
|
43
|
+
/**
|
|
44
|
+
* What a **horizontal** strip does with more tabs than it has room for.
|
|
45
|
+
*
|
|
46
|
+
* `'menu'` (the default) keeps as many as fit and moves the rest behind a
|
|
47
|
+
* button at the end of the strip, which drops them as a menu; the selected
|
|
48
|
+
* tab is never one of them. `'clip'` is the older behaviour — the strip
|
|
49
|
+
* overflows and the tabs past its edge are simply not visible.
|
|
50
|
+
*
|
|
51
|
+
* A vertical strip ignores this: it overflows downward, where a menu is
|
|
52
|
+
* the wrong answer and a scroll is the right one.
|
|
53
|
+
*/
|
|
54
|
+
overflow?: TabsOverflow;
|
|
42
55
|
/** Build a panel the first time its tab is selected rather than up front.
|
|
43
56
|
* Default false: every panel mounts, hidden, so its state is live. */
|
|
44
57
|
lazyMount?: boolean;
|
|
@@ -91,6 +104,10 @@ export interface TabsListProps {
|
|
|
91
104
|
* to the ends. In `manual` mode focus moves without selecting, and Enter or
|
|
92
105
|
* Space commits — those keys are not handled here, because core makes them
|
|
93
106
|
* the click the trigger's own `onClick` already is.
|
|
107
|
+
*
|
|
108
|
+
* A horizontal strip with more tabs than room keeps the ones that fit and
|
|
109
|
+
* drops the rest into a menu at its end (`overflow`, on the root). The
|
|
110
|
+
* menu's button is the last stop on the same walk.
|
|
94
111
|
*/
|
|
95
112
|
export declare function TabsList(props: TabsListProps): ReactElement;
|
|
96
113
|
export interface TabsTriggerProps {
|
package/dist/tabs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrD,OAAO,KAAK,EAAE,KAAK,EAAmB,MAAM,iBAAiB,CAAC;AAkB9D,wEAAwE;AACxE,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;AA+ClC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,Q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