create-packer 1.17.7 → 1.17.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.17.7",
3
+ "version": "1.17.9",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -37,7 +37,7 @@ export async function create<P extends Record<string, any>, Refs extends Record<
37
37
  },
38
38
  $updateProps: newProps => {
39
39
  if (newProps) {
40
- setState(state => ({ ...state, ...props }))
40
+ setState(state => ({ ...state, ...newProps }))
41
41
  }
42
42
  },
43
43
  ...ref.current
@@ -1,20 +1,30 @@
1
1
  import { createVNode, render, VNodeChild } from 'vue'
2
- import { assign } from 'lodash-es'
3
- import app from '@/providers/app'
2
+ import { assign, keys } from 'lodash-es'
3
+ import app from './app'
4
4
 
5
5
  const store = new Map()
6
- export default function createModal<
6
+
7
+ function reset(oldObj: Record<string, any>, newObj: Record<string, any>) {
8
+ keys(oldObj).forEach(k => {
9
+ oldObj[k] = void 0
10
+ })
11
+ assign(oldObj, newObj)
12
+ }
13
+
14
+ export default function createComponentInstance<
7
15
  P extends Record<string, any>,
8
16
  E extends Record<string, any>,
9
17
  Slots extends Record<string, () => VNodeChild> = Record<string, () => VNodeChild>
10
18
  >(name: string, component: any, props?: P, slots?: Slots) {
11
19
  let vNode = store.get(name)
12
20
  function updateProps(props: Partial<P>) {
13
- assign(vNode.component.props, props)
21
+ reset(vNode.component.props, props)
14
22
  }
15
- function updateSlots(slots?: Partial<Record<string, () => VNodeChild>>) {
16
- assign(vNode.component.slots, slots)
23
+
24
+ function updateSlots(slots: Partial<Record<string, () => VNodeChild>>) {
25
+ reset(vNode.component.slots, slots)
17
26
  }
27
+
18
28
  if (!vNode) {
19
29
  const container = document.createElement('div')
20
30
  vNode = createVNode(component, props, slots)
@@ -23,7 +33,7 @@ export default function createModal<
23
33
  render(vNode, container)
24
34
  } else {
25
35
  updateProps(props || {})
26
- updateSlots(slots)
36
+ updateSlots(slots || {})
27
37
  }
28
38
  return {
29
39
  instance: vNode,
@@ -1,3 +1,3 @@
1
1
  export { default as app } from './app'
2
- export { default as createModalVNode } from './createModalVNode'
2
+ export { default as createComponentInstance } from './createComponentInstance'
3
3
  export { default as request } from './request'