drawnui-react 0.1.0-preview.8 → 1.0.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/README.md +229 -22
- package/SKIPPED.md +38 -29
- package/dist/controls/AnimatedFramesRenderer.d.ts +9 -0
- package/dist/controls/AnimatedFramesRenderer.js +18 -1
- package/dist/controls/DrawnGame.d.ts +44 -0
- package/dist/controls/DrawnGame.js +82 -0
- package/dist/controls/GridStructure.d.ts +25 -3
- package/dist/controls/GridStructure.js +81 -5
- package/dist/controls/SkiaBackdrop.d.ts +8 -2
- package/dist/controls/SkiaBackdrop.js +42 -14
- package/dist/controls/SkiaButton.d.ts +17 -3
- package/dist/controls/SkiaButton.js +26 -8
- package/dist/controls/SkiaCarousel.d.ts +22 -3
- package/dist/controls/SkiaCarousel.js +85 -9
- package/dist/controls/SkiaCheckbox.d.ts +0 -1
- package/dist/controls/SkiaCheckbox.js +2 -7
- package/dist/controls/SkiaDrawer.d.ts +15 -0
- package/dist/controls/SkiaDrawer.js +42 -7
- package/dist/controls/SkiaEditor.d.ts +51 -2
- package/dist/controls/SkiaEditor.js +292 -58
- package/dist/controls/SkiaGif.d.ts +7 -0
- package/dist/controls/SkiaGif.js +25 -4
- package/dist/controls/SkiaImage.d.ts +10 -0
- package/dist/controls/SkiaImage.js +80 -19
- package/dist/controls/SkiaLabel.d.ts +200 -11
- package/dist/controls/SkiaLabel.js +925 -93
- package/dist/controls/SkiaLabelFps.d.ts +12 -0
- package/dist/controls/SkiaLabelFps.js +35 -0
- package/dist/controls/SkiaLayout.d.ts +89 -9
- package/dist/controls/SkiaLayout.js +397 -23
- package/dist/controls/SkiaLottie.js +5 -3
- package/dist/controls/SkiaProgress.d.ts +2 -1
- package/dist/controls/SkiaProgress.js +8 -5
- package/dist/controls/SkiaRadioButton.d.ts +2 -0
- package/dist/controls/SkiaRadioButton.js +16 -4
- package/dist/controls/SkiaRichLabel.d.ts +1 -1
- package/dist/controls/SkiaRichLabel.js +11 -1
- package/dist/controls/SkiaScroll.d.ts +86 -7
- package/dist/controls/SkiaScroll.js +361 -40
- package/dist/controls/SkiaScrollBar.d.ts +27 -0
- package/dist/controls/SkiaScrollBar.js +51 -2
- package/dist/controls/SkiaShaderCarousel.d.ts +11 -1
- package/dist/controls/SkiaShaderCarousel.js +27 -5
- package/dist/controls/SkiaShape.d.ts +15 -2
- package/dist/controls/SkiaShape.js +57 -10
- package/dist/controls/SkiaShell.d.ts +282 -0
- package/dist/controls/SkiaShell.js +972 -0
- package/dist/controls/SkiaSlider.d.ts +20 -2
- package/dist/controls/SkiaSlider.js +61 -7
- package/dist/controls/SkiaSprite.d.ts +4 -0
- package/dist/controls/SkiaSprite.js +27 -11
- package/dist/controls/SkiaSvg.d.ts +4 -0
- package/dist/controls/SkiaSvg.js +28 -4
- package/dist/controls/SkiaSwitch.d.ts +0 -1
- package/dist/controls/SkiaSwitch.js +4 -8
- package/dist/controls/SkiaToggle.d.ts +25 -5
- package/dist/controls/SkiaToggle.js +58 -5
- package/dist/controls/SnappingLayout.d.ts +12 -1
- package/dist/controls/SnappingLayout.js +21 -2
- package/dist/controls/TooltipStyle.d.ts +52 -0
- package/dist/controls/TooltipStyle.js +88 -0
- package/dist/core/Accessibility.d.ts +162 -11
- package/dist/core/Accessibility.js +882 -22
- package/dist/core/Animators.d.ts +37 -1
- package/dist/core/Animators.js +102 -9
- package/dist/core/Canvas.d.ts +307 -8
- package/dist/core/Canvas.js +1202 -66
- package/dist/core/ControlStyle.d.ts +2 -0
- package/dist/core/ControlStyle.js +2 -0
- package/dist/core/DesignerActions.d.ts +32 -0
- package/dist/core/DesignerActions.js +68 -0
- package/dist/core/Easing.d.ts +12 -1
- package/dist/core/Easing.js +25 -1
- package/dist/core/Gestures.d.ts +86 -2
- package/dist/core/Gestures.js +184 -4
- package/dist/core/Hover.d.ts +51 -0
- package/dist/core/Hover.js +140 -0
- package/dist/core/ImageEffects.d.ts +2 -0
- package/dist/core/ImageEffects.js +2 -0
- package/dist/core/KeyboardManager.d.ts +40 -0
- package/dist/core/KeyboardManager.js +98 -8
- package/dist/core/PopupWindows.d.ts +94 -0
- package/dist/core/PopupWindows.js +207 -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 +16 -1
- package/dist/core/Shaping.d.ts +40 -0
- package/dist/core/Shaping.js +224 -0
- package/dist/core/SkiaControl.d.ts +306 -13
- package/dist/core/SkiaControl.js +681 -75
- package/dist/core/SkiaEffect.d.ts +29 -1
- package/dist/core/SkiaEffect.js +78 -16
- 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 +33 -2
- package/dist/core/Super.js +58 -12
- package/dist/core/TextInputProxy.d.ts +31 -1
- package/dist/core/TextInputProxy.js +97 -15
- package/dist/core/Tooltips.d.ts +71 -0
- package/dist/core/Tooltips.js +205 -0
- package/dist/core/Types.d.ts +11 -1
- package/dist/core/Types.js +32 -1
- package/dist/core/ViewsAdapter.d.ts +7 -2
- package/dist/core/ViewsAdapter.js +10 -3
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/react/SkiaShell.d.ts +8 -74
- package/dist/react/SkiaShell.js +163 -475
- package/dist/react/index.d.ts +48 -4
- package/dist/react/index.js +210 -43
- package/dist/react/reconciler.d.ts +32 -0
- package/dist/react/reconciler.js +71 -40
- package/dist/vite/index.d.ts +9 -0
- package/dist/vite/index.js +36 -3
- package/package.json +103 -5
package/dist/react/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { type CSSProperties, type FC, type ReactNode, type Ref } from "react";
|
|
2
2
|
import { Canvas as CanvasView } from "../core/Canvas";
|
|
3
3
|
import type { SkiaControl } from "../core/SkiaControl";
|
|
4
|
-
import type {
|
|
4
|
+
import type { PopupAnchor, PopupId, PopupWindowOptions } from "../core/PopupWindows";
|
|
5
|
+
import type { SKPoint } from "../core/Gestures";
|
|
6
|
+
import type { SKRect } from "../core/Types";
|
|
7
|
+
import type { Thickness, ThicknessValue } from "../core/Types";
|
|
8
|
+
import { SkiaLabel as SkiaLabelCtrl } from "../controls/SkiaLabel";
|
|
5
9
|
import type { TextSpan as TextSpanCtrl } from "../controls/TextSpan";
|
|
6
10
|
import type { SkiaRichLabel as SkiaRichLabelCtrl } from "../controls/SkiaRichLabel";
|
|
11
|
+
import type { SkiaLabelFps as SkiaLabelFpsCtrl } from "../controls/SkiaLabelFps";
|
|
7
12
|
import type { SkiaSwitch as SkiaSwitchCtrl } from "../controls/SkiaSwitch";
|
|
8
13
|
import type { SkiaCheckbox as SkiaCheckboxCtrl } from "../controls/SkiaCheckbox";
|
|
9
14
|
import type { SkiaRadioButton as SkiaRadioButtonCtrl } from "../controls/SkiaRadioButton";
|
|
@@ -22,7 +27,7 @@ import type { SkiaScrollBar as SkiaScrollBarCtrl } from "../controls/SkiaScrollB
|
|
|
22
27
|
import type { RefreshIndicator as RefreshIndicatorCtrl } from "../controls/RefreshIndicator";
|
|
23
28
|
import type { SkiaSvg as SkiaSvgCtrl } from "../controls/SkiaSvg";
|
|
24
29
|
import type { SkiaBackdrop as SkiaBackdropCtrl } from "../controls/SkiaBackdrop";
|
|
25
|
-
import
|
|
30
|
+
import { SkiaEditor as SkiaEditorCtrl } from "../controls/SkiaEditor";
|
|
26
31
|
import type { SkiaSprite as SkiaSpriteCtrl } from "../controls/SkiaSprite";
|
|
27
32
|
import type { SkiaSpriteSet as SkiaSpriteSetCtrl } from "../controls/SkiaSpriteSet";
|
|
28
33
|
import type { SkiaLottie as SkiaLottieCtrl } from "../controls/SkiaLottie";
|
|
@@ -31,6 +36,25 @@ import { SkiaScroll as SkiaScrollCtrl } from "../controls/SkiaScroll";
|
|
|
31
36
|
import type { SkiaShape as SkiaShapeCtrl } from "../controls/SkiaShape";
|
|
32
37
|
import type { Color, RenderingModeType } from "../core/Types";
|
|
33
38
|
import type { GesturesMode } from "../core/Gestures";
|
|
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";
|
|
42
|
+
import { DesignerActions, designerAction } from "../core/DesignerActions";
|
|
43
|
+
export { DesignerActions, designerAction };
|
|
44
|
+
/**
|
|
45
|
+
* A Designer action that exists while the component is mounted (DesignerActions): `path` is its groups and name,
|
|
46
|
+
* slash-separated ("Levels/Level 3"); `run` is called when the designer runs it (always the latest `run` passed). It is
|
|
47
|
+
* registered again when the path or one of `deps` changes. Nothing runs without a designer attached.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useDesignerAction(path: string, run: () => void, deps?: readonly unknown[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* A Designer action as an element (for JSX and NX): declared while it is mounted, `onRun` called when the designer runs
|
|
52
|
+
* it. Draws nothing. `<DesignerAction Name="Levels/Level 3" onRun={() => startLevel(3)} />`
|
|
53
|
+
*/
|
|
54
|
+
export declare function DesignerAction({ Name, onRun }: {
|
|
55
|
+
Name: string;
|
|
56
|
+
onRun: () => void;
|
|
57
|
+
}): null;
|
|
34
58
|
/**
|
|
35
59
|
* Public settable properties of a control become its JSX props, same PascalCase names as C#.
|
|
36
60
|
*
|
|
@@ -41,8 +65,10 @@ import type { GesturesMode } from "../core/Gestures";
|
|
|
41
65
|
* and never appeared in completion.
|
|
42
66
|
*/
|
|
43
67
|
type PropsOf<T> = Partial<{
|
|
44
|
-
[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" ? never : K]: T[K];
|
|
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];
|
|
45
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>;
|
|
46
72
|
/** `ref` receives the engine control instance (react-reconciler getPublicInstance). */
|
|
47
73
|
type LeafProps<T> = PropsOf<T> & {
|
|
48
74
|
ref?: Ref<T>;
|
|
@@ -57,10 +83,13 @@ export declare const SkiaStack: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
|
57
83
|
export declare const SkiaRow: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
58
84
|
export declare const SkiaLayer: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
59
85
|
export declare const SkiaWrap: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
86
|
+
export declare const SkiaMasonry: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
60
87
|
export declare const SkiaGrid: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
61
88
|
/** Grid drawing gradient separator lines in its spacing (C# SkiaDecoratedGrid). */
|
|
62
89
|
export declare const SkiaDecoratedGrid: FC<LayoutProps<SkiaDecoratedGridCtrl>>;
|
|
63
90
|
export declare const SkiaLabel: FC<LayoutProps<SkiaLabelCtrl>>;
|
|
91
|
+
/** Canvas FPS counter (C# SkiaLabelFps); its value changes only on frames running animators request anyway. */
|
|
92
|
+
export declare const SkiaLabelFps: FC<LeafProps<SkiaLabelFpsCtrl>>;
|
|
64
93
|
/** Markdown label (C# SkiaRichLabel): Text is markdown, rendered as spans; LinkTapped for [text](url). */
|
|
65
94
|
export declare const SkiaRichLabel: FC<LeafProps<SkiaRichLabelCtrl>>;
|
|
66
95
|
/** Child of <SkiaLabel>: a styled fragment (C# TextSpan). */
|
|
@@ -106,6 +135,8 @@ export interface CanvasProps {
|
|
|
106
135
|
* scrolls it unless a control used the wheel. A page that cannot scroll keeps every touch. Lock keeps all input.
|
|
107
136
|
*/
|
|
108
137
|
Gestures?: GesturesMode;
|
|
138
|
+
/** While nothing has keyboard focus, an arrow key starts keyboard navigation as the first Tab does (off by default: games keep their arrows). */
|
|
139
|
+
ArrowsStartKeyboardNavigation?: boolean;
|
|
109
140
|
children?: ReactNode;
|
|
110
141
|
style?: CSSProperties;
|
|
111
142
|
className?: string;
|
|
@@ -117,12 +148,25 @@ export interface CanvasProps {
|
|
|
117
148
|
WillFirstTimeDraw?: CanvasView["WillFirstTimeDraw"];
|
|
118
149
|
/** DrawnView.WasDrawn: after every drawn frame. */
|
|
119
150
|
WasDrawn?: CanvasView["WasDrawn"];
|
|
151
|
+
/** The system light / dark appearance: once when known (at creation), then once per change. */
|
|
152
|
+
SystemThemeChanged?: CanvasView["SystemThemeChanged"];
|
|
120
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Opens a popup window (drawnui-cross 6at) whose content is drawn elements, e.g. a menu:
|
|
156
|
+
* `OpenPopupWindow(canvas, <SkiaShape ...>...</SkiaShape>, e.Location)`. The elements are rendered at once in a React
|
|
157
|
+
* root of their own and unmounted when the popup closes; the anchor is a point (canvas points), a rect, a control or a
|
|
158
|
+
* `PopupAnchor`. Returns the popup's id (for `canvas.ClosePopupWindow`).
|
|
159
|
+
*/
|
|
160
|
+
export declare function OpenPopupWindow(canvas: CanvasView, content: ReactNode, anchor: PopupAnchor | SKPoint | SKRect | SkiaControl | {
|
|
161
|
+
X: number;
|
|
162
|
+
Y: number;
|
|
163
|
+
}, options?: PopupWindowOptions): PopupId;
|
|
121
164
|
/**
|
|
122
165
|
* Mirrors DrawnUi Canvas: the bridge between the DOM (react-dom) and the drawn tree (DrawnUi reconciler).
|
|
123
166
|
* Requires Super.UseDrawnUi()...BuildAsync() to have completed.
|
|
124
167
|
*/
|
|
125
|
-
export declare function Canvas({ BackgroundColor, RenderingMode, Gestures, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn }: CanvasProps): import("react").JSX.Element;
|
|
168
|
+
export declare function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKeyboardNavigation, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn, SystemThemeChanged }: CanvasProps): import("react").JSX.Element;
|
|
126
169
|
export type { SkiaControl };
|
|
127
170
|
export * from "../index";
|
|
128
171
|
export * from "./SkiaShell";
|
|
172
|
+
export { SkiaShell } from "./SkiaShell";
|
package/dist/react/index.js
CHANGED
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { SkiaAccessibilityManager } from "../core/Accessibility";
|
|
4
|
+
import { KeyboardManager } from "../core/KeyboardManager";
|
|
5
|
+
import { TextInputProxy } from "../core/TextInputProxy";
|
|
3
6
|
import { Canvas as CanvasView } from "../core/Canvas";
|
|
7
|
+
import { SkiaEditor as SkiaEditorCtrl } from "../controls/SkiaEditor";
|
|
4
8
|
import { SkiaScroll as SkiaScrollCtrl } from "../controls/SkiaScroll";
|
|
5
9
|
import { createDrawnRoot } from "./reconciler";
|
|
10
|
+
export { DesignerSourceOf } from "./reconciler";
|
|
11
|
+
/** JSX tag name -> engine class: add-on packages register their controls here. */
|
|
12
|
+
export { Registry } from "./reconciler";
|
|
13
|
+
import { DesignerActions, designerAction } from "../core/DesignerActions";
|
|
14
|
+
export { DesignerActions, designerAction };
|
|
15
|
+
/**
|
|
16
|
+
* A Designer action that exists while the component is mounted (DesignerActions): `path` is its groups and name,
|
|
17
|
+
* slash-separated ("Levels/Level 3"); `run` is called when the designer runs it (always the latest `run` passed). It is
|
|
18
|
+
* registered again when the path or one of `deps` changes. Nothing runs without a designer attached.
|
|
19
|
+
*/
|
|
20
|
+
export function useDesignerAction(path, run, deps = []) {
|
|
21
|
+
const latest = useRef(run);
|
|
22
|
+
latest.current = run;
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
useEffect(() => designerAction(path, () => latest.current()), [path, ...deps]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A Designer action as an element (for JSX and NX): declared while it is mounted, `onRun` called when the designer runs
|
|
28
|
+
* it. Draws nothing. `<DesignerAction Name="Levels/Level 3" onRun={() => startLevel(3)} />`
|
|
29
|
+
*/
|
|
30
|
+
export function DesignerAction({ Name, onRun }) {
|
|
31
|
+
useDesignerAction(Name, onRun);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
6
34
|
/** Typed JSX tags resolved by the reconciler Registry. */
|
|
7
35
|
export const SkiaLayout = "SkiaLayout";
|
|
8
36
|
export const SkiaStack = "SkiaStack";
|
|
9
37
|
export const SkiaRow = "SkiaRow";
|
|
10
38
|
export const SkiaLayer = "SkiaLayer";
|
|
11
39
|
export const SkiaWrap = "SkiaWrap";
|
|
40
|
+
export const SkiaMasonry = "SkiaMasonry";
|
|
12
41
|
export const SkiaGrid = "SkiaGrid";
|
|
13
42
|
/** Grid drawing gradient separator lines in its spacing (C# SkiaDecoratedGrid). */
|
|
14
43
|
export const SkiaDecoratedGrid = "SkiaDecoratedGrid";
|
|
15
44
|
export const SkiaLabel = "SkiaLabel";
|
|
45
|
+
/** Canvas FPS counter (C# SkiaLabelFps); its value changes only on frames running animators request anyway. */
|
|
46
|
+
export const SkiaLabelFps = "SkiaLabelFps";
|
|
16
47
|
/** Markdown label (C# SkiaRichLabel): Text is markdown, rendered as spans; LinkTapped for [text](url). */
|
|
17
48
|
export const SkiaRichLabel = "SkiaRichLabel";
|
|
18
49
|
/** Child of <SkiaLabel>: a styled fragment (C# TextSpan). */
|
|
@@ -62,11 +93,36 @@ function removeStaticContent() {
|
|
|
62
93
|
for (const el of document.querySelectorAll("[data-drawnui-static]"))
|
|
63
94
|
el.remove();
|
|
64
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Opens a popup window (drawnui-cross 6at) whose content is drawn elements, e.g. a menu:
|
|
98
|
+
* `OpenPopupWindow(canvas, <SkiaShape ...>...</SkiaShape>, e.Location)`. The elements are rendered at once in a React
|
|
99
|
+
* root of their own and unmounted when the popup closes; the anchor is a point (canvas points), a rect, a control or a
|
|
100
|
+
* `PopupAnchor`. Returns the popup's id (for `canvas.ClosePopupWindow`).
|
|
101
|
+
*/
|
|
102
|
+
export function OpenPopupWindow(canvas, content, anchor, options) {
|
|
103
|
+
const holder = { Content: undefined };
|
|
104
|
+
const root = createDrawnRoot(holder);
|
|
105
|
+
root.renderSync(content);
|
|
106
|
+
const control = holder.Content;
|
|
107
|
+
if (!control) {
|
|
108
|
+
root.unmount();
|
|
109
|
+
throw new Error("DrawnUi: OpenPopupWindow content rendered no control");
|
|
110
|
+
}
|
|
111
|
+
const id = canvas.OpenPopupWindow(control, anchor, options);
|
|
112
|
+
const closed = (which) => {
|
|
113
|
+
if (which !== id)
|
|
114
|
+
return;
|
|
115
|
+
canvas.PopupWindowClosed.delete(closed);
|
|
116
|
+
root.unmount();
|
|
117
|
+
};
|
|
118
|
+
canvas.PopupWindowClosed.add(closed);
|
|
119
|
+
return id;
|
|
120
|
+
}
|
|
65
121
|
/**
|
|
66
122
|
* Mirrors DrawnUi Canvas: the bridge between the DOM (react-dom) and the drawn tree (DrawnUi reconciler).
|
|
67
123
|
* Requires Super.UseDrawnUi()...BuildAsync() to have completed.
|
|
68
124
|
*/
|
|
69
|
-
export function Canvas({ BackgroundColor, RenderingMode, Gestures, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn }) {
|
|
125
|
+
export function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKeyboardNavigation, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn, SystemThemeChanged }) {
|
|
70
126
|
const ref = useRef(null);
|
|
71
127
|
const view = useRef(null);
|
|
72
128
|
const root = useRef(null);
|
|
@@ -78,6 +134,7 @@ export function Canvas({ BackgroundColor, RenderingMode, Gestures, children, sty
|
|
|
78
134
|
c.RenderingMode = RenderingMode;
|
|
79
135
|
c.WillFirstTimeDraw = WillFirstTimeDraw;
|
|
80
136
|
c.WasDrawn = WasDrawn;
|
|
137
|
+
c.SystemThemeChanged = SystemThemeChanged;
|
|
81
138
|
});
|
|
82
139
|
view.current = v;
|
|
83
140
|
root.current = createDrawnRoot(v);
|
|
@@ -96,13 +153,17 @@ export function Canvas({ BackgroundColor, RenderingMode, Gestures, children, sty
|
|
|
96
153
|
v.Update();
|
|
97
154
|
}
|
|
98
155
|
v.Gestures = Gestures ?? "Disabled";
|
|
156
|
+
v.ArrowsStartKeyboardNavigation = ArrowsStartKeyboardNavigation ?? false;
|
|
99
157
|
v.ContextMenu = ContextMenu;
|
|
100
158
|
v.WillFirstTimeDraw = WillFirstTimeDraw;
|
|
101
159
|
v.WasDrawn = WasDrawn;
|
|
160
|
+
v.SystemThemeChanged = SystemThemeChanged;
|
|
102
161
|
root.current.render(children);
|
|
103
162
|
});
|
|
104
|
-
// The drawn surface is aria-hidden; the overlay is the accessibility tree (DrawnUi.Blazor pattern).
|
|
105
|
-
|
|
163
|
+
// The drawn surface is aria-hidden; the overlay is the accessibility tree (DrawnUi.Blazor pattern). The host takes the
|
|
164
|
+
// DOM focus (from code only, no ring) when the focused control leaves: no control is focused and the keys belong to the
|
|
165
|
+
// app, as in the other engines, while a screen reader stays at the canvas instead of the top of the page.
|
|
166
|
+
return (_jsxs("div", { className: className, tabIndex: -1, "data-drawnui-host": "1", style: { position: "relative", outline: "none", ...style }, children: [_jsx("canvas", { ref: ref, "aria-hidden": true, style: { display: "block", width: "100%", height: "100%" } }), engine && _jsx(AccessibilityOverlay, { view: engine })] }));
|
|
106
167
|
}
|
|
107
168
|
const A11Y_CSS = `
|
|
108
169
|
.drawnui-a11y-overlay{position:absolute;inset:0;overflow:hidden;pointer-events:none;user-select:none;-webkit-user-select:none}
|
|
@@ -110,70 +171,176 @@ const A11Y_CSS = `
|
|
|
110
171
|
.drawnui-a11y-node::selection,.drawnui-a11y-node *::selection{background:transparent;color:transparent}
|
|
111
172
|
.drawnui-a11y-node:focus{outline:none}
|
|
112
173
|
.drawnui-a11y-node:focus-visible{outline:3px solid rgba(13,110,253,.85);outline-offset:1px;border-radius:3px}
|
|
113
|
-
.drawnui-a11y-text{overflow:visible}
|
|
114
|
-
.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}
|
|
115
|
-
.drawnui-a11y-text>span::selection{background:rgba(110,168,254,.55);color:transparent}
|
|
116
174
|
`;
|
|
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;
|
|
117
185
|
/**
|
|
118
|
-
* Invisible ARIA elements mirroring the accessible drawn controls, positioned over the canvas.
|
|
119
|
-
* Improvement over DrawnUi.Blazor: `pointer-events:none`, so hover and every pointer gesture still reach the
|
|
120
|
-
*
|
|
186
|
+
* Invisible ARIA elements mirroring the accessible drawn controls, positioned over the canvas (the DrawnUi.Blazor
|
|
187
|
+
* overlay). Improvement over DrawnUi.Blazor: `pointer-events:none`, so hover and every pointer gesture still reach the
|
|
188
|
+
* canvas. Keyboard and screen-reader input arrive as DOM events: Enter / Space activate (a Tapped), the navigation keys
|
|
189
|
+
* go to the focused control and then to its arrow-key group; a group is one Tab stop (roving tabindex).
|
|
121
190
|
*/
|
|
191
|
+
/** aria-valuenow / min / max / valuetext of a range control (drawnui-cross 6c); a slider reads as horizontal. */
|
|
192
|
+
function valueAttributes(n) {
|
|
193
|
+
const v = n.Value;
|
|
194
|
+
if (!v)
|
|
195
|
+
return undefined;
|
|
196
|
+
return { "aria-valuenow": v.Now, "aria-valuemin": v.Min, "aria-valuemax": v.Max, "aria-valuetext": v.Text || undefined, "aria-orientation": n.Role === "slider" ? "horizontal" : undefined };
|
|
197
|
+
}
|
|
122
198
|
function AccessibilityOverlay({ view }) {
|
|
123
199
|
const [nodes, setNodes] = useState(() => view.AccessibilityManager.Snapshot);
|
|
200
|
+
// keyboard focus moved by the manager (arrow keys in a group): focus that node's element once it is rendered
|
|
201
|
+
const [focusRequest, setFocusRequest] = useState();
|
|
202
|
+
// the Tab stop of a group moves with keyboard focus: re-render on focus
|
|
203
|
+
const [, setFocusTick] = useState(0);
|
|
124
204
|
useEffect(() => {
|
|
125
205
|
const mgr = view.AccessibilityManager;
|
|
126
206
|
setNodes(mgr.Snapshot);
|
|
127
207
|
const off = mgr.OnChanged(() => setNodes(mgr.Snapshot));
|
|
128
208
|
const offLive = mgr.OnLiveRegionUpdated(() => { mgr.ForceRebuildOnNextFrame(); view.Update(); });
|
|
129
|
-
|
|
209
|
+
const offFocus = mgr.OnKeyboardFocusRequested((node) => { setNodes(mgr.Snapshot); setFocusRequest({ id: node?.AccessibilityId ?? 0 }); });
|
|
210
|
+
return () => { off(); offLive(); offFocus(); };
|
|
130
211
|
}, [view]);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
const el = overlayRef.current;
|
|
136
|
-
if (!el)
|
|
212
|
+
const elementOf = (id) => overlayRef.current?.querySelector(`[data-a11y-id="${id}"]`) ?? undefined;
|
|
213
|
+
useLayoutEffect(() => {
|
|
214
|
+
if (!focusRequest)
|
|
137
215
|
return;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
216
|
+
setFocusRequest(undefined);
|
|
217
|
+
// no node: the app took the focus away (SetAccessibilityFocus()), the DOM focus goes back to the canvas host
|
|
218
|
+
if (!focusRequest.id)
|
|
219
|
+
overlayRef.current?.parentElement?.focus({ preventScroll: true });
|
|
220
|
+
else
|
|
221
|
+
elementOf(focusRequest.id)?.focus({ preventScroll: true });
|
|
222
|
+
}, [focusRequest]);
|
|
223
|
+
// the focused node went away (its page or popup closed): no control keeps the focus and its ring goes with it, the keys
|
|
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
|
|
225
|
+
// thrown to the top of the page and the next Tab starts from the canvas. A focus the user moved away stays away.
|
|
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);
|
|
144
230
|
useLayoutEffect(() => {
|
|
145
|
-
const
|
|
146
|
-
|
|
231
|
+
const previous = previousNodes.current;
|
|
232
|
+
previousNodes.current = nodes;
|
|
233
|
+
const id = focusedId.current;
|
|
234
|
+
if (!id || nodes.some((n) => n.Id === id))
|
|
147
235
|
return;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
236
|
+
focusedId.current = 0;
|
|
237
|
+
const mgr = view.AccessibilityManager;
|
|
238
|
+
if (mgr.FocusedNode?.AccessibilityId === id)
|
|
239
|
+
mgr.NotifyFocused(undefined);
|
|
240
|
+
const active = document.activeElement;
|
|
241
|
+
if (active && active !== document.body)
|
|
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
|
+
}
|
|
156
260
|
}
|
|
261
|
+
overlayRef.current?.parentElement?.focus({ preventScroll: true });
|
|
157
262
|
}, [nodes]);
|
|
158
|
-
|
|
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
|
|
264
|
+
// field's own element (without taking the caret again) and the browser's Tab moves on from there
|
|
265
|
+
const tabbingOut = useRef(0);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
const onKey = (e) => {
|
|
268
|
+
const editor = SkiaEditorCtrl.Focused;
|
|
269
|
+
if (e.key !== "Tab" || !editor || editor.Superview !== view || !TextInputProxy.IsProxyTarget(e.target))
|
|
270
|
+
return;
|
|
271
|
+
const el = elementOf(editor.AccessibilityId);
|
|
272
|
+
if (!el)
|
|
273
|
+
return;
|
|
274
|
+
tabbingOut.current = editor.AccessibilityId;
|
|
275
|
+
el.focus({ preventScroll: true });
|
|
276
|
+
};
|
|
277
|
+
document.addEventListener("keydown", onKey, true);
|
|
278
|
+
return () => document.removeEventListener("keydown", onKey, true);
|
|
279
|
+
}, [view]);
|
|
280
|
+
const overlayRef = useRef(null);
|
|
281
|
+
if (nodes.length === 0)
|
|
159
282
|
return null;
|
|
160
283
|
// the browser scrolls an overflow:hidden container to reveal a focused child; the overlay must stay pinned to the canvas
|
|
161
284
|
const pin = (e) => { e.currentTarget.scrollTop = 0; e.currentTarget.scrollLeft = 0; };
|
|
162
|
-
|
|
285
|
+
// an active modal (drawnui-cross 6av): the overlay itself is the dialog (role, name, aria-modal) around the dialog's
|
|
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)
|
|
288
|
+
const modal = view.AccessibilityManager.ActiveModal;
|
|
289
|
+
const modalNode = modal ? view.AccessibilityManager.ActiveModalNode : undefined;
|
|
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) => {
|
|
291
|
+
if (n === modalNode || (modal && n.Source === modal))
|
|
292
|
+
return null;
|
|
163
293
|
const pos = { left: n.Rect.Left, top: n.Rect.Top, width: n.Rect.Width, height: n.Rect.Height };
|
|
164
|
-
const activate = () => n.Source
|
|
165
|
-
return n.CanInteract ? (_jsx("div", { role: n.Role, "aria-label": n.Label, title: n.Hint, "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: 0, className: "drawnui-a11y-node", style: { ...pos, fontSize: 0, userSelect: "none" }, onClick: activate,
|
|
166
|
-
e.preventDefault();
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
294
|
+
const activate = () => SkiaAccessibilityManager.Activate(n.Source);
|
|
295
|
+
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, onContextMenu: (e) => { if (view.OpenContextMenuFromKeyboard(n.Source, e.nativeEvent))
|
|
296
|
+
e.preventDefault(); }, onKeyDown: (e) => {
|
|
297
|
+
// the canvas navigation gets the key first; the app's KeyDown runs after it with IsKeyHandled (6az)
|
|
298
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
299
|
+
e.preventDefault();
|
|
300
|
+
if (activate())
|
|
301
|
+
KeyboardManager.MarkKeyHandled(e.nativeEvent.code);
|
|
302
|
+
}
|
|
303
|
+
else if (e.key === "Tab" && view.AccessibilityManager.KeyboardScope) {
|
|
304
|
+
// an open popup window keeps the keyboard: Tab goes round its stops (a menu is one stop)
|
|
305
|
+
e.preventDefault();
|
|
306
|
+
const next = view.AccessibilityManager.NextTabStop(n.Source, !e.shiftKey);
|
|
307
|
+
if (next)
|
|
308
|
+
elementOf(next.AccessibilityId)?.focus({ preventScroll: true });
|
|
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();
|
|
313
|
+
else if (NAVIGATION_KEYS.has(e.key) && SkiaAccessibilityManager.Key(n.Source, e.key)) {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
KeyboardManager.MarkKeyHandled(e.nativeEvent.code);
|
|
316
|
+
}
|
|
317
|
+
}, onFocus: (e) => {
|
|
318
|
+
focusedId.current = n.Id;
|
|
319
|
+
focusedLayer.current = LayerOf(n.Source);
|
|
320
|
+
pin({ currentTarget: e.currentTarget.parentElement });
|
|
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));
|
|
323
|
+
if (tabbingOut.current === n.Id)
|
|
324
|
+
tabbingOut.current = 0; // leaving a text field: it keeps no caret
|
|
325
|
+
else
|
|
326
|
+
n.Source.OnAccessibilityFocused(true); // a text field takes the caret, as after a click
|
|
327
|
+
n.Source.NotifyAccessibilityFocused(true);
|
|
328
|
+
setFocusTick((t) => t + 1);
|
|
329
|
+
}, onBlur: (e) => {
|
|
330
|
+
if (e.currentTarget.isConnected && focusedId.current === n.Id)
|
|
331
|
+
focusedId.current = 0; // moved away on purpose
|
|
332
|
+
if (TextInputProxy.IsProxyTarget(e.relatedTarget))
|
|
333
|
+
return; // a text field moved DOM focus to its own input
|
|
334
|
+
n.Source.OnAccessibilityFocused(false);
|
|
335
|
+
n.Source.NotifyAccessibilityFocused(false);
|
|
336
|
+
}, children: n.Label }, n.Id)) : (
|
|
171
337
|
// static text is exposed as real (transparent) text content; aria-label only for roles that need a name
|
|
172
|
-
_jsx("div", { role: n.Role, "aria-label": n.Role === "text" ? undefined : n.Label, title: n.Hint, "aria-live": n.Live, className: "drawnui-a11y-node", style: pos, children: n.Label }, n.Id));
|
|
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));
|
|
173
339
|
})] }));
|
|
174
340
|
}
|
|
175
341
|
// One import for apps: React tags + every engine type (Colors, Thickness, Super, gestures, animators...).
|
|
176
342
|
// The engine `Canvas` class is shadowed by the React <Canvas> above; reach it via "drawnui-react/core".
|
|
177
343
|
export * from "../index";
|
|
178
|
-
//
|
|
344
|
+
// SkiaShell with JSX pages, popups and modals (useShell()); the engine SkiaShell is in "drawnui-react/core"
|
|
179
345
|
export * from "./SkiaShell";
|
|
346
|
+
export { SkiaShell } from "./SkiaShell";
|
|
@@ -6,9 +6,41 @@ 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;
|
|
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;
|
|
9
39
|
/** Creates a React root whose container is an engine Canvas. */
|
|
10
40
|
export declare function createDrawnRoot(canvas: Canvas): {
|
|
11
41
|
render(children: ReactNode): void;
|
|
42
|
+
/** Renders and commits now: the container holds the drawn controls when it returns. */
|
|
43
|
+
renderSync(children: ReactNode): void;
|
|
12
44
|
unmount(): void;
|
|
13
45
|
};
|
|
14
46
|
export {};
|