@studiometa/js-toolkit 2.0.0-beta.9 → 2.0.0
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 +284 -0
- package/Base/index.d.ts +36 -28
- package/Base/index.js +113 -197
- package/Base/managers/ChildrenManager.cjs +146 -0
- package/Base/managers/ChildrenManager.d.ts +11 -3
- package/Base/managers/ChildrenManager.js +60 -59
- package/Base/managers/EventsManager.cjs +183 -0
- package/Base/managers/EventsManager.d.ts +13 -20
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +173 -0
- package/Base/managers/OptionsManager.d.ts +20 -13
- package/Base/managers/OptionsManager.js +60 -91
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.d.ts +4 -4
- package/Base/managers/RefsManager.js +28 -38
- package/Base/managers/ServicesManager.cjs +134 -0
- package/Base/managers/ServicesManager.d.ts +14 -8
- package/Base/managers/ServicesManager.js +42 -67
- package/Base/utils.cjs +41 -0
- package/Base/utils.d.ts +4 -4
- package/Base/utils.js +12 -11
- package/decorators/index.cjs +45 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +20 -8
- package/decorators/withBreakpointManager.cjs +84 -0
- package/decorators/withBreakpointManager.d.ts +2 -2
- package/decorators/withBreakpointManager.js +18 -40
- package/decorators/withBreakpointObserver.cjs +114 -0
- package/decorators/withBreakpointObserver.d.ts +1 -1
- package/decorators/withBreakpointObserver.js +45 -88
- package/decorators/withDrag.cjs +53 -0
- package/decorators/withDrag.d.ts +1 -1
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +43 -0
- package/decorators/withExtraConfig.d.ts +1 -1
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withFreezedOptions.cjs +37 -0
- package/decorators/withFreezedOptions.d.ts +14 -0
- package/decorators/withFreezedOptions.js +15 -0
- package/decorators/withIntersectionObserver.cjs +61 -0
- package/decorators/withIntersectionObserver.d.ts +1 -1
- package/decorators/withIntersectionObserver.js +29 -33
- package/decorators/withMountWhenInView.cjs +68 -0
- package/decorators/withMountWhenInView.d.ts +1 -1
- package/decorators/withMountWhenInView.js +31 -53
- package/decorators/withScrolledInView.cjs +114 -0
- package/decorators/withScrolledInView.d.ts +1 -1
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +61 -0
- package/decorators/withVue2.js +27 -32
- package/helpers/createApp.cjs +52 -0
- package/helpers/createApp.d.ts +3 -26
- package/helpers/createApp.js +12 -12
- package/helpers/getInstanceFromElement.cjs +32 -0
- package/helpers/getInstanceFromElement.d.ts +14 -0
- package/helpers/getInstanceFromElement.js +10 -0
- package/helpers/importOnInteraction.cjs +52 -0
- package/helpers/importOnInteraction.d.ts +3 -5
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +49 -0
- package/helpers/importWhenIdle.d.ts +3 -5
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +50 -0
- package/helpers/importWhenVisible.d.ts +4 -6
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +37 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +12 -4
- package/helpers/utils.cjs +35 -0
- package/helpers/utils.d.ts +3 -4
- package/helpers/utils.js +7 -6
- package/index.cjs +33 -0
- package/index.js +7 -4
- package/package.json +14 -4
- package/services/Service.cjs +76 -0
- package/services/Service.d.ts +9 -9
- package/services/Service.js +19 -32
- package/services/drag.cjs +212 -0
- package/services/drag.d.ts +3 -2
- package/services/drag.js +64 -69
- package/services/index.cjs +41 -0
- package/services/index.js +16 -7
- package/services/key.cjs +104 -0
- package/services/key.d.ts +1 -1
- package/services/key.js +28 -36
- package/services/load.cjs +72 -0
- package/services/load.d.ts +1 -1
- package/services/load.js +17 -19
- package/services/pointer.cjs +162 -0
- package/services/pointer.d.ts +1 -1
- package/services/pointer.js +43 -60
- package/services/raf.cjs +83 -0
- package/services/raf.d.ts +1 -1
- package/services/raf.js +20 -28
- package/services/resize.cjs +108 -0
- package/services/resize.d.ts +1 -1
- package/services/resize.js +33 -42
- package/services/scroll.cjs +131 -0
- package/services/scroll.d.ts +1 -1
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +34 -0
- package/utils/collide/boundingRectToCircle.d.ts +6 -6
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +34 -0
- package/utils/collide/collideCircleCircle.d.ts +4 -4
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +46 -0
- package/utils/collide/collideCircleRect.d.ts +8 -8
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +31 -0
- package/utils/collide/collidePointCircle.d.ts +6 -6
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +28 -0
- package/utils/collide/collidePointRect.d.ts +7 -7
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +28 -0
- package/utils/collide/collideRectRect.d.ts +5 -5
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +39 -0
- package/utils/collide/index.js +14 -6
- package/utils/css/classes.cjs +47 -0
- package/utils/css/classes.d.ts +13 -12
- package/utils/css/classes.js +19 -15
- package/utils/css/index.cjs +38 -0
- package/utils/css/index.d.ts +2 -2
- package/utils/css/index.js +13 -6
- package/utils/css/matrix.cjs +30 -0
- package/utils/css/matrix.d.ts +14 -15
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +44 -0
- package/utils/css/styles.d.ts +8 -20
- package/utils/css/styles.js +12 -12
- package/utils/css/transition.cjs +120 -0
- package/utils/css/transition.d.ts +15 -9
- package/utils/css/transition.js +70 -119
- package/utils/debounce.cjs +34 -0
- package/utils/debounce.d.ts +4 -4
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +82 -0
- package/utils/focusTrap.d.ts +1 -0
- package/utils/focusTrap.js +31 -22
- package/utils/history.cjs +89 -0
- package/utils/history.d.ts +13 -11
- package/utils/history.js +28 -57
- package/utils/index.cjs +54 -0
- package/utils/index.d.ts +4 -1
- package/utils/index.js +32 -11
- package/utils/keyCodes.cjs +35 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +28 -0
- package/utils/math/clamp.d.ts +1 -1
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +32 -0
- package/utils/math/clamp01.d.ts +1 -1
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +28 -0
- package/utils/math/damp.d.ts +6 -6
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +88 -0
- package/utils/math/ease.d.ts +7 -7
- package/utils/math/ease.js +50 -25
- package/utils/math/index.cjs +43 -0
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +37 -0
- package/utils/math/inertiaFinalValue.d.ts +5 -5
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +28 -0
- package/utils/math/lerp.d.ts +4 -4
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +28 -0
- package/utils/math/map.d.ts +6 -6
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +28 -0
- package/utils/math/round.d.ts +4 -4
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +43 -0
- package/utils/memoize.d.ts +1 -1
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +38 -0
- package/utils/nextFrame.d.ts +6 -6
- package/utils/nextFrame.js +13 -10
- package/utils/nextMicrotask.cjs +28 -0
- package/utils/nextMicrotask.d.ts +8 -0
- package/utils/nextMicrotask.js +6 -0
- package/utils/nextTick.cjs +30 -0
- package/utils/nextTick.d.ts +8 -0
- package/utils/nextTick.js +8 -0
- package/utils/object/autoBind.cjs +49 -0
- package/utils/object/autoBind.d.ts +3 -3
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +37 -0
- package/utils/object/getAllProperties.d.ts +3 -3
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +33 -0
- package/utils/object/index.js +8 -3
- package/utils/object/isObject.cjs +28 -0
- package/utils/object/isObject.d.ts +1 -1
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +80 -0
- package/utils/scrollTo.d.ts +1 -1
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +47 -0
- package/utils/string/index.js +22 -10
- package/utils/string/withLeadingCharacters.cjs +32 -0
- package/utils/string/withLeadingCharacters.d.ts +3 -2
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +32 -0
- package/utils/string/withLeadingSlash.d.ts +1 -1
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +32 -0
- package/utils/string/withTrailingCharacters.d.ts +3 -2
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +32 -0
- package/utils/string/withTrailingSlash.d.ts +1 -1
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +28 -0
- package/utils/string/withoutLeadingCharacters.d.ts +3 -2
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutLeadingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +32 -0
- package/utils/string/withoutLeadingSlash.d.ts +1 -1
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +28 -0
- package/utils/string/withoutTrailingCharacters.d.ts +3 -2
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutTrailingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +32 -0
- package/utils/string/withoutTrailingSlash.d.ts +1 -1
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +36 -0
- package/utils/throttle.d.ts +3 -3
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @template {BaseConstructor} T
|
|
5
5
|
* @param {T} BaseClass The Base class to extend from.
|
|
6
|
-
* @
|
|
6
|
+
* @returns {T}
|
|
7
7
|
*/
|
|
8
8
|
export default function withBreakpointObserver<T extends typeof import("../Base").default>(BaseClass: T): T;
|
|
9
9
|
export type Base = import('../Base').default;
|
|
@@ -1,133 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import useResize from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import useResize from "../services/resize.js";
|
|
8
|
+
function testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {
|
|
9
|
+
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
10
|
+
const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
|
|
11
|
+
const isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(" ").includes(breakpoint);
|
|
18
12
|
if (activeBreakpoints && isInActiveBreakpoint || inactiveBreakpoints && !isInInactiveBreakpoint) {
|
|
19
|
-
return
|
|
13
|
+
return "$mount";
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
return '$destroy';
|
|
15
|
+
return "$destroy";
|
|
23
16
|
}
|
|
24
|
-
|
|
25
17
|
function hasBreakpointConfiguration(instance) {
|
|
26
|
-
|
|
27
|
-
activeBreakpoints,
|
|
28
|
-
inactiveBreakpoints
|
|
29
|
-
} = instance.$options;
|
|
18
|
+
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
30
19
|
return Boolean(activeBreakpoints || inactiveBreakpoints);
|
|
31
20
|
}
|
|
32
|
-
|
|
33
21
|
function testConflictingBreakpointConfiguration(instance) {
|
|
34
|
-
|
|
35
|
-
activeBreakpoints,
|
|
36
|
-
inactiveBreakpoints,
|
|
37
|
-
name
|
|
38
|
-
} = instance.$options;
|
|
39
|
-
|
|
22
|
+
const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
|
|
40
23
|
if (activeBreakpoints && inactiveBreakpoints) {
|
|
41
|
-
throw new Error(
|
|
24
|
+
throw new Error(`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`);
|
|
42
25
|
}
|
|
43
26
|
}
|
|
44
|
-
|
|
45
27
|
function addToResize(key, instance) {
|
|
46
28
|
testConflictingBreakpointConfiguration(instance);
|
|
47
|
-
|
|
48
|
-
add,
|
|
49
|
-
has
|
|
50
|
-
} = useResize();
|
|
51
|
-
|
|
29
|
+
const { add, has } = useResize();
|
|
52
30
|
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) {
|
|
31
|
+
add(key, function onResize({ breakpoint }) {
|
|
32
|
+
const action = testBreakpoints(instance, breakpoint);
|
|
33
|
+
if (action === "$destroy" && instance.$isMounted) {
|
|
60
34
|
instance[action]();
|
|
61
|
-
} else if (action ===
|
|
35
|
+
} else if (action === "$mount" && !instance.$isMounted) {
|
|
62
36
|
setTimeout(() => instance[action](), 0);
|
|
63
37
|
}
|
|
64
38
|
});
|
|
65
39
|
}
|
|
66
40
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return _temp = _class = class extends BaseClass {
|
|
41
|
+
function withBreakpointObserver(BaseClass) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return _b = class extends BaseClass {
|
|
72
44
|
constructor(element) {
|
|
73
45
|
super(element);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
props
|
|
77
|
-
} = useResize();
|
|
78
|
-
var {
|
|
79
|
-
name
|
|
80
|
-
} = this.$options;
|
|
81
|
-
|
|
46
|
+
const { remove, props } = useResize();
|
|
47
|
+
const { name } = this.$options;
|
|
82
48
|
if (!props().breakpoint) {
|
|
83
|
-
throw new Error(
|
|
49
|
+
throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
|
|
84
50
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var [mutation] = _ref2;
|
|
89
|
-
|
|
90
|
-
if (mutation.type === 'attributes' && (mutation.attributeName === 'data-options' || mutation.attributeName.startsWith('data-option-'))) {
|
|
51
|
+
const key = `BreakpointObserver-${this.$id}`;
|
|
52
|
+
const mutationObserver = new MutationObserver(([mutation]) => {
|
|
53
|
+
if (mutation.type === "attributes" && (mutation.attributeName === "data-options" || mutation.attributeName.startsWith("data-option-"))) {
|
|
91
54
|
if (!hasBreakpointConfiguration(this)) {
|
|
92
55
|
this.$mount();
|
|
93
56
|
remove(key);
|
|
94
57
|
return;
|
|
95
58
|
}
|
|
96
|
-
|
|
97
59
|
addToResize(key, this);
|
|
98
60
|
}
|
|
99
61
|
});
|
|
100
|
-
mutationObserver.observe(this.$el, {
|
|
101
|
-
attributes: true
|
|
102
|
-
});
|
|
103
|
-
|
|
62
|
+
mutationObserver.observe(this.$el, { attributes: true });
|
|
104
63
|
if (!hasBreakpointConfiguration(this)) {
|
|
105
|
-
return
|
|
64
|
+
return;
|
|
106
65
|
}
|
|
107
|
-
|
|
108
66
|
addToResize(key, this);
|
|
109
|
-
return this;
|
|
110
67
|
}
|
|
111
|
-
|
|
112
68
|
$mount() {
|
|
113
69
|
if (!hasBreakpointConfiguration(this)) {
|
|
114
70
|
return super.$mount();
|
|
115
71
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (action === '$mount') {
|
|
72
|
+
const action = testBreakpoints(this);
|
|
73
|
+
if (action === "$mount") {
|
|
120
74
|
return super.$mount();
|
|
121
75
|
}
|
|
122
|
-
|
|
123
76
|
return this;
|
|
124
77
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
name:
|
|
128
|
-
options:
|
|
78
|
+
}, __publicField(_b, "config", {
|
|
79
|
+
...BaseClass.config,
|
|
80
|
+
name: `${BaseClass.config.name}WithBreakpointObserver`,
|
|
81
|
+
options: {
|
|
82
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
129
83
|
activeBreakpoints: String,
|
|
130
84
|
inactiveBreakpoints: String
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
}
|
|
85
|
+
}
|
|
86
|
+
}), _b;
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
withBreakpointObserver as default
|
|
90
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/js-toolkit/decorators/withDrag.js
|
|
28
|
+
var withDrag_exports = {};
|
|
29
|
+
__export(withDrag_exports, {
|
|
30
|
+
default: () => withDrag
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(withDrag_exports);
|
|
33
|
+
var import_drag = __toESM(require("../services/drag.cjs"), 1);
|
|
34
|
+
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
|
|
35
|
+
var _a;
|
|
36
|
+
return _a = class extends BaseClass {
|
|
37
|
+
constructor(el) {
|
|
38
|
+
super(el);
|
|
39
|
+
this.$on("mounted", () => {
|
|
40
|
+
this.$services.register("dragged", import_drag.default.bind(void 0, target.call(this, this), options));
|
|
41
|
+
this.$services.enable("dragged");
|
|
42
|
+
});
|
|
43
|
+
this.$on("destroyed", () => {
|
|
44
|
+
this.$services.disable("dragged");
|
|
45
|
+
this.$services.unregister("dragged");
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, __publicField(_a, "config", {
|
|
49
|
+
name: `${BaseClass.config.name}WithDrag`,
|
|
50
|
+
emits: ["dragged"]
|
|
51
|
+
}), _a;
|
|
52
|
+
}
|
|
53
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/decorators/withDrag.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @template {BaseConstructor} T
|
|
13
13
|
* @param {T} BaseClass
|
|
14
14
|
* @param {DragDecoratorOptions} options
|
|
15
|
-
* @
|
|
15
|
+
* @returns {T}
|
|
16
16
|
*/
|
|
17
17
|
export default function withDrag<T extends typeof import("../Base").default>(BaseClass: T, { target, ...options }?: DragDecoratorOptions): T;
|
|
18
18
|
export type Base = import('../Base').default;
|
package/decorators/withDrag.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} = _ref,
|
|
12
|
-
options = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
-
|
|
14
|
-
return _temp = _class = class extends BaseClass {
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import useDrag from "../services/drag.js";
|
|
8
|
+
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
|
|
9
|
+
var _a;
|
|
10
|
+
return _a = class extends BaseClass {
|
|
15
11
|
constructor(el) {
|
|
16
12
|
super(el);
|
|
17
|
-
this.$on(
|
|
18
|
-
this.$services.register(
|
|
19
|
-
this.$services.enable(
|
|
13
|
+
this.$on("mounted", () => {
|
|
14
|
+
this.$services.register("dragged", useDrag.bind(void 0, target.call(this, this), options));
|
|
15
|
+
this.$services.enable("dragged");
|
|
20
16
|
});
|
|
21
|
-
this.$on(
|
|
22
|
-
this.$services.disable(
|
|
23
|
-
this.$services.unregister(
|
|
17
|
+
this.$on("destroyed", () => {
|
|
18
|
+
this.$services.disable("dragged");
|
|
19
|
+
this.$services.unregister("dragged");
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
}, __publicField(_a, "config", {
|
|
23
|
+
name: `${BaseClass.config.name}WithDrag`,
|
|
24
|
+
emits: ["dragged"]
|
|
25
|
+
}), _a;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
withDrag as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/js-toolkit/decorators/withExtraConfig.js
|
|
28
|
+
var withExtraConfig_exports = {};
|
|
29
|
+
__export(withExtraConfig_exports, {
|
|
30
|
+
default: () => withExtraConfig
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(withExtraConfig_exports);
|
|
33
|
+
var import_deepmerge = __toESM(require("deepmerge"), 1);
|
|
34
|
+
function withExtraConfig(BaseClass, config, options = {}) {
|
|
35
|
+
var _a;
|
|
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 _a = class extends BaseClass {
|
|
41
|
+
}, __publicField(_a, "config", newConfig), _a;
|
|
42
|
+
}
|
|
43
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @param {T} BaseClass The Base class to extend.
|
|
11
11
|
* @param {Partial<BaseConfig>} config Extra configuration to merge.
|
|
12
12
|
* @param {DeepmergeOptions} options Options for the `deepmerge` function. {@link https://github.com/TehShrike/deepmerge#options}
|
|
13
|
-
* @
|
|
13
|
+
* @returns {T}
|
|
14
14
|
*/
|
|
15
15
|
export default function withExtraConfig<T extends typeof import("../Base").default>(BaseClass: T, config: Partial<BaseConfig>, options?: DeepmergeOptions): T;
|
|
16
16
|
export type DeepmergeOptions = import('deepmerge').Options;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import merge from "deepmerge";
|
|
8
|
+
function withExtraConfig(BaseClass, config, options = {}) {
|
|
9
|
+
var _a;
|
|
10
|
+
const newConfig = merge(BaseClass.config, config, options);
|
|
9
11
|
if (newConfig.name === BaseClass.config.name) {
|
|
10
|
-
newConfig.name =
|
|
12
|
+
newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
14
|
+
return _a = class extends BaseClass {
|
|
15
|
+
}, __publicField(_a, "config", newConfig), _a;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
withExtraConfig as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/decorators/withFreezedOptions.js
|
|
20
|
+
var withFreezedOptions_exports = {};
|
|
21
|
+
__export(withFreezedOptions_exports, {
|
|
22
|
+
default: () => withFreezedOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(withFreezedOptions_exports);
|
|
25
|
+
function withFreezedOptions(BaseClass) {
|
|
26
|
+
return class extends BaseClass {
|
|
27
|
+
get $options() {
|
|
28
|
+
Object.defineProperty(this, "$options", {
|
|
29
|
+
value: Object.freeze({ ...super.$options }),
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
return this.$options;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base').BaseOptions} BaseOptions
|
|
3
|
+
* @typedef {import('../Base').BaseConstructor} BaseConstructor
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Freeze the `$options` property to improve performance.
|
|
7
|
+
*
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
|
+
* @param {T} BaseClass The Base class to extend.
|
|
10
|
+
* @returns {T}
|
|
11
|
+
*/
|
|
12
|
+
export default function withFreezedOptions<T extends typeof import("../Base").default>(BaseClass: T): T;
|
|
13
|
+
export type BaseOptions = import('../Base').BaseOptions;
|
|
14
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function withFreezedOptions(BaseClass) {
|
|
2
|
+
return class extends BaseClass {
|
|
3
|
+
get $options() {
|
|
4
|
+
Object.defineProperty(this, "$options", {
|
|
5
|
+
value: Object.freeze({ ...super.$options }),
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true
|
|
8
|
+
});
|
|
9
|
+
return this.$options;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
withFreezedOptions as default
|
|
15
|
+
};
|
|
@@ -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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/decorators/withIntersectionObserver.js
|
|
25
|
+
var withIntersectionObserver_exports = {};
|
|
26
|
+
__export(withIntersectionObserver_exports, {
|
|
27
|
+
default: () => withIntersectionObserver
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(withIntersectionObserver_exports);
|
|
30
|
+
function createArrayOfNumber(length) {
|
|
31
|
+
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
32
|
+
}
|
|
33
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
return _b = class extends BaseClass {
|
|
36
|
+
constructor(element) {
|
|
37
|
+
super(element);
|
|
38
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
39
|
+
this.__callMethod("intersected", entries);
|
|
40
|
+
}, {
|
|
41
|
+
...defaultOptions,
|
|
42
|
+
...this.$options.intersectionObserver
|
|
43
|
+
});
|
|
44
|
+
this.$on("mounted", () => {
|
|
45
|
+
this.$observer.observe(this.$el);
|
|
46
|
+
});
|
|
47
|
+
this.$on("destroyed", () => {
|
|
48
|
+
this.$observer.unobserve(this.$el);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, __publicField(_b, "config", {
|
|
52
|
+
...BaseClass.config,
|
|
53
|
+
name: `${BaseClass.config.name}WithIntersectionObserver`,
|
|
54
|
+
options: {
|
|
55
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
56
|
+
intersectionObserver: Object
|
|
57
|
+
},
|
|
58
|
+
emits: ["intersected"]
|
|
59
|
+
}), _b;
|
|
60
|
+
}
|
|
61
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @template {BaseConstructor} T
|
|
5
5
|
* @param {T} BaseClass The Base class to extend.
|
|
6
6
|
* @param {Object} [defaultOptions] The options for the IntersectionObserver instance.
|
|
7
|
-
* @
|
|
7
|
+
* @returns {T & { new: (element:HTMLElement) => { $observer: IntersectionObserver }}}
|
|
8
8
|
*/
|
|
9
9
|
export default function withIntersectionObserver<T extends typeof import("../Base").default>(BaseClass: T, defaultOptions?: any): T & {
|
|
10
10
|
new: (element: HTMLElement) => {
|
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
7
|
function createArrayOfNumber(length) {
|
|
8
8
|
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
15
|
-
threshold: createArrayOfNumber(100)
|
|
16
|
-
};
|
|
17
|
-
return _temp = _class = class extends BaseClass {
|
|
10
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
return _b = class extends BaseClass {
|
|
18
13
|
constructor(element) {
|
|
19
14
|
super(element);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver || {}));
|
|
28
|
-
this.$on('mounted', () => {
|
|
15
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
16
|
+
this.__callMethod("intersected", entries);
|
|
17
|
+
}, {
|
|
18
|
+
...defaultOptions,
|
|
19
|
+
...this.$options.intersectionObserver
|
|
20
|
+
});
|
|
21
|
+
this.$on("mounted", () => {
|
|
29
22
|
this.$observer.observe(this.$el);
|
|
30
23
|
});
|
|
31
|
-
this.$on(
|
|
24
|
+
this.$on("destroyed", () => {
|
|
32
25
|
this.$observer.unobserve(this.$el);
|
|
33
26
|
});
|
|
34
|
-
return this;
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
name:
|
|
39
|
-
options:
|
|
28
|
+
}, __publicField(_b, "config", {
|
|
29
|
+
...BaseClass.config,
|
|
30
|
+
name: `${BaseClass.config.name}WithIntersectionObserver`,
|
|
31
|
+
options: {
|
|
32
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
40
33
|
intersectionObserver: Object
|
|
41
|
-
}
|
|
42
|
-
emits: [
|
|
43
|
-
})
|
|
44
|
-
}
|
|
34
|
+
},
|
|
35
|
+
emits: ["intersected"]
|
|
36
|
+
}), _b;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
withIntersectionObserver as default
|
|
40
|
+
};
|