@kubed/hooks 0.0.3 → 0.0.4
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 +7 -0
- package/cjs/index.js +1 -30
- package/cjs/index.js.map +1 -1
- package/cjs/useClickOutside/index.js +2 -0
- package/cjs/useClickOutside/index.js.map +1 -0
- package/cjs/useClipboard/index.js +1 -31
- package/cjs/useForceUpdate/index.js +1 -13
- package/cjs/useHotkeys/index.js +2 -0
- package/cjs/useHotkeys/index.js.map +1 -0
- package/cjs/useHotkeys/parseHotkey.js +2 -0
- package/cjs/useHotkeys/parseHotkey.js.map +1 -0
- package/cjs/useId/index.js +1 -13
- package/cjs/useLocalStorage/index.js +1 -38
- package/cjs/useMediaQuery/index.js +1 -35
- package/cjs/useMove/index.js +2 -0
- package/cjs/useMove/index.js.map +1 -0
- package/cjs/useQueue/index.js +1 -36
- package/cjs/useReducedMotion/index.js +1 -11
- package/cjs/useToggle/index.js +1 -28
- package/cjs/useUncontrolled/index.js +1 -40
- package/cjs/useWindowEvent/index.js +1 -14
- package/cjs/utils/index.js +1 -9
- package/cjs/utils/index.js.map +1 -1
- package/esm/index.js +1 -11
- package/esm/index.js.map +1 -1
- package/esm/useClickOutside/index.js +2 -0
- package/esm/useClickOutside/index.js.map +1 -0
- package/esm/useClipboard/index.js +1 -27
- package/esm/useForceUpdate/index.js +1 -9
- package/esm/useHotkeys/index.js +2 -0
- package/esm/useHotkeys/index.js.map +1 -0
- package/esm/useHotkeys/parseHotkey.js +2 -0
- package/esm/useHotkeys/parseHotkey.js.map +1 -0
- package/esm/useId/index.js +1 -9
- package/esm/useLocalStorage/index.js +1 -34
- package/esm/useMediaQuery/index.js +1 -31
- package/esm/useMove/index.js +2 -0
- package/esm/useMove/index.js.map +1 -0
- package/esm/useQueue/index.js +1 -32
- package/esm/useReducedMotion/index.js +1 -7
- package/esm/useToggle/index.js +1 -23
- package/esm/useUncontrolled/index.js +1 -36
- package/esm/useWindowEvent/index.js +1 -10
- package/esm/utils/index.js +1 -5
- package/esm/utils/index.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/useClickOutside/index.d.ts +3 -0
- package/lib/useClickOutside/index.d.ts.map +1 -0
- package/lib/useHotkeys/index.d.ts +5 -0
- package/lib/useHotkeys/index.d.ts.map +1 -0
- package/lib/useHotkeys/parseHotkey.d.ts +18 -0
- package/lib/useHotkeys/parseHotkey.d.ts.map +1 -0
- package/lib/useMove/index.d.ts +19 -0
- package/lib/useMove/index.d.ts.map +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @kubed/hooks
|
|
2
2
|
|
|
3
|
+
## 0.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`bf37ccc`](https://github.com/kubesphere/kube-design/commit/bf37cccbf64598b67b6e599b61c9d4ed33ec8504) Thanks [@chenz24](https://github.com/chenz24)! - 1. Add hotkey hook.
|
|
8
|
+
2. Fix Banner cannot set className
|
|
9
|
+
|
|
3
10
|
## 0.0.3
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/cjs/index.js
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index$a = require('./utils/index.js');
|
|
6
|
-
var index = require('./useId/index.js');
|
|
7
|
-
var index$1 = require('./useToggle/index.js');
|
|
8
|
-
var index$2 = require('./useUncontrolled/index.js');
|
|
9
|
-
var index$3 = require('./useMediaQuery/index.js');
|
|
10
|
-
var index$4 = require('./useReducedMotion/index.js');
|
|
11
|
-
var index$5 = require('./useWindowEvent/index.js');
|
|
12
|
-
var index$6 = require('./useLocalStorage/index.js');
|
|
13
|
-
var index$7 = require('./useForceUpdate/index.js');
|
|
14
|
-
var index$8 = require('./useClipboard/index.js');
|
|
15
|
-
var index$9 = require('./useQueue/index.js');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.randomId = index$a.randomId;
|
|
20
|
-
exports.useId = index.useId;
|
|
21
|
-
exports.useBooleanToggle = index$1.useBooleanToggle;
|
|
22
|
-
exports.useToggle = index$1.useToggle;
|
|
23
|
-
exports.useUncontrolled = index$2.useUncontrolled;
|
|
24
|
-
exports.useMediaQuery = index$3.useMediaQuery;
|
|
25
|
-
exports.useReducedMotion = index$4.useReducedMotion;
|
|
26
|
-
exports.useWindowEvent = index$5.useWindowEvent;
|
|
27
|
-
exports.useLocalStorage = index$6.useLocalStorage;
|
|
28
|
-
exports.useForceUpdate = index$7.useForceUpdate;
|
|
29
|
-
exports.useClipboard = index$8.useClipboard;
|
|
30
|
-
exports.useQueue = index$9.useQueue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$d=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");exports.clamp=index$d.clamp,exports.randomId=index$d.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;
|
|
31
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");const DEFAULT_EVENTS=["mousedown","touchstart"];function useClickOutside(t,u,s){const r=react.useRef();return react.useEffect(()=>{const c=e=>{Array.isArray(s)?s.every(i=>!!i&&!i.contains(e.target))&&t():r.current&&!r.current.contains(e.target)&&t()};return(u||DEFAULT_EVENTS).forEach(e=>document.addEventListener(e,c)),()=>{(u||DEFAULT_EVENTS).forEach(e=>document.removeEventListener(e,c))}},[r,t,s]),r}exports.useClickOutside=useClickOutside;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T>();\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };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
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function useClipboard({ timeout = 2e3 } = {}) {
|
|
8
|
-
const [error, setError] = react.useState(null);
|
|
9
|
-
const [copied, setCopied] = react.useState(false);
|
|
10
|
-
const [copyTimeout, setCopyTimeout] = react.useState(null);
|
|
11
|
-
const handleCopyResult = (value) => {
|
|
12
|
-
clearTimeout(copyTimeout);
|
|
13
|
-
setCopyTimeout(setTimeout(() => setCopied(false), timeout));
|
|
14
|
-
setCopied(value);
|
|
15
|
-
};
|
|
16
|
-
const copy = (valueToCopy) => {
|
|
17
|
-
if ("clipboard" in navigator) {
|
|
18
|
-
navigator.clipboard.writeText(valueToCopy).then(() => handleCopyResult(true)).catch((err) => setError(err));
|
|
19
|
-
} else {
|
|
20
|
-
setError(new Error("useClipboard: navigator.clipboard is not supported"));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const reset = () => {
|
|
24
|
-
setCopied(false);
|
|
25
|
-
setError(null);
|
|
26
|
-
clearTimeout(copyTimeout);
|
|
27
|
-
};
|
|
28
|
-
return { copy, reset, error, copied };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.useClipboard = useClipboard;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useClipboard({timeout:s=2e3}={}){const[a,e]=react.useState(null),[i,t]=react.useState(!1),[o,u]=react.useState(null),c=r=>{clearTimeout(o),u(setTimeout(()=>t(!1),s)),t(r)};return{copy:r=>{"clipboard"in navigator?navigator.clipboard.writeText(r).then(()=>c(!0)).catch(l=>e(l)):e(new Error("useClipboard: navigator.clipboard is not supported"))},reset:()=>{t(!1),e(null),clearTimeout(o)},error:a,copied:i}}exports.useClipboard=useClipboard;
|
|
32
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
const reducer = (value) => (value + 1) % 1e6;
|
|
8
|
-
function useForceUpdate() {
|
|
9
|
-
const [, update] = react.useReducer(reducer, 0);
|
|
10
|
-
return update;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
exports.useForceUpdate = useForceUpdate;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const reducer=e=>(e+1)%1e6;function useForceUpdate(){const[,e]=react.useReducer(reducer,0);return e}exports.useForceUpdate=useForceUpdate;
|
|
14
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),parseHotkey=require("./parseHotkey.js");function useHotkeys(t){react.useEffect(()=>{const r=e=>{t.forEach(([o,n])=>{parseHotkey.getHotkeyMatcher(o)(e)&&(e.preventDefault(),n(e))})};return document.documentElement.addEventListener("keydown",r),()=>document.documentElement.removeEventListener("keydown",r)},[t])}exports.useHotkeys=useHotkeys;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useHotkeys/index.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { getHotkeyMatcher, getHotkeyHandler } from './parseHotkey';\n\nexport { getHotkeyHandler };\n\ntype HokeyItem = [string, (event: KeyboardEvent) => void];\n\nexport function useHotkeys(hotkeys: HokeyItem[]) {\n useEffect(() => {\n const keydownListener = (event: KeyboardEvent) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n\n document.documentElement.addEventListener('keydown', keydownListener);\n return () => document.documentElement.removeEventListener('keydown', keydownListener);\n }, [hotkeys]);\n}\n"],"names":["useEffect","getHotkeyMatcher"],"mappings":";;;;;;;AAGO,SAAS,UAAU,CAAC,OAAO,EAAE;AACpC,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,eAAe,GAAG,CAAC,KAAK,KAAK;AACvC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;AAC7C,QAAQ,IAAIC,4BAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;AAC7C,UAAU,KAAK,CAAC,cAAc,EAAE,CAAC;AACjC,UAAU,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,SAAS;AACT,OAAO,CAAC,CAAC;AACT,KAAK,CAAC;AACN,IAAI,QAAQ,CAAC,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1E,IAAI,OAAO,MAAM,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1F,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));function parseHotkey(r){const e=r.toLowerCase().split("+").map(s=>s.trim()),t={alt:e.includes("alt"),ctrl:e.includes("ctrl"),meta:e.includes("meta"),mod:e.includes("mod"),shift:e.includes("shift")},o=["alt","ctrl","meta","shift","mod"],a=e.find(s=>!o.includes(s));return __spreadProps(__spreadValues({},t),{key:a})}function isExactHotkey(r,e){const{alt:t,ctrl:o,meta:a,mod:s,shift:l,key:n}=r,{altKey:f,ctrlKey:i,metaKey:c,shiftKey:p,key:u}=e;if(t!==f)return!1;if(s){if(!i&&!c)return!1}else if(o!==i||a!==c)return!1;return l!==p?!1:!!(n&&(u.toLowerCase()===n.toLowerCase()||e.code.replace("Key","").toLowerCase()===n.toLowerCase()))}function getHotkeyMatcher(r){return e=>isExactHotkey(parseHotkey(r),e)}exports.getHotkeyMatcher=getHotkeyMatcher,exports.parseHotkey=parseHotkey;
|
|
2
|
+
//# sourceMappingURL=parseHotkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHotkey.js","sources":["../../src/useHotkeys/parseHotkey.ts"],"sourcesContent":["export type KeyboardModifiers = {\n alt: boolean;\n ctrl: boolean;\n meta: boolean;\n mod: boolean;\n shift: boolean;\n};\n\nexport type Hotkey = KeyboardModifiers & {\n key?: string;\n};\n\ntype CheckHotkeyMatch = (event: KeyboardEvent) => boolean;\n\nexport function parseHotkey(hotkey: string): Hotkey {\n const keys = hotkey\n .toLowerCase()\n .split('+')\n .map((part) => part.trim());\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n shift: keys.includes('shift'),\n };\n\n const reservedKeys = ['alt', 'ctrl', 'meta', 'shift', 'mod'];\n\n const freeKey = keys.find((key) => !reservedKeys.includes(key));\n\n return {\n ...modifiers,\n key: freeKey,\n };\n}\n\nfunction isExactHotkey(hotkey: Hotkey, event: KeyboardEvent): boolean {\n const { alt, ctrl, meta, mod, shift, key } = hotkey;\n const { altKey, ctrlKey, metaKey, shiftKey, key: pressedKey } = event;\n\n if (alt !== altKey) {\n return false;\n }\n\n if (mod) {\n if (!ctrlKey && !metaKey) {\n return false;\n }\n } else {\n if (ctrl !== ctrlKey) {\n return false;\n }\n if (meta !== metaKey) {\n return false;\n }\n }\n if (shift !== shiftKey) {\n return false;\n }\n\n if (\n key &&\n (pressedKey.toLowerCase() === key.toLowerCase() ||\n event.code.replace('Key', '').toLowerCase() === key.toLowerCase())\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function getHotkeyMatcher(hotkey: string): CheckHotkeyMatch {\n return (event) => isExactHotkey(parseHotkey(hotkey), event);\n}\n\ntype HotkeyItem = [string, (event: React.KeyboardEvent<HTMLElement>) => void];\n\nexport function getHotkeyHandler(hotkeys: HotkeyItem[]) {\n return (event: React.KeyboardEvent<HTMLElement>) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event.nativeEvent)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n}\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GA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,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE;AACpI,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf,CAAC;AACM,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC,EAAE,OAAO,CAAC,KAAK,KAAK,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9D;;;;;"}
|
package/cjs/useId/index.js
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var index = require('../utils/index.js');
|
|
7
|
-
|
|
8
|
-
function useId(id, generateId = index.randomId) {
|
|
9
|
-
const generatedId = react.useRef(generateId());
|
|
10
|
-
return id || generatedId.current;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
exports.useId = useId;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../utils/index.js");function useId(e,r=index.randomId){const t=react.useRef(r());return e||t.current}exports.useId=useId;
|
|
14
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,39 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var index = require('../useWindowEvent/index.js');
|
|
7
|
-
|
|
8
|
-
function useLocalStorage({
|
|
9
|
-
key,
|
|
10
|
-
defaultValue = void 0
|
|
11
|
-
}) {
|
|
12
|
-
const [value, setValue] = react.useState(typeof window !== "undefined" && "localStorage" in window ? window.localStorage.getItem(key) : defaultValue != null ? defaultValue : "");
|
|
13
|
-
const setLocalStorageValue = react.useCallback((val) => {
|
|
14
|
-
if (typeof val === "function") {
|
|
15
|
-
setValue((current) => {
|
|
16
|
-
const result = val(current);
|
|
17
|
-
window.localStorage.setItem(key, result);
|
|
18
|
-
return result;
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
window.localStorage.setItem(key, val);
|
|
22
|
-
setValue(val);
|
|
23
|
-
}
|
|
24
|
-
}, [key]);
|
|
25
|
-
index.useWindowEvent("storage", (event) => {
|
|
26
|
-
if (event.storageArea === window.localStorage && event.key === key) {
|
|
27
|
-
setValue(event.newValue);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
react.useEffect(() => {
|
|
31
|
-
if (defaultValue && !value) {
|
|
32
|
-
setLocalStorageValue(defaultValue);
|
|
33
|
-
}
|
|
34
|
-
}, [defaultValue, value, setLocalStorageValue]);
|
|
35
|
-
return [value, setLocalStorageValue];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
exports.useLocalStorage = useLocalStorage;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../useWindowEvent/index.js");function useLocalStorage({key:o,defaultValue:t=void 0}){const[r,n]=react.useState(typeof window!="undefined"&&"localStorage"in window?window.localStorage.getItem(o):t!=null?t:""),s=react.useCallback(e=>{typeof e=="function"?n(a=>{const i=e(a);return window.localStorage.setItem(o,i),i}):(window.localStorage.setItem(o,e),n(e))},[o]);return index.useWindowEvent("storage",e=>{e.storageArea===window.localStorage&&e.key===o&&n(e.newValue)}),react.useEffect(()=>{t&&!r&&s(t)},[t,r,s]),[r,s]}exports.useLocalStorage=useLocalStorage;
|
|
39
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function attachMediaListener(query, callback) {
|
|
8
|
-
try {
|
|
9
|
-
query.addEventListener("change", callback);
|
|
10
|
-
return () => query.removeEventListener("change", callback);
|
|
11
|
-
} catch (e) {
|
|
12
|
-
query.addListener(callback);
|
|
13
|
-
return () => query.removeListener(callback);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function getInitialValue(query) {
|
|
17
|
-
if (typeof window !== "undefined" && "matchMedia" in window) {
|
|
18
|
-
return window.matchMedia(query).matches;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
function useMediaQuery(query) {
|
|
23
|
-
const [matches, setMatches] = react.useState(getInitialValue(query));
|
|
24
|
-
const queryRef = react.useRef();
|
|
25
|
-
react.useEffect(() => {
|
|
26
|
-
if ("matchMedia" in window) {
|
|
27
|
-
queryRef.current = window.matchMedia(query);
|
|
28
|
-
setMatches(queryRef.current.matches);
|
|
29
|
-
return attachMediaListener(queryRef.current, (event) => setMatches(event.matches));
|
|
30
|
-
}
|
|
31
|
-
}, [query]);
|
|
32
|
-
return matches;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.useMediaQuery = useMediaQuery;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function attachMediaListener(e,t){try{return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}catch(n){return e.addListener(t),()=>e.removeListener(t)}}function getInitialValue(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function useMediaQuery(e){const[t,n]=react.useState(getInitialValue(e)),r=react.useRef();return react.useEffect(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),n(r.current.matches),attachMediaListener(r.current,i=>n(i.matches))},[e]),t}exports.useMediaQuery=useMediaQuery;
|
|
36
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../utils/index.js");function useMove(E,n){const t=react.useRef(),u=react.useRef(!1),o=react.useRef(!1),d=react.useRef(0),[h,m]=react.useState(!1);return react.useEffect(()=>{u.current=!0},[]),react.useEffect(()=>{const a=({x:e,y:b})=>{cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{if(u.current&&t.current){t.current.style.userSelect="none";const r=t.current.getBoundingClientRect();r.width&&r.height&&E({x:index.clamp({value:(e-r.left)/r.width,min:0,max:1}),y:index.clamp({value:(b-r.top)/r.height,min:0,max:1})})}})},p=()=>{document.addEventListener("mousemove",s),document.addEventListener("mouseup",c),document.addEventListener("touchmove",i),document.addEventListener("touchend",c)},S=()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",c),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",c)},v=()=>{!o.current&&u.current&&(o.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),m(!0),p())},c=()=>{o.current&&u.current&&(o.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),m(!1),S())},f=e=>{v(),s(e)},s=e=>a({x:e.clientX,y:e.clientY}),l=e=>{v(),e==null||e.preventDefault(),i(e)},i=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",f),t.current.addEventListener("touchstart",l),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",l))}},[t.current]),{ref:t,active:h}}exports.useMove=useMove;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useMove/index.tsx"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-move/use-move.ts\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useEffect, useState, useRef } from 'react';\nimport { clamp } from '../utils';\n\nexport interface UseMovePosition {\n x: number;\n y: number;\n}\n\nexport const clampUseMovePosition = (position: UseMovePosition) => ({\n x: clamp({ min: 0, max: 1, value: position.x }),\n y: clamp({ min: 0, max: 1, value: position.y }),\n});\n\ninterface useMoveHandlers {\n onScrubStart?(): void;\n onScrubEnd?(): void;\n}\n\nexport function useMove<T extends HTMLElement = HTMLDivElement>(\n onChange: (value: UseMovePosition) => void,\n handlers?: useMoveHandlers\n) {\n const ref = useRef<T>();\n const mounted = useRef<boolean>(false);\n const isSliding = useRef(false);\n const frame = useRef(0);\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n mounted.current = true;\n }, []);\n\n useEffect(() => {\n const onScrub = ({ x, y }: UseMovePosition) => {\n cancelAnimationFrame(frame.current);\n\n frame.current = requestAnimationFrame(() => {\n if (mounted.current && ref.current) {\n ref.current.style.userSelect = 'none';\n const rect = ref.current.getBoundingClientRect();\n\n if (rect.width && rect.height) {\n onChange({\n x: clamp({ value: (x - rect.left) / rect.width, min: 0, max: 1 }),\n y: clamp({ value: (y - rect.top) / rect.height, min: 0, max: 1 }),\n });\n }\n }\n });\n };\n\n const bindEvents = () => {\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', stopScrubbing);\n document.addEventListener('touchmove', onTouchMove);\n document.addEventListener('touchend', stopScrubbing);\n };\n\n const unbindEvents = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', stopScrubbing);\n document.removeEventListener('touchmove', onTouchMove);\n document.removeEventListener('touchend', stopScrubbing);\n };\n\n const startScrubbing = () => {\n if (!isSliding.current && mounted.current) {\n isSliding.current = true;\n typeof handlers?.onScrubStart === 'function' && handlers.onScrubStart();\n setActive(true);\n bindEvents();\n }\n };\n\n const stopScrubbing = () => {\n if (isSliding.current && mounted.current) {\n isSliding.current = false;\n typeof handlers?.onScrubEnd === 'function' && handlers.onScrubEnd();\n setActive(false);\n unbindEvents();\n }\n };\n\n const onMouseDown = (event: MouseEvent) => {\n startScrubbing();\n onMouseMove(event);\n };\n\n const onMouseMove = (event: MouseEvent) => onScrub({ x: event.clientX, y: event.clientY });\n\n const onTouchStart = (event: TouchEvent) => {\n startScrubbing();\n event?.preventDefault();\n onTouchMove(event);\n };\n\n const onTouchMove = (event: TouchEvent) => {\n event?.preventDefault();\n onScrub({ x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY });\n };\n\n ref.current.addEventListener('mousedown', onMouseDown);\n ref.current.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener('mousedown', onMouseDown);\n ref.current.removeEventListener('touchstart', onTouchStart);\n }\n };\n }, [ref.current]);\n\n return { ref, active };\n}\n"],"names":["useRef","useState","useEffect","clamp"],"mappings":";;;;;;;AAMO,SAAS,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE;AAC5C,EAAE,MAAM,GAAG,GAAGA,YAAM,EAAE,CAAC;AACvB,EAAE,MAAM,OAAO,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAE,MAAM,SAAS,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AAClC,EAAE,MAAM,KAAK,GAAGA,YAAM,CAAC,CAAC,CAAC,CAAC;AAC1B,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAC;AAC9C,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAC3B,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK;AAClC,MAAM,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1C,MAAM,KAAK,CAAC,OAAO,GAAG,qBAAqB,CAAC,MAAM;AAClD,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,EAAE;AAC5C,UAAU,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC;AAChD,UAAU,MAAM,IAAI,GAAG,GAAG,CA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C,cAAc,EAAE,CAAC;AACtD,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC;AACzB,KAAK,CAAC;AACN,IAAI,MAAM,WAAW,GAAG,CAAC,KAAK,KAAK;AACnC,MAAM,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;AACtD,MAAM,OAAO,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1F,KAAK,CAAC;AACN,IAAI,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC3D,IAAI,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAC7D,IAAI,OAAO,MAAM;AACjB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE;AACvB,QAAQ,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAClE,QAAQ,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AACpE,OAAO;AACP,KAAK,CAAC;AACN,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACpB,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB;;;;"}
|
package/cjs/useQueue/index.js
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function useQueue({ initialValues = [], limit }) {
|
|
8
|
-
const [{ state, queue }, setState] = react.useState({
|
|
9
|
-
state: initialValues.slice(0, limit),
|
|
10
|
-
queue: initialValues.slice(limit)
|
|
11
|
-
});
|
|
12
|
-
const add = (...items) => setState((current) => {
|
|
13
|
-
const results = [...current.state, ...current.queue, ...items];
|
|
14
|
-
return {
|
|
15
|
-
state: results.slice(0, limit),
|
|
16
|
-
queue: results.slice(limit)
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
const update = (fn) => setState((current) => {
|
|
20
|
-
const results = fn([...current.state, ...current.queue]);
|
|
21
|
-
return {
|
|
22
|
-
state: results.slice(0, limit),
|
|
23
|
-
queue: results.slice(limit)
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
const cleanQueue = () => setState((current) => ({ state: current.state, queue: [] }));
|
|
27
|
-
return {
|
|
28
|
-
state,
|
|
29
|
-
queue,
|
|
30
|
-
add,
|
|
31
|
-
update,
|
|
32
|
-
cleanQueue
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.useQueue = useQueue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useQueue({initialValues:c=[],limit:e}){const[{state:r,queue:n},a]=react.useState({state:c.slice(0,e),queue:c.slice(e)});return{state:r,queue:n,add:(...t)=>a(u=>{const s=[...u.state,...u.queue,...t];return{state:s.slice(0,e),queue:s.slice(e)}}),update:t=>a(u=>{const s=t([...u.state,...u.queue]);return{state:s.slice(0,e),queue:s.slice(e)}}),cleanQueue:()=>a(t=>({state:t.state,queue:[]}))}}exports.useQueue=useQueue;
|
|
37
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index = require('../useMediaQuery/index.js');
|
|
6
|
-
|
|
7
|
-
function useReducedMotion() {
|
|
8
|
-
return index.useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
exports.useReducedMotion = useReducedMotion;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index=require("../useMediaQuery/index.js");function useReducedMotion(){return index.useMediaQuery("(prefers-reduced-motion: reduce)")}exports.useReducedMotion=useReducedMotion;
|
|
12
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/useToggle/index.js
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function useToggle(initialValue, options) {
|
|
8
|
-
const [state, setState] = react.useState(initialValue);
|
|
9
|
-
const toggle = (value) => {
|
|
10
|
-
if (typeof value !== "undefined") {
|
|
11
|
-
setState(value);
|
|
12
|
-
} else {
|
|
13
|
-
setState((current) => {
|
|
14
|
-
if (current === options[0]) {
|
|
15
|
-
return options[1];
|
|
16
|
-
}
|
|
17
|
-
return options[0];
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
return [state, toggle];
|
|
22
|
-
}
|
|
23
|
-
function useBooleanToggle(initialValue = false) {
|
|
24
|
-
return useToggle(initialValue, [true, false]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.useBooleanToggle = useBooleanToggle;
|
|
28
|
-
exports.useToggle = useToggle;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useToggle(e,t){const[o,r]=react.useState(e);return[o,u=>{typeof u!="undefined"?r(u):r(s=>s===t[0]?t[1]:t[0])}]}function useBooleanToggle(e=!1){return useToggle(e,[!0,!1])}exports.useBooleanToggle=useBooleanToggle,exports.useToggle=useToggle;
|
|
29
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function useUncontrolled({
|
|
8
|
-
value,
|
|
9
|
-
defaultValue,
|
|
10
|
-
finalValue,
|
|
11
|
-
rule,
|
|
12
|
-
onChange,
|
|
13
|
-
onValueUpdate
|
|
14
|
-
}) {
|
|
15
|
-
const shouldBeControlled = rule(value);
|
|
16
|
-
const modeRef = react.useRef("initial");
|
|
17
|
-
const initialValue = rule(defaultValue) ? defaultValue : finalValue;
|
|
18
|
-
const [uncontrolledValue, setUncontrolledValue] = react.useState(initialValue);
|
|
19
|
-
let effectiveValue = shouldBeControlled ? value : uncontrolledValue;
|
|
20
|
-
if (!shouldBeControlled && modeRef.current === "controlled") {
|
|
21
|
-
effectiveValue = finalValue;
|
|
22
|
-
}
|
|
23
|
-
modeRef.current = shouldBeControlled ? "controlled" : "uncontrolled";
|
|
24
|
-
const mode = modeRef.current;
|
|
25
|
-
const handleChange = (nextValue) => {
|
|
26
|
-
typeof onChange === "function" && onChange(nextValue);
|
|
27
|
-
if (mode === "uncontrolled") {
|
|
28
|
-
setUncontrolledValue(nextValue);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
react.useEffect(() => {
|
|
32
|
-
if (mode === "uncontrolled") {
|
|
33
|
-
setUncontrolledValue(effectiveValue);
|
|
34
|
-
}
|
|
35
|
-
typeof onValueUpdate === "function" && onValueUpdate(effectiveValue);
|
|
36
|
-
}, [mode, effectiveValue]);
|
|
37
|
-
return [effectiveValue, handleChange, modeRef.current];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.useUncontrolled = useUncontrolled;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useUncontrolled({value:r,defaultValue:c,finalValue:l,rule:u,onChange:s,onValueUpdate:i}){const o=u(r),t=react.useRef("initial"),a=u(c)?c:l,[p,d]=react.useState(a);let e=o?r:p;!o&&t.current==="controlled"&&(e=l),t.current=o?"controlled":"uncontrolled";const n=t.current,y=f=>{typeof s=="function"&&s(f),n==="uncontrolled"&&d(f)};return react.useEffect(()=>{n==="uncontrolled"&&d(e),typeof i=="function"&&i(e)},[n,e]),[e,y,t.current]}exports.useUncontrolled=useUncontrolled;
|
|
41
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function useWindowEvent(type, listener, options) {
|
|
8
|
-
react.useEffect(() => {
|
|
9
|
-
window.addEventListener(type, listener, options);
|
|
10
|
-
return () => window.removeEventListener(type, listener, options);
|
|
11
|
-
}, []);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
exports.useWindowEvent = useWindowEvent;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useWindowEvent(e,r,t){react.useEffect(()=>(window.addEventListener(e,r,t),()=>window.removeEventListener(e,r,t)),[])}exports.useWindowEvent=useWindowEvent;
|
|
15
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/utils/index.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function randomId() {
|
|
6
|
-
return `kubed-${Math.random().toString(36).substr(2, 9)}`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
exports.randomId = randomId;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function randomId(){return`kubed-${Math.random().toString(36).substr(2,9)}`}function clamp({value:t,min:r,max:e}){return Math.min(Math.max(t,r),e)}exports.clamp=clamp,exports.randomId=randomId;
|
|
10
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["export function randomId() {\n return `kubed-${Math.random().toString(36).substr(2, 9)}`;\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["export function randomId() {\n return `kubed-${Math.random().toString(36).substr(2, 9)}`;\n}\n\ninterface Clamp {\n value: number;\n min: number;\n max: number;\n}\n\nexport function clamp({ value, min, max }: Clamp) {\n return Math.min(Math.max(value, min), max);\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AACM,SAAS,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;AAC3C,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7C;;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { useId } from './useId/index.js';
|
|
3
|
-
export { useBooleanToggle, useToggle } from './useToggle/index.js';
|
|
4
|
-
export { useUncontrolled } from './useUncontrolled/index.js';
|
|
5
|
-
export { useMediaQuery } from './useMediaQuery/index.js';
|
|
6
|
-
export { useReducedMotion } from './useReducedMotion/index.js';
|
|
7
|
-
export { useWindowEvent } from './useWindowEvent/index.js';
|
|
8
|
-
export { useLocalStorage } from './useLocalStorage/index.js';
|
|
9
|
-
export { useForceUpdate } from './useForceUpdate/index.js';
|
|
10
|
-
export { useClipboard } from './useClipboard/index.js';
|
|
11
|
-
export { useQueue } from './useQueue/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";
|
|
12
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{useRef as i,useEffect as f}from"react";const u=["mousedown","touchstart"];function a(e,o,c){const t=i();return f(()=>{const s=r=>{Array.isArray(c)?c.every(n=>!!n&&!n.contains(r.target))&&e():t.current&&!t.current.contains(r.target)&&e()};return(o||u).forEach(r=>document.addEventListener(r,s)),()=>{(o||u).forEach(r=>document.removeEventListener(r,s))}},[t,e,c]),t}export{a as useClickOutside};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T>();\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };\n }, [ref, handler, nodes]);\n\n return ref;\n}\n"],"names":[],"mappings":";;AACA,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAC5C,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;AACxD,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AACvB,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,MAAM,QAAQ,GAAG,CAAC,KAAK,KAAK;AAChC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAChC,QAAQ,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5F,QAAQ,aAAa,IAAI,OAAO,EAAE,CAAC;AACnC,OAAO,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACrE,QAAQ,OAAO,EAAE,CAAC;AAClB,OAAO;AACP,KAAK,CAAC;AACN,IAAI,CAAC,MAAM,IAAI,cAAc,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxF,IAAI,OAAO,MAAM;AACjB,MAAM,CAAC,MAAM,IAAI,cAAc,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,mBAAmB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7F,KAAK,CAAC;AACN,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5B,EAAE,OAAO,GAAG,CAAC;AACb;;;;"}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function useClipboard({ timeout = 2e3 } = {}) {
|
|
4
|
-
const [error, setError] = useState(null);
|
|
5
|
-
const [copied, setCopied] = useState(false);
|
|
6
|
-
const [copyTimeout, setCopyTimeout] = useState(null);
|
|
7
|
-
const handleCopyResult = (value) => {
|
|
8
|
-
clearTimeout(copyTimeout);
|
|
9
|
-
setCopyTimeout(setTimeout(() => setCopied(false), timeout));
|
|
10
|
-
setCopied(value);
|
|
11
|
-
};
|
|
12
|
-
const copy = (valueToCopy) => {
|
|
13
|
-
if ("clipboard" in navigator) {
|
|
14
|
-
navigator.clipboard.writeText(valueToCopy).then(() => handleCopyResult(true)).catch((err) => setError(err));
|
|
15
|
-
} else {
|
|
16
|
-
setError(new Error("useClipboard: navigator.clipboard is not supported"));
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const reset = () => {
|
|
20
|
-
setCopied(false);
|
|
21
|
-
setError(null);
|
|
22
|
-
clearTimeout(copyTimeout);
|
|
23
|
-
};
|
|
24
|
-
return { copy, reset, error, copied };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { useClipboard };
|
|
1
|
+
import{useState as r}from"react";function u({timeout:i=2e3}={}){const[a,e]=r(null),[n,o]=r(!1),[s,c]=r(null),l=t=>{clearTimeout(s),c(setTimeout(()=>o(!1),i)),o(t)};return{copy:t=>{"clipboard"in navigator?navigator.clipboard.writeText(t).then(()=>l(!0)).catch(p=>e(p)):e(new Error("useClipboard: navigator.clipboard is not supported"))},reset:()=>{o(!1),e(null),clearTimeout(s)},error:a,copied:n}}export{u as useClipboard};
|
|
28
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const reducer = (value) => (value + 1) % 1e6;
|
|
4
|
-
function useForceUpdate() {
|
|
5
|
-
const [, update] = useReducer(reducer, 0);
|
|
6
|
-
return update;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { useForceUpdate };
|
|
1
|
+
import{useReducer as r}from"react";const t=e=>(e+1)%1e6;function c(){const[,e]=r(t,0);return e}export{c as useForceUpdate};
|
|
10
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useEffect as m}from"react";import{getHotkeyMatcher as c}from"./parseHotkey.js";function d(t){m(()=>{const o=e=>{t.forEach(([n,r])=>{c(n)(e)&&(e.preventDefault(),r(e))})};return document.documentElement.addEventListener("keydown",o),()=>document.documentElement.removeEventListener("keydown",o)},[t])}export{d as useHotkeys};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useHotkeys/index.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { getHotkeyMatcher, getHotkeyHandler } from './parseHotkey';\n\nexport { getHotkeyHandler };\n\ntype HokeyItem = [string, (event: KeyboardEvent) => void];\n\nexport function useHotkeys(hotkeys: HokeyItem[]) {\n useEffect(() => {\n const keydownListener = (event: KeyboardEvent) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n\n document.documentElement.addEventListener('keydown', keydownListener);\n return () => document.documentElement.removeEventListener('keydown', keydownListener);\n }, [hotkeys]);\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,UAAU,CAAC,OAAO,EAAE;AACpC,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,MAAM,eAAe,GAAG,CAAC,KAAK,KAAK;AACvC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;AAC7C,QAAQ,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;AAC7C,UAAU,KAAK,CAAC,cAAc,EAAE,CAAC;AACjC,UAAU,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,SAAS;AACT,OAAO,CAAC,CAAC;AACT,KAAK,CAAC;AACN,IAAI,QAAQ,CAAC,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1E,IAAI,OAAO,MAAM,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1F,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var _=Object.defineProperty,w=Object.defineProperties,O=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,c=(r,e,t)=>e in r?_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,h=(r,e)=>{for(var t in e||(e={}))P.call(e,t)&&c(r,t,e[t]);if(l)for(var t of l(e))v.call(e,t)&&c(r,t,e[t]);return r},K=(r,e)=>w(r,O(e));function p(r){const e=r.toLowerCase().split("+").map(s=>s.trim()),t={alt:e.includes("alt"),ctrl:e.includes("ctrl"),meta:e.includes("meta"),mod:e.includes("mod"),shift:e.includes("shift")},o=["alt","ctrl","meta","shift","mod"],a=e.find(s=>!o.includes(s));return K(h({},t),{key:a})}function g(r,e){const{alt:t,ctrl:o,meta:a,mod:s,shift:u,key:n}=r,{altKey:d,ctrlKey:i,metaKey:f,shiftKey:y,key:m}=e;if(t!==d)return!1;if(s){if(!i&&!f)return!1}else if(o!==i||a!==f)return!1;return u!==y?!1:!!(n&&(m.toLowerCase()===n.toLowerCase()||e.code.replace("Key","").toLowerCase()===n.toLowerCase()))}function k(r){return e=>g(p(r),e)}export{k as getHotkeyMatcher,p as parseHotkey};
|
|
2
|
+
//# sourceMappingURL=parseHotkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHotkey.js","sources":["../../src/useHotkeys/parseHotkey.ts"],"sourcesContent":["export type KeyboardModifiers = {\n alt: boolean;\n ctrl: boolean;\n meta: boolean;\n mod: boolean;\n shift: boolean;\n};\n\nexport type Hotkey = KeyboardModifiers & {\n key?: string;\n};\n\ntype CheckHotkeyMatch = (event: KeyboardEvent) => boolean;\n\nexport function parseHotkey(hotkey: string): Hotkey {\n const keys = hotkey\n .toLowerCase()\n .split('+')\n .map((part) => part.trim());\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n shift: keys.includes('shift'),\n };\n\n const reservedKeys = ['alt', 'ctrl', 'meta', 'shift', 'mod'];\n\n const freeKey = keys.find((key) => !reservedKeys.includes(key));\n\n return {\n ...modifiers,\n key: freeKey,\n };\n}\n\nfunction isExactHotkey(hotkey: Hotkey, event: KeyboardEvent): boolean {\n const { alt, ctrl, meta, mod, shift, key } = hotkey;\n const { altKey, ctrlKey, metaKey, shiftKey, key: pressedKey } = event;\n\n if (alt !== altKey) {\n return false;\n }\n\n if (mod) {\n if (!ctrlKey && !metaKey) {\n return false;\n }\n } else {\n if (ctrl !== ctrlKey) {\n return false;\n }\n if (meta !== metaKey) {\n return false;\n }\n }\n if (shift !== shiftKey) {\n return false;\n }\n\n if (\n key &&\n (pressedKey.toLowerCase() === key.toLowerCase() ||\n event.code.replace('Key', '').toLowerCase() === key.toLowerCase())\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function getHotkeyMatcher(hotkey: string): CheckHotkeyMatch {\n return (event) => isExactHotkey(parseHotkey(hotkey), event);\n}\n\ntype HotkeyItem = [string, (event: React.KeyboardEvent<HTMLElement>) => void];\n\nexport function getHotkeyHandler(hotkeys: HotkeyItem[]) {\n return (event: React.KeyboardEvent<HTMLElement>) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event.nativeEvent)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n}\n"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAA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-1,10 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { randomId } from '../utils/index.js';
|
|
3
|
-
|
|
4
|
-
function useId(id, generateId = randomId) {
|
|
5
|
-
const generatedId = useRef(generateId());
|
|
6
|
-
return id || generatedId.current;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { useId };
|
|
1
|
+
import{useRef as n}from"react";import{randomId as o}from"../utils/index.js";function d(r,e=o){const t=n(e());return r||t.current}export{d as useId};
|
|
10
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useWindowEvent } from '../useWindowEvent/index.js';
|
|
3
|
-
|
|
4
|
-
function useLocalStorage({
|
|
5
|
-
key,
|
|
6
|
-
defaultValue = void 0
|
|
7
|
-
}) {
|
|
8
|
-
const [value, setValue] = useState(typeof window !== "undefined" && "localStorage" in window ? window.localStorage.getItem(key) : defaultValue != null ? defaultValue : "");
|
|
9
|
-
const setLocalStorageValue = useCallback((val) => {
|
|
10
|
-
if (typeof val === "function") {
|
|
11
|
-
setValue((current) => {
|
|
12
|
-
const result = val(current);
|
|
13
|
-
window.localStorage.setItem(key, result);
|
|
14
|
-
return result;
|
|
15
|
-
});
|
|
16
|
-
} else {
|
|
17
|
-
window.localStorage.setItem(key, val);
|
|
18
|
-
setValue(val);
|
|
19
|
-
}
|
|
20
|
-
}, [key]);
|
|
21
|
-
useWindowEvent("storage", (event) => {
|
|
22
|
-
if (event.storageArea === window.localStorage && event.key === key) {
|
|
23
|
-
setValue(event.newValue);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (defaultValue && !value) {
|
|
28
|
-
setLocalStorageValue(defaultValue);
|
|
29
|
-
}
|
|
30
|
-
}, [defaultValue, value, setLocalStorageValue]);
|
|
31
|
-
return [value, setLocalStorageValue];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { useLocalStorage };
|
|
1
|
+
import{useState as w,useCallback as a,useEffect as l}from"react";import{useWindowEvent as g}from"../useWindowEvent/index.js";function u({key:e,defaultValue:t=void 0}){const[n,r]=w(typeof window!="undefined"&&"localStorage"in window?window.localStorage.getItem(e):t!=null?t:""),i=a(o=>{typeof o=="function"?r(c=>{const s=o(c);return window.localStorage.setItem(e,s),s}):(window.localStorage.setItem(e,o),r(o))},[e]);return g("storage",o=>{o.storageArea===window.localStorage&&o.key===e&&r(o.newValue)}),l(()=>{t&&!n&&i(t)},[t,n,i]),[n,i]}export{u as useLocalStorage};
|
|
35
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function attachMediaListener(query, callback) {
|
|
4
|
-
try {
|
|
5
|
-
query.addEventListener("change", callback);
|
|
6
|
-
return () => query.removeEventListener("change", callback);
|
|
7
|
-
} catch (e) {
|
|
8
|
-
query.addListener(callback);
|
|
9
|
-
return () => query.removeListener(callback);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function getInitialValue(query) {
|
|
13
|
-
if (typeof window !== "undefined" && "matchMedia" in window) {
|
|
14
|
-
return window.matchMedia(query).matches;
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
function useMediaQuery(query) {
|
|
19
|
-
const [matches, setMatches] = useState(getInitialValue(query));
|
|
20
|
-
const queryRef = useRef();
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if ("matchMedia" in window) {
|
|
23
|
-
queryRef.current = window.matchMedia(query);
|
|
24
|
-
setMatches(queryRef.current.matches);
|
|
25
|
-
return attachMediaListener(queryRef.current, (event) => setMatches(event.matches));
|
|
26
|
-
}
|
|
27
|
-
}, [query]);
|
|
28
|
-
return matches;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { useMediaQuery };
|
|
1
|
+
import{useState as a,useRef as c,useEffect as s}from"react";function d(e,t){try{return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}catch(n){return e.addListener(t),()=>e.removeListener(t)}}function o(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function u(e){const[t,n]=a(o(e)),i=c();return s(()=>{if("matchMedia"in window)return i.current=window.matchMedia(e),n(i.current.matches),d(i.current,r=>n(r.matches))},[e]),t}export{u as useMediaQuery};
|
|
32
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useRef as s,useState as y,useEffect as h}from"react";import{clamp as S}from"../utils/index.js";function w(p,n){const t=s(),r=s(!1),u=s(!1),d=s(0),[L,v]=y(!1);return h(()=>{r.current=!0},[]),h(()=>{const a=({x:e,y:x})=>{cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{if(r.current&&t.current){t.current.style.userSelect="none";const o=t.current.getBoundingClientRect();o.width&&o.height&&p({x:S({value:(e-o.left)/o.width,min:0,max:1}),y:S({value:(x-o.top)/o.height,min:0,max:1})})}})},b=()=>{document.addEventListener("mousemove",i),document.addEventListener("mouseup",c),document.addEventListener("touchmove",m),document.addEventListener("touchend",c)},g=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",c),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",c)},f=()=>{!u.current&&r.current&&(u.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),v(!0),b())},c=()=>{u.current&&r.current&&(u.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),v(!1),g())},l=e=>{f(),i(e)},i=e=>a({x:e.clientX,y:e.clientY}),E=e=>{f(),e==null||e.preventDefault(),m(e)},m=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",l),t.current.addEventListener("touchstart",E),()=>{t.current&&(t.current.removeEventListener("mousedown",l),t.current.removeEventListener("touchstart",E))}},[t.current]),{ref:t,active:L}}export{w as useMove};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useMove/index.tsx"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-move/use-move.ts\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useEffect, useState, useRef } from 'react';\nimport { clamp } from '../utils';\n\nexport interface UseMovePosition {\n x: number;\n y: number;\n}\n\nexport const clampUseMovePosition = (position: UseMovePosition) => ({\n x: clamp({ min: 0, max: 1, value: position.x }),\n y: clamp({ min: 0, max: 1, value: position.y }),\n});\n\ninterface useMoveHandlers {\n onScrubStart?(): void;\n onScrubEnd?(): void;\n}\n\nexport function useMove<T extends HTMLElement = HTMLDivElement>(\n onChange: (value: UseMovePosition) => void,\n handlers?: useMoveHandlers\n) {\n const ref = useRef<T>();\n const mounted = useRef<boolean>(false);\n const isSliding = useRef(false);\n const frame = useRef(0);\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n mounted.current = true;\n }, []);\n\n useEffect(() => {\n const onScrub = ({ x, y }: UseMovePosition) => {\n cancelAnimationFrame(frame.current);\n\n frame.current = requestAnimationFrame(() => {\n if (mounted.current && ref.current) {\n ref.current.style.userSelect = 'none';\n const rect = ref.current.getBoundingClientRect();\n\n if (rect.width && rect.height) {\n onChange({\n x: clamp({ value: (x - rect.left) / rect.width, min: 0, max: 1 }),\n y: clamp({ value: (y - rect.top) / rect.height, min: 0, max: 1 }),\n });\n }\n }\n });\n };\n\n const bindEvents = () => {\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', stopScrubbing);\n document.addEventListener('touchmove', onTouchMove);\n document.addEventListener('touchend', stopScrubbing);\n };\n\n const unbindEvents = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', stopScrubbing);\n document.removeEventListener('touchmove', onTouchMove);\n document.removeEventListener('touchend', stopScrubbing);\n };\n\n const startScrubbing = () => {\n if (!isSliding.current && mounted.current) {\n isSliding.current = true;\n typeof handlers?.onScrubStart === 'function' && handlers.onScrubStart();\n setActive(true);\n bindEvents();\n }\n };\n\n const stopScrubbing = () => {\n if (isSliding.current && mounted.current) {\n isSliding.current = false;\n typeof handlers?.onScrubEnd === 'function' && handlers.onScrubEnd();\n setActive(false);\n unbindEvents();\n }\n };\n\n const onMouseDown = (event: MouseEvent) => {\n startScrubbing();\n onMouseMove(event);\n };\n\n const onMouseMove = (event: MouseEvent) => onScrub({ x: event.clientX, y: event.clientY });\n\n const onTouchStart = (event: TouchEvent) => {\n startScrubbing();\n event?.preventDefault();\n onTouchMove(event);\n };\n\n const onTouchMove = (event: TouchEvent) => {\n event?.preventDefault();\n onScrub({ x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY });\n };\n\n ref.current.addEventListener('mousedown', onMouseDown);\n ref.current.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener('mousedown', onMouseDown);\n ref.current.removeEventListener('touchstart', onTouchStart);\n }\n };\n }, [ref.current]);\n\n return { ref, active };\n}\n"],"names":[],"mappings":";;;AAMO,SAAS,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE;AAC5C,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AACvB,EAAE,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAClC,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC1B,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9C,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAC3B,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,MAAM,OAAO,GAAG,CAAC,EAA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,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB;;;;"}
|
package/esm/useQueue/index.js
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function useQueue({ initialValues = [], limit }) {
|
|
4
|
-
const [{ state, queue }, setState] = useState({
|
|
5
|
-
state: initialValues.slice(0, limit),
|
|
6
|
-
queue: initialValues.slice(limit)
|
|
7
|
-
});
|
|
8
|
-
const add = (...items) => setState((current) => {
|
|
9
|
-
const results = [...current.state, ...current.queue, ...items];
|
|
10
|
-
return {
|
|
11
|
-
state: results.slice(0, limit),
|
|
12
|
-
queue: results.slice(limit)
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
const update = (fn) => setState((current) => {
|
|
16
|
-
const results = fn([...current.state, ...current.queue]);
|
|
17
|
-
return {
|
|
18
|
-
state: results.slice(0, limit),
|
|
19
|
-
queue: results.slice(limit)
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
const cleanQueue = () => setState((current) => ({ state: current.state, queue: [] }));
|
|
23
|
-
return {
|
|
24
|
-
state,
|
|
25
|
-
queue,
|
|
26
|
-
add,
|
|
27
|
-
update,
|
|
28
|
-
cleanQueue
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { useQueue };
|
|
1
|
+
import{useState as r}from"react";function q({initialValues:c=[],limit:e}){const[{state:n,queue:o},a]=r({state:c.slice(0,e),queue:c.slice(e)});return{state:n,queue:o,add:(...t)=>a(u=>{const s=[...u.state,...u.queue,...t];return{state:s.slice(0,e),queue:s.slice(e)}}),update:t=>a(u=>{const s=t([...u.state,...u.queue]);return{state:s.slice(0,e),queue:s.slice(e)}}),cleanQueue:()=>a(t=>({state:t.state,queue:[]}))}}export{q as useQueue};
|
|
33
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function useReducedMotion() {
|
|
4
|
-
return useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export { useReducedMotion };
|
|
1
|
+
import{useMediaQuery as e}from"../useMediaQuery/index.js";function r(){return e("(prefers-reduced-motion: reduce)")}export{r as useReducedMotion};
|
|
8
2
|
//# sourceMappingURL=index.js.map
|
package/esm/useToggle/index.js
CHANGED
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function useToggle(initialValue, options) {
|
|
4
|
-
const [state, setState] = useState(initialValue);
|
|
5
|
-
const toggle = (value) => {
|
|
6
|
-
if (typeof value !== "undefined") {
|
|
7
|
-
setState(value);
|
|
8
|
-
} else {
|
|
9
|
-
setState((current) => {
|
|
10
|
-
if (current === options[0]) {
|
|
11
|
-
return options[1];
|
|
12
|
-
}
|
|
13
|
-
return options[0];
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return [state, toggle];
|
|
18
|
-
}
|
|
19
|
-
function useBooleanToggle(initialValue = false) {
|
|
20
|
-
return useToggle(initialValue, [true, false]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { useBooleanToggle, useToggle };
|
|
1
|
+
import{useState as g}from"react";function o(e,t){const[u,r]=g(e);return[u,n=>{typeof n!="undefined"?r(n):r(f=>f===t[0]?t[1]:t[0])}]}function s(e=!1){return o(e,[!0,!1])}export{s as useBooleanToggle,o as useToggle};
|
|
24
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function useUncontrolled({
|
|
4
|
-
value,
|
|
5
|
-
defaultValue,
|
|
6
|
-
finalValue,
|
|
7
|
-
rule,
|
|
8
|
-
onChange,
|
|
9
|
-
onValueUpdate
|
|
10
|
-
}) {
|
|
11
|
-
const shouldBeControlled = rule(value);
|
|
12
|
-
const modeRef = useRef("initial");
|
|
13
|
-
const initialValue = rule(defaultValue) ? defaultValue : finalValue;
|
|
14
|
-
const [uncontrolledValue, setUncontrolledValue] = useState(initialValue);
|
|
15
|
-
let effectiveValue = shouldBeControlled ? value : uncontrolledValue;
|
|
16
|
-
if (!shouldBeControlled && modeRef.current === "controlled") {
|
|
17
|
-
effectiveValue = finalValue;
|
|
18
|
-
}
|
|
19
|
-
modeRef.current = shouldBeControlled ? "controlled" : "uncontrolled";
|
|
20
|
-
const mode = modeRef.current;
|
|
21
|
-
const handleChange = (nextValue) => {
|
|
22
|
-
typeof onChange === "function" && onChange(nextValue);
|
|
23
|
-
if (mode === "uncontrolled") {
|
|
24
|
-
setUncontrolledValue(nextValue);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (mode === "uncontrolled") {
|
|
29
|
-
setUncontrolledValue(effectiveValue);
|
|
30
|
-
}
|
|
31
|
-
typeof onValueUpdate === "function" && onValueUpdate(effectiveValue);
|
|
32
|
-
}, [mode, effectiveValue]);
|
|
33
|
-
return [effectiveValue, handleChange, modeRef.current];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { useUncontrolled };
|
|
1
|
+
import{useRef as y,useState as R,useEffect as a}from"react";function B({value:c,defaultValue:r,finalValue:l,rule:u,onChange:f,onValueUpdate:i}){const n=u(c),t=y("initial"),m=u(r)?r:l,[p,s]=R(m);let o=n?c:p;!n&&t.current==="controlled"&&(o=l),t.current=n?"controlled":"uncontrolled";const e=t.current,h=d=>{typeof f=="function"&&f(d),e==="uncontrolled"&&s(d)};return a(()=>{e==="uncontrolled"&&s(o),typeof i=="function"&&i(o)},[e,o]),[o,h,t.current]}export{B as useUncontrolled};
|
|
37
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function useWindowEvent(type, listener, options) {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
window.addEventListener(type, listener, options);
|
|
6
|
-
return () => window.removeEventListener(type, listener, options);
|
|
7
|
-
}, []);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { useWindowEvent };
|
|
1
|
+
import{useEffect as t}from"react";function o(e,n,r){t(()=>(window.addEventListener(e,n,r),()=>window.removeEventListener(e,n,r)),[])}export{o as useWindowEvent};
|
|
11
2
|
//# sourceMappingURL=index.js.map
|
package/esm/utils/index.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
return `kubed-${Math.random().toString(36).substr(2, 9)}`;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export { randomId };
|
|
1
|
+
function a(){return`kubed-${Math.random().toString(36).substr(2,9)}`}function o({value:t,min:n,max:r}){return Math.min(Math.max(t,n),r)}export{o as clamp,a as randomId};
|
|
6
2
|
//# sourceMappingURL=index.js.map
|
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["export function randomId() {\n return `kubed-${Math.random().toString(36).substr(2, 9)}`;\n}\n"],"names":[],"mappings":"AAAO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["export function randomId() {\n return `kubed-${Math.random().toString(36).substr(2, 9)}`;\n}\n\ninterface Clamp {\n value: number;\n min: number;\n max: number;\n}\n\nexport function clamp({ value, min, max }: Clamp) {\n return Math.min(Math.max(value, min), max);\n}\n"],"names":[],"mappings":"AAAO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AACM,SAAS,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;AAC3C,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7C;;;;"}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,4 +9,7 @@ export { useLocalStorage } from './useLocalStorage';
|
|
|
9
9
|
export { useForceUpdate } from './useForceUpdate';
|
|
10
10
|
export { useClipboard } from './useClipboard';
|
|
11
11
|
export { useQueue } from './useQueue';
|
|
12
|
+
export { useClickOutside } from './useClickOutside';
|
|
13
|
+
export { useMove } from './useMove';
|
|
14
|
+
export { useHotkeys } from './useHotkeys';
|
|
12
15
|
//# 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"}
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useClickOutside/index.ts"],"names":[],"mappings":";AAIA,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,GAAG,EACzD,OAAO,EAAE,MAAM,IAAI,EACnB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EACxB,KAAK,CAAC,EAAE,WAAW,EAAE,uCAsBtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useHotkeys/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,aAAK,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC;AAE1D,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,QAc9C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type KeyboardModifiers = {
|
|
3
|
+
alt: boolean;
|
|
4
|
+
ctrl: boolean;
|
|
5
|
+
meta: boolean;
|
|
6
|
+
mod: boolean;
|
|
7
|
+
shift: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare type Hotkey = KeyboardModifiers & {
|
|
10
|
+
key?: string;
|
|
11
|
+
};
|
|
12
|
+
declare type CheckHotkeyMatch = (event: KeyboardEvent) => boolean;
|
|
13
|
+
export declare function parseHotkey(hotkey: string): Hotkey;
|
|
14
|
+
export declare function getHotkeyMatcher(hotkey: string): CheckHotkeyMatch;
|
|
15
|
+
declare type HotkeyItem = [string, (event: React.KeyboardEvent<HTMLElement>) => void];
|
|
16
|
+
export declare function getHotkeyHandler(hotkeys: HotkeyItem[]): (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=parseHotkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHotkey.d.ts","sourceRoot":"","sources":["../../src/useHotkeys/parseHotkey.ts"],"names":[],"mappings":";AAAA,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,oBAAY,MAAM,GAAG,iBAAiB,GAAG;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,aAAK,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;AAE1D,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAsBlD;AAqCD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEjE;AAED,aAAK,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC;AAE9E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,WACrC,mBAAmB,CAAC,WAAW,CAAC,UAQhD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface UseMovePosition {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const clampUseMovePosition: (position: UseMovePosition) => {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
interface useMoveHandlers {
|
|
11
|
+
onScrubStart?(): void;
|
|
12
|
+
onScrubEnd?(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function useMove<T extends HTMLElement = HTMLDivElement>(onChange: (value: UseMovePosition) => void, handlers?: useMoveHandlers): {
|
|
15
|
+
ref: import("react").MutableRefObject<T>;
|
|
16
|
+
active: boolean;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useMove/index.tsx"],"names":[],"mappings":";AAKA,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,eAAO,MAAM,oBAAoB,aAAc,eAAe;;;CAG5D,CAAC;AAEH,UAAU,eAAe;IACvB,YAAY,CAAC,IAAI,IAAI,CAAC;IACtB,UAAU,CAAC,IAAI,IAAI,CAAC;CACrB;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,EAC5D,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,EAC1C,QAAQ,CAAC,EAAE,eAAe;;;EA6F3B"}
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,WAEvB"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,WAEvB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,UAE/C"}
|