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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/Base/Base.d.ts +2 -2
  2. package/Base/Base.js +8 -45
  3. package/Base/Base.js.map +2 -2
  4. package/Base/features.d.ts +10 -2
  5. package/Base/features.js +23 -1
  6. package/Base/features.js.map +2 -2
  7. package/Base/managers/AbstractManager.d.ts +3 -3
  8. package/Base/managers/ActionManager.d.ts +4 -0
  9. package/Base/managers/ActionManager.js +10 -0
  10. package/Base/managers/ActionManager.js.map +7 -0
  11. package/Base/managers/ChildrenManager.d.ts +1 -1
  12. package/Base/managers/ServicesManager.d.ts +2 -4
  13. package/Base/managers/ServicesManager.js +2 -3
  14. package/Base/managers/ServicesManager.js.map +2 -2
  15. package/Base/utils.js +1 -1
  16. package/Base/utils.js.map +2 -2
  17. package/decorators/index.d.ts +0 -1
  18. package/decorators/index.js +0 -1
  19. package/decorators/index.js.map +2 -2
  20. package/decorators/withBreakpointObserver.js +1 -1
  21. package/decorators/withBreakpointObserver.js.map +2 -2
  22. package/decorators/withIntersectionObserver.js +1 -1
  23. package/decorators/withIntersectionObserver.js.map +2 -2
  24. package/decorators/withMountOnMediaQuery.js +1 -1
  25. package/decorators/withMountOnMediaQuery.js.map +2 -2
  26. package/decorators/withMountWhenInView.js +1 -1
  27. package/decorators/withMountWhenInView.js.map +2 -2
  28. package/decorators/withScrolledInView/utils.d.ts +12 -1
  29. package/decorators/withScrolledInView/utils.js.map +2 -2
  30. package/decorators/withScrolledInView/withScrolledInView.js +7 -62
  31. package/decorators/withScrolledInView/withScrolledInView.js.map +2 -2
  32. package/helpers/createApp.d.ts +2 -1
  33. package/helpers/createApp.js.map +2 -2
  34. package/package.json +2 -10
  35. package/services/index.d.ts +1 -1
  36. package/services/index.js.map +2 -2
  37. package/services/pointer.d.ts +1 -1
  38. package/services/pointer.js +3 -3
  39. package/services/pointer.js.map +2 -2
  40. package/services/raf.js +2 -4
  41. package/services/raf.js.map +2 -2
  42. package/services/resize.d.ts +7 -6
  43. package/services/resize.js +19 -26
  44. package/services/resize.js.map +2 -2
  45. package/services/scroll.js +8 -8
  46. package/services/scroll.js.map +2 -2
  47. package/utils/SmartQueue.d.ts +1 -1
  48. package/utils/SmartQueue.js +1 -1
  49. package/utils/SmartQueue.js.map +2 -2
  50. package/utils/css/animate.d.ts +33 -15
  51. package/utils/css/animate.js +67 -26
  52. package/utils/css/animate.js.map +2 -2
  53. package/utils/css/getOffsetSizes.js +2 -2
  54. package/utils/css/getOffsetSizes.js.map +1 -1
  55. package/utils/css/index.d.ts +2 -1
  56. package/utils/css/index.js +4 -4
  57. package/utils/css/index.js.map +2 -2
  58. package/utils/css/matrix.d.ts +1 -1
  59. package/utils/css/matrix.js.map +2 -2
  60. package/utils/css/transform.d.ts +1 -1
  61. package/utils/css/transform.js +1 -1
  62. package/utils/css/transform.js.map +2 -2
  63. package/utils/css/utils.d.ts +1 -1
  64. package/utils/css/utils.js +1 -1
  65. package/utils/css/utils.js.map +2 -2
  66. package/utils/index.d.ts +5 -4
  67. package/utils/index.js +16 -16
  68. package/utils/index.js.map +2 -2
  69. package/utils/is.d.ts +12 -0
  70. package/utils/is.js +17 -0
  71. package/utils/is.js.map +2 -2
  72. package/utils/math/ease.d.ts +1 -0
  73. package/utils/math/ease.js +2 -0
  74. package/utils/math/ease.js.map +2 -2
  75. package/utils/math/index.d.ts +4 -3
  76. package/utils/math/index.js +5 -3
  77. package/utils/math/index.js.map +2 -2
  78. package/utils/math/mean.d.ts +1 -0
  79. package/utils/math/mean.js +17 -0
  80. package/utils/math/mean.js.map +7 -0
  81. package/utils/nextFrame.d.ts +4 -22
  82. package/utils/nextFrame.js +3 -10
  83. package/utils/nextFrame.js.map +2 -2
  84. package/utils/nextMicrotask.d.ts +4 -1
  85. package/utils/nextMicrotask.js +3 -3
  86. package/utils/nextMicrotask.js.map +2 -2
  87. package/utils/nextTick.d.ts +4 -1
  88. package/utils/nextTick.js +3 -3
  89. package/utils/nextTick.js.map +2 -2
  90. package/utils/random.d.ts +15 -0
  91. package/utils/random.js +15 -0
  92. package/utils/random.js.map +7 -0
  93. package/utils/scrollTo.d.ts +30 -6
  94. package/utils/scrollTo.js +97 -43
  95. package/utils/scrollTo.js.map +2 -2
  96. package/utils/{focusTrap.d.ts → trapFocus.d.ts} +2 -10
  97. package/utils/{focusTrap.js → trapFocus.js} +5 -9
  98. package/utils/trapFocus.js.map +7 -0
  99. package/utils/tween.d.ts +59 -10
  100. package/utils/tween.js +24 -18
  101. package/utils/tween.js.map +2 -2
  102. package/Base/Base.cjs +0 -420
  103. package/Base/Base.cjs.map +0 -7
  104. package/Base/features.cjs +0 -27
  105. package/Base/features.cjs.map +0 -7
  106. package/Base/index.cjs +0 -21
  107. package/Base/index.cjs.map +0 -7
  108. package/Base/managers/AbstractManager.cjs +0 -78
  109. package/Base/managers/AbstractManager.cjs.map +0 -7
  110. package/Base/managers/ChildrenManager.cjs +0 -156
  111. package/Base/managers/ChildrenManager.cjs.map +0 -7
  112. package/Base/managers/EventsManager.cjs +0 -305
  113. package/Base/managers/EventsManager.cjs.map +0 -7
  114. package/Base/managers/OptionsManager.cjs +0 -198
  115. package/Base/managers/OptionsManager.cjs.map +0 -7
  116. package/Base/managers/RefsManager.cjs +0 -118
  117. package/Base/managers/RefsManager.cjs.map +0 -7
  118. package/Base/managers/ResponsiveOptionsManager.cjs +0 -79
  119. package/Base/managers/ResponsiveOptionsManager.cjs.map +0 -7
  120. package/Base/managers/ServicesManager.cjs +0 -161
  121. package/Base/managers/ServicesManager.cjs.map +0 -7
  122. package/Base/managers/index.cjs +0 -39
  123. package/Base/managers/index.cjs.map +0 -7
  124. package/Base/types.cjs +0 -19
  125. package/Base/types.cjs.map +0 -7
  126. package/Base/utils.cjs +0 -95
  127. package/Base/utils.cjs.map +0 -7
  128. package/decorators/index.cjs +0 -33
  129. package/decorators/index.cjs.map +0 -7
  130. package/decorators/withBreakpointManager.cjs +0 -102
  131. package/decorators/withBreakpointManager.cjs.map +0 -7
  132. package/decorators/withBreakpointObserver.cjs +0 -128
  133. package/decorators/withBreakpointObserver.cjs.map +0 -7
  134. package/decorators/withDrag.cjs +0 -56
  135. package/decorators/withDrag.cjs.map +0 -7
  136. package/decorators/withExtraConfig.cjs +0 -50
  137. package/decorators/withExtraConfig.cjs.map +0 -7
  138. package/decorators/withFreezedOptions.cjs +0 -50
  139. package/decorators/withFreezedOptions.cjs.map +0 -7
  140. package/decorators/withIntersectionObserver.cjs +0 -71
  141. package/decorators/withIntersectionObserver.cjs.map +0 -7
  142. package/decorators/withMountOnMediaQuery.cjs +0 -86
  143. package/decorators/withMountOnMediaQuery.cjs.map +0 -7
  144. package/decorators/withMountWhenInView.cjs +0 -92
  145. package/decorators/withMountWhenInView.cjs.map +0 -7
  146. package/decorators/withMountWhenPrefersMotion.cjs +0 -30
  147. package/decorators/withMountWhenPrefersMotion.cjs.map +0 -7
  148. package/decorators/withRelativePointer.cjs +0 -56
  149. package/decorators/withRelativePointer.cjs.map +0 -7
  150. package/decorators/withResponsiveOptions.cjs +0 -41
  151. package/decorators/withResponsiveOptions.cjs.map +0 -7
  152. package/decorators/withScrolledInView/index.cjs +0 -22
  153. package/decorators/withScrolledInView/index.cjs.map +0 -7
  154. package/decorators/withScrolledInView/types.cjs +0 -19
  155. package/decorators/withScrolledInView/types.cjs.map +0 -7
  156. package/decorators/withScrolledInView/utils.cjs +0 -99
  157. package/decorators/withScrolledInView/utils.cjs.map +0 -7
  158. package/decorators/withScrolledInView/withScrolledInView.cjs +0 -249
  159. package/decorators/withScrolledInView/withScrolledInView.cjs.map +0 -7
  160. package/decorators/withVue2.cjs +0 -68
  161. package/decorators/withVue2.cjs.map +0 -7
  162. package/decorators/withVue2.d.ts +0 -16
  163. package/decorators/withVue2.js +0 -46
  164. package/decorators/withVue2.js.map +0 -7
  165. package/helpers/createApp.cjs +0 -58
  166. package/helpers/createApp.cjs.map +0 -7
  167. package/helpers/getClosestParent.cjs +0 -45
  168. package/helpers/getClosestParent.cjs.map +0 -7
  169. package/helpers/getDirectChildren.cjs +0 -47
  170. package/helpers/getDirectChildren.cjs.map +0 -7
  171. package/helpers/getInstanceFromElement.cjs +0 -32
  172. package/helpers/getInstanceFromElement.cjs.map +0 -7
  173. package/helpers/importOnInteraction.cjs +0 -48
  174. package/helpers/importOnInteraction.cjs.map +0 -7
  175. package/helpers/importOnMediaQuery.cjs +0 -44
  176. package/helpers/importOnMediaQuery.cjs.map +0 -7
  177. package/helpers/importWhenIdle.cjs +0 -46
  178. package/helpers/importWhenIdle.cjs.map +0 -7
  179. package/helpers/importWhenPrefersMotion.cjs +0 -40
  180. package/helpers/importWhenPrefersMotion.cjs.map +0 -7
  181. package/helpers/importWhenVisible.cjs +0 -44
  182. package/helpers/importWhenVisible.cjs.map +0 -7
  183. package/helpers/index.cjs +0 -53
  184. package/helpers/index.cjs.map +0 -7
  185. package/helpers/utils.cjs +0 -37
  186. package/helpers/utils.cjs.map +0 -7
  187. package/index.cjs +0 -31
  188. package/index.cjs.map +0 -7
  189. package/services/drag.cjs +0 -231
  190. package/services/drag.cjs.map +0 -7
  191. package/services/index.cjs +0 -51
  192. package/services/index.cjs.map +0 -7
  193. package/services/key.cjs +0 -97
  194. package/services/key.cjs.map +0 -7
  195. package/services/load.cjs +0 -60
  196. package/services/load.cjs.map +0 -7
  197. package/services/pointer.cjs +0 -145
  198. package/services/pointer.cjs.map +0 -7
  199. package/services/raf.cjs +0 -80
  200. package/services/raf.cjs.map +0 -7
  201. package/services/resize.cjs +0 -107
  202. package/services/resize.cjs.map +0 -7
  203. package/services/scroll.cjs +0 -119
  204. package/services/scroll.cjs.map +0 -7
  205. package/services/service.cjs +0 -69
  206. package/services/service.cjs.map +0 -7
  207. package/utils/Queue.cjs +0 -93
  208. package/utils/Queue.cjs.map +0 -7
  209. package/utils/SmartQueue.cjs +0 -73
  210. package/utils/SmartQueue.cjs.map +0 -7
  211. package/utils/collide/boundingRectToCircle.cjs +0 -36
  212. package/utils/collide/boundingRectToCircle.cjs.map +0 -7
  213. package/utils/collide/collideCircleCircle.cjs +0 -35
  214. package/utils/collide/collideCircleCircle.cjs.map +0 -7
  215. package/utils/collide/collideCircleRect.cjs +0 -47
  216. package/utils/collide/collideCircleRect.cjs.map +0 -7
  217. package/utils/collide/collidePointCircle.cjs +0 -32
  218. package/utils/collide/collidePointCircle.cjs.map +0 -7
  219. package/utils/collide/collidePointRect.cjs +0 -32
  220. package/utils/collide/collidePointRect.cjs.map +0 -7
  221. package/utils/collide/collideRectRect.cjs +0 -32
  222. package/utils/collide/collideRectRect.cjs.map +0 -7
  223. package/utils/collide/index.cjs +0 -47
  224. package/utils/collide/index.cjs.map +0 -7
  225. package/utils/css/animate.cjs +0 -202
  226. package/utils/css/animate.cjs.map +0 -7
  227. package/utils/css/classes.cjs +0 -51
  228. package/utils/css/classes.cjs.map +0 -7
  229. package/utils/css/getOffsetSizes.cjs +0 -48
  230. package/utils/css/getOffsetSizes.cjs.map +0 -7
  231. package/utils/css/index.cjs +0 -52
  232. package/utils/css/index.cjs.map +0 -7
  233. package/utils/css/matrix.cjs +0 -30
  234. package/utils/css/matrix.cjs.map +0 -7
  235. package/utils/css/styles.cjs +0 -45
  236. package/utils/css/styles.cjs.map +0 -7
  237. package/utils/css/transform.cjs +0 -91
  238. package/utils/css/transform.cjs.map +0 -7
  239. package/utils/css/transition.cjs +0 -145
  240. package/utils/css/transition.cjs.map +0 -7
  241. package/utils/css/utils.cjs +0 -32
  242. package/utils/css/utils.cjs.map +0 -7
  243. package/utils/debounce.cjs +0 -35
  244. package/utils/debounce.cjs.map +0 -7
  245. package/utils/dom/ancestors.cjs +0 -37
  246. package/utils/dom/ancestors.cjs.map +0 -7
  247. package/utils/dom/index.cjs +0 -21
  248. package/utils/dom/index.cjs.map +0 -7
  249. package/utils/focusTrap.cjs +0 -93
  250. package/utils/focusTrap.cjs.map +0 -7
  251. package/utils/focusTrap.js.map +0 -7
  252. package/utils/getComponentResolver.cjs +0 -38
  253. package/utils/getComponentResolver.cjs.map +0 -7
  254. package/utils/has.cjs +0 -29
  255. package/utils/has.cjs.map +0 -7
  256. package/utils/history.cjs +0 -92
  257. package/utils/history.cjs.map +0 -7
  258. package/utils/index.cjs +0 -76
  259. package/utils/index.cjs.map +0 -7
  260. package/utils/is.cjs +0 -41
  261. package/utils/is.cjs.map +0 -7
  262. package/utils/keyCodes.cjs +0 -36
  263. package/utils/keyCodes.cjs.map +0 -7
  264. package/utils/math/clamp.cjs +0 -29
  265. package/utils/math/clamp.cjs.map +0 -7
  266. package/utils/math/clamp01.cjs +0 -40
  267. package/utils/math/clamp01.cjs.map +0 -7
  268. package/utils/math/createEases.cjs +0 -33
  269. package/utils/math/createEases.cjs.map +0 -7
  270. package/utils/math/damp.cjs +0 -29
  271. package/utils/math/damp.cjs.map +0 -7
  272. package/utils/math/ease.cjs +0 -82
  273. package/utils/math/ease.cjs.map +0 -7
  274. package/utils/math/index.cjs +0 -54
  275. package/utils/math/index.cjs.map +0 -7
  276. package/utils/math/inertiaFinalValue.cjs +0 -47
  277. package/utils/math/inertiaFinalValue.cjs.map +0 -7
  278. package/utils/math/lerp.cjs +0 -29
  279. package/utils/math/lerp.cjs.map +0 -7
  280. package/utils/math/map.cjs +0 -29
  281. package/utils/math/map.cjs.map +0 -7
  282. package/utils/math/round.cjs +0 -29
  283. package/utils/math/round.cjs.map +0 -7
  284. package/utils/memoize.cjs +0 -48
  285. package/utils/memoize.cjs.map +0 -7
  286. package/utils/nextFrame.cjs +0 -41
  287. package/utils/nextFrame.cjs.map +0 -7
  288. package/utils/nextMicrotask.cjs +0 -30
  289. package/utils/nextMicrotask.cjs.map +0 -7
  290. package/utils/nextTick.cjs +0 -31
  291. package/utils/nextTick.cjs.map +0 -7
  292. package/utils/noop.cjs +0 -32
  293. package/utils/noop.cjs.map +0 -7
  294. package/utils/object/autoBind.cjs +0 -60
  295. package/utils/object/autoBind.cjs.map +0 -7
  296. package/utils/object/autoBind.d.ts +0 -14
  297. package/utils/object/autoBind.js +0 -28
  298. package/utils/object/autoBind.js.map +0 -7
  299. package/utils/object/getAllProperties.cjs +0 -39
  300. package/utils/object/getAllProperties.cjs.map +0 -7
  301. package/utils/object/index.cjs +0 -39
  302. package/utils/object/index.cjs.map +0 -7
  303. package/utils/object/index.d.ts +0 -2
  304. package/utils/object/index.js +0 -7
  305. package/utils/object/index.js.map +0 -7
  306. package/utils/scheduler.cjs +0 -75
  307. package/utils/scheduler.cjs.map +0 -7
  308. package/utils/scrollTo.cjs +0 -88
  309. package/utils/scrollTo.cjs.map +0 -7
  310. package/utils/string/endsWith.cjs +0 -35
  311. package/utils/string/endsWith.cjs.map +0 -7
  312. package/utils/string/index.cjs +0 -58
  313. package/utils/string/index.cjs.map +0 -7
  314. package/utils/string/startsWith.cjs +0 -35
  315. package/utils/string/startsWith.cjs.map +0 -7
  316. package/utils/string/withLeadingCharacters.cjs +0 -40
  317. package/utils/string/withLeadingCharacters.cjs.map +0 -7
  318. package/utils/string/withLeadingSlash.cjs +0 -40
  319. package/utils/string/withLeadingSlash.cjs.map +0 -7
  320. package/utils/string/withTrailingCharacters.cjs +0 -40
  321. package/utils/string/withTrailingCharacters.cjs.map +0 -7
  322. package/utils/string/withTrailingSlash.cjs +0 -40
  323. package/utils/string/withTrailingSlash.cjs.map +0 -7
  324. package/utils/string/withoutLeadingCharacters.cjs +0 -29
  325. package/utils/string/withoutLeadingCharacters.cjs.map +0 -7
  326. package/utils/string/withoutLeadingCharactersRecursive.cjs +0 -45
  327. package/utils/string/withoutLeadingCharactersRecursive.cjs.map +0 -7
  328. package/utils/string/withoutLeadingSlash.cjs +0 -40
  329. package/utils/string/withoutLeadingSlash.cjs.map +0 -7
  330. package/utils/string/withoutTrailingCharacters.cjs +0 -29
  331. package/utils/string/withoutTrailingCharacters.cjs.map +0 -7
  332. package/utils/string/withoutTrailingCharactersRecursive.cjs +0 -45
  333. package/utils/string/withoutTrailingCharactersRecursive.cjs.map +0 -7
  334. package/utils/string/withoutTrailingSlash.cjs +0 -40
  335. package/utils/string/withoutTrailingSlash.cjs.map +0 -7
  336. package/utils/throttle.cjs +0 -37
  337. package/utils/throttle.cjs.map +0 -7
  338. package/utils/tween.cjs +0 -122
  339. package/utils/tween.cjs.map +0 -7
  340. package/utils/wait.cjs +0 -31
  341. package/utils/wait.cjs.map +0 -7
