domma-js 0.55.0 → 0.57.0
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/assets/types/generated/public/assets/flags/africa.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/americas.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/asia.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/europe.d.ts +9 -0
- package/assets/types/generated/public/assets/flags/index.d.ts +11 -0
- package/assets/types/generated/public/assets/flags/oceania.d.ts +2 -0
- package/assets/types/generated/public/assets/icons/buildings.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/code.d.ts +2 -0
- package/assets/types/generated/public/assets/icons/commerce.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/communication.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/devices.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/emojis.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/files.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/finance.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/forms.d.ts +5 -0
- package/assets/types/generated/public/assets/icons/health.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/index.d.ts +24 -0
- package/assets/types/generated/public/assets/icons/media.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/navigation.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/seasonal.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/social.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/sport.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/status.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/transport.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/ui.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/weather.d.ts +6 -0
- package/assets/types/generated/src/auth.d.ts +424 -0
- package/assets/types/generated/src/avatar.d.ts +270 -0
- package/assets/types/generated/src/binding-source.d.ts +58 -0
- package/assets/types/generated/src/butterfly-drawing.d.ts +2 -0
- package/assets/types/generated/src/component-factory.d.ts +150 -0
- package/assets/types/generated/src/component.d.ts +162 -0
- package/assets/types/generated/src/components/back-to-top.d.ts +150 -0
- package/assets/types/generated/src/components/badge.d.ts +208 -0
- package/assets/types/generated/src/components/card.d.ts +189 -0
- package/assets/types/generated/src/components/command-palette.d.ts +352 -0
- package/assets/types/generated/src/components/dropzone.d.ts +342 -0
- package/assets/types/generated/src/components/focus-trap.d.ts +238 -0
- package/assets/types/generated/src/components/loader.d.ts +133 -0
- package/assets/types/generated/src/components/modal.d.ts +341 -0
- package/assets/types/generated/src/components/range-slider.d.ts +267 -0
- package/assets/types/generated/src/components/shared.d.ts +91 -0
- package/assets/types/generated/src/components/split-pane.d.ts +239 -0
- package/assets/types/generated/src/components/toast.d.ts +284 -0
- package/assets/types/generated/src/components/tooltip.d.ts +200 -0
- package/assets/types/generated/src/components/virtual-list.d.ts +340 -0
- package/assets/types/generated/src/config.d.ts +193 -0
- package/assets/types/generated/src/context-cursor.d.ts +69 -0
- package/assets/types/generated/src/context-menu.d.ts +596 -0
- package/assets/types/generated/src/dates.d.ts +367 -0
- package/assets/types/generated/src/dom.d.ts +1221 -0
- package/assets/types/generated/src/effects.d.ts +1281 -0
- package/assets/types/generated/src/elements.d.ts +4996 -0
- package/assets/types/generated/src/escape.d.ts +5 -0
- package/assets/types/generated/src/flags-bundle.d.ts +4 -0
- package/assets/types/generated/src/flags.d.ts +338 -0
- package/assets/types/generated/src/forms.d.ts +1060 -0
- package/assets/types/generated/src/globals.d.ts +45 -0
- package/assets/types/generated/src/http.d.ts +131 -0
- package/assets/types/generated/src/i18n.d.ts +261 -0
- package/assets/types/generated/src/icons.d.ts +213 -0
- package/assets/types/generated/src/index.d.ts +249 -0
- package/assets/types/generated/src/input-group.d.ts +135 -0
- package/assets/types/generated/src/models.d.ts +968 -0
- package/assets/types/generated/src/popover.d.ts +412 -0
- package/assets/types/generated/src/router.d.ts +344 -0
- package/assets/types/generated/src/safe-url.d.ts +10 -0
- package/assets/types/generated/src/sanitize.d.ts +97 -0
- package/assets/types/generated/src/schema-builder.d.ts +420 -0
- package/assets/types/generated/src/skeleton.d.ts +135 -0
- package/assets/types/generated/src/smooth-caret.d.ts +61 -0
- package/assets/types/generated/src/sortable.d.ts +369 -0
- package/assets/types/generated/src/storage.d.ts +93 -0
- package/assets/types/generated/src/tables.d.ts +901 -0
- package/assets/types/generated/src/theme.d.ts +277 -0
- package/assets/types/generated/src/ticker-tape-drawing.d.ts +2 -0
- package/assets/types/generated/src/treeview.d.ts +504 -0
- package/assets/types/generated/src/utils.d.ts +1667 -0
- package/assets/types/generated/src/web-components/base/domma-element.d.ts +134 -0
- package/assets/types/generated/src/web-components/index.d.ts +14 -0
- package/assets/types/generated/vendor/domma-reactive.d.ts +587 -0
- package/assets/types/index.d.ts +104 -216
- package/package.json +5 -2
- package/public/dist/bundles/domma-complete.css +1084 -14
- package/public/dist/bundles/domma-data-focused.css +1084 -14
- package/public/dist/bundles/domma-essentials.css +1084 -14
- package/public/dist/bundles/domma-full.css +1084 -14
- package/public/dist/bundles/domma-minimal.css +8 -8
- package/public/dist/domma-flags.esm.js +3 -3
- package/public/dist/domma-flags.esm.js.map +1 -1
- package/public/dist/domma-flags.min.js +3 -3
- package/public/dist/domma-flags.min.js.map +1 -1
- package/public/dist/domma-syntax.min.js +3 -3
- package/public/dist/domma.css +3 -3
- package/public/dist/domma.esm.js +5 -5
- package/public/dist/domma.esm.js.map +1 -1
- package/public/dist/domma.min.js +5 -5
- package/public/dist/domma.min.js.map +1 -1
- package/public/dist/elements.css +1073 -3
- package/public/dist/grid.css +3 -3
- package/public/dist/syntax.css +3 -3
- package/public/dist/themes/domma-themes.css +3 -3
- package/templates/kickstart/frontend/types/domma.d.ts +2 -1
- package/assets/types/config.d.ts +0 -136
- package/assets/types/dates.d.ts +0 -209
- package/assets/types/dom.d.ts +0 -448
- package/assets/types/elements.d.ts +0 -682
- package/assets/types/flags.d.ts +0 -130
- package/assets/types/http.d.ts +0 -97
- package/assets/types/icons.d.ts +0 -147
- package/assets/types/models.d.ts +0 -260
- package/assets/types/smooth-caret.d.ts +0 -12
- package/assets/types/storage.d.ts +0 -93
- package/assets/types/tables.d.ts +0 -327
- package/assets/types/theme.d.ts +0 -137
- package/assets/types/utils.d.ts +0 -675
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document coordinates of an element (`offset()`).
|
|
3
|
+
* @typedef {object} Offset
|
|
4
|
+
* @property {number} top
|
|
5
|
+
* @property {number} left
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Coordinates of an element relative to its offset parent (`position()`).
|
|
9
|
+
* @typedef {object} Position
|
|
10
|
+
* @property {number} top
|
|
11
|
+
* @property {number} left
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* CSS properties to animate; numbers are pixels.
|
|
15
|
+
* @typedef {{[property: string]: string | number}} AnimationProperties
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Animation length in ms, or `'fast'` (200) / `'slow'` (600); anything else is 400.
|
|
19
|
+
* @typedef {number | 'fast' | 'slow'} Duration
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {(this: HTMLElement, index: number, element: HTMLElement) => boolean} FilterFunction
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Returns the class name(s) to add/remove, space-separated.
|
|
26
|
+
* @typedef {(this: HTMLElement, index: number, currentClass: string) => string} ClassFunction
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Returns the content to insert into one target; receives that target's current inner HTML.
|
|
30
|
+
* @typedef {(this: HTMLElement, index: number, currentContent: string) => string | HTMLElement | DommaCollection} ContentFunction
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Returns the wrapper for one element.
|
|
34
|
+
* @typedef {(this: HTMLElement, index: number) => string | HTMLElement | DommaCollection} WrapperFunction
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Returns the new width/height of one element; receives its current one.
|
|
38
|
+
* @typedef {(this: HTMLElement, index: number, currentValue: number) => number | string} ValueFunction
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* An event handler; `this` is the element (the matched descendant for a delegated handler).
|
|
42
|
+
* @template {Event} [E=Event]
|
|
43
|
+
* @typedef {(this: HTMLElement, event: E) => void} EventHandler
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* What `$()` accepts: a CSS selector or an HTML string (`'<li>One</li>'`), a node, a NodeList or
|
|
47
|
+
* HTMLCollection, an array (only its HTMLElements are kept) or another collection.
|
|
48
|
+
* @typedef {string | Node | NodeList | HTMLCollection | Element[] | DommaCollection} DommaSelector
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* Sanitisation options for `html()`.
|
|
52
|
+
* @typedef {object} DommaHtmlOptions
|
|
53
|
+
* @property {boolean} [safe=true] - Sanitise content (true = safe, false = raw - TRUSTED content only)
|
|
54
|
+
* @property {'default'|'strict'|'basic'} [preset='default'] - Sanitiser preset
|
|
55
|
+
* @property {string[]} [allowedTags] - Custom allowed HTML tags (overrides the preset)
|
|
56
|
+
* @property {string[]} [allowedAttrs] - Custom allowed attributes (overrides the preset)
|
|
57
|
+
* @property {boolean} [allowDataAttrs] - Allow data-* attributes
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* jQuery-compatible chainable DOM collection - what `$()` returns.
|
|
61
|
+
* Elements are also reachable by index (`$('li')[0]`, same as `get(0)`).
|
|
62
|
+
*/
|
|
63
|
+
export class DommaCollection {
|
|
64
|
+
/**
|
|
65
|
+
* @param {DommaSelector} [selector] - CSS selector, HTML string, element(s) or a collection
|
|
66
|
+
* @param {Document | Element | DocumentFragment} [context] - Where to look for a CSS selector (default: document)
|
|
67
|
+
*/
|
|
68
|
+
constructor(selector?: DommaSelector, context?: Document | Element | DocumentFragment);
|
|
69
|
+
/**
|
|
70
|
+
* The matched elements.
|
|
71
|
+
* @type {HTMLElement[]}
|
|
72
|
+
*/
|
|
73
|
+
elements: HTMLElement[];
|
|
74
|
+
/**
|
|
75
|
+
* Number of matched elements.
|
|
76
|
+
* @type {number}
|
|
77
|
+
*/
|
|
78
|
+
length: number;
|
|
79
|
+
/**
|
|
80
|
+
* Get descendants matching selector.
|
|
81
|
+
* @param {string} selector
|
|
82
|
+
* @returns {DommaCollection}
|
|
83
|
+
*/
|
|
84
|
+
find(selector: string): DommaCollection;
|
|
85
|
+
/**
|
|
86
|
+
* Get immediate children, optionally filtered by selector.
|
|
87
|
+
* @param {string} [selector]
|
|
88
|
+
* @returns {DommaCollection}
|
|
89
|
+
*/
|
|
90
|
+
children(selector?: string): DommaCollection;
|
|
91
|
+
/**
|
|
92
|
+
* Get parent of each element, optionally filtered by selector.
|
|
93
|
+
* @param {string} [selector]
|
|
94
|
+
* @returns {DommaCollection}
|
|
95
|
+
*/
|
|
96
|
+
parent(selector?: string): DommaCollection;
|
|
97
|
+
/**
|
|
98
|
+
* Get all ancestors, optionally filtered by selector.
|
|
99
|
+
* @param {string} [selector]
|
|
100
|
+
* @returns {DommaCollection}
|
|
101
|
+
*/
|
|
102
|
+
parents(selector?: string): DommaCollection;
|
|
103
|
+
/**
|
|
104
|
+
* Get closest ancestor matching selector.
|
|
105
|
+
* @param {string} selector
|
|
106
|
+
* @returns {DommaCollection}
|
|
107
|
+
*/
|
|
108
|
+
closest(selector: string): DommaCollection;
|
|
109
|
+
/**
|
|
110
|
+
* Get siblings, optionally filtered by selector.
|
|
111
|
+
* @param {string} [selector]
|
|
112
|
+
* @returns {DommaCollection}
|
|
113
|
+
*/
|
|
114
|
+
siblings(selector?: string): DommaCollection;
|
|
115
|
+
/**
|
|
116
|
+
* Get next sibling, optionally filtered by selector.
|
|
117
|
+
* @param {string} [selector]
|
|
118
|
+
* @returns {DommaCollection}
|
|
119
|
+
*/
|
|
120
|
+
next(selector?: string): DommaCollection;
|
|
121
|
+
/**
|
|
122
|
+
* Get all following siblings, optionally filtered by selector.
|
|
123
|
+
* @param {string} [selector]
|
|
124
|
+
* @returns {DommaCollection}
|
|
125
|
+
*/
|
|
126
|
+
nextAll(selector?: string): DommaCollection;
|
|
127
|
+
/**
|
|
128
|
+
* Get previous sibling, optionally filtered by selector.
|
|
129
|
+
* @param {string} [selector]
|
|
130
|
+
* @returns {DommaCollection}
|
|
131
|
+
*/
|
|
132
|
+
prev(selector?: string): DommaCollection;
|
|
133
|
+
/**
|
|
134
|
+
* Get all preceding siblings, optionally filtered by selector.
|
|
135
|
+
* @param {string} [selector]
|
|
136
|
+
* @returns {DommaCollection}
|
|
137
|
+
*/
|
|
138
|
+
prevAll(selector?: string): DommaCollection;
|
|
139
|
+
/**
|
|
140
|
+
* Get first element in collection.
|
|
141
|
+
* @returns {DommaCollection}
|
|
142
|
+
*/
|
|
143
|
+
first(): DommaCollection;
|
|
144
|
+
/**
|
|
145
|
+
* Get last element in collection.
|
|
146
|
+
* @returns {DommaCollection}
|
|
147
|
+
*/
|
|
148
|
+
last(): DommaCollection;
|
|
149
|
+
/**
|
|
150
|
+
* Get element at index.
|
|
151
|
+
* @param {number} index
|
|
152
|
+
* @returns {DommaCollection}
|
|
153
|
+
*/
|
|
154
|
+
eq(index: number): DommaCollection;
|
|
155
|
+
/**
|
|
156
|
+
* Get every element as an array.
|
|
157
|
+
* @overload
|
|
158
|
+
* @returns {HTMLElement[]}
|
|
159
|
+
*/
|
|
160
|
+
get(): HTMLElement[];
|
|
161
|
+
/**
|
|
162
|
+
* Get the raw element at index (negative counts from the end).
|
|
163
|
+
* @overload
|
|
164
|
+
* @param {number} index
|
|
165
|
+
* @returns {HTMLElement|undefined}
|
|
166
|
+
*/
|
|
167
|
+
get(index: number): HTMLElement | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Filter elements by selector or function.
|
|
170
|
+
* @param {string|FilterFunction} selector
|
|
171
|
+
* @returns {DommaCollection}
|
|
172
|
+
*/
|
|
173
|
+
filter(selector: string | FilterFunction): DommaCollection;
|
|
174
|
+
/**
|
|
175
|
+
* Remove elements matching selector from collection.
|
|
176
|
+
* @param {string|FilterFunction} selector
|
|
177
|
+
* @returns {DommaCollection}
|
|
178
|
+
*/
|
|
179
|
+
not(selector: string | FilterFunction): DommaCollection;
|
|
180
|
+
/**
|
|
181
|
+
* Check if any element matches selector.
|
|
182
|
+
* @param {string} selector
|
|
183
|
+
* @returns {boolean}
|
|
184
|
+
*/
|
|
185
|
+
is(selector: string): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Filter elements that have descendants matching selector.
|
|
188
|
+
* @param {string} selector
|
|
189
|
+
* @returns {DommaCollection}
|
|
190
|
+
*/
|
|
191
|
+
has(selector: string): DommaCollection;
|
|
192
|
+
/**
|
|
193
|
+
* Add elements to the collection.
|
|
194
|
+
* @param {DommaSelector} selector
|
|
195
|
+
* @returns {DommaCollection}
|
|
196
|
+
*/
|
|
197
|
+
add(selector: DommaSelector): DommaCollection;
|
|
198
|
+
/**
|
|
199
|
+
* Get children including text nodes.
|
|
200
|
+
* @returns {DommaCollection}
|
|
201
|
+
*/
|
|
202
|
+
contents(): DommaCollection;
|
|
203
|
+
/**
|
|
204
|
+
* Convert to array.
|
|
205
|
+
* @returns {HTMLElement[]}
|
|
206
|
+
*/
|
|
207
|
+
toArray(): HTMLElement[];
|
|
208
|
+
/**
|
|
209
|
+
* Index of the first element among its siblings (-1 when it has no parent).
|
|
210
|
+
* @overload
|
|
211
|
+
* @returns {number}
|
|
212
|
+
*/
|
|
213
|
+
index(): number;
|
|
214
|
+
/**
|
|
215
|
+
* Index of the first element within the elements matching a selector.
|
|
216
|
+
* @overload
|
|
217
|
+
* @param {string} selector
|
|
218
|
+
* @returns {number}
|
|
219
|
+
*/
|
|
220
|
+
index(selector: string): number;
|
|
221
|
+
/**
|
|
222
|
+
* Index of an element within this collection.
|
|
223
|
+
* @overload
|
|
224
|
+
* @param {HTMLElement} element
|
|
225
|
+
* @returns {number}
|
|
226
|
+
*/
|
|
227
|
+
index(element: HTMLElement): number;
|
|
228
|
+
/**
|
|
229
|
+
* Iterate over each element.
|
|
230
|
+
* @param {(this: HTMLElement, index: number, element: HTMLElement) => void} callback
|
|
231
|
+
* @returns {this}
|
|
232
|
+
*/
|
|
233
|
+
each(callback: (this: HTMLElement, index: number, element: HTMLElement) => void): this;
|
|
234
|
+
/**
|
|
235
|
+
* Get the inner HTML of the first element ('' when the collection is empty).
|
|
236
|
+
* @overload
|
|
237
|
+
* @returns {string}
|
|
238
|
+
*/
|
|
239
|
+
html(): string;
|
|
240
|
+
/**
|
|
241
|
+
* Set the inner HTML of every element, sanitised unless `options.safe` is false.
|
|
242
|
+
* @overload
|
|
243
|
+
* @param {string} content - HTML content to set
|
|
244
|
+
* @param {DommaHtmlOptions} [options] - Sanitisation options
|
|
245
|
+
* @returns {this}
|
|
246
|
+
*/
|
|
247
|
+
html(content: string, options?: DommaHtmlOptions): this;
|
|
248
|
+
/**
|
|
249
|
+
* Get the combined text content of every element.
|
|
250
|
+
* @overload
|
|
251
|
+
* @returns {string}
|
|
252
|
+
*/
|
|
253
|
+
text(): string;
|
|
254
|
+
/**
|
|
255
|
+
* Set the text content of every element.
|
|
256
|
+
* @overload
|
|
257
|
+
* @param {string} content
|
|
258
|
+
* @returns {this}
|
|
259
|
+
*/
|
|
260
|
+
text(content: string): this;
|
|
261
|
+
/**
|
|
262
|
+
* Get the value of the first form element: an array for a multiple select, undefined for an unchecked checkbox/radio or an empty collection.
|
|
263
|
+
* @overload
|
|
264
|
+
* @returns {string|string[]|undefined}
|
|
265
|
+
*/
|
|
266
|
+
val(): string | string[] | undefined;
|
|
267
|
+
/**
|
|
268
|
+
* Set the value of every form element (checks checkboxes/radios whose value matches; selects options of a multiple select).
|
|
269
|
+
* @overload
|
|
270
|
+
* @param {string|string[]} value
|
|
271
|
+
* @returns {this}
|
|
272
|
+
*/
|
|
273
|
+
val(value: string | string[]): this;
|
|
274
|
+
/**
|
|
275
|
+
* Set several attributes on every element.
|
|
276
|
+
* @overload
|
|
277
|
+
* @param {Record<string, string>} attributes
|
|
278
|
+
* @returns {this}
|
|
279
|
+
*/
|
|
280
|
+
attr(attributes: Record<string, string>): this;
|
|
281
|
+
/**
|
|
282
|
+
* Get an attribute of the first element (null when absent, undefined when the collection is empty).
|
|
283
|
+
* @overload
|
|
284
|
+
* @param {string} name
|
|
285
|
+
* @returns {string|null|undefined}
|
|
286
|
+
*/
|
|
287
|
+
attr(name: string): string | null | undefined;
|
|
288
|
+
/**
|
|
289
|
+
* Set an attribute on every element.
|
|
290
|
+
* @overload
|
|
291
|
+
* @param {string} name
|
|
292
|
+
* @param {string} value
|
|
293
|
+
* @returns {this}
|
|
294
|
+
*/
|
|
295
|
+
attr(name: string, value: string): this;
|
|
296
|
+
/**
|
|
297
|
+
* Remove attribute(s) - space-separated names.
|
|
298
|
+
* @param {string} name
|
|
299
|
+
* @returns {this}
|
|
300
|
+
*/
|
|
301
|
+
removeAttr(name: string): this;
|
|
302
|
+
/**
|
|
303
|
+
* Set several properties on every element.
|
|
304
|
+
* @overload
|
|
305
|
+
* @param {Record<string, any>} properties
|
|
306
|
+
* @returns {this}
|
|
307
|
+
*/
|
|
308
|
+
prop(properties: Record<string, any>): this;
|
|
309
|
+
/**
|
|
310
|
+
* Get a property of the first element.
|
|
311
|
+
* @overload
|
|
312
|
+
* @param {string} name
|
|
313
|
+
* @returns {any}
|
|
314
|
+
*/
|
|
315
|
+
prop(name: string): any;
|
|
316
|
+
/**
|
|
317
|
+
* Set a property on every element.
|
|
318
|
+
* @overload
|
|
319
|
+
* @param {string} name
|
|
320
|
+
* @param {any} value
|
|
321
|
+
* @returns {this}
|
|
322
|
+
*/
|
|
323
|
+
prop(name: string, value: any): this;
|
|
324
|
+
/**
|
|
325
|
+
* Remove property.
|
|
326
|
+
* @param {string} name
|
|
327
|
+
* @returns {this}
|
|
328
|
+
*/
|
|
329
|
+
removeProp(name: string): this;
|
|
330
|
+
/**
|
|
331
|
+
* Get every data attribute of the first element (undefined when the collection is empty).
|
|
332
|
+
* @overload
|
|
333
|
+
* @returns {Record<string, string>|undefined}
|
|
334
|
+
*/
|
|
335
|
+
data(): Record<string, string> | undefined;
|
|
336
|
+
/**
|
|
337
|
+
* Set several data attributes on every element.
|
|
338
|
+
* @overload
|
|
339
|
+
* @param {Record<string, any>} data
|
|
340
|
+
* @returns {this}
|
|
341
|
+
*/
|
|
342
|
+
data(data: Record<string, any>): this;
|
|
343
|
+
/**
|
|
344
|
+
* Get a data attribute of the first element (camelCase key).
|
|
345
|
+
* @overload
|
|
346
|
+
* @param {string} key
|
|
347
|
+
* @returns {string|undefined}
|
|
348
|
+
*/
|
|
349
|
+
data(key: string): string | undefined;
|
|
350
|
+
/**
|
|
351
|
+
* Set a data attribute on every element.
|
|
352
|
+
* @overload
|
|
353
|
+
* @param {string} key
|
|
354
|
+
* @param {any} value
|
|
355
|
+
* @returns {this}
|
|
356
|
+
*/
|
|
357
|
+
data(key: string, value: any): this;
|
|
358
|
+
/**
|
|
359
|
+
* Remove data attribute.
|
|
360
|
+
* @param {string} key
|
|
361
|
+
* @returns {this}
|
|
362
|
+
*/
|
|
363
|
+
removeData(key: string): this;
|
|
364
|
+
/**
|
|
365
|
+
* Set several CSS properties on every element.
|
|
366
|
+
* @overload
|
|
367
|
+
* @param {Record<string, string|number>} properties
|
|
368
|
+
* @returns {this}
|
|
369
|
+
*/
|
|
370
|
+
css(properties: Record<string, string | number>): this;
|
|
371
|
+
/**
|
|
372
|
+
* Get a computed CSS property of the first element ('' when the collection is empty).
|
|
373
|
+
* @overload
|
|
374
|
+
* @param {string} property
|
|
375
|
+
* @returns {string}
|
|
376
|
+
*/
|
|
377
|
+
css(property: string): string;
|
|
378
|
+
/**
|
|
379
|
+
* Set a CSS property on every element.
|
|
380
|
+
* @overload
|
|
381
|
+
* @param {string} property
|
|
382
|
+
* @param {string|number} value
|
|
383
|
+
* @returns {this}
|
|
384
|
+
*/
|
|
385
|
+
css(property: string, value: string | number): this;
|
|
386
|
+
/**
|
|
387
|
+
* Add class(es) - space-separated.
|
|
388
|
+
* @param {string|ClassFunction} className
|
|
389
|
+
* @returns {this}
|
|
390
|
+
*/
|
|
391
|
+
addClass(className: string | ClassFunction): this;
|
|
392
|
+
/**
|
|
393
|
+
* Remove class(es) - space-separated, or every class when no argument is given.
|
|
394
|
+
* @param {string|ClassFunction} [className]
|
|
395
|
+
* @returns {this}
|
|
396
|
+
*/
|
|
397
|
+
removeClass(className?: string | ClassFunction): this;
|
|
398
|
+
/**
|
|
399
|
+
* Toggle class(es).
|
|
400
|
+
* @param {string|((this: HTMLElement, index: number, currentClass: string, state?: boolean) => string)} className
|
|
401
|
+
* @param {boolean} [state]
|
|
402
|
+
* @returns {this}
|
|
403
|
+
*/
|
|
404
|
+
toggleClass(className: string | ((this: HTMLElement, index: number, currentClass: string, state?: boolean) => string), state?: boolean): this;
|
|
405
|
+
/**
|
|
406
|
+
* Check if any element has class.
|
|
407
|
+
* @param {string} className
|
|
408
|
+
* @returns {boolean}
|
|
409
|
+
*/
|
|
410
|
+
hasClass(className: string): boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Append content to each element.
|
|
413
|
+
*
|
|
414
|
+
* An element or collection is **moved** into place, so the node you built
|
|
415
|
+
* is the node in the page and any handler bound to it beforehand still
|
|
416
|
+
* fires. A markup string is parsed fresh for each target. Appending into
|
|
417
|
+
* several targets at once copies for all but the last - see `_getNodes`.
|
|
418
|
+
*
|
|
419
|
+
* @param {string|HTMLElement|DommaCollection|ContentFunction} content
|
|
420
|
+
* @returns {this}
|
|
421
|
+
*/
|
|
422
|
+
append(content: string | HTMLElement | DommaCollection | ContentFunction): this;
|
|
423
|
+
/**
|
|
424
|
+
* Prepend content to each element.
|
|
425
|
+
* @param {string|HTMLElement|DommaCollection|ContentFunction} content
|
|
426
|
+
* @returns {this}
|
|
427
|
+
*/
|
|
428
|
+
prepend(content: string | HTMLElement | DommaCollection | ContentFunction): this;
|
|
429
|
+
/**
|
|
430
|
+
* Insert content after each element.
|
|
431
|
+
* @param {string|HTMLElement|DommaCollection|ContentFunction} content
|
|
432
|
+
* @returns {this}
|
|
433
|
+
*/
|
|
434
|
+
after(content: string | HTMLElement | DommaCollection | ContentFunction): this;
|
|
435
|
+
/**
|
|
436
|
+
* Insert content before each element.
|
|
437
|
+
* @param {string|HTMLElement|DommaCollection|ContentFunction} content
|
|
438
|
+
* @returns {this}
|
|
439
|
+
*/
|
|
440
|
+
before(content: string | HTMLElement | DommaCollection | ContentFunction): this;
|
|
441
|
+
/**
|
|
442
|
+
* Append elements to target.
|
|
443
|
+
* @param {DommaSelector} target
|
|
444
|
+
* @returns {this}
|
|
445
|
+
*/
|
|
446
|
+
appendTo(target: DommaSelector): this;
|
|
447
|
+
/**
|
|
448
|
+
* Prepend elements to target.
|
|
449
|
+
* @param {DommaSelector} target
|
|
450
|
+
* @returns {this}
|
|
451
|
+
*/
|
|
452
|
+
prependTo(target: DommaSelector): this;
|
|
453
|
+
/**
|
|
454
|
+
* Insert elements after target.
|
|
455
|
+
* @param {DommaSelector} target
|
|
456
|
+
* @returns {this}
|
|
457
|
+
*/
|
|
458
|
+
insertAfter(target: DommaSelector): this;
|
|
459
|
+
/**
|
|
460
|
+
* Insert elements before target.
|
|
461
|
+
* @param {DommaSelector} target
|
|
462
|
+
* @returns {this}
|
|
463
|
+
*/
|
|
464
|
+
insertBefore(target: DommaSelector): this;
|
|
465
|
+
/**
|
|
466
|
+
* Wrap each element with structure.
|
|
467
|
+
* @param {string|HTMLElement|DommaCollection|WrapperFunction} wrapper
|
|
468
|
+
* @returns {this}
|
|
469
|
+
*/
|
|
470
|
+
wrap(wrapper: string | HTMLElement | DommaCollection | WrapperFunction): this;
|
|
471
|
+
/**
|
|
472
|
+
* Wrap all elements together with structure.
|
|
473
|
+
* @param {string|HTMLElement|DommaCollection} wrapper
|
|
474
|
+
* @returns {this}
|
|
475
|
+
*/
|
|
476
|
+
wrapAll(wrapper: string | HTMLElement | DommaCollection): this;
|
|
477
|
+
/**
|
|
478
|
+
* Wrap inner contents of each element.
|
|
479
|
+
* @param {string|HTMLElement|DommaCollection|WrapperFunction} wrapper
|
|
480
|
+
* @returns {this}
|
|
481
|
+
*/
|
|
482
|
+
wrapInner(wrapper: string | HTMLElement | DommaCollection | WrapperFunction): this;
|
|
483
|
+
/**
|
|
484
|
+
* Remove parent wrapper from each element.
|
|
485
|
+
* @param {string} [selector]
|
|
486
|
+
* @returns {this}
|
|
487
|
+
*/
|
|
488
|
+
unwrap(selector?: string): this;
|
|
489
|
+
/**
|
|
490
|
+
* Remove elements from DOM.
|
|
491
|
+
* @param {string} [selector]
|
|
492
|
+
* @returns {this}
|
|
493
|
+
*/
|
|
494
|
+
remove(selector?: string): this;
|
|
495
|
+
/**
|
|
496
|
+
* Remove elements from DOM (alias for remove, simplified).
|
|
497
|
+
* @returns {this}
|
|
498
|
+
*/
|
|
499
|
+
detach(): this;
|
|
500
|
+
/**
|
|
501
|
+
* Remove all children from elements.
|
|
502
|
+
* @returns {this}
|
|
503
|
+
*/
|
|
504
|
+
empty(): this;
|
|
505
|
+
/**
|
|
506
|
+
* Clone elements.
|
|
507
|
+
* @param {boolean} [deep=true]
|
|
508
|
+
* @returns {DommaCollection}
|
|
509
|
+
*/
|
|
510
|
+
clone(deep?: boolean): DommaCollection;
|
|
511
|
+
/**
|
|
512
|
+
* Replace each element with content.
|
|
513
|
+
* @param {string|HTMLElement|DommaCollection|ContentFunction} content
|
|
514
|
+
* @returns {this}
|
|
515
|
+
*/
|
|
516
|
+
replaceWith(content: string | HTMLElement | DommaCollection | ContentFunction): this;
|
|
517
|
+
/**
|
|
518
|
+
* Replace target with elements.
|
|
519
|
+
* @param {DommaSelector} target
|
|
520
|
+
* @returns {this}
|
|
521
|
+
*/
|
|
522
|
+
replaceAll(target: DommaSelector): this;
|
|
523
|
+
/**
|
|
524
|
+
* Resolve insertion content to the nodes to insert into one target.
|
|
525
|
+
*
|
|
526
|
+
* An existing node is **moved**, not copied, which is what jQuery does and
|
|
527
|
+
* what callers assume: `$('<input>').on('change', fn)` followed by an
|
|
528
|
+
* append has to put *that* input in the page, or the handler is bound to a
|
|
529
|
+
* node nobody can click and the state set with `prop()` is lost with it.
|
|
530
|
+
* Copying was silent - the markup looked right and nothing threw.
|
|
531
|
+
*
|
|
532
|
+
* Only a collection with more than one target needs copies, because a node
|
|
533
|
+
* cannot be in two places. The original then goes to the **last** target,
|
|
534
|
+
* as in jQuery, and the earlier ones get `cloneNode(true)`.
|
|
535
|
+
*
|
|
536
|
+
* `cloneNode` copies attributes and descendants, never listeners or
|
|
537
|
+
* properties, so a handler bound before a *multi-target* insert still only
|
|
538
|
+
* survives on the last one. Bind after inserting, or delegate from a
|
|
539
|
+
* container, when inserting into several targets at once.
|
|
540
|
+
*
|
|
541
|
+
* @param {string|HTMLElement|DommaCollection|Function} content
|
|
542
|
+
* @param {number} index - Index of the target being filled
|
|
543
|
+
* @param {HTMLElement} element - The target being filled
|
|
544
|
+
* @param {boolean} [isLast=true] - Whether this is the final target, and so
|
|
545
|
+
* receives the original nodes rather than copies
|
|
546
|
+
* @returns {Node[]}
|
|
547
|
+
* @private
|
|
548
|
+
*/
|
|
549
|
+
private _getNodes;
|
|
550
|
+
/**
|
|
551
|
+
* @param {string|HTMLElement|DommaCollection|WrapperFunction} wrapper
|
|
552
|
+
* @param {number} index
|
|
553
|
+
* @param {HTMLElement} element
|
|
554
|
+
* @returns {Node}
|
|
555
|
+
* @private
|
|
556
|
+
*/
|
|
557
|
+
private _getWrapper;
|
|
558
|
+
/**
|
|
559
|
+
* Attach a handler for a DOM event (the event object is typed from its name).
|
|
560
|
+
* @template {keyof HTMLElementEventMap} K
|
|
561
|
+
* @overload
|
|
562
|
+
* @param {K} event
|
|
563
|
+
* @param {EventHandler<HTMLElementEventMap[K]>} handler
|
|
564
|
+
* @returns {this}
|
|
565
|
+
*/
|
|
566
|
+
on<K extends keyof HTMLElementEventMap>(event: K, handler: EventHandler<HTMLElementEventMap[K]>): this;
|
|
567
|
+
/**
|
|
568
|
+
* Attach a handler for one or more space-separated events.
|
|
569
|
+
* @template {Event} [E=Event]
|
|
570
|
+
* @overload
|
|
571
|
+
* @param {string} event
|
|
572
|
+
* @param {EventHandler<E>} handler
|
|
573
|
+
* @returns {this}
|
|
574
|
+
*/
|
|
575
|
+
on<E extends Event = Event>(event: string, handler: EventHandler<E>): this;
|
|
576
|
+
/**
|
|
577
|
+
* Attach a delegated handler: it runs for events from descendants matching `selector`, with `this` set to the match.
|
|
578
|
+
* @template {keyof HTMLElementEventMap} K
|
|
579
|
+
* @overload
|
|
580
|
+
* @param {K} event
|
|
581
|
+
* @param {string} selector
|
|
582
|
+
* @param {EventHandler<HTMLElementEventMap[K]>} handler
|
|
583
|
+
* @returns {this}
|
|
584
|
+
*/
|
|
585
|
+
on<K extends keyof HTMLElementEventMap>(event: K, selector: string, handler: EventHandler<HTMLElementEventMap[K]>): this;
|
|
586
|
+
/**
|
|
587
|
+
* Attach a delegated handler for one or more space-separated events.
|
|
588
|
+
* @template {Event} [E=Event]
|
|
589
|
+
* @overload
|
|
590
|
+
* @param {string} event
|
|
591
|
+
* @param {string} selector
|
|
592
|
+
* @param {EventHandler<E>} handler
|
|
593
|
+
* @returns {this}
|
|
594
|
+
*/
|
|
595
|
+
on<E extends Event = Event>(event: string, selector: string, handler: EventHandler<E>): this;
|
|
596
|
+
/**
|
|
597
|
+
* Remove a handler (nothing is removed without both an event and a handler).
|
|
598
|
+
* @overload
|
|
599
|
+
* @param {string} [event]
|
|
600
|
+
* @param {EventHandler<any>} [handler]
|
|
601
|
+
* @returns {this}
|
|
602
|
+
*/
|
|
603
|
+
off(event?: string, handler?: EventHandler<any>): this;
|
|
604
|
+
/**
|
|
605
|
+
* Remove delegated handlers bound with this selector (all of them when no handler is given).
|
|
606
|
+
* @overload
|
|
607
|
+
* @param {string} event
|
|
608
|
+
* @param {string} selector
|
|
609
|
+
* @param {EventHandler<any>} [handler]
|
|
610
|
+
* @returns {this}
|
|
611
|
+
*/
|
|
612
|
+
off(event: string, selector: string, handler?: EventHandler<any>): this;
|
|
613
|
+
/**
|
|
614
|
+
* Attach a handler that runs once.
|
|
615
|
+
* @template {keyof HTMLElementEventMap} K
|
|
616
|
+
* @overload
|
|
617
|
+
* @param {K} event
|
|
618
|
+
* @param {EventHandler<HTMLElementEventMap[K]>} handler
|
|
619
|
+
* @returns {this}
|
|
620
|
+
*/
|
|
621
|
+
one<K extends keyof HTMLElementEventMap>(event: K, handler: EventHandler<HTMLElementEventMap[K]>): this;
|
|
622
|
+
/**
|
|
623
|
+
* Attach a handler that runs once.
|
|
624
|
+
* @template {Event} [E=Event]
|
|
625
|
+
* @overload
|
|
626
|
+
* @param {string} event
|
|
627
|
+
* @param {EventHandler<E>} handler
|
|
628
|
+
* @returns {this}
|
|
629
|
+
*/
|
|
630
|
+
one<E extends Event = Event>(event: string, handler: EventHandler<E>): this;
|
|
631
|
+
/**
|
|
632
|
+
* Attach a delegated handler that runs once.
|
|
633
|
+
* @template {keyof HTMLElementEventMap} K
|
|
634
|
+
* @overload
|
|
635
|
+
* @param {K} event
|
|
636
|
+
* @param {string} selector
|
|
637
|
+
* @param {EventHandler<HTMLElementEventMap[K]>} handler
|
|
638
|
+
* @returns {this}
|
|
639
|
+
*/
|
|
640
|
+
one<K extends keyof HTMLElementEventMap>(event: K, selector: string, handler: EventHandler<HTMLElementEventMap[K]>): this;
|
|
641
|
+
/**
|
|
642
|
+
* Attach a delegated handler that runs once.
|
|
643
|
+
* @template {Event} [E=Event]
|
|
644
|
+
* @overload
|
|
645
|
+
* @param {string} event
|
|
646
|
+
* @param {string} selector
|
|
647
|
+
* @param {EventHandler<E>} handler
|
|
648
|
+
* @returns {this}
|
|
649
|
+
*/
|
|
650
|
+
one<E extends Event = Event>(event: string, selector: string, handler: EventHandler<E>): this;
|
|
651
|
+
/**
|
|
652
|
+
* Trigger event on elements: a bubbling, cancelable CustomEvent with `data` as its `detail`.
|
|
653
|
+
* @param {string} event
|
|
654
|
+
* @param {any} [data]
|
|
655
|
+
* @returns {this}
|
|
656
|
+
*/
|
|
657
|
+
trigger(event: string, data?: any): this;
|
|
658
|
+
/**
|
|
659
|
+
* Trigger native event.
|
|
660
|
+
* @param {string} eventType
|
|
661
|
+
* @returns {this}
|
|
662
|
+
*/
|
|
663
|
+
triggerNative(eventType: string): this;
|
|
664
|
+
/**
|
|
665
|
+
* Trigger a native click.
|
|
666
|
+
* @overload
|
|
667
|
+
* @returns {this}
|
|
668
|
+
*/
|
|
669
|
+
click(): this;
|
|
670
|
+
/**
|
|
671
|
+
* Attach a `click` handler.
|
|
672
|
+
* @overload
|
|
673
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
674
|
+
* @returns {this}
|
|
675
|
+
*/
|
|
676
|
+
click(handler: EventHandler<MouseEvent>): this;
|
|
677
|
+
/**
|
|
678
|
+
* Trigger a `dblclick` event.
|
|
679
|
+
* @overload
|
|
680
|
+
* @returns {this}
|
|
681
|
+
*/
|
|
682
|
+
dblclick(): this;
|
|
683
|
+
/**
|
|
684
|
+
* Attach a `dblclick` handler.
|
|
685
|
+
* @overload
|
|
686
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
687
|
+
* @returns {this}
|
|
688
|
+
*/
|
|
689
|
+
dblclick(handler: EventHandler<MouseEvent>): this;
|
|
690
|
+
/**
|
|
691
|
+
* Trigger a `mousedown` event.
|
|
692
|
+
* @overload
|
|
693
|
+
* @returns {this}
|
|
694
|
+
*/
|
|
695
|
+
mousedown(): this;
|
|
696
|
+
/**
|
|
697
|
+
* Attach a `mousedown` handler.
|
|
698
|
+
* @overload
|
|
699
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
700
|
+
* @returns {this}
|
|
701
|
+
*/
|
|
702
|
+
mousedown(handler: EventHandler<MouseEvent>): this;
|
|
703
|
+
/**
|
|
704
|
+
* Trigger a `mouseup` event.
|
|
705
|
+
* @overload
|
|
706
|
+
* @returns {this}
|
|
707
|
+
*/
|
|
708
|
+
mouseup(): this;
|
|
709
|
+
/**
|
|
710
|
+
* Attach a `mouseup` handler.
|
|
711
|
+
* @overload
|
|
712
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
713
|
+
* @returns {this}
|
|
714
|
+
*/
|
|
715
|
+
mouseup(handler: EventHandler<MouseEvent>): this;
|
|
716
|
+
/**
|
|
717
|
+
* Trigger a `mousemove` event.
|
|
718
|
+
* @overload
|
|
719
|
+
* @returns {this}
|
|
720
|
+
*/
|
|
721
|
+
mousemove(): this;
|
|
722
|
+
/**
|
|
723
|
+
* Attach a `mousemove` handler.
|
|
724
|
+
* @overload
|
|
725
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
726
|
+
* @returns {this}
|
|
727
|
+
*/
|
|
728
|
+
mousemove(handler: EventHandler<MouseEvent>): this;
|
|
729
|
+
/**
|
|
730
|
+
* Trigger a `mouseover` event.
|
|
731
|
+
* @overload
|
|
732
|
+
* @returns {this}
|
|
733
|
+
*/
|
|
734
|
+
mouseover(): this;
|
|
735
|
+
/**
|
|
736
|
+
* Attach a `mouseover` handler.
|
|
737
|
+
* @overload
|
|
738
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
739
|
+
* @returns {this}
|
|
740
|
+
*/
|
|
741
|
+
mouseover(handler: EventHandler<MouseEvent>): this;
|
|
742
|
+
/**
|
|
743
|
+
* Trigger a `mouseout` event.
|
|
744
|
+
* @overload
|
|
745
|
+
* @returns {this}
|
|
746
|
+
*/
|
|
747
|
+
mouseout(): this;
|
|
748
|
+
/**
|
|
749
|
+
* Attach a `mouseout` handler.
|
|
750
|
+
* @overload
|
|
751
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
752
|
+
* @returns {this}
|
|
753
|
+
*/
|
|
754
|
+
mouseout(handler: EventHandler<MouseEvent>): this;
|
|
755
|
+
/**
|
|
756
|
+
* Trigger a `mouseenter` event.
|
|
757
|
+
* @overload
|
|
758
|
+
* @returns {this}
|
|
759
|
+
*/
|
|
760
|
+
mouseenter(): this;
|
|
761
|
+
/**
|
|
762
|
+
* Attach a `mouseenter` handler.
|
|
763
|
+
* @overload
|
|
764
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
765
|
+
* @returns {this}
|
|
766
|
+
*/
|
|
767
|
+
mouseenter(handler: EventHandler<MouseEvent>): this;
|
|
768
|
+
/**
|
|
769
|
+
* Trigger a `mouseleave` event.
|
|
770
|
+
* @overload
|
|
771
|
+
* @returns {this}
|
|
772
|
+
*/
|
|
773
|
+
mouseleave(): this;
|
|
774
|
+
/**
|
|
775
|
+
* Attach a `mouseleave` handler.
|
|
776
|
+
* @overload
|
|
777
|
+
* @param {EventHandler<MouseEvent>} handler
|
|
778
|
+
* @returns {this}
|
|
779
|
+
*/
|
|
780
|
+
mouseleave(handler: EventHandler<MouseEvent>): this;
|
|
781
|
+
/**
|
|
782
|
+
* Trigger a `keydown` event.
|
|
783
|
+
* @overload
|
|
784
|
+
* @returns {this}
|
|
785
|
+
*/
|
|
786
|
+
keydown(): this;
|
|
787
|
+
/**
|
|
788
|
+
* Attach a `keydown` handler.
|
|
789
|
+
* @overload
|
|
790
|
+
* @param {EventHandler<KeyboardEvent>} handler
|
|
791
|
+
* @returns {this}
|
|
792
|
+
*/
|
|
793
|
+
keydown(handler: EventHandler<KeyboardEvent>): this;
|
|
794
|
+
/**
|
|
795
|
+
* Trigger a `keyup` event.
|
|
796
|
+
* @overload
|
|
797
|
+
* @returns {this}
|
|
798
|
+
*/
|
|
799
|
+
keyup(): this;
|
|
800
|
+
/**
|
|
801
|
+
* Attach a `keyup` handler.
|
|
802
|
+
* @overload
|
|
803
|
+
* @param {EventHandler<KeyboardEvent>} handler
|
|
804
|
+
* @returns {this}
|
|
805
|
+
*/
|
|
806
|
+
keyup(handler: EventHandler<KeyboardEvent>): this;
|
|
807
|
+
/**
|
|
808
|
+
* Trigger a `keypress` event.
|
|
809
|
+
* @overload
|
|
810
|
+
* @returns {this}
|
|
811
|
+
*/
|
|
812
|
+
keypress(): this;
|
|
813
|
+
/**
|
|
814
|
+
* Attach a `keypress` handler.
|
|
815
|
+
* @overload
|
|
816
|
+
* @param {EventHandler<KeyboardEvent>} handler
|
|
817
|
+
* @returns {this}
|
|
818
|
+
*/
|
|
819
|
+
keypress(handler: EventHandler<KeyboardEvent>): this;
|
|
820
|
+
/**
|
|
821
|
+
* Trigger focus on every element.
|
|
822
|
+
* @overload
|
|
823
|
+
* @returns {this}
|
|
824
|
+
*/
|
|
825
|
+
focus(): this;
|
|
826
|
+
/**
|
|
827
|
+
* Attach a `focus` handler.
|
|
828
|
+
* @overload
|
|
829
|
+
* @param {EventHandler<FocusEvent>} handler
|
|
830
|
+
* @returns {this}
|
|
831
|
+
*/
|
|
832
|
+
focus(handler: EventHandler<FocusEvent>): this;
|
|
833
|
+
/**
|
|
834
|
+
* Trigger blur on every element.
|
|
835
|
+
* @overload
|
|
836
|
+
* @returns {this}
|
|
837
|
+
*/
|
|
838
|
+
blur(): this;
|
|
839
|
+
/**
|
|
840
|
+
* Attach a `blur` handler.
|
|
841
|
+
* @overload
|
|
842
|
+
* @param {EventHandler<FocusEvent>} handler
|
|
843
|
+
* @returns {this}
|
|
844
|
+
*/
|
|
845
|
+
blur(handler: EventHandler<FocusEvent>): this;
|
|
846
|
+
/**
|
|
847
|
+
* Trigger a `change` event.
|
|
848
|
+
* @overload
|
|
849
|
+
* @returns {this}
|
|
850
|
+
*/
|
|
851
|
+
change(): this;
|
|
852
|
+
/**
|
|
853
|
+
* Attach a `change` handler.
|
|
854
|
+
* @overload
|
|
855
|
+
* @param {EventHandler<Event>} handler
|
|
856
|
+
* @returns {this}
|
|
857
|
+
*/
|
|
858
|
+
change(handler: EventHandler<Event>): this;
|
|
859
|
+
/**
|
|
860
|
+
* Trigger a `select` event.
|
|
861
|
+
* @overload
|
|
862
|
+
* @returns {this}
|
|
863
|
+
*/
|
|
864
|
+
select(): this;
|
|
865
|
+
/**
|
|
866
|
+
* Attach a `select` handler.
|
|
867
|
+
* @overload
|
|
868
|
+
* @param {EventHandler<Event>} handler
|
|
869
|
+
* @returns {this}
|
|
870
|
+
*/
|
|
871
|
+
select(handler: EventHandler<Event>): this;
|
|
872
|
+
/**
|
|
873
|
+
* Trigger submit on every form.
|
|
874
|
+
* @overload
|
|
875
|
+
* @returns {this}
|
|
876
|
+
*/
|
|
877
|
+
submit(): this;
|
|
878
|
+
/**
|
|
879
|
+
* Attach a `submit` handler.
|
|
880
|
+
* @overload
|
|
881
|
+
* @param {EventHandler<SubmitEvent>} handler
|
|
882
|
+
* @returns {this}
|
|
883
|
+
*/
|
|
884
|
+
submit(handler: EventHandler<SubmitEvent>): this;
|
|
885
|
+
/**
|
|
886
|
+
* Trigger a `scroll` event.
|
|
887
|
+
* @overload
|
|
888
|
+
* @returns {this}
|
|
889
|
+
*/
|
|
890
|
+
scroll(): this;
|
|
891
|
+
/**
|
|
892
|
+
* Attach a `scroll` handler.
|
|
893
|
+
* @overload
|
|
894
|
+
* @param {EventHandler<Event>} handler
|
|
895
|
+
* @returns {this}
|
|
896
|
+
*/
|
|
897
|
+
scroll(handler: EventHandler<Event>): this;
|
|
898
|
+
/**
|
|
899
|
+
* Trigger a `resize` event.
|
|
900
|
+
* @overload
|
|
901
|
+
* @returns {this}
|
|
902
|
+
*/
|
|
903
|
+
resize(): this;
|
|
904
|
+
/**
|
|
905
|
+
* Attach a `resize` handler.
|
|
906
|
+
* @overload
|
|
907
|
+
* @param {EventHandler<UIEvent>} handler
|
|
908
|
+
* @returns {this}
|
|
909
|
+
*/
|
|
910
|
+
resize(handler: EventHandler<UIEvent>): this;
|
|
911
|
+
/**
|
|
912
|
+
* Handle mouseenter and mouseleave (one handler for both when leaveHandler is omitted).
|
|
913
|
+
* @param {EventHandler<MouseEvent>} enterHandler
|
|
914
|
+
* @param {EventHandler<MouseEvent>} [leaveHandler]
|
|
915
|
+
* @returns {this}
|
|
916
|
+
*/
|
|
917
|
+
hover(enterHandler: EventHandler<MouseEvent>, leaveHandler?: EventHandler<MouseEvent>): this;
|
|
918
|
+
/**
|
|
919
|
+
* Show elements.
|
|
920
|
+
* @param {Duration} [duration]
|
|
921
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
922
|
+
* @returns {this}
|
|
923
|
+
*/
|
|
924
|
+
show(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
925
|
+
/**
|
|
926
|
+
* Hide elements.
|
|
927
|
+
* @param {Duration} [duration]
|
|
928
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
929
|
+
* @returns {this}
|
|
930
|
+
*/
|
|
931
|
+
hide(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
932
|
+
/**
|
|
933
|
+
* Toggle visibility.
|
|
934
|
+
* @param {Duration} [duration]
|
|
935
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
936
|
+
* @returns {this}
|
|
937
|
+
*/
|
|
938
|
+
toggle(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
939
|
+
/**
|
|
940
|
+
* Fade in elements.
|
|
941
|
+
* @param {Duration} [duration=400]
|
|
942
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
943
|
+
* @returns {this}
|
|
944
|
+
*/
|
|
945
|
+
fadeIn(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
946
|
+
/**
|
|
947
|
+
* Fade out elements.
|
|
948
|
+
* @param {Duration} [duration=400]
|
|
949
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
950
|
+
* @returns {this}
|
|
951
|
+
*/
|
|
952
|
+
fadeOut(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
953
|
+
/**
|
|
954
|
+
* Toggle fade.
|
|
955
|
+
* @param {Duration} [duration=400]
|
|
956
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
957
|
+
* @returns {this}
|
|
958
|
+
*/
|
|
959
|
+
fadeToggle(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
960
|
+
/**
|
|
961
|
+
* Fade to opacity.
|
|
962
|
+
* @param {Duration} duration
|
|
963
|
+
* @param {number} opacity
|
|
964
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
965
|
+
* @returns {this}
|
|
966
|
+
*/
|
|
967
|
+
fadeTo(duration: Duration, opacity: number, callback?: (this: HTMLElement) => void): this;
|
|
968
|
+
/**
|
|
969
|
+
* Slide up (hide).
|
|
970
|
+
* @param {Duration} [duration=400]
|
|
971
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
972
|
+
* @returns {this}
|
|
973
|
+
*/
|
|
974
|
+
slideUp(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
975
|
+
/**
|
|
976
|
+
* Slide down (show).
|
|
977
|
+
* @param {Duration} [duration=400]
|
|
978
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
979
|
+
* @returns {this}
|
|
980
|
+
*/
|
|
981
|
+
slideDown(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
982
|
+
/**
|
|
983
|
+
* Toggle slide.
|
|
984
|
+
* @param {Duration} [duration=400]
|
|
985
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
986
|
+
* @returns {this}
|
|
987
|
+
*/
|
|
988
|
+
slideToggle(duration?: Duration, callback?: (this: HTMLElement) => void): this;
|
|
989
|
+
/**
|
|
990
|
+
* Animate CSS properties (numbers are pixels).
|
|
991
|
+
* @overload
|
|
992
|
+
* @param {AnimationProperties} properties
|
|
993
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
994
|
+
* @returns {this}
|
|
995
|
+
*/
|
|
996
|
+
animate(properties: AnimationProperties, callback?: (this: HTMLElement) => void): this;
|
|
997
|
+
/**
|
|
998
|
+
* Animate CSS properties (numbers are pixels).
|
|
999
|
+
* @overload
|
|
1000
|
+
* @param {AnimationProperties} properties
|
|
1001
|
+
* @param {Duration} duration
|
|
1002
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
1003
|
+
* @returns {this}
|
|
1004
|
+
*/
|
|
1005
|
+
animate(properties: AnimationProperties, duration: Duration, callback?: (this: HTMLElement) => void): this;
|
|
1006
|
+
/**
|
|
1007
|
+
* Animate CSS properties (numbers are pixels) with a CSS easing.
|
|
1008
|
+
* @overload
|
|
1009
|
+
* @param {AnimationProperties} properties
|
|
1010
|
+
* @param {Duration} duration
|
|
1011
|
+
* @param {string} easing
|
|
1012
|
+
* @param {(this: HTMLElement) => void} [callback]
|
|
1013
|
+
* @returns {this}
|
|
1014
|
+
*/
|
|
1015
|
+
animate(properties: AnimationProperties, duration: Duration, easing: string, callback?: (this: HTMLElement) => void): this;
|
|
1016
|
+
/**
|
|
1017
|
+
* Stop animations.
|
|
1018
|
+
* @returns {this}
|
|
1019
|
+
*/
|
|
1020
|
+
stop(): this;
|
|
1021
|
+
/**
|
|
1022
|
+
* Delay next animation: resolves with this collection after `duration` ms.
|
|
1023
|
+
* @param {number} duration
|
|
1024
|
+
* @returns {Promise<this>}
|
|
1025
|
+
*/
|
|
1026
|
+
delay(duration: number): Promise<this>;
|
|
1027
|
+
/**
|
|
1028
|
+
* @param {Duration} duration
|
|
1029
|
+
* @returns {number}
|
|
1030
|
+
* @private
|
|
1031
|
+
*/
|
|
1032
|
+
private _getDuration;
|
|
1033
|
+
/**
|
|
1034
|
+
* Get the rendered width of the first element (undefined when the collection is empty).
|
|
1035
|
+
* @overload
|
|
1036
|
+
* @returns {number|undefined}
|
|
1037
|
+
*/
|
|
1038
|
+
width(): number | undefined;
|
|
1039
|
+
/**
|
|
1040
|
+
* Set the width of every element (numbers are pixels).
|
|
1041
|
+
* @overload
|
|
1042
|
+
* @param {number|string|ValueFunction} value
|
|
1043
|
+
* @returns {this}
|
|
1044
|
+
*/
|
|
1045
|
+
width(value: number | string | ValueFunction): this;
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the rendered height of the first element (undefined when the collection is empty).
|
|
1048
|
+
* @overload
|
|
1049
|
+
* @returns {number|undefined}
|
|
1050
|
+
*/
|
|
1051
|
+
height(): number | undefined;
|
|
1052
|
+
/**
|
|
1053
|
+
* Set the height of every element (numbers are pixels).
|
|
1054
|
+
* @overload
|
|
1055
|
+
* @param {number|string|ValueFunction} value
|
|
1056
|
+
* @returns {this}
|
|
1057
|
+
*/
|
|
1058
|
+
height(value: number | string | ValueFunction): this;
|
|
1059
|
+
/**
|
|
1060
|
+
* Get inner width (content + padding).
|
|
1061
|
+
* @returns {number|undefined}
|
|
1062
|
+
*/
|
|
1063
|
+
innerWidth(): number | undefined;
|
|
1064
|
+
/**
|
|
1065
|
+
* Get inner height (content + padding).
|
|
1066
|
+
* @returns {number|undefined}
|
|
1067
|
+
*/
|
|
1068
|
+
innerHeight(): number | undefined;
|
|
1069
|
+
/**
|
|
1070
|
+
* Get outer width (content + padding + border + optional margin).
|
|
1071
|
+
* @param {boolean} [includeMargin=false]
|
|
1072
|
+
* @returns {number|undefined}
|
|
1073
|
+
*/
|
|
1074
|
+
outerWidth(includeMargin?: boolean): number | undefined;
|
|
1075
|
+
/**
|
|
1076
|
+
* Get outer height (content + padding + border + optional margin).
|
|
1077
|
+
* @param {boolean} [includeMargin=false]
|
|
1078
|
+
* @returns {number|undefined}
|
|
1079
|
+
*/
|
|
1080
|
+
outerHeight(includeMargin?: boolean): number | undefined;
|
|
1081
|
+
/**
|
|
1082
|
+
* Get the position of the first element relative to the document.
|
|
1083
|
+
* @overload
|
|
1084
|
+
* @returns {Offset|undefined}
|
|
1085
|
+
*/
|
|
1086
|
+
offset(): Offset | undefined;
|
|
1087
|
+
/**
|
|
1088
|
+
* Move every element to these document coordinates (static elements become relative).
|
|
1089
|
+
* @overload
|
|
1090
|
+
* @param {Partial<Offset>} coords
|
|
1091
|
+
* @returns {this}
|
|
1092
|
+
*/
|
|
1093
|
+
offset(coords: Partial<Offset>): this;
|
|
1094
|
+
/**
|
|
1095
|
+
* Get position (relative to offset parent).
|
|
1096
|
+
* @returns {Position|undefined}
|
|
1097
|
+
*/
|
|
1098
|
+
position(): Position | undefined;
|
|
1099
|
+
/**
|
|
1100
|
+
* Get the scroll top position of the first element.
|
|
1101
|
+
* @overload
|
|
1102
|
+
* @returns {number|undefined}
|
|
1103
|
+
*/
|
|
1104
|
+
scrollTop(): number | undefined;
|
|
1105
|
+
/**
|
|
1106
|
+
* Set the scroll top position of every element.
|
|
1107
|
+
* @overload
|
|
1108
|
+
* @param {number} value
|
|
1109
|
+
* @returns {this}
|
|
1110
|
+
*/
|
|
1111
|
+
scrollTop(value: number): this;
|
|
1112
|
+
/**
|
|
1113
|
+
* Get the scroll left position of the first element.
|
|
1114
|
+
* @overload
|
|
1115
|
+
* @returns {number|undefined}
|
|
1116
|
+
*/
|
|
1117
|
+
scrollLeft(): number | undefined;
|
|
1118
|
+
/**
|
|
1119
|
+
* Set the scroll left position of every element.
|
|
1120
|
+
* @overload
|
|
1121
|
+
* @param {number} value
|
|
1122
|
+
* @returns {this}
|
|
1123
|
+
*/
|
|
1124
|
+
scrollLeft(value: number): this;
|
|
1125
|
+
/**
|
|
1126
|
+
* Get offset parent.
|
|
1127
|
+
* @returns {DommaCollection}
|
|
1128
|
+
*/
|
|
1129
|
+
offsetParent(): DommaCollection;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Wrap elements in a DommaCollection.
|
|
1133
|
+
* @overload
|
|
1134
|
+
* @param {DommaSelector} selector - CSS selector, HTML string, element(s) or a collection
|
|
1135
|
+
* @param {Document | Element | DocumentFragment} [context] - Where to look for a CSS selector (default: document)
|
|
1136
|
+
* @returns {DommaCollection}
|
|
1137
|
+
*/
|
|
1138
|
+
export function dom(selector: DommaSelector, context?: Document | Element | DocumentFragment): DommaCollection;
|
|
1139
|
+
/**
|
|
1140
|
+
* Run a function when the DOM is ready (straight away if it already is).
|
|
1141
|
+
* @overload
|
|
1142
|
+
* @param {() => void} callback
|
|
1143
|
+
* @returns {DommaCollection} An empty collection
|
|
1144
|
+
*/
|
|
1145
|
+
export function dom(callback: () => void): DommaCollection;
|
|
1146
|
+
export function isDomma(value: unknown): value is DommaCollection;
|
|
1147
|
+
/**
|
|
1148
|
+
* Document coordinates of an element (`offset()`).
|
|
1149
|
+
*/
|
|
1150
|
+
export type Offset = {
|
|
1151
|
+
top: number;
|
|
1152
|
+
left: number;
|
|
1153
|
+
};
|
|
1154
|
+
/**
|
|
1155
|
+
* Coordinates of an element relative to its offset parent (`position()`).
|
|
1156
|
+
*/
|
|
1157
|
+
export type Position = {
|
|
1158
|
+
top: number;
|
|
1159
|
+
left: number;
|
|
1160
|
+
};
|
|
1161
|
+
/**
|
|
1162
|
+
* CSS properties to animate; numbers are pixels.
|
|
1163
|
+
*/
|
|
1164
|
+
export type AnimationProperties = {
|
|
1165
|
+
[property: string]: string | number;
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* Animation length in ms, or `'fast'` (200) / `'slow'` (600); anything else is 400.
|
|
1169
|
+
*/
|
|
1170
|
+
export type Duration = number | "fast" | "slow";
|
|
1171
|
+
export type FilterFunction = (this: HTMLElement, index: number, element: HTMLElement) => boolean;
|
|
1172
|
+
/**
|
|
1173
|
+
* Returns the class name(s) to add/remove, space-separated.
|
|
1174
|
+
*/
|
|
1175
|
+
export type ClassFunction = (this: HTMLElement, index: number, currentClass: string) => string;
|
|
1176
|
+
/**
|
|
1177
|
+
* Returns the content to insert into one target; receives that target's current inner HTML.
|
|
1178
|
+
*/
|
|
1179
|
+
export type ContentFunction = (this: HTMLElement, index: number, currentContent: string) => string | HTMLElement | DommaCollection;
|
|
1180
|
+
/**
|
|
1181
|
+
* Returns the wrapper for one element.
|
|
1182
|
+
*/
|
|
1183
|
+
export type WrapperFunction = (this: HTMLElement, index: number) => string | HTMLElement | DommaCollection;
|
|
1184
|
+
/**
|
|
1185
|
+
* Returns the new width/height of one element; receives its current one.
|
|
1186
|
+
*/
|
|
1187
|
+
export type ValueFunction = (this: HTMLElement, index: number, currentValue: number) => number | string;
|
|
1188
|
+
/**
|
|
1189
|
+
* An event handler; `this` is the element (the matched descendant for a delegated handler).
|
|
1190
|
+
*/
|
|
1191
|
+
export type EventHandler<E extends Event = Event> = (this: HTMLElement, event: E) => void;
|
|
1192
|
+
/**
|
|
1193
|
+
* What `$()` accepts: a CSS selector or an HTML string (`'<li>One</li>'`), a node, a NodeList or
|
|
1194
|
+
* HTMLCollection, an array (only its HTMLElements are kept) or another collection.
|
|
1195
|
+
*/
|
|
1196
|
+
export type DommaSelector = string | Node | NodeList | HTMLCollection | Element[] | DommaCollection;
|
|
1197
|
+
/**
|
|
1198
|
+
* Sanitisation options for `html()`.
|
|
1199
|
+
*/
|
|
1200
|
+
export type DommaHtmlOptions = {
|
|
1201
|
+
/**
|
|
1202
|
+
* - Sanitise content (true = safe, false = raw - TRUSTED content only)
|
|
1203
|
+
*/
|
|
1204
|
+
safe?: boolean;
|
|
1205
|
+
/**
|
|
1206
|
+
* - Sanitiser preset
|
|
1207
|
+
*/
|
|
1208
|
+
preset?: "default" | "strict" | "basic";
|
|
1209
|
+
/**
|
|
1210
|
+
* - Custom allowed HTML tags (overrides the preset)
|
|
1211
|
+
*/
|
|
1212
|
+
allowedTags?: string[];
|
|
1213
|
+
/**
|
|
1214
|
+
* - Custom allowed attributes (overrides the preset)
|
|
1215
|
+
*/
|
|
1216
|
+
allowedAttrs?: string[];
|
|
1217
|
+
/**
|
|
1218
|
+
* - Allow data-* attributes
|
|
1219
|
+
*/
|
|
1220
|
+
allowDataAttrs?: boolean;
|
|
1221
|
+
};
|