@studiometa/js-toolkit 2.0.0-rc.1 → 2.0.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 (109) hide show
  1. package/Base/index.cjs +1 -2
  2. package/Base/index.d.ts +25 -26
  3. package/Base/index.js +1 -2
  4. package/Base/managers/ChildrenManager.d.ts +2 -2
  5. package/Base/managers/EventsManager.d.ts +13 -20
  6. package/Base/managers/OptionsManager.cjs +0 -1
  7. package/Base/managers/OptionsManager.d.ts +13 -10
  8. package/Base/managers/OptionsManager.js +0 -1
  9. package/Base/managers/RefsManager.d.ts +4 -4
  10. package/Base/managers/ServicesManager.cjs +3 -0
  11. package/Base/managers/ServicesManager.d.ts +14 -8
  12. package/Base/managers/ServicesManager.js +3 -0
  13. package/Base/utils.d.ts +4 -4
  14. package/decorators/withBreakpointManager.cjs +0 -1
  15. package/decorators/withBreakpointManager.d.ts +2 -2
  16. package/decorators/withBreakpointManager.js +0 -1
  17. package/decorators/withBreakpointObserver.cjs +1 -2
  18. package/decorators/withBreakpointObserver.d.ts +1 -1
  19. package/decorators/withBreakpointObserver.js +1 -2
  20. package/decorators/withDrag.d.ts +1 -1
  21. package/decorators/withExtraConfig.d.ts +1 -1
  22. package/decorators/withFreezedOptions.cjs +13 -3
  23. package/decorators/withFreezedOptions.d.ts +1 -1
  24. package/decorators/withFreezedOptions.js +14 -3
  25. package/decorators/withIntersectionObserver.cjs +0 -1
  26. package/decorators/withIntersectionObserver.d.ts +1 -1
  27. package/decorators/withIntersectionObserver.js +0 -1
  28. package/decorators/withMountWhenInView.cjs +0 -1
  29. package/decorators/withMountWhenInView.d.ts +1 -1
  30. package/decorators/withMountWhenInView.js +0 -1
  31. package/decorators/withScrolledInView.d.ts +1 -1
  32. package/decorators/withVue2.cjs +2 -1
  33. package/decorators/withVue2.js +2 -1
  34. package/helpers/createApp.d.ts +3 -26
  35. package/helpers/getInstanceFromElement.cjs +32 -0
  36. package/helpers/getInstanceFromElement.d.ts +14 -0
  37. package/helpers/getInstanceFromElement.js +10 -0
  38. package/helpers/importOnInteraction.d.ts +3 -5
  39. package/helpers/importWhenIdle.d.ts +3 -5
  40. package/helpers/importWhenVisible.d.ts +4 -6
  41. package/helpers/index.cjs +2 -0
  42. package/helpers/index.d.ts +1 -0
  43. package/helpers/index.js +8 -6
  44. package/helpers/utils.d.ts +3 -4
  45. package/package.json +1 -1
  46. package/services/Service.d.ts +9 -9
  47. package/services/drag.cjs +0 -1
  48. package/services/drag.d.ts +3 -3
  49. package/services/drag.js +0 -1
  50. package/services/key.d.ts +1 -1
  51. package/services/load.d.ts +1 -1
  52. package/services/pointer.d.ts +1 -1
  53. package/services/raf.d.ts +1 -1
  54. package/services/resize.cjs +2 -2
  55. package/services/resize.d.ts +1 -1
  56. package/services/resize.js +2 -2
  57. package/services/scroll.cjs +3 -1
  58. package/services/scroll.d.ts +1 -1
  59. package/services/scroll.js +3 -1
  60. package/utils/collide/boundingRectToCircle.d.ts +5 -5
  61. package/utils/collide/collideCircleCircle.d.ts +4 -4
  62. package/utils/collide/collideCircleRect.d.ts +8 -8
  63. package/utils/collide/collidePointCircle.d.ts +6 -6
  64. package/utils/collide/collidePointRect.d.ts +7 -7
  65. package/utils/collide/collideRectRect.d.ts +5 -5
  66. package/utils/css/classes.cjs +3 -3
  67. package/utils/css/classes.d.ts +10 -10
  68. package/utils/css/classes.js +3 -3
  69. package/utils/css/matrix.d.ts +14 -15
  70. package/utils/css/styles.d.ts +2 -2
  71. package/utils/css/transition.cjs +2 -0
  72. package/utils/css/transition.d.ts +2 -2
  73. package/utils/css/transition.js +2 -0
  74. package/utils/debounce.d.ts +4 -4
  75. package/utils/focusTrap.cjs +1 -1
  76. package/utils/focusTrap.d.ts +1 -0
  77. package/utils/focusTrap.js +1 -1
  78. package/utils/history.d.ts +13 -11
  79. package/utils/math/clamp.d.ts +1 -1
  80. package/utils/math/clamp01.d.ts +1 -1
  81. package/utils/math/damp.d.ts +6 -6
  82. package/utils/math/ease.d.ts +7 -7
  83. package/utils/math/inertiaFinalValue.d.ts +5 -5
  84. package/utils/math/lerp.d.ts +4 -4
  85. package/utils/math/map.d.ts +6 -6
  86. package/utils/math/round.d.ts +4 -4
  87. package/utils/memoize.d.ts +1 -1
  88. package/utils/nextFrame.d.ts +3 -4
  89. package/utils/nextMicrotask.d.ts +1 -1
  90. package/utils/nextTick.d.ts +1 -1
  91. package/utils/object/autoBind.d.ts +3 -3
  92. package/utils/object/getAllProperties.d.ts +3 -3
  93. package/utils/object/isObject.d.ts +1 -1
  94. package/utils/scrollTo.cjs +1 -1
  95. package/utils/scrollTo.d.ts +1 -1
  96. package/utils/scrollTo.js +1 -1
  97. package/utils/string/withLeadingCharacters.d.ts +3 -2
  98. package/utils/string/withLeadingSlash.d.ts +1 -1
  99. package/utils/string/withTrailingCharacters.d.ts +3 -2
  100. package/utils/string/withTrailingSlash.d.ts +1 -1
  101. package/utils/string/withoutLeadingCharacters.d.ts +3 -2
  102. package/utils/string/withoutLeadingCharactersRecursive.d.ts +3 -2
  103. package/utils/string/withoutLeadingSlash.d.ts +1 -1
  104. package/utils/string/withoutTrailingCharacters.d.ts +3 -2
  105. package/utils/string/withoutTrailingCharactersRecursive.d.ts +3 -2
  106. package/utils/string/withoutTrailingSlash.d.ts +1 -1
  107. package/utils/throttle.cjs +1 -1
  108. package/utils/throttle.d.ts +3 -3
  109. package/utils/throttle.js +1 -1
