react-x11 2.48.0 → 2.50.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.
@@ -10,11 +10,71 @@
10
10
  */
11
11
  export type Color = string;
12
12
 
13
+ /**
14
+ * A colour in a style: any {@link Color}, or `'currentColor'` — the node's
15
+ * ink, its own `color` or the one it inherits, followed wherever it moves.
16
+ * See
17
+ * {@link https://github.com/sidorares/react-x11/blob/master/docs/styling.md#currentcolor currentColor}.
18
+ */
19
+ export type StyleColor = 'currentColor' | (string & {});
20
+
21
+ /**
22
+ * CSS's relative units, resolved for the node they are written on, in
23
+ * logical pixels: `em` is its own font size (on `fontSize`, the one it
24
+ * inherits), `rem` the palette's `fontSize`, and the viewport units the
25
+ * window it is in — the size a `'@width >= 600'` block asks about. Each is
26
+ * resolved again when what it is relative to moves. See docs/styling.md,
27
+ * "Lengths and shorthands".
28
+ */
29
+ export type RelativeLength =
30
+ `${number}${'em' | 'rem' | 'vw' | 'vh' | 'vmin' | 'vmax'}`;
31
+
32
+ /**
33
+ * CSS's length functions over pixels and the relative units, resolved to one
34
+ * number where the style is: `'calc(1rem + 2px)'`, `'clamp(14px, 2vw,
35
+ * 20px)'`. A percentage takes part only alone — yoga takes one unit per
36
+ * value — so `'calc(100% - 16px)'` is an error saying so.
37
+ */
38
+ export type LengthFunction = `${'calc' | 'min' | 'max' | 'clamp'}(${string})`;
39
+
40
+ /**
41
+ * A distance in logical pixels: a number, the same number written `'12px'`,
42
+ * a relative length or a length function. The display scale turns what it
43
+ * comes to into device pixels. CSS's other units — `ex`, `ch`, the container
44
+ * units, print units — are an error naming the unit rather than a guess.
45
+ */
46
+ export type Pixels = number | `${number}px` | RelativeLength | LengthFunction;
47
+
13
48
  /** A yoga length: pixels, a percentage, or `'auto'`. */
14
- export type Dimension = number | `${number}%` | 'auto';
49
+ export type Dimension = Pixels | `${number}%` | 'auto';
15
50
 
16
51
  /** A yoga length that has no `auto` form. */
17
- export type Length = number | `${number}%`;
52
+ export type Length = Pixels | `${number}%`;
53
+
54
+ /** A border's or an outline's width: pixels, or CSS's three keywords —
55
+ * `'thin'` 1, `'medium'` 3, `'thick'` 5. */
56
+ export type LineWidth = Pixels | 'thin' | 'medium' | 'thick';
57
+
58
+ /**
59
+ * CSS's one-to-four rule, as one string: `'8px 16px'` is top and bottom,
60
+ * then right and left; `'1px 2px 3px'` is top, the sides, bottom. Typed as a
61
+ * first value and whatever follows; the rest is checked when the style is.
62
+ */
63
+ export type Edges<T extends string | number> = T | `${T} ${string}`;
64
+
65
+ /** A first value and a second, the second the first when left out:
66
+ * `gap: '4px 8px'` is a row gap and a column gap. */
67
+ export type Pair<T extends string | number> = T | `${T} ${T}`;
68
+
69
+ /**
70
+ * A line — `border` and its sides, `outline` — as CSS writes it: a width, a
71
+ * style and a colour in any order, each at most once, or `'none'`.
72
+ * `'1px solid $border'`, `'2px dashed #c0392b'`. A number is the width. A
73
+ * width left out is CSS's `'medium'`, 3px; the style is `'solid'` or
74
+ * `'dashed'` (an outline is solid only); and a colour left out is
75
+ * `currentColor`, unless the style names one for that side elsewhere.
76
+ */
77
+ export type Line = number | 'none' | (string & {});
18
78
 
19
79
  export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
20
80
 
