@aiszlab/relax 1.2.73 → 1.2.74
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/dist/dom/contains.d.ts +16 -1
- package/dist/dom/contains.js +6 -6
- package/dist/dom/index.d.ts +3 -2
- package/dist/hooks/use-boolean.d.ts +1 -1
- package/dist/hooks/use-click-away.d.ts +3 -2
- package/dist/hooks/use-click-away.js +2 -2
- package/dist/hooks/use-controlled-state.d.ts +1 -1
- package/dist/hooks/use-counter.d.ts +1 -1
- package/dist/hooks/use-default.d.ts +1 -1
- package/dist/hooks/use-mount.d.ts +1 -1
- package/dist/hooks/use-mounted.d.ts +1 -1
- package/dist/hooks/use-reactive.d.ts +1 -1
- package/dist/hooks/use-refs.d.ts +1 -1
- package/dist/hooks/use-scrollable.d.ts +1 -1
- package/dist/hooks/use-scrollable.js +4 -4
- package/dist/hooks/use-update-effect.d.ts +1 -1
- package/dist/utils/chain.d.ts +1 -1
- package/dist/utils/effect.d.ts +1 -1
- package/dist/utils/set-style.d.ts +1 -1
- package/dist/utils/tagged-template-literals.d.ts +1 -1
- package/package.json +3 -2
package/dist/dom/contains.d.ts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Nullable, Voidable } from "@aiszlab/relax/types";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* in musae, we add this function to replace `root.contains(n)`
|
|
5
|
+
* and we use simple type declaration
|
|
6
|
+
*
|
|
7
|
+
* support `HTMLElement` interface
|
|
8
|
+
*/
|
|
9
|
+
export type Containable = {
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* native `contains` api
|
|
13
|
+
*/
|
|
14
|
+
contains?: (node: Nullable<Node>) => boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const contains: (root: Voidable<Containable>, node: Voidable<Node>) => boolean;
|
package/dist/dom/contains.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var contains = function contains(root,
|
|
1
|
+
var contains = function contains(root, node) {
|
|
2
2
|
if (!root) {
|
|
3
3
|
return false;
|
|
4
4
|
}
|
|
5
5
|
// Use native if support
|
|
6
6
|
if (root.contains) {
|
|
7
|
-
return root.contains(
|
|
7
|
+
return root.contains(node !== null && node !== void 0 ? node : null);
|
|
8
8
|
}
|
|
9
9
|
// `document.contains` not support with IE11
|
|
10
|
-
var
|
|
11
|
-
while (
|
|
12
|
-
if (
|
|
10
|
+
var _node = node;
|
|
11
|
+
while (_node) {
|
|
12
|
+
if (_node === root) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
_node = _node.parentNode;
|
|
16
16
|
}
|
|
17
17
|
return false;
|
|
18
18
|
};
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { scrollTo } from "./scroll-to";
|
|
2
|
-
import { contains } from "./contains";
|
|
1
|
+
import { scrollTo, type Orientation } from "./scroll-to";
|
|
2
|
+
import { contains, type Containable } from "./contains";
|
|
3
3
|
export { scrollTo, contains };
|
|
4
|
+
export type { Containable, Orientation };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type MutableRefObject } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type Containable } from "@aiszlab/relax/dom";
|
|
3
|
+
import type { Nullable, Arrayable } from "@aiszlab/relax/types";
|
|
3
4
|
/**
|
|
4
5
|
* @description
|
|
5
6
|
* click away
|
|
6
7
|
*/
|
|
7
|
-
export declare const useClickAway: (onClickAway: (event: MouseEvent) => void, target: Arrayable<MutableRefObject<
|
|
8
|
+
export declare const useClickAway: (onClickAway: (event: MouseEvent) => void, target: Arrayable<MutableRefObject<Nullable<Containable>> | false>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useEvent } from './use-event.js';
|
|
3
|
-
import { contains } from '../dom/contains.js';
|
|
4
3
|
import { toArray } from '../utils/to-array.js';
|
|
4
|
+
import { contains } from '@aiszlab/relax/dom';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
@@ -11,7 +11,7 @@ var useClickAway = function useClickAway(onClickAway, target) {
|
|
|
11
11
|
var clickAway = useEvent(function (event) {
|
|
12
12
|
var targets = toArray(target);
|
|
13
13
|
var isContained = targets.some(function (_target) {
|
|
14
|
-
return contains(_target.current, event.target);
|
|
14
|
+
return _target && contains(_target.current, event.target);
|
|
15
15
|
});
|
|
16
16
|
if (isContained) return;
|
|
17
17
|
onClickAway(event);
|
package/dist/hooks/use-refs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MutableRefObject, type RefCallback } from "react";
|
|
2
|
-
import type { Nullable, Voidable } from "
|
|
2
|
+
import type { Nullable, Voidable } from "@aiszlab/relax/types";
|
|
3
3
|
type Refable<T> = RefCallback<T> | MutableRefObject<T> | string;
|
|
4
4
|
export declare const useRefs: <T>(...refs: Voidable<Refable<Nullable<T>>>[]) => (trigger: T) => void;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef, useCallback } from 'react';
|
|
2
|
-
import { scrollTo
|
|
2
|
+
import { scrollTo } from '@aiszlab/relax/dom';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
@@ -11,12 +11,12 @@ var useScrollable = function useScrollable() {
|
|
|
11
11
|
orientation = _ref$orientation === void 0 ? "vertical" : _ref$orientation;
|
|
12
12
|
var targetRef = useRef(null);
|
|
13
13
|
var triggerRefs = useRef(new Map());
|
|
14
|
-
var scrollTo = useCallback(function (to) {
|
|
14
|
+
var scrollTo$1 = useCallback(function (to) {
|
|
15
15
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
16
16
|
var target = targetRef.current;
|
|
17
17
|
if (!target) return;
|
|
18
18
|
// use animated scroll
|
|
19
|
-
|
|
19
|
+
scrollTo(target, to, {
|
|
20
20
|
duration: duration,
|
|
21
21
|
orientation: orientation
|
|
22
22
|
});
|
|
@@ -34,7 +34,7 @@ var useScrollable = function useScrollable() {
|
|
|
34
34
|
return {
|
|
35
35
|
targetRef: targetRef,
|
|
36
36
|
triggerRefs: triggerRefs,
|
|
37
|
-
scrollTo: scrollTo,
|
|
37
|
+
scrollTo: scrollTo$1,
|
|
38
38
|
to: to,
|
|
39
39
|
setTrigger: setTrigger
|
|
40
40
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type DependencyList } from "react";
|
|
2
|
-
import type { ThenableEffectCallback } from "
|
|
2
|
+
import type { ThenableEffectCallback } from "@aiszlab/relax/types";
|
|
3
3
|
export declare const useUpdateEffect: (callback: ThenableEffectCallback, deps?: DependencyList) => void;
|
package/dist/utils/chain.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Voidable } from "
|
|
1
|
+
import type { Voidable } from "@aiszlab/relax/types";
|
|
2
2
|
export declare const chain: <T extends Function>(...callbacks: Voidable<T>[]) => T;
|
package/dist/utils/effect.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.74",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"build": "rollup -c",
|
|
20
20
|
"clean:build": "rm -rf dist",
|
|
21
21
|
"prepublishOnly": "npm run clean:build && npm run build",
|
|
22
|
-
"test": "jest"
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"publish:npm": "npm publish"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@babel/runtime": "^7.25.0",
|