htmx.org 2.0.0 → 2.0.2
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 +3 -4
- package/dist/ext/README.md +9 -0
- package/dist/ext/ajax-header.js +11 -0
- package/dist/ext/alpine-morph.js +20 -0
- package/dist/ext/class-tools.js +97 -0
- package/dist/ext/client-side-templates.js +100 -0
- package/dist/ext/debug.js +15 -0
- package/dist/ext/disable-element.js +20 -0
- package/dist/ext/event-header.js +41 -0
- package/dist/ext/head-support.js +146 -0
- package/dist/ext/include-vals.js +28 -0
- package/dist/ext/json-enc.js +16 -0
- package/dist/ext/loading-states.js +189 -0
- package/dist/ext/method-override.js +15 -0
- package/dist/ext/morphdom-swap.js +21 -0
- package/dist/ext/multi-swap.js +50 -0
- package/dist/ext/path-deps.js +63 -0
- package/dist/ext/path-params.js +15 -0
- package/dist/ext/preload.js +151 -0
- package/dist/ext/rails-method.js +14 -0
- package/dist/ext/remove-me.js +31 -0
- package/dist/ext/response-targets.js +135 -0
- package/dist/ext/restored.js +19 -0
- package/dist/ext/sse.js +374 -0
- package/dist/ext/ws.js +481 -0
- package/dist/htmx.amd.js +47 -22
- package/dist/htmx.cjs.js +47 -22
- package/dist/htmx.esm.d.ts +205 -0
- package/dist/htmx.esm.js +47 -22
- package/dist/htmx.js +47 -22
- package/dist/htmx.min.js +1 -1
- package/dist/htmx.min.js.gz +0 -0
- package/editors/jetbrains/htmx.web-types.json +1 -1
- package/package.json +11 -8
- package/CHANGELOG.md +0 -485
package/dist/htmx.esm.js
CHANGED
|
@@ -206,7 +206,7 @@ var htmx = (function() {
|
|
|
206
206
|
disableSelector: '[hx-disable], [data-hx-disable]',
|
|
207
207
|
/**
|
|
208
208
|
* @type {'auto' | 'instant' | 'smooth'}
|
|
209
|
-
* @default '
|
|
209
|
+
* @default 'instant'
|
|
210
210
|
*/
|
|
211
211
|
scrollBehavior: 'instant',
|
|
212
212
|
/**
|
|
@@ -277,7 +277,7 @@ var htmx = (function() {
|
|
|
277
277
|
parseInterval: null,
|
|
278
278
|
/** @type {typeof internalEval} */
|
|
279
279
|
_: null,
|
|
280
|
-
version: '2.0.
|
|
280
|
+
version: '2.0.2'
|
|
281
281
|
}
|
|
282
282
|
// Tsc madness part 2
|
|
283
283
|
htmx.onLoad = onLoadHelper
|
|
@@ -1626,6 +1626,9 @@ var htmx = (function() {
|
|
|
1626
1626
|
* @param {HtmxSettleInfo} settleInfo
|
|
1627
1627
|
*/
|
|
1628
1628
|
function swapOuterHTML(target, fragment, settleInfo) {
|
|
1629
|
+
if (target instanceof Element && target.tagName === 'BODY') { // special case the body to innerHTML because DocumentFragments can't contain a body elt unfortunately
|
|
1630
|
+
return swapInnerHTML(target, fragment, settleInfo)
|
|
1631
|
+
}
|
|
1629
1632
|
/** @type {Node} */
|
|
1630
1633
|
let newElt
|
|
1631
1634
|
const eltBeforeNewContent = target.previousSibling
|
|
@@ -1636,13 +1639,13 @@ var htmx = (function() {
|
|
|
1636
1639
|
newElt = eltBeforeNewContent.nextSibling
|
|
1637
1640
|
}
|
|
1638
1641
|
settleInfo.elts = settleInfo.elts.filter(function(e) { return e !== target })
|
|
1642
|
+
// scan through all newly added content and add all elements to the settle info so we trigger
|
|
1643
|
+
// events properly on them
|
|
1639
1644
|
while (newElt && newElt !== target) {
|
|
1640
1645
|
if (newElt instanceof Element) {
|
|
1641
1646
|
settleInfo.elts.push(newElt)
|
|
1642
|
-
newElt = newElt.nextElementSibling
|
|
1643
|
-
} else {
|
|
1644
|
-
newElt = null
|
|
1645
1647
|
}
|
|
1648
|
+
newElt = newElt.nextSibling
|
|
1646
1649
|
}
|
|
1647
1650
|
cleanUpElement(target)
|
|
1648
1651
|
if (target instanceof Element) {
|
|
@@ -1750,7 +1753,7 @@ var htmx = (function() {
|
|
|
1750
1753
|
try {
|
|
1751
1754
|
const newElements = ext.handleSwap(swapStyle, target, fragment, settleInfo)
|
|
1752
1755
|
if (newElements) {
|
|
1753
|
-
if (
|
|
1756
|
+
if (Array.isArray(newElements)) {
|
|
1754
1757
|
// if handleSwap returns an array (like) of elements, we handle them
|
|
1755
1758
|
for (let j = 0; j < newElements.length; j++) {
|
|
1756
1759
|
const child = newElements[j]
|
|
@@ -1778,7 +1781,8 @@ var htmx = (function() {
|
|
|
1778
1781
|
* @param {HtmxSettleInfo} settleInfo
|
|
1779
1782
|
*/
|
|
1780
1783
|
function findAndSwapOobElements(fragment, settleInfo) {
|
|
1781
|
-
|
|
1784
|
+
var oobElts = findAll(fragment, '[hx-swap-oob], [data-hx-swap-oob]')
|
|
1785
|
+
forEach(oobElts, function(oobElement) {
|
|
1782
1786
|
if (htmx.config.allowNestedOobSwaps || oobElement.parentElement === null) {
|
|
1783
1787
|
const oobValue = getAttributeValue(oobElement, 'hx-swap-oob')
|
|
1784
1788
|
if (oobValue != null) {
|
|
@@ -1789,6 +1793,7 @@ var htmx = (function() {
|
|
|
1789
1793
|
oobElement.removeAttribute('data-hx-swap-oob')
|
|
1790
1794
|
}
|
|
1791
1795
|
})
|
|
1796
|
+
return oobElts.length > 0
|
|
1792
1797
|
}
|
|
1793
1798
|
|
|
1794
1799
|
/**
|
|
@@ -1850,9 +1855,8 @@ var htmx = (function() {
|
|
|
1850
1855
|
// oob swaps
|
|
1851
1856
|
findAndSwapOobElements(fragment, settleInfo)
|
|
1852
1857
|
forEach(findAll(fragment, 'template'), /** @param {HTMLTemplateElement} template */function(template) {
|
|
1853
|
-
findAndSwapOobElements(template.content, settleInfo)
|
|
1854
|
-
|
|
1855
|
-
// Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap
|
|
1858
|
+
if (findAndSwapOobElements(template.content, settleInfo)) {
|
|
1859
|
+
// Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap
|
|
1856
1860
|
template.remove()
|
|
1857
1861
|
}
|
|
1858
1862
|
})
|
|
@@ -1949,7 +1953,10 @@ var htmx = (function() {
|
|
|
1949
1953
|
for (const eventName in triggers) {
|
|
1950
1954
|
if (triggers.hasOwnProperty(eventName)) {
|
|
1951
1955
|
let detail = triggers[eventName]
|
|
1952
|
-
if (
|
|
1956
|
+
if (isRawObject(detail)) {
|
|
1957
|
+
// @ts-ignore
|
|
1958
|
+
elt = detail.target !== undefined ? detail.target : elt
|
|
1959
|
+
} else {
|
|
1953
1960
|
detail = { value: detail }
|
|
1954
1961
|
}
|
|
1955
1962
|
triggerEvent(elt, eventName, detail)
|
|
@@ -2270,7 +2277,7 @@ var htmx = (function() {
|
|
|
2270
2277
|
* @param {HtmxTriggerSpecification[]} triggerSpecs
|
|
2271
2278
|
*/
|
|
2272
2279
|
function boostElement(elt, nodeData, triggerSpecs) {
|
|
2273
|
-
if ((elt instanceof HTMLAnchorElement && isLocalLink(elt) && (elt.target === '' || elt.target === '_self')) || elt.tagName === 'FORM') {
|
|
2280
|
+
if ((elt instanceof HTMLAnchorElement && isLocalLink(elt) && (elt.target === '' || elt.target === '_self')) || (elt.tagName === 'FORM' && String(getRawAttribute(elt, 'method')).toLowerCase() !== 'dialog')) {
|
|
2274
2281
|
nodeData.boosted = true
|
|
2275
2282
|
let verb, path
|
|
2276
2283
|
if (elt.tagName === 'A') {
|
|
@@ -2432,13 +2439,17 @@ var htmx = (function() {
|
|
|
2432
2439
|
|
|
2433
2440
|
if (triggerSpec.throttle > 0) {
|
|
2434
2441
|
if (!elementData.throttle) {
|
|
2442
|
+
triggerEvent(elt, 'htmx:trigger')
|
|
2435
2443
|
handler(elt, evt)
|
|
2436
2444
|
elementData.throttle = getWindow().setTimeout(function() {
|
|
2437
2445
|
elementData.throttle = null
|
|
2438
2446
|
}, triggerSpec.throttle)
|
|
2439
2447
|
}
|
|
2440
2448
|
} else if (triggerSpec.delay > 0) {
|
|
2441
|
-
elementData.delayed = getWindow().setTimeout(function() {
|
|
2449
|
+
elementData.delayed = getWindow().setTimeout(function() {
|
|
2450
|
+
triggerEvent(elt, 'htmx:trigger')
|
|
2451
|
+
handler(elt, evt)
|
|
2452
|
+
}, triggerSpec.delay)
|
|
2442
2453
|
} else {
|
|
2443
2454
|
triggerEvent(elt, 'htmx:trigger')
|
|
2444
2455
|
handler(elt, evt)
|
|
@@ -3056,6 +3067,10 @@ var htmx = (function() {
|
|
|
3056
3067
|
forEach(findAll(clone, '.' + className), function(child) {
|
|
3057
3068
|
removeClassFromElement(child, className)
|
|
3058
3069
|
})
|
|
3070
|
+
// remove the disabled attribute for any element disabled due to an htmx request
|
|
3071
|
+
forEach(findAll(clone, '[data-disabled-by-htmx]'), function(child) {
|
|
3072
|
+
child.removeAttribute('disabled')
|
|
3073
|
+
})
|
|
3059
3074
|
return clone.innerHTML
|
|
3060
3075
|
}
|
|
3061
3076
|
|
|
@@ -3209,6 +3224,7 @@ var htmx = (function() {
|
|
|
3209
3224
|
const internalData = getInternalData(disabledElement)
|
|
3210
3225
|
internalData.requestCount = (internalData.requestCount || 0) + 1
|
|
3211
3226
|
disabledElement.setAttribute('disabled', '')
|
|
3227
|
+
disabledElement.setAttribute('data-disabled-by-htmx', '')
|
|
3212
3228
|
})
|
|
3213
3229
|
return disabledElts
|
|
3214
3230
|
}
|
|
@@ -3230,6 +3246,7 @@ var htmx = (function() {
|
|
|
3230
3246
|
internalData.requestCount = (internalData.requestCount || 0) - 1
|
|
3231
3247
|
if (internalData.requestCount === 0) {
|
|
3232
3248
|
disabledElement.removeAttribute('disabled')
|
|
3249
|
+
disabledElement.removeAttribute('data-disabled-by-htmx')
|
|
3233
3250
|
}
|
|
3234
3251
|
})
|
|
3235
3252
|
}
|
|
@@ -3379,10 +3396,10 @@ var htmx = (function() {
|
|
|
3379
3396
|
function overrideFormData(receiver, donor) {
|
|
3380
3397
|
for (const key of donor.keys()) {
|
|
3381
3398
|
receiver.delete(key)
|
|
3382
|
-
donor.getAll(key).forEach(function(value) {
|
|
3383
|
-
receiver.append(key, value)
|
|
3384
|
-
})
|
|
3385
3399
|
}
|
|
3400
|
+
donor.forEach(function(value, key) {
|
|
3401
|
+
receiver.append(key, value)
|
|
3402
|
+
})
|
|
3386
3403
|
return receiver
|
|
3387
3404
|
}
|
|
3388
3405
|
|
|
@@ -3912,7 +3929,7 @@ var htmx = (function() {
|
|
|
3912
3929
|
if (obj.hasOwnProperty(key)) {
|
|
3913
3930
|
if (typeof obj[key].forEach === 'function') {
|
|
3914
3931
|
obj[key].forEach(function(v) { formData.append(key, v) })
|
|
3915
|
-
} else if (typeof obj[key] === 'object') {
|
|
3932
|
+
} else if (typeof obj[key] === 'object' && !(obj[key] instanceof Blob)) {
|
|
3916
3933
|
formData.append(key, JSON.stringify(obj[key]))
|
|
3917
3934
|
} else {
|
|
3918
3935
|
formData.append(key, obj[key])
|
|
@@ -4005,6 +4022,8 @@ var htmx = (function() {
|
|
|
4005
4022
|
target.delete(name)
|
|
4006
4023
|
if (typeof value.forEach === 'function') {
|
|
4007
4024
|
value.forEach(function(v) { target.append(name, v) })
|
|
4025
|
+
} else if (typeof value === 'object' && !(value instanceof Blob)) {
|
|
4026
|
+
target.append(name, JSON.stringify(value))
|
|
4008
4027
|
} else {
|
|
4009
4028
|
target.append(name, value)
|
|
4010
4029
|
}
|
|
@@ -4340,7 +4359,9 @@ var htmx = (function() {
|
|
|
4340
4359
|
const hierarchy = hierarchyForElt(elt)
|
|
4341
4360
|
responseInfo.pathInfo.responsePath = getPathFromResponse(xhr)
|
|
4342
4361
|
responseHandler(elt, responseInfo)
|
|
4343
|
-
|
|
4362
|
+
if (responseInfo.keepIndicators !== true) {
|
|
4363
|
+
removeRequestIndicators(indicators, disableElts)
|
|
4364
|
+
}
|
|
4344
4365
|
triggerEvent(elt, 'htmx:afterRequest', responseInfo)
|
|
4345
4366
|
triggerEvent(elt, 'htmx:afterOnLoad', responseInfo)
|
|
4346
4367
|
// if the body no longer contains the element, trigger the event on the closest parent
|
|
@@ -4580,12 +4601,14 @@ var htmx = (function() {
|
|
|
4580
4601
|
const shouldRefresh = hasHeader(xhr, /HX-Refresh:/i) && xhr.getResponseHeader('HX-Refresh') === 'true'
|
|
4581
4602
|
|
|
4582
4603
|
if (hasHeader(xhr, /HX-Redirect:/i)) {
|
|
4604
|
+
responseInfo.keepIndicators = true
|
|
4583
4605
|
location.href = xhr.getResponseHeader('HX-Redirect')
|
|
4584
4606
|
shouldRefresh && location.reload()
|
|
4585
4607
|
return
|
|
4586
4608
|
}
|
|
4587
4609
|
|
|
4588
4610
|
if (shouldRefresh) {
|
|
4611
|
+
responseInfo.keepIndicators = true
|
|
4589
4612
|
location.reload()
|
|
4590
4613
|
return
|
|
4591
4614
|
}
|
|
@@ -5033,7 +5056,7 @@ var htmx = (function() {
|
|
|
5033
5056
|
* @property {Element|string} [source]
|
|
5034
5057
|
* @property {Event} [event]
|
|
5035
5058
|
* @property {HtmxAjaxHandler} [handler]
|
|
5036
|
-
* @property {Element|string} target
|
|
5059
|
+
* @property {Element|string} [target]
|
|
5037
5060
|
* @property {HtmxSwapStyle} [swap]
|
|
5038
5061
|
* @property {Object|FormData} [values]
|
|
5039
5062
|
* @property {Record<string,string>} [headers]
|
|
@@ -5069,6 +5092,7 @@ var htmx = (function() {
|
|
|
5069
5092
|
* @property {{requestPath: string, finalRequestPath: string, responsePath: string|null, anchor: string}} pathInfo
|
|
5070
5093
|
* @property {boolean} [failed]
|
|
5071
5094
|
* @property {boolean} [successful]
|
|
5095
|
+
* @property {boolean} [keepIndicators]
|
|
5072
5096
|
*/
|
|
5073
5097
|
|
|
5074
5098
|
/**
|
|
@@ -5118,13 +5142,14 @@ var htmx = (function() {
|
|
|
5118
5142
|
*/
|
|
5119
5143
|
|
|
5120
5144
|
/**
|
|
5145
|
+
* @see https://github.com/bigskysoftware/htmx-extensions/blob/main/README.md
|
|
5121
5146
|
* @typedef {Object} HtmxExtension
|
|
5122
|
-
* @see https://htmx.org/extensions/#defining
|
|
5123
5147
|
* @property {(api: any) => void} init
|
|
5124
5148
|
* @property {(name: string, event: Event|CustomEvent) => boolean} onEvent
|
|
5125
5149
|
* @property {(text: string, xhr: XMLHttpRequest, elt: Element) => string} transformResponse
|
|
5126
5150
|
* @property {(swapStyle: HtmxSwapStyle) => boolean} isInlineSwap
|
|
5127
|
-
* @property {(swapStyle: HtmxSwapStyle, target:
|
|
5128
|
-
* @property {(xhr: XMLHttpRequest, parameters: FormData, elt:
|
|
5151
|
+
* @property {(swapStyle: HtmxSwapStyle, target: Node, fragment: Node, settleInfo: HtmxSettleInfo) => boolean|Node[]} handleSwap
|
|
5152
|
+
* @property {(xhr: XMLHttpRequest, parameters: FormData, elt: Node) => *|string|null} encodeParameters
|
|
5153
|
+
* @property {() => string[]|null} getSelectors
|
|
5129
5154
|
*/
|
|
5130
5155
|
export default htmx
|
package/dist/htmx.js
CHANGED
|
@@ -206,7 +206,7 @@ var htmx = (function() {
|
|
|
206
206
|
disableSelector: '[hx-disable], [data-hx-disable]',
|
|
207
207
|
/**
|
|
208
208
|
* @type {'auto' | 'instant' | 'smooth'}
|
|
209
|
-
* @default '
|
|
209
|
+
* @default 'instant'
|
|
210
210
|
*/
|
|
211
211
|
scrollBehavior: 'instant',
|
|
212
212
|
/**
|
|
@@ -277,7 +277,7 @@ var htmx = (function() {
|
|
|
277
277
|
parseInterval: null,
|
|
278
278
|
/** @type {typeof internalEval} */
|
|
279
279
|
_: null,
|
|
280
|
-
version: '2.0.
|
|
280
|
+
version: '2.0.2'
|
|
281
281
|
}
|
|
282
282
|
// Tsc madness part 2
|
|
283
283
|
htmx.onLoad = onLoadHelper
|
|
@@ -1626,6 +1626,9 @@ var htmx = (function() {
|
|
|
1626
1626
|
* @param {HtmxSettleInfo} settleInfo
|
|
1627
1627
|
*/
|
|
1628
1628
|
function swapOuterHTML(target, fragment, settleInfo) {
|
|
1629
|
+
if (target instanceof Element && target.tagName === 'BODY') { // special case the body to innerHTML because DocumentFragments can't contain a body elt unfortunately
|
|
1630
|
+
return swapInnerHTML(target, fragment, settleInfo)
|
|
1631
|
+
}
|
|
1629
1632
|
/** @type {Node} */
|
|
1630
1633
|
let newElt
|
|
1631
1634
|
const eltBeforeNewContent = target.previousSibling
|
|
@@ -1636,13 +1639,13 @@ var htmx = (function() {
|
|
|
1636
1639
|
newElt = eltBeforeNewContent.nextSibling
|
|
1637
1640
|
}
|
|
1638
1641
|
settleInfo.elts = settleInfo.elts.filter(function(e) { return e !== target })
|
|
1642
|
+
// scan through all newly added content and add all elements to the settle info so we trigger
|
|
1643
|
+
// events properly on them
|
|
1639
1644
|
while (newElt && newElt !== target) {
|
|
1640
1645
|
if (newElt instanceof Element) {
|
|
1641
1646
|
settleInfo.elts.push(newElt)
|
|
1642
|
-
newElt = newElt.nextElementSibling
|
|
1643
|
-
} else {
|
|
1644
|
-
newElt = null
|
|
1645
1647
|
}
|
|
1648
|
+
newElt = newElt.nextSibling
|
|
1646
1649
|
}
|
|
1647
1650
|
cleanUpElement(target)
|
|
1648
1651
|
if (target instanceof Element) {
|
|
@@ -1750,7 +1753,7 @@ var htmx = (function() {
|
|
|
1750
1753
|
try {
|
|
1751
1754
|
const newElements = ext.handleSwap(swapStyle, target, fragment, settleInfo)
|
|
1752
1755
|
if (newElements) {
|
|
1753
|
-
if (
|
|
1756
|
+
if (Array.isArray(newElements)) {
|
|
1754
1757
|
// if handleSwap returns an array (like) of elements, we handle them
|
|
1755
1758
|
for (let j = 0; j < newElements.length; j++) {
|
|
1756
1759
|
const child = newElements[j]
|
|
@@ -1778,7 +1781,8 @@ var htmx = (function() {
|
|
|
1778
1781
|
* @param {HtmxSettleInfo} settleInfo
|
|
1779
1782
|
*/
|
|
1780
1783
|
function findAndSwapOobElements(fragment, settleInfo) {
|
|
1781
|
-
|
|
1784
|
+
var oobElts = findAll(fragment, '[hx-swap-oob], [data-hx-swap-oob]')
|
|
1785
|
+
forEach(oobElts, function(oobElement) {
|
|
1782
1786
|
if (htmx.config.allowNestedOobSwaps || oobElement.parentElement === null) {
|
|
1783
1787
|
const oobValue = getAttributeValue(oobElement, 'hx-swap-oob')
|
|
1784
1788
|
if (oobValue != null) {
|
|
@@ -1789,6 +1793,7 @@ var htmx = (function() {
|
|
|
1789
1793
|
oobElement.removeAttribute('data-hx-swap-oob')
|
|
1790
1794
|
}
|
|
1791
1795
|
})
|
|
1796
|
+
return oobElts.length > 0
|
|
1792
1797
|
}
|
|
1793
1798
|
|
|
1794
1799
|
/**
|
|
@@ -1850,9 +1855,8 @@ var htmx = (function() {
|
|
|
1850
1855
|
// oob swaps
|
|
1851
1856
|
findAndSwapOobElements(fragment, settleInfo)
|
|
1852
1857
|
forEach(findAll(fragment, 'template'), /** @param {HTMLTemplateElement} template */function(template) {
|
|
1853
|
-
findAndSwapOobElements(template.content, settleInfo)
|
|
1854
|
-
|
|
1855
|
-
// Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap
|
|
1858
|
+
if (findAndSwapOobElements(template.content, settleInfo)) {
|
|
1859
|
+
// Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap
|
|
1856
1860
|
template.remove()
|
|
1857
1861
|
}
|
|
1858
1862
|
})
|
|
@@ -1949,7 +1953,10 @@ var htmx = (function() {
|
|
|
1949
1953
|
for (const eventName in triggers) {
|
|
1950
1954
|
if (triggers.hasOwnProperty(eventName)) {
|
|
1951
1955
|
let detail = triggers[eventName]
|
|
1952
|
-
if (
|
|
1956
|
+
if (isRawObject(detail)) {
|
|
1957
|
+
// @ts-ignore
|
|
1958
|
+
elt = detail.target !== undefined ? detail.target : elt
|
|
1959
|
+
} else {
|
|
1953
1960
|
detail = { value: detail }
|
|
1954
1961
|
}
|
|
1955
1962
|
triggerEvent(elt, eventName, detail)
|
|
@@ -2270,7 +2277,7 @@ var htmx = (function() {
|
|
|
2270
2277
|
* @param {HtmxTriggerSpecification[]} triggerSpecs
|
|
2271
2278
|
*/
|
|
2272
2279
|
function boostElement(elt, nodeData, triggerSpecs) {
|
|
2273
|
-
if ((elt instanceof HTMLAnchorElement && isLocalLink(elt) && (elt.target === '' || elt.target === '_self')) || elt.tagName === 'FORM') {
|
|
2280
|
+
if ((elt instanceof HTMLAnchorElement && isLocalLink(elt) && (elt.target === '' || elt.target === '_self')) || (elt.tagName === 'FORM' && String(getRawAttribute(elt, 'method')).toLowerCase() !== 'dialog')) {
|
|
2274
2281
|
nodeData.boosted = true
|
|
2275
2282
|
let verb, path
|
|
2276
2283
|
if (elt.tagName === 'A') {
|
|
@@ -2432,13 +2439,17 @@ var htmx = (function() {
|
|
|
2432
2439
|
|
|
2433
2440
|
if (triggerSpec.throttle > 0) {
|
|
2434
2441
|
if (!elementData.throttle) {
|
|
2442
|
+
triggerEvent(elt, 'htmx:trigger')
|
|
2435
2443
|
handler(elt, evt)
|
|
2436
2444
|
elementData.throttle = getWindow().setTimeout(function() {
|
|
2437
2445
|
elementData.throttle = null
|
|
2438
2446
|
}, triggerSpec.throttle)
|
|
2439
2447
|
}
|
|
2440
2448
|
} else if (triggerSpec.delay > 0) {
|
|
2441
|
-
elementData.delayed = getWindow().setTimeout(function() {
|
|
2449
|
+
elementData.delayed = getWindow().setTimeout(function() {
|
|
2450
|
+
triggerEvent(elt, 'htmx:trigger')
|
|
2451
|
+
handler(elt, evt)
|
|
2452
|
+
}, triggerSpec.delay)
|
|
2442
2453
|
} else {
|
|
2443
2454
|
triggerEvent(elt, 'htmx:trigger')
|
|
2444
2455
|
handler(elt, evt)
|
|
@@ -3056,6 +3067,10 @@ var htmx = (function() {
|
|
|
3056
3067
|
forEach(findAll(clone, '.' + className), function(child) {
|
|
3057
3068
|
removeClassFromElement(child, className)
|
|
3058
3069
|
})
|
|
3070
|
+
// remove the disabled attribute for any element disabled due to an htmx request
|
|
3071
|
+
forEach(findAll(clone, '[data-disabled-by-htmx]'), function(child) {
|
|
3072
|
+
child.removeAttribute('disabled')
|
|
3073
|
+
})
|
|
3059
3074
|
return clone.innerHTML
|
|
3060
3075
|
}
|
|
3061
3076
|
|
|
@@ -3209,6 +3224,7 @@ var htmx = (function() {
|
|
|
3209
3224
|
const internalData = getInternalData(disabledElement)
|
|
3210
3225
|
internalData.requestCount = (internalData.requestCount || 0) + 1
|
|
3211
3226
|
disabledElement.setAttribute('disabled', '')
|
|
3227
|
+
disabledElement.setAttribute('data-disabled-by-htmx', '')
|
|
3212
3228
|
})
|
|
3213
3229
|
return disabledElts
|
|
3214
3230
|
}
|
|
@@ -3230,6 +3246,7 @@ var htmx = (function() {
|
|
|
3230
3246
|
internalData.requestCount = (internalData.requestCount || 0) - 1
|
|
3231
3247
|
if (internalData.requestCount === 0) {
|
|
3232
3248
|
disabledElement.removeAttribute('disabled')
|
|
3249
|
+
disabledElement.removeAttribute('data-disabled-by-htmx')
|
|
3233
3250
|
}
|
|
3234
3251
|
})
|
|
3235
3252
|
}
|
|
@@ -3379,10 +3396,10 @@ var htmx = (function() {
|
|
|
3379
3396
|
function overrideFormData(receiver, donor) {
|
|
3380
3397
|
for (const key of donor.keys()) {
|
|
3381
3398
|
receiver.delete(key)
|
|
3382
|
-
donor.getAll(key).forEach(function(value) {
|
|
3383
|
-
receiver.append(key, value)
|
|
3384
|
-
})
|
|
3385
3399
|
}
|
|
3400
|
+
donor.forEach(function(value, key) {
|
|
3401
|
+
receiver.append(key, value)
|
|
3402
|
+
})
|
|
3386
3403
|
return receiver
|
|
3387
3404
|
}
|
|
3388
3405
|
|
|
@@ -3912,7 +3929,7 @@ var htmx = (function() {
|
|
|
3912
3929
|
if (obj.hasOwnProperty(key)) {
|
|
3913
3930
|
if (typeof obj[key].forEach === 'function') {
|
|
3914
3931
|
obj[key].forEach(function(v) { formData.append(key, v) })
|
|
3915
|
-
} else if (typeof obj[key] === 'object') {
|
|
3932
|
+
} else if (typeof obj[key] === 'object' && !(obj[key] instanceof Blob)) {
|
|
3916
3933
|
formData.append(key, JSON.stringify(obj[key]))
|
|
3917
3934
|
} else {
|
|
3918
3935
|
formData.append(key, obj[key])
|
|
@@ -4005,6 +4022,8 @@ var htmx = (function() {
|
|
|
4005
4022
|
target.delete(name)
|
|
4006
4023
|
if (typeof value.forEach === 'function') {
|
|
4007
4024
|
value.forEach(function(v) { target.append(name, v) })
|
|
4025
|
+
} else if (typeof value === 'object' && !(value instanceof Blob)) {
|
|
4026
|
+
target.append(name, JSON.stringify(value))
|
|
4008
4027
|
} else {
|
|
4009
4028
|
target.append(name, value)
|
|
4010
4029
|
}
|
|
@@ -4340,7 +4359,9 @@ var htmx = (function() {
|
|
|
4340
4359
|
const hierarchy = hierarchyForElt(elt)
|
|
4341
4360
|
responseInfo.pathInfo.responsePath = getPathFromResponse(xhr)
|
|
4342
4361
|
responseHandler(elt, responseInfo)
|
|
4343
|
-
|
|
4362
|
+
if (responseInfo.keepIndicators !== true) {
|
|
4363
|
+
removeRequestIndicators(indicators, disableElts)
|
|
4364
|
+
}
|
|
4344
4365
|
triggerEvent(elt, 'htmx:afterRequest', responseInfo)
|
|
4345
4366
|
triggerEvent(elt, 'htmx:afterOnLoad', responseInfo)
|
|
4346
4367
|
// if the body no longer contains the element, trigger the event on the closest parent
|
|
@@ -4580,12 +4601,14 @@ var htmx = (function() {
|
|
|
4580
4601
|
const shouldRefresh = hasHeader(xhr, /HX-Refresh:/i) && xhr.getResponseHeader('HX-Refresh') === 'true'
|
|
4581
4602
|
|
|
4582
4603
|
if (hasHeader(xhr, /HX-Redirect:/i)) {
|
|
4604
|
+
responseInfo.keepIndicators = true
|
|
4583
4605
|
location.href = xhr.getResponseHeader('HX-Redirect')
|
|
4584
4606
|
shouldRefresh && location.reload()
|
|
4585
4607
|
return
|
|
4586
4608
|
}
|
|
4587
4609
|
|
|
4588
4610
|
if (shouldRefresh) {
|
|
4611
|
+
responseInfo.keepIndicators = true
|
|
4589
4612
|
location.reload()
|
|
4590
4613
|
return
|
|
4591
4614
|
}
|
|
@@ -5033,7 +5056,7 @@ var htmx = (function() {
|
|
|
5033
5056
|
* @property {Element|string} [source]
|
|
5034
5057
|
* @property {Event} [event]
|
|
5035
5058
|
* @property {HtmxAjaxHandler} [handler]
|
|
5036
|
-
* @property {Element|string} target
|
|
5059
|
+
* @property {Element|string} [target]
|
|
5037
5060
|
* @property {HtmxSwapStyle} [swap]
|
|
5038
5061
|
* @property {Object|FormData} [values]
|
|
5039
5062
|
* @property {Record<string,string>} [headers]
|
|
@@ -5069,6 +5092,7 @@ var htmx = (function() {
|
|
|
5069
5092
|
* @property {{requestPath: string, finalRequestPath: string, responsePath: string|null, anchor: string}} pathInfo
|
|
5070
5093
|
* @property {boolean} [failed]
|
|
5071
5094
|
* @property {boolean} [successful]
|
|
5095
|
+
* @property {boolean} [keepIndicators]
|
|
5072
5096
|
*/
|
|
5073
5097
|
|
|
5074
5098
|
/**
|
|
@@ -5118,12 +5142,13 @@ var htmx = (function() {
|
|
|
5118
5142
|
*/
|
|
5119
5143
|
|
|
5120
5144
|
/**
|
|
5145
|
+
* @see https://github.com/bigskysoftware/htmx-extensions/blob/main/README.md
|
|
5121
5146
|
* @typedef {Object} HtmxExtension
|
|
5122
|
-
* @see https://htmx.org/extensions/#defining
|
|
5123
5147
|
* @property {(api: any) => void} init
|
|
5124
5148
|
* @property {(name: string, event: Event|CustomEvent) => boolean} onEvent
|
|
5125
5149
|
* @property {(text: string, xhr: XMLHttpRequest, elt: Element) => string} transformResponse
|
|
5126
5150
|
* @property {(swapStyle: HtmxSwapStyle) => boolean} isInlineSwap
|
|
5127
|
-
* @property {(swapStyle: HtmxSwapStyle, target:
|
|
5128
|
-
* @property {(xhr: XMLHttpRequest, parameters: FormData, elt:
|
|
5151
|
+
* @property {(swapStyle: HtmxSwapStyle, target: Node, fragment: Node, settleInfo: HtmxSettleInfo) => boolean|Node[]} handleSwap
|
|
5152
|
+
* @property {(xhr: XMLHttpRequest, parameters: FormData, elt: Node) => *|string|null} encodeParameters
|
|
5153
|
+
* @property {() => string[]|null} getSelectors
|
|
5129
5154
|
*/
|