@studiometa/js-toolkit 2.0.0-beta.1 → 2.0.0-beta.13
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.
- package/Base/index.cjs +294 -0
- package/Base/index.d.ts +27 -1
- package/Base/index.js +149 -179
- package/Base/managers/ChildrenManager.cjs +124 -0
- package/Base/managers/ChildrenManager.js +29 -55
- package/Base/managers/EventsManager.cjs +184 -0
- package/Base/managers/EventsManager.d.ts +3 -1
- package/Base/managers/EventsManager.js +85 -127
- package/Base/managers/OptionsManager.cjs +175 -0
- package/Base/managers/OptionsManager.d.ts +2 -0
- package/Base/managers/OptionsManager.js +46 -88
- package/Base/managers/RefsManager.cjs +98 -0
- package/Base/managers/RefsManager.d.ts +2 -0
- package/Base/managers/RefsManager.js +24 -35
- package/Base/managers/ServicesManager.cjs +132 -0
- package/Base/managers/ServicesManager.d.ts +29 -4
- package/Base/managers/ServicesManager.js +33 -63
- package/Base/utils.cjs +45 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +49 -0
- package/decorators/index.d.ts +8 -9
- package/decorators/index.js +18 -9
- package/decorators/withBreakpointManager.cjs +91 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +116 -0
- package/decorators/withBreakpointObserver.js +40 -88
- package/decorators/withDrag.cjs +54 -0
- package/decorators/withDrag.js +16 -18
- package/decorators/withExtraConfig.cjs +44 -0
- package/decorators/withExtraConfig.js +11 -12
- package/decorators/withIntersectionObserver.cjs +61 -0
- package/decorators/withIntersectionObserver.js +23 -31
- package/decorators/withMountWhenInView.cjs +68 -0
- package/decorators/withMountWhenInView.js +31 -55
- package/decorators/withScrolledInView.cjs +112 -0
- package/decorators/withScrolledInView.d.ts +4 -1
- package/decorators/withScrolledInView.js +77 -73
- package/decorators/withVue2.cjs +60 -0
- package/decorators/withVue2.js +21 -32
- package/helpers/createApp.cjs +56 -0
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +56 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +52 -0
- package/helpers/importWhenIdle.js +13 -17
- package/helpers/importWhenVisible.cjs +54 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +41 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +39 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +38 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -3
- package/services/Service.cjs +75 -0
- package/services/Service.d.ts +22 -17
- package/services/Service.js +14 -28
- package/services/drag.cjs +194 -0
- package/services/drag.d.ts +4 -18
- package/services/drag.js +103 -156
- package/services/index.cjs +47 -0
- package/services/index.d.ts +13 -10
- package/services/index.js +16 -8
- package/services/key.cjs +101 -0
- package/services/key.d.ts +4 -13
- package/services/key.js +58 -77
- package/services/load.cjs +70 -0
- package/services/load.d.ts +3 -13
- package/services/load.js +31 -36
- package/services/pointer.cjs +159 -0
- package/services/pointer.d.ts +4 -13
- package/services/pointer.js +91 -121
- package/services/raf.cjs +81 -0
- package/services/raf.d.ts +3 -13
- package/services/raf.js +32 -52
- package/services/resize.cjs +106 -0
- package/services/resize.d.ts +3 -13
- package/services/resize.js +52 -52
- package/services/scroll.cjs +129 -0
- package/services/scroll.d.ts +3 -13
- package/services/scroll.js +75 -89
- package/utils/collide/boundingRectToCircle.cjs +38 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +38 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +50 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +35 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +32 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +32 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +45 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +48 -0
- package/utils/css/classes.js +13 -12
- package/utils/css/index.cjs +41 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +10 -5
- package/utils/css/matrix.cjs +33 -0
- package/utils/css/matrix.js +6 -5
- package/utils/css/styles.cjs +51 -0
- package/utils/css/styles.js +13 -12
- package/utils/css/transition.cjs +121 -0
- package/utils/css/transition.js +62 -117
- package/utils/debounce.cjs +38 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +88 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +95 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +57 -0
- package/utils/index.d.ts +12 -35
- package/utils/index.js +30 -17
- package/utils/keyCodes.cjs +39 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +32 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +38 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +32 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +92 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +48 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +41 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +32 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +32 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +32 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +47 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +44 -0
- package/utils/nextFrame.js +14 -9
- package/utils/object/autoBind.cjs +55 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +41 -0
- package/utils/object/getAllProperties.js +11 -14
- package/utils/object/index.cjs +39 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +32 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +86 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +53 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +38 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +38 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +38 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +38 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +32 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +43 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +38 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +32 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +43 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +38 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +40 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
package/utils/history.js
CHANGED
|
@@ -1,93 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import isObject from './object/isObject.js';
|
|
8
|
-
|
|
1
|
+
import isObject from "./object/isObject.js";
|
|
9
2
|
function updateUrlSearchParam(params, name, value) {
|
|
10
|
-
if (value ===
|
|
3
|
+
if (value === "" || value === null || value === void 0) {
|
|
11
4
|
if (params.has(name)) {
|
|
12
5
|
params.delete(name);
|
|
13
6
|
}
|
|
14
|
-
|
|
15
7
|
return params;
|
|
16
8
|
}
|
|
17
|
-
|
|
18
9
|
if (Array.isArray(value)) {
|
|
19
10
|
value.forEach((val, index) => {
|
|
20
|
-
|
|
11
|
+
const arrayName = `${name}[${index}]`;
|
|
21
12
|
updateUrlSearchParam(params, arrayName, val);
|
|
22
13
|
});
|
|
23
14
|
return params;
|
|
24
15
|
}
|
|
25
|
-
|
|
26
16
|
if (isObject(value)) {
|
|
27
|
-
Object.entries(value).forEach(
|
|
28
|
-
|
|
29
|
-
var objectName = "".concat(name, "[").concat(key, "]");
|
|
17
|
+
Object.entries(value).forEach(([key, val]) => {
|
|
18
|
+
const objectName = `${name}[${key}]`;
|
|
30
19
|
updateUrlSearchParam(params, objectName, val);
|
|
31
20
|
});
|
|
32
21
|
return params;
|
|
33
22
|
}
|
|
34
|
-
|
|
35
23
|
params.set(name, value);
|
|
36
24
|
return params;
|
|
37
25
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var defaultSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : typeof window === 'undefined' ? '' : window.location.search;
|
|
41
|
-
return Object.entries(obj).reduce((urlSearchParams, _ref2) => {
|
|
42
|
-
var [name, value] = _ref2;
|
|
43
|
-
return updateUrlSearchParam(urlSearchParams, name, value);
|
|
44
|
-
}, new URLSearchParams(defaultSearch));
|
|
26
|
+
function objectToURLSearchParams(obj, defaultSearch = typeof window === "undefined" ? "" : window.location.search) {
|
|
27
|
+
return Object.entries(obj).reduce((urlSearchParams, [name, value]) => updateUrlSearchParam(urlSearchParams, name, value), new URLSearchParams(defaultSearch));
|
|
45
28
|
}
|
|
46
|
-
|
|
47
|
-
function updateHistory(mode, options) {
|
|
48
|
-
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
49
|
-
var title = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
50
|
-
|
|
29
|
+
function updateHistory(mode, options, data = {}, title = "") {
|
|
51
30
|
if (!window.history) {
|
|
52
31
|
return;
|
|
53
32
|
}
|
|
54
|
-
|
|
55
|
-
var {
|
|
56
|
-
path,
|
|
57
|
-
search,
|
|
58
|
-
hash
|
|
59
|
-
} = _objectSpread({
|
|
33
|
+
const { path, search, hash } = {
|
|
60
34
|
path: window.location.pathname,
|
|
61
35
|
search: new URLSearchParams(window.location.search),
|
|
62
|
-
hash: window.location.hash
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
36
|
+
hash: window.location.hash,
|
|
37
|
+
...options
|
|
38
|
+
};
|
|
39
|
+
let url = path;
|
|
40
|
+
const mergedSearch = search instanceof URLSearchParams ? search : objectToURLSearchParams(search);
|
|
68
41
|
if (mergedSearch.toString()) {
|
|
69
|
-
url +=
|
|
42
|
+
url += `?${mergedSearch.toString()}`;
|
|
70
43
|
}
|
|
71
|
-
|
|
72
44
|
if (hash) {
|
|
73
|
-
if (hash.startsWith(
|
|
45
|
+
if (hash.startsWith("#")) {
|
|
74
46
|
url += hash;
|
|
75
47
|
} else {
|
|
76
|
-
url +=
|
|
48
|
+
url += `#${hash}`;
|
|
77
49
|
}
|
|
78
50
|
}
|
|
79
|
-
|
|
80
|
-
var method = "".concat(mode, "State");
|
|
51
|
+
const method = `${mode}State`;
|
|
81
52
|
window.history[method](data, title, url);
|
|
82
53
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
86
|
-
var title = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
87
|
-
updateHistory('push', options, data, title);
|
|
54
|
+
function push(options, data = {}, title = "") {
|
|
55
|
+
updateHistory("push", options, data, title);
|
|
88
56
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
57
|
+
function replace(options, data = {}, title = "") {
|
|
58
|
+
updateHistory("replace", options, data, title);
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
objectToURLSearchParams,
|
|
62
|
+
push,
|
|
63
|
+
replace
|
|
64
|
+
};
|
package/utils/index.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
|
|
29
|
+
// packages/js-toolkit/utils/index.js
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
debounce: () => import_debounce.default,
|
|
33
|
+
focusTrap: () => import_focusTrap.default,
|
|
34
|
+
historyPush: () => import_history.push,
|
|
35
|
+
historyReplace: () => import_history.replace,
|
|
36
|
+
keyCodes: () => import_keyCodes.default,
|
|
37
|
+
matrix: () => import_css.matrix,
|
|
38
|
+
memoize: () => import_memoize.default,
|
|
39
|
+
nextFrame: () => import_nextFrame.default,
|
|
40
|
+
objectToURLSearchParams: () => import_history.objectToURLSearchParams,
|
|
41
|
+
scrollTo: () => import_scrollTo.default,
|
|
42
|
+
throttle: () => import_throttle.default,
|
|
43
|
+
transition: () => import_css.transition
|
|
44
|
+
});
|
|
45
|
+
var import_debounce = __toESM(require("./debounce.cjs"), 1);
|
|
46
|
+
var import_focusTrap = __toESM(require("./focusTrap.cjs"), 1);
|
|
47
|
+
var import_keyCodes = __toESM(require("./keyCodes.cjs"), 1);
|
|
48
|
+
var import_memoize = __toESM(require("./memoize.cjs"), 1);
|
|
49
|
+
var import_nextFrame = __toESM(require("./nextFrame.cjs"), 1);
|
|
50
|
+
var import_throttle = __toESM(require("./throttle.cjs"), 1);
|
|
51
|
+
var import_scrollTo = __toESM(require("./scrollTo.cjs"), 1);
|
|
52
|
+
var import_css = require("./css/index.cjs");
|
|
53
|
+
var import_history = require("./history.cjs");
|
|
54
|
+
__reExport(utils_exports, require("./collide/index.cjs"));
|
|
55
|
+
__reExport(utils_exports, require("./math/index.cjs"));
|
|
56
|
+
__reExport(utils_exports, require("./string/index.cjs"));
|
|
57
|
+
module.exports = __toCommonJS(utils_exports);
|
package/utils/index.d.ts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { clamp01 } from "./math/index.js";
|
|
14
|
-
import { damp } from "./math/index.js";
|
|
15
|
-
import { inertiaFinalValue } from "./math/index.js";
|
|
16
|
-
import { lerp } from "./math/index.js";
|
|
17
|
-
import { map } from "./math/index.js";
|
|
18
|
-
import { round } from "./math/index.js";
|
|
19
|
-
import { withLeadingCharacters } from "./string/index.js";
|
|
20
|
-
import { withLeadingSlash } from "./string/index.js";
|
|
21
|
-
import { withoutLeadingCharacters } from "./string/index.js";
|
|
22
|
-
import { withoutLeadingCharactersRecursive } from "./string/index.js";
|
|
23
|
-
import { withoutLeadingSlash } from "./string/index.js";
|
|
24
|
-
import { withoutTrailingCharacters } from "./string/index.js";
|
|
25
|
-
import { withoutTrailingCharactersRecursive } from "./string/index.js";
|
|
26
|
-
import { withoutTrailingSlash } from "./string/index.js";
|
|
27
|
-
import { withTrailingCharacters } from "./string/index.js";
|
|
28
|
-
import { withTrailingSlash } from "./string/index.js";
|
|
29
|
-
import debounce from "./debounce.js";
|
|
30
|
-
import focusTrap from "./focusTrap.js";
|
|
31
|
-
import keyCodes from "./keyCodes.js";
|
|
32
|
-
import memoize from "./memoize.js";
|
|
33
|
-
import nextFrame from "./nextFrame.js";
|
|
34
|
-
import throttle from "./throttle.js";
|
|
35
|
-
export { matrix, transition, collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle, objectToURLSearchParams, historyPush, historyReplace, clamp, clamp01, damp, inertiaFinalValue, lerp, map, round, withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash, debounce, focusTrap, keyCodes, memoize, nextFrame, throttle };
|
|
1
|
+
export { default as debounce } from "./debounce.js";
|
|
2
|
+
export { default as focusTrap } from "./focusTrap.js";
|
|
3
|
+
export { default as keyCodes } from "./keyCodes.js";
|
|
4
|
+
export { default as memoize } from "./memoize.js";
|
|
5
|
+
export { default as nextFrame } from "./nextFrame.js";
|
|
6
|
+
export { default as throttle } from "./throttle.js";
|
|
7
|
+
export { default as scrollTo } from "./scrollTo.js";
|
|
8
|
+
export * from "./collide/index.js";
|
|
9
|
+
export * from "./math/index.js";
|
|
10
|
+
export * from "./string/index.js";
|
|
11
|
+
export { matrix, transition } from "./css/index.js";
|
|
12
|
+
export { objectToURLSearchParams, push as historyPush, replace as historyReplace } from "./history.js";
|
package/utils/index.js
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
1
|
+
import { default as default2 } from "./debounce.js";
|
|
2
|
+
import { default as default3 } from "./focusTrap.js";
|
|
3
|
+
import { default as default4 } from "./keyCodes.js";
|
|
4
|
+
import { default as default5 } from "./memoize.js";
|
|
5
|
+
import { default as default6 } from "./nextFrame.js";
|
|
6
|
+
import { default as default7 } from "./throttle.js";
|
|
7
|
+
import { default as default8 } from "./scrollTo.js";
|
|
8
|
+
import { matrix, transition } from "./css/index.js";
|
|
9
|
+
import {
|
|
10
|
+
objectToURLSearchParams,
|
|
11
|
+
push,
|
|
12
|
+
replace
|
|
13
|
+
} from "./history.js";
|
|
14
|
+
export * from "./collide/index.js";
|
|
15
|
+
export * from "./math/index.js";
|
|
16
|
+
export * from "./string/index.js";
|
|
17
|
+
export {
|
|
18
|
+
default2 as debounce,
|
|
19
|
+
default3 as focusTrap,
|
|
20
|
+
push as historyPush,
|
|
21
|
+
replace as historyReplace,
|
|
22
|
+
default4 as keyCodes,
|
|
23
|
+
matrix,
|
|
24
|
+
default5 as memoize,
|
|
25
|
+
default6 as nextFrame,
|
|
26
|
+
objectToURLSearchParams,
|
|
27
|
+
default8 as scrollTo,
|
|
28
|
+
default7 as throttle,
|
|
29
|
+
transition
|
|
30
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/utils/keyCodes.js
|
|
25
|
+
var keyCodes_exports = {};
|
|
26
|
+
__export(keyCodes_exports, {
|
|
27
|
+
default: () => keyCodes_default
|
|
28
|
+
});
|
|
29
|
+
var keyCodes_default = {
|
|
30
|
+
ENTER: 13,
|
|
31
|
+
SPACE: 32,
|
|
32
|
+
TAB: 9,
|
|
33
|
+
ESC: 27,
|
|
34
|
+
LEFT: 37,
|
|
35
|
+
UP: 38,
|
|
36
|
+
RIGHT: 39,
|
|
37
|
+
DOWN: 40
|
|
38
|
+
};
|
|
39
|
+
module.exports = __toCommonJS(keyCodes_exports);
|
package/utils/keyCodes.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/utils/math/clamp.js
|
|
25
|
+
var clamp_exports = {};
|
|
26
|
+
__export(clamp_exports, {
|
|
27
|
+
default: () => clamp
|
|
28
|
+
});
|
|
29
|
+
function clamp(value, min, max) {
|
|
30
|
+
return min < max ? value < min ? min : value > max ? max : value : value < max ? max : value > min ? min : value;
|
|
31
|
+
}
|
|
32
|
+
module.exports = __toCommonJS(clamp_exports);
|
package/utils/math/clamp.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
|
|
29
|
+
// packages/js-toolkit/utils/math/clamp01.js
|
|
30
|
+
var clamp01_exports = {};
|
|
31
|
+
__export(clamp01_exports, {
|
|
32
|
+
default: () => clamp01
|
|
33
|
+
});
|
|
34
|
+
var import_clamp = __toESM(require("./clamp.cjs"), 1);
|
|
35
|
+
function clamp01(value) {
|
|
36
|
+
return (0, import_clamp.default)(value, 0, 1);
|
|
37
|
+
}
|
|
38
|
+
module.exports = __toCommonJS(clamp01_exports);
|
package/utils/math/clamp01.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/utils/math/damp.js
|
|
25
|
+
var damp_exports = {};
|
|
26
|
+
__export(damp_exports, {
|
|
27
|
+
default: () => damp
|
|
28
|
+
});
|
|
29
|
+
function damp(targetValue, currentValue, factor = 0.5, precision = 0.01) {
|
|
30
|
+
return Math.abs(targetValue - currentValue) < precision ? targetValue : currentValue + (targetValue - currentValue) * factor;
|
|
31
|
+
}
|
|
32
|
+
module.exports = __toCommonJS(damp_exports);
|
package/utils/math/damp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var factor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
|
|
3
|
-
var precision = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.01;
|
|
1
|
+
function damp(targetValue, currentValue, factor = 0.5, precision = 0.01) {
|
|
4
2
|
return Math.abs(targetValue - currentValue) < precision ? targetValue : currentValue + (targetValue - currentValue) * factor;
|
|
5
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
damp as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/utils/math/ease.js
|
|
25
|
+
var ease_exports = {};
|
|
26
|
+
__export(ease_exports, {
|
|
27
|
+
createEaseInOut: () => createEaseInOut,
|
|
28
|
+
createEaseOut: () => createEaseOut,
|
|
29
|
+
easeInCirc: () => easeInCirc,
|
|
30
|
+
easeInCubic: () => easeInCubic,
|
|
31
|
+
easeInExpo: () => easeInExpo,
|
|
32
|
+
easeInOutCirc: () => easeInOutCirc,
|
|
33
|
+
easeInOutCubic: () => easeInOutCubic,
|
|
34
|
+
easeInOutExpo: () => easeInOutExpo,
|
|
35
|
+
easeInOutQuad: () => easeInOutQuad,
|
|
36
|
+
easeInOutQuart: () => easeInOutQuart,
|
|
37
|
+
easeInOutQuint: () => easeInOutQuint,
|
|
38
|
+
easeInOutSine: () => easeInOutSine,
|
|
39
|
+
easeInQuad: () => easeInQuad,
|
|
40
|
+
easeInQuart: () => easeInQuart,
|
|
41
|
+
easeInQuint: () => easeInQuint,
|
|
42
|
+
easeInSine: () => easeInSine,
|
|
43
|
+
easeOutCirc: () => easeOutCirc,
|
|
44
|
+
easeOutCubic: () => easeOutCubic,
|
|
45
|
+
easeOutExpo: () => easeOutExpo,
|
|
46
|
+
easeOutQuad: () => easeOutQuad,
|
|
47
|
+
easeOutQuart: () => easeOutQuart,
|
|
48
|
+
easeOutQuint: () => easeOutQuint,
|
|
49
|
+
easeOutSine: () => easeOutSine
|
|
50
|
+
});
|
|
51
|
+
function createEaseOut(easeIn) {
|
|
52
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
53
|
+
}
|
|
54
|
+
function createEaseInOut(easeIn) {
|
|
55
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
56
|
+
}
|
|
57
|
+
function easeInQuad(progress) {
|
|
58
|
+
return progress ** 2;
|
|
59
|
+
}
|
|
60
|
+
var easeOutQuad = createEaseOut(easeInQuad);
|
|
61
|
+
var easeInOutQuad = createEaseInOut(easeInQuad);
|
|
62
|
+
function easeInCubic(progress) {
|
|
63
|
+
return progress ** 3;
|
|
64
|
+
}
|
|
65
|
+
var easeOutCubic = createEaseOut(easeInCubic);
|
|
66
|
+
var easeInOutCubic = createEaseInOut(easeInCubic);
|
|
67
|
+
function easeInQuart(progress) {
|
|
68
|
+
return progress ** 4;
|
|
69
|
+
}
|
|
70
|
+
var easeOutQuart = createEaseOut(easeInQuart);
|
|
71
|
+
var easeInOutQuart = createEaseInOut(easeInQuart);
|
|
72
|
+
function easeInQuint(progress) {
|
|
73
|
+
return progress ** 5;
|
|
74
|
+
}
|
|
75
|
+
var easeOutQuint = createEaseOut(easeInQuint);
|
|
76
|
+
var easeInOutQuint = createEaseInOut(easeInQuint);
|
|
77
|
+
function easeInSine(progress) {
|
|
78
|
+
return progress === 1 ? 1 : -Math.cos(progress * Math.PI / 2) + 1;
|
|
79
|
+
}
|
|
80
|
+
var easeOutSine = createEaseOut(easeInSine);
|
|
81
|
+
var easeInOutSine = createEaseInOut(easeInSine);
|
|
82
|
+
function easeInCirc(progress) {
|
|
83
|
+
return -(Math.sqrt(1 - progress * progress) - 1);
|
|
84
|
+
}
|
|
85
|
+
var easeOutCirc = createEaseOut(easeInCirc);
|
|
86
|
+
var easeInOutCirc = createEaseInOut(easeInCirc);
|
|
87
|
+
function easeInExpo(progress) {
|
|
88
|
+
return 2 ** (10 * (progress - 1));
|
|
89
|
+
}
|
|
90
|
+
var easeOutExpo = createEaseOut(easeInExpo);
|
|
91
|
+
var easeInOutExpo = createEaseInOut(easeInExpo);
|
|
92
|
+
module.exports = __toCommonJS(ease_exports);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {(progress: number) => number} EasingFunction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create an out easing function.
|
|
6
|
+
*
|
|
7
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
8
|
+
* @returns {EasingFunction} The out function.
|
|
9
|
+
*/
|
|
10
|
+
export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
11
|
+
/**
|
|
12
|
+
* Create an in-out easing function.
|
|
13
|
+
*
|
|
14
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
+
* @return {EasingFunction} The in-out function.
|
|
16
|
+
*/
|
|
17
|
+
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
|
+
/**
|
|
19
|
+
* @type {EasingFunction}
|
|
20
|
+
*/
|
|
21
|
+
export function easeInQuad(progress: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Ease in cubic.
|
|
24
|
+
*
|
|
25
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
26
|
+
* @return {number} Eased value between 0 and 1.
|
|
27
|
+
*/
|
|
28
|
+
export function easeInCubic(progress: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Ease in quart.
|
|
31
|
+
*
|
|
32
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
33
|
+
* @return {number} Eased value between 0 and 1.
|
|
34
|
+
*/
|
|
35
|
+
export function easeInQuart(progress: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Ease in quint.
|
|
38
|
+
*
|
|
39
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
40
|
+
* @return {number} Eased value between 0 and 1.
|
|
41
|
+
*/
|
|
42
|
+
export function easeInQuint(progress: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Ease in sine.
|
|
45
|
+
*
|
|
46
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
47
|
+
* @return {number} Eased value between 0 and 1.
|
|
48
|
+
*/
|
|
49
|
+
export function easeInSine(progress: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Ease in circ.
|
|
52
|
+
*
|
|
53
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
54
|
+
* @return {number} Eased value between 0 and 1.
|
|
55
|
+
*/
|
|
56
|
+
export function easeInCirc(progress: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Ease in exponential.
|
|
59
|
+
*
|
|
60
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
61
|
+
* @return {number} Eased value between 0 and 1.
|
|
62
|
+
*/
|
|
63
|
+
export function easeInExpo(progress: number): number;
|
|
64
|
+
export function easeOutQuad(progress: number): number;
|
|
65
|
+
export function easeInOutQuad(progress: number): number;
|
|
66
|
+
export function easeOutCubic(progress: number): number;
|
|
67
|
+
export function easeInOutCubic(progress: number): number;
|
|
68
|
+
export function easeOutQuart(progress: number): number;
|
|
69
|
+
export function easeInOutQuart(progress: number): number;
|
|
70
|
+
export function easeOutQuint(progress: number): number;
|
|
71
|
+
export function easeInOutQuint(progress: number): number;
|
|
72
|
+
export function easeOutSine(progress: number): number;
|
|
73
|
+
export function easeInOutSine(progress: number): number;
|
|
74
|
+
export function easeOutCirc(progress: number): number;
|
|
75
|
+
export function easeInOutCirc(progress: number): number;
|
|
76
|
+
export function easeOutExpo(progress: number): number;
|
|
77
|
+
export function easeInOutExpo(progress: number): number;
|
|
78
|
+
export type EasingFunction = (progress: number) => number;
|