@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,6 +1,10 @@
1
1
  import { type Dispatch, type SetStateAction } from 'react';
2
2
  import type { State } from '../types';
3
3
  interface Props<T> {
4
+ /**
5
+ * @description
6
+ * default value
7
+ */
4
8
  defaultState?: State<T>;
5
9
  }
6
10
  /**
@@ -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(initialState) {
13
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
14
- max: Infinity,
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
- var defaultState = useDefault(initialState !== null && initialState !== void 0 ? initialState : 0);
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],
@@ -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: Nullable<Refable<Nullable<T>>>[]) => (trigger: T) => void;
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 {};
@@ -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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.2.48",
3
+ "version": "1.2.50",
4
4
  "description": "react utils collection",
5
5
  "type": "module",
6
6
  "exports": {