xote 6.0.1 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -19
- package/dist/xote.cjs +10 -10
- package/dist/xote.mjs +1280 -1094
- package/dist/xote.umd.js +10 -10
- package/package.json +3 -2
- package/src/Computed.res.mjs +6 -0
- package/src/Hydration.res +0 -1
- package/src/Node.res +11 -2
- package/src/Node.res.mjs +9 -4
- package/src/ReactiveProp.res +0 -1
- package/src/Router.res +11 -5
- package/src/Router.res.mjs +2 -2
- package/src/SSR.res +6 -3
- package/src/SSR.res.mjs +5 -0
- package/src/SSRState.res +0 -1
- package/src/Signal.res.mjs +6 -0
- package/src/XoteJSX.res +51 -211
- package/src/XoteJSX.res.mjs +17 -2
package/src/XoteJSX.res
CHANGED
|
@@ -11,8 +11,9 @@ type componentLike<'props, 'return> = 'props => 'return
|
|
|
11
11
|
* This ensures component functions (which may create effects/computeds) are not
|
|
12
12
|
* evaluated during a Computed context, which would incorrectly track their
|
|
13
13
|
* dependencies as belonging to the outer computed. */
|
|
14
|
-
let jsx = (component: component<'props>, props: 'props): element =>
|
|
15
|
-
|
|
14
|
+
let jsx = (component: component<'props>, props: 'props): element => Node.LazyComponent(
|
|
15
|
+
() => component(props),
|
|
16
|
+
)
|
|
16
17
|
|
|
17
18
|
let jsxs = jsx
|
|
18
19
|
|
|
@@ -79,11 +80,20 @@ module Elements = {
|
|
|
79
80
|
'ariaHidden,
|
|
80
81
|
'ariaExpanded,
|
|
81
82
|
'ariaSelected,
|
|
83
|
+
'draggable,
|
|
84
|
+
'hidden,
|
|
85
|
+
'title,
|
|
86
|
+
'contentEditable,
|
|
87
|
+
'spellcheck,
|
|
88
|
+
'autofocus,
|
|
89
|
+
'action,
|
|
90
|
+
'method,
|
|
82
91
|
> = {
|
|
83
92
|
/* Standard attributes - accept raw strings or ReactiveProp.t<string> */
|
|
84
93
|
id?: 'id,
|
|
85
94
|
class?: 'class,
|
|
86
95
|
style?: 'style,
|
|
96
|
+
title?: 'title,
|
|
87
97
|
/* Form/Input attributes */
|
|
88
98
|
@as("type") type_?: 'typ,
|
|
89
99
|
name?: 'name,
|
|
@@ -104,6 +114,9 @@ module Elements = {
|
|
|
104
114
|
accept?: 'accept,
|
|
105
115
|
rows?: int,
|
|
106
116
|
cols?: int,
|
|
117
|
+
autofocus?: 'autofocus,
|
|
118
|
+
action?: 'action,
|
|
119
|
+
method?: 'method,
|
|
107
120
|
/* Label attributes */
|
|
108
121
|
@as("for") for_?: 'forAttr,
|
|
109
122
|
/* Link attributes */
|
|
@@ -114,6 +127,11 @@ module Elements = {
|
|
|
114
127
|
alt?: 'alt,
|
|
115
128
|
width?: 'width,
|
|
116
129
|
height?: 'height,
|
|
130
|
+
/* Global attributes */
|
|
131
|
+
draggable?: 'draggable,
|
|
132
|
+
hidden?: 'hidden,
|
|
133
|
+
contentEditable?: 'contentEditable,
|
|
134
|
+
spellcheck?: 'spellcheck,
|
|
117
135
|
/* Accessibility attributes */
|
|
118
136
|
role?: 'role,
|
|
119
137
|
tabIndex?: int,
|
|
@@ -138,6 +156,14 @@ module Elements = {
|
|
|
138
156
|
onMouseMove?: Dom.event => unit,
|
|
139
157
|
onMouseUp?: Dom.event => unit,
|
|
140
158
|
onContextMenu?: Dom.event => unit,
|
|
159
|
+
/* Drag-and-drop event handlers */
|
|
160
|
+
onDrag?: Dom.event => unit,
|
|
161
|
+
onDragStart?: Dom.event => unit,
|
|
162
|
+
onDragEnd?: Dom.event => unit,
|
|
163
|
+
onDragOver?: Dom.event => unit,
|
|
164
|
+
onDragEnter?: Dom.event => unit,
|
|
165
|
+
onDragLeave?: Dom.event => unit,
|
|
166
|
+
onDrop?: Dom.event => unit,
|
|
141
167
|
/* Children */
|
|
142
168
|
children?: element,
|
|
143
169
|
}
|
|
@@ -217,46 +243,14 @@ module Elements = {
|
|
|
217
243
|
}
|
|
218
244
|
|
|
219
245
|
/* Convert props to attrs array */
|
|
220
|
-
let propsToAttrs = (
|
|
221
|
-
props: props<
|
|
222
|
-
_,
|
|
223
|
-
_,
|
|
224
|
-
_,
|
|
225
|
-
_,
|
|
226
|
-
_,
|
|
227
|
-
_,
|
|
228
|
-
_,
|
|
229
|
-
_,
|
|
230
|
-
_,
|
|
231
|
-
_,
|
|
232
|
-
_,
|
|
233
|
-
_,
|
|
234
|
-
_,
|
|
235
|
-
_,
|
|
236
|
-
_,
|
|
237
|
-
_,
|
|
238
|
-
_,
|
|
239
|
-
_,
|
|
240
|
-
_,
|
|
241
|
-
_,
|
|
242
|
-
_,
|
|
243
|
-
_,
|
|
244
|
-
_,
|
|
245
|
-
_,
|
|
246
|
-
_,
|
|
247
|
-
_,
|
|
248
|
-
_,
|
|
249
|
-
_,
|
|
250
|
-
_,
|
|
251
|
-
_,
|
|
252
|
-
>,
|
|
253
|
-
): array<(string, Node.attrValue)> => {
|
|
246
|
+
let propsToAttrs = (props): array<(string, Node.attrValue)> => {
|
|
254
247
|
let attrs = []
|
|
255
248
|
|
|
256
249
|
/* Standard attributes */
|
|
257
250
|
addAttr(attrs, props.id, "id", convertAttrValue)
|
|
258
251
|
addAttr(attrs, props.class, "class", convertAttrValue)
|
|
259
252
|
addAttr(attrs, props.style, "style", convertAttrValue)
|
|
253
|
+
addAttr(attrs, props.title, "title", convertAttrValue)
|
|
260
254
|
|
|
261
255
|
/* Form/Input attributes */
|
|
262
256
|
addAttr(attrs, props.type_, "type", convertAttrValue)
|
|
@@ -278,6 +272,9 @@ module Elements = {
|
|
|
278
272
|
addAttr(attrs, props.accept, "accept", convertAttrValue)
|
|
279
273
|
addIntAttr(attrs, props.rows, "rows")
|
|
280
274
|
addIntAttr(attrs, props.cols, "cols")
|
|
275
|
+
addAttr(attrs, props.autofocus, "autofocus", convertBoolAttrValue)
|
|
276
|
+
addAttr(attrs, props.action, "action", convertAttrValue)
|
|
277
|
+
addAttr(attrs, props.method, "method", convertAttrValue)
|
|
281
278
|
|
|
282
279
|
/* Label attributes */
|
|
283
280
|
addAttr(attrs, props.for_, "for", convertAttrValue)
|
|
@@ -292,6 +289,12 @@ module Elements = {
|
|
|
292
289
|
addAttr(attrs, props.width, "width", convertAttrValue)
|
|
293
290
|
addAttr(attrs, props.height, "height", convertAttrValue)
|
|
294
291
|
|
|
292
|
+
/* Global attributes */
|
|
293
|
+
addAttr(attrs, props.draggable, "draggable", convertBoolAttrValue)
|
|
294
|
+
addAttr(attrs, props.hidden, "hidden", convertBoolAttrValue)
|
|
295
|
+
addAttr(attrs, props.contentEditable, "contenteditable", convertBoolAttrValue)
|
|
296
|
+
addAttr(attrs, props.spellcheck, "spellcheck", convertBoolAttrValue)
|
|
297
|
+
|
|
295
298
|
/* Accessibility attributes */
|
|
296
299
|
addAttr(attrs, props.role, "role", convertAttrValue)
|
|
297
300
|
addIntAttr(attrs, props.tabIndex, "tabindex")
|
|
@@ -324,40 +327,7 @@ module Elements = {
|
|
|
324
327
|
}
|
|
325
328
|
|
|
326
329
|
/* Convert props to events array */
|
|
327
|
-
let propsToEvents = (
|
|
328
|
-
props: props<
|
|
329
|
-
_,
|
|
330
|
-
_,
|
|
331
|
-
_,
|
|
332
|
-
_,
|
|
333
|
-
_,
|
|
334
|
-
_,
|
|
335
|
-
_,
|
|
336
|
-
_,
|
|
337
|
-
_,
|
|
338
|
-
_,
|
|
339
|
-
_,
|
|
340
|
-
_,
|
|
341
|
-
_,
|
|
342
|
-
_,
|
|
343
|
-
_,
|
|
344
|
-
_,
|
|
345
|
-
_,
|
|
346
|
-
_,
|
|
347
|
-
_,
|
|
348
|
-
_,
|
|
349
|
-
_,
|
|
350
|
-
_,
|
|
351
|
-
_,
|
|
352
|
-
_,
|
|
353
|
-
_,
|
|
354
|
-
_,
|
|
355
|
-
_,
|
|
356
|
-
_,
|
|
357
|
-
_,
|
|
358
|
-
_,
|
|
359
|
-
>,
|
|
360
|
-
): array<(string, Dom.event => unit)> => {
|
|
330
|
+
let propsToEvents = (props): array<(string, Dom.event => unit)> => {
|
|
361
331
|
let events = []
|
|
362
332
|
|
|
363
333
|
addEvent(events, props.onClick, "click")
|
|
@@ -374,45 +344,19 @@ module Elements = {
|
|
|
374
344
|
addEvent(events, props.onMouseMove, "mousemove")
|
|
375
345
|
addEvent(events, props.onMouseUp, "mouseup")
|
|
376
346
|
addEvent(events, props.onContextMenu, "contextmenu")
|
|
347
|
+
addEvent(events, props.onDrag, "drag")
|
|
348
|
+
addEvent(events, props.onDragStart, "dragstart")
|
|
349
|
+
addEvent(events, props.onDragEnd, "dragend")
|
|
350
|
+
addEvent(events, props.onDragOver, "dragover")
|
|
351
|
+
addEvent(events, props.onDragEnter, "dragenter")
|
|
352
|
+
addEvent(events, props.onDragLeave, "dragleave")
|
|
353
|
+
addEvent(events, props.onDrop, "drop")
|
|
377
354
|
|
|
378
355
|
events
|
|
379
356
|
}
|
|
380
357
|
|
|
381
358
|
/* Extract children from props */
|
|
382
|
-
let getChildren = (
|
|
383
|
-
props: props<
|
|
384
|
-
_,
|
|
385
|
-
_,
|
|
386
|
-
_,
|
|
387
|
-
_,
|
|
388
|
-
_,
|
|
389
|
-
_,
|
|
390
|
-
_,
|
|
391
|
-
_,
|
|
392
|
-
_,
|
|
393
|
-
_,
|
|
394
|
-
_,
|
|
395
|
-
_,
|
|
396
|
-
_,
|
|
397
|
-
_,
|
|
398
|
-
_,
|
|
399
|
-
_,
|
|
400
|
-
_,
|
|
401
|
-
_,
|
|
402
|
-
_,
|
|
403
|
-
_,
|
|
404
|
-
_,
|
|
405
|
-
_,
|
|
406
|
-
_,
|
|
407
|
-
_,
|
|
408
|
-
_,
|
|
409
|
-
_,
|
|
410
|
-
_,
|
|
411
|
-
_,
|
|
412
|
-
_,
|
|
413
|
-
_,
|
|
414
|
-
>,
|
|
415
|
-
): array<element> => {
|
|
359
|
+
let getChildren = (props): array<element> => {
|
|
416
360
|
switch props.children {
|
|
417
361
|
| Some(Fragment(children)) => children
|
|
418
362
|
| Some(child) => [child]
|
|
@@ -421,41 +365,7 @@ module Elements = {
|
|
|
421
365
|
}
|
|
422
366
|
|
|
423
367
|
/* Create an element from a tag string and props */
|
|
424
|
-
let createElement = (
|
|
425
|
-
tag: string,
|
|
426
|
-
props: props<
|
|
427
|
-
_,
|
|
428
|
-
_,
|
|
429
|
-
_,
|
|
430
|
-
_,
|
|
431
|
-
_,
|
|
432
|
-
_,
|
|
433
|
-
_,
|
|
434
|
-
_,
|
|
435
|
-
_,
|
|
436
|
-
_,
|
|
437
|
-
_,
|
|
438
|
-
_,
|
|
439
|
-
_,
|
|
440
|
-
_,
|
|
441
|
-
_,
|
|
442
|
-
_,
|
|
443
|
-
_,
|
|
444
|
-
_,
|
|
445
|
-
_,
|
|
446
|
-
_,
|
|
447
|
-
_,
|
|
448
|
-
_,
|
|
449
|
-
_,
|
|
450
|
-
_,
|
|
451
|
-
_,
|
|
452
|
-
_,
|
|
453
|
-
_,
|
|
454
|
-
_,
|
|
455
|
-
_,
|
|
456
|
-
_,
|
|
457
|
-
>,
|
|
458
|
-
): element => {
|
|
368
|
+
let createElement = (tag: string, props): element => {
|
|
459
369
|
Node.Element({
|
|
460
370
|
tag,
|
|
461
371
|
attrs: propsToAttrs(props),
|
|
@@ -465,81 +375,11 @@ module Elements = {
|
|
|
465
375
|
}
|
|
466
376
|
|
|
467
377
|
/* JSX functions for HTML elements - all delegate to createElement */
|
|
468
|
-
let jsx = (
|
|
469
|
-
tag: string,
|
|
470
|
-
props: props<
|
|
471
|
-
_,
|
|
472
|
-
_,
|
|
473
|
-
_,
|
|
474
|
-
_,
|
|
475
|
-
_,
|
|
476
|
-
_,
|
|
477
|
-
_,
|
|
478
|
-
_,
|
|
479
|
-
_,
|
|
480
|
-
_,
|
|
481
|
-
_,
|
|
482
|
-
_,
|
|
483
|
-
_,
|
|
484
|
-
_,
|
|
485
|
-
_,
|
|
486
|
-
_,
|
|
487
|
-
_,
|
|
488
|
-
_,
|
|
489
|
-
_,
|
|
490
|
-
_,
|
|
491
|
-
_,
|
|
492
|
-
_,
|
|
493
|
-
_,
|
|
494
|
-
_,
|
|
495
|
-
_,
|
|
496
|
-
_,
|
|
497
|
-
_,
|
|
498
|
-
_,
|
|
499
|
-
_,
|
|
500
|
-
_,
|
|
501
|
-
>,
|
|
502
|
-
): element => createElement(tag, props)
|
|
378
|
+
let jsx = (tag: string, props): element => createElement(tag, props)
|
|
503
379
|
|
|
504
380
|
let jsxs = jsx
|
|
505
381
|
|
|
506
|
-
let jsxKeyed = (
|
|
507
|
-
tag: string,
|
|
508
|
-
props: props<
|
|
509
|
-
_,
|
|
510
|
-
_,
|
|
511
|
-
_,
|
|
512
|
-
_,
|
|
513
|
-
_,
|
|
514
|
-
_,
|
|
515
|
-
_,
|
|
516
|
-
_,
|
|
517
|
-
_,
|
|
518
|
-
_,
|
|
519
|
-
_,
|
|
520
|
-
_,
|
|
521
|
-
_,
|
|
522
|
-
_,
|
|
523
|
-
_,
|
|
524
|
-
_,
|
|
525
|
-
_,
|
|
526
|
-
_,
|
|
527
|
-
_,
|
|
528
|
-
_,
|
|
529
|
-
_,
|
|
530
|
-
_,
|
|
531
|
-
_,
|
|
532
|
-
_,
|
|
533
|
-
_,
|
|
534
|
-
_,
|
|
535
|
-
_,
|
|
536
|
-
_,
|
|
537
|
-
_,
|
|
538
|
-
_,
|
|
539
|
-
>,
|
|
540
|
-
~key: option<string>=?,
|
|
541
|
-
_: unit,
|
|
542
|
-
): element => {
|
|
382
|
+
let jsxKeyed = (tag: string, props, ~key: option<string>=?, _: unit): element => {
|
|
543
383
|
let _ = key
|
|
544
384
|
jsx(tag, props)
|
|
545
385
|
}
|
package/src/XoteJSX.res.mjs
CHANGED
|
@@ -66,7 +66,7 @@ function convertBoolAttrValue(key, value) {
|
|
|
66
66
|
} else {
|
|
67
67
|
return "false";
|
|
68
68
|
}
|
|
69
|
-
}, undefined);
|
|
69
|
+
}, undefined, undefined);
|
|
70
70
|
return Node$Xote.signalAttr(key, strSignal);
|
|
71
71
|
}
|
|
72
72
|
if (typeof value === "function") {
|
|
@@ -87,7 +87,7 @@ function convertBoolAttrValue(key, value) {
|
|
|
87
87
|
} else {
|
|
88
88
|
return "false";
|
|
89
89
|
}
|
|
90
|
-
}, undefined);
|
|
90
|
+
}, undefined, undefined);
|
|
91
91
|
return Node$Xote.signalAttr(key, strSignal$1);
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -110,6 +110,7 @@ function propsToAttrs(props) {
|
|
|
110
110
|
addAttr(attrs, props.id, "id", convertAttrValue);
|
|
111
111
|
addAttr(attrs, props.class, "class", convertAttrValue);
|
|
112
112
|
addAttr(attrs, props.style, "style", convertAttrValue);
|
|
113
|
+
addAttr(attrs, props.title, "title", convertAttrValue);
|
|
113
114
|
addAttr(attrs, props.type, "type", convertAttrValue);
|
|
114
115
|
addAttr(attrs, props.name, "name", convertAttrValue);
|
|
115
116
|
addAttr(attrs, props.value, "value", convertAttrValue);
|
|
@@ -129,6 +130,9 @@ function propsToAttrs(props) {
|
|
|
129
130
|
addAttr(attrs, props.accept, "accept", convertAttrValue);
|
|
130
131
|
addIntAttr(attrs, props.rows, "rows");
|
|
131
132
|
addIntAttr(attrs, props.cols, "cols");
|
|
133
|
+
addAttr(attrs, props.autofocus, "autofocus", convertBoolAttrValue);
|
|
134
|
+
addAttr(attrs, props.action, "action", convertAttrValue);
|
|
135
|
+
addAttr(attrs, props.method, "method", convertAttrValue);
|
|
132
136
|
addAttr(attrs, props.for, "for", convertAttrValue);
|
|
133
137
|
addAttr(attrs, props.href, "href", convertAttrValue);
|
|
134
138
|
addAttr(attrs, props.target, "target", convertAttrValue);
|
|
@@ -136,6 +140,10 @@ function propsToAttrs(props) {
|
|
|
136
140
|
addAttr(attrs, props.alt, "alt", convertAttrValue);
|
|
137
141
|
addAttr(attrs, props.width, "width", convertAttrValue);
|
|
138
142
|
addAttr(attrs, props.height, "height", convertAttrValue);
|
|
143
|
+
addAttr(attrs, props.draggable, "draggable", convertBoolAttrValue);
|
|
144
|
+
addAttr(attrs, props.hidden, "hidden", convertBoolAttrValue);
|
|
145
|
+
addAttr(attrs, props.contentEditable, "contenteditable", convertBoolAttrValue);
|
|
146
|
+
addAttr(attrs, props.spellcheck, "spellcheck", convertBoolAttrValue);
|
|
139
147
|
addAttr(attrs, props.role, "role", convertAttrValue);
|
|
140
148
|
addIntAttr(attrs, props.tabIndex, "tabindex");
|
|
141
149
|
addAttr(attrs, props["aria-label"], "aria-label", convertAttrValue);
|
|
@@ -177,6 +185,13 @@ function propsToEvents(props) {
|
|
|
177
185
|
addEvent(events, props.onMouseMove, "mousemove");
|
|
178
186
|
addEvent(events, props.onMouseUp, "mouseup");
|
|
179
187
|
addEvent(events, props.onContextMenu, "contextmenu");
|
|
188
|
+
addEvent(events, props.onDrag, "drag");
|
|
189
|
+
addEvent(events, props.onDragStart, "dragstart");
|
|
190
|
+
addEvent(events, props.onDragEnd, "dragend");
|
|
191
|
+
addEvent(events, props.onDragOver, "dragover");
|
|
192
|
+
addEvent(events, props.onDragEnter, "dragenter");
|
|
193
|
+
addEvent(events, props.onDragLeave, "dragleave");
|
|
194
|
+
addEvent(events, props.onDrop, "drop");
|
|
180
195
|
return events;
|
|
181
196
|
}
|
|
182
197
|
|