@kubed/hooks 0.0.4 → 0.0.5
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/CHANGELOG.md +8 -0
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/useDebouncedValue/index.js +2 -0
- package/cjs/useDebouncedValue/index.js.map +1 -0
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/useDebouncedValue/index.js +2 -0
- package/esm/useDebouncedValue/index.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/useDebouncedValue/index.d.ts +4 -0
- package/lib/useDebouncedValue/index.d.ts.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @kubed/hooks
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f39c7e8`](https://github.com/kubesphere/kube-design/commit/f39c7e8d9550ddd329dc057bf6a737835b738d33) Thanks [@chenz24](https://github.com/chenz24)! - 1. Completely Refactor Empty component.
|
|
8
|
+
2. Add useDebouncedValue hook.
|
|
9
|
+
3. Reset default props for LoadingOverlay.
|
|
10
|
+
|
|
3
11
|
## 0.0.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$e=require("./utils/index.js"),index=require("./useId/index.js"),index$1=require("./useToggle/index.js"),index$2=require("./useUncontrolled/index.js"),index$3=require("./useMediaQuery/index.js"),index$4=require("./useReducedMotion/index.js"),index$5=require("./useWindowEvent/index.js"),index$6=require("./useLocalStorage/index.js"),index$7=require("./useForceUpdate/index.js"),index$8=require("./useClipboard/index.js"),index$9=require("./useQueue/index.js"),index$a=require("./useClickOutside/index.js"),index$b=require("./useMove/index.js"),index$c=require("./useHotkeys/index.js"),index$d=require("./useDebouncedValue/index.js");exports.clamp=index$e.clamp,exports.randomId=index$e.randomId,exports.useId=index.useId,exports.useBooleanToggle=index$1.useBooleanToggle,exports.useToggle=index$1.useToggle,exports.useUncontrolled=index$2.useUncontrolled,exports.useMediaQuery=index$3.useMediaQuery,exports.useReducedMotion=index$4.useReducedMotion,exports.useWindowEvent=index$5.useWindowEvent,exports.useLocalStorage=index$6.useLocalStorage,exports.useForceUpdate=index$7.useForceUpdate,exports.useClipboard=index$8.useClipboard,exports.useQueue=index$9.useQueue,exports.useClickOutside=index$a.useClickOutside,exports.useMove=index$b.useMove,exports.useHotkeys=index$c.useHotkeys,exports.useDebouncedValue=index$d.useDebouncedValue;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDebouncedValue(e,o,r={leading:!1}){const[f,n]=react.useState(e),c=react.useRef(!1),s=react.useRef(null),t=react.useRef(!1),u=()=>window.clearTimeout(s.current);return react.useEffect(()=>{c.current&&(!t.current&&r.leading?(t.current=!0,n(e)):(u(),s.current=window.setTimeout(()=>{t.current=!1,n(e)},o)))},[e,r.leading]),react.useEffect(()=>(c.current=!0,u),[]),[f,u]}exports.useDebouncedValue=useDebouncedValue;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useDebouncedValue/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-debounced-value/use-debounced-value.ts\nimport { useEffect, useState, useRef } from 'react';\n\nexport function useDebouncedValue<T = any>(value: T, wait: number, options = { leading: false }) {\n const [_value, setValue] = useState(value);\n const mountedRef = useRef(false);\n const timeoutRef = useRef<number>(null);\n const cooldownRef = useRef(false);\n\n const cancel = () => window.clearTimeout(timeoutRef.current);\n\n useEffect(() => {\n if (mountedRef.current) {\n if (!cooldownRef.current && options.leading) {\n cooldownRef.current = true;\n setValue(value);\n } else {\n cancel();\n timeoutRef.current = window.setTimeout(() => {\n cooldownRef.current = false;\n setValue(value);\n }, wait);\n }\n }\n }, [value, options.leading]);\n\n useEffect(() => {\n mountedRef.current = true;\n return cancel;\n }, []);\n\n return [_value, cancel] as const;\n}\n"],"names":["useState","useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;AAC7E,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,CAAC;AAC7C,EAAE,MAAM,UAAU,GAAGC,YAAM,CAAC,KAAK,CAAC,CAAC;AACnC,EAAE,MAAM,UAAU,GAAGA,YAAM,CAAC,IAAI,CAAC,CAAC;AAClC,EAAE,MAAM,WAAW,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AACpC,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC/D,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;AAC5B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;AACnD,QAAQ,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,QAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxB,OAAO,MAAM;AACb,QAAQ,MAAM,EAAE,CAAC;AACjB,QAAQ,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM;AACrD,UAAU,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;AACtC,UAAU,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAS,EAAE,IAAI,CAAC,CAAC;AACjB,OAAO;AACP,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/B,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;AAC9B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{clamp,randomId}from"./utils/index.js";export{useId}from"./useId/index.js";export{useBooleanToggle,useToggle}from"./useToggle/index.js";export{useUncontrolled}from"./useUncontrolled/index.js";export{useMediaQuery}from"./useMediaQuery/index.js";export{useReducedMotion}from"./useReducedMotion/index.js";export{useWindowEvent}from"./useWindowEvent/index.js";export{useLocalStorage}from"./useLocalStorage/index.js";export{useForceUpdate}from"./useForceUpdate/index.js";export{useClipboard}from"./useClipboard/index.js";export{useQueue}from"./useQueue/index.js";export{useClickOutside}from"./useClickOutside/index.js";export{useMove}from"./useMove/index.js";export{useHotkeys}from"./useHotkeys/index.js";
|
|
1
|
+
export{clamp,randomId}from"./utils/index.js";export{useId}from"./useId/index.js";export{useBooleanToggle,useToggle}from"./useToggle/index.js";export{useUncontrolled}from"./useUncontrolled/index.js";export{useMediaQuery}from"./useMediaQuery/index.js";export{useReducedMotion}from"./useReducedMotion/index.js";export{useWindowEvent}from"./useWindowEvent/index.js";export{useLocalStorage}from"./useLocalStorage/index.js";export{useForceUpdate}from"./useForceUpdate/index.js";export{useClipboard}from"./useClipboard/index.js";export{useQueue}from"./useQueue/index.js";export{useClickOutside}from"./useClickOutside/index.js";export{useMove}from"./useMove/index.js";export{useHotkeys}from"./useHotkeys/index.js";export{useDebouncedValue}from"./useDebouncedValue/index.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useState as i,useRef as r,useEffect as f}from"react";function d(e,l,u={leading:!1}){const[a,c]=i(e),o=r(!1),s=r(null),t=r(!1),n=()=>window.clearTimeout(s.current);return f(()=>{o.current&&(!t.current&&u.leading?(t.current=!0,c(e)):(n(),s.current=window.setTimeout(()=>{t.current=!1,c(e)},l)))},[e,u.leading]),f(()=>(o.current=!0,n),[]),[a,n]}export{d as useDebouncedValue};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useDebouncedValue/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-debounced-value/use-debounced-value.ts\nimport { useEffect, useState, useRef } from 'react';\n\nexport function useDebouncedValue<T = any>(value: T, wait: number, options = { leading: false }) {\n const [_value, setValue] = useState(value);\n const mountedRef = useRef(false);\n const timeoutRef = useRef<number>(null);\n const cooldownRef = useRef(false);\n\n const cancel = () => window.clearTimeout(timeoutRef.current);\n\n useEffect(() => {\n if (mountedRef.current) {\n if (!cooldownRef.current && options.leading) {\n cooldownRef.current = true;\n setValue(value);\n } else {\n cancel();\n timeoutRef.current = window.setTimeout(() => {\n cooldownRef.current = false;\n setValue(value);\n }, wait);\n }\n }\n }, [value, options.leading]);\n\n useEffect(() => {\n mountedRef.current = true;\n return cancel;\n }, []);\n\n return [_value, cancel] as const;\n}\n"],"names":[],"mappings":";;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;AAC7E,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7C,EAAE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,EAAE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAClC,EAAE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC/D,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;AAC5B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;AACnD,QAAQ,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,QAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxB,OAAO,MAAM;AACb,QAAQ,MAAM,EAAE,CAAC;AACjB,QAAQ,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM;AACrD,UAAU,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;AACtC,UAAU,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAS,EAAE,IAAI,CAAC,CAAC;AACjB,OAAO;AACP,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/B,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;AAC9B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B;;;;"}
|
package/lib/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export { useQueue } from './useQueue';
|
|
|
12
12
|
export { useClickOutside } from './useClickOutside';
|
|
13
13
|
export { useMove } from './useMove';
|
|
14
14
|
export { useHotkeys } from './useHotkeys';
|
|
15
|
+
export { useDebouncedValue } from './useDebouncedValue';
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDebouncedValue/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO;;CAAqB,4BA6B9F"}
|