@os-design/use-cursor-position 1.0.19 → 1.0.20
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/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +1 -2
- package/package.json +8 -9
- package/dist/cjs/index.js +0 -43
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,QAAA,MAAM,iBAAiB,sBAoBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/use-cursor-position",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "dist/
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"src",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rimraf dist",
|
|
23
|
-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist
|
|
24
|
-
"build:
|
|
25
|
-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
23
|
+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist",
|
|
24
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationDir dist",
|
|
26
25
|
"build": "yarn clean && npm-run-all 'build:*'",
|
|
27
26
|
"ncu": "ncu -u"
|
|
28
27
|
},
|
|
@@ -30,10 +29,10 @@
|
|
|
30
29
|
"access": "public"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@os-design/use-event": "^1.0.
|
|
32
|
+
"@os-design/use-event": "^1.0.23"
|
|
34
33
|
},
|
|
35
34
|
"peerDependencies": {
|
|
36
35
|
"react": ">=18"
|
|
37
36
|
},
|
|
38
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "86a83e87297a07afe132782ca2c95023b7139276"
|
|
39
38
|
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _useEvent = _interopRequireDefault(require("@os-design/use-event"));
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
var useCursorPosition = function useCursorPosition() {
|
|
17
|
-
var _useState = (0, _react.useState)({
|
|
18
|
-
x: 0,
|
|
19
|
-
y: 0
|
|
20
|
-
}),
|
|
21
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
-
cursorPosition = _useState2[0],
|
|
23
|
-
setCursorPosition = _useState2[1];
|
|
24
|
-
var mouseMoveHandler = (0, _react.useCallback)(function (e) {
|
|
25
|
-
setCursorPosition({
|
|
26
|
-
x: e.clientX,
|
|
27
|
-
y: e.clientY
|
|
28
|
-
});
|
|
29
|
-
}, []);
|
|
30
|
-
var touchMoveHandler = (0, _react.useCallback)(function (e) {
|
|
31
|
-
if (e.touches.length === 0) return;
|
|
32
|
-
setCursorPosition({
|
|
33
|
-
x: e.touches[0].clientX,
|
|
34
|
-
y: e.touches[0].clientY
|
|
35
|
-
});
|
|
36
|
-
}, []);
|
|
37
|
-
(0, _useEvent["default"])(window, 'mousemove', mouseMoveHandler);
|
|
38
|
-
(0, _useEvent["default"])(window, 'touchstart', touchMoveHandler);
|
|
39
|
-
(0, _useEvent["default"])(window, 'touchmove', touchMoveHandler);
|
|
40
|
-
return cursorPosition;
|
|
41
|
-
};
|
|
42
|
-
var _default = exports["default"] = useCursorPosition;
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_useEvent","_interopRequireDefault","require","_react","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","r","l","t","Symbol","iterator","e","u","a","f","next","done","push","value","isArray","useCursorPosition","_useState","useState","x","y","_useState2","cursorPosition","setCursorPosition","mouseMoveHandler","useCallback","clientX","clientY","touchMoveHandler","touches","useEvent","window","_default","exports"],"sources":["../../src/index.ts"],"sourcesContent":["import useEvent from '@os-design/use-event';\nimport { useCallback, useState } from 'react';\n\nexport interface CursorPosition {\n x: number;\n y: number;\n}\n\nconst useCursorPosition = () => {\n const [cursorPosition, setCursorPosition] = useState<CursorPosition>({\n x: 0,\n y: 0,\n });\n\n const mouseMoveHandler = useCallback((e: MouseEvent) => {\n setCursorPosition({ x: e.clientX, y: e.clientY });\n }, []);\n\n const touchMoveHandler = useCallback((e: TouchEvent) => {\n if (e.touches.length === 0) return;\n setCursorPosition({ x: e.touches[0].clientX, y: e.touches[0].clientY });\n }, []);\n\n useEvent(window, 'mousemove', mouseMoveHandler);\n useEvent(window, 'touchstart', touchMoveHandler);\n useEvent(window, 'touchmove', touchMoveHandler);\n\n return cursorPosition;\n};\n\nexport default useCursorPosition;\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA8C,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,G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ACsB,OAAO,CAAC,CAAC,CAAC,CAACH,OAAO;MAAEN,CAAC,EAAEb,CAAC,CAACsB,OAAO,CAAC,CAAC,CAAC,CAACF;IAAQ,CAAC,CAAC;EACzE,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAG,oBAAQ,EAACC,MAAM,EAAE,WAAW,EAAEP,gBAAgB,CAAC;EAC/C,IAAAM,oBAAQ,EAACC,MAAM,EAAE,YAAY,EAAEH,gBAAgB,CAAC;EAChD,IAAAE,oBAAQ,EAACC,MAAM,EAAE,WAAW,EAAEH,gBAAgB,CAAC;EAE/C,OAAON,cAAc;AACvB,CAAC;AAAC,IAAAU,QAAA,GAAAC,OAAA,cAEajB,iBAAiB","ignoreList":[]}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEvent","useCallback","useState","useCursorPosition","cursorPosition","setCursorPosition","x","y","mouseMoveHandler","e","clientX","clientY","touchMoveHandler","touches","length","window"],"sources":["../../src/index.ts"],"sourcesContent":["import useEvent from '@os-design/use-event';\nimport { useCallback, useState } from 'react';\n\nexport interface CursorPosition {\n x: number;\n y: number;\n}\n\nconst useCursorPosition = () => {\n const [cursorPosition, setCursorPosition] = useState<CursorPosition>({\n x: 0,\n y: 0,\n });\n\n const mouseMoveHandler = useCallback((e: MouseEvent) => {\n setCursorPosition({ x: e.clientX, y: e.clientY });\n }, []);\n\n const touchMoveHandler = useCallback((e: TouchEvent) => {\n if (e.touches.length === 0) return;\n setCursorPosition({ x: e.touches[0].clientX, y: e.touches[0].clientY });\n }, []);\n\n useEvent(window, 'mousemove', mouseMoveHandler);\n useEvent(window, 'touchstart', touchMoveHandler);\n useEvent(window, 'touchmove', touchMoveHandler);\n\n return cursorPosition;\n};\n\nexport default useCursorPosition;\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAO7C,MAAMC,iBAA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