@sharadox/pointer-web-library 0.0.0-stage → 0.1.1

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/LICENCA.md ADDED
@@ -0,0 +1,76 @@
1
+ # Licença Sharadox de Código Aberto
2
+
3
+ Versão 0.1.0
4
+
5
+ O texto em língua portuguesa é o único texto original e vinculativo desta licença. A tradução para inglês (`LICENSE.md`) é meramente informativa; em caso de divergência prevalece o texto em português.
6
+
7
+ ## 1. Definições
8
+
9
+ Para efeitos desta licença:
10
+
11
+ 1. **«Obra»** — o programa de computador, a sua documentação e quaisquer outros conteúdos disponibilizados pelo Licenciante ao abrigo desta licença, em código-fonte ou em qualquer outra forma.
12
+ 2. **«Licenciante»** — o titular dos direitos de autor identificado no aviso de direitos de autor que acompanha a Obra.
13
+ 3. **«Licenciado»** — qualquer pessoa, singular ou coletiva, que exerça os direitos concedidos por esta licença.
14
+ 4. **«Obra Derivada»** — qualquer obra baseada na Obra ou que a incorpore, total ou parcialmente, com ou sem modificações, incluindo traduções, adaptações e programas que a integrem.
15
+ 5. **«Aviso»** — o aviso de direitos de autor do Licenciante e a indicação de que a Obra está licenciada ao abrigo desta licença, incluindo a respetiva versão.
16
+
17
+ ## 2. Concessão de direitos
18
+
19
+ 1. Nos termos desta licença, o Licenciante concede ao Licenciado uma licença mundial, gratuita, não exclusiva e por todo o prazo de proteção dos direitos de autor para:
20
+ 1. utilizar a Obra para qualquer finalidade, incluindo finalidades comerciais;
21
+ 2. reproduzir a Obra, total ou parcialmente, por qualquer meio e sob qualquer forma;
22
+ 3. modificar, traduzir, adaptar e transformar a Obra e criar Obras Derivadas;
23
+ 4. distribuir, publicar, comunicar ao público, colocar à disposição, vender e sublicenciar a Obra e as Obras Derivadas.
24
+ 2. Na medida em que o Licenciante seja titular de patentes necessariamente infringidas pela Obra tal como por si disponibilizada, concede igualmente ao Licenciado, nos mesmos termos, uma licença para utilizar essas patentes no exercício dos direitos previstos no número anterior.
25
+ 3. Esta licença não transmite a titularidade de quaisquer direitos, que permanecem do Licenciante.
26
+
27
+ ## 3. Condições
28
+
29
+ O exercício dos direitos concedidos fica sujeito às seguintes condições:
30
+
31
+ 1. Todas as cópias da Obra, ou de partes substanciais da mesma, e todas as Obras Derivadas distribuídas devem incluir o Aviso e uma cópia desta licença ou uma ligação estável para o seu texto.
32
+ 2. Quem distribuir uma versão modificada da Obra deve indicar de forma visível que a mesma foi modificada, não podendo apresentá-la como versão original do Licenciante.
33
+ 3. O Licenciado pode licenciar as suas próprias modificações ao abrigo de outros termos, desde que a parte da Obra que delas faça parte continue sujeita às condições desta licença.
34
+
35
+ ## 4. Nomes e marcas
36
+
37
+ Esta licença não concede qualquer direito sobre o nome, as marcas, os logótipos ou outros sinais distintivos do Licenciante, incluindo a designação «Sharadox», salvo na medida estritamente necessária para cumprir o dever de incluir o Aviso. É proibido utilizá-los para promover ou sugerir o apoio do Licenciante a Obras Derivadas ou a quaisquer produtos ou serviços sem autorização prévia e escrita.
38
+
39
+ ## 5. Exclusão de garantias
40
+
41
+ A Obra é disponibilizada «tal como está» e «conforme disponível», sem qualquer garantia, expressa ou tácita, incluindo, designadamente, garantias de comerciabilidade, de adequação a um fim específico, de ausência de erros ou de não violação de direitos de terceiros, na medida máxima permitida pela lei aplicável.
42
+
43
+ ## 6. Limitação de responsabilidade
44
+
45
+ 1. Na medida máxima permitida pela lei aplicável, o Licenciante não é responsável por quaisquer danos, diretos ou indiretos, incluindo lucros cessantes, perda de dados ou interrupção de atividade, resultantes da utilização ou da impossibilidade de utilização da Obra, ainda que tenha sido avisado da possibilidade da sua ocorrência.
46
+ 2. Nada nesta licença exclui ou limita a responsabilidade do Licenciante nos casos em que tal exclusão ou limitação não seja permitida por lei, designadamente por atos praticados com dolo ou culpa grave, nos termos do artigo 809.º e do n.º 2 do artigo 800.º do Código Civil, nem afeta os direitos que a lei imperativamente reconheça aos consumidores.
47
+
48
+ ## 7. Cessação
49
+
50
+ 1. Os direitos concedidos por esta licença cessam automaticamente se o Licenciado violar qualquer das suas condições.
51
+ 2. Os direitos são repostos se a violação for sanada no prazo de 30 dias a contar do momento em que o Licenciado dela tome conhecimento, salvo se o Licenciante tiver entretanto comunicado por escrito a sua oposição.
52
+ 3. A cessação não afeta as licenças validamente concedidas pelo Licenciado a terceiros que cumpram esta licença.
53
+
54
+ ## 8. Lei aplicável e foro
55
+
56
+ 1. Esta licença rege-se pela lei portuguesa, designadamente pelo Código do Direito de Autor e dos Direitos Conexos, aprovado pelo Decreto-Lei n.º 63/85, de 14 de março, e pelo Decreto-Lei n.º 252/94, de 20 de outubro, relativo à proteção jurídica dos programas de computador.
57
+ 2. Para a resolução de quaisquer litígios emergentes desta licença é competente o Tribunal Judicial da Comarca de Faro, sem prejuízo das normas imperativas de competência aplicáveis, nomeadamente as que protegem os consumidores.
58
+
59
+ ## 9. Versões da licença
60
+
61
+ O Licenciante pode publicar novas versões desta licença, identificadas por um número de versão. A Obra fica sujeita à versão indicada no Aviso. O Licenciado pode, se o Aviso o permitir, optar por qualquer versão posterior.
62
+
63
+ ## 10. Disposições finais
64
+
65
+ 1. Se alguma disposição desta licença for considerada inválida ou ineficaz, as restantes mantêm-se em vigor, devendo a disposição afetada ser interpretada de forma a aproximar-se, tanto quanto possível, da intenção original.
66
+ 2. A não exigência, em qualquer momento, do cumprimento de uma disposição desta licença não constitui renúncia ao direito de o exigir posteriormente.
67
+
68
+ ## Como aplicar esta licença
69
+
70
+ Inclua na Obra um ficheiro `LICENCA.md` com este texto, a tradução `LICENSE.md` e o seguinte aviso, preenchendo o ano e o titular:
71
+
72
+ ```
73
+ Direitos de autor © <ano> <titular>.
74
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
75
+ https://github.com/Sharadox/sharadox-open-source-license
76
+ ```
package/LICENSE.md ADDED
@@ -0,0 +1,76 @@
1
+ # Sharadox Open Source License
2
+
3
+ Version 0.1.0
4
+
5
+ This is an informative English translation. The Portuguese text (`LICENCA.md`) is the only original and binding text of this license; if the two differ, the Portuguese text prevails.
6
+
7
+ ## 1. Definitions
8
+
9
+ For the purposes of this license:
10
+
11
+ 1. **"Work"** — the computer program, its documentation and any other content made available by the Licensor under this license, in source code or in any other form.
12
+ 2. **"Licensor"** — the copyright holder identified in the copyright notice that accompanies the Work.
13
+ 3. **"Licensee"** — any natural or legal person exercising the rights granted by this license.
14
+ 4. **"Derivative Work"** — any work based on or incorporating the Work, in whole or in part, with or without modifications, including translations, adaptations and programs that integrate it.
15
+ 5. **"Notice"** — the Licensor's copyright notice and the statement that the Work is licensed under this license, including its version.
16
+
17
+ ## 2. Grant of rights
18
+
19
+ 1. Under this license, the Licensor grants the Licensee a worldwide, royalty-free, non-exclusive license, for the whole term of copyright protection, to:
20
+ 1. use the Work for any purpose, including commercial purposes;
21
+ 2. reproduce the Work, in whole or in part, by any means and in any form;
22
+ 3. modify, translate, adapt and transform the Work and create Derivative Works;
23
+ 4. distribute, publish, communicate to the public, make available, sell and sublicense the Work and Derivative Works.
24
+ 2. To the extent the Licensor holds patents necessarily infringed by the Work as made available by it, the Licensor also grants the Licensee, on the same terms, a license to use those patents in exercising the rights in the previous paragraph.
25
+ 3. This license does not transfer ownership of any rights, which remain with the Licensor.
26
+
27
+ ## 3. Conditions
28
+
29
+ The exercise of the rights granted is subject to the following conditions:
30
+
31
+ 1. Every copy of the Work, or of substantial parts of it, and every distributed Derivative Work must include the Notice and a copy of this license or a stable link to its text.
32
+ 2. Anyone distributing a modified version of the Work must state visibly that it has been modified and may not present it as the Licensor's original version.
33
+ 3. The Licensee may license their own modifications under other terms, provided the part of the Work included in them remains subject to the conditions of this license.
34
+
35
+ ## 4. Names and trademarks
36
+
37
+ This license grants no rights to the Licensor's name, trademarks, logos or other distinctive signs, including the name "Sharadox", except as strictly necessary to comply with the duty to include the Notice. Using them to promote or suggest the Licensor's endorsement of Derivative Works or of any products or services without prior written permission is prohibited.
38
+
39
+ ## 5. Disclaimer of warranties
40
+
41
+ The Work is provided "as is" and "as available", without any warranty, express or implied, including in particular warranties of merchantability, fitness for a particular purpose, absence of errors or non-infringement of third-party rights, to the maximum extent permitted by applicable law.
42
+
43
+ ## 6. Limitation of liability
44
+
45
+ 1. To the maximum extent permitted by applicable law, the Licensor is not liable for any damages, direct or indirect, including loss of profits, loss of data or business interruption, arising from the use of or inability to use the Work, even if advised of the possibility of such damages.
46
+ 2. Nothing in this license excludes or limits the Licensor's liability where such exclusion or limitation is not permitted by law, in particular for acts committed with intent or gross negligence, under article 809 and article 800(2) of the Portuguese Civil Code, nor does it affect rights that the law mandatorily grants to consumers.
47
+
48
+ ## 7. Termination
49
+
50
+ 1. The rights granted by this license terminate automatically if the Licensee breaches any of its conditions.
51
+ 2. The rights are reinstated if the breach is remedied within 30 days of the Licensee becoming aware of it, unless the Licensor has meanwhile objected in writing.
52
+ 3. Termination does not affect licenses validly granted by the Licensee to third parties who comply with this license.
53
+
54
+ ## 8. Governing law and jurisdiction
55
+
56
+ 1. This license is governed by Portuguese law, in particular the Code of Copyright and Related Rights, approved by Decree-Law no. 63/85 of 14 March, and Decree-Law no. 252/94 of 20 October on the legal protection of computer programs.
57
+ 2. The Judicial Court of the District of Faro has jurisdiction over any dispute arising from this license, without prejudice to applicable mandatory rules of jurisdiction, in particular those protecting consumers.
58
+
59
+ ## 9. License versions
60
+
61
+ The Licensor may publish new versions of this license, identified by a version number. The Work is subject to the version stated in the Notice. If the Notice allows it, the Licensee may choose any later version.
62
+
63
+ ## 10. Final provisions
64
+
65
+ 1. If any provision of this license is held invalid or unenforceable, the remaining provisions stay in force, and the affected provision shall be interpreted as closely as possible to its original intent.
66
+ 2. Failure to enforce any provision of this license at any time does not waive the right to enforce it later.
67
+
68
+ ## How to apply this license
69
+
70
+ Include in the Work a `LICENCA.md` file with the Portuguese text, this translation as `LICENSE.md`, and the following notice, filling in the year and holder:
71
+
72
+ ```
73
+ Direitos de autor © <ano> <titular>.
74
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
75
+ https://github.com/Sharadox/sharadox-open-source-license
76
+ ```
package/NOTICE.md ADDED
@@ -0,0 +1,3 @@
1
+ Direitos de autor © 2026 Micael Pires (Sharadox).
2
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
3
+ https://github.com/Sharadox/sharadox-open-source-license
package/README.md CHANGED
@@ -1,3 +1,46 @@
1
- # Temporary Holding Version
1
+ # @sharadox/pointer-web-library
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Pointer effects for React websites:
4
+
5
+ - **`useSpotlight`:** the pointer's position inside an element as `--pointer-x` and `--pointer-y`, for lights that follow it.
6
+ - **`useTilt(maximum)`:** `--tilt-x` and `--tilt-y` in degrees, for a 3D tilt towards the pointer. It eases back when the pointer leaves, and is off on touch screens.
7
+ - **`<Cursor>`:** a dot and a lagging ring. The ring grows over clickable elements and turns dashed over draggable ones. It uses blend mode `difference`, so it shows on any background, and only runs on fine pointers.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pnpm add @sharadox/pointer-web-library
13
+ ```
14
+
15
+ ## Use
16
+
17
+ ```tsx
18
+ const card = useSpotlight<HTMLElement>();
19
+ <article ref={card} className={styles.card} />;
20
+ // .card::before { background: radial-gradient(400px circle at var(--pointer-x) var(--pointer-y), …) }
21
+ ```
22
+
23
+ ```tsx
24
+ const stage = useTilt<HTMLDivElement>(6);
25
+ // .stage { transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) }
26
+ ```
27
+
28
+ ```tsx
29
+ <Cursor grabSelector="canvas, [data-grab]" />
30
+ ```
31
+
32
+ ## API
33
+
34
+ | Import | Export |
35
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
36
+ | `…/spotlight` | `useSpotlight<T>()` → reference |
37
+ | `…/tilt` | `useTilt<T>(maximum = 8)` → reference |
38
+ | `…/cursor` | `<Cursor hotSelector? grabSelector? className?>`, `HOT_ELEMENTS`, `GRAB_ELEMENTS`; CSS variables `--cursor-color` and `--cursor-size` |
39
+
40
+ ## Develop
41
+
42
+ `pnpm verify` runs formatting, lint, type-check, tests with 100% coverage and the build. Branches follow `<feature>.development` → `development` → `index`, and releases are `v<version>` tags on `index`.
43
+
44
+ ## License
45
+
46
+ Licença Sharadox de Código Aberto, versão 0.1.0. See [português](LICENCA.md) (the binding text) and the [English translation](LICENSE.md).
@@ -0,0 +1,15 @@
1
+ import type { CursorProperties } from "@sharadox/pointer-web-library/cursor/type";
2
+ /** Where the ring grows by default: anything clickable or typed into. */
3
+ export declare const HOT_ELEMENTS = "a, button, input, textarea, select, label, [data-hot]";
4
+ /** Where the ring shows "drag" by default. */
5
+ export declare const GRAB_ELEMENTS = "canvas, [data-grab]";
6
+ /**
7
+ * A custom cursor on fine pointers (mice, trackpads): a dot and a ring that follows with a slight lag, grows over
8
+ * clickable elements and turns dashed over draggable ones. White with `mix-blend-mode: difference`, so it shows on
9
+ * any background; restyle it with `--cursor-color`, `--cursor-size` and `className`. Touch screens keep their own.
10
+ *
11
+ * @example
12
+ * <Cursor grabSelector="canvas, [data-grab], .gallery" />
13
+ */
14
+ export declare function Cursor({ hotSelector, grabSelector, className }: CursorProperties): import("react").JSX.Element;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/cursor/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAElF,yEAAyE;AACzE,eAAO,MAAM,YAAY,0DAA0D,CAAC;AACpF,8CAA8C;AAC9C,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EAAE,WAA0B,EAAE,YAA4B,EAAE,SAAS,EAAE,EAAE,gBAAgB,+BAwC/G"}
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { classNames } from "@sharadox/web-library/class-name";
5
+ import styles from "./index.module.css";
6
+ /** Where the ring grows by default: anything clickable or typed into. */
7
+ export const HOT_ELEMENTS = "a, button, input, textarea, select, label, [data-hot]";
8
+ /** Where the ring shows "drag" by default. */
9
+ export const GRAB_ELEMENTS = "canvas, [data-grab]";
10
+ /**
11
+ * A custom cursor on fine pointers (mice, trackpads): a dot and a ring that follows with a slight lag, grows over
12
+ * clickable elements and turns dashed over draggable ones. White with `mix-blend-mode: difference`, so it shows on
13
+ * any background; restyle it with `--cursor-color`, `--cursor-size` and `className`. Touch screens keep their own.
14
+ *
15
+ * @example
16
+ * <Cursor grabSelector="canvas, [data-grab], .gallery" />
17
+ */
18
+ export function Cursor({ hotSelector = HOT_ELEMENTS, grabSelector = GRAB_ELEMENTS, className }) {
19
+ const dot = useRef(null);
20
+ const ring = useRef(null);
21
+ useEffect(() => {
22
+ if (!window.matchMedia("(pointer: fine)").matches)
23
+ return;
24
+ const root = document.documentElement;
25
+ root.classList.add(styles.active);
26
+ let x = innerWidth / 2;
27
+ let y = innerHeight / 2;
28
+ let ringX = x;
29
+ let ringY = y;
30
+ let frame = 0;
31
+ const move = (event) => {
32
+ x = event.clientX;
33
+ y = event.clientY;
34
+ const target = event.target;
35
+ ring.current?.classList.toggle(styles.hot, !!target.closest?.(hotSelector));
36
+ ring.current?.classList.toggle(styles.grab, !!target.closest?.(grabSelector));
37
+ };
38
+ const loop = () => {
39
+ ringX += (x - ringX) * 0.18;
40
+ ringY += (y - ringY) * 0.18;
41
+ dot.current.style.transform = `translate3d(${x}px, ${y}px, 0)`;
42
+ ring.current.style.transform = `translate3d(${ringX}px, ${ringY}px, 0)`;
43
+ frame = requestAnimationFrame(loop);
44
+ };
45
+ addEventListener("pointermove", move);
46
+ frame = requestAnimationFrame(loop);
47
+ return () => {
48
+ removeEventListener("pointermove", move);
49
+ cancelAnimationFrame(frame);
50
+ root.classList.remove(styles.active);
51
+ };
52
+ }, [hotSelector, grabSelector]);
53
+ return (_jsxs(_Fragment, { children: [_jsx("div", { ref: ring, className: classNames(styles.ring, className), "aria-hidden": true }), _jsx("div", { ref: dot, className: classNames(styles.dot, className), "aria-hidden": true })] }));
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/cursor/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAGxC,yEAAyE;AACzE,MAAM,CAAC,MAAM,YAAY,GAAG,uDAAuD,CAAC;AACpF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE,YAAY,GAAG,aAAa,EAAE,SAAS,EAAoB;IAC9G,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC1C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,OAAO;YAAE,OAAO;QAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,MAAO,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,I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,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAChC,OAAO,CACL,8BACE,cAAK,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,wBAAgB,EAC7E,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,wBAAgB,IAC1E,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ /* The system cursor hides only while the custom one is running (fine pointers). */
2
+ :global(html).active,
3
+ :global(html).active * {
4
+ cursor: none !important;
5
+ }
6
+ .dot,
7
+ .ring {
8
+ --cursor-color: #fff;
9
+ --cursor-size: 34px;
10
+ position: fixed;
11
+ left: 0;
12
+ top: 0;
13
+ z-index: 1000;
14
+ pointer-events: none;
15
+ border-radius: 50%;
16
+ mix-blend-mode: difference;
17
+ display: none;
18
+ }
19
+ :global(html).active .dot,
20
+ :global(html).active .ring {
21
+ display: block;
22
+ }
23
+ .dot {
24
+ width: 6px;
25
+ height: 6px;
26
+ margin: -3px 0 0 -3px;
27
+ background: var(--cursor-color);
28
+ }
29
+ .ring {
30
+ width: var(--cursor-size);
31
+ height: var(--cursor-size);
32
+ margin: calc(var(--cursor-size) / -2) 0 0 calc(var(--cursor-size) / -2);
33
+ border: 1px solid color-mix(in srgb, var(--cursor-color) 60%, transparent);
34
+ transition:
35
+ width 0.35s cubic-bezier(0.22, 1, 0.36, 1),
36
+ height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
37
+ margin 0.35s cubic-bezier(0.22, 1, 0.36, 1),
38
+ background 0.35s;
39
+ }
40
+ .hot {
41
+ --cursor-size: 60px;
42
+ background: color-mix(in srgb, var(--cursor-color) 12%, transparent);
43
+ }
44
+ .grab {
45
+ --cursor-size: 76px;
46
+ border-style: dashed;
47
+ }
@@ -0,0 +1,9 @@
1
+ export interface CursorProperties {
2
+ /** Elements that make the ring grow (links, buttons, fields…). */
3
+ hotSelector?: string;
4
+ /** Elements that show the "drag" ring (canvases, draggable strips…). */
5
+ grabSelector?: string;
6
+ /** Extra class for the dot and the ring, to restyle them. */
7
+ className?: string;
8
+ }
9
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/cursor/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/cursor/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** Tracks the pointer inside an element as `--pointer-x`/`--pointer-y`, for lights that follow the cursor. */
2
+ export declare function useSpotlight<Target extends HTMLElement>(): import("react").RefObject<Target | null>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/spotlight/index.ts"],"names":[],"mappings":"AAGA,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,MAAM,SAAS,WAAW,8CActD"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { useEffect, useRef } from "react";
3
+ /** Tracks the pointer inside an element as `--pointer-x`/`--pointer-y`, for lights that follow the cursor. */
4
+ export function useSpotlight() {
5
+ const reference = useRef(null);
6
+ useEffect(() => {
7
+ const element = reference.current;
8
+ if (!element)
9
+ return;
10
+ const move = (event) => {
11
+ const bounds = element.getBoundingClientRect();
12
+ element.style.setProperty("--pointer-x", `${event.clientX - bounds.left}px`);
13
+ element.style.setProperty("--pointer-y", `${event.clientY - bounds.top}px`);
14
+ };
15
+ element.addEventListener("pointermove", move);
16
+ return () => element.removeEventListener("pointermove", move);
17
+ }, []);
18
+ return reference;
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/spotlight/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,8GAA8G;AAC9G,MAAM,UAAU,YAAY;IAC1B,MAAM,SAAS,GAAG,MAAM,CAAS,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAE,EAAE;YACnC,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;YAC/C,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;YAC7E,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9E,CAAC,CAAC;QACF,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tilts an element towards the pointer: sets `--tilt-x` and `--tilt-y` (degrees, up to `maximum`) while the pointer
3
+ * is over it and eases back to 0 when it leaves. Use them in CSS, for example
4
+ * `transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y))`. Off on touch screens.
5
+ */
6
+ export declare function useTilt<Target extends HTMLElement>(maximum?: number): import("react").RefObject<Target | null>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tilt/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,SAAS,WAAW,EAAE,OAAO,SAAI,4CAwB9D"}
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import { useEffect, useRef } from "react";
3
+ /**
4
+ * Tilts an element towards the pointer: sets `--tilt-x` and `--tilt-y` (degrees, up to `maximum`) while the pointer
5
+ * is over it and eases back to 0 when it leaves. Use them in CSS, for example
6
+ * `transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y))`. Off on touch screens.
7
+ */
8
+ export function useTilt(maximum = 8) {
9
+ const reference = useRef(null);
10
+ useEffect(() => {
11
+ const element = reference.current;
12
+ if (!element || !window.matchMedia("(pointer: fine)").matches)
13
+ return;
14
+ const move = (event) => {
15
+ const bounds = element.getBoundingClientRect();
16
+ const x = (event.clientX - bounds.left) / bounds.width - 0.5;
17
+ const y = (event.clientY - bounds.top) / bounds.height - 0.5;
18
+ element.style.setProperty("--tilt-x", `${(-y * maximum * 2).toFixed(2)}deg`);
19
+ element.style.setProperty("--tilt-y", `${(x * maximum * 2).toFixed(2)}deg`);
20
+ };
21
+ const leave = () => {
22
+ element.style.setProperty("--tilt-x", "0deg");
23
+ element.style.setProperty("--tilt-y", "0deg");
24
+ };
25
+ element.addEventListener("pointermove", move);
26
+ element.addEventListener("pointerleave", leave);
27
+ return () => {
28
+ element.removeEventListener("pointermove", move);
29
+ element.removeEventListener("pointerleave", leave);
30
+ };
31
+ }, [maximum]);
32
+ return reference;
33
+ }
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 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YAC9C,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC,CAAC;QACF,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACjD,OAAO,CAAC,mBAAmB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/llms.txt ADDED
@@ -0,0 +1,8 @@
1
+ # @sharadox/pointer-web-library
2
+
3
+ > Pointer effects for React.
4
+
5
+ - /spotlight: useSpotlight<T>() → ref; sets --pointer-x/--pointer-y (px) on pointermove
6
+ - /tilt: useTilt<T>(maximum=8) → ref; sets --tilt-x/--tilt-y (deg); resets on leave; fine pointers only
7
+ - /cursor: <Cursor hotSelector grabSelector className /> dot + lagging ring, mix-blend difference; --cursor-color, --cursor-size; html gets class while active (hides system cursor)
8
+ - Peer: react. License: Sharadox Open Source License 0.1.0
package/package.json CHANGED
@@ -1,6 +1,93 @@
1
1
  {
2
2
  "name": "@sharadox/pointer-web-library",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Pointer effects for React: a spotlight that follows the pointer, 3D tilt towards it and a custom cursor.",
5
+ "private": false,
6
+ "license": "SEE LICENSE IN LICENCA.md",
7
+ "author": "Sharadox <contact@sharadox.com>",
8
+ "type": "module",
9
+ "exports": {
10
+ "./*/type": {
11
+ "sharadox-source": "./source/*/type.ts",
12
+ "types": "./distribution/*/type.d.ts"
13
+ },
14
+ "./*": {
15
+ "sharadox-source": [
16
+ "./source/*/index.ts",
17
+ "./source/*/index.tsx"
18
+ ],
19
+ "types": "./distribution/*/index.d.ts",
20
+ "default": "./distribution/*/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "distribution",
25
+ "LICENCA.md",
26
+ "LICENSE.md",
27
+ "NOTICE.md",
28
+ "llms.txt"
29
+ ],
30
+ "sideEffects": [
31
+ "**/*.css"
32
+ ],
33
+ "engines": {
34
+ "node": ">=26"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "lint-staged": {
40
+ "*.{ts,tsx,js,mjs,cjs}": [
41
+ "prettier --write",
42
+ "eslint --fix --max-warnings=0"
43
+ ],
44
+ "*.{json,md,yml,yaml,scss}": "prettier --write"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/Sharadox/pointer-web-library.git"
49
+ },
50
+ "homepage": "https://github.com/Sharadox/pointer-web-library#readme",
51
+ "devDependencies": {
52
+ "@sharadox/es-lint-configuration-web-library": "^0.1.1",
53
+ "@sharadox/library-build-web-library": "^0.1.1",
54
+ "@sharadox/prettier-configuration-web-library": "^0.1.0",
55
+ "@sharadox/turborepo-configuration-web-library": "^0.1.0",
56
+ "@sharadox/type-script-configuration-web-library": "^0.2.0",
57
+ "@sharadox/vitest-configuration-web-library": "^0.1.2",
58
+ "@testing-library/dom": "^10.4.2",
59
+ "@testing-library/react": "^16.3.3",
60
+ "@types/node": "^24.19.2",
61
+ "@types/react": "^19.3.0",
62
+ "@types/react-dom": "^19.3.0",
63
+ "@vitest/coverage-v8": "^5.1.0",
64
+ "eslint": "9.39.5",
65
+ "happy-dom": "^21.0.4",
66
+ "husky": "^9.1.7",
67
+ "lint-staged": "^17.6.0",
68
+ "prettier": "^3.10.0",
69
+ "react": "^19.3.1",
70
+ "react-dom": "^19.3.1",
71
+ "turbo": "^2.11.10",
72
+ "typedoc": "^0.28.20",
73
+ "typescript": "6.0.3",
74
+ "vitest": "^5.1.0"
75
+ },
76
+ "dependencies": {
77
+ "@sharadox/web-library": "^0.5.0"
78
+ },
79
+ "peerDependencies": {
80
+ "react": ">=19"
81
+ },
82
+ "scripts": {
83
+ "build": "library-build",
84
+ "lint": "eslint --max-warnings=0 .",
85
+ "format": "prettier --write .",
86
+ "format:check": "prettier --check .",
87
+ "type-check": "tsc --noEmit",
88
+ "test:unit": "vitest run --coverage",
89
+ "documentation": "typedoc",
90
+ "verify": "turbo run format:check lint type-check test:unit build",
91
+ "test:benchmark": "vitest bench --run --passWithNoTests"
92
+ }
6
93
  }