@vnejs/uis.react.cursor 0.1.2
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/Cursor.d.ts +11 -0
- package/dist/Cursor.d.ts.map +1 -0
- package/dist/Cursor.js +33 -0
- package/dist/Cursor.js.map +1 -0
- package/dist/Cursor.styl +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/dist/Cursor.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./Cursor.styl";
|
|
2
|
+
export declare const Cursor: ({ isShow, transition, size, forceX, forceY, srcDefault, srcPointer }: {
|
|
3
|
+
isShow?: boolean;
|
|
4
|
+
transition?: number;
|
|
5
|
+
size?: number;
|
|
6
|
+
forceX: any;
|
|
7
|
+
forceY: any;
|
|
8
|
+
srcDefault: any;
|
|
9
|
+
srcPointer: any;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=Cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cursor.d.ts","sourceRoot":"","sources":["../src/Cursor.tsx"],"names":[],"mappings":"AAIA,OAAO,eAAe,CAAC;AAIvB,eAAO,MAAM,MAAM,GAAI;;;;;;;;CAAwF,4CAyC9G,CAAC"}
|
package/dist/Cursor.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { cn, getVneLength } from "@vnejs/uis.utils";
|
|
4
|
+
import "./Cursor.styl";
|
|
5
|
+
const b = cn("Cursor");
|
|
6
|
+
export const Cursor = ({ isShow = false, transition = 500, size = 120, forceX, forceY, srcDefault, srcPointer }) => {
|
|
7
|
+
const cursorType = useMemo(() => {
|
|
8
|
+
const elements = document.elementsFromPoint(forceX, forceY);
|
|
9
|
+
[...document.querySelectorAll("[vne-cursor-target]")].forEach((elem) => elem.removeAttribute("vne-cursor-target"));
|
|
10
|
+
elements.forEach((elem) => elem.setAttribute("vne-cursor-target", ""));
|
|
11
|
+
for (let i = 0; i < elements.length; i++) {
|
|
12
|
+
const cur = elements[elements.length - i - 1];
|
|
13
|
+
if (cur.getAttribute("vne-cursor-type"))
|
|
14
|
+
return cur.getAttribute("vne-cursor-type");
|
|
15
|
+
}
|
|
16
|
+
return "default";
|
|
17
|
+
}, [forceX, forceY]);
|
|
18
|
+
const style = useMemo(() => {
|
|
19
|
+
const result = {};
|
|
20
|
+
if (transition)
|
|
21
|
+
result.transition = `background-image ${transition}ms, opacity ${transition}ms`;
|
|
22
|
+
if (size) {
|
|
23
|
+
result.width = getVneLength(size);
|
|
24
|
+
result.height = getVneLength(size);
|
|
25
|
+
}
|
|
26
|
+
result["--vne-cursor-src"] = `url('${cursorType === "pointer" ? srcPointer : srcDefault}')`;
|
|
27
|
+
result["--vne-cursor-top"] = forceY;
|
|
28
|
+
result["--vne-cursor-left"] = forceX;
|
|
29
|
+
return result;
|
|
30
|
+
}, [forceX, forceY, size, cursorType, srcPointer, srcDefault, transition]);
|
|
31
|
+
return (_jsx("div", { className: b({ isShow }), "data-html2canvas-ignore": true, id: "cursor", style: style }));
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cursor.js","sourceRoot":"","sources":["../src/Cursor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,eAAe,CAAC;AAEvB,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG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,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,CAAC,kBAAkB,CAAC,GAAG,QAAQ,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC;QAC5F,MAAM,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;QACpC,MAAM,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC;QAErC,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAE3E,OAAO,CACL,cACE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,mCAExB,EAAE,EAAC,QAAQ,EACX,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/Cursor.styl
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.Cursor
|
|
2
|
+
position: fixed
|
|
3
|
+
translate: calc(-50% + 1px * var(--vne-cursor-left)) calc(-50% + 1px * var(--vne-cursor-top))
|
|
4
|
+
z-index: 999999999999999
|
|
5
|
+
top: 0
|
|
6
|
+
left: 0
|
|
7
|
+
|
|
8
|
+
background-image: var(--vne-cursor-src)
|
|
9
|
+
|
|
10
|
+
background-position: center
|
|
11
|
+
background-size: contain
|
|
12
|
+
background-repeat: no-repeat
|
|
13
|
+
|
|
14
|
+
pointer-events: none
|
|
15
|
+
|
|
16
|
+
opacity: 0
|
|
17
|
+
|
|
18
|
+
&_isShow
|
|
19
|
+
opacity 1
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/uis.react.cursor",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
8
|
+
"publish:major:plugin": "npm run publish:major",
|
|
9
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
10
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
11
|
+
"publish:major": "npm run build && npm version major && npm publish --access public",
|
|
12
|
+
"publish:minor": "npm run build && npm version minor && npm publish --access public",
|
|
13
|
+
"publish:patch": "npm run build && npm version patch && npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@bem-react/classname": "1.5.12",
|
|
17
|
+
"@vnejs/uis.utils": "~0.1.0",
|
|
18
|
+
"react": "19.2.4",
|
|
19
|
+
"react-dom": "19.2.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@vnejs/uis.react": "~0.1.0",
|
|
23
|
+
"typescript": "^5.7.3",
|
|
24
|
+
"@types/react": "^19.0.10",
|
|
25
|
+
"@types/react-dom": "^19.0.4"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"package.json"
|
|
30
|
+
]
|
|
31
|
+
}
|