@react-x11/components 0.4.0 → 0.5.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.
Files changed (219) hide show
  1. package/README.md +125 -4
  2. package/dist/charts/components.d.ts +3 -1
  3. package/dist/charts/components.d.ts.map +1 -1
  4. package/dist/charts/components.js +8 -4
  5. package/dist/charts/components.js.map +1 -1
  6. package/dist/charts/node.d.ts +13 -6
  7. package/dist/charts/node.d.ts.map +1 -1
  8. package/dist/charts/node.js +75 -24
  9. package/dist/charts/node.js.map +1 -1
  10. package/dist/charts/render.d.ts +4 -0
  11. package/dist/charts/render.d.ts.map +1 -1
  12. package/dist/charts/render.js +11 -6
  13. package/dist/charts/render.js.map +1 -1
  14. package/dist/code-editor/node.d.ts +47 -16
  15. package/dist/code-editor/node.d.ts.map +1 -1
  16. package/dist/code-editor/node.js +121 -51
  17. package/dist/code-editor/node.js.map +1 -1
  18. package/dist/flow/draw.d.ts +19 -1
  19. package/dist/flow/draw.d.ts.map +1 -1
  20. package/dist/flow/draw.js +64 -35
  21. package/dist/flow/draw.js.map +1 -1
  22. package/dist/flow/index.d.ts.map +1 -1
  23. package/dist/flow/index.js +24 -8
  24. package/dist/flow/index.js.map +1 -1
  25. package/dist/flow/model.d.ts +4 -2
  26. package/dist/flow/model.d.ts.map +1 -1
  27. package/dist/flow/model.js +4 -2
  28. package/dist/flow/model.js.map +1 -1
  29. package/dist/flow/node.d.ts +40 -9
  30. package/dist/flow/node.d.ts.map +1 -1
  31. package/dist/flow/node.js +142 -53
  32. package/dist/flow/node.js.map +1 -1
  33. package/dist/flow/types.d.ts +46 -21
  34. package/dist/flow/types.d.ts.map +1 -1
  35. package/dist/formula/index.d.ts +4 -2
  36. package/dist/formula/index.d.ts.map +1 -1
  37. package/dist/formula/index.js.map +1 -1
  38. package/dist/formula/node.d.ts +5 -1
  39. package/dist/formula/node.d.ts.map +1 -1
  40. package/dist/formula/node.js +19 -3
  41. package/dist/formula/node.js.map +1 -1
  42. package/dist/html/controls.d.ts +4 -1
  43. package/dist/html/controls.d.ts.map +1 -1
  44. package/dist/html/controls.js.map +1 -1
  45. package/dist/html/css/cascade.d.ts +11 -5
  46. package/dist/html/css/cascade.d.ts.map +1 -1
  47. package/dist/html/css/cascade.js +18 -8
  48. package/dist/html/css/cascade.js.map +1 -1
  49. package/dist/html/css/parse.d.ts +15 -10
  50. package/dist/html/css/parse.d.ts.map +1 -1
  51. package/dist/html/css/parse.js +41 -16
  52. package/dist/html/css/parse.js.map +1 -1
  53. package/dist/html/css/style.d.ts +3 -0
  54. package/dist/html/css/style.d.ts.map +1 -1
  55. package/dist/html/css/style.js +3 -1
  56. package/dist/html/css/style.js.map +1 -1
  57. package/dist/html/css/values.d.ts +14 -1
  58. package/dist/html/css/values.d.ts.map +1 -1
  59. package/dist/html/css/values.js +11 -8
  60. package/dist/html/css/values.js.map +1 -1
  61. package/dist/html/index.d.ts.map +1 -1
  62. package/dist/html/index.js +1 -0
  63. package/dist/html/index.js.map +1 -1
  64. package/dist/html/layout/boxes.d.ts +12 -5
  65. package/dist/html/layout/boxes.d.ts.map +1 -1
  66. package/dist/html/layout/boxes.js +7 -4
  67. package/dist/html/layout/boxes.js.map +1 -1
  68. package/dist/html/layout/inline.d.ts.map +1 -1
  69. package/dist/html/layout/inline.js +22 -1
  70. package/dist/html/layout/inline.js.map +1 -1
  71. package/dist/html/node.d.ts +22 -8
  72. package/dist/html/node.d.ts.map +1 -1
  73. package/dist/html/node.js +97 -15
  74. package/dist/html/node.js.map +1 -1
  75. package/dist/html/paint.d.ts +3 -0
  76. package/dist/html/paint.d.ts.map +1 -1
  77. package/dist/html/paint.js +2 -2
  78. package/dist/html/paint.js.map +1 -1
  79. package/dist/index.d.ts +7 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +21 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/maps/clip.d.ts +43 -0
  84. package/dist/maps/clip.d.ts.map +1 -0
  85. package/dist/maps/clip.js +171 -0
  86. package/dist/maps/clip.js.map +1 -0
  87. package/dist/maps/gzip.d.ts +15 -0
  88. package/dist/maps/gzip.d.ts.map +1 -0
  89. package/dist/maps/gzip.js +56 -0
  90. package/dist/maps/gzip.js.map +1 -0
  91. package/dist/maps/index.d.ts +55 -0
  92. package/dist/maps/index.d.ts.map +1 -0
  93. package/dist/maps/index.js +141 -0
  94. package/dist/maps/index.js.map +1 -0
  95. package/dist/maps/labels.d.ts +123 -0
  96. package/dist/maps/labels.d.ts.map +1 -0
  97. package/dist/maps/labels.js +323 -0
  98. package/dist/maps/labels.js.map +1 -0
  99. package/dist/maps/mvt.d.ts +244 -0
  100. package/dist/maps/mvt.d.ts.map +1 -0
  101. package/dist/maps/mvt.js +820 -0
  102. package/dist/maps/mvt.js.map +1 -0
  103. package/dist/maps/node.d.ts +278 -0
  104. package/dist/maps/node.d.ts.map +1 -0
  105. package/dist/maps/node.js +1459 -0
  106. package/dist/maps/node.js.map +1 -0
  107. package/dist/maps/overlay.d.ts +157 -0
  108. package/dist/maps/overlay.d.ts.map +1 -0
  109. package/dist/maps/overlay.js +472 -0
  110. package/dist/maps/overlay.js.map +1 -0
  111. package/dist/maps/paint.d.ts +226 -0
  112. package/dist/maps/paint.d.ts.map +1 -0
  113. package/dist/maps/paint.js +705 -0
  114. package/dist/maps/paint.js.map +1 -0
  115. package/dist/maps/proj.d.ts +281 -0
  116. package/dist/maps/proj.d.ts.map +1 -0
  117. package/dist/maps/proj.js +451 -0
  118. package/dist/maps/proj.js.map +1 -0
  119. package/dist/maps/sources.d.ts +256 -0
  120. package/dist/maps/sources.d.ts.map +1 -0
  121. package/dist/maps/sources.js +210 -0
  122. package/dist/maps/sources.js.map +1 -0
  123. package/dist/maps/style.d.ts +141 -0
  124. package/dist/maps/style.d.ts.map +1 -0
  125. package/dist/maps/style.js +147 -0
  126. package/dist/maps/style.js.map +1 -0
  127. package/dist/maps/styles.d.ts +82 -0
  128. package/dist/maps/styles.d.ts.map +1 -0
  129. package/dist/maps/styles.js +898 -0
  130. package/dist/maps/styles.js.map +1 -0
  131. package/dist/maps/tiles.d.ts +283 -0
  132. package/dist/maps/tiles.d.ts.map +1 -0
  133. package/dist/maps/tiles.js +469 -0
  134. package/dist/maps/tiles.js.map +1 -0
  135. package/dist/maps/types.d.ts +244 -0
  136. package/dist/maps/types.d.ts.map +1 -0
  137. package/dist/maps/types.js +2 -0
  138. package/dist/maps/types.js.map +1 -0
  139. package/dist/reorder/hx.d.ts +18 -0
  140. package/dist/reorder/hx.d.ts.map +1 -0
  141. package/dist/reorder/hx.js +10 -0
  142. package/dist/reorder/hx.js.map +1 -0
  143. package/dist/reorder/index.d.ts +314 -0
  144. package/dist/reorder/index.d.ts.map +1 -0
  145. package/dist/reorder/index.js +1539 -0
  146. package/dist/reorder/index.js.map +1 -0
  147. package/dist/reorder/model.d.ts +107 -0
  148. package/dist/reorder/model.d.ts.map +1 -0
  149. package/dist/reorder/model.js +162 -0
  150. package/dist/reorder/model.js.map +1 -0
  151. package/dist/richtext/node.d.ts +15 -5
  152. package/dist/richtext/node.d.ts.map +1 -1
  153. package/dist/richtext/node.js +40 -11
  154. package/dist/richtext/node.js.map +1 -1
  155. package/dist/richtext/runs.d.ts +35 -13
  156. package/dist/richtext/runs.d.ts.map +1 -1
  157. package/dist/richtext/runs.js +83 -27
  158. package/dist/richtext/runs.js.map +1 -1
  159. package/dist/tabs/index.d.ts +17 -0
  160. package/dist/tabs/index.d.ts.map +1 -1
  161. package/dist/tabs/index.js +849 -186
  162. package/dist/tabs/index.js.map +1 -1
  163. package/dist/terminal/vt/fonts.d.ts +45 -15
  164. package/dist/terminal/vt/fonts.d.ts.map +1 -1
  165. package/dist/terminal/vt/fonts.js +89 -19
  166. package/dist/terminal/vt/fonts.js.map +1 -1
  167. package/dist/terminal/vt/node.d.ts +42 -0
  168. package/dist/terminal/vt/node.d.ts.map +1 -1
  169. package/dist/terminal/vt/node.js +95 -11
  170. package/dist/terminal/vt/node.js.map +1 -1
  171. package/dist/terminal/vt/renderer.d.ts.map +1 -1
  172. package/dist/terminal/vt/renderer.js +13 -3
  173. package/dist/terminal/vt/renderer.js.map +1 -1
  174. package/package.json +13 -3
  175. package/src/charts/components.ts +14 -7
  176. package/src/charts/node.ts +81 -26
  177. package/src/charts/render.ts +16 -6
  178. package/src/code-editor/node.ts +147 -53
  179. package/src/flow/draw.ts +104 -35
  180. package/src/flow/index.ts +33 -13
  181. package/src/flow/model.ts +4 -2
  182. package/src/flow/node.ts +158 -59
  183. package/src/flow/types.ts +46 -21
  184. package/src/formula/index.ts +4 -2
  185. package/src/formula/node.ts +24 -5
  186. package/src/html/controls.ts +4 -1
  187. package/src/html/css/cascade.ts +18 -7
  188. package/src/html/css/parse.ts +46 -21
  189. package/src/html/css/style.ts +6 -1
  190. package/src/html/css/values.ts +25 -9
  191. package/src/html/index.ts +1 -0
  192. package/src/html/layout/boxes.ts +19 -9
  193. package/src/html/layout/inline.ts +23 -1
  194. package/src/html/node.ts +110 -17
  195. package/src/html/paint.ts +17 -2
  196. package/src/index.ts +98 -0
  197. package/src/maps/clip.ts +184 -0
  198. package/src/maps/gzip.ts +66 -0
  199. package/src/maps/index.ts +316 -0
  200. package/src/maps/labels.ts +442 -0
  201. package/src/maps/mvt.ts +857 -0
  202. package/src/maps/node.ts +1819 -0
  203. package/src/maps/overlay.ts +639 -0
  204. package/src/maps/paint.ts +978 -0
  205. package/src/maps/proj.ts +641 -0
  206. package/src/maps/sources.ts +425 -0
  207. package/src/maps/style.ts +309 -0
  208. package/src/maps/styles.ts +1040 -0
  209. package/src/maps/tiles.ts +676 -0
  210. package/src/maps/types.ts +260 -0
  211. package/src/reorder/hx.ts +31 -0
  212. package/src/reorder/index.ts +2223 -0
  213. package/src/reorder/model.ts +232 -0
  214. package/src/richtext/node.ts +49 -14
  215. package/src/richtext/runs.ts +115 -30
  216. package/src/tabs/index.ts +1040 -204
  217. package/src/terminal/vt/fonts.ts +128 -36
  218. package/src/terminal/vt/node.ts +105 -12
  219. package/src/terminal/vt/renderer.ts +13 -3
