@studiometa/js-toolkit 2.0.0-beta.9 → 2.0.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 (238) hide show
  1. package/Base/index.cjs +284 -0
  2. package/Base/index.d.ts +36 -28
  3. package/Base/index.js +113 -197
  4. package/Base/managers/ChildrenManager.cjs +146 -0
  5. package/Base/managers/ChildrenManager.d.ts +11 -3
  6. package/Base/managers/ChildrenManager.js +60 -59
  7. package/Base/managers/EventsManager.cjs +183 -0
  8. package/Base/managers/EventsManager.d.ts +13 -20
  9. package/Base/managers/EventsManager.js +72 -112
  10. package/Base/managers/OptionsManager.cjs +173 -0
  11. package/Base/managers/OptionsManager.d.ts +20 -13
  12. package/Base/managers/OptionsManager.js +60 -91
  13. package/Base/managers/RefsManager.cjs +99 -0
  14. package/Base/managers/RefsManager.d.ts +4 -4
  15. package/Base/managers/RefsManager.js +28 -38
  16. package/Base/managers/ServicesManager.cjs +134 -0
  17. package/Base/managers/ServicesManager.d.ts +14 -8
  18. package/Base/managers/ServicesManager.js +42 -67
  19. package/Base/utils.cjs +41 -0
  20. package/Base/utils.d.ts +4 -4
  21. package/Base/utils.js +12 -11
  22. package/decorators/index.cjs +45 -0
  23. package/decorators/index.d.ts +1 -0
  24. package/decorators/index.js +20 -8
  25. package/decorators/withBreakpointManager.cjs +84 -0
  26. package/decorators/withBreakpointManager.d.ts +2 -2
  27. package/decorators/withBreakpointManager.js +18 -40
  28. package/decorators/withBreakpointObserver.cjs +114 -0
  29. package/decorators/withBreakpointObserver.d.ts +1 -1
  30. package/decorators/withBreakpointObserver.js +45 -88
  31. package/decorators/withDrag.cjs +53 -0
  32. package/decorators/withDrag.d.ts +1 -1
  33. package/decorators/withDrag.js +24 -26
  34. package/decorators/withExtraConfig.cjs +43 -0
  35. package/decorators/withExtraConfig.d.ts +1 -1
  36. package/decorators/withExtraConfig.js +17 -12
  37. package/decorators/withFreezedOptions.cjs +37 -0
  38. package/decorators/withFreezedOptions.d.ts +14 -0
  39. package/decorators/withFreezedOptions.js +15 -0
  40. package/decorators/withIntersectionObserver.cjs +61 -0
  41. package/decorators/withIntersectionObserver.d.ts +1 -1
  42. package/decorators/withIntersectionObserver.js +29 -33
  43. package/decorators/withMountWhenInView.cjs +68 -0
  44. package/decorators/withMountWhenInView.d.ts +1 -1
  45. package/decorators/withMountWhenInView.js +31 -53
  46. package/decorators/withScrolledInView.cjs +114 -0
  47. package/decorators/withScrolledInView.d.ts +1 -1
  48. package/decorators/withScrolledInView.js +35 -39
  49. package/decorators/withVue2.cjs +61 -0
  50. package/decorators/withVue2.js +27 -32
  51. package/helpers/createApp.cjs +52 -0
  52. package/helpers/createApp.d.ts +3 -26
  53. package/helpers/createApp.js +12 -12
  54. package/helpers/getInstanceFromElement.cjs +32 -0
  55. package/helpers/getInstanceFromElement.d.ts +14 -0
  56. package/helpers/getInstanceFromElement.js +10 -0
  57. package/helpers/importOnInteraction.cjs +52 -0
  58. package/helpers/importOnInteraction.d.ts +3 -5
  59. package/helpers/importOnInteraction.js +17 -18
  60. package/helpers/importWhenIdle.cjs +49 -0
  61. package/helpers/importWhenIdle.d.ts +3 -5
  62. package/helpers/importWhenIdle.js +14 -17
  63. package/helpers/importWhenVisible.cjs +50 -0
  64. package/helpers/importWhenVisible.d.ts +4 -6
  65. package/helpers/importWhenVisible.js +16 -18
  66. package/helpers/index.cjs +37 -0
  67. package/helpers/index.d.ts +1 -0
  68. package/helpers/index.js +12 -4
  69. package/helpers/utils.cjs +35 -0
  70. package/helpers/utils.d.ts +3 -4
  71. package/helpers/utils.js +7 -6
  72. package/index.cjs +33 -0
  73. package/index.js +7 -4
  74. package/package.json +14 -4
  75. package/services/Service.cjs +76 -0
  76. package/services/Service.d.ts +9 -9
  77. package/services/Service.js +19 -32
  78. package/services/drag.cjs +212 -0
  79. package/services/drag.d.ts +3 -2
  80. package/services/drag.js +64 -69
  81. package/services/index.cjs +41 -0
  82. package/services/index.js +16 -7
  83. package/services/key.cjs +104 -0
  84. package/services/key.d.ts +1 -1
  85. package/services/key.js +28 -36
  86. package/services/load.cjs +72 -0
  87. package/services/load.d.ts +1 -1
  88. package/services/load.js +17 -19
  89. package/services/pointer.cjs +162 -0
  90. package/services/pointer.d.ts +1 -1
  91. package/services/pointer.js +43 -60
  92. package/services/raf.cjs +83 -0
  93. package/services/raf.d.ts +1 -1
  94. package/services/raf.js +20 -28
  95. package/services/resize.cjs +108 -0
  96. package/services/resize.d.ts +1 -1
  97. package/services/resize.js +33 -42
  98. package/services/scroll.cjs +131 -0
  99. package/services/scroll.d.ts +1 -1
  100. package/services/scroll.js +26 -35
  101. package/utils/collide/boundingRectToCircle.cjs +34 -0
  102. package/utils/collide/boundingRectToCircle.d.ts +6 -6
  103. package/utils/collide/boundingRectToCircle.js +7 -10
  104. package/utils/collide/collideCircleCircle.cjs +34 -0
  105. package/utils/collide/collideCircleCircle.d.ts +4 -4
  106. package/utils/collide/collideCircleCircle.js +8 -7
  107. package/utils/collide/collideCircleRect.cjs +46 -0
  108. package/utils/collide/collideCircleRect.d.ts +8 -8
  109. package/utils/collide/collideCircleRect.js +10 -12
  110. package/utils/collide/collidePointCircle.cjs +31 -0
  111. package/utils/collide/collidePointCircle.d.ts +6 -6
  112. package/utils/collide/collidePointCircle.js +8 -5
  113. package/utils/collide/collidePointRect.cjs +28 -0
  114. package/utils/collide/collidePointRect.d.ts +7 -7
  115. package/utils/collide/collidePointRect.js +5 -2
  116. package/utils/collide/collideRectRect.cjs +28 -0
  117. package/utils/collide/collideRectRect.d.ts +5 -5
  118. package/utils/collide/collideRectRect.js +5 -2
  119. package/utils/collide/index.cjs +39 -0
  120. package/utils/collide/index.js +14 -6
  121. package/utils/css/classes.cjs +47 -0
  122. package/utils/css/classes.d.ts +13 -12
  123. package/utils/css/classes.js +19 -15
  124. package/utils/css/index.cjs +38 -0
  125. package/utils/css/index.d.ts +2 -2
  126. package/utils/css/index.js +13 -6
  127. package/utils/css/matrix.cjs +30 -0
  128. package/utils/css/matrix.d.ts +14 -15
  129. package/utils/css/matrix.js +7 -5
  130. package/utils/css/styles.cjs +44 -0
  131. package/utils/css/styles.d.ts +8 -20
  132. package/utils/css/styles.js +12 -12
  133. package/utils/css/transition.cjs +120 -0
  134. package/utils/css/transition.d.ts +15 -9
  135. package/utils/css/transition.js +70 -119
  136. package/utils/debounce.cjs +34 -0
  137. package/utils/debounce.d.ts +4 -4
  138. package/utils/debounce.js +7 -9
  139. package/utils/focusTrap.cjs +82 -0
  140. package/utils/focusTrap.d.ts +1 -0
  141. package/utils/focusTrap.js +31 -22
  142. package/utils/history.cjs +89 -0
  143. package/utils/history.d.ts +13 -11
  144. package/utils/history.js +28 -57
  145. package/utils/index.cjs +54 -0
  146. package/utils/index.d.ts +4 -1
  147. package/utils/index.js +32 -11
  148. package/utils/keyCodes.cjs +35 -0
  149. package/utils/keyCodes.js +5 -2
  150. package/utils/math/clamp.cjs +28 -0
  151. package/utils/math/clamp.d.ts +1 -1
  152. package/utils/math/clamp.js +5 -2
  153. package/utils/math/clamp01.cjs +32 -0
  154. package/utils/math/clamp01.d.ts +1 -1
  155. package/utils/math/clamp01.js +6 -3
  156. package/utils/math/damp.cjs +28 -0
  157. package/utils/math/damp.d.ts +6 -6
  158. package/utils/math/damp.js +5 -4
  159. package/utils/math/ease.cjs +88 -0
  160. package/utils/math/ease.d.ts +7 -7
  161. package/utils/math/ease.js +50 -25
  162. package/utils/math/index.cjs +43 -0
  163. package/utils/math/index.js +17 -8
  164. package/utils/math/inertiaFinalValue.cjs +37 -0
  165. package/utils/math/inertiaFinalValue.d.ts +5 -5
  166. package/utils/math/inertiaFinalValue.js +8 -10
  167. package/utils/math/lerp.cjs +28 -0
  168. package/utils/math/lerp.d.ts +4 -4
  169. package/utils/math/lerp.js +5 -2
  170. package/utils/math/map.cjs +28 -0
  171. package/utils/math/map.d.ts +6 -6
  172. package/utils/math/map.js +5 -2
  173. package/utils/math/round.cjs +28 -0
  174. package/utils/math/round.d.ts +4 -4
  175. package/utils/math/round.js +5 -3
  176. package/utils/memoize.cjs +43 -0
  177. package/utils/memoize.d.ts +1 -1
  178. package/utils/memoize.js +10 -19
  179. package/utils/nextFrame.cjs +38 -0
  180. package/utils/nextFrame.d.ts +6 -6
  181. package/utils/nextFrame.js +13 -10
  182. package/utils/nextMicrotask.cjs +28 -0
  183. package/utils/nextMicrotask.d.ts +8 -0
  184. package/utils/nextMicrotask.js +6 -0
  185. package/utils/nextTick.cjs +30 -0
  186. package/utils/nextTick.d.ts +8 -0
  187. package/utils/nextTick.js +8 -0
  188. package/utils/object/autoBind.cjs +49 -0
  189. package/utils/object/autoBind.d.ts +3 -3
  190. package/utils/object/autoBind.js +12 -22
  191. package/utils/object/getAllProperties.cjs +37 -0
  192. package/utils/object/getAllProperties.d.ts +3 -3
  193. package/utils/object/getAllProperties.js +10 -13
  194. package/utils/object/index.cjs +33 -0
  195. package/utils/object/index.js +8 -3
  196. package/utils/object/isObject.cjs +28 -0
  197. package/utils/object/isObject.d.ts +1 -1
  198. package/utils/object/isObject.js +6 -3
  199. package/utils/scrollTo.cjs +80 -0
  200. package/utils/scrollTo.d.ts +1 -1
  201. package/utils/scrollTo.js +20 -40
  202. package/utils/string/index.cjs +47 -0
  203. package/utils/string/index.js +22 -10
  204. package/utils/string/withLeadingCharacters.cjs +32 -0
  205. package/utils/string/withLeadingCharacters.d.ts +3 -2
  206. package/utils/string/withLeadingCharacters.js +7 -4
  207. package/utils/string/withLeadingSlash.cjs +32 -0
  208. package/utils/string/withLeadingSlash.d.ts +1 -1
  209. package/utils/string/withLeadingSlash.js +7 -4
  210. package/utils/string/withTrailingCharacters.cjs +32 -0
  211. package/utils/string/withTrailingCharacters.d.ts +3 -2
  212. package/utils/string/withTrailingCharacters.js +7 -4
  213. package/utils/string/withTrailingSlash.cjs +32 -0
  214. package/utils/string/withTrailingSlash.d.ts +1 -1
  215. package/utils/string/withTrailingSlash.js +7 -4
  216. package/utils/string/withoutLeadingCharacters.cjs +28 -0
  217. package/utils/string/withoutLeadingCharacters.d.ts +3 -2
  218. package/utils/string/withoutLeadingCharacters.js +6 -3
  219. package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
  220. package/utils/string/withoutLeadingCharactersRecursive.d.ts +3 -2
  221. package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
  222. package/utils/string/withoutLeadingSlash.cjs +32 -0
  223. package/utils/string/withoutLeadingSlash.d.ts +1 -1
  224. package/utils/string/withoutLeadingSlash.js +7 -4
  225. package/utils/string/withoutTrailingCharacters.cjs +28 -0
  226. package/utils/string/withoutTrailingCharacters.d.ts +3 -2
  227. package/utils/string/withoutTrailingCharacters.js +6 -3
  228. package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
  229. package/utils/string/withoutTrailingCharactersRecursive.d.ts +3 -2
  230. package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
  231. package/utils/string/withoutTrailingSlash.cjs +32 -0
  232. package/utils/string/withoutTrailingSlash.d.ts +1 -1
  233. package/utils/string/withoutTrailingSlash.js +7 -4
  234. package/utils/throttle.cjs +36 -0
  235. package/utils/throttle.d.ts +3 -3
  236. package/utils/throttle.js +9 -9
  237. package/index.modern.js +0 -1
  238. package/index.umd.js +0 -1
