@oscarpalmer/toretto 0.45.0 → 0.46.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.
Files changed (48) hide show
  1. package/dist/attribute/get.attribute.d.mts +2 -0
  2. package/dist/attribute/get.attribute.mjs +1 -0
  3. package/dist/attribute/index.d.mts +6 -0
  4. package/dist/attribute/set.attribute.d.mts +5 -0
  5. package/dist/create.d.mts +2 -0
  6. package/dist/data.d.mts +4 -0
  7. package/dist/event/index.d.mts +9 -1
  8. package/dist/event/index.mjs +2 -0
  9. package/dist/find/index.d.mts +14 -1
  10. package/dist/find/index.mjs +36 -1
  11. package/dist/find/relative.d.mts +5 -0
  12. package/dist/find/relative.mjs +1 -0
  13. package/dist/focusable.d.mts +4 -0
  14. package/dist/focusable.mjs +4 -0
  15. package/dist/html/index.d.mts +3 -0
  16. package/dist/html/index.mjs +1 -0
  17. package/dist/index.d.mts +90 -8
  18. package/dist/index.mjs +116 -10
  19. package/dist/internal/is.d.mts +13 -1
  20. package/dist/internal/is.mjs +13 -1
  21. package/dist/is.d.mts +5 -2
  22. package/dist/is.mjs +3 -2
  23. package/dist/models.d.mts +1 -8
  24. package/dist/property/get.property.d.mts +2 -0
  25. package/dist/property/get.property.mjs +2 -0
  26. package/dist/property/set.property.d.mts +3 -0
  27. package/dist/property/set.property.mjs +1 -0
  28. package/dist/style.d.mts +7 -0
  29. package/dist/style.mjs +5 -0
  30. package/dist/touch.d.mts +4 -0
  31. package/package.json +6 -6
  32. package/src/attribute/get.attribute.ts +2 -0
  33. package/src/attribute/index.ts +6 -0
  34. package/src/attribute/set.attribute.ts +5 -0
  35. package/src/create.ts +2 -0
  36. package/src/data.ts +4 -0
  37. package/src/event/index.ts +10 -1
  38. package/src/find/index.ts +64 -1
  39. package/src/find/relative.ts +5 -0
  40. package/src/focusable.ts +4 -0
  41. package/src/html/index.ts +4 -0
  42. package/src/internal/is.ts +20 -0
  43. package/src/is.ts +4 -1
  44. package/src/models.ts +0 -8
  45. package/src/property/get.property.ts +2 -0
  46. package/src/property/set.property.ts +3 -0
  47. package/src/style.ts +7 -0
  48. package/src/touch.ts +4 -0
