drawnui-react 0.1.0-preview.37 → 0.1.0-preview.38

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 (50) hide show
  1. package/README.md +87 -13
  2. package/SKIPPED.md +6 -6
  3. package/dist/controls/AnimatedFramesRenderer.d.ts +2 -0
  4. package/dist/controls/AnimatedFramesRenderer.js +2 -0
  5. package/dist/controls/DrawnGame.d.ts +5 -1
  6. package/dist/controls/DrawnGame.js +22 -4
  7. package/dist/controls/SkiaCarousel.d.ts +1 -1
  8. package/dist/controls/SkiaCarousel.js +5 -1
  9. package/dist/controls/SkiaDrawer.d.ts +13 -0
  10. package/dist/controls/SkiaDrawer.js +40 -7
  11. package/dist/controls/SkiaEditor.d.ts +3 -1
  12. package/dist/controls/SkiaEditor.js +5 -0
  13. package/dist/controls/SkiaGif.d.ts +4 -0
  14. package/dist/controls/SkiaGif.js +13 -2
  15. package/dist/controls/SkiaImage.d.ts +5 -0
  16. package/dist/controls/SkiaImage.js +33 -4
  17. package/dist/controls/SkiaLabel.d.ts +7 -1
  18. package/dist/controls/SkiaLabel.js +9 -3
  19. package/dist/controls/SkiaLayout.js +3 -1
  20. package/dist/controls/SkiaLottie.js +1 -1
  21. package/dist/controls/SkiaRadioButton.d.ts +2 -0
  22. package/dist/controls/SkiaRadioButton.js +10 -0
  23. package/dist/controls/SkiaScroll.js +18 -9
  24. package/dist/controls/SkiaShaderCarousel.d.ts +6 -1
  25. package/dist/controls/SkiaShaderCarousel.js +17 -5
  26. package/dist/controls/SkiaSprite.d.ts +3 -0
  27. package/dist/controls/SkiaSprite.js +18 -10
  28. package/dist/controls/SkiaSvg.d.ts +4 -0
  29. package/dist/controls/SkiaSvg.js +27 -3
  30. package/dist/controls/SnappingLayout.js +2 -1
  31. package/dist/core/Accessibility.d.ts +26 -2
  32. package/dist/core/Accessibility.js +99 -5
  33. package/dist/core/Canvas.d.ts +34 -3
  34. package/dist/core/Canvas.js +104 -14
  35. package/dist/core/Gestures.d.ts +47 -0
  36. package/dist/core/Gestures.js +93 -0
  37. package/dist/core/ImageEffects.d.ts +2 -0
  38. package/dist/core/ImageEffects.js +2 -0
  39. package/dist/core/KeyboardManager.d.ts +20 -0
  40. package/dist/core/KeyboardManager.js +54 -13
  41. package/dist/core/PopupWindows.d.ts +2 -0
  42. package/dist/core/PopupWindows.js +2 -0
  43. package/dist/core/SkiaControl.d.ts +21 -1
  44. package/dist/core/SkiaControl.js +34 -2
  45. package/dist/react/SkiaShell.js +32 -12
  46. package/dist/react/index.d.ts +1 -0
  47. package/dist/react/index.js +15 -5
  48. package/dist/react/reconciler.d.ts +18 -0
  49. package/dist/react/reconciler.js +31 -1
  50. package/package.json +15 -2
