drawnui-react 0.1.0-preview.14 → 0.1.0-preview.16
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 +5 -4
- package/dist/controls/SkiaBackdrop.d.ts +2 -0
- package/dist/controls/SkiaBackdrop.js +2 -0
- package/dist/controls/SkiaButton.d.ts +2 -0
- package/dist/controls/SkiaButton.js +2 -0
- package/dist/controls/SkiaCarousel.d.ts +2 -0
- package/dist/controls/SkiaCarousel.js +2 -0
- package/dist/controls/SkiaDrawer.d.ts +2 -0
- package/dist/controls/SkiaDrawer.js +2 -0
- package/dist/controls/SkiaEditor.js +10 -1
- package/dist/controls/SkiaLabel.d.ts +2 -0
- package/dist/controls/SkiaLabel.js +13 -2
- package/dist/controls/SkiaLayout.d.ts +15 -0
- package/dist/controls/SkiaLayout.js +75 -6
- package/dist/controls/SkiaProgress.js +2 -2
- package/dist/controls/SkiaScroll.d.ts +4 -0
- package/dist/controls/SkiaScroll.js +9 -0
- package/dist/controls/SkiaSlider.d.ts +2 -0
- package/dist/controls/SkiaSlider.js +5 -3
- package/dist/controls/SkiaToggle.d.ts +2 -0
- package/dist/controls/SkiaToggle.js +3 -1
- package/dist/controls/SnappingLayout.d.ts +2 -0
- package/dist/controls/SnappingLayout.js +3 -0
- package/dist/core/Accessibility.d.ts +8 -0
- package/dist/core/Accessibility.js +56 -5
- package/dist/core/Canvas.d.ts +23 -0
- package/dist/core/Canvas.js +65 -3
- package/dist/core/Hover.d.ts +37 -0
- package/dist/core/Hover.js +118 -0
- package/dist/core/KeyboardManager.d.ts +13 -0
- package/dist/core/KeyboardManager.js +18 -0
- package/dist/core/SkiaControl.d.ts +87 -1
- package/dist/core/SkiaControl.js +229 -18
- package/dist/core/SkiaEffect.d.ts +3 -0
- package/dist/core/SkiaEffect.js +8 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/reconciler.js +29 -10
- package/package.json +4 -1
package/dist/react/reconciler.js
CHANGED
|
@@ -1,6 +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 { SkiaControl } from "../core/SkiaControl";
|
|
4
5
|
import { SkiaLabel } from "../controls/SkiaLabel";
|
|
5
6
|
import { TextSpan } from "../controls/TextSpan";
|
|
6
7
|
import { SkiaRichLabel } from "../controls/SkiaRichLabel";
|
|
@@ -38,12 +39,14 @@ export const Registry = {
|
|
|
38
39
|
const SKIP = new Set(["children", "key", "ref"]);
|
|
39
40
|
/** Props that change how the subtree is composited, not what it contains: repaint, keep caches (DrawnUi RedrawCanvas). */
|
|
40
41
|
const REPAINT_ONLY = new Set(["TranslationX", "TranslationY", "Rotation", "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";
|
|
41
44
|
/**
|
|
42
45
|
* Assigns changed props straight onto the control (same names as the C# properties).
|
|
43
46
|
* Handler props (functions) are swapped without invalidating: inline arrows change identity every render.
|
|
44
47
|
*/
|
|
45
48
|
function applyProps(inst, prev, next) {
|
|
46
|
-
let changed = false, repaint = false;
|
|
49
|
+
let changed = false, repaint = false, layout = false;
|
|
47
50
|
for (const k in next) {
|
|
48
51
|
if (SKIP.has(k) || (prev && prev[k] === next[k]))
|
|
49
52
|
continue;
|
|
@@ -52,23 +55,36 @@ function applyProps(inst, prev, next) {
|
|
|
52
55
|
continue;
|
|
53
56
|
if (REPAINT_ONLY.has(k))
|
|
54
57
|
repaint = true;
|
|
55
|
-
else
|
|
58
|
+
else {
|
|
56
59
|
changed = true;
|
|
60
|
+
if (!isDrawOnly(k))
|
|
61
|
+
layout = true;
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
if (prev)
|
|
59
65
|
for (const k in prev)
|
|
60
66
|
if (!SKIP.has(k) && !(k in next)) {
|
|
61
67
|
inst[k] = new inst.constructor()[k];
|
|
62
|
-
changed = true;
|
|
68
|
+
changed = layout = true;
|
|
63
69
|
}
|
|
64
|
-
if (changed && prev)
|
|
65
|
-
inst
|
|
70
|
+
if (changed && prev) {
|
|
71
|
+
if (layout || !(inst instanceof SkiaControl))
|
|
72
|
+
inst.Update();
|
|
73
|
+
else
|
|
74
|
+
inst.UpdateDraw();
|
|
75
|
+
}
|
|
66
76
|
else if (repaint && prev)
|
|
67
77
|
inst.RepaintComposition?.();
|
|
68
78
|
}
|
|
69
79
|
let currentUpdatePriority = DefaultEventPriority;
|
|
70
80
|
const noop = () => { };
|
|
71
81
|
const hostContext = {};
|
|
82
|
+
function appendChild(parent, child) {
|
|
83
|
+
if (parent instanceof SkiaLayout)
|
|
84
|
+
return parent.InsertChild(child);
|
|
85
|
+
child.IsChildrenItem = true;
|
|
86
|
+
parent.AddSubView(child);
|
|
87
|
+
}
|
|
72
88
|
// Record<string, unknown> absorbs members that react-reconciler 0.33 reads but @types 0.32 does not declare yet.
|
|
73
89
|
const hostConfig = {
|
|
74
90
|
supportsMutation: true,
|
|
@@ -94,12 +110,15 @@ const hostConfig = {
|
|
|
94
110
|
createTextInstance(text) {
|
|
95
111
|
throw new Error(`DrawnUi: raw text "${text}" is not allowed, use <SkiaLabel Text="..." />`);
|
|
96
112
|
},
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
// JSX children are the app's children (C# IsChildrenItem): a layout keeps them in JSX order inside the slots they
|
|
114
|
+
// occupy, so its own parts keep their place; an existing child passed again is a move
|
|
115
|
+
appendInitialChild: (parent, child) => appendChild(parent, child),
|
|
116
|
+
appendChild: (parent, child) => appendChild(parent, child),
|
|
99
117
|
insertBefore: (parent, child, before) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
if (parent instanceof SkiaLayout)
|
|
119
|
+
return parent.InsertChild(child, before);
|
|
120
|
+
child.IsChildrenItem = true;
|
|
121
|
+
parent.InsertSubView(parent instanceof SkiaLabel ? parent.Spans.indexOf(before) : 0, child);
|
|
103
122
|
},
|
|
104
123
|
removeChild: (parent, child) => parent.RemoveSubView(child),
|
|
105
124
|
appendChildToContainer: (canvas, child) => { canvas.Content = child; },
|
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.16",
|
|
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)",
|
|
@@ -56,6 +56,9 @@
|
|
|
56
56
|
"check:recycling": "node dev/check.mjs dev/check-recycling.ts",
|
|
57
57
|
"check:keyboard": "node dev/check.mjs dev/check-keyboard.ts",
|
|
58
58
|
"check:wheel": "node dev/check.mjs dev/check-wheel.ts",
|
|
59
|
+
"check:children": "node dev/check.mjs dev/check-children.tsx",
|
|
60
|
+
"check:composite": "node dev/check.mjs dev/check-composite.tsx",
|
|
61
|
+
"check:hover": "node dev/check.mjs dev/check-hover.ts",
|
|
59
62
|
"site:extras": "node dev/site-extras.mjs dist/demo",
|
|
60
63
|
"build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
61
64
|
"prepublishOnly": "npm run build:lib",
|