@@ -0,0 +1,38 @@
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/nextFrame.js
20
+ var nextFrame_exports = {};
21
+ __export(nextFrame_exports, {
22
+ default: () => nextFrame,
23
+ getCancelRaf: () => getCancelRaf,
24
+ getRaf: () => getRaf
25
+ });
26
+ module.exports = __toCommonJS(nextFrame_exports);
27
+ function getRaf() {
28
+ return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
29
+ }
30
+ function getCancelRaf() {
31
+ return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
32
+ }
33
+ function nextFrame(fn) {
34
+ return new Promise((resolve) => {
35
+ getRaf()(() => resolve(typeof fn === "function" && fn()));
36
+ });
37
+ }
38
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,21 +1,21 @@
1
1
  /**
2
2
  * RequestAnimation frame polyfill.
3
3
  * @see https://github.com/vuejs/vue/blob/ec78fc8b6d03e59da669be1adf4b4b5abf670a34/dist/vue.runtime.esm.js#L7355
4
- * @return {(handler: Function) => number}
4
+ * @returns {(handler: Function) => number}
5
5
  */
6
6
  export function getRaf(): (handler: Function) => number;
7
7
  /**
8
8
  * Get a function to cancel the method returned by `getRaf()`.
9
9
  *
10
- * @return {(id:number) => void}
10
+ * @returns {(id:number) => void}
11
11
  */
