@hydrateless/react 0.10.1 → 0.11.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 +20 -15
- package/dist/client.d.ts +760 -0
- package/dist/client.js +1121 -0
- package/dist/index.d.ts +2 -939
- package/dist/index.js +2 -1422
- package/dist/server.d.ts +216 -0
- package/dist/server.js +244 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -45,25 +45,30 @@ value during render, so server output is correct before hydration.
|
|
|
45
45
|
|
|
46
46
|
### Server Components
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
Static, hook-free components are split into `@hydrateless/react/server` (no
|
|
49
|
+
`'use client'` directive), while interactive components and hooks live in
|
|
50
|
+
`@hydrateless/react/client` (`'use client'`). The root entry re-exports both
|
|
51
|
+
without `'use client'` on the barrel, so importing static components like
|
|
52
|
+
`Button`, `Card`, `Badge`, `Breadcrumb`, or `ModalTrigger` into a React Server
|
|
53
|
+
Component creates no client boundary.
|
|
51
54
|
|
|
52
|
-
### Dialogs
|
|
55
|
+
### Dialogs and overlay triggers
|
|
53
56
|
|
|
54
57
|
`Modal` and `Drawer` are built on the native `<dialog>` element plus the modal
|
|
55
58
|
enhancer (focus trap, scroll-lock, background `inert`). Escape and backdrop
|
|
56
59
|
clicks report back through `onOpenChange`. `Drawer` takes `side="start" | "end"`
|
|
57
|
-
(default `end`), which follows the writing direction.
|
|
60
|
+
(default `end`), which follows the writing direction. Use `ModalTrigger`,
|
|
61
|
+
`DrawerTrigger`, and `PopoverTrigger` for declarative invokers that work before
|
|
62
|
+
React hydrates:
|
|
58
63
|
|
|
59
64
|
```tsx
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<button onClick={() => setOpen(true)}>Open</button>
|
|
63
|
-
<Modal open={open} onOpenChange={setOpen}>
|
|
65
|
+
<ModalTrigger target="confirm" className="hl-button">Open</ModalTrigger>
|
|
66
|
+
<Modal id="confirm">
|
|
64
67
|
<ModalHeader>Title</ModalHeader>
|
|
65
68
|
<ModalBody>Body content.</ModalBody>
|
|
66
|
-
<ModalFooter
|
|
69
|
+
<ModalFooter>
|
|
70
|
+
<ModalTrigger target="confirm" command="close" className="hl-button">Close</ModalTrigger>
|
|
71
|
+
</ModalFooter>
|
|
67
72
|
</Modal>;
|
|
68
73
|
```
|
|
69
74
|
|
|
@@ -179,10 +184,10 @@ function Save() {
|
|
|
179
184
|
## Escape hatch: `useEnhancer`
|
|
180
185
|
|
|
181
186
|
For your own markup, attach any enhancer with `useEnhancer(ref, enhancer,
|
|
182
|
-
options, deps)`. It
|
|
183
|
-
|
|
184
|
-
always call the handler from the
|
|
185
|
-
listed in `deps`.
|
|
187
|
+
options, deps)`. It attaches once on mount, destroys on unmount, and updates
|
|
188
|
+
options in place via `handle.update()` when `deps` change so open overlays and
|
|
189
|
+
active state stay intact. Callback options always call the handler from the
|
|
190
|
+
latest render, so they never need to be listed in `deps`.
|
|
186
191
|
|
|
187
192
|
```tsx
|
|
188
193
|
import { useRef } from 'react';
|
|
@@ -194,7 +199,7 @@ function CustomTabs() {
|
|
|
194
199
|
const api = useEnhancer(ref, enhanceTabs, { activation: 'automatic', onValueChange: log });
|
|
195
200
|
// api.current?.setValue('install')
|
|
196
201
|
return (
|
|
197
|
-
<div data-hl-tabs ref={ref}>
|
|
202
|
+
<div className="hl-tabs" data-hl-tabs ref={ref}>
|
|
198
203
|
{/* tablist + tabpanels */}
|
|
199
204
|
</div>
|
|
200
205
|
);
|