nitro-ui-solid 0.0.1 → 0.1.0-preview.0
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/LICENSE +21 -0
- package/dist/compiler.d.ts +5 -0
- package/dist/compiler.js +33 -0
- package/dist/index.d.ts +1001 -0
- package/dist/index.js +2134 -0
- package/dist/jsx-runtime.d.ts +9 -0
- package/package.json +55 -2
- package/README.md +0 -3
- package/printName.ts +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1001 @@
|
|
|
1
|
+
import "nitro-ui-runtime";
|
|
2
|
+
import { Accessor, Element, Errored, For, Loading, Match, Repeat, Reveal, Show, Switch, createComponent } from "solid-js";
|
|
3
|
+
import { Application, Application as Application$1, ImageView as ImageView$1, Label as Label$1, MaskedView as MaskedView$1, ScrollView as ScrollView$1, ScrollViewContent as ScrollViewContent$1, TextInput as TextInput$1, View as View$2, ViewController, ViewController as ViewController$1, Window, WindowScene } from "nitro-ui-renderer/hybrids";
|
|
4
|
+
import { RendererEffectOptions } from "@solidjs/universal";
|
|
5
|
+
import { NLNodeRef } from "nitro-ui-layout";
|
|
6
|
+
import { HybridObject } from "nitro-core";
|
|
7
|
+
import "react";
|
|
8
|
+
/** Solid can place invisible markers between native children when a conditional is empty. */
|
|
9
|
+
interface HostNode<View> {
|
|
10
|
+
readonly view: View | undefined;
|
|
11
|
+
parent?: HostNode<View>;
|
|
12
|
+
first?: HostNode<View>;
|
|
13
|
+
last?: HostNode<View>;
|
|
14
|
+
previous?: HostNode<View>;
|
|
15
|
+
next?: HostNode<View>;
|
|
16
|
+
}
|
|
17
|
+
interface NativeHandle {
|
|
18
|
+
readonly view: View$2;
|
|
19
|
+
readonly layout: NLNodeRef;
|
|
20
|
+
readonly requestLayout: () => void;
|
|
21
|
+
}
|
|
22
|
+
export type NativeNode = HostNode<NativeHandle>;
|
|
23
|
+
export declare const ViewControllerContext: import("solid-js").Context<ViewController$1>;
|
|
24
|
+
export declare function mountView(view: View$2): NativeNode;
|
|
25
|
+
export declare const createElement: (tag: string, staticProps?: Record<string, unknown>) => NativeNode, createTextNode: (value: string) => NativeNode, effect: <T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void, options?: RendererEffectOptions) => void, insertNode: (parent: NativeNode, node: NativeNode, anchor?: NativeNode | undefined) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, mergeProps: (...sources: unknown[]) => unknown, ref: (fn: () => ((element: NativeNode) => void)[] | ((element: NativeNode) => void), element: NativeNode) => void, setProp: <T>(node: NativeNode, name: string, value: T, prev?: T | undefined) => T;
|
|
26
|
+
export declare const insert: <T>(parent: NativeNode, value: T | (() => T), marker?: NativeNode | null, initial?: Element, options?: RendererEffectOptions) => void;
|
|
27
|
+
export declare const spread: <T extends object>(node: NativeNode, props: T | (() => T) | (T | (() => T) | null | undefined)[] | null | undefined, skipChildren?: boolean, options?: RendererEffectOptions) => void;
|
|
28
|
+
export declare function applyRef<T>(ref: ((value: T) => void) | readonly ((value: T) => void)[], value: T): void;
|
|
29
|
+
interface NativeSurface {
|
|
30
|
+
dispose: () => void;
|
|
31
|
+
layout: () => void;
|
|
32
|
+
}
|
|
33
|
+
/** A native-owned container measures its contents without inheriting the previous frame size. */
|
|
34
|
+
export declare function mountPortal(view: View$2, content: () => Element): NativeSurface;
|
|
35
|
+
/** Mounts a Solid tree in a native controller. The disposer releases views and resize observation. */
|
|
36
|
+
export declare function renderRoot(content: () => Element, controller: ViewController$1): () => void;
|
|
37
|
+
type LayoutLength = number | `${number}%`;
|
|
38
|
+
interface LayoutStyleProps {
|
|
39
|
+
/** Defaults to relative. Absolute positioning removes the view from flex flow. */
|
|
40
|
+
position?: "static" | "relative" | "absolute";
|
|
41
|
+
/** Top offset in points or percent. Removing it clears the offset. */
|
|
42
|
+
top?: LayoutLength;
|
|
43
|
+
/** Right offset in points or percent. Removing it clears the offset. */
|
|
44
|
+
right?: LayoutLength;
|
|
45
|
+
/** Bottom offset in points or percent. Removing it clears the offset. */
|
|
46
|
+
bottom?: LayoutLength;
|
|
47
|
+
/** Left offset in points or percent. Removing it clears the offset. */
|
|
48
|
+
left?: LayoutLength;
|
|
49
|
+
flex?: number;
|
|
50
|
+
flexDirection?: "column" | "column-reverse" | "row" | "row-reverse";
|
|
51
|
+
flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
|
|
52
|
+
gap?: LayoutLength;
|
|
53
|
+
rowGap?: LayoutLength;
|
|
54
|
+
columnGap?: LayoutLength;
|
|
55
|
+
flexShrink?: number;
|
|
56
|
+
flexGrow?: number;
|
|
57
|
+
justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
|
|
58
|
+
alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
59
|
+
alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
60
|
+
width?: LayoutLength;
|
|
61
|
+
height?: LayoutLength;
|
|
62
|
+
/** Width divided by height when one dimension is automatic. */
|
|
63
|
+
aspectRatio?: number;
|
|
64
|
+
minWidth?: LayoutLength;
|
|
65
|
+
/** A point limit or a percentage of the containing block's width. */
|
|
66
|
+
maxWidth?: LayoutLength;
|
|
67
|
+
minHeight?: LayoutLength;
|
|
68
|
+
maxHeight?: LayoutLength;
|
|
69
|
+
margin?: "auto" | LayoutLength;
|
|
70
|
+
marginHorizontal?: "auto" | LayoutLength;
|
|
71
|
+
marginVertical?: "auto" | LayoutLength;
|
|
72
|
+
marginTop?: "auto" | LayoutLength;
|
|
73
|
+
marginBottom?: "auto" | LayoutLength;
|
|
74
|
+
marginLeft?: "auto" | LayoutLength;
|
|
75
|
+
marginRight?: "auto" | LayoutLength;
|
|
76
|
+
padding?: LayoutLength;
|
|
77
|
+
paddingTop?: LayoutLength;
|
|
78
|
+
paddingBottom?: LayoutLength;
|
|
79
|
+
paddingLeft?: LayoutLength;
|
|
80
|
+
paddingRight?: LayoutLength;
|
|
81
|
+
paddingHorizontal?: LayoutLength;
|
|
82
|
+
paddingVertical?: LayoutLength;
|
|
83
|
+
overflow?: "visible" | "hidden" | "scroll";
|
|
84
|
+
borderWidth?: number;
|
|
85
|
+
}
|
|
86
|
+
interface Frame {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
}
|
|
92
|
+
type Corner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
93
|
+
export declare enum AnimationCurve {
|
|
94
|
+
Linear = 0,
|
|
95
|
+
EaseIn = 1,
|
|
96
|
+
EaseOut = 2,
|
|
97
|
+
EaseInOut = 3
|
|
98
|
+
}
|
|
99
|
+
declare class Animator extends HybridObject {
|
|
100
|
+
startAnimation(afterDelay?: number): void;
|
|
101
|
+
pauseAnimation(): void;
|
|
102
|
+
stopAnimation(withoutFinishing?: boolean): void;
|
|
103
|
+
}
|
|
104
|
+
/** Insets in points from a {@linkcode View}'s edges. @see {@linkcode View.safeAreaInsets} */
|
|
105
|
+
interface EdgeInsets {
|
|
106
|
+
/** Distance from the top edge, in points. */
|
|
107
|
+
readonly top: number;
|
|
108
|
+
/** Distance from the right edge, in points. */
|
|
109
|
+
readonly right: number;
|
|
110
|
+
/** Distance from the bottom edge, in points. */
|
|
111
|
+
readonly bottom: number;
|
|
112
|
+
/** Distance from the left edge, in points. */
|
|
113
|
+
readonly left: number;
|
|
114
|
+
}
|
|
115
|
+
type CornerCurve = "circular" | "continuous";
|
|
116
|
+
type Point3D = {
|
|
117
|
+
x: number;
|
|
118
|
+
y: number;
|
|
119
|
+
z: number;
|
|
120
|
+
};
|
|
121
|
+
declare class View$1 extends HybridObject {
|
|
122
|
+
protected constructor();
|
|
123
|
+
/**
|
|
124
|
+
* The parent view set by appendChild or insertBefore.
|
|
125
|
+
* Returns the existing HybridView, or undefined for roots and detached views.
|
|
126
|
+
*/
|
|
127
|
+
readonly parent?: View$1;
|
|
128
|
+
/**
|
|
129
|
+
* The safe area insets relative to this view's bounds, in points.
|
|
130
|
+
* Insets are zero while detached or when the view is entirely inside its parent's safe area.
|
|
131
|
+
*/
|
|
132
|
+
readonly safeAreaInsets: EdgeInsets;
|
|
133
|
+
/** Bit pattern of the native layout node pointer, carried in a Hermes number. */
|
|
134
|
+
readonly layoutNodePtr: number;
|
|
135
|
+
/** Clips descendants to this view's bounds when layout.overflow is hidden. */
|
|
136
|
+
clipsToBounds: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* The background color as an unsigned 32-bit `0xRRGGBBAA` sRGB number.
|
|
139
|
+
* Returns `undefined` when unset or the native color cannot be represented as RGB.
|
|
140
|
+
*/
|
|
141
|
+
readonly backgroundColor?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Sets a fixed sRGB color in `0xRRGGBBAA` format (alpha is the last byte).
|
|
144
|
+
* For example, `0xff0000ff` is opaque red and `0x00000000` is transparent.
|
|
145
|
+
* Replaces the current background. Pass `undefined` to remove it.
|
|
146
|
+
* @throws If color is not a finite integer between `0` and `0xffffffff`.
|
|
147
|
+
*/
|
|
148
|
+
setBackgroundColor(color?: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* The opacity of the view and its children, from 0 (transparent) to 1 (opaque).
|
|
151
|
+
* Defaults to 1.
|
|
152
|
+
*/
|
|
153
|
+
opacity: number;
|
|
154
|
+
/** Hides or reveals the native subtree while keeping it mounted. */
|
|
155
|
+
setHidden(hidden: boolean): void;
|
|
156
|
+
borderWidth?: number;
|
|
157
|
+
readonly borderColor?: number;
|
|
158
|
+
setBorderColor(color?: number): void;
|
|
159
|
+
cornerRadius: number;
|
|
160
|
+
/**
|
|
161
|
+
* The corners rounded by cornerRadius. Defaults to all four corners.
|
|
162
|
+
* Pass an empty array to leave every corner square.
|
|
163
|
+
*/
|
|
164
|
+
maskedCorners: Corner[];
|
|
165
|
+
cornerCurve: CornerCurve;
|
|
166
|
+
setTranslation(x: number, y: number, z: number): void;
|
|
167
|
+
readonly translation: Point3D;
|
|
168
|
+
/**
|
|
169
|
+
* Scales each axis around the view's center without changing its layout or translation.
|
|
170
|
+
* On iOS, each exact zero is applied as `0.00001` to avoid broken UIKit transform animations.
|
|
171
|
+
* The `scale` getter returns these applied values. Use `opacity = 0` to fully hide the view.
|
|
172
|
+
* @see https://stackoverflow.com/questions/25964224/cgaffinetransformscale-not-working-with-zero-scale
|
|
173
|
+
* @see https://stackoverflow.com/questions/75793513/uiview-animation-downscale-instantly-hides-the-view
|
|
174
|
+
*/
|
|
175
|
+
setScale(x: number, y: number, z: number): void;
|
|
176
|
+
/** Applied scale factors, including the zero substitution described in `setScale`. */
|
|
177
|
+
readonly scale: Point3D;
|
|
178
|
+
/**
|
|
179
|
+
* Rotates the view clockwise around its center by `degrees`, without changing its layout,
|
|
180
|
+
* translation, or scale. iOS animates between two angles along the shorter direction.
|
|
181
|
+
*/
|
|
182
|
+
setRotation(degrees: number): void;
|
|
183
|
+
/** Applied rotation in degrees. iOS reports an equivalent angle between -180 and 180. */
|
|
184
|
+
readonly rotation: number;
|
|
185
|
+
getFrame(): Frame;
|
|
186
|
+
/**
|
|
187
|
+
* The view's frame in its window's coordinates, in points. It includes the transforms of the view and its
|
|
188
|
+
* ancestors and the scroll offsets of scroll views, so a scaled or rotated view returns its bounding box.
|
|
189
|
+
* During an animation it returns where the view is on screen at that moment.
|
|
190
|
+
* A view that isn't in a window is measured relative to its topmost ancestor.
|
|
191
|
+
*/
|
|
192
|
+
getFrameInWindow(): Frame;
|
|
193
|
+
setFrame(frame: Frame): void;
|
|
194
|
+
appendChild(child: View$1): void;
|
|
195
|
+
insertBefore(child: View$1, beforeChild: View$1): void;
|
|
196
|
+
removeChild(child: View$1): void;
|
|
197
|
+
/**
|
|
198
|
+
* Called after initial setup and after a React update runs a registered prop setter.
|
|
199
|
+
*/
|
|
200
|
+
afterUpdate(): void;
|
|
201
|
+
setGestureRecognizers(gestureRecognizers?: GestureRecognizer[]): void;
|
|
202
|
+
isUserInteractionEnabled: boolean;
|
|
203
|
+
animate(duration: number, curve: AnimationCurve, animations: () => void): Animator;
|
|
204
|
+
/**
|
|
205
|
+
* Animated the changes with spring.
|
|
206
|
+
* @param duration The duration of the spring animation in seconds.
|
|
207
|
+
* @param dampingRatio The damping ratio to apply to the initial acceleration and oscillation. To smoothly decelerate the animation without oscillation, specify a value of 1. Specify values closer to 0 to create less damping and more oscillation.
|
|
208
|
+
* @param animations Callback with the changes to perform.
|
|
209
|
+
*/
|
|
210
|
+
animateSpring(duration: number, dampingRatio: number, animations: () => void): Animator;
|
|
211
|
+
}
|
|
212
|
+
/** Called synchronously before recognition. Return false to fail this attempt. */
|
|
213
|
+
type GestureShouldBegin<T extends GestureRecognizer> = (recognizer: T, view: View$1) => boolean;
|
|
214
|
+
export declare enum GestureRecognizerState {
|
|
215
|
+
Possible = 0,
|
|
216
|
+
Began = 1,
|
|
217
|
+
Changed = 2,
|
|
218
|
+
Ended = 3,
|
|
219
|
+
Cancelled = 4,
|
|
220
|
+
Failed = 5
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* A gesture that can be attached to a {@linkcode View}.
|
|
224
|
+
*
|
|
225
|
+
* Detaching preserves its callback so the gesture can be reattached. Call the
|
|
226
|
+
* inherited `dispose()` when permanently finished with a gesture to detach it
|
|
227
|
+
* and release its callback. Disposed gestures cannot be used again.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const gesture = new TapGestureRecognizer();
|
|
232
|
+
* gesture.onTap = onTap;
|
|
233
|
+
* view.setGestureRecognizers([gesture]);
|
|
234
|
+
* // Once this gesture is permanently finished:
|
|
235
|
+
* gesture.dispose();
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @see {@linkcode View.setGestureRecognizers}
|
|
239
|
+
*/
|
|
240
|
+
declare class GestureRecognizer extends HybridObject {
|
|
241
|
+
readonly numberOfTouches: number;
|
|
242
|
+
isEnabled: boolean;
|
|
243
|
+
readonly state: GestureRecognizerState;
|
|
244
|
+
}
|
|
245
|
+
type Point = {
|
|
246
|
+
x: number;
|
|
247
|
+
y: number;
|
|
248
|
+
};
|
|
249
|
+
export declare class PanGestureRecognizer extends GestureRecognizer {
|
|
250
|
+
constructor();
|
|
251
|
+
maximumNumberOfTouches: number;
|
|
252
|
+
minimumNumberOfTouches: number;
|
|
253
|
+
/**
|
|
254
|
+
* Interprets the pan gesture in the coordinate system of the specified view.
|
|
255
|
+
*/
|
|
256
|
+
translation(inParent: View$1): Point;
|
|
257
|
+
/**
|
|
258
|
+
* Interprets the velocity of the pan gesture in the coordinate system of the specified view.
|
|
259
|
+
*/
|
|
260
|
+
velocity(inParent: View$1): Point;
|
|
261
|
+
gestureRecognizerShouldBegin?: GestureShouldBegin<PanGestureRecognizer>;
|
|
262
|
+
/** Called as the pan changes state, with the view the recognizer is attached to. */
|
|
263
|
+
onPan?: (recognizer: PanGestureRecognizer, view: View$1) => void;
|
|
264
|
+
}
|
|
265
|
+
/** Color stops and direction for a container's linear gradient background. */
|
|
266
|
+
type LinearGradientOptions = {
|
|
267
|
+
/** At least two colors as unsigned 32-bit 0xRRGGBBAA sRGB numbers. */
|
|
268
|
+
colors: number[];
|
|
269
|
+
/** Nondecreasing positions from zero to one, one per color. Defaults to even spacing. */
|
|
270
|
+
locations?: number[];
|
|
271
|
+
/** Start in normalized view coordinates. Defaults to top center (0.5, 0). */
|
|
272
|
+
start?: Point;
|
|
273
|
+
/** End in normalized view coordinates. Defaults to bottom center (0.5, 1). */
|
|
274
|
+
end?: Point;
|
|
275
|
+
};
|
|
276
|
+
/** Resolved box shadow in logical units, with a packed 0xRRGGBBAA color. */
|
|
277
|
+
type BoxShadowOptions = {
|
|
278
|
+
offsetX: number;
|
|
279
|
+
offsetY: number;
|
|
280
|
+
blurRadius: number;
|
|
281
|
+
spreadDistance: number;
|
|
282
|
+
color: number;
|
|
283
|
+
inset: boolean;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* A color: a 0xRRGGBBAA number, or a CSS color string such as `'red'`, `'#ff0000'`,
|
|
287
|
+
* `'rgba(255, 0, 0, 0.5)'` or `'hsl(0, 100%, 50%)'`.
|
|
288
|
+
*/
|
|
289
|
+
type ColorValue = number | string;
|
|
290
|
+
/**
|
|
291
|
+
* Converts a {@linkcode ColorValue} to the 0xRRGGBBAA number that native views take.
|
|
292
|
+
* @throws If the value is not a valid color.
|
|
293
|
+
*/
|
|
294
|
+
export declare function processColor(color: ColorValue): number;
|
|
295
|
+
interface ViewPropsExtension {}
|
|
296
|
+
type ViewProps$1<Background = ColorValue> = ViewPropsExtension & {
|
|
297
|
+
layout?: LayoutStyleProps;
|
|
298
|
+
style?: SharedStyleProps<Background>;
|
|
299
|
+
/** Recognizers attached to this view. Each callback receives the view as its second argument. */
|
|
300
|
+
gestureRecognizers?: GestureRecognizer[];
|
|
301
|
+
isUserInteractionEnabled?: boolean;
|
|
302
|
+
};
|
|
303
|
+
type TranslationStyleProps = {
|
|
304
|
+
translateX?: number;
|
|
305
|
+
translateY?: number;
|
|
306
|
+
translateZ?: number;
|
|
307
|
+
};
|
|
308
|
+
type ScaleStyleProps = {
|
|
309
|
+
scale?: number;
|
|
310
|
+
scaleX?: number;
|
|
311
|
+
scaleY?: number;
|
|
312
|
+
scaleZ?: number;
|
|
313
|
+
};
|
|
314
|
+
type RotationStyleProps = {
|
|
315
|
+
/** Clockwise rotation around the view's center, in degrees. Layout keeps the unrotated frame. */
|
|
316
|
+
rotate?: number;
|
|
317
|
+
};
|
|
318
|
+
/** A linear gradient used as a {@linkcode View} background. */
|
|
319
|
+
type LinearGradientBackground = Omit<LinearGradientOptions, "colors"> & {
|
|
320
|
+
/** Identifies a linear gradient. */
|
|
321
|
+
type: "linear-gradient";
|
|
322
|
+
/** At least two colors. */
|
|
323
|
+
colors: ColorValue[];
|
|
324
|
+
};
|
|
325
|
+
type SharedStyleProps<Background = ColorValue> = Partial<Pick<View$1, "opacity" | "cornerRadius" | "maskedCorners" | "cornerCurve">> & TranslationStyleProps & ScaleStyleProps & RotationStyleProps & {
|
|
326
|
+
borderColor?: ColorValue;
|
|
327
|
+
/** A background fill. Omit to clear the fill. */
|
|
328
|
+
background?: Background;
|
|
329
|
+
};
|
|
330
|
+
/** A shadow cast by the rounded border box, in logical units. */
|
|
331
|
+
type BoxShadow = Pick<BoxShadowOptions, "offsetX" | "offsetY"> & Partial<Pick<BoxShadowOptions, "blurRadius" | "spreadDistance" | "inset">> & {
|
|
332
|
+
color: ColorValue;
|
|
333
|
+
};
|
|
334
|
+
type StyleProps<Background = ColorValue | LinearGradientBackground> = SharedStyleProps<Background> & {
|
|
335
|
+
/** Shadows ordered front to back. Requires Android API 31 or later. */
|
|
336
|
+
boxShadow?: readonly BoxShadow[];
|
|
337
|
+
};
|
|
338
|
+
type ContainerProperties<Background = ColorValue | LinearGradientBackground> = Omit<ViewProps$1, "style"> & {
|
|
339
|
+
style?: StyleProps<Background>;
|
|
340
|
+
};
|
|
341
|
+
/** System font weights accepted by {@linkcode Label.fontWeight}. */
|
|
342
|
+
type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';
|
|
343
|
+
/** Line-limit truncation modes accepted by {@linkcode Label.ellipsizeMode}. */
|
|
344
|
+
type EllipsizeMode = 'tail' | 'clip';
|
|
345
|
+
/** Horizontal alignment relative to the view's layout direction. */
|
|
346
|
+
type TextAlignment = 'start' | 'center' | 'end' | 'justify';
|
|
347
|
+
declare class Label extends View$1 {
|
|
348
|
+
constructor();
|
|
349
|
+
text?: string;
|
|
350
|
+
/** Text color as 0xRRGGBBAA. Defaults to opaque black. */
|
|
351
|
+
color: number;
|
|
352
|
+
/** Positive text size, in points on iOS and scaled pixels on Android. Defaults to 17. */
|
|
353
|
+
fontSize: number;
|
|
354
|
+
/** System font weight. Non-regular weights require Android 9+. Defaults to regular. */
|
|
355
|
+
fontWeight: FontWeight;
|
|
356
|
+
/**
|
|
357
|
+
* Resource identifier from an imported .ttf or .otf file.
|
|
358
|
+
* The font file determines its weight. An unknown asset throws on update.
|
|
359
|
+
* Removing this property selects the system font.
|
|
360
|
+
*/
|
|
361
|
+
font?: string;
|
|
362
|
+
/** Positive line spacing in the same units as fontSize. Undefined uses the font's metrics. */
|
|
363
|
+
lineHeight?: number;
|
|
364
|
+
/** Paragraph alignment inside the label. Undefined preserves native text alignment. */
|
|
365
|
+
textAlign?: TextAlignment;
|
|
366
|
+
/** Maximum number of lines. Zero allows unlimited lines. Defaults to zero. */
|
|
367
|
+
numberOfLines: number;
|
|
368
|
+
/** Truncation at the line limit. Defaults to tail. */
|
|
369
|
+
ellipsizeMode: EllipsizeMode;
|
|
370
|
+
/**
|
|
371
|
+
* Number of lines the text took in its last layout, up to {@linkcode numberOfLines}. Zero for empty text.
|
|
372
|
+
* Meant for development checks. On iOS only Debug builds have it, Release returns 0,
|
|
373
|
+
* and the count ignores padding.
|
|
374
|
+
*/
|
|
375
|
+
readonly lineCount: number;
|
|
376
|
+
}
|
|
377
|
+
interface ListenerSubscription {
|
|
378
|
+
remove: () => void;
|
|
379
|
+
}
|
|
380
|
+
/** A UTF-16 span from inclusive {@linkcode TextRange.start} to exclusive {@linkcode TextRange.end}. */
|
|
381
|
+
interface TextRange {
|
|
382
|
+
/** The inclusive start offset, measured in UTF-16 code units. */
|
|
383
|
+
start: number;
|
|
384
|
+
/** The exclusive end offset. Equal to start for a caret position. */
|
|
385
|
+
end: number;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A snapshot reported by {@linkcode TextInput.addOnTextChangedListener}
|
|
389
|
+
* and {@linkcode TextInput.addOnSelectionChangedListener}.
|
|
390
|
+
*/
|
|
391
|
+
interface TextInputChange {
|
|
392
|
+
/** The entire current text, including any provisional input. */
|
|
393
|
+
text: string;
|
|
394
|
+
/** The selected text or caret position. Undefined when there is no selection. */
|
|
395
|
+
selectedTextRange?: TextRange;
|
|
396
|
+
/** Provisional keyboard text awaiting confirmation. Undefined when no composition is active. */
|
|
397
|
+
markedTextRange?: TextRange;
|
|
398
|
+
}
|
|
399
|
+
/** A proposed edit passed to {@linkcode TextInput.setOnBeforeTextChange}. */
|
|
400
|
+
interface TextInputEdit {
|
|
401
|
+
/** The text before the edit, or before composition began. */
|
|
402
|
+
text: string;
|
|
403
|
+
/** The full text that would result from accepting the edit. */
|
|
404
|
+
proposedText: string;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* How iOS adds safe-area insets to the scrollable area, matching `UIScrollView.ContentInsetAdjustmentBehavior`.
|
|
408
|
+
* - `automatic`: Like `scrollableAxes`, but also adjusts the top and bottom inside a navigation controller.
|
|
409
|
+
* - `scrollableAxes`: Adjusts the edges of axes that scroll.
|
|
410
|
+
* - `never`: Never adjusts the insets.
|
|
411
|
+
* - `always`: Always includes the safe-area insets.
|
|
412
|
+
*/
|
|
413
|
+
type ContentInsetAdjustmentBehavior = 'automatic' | 'scrollableAxes' | 'never' | 'always';
|
|
414
|
+
/**
|
|
415
|
+
* Represents the pixel ordering format of the literal bytes in memory.
|
|
416
|
+
* - `ARGB`: `[alpha, red, green, blue]`
|
|
417
|
+
* - `BGRA`: `[blue, green, red, alpha]`
|
|
418
|
+
* - `ABGR`: `[alpha, blue, green, red]`
|
|
419
|
+
* - `RGBA`: `[red, green, blue, alpha]`
|
|
420
|
+
* - `XRGB`: `[skip, red, green, blue]`
|
|
421
|
+
* - `BGRX`: `[blue, green, red, skip]`
|
|
422
|
+
* - `XBGR`: `[skip, blue, green, red]`
|
|
423
|
+
* - `RGBX`: `[red, green, blue, skip]`
|
|
424
|
+
* - `RGB`: `[red, green, blue]`
|
|
425
|
+
* - `BGR`: `[blue, green, red]`
|
|
426
|
+
* - `unknown`: Unknown pixel format.
|
|
427
|
+
*
|
|
428
|
+
* `A` means alpha, `X` means placeholder - skip alpha.
|
|
429
|
+
*
|
|
430
|
+
* @note Native config names do not always describe the byte order in memory.
|
|
431
|
+
* For example, Android's [`Bitmap.Config.ARGB_8888`](https://developer.android.com/reference/android/graphics/Bitmap.Config)
|
|
432
|
+
* is named after the "`0xAARRGGBB`" `Int` packing used by `getPixel()`/`setPixel()` - but the Bitmap's actual
|
|
433
|
+
* memory is laid out as `[R, G, B, A]` bytes. Since raw pixel data is exported as a raw
|
|
434
|
+
* memory copy, a `Bitmap` in `ARGB_8888` config returns `RGBA` here in Nitro Image.
|
|
435
|
+
*/
|
|
436
|
+
type PixelFormat = 'ARGB' | 'BGRA' | 'ABGR' | 'RGBA' | 'XRGB' | 'BGRX' | 'XBGR' | 'RGBX' | 'RGB' | 'BGR' | 'unknown';
|
|
437
|
+
/**
|
|
438
|
+
* Describes the format of an encoded Image.
|
|
439
|
+
*/
|
|
440
|
+
type ImageFormat = 'jpg' | 'png' | 'heic';
|
|
441
|
+
/**
|
|
442
|
+
* Describes raw pixel data (`buffer`) with `width`, `height` and `pixelFormat`.
|
|
443
|
+
*/
|
|
444
|
+
interface RawPixelData {
|
|
445
|
+
buffer: ArrayBuffer;
|
|
446
|
+
width: number;
|
|
447
|
+
height: number;
|
|
448
|
+
pixelFormat: PixelFormat;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Describes encoded image data (`buffer`) with `width`, `height` and `imageFormat`.
|
|
452
|
+
*/
|
|
453
|
+
interface EncodedImageData {
|
|
454
|
+
buffer: ArrayBuffer;
|
|
455
|
+
width: number;
|
|
456
|
+
height: number;
|
|
457
|
+
imageFormat: ImageFormat;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* A native Image instance.
|
|
461
|
+
*/
|
|
462
|
+
declare class Image$1 extends HybridObject {
|
|
463
|
+
readonly width: number;
|
|
464
|
+
readonly height: number;
|
|
465
|
+
/**
|
|
466
|
+
* Returns {@linkcode RawPixelData} containing the raw pixel data of the Image in an {@linkcode ArrayBuffer}.
|
|
467
|
+
* @note The returned {@linkcode PixelFormat} describes the literal byte order in memory -
|
|
468
|
+
* always read it instead of assuming a fixed format. It is typically
|
|
469
|
+
* {@linkcode PixelFormat | 'RGBA'} on Android (the memory layout of `ARGB_8888` Bitmaps),
|
|
470
|
+
* and {@linkcode PixelFormat | 'BGRA'} on iOS - but it can differ per image.
|
|
471
|
+
* @param allowGpu If `allowGpu` is set to `true`, the returned buffer might
|
|
472
|
+
* be a `HardwareBuffer` (a GPU-buffer) on Android. By default, it is `false`.
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* const rawData = image.toRawPixelData()
|
|
476
|
+
* const data = new Uint8Array(rawData.buffer)
|
|
477
|
+
* let r, g, b
|
|
478
|
+
* if (rawData.pixelFormat === 'BGRA') {
|
|
479
|
+
* r = data[2]
|
|
480
|
+
* g = data[1]
|
|
481
|
+
* b = data[0]
|
|
482
|
+
* } else if (rawData.pixelFormat === 'RGBA') {
|
|
483
|
+
* r = data[0]
|
|
484
|
+
* g = data[1]
|
|
485
|
+
* b = data[2]
|
|
486
|
+
* }
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
toRawPixelData(allowGpu?: boolean): RawPixelData;
|
|
490
|
+
toRawPixelDataAsync(allowGpu?: boolean): Promise<RawPixelData>;
|
|
491
|
+
/**
|
|
492
|
+
* Returns {@linkcode EncodedImageData} containing the encoded data of an Image in
|
|
493
|
+
* the requested container {@linkcode format}.
|
|
494
|
+
* @note If the requested {@linkcode format} is {@linkcode ImageFormat | 'jpg'}, you can use
|
|
495
|
+
* {@linkcode quality} to compress the image. Quality ranges from `0` (worst) to `100` (best), rounds to the nearest integer, and defaults to `100`. In {@linkcode ImageFormat | 'png'}, the
|
|
496
|
+
* {@linkcode quality} flag is ignored.
|
|
497
|
+
* @throws If {@linkcode quality} is outside the `0...100` range.
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* const compressed = image.toEncodedImageData('jpg', 70)
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
toEncodedImageData(format: ImageFormat, quality?: number): EncodedImageData;
|
|
504
|
+
toEncodedImageDataAsync(format: ImageFormat, quality?: number): Promise<EncodedImageData>;
|
|
505
|
+
/**
|
|
506
|
+
* Encodes this Image in the requested {@linkcode ImageFormat} and returns the encoded bytes as a Base64 string.
|
|
507
|
+
* @note This method re-encodes the current Image. It does not return the original file bytes or preserve all original metadata.
|
|
508
|
+
* @note The returned string uses standard padded Base64 without line breaks or a data URL prefix.
|
|
509
|
+
* @param format The {@linkcode ImageFormat} to use for encoding this Image.
|
|
510
|
+
* @param quality The target Image quality from `0` (worst quality/highest compression) to `100` (best quality/least compression), rounded to the nearest integer. Defaults to `100`. {@linkcode quality} is ignored for non-compressible {@linkcode ImageFormat}s, such as {@linkcode ImageFormat | 'png'}.
|
|
511
|
+
* @throws If {@linkcode quality} is outside the `0...100` range.
|
|
512
|
+
* @example
|
|
513
|
+
* ```ts
|
|
514
|
+
* const base64 = await image.toBase64Async('jpg', 80)
|
|
515
|
+
* const dataUrl = `data:image/jpeg;base64,${base64}`
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
toBase64Async(format: ImageFormat, quality?: number): Promise<string>;
|
|
519
|
+
/**
|
|
520
|
+
* Resizes this Image into a new image with the new given {@linkcode width} and {@linkcode height}.
|
|
521
|
+
* @example
|
|
522
|
+
* ```ts
|
|
523
|
+
* const smaller = image.resize(image.width / 2, image.height / 2)
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
resize(width: number, height: number): Image$1;
|
|
527
|
+
resizeAsync(width: number, height: number): Promise<Image$1>;
|
|
528
|
+
/**
|
|
529
|
+
* Rotates this Image by the given {@linkcode degrees} and returns
|
|
530
|
+
* the newly created {@linkcode Image}.
|
|
531
|
+
*
|
|
532
|
+
* @param degrees The degrees to rotate the Image. May be any arbitrary number, and can be negative.
|
|
533
|
+
* @param allowFastFlagRotation When {@linkcode allowFastFlagRotation} is set to `true`, the implementation may choose to only change the orientation flag on the underlying image instead of physically rotating the buffers. This may only work when {@linkcode degrees} is a multiple of `90`, and will only apply rotation when displaying the Image (via view transforms) or exporting it to a file (via EXIF flags). The actual buffer (e.g. obtained via {@linkcode toRawPixelData | toRawPixelData()}) may remain untouched.
|
|
534
|
+
* @example
|
|
535
|
+
* ```ts
|
|
536
|
+
* const upsideDown = image.rotate(180)
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
rotate(degrees: number, allowFastFlagRotation?: boolean): Image$1;
|
|
540
|
+
rotateAsync(degrees: number, allowFastFlagRotation?: boolean): Promise<Image$1>;
|
|
541
|
+
/**
|
|
542
|
+
* Crops this Image into a new image starting from the source image's {@linkcode startX} and {@linkcode startY} coordinates,
|
|
543
|
+
* up until the source image's {@linkcode endX} and {@linkcode endY} coordinates.
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const cropped = image.crop(
|
|
547
|
+
* image.width * 0.1,
|
|
548
|
+
* image.height * 0.1,
|
|
549
|
+
* image.width * 0.8,
|
|
550
|
+
* image.height * 0.8
|
|
551
|
+
* )
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
crop(startX: number, startY: number, endX: number, endY: number): Image$1;
|
|
555
|
+
cropAsync(startX: number, startY: number, endX: number, endY: number): Promise<Image$1>;
|
|
556
|
+
/**
|
|
557
|
+
* Mirrors this Image horizontally. Left is now right, right is now left.
|
|
558
|
+
*/
|
|
559
|
+
mirrorHorizontally(): Image$1;
|
|
560
|
+
mirrorHorizontallyAsync(): Promise<Image$1>;
|
|
561
|
+
/**
|
|
562
|
+
* Saves this image in the given {@linkcode ImageFormat} to the given filesystem {@linkcode path}.
|
|
563
|
+
*
|
|
564
|
+
* @param path A filesystem path including filename and extension - for example: `/tmp/image.jpg`. This is not a URL, so omit the `file://` prefix. The file extension is not authoritative and does not affect encoding/file format, but typically it should match the {@linkcode ImageFormat} passed to the {@linkcode format} parameter.
|
|
565
|
+
*
|
|
566
|
+
* @param format The {@linkcode ImageFormat} to use for encoding this Image to a file.
|
|
567
|
+
*
|
|
568
|
+
* @param quality The target Image quality to use, from `0` (worst quality/highest compression) to `100` (best quality/least compression), rounded to the nearest integer. Defaults to `100`. {@linkcode quality} is ignored for non-compressible {@linkcode ImageFormat}s, such as {@linkcode ImageFormat | 'png'}.
|
|
569
|
+
* @throws If {@linkcode quality} is outside the `0...100` range.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```ts
|
|
573
|
+
* const path = '/tmp/image.jpg'
|
|
574
|
+
* await image.saveToFileAsync(path, 'jpg', 80)
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
saveToFileAsync(path: string, format: ImageFormat, quality?: number): Promise<void>;
|
|
578
|
+
/**
|
|
579
|
+
* Saves this image in the given {@linkcode ImageFormat} to a temporary file, and returns its filesystem path.
|
|
580
|
+
*
|
|
581
|
+
* @param format The {@linkcode ImageFormat} to use for encoding this Image to a file. The given {@linkcode ImageFormat} will also be used as the generated file's extension.
|
|
582
|
+
*
|
|
583
|
+
* @param quality The target Image quality to use, from `0` (worst quality/highest compression) to `100` (best quality/least compression), rounded to the nearest integer. Defaults to `100`. {@linkcode quality} is ignored for non-compressible {@linkcode ImageFormat}s, such as {@linkcode ImageFormat | 'png'}.
|
|
584
|
+
* @throws If {@linkcode quality} is outside the `0...100` range.
|
|
585
|
+
*
|
|
586
|
+
* @returns A filesystem path such as `/tmp/image.jpg`. This is not a URL, so the returned path does not have a `file://` prefix. If another API needs a file URL, prepend `file://`, for example `fetch('file://' + path)`.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```ts
|
|
590
|
+
* const path = await image.saveToTemporaryFileAsync('jpg', 80)
|
|
591
|
+
* const response = await fetch(`file://${path}`)
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
saveToTemporaryFileAsync(format: ImageFormat, quality?: number): Promise<string>;
|
|
595
|
+
/**
|
|
596
|
+
* Renders the given {@linkcode Image} into a copy of this {@linkcode Image},
|
|
597
|
+
* at the given {@linkcode x} and {@linkcode y} position, scaled to the
|
|
598
|
+
* given {@linkcode width} and {@linkcode height}.
|
|
599
|
+
*/
|
|
600
|
+
renderInto(image: Image$1, x: number, y: number, width: number, height: number): Image$1;
|
|
601
|
+
renderIntoAsync(image: Image$1, x: number, y: number, width: number, height: number): Promise<Image$1>;
|
|
602
|
+
}
|
|
603
|
+
/** A named image in the app's native resources. */
|
|
604
|
+
interface ImageResource {
|
|
605
|
+
resourceName: string;
|
|
606
|
+
}
|
|
607
|
+
type ImageSource = Image$1 | ArrayBuffer | ImageResource;
|
|
608
|
+
interface ImageLoaderOptions {
|
|
609
|
+
/**
|
|
610
|
+
* Reuse the loaded image on later requests. Encoded sources are retained so the loader
|
|
611
|
+
* can use the same bytes when the view changes size.
|
|
612
|
+
* @default true
|
|
613
|
+
*/
|
|
614
|
+
allowCaching?: boolean;
|
|
615
|
+
/**
|
|
616
|
+
* On iOS, decode bitmap images for display before returning them. This moves
|
|
617
|
+
* decompression off the main thread so it doesn't delay a scrolling frame.
|
|
618
|
+
* The loader caches only the selected representation when caching is enabled.
|
|
619
|
+
* Use loadImage() with this option disabled when exporting the original pixels.
|
|
620
|
+
* Android already decodes encoded images when creating the bitmap.
|
|
621
|
+
* @default true
|
|
622
|
+
* @see {@link https://developer.apple.com/documentation/uikit/uiimage/preparefordisplay(completionhandler:)|Apple's asynchronous image preparation}
|
|
623
|
+
* @see {@link https://developer.apple.com/documentation/uikit/uiimage/preparingfordisplay()|Apple's guidance on pixels and display traits}
|
|
624
|
+
*/
|
|
625
|
+
decodeOnLoad?: boolean;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Loads an image for a single {@linkcode ImageView} instance.
|
|
629
|
+
*/
|
|
630
|
+
declare class ImageLoader extends HybridObject {
|
|
631
|
+
/**
|
|
632
|
+
* Return encoded bytes or a native resource to let the loader decode at the view's
|
|
633
|
+
* pixel size. A callback returning an already-created Image supplies its pixels directly.
|
|
634
|
+
*/
|
|
635
|
+
constructor(load: () => Promise<ImageSource>, options?: ImageLoaderOptions);
|
|
636
|
+
/** Load the original resolution, including after displaying the source in a smaller view. */
|
|
637
|
+
loadImage(): Promise<Image$1>;
|
|
638
|
+
/**
|
|
639
|
+
* Called by an Image View when it becomes visible.
|
|
640
|
+
* Sets the loaded image on the given image view.
|
|
641
|
+
* @param forView The image view receiving the loaded image.
|
|
642
|
+
*/
|
|
643
|
+
requestImage(forView: ImageView): void;
|
|
644
|
+
/**
|
|
645
|
+
* Called by an Image View when it becomes invisible.
|
|
646
|
+
* The native implementation can remove the `image` on the `imageView` if needed to save memory.
|
|
647
|
+
* @param forView The native view type (e.g. `HybridImageView`)
|
|
648
|
+
*/
|
|
649
|
+
dropImage(forView: ImageView): void;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* A resizing mode for fitting an Image inside an Image View.
|
|
653
|
+
* - `cover`: Scale the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.
|
|
654
|
+
* - `contain`: Scale the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.
|
|
655
|
+
* - `center`: Center the content in the view’s bounds, keeping the proportions the same.
|
|
656
|
+
* - `stretch`: Scale the content to fill the view's bounds, changing the content's aspect ratio if necessary.
|
|
657
|
+
*/
|
|
658
|
+
type ResizeMode = 'cover' | 'contain' | 'center' | 'stretch';
|
|
659
|
+
type ImageDecodeSize = 'view' | 'original';
|
|
660
|
+
/** Resolved alpha shadow in logical units, with a packed 0xRRGGBBAA color. */
|
|
661
|
+
type DropShadowOptions = {
|
|
662
|
+
offsetX: number;
|
|
663
|
+
offsetY: number;
|
|
664
|
+
standardDeviation: number;
|
|
665
|
+
color: number;
|
|
666
|
+
};
|
|
667
|
+
declare class ImageView extends View$1 {
|
|
668
|
+
constructor();
|
|
669
|
+
/** Replaces the ordered drop-shadow filter chain. Pass an empty array to clear. */
|
|
670
|
+
setDropShadows(shadows: DropShadowOptions[]): void;
|
|
671
|
+
/**
|
|
672
|
+
* Paints every visible pixel of the image in one color and keeps its alpha.
|
|
673
|
+
* Pass `undefined` to show the image's own colors.
|
|
674
|
+
* @param color A packed 0xRRGGBBAA color.
|
|
675
|
+
*/
|
|
676
|
+
setTintColor(color?: number): void;
|
|
677
|
+
/**
|
|
678
|
+
* Represents the image actually shown in this Image View.
|
|
679
|
+
* - {@linkcode Image}: Shows a specific in-memory {@linkcode Image}
|
|
680
|
+
* instance. Even when the view goes invisible, the image will still
|
|
681
|
+
* be in-memory.
|
|
682
|
+
* - {@linkcode ImageLoader}: Asynchronously loads an image from the
|
|
683
|
+
* given {@linkcode ImageLoader} into the view when it becomes visible
|
|
684
|
+
* ({@linkcode ImageLoader.requestImage | requestImage(…)}),
|
|
685
|
+
* and drops it again when the view becomes invisible
|
|
686
|
+
* ({@linkcode ImageLoader.dropImage | dropImage(…)}). This is
|
|
687
|
+
* more efficient and works better for Lists.
|
|
688
|
+
* - `undefined`: Shows no image.
|
|
689
|
+
* @default undefined
|
|
690
|
+
*/
|
|
691
|
+
image?: Image$1 | ImageLoader;
|
|
692
|
+
/**
|
|
693
|
+
* Specifies the resizing mode that will be applied when the Image
|
|
694
|
+
* does not exactly match the Image View's width and height.
|
|
695
|
+
* @see {@linkcode ResizeMode}
|
|
696
|
+
* @default 'cover'
|
|
697
|
+
*/
|
|
698
|
+
resizeMode?: ResizeMode;
|
|
699
|
+
/**
|
|
700
|
+
* Decodes eligible bitmap sources for the measured view by default. Choose
|
|
701
|
+
* `original` for full-resolution display, for example when magnifying the view.
|
|
702
|
+
* The `center` resize mode always uses the source resolution.
|
|
703
|
+
* @default 'view'
|
|
704
|
+
*/
|
|
705
|
+
decodeSize?: ImageDecodeSize;
|
|
706
|
+
/**
|
|
707
|
+
* A key that uniquely identifies an Image that should be displayed.
|
|
708
|
+
*
|
|
709
|
+
* If the {@linkcode recyclingKey} changes, the view clears the previous
|
|
710
|
+
* image while loading. An image already available from the loader's
|
|
711
|
+
* cache can replace it immediately.
|
|
712
|
+
*
|
|
713
|
+
* It is recommended to set this to the {@linkcode Image}'s URL in
|
|
714
|
+
* large lists to prevent the recycled views from displaying
|
|
715
|
+
* stale {@linkcode Image} instances.
|
|
716
|
+
* @default undefined
|
|
717
|
+
* @example
|
|
718
|
+
* ```tsx
|
|
719
|
+
* <NitroImage image={{ url }} recyclingKey={url} />
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
recyclingKey?: string;
|
|
723
|
+
}
|
|
724
|
+
declare const fontAssetBrand: unique symbol;
|
|
725
|
+
/** A bundled font face obtained by importing a .ttf or .otf file. */
|
|
726
|
+
type FontAsset = string & {
|
|
727
|
+
readonly [fontAssetBrand]: true;
|
|
728
|
+
};
|
|
729
|
+
/** Content and typography options for {@linkcode Text}. */
|
|
730
|
+
type TextProps$1 = ViewProps$1 & Partial<Pick<Label, "text" | "fontSize" | "fontWeight" | "lineHeight" | "textAlign" | "numberOfLines" | "ellipsizeMode">> & {
|
|
731
|
+
/** Text color. Defaults to opaque black. */
|
|
732
|
+
color?: ColorValue;
|
|
733
|
+
children?: string | string[];
|
|
734
|
+
/** Font face imported from a .ttf or .otf file. Omit to use the system font. */
|
|
735
|
+
font?: FontAsset;
|
|
736
|
+
};
|
|
737
|
+
/** Extracts non-function instance properties, excluding keys shared with the base type. */
|
|
738
|
+
type PropertiesOf<T, Base = object> = { [Key in keyof T as Key extends keyof Base ? never : NonNullable<T[Key]> extends ((...args: never[]) => unknown) ? never : Key]: T[Key]; };
|
|
739
|
+
/** A shadow cast by the painted alpha, in logical units. */
|
|
740
|
+
type DropShadow = Pick<DropShadowOptions, "offsetX" | "offsetY"> & {
|
|
741
|
+
standardDeviation?: number;
|
|
742
|
+
color: ColorValue;
|
|
743
|
+
};
|
|
744
|
+
type ImageFilterStyle = {
|
|
745
|
+
/** Each filter acts on the result of the previous filter. Requires Android API 31 or later. */
|
|
746
|
+
filter?: readonly {
|
|
747
|
+
dropShadow: DropShadow;
|
|
748
|
+
}[];
|
|
749
|
+
};
|
|
750
|
+
type ImageStyleProps = SharedStyleProps & ImageFilterStyle & {
|
|
751
|
+
/** Paints every visible pixel of the image in this color and keeps its alpha, for example to color an icon. */
|
|
752
|
+
tintColor?: ColorValue;
|
|
753
|
+
};
|
|
754
|
+
type ImageProps$1 = Omit<ViewProps$1, "style"> & PropertiesOf<ImageView, View$1> & {
|
|
755
|
+
style?: ImageStyleProps;
|
|
756
|
+
};
|
|
757
|
+
interface ScrollOptions {
|
|
758
|
+
/** Shows the vertical scroll indicator. Defaults to true; removing the prop restores it. */
|
|
759
|
+
showsVerticalScrollIndicator?: boolean;
|
|
760
|
+
/** Shows the horizontal scroll indicator. Defaults to true; removing the prop restores it. */
|
|
761
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
762
|
+
/**
|
|
763
|
+
* How iOS adds safe-area insets to the scrollable area. Defaults to `automatic`.
|
|
764
|
+
* Use `never` when the content already pads for the safe area. Android ignores it.
|
|
765
|
+
*/
|
|
766
|
+
contentInsetAdjustmentBehavior?: ContentInsetAdjustmentBehavior;
|
|
767
|
+
/**
|
|
768
|
+
* Lets this view scroll before a scrolling parent, such as a modal sheet, takes over the drag.
|
|
769
|
+
* Android only. iOS ignores it. Defaults to false.
|
|
770
|
+
*/
|
|
771
|
+
isNestedScrollingEnabled?: boolean;
|
|
772
|
+
}
|
|
773
|
+
interface NativeRef<View> {
|
|
774
|
+
ref?: (view: View) => void | (() => void);
|
|
775
|
+
}
|
|
776
|
+
type WithChildren<Props> = Omit<Props, "children"> & {
|
|
777
|
+
children?: Element;
|
|
778
|
+
};
|
|
779
|
+
export type ViewRef = ReturnType<typeof Application$1.createView>;
|
|
780
|
+
export type ViewProps = WithChildren<ContainerProperties> & NativeRef<ViewRef>;
|
|
781
|
+
export type TextProps = TextProps$1 & NativeRef<Label$1>;
|
|
782
|
+
export type ImageProps = ImageProps$1 & NativeRef<ImageView$1>;
|
|
783
|
+
export type ScrollViewProps = WithChildren<ViewProps$1 & ScrollOptions> & NativeRef<ScrollView$1>;
|
|
784
|
+
export type ScrollViewContentProps = WithChildren<ViewProps$1> & NativeRef<ScrollViewContent$1>;
|
|
785
|
+
export type MaskedViewProps = WithChildren<ViewProps$1> & NativeRef<MaskedView$1> & {
|
|
786
|
+
maskElement: Element;
|
|
787
|
+
};
|
|
788
|
+
export declare function View(props: ViewProps): NativeNode;
|
|
789
|
+
export declare function Text(props: TextProps): NativeNode;
|
|
790
|
+
export declare function Image(props: ImageProps): NativeNode;
|
|
791
|
+
export declare function ScrollView(props: ScrollViewProps): NativeNode;
|
|
792
|
+
export declare function ScrollViewContent(props: ScrollViewContentProps): NativeNode;
|
|
793
|
+
export declare function MaskedView(props: MaskedViewProps): NativeNode;
|
|
794
|
+
/** Props for the TextInput component. The ref exposes the native {@linkcode TextInput}. */
|
|
795
|
+
type InputProperties = ViewProps$1 & {
|
|
796
|
+
/** Accepts newlines and scrolls vertically. Cannot change without a new React key. @default false */
|
|
797
|
+
multiline?: boolean;
|
|
798
|
+
/** The text displayed while empty. */
|
|
799
|
+
placeholder?: string;
|
|
800
|
+
/** Reports native text or marked-text changes, including provisional keyboard input. */
|
|
801
|
+
onTextChanged?: (change: TextInputChange) => void;
|
|
802
|
+
/** Reports native selection or marked-text changes, including changes without a text edit. */
|
|
803
|
+
onSelectionChanged?: (change: TextInputChange) => void;
|
|
804
|
+
/** The initial text. Later changes are ignored. @default '' */
|
|
805
|
+
defaultValue?: string;
|
|
806
|
+
/**
|
|
807
|
+
* Returns the accepted text synchronously: proposedText accepts, text rejects,
|
|
808
|
+
* and another string transforms. Omission accepts native edits.
|
|
809
|
+
* Provisional composition is left untouched; the completed text is evaluated on confirmation.
|
|
810
|
+
* Programmatic setText calls bypass this callback. Do not mutate the input inside it.
|
|
811
|
+
*/
|
|
812
|
+
onBeforeTextChange?: (edit: TextInputEdit) => string;
|
|
813
|
+
};
|
|
814
|
+
export type TextInputRef = TextInput$1;
|
|
815
|
+
export type TextInputProps = InputProperties & NativeRef<TextInput$1>;
|
|
816
|
+
/** Mounts an editable native control. A new control is required to change multiline mode. */
|
|
817
|
+
export declare function TextInput(props: TextInputProps): NativeNode;
|
|
818
|
+
/** Configures the native pull-to-refresh gesture and indicator. */
|
|
819
|
+
interface RefreshControl {
|
|
820
|
+
/** Called once when the user pulls far enough from the top and releases. */
|
|
821
|
+
onRefresh: () => void;
|
|
822
|
+
/** Keep the indicator visible until the refresh operation finishes. */
|
|
823
|
+
refreshing: boolean;
|
|
824
|
+
/** Vertical offset of the indicator from its default position, in points. */
|
|
825
|
+
progressViewOffset?: number;
|
|
826
|
+
tintColor?: ColorValue;
|
|
827
|
+
}
|
|
828
|
+
type ListHostProps = ViewProps$1 & {
|
|
829
|
+
horizontal: boolean;
|
|
830
|
+
anchorItem?: {
|
|
831
|
+
type: string;
|
|
832
|
+
key: string;
|
|
833
|
+
alignment?: number;
|
|
834
|
+
};
|
|
835
|
+
refreshControl?: RefreshControl;
|
|
836
|
+
estimatedItemSize?: number;
|
|
837
|
+
contentPadding?: Partial<EdgeInsets>;
|
|
838
|
+
showsVerticalScrollIndicator?: boolean;
|
|
839
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
840
|
+
};
|
|
841
|
+
/** A row in a {@linkcode ListDataSource}, discriminated by its renderer type. */
|
|
842
|
+
type ListItem<Types, Key extends keyof Types & string = keyof Types & string> = { [Type in Key]: {
|
|
843
|
+
/** Stable identity within this item type. */
|
|
844
|
+
readonly key: string;
|
|
845
|
+
/** Selects the row renderer and native recycling pool. */
|
|
846
|
+
readonly type: Type;
|
|
847
|
+
/** Immutable payload passed to the row renderer. */
|
|
848
|
+
readonly data: Types[Type];
|
|
849
|
+
/** Fixed width in points. Defaults to the viewport width in a vertical list and content width in a horizontal list. */
|
|
850
|
+
readonly width?: number;
|
|
851
|
+
/** Fixed height in points. Defaults to the content height in a vertical list and viewport height in a horizontal list. */
|
|
852
|
+
readonly height?: number;
|
|
853
|
+
}; }[Key];
|
|
854
|
+
/** Content comparisons used by {@linkcode createListDataSource}. */
|
|
855
|
+
interface ListDataSourceConfig<Types> {
|
|
856
|
+
/**
|
|
857
|
+
* Return true to skip updating a retained row's content. Without a comparison,
|
|
858
|
+
* replacing an item updates it. Changed dimensions always update the row.
|
|
859
|
+
*/
|
|
860
|
+
isContentEqualByType?: { [Type in keyof Types & string]?: (oldItem: ListItem<Types, Type>, newItem: ListItem<Types, Type>) => boolean; };
|
|
861
|
+
}
|
|
862
|
+
/** @internal An immutable row binding in a {@linkcode ListDataSourceSnapshot}. */
|
|
863
|
+
interface ListDataSourceEntry<Types> {
|
|
864
|
+
readonly id: string;
|
|
865
|
+
readonly item: ListItem<Types>;
|
|
866
|
+
readonly version: number;
|
|
867
|
+
}
|
|
868
|
+
/** @internal A committed revision read by a List's native snapshot controller. */
|
|
869
|
+
interface ListDataSourceSnapshot<Types> {
|
|
870
|
+
readonly entries: readonly ListDataSourceEntry<Types>[];
|
|
871
|
+
readonly animated: boolean;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Owns rows independently of React renders. A row's identity is its type and key;
|
|
875
|
+
* changing either replaces the row. Treat item objects and their data as immutable.
|
|
876
|
+
*
|
|
877
|
+
* A source may feed multiple lists. Unmounting removes only that list's subscription.
|
|
878
|
+
* Call {@linkcode release} to explicitly empty and invalidate a source that is still
|
|
879
|
+
* referenced. Component-owned sources can otherwise be garbage collected.
|
|
880
|
+
* @see {@linkcode createListDataSource}
|
|
881
|
+
*/
|
|
882
|
+
export declare class ListDataSource<Types> {
|
|
883
|
+
private snapshot;
|
|
884
|
+
private readonly listeners;
|
|
885
|
+
private config;
|
|
886
|
+
private nextVersion;
|
|
887
|
+
private released;
|
|
888
|
+
constructor(config?: ListDataSourceConfig<Types>);
|
|
889
|
+
/** Number of rows currently owned by this source. */
|
|
890
|
+
get itemCount(): number;
|
|
891
|
+
/** Returns the row at an integer index; throws when the index is out of bounds. */
|
|
892
|
+
getItem(index: number): ListItem<Types>;
|
|
893
|
+
/**
|
|
894
|
+
* Replaces all rows, matching retained rows by type and key.
|
|
895
|
+
* @param animated Whether to animate the native changes. Defaults to false.
|
|
896
|
+
*/
|
|
897
|
+
replaceData(items: readonly ListItem<Types>[], animated?: boolean): void;
|
|
898
|
+
/** Inserts a row before index, or appends at {@linkcode itemCount}. Animates the change. */
|
|
899
|
+
insertItem(index: number, item: ListItem<Types>): void;
|
|
900
|
+
/** Updates a row, or replaces it if its type or key changes. Animates the change. */
|
|
901
|
+
updateItem(index: number, item: ListItem<Types>): void;
|
|
902
|
+
/** Removes the row at index. Animates the change. */
|
|
903
|
+
removeItem(index: number): void;
|
|
904
|
+
/** Moves a row to its final index without changing its identity. Animates the change. */
|
|
905
|
+
moveItem(fromIndex: number, toIndex: number): void;
|
|
906
|
+
/** @internal Returns the current snapshot without allocating a copy. */
|
|
907
|
+
getSnapshot(): ListDataSourceSnapshot<Types>;
|
|
908
|
+
/** @internal Observes future commits; the returned function removes the subscription. */
|
|
909
|
+
subscribe(listener: (snapshot: ListDataSourceSnapshot<Types>) => void): () => void;
|
|
910
|
+
/**
|
|
911
|
+
* Empties attached lists and releases rows and listeners. Safe to call repeatedly.
|
|
912
|
+
* Further mutations and new subscriptions throw.
|
|
913
|
+
*/
|
|
914
|
+
release(): void;
|
|
915
|
+
private ensureActive;
|
|
916
|
+
private validateIndex;
|
|
917
|
+
private validateItem;
|
|
918
|
+
private validateUniqueIdentity;
|
|
919
|
+
private isContentEqual;
|
|
920
|
+
private publish;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Creates an empty, JavaScript-owned {@linkcode ListDataSource}.
|
|
924
|
+
* @example
|
|
925
|
+
* const source = createListDataSource<{ message: { text: string } }>()
|
|
926
|
+
* source.replaceData([{ key: 'first', type: 'message', data: { text: 'Hello' } }])
|
|
927
|
+
* source.insertItem(1, { key: 'second', type: 'message', data: { text: 'World' } })
|
|
928
|
+
*/
|
|
929
|
+
export declare function createListDataSource<Types>(config?: ListDataSourceConfig<Types>): ListDataSource<Types>;
|
|
930
|
+
interface Row<Types, Type extends keyof Types & string = keyof Types & string> {
|
|
931
|
+
readonly item: ListItem<Types, Type>;
|
|
932
|
+
readonly index: number;
|
|
933
|
+
}
|
|
934
|
+
export type ListRenderers<Types> = { [Type in keyof Types & string]: (row: Row<Types, Type>) => Element; };
|
|
935
|
+
export interface ListProps<Types> extends Omit<ListHostProps, "horizontal"> {
|
|
936
|
+
readonly dataSource: ListDataSource<Types>;
|
|
937
|
+
readonly renderers: ListRenderers<Types>;
|
|
938
|
+
readonly horizontal?: boolean;
|
|
939
|
+
}
|
|
940
|
+
/** The native view borrows its source. A row keeps its Solid owner until its key or cell changes. */
|
|
941
|
+
export declare function List<Types>(props: ListProps<Types>): Element;
|
|
942
|
+
type ColorSchemeName = 'light' | 'dark';
|
|
943
|
+
type ColorSchemeOverride = ColorSchemeName | 'auto';
|
|
944
|
+
export declare const Appearance: {
|
|
945
|
+
/**
|
|
946
|
+
* Returns the color scheme the app uses, following the system setting.
|
|
947
|
+
* Prefer {@linkcode useColorScheme} in components.
|
|
948
|
+
* @throws On iOS, before the app's first window is created.
|
|
949
|
+
*/
|
|
950
|
+
getColorScheme(): ColorSchemeName;
|
|
951
|
+
/**
|
|
952
|
+
* Calls {@linkcode listener} when the color scheme changes.
|
|
953
|
+
* Remove the returned subscription when observation is no longer needed.
|
|
954
|
+
*/
|
|
955
|
+
addOnColorSchemeChangedListener(listener: (colorScheme: ColorSchemeName) => void): ListenerSubscription;
|
|
956
|
+
/**
|
|
957
|
+
* Forces a light or dark interface, or follows the system setting again with `'auto'`.
|
|
958
|
+
* The choice lasts until the app process ends.
|
|
959
|
+
*/
|
|
960
|
+
setColorScheme(colorScheme: ColorSchemeOverride): void;
|
|
961
|
+
};
|
|
962
|
+
export declare function useRootContext(): ViewController$1;
|
|
963
|
+
/** Reads the current safe area, preserving the snapshot identity for equal inset values. */
|
|
964
|
+
export declare function useSafeAreaInsets(): Accessor<EdgeInsets>;
|
|
965
|
+
export declare function useKeyboardInset(): Accessor<number>;
|
|
966
|
+
export declare function useColorScheme(): Accessor<ColorSchemeName>;
|
|
967
|
+
export declare function getViewLayoutNode(view: View$1): NLNodeRef;
|
|
968
|
+
interface KeyboardDismissOptions {
|
|
969
|
+
/** Animate the dismissal when supported by the platform. Defaults to `true`. */
|
|
970
|
+
animated?: boolean;
|
|
971
|
+
/** Keep the active text input focused. Defaults to `false`. */
|
|
972
|
+
keepFocus?: boolean;
|
|
973
|
+
}
|
|
974
|
+
export declare class Keyboard extends HybridObject {
|
|
975
|
+
/** Hides the software keyboard and resolves once the dismissal finishes. */
|
|
976
|
+
static dismiss(options?: KeyboardDismissOptions): Promise<void>;
|
|
977
|
+
}
|
|
978
|
+
export declare class TapGestureRecognizer extends GestureRecognizer {
|
|
979
|
+
constructor();
|
|
980
|
+
numberOfTapsRequired: number;
|
|
981
|
+
numberOfTouchesRequired: number;
|
|
982
|
+
gestureRecognizerShouldBegin?: GestureShouldBegin<TapGestureRecognizer>;
|
|
983
|
+
/** Called when a tap is recognized, with the view the recognizer is attached to. */
|
|
984
|
+
onTap?: (recognizer: TapGestureRecognizer, view: View$1) => void;
|
|
985
|
+
}
|
|
986
|
+
export declare class LongPressGestureRecognizer extends GestureRecognizer {
|
|
987
|
+
constructor();
|
|
988
|
+
/** The minimum press duration in seconds. Defaults to 0.5. */
|
|
989
|
+
minimumPressDuration: number;
|
|
990
|
+
/** The maximum movement in points before recognition fails. Defaults to 10. */
|
|
991
|
+
allowableMovement: number;
|
|
992
|
+
/** The number of full taps required before the final press. Defaults to 0. */
|
|
993
|
+
numberOfTapsRequired: number;
|
|
994
|
+
numberOfTouchesRequired: number;
|
|
995
|
+
gestureRecognizerShouldBegin?: GestureShouldBegin<LongPressGestureRecognizer>;
|
|
996
|
+
/** Called when the long press begins, changes, ends, or is cancelled, with the attached view. */
|
|
997
|
+
onLongPress?: (recognizer: LongPressGestureRecognizer, view: View$1) => void;
|
|
998
|
+
}
|
|
999
|
+
/** Registers a Solid component as the root of each native application window. */
|
|
1000
|
+
export declare function registerApp(App: () => Element): void;
|
|
1001
|
+
export { type Animator, Application, type ColorSchemeName, type ColorSchemeOverride, type ColorValue, type ContentInsetAdjustmentBehavior, type Corner, type CornerCurve, type EdgeInsets, type EllipsizeMode, Errored, type FontAsset, type FontWeight, For, type GestureShouldBegin, type KeyboardDismissOptions, type LayoutLength, type ListDataSourceConfig, type ListItem, type ListenerSubscription, Loading, Match, type Point, type Point3D, type RefreshControl, Repeat, Reveal, Show, Switch, type TextInputChange, type TextInputEdit, type TextRange, ViewController, Window, WindowScene, createComponent };
|