@@ -70,6 +70,11 @@ export declare class CachedObject {
70
70
  * Render(ctx) -> background + Paint(ctx),
71
71
  * ProcessGestures(args, apply) -> consumer or null.
72
72
  */
73
+ /**
74
+ * Controls holding something outside the tree while they are on a canvas (a focused editor's keys and caret timer, a
75
+ * game's keys): the canvas calls their OnLeftCanvas when they leave it with a removed or disposed subtree.
76
+ */
77
+ export declare const CanvasLeaveWatchers: Set<SkiaControl>;
73
78
  export declare class SkiaControl {
74
79
  HorizontalOptions: LayoutOptions;
75
80
  VerticalOptions: LayoutOptions;
@@ -373,6 +378,12 @@ export declare class SkiaControl {
373
378
  */
374
379
  get AccessibilityRole(): string | undefined;
375
380
  set AccessibilityRole(v: string | undefined);
381
+ /**
382
+ * On an arrow-key group (a container with a composite role such as `Aria.RoleMenu` or `Aria.RoleList`): the arrows go
383
+ * round, from the last item to the first and back, instead of stopping at the ends, as in desktop menus. Home / End
384
+ * unchanged. Default false (C# KeyboardWrap, Rust keyboard_wrap).
385
+ */
386
+ KeyboardWrap: boolean;
376
387
  private accessibilityModal;
377
388
  /**
378
389
  * A modal overlay, such as a dialog drawn over the screen (C# AccessibilityModal, drawnui-cross 6av): while it shows,
@@ -420,6 +431,10 @@ export declare class SkiaControl {
420
431
  /** aria-pressed for toggles; undefined = not a toggle. */
421
432
  get AccessibilityIsPressed(): boolean | undefined;
422
433
  set AccessibilityIsPressed(v: boolean | undefined);
434
+ private accessibilityExpanded?;
435
+ /** A control that opens something, such as a menu title: whether it is open now (aria-expanded). Unset: it opens nothing. */
436
+ get AccessibilityExpanded(): boolean | undefined;
437
+ set AccessibilityExpanded(v: boolean | undefined);
423
438
  /** aria-live: `Aria.LivePolite` / `Aria.LiveAssertive`; changes are announced immediately. */
424
439
  get AccessibilityLive(): string | undefined;
425
440
  set AccessibilityLive(v: string | undefined);
@@ -477,6 +492,8 @@ export declare class SkiaControl {
477
492
  private static Align;
478
493
  /** Called after DrawingRect changed; layouts arrange children here. */
479
494
  protected OnLayoutChanged(): void;
495
+ /** A control in CanvasLeaveWatchers left its canvas (removed or disposed): it lets go of what it held there. */
496
+ OnLeftCanvas(): void;
480
497
  /** Part of DrawingRect that can actually be seen: intersected with every ancestor (a scroll's box clips its content). */
481
498
  GetVisibleViewport(): SKRect;
482
499
  /** Draws the control: from its cache when it has one, else background + Paint(); overlays always live. */
@@ -563,7 +580,10 @@ export declare class SkiaControl {
563
580
  CreateGradient(rect: SKRect, g: SkiaGradient): import("canvaskit-wasm").Shader | null;
564
581
  /** C# SkiaGradient.LinearGradientAngleToPoints (CSS angle -> start/end ratios). */
565
582
  static LinearGradientAngleToPoints(direction: number): [number, number, number, number];
566
- /** C# MakeDarker / MakeLighter: HSL lightness scaled down (light < 1) or pushed toward white (light > 1). */
583
+ /**
584
+ * A gradient's Light: below 1 red, green and blue multiplied by Light (C# MakeDarker, as Rust); above 1 the HSL
585
+ * lightness multiplied by Light, clamped to 1, hue and saturation kept (.NET MAUI Color.AddLuminosity, C# f77136c4).
586
+ */
567
587
  static AdjustLightness(rgb: [number, number, number], light: number): [number, number, number];
568
588
  /** Override to draw own content into ctx.Destination. */
569
589
  protected Paint(_ctx: DrawingContext): void;
@@ -92,6 +92,11 @@ export class CachedObject {
92
92
  * Render(ctx) -> background + Paint(ctx),
93
93
  * ProcessGestures(args, apply) -> consumer or null.
94
94
  */
95
+ /**
96
+ * Controls holding something outside the tree while they are on a canvas (a focused editor's keys and caret timer, a
97
+ * game's keys): the canvas calls their OnLeftCanvas when they leave it with a removed or disposed subtree.
98
+ */
99
+ export const CanvasLeaveWatchers = new Set();
95
100
  export class SkiaControl {
96
101
  // ---- layout properties (points) ----
97
102
  HorizontalOptions = "Start";
@@ -618,6 +623,12 @@ export class SkiaControl {
618
623
  this.accessibilityRole = v;
619
624
  this.AccessibilityChanged();
620
625
  } }
626
+ /**
627
+ * On an arrow-key group (a container with a composite role such as `Aria.RoleMenu` or `Aria.RoleList`): the arrows go
628
+ * round, from the last item to the first and back, instead of stopping at the ends, as in desktop menus. Home / End
629
+ * unchanged. Default false (C# KeyboardWrap, Rust keyboard_wrap).
630
+ */
631
+ KeyboardWrap = false;
621
632
  accessibilityModal = false;
622
633
  /**
623
634
  * A modal overlay, such as a dialog drawn over the screen (C# AccessibilityModal, drawnui-cross 6av): while it shows,
@@ -699,6 +710,13 @@ export class SkiaControl {
699
710
  this.accessibilityIsPressed = v;
700
711
  this.AccessibilityChanged();
701
712
  } }
713
+ accessibilityExpanded;
714
+ /** A control that opens something, such as a menu title: whether it is open now (aria-expanded). Unset: it opens nothing. */
715
+ get AccessibilityExpanded() { return this.accessibilityExpanded; }
716
+ set AccessibilityExpanded(v) { if (this.accessibilityExpanded !== v) {
717
+ this.accessibilityExpanded = v;
718
+ this.AccessibilityChanged();
719
+ } }
702
720
  /** aria-live: `Aria.LivePolite` / `Aria.LiveAssertive`; changes are announced immediately. */
703
721
  get AccessibilityLive() { return this.accessibilityLive; }
704
722
  set AccessibilityLive(v) { if (this.accessibilityLive !== v) {
@@ -822,6 +840,8 @@ export class SkiaControl {
822
840
  }
823
841
  /** Called after DrawingRect changed; layouts arrange children here. */
824
842
  OnLayoutChanged() { }
843
+ /** A control in CanvasLeaveWatchers left its canvas (removed or disposed): it lets go of what it held there. */
844
+ OnLeftCanvas() { }
825
845
  /** Part of DrawingRect that can actually be seen: intersected with every ancestor (a scroll's box clips its content). */
826
846
  GetVisibleViewport() {
827
847
  const r = this.DrawingRect;
@@ -1400,9 +1420,16 @@ export class SkiaControl {
1400
1420
  ey = 0;
1401
1421
  return [sx, sy, ex, ey];
1402
1422
  }
1403
- /** C# MakeDarker / MakeLighter: HSL lightness scaled down (light < 1) or pushed toward white (light > 1). */
1423
+ /**
1424
+ * A gradient's Light: below 1 red, green and blue multiplied by Light (C# MakeDarker, as Rust); above 1 the HSL
1425
+ * lightness multiplied by Light, clamped to 1, hue and saturation kept (.NET MAUI Color.AddLuminosity, C# f77136c4).
1426
+ */
1404
1427
  static AdjustLightness(rgb, light) {
1405
1428
  const [r, g, b] = rgb;
1429
+ if (light < 1) {
1430
+ const k = Math.max(0, light);
1431
+ return [r * k, g * k, b * k];
1432
+ }
1406
1433
  const max = Math.max(r, g, b), min = Math.min(r, g, b);
1407
1434
  let h = 0, s = 0;
1408
1435
  let l = (max + min) / 2;
@@ -1417,7 +1444,7 @@ export class SkiaControl {
1417
1444
  h = (r - g) / d + 4;
1418
1445
  h /= 6;
1419
1446
  }
1420
- l = light < 1 ? l * light : l + (1 - l) * (light - 1);
1447
+ l = l * light;
1421
1448
  l = Math.max(0, Math.min(1, l));
1422
1449
  if (s === 0)
1423
1450
  return [l, l, l];
@@ -1442,6 +1469,9 @@ export class SkiaControl {
1442
1469
  Dispose() {
1443
1470
  if (this.IsDisposed)
1444
1471
  return;
1472
+ // disposed while still on a canvas: its subtree's animators stop, once, from the top disposed control
1473
+ if (!this.Parent?.IsDisposed)
1474
+ this.Superview?.ControlLeft(this, true);
1445
1475
  this.IsDisposed = true;
1446
1476
  if (this.accessibilityModal)
1447
1477
  AccessibilityModals.delete(this);
@@ -1451,6 +1481,8 @@ export class SkiaControl {
1451
1481
  this.ownAnimations.clear();
1452
1482
  for (const e of [...this.PostAnimators])
1453
1483
  e.Stop?.();
1484
+ for (const a of [...(this.PendingUnattachedAnimators ?? [])])
1485
+ a.Stop(); // waiting since it was removed: they end with it
1454
1486
  this.PendingUnattachedAnimators = undefined;
1455
1487
  this.PostAnimators.length = 0;
1456
1488
  this.DestroyRenderingObject();
@@ -213,7 +213,10 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
213
213
  const closeWhenBackgroundTapped = options?.closeWhenBackgroundTapped ?? true;
214
214
  const showOverlay = options?.showOverlay ?? true;
215
215
  const overlay = options?.backgroundColor ?? ShellDefaults.PopupBackgroundColor;
216
- entry.node = (_jsxs(SkiaLayer, { VerticalOptions: "Fill", HorizontalOptions: "Fill", ZIndex: ShellDefaults.ZIndexPopups + entry.id, BlockGesturesBelow: true, Opacity: animated ? 0.1 : 1, ref: (c) => { if (c)
216
+ entry.node = (
217
+ // a dialog for screen readers and the keyboard while open (drawnui-cross 6av, C# 2be842b8): its outside-tap close
218
+ // stays, but the wrapper is no Tab stop; the backdrop is no node
219
+ _jsxs(SkiaLayer, { VerticalOptions: "Fill", HorizontalOptions: "Fill", ZIndex: ShellDefaults.ZIndexPopups + entry.id, BlockGesturesBelow: true, Opacity: animated ? 0.1 : 1, AccessibilityModal: true, AccessibilityCanInteract: false, ref: (c) => { if (c)
217
220
  entry.ctrl = c; }, Tapped: (_, e) => {
218
221
  // C# PopupWrapper: a tap outside the content closes it
219
222
  const c = entry.content;
@@ -236,12 +239,28 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
236
239
  await closePopup(p, false); }, [closePopup]);
237
240
  // ---- modals ----
238
241
  const removeModal = useCallback((m) => setModals((list) => list.filter((x) => x !== m)), []);
242
+ /**
243
+ * A modal leaves the modal stack the moment its close starts, whatever started it (PopModalAsync, a swipe, IsOpen =
244
+ * false): ModalsCount and CanGoBack drop it and Navigated Pop is raised; its drawer takes no more pans. It stays on
245
+ * screen until its slide ends (drawnui-cross 6s, C# SkiaShell.LeaveModalStack).
246
+ */
247
+ const [, setStackChanged] = useState(0);
248
+ const leaveModalStack = useCallback((m) => {
249
+ if (m.left)
250
+ return;
251
+ m.left = true;
252
+ if (m.drawer)
253
+ m.drawer.RespondsToGestures = false;
254
+ setStackChanged((t) => t + 1);
255
+ navigated(live.current.stack[live.current.stack.length - 1] ?? "", "Pop");
256
+ }, [navigated]);
239
257
  const popModalNow = useCallback(async (top, animated) => {
240
258
  if (top.closing)
241
259
  return false;
242
260
  if (!canNavigate(live.current.stack[live.current.stack.length - 1] ?? "", "Pop", top.drawer, top.drawer))
243
261
  return false;
244
262
  top.closing = true;
263
+ leaveModalStack(top);
245
264
  if (top.drawer && top.drawer.IsOpen) {
246
265
  top.drawer.Animated = animated;
247
266
  const done = new Promise((r) => { const prev = top.drawer.StateTransitionComplete; top.drawer.StateTransitionComplete = (d, o) => { prev?.(d, o); if (!o)
@@ -251,9 +270,8 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
251
270
  await AnimateWithTimeout(done);
252
271
  }
253
272
  removeModal(top);
254
- navigated(live.current.stack[live.current.stack.length - 1] ?? "", "Pop");
255
273
  return true;
256
- }, [removeModal, canNavigate, navigated]);
274
+ }, [removeModal, canNavigate, leaveModalStack]);
257
275
  const PushModalAsync = useCallback(async (content, options) => {
258
276
  const animated = options?.animated ?? true;
259
277
  if (!canNavigate(live.current.stack[live.current.stack.length - 1] ?? "", "Push"))
@@ -270,8 +288,10 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
270
288
  entry.closing = true;
271
289
  removeModal(entry);
272
290
  } };
273
- entry.node = (_jsxs(SkiaLayer, { VerticalOptions: "Fill", HorizontalOptions: "Fill", ZIndex: ShellDefaults.ZIndexModals + entry.id, BlockGesturesBelow: true, children: [overlay && _jsx(SkiaBackdrop, { Blur: ShellDefaults.PopupsBackgroundBlur, BackgroundColor: overlay, InputTransparent: true }), _jsx(SkiaDrawer, { ref: (d) => { if (d)
274
- entry.drawer = d; }, Direction: "FromBottom", HeaderSize: 0, HorizontalOptions: "Fill", VerticalOptions: "Fill", RespondsToGestures: options?.useGestures ?? false, Animated: animated, Bounces: false, BlockGesturesBelow: true, StateTransitionComplete: (d, isOpen) => { if (isOpen)
291
+ entry.node = (
292
+ // a dialog for screen readers and the keyboard while open (drawnui-cross 6av, C# 2be842b8)
293
+ _jsxs(SkiaLayer, { VerticalOptions: "Fill", HorizontalOptions: "Fill", ZIndex: ShellDefaults.ZIndexModals + entry.id, BlockGesturesBelow: true, AccessibilityModal: true, children: [overlay && _jsx(SkiaBackdrop, { Blur: ShellDefaults.PopupsBackgroundBlur, BackgroundColor: overlay, InputTransparent: true }), _jsx(SkiaDrawer, { ref: (d) => { if (d)
294
+ entry.drawer = d; }, Direction: "FromBottom", HeaderSize: 0, HorizontalOptions: "Fill", VerticalOptions: "Fill", RespondsToGestures: options?.useGestures ?? false, Animated: animated, Bounces: false, BlockGesturesBelow: true, ClosingStarted: () => leaveModalStack(entry), StateTransitionComplete: (d, isOpen) => { if (isOpen)
275
295
  opened();
276
296
  else if (!d.IsOpen)
277
297
  userClosed(); }, IsOpenChanged: (_, isOpen) => { if (!isOpen && !animated)
@@ -288,10 +308,9 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
288
308
  }
289
309
  await AnimateWithTimeout(openedPromise);
290
310
  navigated(live.current.stack[live.current.stack.length - 1] ?? "", "Push", drawer);
291
- }, [removeModal, pushHistory, backThroughHistory, canNavigate, navigated]);
311
+ }, [removeModal, pushHistory, backThroughHistory, canNavigate, navigated, leaveModalStack]);
292
312
  const PopModalAsync = useCallback(async (animated = true) => {
293
- const list = live.current.modals;
294
- const top = list[list.length - 1];
313
+ const top = [...live.current.modals].reverse().find((m) => !m.left); // a modal sliding out has left the stack
295
314
  if (!top || top.closing)
296
315
  return;
297
316
  if (top.history && backThroughHistory("modal")) {
@@ -340,7 +359,7 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
340
359
  await closePopup(ps[ps.length - 1], animated);
341
360
  return;
342
361
  }
343
- if (ms.length) {
362
+ if (ms.some((m) => !m.left)) {
344
363
  await PopModalAsync(animated);
345
364
  return;
346
365
  }
@@ -465,12 +484,13 @@ export const SkiaShell = forwardRef(function SkiaShell({ Routes, children, NavBa
465
484
  window.addEventListener("popstate", onPop);
466
485
  return () => window.removeEventListener("popstate", onPop);
467
486
  }, [historyOn, Routes, closePopupNow, popModalNow, popPage]);
487
+ const inStack = modals.filter((m) => !m.left).length; // modals sliding out have left the stack
468
488
  const nav = useMemo(() => ({
469
- GoToAsync, GoBackAsync, PopToRootAsync, NavigationStack: stack, CanGoBack: stack.length > 0 || popups.length > 0 || modals.length > 0, Route: route, Arguments: { ...SplitRoute(route).args, ...argsInMemory.current.get(route) },
489
+ GoToAsync, GoBackAsync, PopToRootAsync, NavigationStack: stack, CanGoBack: stack.length > 0 || popups.length > 0 || inStack > 0, Route: route, Arguments: { ...SplitRoute(route).args, ...argsInMemory.current.get(route) },
470
490
  OpenPopupAsync, ClosePopupAsync, CloseAllPopups, PushModalAsync, PopModalAsync, ShowToast, CloseAllToasts,
471
- PopupsCount: popups.length, ModalsCount: modals.length, ToastsCount: toasts.length,
491
+ PopupsCount: popups.length, ModalsCount: inStack, ToastsCount: toasts.length,
472
492
  SelectedTab: selectedTab, SelectTabAsync, PopTabToRootAsync,
473
- }), [GoToAsync, GoBackAsync, PopToRootAsync, stack, route, OpenPopupAsync, ClosePopupAsync, CloseAllPopups, PushModalAsync, PopModalAsync, ShowToast, CloseAllToasts, popups.length, modals.length, toasts.length, selectedTab, SelectTabAsync, PopTabToRootAsync]);
493
+ }), [GoToAsync, GoBackAsync, PopToRootAsync, stack, route, OpenPopupAsync, ClosePopupAsync, CloseAllPopups, PushModalAsync, PopModalAsync, ShowToast, CloseAllToasts, popups.length, inStack, toasts.length, selectedTab, SelectTabAsync, PopTabToRootAsync]);
474
494
  useImperativeHandle(ref, () => nav, [nav]);
475
495
  const visiblePages = leaving && !stack.includes(leaving) ? [...stack, leaving] : stack;
476
496
  const topRoute = visiblePages[visiblePages.length - 1] ?? "";
@@ -36,6 +36,7 @@ import { SkiaScroll as SkiaScrollCtrl } from "../controls/SkiaScroll";
36
36
  import type { SkiaShape as SkiaShapeCtrl } from "../controls/SkiaShape";
37
37
  import type { Color, RenderingModeType } from "../core/Types";
38
38
  import type { GesturesMode } from "../core/Gestures";
39
+ export { DesignerSourceOf, type DesignerSource } from "./reconciler";
39
40
  /**
40
41
  * Public settable properties of a control become its JSX props, same PascalCase names as C#.
41
42
  *
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
3
3
  import { SkiaAccessibilityManager } from "../core/Accessibility";
4
+ import { KeyboardManager } from "../core/KeyboardManager";
4
5
  import { TextInputProxy } from "../core/TextInputProxy";
5
6
  import { Canvas as CanvasView } from "../core/Canvas";
6
7
  import { SkiaEditor as SkiaEditorCtrl } from "../controls/SkiaEditor";
7
8
  import { SkiaScroll as SkiaScrollCtrl } from "../controls/SkiaScroll";
8
9
  import { createDrawnRoot } from "./reconciler";
10
+ export { DesignerSourceOf } from "./reconciler";
9
11
  /** Typed JSX tags resolved by the reconciler Registry. */
10
12
  export const SkiaLayout = "SkiaLayout";
11
13
  export const SkiaStack = "SkiaStack";
@@ -173,7 +175,7 @@ function AccessibilityOverlay({ view }) {
173
175
  setNodes(mgr.Snapshot);
174
176
  const off = mgr.OnChanged(() => setNodes(mgr.Snapshot));
175
177
  const offLive = mgr.OnLiveRegionUpdated(() => { mgr.ForceRebuildOnNextFrame(); view.Update(); });
176
- const offFocus = mgr.OnKeyboardFocusRequested((node) => { setNodes(mgr.Snapshot); setFocusRequest({ id: node.AccessibilityId }); });
178
+ const offFocus = mgr.OnKeyboardFocusRequested((node) => { setNodes(mgr.Snapshot); setFocusRequest({ id: node?.AccessibilityId ?? 0 }); });
177
179
  return () => { off(); offLive(); offFocus(); };
178
180
  }, [view]);
179
181
  const elementOf = (id) => overlayRef.current?.querySelector(`[data-a11y-id="${id}"]`) ?? undefined;
@@ -181,7 +183,11 @@ function AccessibilityOverlay({ view }) {
181
183
  if (!focusRequest)
182
184
  return;
183
185
  setFocusRequest(undefined);
184
- elementOf(focusRequest.id)?.focus({ preventScroll: true });
186
+ // no node: the app took the focus away (SetAccessibilityFocus()), the DOM focus goes back to the canvas host
187
+ if (!focusRequest.id)
188
+ overlayRef.current?.parentElement?.focus({ preventScroll: true });
189
+ else
190
+ elementOf(focusRequest.id)?.focus({ preventScroll: true });
185
191
  }, [focusRequest]);
186
192
  // the focused node went away (its page or popup closed): no control keeps the focus and its ring goes with it, the keys
187
193
  // belong to the app again (as in the other engines); the DOM focus stays on the canvas host, so a screen reader is not
@@ -256,10 +262,12 @@ function AccessibilityOverlay({ view }) {
256
262
  return null;
257
263
  const pos = { left: n.Rect.Left, top: n.Rect.Top, width: n.Rect.Width, height: n.Rect.Height };
258
264
  const activate = () => SkiaAccessibilityManager.Activate(n.Source);
259
- return n.CanInteract ? (_jsx("div", { "data-a11y-id": n.Id, role: n.Role, "aria-label": n.Label, title: n.Hint, ...valueAttributes(n), "aria-pressed": n.Role === "button" ? n.IsPressed : undefined, "aria-checked": n.Role === "switch" || n.Role === "checkbox" || n.Role === "radio" ? n.IsPressed : undefined, "aria-live": n.Live, tabIndex: view.AccessibilityManager.IsTabStop(n.Source) ? 0 : -1, className: "drawnui-a11y-node", style: { ...pos, fontSize: 0, userSelect: "none" }, onClick: activate, onKeyDown: (e) => {
265
+ return n.CanInteract ? (_jsx("div", { "data-a11y-id": n.Id, role: n.Role, "aria-label": n.Label, title: n.Hint, ...valueAttributes(n), "aria-pressed": n.Role === "button" ? n.IsPressed : undefined, "aria-expanded": n.Expanded, "aria-haspopup": n.Expanded !== undefined && n.Role === "menuitem" ? "menu" : undefined, "aria-checked": n.Role === "switch" || n.Role === "checkbox" || n.Role === "radio" ? n.IsPressed : undefined, "aria-live": n.Live, tabIndex: view.AccessibilityManager.IsTabStop(n.Source) ? 0 : -1, className: "drawnui-a11y-node", style: { ...pos, fontSize: 0, userSelect: "none" }, onClick: activate, onKeyDown: (e) => {
266
+ // the canvas navigation gets the key first; the app's KeyDown runs after it with IsKeyHandled (6az)
260
267
  if (e.key === "Enter" || e.key === " ") {
261
268
  e.preventDefault();
262
- activate();
269
+ if (activate())
270
+ KeyboardManager.MarkKeyHandled(e.nativeEvent.code);
263
271
  }
264
272
  else if (e.key === "Tab" && view.AccessibilityManager.KeyboardScope) {
265
273
  // an open popup window keeps the keyboard: Tab goes round its stops (a menu is one stop)
@@ -268,8 +276,10 @@ function AccessibilityOverlay({ view }) {
268
276
  if (next)
269
277
  elementOf(next.AccessibilityId)?.focus({ preventScroll: true });
270
278
  }
271
- else if (NAVIGATION_KEYS.has(e.key) && SkiaAccessibilityManager.Key(n.Source, e.key))
279
+ else if (NAVIGATION_KEYS.has(e.key) && SkiaAccessibilityManager.Key(n.Source, e.key)) {
272
280
  e.preventDefault();
281
+ KeyboardManager.MarkKeyHandled(e.nativeEvent.code);
282
+ }
273
283
  }, onFocus: (e) => {
274
284
  focusedId.current = n.Id;
275
285
  pin({ currentTarget: e.currentTarget.parentElement });
@@ -6,6 +6,24 @@ import { TextSpan } from "../controls/TextSpan";
6
6
  type HostInstance = SkiaControl | TextSpan;
7
7
  /** JSX tag name -> engine class. Add a control here to expose it to React. */
8
8
  export declare const Registry: Record<string, new () => HostInstance>;
9
+ /** What DrawnUI Designer reads about the JSX element that created a control (dev builds; undefined in production). */
10
+ export interface DesignerSource {
11
+ /** The React fiber that created the control. */
12
+ Fiber: unknown;
13
+ /** The name of the component that rendered the element (the fiber's owner). */
14
+ Component?: string;
15
+ /** The raw stack captured where the element was created. */
16
+ Stack?: string;
17
+ /** The first app frame of that stack: positions in the served (transformed) module, map them through its source map. */
18
+ File?: string;
19
+ Line?: number;
20
+ Column?: number;
21
+ }
22
+ /**
23
+ * The JSX element that created `control`, for DrawnUI Designer: its fiber, owner component and source position (parsed
24
+ * from the fiber's stack only when asked). Undefined in production builds and for controls made outside React.
25
+ */
26
+ export declare function DesignerSourceOf(control: SkiaControl): DesignerSource | undefined;
9
27
  /** Creates a React root whose container is an engine Canvas. */
10
28
  export declare function createDrawnRoot(canvas: Canvas): {
11
29
  render(children: ReactNode): void;
@@ -76,6 +76,34 @@ function applyProps(inst, prev, next) {
76
76
  else if (repaint && prev)
77
77
  inst.RepaintComposition?.();
78
78
  }
79
+ // DrawnUI Designer, dev builds only: the React fiber that created each control (DesignerSourceOf). Vite replaces
80
+ // import.meta.env.DEV, false in production builds, so the map and its use compile away; without Vite it is undefined
81
+ // and nothing is kept.
82
+ const designerSources = import.meta.env?.DEV ? new WeakMap() : undefined;
83
+ /**
84
+ * The JSX element that created `control`, for DrawnUI Designer: its fiber, owner component and source position (parsed
85
+ * from the fiber's stack only when asked). Undefined in production builds and for controls made outside React.
86
+ */
87
+ export function DesignerSourceOf(control) {
88
+ if (!import.meta.env?.DEV)
89
+ return undefined;
90
+ const fiber = designerSources?.get(control);
91
+ if (!fiber)
92
+ return undefined;
93
+ const owner = fiber._debugOwner?.type;
94
+ const stack = fiber._debugStack?.stack;
95
+ const source = { Fiber: fiber, Component: typeof owner === "string" ? owner : owner?.displayName ?? owner?.name, Stack: stack };
96
+ // React's stack: "Error: react-stack-top-frame", the jsx runtime's own frame, then the frame that wrote the JSX
97
+ // ("at Card (url-or-path:line:col)", or "at url-or-path:line:col" for an anonymous function)
98
+ const frames = stack?.split("\n").filter((l) => /^\s*at /.test(l)) ?? [];
99
+ const m = frames.length > 1 ? /^\s*at (?:.*? \()?(.+?):(\d+):(\d+)\)?\s*$/.exec(frames[1]) : null;
100
+ if (m) {
101
+ source.File = m[1];
102
+ source.Line = Number(m[2]);
103
+ source.Column = Number(m[3]);
104
+ }
105
+ return source;
106
+ }
79
107
  let currentUpdatePriority = DefaultEventPriority;
80
108
  const noop = () => { };
81
109
  const hostContext = {};
@@ -97,7 +125,7 @@ const hostConfig = {
97
125
  cancelTimeout: clearTimeout,
98
126
  supportsMicrotasks: true,
99
127
  scheduleMicrotask: queueMicrotask,
100
- createInstance(type, props) {
128
+ createInstance(type, props, _root, _host, fiber) {
101
129
  const ctor = Registry[type];
102
130
  if (!ctor)
103
131
  throw new Error(`DrawnUi: unknown control <${type}>`);
@@ -105,6 +133,8 @@ const hostConfig = {
105
133
  // ConfigureStyles defaults first, the JSX props below override them (a TextSpan is not a control, it has none)
106
134
  inst.ApplyInitialStyles?.(true);
107
135
  applyProps(inst, null, props);
136
+ if (import.meta.env?.DEV)
137
+ designerSources.set(inst, fiber);
108
138
  return inst;
109
139
  },
110
140
  createTextInstance(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawnui-react",
3
- "version": "0.1.0-preview.37",
3
+ "version": "0.1.0-preview.38",
4
4
  "description": "DrawnUi for React: the DrawnUi (.NET) drawn-UI engine in TypeScript on CanvasKit (Skia WASM). Same controls, same PascalCase API as DrawnUi.Net.",
5
5
  "license": "MIT",
6
6
  "author": "Nick Kovalsky (AppoMobi)",
@@ -92,6 +92,19 @@
92
92
  "check:label-reuse": "node dev/check.mjs dev/check-label-reuse.ts",
93
93
  "check:popups-tooltips": "node dev/check.mjs dev/check-popups-tooltips.ts",
94
94
  "check:carousel-loop": "node dev/check.mjs dev/check-carousel-loop.ts",
95
+ "check:release": "node dev/check.mjs dev/check-release.tsx",
96
+ "check:designer-dev": "node dev/check.mjs dev/check-designer-dev.tsx",
97
+ "check:keyboard-wrap": "node dev/check.mjs dev/check-keyboard-wrap.ts",
98
+ "check:removed": "node dev/check.mjs dev/check-removed.ts",
99
+ "check:key-routing": "node dev/check.mjs dev/check-key-routing.ts",
100
+ "check:drawer-interrupted": "node dev/check.mjs dev/check-drawer-interrupted.ts",
101
+ "check:animated-frames": "node dev/check.mjs dev/check-animated-frames.ts",
102
+ "check:image-features": "node dev/check.mjs dev/check-image-features.ts",
103
+ "check:shader-carousel-interrupted": "node dev/check.mjs dev/check-shader-carousel-interrupted.ts",
104
+ "check:shell-modal": "node dev/check.mjs dev/check-shell-modal.tsx",
105
+ "check:multitouch": "node dev/check.mjs dev/check-multitouch.ts",
106
+ "check:scroll-size": "node dev/check.mjs dev/check-scroll-size.ts",
107
+ "audit:a11y": "node dev/audit-a11y.mjs",
95
108
  "bench:relayout": "node dev/check.mjs dev/bench-relayout.ts",
96
109
  "site:extras": "node dev/site-extras.mjs dist/demo",
97
110
  "build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
@@ -126,6 +139,6 @@
126
139
  "react": "^19.2.0",
127
140
  "react-dom": "^19.2.0",
128
141
  "typescript": "^5.9.0",
129
- "vite": "^7.0.0"
142
+ "vite": "^7.3.7"
130
143
  }
131
144
  }