@koine/dom 2.0.0-beta.11 → 2.0.0-beta.110

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 (328) hide show
  1. package/_listen-delegation.cjs.js +39 -0
  2. package/_listen-delegation.d.ts +1 -39
  3. package/_listen-delegation.esm.js +34 -0
  4. package/addClass.cjs.d.ts +2 -0
  5. package/addClass.cjs.default.js +1 -0
  6. package/addClass.cjs.js +10 -0
  7. package/addClass.cjs.mjs +2 -0
  8. package/addClass.d.ts +1 -4
  9. package/addClass.esm.js +5 -0
  10. package/calculateFixedOffset.cjs.d.ts +2 -0
  11. package/calculateFixedOffset.cjs.default.js +1 -0
  12. package/calculateFixedOffset.cjs.js +11 -0
  13. package/calculateFixedOffset.cjs.mjs +2 -0
  14. package/calculateFixedOffset.d.ts +1 -1
  15. package/calculateFixedOffset.esm.js +6 -0
  16. package/createElement.cjs.d.ts +2 -0
  17. package/createElement.cjs.default.js +1 -0
  18. package/createElement.cjs.js +13 -0
  19. package/createElement.cjs.mjs +2 -0
  20. package/createElement.d.ts +1 -8
  21. package/createElement.esm.js +8 -0
  22. package/dom.cjs.d.ts +2 -0
  23. package/dom.cjs.default.js +1 -0
  24. package/{$.mjs → dom.cjs.js} +10 -6
  25. package/dom.cjs.mjs +2 -0
  26. package/dom.d.ts +2 -0
  27. package/{$.d.ts → dom.esm.js} +5 -5
  28. package/domAll.cjs.d.ts +2 -0
  29. package/domAll.cjs.default.js +1 -0
  30. package/{$$.mjs → domAll.cjs.js} +8 -4
  31. package/domAll.cjs.mjs +2 -0
  32. package/domAll.d.ts +2 -0
  33. package/{$$.d.ts → domAll.esm.js} +3 -3
  34. package/domEach.cjs.d.ts +2 -0
  35. package/domEach.cjs.default.js +1 -0
  36. package/{$each.mjs → domEach.cjs.js} +10 -8
  37. package/domEach.cjs.mjs +2 -0
  38. package/domEach.d.ts +2 -0
  39. package/{$each.d.ts → domEach.esm.js} +5 -3
  40. package/emitEvent.cjs.d.ts +2 -0
  41. package/emitEvent.cjs.default.js +1 -0
  42. package/emitEvent.cjs.js +10 -0
  43. package/emitEvent.cjs.mjs +2 -0
  44. package/emitEvent.d.ts +1 -4
  45. package/emitEvent.esm.js +5 -0
  46. package/escapeSelector.cjs.d.ts +2 -0
  47. package/escapeSelector.cjs.default.js +1 -0
  48. package/escapeSelector.cjs.js +13 -0
  49. package/escapeSelector.cjs.mjs +2 -0
  50. package/escapeSelector.d.ts +1 -7
  51. package/{escapeSelector.mjs → escapeSelector.esm.js} +3 -4
  52. package/exists.cjs.d.ts +2 -0
  53. package/exists.cjs.default.js +1 -0
  54. package/exists.cjs.js +12 -0
  55. package/exists.cjs.mjs +2 -0
  56. package/exists.d.ts +1 -6
  57. package/exists.esm.js +7 -0
  58. package/forEach.cjs.d.ts +2 -0
  59. package/forEach.cjs.default.js +1 -0
  60. package/forEach.cjs.js +12 -0
  61. package/forEach.cjs.mjs +2 -0
  62. package/forEach.d.ts +1 -6
  63. package/forEach.esm.js +7 -0
  64. package/getDataAttr.cjs.d.ts +2 -0
  65. package/getDataAttr.cjs.default.js +1 -0
  66. package/getDataAttr.cjs.js +16 -0
  67. package/getDataAttr.cjs.mjs +2 -0
  68. package/getDataAttr.d.ts +1 -7
  69. package/{getDataAttr.mjs → getDataAttr.esm.js} +4 -5
  70. package/getDocumentHeight.cjs.d.ts +2 -0
  71. package/getDocumentHeight.cjs.default.js +1 -0
  72. package/getDocumentHeight.cjs.js +12 -0
  73. package/getDocumentHeight.cjs.mjs +2 -0
  74. package/getDocumentHeight.d.ts +1 -6
  75. package/getDocumentHeight.esm.js +7 -0
  76. package/getHeight.cjs.d.ts +2 -0
  77. package/getHeight.cjs.default.js +1 -0
  78. package/getHeight.cjs.js +10 -0
  79. package/getHeight.cjs.mjs +2 -0
  80. package/getHeight.d.ts +1 -4
  81. package/getHeight.esm.js +5 -0
  82. package/getListeners.cjs.d.ts +2 -0
  83. package/getListeners.cjs.default.js +1 -0
  84. package/getListeners.cjs.js +20 -0
  85. package/getListeners.cjs.mjs +2 -0
  86. package/getListeners.d.ts +1 -8
  87. package/getListeners.esm.js +15 -0
  88. package/getOffset.cjs.d.ts +2 -0
  89. package/getOffset.cjs.default.js +1 -0
  90. package/getOffset.cjs.js +14 -0
  91. package/getOffset.cjs.mjs +2 -0
  92. package/getOffset.d.ts +1 -7
  93. package/getOffset.esm.js +9 -0
  94. package/getOffsetTop.cjs.d.ts +2 -0
  95. package/getOffsetTop.cjs.default.js +1 -0
  96. package/getOffsetTop.cjs.js +16 -0
  97. package/getOffsetTop.cjs.mjs +2 -0
  98. package/getOffsetTop.d.ts +1 -9
  99. package/getOffsetTop.esm.js +11 -0
  100. package/getOffsetTopSlim.cjs.d.ts +2 -0
  101. package/getOffsetTopSlim.cjs.default.js +1 -0
  102. package/getOffsetTopSlim.cjs.js +16 -0
  103. package/getOffsetTopSlim.cjs.mjs +2 -0
  104. package/getOffsetTopSlim.d.ts +1 -10
  105. package/{getOffsetTopSlim.mjs → getOffsetTopSlim.esm.js} +3 -4
  106. package/getScrollbarWidth.cjs.d.ts +2 -0
  107. package/getScrollbarWidth.cjs.default.js +1 -0
  108. package/getScrollbarWidth.cjs.js +10 -0
  109. package/getScrollbarWidth.cjs.mjs +2 -0
  110. package/getScrollbarWidth.d.ts +1 -4
  111. package/getScrollbarWidth.esm.js +5 -0
  112. package/getStyleValue.cjs.d.ts +2 -0
  113. package/getStyleValue.cjs.default.js +1 -0
  114. package/getStyleValue.cjs.js +13 -0
  115. package/getStyleValue.cjs.mjs +2 -0
  116. package/getStyleValue.d.ts +1 -7
  117. package/getStyleValue.esm.js +8 -0
  118. package/getVisualBackgroundColor.cjs.d.ts +2 -0
  119. package/getVisualBackgroundColor.cjs.default.js +1 -0
  120. package/getVisualBackgroundColor.cjs.js +12 -0
  121. package/getVisualBackgroundColor.cjs.mjs +2 -0
  122. package/getVisualBackgroundColor.d.ts +1 -5
  123. package/getVisualBackgroundColor.esm.js +7 -0
  124. package/index.cjs.d.ts +1 -0
  125. package/index.cjs.default.js +1 -0
  126. package/index.cjs.js +99 -0
  127. package/index.cjs.mjs +2 -0
  128. package/index.d.ts +4 -4
  129. package/index.esm.js +47 -0
  130. package/injectCss.cjs.d.ts +2 -0
  131. package/injectCss.cjs.default.js +1 -0
  132. package/injectCss.cjs.js +14 -0
  133. package/injectCss.cjs.mjs +2 -0
  134. package/injectCss.d.ts +1 -4
  135. package/injectCss.esm.js +9 -0
  136. package/isHidden.cjs.d.ts +2 -0
  137. package/isHidden.cjs.default.js +1 -0
  138. package/isHidden.cjs.js +10 -0
  139. package/isHidden.cjs.mjs +2 -0
  140. package/isHidden.d.ts +1 -4
  141. package/isHidden.esm.js +5 -0
  142. package/isInViewport.cjs.d.ts +2 -0
  143. package/isInViewport.cjs.default.js +1 -0
  144. package/isInViewport.cjs.js +15 -0
  145. package/isInViewport.cjs.mjs +2 -0
  146. package/isInViewport.d.ts +1 -9
  147. package/isInViewport.esm.js +10 -0
  148. package/isNodeList.cjs.d.ts +2 -0
  149. package/isNodeList.cjs.default.js +1 -0
  150. package/isNodeList.cjs.js +12 -0
  151. package/isNodeList.cjs.mjs +2 -0
  152. package/isNodeList.d.ts +1 -6
  153. package/isNodeList.esm.js +7 -0
  154. package/isTotallyScrolled.cjs.d.ts +2 -0
  155. package/isTotallyScrolled.cjs.default.js +1 -0
  156. package/isTotallyScrolled.cjs.js +13 -0
  157. package/isTotallyScrolled.cjs.mjs +2 -0
  158. package/isTotallyScrolled.d.ts +1 -7
  159. package/{isTotallyScrolled.mjs → isTotallyScrolled.esm.js} +3 -4
  160. package/listen.cjs.d.ts +2 -0
  161. package/listen.cjs.default.js +1 -0
  162. package/listen.cjs.js +32 -0
  163. package/listen.cjs.mjs +2 -0
  164. package/listen.d.ts +1 -10
  165. package/listen.esm.js +27 -0
  166. package/listenLoaded.cjs.d.ts +2 -0
  167. package/listenLoaded.cjs.default.js +1 -0
  168. package/listenLoaded.cjs.js +17 -0
  169. package/listenLoaded.cjs.mjs +2 -0
  170. package/listenLoaded.d.ts +1 -6
  171. package/listenLoaded.esm.js +12 -0
  172. package/listenOnce.cjs.d.ts +2 -0
  173. package/listenOnce.cjs.default.js +1 -0
  174. package/listenOnce.cjs.js +24 -0
  175. package/listenOnce.cjs.mjs +2 -0
  176. package/listenOnce.d.ts +1 -10
  177. package/listenOnce.esm.js +19 -0
  178. package/listenResize.cjs.d.ts +2 -0
  179. package/listenResize.cjs.default.js +1 -0
  180. package/listenResize.cjs.js +16 -0
  181. package/listenResize.cjs.mjs +2 -0
  182. package/listenResize.d.ts +1 -6
  183. package/listenResize.esm.js +11 -0
  184. package/listenResizeDebounced.cjs.d.ts +2 -0
  185. package/listenResizeDebounced.cjs.default.js +1 -0
  186. package/listenResizeDebounced.cjs.js +17 -0
  187. package/listenResizeDebounced.cjs.mjs +2 -0
  188. package/listenResizeDebounced.d.ts +2 -7
  189. package/listenResizeDebounced.esm.js +12 -0
  190. package/listenResizeThrottled.cjs.d.ts +2 -0
  191. package/listenResizeThrottled.cjs.default.js +1 -0
  192. package/listenResizeThrottled.cjs.js +17 -0
  193. package/listenResizeThrottled.cjs.mjs +2 -0
  194. package/listenResizeThrottled.d.ts +1 -6
  195. package/listenResizeThrottled.esm.js +12 -0
  196. package/listenScroll.cjs.d.ts +2 -0
  197. package/listenScroll.cjs.default.js +1 -0
  198. package/listenScroll.cjs.js +16 -0
  199. package/listenScroll.cjs.mjs +2 -0
  200. package/listenScroll.d.ts +1 -6
  201. package/listenScroll.esm.js +11 -0
  202. package/listenScrollDebounced.cjs.d.ts +2 -0
  203. package/listenScrollDebounced.cjs.default.js +1 -0
  204. package/listenScrollDebounced.cjs.js +17 -0
  205. package/listenScrollDebounced.cjs.mjs +2 -0
  206. package/listenScrollDebounced.d.ts +1 -6
  207. package/listenScrollDebounced.esm.js +12 -0
  208. package/listenScrollThrottled.cjs.d.ts +2 -0
  209. package/listenScrollThrottled.cjs.default.js +1 -0
  210. package/listenScrollThrottled.cjs.js +17 -0
  211. package/listenScrollThrottled.cjs.mjs +2 -0
  212. package/listenScrollThrottled.d.ts +1 -6
  213. package/listenScrollThrottled.esm.js +12 -0
  214. package/off.cjs.d.ts +2 -0
  215. package/off.cjs.default.js +1 -0
  216. package/off.cjs.js +10 -0
  217. package/off.cjs.mjs +2 -0
  218. package/off.d.ts +1 -4
  219. package/off.esm.js +5 -0
  220. package/on.cjs.d.ts +2 -0
  221. package/on.cjs.default.js +1 -0
  222. package/on.cjs.js +16 -0
  223. package/on.cjs.mjs +2 -0
  224. package/on.d.ts +1 -6
  225. package/on.esm.js +11 -0
  226. package/onClickOutside.cjs.d.ts +2 -0
  227. package/onClickOutside.cjs.default.js +1 -0
  228. package/onClickOutside.cjs.js +13 -0
  229. package/onClickOutside.cjs.mjs +2 -0
  230. package/onClickOutside.d.ts +2 -1
  231. package/onClickOutside.esm.js +8 -0
  232. package/once.cjs.d.ts +2 -0
  233. package/once.cjs.default.js +1 -0
  234. package/once.cjs.js +15 -0
  235. package/once.cjs.mjs +2 -0
  236. package/once.d.ts +2 -6
  237. package/once.esm.js +10 -0
  238. package/package.json +242 -8
  239. package/removeClass.cjs.d.ts +2 -0
  240. package/removeClass.cjs.default.js +1 -0
  241. package/removeClass.cjs.js +10 -0
  242. package/removeClass.cjs.mjs +2 -0
  243. package/removeClass.d.ts +1 -4
  244. package/removeClass.esm.js +5 -0
  245. package/scrollTo.cjs.d.ts +2 -0
  246. package/scrollTo.cjs.default.js +1 -0
  247. package/scrollTo.cjs.js +21 -0
  248. package/scrollTo.cjs.mjs +2 -0
  249. package/scrollTo.d.ts +1 -11
  250. package/scrollTo.esm.js +16 -0
  251. package/setDataAttr.cjs.d.ts +2 -0
  252. package/setDataAttr.cjs.default.js +1 -0
  253. package/setDataAttr.cjs.js +17 -0
  254. package/setDataAttr.cjs.mjs +2 -0
  255. package/setDataAttr.d.ts +1 -8
  256. package/setDataAttr.esm.js +12 -0
  257. package/setVendorCSS.cjs.d.ts +2 -0
  258. package/setVendorCSS.cjs.default.js +1 -0
  259. package/setVendorCSS.cjs.js +19 -0
  260. package/setVendorCSS.cjs.mjs +2 -0
  261. package/setVendorCSS.d.ts +1 -8
  262. package/setVendorCSS.esm.js +14 -0
  263. package/siblings.cjs.d.ts +2 -0
  264. package/siblings.cjs.default.js +1 -0
  265. package/siblings.cjs.js +12 -0
  266. package/siblings.cjs.mjs +2 -0
  267. package/siblings.d.ts +1 -6
  268. package/siblings.esm.js +7 -0
  269. package/toArray.cjs.d.ts +2 -0
  270. package/toArray.cjs.default.js +1 -0
  271. package/toArray.cjs.js +12 -0
  272. package/toArray.cjs.mjs +2 -0
  273. package/toArray.d.ts +1 -6
  274. package/toArray.esm.js +7 -0
  275. package/types.cjs.d.ts +1 -0
  276. package/types.cjs.default.js +1 -0
  277. package/types.cjs.js +2 -0
  278. package/types.cjs.mjs +2 -0
  279. package/types.d.ts +1 -6
  280. package/types.esm.js +1 -0
  281. package/unlisten.cjs.d.ts +2 -0
  282. package/unlisten.cjs.default.js +1 -0
  283. package/unlisten.cjs.js +32 -0
  284. package/unlisten.cjs.mjs +2 -0
  285. package/unlisten.d.ts +1 -10
  286. package/unlisten.esm.js +27 -0
  287. package/_listen-delegation.mjs +0 -77
  288. package/addClass.mjs +0 -12
  289. package/calculateFixedOffset.mjs +0 -9
  290. package/createElement.mjs +0 -15
  291. package/emitEvent.mjs +0 -10
  292. package/exists.mjs +0 -11
  293. package/forEach.mjs +0 -34
  294. package/getDocumentHeight.mjs +0 -9
  295. package/getHeight.mjs +0 -6
  296. package/getListeners.mjs +0 -17
  297. package/getOffset.mjs +0 -20
  298. package/getOffsetTop.mjs +0 -19
  299. package/getScrollbarWidth.mjs +0 -6
  300. package/getStyleValue.mjs +0 -9
  301. package/getVisualBackgroundColor.mjs +0 -19
  302. package/index.mjs +0 -45
  303. package/injectCss.mjs +0 -13
  304. package/isHidden.mjs +0 -6
  305. package/isInViewport.mjs +0 -12
  306. package/isNodeList.mjs +0 -9
  307. package/listen.mjs +0 -36
  308. package/listenLoaded.mjs +0 -10
  309. package/listenOnce.mjs +0 -19
  310. package/listenResize.mjs +0 -7
  311. package/listenResizeDebounced.mjs +0 -34
  312. package/listenResizeThrottled.mjs +0 -8
  313. package/listenScroll.mjs +0 -10
  314. package/listenScrollDebounced.mjs +0 -8
  315. package/listenScrollThrottled.mjs +0 -8
  316. package/off.mjs +0 -11
  317. package/on.mjs +0 -21
  318. package/onClickOutside.mjs +0 -15
  319. package/once.mjs +0 -13
  320. package/removeClass.mjs +0 -12
  321. package/scrollTo.mjs +0 -39
  322. package/setDataAttr.mjs +0 -17
  323. package/setVendorCSS.mjs +0 -20
  324. package/siblings.mjs +0 -18
  325. package/toArray.mjs +0 -8
  326. package/types.mjs +0 -1
  327. package/typings.d.ts +0 -4
  328. package/unlisten.mjs +0 -35
