-
Notifications
You must be signed in to change notification settings - Fork 1
/
utilityTypes.ts
6061 lines (5409 loc) · 344 KB
/
utilityTypes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
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
416
417
418
419
420
421
422
423
424
425
426
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
459
460
461
462
463
464
465
466
467
468
469
470
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
503
504
505
506
507
508
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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Element, HTMLElement, SVGElement, MathMLElement, HTMLInputElement, HTMLOptionElement } from './utils/minidom'
export type innerKey = any
// TODO: SKRUV_1: To do this properly would require https://github.com/microsoft/TypeScript/issues/43826 as we need to always return a type with the generator/proxy but be able to set the original type (or any other type).
export type State<T> = T & AsyncGenerator<T> & { [key in keyof T]: State<T[key]> | T[key] } & { getGenerator: (innerKey: string | number) => State<T[innerKey]>, toJSON: () => T };
// Vnode/DOM types
type NotAUnion<T> = [T] extends [infer U] ? _NotAUnion<U, U> : never;
type _NotAUnion<T, U> = U extends any ? [T] extends [U] ? unknown : never : never;
type NotBuiltinEvent = string & NotAUnion<keyof HTMLElementEventMap | keyof SVGElementEventMap | keyof MathMLElementEventMap>
export type CustomEvents<T> = Record<`on${NotBuiltinEvent}`, (e: CustomEvent & { currentTarget: T }) => void>
export type DataAttributes = Record<`data-${string}`, string | number | boolean> | {}
export type SkruvAdditionalAttributes<T> = {
'skruvAfterCreate'?: (element: T) => void,
'skruvKey'?: object,
'skruvFinished'?: boolean,
'skruvWaitForNotEmpty'?: boolean
}
// AriaAttributes copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/v17/index.d.ts
// Credit to: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
// Microsoft <https://microsoft.com>
// John Reilly <https://github.com/johnnyreilly>
// Benoit Benezech <https://github.com/bbenezech>
// Patricio Zavolinsky <https://github.com/pzavolinsky>
// Eric Anderson <https://github.com/ericanderson>
// Dovydas Navickas <https://github.com/DovydasNavickas>
// Josh Rutherford <https://github.com/theruther4d>
// Guilherme Hübner <https://github.com/guilhermehubner>
// Ferdy Budhidharma <https://github.com/ferdaber>
// Johann Rakotoharisoa <https://github.com/jrakotoharisoa>
// Olivier Pascal <https://github.com/pascaloliv>
// Martin Hochel <https://github.com/hotell>
// Frank Li <https://github.com/franklixuefei>
// Jessica Franco <https://github.com/Jessidhia>
// Saransh Kataria <https://github.com/saranshkataria>
// Kanitkorn Sujautra <https://github.com/lukyth>
// Sebastian Silbermann <https://github.com/eps1lon>
// Kyle Scully <https://github.com/zieka>
// Cong Zhang <https://github.com/dancerphil>
// Dimitri Mitropoulos <https://github.com/dimitropoulos>
// JongChan Choi <https://github.com/disjukr>
// Victor Magalhães <https://github.com/vhfmag>
// Dale Tan <https://github.com/hellatan>
// Priyanshu Rav <https://github.com/priyanshurav>
// Costa Alexoglou <https://github.com/konsalex>
// All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
interface AriaAttributes {
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
'aria-activedescendant'?: string | undefined;
/** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
'aria-atomic'?: boolean | undefined;
/**
* Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
* presented if they are made.
*/
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both' | undefined;
/** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */
'aria-busy'?: boolean | undefined;
/**
* Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
* @see aria-pressed @see aria-selected.
*/
'aria-checked'?: boolean | 'false' | 'mixed' | 'true' | undefined;
/**
* Defines the total number of columns in a table, grid, or treegrid.
* @see aria-colindex.
*/
'aria-colcount'?: number | undefined;
/**
* Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
* @see aria-colcount @see aria-colspan.
*/
'aria-colindex'?: number | undefined;
/**
* Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
* @see aria-colindex @see aria-rowspan.
*/
'aria-colspan'?: number | undefined;
/**
* Identifies the element (or elements) whose contents or presence are controlled by the current element.
* @see aria-owns.
*/
'aria-controls'?: string | undefined;
/** Indicates the element that represents the current item within a container or set of related elements. */
'aria-current'?: boolean | 'false' | 'true' | 'page' | 'step' | 'location' | 'date' | 'time' | undefined;
/**
* Identifies the element (or elements) that describes the object.
* @see aria-labelledby
*/
'aria-describedby'?: string | undefined;
/**
* Identifies the element that provides a detailed, extended description for the object.
* @see aria-describedby.
*/
'aria-details'?: string | undefined;
/**
* Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
* @see aria-hidden @see aria-readonly.
*/
'aria-disabled'?: boolean | undefined;
/**
* Indicates what functions can be performed when a dragged object is released on the drop target.
* @deprecated in ARIA 1.1
*/
'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined;
/**
* Identifies the element that provides an error message for the object.
* @see aria-invalid @see aria-describedby.
*/
'aria-errormessage'?: string | undefined;
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
'aria-expanded'?: boolean | undefined;
/**
* Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
* allows assistive technology to override the general default of reading in document source order.
*/
'aria-flowto'?: string | undefined;
/**
* Indicates an element's "grabbed" state in a drag-and-drop operation.
* @deprecated in ARIA 1.1
*/
'aria-grabbed'?: boolean | undefined;
/** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | undefined;
/**
* Indicates whether the element is exposed to an accessibility API.
* @see aria-disabled.
*/
'aria-hidden'?: boolean | undefined;
/**
* Indicates the entered value does not conform to the format expected by the application.
* @see aria-errormessage.
*/
'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling' | undefined;
/** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
'aria-keyshortcuts'?: string | undefined;
/**
* Defines a string value that labels the current element.
* @see aria-labelledby.
*/
'aria-label'?: string | undefined;
/**
* Identifies the element (or elements) that labels the current element.
* @see aria-describedby.
*/
'aria-labelledby'?: string | undefined;
/** Defines the hierarchical level of an element within a structure. */
'aria-level'?: number | undefined;
/** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */
'aria-live'?: 'off' | 'assertive' | 'polite' | undefined;
/** Indicates whether an element is modal when displayed. */
'aria-modal'?: boolean | undefined;
/** Indicates whether a text box accepts multiple lines of input or only a single line. */
'aria-multiline'?: boolean | undefined;
/** Indicates that the user may select more than one item from the current selectable descendants. */
'aria-multiselectable'?: boolean | undefined;
/** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
'aria-orientation'?: 'horizontal' | 'vertical' | undefined;
/**
* Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
* between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
* @see aria-controls.
*/
'aria-owns'?: string | undefined;
/**
* Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
* A hint could be a sample value or a brief description of the expected format.
*/
'aria-placeholder'?: string | undefined;
/**
* Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
* @see aria-setsize.
*/
'aria-posinset'?: number | undefined;
/**
* Indicates the current "pressed" state of toggle buttons.
* @see aria-checked @see aria-selected.
*/
'aria-pressed'?: boolean | 'false' | 'mixed' | 'true' | undefined;
/**
* Indicates that the element is not editable, but is otherwise operable.
* @see aria-disabled.
*/
'aria-readonly'?: boolean | undefined;
/**
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
* @see aria-atomic.
*/
'aria-relevant'?: 'additions' | 'additions removals' | 'additions text' | 'all' | 'removals' | 'removals additions' | 'removals text' | 'text' | 'text additions' | 'text removals' | undefined;
/** Indicates that user input is required on the element before a form may be submitted. */
'aria-required'?: boolean | undefined;
/** Defines a human-readable, author-localized description for the role of an element. */
'aria-roledescription'?: string | undefined;
/**
* Defines the total number of rows in a table, grid, or treegrid.
* @see aria-rowindex.
*/
'aria-rowcount'?: number | undefined;
/**
* Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
* @see aria-rowcount @see aria-rowspan.
*/
'aria-rowindex'?: number | undefined;
/**
* Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
* @see aria-rowindex @see aria-colspan.
*/
'aria-rowspan'?: number | undefined;
/**
* Indicates the current "selected" state of various widgets.
* @see aria-checked @see aria-pressed.
*/
'aria-selected'?: boolean | undefined;
/**
* Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
* @see aria-posinset.
*/
'aria-setsize'?: number | undefined;
/** Indicates if items in a table or grid are sorted in ascending or descending order. */
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other' | undefined;
/** Defines the maximum allowed value for a range widget. */
'aria-valuemax'?: number | undefined;
/** Defines the minimum allowed value for a range widget. */
'aria-valuemin'?: number | undefined;
/**
* Defines the current value for a range widget.
* @see aria-valuetext.
*/
'aria-valuenow'?: number | undefined;
/** Defines the human readable text alternative of aria-valuenow for a range widget. */
'aria-valuetext'?: string | undefined;
}
// All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
type AriaRole =
| 'alert'
| 'alertdialog'
| 'application'
| 'article'
| 'banner'
| 'button'
| 'cell'
| 'checkbox'
| 'columnheader'
| 'combobox'
| 'complementary'
| 'contentinfo'
| 'definition'
| 'dialog'
| 'directory'
| 'document'
| 'feed'
| 'figure'
| 'form'
| 'grid'
| 'gridcell'
| 'group'
| 'heading'
| 'img'
| 'link'
| 'list'
| 'listbox'
| 'listitem'
| 'log'
| 'main'
| 'marquee'
| 'math'
| 'menu'
| 'menubar'
| 'menuitem'
| 'menuitemcheckbox'
| 'menuitemradio'
| 'navigation'
| 'none'
| 'note'
| 'option'
| 'presentation'
| 'progressbar'
| 'radio'
| 'radiogroup'
| 'region'
| 'row'
| 'rowgroup'
| 'rowheader'
| 'scrollbar'
| 'search'
| 'searchbox'
| 'separator'
| 'slider'
| 'spinbutton'
| 'status'
| 'switch'
| 'tab'
| 'table'
| 'tablist'
| 'tabpanel'
| 'term'
| 'textbox'
| 'timer'
| 'toolbar'
| 'tooltip'
| 'tree'
| 'treegrid'
| 'treeitem'
| (string & {});
interface HTMLGlobalAttributes extends AriaAttributes {
'class'?: string | undefined
'id'?: string | undefined
'slot'?: string | undefined
'accesskey'?: string | undefined
'autocapitalize'?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters' | undefined
'autofocus'?: boolean | undefined
'contenteditable'?: '' | 'true' | 'plaintext-only' | 'false'
'dir'?: 'ltr' | 'rtl' | 'auto' | undefined
'draggable'?: 'true' | 'false' | 'auto' | undefined
'enterkeyhint'?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined
'hidden'?: 'until-found' | 'hidden' | '' | undefined
'inert'?: boolean | undefined
'inputmode'?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search' | undefined
// "is" is special, see the spec
'// is'?: string
'itemid'?: URL | undefined
'itemprop'?: string | undefined
'itemref'?: string | undefined // this needs to be a space separated list of valid ID's in the document
'itemscope'?: boolean | undefined
'itemtype'?: string | undefined // this needs to be a space separated list of valid URL's
'lang'?: string | undefined
'nonce'?: string | undefined
'popover'?: 'auto' | '' | 'manual' | undefined
'spellcheck'?: boolean | undefined
'style'?: string | undefined
'tabindex'?: number | undefined
'title'?: string | undefined
'translate'?: 'yes' | '' | 'no' | undefined
}
interface SVGGlobalAttributes {
'class'?: string | undefined
'style'?: string | undefined
'id'?: string | undefined
'lang'?: string | undefined
'tabindex'?: number | undefined
'xml:base'?: string | undefined
'xml:lang'?: string | undefined
'xml:space'?: 'default' | 'preserve' | undefined
'requiredExtensions'?: string | undefined
'requiredFeatures'?: string | undefined
'systemLanguage'?: string | undefined
}
interface SVGPresentationAttributes {
'alignment-baseline'?: string | number | undefined;
'baseline-shift'?: string | number | undefined;
'clip'?: string | number | undefined;
'clip-path'?: string | number | undefined;
'clip-rule'?: string | number | undefined;
'color'?: string | number | undefined;
'color-interpolation'?: string | number | undefined;
'color-interpolation-filters'?: string | number | undefined;
'color-profile'?: string | number | undefined;
'color-rendering'?: string | number | undefined;
'cursor'?: string | number | undefined;
'direction'?: string | number | undefined;
'display'?: string | number | undefined;
'dominant-baseline'?: string | number | undefined;
'enable-background'?: string | number | undefined;
'fill'?: string | number | undefined;
'fill-opacity'?: string | number | undefined;
'fill-rule'?: string | number | undefined;
'filter'?: string | number | undefined;
'flood-color'?: string | number | undefined;
'flood-opacity'?: string | number | undefined;
'font-family'?: string | number | undefined;
'font-size'?: string | number | undefined;
'font-size-adjust'?: string | number | undefined;
'font-stretch'?: string | number | undefined;
'font-style'?: string | number | undefined;
'font-variant'?: string | number | undefined;
'font-weight'?: string | number | undefined;
'glyph-orientation-horizontal'?: string | number | undefined;
'glyph-orientation-vertical'?: string | number | undefined;
'image-rendering'?: string | number | undefined;
'kerning'?: string | number | undefined;
'letter-spacing'?: string | number | undefined;
'lighting-color'?: string | number | undefined;
'marker-end'?: string | number | undefined;
'marker-mid'?: string | number | undefined;
'marker-start'?: string | number | undefined;
'mask'?: string | number | undefined;
'opacity'?: string | number | undefined;
'overflow'?: string | number | undefined;
'pointer-events'?: string | number | undefined;
'shape-rendering'?: string | number | undefined;
'stop-color'?: string | number | undefined;
'stop-opacity'?: string | number | undefined;
'stroke'?: string | number | undefined;
'stroke-dasharray'?: string | number | undefined;
'stroke-dashoffset'?: string | number | undefined;
'stroke-linecap'?: string | number | undefined;
'stroke-linejoin'?: string | number | undefined;
'stroke-miterlimit'?: string | number | undefined;
'stroke-opacity'?: string | number | undefined;
'stroke-width'?: string | number | undefined;
'text-anchor'?: string | number | undefined;
'text-decoration'?: string | number | undefined;
'text-rendering'?: string | number | undefined;
'transform'?: string | number | undefined;
'transform-origin'?: string | number | undefined;
'unicode-bidi'?: string | number | undefined;
'vector-effect'?: string | number | undefined;
'visibility'?: string | number | undefined;
'word-spacing'?: string | number | undefined;
'writing-mode'?: string | number | undefined;
}
interface SVGFilterAttributes {
'height'?: string | number | undefined;
'result'?: string | number | undefined;
'width'?: string | number | undefined;
'x'?: string | number | undefined;
'y'?: string | number | undefined;
'type'?: string | number | undefined;
'tableValues'?: string | number | undefined;
'slope'?: string | number | undefined;
'intercept'?: string | number | undefined;
'amplitude'?: string | number | undefined;
'exponent'?: string | number | undefined;
'offset'?: string | number | undefined;
}
interface SVGAnimationAttributes {
'href'?: string | number | undefined;
'attributeType'?: string | number | undefined;
'attributeName'?: string | number | undefined;
'begin'?: string | number | undefined;
'dur'?: string | number | undefined;
'end'?: string | number | undefined;
'min'?: string | number | undefined;
'max'?: string | number | undefined;
'restart'?: string | number | undefined;
'repeatCount'?: string | number | undefined;
'repeatDur'?: string | number | undefined;
'fill'?: string | number | undefined;
'calcMode'?: string | number | undefined;
'values'?: string | number | undefined;
'keyTimes'?: string | number | undefined;
'keySplines'?: string | number | undefined;
'from'?: string | number | undefined;
'to'?: string | number | undefined;
'by'?: string | number | undefined;
'autoReverse'?: string | number | undefined;
'accelerate'?: string | number | undefined;
'decelerate'?: string | number | undefined;
'additive'?: string | number | undefined;
'accumulate'?: string | number | undefined;
}
interface MathMLGlobalAttributes {
class?: string | number | undefined;
dir?: string | number | undefined;
id?: string | number | undefined;
mathbackground?: string | number | undefined;
mathcolor?: string | number | undefined;
mathsize?: string | number | undefined;
mathvariant?: string | number | undefined;
nonce?: string | number | undefined;
scriptlevel?: string | number | undefined;
style?: string | number | undefined;
tabindex?: string | number | undefined;
}
interface AtomGlobalAttributes { }
interface SitemapGlobalAttributes { }
type HTMLEvents<T> = { [key in keyof HTMLElementEventMap as `on${key}`]?: ((e: (HTMLElementEventMap[key] & { currentTarget: T })) => void) }
type SVGEvents<T> = { [key in keyof SVGElementEventMap as `on${key}`]?: ((e: (SVGElementEventMap[key] & { currentTarget: T })) => void) }
type MathMlEvents<T> = { [key in keyof MathMLElementEventMap as `on${key}`]?: ((e: (MathMLElementEventMap[key] & { currentTarget: T })) => void) }
type HTMLAttributes<T, A> = A & CustomEvents<T> & HTMLEvents<T> & DataAttributes & SkruvAdditionalAttributes<T> & HTMLGlobalAttributes & { isSkruvDom?: false }
type SVGAttributes<T, A> = A & CustomEvents<T> & SVGEvents<T> & DataAttributes & SkruvAdditionalAttributes<T> & SVGGlobalAttributes & { isSkruvDom?: false }
type MathMLAttributes<T, A> = A & CustomEvents<T> & MathMlEvents<T> & DataAttributes & SkruvAdditionalAttributes<T> & MathMLGlobalAttributes & { isSkruvDom?: false }
type AtomAttributes<T, A> = A & { isSkruvDom?: false }
type SitemapAttributes<T, A> = A & { isSkruvDom?: false }
export type HTMLVnode<N, A, C> = {
isSkruvDom: true
t: N
c: [(A | C)?, ...C[]]
r?: () => boolean
}
export type SVGVnode<N, A, C> = {
isSkruvDom: true
t: N
c: [(A | C)?, ...C[]]
r?: () => boolean
}
export type MathMLVnode<N, A, C> = {
isSkruvDom: true
t: N
c: [(A | C)?, ...C[]]
r?: () => boolean
}
export type AtomVnode<N, A, C> = {
isSkruvDom: true
t: N
c: [(A & { isSkruvDom?: false } | C)?, ...C[]]
r?: () => boolean
}
export type SitemapVnode<N, A, C> = {
isSkruvDom: true
t: N
c: [(A & { isSkruvDom?: false } | C)?, ...C[]]
r?: () => boolean
}
export type attributes = HTMLAttributes<Record<string, string | number | boolean | object | Function>, HTMLElement> | SVGAttributes<Record<string, string | number | boolean | object | Function>, SVGElement> | MathMLAttributes<Record<string, string | number | boolean | object | Function>, MathMLElement>
export type Vnode = AnyElement
export type children = Vnode['c']
export type CustomElements = { [id: `${string}-${string}`]: getHTMLVnode<Record<string, string | number | boolean | object | Function>, HTMLElement, typeof id, Vnode | StringChild> }
export type getHTMLVnode<N, T, A, C> = (...args: [(HTMLAttributes<T, A> | C), ...C[]]) => HTMLVnode<N, HTMLAttributes<T, A>, C>
export type keyedMap = WeakMap<Element | object, Element | object>
export type oldKeysMap = WeakMap<Element, object>
export type attributesMap = WeakMap<Element, Record<string, Function | string | boolean | object>>
export type domCacheObj = Record<string, Element>
export type AnyRealElement = HTMLElement | SVGElement | MathMLElement
export type VoidCheck = void | SkruvCommentElement | SkruvHeaderElement
export type StringChild = string | number | boolean | SkruvCommentElement | SkruvTextElement | SkruvHeaderElement
/** The <html> HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element. */
export type SkruvHtmlHTMLAttributes = AsyncContent<HTMLAttributes<HTMLHtmlElement, {
/**
* Specifies the URI of a resource manifest indicating resources that should be cached locally.
*/
'manifest'?: string | number | boolean | false
/**
* Specifies the version of the HTML Document Type Definition that governs the current document. This attribute is not needed, because it is redundant with the version information in the document type declaration.
*/
'version'?: string | false
/**
* Specifies the XML Namespace of the document. Default value is "http://www.w3.org/1999/xhtml". This is required in documents parsed with XML parsers, and optional in text/html documents.
*/
'xmlns'?: string | number | boolean | false
}>>
export interface SkruvHtmlHTMLElement extends HTMLVnode<'html', SkruvHtmlHTMLAttributes, AsyncContent<AnyHTMLContent>> { }
/** The <base> HTML element specifies the base URL to use for all relative URLs in a document. There can be only one <base> element in a document. */
export type SkruvBaseHTMLAttributes = AsyncContent<HTMLAttributes<HTMLBaseElement, {
/**
* The base URL to be used throughout the document for relative URLs. Absolute and relative URLs are allowed.
*/
'href'?: string | false
/**
* A keyword or author-defined name of the default browsing context to show the results of navigation from <a>, <area>, or <form> elements without explicit target attributes. The following keywords have special meanings:
*
* _self (default): Show the result in the current browsing context.
*
* _blank: Show the result in a new, unnamed browsing context.
*
* _parent: Show the result in the parent browsing context of the current one, if the current page is inside a frame. If there is no parent, acts the same as _self.
*
* _top: Show the result in the topmost browsing context (the browsing context that is an ancestor of the current one and has no parent). If there is no parent, acts the same as _self.
*/
'target'?: string | false
}>>
export interface SkruvBaseHTMLElement extends HTMLVnode<'base', SkruvBaseHTMLAttributes, VoidCheck> { }
/** The <head> HTML element contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets. */
export type SkruvHeadHTMLAttributes = AsyncContent<HTMLAttributes<HTMLHeadElement, {
/**
* The URIs of one or more metadata profiles, separated by white space.
*/
'profile'?: string | number | boolean | false
}>>
export interface SkruvHeadHTMLElement extends HTMLVnode<'head', SkruvHeadHTMLAttributes, AsyncContent<SkruvHTMLMetadataContentGroup>> { }
/** The <title> HTML element defines the document's title that is shown in a browser's title bar or a page's tab. It only contains text; tags within the element are ignored. */
export type SkruvTitleHTMLAttributes = AsyncContent<HTMLAttributes<HTMLTitleElement, {}>>
export interface SkruvTitleHTMLElement extends HTMLVnode<'title', SkruvTitleHTMLAttributes, AsyncContent<StringChild>> { }
/** The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON. */
export type SkruvScriptHTMLAttributes = AsyncContent<HTMLAttributes<HTMLScriptElement, {
/**
* For classic scripts, if the async attribute is present, then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available.
*
* For module scripts, if the async attribute is present then the scripts and all their dependencies will be executed in the defer queue, therefore they will get fetched in parallel to parsing and evaluated as soon as they are available.
*
* This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. defer has a similar effect in this case.
*
* This is a boolean attribute: the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
*
* See Browser compatibility for notes on browser support. See also Async scripts for asm.js.
*/
'async'?: boolean | false
/**
* Normal script elements pass minimal information to the window.onerror for scripts which do not pass the standard CORS checks. To allow error logging for sites which use a separate domain for static media, use this attribute. See CORS settings attributes for a more descriptive explanation of its valid arguments.
*/
'crossorigin'?: string | false
/**
* This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded.
*
* Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has loaded and finished evaluating.
*
* Warning: This attribute must not be used if the src attribute is absent (i.e. for inline scripts), in this case it would have no effect.
*
* The defer attribute has no effect on module scripts — they defer by default.
*
* Scripts with the defer attribute will execute in the order in which they appear in the document.
*
* This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. async has a similar effect in this case.
*/
'defer'?: boolean | false
/**
* Provides a hint of the relative priority to use when fetching an external script. Allowed values:
*
* high
*
* Signals a high-priority fetch relative to other external scripts.
*
* low
*
* Signals a low-priority fetch relative to other external scripts.
*
* auto
*
* Default: Signals automatic determination of fetch priority relative to other external scripts.
*/
'fetchpriority'?: string | false
/**
* This attribute contains inline metadata that a user agent can use to verify that a fetched resource has been delivered free of unexpected manipulation. See Subresource Integrity.
*/
'integrity'?: string | false
/**
* This Boolean attribute is set to indicate that the script should not be executed in browsers that support ES modules — in effect, this can be used to serve fallback scripts to older browsers that do not support modular JavaScript code.
*/
'nomodule'?: boolean | false
/**
* A cryptographic nonce (number used once) to allow scripts in a script-src Content-Security-Policy. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.
*/
'nonce'?: string | number | boolean | false
/**
* Indicates which referrer to send when fetching the script, or resources fetched by the script:
*
* no-referrer: The Referer header will not be sent.
*
* no-referrer-when-downgrade: The Referer header will not be sent to origins without TLS (HTTPS).
*
* origin: The sent referrer will be limited to the origin of the referring page: its scheme, host, and port.
*
* origin-when-cross-origin: The referrer sent to other origins will be limited to the scheme, the host, and the port. Navigations on the same origin will still include the path.
*
* same-origin: A referrer will be sent for same origin, but cross-origin requests will contain no referrer information.
*
* strict-origin: Only send the origin of the document as the referrer when the protocol security level stays the same (HTTPS→HTTPS), but don't send it to a less secure destination (HTTPS→HTTP).
*
* strict-origin-when-cross-origin (default): Send a full URL when performing a same-origin request, only send the origin when the protocol security level stays the same (HTTPS→HTTPS), and send no header to a less secure destination (HTTPS→HTTP).
*
* unsafe-url: The referrer will include the origin and the path (but not the fragment, password, or username). This value is unsafe, because it leaks origins and paths from TLS-protected resources to insecure origins.
*
* Note: An empty string value ("") is both the default value, and a fallback value if referrerpolicy is not supported. If referrerpolicy is not explicitly specified on the <script> element, it will adopt a higher-level referrer policy, i.e. one set on the whole document or domain. If a higher-level policy is not available, the empty string is treated as being equivalent to strict-origin-when-cross-origin.
*/
'referrerpolicy'?: string | false
/**
* This attribute specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a document.
*/
'src'?: string | false
/**
* This attribute indicates the type of script represented.
*
* The value of this attribute will be one of the following:
*
* Attribute is not set (default), an empty string, or a JavaScript MIME type
*
* Indicates that the script is a "classic script", containing JavaScript code.
*
* Authors are encouraged to omit the attribute if the script refers to JavaScript code rather than specify a MIME type.
*
* JavaScript MIME types are listed in the IANA media types specification.
*
* module
*
* This value causes the code to be treated as a JavaScript module.
*
* The processing of the script contents is deferred.
*
* The charset and defer attributes have no effect.
*
* For information on using module, see our JavaScript modules guide.
*
* Unlike classic scripts, module scripts require the use of the CORS protocol for cross-origin fetching.
*
* importmap
*
* This value indicates that the body of the element contains an import map.
*
* The import map is a JSON object that developers can use to control how the browser resolves module specifiers when importing JavaScript modules.
*
* Any other value
*
* The embedded content is treated as a data block, and won't be processed by the browser.
*
* Developers must use a valid MIME type that is not a JavaScript MIME type to denote data blocks.
*
* All of the other attributes will be ignored, including the src attribute.
*/
'type'?: string | false
/**
* This attribute explicitly indicates that certain operations should be blocked on the fetching of the script. The operations that are to be blocked must be a space-separated list of blocking attributes listed below.
*
* render: The rendering of content on the screen is blocked.
*/
'blocking'?: 'render' | false
}>>
export interface SkruvScriptHTMLElement extends HTMLVnode<'script', SkruvScriptHTMLAttributes, AsyncContent<StringChild>> { }
/** The <style> HTML element contains style information for a document, or part of a document. It contains CSS, which is applied to the contents of the document containing the <style> element. */
export type SkruvStyleHTMLAttributes = AsyncContent<HTMLAttributes<HTMLStyleElement, {
/**
* This attribute defines which media the style should be applied to. Its value is a media query, which defaults to all if the attribute is missing.
*/
'media'?: string | false
/**
* A cryptographic nonce (number used once) used to allow inline styles in a style-src Content-Security-Policy. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.
*/
'nonce'?: string | number | boolean | false
/**
* This attribute specifies alternative style sheet sets.
*/
'title'?: string | false
/**
* This attribute explicitly indicates that certain operations should be blocked on the fetching of critical subresources. @import-ed stylesheets are generally considered as critical subresources, whereas background-image and fonts are not.
*
* render: The rendering of content on the screen is blocked.
*/
'blocking'?: 'render' | false
}>>
export interface SkruvStyleHTMLElement extends HTMLVnode<'style', SkruvStyleHTMLAttributes, AsyncContent<StringChild>> { }
/** The <link> HTML element specifies relationships between the current document and an external resource.
*
* This element is most commonly used to link to stylesheets, but is also used to establish site icons (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things. */
export type SkruvLinkHTMLAttributes = AsyncContent<HTMLAttributes<HTMLLinkElement, {
/**
* This attribute is required when rel="preload" has been set on the <link> element, optional when rel="modulepreload" has been set, and otherwise should not be used.
*
* It specifies the type of content being loaded by the <link>, which is necessary for request matching, application of correct content security policy, and setting of correct Accept request header.
*
* Furthermore, rel="preload" uses this as a signal for request prioritization.
*
* The table below lists the valid values for this attribute and the elements or resources they apply to.
*
* Value
*
* Applies To
*
* audio
*
* <audio> elements
*
* document
*
* <iframe> and <frame> elements
*
* embed
*
* <embed> elements
*
* fetch
*
* fetch, XHR
*
* Note: This value also requires
*
* <link> to contain the crossorigin attribute.
*
* font
*
* CSS @font-face
*
* image
*
* <img> and <picture> elements with
*
* srcset or imageset attributes, SVG <image> elements,
*
* CSS *-image rules
*
* object
*
* <object> elements
*
* script
*
* <script> elements, Worker importScripts
*
* style
*
* <link rel=stylesheet> elements, CSS
*
* @import
*
* track
*
* <track> elements
*
* video
*
* <video> elements
*
* worker
*
* Worker, SharedWorker
*/
'as'?: string | false
/**
* This enumerated attribute indicates whether CORS must be used when fetching the resource.
*
* CORS-enabled images can be reused in the <canvas> element without being tainted.
*
* The allowed values are:
*
* anonymous
*
* A cross-origin request (i.e. with an Origin HTTP header) is performed, but no credential is sent (i.e. no cookie, X.509 certificate, or HTTP Basic authentication).
*
* If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin HTTP header) the resource will be tainted and its usage restricted.
*
* use-credentials
*
* A cross-origin request (i.e. with an Origin HTTP header) is performed along with a credential sent (i.e. a cookie, certificate, and/or HTTP Basic authentication is performed).
*
* If the server does not give credentials to the origin site (through Access-Control-Allow-Credentials HTTP header), the resource will be tainted and its usage restricted.
*
* If the attribute is not present, the resource is fetched without a CORS request (i.e. without sending the Origin HTTP header), preventing its non-tainted usage. If invalid, it is handled as if the enumerated keyword anonymous was used.
*
* See CORS settings attributes for additional information.
*/
'crossorigin'?: string | false
/**
* For rel="stylesheet" only, the disabled Boolean attribute indicates whether the described stylesheet should be loaded and applied to the document.
*
* If disabled is specified in the HTML when it is loaded, the stylesheet will not be loaded during page load.
*
* Instead, the stylesheet will be loaded on-demand, if and when the disabled attribute is changed to false or removed.
*
* Setting the disabled property in the DOM causes the stylesheet to be removed from the document's Document.styleSheets list.
*/
'disabled'?: boolean | false
/**
* Provides a hint of the relative priority to use when fetching a preloaded resource. Allowed values:
*
* high
*
* Signals a high-priority fetch relative to other resources of the same type.
*
* low
*
* Signals a low-priority fetch relative to other resources of the same type.
*
* auto
*
* Default: Signals automatic determination of fetch priority relative to other resources of the same type.
*/
'fetchpriority'?: string | false
/**
* This attribute specifies the URL of the linked resource. A URL can be absolute or relative.
*/
'href'?: string | false
/**
* This attribute indicates the language of the linked resource.
*
* It is purely advisory.
*
* Allowed values are specified by RFC 5646: Tags for Identifying Languages (also known as BCP 47).
*
* Use this attribute only if the href attribute is present.
*/
'hreflang'?: string | false
/**
* For rel="preload" and as="image" only, the imagesizes attribute is a sizes attribute that indicates to preload the appropriate resource used by an img element with corresponding values for its srcset and sizes attributes.
*/
'imagesizes'?: string | false
/**
* For rel="preload" and as="image" only, the imagesrcset attribute is a sourceset attribute that indicates to preload the appropriate resource used by an img element with corresponding values for its srcset and sizes attributes.
*/
'imagesrcset'?: string | false
/**
* Contains inline metadata — a base64-encoded cryptographic hash of the resource (file) you're telling the browser to fetch.
*
* The browser can use this to verify that the fetched resource has been delivered free of unexpected manipulation.
*
* See Subresource Integrity.
*/
'integrity'?: string | false
/**
* This attribute specifies the media that the linked resource applies to. Its value must be a media type / media query.
*
* This attribute is mainly useful when linking to external stylesheets — it allows the user agent to pick the best adapted one for the device it runs on.
*
* Note:
*
* In HTML 4, this can only be a simple white-space-separated list of media description literals, i.e., media types and groups, where defined and allowed as values for this attribute, such as print, screen, aural, braille.
*
* HTML5 extended this to any kind of media queries, which are a superset of the allowed values of HTML 4.
*
* Browsers not supporting CSS Media Queries won't necessarily recognize the adequate link; do not forget to set fallback links, the restricted set of media queries defined in HTML 4.
*/
'media'?: string | false
/**
* Identifies a resource that might be required by the next navigation and that the user agent should retrieve it.
*
* This allows the user agent to respond faster when the resource is requested in the future.
*/
'prefetch'?: string | number | boolean | false
/**
* A string indicating which referrer to use when fetching the resource:
*
* no-referrer means that the Referer header will not be sent.
*
* no-referrer-when-downgrade means that no Referer header will be sent when navigating to an origin without TLS (HTTPS).
*
* This is a user agent's default behavior, if no policy is otherwise specified.
*
* origin means that the referrer will be the origin of the page, which is roughly the scheme, the host, and the port.
*
* origin-when-cross-origin means that navigating to other origins will be limited to the scheme, the host, and the port, while navigating on the same origin will include the referrer's path.
*
* unsafe-url means that the referrer will include the origin and the path (but not the fragment, password, or username).
*
* This case is unsafe because it can leak origins and paths from TLS-protected resources to insecure origins.
*/
'referrerpolicy'?: string | false
/**
* This attribute names a relationship of the linked document to the current document. The attribute must be a space-separated list of link type values.
*/
'rel'?: string | false
/**
* This attribute defines the sizes of the icons for visual media contained in the resource.
*
* It must be present only if the rel contains a value of icon or a non-standard type such as Apple's apple-touch-icon.
*
* It may have the following values:
*
* any, meaning that the icon can be scaled to any size as it is in a vector format, like image/svg+xml.
*
* a white-space separated list of sizes, each in the format <width in pixels>x<height in pixels> or <width in pixels>X<height in pixels>. Each of these sizes must be contained in the resource.
*
* Note: Most icon formats are only able to store one single icon; therefore, most of the time, the sizes attribute contains only one entry.
*
* MS's ICO format does, as well as Apple's ICNS. ICO is more ubiquitous, so you should use this format if cross-browser support is a concern (especially for old IE versions).
*/
'sizes'?: string | false
/**
* The title attribute has special semantics on the <link> element.
*
* When used on a <link rel="stylesheet"> it defines a default or an alternate stylesheet.
*/
'title'?: string | false
/**
* This attribute is used to define the type of the content linked to.
*
* The value of the attribute should be a MIME type such as text/html, text/css, and so on.
*
* The common use of this attribute is to define the type of stylesheet being referenced (such as text/css), but given that CSS is the only stylesheet language used on the web, not only is it possible to omit the type attribute, but is actually now recommended practice.
*
* It is also used on rel="preload" link types, to make sure the browser only downloads file types that it supports.
*/
'type'?: string | false
/**
* This attribute explicitly indicates that certain operations should be blocked on the fetching of an external resource. The operations that are to be blocked must be a space-separated list of blocking attributes listed below.
*
* render: The rendering of content on the screen is blocked.
*/
'blocking'?: 'render' | false
}>>
export interface SkruvLinkHTMLElement extends HTMLVnode<'link', SkruvLinkHTMLAttributes, VoidCheck> { }
/** The <meta> HTML element represents metadata that cannot be represented by other HTML meta-related elements, like <base>, <link>, <script>, <style> or <title>. */