@@ -146,9 +206,19 @@ export interface LayoutStyle {
146
206
  * CSS's shorthand: `flex: 1` is `flexGrow: 1, flexShrink: 1,
147
207
  * flexBasis: 0` — take this share of what is left, from a base size of
148
208
  * nothing. `'auto'` grows and shrinks from the content's own size,
149
- * `'none'` does neither. A longhand written beside it wins.
209
+ * `'none'` does neither, `'initial'` shrinks only. And CSS's long form —
210
+ * `'1 1 0'`, `'0 0 240px'`, `'2 200px'`, `'240px'`. A longhand written
211
+ * beside it wins.
150
212
  */
151
- flex?: number | 'auto' | 'none';
213
+ flex?:
214
+ | number
215
+ | 'auto'
216
+ | 'none'
217
+ | 'initial'
218
+ | `${number}`
219
+ | Length
220
+ | `${number} ${string}`
221
+ | `${Length} ${number}`;
152
222
  flexGrow?: number;
153
223
  /** How eagerly this item gives up the space it has **above its content**;
154
224
  * `1` by default, as in CSS. It never shrinks past what is inside it —
@@ -216,16 +286,23 @@ export interface LayoutStyle {
216
286
  * the scheme's to read: how close to the scroll pane's edge the box may
217
287
  * come, for sticky, where a percentage is of the pane's size. The same
218
288
  * holds for the other five. */
219
- top?: Length;
220
- right?: Length;
221
- bottom?: Length;
222
- left?: Length;
223
- margin?: Dimension;
289
+ top?: Dimension;
290
+ right?: Dimension;
291
+ bottom?: Dimension;
292
+ left?: Dimension;
293
+ /** CSS's `inset`: `top`, `right`, `bottom` and `left` in one, by the
294
+ * one-to-four rule — `inset: 0` pins all four edges. */
295
+ inset?: Edges<Dimension>;
296
+ /** One value for all four sides, or CSS's one-to-four rule:
297
+ * `'0 auto'`, `'8px 16px 4px'`. A side written beside it wins. */
298
+ margin?: Edges<Dimension>;
224
299
  marginTop?: Dimension;
225
300
  marginRight?: Dimension;
226
301
  marginBottom?: Dimension;
227
302
  marginLeft?: Dimension;
228
- padding?: Length;
303
+ /** One value for all four sides, or CSS's one-to-four rule:
304
+ * `'8px 16px'`. A side written beside it wins, wherever it is written. */
305
+ padding?: Edges<Length>;
229
306
  paddingTop?: Length;
230
307
  paddingRight?: Length;
231
308
  paddingBottom?: Length;
@@ -236,29 +313,55 @@ export interface LayoutStyle {
236
313
  * override their physical counterparts even in LTR, the way CSS's
237
314
  * `padding-inline-start` overrides `padding-left`.
238
315
  */
239
- start?: Length;
240
- end?: Length;
316
+ start?: Dimension;
317
+ end?: Dimension;
241
318
  marginStart?: Dimension;
242
319
  marginEnd?: Dimension;
243
320
  paddingStart?: Length;
244
321
  paddingEnd?: Length;
245
- gap?: number;
246
- rowGap?: number;
247
- columnGap?: number;
322
+ /** CSS's logical pairs: `paddingInline` is `paddingStart` then
323
+ * `paddingEnd`, `paddingBlock` is `paddingTop` then `paddingBottom` —
324
+ * one value for both, or two. */
325
+ paddingInline?: Pair<Length>;
326
+ paddingBlock?: Pair<Length>;
327
+ marginInline?: Pair<Dimension>;
328
+ marginBlock?: Pair<Dimension>;
329
+ /** One gap for both directions, or CSS's two: `'4px 8px'` is the row gap,
330
+ * then the column gap. */
331
+ gap?: Pair<Length>;
332
+ rowGap?: Length;
333
+ columnGap?: Length;
248
334
  aspectRatio?: number;
249
335
  display?: Display;
250
336
  overflow?: Overflow;
251
- borderWidth?: number;
337
+ /**
338
+ * CSS's `border`: a width, a style and a colour in one —
339
+ * `'1px solid $border'`. It sets `borderWidth`, `borderStyle` and
340
+ * `borderColor`, and each of those written beside it wins. Layout, since
341
+ * the width is: not legal in a state block, where `borderColor` is.
342
+ */
343
+ border?: Line;
344
+ /** One side's width and colour — `borderBottom: '1px solid $border'` is a
345
+ * row's rule. A side's style is the box's: one `borderStyle` per box. */
346
+ borderTop?: Line;
347
+ borderRight?: Line;
348
+ borderBottom?: Line;
349
+ borderLeft?: Line;
350
+ /** …and the logical sides, which win over the physical ones. */
351
+ borderStart?: Line;
352
+ borderEnd?: Line;
353
+ /** One width for all four sides, or CSS's one-to-four rule. */
354
+ borderWidth?: Edges<LineWidth>;
252
355
  /** Per-side widths override `borderWidth` the way `paddingTop` overrides
253
356
  * `padding`. Layout properties: yoga sees each edge, so a 3px left bar
254
357
  * insets content on the left only. */
255
- borderTopWidth?: number;
256
- borderRightWidth?: number;
257
- borderBottomWidth?: number;
258
- borderLeftWidth?: number;
358
+ borderTopWidth?: LineWidth;
359
+ borderRightWidth?: LineWidth;
360
+ borderBottomWidth?: LineWidth;
361
+ borderLeftWidth?: LineWidth;
259
362
  /** The logical sides, which win over the physical ones. */
260
- borderStartWidth?: number;
261
- borderEndWidth?: number;
363
+ borderStartWidth?: LineWidth;
364
+ borderEndWidth?: LineWidth;
262
365
  direction?: Direction;
263
366
  }
264
367
 
@@ -269,7 +372,14 @@ export interface LayoutStyle {
269
372
  * on pointer move.
270
373
  */
271
374
  export interface PaintStyle {
272
- backgroundColor?: Color;
375
+ /**
376
+ * CSS's `background`, as much of it as a box paints: a colour, a
377
+ * `linear-gradient(…)`, or both — `'#f5f6fa'`,
378
+ * `'linear-gradient($accent, $accentActive) $accent'`. `'none'` takes both
379
+ * away. A `url()` is an `<image>` here, not a background.
380
+ */
381
+ background?: StyleColor;
382
+ backgroundColor?: StyleColor;
273
383
  /**
274
384
  * A gradient behind the node, in the box the layout gave it:
275
385
  * `'linear-gradient(#2b5876, #4e4376)'`, `'linear-gradient(135deg, $accent,
@@ -294,20 +404,25 @@ export interface PaintStyle {
294
404
  * `<window>`/`<popup>`, which own no pixels outside themselves.
295
405
  */
296
406
  boxShadow?: string;
297
- borderColor?: Color;
407
+ /** One colour for all four sides, or CSS's one-to-four rule:
408
+ * `'$border transparent'`. */
409
+ borderColor?: StyleColor;
298
410
  /** Per-side colours fall back to `borderColor`. Paint properties, legal in
299
411
  * state blocks like it. */
300
- borderTopColor?: Color;
301
- borderRightColor?: Color;
302
- borderBottomColor?: Color;
303
- borderLeftColor?: Color;
412
+ borderTopColor?: StyleColor;
413
+ borderRightColor?: StyleColor;
414
+ borderBottomColor?: StyleColor;
415
+ borderLeftColor?: StyleColor;
304
416
  /** …and the logical sides, matching `borderStartWidth`/`borderEndWidth`. */
305
- borderStartColor?: Color;
306
- borderEndColor?: Color;
417
+ borderStartColor?: StyleColor;
418
+ borderEndColor?: StyleColor;
307
419
  /** Rounds the background, the border and the child clip. Requires uniform
308
420
  * borders — same width and colour on all four sides; a non-uniform border
309
421
  * paints square and ignores the radius. */
310
- borderRadius?: number;
422
+ /** …in pixels, or a percentage of the box's shorter side: a corner here is
423
+ * a circle, so `'50%'` is a circle on a square and a pill on anything
424
+ * longer, where CSS would draw each corner as an ellipse. */
425
+ borderRadius?: Pixels | `${number}%`;
311
426
  zIndex?: number;
312
427
  /**
313
428
  * The focus-ring family. Painted *outside* the border box and never seen
@@ -317,10 +432,14 @@ export interface PaintStyle {
317
432
  * A focusable node draws one on `:focus-visible` with no styling at all;
318
433
  * these override it, and `outlineWidth: 0` opts out.
319
434
  */
320
- outlineWidth?: number;
321
- outlineColor?: Color;
435
+ /** CSS's `outline`: a width and a colour — `'2px solid $accent'` — or
436
+ * `'none'`, which is `outlineWidth: 0`, the way a focusable node opts out
437
+ * of its ring. Drawn solid. */
438
+ outline?: Line;
439
+ outlineWidth?: LineWidth;
440
+ outlineColor?: StyleColor;
322
441
  /** The gap between the border box and the ring. Default 1. */
323
- outlineOffset?: number;
442
+ outlineOffset?: Pixels;
324
443
  /**
325
444
  * How opaque the node is **with everything inside it**, from 0 to 1: the
326
445
  * subtree is drawn once and composited at this alpha, so a card, its
@@ -381,9 +500,11 @@ export type FontFeatureSettings =
381
500
 
382
501
  /** Text properties. All affect measurement except `color`. */
383
502
  export interface TextStyle {
384
- color?: Color;
503
+ color?: StyleColor;
385
504
  fontFamily?: string;
386
- fontSize?: number;
505
+ /** A size in pixels or relative units; `em` and a percentage are of the
506
+ * size this node inherits, as in CSS. */
507
+ fontSize?: Pixels | `${number}%`;
387
508
  fontWeight?: FontWeight;
388
509
  fontStyle?: FontStyle;
389
510
  /** A variable font's axes, by OpenType tag: `{ wdth: 87.5, slnt: -8 }`.
@@ -402,7 +523,7 @@ export interface TextStyle {
402
523
  * last on a line included, and negative to tighten. Spaced text drops the
403
524
  * optional ligatures (`liga`, `clig`, `dlig`, `hlig`) unless
404
525
  * `fontFeatureSettings` names them. Inherits. */
405
- letterSpacing?: number;
526
+ letterSpacing?: Pixels;
406
527
  /** Which figures: `'tabular-nums'` gives every digit one width, so a
407
528
  * number that changes holds its width while it does. The friendly names
408
529
  * for features `fontFeatureSettings` can also set by tag, and it wins
@@ -412,7 +533,10 @@ export interface TextStyle {
412
533
  * ignored. Compared by value, so an object literal is fine. Inherits. */
413
534
  fontFeatureSettings?: FontFeatureSettings;
414
535
  textAlign?: TextAlign;
415
- lineHeight?: number;
536
+ /** A multiple of the font's own line height — `1.5`, `'150%'`, `'1.5em'` —
537
+ * or a length, `'24px'` or `'1.5rem'`, taken as that multiple of this
538
+ * node's font size. `'normal'` is the font's own. */
539
+ lineHeight?: number | `${number}` | `${number}%` | Pixels | 'normal';
416
540
  /** CSS's `text-wrap`. `'nowrap'` measures the text at unbounded width, so
417
541
  * it stays on one line and overflows its box horizontally rather than
418
542
  * wrapping to fit — what a fixed-height row wants, since a wrapped line in
@@ -448,7 +572,7 @@ export interface TextStyle {
448
572
 
449
573
  /** What a pseudo-state block may change: paint properties, plus `color`. */
450
574
  export interface StateStyle extends PaintStyle {
451
- color?: Color;
575
+ color?: StyleColor;
452
576
  }
453
577
 
454
578
  /** How far outside the box the pointer still counts as hitting it. A number