drawnui-react 0.1.0-preview.42 → 0.1.0-preview.44
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 +49 -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 +20 -2
- package/dist/controls/SkiaLabel.d.ts +68 -2
- package/dist/controls/SkiaLabel.js +368 -8
- package/dist/controls/SkiaLabelFps.d.ts +3 -4
- package/dist/controls/SkiaLabelFps.js +11 -7
- package/dist/controls/SkiaScroll.d.ts +34 -2
- package/dist/controls/SkiaScroll.js +99 -3
- package/dist/controls/SkiaShape.d.ts +2 -0
- package/dist/controls/SkiaShape.js +7 -0
- package/dist/core/Accessibility.d.ts +18 -13
- package/dist/core/Accessibility.js +175 -29
- package/dist/core/Canvas.d.ts +91 -6
- package/dist/core/Canvas.js +500 -29
- package/dist/core/Gestures.d.ts +10 -1
- package/dist/core/Gestures.js +12 -1
- package/dist/core/PopupWindows.js +2 -0
- package/dist/core/ScrollAnimators.d.ts +6 -0
- package/dist/core/ScrollAnimators.js +7 -1
- package/dist/core/SkiaControl.d.ts +3 -2
- package/dist/core/SkiaControl.js +4 -2
- package/dist/core/SkiaImageManager.d.ts +7 -6
- package/dist/core/SkiaImageManager.js +20 -10
- package/dist/core/Super.d.ts +2 -0
- package/dist/core/Super.js +2 -9
- package/dist/core/TextInputProxy.d.ts +31 -1
- package/dist/core/TextInputProxy.js +97 -15
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +43 -36
- package/package.json +21 -4
package/dist/react/index.js
CHANGED
|
@@ -171,11 +171,17 @@ const A11Y_CSS = `
|
|
|
171
171
|
.drawnui-a11y-node::selection,.drawnui-a11y-node *::selection{background:transparent;color:transparent}
|
|
172
172
|
.drawnui-a11y-node:focus{outline:none}
|
|
173
173
|
.drawnui-a11y-node:focus-visible{outline:3px solid rgba(13,110,253,.85);outline-offset:1px;border-radius:3px}
|
|
174
|
-
.drawnui-a11y-text{overflow:visible}
|
|
175
|
-
.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}
|
|
176
|
-
.drawnui-a11y-text>span::selection{background:rgba(110,168,254,.55);color:transparent}
|
|
177
174
|
`;
|
|
178
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;
|
|
179
185
|
/**
|
|
180
186
|
* Invisible ARIA elements mirroring the accessible drawn controls, positioned over the canvas (the DrawnUi.Blazor
|
|
181
187
|
* overlay). Improvement over DrawnUi.Blazor: `pointer-events:none`, so hover and every pointer gesture still reach the
|
|
@@ -218,16 +224,40 @@ function AccessibilityOverlay({ view }) {
|
|
|
218
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
|
|
219
225
|
// thrown to the top of the page and the next Tab starts from the canvas. A focus the user moved away stays away.
|
|
220
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);
|
|
221
230
|
useLayoutEffect(() => {
|
|
231
|
+
const previous = previousNodes.current;
|
|
232
|
+
previousNodes.current = nodes;
|
|
222
233
|
const id = focusedId.current;
|
|
223
234
|
if (!id || nodes.some((n) => n.Id === id))
|
|
224
235
|
return;
|
|
225
236
|
focusedId.current = 0;
|
|
226
|
-
|
|
227
|
-
|
|
237
|
+
const mgr = view.AccessibilityManager;
|
|
238
|
+
if (mgr.FocusedNode?.AccessibilityId === id)
|
|
239
|
+
mgr.NotifyFocused(undefined);
|
|
228
240
|
const active = document.activeElement;
|
|
229
241
|
if (active && active !== document.body)
|
|
230
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
|
+
}
|
|
231
261
|
overlayRef.current?.parentElement?.focus({ preventScroll: true });
|
|
232
262
|
}, [nodes]);
|
|
233
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
|
|
@@ -247,34 +277,8 @@ function AccessibilityOverlay({ view }) {
|
|
|
247
277
|
document.addEventListener("keydown", onKey, true);
|
|
248
278
|
return () => document.removeEventListener("keydown", onKey, true);
|
|
249
279
|
}, [view]);
|
|
250
|
-
// selectable text spans take pointer events: the wheel over them is re-dispatched to the canvas so drawn scrolls keep working
|
|
251
280
|
const overlayRef = useRef(null);
|
|
252
|
-
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
const el = overlayRef.current;
|
|
255
|
-
if (!el)
|
|
256
|
-
return;
|
|
257
|
-
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 })); };
|
|
258
|
-
el.addEventListener("wheel", forward, { passive: false });
|
|
259
|
-
return () => el.removeEventListener("wheel", forward);
|
|
260
|
-
}, [view, hasNodes]);
|
|
261
|
-
// the browser lays the invisible lines out with its own shaping; stretch each line with letter-spacing to the drawn width
|
|
262
|
-
// so the selection highlight covers the drawn glyphs end to end
|
|
263
|
-
useLayoutEffect(() => {
|
|
264
|
-
const el = overlayRef.current;
|
|
265
|
-
if (!el)
|
|
266
|
-
return;
|
|
267
|
-
for (const span of el.querySelectorAll(".drawnui-a11y-text>span")) {
|
|
268
|
-
const want = parseFloat(span.dataset.w ?? "0"), n = (span.textContent ?? "").replace(/\n$/, "").length - 1;
|
|
269
|
-
span.style.letterSpacing = "0px";
|
|
270
|
-
if (want <= 0 || n <= 0)
|
|
271
|
-
continue;
|
|
272
|
-
const have = span.getBoundingClientRect().width;
|
|
273
|
-
if (Math.abs(have - want) > 0.5)
|
|
274
|
-
span.style.letterSpacing = `${(want - have) / n}px`;
|
|
275
|
-
}
|
|
276
|
-
}, [nodes]);
|
|
277
|
-
if (!hasNodes)
|
|
281
|
+
if (nodes.length === 0)
|
|
278
282
|
return null;
|
|
279
283
|
// the browser scrolls an overflow:hidden container to reveal a focused child; the overlay must stay pinned to the canvas
|
|
280
284
|
const pin = (e) => { e.currentTarget.scrollTop = 0; e.currentTarget.scrollLeft = 0; };
|
|
@@ -303,14 +307,19 @@ function AccessibilityOverlay({ view }) {
|
|
|
303
307
|
if (next)
|
|
304
308
|
elementOf(next.AccessibilityId)?.focus({ preventScroll: true });
|
|
305
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();
|
|
306
313
|
else if (NAVIGATION_KEYS.has(e.key) && SkiaAccessibilityManager.Key(n.Source, e.key)) {
|
|
307
314
|
e.preventDefault();
|
|
308
315
|
KeyboardManager.MarkKeyHandled(e.nativeEvent.code);
|
|
309
316
|
}
|
|
310
317
|
}, onFocus: (e) => {
|
|
311
318
|
focusedId.current = n.Id;
|
|
319
|
+
focusedLayer.current = LayerOf(n.Source);
|
|
312
320
|
pin({ currentTarget: e.currentTarget.parentElement });
|
|
313
|
-
|
|
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));
|
|
314
323
|
if (tabbingOut.current === n.Id)
|
|
315
324
|
tabbingOut.current = 0; // leaving a text field: it keeps no caret
|
|
316
325
|
else
|
|
@@ -324,9 +333,7 @@ function AccessibilityOverlay({ view }) {
|
|
|
324
333
|
return; // a text field moved DOM focus to its own input
|
|
325
334
|
n.Source.OnAccessibilityFocused(false);
|
|
326
335
|
n.Source.NotifyAccessibilityFocused(false);
|
|
327
|
-
}, children: n.Label }, n.Id)) :
|
|
328
|
-
// AccessibilityTextSelectable: one positioned span per drawn line, in the drawn font, so the browser selects and copies it like HTML
|
|
329
|
-
_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)) : (
|
|
330
337
|
// static text is exposed as real (transparent) text content; aria-label only for roles that need a name
|
|
331
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));
|
|
332
339
|
})] }));
|
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.44",
|
|
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)",
|
|
@@ -123,6 +123,10 @@
|
|
|
123
123
|
"check:label-span-effects": "node dev/check.mjs dev/check-label-span-effects.ts",
|
|
124
124
|
"check:animator-isolation": "node dev/check.mjs dev/check-animator-isolation.ts",
|
|
125
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:fps-label": "node dev/check.mjs dev/check-fps-label.ts",
|
|
129
|
+
"check:release-velocity": "node dev/check.mjs dev/check-release-velocity.ts",
|
|
126
130
|
"check:quiet-animations": "node dev/check.mjs dev/check-quiet-animations.ts",
|
|
127
131
|
"check:skew-sign": "node dev/check.mjs dev/check-skew-sign.ts",
|
|
128
132
|
"check:styles-code": "node dev/check.mjs dev/check-styles-code.ts",
|
|
@@ -137,12 +141,25 @@
|
|
|
137
141
|
"check:parent-independent": "node dev/check.mjs dev/check-parent-independent.ts",
|
|
138
142
|
"check:update-while-recording": "node dev/check.mjs dev/check-update-while-recording.ts",
|
|
139
143
|
"check:image-cache": "node dev/check.mjs dev/check-image-cache.ts",
|
|
140
|
-
"browser:canvas-contexts": "node dev/check-canvas-contexts.mjs"
|
|
144
|
+
"browser:canvas-contexts": "node dev/check-canvas-contexts.mjs",
|
|
145
|
+
"check:editor-wheel": "node dev/check.mjs dev/check-editor-wheel.ts",
|
|
146
|
+
"check:reading-order": "node dev/check.mjs dev/check-reading-order.ts",
|
|
147
|
+
"check:editor-rightpress": "node dev/check.mjs dev/check-editor-rightpress.ts",
|
|
148
|
+
"browser:touch-contextmenu": "node dev/check-touch-contextmenu.mjs",
|
|
149
|
+
"browser:text-selection": "node dev/check-text-selection.mjs",
|
|
150
|
+
"browser:tab-scroll": "node dev/check-tab-scroll.mjs",
|
|
151
|
+
"check:recycled-doublebuffer": "node dev/check.mjs dev/check-recycled-doublebuffer.ts",
|
|
152
|
+
"check:add3d-framing": "node dev/check.mjs dev/check-add3d-framing.ts",
|
|
153
|
+
"check:label-selection": "node dev/check.mjs dev/check-label-selection.ts",
|
|
154
|
+
"check:frame-errors": "node dev/check.mjs dev/check-frame-errors.ts",
|
|
155
|
+
"browser:editor-keyboard": "node dev/check-editor-keyboard.mjs",
|
|
156
|
+
"browser:double-tap": "node dev/check-double-tap.mjs",
|
|
157
|
+
"check:scroll-keyboard": "node dev/check.mjs dev/check-scroll-keyboard.ts"
|
|
141
158
|
},
|
|
142
159
|
"peerDependencies": {
|
|
143
160
|
"playwright-core": ">=1.40",
|
|
144
|
-
"react": "^
|
|
145
|
-
"react-dom": "^
|
|
161
|
+
"react": "^19.2.0",
|
|
162
|
+
"react-dom": "^19.2.0",
|
|
146
163
|
"vite": ">=5"
|
|
147
164
|
},
|
|
148
165
|
"peerDependenciesMeta": {
|