@@ -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]>;
@@ -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;
@@ -39,7 +39,7 @@ function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
39
39
  const sizes = targetElement.getBoundingClientRect();
40
40
  const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
41
41
  const max = document.documentElement.scrollHeight - window.innerHeight;
42
- let scrollTarget = sizes.top + window.pageYOffset - parseInt(scrollMargin, 10) - offset;
42
+ let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;
43
43
  if (scrollTarget > max) {
44
44
  scrollTarget = max;
45
45
  }
@@ -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;
package/utils/scrollTo.js CHANGED
@@ -12,7 +12,7 @@ function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
12
12
  const sizes = targetElement.getBoundingClientRect();
13
13
  const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
14
14
  const max = document.documentElement.scrollHeight - window.innerHeight;
15
- let scrollTarget = sizes.top + window.pageYOffset - parseInt(scrollMargin, 10) - offset;
15
+ let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;
16
16
  if (scrollTarget > max) {
17
17
  scrollTarget = max;
18
18
  }
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Add the given characters to the start of the given string.
3
3
  *
4
- * @param {string} string The string to modify.
5
- * @param {string} characters The characters to add to the start.
4
+ * @param {string} string The string to modify.
5
+ * @param {string} characters The characters to add to the start.
6
+ * @returns {string}
6
7
  */
7
8
  export default function withLeadingCharacters(string: string, characters: string): string;
@@ -2,6 +2,6 @@
2
2
  * Add a leading slash to a string.
3
3
  *
4
4
  * @param {string} string The string to modify.
5
- * @return {string} The string with a leading slash.
5
+ * @returns {string} The string with a leading slash.
6
6
  */
7
7
  export default function withLeadingSlash(string: string): string;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Add the given characters to the end of the given string.
