@aiszlab/relax 1.2.48 → 1.2.50
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.
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
2
|
import type { State } from '../types';
|
|
3
3
|
type Props = {
|
|
4
|
-
/**
|
|
5
|
-
* @description
|
|
6
|
-
* initial value
|
|
7
|
-
*/
|
|
8
|
-
initialState?: State<number>;
|
|
9
4
|
/**
|
|
10
5
|
* @description
|
|
11
6
|
* max: count will not be greater than max
|
|
@@ -9,16 +9,15 @@ import { useDefault } from './use-default.js';
|
|
|
9
9
|
* @description
|
|
10
10
|
* a number counter with some useful apis
|
|
11
11
|
*/
|
|
12
|
-
var useCounter = function useCounter(
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
min: -Infinity
|
|
16
|
-
},
|
|
12
|
+
var useCounter = function useCounter() {
|
|
13
|
+
var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
14
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
17
15
|
_ref$max = _ref.max,
|
|
18
16
|
max = _ref$max === void 0 ? Infinity : _ref$max,
|
|
19
17
|
_ref$min = _ref.min,
|
|
20
18
|
min = _ref$min === void 0 ? -Infinity : _ref$min;
|
|
21
|
-
|
|
19
|
+
// memorized first time prop value
|
|
20
|
+
var defaultState = useDefault(initialState);
|
|
22
21
|
var _useState = useState(defaultState),
|
|
23
22
|
_useState2 = _slicedToArray(_useState, 2),
|
|
24
23
|
_count = _useState2[0],
|
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 } from '../types';
|
|
3
|
-
type Refable<T> = RefCallback<T> | MutableRefObject<T
|
|
4
|
-
export declare const useRefs: <T>(...refs:
|
|
2
|
+
import type { Nullable, Voidable } from '../types';
|
|
3
|
+
type Refable<T> = RefCallback<T> | MutableRefObject<T> | string;
|
|
4
|
+
export declare const useRefs: <T>(...refs: Voidable<Refable<Nullable<T>>>[]) => (trigger: T) => void;
|
|
5
5
|
export {};
|
package/dist/hooks/use-refs.js
CHANGED
|
@@ -6,6 +6,12 @@ var mount = function mount(ref, trigger) {
|
|
|
6
6
|
ref(trigger);
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
+
// in deprecated react, class component can use string ref
|
|
10
|
+
// but there are many problems, in relax, we just make it not work
|
|
11
|
+
// issue for react: https://github.com/facebook/react/pull/8333#issuecomment-271648615
|
|
12
|
+
if (typeof ref === 'string') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
9
15
|
ref.current = trigger;
|
|
10
16
|
};
|
|
11
17
|
var useRefs = function useRefs() {
|