drawnui-react 0.1.0-preview.34 → 0.1.0-preview.36
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/SKIPPED.md +2 -0
- package/dist/controls/SkiaButton.js +2 -2
- package/dist/controls/SkiaCheckbox.js +2 -1
- package/dist/controls/SkiaEditor.d.ts +4 -0
- package/dist/controls/SkiaEditor.js +16 -4
- package/dist/controls/SkiaLabel.d.ts +7 -1
- package/dist/controls/SkiaLabel.js +44 -8
- package/dist/controls/SkiaLayout.d.ts +2 -0
- package/dist/controls/SkiaLayout.js +2 -0
- package/dist/controls/SkiaProgress.js +2 -2
- package/dist/controls/SkiaRadioButton.js +2 -1
- package/dist/controls/SkiaSlider.js +2 -2
- package/dist/controls/SkiaSwitch.js +4 -2
- package/dist/controls/TooltipStyle.d.ts +52 -0
- package/dist/controls/TooltipStyle.js +88 -0
- package/dist/core/Accessibility.d.ts +18 -0
- package/dist/core/Accessibility.js +75 -3
- package/dist/core/Canvas.d.ts +60 -3
- package/dist/core/Canvas.js +185 -5
- package/dist/core/ControlStyle.d.ts +2 -0
- package/dist/core/ControlStyle.js +2 -0
- package/dist/core/Hover.d.ts +4 -0
- package/dist/core/Hover.js +6 -0
- package/dist/core/KeyboardManager.d.ts +7 -0
- package/dist/core/KeyboardManager.js +31 -2
- package/dist/core/PopupWindows.d.ts +92 -0
- package/dist/core/PopupWindows.js +203 -0
- package/dist/core/SkiaControl.d.ts +20 -0
- package/dist/core/SkiaControl.js +33 -0
- package/dist/core/Super.d.ts +7 -0
- package/dist/core/Super.js +7 -0
- package/dist/core/Tooltips.d.ts +69 -0
- package/dist/core/Tooltips.js +195 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +32 -0
- package/dist/react/reconciler.d.ts +2 -0
- package/dist/react/reconciler.js +5 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,13 @@ export * from "./core/Canvas";
|
|
|
10
10
|
export * from "./controls/SkiaLayout";
|
|
11
11
|
export * from "./core/Accessibility";
|
|
12
12
|
export * from "./core/Hover";
|
|
13
|
+
export * from "./core/Tooltips";
|
|
14
|
+
export * from "./core/PopupWindows";
|
|
13
15
|
export * from "./controls/SkiaLabel";
|
|
14
16
|
export * from "./controls/TextSpan";
|
|
15
17
|
export * from "./controls/SkiaRichLabel";
|
|
16
18
|
export * from "./controls/SkiaLabelFps";
|
|
19
|
+
export * from "./controls/TooltipStyle";
|
|
17
20
|
export * from "./core/ControlStyle";
|
|
18
21
|
export * from "./core/ImageEffects";
|
|
19
22
|
export * from "./controls/SkiaToggle";
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,13 @@ export * from "./core/Canvas";
|
|
|
10
10
|
export * from "./controls/SkiaLayout";
|
|
11
11
|
export * from "./core/Accessibility";
|
|
12
12
|
export * from "./core/Hover";
|
|
13
|
+
export * from "./core/Tooltips";
|
|
14
|
+
export * from "./core/PopupWindows";
|
|
13
15
|
export * from "./controls/SkiaLabel";
|
|
14
16
|
export * from "./controls/TextSpan";
|
|
15
17
|
export * from "./controls/SkiaRichLabel";
|
|
16
18
|
export * from "./controls/SkiaLabelFps";
|
|
19
|
+
export * from "./controls/TooltipStyle";
|
|
17
20
|
export * from "./core/ControlStyle";
|
|
18
21
|
export * from "./core/ImageEffects";
|
|
19
22
|
export * from "./controls/SkiaToggle";
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
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 { PopupAnchor, PopupId, PopupWindowOptions } from "../core/PopupWindows";
|
|
5
|
+
import type { SKPoint } from "../core/Gestures";
|
|
6
|
+
import type { SKRect } from "../core/Types";
|
|
4
7
|
import type { Thickness, ThicknessValue } from "../core/Types";
|
|
5
8
|
import type { SkiaLabel as SkiaLabelCtrl } from "../controls/SkiaLabel";
|
|
6
9
|
import type { TextSpan as TextSpanCtrl } from "../controls/TextSpan";
|
|
@@ -123,6 +126,16 @@ export interface CanvasProps {
|
|
|
123
126
|
/** DrawnView.WasDrawn: after every drawn frame. */
|
|
124
127
|
WasDrawn?: CanvasView["WasDrawn"];
|
|
125
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Opens a popup window (drawnui-cross 6at) whose content is drawn elements, e.g. a menu:
|
|
131
|
+
* `OpenPopupWindow(canvas, <SkiaShape ...>...</SkiaShape>, e.Location)`. The elements are rendered at once in a React
|
|
132
|
+
* root of their own and unmounted when the popup closes; the anchor is a point (canvas points), a rect, a control or a
|
|
133
|
+
* `PopupAnchor`. Returns the popup's id (for `canvas.ClosePopupWindow`).
|
|
134
|
+
*/
|
|
135
|
+
export declare function OpenPopupWindow(canvas: CanvasView, content: ReactNode, anchor: PopupAnchor | SKPoint | SKRect | SkiaControl | {
|
|
136
|
+
X: number;
|
|
137
|
+
Y: number;
|
|
138
|
+
}, options?: PopupWindowOptions): PopupId;
|
|
126
139
|
/**
|
|
127
140
|
* Mirrors DrawnUi Canvas: the bridge between the DOM (react-dom) and the drawn tree (DrawnUi reconciler).
|
|
128
141
|
* Requires Super.UseDrawnUi()...BuildAsync() to have completed.
|
package/dist/react/index.js
CHANGED
|
@@ -68,6 +68,31 @@ function removeStaticContent() {
|
|
|
68
68
|
for (const el of document.querySelectorAll("[data-drawnui-static]"))
|
|
69
69
|
el.remove();
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Opens a popup window (drawnui-cross 6at) whose content is drawn elements, e.g. a menu:
|
|
73
|
+
* `OpenPopupWindow(canvas, <SkiaShape ...>...</SkiaShape>, e.Location)`. The elements are rendered at once in a React
|
|
74
|
+
* root of their own and unmounted when the popup closes; the anchor is a point (canvas points), a rect, a control or a
|
|
75
|
+
* `PopupAnchor`. Returns the popup's id (for `canvas.ClosePopupWindow`).
|
|
76
|
+
*/
|
|
77
|
+
export function OpenPopupWindow(canvas, content, anchor, options) {
|
|
78
|
+
const holder = { Content: undefined };
|
|
79
|
+
const root = createDrawnRoot(holder);
|
|
80
|
+
root.renderSync(content);
|
|
81
|
+
const control = holder.Content;
|
|
82
|
+
if (!control) {
|
|
83
|
+
root.unmount();
|
|
84
|
+
throw new Error("DrawnUi: OpenPopupWindow content rendered no control");
|
|
85
|
+
}
|
|
86
|
+
const id = canvas.OpenPopupWindow(control, anchor, options);
|
|
87
|
+
const closed = (which) => {
|
|
88
|
+
if (which !== id)
|
|
89
|
+
return;
|
|
90
|
+
canvas.PopupWindowClosed.delete(closed);
|
|
91
|
+
root.unmount();
|
|
92
|
+
};
|
|
93
|
+
canvas.PopupWindowClosed.add(closed);
|
|
94
|
+
return id;
|
|
95
|
+
}
|
|
71
96
|
/**
|
|
72
97
|
* Mirrors DrawnUi Canvas: the bridge between the DOM (react-dom) and the drawn tree (DrawnUi reconciler).
|
|
73
98
|
* Requires Super.UseDrawnUi()...BuildAsync() to have completed.
|
|
@@ -228,6 +253,13 @@ function AccessibilityOverlay({ view }) {
|
|
|
228
253
|
e.preventDefault();
|
|
229
254
|
activate();
|
|
230
255
|
}
|
|
256
|
+
else if (e.key === "Tab" && view.AccessibilityManager.KeyboardScope) {
|
|
257
|
+
// an open popup window keeps the keyboard: Tab goes round its stops (a menu is one stop)
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
const next = view.AccessibilityManager.NextTabStop(n.Source, !e.shiftKey);
|
|
260
|
+
if (next)
|
|
261
|
+
elementOf(next.AccessibilityId)?.focus({ preventScroll: true });
|
|
262
|
+
}
|
|
231
263
|
else if (NAVIGATION_KEYS.has(e.key) && SkiaAccessibilityManager.Key(n.Source, e.key))
|
|
232
264
|
e.preventDefault();
|
|
233
265
|
}, onFocus: (e) => {
|
|
@@ -9,6 +9,8 @@ export declare const Registry: Record<string, new () => HostInstance>;
|
|
|
9
9
|
/** Creates a React root whose container is an engine Canvas. */
|
|
10
10
|
export declare function createDrawnRoot(canvas: Canvas): {
|
|
11
11
|
render(children: ReactNode): void;
|
|
12
|
+
/** Renders and commits now: the container holds the drawn controls when it returns. */
|
|
13
|
+
renderSync(children: ReactNode): void;
|
|
12
14
|
unmount(): void;
|
|
13
15
|
};
|
|
14
16
|
export {};
|
package/dist/react/reconciler.js
CHANGED
|
@@ -177,6 +177,11 @@ export function createDrawnRoot(canvas) {
|
|
|
177
177
|
const container = reconciler.createContainer(canvas, ConcurrentRoot, null, false, null, "", onError, onError, onError, noop, null);
|
|
178
178
|
return {
|
|
179
179
|
render(children) { reconciler.updateContainer(children, container, null, null); },
|
|
180
|
+
/** Renders and commits now: the container holds the drawn controls when it returns. */
|
|
181
|
+
renderSync(children) {
|
|
182
|
+
const r = reconciler;
|
|
183
|
+
r.flushSyncFromReconciler(() => reconciler.updateContainer(children, container, null, null));
|
|
184
|
+
},
|
|
180
185
|
unmount() { reconciler.updateContainer(null, container, null, null); },
|
|
181
186
|
};
|
|
182
187
|
}
|
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.36",
|
|
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)",
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
"check:label-direction": "node dev/check.mjs dev/check-label-direction.ts",
|
|
91
91
|
"check:stack-fit": "node dev/check.mjs dev/check-stack-fit.ts",
|
|
92
92
|
"check:label-reuse": "node dev/check.mjs dev/check-label-reuse.ts",
|
|
93
|
+
"check:popups-tooltips": "node dev/check.mjs dev/check-popups-tooltips.ts",
|
|
93
94
|
"bench:relayout": "node dev/check.mjs dev/bench-relayout.ts",
|
|
94
95
|
"site:extras": "node dev/site-extras.mjs dist/demo",
|
|
95
96
|
"build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|