@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,133 +1,85 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import useResize from '../services/resize.js';
|
|
8
|
-
|
|
9
|
-
function testBreakpoints(instance) {
|
|
10
|
-
var breakpoint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : useResize().props().breakpoint;
|
|
11
|
-
var {
|
|
12
|
-
activeBreakpoints,
|
|
13
|
-
inactiveBreakpoints
|
|
14
|
-
} = instance.$options;
|
|
15
|
-
var isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);
|
|
16
|
-
var isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);
|
|
17
|
-
|
|
1
|
+
import useResize from "../services/resize.js";
|
|
2
|
+
function testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {
|
|
3
|
+
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
4
|
+
const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
|
|
5
|
+
const isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(" ").includes(breakpoint);
|
|
18
6
|
if (activeBreakpoints && isInActiveBreakpoint || inactiveBreakpoints && !isInInactiveBreakpoint) {
|
|
19
|
-
return
|
|
7
|
+
return "$mount";
|
|
20
8
|
}
|
|
21
|
-
|
|
22
|
-
return '$destroy';
|
|
9
|
+
return "$destroy";
|
|
23
10
|
}
|
|
24
|
-
|
|
25
11
|
function hasBreakpointConfiguration(instance) {
|
|
26
|
-
|
|
27
|
-
activeBreakpoints,
|
|
28
|
-
inactiveBreakpoints
|
|
29
|
-
} = instance.$options;
|
|
12
|
+
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
30
13
|
return Boolean(activeBreakpoints || inactiveBreakpoints);
|
|
31
14
|
}
|
|
32
|
-
|
|
33
15
|
function testConflictingBreakpointConfiguration(instance) {
|
|
34
|
-
|
|
35
|
-
activeBreakpoints,
|
|
36
|
-
inactiveBreakpoints,
|
|
37
|
-
name
|
|
38
|
-
} = instance.$options;
|
|
39
|
-
|
|
16
|
+
const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
|
|
40
17
|
if (activeBreakpoints && inactiveBreakpoints) {
|
|
41
|
-
throw new Error(
|
|
18
|
+
throw new Error(`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`);
|
|
42
19
|
}
|
|
43
20
|
}
|
|
44
|
-
|
|
45
21
|
function addToResize(key, instance) {
|
|
46
22
|
testConflictingBreakpointConfiguration(instance);
|
|
47
|
-
|
|
48
|
-
add,
|
|
49
|
-
has
|
|
50
|
-
} = useResize();
|
|
51
|
-
|
|
23
|
+
const { add, has } = useResize();
|
|
52
24
|
if (!has(key)) {
|
|
53
|
-
add(key, function onResize(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} = _ref;
|
|
57
|
-
var action = testBreakpoints(instance, breakpoint);
|
|
58
|
-
|
|
59
|
-
if (action === '$destroy' && instance.$isMounted) {
|
|
25
|
+
add(key, function onResize({ breakpoint }) {
|
|
26
|
+
const action = testBreakpoints(instance, breakpoint);
|
|
27
|
+
if (action === "$destroy" && instance.$isMounted) {
|
|
60
28
|
instance[action]();
|
|
61
|
-
} else if (action ===
|
|
29
|
+
} else if (action === "$mount" && !instance.$isMounted) {
|
|
62
30
|
setTimeout(() => instance[action](), 0);
|
|
63
31
|
}
|
|
64
32
|
});
|
|
65
33
|
}
|
|
66
34
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
35
|
+
function withBreakpointObserver(BaseClass) {
|
|
36
|
+
return class extends BaseClass {
|
|
37
|
+
static config = {
|
|
38
|
+
...BaseClass.config || {},
|
|
39
|
+
name: `${BaseClass?.config?.name ?? ""}WithBreakpointObserver`,
|
|
40
|
+
options: {
|
|
41
|
+
...BaseClass?.config?.options || {},
|
|
42
|
+
activeBreakpoints: String,
|
|
43
|
+
inactiveBreakpoints: String
|
|
44
|
+
}
|
|
45
|
+
};
|
|
72
46
|
constructor(element) {
|
|
73
47
|
super(element);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
props
|
|
77
|
-
} = useResize();
|
|
78
|
-
var {
|
|
79
|
-
name
|
|
80
|
-
} = this.$options;
|
|
81
|
-
|
|
48
|
+
const { remove, props } = useResize();
|
|
49
|
+
const { name } = this.$options;
|
|
82
50
|
if (!props().breakpoint) {
|
|
83
|
-
throw new Error(
|
|
51
|
+
throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
|
|
84
52
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var [mutation] = _ref2;
|
|
89
|
-
|
|
90
|
-
if (mutation.type === 'attributes' && (mutation.attributeName === 'data-options' || mutation.attributeName.startsWith('data-option-'))) {
|
|
53
|
+
const key = `BreakpointObserver-${this.$id}`;
|
|
54
|
+
const mutationObserver = new MutationObserver(([mutation]) => {
|
|
55
|
+
if (mutation.type === "attributes" && (mutation.attributeName === "data-options" || mutation.attributeName.startsWith("data-option-"))) {
|
|
91
56
|
if (!hasBreakpointConfiguration(this)) {
|
|
92
57
|
this.$mount();
|
|
93
58
|
remove(key);
|
|
94
59
|
return;
|
|
95
60
|
}
|
|
96
|
-
|
|
97
61
|
addToResize(key, this);
|
|
98
62
|
}
|
|
99
63
|
});
|
|
100
|
-
mutationObserver.observe(this.$el, {
|
|
101
|
-
attributes: true
|
|
102
|
-
});
|
|
103
|
-
|
|
64
|
+
mutationObserver.observe(this.$el, { attributes: true });
|
|
104
65
|
if (!hasBreakpointConfiguration(this)) {
|
|
105
66
|
return this;
|
|
106
67
|
}
|
|
107
|
-
|
|
108
68
|
addToResize(key, this);
|
|
109
69
|
return this;
|
|
110
70
|
}
|
|
111
|
-
|
|
112
71
|
$mount() {
|
|
113
72
|
if (!hasBreakpointConfiguration(this)) {
|
|
114
73
|
return super.$mount();
|
|
115
74
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (action === '$mount') {
|
|
75
|
+
const action = testBreakpoints(this);
|
|
76
|
+
if (action === "$mount") {
|
|
120
77
|
return super.$mount();
|
|
121
78
|
}
|
|
122
|
-
|
|
123
79
|
return this;
|
|
124
80
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
inactiveBreakpoints: String
|
|
131
|
-
})
|
|
132
|
-
})), _temp;
|
|
133
|
-
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
withBreakpointObserver as default
|
|
85
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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/withDrag.js
|
|
30
|
+
var withDrag_exports = {};
|
|
31
|
+
__export(withDrag_exports, {
|
|
32
|
+
default: () => withDrag
|
|
33
|
+
});
|
|
34
|
+
var import_drag = __toESM(require("../services/drag.cjs"), 1);
|
|
35
|
+
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
|
|
36
|
+
return class extends BaseClass {
|
|
37
|
+
static config = {
|
|
38
|
+
name: `${BaseClass.config.name}WithDrag`,
|
|
39
|
+
emits: ["dragged"]
|
|
40
|
+
};
|
|
41
|
+
constructor(el) {
|
|
42
|
+
super(el);
|
|
43
|
+
this.$on("mounted", () => {
|
|
44
|
+
this.$services.register("dragged", import_drag.default.bind(void 0, target.call(this, this), options));
|
|
45
|
+
this.$services.enable("dragged");
|
|
46
|
+
});
|
|
47
|
+
this.$on("destroyed", () => {
|
|
48
|
+
this.$services.disable("dragged");
|
|
49
|
+
this.$services.unregister("dragged");
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
module.exports = __toCommonJS(withDrag_exports);
|
|
55
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/decorators/withDrag.js
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
9
|
-
{
|
|
10
|
-
target = instance => instance.$el
|
|
11
|
-
} = _ref,
|
|
12
|
-
options = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
-
|
|
14
|
-
return _temp = _class = class extends BaseClass {
|
|
1
|
+
import useDrag from "../services/drag.js";
|
|
2
|
+
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
|
|
3
|
+
return class extends BaseClass {
|
|
4
|
+
static config = {
|
|
5
|
+
name: `${BaseClass.config.name}WithDrag`,
|
|
6
|
+
emits: ["dragged"]
|
|
7
|
+
};
|
|
15
8
|
constructor(el) {
|
|
16
9
|
super(el);
|
|
17
|
-
this.$on(
|
|
18
|
-
this.$services.register(
|
|
19
|
-
this.$services.enable(
|
|
10
|
+
this.$on("mounted", () => {
|
|
11
|
+
this.$services.register("dragged", useDrag.bind(void 0, target.call(this, this), options));
|
|
12
|
+
this.$services.enable("dragged");
|
|
20
13
|
});
|
|
21
|
-
this.$on(
|
|
22
|
-
this.$services.disable(
|
|
23
|
-
this.$services.unregister(
|
|
14
|
+
this.$on("destroyed", () => {
|
|
15
|
+
this.$services.disable("dragged");
|
|
16
|
+
this.$services.unregister("dragged");
|
|
24
17
|
});
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
withDrag as default
|
|
23
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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/withExtraConfig.js
|
|
30
|
+
var withExtraConfig_exports = {};
|
|
31
|
+
__export(withExtraConfig_exports, {
|
|
32
|
+
default: () => withExtraConfig
|
|
33
|
+
});
|
|
34
|
+
var import_deepmerge = __toESM(require("deepmerge"), 1);
|
|
35
|
+
function withExtraConfig(BaseClass, config, options = {}) {
|
|
36
|
+
const newConfig = (0, import_deepmerge.default)(BaseClass.config, config, options);
|
|
37
|
+
if (newConfig.name === BaseClass.config.name) {
|
|
38
|
+
newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
|
|
39
|
+
}
|
|
40
|
+
return class extends BaseClass {
|
|
41
|
+
static config = newConfig;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
module.exports = __toCommonJS(withExtraConfig_exports);
|
|
45
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _class, _temp;
|
|
5
|
-
|
|
6
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
7
|
-
var newConfig = merge(BaseClass.config, config, options);
|
|
8
|
-
|
|
1
|
+
import merge from "deepmerge";
|
|
2
|
+
function withExtraConfig(BaseClass, config, options = {}) {
|
|
3
|
+
const newConfig = merge(BaseClass.config, config, options);
|
|
9
4
|
if (newConfig.name === BaseClass.config.name) {
|
|
10
|
-
newConfig.name =
|
|
5
|
+
newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
|
|
11
6
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
7
|
+
return class extends BaseClass {
|
|
8
|
+
static config = newConfig;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
withExtraConfig as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
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/withIntersectionObserver.js
|
|
25
|
+
var withIntersectionObserver_exports = {};
|
|
26
|
+
__export(withIntersectionObserver_exports, {
|
|
27
|
+
default: () => withIntersectionObserver
|
|
28
|
+
});
|
|
29
|
+
function createArrayOfNumber(length) {
|
|
30
|
+
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
31
|
+
}
|
|
32
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
33
|
+
return class extends BaseClass {
|
|
34
|
+
static config = {
|
|
35
|
+
...BaseClass.config || {},
|
|
36
|
+
name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
|
|
37
|
+
options: {
|
|
38
|
+
...BaseClass?.config?.options || {},
|
|
39
|
+
intersectionObserver: Object
|
|
40
|
+
},
|
|
41
|
+
emits: ["intersected"]
|
|
42
|
+
};
|
|
43
|
+
constructor(element) {
|
|
44
|
+
super(element);
|
|
45
|
+
if (!this.intersected || typeof this.intersected !== "function") {
|
|
46
|
+
throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
|
|
47
|
+
}
|
|
48
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
49
|
+
this.__callMethod("intersected", entries);
|
|
50
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver || {} });
|
|
51
|
+
this.$on("mounted", () => {
|
|
52
|
+
this.$observer.observe(this.$el);
|
|
53
|
+
});
|
|
54
|
+
this.$on("destroyed", () => {
|
|
55
|
+
this.$observer.unobserve(this.$el);
|
|
56
|
+
});
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
module.exports = __toCommonJS(withIntersectionObserver_exports);
|
|
62
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,44 +1,35 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
1
|
function createArrayOfNumber(length) {
|
|
8
2
|
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
9
3
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
5
|
+
return class extends BaseClass {
|
|
6
|
+
static config = {
|
|
7
|
+
...BaseClass.config || {},
|
|
8
|
+
name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
|
|
9
|
+
options: {
|
|
10
|
+
...BaseClass?.config?.options || {},
|
|
11
|
+
intersectionObserver: Object
|
|
12
|
+
},
|
|
13
|
+
emits: ["intersected"]
|
|
14
|
+
};
|
|
18
15
|
constructor(element) {
|
|
19
16
|
super(element);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
throw new Error('[withIntersectionObserver] The `intersected` method must be defined.');
|
|
17
|
+
if (!this.intersected || typeof this.intersected !== "function") {
|
|
18
|
+
throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.$on('mounted', () => {
|
|
20
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
21
|
+
this.__callMethod("intersected", entries);
|
|
22
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver || {} });
|
|
23
|
+
this.$on("mounted", () => {
|
|
29
24
|
this.$observer.observe(this.$el);
|
|
30
25
|
});
|
|
31
|
-
this.$on(
|
|
26
|
+
this.$on("destroyed", () => {
|
|
32
27
|
this.$observer.unobserve(this.$el);
|
|
33
28
|
});
|
|
34
29
|
return this;
|
|
35
30
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}),
|
|
42
|
-
emits: ['intersected']
|
|
43
|
-
})), _temp;
|
|
44
|
-
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
withIntersectionObserver as default
|
|
35
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
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/withMountWhenInView.js
|
|
25
|
+
var withMountWhenInView_exports = {};
|
|
26
|
+
__export(withMountWhenInView_exports, {
|
|
27
|
+
default: () => withMountWhenInView
|
|
28
|
+
});
|
|
29
|
+
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
30
|
+
return class extends BaseClass {
|
|
31
|
+
static config = {
|
|
32
|
+
...BaseClass.config || {},
|
|
33
|
+
name: `${BaseClass?.config?.name ?? ""}WithMountWhenInView`,
|
|
34
|
+
options: {
|
|
35
|
+
...BaseClass?.config?.options || {},
|
|
36
|
+
intersectionObserver: Object
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
#isVisible = false;
|
|
40
|
+
#observer;
|
|
41
|
+
constructor(element) {
|
|
42
|
+
super(element);
|
|
43
|
+
this.#observer = new IntersectionObserver((entries) => {
|
|
44
|
+
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
45
|
+
if (this.#isVisible !== isVisible) {
|
|
46
|
+
this.#isVisible = isVisible;
|
|
47
|
+
if (isVisible) {
|
|
48
|
+
this.$mount();
|
|
49
|
+
} else {
|
|
50
|
+
setTimeout(() => this.$destroy());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver });
|
|
54
|
+
this.#observer.observe(this.$el);
|
|
55
|
+
this.$on("terminated", () => {
|
|
56
|
+
this.#observer.disconnect();
|
|
57
|
+
});
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
$mount() {
|
|
61
|
+
if (this.#isVisible) {
|
|
62
|
+
super.$mount();
|
|
63
|
+
}
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
module.exports = __toCommonJS(withMountWhenInView_exports);
|
|
69
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,69 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default function withMountWhenInView(BaseClass) {
|
|
14
|
-
var _class, _isVisible, _observer, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
|
|
15
|
-
|
|
16
|
-
var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
17
|
-
threshold: [0, 1]
|
|
18
|
-
};
|
|
19
|
-
return _temp = (_isVisible = new WeakMap(), _observer = new WeakMap(), _class = class extends BaseClass {
|
|
1
|
+
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
2
|
+
return class extends BaseClass {
|
|
3
|
+
static config = {
|
|
4
|
+
...BaseClass.config || {},
|
|
5
|
+
name: `${BaseClass?.config?.name ?? ""}WithMountWhenInView`,
|
|
6
|
+
options: {
|
|
7
|
+
...BaseClass?.config?.options || {},
|
|
8
|
+
intersectionObserver: Object
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
#isVisible = false;
|
|
12
|
+
#observer;
|
|
20
13
|
constructor(element) {
|
|
21
14
|
super(element);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
_classPrivateFieldInitSpec(this, _observer, {
|
|
29
|
-
writable: true,
|
|
30
|
-
value: void 0
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
_classPrivateFieldSet(this, _observer, new IntersectionObserver(entries => {
|
|
34
|
-
var isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
35
|
-
|
|
36
|
-
if (_classPrivateFieldGet(this, _isVisible) !== isVisible) {
|
|
37
|
-
_classPrivateFieldSet(this, _isVisible, isVisible);
|
|
38
|
-
|
|
15
|
+
this.#observer = new IntersectionObserver((entries) => {
|
|
16
|
+
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
17
|
+
if (this.#isVisible !== isVisible) {
|
|
18
|
+
this.#isVisible = isVisible;
|
|
39
19
|
if (isVisible) {
|
|
40
20
|
this.$mount();
|
|
41
21
|
} else {
|
|
42
22
|
setTimeout(() => this.$destroy());
|
|
43
23
|
}
|
|
44
24
|
}
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.$on('terminated', () => {
|
|
50
|
-
_classPrivateFieldGet(this, _observer).disconnect();
|
|
25
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver });
|
|
26
|
+
this.#observer.observe(this.$el);
|
|
27
|
+
this.$on("terminated", () => {
|
|
28
|
+
this.#observer.disconnect();
|
|
51
29
|
});
|
|
52
30
|
return this;
|
|
53
31
|
}
|
|
54
|
-
|
|
55
32
|
$mount() {
|
|
56
|
-
if (
|
|
33
|
+
if (this.#isVisible) {
|
|
57
34
|
super.$mount();
|
|
58
35
|
}
|
|
59
|
-
|
|
60
36
|
return this;
|
|
61
37
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
})), _temp;
|
|
69
|
-
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
withMountWhenInView as default
|
|
42
|
+
};
|