@@ -0,0 +1,260 @@
1
+ // The public vocabulary: what `<Map>` takes, what it hands back, and what
2
+ // its events carry.
3
+ //
4
+ // Separate from `index.ts` for the reason `src/flow/types.ts` is: the
5
+ // element, the component and the tests all name these, and a types module
6
+ // with no runtime in it can be imported by any of them without dragging the
7
+ // others in.
8
+ import type { Style } from 'react-x11/style';
9
+ import type { ReactNode, Ref } from 'react';
10
+
11
+ import type { LngLat, LngLatBounds, MapCamera, TileId } from './proj.js';
12
+ import type { MapSource } from './sources.js';
13
+ import type { MapStyle } from './style.js';
14
+ import type { MapMarker, MapOverlay } from './overlay.js';
15
+
16
+ export type { LngLat, LngLatBounds, MapCamera };
17
+ export type { MapSource, TileData, TileRequest } from './sources.js';
18
+ export type { MapMarker, MapOverlay, OverlayPalette } from './overlay.js';
19
+ export type {
20
+ MapStyle,
21
+ MapStyleLayer,
22
+ MapFilter,
23
+ FillLayer,
24
+ LineLayer,
25
+ CircleLayer,
26
+ SymbolLayer,
27
+ Zoomed,
28
+ } from './style.js';
29
+
30
+ /** Where a pointer event happened, in every space that could be wanted. */
31
+ export interface MapPointerEvent {
32
+ /** Geographic. */
33
+ lngLat: LngLat;
34
+ /** Pane-local logical pixels. */
35
+ x: number;
36
+ y: number;
37
+ /** The marker under the pointer, when there was one. */
38
+ marker: MapMarker | null;
39
+ /** Modifier state, as the synthetic event reported it. */
40
+ shiftKey: boolean;
41
+ ctrlKey: boolean;
42
+ altKey: boolean;
43
+ metaKey: boolean;
44
+ /** `1` left, `2` middle, `3` right. */
45
+ button: number;
46
+ }
47
+
48
+ /** What one frame cost — for a performance HUD, and what
49
+ * `scripts/bench/maps.ts` reads. */
50
+ export interface MapFrameStats {
51
+ /** Milliseconds spent rasterizing tiles into their surfaces this frame.
52
+ * Bounded by `rasterBudgetMs` except for the one run that crossed it. */
53
+ rasterMs: number;
54
+ /** …and compositing them, drawing the labels, overlays and markers. */
55
+ drawMs: number;
56
+ /** Tiles the cover asked for. */
57
+ tiles: number;
58
+ /** …of which were composited from their own finished surface. Under
59
+ * `progressive` this also counts the half-drawn ones. */
60
+ ready: number;
61
+ /** …and how many were drawn from a coarser ancestor instead, scaled up.
62
+ * What covers a hole while zooming *in*. */
63
+ fromAncestor: number;
64
+ /** …and how many from their finer descendants, scaled down. What covers
65
+ * a hole while zooming *out*, where there is no ancestor to borrow. */
66
+ fromDescendant: number;
67
+ /** Tiles still to rasterize — non-zero means the map is still sharpening
68
+ * and another frame is already scheduled. */
69
+ pending: number;
70
+ /** Labels placed, and labels drawn. */
71
+ labels: number;
72
+ /**
73
+ * Tiles in the cover whose load failed and are waiting on a retry.
74
+ *
75
+ * Here because a map whose tiles all fail looks exactly like a map that
76
+ * is still loading — an empty background and nothing else — and the
77
+ * difference is not something a user can see.
78
+ */
79
+ errors: number;
80
+ /** Bytes of rendered surfaces the cache is holding. */
81
+ surfaceBytes: number;
82
+ /**
83
+ * What this pass repainted, in device pixels, or `null` for a full one.
84
+ *
85
+ * The number to watch when a map looks busy: a frame that is only
86
+ * continuing a rasterization should claim almost nothing, because the
87
+ * tile being drawn is a second surface nobody is looking at. A run of
88
+ * full-pane damage while tiles are still landing means something is
89
+ * asking for repaints it does not need — which on a backend that paints
90
+ * many frames a second reads as flashing.
91
+ */
92
+ damage: { x: number; y: number; width: number; height: number } | null;
93
+ /** What the rasterizer did, summed over the tiles drawn this frame. */
94
+ draw: {
95
+ features: number;
96
+ vertices: number;
97
+ decimated: number;
98
+ culled: number;
99
+ batches: number;
100
+ };
101
+ }
102
+
103
+ /** Options for framing a box. */
104
+ export interface FitBoundsOptions {
105
+ /** Logical pixels kept clear on every side. 24 by default. */
106
+ padding?: number;
107
+ maxZoom?: number;
108
+ }
109
+
110
+ /** The imperative surface, through `ref`. */
111
+ export interface MapHandle {
112
+ getCamera(): MapCamera;
113
+ setCamera(camera: Partial<MapCamera>): void;
114
+ panBy(dx: number, dy: number): void;
115
+ zoomIn(step?: number): void;
116
+ zoomOut(step?: number): void;
117
+ zoomTo(zoom: number): void;
118
+ /** Frame a box. */
119
+ fitBounds(bounds: LngLatBounds, options?: FitBoundsOptions): void;
120
+ /** Frame every marker, or the ones named. */
121
+ fitMarkers(ids?: readonly string[], options?: FitBoundsOptions): void;
122
+ /** What the pane can see. `west > east` across the antimeridian. */
123
+ getBounds(): LngLatBounds;
124
+ /** Geography to pane-local logical pixels, and back. */
125
+ project(position: LngLat): { x: number; y: number };
126
+ unproject(x: number, y: number): LngLat;
127
+ /** The marker at a pane-local point, or null. */
128
+ markerAt(x: number, y: number): MapMarker | null;
129
+ /** Throw away every rendered tile — after a style edit an application
130
+ * made in place, which the map cannot see. */
131
+ refresh(): void;
132
+ /** What the last frame cost. */
133
+ stats(): MapFrameStats | null;
134
+ }
135
+
136
+ /** What the `<mapview>` element takes. `<Map>` adds the uncontrolled
137
+ * camera and the box around it. */
138
+ export interface MapViewProps {
139
+ /**
140
+ * Where tiles come from, drawn in order — a basemap, then an overlay
141
+ * pyramid over it. Empty draws the style's background and nothing else,
142
+ * which is what a map with only markers on it wants.
143
+ */
144
+ sources?: readonly MapSource[];
145
+ /** How to draw them. Defaults to {@link shortbreadStyle} in the theme's
146
+ * light or dark palette. */
147
+ mapStyle?: MapStyle;
148
+ /**
149
+ * The camera, controlled. Leave it out and the **element** owns it —
150
+ * which is not just a convenience: an element-owned camera means a pan is
151
+ * a blit and a claim, with no React render in the loop at all.
152
+ */
153
+ camera?: MapCamera;
154
+ /** Where an element-owned camera starts. Read once, at construction. */
155
+ defaultCamera?: MapCamera;
156
+ onCameraChange?: (camera: MapCamera) => void;
157
+ /** Fired when a gesture ends and the camera has settled — the moment to
158
+ * fetch what is now on screen. */
159
+ onMoveEnd?: (camera: MapCamera) => void;
160
+ minZoom?: number;
161
+ maxZoom?: number;
162
+ markers?: readonly MapMarker[];
163
+ overlays?: readonly MapOverlay[];
164
+ onMapClick?: (event: MapPointerEvent) => void;
165
+ onMarkerClick?: (marker: MapMarker, event: MapPointerEvent) => void;
166
+ /**
167
+ * The marker under the pointer, or null when it left every marker.
168
+ *
169
+ * `event` is null for the leave that comes from the pointer leaving the
170
+ * map altogether: there is no position on the map to report, and
171
+ * inventing one would be worse than saying so.
172
+ */
173
+ onMarkerHover?: (
174
+ marker: MapMarker | null,
175
+ event: MapPointerEvent | null,
176
+ ) => void;
177
+ /** `false` freezes the camera: no drag, no wheel, no keys. The map still
178
+ * draws and still reports clicks. */
179
+ interactive?: boolean;
180
+ /**
181
+ * Show a tile as it is drawn rather than when it is finished.
182
+ *
183
+ * `false` by default, which is what every other map client does: a tile
184
+ * appears whole, and until it does the coarser one already in the cache
185
+ * is scaled up in its place. `true` composites a tile's surface as soon
186
+ * as it exists — so a dense tile arrives as water, then landuse, then
187
+ * road casings, then roads, across a dozen frames — which is honest about
188
+ * what the renderer is doing and does not look like a map.
189
+ *
190
+ * The one thing the default costs is a transition that invalidates every
191
+ * surface at once: a `mapStyle` change, `refresh()`, or a display-scale
192
+ * change leaves no finished tile *and* no finished ancestor, so the map
193
+ * drops to its background colour until the new tiles land. `true` shows
194
+ * it repainting instead.
195
+ */
196
+ progressive?: boolean;
197
+ /**
198
+ * Milliseconds a frame may spend rasterizing tiles. 8 by default, which
199
+ * leaves the rest of a 60 Hz frame for everything else; a tile that takes
200
+ * longer than the budget is finished over the frames after it. `0`
201
+ * suspends rasterization, which is what a gesture does on its own.
202
+ */
203
+ rasterBudgetMs?: number;
204
+ /**
205
+ * Device pixels per logical pixel for the tile surfaces, if not the
206
+ * display's.
207
+ *
208
+ * Lowering it to 1 on a retina panel makes rasterization about 1.6×
209
+ * quicker and the basemap correspondingly softer; labels, markers and
210
+ * overlays are unaffected, since none of them goes through a tile
211
+ * surface. Worth having on a slow machine, and worth knowing about before
212
+ * reaching for it.
213
+ */
214
+ rasterScale?: number;
215
+ /** Bytes of rendered tile surfaces to keep. 128 MB by default. */
216
+ surfaceBudget?: number;
217
+ /**
218
+ * Vertices after which the rasterizer flushes its path. 12,000 by
219
+ * default.
220
+ *
221
+ * A real trade on X11, where a fill becomes one coverage-mask upload and
222
+ * a bigger path is fewer of them over the same pixels. It used to be a
223
+ * per-backend trade — `CGContextStrokePath` was quadratic in the number
224
+ * of subpaths, so the Cocoa backend wanted the opposite value and this
225
+ * element probed for it — and react-x11 2.6.1 chunks that stroke inside
226
+ * the backend instead (react-x11#457). Set it only with a profile in
227
+ * hand.
228
+ */
229
+ batchVertices?: number;
230
+ /** What the licence requires, drawn in the corner. Taken from the
231
+ * sources when they carry one; `''` removes it, which is the
232
+ * application saying it has put the attribution somewhere else. */
233
+ attribution?: string;
234
+ /** Called once per painted frame with what it cost. */
235
+ onFrame?: (stats: MapFrameStats) => void;
236
+ /**
237
+ * Called once per failed tile load, with whatever the source threw.
238
+ *
239
+ * Nothing is drawn for a failed tile, so without this a source that is
240
+ * misconfigured, rate-limited or down is indistinguishable from one that
241
+ * is slow. The tile is retried on a backoff (0.5 s doubling to 30 s), so
242
+ * this fires again for each retry rather than once and forever.
243
+ */
244
+ onTileError?: (error: unknown, tile: TileId & { sourceId: string }) => void;
245
+ style?: Style;
246
+ role?: string;
247
+ 'aria-label'?: string;
248
+ 'data-testname'?: string;
249
+ ref?: Ref<unknown>;
250
+ }
251
+
252
+ /** What `<Map>` takes. */
253
+ export interface MapProps extends Omit<MapViewProps, 'ref'> {
254
+ ref?: Ref<MapHandle>;
255
+ /** Anything absolutely positioned over the map — a legend, a control
256
+ * panel. Laid out as siblings of the drawn pane rather than inside it,
257
+ * because a registered element paints its children *before* its own
258
+ * drawing and anything inside would be painted over. */
259
+ children?: ReactNode;
260
+ }
@@ -0,0 +1,31 @@
1
+ // `React.createElement`, typed against react-x11's host elements — a copy of
2
+ // `src/tabs/hx.ts`, duplicated on purpose: components in this package do not
3
+ // import each other (a lateral import welds two components into one
4
+ // tree-shaking unit — see AGENTS.md), and thirty shared lines are cheaper
5
+ // than that. See `src/internal/hx.ts` for the full why of the shape.
6
+ import React from 'react';
7
+ import type { Key, ReactElement, ReactNode } from 'react';
8
+ import type { ReactX11Elements, Theme } from 'react-x11';
9
+
10
+ /** The host elements, by name. */
11
+ export type Host = ReactX11Elements;
12
+
13
+ interface CommonProps {
14
+ key?: Key;
15
+ /** Honoured by every node at runtime; declared only on `<window>` — the
16
+ * same narrow declaration the calendar works around. */
17
+ theme?: Theme | Record<string, string | number>;
18
+ /** The query hook every component forwards (docs/README.md,
19
+ * "Conventions"). react-x11 passes `data-*` through; the declarations
20
+ * just do not spell it, so it is added here rather than cast away at
21
+ * every call site. */
22
+ 'data-testname'?: string;
23
+ }
24
+
25
+ export function hx<K extends keyof Host>(
26
+ type: K,
27
+ props?: (Omit<Host[K], 'theme'> & CommonProps) | null,
28
+ ...children: ReactNode[]
29
+ ): ReactElement {
30
+ return React.createElement(type as string, props as never, ...children);
31
+ }