drawnui-react 0.1.0-preview.40 → 0.1.0-preview.42

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.
Files changed (42) hide show
  1. package/README.md +57 -0
  2. package/SKIPPED.md +2 -2
  3. package/dist/controls/SkiaEditor.js +5 -4
  4. package/dist/controls/SkiaImage.d.ts +5 -0
  5. package/dist/controls/SkiaImage.js +32 -5
  6. package/dist/controls/SkiaLabel.d.ts +17 -2
  7. package/dist/controls/SkiaLabel.js +38 -12
  8. package/dist/controls/SkiaLabelFps.d.ts +0 -3
  9. package/dist/controls/SkiaLabelFps.js +1 -11
  10. package/dist/controls/SkiaLayout.js +33 -2
  11. package/dist/controls/SkiaScroll.d.ts +17 -0
  12. package/dist/controls/SkiaScroll.js +51 -6
  13. package/dist/controls/SkiaShell.d.ts +282 -0
  14. package/dist/controls/SkiaShell.js +972 -0
  15. package/dist/controls/SkiaSprite.js +5 -1
  16. package/dist/core/Accessibility.d.ts +12 -0
  17. package/dist/core/Accessibility.js +62 -14
  18. package/dist/core/Canvas.d.ts +50 -8
  19. package/dist/core/Canvas.js +126 -25
  20. package/dist/core/DesignerActions.d.ts +32 -0
  21. package/dist/core/DesignerActions.js +68 -0
  22. package/dist/core/Gestures.d.ts +1 -0
  23. package/dist/core/Props.d.ts +11 -0
  24. package/dist/core/Props.js +44 -0
  25. package/dist/core/SkiaControl.d.ts +26 -3
  26. package/dist/core/SkiaControl.js +64 -13
  27. package/dist/core/SkiaEffect.d.ts +12 -1
  28. package/dist/core/SkiaEffect.js +35 -8
  29. package/dist/core/SkiaImageManager.d.ts +100 -18
  30. package/dist/core/SkiaImageManager.js +309 -64
  31. package/dist/core/Styles.js +7 -1
  32. package/dist/core/Super.d.ts +2 -0
  33. package/dist/core/Super.js +2 -0
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +2 -0
  36. package/dist/react/SkiaShell.d.ts +8 -74
  37. package/dist/react/SkiaShell.js +163 -514
  38. package/dist/react/index.d.ts +24 -1
  39. package/dist/react/index.js +32 -5
  40. package/dist/react/reconciler.d.ts +12 -0
  41. package/dist/react/reconciler.js +22 -46
  42. package/package.json +24 -2
