@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,52 +1,32 @@
|
|
|
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
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
9
|
-
|
|
10
|
-
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); }; }
|
|
11
|
-
|
|
12
|
-
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; } }
|
|
13
|
-
|
|
14
1
|
import useResize from '../services/resize.js';
|
|
15
2
|
|
|
16
3
|
function testBreakpoints(breakpoints) {
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
breakpoints.forEach(
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (breakpointKeys.includes(breakpoint)) {
|
|
26
|
-
instance.$mount();
|
|
27
|
-
} else {
|
|
4
|
+
var {
|
|
5
|
+
breakpoint
|
|
6
|
+
} = useResize().props();
|
|
7
|
+
breakpoints.forEach(_ref => {
|
|
8
|
+
var [breakpointKeys, instance] = _ref;
|
|
9
|
+
|
|
10
|
+
if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {
|
|
11
|
+
setTimeout(() => instance.$mount(), 0);
|
|
12
|
+
} else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {
|
|
28
13
|
instance.$destroy();
|
|
29
14
|
}
|
|
30
15
|
});
|
|
31
16
|
}
|
|
32
17
|
|
|
33
18
|
function mountComponents(instance, breakpoints) {
|
|
34
|
-
return breakpoints.map(
|
|
35
|
-
var
|
|
36
|
-
bk = _ref4[0],
|
|
37
|
-
ComponentClass = _ref4[1];
|
|
38
|
-
|
|
19
|
+
return breakpoints.map(_ref2 => {
|
|
20
|
+
var [bk, ComponentClass] = _ref2;
|
|
39
21
|
var child = new ComponentClass(instance.$el);
|
|
40
22
|
Object.defineProperty(child, '$parent', {
|
|
41
|
-
get:
|
|
42
|
-
return instance;
|
|
43
|
-
}
|
|
23
|
+
get: () => instance.$parent
|
|
44
24
|
});
|
|
45
25
|
return [bk, child];
|
|
46
26
|
});
|
|
47
27
|
}
|
|
48
28
|
|
|
49
|
-
var instances =
|
|
29
|
+
var instances = new WeakMap();
|
|
50
30
|
export default function withBreakpointManager(BaseClass, breakpoints) {
|
|
51
31
|
if (!Array.isArray(breakpoints)) {
|
|
52
32
|
throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');
|
|
@@ -56,64 +36,46 @@ export default function withBreakpointManager(BaseClass, breakpoints) {
|
|
|
56
36
|
throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');
|
|
57
37
|
}
|
|
58
38
|
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
39
|
+
var {
|
|
40
|
+
add,
|
|
41
|
+
props
|
|
42
|
+
} = useResize();
|
|
62
43
|
|
|
63
44
|
if (!props().breakpoint) {
|
|
64
45
|
throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");
|
|
65
46
|
}
|
|
66
47
|
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var _super = _createSuper(_class);
|
|
48
|
+
return class extends BaseClass {
|
|
49
|
+
constructor(element) {
|
|
50
|
+
super(element);
|
|
71
51
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_classCallCheck(this, _class);
|
|
76
|
-
|
|
77
|
-
_this = _super.call(this, element);
|
|
78
|
-
|
|
79
|
-
if (!instances[_this.$id]) {
|
|
80
|
-
instances[_this.$id] = mountComponents(_assertThisInitialized(_this), breakpoints);
|
|
52
|
+
if (!instances.has(this)) {
|
|
53
|
+
instances.set(this, mountComponents(this, breakpoints));
|
|
81
54
|
}
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
testBreakpoints(instances[_this.$id]);
|
|
56
|
+
add("BreakpointManager-".concat(this.$id), () => {
|
|
57
|
+
testBreakpoints(instances.get(this));
|
|
86
58
|
});
|
|
87
|
-
|
|
59
|
+
this.instances = instances.get(this);
|
|
60
|
+
return this;
|
|
88
61
|
}
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
63
|
+
$mount() {
|
|
64
|
+
super.$mount();
|
|
65
|
+
testBreakpoints(instances.get(this));
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
96
68
|
|
|
97
|
-
|
|
98
|
-
|
|
69
|
+
$destroy() {
|
|
70
|
+
if (Array.isArray(instances.get(this))) {
|
|
71
|
+
instances.get(this).forEach(_ref3 => {
|
|
72
|
+
var [, instance] = _ref3;
|
|
73
|
+
instance.$destroy();
|
|
74
|
+
});
|
|
99
75
|
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "$destroy",
|
|
102
|
-
value: function $destroy() {
|
|
103
|
-
if (Array.isArray(instances[this.$id])) {
|
|
104
|
-
instances[this.$id].forEach(function (_ref5) {
|
|
105
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
106
|
-
instance = _ref6[1];
|
|
107
76
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return _get(_getPrototypeOf(_class.prototype), "$destroy", this).call(this);
|
|
113
|
-
}
|
|
114
|
-
}]);
|
|
77
|
+
return super.$destroy();
|
|
78
|
+
}
|
|
115
79
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=withBreakpointManager.js.map
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BreakpointObserver class.
|
|
3
3
|
*
|
|
4
|
-
* @template {
|
|
4
|
+
* @template {BaseConstructor} T
|
|
5
5
|
* @param {T} BaseClass The Base class to extend from.
|
|
6
6
|
* @return {T}
|
|
7
7
|
*/
|
|
8
|
-
export default function withBreakpointObserver<T extends typeof import("../
|
|
9
|
-
export type Base = import('../
|
|
10
|
-
export type
|
|
8
|
+
export default function withBreakpointObserver<T extends typeof import("../Base").default>(BaseClass: T): T;
|
|
9
|
+
export type Base = import('../Base').default;
|
|
10
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
11
11
|
export type WithBreakpointObserverOptions = {
|
|
12
12
|
activeBreakpoints?: string;
|
|
13
13
|
inactiveBreakpoints?: string;
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _get from "@babel/runtime/helpers/get";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
7
|
import useResize from '../services/resize.js';
|
|
20
8
|
|
|
21
9
|
function testBreakpoints(instance) {
|
|
22
10
|
var breakpoint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : useResize().props().breakpoint;
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
var {
|
|
12
|
+
activeBreakpoints,
|
|
13
|
+
inactiveBreakpoints
|
|
14
|
+
} = instance.$options;
|
|
26
15
|
var isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);
|
|
27
16
|
var isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);
|
|
28
17
|
|
|
@@ -34,17 +23,19 @@ function testBreakpoints(instance) {
|
|
|
34
23
|
}
|
|
35
24
|
|
|
36
25
|
function hasBreakpointConfiguration(instance) {
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
var {
|
|
27
|
+
activeBreakpoints,
|
|
28
|
+
inactiveBreakpoints
|
|
29
|
+
} = instance.$options;
|
|
40
30
|
return Boolean(activeBreakpoints || inactiveBreakpoints);
|
|
41
31
|
}
|
|
42
32
|
|
|
43
33
|
function testConflictingBreakpointConfiguration(instance) {
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
var {
|
|
35
|
+
activeBreakpoints,
|
|
36
|
+
inactiveBreakpoints,
|
|
37
|
+
name
|
|
38
|
+
} = instance.$options;
|
|
48
39
|
|
|
49
40
|
if (activeBreakpoints && inactiveBreakpoints) {
|
|
50
41
|
throw new Error("[".concat(name, "] Incorrect configuration: the `activeBreakpoints` and `inactiveBreakpoints` are not compatible."));
|
|
@@ -53,22 +44,22 @@ function testConflictingBreakpointConfiguration(instance) {
|
|
|
53
44
|
|
|
54
45
|
function addToResize(key, instance) {
|
|
55
46
|
testConflictingBreakpointConfiguration(instance);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
var {
|
|
48
|
+
add,
|
|
49
|
+
has
|
|
50
|
+
} = useResize();
|
|
60
51
|
|
|
61
52
|
if (!has(key)) {
|
|
62
53
|
add(key, function onResize(_ref) {
|
|
63
|
-
var
|
|
54
|
+
var {
|
|
55
|
+
breakpoint
|
|
56
|
+
} = _ref;
|
|
64
57
|
var action = testBreakpoints(instance, breakpoint);
|
|
65
58
|
|
|
66
59
|
if (action === '$destroy' && instance.$isMounted) {
|
|
67
60
|
instance[action]();
|
|
68
61
|
} else if (action === '$mount' && !instance.$isMounted) {
|
|
69
|
-
setTimeout(
|
|
70
|
-
return instance[action]();
|
|
71
|
-
}, 0);
|
|
62
|
+
setTimeout(() => instance[action](), 0);
|
|
72
63
|
}
|
|
73
64
|
});
|
|
74
65
|
}
|
|
@@ -77,80 +68,66 @@ function addToResize(key, instance) {
|
|
|
77
68
|
export default function withBreakpointObserver(BaseClass) {
|
|
78
69
|
var _class, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
|
|
79
70
|
|
|
80
|
-
return _temp = _class =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_this = _super.call(this, element);
|
|
91
|
-
|
|
92
|
-
var _useResize2 = useResize(),
|
|
93
|
-
remove = _useResize2.remove,
|
|
94
|
-
props = _useResize2.props;
|
|
95
|
-
|
|
96
|
-
var name = _this.$options.name;
|
|
71
|
+
return _temp = _class = class extends BaseClass {
|
|
72
|
+
constructor(element) {
|
|
73
|
+
super(element);
|
|
74
|
+
var {
|
|
75
|
+
remove,
|
|
76
|
+
props
|
|
77
|
+
} = useResize();
|
|
78
|
+
var {
|
|
79
|
+
name
|
|
80
|
+
} = this.$options;
|
|
97
81
|
|
|
98
82
|
if (!props().breakpoint) {
|
|
99
83
|
throw new Error("[".concat(name, "] The `BreakpointObserver` class requires breakpoints to be defined."));
|
|
100
84
|
}
|
|
101
85
|
|
|
102
|
-
var key = "BreakpointObserver-".concat(
|
|
103
|
-
var mutationObserver = new MutationObserver(
|
|
104
|
-
var
|
|
105
|
-
mutation = _ref3[0];
|
|
86
|
+
var key = "BreakpointObserver-".concat(this.$id);
|
|
87
|
+
var mutationObserver = new MutationObserver(_ref2 => {
|
|
88
|
+
var [mutation] = _ref2;
|
|
106
89
|
|
|
107
90
|
if (mutation.type === 'attributes' && (mutation.attributeName === 'data-options' || mutation.attributeName.startsWith('data-option-'))) {
|
|
108
|
-
if (!hasBreakpointConfiguration(
|
|
109
|
-
|
|
110
|
-
|
|
91
|
+
if (!hasBreakpointConfiguration(this)) {
|
|
92
|
+
this.$mount();
|
|
111
93
|
remove(key);
|
|
112
94
|
return;
|
|
113
95
|
}
|
|
114
96
|
|
|
115
|
-
addToResize(key,
|
|
97
|
+
addToResize(key, this);
|
|
116
98
|
}
|
|
117
99
|
});
|
|
118
|
-
mutationObserver.observe(
|
|
100
|
+
mutationObserver.observe(this.$el, {
|
|
119
101
|
attributes: true
|
|
120
102
|
});
|
|
121
103
|
|
|
122
|
-
if (!hasBreakpointConfiguration(
|
|
123
|
-
return
|
|
104
|
+
if (!hasBreakpointConfiguration(this)) {
|
|
105
|
+
return this;
|
|
124
106
|
}
|
|
125
107
|
|
|
126
|
-
addToResize(key,
|
|
127
|
-
return
|
|
108
|
+
addToResize(key, this);
|
|
109
|
+
return this;
|
|
128
110
|
}
|
|
129
111
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return _get(_getPrototypeOf(_class.prototype), "$mount", this).call(this);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var action = testBreakpoints(this);
|
|
112
|
+
$mount() {
|
|
113
|
+
if (!hasBreakpointConfiguration(this)) {
|
|
114
|
+
return super.$mount();
|
|
115
|
+
}
|
|
138
116
|
|
|
139
|
-
|
|
140
|
-
return _get(_getPrototypeOf(_class.prototype), "$mount", this).call(this);
|
|
141
|
-
}
|
|
117
|
+
var action = testBreakpoints(this);
|
|
142
118
|
|
|
143
|
-
|
|
119
|
+
if (action === '$mount') {
|
|
120
|
+
return super.$mount();
|
|
144
121
|
}
|
|
145
|
-
}]);
|
|
146
122
|
|
|
147
|
-
|
|
148
|
-
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}, _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
|
|
149
127
|
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 : '', "WithBreakpointObserver"),
|
|
150
128
|
options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
|
|
151
129
|
activeBreakpoints: String,
|
|
152
130
|
inactiveBreakpoints: String
|
|
153
131
|
})
|
|
154
132
|
})), _temp;
|
|
155
|
-
}
|
|
156
|
-
//# sourceMappingURL=withBreakpointObserver.js.map
|
|
133
|
+
}
|
package/decorators/withDrag.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../
|
|
3
|
-
* @typedef {import('../
|
|
2
|
+
* @typedef {import('../Base').default} Base
|
|
3
|
+
* @typedef {import('../Base').BaseConstructor} BaseConstructor
|
|
4
4
|
* @typedef {import('../services/drag').DragServiceOptions} DragServiceOptions
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* Add dragging capabilities to a component.
|
|
11
11
|
*
|
|
12
|
-
* @template {
|
|
12
|
+
* @template {BaseConstructor} T
|
|
13
13
|
* @param {T} BaseClass
|
|
14
14
|
* @param {DragDecoratorOptions} options
|
|
15
15
|
* @return {T}
|
|
16
16
|
*/
|
|
17
|
-
export default function withDrag<T extends typeof import("../
|
|
18
|
-
export type Base = import('../
|
|
19
|
-
export type
|
|
17
|
+
export default function withDrag<T extends typeof import("../Base").default>(BaseClass: T, options?: DragDecoratorOptions): T;
|
|
18
|
+
export type Base = import('../Base').default;
|
|
19
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
20
20
|
export type DragServiceOptions = import('../services/drag').DragServiceOptions;
|
|
21
21
|
export type DragDecoratorOptions = import("../services/drag.js").DragServiceOptions & {
|
|
22
22
|
target: (this: Base) => HTMLElement;
|
package/decorators/withDrag.js
CHANGED
|
@@ -1,55 +1,31 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
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 _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
2
|
var _excluded = ["target"];
|
|
8
|
-
|
|
9
|
-
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); }; }
|
|
10
|
-
|
|
11
|
-
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; } }
|
|
12
|
-
|
|
13
3
|
import useDrag from '../services/drag.js';
|
|
14
4
|
export default function withDrag(BaseClass) {
|
|
15
5
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
16
|
-
target
|
|
6
|
+
target() {
|
|
17
7
|
return this.$el;
|
|
18
8
|
}
|
|
19
|
-
};
|
|
20
|
-
return function (_BaseClass) {
|
|
21
|
-
_inherits(_class, _BaseClass);
|
|
22
|
-
|
|
23
|
-
var _super = _createSuper(_class);
|
|
24
|
-
|
|
25
|
-
function _class(el) {
|
|
26
|
-
var _this;
|
|
27
|
-
|
|
28
|
-
_classCallCheck(this, _class);
|
|
29
|
-
|
|
30
|
-
_this = _super.call(this, el);
|
|
31
9
|
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
};
|
|
11
|
+
return class extends BaseClass {
|
|
12
|
+
constructor(el) {
|
|
13
|
+
super(el);
|
|
14
|
+
this.$on('mounted', () => {
|
|
15
|
+
var {
|
|
16
|
+
target
|
|
17
|
+
} = options,
|
|
34
18
|
otherOptions = _objectWithoutProperties(options, _excluded);
|
|
35
19
|
|
|
36
|
-
var boundUseDrag = useDrag.bind(undefined, target.call(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
_this.$services.enable('dragged');
|
|
20
|
+
var boundUseDrag = useDrag.bind(undefined, target.call(this), otherOptions);
|
|
21
|
+
this.$services.register('dragged', boundUseDrag);
|
|
22
|
+
this.$services.enable('dragged');
|
|
41
23
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_this.$services.unregister('dragged');
|
|
24
|
+
this.$on('destroyed', () => {
|
|
25
|
+
this.$services.disable('dragged');
|
|
26
|
+
this.$services.unregister('dragged');
|
|
47
27
|
});
|
|
48
|
-
|
|
49
|
-
return _this;
|
|
50
28
|
}
|
|
51
29
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=withDrag.js.map
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('deepmerge').Options} DeepmergeOptions
|
|
3
|
-
* @typedef {import('../
|
|
4
|
-
* @typedef {import('../
|
|
3
|
+
* @typedef {import('../Base').BaseConfig} BaseConfig
|
|
4
|
+
* @typedef {import('../Base').BaseConstructor} BaseConstructor
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Extends the configuration of an existing class.
|
|
8
8
|
*
|
|
9
|
-
* @template {
|
|
9
|
+
* @template {BaseConstructor} T
|
|
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
|
* @return {T}
|
|
14
14
|
*/
|
|
15
|
-
export default function withExtraConfig<T extends typeof import("../
|
|
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;
|
|
17
|
-
export type BaseConfig = import('../
|
|
18
|
-
export type
|
|
17
|
+
export type BaseConfig = import('../Base').BaseConfig;
|
|
18
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
|
|
7
|
-
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); }; }
|
|
8
|
-
|
|
9
|
-
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; } }
|
|
10
|
-
|
|
11
2
|
import merge from 'deepmerge';
|
|
12
3
|
export default function withExtraConfig(BaseClass, config) {
|
|
13
4
|
var _class, _temp;
|
|
@@ -19,18 +10,5 @@ export default function withExtraConfig(BaseClass, config) {
|
|
|
19
10
|
newConfig.name = "".concat(BaseClass.config.name, "WithExtraConfig");
|
|
20
11
|
}
|
|
21
12
|
|
|
22
|
-
return _temp = _class =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var _super = _createSuper(_class);
|
|
26
|
-
|
|
27
|
-
function _class() {
|
|
28
|
-
_classCallCheck(this, _class);
|
|
29
|
-
|
|
30
|
-
return _super.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return _class;
|
|
34
|
-
}(BaseClass), _defineProperty(_class, "config", newConfig), _temp;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=withExtraConfig.js.map
|
|
13
|
+
return _temp = _class = class extends BaseClass {}, _defineProperty(_class, "config", newConfig), _temp;
|
|
14
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IntersectionObserver decoration.
|
|
3
3
|
*
|
|
4
|
-
* @template {
|
|
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
|
* @return {T & { new: (element:HTMLElement) => { $observer: IntersectionObserver }}}
|
|
8
8
|
*/
|
|
9
|
-
export default function withIntersectionObserver<T extends typeof import("../
|
|
9
|
+
export default function withIntersectionObserver<T extends typeof import("../Base").default>(BaseClass: T, defaultOptions?: any): T & {
|
|
10
10
|
new: (element: HTMLElement) => {
|
|
11
11
|
$observer: IntersectionObserver;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export type Base = import('../
|
|
15
|
-
export type
|
|
14
|
+
export type Base = import('../Base').default;
|
|
15
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
16
16
|
export type WithIntersectionObserverOptions = {
|
|
17
17
|
intersectionObserver: any;
|
|
18
18
|
};
|