package/dist/index.mjs CHANGED
@@ -33,6 +33,7 @@ const supportsTouch = (() => {
33
33
  //#region node_modules/@oscarpalmer/atoms/dist/internal/is.mjs
34
34
  /**
35
35
  * Is the value a number?
36
+ *
36
37
  * @param value Value to check
37
38
  * @returns `true` if the value is a `number`, otherwise `false`
38
39
  */
@@ -41,6 +42,7 @@ function isNumber(value) {
41
42
  }
42
43
  /**
43
44
  * Is the value a plain object?
45
+ *
44
46
  * @param value Value to check
45
47
  * @returns `true` if the value is a plain object, otherwise `false`
46
48
  */
@@ -54,8 +56,20 @@ function isPlainObject(value) {
54
56
  //#region node_modules/@oscarpalmer/atoms/dist/internal/string.mjs
55
57
  /**
56
58
  * Get the string value from any value
59
+ *
57
60
  * @param value Original value
58
61
  * @returns String representation of the value
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * getString(null) // => ''
66
+ * getString('foo') // => 'foo'
67
+ * getString(123) // => '123'
68
+ * getString(true) // => 'true'
69
+ * getString([1, 2, 3]) // => '1,2,3'
70
+ * getString({a: 1}) // => '{"a":1}'
71
+ * getString(() => 123) // => '123'
72
+ * ```
59
73
  */
60
74
  function getString(value) {
61
75
  if (typeof value === "string") return value;
@@ -69,6 +83,7 @@ function getString(value) {
69
83
  * Join an array of values into a string _(while ignoring empty values)_
70
84
  *
71
85
  * _(`null`, `undefined`, and any values that become whitespace-only strings are considered empty)_
86
+ *
72
87
  * @param array Array of values
73
88
  * @param delimiter Delimiter to use between values
74
89
  * @returns Joined string
@@ -80,12 +95,13 @@ function join(array, delimiter) {
80
95
  const values = [];
81
96
  for (let index = 0; index < length; index += 1) {
82
97
  const item = getString(array[index]);
83
- if (item.trim().length > 0) values.push(item);
98
+ if (item.length > 0) values.push(item);
84
99
  }
85
100
  return values.join(typeof delimiter === "string" ? delimiter : "");
86
101
  }
87
102
  /**
88
103
  * Split a string into words _(and other readable parts)_
104
+ *
89
105
  * @param value Original string
90
106
  * @returns Array of words found in the string
91
107
  */
@@ -97,6 +113,7 @@ const EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
97
113
  //#region node_modules/@oscarpalmer/atoms/dist/is.mjs
98
114
  /**
99
115
  * Is the value `undefined`, `null`, or stringified as a whitespace-only string?
116
+ *
100
117
  * @param value Value to check
101
118
  * @returns `true` if the value is nullable or matches a whitespace-only string, otherwise `false`
102
119
  */
@@ -108,6 +125,7 @@ const EXPRESSION_WHITESPACE$1 = /^\s*$/;
108
125
  //#region node_modules/@oscarpalmer/atoms/dist/string/index.mjs
109
126
  /**
110
127
  * Parse a JSON string into its proper value _(or `undefined` if it fails)_
128
+ *
111
129
  * @param value JSON string to parse
112
130
  * @param reviver Reviver function to transform the parsed values
113
131
  * @returns Parsed value or `undefined` if parsing fails
@@ -123,11 +141,18 @@ function parse(value, reviver) {
123
141
  //#region node_modules/@oscarpalmer/atoms/dist/internal/number.mjs
124
142
  /**
125
143
  * Clamp a number between a minimum and maximum value
144
+ *
126
145
  * @param value Value to clamp
127
146
  * @param minimum Minimum value
128
147
  * @param maximum Maximum value
129
148
  * @param loop If `true`, the value will loop around when smaller than the minimum or larger than the maximum _(defaults to `false`)_
130
149
  * @returns Clamped value
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * clamp(10, 0, 5); // => 5
154
+ * clamp(10, 0, 5, true); // => 0
155
+ * ```
131
156
  */
132
157
  function clamp(value, minimum, maximum, loop) {
133
158
  if (![
@@ -151,17 +176,17 @@ const MAXIMUM_DEFAULT = 1048576;
151
176
  //#endregion
152
177
  //#region node_modules/@oscarpalmer/atoms/dist/sized/map.mjs
153
178
  /**
154
- * A Map with a maximum size
179
+ * A _Map_ with a maximum size
155
180
  *
156
- * Behavior is similar to a _LRU_-cache, where the least recently used entries are removed
181
+ * Behavior is similar to a _LRU_ cache, where the least recently used entries are removed
157
182
  */
158
183
  var SizedMap = class extends Map {
159
184
  /**
160
- * The maximum size of the Map
185
+ * The maximum size of the _Map_
161
186
  */
162
187
  #maximumSize;
163
188
  /**
164
- * Is the Map full?
189
+ * Is the _Map_ full?
165
190
  */
166
191
  get full() {
167
192
  return super.size >= this.#maximumSize;
@@ -205,18 +230,22 @@ var SizedMap = class extends Map {
205
230
  //#endregion
206
231
  //#region node_modules/@oscarpalmer/atoms/dist/function/memoize.mjs
207
232
  /**
208
- * A memoized function, caching and retrieving results based on the its parameters _(or a custom cache key)_
233
+ * A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
209
234
  */
210
235
  var Memoized = class {
211
236
  #state;
212
237
  /**
213
238
  * Maximum cache size
239
+ *
240
+ * @returns Maximum cache size _(or `Number.NaN` if the instance has been destroyed)_
214
241
  */
215
242
  get maximum() {
216
243
  return this.#state.cache?.maximum ?? NaN;
217
244
  }
218
245
  /**
219
246
  * Current cache size
247
+ *
248
+ * @returns Current cache size _(or `Number.NaN` if the instance has been destroyed)_
220
249
  */
221
250
  get size() {
222
251
  return this.#state.cache?.size ?? NaN;
@@ -243,6 +272,7 @@ var Memoized = class {
243
272
  }
244
273
  /**
245
274
  * Delete a result from the cache
275
+ *
246
276
  * @param key Key to delete
247
277
  * @returns `true` if the key existed and was removed, otherwise `false`
248
278
  */
@@ -250,7 +280,9 @@ var Memoized = class {
250
280
  return this.#state.cache?.delete(key) ?? false;
251
281
  }
252
282
  /**
253
- * Destroy the instance _(clearing its cache and removing its callback)_
283
+ * Destroy the instance
284
+ *
285
+ * _(When a Memoized instance is destroyed, its cache and callback are removed, and calls to `run` will throw an error)_
254
286
  */
255
287
  destroy() {
256
288
  this.#state.cache?.clear();
@@ -259,6 +291,7 @@ var Memoized = class {
259
291
  }
260
292
  /**
261
293
  * Get a result from the cache
294
+ *
262
295
  * @param key Key to get
263
296
  * @returns Cached result or `undefined` if it does not exist
264
297
  */
@@ -267,6 +300,7 @@ var Memoized = class {
267
300
  }
268
301
  /**
269
302
  * Does the result exist?
303
+ *
270
304
  * @param key Key to check
271
305
  * @returns `true` if the result exists, otherwise `false`
272
306
  */
@@ -275,11 +309,12 @@ var Memoized = class {
275
309
  }
276
310
  /**
277
311
  * Run the callback with the provided parameters
312
+ *
278
313
  * @param parameters Parameters to pass to the callback
279
314
  * @returns Cached or computed _(then cached)_ result
280
315
  */
281
316
  run(...parameters) {
282
- if (this.#state.cache == null || this.#state.getter == null) throw new Error("The Memoized instance has been destroyed");
317
+ if (this.#state.cache == null || this.#state.getter == null) throw new Error(MEMOIZED_ERROR_DESTROYED);
283
318
  return this.#state.getter(...parameters);
284
319
  }
285
320
  };
@@ -292,19 +327,24 @@ function getMemoizationOptions(input) {
292
327
  }
293
328
  /**
294
329
  * Memoize a function, caching and retrieving results based on the first parameter
330
+ *
295
331
  * @param callback Callback to memoize
296
332
  * @param options Memoization options
297
- * @returns Memoized instance
333
+ * @returns _Memoized_ instance
298
334
  */
299
335
  function memoize(callback, options) {
336
+ if (typeof callback !== "function") throw new TypeError(MEMOIZED_ERROR_CALLBACK);
300
337
  return new Memoized(callback, getMemoizationOptions(options));
301
338
  }
302
339
  const DEFAULT_CACHE_SIZE = 1024;
340
+ const MEMOIZED_ERROR_CALLBACK = "Memoized requires a callback function";
341
+ const MEMOIZED_ERROR_DESTROYED = "The Memoized instance has been destroyed";
303
342
  const SEPARATOR = "_";
304
343
  //#endregion
305
344
  //#region node_modules/@oscarpalmer/atoms/dist/string/case.mjs
306
345
  /**
307
346
  * Convert a string to camel case _(thisIsCamelCase)_
347
+ *
308
348
  * @param value String to convert
309
349
  * @returns Camel-cased string
310
350
  */
@@ -313,6 +353,7 @@ function camelCase(value) {
313
353
  }
314
354
  /**
315
355
  * Capitalize the first letter of a string _(and lowercase the rest)_
356
+ *
316
357
  * @param value String to capitalize
317
358
  * @returns Capitalized string
318
359
  */
@@ -323,6 +364,7 @@ function capitalize(value) {
323
364
  }
324
365
  /**
325
366
  * Convert a string to kebab case _(this-is-kebab-case)_
367
+ *
326
368
  * @param value String to convert
327
369
  * @returns Kebab-cased string
328
370
  */
@@ -382,7 +424,17 @@ let memoizedCapitalize;
382
424
  //#endregion
383
425
  //#region src/internal/is.ts
384
426
  /**
427
+ * Is the value an event position?
428
+ *
429
+ * @param value Value to check
430
+ * @returns `true` if it's an event position, otherwise `false`
431
+ */
432
+ function isEventPosition(value) {
433
+ return typeof value === "object" && value != null && typeof value.x === "number" && typeof value.y === "number";
434
+ }
435
+ /**
385
436
  * Is the value an event target?
437
+ *
386
438
  * @param value Value to check
387
439
  * @returns `true` if it's an event target, otherwise `false`
388
440
  */
@@ -391,6 +443,7 @@ function isEventTarget(value) {
391
443
  }
392
444
  /**
393
445
  * Is the value an HTML or SVG element?
446
+ *
394
447
  * @param value Value to check
395
448
  * @returns `true` if it's an HTML or SVG element, otherwise `false`
396
449
  */
@@ -399,6 +452,7 @@ function isHTMLOrSVGElement(value) {
399
452
  }
400
453
  /**
401
454
  * Is the value an input element? _(`<input>`, `<select>`, or `<textarea>`)_
455
+ *
402
456
  * @param value Value to check
403
457
  * @returns `true` if it's an input element, otherwise `false`
404
458
  */
@@ -409,6 +463,7 @@ function isInputElement(value) {
409
463
  //#region src/is.ts
410
464
  /**
411
465
  * Is the value a child node?
466
+ *
412
467
  * @param value Value to check
413
468
  * @returns `true` if it's a child node, otherwise `false`
414
469
  */
@@ -618,6 +673,7 @@ function getAttribute(element, name, parseValues) {
618
673
  }
619
674
  /**
620
675
  * Get specific attributes from an element
676
+ *
621
677
  * @param element Element to get attributes from
622
678
  * @param names Attribute names
623
679
  * @param parseData Parse data values? _(defaults to `true`)_
@@ -657,6 +713,7 @@ function isInvalidBooleanAttribute(first, second) {
657
713
  //#region src/style.ts
658
714
  /**
659
715
  * Get a style from an element
716
+ *
660
717
  * @param element Element to get the style from
661
718
  * @param property Style name
662
719
  * @param computed Get the computed style? _(defaults to `false`)_
@@ -667,6 +724,7 @@ function getStyle(element, property, computed) {
667
724
  }
668
725
  /**
669
726
  * Get styles from an element
727
+ *
670
728
  * @param element Element to get the styles from
671
729
  * @param properties Styles to get
672
730
  * @param computed Get the computed styles? _(defaults to `false`)_
@@ -692,6 +750,7 @@ function getTextDirection(node) {
692
750
  }
693
751
  /**
694
752
  * Set a style on an element
753
+ *
695
754
  * @param element Element to set the style on
696
755
  * @param property Style name
697
756
  * @param value Style value
@@ -701,6 +760,7 @@ function setStyle(element, property, value) {
701
760
  }
702
761
  /**
703
762
  * Set styles on an element
763
+ *
704
764
  * @param element Element to set the styles on
705
765
  * @param styles Styles to set
706
766
  */
@@ -709,6 +769,7 @@ function setStyles(element, styles) {
709
769
  }
710
770
  /**
711
771
  * Toggle styles for an element
772
+ *
712
773
  * @param element Element to style
713
774
  * @param styles Styles to be set or removed
714
775
  * @returns Style toggler
@@ -759,6 +820,7 @@ const VARIABLE_PREFIX = "--";
759
820
  //#region src/property/get.property.ts
760
821
  /**
761
822
  * Get the values of one or more properties on an element
823
+ *
762
824
  * @param target Target element
763
825
  * @param properties Properties to get
764
826
  * @returns Property values
@@ -775,6 +837,7 @@ function getProperties(target, properties) {
775
837
  }
776
838
  /**
777
839
  * Get the value of a property on an element
840
+ *
778
841
  * @param target Target element
779
842
  * @param property Property to get
780
843
  * @returns Property value
@@ -793,6 +856,7 @@ function getPropertyValue(element, property) {
793
856
  * Set the values of one or more properties on an element
794
857
  *
795
858
  * Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
859
+ *
796
860
  * @param target Target element
797
861
  * @param properties Properties to set
798
862
  * @param dispatch Dispatch events for properties? _(defaults to `true`)_
@@ -978,6 +1042,7 @@ function dispatch(target, type, options) {
978
1042
  }
979
1043
  /**
980
1044
  * Get the X- and Y-coordinates from a pointer event
1045
+ *
981
1046
  * @param event Pointer event
982
1047
  * @returns X- and Y-coordinates
983
1048
  */
@@ -998,6 +1063,7 @@ function getPosition(event) {
998
1063
  }
999
1064
  /**
1000
1065
  * Remove an event listener
1066
+ *
1001
1067
  * @param target Event target
1002
1068
  * @param type Type of event
1003
1069
  * @param listener Event listener
@@ -1061,6 +1127,7 @@ function findRelatives(origin, selector, context) {
1061
1127
  }
1062
1128
  /**
1063
1129
  * Get the distance between two elements _(i.e., the amount of nodes of between them)_
1130
+ *
1064
1131
  * @param origin Origin element
1065
1132
  * @param target Target element
1066
1133
  * @returns Distance between elements, or `-1` if distance cannot be calculated
@@ -1143,10 +1210,42 @@ function findElements(selector, context) {
1143
1210
  return findElementOrElements(selector, context, false);
1144
1211
  }
1145
1212
  /**
1213
+ * Get elements from an event position
1214
+ *
1215
+ * @param position Event position
1216
+ * @returns Elements at the event position
1217
+ */
1218
+ function getElementFromPosition(position) {
1219
+ if (!isEventPosition(position) || typeof document.elementFromPoint !== "function") return [];
1220
+ const { x, y } = position;
1221
+ const elements = [];
1222
+ const events = [];
1223
+ let current;
1224
+ while (true) {
1225
+ current = document.elementFromPoint(x, y);
1226
+ if (current == null || elements.indexOf(current) !== -1) break;
1227
+ if (!(current instanceof HTMLElement)) continue;
1228
+ elements.push(current);
1229
+ events.push({
1230
+ value: current.style.getPropertyValue(STYLE_POINTER_EVENTS),
1231
+ priority: current.style.getPropertyPriority(STYLE_POINTER_EVENTS)
1232
+ });
1233
+ current.style.setProperty(STYLE_POINTER_EVENTS, STYLE_NONE$1, STYLE_IMPORTANT);
1234
+ }
1235
+ const { length } = elements;
1236
+ for (let index = 0; index < length; index += 1) {
1237
+ const element = elements[index];
1238
+ const event = events[index];
1239
+ if (element instanceof HTMLElement) element.style.setProperty(STYLE_POINTER_EVENTS, event.value ?? "", event.priority);
1240
+ }
1241
+ return elements;
1242
+ }
1243
+ /**
1146
1244
  * Get the most specific element under the pointer
1147
1245
  *
1148
1246
  * - Ignores elements with `pointer-events: none` and `visibility: hidden`
1149
1247
  * - _(If `skipIgnore` is `true`, no elements are ignored)_
1248
+ *
1150
1249
  * @param skipIgnore Skip ignored elements?
1151
1250
  * @returns Found element or `null`
1152
1251
  */
@@ -1168,13 +1267,16 @@ function isContext(value) {
1168
1267
  const QUERY_SELECTOR_ALL = "querySelectorAll";
1169
1268
  const QUERY_SELECTOR_SINGLE = "querySelector";
1170
1269
  const STYLE_HIDDEN$1 = "hidden";
1270
+ const STYLE_IMPORTANT = "important";
1171
1271
  const STYLE_NONE$1 = "none";
1272
+ const STYLE_POINTER_EVENTS = "pointer-events";
1172
1273
  const SUFFIX_HOVER = ":hover";
1173
1274
  const TAG_HEAD = "HEAD";
1174
1275
  //#endregion
1175
1276
  //#region src/focusable.ts
1176
1277
  /**
1177
1278
  * Get a list of focusable elements within a parent element
1279
+ *
1178
1280
  * @param parent Parent element
1179
1281
  * @returns Focusable elements
1180
1282
  */
@@ -1189,6 +1291,7 @@ function getItem(element, tabbable) {
1189
1291
  }
1190
1292
  /**
1191
1293
  * Get a list of tabbable elements within a parent element
1294
+ *
1192
1295
  * @param parent Parent element
1193
1296
  * @returns Tabbable elements
1194
1297
  */
@@ -1248,6 +1351,7 @@ function isEditable(element) {
1248
1351
  }
1249
1352
  /**
1250
1353
  * Is the element focusable?
1354
+ *
1251
1355
  * @param element Element to check
1252
1356
  * @returns `true` if focusable, otherwise `false`
1253
1357
  */
@@ -1283,6 +1387,7 @@ function isSummarised(item) {
1283
1387
  }
1284
1388
  /**
1285
1389
  * Is the element tabbable?
1390
+ *
1286
1391
  * @param element Element to check
1287
1392
  * @returns `true` if tabbable, otherwise `false`
1288
1393
  */
@@ -1490,6 +1595,7 @@ html.clear = () => {
1490
1595
  };
1491
1596
  /**
1492
1597
  * Remove cached template element for an HTML string or id
1598
+ *
1493
1599
  * @param template HTML string or id for a template element
1494
1600
  */
1495
1601
  html.remove = (template) => {
@@ -1531,4 +1637,4 @@ const templates = new SizedMap(128);
1531
1637
  let parser;
1532
1638
  window.templates = templates;
1533
1639
  //#endregion
1534
- export { findElement as $, findElement, findElements as $$, findElements, booleanAttributes, createElement, dispatch, findAncestor, findRelatives, getAttribute, getAttributes, getData, getDistance, getElementUnderPointer, getFocusable, getPosition, getProperties, getProperty, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInputElement, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAttribute, setAttributes, setData, setProperties, setProperty, setStyle, setStyles, supportsTouch, toggleStyles };
1640
+ export { findElement as $, findElement, findElements as $$, findElements, booleanAttributes, createElement, dispatch, findAncestor, findRelatives, getAttribute, getAttributes, getData, getDistance, getElementFromPosition, getElementUnderPointer, getFocusable, getPosition, getProperties, getProperty, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEventPosition, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInputElement, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAttribute, setAttributes, setData, setProperties, setProperty, setStyle, setStyles, supportsTouch, toggleStyles };
@@ -1,21 +1,33 @@
1
+ import { EventPosition } from "@oscarpalmer/atoms/models";
2
+
1
3
  //#region src/internal/is.d.ts
4
+ /**
5
+ * Is the value an event position?
6
+ *
7
+ * @param value Value to check
8
+ * @returns `true` if it's an event position, otherwise `false`
9
+ */
10
+ declare function isEventPosition(value: unknown): value is EventPosition;
2
11
  /**
3
12
  * Is the value an event target?
13
+ *
4
14
  * @param value Value to check
5
15
  * @returns `true` if it's an event target, otherwise `false`
6
16
  */
7
17
  declare function isEventTarget(value: unknown): value is EventTarget;
8
18
  /**
9
19
  * Is the value an HTML or SVG element?
20
+ *
10
21
  * @param value Value to check
11
22
  * @returns `true` if it's an HTML or SVG element, otherwise `false`
12
23
  */
13
24
  declare function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement;
14
25
  /**
15
26
  * Is the value an input element? _(`<input>`, `<select>`, or `<textarea>`)_
27
+ *
16
28
  * @param value Value to check
17
29
  * @returns `true` if it's an input element, otherwise `false`
18
30
  */
19
31
  declare function isInputElement(value: unknown): value is HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
20
32
  //#endregion
21
- export { isEventTarget, isHTMLOrSVGElement, isInputElement };
33
+ export { isEventPosition, isEventTarget, isHTMLOrSVGElement, isInputElement };
@@ -1,6 +1,16 @@
1
1
  //#region src/internal/is.ts
2
2
  /**
3
+ * Is the value an event position?
4
+ *
5
+ * @param value Value to check
6
+ * @returns `true` if it's an event position, otherwise `false`
7
+ */
8
+ function isEventPosition(value) {
9
+ return typeof value === "object" && value != null && typeof value.x === "number" && typeof value.y === "number";
10
+ }
11
+ /**
3
12
  * Is the value an event target?
13
+ *
4
14
  * @param value Value to check
5
15
  * @returns `true` if it's an event target, otherwise `false`
6
16
  */
@@ -9,6 +19,7 @@ function isEventTarget(value) {
9
19
  }
10
20
  /**
11
21
  * Is the value an HTML or SVG element?
22
+ *
12
23
  * @param value Value to check
13
24
  * @returns `true` if it's an HTML or SVG element, otherwise `false`
14
25
  */
@@ -17,6 +28,7 @@ function isHTMLOrSVGElement(value) {
17
28
  }
18
29
  /**
19
30
  * Is the value an input element? _(`<input>`, `<select>`, or `<textarea>`)_
31
+ *
20
32
  * @param value Value to check
21
33
  * @returns `true` if it's an input element, otherwise `false`
22
34
  */
@@ -24,4 +36,4 @@ function isInputElement(value) {
24
36
  return value instanceof HTMLInputElement || value instanceof HTMLSelectElement || value instanceof HTMLTextAreaElement;
25
37
  }
26
38
  //#endregion
27
- export { isEventTarget, isHTMLOrSVGElement, isInputElement };
39
+ export { isEventPosition, isEventTarget, isHTMLOrSVGElement, isInputElement };
package/dist/is.d.mts CHANGED
@@ -1,24 +1,27 @@
1
- import { isEventTarget, isHTMLOrSVGElement, isInputElement } from "./internal/is.mjs";
1
+ import { isEventPosition, isEventTarget, isHTMLOrSVGElement, isInputElement } from "./internal/is.mjs";
2
2
 
3
3
  //#region src/is.d.ts
4
4
  /**
5
5
  * Is the value a child node?
6
+ *
6
7
  * @param value Value to check
7
8
  * @returns `true` if it's a child node, otherwise `false`
8
9
  */
9
10
  declare function isChildNode(value: unknown): value is ChildNode;
10
11
  /**
11
12
  * Is the node inside a document?
13
+ *
12
14
  * @param node Node to check
13
15
  * @returns `true` if it's inside a document, otherwise `false`
14
16
  */
15
17
  declare function isInDocument(node: Node): boolean;
16
18
  /**
17
19
  * Is the node inside a specific document?
20
+ *
18
21
  * @param node Node to check
19
22
  * @param document Document to check within
20
23
  * @returns `true` if it's inside the document, otherwise `false`
21
24
  */
22
25
  declare function isInDocument(node: Node, document: Document): boolean;
23
26
  //#endregion
24
- export { isChildNode, isEventTarget, isHTMLOrSVGElement, isInDocument, isInputElement };
27
+ export { isChildNode, isEventPosition, isEventTarget, isHTMLOrSVGElement, isInDocument, isInputElement };
package/dist/is.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { isEventTarget, isHTMLOrSVGElement, isInputElement } from "./internal/is.mjs";
1
+ import { isEventPosition, isEventTarget, isHTMLOrSVGElement, isInputElement } from "./internal/is.mjs";
2
2
  //#region src/is.ts
3
3
  /**
4
4
  * Is the value a child node?
5
+ *
5
6
  * @param value Value to check
6
7
  * @returns `true` if it's a child node, otherwise `false`
7
8
  */
@@ -21,4 +22,4 @@ const CHILD_NODE_TYPES = new Set([
21
22
  Node.DOCUMENT_TYPE_NODE
22
23
  ]);
23
24
  //#endregion
24
- export { isChildNode, isEventTarget, isHTMLOrSVGElement, isInDocument, isInputElement };
25
+ export { isChildNode, isEventPosition, isEventTarget, isHTMLOrSVGElement, isInDocument, isInputElement };
package/dist/models.d.mts CHANGED
@@ -10,13 +10,6 @@ type Attribute = {
10
10
  * Event listener for custom events
11
11
  */
12
12
  type CustomEventListener = (event: CustomEvent) => void;
13
- /**
14
- * The position of an event
15
- */
16
- type EventPosition = {
17
- x: number;
18
- y: number;
19
- };
20
13
  /**
21
14
  * Event listener that can be removed
22
15
  */
@@ -30,4 +23,4 @@ type Selector = string | Node | Node[] | NodeList;
30
23
  */
31
24
  type TextDirection = 'ltr' | 'rtl';
32
25
  //#endregion
33
- export { Attribute, CustomEventListener, EventPosition, RemovableEventListener, Selector, TextDirection };
26
+ export { Attribute, CustomEventListener, RemovableEventListener, Selector, TextDirection };
@@ -4,6 +4,7 @@ import { Primitive } from "@oscarpalmer/atoms/models";
4
4
  type GetProperties<Target extends Element> = { [Property in keyof Target as Target[Property] extends Primitive ? Property : never]?: Target[Property] };
5
5
  /**
6
6
  * Get the values of one or more properties on an element
7
+ *
7
8
  * @param target Target element
8
9
  * @param properties Properties to get
9
10
  * @returns Property values
@@ -11,6 +12,7 @@ type GetProperties<Target extends Element> = { [Property in keyof Target as Targ
11
12
  declare function getProperties<Target extends Element, Property extends keyof GetProperties<Target>>(target: Target, properties: Property[]): Pick<GetProperties<Target>, Property>;
12
13
  /**
13
14
  * Get the value of a property on an element
15
+ *
14
16
  * @param target Target element
15
17
  * @param property Property to get
16
18
  * @returns Property value
@@ -3,6 +3,7 @@ import { camelCase } from "@oscarpalmer/atoms/string/case";
3
3
  //#region src/property/get.property.ts
4
4
  /**
5
5
  * Get the values of one or more properties on an element
6
+ *
6
7
  * @param target Target element
7
8
  * @param properties Properties to get
8
9
  * @returns Property values
@@ -19,6 +20,7 @@ function getProperties(target, properties) {
19
20
  }
20
21
  /**
21
22
  * Get the value of a property on an element
23
+ *
22
24
  * @param target Target element
23
25
  * @param property Property to get
24
26
  * @returns Property value
@@ -8,6 +8,7 @@ type SetProperties<Target extends Element> = { [Property in keyof Target as Targ
8
8
  * Set the values of one or more properties on an element
9
9
  *
10
10
  * Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
11
+ *
11
12
  * @param target Target element
12
13
  * @param properties Properties to set
13
14
  * @param dispatch Dispatch events for properties? _(defaults to `true`)_
@@ -15,6 +16,7 @@ type SetProperties<Target extends Element> = { [Property in keyof Target as Targ
15
16
  declare function setProperties<Target extends Element>(target: Target, properties: SetProperties<Target>, dispatch?: boolean): void;
16
17
  /**
17
18
  * Set the value for a dispatchable property on an element
19
+ *
18
20
  * @param target Target element
19
21
  * @param property Property to set
20
22
  * @param value Value to set
@@ -23,6 +25,7 @@ declare function setProperties<Target extends Element>(target: Target, propertie
23
25
  declare function setProperty<Target extends Element, Property extends DispatchedAttributeName>(target: Target, property: Property, value: DispatchedPropertyValue<Target, Property>, dispatch?: boolean): void;
24
26
  /**
25
27
  * Set the value for a property on an element
28
+ *
26
29
  * @param target Target element
27
30
  * @param property Property to set
28
31
  * @param value Value to set
@@ -10,6 +10,7 @@ import { isPlainObject } from "@oscarpalmer/atoms/is";
10
10
  * Set the values of one or more properties on an element
11
11
  *
12
12
  * Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
13
+ *
13
14
  * @param target Target element
14
15
  * @param properties Properties to set
15
16
  * @param dispatch Dispatch events for properties? _(defaults to `true`)_