@@ -1,6 +0,0 @@
1
- /**
2
- * Get scrollbar's current width
3
- */ export function getScrollbarWidth(element) {
4
- return window.innerWidth - (element || document.documentElement).clientWidth;
5
- }
6
- export default getScrollbarWidth;
package/getStyleValue.mjs DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Return the current style value for an element CSS property
3
- *
4
- * @param el The element to compute
5
- * @param prop The style property
6
- */ export function getStyleValue(el, prop) {
7
- return getComputedStyle(el, null).getPropertyValue(prop);
8
- }
9
- export default getStyleValue;
@@ -1,19 +0,0 @@
1
- /**
2
- * Get the background color of an element eventually looking recursively into
3
- * its parents, if nothing is found it returns a `#fff` background
4
- */ export function getVisualBackgroundColor(elem) {
5
- if (!elem) return "#fff";
6
- const transparent = "rgba(0, 0, 0, 0)";
7
- const transparentIE11 = "transparent";
8
- // if (!elem) return transparent;
9
- const bg = window.getComputedStyle(elem).backgroundColor;
10
- if (bg === transparent || bg === transparentIE11) {
11
- const parent = elem.parentElement;
12
- if (parent) {
13
- return getVisualBackgroundColor(parent);
14
- }
15
- return "#fff";
16
- }
17
- return bg;
18
- }
19
- export default getVisualBackgroundColor;
package/index.mjs DELETED
@@ -1,45 +0,0 @@
1
- export { $$ } from "./$$";
2
- export { $each } from "./$each";
3
- export { $ } from "./$";
4
- export { addClass } from "./addClass";
5
- export { calculateFixedOffset } from "./calculateFixedOffset";
6
- export { createElement } from "./createElement";
7
- export { emitEvent } from "./emitEvent";
8
- export { escapeSelector } from "./escapeSelector";
9
- export { exists } from "./exists";
10
- export { forEach } from "./forEach";
11
- export { getDataAttr } from "./getDataAttr";
12
- export { getDocumentHeight } from "./getDocumentHeight";
13
- export { getHeight } from "./getHeight";
14
- export { getListeners } from "./getListeners";
15
- export { getOffset } from "./getOffset";
16
- export { getOffsetTop } from "./getOffsetTop";
17
- export { getOffsetTopSlim } from "./getOffsetTopSlim";
18
- export { getScrollbarWidth } from "./getScrollbarWidth";
19
- export { getStyleValue } from "./getStyleValue";
20
- export { getVisualBackgroundColor } from "./getVisualBackgroundColor";
21
- export { injectCss } from "./injectCss";
22
- export { isHidden } from "./isHidden";
23
- export { isInViewport } from "./isInViewport";
24
- export { isNodeList } from "./isNodeList";
25
- export { isTotallyScrolled } from "./isTotallyScrolled";
26
- export { listenLoaded } from "./listenLoaded";
27
- export { listenOnce } from "./listenOnce";
28
- export { listenResize } from "./listenResize";
29
- export { listenResizeDebounced } from "./listenResizeDebounced";
30
- export { listenResizeThrottled } from "./listenResizeThrottled";
31
- export { listenScroll } from "./listenScroll";
32
- export { listenScrollDebounced } from "./listenScrollDebounced";
33
- export { listenScrollThrottled } from "./listenScrollThrottled";
34
- export { listen } from "./listen";
35
- export { off } from "./off";
36
- export { once } from "./once";
37
- export { onClickOutside } from "./onClickOutside";
38
- export { on } from "./on";
39
- export { removeClass } from "./removeClass";
40
- export { scrollTo } from "./scrollTo";
41
- export { setDataAttr } from "./setDataAttr";
42
- export { setVendorCSS } from "./setVendorCSS";
43
- export { siblings } from "./siblings";
44
- export { toArray } from "./toArray";
45
- export { unlisten } from "./unlisten";
package/injectCss.mjs DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Inject css
3
- */ export function injectCss(id, cssString = "", root = document) {
4
- let styleblock;
5
- styleblock = root.getElementById(id);
6
- if (!styleblock) {
7
- styleblock = root.createElement("style");
8
- styleblock.id = id;
9
- root.body.appendChild(styleblock);
10
- }
11
- styleblock.innerHTML = cssString;
12
- }
13
- export default injectCss;
package/isHidden.mjs DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Is element hidden?
3
- */ export function isHidden(el) {
4
- return !el || el.offsetParent === null;
5
- }
6
- export default isHidden;
package/isInViewport.mjs DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Determine if an element is in the viewport
3
- *
4
- * @borrows (c) 2017 Chris Ferdinandi, MIT License, https://gomakethings.com
5
- *
6
- * @param elem The element
7
- * @return Returns true if element is in the viewport
8
- */ export function isInViewport(elem) {
9
- const distance = elem.getBoundingClientRect();
10
- return distance.top >= 0 && distance.left >= 0 && distance.bottom <= (window.innerHeight || document.documentElement.clientHeight) && distance.right <= (window.innerWidth || document.documentElement.clientWidth);
11
- }
12
- export default isInViewport;
package/isNodeList.mjs DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Is node list
3
- *
4
- * @param nodes The object to check
5
- */ export function isNodeList(nodes) {
6
- const stringRepr = Object.prototype.toString.call(nodes);
7
- return typeof nodes === "object" && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) && typeof nodes.length === "number" && (nodes.length === 0 || typeof nodes[0] === "object" && nodes[0].nodeType > 0);
8
- }
9
- export default isNodeList;
package/listen.mjs DELETED
@@ -1,36 +0,0 @@
1
- import { activeEvents, eventHandler } from "./_listen-delegation";
2
- import { on } from "./on";
3
- // import { off } from "./off";
4
- /**
5
- * Listen an event
6
- *
7
- * @category listen-delegation
8
- *
9
- * @param types The event type or types (comma separated)
10
- * @param selector The selector to run the event on
11
- * @param callback The function to run when the event fires
12
- */ export function listen(types, // | `${TTypes},${TTypes}`
13
- // | `${TTypes},${TTypes},${TTypes}`
14
- // | `${TTypes},${TTypes},${TTypes},${TTypes}`
15
- // | `${TTypes},${TTypes},${TTypes},${TTypes},${TTypes}`,
16
- selector, callback) {
17
- // Make sure there's a selector and callback
18
- if (!selector || !callback) return;
19
- // Loop through each event type
20
- types.split(",").forEach(function(type) {
21
- // Remove whitespace
22
- type = type.trim();
23
- // If no event of this type yet, setup
24
- if (!activeEvents[type]) {
25
- activeEvents[type] = [];
26
- on(window, type, eventHandler, true);
27
- }
28
- // Push to active events
29
- activeEvents[type]?.push({
30
- selector: selector,
31
- // @ts-expect-error FIXME: type...
32
- callback: callback
33
- });
34
- });
35
- }
36
- export default listen;
package/listenLoaded.mjs DELETED
@@ -1,10 +0,0 @@
1
- import { on } from "./on";
2
- /**
3
- * Fires a callback when the DOM content is loaded
4
- *
5
- * @see https://mathiasbynens.be/notes/settimeout-onload
6
- */ export function listenLoaded(handler) {
7
- on(document, "DOMContentLoaded", handler);
8
- // document.addEventListener("DOMContentLoaded", setTimeout(handler, 4));
9
- }
10
- export default listenLoaded;
package/listenOnce.mjs DELETED
@@ -1,19 +0,0 @@
1
- import { getRunTarget } from "./_listen-delegation";
2
- import { listen } from "./listen";
3
- import { unlisten } from "./unlisten";
4
- /**
5
- * Listen an event, and automatically unlisten it after it's first run
6
- *
7
- * @category listen-delegation
8
- *
9
- * @param types The event type or types (comma separated)
10
- * @param selector The selector to run the event on
11
- * @param callback The function to run when the event fires
12
- */ export function listenOnce(types, selector, callback) {
13
- listen(types, selector, function temp(event) {
14
- const target = getRunTarget(event.target, selector);
15
- callback(event, target || window);
16
- unlisten(types, selector, temp);
17
- });
18
- }
19
- export default listenOnce;
package/listenResize.mjs DELETED
@@ -1,7 +0,0 @@
1
- import { on } from "./on";
2
- /**
3
- * Listen element's (`window` by default) _scroll_ event
4
- *
5
- * @returns An automatic unbinding function to run to deregister the listener upon call
6
- */ export const listenResize = (handler, el)=>on(el || window, "resize", handler);
7
- export default listenResize;
@@ -1,34 +0,0 @@
1
- import debounce from "@koine/utils/debounce";
2
- import listenResize from "./listenResize";
3
- /**
4
- * Listen element's (`window` by default) _resize_ event debouncing the callback
5
- *
6
- * @returns An automatic unbinding function to run to deregister the listener upon call
7
- */ export const listenResizeDebounced = (el, ...args)=>listenResize(debounce(...args), el);
8
- export default listenResizeDebounced; // EXP: with too complex overload signature...
9
- // import debounce from "@koine/utils/debounce";
10
- // import isUndefined from "@koine/utils/isUndefined";
11
- // import listenResize from "./listenResize";
12
- // /**
13
- // * Listen element's (`window` by default) _resize_ event debouncing the callback
14
- // *
15
- // * @returns An automatic unbinding function to run to deregister the listener upon call
16
- // */
17
- // export function listenResizeDebounced(
18
- // ...args: Parameters<typeof debounce>
19
- // ): ReturnType<typeof listenResize>;
20
- // export function listenResizeDebounced(
21
- // el: Parameters<typeof listenResize>[1],
22
- // ...args: Parameters<typeof debounce>
23
- // ): ReturnType<typeof listenResize>;
24
- // export function listenResizeDebounced(
25
- // ...args:
26
- // | [Parameters<typeof listenResize>[1], ...Parameters<typeof debounce>]
27
- // | Parameters<typeof debounce>
28
- // ) {
29
- // if (isUndefined(args[0])) {
30
- // return listenResize(debounce(...args));
31
- // }
32
- // return listenResize(debounce(...args.slice(1)), args[0]);
33
- // }
34
- // export default listenResizeDebounced;
@@ -1,8 +0,0 @@
1
- import throttle from "@koine/utils/throttle";
2
- import { listenResize } from "./listenResize";
3
- /**
4
- * Listen element's (`window` by default) _resize_ event throttling the callback
5
- *
6
- * @returns An automatic unbinding function to run to deregister the listener upon call
7
- */ export const listenResizeThrottled = (el, ...args)=>listenResize(throttle(...args), el);
8
- export default listenResizeThrottled;
package/listenScroll.mjs DELETED
@@ -1,10 +0,0 @@
1
- import { on } from "./on";
2
- /**
3
- * Listen element's (`window` by default) _scroll_ event
4
- *
5
- * @returns An automatic unbinding function to run to deregister the listener upon call
6
- */ export const listenScroll = (handler, el)=>on(el || window, "scroll", handler, {
7
- capture: true,
8
- passive: true
9
- });
10
- export default listenScroll;
@@ -1,8 +0,0 @@
1
- import debounce from "@koine/utils/debounce";
2
- import { listenScroll } from "./listenScroll";
3
- /**
4
- * Listen element's (`window` by default) _scroll_ event debouncing the callback
5
- *
6
- * @returns An automatic unbinding function to run to deregister the listener upon call
7
- */ export const listenScrollDebounced = (el, ...args)=>listenScroll(debounce(...args), el);
8
- export default listenScrollDebounced;
@@ -1,8 +0,0 @@
1
- import throttle from "@koine/utils/throttle";
2
- import { listenScroll } from "./listenScroll";
3
- /**
4
- * Listen element's (`window` by default) _scroll_ event throttling the callback
5
- *
6
- * @returns An automatic unbinding function to run to deregister the listener upon call
7
- */ export const listenScrollThrottled = (el, ...args)=>listenScroll(throttle(...args), el);
8
- export default listenScrollThrottled;
package/off.mjs DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Shortcut for `removeEventListener`
3
- */ export function off(el, type, handler, options = false) {
4
- if (process.env["NODE_ENV"] !== "production") {
5
- if (!el) {
6
- console.warn("[@koine/dom:off] unexisting DOM element");
7
- }
8
- }
9
- if (el) el.removeEventListener(type, handler, options);
10
- }
11
- export default off;
package/on.mjs DELETED
@@ -1,21 +0,0 @@
1
- // import noop from "@koine/utils/noop"; FIXME: build breaks with this import
2
- import off from "./off";
3
- /**
4
- * Shortcut for `addEventListener`
5
- *
6
- * @returns An automatic unbinding function to run to deregister the listener upon call
7
- */ export function on(el, type, handler, // handler: THandler /* EventListener | */ /* ((event: Event) => void) */,
8
- options = false) {
9
- if (process.env["NODE_ENV"] !== "production") {
10
- if (!el) {
11
- console.warn("[@koine/dom:on] unexisting DOM element");
12
- }
13
- }
14
- if (el) {
15
- el.addEventListener(type, handler, options);
16
- return ()=>off(el, type, handler);
17
- }
18
- // return noop;
19
- return ()=>void 0;
20
- }
21
- export default on;
@@ -1,15 +0,0 @@
1
- import { off, on } from "./index";
2
- export function onClickOutside(element, callback, autoUnbind = false) {
3
- const bind = (event)=>{
4
- // if (event.target.closest(element) === null) {
5
- if (!element.contains(event.target)) {
6
- callback(event);
7
- if (autoUnbind) unbind();
8
- }
9
- };
10
- const unbind = ()=>{
11
- off(document, "click", bind);
12
- };
13
- on(document, "click", bind);
14
- return unbind;
15
- }
package/once.mjs DELETED
@@ -1,13 +0,0 @@
1
- import off from "./off";
2
- import on from "./on";
3
- /**
4
- * One shot listener, it `addEventListener` and removes it first time is called
5
- * with `removeEventListener`
6
- */ export function once(el, type, handler, options = false) {
7
- const handlerWrapper = (event)=>{
8
- handler(event);
9
- off(el, type, handlerWrapper);
10
- };
11
- return on(el, type, handlerWrapper, options);
12
- }
13
- export default once;
package/removeClass.mjs DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Remove class shortcut
3
- */ export function removeClass(el, className = "") {
4
- if (process.env["NODE_ENV"] !== "production") {
5
- if (!el) {
6
- "[@koine/dom:removeClass] unexisting DOM element";
7
- return;
8
- }
9
- }
10
- if (el) el.classList.remove(className);
11
- }
12
- export default removeClass;
package/scrollTo.mjs DELETED
@@ -1,39 +0,0 @@
1
- import { off } from "./off";
2
- import { on } from "./on";
3
- /**
4
- * Native `scrollTo`, `"smooth"` and with callback
5
- *
6
- * @borrows https://stackoverflow.com/a/55686711/1938970
7
- *
8
- * @param offset - offset to scroll to
9
- * @param callback - callback function
10
- * @param [fallbackTimeout] - this appears to be needed in some hard to reproduce scenario on safari, where the callback seem to be never called
11
- * @param [behavior="smooth"]
12
- */ export function scrollTo(destination, callback, fallbackTimeout, behavior) {
13
- const fixedDestination = destination.toFixed();
14
- if (callback) {
15
- let callbackFired = false;
16
- const onScroll = function() {
17
- if (window.pageYOffset.toFixed() === fixedDestination) {
18
- off(window, "scroll", onScroll);
19
- callbackFired = true;
20
- callback();
21
- }
22
- };
23
- on(window, "scroll", onScroll);
24
- onScroll();
25
- if (fallbackTimeout) {
26
- setTimeout(()=>{
27
- if (!callbackFired) {
28
- off(window, "scroll", onScroll);
29
- callback();
30
- }
31
- }, fallbackTimeout);
32
- }
33
- }
34
- window.scrollTo({
35
- top: destination,
36
- behavior: behavior || "smooth"
37
- });
38
- }
39
- export default scrollTo;
package/setDataAttr.mjs DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Set data attribute
3
- *
4
- * @param element
5
- * @param attribute The name of the `data-{attr}`
6
- * @param value The value to set, `null` or `undefined` will remove the attribute
7
- */ export function setDataAttr(element, attribute, value) {
8
- if (value === null || typeof value === "undefined") {
9
- // delete element.dataset[attribute];
10
- // return;
11
- element.removeAttribute("data-" + attribute);
12
- return;
13
- }
14
- // element.dataset[attribute] = value.toString();
15
- element.setAttribute("data-" + attribute, value.toString());
16
- }
17
- export default setDataAttr;
package/setVendorCSS.mjs DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * Set vendor CSS rule
3
- *
4
- * @param element A single HTMLElement
5
- * @param prop CSS rule proerty
6
- * @param value The CSS value to set, it will be automatically vendor prefixed
7
- */ export function setVendorCSS(element, prop, value) {
8
- const propUpper = prop.charAt(0).toUpperCase() + prop.slice(1);
9
- // @ts-expect-error nevermind now...
10
- element.style["webkit" + propUpper] = value;
11
- // @ts-expect-error nevermind now...
12
- element.style["moz" + propUpper] = value;
13
- // @ts-expect-error nevermind now...
14
- element.style["ms" + propUpper] = value;
15
- // @ts-expect-error nevermind now...
16
- element.style["o" + propUpper] = value;
17
- // @ts-expect-error nevermind now...
18
- element.style[prop] = value;
19
- }
20
- export default setVendorCSS;
package/siblings.mjs DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Finds siblings nodes of the passed node.
3
- *
4
- * @borrows @glidejs/glide/src/utils/dom (source)
5
- */ export function siblings(node) {
6
- if (node && node.parentNode) {
7
- let n = node.parentNode.firstChild;
8
- const matched = [];
9
- for(; n; n = n.nextSibling){
10
- if (n.nodeType === 1 && n !== node) {
11
- matched.push(n);
12
- }
13
- }
14
- return matched;
15
- }
16
- return [];
17
- }
18
- export default siblings;
package/toArray.mjs DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Node list to array
3
- *
4
- * @param nodeList
5
- */ export function toArray(nodeList) {
6
- return Array.prototype.slice.call(nodeList);
7
- }
8
- export default toArray;
package/types.mjs DELETED
@@ -1 +0,0 @@
1
- export { };
package/typings.d.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * List here the global variables used by third party scripts supported within
3
- * the `koine` ecosystem.
4
- */
package/unlisten.mjs DELETED
@@ -1,35 +0,0 @@
1
- import { activeEvents, eventHandler, getIndex } from "./_listen-delegation";
2
- import { off } from "./off";
3
- /**
4
- * Stop listening for an event
5
- *
6
- * @category listen-delegation
7
- *
8
- * @param types The event type or types (comma separated)
9
- * @param selector The selector to remove the event from
10
- * @param callback The function to remove
11
- */ export function unlisten(types, // | `${TTypes},${TTypes}`
12
- // | `${TTypes},${TTypes},${TTypes}`
13
- // | `${TTypes},${TTypes},${TTypes},${TTypes}`
14
- // | `${TTypes},${TTypes},${TTypes},${TTypes},${TTypes}`,
15
- selector, callback) {
16
- // Loop through each event type
17
- types.split(",").forEach(function(type) {
18
- // Remove whitespace
19
- type = type.trim();
20
- // if event type doesn't exist, bail
21
- if (!activeEvents[type]) return;
22
- // If it's the last event of it's type, remove entirely
23
- if (activeEvents[type].length < 2 || !selector) {
24
- delete activeEvents[type];
25
- off(window, type, eventHandler, true);
26
- return;
27
- }
28
- // Otherwise, remove event
29
- // @ts-expect-error FIXME: type...
30
- const index = getIndex(activeEvents[type], selector, callback);
31
- if (index < 0) return;
32
- activeEvents[type].splice(index, 1);
33
- });
34
- }
35
- export default unlisten;