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.
Files changed (117) hide show
  1. package/README.md +229 -22
  2. package/SKIPPED.md +38 -29
  3. package/dist/controls/AnimatedFramesRenderer.d.ts +9 -0
  4. package/dist/controls/AnimatedFramesRenderer.js +18 -1
  5. package/dist/controls/DrawnGame.d.ts +44 -0
  6. package/dist/controls/DrawnGame.js +82 -0
  7. package/dist/controls/GridStructure.d.ts +25 -3
  8. package/dist/controls/GridStructure.js +81 -5
  9. package/dist/controls/SkiaBackdrop.d.ts +8 -2
  10. package/dist/controls/SkiaBackdrop.js +42 -14
  11. package/dist/controls/SkiaButton.d.ts +17 -3
  12. package/dist/controls/SkiaButton.js +26 -8
  13. package/dist/controls/SkiaCarousel.d.ts +22 -3
  14. package/dist/controls/SkiaCarousel.js +85 -9
  15. package/dist/controls/SkiaCheckbox.d.ts +0 -1
  16. package/dist/controls/SkiaCheckbox.js +2 -7
  17. package/dist/controls/SkiaDrawer.d.ts +15 -0
  18. package/dist/controls/SkiaDrawer.js +42 -7
  19. package/dist/controls/SkiaEditor.d.ts +51 -2
  20. package/dist/controls/SkiaEditor.js +292 -58
  21. package/dist/controls/SkiaGif.d.ts +7 -0
  22. package/dist/controls/SkiaGif.js +25 -4
  23. package/dist/controls/SkiaImage.d.ts +10 -0
  24. package/dist/controls/SkiaImage.js +80 -19
  25. package/dist/controls/SkiaLabel.d.ts +200 -11
  26. package/dist/controls/SkiaLabel.js +925 -93
  27. package/dist/controls/SkiaLabelFps.d.ts +12 -0
  28. package/dist/controls/SkiaLabelFps.js +35 -0
  29. package/dist/controls/SkiaLayout.d.ts +89 -9
  30. package/dist/controls/SkiaLayout.js +397 -23
  31. package/dist/controls/SkiaLottie.js +5 -3
  32. package/dist/controls/SkiaProgress.d.ts +2 -1
  33. package/dist/controls/SkiaProgress.js +8 -5
  34. package/dist/controls/SkiaRadioButton.d.ts +2 -0
  35. package/dist/controls/SkiaRadioButton.js +16 -4
  36. package/dist/controls/SkiaRichLabel.d.ts +1 -1
  37. package/dist/controls/SkiaRichLabel.js +11 -1
  38. package/dist/controls/SkiaScroll.d.ts +86 -7
  39. package/dist/controls/SkiaScroll.js +361 -40
  40. package/dist/controls/SkiaScrollBar.d.ts +27 -0
  41. package/dist/controls/SkiaScrollBar.js +51 -2
  42. package/dist/controls/SkiaShaderCarousel.d.ts +11 -1
  43. package/dist/controls/SkiaShaderCarousel.js +27 -5
  44. package/dist/controls/SkiaShape.d.ts +15 -2
  45. package/dist/controls/SkiaShape.js +57 -10
  46. package/dist/controls/SkiaShell.d.ts +282 -0
  47. package/dist/controls/SkiaShell.js +972 -0
  48. package/dist/controls/SkiaSlider.d.ts +20 -2
  49. package/dist/controls/SkiaSlider.js +61 -7
  50. package/dist/controls/SkiaSprite.d.ts +4 -0
  51. package/dist/controls/SkiaSprite.js +27 -11
  52. package/dist/controls/SkiaSvg.d.ts +4 -0
  53. package/dist/controls/SkiaSvg.js +28 -4
  54. package/dist/controls/SkiaSwitch.d.ts +0 -1
  55. package/dist/controls/SkiaSwitch.js +4 -8
  56. package/dist/controls/SkiaToggle.d.ts +25 -5
  57. package/dist/controls/SkiaToggle.js +58 -5
  58. package/dist/controls/SnappingLayout.d.ts +12 -1
  59. package/dist/controls/SnappingLayout.js +21 -2
  60. package/dist/controls/TooltipStyle.d.ts +52 -0
  61. package/dist/controls/TooltipStyle.js +88 -0
  62. package/dist/core/Accessibility.d.ts +162 -11
  63. package/dist/core/Accessibility.js +882 -22
  64. package/dist/core/Animators.d.ts +37 -1
  65. package/dist/core/Animators.js +102 -9
  66. package/dist/core/Canvas.d.ts +307 -8
  67. package/dist/core/Canvas.js +1202 -66
  68. package/dist/core/ControlStyle.d.ts +2 -0
  69. package/dist/core/ControlStyle.js +2 -0
  70. package/dist/core/DesignerActions.d.ts +32 -0
  71. package/dist/core/DesignerActions.js +68 -0
  72. package/dist/core/Easing.d.ts +12 -1
  73. package/dist/core/Easing.js +25 -1
  74. package/dist/core/Gestures.d.ts +86 -2
  75. package/dist/core/Gestures.js +184 -4
  76. package/dist/core/Hover.d.ts +51 -0
  77. package/dist/core/Hover.js +140 -0
  78. package/dist/core/ImageEffects.d.ts +2 -0
  79. package/dist/core/ImageEffects.js +2 -0
  80. package/dist/core/KeyboardManager.d.ts +40 -0
  81. package/dist/core/KeyboardManager.js +98 -8
  82. package/dist/core/PopupWindows.d.ts +94 -0
  83. package/dist/core/PopupWindows.js +207 -0
  84. package/dist/core/Props.d.ts +11 -0
  85. package/dist/core/Props.js +44 -0
  86. package/dist/core/ScrollAnimators.d.ts +6 -0
  87. package/dist/core/ScrollAnimators.js +16 -1
  88. package/dist/core/Shaping.d.ts +40 -0
  89. package/dist/core/Shaping.js +224 -0
  90. package/dist/core/SkiaControl.d.ts +306 -13
  91. package/dist/core/SkiaControl.js +681 -75
  92. package/dist/core/SkiaEffect.d.ts +29 -1
  93. package/dist/core/SkiaEffect.js +78 -16
  94. package/dist/core/SkiaImageManager.d.ts +101 -18
  95. package/dist/core/SkiaImageManager.js +318 -63
  96. package/dist/core/Styles.js +7 -1
  97. package/dist/core/Super.d.ts +33 -2
  98. package/dist/core/Super.js +58 -12
  99. package/dist/core/TextInputProxy.d.ts +31 -1
  100. package/dist/core/TextInputProxy.js +97 -15
  101. package/dist/core/Tooltips.d.ts +71 -0
  102. package/dist/core/Tooltips.js +205 -0
  103. package/dist/core/Types.d.ts +11 -1
  104. package/dist/core/Types.js +32 -1
  105. package/dist/core/ViewsAdapter.d.ts +7 -2
  106. package/dist/core/ViewsAdapter.js +10 -3
  107. package/dist/index.d.ts +8 -0
  108. package/dist/index.js +8 -0
  109. package/dist/react/SkiaShell.d.ts +8 -74
  110. package/dist/react/SkiaShell.js +163 -475
  111. package/dist/react/index.d.ts +48 -4
  112. package/dist/react/index.js +210 -43
  113. package/dist/react/reconciler.d.ts +32 -0
  114. package/dist/react/reconciler.js +71 -40
  115. package/dist/vite/index.d.ts +9 -0
  116. package/dist/vite/index.js +36 -3
  117. package/package.json +103 -5
