@puzzle-ui/hooks 0.4.0 → 0.5.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/README.md +23 -86
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,99 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
title: Getting Started
|
|
3
|
-
description: Install Puzzle in your React app, build your first interface, and customize the theme.
|
|
4
|
-
---
|
|
1
|
+
# @puzzle-ui/hooks
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
> This project is under active development. APIs, component props,
|
|
9
|
-
> package exports, styling, and internal implementation may change
|
|
10
|
-
> without notice. Components may be incomplete, and testing,
|
|
11
|
-
> accessibility, documentation, and framework compatibility are not yet
|
|
12
|
-
> guaranteed. Use it for experimentation and evaluation only---not for
|
|
13
|
-
> production applications.
|
|
3
|
+
Reusable React hooks for keyboard shortcuts and accessible roving focus. Use this package when an application needs low-level keyboard or focus behavior without taking on a component or styling dependency.
|
|
14
4
|
|
|
15
|
-
|
|
5
|
+
**Documentation: [puzzle-ui.com/docs/hooks](https://puzzle-ui.com/docs/hooks)**
|
|
16
6
|
|
|
17
|
-
|
|
7
|
+
## Install
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Set up a new project
|
|
26
|
-
|
|
27
|
-
Simple run our @puzzle-ui/create project template to get started.
|
|
28
|
-
|
|
29
|
-
npm:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npx @puzzle-ui/create
|
|
9
|
+
```sh
|
|
10
|
+
npm install @puzzle-ui/hooks
|
|
11
|
+
# or: bun add @puzzle-ui/hooks
|
|
12
|
+
# or: pnpm add @puzzle-ui/hooks
|
|
13
|
+
# or: yarn add @puzzle-ui/hooks
|
|
33
14
|
```
|
|
34
15
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
bunx @puzzle-ui/create
|
|
39
|
-
```
|
|
16
|
+
Requires React `^19.0.0` as a peer dependency.
|
|
40
17
|
|
|
41
|
-
|
|
18
|
+
## Usage
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- Next.js
|
|
46
|
-
|
|
47
|
-
Furthermore you can choose to install tailwindcss or not.
|
|
48
|
-
It directly installs all dependencies and sets up the project for you.
|
|
49
|
-
|
|
50
|
-
## Set up in an existing project:
|
|
51
|
-
|
|
52
|
-
Install the UI library and theme package in your application's directory. Choose your package manager below:
|
|
53
|
-
|
|
54
|
-
npm:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm install @puzzle-ui/ui --save
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
bun:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
bun add @puzzle-ui/create
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
pnpm:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
pnpm add @puzzle-ui/ui
|
|
70
|
-
```
|
|
20
|
+
```tsx
|
|
21
|
+
import { useKeyboardKeys } from "@puzzle-ui/hooks";
|
|
71
22
|
|
|
72
|
-
|
|
23
|
+
function EscapeShortcut({ close }: { close: () => void }) {
|
|
24
|
+
useKeyboardKeys({
|
|
25
|
+
keys: ["Escape"],
|
|
26
|
+
onKeyDown: () => close(),
|
|
27
|
+
enabled: true,
|
|
28
|
+
});
|
|
73
29
|
|
|
74
|
-
|
|
75
|
-
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
76
32
|
```
|
|
77
33
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
## Your first interface
|
|
81
|
-
|
|
82
|
-
Import components from `"@puzzle-ui/ui` and wrap your application in `Theme` from `"@puzzle-ui/theme`:
|
|
34
|
+
`useKeyboardKeys` subscribes to selected global keydown/keyup events and reports modifier state. `useRovingFocus` provides roving `tabIndex`, element refs, focus management, and arrow/Home/End navigation for composite widgets. Both hooks and their public types are exported from the package root; React is the only peer dependency.
|
|
83
35
|
|
|
84
|
-
|
|
85
|
-
import { Theme } from "@puzzle-ui/theme";
|
|
86
|
-
import { Button } from "@puzzle-ui/ui";
|
|
87
|
-
|
|
88
|
-
export const App = () => (
|
|
89
|
-
<Theme>
|
|
90
|
-
<main>
|
|
91
|
-
<h1>Hello, Puzzle</h1>
|
|
92
|
-
<p>Build your interface with reusable components and shared tokens.</p>
|
|
93
|
-
<Button onClick={() => window.alert("Welcome to Puzzle!")}>
|
|
94
|
-
Get started
|
|
95
|
-
</Button>
|
|
96
|
-
</main>
|
|
97
|
-
</Theme>
|
|
98
|
-
);
|
|
99
|
-
```
|
|
36
|
+
See the [hooks documentation](https://puzzle-ui.com/docs/hooks) for complete signatures, options, return values, examples, SSR guidance, and accessibility notes.
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puzzle-ui/hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Reusable React hooks for Puzzle",
|
|
5
|
+
"homepage": "https://puzzle-ui.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/senorprogramador/puzzle.git"
|
|
9
|
+
},
|
|
5
10
|
"license": "MIT",
|
|
6
11
|
"publishConfig": {
|
|
7
12
|
"access": "public",
|
|
@@ -34,7 +39,7 @@
|
|
|
34
39
|
"prepack": "tsdown"
|
|
35
40
|
},
|
|
36
41
|
"dependencies": {
|
|
37
|
-
"@puzzle-ui/core": "^0.
|
|
42
|
+
"@puzzle-ui/core": "^0.5.1"
|
|
38
43
|
},
|
|
39
44
|
"peerDependencies": {
|
|
40
45
|
"react": "^19.0.0"
|
|
@@ -43,6 +48,6 @@
|
|
|
43
48
|
"@types/react": "^19.0.0",
|
|
44
49
|
"react": "^19.0.0",
|
|
45
50
|
"tsdown": "^0.23.1",
|
|
46
|
-
"typescript": "^
|
|
51
|
+
"typescript": "^7.0.2"
|
|
47
52
|
}
|
|
48
53
|
}
|