12
12
  export function getCancelRaf(): (id: number) => void;
13
13
  /**
14
14
  * Wait for the next frame to execute a function.
15
15
  *
16
- * @param {Function=} [fn=() => {}] The callback function to execute.
17
- * @return {Promise} A Promise resolving when the next frame is reached.
18
- *
16
+ * @template {() => any} T
17
+ * @param {T} [fn] The callback function to execute.
18
+ * @returns {Promise<T extends Function ? ReturnType<T> : undefined>} A Promise resolving when the next frame is reached.
19
19
  * @example
20
20
  * ```js
21
21
  * nextFrame(() => console.log('hello world'));
@@ -24,4 +24,4 @@ export function getCancelRaf(): (id: number) => void;
24
24
  * console.log('hello world');
25
25
  * ```
26
26
  */
27
- export default function nextFrame(fn?: Function | undefined): Promise<any>;
27
+ export default function nextFrame<T extends () => any>(fn?: T): Promise<T extends Function ? ReturnType<T> : undefined>;
@@ -1,13 +1,16 @@
1
- export function getRaf() {
2
- return typeof window !== 'undefined' && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
1
+ function getRaf() {
2
+ return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
3
3
  }
4
- export function getCancelRaf() {
5
- return typeof window !== 'undefined' && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
4
+ function getCancelRaf() {
5
+ return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
6
6
  }
7
- export default function nextFrame() {
8
- var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
9
- var raf = getRaf();
10
- return new Promise(resolve => {
11
- raf(() => raf(() => resolve(fn())));
7
+ function nextFrame(fn) {
8
+ return new Promise((resolve) => {
9
+ getRaf()(() => resolve(typeof fn === "function" && fn()));
12
10
  });
13
- }
11
+ }
12
+ export {
13
+ nextFrame as default,
14
+ getCancelRaf,
15
+ getRaf
16
+ };
@@ -0,0 +1,28 @@
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/nextMicrotask.js
20
+ var nextMicrotask_exports = {};
21
+ __export(nextMicrotask_exports, {
22
+ default: () => nextMicrotask
23
+ });
24
+ module.exports = __toCommonJS(nextMicrotask_exports);
25
+ async function nextMicrotask(fn) {
26
+ return Promise.resolve().then(() => typeof fn === "function" && fn());
27
+ }
28
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Wait for the next microtask.
3
+ *
4
+ * @template {() => any} T
5
+ * @param {T} [fn]
6
+ * @returns {Promise<T extends Function ? ReturnType<T> : undefined>}
7
+ */
8
+ export default function nextMicrotask<T extends () => any>(fn?: T): Promise<T extends Function ? ReturnType<T> : undefined>;
@@ -0,0 +1,6 @@
1
+ async function nextMicrotask(fn) {
2
+ return Promise.resolve().then(() => typeof fn === "function" && fn());
3
+ }
4
+ export {
5
+ nextMicrotask as default
6
+ };
@@ -0,0 +1,30 @@
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/nextTick.js
20
+ var nextTick_exports = {};
21
+ __export(nextTick_exports, {
22
+ default: () => nextTick
23
+ });
24
+ module.exports = __toCommonJS(nextTick_exports);
25
+ async function nextTick(fn) {
26
+ return new Promise((resolve) => setTimeout(() => {
27
+ resolve(typeof fn === "function" && fn());
28
+ }, 0));
29
+ }
30
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Wait for the next tick.
3
+ *
4
+ * @template {() => any} T
5
+ * @param {T} [fn]
6
+ * @returns {Promise<T extends Function ? ReturnType<T> : undefined>}
7
+ */
8
+ export default function nextTick<T extends () => any>(fn?: T): Promise<T extends Function ? ReturnType<T> : undefined>;
@@ -0,0 +1,8 @@
1
+ async function nextTick(fn) {
2
+ return new Promise((resolve) => setTimeout(() => {
3
+ resolve(typeof fn === "function" && fn());
4
+ }, 0));
5
+ }
6
+ export {
7
+ nextTick as default
8
+ };
@@ -0,0 +1,49 @@
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // packages/js-toolkit/utils/object/autoBind.js
23
+ var autoBind_exports = {};
24
+ __export(autoBind_exports, {
25
+ default: () => autoBind
26
+ });
27
+ module.exports = __toCommonJS(autoBind_exports);
28
+ var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
29
+ function autoBind(instance, options) {
30
+ const { exclude, include } = options || {};
31
+ const filter = (key) => {
32
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
33
+ if (include) {
34
+ return include.some(match);
35
+ }
36
+ if (exclude) {
37
+ return !exclude.some(match);
38
+ }
39
+ return true;
40
+ };
41
+ (0, import_getAllProperties.default)(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
42
+ const descriptor = Object.getOwnPropertyDescriptor(object, key);
43
+ if (descriptor && typeof descriptor.value === "function") {
44
+ instance[key] = instance[key].bind(instance);
45
+ }
46
+ });
47
+ return instance;
48
+ }
49
+ if (module.exports.default) module.exports = module.exports.default;
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * @param {Object} instance The instance.
5
5
  * @param {Object} options Define specific methods to include or exlude.
6
- * @param {Array<String|RegExp>} [options.include] Methods to include.
7
- * @param {Array<String|RegExp>} [options.exclude] Methods to exclude.
8
- * @return {Object} The instance.
6
+ * @param {Array<string | RegExp>} [options.include] Methods to include.
7
+ * @param {Array<string | RegExp>} [options.exclude] Methods to exclude.
8
+ * @returns {Object} The instance.
9
9
  */
10
10
  export default function autoBind(instance: any, options: {
11
11
  include?: Array<string | RegExp>;
@@ -1,34 +1,24 @@
1
- import getAllProperties from './getAllProperties.js';
2
- export default function autoBind(instance, options) {
3
- var {
4
- exclude,
5
- include
6
- } = options || {};
7
-
8
- var filter = key => {
9
- var match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
10
-
1
+ import getAllProperties from "./getAllProperties.js";
2
+ function autoBind(instance, options) {
3
+ const { exclude, include } = options || {};
4
+ const filter = (key) => {
5
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
11
6
  if (include) {
12
7
  return include.some(match);
13
8
  }
14
-
15
9
  if (exclude) {
16
10
  return !exclude.some(match);
17
11
  }
18
-
19
12
  return true;
20
13
  };
21
-
22
- getAllProperties(instance).filter(_ref => {
23
- var [key] = _ref;
24
- return key !== 'constructor' && filter(key);
25
- }).forEach(_ref2 => {
26
- var [key, object] = _ref2;
27
- var descriptor = Object.getOwnPropertyDescriptor(object, key);
28
-
29
- if (descriptor && typeof descriptor.value === 'function') {
14
+ getAllProperties(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
15
+ const descriptor = Object.getOwnPropertyDescriptor(object, key);
16
+ if (descriptor && typeof descriptor.value === "function") {
30
17
  instance[key] = instance[key].bind(instance);
31
18
  }
32
19
  });
33
20
  return instance;
34
- }
21
+ }
22
+ export {
23
+ autoBind as default
24
+ };
@@ -0,0 +1,37 @@
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.js
20
+ var getAllProperties_exports = {};
21
+ __export(getAllProperties_exports, {
22
+ default: () => getAllProperties
23
+ });
24
+ module.exports = __toCommonJS(getAllProperties_exports);
25
+ function getAllProperties(object, props = [], testFn = null) {
26
+ const proto = Object.getPrototypeOf(object);
27
+ if (proto === Object.prototype || proto === null) {
28
+ return props;
29
+ }
30
+ let foundProps = Object.getOwnPropertyNames(proto);
31
+ if (typeof testFn === "function") {
32
+ foundProps = foundProps.filter((name) => testFn(name, proto));
33
+ }
34
+ foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
35
+ return getAllProperties(proto, foundProps, testFn);
36
+ }
37
+ if (module.exports.default) module.exports = module.exports.default;
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * @param {Object} object
5
5
  * The object to get the propeties from.
6
- * @param {Array=} [props=[]]
6
+ * @param {Array} [props=[]]
7
7
  * The already existing properties.
8
8
  * @param {(name:string, proto:any) => boolean} testFn
9
- * @return {Array<[String, Object]>} An array of properties and the prototype they belong to.
9
+ * @returns {Array<[string, Object]>} An array of properties and the prototype they belong to.
10
10
  */
11
- export default function getAllProperties(object: any, props?: any[] | undefined, testFn?: (name: string, proto: any) => boolean): Array<[string, any]>;
11
+ export default function getAllProperties(object: any, props?: any[], testFn?: (name: string, proto: any) => boolean): Array<[string, any]>;
@@ -1,18 +1,15 @@
1
- export default function getAllProperties(object) {
2
- var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
3
- var testFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4
- var proto = Object.getPrototypeOf(object);
5
-
1
+ function getAllProperties(object, props = [], testFn = null) {
2
+ const proto = Object.getPrototypeOf(object);
6
3
  if (proto === Object.prototype || proto === null) {
7
4
  return props;
8
5
  }
9
-
10
- var foundProps = Object.getOwnPropertyNames(proto);
11
-
12
- if (typeof testFn === 'function') {
13
- foundProps = foundProps.filter(name => testFn(name, proto));
6
+ let foundProps = Object.getOwnPropertyNames(proto);
7
+ if (typeof testFn === "function") {
8
+ foundProps = foundProps.filter((name) => testFn(name, proto));
14
9
  }
15
-
16
- foundProps = foundProps.map(name => [name, proto]).reduce((acc, val) => [...acc, val], props);
10
+ foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
17
11
  return getAllProperties(proto, foundProps, testFn);
18
- }
12
+ }
13
+ export {
14
+ getAllProperties as default
15
+ };
@@ -0,0 +1,33 @@
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // packages/js-toolkit/utils/object/index.js
23
+ var object_exports = {};
24
+ __export(object_exports, {
25
+ autoBind: () => import_autoBind.default,
26
+ getAllProperties: () => import_getAllProperties.default,
27
+ isObject: () => import_isObject.default
28
+ });
29
+ module.exports = __toCommonJS(object_exports);
30
+ var import_autoBind = __toESM(require("./autoBind.cjs"), 1);
31
+ var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
32
+ var import_isObject = __toESM(require("./isObject.cjs"), 1);
33
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,3 +1,8 @@
1
- export { default as autoBind } from './autoBind.js';
2
- export { default as getAllProperties } from './getAllProperties.js';
3
- export { default as isObject } from './isObject.js';
1
+ import { default as default2 } from "./autoBind.js";
2
+ import { default as default3 } from "./getAllProperties.js";
3
+ import { default as default4 } from "./isObject.js";
4
+ export {
5
+ default2 as autoBind,
6
+ default3 as getAllProperties,
7
+ default4 as isObject
8
+ };
@@ -0,0 +1,28 @@
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/isObject.js
20
+ var isObject_exports = {};
21
+ __export(isObject_exports, {
22
+ default: () => isObject
23
+ });
24
+ module.exports = __toCommonJS(isObject_exports);
25
+ function isObject(value) {
26
+ return typeof value === "object" && !!value && value.toString() === "[object Object]";
27
+ }
28
+ if (module.exports.default) module.exports = module.exports.default;
@@ -2,6 +2,6 @@
2
2
  * Test if the given value is an object.
3
3
  *
4
4
  * @param {*} value The value to test.
5
- * @return {Boolean} Whether or not the value is an object.
5
+ * @returns {boolean} Whether or not the value is an object.
6
6
  */
7
7
  export default function isObject(value: any): boolean;
@@ -1,3 +1,6 @@
1
- export default function isObject(value) {
2
- return typeof value === 'object' && !!value && value.toString() === '[object Object]';
3
- }
1
+ function isObject(value) {
2
+ return typeof value === "object" && !!value && value.toString() === "[object Object]";
3
+ }
4
+ export {
5
+ isObject as default
6
+ };
@@ -0,0 +1,80 @@
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // packages/js-toolkit/utils/scrollTo.js
23
+ var scrollTo_exports = {};
24
+ __export(scrollTo_exports, {
25
+ default: () => scrollTo
26
+ });
27
+ module.exports = __toCommonJS(scrollTo_exports);
28
+ var import_damp = __toESM(require("./math/damp.cjs"), 1);
29
+ function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
30
+ let targetElement = null;
31
+ if (selectorElement instanceof HTMLElement) {
32
+ targetElement = selectorElement;
33
+ } else {
34
+ targetElement = document.querySelector(selectorElement);
35
+ }
36
+ if (!targetElement) {
37
+ return Promise.resolve(window.pageYOffset);
38
+ }
39
+ const sizes = targetElement.getBoundingClientRect();
40
+ const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
41
+ const max = document.documentElement.scrollHeight - window.innerHeight;
42
+ let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;
43
+ if (scrollTarget > max) {
44
+ scrollTarget = max;
45
+ }
46
+ return new Promise((resolve) => {
47
+ let isScrolling = false;
48
+ let scroll = window.pageYOffset;
49
+ let dampScroll = window.pageYOffset;
50
+ function eventHandler() {
51
+ isScrolling = false;
52
+ }
53
+ function end() {
54
+ window.removeEventListener("wheel", eventHandler);
55
+ window.removeEventListener("touchmove", eventHandler);
56
+ resolve(window.pageYOffset);
57
+ }
58
+ function loop() {
59
+ if (!isScrolling) {
60
+ return end();
61
+ }
62
+ dampScroll = (0, import_damp.default)(scroll, dampScroll, dampFactor);
63
+ window.scrollTo({ top: dampScroll });
64
+ if (dampScroll === scroll) {
65
+ isScrolling = false;
66
+ }
67
+ return requestAnimationFrame(loop);
68
+ }
69
+ function start(target) {
70
+ isScrolling = true;
71
+ dampScroll = window.pageYOffset;
72
+ scroll = target;
73
+ window.addEventListener("wheel", eventHandler, { passive: true });
74
+ window.addEventListener("touchmove", eventHandler, { passive: true });
75
+ loop();
76
+ }
77
+ start(scrollTarget);
78
+ });
79
+ }
80
+ if (module.exports.default) module.exports = module.exports.default;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @param {HTMLElement|string} selectorElement The target element.
5
5
  * @param {{ offset?: number, dampFactor?: number }} [options] Options for the scroll.
6
- * @return {Promise<number>} A promising resolving with the target scroll position.
6
+ * @returns {Promise<number>} A promising resolving with the target scroll position.
7
7
  */
8
8
  export default function scrollTo(selectorElement: HTMLElement | string, { offset, dampFactor }?: {
9
9
  offset?: number;