@studiometa/js-toolkit 2.11.2 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/Base/Base.d.ts +2 -2
  2. package/Base/Base.js +142 -79
  3. package/Base/Base.js.map +2 -2
  4. package/Base/features.d.ts +10 -2
  5. package/Base/features.js +23 -1
  6. package/Base/features.js.map +2 -2
  7. package/Base/managers/AbstractManager.d.ts +3 -3
  8. package/Base/managers/AbstractManager.js +21 -0
  9. package/Base/managers/AbstractManager.js.map +1 -1
  10. package/Base/managers/ActionManager.d.ts +4 -0
  11. package/Base/managers/ActionManager.js +10 -0
  12. package/Base/managers/ActionManager.js.map +7 -0
  13. package/Base/managers/ChildrenManager.d.ts +1 -1
  14. package/Base/managers/ChildrenManager.js +41 -8
  15. package/Base/managers/ChildrenManager.js.map +2 -2
  16. package/Base/managers/EventsManager.js +88 -7
  17. package/Base/managers/EventsManager.js.map +2 -2
  18. package/Base/managers/OptionsManager.js +25 -2
  19. package/Base/managers/OptionsManager.js.map +2 -2
  20. package/Base/managers/RefsManager.js +27 -6
  21. package/Base/managers/RefsManager.js.map +2 -2
  22. package/Base/managers/ResponsiveOptionsManager.js +22 -6
  23. package/Base/managers/ResponsiveOptionsManager.js.map +2 -2
  24. package/Base/managers/ServicesManager.d.ts +2 -4
  25. package/Base/managers/ServicesManager.js +56 -7
  26. package/Base/managers/ServicesManager.js.map +2 -2
  27. package/Base/utils.js +5 -1
  28. package/Base/utils.js.map +2 -2
  29. package/decorators/index.d.ts +0 -1
  30. package/decorators/index.js +0 -1
  31. package/decorators/index.js.map +2 -2
  32. package/decorators/withBreakpointManager.js +14 -4
  33. package/decorators/withBreakpointManager.js.map +2 -2
  34. package/decorators/withBreakpointObserver.js +13 -3
  35. package/decorators/withBreakpointObserver.js.map +2 -2
  36. package/decorators/withDrag.js +6 -0
  37. package/decorators/withDrag.js.map +1 -1
  38. package/decorators/withExtraConfig.js +3 -0
  39. package/decorators/withExtraConfig.js.map +1 -1
  40. package/decorators/withFreezedOptions.js +8 -0
  41. package/decorators/withFreezedOptions.js.map +1 -1
  42. package/decorators/withIntersectionObserver.js +10 -1
  43. package/decorators/withIntersectionObserver.js.map +2 -2
  44. package/decorators/withMountOnMediaQuery.js +17 -1
  45. package/decorators/withMountOnMediaQuery.js.map +2 -2
  46. package/decorators/withMountWhenInView.js +22 -1
  47. package/decorators/withMountWhenInView.js.map +2 -2
  48. package/decorators/withRelativePointer.js +6 -0
  49. package/decorators/withRelativePointer.js.map +1 -1
  50. package/decorators/withResponsiveOptions.js +3 -0
  51. package/decorators/withResponsiveOptions.js.map +1 -1
  52. package/decorators/withScrolledInView/utils.d.ts +12 -1
  53. package/decorators/withScrolledInView/utils.js +7 -7
  54. package/decorators/withScrolledInView/utils.js.map +2 -2
  55. package/decorators/withScrolledInView/withScrolledInView.js +13 -35
  56. package/decorators/withScrolledInView/withScrolledInView.js.map +2 -2
  57. package/helpers/createApp.d.ts +2 -1
  58. package/helpers/createApp.js +2 -2
  59. package/helpers/createApp.js.map +2 -2
  60. package/helpers/getDirectChildren.js.map +1 -1
  61. package/helpers/importOnInteraction.js +4 -4
  62. package/helpers/importOnInteraction.js.map +2 -2
  63. package/helpers/importWhenVisible.js +2 -1
  64. package/helpers/importWhenVisible.js.map +2 -2
  65. package/package.json +2 -10
  66. package/services/drag.js +8 -8
  67. package/services/drag.js.map +2 -2
  68. package/services/index.d.ts +1 -1
  69. package/services/index.js.map +2 -2
  70. package/services/key.js +2 -2
  71. package/services/key.js.map +2 -2
  72. package/services/load.js +3 -0
  73. package/services/load.js.map +1 -1
  74. package/services/pointer.d.ts +1 -1
  75. package/services/pointer.js +7 -7
  76. package/services/pointer.js.map +2 -2
  77. package/services/raf.js +4 -6
  78. package/services/raf.js.map +2 -2
  79. package/services/resize.d.ts +7 -6
  80. package/services/resize.js +19 -26
  81. package/services/resize.js.map +2 -2
  82. package/services/scroll.js +8 -8
  83. package/services/scroll.js.map +2 -2
  84. package/services/service.js +2 -2
  85. package/services/service.js.map +2 -2
  86. package/utils/Queue.js +30 -0
  87. package/utils/Queue.js.map +1 -1
  88. package/utils/SmartQueue.d.ts +1 -1
  89. package/utils/SmartQueue.js +13 -1
  90. package/utils/SmartQueue.js.map +2 -2
  91. package/utils/collide/collidePointRect.js +4 -1
  92. package/utils/collide/collidePointRect.js.map +1 -1
  93. package/utils/collide/collideRectRect.js +4 -1
  94. package/utils/collide/collideRectRect.js.map +1 -1
  95. package/utils/css/animate.d.ts +33 -15
  96. package/utils/css/animate.js +80 -34
  97. package/utils/css/animate.js.map +2 -2
  98. package/utils/css/classes.js +2 -3
  99. package/utils/css/classes.js.map +2 -2
  100. package/utils/css/getOffsetSizes.js +2 -2
  101. package/utils/css/getOffsetSizes.js.map +1 -1
  102. package/utils/css/index.d.ts +2 -1
  103. package/utils/css/index.js +4 -4
  104. package/utils/css/index.js.map +2 -2
  105. package/utils/css/matrix.d.ts +1 -1
  106. package/utils/css/matrix.js.map +2 -2
  107. package/utils/css/styles.js +2 -2
  108. package/utils/css/styles.js.map +2 -2
  109. package/utils/css/transform.d.ts +1 -1
  110. package/utils/css/transform.js +1 -1
  111. package/utils/css/transform.js.map +2 -2
  112. package/utils/css/transition.js +15 -0
  113. package/utils/css/transition.js.map +1 -1
  114. package/utils/css/utils.d.ts +1 -1
  115. package/utils/css/utils.js +1 -1
  116. package/utils/css/utils.js.map +2 -2
  117. package/utils/history.js +6 -5
  118. package/utils/history.js.map +2 -2
  119. package/utils/index.d.ts +5 -4
  120. package/utils/index.js +16 -16
  121. package/utils/index.js.map +2 -2
  122. package/utils/is.d.ts +12 -0
  123. package/utils/is.js +17 -0
  124. package/utils/is.js.map +2 -2
  125. package/utils/math/ease.d.ts +1 -0
  126. package/utils/math/ease.js +2 -0
  127. package/utils/math/ease.js.map +2 -2
  128. package/utils/math/index.d.ts +4 -3
  129. package/utils/math/index.js +5 -3
  130. package/utils/math/index.js.map +2 -2
  131. package/utils/math/mean.d.ts +1 -0
  132. package/utils/math/mean.js +17 -0
  133. package/utils/math/mean.js.map +7 -0
  134. package/utils/nextFrame.d.ts +4 -22
  135. package/utils/nextFrame.js +3 -10
  136. package/utils/nextFrame.js.map +2 -2
  137. package/utils/nextMicrotask.d.ts +4 -1
  138. package/utils/nextMicrotask.js +3 -3
  139. package/utils/nextMicrotask.js.map +2 -2
  140. package/utils/nextTick.d.ts +4 -1
  141. package/utils/nextTick.js +3 -3
  142. package/utils/nextTick.js.map +2 -2
  143. package/utils/random.d.ts +15 -0
  144. package/utils/random.js +15 -0
  145. package/utils/random.js.map +7 -0
  146. package/utils/scheduler.js +4 -4
  147. package/utils/scheduler.js.map +2 -2
  148. package/utils/scrollTo.d.ts +30 -6
  149. package/utils/scrollTo.js +97 -43
  150. package/utils/scrollTo.js.map +2 -2
  151. package/utils/string/endsWith.d.ts +8 -0
  152. package/utils/string/endsWith.js +13 -0
  153. package/utils/string/endsWith.js.map +7 -0
  154. package/utils/string/index.d.ts +2 -0
  155. package/utils/string/index.js +2 -0
  156. package/utils/string/index.js.map +2 -2
  157. package/utils/string/startsWith.d.ts +8 -0
  158. package/utils/string/startsWith.js +13 -0
  159. package/utils/string/startsWith.js.map +7 -0
  160. package/utils/string/withLeadingCharacters.js.map +1 -1
  161. package/utils/string/withTrailingCharacters.js.map +1 -1
  162. package/utils/string/withoutLeadingCharacters.js.map +1 -1
  163. package/utils/string/withoutLeadingCharactersRecursive.js.map +1 -1
  164. package/utils/string/withoutTrailingCharacters.js.map +1 -1
  165. package/utils/string/withoutTrailingCharactersRecursive.js.map +1 -1
  166. package/utils/{focusTrap.d.ts → trapFocus.d.ts} +2 -10
  167. package/utils/{focusTrap.js → trapFocus.js} +5 -9
  168. package/utils/trapFocus.js.map +7 -0
  169. package/utils/tween.d.ts +59 -10
  170. package/utils/tween.js +24 -18
  171. package/utils/tween.js.map +2 -2
  172. package/Base/Base.cjs +0 -325
  173. package/Base/Base.cjs.map +0 -7
  174. package/Base/features.cjs +0 -27
  175. package/Base/features.cjs.map +0 -7
  176. package/Base/index.cjs +0 -21
  177. package/Base/index.cjs.map +0 -7
  178. package/Base/managers/AbstractManager.cjs +0 -57
  179. package/Base/managers/AbstractManager.cjs.map +0 -7
  180. package/Base/managers/ChildrenManager.cjs +0 -123
  181. package/Base/managers/ChildrenManager.cjs.map +0 -7
  182. package/Base/managers/EventsManager.cjs +0 -220
  183. package/Base/managers/EventsManager.cjs.map +0 -7
  184. package/Base/managers/OptionsManager.cjs +0 -171
  185. package/Base/managers/OptionsManager.cjs.map +0 -7
  186. package/Base/managers/RefsManager.cjs +0 -104
  187. package/Base/managers/RefsManager.cjs.map +0 -7
  188. package/Base/managers/ResponsiveOptionsManager.cjs +0 -63
  189. package/Base/managers/ResponsiveOptionsManager.cjs.map +0 -7
  190. package/Base/managers/ServicesManager.cjs +0 -111
  191. package/Base/managers/ServicesManager.cjs.map +0 -7
  192. package/Base/managers/index.cjs +0 -39
  193. package/Base/managers/index.cjs.map +0 -7
  194. package/Base/types.cjs +0 -19
  195. package/Base/types.cjs.map +0 -7
  196. package/Base/utils.cjs +0 -91
  197. package/Base/utils.cjs.map +0 -7
  198. package/decorators/index.cjs +0 -33
  199. package/decorators/index.cjs.map +0 -7
  200. package/decorators/withBreakpointManager.cjs +0 -92
  201. package/decorators/withBreakpointManager.cjs.map +0 -7
  202. package/decorators/withBreakpointObserver.cjs +0 -118
  203. package/decorators/withBreakpointObserver.cjs.map +0 -7
  204. package/decorators/withDrag.cjs +0 -50
  205. package/decorators/withDrag.cjs.map +0 -7
  206. package/decorators/withExtraConfig.cjs +0 -43
  207. package/decorators/withExtraConfig.cjs.map +0 -7
  208. package/decorators/withFreezedOptions.cjs +0 -42
  209. package/decorators/withFreezedOptions.cjs.map +0 -7
  210. package/decorators/withIntersectionObserver.cjs +0 -62
  211. package/decorators/withIntersectionObserver.cjs.map +0 -7
  212. package/decorators/withMountOnMediaQuery.cjs +0 -70
  213. package/decorators/withMountOnMediaQuery.cjs.map +0 -7
  214. package/decorators/withMountWhenInView.cjs +0 -71
  215. package/decorators/withMountWhenInView.cjs.map +0 -7
  216. package/decorators/withMountWhenPrefersMotion.cjs +0 -30
  217. package/decorators/withMountWhenPrefersMotion.cjs.map +0 -7
  218. package/decorators/withRelativePointer.cjs +0 -50
  219. package/decorators/withRelativePointer.cjs.map +0 -7
  220. package/decorators/withResponsiveOptions.cjs +0 -38
  221. package/decorators/withResponsiveOptions.cjs.map +0 -7
  222. package/decorators/withScrolledInView/index.cjs +0 -22
  223. package/decorators/withScrolledInView/index.cjs.map +0 -7
  224. package/decorators/withScrolledInView/types.cjs +0 -19
  225. package/decorators/withScrolledInView/types.cjs.map +0 -7
  226. package/decorators/withScrolledInView/utils.cjs +0 -99
  227. package/decorators/withScrolledInView/utils.cjs.map +0 -7
  228. package/decorators/withScrolledInView/withScrolledInView.cjs +0 -216
  229. package/decorators/withScrolledInView/withScrolledInView.cjs.map +0 -7
  230. package/decorators/withVue2.cjs +0 -65
  231. package/decorators/withVue2.cjs.map +0 -7
  232. package/decorators/withVue2.d.ts +0 -16
  233. package/decorators/withVue2.js +0 -43
  234. package/decorators/withVue2.js.map +0 -7
  235. package/helpers/createApp.cjs +0 -58
  236. package/helpers/createApp.cjs.map +0 -7
  237. package/helpers/getClosestParent.cjs +0 -41
  238. package/helpers/getClosestParent.cjs.map +0 -7
  239. package/helpers/getDirectChildren.cjs +0 -47
  240. package/helpers/getDirectChildren.cjs.map +0 -7
  241. package/helpers/getInstanceFromElement.cjs +0 -32
  242. package/helpers/getInstanceFromElement.cjs.map +0 -7
  243. package/helpers/importOnInteraction.cjs +0 -48
  244. package/helpers/importOnInteraction.cjs.map +0 -7
  245. package/helpers/importOnMediaQuery.cjs +0 -44
  246. package/helpers/importOnMediaQuery.cjs.map +0 -7
  247. package/helpers/importWhenIdle.cjs +0 -46
  248. package/helpers/importWhenIdle.cjs.map +0 -7
  249. package/helpers/importWhenPrefersMotion.cjs +0 -36
  250. package/helpers/importWhenPrefersMotion.cjs.map +0 -7
  251. package/helpers/importWhenVisible.cjs +0 -43
  252. package/helpers/importWhenVisible.cjs.map +0 -7
  253. package/helpers/index.cjs +0 -49
  254. package/helpers/index.cjs.map +0 -7
  255. package/helpers/utils.cjs +0 -37
  256. package/helpers/utils.cjs.map +0 -7
  257. package/index.cjs +0 -31
  258. package/index.cjs.map +0 -7
  259. package/services/drag.cjs +0 -227
  260. package/services/drag.cjs.map +0 -7
  261. package/services/index.cjs +0 -47
  262. package/services/index.cjs.map +0 -7
  263. package/services/key.cjs +0 -93
  264. package/services/key.cjs.map +0 -7
  265. package/services/load.cjs +0 -57
  266. package/services/load.cjs.map +0 -7
  267. package/services/pointer.cjs +0 -145
  268. package/services/pointer.cjs.map +0 -7
  269. package/services/raf.cjs +0 -80
  270. package/services/raf.cjs.map +0 -7
  271. package/services/resize.cjs +0 -103
  272. package/services/resize.cjs.map +0 -7
  273. package/services/scroll.cjs +0 -115
  274. package/services/scroll.cjs.map +0 -7
  275. package/services/service.cjs +0 -69
  276. package/services/service.cjs.map +0 -7
  277. package/utils/Queue.cjs +0 -63
  278. package/utils/Queue.cjs.map +0 -7
  279. package/utils/SmartQueue.cjs +0 -57
  280. package/utils/SmartQueue.cjs.map +0 -7
  281. package/utils/collide/boundingRectToCircle.cjs +0 -36
  282. package/utils/collide/boundingRectToCircle.cjs.map +0 -7
  283. package/utils/collide/collideCircleCircle.cjs +0 -35
  284. package/utils/collide/collideCircleCircle.cjs.map +0 -7
  285. package/utils/collide/collideCircleRect.cjs +0 -47
  286. package/utils/collide/collideCircleRect.cjs.map +0 -7
  287. package/utils/collide/collidePointCircle.cjs +0 -32
  288. package/utils/collide/collidePointCircle.cjs.map +0 -7
  289. package/utils/collide/collidePointRect.cjs +0 -29
  290. package/utils/collide/collidePointRect.cjs.map +0 -7
  291. package/utils/collide/collideRectRect.cjs +0 -29
  292. package/utils/collide/collideRectRect.cjs.map +0 -7
  293. package/utils/collide/index.cjs +0 -43
  294. package/utils/collide/index.cjs.map +0 -7
  295. package/utils/css/animate.cjs +0 -193
  296. package/utils/css/animate.cjs.map +0 -7
  297. package/utils/css/classes.cjs +0 -52
  298. package/utils/css/classes.cjs.map +0 -7
  299. package/utils/css/getOffsetSizes.cjs +0 -48
  300. package/utils/css/getOffsetSizes.cjs.map +0 -7
  301. package/utils/css/index.cjs +0 -48
  302. package/utils/css/index.cjs.map +0 -7
  303. package/utils/css/matrix.cjs +0 -30
  304. package/utils/css/matrix.cjs.map +0 -7
  305. package/utils/css/styles.cjs +0 -45
  306. package/utils/css/styles.cjs.map +0 -7
  307. package/utils/css/transform.cjs +0 -91
  308. package/utils/css/transform.cjs.map +0 -7
  309. package/utils/css/transition.cjs +0 -126
  310. package/utils/css/transition.cjs.map +0 -7
  311. package/utils/css/utils.cjs +0 -32
  312. package/utils/css/utils.cjs.map +0 -7
  313. package/utils/debounce.cjs +0 -35
  314. package/utils/debounce.cjs.map +0 -7
  315. package/utils/dom/ancestors.cjs +0 -37
  316. package/utils/dom/ancestors.cjs.map +0 -7
  317. package/utils/dom/index.cjs +0 -21
  318. package/utils/dom/index.cjs.map +0 -7
  319. package/utils/focusTrap.cjs +0 -89
  320. package/utils/focusTrap.cjs.map +0 -7
  321. package/utils/focusTrap.js.map +0 -7
  322. package/utils/getComponentResolver.cjs +0 -38
  323. package/utils/getComponentResolver.cjs.map +0 -7
  324. package/utils/has.cjs +0 -29
  325. package/utils/has.cjs.map +0 -7
  326. package/utils/history.cjs +0 -91
  327. package/utils/history.cjs.map +0 -7
  328. package/utils/index.cjs +0 -72
  329. package/utils/index.cjs.map +0 -7
  330. package/utils/is.cjs +0 -41
  331. package/utils/is.cjs.map +0 -7
  332. package/utils/keyCodes.cjs +0 -36
  333. package/utils/keyCodes.cjs.map +0 -7
  334. package/utils/math/clamp.cjs +0 -29
  335. package/utils/math/clamp.cjs.map +0 -7
  336. package/utils/math/clamp01.cjs +0 -36
  337. package/utils/math/clamp01.cjs.map +0 -7
  338. package/utils/math/createEases.cjs +0 -33
  339. package/utils/math/createEases.cjs.map +0 -7
  340. package/utils/math/damp.cjs +0 -29
  341. package/utils/math/damp.cjs.map +0 -7
  342. package/utils/math/ease.cjs +0 -82
  343. package/utils/math/ease.cjs.map +0 -7
  344. package/utils/math/index.cjs +0 -50
  345. package/utils/math/index.cjs.map +0 -7
  346. package/utils/math/inertiaFinalValue.cjs +0 -43
  347. package/utils/math/inertiaFinalValue.cjs.map +0 -7
  348. package/utils/math/lerp.cjs +0 -29
  349. package/utils/math/lerp.cjs.map +0 -7
  350. package/utils/math/map.cjs +0 -29
  351. package/utils/math/map.cjs.map +0 -7
  352. package/utils/math/round.cjs +0 -29
  353. package/utils/math/round.cjs.map +0 -7
  354. package/utils/memoize.cjs +0 -48
  355. package/utils/memoize.cjs.map +0 -7
  356. package/utils/nextFrame.cjs +0 -41
  357. package/utils/nextFrame.cjs.map +0 -7
  358. package/utils/nextMicrotask.cjs +0 -30
  359. package/utils/nextMicrotask.cjs.map +0 -7
  360. package/utils/nextTick.cjs +0 -31
  361. package/utils/nextTick.cjs.map +0 -7
  362. package/utils/noop.cjs +0 -32
  363. package/utils/noop.cjs.map +0 -7
  364. package/utils/object/autoBind.cjs +0 -54
  365. package/utils/object/autoBind.cjs.map +0 -7
  366. package/utils/object/autoBind.d.ts +0 -14
  367. package/utils/object/autoBind.js +0 -26
  368. package/utils/object/autoBind.js.map +0 -7
  369. package/utils/object/getAllProperties.cjs +0 -39
  370. package/utils/object/getAllProperties.cjs.map +0 -7
  371. package/utils/object/index.cjs +0 -35
  372. package/utils/object/index.cjs.map +0 -7
  373. package/utils/object/index.d.ts +0 -2
  374. package/utils/object/index.js +0 -7
  375. package/utils/object/index.js.map +0 -7
  376. package/utils/scheduler.cjs +0 -75
  377. package/utils/scheduler.cjs.map +0 -7
  378. package/utils/scrollTo.cjs +0 -84
  379. package/utils/scrollTo.cjs.map +0 -7
  380. package/utils/string/index.cjs +0 -51
  381. package/utils/string/index.cjs.map +0 -7
  382. package/utils/string/withLeadingCharacters.cjs +0 -36
  383. package/utils/string/withLeadingCharacters.cjs.map +0 -7
  384. package/utils/string/withLeadingSlash.cjs +0 -36
  385. package/utils/string/withLeadingSlash.cjs.map +0 -7
  386. package/utils/string/withTrailingCharacters.cjs +0 -36
  387. package/utils/string/withTrailingCharacters.cjs.map +0 -7
  388. package/utils/string/withTrailingSlash.cjs +0 -36
  389. package/utils/string/withTrailingSlash.cjs.map +0 -7
  390. package/utils/string/withoutLeadingCharacters.cjs +0 -29
  391. package/utils/string/withoutLeadingCharacters.cjs.map +0 -7
  392. package/utils/string/withoutLeadingCharactersRecursive.cjs +0 -41
  393. package/utils/string/withoutLeadingCharactersRecursive.cjs.map +0 -7
  394. package/utils/string/withoutLeadingSlash.cjs +0 -36
  395. package/utils/string/withoutLeadingSlash.cjs.map +0 -7
  396. package/utils/string/withoutTrailingCharacters.cjs +0 -29
  397. package/utils/string/withoutTrailingCharacters.cjs.map +0 -7
  398. package/utils/string/withoutTrailingCharactersRecursive.cjs +0 -41
  399. package/utils/string/withoutTrailingCharactersRecursive.cjs.map +0 -7
  400. package/utils/string/withoutTrailingSlash.cjs +0 -36
  401. package/utils/string/withoutTrailingSlash.cjs.map +0 -7
  402. package/utils/throttle.cjs +0 -37
  403. package/utils/throttle.cjs.map +0 -7
  404. package/utils/tween.cjs +0 -118
  405. package/utils/tween.cjs.map +0 -7
  406. package/utils/wait.cjs +0 -31
  407. package/utils/wait.cjs.map +0 -7
@@ -1,216 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/decorators/withScrolledInView/withScrolledInView.ts
20
- var withScrolledInView_exports = {};
21
- __export(withScrolledInView_exports, {
22
- withScrolledInView: () => withScrolledInView
23
- });
24
- module.exports = __toCommonJS(withScrolledInView_exports);
25
- var import_withMountWhenInView = require("../withMountWhenInView.cjs");
26
- var import_utils = require("../../utils/index.cjs");
27
- var import_utils2 = require("./utils.cjs");
28
- var scheduler = (0, import_utils.useScheduler)(["update", "render"]);
29
- function updateProgress(props, axis, progressKey, currentKey) {
30
- props[progressKey][axis] = props.start[axis] === props.end[axis] ? 0 : (0, import_utils.clamp01)(
31
- (props[currentKey][axis] - props.start[axis]) / (props.end[axis] - props.start[axis])
32
- );
33
- }
34
- function updateProps(props, dampFactor, dampPrecision, axis = "x") {
35
- props.current[axis] = (0, import_utils.clamp)(
36
- axis === "x" ? window.pageXOffset : window.pageYOffset,
37
- props.start[axis],
38
- props.end[axis]
39
- );
40
- props.dampedCurrent[axis] = (0, import_utils.damp)(
41
- props.current[axis],
42
- props.dampedCurrent[axis],
43
- dampFactor,
44
- dampPrecision
45
- );
46
- updateProgress(props, axis, "progress", "current");
47
- updateProgress(props, axis, "dampedProgress", "dampedCurrent");
48
- }
49
- function withScrolledInView(BaseClass, options = {}) {
50
- class WithScrolledInView extends (0, import_withMountWhenInView.withMountWhenInView)(
51
- BaseClass,
52
- options
53
- ) {
54
- static config = {
55
- name: `${BaseClass.config.name}WithMountWhenInView`,
56
- emits: ["scrolledInView"],
57
- options: {
58
- dampFactor: {
59
- type: Number,
60
- default: 0.1
61
- },
62
- dampPrecision: {
63
- type: Number,
64
- default: 1e-3
65
- },
66
- offset: {
67
- type: String,
68
- default: "start end / end start"
69
- }
70
- }
71
- };
72
- __props = {
73
- start: {
74
- x: 0,
75
- y: 0
76
- },
77
- end: {
78
- x: 0,
79
- y: 0
80
- },
81
- current: {
82
- x: 0,
83
- y: 0
84
- },
85
- dampedCurrent: {
86
- x: 0,
87
- y: 0
88
- },
89
- progress: {
90
- x: 0,
91
- y: 0
92
- },
93
- dampedProgress: {
94
- x: 0,
95
- y: 0
96
- }
97
- };
98
- shouldEvaluateProps = true;
99
- get props() {
100
- if (this.shouldEvaluateProps) {
101
- this.shouldEvaluateProps = false;
102
- const targetSizes = options.useOffsetSizes ? (0, import_utils.getOffsetSizes)(this.$el) : this.$el.getBoundingClientRect();
103
- targetSizes.y += window.pageYOffset;
104
- targetSizes.x += window.pageXOffset;
105
- const containerSizes = {
106
- x: 0,
107
- y: 0,
108
- height: window.innerHeight,
109
- width: window.innerWidth
110
- };
111
- const offset = (0, import_utils2.normalizeOffset)(this.$options.offset);
112
- const [yStart, yEnd] = (0, import_utils2.getEdges)("y", targetSizes, containerSizes, offset);
113
- const yCurrent = (0, import_utils.clamp)(window.pageYOffset, yStart, yEnd);
114
- const yProgress = yStart === yEnd ? 0 : (0, import_utils.clamp01)((yCurrent - yStart) / (yEnd - yStart));
115
- const [xStart, xEnd] = (0, import_utils2.getEdges)("x", targetSizes, containerSizes, offset);
116
- const xCurrent = (0, import_utils.clamp)(window.pageXOffset, xStart, xEnd);
117
- const xProgress = xStart === xEnd ? 0 : (0, import_utils.clamp01)((xCurrent - xStart) / (xEnd - xStart));
118
- this.__props.start.x = xStart;
119
- this.__props.start.y = yStart;
120
- this.__props.end.x = xEnd;
121
- this.__props.end.y = yEnd;
122
- this.__props.current.x = xCurrent;
123
- this.__props.current.y = yCurrent;
124
- this.__props.dampedCurrent.x = xCurrent;
125
- this.__props.dampedCurrent.y = yCurrent;
126
- this.__props.progress.x = xProgress;
127
- this.__props.progress.y = yProgress;
128
- this.__props.dampedProgress.x = xProgress;
129
- this.__props.dampedProgress.y = yProgress;
130
- }
131
- return this.__props;
132
- }
133
- dampFactor = null;
134
- dampPrecision = null;
135
- constructor(element) {
136
- super(element);
137
- const render = () => {
138
- scheduler.update(() => {
139
- const renderFn = this.__callMethod("scrolledInView", this.props);
140
- if ((0, import_utils.isFunction)(renderFn)) {
141
- scheduler.render(() => {
142
- renderFn(this.__props);
143
- });
144
- }
145
- });
146
- };
147
- const delegate = {
148
- handleEvent(event) {
149
- delegate[event.type](event.detail[0]);
150
- },
151
- resized: () => {
152
- this.shouldEvaluateProps = true;
153
- render();
154
- },
155
- scrolled: (props) => {
156
- if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
157
- this.$services.enable("ticked");
158
- }
159
- },
160
- ticked: () => {
161
- const dampFactor = this.dampFactor ?? this.$options.dampFactor;
162
- const dampPrecision = this.dampPrecision ?? this.$options.dampPrecision;
163
- updateProps(this.__props, dampFactor, dampPrecision, "x");
164
- updateProps(this.__props, dampFactor, dampPrecision, "y");
165
- if (this.__props.dampedCurrent.x === this.__props.current.x && this.__props.dampedCurrent.y === this.__props.current.y) {
166
- this.$services.disable("ticked");
167
- }
168
- render();
169
- }
170
- };
171
- this.$on("before-mounted", () => {
172
- this.$on("resized", delegate);
173
- this.$on("scrolled", delegate);
174
- this.$on("ticked", delegate);
175
- });
176
- this.$on("destroyed", () => {
177
- this.$off("resized", delegate);
178
- this.$off("scrolled", delegate);
179
- this.$off("ticked", delegate);
180
- this.__props.dampedCurrent.x = this.__props.current.x;
181
- this.__props.dampedCurrent.y = this.__props.current.y;
182
- this.__props.dampedProgress.x = this.__props.progress.x;
183
- this.__props.dampedProgress.y = this.__props.progress.y;
184
- render();
185
- });
186
- }
187
- mounted() {
188
- if ((0, import_utils.isFunction)(super.mounted)) {
189
- super.mounted();
190
- }
191
- }
192
- resized(props) {
193
- if ((0, import_utils.isFunction)(super.resized)) {
194
- super.resized(props);
195
- }
196
- }
197
- scrolled(props) {
198
- if ((0, import_utils.isFunction)(super.scrolled)) {
199
- super.scrolled(props);
200
- }
201
- }
202
- ticked(props) {
203
- if ((0, import_utils.isFunction)(super.ticked)) {
204
- super.ticked(props);
205
- }
206
- }
207
- destroyed() {
208
- if ((0, import_utils.isFunction)(super.destroyed)) {
209
- super.destroyed();
210
- }
211
- }
212
- }
213
- return WithScrolledInView;
214
- }
215
- if (module.exports.default) module.exports = module.exports.default;
216
- //# sourceMappingURL=withScrolledInView.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/decorators/withScrolledInView/withScrolledInView.ts"],
4
- "sourcesContent": ["import type { BaseInterface, BaseDecorator } from '../../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../../Base/index.js';\nimport type {\n RafServiceProps,\n ScrollServiceProps,\n ResizeServiceProps,\n} from '../../services/index.js';\nimport { withMountWhenInView } from '../withMountWhenInView.js';\nimport {\n damp,\n clamp,\n clamp01,\n getOffsetSizes,\n isFunction,\n useScheduler,\n} from '../../utils/index.js';\nimport { normalizeOffset, getEdges } from './utils.js';\n\nconst scheduler = useScheduler(['update', 'render']);\n\nexport interface WithScrolledInViewProps extends BaseProps {\n $options: {\n dampFactor: number;\n dampPrecision: number;\n offset: string;\n };\n}\n\nexport type ScrollInViewProps = {\n start: {\n x: number;\n y: number;\n };\n end: {\n x: number;\n y: number;\n };\n current: {\n x: number;\n y: number;\n };\n dampedCurrent: {\n x: number;\n y: number;\n };\n progress: {\n x: number;\n y: number;\n };\n dampedProgress: {\n x: number;\n y: number;\n };\n};\n\nexport type WithScrolledInViewOptions = IntersectionObserverInit & {\n useOffsetSizes?: boolean;\n};\n\nfunction updateProgress(\n props: ScrollInViewProps,\n axis: 'x' | 'y',\n progressKey: 'progress' | 'dampedProgress',\n currentKey: 'current' | 'dampedCurrent',\n) {\n props[progressKey][axis] =\n props.start[axis] === props.end[axis]\n ? 0\n : clamp01(\n (props[currentKey][axis] - props.start[axis]) / (props.end[axis] - props.start[axis]),\n );\n}\n\n/**\n * Update props on tick.\n */\nfunction updateProps(\n props: ScrollInViewProps,\n dampFactor: number,\n dampPrecision: number,\n axis: 'x' | 'y' = 'x',\n): void {\n props.current[axis] = clamp(\n axis === 'x' ? window.pageXOffset : window.pageYOffset,\n props.start[axis],\n props.end[axis],\n );\n props.dampedCurrent[axis] = damp(\n props.current[axis],\n props.dampedCurrent[axis],\n dampFactor,\n dampPrecision,\n );\n updateProgress(props, axis, 'progress', 'current');\n updateProgress(props, axis, 'dampedProgress', 'dampedCurrent');\n}\n\nexport interface WithScrolledInViewInterface extends BaseInterface {\n /**\n * @type {ScrollInViewProps}\n */\n readonly props: ScrollInViewProps;\n dampFactor?: number;\n dampPrecision?: number;\n mounted(): void;\n resized(props: ResizeServiceProps): void;\n scrolled(props: ScrollServiceProps): void;\n ticked(props: RafServiceProps): void;\n destroyed(): void;\n}\n\n/**\n * Add scrolled in view capabilities to a component.\n */\nexport function withScrolledInView<S extends Base = Base>(\n BaseClass: typeof Base,\n options: WithScrolledInViewOptions = {},\n): BaseDecorator<WithScrolledInViewInterface, S, WithScrolledInViewProps> {\n /**\n * Class.\n */\n class WithScrolledInView<T extends BaseProps = BaseProps> extends withMountWhenInView(\n BaseClass,\n options,\n )<T & WithScrolledInViewProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: `${BaseClass.config.name}WithMountWhenInView`,\n emits: ['scrolledInView'],\n options: {\n dampFactor: {\n type: Number,\n default: 0.1,\n },\n dampPrecision: {\n type: Number,\n default: 0.001,\n },\n offset: {\n type: String,\n default: 'start end / end start',\n },\n },\n };\n\n __props: ScrollInViewProps = {\n start: {\n x: 0,\n y: 0,\n },\n end: {\n x: 0,\n y: 0,\n },\n current: {\n x: 0,\n y: 0,\n },\n dampedCurrent: {\n x: 0,\n y: 0,\n },\n progress: {\n x: 0,\n y: 0,\n },\n dampedProgress: {\n x: 0,\n y: 0,\n },\n };\n\n shouldEvaluateProps = true;\n\n get props() {\n if (this.shouldEvaluateProps) {\n this.shouldEvaluateProps = false;\n const targetSizes = options.useOffsetSizes\n ? getOffsetSizes(this.$el)\n : this.$el.getBoundingClientRect();\n\n targetSizes.y += window.pageYOffset;\n targetSizes.x += window.pageXOffset;\n\n const containerSizes = {\n x: 0,\n y: 0,\n height: window.innerHeight,\n width: window.innerWidth,\n };\n\n const offset = normalizeOffset(this.$options.offset);\n\n // Y axis\n const [yStart, yEnd] = getEdges('y', targetSizes, containerSizes, offset);\n const yCurrent = clamp(window.pageYOffset, yStart, yEnd);\n const yProgress = yStart === yEnd ? 0 : clamp01((yCurrent - yStart) / (yEnd - yStart));\n // X axis\n const [xStart, xEnd] = getEdges('x', targetSizes, containerSizes, offset);\n const xCurrent = clamp(window.pageXOffset, xStart, xEnd);\n const xProgress = xStart === xEnd ? 0 : clamp01((xCurrent - xStart) / (xEnd - xStart));\n\n this.__props.start.x = xStart;\n this.__props.start.y = yStart;\n this.__props.end.x = xEnd;\n this.__props.end.y = yEnd;\n this.__props.current.x = xCurrent;\n this.__props.current.y = yCurrent;\n this.__props.dampedCurrent.x = xCurrent;\n this.__props.dampedCurrent.y = yCurrent;\n this.__props.progress.x = xProgress;\n this.__props.progress.y = yProgress;\n this.__props.dampedProgress.x = xProgress;\n this.__props.dampedProgress.y = yProgress;\n }\n\n return this.__props;\n }\n\n /**\n * Factor used for the `dampedProgress` props.\n *\n * @deprecated\n * @todo v3 delete in favor of option API\n */\n dampFactor?: number = null;\n\n /**\n * Precision for the `dampedProgress` props.\n *\n * @deprecated\n * @todo v3 delete in favor of option API\n */\n dampPrecision?: number = null;\n\n /**\n * Bind listeners.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n const render = () => {\n scheduler.update(() => {\n // @ts-ignore\n const renderFn = this.__callMethod('scrolledInView', this.props);\n if (isFunction(renderFn)) {\n scheduler.render(() => {\n renderFn(this.__props);\n });\n }\n });\n };\n\n const delegate = {\n handleEvent(event) {\n delegate[event.type](event.detail[0]);\n },\n resized: () => {\n this.shouldEvaluateProps = true;\n render();\n },\n scrolled: (props) => {\n if ((!this.$services.has('ticked') && props.changed.y) || props.changed.x) {\n this.$services.enable('ticked');\n }\n },\n ticked: () => {\n const dampFactor = this.dampFactor ?? this.$options.dampFactor;\n const dampPrecision = this.dampPrecision ?? this.$options.dampPrecision;\n updateProps(this.__props, dampFactor, dampPrecision, 'x');\n updateProps(this.__props, dampFactor, dampPrecision, 'y');\n\n if (\n this.__props.dampedCurrent.x === this.__props.current.x &&\n this.__props.dampedCurrent.y === this.__props.current.y\n ) {\n this.$services.disable('ticked');\n }\n\n render();\n },\n };\n\n this.$on('before-mounted', () => {\n this.$on('resized', delegate);\n this.$on('scrolled', delegate);\n this.$on('ticked', delegate);\n });\n\n this.$on('destroyed', () => {\n this.$off('resized', delegate);\n this.$off('scrolled', delegate);\n this.$off('ticked', delegate);\n\n // Clamp damped values to their final value and trigger one last render on destroy\n this.__props.dampedCurrent.x = this.__props.current.x;\n this.__props.dampedCurrent.y = this.__props.current.y;\n this.__props.dampedProgress.x = this.__props.progress.x;\n this.__props.dampedProgress.y = this.__props.progress.y;\n render();\n });\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n // @ts-ignore\n if (isFunction(super.mounted)) {\n // @ts-ignore\n super.mounted();\n }\n }\n\n /**\n * Resized hook.\n */\n resized(props: ResizeServiceProps) {\n // @ts-ignore\n if (isFunction(super.resized)) {\n // @ts-ignore\n super.resized(props);\n }\n }\n\n /**\n * Scrolled hook.\n */\n scrolled(props: ScrollServiceProps) {\n // @ts-ignore\n if (isFunction(super.scrolled)) {\n // @ts-ignore\n super.scrolled(props);\n }\n }\n\n /**\n * Ticked hook.\n */\n ticked(props: RafServiceProps) {\n // @ts-ignore\n if (isFunction(super.ticked)) {\n // @ts-ignore\n super.ticked(props);\n }\n }\n\n /**\n * Destroyed hook.\n */\n destroyed() {\n // @ts-ignore\n if (isFunction(super.destroyed)) {\n // @ts-ignore\n super.destroyed();\n }\n }\n }\n\n // @ts-ignore\n return WithScrolledInView;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;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2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/decorators/withVue2.ts
20
- var withVue2_exports = {};
21
- __export(withVue2_exports, {
22
- withVue2: () => withVue2
23
- });
24
- module.exports = __toCommonJS(withVue2_exports);
25
- var import_utils = require("../utils/index.cjs");
26
- function withVue2(BaseClass, VueCtor) {
27
- class WithVue2 extends BaseClass {
28
- static config = {
29
- ...BaseClass.config,
30
- name: `${BaseClass.config.name}WithVue`,
31
- refs: [...BaseClass.config?.refs ?? [], "vue"]
32
- };
33
- $vue;
34
- static vueConfig;
35
- constructor(element) {
36
- super(element);
37
- const vueConfig = this.vueConfig ?? this.constructor.vueConfig;
38
- if (!vueConfig) {
39
- if (import_utils.isDev) {
40
- throw new Error("[withVue] You must define a `vueConfig` object.");
41
- }
42
- return;
43
- }
44
- if (!(0, import_utils.isFunction)(vueConfig.render)) {
45
- if (import_utils.isDev) {
46
- throw new Error("[withVue] You must define a `render` function in vueConfig.");
47
- }
48
- return;
49
- }
50
- this.$vue = new VueCtor(vueConfig);
51
- this.$on("mounted", () => {
52
- if (!(this.$refs.vue instanceof HTMLElement)) {
53
- throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
54
- }
55
- this.$vue.$mount(this.$refs.vue);
56
- });
57
- this.$on("destroyed", () => {
58
- this.$vue.$destroy();
59
- });
60
- }
61
- }
62
- return WithVue2;
63
- }
64
- if (module.exports.default) module.exports = module.exports.default;
65
- //# sourceMappingURL=withVue2.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/decorators/withVue2.ts"],
4
- "sourcesContent": ["import type Vue from 'vue';\nimport type { ComponentOptions, VueConstructor } from 'vue';\nimport type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseConfig, BaseProps } from '../Base/index.js';\nimport { isDev, isFunction } from '../utils/index.js';\n\nexport interface WithVue2Props extends BaseProps {\n $refs: {\n vue: HTMLElement;\n };\n}\n\nexport interface WithVue2Interface extends BaseInterface {\n $vue: Vue;\n}\n\n/**\n * withVue decorator.\n */\nexport function withVue2<S extends Base, T extends Vue = Vue>(\n BaseClass: typeof Base,\n VueCtor: VueConstructor,\n): BaseDecorator<WithVue2Interface, S, WithVue2Props> {\n type VueConfig = ComponentOptions<T> & {\n render: ComponentOptions<T>['render'];\n };\n\n /**\n * Class.\n */\n class WithVue2 extends BaseClass {\n static config: BaseConfig = {\n ...BaseClass.config,\n name: `${BaseClass.config.name}WithVue`,\n refs: [...(BaseClass.config?.refs ?? []), 'vue'],\n };\n\n $vue: Vue;\n\n /**\n * Vue app configuration.\n */\n static vueConfig: VueConfig;\n\n constructor(element: HTMLElement) {\n super(element);\n\n // @ts-ignore\n const vueConfig: VueConfig = this.vueConfig ?? this.constructor.vueConfig;\n\n if (!vueConfig) {\n if (isDev) {\n throw new Error('[withVue] You must define a `vueConfig` object.');\n }\n return;\n }\n\n if (!isFunction(vueConfig.render)) {\n if (isDev) {\n throw new Error('[withVue] You must define a `render` function in vueConfig.');\n }\n return;\n }\n\n this.$vue = new VueCtor(vueConfig);\n\n this.$on('mounted', () => {\n if (!(this.$refs.vue instanceof HTMLElement)) {\n throw new Error('[withVue] The `vue` refs must be a single HTMLElement.');\n }\n\n this.$vue.$mount(this.$refs.vue);\n });\n\n this.$on('destroyed', () => {\n this.$vue.$destroy();\n });\n }\n }\n\n // @ts-ignore\n return WithVue2;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAkC;AAe3B,SAAS,SACd,WACA,SACoD;AAQpD,QAAM,iBAAiB,UAAU;AAAA,IAC/B,OAAO,SAAqB;AAAA,MAC1B,GAAG,UAAU;AAAA,MACb,MAAM,GAAG,UAAU,OAAO;AAAA,MAC1B,MAAM,CAAC,GAAI,UAAU,QAAQ,QAAQ,CAAC,GAAI,KAAK;AAAA,IACjD;AAAA,IAEA;AAAA,IAKA,OAAO;AAAA,IAEP,YAAY,SAAsB;AAChC,YAAM,OAAO;AAGb,YAAM,YAAuB,KAAK,aAAa,KAAK,YAAY;AAEhE,UAAI,CAAC,WAAW;AACd,YAAI,oBAAO;AACT,gBAAM,IAAI,MAAM,iDAAiD;AAAA,QACnE;AACA;AAAA,MACF;AAEA,UAAI,KAAC,yBAAW,UAAU,MAAM,GAAG;AACjC,YAAI,oBAAO;AACT,gBAAM,IAAI,MAAM,6DAA6D;AAAA,QAC/E;AACA;AAAA,MACF;AAEA,WAAK,OAAO,IAAI,QAAQ,SAAS;AAEjC,WAAK,IAAI,WAAW,MAAM;AACxB,YAAI,EAAE,KAAK,MAAM,eAAe,cAAc;AAC5C,gBAAM,IAAI,MAAM,wDAAwD;AAAA,QAC1E;AAEA,aAAK,KAAK,OAAO,KAAK,MAAM,GAAG;AAAA,MACjC,CAAC;AAED,WAAK,IAAI,aAAa,MAAM;AAC1B,aAAK,KAAK,SAAS;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,16 +0,0 @@
1
- import type Vue from 'vue';
2
- import type { VueConstructor } from 'vue';
3
- import type { BaseDecorator, BaseInterface } from '../Base/types.js';
4
- import type { Base, BaseProps } from '../Base/index.js';
5
- export interface WithVue2Props extends BaseProps {
6
- $refs: {
7
- vue: HTMLElement;
8
- };
9
- }
10
- export interface WithVue2Interface extends BaseInterface {
11
- $vue: Vue;
12
- }
13
- /**
14
- * withVue decorator.
15
- */
16
- export declare function withVue2<S extends Base, T extends Vue = Vue>(BaseClass: typeof Base, VueCtor: VueConstructor): BaseDecorator<WithVue2Interface, S, WithVue2Props>;
@@ -1,43 +0,0 @@
1
- import { isDev, isFunction } from "../utils/index.js";
2
- function withVue2(BaseClass, VueCtor) {
3
- class WithVue2 extends BaseClass {
4
- static config = {
5
- ...BaseClass.config,
6
- name: `${BaseClass.config.name}WithVue`,
7
- refs: [...BaseClass.config?.refs ?? [], "vue"]
8
- };
9
- $vue;
10
- static vueConfig;
11
- constructor(element) {
12
- super(element);
13
- const vueConfig = this.vueConfig ?? this.constructor.vueConfig;
14
- if (!vueConfig) {
15
- if (isDev) {
16
- throw new Error("[withVue] You must define a `vueConfig` object.");
17
- }
18
- return;
19
- }
20
- if (!isFunction(vueConfig.render)) {
21
- if (isDev) {
22
- throw new Error("[withVue] You must define a `render` function in vueConfig.");
23
- }
24
- return;
25
- }
26
- this.$vue = new VueCtor(vueConfig);
27
- this.$on("mounted", () => {
28
- if (!(this.$refs.vue instanceof HTMLElement)) {
29
- throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
30
- }
31
- this.$vue.$mount(this.$refs.vue);
32
- });
33
- this.$on("destroyed", () => {
34
- this.$vue.$destroy();
35
- });
36
- }
37
- }
38
- return WithVue2;
39
- }
40
- export {
41
- withVue2
42
- };
43
- //# sourceMappingURL=withVue2.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/decorators/withVue2.ts"],
4
- "sourcesContent": ["import type Vue from 'vue';\nimport type { ComponentOptions, VueConstructor } from 'vue';\nimport type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseConfig, BaseProps } from '../Base/index.js';\nimport { isDev, isFunction } from '../utils/index.js';\n\nexport interface WithVue2Props extends BaseProps {\n $refs: {\n vue: HTMLElement;\n };\n}\n\nexport interface WithVue2Interface extends BaseInterface {\n $vue: Vue;\n}\n\n/**\n * withVue decorator.\n */\nexport function withVue2<S extends Base, T extends Vue = Vue>(\n BaseClass: typeof Base,\n VueCtor: VueConstructor,\n): BaseDecorator<WithVue2Interface, S, WithVue2Props> {\n type VueConfig = ComponentOptions<T> & {\n render: ComponentOptions<T>['render'];\n };\n\n /**\n * Class.\n */\n class WithVue2 extends BaseClass {\n static config: BaseConfig = {\n ...BaseClass.config,\n name: `${BaseClass.config.name}WithVue`,\n refs: [...(BaseClass.config?.refs ?? []), 'vue'],\n };\n\n $vue: Vue;\n\n /**\n * Vue app configuration.\n */\n static vueConfig: VueConfig;\n\n constructor(element: HTMLElement) {\n super(element);\n\n // @ts-ignore\n const vueConfig: VueConfig = this.vueConfig ?? this.constructor.vueConfig;\n\n if (!vueConfig) {\n if (isDev) {\n throw new Error('[withVue] You must define a `vueConfig` object.');\n }\n return;\n }\n\n if (!isFunction(vueConfig.render)) {\n if (isDev) {\n throw new Error('[withVue] You must define a `render` function in vueConfig.');\n }\n return;\n }\n\n this.$vue = new VueCtor(vueConfig);\n\n this.$on('mounted', () => {\n if (!(this.$refs.vue instanceof HTMLElement)) {\n throw new Error('[withVue] The `vue` refs must be a single HTMLElement.');\n }\n\n this.$vue.$mount(this.$refs.vue);\n });\n\n this.$on('destroyed', () => {\n this.$vue.$destroy();\n });\n }\n }\n\n // @ts-ignore\n return WithVue2;\n}\n"],
5
- "mappings": "AAIA,SAAS,OAAO,kBAAkB;AAe3B,SAAS,SACd,WACA,SACoD;AAQpD,QAAM,iBAAiB,UAAU;AAAA,IAC/B,OAAO,SAAqB;AAAA,MAC1B,GAAG,UAAU;AAAA,MACb,MAAM,GAAG,UAAU,OAAO;AAAA,MAC1B,MAAM,CAAC,GAAI,UAAU,QAAQ,QAAQ,CAAC,GAAI,KAAK;AAAA,IACjD;AAAA,IAEA;AAAA,IAKA,OAAO;AAAA,IAEP,YAAY,SAAsB;AAChC,YAAM,OAAO;AAGb,YAAM,YAAuB,KAAK,aAAa,KAAK,YAAY;AAEhE,UAAI,CAAC,WAAW;AACd,YAAI,OAAO;AACT,gBAAM,IAAI,MAAM,iDAAiD;AAAA,QACnE;AACA;AAAA,MACF;AAEA,UAAI,CAAC,WAAW,UAAU,MAAM,GAAG;AACjC,YAAI,OAAO;AACT,gBAAM,IAAI,MAAM,6DAA6D;AAAA,QAC/E;AACA;AAAA,MACF;AAEA,WAAK,OAAO,IAAI,QAAQ,SAAS;AAEjC,WAAK,IAAI,WAAW,MAAM;AACxB,YAAI,EAAE,KAAK,MAAM,eAAe,cAAc;AAC5C,gBAAM,IAAI,MAAM,wDAAwD;AAAA,QAC1E;AAEA,aAAK,KAAK,OAAO,KAAK,MAAM,GAAG;AAAA,MACjC,CAAC;AAED,WAAK,IAAI,aAAa,MAAM;AAC1B,aAAK,KAAK,SAAS;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,58 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/helpers/createApp.ts
20
- var createApp_exports = {};
21
- __export(createApp_exports, {
22
- default: () => createApp
23
- });
24
- module.exports = __toCommonJS(createApp_exports);
25
- var import_features = require("../Base/features.cjs");
26
- var import_utils = require("../utils/index.cjs");
27
- function createApp(App, rootElement = document.body) {
28
- let app;
29
- const options = rootElement instanceof HTMLElement ? { root: rootElement, features: void 0 } : { root: document.body, ...rootElement };
30
- if ((0, import_utils.isDefined)(options.features)) {
31
- Object.entries(options.features).forEach(([feature, value]) => {
32
- import_features.features.set(feature, value);
33
- });
34
- }
35
- function init() {
36
- app = new App(options.root).$mount();
37
- return app;
38
- }
39
- let p;
40
- if (import_features.features.get("asyncChildren")) {
41
- p = Promise.resolve(init());
42
- } else {
43
- p = new Promise((resolve) => {
44
- if (document.readyState === "complete") {
45
- resolve(init());
46
- } else {
47
- document.addEventListener("readystatechange", () => {
48
- if (document.readyState === "complete") {
49
- resolve(init());
50
- }
51
- });
52
- }
53
- });
54
- }
55
- return () => p;
56
- }
57
- if (module.exports.default) module.exports = module.exports.default;
58
- //# sourceMappingURL=createApp.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/helpers/createApp.ts"],
4
- "sourcesContent": ["import type { Base, BaseConstructor, BaseProps } from '../Base/index.js';\nimport type { Features } from '../Base/features.js';\nimport { features } from '../Base/features.js';\nimport { isDefined } from '../utils/index.js';\n\nexport type CreateAppOptions = {\n root: HTMLElement;\n features: Features;\n};\n\n/**\n * Instantiate and mount the given component on the given root element when the page has been loaded\n * and return a function to use the app instance when it is ready.\n */\nexport default function createApp<S extends BaseConstructor<Base>, T extends BaseProps = BaseProps>(\n App: S,\n rootElement: HTMLElement | Partial<CreateAppOptions> = document.body,\n): () => Promise<S & Base<T>> {\n let app: S & Base<T>;\n const options =\n rootElement instanceof HTMLElement\n ? { root: rootElement, features: undefined }\n : { root: document.body, ...rootElement };\n\n if (isDefined(options.features)) {\n Object.entries(options.features as Features).forEach(([feature, value]) => {\n features.set(feature as keyof Features, value);\n });\n }\n\n function init() {\n app = (new App(options.root) as S & Base<T>).$mount();\n return app;\n }\n\n let p: Promise<S & Base<T>>;\n\n if (features.get('asyncChildren')) {\n p = Promise.resolve(init());\n } else {\n p = new Promise<S & Base<T>>((resolve) => {\n if (document.readyState === 'complete') {\n resolve(init());\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n resolve(init());\n }\n });\n }\n });\n }\n\n return () => p;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAyB;AACzB,mBAA0B;AAWX,SAAR,UACL,KACA,cAAuD,SAAS,MACpC;AAC5B,MAAI;AACJ,QAAM,UACJ,uBAAuB,cACnB,EAAE,MAAM,aAAa,UAAU,OAAU,IACzC,EAAE,MAAM,SAAS,MAAM,GAAG,YAAY;AAE5C,UAAI,wBAAU,QAAQ,QAAQ,GAAG;AAC/B,WAAO,QAAQ,QAAQ,QAAoB,EAAE,QAAQ,CAAC,CAAC,SAAS,KAAK,MAAM;AACzE,+BAAS,IAAI,SAA2B,KAAK;AAAA,IAC/C,CAAC;AAAA,EACH;AAEA,WAAS,OAAO;AACd,UAAO,IAAI,IAAI,QAAQ,IAAI,EAAkB,OAAO;AACpD,WAAO;AAAA,EACT;AAEA,MAAI;AAEJ,MAAI,yBAAS,IAAI,eAAe,GAAG;AACjC,QAAI,QAAQ,QAAQ,KAAK,CAAC;AAAA,EAC5B,OAAO;AACL,QAAI,IAAI,QAAqB,CAAC,YAAY;AACxC,UAAI,SAAS,eAAe,YAAY;AACtC,gBAAQ,KAAK,CAAC;AAAA,MAChB,OAAO;AACL,iBAAS,iBAAiB,oBAAoB,MAAM;AAClD,cAAI,SAAS,eAAe,YAAY;AACtC,oBAAQ,KAAK,CAAC;AAAA,UAChB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,MAAM;AACf;",
6
- "names": []
7
- }
@@ -1,41 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
-
25
- // packages/js-toolkit/helpers/getClosestParent.ts
26
- var getClosestParent_exports = {};
27
- __export(getClosestParent_exports, {
28
- default: () => getClosestParent
29
- });
30
- module.exports = __toCommonJS(getClosestParent_exports);
31
- var import_getInstanceFromElement = __toESM(require("./getInstanceFromElement.cjs"), 1);
32
- var import_utils = require("../utils/index.cjs");
33
- function getClosestParent(childInstance, ParentConstructor) {
34
- const parentEl = (0, import_utils.getAncestorWhere)(
35
- childInstance.$el,
36
- (element) => element && (0, import_getInstanceFromElement.default)(element, ParentConstructor) !== null
37
- );
38
- return parentEl ? (0, import_getInstanceFromElement.default)(parentEl, ParentConstructor) : null;
39
- }
40
- if (module.exports.default) module.exports = module.exports.default;
41
- //# sourceMappingURL=getClosestParent.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/helpers/getClosestParent.ts"],
4
- "sourcesContent": ["import type { Base, BaseConstructor } from '../Base/index.js';\nimport getInstanceFromElement from './getInstanceFromElement.js';\nimport { getAncestorWhere } from '../utils/index.js';\n\n/**\n * Get the closest parent of a component.\n */\nexport default function getClosestParent<T extends BaseConstructor>(\n childInstance: Base,\n ParentConstructor: T,\n) {\n const parentEl = getAncestorWhere(\n childInstance.$el,\n (element) => element && getInstanceFromElement(element, ParentConstructor) !== null,\n );\n\n return parentEl ? getInstanceFromElement(parentEl, ParentConstructor) : null;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAmC;AACnC,mBAAiC;AAKlB,SAAR,iBACL,eACA,mBACA;AACA,QAAM,eAAW;AAAA,IACf,cAAc;AAAA,IACd,CAAC,YAAY,eAAW,8BAAAA,SAAuB,SAAS,iBAAiB,MAAM;AAAA,EACjF;AAEA,SAAO,eAAW,8BAAAA,SAAuB,UAAU,iBAAiB,IAAI;AAC1E;",
6
- "names": ["getInstanceFromElement"]
7
- }
@@ -1,47 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/helpers/getDirectChildren.ts
20
- var getDirectChildren_exports = {};
21
- __export(getDirectChildren_exports, {
22
- getDirectChildren: () => getDirectChildren,
23
- isDirectChild: () => isDirectChild
24
- });
25
- module.exports = __toCommonJS(getDirectChildren_exports);
26
- var import_utils = require("../utils/index.cjs");
27
- function getDirectChildren(parentInstance, parentName, childrenName) {
28
- const children = parentInstance.$children[childrenName];
29
- const nestedParents = parentInstance.$children[parentName];
30
- if (!(0, import_utils.isArray)(children)) {
31
- return [];
32
- }
33
- if (!(0, import_utils.isArray)(nestedParents) || nestedParents.length <= 0) {
34
- return children;
35
- }
36
- return [...children].filter(
37
- (child) => [...nestedParents].every((nestedParent) => {
38
- const nestedChildren = nestedParent.$children[childrenName];
39
- return (0, import_utils.isArray)(nestedChildren) ? !nestedChildren.includes(child) : true;
40
- })
41
- );
42
- }
43
- function isDirectChild(parentInstance, parentName, childrenName, childInstance) {
44
- return getDirectChildren(parentInstance, parentName, childrenName).includes(childInstance);
45
- }
46
- if (module.exports.default) module.exports = module.exports.default;
47
- //# sourceMappingURL=getDirectChildren.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/helpers/getDirectChildren.ts"],
4
- "sourcesContent": ["import { Base, BaseProps } from '../Base/index.js';\nimport { isArray } from '../utils/index.js';\n\n/**\n * Get direct children from a parent when working with nested components.\n *\n * @template {Base} T\n * @param {Base} parentInstance\n * @param {string} parentName\n * @param {string} childrenName\n * @returns {T[]}\n */\nexport function getDirectChildren<T extends Base = Base>(\n parentInstance: Base,\n parentName: string,\n childrenName: string,\n): T[] {\n const children = parentInstance.$children[childrenName] as Base<BaseProps>[];\n const nestedParents = parentInstance.$children[parentName] as Base<BaseProps>[];\n\n if (!isArray(children)) {\n return [];\n }\n\n if (!isArray(nestedParents) || nestedParents.length <= 0) {\n return children as T[];\n }\n\n return [...children].filter((child) =>\n [...nestedParents].every((nestedParent) => {\n const nestedChildren = nestedParent.$children[childrenName] as Base<BaseProps>[];\n /* istanbul ignore next */\n return isArray(nestedChildren) ? !nestedChildren.includes(child) : true;\n }),\n ) as T[];\n}\n\n/**\n * Test if a component instance is a direct child from the given component.\n *\n * @param {Base} parentInstance\n * @param {string} parentName\n * @param {string} childrenName\n * @param {Base} childInstance\n * @returns {boolean}\n */\nexport function isDirectChild(parentInstance, parentName, childrenName, childInstance) {\n return getDirectChildren(parentInstance, parentName, childrenName).includes(childInstance);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwB;AAWjB,SAAS,kBACd,gBACA,YACA,cACK;AACL,QAAM,WAAW,eAAe,UAAU;AAC1C,QAAM,gBAAgB,eAAe,UAAU;AAE/C,MAAI,KAAC,sBAAQ,QAAQ,GAAG;AACtB,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,KAAC,sBAAQ,aAAa,KAAK,cAAc,UAAU,GAAG;AACxD,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,GAAG,QAAQ,EAAE;AAAA,IAAO,CAAC,UAC3B,CAAC,GAAG,aAAa,EAAE,MAAM,CAAC,iBAAiB;AACzC,YAAM,iBAAiB,aAAa,UAAU;AAE9C,iBAAO,sBAAQ,cAAc,IAAI,CAAC,eAAe,SAAS,KAAK,IAAI;AAAA,IACrE,CAAC;AAAA,EACH;AACF;AAWO,SAAS,cAAc,gBAAgB,YAAY,cAAc,eAAe;AACrF,SAAO,kBAAkB,gBAAgB,YAAY,YAAY,EAAE,SAAS,aAAa;AAC3F;",
6
- "names": []
7
- }
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/helpers/getInstanceFromElement.ts
20
- var getInstanceFromElement_exports = {};
21
- __export(getInstanceFromElement_exports, {
22
- default: () => getInstanceFromElement
23
- });
24
- module.exports = __toCommonJS(getInstanceFromElement_exports);
25
- function getInstanceFromElement(element, Constructor) {
26
- if (!element || !element.__base__ || !element.__base__.has(Constructor)) {
27
- return null;
28
- }
29
- return element.__base__.get(Constructor);
30
- }
31
- if (module.exports.default) module.exports = module.exports.default;
32
- //# sourceMappingURL=getInstanceFromElement.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/helpers/getInstanceFromElement.ts"],
4
- "sourcesContent": ["import type { BaseConstructor, BaseEl } from '../Base/index.js';\n\n/**\n * Get a component instance from a DOM element.\n */\nexport default function getInstanceFromElement<T extends BaseConstructor>(\n element: BaseEl,\n Constructor: T,\n): InstanceType<T> | null {\n if (!element || !element.__base__ || !element.__base__.has(Constructor)) {\n return null;\n }\n\n return element.__base__.get(Constructor) as InstanceType<T>;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKe,SAAR,uBACL,SACA,aACwB;AACxB,MAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,CAAC,QAAQ,SAAS,IAAI,WAAW,GAAG;AACvE,WAAO;AAAA,EACT;AAEA,SAAO,QAAQ,SAAS,IAAI,WAAW;AACzC;",
6
- "names": []
7
- }