@molecule/app-ui 1.5.0 → 1.13.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/README.md +2067 -26
- package/dist/elements.d.ts +1322 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +28 -0
- package/dist/elements.js.map +1 -0
- package/dist/field-layout.d.ts +33 -0
- package/dist/field-layout.d.ts.map +1 -0
- package/dist/field-layout.js +34 -0
- package/dist/field-layout.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/overlay-position.d.ts +25 -0
- package/dist/overlay-position.d.ts.map +1 -0
- package/dist/overlay-position.js +77 -0
- package/dist/overlay-position.js.map +1 -0
- package/dist/overlay.d.ts +46 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +6 -0
- package/dist/overlay.js.map +1 -0
- package/dist/toast-countdown.d.ts +23 -0
- package/dist/toast-countdown.d.ts.map +1 -0
- package/dist/toast-countdown.js +56 -0
- package/dist/toast-countdown.js.map +1 -0
- package/dist/types.d.ts +56 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,1322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renderer-neutral elements: the props of the elements a React feature renders with, so one
|
|
3
|
+
* feature serves React DOM and React Native.
|
|
4
|
+
*
|
|
5
|
+
* Each element names the web tag it renders with a required `as` (`<Box as="ul">`). The web kit
|
|
6
|
+
* (`@molecule/app-ui-react/elements`) renders exactly that tag with the props given, so the DOM is
|
|
7
|
+
* the one a raw `<ul>` would produce. The native kit (`@molecule/app-ui-react-native`) renders a
|
|
8
|
+
* `View`, `Text`, `Pressable`, `TextInput`, `Image`, `ScrollView` or react-native-svg shape, with the
|
|
9
|
+
* accessibility role `as` implies.
|
|
10
|
+
*
|
|
11
|
+
* The props are the web names the features already use (`onClick`, `aria-label`, `data-mol-id`),
|
|
12
|
+
* limited to what both renderers can do. Anything only a browser has (pointer and drag events,
|
|
13
|
+
* `dangerouslySetInnerHTML`, CSS grid, `calc()`) is in no interface, so a feature that needs it is
|
|
14
|
+
* a compile error until it is registered web-only.
|
|
15
|
+
*
|
|
16
|
+
* Framework-agnostic: children are typed by each kit (`Node`).
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import type { PickedFile } from '@molecule/app-filesystem';
|
|
21
|
+
import type { ChangeEventHandler, CSSProperties, EventHandler, FocusEventHandler, FormEventHandler, KeyboardEventHandler, KitEvent, KitKeyboardEvent, KitModifierKeys, MouseEventHandler } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* What an element's `ref` receives on every renderer: a DOM element and a React Native host
|
|
24
|
+
* instance both satisfy it. Measure an element with the kit's `measureElement`, never with
|
|
25
|
+
* `getBoundingClientRect`.
|
|
26
|
+
*/
|
|
27
|
+
export interface ElementHandle {
|
|
28
|
+
/** Moves focus to the element. */
|
|
29
|
+
focus(): void;
|
|
30
|
+
/** Removes focus from the element. */
|
|
31
|
+
blur(): void;
|
|
32
|
+
/** Selects the entire current text field value, via DOM selection or native TextInput selection. */
|
|
33
|
+
select?(): void;
|
|
34
|
+
}
|
|
35
|
+
/** An element's box in the window, in CSS pixels on the web and density-independent pixels on native. */
|
|
36
|
+
export interface ElementBox {
|
|
37
|
+
/** Distance from the window's left edge. */
|
|
38
|
+
x: number;
|
|
39
|
+
/** Distance from the window's top edge. */
|
|
40
|
+
y: number;
|
|
41
|
+
/** Width of the box. */
|
|
42
|
+
width: number;
|
|
43
|
+
/** Height of the box. */
|
|
44
|
+
height: number;
|
|
45
|
+
}
|
|
46
|
+
/** The visible window containing a registered element. */
|
|
47
|
+
export interface ElementViewport {
|
|
48
|
+
/** Available width, excluding the browser's scrollbar, or the native window width. */
|
|
49
|
+
readonly width: number;
|
|
50
|
+
/** Full browser viewport or native window height. */
|
|
51
|
+
readonly height: number;
|
|
52
|
+
/** Height excluding the browser's scrollbar. Equal to height on a device. */
|
|
53
|
+
readonly contentHeight: number;
|
|
54
|
+
/** Web content uses the document scroll. Device content scrolls in an element. */
|
|
55
|
+
readonly scrollOwner: 'document' | 'element';
|
|
56
|
+
}
|
|
57
|
+
/** Which part of a registered element to measure, in window coordinates. */
|
|
58
|
+
export type ElementMeasureTarget =
|
|
59
|
+
/** The element's own rendered frame on web and device. */
|
|
60
|
+
'frame'
|
|
61
|
+
/** The browser's first child element, falling back to the registered frame on either renderer. */
|
|
62
|
+
| 'content-start';
|
|
63
|
+
/** One sample from the contact that owns a drag, in CSS pixels on web or dp on native. */
|
|
64
|
+
export interface ElementDragPoint extends KitModifierKeys {
|
|
65
|
+
/** Unclamped horizontal offset from the current HTML box, SVG viewport, or native frame. */
|
|
66
|
+
readonly x: number;
|
|
67
|
+
/** Unclamped vertical offset from the current HTML box, SVG viewport, or native frame. */
|
|
68
|
+
readonly y: number;
|
|
69
|
+
/** Horizontal displacement from contact-down in viewport axes on either renderer. */
|
|
70
|
+
readonly dx: number;
|
|
71
|
+
/** Vertical displacement from contact-down in viewport axes on either renderer. */
|
|
72
|
+
readonly dy: number;
|
|
73
|
+
/** Current frame in the same window space as the renderer's `measureElement`. */
|
|
74
|
+
readonly bounds: Readonly<ElementBox>;
|
|
75
|
+
}
|
|
76
|
+
/** One primary contact, owned until release or interruption on web and native. */
|
|
77
|
+
export interface ElementDrag {
|
|
78
|
+
/** Axis used to negotiate with an enclosing scroller on either renderer. Defaults to both. */
|
|
79
|
+
axis?: 'horizontal' | 'vertical' | 'both';
|
|
80
|
+
/** Whether touch acquires on contact or waits for a long press so an ordinary swipe can scroll. */
|
|
81
|
+
touchStart?: 'immediate' | 'longPress';
|
|
82
|
+
/** Acquires once, including a stationary mouse, pen, or touch on either renderer. */
|
|
83
|
+
onStart(point: ElementDragPoint): void;
|
|
84
|
+
/** Reports motion of the owned pointer or native responder, including outside the surface. */
|
|
85
|
+
onMove?(point: ElementDragPoint): void;
|
|
86
|
+
/** Reports the final position on web pointer-up or native touch release. */
|
|
87
|
+
onEnd?(point: ElementDragPoint): void;
|
|
88
|
+
/** Reports the last reliable sample on web capture loss or native responder interruption. */
|
|
89
|
+
onCancel?(point: ElementDragPoint): void;
|
|
90
|
+
}
|
|
91
|
+
/** Continuous manipulation of an element, through pointer capture or the native touch responder. */
|
|
92
|
+
export interface ElementDragProps {
|
|
93
|
+
/** Binds one contact on the current box or the enclosing SVG viewport. */
|
|
94
|
+
drag?: ElementDrag;
|
|
95
|
+
}
|
|
96
|
+
/** A length both renderers accept: pixels as a number, or a percentage of the parent. */
|
|
97
|
+
export type ElementLength = number | `${number}%`;
|
|
98
|
+
/**
|
|
99
|
+
* Inline layout and paint that CSS and React Native apply the same way. Numbers are CSS pixels on
|
|
100
|
+
* the web and density-independent pixels on native. Shorthand strings (`padding: '8px 12px'`,
|
|
101
|
+
* `border: '1px solid'`), CSS grid, `calc()`, `var()` and units other than pixels and percent are
|
|
102
|
+
* not accepted: write longhands, or use a ClassMap class (the nativewind ClassMap translates
|
|
103
|
+
* classes for native).
|
|
104
|
+
*/
|
|
105
|
+
export interface BoxStyle {
|
|
106
|
+
/** `'flex'` or `'none'`; every native view is a flex container. */
|
|
107
|
+
display?: 'flex' | 'none';
|
|
108
|
+
/** Positioning scheme. */
|
|
109
|
+
position?: 'relative' | 'absolute';
|
|
110
|
+
/** Offset from the containing block's top. */
|
|
111
|
+
top?: ElementLength;
|
|
112
|
+
/** Offset from the containing block's right. */
|
|
113
|
+
right?: ElementLength;
|
|
114
|
+
/** Offset from the containing block's bottom. */
|
|
115
|
+
bottom?: ElementLength;
|
|
116
|
+
/** Offset from the containing block's left. */
|
|
117
|
+
left?: ElementLength;
|
|
118
|
+
/** Width. */
|
|
119
|
+
width?: ElementLength;
|
|
120
|
+
/** Height. */
|
|
121
|
+
height?: ElementLength;
|
|
122
|
+
/** Minimum width. */
|
|
123
|
+
minWidth?: ElementLength;
|
|
124
|
+
/** Minimum height. */
|
|
125
|
+
minHeight?: ElementLength;
|
|
126
|
+
/** Maximum width. */
|
|
127
|
+
maxWidth?: ElementLength;
|
|
128
|
+
/** Maximum height. */
|
|
129
|
+
maxHeight?: ElementLength;
|
|
130
|
+
/** Margin on all sides. */
|
|
131
|
+
margin?: ElementLength | 'auto';
|
|
132
|
+
/** Top margin. */
|
|
133
|
+
marginTop?: ElementLength | 'auto';
|
|
134
|
+
/** Right margin. */
|
|
135
|
+
marginRight?: ElementLength | 'auto';
|
|
136
|
+
/** Bottom margin. */
|
|
137
|
+
marginBottom?: ElementLength | 'auto';
|
|
138
|
+
/** Left margin. */
|
|
139
|
+
marginLeft?: ElementLength | 'auto';
|
|
140
|
+
/** Padding on all sides. */
|
|
141
|
+
padding?: ElementLength;
|
|
142
|
+
/** Top padding. */
|
|
143
|
+
paddingTop?: ElementLength;
|
|
144
|
+
/** Right padding. */
|
|
145
|
+
paddingRight?: ElementLength;
|
|
146
|
+
/** Bottom padding. */
|
|
147
|
+
paddingBottom?: ElementLength;
|
|
148
|
+
/** Left padding. */
|
|
149
|
+
paddingLeft?: ElementLength;
|
|
150
|
+
/** Grow and shrink factor with a zero basis (`flex: 1`). */
|
|
151
|
+
flex?: number;
|
|
152
|
+
/** Grow factor. */
|
|
153
|
+
flexGrow?: number;
|
|
154
|
+
/** Shrink factor. */
|
|
155
|
+
flexShrink?: number;
|
|
156
|
+
/** Initial main size. */
|
|
157
|
+
flexBasis?: ElementLength | 'auto';
|
|
158
|
+
/** Main axis direction. */
|
|
159
|
+
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
160
|
+
/** Whether lines wrap. */
|
|
161
|
+
flexWrap?: 'wrap' | 'nowrap' | 'wrap-reverse';
|
|
162
|
+
/** Cross-axis alignment of children. */
|
|
163
|
+
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
164
|
+
/** Cross-axis alignment of this element. */
|
|
165
|
+
alignSelf?: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
166
|
+
/** Cross-axis alignment of wrapped lines. */
|
|
167
|
+
alignContent?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around' | 'space-evenly';
|
|
168
|
+
/** Main-axis alignment of children. */
|
|
169
|
+
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
170
|
+
/** Gap between children. */
|
|
171
|
+
gap?: number;
|
|
172
|
+
/** Gap between rows. */
|
|
173
|
+
rowGap?: number;
|
|
174
|
+
/** Gap between columns. */
|
|
175
|
+
columnGap?: number;
|
|
176
|
+
/** Clipping of overflowing children (scrolling content belongs in a `ScrollArea`). */
|
|
177
|
+
overflow?: 'visible' | 'hidden';
|
|
178
|
+
/** Stacking order. */
|
|
179
|
+
zIndex?: number;
|
|
180
|
+
/** Width-to-height ratio. */
|
|
181
|
+
aspectRatio?: number;
|
|
182
|
+
/** Whether the element receives pointer and touch events. */
|
|
183
|
+
pointerEvents?: 'auto' | 'none';
|
|
184
|
+
/** Opacity, 0 to 1. */
|
|
185
|
+
opacity?: number;
|
|
186
|
+
/** Background colour (a theme colour belongs in a ClassMap class). */
|
|
187
|
+
backgroundColor?: string;
|
|
188
|
+
/** Border width on all sides. */
|
|
189
|
+
borderWidth?: number;
|
|
190
|
+
/** Top border width. */
|
|
191
|
+
borderTopWidth?: number;
|
|
192
|
+
/** Right border width. */
|
|
193
|
+
borderRightWidth?: number;
|
|
194
|
+
/** Bottom border width. */
|
|
195
|
+
borderBottomWidth?: number;
|
|
196
|
+
/** Left border width. */
|
|
197
|
+
borderLeftWidth?: number;
|
|
198
|
+
/** Border colour on all sides. */
|
|
199
|
+
borderColor?: string;
|
|
200
|
+
/** Top border colour. */
|
|
201
|
+
borderTopColor?: string;
|
|
202
|
+
/** Right border colour. */
|
|
203
|
+
borderRightColor?: string;
|
|
204
|
+
/** Bottom border colour. */
|
|
205
|
+
borderBottomColor?: string;
|
|
206
|
+
/** Left border colour. */
|
|
207
|
+
borderLeftColor?: string;
|
|
208
|
+
/** Border line style. */
|
|
209
|
+
borderStyle?: 'solid' | 'dotted' | 'dashed';
|
|
210
|
+
/** Corner radius on all corners. */
|
|
211
|
+
borderRadius?: number;
|
|
212
|
+
/** Top-left corner radius. */
|
|
213
|
+
borderTopLeftRadius?: number;
|
|
214
|
+
/** Top-right corner radius. */
|
|
215
|
+
borderTopRightRadius?: number;
|
|
216
|
+
/** Bottom-left corner radius. */
|
|
217
|
+
borderBottomLeftRadius?: number;
|
|
218
|
+
/** Bottom-right corner radius. */
|
|
219
|
+
borderBottomRightRadius?: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* {@link BoxStyle} plus the text properties, for a {@link TextProps} element only: on native,
|
|
223
|
+
* text styles apply to a `Text` and are not inherited from a view.
|
|
224
|
+
*/
|
|
225
|
+
export interface TextStyle extends BoxStyle {
|
|
226
|
+
/** Text colour (a theme colour belongs in a ClassMap class). */
|
|
227
|
+
color?: string;
|
|
228
|
+
/** Font size. */
|
|
229
|
+
fontSize?: number;
|
|
230
|
+
/** Font weight. */
|
|
231
|
+
fontWeight?: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
232
|
+
/** Font style. */
|
|
233
|
+
fontStyle?: 'normal' | 'italic';
|
|
234
|
+
/** Line height in pixels (a multiplier such as `1.5` belongs in a ClassMap class). */
|
|
235
|
+
lineHeight?: `${number}px`;
|
|
236
|
+
/** Spacing between letters. */
|
|
237
|
+
letterSpacing?: number;
|
|
238
|
+
/** Horizontal alignment. */
|
|
239
|
+
textAlign?: 'left' | 'right' | 'center' | 'justify';
|
|
240
|
+
/** Letter case. */
|
|
241
|
+
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
242
|
+
/** Underline and strike-through. */
|
|
243
|
+
textDecorationLine?: 'none' | 'underline' | 'line-through' | 'underline line-through';
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* An element's `webStyle`: CSS for the web (resets of browser defaults such as a button's border
|
|
247
|
+
* and outline, cursors, shadows, or a consumer's `style` a kit component passes on). The web kit
|
|
248
|
+
* applies it after `style`. The native kit applies only the keys {@link TextStyle} names whose
|
|
249
|
+
* values a device can draw (`width: 200`, not `width: '10rem'`), so layout a feature means for
|
|
250
|
+
* both renderers belongs in `style`, which the compiler holds to that subset.
|
|
251
|
+
*/
|
|
252
|
+
export type WebStyle = CSSProperties;
|
|
253
|
+
/** Roles a feature gives an element (an explicit role overrides the one its `as` implies). */
|
|
254
|
+
export type ElementRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'blockquote' | 'button' | 'caption' | 'cell' | 'checkbox' | 'code' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'deletion' | 'dialog' | 'directory' | 'document' | 'emphasis' | 'feed' | 'figure' | 'form' | 'generic' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'insertion' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'meter' | 'navigation' | 'none' | 'note' | 'option' | 'paragraph' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'strong' | 'subscript' | 'superscript' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'time' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
|
255
|
+
/** `data-*` attributes: `data-mol-id` becomes the native `testID`; the rest are web-only. */
|
|
256
|
+
export type DataAttributes = {
|
|
257
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* A boolean ARIA value, as React DOM takes one: `true`/`false`, or the attribute's own spelling
|
|
261
|
+
* `'true'`/`'false'` (`aria-hidden="true"`). A device reads `'false'` as false.
|
|
262
|
+
*/
|
|
263
|
+
export type AriaBoolean = boolean | 'true' | 'false';
|
|
264
|
+
/** The accessibility attributes both renderers apply. */
|
|
265
|
+
export interface AriaAttributes {
|
|
266
|
+
'aria-label'?: string;
|
|
267
|
+
'aria-labelledby'?: string;
|
|
268
|
+
'aria-describedby'?: string;
|
|
269
|
+
'aria-hidden'?: AriaBoolean;
|
|
270
|
+
'aria-disabled'?: AriaBoolean;
|
|
271
|
+
'aria-expanded'?: AriaBoolean;
|
|
272
|
+
'aria-selected'?: AriaBoolean;
|
|
273
|
+
'aria-checked'?: AriaBoolean | 'mixed';
|
|
274
|
+
'aria-pressed'?: AriaBoolean | 'mixed';
|
|
275
|
+
'aria-busy'?: AriaBoolean;
|
|
276
|
+
'aria-live'?: 'off' | 'polite' | 'assertive';
|
|
277
|
+
'aria-valuenow'?: number;
|
|
278
|
+
'aria-valuemin'?: number;
|
|
279
|
+
'aria-valuemax'?: number;
|
|
280
|
+
'aria-valuetext'?: string;
|
|
281
|
+
'aria-current'?: AriaBoolean | 'page' | 'step' | 'location' | 'date' | 'time';
|
|
282
|
+
'aria-controls'?: string;
|
|
283
|
+
'aria-haspopup'?: AriaBoolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
284
|
+
'aria-modal'?: AriaBoolean;
|
|
285
|
+
'aria-invalid'?: AriaBoolean;
|
|
286
|
+
'aria-required'?: AriaBoolean;
|
|
287
|
+
'aria-readonly'?: AriaBoolean;
|
|
288
|
+
'aria-orientation'?: 'horizontal' | 'vertical';
|
|
289
|
+
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
|
290
|
+
/** Web heading or tree depth. Native announces the depth and keeps the element's role. */
|
|
291
|
+
'aria-level'?: number;
|
|
292
|
+
/** Web row total. Native exposes collection metadata or announces the localized total. */
|
|
293
|
+
'aria-rowcount'?: number;
|
|
294
|
+
/** Web column total. Native exposes collection metadata or announces the localized total. */
|
|
295
|
+
'aria-colcount'?: number;
|
|
296
|
+
/** One-based web row position. Native converts to collection metadata or announces the position. */
|
|
297
|
+
'aria-rowindex'?: number;
|
|
298
|
+
/** One-based web column position. Native converts to collection metadata or announces the position. */
|
|
299
|
+
'aria-colindex'?: number;
|
|
300
|
+
}
|
|
301
|
+
/** Props every element takes. */
|
|
302
|
+
export interface ElementProps extends AriaAttributes, DataAttributes {
|
|
303
|
+
/** Element id (native `nativeID`). */
|
|
304
|
+
id?: string;
|
|
305
|
+
/** ClassMap classes (`cm.*`). */
|
|
306
|
+
className?: string;
|
|
307
|
+
/** Accessibility role, when it differs from the one `as` implies. */
|
|
308
|
+
role?: ElementRole;
|
|
309
|
+
}
|
|
310
|
+
/** Pass-through props of each element variant after the component's own keys are removed. */
|
|
311
|
+
export type ForwardedElementProps<P, Owned extends PropertyKey = never> = P extends unknown ? Omit<P, 'as' | Owned> : never;
|
|
312
|
+
/** The interaction handlers a focusable element takes on both renderers. */
|
|
313
|
+
export interface InteractionProps {
|
|
314
|
+
/** Activation: a click on the web, a press on native. */
|
|
315
|
+
onClick?: MouseEventHandler;
|
|
316
|
+
/** Pointer enters (native: hover in, where the device has a pointer). */
|
|
317
|
+
onMouseEnter?: MouseEventHandler;
|
|
318
|
+
/** Pointer leaves (native: hover out). */
|
|
319
|
+
onMouseLeave?: MouseEventHandler;
|
|
320
|
+
/** The element gains focus. */
|
|
321
|
+
onFocus?: FocusEventHandler;
|
|
322
|
+
/** The element loses focus. */
|
|
323
|
+
onBlur?: FocusEventHandler;
|
|
324
|
+
/** A hardware key goes down; every key action also needs a touch route. */
|
|
325
|
+
onKeyDown?: KeyboardEventHandler;
|
|
326
|
+
/** A hardware key goes up. */
|
|
327
|
+
onKeyUp?: KeyboardEventHandler;
|
|
328
|
+
/** Web-only: a device has no double click. */
|
|
329
|
+
onDoubleClick?: MouseEventHandler;
|
|
330
|
+
/** Web-only (deprecated on the web too); a hardware key press. */
|
|
331
|
+
onKeyPress?: KeyboardEventHandler;
|
|
332
|
+
/** Tab order: in it (`0`) or only programmatically focusable (`-1`). */
|
|
333
|
+
tabIndex?: number;
|
|
334
|
+
}
|
|
335
|
+
/** Mouse handlers for containers and controls with corresponding device gestures. */
|
|
336
|
+
export interface MousePressProps {
|
|
337
|
+
/** DOM context menu. Native calls this for a stationary long press or secondary activation. */
|
|
338
|
+
onContextMenu?: MouseEventHandler;
|
|
339
|
+
/** DOM mouse down. Native calls this on press-in and observes canceled activation. */
|
|
340
|
+
onMouseDown?: MouseEventHandler;
|
|
341
|
+
}
|
|
342
|
+
/** Web container tags and their native view counterparts, including paragraphs with controls. */
|
|
343
|
+
export type BoxTag = 'div' | 'span' | 'p' | 'section' | 'header' | 'footer' | 'main' | 'aside' | 'nav' | 'article' | 'ul' | 'ol' | 'li' | 'dl' | 'dd' | 'figure' | 'address';
|
|
344
|
+
/**
|
|
345
|
+
* A container (native `View`; a native `Pressable` when it has a press, hover or focus handler or a
|
|
346
|
+
* tab stop, as a `div` with `onClick` is). Bare text inside it is laid out as the web lays it out
|
|
347
|
+
* (in a flex container, its own flex item; in any other, a line with its inline siblings). Use
|
|
348
|
+
* {@link PressableProps} for a control: a button, or anything announced as one.
|
|
349
|
+
*/
|
|
350
|
+
export interface BoxProps<Node = unknown> extends ElementProps, InteractionProps, MousePressProps, ElementDragProps {
|
|
351
|
+
/** The web tag. A label activates the first labelable control it wraps. */
|
|
352
|
+
as: BoxTag | 'label';
|
|
353
|
+
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
|
|
354
|
+
title?: string;
|
|
355
|
+
/** HTML hidden state. Native excludes the box from layout, hits and accessibility while mounted. */
|
|
356
|
+
hidden?: boolean;
|
|
357
|
+
/** Native groups the box and its contents as one screen-reader element when true. Web ignores this. */
|
|
358
|
+
accessibilityGroup?: boolean;
|
|
359
|
+
/** Web outside mouse down. Native observes outside touches in the enclosing box tree. */
|
|
360
|
+
onPressOutside?: () => void;
|
|
361
|
+
/** Observes touch-down, including on a child, without claiming it on web or native. */
|
|
362
|
+
onTouchStart?: () => void;
|
|
363
|
+
/** A browser double-click, native double tap, or native assistive action. */
|
|
364
|
+
secondaryAction?: {
|
|
365
|
+
/** Localized name for the native accessibility action. The browser adds no attribute. */
|
|
366
|
+
label: string;
|
|
367
|
+
/** Runs the secondary action from the browser event or native gesture or assistive action. */
|
|
368
|
+
run: () => void;
|
|
369
|
+
};
|
|
370
|
+
/** Consumes plain-text paste on the web or through a native field or focused Paste command. */
|
|
371
|
+
onPasteText?: (text: string) => void;
|
|
372
|
+
/** Layout and paint both renderers apply. */
|
|
373
|
+
style?: BoxStyle & {
|
|
374
|
+
/**
|
|
375
|
+
* URI painted behind the contents, centered and sized to cover the box. Web emits
|
|
376
|
+
* CSS background declarations here. Native draws a decorative image within the box.
|
|
377
|
+
* An empty URI leaves the box's background color visible.
|
|
378
|
+
*/
|
|
379
|
+
coverImage?: string;
|
|
380
|
+
};
|
|
381
|
+
/** Web-only paint. */
|
|
382
|
+
webStyle?: WebStyle;
|
|
383
|
+
/** Child elements. */
|
|
384
|
+
children?: Node;
|
|
385
|
+
}
|
|
386
|
+
/** Attributes of the browser summary or its native pressable control. */
|
|
387
|
+
export interface DisclosureSummaryProps extends ElementProps {
|
|
388
|
+
/** Layout and paint for the summary on web and device. */
|
|
389
|
+
style?: BoxStyle;
|
|
390
|
+
/** CSS for the summary. Devices apply the subset they can draw. */
|
|
391
|
+
webStyle?: WebStyle;
|
|
392
|
+
}
|
|
393
|
+
/** A disclosure with a first-child summary and a body that stays mounted while closed. */
|
|
394
|
+
export interface DisclosureProps<Node = unknown> extends ElementProps {
|
|
395
|
+
/** A literal details element on web and a view on device. */
|
|
396
|
+
as: 'details';
|
|
397
|
+
/** Initial open state and subsequent parent changes. Both renderers default to closed. */
|
|
398
|
+
open?: boolean;
|
|
399
|
+
/** Content of the browser summary or native pressable summary. */
|
|
400
|
+
summary: Node;
|
|
401
|
+
/** Attributes on the summary element or native pressable itself. */
|
|
402
|
+
summaryProps?: DisclosureSummaryProps;
|
|
403
|
+
/** Reports the resulting state after the browser toggle event or a queued native transition. */
|
|
404
|
+
onToggle?: (open: boolean) => void;
|
|
405
|
+
/** Layout and paint for the whole disclosure on web and device. */
|
|
406
|
+
style?: BoxStyle;
|
|
407
|
+
/** CSS for the details element. Devices apply the subset they can draw. */
|
|
408
|
+
webStyle?: WebStyle;
|
|
409
|
+
/** Body content. Both renderers hide it while closed and preserve its state. */
|
|
410
|
+
children?: Node;
|
|
411
|
+
}
|
|
412
|
+
/** A horizontal thematic break. Web renders a void element and native draws a themed line. */
|
|
413
|
+
export interface RuleProps extends ElementProps, Pick<BoxProps, 'style' | 'webStyle'> {
|
|
414
|
+
/** A literal hr on web and a separator view on device. */
|
|
415
|
+
as: 'hr';
|
|
416
|
+
/** A thematic break has no children on either renderer. */
|
|
417
|
+
children?: never;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* How a component takes part in a line of a container that is not a flex container: inline text
|
|
421
|
+
* (it renders a text element that joins the line), an inline box (a button, a badge, an icon:
|
|
422
|
+
* it sits in the line beside text), or `null` for a block. The web reads this from CSS; React
|
|
423
|
+
* Native has no inline layout, so the native kit is told (`registerInline` in each React kit).
|
|
424
|
+
*/
|
|
425
|
+
export type InlineKind = 'text' | 'box' | null;
|
|
426
|
+
/**
|
|
427
|
+
* A glyph of the icon font (Material Symbols): text on the web, which the font draws by ligature
|
|
428
|
+
* (`<span class="…">check_circle</span>`); its codepoint on native, which draws neither ligatures
|
|
429
|
+
* nor variable axes. It flows inline, as text.
|
|
430
|
+
*/
|
|
431
|
+
export interface GlyphIconProps extends ElementProps {
|
|
432
|
+
/** The glyph's name (`check_circle`). On native, a name the font does not draw renders nothing. */
|
|
433
|
+
name: string;
|
|
434
|
+
/** Draws the filled form (the font's `FILL` axis at 1). */
|
|
435
|
+
filled?: boolean;
|
|
436
|
+
/** Layout and text paint both renderers apply (`fontSize`). */
|
|
437
|
+
style?: TextStyle;
|
|
438
|
+
/** CSS for the web. */
|
|
439
|
+
webStyle?: WebStyle;
|
|
440
|
+
}
|
|
441
|
+
/** Fractions of one cycle and the paint at its dimmest point. */
|
|
442
|
+
export interface DotPulseMotion {
|
|
443
|
+
/** Full brightness as a fraction of the CSS keyframes and the native cycle, after zero. */
|
|
444
|
+
readonly peakAt: number;
|
|
445
|
+
/** Return to dim paint in the CSS keyframes and native cycle, after the peak and at or before one. */
|
|
446
|
+
readonly restAt: number;
|
|
447
|
+
/** Delay between dots as a fraction of a cycle, in the CSS animation and native driver. */
|
|
448
|
+
readonly stagger: number;
|
|
449
|
+
/** Opacity from zero to one at rest, set by the stylesheet and the native view animation. */
|
|
450
|
+
readonly dimOpacity: number;
|
|
451
|
+
/** Scale from zero to one at rest, set by the stylesheet and the native view animation. */
|
|
452
|
+
readonly dimScale: number;
|
|
453
|
+
}
|
|
454
|
+
/** The motion both renderers use when the ClassMap omits its typing pulse. */
|
|
455
|
+
export declare const DEFAULT_TYPING_PULSE: DotPulseMotion;
|
|
456
|
+
/** Three decorative dots drawn in the inherited text colour. */
|
|
457
|
+
export interface PulseDotsProps {
|
|
458
|
+
/** Dot diameter, applied to the span in CSS px and the native view in dp. */
|
|
459
|
+
size: number;
|
|
460
|
+
/** Duration of one CSS animation cycle on web or one native loop iteration on device, in ms. */
|
|
461
|
+
durationMs: number;
|
|
462
|
+
}
|
|
463
|
+
/** Web tags a {@link TextProps} element renders. */
|
|
464
|
+
export type TextTag = 'span' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'strong' | 'em' | 'small' | 'code' | 'pre' | 'kbd' | 'mark' | 'dt' | 'dd' | 'li' | 'figcaption';
|
|
465
|
+
/** Props shared by every {@link TextProps} variant. */
|
|
466
|
+
interface TextCommonProps<Node> extends ElementProps {
|
|
467
|
+
/** Layout, paint and text styles both renderers apply. */
|
|
468
|
+
style?: TextStyle;
|
|
469
|
+
/** Web-only paint. */
|
|
470
|
+
webStyle?: WebStyle;
|
|
471
|
+
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
|
|
472
|
+
title?: string;
|
|
473
|
+
/** Web translation metadata. A device displays the supplied text. */
|
|
474
|
+
translate?: 'yes' | 'no';
|
|
475
|
+
/** Text: strings, numbers and nested text elements. */
|
|
476
|
+
children?: Node;
|
|
477
|
+
}
|
|
478
|
+
/** Text (native `Text`); `h1`–`h6` read as headings on native. */
|
|
479
|
+
export type TextProps<Node = unknown> = (TextCommonProps<Node> & {
|
|
480
|
+
as: TextTag;
|
|
481
|
+
}) | (TextCommonProps<Node> & {
|
|
482
|
+
as: 'label';
|
|
483
|
+
/** The id of the control this label names and activates. */
|
|
484
|
+
htmlFor?: string;
|
|
485
|
+
}) | (TextCommonProps<Node> & {
|
|
486
|
+
as: 'time';
|
|
487
|
+
/** The machine-readable date or time. */
|
|
488
|
+
dateTime?: string;
|
|
489
|
+
});
|
|
490
|
+
/** Web tags a {@link PressableProps} element renders. */
|
|
491
|
+
export type PressableTag = 'button' | 'div' | 'span' | 'li';
|
|
492
|
+
/**
|
|
493
|
+
* Something the user activates (native `Pressable`). A string child renders as the web tag's own
|
|
494
|
+
* text and inside a native `Text`.
|
|
495
|
+
*/
|
|
496
|
+
export interface PressableProps<Node = unknown> extends ElementProps, InteractionProps, MousePressProps, ElementDragProps {
|
|
497
|
+
/** The web tag. */
|
|
498
|
+
as: PressableTag;
|
|
499
|
+
/** A button's type: always set it, a button inside a form submits it by default. */
|
|
500
|
+
type?: 'button' | 'submit' | 'reset';
|
|
501
|
+
/** Web-only: the form field name a submit button sends. */
|
|
502
|
+
name?: string;
|
|
503
|
+
/** Web-only: the value a submit button sends. */
|
|
504
|
+
value?: string;
|
|
505
|
+
/** Web-only: the id of the form the button belongs to. */
|
|
506
|
+
form?: string;
|
|
507
|
+
/** Whether it is disabled. */
|
|
508
|
+
disabled?: boolean;
|
|
509
|
+
/** A browser double-click, device double tap, or device assistive action. */
|
|
510
|
+
secondaryAction?: BoxProps['secondaryAction'];
|
|
511
|
+
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
|
|
512
|
+
title?: string;
|
|
513
|
+
/** Layout and paint both renderers apply. */
|
|
514
|
+
style?: BoxStyle;
|
|
515
|
+
/** Web-only paint. */
|
|
516
|
+
webStyle?: WebStyle;
|
|
517
|
+
/** Content: elements, or a string or number. */
|
|
518
|
+
children?: Node;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* A link (native `Pressable` with the link role): an app path navigates through the router, a
|
|
522
|
+
* URL on another origin opens outside the app. A string child renders as the link's text.
|
|
523
|
+
*/
|
|
524
|
+
export interface ElementLinkProps<Node = unknown> extends ElementProps, InteractionProps {
|
|
525
|
+
/** Destination: an app path (`/settings?tab=billing`) or a URL. */
|
|
526
|
+
to: string;
|
|
527
|
+
/** Replace the current history entry instead of pushing one. */
|
|
528
|
+
replace?: boolean;
|
|
529
|
+
/** State stored with the new history entry. */
|
|
530
|
+
state?: unknown;
|
|
531
|
+
/**
|
|
532
|
+
* Where a URL opens on the web: a browsing-context keyword or name (`_self`, `_blank`, `_parent`,
|
|
533
|
+
* `_top`, or a frame's name). On a device a URL opens outside the app whatever its target.
|
|
534
|
+
*/
|
|
535
|
+
target?: string;
|
|
536
|
+
/** Relationship of a URL to the page (`'noopener noreferrer'`). */
|
|
537
|
+
rel?: string;
|
|
538
|
+
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
|
|
539
|
+
title?: string;
|
|
540
|
+
/** Layout and paint both renderers apply. */
|
|
541
|
+
style?: BoxStyle;
|
|
542
|
+
/** Web-only paint. */
|
|
543
|
+
webStyle?: WebStyle;
|
|
544
|
+
/** Content: elements, or a string or number. */
|
|
545
|
+
children?: Node;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* A literal anchor with no router. Web keeps the browsing context (`target`) and link
|
|
549
|
+
* relationship (`rel`), which have no device equivalent. Both renderers call `onClick` before
|
|
550
|
+
* the default action and honor `preventDefault()`.
|
|
551
|
+
*/
|
|
552
|
+
export type AnchorProps<Node = unknown> = Omit<ElementLinkProps<Node>, 'to' | 'replace' | 'state'> & {
|
|
553
|
+
/**
|
|
554
|
+
* The literal `href` on the web. A device passes absolute URLs to the OS, resolves relative
|
|
555
|
+
* URLs against the app's configured public document URL, and stays on the current screen for
|
|
556
|
+
* `'#'`. A relative URL with no configured base reports a diagnostic on press.
|
|
557
|
+
*/
|
|
558
|
+
href: string;
|
|
559
|
+
};
|
|
560
|
+
/** Keyboard input received by a browser text field or native TextInput. */
|
|
561
|
+
export interface TextFieldKeyEvent extends KitKeyboardEvent {
|
|
562
|
+
/** The browser reports IME-owned keystrokes, including legacy key code 229. Device key events omit it. */
|
|
563
|
+
readonly isComposing?: boolean;
|
|
564
|
+
}
|
|
565
|
+
/** Props common to a browser text field or text area and the native TextInput. */
|
|
566
|
+
export interface TextFieldBaseProps extends ElementProps, Omit<InteractionProps, 'onKeyDown'> {
|
|
567
|
+
/** `input` for one line, `textarea` for several. */
|
|
568
|
+
as: 'input' | 'textarea';
|
|
569
|
+
/**
|
|
570
|
+
* The kind of text (`input` only). A device takes a date or time as text in the web's value
|
|
571
|
+
* format (`YYYY-MM-DD`, `HH:MM`, `YYYY-MM-DDTHH:MM`), so a form receives the same value.
|
|
572
|
+
*/
|
|
573
|
+
type?: 'text' | 'email' | 'password' | 'search' | 'number' | 'tel' | 'url' | 'date' | 'time' | 'datetime-local';
|
|
574
|
+
/** The on-screen keyboard to show. */
|
|
575
|
+
inputMode?: 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
576
|
+
/** The field's text. */
|
|
577
|
+
value?: string;
|
|
578
|
+
/** The text of a field whose text the caller does not hold, when it mounts. */
|
|
579
|
+
defaultValue?: string;
|
|
580
|
+
/** Text shown while the field is empty. */
|
|
581
|
+
placeholder?: string;
|
|
582
|
+
/** Whether the user can edit the text. */
|
|
583
|
+
readOnly?: boolean;
|
|
584
|
+
/** Whether it is disabled. */
|
|
585
|
+
disabled?: boolean;
|
|
586
|
+
/** Whether a form refuses to submit while the field is empty. */
|
|
587
|
+
required?: boolean;
|
|
588
|
+
/** Longest text the field accepts. */
|
|
589
|
+
maxLength?: number;
|
|
590
|
+
/** Shortest text a form accepts in the field. */
|
|
591
|
+
minLength?: number;
|
|
592
|
+
/** Web-only: a pattern a form checks the text against. */
|
|
593
|
+
pattern?: string;
|
|
594
|
+
/** Visible lines (`textarea` only). */
|
|
595
|
+
rows?: number;
|
|
596
|
+
/** Web-only: visible columns (`textarea` only). */
|
|
597
|
+
cols?: number;
|
|
598
|
+
/** Web-only: how a form sends the text's line breaks (`textarea` only). */
|
|
599
|
+
wrap?: 'hard' | 'soft' | 'off';
|
|
600
|
+
/**
|
|
601
|
+
* Grows the field with its text, between these line counts (`textarea` only): the field is
|
|
602
|
+
* `minRows` lines tall when nearly empty and scrolls past `maxRows`.
|
|
603
|
+
*/
|
|
604
|
+
autoGrow?: {
|
|
605
|
+
minRows: number;
|
|
606
|
+
maxRows?: number;
|
|
607
|
+
};
|
|
608
|
+
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
|
|
609
|
+
title?: string;
|
|
610
|
+
/** The autofill hint. */
|
|
611
|
+
autoComplete?: string;
|
|
612
|
+
/** Web spell checking. Native passes the boolean on devices with a spell-check control. */
|
|
613
|
+
spellCheck?: boolean;
|
|
614
|
+
/** Web autocorrection hint. Native maps `'on'` and `'off'` to a boolean. */
|
|
615
|
+
autoCorrect?: 'on' | 'off';
|
|
616
|
+
/** Web return-key label. Native uses the hint when the platform supports it. */
|
|
617
|
+
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
618
|
+
/** Moves focus to the field when it mounts. */
|
|
619
|
+
autoFocus?: boolean;
|
|
620
|
+
/** Selects the field's text on focus in the browser and on a device. */
|
|
621
|
+
selectTextOnFocus?: boolean;
|
|
622
|
+
/** Consumes nonempty plain-text paste before insertion and length limits on web and native. */
|
|
623
|
+
onPasteText?: (text: string) => void;
|
|
624
|
+
/** Field name. */
|
|
625
|
+
name?: string;
|
|
626
|
+
/**
|
|
627
|
+
* The text changed; read `(event.target as HTMLInputElement).value` on the web. Prefer
|
|
628
|
+
* {@link TextFieldProps.onValueChange}, which native can supply too.
|
|
629
|
+
*/
|
|
630
|
+
onChange?: ChangeEventHandler;
|
|
631
|
+
/** The text changed, with the new text. */
|
|
632
|
+
onValueChange?: (value: string) => void;
|
|
633
|
+
/** Browser key-down with composition state, or a key delivered by the device's TextInput. */
|
|
634
|
+
onKeyDown?: EventHandler<TextFieldKeyEvent>;
|
|
635
|
+
/** The text changed: fires with {@link TextFieldProps.onChange} on each edit, on both renderers. */
|
|
636
|
+
onInput?: FormEventHandler;
|
|
637
|
+
/** Layout, paint and text styles both renderers apply. */
|
|
638
|
+
style?: TextStyle;
|
|
639
|
+
/** Web-only paint (a field's border and outline resets). */
|
|
640
|
+
webStyle?: WebStyle;
|
|
641
|
+
}
|
|
642
|
+
/** Inclusive bounds and step for a number or calendar-date field. */
|
|
643
|
+
export interface FieldBounds<T> {
|
|
644
|
+
/** HTML minimum attribute. Native uses it as an inclusive lower bound and step base. */
|
|
645
|
+
min?: T;
|
|
646
|
+
/** HTML maximum attribute. Native uses it as an inclusive upper bound. */
|
|
647
|
+
max?: T;
|
|
648
|
+
/** Increment on both renderers, in days for dates. 'any' disables step validation. */
|
|
649
|
+
step?: number | 'any';
|
|
650
|
+
}
|
|
651
|
+
/** Web and native text fields accept bounds only on number and date inputs. */
|
|
652
|
+
export type TextFieldProps = TextFieldBaseProps & ({
|
|
653
|
+
min?: never;
|
|
654
|
+
max?: never;
|
|
655
|
+
step?: never;
|
|
656
|
+
} | ({
|
|
657
|
+
as: 'input';
|
|
658
|
+
type: 'number';
|
|
659
|
+
} & FieldBounds<number>) | ({
|
|
660
|
+
as: 'input';
|
|
661
|
+
type: 'date';
|
|
662
|
+
} & FieldBounds<string>));
|
|
663
|
+
/** A numeric range rendered by the browser's range input or the device's adjustable slider. */
|
|
664
|
+
export interface RangeFieldProps extends ElementProps, InteractionProps {
|
|
665
|
+
/** Optional position of the fixed web type attribute. Native always uses a slider. */
|
|
666
|
+
type?: 'range';
|
|
667
|
+
/** Lower bound. The browser and device use 0 when it is omitted. */
|
|
668
|
+
min?: number;
|
|
669
|
+
/** Upper bound. The browser and device use 100 when it is omitted. */
|
|
670
|
+
max?: number;
|
|
671
|
+
/** Controlled value. The browser and device clamp and align it to their range. */
|
|
672
|
+
value?: number;
|
|
673
|
+
/** Initial and reset value when uncontrolled. The browser and device otherwise use the midpoint. */
|
|
674
|
+
defaultValue?: number;
|
|
675
|
+
/** Allowed value spacing. Both renderers default to 1. Use `'any'` for continuous values. */
|
|
676
|
+
step?: number | 'any';
|
|
677
|
+
/** Disables pointer and keyboard edits and excludes the field from forms on both renderers. */
|
|
678
|
+
disabled?: boolean;
|
|
679
|
+
/** Field name used for form submission on the browser and device. */
|
|
680
|
+
name?: string;
|
|
681
|
+
/** Called with the numeric value of each user edit on the browser and device. */
|
|
682
|
+
onValueChange?: (value: number) => void;
|
|
683
|
+
/** Layout and paint applied by both the browser and device. */
|
|
684
|
+
style?: BoxStyle;
|
|
685
|
+
/** CSS layered over `style` in the browser. The device applies the subset it can draw. */
|
|
686
|
+
webStyle?: WebStyle;
|
|
687
|
+
}
|
|
688
|
+
/** A browse target that delivers an ordered batch of selected files. */
|
|
689
|
+
export interface FileFieldProps<Node = unknown> extends ElementProps {
|
|
690
|
+
/** Content of the browse target. */
|
|
691
|
+
children?: Node;
|
|
692
|
+
/** Comma-separated extensions, MIME types, MIME wildcards or `*`. */
|
|
693
|
+
accept?: string;
|
|
694
|
+
/** Deliver all accepted files. Defaults to delivering the first accepted file. */
|
|
695
|
+
multiple?: boolean;
|
|
696
|
+
/** Inclusive per-file limit in bytes. */
|
|
697
|
+
maxSize?: number;
|
|
698
|
+
/** Prevents opening the chooser or delivering files. */
|
|
699
|
+
disabled?: boolean;
|
|
700
|
+
/** Receives a nonempty batch of accepted files in selection order. */
|
|
701
|
+
onValueChange(files: readonly PickedFile[]): void;
|
|
702
|
+
/** Receives a nonempty batch of files rejected by the type or size filter. */
|
|
703
|
+
onRejected?(files: readonly PickedFile[]): void;
|
|
704
|
+
/** Receives a failure to open the chooser or read its selection. */
|
|
705
|
+
onPickError?(error: Error): void;
|
|
706
|
+
}
|
|
707
|
+
/** One selectable row in the browser's select and the device's option list. */
|
|
708
|
+
export interface SelectFieldOption {
|
|
709
|
+
/** Value reported on selection and submitted by either renderer. */
|
|
710
|
+
value: string;
|
|
711
|
+
/** Plain text shown by the browser and by the device. */
|
|
712
|
+
label: string;
|
|
713
|
+
/** Both renderers keep the row visible but exclude it from edits and form entries. */
|
|
714
|
+
disabled?: boolean;
|
|
715
|
+
/** Reflects this option's initial selection as a web reset attribute. Device uses the field value. */
|
|
716
|
+
webDefaultSelected?: true;
|
|
717
|
+
}
|
|
718
|
+
/** A browser optgroup and the corresponding device list section. */
|
|
719
|
+
export interface SelectFieldGroup {
|
|
720
|
+
/** The browser's optgroup label and the device's noninteractive heading. */
|
|
721
|
+
label: string;
|
|
722
|
+
/** Options in display and submission order on both renderers. */
|
|
723
|
+
options: readonly SelectFieldOption[];
|
|
724
|
+
}
|
|
725
|
+
interface SelectFieldCommonProps extends ElementProps, InteractionProps {
|
|
726
|
+
/** Renders a `select` in the browser and a trigger with a modal option list on a device. */
|
|
727
|
+
as: 'select';
|
|
728
|
+
/** Options and groups in browser DOM and device list order. */
|
|
729
|
+
options: readonly (SelectFieldOption | SelectFieldGroup)[];
|
|
730
|
+
/** The name used for each successful option in browser and device form entries. */
|
|
731
|
+
name?: string;
|
|
732
|
+
/** Both renderers validate selectedness on form submission. */
|
|
733
|
+
required?: boolean;
|
|
734
|
+
/** Both renderers block edits and omit a disabled field from form submission. */
|
|
735
|
+
disabled?: boolean;
|
|
736
|
+
/** Focuses the enabled browser select or device trigger when it mounts. */
|
|
737
|
+
autoFocus?: boolean;
|
|
738
|
+
/** The browser tooltip and a fallback name or supplementary accessibility hint on device. */
|
|
739
|
+
title?: string;
|
|
740
|
+
/** Browser translation metadata. Devices display the option labels as supplied. */
|
|
741
|
+
translate?: 'yes' | 'no';
|
|
742
|
+
/** Styles the browser select and the device trigger and its text. */
|
|
743
|
+
style?: TextStyle;
|
|
744
|
+
/** CSS applied last on the browser select. The device applies the subset it can draw. */
|
|
745
|
+
webStyle?: WebStyle;
|
|
746
|
+
/** Fires before the value handler with the browser change event or device selection snapshot. */
|
|
747
|
+
onChange?: ChangeEventHandler;
|
|
748
|
+
}
|
|
749
|
+
type SelectFieldValue<Value> = {
|
|
750
|
+
/** Caller-owned selection on web and device. */
|
|
751
|
+
value: Value;
|
|
752
|
+
/** The browser and device use the controlled value instead of a default in this mode. */
|
|
753
|
+
defaultValue?: never;
|
|
754
|
+
} | {
|
|
755
|
+
/** Omit on both renderers to let the field hold its selection. */
|
|
756
|
+
value?: never;
|
|
757
|
+
/** Initial and reset selection for an uncontrolled browser or device field. */
|
|
758
|
+
defaultValue?: Value;
|
|
759
|
+
};
|
|
760
|
+
/** A single or multiple select with the same option and value contract on web and device. */
|
|
761
|
+
export type SelectFieldProps = SelectFieldCommonProps & (({
|
|
762
|
+
/** The browser select and the device list allow one selected option. */
|
|
763
|
+
multiple?: false;
|
|
764
|
+
/** Reports the selected string on user edits in either renderer. */
|
|
765
|
+
onValueChange?: (value: string) => void;
|
|
766
|
+
} & SelectFieldValue<string>) | ({
|
|
767
|
+
/** The browser select and the device list allow multiple selected options. */
|
|
768
|
+
multiple: true;
|
|
769
|
+
/** Reports every selected string in option order on a user edit in either renderer. */
|
|
770
|
+
onValueChange?: (values: readonly string[]) => void;
|
|
771
|
+
} & SelectFieldValue<readonly string[]>));
|
|
772
|
+
/** A successful control's value, including files from a web form. */
|
|
773
|
+
export type FormEntryValue = string | Blob;
|
|
774
|
+
/** A form's successful controls in order, with repeated names preserved. */
|
|
775
|
+
export type FormEntries = ReadonlyArray<readonly [name: string, value: FormEntryValue]>;
|
|
776
|
+
/** The form element's focus and submission methods. */
|
|
777
|
+
export interface FormAreaHandle extends ElementHandle {
|
|
778
|
+
/** Attempts submission through normal form validation. */
|
|
779
|
+
requestSubmit(): void;
|
|
780
|
+
}
|
|
781
|
+
/** A form and its submission, validation and reset handlers. */
|
|
782
|
+
export interface FormAreaProps<Node = unknown> extends ElementProps {
|
|
783
|
+
/** The web tag. */
|
|
784
|
+
as: 'form';
|
|
785
|
+
/** Web-only: browser submission destination. */
|
|
786
|
+
action?: string;
|
|
787
|
+
/** Web-only: browser submission method. */
|
|
788
|
+
method?: 'get' | 'post' | 'dialog';
|
|
789
|
+
/** Submits even if a field fails validation. */
|
|
790
|
+
noValidate?: boolean;
|
|
791
|
+
/** Whether browser autofill is enabled for the form. */
|
|
792
|
+
autoComplete?: 'on' | 'off';
|
|
793
|
+
/** Receives the event and the same entries as `new FormData(form)` on the web. */
|
|
794
|
+
onSubmit?: (event: KitEvent, entries: FormEntries) => void;
|
|
795
|
+
/** Fires before uncontrolled fields return to their defaults. Calling preventDefault cancels reset. */
|
|
796
|
+
onReset?: FormEventHandler;
|
|
797
|
+
/** Layout and paint both renderers apply. */
|
|
798
|
+
style?: BoxStyle;
|
|
799
|
+
/** Web-only paint. */
|
|
800
|
+
webStyle?: WebStyle;
|
|
801
|
+
/** The form's content. */
|
|
802
|
+
children?: Node;
|
|
803
|
+
}
|
|
804
|
+
/** Groups controls and disables them together when necessary. */
|
|
805
|
+
export interface FieldsetProps<Node = unknown> extends ElementProps {
|
|
806
|
+
/** The web tag. */
|
|
807
|
+
as: 'fieldset';
|
|
808
|
+
/** Disables the form controls inside it. */
|
|
809
|
+
disabled?: boolean;
|
|
810
|
+
/** The group name. */
|
|
811
|
+
name?: string;
|
|
812
|
+
/** Layout and paint both renderers apply. */
|
|
813
|
+
style?: BoxStyle;
|
|
814
|
+
/** Web-only paint. */
|
|
815
|
+
webStyle?: WebStyle;
|
|
816
|
+
/** The group's content. */
|
|
817
|
+
children?: Node;
|
|
818
|
+
}
|
|
819
|
+
/** A checkbox or radio's state and activation methods. */
|
|
820
|
+
export interface CheckFieldHandle extends ElementHandle {
|
|
821
|
+
/** Activates the control as a user click or press would. */
|
|
822
|
+
click(): void;
|
|
823
|
+
/** The checked state at the time the handle is read. */
|
|
824
|
+
readonly checked: boolean;
|
|
825
|
+
}
|
|
826
|
+
/** Props shared by checkboxes and radios. */
|
|
827
|
+
interface CheckFieldCommonProps extends ElementProps {
|
|
828
|
+
as: 'input';
|
|
829
|
+
name?: string;
|
|
830
|
+
/** Form value when checked, defaulting to `'on'`. */
|
|
831
|
+
value?: string;
|
|
832
|
+
disabled?: boolean;
|
|
833
|
+
required?: boolean;
|
|
834
|
+
autoFocus?: boolean;
|
|
835
|
+
/** Receives the change event. Its target's `checked` gives the new state. */
|
|
836
|
+
onChange?: ChangeEventHandler;
|
|
837
|
+
/** Web-only: delivers the DOM change event to a legacy handler that expects it. */
|
|
838
|
+
nativeChangeEvent?: boolean;
|
|
839
|
+
/** Receives the new checked state directly. */
|
|
840
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
841
|
+
onClick?: MouseEventHandler;
|
|
842
|
+
onFocus?: FocusEventHandler;
|
|
843
|
+
onBlur?: FocusEventHandler;
|
|
844
|
+
tabIndex?: number;
|
|
845
|
+
style?: BoxStyle;
|
|
846
|
+
webStyle?: WebStyle;
|
|
847
|
+
}
|
|
848
|
+
/** A checkbox, or a radio whose checked state is owned by its group. */
|
|
849
|
+
export type CheckFieldProps = (CheckFieldCommonProps & {
|
|
850
|
+
type: 'checkbox';
|
|
851
|
+
checked?: boolean;
|
|
852
|
+
defaultChecked?: boolean;
|
|
853
|
+
/** Draws the mixed state. */
|
|
854
|
+
indeterminate?: boolean;
|
|
855
|
+
}) | (CheckFieldCommonProps & {
|
|
856
|
+
type: 'radio';
|
|
857
|
+
checked: boolean;
|
|
858
|
+
defaultChecked?: never;
|
|
859
|
+
indeterminate?: never;
|
|
860
|
+
});
|
|
861
|
+
/** The table and row container tags. */
|
|
862
|
+
export type TableBoxTag = 'table' | 'thead' | 'tbody' | 'tfoot' | 'tr';
|
|
863
|
+
/** A table, a group of rows, or a row. */
|
|
864
|
+
export interface TableBoxProps<Node = unknown> extends ElementProps, InteractionProps {
|
|
865
|
+
as: TableBoxTag;
|
|
866
|
+
/** Layout and paint both renderers apply. */
|
|
867
|
+
style?: BoxStyle;
|
|
868
|
+
/** Web-only paint. */
|
|
869
|
+
webStyle?: WebStyle;
|
|
870
|
+
/** The table parts this element contains. */
|
|
871
|
+
children?: Node;
|
|
872
|
+
}
|
|
873
|
+
/** Props shared by table data and header cells. */
|
|
874
|
+
interface TableCellCommonProps<Node> extends ElementProps, InteractionProps {
|
|
875
|
+
/** How many columns the cell covers. */
|
|
876
|
+
colSpan?: number;
|
|
877
|
+
/** Layout and paint, with a numeric or percentage width fixing a single column on native. */
|
|
878
|
+
style?: BoxStyle;
|
|
879
|
+
/** Web-only paint. */
|
|
880
|
+
webStyle?: WebStyle;
|
|
881
|
+
/** Text or elements, laid out as in Box. */
|
|
882
|
+
children?: Node;
|
|
883
|
+
}
|
|
884
|
+
/** A data cell or a header cell, with optional row or column scope on headers. */
|
|
885
|
+
export type TableCellProps<Node = unknown> = (TableCellCommonProps<Node> & {
|
|
886
|
+
as: 'td';
|
|
887
|
+
scope?: never;
|
|
888
|
+
}) | (TableCellCommonProps<Node> & {
|
|
889
|
+
as: 'th';
|
|
890
|
+
scope?: 'col' | 'row';
|
|
891
|
+
});
|
|
892
|
+
/** An image (native `Image`). */
|
|
893
|
+
export interface ImageProps extends ElementProps {
|
|
894
|
+
/** Image URL. */
|
|
895
|
+
src: string;
|
|
896
|
+
/** Text alternative; an empty string marks a decorative image. */
|
|
897
|
+
alt: string;
|
|
898
|
+
/** Rendered width. */
|
|
899
|
+
width?: number;
|
|
900
|
+
/** Rendered height. */
|
|
901
|
+
height?: number;
|
|
902
|
+
/** Tooltip text. */
|
|
903
|
+
title?: string;
|
|
904
|
+
/** Called once the image has loaded. */
|
|
905
|
+
onLoad?: () => void;
|
|
906
|
+
/** Called when the image fails to load (a broken URL, no network). */
|
|
907
|
+
onError?: () => void;
|
|
908
|
+
/** Layout and paint both renderers apply. */
|
|
909
|
+
style?: BoxStyle & {
|
|
910
|
+
objectFit?: 'cover' | 'contain' | 'fill' | 'none';
|
|
911
|
+
};
|
|
912
|
+
/** Web-only paint. */
|
|
913
|
+
webStyle?: WebStyle;
|
|
914
|
+
}
|
|
915
|
+
/** The physical scroll position, in CSS pixels on web or density-independent pixels on device. */
|
|
916
|
+
export interface ScrollOffset {
|
|
917
|
+
/** Distance from the content's left edge on both renderers, including in RTL layouts. */
|
|
918
|
+
readonly x: number;
|
|
919
|
+
/** Distance from the content's top edge on both renderers. */
|
|
920
|
+
readonly y: number;
|
|
921
|
+
}
|
|
922
|
+
/** A container that scrolls its children (native `ScrollView`). */
|
|
923
|
+
export interface ScrollAreaProps<Node = unknown> extends ElementProps {
|
|
924
|
+
/** The web tag. */
|
|
925
|
+
as: BoxTag;
|
|
926
|
+
/** Axes enabled on device, default vertical. On web the authored overflow styles set the axes. */
|
|
927
|
+
direction?: 'vertical' | 'horizontal' | 'both';
|
|
928
|
+
/** Supplies both offsets when either changes on the web host or its native scroll view. */
|
|
929
|
+
onScroll?: (offset: ScrollOffset) => void;
|
|
930
|
+
/** Focus order on the scroll area's outer frame. */
|
|
931
|
+
tabIndex?: InteractionProps['tabIndex'];
|
|
932
|
+
/** Layout and paint both renderers apply. */
|
|
933
|
+
style?: BoxStyle;
|
|
934
|
+
/** Web-only paint. */
|
|
935
|
+
webStyle?: WebStyle;
|
|
936
|
+
/** Child elements. */
|
|
937
|
+
children?: Node;
|
|
938
|
+
}
|
|
939
|
+
/** Paint props every SVG shape takes. */
|
|
940
|
+
export interface SvgPaintProps {
|
|
941
|
+
/** Fill colour or `'none'`. */
|
|
942
|
+
fill?: string;
|
|
943
|
+
/** Fill opacity, 0 to 1. */
|
|
944
|
+
fillOpacity?: number;
|
|
945
|
+
/** Stroke colour or `'none'`. */
|
|
946
|
+
stroke?: string;
|
|
947
|
+
/** Stroke width. */
|
|
948
|
+
strokeWidth?: number;
|
|
949
|
+
/** Stroke opacity, 0 to 1. */
|
|
950
|
+
strokeOpacity?: number;
|
|
951
|
+
/** Stroke end caps. */
|
|
952
|
+
strokeLinecap?: 'butt' | 'round' | 'square';
|
|
953
|
+
/** Stroke corners. */
|
|
954
|
+
strokeLinejoin?: 'miter' | 'round' | 'bevel';
|
|
955
|
+
/** Dash pattern. */
|
|
956
|
+
strokeDasharray?: string | number;
|
|
957
|
+
/** Dash offset. */
|
|
958
|
+
strokeDashoffset?: number;
|
|
959
|
+
/** Opacity, 0 to 1. */
|
|
960
|
+
opacity?: number;
|
|
961
|
+
/** SVG transform (`'rotate(-90 12 12)'`). */
|
|
962
|
+
transform?: string;
|
|
963
|
+
/** ClassMap classes. */
|
|
964
|
+
className?: string;
|
|
965
|
+
}
|
|
966
|
+
/** SVG inline paint and hit-testing supported by both renderers. */
|
|
967
|
+
export interface SvgStyle extends Omit<SvgPaintProps, 'className' | 'transform'> {
|
|
968
|
+
/** The CSS hit-testing mode on web and the shape's native hit-testing mode. */
|
|
969
|
+
pointerEvents?: 'auto' | 'none';
|
|
970
|
+
}
|
|
971
|
+
/** Identity, interaction and paint shared by an SVG canvas and its shapes. */
|
|
972
|
+
export interface SvgElementProps extends ElementProps, SvgPaintProps {
|
|
973
|
+
/** DOM tab order. On a device, a nonnegative value supplies a focusable target. */
|
|
974
|
+
tabIndex?: number;
|
|
975
|
+
/** DOM click. On a device, draws a shape that can be pressed. */
|
|
976
|
+
onClick?: MouseEventHandler;
|
|
977
|
+
/** DOM key down. Native routes focused activation through the supplied key handler. */
|
|
978
|
+
onKeyDown?: KeyboardEventHandler;
|
|
979
|
+
/** Inline SVG paint and hit-testing, applied by the browser and on a device. */
|
|
980
|
+
style?: SvgStyle;
|
|
981
|
+
/** Additional CSS, applied after `style` by the browser. Shape CSS is omitted on a device. */
|
|
982
|
+
webStyle?: WebStyle;
|
|
983
|
+
}
|
|
984
|
+
/** Definitions in the enclosing SVG's ID namespace on both renderers. */
|
|
985
|
+
export interface SvgDefsProps<Node = unknown> {
|
|
986
|
+
/** Definition elements drawn through references on web and native. */
|
|
987
|
+
children: Node;
|
|
988
|
+
}
|
|
989
|
+
/** Geometry referenced by `url(#id)` as a clipping region. */
|
|
990
|
+
export interface SvgClipPathProps<Node = unknown> extends SvgDefsProps<Node> {
|
|
991
|
+
/** Local ID used by the browser's and device's SVG clipping engines. */
|
|
992
|
+
id: string;
|
|
993
|
+
}
|
|
994
|
+
/** One gradient stop. Equal offsets retain their input order on both renderers. */
|
|
995
|
+
export interface SvgGradientStop {
|
|
996
|
+
/** A fraction or percentage such as `'50%'`, passed to each renderer's stop. */
|
|
997
|
+
offset: ElementLength;
|
|
998
|
+
/** CSS colour, including `currentColor`, which native resolves to the inherited ink. */
|
|
999
|
+
stopColor: string;
|
|
1000
|
+
/** Opacity from zero to one for the browser and native stop. */
|
|
1001
|
+
stopOpacity?: number;
|
|
1002
|
+
}
|
|
1003
|
+
/** A named linear paint server and its stops. */
|
|
1004
|
+
export interface SvgLinearGradientProps {
|
|
1005
|
+
/** Local ID used by paint references on web and native. */
|
|
1006
|
+
id: string;
|
|
1007
|
+
/** Horizontal start in the selected coordinate system, on web and native. */
|
|
1008
|
+
x1?: ElementLength;
|
|
1009
|
+
/** Vertical start in the selected coordinate system, on web and native. */
|
|
1010
|
+
y1?: ElementLength;
|
|
1011
|
+
/** Horizontal end in the selected coordinate system, on web and native. */
|
|
1012
|
+
x2?: ElementLength;
|
|
1013
|
+
/** Vertical end in the selected coordinate system, on web and native. */
|
|
1014
|
+
y2?: ElementLength;
|
|
1015
|
+
/** Coordinate system for the gradient on both renderers. */
|
|
1016
|
+
gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse';
|
|
1017
|
+
/** In-order stop elements for the browser's SVG painter and react-native-svg. */
|
|
1018
|
+
stops: readonly SvgGradientStop[];
|
|
1019
|
+
}
|
|
1020
|
+
/** A named, repeating SVG tile. */
|
|
1021
|
+
export interface SvgPatternProps<Node = unknown> extends SvgDefsProps<Node> {
|
|
1022
|
+
/** Local ID used by paint references on web and native. */
|
|
1023
|
+
id: string;
|
|
1024
|
+
/** Tile's horizontal origin for the browser and native SVG painter. */
|
|
1025
|
+
x?: ElementLength;
|
|
1026
|
+
/** Tile's vertical origin for the browser and native SVG painter. */
|
|
1027
|
+
y?: ElementLength;
|
|
1028
|
+
/** Tile width for the browser and native SVG painter. */
|
|
1029
|
+
width: ElementLength;
|
|
1030
|
+
/** Tile height for the browser and native SVG painter. */
|
|
1031
|
+
height: ElementLength;
|
|
1032
|
+
/** Coordinate system for the tile's origin and size, on both renderers. */
|
|
1033
|
+
patternUnits?: 'objectBoundingBox' | 'userSpaceOnUse';
|
|
1034
|
+
}
|
|
1035
|
+
/** An image positioned in SVG user space. */
|
|
1036
|
+
export interface SvgImageProps extends SvgElementProps {
|
|
1037
|
+
/** Literal browser URL. Native resolves relative URLs against the public document URL. */
|
|
1038
|
+
href: string;
|
|
1039
|
+
/** Horizontal origin on web and native. */
|
|
1040
|
+
x?: ElementLength;
|
|
1041
|
+
/** Vertical origin on web and native. */
|
|
1042
|
+
y?: ElementLength;
|
|
1043
|
+
/** Image viewport width on web and native. */
|
|
1044
|
+
width: ElementLength;
|
|
1045
|
+
/** Image viewport height on web and native. */
|
|
1046
|
+
height: ElementLength;
|
|
1047
|
+
/** Alignment and fit of the image in its viewport on both renderers. */
|
|
1048
|
+
preserveAspectRatio?: string;
|
|
1049
|
+
}
|
|
1050
|
+
/** Descriptive SVG children. They precede geometry on web and name the native graphic. */
|
|
1051
|
+
export interface SvgMetadata {
|
|
1052
|
+
/** Browser `<title>` and the device's fallback accessible name. */
|
|
1053
|
+
title?: string;
|
|
1054
|
+
/** Browser `<desc>` and the device's accessible description. */
|
|
1055
|
+
description?: {
|
|
1056
|
+
/** ID that `aria-describedby` can reference on either renderer. */
|
|
1057
|
+
id?: string;
|
|
1058
|
+
/** Description drawn as SVG metadata on web and spoken by the device. */
|
|
1059
|
+
text: string;
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
/** An SVG canvas (native react-native-svg `Svg`). */
|
|
1063
|
+
export interface SvgProps<Node = unknown> extends SvgElementProps, ElementDragProps {
|
|
1064
|
+
/** Rendered width. */
|
|
1065
|
+
width?: number | `${number}%`;
|
|
1066
|
+
/** Rendered height. */
|
|
1067
|
+
height?: number | `${number}%`;
|
|
1068
|
+
/** The user coordinate system (`'0 0 24 24'`). */
|
|
1069
|
+
viewBox?: string;
|
|
1070
|
+
/** How the view box fits the element. */
|
|
1071
|
+
preserveAspectRatio?: string;
|
|
1072
|
+
/** Whether the canvas takes keyboard focus (web). */
|
|
1073
|
+
focusable?: boolean;
|
|
1074
|
+
/** The SVG namespace attribute (web; a device ignores it). */
|
|
1075
|
+
xmlns?: string;
|
|
1076
|
+
/** CSS for the web, and the style a device can draw of it. */
|
|
1077
|
+
webStyle?: WebStyle;
|
|
1078
|
+
/** Descriptive SVG children on web, and name and description for native accessibility. */
|
|
1079
|
+
metadata?: SvgMetadata;
|
|
1080
|
+
/** The browser's `shape-rendering` presentation hint. The device uses its SVG painter. */
|
|
1081
|
+
webShapeRendering?: 'auto' | 'optimizeSpeed' | 'crispEdges' | 'geometricPrecision';
|
|
1082
|
+
/** Language metadata emitted as `translate` on web and consumed before native drawing. */
|
|
1083
|
+
translate?: 'yes' | 'no';
|
|
1084
|
+
/** Shapes. */
|
|
1085
|
+
children?: Node;
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* An SVG canvas drawn from inner SVG markup (an icon set's prebuilt glyph; native react-native-svg
|
|
1089
|
+
* `SvgXml`). The markup is trusted: it comes from a bonded set, never from a user.
|
|
1090
|
+
*/
|
|
1091
|
+
export interface SvgMarkupProps extends Omit<SvgProps, 'children' | 'drag' | 'metadata'> {
|
|
1092
|
+
/** The markup inside the `<svg>` element. */
|
|
1093
|
+
markup: string;
|
|
1094
|
+
}
|
|
1095
|
+
/** An SVG path. */
|
|
1096
|
+
export interface SvgPathProps extends SvgElementProps {
|
|
1097
|
+
/** Path data. */
|
|
1098
|
+
d: string;
|
|
1099
|
+
/** Which areas the path fills. */
|
|
1100
|
+
fillRule?: 'nonzero' | 'evenodd';
|
|
1101
|
+
/** Which areas the path clips. */
|
|
1102
|
+
clipRule?: 'nonzero' | 'evenodd';
|
|
1103
|
+
}
|
|
1104
|
+
/** An SVG rectangle. */
|
|
1105
|
+
export interface SvgRectProps extends SvgElementProps {
|
|
1106
|
+
/** Left edge. */
|
|
1107
|
+
x?: number;
|
|
1108
|
+
/** Top edge. */
|
|
1109
|
+
y?: number;
|
|
1110
|
+
/** Width. */
|
|
1111
|
+
width: number;
|
|
1112
|
+
/** Height. */
|
|
1113
|
+
height: number;
|
|
1114
|
+
/** Corner radius on x. */
|
|
1115
|
+
rx?: number;
|
|
1116
|
+
/** Corner radius on y. */
|
|
1117
|
+
ry?: number;
|
|
1118
|
+
/** Web `<title>` and `<desc>` inside this rectangle, mapped to its device focus target. */
|
|
1119
|
+
metadata?: SvgMetadata;
|
|
1120
|
+
/** Web presentation attribute and native hit testing. Inline `style.pointerEvents` wins. */
|
|
1121
|
+
pointerEvents?: SvgStyle['pointerEvents'];
|
|
1122
|
+
/** Web mouse entry or native hover into this rectangle when pointing hardware delivers it. */
|
|
1123
|
+
onMouseEnter?: InteractionProps['onMouseEnter'];
|
|
1124
|
+
}
|
|
1125
|
+
/** An SVG circle. */
|
|
1126
|
+
export interface SvgCircleProps extends SvgElementProps {
|
|
1127
|
+
/** Centre x. The web and native SVG defaults are zero. */
|
|
1128
|
+
cx?: number;
|
|
1129
|
+
/** Centre y. The web and native SVG defaults are zero. */
|
|
1130
|
+
cy?: number;
|
|
1131
|
+
/** Radius. */
|
|
1132
|
+
r: number;
|
|
1133
|
+
}
|
|
1134
|
+
/** An SVG ellipse. */
|
|
1135
|
+
export interface SvgEllipseProps extends SvgElementProps {
|
|
1136
|
+
/** Centre x. */
|
|
1137
|
+
cx: number;
|
|
1138
|
+
/** Centre y. */
|
|
1139
|
+
cy: number;
|
|
1140
|
+
/** Radius on x. */
|
|
1141
|
+
rx: number;
|
|
1142
|
+
/** Radius on y. */
|
|
1143
|
+
ry: number;
|
|
1144
|
+
}
|
|
1145
|
+
/** An SVG line. */
|
|
1146
|
+
export interface SvgLineProps extends SvgElementProps {
|
|
1147
|
+
/** Start x. */
|
|
1148
|
+
x1: number;
|
|
1149
|
+
/** Start y. */
|
|
1150
|
+
y1: number;
|
|
1151
|
+
/** End x. */
|
|
1152
|
+
x2: number;
|
|
1153
|
+
/** End y. */
|
|
1154
|
+
y2: number;
|
|
1155
|
+
}
|
|
1156
|
+
/** An SVG polyline or polygon. */
|
|
1157
|
+
export interface SvgPolyProps extends SvgElementProps {
|
|
1158
|
+
/** Points (`'0,0 10,10'`). */
|
|
1159
|
+
points: string;
|
|
1160
|
+
}
|
|
1161
|
+
/** An SVG group. */
|
|
1162
|
+
export interface SvgGroupProps<Node = unknown> extends SvgElementProps, ElementDragProps {
|
|
1163
|
+
/** Local clipping region reference for the web or native SVG painter. */
|
|
1164
|
+
clipPath?: `url(#${string})`;
|
|
1165
|
+
/** Shapes. */
|
|
1166
|
+
children?: Node;
|
|
1167
|
+
}
|
|
1168
|
+
/** SVG text. */
|
|
1169
|
+
export interface SvgTextProps<Node = unknown> extends SvgElementProps {
|
|
1170
|
+
/** Anchor x. */
|
|
1171
|
+
x?: number;
|
|
1172
|
+
/** Anchor y. */
|
|
1173
|
+
y?: number;
|
|
1174
|
+
/** Horizontal anchor. */
|
|
1175
|
+
textAnchor?: 'start' | 'middle' | 'end';
|
|
1176
|
+
/** SVG baseline on the web. Native maps explicit baselines to `alignmentBaseline`. */
|
|
1177
|
+
dominantBaseline?: 'auto' | 'alphabetic' | 'middle' | 'central';
|
|
1178
|
+
/** Font size. */
|
|
1179
|
+
fontSize?: number;
|
|
1180
|
+
/** Font weight. */
|
|
1181
|
+
fontWeight?: 'normal' | 'bold' | number;
|
|
1182
|
+
/** CSS font-family on web. The device selects an available family or its system font. */
|
|
1183
|
+
fontFamily?: string;
|
|
1184
|
+
/** Text. */
|
|
1185
|
+
children?: Node;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* A CSS grid's classes ({@link NativeClassSplit.grid}), by breakpoint variant: `''` at the base
|
|
1189
|
+
* size, then `sm`, `md`, … ({@link UIClassMapNativeSplit.nativeBreakpoints}). A device has no grid
|
|
1190
|
+
* layout, so a native element lays its children out from these.
|
|
1191
|
+
*/
|
|
1192
|
+
export interface NativeGridClasses {
|
|
1193
|
+
/**
|
|
1194
|
+
* Its columns: a count of equal columns (`grid-cols-3` is 3), or a CSS track list
|
|
1195
|
+
* (`grid-cols-[1fr_2fr]` is `'1fr 2fr'`). No entry at the base size is one column.
|
|
1196
|
+
*/
|
|
1197
|
+
columns: Readonly<Record<string, number | string>>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Its explicit rows: a count of equal rows (`grid-rows-3`) or a CSS track list
|
|
1200
|
+
* (`grid-rows-[auto_1fr]`). No entry: rows only as its items need them.
|
|
1201
|
+
*/
|
|
1202
|
+
rows?: Readonly<Record<string, number | string>>;
|
|
1203
|
+
/** The gap between its columns, in pixels (`gap-4` and `gap-x-4` are 16). */
|
|
1204
|
+
columnGap: Readonly<Record<string, number>>;
|
|
1205
|
+
/** The gap between its rows, in pixels. */
|
|
1206
|
+
rowGap: Readonly<Record<string, number>>;
|
|
1207
|
+
/** How its items sit in their rows (`items-center`); stretched when it sets none. */
|
|
1208
|
+
alignItems: Readonly<Record<string, 'start' | 'end' | 'center' | 'stretch' | 'baseline'>>;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* A class string divided for a native renderer, which has no CSS cascade (see
|
|
1212
|
+
* {@link UIClassMapNativeSplit}).
|
|
1213
|
+
*/
|
|
1214
|
+
export interface NativeClassSplit {
|
|
1215
|
+
/** Classes the native view itself applies (no display class: {@link NativeClassSplit.display}). */
|
|
1216
|
+
view: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* The text classes in effect for the element's text, as the CSS cascade would give them (text
|
|
1219
|
+
* properties only: `visibility`, `cursor` and other inherited CSS properties do not pass down): the
|
|
1220
|
+
* inherited ones the element's own text classes (colour, font, size, line height, letter
|
|
1221
|
+
* spacing, alignment, case, decoration, white space) do not override, then its own. A native
|
|
1222
|
+
* container hands them to the text inside it.
|
|
1223
|
+
*/
|
|
1224
|
+
text: string;
|
|
1225
|
+
/**
|
|
1226
|
+
* The display the classes give the element at its base size (no responsive or state variant), or
|
|
1227
|
+
* `null` when they set none: `flex`/`inline-flex` make its children flex items, `inline` and
|
|
1228
|
+
* `inline-*` put it in a line with its inline siblings, `block` takes it out of one and
|
|
1229
|
+
* `contents` lets a fieldset's children participate directly in its parent's layout.
|
|
1230
|
+
*/
|
|
1231
|
+
display: 'block' | 'inline' | 'inline-block' | 'flex' | 'inline-flex' | 'grid' | 'inline-grid' | 'contents' | 'none' | null;
|
|
1232
|
+
/** The vertical alignment requested for a native table cell. */
|
|
1233
|
+
verticalAlign?: 'middle';
|
|
1234
|
+
/**
|
|
1235
|
+
* The lines the element's text is clamped to with an ellipsis (`truncate` is 1,
|
|
1236
|
+
* `line-clamp-3` is 3), or `null`. The clamp is the element's own: it is not inherited.
|
|
1237
|
+
*/
|
|
1238
|
+
lines: number | null;
|
|
1239
|
+
/**
|
|
1240
|
+
* The font weight {@link NativeClassSplit.text} sets at its base size (`font-bold` is 700), or
|
|
1241
|
+
* `null` when it sets none (the platform's normal weight). A `<strong>` draws `bolder` than it.
|
|
1242
|
+
*/
|
|
1243
|
+
weight: number | null;
|
|
1244
|
+
/**
|
|
1245
|
+
* The line height in pixels for a field that grows by lines, keyed by breakpoint like the grid
|
|
1246
|
+
* classes (`''` at the base size). A bond can omit this if it does not resolve text metrics.
|
|
1247
|
+
*/
|
|
1248
|
+
lineHeight?: Readonly<Record<string, number>>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Whether the classes set the element's width or height (`w-5`, `h-5`, `size-5`, at any
|
|
1251
|
+
* breakpoint). On the web a class beats a replaced element's `width` and `height` attributes, so
|
|
1252
|
+
* a native image or drawing takes those attributes only for the sizes its classes leave unset.
|
|
1253
|
+
*/
|
|
1254
|
+
sized?: {
|
|
1255
|
+
width: boolean;
|
|
1256
|
+
height: boolean;
|
|
1257
|
+
};
|
|
1258
|
+
/**
|
|
1259
|
+
* Classes the element gives its descendants with one tag, as a CSS descendant selector does
|
|
1260
|
+
* (`[&_p]:leading-relaxed` is `{ p: 'leading-relaxed' }`): left out of `view` and `text`, and
|
|
1261
|
+
* applied by each descendant element whose tag it names, after that element's own classes.
|
|
1262
|
+
*/
|
|
1263
|
+
descendants?: Readonly<Record<string, string>>;
|
|
1264
|
+
/**
|
|
1265
|
+
* The element's grid when {@link NativeClassSplit.display} is `grid` or `inline-grid`, else
|
|
1266
|
+
* `null`. Its column and span classes are left out of `view`.
|
|
1267
|
+
*/
|
|
1268
|
+
grid?: NativeGridClasses | null;
|
|
1269
|
+
/**
|
|
1270
|
+
* The columns the element spans as a grid item, by breakpoint variant (`col-span-2` is
|
|
1271
|
+
* `{ '': 2 }`; `col-span-full` is every column).
|
|
1272
|
+
*/
|
|
1273
|
+
span?: Readonly<Record<string, number | 'full'>>;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* The ClassMap member a device ClassMap (the nativewind bond) adds so native elements can do what
|
|
1277
|
+
* the CSS cascade does on the web. Web ClassMaps leave it out.
|
|
1278
|
+
*/
|
|
1279
|
+
export interface UIClassMapNativeSplit {
|
|
1280
|
+
/**
|
|
1281
|
+
* Divides a class string for a native element.
|
|
1282
|
+
*
|
|
1283
|
+
* @param className - The element's classes.
|
|
1284
|
+
* @param inheritedText - The text classes in effect for its container's text.
|
|
1285
|
+
* @param data - The element's `data-*` attributes by name without the prefix (`{ state: 'open' }`):
|
|
1286
|
+
* a class with a `data-[state=open]:` variant applies only when they match, as on the web.
|
|
1287
|
+
* @returns The view classes, the text classes in effect for its own text, and its display.
|
|
1288
|
+
*/
|
|
1289
|
+
splitForNative?(className: string, inheritedText?: string, data?: Readonly<Record<string, string | undefined>>): NativeClassSplit;
|
|
1290
|
+
/**
|
|
1291
|
+
* The text classes a browser's stylesheet gives a `<button>` (its text is centred), which a
|
|
1292
|
+
* native button hands to its text beneath the button's own classes.
|
|
1293
|
+
*/
|
|
1294
|
+
nativeButtonText?: string;
|
|
1295
|
+
/**
|
|
1296
|
+
* The text classes the web's stylesheet gives the document (`html`, `body`), which every text
|
|
1297
|
+
* inherits there: native text starts from them.
|
|
1298
|
+
*/
|
|
1299
|
+
nativeRootText?: string;
|
|
1300
|
+
/**
|
|
1301
|
+
* Lets the native styling runtime supply resolved text colour to paint computed in JavaScript.
|
|
1302
|
+
* The browser applies its own CSS cascade.
|
|
1303
|
+
*
|
|
1304
|
+
* @param classes - Text classes after native inheritance and overrides.
|
|
1305
|
+
* @param render - Draws the renderer's element with the resolved colour, if any.
|
|
1306
|
+
* @returns The renderer's element wrapped by the native styling runtime.
|
|
1307
|
+
*/
|
|
1308
|
+
renderNativeTextColor?(classes: string, render: (color: string | undefined) => unknown): unknown;
|
|
1309
|
+
/**
|
|
1310
|
+
* The tags the web's stylesheet makes blocks although a browser draws them inline (Tailwind's
|
|
1311
|
+
* reset makes `img` and `svg` blocks): a native image or drawing with one of these tags stacks
|
|
1312
|
+
* like a block unless a class puts it in a line (`inline`, `inline-block`).
|
|
1313
|
+
*/
|
|
1314
|
+
nativeBlockTags?: readonly string[];
|
|
1315
|
+
/**
|
|
1316
|
+
* The window width, in pixels, from which each breakpoint variant applies (`sm:` from 640):
|
|
1317
|
+
* a native grid picks its columns and gaps by it.
|
|
1318
|
+
*/
|
|
1319
|
+
nativeBreakpoints?: Readonly<Record<string, number>>;
|
|
1320
|
+
}
|
|
1321
|
+
export {};
|
|
1322
|
+
//# sourceMappingURL=elements.d.ts.map
|