forked from kitajs/html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotwire-turbo.d.ts
124 lines (116 loc) · 4.12 KB
/
hotwire-turbo.d.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
// This file is a result from https://turbo.hotwired.dev/
// Missing something? Please submit a issue report or a PR:
// https://github.com/kitajs/html
declare namespace JSX {
interface HtmlTag extends HotwireTurbo.Attributes {}
interface IntrinsicElements extends HotwireTurbo.Elements {}
}
declare namespace HotwireTurbo {
interface TurboFrameTag extends JSX.HtmlTag {
id: string;
/**
* Scroll to Turbo frame element after load Control the vertical alignment with
* data-autoscroll-block
*/
autoscroll?: boolean;
target?: '_top' | Omit<string, '_top'>;
/** Accepts a URL or path value that controls navigation of the element */
src?: string;
/**
* When loading="eager", changes to the src attribute will immediately navigate the
* element. When loading="lazy", changes to the src attribute will defer navigation
* until the element is visible in the viewport.
*
* @default { eager }
*/
loading?: 'eager' | 'lazy';
/**
* Controls the autoscroll vertical alignment
*
* @default { end }
* @link {https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#parameters}
*/
['data-autoscroll-block']?: 'end' | 'start' | 'center' | 'nearest';
/**
* Controls the autoscroll behavior
*
* @default { end }
* @link {https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#parameters}
*/
['data-autoscroll-behavior']?: 'auto' | 'smooth';
}
interface TurboStreamTag extends JSX.HtmlTag {
action: 'append' | 'prepend' | 'replace' | 'update' | 'remove' | 'before' | 'after';
target?: string;
targets?: string;
}
interface Elements {
['turbo-frame']: TurboFrameTag;
['turbo-stream']: TurboStreamTag;
}
/**
* Turbo data attributes to add to every element This adds strong typing and
* documentation to these tags
*/
interface Attributes {
/**
* False: disables Turbo Drive on links and forms including descendants. Use "true" to
* renable when an ancestor has opted out
*/
['data-turbo']?: 'true' | 'false';
/** Tracks the element’s HTML and performs a full page reload when it changes */
['data-turbo-track']?: 'reload';
/** Identifies the Turbo Frame to navigate. */
['data-turbo-frame']?: string;
/**
* Customizes the Turbo.visit action.
*
* "Replace" will visit a link without pushing a new history entry onto the stack. It
* will discard your current location in the history stack.
*/
['data-turbo-action']?: 'replace' | 'advance';
/**
* Persists element between page loads
*
* The element **must** have an id
*
* @link {https://turbo.hotwired.dev/handbook/building#persisting-elements-across-page-loads}
*/
['data-turbo-permanent']?: boolean;
/**
* Removes the element before the document is cached, preventing it from reappearing
* when restored.
*/
['data-turbo-temporary']?: boolean;
/** Prevents inline scripts from being re-evaluated on Visits. */
['data-turbo-eval']?: 'false';
/**
* Changes the request link method from the default "GET" request You should prefer a
* form in most cases
*/
['data-turbo-method']?: string;
/**
* Specifies that a link/form can accept a turbo stream response
*
* Turbo will automatically request Turbo streams on Form submissions for non GETs
*
* This is useful when trying to request turbo streams on GET requests
*/
['data-turbo-stream']?: boolean;
/**
* Presents a confirm dialog with the given value. This can be used on form elements
* or links with the data-turbo-method attribute.
*/
['data-turbo-confirm']?: string;
/**
* Specifies text to display when submitting a form. Can be used on input or button
* elements. While the form is submitting, the text of the element will show with this
* value.
*
* After submission, the original text will be restored.
*
* Useful for feedback like "Saving..." while an operation is in progress
*/
['data-turbo-submits-with']?: string;
}
}