@react-x11/components 0.14.1 → 0.16.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.
Files changed (96) hide show
  1. package/dist/code-editor/node.d.ts +13 -0
  2. package/dist/code-editor/node.d.ts.map +1 -1
  3. package/dist/code-editor/node.js +23 -5
  4. package/dist/code-editor/node.js.map +1 -1
  5. package/dist/html/css/cascade.d.ts +171 -26
  6. package/dist/html/css/cascade.d.ts.map +1 -1
  7. package/dist/html/css/cascade.js +616 -216
  8. package/dist/html/css/cascade.js.map +1 -1
  9. package/dist/html/css/color.d.ts +25 -0
  10. package/dist/html/css/color.d.ts.map +1 -1
  11. package/dist/html/css/color.js +307 -19
  12. package/dist/html/css/color.js.map +1 -1
  13. package/dist/html/css/content.d.ts +11 -6
  14. package/dist/html/css/content.d.ts.map +1 -1
  15. package/dist/html/css/content.js +171 -12
  16. package/dist/html/css/content.js.map +1 -1
  17. package/dist/html/css/parse.d.ts.map +1 -1
  18. package/dist/html/css/parse.js +62 -9
  19. package/dist/html/css/parse.js.map +1 -1
  20. package/dist/html/css/shapes.d.ts +18 -0
  21. package/dist/html/css/shapes.d.ts.map +1 -1
  22. package/dist/html/css/shapes.js +21 -1
  23. package/dist/html/css/shapes.js.map +1 -1
  24. package/dist/html/css/style.d.ts +42 -5
  25. package/dist/html/css/style.d.ts.map +1 -1
  26. package/dist/html/css/style.js +74 -12
  27. package/dist/html/css/style.js.map +1 -1
  28. package/dist/html/css/ua.js +15 -0
  29. package/dist/html/css/ua.js.map +1 -1
  30. package/dist/html/css/values.d.ts +5 -0
  31. package/dist/html/css/values.d.ts.map +1 -1
  32. package/dist/html/css/values.js +18 -9
  33. package/dist/html/css/values.js.map +1 -1
  34. package/dist/html/index.d.ts.map +1 -1
  35. package/dist/html/index.js +7 -0
  36. package/dist/html/index.js.map +1 -1
  37. package/dist/html/layout/block.d.ts +29 -9
  38. package/dist/html/layout/block.d.ts.map +1 -1
  39. package/dist/html/layout/block.js +141 -52
  40. package/dist/html/layout/block.js.map +1 -1
  41. package/dist/html/layout/boxes.d.ts +16 -2
  42. package/dist/html/layout/boxes.d.ts.map +1 -1
  43. package/dist/html/layout/boxes.js +144 -23
  44. package/dist/html/layout/boxes.js.map +1 -1
  45. package/dist/html/layout/css-grid.d.ts.map +1 -1
  46. package/dist/html/layout/css-grid.js +11 -9
  47. package/dist/html/layout/css-grid.js.map +1 -1
  48. package/dist/html/layout/flex.d.ts.map +1 -1
  49. package/dist/html/layout/flex.js +1631 -221
  50. package/dist/html/layout/flex.js.map +1 -1
  51. package/dist/html/layout/inline.d.ts +15 -3
  52. package/dist/html/layout/inline.d.ts.map +1 -1
  53. package/dist/html/layout/inline.js +23 -8
  54. package/dist/html/layout/inline.js.map +1 -1
  55. package/dist/html/layout/table.d.ts +27 -1
  56. package/dist/html/layout/table.d.ts.map +1 -1
  57. package/dist/html/layout/table.js +886 -324
  58. package/dist/html/layout/table.js.map +1 -1
  59. package/dist/html/node.d.ts +35 -4
  60. package/dist/html/node.d.ts.map +1 -1
  61. package/dist/html/node.js +118 -26
  62. package/dist/html/node.js.map +1 -1
  63. package/dist/html/paint.d.ts.map +1 -1
  64. package/dist/html/paint.js +558 -178
  65. package/dist/html/paint.js.map +1 -1
  66. package/dist/html/resources.js +14 -1
  67. package/dist/html/resources.js.map +1 -1
  68. package/dist/html/svg.d.ts +23 -7
  69. package/dist/html/svg.d.ts.map +1 -1
  70. package/dist/html/svg.js +264 -59
  71. package/dist/html/svg.js.map +1 -1
  72. package/dist/html/widgets.d.ts.map +1 -1
  73. package/dist/html/widgets.js +57 -4
  74. package/dist/html/widgets.js.map +1 -1
  75. package/package.json +3 -3
  76. package/src/code-editor/node.ts +24 -5
  77. package/src/html/css/cascade.ts +697 -221
  78. package/src/html/css/color.ts +345 -18
  79. package/src/html/css/content.ts +173 -15
  80. package/src/html/css/parse.ts +60 -8
  81. package/src/html/css/shapes.ts +35 -1
  82. package/src/html/css/style.ts +122 -17
  83. package/src/html/css/ua.ts +15 -0
  84. package/src/html/css/values.ts +23 -9
  85. package/src/html/index.ts +7 -0
  86. package/src/html/layout/block.ts +149 -58
  87. package/src/html/layout/boxes.ts +171 -27
  88. package/src/html/layout/css-grid.ts +12 -9
  89. package/src/html/layout/flex.ts +1843 -212
  90. package/src/html/layout/inline.ts +27 -7
  91. package/src/html/layout/table.ts +961 -332
  92. package/src/html/node.ts +151 -27
  93. package/src/html/paint.ts +692 -234
  94. package/src/html/resources.ts +13 -1
  95. package/src/html/svg.ts +299 -56
  96. package/src/html/widgets.ts +61 -4