@@ -1,3 +1,4 @@
1
+ import { DefaultAccent } from "../core/ControlStyle";
1
2
  import { Colors, Thickness } from "../core/Types";
2
3
  import { SkiaShape } from "./SkiaShape";
3
4
  import { SkiaSvg } from "./SkiaSvg";
@@ -12,7 +13,7 @@ export class SkiaCheckbox extends SkiaToggle {
12
13
  FrameOn;
13
14
  ViewCheckOn;
14
15
  colorCheckOn;
15
- static DefaultAccent = "#DC143C";
16
+ static DefaultAccent = DefaultAccent;
16
17
  static DefaultOutline = "#8E959D";
17
18
  /** Color of the check mark (inner square for the default look). */
18
19
  get ColorCheckOn() { return this.colorCheckOn ?? (this.UsingControlStyle === "Unset" ? SkiaCheckbox.DefaultAccent : Colors.White); }
@@ -27,12 +28,6 @@ export class SkiaCheckbox extends SkiaToggle {
27
28
  };
28
29
  return table[this.UsingControlStyle]?.[name];
29
30
  }
30
- SetContentSize(w, h) {
31
- if (this.WidthRequest < 0)
32
- this.WidthRequest = w;
33
- if (this.HeightRequest < 0)
34
- this.HeightRequest = h;
35
- }
36
31
  CreateDefaultContent() {
37
32
  const off = new SkiaShape();
38
33
  off.Tag = "FrameOff";
@@ -9,6 +9,8 @@ import { SnappingLayout } from "./SnappingLayout";
9
9
  * so it must be aligned to its edge by the parent (VerticalOptions="End" for FromBottom, etc.).
10
10
  */
11
11
  export declare class SkiaDrawer extends SnappingLayout {
12
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
13
+ protected ReceivesHoverByDefault(): boolean;
12
14
  Direction: DrawerDirection;
13
15
  /** Points that stay visible when closed. */
14
16
  HeaderSize: number;
@@ -27,6 +29,13 @@ export declare class SkiaDrawer extends SnappingLayout {
27
29
  constructor();
28
30
  get IsOpen(): boolean;
29
31
  set IsOpen(v: boolean);
32
+ /**
33
+ * The drawer starts moving from open to closed (IsOpen = false, a swipe release, code): raised once the move is under
34
+ * way, before it ends (C# internal ClosingStarted; SkiaShell takes a modal out of its stack here).
35
+ */
36
+ ClosingStarted?: (sender: SkiaDrawer) => void;
37
+ private headingOpen;
38
+ protected ScrollToOffset(target: SKPoint, velocity: SKPoint, animate: boolean): boolean;
30
39
  Open(): void;
31
40
  Close(): void;
32
41
  get Horizontal(): boolean;
@@ -42,5 +51,11 @@ export declare class SkiaDrawer extends SnappingLayout {
42
51
  private ReportFromSnap;
43
52
  CheckTransitionEnded(): boolean;
44
53
  ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
54
+ /**
55
+ * A Down stops a running move to a snap, so a pan can take the drawer from where it is. When the touch ends without a
56
+ * pan, the drawer finishes that move to the snap it was sent to (IsOpen changed in code, or a released swipe), instead
57
+ * of staying between its snaps (C# FinishStoppedMove).
58
+ */
59
+ private FinishStoppedMove;
45
60
  protected DefaultAccessibilityLabel(): string | undefined;
46
61
  }
@@ -7,6 +7,8 @@ import { SnappingLayout } from "./SnappingLayout";
7
7
  * so it must be aligned to its edge by the parent (VerticalOptions="End" for FromBottom, etc.).
8
8
  */
9
9
  export class SkiaDrawer extends SnappingLayout {
10
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
11
+ ReceivesHoverByDefault() { return true; }
10
12
  Direction = "FromBottom";
11
13
  /** Points that stay visible when closed. */
12
14
  HeaderSize = 0;
@@ -33,6 +35,23 @@ export class SkiaDrawer extends SnappingLayout {
33
35
  if (this.SnapPoints.length === 2)
34
36
  this.ScrollToOffset(v ? this.SnapPoints[0] : this.SnapPoints[1], SKPoint.Empty, this.Animated && this.wasDrawn);
35
37
  }
38
+ /**
39
+ * The drawer starts moving from open to closed (IsOpen = false, a swipe release, code): raised once the move is under
40
+ * way, before it ends (C# internal ClosingStarted; SkiaShell takes a modal out of its stack here).
41
+ */
42
+ ClosingStarted;
43
+ // the state of the snap the drawer was last sent to; IsOpen catches up with it when the move ends (C# _headingOpen)
44
+ headingOpen = false;
45
+ ScrollToOffset(target, velocity, animate) {
46
+ const wasHeadingOpen = this.headingOpen;
47
+ if (!super.ScrollToOffset(target, velocity, animate))
48
+ return false;
49
+ const hidden = this.SnapPoints[1];
50
+ this.headingOpen = this.SnapPoints.length < 2 || target.X !== hidden.X || target.Y !== hidden.Y;
51
+ if (wasHeadingOpen && !this.headingOpen)
52
+ this.ClosingStarted?.(this);
53
+ return true;
54
+ }
36
55
  Open() { this.IsOpen = true; }
37
56
  Close() { this.IsOpen = false; }
38
57
  get Horizontal() { return this.Direction === "FromLeft" || this.Direction === "FromRight"; }
@@ -106,14 +125,15 @@ export class SkiaDrawer extends SnappingLayout {
106
125
  const consumedDefault = this.BlockGesturesBelow ? this : null;
107
126
  const scale = this.RenderingScale;
108
127
  const e = args.Event;
109
- // the drawer sits in a full-size layer: touches outside its (translated) box are not ours
110
- const local = apply.MappedLocation;
111
- const hit = this.HitIsInside(local.X + apply.ChildOffset.X, local.Y + apply.ChildOffset.Y);
128
+ // touches outside its content are not ours, also when the drawer is larger than the panel it slides (C# hitContent:
129
+ // CheckChildGestureHit(Content)); a press there closes it with AutoClose
130
+ const point = new SKPoint(apply.MappedLocation.X + apply.ChildOffset.X, apply.MappedLocation.Y + apply.ChildOffset.Y);
131
+ const hitContent = this.GetGestureListeners().some((c) => c.IsVisible && !c.InputTransparent && this.IsGestureForChild(c, point));
112
132
  if (!this.hadDown && args.Type !== "Up") {
113
- if (!hit) {
114
- if (this.AutoClose && this.isOpen && !this.InTransition)
133
+ if (!hitContent) {
134
+ if (this.AutoClose && this.isOpen && !this.InTransition && (args.Type === "Down" || args.Type === "Tapped"))
115
135
  this.IsOpen = false;
116
- return null;
136
+ return consumedDefault; // a drawer that blocks gestures below still does (C# OnSkiaGestureEvent)
117
137
  }
118
138
  }
119
139
  let passed = false;
@@ -190,8 +210,10 @@ export class SkiaDrawer extends SnappingLayout {
190
210
  }
191
211
  case "Up": {
192
212
  this.hadDown = false;
193
- if (this.childWasTapped || !this.IsUserPanning)
213
+ if (this.childWasTapped || !this.IsUserPanning) {
214
+ this.FinishStoppedMove();
194
215
  break;
216
+ }
195
217
  const final = this.velocityAccumulator.CalculateFinalVelocity(3000);
196
218
  const v = this.Horizontal ? new SKPoint(final.X, 0) : new SKPoint(0, final.Y);
197
219
  this.CurrentSnap = this.CurrentPosition;
@@ -208,5 +230,18 @@ export class SkiaDrawer extends SnappingLayout {
208
230
  return passToChildren();
209
231
  return consumedDefault;
210
232
  }
233
+ /**
234
+ * A Down stops a running move to a snap, so a pan can take the drawer from where it is. When the touch ends without a
235
+ * pan, the drawer finishes that move to the snap it was sent to (IsOpen changed in code, or a released swipe), instead
236
+ * of staying between its snaps (C# FinishStoppedMove).
237
+ */
238
+ FinishStoppedMove() {
239
+ const target = this.CurrentSnap, at = this.CurrentPosition;
240
+ if (this.IsSnapAnimating || !this.SnapPoints.some((p) => p.X === target.X && p.Y === target.Y)
241
+ || (Math.abs(at.X - target.X) <= 1 && Math.abs(at.Y - target.Y) <= 1))
242
+ return;
243
+ this.CurrentSnap = at;
244
+ this.ScrollToOffset(target, SKPoint.Empty, this.CanAnimate);
245
+ }
211
246
  DefaultAccessibilityLabel() { return this.isOpen ? "Drawer open" : "Drawer closed"; }
212
247
  }
@@ -1,4 +1,4 @@
1
- import type { DrawingContext, SkiaControl } from "../core/SkiaControl";
1
+ import { type DrawingContext, SkiaControl } from "../core/SkiaControl";
2
2
  import { type GestureEventProcessingInfo, type SkiaGesturesParameters } from "../core/Gestures";
3
3
  import { type PrebuiltControlStyle } from "../core/ControlStyle";
4
4
  import { type Color, type DrawTextAlignment, type ReturnType, ScaledSize, type SkiaEditorKeyboard, type SkiaGradient, type TextAlignment } from "../core/Types";
@@ -51,6 +51,8 @@ export declare class SkiaEditor extends SkiaShape {
51
51
  CanShowCursor: boolean;
52
52
  SelectionColor: Color;
53
53
  private cursorPosition;
54
+ /** A caret position was given (by the app, a tap, a selection): focusing keeps it; otherwise focusing puts the caret at the end. */
55
+ private cursorPlaced;
54
56
  private selectionLength;
55
57
  private isFocused;
56
58
  private controlStyle;
@@ -58,7 +60,8 @@ export declare class SkiaEditor extends SkiaShape {
58
60
  private readonly placeholder;
59
61
  private scrollX;
60
62
  private scrollY;
61
- private blink;
63
+ /** The caret blinks on a timer, asleep between blinks: no frame runs while it waits (DrawnUi.Rust editor_rules). */
64
+ private blinkTimer;
62
65
  private caretVisible;
63
66
  private subscribed;
64
67
  private stubSelectionStop;
@@ -70,6 +73,12 @@ export declare class SkiaEditor extends SkiaShape {
70
73
  private styleApplied;
71
74
  private layoutVersion;
72
75
  private boxes;
76
+ /** The glyph box starting at a text index, and the one ending at it. */
77
+ private readonly boxAt;
78
+ private readonly boxEnd;
79
+ /** Grapheme boundaries of the text, the places a caret may stand. */
80
+ private stops;
81
+ private stopsText;
73
82
  constructor();
74
83
  get Text(): string;
75
84
  set Text(v: string);
@@ -99,9 +108,14 @@ export declare class SkiaEditor extends SkiaShape {
99
108
  get ShouldSubmitOnEnter(): boolean;
100
109
  /** Caret index (UTF-16 units) = the left edge of the selection when one exists. */
101
110
  get CursorPosition(): number;
111
+ /** A position from app code as a whole number: beyond the text (MAX_SAFE_INTEGER, Infinity) is the end, NaN is 0. */
112
+ private static Whole;
102
113
  set CursorPosition(v: number);
103
114
  get SelectionLength(): number;
104
115
  set SelectionLength(v: number);
116
+ /** Shows the caret for a full half second, then blinks every 500 ms; while the window is inactive no caret, no timer. */
117
+ private StartBlink;
118
+ private StopBlink;
105
119
  private OnCursorMoved;
106
120
  get IsFocused(): boolean;
107
121
  set IsFocused(v: boolean);
@@ -121,14 +135,39 @@ export declare class SkiaEditor extends SkiaShape {
121
135
  /** Keeps the caret inside the padded box by scrolling the label (C#: SkiaScroll under the label). */
122
136
  private ScrollToCaret;
123
137
  private Boxes;
138
+ private Stops;
139
+ /** The laid-out line a caret index belongs to: the line holding the character before it, else the one starting at it. */
140
+ private static LineOf;
141
+ /** Where the caret before character `index` stands (label pixels): its x, the direction of the text there, its line box. */
142
+ private CaretPlace;
124
143
  /** Rect of the caret before character `index` (label pixels), or undefined before the first layout. */
125
144
  private CaretRectLabelPx;
145
+ /** The grapheme boundary of a line whose caret x is nearest to `x` (a tie: the smaller index). */
146
+ private NearestStop;
126
147
  /** C# GetCursorPosition: the text index nearest to a point in label pixels. */
127
148
  private HitTestIndex;
149
+ /**
150
+ * Left / Right from a caret index: the grapheme boundary on its line whose caret x is nearest that way (equal x: the
151
+ * one logically nearest); at the visual edge of the line one grapheme logically, forward for Right in a
152
+ * left-to-right paragraph and backward in a right-to-left one (Left the other way round).
153
+ */
154
+ private VisualTarget;
128
155
  private LabelPoint;
129
156
  protected Paint(ctx: DrawingContext): void;
157
+ /** The press now down is not the main button's. */
158
+ private otherButtonPress;
130
159
  ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
160
+ /** The canvas gives or takes the focus (a tap elsewhere): an editor always takes it. */
161
+ SetFrameworkFocus(focus: boolean): boolean;
162
+ /** A text field is a Tab stop by default, like a native text box, with no Tapped handler needed. */
163
+ protected DefaultAccessibilityCanInteract(): boolean;
164
+ /** Keyboard navigation reached the field (Tab) or left it: take the caret and the input sink like a native text box, or release them. */
165
+ OnAccessibilityFocused(focused: boolean): void;
166
+ /** Enter / Space on the field while it has no caret start editing; while editing they are text. */
131
167
  OnAccessibilityActivated(): void;
168
+ /** While editing, arrows, Home / End and PageUp / PageDown belong to the text: they never move a surrounding group. */
169
+ OnAccessibilityKey(_key: string): boolean;
170
+ /** The typed text, else the placeholder. A password field never exposes its text: only the placeholder (C# SkiaEditor). */
132
171
  protected DefaultAccessibilityLabel(): string | undefined;
133
172
  Submit(): void;
134
173
  private ExecuteSubmit;
@@ -144,6 +183,11 @@ export declare class SkiaEditor extends SkiaShape {
144
183
  PasteFromClipboard(): void;
145
184
  private ReplaceSelection;
146
185
  private SetFocusNative;
186
+ private windowCanvas?;
187
+ /** The window lost the keyboard: the caret hides and stops blinking (no redraws); back: it shows again in this field. */
188
+ private readonly onWindowActive;
189
+ /** Removed from the canvas while focused: the editing ends (caret timer, keys, text proxy). */
190
+ OnLeftCanvas(): void;
147
191
  private OnKeyDown;
148
192
  StubTypeText(value: string): void;
149
193
  StubPressEnter(splitLine?: boolean, shift?: boolean): void;
@@ -151,6 +195,11 @@ export declare class SkiaEditor extends SkiaShape {
151
195
  StubDelete(count?: number): void;
152
196
  /** Arrow / Home / End: the anchor stays, the moving edge follows (shift), or the selection collapses in the move direction. */
153
197
  StubMoveCursor(delta: number, extendSelection?: boolean): void;
198
+ /**
199
+ * Arrow Left (-1) / Right (1): visual moves, as native text fields (see VisualTarget). Without Shift a selection
200
+ * collapses to its visually left (Left) or right (Right) edge; with Shift its moving edge moves.
201
+ */
202
+ MoveVisual(dir: -1 | 1, extendSelection?: boolean): void;
154
203
  StubSelectRange(start: number, length: number): void;
155
204
  StubSelectAll(): void;
156
205
  /** Up / Down keep the caret x on the neighbouring line (C# HandleVerticalArrow). */