3
3
  *
4
- * @param {string} string The string to modify.
5
- * @param {string} characters The characters to add to the end.
4
+ * @param {string} string The string to modify.
5
+ * @param {string} characters The characters to add to the end.
6
+ * @returns {string}
6
7
  */
7
8
  export default function withTrailingCharacters(string: string, characters: string): string;
@@ -2,6 +2,6 @@
2
2
  * Add a trailing slash to a string.
3
3
  *
4
4
  * @param {string} string The string to modify.
5
- * @return {string} The string with a trailing slash.
5
+ * @returns {string} The string with a trailing slash.
6
6
  */
7
7
  export default function withTrailingSlash(string: string): string;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Remove the given characters from the start of the given string.
3
3
  *
4
- * @param {string} string The string to modify.
5
- * @param {string} characters The characters to remove from the start.
4
+ * @param {string} string The string to modify.
5
+ * @param {string} characters The characters to remove from the start.
6
+ * @returns {string}
6
7
  */
7
8
  export default function withoutLeadingCharacters(string: string, characters: string): string;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Remove the given characters to the start of the given string recursively.
3
3
  *
4
- * @param {string} string The string to modify.
5
- * @param {string} characters The characters to add to the start.
4
+ * @param {string} string The string to modify.
5
+ * @param {string} characters The characters to add to the start.
6
+ * @returns {string}
6
7
  */
7
8
  export default function withoutLeadingCharactersRecursive(string: string, characters: string): string;
@@ -2,6 +2,6 @@
2
2
  * Remove the leading slash from a string.
3
3
  *
4
4
  * @param {string} string The string to modify.
5
- * @return {string} The string without leading slash.
5
+ * @returns {string} The string without leading slash.
6
6
  */
7
7
  export default function withoutLeadingSlash(string: string): string;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Remove the given characters from the end of the given string.
3
3
  *
4
- * @param {string} string The string to modify.
5
- * @param {string} characters The characters to remove from the end.
4
+ * @param {string} string The string to modify.
5
+ * @param {string} characters The characters to remove from the end.
6
+ * @returns {string}
6
7
  */
7
8
  export default function withoutTrailingCharacters(string: string, characters: string): string;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Remove the given characters to the start of the given string recursively.
3
3
  *
4
- * @param {string} string The string to modify.
5
- * @param {string} characters The characters to add to the start.
4
+ * @param {string} string The string to modify.
5
+ * @param {string} characters The characters to add to the start.
6
+ * @returns {string}
6
7
  */
7
8
  export default function withoutTrailingCharactersRecursive(string: string, characters: string): string;
@@ -2,6 +2,6 @@
2
2
  * Remove the trailing slash from a string.
3
3
  *
4
4
  * @param {string} string The string to modify.
5
- * @return {string} The string without trailing slash.
5
+ * @returns {string} The string without trailing slash.
6
6
  */
7
7
  export default function withoutTrailingSlash(string: string): string;
@@ -25,7 +25,7 @@ module.exports = __toCommonJS(throttle_exports);
25
25
  function throttle(fn, delay = 16) {
26
26
  let lastCall = 0;
27
27
  return function throttled(...args) {
28
- const now = new Date().getTime();
28
+ const now = Date.now();
29
29
  if (now - lastCall < delay) {
30
30
  return false;
31
31
  }
@@ -2,7 +2,7 @@
2
2
  * Simple throttling helper that limits a function to only run once every {delay}ms.
3
3
  *
4
4
  * @param {Function} fn The function to throttle
5
- * @param {Number=} [delay=16] The delay in ms
6
- * @return {Function} The throttled function.
5
+ * @param {number} [delay] The delay in ms
6
+ * @returns {Function} The throttled function.
7
7
  */
8
- export default function throttle(fn: Function, delay?: number | undefined): Function;
8
+ export default function throttle(fn: Function, delay?: number): Function;
package/utils/throttle.js CHANGED
@@ -1,7 +1,7 @@
1
1
  function throttle(fn, delay = 16) {
2
2
  let lastCall = 0;
3
3
  return function throttled(...args) {
4
- const now = new Date().getTime();
4
+ const now = Date.now();
5
5
  if (now - lastCall < delay) {
6
6
  return false;
7
7
  }