@@ -0,0 +1,282 @@
1
+ import { Thickness } from "../core/Types";
2
+ import { SkiaControl } from "../core/SkiaControl";
3
+ import { SkiaLayer, type SkiaLayout } from "./SkiaLayout";
4
+ /** Arguments passed to a page (C# GoToAsync arguments / query string), e.g. `GoToAsync("detail", true, { id: 42 })` or `GoToAsync("detail?id=42")`. */
5
+ export type ShellArguments = Record<string, unknown>;
6
+ /** C# NavigationSource. */
7
+ export type NavigationSource = "Push" | "Pop";
8
+ /** C# SkiaShellNavigatingArgs: set Cancel to stop the navigation. */
9
+ export interface SkiaShellNavigatingArgs {
10
+ Route: string;
11
+ Source: NavigationSource;
12
+ Cancel: boolean;
13
+ View?: SkiaControl;
14
+ Previous?: SkiaControl;
15
+ }
16
+ /** C# SkiaShellNavigatedArgs. */
17
+ export interface SkiaShellNavigatedArgs {
18
+ Route: string;
19
+ Source: NavigationSource;
20
+ View?: SkiaControl;
21
+ }
22
+ /** "name?a=1&b=2" -> name + arguments (query values are strings). */
23
+ export declare function SplitRoute(route: string): {
24
+ name: string;
25
+ args: ShellArguments;
26
+ };
27
+ /** name + arguments -> "name?a=1" (only string / number / boolean values travel in the route, the rest stays in memory). */
28
+ export declare function BuildRoute(name: string, args?: ShellArguments): string;
29
+ /** C# OpenPopupAsync parameters. */
30
+ export interface PopupOptions {
31
+ animated?: boolean;
32
+ /** A tap outside the content closes the popup (default true). */
33
+ closeWhenBackgroundTapped?: boolean;
34
+ /** Dim + blur the page behind (default true). */
35
+ showOverlay?: boolean;
36
+ backgroundColor?: string;
37
+ }
38
+ /** C# PushModalAsync parameters. */
39
+ export interface ModalOptions {
40
+ /** The modal can be dragged down to close (default false). */
41
+ useGestures?: boolean;
42
+ animated?: boolean;
43
+ /** Dim + blur the page behind (C# freezeBackground; the frozen screenshot is not ported). */
44
+ freezeBackground?: boolean;
45
+ }
46
+ /** A shell tab: its root route and the label shown in the tab bar. */
47
+ export interface ShellTab {
48
+ route: string;
49
+ title: string;
50
+ }
51
+ /** C# SkiaShell static defaults (mutable). */
52
+ export declare const ShellDefaults: {
53
+ ToastBackgroundColor: string;
54
+ ToastTextColor: "#FFFFFF";
55
+ ToastTextFont: string;
56
+ ToastTextSize: number;
57
+ ToastTextMargins: number;
58
+ /** Default overlay tint behind popups / modals. */
59
+ PopupBackgroundColor: string;
60
+ /** Backdrop blur behind popups / modals, points. */
61
+ PopupsBackgroundBlur: number;
62
+ PopupsAnimationSpeed: number;
63
+ PopupsCancelAnimationsAfterMs: number;
64
+ ZIndexModals: number;
65
+ ZIndexPopups: number;
66
+ ZIndexToasts: number;
67
+ /** Accent of the selected tab. */
68
+ TabSelectedColor: string;
69
+ TabColor: string;
70
+ };
71
+ /**
72
+ * Content that puts itself into the place the shell made for it, instead of being a control the shell adds there (the
73
+ * React `<SkiaShell>` renders JSX this way).
74
+ */
75
+ export interface ShellContentHost {
76
+ /** The shell made room for the content: fill `parent` with it. */
77
+ AttachTo(parent: SkiaLayout): void;
78
+ /** The shell removed that room (a page popped, a popup closed): let go of the content. */
79
+ Detach(): void;
80
+ /** Resolves once the content is in place; the shell waits for it before it animates or reports the navigation. */
81
+ Ready?(): Promise<void>;
82
+ }
83
+ /** What the shell shows: a control, a function making one (built when shown), or a host filling the room itself. */
84
+ export type ShellContent = SkiaControl | (() => SkiaControl) | ShellContentHost;
85
+ /** Route name -> page factory receiving the navigation arguments (C# Routes). */
86
+ export type ShellRouteFactory = (args: ShellArguments) => ShellContent;
87
+ /**
88
+ * DrawnUi SkiaShell: a root page (or tabs) plus per-tab stacks of routed pages with a nav bar (pages slide in / out
89
+ * like SkiaViewSwitcher), popups (blurred + dimmed backdrop, scale + fade, tap outside to close), modals (full-screen
90
+ * SkiaDrawer from the bottom, optionally draggable), toasts (bottom banner, slide + fade, auto close). With
91
+ * `UseBrowserHistory` pages live in the URL hash and the browser back button behaves like C# GoBack (popup, then
92
+ * modal, then page). Content is a control, a function making one, or a ShellContentHost.
93
+ */
94
+ export declare class SkiaShell extends SkiaLayer {
95
+ constructor();
96
+ /** Page factories by route name; a factory receives the route's arguments. */
97
+ Routes: Record<string, ShellRouteFactory>;
98
+ /** Page push / pop slide duration in ms (C# SkiaViewSwitcher.PagesAnimationSpeed). */
99
+ PagesAnimationSpeed: number;
100
+ /** Slide + fade between tabs (C# SkiaViewSwitcher.AnimateTabs). */
101
+ AnimateTabs: boolean;
102
+ /** Tab switch duration in ms (C# TabsAnimationSpeed). */
103
+ TabsAnimationSpeed: number;
104
+ /** Before a page / popup / modal is pushed or popped; set e.Cancel = true to stop it (C# Navigating). */
105
+ Navigating?: (e: SkiaShellNavigatingArgs) => void;
106
+ /** After a page / popup / modal went upfront or was removed (C# Navigated). */
107
+ Navigated?: (e: SkiaShellNavigatedArgs) => void;
108
+ /** The current route changed (C# RouteChanged). */
109
+ RouteChanged?: (route: string) => void;
110
+ private titles?;
111
+ /** Title shown in the nav bar per route name; defaults to the route name. */
112
+ get Titles(): Record<string, string> | undefined;
113
+ set Titles(v: Record<string, string> | undefined);
114
+ private navBarHeight;
115
+ /** Nav bar height in points when a page is open. */
116
+ get NavBarHeight(): number;
117
+ set NavBarHeight(v: number);
118
+ private navBarColor;
119
+ get NavBarColor(): string;
120
+ set NavBarColor(v: string);
121
+ private pageBackgroundColor;
122
+ /** Opaque background of pushed pages (they slide over the page below). */
123
+ get PageBackgroundColor(): string;
124
+ set PageBackgroundColor(v: string);
125
+ private tabBarHeight;
126
+ get TabBarHeight(): number;
127
+ set TabBarHeight(v: number);
128
+ private tabBarColor;
129
+ get TabBarColor(): string;
130
+ set TabBarColor(v: string);
131
+ private insets?;
132
+ /** Safe-area insets (points) reserved above the nav bar and below the tab bar; default Super.Insets (C# Super.Insets). */
133
+ get Insets(): Thickness | undefined;
134
+ set Insets(v: Thickness | undefined);
135
+ private tabs?;
136
+ /** Bottom tab bar: one root route per tab, per-tab navigation stacks (C# SkiaViewSwitcher tabs). */
137
+ get Tabs(): ShellTab[] | undefined;
138
+ set Tabs(v: ShellTab[] | undefined);
139
+ private useBrowserHistory;
140
+ /** Mirror pages in the URL hash (#/route/route) and honour the browser back button (React extension, default true). */
141
+ get UseBrowserHistory(): boolean;
142
+ set UseBrowserHistory(v: boolean);
143
+ private rootContent?;
144
+ /** The root content, shown when nothing is pushed and no Tabs are set (C# RootContent). */
145
+ get RootContent(): ShellContent | undefined;
146
+ set RootContent(v: ShellContent | undefined);
147
+ private readonly containers;
148
+ private readonly tabRoots;
149
+ private readonly stacks;
150
+ private readonly popups;
151
+ private readonly modals;
152
+ private readonly toasts;
153
+ private tabBar?;
154
+ private tabCells;
155
+ private selected;
156
+ /** The page sliding out during a pop. */
157
+ private leaving?;
158
+ /** Pages sliding in: the page below stays visible meanwhile. */
159
+ private transitions;
160
+ /** The tab root leaving during an animated switch (C# PreviousVisibleView) and the slide direction. */
161
+ private tabTransition?;
162
+ private nextId;
163
+ private lastRoute?;
164
+ private started;
165
+ private unsubscribeInsets?;
166
+ /** What each chrome control was last given, so a new declaration changes only what differs (as React's props). */
167
+ private readonly declared;
168
+ /** Bumped whenever what the navigation reports changed (stack, overlays, tab). */
169
+ NavVersion: number;
170
+ /** Called after the stack, the overlays or the selected tab changed. */
171
+ protected OnChanged(): void;
172
+ /** The root of tab `index` (C#: built from its route). */
173
+ protected CreateTabRoot(index: number): ShellContent | undefined;
174
+ private get HasTabs();
175
+ private get Stack();
176
+ /** Index of the selected tab. */
177
+ get SelectedTab(): number;
178
+ /** Routes below the current page of the current tab, root excluded. */
179
+ get NavigationStack(): readonly string[];
180
+ /** Current route (with its query), "" for the root content. */
181
+ get Route(): string;
182
+ /** Arguments of the current page (query + explicit). */
183
+ get Arguments(): ShellArguments;
184
+ get PopupsCount(): number;
185
+ /** Open modals; a modal sliding out has left the stack. */
186
+ get ModalsCount(): number;
187
+ get ToastsCount(): number;
188
+ /** Something to go back from: a popup, a modal or a pushed page. */
189
+ get CanGoBack(): boolean;
190
+ /** Builds the control and sets its values as the React renderer would (styles first, then the values). */
191
+ private Create;
192
+ /** New values for a control the shell made: only the differences are applied. */
193
+ private Declare;
194
+ private Place;
195
+ /** A root replaced: the old one leaves its container (C# SetRoot), a control is not disposed. */
196
+ private Release;
197
+ /** Before the room of `content` is disposed: a host lets go of its content, a control is disposed with the room (C#). */
198
+ private Detach;
199
+ private Ready;
200
+ private get EffectiveInsets();
201
+ private get RootBottom();
202
+ /** A tabbed shell has no RootContent to start it: it is built at the first measure. */
203
+ Measure(widthConstraint: number, heightConstraint: number, scale: number): import("..").ScaledSize;
204
+ /** One container per tab (one without tabs) holds that tab's root; pushed pages are drawn over it. */
205
+ private EnsureContainers;
206
+ /** The tabs changed after the shell was built: new containers, roots and tab bar; the pushed pages stay. */
207
+ private RebuildContainers;
208
+ private RemoveContainer;
209
+ private SetRoot;
210
+ private ContainerProps;
211
+ /** The first page host in the shell's children: tab containers go before every page. */
212
+ private FirstPageHost;
213
+ private BuildTabBar;
214
+ private TabBarProps;
215
+ private TabLabelProps;
216
+ private RenderTabBar;
217
+ /** Applies the state to the chrome: containers, page hosts and their bars, tab bar. */
218
+ private RenderChrome;
219
+ private TitleProps;
220
+ private Notify;
221
+ /** C# NotifyAndCheckCanNavigate: raises Navigating, false when cancelled. */
222
+ private CanNavigate;
223
+ private NotifyNavigated;
224
+ private CheckRoute;
225
+ /** After the first build: the first RouteChanged, the insets, the browser history (deep link). */
226
+ private Start;
227
+ protected OnDisposing(): void;
228
+ private history;
229
+ private onPop?;
230
+ private get HistoryOn();
231
+ private HashFor;
232
+ private PushHistory;
233
+ /** A programmatic close of something that has a history entry goes through history.back(), so the URL stays in sync. */
234
+ private BackThroughHistory;
235
+ private ParseHash;
236
+ private StopHistory;
237
+ private StartHistory;
238
+ /** Builds a page host (content under its nav bar) for `route` in tab `tab` and adds it; it slides in from the right. */
239
+ private CreatePage;
240
+ private FirstOverlay;
241
+ private RemovePageHost;
242
+ /** Tab `tab` shows `routes` (a deep link, a typed hash): pages already there at their index stay, the rest are made. */
243
+ private ReplaceStack;
244
+ private SlideOut;
245
+ /** Pops the top page; false when Navigating cancelled it (C# NavigationSource.Pop). */
246
+ private PopPage;
247
+ /** Pushes a registered route; `route` may carry a query ("detail?id=42") and/or explicit arguments (C# GoToAsync(route, animate, arguments)). */
248
+ GoToAsync(route: string, animated?: boolean, args?: ShellArguments): Promise<void>;
249
+ /** C# GoBack: closes the top popup, else the top modal, else pops the page. */
250
+ GoBackAsync(animated?: boolean): Promise<void>;
251
+ /** Pops every page of every tab at once. */
252
+ PopToRootAsync(): Promise<void>;
253
+ /** Pops every page of the current tab (C# PopTabToRoot). */
254
+ PopTabToRootAsync(): Promise<void>;
255
+ /** Tabs (C# SkiaViewSwitcher.SelectedIndex): each tab keeps its own page stack. */
256
+ SelectTabAsync(index: number): Promise<void>;
257
+ private ClosePopupNow;
258
+ private ClosePopup;
259
+ private RemoveOverlay;
260
+ /** Shows `content` centered over the page (C# OpenPopupAsync): scales in, a tap outside closes it. */
261
+ OpenPopupAsync(content: ShellContent, options?: PopupOptions): Promise<void>;
262
+ /** Closes the top popup. */
263
+ ClosePopupAsync(animated?: boolean): Promise<void>;
264
+ /** Closes every popup, without animation. */
265
+ CloseAllPopups(): Promise<void>;
266
+ /**
267
+ * A modal leaves the modal stack the moment its close starts, whatever started it (PopModalAsync, a swipe, IsOpen =
268
+ * false): ModalsCount and CanGoBack drop it and Navigated Pop is raised; its drawer takes no more pans. It stays on
269
+ * screen until its slide ends (drawnui-cross 6s, C# SkiaShell.LeaveModalStack).
270
+ */
271
+ private LeaveModalStack;
272
+ private PopModalNow;
273
+ /** Shows `content` full screen in a drawer sliding up from the bottom (C# PushModalAsync). */
274
+ PushModalAsync(content: ShellContent, options?: ModalOptions): Promise<void>;
275
+ /** Closes the top modal. */
276
+ PopModalAsync(animated?: boolean): Promise<void>;
277
+ private CloseToast;
278
+ /** Removes every toast, without animation. */
279
+ CloseAllToasts(): Promise<void>;
280
+ /** Shows a banner at the bottom for `msShowTime` ms: markdown text, or any content. */
281
+ ShowToast(content: string | ShellContent, msShowTime?: number): void;
282
+ }