htmx.org 1.9.4 → 1.9.6
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/CHANGELOG.md +26 -1
- package/README.md +3 -9
- package/dist/ext/client-side-templates.js +48 -1
- package/dist/ext/disable-element.js +7 -5
- package/dist/ext/loading-states.js +48 -44
- package/dist/ext/morphdom-swap.js +2 -1
- package/dist/ext/response-targets.js +38 -26
- package/dist/ext/ws.js +1 -1
- package/dist/htmx.d.ts +78 -20
- package/dist/htmx.js +185 -59
- package/dist/htmx.js.gz +0 -0
- package/dist/htmx.min.js +1 -1
- package/dist/htmx.min.js.gz +0 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.9.6] - 2023-09-22
|
|
4
|
+
|
|
5
|
+
* IE support has been restored (thank you @telroshan!)
|
|
6
|
+
* Introduced the `hx-disabled-elt` attribute to allow specifing elements to disable during a request
|
|
7
|
+
* You can now explicitly decide to ignore `title` tags found in new content via the `ignoreTitle` option in `hx-swap` and the `htmx.config.ignoreTitle` configuration variable.
|
|
8
|
+
* `hx-swap` modifiers may be used without explicitly specifying the swap mechanism
|
|
9
|
+
* Arrays are now supported in the `client-side-templates` extension
|
|
10
|
+
* XSLT support in the `client-side-templates` extension
|
|
11
|
+
* Support `preventDefault()` in extension event handling
|
|
12
|
+
* Allow the `HX-Refresh` header to apply even after an `HX-Redirect` has occurred
|
|
13
|
+
* the `formaction` and `formmethod` attributes on buttons are now properly respected
|
|
14
|
+
* `hx-on` can now handle events with dots in their name
|
|
15
|
+
* `htmx.ajax()` now always returns a Promise
|
|
16
|
+
* Handle leading `style` tag parsing more effectively
|
|
17
|
+
|
|
18
|
+
## [1.9.5] - 2023-08-25
|
|
19
|
+
|
|
20
|
+
* Web sockets now properly pass the target id in the HEADERS struct
|
|
21
|
+
* A very rare loading state bug was fixed (see https://github.com/bigskysoftware/htmx/commit/93bd81b6d003bb7bc445f10192bdb8089fa3495d)
|
|
22
|
+
* `hx-on` will not evaluate if `allowEval` is set to false
|
|
23
|
+
* You can disable the interpretation of script tags with the new `htmx.config.allowScriptTags` config variable
|
|
24
|
+
* You can now disable htmx-based requests to non-origin hosts via the `htmx.config.selfRequestsOnly` config variable
|
|
25
|
+
* The [Security](https://htmx.org/docs#security) section has been expanded to help developers better understand how to
|
|
26
|
+
properly secure their htmx-based applications.
|
|
27
|
+
|
|
3
28
|
## [1.9.4] - 2023-07-25
|
|
4
29
|
|
|
5
30
|
* This is a bug-fix release for the most part, w/a heavy dose of @telroshan
|
|
@@ -13,7 +38,7 @@
|
|
|
13
38
|
|
|
14
39
|
## [1.9.3] - 2023-07-14
|
|
15
40
|
|
|
16
|
-
* The `hx-on` attribute has been deprecated (sorry) in favor of `hx-on
|
|
41
|
+
* The `hx-on` attribute has been deprecated (sorry) in favor of `hx-on:<event name>` attributes. See [`hx-on`](/attributes/hx-on) for more information.
|
|
17
42
|
* We now have functioning CI using GitHub actions!
|
|
18
43
|
* You can now configure if a type of HTTP request uses the body for parameters or not. In particular, the `DELETE` _should_ use
|
|
19
44
|
query parameters, according to the spec. htmx has used the body, instead. To avoid breaking code we are keeping this undefined
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ By removing these arbitrary constraints htmx completes HTML as a
|
|
|
33
33
|
## quick start
|
|
34
34
|
|
|
35
35
|
```html
|
|
36
|
-
<script src="https://unpkg.com/htmx.org@1.9.
|
|
36
|
+
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
|
|
37
37
|
<!-- have a button POST a click via AJAX -->
|
|
38
38
|
<button hx-post="/clicked" hx-swap="outerHTML">
|
|
39
39
|
Click Me
|
|
@@ -62,15 +62,9 @@ Note there is an old broken package called `htmx`. This is `htmx.org`.
|
|
|
62
62
|
* <https://htmx.org/docs>
|
|
63
63
|
|
|
64
64
|
## contributing
|
|
65
|
+
Want to contribute? Check out our [contribution guidelines](CONTRIBUTING.md)
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
* Please write code, including tests, in ES5 for [IE 11 compatibility](https://stackoverflow.com/questions/39902809/support-for-es6-in-internet-explorer-11)
|
|
68
|
-
* Please include test cases in [`/test`](https://github.com/bigskysoftware/htmx/tree/dev/test) and docs in [`/www`](https://github.com/bigskysoftware/htmx/tree/dev/www)
|
|
69
|
-
* Search the issues before proposing a feature to see if it is already under discussion
|
|
70
|
-
* If you are adding a feature, consider doing it as an [extension](https://htmx.org/extensions) instead to keep the core htmx code tidy
|
|
71
|
-
* Want to contribute but don't know where to start? Look for issues with the "help wanted" tag
|
|
72
|
-
* Refactors that do not make functional changes will be automatically closed, unless explicitly solicited (documentation typo fixes are fine)
|
|
73
|
-
* No time? Then [become a sponsor](https://github.com/sponsors/bigskysoftware#sponsors)
|
|
67
|
+
No time? Then [become a sponsor](https://github.com/sponsors/bigskysoftware#sponsors)
|
|
74
68
|
|
|
75
69
|
### hacking guide
|
|
76
70
|
|
|
@@ -13,6 +13,18 @@ htmx.defineExtension('client-side-templates', {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
var mustacheArrayTemplate = htmx.closest(elt, "[mustache-array-template]");
|
|
17
|
+
if (mustacheArrayTemplate) {
|
|
18
|
+
var data = JSON.parse(text);
|
|
19
|
+
var templateId = mustacheArrayTemplate.getAttribute('mustache-array-template');
|
|
20
|
+
var template = htmx.find("#" + templateId);
|
|
21
|
+
if (template) {
|
|
22
|
+
return Mustache.render(template.innerHTML, {"data": data });
|
|
23
|
+
} else {
|
|
24
|
+
throw "Unknown mustache template: " + templateId;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
var handlebarsTemplate = htmx.closest(elt, "[handlebars-template]");
|
|
17
29
|
if (handlebarsTemplate) {
|
|
18
30
|
var data = JSON.parse(text);
|
|
@@ -20,6 +32,13 @@ htmx.defineExtension('client-side-templates', {
|
|
|
20
32
|
return Handlebars.partials[templateName](data);
|
|
21
33
|
}
|
|
22
34
|
|
|
35
|
+
var handlebarsArrayTemplate = htmx.closest(elt, "[handlebars-array-template]");
|
|
36
|
+
if (handlebarsArrayTemplate) {
|
|
37
|
+
var data = JSON.parse(text);
|
|
38
|
+
var templateName = handlebarsArrayTemplate.getAttribute('handlebars-array-template');
|
|
39
|
+
return Handlebars.partials[templateName]({"data": data});
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
var nunjucksTemplate = htmx.closest(elt, "[nunjucks-template]");
|
|
24
43
|
if (nunjucksTemplate) {
|
|
25
44
|
var data = JSON.parse(text);
|
|
@@ -30,8 +49,36 @@ htmx.defineExtension('client-side-templates', {
|
|
|
30
49
|
} else {
|
|
31
50
|
return nunjucks.render(templateName, data);
|
|
32
51
|
}
|
|
33
|
-
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var xsltTemplate = htmx.closest(elt, "[xslt-template]");
|
|
55
|
+
if (xsltTemplate) {
|
|
56
|
+
var templateId = xsltTemplate.getAttribute('xslt-template');
|
|
57
|
+
var template = htmx.find("#" + templateId);
|
|
58
|
+
if (template) {
|
|
59
|
+
var content = template.innerHTML ? new DOMParser().parseFromString(template.innerHTML, 'application/xml')
|
|
60
|
+
: template.contentDocument;
|
|
61
|
+
var processor = new XSLTProcessor();
|
|
62
|
+
processor.importStylesheet(content);
|
|
63
|
+
var data = new DOMParser().parseFromString(text, "application/xml");
|
|
64
|
+
var frag = processor.transformToFragment(data, document);
|
|
65
|
+
return new XMLSerializer().serializeToString(frag);
|
|
66
|
+
} else {
|
|
67
|
+
throw "Unknown XSLT template: " + templateId;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
34
70
|
|
|
71
|
+
var nunjucksArrayTemplate = htmx.closest(elt, "[nunjucks-array-template]");
|
|
72
|
+
if (nunjucksArrayTemplate) {
|
|
73
|
+
var data = JSON.parse(text);
|
|
74
|
+
var templateName = nunjucksArrayTemplate.getAttribute('nunjucks-array-template');
|
|
75
|
+
var template = htmx.find('#' + templateName);
|
|
76
|
+
if (template) {
|
|
77
|
+
return nunjucks.renderString(template.innerHTML, {"data": data});
|
|
78
|
+
} else {
|
|
79
|
+
return nunjucks.render(templateName, {"data": data});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
35
82
|
return text;
|
|
36
83
|
}
|
|
37
84
|
});
|
|
@@ -5,12 +5,14 @@ htmx.defineExtension('disable-element', {
|
|
|
5
5
|
onEvent: function (name, evt) {
|
|
6
6
|
let elt = evt.detail.elt;
|
|
7
7
|
let target = elt.getAttribute("hx-disable-element");
|
|
8
|
-
let
|
|
8
|
+
let targetElements = (target == "self") ? [ elt ] : document.querySelectorAll(target);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
for (var i = 0; i < targetElements.length; i++) {
|
|
11
|
+
if (name === "htmx:beforeRequest" && targetElements[i]) {
|
|
12
|
+
targetElements[i].disabled = true;
|
|
13
|
+
} else if (name == "htmx:afterRequest" && targetElements[i]) {
|
|
14
|
+
targetElements[i].disabled = false;
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
});
|
|
@@ -25,28 +25,28 @@
|
|
|
25
25
|
if (delayElt) {
|
|
26
26
|
const delayInMilliseconds =
|
|
27
27
|
delayElt.getAttribute('data-loading-delay') || 200
|
|
28
|
-
const timeout = setTimeout(()
|
|
28
|
+
const timeout = setTimeout(function () {
|
|
29
29
|
doCallback()
|
|
30
30
|
|
|
31
|
-
loadingStatesUndoQueue.push(()
|
|
32
|
-
mayProcessUndoCallback(targetElt,
|
|
31
|
+
loadingStatesUndoQueue.push(function () {
|
|
32
|
+
mayProcessUndoCallback(targetElt, undoCallback)
|
|
33
33
|
})
|
|
34
34
|
}, delayInMilliseconds)
|
|
35
35
|
|
|
36
|
-
loadingStatesUndoQueue.push(()
|
|
37
|
-
mayProcessUndoCallback(targetElt, ()
|
|
36
|
+
loadingStatesUndoQueue.push(function () {
|
|
37
|
+
mayProcessUndoCallback(targetElt, function () { clearTimeout(timeout) })
|
|
38
38
|
})
|
|
39
39
|
} else {
|
|
40
40
|
doCallback()
|
|
41
|
-
loadingStatesUndoQueue.push(()
|
|
42
|
-
mayProcessUndoCallback(targetElt,
|
|
41
|
+
loadingStatesUndoQueue.push(function () {
|
|
42
|
+
mayProcessUndoCallback(targetElt, undoCallback)
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function getLoadingStateElts(loadingScope, type, path) {
|
|
48
|
-
return Array.from(htmx.findAll(loadingScope,
|
|
49
|
-
(elt)
|
|
48
|
+
return Array.from(htmx.findAll(loadingScope, "[" + type + "]")).filter(
|
|
49
|
+
function (elt) { return mayProcessLoadingStateByPath(elt, path) }
|
|
50
50
|
)
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
|
|
75
75
|
let loadingStateEltsByType = {}
|
|
76
76
|
|
|
77
|
-
loadingStateTypes.forEach((type)
|
|
77
|
+
loadingStateTypes.forEach(function (type) {
|
|
78
78
|
loadingStateEltsByType[type] = getLoadingStateElts(
|
|
79
79
|
container,
|
|
80
80
|
type,
|
|
@@ -82,87 +82,91 @@
|
|
|
82
82
|
)
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
loadingStateEltsByType['data-loading'].forEach((sourceElt)
|
|
86
|
-
getLoadingTarget(sourceElt).forEach((targetElt)
|
|
85
|
+
loadingStateEltsByType['data-loading'].forEach(function (sourceElt) {
|
|
86
|
+
getLoadingTarget(sourceElt).forEach(function (targetElt) {
|
|
87
87
|
queueLoadingState(
|
|
88
88
|
sourceElt,
|
|
89
89
|
targetElt,
|
|
90
|
-
()
|
|
91
|
-
|
|
90
|
+
function () {
|
|
91
|
+
targetElt.style.display =
|
|
92
92
|
sourceElt.getAttribute('data-loading') ||
|
|
93
|
-
'inline-block'
|
|
94
|
-
()
|
|
93
|
+
'inline-block' },
|
|
94
|
+
function () { targetElt.style.display = 'none' }
|
|
95
95
|
)
|
|
96
96
|
})
|
|
97
97
|
})
|
|
98
98
|
|
|
99
99
|
loadingStateEltsByType['data-loading-class'].forEach(
|
|
100
|
-
(sourceElt)
|
|
100
|
+
function (sourceElt) {
|
|
101
101
|
const classNames = sourceElt
|
|
102
102
|
.getAttribute('data-loading-class')
|
|
103
103
|
.split(' ')
|
|
104
104
|
|
|
105
|
-
getLoadingTarget(sourceElt).forEach((targetElt)
|
|
105
|
+
getLoadingTarget(sourceElt).forEach(function (targetElt) {
|
|
106
106
|
queueLoadingState(
|
|
107
107
|
sourceElt,
|
|
108
108
|
targetElt,
|
|
109
|
-
()
|
|
110
|
-
classNames.forEach((className)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
function () {
|
|
110
|
+
classNames.forEach(function (className) {
|
|
111
|
+
targetElt.classList.add(className)
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
function() {
|
|
115
|
+
classNames.forEach(function (className) {
|
|
116
|
+
targetElt.classList.remove(className)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
117
119
|
)
|
|
118
120
|
})
|
|
119
121
|
}
|
|
120
122
|
)
|
|
121
123
|
|
|
122
124
|
loadingStateEltsByType['data-loading-class-remove'].forEach(
|
|
123
|
-
(sourceElt)
|
|
125
|
+
function (sourceElt) {
|
|
124
126
|
const classNames = sourceElt
|
|
125
127
|
.getAttribute('data-loading-class-remove')
|
|
126
128
|
.split(' ')
|
|
127
129
|
|
|
128
|
-
getLoadingTarget(sourceElt).forEach((targetElt)
|
|
130
|
+
getLoadingTarget(sourceElt).forEach(function (targetElt) {
|
|
129
131
|
queueLoadingState(
|
|
130
132
|
sourceElt,
|
|
131
133
|
targetElt,
|
|
132
|
-
()
|
|
133
|
-
classNames.forEach((className)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
function () {
|
|
135
|
+
classNames.forEach(function (className) {
|
|
136
|
+
targetElt.classList.remove(className)
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
function() {
|
|
140
|
+
classNames.forEach(function (className) {
|
|
141
|
+
targetElt.classList.add(className)
|
|
142
|
+
})
|
|
143
|
+
}
|
|
140
144
|
)
|
|
141
145
|
})
|
|
142
146
|
}
|
|
143
147
|
)
|
|
144
148
|
|
|
145
149
|
loadingStateEltsByType['data-loading-disable'].forEach(
|
|
146
|
-
(sourceElt)
|
|
147
|
-
getLoadingTarget(sourceElt).forEach((targetElt)
|
|
150
|
+
function (sourceElt) {
|
|
151
|
+
getLoadingTarget(sourceElt).forEach(function (targetElt) {
|
|
148
152
|
queueLoadingState(
|
|
149
153
|
sourceElt,
|
|
150
154
|
targetElt,
|
|
151
|
-
()
|
|
152
|
-
|
|
155
|
+
function() { targetElt.disabled = true },
|
|
156
|
+
function() { targetElt.disabled = false }
|
|
153
157
|
)
|
|
154
158
|
})
|
|
155
159
|
}
|
|
156
160
|
)
|
|
157
161
|
|
|
158
162
|
loadingStateEltsByType['data-loading-aria-busy'].forEach(
|
|
159
|
-
(sourceElt)
|
|
160
|
-
getLoadingTarget(sourceElt).forEach((targetElt)
|
|
163
|
+
function (sourceElt) {
|
|
164
|
+
getLoadingTarget(sourceElt).forEach(function (targetElt) {
|
|
161
165
|
queueLoadingState(
|
|
162
166
|
sourceElt,
|
|
163
167
|
targetElt,
|
|
164
|
-
()
|
|
165
|
-
()
|
|
168
|
+
function () { targetElt.setAttribute("aria-busy", "true") },
|
|
169
|
+
function () { targetElt.removeAttribute("aria-busy") }
|
|
166
170
|
)
|
|
167
171
|
})
|
|
168
172
|
}
|
|
@@ -5,7 +5,8 @@ htmx.defineExtension('morphdom-swap', {
|
|
|
5
5
|
handleSwap: function (swapStyle, target, fragment) {
|
|
6
6
|
if (swapStyle === 'morphdom') {
|
|
7
7
|
if (fragment.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
8
|
-
|
|
8
|
+
// IE11 doesn't support DocumentFragment.firstElementChild
|
|
9
|
+
morphdom(target, fragment.firstElementChild || fragment.firstChild);
|
|
9
10
|
return [target];
|
|
10
11
|
} else {
|
|
11
12
|
morphdom(target, fragment.outerHTML);
|
|
@@ -3,43 +3,55 @@
|
|
|
3
3
|
/** @type {import("../htmx").HtmxInternalApi} */
|
|
4
4
|
var api;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const targetAttrMinLen = targetAttrPrefix.length - 1;
|
|
6
|
+
var attrPrefix = 'hx-target-';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @param {HTMLElement} elt
|
|
11
10
|
* @param {number} respCode
|
|
12
11
|
* @returns {HTMLElement | null}
|
|
13
12
|
*/
|
|
14
|
-
function getRespCodeTarget(elt,
|
|
15
|
-
if (!elt || !
|
|
13
|
+
function getRespCodeTarget(elt, respCodeNumber) {
|
|
14
|
+
if (!elt || !respCodeNumber) return null;
|
|
16
15
|
|
|
17
|
-
var
|
|
18
|
-
var targetStr = api.getClosestAttributeValue(elt, targetAttr);
|
|
16
|
+
var respCode = respCodeNumber.toString();
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
18
|
+
// '*' is the original syntax, as the obvious character for a wildcard.
|
|
19
|
+
// The 'x' alternative was added for maximum compatibility with HTML
|
|
20
|
+
// templating engines, due to ambiguity around which characters are
|
|
21
|
+
// supported in HTML attributes.
|
|
22
|
+
//
|
|
23
|
+
// Start with the most specific possible attribute and generalize from
|
|
24
|
+
// there.
|
|
25
|
+
var attrPossibilities = [
|
|
26
|
+
respCode,
|
|
27
|
+
|
|
28
|
+
respCode.substr(0, 2) + '*',
|
|
29
|
+
respCode.substr(0, 2) + 'x',
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
respCode.substr(0, 1) + '*',
|
|
32
|
+
respCode.substr(0, 1) + 'x',
|
|
33
|
+
respCode.substr(0, 1) + '**',
|
|
34
|
+
respCode.substr(0, 1) + 'xx',
|
|
35
|
+
|
|
36
|
+
'*',
|
|
37
|
+
'x',
|
|
38
|
+
'***',
|
|
39
|
+
'xxx',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
for (var i = 0; i < attrPossibilities.length; i++) {
|
|
43
|
+
var attr = attrPrefix + attrPossibilities[i];
|
|
44
|
+
var attrValue = api.getClosestAttributeValue(elt, attr);
|
|
45
|
+
if (attrValue) {
|
|
46
|
+
if (attrValue === "this") {
|
|
47
|
+
return api.findThisElement(elt, attr);
|
|
48
|
+
} else {
|
|
49
|
+
return api.querySelectorExt(elt, attrValue);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
|
-
} else {
|
|
41
|
-
return null;
|
|
42
52
|
}
|
|
53
|
+
|
|
54
|
+
return null;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
/** @param {Event} evt */
|
package/dist/ext/ws.js
CHANGED
|
@@ -341,7 +341,7 @@ This extension adds support for WebSockets to htmx. See /www/extensions/ws.md f
|
|
|
341
341
|
|
|
342
342
|
/** @type {WebSocketWrapper} */
|
|
343
343
|
var socketWrapper = api.getInternalData(socketElt).webSocket;
|
|
344
|
-
var headers = api.getHeaders(sendElt,
|
|
344
|
+
var headers = api.getHeaders(sendElt, api.getTarget(sendElt));
|
|
345
345
|
var results = api.getInputValues(sendElt, 'post');
|
|
346
346
|
var errors = results.errors;
|
|
347
347
|
var rawParameters = results.values;
|
package/dist/htmx.d.ts
CHANGED
|
@@ -19,8 +19,9 @@ export function addClass(elt: Element, clazz: string, delay?: number): void;
|
|
|
19
19
|
* @param verb 'GET', 'POST', etc.
|
|
20
20
|
* @param path the URL path to make the AJAX
|
|
21
21
|
* @param element the element to target (defaults to the **body**)
|
|
22
|
+
* @returns Promise that resolves immediately if no request is sent, or when the request is complete
|
|
22
23
|
*/
|
|
23
|
-
export function ajax(verb: string, path: string, element: Element): void
|
|
24
|
+
export function ajax(verb: string, path: string, element: Element): Promise<void>;
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Issues an htmx-style AJAX request
|
|
@@ -30,8 +31,9 @@ export function ajax(verb: string, path: string, element: Element): void;
|
|
|
30
31
|
* @param verb 'GET', 'POST', etc.
|
|
31
32
|
* @param path the URL path to make the AJAX
|
|
32
33
|
* @param selector a selector for the target
|
|
34
|
+
* @returns Promise that resolves immediately if no request is sent, or when the request is complete
|
|
33
35
|
*/
|
|
34
|
-
export function ajax(verb: string, path: string, selector: string): void
|
|
36
|
+
export function ajax(verb: string, path: string, selector: string): Promise<void>;
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* Issues an htmx-style AJAX request
|
|
@@ -41,12 +43,13 @@ export function ajax(verb: string, path: string, selector: string): void;
|
|
|
41
43
|
* @param verb 'GET', 'POST', etc.
|
|
42
44
|
* @param path the URL path to make the AJAX
|
|
43
45
|
* @param context a context object that contains any of the following
|
|
46
|
+
* @returns Promise that resolves immediately if no request is sent, or when the request is complete
|
|
44
47
|
*/
|
|
45
48
|
export function ajax(
|
|
46
49
|
verb: string,
|
|
47
50
|
path: string,
|
|
48
51
|
context: Partial<{ source: any; event: any; handler: any; target: any; swap: any; values: any; headers: any }>
|
|
49
|
-
): void
|
|
52
|
+
): Promise<void>;
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
55
|
* Finds the closest matching element in the given elements parentage, inclusive of the element
|
|
@@ -288,44 +291,99 @@ export function values(elt: Element, requestType?: string): any;
|
|
|
288
291
|
export const version: string;
|
|
289
292
|
|
|
290
293
|
export interface HtmxConfig {
|
|
291
|
-
/**
|
|
294
|
+
/**
|
|
295
|
+
* The attributes to settle during the settling phase.
|
|
296
|
+
* @default ["class", "style", "width", "height"]
|
|
297
|
+
*/
|
|
292
298
|
attributesToSettle?: ["class", "style", "width", "height"] | string[];
|
|
293
|
-
/**
|
|
299
|
+
/**
|
|
300
|
+
* If the focused element should be scrolled into view.
|
|
301
|
+
* @default false
|
|
302
|
+
*/
|
|
294
303
|
defaultFocusScroll?: boolean;
|
|
295
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* The default delay between completing the content swap and settling attributes.
|
|
306
|
+
* @default 20
|
|
307
|
+
*/
|
|
296
308
|
defaultSettleDelay?: number;
|
|
297
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* The default delay between receiving a response from the server and doing the swap.
|
|
311
|
+
* @default 0
|
|
312
|
+
*/
|
|
298
313
|
defaultSwapDelay?: number;
|
|
299
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* The default swap style to use if **[hx-swap](https://htmx.org/attributes/hx-swap)** is omitted.
|
|
316
|
+
* @default "innerHTML"
|
|
317
|
+
*/
|
|
300
318
|
defaultSwapStyle?: "innerHTML" | string;
|
|
301
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* The number of pages to keep in **localStorage** for history support.
|
|
321
|
+
* @default 10
|
|
322
|
+
*/
|
|
302
323
|
historyCacheSize?: number;
|
|
303
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* Whether or not to use history.
|
|
326
|
+
* @default true
|
|
327
|
+
*/
|
|
304
328
|
historyEnabled?: boolean;
|
|
305
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* If true, htmx will inject a small amount of CSS into the page to make indicators invisible unless the **htmx-indicator** class is present.
|
|
331
|
+
* @default true
|
|
332
|
+
*/
|
|
306
333
|
includeIndicatorStyles?: boolean;
|
|
307
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* The class to place on indicators when a request is in flight.
|
|
336
|
+
* @default "htmx-indicator"
|
|
337
|
+
*/
|
|
308
338
|
indicatorClass?: "htmx-indicator" | string;
|
|
309
|
-
/**
|
|
339
|
+
/**
|
|
340
|
+
* The class to place on triggering elements when a request is in flight.
|
|
341
|
+
* @default "htmx-request"
|
|
342
|
+
*/
|
|
310
343
|
requestClass?: "htmx-request" | string;
|
|
311
|
-
/**
|
|
344
|
+
/**
|
|
345
|
+
* The class to temporarily place on elements that htmx has added to the DOM.
|
|
346
|
+
* @default "htmx-added"
|
|
347
|
+
*/
|
|
312
348
|
addedClass?: "htmx-added" | string;
|
|
313
|
-
/**
|
|
349
|
+
/**
|
|
350
|
+
* The class to place on target elements when htmx is in the settling phase.
|
|
351
|
+
* @default "htmx-settling"
|
|
352
|
+
*/
|
|
314
353
|
settlingClass?: "htmx-settling" | string;
|
|
315
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* The class to place on target elements when htmx is in the swapping phase.
|
|
356
|
+
* @default "htmx-swapping"
|
|
357
|
+
*/
|
|
316
358
|
swappingClass?: "htmx-swapping" | string;
|
|
317
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* Allows the use of eval-like functionality in htmx, to enable **hx-vars**, trigger conditions & script tag evaluation. Can be set to **false** for CSP compatibility.
|
|
361
|
+
* @default true
|
|
362
|
+
*/
|
|
318
363
|
allowEval?: boolean;
|
|
319
|
-
/**
|
|
364
|
+
/**
|
|
365
|
+
* Use HTML template tags for parsing content from the server. This allows you to use Out of Band content when returning things like table rows, but it is *not* IE11 compatible.
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
320
368
|
useTemplateFragments?: boolean;
|
|
321
|
-
/**
|
|
369
|
+
/**
|
|
370
|
+
* Allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates.
|
|
371
|
+
* @default false
|
|
372
|
+
*/
|
|
322
373
|
withCredentials?: boolean;
|
|
323
|
-
/**
|
|
374
|
+
/**
|
|
375
|
+
* The default implementation of **getWebSocketReconnectDelay** for reconnecting after unexpected connection loss by the event code **Abnormal Closure**, **Service Restart** or **Try Again Later**.
|
|
376
|
+
* @default "full-jitter"
|
|
377
|
+
*/
|
|
324
378
|
wsReconnectDelay?: "full-jitter" | string | ((retryCount: number) => number);
|
|
325
379
|
// following don't appear in the docs
|
|
380
|
+
/** @default false */
|
|
326
381
|
refreshOnHistoryMiss?: boolean;
|
|
382
|
+
/** @default 0 */
|
|
327
383
|
timeout?: number;
|
|
384
|
+
/** @default "[hx-disable], [data-hx-disable]" */
|
|
328
385
|
disableSelector?: "[hx-disable], [data-hx-disable]" | string;
|
|
386
|
+
/** @default "smooth" */
|
|
329
387
|
scrollBehavior?: "smooth" | "auto";
|
|
330
388
|
}
|
|
331
389
|
|