@studiometa/js-toolkit 2.0.0-beta.10 → 2.0.0-beta.14
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 +295 -0
- package/Base/index.js +88 -174
- package/Base/managers/ChildrenManager.cjs +125 -0
- package/Base/managers/ChildrenManager.js +29 -55
- package/Base/managers/EventsManager.cjs +185 -0
- package/Base/managers/EventsManager.js +84 -130
- package/Base/managers/OptionsManager.cjs +176 -0
- package/Base/managers/OptionsManager.js +46 -88
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.js +22 -38
- package/Base/managers/ServicesManager.cjs +133 -0
- package/Base/managers/ServicesManager.js +31 -65
- package/Base/utils.cjs +46 -0
- package/Base/utils.js +12 -11
- package/decorators/index.cjs +50 -0
- package/decorators/index.js +18 -8
- package/decorators/withBreakpointManager.cjs +92 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +117 -0
- package/decorators/withBreakpointObserver.js +40 -88
- package/decorators/withDrag.cjs +55 -0
- package/decorators/withDrag.js +18 -26
- package/decorators/withExtraConfig.cjs +45 -0
- package/decorators/withExtraConfig.js +11 -12
- package/decorators/withIntersectionObserver.cjs +62 -0
- package/decorators/withIntersectionObserver.js +23 -32
- package/decorators/withMountWhenInView.cjs +69 -0
- package/decorators/withMountWhenInView.js +26 -53
- package/decorators/withScrolledInView.cjs +113 -0
- package/decorators/withScrolledInView.js +50 -63
- package/decorators/withVue2.cjs +61 -0
- package/decorators/withVue2.js +21 -32
- package/helpers/createApp.cjs +57 -0
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +57 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +53 -0
- package/helpers/importWhenIdle.js +13 -17
- package/helpers/importWhenVisible.cjs +55 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +42 -0
- package/helpers/index.js +10 -4
- package/helpers/utils.cjs +40 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +39 -0
- package/index.js +7 -4
- package/package.json +14 -3
- package/services/Service.cjs +76 -0
- package/services/Service.js +13 -32
- package/services/drag.cjs +195 -0
- package/services/drag.js +60 -90
- package/services/index.cjs +48 -0
- package/services/index.js +16 -7
- package/services/key.cjs +102 -0
- package/services/key.js +34 -52
- package/services/load.cjs +71 -0
- package/services/load.js +13 -24
- package/services/pointer.cjs +160 -0
- package/services/pointer.js +60 -87
- package/services/raf.cjs +82 -0
- package/services/raf.js +16 -33
- package/services/resize.cjs +107 -0
- package/services/resize.js +31 -49
- package/services/scroll.cjs +130 -0
- package/services/scroll.js +44 -62
- package/utils/collide/boundingRectToCircle.cjs +39 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +39 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +51 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +36 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +33 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +33 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +46 -0
- package/utils/collide/index.js +14 -6
- package/utils/css/classes.cjs +49 -0
- package/utils/css/classes.js +13 -12
- package/utils/css/index.cjs +42 -0
- package/utils/css/index.js +10 -6
- package/utils/css/matrix.cjs +34 -0
- package/utils/css/matrix.js +6 -5
- package/utils/css/styles.cjs +52 -0
- package/utils/css/styles.js +13 -12
- package/utils/css/transition.cjs +122 -0
- package/utils/css/transition.js +62 -117
- package/utils/debounce.cjs +39 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +89 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +96 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +58 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +30 -11
- package/utils/keyCodes.cjs +40 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +33 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +39 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +33 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +93 -0
- package/utils/math/ease.js +50 -25
- package/utils/math/index.cjs +49 -0
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +42 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +33 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +33 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +33 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +48 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +45 -0
- package/utils/nextFrame.js +14 -9
- package/utils/object/autoBind.cjs +56 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +42 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +40 -0
- package/utils/object/index.js +8 -3
- package/utils/object/isObject.cjs +33 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +87 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +54 -0
- package/utils/string/index.js +22 -10
- package/utils/string/withLeadingCharacters.cjs +39 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +39 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +39 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +39 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +33 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +44 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +39 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +33 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +44 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +39 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +41 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import useResize from '../../services/resize.js';
|
|
10
|
-
import useScroll from '../../services/scroll.js';
|
|
11
|
-
import useKey from '../../services/key.js';
|
|
12
|
-
import useLoad from '../../services/load.js';
|
|
13
|
-
import { hasMethod } from '../utils.js';
|
|
14
|
-
var SERVICES_MAP = {
|
|
1
|
+
import usePointer from "../../services/pointer.js";
|
|
2
|
+
import useRaf from "../../services/raf.js";
|
|
3
|
+
import useResize from "../../services/resize.js";
|
|
4
|
+
import useScroll from "../../services/scroll.js";
|
|
5
|
+
import useKey from "../../services/key.js";
|
|
6
|
+
import useLoad from "../../services/load.js";
|
|
7
|
+
import { hasMethod } from "../utils.js";
|
|
8
|
+
const SERVICES_MAP = {
|
|
15
9
|
scrolled: useScroll,
|
|
16
10
|
resized: useResize,
|
|
17
11
|
ticked: useRaf,
|
|
@@ -19,17 +13,17 @@ var SERVICES_MAP = {
|
|
|
19
13
|
keyed: useKey,
|
|
20
14
|
loaded: useLoad
|
|
21
15
|
};
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const SERVICE_NAMES = Object.keys(SERVICES_MAP);
|
|
17
|
+
class ServicesManager {
|
|
18
|
+
__base;
|
|
19
|
+
__customServices = {};
|
|
24
20
|
get __services() {
|
|
25
|
-
return
|
|
21
|
+
return {
|
|
22
|
+
...this.__customServices,
|
|
23
|
+
...SERVICES_MAP
|
|
24
|
+
};
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
constructor(instance) {
|
|
29
|
-
_defineProperty(this, "__base", void 0);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "__customServices", {});
|
|
32
|
-
|
|
33
27
|
Object.defineProperties(this, {
|
|
34
28
|
__base: {
|
|
35
29
|
enumerable: false,
|
|
@@ -38,74 +32,49 @@ export default class ServicesManager {
|
|
|
38
32
|
}
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
has(service) {
|
|
43
36
|
if (!((hasMethod(this.__base, service) || this.__base.__hasEvent(service)) && this.__services[service])) {
|
|
44
37
|
return false;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
var {
|
|
48
|
-
has
|
|
49
|
-
} = this.__services[service]();
|
|
50
|
-
|
|
39
|
+
const { has } = this.__services[service]();
|
|
51
40
|
return has(this.__base.$id);
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
enable(service) {
|
|
55
43
|
if (this.has(service)) {
|
|
56
44
|
return this.disable.bind(this, service);
|
|
57
45
|
}
|
|
58
|
-
|
|
59
46
|
if (!(hasMethod(this.__base, service) || this.__base.__hasEvent(service)) || !this.__services[service]) {
|
|
60
|
-
return function noop() {
|
|
47
|
+
return function noop() {
|
|
48
|
+
};
|
|
61
49
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} = this.__services[service]();
|
|
66
|
-
|
|
67
|
-
var self = this;
|
|
68
|
-
|
|
69
|
-
function serviceHandler() {
|
|
70
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
71
|
-
args[_key] = arguments[_key];
|
|
72
|
-
}
|
|
73
|
-
|
|
50
|
+
const { add } = this.__services[service]();
|
|
51
|
+
const self = this;
|
|
52
|
+
function serviceHandler(...args) {
|
|
74
53
|
self.__base.__callMethod(service, ...args);
|
|
75
54
|
}
|
|
76
|
-
|
|
77
55
|
add(this.__base.$id, serviceHandler);
|
|
78
56
|
return this.disable.bind(this, service);
|
|
79
57
|
}
|
|
80
|
-
|
|
81
58
|
enableAll() {
|
|
82
|
-
return Object.keys(this.__services).map(serviceName => this.enable(serviceName));
|
|
59
|
+
return Object.keys(this.__services).map((serviceName) => this.enable(serviceName));
|
|
83
60
|
}
|
|
84
|
-
|
|
85
61
|
disableAll() {
|
|
86
|
-
Object.keys(this.__services).forEach(serviceName => {
|
|
62
|
+
Object.keys(this.__services).forEach((serviceName) => {
|
|
87
63
|
this.disable(serviceName);
|
|
88
64
|
});
|
|
89
65
|
}
|
|
90
|
-
|
|
91
66
|
disable(service) {
|
|
92
67
|
if (!this.__services[service]) {
|
|
93
68
|
return;
|
|
94
69
|
}
|
|
95
|
-
|
|
96
|
-
var {
|
|
97
|
-
remove
|
|
98
|
-
} = this.__services[service]();
|
|
99
|
-
|
|
70
|
+
const { remove } = this.__services[service]();
|
|
100
71
|
remove(this.__base.$id);
|
|
101
72
|
}
|
|
102
|
-
|
|
103
73
|
toggle(service, force) {
|
|
104
|
-
if (typeof force !==
|
|
74
|
+
if (typeof force !== "undefined") {
|
|
105
75
|
if (force && !this.has(service)) {
|
|
106
76
|
this.enable(service);
|
|
107
77
|
}
|
|
108
|
-
|
|
109
78
|
if (!force && this.has(service)) {
|
|
110
79
|
this.disable(service);
|
|
111
80
|
}
|
|
@@ -115,21 +84,18 @@ export default class ServicesManager {
|
|
|
115
84
|
this.enable(service);
|
|
116
85
|
}
|
|
117
86
|
}
|
|
118
|
-
|
|
119
87
|
register(name, useFunction) {
|
|
120
88
|
this.__customServices[name] = useFunction;
|
|
121
|
-
|
|
122
89
|
this.__base.__addEmits(name);
|
|
123
90
|
}
|
|
124
|
-
|
|
125
91
|
unregister(name) {
|
|
126
92
|
if (SERVICE_NAMES.includes(name)) {
|
|
127
|
-
throw new Error(
|
|
93
|
+
throw new Error(`[ServicesManager] The \`${name}\` core service can not be unregistered.`);
|
|
128
94
|
}
|
|
129
|
-
|
|
130
95
|
this.__base.__removeEmits(name);
|
|
131
|
-
|
|
132
96
|
delete this.__customServices[name];
|
|
133
97
|
}
|
|
134
|
-
|
|
135
|
-
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
ServicesManager as default
|
|
101
|
+
};
|
package/Base/utils.cjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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/Base/utils.js
|
|
25
|
+
var utils_exports = {};
|
|
26
|
+
__export(utils_exports, {
|
|
27
|
+
getComponentElements: () => getComponentElements,
|
|
28
|
+
hasMethod: () => hasMethod
|
|
29
|
+
});
|
|
30
|
+
function hasMethod(obj, name) {
|
|
31
|
+
return typeof obj[name] === "function";
|
|
32
|
+
}
|
|
33
|
+
function getComponentElements(nameOrSelector, element = document) {
|
|
34
|
+
const selector = `[data-component="${nameOrSelector}"]`;
|
|
35
|
+
let elements = [];
|
|
36
|
+
try {
|
|
37
|
+
elements = Array.from(element.querySelectorAll(selector));
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
if (elements.length === 0) {
|
|
41
|
+
elements = Array.from(element.querySelectorAll(nameOrSelector));
|
|
42
|
+
}
|
|
43
|
+
return elements;
|
|
44
|
+
}
|
|
45
|
+
module.exports = __toCommonJS(utils_exports);
|
|
46
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/Base/utils.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
return typeof obj[name] ===
|
|
1
|
+
function hasMethod(obj, name) {
|
|
2
|
+
return typeof obj[name] === "function";
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var elements = [];
|
|
8
|
-
|
|
4
|
+
function getComponentElements(nameOrSelector, element = document) {
|
|
5
|
+
const selector = `[data-component="${nameOrSelector}"]`;
|
|
6
|
+
let elements = [];
|
|
9
7
|
try {
|
|
10
8
|
elements = Array.from(element.querySelectorAll(selector));
|
|
11
|
-
} catch
|
|
12
|
-
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
13
11
|
if (elements.length === 0) {
|
|
14
12
|
elements = Array.from(element.querySelectorAll(nameOrSelector));
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
return elements;
|
|
18
|
-
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getComponentElements,
|
|
18
|
+
hasMethod
|
|
19
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
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/decorators/index.js
|
|
30
|
+
var decorators_exports = {};
|
|
31
|
+
__export(decorators_exports, {
|
|
32
|
+
withBreakpointManager: () => import_withBreakpointManager.default,
|
|
33
|
+
withBreakpointObserver: () => import_withBreakpointObserver.default,
|
|
34
|
+
withDrag: () => import_withDrag.default,
|
|
35
|
+
withExtraConfig: () => import_withExtraConfig.default,
|
|
36
|
+
withIntersectionObserver: () => import_withIntersectionObserver.default,
|
|
37
|
+
withMountWhenInView: () => import_withMountWhenInView.default,
|
|
38
|
+
withScrolledInView: () => import_withScrolledInView.default,
|
|
39
|
+
withVue2: () => import_withVue2.default
|
|
40
|
+
});
|
|
41
|
+
var import_withBreakpointManager = __toESM(require("./withBreakpointManager.cjs"), 1);
|
|
42
|
+
var import_withBreakpointObserver = __toESM(require("./withBreakpointObserver.cjs"), 1);
|
|
43
|
+
var import_withDrag = __toESM(require("./withDrag.cjs"), 1);
|
|
44
|
+
var import_withExtraConfig = __toESM(require("./withExtraConfig.cjs"), 1);
|
|
45
|
+
var import_withIntersectionObserver = __toESM(require("./withIntersectionObserver.cjs"), 1);
|
|
46
|
+
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
|
|
47
|
+
var import_withScrolledInView = __toESM(require("./withScrolledInView.cjs"), 1);
|
|
48
|
+
var import_withVue2 = __toESM(require("./withVue2.cjs"), 1);
|
|
49
|
+
module.exports = __toCommonJS(decorators_exports);
|
|
50
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/decorators/index.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { default as default2 } from "./withBreakpointManager.js";
|
|
2
|
+
import { default as default3 } from "./withBreakpointObserver.js";
|
|
3
|
+
import { default as default4 } from "./withDrag.js";
|
|
4
|
+
import { default as default5 } from "./withExtraConfig.js";
|
|
5
|
+
import { default as default6 } from "./withIntersectionObserver.js";
|
|
6
|
+
import { default as default7 } from "./withMountWhenInView.js";
|
|
7
|
+
import { default as default8 } from "./withScrolledInView.js";
|
|
8
|
+
import { default as default9 } from "./withVue2.js";
|
|
9
|
+
export {
|
|
10
|
+
default2 as withBreakpointManager,
|
|
11
|
+
default3 as withBreakpointObserver,
|
|
12
|
+
default4 as withDrag,
|
|
13
|
+
default5 as withExtraConfig,
|
|
14
|
+
default6 as withIntersectionObserver,
|
|
15
|
+
default7 as withMountWhenInView,
|
|
16
|
+
default8 as withScrolledInView,
|
|
17
|
+
default9 as withVue2
|
|
18
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
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/decorators/withBreakpointManager.js
|
|
30
|
+
var withBreakpointManager_exports = {};
|
|
31
|
+
__export(withBreakpointManager_exports, {
|
|
32
|
+
default: () => withBreakpointManager
|
|
33
|
+
});
|
|
34
|
+
var import_resize = __toESM(require("../services/resize.cjs"), 1);
|
|
35
|
+
function testBreakpoints(breakpoints) {
|
|
36
|
+
const { breakpoint } = (0, import_resize.default)().props();
|
|
37
|
+
breakpoints.forEach(([breakpointKeys, instance]) => {
|
|
38
|
+
if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {
|
|
39
|
+
setTimeout(() => instance.$mount(), 0);
|
|
40
|
+
} else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {
|
|
41
|
+
instance.$destroy();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function mountComponents(instance, breakpoints) {
|
|
46
|
+
return breakpoints.map(([bk, ComponentClass]) => {
|
|
47
|
+
const child = new ComponentClass(instance.$el);
|
|
48
|
+
Object.defineProperty(child, "$parent", { get: () => instance.$parent });
|
|
49
|
+
return [bk, child];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
var instances = /* @__PURE__ */ new WeakMap();
|
|
53
|
+
function withBreakpointManager(BaseClass, breakpoints) {
|
|
54
|
+
if (!Array.isArray(breakpoints)) {
|
|
55
|
+
throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
|
|
56
|
+
}
|
|
57
|
+
if (breakpoints.length < 2) {
|
|
58
|
+
throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
|
|
59
|
+
}
|
|
60
|
+
const { add, props } = (0, import_resize.default)();
|
|
61
|
+
if (!props().breakpoint) {
|
|
62
|
+
throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
|
|
63
|
+
}
|
|
64
|
+
return class extends BaseClass {
|
|
65
|
+
constructor(element) {
|
|
66
|
+
super(element);
|
|
67
|
+
if (!instances.has(this)) {
|
|
68
|
+
instances.set(this, mountComponents(this, breakpoints));
|
|
69
|
+
}
|
|
70
|
+
add(`BreakpointManager-${this.$id}`, () => {
|
|
71
|
+
testBreakpoints(instances.get(this));
|
|
72
|
+
});
|
|
73
|
+
this.instances = instances.get(this);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
$mount() {
|
|
77
|
+
super.$mount();
|
|
78
|
+
testBreakpoints(instances.get(this));
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
$destroy() {
|
|
82
|
+
if (Array.isArray(instances.get(this))) {
|
|
83
|
+
instances.get(this).forEach(([, instance]) => {
|
|
84
|
+
instance.$destroy();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return super.$destroy();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
module.exports = __toCommonJS(withBreakpointManager_exports);
|
|
92
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import useResize from
|
|
2
|
-
|
|
1
|
+
import useResize from "../services/resize.js";
|
|
3
2
|
function testBreakpoints(breakpoints) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = useResize().props();
|
|
7
|
-
breakpoints.forEach(_ref => {
|
|
8
|
-
var [breakpointKeys, instance] = _ref;
|
|
9
|
-
|
|
3
|
+
const { breakpoint } = useResize().props();
|
|
4
|
+
breakpoints.forEach(([breakpointKeys, instance]) => {
|
|
10
5
|
if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {
|
|
11
6
|
setTimeout(() => instance.$mount(), 0);
|
|
12
7
|
} else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {
|
|
@@ -14,68 +9,52 @@ function testBreakpoints(breakpoints) {
|
|
|
14
9
|
}
|
|
15
10
|
});
|
|
16
11
|
}
|
|
17
|
-
|
|
18
12
|
function mountComponents(instance, breakpoints) {
|
|
19
|
-
return breakpoints.map(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(child, '$parent', {
|
|
23
|
-
get: () => instance.$parent
|
|
24
|
-
});
|
|
13
|
+
return breakpoints.map(([bk, ComponentClass]) => {
|
|
14
|
+
const child = new ComponentClass(instance.$el);
|
|
15
|
+
Object.defineProperty(child, "$parent", { get: () => instance.$parent });
|
|
25
16
|
return [bk, child];
|
|
26
17
|
});
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export default function withBreakpointManager(BaseClass, breakpoints) {
|
|
19
|
+
const instances = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
function withBreakpointManager(BaseClass, breakpoints) {
|
|
31
21
|
if (!Array.isArray(breakpoints)) {
|
|
32
|
-
throw new Error(
|
|
22
|
+
throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
|
|
33
23
|
}
|
|
34
|
-
|
|
35
24
|
if (breakpoints.length < 2) {
|
|
36
|
-
throw new Error(
|
|
25
|
+
throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
var {
|
|
40
|
-
add,
|
|
41
|
-
props
|
|
42
|
-
} = useResize();
|
|
43
|
-
|
|
27
|
+
const { add, props } = useResize();
|
|
44
28
|
if (!props().breakpoint) {
|
|
45
|
-
throw new Error(
|
|
29
|
+
throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
|
|
46
30
|
}
|
|
47
|
-
|
|
48
31
|
return class extends BaseClass {
|
|
49
32
|
constructor(element) {
|
|
50
33
|
super(element);
|
|
51
|
-
|
|
52
34
|
if (!instances.has(this)) {
|
|
53
35
|
instances.set(this, mountComponents(this, breakpoints));
|
|
54
36
|
}
|
|
55
|
-
|
|
56
|
-
add("BreakpointManager-".concat(this.$id), () => {
|
|
37
|
+
add(`BreakpointManager-${this.$id}`, () => {
|
|
57
38
|
testBreakpoints(instances.get(this));
|
|
58
39
|
});
|
|
59
40
|
this.instances = instances.get(this);
|
|
60
41
|
return this;
|
|
61
42
|
}
|
|
62
|
-
|
|
63
43
|
$mount() {
|
|
64
44
|
super.$mount();
|
|
65
45
|
testBreakpoints(instances.get(this));
|
|
66
46
|
return this;
|
|
67
47
|
}
|
|
68
|
-
|
|
69
48
|
$destroy() {
|
|
70
49
|
if (Array.isArray(instances.get(this))) {
|
|
71
|
-
instances.get(this).forEach(
|
|
72
|
-
var [, instance] = _ref3;
|
|
50
|
+
instances.get(this).forEach(([, instance]) => {
|
|
73
51
|
instance.$destroy();
|
|
74
52
|
});
|
|
75
53
|
}
|
|
76
|
-
|
|
77
54
|
return super.$destroy();
|
|
78
55
|
}
|
|
79
|
-
|
|
80
56
|
};
|
|
81
|
-
}
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
withBreakpointManager as default
|
|
60
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
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/decorators/withBreakpointObserver.js
|
|
30
|
+
var withBreakpointObserver_exports = {};
|
|
31
|
+
__export(withBreakpointObserver_exports, {
|
|
32
|
+
default: () => withBreakpointObserver
|
|
33
|
+
});
|
|
34
|
+
var import_resize = __toESM(require("../services/resize.cjs"), 1);
|
|
35
|
+
function testBreakpoints(instance, breakpoint = (0, import_resize.default)().props().breakpoint) {
|
|
36
|
+
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
37
|
+
const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
|
|
38
|
+
const isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(" ").includes(breakpoint);
|
|
39
|
+
if (activeBreakpoints && isInActiveBreakpoint || inactiveBreakpoints && !isInInactiveBreakpoint) {
|
|
40
|
+
return "$mount";
|
|
41
|
+
}
|
|
42
|
+
return "$destroy";
|
|
43
|
+
}
|
|
44
|
+
function hasBreakpointConfiguration(instance) {
|
|
45
|
+
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
46
|
+
return Boolean(activeBreakpoints || inactiveBreakpoints);
|
|
47
|
+
}
|
|
48
|
+
function testConflictingBreakpointConfiguration(instance) {
|
|
49
|
+
const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
|
|
50
|
+
if (activeBreakpoints && inactiveBreakpoints) {
|
|
51
|
+
throw new Error(`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function addToResize(key, instance) {
|
|
55
|
+
testConflictingBreakpointConfiguration(instance);
|
|
56
|
+
const { add, has } = (0, import_resize.default)();
|
|
57
|
+
if (!has(key)) {
|
|
58
|
+
add(key, function onResize({ breakpoint }) {
|
|
59
|
+
const action = testBreakpoints(instance, breakpoint);
|
|
60
|
+
if (action === "$destroy" && instance.$isMounted) {
|
|
61
|
+
instance[action]();
|
|
62
|
+
} else if (action === "$mount" && !instance.$isMounted) {
|
|
63
|
+
setTimeout(() => instance[action](), 0);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function withBreakpointObserver(BaseClass) {
|
|
69
|
+
return class extends BaseClass {
|
|
70
|
+
static config = {
|
|
71
|
+
...BaseClass.config || {},
|
|
72
|
+
name: `${BaseClass?.config?.name ?? ""}WithBreakpointObserver`,
|
|
73
|
+
options: {
|
|
74
|
+
...BaseClass?.config?.options || {},
|
|
75
|
+
activeBreakpoints: String,
|
|
76
|
+
inactiveBreakpoints: String
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
constructor(element) {
|
|
80
|
+
super(element);
|
|
81
|
+
const { remove, props } = (0, import_resize.default)();
|
|
82
|
+
const { name } = this.$options;
|
|
83
|
+
if (!props().breakpoint) {
|
|
84
|
+
throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
|
|
85
|
+
}
|
|
86
|
+
const key = `BreakpointObserver-${this.$id}`;
|
|
87
|
+
const mutationObserver = new MutationObserver(([mutation]) => {
|
|
88
|
+
if (mutation.type === "attributes" && (mutation.attributeName === "data-options" || mutation.attributeName.startsWith("data-option-"))) {
|
|
89
|
+
if (!hasBreakpointConfiguration(this)) {
|
|
90
|
+
this.$mount();
|
|
91
|
+
remove(key);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
addToResize(key, this);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
mutationObserver.observe(this.$el, { attributes: true });
|
|
98
|
+
if (!hasBreakpointConfiguration(this)) {
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
addToResize(key, this);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
$mount() {
|
|
105
|
+
if (!hasBreakpointConfiguration(this)) {
|
|
106
|
+
return super.$mount();
|
|
107
|
+
}
|
|
108
|
+
const action = testBreakpoints(this);
|
|
109
|
+
if (action === "$mount") {
|
|
110
|
+
return super.$mount();
|
|
111
|
+
}
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
module.exports = __toCommonJS(withBreakpointObserver_exports);
|
|
117
|
+
if (module.exports.default) module.exports = module.exports.default;
|