@react-x11/components 0.14.1 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-editor/node.d.ts +13 -0
- package/dist/code-editor/node.d.ts.map +1 -1
- package/dist/code-editor/node.js +23 -5
- package/dist/code-editor/node.js.map +1 -1
- package/dist/html/css/cascade.d.ts +171 -26
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +616 -216
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/color.d.ts +25 -0
- package/dist/html/css/color.d.ts.map +1 -1
- package/dist/html/css/color.js +307 -19
- package/dist/html/css/color.js.map +1 -1
- package/dist/html/css/content.d.ts +11 -6
- package/dist/html/css/content.d.ts.map +1 -1
- package/dist/html/css/content.js +171 -12
- package/dist/html/css/content.js.map +1 -1
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +62 -9
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/shapes.d.ts +18 -0
- package/dist/html/css/shapes.d.ts.map +1 -1
- package/dist/html/css/shapes.js +21 -1
- package/dist/html/css/shapes.js.map +1 -1
- package/dist/html/css/style.d.ts +42 -5
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +74 -12
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/ua.js +27 -8
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/css/values.d.ts +5 -0
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +18 -9
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +7 -0
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/block.d.ts +29 -9
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +141 -52
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +29 -2
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +172 -23
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/css-grid.d.ts.map +1 -1
- package/dist/html/layout/css-grid.js +11 -9
- package/dist/html/layout/css-grid.js.map +1 -1
- package/dist/html/layout/flex.d.ts.map +1 -1
- package/dist/html/layout/flex.js +1759 -238
- package/dist/html/layout/flex.js.map +1 -1
- package/dist/html/layout/inline.d.ts +15 -3
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +64 -19
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/layout/table.d.ts +27 -1
- package/dist/html/layout/table.d.ts.map +1 -1
- package/dist/html/layout/table.js +886 -324
- package/dist/html/layout/table.js.map +1 -1
- package/dist/html/node.d.ts +35 -4
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +122 -26
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +558 -178
- package/dist/html/paint.js.map +1 -1
- package/dist/html/resources.js +14 -1
- package/dist/html/resources.js.map +1 -1
- package/dist/html/svg.d.ts +23 -7
- package/dist/html/svg.d.ts.map +1 -1
- package/dist/html/svg.js +264 -59
- package/dist/html/svg.js.map +1 -1
- package/dist/html/widgets.d.ts.map +1 -1
- package/dist/html/widgets.js +57 -4
- package/dist/html/widgets.js.map +1 -1
- package/package.json +3 -3
- package/src/code-editor/node.ts +24 -5
- package/src/html/css/cascade.ts +697 -221
- package/src/html/css/color.ts +345 -18
- package/src/html/css/content.ts +173 -15
- package/src/html/css/parse.ts +60 -8
- package/src/html/css/shapes.ts +35 -1
- package/src/html/css/style.ts +122 -17
- package/src/html/css/ua.ts +27 -8
- package/src/html/css/values.ts +23 -9
- package/src/html/index.ts +7 -0
- package/src/html/layout/block.ts +149 -58
- package/src/html/layout/boxes.ts +211 -27
- package/src/html/layout/css-grid.ts +12 -9
- package/src/html/layout/flex.ts +1975 -231
- package/src/html/layout/inline.ts +70 -16
- package/src/html/layout/table.ts +961 -332
- package/src/html/node.ts +155 -27
- package/src/html/paint.ts +692 -234
- package/src/html/resources.ts +13 -1
- package/src/html/svg.ts +299 -56
- package/src/html/widgets.ts +61 -4
|
@@ -45,6 +45,7 @@ import { inkColor, isTransparent, resolve } from '../css/values.js';
|
|
|
45
45
|
import { tagOf } from '../dom.js';
|
|
46
46
|
import {
|
|
47
47
|
BOX_RAISES,
|
|
48
|
+
CONTROL_BASELINES,
|
|
48
49
|
GRID_TRACKS,
|
|
49
50
|
LINE_BOX_RAISES,
|
|
50
51
|
PADDED_FACES,
|
|
@@ -483,7 +484,7 @@ function linesOf(
|
|
|
483
484
|
// text a box's background shows through (`background-clip: text`): its
|
|
484
485
|
// layouts are made through a recorder, so paint can lay the same text out
|
|
485
486
|
// again with no ink of its own and fill it with that background
|
|
486
|
-
if (options.clipText && clipsText(
|
|
487
|
+
if (options.clipText && clipsText(items)) {
|
|
487
488
|
CLIPPED_TEXT.add(block);
|
|
488
489
|
fonts = recording(fonts);
|
|
489
490
|
}
|
|
@@ -3329,6 +3330,22 @@ function atomicRaise(
|
|
|
3329
3330
|
*/
|
|
3330
3331
|
function atomicBaseline(box: Box): number {
|
|
3331
3332
|
const margin = box.height + box.marginTop + box.marginBottom;
|
|
3333
|
+
// a control on its text's baseline, or on its border box's bottom,
|
|
3334
|
+
// where layout containment does not keep its baseline in
|
|
3335
|
+
const control =
|
|
3336
|
+
box.style.contain & CONTAIN_LAYOUT ? undefined : CONTROL_BASELINES.get(box);
|
|
3337
|
+
if (control === 'border') return box.marginTop + box.height;
|
|
3338
|
+
if (control) {
|
|
3339
|
+
const content = box.height - box.verticalExtra;
|
|
3340
|
+
const text = control.ascent + control.descent;
|
|
3341
|
+
return (
|
|
3342
|
+
box.marginTop +
|
|
3343
|
+
box.borderTop +
|
|
3344
|
+
box.padTop +
|
|
3345
|
+
(content - text) / 2 +
|
|
3346
|
+
control.ascent
|
|
3347
|
+
);
|
|
3348
|
+
}
|
|
3332
3349
|
const button = isButton(box);
|
|
3333
3350
|
// A `<button>` with no line in it sits on the bottom of its content box,
|
|
3334
3351
|
// not of its margin box: where its label would have sat. No specification
|
|
@@ -3468,14 +3485,14 @@ function tableBaseline(table: Box): number | null {
|
|
|
3468
3485
|
* chevron, and the line it was on came out shorter than a browser's.
|
|
3469
3486
|
*/
|
|
3470
3487
|
function lastBaselineIn(box: Box): number | null {
|
|
3471
|
-
if (box.kind === 'flex') return flexBaseline(box);
|
|
3488
|
+
if (box.kind === 'flex') return heldIn(box, flexBaseline(box));
|
|
3472
3489
|
if (box.lines?.length) {
|
|
3473
3490
|
const line = box.lines[box.lines.length - 1];
|
|
3474
|
-
return line.y + line.baseline;
|
|
3491
|
+
return heldIn(box, line.y + line.baseline);
|
|
3475
3492
|
}
|
|
3476
3493
|
for (let i = box.children.length - 1; i >= 0; i -= 1) {
|
|
3477
3494
|
const found = childBaseline(box.children[i], lastBaselineIn);
|
|
3478
|
-
if (found !== null) return found;
|
|
3495
|
+
if (found !== null) return heldIn(box, found);
|
|
3479
3496
|
}
|
|
3480
3497
|
return null;
|
|
3481
3498
|
}
|
|
@@ -3483,15 +3500,32 @@ function lastBaselineIn(box: Box): number | null {
|
|
|
3483
3500
|
/** The same, from the first line box or child: a table's baseline is its
|
|
3484
3501
|
* first row's, and so is a table cell's. */
|
|
3485
3502
|
export function firstBaselineIn(box: Box): number | null {
|
|
3486
|
-
if (box.kind === 'flex') return flexBaseline(box);
|
|
3487
|
-
if (box.lines?.length)
|
|
3503
|
+
if (box.kind === 'flex') return heldIn(box, flexBaseline(box));
|
|
3504
|
+
if (box.lines?.length) {
|
|
3505
|
+
return heldIn(box, box.lines[0].y + box.lines[0].baseline);
|
|
3506
|
+
}
|
|
3488
3507
|
for (const child of box.children) {
|
|
3489
3508
|
const found = childBaseline(child, firstBaselineIn);
|
|
3490
|
-
if (found !== null) return found;
|
|
3509
|
+
if (found !== null) return heldIn(box, found);
|
|
3491
3510
|
}
|
|
3492
3511
|
return null;
|
|
3493
3512
|
}
|
|
3494
3513
|
|
|
3514
|
+
/**
|
|
3515
|
+
* A box's baseline as its content gives it, held to its border box where
|
|
3516
|
+
* the box is a scroll container (CSS Box Alignment 3, 9.1), at either edge
|
|
3517
|
+
* — and only there: a box whose text overflows it otherwise, or clips it
|
|
3518
|
+
* (`overflow: clip` is no scroll container), has the baseline its text
|
|
3519
|
+
* has, as Chrome has it. Held at every box, so a scroll container deep in
|
|
3520
|
+
* an item, or in an inline block, holds the baseline it gives to its box.
|
|
3521
|
+
* The flex layout held every item to its height, and an item shorter
|
|
3522
|
+
* than its text sat its text's descent below the items beside it.
|
|
3523
|
+
*/
|
|
3524
|
+
function heldIn(box: Box, found: number | null): number | null {
|
|
3525
|
+
if (found === null || !scrolls(box.style)) return found;
|
|
3526
|
+
return Math.min(Math.max(found, box.y), box.y + box.height);
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3495
3529
|
function childBaseline(
|
|
3496
3530
|
child: Box,
|
|
3497
3531
|
inside: (box: Box) => number | null,
|
|
@@ -3502,9 +3536,9 @@ function childBaseline(
|
|
|
3502
3536
|
// a table is passed over for a block's last baseline (`lastBaselineIn`)
|
|
3503
3537
|
if (inside === lastBaselineIn && child.kind === 'table') return null;
|
|
3504
3538
|
// the legacy rule is a block container's last baseline alone (CSS Box
|
|
3505
|
-
// Alignment 3, 9.2): its first is its first line's, clipped or not
|
|
3506
|
-
// and a button that clips keeps its
|
|
3507
|
-
// own (`atomicBaseline`)
|
|
3539
|
+
// Alignment 3, 9.2): its first is its first line's, clipped or not, held
|
|
3540
|
+
// to its border box (`heldIn`) — and a button that clips keeps its
|
|
3541
|
+
// label's, here as on a line of its own (`atomicBaseline`)
|
|
3508
3542
|
if (
|
|
3509
3543
|
inside === lastBaselineIn &&
|
|
3510
3544
|
child.kind !== 'flex' &&
|
|
@@ -5333,6 +5367,22 @@ function alignShift(
|
|
|
5333
5367
|
}
|
|
5334
5368
|
}
|
|
5335
5369
|
|
|
5370
|
+
/**
|
|
5371
|
+
* Where an empty line in `style`'s block sets the point it holds, between
|
|
5372
|
+
* `left` and `right`: an absolutely positioned box that was inline-level
|
|
5373
|
+
* before it was made a block has its static position there, as though it
|
|
5374
|
+
* were all its line held (CSS 2.1 10.3.7, as browsers place it). Such a
|
|
5375
|
+
* line is its block's last, which `text-align-last` sets.
|
|
5376
|
+
*/
|
|
5377
|
+
export function emptyLinePoint(
|
|
5378
|
+
style: ComputedStyle,
|
|
5379
|
+
left: number,
|
|
5380
|
+
right: number,
|
|
5381
|
+
): number {
|
|
5382
|
+
const shift = alignShift(lastAlignOf(style), style.direction === 'rtl');
|
|
5383
|
+
return left + (right - left) * shift;
|
|
5384
|
+
}
|
|
5385
|
+
|
|
5336
5386
|
/** How far a line of a layout moves to where it belongs in its box. */
|
|
5337
5387
|
type LinePlacer = (line: { x: number; width: number }) => number;
|
|
5338
5388
|
|
|
@@ -5392,9 +5442,9 @@ export function inklessLayout(layout: object): TextLayoutLike | null {
|
|
|
5392
5442
|
}
|
|
5393
5443
|
|
|
5394
5444
|
/** Whether any of a block's text is text a background shows through. */
|
|
5395
|
-
function clipsText(
|
|
5445
|
+
function clipsText(items: Item[]): boolean {
|
|
5396
5446
|
for (const item of items) {
|
|
5397
|
-
if (item.kind === 'text' && !item.control && clipBoxOf(item.box
|
|
5447
|
+
if (item.kind === 'text' && !item.control && clipBoxOf(item.box)) {
|
|
5398
5448
|
return true;
|
|
5399
5449
|
}
|
|
5400
5450
|
}
|
|
@@ -5402,12 +5452,16 @@ function clipsText(block: Box, items: Item[]): boolean {
|
|
|
5402
5452
|
}
|
|
5403
5453
|
|
|
5404
5454
|
/** The box whose background a text box's glyphs show: the nearest element
|
|
5405
|
-
* box from it up
|
|
5406
|
-
*
|
|
5407
|
-
|
|
5455
|
+
* box from it up with `background-clip: text`, or null. That is past the
|
|
5456
|
+
* block its lines are in: an ancestor's background is clipped to the text
|
|
5457
|
+
* of its descendants in flow and floating, a block, an inline-block, a
|
|
5458
|
+
* flex item or a table cell's among them (CSS Backgrounds 4, 3.7), and
|
|
5459
|
+
* `bg-clip-text` on a `<div>` round a heading showed nothing through it.
|
|
5460
|
+
* Not past an absolutely positioned box, whose text is its own. */
|
|
5461
|
+
export function clipBoxOf(box: Box | null): Box | null {
|
|
5408
5462
|
for (let at = box; at; at = at.parent) {
|
|
5409
5463
|
if (at.kind !== 'text' && at.style.backgroundClipText) return at;
|
|
5410
|
-
if (at
|
|
5464
|
+
if (at.outOfFlow) return null;
|
|
5411
5465
|
}
|
|
5412
5466
|
return null;
|
|
5413
5467
|
}
|