jhx 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,2054 @@
1
+ import { HttpVerb, HtmxResponseHandlingConfig as HtmxResponseHandlingConfig$1, HtmxSettleInfo as HtmxSettleInfo$1, HtmxAjaxHelperContext, HtmxExtension as HtmxExtension$1, HtmxSwapSpecification, SwapOptions, ConditionalFunction as ConditionalFunction$1 } from 'htmx.org';
2
+ import { DOMAttributes, ElementType, ComponentPropsWithoutRef, PropsWithChildren, JSX } from 'react';
3
+
4
+ /**
5
+ * @see https://htmx.org/reference/
6
+ * @see https://htmx.org/docs/
7
+ */
8
+ declare const htmx: {
9
+ readonly attr: {
10
+ readonly onAbort: "hx-on--abort";
11
+ readonly onAfterOnLoad: "hx-on--after-on-load";
12
+ readonly onAfterProcessNode: "hx-on--after-process-node";
13
+ readonly onAfterRequest: "hx-on--after-request";
14
+ readonly onAfterSettle: "hx-on--after-settle";
15
+ readonly onAfterSwap: "hx-on--after-swap";
16
+ readonly onBeforeCleanupElement: "hx-on--before-cleanup-element";
17
+ readonly onBeforeOnLoad: "hx-on--before-on-load";
18
+ readonly onBeforeProcessNode: "hx-on--before-process-node";
19
+ readonly onBeforeRequest: "hx-on--before-request";
20
+ readonly onBeforeSwap: "hx-on--before-swap";
21
+ readonly onBeforeSend: "hx-on--before-send";
22
+ readonly onBeforeTransition: "hx-on--before-transition";
23
+ readonly onConfigRequest: "hx-on--config-request";
24
+ readonly onConfirm: "hx-on--confirm";
25
+ readonly onHistoryCacheError: "hx-on--history-cache-error";
26
+ readonly onHistoryCacheHit: "hx-on--history-cache-hit";
27
+ readonly onHistoryCacheMiss: "hx-on--history-cache-miss";
28
+ readonly onHistoryCacheMissLoadError: "hx-on--history-cache-miss-load-error";
29
+ readonly onHistoryCacheMissLoad: "hx-on--history-cache-miss-load";
30
+ readonly onHistoryRestore: "hx-on--history-restore";
31
+ readonly onBeforeHistorySave: "hx-on--before-history-save";
32
+ readonly onLoad: "hx-on--load";
33
+ readonly onNoSSESourceError: "hx-on--no-sse-source-error";
34
+ readonly onOnLoadError: "hx-on--on-load-error";
35
+ readonly onOobAfterSwap: "hx-on--oob-after-swap";
36
+ readonly onOobBeforeSwap: "hx-on--oob-before-swap";
37
+ readonly onOobErrorNoTarget: "hx-on--oob-error-no-target";
38
+ readonly onPrompt: "hx-on--prompt";
39
+ readonly onPushedIntoHistory: "hx-on--pushed-into-history";
40
+ readonly onReplacedInHistory: "hx-on--replaced-in-history";
41
+ readonly onResponseError: "hx-on--response-error";
42
+ readonly onSendAbort: "hx-on--send-abort";
43
+ readonly onSendError: "hx-on--send-error";
44
+ readonly onSseError: "hx-on--sse-error";
45
+ readonly onSseOpen: "hx-on--sse-open";
46
+ readonly onSwapError: "hx-on--swap-error";
47
+ readonly onTargetError: "hx-on--target-error";
48
+ readonly onTimeout: "hx-on--timeout";
49
+ readonly onValidateUrl: "hx-on--validate-url";
50
+ readonly onValidationValidate: "hx-on--validation-validate";
51
+ readonly onValidationFailed: "hx-on--validation-failed";
52
+ readonly onValidationHalted: "hx-on--validation-halted";
53
+ readonly onXhrAbort: "hx-on--xhr-abort";
54
+ readonly onXhrLoadend: "hx-on--xhr-loadend";
55
+ readonly onXhrLoadstart: "hx-on--xhr-loadstart";
56
+ readonly onXhrProgress: "hx-on--xhr-progress";
57
+ readonly get: "hx-get";
58
+ readonly post: "hx-post";
59
+ readonly put: "hx-put";
60
+ readonly delete: "hx-delete";
61
+ readonly patch: "hx-patch";
62
+ readonly pushUrl: "hx-push-url";
63
+ readonly select: "hx-select";
64
+ readonly selectOob: "hx-select-oob";
65
+ readonly swap: "hx-swap";
66
+ readonly swapOob: "hx-swap-oob";
67
+ readonly target: "hx-target";
68
+ readonly trigger: "hx-trigger";
69
+ readonly vals: "hx-vals";
70
+ readonly boost: "hx-boost";
71
+ readonly confirm: "hx-confirm";
72
+ readonly disable: "hx-disable";
73
+ readonly disabledElt: "hx-disabled-elt";
74
+ readonly disinherit: "hx-disinherit";
75
+ readonly encoding: "hx-encoding";
76
+ readonly ext: "hx-ext";
77
+ readonly headers: "hx-headers";
78
+ readonly history: "hx-history";
79
+ readonly historyElt: "hx-history-elt";
80
+ readonly include: "hx-include";
81
+ readonly indicator: "hx-indicator";
82
+ readonly inherit: "hx-inherit";
83
+ readonly params: "hx-params";
84
+ readonly preserve: "hx-preserve";
85
+ readonly prompt: "hx-prompt";
86
+ readonly replaceUrl: "hx-replace-url";
87
+ readonly request: "hx-request";
88
+ readonly sync: "hx-sync";
89
+ readonly validate: "hx-validate";
90
+ readonly vars: "hx-vars";
91
+ };
92
+ readonly config: HtmxConfig;
93
+ readonly css: {
94
+ readonly added: "htmx-added";
95
+ readonly indicator: "htmx-indicator";
96
+ readonly request: "htmx-request";
97
+ readonly settling: "htmx-settling";
98
+ readonly swapping: "htmx-swapping";
99
+ };
100
+ readonly event: {
101
+ readonly abort: "htmx:abort";
102
+ readonly afterOnLoad: "htmx:afterOnLoad";
103
+ readonly afterProcessNode: "htmx:afterProcessNode";
104
+ readonly afterRequest: "htmx:afterRequest";
105
+ readonly afterSettle: "htmx:afterSettle";
106
+ readonly afterSwap: "htmx:afterSwap";
107
+ readonly beforeCleanupElement: "htmx:beforeCleanupElement";
108
+ readonly beforeOnLoad: "htmx:beforeOnLoad";
109
+ readonly beforeProcessNode: "htmx:beforeProcessNode";
110
+ readonly beforeRequest: "htmx:beforeRequest";
111
+ readonly beforeSwap: "htmx:beforeSwap";
112
+ readonly beforeSend: "htmx:beforeSend";
113
+ readonly beforeTransition: "htmx:beforeTransition";
114
+ readonly configRequest: "htmx:configRequest";
115
+ readonly confirm: "htmx:confirm";
116
+ readonly historyCacheError: "htmx:historyCacheError";
117
+ readonly historyCacheHit: "htmx:historyCacheHit";
118
+ readonly historyCacheMiss: "htmx:historyCacheMiss";
119
+ readonly historyCacheMissLoadError: "htmx:historyCacheMissLoadError";
120
+ readonly historyCacheMissLoad: "htmx:historyCacheMissLoad";
121
+ readonly historyRestore: "htmx:historyRestore";
122
+ readonly beforeHistorySave: "htmx:beforeHistorySave";
123
+ readonly load: "htmx:load";
124
+ readonly noSSESourceError: "htmx:noSSESourceError";
125
+ readonly onLoadError: "htmx:onLoadError";
126
+ readonly oobAfterSwap: "htmx:oobAfterSwap";
127
+ readonly oobBeforeSwap: "htmx:oobBeforeSwap";
128
+ readonly oobErrorNoTarget: "htmx:oobErrorNoTarget";
129
+ readonly prompt: "htmx:prompt";
130
+ readonly pushedIntoHistory: "htmx:pushedIntoHistory";
131
+ readonly replacedInHistory: "htmx:replacedInHistory";
132
+ readonly responseError: "htmx:responseError";
133
+ readonly sendAbort: "htmx:sendAbort";
134
+ readonly sendError: "htmx:sendError";
135
+ readonly sseError: "htmx:sseError";
136
+ readonly sseOpen: "htmx:sseOpen";
137
+ readonly swapError: "htmx:swapError";
138
+ readonly targetError: "htmx:targetError";
139
+ readonly timeout: "htmx:timeout";
140
+ readonly validateUrl: "htmx:validateUrl";
141
+ readonly validationValidate: "htmx:validation:validate";
142
+ readonly validationFailed: "htmx:validation:failed";
143
+ readonly validationHalted: "htmx:validation:halted";
144
+ readonly xhrAbort: "htmx:xhr:abort";
145
+ readonly xhrLoadend: "htmx:xhr:loadend";
146
+ readonly xhrLoadstart: "htmx:xhr:loadstart";
147
+ readonly xhrProgress: "htmx:xhr:progress";
148
+ };
149
+ readonly eventAttr: {
150
+ readonly onAbort: "hx-on--abort";
151
+ readonly onAfterOnLoad: "hx-on--after-on-load";
152
+ readonly onAfterProcessNode: "hx-on--after-process-node";
153
+ readonly onAfterRequest: "hx-on--after-request";
154
+ readonly onAfterSettle: "hx-on--after-settle";
155
+ readonly onAfterSwap: "hx-on--after-swap";
156
+ readonly onBeforeCleanupElement: "hx-on--before-cleanup-element";
157
+ readonly onBeforeOnLoad: "hx-on--before-on-load";
158
+ readonly onBeforeProcessNode: "hx-on--before-process-node";
159
+ readonly onBeforeRequest: "hx-on--before-request";
160
+ readonly onBeforeSwap: "hx-on--before-swap";
161
+ readonly onBeforeSend: "hx-on--before-send";
162
+ readonly onBeforeTransition: "hx-on--before-transition";
163
+ readonly onConfigRequest: "hx-on--config-request";
164
+ readonly onConfirm: "hx-on--confirm";
165
+ readonly onHistoryCacheError: "hx-on--history-cache-error";
166
+ readonly onHistoryCacheHit: "hx-on--history-cache-hit";
167
+ readonly onHistoryCacheMiss: "hx-on--history-cache-miss";
168
+ readonly onHistoryCacheMissLoadError: "hx-on--history-cache-miss-load-error";
169
+ readonly onHistoryCacheMissLoad: "hx-on--history-cache-miss-load";
170
+ readonly onHistoryRestore: "hx-on--history-restore";
171
+ readonly onBeforeHistorySave: "hx-on--before-history-save";
172
+ readonly onLoad: "hx-on--load";
173
+ readonly onNoSSESourceError: "hx-on--no-sse-source-error";
174
+ readonly onOnLoadError: "hx-on--on-load-error";
175
+ readonly onOobAfterSwap: "hx-on--oob-after-swap";
176
+ readonly onOobBeforeSwap: "hx-on--oob-before-swap";
177
+ readonly onOobErrorNoTarget: "hx-on--oob-error-no-target";
178
+ readonly onPrompt: "hx-on--prompt";
179
+ readonly onPushedIntoHistory: "hx-on--pushed-into-history";
180
+ readonly onReplacedInHistory: "hx-on--replaced-in-history";
181
+ readonly onResponseError: "hx-on--response-error";
182
+ readonly onSendAbort: "hx-on--send-abort";
183
+ readonly onSendError: "hx-on--send-error";
184
+ readonly onSseError: "hx-on--sse-error";
185
+ readonly onSseOpen: "hx-on--sse-open";
186
+ readonly onSwapError: "hx-on--swap-error";
187
+ readonly onTargetError: "hx-on--target-error";
188
+ readonly onTimeout: "hx-on--timeout";
189
+ readonly onValidateUrl: "hx-on--validate-url";
190
+ readonly onValidationValidate: "hx-on--validation-validate";
191
+ readonly onValidationFailed: "hx-on--validation-failed";
192
+ readonly onValidationHalted: "hx-on--validation-halted";
193
+ readonly onXhrAbort: "hx-on--xhr-abort";
194
+ readonly onXhrLoadend: "hx-on--xhr-loadend";
195
+ readonly onXhrLoadstart: "hx-on--xhr-loadstart";
196
+ readonly onXhrProgress: "hx-on--xhr-progress";
197
+ };
198
+ readonly ext: {
199
+ readonly headSupport: {
200
+ readonly name: "head-support";
201
+ readonly version: "2.0.5";
202
+ readonly npm: "htmx-ext-head-support";
203
+ readonly cdn: readonly [{
204
+ readonly url: "https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5";
205
+ readonly integrity: "sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0";
206
+ }];
207
+ };
208
+ readonly htmx1Compat: {
209
+ readonly name: "htmx-1-compat";
210
+ readonly version: "2.0.2";
211
+ readonly npm: "htmx-ext-htmx-1-compat";
212
+ readonly cdn: readonly [{
213
+ readonly url: "https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2";
214
+ readonly integrity: "sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg";
215
+ }];
216
+ };
217
+ readonly idiomorph: {
218
+ readonly name: "morph";
219
+ readonly version: "0.7.4";
220
+ readonly npm: "idiomorph";
221
+ readonly cdn: readonly [{
222
+ readonly url: "https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js";
223
+ readonly integrity: "sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8";
224
+ }];
225
+ };
226
+ readonly preload: {
227
+ readonly name: "preload";
228
+ readonly version: "2.1.2";
229
+ readonly npm: "htmx-ext-preload";
230
+ readonly cdn: readonly [{
231
+ readonly url: "https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2";
232
+ readonly integrity: "sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk";
233
+ }];
234
+ };
235
+ readonly responseTargets: {
236
+ readonly name: "response-targets";
237
+ readonly version: "2.0.4";
238
+ readonly npm: "htmx-ext-response-targets";
239
+ readonly cdn: readonly [{
240
+ readonly url: "https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4";
241
+ readonly integrity: "sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg";
242
+ }];
243
+ };
244
+ readonly sse: {
245
+ readonly name: "sse";
246
+ readonly version: "2.2.4";
247
+ readonly npm: "htmx-ext-sse";
248
+ readonly cdn: readonly [{
249
+ readonly url: "https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4";
250
+ readonly integrity: "sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N";
251
+ }];
252
+ };
253
+ readonly ws: {
254
+ readonly name: "ws";
255
+ readonly version: "2.0.4";
256
+ readonly npm: "htmx-ext-ws";
257
+ readonly cdn: readonly [{
258
+ readonly url: "https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4";
259
+ readonly integrity: "sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G";
260
+ }];
261
+ };
262
+ };
263
+ readonly method: {
264
+ readonly GET: "hx-get";
265
+ readonly POST: "hx-post";
266
+ readonly PUT: "hx-put";
267
+ readonly DELETE: "hx-delete";
268
+ readonly PATCH: "hx-patch";
269
+ readonly get: "hx-get";
270
+ readonly post: "hx-post";
271
+ readonly put: "hx-put";
272
+ readonly delete: "hx-delete";
273
+ readonly patch: "hx-patch";
274
+ };
275
+ readonly res: {
276
+ readonly location: "HX-Location";
277
+ readonly pushUrl: "HX-Push-URL";
278
+ readonly redirect: "HX-Redirect";
279
+ readonly refresh: "HX-Refresh";
280
+ readonly replaceUrl: "HX-Replace-URL";
281
+ readonly reswap: "HX-Reswap";
282
+ readonly retarget: "HX-Retarget";
283
+ readonly reselect: "HX-Reselect";
284
+ readonly trigger: "HX-Trigger";
285
+ readonly triggerAfterSettle: "HX-Trigger-After-Settle";
286
+ readonly triggerAfterSwap: "HX-Trigger-After-Swap";
287
+ };
288
+ readonly req: {
289
+ readonly boosted: "HX-Boosted";
290
+ readonly currentUrl: "HX-Current-URL";
291
+ readonly historyRestoreRequest: "HX-History-Restore-Request";
292
+ readonly prompt: "HX-Prompt";
293
+ readonly request: "HX-Request";
294
+ readonly target: "HX-Target";
295
+ readonly triggerName: "HX-Trigger-Name";
296
+ readonly trigger: "HX-Trigger";
297
+ };
298
+ readonly swap: {
299
+ readonly innerHTML: "innerHTML";
300
+ readonly outerHTML: "outerHTML";
301
+ readonly textContent: "textContent";
302
+ readonly beforeBegin: "beforebegin";
303
+ readonly afterBegin: "afterbegin";
304
+ readonly beforeEnd: "beforeend";
305
+ readonly afterEnd: "afterend";
306
+ readonly delete: "delete";
307
+ readonly none: "none";
308
+ };
309
+ readonly sync: {
310
+ readonly drop: "drop";
311
+ readonly abort: "abort";
312
+ readonly replace: "replace";
313
+ readonly queue: "queue";
314
+ readonly queueAll: "queue all";
315
+ readonly queueFirst: "queue first";
316
+ readonly queueLast: "queue last";
317
+ };
318
+ };
319
+
320
+ /** @see https://htmx.org/reference/#attributes */
321
+ type HtmxAttribute = (typeof htmx.attr)[keyof typeof htmx.attr];
322
+ /** @see https://htmx.org/reference/#classes */
323
+ type HtmxClass = (typeof htmx.css)[keyof typeof htmx.css];
324
+ /** @see https://htmx.org/reference/#events */
325
+ type HtmxEventName = (typeof htmx.event)[keyof typeof htmx.event];
326
+ /**
327
+ * @see https://htmx.org/reference/#events
328
+ * @see https://htmx.org/attributes/hx-on/
329
+ */
330
+ type HtmxEventAttribute = (typeof htmx.eventAttr)[keyof typeof htmx.eventAttr] | `hx-on--${string}` | `hx-on-${string}`;
331
+ interface HtmxExtensionMetadata {
332
+ name: string;
333
+ version: string;
334
+ npm?: string;
335
+ cdn?: Array<{
336
+ url: string;
337
+ integrity?: string;
338
+ }>;
339
+ }
340
+ type HtmxDefaultExtension = (typeof htmx.ext)[keyof typeof htmx.ext]['name'];
341
+ /**
342
+ * @see https://htmx.org/docs/#ajax
343
+ * @see https://htmx.org/reference/#attributes
344
+ */
345
+ type HtmxHttpMethod = keyof typeof htmx.method;
346
+ /**
347
+ * @see https://htmx.org/docs/#ajax
348
+ * @see https://htmx.org/reference/#attributes
349
+ */
350
+ type HtmxMethodAttribute = (typeof htmx.method)[keyof typeof htmx.method];
351
+ type HtmxRequestHeader = (typeof htmx.req)[keyof typeof htmx.req];
352
+ type HtmxResponseHeader = (typeof htmx.res)[keyof typeof htmx.res];
353
+ type HtmxSwapStyle = (typeof htmx.swap)[keyof typeof htmx.swap];
354
+ type HtmxSyncStrategy = (typeof htmx.sync)[keyof typeof htmx.sync];
355
+
356
+ interface HtmxPathInfo {
357
+ /**
358
+ * The original request path specified for the HTMX request.
359
+ */
360
+ requestPath: string;
361
+ /**
362
+ * The final request path after any server-side redirections or URL rewrites.
363
+ */
364
+ finalRequestPath: string;
365
+ /**
366
+ * The path extracted from the server response, or `null` if none was provided.
367
+ */
368
+ responsePath: string | null;
369
+ /**
370
+ * The URL fragment (anchor) associated with the request.
371
+ */
372
+ anchor: string;
373
+ }
374
+
375
+ interface HtmxElementValidationError {
376
+ elt: Element;
377
+ message: string;
378
+ validity: ValidityState;
379
+ }
380
+
381
+ type HtmxHttpVerb = HttpVerb;
382
+
383
+ interface HtmxRequestConfig {
384
+ /**
385
+ * Indicates if the request was boosted via `hx-boost`.
386
+ */
387
+ boosted: boolean;
388
+ /**
389
+ * The element that initiated the HTMX request.
390
+ */
391
+ elt: Element;
392
+ /**
393
+ * Validation errors associated with the target element.
394
+ */
395
+ errors: HtmxElementValidationError[];
396
+ /**
397
+ * FormData object assembled for the request.
398
+ */
399
+ formData: FormData;
400
+ /**
401
+ * HTTP headers to include with the request.
402
+ */
403
+ headers: Record<string, string>;
404
+ /**
405
+ * Key/value pairs representing entries in `formData`.
406
+ */
407
+ parameters: Record<string, FormDataEntryValue | FormDataEntryValue[]>;
408
+ /**
409
+ * URL or path used for the HTMX request.
410
+ */
411
+ path: string;
412
+ /**
413
+ * Element into which the response content will be swapped.
414
+ */
415
+ target: Element;
416
+ /**
417
+ * Maximum time in milliseconds before the request times out.
418
+ */
419
+ timeout: number;
420
+ /**
421
+ * Original DOM event that triggered the HTMX request.
422
+ */
423
+ triggeringEvent: Event;
424
+ /**
425
+ * Unfiltered FormData before any HTMX processing.
426
+ */
427
+ unfilteredFormData: FormData;
428
+ /**
429
+ * Key/value pairs representing entries in `unfilteredFormData`.
430
+ */
431
+ unfilteredParameters: Record<string, FormDataEntryValue | FormDataEntryValue[]>;
432
+ /**
433
+ * Whether to include parameters in the URL instead of the request body.
434
+ */
435
+ useUrlParams: boolean;
436
+ /**
437
+ * HTTP method to use for the request (e.g.\ `"GET"`, `"POST"`).
438
+ */
439
+ verb: HtmxHttpVerb;
440
+ /**
441
+ * Whether to include credentials (cookies, authorization headers) with the request.
442
+ */
443
+ withCredentials: boolean;
444
+ }
445
+
446
+ /**
447
+ * Callback invoked during the HTMX AJAX lifecycle.
448
+ */
449
+ type HtmxAjaxHandler = (elt: Element, responseInfo: {
450
+ /**
451
+ * The underlying `XMLHttpRequest` instance.
452
+ */
453
+ xhr: XMLHttpRequest;
454
+ /**
455
+ * Element into which the response content will be swapped.
456
+ */
457
+ target: Element;
458
+ /**
459
+ * Configuration used for the HTMX request.
460
+ */
461
+ requestConfig: HtmxRequestConfig;
462
+ /**
463
+ * Additional AJAX-specific options and callbacks.
464
+ */
465
+ etc: HtmxAjaxEtc;
466
+ /**
467
+ * Indicates whether the request was boosted via `hx-boost`.
468
+ */
469
+ boosted: boolean;
470
+ /**
471
+ * CSS selector used for swapping content.
472
+ */
473
+ select: string;
474
+ /**
475
+ * Parsed path information for the request URL.
476
+ */
477
+ pathInfo: HtmxPathInfo;
478
+ /**
479
+ * True if the request failed.
480
+ */
481
+ failed?: boolean;
482
+ /**
483
+ * True if the request completed successfully.
484
+ */
485
+ successful?: boolean;
486
+ /**
487
+ * Whether to retain CSS indicators after the swap.
488
+ */
489
+ keepIndicators?: boolean;
490
+ }) => any;
491
+
492
+ interface HtmxAjaxEtc {
493
+ /**
494
+ * When true, returns a Promise that resolves with the AJAX response.
495
+ */
496
+ returnPromise?: boolean;
497
+ /**
498
+ * Custom handler invoked during the AJAX request lifecycle.
499
+ */
500
+ handler?: HtmxAjaxHandler;
501
+ /**
502
+ * CSS selector used to find the element(s) to swap content into.
503
+ */
504
+ select?: string | null;
505
+ /**
506
+ * Overrides the default target element for content swapping.
507
+ */
508
+ targetOverride?: Element;
509
+ /**
510
+ * Overrides the default swap strategy (e.g., "innerHTML", "outerHTML").
511
+ */
512
+ swapOverride?: HtmxSwapStyle;
513
+ /**
514
+ * Additional HTTP headers to include with the request.
515
+ */
516
+ headers?: Record<string, string>;
517
+ /**
518
+ * FormData instance containing key/value pairs to send with the request.
519
+ */
520
+ values?: FormData;
521
+ /**
522
+ * Indicates whether to include credentials (cookies, authorization headers) in the request.
523
+ */
524
+ credentials?: boolean;
525
+ /**
526
+ * Maximum time in milliseconds before the request times out.
527
+ */
528
+ timeout?: number;
529
+ }
530
+
531
+ interface HtmxCacheItem {
532
+ /**
533
+ * The request URL used as the cache key.
534
+ */
535
+ url: string;
536
+ /**
537
+ * The cached HTML content or response text associated with the URL.
538
+ */
539
+ content: string;
540
+ }
541
+
542
+ type HtmxResponseHandlingConfig = HtmxResponseHandlingConfig$1;
543
+
544
+ /**
545
+ * @see https://htmx.org/reference/#config
546
+ */
547
+ type HtmxConfig = {
548
+ /**
549
+ * @see https://htmx.org/reference/#config
550
+ */
551
+ addedClass: string;
552
+ /**
553
+ * @see https://htmx.org/reference/#config
554
+ */
555
+ allowEval: boolean;
556
+ /**
557
+ * @see https://htmx.org/reference/#config
558
+ */
559
+ allowNestedOobSwaps: boolean;
560
+ /**
561
+ * @see https://htmx.org/reference/#config
562
+ */
563
+ allowScriptTags: boolean;
564
+ /**
565
+ * @see https://htmx.org/reference/#config
566
+ */
567
+ attributesToSettle: string[];
568
+ /**
569
+ * @see https://htmx.org/reference/#config
570
+ */
571
+ defaultFocusScroll: boolean;
572
+ /**
573
+ * @see https://htmx.org/reference/#config
574
+ */
575
+ defaultSettleDelay: number;
576
+ /**
577
+ * @see https://htmx.org/reference/#config
578
+ */
579
+ defaultSwapDelay: number;
580
+ /**
581
+ * @see https://htmx.org/reference/#config
582
+ */
583
+ defaultSwapStyle: HtmxSwapStyle | (string & {});
584
+ /**
585
+ * @see https://htmx.org/reference/#config
586
+ */
587
+ disableInheritance: boolean;
588
+ /**
589
+ * @see https://htmx.org/reference/#config
590
+ */
591
+ disableSelector: string;
592
+ /**
593
+ * @see https://htmx.org/reference/#config
594
+ */
595
+ getCacheBusterParam: boolean;
596
+ /**
597
+ * @see https://htmx.org/reference/#config
598
+ */
599
+ globalViewTransitions: boolean;
600
+ /**
601
+ * @see https://htmx.org/reference/#config
602
+ */
603
+ historyCacheSize: number;
604
+ /**
605
+ * @see https://htmx.org/reference/#config
606
+ */
607
+ historyEnabled: boolean;
608
+ /**
609
+ * @see https://htmx.org/reference/#config
610
+ */
611
+ historyRestoreAsHxRequest: boolean;
612
+ /**
613
+ * @see https://htmx.org/reference/#config
614
+ */
615
+ ignoreTitle: boolean;
616
+ /**
617
+ * @see https://htmx.org/reference/#config
618
+ */
619
+ includeIndicatorStyles: boolean;
620
+ /**
621
+ * @see https://htmx.org/reference/#config
622
+ */
623
+ indicatorClass: string;
624
+ /**
625
+ * @see https://htmx.org/reference/#config
626
+ */
627
+ inlineScriptNonce: string;
628
+ /**
629
+ * @see https://htmx.org/reference/#config
630
+ */
631
+ inlineStyleNonce: string;
632
+ /**
633
+ * @see https://htmx.org/reference/#config
634
+ */
635
+ methodsThatUseUrlParams: HtmxHttpVerb[];
636
+ /**
637
+ * @see https://htmx.org/reference/#config
638
+ */
639
+ refreshOnHistoryMiss: boolean;
640
+ /**
641
+ * @see https://htmx.org/reference/#config
642
+ */
643
+ requestClass: string;
644
+ /**
645
+ * @see https://htmx.org/reference/#config
646
+ */
647
+ responseHandling: HtmxResponseHandlingConfig[];
648
+ /**
649
+ * @see https://htmx.org/reference/#config
650
+ */
651
+ scrollBehavior: 'auto' | 'instant' | 'smooth';
652
+ /**
653
+ * @see https://htmx.org/reference/#config
654
+ */
655
+ scrollIntoViewOnBoost: boolean;
656
+ /**
657
+ * @see https://htmx.org/reference/#config
658
+ */
659
+ selfRequestsOnly: boolean;
660
+ /**
661
+ * @see https://htmx.org/reference/#config
662
+ */
663
+ settlingClass: string;
664
+ /**
665
+ * @see https://htmx.org/reference/#config
666
+ */
667
+ swappingClass: string;
668
+ /**
669
+ * @see https://htmx.org/reference/#config
670
+ */
671
+ timeout: number;
672
+ /**
673
+ * @see https://htmx.org/reference/#config
674
+ */
675
+ triggerSpecsCache: any | null;
676
+ /**
677
+ * @see https://htmx.org/reference/#config
678
+ */
679
+ withCredentials: boolean;
680
+ /**
681
+ * @see https://htmx.org/reference/#config
682
+ */
683
+ wsBinaryType: BinaryType;
684
+ /**
685
+ * @see https://htmx.org/reference/#config
686
+ */
687
+ wsReconnectDelay: 'full-jitter' | ((retryCount: number) => number);
688
+ };
689
+
690
+ type HtmxIssueRequest = (skipConfirmation?: boolean) => void;
691
+
692
+ interface HtmxSwapSpec {
693
+ /**
694
+ * Vertical scroll offset to apply after the swap completes.
695
+ */
696
+ scroll: number;
697
+ /**
698
+ * Time in milliseconds to wait before initiating the swap’s settle phase.
699
+ */
700
+ settleDelay: number;
701
+ /**
702
+ * Time in milliseconds to wait before performing the actual content swap.
703
+ */
704
+ swapDelay: number;
705
+ /**
706
+ * Strategy for swapping content (e.g., “innerHTML”, “outerHTML”).
707
+ */
708
+ swapStyle: HtmxSwapStyle;
709
+ }
710
+
711
+ interface HtmxEventDetail {
712
+ /**
713
+ * Indicates if the request was boosted via `hx-boost`.
714
+ */
715
+ boosted?: boolean | undefined;
716
+ /**
717
+ * The content element to be swapped in.
718
+ */
719
+ content?: Element;
720
+ /**
721
+ * The element that triggered the event.
722
+ */
723
+ elt?: Element;
724
+ /**
725
+ * Validation errors for the target element.
726
+ */
727
+ errors?: HtmxElementValidationError[];
728
+ /**
729
+ * Additional AJAX-related information.
730
+ */
731
+ etc?: HtmxAjaxEtc;
732
+ /**
733
+ * Error message returned by the server.
734
+ */
735
+ error?: string;
736
+ /**
737
+ * The original DOM event associated with this detail.
738
+ */
739
+ event?: Event;
740
+ /**
741
+ * Exception caught during request handling.
742
+ */
743
+ exception?: Error;
744
+ /**
745
+ * Whether the request failed.
746
+ */
747
+ failed?: boolean;
748
+ /**
749
+ * Collected form data for the request.
750
+ */
751
+ formData?: FormData;
752
+ /**
753
+ * Fragment element extracted from the response.
754
+ */
755
+ fragment?: Element;
756
+ /**
757
+ * Parsed response headers as key/value pairs.
758
+ */
759
+ headers?: Record<string, string>;
760
+ /**
761
+ * Element used for history updates.
762
+ */
763
+ historyElt?: Element;
764
+ /**
765
+ * If true, update of document title is skipped.
766
+ */
767
+ ignoreTitle?: boolean | undefined;
768
+ /**
769
+ * True when the response status indicates an error.
770
+ */
771
+ isError?: boolean;
772
+ /**
773
+ * Details for issuing follow-up requests.
774
+ */
775
+ issueRequest?: HtmxIssueRequest;
776
+ /**
777
+ * Cached item associated with the request.
778
+ */
779
+ item?: HtmxCacheItem;
780
+ /**
781
+ * Retain CSS indicators after swap.
782
+ */
783
+ keepIndicators?: boolean;
784
+ /**
785
+ * Indicates if the total size is computable in progress events.
786
+ */
787
+ lengthComputable?: boolean;
788
+ /**
789
+ * Number of bytes loaded in progress events.
790
+ */
791
+ loaded?: number;
792
+ /**
793
+ * Message returned from the server.
794
+ */
795
+ message?: string;
796
+ /**
797
+ * Proxy for `formData` as a key/value map.
798
+ */
799
+ parameters?: Record<string, FormDataEntryValue | FormDataEntryValue[]>;
800
+ /**
801
+ * Request path used.
802
+ */
803
+ path?: string;
804
+ /**
805
+ * Parsed information about the request path.
806
+ */
807
+ pathInfo?: HtmxPathInfo;
808
+ /**
809
+ * Prompt text displayed to the user.
810
+ */
811
+ prompt?: string;
812
+ /**
813
+ * User response for confirmation or prompt dialogs.
814
+ */
815
+ question?: string | null;
816
+ /**
817
+ * Raw response text from the server.
818
+ */
819
+ response?: string;
820
+ /**
821
+ * Configuration used for the request.
822
+ */
823
+ requestConfig?: HtmxRequestConfig;
824
+ /**
825
+ * True if the response came from the same host.
826
+ */
827
+ sameHost?: boolean;
828
+ /**
829
+ * CSS selector used for swapping content.
830
+ */
831
+ select?: string | null;
832
+ /**
833
+ * Overrides the default swap selector.
834
+ */
835
+ selectOverride?: string | null;
836
+ /**
837
+ * Unparsed server response string.
838
+ */
839
+ serverResponse?: string;
840
+ /**
841
+ * Indicates whether a swap should occur.
842
+ */
843
+ shouldSwap?: boolean;
844
+ /**
845
+ * Associated `EventSource` for server-sent events.
846
+ */
847
+ source?: EventSource;
848
+ /**
849
+ * True if the request completed successfully.
850
+ */
851
+ successful?: boolean;
852
+ /**
853
+ * Overrides the swap style (e.g., `innerHTML`, `outerHTML`).
854
+ */
855
+ swapOverride?: HtmxSwapStyle | null;
856
+ /**
857
+ * Parsed specification for swapping.
858
+ */
859
+ swapSpec?: HtmxSwapSpec;
860
+ /**
861
+ * Target element for content swap.
862
+ */
863
+ target?: Element;
864
+ /**
865
+ * Timeout value for the request in milliseconds.
866
+ */
867
+ timeout?: number;
868
+ /**
869
+ * Total bytes expected in progress events.
870
+ */
871
+ total?: number;
872
+ /**
873
+ * The original event that triggered this HTMX event.
874
+ */
875
+ triggeringEvent?: Event;
876
+ /**
877
+ * Unfiltered form data before any modifications.
878
+ */
879
+ unfilteredFormData?: FormData;
880
+ /**
881
+ * Proxy for `unfilteredFormData` as a key/value map.
882
+ */
883
+ unfilteredParameters?: Record<string, FormDataEntryValue | FormDataEntryValue[]>;
884
+ /**
885
+ * Full URL used for the request.
886
+ */
887
+ url?: URL;
888
+ /**
889
+ * Whether URL parameters should be used instead of body.
890
+ */
891
+ useUrlParams?: boolean;
892
+ /**
893
+ * Validity state of the form element.
894
+ */
895
+ validity?: ValidityState;
896
+ /**
897
+ * HTTP method used for the request.
898
+ */
899
+ verb?: HtmxHttpVerb;
900
+ /**
901
+ * Whether credentials are included in the request.
902
+ */
903
+ withCredentials?: boolean;
904
+ /**
905
+ * Underlying `XMLHttpRequest` object.
906
+ */
907
+ xhr?: XMLHttpRequest;
908
+ }
909
+
910
+ interface HtmxDomEvent extends Event {
911
+ detail: HtmxEventDetail;
912
+ type: HtmxEventName;
913
+ }
914
+
915
+ interface DomObjects {
916
+ document: Document;
917
+ htmx: HtmxInstance;
918
+ window: Window;
919
+ }
920
+
921
+ interface HtmxEventProps<TDom extends object = object> {
922
+ onAbort?: (args: {
923
+ event: HtmxAbortEvent;
924
+ } & DomObjects & TDom) => void;
925
+ onAfterOnLoad?: (args: {
926
+ event: HtmxAfterOnLoadEvent;
927
+ } & DomObjects & TDom) => void;
928
+ onAfterProcessNode?: (args: {
929
+ event: HtmxAfterProcessNodeEvent;
930
+ } & DomObjects & TDom) => void;
931
+ onAfterRequest?: (args: {
932
+ event: HtmxAfterRequestEvent;
933
+ } & DomObjects & TDom) => void;
934
+ onAfterSettle?: (args: {
935
+ event: HtmxAfterSettleEvent;
936
+ } & DomObjects & TDom) => void;
937
+ onAfterSwap?: (args: {
938
+ event: HtmxAfterSwapEvent;
939
+ } & DomObjects & TDom) => void;
940
+ onBeforeCleanupElement?: (args: {
941
+ event: HtmxBeforeCleanupElementEvent;
942
+ } & DomObjects & TDom) => void;
943
+ onBeforeOnLoad?: (args: {
944
+ event: HtmxBeforeOnLoadEvent;
945
+ } & DomObjects & TDom) => void;
946
+ onBeforeProcessNode?: (args: {
947
+ event: HtmxBeforeProcessNodeEvent;
948
+ } & DomObjects & TDom) => void;
949
+ onBeforeRequest?: (args: {
950
+ event: HtmxBeforeRequestEvent;
951
+ } & DomObjects & TDom) => void;
952
+ onBeforeSwap?: (args: {
953
+ event: HtmxBeforeSwapEvent;
954
+ } & DomObjects & TDom) => void;
955
+ onBeforeSend?: (args: {
956
+ event: HtmxBeforeSendEvent;
957
+ } & DomObjects & TDom) => void;
958
+ onBeforeTransition?: (args: {
959
+ event: HtmxBeforeTransitionEvent;
960
+ } & DomObjects & TDom) => void;
961
+ onConfigRequest?: (args: {
962
+ event: HtmxConfigRequestEvent;
963
+ } & DomObjects & TDom) => void;
964
+ onConfirm?: (args: {
965
+ event: HtmxConfirmEvent;
966
+ } & DomObjects & TDom) => void;
967
+ onHistoryCacheError?: (args: {
968
+ event: HtmxHistoryCacheErrorEvent;
969
+ } & DomObjects & TDom) => void;
970
+ onHistoryCacheHit?: (args: {
971
+ event: HtmxHistoryCacheHitEvent;
972
+ } & DomObjects & TDom) => void;
973
+ onHistoryCacheMiss?: (args: {
974
+ event: HtmxHistoryCacheMissEvent;
975
+ } & DomObjects & TDom) => void;
976
+ onHistoryCacheMissLoadError?: (args: {
977
+ event: HtmxHistoryCacheMissLoadErrorEvent;
978
+ } & DomObjects & TDom) => void;
979
+ onHistoryCacheMissLoad?: (args: {
980
+ event: HtmxHistoryCacheMissLoadEvent;
981
+ } & DomObjects & TDom) => void;
982
+ onHistoryRestore?: (args: {
983
+ event: HtmxHistoryRestoreEvent;
984
+ } & DomObjects & TDom) => void;
985
+ onBeforeHistorySave?: (args: {
986
+ event: HtmxBeforeHistorySaveEvent;
987
+ } & DomObjects & TDom) => void;
988
+ onLoad?: (args: {
989
+ event: HtmxLoadEvent;
990
+ } & DomObjects & TDom) => void;
991
+ onNoSSESourceError?: (args: {
992
+ event: HtmxNoSseSourceErrorEvent;
993
+ } & DomObjects & TDom) => void;
994
+ onOnLoadError?: (args: {
995
+ event: HtmxOnLoadErrorEvent;
996
+ } & DomObjects & TDom) => void;
997
+ onOobAfterSwap?: (args: {
998
+ event: HtmxOobAfterSwapEvent;
999
+ } & DomObjects & TDom) => void;
1000
+ onOobBeforeSwap?: (args: {
1001
+ event: HtmxOobBeforeSwapEvent;
1002
+ } & DomObjects & TDom) => void;
1003
+ onOobErrorNoTarget?: (args: {
1004
+ event: HtmxOobErrorNoTargetEvent;
1005
+ } & DomObjects & TDom) => void;
1006
+ onPrompt?: (args: {
1007
+ event: HtmxPromptEvent;
1008
+ } & DomObjects & TDom) => void;
1009
+ onPushedIntoHistory?: (args: {
1010
+ event: HtmxPushedIntoHistoryEvent;
1011
+ } & DomObjects & TDom) => void;
1012
+ onReplacedInHistory?: (args: {
1013
+ event: HtmxReplacedInHistoryEvent;
1014
+ } & DomObjects & TDom) => void;
1015
+ onResponseError?: (args: {
1016
+ event: HtmxResponseErrorEvent;
1017
+ } & DomObjects & TDom) => void;
1018
+ onSendAbort?: (args: {
1019
+ event: HtmxSendAbortEvent;
1020
+ } & DomObjects & TDom) => void;
1021
+ onSendError?: (args: {
1022
+ event: HtmxSendErrorEvent;
1023
+ } & DomObjects & TDom) => void;
1024
+ onSseError?: (args: {
1025
+ event: HtmxSseErrorEvent;
1026
+ } & DomObjects & TDom) => void;
1027
+ onSseOpen?: (args: {
1028
+ event: HtmxSseOpenEvent;
1029
+ } & DomObjects & TDom) => void;
1030
+ onSwapError?: (args: {
1031
+ event: HtmxSwapErrorEvent;
1032
+ } & DomObjects & TDom) => void;
1033
+ onTargetError?: (args: {
1034
+ event: HtmxTargetErrorEvent;
1035
+ } & DomObjects & TDom) => void;
1036
+ onTimeout?: (args: {
1037
+ event: HtmxTimeoutEvent;
1038
+ } & DomObjects & TDom) => void;
1039
+ onValidateUrl?: (args: {
1040
+ event: HtmxValidateUrlEvent;
1041
+ } & DomObjects & TDom) => void;
1042
+ onValidationValidate?: (args: {
1043
+ event: HtmxValidationValidateEvent;
1044
+ } & DomObjects & TDom) => void;
1045
+ onValidationFailed?: (args: {
1046
+ event: HtmxValidationFailedEvent;
1047
+ } & DomObjects & TDom) => void;
1048
+ onValidationHalted?: (args: {
1049
+ event: HtmxValidationHaltedEvent;
1050
+ } & DomObjects & TDom) => void;
1051
+ onXhrAbort?: (args: {
1052
+ event: HtmxXhrAbortEvent;
1053
+ } & DomObjects & TDom) => void;
1054
+ onXhrLoadend?: (args: {
1055
+ event: HtmxXhrLoadendEvent;
1056
+ } & DomObjects & TDom) => void;
1057
+ onXhrLoadstart?: (args: {
1058
+ event: HtmxXhrLoadstartEvent;
1059
+ } & DomObjects & TDom) => void;
1060
+ onXhrProgress?: (args: {
1061
+ event: HtmxXhrProgressEvent;
1062
+ } & DomObjects & TDom) => void;
1063
+ }
1064
+
1065
+ type HtmxEvent = Parameters<Exclude<HtmxEventProps[keyof HtmxEventProps], undefined>>[0];
1066
+
1067
+ type HtmxSettleInfo = HtmxSettleInfo$1;
1068
+
1069
+ interface HtmxExtension<T extends CustomEvent = CustomEvent & HtmxEvent> {
1070
+ /**
1071
+ * Initializes the extension with the HTMX API.
1072
+ */
1073
+ init?: (api: any) => void;
1074
+ /**
1075
+ * Intercepts HTMX events dispatched on elements.
1076
+ * Return `false` to prevent default HTMX handling.
1077
+ */
1078
+ onEvent?: (name: string, event: T) => boolean;
1079
+ /**
1080
+ * Transforms the raw response text before swapping into the DOM.
1081
+ */
1082
+ transformResponse?: (text: string, xhr: XMLHttpRequest, elt: Element) => string;
1083
+ /**
1084
+ * Determines if a swap style should be treated as inline insertion.
1085
+ */
1086
+ isInlineSwap?: (swapStyle: HtmxSwapStyle) => boolean;
1087
+ /**
1088
+ * Custom handler for swapping content into the target node.
1089
+ */
1090
+ handleSwap?: (swapStyle: HtmxSwapStyle, target: Node, fragment: Node, settleInfo: HtmxSettleInfo) => boolean | Node[];
1091
+ /**
1092
+ * Encodes request parameters before sending via `XMLHttpRequest`.
1093
+ */
1094
+ encodeParameters?: (xhr: XMLHttpRequest, parameters: FormData, elt: Node) => any | string | null;
1095
+ /**
1096
+ * Provides additional selectors for HTMX to initialize.
1097
+ */
1098
+ getSelectors?: () => string[] | null;
1099
+ }
1100
+
1101
+ type Duration = `${number}${'m' | 's' | 'ms'}`;
1102
+
1103
+ interface HtmxInstance {
1104
+ _: (str: string) => any;
1105
+ /**
1106
+ * Adds a class to the given element.
1107
+ */
1108
+ addClass: (elt: Element | string, clazz: string, delay?: Duration) => void;
1109
+ /**
1110
+ * Issues an htmx-style ajax request.
1111
+ */
1112
+ ajax: (verb: HttpVerb, path: string, context: Element | string | HtmxAjaxHelperContext) => Promise<void>;
1113
+ /**
1114
+ * Finds the closest parent to the given element matching the selector.
1115
+ */
1116
+ closest: (elt: Element | string, selector: string) => Element | null;
1117
+ /**
1118
+ * A property that holds the current htmx config object.
1119
+ */
1120
+ config: HtmxConfig;
1121
+ /**
1122
+ * A property holding the function to create SSE EventSource objects for htmx,
1123
+ */
1124
+ createEventSource: (url: string) => EventSource;
1125
+ /**
1126
+ * A property holding the function to create WebSocket objects for htmx.
1127
+ */
1128
+ createWebSocket: (url: string) => WebSocket;
1129
+ /**
1130
+ * Defines an htmx [extension](https://htmx.org/extensions).
1131
+ */
1132
+ defineExtension: (name: string, extension: Partial<HtmxExtension$1>) => void;
1133
+ /**
1134
+ * Finds a single element matching the selector.
1135
+ */
1136
+ find: (eltOrSelector: ParentNode | string, selector?: string) => Element | null;
1137
+ /**
1138
+ * Finds all elements matching a given selector.
1139
+ */
1140
+ findAll: {
1141
+ (): NodeListOf<Element>;
1142
+ (eltOrSelector: ParentNode | string, selector?: string): NodeListOf<Element>;
1143
+ };
1144
+ /**
1145
+ * A property that holds the current window location (URL).
1146
+ */
1147
+ location: Location;
1148
+ /**
1149
+ * Installs a logger that will log all htmx events.
1150
+ */
1151
+ logAll: () => void;
1152
+ /**
1153
+ * Removes the existing logger.
1154
+ */
1155
+ logNone: () => void;
1156
+ /**
1157
+ * A property set to the current logger (default is `null`).
1158
+ */
1159
+ logger: any;
1160
+ /**
1161
+ * Removes an event listener from the given element.
1162
+ */
1163
+ off: (arg1: EventTarget | string, arg2: string | EventListener, arg3?: EventListener) => EventListener;
1164
+ /**
1165
+ * Creates an event listener on the given element, returning it.
1166
+ */
1167
+ on: (arg1: EventTarget | string, arg2: string | EventListener, arg3?: EventListener | any | boolean, arg4?: any | boolean) => EventListener;
1168
+ /**
1169
+ * Adds a callback handler for the `htmx:load` event.
1170
+ */
1171
+ onLoad: (callback: (elt: Node) => void) => EventListener;
1172
+ /**
1173
+ * Parses an interval declaration into a millisecond value.
1174
+ */
1175
+ parseInterval: (str: string) => number | undefined;
1176
+ /**
1177
+ * Processes the given element and its children, hooking up any htmx behavior.
1178
+ */
1179
+ process: (elt: Element | string) => void;
1180
+ /**
1181
+ * Removes the given element.
1182
+ */
1183
+ remove: (elt: Node, delay?: Duration) => void;
1184
+ /**
1185
+ * Removes a class from the given element.
1186
+ */
1187
+ removeClass: (node: Node | string, clazz: string, delay?: Duration) => void;
1188
+ /**
1189
+ * Removes an htmx [extension](https://htmx.org/extensions).
1190
+ */
1191
+ removeExtension: (name: string) => void;
1192
+ /**
1193
+ * Performs swapping (and settling) of HTML content.
1194
+ */
1195
+ swap: (target: string | Element, content: string, swapSpec: HtmxSwapSpecification, swapOptions?: SwapOptions) => void;
1196
+ /**
1197
+ * Takes a class from other elements for the given element.
1198
+ */
1199
+ takeClass: (elt: Node | string, clazz: string) => void;
1200
+ /**
1201
+ * Toggles a class from the given element.
1202
+ */
1203
+ toggleClass: (elt: Element | string, clazz: string) => void;
1204
+ /**
1205
+ * Triggers an event on an element.
1206
+ */
1207
+ trigger: (elt: EventTarget | string, eventName: string, detail?: any | undefined) => boolean;
1208
+ /**
1209
+ * Returns the input values associated with the given element.
1210
+ */
1211
+ values: (elt: Element, type: HttpVerb) => any;
1212
+ /**
1213
+ * Current htmx version.
1214
+ */
1215
+ version: string;
1216
+ }
1217
+
1218
+ type Detail<TProperties extends keyof HtmxEventDetail> = Pick<Required<HtmxEventDetail>, TProperties> & {
1219
+ [K in Exclude<keyof HtmxEventDetail, TProperties>]?: never;
1220
+ };
1221
+
1222
+ type HtmxAbortEventProperties = 'boosted' | 'elt' | 'error' | 'etc' | 'pathInfo' | 'requestConfig' | 'select' | 'target' | 'xhr';
1223
+ interface HtmxAbortEvent extends HtmxDomEvent {
1224
+ detail: Detail<HtmxAbortEventProperties>;
1225
+ type: 'htmx:abort';
1226
+ }
1227
+
1228
+ type HtmxAfterOnLoadEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1229
+ interface HtmxAfterOnLoadEvent extends HtmxDomEvent {
1230
+ detail: Detail<HtmxAfterOnLoadEventProperties>;
1231
+ type: 'htmx:afterOnLoad';
1232
+ }
1233
+
1234
+ type HtmxAfterProcessNodeEventProperties = 'elt';
1235
+ interface HtmxAfterProcessNodeEvent extends HtmxDomEvent {
1236
+ detail: Detail<HtmxAfterProcessNodeEventProperties>;
1237
+ type: 'htmx:afterProcessNode';
1238
+ }
1239
+
1240
+ type HtmxAfterRequestEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1241
+ interface HtmxAfterRequestEvent extends HtmxDomEvent {
1242
+ detail: Detail<HtmxAfterRequestEventProperties>;
1243
+ type: 'htmx:afterRequest';
1244
+ }
1245
+
1246
+ type HtmxAfterSettleEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1247
+ interface HtmxAfterSettleEvent extends HtmxDomEvent {
1248
+ detail: Detail<HtmxAfterSettleEventProperties>;
1249
+ type: 'htmx:afterSettle';
1250
+ }
1251
+
1252
+ type HtmxAfterSwapEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1253
+ interface HtmxAfterSwapEvent extends HtmxDomEvent {
1254
+ detail: Detail<HtmxAfterSwapEventProperties>;
1255
+ type: 'htmx:afterSwap';
1256
+ }
1257
+
1258
+ type HtmxBeforeCleanupElementEventProperties = 'elt';
1259
+ interface HtmxBeforeCleanupElementEvent extends HtmxDomEvent {
1260
+ detail: Detail<HtmxBeforeCleanupElementEventProperties>;
1261
+ type: 'htmx:beforeCleanupElement';
1262
+ }
1263
+
1264
+ type HtmxBeforeHistorySaveEventProperties = 'elt' | 'historyElt' | 'path';
1265
+ interface HtmxBeforeHistorySaveEvent extends HtmxDomEvent {
1266
+ detail: Detail<HtmxBeforeHistorySaveEventProperties>;
1267
+ type: 'htmx:beforeHistorySave';
1268
+ }
1269
+
1270
+ type HtmxBeforeOnLoadEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1271
+ interface HtmxBeforeOnLoadEvent extends HtmxDomEvent {
1272
+ detail: Detail<HtmxBeforeOnLoadEventProperties>;
1273
+ type: 'htmx:beforeOnLoad';
1274
+ }
1275
+
1276
+ type HtmxBeforeProcessNodeEventProperties = 'elt';
1277
+ interface HtmxBeforeProcessNodeEvent extends HtmxDomEvent {
1278
+ detail: Detail<HtmxBeforeProcessNodeEventProperties>;
1279
+ type: 'htmx:beforeProcessNode';
1280
+ }
1281
+
1282
+ type HtmxBeforeRequestEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1283
+ interface HtmxBeforeRequestEvent extends HtmxDomEvent {
1284
+ detail: Detail<HtmxBeforeRequestEventProperties>;
1285
+ type: 'htmx:beforeRequest';
1286
+ }
1287
+
1288
+ type HtmxBeforeSendEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1289
+ interface HtmxBeforeSendEvent extends HtmxDomEvent {
1290
+ detail: Detail<HtmxBeforeSendEventProperties>;
1291
+ type: 'htmx:beforeSend';
1292
+ }
1293
+
1294
+ type HtmxBeforeSwapEventProperties = 'boosted' | 'elt' | 'etc' | 'ignoreTitle' | 'isError' | 'pathInfo' | 'requestConfig' | 'select' | 'selectOverride' | 'serverResponse' | 'shouldSwap' | 'swapOverride' | 'target' | 'xhr';
1295
+ interface HtmxBeforeSwapEvent extends HtmxDomEvent {
1296
+ detail: Detail<HtmxBeforeSwapEventProperties>;
1297
+ type: 'htmx:beforeSwap';
1298
+ }
1299
+
1300
+ type HtmxBeforeTransitionEventProperties = 'boosted' | 'elt' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1301
+ interface HtmxBeforeTransitionEvent extends HtmxDomEvent {
1302
+ detail: Detail<HtmxBeforeTransitionEventProperties>;
1303
+ type: 'htmx:beforeTransition';
1304
+ }
1305
+
1306
+ type HtmxConfigRequestEventProperties = 'boosted' | 'elt' | 'errors' | 'formData' | 'headers' | 'parameters' | 'path' | 'target' | 'timeout' | 'triggeringEvent' | 'unfilteredFormData' | 'unfilteredParameters' | 'useUrlParams' | 'verb' | 'withCredentials';
1307
+ interface HtmxConfigRequestEvent extends HtmxDomEvent {
1308
+ detail: Detail<HtmxConfigRequestEventProperties>;
1309
+ type: 'htmx:configRequest';
1310
+ }
1311
+
1312
+ type HtmxConfirmEventProperties = 'elt' | 'etc' | 'issueRequest' | 'path' | 'question' | 'target' | 'triggeringEvent' | 'verb';
1313
+ interface HtmxConfirmEvent extends HtmxDomEvent {
1314
+ detail: Detail<HtmxConfirmEventProperties>;
1315
+ type: 'htmx:confirm';
1316
+ }
1317
+
1318
+ type HtmxHistoryCacheErrorEventProperties = 'error' | 'path' | 'target';
1319
+ interface HtmxHistoryCacheErrorEvent extends HtmxDomEvent {
1320
+ detail: Detail<HtmxHistoryCacheErrorEventProperties>;
1321
+ type: 'htmx:historyCacheError';
1322
+ }
1323
+
1324
+ type HtmxHistoryCacheHitEventProperties = 'item' | 'target';
1325
+ interface HtmxHistoryCacheHitEvent extends HtmxDomEvent {
1326
+ detail: Detail<HtmxHistoryCacheHitEventProperties>;
1327
+ type: 'htmx:historyCacheHit';
1328
+ }
1329
+
1330
+ type HtmxHistoryCacheMissEventProperties = 'path' | 'target';
1331
+ interface HtmxHistoryCacheMissEvent extends HtmxDomEvent {
1332
+ detail: Detail<HtmxHistoryCacheMissEventProperties>;
1333
+ type: 'htmx:historyCacheMiss';
1334
+ }
1335
+
1336
+ type HtmxHistoryCacheMissLoadErrorEventProperties = 'path' | 'target' | 'xhr';
1337
+ interface HtmxHistoryCacheMissLoadErrorEvent extends HtmxDomEvent {
1338
+ detail: Detail<HtmxHistoryCacheMissLoadErrorEventProperties>;
1339
+ type: 'htmx:historyCacheMissLoadError';
1340
+ }
1341
+
1342
+ type HtmxHistoryCacheMissLoadEventProperties = 'historyElt' | 'path' | 'response' | 'swapSpec' | 'xhr';
1343
+ interface HtmxHistoryCacheMissLoadEvent extends HtmxDomEvent {
1344
+ detail: Detail<HtmxHistoryCacheMissLoadEventProperties>;
1345
+ type: 'htmx:historyCacheMissLoad';
1346
+ }
1347
+
1348
+ type HtmxHistoryRestoreEventProperties = 'elt' | 'historyElt' | 'item' | 'path' | 'swapSpec';
1349
+ interface HtmxHistoryRestoreEvent extends HtmxDomEvent {
1350
+ detail: Detail<HtmxHistoryRestoreEventProperties>;
1351
+ type: 'htmx:historyRestore';
1352
+ }
1353
+
1354
+ type HtmxLoadEventProperties = 'elt';
1355
+ interface HtmxLoadEvent extends HtmxDomEvent {
1356
+ detail: Detail<HtmxLoadEventProperties>;
1357
+ type: 'htmx:load';
1358
+ }
1359
+
1360
+ type HtmxNoSseSourceErrorEventProperties = 'error' | 'source';
1361
+ interface HtmxNoSseSourceErrorEvent extends HtmxDomEvent {
1362
+ detail: Detail<HtmxNoSseSourceErrorEventProperties>;
1363
+ type: 'htmx:noSSESourceError';
1364
+ }
1365
+
1366
+ type HtmxOnLoadErrorEventProperties = 'elt' | 'error' | 'exception' | 'pathInfo' | 'requestConfig' | 'target' | 'xhr';
1367
+ interface HtmxOnLoadErrorEvent extends HtmxDomEvent {
1368
+ detail: Detail<HtmxOnLoadErrorEventProperties>;
1369
+ type: 'htmx:onLoadError';
1370
+ }
1371
+
1372
+ type HtmxOobAfterSwapEventProperties = 'elt' | 'fragment' | 'shouldSwap' | 'target';
1373
+ interface HtmxOobAfterSwapEvent extends HtmxDomEvent {
1374
+ detail: Detail<HtmxOobAfterSwapEventProperties>;
1375
+ type: 'htmx:oobAfterSwap';
1376
+ }
1377
+
1378
+ type HtmxOobBeforeSwapEventProperties = 'elt' | 'fragment' | 'shouldSwap' | 'target';
1379
+ interface HtmxOobBeforeSwapEvent extends HtmxDomEvent {
1380
+ detail: Detail<HtmxOobBeforeSwapEventProperties>;
1381
+ type: 'htmx:oobBeforeSwap';
1382
+ }
1383
+
1384
+ type HtmxOobErrorNoTargetEventProperties = 'content' | 'elt' | 'error';
1385
+ interface HtmxOobErrorNoTargetEvent extends HtmxDomEvent {
1386
+ detail: Detail<HtmxOobErrorNoTargetEventProperties>;
1387
+ type: 'htmx:oobErrorNoTarget';
1388
+ }
1389
+
1390
+ type HtmxPromptEventProperties = 'elt' | 'prompt' | 'target';
1391
+ interface HtmxPromptEvent extends HtmxDomEvent {
1392
+ detail: Detail<HtmxPromptEventProperties>;
1393
+ type: 'htmx:prompt';
1394
+ }
1395
+
1396
+ type HtmxPushedIntoHistoryEventProperties = 'elt' | 'path';
1397
+ interface HtmxPushedIntoHistoryEvent extends HtmxDomEvent {
1398
+ detail: Detail<HtmxPushedIntoHistoryEventProperties>;
1399
+ type: 'htmx:pushedIntoHistory';
1400
+ }
1401
+
1402
+ type HtmxReplacedInHistoryEventProperties = 'elt' | 'path';
1403
+ interface HtmxReplacedInHistoryEvent extends HtmxDomEvent {
1404
+ detail: Detail<HtmxReplacedInHistoryEventProperties>;
1405
+ type: 'htmx:replacedInHistory';
1406
+ }
1407
+
1408
+ type HtmxResponseErrorEventProperties = 'boosted' | 'elt' | 'error' | 'etc' | 'failed' | 'pathInfo' | 'requestConfig' | 'select' | 'successful' | 'target' | 'xhr';
1409
+ interface HtmxResponseErrorEvent extends HtmxDomEvent {
1410
+ detail: Detail<HtmxResponseErrorEventProperties>;
1411
+ type: 'htmx:responseError';
1412
+ }
1413
+
1414
+ type HtmxSendAbortEventProperties = 'boosted' | 'elt' | 'error' | 'etc' | 'pathInfo' | 'requestConfig' | 'select' | 'target' | 'xhr';
1415
+ interface HtmxSendAbortEvent extends HtmxDomEvent {
1416
+ detail: Detail<HtmxSendAbortEventProperties>;
1417
+ type: 'htmx:sendAbort';
1418
+ }
1419
+
1420
+ type HtmxSendErrorEventProperties = 'elt' | 'requestConfig' | 'target' | 'xhr';
1421
+ interface HtmxSendErrorEvent extends HtmxDomEvent {
1422
+ detail: Detail<HtmxSendErrorEventProperties>;
1423
+ type: 'htmx:sendError';
1424
+ }
1425
+
1426
+ type HtmxSseErrorEventProperties = 'error' | 'event' | 'source';
1427
+ interface HtmxSseErrorEvent extends HtmxDomEvent {
1428
+ detail: Detail<HtmxSseErrorEventProperties>;
1429
+ type: 'htmx:sseError';
1430
+ }
1431
+
1432
+ type HtmxSseOpenEventProperties = 'event' | 'source';
1433
+ interface HtmxSseOpenEvent extends HtmxDomEvent {
1434
+ detail: Detail<HtmxSseOpenEventProperties>;
1435
+ type: 'htmx:sseOpen';
1436
+ }
1437
+
1438
+ type HtmxSwapErrorEventProperties = 'elt' | 'requestConfig' | 'target' | 'xhr';
1439
+ interface HtmxSwapErrorEvent extends HtmxDomEvent {
1440
+ detail: Detail<HtmxSwapErrorEventProperties>;
1441
+ type: 'htmx:swapError';
1442
+ }
1443
+
1444
+ type HtmxTargetErrorEventProperties = 'elt' | 'error' | 'target';
1445
+ interface HtmxTargetErrorEvent extends HtmxDomEvent {
1446
+ detail: Detail<HtmxTargetErrorEventProperties>;
1447
+ type: 'htmx:targetError';
1448
+ }
1449
+
1450
+ type HtmxTimeoutEventProperties = 'elt' | 'requestConfig' | 'target' | 'xhr';
1451
+ interface HtmxTimeoutEvent extends HtmxDomEvent {
1452
+ detail: Detail<HtmxTimeoutEventProperties>;
1453
+ type: 'htmx:timeout';
1454
+ }
1455
+
1456
+ type HtmxValidateUrlEventProperties = 'url' | 'sameHost';
1457
+ interface HtmxValidateUrlEvent extends HtmxDomEvent {
1458
+ detail: Detail<HtmxValidateUrlEventProperties>;
1459
+ type: 'htmx:validateUrl';
1460
+ }
1461
+
1462
+ type HtmxValidationFailedEventProperties = 'elt' | 'message' | 'validity';
1463
+ interface HtmxValidationFailedEvent extends HtmxDomEvent {
1464
+ detail: Detail<HtmxValidationFailedEventProperties>;
1465
+ type: 'htmx:validation:failed';
1466
+ }
1467
+
1468
+ type HtmxValidationHaltedEventProperties = 'boosted' | 'elt' | 'errors' | 'formData' | 'headers' | 'parameters' | 'path' | 'target' | 'timeout' | 'triggeringEvent' | 'unfilteredFormData' | 'unfilteredParameters' | 'useUrlParams' | 'verb' | 'withCredentials';
1469
+ interface HtmxValidationHaltedEvent extends HtmxDomEvent {
1470
+ detail: Detail<HtmxValidationHaltedEventProperties>;
1471
+ type: 'htmx:validation:halted';
1472
+ }
1473
+
1474
+ type HtmxValidationValidateEventProperties = 'elt';
1475
+ interface HtmxValidationValidateEvent extends HtmxDomEvent {
1476
+ detail: Detail<HtmxValidationValidateEventProperties>;
1477
+ type: 'htmx:validation:validate';
1478
+ }
1479
+
1480
+ type HtmxXhrAbortEventProperties = 'elt' | 'lengthComputable' | 'loaded' | 'total';
1481
+ interface HtmxXhrAbortEvent extends HtmxDomEvent {
1482
+ detail: Detail<HtmxXhrAbortEventProperties>;
1483
+ type: 'htmx:xhr:abort';
1484
+ }
1485
+
1486
+ type HtmxXhrLoadendEventProperties = 'elt' | 'lengthComputable' | 'loaded' | 'total';
1487
+ interface HtmxXhrLoadendEvent extends HtmxDomEvent {
1488
+ detail: Detail<HtmxXhrLoadendEventProperties>;
1489
+ type: 'htmx:xhr:loadend';
1490
+ }
1491
+
1492
+ type HtmxXhrLoadstartEventProperties = 'elt' | 'lengthComputable' | 'loaded' | 'total';
1493
+ interface HtmxXhrLoadstartEvent extends HtmxDomEvent {
1494
+ detail: Detail<HtmxXhrLoadstartEventProperties>;
1495
+ type: 'htmx:xhr:loadstart';
1496
+ }
1497
+
1498
+ type HtmxXhrProgressEventProperties = 'elt' | 'lengthComputable' | 'loaded' | 'total';
1499
+ interface HtmxXhrProgressEvent extends HtmxDomEvent {
1500
+ detail: Detail<HtmxXhrProgressEventProperties>;
1501
+ type: 'htmx:xhr:progress';
1502
+ }
1503
+
1504
+ interface Logger {
1505
+ debug: (msg: string, ...args: any[]) => void;
1506
+ error: (msg: string, ...args: any[]) => void;
1507
+ info: (msg: string, ...args: any[]) => void;
1508
+ warn: (msg: string, ...args: any[]) => void;
1509
+ }
1510
+
1511
+ interface JhxConfig {
1512
+ logger?: Logger;
1513
+ stringify?: boolean;
1514
+ escape?: boolean;
1515
+ }
1516
+
1517
+ /**
1518
+ * Properties for handling standard DOM events.
1519
+ *
1520
+ * Note: The `stringify` config property must be set to `true` since in-line
1521
+ * DOM event handlers are stripped during rendering.
1522
+ */
1523
+ interface CommonDomEventProps<TDom extends object = object> {
1524
+ onClick?: (args: {
1525
+ event: MouseEvent;
1526
+ } & DomObjects & TDom) => void;
1527
+ onDoubleClick?: (args: {
1528
+ event: MouseEvent;
1529
+ } & DomObjects & TDom) => void;
1530
+ onContextMenu?: (args: {
1531
+ event: MouseEvent;
1532
+ } & DomObjects & TDom) => void;
1533
+ onMouseDown?: (args: {
1534
+ event: MouseEvent;
1535
+ } & DomObjects & TDom) => void;
1536
+ onMouseUp?: (args: {
1537
+ event: MouseEvent;
1538
+ } & DomObjects & TDom) => void;
1539
+ onMouseMove?: (args: {
1540
+ event: MouseEvent;
1541
+ } & DomObjects & TDom) => void;
1542
+ onMouseEnter?: (args: {
1543
+ event: MouseEvent;
1544
+ } & DomObjects & TDom) => void;
1545
+ onMouseLeave?: (args: {
1546
+ event: MouseEvent;
1547
+ } & DomObjects & TDom) => void;
1548
+ onMouseOver?: (args: {
1549
+ event: MouseEvent;
1550
+ } & DomObjects & TDom) => void;
1551
+ onMouseOut?: (args: {
1552
+ event: MouseEvent;
1553
+ } & DomObjects & TDom) => void;
1554
+ onAuxClick?: (args: {
1555
+ event: MouseEvent;
1556
+ } & DomObjects & TDom) => void;
1557
+ onWheel?: (args: {
1558
+ event: WheelEvent;
1559
+ } & DomObjects & TDom) => void;
1560
+ onKeyDown?: (args: {
1561
+ event: KeyboardEvent;
1562
+ } & DomObjects & TDom) => void;
1563
+ onKeyPress?: (args: {
1564
+ event: KeyboardEvent;
1565
+ } & DomObjects & TDom) => void;
1566
+ onKeyUp?: (args: {
1567
+ event: KeyboardEvent;
1568
+ } & DomObjects & TDom) => void;
1569
+ onFocus?: (args: {
1570
+ event: FocusEvent;
1571
+ } & DomObjects & TDom) => void;
1572
+ onBlur?: (args: {
1573
+ event: FocusEvent;
1574
+ } & DomObjects & TDom) => void;
1575
+ onFocusIn?: (args: {
1576
+ event: FocusEvent;
1577
+ } & DomObjects & TDom) => void;
1578
+ onFocusOut?: (args: {
1579
+ event: FocusEvent;
1580
+ } & DomObjects & TDom) => void;
1581
+ onChange?: (args: {
1582
+ event: Event;
1583
+ } & DomObjects & TDom) => void;
1584
+ onInput?: (args: {
1585
+ event: InputEvent;
1586
+ } & DomObjects & TDom) => void;
1587
+ onBeforeInput?: (args: {
1588
+ event: InputEvent;
1589
+ } & DomObjects & TDom) => void;
1590
+ onSubmit?: (args: {
1591
+ event: SubmitEvent;
1592
+ } & DomObjects & TDom) => void;
1593
+ onReset?: (args: {
1594
+ event: Event;
1595
+ } & DomObjects & TDom) => void;
1596
+ onInvalid?: (args: {
1597
+ event: Event;
1598
+ } & DomObjects & TDom) => void;
1599
+ onSelect?: (args: {
1600
+ event: Event;
1601
+ } & DomObjects & TDom) => void;
1602
+ onDrag?: (args: {
1603
+ event: DragEvent;
1604
+ } & DomObjects & TDom) => void;
1605
+ onDragStart?: (args: {
1606
+ event: DragEvent;
1607
+ } & DomObjects & TDom) => void;
1608
+ onDragEnd?: (args: {
1609
+ event: DragEvent;
1610
+ } & DomObjects & TDom) => void;
1611
+ onDragOver?: (args: {
1612
+ event: DragEvent;
1613
+ } & DomObjects & TDom) => void;
1614
+ onDragEnter?: (args: {
1615
+ event: DragEvent;
1616
+ } & DomObjects & TDom) => void;
1617
+ onDragLeave?: (args: {
1618
+ event: DragEvent;
1619
+ } & DomObjects & TDom) => void;
1620
+ onDrop?: (args: {
1621
+ event: DragEvent;
1622
+ } & DomObjects & TDom) => void;
1623
+ onTouchStart?: (args: {
1624
+ event: TouchEvent;
1625
+ } & DomObjects & TDom) => void;
1626
+ onTouchMove?: (args: {
1627
+ event: TouchEvent;
1628
+ } & DomObjects & TDom) => void;
1629
+ onTouchEnd?: (args: {
1630
+ event: TouchEvent;
1631
+ } & DomObjects & TDom) => void;
1632
+ onTouchCancel?: (args: {
1633
+ event: TouchEvent;
1634
+ } & DomObjects & TDom) => void;
1635
+ onPointerDown?: (args: {
1636
+ event: PointerEvent;
1637
+ } & DomObjects & TDom) => void;
1638
+ onPointerMove?: (args: {
1639
+ event: PointerEvent;
1640
+ } & DomObjects & TDom) => void;
1641
+ onPointerUp?: (args: {
1642
+ event: PointerEvent;
1643
+ } & DomObjects & TDom) => void;
1644
+ onPointerCancel?: (args: {
1645
+ event: PointerEvent;
1646
+ } & DomObjects & TDom) => void;
1647
+ onPointerEnter?: (args: {
1648
+ event: PointerEvent;
1649
+ } & DomObjects & TDom) => void;
1650
+ onPointerLeave?: (args: {
1651
+ event: PointerEvent;
1652
+ } & DomObjects & TDom) => void;
1653
+ onPointerOver?: (args: {
1654
+ event: PointerEvent;
1655
+ } & DomObjects & TDom) => void;
1656
+ onPointerOut?: (args: {
1657
+ event: PointerEvent;
1658
+ } & DomObjects & TDom) => void;
1659
+ onGotPointerCapture?: (args: {
1660
+ event: PointerEvent;
1661
+ } & DomObjects & TDom) => void;
1662
+ onLostPointerCapture?: (args: {
1663
+ event: PointerEvent;
1664
+ } & DomObjects & TDom) => void;
1665
+ onCopy?: (args: {
1666
+ event: ClipboardEvent;
1667
+ } & DomObjects & TDom) => void;
1668
+ onCut?: (args: {
1669
+ event: ClipboardEvent;
1670
+ } & DomObjects & TDom) => void;
1671
+ onPaste?: (args: {
1672
+ event: ClipboardEvent;
1673
+ } & DomObjects & TDom) => void;
1674
+ onCompositionStart?: (args: {
1675
+ event: CompositionEvent;
1676
+ } & DomObjects & TDom) => void;
1677
+ onCompositionUpdate?: (args: {
1678
+ event: CompositionEvent;
1679
+ } & DomObjects & TDom) => void;
1680
+ onCompositionEnd?: (args: {
1681
+ event: CompositionEvent;
1682
+ } & DomObjects & TDom) => void;
1683
+ onAnimationStart?: (args: {
1684
+ event: AnimationEvent;
1685
+ } & DomObjects & TDom) => void;
1686
+ onAnimationIteration?: (args: {
1687
+ event: AnimationEvent;
1688
+ } & DomObjects & TDom) => void;
1689
+ onAnimationEnd?: (args: {
1690
+ event: AnimationEvent;
1691
+ } & DomObjects & TDom) => void;
1692
+ onAnimationCancel?: (args: {
1693
+ event: AnimationEvent;
1694
+ } & DomObjects & TDom) => void;
1695
+ onTransitionStart?: (args: {
1696
+ event: TransitionEvent;
1697
+ } & DomObjects & TDom) => void;
1698
+ onTransitionEnd?: (args: {
1699
+ event: TransitionEvent;
1700
+ } & DomObjects & TDom) => void;
1701
+ onTransitionRun?: (args: {
1702
+ event: TransitionEvent;
1703
+ } & DomObjects & TDom) => void;
1704
+ onTransitionCancel?: (args: {
1705
+ event: TransitionEvent;
1706
+ } & DomObjects & TDom) => void;
1707
+ onScroll?: (args: {
1708
+ event: Event;
1709
+ } & DomObjects & TDom) => void;
1710
+ onResize?: (args: {
1711
+ event: UIEvent;
1712
+ } & DomObjects & TDom) => void;
1713
+ onToggle?: (args: {
1714
+ event: Event;
1715
+ } & DomObjects & TDom) => void;
1716
+ }
1717
+ type CustomDomEvent<TArgs> = {
1718
+ event(args: TArgs): void;
1719
+ }['event'];
1720
+ type CustomDomEventProps<TDom extends object = object> = {
1721
+ [K in `on${string}` as Exclude<K, keyof CommonDomEventProps<TDom> | keyof HtmxEventProps>]?: CustomDomEvent<{
1722
+ event: Event;
1723
+ } & DomObjects & TDom>;
1724
+ };
1725
+ type DomEventProps<TDom extends object = object> = CommonDomEventProps<TDom> & CustomDomEventProps<TDom>;
1726
+
1727
+ type JhxAttribute = HtmxAttribute | HtmxEventAttribute | Lowercase<keyof DomEventProps> | Lowercase<Exclude<keyof DOMAttributes<any>, 'children' | 'dangerouslySetInnerHTML'>>;
1728
+
1729
+ /**
1730
+ * - If the value is an `object` or `string`, it is evaluated server-side at render time.
1731
+ * - If the value is a `function`, it is evaluated client-side when triggered.
1732
+ * @template TDom Type for additional parameters received from the DOM.
1733
+ */
1734
+ type JhxEvaluableAttribute<TBaseDom extends object = object> = (<TDom extends TBaseDom | object = object>(dom: DomObjects & TDom) => Record<string, any> | object) | Record<string, any> | object | string;
1735
+
1736
+ type JhxExtensionAttribute = Array<string | {
1737
+ /** The name of the HTMX extension. */
1738
+ name: HtmxDefaultExtension | (string & {});
1739
+ /** Whether the extension will be ignored for the element (defaults to `false`). */
1740
+ ignore?: boolean;
1741
+ }> | {
1742
+ /** The name of the HTMX extension. */
1743
+ name: HtmxDefaultExtension | (string & {});
1744
+ /** Whether the extension will be ignored for the element (defaults to `false`). */
1745
+ ignore?: boolean;
1746
+ } | HtmxDefaultExtension | (string & {});
1747
+
1748
+ type JhxIndicatorAttribute = {
1749
+ selector: string;
1750
+ /** Defaults to `false`. */
1751
+ closest?: boolean;
1752
+ /** Defaults to `false`. */
1753
+ inherit?: boolean;
1754
+ } | string;
1755
+
1756
+ type JhxInheritAttribute = Array<HtmxAttribute | (string & {})> | HtmxAttribute | '*' | (string & {});
1757
+
1758
+ type JhxParamsAttribute = {
1759
+ include: string[];
1760
+ exclude?: never;
1761
+ } | {
1762
+ include?: never;
1763
+ exclude: string[];
1764
+ } | '*' | 'none' | (string & {});
1765
+
1766
+ interface JhxRequestArgs {
1767
+ timeout?: number;
1768
+ credentials?: boolean;
1769
+ noHeaders?: boolean;
1770
+ }
1771
+ /**
1772
+ * - If the value is an `object` or `string`, it is evaluated server-side at render time.
1773
+ * - If the value is a `function`, it is evaluated client-side when triggered.
1774
+ */
1775
+ type JhxRequestAttribute<
1776
+ /** Type for additional parameters received from the DOM. */
1777
+ TDom extends object = object> = ((dom: DomObjects & TDom) => JhxRequestArgs) | JhxRequestArgs | string;
1778
+
1779
+ type JhxSelectOobAttribute = Array<string | {
1780
+ selector: string;
1781
+ swap?: HtmxSwapStyle;
1782
+ }> | {
1783
+ selector: string;
1784
+ swap?: HtmxSwapStyle;
1785
+ } | string;
1786
+
1787
+ type JhxSwapScroll = 'top' | 'bottom' | {
1788
+ selector: string;
1789
+ position: 'top' | 'bottom';
1790
+ } | {
1791
+ window: true;
1792
+ position: 'top' | 'bottom';
1793
+ };
1794
+ type JhxSwapShow = 'none' | JhxSwapScroll;
1795
+ type JhxSwapAttribute = (HtmxSwapStyle | (string & {})) | {
1796
+ /** The swap style. */
1797
+ style?: HtmxSwapStyle | (string & {});
1798
+ /** The duration of time that htmx will wait to swap the content after receiving a response. */
1799
+ swap?: Duration;
1800
+ /** The duration of time that htmx will wait to settle after swapping. */
1801
+ settle?: Duration;
1802
+ /**
1803
+ * Whether the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API) will be used.
1804
+ */
1805
+ transition?: boolean;
1806
+ /**
1807
+ * Specifies the scrolling behavior after the swap.
1808
+ * Can be `'top'`, `'bottom'`, or an object specifying a selector and position.
1809
+ */
1810
+ scroll?: JhxSwapScroll;
1811
+ /**
1812
+ * Specifies which element to show in the viewport after the swap.
1813
+ * Can be `'top'`, `'bottom'`, `'none'`, or an object specifying a selector and position.
1814
+ */
1815
+ show?: JhxSwapShow;
1816
+ /**
1817
+ * Whether htmx will update the page title when the response contains a `<title>` element.
1818
+ * Defaults to `false`.
1819
+ */
1820
+ ignoreTitle?: boolean;
1821
+ /**
1822
+ * Whether the `<input>` focus is maintained between requests. The `<input>` element must have an `id` attribute.
1823
+ *
1824
+ * Defaults to `false`.
1825
+ */
1826
+ focusScroll?: boolean;
1827
+ };
1828
+
1829
+ type JhxSwapOobAttribute = {
1830
+ swap: HtmxSwapStyle;
1831
+ selector?: string;
1832
+ } | HtmxSwapStyle | boolean | (string & {});
1833
+
1834
+ type JhxSyncAttribute = {
1835
+ strategy: HtmxSyncStrategy;
1836
+ tag: string;
1837
+ closest?: boolean;
1838
+ } | {
1839
+ strategy: HtmxSyncStrategy;
1840
+ tag?: never;
1841
+ closest?: never;
1842
+ } | string;
1843
+
1844
+ type TargetAttribute = {
1845
+ inherit?: never;
1846
+ position?: 'closest' | 'next' | 'previous' | 'find';
1847
+ selector: string;
1848
+ } | {
1849
+ inherit?: never;
1850
+ position: 'this' | 'next' | 'previous';
1851
+ selector?: never;
1852
+ } | {
1853
+ inherit: boolean;
1854
+ position?: never;
1855
+ selector?: never;
1856
+ };
1857
+ type JhxTargetAttribute = Array<TargetAttribute | string> | TargetAttribute | string;
1858
+
1859
+ type JhxTriggerQueue = 'first' | 'last' | 'all' | 'none';
1860
+ type JhxTriggerFrom = {
1861
+ selector: string;
1862
+ op?: 'closest' | 'next' | 'previous' | 'find';
1863
+ } | {
1864
+ selector?: never;
1865
+ op: 'this' | 'document' | 'window';
1866
+ } | string;
1867
+ type ConditionalFunction = ConditionalFunction$1;
1868
+ interface JhxTriggerModifier {
1869
+ changed?: boolean;
1870
+ consume?: boolean;
1871
+ delay?: Duration;
1872
+ event?: string;
1873
+ filter?: ConditionalFunction | string;
1874
+ from?: JhxTriggerFrom;
1875
+ once?: boolean;
1876
+ queue?: JhxTriggerQueue;
1877
+ target?: JhxTargetAttribute;
1878
+ throttle?: Duration;
1879
+ }
1880
+ interface JhxTriggerAttribute_Standard extends JhxTriggerModifier {
1881
+ trigger: 'load' | 'revealed' | (string & {});
1882
+ }
1883
+ interface JhxTriggerAttribute_Intersect extends JhxTriggerModifier {
1884
+ trigger: 'intersect';
1885
+ root?: string;
1886
+ threshold?: number;
1887
+ }
1888
+ interface JhxTriggerAttribute_Poll extends JhxTriggerModifier {
1889
+ poll: Duration;
1890
+ trigger?: never;
1891
+ }
1892
+ type JhxTriggerAttribute = JhxTriggerAttribute_Standard | JhxTriggerAttribute_Intersect | JhxTriggerAttribute_Poll | (JhxTriggerAttribute_Standard | JhxTriggerAttribute_Intersect | JhxTriggerAttribute_Poll | string)[] | string;
1893
+
1894
+ /** @template TDom Additional variables that are available in the DOM. */
1895
+ interface HtmxProps<TDom extends object = object> {
1896
+ boost?: boolean;
1897
+ confirm?: string;
1898
+ delete?: string;
1899
+ disable?: boolean;
1900
+ disabledElt?: JhxTargetAttribute;
1901
+ disinherit?: JhxInheritAttribute;
1902
+ encoding?: string;
1903
+ ext?: JhxExtensionAttribute;
1904
+ get?: string;
1905
+ headers?: JhxEvaluableAttribute<TDom>;
1906
+ history?: boolean;
1907
+ historyElt?: boolean;
1908
+ include?: JhxTargetAttribute;
1909
+ indicator?: JhxIndicatorAttribute;
1910
+ inherit?: JhxInheritAttribute;
1911
+ patch?: string;
1912
+ params?: JhxParamsAttribute;
1913
+ post?: string;
1914
+ preserve?: boolean;
1915
+ prompt?: string;
1916
+ pushUrl?: boolean | string;
1917
+ put?: string;
1918
+ replaceUrl?: boolean | string;
1919
+ request?: JhxRequestAttribute<TDom>;
1920
+ select?: string;
1921
+ selectOob?: JhxSelectOobAttribute;
1922
+ swap?: JhxSwapAttribute;
1923
+ swapOob?: JhxSwapOobAttribute;
1924
+ sync?: JhxSyncAttribute;
1925
+ target?: JhxTargetAttribute;
1926
+ trigger?: JhxTriggerAttribute;
1927
+ validate?: boolean;
1928
+ vals?: JhxEvaluableAttribute<TDom>;
1929
+ /** Deprecated. Use `vals` instead. */
1930
+ vars?: never;
1931
+ }
1932
+
1933
+ type JhxRouteProps = {
1934
+ route?: string;
1935
+ method?: HtmxHttpMethod;
1936
+ };
1937
+
1938
+ /**
1939
+ * Properties for configuring HTMX behavior, events, and methods.
1940
+ * @template TDom Type for additional parameters received from the DOM.
1941
+ */
1942
+ type JhxProps<TDom extends object = object> = HtmxProps<TDom> & HtmxEventProps<TDom> & JhxRouteProps & {};
1943
+ /**
1944
+ * Properties for configuring HTMX behavior, events, methods, and standard DOM events.
1945
+ * @template TDom Type for additional parameters received from the DOM.
1946
+ */
1947
+ type JhxDomProps<TDom extends object = object> = HtmxProps<TDom> & HtmxEventProps<TDom> & JhxRouteProps & DomEventProps<TDom> & {};
1948
+
1949
+ type NativeProps<TTag extends ElementType> = Omit<ComponentPropsWithoutRef<TTag>, 'children' | keyof JhxProps<any>>;
1950
+ type JhxComponentProps<TDom extends object = object, TTag extends ElementType = 'div'> = JhxProps<TDom> & NativeProps<TTag> & {
1951
+ jhxConfig?: Omit<JhxConfig, 'stringify'>;
1952
+ as?: TTag;
1953
+ };
1954
+ declare const JhxComponent: <TDom extends object = object, TTag extends ElementType = "div">(props: PropsWithChildren<JhxComponentProps<TDom, TTag>>) => JSX.Element;
1955
+ type JhxComponentType<TDom extends object = object, TTag extends keyof JSX.IntrinsicElements = 'div'> = typeof JhxComponent<TDom, TTag>;
1956
+
1957
+ /**
1958
+ * Applies a key-value pairs of HTML attributes to a given element.
1959
+ *
1960
+ * @param element The target HTML element to apply the attributes to.
1961
+ * @param attributes An object containing key-value pairs of HTML attributes.
1962
+ *
1963
+ * @example
1964
+ * ```ts
1965
+ * import { applyAttributes } from 'jhx';
1966
+ *
1967
+ * const button = document.createElement('button');
1968
+ * applyAttributes(button, {
1969
+ * 'hx-get': '/api',
1970
+ * 'hx-swap': 'outerHTML',
1971
+ * 'custom-attribute': { id: 123, name: 'test' },
1972
+ * });
1973
+ * ```
1974
+ */
1975
+ declare const applyAttributes: (element: Element, attributes: Record<string, unknown>) => void;
1976
+
1977
+ /**
1978
+ * Converts a record of HTML attributes into an HTML element attribute string.
1979
+ *
1980
+ * Typically used to format the attributes before sending to the client.
1981
+ *
1982
+ * @param attributes An object containing key-value pairs of HTML attributes.
1983
+ * @param escape Whether to escape the HTML characters within string values. Defaults to `true`.
1984
+ *
1985
+ * @example
1986
+ * ```ts
1987
+ * import { attributesToString } from 'jhx';
1988
+ *
1989
+ * const attrs = attributesToString({
1990
+ * 'hx-get': '/api',
1991
+ * 'hx-swap': 'outerHTML',
1992
+ * });
1993
+ * // 'hx-get="/api" hx-swap="outerHTML"'
1994
+ *
1995
+ * const html = `<button ${attrs}>Click Me</button>`;
1996
+ * ```
1997
+ */
1998
+ declare const attributesToString: (attributes: Record<string, unknown>, escape?: boolean) => string;
1999
+
2000
+ type JhxDefaultConfig = Required<JhxConfig>;
2001
+ /**
2002
+ * Default jhx configuration
2003
+ */
2004
+ declare const defaultConfig: JhxDefaultConfig;
2005
+
2006
+ /**
2007
+ * Escapes HTML special characters in all string values within the provided object.
2008
+ *
2009
+ * @param attributes An object containing key-value pairs of HTML attributes.
2010
+ */
2011
+ declare const escapeAttributes: <T = Record<string, any>>(attributes: Record<string, any>) => T;
2012
+
2013
+ /**
2014
+ * Returns an object or string containing HTMX and HTML attributes.
2015
+ * @template TDom Type for additional parameters from within the DOM. Defaults to `object`.
2016
+ */
2017
+ declare function jhx<TDom extends object = object>(props: JhxDomProps<TDom>, config: Omit<JhxConfig, 'stringify'> & {
2018
+ stringify: true;
2019
+ }): string;
2020
+ declare function jhx<TDom extends object = object>(props: JhxProps<TDom>, config: Omit<JhxConfig, 'stringify'> & {
2021
+ stringify: false;
2022
+ }): Record<JhxAttribute, string>;
2023
+ declare function jhx<TDom extends object = object>(props: JhxProps<TDom>, config?: Omit<JhxConfig, 'stringify'> & {
2024
+ stringify?: false;
2025
+ }): Record<JhxAttribute, string>;
2026
+
2027
+ type JhxErrorAttribute = 'hx-headers' | 'hx-request' | 'hx-vals';
2028
+ interface JhxError extends Error {
2029
+ attribute: JhxErrorAttribute;
2030
+ message: JhxHeadersError['message'] | JhxRequestError['message'] | JhxValsError['message'] | (string & {});
2031
+ }
2032
+ interface JhxHeadersError extends JhxError {
2033
+ attribute: 'hx-headers';
2034
+ message: "[jhx] Error while parsing 'hx-headers' object";
2035
+ }
2036
+ interface JhxRequestError extends JhxError {
2037
+ attribute: 'hx-request';
2038
+ message: "[jhx] Error while parsing 'hx-request' object";
2039
+ }
2040
+ interface JhxValsError extends JhxError {
2041
+ attribute: 'hx-vals';
2042
+ message: "[jhx] Error while parsing 'hx-vals' object";
2043
+ }
2044
+ declare class JhxErrorThrowable extends Error implements JhxError {
2045
+ attribute: JhxErrorAttribute;
2046
+ constructor(message: JhxError['message'], options: {
2047
+ attribute: JhxErrorAttribute;
2048
+ cause?: unknown;
2049
+ stack?: string;
2050
+ });
2051
+ }
2052
+
2053
+ export { JhxComponent, JhxErrorThrowable, applyAttributes, attributesToString, defaultConfig, escapeAttributes, htmx, jhx };
2054
+ export type { ConditionalFunction, CustomDomEventProps, DomEventProps, DomObjects, Duration, HtmxAbortEvent, HtmxAfterOnLoadEvent, HtmxAfterProcessNodeEvent, HtmxAfterRequestEvent, HtmxAfterSettleEvent, HtmxAfterSwapEvent, HtmxAjaxEtc, HtmxAjaxHandler, HtmxAttribute, HtmxBeforeCleanupElementEvent, HtmxBeforeHistorySaveEvent, HtmxBeforeOnLoadEvent, HtmxBeforeProcessNodeEvent, HtmxBeforeRequestEvent, HtmxBeforeSendEvent, HtmxBeforeSwapEvent, HtmxBeforeTransitionEvent, HtmxCacheItem, HtmxClass, HtmxConfig, HtmxConfigRequestEvent, HtmxConfirmEvent, HtmxDefaultExtension, HtmxDomEvent, HtmxElementValidationError, HtmxEvent, HtmxEventAttribute, HtmxEventDetail, HtmxEventName, HtmxEventProps, HtmxExtension, HtmxExtensionMetadata, HtmxHistoryCacheErrorEvent, HtmxHistoryCacheHitEvent, HtmxHistoryCacheMissEvent, HtmxHistoryCacheMissLoadErrorEvent, HtmxHistoryCacheMissLoadEvent, HtmxHistoryRestoreEvent, HtmxHttpMethod, HtmxHttpVerb, HtmxInstance, HtmxIssueRequest, HtmxLoadEvent, HtmxMethodAttribute, HtmxNoSseSourceErrorEvent, HtmxOnLoadErrorEvent, HtmxOobAfterSwapEvent, HtmxOobBeforeSwapEvent, HtmxOobErrorNoTargetEvent, HtmxPathInfo, HtmxPromptEvent, HtmxProps, HtmxPushedIntoHistoryEvent, HtmxReplacedInHistoryEvent, HtmxRequestConfig, HtmxRequestHeader, HtmxResponseErrorEvent, HtmxResponseHandlingConfig, HtmxResponseHeader, HtmxSendAbortEvent, HtmxSendErrorEvent, HtmxSettleInfo, HtmxSseErrorEvent, HtmxSseOpenEvent, HtmxSwapErrorEvent, HtmxSwapSpec, HtmxSwapStyle, HtmxSyncStrategy, HtmxTargetErrorEvent, HtmxTimeoutEvent, HtmxValidateUrlEvent, HtmxValidationFailedEvent, HtmxValidationHaltedEvent, HtmxValidationValidateEvent, HtmxXhrAbortEvent, HtmxXhrLoadendEvent, HtmxXhrLoadstartEvent, HtmxXhrProgressEvent, JhxAttribute, JhxComponentProps, JhxComponentType, JhxConfig, JhxDefaultConfig, JhxDomProps, JhxError, JhxErrorAttribute, JhxEvaluableAttribute, JhxExtensionAttribute, JhxHeadersError, JhxIndicatorAttribute, JhxInheritAttribute, JhxParamsAttribute, JhxProps, JhxRequestArgs, JhxRequestAttribute, JhxRequestError, JhxRouteProps, JhxSelectOobAttribute, JhxSwapAttribute, JhxSwapOobAttribute, JhxSwapScroll, JhxSwapShow, JhxSyncAttribute, JhxTargetAttribute, JhxTriggerAttribute, JhxTriggerAttribute_Intersect, JhxTriggerAttribute_Poll, JhxTriggerAttribute_Standard, JhxTriggerFrom, JhxTriggerQueue, JhxValsError, Logger };