@studiometa/js-toolkit 2.0.0-rc.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +1 -2
- package/Base/index.d.ts +25 -26
- package/Base/index.js +1 -2
- package/Base/managers/ChildrenManager.d.ts +2 -2
- package/Base/managers/EventsManager.d.ts +13 -20
- package/Base/managers/OptionsManager.cjs +0 -1
- package/Base/managers/OptionsManager.d.ts +13 -10
- package/Base/managers/OptionsManager.js +0 -1
- package/Base/managers/RefsManager.d.ts +4 -4
- package/Base/managers/ServicesManager.cjs +3 -0
- package/Base/managers/ServicesManager.d.ts +14 -8
- package/Base/managers/ServicesManager.js +3 -0
- package/Base/utils.d.ts +4 -4
- package/decorators/withBreakpointManager.cjs +0 -1
- package/decorators/withBreakpointManager.d.ts +2 -2
- package/decorators/withBreakpointManager.js +0 -1
- package/decorators/withBreakpointObserver.cjs +1 -2
- package/decorators/withBreakpointObserver.d.ts +1 -1
- package/decorators/withBreakpointObserver.js +1 -2
- package/decorators/withDrag.d.ts +1 -1
- package/decorators/withExtraConfig.d.ts +1 -1
- package/decorators/withFreezedOptions.d.ts +1 -1
- package/decorators/withIntersectionObserver.cjs +0 -1
- package/decorators/withIntersectionObserver.d.ts +1 -1
- package/decorators/withIntersectionObserver.js +0 -1
- package/decorators/withMountWhenInView.cjs +0 -1
- package/decorators/withMountWhenInView.d.ts +1 -1
- package/decorators/withMountWhenInView.js +0 -1
- package/decorators/withScrolledInView.d.ts +1 -1
- package/helpers/createApp.d.ts +3 -26
- package/helpers/getInstanceFromElement.cjs +32 -0
- package/helpers/getInstanceFromElement.d.ts +14 -0
- package/helpers/getInstanceFromElement.js +10 -0
- package/helpers/importOnInteraction.d.ts +3 -5
- package/helpers/importWhenIdle.d.ts +3 -5
- package/helpers/importWhenVisible.d.ts +4 -6
- package/helpers/index.cjs +2 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +8 -6
- package/helpers/utils.d.ts +3 -4
- package/package.json +1 -1
- package/services/Service.d.ts +9 -9
- package/services/drag.cjs +0 -1
- package/services/drag.d.ts +3 -3
- package/services/drag.js +0 -1
- package/services/key.d.ts +1 -1
- package/services/load.d.ts +1 -1
- package/services/pointer.d.ts +1 -1
- package/services/raf.d.ts +1 -1
- package/services/resize.cjs +2 -2
- package/services/resize.d.ts +1 -1
- package/services/resize.js +2 -2
- package/services/scroll.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.d.ts +5 -5
- package/utils/collide/collideCircleCircle.d.ts +4 -4
- package/utils/collide/collideCircleRect.d.ts +8 -8
- package/utils/collide/collidePointCircle.d.ts +6 -6
- package/utils/collide/collidePointRect.d.ts +7 -7
- package/utils/collide/collideRectRect.d.ts +5 -5
- package/utils/css/classes.cjs +3 -3
- package/utils/css/classes.d.ts +10 -10
- package/utils/css/classes.js +3 -3
- package/utils/css/matrix.d.ts +14 -15
- package/utils/css/styles.d.ts +2 -2
- package/utils/css/transition.d.ts +2 -2
- package/utils/debounce.d.ts +4 -4
- package/utils/focusTrap.cjs +1 -1
- package/utils/focusTrap.d.ts +1 -0
- package/utils/focusTrap.js +1 -1
- package/utils/history.d.ts +13 -11
- package/utils/math/clamp.d.ts +1 -1
- package/utils/math/clamp01.d.ts +1 -1
- package/utils/math/damp.d.ts +6 -6
- package/utils/math/ease.d.ts +7 -7
- package/utils/math/inertiaFinalValue.d.ts +5 -5
- package/utils/math/lerp.d.ts +4 -4
- package/utils/math/map.d.ts +6 -6
- package/utils/math/round.d.ts +4 -4
- package/utils/memoize.d.ts +1 -1
- package/utils/nextFrame.d.ts +3 -4
- package/utils/nextMicrotask.d.ts +1 -1
- package/utils/nextTick.d.ts +1 -1
- package/utils/object/autoBind.d.ts +3 -3
- package/utils/object/getAllProperties.d.ts +3 -3
- package/utils/object/isObject.d.ts +1 -1
- package/utils/scrollTo.cjs +1 -1
- package/utils/scrollTo.d.ts +1 -1
- package/utils/scrollTo.js +1 -1
- package/utils/string/withLeadingCharacters.d.ts +3 -2
- package/utils/string/withLeadingSlash.d.ts +1 -1
- package/utils/string/withTrailingCharacters.d.ts +3 -2
- package/utils/string/withTrailingSlash.d.ts +1 -1
- package/utils/string/withoutLeadingCharacters.d.ts +3 -2
- package/utils/string/withoutLeadingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutLeadingSlash.d.ts +1 -1
- package/utils/string/withoutTrailingCharacters.d.ts +3 -2
- package/utils/string/withoutTrailingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutTrailingSlash.d.ts +1 -1
- package/utils/throttle.cjs +1 -1
- package/utils/throttle.d.ts +3 -3
- package/utils/throttle.js +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @template {BaseConstructor} T
|
|
5
5
|
* @param {T} BaseClass The Base class to extend.
|
|
6
6
|
* @param {Object} [defaultOptions] The options for the IntersectionObserver instance.
|
|
7
|
-
* @
|
|
7
|
+
* @returns {T & { new: (element:HTMLElement) => { $observer: IntersectionObserver }}}
|
|
8
8
|
*/
|
|
9
9
|
export default function withIntersectionObserver<T extends typeof import("../Base").default>(BaseClass: T, defaultOptions?: any): T & {
|
|
10
10
|
new: (element: HTMLElement) => {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @template {BaseConstructor} T
|
|
19
19
|
* @param {T} BaseClass The Base class to extend.
|
|
20
20
|
* @param {IntersectionObserverInit} [defaultOptions] The options for the IntersectionObserver instance.
|
|
21
|
-
* @
|
|
21
|
+
* @returns {T}
|
|
22
22
|
*/
|
|
23
23
|
export default function withMountWhenInView<T extends typeof import("../Base").default>(BaseClass: T, defaultOptions?: IntersectionObserverInit): T;
|
|
24
24
|
export type Base = import('../Base').default;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @template {BaseConstructor} T
|
|
10
10
|
* @param {T} BaseClass
|
|
11
11
|
* @param {IntersectionObserverInit} options
|
|
12
|
-
* @
|
|
12
|
+
* @returns {T}
|
|
13
13
|
*/
|
|
14
14
|
export default function withScrolledInView<T extends typeof import("../Base").default>(BaseClass: T, options: IntersectionObserverInit): T;
|
|
15
15
|
export type Base = import('../Base').default;
|
package/helpers/createApp.d.ts
CHANGED
|
@@ -5,33 +5,10 @@
|
|
|
5
5
|
* Instantiate and mount the given component on the given root element when the page has been loaded
|
|
6
6
|
* and return a function to use the app instance when it is ready.
|
|
7
7
|
*
|
|
8
|
-
* @usage
|
|
9
|
-
* ```js
|
|
10
|
-
* // app.js
|
|
11
|
-
* import Base, { createApp } from '@studiometa/js-toolkit';
|
|
12
|
-
*
|
|
13
|
-
* class App extends Base {
|
|
14
|
-
* static config = {
|
|
15
|
-
* name: 'App',
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* export default createApp(App, document.body);
|
|
20
|
-
* ```
|
|
21
|
-
* ```js
|
|
22
|
-
* // other.js
|
|
23
|
-
* import useApp from './app.js';
|
|
24
|
-
*
|
|
25
|
-
* const app = await useApp();
|
|
26
|
-
* console.log(app.$options.name); // 'App'
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
8
|
* @template {BaseConstructor} T
|
|
30
9
|
* @param {T} App
|
|
31
|
-
* @param {HTMLElement
|
|
32
|
-
*
|
|
33
|
-
* @return {() => Promise<InstanceType<T>>}
|
|
34
|
-
*
|
|
10
|
+
* @param {HTMLElement} [rootElement]
|
|
11
|
+
* @returns {() => Promise<InstanceType<T>>}
|
|
35
12
|
*/
|
|
36
|
-
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement?: HTMLElement
|
|
13
|
+
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement?: HTMLElement): () => Promise<InstanceType<T>>;
|
|
37
14
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/helpers/getInstanceFromElement.js
|
|
20
|
+
var getInstanceFromElement_exports = {};
|
|
21
|
+
__export(getInstanceFromElement_exports, {
|
|
22
|
+
default: () => getInstanceFromElement
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getInstanceFromElement_exports);
|
|
25
|
+
function getInstanceFromElement(element, Constructor) {
|
|
26
|
+
var _a;
|
|
27
|
+
if (!element.__base__) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (_a = element.__base__.get(Constructor)) != null ? _a : null;
|
|
31
|
+
}
|
|
32
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get a component instance from a DOM element.
|
|
6
|
+
* @template {BaseConstructor} T
|
|
7
|
+
* @param {HTMLElement & { __base__?: WeakMap<T, InstanceType<T>> }} element
|
|
8
|
+
* @param {T} Constructor
|
|
9
|
+
* @returns {null|InstanceType<T>}
|
|
10
|
+
*/
|
|
11
|
+
export default function getInstanceFromElement<T extends typeof import("../Base/index.js").default>(element: HTMLElement & {
|
|
12
|
+
__base__?: WeakMap<T, InstanceType<T>>;
|
|
13
|
+
}, Constructor: T): InstanceType<T>;
|
|
14
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -6,20 +6,18 @@
|
|
|
6
6
|
* Import a component on an interaction.
|
|
7
7
|
*
|
|
8
8
|
* @template {BaseConstructor} T
|
|
9
|
-
*
|
|
10
9
|
* @param {() => Promise<T|{default:T}>} fn
|
|
11
10
|
* The import function.
|
|
12
11
|
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
13
12
|
* The name or selector for the component.
|
|
14
13
|
* @param {string|string[]} events
|
|
15
14
|
* The events to listen to to trigger the import.
|
|
16
|
-
* @param {Base
|
|
15
|
+
* @param {Base} [parent]
|
|
17
16
|
* The parent component.
|
|
18
|
-
*
|
|
19
|
-
* @return {Promise<T>}
|
|
17
|
+
* @returns {Promise<T>}
|
|
20
18
|
*/
|
|
21
19
|
export default function importOnInteraction<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
22
20
|
default: T;
|
|
23
|
-
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], events: string | string[], parent?: Base
|
|
21
|
+
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], events: string | string[], parent?: Base): Promise<T>;
|
|
24
22
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
25
23
|
export type Base = import('../Base/index.js').default;
|
|
@@ -6,17 +6,15 @@
|
|
|
6
6
|
* Import a component when user is idle.
|
|
7
7
|
*
|
|
8
8
|
* @template {BaseConstructor} T
|
|
9
|
-
*
|
|
10
9
|
* @param {() => Promise<T|{default:T}>} fn
|
|
11
10
|
* The import function.
|
|
12
|
-
* @param {ImportWhenIdleOptions
|
|
11
|
+
* @param {ImportWhenIdleOptions} [options]
|
|
13
12
|
* The time to wait before triggering the callback if never idle.
|
|
14
|
-
*
|
|
15
|
-
* @return {Promise<T>}
|
|
13
|
+
* @returns {Promise<T>}
|
|
16
14
|
*/
|
|
17
15
|
export default function importWhenIdle<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
18
16
|
default: T;
|
|
19
|
-
}>, options?: ImportWhenIdleOptions
|
|
17
|
+
}>, options?: ImportWhenIdleOptions): Promise<T>;
|
|
20
18
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
21
19
|
export type ImportWhenIdleOptions = {
|
|
22
20
|
timeout?: number;
|
|
@@ -6,20 +6,18 @@
|
|
|
6
6
|
* Import a component when it is visible.
|
|
7
7
|
*
|
|
8
8
|
* @template {BaseConstructor} T
|
|
9
|
-
*
|
|
10
9
|
* @param {() => Promise<T|{default:T}>} fn
|
|
11
10
|
* The import function.
|
|
12
11
|
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
13
12
|
* The name or selector for the component.
|
|
14
|
-
* @param {Base
|
|
13
|
+
* @param {Base} [parent]
|
|
15
14
|
* The parent component.
|
|
16
|
-
* @param {IntersectionObserverInit
|
|
15
|
+
* @param {IntersectionObserverInit} [observerOptions]
|
|
17
16
|
* Options for the `IntersectionObserver` instance.
|
|
18
|
-
*
|
|
19
|
-
* @return {Promise<T>}
|
|
17
|
+
* @returns {Promise<T>}
|
|
20
18
|
*/
|
|
21
19
|
export default function importWhenVisible<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
22
20
|
default: T;
|
|
23
|
-
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: Base
|
|
21
|
+
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: Base, observerOptions?: IntersectionObserverInit): Promise<T>;
|
|
24
22
|
export type Base = import('../Base/index.js').default;
|
|
25
23
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
package/helpers/index.cjs
CHANGED
|
@@ -23,12 +23,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
23
23
|
var helpers_exports = {};
|
|
24
24
|
__export(helpers_exports, {
|
|
25
25
|
createApp: () => import_createApp.default,
|
|
26
|
+
getInstanceFromElement: () => import_getInstanceFromElement.default,
|
|
26
27
|
importOnInteraction: () => import_importOnInteraction.default,
|
|
27
28
|
importWhenIdle: () => import_importWhenIdle.default,
|
|
28
29
|
importWhenVisible: () => import_importWhenVisible.default
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(helpers_exports);
|
|
31
32
|
var import_createApp = __toESM(require("./createApp.cjs"), 1);
|
|
33
|
+
var import_getInstanceFromElement = __toESM(require("./getInstanceFromElement.cjs"), 1);
|
|
32
34
|
var import_importOnInteraction = __toESM(require("./importOnInteraction.cjs"), 1);
|
|
33
35
|
var import_importWhenIdle = __toESM(require("./importWhenIdle.cjs"), 1);
|
|
34
36
|
var import_importWhenVisible = __toESM(require("./importWhenVisible.cjs"), 1);
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as createApp } from "./createApp.js";
|
|
2
|
+
export { default as getInstanceFromElement } from "./getInstanceFromElement.js";
|
|
2
3
|
export { default as importOnInteraction } from "./importOnInteraction.js";
|
|
3
4
|
export { default as importWhenIdle } from "./importWhenIdle.js";
|
|
4
5
|
export { default as importWhenVisible } from "./importWhenVisible.js";
|
package/helpers/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { default as default2 } from "./createApp.js";
|
|
2
|
-
import { default as default3 } from "./
|
|
3
|
-
import { default as default4 } from "./
|
|
4
|
-
import { default as default5 } from "./
|
|
2
|
+
import { default as default3 } from "./getInstanceFromElement.js";
|
|
3
|
+
import { default as default4 } from "./importOnInteraction.js";
|
|
4
|
+
import { default as default5 } from "./importWhenIdle.js";
|
|
5
|
+
import { default as default6 } from "./importWhenVisible.js";
|
|
5
6
|
export {
|
|
6
7
|
default2 as createApp,
|
|
7
|
-
default3 as
|
|
8
|
-
default4 as
|
|
9
|
-
default5 as
|
|
8
|
+
default3 as getInstanceFromElement,
|
|
9
|
+
default4 as importOnInteraction,
|
|
10
|
+
default5 as importWhenIdle,
|
|
11
|
+
default6 as importWhenVisible
|
|
10
12
|
};
|
package/helpers/utils.d.ts
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
5
5
|
* The original selector or element, or list of elements.
|
|
6
|
-
* @param {HTMLElement
|
|
6
|
+
* @param {HTMLElement} [context]
|
|
7
7
|
* The optional context to use to query for elements.
|
|
8
|
-
*
|
|
9
|
-
* @return {HTMLElement[]} A normalized list of elements.
|
|
8
|
+
* @returns {HTMLElement[]} A normalized list of elements.
|
|
10
9
|
*/
|
|
11
|
-
export function getTargetElements(nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], context?: HTMLElement
|
|
10
|
+
export function getTargetElements(nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], context?: HTMLElement): HTMLElement[];
|
package/package.json
CHANGED
package/services/Service.d.ts
CHANGED
|
@@ -13,43 +13,43 @@ export default class Service {
|
|
|
13
13
|
* This method MUST be implemented by the service extending this class.
|
|
14
14
|
*
|
|
15
15
|
* @param {...any} args
|
|
16
|
-
* @
|
|
16
|
+
* @returns {this['props']}
|
|
17
17
|
*/
|
|
18
18
|
updateProps(...args: any[]): unknown;
|
|
19
19
|
/**
|
|
20
20
|
* Method to initialize the service behaviors.
|
|
21
21
|
* This method MUST be implemented by the service extending this class.
|
|
22
22
|
*
|
|
23
|
-
* @
|
|
23
|
+
* @returns {void}
|
|
24
24
|
*/
|
|
25
25
|
init(): void;
|
|
26
26
|
/**
|
|
27
27
|
* Method to kill the service behaviors.
|
|
28
28
|
* This method MUST be implemented by the service extending this class.
|
|
29
29
|
*
|
|
30
|
-
* @
|
|
30
|
+
* @returns {void}
|
|
31
31
|
*/
|
|
32
32
|
kill(): void;
|
|
33
33
|
/**
|
|
34
34
|
* Add a callback.
|
|
35
35
|
*
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {string} key The callback's identifier
|
|
37
37
|
* @param {Function} callback The callback function
|
|
38
|
-
* @
|
|
38
|
+
* @returns {void}
|
|
39
39
|
*/
|
|
40
40
|
add(key: string, callback: Function): void;
|
|
41
41
|
/**
|
|
42
42
|
* Test if a callback with the given key has already been added.
|
|
43
43
|
*
|
|
44
|
-
* @param {
|
|
45
|
-
* @
|
|
44
|
+
* @param {string} key The identifier to test
|
|
45
|
+
* @returns {boolean} Whether or not the identifier already exists
|
|
46
46
|
*/
|
|
47
47
|
has(key: string): boolean;
|
|
48
48
|
/**
|
|
49
49
|
* Get the callback tied to the given key.
|
|
50
50
|
*
|
|
51
51
|
* @param {string} key The identifier to get
|
|
52
|
-
* @
|
|
52
|
+
* @returns {Function} The callback function
|
|
53
53
|
*/
|
|
54
54
|
get(key: string): Function;
|
|
55
55
|
/**
|
|
@@ -62,7 +62,7 @@ export default class Service {
|
|
|
62
62
|
* Trigger each added callback with the given arguments.
|
|
63
63
|
*
|
|
64
64
|
* @param {...any} args All the arguments to apply to the callback
|
|
65
|
-
* @
|
|
65
|
+
* @returns {this} The current instance
|
|
66
66
|
*/
|
|
67
67
|
trigger(...args: any[]): this;
|
|
68
68
|
}
|
package/services/drag.cjs
CHANGED
|
@@ -80,7 +80,6 @@ var Drag = class extends import_Service.default {
|
|
|
80
80
|
this.options = { ...this.options, ...options };
|
|
81
81
|
this.pointerHandler = this.pointerHandler.bind(this);
|
|
82
82
|
this.rafHandler = this.rafHandler.bind(this);
|
|
83
|
-
return this;
|
|
84
83
|
}
|
|
85
84
|
init() {
|
|
86
85
|
const options = { passive: true };
|
package/services/drag.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @param {HTMLElement} target
|
|
14
14
|
* @param {DragServiceOptions} options
|
|
15
|
-
* @
|
|
15
|
+
* @returns {DragService}
|
|
16
16
|
*/
|
|
17
17
|
export default function useDrag(target: HTMLElement, options: DragServiceOptions): DragService;
|
|
18
18
|
export type DragService = import('./index').ServiceInterface<DragServiceProps>;
|
|
@@ -73,6 +73,6 @@ export type DragServiceProps = {
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
export type DragServiceOptions = {
|
|
76
|
-
dampFactor?: number
|
|
77
|
-
dragTreshold?: number
|
|
76
|
+
dampFactor?: number;
|
|
77
|
+
dragTreshold?: number;
|
|
78
78
|
};
|
package/services/drag.js
CHANGED
package/services/key.d.ts
CHANGED
package/services/load.d.ts
CHANGED
package/services/pointer.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
12
|
* @todo Add element as parameter to get the pointer position relatively from.
|
|
13
|
-
* @
|
|
13
|
+
* @returns {PointerService}
|
|
14
14
|
*/
|
|
15
15
|
export default function usePointer(): PointerService;
|
|
16
16
|
export type PointerService = import('./index').ServiceInterface<PointerServiceProps>;
|
package/services/raf.d.ts
CHANGED
package/services/resize.cjs
CHANGED
|
@@ -78,10 +78,10 @@ var Resize = class extends import_Service.default {
|
|
|
78
78
|
return document.querySelector("[data-breakpoint]");
|
|
79
79
|
}
|
|
80
80
|
get breakpoint() {
|
|
81
|
-
return window.getComputedStyle(this.breakpointElement, "::before").getPropertyValue("content").
|
|
81
|
+
return window.getComputedStyle(this.breakpointElement, "::before").getPropertyValue("content").replaceAll('"', "");
|
|
82
82
|
}
|
|
83
83
|
get breakpoints() {
|
|
84
|
-
const breakpoints = window.getComputedStyle(this.breakpointElement, "::after").getPropertyValue("content").
|
|
84
|
+
const breakpoints = window.getComputedStyle(this.breakpointElement, "::after").getPropertyValue("content").replaceAll('"', "");
|
|
85
85
|
return breakpoints.split(",");
|
|
86
86
|
}
|
|
87
87
|
};
|
package/services/resize.d.ts
CHANGED
package/services/resize.js
CHANGED
|
@@ -52,10 +52,10 @@ class Resize extends Service {
|
|
|
52
52
|
return document.querySelector("[data-breakpoint]");
|
|
53
53
|
}
|
|
54
54
|
get breakpoint() {
|
|
55
|
-
return window.getComputedStyle(this.breakpointElement, "::before").getPropertyValue("content").
|
|
55
|
+
return window.getComputedStyle(this.breakpointElement, "::before").getPropertyValue("content").replaceAll('"', "");
|
|
56
56
|
}
|
|
57
57
|
get breakpoints() {
|
|
58
|
-
const breakpoints = window.getComputedStyle(this.breakpointElement, "::after").getPropertyValue("content").
|
|
58
|
+
const breakpoints = window.getComputedStyle(this.breakpointElement, "::after").getPropertyValue("content").replaceAll('"', "");
|
|
59
59
|
return breakpoints.split(",");
|
|
60
60
|
}
|
|
61
61
|
}
|
package/services/scroll.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Circle
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
5
|
-
* @property {
|
|
3
|
+
* @property {number} x Circle's x position
|
|
4
|
+
* @property {number} y Circle's y position
|
|
5
|
+
* @property {number} radius Circle's radius
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Convert clientRect to a formatted circle object
|
|
9
9
|
*
|
|
10
10
|
* @param {Partial<DOMRect>} domRect DOMRect of a square DOMElement
|
|
11
|
-
* @param {
|
|
12
|
-
* @
|
|
11
|
+
* @param {boolean} force Force usage of non-square DOMElements
|
|
12
|
+
* @returns {Circle} Circle object that can be used in collides functions
|
|
13
13
|
*/
|
|
14
14
|
export default function boundingRectToCircle({ x, y, width, height }: Partial<DOMRect>, force?: boolean): Circle;
|
|
15
15
|
export type Circle = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Circle
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
5
|
-
* @property {
|
|
3
|
+
* @property {number} x Circle's x position
|
|
4
|
+
* @property {number} y Circle's y position
|
|
5
|
+
* @property {number} radius Circle's radius
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Test if a circle collides with another.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @param {Circle} circle1 Circle 1
|
|
12
12
|
* @param {Circle} circle2 Circle 2
|
|
13
|
-
* @
|
|
13
|
+
* @returns {boolean} Are the sides of one circle touching the other ?
|
|
14
14
|
*/
|
|
15
15
|
export default function collideCircleCircle(circle1: Circle, circle2: Circle): boolean;
|
|
16
16
|
export type Circle = {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Rect
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
5
|
-
* @property {
|
|
6
|
-
* @property {
|
|
3
|
+
* @property {number} x Rectangle's x position
|
|
4
|
+
* @property {number} y Rectangle's y position
|
|
5
|
+
* @property {number} width Rectangle's width
|
|
6
|
+
* @property {number} height Rectangle's height
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {Object} Circle
|
|
10
|
-
* @property {
|
|
11
|
-
* @property {
|
|
12
|
-
* @property {
|
|
10
|
+
* @property {number} x Circle's x position
|
|
11
|
+
* @property {number} y Circle's y position
|
|
12
|
+
* @property {number} radius Circle's radius
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* Test if a circle collides with a rectangle.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @param {Circle} circle Circle
|
|
19
19
|
* @param {Rect} rect Rectangle
|
|
20
|
-
* @
|
|
20
|
+
* @returns {boolean} Are the sides of the circle touching the rectangle ?
|
|
21
21
|
*/
|
|
22
22
|
export default function collideCircleRect(circle: Circle, rect: Rect): boolean;
|
|
23
23
|
export type Rect = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Point
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
3
|
+
* @property {number} x Point's x position
|
|
4
|
+
* @property {number} y Point's y position
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} Circle
|
|
8
|
-
* @property {
|
|
9
|
-
* @property {
|
|
10
|
-
* @property {
|
|
8
|
+
* @property {number} x Circle's x position
|
|
9
|
+
* @property {number} y Circle's y position
|
|
10
|
+
* @property {number} radius Circle's radius
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* Test if a point is inside a circle.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @param {Point} point Point
|
|
17
17
|
* @param {Circle} circle Circle
|
|
18
|
-
* @
|
|
18
|
+
* @returns {boolean} Is the point inside the circle's bounds ?
|
|
19
19
|
*/
|
|
20
20
|
export default function collidePointCircle(point: Point, circle: Circle): boolean;
|
|
21
21
|
export type Point = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Point
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
3
|
+
* @property {number} x Point's x position
|
|
4
|
+
* @property {number} y Point's y position
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} Rect
|
|
8
|
-
* @property {
|
|
9
|
-
* @property {
|
|
10
|
-
* @property {
|
|
11
|
-
* @property {
|
|
8
|
+
* @property {number} x Rectangle's x position
|
|
9
|
+
* @property {number} y Rectangle's y position
|
|
10
|
+
* @property {number} width Rectangle's width
|
|
11
|
+
* @property {number} height Rectangle's height
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* Test if a point collides with a rectangle.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @param {Point} point Point
|
|
18
18
|
* @param {Rect} rect Rectangle
|
|
19
|
-
* @
|
|
19
|
+
* @returns {boolean} Is the point inside the rectangle's bounds ?
|
|
20
20
|
*/
|
|
21
21
|
export default function collidePointRect(point: Point, rect: Rect): boolean;
|
|
22
22
|
export type Point = {
|