@studiometa/js-toolkit 2.0.0-alpha.4 → 2.0.0-alpha.8
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 +29 -47
- package/Base/index.js +19 -14
- package/Base/managers/ChildrenManager.d.ts +6 -6
- package/Base/managers/ChildrenManager.js +1 -2
- package/Base/managers/EventsManager.d.ts +9 -9
- package/Base/managers/EventsManager.js +18 -33
- package/Base/managers/OptionsManager.d.ts +0 -8
- package/Base/managers/OptionsManager.js +1 -6
- package/Base/managers/RefsManager.js +1 -2
- package/Base/managers/ServicesManager.d.ts +14 -3
- package/Base/managers/ServicesManager.js +30 -12
- package/Base/utils.js +1 -2
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +4 -4
- package/decorators/withBreakpointManager.js +1 -2
- package/decorators/withBreakpointObserver.d.ts +2 -2
- package/decorators/withBreakpointObserver.js +1 -2
- package/decorators/withDrag.d.ts +3 -3
- package/decorators/withDrag.js +1 -2
- package/decorators/withExtraConfig.d.ts +3 -3
- package/decorators/withExtraConfig.js +1 -2
- package/decorators/withIntersectionObserver.d.ts +2 -2
- package/decorators/withIntersectionObserver.js +1 -11
- package/decorators/withMountWhenInView.d.ts +3 -3
- package/decorators/withMountWhenInView.js +1 -2
- package/helpers/createApp.d.ts +3 -3
- package/helpers/createApp.js +9 -9
- package/helpers/importOnInteraction.d.ts +3 -3
- package/helpers/importOnInteraction.js +1 -2
- package/helpers/importWhenIdle.d.ts +3 -3
- package/helpers/importWhenIdle.js +1 -2
- package/helpers/importWhenVisible.d.ts +3 -3
- package/helpers/importWhenVisible.js +1 -2
- package/helpers/index.js +1 -2
- package/helpers/utils.js +1 -2
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/index.modern.js +1 -2
- package/index.umd.js +1 -2
- package/package.json +3 -4
- package/services/Service.js +1 -2
- package/services/drag.js +1 -2
- package/services/index.js +1 -2
- package/services/key.js +1 -2
- package/services/load.d.ts +1 -1
- package/services/load.js +2 -3
- package/services/pointer.js +1 -2
- package/services/raf.js +1 -2
- package/services/resize.js +1 -6
- package/services/scroll.js +1 -2
- package/utils/collide/boundingRectToCircle.js +1 -2
- 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 +1 -2
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +1 -2
- package/utils/css/transition.js +1 -2
- package/utils/debounce.js +1 -2
- package/utils/focusTrap.js +1 -2
- package/utils/history.js +2 -3
- 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 +1 -2
- package/utils/object/autoBind.js +1 -2
- package/utils/object/getAllProperties.js +1 -2
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +1 -2
- 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 +1 -2
- package/Base/index.js.map +0 -1
- package/Base/managers/ChildrenManager.js.map +0 -1
- package/Base/managers/EventsManager.js.map +0 -1
- package/Base/managers/OptionsManager.js.map +0 -1
- package/Base/managers/RefsManager.js.map +0 -1
- package/Base/managers/ServicesManager.js.map +0 -1
- package/Base/utils.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -58
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -244
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -19
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -136
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -43
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -186
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -120
- 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/helpers/createApp.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/Service.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
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# JS Toolkit
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@studiometa/js-toolkit/)
|
|
4
|
-
[](https://bundlephobia.com/package/@studiometa/js-toolkit)
|
|
5
|
+
[](https://david-dm.org/studiometa/js-toolkit)
|
|
6
6
|

|
|
7
7
|
|
|
8
8
|
> A set of useful little bits of JavaScript to boost your project! 🚀
|
|
@@ -15,29 +15,19 @@ Install the latest version via NPM:
|
|
|
15
15
|
npm install @studiometa/js-toolkit
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
The package can be used directly with the [Skypack CDN](https://www.skypack.dev) as follow:
|
|
19
|
-
|
|
20
|
-
```html
|
|
21
|
-
<script type="module">
|
|
22
|
-
// Import the Base class
|
|
23
|
-
import Base from 'https://cdn.skypack.dev/@studiometa/js-toolkit/';
|
|
24
|
-
// Import the full toolkit
|
|
25
|
-
import * as components from 'https://cdn.skypack.dev/@studiometa/js-toolkit/components';
|
|
26
|
-
import * as decorators from 'https://cdn.skypack.dev/@studiometa/js-toolkit/decorators';
|
|
27
|
-
import * as services from 'https://cdn.skypack.dev/@studiometa/js-toolkit/services';
|
|
28
|
-
import * as utils from 'https://cdn.skypack.dev/@studiometa/js-toolkit/utils';
|
|
29
|
-
</script>
|
|
30
|
-
```
|
|
31
|
-
|
|
32
18
|
## Usage
|
|
33
19
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Import the `Base` class to create your components from your `node_modules`:
|
|
20
|
+
Import the `Base` class and extend it to create your components:
|
|
37
21
|
|
|
38
22
|
```js
|
|
39
|
-
import Base from '@studiometa/js-toolkit';
|
|
40
|
-
import Modal from '@studiometa/
|
|
23
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
24
|
+
import Modal from '@studiometa/ui/Modal';
|
|
25
|
+
|
|
26
|
+
class Component {
|
|
27
|
+
static config = {
|
|
28
|
+
name: 'Component',
|
|
29
|
+
}
|
|
30
|
+
}
|
|
41
31
|
|
|
42
32
|
class App extends Base {
|
|
43
33
|
static config = {
|
|
@@ -46,6 +36,7 @@ class App extends Base {
|
|
|
46
36
|
debug: true,
|
|
47
37
|
components: {
|
|
48
38
|
Modal,
|
|
39
|
+
Component,
|
|
49
40
|
},
|
|
50
41
|
refs: ['btn', 'items[]'],
|
|
51
42
|
options: {
|
|
@@ -90,53 +81,4 @@ export default new App(document.querySelector('#app'));
|
|
|
90
81
|
|
|
91
82
|
Read the [documentation](https://js-toolkit.meta.fr/) to learn more.
|
|
92
83
|
|
|
93
|
-
### Modern JS in browser
|
|
94
|
-
|
|
95
|
-
Two modern builds are provided for prototyping purpose, they can be used as follow:
|
|
96
84
|
|
|
97
|
-
```html
|
|
98
|
-
<script type="module">
|
|
99
|
-
// Import the Base class
|
|
100
|
-
import Base from 'https://cdn.skypack.dev/@studiometa/js-toolkit/';
|
|
101
|
-
// Import the full toolkit
|
|
102
|
-
import Modal from 'https://cdn.skypack.dev/@studiometa/js-toolkit/components/Modal';
|
|
103
|
-
</script>
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Legacy JS
|
|
107
|
-
|
|
108
|
-
Two UMD builds are also provided to be used in legacy projects.
|
|
109
|
-
|
|
110
|
-
```html
|
|
111
|
-
<div id="app">
|
|
112
|
-
<button data-ref="btn">Add more</button>
|
|
113
|
-
<input data-ref="input" value="0" readonly />
|
|
114
|
-
<div data-component="Component"></div>
|
|
115
|
-
</div>
|
|
116
|
-
<script src="https://unpkg.com/@studiometa/js-toolkit/index.umd.js"></script>
|
|
117
|
-
<script>
|
|
118
|
-
var Component = Base.defineComponent({
|
|
119
|
-
config: {
|
|
120
|
-
name: 'Component',
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
Base.createBase(document.querySelector('#app'), {
|
|
125
|
-
config: {
|
|
126
|
-
name: 'App',
|
|
127
|
-
log: true,
|
|
128
|
-
components: {
|
|
129
|
-
Component: Component,
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
mounted: function() {
|
|
133
|
-
this.$log('mounted');
|
|
134
|
-
},
|
|
135
|
-
methods: {
|
|
136
|
-
onBtnClick: function() {
|
|
137
|
-
this.$refs.input.value = Number(this.$refs.input.value) + 1;
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
</script>
|
|
142
|
-
```
|
package/decorators/index.js
CHANGED
|
@@ -4,5 +4,4 @@ import withDrag from './withDrag.js';
|
|
|
4
4
|
import withExtraConfig from './withExtraConfig.js';
|
|
5
5
|
import withIntersectionObserver from './withIntersectionObserver.js';
|
|
6
6
|
import withMountWhenInView from './withMountWhenInView.js';
|
|
7
|
-
export { withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withIntersectionObserver, withMountWhenInView };
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
7
|
+
export { withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withIntersectionObserver, withMountWhenInView };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BreakpointManager class.
|
|
3
|
-
* @template {
|
|
3
|
+
* @template {BaseConstructor} T
|
|
4
4
|
* @param {T} BaseClass
|
|
5
|
-
* @param {Array<[String,
|
|
5
|
+
* @param {Array<[String, BaseConstructor]>} breakpoints
|
|
6
6
|
* @return {T}
|
|
7
7
|
*/
|
|
8
|
-
export default function withBreakpointManager<T extends typeof import("../Base").default>(BaseClass: T, breakpoints: Array<[string,
|
|
8
|
+
export default function withBreakpointManager<T extends typeof import("../Base").default>(BaseClass: T, breakpoints: Array<[string, BaseConstructor]>): T;
|
|
9
9
|
export type Base = import('../Base').default;
|
|
10
|
-
export type
|
|
10
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
@@ -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
8
|
export default function withBreakpointObserver<T extends typeof import("../Base").default>(BaseClass: T): T;
|
|
9
9
|
export type Base = import('../Base').default;
|
|
10
|
-
export type
|
|
10
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
11
11
|
export type WithBreakpointObserverOptions = {
|
|
12
12
|
activeBreakpoints?: string;
|
|
13
13
|
inactiveBreakpoints?: string;
|
package/decorators/withDrag.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('../Base').default} Base
|
|
3
|
-
* @typedef {import('../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
17
|
export default function withDrag<T extends typeof import("../Base").default>(BaseClass: T, options?: DragDecoratorOptions): T;
|
|
18
18
|
export type Base = import('../Base').default;
|
|
19
|
-
export type
|
|
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,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('deepmerge').Options} DeepmergeOptions
|
|
3
3
|
* @typedef {import('../Base').BaseConfig} BaseConfig
|
|
4
|
-
* @typedef {import('../Base').
|
|
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}
|
|
@@ -15,4 +15,4 @@
|
|
|
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;
|
|
17
17
|
export type BaseConfig = import('../Base').BaseConfig;
|
|
18
|
-
export type
|
|
18
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
@@ -1,7 +1,7 @@
|
|
|
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 }}}
|
|
@@ -12,7 +12,7 @@ export default function withIntersectionObserver<T extends typeof import("../Bas
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
export type Base = import('../Base').default;
|
|
15
|
-
export type
|
|
15
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
16
16
|
export type WithIntersectionObserverOptions = {
|
|
17
17
|
intersectionObserver: any;
|
|
18
18
|
};
|
|
@@ -15,10 +15,6 @@ export default function withIntersectionObserver(BaseClass) {
|
|
|
15
15
|
threshold: createArrayOfNumber(100)
|
|
16
16
|
};
|
|
17
17
|
return _temp = _class = class extends BaseClass {
|
|
18
|
-
get __excludeFromAutoBind() {
|
|
19
|
-
return [...(super.__excludeFromAutoBind || []), 'intersected'];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
constructor(element) {
|
|
23
19
|
super(element);
|
|
24
20
|
|
|
@@ -32,11 +28,6 @@ export default function withIntersectionObserver(BaseClass) {
|
|
|
32
28
|
this.$emit('intersected', entries);
|
|
33
29
|
this.intersected(entries);
|
|
34
30
|
}, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver || {}));
|
|
35
|
-
|
|
36
|
-
if (this.$isMounted) {
|
|
37
|
-
this.$observer.observe(this.$el);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
31
|
this.$on('mounted', () => {
|
|
41
32
|
this.$observer.observe(this.$el);
|
|
42
33
|
});
|
|
@@ -52,5 +43,4 @@ export default function withIntersectionObserver(BaseClass) {
|
|
|
52
43
|
intersectionObserver: Object
|
|
53
44
|
})
|
|
54
45
|
})), _temp;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=withIntersectionObserver.js.map
|
|
46
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('../Base').default} Base
|
|
3
3
|
* @typedef {import('../Base').BaseOptions} BaseOptions
|
|
4
|
-
* @typedef {import('../Base').
|
|
4
|
+
* @typedef {import('../Base').BaseConstructor} BaseConstructor
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} WithMountWhenInViewOptions
|
|
@@ -15,7 +15,7 @@
|
|
|
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}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
export default function withMountWhenInView<T extends typeof import("../Base").default>(BaseClass: T, defaultOptions?: any): T;
|
|
24
24
|
export type Base = import('../Base').default;
|
|
25
25
|
export type BaseOptions = import('../Base').BaseOptions;
|
|
26
|
-
export type
|
|
26
|
+
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
27
27
|
export type WithMountWhenInViewOptions = {
|
|
28
28
|
intersectionObserver: any;
|
|
29
29
|
};
|
package/helpers/createApp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../Base/index.js').
|
|
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,7 +26,7 @@
|
|
|
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
|
*
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
36
|
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement: HTMLElement): () => Promise<InstanceType<T>>;
|
|
37
|
-
export type
|
|
37
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
package/helpers/createApp.js
CHANGED
|
@@ -13,18 +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', () => {
|
|
23
|
-
if (document.readyState === 'complete') {
|
|
24
|
-
setTimeout(() => resolve(app), 0);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
+
return promise;
|
|
28
29
|
};
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=createApp.js.map
|
|
30
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../Base/index.js').
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
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.
|
|
@@ -21,5 +21,5 @@
|
|
|
21
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
|
|
24
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
25
25
|
export type Base = import('../Base/index.js').default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../Base/index.js').
|
|
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.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
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,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('../Base/index.js').default} Base
|
|
3
|
-
* @typedef {import('../Base/index.js').
|
|
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.
|
|
@@ -22,4 +22,4 @@ export default function importWhenVisible<T extends typeof import("../Base/index
|
|
|
22
22
|
default: T;
|
|
23
23
|
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: Base | undefined, observerOptions?: IntersectionObserverInit | undefined): Promise<T>;
|
|
24
24
|
export type Base = import('../Base/index.js').default;
|
|
25
|
-
export type
|
|
25
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -27,5 +27,4 @@ export default function importWhenVisible(fn, nameOrSelectorOrElement, parent) {
|
|
|
27
27
|
var elements = getTargetElements(nameOrSelectorOrElement, parent === null || parent === void 0 ? void 0 : parent.$el);
|
|
28
28
|
elements.forEach(element => observer.observe(element));
|
|
29
29
|
});
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=importWhenVisible.js.map
|
|
30
|
+
}
|
package/helpers/index.js
CHANGED
|
@@ -2,5 +2,4 @@ import createApp from './createApp.js';
|
|
|
2
2
|
import importOnInteraction from './importOnInteraction.js';
|
|
3
3
|
import importWhenIdle from './importWhenIdle.js';
|
|
4
4
|
import importWhenVisible from './importWhenVisible.js';
|
|
5
|
-
export { createApp, importOnInteraction, importWhenIdle, importWhenVisible };
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { createApp, importOnInteraction, importWhenIdle, importWhenVisible };
|
package/helpers/utils.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ import { usePointer } from "./services/index.js";
|
|
|
10
10
|
import { useRaf } from "./services/index.js";
|
|
11
11
|
import { useResize } from "./services/index.js";
|
|
12
12
|
import { useScroll } from "./services/index.js";
|
|
13
|
-
import { withDrag } from "./decorators/index.js";
|
|
14
13
|
import { withBreakpointManager } from "./decorators/index.js";
|
|
15
14
|
import { withBreakpointObserver } from "./decorators/index.js";
|
|
15
|
+
import { withDrag } from "./decorators/index.js";
|
|
16
16
|
import { withExtraConfig } from "./decorators/index.js";
|
|
17
17
|
import { withIntersectionObserver } from "./decorators/index.js";
|
|
18
18
|
import { withMountWhenInView } from "./decorators/index.js";
|
|
19
|
-
export { Base, createApp, importOnInteraction, importWhenIdle, importWhenVisible, useDrag, useKey, useLoad, usePointer, useRaf, useResize, useScroll,
|
|
19
|
+
export { Base, createApp, importOnInteraction, importWhenIdle, importWhenVisible, useDrag, useKey, useLoad, usePointer, useRaf, useResize, useScroll, withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withIntersectionObserver, withMountWhenInView };
|
package/index.js
CHANGED
|
@@ -2,5 +2,4 @@ import Base from './Base/index.js';
|
|
|
2
2
|
import { withDrag, withBreakpointManager, withBreakpointObserver, withExtraConfig, withIntersectionObserver, withMountWhenInView } from './decorators/index.js';
|
|
3
3
|
import { createApp, importOnInteraction, importWhenIdle, importWhenVisible } from './helpers/index.js';
|
|
4
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,
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { Base, createApp, importOnInteraction, importWhenIdle, importWhenVisible, useDrag, useKey, useLoad, usePointer, useRaf, useResize, useScroll, withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withIntersectionObserver, withMountWhenInView };
|