@studiometa/js-toolkit 2.0.0-beta.9 → 2.0.0-rc.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 (179) hide show
  1. package/Base/index.cjs +285 -0
  2. package/Base/index.d.ts +11 -2
  3. package/Base/index.js +114 -197
  4. package/Base/managers/ChildrenManager.cjs +146 -0
  5. package/Base/managers/ChildrenManager.d.ts +9 -1
  6. package/Base/managers/ChildrenManager.js +60 -59
  7. package/Base/managers/EventsManager.cjs +183 -0
  8. package/Base/managers/EventsManager.js +72 -112
  9. package/Base/managers/OptionsManager.cjs +174 -0
  10. package/Base/managers/OptionsManager.d.ts +9 -5
  11. package/Base/managers/OptionsManager.js +60 -90
  12. package/Base/managers/RefsManager.cjs +99 -0
  13. package/Base/managers/RefsManager.js +28 -38
  14. package/Base/managers/ServicesManager.cjs +131 -0
  15. package/Base/managers/ServicesManager.js +39 -67
  16. package/Base/utils.cjs +41 -0
  17. package/Base/utils.js +12 -11
  18. package/decorators/index.cjs +45 -0
  19. package/decorators/index.d.ts +1 -0
  20. package/decorators/index.js +20 -8
  21. package/decorators/withBreakpointManager.cjs +85 -0
  22. package/decorators/withBreakpointManager.js +18 -39
  23. package/decorators/withBreakpointObserver.cjs +115 -0
  24. package/decorators/withBreakpointObserver.js +44 -86
  25. package/decorators/withDrag.cjs +53 -0
  26. package/decorators/withDrag.js +24 -26
  27. package/decorators/withExtraConfig.cjs +43 -0
  28. package/decorators/withExtraConfig.js +17 -12
  29. package/decorators/withFreezedOptions.cjs +36 -0
  30. package/decorators/withFreezedOptions.d.ts +14 -0
  31. package/decorators/withFreezedOptions.js +14 -0
  32. package/decorators/withIntersectionObserver.cjs +62 -0
  33. package/decorators/withIntersectionObserver.js +29 -32
  34. package/decorators/withMountWhenInView.cjs +69 -0
  35. package/decorators/withMountWhenInView.js +31 -52
  36. package/decorators/withScrolledInView.cjs +114 -0
  37. package/decorators/withScrolledInView.js +35 -39
  38. package/decorators/withVue2.cjs +60 -0
  39. package/decorators/withVue2.js +26 -32
  40. package/helpers/createApp.cjs +52 -0
  41. package/helpers/createApp.d.ts +2 -2
  42. package/helpers/createApp.js +12 -12
  43. package/helpers/importOnInteraction.cjs +52 -0
  44. package/helpers/importOnInteraction.js +17 -18
  45. package/helpers/importWhenIdle.cjs +49 -0
  46. package/helpers/importWhenIdle.js +14 -17
  47. package/helpers/importWhenVisible.cjs +50 -0
  48. package/helpers/importWhenVisible.js +16 -18
  49. package/helpers/index.cjs +35 -0
  50. package/helpers/index.js +10 -4
  51. package/helpers/utils.cjs +35 -0
  52. package/helpers/utils.js +7 -6
  53. package/index.cjs +33 -0
  54. package/index.js +7 -4
  55. package/package.json +14 -4
  56. package/services/Service.cjs +76 -0
  57. package/services/Service.js +19 -32
  58. package/services/drag.cjs +213 -0
  59. package/services/drag.d.ts +1 -0
  60. package/services/drag.js +64 -68
  61. package/services/index.cjs +41 -0
  62. package/services/index.js +16 -7
  63. package/services/key.cjs +104 -0
  64. package/services/key.js +28 -36
  65. package/services/load.cjs +72 -0
  66. package/services/load.js +17 -19
  67. package/services/pointer.cjs +162 -0
  68. package/services/pointer.js +43 -60
  69. package/services/raf.cjs +83 -0
  70. package/services/raf.js +20 -28
  71. package/services/resize.cjs +108 -0
  72. package/services/resize.js +33 -42
  73. package/services/scroll.cjs +131 -0
  74. package/services/scroll.js +26 -35
  75. package/utils/collide/boundingRectToCircle.cjs +34 -0
  76. package/utils/collide/boundingRectToCircle.d.ts +1 -1
  77. package/utils/collide/boundingRectToCircle.js +7 -10
  78. package/utils/collide/collideCircleCircle.cjs +34 -0
  79. package/utils/collide/collideCircleCircle.js +8 -7
  80. package/utils/collide/collideCircleRect.cjs +46 -0
  81. package/utils/collide/collideCircleRect.js +10 -12
  82. package/utils/collide/collidePointCircle.cjs +31 -0
  83. package/utils/collide/collidePointCircle.js +8 -5
  84. package/utils/collide/collidePointRect.cjs +28 -0
  85. package/utils/collide/collidePointRect.js +5 -2
  86. package/utils/collide/collideRectRect.cjs +28 -0
  87. package/utils/collide/collideRectRect.js +5 -2
  88. package/utils/collide/index.cjs +39 -0
  89. package/utils/collide/index.js +14 -6
  90. package/utils/css/classes.cjs +47 -0
  91. package/utils/css/classes.d.ts +10 -9
  92. package/utils/css/classes.js +18 -14
  93. package/utils/css/index.cjs +38 -0
  94. package/utils/css/index.d.ts +2 -2
  95. package/utils/css/index.js +13 -6
  96. package/utils/css/matrix.cjs +30 -0
  97. package/utils/css/matrix.js +7 -5
  98. package/utils/css/styles.cjs +44 -0
  99. package/utils/css/styles.d.ts +6 -18
  100. package/utils/css/styles.js +12 -12
  101. package/utils/css/transition.cjs +120 -0
  102. package/utils/css/transition.d.ts +15 -9
  103. package/utils/css/transition.js +70 -119
  104. package/utils/debounce.cjs +34 -0
  105. package/utils/debounce.js +7 -9
  106. package/utils/focusTrap.cjs +82 -0
  107. package/utils/focusTrap.js +30 -21
  108. package/utils/history.cjs +89 -0
  109. package/utils/history.js +28 -57
  110. package/utils/index.cjs +54 -0
  111. package/utils/index.d.ts +4 -1
  112. package/utils/index.js +32 -11
  113. package/utils/keyCodes.cjs +35 -0
  114. package/utils/keyCodes.js +5 -2
  115. package/utils/math/clamp.cjs +28 -0
  116. package/utils/math/clamp.js +5 -2
  117. package/utils/math/clamp01.cjs +32 -0
  118. package/utils/math/clamp01.js +6 -3
  119. package/utils/math/damp.cjs +28 -0
  120. package/utils/math/damp.js +5 -4
  121. package/utils/math/ease.cjs +88 -0
  122. package/utils/math/ease.js +50 -25
  123. package/utils/math/index.cjs +43 -0
  124. package/utils/math/index.js +17 -8
  125. package/utils/math/inertiaFinalValue.cjs +37 -0
  126. package/utils/math/inertiaFinalValue.js +8 -10
  127. package/utils/math/lerp.cjs +28 -0
  128. package/utils/math/lerp.js +5 -2
  129. package/utils/math/map.cjs +28 -0
  130. package/utils/math/map.js +5 -2
  131. package/utils/math/round.cjs +28 -0
  132. package/utils/math/round.js +5 -3
  133. package/utils/memoize.cjs +43 -0
  134. package/utils/memoize.js +10 -19
  135. package/utils/nextFrame.cjs +38 -0
  136. package/utils/nextFrame.d.ts +4 -3
  137. package/utils/nextFrame.js +13 -10
  138. package/utils/nextMicrotask.cjs +28 -0
  139. package/utils/nextMicrotask.d.ts +8 -0
  140. package/utils/nextMicrotask.js +6 -0
  141. package/utils/nextTick.cjs +30 -0
  142. package/utils/nextTick.d.ts +8 -0
  143. package/utils/nextTick.js +8 -0
  144. package/utils/object/autoBind.cjs +49 -0
  145. package/utils/object/autoBind.js +12 -22
  146. package/utils/object/getAllProperties.cjs +37 -0
  147. package/utils/object/getAllProperties.js +10 -13
  148. package/utils/object/index.cjs +33 -0
  149. package/utils/object/index.js +8 -3
  150. package/utils/object/isObject.cjs +28 -0
  151. package/utils/object/isObject.js +6 -3
  152. package/utils/scrollTo.cjs +80 -0
  153. package/utils/scrollTo.js +20 -40
  154. package/utils/string/index.cjs +47 -0
  155. package/utils/string/index.js +22 -10
  156. package/utils/string/withLeadingCharacters.cjs +32 -0
  157. package/utils/string/withLeadingCharacters.js +7 -4
  158. package/utils/string/withLeadingSlash.cjs +32 -0
  159. package/utils/string/withLeadingSlash.js +7 -4
  160. package/utils/string/withTrailingCharacters.cjs +32 -0
  161. package/utils/string/withTrailingCharacters.js +7 -4
  162. package/utils/string/withTrailingSlash.cjs +32 -0
  163. package/utils/string/withTrailingSlash.js +7 -4
  164. package/utils/string/withoutLeadingCharacters.cjs +28 -0
  165. package/utils/string/withoutLeadingCharacters.js +6 -3
  166. package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
  167. package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
  168. package/utils/string/withoutLeadingSlash.cjs +32 -0
  169. package/utils/string/withoutLeadingSlash.js +7 -4
  170. package/utils/string/withoutTrailingCharacters.cjs +28 -0
  171. package/utils/string/withoutTrailingCharacters.js +6 -3
  172. package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
  173. package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
  174. package/utils/string/withoutTrailingSlash.cjs +32 -0
  175. package/utils/string/withoutTrailingSlash.js +7 -4
  176. package/utils/throttle.cjs +36 -0
  177. package/utils/throttle.js +9 -9
  178. package/index.modern.js +0 -1
  179. package/index.umd.js +0 -1