@@ -14,9 +14,9 @@
14
14
  // correct at every width, which is the whole of the resize story.
15
15
  import { AUTO, alphaOf, fourSides, inkColor, isTransparent, keywordFontSize, parseAlpha, parseColor, isPct, parseLength, parseNumber, parseWeight, resolve, splitCommas, splitValue, } from './values.js';
16
16
  import { parseUrl, readIdent, startsIdent } from './parse.js';
17
- import { DEFAULT_QUOTES, parseContent, parseCounterList, parseListStyleType, parseQuotes, } from './content.js';
17
+ import { parseContent, parseCounterList, parseListStyleType, parseQuotes, } from './content.js';
18
18
  import { parseRotate, parseScale, parseTransform } from './transform.js';
19
- import { LIGHT_DARK, lightDark, usedColorScheme } from './color.js';
19
+ import { LIGHT_DARK, SYSTEM_COLOR, lightDark, systemColors, usedColorScheme, } from './color.js';
20
20
  import { svgPaint } from './shapes.js';
21
21
  /** Whether a length is one `padding` takes: not `auto`, not negative. A
22
22
  * `calc()` with a percentage in it has no sign until layout, which clamps
@@ -206,6 +206,36 @@ export const INHERITED = [
206
206
  'quotes',
207
207
  'custom',
208
208
  ];
209
+ /** Core's focus ring, where a look names none (`DEFAULT_FOCUS_RING`). */
210
+ const FOCUS_RING = { color: '#2980b9', width: 2, offset: 1 };
211
+ /**
212
+ * An `outline-style: auto` as the platform's focus ring: the palette's
213
+ * width and, where the outline's colour is the text's or the keyword's,
214
+ * its colour, the palette's gap outside `outline-offset` — so a field the
215
+ * document draws is ringed as the window's own fields are. A browser
216
+ * draws `auto` in a style of its own the same way, whatever width it was
217
+ * given. `look` is the device one, as every length here is, and `scale`
218
+ * what makes core's defaults device lengths too.
219
+ */
220
+ export function settleOutline(style, look, scale) {
221
+ if (style.outlineStyle !== 'auto')
222
+ return;
223
+ style.outlineWidth = look.focusRingWidth ?? FOCUS_RING.width * scale;
224
+ style.outlineOffset += look.focusRingOffset ?? FOCUS_RING.offset * scale;
225
+ if (style.outlineColor === 'currentColor') {
226
+ style.outlineColor = look.focusRing ?? FOCUS_RING.color;
227
+ }
228
+ }
229
+ /** `-webkit-focus-ring-color`, a colour of an outline's. */
230
+ function outlineColorOf(v, ctx) {
231
+ const lower = v.trim().toLowerCase();
232
+ if (lower === 'invert')
233
+ return 'currentColor';
234
+ if (lower === '-webkit-focus-ring-color') {
235
+ return ctx.focusRing ?? FOCUS_RING.color;
236
+ }
237
+ return parseColor(v);
238
+ }
209
239
  export function initialStyle(look, scale = 1) {
210
240
  // `medium`, in device pixels
211
241
  const medium = BORDER_WIDTH_KEYWORDS.medium * scale;
@@ -259,7 +289,7 @@ export function initialStyle(look, scale = 1) {
259
289
  captionSide: 'top',
260
290
  emptyCells: 'show',
261
291
  tableTextAlignSet: false,
262
- quotes: DEFAULT_QUOTES,
292
+ quotes: 'auto',
263
293
  custom: null,
264
294
  display: 'inline',
265
295
  flowRoot: false,
@@ -397,7 +427,7 @@ export function initialStyle(look, scale = 1) {
397
427
  flexDirection: 'row',
398
428
  flexWrap: 'nowrap',
399
429
  justifyContent: 'normal',
400
- alignItems: 'stretch',
430
+ alignItems: 'normal',
401
431
  alignSelf: 'auto',
402
432
  alignContent: 'stretch',
403
433
  flexGrow: 0,
@@ -581,6 +611,9 @@ export function firstLineParent(parent, onLine) {
581
611
  }
582
612
  // --- applying a declaration -------------------------------------------------
583
613
  /** Longhands that take a colour and nothing else, by property name. */
614
+ /** The properties a colour is written in, alone or in a shorthand, a
615
+ * shadow, a gradient or an image's mask. */
616
+ const TAKES_COLOR = /^(?:color|background|border|outline|box-shadow|text-shadow|text-decoration|text-emphasis|column-rule|fill|stroke|stop-color|flood-color|lighting-color|caret-color|accent-color|scrollbar-color|filter|mask|list-style|-webkit-text-(?:fill|stroke))/;
584
617
  const COLOR_PROPS = {
585
618
  color: 'color',
586
619
  'background-color': 'backgroundColor',
@@ -680,6 +713,11 @@ export function applyDeclaration(style, parent, prop, rawValue, ctx) {
680
713
  if (/!\s*important$/i.test(value)) {
681
714
  value = value.replace(/!\s*important$/i, '').trim();
682
715
  }
716
+ // a system colour is a `light-dark()` of its own, in a property that
717
+ // takes a colour: `Menu` is a font in `font`, and `Mark` a family's name
718
+ if (TAKES_COLOR.test(name) && SYSTEM_COLOR.test(value)) {
719
+ value = systemColors(value, ctx.systemColors);
720
+ }
683
721
  // the branch of each `light-dark()` this element's scheme picks, before
684
722
  // anything reads the value: it stands wherever a colour can, in a
685
723
  // shorthand, a shadow, a gradient or a mix, and most often arrives
@@ -1415,7 +1453,7 @@ export function applyDeclaration(style, parent, prop, rawValue, ctx) {
1415
1453
  width = w;
1416
1454
  continue;
1417
1455
  }
1418
- const c = v === 'invert' ? 'currentColor' : parseColor(part);
1456
+ const c = outlineColorOf(part, ctx);
1419
1457
  if (c === null)
1420
1458
  return;
1421
1459
  color = c;
@@ -1439,8 +1477,7 @@ export function applyDeclaration(style, parent, prop, rawValue, ctx) {
1439
1477
  }
1440
1478
  case 'outline-color': {
1441
1479
  // `invert` is the text's colour where a browser cannot invert
1442
- const v = value.trim().toLowerCase();
1443
- const c = v === 'invert' ? 'currentColor' : parseColor(value);
1480
+ const c = outlineColorOf(value, ctx);
1444
1481
  if (c !== null)
1445
1482
  style.outlineColor = c;
1446
1483
  return;
@@ -2286,14 +2323,17 @@ export function applyDeclaration(style, parent, prop, rawValue, ctx) {
2286
2323
  return;
2287
2324
  }
2288
2325
  case 'align-items': {
2289
- const v = alignKeyword(value);
2326
+ const v = value.trim().toLowerCase() === 'normal'
2327
+ ? 'normal'
2328
+ : alignKeyword(value);
2290
2329
  if (v)
2291
2330
  style.alignItems = v;
2292
2331
  return;
2293
2332
  }
2294
2333
  case 'align-self': {
2295
- if (value.toLowerCase() === 'auto') {
2296
- style.alignSelf = AUTO;
2334
+ const keyword = value.trim().toLowerCase();
2335
+ if (keyword === 'auto' || keyword === 'normal') {
2336
+ style.alignSelf = keyword;
2297
2337
  return;
2298
2338
  }
2299
2339
  const v = alignKeyword(value);
@@ -2303,10 +2343,14 @@ export function applyDeclaration(style, parent, prop, rawValue, ctx) {
2303
2343
  }
2304
2344
  case 'align-content': {
2305
2345
  // `normal` is `stretch` in a flex and a grid container, the only
2306
- // boxes it moves anything in (CSS Box Alignment 3, 5.1)
2346
+ // boxes it moves anything in (CSS Box Alignment 3, 5.1); `start` and
2347
+ // `end` are the box's own edges, and stay those
2348
+ const plain = overflowAligned(value);
2307
2349
  const v = value.trim().toLowerCase() === 'normal'
2308
2350
  ? 'stretch'
2309
- : alignKeyword(value);
2351
+ : plain === 'start' || plain === 'end'
2352
+ ? plain
2353
+ : alignKeyword(value);
2310
2354
  if (v)
2311
2355
  style.alignContent = v;
2312
2356
  return;
@@ -2771,6 +2815,24 @@ export function settleContentVisibility(style) {
2771
2815
  style.contain &= ~CONTAIN_INLINE_SIZE;
2772
2816
  }
2773
2817
  }
2818
+ /**
2819
+ * `align-items: normal` and `align-self: normal`, settled once the cascade
2820
+ * knows what the box and its parent are. In a grid `normal` stretches an
2821
+ * item only where it has neither a natural size nor a ratio, and `stretch`
2822
+ * stretches every item (CSS Grid 1, 6.2; CSS Box Alignment 3, 6.1), so the
2823
+ * grid keeps the two apart; everywhere else `normal` is `stretch`, and a
2824
+ * flex box reads nothing new. Unread, `normal` was dropped, and a grid could
2825
+ * not tell an unset `align-items` from `stretch`: an image under an explicit
2826
+ * `stretch` kept the height its ratio gave it.
2827
+ */
2828
+ export function settleAlign(style, parent) {
2829
+ if (style.alignItems === 'normal' && !style.grid) {
2830
+ style.alignItems = 'stretch';
2831
+ }
2832
+ if (style.alignSelf === 'normal' && !parent?.grid) {
2833
+ style.alignSelf = 'stretch';
2834
+ }
2835
+ }
2774
2836
  export function settleOverflow(style) {
2775
2837
  const x = style.overflowX;
2776
2838
  const y = style.overflowY;