@rexezuge/web 1.0.1 → 1.0.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/README.md +67 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @rexezuge/web
|
|
2
|
+
|
|
3
|
+
React UI primitives, hooks, and API client for the family SPAs.
|
|
4
|
+
|
|
5
|
+
Depends on `@rexezuge/errors` (every rejection is a `ServiceError`) and `@rexezuge/shared`. Peer-depends on `react` + `react-dom` 19 — the kit stays version-agnostic and the app owns the renderer.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @rexezuge/web
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Components
|
|
14
|
+
|
|
15
|
+
Class-based primitives over the CSS variables every Tailwind consumer already defines (`--color-accent`, `--color-surface-*`, `--color-text-*`, `--color-{success,error,warning,info,neutral}-{bg,text}`); `Spinner` (and `Button`'s busy state) additionally needs `animate-spin`.
|
|
16
|
+
|
|
17
|
+
| Export | Notes |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `Button` / `LoadingButton` | variants + sizes via `buttonClass`; loading state with spinner |
|
|
20
|
+
| `Badge` | `badgeClass` / `badgeVariantClass` status pills |
|
|
21
|
+
| `Card`, `CardHeader`, `CardTitle` | layout shells |
|
|
22
|
+
| `Input`, `Label`, `Select`, `Textarea`, `FocusInput` | form controls, `fieldClass` shared styling |
|
|
23
|
+
| `Pagination` (+ `pageWindow`, `pageCountFor`, `clampPage`) | windowed page navigation |
|
|
24
|
+
| `Spinner` | standalone busy indicator |
|
|
25
|
+
| `theme` (+ `buttonColors`, `inputStyle`, …) | legacy inline-style escape hatch |
|
|
26
|
+
| `cn` | conditional class join |
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Button, Card, CardHeader, CardTitle, useNotice } from '@rexezuge/web';
|
|
30
|
+
|
|
31
|
+
function Panel() {
|
|
32
|
+
const { notices, showNotice } = useNotice();
|
|
33
|
+
return (
|
|
34
|
+
<Card>
|
|
35
|
+
<CardHeader><CardTitle>Tokens</CardTitle></CardHeader>
|
|
36
|
+
<Button onClick={() => showNotice('Saved', { kind: 'success' })}>Save</Button>
|
|
37
|
+
</Card>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 2. Hooks
|
|
43
|
+
|
|
44
|
+
- **`useNotice`** — timed notice stack (`NOTICE_TIMEOUT_MS`, `COPY_FEEDBACK_TIMEOUT_MS`); `showNotice` returns a dismiss handle.
|
|
45
|
+
- **`useSpaLanguage`** — `localStorage`-persisted language with `Accept-Language` default (`DEFAULT_SUPPORTED_LANGUAGES`, `resolveLanguageTag`, `canonicalizeLanguageTag`).
|
|
46
|
+
- **`useCurrentUser`** — fetches `CURRENT_USER_PATH` (`/user`), with loading/error states for shell gating.
|
|
47
|
+
|
|
48
|
+
## 3. API client
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createApiClient } from '@rexezuge/web';
|
|
52
|
+
|
|
53
|
+
const api = createApiClient({ baseUrl: '', fetchFn: fetch });
|
|
54
|
+
const me = await api.get('/user'); // typed JSON; 204/empty bodies resolve to undefined
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Every rejection is a `ServiceError` with `status` / `type` / `retryable`, decoded from the family `{ Exception: { Type, Message } }` envelope first, then the legacy `{ error, message }` shape; markup bodies are treated as absent and messages truncate at `MAX_ERROR_MESSAGE_LENGTH` (500). `buildQuery` encodes `QueryParams`. Deliberately excluded: the D1 bookmark header, the authed-first public fallback, WebDAV `207` handling, and per-app `SUPPORTED_LANGUAGES` — each had exactly one consumer, so each stays with it.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Verifying this package
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pnpm --filter @rexezuge/web exec tsc -p tsconfig.json
|
|
65
|
+
pnpm --filter @rexezuge/web typecheck
|
|
66
|
+
pnpm --filter @rexezuge/web test
|
|
67
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@rexezuge/errors": "1.0.
|
|
29
|
-
"@rexezuge/shared": "1.0.
|
|
28
|
+
"@rexezuge/errors": "1.0.2",
|
|
29
|
+
"@rexezuge/shared": "1.0.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^19.3.0",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"typescript": "6.0.3",
|
|
47
47
|
"vitest": "4.1.11"
|
|
48
48
|
},
|
|
49
|
+
"description": "React UI primitives, hooks, and API client for the family SPAs.",
|
|
49
50
|
"scripts": {
|
|
50
51
|
"build": "tsc -p tsconfig.json",
|
|
51
52
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|