@aiszlab/relax 1.0.21 → 1.0.23

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,6 @@
1
1
  import { useState, useEffect } from 'react';
2
2
  import { isStateGetter } from '../utils/is-state-getter.js';
3
- import { isVoid } from '../utils/is-void.js';
3
+ import { isUndefined } from '../utils/is-undefined.js';
4
4
 
5
5
  /**
6
6
  * @author murukal
@@ -13,8 +13,8 @@ const useControlledState = (controlledState, { defaultState } = {}) => {
13
13
  const [state, setState] = useState(() => {
14
14
  if (isStateGetter(controlledState))
15
15
  return controlledState();
16
- if (isVoid(controlledState)) {
17
- if (isVoid(defaultState))
16
+ if (isUndefined(controlledState)) {
17
+ if (isUndefined(defaultState))
18
18
  return controlledState;
19
19
  if (isStateGetter(defaultState))
20
20
  return defaultState();
@@ -24,7 +24,7 @@ const useControlledState = (controlledState, { defaultState } = {}) => {
24
24
  });
25
25
  useEffect(() => {
26
26
  // when state is not controlled
27
- if (isVoid(controlledState))
27
+ if (isUndefined(controlledState))
28
28
  return;
29
29
  // if state is equal with value
30
30
  if (controlledState === state)
package/dist/index.d.ts CHANGED
@@ -15,5 +15,7 @@ export { useOnceState } from './hooks/use-once-state';
15
15
  * utils
16
16
  */
17
17
  export { isRefable } from './utils/is-refable';
18
- export { isVoid } from './utils/is-void';
18
+ export { isUndefined } from './utils/is-undefined';
19
19
  export { isStateGetter } from './utils/is-state-getter';
20
+ export { isNull } from './utils/is-null';
21
+ export { isVoid } from './utils/is-void';
package/dist/index.js CHANGED
@@ -7,5 +7,7 @@ export { useTimeout } from './hooks/use-timeout.js';
7
7
  export { useControlledState } from './hooks/use-controlled-state.js';
8
8
  export { useOnceState } from './hooks/use-once-state.js';
9
9
  export { isRefable } from './utils/is-refable.js';
10
- export { isVoid } from './utils/is-void.js';
10
+ export { isUndefined } from './utils/is-undefined.js';
11
11
  export { isStateGetter } from './utils/is-state-getter.js';
12
+ export { isNull } from './utils/is-null.js';
13
+ export { isVoid } from './utils/is-void.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @description
3
+ * is null
4
+ */
5
+ export declare const isNull: (value: unknown) => value is null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @description
3
+ * is null
4
+ */
5
+ const isNull = (value) => {
6
+ return value === null;
7
+ };
8
+
9
+ export { isNull };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @description
3
+ * is undefined
4
+ */
5
+ export declare const isUndefined: (value: unknown) => value is undefined;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @description
3
+ * is undefined
4
+ */
5
+ const isUndefined = (value) => {
6
+ return value === void 0;
7
+ };
8
+
9
+ export { isUndefined };
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * @description
3
- * is undefined
3
+ * is null or undefined
4
4
  */
5
- export declare const isVoid: (value: unknown) => value is undefined;
5
+ export declare const isVoid: (value: unknown) => value is null | undefined;
@@ -1,9 +1,12 @@
1
+ import { isUndefined } from './is-undefined.js';
2
+ import { isNull } from './is-null.js';
3
+
1
4
  /**
2
5
  * @description
3
- * is undefined
6
+ * is null or undefined
4
7
  */
5
8
  const isVoid = (value) => {
6
- return value === void 0;
9
+ return isNull(value) || isUndefined(value);
7
10
  };
8
11
 
9
12
  export { isVoid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "react utils collection",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",