@studiometa/js-toolkit 2.0.0-beta.7 → 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.
- package/Base/index.cjs +285 -0
- package/Base/index.d.ts +13 -4
- package/Base/index.js +114 -197
- package/Base/managers/ChildrenManager.cjs +146 -0
- package/Base/managers/ChildrenManager.d.ts +9 -1
- package/Base/managers/ChildrenManager.js +60 -59
- package/Base/managers/EventsManager.cjs +183 -0
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +174 -0
- package/Base/managers/OptionsManager.d.ts +9 -5
- package/Base/managers/OptionsManager.js +60 -90
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.js +30 -35
- package/Base/managers/ServicesManager.cjs +131 -0
- package/Base/managers/ServicesManager.js +39 -67
- package/Base/utils.cjs +41 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +45 -0
- package/decorators/index.d.ts +9 -9
- package/decorators/index.js +20 -9
- package/decorators/withBreakpointManager.cjs +85 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +115 -0
- package/decorators/withBreakpointObserver.js +44 -86
- package/decorators/withDrag.cjs +53 -0
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +43 -0
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withFreezedOptions.cjs +36 -0
- package/decorators/withFreezedOptions.d.ts +14 -0
- package/decorators/withFreezedOptions.js +14 -0
- package/decorators/withIntersectionObserver.cjs +62 -0
- package/decorators/withIntersectionObserver.js +29 -32
- package/decorators/withMountWhenInView.cjs +69 -0
- package/decorators/withMountWhenInView.js +31 -52
- package/decorators/withScrolledInView.cjs +114 -0
- package/decorators/withScrolledInView.d.ts +2 -1
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +60 -0
- package/decorators/withVue2.js +26 -32
- package/helpers/createApp.cjs +52 -0
- package/helpers/createApp.d.ts +2 -2
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +52 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +49 -0
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +50 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +35 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +35 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +33 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -4
- package/services/Service.cjs +76 -0
- package/services/Service.js +19 -32
- package/services/drag.cjs +213 -0
- package/services/drag.d.ts +1 -0
- package/services/drag.js +64 -68
- package/services/index.cjs +41 -0
- package/services/index.d.ts +7 -8
- package/services/index.js +16 -8
- package/services/key.cjs +104 -0
- package/services/key.js +28 -36
- package/services/load.cjs +72 -0
- package/services/load.js +17 -19
- package/services/pointer.cjs +162 -0
- package/services/pointer.js +43 -60
- package/services/raf.cjs +83 -0
- package/services/raf.js +20 -28
- package/services/resize.cjs +108 -0
- package/services/resize.js +33 -42
- package/services/scroll.cjs +131 -0
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +34 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +34 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +46 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +31 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +28 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +28 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +39 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +47 -0
- package/utils/css/classes.d.ts +10 -9
- package/utils/css/classes.js +18 -14
- package/utils/css/index.cjs +38 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +13 -5
- package/utils/css/matrix.cjs +30 -0
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +44 -0
- package/utils/css/styles.d.ts +6 -18
- package/utils/css/styles.js +12 -12
- package/utils/css/transition.cjs +120 -0
- package/utils/css/transition.d.ts +15 -9
- package/utils/css/transition.js +70 -119
- package/utils/debounce.cjs +34 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +82 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +89 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +54 -0
- package/utils/index.d.ts +14 -35
- package/utils/index.js +32 -17
- package/utils/keyCodes.cjs +35 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +28 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +32 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +28 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +88 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +43 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +37 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +28 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +28 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +28 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +43 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +38 -0
- package/utils/nextFrame.d.ts +4 -3
- package/utils/nextFrame.js +13 -10
- package/utils/nextMicrotask.cjs +28 -0
- package/utils/nextMicrotask.d.ts +8 -0
- package/utils/nextMicrotask.js +6 -0
- package/utils/nextTick.cjs +30 -0
- package/utils/nextTick.d.ts +8 -0
- package/utils/nextTick.js +8 -0
- package/utils/object/autoBind.cjs +49 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +37 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +33 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +28 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +80 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +47 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +32 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +32 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +32 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +32 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +28 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +32 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +28 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +32 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +36 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
|
@@ -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/collide/collideRectRect.js
|
|
20
|
+
var collideRectRect_exports = {};
|
|
21
|
+
__export(collideRectRect_exports, {
|
|
22
|
+
default: () => collideRectRect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collideRectRect_exports);
|
|
25
|
+
function collideRectRect(rect1, rect2) {
|
|
26
|
+
return rect1.x + rect1.width >= rect2.x && rect1.x <= rect2.x + rect2.width && rect1.y + rect1.height >= rect2.y && rect1.y <= rect2.y + rect2.height;
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function collideRectRect(rect1, rect2) {
|
|
2
2
|
return rect1.x + rect1.width >= rect2.x && rect1.x <= rect2.x + rect2.width && rect1.y + rect1.height >= rect2.y && rect1.y <= rect2.y + rect2.height;
|
|
3
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
collideRectRect as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
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/collide/index.js
|
|
23
|
+
var collide_exports = {};
|
|
24
|
+
__export(collide_exports, {
|
|
25
|
+
boundingRectToCircle: () => import_boundingRectToCircle.default,
|
|
26
|
+
collideCircleCircle: () => import_collideCircleCircle.default,
|
|
27
|
+
collideCircleRect: () => import_collideCircleRect.default,
|
|
28
|
+
collidePointCircle: () => import_collidePointCircle.default,
|
|
29
|
+
collidePointRect: () => import_collidePointRect.default,
|
|
30
|
+
collideRectRect: () => import_collideRectRect.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(collide_exports);
|
|
33
|
+
var import_boundingRectToCircle = __toESM(require("./boundingRectToCircle.cjs"), 1);
|
|
34
|
+
var import_collideCircleCircle = __toESM(require("./collideCircleCircle.cjs"), 1);
|
|
35
|
+
var import_collideCircleRect = __toESM(require("./collideCircleRect.cjs"), 1);
|
|
36
|
+
var import_collidePointCircle = __toESM(require("./collidePointCircle.cjs"), 1);
|
|
37
|
+
var import_collidePointRect = __toESM(require("./collidePointRect.cjs"), 1);
|
|
38
|
+
var import_collideRectRect = __toESM(require("./collideRectRect.cjs"), 1);
|
|
39
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/collide/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { boundingRectToCircle, collideCircleCircle, collideCircleRect, collidePointCircle, collidePointRect, collideRectRect };
|
|
1
|
+
export { default as boundingRectToCircle } from "./boundingRectToCircle.js";
|
|
2
|
+
export { default as collideCircleCircle } from "./collideCircleCircle.js";
|
|
3
|
+
export { default as collideCircleRect } from "./collideCircleRect.js";
|
|
4
|
+
export { default as collidePointCircle } from "./collidePointCircle.js";
|
|
5
|
+
export { default as collidePointRect } from "./collidePointRect.js";
|
|
6
|
+
export { default as collideRectRect } from "./collideRectRect.js";
|
package/utils/collide/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
export {
|
|
1
|
+
import { default as default2 } from "./boundingRectToCircle.js";
|
|
2
|
+
import { default as default3 } from "./collideCircleCircle.js";
|
|
3
|
+
import { default as default4 } from "./collideCircleRect.js";
|
|
4
|
+
import { default as default5 } from "./collidePointCircle.js";
|
|
5
|
+
import { default as default6 } from "./collidePointRect.js";
|
|
6
|
+
import { default as default7 } from "./collideRectRect.js";
|
|
7
|
+
export {
|
|
8
|
+
default2 as boundingRectToCircle,
|
|
9
|
+
default3 as collideCircleCircle,
|
|
10
|
+
default4 as collideCircleRect,
|
|
11
|
+
default5 as collidePointCircle,
|
|
12
|
+
default6 as collidePointRect,
|
|
13
|
+
default7 as collideRectRect
|
|
14
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
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/css/classes.js
|
|
20
|
+
var classes_exports = {};
|
|
21
|
+
__export(classes_exports, {
|
|
22
|
+
add: () => add,
|
|
23
|
+
remove: () => remove,
|
|
24
|
+
toggle: () => toggle
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(classes_exports);
|
|
27
|
+
function setClasses(element, classNames, method = "add", forceToggle = void 0) {
|
|
28
|
+
if (!element || !classNames) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const normalizedClassNames = Array.isArray(classNames) ? classNames : classNames.split(" ");
|
|
32
|
+
if (method !== "toggle") {
|
|
33
|
+
element.classList[method](...normalizedClassNames);
|
|
34
|
+
} else {
|
|
35
|
+
normalizedClassNames.forEach((className) => element.classList[method](className, forceToggle));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function add(element, classNames) {
|
|
39
|
+
setClasses(element, classNames);
|
|
40
|
+
}
|
|
41
|
+
function remove(element, classNames) {
|
|
42
|
+
setClasses(element, classNames, "remove");
|
|
43
|
+
}
|
|
44
|
+
function toggle(element, classNames, force = void 0) {
|
|
45
|
+
setClasses(element, classNames, "toggle", force);
|
|
46
|
+
}
|
|
47
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/classes.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add class names to an element.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param {HTMLElement} element The element to update.
|
|
5
|
+
* @param {string|string[]} classNames A string of class names.
|
|
6
6
|
* @return {void}
|
|
7
7
|
*/
|
|
8
|
-
export function add(element: HTMLElement, classNames: string): void;
|
|
8
|
+
export function add(element: HTMLElement, classNames: string | string[]): void;
|
|
9
9
|
/**
|
|
10
10
|
* Remove class names from an element.
|
|
11
11
|
*
|
|
12
|
-
* @param {HTMLElement}
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {HTMLElement} element The element to update.
|
|
13
|
+
* @param {string|string[]} classNames A string of class names.
|
|
14
14
|
* @return {void}
|
|
15
15
|
*/
|
|
16
|
-
export function remove(element: HTMLElement, classNames: string): void;
|
|
16
|
+
export function remove(element: HTMLElement, classNames: string | string[]): void;
|
|
17
17
|
/**
|
|
18
18
|
* Toggle class names from an element.
|
|
19
19
|
*
|
|
20
|
-
* @param {HTMLElement}
|
|
21
|
-
* @param {
|
|
20
|
+
* @param {HTMLElement} element The element to update.
|
|
21
|
+
* @param {string|string[]} classNames A string of class names.
|
|
22
|
+
* @param {boolean} [force] Force toggle?
|
|
22
23
|
* @return {void}
|
|
23
24
|
*/
|
|
24
|
-
export function toggle(element: HTMLElement, classNames: string): void;
|
|
25
|
+
export function toggle(element: HTMLElement, classNames: string | string[], force?: boolean): void;
|
package/utils/css/classes.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
function setClasses(element, classNames) {
|
|
2
|
-
var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'add';
|
|
3
|
-
|
|
1
|
+
function setClasses(element, classNames, method = "add", forceToggle = void 0) {
|
|
4
2
|
if (!element || !classNames) {
|
|
5
3
|
return;
|
|
6
4
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
element.classList[method](
|
|
10
|
-
}
|
|
5
|
+
const normalizedClassNames = Array.isArray(classNames) ? classNames : classNames.split(" ");
|
|
6
|
+
if (method !== "toggle") {
|
|
7
|
+
element.classList[method](...normalizedClassNames);
|
|
8
|
+
} else {
|
|
9
|
+
normalizedClassNames.forEach((className) => element.classList[method](className, forceToggle));
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export function add(element, classNames) {
|
|
12
|
+
function add(element, classNames) {
|
|
14
13
|
setClasses(element, classNames);
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
setClasses(element, classNames,
|
|
15
|
+
function remove(element, classNames) {
|
|
16
|
+
setClasses(element, classNames, "remove");
|
|
17
|
+
}
|
|
18
|
+
function toggle(element, classNames, force = void 0) {
|
|
19
|
+
setClasses(element, classNames, "toggle", force);
|
|
18
20
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
|
+
add,
|
|
23
|
+
remove,
|
|
24
|
+
toggle
|
|
25
|
+
};
|
|
@@ -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 __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/css/index.js
|
|
23
|
+
var css_exports = {};
|
|
24
|
+
__export(css_exports, {
|
|
25
|
+
addClass: () => import_classes.add,
|
|
26
|
+
addStyle: () => import_styles.add,
|
|
27
|
+
matrix: () => import_matrix.default,
|
|
28
|
+
removeClass: () => import_classes.remove,
|
|
29
|
+
removeStyle: () => import_styles.remove,
|
|
30
|
+
toggleClass: () => import_classes.toggle,
|
|
31
|
+
transition: () => import_transition.default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(css_exports);
|
|
34
|
+
var import_classes = require("./classes.cjs");
|
|
35
|
+
var import_styles = require("./styles.cjs");
|
|
36
|
+
var import_matrix = __toESM(require("./matrix.cjs"), 1);
|
|
37
|
+
var import_transition = __toESM(require("./transition.cjs"), 1);
|
|
38
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { classes, styles, matrix, transition };
|
|
1
|
+
export { default as matrix } from "./matrix.js";
|
|
2
|
+
export { default as transition } from "./transition.js";
|
|
3
|
+
export { add as addClass, remove as removeClass, toggle as toggleClass } from "./classes.js";
|
|
4
|
+
export { add as addStyle, remove as removeStyle } from "./styles.js";
|
package/utils/css/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
export {
|
|
1
|
+
import { add, remove, toggle } from "./classes.js";
|
|
2
|
+
import { add as add2, remove as remove2 } from "./styles.js";
|
|
3
|
+
import { default as default2 } from "./matrix.js";
|
|
4
|
+
import { default as default3 } from "./transition.js";
|
|
5
|
+
export {
|
|
6
|
+
add as addClass,
|
|
7
|
+
add2 as addStyle,
|
|
8
|
+
default2 as matrix,
|
|
9
|
+
remove as removeClass,
|
|
10
|
+
remove2 as removeStyle,
|
|
11
|
+
toggle as toggleClass,
|
|
12
|
+
default3 as transition
|
|
13
|
+
};
|
|
@@ -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/css/matrix.js
|
|
20
|
+
var matrix_exports = {};
|
|
21
|
+
__export(matrix_exports, {
|
|
22
|
+
default: () => matrix
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(matrix_exports);
|
|
25
|
+
function matrix(transform) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
transform = transform || {};
|
|
28
|
+
return `matrix(${(_a = transform.scaleX) != null ? _a : 1}, ${(_b = transform.skewY) != null ? _b : 0}, ${(_c = transform.skewX) != null ? _c : 0}, ${(_d = transform.scaleY) != null ? _d : 1}, ${(_e = transform.translateX) != null ? _e : 0}, ${(_f = transform.translateY) != null ? _f : 0})`;
|
|
29
|
+
}
|
|
30
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/matrix.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
function matrix(transform) {
|
|
2
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4
3
|
transform = transform || {};
|
|
5
|
-
return
|
|
6
|
-
}
|
|
4
|
+
return `matrix(${(_a = transform.scaleX) != null ? _a : 1}, ${(_b = transform.skewY) != null ? _b : 0}, ${(_c = transform.skewX) != null ? _c : 0}, ${(_d = transform.scaleY) != null ? _d : 1}, ${(_e = transform.translateX) != null ? _e : 0}, ${(_f = transform.translateY) != null ? _f : 0})`;
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
matrix as default
|
|
8
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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/css/styles.js
|
|
23
|
+
var styles_exports = {};
|
|
24
|
+
__export(styles_exports, {
|
|
25
|
+
add: () => add,
|
|
26
|
+
remove: () => remove
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(styles_exports);
|
|
29
|
+
var import_isObject = __toESM(require("../object/isObject.cjs"), 1);
|
|
30
|
+
function setStyles(element, styles, method = "add") {
|
|
31
|
+
if (!element || !styles || !(0, import_isObject.default)(styles)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
Object.entries(styles).forEach(([prop, value]) => {
|
|
35
|
+
element.style[prop] = method === "add" ? value : "";
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function add(element, styles) {
|
|
39
|
+
setStyles(element, styles);
|
|
40
|
+
}
|
|
41
|
+
function remove(element, styles) {
|
|
42
|
+
setStyles(element, styles, "remove");
|
|
43
|
+
}
|
|
44
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/styles.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Record<string, string | null> & Partial<CSSStyleDeclaration>} CssStyleObject
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Manage a list of style properties on an element.
|
|
6
|
-
*
|
|
7
|
-
* @param {HTMLElement} element The element to update.
|
|
8
|
-
* @param {CssStyleObject} styles An object of styles properties and values.
|
|
9
|
-
* @param {String} method The method to use: add or remove.
|
|
10
|
-
*/
|
|
11
|
-
export default function setStyles(element: HTMLElement, styles: CssStyleObject, method?: string): void;
|
|
12
1
|
/**
|
|
13
2
|
* Add styles to an element.
|
|
14
3
|
*
|
|
15
|
-
* @param {HTMLElement}
|
|
16
|
-
* @param {
|
|
4
|
+
* @param {HTMLElement} element The element to update.
|
|
5
|
+
* @param {Partial<CSSStyleDeclaration>} styles A string of class names.
|
|
17
6
|
* @return {void}
|
|
18
7
|
*/
|
|
19
|
-
export function add(element: HTMLElement, styles:
|
|
8
|
+
export function add(element: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
|
|
20
9
|
/**
|
|
21
10
|
* Remove class names from an element.
|
|
22
11
|
*
|
|
23
|
-
* @param {HTMLElement}
|
|
24
|
-
* @param {
|
|
12
|
+
* @param {HTMLElement} element The element to update.
|
|
13
|
+
* @param {Partial<CSSStyleDeclaration>} styles A string of class names.
|
|
25
14
|
* @return {void}
|
|
26
15
|
*/
|
|
27
|
-
export function remove(element: HTMLElement, styles:
|
|
28
|
-
export type CssStyleObject = Record<string, string | null> & Partial<CSSStyleDeclaration>;
|
|
16
|
+
export function remove(element: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
|
package/utils/css/styles.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import isObject from
|
|
2
|
-
|
|
3
|
-
var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'add';
|
|
4
|
-
|
|
1
|
+
import isObject from "../object/isObject.js";
|
|
2
|
+
function setStyles(element, styles, method = "add") {
|
|
5
3
|
if (!element || !styles || !isObject(styles)) {
|
|
6
4
|
return;
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var [prop, value] = _ref;
|
|
11
|
-
element.style[prop] = method === 'add' ? value : '';
|
|
6
|
+
Object.entries(styles).forEach(([prop, value]) => {
|
|
7
|
+
element.style[prop] = method === "add" ? value : "";
|
|
12
8
|
});
|
|
13
9
|
}
|
|
14
|
-
|
|
10
|
+
function add(element, styles) {
|
|
15
11
|
setStyles(element, styles);
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
setStyles(element, styles,
|
|
19
|
-
}
|
|
13
|
+
function remove(element, styles) {
|
|
14
|
+
setStyles(element, styles, "remove");
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
add,
|
|
18
|
+
remove
|
|
19
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
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));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/js-toolkit/utils/css/transition.js
|
|
28
|
+
var transition_exports = {};
|
|
29
|
+
__export(transition_exports, {
|
|
30
|
+
default: () => transition,
|
|
31
|
+
setClassesOrStyles: () => setClassesOrStyles
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(transition_exports);
|
|
34
|
+
var import_nextFrame = __toESM(require("../nextFrame.cjs"), 1);
|
|
35
|
+
var classes = __toESM(require("./classes.cjs"), 1);
|
|
36
|
+
var styles = __toESM(require("./styles.cjs"), 1);
|
|
37
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
var Transition = class {
|
|
39
|
+
constructor(element) {
|
|
40
|
+
__publicField(this, "isTransitioning", false);
|
|
41
|
+
__publicField(this, "transitionEndHandler", null);
|
|
42
|
+
cache.set(element, this);
|
|
43
|
+
}
|
|
44
|
+
static getInstance(element) {
|
|
45
|
+
let instance = cache.get(element);
|
|
46
|
+
if (!instance) {
|
|
47
|
+
instance = new this(element);
|
|
48
|
+
}
|
|
49
|
+
return instance;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function setClassesOrStyles(element, classesOrStyles, method = "add") {
|
|
53
|
+
if (typeof classesOrStyles === "string" || Array.isArray(classesOrStyles)) {
|
|
54
|
+
classes[method](element, classesOrStyles);
|
|
55
|
+
} else {
|
|
56
|
+
styles[method](element, classesOrStyles);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function testTransition(element) {
|
|
60
|
+
if (typeof window === "undefined") {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const { transitionDuration } = window.getComputedStyle(element);
|
|
64
|
+
return !!transitionDuration && transitionDuration !== "0s";
|
|
65
|
+
}
|
|
66
|
+
async function start(element, classesOrStyles) {
|
|
67
|
+
const trs = Transition.getInstance(element);
|
|
68
|
+
trs.isTransitioning = true;
|
|
69
|
+
setClassesOrStyles(element, classesOrStyles.from);
|
|
70
|
+
await (0, import_nextFrame.default)();
|
|
71
|
+
setClassesOrStyles(element, classesOrStyles.active);
|
|
72
|
+
await (0, import_nextFrame.default)();
|
|
73
|
+
}
|
|
74
|
+
async function next(element, classesOrStyles) {
|
|
75
|
+
const hasTransition = testTransition(element);
|
|
76
|
+
return new Promise(async (resolve) => {
|
|
77
|
+
if (hasTransition) {
|
|
78
|
+
const trs = Transition.getInstance(element);
|
|
79
|
+
trs.transitionEndHandler = resolve;
|
|
80
|
+
element.addEventListener("transitionend", trs.transitionEndHandler, false);
|
|
81
|
+
}
|
|
82
|
+
setClassesOrStyles(element, classesOrStyles.from, "remove");
|
|
83
|
+
setClassesOrStyles(element, classesOrStyles.to);
|
|
84
|
+
await (0, import_nextFrame.default)();
|
|
85
|
+
if (!hasTransition) {
|
|
86
|
+
resolve();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function end(element, classesOrStyles, mode = "remove") {
|
|
91
|
+
const trs = Transition.getInstance(element);
|
|
92
|
+
element.removeEventListener("transitionend", trs.transitionEndHandler, false);
|
|
93
|
+
if (mode === "remove") {
|
|
94
|
+
setClassesOrStyles(element, classesOrStyles.to, "remove");
|
|
95
|
+
}
|
|
96
|
+
setClassesOrStyles(element, classesOrStyles.active, "remove");
|
|
97
|
+
trs.isTransitioning = false;
|
|
98
|
+
trs.transitionEndHandler = null;
|
|
99
|
+
}
|
|
100
|
+
async function transition(element, name, endMode = "remove") {
|
|
101
|
+
const classesOrStyles = typeof name === "string" ? {
|
|
102
|
+
from: `${name}-from`,
|
|
103
|
+
active: `${name}-active`,
|
|
104
|
+
to: `${name}-to`
|
|
105
|
+
} : {
|
|
106
|
+
from: "",
|
|
107
|
+
active: "",
|
|
108
|
+
to: "",
|
|
109
|
+
...name
|
|
110
|
+
};
|
|
111
|
+
const trs = Transition.getInstance(element);
|
|
112
|
+
if (trs.isTransitioning) {
|
|
113
|
+
end(element, classesOrStyles);
|
|
114
|
+
}
|
|
115
|
+
await start(element, classesOrStyles);
|
|
116
|
+
await next(element, classesOrStyles);
|
|
117
|
+
end(element, classesOrStyles, endMode);
|
|
118
|
+
return Promise.resolve();
|
|
119
|
+
}
|
|
120
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Update either the classes or the styles of an element with the given method.
|
|
3
3
|
*
|
|
4
|
-
* @param {HTMLElement}
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
4
|
+
* @param {HTMLElement} element The element to update.
|
|
5
|
+
* @param {ClassesOrStyles} classesOrStyles The classes or styles to apply.
|
|
6
|
+
* @param {'add'|'remove'} method The method to use, one of `add` or `remove`.
|
|
7
7
|
*/
|
|
8
|
-
export function setClassesOrStyles(element: HTMLElement, classesOrStyles:
|
|
8
|
+
export function setClassesOrStyles(element: HTMLElement, classesOrStyles: ClassesOrStyles, method?: 'add' | 'remove'): void;
|
|
9
9
|
/**
|
|
10
10
|
* Manage CSS transition with class.
|
|
11
11
|
*
|
|
12
12
|
* This is heavily inspired by the Vue `<transition>` component
|
|
13
13
|
* and the `@barba/css` package, many thanks to them!
|
|
14
14
|
*
|
|
15
|
-
* @param {HTMLElement}
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {String}
|
|
18
|
-
* @return {Promise}
|
|
15
|
+
* @param {HTMLElement} element The target element.
|
|
16
|
+
* @param {string|TransitionStyles} name The name of the transition or an object with the hooks classesOrStyles.
|
|
17
|
+
* @param {String} endMode Whether to remove or keep the `to` classes/styles
|
|
18
|
+
* @return {Promise<void>} A promise resolving at the end of the transition.
|
|
19
19
|
*/
|
|
20
|
-
export default function transition(element: HTMLElement, name: string |
|
|
20
|
+
export default function transition(element: HTMLElement, name: string | TransitionStyles, endMode?: string): Promise<void>;
|
|
21
|
+
export type ClassesOrStyles = string | string[] | Partial<CSSStyleDeclaration>;
|
|
22
|
+
export type TransitionStyles = {
|
|
23
|
+
from?: ClassesOrStyles;
|
|
24
|
+
active?: ClassesOrStyles;
|
|
25
|
+
to?: ClassesOrStyles;
|
|
26
|
+
};
|