@studiometa/js-toolkit 2.6.5 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/Base/features.cjs +27 -0
  2. package/Base/features.cjs.map +7 -0
  3. package/Base/features.d.ts +2 -0
  4. package/Base/features.js +5 -0
  5. package/Base/features.js.map +7 -0
  6. package/Base/index.cjs +12 -15
  7. package/Base/index.cjs.map +2 -2
  8. package/Base/index.d.ts +11 -15
  9. package/Base/index.js +10 -6
  10. package/Base/index.js.map +2 -2
  11. package/Base/managers/AsyncChildrenManager.cjs +61 -0
  12. package/Base/managers/AsyncChildrenManager.cjs.map +7 -0
  13. package/Base/managers/AsyncChildrenManager.d.ts +18 -0
  14. package/Base/managers/AsyncChildrenManager.js +39 -0
  15. package/Base/managers/AsyncChildrenManager.js.map +7 -0
  16. package/Base/managers/ChildrenManager.cjs +32 -29
  17. package/Base/managers/ChildrenManager.cjs.map +2 -2
  18. package/Base/managers/ChildrenManager.d.ts +21 -1
  19. package/Base/managers/ChildrenManager.js +32 -29
  20. package/Base/managers/ChildrenManager.js.map +2 -2
  21. package/Base/managers/EventsManager.cjs.map +2 -2
  22. package/Base/managers/EventsManager.js.map +2 -2
  23. package/Base/managers/OptionsManager.d.ts +9 -9
  24. package/Base/managers/RefsManager.cjs +13 -8
  25. package/Base/managers/RefsManager.cjs.map +2 -2
  26. package/Base/managers/RefsManager.js +14 -9
  27. package/Base/managers/RefsManager.js.map +2 -2
  28. package/Base/managers/ResponsiveOptionsManager.d.ts +1 -1
  29. package/Base/managers/ServicesManager.d.ts +2 -2
  30. package/Base/managers/index.cjs +41 -0
  31. package/Base/managers/index.cjs.map +7 -0
  32. package/Base/managers/index.d.ts +8 -0
  33. package/Base/managers/index.js +19 -0
  34. package/Base/managers/index.js.map +7 -0
  35. package/Base/types.cjs.map +1 -1
  36. package/Base/types.d.ts +1 -1
  37. package/Base/utils.cjs +15 -1
  38. package/Base/utils.cjs.map +2 -2
  39. package/Base/utils.d.ts +1 -0
  40. package/Base/utils.js +15 -1
  41. package/Base/utils.js.map +2 -2
  42. package/decorators/index.cjs +1 -1
  43. package/decorators/index.cjs.map +2 -2
  44. package/decorators/index.d.ts +1 -1
  45. package/decorators/index.js +1 -1
  46. package/decorators/index.js.map +1 -1
  47. package/decorators/withBreakpointManager.cjs.map +2 -2
  48. package/decorators/withBreakpointManager.js.map +2 -2
  49. package/decorators/withBreakpointObserver.cjs.map +2 -2
  50. package/decorators/withBreakpointObserver.js.map +2 -2
  51. package/decorators/withDrag.cjs.map +2 -2
  52. package/decorators/withDrag.d.ts +1 -1
  53. package/decorators/withDrag.js.map +2 -2
  54. package/decorators/withMountWhenInView.cjs.map +2 -2
  55. package/decorators/withMountWhenInView.js.map +2 -2
  56. package/decorators/withResponsiveOptions.cjs.map +2 -2
  57. package/decorators/withResponsiveOptions.js.map +2 -2
  58. package/decorators/withScrolledInView/index.cjs +22 -0
  59. package/decorators/withScrolledInView/index.cjs.map +7 -0
  60. package/decorators/withScrolledInView/index.d.ts +2 -0
  61. package/decorators/withScrolledInView/index.js +3 -0
  62. package/decorators/withScrolledInView/index.js.map +7 -0
  63. package/decorators/withScrolledInView/types.cjs +19 -0
  64. package/decorators/withScrolledInView/types.cjs.map +7 -0
  65. package/decorators/withScrolledInView/types.d.ts +2 -0
  66. package/decorators/withScrolledInView/types.js +1 -0
  67. package/decorators/withScrolledInView/types.js.map +7 -0
  68. package/decorators/withScrolledInView/utils.cjs +99 -0
  69. package/decorators/withScrolledInView/utils.cjs.map +7 -0
  70. package/decorators/withScrolledInView/utils.d.ts +17 -0
  71. package/decorators/withScrolledInView/utils.js +77 -0
  72. package/decorators/withScrolledInView/utils.js.map +7 -0
  73. package/decorators/{withScrolledInView.cjs → withScrolledInView/withScrolledInView.cjs} +25 -10
  74. package/decorators/withScrolledInView/withScrolledInView.cjs.map +7 -0
  75. package/decorators/{withScrolledInView.d.ts → withScrolledInView/withScrolledInView.d.ts} +6 -5
  76. package/decorators/{withScrolledInView.js → withScrolledInView/withScrolledInView.js} +31 -9
  77. package/decorators/withScrolledInView/withScrolledInView.js.map +7 -0
  78. package/decorators/withVue2.cjs.map +2 -2
  79. package/decorators/withVue2.js.map +2 -2
  80. package/helpers/createApp.cjs +23 -19
  81. package/helpers/createApp.cjs.map +2 -2
  82. package/helpers/createApp.d.ts +6 -1
  83. package/helpers/createApp.js +23 -19
  84. package/helpers/createApp.js.map +2 -2
  85. package/helpers/getClosestParent.cjs +3 -11
  86. package/helpers/getClosestParent.cjs.map +2 -2
  87. package/helpers/getClosestParent.js +3 -11
  88. package/helpers/getClosestParent.js.map +2 -2
  89. package/helpers/getInstanceFromElement.cjs.map +2 -2
  90. package/helpers/getInstanceFromElement.js.map +2 -2
  91. package/helpers/importOnInteraction.cjs.map +2 -2
  92. package/helpers/importOnInteraction.js.map +2 -2
  93. package/helpers/importWhenIdle.cjs.map +2 -2
  94. package/helpers/importWhenIdle.d.ts +1 -1
  95. package/helpers/importWhenIdle.js.map +2 -2
  96. package/index.cjs.map +1 -1
  97. package/index.d.ts +1 -1
  98. package/index.js.map +1 -1
  99. package/package.json +2 -2
  100. package/services/drag.cjs +1 -1
  101. package/services/drag.cjs.map +3 -3
  102. package/services/drag.d.ts +21 -24
  103. package/services/drag.js.map +3 -3
  104. package/services/index.d.ts +7 -7
  105. package/services/key.cjs +1 -1
  106. package/services/key.cjs.map +3 -3
  107. package/services/key.d.ts +8 -9
  108. package/services/key.js.map +3 -3
  109. package/services/load.cjs +1 -1
  110. package/services/load.cjs.map +3 -3
  111. package/services/load.d.ts +6 -5
  112. package/services/load.js.map +3 -3
  113. package/services/pointer.cjs +1 -1
  114. package/services/pointer.cjs.map +3 -3
  115. package/services/pointer.d.ts +10 -10
  116. package/services/pointer.js.map +3 -3
  117. package/services/raf.cjs +4 -4
  118. package/services/raf.cjs.map +3 -3
  119. package/services/raf.d.ts +6 -7
  120. package/services/raf.js +3 -3
  121. package/services/raf.js.map +3 -3
  122. package/services/resize.cjs +1 -1
  123. package/services/resize.cjs.map +3 -3
  124. package/services/resize.d.ts +8 -9
  125. package/services/resize.js.map +3 -3
  126. package/services/scroll.cjs +1 -1
  127. package/services/scroll.cjs.map +3 -3
  128. package/services/scroll.d.ts +16 -17
  129. package/services/scroll.js.map +3 -3
  130. package/services/service.cjs +2 -2
  131. package/services/service.cjs.map +3 -3
  132. package/services/service.d.ts +12 -14
  133. package/services/service.js +1 -1
  134. package/services/service.js.map +3 -3
  135. package/utils/Queue.cjs +60 -0
  136. package/utils/Queue.cjs.map +7 -0
  137. package/utils/Queue.d.ts +44 -0
  138. package/utils/Queue.js +38 -0
  139. package/utils/Queue.js.map +7 -0
  140. package/utils/collide/boundingRectToCircle.cjs +3 -2
  141. package/utils/collide/boundingRectToCircle.cjs.map +3 -3
  142. package/utils/collide/boundingRectToCircle.d.ts +8 -13
  143. package/utils/collide/boundingRectToCircle.js +2 -1
  144. package/utils/collide/boundingRectToCircle.js.map +3 -3
  145. package/utils/collide/collideCircleCircle.cjs +1 -1
  146. package/utils/collide/collideCircleCircle.cjs.map +1 -1
  147. package/utils/collide/collideCircleCircle.d.ts +1 -15
  148. package/utils/collide/collideCircleCircle.js.map +1 -1
  149. package/utils/collide/collideCircleRect.cjs +1 -1
  150. package/utils/collide/collideCircleRect.cjs.map +1 -1
  151. package/utils/collide/collideCircleRect.d.ts +1 -33
  152. package/utils/collide/collideCircleRect.js.map +1 -1
  153. package/utils/collide/collidePointCircle.cjs +1 -1
  154. package/utils/collide/collidePointCircle.cjs.map +1 -1
  155. package/utils/collide/collidePointCircle.d.ts +1 -25
  156. package/utils/collide/collidePointCircle.js.map +1 -1
  157. package/utils/collide/collidePointRect.cjs +1 -1
  158. package/utils/collide/collidePointRect.cjs.map +1 -1
  159. package/utils/collide/collidePointRect.d.ts +1 -29
  160. package/utils/collide/collidePointRect.js.map +1 -1
  161. package/utils/collide/collideRectRect.cjs +1 -1
  162. package/utils/collide/collideRectRect.cjs.map +1 -1
  163. package/utils/collide/collideRectRect.d.ts +1 -19
  164. package/utils/collide/collideRectRect.js.map +1 -1
  165. package/utils/collide/index.cjs +1 -1
  166. package/utils/collide/index.cjs.map +1 -1
  167. package/utils/collide/index.d.ts +9 -6
  168. package/utils/collide/index.js.map +1 -1
  169. package/utils/css/animate.cjs +32 -16
  170. package/utils/css/animate.cjs.map +4 -4
  171. package/utils/css/animate.d.ts +12 -11
  172. package/utils/css/animate.js +31 -15
  173. package/utils/css/animate.js.map +4 -4
  174. package/utils/css/classes.cjs +1 -1
  175. package/utils/css/classes.cjs.map +3 -3
  176. package/utils/css/classes.d.ts +3 -16
  177. package/utils/css/classes.js.map +3 -3
  178. package/utils/css/getOffsetSizes.cjs +2 -2
  179. package/utils/css/getOffsetSizes.cjs.map +3 -3
  180. package/utils/css/getOffsetSizes.d.ts +0 -2
  181. package/utils/css/getOffsetSizes.js +1 -1
  182. package/utils/css/getOffsetSizes.js.map +3 -3
  183. package/utils/css/matrix.cjs +1 -1
  184. package/utils/css/matrix.cjs.map +3 -3
  185. package/utils/css/matrix.d.ts +10 -8
  186. package/utils/css/matrix.js.map +3 -3
  187. package/utils/css/styles.cjs +1 -1
  188. package/utils/css/styles.cjs.map +3 -3
  189. package/utils/css/styles.d.ts +2 -10
  190. package/utils/css/styles.js.map +3 -3
  191. package/utils/css/transform.cjs +1 -1
  192. package/utils/css/transform.cjs.map +3 -3
  193. package/utils/css/transform.d.ts +5 -27
  194. package/utils/css/transform.js.map +3 -3
  195. package/utils/css/transition.cjs +2 -2
  196. package/utils/css/transition.cjs.map +3 -3
  197. package/utils/css/transition.d.ts +11 -15
  198. package/utils/css/transition.js +1 -1
  199. package/utils/css/transition.js.map +3 -3
  200. package/utils/debounce.cjs +1 -1
  201. package/utils/debounce.cjs.map +3 -3
  202. package/utils/debounce.d.ts +3 -3
  203. package/utils/debounce.js.map +3 -3
  204. package/utils/dom/ancestors.cjs +37 -0
  205. package/utils/dom/ancestors.cjs.map +7 -0
  206. package/utils/dom/ancestors.d.ts +8 -0
  207. package/utils/dom/ancestors.js +15 -0
  208. package/utils/dom/ancestors.js.map +7 -0
  209. package/utils/dom/index.cjs +21 -0
  210. package/utils/dom/index.cjs.map +7 -0
  211. package/utils/dom/index.d.ts +1 -0
  212. package/utils/dom/index.js +2 -0
  213. package/utils/dom/index.js.map +7 -0
  214. package/utils/focusTrap.cjs +4 -2
  215. package/utils/focusTrap.cjs.map +3 -3
  216. package/utils/focusTrap.d.ts +3 -4
  217. package/utils/focusTrap.js +3 -1
  218. package/utils/focusTrap.js.map +3 -3
  219. package/utils/has.cjs +1 -1
  220. package/utils/has.cjs.map +3 -3
  221. package/utils/has.d.ts +1 -3
  222. package/utils/has.js.map +3 -3
  223. package/utils/history.cjs +1 -1
  224. package/utils/history.cjs.map +3 -3
  225. package/utils/history.d.ts +10 -10
  226. package/utils/history.js.map +3 -3
  227. package/utils/index.cjs +3 -0
  228. package/utils/index.cjs.map +2 -2
  229. package/utils/index.d.ts +2 -0
  230. package/utils/index.js +3 -0
  231. package/utils/index.js.map +2 -2
  232. package/utils/is.cjs +2 -2
  233. package/utils/is.cjs.map +3 -3
  234. package/utils/is.d.ts +26 -8
  235. package/utils/is.js +1 -1
  236. package/utils/is.js.map +3 -3
  237. package/utils/keyCodes.cjs +1 -1
  238. package/utils/keyCodes.cjs.map +2 -2
  239. package/utils/keyCodes.d.ts +10 -10
  240. package/utils/keyCodes.js.map +2 -2
  241. package/utils/math/clamp.cjs +1 -1
  242. package/utils/math/clamp.cjs.map +3 -3
  243. package/utils/math/clamp.js.map +3 -3
  244. package/utils/math/clamp01.cjs +1 -1
  245. package/utils/math/clamp01.cjs.map +3 -3
  246. package/utils/math/clamp01.js.map +3 -3
  247. package/utils/math/createEases.cjs +1 -1
  248. package/utils/math/createEases.cjs.map +3 -3
  249. package/utils/math/createEases.d.ts +3 -6
  250. package/utils/math/createEases.js.map +3 -3
  251. package/utils/math/damp.cjs +1 -1
  252. package/utils/math/damp.cjs.map +3 -3
  253. package/utils/math/damp.js.map +3 -3
  254. package/utils/math/ease.cjs +1 -1
  255. package/utils/math/ease.cjs.map +3 -3
  256. package/utils/math/ease.d.ts +21 -21
  257. package/utils/math/ease.js.map +3 -3
  258. package/utils/math/index.cjs +1 -1
  259. package/utils/math/index.cjs.map +1 -1
  260. package/utils/math/index.d.ts +10 -10
  261. package/utils/math/index.js.map +1 -1
  262. package/utils/math/inertiaFinalValue.cjs +1 -1
  263. package/utils/math/inertiaFinalValue.cjs.map +3 -3
  264. package/utils/math/inertiaFinalValue.js.map +3 -3
  265. package/utils/math/lerp.cjs +1 -1
  266. package/utils/math/lerp.cjs.map +3 -3
  267. package/utils/math/lerp.js.map +3 -3
  268. package/utils/math/map.cjs +1 -1
  269. package/utils/math/map.cjs.map +3 -3
  270. package/utils/math/map.js.map +3 -3
  271. package/utils/math/round.cjs +1 -1
  272. package/utils/math/round.cjs.map +3 -3
  273. package/utils/math/round.js.map +3 -3
  274. package/utils/memoize.cjs +6 -2
  275. package/utils/memoize.cjs.map +3 -3
  276. package/utils/memoize.d.ts +18 -28
  277. package/utils/memoize.js +5 -1
  278. package/utils/memoize.js.map +3 -3
  279. package/utils/nextFrame.cjs +1 -1
  280. package/utils/nextFrame.cjs.map +3 -3
  281. package/utils/nextFrame.d.ts +3 -6
  282. package/utils/nextFrame.js.map +3 -3
  283. package/utils/nextMicrotask.cjs +1 -1
  284. package/utils/nextMicrotask.cjs.map +3 -3
  285. package/utils/nextMicrotask.d.ts +1 -5
  286. package/utils/nextMicrotask.js.map +3 -3
  287. package/utils/nextTick.cjs +5 -5
  288. package/utils/nextTick.cjs.map +3 -3
  289. package/utils/nextTick.d.ts +1 -5
  290. package/utils/nextTick.js +4 -4
  291. package/utils/nextTick.js.map +3 -3
  292. package/utils/noop.cjs +1 -1
  293. package/utils/noop.cjs.map +3 -3
  294. package/utils/noop.d.ts +2 -5
  295. package/utils/noop.js.map +3 -3
  296. package/utils/object/autoBind.cjs +1 -1
  297. package/utils/object/autoBind.cjs.map +3 -3
  298. package/utils/object/autoBind.d.ts +5 -4
  299. package/utils/object/autoBind.js.map +3 -3
  300. package/utils/object/getAllProperties.cjs +3 -3
  301. package/utils/object/getAllProperties.cjs.map +3 -3
  302. package/utils/object/getAllProperties.d.ts +1 -1
  303. package/utils/object/getAllProperties.js +2 -2
  304. package/utils/object/getAllProperties.js.map +3 -3
  305. package/utils/object/index.cjs +1 -1
  306. package/utils/object/index.cjs.map +1 -1
  307. package/utils/object/index.d.ts +2 -2
  308. package/utils/object/index.js.map +1 -1
  309. package/utils/scheduler.cjs +2 -2
  310. package/utils/scheduler.cjs.map +3 -3
  311. package/utils/scheduler.d.ts +4 -13
  312. package/utils/scheduler.js +1 -1
  313. package/utils/scheduler.js.map +3 -3
  314. package/utils/scrollTo.cjs +1 -1
  315. package/utils/scrollTo.cjs.map +3 -3
  316. package/utils/scrollTo.d.ts +0 -3
  317. package/utils/scrollTo.js.map +3 -3
  318. package/utils/string/index.cjs +1 -1
  319. package/utils/string/index.cjs.map +1 -1
  320. package/utils/string/index.d.ts +10 -10
  321. package/utils/string/index.js.map +1 -1
  322. package/utils/string/withLeadingCharacters.cjs +1 -1
  323. package/utils/string/withLeadingCharacters.cjs.map +3 -3
  324. package/utils/string/withLeadingCharacters.js.map +3 -3
  325. package/utils/string/withLeadingSlash.cjs +1 -1
  326. package/utils/string/withLeadingSlash.cjs.map +3 -3
  327. package/utils/string/withLeadingSlash.js.map +3 -3
  328. package/utils/string/withTrailingCharacters.cjs +1 -1
  329. package/utils/string/withTrailingCharacters.cjs.map +3 -3
  330. package/utils/string/withTrailingCharacters.js.map +3 -3
  331. package/utils/string/withTrailingSlash.cjs +1 -1
  332. package/utils/string/withTrailingSlash.cjs.map +3 -3
  333. package/utils/string/withTrailingSlash.js.map +3 -3
  334. package/utils/string/withoutLeadingCharacters.cjs +1 -1
  335. package/utils/string/withoutLeadingCharacters.cjs.map +3 -3
  336. package/utils/string/withoutLeadingCharacters.js.map +3 -3
  337. package/utils/string/withoutLeadingCharactersRecursive.cjs +1 -1
  338. package/utils/string/withoutLeadingCharactersRecursive.cjs.map +3 -3
  339. package/utils/string/withoutLeadingCharactersRecursive.js.map +3 -3
  340. package/utils/string/withoutLeadingSlash.cjs +1 -1
  341. package/utils/string/withoutLeadingSlash.cjs.map +3 -3
  342. package/utils/string/withoutLeadingSlash.js.map +3 -3
  343. package/utils/string/withoutTrailingCharacters.cjs +1 -1
  344. package/utils/string/withoutTrailingCharacters.cjs.map +3 -3
  345. package/utils/string/withoutTrailingCharacters.js.map +3 -3
  346. package/utils/string/withoutTrailingCharactersRecursive.cjs +1 -1
  347. package/utils/string/withoutTrailingCharactersRecursive.cjs.map +3 -3
  348. package/utils/string/withoutTrailingCharactersRecursive.js.map +3 -3
  349. package/utils/string/withoutTrailingSlash.cjs +1 -1
  350. package/utils/string/withoutTrailingSlash.cjs.map +3 -3
  351. package/utils/string/withoutTrailingSlash.js.map +3 -3
  352. package/utils/throttle.cjs +2 -2
  353. package/utils/throttle.cjs.map +3 -3
  354. package/utils/throttle.d.ts +1 -1
  355. package/utils/throttle.js +1 -1
  356. package/utils/throttle.js.map +3 -3
  357. package/utils/tween.cjs +4 -3
  358. package/utils/tween.cjs.map +3 -3
  359. package/utils/tween.d.ts +17 -24
  360. package/utils/tween.js +3 -2
  361. package/utils/tween.js.map +3 -3
  362. package/decorators/withScrolledInView.cjs.map +0 -7
  363. package/decorators/withScrolledInView.js.map +0 -7
