@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 CHANGED
@@ -45,25 +45,30 @@ value during render, so server output is correct before hydration.
45
45
 
46
46
  ### Server Components
47
47
 
48
- The package is a client bundle: `'use client'` is embedded at the top of the
49
- built module, so you can import any component from a React Server Components
50
- app (Next.js App Router, for example) without wrapping it yourself.
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
- const [open, setOpen] = useState(false);
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><button onClick={() => setOpen(false)}>Close</button></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 returns a ref to the enhancer's imperative API, destroys
183
- the instance on unmount, and re-creates it when `deps` change. Callback options
184
- always call the handler from the latest render, so they never need to be
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
  );