fine-modal-react 1.0.4 → 1.0.5

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.
Files changed (2) hide show
  1. package/README.md +27 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -20,10 +20,10 @@ Peer deps: `react` and `react-dom` (19.x).
20
20
  4) Choose mounting strategy:
21
21
  - Global host: create `ModalHost = FineModal.createHost({ modals })` near root.
22
22
  - Local: render the modal component where you need it.
23
- 5) Call `open`:
24
- - `FineModal.open('ModalId', props?)` for global host.
25
- - `SomeModal.open(props?)` for colocated modal.
26
- Resolves with the value from `onConfirm`, or `null` on `onCancel/close`.
23
+ 5) Call `open` (typed both ways):
24
+ - `FineModal.open('ModalId', props?)` uses registered ids/props/result from `modals`.
25
+ - `SomeModal.open(props?)` uses the component’s props/result.
26
+ Both resolve to the `onConfirm` value, or `null` on `onCancel/close`.
27
27
 
28
28
  ## Define a modal (shared for both strategies)
29
29
 
@@ -116,6 +116,29 @@ export function App() {
116
116
  }
117
117
  ```
118
118
 
119
+ ## Type safety (global & local)
120
+
121
+ ```ts
122
+ // Global host: ids/props/result inferred from registered modals
123
+ const result = await FineModal.open('ConfirmInviteModal', { email: 'team@org.com' })
124
+ // ^? result is "sent" | null
125
+
126
+ // TS error: missing required prop "email"
127
+ FineModal.open('ConfirmInviteModal')
128
+
129
+ // TS error: unknown modal id
130
+ FineModal.open('UnknownModal')
131
+ ```
132
+
133
+ ```ts
134
+ // Local modal: props/result inferred from component definition
135
+ const result = await ConfirmInviteModal.open({ email: 'new.user@org.com' })
136
+ // ^? result is "sent" | null
137
+
138
+ // TS error: email must be a string
139
+ ConfirmInviteModal.open({ email: 42 })
140
+ ```
141
+
119
142
  ## Option B: Local modal component (colocated scope)
120
143
 
121
144
  Render the modal component where you need it; open it via its static API. This avoids a global host if you only need the modal in one subtree.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fine-modal-react",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "description": "Typed, promise-based modal utilities for React 19+.",
6
6
  "author": "lorof",
7
7
  "license": "MIT",