drawnui-react 0.1.0-preview.41 → 0.1.0-preview.43
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 +89 -7
- package/SKIPPED.md +7 -7
- package/dist/controls/GridStructure.d.ts +9 -1
- package/dist/controls/GridStructure.js +41 -1
- package/dist/controls/SkiaEditor.d.ts +4 -1
- package/dist/controls/SkiaEditor.js +25 -6
- package/dist/controls/SkiaImage.d.ts +5 -0
- package/dist/controls/SkiaImage.js +32 -5
- package/dist/controls/SkiaLabel.d.ts +85 -4
- package/dist/controls/SkiaLabel.js +406 -20
- package/dist/controls/SkiaLabelFps.d.ts +0 -3
- package/dist/controls/SkiaLabelFps.js +1 -11
- package/dist/controls/SkiaLayout.js +33 -2
- package/dist/controls/SkiaScroll.d.ts +51 -2
- package/dist/controls/SkiaScroll.js +150 -9
- package/dist/controls/SkiaShape.d.ts +2 -0
- package/dist/controls/SkiaShape.js +7 -0
- package/dist/controls/SkiaShell.d.ts +282 -0
- package/dist/controls/SkiaShell.js +972 -0
- package/dist/controls/SkiaSprite.js +5 -1
- package/dist/core/Accessibility.d.ts +30 -13
- package/dist/core/Accessibility.js +237 -43
- package/dist/core/Canvas.d.ts +122 -14
- package/dist/core/Canvas.js +585 -47
- package/dist/core/Gestures.d.ts +11 -1
- package/dist/core/Gestures.js +12 -1
- package/dist/core/PopupWindows.js +2 -0
- package/dist/core/Props.d.ts +11 -0
- package/dist/core/Props.js +44 -0
- package/dist/core/ScrollAnimators.d.ts +6 -0
- package/dist/core/ScrollAnimators.js +7 -1
- package/dist/core/SkiaControl.d.ts +24 -4
- package/dist/core/SkiaControl.js +59 -13
- package/dist/core/SkiaEffect.d.ts +12 -1
- package/dist/core/SkiaEffect.js +35 -8
- package/dist/core/SkiaImageManager.d.ts +101 -18
- package/dist/core/SkiaImageManager.js +318 -63
- package/dist/core/Styles.js +7 -1
- package/dist/core/Super.d.ts +4 -0
- package/dist/core/Super.js +4 -9
- package/dist/core/TextInputProxy.d.ts +31 -1
- package/dist/core/TextInputProxy.js +97 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/SkiaShell.d.ts +8 -74
- package/dist/react/SkiaShell.js +163 -514
- package/dist/react/index.d.ts +6 -1
- package/dist/react/index.js +51 -40
- package/dist/react/reconciler.d.ts +12 -0
- package/dist/react/reconciler.js +22 -46
- package/package.json +37 -4
package/dist/react/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { PopupAnchor, PopupId, PopupWindowOptions } from "../core/PopupWind
|
|
|
5
5
|
import type { SKPoint } from "../core/Gestures";
|
|
6
6
|
import type { SKRect } from "../core/Types";
|
|
7
7
|
import type { Thickness, ThicknessValue } from "../core/Types";
|
|
8
|
-
import
|
|
8
|
+
import { SkiaLabel as SkiaLabelCtrl } from "../controls/SkiaLabel";
|
|
9
9
|
import type { TextSpan as TextSpanCtrl } from "../controls/TextSpan";
|
|
10
10
|
import type { SkiaRichLabel as SkiaRichLabelCtrl } from "../controls/SkiaRichLabel";
|
|
11
11
|
import type { SkiaLabelFps as SkiaLabelFpsCtrl } from "../controls/SkiaLabelFps";
|
|
@@ -37,6 +37,8 @@ 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
39
|
export { DesignerSourceOf, type DesignerSource } from "./reconciler";
|
|
40
|
+
/** JSX tag name -> engine class: add-on packages register their controls here. */
|
|
41
|
+
export { Registry } from "./reconciler";
|
|
40
42
|
import { DesignerActions, designerAction } from "../core/DesignerActions";
|
|
41
43
|
export { DesignerActions, designerAction };
|
|
42
44
|
/**
|
|
@@ -65,6 +67,8 @@ export declare function DesignerAction({ Name, onRun }: {
|
|
|
65
67
|
type PropsOf<T> = Partial<{
|
|
66
68
|
[K in keyof T as T[K] extends Function ? (undefined extends T[K] ? K : never) : K extends "Children" | "Views" | "Parent" | "Spans" | "GridStructure" | "AccessibilityId" | "IsAccessibilityElement" | "HasTransform" | "RenderTransformMatrix" | "RenderObjectPrevious" | "LastMeasuredIndex" | "ItemsInsertedAtStart" | "UsingControlStyle" | "Track" | "Thumb" | "FrameOn" | "FrameOff" | "ViewCheckOn" | "ViewOn" | "ViewText" | "Ratio" | "StartThumbX" | "EndThumbX" | "SnapPoints" | "CurrentPosition" | "CurrentSnap" | "ContentOffsetBounds" | "InTransition" | "CanAnimate" | "MaxIndex" | "ChildrenTotal" | "IsAtStart" | "IsAtEnd" | "ScrollProgress" | "ScrollAmount" | "TransitionProgress" | "LastIndex" | "ChildrenCount" | "Horizontal" | "Animator" | "Animation" | "IsPlaying" | "PlayWhenAvailable" | "TotalFrames" | "HasEffects" | "IsDisposed" | "Label" | "IsMultiline" | "HasSelection" | "LayoutVersion" | "LinesCount" | "MeasuredLineHeight" | "Focused" | "SpriteSheet" | "FrameWidth" | "FrameHeight" | "DurationMs" | "FrameDurationMs" | "CurrentSprite" | "Rects" | "HasTapHandler" | "HasDecorations" | "LinesCount" | "Superview" | "DrawingRect" | "MeasuredSize" | "RenderingScale" | "NeedMeasure" | "_superview" | "HitBoxAuto" | "TotalDown" | "TotalTapped" | "TouchDown" | "PostAnimators" | "LoadedSource" | "IsLoading" | "DisplayRect" | "AspectScale" | "Content" | "ContentSize" | "ContentOffsetBounds" | "OverscrollDistance" | "OverScrolled" | "IsUserPanning" | "IsUserFocused" | "IsScrolling" | "IsTemplated" | "FirstVisibleIndex" | "LastVisibleIndex" | "DebugString" | "ChildrenFactory" | "ContextIndex" | "RenderObject" | "UsingCacheType" | "TransitionEffect" | "TransitionFromIndex" | "TransitionToIndex" | "EffectPostRenderers" | "CachedImage" | "ImageBitmap" | "ShouldSubmitOnEnter" | "Header" | "Footer" | "RefreshIndicator" | "ScrollBar" | "ScrollBarHorizontal" | "IsRunning" | "VisibleRatio" | "CurrentIndex" | "LastCompositeRecord" | "DirtyChildrenInternal" | "IsRenderingWithComposition" | "IsHovered" ? never : K]: T[K] extends Thickness ? ThicknessValue : T[K];
|
|
67
69
|
}>;
|
|
70
|
+
/** The JSX props of an engine control class (for add-on packages that declare their own tags). */
|
|
71
|
+
export type DrawnProps<T> = PropsOf<T>;
|
|
68
72
|
/** `ref` receives the engine control instance (react-reconciler getPublicInstance). */
|
|
69
73
|
type LeafProps<T> = PropsOf<T> & {
|
|
70
74
|
ref?: Ref<T>;
|
|
@@ -165,3 +169,4 @@ export declare function Canvas({ BackgroundColor, RenderingMode, Gestures, Arrow
|
|
|
165
169
|
export type { SkiaControl };
|
|
166
170
|
export * from "../index";
|
|
167
171
|
export * from "./SkiaShell";
|
|
172
|
+
export { SkiaShell } from "./SkiaShell";
|
package/dist/react/index.js
CHANGED
|
@@ -8,6 +8,8 @@ import { SkiaEditor as SkiaEditorCtrl } from "../controls/SkiaEditor";
|
|
|
8
8
|
import { SkiaScroll as SkiaScrollCtrl } from "../controls/SkiaScroll";
|
|
9
9
|
import { createDrawnRoot } from "./reconciler";
|
|
10
10
|
export { DesignerSourceOf } from "./reconciler";
|
|
11
|
+
/** JSX tag name -> engine class: add-on packages register their controls here. */
|
|
12
|
+
export { Registry } from "./reconciler";
|
|
11
13
|
import { DesignerActions, designerAction } from "../core/DesignerActions";
|
|
12
14
|
export { DesignerActions, designerAction };
|
|
13
15
|
/**
|
|
@@ -169,11 +171,17 @@ const A11Y_CSS = `
|
|
|
169
171
|
.drawnui-a11y-node::selection,.drawnui-a11y-node *::selection{background:transparent;color:transparent}
|
|
170
172
|
.drawnui-a11y-node:focus{outline:none}
|
|
171
173
|
.drawnui-a11y-node:focus-visible{outline:3px solid rgba(13,110,253,.85);outline-offset:1px;border-radius:3px}
|
|
172
|
-
.drawnui-a11y-text{overflow:visible}
|
|
173
|
-
.drawnui-a11y-text>span{position:absolute;white-space:pre;color:transparent;user-select:text;-webkit-user-select:text;pointer-events:auto;cursor:text;line-height:1;font-kerning:none;font-feature-settings:"kern" 0,"liga" 0,"calt" 0;text-rendering:geometricPrecision}
|
|
174
|
-
.drawnui-a11y-text>span::selection{background:rgba(110,168,254,.55);color:transparent}
|
|
175
174
|
`;
|
|
176
175
|
const NAVIGATION_KEYS = new Set(["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown"]);
|
|
176
|
+
/** The layer a control lives in: its top ancestor (the canvas content for the page, a popup window's root). */
|
|
177
|
+
function LayerOf(control) {
|
|
178
|
+
let c = control;
|
|
179
|
+
while (c.Parent)
|
|
180
|
+
c = c.Parent;
|
|
181
|
+
return c;
|
|
182
|
+
}
|
|
183
|
+
/** How long a scroll bringing the keyboard's control into view takes, seconds. */
|
|
184
|
+
const KeyboardScrollSecs = 0.25;
|
|
177
185
|
/**
|
|
178
186
|
* Invisible ARIA elements mirroring the accessible drawn controls, positioned over the canvas (the DrawnUi.Blazor
|
|
179
187
|
* overlay). Improvement over DrawnUi.Blazor: `pointer-events:none`, so hover and every pointer gesture still reach the
|
|
@@ -216,16 +224,40 @@ function AccessibilityOverlay({ view }) {
|
|
|
216
224
|
// belong to the app again (as in the other engines); the DOM focus stays on the canvas host, so a screen reader is not
|
|
217
225
|
// thrown to the top of the page and the next Tab starts from the canvas. A focus the user moved away stays away.
|
|
218
226
|
const focusedId = useRef(0);
|
|
227
|
+
/** The layer the focused node lives in: the page (the canvas content) or a popup window (its root). */
|
|
228
|
+
const focusedLayer = useRef(undefined);
|
|
229
|
+
const previousNodes = useRef(nodes);
|
|
219
230
|
useLayoutEffect(() => {
|
|
231
|
+
const previous = previousNodes.current;
|
|
232
|
+
previousNodes.current = nodes;
|
|
220
233
|
const id = focusedId.current;
|
|
221
234
|
if (!id || nodes.some((n) => n.Id === id))
|
|
222
235
|
return;
|
|
223
236
|
focusedId.current = 0;
|
|
224
|
-
|
|
225
|
-
|
|
237
|
+
const mgr = view.AccessibilityManager;
|
|
238
|
+
if (mgr.FocusedNode?.AccessibilityId === id)
|
|
239
|
+
mgr.NotifyFocused(undefined);
|
|
226
240
|
const active = document.activeElement;
|
|
227
241
|
if (active && active !== document.body)
|
|
228
242
|
return;
|
|
243
|
+
// its control went away (hidden, removed, no longer taking input: a pin turned to the far side of a globe): the
|
|
244
|
+
// keyboard goes on to the next stop, or the one before it at the end, never to nothing (DrawnUi.Net KeyboardTabScrollTests).
|
|
245
|
+
// A node only scrolled far away keeps no focus here (moving it would scroll the page back).
|
|
246
|
+
// The next stop stays in the layer the control lived in; a popup window that closed (its item chosen) takes its layer
|
|
247
|
+
// with it and the keyboard goes to nothing, never to a page control (that would scroll the page to it).
|
|
248
|
+
const at = previous.findIndex((n) => n.Id === id), gone = at >= 0 ? previous[at].Source : undefined;
|
|
249
|
+
const layer = focusedLayer.current;
|
|
250
|
+
if (gone && layer && nodes.some((n) => LayerOf(n.Source) === layer)
|
|
251
|
+
&& (gone.IsDisposed || !gone.Superview || gone.HiddenInTree() || gone.Opacity <= 0 || !gone.AccessibilityCanInteract)) {
|
|
252
|
+
const alive = new Set(nodes.map((n) => n.Id));
|
|
253
|
+
const stop = (n) => alive.has(n.Id) && n.CanInteract && mgr.IsTabStop(n.Source) && LayerOf(n.Source) === layer;
|
|
254
|
+
const next = previous.slice(at + 1).find(stop) ?? previous.slice(0, at).reverse().find(stop);
|
|
255
|
+
const el = next && elementOf(next.Id);
|
|
256
|
+
if (el) {
|
|
257
|
+
el.focus({ preventScroll: true });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
229
261
|
overlayRef.current?.parentElement?.focus({ preventScroll: true });
|
|
230
262
|
}, [nodes]);
|
|
231
263
|
// Tab / Shift+Tab in a text field leave it for the next node, also after a click into it: DOM focus goes to the
|
|
@@ -245,43 +277,18 @@ function AccessibilityOverlay({ view }) {
|
|
|
245
277
|
document.addEventListener("keydown", onKey, true);
|
|
246
278
|
return () => document.removeEventListener("keydown", onKey, true);
|
|
247
279
|
}, [view]);
|
|
248
|
-
// selectable text spans take pointer events: the wheel over them is re-dispatched to the canvas so drawn scrolls keep working
|
|
249
280
|
const overlayRef = useRef(null);
|
|
250
|
-
|
|
251
|
-
useEffect(() => {
|
|
252
|
-
const el = overlayRef.current;
|
|
253
|
-
if (!el)
|
|
254
|
-
return;
|
|
255
|
-
const forward = (e) => { e.preventDefault(); view.Element.dispatchEvent(new WheelEvent("wheel", { deltaX: e.deltaX, deltaY: e.deltaY, deltaMode: e.deltaMode, clientX: e.clientX, clientY: e.clientY, ctrlKey: e.ctrlKey, shiftKey: e.shiftKey, bubbles: false, cancelable: true })); };
|
|
256
|
-
el.addEventListener("wheel", forward, { passive: false });
|
|
257
|
-
return () => el.removeEventListener("wheel", forward);
|
|
258
|
-
}, [view, hasNodes]);
|
|
259
|
-
// the browser lays the invisible lines out with its own shaping; stretch each line with letter-spacing to the drawn width
|
|
260
|
-
// so the selection highlight covers the drawn glyphs end to end
|
|
261
|
-
useLayoutEffect(() => {
|
|
262
|
-
const el = overlayRef.current;
|
|
263
|
-
if (!el)
|
|
264
|
-
return;
|
|
265
|
-
for (const span of el.querySelectorAll(".drawnui-a11y-text>span")) {
|
|
266
|
-
const want = parseFloat(span.dataset.w ?? "0"), n = (span.textContent ?? "").replace(/\n$/, "").length - 1;
|
|
267
|
-
span.style.letterSpacing = "0px";
|
|
268
|
-
if (want <= 0 || n <= 0)
|
|
269
|
-
continue;
|
|
270
|
-
const have = span.getBoundingClientRect().width;
|
|
271
|
-
if (Math.abs(have - want) > 0.5)
|
|
272
|
-
span.style.letterSpacing = `${(want - have) / n}px`;
|
|
273
|
-
}
|
|
274
|
-
}, [nodes]);
|
|
275
|
-
if (!hasNodes)
|
|
281
|
+
if (nodes.length === 0)
|
|
276
282
|
return null;
|
|
277
283
|
// the browser scrolls an overflow:hidden container to reveal a focused child; the overlay must stay pinned to the canvas
|
|
278
284
|
const pin = (e) => { e.currentTarget.scrollTop = 0; e.currentTarget.scrollLeft = 0; };
|
|
279
285
|
// an active modal (drawnui-cross 6av): the overlay itself is the dialog (role, name, aria-modal) around the dialog's
|
|
280
|
-
// controls, which are its elements; aria-modal on a separate element of this flat overlay would hide them
|
|
286
|
+
// controls, which are its elements; aria-modal on a separate element of this flat overlay would hide them. A nameless
|
|
287
|
+
// modal (a popup host) takes the role and name of the dialog inside it: one dialog for readers (6bs)
|
|
281
288
|
const modal = view.AccessibilityManager.ActiveModal;
|
|
282
|
-
const modalNode = modal ?
|
|
289
|
+
const modalNode = modal ? view.AccessibilityManager.ActiveModalNode : undefined;
|
|
283
290
|
return (_jsxs("div", { className: "drawnui-a11y-overlay", onScroll: pin, ref: overlayRef, role: modal ? modalNode?.Role ?? "dialog" : undefined, "aria-label": modalNode?.Label, "aria-modal": modal ? true : undefined, children: [_jsx("style", { children: A11Y_CSS }), nodes.map((n) => {
|
|
284
|
-
if (n === modalNode)
|
|
291
|
+
if (n === modalNode || (modal && n.Source === modal))
|
|
285
292
|
return null;
|
|
286
293
|
const pos = { left: n.Rect.Left, top: n.Rect.Top, width: n.Rect.Width, height: n.Rect.Height };
|
|
287
294
|
const activate = () => SkiaAccessibilityManager.Activate(n.Source);
|
|
@@ -300,14 +307,19 @@ function AccessibilityOverlay({ view }) {
|
|
|
300
307
|
if (next)
|
|
301
308
|
elementOf(next.AccessibilityId)?.focus({ preventScroll: true });
|
|
302
309
|
}
|
|
310
|
+
// a list whose cells are made on demand: Tab goes on to the next item, scrolling it in (ac70a1d9)
|
|
311
|
+
else if (e.key === "Tab" && view.AccessibilityManager.TabThroughList(n.Source, !e.shiftKey))
|
|
312
|
+
e.preventDefault();
|
|
303
313
|
else if (NAVIGATION_KEYS.has(e.key) && SkiaAccessibilityManager.Key(n.Source, e.key)) {
|
|
304
314
|
e.preventDefault();
|
|
305
315
|
KeyboardManager.MarkKeyHandled(e.nativeEvent.code);
|
|
306
316
|
}
|
|
307
317
|
}, onFocus: (e) => {
|
|
308
318
|
focusedId.current = n.Id;
|
|
319
|
+
focusedLayer.current = LayerOf(n.Source);
|
|
309
320
|
pin({ currentTarget: e.currentTarget.parentElement });
|
|
310
|
-
|
|
321
|
+
// inside every enclosing scroll; the overlay follows that scroll, so the next Tab finds the controls it brings in
|
|
322
|
+
view.AccessibilityManager.FollowScroll(SkiaScrollCtrl.EnsureVisible(n.Source, KeyboardScrollSecs));
|
|
311
323
|
if (tabbingOut.current === n.Id)
|
|
312
324
|
tabbingOut.current = 0; // leaving a text field: it keeps no caret
|
|
313
325
|
else
|
|
@@ -321,9 +333,7 @@ function AccessibilityOverlay({ view }) {
|
|
|
321
333
|
return; // a text field moved DOM focus to its own input
|
|
322
334
|
n.Source.OnAccessibilityFocused(false);
|
|
323
335
|
n.Source.NotifyAccessibilityFocused(false);
|
|
324
|
-
}, children: n.Label }, n.Id)) :
|
|
325
|
-
// AccessibilityTextSelectable: one positioned span per drawn line, in the drawn font, so the browser selects and copies it like HTML
|
|
326
|
-
_jsx("div", { role: n.Role, title: n.Hint, "aria-disabled": n.Disabled || undefined, "aria-live": n.Live, className: "drawnui-a11y-node drawnui-a11y-text", style: pos, children: n.TextLines.map((l, i) => (_jsxs("span", { "data-w": l.Width, style: { left: l.Left, top: l.Top, height: l.Height, fontFamily: l.FontFamily, fontWeight: l.FontWeight, fontSize: l.FontSize, lineHeight: `${l.Height}px` }, children: [l.Text, i < n.TextLines.length - 1 ? "\n" : ""] }, i))) }, n.Id)) : (
|
|
336
|
+
}, children: n.Label }, n.Id)) : (
|
|
327
337
|
// static text is exposed as real (transparent) text content; aria-label only for roles that need a name
|
|
328
338
|
_jsx("div", { role: n.Role, "aria-label": n.Role === "text" ? undefined : n.Label, title: n.Hint, ...valueAttributes(n), "aria-disabled": n.Disabled || undefined, "aria-live": n.Live, className: "drawnui-a11y-node", style: pos, children: n.Label }, n.Id));
|
|
329
339
|
})] }));
|
|
@@ -331,5 +341,6 @@ function AccessibilityOverlay({ view }) {
|
|
|
331
341
|
// One import for apps: React tags + every engine type (Colors, Thickness, Super, gestures, animators...).
|
|
332
342
|
// The engine `Canvas` class is shadowed by the React <Canvas> above; reach it via "drawnui-react/core".
|
|
333
343
|
export * from "../index";
|
|
334
|
-
//
|
|
344
|
+
// SkiaShell with JSX pages, popups and modals (useShell()); the engine SkiaShell is in "drawnui-react/core"
|
|
335
345
|
export * from "./SkiaShell";
|
|
346
|
+
export { SkiaShell } from "./SkiaShell";
|
|
@@ -24,6 +24,18 @@ export interface DesignerSource {
|
|
|
24
24
|
* from the fiber's stack only when asked). Undefined in production builds and for controls made outside React.
|
|
25
25
|
*/
|
|
26
26
|
export declare function DesignerSourceOf(control: SkiaControl): DesignerSource | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* A portal target other than the canvas: JSX rendered into a place an engine control made for it (the shell's pages,
|
|
29
|
+
* popups, modals). Its top-level controls are handed to it in order.
|
|
30
|
+
*/
|
|
31
|
+
export interface DrawnContainer {
|
|
32
|
+
appendChild(child: SkiaControl): void;
|
|
33
|
+
insertBefore(child: SkiaControl, before: SkiaControl): void;
|
|
34
|
+
removeChild(child: SkiaControl): void;
|
|
35
|
+
clear(): void;
|
|
36
|
+
}
|
|
37
|
+
/** Renders `children` into `container` from inside another React tree (contexts reach it), as react-dom createPortal. */
|
|
38
|
+
export declare function createDrawnPortal(children: ReactNode, container: DrawnContainer, key?: string): ReactNode;
|
|
27
39
|
/** Creates a React root whose container is an engine Canvas. */
|
|
28
40
|
export declare function createDrawnRoot(canvas: Canvas): {
|
|
29
41
|
render(children: ReactNode): void;
|
package/dist/react/reconciler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
2
|
import Reconciler from "react-reconciler";
|
|
3
3
|
import { ConcurrentRoot, DefaultEventPriority } from "react-reconciler/constants";
|
|
4
|
-
import {
|
|
4
|
+
import { ApplyProps as applyProps } from "../core/Props";
|
|
5
5
|
import { SkiaLabel } from "../controls/SkiaLabel";
|
|
6
6
|
import { TextSpan } from "../controls/TextSpan";
|
|
7
7
|
import { SkiaRichLabel } from "../controls/SkiaRichLabel";
|
|
@@ -36,46 +36,6 @@ export const Registry = {
|
|
|
36
36
|
SkiaLayout, SkiaStack, SkiaRow, SkiaLayer, SkiaWrap, SkiaMasonry, SkiaGrid, SkiaDecoratedGrid, SkiaBackdrop, SkiaEditor, SkiaSprite, SkiaSpriteSet, SkiaLabel, SkiaLabelFps, SkiaRichLabel, TextSpan, SkiaHotspot, SkiaButton, SkiaImage, SkiaImageTiles, SkiaSvg, SkiaLottie, SkiaGif, SkiaScroll, SkiaScrollBar, RefreshIndicator, SkiaShape, SkiaFrame,
|
|
37
37
|
SkiaSwitch, SkiaCheckbox, SkiaRadioButton, SkiaProgress, SkiaSlider, SkiaCarousel, SkiaShaderCarousel, SkiaDrawer,
|
|
38
38
|
};
|
|
39
|
-
const SKIP = new Set(["children", "key", "ref"]);
|
|
40
|
-
/** Props that change how the subtree is composited, not what it contains: repaint, keep caches (DrawnUi RedrawCanvas). */
|
|
41
|
-
const REPAINT_ONLY = new Set(["TranslationX", "TranslationY", "TranslationZ", "Rotation", "RotationX", "RotationY", "RotationZ", "ScaleX", "ScaleY", "Scale", "SkewX", "SkewY", "AnchorX", "AnchorY", "Opacity"]);
|
|
42
|
-
/** Props that change only how a control looks, never its size (C# NeedDraw): an ImageComposite above redraws only its area. */
|
|
43
|
-
const isDrawOnly = (k) => k.endsWith("Color") || k === "FillGradient" || k === "StrokeGradient";
|
|
44
|
-
/**
|
|
45
|
-
* Assigns changed props straight onto the control (same names as the C# properties).
|
|
46
|
-
* Handler props (functions) are swapped without invalidating: inline arrows change identity every render.
|
|
47
|
-
*/
|
|
48
|
-
function applyProps(inst, prev, next) {
|
|
49
|
-
let changed = false, repaint = false, layout = false;
|
|
50
|
-
for (const k in next) {
|
|
51
|
-
if (SKIP.has(k) || (prev && prev[k] === next[k]))
|
|
52
|
-
continue;
|
|
53
|
-
inst[k] = next[k];
|
|
54
|
-
if (typeof next[k] === "function")
|
|
55
|
-
continue;
|
|
56
|
-
if (REPAINT_ONLY.has(k))
|
|
57
|
-
repaint = true;
|
|
58
|
-
else {
|
|
59
|
-
changed = true;
|
|
60
|
-
if (!isDrawOnly(k))
|
|
61
|
-
layout = true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (prev)
|
|
65
|
-
for (const k in prev)
|
|
66
|
-
if (!SKIP.has(k) && !(k in next)) {
|
|
67
|
-
inst[k] = new inst.constructor()[k];
|
|
68
|
-
changed = layout = true;
|
|
69
|
-
}
|
|
70
|
-
if (changed && prev) {
|
|
71
|
-
if (layout || !(inst instanceof SkiaControl))
|
|
72
|
-
inst.Update();
|
|
73
|
-
else
|
|
74
|
-
inst.UpdateDraw();
|
|
75
|
-
}
|
|
76
|
-
else if (repaint && prev)
|
|
77
|
-
inst.RepaintComposition?.();
|
|
78
|
-
}
|
|
79
39
|
// DrawnUI Designer, dev builds only: the React fiber that created each control (DesignerSourceOf). Vite replaces
|
|
80
40
|
// import.meta.env.DEV, false in production builds, so the map and its use compile away; without Vite it is undefined
|
|
81
41
|
// and nothing is kept.
|
|
@@ -113,6 +73,7 @@ function appendChild(parent, child) {
|
|
|
113
73
|
child.IsChildrenItem = true;
|
|
114
74
|
parent.AddSubView(child);
|
|
115
75
|
}
|
|
76
|
+
const IsDrawnContainer = (c) => typeof c.appendChild === "function";
|
|
116
77
|
// Record<string, unknown> absorbs members that react-reconciler 0.33 reads but @types 0.32 does not declare yet.
|
|
117
78
|
const hostConfig = {
|
|
118
79
|
supportsMutation: true,
|
|
@@ -151,11 +112,22 @@ const hostConfig = {
|
|
|
151
112
|
parent.InsertSubView(parent instanceof SkiaLabel ? parent.Spans.indexOf(before) : 0, child);
|
|
152
113
|
},
|
|
153
114
|
removeChild: (parent, child) => parent.RemoveSubView(child),
|
|
154
|
-
appendChildToContainer: (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
115
|
+
appendChildToContainer: (c, child) => { if (IsDrawnContainer(c))
|
|
116
|
+
c.appendChild(child);
|
|
117
|
+
else
|
|
118
|
+
c.Content = child; },
|
|
119
|
+
insertInContainerBefore: (c, child, before) => { if (IsDrawnContainer(c))
|
|
120
|
+
c.insertBefore(child, before);
|
|
121
|
+
else
|
|
122
|
+
c.Content = child; },
|
|
123
|
+
removeChildFromContainer: (c, child) => { if (IsDrawnContainer(c))
|
|
124
|
+
c.removeChild(child);
|
|
125
|
+
else if (c.Content === child)
|
|
126
|
+
c.Content = undefined; },
|
|
127
|
+
clearContainer: (c) => { if (IsDrawnContainer(c))
|
|
128
|
+
c.clear();
|
|
129
|
+
else
|
|
130
|
+
c.Content = undefined; },
|
|
159
131
|
commitUpdate: (inst, _type, prev, next) => applyProps(inst, prev, next),
|
|
160
132
|
commitTextUpdate: noop,
|
|
161
133
|
commitMount: noop,
|
|
@@ -202,6 +174,10 @@ const hostConfig = {
|
|
|
202
174
|
};
|
|
203
175
|
const reconciler = Reconciler(hostConfig);
|
|
204
176
|
const onError = (e) => console.error("DrawnUi.React:", e);
|
|
177
|
+
/** Renders `children` into `container` from inside another React tree (contexts reach it), as react-dom createPortal. */
|
|
178
|
+
export function createDrawnPortal(children, container, key) {
|
|
179
|
+
return reconciler.createPortal(children, container, null, key);
|
|
180
|
+
}
|
|
205
181
|
/** Creates a React root whose container is an engine Canvas. */
|
|
206
182
|
export function createDrawnRoot(canvas) {
|
|
207
183
|
const container = reconciler.createContainer(canvas, ConcurrentRoot, null, false, null, "", onError, onError, onError, noop, null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drawnui-react",
|
|
3
|
-
"version": "0.1.0-preview.
|
|
3
|
+
"version": "0.1.0-preview.43",
|
|
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)",
|
|
@@ -65,19 +65,23 @@
|
|
|
65
65
|
"check:animation": "node dev/check.mjs dev/check-animation.ts",
|
|
66
66
|
"check:shape": "node dev/check.mjs dev/check-shape.ts",
|
|
67
67
|
"check:label": "node dev/check.mjs dev/check-label.ts",
|
|
68
|
+
"check:label-baseline": "node dev/check.mjs dev/check-label-baseline.ts",
|
|
68
69
|
"check:image": "node dev/check.mjs dev/check-image.ts",
|
|
69
70
|
"check:longpress": "node dev/check.mjs dev/check-longpress.ts",
|
|
70
71
|
"check:hidden": "node dev/check.mjs dev/check-hidden.ts",
|
|
71
72
|
"check:shell": "node dev/check.mjs dev/check-shell.tsx",
|
|
73
|
+
"check:shell-core": "node dev/check.mjs dev/check-shell-core.ts",
|
|
72
74
|
"check:wheel-routing": "node dev/check.mjs dev/check-wheel-routing.ts",
|
|
73
75
|
"check:velocity": "node dev/check.mjs dev/check-velocity.ts",
|
|
74
76
|
"check:scroll-index": "node dev/check.mjs dev/check-scroll-index.ts",
|
|
77
|
+
"check:scroll-chaining": "node dev/check.mjs dev/check-scroll-chaining.ts",
|
|
75
78
|
"check:culling": "node dev/check.mjs dev/check-culling.ts",
|
|
76
79
|
"check:responds": "node dev/check.mjs dev/check-responds.ts",
|
|
77
80
|
"check:3d": "node dev/check.mjs dev/check-3d.ts",
|
|
78
81
|
"check:gesture-owner": "node dev/check.mjs dev/check-gesture-owner.ts",
|
|
79
82
|
"check:shader-cache": "node dev/check.mjs dev/check-shader-cache.ts",
|
|
80
83
|
"check:shader-content": "node dev/check.mjs dev/check-shader-content.ts",
|
|
84
|
+
"check:shader-time": "node dev/check.mjs dev/check-shader-time.ts",
|
|
81
85
|
"check:backdrop": "node dev/check.mjs dev/check-backdrop.ts",
|
|
82
86
|
"check:masonry": "node dev/check.mjs dev/check-masonry.ts",
|
|
83
87
|
"check:thickness": "node dev/check.mjs dev/check-thickness.ts",
|
|
@@ -85,11 +89,13 @@
|
|
|
85
89
|
"check:masonry-keys": "node dev/check.mjs dev/check-masonry-keys.ts",
|
|
86
90
|
"check:carousel-swipe": "node dev/check.mjs dev/check-carousel-swipe.ts",
|
|
87
91
|
"check:editor-focus": "node dev/check.mjs dev/check-editor-focus.ts",
|
|
92
|
+
"check:editor-lines": "node dev/check.mjs dev/check-editor-lines.ts",
|
|
88
93
|
"check:shaping": "node dev/check.mjs dev/check-shaping.ts",
|
|
89
94
|
"check:editor-rtl": "node dev/check.mjs dev/check-editor-rtl.ts",
|
|
90
95
|
"check:label-direction": "node dev/check.mjs dev/check-label-direction.ts",
|
|
91
96
|
"check:stack-fit": "node dev/check.mjs dev/check-stack-fit.ts",
|
|
92
97
|
"check:label-reuse": "node dev/check.mjs dev/check-label-reuse.ts",
|
|
98
|
+
"check:layout-rules": "node dev/check.mjs dev/check-layout-rules.ts",
|
|
93
99
|
"check:popups-tooltips": "node dev/check.mjs dev/check-popups-tooltips.ts",
|
|
94
100
|
"check:carousel-loop": "node dev/check.mjs dev/check-carousel-loop.ts",
|
|
95
101
|
"check:release": "node dev/check.mjs dev/check-release.tsx",
|
|
@@ -103,6 +109,7 @@
|
|
|
103
109
|
"check:shader-carousel-interrupted": "node dev/check.mjs dev/check-shader-carousel-interrupted.ts",
|
|
104
110
|
"check:shell-modal": "node dev/check.mjs dev/check-shell-modal.tsx",
|
|
105
111
|
"check:multitouch": "node dev/check.mjs dev/check-multitouch.ts",
|
|
112
|
+
"check:openlink-nonstop": "node dev/check.mjs dev/check-openlink-nonstop.ts",
|
|
106
113
|
"check:scroll-size": "node dev/check.mjs dev/check-scroll-size.ts",
|
|
107
114
|
"check:ripple-primary": "node dev/check.mjs dev/check-ripple-primary.ts",
|
|
108
115
|
"check:stack-margins": "node dev/check.mjs dev/check-stack-margins.ts",
|
|
@@ -112,20 +119,46 @@
|
|
|
112
119
|
"check:editor-window": "node dev/check.mjs dev/check-editor-window.ts",
|
|
113
120
|
"check:system-theme": "node dev/check.mjs dev/check-system-theme.ts",
|
|
114
121
|
"check:designer-actions": "node dev/check.mjs dev/check-designer-actions.tsx",
|
|
122
|
+
"check:dialog-a11y": "node dev/check.mjs dev/check-dialog-a11y.ts",
|
|
115
123
|
"check:label-span-effects": "node dev/check.mjs dev/check-label-span-effects.ts",
|
|
116
124
|
"check:animator-isolation": "node dev/check.mjs dev/check-animator-isolation.ts",
|
|
125
|
+
"check:a11y-opacity": "node dev/check.mjs dev/check-a11y-opacity.ts",
|
|
126
|
+
"check:a11y-presentational": "node dev/check.mjs dev/check-a11y-presentational.ts",
|
|
127
|
+
"check:password-a11y": "node dev/check.mjs dev/check-password-a11y.ts",
|
|
128
|
+
"check:release-velocity": "node dev/check.mjs dev/check-release-velocity.ts",
|
|
117
129
|
"check:quiet-animations": "node dev/check.mjs dev/check-quiet-animations.ts",
|
|
130
|
+
"check:skew-sign": "node dev/check.mjs dev/check-skew-sign.ts",
|
|
131
|
+
"check:styles-code": "node dev/check.mjs dev/check-styles-code.ts",
|
|
132
|
+
"check:composite-removed": "node dev/check.mjs dev/check-composite-removed.ts",
|
|
118
133
|
"audit:a11y": "node dev/audit-a11y.mjs",
|
|
119
134
|
"bench:relayout": "node dev/check.mjs dev/bench-relayout.ts",
|
|
120
135
|
"site:extras": "node dev/site-extras.mjs dist/demo",
|
|
121
136
|
"build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
122
137
|
"prepublishOnly": "npm run build:lib",
|
|
123
|
-
"preview": "vite preview samples/demo"
|
|
138
|
+
"preview": "vite preview samples/demo",
|
|
139
|
+
"check:add3d": "node dev/check.mjs dev/check-add3d.ts",
|
|
140
|
+
"check:parent-independent": "node dev/check.mjs dev/check-parent-independent.ts",
|
|
141
|
+
"check:update-while-recording": "node dev/check.mjs dev/check-update-while-recording.ts",
|
|
142
|
+
"check:image-cache": "node dev/check.mjs dev/check-image-cache.ts",
|
|
143
|
+
"browser:canvas-contexts": "node dev/check-canvas-contexts.mjs",
|
|
144
|
+
"check:editor-wheel": "node dev/check.mjs dev/check-editor-wheel.ts",
|
|
145
|
+
"check:reading-order": "node dev/check.mjs dev/check-reading-order.ts",
|
|
146
|
+
"check:editor-rightpress": "node dev/check.mjs dev/check-editor-rightpress.ts",
|
|
147
|
+
"browser:touch-contextmenu": "node dev/check-touch-contextmenu.mjs",
|
|
148
|
+
"browser:text-selection": "node dev/check-text-selection.mjs",
|
|
149
|
+
"browser:tab-scroll": "node dev/check-tab-scroll.mjs",
|
|
150
|
+
"check:recycled-doublebuffer": "node dev/check.mjs dev/check-recycled-doublebuffer.ts",
|
|
151
|
+
"check:add3d-framing": "node dev/check.mjs dev/check-add3d-framing.ts",
|
|
152
|
+
"check:label-selection": "node dev/check.mjs dev/check-label-selection.ts",
|
|
153
|
+
"check:frame-errors": "node dev/check.mjs dev/check-frame-errors.ts",
|
|
154
|
+
"browser:editor-keyboard": "node dev/check-editor-keyboard.mjs",
|
|
155
|
+
"browser:double-tap": "node dev/check-double-tap.mjs",
|
|
156
|
+
"check:scroll-keyboard": "node dev/check.mjs dev/check-scroll-keyboard.ts"
|
|
124
157
|
},
|
|
125
158
|
"peerDependencies": {
|
|
126
159
|
"playwright-core": ">=1.40",
|
|
127
|
-
"react": "^
|
|
128
|
-
"react-dom": "^
|
|
160
|
+
"react": "^19.2.0",
|
|
161
|
+
"react-dom": "^19.2.0",
|
|
129
162
|
"vite": ">=5"
|
|
130
163
|
},
|
|
131
164
|
"peerDependenciesMeta": {
|