@@ -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;
@@ -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;
@@ -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;
@@ -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 - 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;
package/utils/scrollTo.js CHANGED
@@ -1,75 +1,55 @@
1
- import damp from './math/damp.js';
2
- export default function scrollTo(selectorElement) {
3
- var {
4
- offset = 0,
5
- dampFactor = 0.2
6
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7
- var targetElement = null;
8
-
1
+ import damp from "./math/damp.js";
2
+ function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
3
+ let targetElement = null;
9
4
  if (selectorElement instanceof HTMLElement) {
10
5
  targetElement = selectorElement;
11
6
  } else {
12
7
  targetElement = document.querySelector(selectorElement);
13
8
  }
14
-
15
9
  if (!targetElement) {
16
10
  return Promise.resolve(window.pageYOffset);
17
11
  }
18
-
19
- var sizes = targetElement.getBoundingClientRect();
20
- var scrollMargin = getComputedStyle(targetElement).scrollMarginTop || '0';
21
- var max = document.documentElement.scrollHeight - window.innerHeight;
22
- var scrollTarget = sizes.top + window.pageYOffset + parseInt(scrollMargin, 10) + offset;
23
-
12
+ const sizes = targetElement.getBoundingClientRect();
13
+ const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
14
+ const max = document.documentElement.scrollHeight - window.innerHeight;
15
+ let scrollTarget = sizes.top + window.pageYOffset - parseInt(scrollMargin, 10) - offset;
24
16
  if (scrollTarget > max) {
25
17
  scrollTarget = max;
26
18
  }
27
-
28
- return new Promise(resolve => {
29
- var isScrolling = false;
30
- var scroll = window.pageYOffset;
31
- var dampScroll = window.pageYOffset;
32
-
19
+ return new Promise((resolve) => {
20
+ let isScrolling = false;
21
+ let scroll = window.pageYOffset;
22
+ let dampScroll = window.pageYOffset;
33
23
  function eventHandler() {
34
24
  isScrolling = false;
35
25
  }
36
-
37
26
  function end() {
38
- window.removeEventListener('wheel', eventHandler);
39
- window.removeEventListener('touchmove', eventHandler);
27
+ window.removeEventListener("wheel", eventHandler);
28
+ window.removeEventListener("touchmove", eventHandler);
40
29
  resolve(window.pageYOffset);
41
30
  }
42
-
43
31
  function loop() {
44
32
  if (!isScrolling) {
45
33
  return end();
46
34
  }
47
-
48
35
  dampScroll = damp(scroll, dampScroll, dampFactor);
49
- window.scrollTo({
50
- top: dampScroll
51
- });
52
-
36
+ window.scrollTo({ top: dampScroll });
53
37
  if (dampScroll === scroll) {
54
38
  isScrolling = false;
55
39
  }
56
-
57
40
  return requestAnimationFrame(loop);
58
41
  }
59
-
60
42
  function start(target) {
61
43
  isScrolling = true;
62
44
  dampScroll = window.pageYOffset;
63
45
  scroll = target;
64
- window.addEventListener('wheel', eventHandler, {
65
- passive: true
66
- });
67
- window.addEventListener('touchmove', eventHandler, {
68
- passive: true
69
- });
46
+ window.addEventListener("wheel", eventHandler, { passive: true });
47
+ window.addEventListener("touchmove", eventHandler, { passive: true });
70
48
  loop();
71
49
  }
72
-
73
50
  start(scrollTarget);
74
51
  });
75
- }
52
+ }
53
+ export {
54
+ scrollTo as default
55
+ };
@@ -0,0 +1,47 @@
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/string/index.js
23
+ var string_exports = {};
24
+ __export(string_exports, {
25
+ withLeadingCharacters: () => import_withLeadingCharacters.default,
26
+ withLeadingSlash: () => import_withLeadingSlash.default,
27
+ withTrailingCharacters: () => import_withTrailingCharacters.default,
28
+ withTrailingSlash: () => import_withTrailingSlash.default,
29
+ withoutLeadingCharacters: () => import_withoutLeadingCharacters.default,
30
+ withoutLeadingCharactersRecursive: () => import_withoutLeadingCharactersRecursive.default,
31
+ withoutLeadingSlash: () => import_withoutLeadingSlash.default,
32
+ withoutTrailingCharacters: () => import_withoutTrailingCharacters.default,
33
+ withoutTrailingCharactersRecursive: () => import_withoutTrailingCharactersRecursive.default,
34
+ withoutTrailingSlash: () => import_withoutTrailingSlash.default
35
+ });
36
+ module.exports = __toCommonJS(string_exports);
37
+ var import_withLeadingCharacters = __toESM(require("./withLeadingCharacters.cjs"), 1);
38
+ var import_withLeadingSlash = __toESM(require("./withLeadingSlash.cjs"), 1);
39
+ var import_withoutLeadingCharacters = __toESM(require("./withoutLeadingCharacters.cjs"), 1);
40
+ var import_withoutLeadingCharactersRecursive = __toESM(require("./withoutLeadingCharactersRecursive.cjs"), 1);
41
+ var import_withoutLeadingSlash = __toESM(require("./withoutLeadingSlash.cjs"), 1);
42
+ var import_withoutTrailingCharacters = __toESM(require("./withoutTrailingCharacters.cjs"), 1);
43
+ var import_withoutTrailingCharactersRecursive = __toESM(require("./withoutTrailingCharactersRecursive.cjs"), 1);
44
+ var import_withoutTrailingSlash = __toESM(require("./withoutTrailingSlash.cjs"), 1);
45
+ var import_withTrailingCharacters = __toESM(require("./withTrailingCharacters.cjs"), 1);
46
+ var import_withTrailingSlash = __toESM(require("./withTrailingSlash.cjs"), 1);
47
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,10 +1,22 @@
1
- export { default as withLeadingCharacters } from './withLeadingCharacters.js';
2
- export { default as withLeadingSlash } from './withLeadingSlash.js';
3
- export { default as withoutLeadingCharacters } from './withoutLeadingCharacters.js';
4
- export { default as withoutLeadingCharactersRecursive } from './withoutLeadingCharactersRecursive.js';
5
- export { default as withoutLeadingSlash } from './withoutLeadingSlash.js';
6
- export { default as withoutTrailingCharacters } from './withoutTrailingCharacters.js';
7
- export { default as withoutTrailingCharactersRecursive } from './withoutTrailingCharactersRecursive.js';
8
- export { default as withoutTrailingSlash } from './withoutTrailingSlash.js';
9
- export { default as withTrailingCharacters } from './withTrailingCharacters.js';
10
- export { default as withTrailingSlash } from './withTrailingSlash.js';
1
+ import { default as default2 } from "./withLeadingCharacters.js";
2
+ import { default as default3 } from "./withLeadingSlash.js";
3
+ import { default as default4 } from "./withoutLeadingCharacters.js";
4
+ import { default as default5 } from "./withoutLeadingCharactersRecursive.js";
5
+ import { default as default6 } from "./withoutLeadingSlash.js";
6
+ import { default as default7 } from "./withoutTrailingCharacters.js";
7
+ import { default as default8 } from "./withoutTrailingCharactersRecursive.js";
8
+ import { default as default9 } from "./withoutTrailingSlash.js";
9
+ import { default as default10 } from "./withTrailingCharacters.js";
10
+ import { default as default11 } from "./withTrailingSlash.js";
11
+ export {
12
+ default2 as withLeadingCharacters,
13
+ default3 as withLeadingSlash,
14
+ default10 as withTrailingCharacters,
15
+ default11 as withTrailingSlash,
16
+ default4 as withoutLeadingCharacters,
17
+ default5 as withoutLeadingCharactersRecursive,
18
+ default6 as withoutLeadingSlash,
19
+ default7 as withoutTrailingCharacters,
20
+ default8 as withoutTrailingCharactersRecursive,
21
+ default9 as withoutTrailingSlash
22
+ };
@@ -0,0 +1,32 @@
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/string/withLeadingCharacters.js
23
+ var withLeadingCharacters_exports = {};
24
+ __export(withLeadingCharacters_exports, {
25
+ default: () => withLeadingCharacters
26
+ });
27
+ module.exports = __toCommonJS(withLeadingCharacters_exports);
28
+ var import_withoutLeadingCharacters = __toESM(require("./withoutLeadingCharacters.cjs"), 1);
29
+ function withLeadingCharacters(string, characters) {
30
+ return `${characters}${(0, import_withoutLeadingCharacters.default)(string, characters)}`;
31
+ }
32
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,4 +1,7 @@
1
- import withoutLeadingCharacters from './withoutLeadingCharacters.js';
2
- export default function withLeadingCharacters(string, characters) {
3
- return "".concat(characters).concat(withoutLeadingCharacters(string, characters));
4
- }
1
+ import withoutLeadingCharacters from "./withoutLeadingCharacters.js";
2
+ function withLeadingCharacters(string, characters) {
3
+ return `${characters}${withoutLeadingCharacters(string, characters)}`;
4
+ }
5
+ export {
6
+ withLeadingCharacters as default
7
+ };
@@ -0,0 +1,32 @@
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/string/withLeadingSlash.js
23
+ var withLeadingSlash_exports = {};
24
+ __export(withLeadingSlash_exports, {
25
+ default: () => withLeadingSlash
26
+ });
27
+ module.exports = __toCommonJS(withLeadingSlash_exports);
28
+ var import_withLeadingCharacters = __toESM(require("./withLeadingCharacters.cjs"), 1);
29
+ function withLeadingSlash(string) {
30
+ return (0, import_withLeadingCharacters.default)(string, "/");
31
+ }
32
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,4 +1,7 @@
1
- import withLeadingCharacters from './withLeadingCharacters.js';
2
- export default function withLeadingSlash(string) {
3
- return withLeadingCharacters(string, '/');
4
- }
1
+ import withLeadingCharacters from "./withLeadingCharacters.js";
2
+ function withLeadingSlash(string) {
3
+ return withLeadingCharacters(string, "/");
4
+ }
5
+ export {
6
+ withLeadingSlash as default
7
+ };