@puzzle-ui/hooks 0.3.0 → 0.4.0
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 +73 -56
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,82 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: Getting Started
|
|
3
|
+
description: Install Puzzle in your React app, build your first interface, and customize the theme.
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
> \[!WARNING\] **Puzzle is not ready for production use.**
|
|
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.
|
|
5
14
|
|
|
6
|
-
|
|
7
|
-
> for experimentation and evaluation rather than production applications.
|
|
15
|
+
Puzzle is a TypeScript and React UI component library built around reusable components and shared design tokens. Its components are composable and router-independent, with styling supplied by `"@puzzle-ui/theme`. The framework is setup to be compatible with `Next.js`, `Tanstack Start` and `react-router`.
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
**Puzzle is under active development and is not ready for production use.** APIs, props, exports, and styling may change without notice. Accessibility and framework compatibility are still being tested. Use the project for experimentation and evaluation.
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
npm install @puzzle-ui/hooks
|
|
13
|
-
# or
|
|
14
|
-
bun add @puzzle-ui/hooks
|
|
15
|
-
# or
|
|
16
|
-
pnpm add @puzzle-ui/hooks
|
|
17
|
-
# or
|
|
18
|
-
yarn add @puzzle-ui/hooks
|
|
19
|
-
```
|
|
19
|
+
## Prerequisites
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
- A package manager: npm, Bun, pnpm, or Yarn.
|
|
22
|
+
- An existing React application with a bundler that supports CSS imports, such as Vite.
|
|
23
|
+
- Familiarity with React and TypeScript. The UI and theme packages require React and React DOM 19 or later within the supported React 19 range.
|
|
22
24
|
|
|
23
|
-
##
|
|
25
|
+
## Set up a new project
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
listeners when disabled or unmounted.
|
|
27
|
+
Simple run our @puzzle-ui/create project template to get started.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
"use client";
|
|
29
|
+
npm:
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
```bash
|
|
32
|
+
npx @puzzle-ui/create
|
|
33
|
+
```
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
useKeyboardKeys({
|
|
35
|
-
keys: ["Escape"],
|
|
36
|
-
onKeyDown: () => console.log("Escape pressed"),
|
|
37
|
-
});
|
|
35
|
+
bun:
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
```bash
|
|
38
|
+
bunx @puzzle-ui/create
|
|
41
39
|
```
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
Puzzle can set up a new project for you with the following framework options:
|
|
42
|
+
|
|
43
|
+
- Basic React app
|
|
44
|
+
- Tanstack start
|
|
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:
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
Install the UI library and theme package in your application's directory. Choose your package manager below:
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
IDs. It supports horizontal, vertical, or both orientations, RTL direction,
|
|
52
|
-
looping, disabled items, and an initial active ID.
|
|
54
|
+
npm:
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
```bash
|
|
57
|
+
npm install @puzzle-ui/ui --save
|
|
58
|
+
```
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
the appropriate roles, accessible names, and selection behavior yourself.
|
|
60
|
+
bun:
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
```bash
|
|
63
|
+
bun add @puzzle-ui/create
|
|
64
|
+
```
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
components. In React Server Component applications, use a `"use client"`
|
|
65
|
-
module for interactive consumers. ESM and CommonJS builds and their
|
|
66
|
-
TypeScript declarations are included.
|
|
66
|
+
pnpm:
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
```bash
|
|
69
|
+
pnpm add @puzzle-ui/ui
|
|
70
|
+
```
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
yarn:
|
|
71
73
|
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
+
```bash
|
|
75
|
+
yarn add @puzzle-ui/ui
|
|
74
76
|
```
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
before packing or publishing. See the root
|
|
78
|
-
[publishing guide](../../README.md#publishing-packages).
|
|
78
|
+
These commands install published packages; they do not clone the repository or build its workspaces. Puzzle does not require Bun in your application. React and React DOM are peer dependencies and should already be installed in your app.
|
|
79
79
|
|
|
80
|
-
##
|
|
80
|
+
## Your first interface
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
Import components from `"@puzzle-ui/ui` and wrap your application in `Theme` from `"@puzzle-ui/theme`:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
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
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puzzle-ui/hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Reusable React hooks for Puzzle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsdown",
|
|
32
|
+
"typecheck": "tsc --noEmit -p .",
|
|
32
33
|
"clean": "rm -rf dist",
|
|
33
34
|
"prepack": "tsdown"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@puzzle-ui/core": "^0.
|
|
37
|
+
"@puzzle-ui/core": "^0.4.0"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"react": "^19.0.0"
|