@@ -1,60 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // packages/js-toolkit/utils/object/autoBind.ts
30
- var autoBind_exports = {};
31
- __export(autoBind_exports, {
32
- default: () => autoBind
33
- });
34
- module.exports = __toCommonJS(autoBind_exports);
35
- var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
36
- var import_is = require("../is.cjs");
37
- function autoBind(instance, options) {
38
- const { exclude, include } = options || {};
39
- const filter = (key) => {
40
- const match = (pattern) => (0, import_is.isString)(pattern) ? key === pattern : pattern.test(key);
41
- if (include) {
42
- return include.some(match);
43
- }
44
- if (exclude) {
45
- return !exclude.some(match);
46
- }
47
- return true;
48
- };
49
- for (const [key, object] of (0, import_getAllProperties.default)(instance)) {
50
- if (key !== "constructor" && filter(key)) {
51
- const descriptor = Object.getOwnPropertyDescriptor(object, key);
52
- if (descriptor && (0, import_is.isFunction)(descriptor.value)) {
53
- instance[key] = instance[key].bind(instance);
54
- }
55
- }
56
- }
57
- return instance;
58
- }
59
- if (module.exports.default) module.exports = module.exports.default;
60
- //# sourceMappingURL=autoBind.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/object/autoBind.ts"],
4
- "sourcesContent": ["import getAllProperties from './getAllProperties.js';\nimport { isString, isFunction } from '../is.js';\n\nexport interface AutoBindOptions {\n include?: Array<string | RegExp>;\n exclude?: Array<string | RegExp>;\n}\n\n/**\n * Auto-bind methods to an instance.\n *\n * @param {Object} instance The instance.\n * @param {Object} options Define specific methods to include or exlude.\n * @param {Array<string | RegExp>} [options.include] Methods to include.\n * @param {Array<string | RegExp>} [options.exclude] Methods to exclude.\n * @returns {Object} The instance.\n */\nexport default function autoBind<T>(instance: T, options: AutoBindOptions): T {\n const { exclude, include } = options || {};\n const filter = (key) => {\n const match = (pattern) => (isString(pattern) ? key === pattern : pattern.test(key));\n\n if (include) {\n return include.some(match);\n }\n\n if (exclude) {\n return !exclude.some(match);\n }\n\n return true;\n };\n\n for (const [key, object] of getAllProperties(instance)) {\n if (key !== 'constructor' && filter(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(object, key);\n if (descriptor && isFunction(descriptor.value)) {\n instance[key] = instance[key].bind(instance);\n }\n }\n }\n\n return instance;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6B;AAC7B,gBAAqC;AAgBtB,SAAR,SAA6B,UAAa,SAA6B;AAC5E,QAAM,EAAE,SAAS,QAAQ,IAAI,WAAW,CAAC;AACzC,QAAM,SAAS,CAAC,QAAQ;AACtB,UAAM,QAAQ,CAAC,gBAAa,oBAAS,OAAO,IAAI,QAAQ,UAAU,QAAQ,KAAK,GAAG;AAElF,QAAI,SAAS;AACX,aAAO,QAAQ,KAAK,KAAK;AAAA,IAC3B;AAEA,QAAI,SAAS;AACX,aAAO,CAAC,QAAQ,KAAK,KAAK;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,MAAM,SAAK,wBAAAA,SAAiB,QAAQ,GAAG;AACtD,QAAI,QAAQ,iBAAiB,OAAO,GAAG,GAAG;AACxC,YAAM,aAAa,OAAO,yBAAyB,QAAQ,GAAG;AAC9D,UAAI,kBAAc,sBAAW,WAAW,KAAK,GAAG;AAC9C,iBAAS,GAAG,IAAI,SAAS,GAAG,EAAE,KAAK,QAAQ;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": ["getAllProperties"]
7
- }
@@ -1,14 +0,0 @@
1
- export interface AutoBindOptions {
2
- include?: Array<string | RegExp>;
3
- exclude?: Array<string | RegExp>;
4
- }
5
- /**
6
- * Auto-bind methods to an instance.
7
- *
8
- * @param {Object} instance The instance.
9
- * @param {Object} options Define specific methods to include or exlude.
10
- * @param {Array<string | RegExp>} [options.include] Methods to include.
11
- * @param {Array<string | RegExp>} [options.exclude] Methods to exclude.
12
- * @returns {Object} The instance.
13
- */
14
- export default function autoBind<T>(instance: T, options: AutoBindOptions): T;
@@ -1,28 +0,0 @@
1
- import getAllProperties from "./getAllProperties.js";
2
- import { isString, isFunction } from "../is.js";
3
- function autoBind(instance, options) {
4
- const { exclude, include } = options || {};
5
- const filter = (key) => {
6
- const match = (pattern) => isString(pattern) ? key === pattern : pattern.test(key);
7
- if (include) {
8
- return include.some(match);
9
- }
10
- if (exclude) {
11
- return !exclude.some(match);
12
- }
13
- return true;
14
- };
15
- for (const [key, object] of getAllProperties(instance)) {
16
- if (key !== "constructor" && filter(key)) {
17
- const descriptor = Object.getOwnPropertyDescriptor(object, key);
18
- if (descriptor && isFunction(descriptor.value)) {
19
- instance[key] = instance[key].bind(instance);
20
- }
21
- }
22
- }
23
- return instance;
24
- }
25
- export {
26
- autoBind as default
27
- };
28
- //# sourceMappingURL=autoBind.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/object/autoBind.ts"],
4
- "sourcesContent": ["import getAllProperties from './getAllProperties.js';\nimport { isString, isFunction } from '../is.js';\n\nexport interface AutoBindOptions {\n include?: Array<string | RegExp>;\n exclude?: Array<string | RegExp>;\n}\n\n/**\n * Auto-bind methods to an instance.\n *\n * @param {Object} instance The instance.\n * @param {Object} options Define specific methods to include or exlude.\n * @param {Array<string | RegExp>} [options.include] Methods to include.\n * @param {Array<string | RegExp>} [options.exclude] Methods to exclude.\n * @returns {Object} The instance.\n */\nexport default function autoBind<T>(instance: T, options: AutoBindOptions): T {\n const { exclude, include } = options || {};\n const filter = (key) => {\n const match = (pattern) => (isString(pattern) ? key === pattern : pattern.test(key));\n\n if (include) {\n return include.some(match);\n }\n\n if (exclude) {\n return !exclude.some(match);\n }\n\n return true;\n };\n\n for (const [key, object] of getAllProperties(instance)) {\n if (key !== 'constructor' && filter(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(object, key);\n if (descriptor && isFunction(descriptor.value)) {\n instance[key] = instance[key].bind(instance);\n }\n }\n }\n\n return instance;\n}\n"],
5
- "mappings": "AAAA,OAAO,sBAAsB;AAC7B,SAAS,UAAU,kBAAkB;AAgBtB,SAAR,SAA6B,UAAa,SAA6B;AAC5E,QAAM,EAAE,SAAS,QAAQ,IAAI,WAAW,CAAC;AACzC,QAAM,SAAS,CAAC,QAAQ;AACtB,UAAM,QAAQ,CAAC,YAAa,SAAS,OAAO,IAAI,QAAQ,UAAU,QAAQ,KAAK,GAAG;AAElF,QAAI,SAAS;AACX,aAAO,QAAQ,KAAK,KAAK;AAAA,IAC3B;AAEA,QAAI,SAAS;AACX,aAAO,CAAC,QAAQ,KAAK,KAAK;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,MAAM,KAAK,iBAAiB,QAAQ,GAAG;AACtD,QAAI,QAAQ,iBAAiB,OAAO,GAAG,GAAG;AACxC,YAAM,aAAa,OAAO,yBAAyB,QAAQ,GAAG;AAC9D,UAAI,cAAc,WAAW,WAAW,KAAK,GAAG;AAC9C,iBAAS,GAAG,IAAI,SAAS,GAAG,EAAE,KAAK,QAAQ;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,39 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/object/getAllProperties.ts
20
- var getAllProperties_exports = {};
21
- __export(getAllProperties_exports, {
22
- default: () => getAllProperties
23
- });
24
- module.exports = __toCommonJS(getAllProperties_exports);
25
- var import_is = require("../is.cjs");
26
- function getAllProperties(object, props = [], testFn = null) {
27
- const proto = Object.getPrototypeOf(object);
28
- if (proto === Object.prototype || proto === null) {
29
- return props;
30
- }
31
- let foundProps = Object.getOwnPropertyNames(proto);
32
- if ((0, import_is.isFunction)(testFn)) {
33
- foundProps = foundProps.filter((name) => testFn(name, proto));
34
- }
35
- const formatedProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
36
- return getAllProperties(proto, formatedProps, testFn);
37
- }
38
- if (module.exports.default) module.exports = module.exports.default;
39
- //# sourceMappingURL=getAllProperties.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/object/getAllProperties.ts"],
4
- "sourcesContent": ["import { isFunction } from '../is.js';\n\n/**\n * Gets all non-builtin properties up the prototype chain.\n *\n * @param {Object} object\n * The object to get the propeties from.\n * @param {Array} [props=[]]\n * The already existing properties.\n * @param {(name:string, proto:any) => boolean} testFn\n * @returns {Array<[string, Object]>} An array of properties and the prototype they belong to.\n */\nexport default function getAllProperties(\n object: unknown,\n props: Array<[string, unknown]> = [],\n testFn: (name: string, proto: unknown) => boolean = null,\n): Array<[string, unknown]> {\n const proto = Object.getPrototypeOf(object);\n\n if (proto === Object.prototype || proto === null) {\n return props;\n }\n\n let foundProps = Object.getOwnPropertyNames(proto);\n\n if (isFunction(testFn)) {\n foundProps = foundProps.filter((name) => testFn(name, proto));\n }\n\n const formatedProps = foundProps\n .map<[string, unknown]>((name) => [name, proto])\n .reduce<Array<[string, unknown]>>((acc, val) => [...acc, val], props);\n\n return getAllProperties(proto, formatedProps, testFn);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAYZ,SAAR,iBACL,QACA,QAAkC,CAAC,GACnC,SAAoD,MAC1B;AAC1B,QAAM,QAAQ,OAAO,eAAe,MAAM;AAE1C,MAAI,UAAU,OAAO,aAAa,UAAU,MAAM;AAChD,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,OAAO,oBAAoB,KAAK;AAEjD,UAAI,sBAAW,MAAM,GAAG;AACtB,iBAAa,WAAW,OAAO,CAAC,SAAS,OAAO,MAAM,KAAK,CAAC;AAAA,EAC9D;AAEA,QAAM,gBAAgB,WACnB,IAAuB,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAC9C,OAAiC,CAAC,KAAK,QAAQ,CAAC,GAAG,KAAK,GAAG,GAAG,KAAK;AAEtE,SAAO,iBAAiB,OAAO,eAAe,MAAM;AACtD;",
6
- "names": []
7
- }
@@ -1,39 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // packages/js-toolkit/utils/object/index.ts
30
- var object_exports = {};
31
- __export(object_exports, {
32
- autoBind: () => import_autoBind.default,
33
- getAllProperties: () => import_getAllProperties.default
34
- });
35
- module.exports = __toCommonJS(object_exports);
36
- var import_autoBind = __toESM(require("./autoBind.cjs"), 1);
37
- var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
38
- if (module.exports.default) module.exports = module.exports.default;
39
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/object/index.ts"],
4
- "sourcesContent": ["export { default as autoBind } from './autoBind.js';\nexport { default as getAllProperties } from './getAllProperties.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoC;AACpC,8BAA4C;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- export { default as autoBind } from './autoBind.js';
2
- export { default as getAllProperties } from './getAllProperties.js';
@@ -1,7 +0,0 @@
1
- import { default as default2 } from "./autoBind.js";
2
- import { default as default3 } from "./getAllProperties.js";
3
- export {
4
- default2 as autoBind,
5
- default3 as getAllProperties
6
- };
7
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/object/index.ts"],
4
- "sourcesContent": ["export { default as autoBind } from './autoBind.js';\nexport { default as getAllProperties } from './getAllProperties.js';\n"],
5
- "mappings": "AAAA,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAmC;",
6
- "names": ["default"]
7
- }
@@ -1,75 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/scheduler.ts
20
- var scheduler_exports = {};
21
- __export(scheduler_exports, {
22
- domScheduler: () => domScheduler,
23
- useScheduler: () => useScheduler
24
- });
25
- module.exports = __toCommonJS(scheduler_exports);
26
- function getScheduler(steps) {
27
- const stepsFns = {};
28
- const api = {};
29
- let isScheduled = false;
30
- const resolvedPromise = Promise.resolve();
31
- function run(tasks) {
32
- let task;
33
- while (task = tasks.shift()) {
34
- task();
35
- }
36
- }
37
- function flush() {
38
- for (const step of steps) {
39
- run(stepsFns[step]);
40
- }
41
- isScheduled = false;
42
- if (steps.reduce((length, step) => length + stepsFns[step].length, 0) > 0) {
43
- scheduleFlush();
44
- }
45
- }
46
- function scheduleFlush() {
47
- if (isScheduled) {
48
- return;
49
- }
50
- isScheduled = true;
51
- resolvedPromise.then(flush);
52
- }
53
- for (const step of steps) {
54
- stepsFns[step] = [];
55
- api[step] = function add(fn) {
56
- stepsFns[step].push(fn);
57
- scheduleFlush();
58
- };
59
- }
60
- return api;
61
- }
62
- var instances = /* @__PURE__ */ new Map();
63
- var domSchedulerSteps = ["read", "write", "afterWrite"];
64
- function useScheduler(steps = domSchedulerSteps) {
65
- const key = steps.join("-");
66
- if (instances.has(key)) {
67
- return instances.get(key);
68
- }
69
- const scheduler = getScheduler(steps);
70
- instances.set(key, scheduler);
71
- return scheduler;
72
- }
73
- var domScheduler = useScheduler(domSchedulerSteps);
74
- if (module.exports.default) module.exports = module.exports.default;
75
- //# sourceMappingURL=scheduler.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/utils/scheduler.ts"],
4
- "sourcesContent": ["/**\n * Generate a scheduler.\n */\nfunction getScheduler<T extends string>(steps: T[]): Record<T, (fn: () => unknown) => void> {\n const stepsFns = {} as Record<T, Array<() => void>>;\n const api = {} as Record<T, (fn: () => void) => void>;\n\n let isScheduled = false;\n\n const resolvedPromise = Promise.resolve();\n\n /**\n * Execute the given list of tasks.\n */\n function run(tasks: Array<() => void>) {\n let task;\n // eslint-disable-next-line no-cond-assign\n while ((task = tasks.shift())) {\n task();\n }\n }\n\n /**\n * Flush registered tasks and schedule the next run if needed.\n */\n function flush() {\n for (const step of steps) {\n run(stepsFns[step]);\n }\n isScheduled = false;\n\n if (steps.reduce((length, step) => length + stepsFns[step].length, 0) > 0) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define, no-use-before-define\n scheduleFlush();\n }\n }\n\n /**\n * Schedule the next flush of tasks.\n */\n function scheduleFlush() {\n if (isScheduled) {\n return;\n }\n\n isScheduled = true;\n resolvedPromise.then(flush);\n }\n\n for (const step of steps) {\n stepsFns[step] = [];\n api[step] = function add(fn) {\n stepsFns[step].push(fn);\n scheduleFlush();\n };\n }\n\n return api;\n}\n\nconst instances = new Map();\n\nconst domSchedulerSteps = ['read', 'write', 'afterWrite'];\n\n/**\n * Use a scheduler based on the given steps.\n */\nexport function useScheduler<T extends string>(\n steps: T[] = domSchedulerSteps as T[],\n): ReturnType<typeof getScheduler<T>> {\n const key = steps.join('-');\n\n if (instances.has(key)) {\n return instances.get(key);\n }\n\n const scheduler = getScheduler(steps);\n instances.set(key, scheduler);\n\n return scheduler;\n}\n\nexport const domScheduler = useScheduler(domSchedulerSteps as ['read', 'write', 'afterWrite']);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAS,aAA+B,OAAoD;AAC1F,QAAM,WAAW,CAAC;AAClB,QAAM,MAAM,CAAC;AAEb,MAAI,cAAc;AAElB,QAAM,kBAAkB,QAAQ,QAAQ;AAKxC,WAAS,IAAI,OAA0B;AACrC,QAAI;AAEJ,WAAQ,OAAO,MAAM,MAAM,GAAI;AAC7B,WAAK;AAAA,IACP;AAAA,EACF;AAKA,WAAS,QAAQ;AACf,eAAW,QAAQ,OAAO;AACxB,UAAI,SAAS,IAAI,CAAC;AAAA,IACpB;AACA,kBAAc;AAEd,QAAI,MAAM,OAAO,CAAC,QAAQ,SAAS,SAAS,SAAS,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG;AAEzE,oBAAc;AAAA,IAChB;AAAA,EACF;AAKA,WAAS,gBAAgB;AACvB,QAAI,aAAa;AACf;AAAA,IACF;AAEA,kBAAc;AACd,oBAAgB,KAAK,KAAK;AAAA,EAC5B;AAEA,aAAW,QAAQ,OAAO;AACxB,aAAS,IAAI,IAAI,CAAC;AAClB,QAAI,IAAI,IAAI,SAAS,IAAI,IAAI;AAC3B,eAAS,IAAI,EAAE,KAAK,EAAE;AACtB,oBAAc;AAAA,IAChB;AAAA,EACF;AAEA,SAAO;AACT;AAEA,IAAM,YAAY,oBAAI,IAAI;AAE1B,IAAM,oBAAoB,CAAC,QAAQ,SAAS,YAAY;AAKjD,SAAS,aACd,QAAa,mBACuB;AACpC,QAAM,MAAM,MAAM,KAAK,GAAG;AAE1B,MAAI,UAAU,IAAI,GAAG,GAAG;AACtB,WAAO,UAAU,IAAI,GAAG;AAAA,EAC1B;AAEA,QAAM,YAAY,aAAa,KAAK;AACpC,YAAU,IAAI,KAAK,SAAS;AAE5B,SAAO;AACT;AAEO,IAAM,eAAe,aAAa,iBAAoD;",
6
- "names": []
7
- }
@@ -1,88 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // packages/js-toolkit/utils/scrollTo.ts
30
- var scrollTo_exports = {};
31
- __export(scrollTo_exports, {
32
- default: () => scrollTo
33
- });
34
- module.exports = __toCommonJS(scrollTo_exports);
35
- var import_damp = __toESM(require("./math/damp.cjs"), 1);
36
- function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
37
- let targetElement = null;
38
- if (selectorElement instanceof HTMLElement) {
39
- targetElement = selectorElement;
40
- } else {
41
- targetElement = document.querySelector(selectorElement);
42
- }
43
- if (!targetElement) {
44
- return Promise.resolve(window.pageYOffset);
45
- }
46
- const sizes = targetElement.getBoundingClientRect();
47
- const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
48
- const max = document.documentElement.scrollHeight - window.innerHeight;
49
- let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;
50
- if (scrollTarget > max) {
51
- scrollTarget = max;
52
- }
53
- return new Promise((resolve) => {
54
- let isScrolling = false;
55
- let scroll = window.pageYOffset;
56
- let dampScroll = window.pageYOffset;
57
- function eventHandler() {
58
- isScrolling = false;
59
- }
60
- function end() {
61
- window.removeEventListener("wheel", eventHandler);
62
- window.removeEventListener("touchmove", eventHandler);
63
- resolve(window.pageYOffset);
64
- }
65
- function loop() {
66
- if (!isScrolling) {
67
- return end();
68
- }
69
- dampScroll = (0, import_damp.default)(scroll, dampScroll, dampFactor);
70
- window.scrollTo({ top: dampScroll });
71
- if (dampScroll === scroll) {
72
- isScrolling = false;
73
- }
74
- return requestAnimationFrame(loop);
75
- }
76
- function start(target) {
77
- isScrolling = true;
78
- dampScroll = window.pageYOffset;
79
- scroll = target;
80
- window.addEventListener("wheel", eventHandler, { passive: true });
81
- window.addEventListener("touchmove", eventHandler, { passive: true });
82
- loop();
83
- }
84
- start(scrollTarget);
85
- });
86
- }
87
- if (module.exports.default) module.exports = module.exports.default;
88
- //# sourceMappingURL=scrollTo.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../packages/js-toolkit/utils/scrollTo.ts"],
4
- "sourcesContent": ["import damp from './math/damp.js';\n\n/**\n * Handler for the click event on anchor links\n *\n * @returns {Promise<number>} A promising resolving with the target scroll position.\n */\nexport default function scrollTo(\n selectorElement: HTMLElement | string,\n { offset = 0, dampFactor = 0.2 } = {},\n): Promise<number> {\n let targetElement = null;\n\n if (selectorElement instanceof HTMLElement) {\n targetElement = selectorElement;\n } else {\n targetElement = document.querySelector(selectorElement);\n }\n\n if (!targetElement) {\n return Promise.resolve(window.pageYOffset);\n }\n\n const sizes = targetElement.getBoundingClientRect();\n const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || '0';\n const max = document.documentElement.scrollHeight - window.innerHeight;\n let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;\n\n // Make sure to not scroll more than the max scroll allowed\n if (scrollTarget > max) {\n scrollTarget = max;\n }\n\n return new Promise((resolve) => {\n let isScrolling = false;\n let scroll = window.pageYOffset;\n let dampScroll = window.pageYOffset;\n\n /**\n * Handler for the wheel event\n * Is used to cancel the programmatic scroll animation\n */\n function eventHandler() {\n isScrolling = false;\n }\n\n /**\n * Scroll animation end's hook\n */\n function end() {\n window.removeEventListener('wheel', eventHandler);\n window.removeEventListener('touchmove', eventHandler);\n resolve(window.pageYOffset);\n }\n\n /**\n * Scroll animation's loop\n *\n * @returns {void|number}\n */\n function loop() {\n if (!isScrolling) {\n return end();\n }\n\n dampScroll = damp(scroll, dampScroll, dampFactor);\n window.scrollTo({ top: dampScroll });\n\n if (dampScroll === scroll) {\n isScrolling = false;\n }\n\n return requestAnimationFrame(loop);\n }\n\n /**\n * Start the scroll animation\n *\n * @param {number} target The target scroll\n */\n function start(target) {\n // Update vars\n isScrolling = true;\n dampScroll = window.pageYOffset;\n scroll = target;\n\n // Bind wheel event to stop the animation if\n // the user wants to scroll manually\n window.addEventListener('wheel', eventHandler, { passive: true });\n window.addEventListener('touchmove', eventHandler, { passive: true });\n\n // Init the loop\n loop();\n }\n\n // Start the scroll\n start(scrollTarget);\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAOF,SAAR,SACL,iBACA,EAAE,SAAS,GAAG,aAAa,IAAI,IAAI,CAAC,GACnB;AACjB,MAAI,gBAAgB;AAEpB,MAAI,2BAA2B,aAAa;AAC1C,oBAAgB;AAAA,EAClB,OAAO;AACL,oBAAgB,SAAS,cAAc,eAAe;AAAA,EACxD;AAEA,MAAI,CAAC,eAAe;AAClB,WAAO,QAAQ,QAAQ,OAAO,WAAW;AAAA,EAC3C;AAEA,QAAM,QAAQ,cAAc,sBAAsB;AAClD,QAAM,eAAe,iBAAiB,aAAa,EAAE,mBAAmB;AACxE,QAAM,MAAM,SAAS,gBAAgB,eAAe,OAAO;AAC3D,MAAI,eAAe,MAAM,MAAM,OAAO,cAAc,OAAO,SAAS,cAAc,EAAE,IAAI;AAGxF,MAAI,eAAe,KAAK;AACtB,mBAAe;AAAA,EACjB;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI,cAAc;AAClB,QAAI,SAAS,OAAO;AACpB,QAAI,aAAa,OAAO;AAMxB,aAAS,eAAe;AACtB,oBAAc;AAAA,IAChB;AAKA,aAAS,MAAM;AACb,aAAO,oBAAoB,SAAS,YAAY;AAChD,aAAO,oBAAoB,aAAa,YAAY;AACpD,cAAQ,OAAO,WAAW;AAAA,IAC5B;AAOA,aAAS,OAAO;AACd,UAAI,CAAC,aAAa;AAChB,eAAO,IAAI;AAAA,MACb;AAEA,uBAAa,YAAAA,SAAK,QAAQ,YAAY,UAAU;AAChD,aAAO,SAAS,EAAE,KAAK,WAAW,CAAC;AAEnC,UAAI,eAAe,QAAQ;AACzB,sBAAc;AAAA,MAChB;AAEA,aAAO,sBAAsB,IAAI;AAAA,IACnC;AAOA,aAAS,MAAM,QAAQ;AAErB,oBAAc;AACd,mBAAa,OAAO;AACpB,eAAS;AAIT,aAAO,iBAAiB,SAAS,cAAc,EAAE,SAAS,KAAK,CAAC;AAChE,aAAO,iBAAiB,aAAa,cAAc,EAAE,SAAS,KAAK,CAAC;AAGpE,WAAK;AAAA,IACP;AAGA,UAAM,YAAY;AAAA,EACpB,CAAC;AACH;",
6
- "names": ["damp"]
7
- }
@@ -1,35 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/string/endsWith.ts
20
- var endsWith_exports = {};
21
- __export(endsWith_exports, {
22
- endsWith: () => endsWith
23
- });
24
- module.exports = __toCommonJS(endsWith_exports);
25
- function endsWith(string, search) {
26
- if (search.length === 0) {
27
- return true;
28
- }
29
- if (search.length === 1) {
30
- return string[string.length - 1] === search;
31
- }
32
- return string.substring(string.length - search.length) === search;
33
- }
34
- if (module.exports.default) module.exports = module.exports.default;
35
- //# sourceMappingURL=endsWith.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/string/endsWith.ts"],
4
- "sourcesContent": ["/**\n * Test if a string starts with another string.\n *\n * This is a more performant version of the `String.prototype.endsWith` method.\n *\n * @see https://jsbench.me/1hlkqqd0ff/2\n */\nexport function endsWith(string: string, search: string): boolean {\n if (search.length === 0) {\n return true;\n }\n\n if (search.length === 1) {\n // eslint-disable-next-line unicorn/prefer-at\n return string[string.length - 1] === search;\n }\n\n // eslint-disable-next-line unicorn/prefer-string-slice\n return string.substring(string.length - search.length) === search;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,SAAS,QAAgB,QAAyB;AAChE,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,GAAG;AAEvB,WAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAAA,EACvC;AAGA,SAAO,OAAO,UAAU,OAAO,SAAS,OAAO,MAAM,MAAM;AAC7D;",
6
- "names": []
7
- }
@@ -1,58 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/js-toolkit/utils/string/index.ts
31
- var string_exports = {};
32
- __export(string_exports, {
33
- withLeadingCharacters: () => import_withLeadingCharacters.default,
34
- withLeadingSlash: () => import_withLeadingSlash.default,
35
- withTrailingCharacters: () => import_withTrailingCharacters.default,
36
- withTrailingSlash: () => import_withTrailingSlash.default,
37
- withoutLeadingCharacters: () => import_withoutLeadingCharacters.default,
38
- withoutLeadingCharactersRecursive: () => import_withoutLeadingCharactersRecursive.default,
39
- withoutLeadingSlash: () => import_withoutLeadingSlash.default,
40
- withoutTrailingCharacters: () => import_withoutTrailingCharacters.default,
41
- withoutTrailingCharactersRecursive: () => import_withoutTrailingCharactersRecursive.default,
42
- withoutTrailingSlash: () => import_withoutTrailingSlash.default
43
- });
44
- module.exports = __toCommonJS(string_exports);
45
- var import_withLeadingCharacters = __toESM(require("./withLeadingCharacters.cjs"), 1);
46
- var import_withLeadingSlash = __toESM(require("./withLeadingSlash.cjs"), 1);
47
- var import_withoutLeadingCharacters = __toESM(require("./withoutLeadingCharacters.cjs"), 1);
48
- var import_withoutLeadingCharactersRecursive = __toESM(require("./withoutLeadingCharactersRecursive.cjs"), 1);
49
- var import_withoutLeadingSlash = __toESM(require("./withoutLeadingSlash.cjs"), 1);
50
- var import_withoutTrailingCharacters = __toESM(require("./withoutTrailingCharacters.cjs"), 1);
51
- var import_withoutTrailingCharactersRecursive = __toESM(require("./withoutTrailingCharactersRecursive.cjs"), 1);
52
- var import_withoutTrailingSlash = __toESM(require("./withoutTrailingSlash.cjs"), 1);
53
- var import_withTrailingCharacters = __toESM(require("./withTrailingCharacters.cjs"), 1);
54
- var import_withTrailingSlash = __toESM(require("./withTrailingSlash.cjs"), 1);
55
- __reExport(string_exports, require("./startsWith.cjs"), module.exports);
56
- __reExport(string_exports, require("./endsWith.cjs"), module.exports);
57
- if (module.exports.default) module.exports = module.exports.default;
58
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/string/index.ts"],
4
- "sourcesContent": ["export { default as withLeadingCharacters } from './withLeadingCharacters.js';\nexport { default as withLeadingSlash } from './withLeadingSlash.js';\nexport { default as withoutLeadingCharacters } from './withoutLeadingCharacters.js';\nexport { default as withoutLeadingCharactersRecursive } from './withoutLeadingCharactersRecursive.js';\nexport { default as withoutLeadingSlash } from './withoutLeadingSlash.js';\nexport { default as withoutTrailingCharacters } from './withoutTrailingCharacters.js';\nexport { default as withoutTrailingCharactersRecursive } from './withoutTrailingCharactersRecursive.js';\nexport { default as withoutTrailingSlash } from './withoutTrailingSlash.js';\nexport { default as withTrailingCharacters } from './withTrailingCharacters.js';\nexport { default as withTrailingSlash } from './withTrailingSlash.js';\nexport * from './startsWith.js';\nexport * from './endsWith.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAAiD;AACjD,8BAA4C;AAC5C,sCAAoD;AACpD,+CAA6D;AAC7D,iCAA+C;AAC/C,uCAAqD;AACrD,gDAA8D;AAC9D,kCAAgD;AAChD,oCAAkD;AAClD,+BAA6C;AAC7C,2BAAc,6BAVd;AAWA,2BAAc,2BAXd;",
6
- "names": []
7
- }
@@ -1,35 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/string/startsWith.ts
20
- var startsWith_exports = {};
21
- __export(startsWith_exports, {
22
- startsWith: () => startsWith
23
- });
24
- module.exports = __toCommonJS(startsWith_exports);
25
- function startsWith(string, search) {
26
- if (search.length === 0) {
27
- return true;
28
- }
29
- if (search.length === 1) {
30
- return string[0] === search;
31
- }
32
- return string.substring(0, search.length) === search;
33
- }
34
- if (module.exports.default) module.exports = module.exports.default;
35
- //# sourceMappingURL=startsWith.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/string/startsWith.ts"],
4
- "sourcesContent": ["/**\n * Test if a string starts with another string.\n *\n * This is a more performant version of the `String.prototype.startsWith` method.\n *\n * @see https://jsbench.me/1hlkqqd0ff/1\n */\nexport function startsWith(string: string, search: string): boolean {\n if (search.length === 0) {\n return true;\n }\n\n if (search.length === 1) {\n return string[0] === search;\n }\n\n // eslint-disable-next-line unicorn/prefer-string-slice\n return string.substring(0, search.length) === search;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,WAAW,QAAgB,QAAyB;AAClE,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO,OAAO,CAAC,MAAM;AAAA,EACvB;AAGA,SAAO,OAAO,UAAU,GAAG,OAAO,MAAM,MAAM;AAChD;",
6
- "names": []
7
- }
@@ -1,40 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // packages/js-toolkit/utils/string/withLeadingCharacters.ts
30
- var withLeadingCharacters_exports = {};
31
- __export(withLeadingCharacters_exports, {
32
- default: () => withLeadingCharacters
33
- });
34
- module.exports = __toCommonJS(withLeadingCharacters_exports);
35
- var import_withoutLeadingCharacters = __toESM(require("./withoutLeadingCharacters.cjs"), 1);
36
- function withLeadingCharacters(string, characters) {
37
- return `${characters}${(0, import_withoutLeadingCharacters.default)(string, characters)}`;
38
- }
39
- if (module.exports.default) module.exports = module.exports.default;
40
- //# sourceMappingURL=withLeadingCharacters.cjs.map