@@ -1,22 +1,27 @@
1
1
  import { AbstractManager } from "./AbstractManager.js";
2
- import { isDev, isArray, isDefined } from "../../utils/index.js";
2
+ import { isDev, isArray, isDefined, getAncestorWhereUntil } from "../../utils/index.js";
3
3
  const NORMALIZE_REF_NAME_REGEX = /\[\]$/;
4
4
  function normalizeRefName(name) {
5
5
  return name.endsWith("[]") ? name.replace(NORMALIZE_REF_NAME_REGEX, "") : name;
6
6
  }
7
- function __filterRefsBelongingToInstance(that, ref) {
8
- let ancestor = ref.parentElement;
9
- while (ancestor && !isDefined(ancestor.dataset.component)) {
10
- ancestor = ancestor.parentElement;
11
- }
12
- return ancestor === null || ancestor === that.__element;
7
+ function refBelongToInstance(ref, rootElement, name) {
8
+ const isPrefixed = ref.dataset.ref.startsWith(name);
9
+ const firstComponentAncestor = getAncestorWhereUntil(
10
+ ref,
11
+ (el) => el && (isPrefixed ? el.dataset.component === name && el : isDefined(el.dataset.component)) && el !== rootElement,
12
+ (el) => el === rootElement
13
+ );
14
+ return firstComponentAncestor === rootElement;
13
15
  }
14
16
  function __register(that, refName) {
15
17
  const isMultiple = refName.endsWith("[]");
16
18
  const propName = normalizeRefName(refName);
19
+ const { name } = that.__base.$options;
17
20
  const refs = Array.from(
18
- that.__element.querySelectorAll(`[data-ref="${refName}"]`)
19
- ).filter((ref) => __filterRefsBelongingToInstance(that, ref));
21
+ that.__element.querySelectorAll(
22
+ `[data-ref="${refName}"],[data-ref="${name}.${refName}"]`
23
+ )
24
+ ).filter((ref) => refBelongToInstance(ref, that.__element, name));
20
25
  if (isDev && !isMultiple && refs.length > 1) {
21
26
  console.warn(
22
27
  `[${that.__base.$options.name}]`,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/Base/managers/RefsManager.ts"],
4
- "sourcesContent": ["import { AbstractManager } from './AbstractManager.js';\nimport { isDev, isArray, isDefined } from '../../utils/index.js';\n\nconst NORMALIZE_REF_NAME_REGEX = /\\[\\]$/;\n/**\n * Normalize the name of ref.\n */\nexport function normalizeRefName(name: string) {\n return name.endsWith('[]') ? name.replace(NORMALIZE_REF_NAME_REGEX, '') : name;\n}\n\n/**\n * Filter refs belonging to the related Base instance.\n */\nfunction __filterRefsBelongingToInstance(that: RefsManager, ref: HTMLElement) {\n let ancestor = ref.parentElement;\n\n while (ancestor && !isDefined(ancestor.dataset.component)) {\n ancestor = ancestor.parentElement;\n }\n\n return ancestor === null || ancestor === that.__element;\n}\n\n/**\n * Register one ref.\n *\n * @param {RefsManager} that\n * @param {string} refName The ref name.\n * @private\n */\nfunction __register(that: RefsManager, refName: string) {\n const isMultiple = refName.endsWith('[]');\n const propName = normalizeRefName(refName);\n\n const refs = Array.from(\n that.__element.querySelectorAll<HTMLElement>(`[data-ref=\"${refName}\"]`),\n ).filter((ref) => __filterRefsBelongingToInstance(that, ref));\n\n if (isDev && !isMultiple && refs.length > 1) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref has been found multiple times.`,\n 'Did you forgot to add the `[]` suffix to its name?',\n );\n }\n\n if (!isMultiple && refs.length <= 1 && !isDefined(refs[0])) {\n if (isDev) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref is missing.`,\n `Is there an \\`[data-ref=\"${refName}\"]\\` element in the component's scope?`,\n );\n }\n\n return;\n }\n\n that.__eventsManager.bindRef(refName, refs);\n\n Object.defineProperty(that, propName, {\n // @todo remove usage of non-multiple refs as array\n value: isMultiple || refs.length > 1 ? refs : refs[0],\n enumerable: true,\n configurable: true,\n });\n}\n\n/**\n * Unregister one ref.\n */\nfunction __unregister(that:RefsManager, refName:string) {\n const propName = normalizeRefName(refName);\n const refs = isArray(that[propName]) ? that[propName] : [that[propName]];\n that.__eventsManager.unbindRef(refName, refs);\n}\n\n/**\n * Refs Manager\n *\n * @todo Use `MutationObserver` to automatically update refs?\n */\nexport class RefsManager extends AbstractManager {\n /**\n * Get refs configuration.\n */\n get __refs() {\n return this.__config.refs ?? [];\n }\n\n /**\n * Register all refs.\n */\n registerAll() {\n this.__refs.forEach((refName) => __register(this, refName));\n }\n\n /**\n * Unregister all refs.\n */\n unregisterAll() {\n this.__refs.forEach((refName) => __unregister(this, refName));\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,OAAO,SAAS,iBAAiB;AAE1C,MAAM,2BAA2B;AAI1B,SAAS,iBAAiB,MAAc;AAC7C,SAAO,KAAK,SAA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oBAAoB,gBAAgB;AAAA,EAI/C,IAAI,SAAS;AACX,WAAO,KAAK,SAAS,QAAQ,CAAC;AAAA,EAChC;AAAA,EAKA,cAAc;AACZ,SAAK,OAAO,QAAQ,CAAC,YAAY,WAAW,MAAM,OAAO,CAAC;AAAA,EAC5D;AAAA,EAKA,gBAAgB;AACd,SAAK,OAAO,QAAQ,CAAC,YAAY,aAAa,MAAM,OAAO,CAAC;AAAA,EAC9D;AACF;",
4
+ "sourcesContent": ["import { AbstractManager } from './AbstractManager.js';\nimport { isDev, isArray, isDefined, getAncestorWhereUntil } from '../../utils/index.js';\n\nconst NORMALIZE_REF_NAME_REGEX = /\\[\\]$/;\n\n/**\n * Normalize the name of ref.\n */\nexport function normalizeRefName(name: string) {\n return name.endsWith('[]') ? name.replace(NORMALIZE_REF_NAME_REGEX, '') : name;\n}\n\n/**\n * Filter refs belonging to the related Base instance.\n */\nfunction refBelongToInstance(ref: HTMLElement, rootElement: HTMLElement, name: string) {\n const isPrefixed = ref.dataset.ref.startsWith(name);\n const firstComponentAncestor = getAncestorWhereUntil(\n ref,\n (el) =>\n el &&\n (isPrefixed ? el.dataset.component === name && el : isDefined(el.dataset.component)) &&\n el !== rootElement,\n (el) => el === rootElement,\n );\n\n return firstComponentAncestor === rootElement;\n}\n\n/**\n * Register one ref.\n *\n * @param {RefsManager} that\n * @param {string} refName The ref name.\n * @private\n */\nfunction __register(that: RefsManager, refName: string) {\n const isMultiple = refName.endsWith('[]');\n const propName = normalizeRefName(refName);\n const { name } = that.__base.$options;\n\n const refs = Array.from(\n that.__element.querySelectorAll<HTMLElement>(\n `[data-ref=\"${refName}\"],[data-ref=\"${name}.${refName}\"]`,\n ),\n ).filter((ref) => refBelongToInstance(ref, that.__element, name));\n\n if (isDev && !isMultiple && refs.length > 1) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref has been found multiple times.`,\n 'Did you forgot to add the `[]` suffix to its name?',\n );\n }\n\n if (!isMultiple && refs.length <= 1 && !isDefined(refs[0])) {\n if (isDev) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref is missing.`,\n `Is there an \\`[data-ref=\"${refName}\"]\\` element in the component's scope?`,\n );\n }\n\n return;\n }\n\n that.__eventsManager.bindRef(refName, refs);\n\n Object.defineProperty(that, propName, {\n // @todo remove usage of non-multiple refs as array\n value: isMultiple || refs.length > 1 ? refs : refs[0],\n enumerable: true,\n configurable: true,\n });\n}\n\n/**\n * Unregister one ref.\n */\nfunction __unregister(that: RefsManager, refName: string) {\n const propName = normalizeRefName(refName);\n const refs = isArray(that[propName]) ? that[propName] : [that[propName]];\n that.__eventsManager.unbindRef(refName, refs);\n}\n\n/**\n * Refs Manager\n *\n * @todo Use `MutationObserver` to automatically update refs?\n */\nexport class RefsManager extends AbstractManager {\n /**\n * Get refs configuration.\n */\n get __refs() {\n return this.__config.refs ?? [];\n }\n\n /**\n * Register all refs.\n */\n registerAll() {\n this.__refs.forEach((refName) => __register(this, refName));\n }\n\n /**\n * Unregister all refs.\n */\n unregisterAll() {\n this.__refs.forEach((refName) => __unregister(this, refName));\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,OAAO,SAAS,WAAW,6BAA6B;AAEjE,MAAM,2BAA2B;AAK1B,SAAS,iBAAiB,MAAc;AAC7C,SAAO,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,0BAA0B,EAAE,IAAI;AAC5E;AAKA,SAAS,oBAAoB,KAAkB,aAA0B,MAAc;AACrF,QAAM,aAAa,IAAI,QAAQ,IAAI,WAAW,IAAI;AAClD,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA,CAAC,OACC,OACC,aAAa,GAAG,QAAQ,cAAc,QAAQ,KAAK,UAAU,GAAG,QAAQ,SAAS,MAClF,OAAO;AAAA,IACT,CAAC,OAAO,OAAO;AAAA,EACjB;AAEA,SAAO,2BAA2B;AACpC;AASA,SAAS,WAA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AAAA,EAKA,gBAAgB;AACd,SAAK,OAAO,QAAQ,CAAC,YAAY,aAAa,MAAM,OAAO,CAAC;AAAA,EAC9D;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { OptionsManager } from './OptionsManager.js';
2
2
  import type { OptionObject } from './OptionsManager.js';
3
- export declare type ResponsiveOptionObject = OptionObject & {
3
+ export type ResponsiveOptionObject = OptionObject & {
4
4
  responsive?: boolean;
5
5
  };
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { usePointer, useRaf, useResize, useScroll, useKey, useLoad } from '../../services/index.js';
2
2
  import type { PointerServiceInterface, RafServiceInterface, ResizeServiceInterface, ScrollServiceInterface, KeyServiceInterface, LoadServiceInterface, ServiceInterface } from '../../services/index.js';
3
3
  import { AbstractManager } from './AbstractManager.js';
4
- declare type Services = {
4
+ type Services = {
5
5
  scrolled: ScrollServiceInterface;
6
6
  resized: ResizeServiceInterface;
7
7
  ticked: RafServiceInterface;
@@ -9,7 +9,7 @@ declare type Services = {
9
9
  keyed: KeyServiceInterface;
10
10
  loaded: LoadServiceInterface;
11
11
  } & Record<string, ServiceInterface<unknown>>;
12
- declare type ServiceNames = keyof Services;
12
+ type ServiceNames = keyof Services;
13
13
  /**
14
14
  * Services management for the Base class.
15
15
  *
@@ -0,0 +1,41 @@
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/Base/managers/index.ts
20
+ var managers_exports = {};
21
+ __export(managers_exports, {
22
+ AbstractManager: () => import_AbstractManager.AbstractManager,
23
+ AsyncChildrenManager: () => import_AsyncChildrenManager.AsyncChildrenManager,
24
+ ChildrenManager: () => import_ChildrenManager.ChildrenManager,
25
+ EventsManager: () => import_EventsManager.EventsManager,
26
+ OptionsManager: () => import_OptionsManager.OptionsManager,
27
+ RefsManager: () => import_RefsManager.RefsManager,
28
+ ResponsiveOptionsManager: () => import_ResponsiveOptionsManager.ResponsiveOptionsManager,
29
+ ServicesManager: () => import_ServicesManager.ServicesManager
30
+ });
31
+ module.exports = __toCommonJS(managers_exports);
32
+ var import_AbstractManager = require("./AbstractManager.cjs");
33
+ var import_AsyncChildrenManager = require("./AsyncChildrenManager.cjs");
34
+ var import_ChildrenManager = require("./ChildrenManager.cjs");
35
+ var import_EventsManager = require("./EventsManager.cjs");
36
+ var import_OptionsManager = require("./OptionsManager.cjs");
37
+ var import_RefsManager = require("./RefsManager.cjs");
38
+ var import_ResponsiveOptionsManager = require("./ResponsiveOptionsManager.cjs");
39
+ var import_ServicesManager = require("./ServicesManager.cjs");
40
+ if (module.exports.default) module.exports = module.exports.default;
41
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../packages/js-toolkit/Base/managers/index.ts"],
4
+ "sourcesContent": ["export { AbstractManager } from './AbstractManager.js';\nexport { AsyncChildrenManager } from './AsyncChildrenManager.js';\nexport { ChildrenManager } from './ChildrenManager.js';\nexport { EventsManager } from './EventsManager.js';\nexport { OptionsManager } from './OptionsManager.js';\nexport { RefsManager } from './RefsManager.js';\nexport { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';\nexport { ServicesManager } from './ServicesManager.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,kCAAqC;AACrC,6BAAgC;AAChC,2BAA8B;AAC9B,4BAA+B;AAC/B,yBAA4B;AAC5B,sCAAyC;AACzC,6BAAgC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ export { AbstractManager } from './AbstractManager.js';
2
+ export { AsyncChildrenManager } from './AsyncChildrenManager.js';
3
+ export { ChildrenManager } from './ChildrenManager.js';
4
+ export { EventsManager } from './EventsManager.js';
5
+ export { OptionsManager } from './OptionsManager.js';
6
+ export { RefsManager } from './RefsManager.js';
7
+ export { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';
8
+ export { ServicesManager } from './ServicesManager.js';
@@ -0,0 +1,19 @@
1
+ import { AbstractManager } from "./AbstractManager.js";
2
+ import { AsyncChildrenManager } from "./AsyncChildrenManager.js";
3
+ import { ChildrenManager } from "./ChildrenManager.js";
4
+ import { EventsManager } from "./EventsManager.js";
5
+ import { OptionsManager } from "./OptionsManager.js";
6
+ import { RefsManager } from "./RefsManager.js";
7
+ import { ResponsiveOptionsManager } from "./ResponsiveOptionsManager.js";
8
+ import { ServicesManager } from "./ServicesManager.js";
9
+ export {
10
+ AbstractManager,
11
+ AsyncChildrenManager,
12
+ ChildrenManager,
13
+ EventsManager,
14
+ OptionsManager,
15
+ RefsManager,
16
+ ResponsiveOptionsManager,
17
+ ServicesManager
18
+ };
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../packages/js-toolkit/Base/managers/index.ts"],
4
+ "sourcesContent": ["export { AbstractManager } from './AbstractManager.js';\nexport { AsyncChildrenManager } from './AsyncChildrenManager.js';\nexport { ChildrenManager } from './ChildrenManager.js';\nexport { EventsManager } from './EventsManager.js';\nexport { OptionsManager } from './OptionsManager.js';\nexport { RefsManager } from './RefsManager.js';\nexport { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';\nexport { ServicesManager } from './ServicesManager.js';\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/Base/types.ts"],
4
- "sourcesContent": ["import type { Base, BaseProps } from './index.js';\nimport type {\n KeyServiceProps,\n LoadServiceProps,\n PointerServiceProps,\n RafServiceProps,\n ResizeServiceProps,\n ScrollServiceProps,\n} from '../services/index.js';\n\nexport interface BaseInterface {\n /**\n * Mounted hook.\n */\n mounted?(): void;\n /**\n * Updated hook.\n */\n updated?(): void;\n /**\n * Destroyed hook.\n */\n destroyed?(): void;\n /**\n * Terminated hook.\n */\n terminated?(): void;\n /**\n * Key service, executed when a keyboard key is pressed or released.\n */\n keyed?(props: KeyServiceProps): void;\n /**\n * Load service, executed when the window `load` event is fired.\n */\n loaded?(props: LoadServiceProps): void;\n /**\n * Pointer service, executed when the pointer is moving, pressed or released.\n */\n moved?(props: PointerServiceProps): void;\n /**\n * Raf service, executed on each rendered frame.\n */\n ticked?(props: RafServiceProps): void;\n /**\n * Resize service, executed when the window is resized.\n */\n resized?(props: ResizeServiceProps): void;\n /**\n * Scroll service, executed when the document is scrolled.\n */\n scrolled?(props: ScrollServiceProps): void;\n}\n\nexport type BaseDecorator<S extends BaseInterface, T extends Base, U extends BaseProps = BaseProps> = {\n new <W extends BaseProps = BaseProps>(...args: unknown[]): S & T & Base<W & U>;\n} & Partial<Pick<T, keyof T>> & Pick<typeof Base, keyof typeof Base>;\n"],
4
+ "sourcesContent": ["import type { Base, BaseProps } from './index.js';\nimport type {\n KeyServiceProps,\n LoadServiceProps,\n PointerServiceProps,\n RafServiceProps,\n ResizeServiceProps,\n ScrollServiceProps,\n} from '../services/index.js';\n\nexport interface BaseInterface {\n /**\n * Mounted hook.\n */\n mounted?(): void;\n /**\n * Updated hook.\n */\n updated?(): void;\n /**\n * Destroyed hook.\n */\n destroyed?(): void;\n /**\n * Terminated hook.\n */\n terminated?(): void;\n /**\n * Key service, executed when a keyboard key is pressed or released.\n */\n keyed?(props: KeyServiceProps): void;\n /**\n * Load service, executed when the window `load` event is fired.\n */\n loaded?(props: LoadServiceProps): void;\n /**\n * Pointer service, executed when the pointer is moving, pressed or released.\n */\n moved?(props: PointerServiceProps): void;\n /**\n * Raf service, executed on each rendered frame.\n */\n ticked?(props: RafServiceProps): void;\n /**\n * Resize service, executed when the window is resized.\n */\n resized?(props: ResizeServiceProps): void;\n /**\n * Scroll service, executed when the document is scrolled.\n */\n scrolled?(props: ScrollServiceProps): void;\n}\n\nexport type BaseDecorator<\n S extends BaseInterface,\n T extends Base,\n U extends BaseProps = BaseProps,\n> = {\n new <W extends BaseProps = BaseProps>(...args: unknown[]): S & T & Base<W & U>;\n} & Partial<Pick<T, keyof T>> &\n Pick<typeof Base, keyof typeof Base>;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
package/Base/types.d.ts CHANGED
@@ -42,6 +42,6 @@ export interface BaseInterface {
42
42
  */
43
43
  scrolled?(props: ScrollServiceProps): void;
44
44
  }
45
- export declare type BaseDecorator<S extends BaseInterface, T extends Base, U extends BaseProps = BaseProps> = {
45
+ export type BaseDecorator<S extends BaseInterface, T extends Base, U extends BaseProps = BaseProps> = {
46
46
  new <W extends BaseProps = BaseProps>(...args: unknown[]): S & T & Base<W & U>;
47
47
  } & Partial<Pick<T, keyof T>> & Pick<typeof Base, keyof typeof Base>;
package/Base/utils.cjs CHANGED
@@ -26,8 +26,22 @@ __export(utils_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(utils_exports);
28
28
  var import_utils = require("../utils/index.cjs");
29
+ var selectors = /* @__PURE__ */ new Map();
30
+ var separator = " ";
31
+ function getSelector(nameOrSelector) {
32
+ if (!selectors.has(nameOrSelector)) {
33
+ const parts = [
34
+ `[data-component="${nameOrSelector}"]`,
35
+ `[data-component*="${separator}${nameOrSelector}${separator}"]`,
36
+ `[data-component$="${separator}${nameOrSelector}"]`,
37
+ `[data-component^="${nameOrSelector}${separator}"]`
38
+ ];
39
+ selectors.set(nameOrSelector, parts.join(","));
40
+ }
41
+ return selectors.get(nameOrSelector);
42
+ }
29
43
  function getComponentElements(nameOrSelector, element = document) {
30
- const selector = `[data-component="${nameOrSelector}"]`;
44
+ const selector = getSelector(nameOrSelector);
31
45
  let elements = [];
32
46
  try {
33
47
  elements = Array.from(element.querySelectorAll(selector));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/Base/utils.ts"],
4
- "sourcesContent": ["import { isArray, isDefined, isDev } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(nameOrSelector:string, element:HTMLElement | Document = document):HTMLElement[] {\n const selector = `[data-component=\"${nameOrSelector}\"]`;\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event:string, config: BaseConfig):boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event:string, element:HTMLElement):boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n */\nexport function getEventTarget(instance:Base, event:string, config:BaseConfig):Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n return instance;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAanC,SAAS,qBAAqB,gBAAuB,UAAiC,UAAwB;AACnH,QAAM,WAAW,oBAAoB;AACrC,MAAI,WAAW,CAAC;AAEhB,MAAI;AACF,eAAW,MAAM,KAAK,QAAQ,iBAAiB,QAAQ,CAAC;AAAA,EAE1D,QAAE;AAAA,EAAO;AAGT,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,MAAM,KAAK,QAAQ,iBAAiB,cAAc,CAAC;AAAA,EAChE;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,OAAc,QAA4B;AAC/E,aAAO,sBAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,KAAK;AAC7D;AAKO,SAAS,cAAc,OAAc,SAA6B;AACvE,aAAO,wBAAU,QAAQ,KAAK,QAAQ;AACxC;AAKO,SAAS,eAAe,UAAe,OAAc,QAAsC;AAChG,MAAI,uBAAuB,OAAO,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,OAAO,SAAS,GAAG,GAAG;AACtC,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,oBAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isArray, isDefined, isDev } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\n\nconst selectors = new Map();\n\n// Separator used for multi-component declaration in `data-component` attributeS.\nconst separator = ' ';\n\n/**\n * Get the selector for a given component.\n */\nfunction getSelector(nameOrSelector: string): string {\n if (!selectors.has(nameOrSelector)) {\n const parts = [\n // Single selector\n `[data-component=\"${nameOrSelector}\"]`,\n // Selector in the middle of a list of selectors\n `[data-component*=\"${separator}${nameOrSelector}${separator}\"]`,\n // Selector at the end of a list of selectors\n `[data-component$=\"${separator}${nameOrSelector}\"]`,\n // Selector at the beginning of a list of selectors\n `[data-component^=\"${nameOrSelector}${separator}\"]`,\n ];\n selectors.set(nameOrSelector, parts.join(','));\n }\n\n return selectors.get(nameOrSelector);\n}\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(\n nameOrSelector: string,\n element: HTMLElement | Document = document,\n): HTMLElement[] {\n const selector = getSelector(nameOrSelector);\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event: string, element: HTMLElement): boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.\n */\nexport function getEventTarget(\n instance: Base,\n event: string,\n config: BaseConfig,\n): Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n // @todo v3 return false or null\n return instance;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAG1C,IAAM,YAAY,oBAAI,IAAI;AAG1B,IAAM,YAAY;AAKlB,SAAS,YAAY,gBAAgC;AACnD,MAAI,CAAC,UAAU,IAAI,cAAc,GAAG;AAClC,UAAM,QAAQ;AAAA,MAEZ,oBAAoB;AAAA,MAEpB,qBAAqB,YAAY,iBAAiB;AAAA,MAElD,qBAAqB,YAAY;AAAA,MAEjC,qBAAqB,iBAAiB;AAAA,IACxC;AACA,cAAU,IAAI,gBAAgB,MAAM,KAAK,GAAG,CAAC;AAAA,EAC/C;AAEA,SAAO,UAAU,IAAI,cAAc;AACrC;AAYO,SAAS,qBACd,gBACA,UAAkC,UACnB;AACf,QAAM,WAAW,YAAY,cAAc;AAC3C,MAAI,WAAW,CAAC;AAEhB,MAAI;AACF,eAAW,MAAM,KAAK,QAAQ,iBAAiB,QAAQ,CAAC;AAAA,EAE1D,QAAE;AAAA,EAAO;AAGT,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,MAAM,KAAK,QAAQ,iBAAiB,cAAc,CAAC;AAAA,EAChE;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,OAAe,QAA6B;AACjF,aAAO,sBAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,KAAK;AAC7D;AAKO,SAAS,cAAc,OAAe,SAA+B;AAC1E,aAAO,wBAAU,QAAQ,KAAK,QAAQ;AACxC;AAMO,SAAS,eACd,UACA,OACA,QACoB;AACpB,MAAI,uBAAuB,OAAO,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,OAAO,SAAS,GAAG,GAAG;AACtC,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,oBAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/Base/utils.d.ts CHANGED
@@ -20,5 +20,6 @@ export declare function eventIsDefinedInConfig(event: string, config: BaseConfig
20
20
  export declare function eventIsNative(event: string, element: HTMLElement): boolean;
21
21
  /**
22
22
  * Get the target of a given event.
23
+ * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.
23
24
  */
24
25
  export declare function getEventTarget(instance: Base, event: string, config: BaseConfig): Base | Base['$el'];
package/Base/utils.js CHANGED
@@ -1,6 +1,20 @@
1
1
  import { isArray, isDefined, isDev } from "../utils/index.js";
2
+ const selectors = /* @__PURE__ */ new Map();
3
+ const separator = " ";
4
+ function getSelector(nameOrSelector) {
5
+ if (!selectors.has(nameOrSelector)) {
6
+ const parts = [
7
+ `[data-component="${nameOrSelector}"]`,
8
+ `[data-component*="${separator}${nameOrSelector}${separator}"]`,
9
+ `[data-component$="${separator}${nameOrSelector}"]`,
10
+ `[data-component^="${nameOrSelector}${separator}"]`
11
+ ];
12
+ selectors.set(nameOrSelector, parts.join(","));
13
+ }
14
+ return selectors.get(nameOrSelector);
15
+ }
2
16
  function getComponentElements(nameOrSelector, element = document) {
3
- const selector = `[data-component="${nameOrSelector}"]`;
17
+ const selector = getSelector(nameOrSelector);
4
18
  let elements = [];
5
19
  try {
6
20
  elements = Array.from(element.querySelectorAll(selector));
package/Base/utils.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/Base/utils.ts"],
4
- "sourcesContent": ["import { isArray, isDefined, isDev } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(nameOrSelector:string, element:HTMLElement | Document = document):HTMLElement[] {\n const selector = `[data-component=\"${nameOrSelector}\"]`;\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event:string, config: BaseConfig):boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event:string, element:HTMLElement):boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n */\nexport function getEventTarget(instance:Base, event:string, config:BaseConfig):Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n return instance;\n}\n"],
5
- "mappings": "AAAA,SAAS,SAAS,WAAW,aAAa;AAanC,SAAS,qBAAqB,gBAAuB,UAAiC,UAAwB;AACnH,QAAM,WAAW,oBAAoB;AACrC,MAAI,WAAW,CAAC;AAEhB,MAAI;AACF,eAAW,MAAM,KAAK,QAAQ,iBAAiB,QAAQ,CAAC;AAAA,EAE1D,QAAE;AAAA,EAAO;AAGT,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,MAAM,KAAK,QAAQ,iBAAiB,cAAc,CAAC;AAAA,EAChE;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,OAAc,QAA4B;AAC/E,SAAO,QAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,KAAK;AAC7D;AAKO,SAAS,cAAc,OAAc,SAA6B;AACvE,SAAO,UAAU,QAAQ,KAAK,QAAQ;AACxC;AAKO,SAAS,eAAe,UAAe,OAAc,QAAsC;AAChG,MAAI,uBAAuB,OAAO,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,OAAO,SAAS,GAAG,GAAG;AACtC,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,OAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isArray, isDefined, isDev } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\n\nconst selectors = new Map();\n\n// Separator used for multi-component declaration in `data-component` attributeS.\nconst separator = ' ';\n\n/**\n * Get the selector for a given component.\n */\nfunction getSelector(nameOrSelector: string): string {\n if (!selectors.has(nameOrSelector)) {\n const parts = [\n // Single selector\n `[data-component=\"${nameOrSelector}\"]`,\n // Selector in the middle of a list of selectors\n `[data-component*=\"${separator}${nameOrSelector}${separator}\"]`,\n // Selector at the end of a list of selectors\n `[data-component$=\"${separator}${nameOrSelector}\"]`,\n // Selector at the beginning of a list of selectors\n `[data-component^=\"${nameOrSelector}${separator}\"]`,\n ];\n selectors.set(nameOrSelector, parts.join(','));\n }\n\n return selectors.get(nameOrSelector);\n}\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(\n nameOrSelector: string,\n element: HTMLElement | Document = document,\n): HTMLElement[] {\n const selector = getSelector(nameOrSelector);\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event: string, element: HTMLElement): boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.\n */\nexport function getEventTarget(\n instance: Base,\n event: string,\n config: BaseConfig,\n): Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n // @todo v3 return false or null\n return instance;\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAAS,WAAW,aAAa;AAG1C,MAAM,YAAY,oBAAI,IAAI;AAG1B,MAAM,YAAY;AAKlB,SAAS,YAAY,gBAAgC;AACnD,MAAI,CAAC,UAAU,IAAI,cAAc,GAAG;AAClC,UAAM,QAAQ;AAAA,MAEZ,oBAAoB;AAAA,MAEpB,qBAAqB,YAAY,iBAAiB;AAAA,MAElD,qBAAqB,YAAY;AAAA,MAEjC,qBAAqB,iBAAiB;AAAA,IACxC;AACA,cAAU,IAAI,gBAAgB,MAAM,KAAK,GAAG,CAAC;AAAA,EAC/C;AAEA,SAAO,UAAU,IAAI,cAAc;AACrC;AAYO,SAAS,qBACd,gBACA,UAAkC,UACnB;AACf,QAAM,WAAW,YAAY,cAAc;AAC3C,MAAI,WAAW,CAAC;AAEhB,MAAI;AACF,eAAW,MAAM,KAAK,QAAQ,iBAAiB,QAAQ,CAAC;AAAA,EAE1D,QAAE;AAAA,EAAO;AAGT,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,MAAM,KAAK,QAAQ,iBAAiB,cAAc,CAAC;AAAA,EAChE;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,OAAe,QAA6B;AACjF,SAAO,QAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,KAAK;AAC7D;AAKO,SAAS,cAAc,OAAe,SAA+B;AAC1E,SAAO,UAAU,QAAQ,KAAK,QAAQ;AACxC;AAMO,SAAS,eACd,UACA,OACA,QACoB;AACpB,MAAI,uBAAuB,OAAO,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,OAAO,SAAS,GAAG,GAAG;AACtC,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,OAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -24,7 +24,7 @@ __reExport(decorators_exports, require("./withFreezedOptions.cjs"), module.expor
24
24
  __reExport(decorators_exports, require("./withIntersectionObserver.cjs"), module.exports);
25
25
  __reExport(decorators_exports, require("./withMountWhenInView.cjs"), module.exports);
26
26
  __reExport(decorators_exports, require("./withResponsiveOptions.cjs"), module.exports);
27
- __reExport(decorators_exports, require("./withScrolledInView.cjs"), module.exports);
27
+ __reExport(decorators_exports, require("./withScrolledInView/index.cjs"), module.exports);
28
28
  __reExport(decorators_exports, require("./withVue2.cjs"), module.exports);
29
29
  if (module.exports.default) module.exports = module.exports.default;
30
30
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/index.ts"],
4
- "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView.js';\nexport * from './withVue2.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,wCAAd;AACA,+BAAc,yCADd;AAEA,+BAAc,2BAFd;AAGA,+BAAc,kCAHd;AAIA,+BAAc,qCAJd;AAKA,+BAAc,2CALd;AAMA,+BAAc,sCANd;AAOA,+BAAc,wCAPd;AAQA,+BAAc,qCARd;AASA,+BAAc,2BATd;",
4
+ "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView/index.js';\nexport * from './withVue2.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,wCAAd;AACA,+BAAc,yCADd;AAEA,+BAAc,2BAFd;AAGA,+BAAc,kCAHd;AAIA,+BAAc,qCAJd;AAKA,+BAAc,2CALd;AAMA,+BAAc,sCANd;AAOA,+BAAc,wCAPd;AAQA,+BAAc,2CARd;AASA,+BAAc,2BATd;",
6
6
  "names": []
7
7
  }
@@ -6,5 +6,5 @@ export * from './withFreezedOptions.js';
6
6
  export * from './withIntersectionObserver.js';
7
7
  export * from './withMountWhenInView.js';
8
8
  export * from './withResponsiveOptions.js';
9
- export * from './withScrolledInView.js';
9
+ export * from './withScrolledInView/index.js';
10
10
  export * from './withVue2.js';
@@ -6,6 +6,6 @@ export * from "./withFreezedOptions.js";
6
6
  export * from "./withIntersectionObserver.js";
7
7
  export * from "./withMountWhenInView.js";
8
8
  export * from "./withResponsiveOptions.js";
9
- export * from "./withScrolledInView.js";
9
+ export * from "./withScrolledInView/index.js";
10
10
  export * from "./withVue2.js";
11
11
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/index.ts"],
4
- "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView.js';\nexport * from './withVue2.js';\n"],
4
+ "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView/index.js';\nexport * from './withVue2.js';\n"],
5
5
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/withBreakpointManager.ts"],
4
- "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseConstructor, BaseProps } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev, isArray } from '../utils/index.js';\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n */\nfunction testBreakpoints(breakpoints: Array<[string[], Base]>) {\n const { breakpoint } = useResize().props();\n breakpoints.forEach(([breakpointKeys, instance]) => {\n if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {\n setTimeout(() => instance.$mount(), 0);\n } else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {\n instance.$destroy();\n }\n });\n}\n\n/**\n * Prepare the components.\n */\nfunction mountComponents(\n instance: Base,\n breakpoints: Array<[string, BaseConstructor]>,\n): Array<[string[], Base]> {\n return breakpoints.map(([bk, ComponentClass]) => {\n const child = new ComponentClass(instance.$el);\n Object.defineProperty(child, '$parent', { get: () => instance.$parent });\n return [bk.split(' '), child];\n });\n}\n\n/**\n * A cache object to hold each Base sub-instances.\n */\nconst instances:WeakMap<Base, Array<[string[], Base]>> = new WeakMap();\n\n/**\n * BreakpointManager class.\n */\nexport function withBreakpointManager<S extends Base>(\n BaseClass: typeof Base,\n breakpoints: Array<[string, BaseConstructor<Base>]>,\n): BaseDecorator<BaseInterface, S> {\n if (!isArray(breakpoints)) {\n if (isDev) {\n throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n if (breakpoints.length < 2) {\n if (isDev) {\n throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n const { add, props } = useResize();\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error('The `BreakpointManager` class requires breakpoints to be defined.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n /**\n * Class.\n */\n class WithBreakpointManager<\n T extends BaseProps = BaseProps,\n > extends BaseClass<T> {\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n if (!instances.has(this)) {\n instances.set(this, mountComponents(this, breakpoints));\n }\n\n add(`BreakpointManager-${this.$id}`, () => {\n testBreakpoints(instances.get(this));\n });\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount(): this {\n super.$mount();\n\n testBreakpoints(instances.get(this));\n\n return this;\n }\n\n /**\n * Destroy all instances when the main one is destroyed.\n */\n $destroy():this {\n if (isArray(instances.get(this))) {\n instances.get(this).forEach(([, instance]) => {\n instance.$destroy();\n });\n }\n\n return super.$destroy();\n }\n }\n\n // @ts-ignore\n return WithBreakpointManager;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAA0B;AAC1B,mBAA+B;AAK/B,SAAS,gBAAgB,aAAsC;AAC7D,QAAM,EAAE,WAAW,QAAI,2BAAU,EAAE,MAAM;AACzC,cAAY,QAAQ,CAAC,CAAC,gBAAgB,QAAQ,MAAM;AAClD,QAAI,eAAe,SAAS,UAAU,KAAK,CAAC,SAAS,YAAY;AAC/D,iBAAW,MAAM,SAAS,OAAO,GAAG,CAAC;AAAA,IACvC,WAAW,CAAC,eAAe,SAAS,UAAU,KAAK,SAAS,YAAY;AACtE,eAAS,SAAS;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAKA,SAAS,gBACP,UACA,aACyB;AACzB,SAAO,YAAY,IAAI,CAAC,CAAC,IAAI,cAAc,MAAM;AAC/C,UAAM,QAAQ,IAAI,eAAe,SAAS,GAAG;AAC7C,WAAO,eAAe,OAAO,WAAW,EAAE,KAAK,MAAM,SAAS,QAAQ,CAAC;AACvE,WAAO,CAAC,GAAG,MAAM,GAAG,GAAG,KAAK;AAAA,EAC9B,CAAC;AACH;AAKA,IAAM,YAAmD,oBAAI,QAAQ;AAK9D,SAAS,sBACd,WACA,aACiC;AACjC,MAAI,KAAC,sBAAQ,WAAW,GAAG;AACzB,QAAI,oBAAO;AACT,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAGA,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,SAAS,GAAG;AAC1B,QAAI,oBAAO;AACT,YAAM,IAAI,MAAM,iEAAiE;AAAA,IACnF;AAGA,WAAO;AAAA,EACT;AAEA,QAAM,EAAE,KAAK,MAAM,QAAI,2BAAU;AAIjC,MAAI,CAAC,MAAM,EAAE,YAAY;AACvB,QAAI,oBAAO;AACT,YAAM,IAAI,MAAM,mEAAmE;AAAA,IACrF;AAGA,WAAO;AAAA,EACT;AAKA,QAAM,8BAEI,UAAa;AAAA,IAIrB,YAAY,SAAsB;AAChC,YAAM,OAAO;AAEb,UAAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACxB,kBAAU,IAAI,MAAM,gBAAgB,MAAM,WAAW,CAAC;AAAA,MACxD;AAEA,UAAI,qBAAqB,KAAK,OAAO,MAAM;AACzC,wBAAgB,UAAU,IAAI,IAAI,CAAC;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IAMA,SAAe;AACb,YAAM,OAAO;AAEb,sBAAgB,UAAU,IAAI,IAAI,CAAC;AAEnC,aAAO;AAAA,IACT;AAAA,IAKA,WAAgB;AACd,cAAI,sBAAQ,UAAU,IAAI,IAAI,CAAC,GAAG;AAChC,kBAAU,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,MAAM;AAC5C,mBAAS,SAAS;AAAA,QACpB,CAAC;AAAA,MACH;AAEA,aAAO,MAAM,SAAS;AAAA,IACxB;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseConstructor, BaseProps } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev, isArray } from '../utils/index.js';\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n */\nfunction testBreakpoints(breakpoints: Array<[string[], Base]>) {\n const { breakpoint } = useResize().props();\n breakpoints.forEach(([breakpointKeys, instance]) => {\n if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {\n setTimeout(() => instance.$mount(), 0);\n } else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {\n instance.$destroy();\n }\n });\n}\n\n/**\n * Prepare the components.\n */\nfunction mountComponents(\n instance: Base,\n breakpoints: Array<[string, BaseConstructor]>,\n): Array<[string[], Base]> {\n return breakpoints.map(([bk, ComponentClass]) => {\n const child = new ComponentClass(instance.$el);\n Object.defineProperty(child, '$parent', { get: () => instance.$parent });\n return [bk.split(' '), child];\n });\n}\n\n/**\n * A cache object to hold each Base sub-instances.\n */\nconst instances: WeakMap<Base, Array<[string[], Base]>> = new WeakMap();\n\n/**\n * BreakpointManager class.\n */\nexport function withBreakpointManager<S extends Base>(\n BaseClass: typeof Base,\n breakpoints: Array<[string, BaseConstructor<Base>]>,\n): BaseDecorator<BaseInterface, S> {\n if (!isArray(breakpoints)) {\n if (isDev) {\n throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n if (breakpoints.length < 2) {\n if (isDev) {\n throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n const { add, props } = useResize();\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error('The `BreakpointManager` class requires breakpoints to be defined.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n /**\n * Class.\n */\n class WithBreakpointManager<T extends BaseProps = BaseProps> extends BaseClass<T> {\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n if (!instances.has(this)) {\n instances.set(this, mountComponents(this, breakpoints));\n }\n\n add(`BreakpointManager-${this.$id}`, () => {\n testBreakpoints(instances.get(this));\n });\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount(): this {\n super.$mount();\n\n testBreakpoints(instances.get(this));\n\n return this;\n }\n\n /**\n * Destroy all instances when the main one is destroyed.\n */\n $destroy(): this {\n if (isArray(instances.get(this))) {\n instances.get(this).forEach(([, instance]) => {\n instance.$destroy();\n });\n }\n\n return super.$destroy();\n }\n }\n\n // @ts-ignore\n return WithBreakpointManager;\n}\n"],
5
+ "mappings": ";;;;;;;;;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AAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACxB,kBAAU,IAAI,MAAM,gBAAgB,MAAM,WAAW,CAAC;AAAA,MACxD;AAEA,UAAI,qBAAqB,KAAK,OAAO,MAAM;AACzC,wBAAgB,UAAU,IAAI,IAAI,CAAC;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IAMA,SAAe;AACb,YAAM,OAAO;AAEb,sBAAgB,UAAU,IAAI,IAAI,CAAC;AAEnC,aAAO;AAAA,IACT;AAAA,IAKA,WAAiB;AACf,cAAI,sBAAQ,UAAU,IAAI,IAAI,CAAC,GAAG;AAChC,kBAAU,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,MAAM;AAC5C,mBAAS,SAAS;AAAA,QACpB,CAAC;AAAA,MACH;AAEA,aAAO,MAAM,SAAS;AAAA,IACxB;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/withBreakpointManager.ts"],
4
- "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseConstructor, BaseProps } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev, isArray } from '../utils/index.js';\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n */\nfunction testBreakpoints(breakpoints: Array<[string[], Base]>) {\n const { breakpoint } = useResize().props();\n breakpoints.forEach(([breakpointKeys, instance]) => {\n if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {\n setTimeout(() => instance.$mount(), 0);\n } else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {\n instance.$destroy();\n }\n });\n}\n\n/**\n * Prepare the components.\n */\nfunction mountComponents(\n instance: Base,\n breakpoints: Array<[string, BaseConstructor]>,\n): Array<[string[], Base]> {\n return breakpoints.map(([bk, ComponentClass]) => {\n const child = new ComponentClass(instance.$el);\n Object.defineProperty(child, '$parent', { get: () => instance.$parent });\n return [bk.split(' '), child];\n });\n}\n\n/**\n * A cache object to hold each Base sub-instances.\n */\nconst instances:WeakMap<Base, Array<[string[], Base]>> = new WeakMap();\n\n/**\n * BreakpointManager class.\n */\nexport function withBreakpointManager<S extends Base>(\n BaseClass: typeof Base,\n breakpoints: Array<[string, BaseConstructor<Base>]>,\n): BaseDecorator<BaseInterface, S> {\n if (!isArray(breakpoints)) {\n if (isDev) {\n throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n if (breakpoints.length < 2) {\n if (isDev) {\n throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n const { add, props } = useResize();\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error('The `BreakpointManager` class requires breakpoints to be defined.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n /**\n * Class.\n */\n class WithBreakpointManager<\n T extends BaseProps = BaseProps,\n > extends BaseClass<T> {\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n if (!instances.has(this)) {\n instances.set(this, mountComponents(this, breakpoints));\n }\n\n add(`BreakpointManager-${this.$id}`, () => {\n testBreakpoints(instances.get(this));\n });\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount(): this {\n super.$mount();\n\n testBreakpoints(instances.get(this));\n\n return this;\n }\n\n /**\n * Destroy all instances when the main one is destroyed.\n */\n $destroy():this {\n if (isArray(instances.get(this))) {\n instances.get(this).forEach(([, instance]) => {\n instance.$destroy();\n });\n }\n\n return super.$destroy();\n }\n }\n\n // @ts-ignore\n return WithBreakpointManager;\n}\n"],
5
- "mappings": "AAEA,SAAS,iBAAiB;AAC1B,SAAS,OAAO,eAAe;AAK/B,SAAS,gBAAgB,a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,UAAI,qBAAqB,KAAK,OAAO,MAAM;AACzC,wBAAgB,UAAU,IAAI,IAAI,CAAC;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IAMA,SAAe;AACb,YAAM,OAAO;AAEb,sBAAgB,UAAU,IAAI,IAAI,CAAC;AAEnC,aAAO;AAAA,IACT;AAAA,IAKA,WAAgB;AACd,UAAI,QAAQ,UAAU,IAAI,IAAI,CAAC,GAAG;AAChC,kBAAU,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,MAAM;AAC5C,mBAAS,SAAS;AAAA,QACpB,CAAC;AAAA,MACH;AAEA,aAAO,MAAM,SAAS;AAAA,IACxB;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseConstructor, BaseProps } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev, isArray } from '../utils/index.js';\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n */\nfunction testBreakpoints(breakpoints: Array<[string[], Base]>) {\n const { breakpoint } = useResize().props();\n breakpoints.forEach(([breakpointKeys, instance]) => {\n if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {\n setTimeout(() => instance.$mount(), 0);\n } else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {\n instance.$destroy();\n }\n });\n}\n\n/**\n * Prepare the components.\n */\nfunction mountComponents(\n instance: Base,\n breakpoints: Array<[string, BaseConstructor]>,\n): Array<[string[], Base]> {\n return breakpoints.map(([bk, ComponentClass]) => {\n const child = new ComponentClass(instance.$el);\n Object.defineProperty(child, '$parent', { get: () => instance.$parent });\n return [bk.split(' '), child];\n });\n}\n\n/**\n * A cache object to hold each Base sub-instances.\n */\nconst instances: WeakMap<Base, Array<[string[], Base]>> = new WeakMap();\n\n/**\n * BreakpointManager class.\n */\nexport function withBreakpointManager<S extends Base>(\n BaseClass: typeof Base,\n breakpoints: Array<[string, BaseConstructor<Base>]>,\n): BaseDecorator<BaseInterface, S> {\n if (!isArray(breakpoints)) {\n if (isDev) {\n throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n if (breakpoints.length < 2) {\n if (isDev) {\n throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n const { add, props } = useResize();\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error('The `BreakpointManager` class requires breakpoints to be defined.');\n }\n\n // @ts-ignore\n return BaseClass;\n }\n\n /**\n * Class.\n */\n class WithBreakpointManager<T extends BaseProps = BaseProps> extends BaseClass<T> {\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n if (!instances.has(this)) {\n instances.set(this, mountComponents(this, breakpoints));\n }\n\n add(`BreakpointManager-${this.$id}`, () => {\n testBreakpoints(instances.get(this));\n });\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount(): this {\n super.$mount();\n\n testBreakpoints(instances.get(this));\n\n return this;\n }\n\n /**\n * Destroy all instances when the main one is destroyed.\n */\n $destroy(): this {\n if (isArray(instances.get(this))) {\n instances.get(this).forEach(([, instance]) => {\n instance.$destroy();\n });\n }\n\n return super.$destroy();\n }\n }\n\n // @ts-ignore\n return WithBreakpointManager;\n}\n"],
5
+ "mappings": "AAEA,SAAS,iBAAiB;AAC1B,SAAS,OAAO,eAAe;AAK/B,SAAS,gBAAgB,aAAsC;AAC7D,QAAM,EAAE,WAAW,IAAI,UAAU,EAAE,MAAM;AACzC,cAAY,QAAQ,CAAC,CAAC,gBAAgB,QAAQ,MAAM;AAClD,QAAI,eAAe,SAAS,UAAU,KAAK,CAAC,SAAS,YAAY;AAC/D,iBAAW,MAAM,SAAS,OAAO,GAAG,CAAC;AAAA,IACvC,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AACf,UAAI,QAAQ,UAAU,IAAI,IAAI,CAAC,GAAG;AAChC,kBAAU,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,MAAM;AAC5C,mBAAS,SAAS;AAAA,QACpB,CAAC;AAAA,MACH;AAEA,aAAO,MAAM,SAAS;AAAA,IACxB;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/withBreakpointObserver.ts"],
4
- "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev } from '../utils/index.js';\n\nexport interface WithBreakpointObserverProps extends BaseProps {\n $options: {\n activeBreakpoints?: string;\n inactiveBreakpoints?: string;\n };\n}\n\nexport interface WithBreakpointObserverInterface extends BaseInterface {\n $mount():this;\n}\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n *\n * @param {Base<WithBreakpointObserverProps>} instance The component's instance.\n * @param {string} [breakpoint] The breakpoint to test.\n * @returns {string} The action to trigger.\n */\nfunction testBreakpoints(\n instance: Base<WithBreakpointObserverProps>,\n breakpoint: string = useResize().props().breakpoint,\n): string {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n const isInActiveBreakpoint =\n activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);\n const isInInactiveBreakpoint =\n inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);\n\n if (\n (activeBreakpoints && isInActiveBreakpoint) ||\n (inactiveBreakpoints && !isInInactiveBreakpoint)\n ) {\n return '$mount';\n }\n\n return '$destroy';\n}\n\n/**\n * Test if the given instance is configured for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {boolean} True if configured correctly, false otherwise.\n */\nfunction hasBreakpointConfiguration(instance: Base<WithBreakpointObserverProps>): boolean {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n return Boolean(activeBreakpoints || inactiveBreakpoints);\n}\n\n/**\n * Test if the given instance has a conflicting configuration for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {void}\n */\nfunction testConflictingBreakpointConfiguration(\n instance: Base<WithBreakpointObserverProps>,\n): void {\n const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;\n if (activeBreakpoints && inactiveBreakpoints) {\n throw new Error(\n `[${name}] Incorrect configuration: the \\`activeBreakpoints\\` and \\`inactiveBreakpoints\\` are not compatible.`,\n );\n }\n}\n\n/**\n * Add the current instance to the resize service.\n * @param {string} key The key for the resize service callback.\n * @param {Base} instance The instance to observe.\n */\nfunction addToResize(key, instance) {\n if (isDev) {\n testConflictingBreakpointConfiguration(instance);\n }\n\n const { add, has } = useResize();\n\n if (!has(key)) {\n add(key, ({ breakpoint }) => {\n const action = testBreakpoints(instance, breakpoint);\n\n // Always destroy before mounting\n if (action === '$destroy' && instance.$isMounted) {\n instance[action]();\n } else if (action === '$mount' && !instance.$isMounted) {\n setTimeout(() => instance[action](), 0);\n }\n });\n }\n}\n\n/**\n * BreakpointObserver class.\n */\nexport function withBreakpointObserver<S extends Base>(\n BaseClass: typeof Base,\n): BaseDecorator<WithBreakpointObserverInterface, S, WithBreakpointObserverProps> {\n /**\n * Class.\n */\n class WithBreakpointObserver<T extends BaseProps = BaseProps> extends BaseClass<\n T & WithBreakpointObserverProps\n > {\n /**\n * Config.\n */\n static config:BaseConfig = {\n ...BaseClass.config,\n name: `${BaseClass.config.name}WithBreakpointObserver`,\n options: {\n ...(BaseClass.config?.options || {}),\n activeBreakpoints: String,\n inactiveBreakpoints: String,\n },\n };\n\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element:HTMLElement) {\n super(element);\n\n const { remove, props } = useResize();\n const { name } = this.$options;\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error(\n `[${name}] The \\`BreakpointObserver\\` class requires breakpoints to be defined.`,\n );\n }\n return;\n }\n\n const key = `BreakpointObserver-${this.$id}`;\n\n // Watch change on the `data-options` attribute to emit the `set:options` event.\n const mutationObserver = new MutationObserver(([mutation]) => {\n if (\n mutation.type === 'attributes' &&\n (mutation.attributeName === 'data-options' ||\n mutation.attributeName.startsWith('data-option-'))\n ) {\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n this.$mount();\n remove(key);\n return;\n }\n\n addToResize(key, this);\n }\n });\n mutationObserver.observe(this.$el, { attributes: true });\n\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return;\n }\n\n addToResize(key, this);\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount():this {\n // Execute normal behavior when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return super.$mount();\n }\n\n const action = testBreakpoints(this);\n if (action === '$mount') {\n return super.$mount();\n }\n\n return this;\n }\n }\n\n // @ts-ignore\n return WithBreakpointObserver;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAA0B;AAC1B,mBAAsB;AAoBtB,SAAS,gBACP,UACA,iBAAqB,2BAAU,EAAE,MAAM,EAAE,YACjC;AACR,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC5D,QAAM,uBACJ,qBAAqB,kBAAkB,MAAM,GAAG,EAAE,SAAS,UAAU;AACvE,QAAM,yBACJ,uBAAuB,oBAAoB,MAAM,GAAG,EAAE,SAAS,UAAU;AAE3E,MACG,qBAAqB,wBACrB,uBAAuB,CAAC,wBACzB;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOA,SAAS,2BAA2B,UAAsD;AACxF,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC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,CAAC,QAAQ,MAAM;AAC5D,YACE,SAAS,SAAS,iBACjB,SAAS,kBAAkB,kBAC1B,SAAS,cAAc,WAAW,cAAc,IAClD;AAEA,cAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC,iBAAK,OAAO;AACZ,mBAAO,GAAG;AACV;AAAA,UACF;AAEA,sBAAY,KAAK,IAAI;AAAA,QACvB;AAAA,MACF,CAAC;AACD,uBAAiB,QAAQ,KAAK,KAAK,EAAE,YAAY,KAAK,CAAC;AAGvD,UAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC;AAAA,MACF;AAEA,kBAAY,KAAK,IAAI;AAAA,IACvB;AAAA,IAMA,SAAc;AAEZ,UAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC,eAAO,MAAM,OAAO;AAAA,MACtB;AAEA,YAAM,SAAS,gBAAgB,IAAI;AACnC,UAAI,WAAW,UAAU;AACvB,eAAO,MAAM,OAAO;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev } from '../utils/index.js';\n\nexport interface WithBreakpointObserverProps extends BaseProps {\n $options: {\n activeBreakpoints?: string;\n inactiveBreakpoints?: string;\n };\n}\n\nexport interface WithBreakpointObserverInterface extends BaseInterface {\n $mount(): this;\n}\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n *\n * @param {Base<WithBreakpointObserverProps>} instance The component's instance.\n * @param {string} [breakpoint] The breakpoint to test.\n * @returns {string} The action to trigger.\n */\nfunction testBreakpoints(\n instance: Base<WithBreakpointObserverProps>,\n breakpoint: string = useResize().props().breakpoint,\n): string {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n const isInActiveBreakpoint =\n activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);\n const isInInactiveBreakpoint =\n inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);\n\n if (\n (activeBreakpoints && isInActiveBreakpoint) ||\n (inactiveBreakpoints && !isInInactiveBreakpoint)\n ) {\n return '$mount';\n }\n\n return '$destroy';\n}\n\n/**\n * Test if the given instance is configured for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {boolean} True if configured correctly, false otherwise.\n */\nfunction hasBreakpointConfiguration(instance: Base<WithBreakpointObserverProps>): boolean {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n return Boolean(activeBreakpoints || inactiveBreakpoints);\n}\n\n/**\n * Test if the given instance has a conflicting configuration for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {void}\n */\nfunction testConflictingBreakpointConfiguration(instance: Base<WithBreakpointObserverProps>): void {\n const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;\n if (activeBreakpoints && inactiveBreakpoints) {\n throw new Error(\n `[${name}] Incorrect configuration: the \\`activeBreakpoints\\` and \\`inactiveBreakpoints\\` are not compatible.`,\n );\n }\n}\n\n/**\n * Add the current instance to the resize service.\n * @param {string} key The key for the resize service callback.\n * @param {Base} instance The instance to observe.\n */\nfunction addToResize(key, instance) {\n if (isDev) {\n testConflictingBreakpointConfiguration(instance);\n }\n\n const { add, has } = useResize();\n\n if (!has(key)) {\n add(key, ({ breakpoint }) => {\n const action = testBreakpoints(instance, breakpoint);\n\n // Always destroy before mounting\n if (action === '$destroy' && instance.$isMounted) {\n instance[action]();\n } else if (action === '$mount' && !instance.$isMounted) {\n setTimeout(() => instance[action](), 0);\n }\n });\n }\n}\n\n/**\n * BreakpointObserver class.\n */\nexport function withBreakpointObserver<S extends Base>(\n BaseClass: typeof Base,\n): BaseDecorator<WithBreakpointObserverInterface, S, WithBreakpointObserverProps> {\n /**\n * Class.\n */\n class WithBreakpointObserver<T extends BaseProps = BaseProps> extends BaseClass<\n T & WithBreakpointObserverProps\n > {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...BaseClass.config,\n name: `${BaseClass.config.name}WithBreakpointObserver`,\n options: {\n ...(BaseClass.config?.options || {}),\n activeBreakpoints: String,\n inactiveBreakpoints: String,\n },\n };\n\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n const { remove, props } = useResize();\n const { name } = this.$options;\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error(\n `[${name}] The \\`BreakpointObserver\\` class requires breakpoints to be defined.`,\n );\n }\n return;\n }\n\n const key = `BreakpointObserver-${this.$id}`;\n\n // Watch change on the `data-options` attribute to emit the `set:options` event.\n const mutationObserver = new MutationObserver(([mutation]) => {\n if (\n mutation.type === 'attributes' &&\n (mutation.attributeName === 'data-options' ||\n mutation.attributeName.startsWith('data-option-'))\n ) {\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n this.$mount();\n remove(key);\n return;\n }\n\n addToResize(key, this);\n }\n });\n mutationObserver.observe(this.$el, { attributes: true });\n\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return;\n }\n\n addToResize(key, this);\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount(): this {\n // Execute normal behavior when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return super.$mount();\n }\n\n const action = testBreakpoints(this);\n if (action === '$mount') {\n return super.$mount();\n }\n\n return this;\n }\n }\n\n // @ts-ignore\n return WithBreakpointObserver;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAA0B;AAC1B,mBAAsB;AAoBtB,SAAS,gBACP,UACA,iBAAqB,2BAAU,EAAE,MAAM,EAAE,YACjC;AACR,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC5D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AAChC,YAAM,OAAO;AAEb,YAAM,EAAE,QAAQ,MAAM,QAAI,2BAAU;AACpC,YAAM,EAAE,KAAK,IAAI,KAAK;AAItB,UAAI,CAAC,MAAM,EAAE,YAAY;AACvB,YAAI,oBAAO;AACT,gBAAM,IAAI;AAAA,YACR,IAAI;AAAA,UACN;AAAA,QACF;AACA;AAAA,MACF;AAEA,YAAM,MAAM,sBAAsB,KAAK;AAGvC,YAAM,mBAAmB,IAAI,iBAAiB,CAAC,CAAC,QAAQ,MAAM;AAC5D,YACE,SAAS,SAAS,iBACjB,SAAS,kBAAkB,kBAC1B,SAAS,cAAc,WAAW,cAAc,IAClD;AAEA,cAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC,iBAAK,OAAO;AACZ,mBAAO,GAAG;AACV;AAAA,UACF;AAEA,sBAAY,KAAK,IAAI;AAAA,QACvB;AAAA,MACF,CAAC;AACD,uBAAiB,QAAQ,KAAK,KAAK,EAAE,YAAY,KAAK,CAAC;AAGvD,UAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC;AAAA,MACF;AAEA,kBAAY,KAAK,IAAI;AAAA,IACvB;AAAA,IAMA,SAAe;AAEb,UAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC,eAAO,MAAM,OAAO;AAAA,MACtB;AAEA,YAAM,SAAS,gBAAgB,IAAI;AACnC,UAAI,WAAW,UAAU;AACvB,eAAO,MAAM,OAAO;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/withBreakpointObserver.ts"],
4
- "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev } from '../utils/index.js';\n\nexport interface WithBreakpointObserverProps extends BaseProps {\n $options: {\n activeBreakpoints?: string;\n inactiveBreakpoints?: string;\n };\n}\n\nexport interface WithBreakpointObserverInterface extends BaseInterface {\n $mount():this;\n}\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n *\n * @param {Base<WithBreakpointObserverProps>} instance The component's instance.\n * @param {string} [breakpoint] The breakpoint to test.\n * @returns {string} The action to trigger.\n */\nfunction testBreakpoints(\n instance: Base<WithBreakpointObserverProps>,\n breakpoint: string = useResize().props().breakpoint,\n): string {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n const isInActiveBreakpoint =\n activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);\n const isInInactiveBreakpoint =\n inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);\n\n if (\n (activeBreakpoints && isInActiveBreakpoint) ||\n (inactiveBreakpoints && !isInInactiveBreakpoint)\n ) {\n return '$mount';\n }\n\n return '$destroy';\n}\n\n/**\n * Test if the given instance is configured for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {boolean} True if configured correctly, false otherwise.\n */\nfunction hasBreakpointConfiguration(instance: Base<WithBreakpointObserverProps>): boolean {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n return Boolean(activeBreakpoints || inactiveBreakpoints);\n}\n\n/**\n * Test if the given instance has a conflicting configuration for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {void}\n */\nfunction testConflictingBreakpointConfiguration(\n instance: Base<WithBreakpointObserverProps>,\n): void {\n const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;\n if (activeBreakpoints && inactiveBreakpoints) {\n throw new Error(\n `[${name}] Incorrect configuration: the \\`activeBreakpoints\\` and \\`inactiveBreakpoints\\` are not compatible.`,\n );\n }\n}\n\n/**\n * Add the current instance to the resize service.\n * @param {string} key The key for the resize service callback.\n * @param {Base} instance The instance to observe.\n */\nfunction addToResize(key, instance) {\n if (isDev) {\n testConflictingBreakpointConfiguration(instance);\n }\n\n const { add, has } = useResize();\n\n if (!has(key)) {\n add(key, ({ breakpoint }) => {\n const action = testBreakpoints(instance, breakpoint);\n\n // Always destroy before mounting\n if (action === '$destroy' && instance.$isMounted) {\n instance[action]();\n } else if (action === '$mount' && !instance.$isMounted) {\n setTimeout(() => instance[action](), 0);\n }\n });\n }\n}\n\n/**\n * BreakpointObserver class.\n */\nexport function withBreakpointObserver<S extends Base>(\n BaseClass: typeof Base,\n): BaseDecorator<WithBreakpointObserverInterface, S, WithBreakpointObserverProps> {\n /**\n * Class.\n */\n class WithBreakpointObserver<T extends BaseProps = BaseProps> extends BaseClass<\n T & WithBreakpointObserverProps\n > {\n /**\n * Config.\n */\n static config:BaseConfig = {\n ...BaseClass.config,\n name: `${BaseClass.config.name}WithBreakpointObserver`,\n options: {\n ...(BaseClass.config?.options || {}),\n activeBreakpoints: String,\n inactiveBreakpoints: String,\n },\n };\n\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element:HTMLElement) {\n super(element);\n\n const { remove, props } = useResize();\n const { name } = this.$options;\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error(\n `[${name}] The \\`BreakpointObserver\\` class requires breakpoints to be defined.`,\n );\n }\n return;\n }\n\n const key = `BreakpointObserver-${this.$id}`;\n\n // Watch change on the `data-options` attribute to emit the `set:options` event.\n const mutationObserver = new MutationObserver(([mutation]) => {\n if (\n mutation.type === 'attributes' &&\n (mutation.attributeName === 'data-options' ||\n mutation.attributeName.startsWith('data-option-'))\n ) {\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n this.$mount();\n remove(key);\n return;\n }\n\n addToResize(key, this);\n }\n });\n mutationObserver.observe(this.$el, { attributes: true });\n\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return;\n }\n\n addToResize(key, this);\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount():this {\n // Execute normal behavior when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return super.$mount();\n }\n\n const action = testBreakpoints(this);\n if (action === '$mount') {\n return super.$mount();\n }\n\n return this;\n }\n }\n\n // @ts-ignore\n return WithBreakpointObserver;\n}\n"],
5
- "mappings": "AAEA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AAoBtB,SAAS,gBACP,UACA,aAAqB,UAAU,EAAE,MAAM,EAAE,YACjC;AACR,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC5D,QAAM,uBACJ,qBAAqB,kBAAkB,MAAM,GAAG,EAAE,SAAS,UAAU;AACvE,QAAM,yBACJ,uBAAuB,oBAAoB,MAAM,GAAG,EAAE,SAAS,UAAU;AAE3E,MACG,qBAAqB,wBACrB,uBAAuB,CAAC,wBACzB;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOA,SAAS,2BAA2B,UAAsD;AACxF,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC5D,SAAO,QAAQ,qBAAqB,mBAAmB;AACzD;AAOA,SAAS,uCACP,UACM;AACN,QAAM,EAAE,mBAAmB,qBAAqB,KAAK,IAAI,SAAS;AAClE,MAAI,qBAAqB,qBAAqB;AAC5C,UAAM,IAAI;AAAA,MACR,IAAI;AAAA,IACN;AAAA,EACF;AACF;AAOA,SAAS,YAAY,KAAK,UAAU;AAClC,MAAI,OAAO;AACT,2CAAuC,QAAQ;AAAA,EACjD;AAEA,QAAM,EAAE,KAAK,IAAI,IAAI,UAAU;AAE/B,MAAI,CAAC,IAAI,GAAG,GAAG;AACb,QAAI,KAAK,CAAC,EAAE,WAAW,MAAM;AAC3B,YAAM,SAAS,gBAAgB,UAAU,UAAU;AAGnD,UAAI,WAAW,cAAc,SAAS,YAAY;AAChD,iBAAS,QAAQ;AAAA,MACnB,WAAW,WAAW,YAAY,CAAC,SAAS,YAAY;AACtD,mBAAW,MAAM,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AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport { useResize } from '../services/index.js';\nimport { isDev } from '../utils/index.js';\n\nexport interface WithBreakpointObserverProps extends BaseProps {\n $options: {\n activeBreakpoints?: string;\n inactiveBreakpoints?: string;\n };\n}\n\nexport interface WithBreakpointObserverInterface extends BaseInterface {\n $mount(): this;\n}\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n *\n * @param {Base<WithBreakpointObserverProps>} instance The component's instance.\n * @param {string} [breakpoint] The breakpoint to test.\n * @returns {string} The action to trigger.\n */\nfunction testBreakpoints(\n instance: Base<WithBreakpointObserverProps>,\n breakpoint: string = useResize().props().breakpoint,\n): string {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n const isInActiveBreakpoint =\n activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);\n const isInInactiveBreakpoint =\n inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);\n\n if (\n (activeBreakpoints && isInActiveBreakpoint) ||\n (inactiveBreakpoints && !isInInactiveBreakpoint)\n ) {\n return '$mount';\n }\n\n return '$destroy';\n}\n\n/**\n * Test if the given instance is configured for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {boolean} True if configured correctly, false otherwise.\n */\nfunction hasBreakpointConfiguration(instance: Base<WithBreakpointObserverProps>): boolean {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n return Boolean(activeBreakpoints || inactiveBreakpoints);\n}\n\n/**\n * Test if the given instance has a conflicting configuration for breakpoints.\n * @param {Base<WithBreakpointObserverProps>} instance A Base class instance.\n * @returns {void}\n */\nfunction testConflictingBreakpointConfiguration(instance: Base<WithBreakpointObserverProps>): void {\n const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;\n if (activeBreakpoints && inactiveBreakpoints) {\n throw new Error(\n `[${name}] Incorrect configuration: the \\`activeBreakpoints\\` and \\`inactiveBreakpoints\\` are not compatible.`,\n );\n }\n}\n\n/**\n * Add the current instance to the resize service.\n * @param {string} key The key for the resize service callback.\n * @param {Base} instance The instance to observe.\n */\nfunction addToResize(key, instance) {\n if (isDev) {\n testConflictingBreakpointConfiguration(instance);\n }\n\n const { add, has } = useResize();\n\n if (!has(key)) {\n add(key, ({ breakpoint }) => {\n const action = testBreakpoints(instance, breakpoint);\n\n // Always destroy before mounting\n if (action === '$destroy' && instance.$isMounted) {\n instance[action]();\n } else if (action === '$mount' && !instance.$isMounted) {\n setTimeout(() => instance[action](), 0);\n }\n });\n }\n}\n\n/**\n * BreakpointObserver class.\n */\nexport function withBreakpointObserver<S extends Base>(\n BaseClass: typeof Base,\n): BaseDecorator<WithBreakpointObserverInterface, S, WithBreakpointObserverProps> {\n /**\n * Class.\n */\n class WithBreakpointObserver<T extends BaseProps = BaseProps> extends BaseClass<\n T & WithBreakpointObserverProps\n > {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...BaseClass.config,\n name: `${BaseClass.config.name}WithBreakpointObserver`,\n options: {\n ...(BaseClass.config?.options || {}),\n activeBreakpoints: String,\n inactiveBreakpoints: String,\n },\n };\n\n /**\n * Watch for the document resize to test the breakpoints.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n const { remove, props } = useResize();\n const { name } = this.$options;\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n if (isDev) {\n throw new Error(\n `[${name}] The \\`BreakpointObserver\\` class requires breakpoints to be defined.`,\n );\n }\n return;\n }\n\n const key = `BreakpointObserver-${this.$id}`;\n\n // Watch change on the `data-options` attribute to emit the `set:options` event.\n const mutationObserver = new MutationObserver(([mutation]) => {\n if (\n mutation.type === 'attributes' &&\n (mutation.attributeName === 'data-options' ||\n mutation.attributeName.startsWith('data-option-'))\n ) {\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n this.$mount();\n remove(key);\n return;\n }\n\n addToResize(key, this);\n }\n });\n mutationObserver.observe(this.$el, { attributes: true });\n\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return;\n }\n\n addToResize(key, this);\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n */\n $mount(): this {\n // Execute normal behavior when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return super.$mount();\n }\n\n const action = testBreakpoints(this);\n if (action === '$mount') {\n return super.$mount();\n }\n\n return this;\n }\n }\n\n // @ts-ignore\n return WithBreakpointObserver;\n}\n"],
5
+ "mappings": "AAEA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AAoBtB,SAAS,gBACP,UACA,aAAqB,UAAU,EAAE,MAAM,EAAE,YACjC;AACR,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC5D,QAAM,uBACJ,qBAAqB,kBAAkB,MAAM,GAAG,EAAE,SAAS,UAAU;AACvE,QAAM,yBACJ,uBAAuB,oBAAoB,MAAM,GAAG,EAAE,SAAS,UAAU;AAE3E,MACG,qBAAqB,wBACrB,uBAAuB,CAAC,wBACzB;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOA,SAAS,2BAA2B,UAAsD;AACxF,QAAM,EAAE,mBAAmB,oBAAoB,IAAI,SAAS;AAC5D,SAAO,QAAQ,qBAAqB,mBAAmB;AACzD;AAOA,SAAS,uCAAuC,UAAmD;AACjG,QAAM,EAAE,mBAAmB,qBAAqB,KAAK,IAAI,SAAS;AAClE,MAAI,qBAAqB,qBAAqB;AAC5C,UAAM,IAAI;AAAA,MACR,IAAI;AAAA,IACN;AAAA,EACF;AACF;AAOA,SAAS,YAAY,KAAK,UAAU;AAClC,MAAI,OAAO;AACT,2CAAuC,QAAQ;AAAA,EACjD;AAEA,QAAM,EAAE,KAAK,IAAI,IAAI,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2BAA2B,IAAI,GAAG;AACrC;AAAA,MACF;AAEA,kBAAY,KAAK,IAAI;AAAA,IACvB;AAAA,IAMA,SAAe;AAEb,UAAI,CAAC,2BAA2B,IAAI,GAAG;AACrC,eAAO,MAAM,OAAO;AAAA,MACtB;AAEA,YAAM,SAAS,gBAAgB,IAAI;AACnC,UAAI,WAAW,UAAU;AACvB,eAAO,MAAM,OAAO;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/withDrag.ts"],
4
- "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport type { DragServiceOptions, DragServiceProps } from '../services/drag.js';\nimport { useDrag } from '../services/index.js';\n\nexport type DragDecoratorOptions = DragServiceOptions & {\n target?: (this: Base, instance: Base) => HTMLElement;\n};\n\nexport interface WithDragInterface extends BaseInterface {\n dragged?(props:DragServiceProps):void;\n}\n\n/**\n * Add dragging capabilities to a component.\n */\nexport function withDrag<S extends Base>(\n BaseClass: typeof Base,\n { target = (instance) => instance.$el, ...options }: DragDecoratorOptions = {},\n): BaseDecorator<BaseInterface, S> {\n /**\n * Class.\n */\n class WithDrag<T extends BaseProps = BaseProps> extends BaseClass<T & WithDragInterface> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: `${BaseClass.config.name}WithDrag`,\n emits: ['dragged'],\n };\n\n /**\n * Class constructor.\n */\n constructor(element:HTMLElement) {\n super(element);\n\n this.$on('mounted', () => {\n this.$services.register(\n 'dragged',\n useDrag.bind(undefined, target.call(this, this), options),\n );\n this.$services.enable('dragged');\n });\n\n this.$on('destroyed', () => {\n this.$services.disable('dragged');\n this.$services.unregister('dragged');\n });\n }\n }\n\n // @ts-ignore\n return WithDrag;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAwB;AAajB,SAAS,SACd,WACA,EAAE,SAAS,CAAC,aAAa,SAAS,QAAQ,QAAQ,IAA0B,CAAC,GAC5C;AAIjC,QAAM,iBAAkD,UAAiC;AAAA,IAIvF,OAAO,SAAqB;AAAA,MAC1B,MAAM,GAAG,UAAU,OAAO;AAAA,MAC1B,OAAO,CAAC,SAAS;AAAA,IACnB;AAAA,IAKA,YAAY,SAAqB;AAC/B,YAAM,OAAO;AAEb,WAAK,IAAI,WAAW,MAAM;AACxB,aAAK,UAAU;AAAA,UACb;AAAA,UACA,wBAAQ,KAAK,QAAW,OAAO,KAAK,MAAM,IAAI,GAAG,OAAO;AAAA,QAC1D;AACA,aAAK,UAAU,OAAO,SAAS;AAAA,MACjC,CAAC;AAED,WAAK,IAAI,aAAa,MAAM;AAC1B,aAAK,UAAU,QAAQ,SAAS;AAChC,aAAK,UAAU,WAAW,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport type { DragServiceOptions, DragServiceProps } from '../services/drag.js';\nimport { useDrag } from '../services/index.js';\n\nexport type DragDecoratorOptions = DragServiceOptions & {\n target?: (this: Base, instance: Base) => HTMLElement;\n};\n\nexport interface WithDragInterface extends BaseInterface {\n dragged?(props: DragServiceProps): void;\n}\n\n/**\n * Add dragging capabilities to a component.\n */\nexport function withDrag<S extends Base>(\n BaseClass: typeof Base,\n { target = (instance) => instance.$el, ...options }: DragDecoratorOptions = {},\n): BaseDecorator<BaseInterface, S> {\n /**\n * Class.\n */\n class WithDrag<T extends BaseProps = BaseProps> extends BaseClass<T & WithDragInterface> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: `${BaseClass.config.name}WithDrag`,\n emits: ['dragged'],\n };\n\n /**\n * Class constructor.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n this.$on('mounted', () => {\n this.$services.register(\n 'dragged',\n useDrag.bind(undefined, target.call(this, this), options),\n );\n this.$services.enable('dragged');\n });\n\n this.$on('destroyed', () => {\n this.$services.disable('dragged');\n this.$services.unregister('dragged');\n });\n }\n }\n\n // @ts-ignore\n return WithDrag;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAwB;AAajB,SAAS,SACd,WACA,EAAE,SAAS,CAAC,aAAa,SAAS,QAAQ,QAAQ,IAA0B,CAAC,GAC5C;AAIjC,QAAM,iBAAkD,UAAiC;AAAA,IAIvF,OAAO,SAAqB;AAAA,MAC1B,MAAM,GAAG,UAAU,OAAO;AAAA,MAC1B,OAAO,CAAC,SAAS;AAAA,IACnB;AAAA,IAKA,YAAY,SAAsB;AAChC,YAAM,OAAO;AAEb,WAAK,IAAI,WAAW,MAAM;AACxB,aAAK,UAAU;AAAA,UACb;AAAA,UACA,wBAAQ,KAAK,QAAW,OAAO,KAAK,MAAM,IAAI,GAAG,OAAO;AAAA,QAC1D;AACA,aAAK,UAAU,OAAO,SAAS;AAAA,MACjC,CAAC;AAED,WAAK,IAAI,aAAa,MAAM;AAC1B,aAAK,UAAU,QAAQ,SAAS;AAChC,aAAK,UAAU,WAAW,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import type { BaseDecorator, BaseInterface } from '../Base/types.js';
2
2
  import type { Base } from '../Base/index.js';
3
3
  import type { DragServiceOptions, DragServiceProps } from '../services/drag.js';
4
- export declare type DragDecoratorOptions = DragServiceOptions & {
4
+ export type DragDecoratorOptions = DragServiceOptions & {
5
5
  target?: (this: Base, instance: Base) => HTMLElement;
6
6
  };
7
7
  export interface WithDragInterface extends BaseInterface {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/withDrag.ts"],
4
- "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport type { DragServiceOptions, DragServiceProps } from '../services/drag.js';\nimport { useDrag } from '../services/index.js';\n\nexport type DragDecoratorOptions = DragServiceOptions & {\n target?: (this: Base, instance: Base) => HTMLElement;\n};\n\nexport interface WithDragInterface extends BaseInterface {\n dragged?(props:DragServiceProps):void;\n}\n\n/**\n * Add dragging capabilities to a component.\n */\nexport function withDrag<S extends Base>(\n BaseClass: typeof Base,\n { target = (instance) => instance.$el, ...options }: DragDecoratorOptions = {},\n): BaseDecorator<BaseInterface, S> {\n /**\n * Class.\n */\n class WithDrag<T extends BaseProps = BaseProps> extends BaseClass<T & WithDragInterface> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: `${BaseClass.config.name}WithDrag`,\n emits: ['dragged'],\n };\n\n /**\n * Class constructor.\n */\n constructor(element:HTMLElement) {\n super(element);\n\n this.$on('mounted', () => {\n this.$services.register(\n 'dragged',\n useDrag.bind(undefined, target.call(this, this), options),\n );\n this.$services.enable('dragged');\n });\n\n this.$on('destroyed', () => {\n this.$services.disable('dragged');\n this.$services.unregister('dragged');\n });\n }\n }\n\n // @ts-ignore\n return WithDrag;\n}\n"],
5
- "mappings": "AAGA,SAAS,eAAe;AAajB,SAAS,SACd,WACA,EAAE,SAAS,CAAC,aAAa,SAAS,QAAQ,QAAQ,IAA0B,CAAC,GAC5C;AAIjC,QAAM,iBAAkD,UAAiC;AAAA,IAIvF,OAAO,SAAqB;AAAA,MAC1B,MAAM,GAAG,UAAU,OAAO;AAAA,MAC1B,OAAO,CAAC,SAAS;AAAA,IACnB;AAAA,IAKA,YAAY,SAAqB;AAC/B,YAAM,OAAO;AAEb,WAAK,IAAI,WAAW,MAAM;AACxB,aAAK,UAAU;AAAA,UACb;AAAA,UACA,QAAQ,KAAK,QAAW,OAAO,KAAK,MAAM,IAAI,GAAG,OAAO;AAAA,QAC1D;AACA,aAAK,UAAU,OAAO,SAAS;AAAA,MACjC,CAAC;AAED,WAAK,IAAI,aAAa,MAAM;AAC1B,aAAK,UAAU,QAAQ,SAAS;AAChC,aAAK,UAAU,WAAW,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { BaseDecorator, BaseInterface } from '../Base/types.js';\nimport type { Base, BaseProps, BaseConfig } from '../Base/index.js';\nimport type { DragServiceOptions, DragServiceProps } from '../services/drag.js';\nimport { useDrag } from '../services/index.js';\n\nexport type DragDecoratorOptions = DragServiceOptions & {\n target?: (this: Base, instance: Base) => HTMLElement;\n};\n\nexport interface WithDragInterface extends BaseInterface {\n dragged?(props: DragServiceProps): void;\n}\n\n/**\n * Add dragging capabilities to a component.\n */\nexport function withDrag<S extends Base>(\n BaseClass: typeof Base,\n { target = (instance) => instance.$el, ...options }: DragDecoratorOptions = {},\n): BaseDecorator<BaseInterface, S> {\n /**\n * Class.\n */\n class WithDrag<T extends BaseProps = BaseProps> extends BaseClass<T & WithDragInterface> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: `${BaseClass.config.name}WithDrag`,\n emits: ['dragged'],\n };\n\n /**\n * Class constructor.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n this.$on('mounted', () => {\n this.$services.register(\n 'dragged',\n useDrag.bind(undefined, target.call(this, this), options),\n );\n this.$services.enable('dragged');\n });\n\n this.$on('destroyed', () => {\n this.$services.disable('dragged');\n this.$services.unregister('dragged');\n });\n }\n }\n\n // @ts-ignore\n return WithDrag;\n}\n"],
5
+ "mappings": "AAGA,SAAS,eAAe;AAajB,SAAS,SACd,WACA,EAAE,SAAS,CAAC,aAAa,SAAS,QAAQ,QAAQ,IAA0B,CAAC,GAC5C;AAIjC,QAAM,iBAAkD,UAAiC;AAAA,IAIvF,OAAO,SAAqB;AAAA,MAC1B,MAAM,GAAG,UAAU,OAAO;AAAA,MAC1B,OAAO,CAAC,SAAS;AAAA,IACnB;AAAA,IAKA,YAAY,SAAsB;AAChC,YAAM,OAAO;AAEb,WAAK,IAAI,WAAW,MAAM;AACxB,aAAK,UAAU;AAAA,UACb;AAAA,UACA,QAAQ,KAAK,QAAW,OAAO,KAAK,MAAM,IAAI,GAAG,OAAO;AAAA,QAC1D;AACA,aAAK,UAAU,OAAO,SAAS;AAAA,MACjC,CAAC;AAED,WAAK,IAAI,aAAa,MAAM;AAC1B,aAAK,UAAU,QAAQ,SAAS;AAChC,aAAK,UAAU,WAAW,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }