@vnejs/uis.react.cursor 0.1.2 → 0.1.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/dist/Cursor.d.ts +0 -1
- package/dist/Cursor.d.ts.map +1 -1
- package/dist/Cursor.js +2 -3
- package/dist/Cursor.js.map +1 -1
- package/dist/Cursor.styles.d.ts +2 -0
- package/dist/Cursor.styles.d.ts.map +1 -0
- package/dist/Cursor.styles.js +23 -0
- package/dist/Cursor.styles.js.map +1 -0
- package/package.json +12 -17
- package/src/Cursor.stories.tsx +59 -0
- package/src/Cursor.styles.ts +25 -0
- package/src/Cursor.tsx +48 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +18 -0
- package/dist/Cursor.styl +0 -19
package/dist/Cursor.d.ts
CHANGED
package/dist/Cursor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cursor.d.ts","sourceRoot":"","sources":["../src/Cursor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cursor.d.ts","sourceRoot":"","sources":["../src/Cursor.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,MAAM,GAAI;;;;;;;;CAAwF,4CAyC9G,CAAC"}
|
package/dist/Cursor.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import "./Cursor.
|
|
5
|
-
const b = cn("Cursor");
|
|
3
|
+
import { getVneLength } from "@vnejs/uis.utils";
|
|
4
|
+
import { b } from "./Cursor.styles.js";
|
|
6
5
|
export const Cursor = ({ isShow = false, transition = 500, size = 120, forceX, forceY, srcDefault, srcPointer }) => {
|
|
7
6
|
const cursorType = useMemo(() => {
|
|
8
7
|
const elements = document.elementsFromPoint(forceX, forceY);
|
package/dist/Cursor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-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
+
export const b = cn("Cursor");
|
|
3
|
+
const CSS = `
|
|
4
|
+
${sel(b())} {
|
|
5
|
+
position: fixed;
|
|
6
|
+
translate: calc(-50% + 1px * var(--vne-cursor-left)) calc(-50% + 1px * var(--vne-cursor-top));
|
|
7
|
+
z-index: 999999999999999;
|
|
8
|
+
top: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
background-image: var(--vne-cursor-src);
|
|
11
|
+
background-position: center;
|
|
12
|
+
background-size: contain;
|
|
13
|
+
background-repeat: no-repeat;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
opacity: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
${sel(b({ isShow: true }))} {
|
|
19
|
+
opacity: 1;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
injectStyles(CSS);
|
|
23
|
+
//# sourceMappingURL=Cursor.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cursor.styles.js","sourceRoot":"","sources":["../src/Cursor.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;AAE9B,MAAM,GAAG,GAAG;EACV,GAAG,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;EAcR,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;;;CAGzB,CAAC;AAEF,YAAY,CAAC,GAAG,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/uis.react.cursor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"publish:major:
|
|
9
|
-
"publish:minor:
|
|
10
|
-
"publish:patch:
|
|
11
|
-
"publish:major": "
|
|
12
|
-
"publish:minor": "
|
|
13
|
-
"publish:patch": "
|
|
7
|
+
"build": "npx @vnejs/monorepo package",
|
|
8
|
+
"publish:major:uis:react": "npm run publish:major",
|
|
9
|
+
"publish:minor:uis:react": "npm run publish:minor",
|
|
10
|
+
"publish:patch:uis:react": "npm run publish:patch",
|
|
11
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
12
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
13
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@vnejs/uis.utils": "~0.1.0",
|
|
18
|
-
"react": "19.2.4",
|
|
19
|
-
"react-dom": "19.2.4"
|
|
16
|
+
"@vnejs/uis.utils": "~0.1.0"
|
|
20
17
|
},
|
|
21
18
|
"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"
|
|
19
|
+
"@vnejs/uis.react": "~0.1.0"
|
|
26
20
|
},
|
|
27
21
|
"files": [
|
|
28
22
|
"dist",
|
|
29
|
-
"
|
|
23
|
+
"src",
|
|
24
|
+
"tsconfig.json"
|
|
30
25
|
]
|
|
31
26
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { renderWithVneWrap, VneWrap } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import { Button, Cursor, Flex, Range, Text } from "@vnejs/uis.react";
|
|
6
|
+
|
|
7
|
+
export const Common = {
|
|
8
|
+
args: {
|
|
9
|
+
...VneWrap.DEFAULT_ARGS,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: "Primitives/Cursor",
|
|
15
|
+
render: renderWithVneWrap(
|
|
16
|
+
(args) => {
|
|
17
|
+
const [rangeValue, setRangeValue] = useState(0);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Flex
|
|
21
|
+
align={Flex.ALIGN.CENTER}
|
|
22
|
+
justify={Flex.JUSTIFY.CENTER}
|
|
23
|
+
direction={Flex.DIRECTION.COLUMN}
|
|
24
|
+
height={2160}
|
|
25
|
+
gap={48}
|
|
26
|
+
>
|
|
27
|
+
<Cursor
|
|
28
|
+
{...args}
|
|
29
|
+
srcDefault={"./cursor/default.svg"}
|
|
30
|
+
srcPointer={"./cursor/pointer.svg"}
|
|
31
|
+
/>
|
|
32
|
+
<Button
|
|
33
|
+
text="12345"
|
|
34
|
+
padding={24}
|
|
35
|
+
textSize={60}
|
|
36
|
+
/>
|
|
37
|
+
<Text
|
|
38
|
+
size={48}
|
|
39
|
+
text="1111111"
|
|
40
|
+
isHoverable={true}
|
|
41
|
+
/>
|
|
42
|
+
<Range
|
|
43
|
+
width={360}
|
|
44
|
+
height={60}
|
|
45
|
+
min={0}
|
|
46
|
+
max={100}
|
|
47
|
+
step={1}
|
|
48
|
+
value={rangeValue}
|
|
49
|
+
onChange={(v) => setRangeValue(v)}
|
|
50
|
+
/>
|
|
51
|
+
</Flex>
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
{ hideCursor: true, hideFlex: true },
|
|
55
|
+
),
|
|
56
|
+
argTypes: {
|
|
57
|
+
...VneWrap.ARGS,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cn, injectStyles, sel } from "@vnejs/uis.utils";
|
|
2
|
+
|
|
3
|
+
export const b = cn("Cursor");
|
|
4
|
+
|
|
5
|
+
const CSS = `
|
|
6
|
+
${sel(b())} {
|
|
7
|
+
position: fixed;
|
|
8
|
+
translate: calc(-50% + 1px * var(--vne-cursor-left)) calc(-50% + 1px * var(--vne-cursor-top));
|
|
9
|
+
z-index: 999999999999999;
|
|
10
|
+
top: 0;
|
|
11
|
+
left: 0;
|
|
12
|
+
background-image: var(--vne-cursor-src);
|
|
13
|
+
background-position: center;
|
|
14
|
+
background-size: contain;
|
|
15
|
+
background-repeat: no-repeat;
|
|
16
|
+
pointer-events: none;
|
|
17
|
+
opacity: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
${sel(b({ isShow: true }))} {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
injectStyles(CSS);
|
package/src/Cursor.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
import { getVneLength } from "@vnejs/uis.utils";
|
|
4
|
+
|
|
5
|
+
import { b } from "./Cursor.styles.js";
|
|
6
|
+
|
|
7
|
+
export const Cursor = ({ isShow = false, transition = 500, size = 120, forceX, forceY, srcDefault, srcPointer }) => {
|
|
8
|
+
const cursorType = useMemo(() => {
|
|
9
|
+
const elements = document.elementsFromPoint(forceX, forceY);
|
|
10
|
+
|
|
11
|
+
[...document.querySelectorAll("[vne-cursor-target]")].forEach((elem) => elem.removeAttribute("vne-cursor-target"));
|
|
12
|
+
elements.forEach((elem) => elem.setAttribute("vne-cursor-target", ""));
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < elements.length; i++) {
|
|
15
|
+
const cur = elements[elements.length - i - 1];
|
|
16
|
+
|
|
17
|
+
if (cur.getAttribute("vne-cursor-type")) return cur.getAttribute("vne-cursor-type");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return "default";
|
|
21
|
+
}, [forceX, forceY]);
|
|
22
|
+
|
|
23
|
+
const style = useMemo(() => {
|
|
24
|
+
const result: Record<string, any> = {};
|
|
25
|
+
|
|
26
|
+
if (transition) result.transition = `background-image ${transition}ms, opacity ${transition}ms`;
|
|
27
|
+
|
|
28
|
+
if (size) {
|
|
29
|
+
result.width = getVneLength(size);
|
|
30
|
+
result.height = getVneLength(size);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
result["--vne-cursor-src"] = `url('${cursorType === "pointer" ? srcPointer : srcDefault}')`;
|
|
34
|
+
result["--vne-cursor-top"] = forceY;
|
|
35
|
+
result["--vne-cursor-left"] = forceX;
|
|
36
|
+
|
|
37
|
+
return result;
|
|
38
|
+
}, [forceX, forceY, size, cursorType, srcPointer, srcDefault, transition]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
className={b({ isShow })}
|
|
43
|
+
data-html2canvas-ignore
|
|
44
|
+
id="cursor"
|
|
45
|
+
style={style}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Cursor";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.react.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"rootDir": "src"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*.ts",
|
|
9
|
+
"src/**/*.tsx",
|
|
10
|
+
"../../../globals.d.ts",
|
|
11
|
+
"../../../peer-modules.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"dist",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"src/**/*.stories.tsx"
|
|
17
|
+
]
|
|
18
|
+
}
|
package/dist/Cursor.styl
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|