@studiometa/js-toolkit 1.7.2 → 2.0.0-alpha.10
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.d.ts +217 -0
- package/Base/index.js +237 -0
- package/Base/managers/ChildrenManager.d.ts +108 -0
- package/Base/managers/ChildrenManager.js +124 -0
- package/Base/managers/EventsManager.d.ts +190 -0
- package/Base/managers/EventsManager.js +195 -0
- package/Base/managers/OptionsManager.d.ts +120 -0
- package/Base/managers/OptionsManager.js +180 -0
- package/Base/managers/RefsManager.d.ts +84 -0
- package/Base/managers/RefsManager.js +83 -0
- package/{abstracts/Base/classes/Services.d.ts → Base/managers/ServicesManager.d.ts} +22 -7
- package/Base/managers/ServicesManager.js +115 -0
- package/{abstracts/Base → Base}/utils.d.ts +0 -30
- package/Base/utils.js +43 -0
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +5 -5
- package/decorators/withBreakpointManager.js +41 -79
- package/decorators/withBreakpointObserver.d.ts +4 -4
- package/decorators/withBreakpointObserver.js +54 -77
- package/decorators/withDrag.d.ts +6 -6
- package/decorators/withDrag.js +17 -41
- package/decorators/withExtraConfig.d.ts +6 -6
- package/decorators/withExtraConfig.js +2 -24
- package/decorators/withIntersectionObserver.d.ts +4 -4
- package/decorators/withIntersectionObserver.js +17 -60
- package/decorators/withMountWhenInView.d.ts +8 -8
- package/decorators/withMountWhenInView.js +23 -51
- package/helpers/createApp.d.ts +4 -4
- package/helpers/createApp.js +10 -12
- package/helpers/importOnInteraction.d.ts +6 -6
- package/helpers/importOnInteraction.js +7 -8
- package/helpers/importWhenIdle.d.ts +4 -4
- package/helpers/importWhenIdle.js +7 -8
- package/helpers/importWhenVisible.d.ts +6 -6
- package/helpers/importWhenVisible.js +9 -16
- package/helpers/index.d.ts +1 -3
- package/helpers/index.js +1 -4
- package/helpers/utils.js +2 -3
- package/index.d.ts +19 -5
- package/index.js +5 -6
- package/index.modern.js +1 -3230
- package/index.umd.js +1 -3586
- package/package.json +3 -6
- package/{abstracts → services}/Service.d.ts +0 -0
- package/services/Service.js +63 -0
- package/services/drag.js +144 -180
- package/services/index.js +1 -2
- package/services/key.js +56 -98
- package/services/load.d.ts +1 -1
- package/services/load.js +22 -51
- package/services/pointer.js +118 -157
- package/services/raf.js +37 -65
- package/services/resize.js +46 -98
- package/services/scroll.js +81 -120
- package/utils/collide/boundingRectToCircle.js +7 -6
- package/utils/collide/collideCircleCircle.js +1 -2
- package/utils/collide/collideCircleRect.js +1 -2
- package/utils/collide/collidePointCircle.js +1 -2
- package/utils/collide/collidePointRect.js +1 -2
- package/utils/collide/collideRectRect.js +1 -2
- package/utils/collide/index.js +1 -2
- package/utils/css/classes.js +2 -3
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +3 -8
- package/utils/css/transition.js +67 -140
- package/utils/debounce.js +3 -4
- package/utils/focusTrap.js +4 -5
- package/utils/history.js +12 -19
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -2
- package/utils/keyCodes.js +1 -2
- package/utils/math/clamp.js +1 -2
- package/utils/math/clamp01.js +1 -2
- package/utils/math/damp.js +1 -2
- package/utils/math/index.js +1 -2
- package/utils/math/inertiaFinalValue.js +1 -2
- package/utils/math/lerp.js +1 -2
- package/utils/math/map.js +1 -2
- package/utils/math/round.js +1 -2
- package/utils/memoize.d.ts +30 -0
- package/utils/memoize.js +30 -0
- package/utils/nextFrame.js +4 -9
- package/utils/object/autoBind.js +11 -19
- package/utils/object/getAllProperties.d.ts +6 -3
- package/utils/object/getAllProperties.js +10 -8
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +2 -4
- package/utils/string/index.js +1 -2
- package/utils/string/withLeadingCharacters.js +1 -2
- package/utils/string/withLeadingSlash.js +1 -2
- package/utils/string/withTrailingCharacters.js +1 -2
- package/utils/string/withTrailingSlash.js +1 -2
- package/utils/string/withoutLeadingCharacters.js +1 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
- package/utils/string/withoutLeadingSlash.js +1 -2
- package/utils/string/withoutTrailingCharacters.js +1 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
- package/utils/string/withoutTrailingSlash.js +1 -2
- package/utils/throttle.js +2 -3
- package/abstracts/Base/children.d.ts +0 -16
- package/abstracts/Base/children.js +0 -66
- package/abstracts/Base/children.js.map +0 -1
- package/abstracts/Base/classes/Options.d.ts +0 -37
- package/abstracts/Base/classes/Options.js +0 -182
- package/abstracts/Base/classes/Options.js.map +0 -1
- package/abstracts/Base/classes/Services.js +0 -120
- package/abstracts/Base/classes/Services.js.map +0 -1
- package/abstracts/Base/components.d.ts +0 -22
- package/abstracts/Base/components.js +0 -67
- package/abstracts/Base/components.js.map +0 -1
- package/abstracts/Base/events.d.ts +0 -8
- package/abstracts/Base/events.js +0 -185
- package/abstracts/Base/events.js.map +0 -1
- package/abstracts/Base/index.d.ts +0 -176
- package/abstracts/Base/index.js +0 -215
- package/abstracts/Base/index.js.map +0 -1
- package/abstracts/Base/options.d.ts +0 -17
- package/abstracts/Base/options.js +0 -112
- package/abstracts/Base/options.js.map +0 -1
- package/abstracts/Base/refs.d.ts +0 -30
- package/abstracts/Base/refs.js +0 -60
- package/abstracts/Base/refs.js.map +0 -1
- package/abstracts/Base/utils.js +0 -102
- package/abstracts/Base/utils.js.map +0 -1
- package/abstracts/EventManager.d.ts +0 -41
- package/abstracts/EventManager.js +0 -88
- package/abstracts/EventManager.js.map +0 -1
- package/abstracts/Service.js +0 -82
- package/abstracts/Service.js.map +0 -1
- package/abstracts/index.d.ts +0 -4
- package/abstracts/index.js +0 -5
- package/abstracts/index.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -121
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -327
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -39
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -167
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -77
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -270
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -195
- package/components/Tabs.js.map +0 -1
- package/components/index.d.ts +0 -6
- package/components/index.js +0 -7
- package/components/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/decorators/withBreakpointManager.js.map +0 -1
- package/decorators/withBreakpointObserver.js.map +0 -1
- package/decorators/withDrag.js.map +0 -1
- package/decorators/withExtraConfig.js.map +0 -1
- package/decorators/withIntersectionObserver.js.map +0 -1
- package/decorators/withMountWhenInView.js.map +0 -1
- package/full.d.ts +0 -10
- package/full.js +0 -12
- package/full.js.map +0 -1
- package/full.modern.js +0 -7523
- package/full.modern.js.map +0 -1
- package/full.umd.js +0 -8277
- package/full.umd.js.map +0 -1
- package/helpers/createApp.js.map +0 -1
- package/helpers/createBase.d.ts +0 -7
- package/helpers/createBase.js +0 -7
- package/helpers/createBase.js.map +0 -1
- package/helpers/defineComponent.d.ts +0 -11
- package/helpers/defineComponent.js +0 -68
- package/helpers/defineComponent.js.map +0 -1
- package/helpers/importOnInteraction.js.map +0 -1
- package/helpers/importWhenIdle.js.map +0 -1
- package/helpers/importWhenVisible.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/helpers/utils.js.map +0 -1
- package/index.js.map +0 -1
- package/index.modern.js.map +0 -1
- package/index.umd.js.map +0 -1
- package/services/drag.js.map +0 -1
- package/services/index.js.map +0 -1
- package/services/key.js.map +0 -1
- package/services/load.js.map +0 -1
- package/services/pointer.js.map +0 -1
- package/services/raf.js.map +0 -1
- package/services/resize.js.map +0 -1
- package/services/scroll.js.map +0 -1
- package/utils/collide/boundingRectToCircle.js.map +0 -1
- package/utils/collide/collideCircleCircle.js.map +0 -1
- package/utils/collide/collideCircleRect.js.map +0 -1
- package/utils/collide/collidePointCircle.js.map +0 -1
- package/utils/collide/collidePointRect.js.map +0 -1
- package/utils/collide/collideRectRect.js.map +0 -1
- package/utils/collide/index.js.map +0 -1
- package/utils/css/classes.js.map +0 -1
- package/utils/css/index.js.map +0 -1
- package/utils/css/matrix.js.map +0 -1
- package/utils/css/styles.js.map +0 -1
- package/utils/css/transition.js.map +0 -1
- package/utils/debounce.js.map +0 -1
- package/utils/focusTrap.js.map +0 -1
- package/utils/history.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/keyCodes.js.map +0 -1
- package/utils/math/clamp.js.map +0 -1
- package/utils/math/clamp01.js.map +0 -1
- package/utils/math/damp.js.map +0 -1
- package/utils/math/index.js.map +0 -1
- package/utils/math/inertiaFinalValue.js.map +0 -1
- package/utils/math/lerp.js.map +0 -1
- package/utils/math/map.js.map +0 -1
- package/utils/math/round.js.map +0 -1
- package/utils/nextFrame.js.map +0 -1
- package/utils/object/autoBind.js.map +0 -1
- package/utils/object/getAllProperties.js.map +0 -1
- package/utils/object/index.js.map +0 -1
- package/utils/object/isObject.js.map +0 -1
- package/utils/string/index.js.map +0 -1
- package/utils/string/withLeadingCharacters.js.map +0 -1
- package/utils/string/withLeadingSlash.js.map +0 -1
- package/utils/string/withTrailingCharacters.js.map +0 -1
- package/utils/string/withTrailingSlash.js.map +0 -1
- package/utils/string/withoutLeadingCharacters.js.map +0 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutLeadingSlash.js.map +0 -1
- package/utils/string/withoutTrailingCharacters.js.map +0 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutTrailingSlash.js.map +0 -1
- package/utils/throttle.js.map +0 -1
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _get from "@babel/runtime/helpers/get";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
10
2
|
|
|
11
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
4
|
|
|
13
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
6
|
|
|
15
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
|
|
17
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
|
|
19
|
-
import { debug } from '../abstracts/Base/utils.js';
|
|
20
|
-
|
|
21
7
|
function createArrayOfNumber(length) {
|
|
22
|
-
return
|
|
23
|
-
return index / length;
|
|
24
|
-
});
|
|
8
|
+
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
25
9
|
}
|
|
26
10
|
|
|
27
11
|
export default function withIntersectionObserver(BaseClass) {
|
|
@@ -30,60 +14,33 @@ export default function withIntersectionObserver(BaseClass) {
|
|
|
30
14
|
var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
31
15
|
threshold: createArrayOfNumber(100)
|
|
32
16
|
};
|
|
33
|
-
return _temp = _class =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _super = _createSuper(_class);
|
|
17
|
+
return _temp = _class = class extends BaseClass {
|
|
18
|
+
constructor(element) {
|
|
19
|
+
super(element);
|
|
37
20
|
|
|
38
|
-
|
|
39
|
-
var _this;
|
|
40
|
-
|
|
41
|
-
_classCallCheck(this, _class);
|
|
42
|
-
|
|
43
|
-
_this = _super.call(this, element);
|
|
44
|
-
|
|
45
|
-
if (!_this.intersected || typeof _this.intersected !== 'function') {
|
|
21
|
+
if (!this.intersected || typeof this.intersected !== 'function') {
|
|
46
22
|
throw new Error('[withIntersectionObserver] The `intersected` method must be defined.');
|
|
47
23
|
}
|
|
48
24
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
debug(_assertThisInitialized(_this), 'intersected', entries);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_this.$emit('intersected', entries);
|
|
25
|
+
this.$observer = new IntersectionObserver(entries => {
|
|
26
|
+
this.__debug('intersected', entries);
|
|
55
27
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
_this.$on('mounted', function () {
|
|
64
|
-
_this.$observer.observe(_this.$el);
|
|
28
|
+
this.$emit('intersected', entries);
|
|
29
|
+
this.intersected(entries);
|
|
30
|
+
}, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver || {}));
|
|
31
|
+
this.$on('mounted', () => {
|
|
32
|
+
this.$observer.observe(this.$el);
|
|
65
33
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_this.$observer.unobserve(_this.$el);
|
|
34
|
+
this.$on('destroyed', () => {
|
|
35
|
+
this.$observer.unobserve(this.$el);
|
|
69
36
|
});
|
|
70
|
-
|
|
71
|
-
return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
|
|
37
|
+
return this;
|
|
72
38
|
}
|
|
73
39
|
|
|
74
|
-
|
|
75
|
-
key: "_excludeFromAutoBind",
|
|
76
|
-
get: function get() {
|
|
77
|
-
return [].concat(_toConsumableArray(_get(_getPrototypeOf(_class.prototype), "_excludeFromAutoBind", this) || []), ['intersected']);
|
|
78
|
-
}
|
|
79
|
-
}]);
|
|
80
|
-
|
|
81
|
-
return _class;
|
|
82
|
-
}(BaseClass), _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
|
|
40
|
+
}, _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
|
|
83
41
|
name: "".concat((_BaseClass$config$nam = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config = BaseClass.config) === null || _BaseClass$config === void 0 ? void 0 : _BaseClass$config.name) !== null && _BaseClass$config$nam !== void 0 ? _BaseClass$config$nam : '', "WithIntersectionObserver"),
|
|
84
42
|
options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
|
|
85
43
|
intersectionObserver: Object
|
|
86
44
|
})
|
|
87
45
|
})), _temp;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=withIntersectionObserver.js.map
|
|
46
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../
|
|
3
|
-
* @typedef {import('../
|
|
4
|
-
* @typedef {import('../
|
|
2
|
+
* @typedef {import('../Base').default} Base
|
|
3
|
+
* @typedef {import('../Base').BaseOptions} BaseOptions
|
|
4
|
+
* @typedef {import('../Base').BaseConstructor} BaseConstructor
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} WithMountWhenInViewOptions
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
/**
|
|
16
16
|
* IntersectionObserver decoration.
|
|
17
17
|
*
|
|
18
|
-
* @template {
|
|
18
|
+
* @template {BaseConstructor} T
|
|
19
19
|
* @param {T} BaseClass The Base class to extend.
|
|
20
20
|
* @param {Object} [defaultOptions] The options for the IntersectionObserver instance.
|
|
21
21
|
* @return {T}
|
|
22
22
|
*/
|
|
23
|
-
export default function withMountWhenInView<T extends typeof import("../
|
|
24
|
-
export type Base = import('../
|
|
25
|
-
export type BaseOptions = import('../
|
|
26
|
-
export type
|
|
23
|
+
export default function withMountWhenInView<T extends typeof import("../Base").default>(BaseClass: T, defaultOptions?: any): T;
|
|
24
|
+
export type Base = import('../Base').default;
|
|
25
|
+
export type BaseOptions = import('../Base').BaseOptions;
|
|
26
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
27
27
|
export type WithMountWhenInViewOptions = {
|
|
28
28
|
intersectionObserver: any;
|
|
29
29
|
};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _get from "@babel/runtime/helpers/get";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
2
|
import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
|
|
10
3
|
import _classPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
|
|
@@ -13,78 +6,57 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
13
6
|
|
|
14
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
8
|
|
|
16
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
17
|
-
|
|
18
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
-
|
|
20
9
|
export default function withMountWhenInView(BaseClass) {
|
|
21
10
|
var _class, _isVisible, _observer, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
|
|
22
11
|
|
|
23
12
|
var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
24
13
|
threshold: [0, 1]
|
|
25
14
|
};
|
|
26
|
-
return _temp = (_isVisible = new WeakMap(), _observer = new WeakMap(), _class =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var _super = _createSuper(_class);
|
|
30
|
-
|
|
31
|
-
function _class(element) {
|
|
32
|
-
var _this;
|
|
33
|
-
|
|
34
|
-
_classCallCheck(this, _class);
|
|
35
|
-
|
|
36
|
-
_this = _super.call(this, element);
|
|
15
|
+
return _temp = (_isVisible = new WeakMap(), _observer = new WeakMap(), _class = class extends BaseClass {
|
|
16
|
+
constructor(element) {
|
|
17
|
+
super(element);
|
|
37
18
|
|
|
38
|
-
_isVisible.set(
|
|
19
|
+
_isVisible.set(this, {
|
|
39
20
|
writable: true,
|
|
40
21
|
value: false
|
|
41
22
|
});
|
|
42
23
|
|
|
43
|
-
_observer.set(
|
|
24
|
+
_observer.set(this, {
|
|
44
25
|
writable: true,
|
|
45
26
|
value: void 0
|
|
46
27
|
});
|
|
47
28
|
|
|
48
|
-
_classPrivateFieldSet(
|
|
49
|
-
var isVisible = entries.reduce(
|
|
50
|
-
return acc || entry.isIntersecting;
|
|
51
|
-
}, false);
|
|
29
|
+
_classPrivateFieldSet(this, _observer, new IntersectionObserver(entries => {
|
|
30
|
+
var isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
52
31
|
|
|
53
|
-
if (_classPrivateFieldGet(
|
|
54
|
-
_classPrivateFieldSet(
|
|
32
|
+
if (_classPrivateFieldGet(this, _isVisible) !== isVisible) {
|
|
33
|
+
_classPrivateFieldSet(this, _isVisible, isVisible);
|
|
55
34
|
|
|
56
35
|
var method = isVisible ? '$mount' : '$destroy';
|
|
57
|
-
|
|
58
|
-
_this[method]();
|
|
36
|
+
this[method]();
|
|
59
37
|
}
|
|
60
|
-
}, _objectSpread(_objectSpread({}, defaultOptions),
|
|
38
|
+
}, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver)));
|
|
61
39
|
|
|
62
|
-
_classPrivateFieldGet(
|
|
40
|
+
_classPrivateFieldGet(this, _observer).observe(this.$el);
|
|
63
41
|
|
|
64
|
-
|
|
65
|
-
_classPrivateFieldGet(
|
|
42
|
+
this.$on('terminated', () => {
|
|
43
|
+
_classPrivateFieldGet(this, _observer).disconnect();
|
|
66
44
|
});
|
|
67
|
-
|
|
68
|
-
return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
|
|
45
|
+
return this;
|
|
69
46
|
}
|
|
70
47
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (_classPrivateFieldGet(this, _isVisible)) {
|
|
75
|
-
_get(_getPrototypeOf(_class.prototype), "$mount", this).call(this);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return this;
|
|
48
|
+
$mount() {
|
|
49
|
+
if (_classPrivateFieldGet(this, _isVisible)) {
|
|
50
|
+
super.$mount();
|
|
79
51
|
}
|
|
80
|
-
}]);
|
|
81
52
|
|
|
82
|
-
|
|
83
|
-
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}), _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
|
|
84
57
|
name: "".concat((_BaseClass$config$nam = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config = BaseClass.config) === null || _BaseClass$config === void 0 ? void 0 : _BaseClass$config.name) !== null && _BaseClass$config$nam !== void 0 ? _BaseClass$config$nam : '', "WithMountWhenInView"),
|
|
85
58
|
options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
|
|
86
59
|
intersectionObserver: Object
|
|
87
60
|
})
|
|
88
61
|
})), _temp;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=withMountWhenInView.js.map
|
|
62
|
+
}
|
package/helpers/createApp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Instantiate and mount the given component on the given root element when the page has been loaded
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
* console.log(app.$options.name); // 'App'
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @template {
|
|
29
|
+
* @template {BaseConstructor} T
|
|
30
30
|
* @param {T} App
|
|
31
31
|
* @param {HTMLElement} rootElement
|
|
32
32
|
*
|
|
33
33
|
* @return {() => Promise<InstanceType<T>>}
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
|
-
export default function createApp<T extends typeof import("../
|
|
37
|
-
export type
|
|
36
|
+
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement: HTMLElement): () => Promise<InstanceType<T>>;
|
|
37
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
package/helpers/createApp.js
CHANGED
|
@@ -3,7 +3,7 @@ export default function createApp(App, rootElement) {
|
|
|
3
3
|
var app;
|
|
4
4
|
|
|
5
5
|
if (!isLoaded) {
|
|
6
|
-
document.addEventListener('readystatechange',
|
|
6
|
+
document.addEventListener('readystatechange', () => {
|
|
7
7
|
if (document.readyState === 'complete') {
|
|
8
8
|
app = new App(rootElement).$mount();
|
|
9
9
|
isLoaded = true;
|
|
@@ -13,20 +13,18 @@ export default function createApp(App, rootElement) {
|
|
|
13
13
|
app = new App(rootElement).$mount();
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
var promise = new Promise(resolve => {
|
|
17
|
+
document.addEventListener('readystatechange', () => {
|
|
18
|
+
if (document.readyState === 'complete') {
|
|
19
|
+
setTimeout(() => resolve(app), 0);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
16
23
|
return function useApp() {
|
|
17
24
|
if (isLoaded) {
|
|
18
25
|
return Promise.resolve(app);
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
return
|
|
22
|
-
document.addEventListener('readystatechange', function () {
|
|
23
|
-
if (document.readyState === 'complete') {
|
|
24
|
-
setTimeout(function () {
|
|
25
|
-
return resolve(app);
|
|
26
|
-
}, 0);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
28
|
+
return promise;
|
|
30
29
|
};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=createApp.js.map
|
|
30
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../
|
|
3
|
-
* @typedef {import('../
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
+
* @typedef {import('../Base/index.js').default} Base
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Import a component on an interaction.
|
|
7
7
|
*
|
|
8
|
-
* @template {
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
9
|
*
|
|
10
10
|
* @param {() => Promise<T|{default:T}>} fn
|
|
11
11
|
* The import function.
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @return {Promise<T>}
|
|
20
20
|
*/
|
|
21
|
-
export default function importOnInteraction<T extends typeof import("../
|
|
21
|
+
export default function importOnInteraction<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
22
22
|
default: T;
|
|
23
23
|
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], events: string | string[], parent?: Base | undefined): Promise<T>;
|
|
24
|
-
export type
|
|
25
|
-
export type Base = import('../
|
|
24
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
25
|
+
export type Base = import('../Base/index.js').default;
|
|
@@ -3,14 +3,14 @@ export default function importOnInteraction(fn, nameOrSelectorOrElement, events,
|
|
|
3
3
|
var normalizedEvents = typeof events === 'string' ? [events] : events;
|
|
4
4
|
var ResolvedClass;
|
|
5
5
|
|
|
6
|
-
var resolver =
|
|
7
|
-
fn().then(
|
|
6
|
+
var resolver = resolve => {
|
|
7
|
+
fn().then(module => {
|
|
8
8
|
ResolvedClass = 'default' in module ? module.default : module;
|
|
9
9
|
resolve(ResolvedClass);
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
return new Promise(
|
|
13
|
+
return new Promise(resolve => {
|
|
14
14
|
var elements = getTargetElements(nameOrSelectorOrElement, parent === null || parent === void 0 ? void 0 : parent.$el);
|
|
15
15
|
var eventListenerOptions = {
|
|
16
16
|
capture: true,
|
|
@@ -18,15 +18,14 @@ export default function importOnInteraction(fn, nameOrSelectorOrElement, events,
|
|
|
18
18
|
once: true
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
var handler =
|
|
21
|
+
var handler = () => {
|
|
22
22
|
resolver(resolve);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
elements.forEach(
|
|
26
|
-
normalizedEvents.forEach(
|
|
25
|
+
elements.forEach(element => {
|
|
26
|
+
normalizedEvents.forEach(event => {
|
|
27
27
|
element.addEventListener(event, handler, eventListenerOptions);
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=importOnInteraction.js.map
|
|
31
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
3
|
* @typedef {{ timeout?: number }} ImportWhenIdleOptions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Import a component when user is idle.
|
|
7
7
|
*
|
|
8
|
-
* @template {
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
9
|
*
|
|
10
10
|
* @param {() => Promise<T|{default:T}>} fn
|
|
11
11
|
* The import function.
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @return {Promise<T>}
|
|
16
16
|
*/
|
|
17
|
-
export default function importWhenIdle<T extends typeof import("../
|
|
17
|
+
export default function importWhenIdle<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
18
18
|
default: T;
|
|
19
19
|
}>, options?: ImportWhenIdleOptions | undefined): Promise<T>;
|
|
20
|
-
export type
|
|
20
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
21
21
|
export type ImportWhenIdleOptions = {
|
|
22
22
|
timeout?: number;
|
|
23
23
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
export default function importWhenIdle(fn, options) {
|
|
2
2
|
var ResolvedClass;
|
|
3
3
|
|
|
4
|
-
var resolver =
|
|
5
|
-
fn().then(
|
|
4
|
+
var resolver = resolve => {
|
|
5
|
+
fn().then(module => {
|
|
6
6
|
ResolvedClass = 'default' in module ? module.default : module;
|
|
7
7
|
resolve(ResolvedClass);
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
return new Promise(
|
|
11
|
+
return new Promise(resolve => {
|
|
12
12
|
var _options$timeout;
|
|
13
13
|
|
|
14
14
|
var timeout = (_options$timeout = options === null || options === void 0 ? void 0 : options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 1;
|
|
15
15
|
|
|
16
16
|
if (!('requestIdleCallback' in window)) {
|
|
17
|
-
setTimeout(
|
|
17
|
+
setTimeout(() => {
|
|
18
18
|
resolver(resolve);
|
|
19
19
|
}, timeout);
|
|
20
20
|
} else {
|
|
21
|
-
window.requestIdleCallback(
|
|
22
|
-
setTimeout(
|
|
21
|
+
window.requestIdleCallback(() => {
|
|
22
|
+
setTimeout(() => {
|
|
23
23
|
resolver(resolve);
|
|
24
24
|
}, 0);
|
|
25
25
|
}, {
|
|
@@ -27,5 +27,4 @@ export default function importWhenIdle(fn, options) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=importWhenIdle.js.map
|
|
30
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../
|
|
3
|
-
* @typedef {import('../
|
|
2
|
+
* @typedef {import('../Base/index.js').default} Base
|
|
3
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Import a component when it is visible.
|
|
7
7
|
*
|
|
8
|
-
* @template {
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
9
|
*
|
|
10
10
|
* @param {() => Promise<T|{default:T}>} fn
|
|
11
11
|
* The import function.
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @return {Promise<T>}
|
|
20
20
|
*/
|
|
21
|
-
export default function importWhenVisible<T extends typeof import("../
|
|
21
|
+
export default function importWhenVisible<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
22
22
|
default: T;
|
|
23
23
|
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: Base | undefined, observerOptions?: IntersectionObserverInit | undefined): Promise<T>;
|
|
24
|
-
export type Base = import('../
|
|
25
|
-
export type
|
|
24
|
+
export type Base = import('../Base/index.js').default;
|
|
25
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -3,8 +3,8 @@ export default function importWhenVisible(fn, nameOrSelectorOrElement, parent) {
|
|
|
3
3
|
var observerOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
4
4
|
var ResolvedClass;
|
|
5
5
|
|
|
6
|
-
var resolver =
|
|
7
|
-
fn().then(
|
|
6
|
+
var resolver = (resolve, cb) => {
|
|
7
|
+
fn().then(module => {
|
|
8
8
|
ResolvedClass = 'default' in module ? module.default : module;
|
|
9
9
|
resolve(ResolvedClass);
|
|
10
10
|
|
|
@@ -14,24 +14,17 @@ export default function importWhenVisible(fn, nameOrSelectorOrElement, parent) {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
return new Promise(
|
|
18
|
-
var observer = new IntersectionObserver(
|
|
19
|
-
var someEntriesAreVisible = entries.some(
|
|
20
|
-
return entry.isIntersecting;
|
|
21
|
-
});
|
|
17
|
+
return new Promise(resolve => {
|
|
18
|
+
var observer = new IntersectionObserver(entries => {
|
|
19
|
+
var someEntriesAreVisible = entries.some(entry => entry.isIntersecting);
|
|
22
20
|
|
|
23
21
|
if (someEntriesAreVisible) {
|
|
24
|
-
setTimeout(
|
|
25
|
-
resolver(resolve,
|
|
26
|
-
return observer.disconnect();
|
|
27
|
-
});
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
resolver(resolve, () => observer.disconnect());
|
|
28
24
|
}, 0);
|
|
29
25
|
}
|
|
30
26
|
}, observerOptions);
|
|
31
27
|
var elements = getTargetElements(nameOrSelectorOrElement, parent === null || parent === void 0 ? void 0 : parent.$el);
|
|
32
|
-
elements.forEach(
|
|
33
|
-
return observer.observe(element);
|
|
34
|
-
});
|
|
28
|
+
elements.forEach(element => observer.observe(element));
|
|
35
29
|
});
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=importWhenVisible.js.map
|
|
30
|
+
}
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import createApp from "./createApp.js";
|
|
2
|
-
import createBase from "./createBase.js";
|
|
3
|
-
import defineComponent from "./defineComponent.js";
|
|
4
2
|
import importOnInteraction from "./importOnInteraction.js";
|
|
5
3
|
import importWhenIdle from "./importWhenIdle.js";
|
|
6
4
|
import importWhenVisible from "./importWhenVisible.js";
|
|
7
|
-
export { createApp,
|
|
5
|
+
export { createApp, importOnInteraction, importWhenIdle, importWhenVisible };
|
package/helpers/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import createApp from './createApp.js';
|
|
2
|
-
import createBase from './createBase.js';
|
|
3
|
-
import defineComponent from './defineComponent.js';
|
|
4
2
|
import importOnInteraction from './importOnInteraction.js';
|
|
5
3
|
import importWhenIdle from './importWhenIdle.js';
|
|
6
4
|
import importWhenVisible from './importWhenVisible.js';
|
|
7
|
-
export { createApp,
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { createApp, importOnInteraction, importWhenIdle, importWhenVisible };
|
package/helpers/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getComponentElements } from '../
|
|
1
|
+
import { getComponentElements } from '../Base/utils.js';
|
|
2
2
|
export function getTargetElements(nameOrSelectorOrElement, context) {
|
|
3
3
|
if (typeof nameOrSelectorOrElement === 'string') {
|
|
4
4
|
return getComponentElements(nameOrSelectorOrElement, context);
|
|
@@ -9,5 +9,4 @@ export function getTargetElements(nameOrSelectorOrElement, context) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return nameOrSelectorOrElement;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=utils.js.map
|
|
12
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import Base from "./Base/index.js";
|
|
2
|
+
import { createApp } from "./helpers/index.js";
|
|
3
|
+
import { importOnInteraction } from "./helpers/index.js";
|
|
4
|
+
import { importWhenIdle } from "./helpers/index.js";
|
|
5
|
+
import { importWhenVisible } from "./helpers/index.js";
|
|
6
|
+
import { useDrag } from "./services/index.js";
|
|
7
|
+
import { useKey } from "./services/index.js";
|
|
8
|
+
import { useLoad } from "./services/index.js";
|
|
9
|
+
import { usePointer } from "./services/index.js";
|
|
10
|
+
import { useRaf } from "./services/index.js";
|
|
11
|
+
import { useResize } from "./services/index.js";
|
|
12
|
+
import { useScroll } from "./services/index.js";
|
|
13
|
+
import { withBreakpointManager } from "./decorators/index.js";
|
|
14
|
+
import { withBreakpointObserver } from "./decorators/index.js";
|
|
15
|
+
import { withDrag } from "./decorators/index.js";
|
|
16
|
+
import { withExtraConfig } from "./decorators/index.js";
|
|
17
|
+
import { withIntersectionObserver } from "./decorators/index.js";
|
|
18
|
+
import { withMountWhenInView } from "./decorators/index.js";
|
|
19
|
+
export { Base, createApp, importOnInteraction, importWhenIdle, importWhenVisible, useDrag, useKey, useLoad, usePointer, useRaf, useResize, useScroll, withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withIntersectionObserver, withMountWhenInView };
|
package/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Base from './
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import Base from './Base/index.js';
|
|
2
|
+
import { withDrag, withBreakpointManager, withBreakpointObserver, withExtraConfig, withIntersectionObserver, withMountWhenInView } from './decorators/index.js';
|
|
3
|
+
import { createApp, importOnInteraction, importWhenIdle, importWhenVisible } from './helpers/index.js';
|
|
4
|
+
import { useDrag, useKey, useLoad, usePointer, useRaf, useResize, useScroll } from './services/index.js';
|
|
5
|
+
export { Base, createApp, importOnInteraction, importWhenIdle, importWhenVisible, useDrag, useKey, useLoad, usePointer, useRaf, useResize, useScroll, withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withIntersectionObserver, withMountWhenInView };
|