promise-portal 1.0.0 → 1.0.1

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 +41 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # promise-portal
2
2
 
3
+ let you use react portal in vue, and with promise
4
+
3
5
  ## Install
4
6
 
5
7
  ```bash
@@ -15,6 +17,45 @@ yarn add promise-portal --D
15
17
 
16
18
  ## Use
17
19
 
20
+ ### install in the entry file
21
+
22
+ ```ts
23
+ // ./main.ts
24
+ import { createPromisePortal } from 'promise-portal'
25
+
26
+ const app = createApp(App)
27
+ app.use(createVuePortal())
28
+ ```
29
+
30
+ ### in component, use `usePortalContext` to get portal context
31
+
32
+ ```ts
33
+ // ./components/name.vue
34
+ import { usePortalContext } from 'promise-portal'
35
+
36
+ const { resolve } = usePortalContext<Output>()
37
+ const onClose = () => {
38
+ resolve({ confirm: false, fullName: '' })
39
+ }
40
+ ```
41
+
42
+ ### define portal, use it like a promise-style function
43
+
44
+ ```ts
45
+ // ./App.vue
46
+ import { definePortal } from 'promise-portal'
47
+ import Comp, { Input, Output } from './components/name.vue'
48
+
49
+ const func = definePortal<Output, Input>(Comp)
50
+ const onClick = async () => {
51
+ const data = await func({ firstName: 'joe', lastName: 'watson' })
52
+ if (!data.confirm) {
53
+ return
54
+ }
55
+ console.log(data)
56
+ }
57
+ ```
58
+
18
59
  ## Reference
19
60
 
20
61
  [@filez/portal](https://github.com/lenovo-filez/portal)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promise-portal",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "a vite plugin to load svg icon for element-plus",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",