@aiszlab/relax 1.5.0 → 1.5.2
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/hooks/use-composed-ref.cjs +2 -2
- package/dist/hooks/use-composed-ref.d.ts +1 -1
- package/dist/hooks/use-composed-ref.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/using.cjs +12 -2
- package/dist/react/using.d.ts +5 -1
- package/dist/react/using.mjs +12 -2
- package/package.json +9 -9
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var mountRef = require('../react/mount-ref.cjs');
|
|
4
4
|
var useEvent = require('./use-event.cjs');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var useComposedRef = function useComposedRef() {
|
|
7
7
|
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
8
|
refs[_key] = arguments[_key];
|
|
9
9
|
}
|
|
@@ -15,4 +15,4 @@ var useComposeRef = function useComposeRef() {
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
exports.
|
|
18
|
+
exports.useComposedRef = useComposedRef;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Nullable, Voidable } from "@aiszlab/relax/types";
|
|
2
2
|
import { type Refable } from "../react/mount-ref";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const useComposedRef: <T>(...refs: Voidable<Refable<Nullable<T>>>[]) => (reference: T) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mountRef } from '../react/mount-ref.mjs';
|
|
2
2
|
import { useEvent } from './use-event.mjs';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var useComposedRef = function useComposedRef() {
|
|
5
5
|
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6
6
|
refs[_key] = arguments[_key];
|
|
7
7
|
}
|
|
@@ -13,4 +13,4 @@ var useComposeRef = function useComposeRef() {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export {
|
|
16
|
+
export { useComposedRef };
|
package/dist/index.cjs
CHANGED
|
@@ -89,7 +89,7 @@ exports.useDefault = useDefault.useDefault;
|
|
|
89
89
|
exports.useScrollLocker = useScrollLocker.useScrollLocker;
|
|
90
90
|
exports.useForceUpdate = useForceUpdate.useForceUpdate;
|
|
91
91
|
exports.useScrollable = useScrollable.useScrollable;
|
|
92
|
-
exports.
|
|
92
|
+
exports.useComposedRef = useComposedRef.useComposedRef;
|
|
93
93
|
exports.useTogglable = useTogglable.useTogglable;
|
|
94
94
|
exports.useEvent = useEvent.useEvent;
|
|
95
95
|
exports.useUpdateEffect = useUpdateEffect.useUpdateEffect;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { useDefault } from "./hooks/use-default";
|
|
|
14
14
|
export { useScrollLocker } from "./hooks/use-scroll-locker";
|
|
15
15
|
export { useForceUpdate } from "./hooks/use-force-update";
|
|
16
16
|
export { useScrollable } from "./hooks/use-scrollable";
|
|
17
|
-
export {
|
|
17
|
+
export { useComposedRef } from "./hooks/use-composed-ref";
|
|
18
18
|
export { useTogglable } from "./hooks/use-togglable";
|
|
19
19
|
export { useEvent } from "./hooks/use-event";
|
|
20
20
|
export { useUpdateEffect } from "./hooks/use-update-effect";
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ export { useDefault } from './hooks/use-default.mjs';
|
|
|
10
10
|
export { useScrollLocker } from './hooks/use-scroll-locker.mjs';
|
|
11
11
|
export { useForceUpdate } from './hooks/use-force-update.mjs';
|
|
12
12
|
export { useScrollable } from './hooks/use-scrollable.mjs';
|
|
13
|
-
export {
|
|
13
|
+
export { useComposedRef } from './hooks/use-composed-ref.mjs';
|
|
14
14
|
export { useTogglable } from './hooks/use-togglable.mjs';
|
|
15
15
|
export { useEvent } from './hooks/use-event.mjs';
|
|
16
16
|
export { useUpdateEffect } from './hooks/use-update-effect.mjs';
|
package/dist/react/using.cjs
CHANGED
|
@@ -50,10 +50,20 @@ var using = function using(initializer) {
|
|
|
50
50
|
subscribe = _initialize.subscribe,
|
|
51
51
|
initialState = _initialize.initialState,
|
|
52
52
|
state = _initialize.state;
|
|
53
|
-
//
|
|
54
|
-
|
|
53
|
+
// create like hooks
|
|
54
|
+
var useStore = function useStore() {
|
|
55
55
|
return react.useSyncExternalStore(subscribe, state, initialState);
|
|
56
56
|
};
|
|
57
|
+
Object.defineProperty(useStore, "state", {
|
|
58
|
+
get: function get() {
|
|
59
|
+
return state();
|
|
60
|
+
},
|
|
61
|
+
set: function set() {
|
|
62
|
+
console.warn("`useStore`.`state` is readonly property!");
|
|
63
|
+
return Reflect.get(useStore, "state");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return useStore;
|
|
57
67
|
};
|
|
58
68
|
|
|
59
69
|
exports.using = using;
|
package/dist/react/using.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
type SetState<T> = (state: T | ((previous: T) => T)) => void;
|
|
2
2
|
type Initializer<T> = (setState: SetState<T>) => T;
|
|
3
|
-
|
|
3
|
+
type UseStore<T> = {
|
|
4
|
+
(): T;
|
|
5
|
+
get state(): T;
|
|
6
|
+
};
|
|
7
|
+
declare const using: <T>(initializer: Initializer<T>) => UseStore<T>;
|
|
4
8
|
export { using };
|
package/dist/react/using.mjs
CHANGED
|
@@ -48,10 +48,20 @@ var using = function using(initializer) {
|
|
|
48
48
|
subscribe = _initialize.subscribe,
|
|
49
49
|
initialState = _initialize.initialState,
|
|
50
50
|
state = _initialize.state;
|
|
51
|
-
//
|
|
52
|
-
|
|
51
|
+
// create like hooks
|
|
52
|
+
var useStore = function useStore() {
|
|
53
53
|
return useSyncExternalStore(subscribe, state, initialState);
|
|
54
54
|
};
|
|
55
|
+
Object.defineProperty(useStore, "state", {
|
|
56
|
+
get: function get() {
|
|
57
|
+
return state();
|
|
58
|
+
},
|
|
59
|
+
set: function set() {
|
|
60
|
+
console.warn("`useStore`.`state` is readonly property!");
|
|
61
|
+
return Reflect.get(useStore, "state");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return useStore;
|
|
55
65
|
};
|
|
56
66
|
|
|
57
67
|
export { using };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
"publish:npm": "npm publish"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@babel/runtime": "^7.25.
|
|
39
|
+
"@babel/runtime": "^7.25.7",
|
|
40
40
|
"react-is": "^18.3.1",
|
|
41
41
|
"rxjs": "^7.8.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.25.
|
|
45
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
46
|
-
"@babel/preset-env": "^7.25.
|
|
47
|
-
"@babel/preset-react": "^7.
|
|
48
|
-
"@babel/preset-typescript": "^7.
|
|
44
|
+
"@babel/core": "^7.25.8",
|
|
45
|
+
"@babel/plugin-transform-runtime": "^7.25.7",
|
|
46
|
+
"@babel/preset-env": "^7.25.8",
|
|
47
|
+
"@babel/preset-react": "^7.25.7",
|
|
48
|
+
"@babel/preset-typescript": "^7.25.7",
|
|
49
49
|
"@jest/globals": "^29.7.0",
|
|
50
50
|
"@rollup/plugin-babel": "^6.0.4",
|
|
51
51
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
52
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
52
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
53
53
|
"@testing-library/react": "^16.0.1",
|
|
54
54
|
"@types/babel__core": "^7.20.5",
|
|
55
55
|
"@types/react": "^18.3.11",
|
|
56
|
-
"@types/react-dom": "^18.3.
|
|
56
|
+
"@types/react-dom": "^18.3.1",
|
|
57
57
|
"@types/react-is": "^18.3.0",
|
|
58
58
|
"jest": "^29.7.0",
|
|
59
59
|
"jest-environment-jsdom": "^29.7.0",
|