@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
|
@@ -0,0 +1,113 @@
|
|
|
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/withScrolledInView.js
|
|
30
|
+
var withScrolledInView_exports = {};
|
|
31
|
+
__export(withScrolledInView_exports, {
|
|
32
|
+
default: () => withScrolledInView
|
|
33
|
+
});
|
|
34
|
+
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
|
|
35
|
+
var import_utils = require("../utils/index.cjs");
|
|
36
|
+
function withScrolledInView(BaseClass, options) {
|
|
37
|
+
return class extends (0, import_withMountWhenInView.default)(BaseClass, options) {
|
|
38
|
+
static config = {
|
|
39
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
40
|
+
emits: ["scrolledInView"]
|
|
41
|
+
};
|
|
42
|
+
__props = {
|
|
43
|
+
start: {
|
|
44
|
+
x: 0,
|
|
45
|
+
y: 0
|
|
46
|
+
},
|
|
47
|
+
end: {
|
|
48
|
+
x: 0,
|
|
49
|
+
y: 0
|
|
50
|
+
},
|
|
51
|
+
current: {
|
|
52
|
+
x: 0,
|
|
53
|
+
y: 0
|
|
54
|
+
},
|
|
55
|
+
progress: {
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
},
|
|
59
|
+
dampedProgress: {
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
dampFactor = 0.1;
|
|
65
|
+
dampPrecision = 1e-3;
|
|
66
|
+
mounted() {
|
|
67
|
+
this.__setProps();
|
|
68
|
+
}
|
|
69
|
+
resized() {
|
|
70
|
+
this.__setProps();
|
|
71
|
+
}
|
|
72
|
+
scrolled(props) {
|
|
73
|
+
if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
|
|
74
|
+
this.$services.enable("ticked");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
ticked() {
|
|
78
|
+
this.__props.current.x = (0, import_utils.clamp)(window.pageXOffset, this.__props.start.x, this.__props.end.x);
|
|
79
|
+
this.__props.progress.x = (0, import_utils.clamp01)((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
|
|
80
|
+
this.__props.dampedProgress.x = (0, import_utils.damp)(this.__props.progress.x, this.__props.dampedProgress.x, this.dampFactor, this.dampPrecision);
|
|
81
|
+
this.__props.current.y = (0, import_utils.clamp)(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
82
|
+
this.__props.progress.y = (0, import_utils.clamp01)((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
83
|
+
this.__props.dampedProgress.y = (0, import_utils.damp)(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
84
|
+
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
85
|
+
this.$services.disable("ticked");
|
|
86
|
+
}
|
|
87
|
+
this.__callMethod("scrolledInView", this.__props);
|
|
88
|
+
}
|
|
89
|
+
__setProps() {
|
|
90
|
+
const sizes = this.$el.getBoundingClientRect();
|
|
91
|
+
const yEnd = sizes.top + window.pageYOffset + sizes.height;
|
|
92
|
+
const yStart = yEnd - window.innerHeight - sizes.height;
|
|
93
|
+
const yCurrent = (0, import_utils.clamp)(window.pageYOffset, yStart, yEnd);
|
|
94
|
+
const yProgress = (0, import_utils.clamp01)((yCurrent - yStart) / (yEnd - yStart));
|
|
95
|
+
const xEnd = sizes.left + window.pageXOffset + sizes.width;
|
|
96
|
+
const xStart = xEnd - window.innerWidth - sizes.width;
|
|
97
|
+
const xCurrent = (0, import_utils.clamp)(window.pageXOffset, xStart, xEnd);
|
|
98
|
+
const xProgress = (0, import_utils.clamp01)((xCurrent - xStart) / (xEnd - xStart));
|
|
99
|
+
this.__props.start.x = xStart;
|
|
100
|
+
this.__props.start.y = yStart;
|
|
101
|
+
this.__props.end.x = xEnd;
|
|
102
|
+
this.__props.end.y = yEnd;
|
|
103
|
+
this.__props.current.x = xCurrent;
|
|
104
|
+
this.__props.current.y = yCurrent;
|
|
105
|
+
this.__props.progress.x = xProgress;
|
|
106
|
+
this.__props.progress.y = yProgress;
|
|
107
|
+
this.__props.dampedProgress.x = (0, import_utils.damp)(xProgress, this.__props.dampedProgress.x);
|
|
108
|
+
this.__props.dampedProgress.y = (0, import_utils.damp)(yProgress, this.__props.dampedProgress.y);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
module.exports = __toCommonJS(withScrolledInView_exports);
|
|
113
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,55 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_defineProperty(this, "dampFactor", 0.1);
|
|
35
|
-
|
|
36
|
-
_defineProperty(this, "dampPrecision", 0.001);
|
|
37
|
-
}
|
|
38
|
-
|
|
1
|
+
import withMountWhenInView from "./withMountWhenInView.js";
|
|
2
|
+
import { damp, clamp, clamp01 } from "../utils/index.js";
|
|
3
|
+
function withScrolledInView(BaseClass, options) {
|
|
4
|
+
return class extends withMountWhenInView(BaseClass, options) {
|
|
5
|
+
static config = {
|
|
6
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
7
|
+
emits: ["scrolledInView"]
|
|
8
|
+
};
|
|
9
|
+
__props = {
|
|
10
|
+
start: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0
|
|
13
|
+
},
|
|
14
|
+
end: {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0
|
|
17
|
+
},
|
|
18
|
+
current: {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0
|
|
21
|
+
},
|
|
22
|
+
progress: {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0
|
|
25
|
+
},
|
|
26
|
+
dampedProgress: {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
dampFactor = 0.1;
|
|
32
|
+
dampPrecision = 1e-3;
|
|
39
33
|
mounted() {
|
|
40
34
|
this.__setProps();
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
resized() {
|
|
44
37
|
this.__setProps();
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
scrolled(props) {
|
|
48
|
-
if (!this.$services.has(
|
|
49
|
-
this.$services.enable(
|
|
40
|
+
if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
|
|
41
|
+
this.$services.enable("ticked");
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
ticked() {
|
|
54
45
|
this.__props.current.x = clamp(window.pageXOffset, this.__props.start.x, this.__props.end.x);
|
|
55
46
|
this.__props.progress.x = clamp01((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
|
|
@@ -57,24 +48,21 @@ export default function withScrolledInView(BaseClass, options) {
|
|
|
57
48
|
this.__props.current.y = clamp(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
58
49
|
this.__props.progress.y = clamp01((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
59
50
|
this.__props.dampedProgress.y = damp(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
60
|
-
|
|
61
51
|
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
62
|
-
this.$services.disable(
|
|
52
|
+
this.$services.disable("ticked");
|
|
63
53
|
}
|
|
64
|
-
|
|
65
|
-
this.__callMethod('scrolledInView', this.__props);
|
|
54
|
+
this.__callMethod("scrolledInView", this.__props);
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
__setProps() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
const sizes = this.$el.getBoundingClientRect();
|
|
58
|
+
const yEnd = sizes.top + window.pageYOffset + sizes.height;
|
|
59
|
+
const yStart = yEnd - window.innerHeight - sizes.height;
|
|
60
|
+
const yCurrent = clamp(window.pageYOffset, yStart, yEnd);
|
|
61
|
+
const yProgress = clamp01((yCurrent - yStart) / (yEnd - yStart));
|
|
62
|
+
const xEnd = sizes.left + window.pageXOffset + sizes.width;
|
|
63
|
+
const xStart = xEnd - window.innerWidth - sizes.width;
|
|
64
|
+
const xCurrent = clamp(window.pageXOffset, xStart, xEnd);
|
|
65
|
+
const xProgress = clamp01((xCurrent - xStart) / (xEnd - xStart));
|
|
78
66
|
this.__props.start.x = xStart;
|
|
79
67
|
this.__props.start.y = yStart;
|
|
80
68
|
this.__props.end.x = xEnd;
|
|
@@ -86,9 +74,8 @@ export default function withScrolledInView(BaseClass, options) {
|
|
|
86
74
|
this.__props.dampedProgress.x = damp(xProgress, this.__props.dampedProgress.x);
|
|
87
75
|
this.__props.dampedProgress.y = damp(yProgress, this.__props.dampedProgress.y);
|
|
88
76
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
withScrolledInView as default
|
|
81
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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/decorators/withVue2.js
|
|
25
|
+
var withVue2_exports = {};
|
|
26
|
+
__export(withVue2_exports, {
|
|
27
|
+
default: () => withVue2_default
|
|
28
|
+
});
|
|
29
|
+
var withVue2_default = (BaseClass, Vue) => {
|
|
30
|
+
return class WithVue2 extends BaseClass {
|
|
31
|
+
static config = {
|
|
32
|
+
...BaseClass.config || {},
|
|
33
|
+
name: `${BaseClass?.config?.name ?? ""}WithVue`,
|
|
34
|
+
refs: [...BaseClass?.config?.refs ?? [], "vue"]
|
|
35
|
+
};
|
|
36
|
+
$vue;
|
|
37
|
+
static vueConfig;
|
|
38
|
+
constructor(element) {
|
|
39
|
+
super(element);
|
|
40
|
+
const { vueConfig } = this.constructor;
|
|
41
|
+
if (!vueConfig) {
|
|
42
|
+
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
43
|
+
}
|
|
44
|
+
if (typeof vueConfig.render !== "function") {
|
|
45
|
+
throw new Error("[withVue] You must define a `render` function in vueConfig.");
|
|
46
|
+
}
|
|
47
|
+
this.$vue = new Vue(vueConfig);
|
|
48
|
+
this.$on("mounted", () => {
|
|
49
|
+
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
50
|
+
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
51
|
+
}
|
|
52
|
+
this.$vue.$mount(this.$refs.vue);
|
|
53
|
+
});
|
|
54
|
+
this.$on("destroyed", () => {
|
|
55
|
+
this.$vue.$destroy();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
module.exports = __toCommonJS(withVue2_exports);
|
|
61
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/decorators/withVue2.js
CHANGED
|
@@ -1,45 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return _temp = _class = class WithVue2 extends BaseClass {
|
|
1
|
+
var withVue2_default = (BaseClass, Vue) => {
|
|
2
|
+
return class WithVue2 extends BaseClass {
|
|
3
|
+
static config = {
|
|
4
|
+
...BaseClass.config || {},
|
|
5
|
+
name: `${BaseClass?.config?.name ?? ""}WithVue`,
|
|
6
|
+
refs: [...BaseClass?.config?.refs ?? [], "vue"]
|
|
7
|
+
};
|
|
8
|
+
$vue;
|
|
9
|
+
static vueConfig;
|
|
11
10
|
constructor(element) {
|
|
12
11
|
super(element);
|
|
13
|
-
|
|
14
|
-
_defineProperty(this, "$vue", void 0);
|
|
15
|
-
|
|
16
|
-
var {
|
|
17
|
-
vueConfig
|
|
18
|
-
} = this.constructor;
|
|
19
|
-
|
|
12
|
+
const { vueConfig } = this.constructor;
|
|
20
13
|
if (!vueConfig) {
|
|
21
|
-
throw new Error(
|
|
14
|
+
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
22
15
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
throw new Error('[withVue] You must define a `render` function in vueConfig.');
|
|
16
|
+
if (typeof vueConfig.render !== "function") {
|
|
17
|
+
throw new Error("[withVue] You must define a `render` function in vueConfig.");
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
this.$vue = new Vue(vueConfig);
|
|
29
|
-
this.$on(
|
|
20
|
+
this.$on("mounted", () => {
|
|
30
21
|
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
31
|
-
throw new Error(
|
|
22
|
+
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
this.$vue.$mount(this.$refs.vue);
|
|
35
25
|
});
|
|
36
|
-
this.$on(
|
|
26
|
+
this.$on("destroyed", () => {
|
|
37
27
|
this.$vue.$destroy();
|
|
38
28
|
});
|
|
39
29
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
withVue2_default as default
|
|
34
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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/helpers/createApp.js
|
|
25
|
+
var createApp_exports = {};
|
|
26
|
+
__export(createApp_exports, {
|
|
27
|
+
default: () => createApp
|
|
28
|
+
});
|
|
29
|
+
function createApp(App, rootElement) {
|
|
30
|
+
let isLoaded = document.readyState === "complete";
|
|
31
|
+
let app;
|
|
32
|
+
if (!isLoaded) {
|
|
33
|
+
document.addEventListener("readystatechange", () => {
|
|
34
|
+
if (document.readyState === "complete") {
|
|
35
|
+
app = new App(rootElement).$mount();
|
|
36
|
+
isLoaded = true;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
app = new App(rootElement).$mount();
|
|
41
|
+
}
|
|
42
|
+
const promise = new Promise((resolve) => {
|
|
43
|
+
document.addEventListener("readystatechange", () => {
|
|
44
|
+
if (document.readyState === "complete") {
|
|
45
|
+
setTimeout(() => resolve(app), 0);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return function useApp() {
|
|
50
|
+
if (isLoaded) {
|
|
51
|
+
return Promise.resolve(app);
|
|
52
|
+
}
|
|
53
|
+
return promise;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
module.exports = __toCommonJS(createApp_exports);
|
|
57
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/helpers/createApp.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function createApp(App, rootElement) {
|
|
2
|
+
let isLoaded = document.readyState === "complete";
|
|
3
|
+
let app;
|
|
5
4
|
if (!isLoaded) {
|
|
6
|
-
document.addEventListener(
|
|
7
|
-
if (document.readyState ===
|
|
5
|
+
document.addEventListener("readystatechange", () => {
|
|
6
|
+
if (document.readyState === "complete") {
|
|
8
7
|
app = new App(rootElement).$mount();
|
|
9
8
|
isLoaded = true;
|
|
10
9
|
}
|
|
@@ -12,10 +11,9 @@ export default function createApp(App, rootElement) {
|
|
|
12
11
|
} else {
|
|
13
12
|
app = new App(rootElement).$mount();
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (document.readyState === 'complete') {
|
|
14
|
+
const promise = new Promise((resolve) => {
|
|
15
|
+
document.addEventListener("readystatechange", () => {
|
|
16
|
+
if (document.readyState === "complete") {
|
|
19
17
|
setTimeout(() => resolve(app), 0);
|
|
20
18
|
}
|
|
21
19
|
});
|
|
@@ -24,7 +22,9 @@ export default function createApp(App, rootElement) {
|
|
|
24
22
|
if (isLoaded) {
|
|
25
23
|
return Promise.resolve(app);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
return promise;
|
|
29
26
|
};
|
|
30
|
-
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
createApp as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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/helpers/importOnInteraction.js
|
|
25
|
+
var importOnInteraction_exports = {};
|
|
26
|
+
__export(importOnInteraction_exports, {
|
|
27
|
+
default: () => importOnInteraction
|
|
28
|
+
});
|
|
29
|
+
var import_utils = require("./utils.cjs");
|
|
30
|
+
function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
|
|
31
|
+
const normalizedEvents = typeof events === "string" ? [events] : events;
|
|
32
|
+
let ResolvedClass;
|
|
33
|
+
const resolver = (resolve) => {
|
|
34
|
+
fn().then((module2) => {
|
|
35
|
+
ResolvedClass = "default" in module2 ? module2.default : module2;
|
|
36
|
+
resolve(ResolvedClass);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent?.$el);
|
|
41
|
+
const eventListenerOptions = {
|
|
42
|
+
capture: true,
|
|
43
|
+
passive: true,
|
|
44
|
+
once: true
|
|
45
|
+
};
|
|
46
|
+
const handler = () => {
|
|
47
|
+
resolver(resolve);
|
|
48
|
+
};
|
|
49
|
+
elements.forEach((element) => {
|
|
50
|
+
normalizedEvents.forEach((event) => {
|
|
51
|
+
element.addEventListener(event, handler, eventListenerOptions);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
module.exports = __toCommonJS(importOnInteraction_exports);
|
|
57
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { getTargetElements } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ResolvedClass = 'default' in module ? module.default : module;
|
|
1
|
+
import { getTargetElements } from "./utils.js";
|
|
2
|
+
function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
|
|
3
|
+
const normalizedEvents = typeof events === "string" ? [events] : events;
|
|
4
|
+
let ResolvedClass;
|
|
5
|
+
const resolver = (resolve) => {
|
|
6
|
+
fn().then((module) => {
|
|
7
|
+
ResolvedClass = "default" in module ? module.default : module;
|
|
9
8
|
resolve(ResolvedClass);
|
|
10
9
|
});
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var eventListenerOptions = {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const elements = getTargetElements(nameOrSelectorOrElement, parent?.$el);
|
|
13
|
+
const eventListenerOptions = {
|
|
16
14
|
capture: true,
|
|
17
15
|
passive: true,
|
|
18
16
|
once: true
|
|
19
17
|
};
|
|
20
|
-
|
|
21
|
-
var handler = () => {
|
|
18
|
+
const handler = () => {
|
|
22
19
|
resolver(resolve);
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
normalizedEvents.forEach(event => {
|
|
21
|
+
elements.forEach((element) => {
|
|
22
|
+
normalizedEvents.forEach((event) => {
|
|
27
23
|
element.addEventListener(event, handler, eventListenerOptions);
|
|
28
24
|
});
|
|
29
25
|
});
|
|
30
26
|
});
|
|
31
|
-
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
importOnInteraction as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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/helpers/importWhenIdle.js
|
|
25
|
+
var importWhenIdle_exports = {};
|
|
26
|
+
__export(importWhenIdle_exports, {
|
|
27
|
+
default: () => importWhenIdle
|
|
28
|
+
});
|
|
29
|
+
function importWhenIdle(fn, options) {
|
|
30
|
+
let ResolvedClass;
|
|
31
|
+
const resolver = (resolve) => {
|
|
32
|
+
fn().then((module2) => {
|
|
33
|
+
ResolvedClass = "default" in module2 ? module2.default : module2;
|
|
34
|
+
resolve(ResolvedClass);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
const timeout = options?.timeout ?? 1;
|
|
39
|
+
if (!("requestIdleCallback" in window)) {
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
resolver(resolve);
|
|
42
|
+
}, timeout);
|
|
43
|
+
} else {
|
|
44
|
+
window.requestIdleCallback(() => {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
resolver(resolve);
|
|
47
|
+
}, 0);
|
|
48
|
+
}, { timeout: options?.timeout });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
module.exports = __toCommonJS(importWhenIdle_exports);
|
|
53
|
+
if (module.exports.default) module.exports = module.exports.default;
|