npmapps 1.0.16 → 1.0.18

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "npmapps",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
+ "description": "",
4
5
  "main": "index.js",
5
6
  "scripts": {
6
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -8,5 +9,5 @@
8
9
  "keywords": [],
9
10
  "author": "",
10
11
  "license": "ISC",
11
- "description": ""
12
+ "type": "commonjs"
12
13
  }
Binary file
package/app/jsx/com.vue DELETED
@@ -1,44 +0,0 @@
1
- <script lang="jsx">
2
- import { defineComponent, Fragment } from 'vue'
3
- import { ElButton } from 'element-plus'
4
- import { useRouter, useRoute } from 'vue-router'
5
-
6
- export default defineComponent({
7
- name: 'ComView',
8
- setup(props, { slots, emit ,attrs}) {
9
- console.log(props, 'props');
10
- console.log(attrs, 'attrs');
11
- const router = useRouter()
12
- console.log(router, 'router');
13
- const goHome = () => {
14
- router.push('/')
15
- }
16
- const route = useRoute()
17
- console.log(route, 'route');
18
-
19
- return () => (
20
- <>
21
- <div>ComView</div>
22
- <div>props: {attrs.count}</div>
23
- <ElButton
24
- type="primary"
25
- onClick={() => {
26
- attrs.dialog.close()
27
- }}
28
- >
29
- close dialog
30
- </ElButton>
31
- <ElButton
32
- type="primary"
33
- onClick={() => {
34
- goHome()
35
- attrs.dialog.close()
36
- }}
37
- >
38
- go home
39
- </ElButton>
40
- </>
41
- )
42
- }
43
- })
44
- </script>
@@ -1,66 +0,0 @@
1
- import { defineComponent, ref, h, render } from 'vue'
2
- import { ElDialog, ElButton } from 'element-plus'
3
-
4
- export const openDialog = (options = {}, appContext) => {
5
- const {
6
- props = {},
7
- events = {},
8
- slots = {}
9
- } = options
10
-
11
- const container = document.createElement('div')
12
- document.body.appendChild(container)
13
-
14
- let vnode
15
- const visible = ref(true)
16
- const DialogHost = defineComponent({
17
- name: 'FunctionDialogHost',
18
- setup(props,{expose}) {
19
- const handleSlot = () => {
20
- const slotList = {}
21
- for (const slotName in slots) {
22
- if (slots.hasOwnProperty(slotName)) {
23
- const slot = slots[slotName]
24
- if (slot) {
25
- slotList[slotName] = slot()
26
- }
27
- }
28
- }
29
- return slotList
30
- }
31
- const cleanup = () => {
32
- try {
33
- render(null, container)
34
- } catch {}
35
- if (container && container.parentNode) {
36
- container.parentNode.removeChild(container)
37
- }
38
- }
39
-
40
- // 返回 JSX 渲染函数
41
- return () => (
42
- <ElDialog
43
- modelValue={visible.value}
44
- onUpdate:modelValue={(v) => { visible.value = v }}
45
- {...props}
46
- {...events}
47
- destroyOnClose={true}
48
- onClosed={cleanup}
49
- >
50
- {handleSlot()}
51
- </ElDialog>
52
- )
53
- }
54
- })
55
- vnode = h(DialogHost)
56
- if (appContext) vnode.appContext = appContext
57
- render(vnode, container)
58
- const close = () => {
59
- visible.value = false
60
- }
61
- return {
62
- close,
63
- }
64
- }
65
-
66
- export default openDialog
package/app/jsx/index.vue DELETED
@@ -1,65 +0,0 @@
1
- <script lang="jsx">
2
- import { defineComponent, ref, h, Fragment, getCurrentInstance } from "vue";
3
- import PropsView from "./props.vue";
4
- import openDialog from "./dialog.jsx";
5
- import ComView from "./com.vue";
6
-
7
- export default defineComponent({
8
- name: "JsxView",
9
- setup() {
10
- const count = ref(0);
11
- const propsViewRef = ref(null);
12
- const countAdd = () => {
13
- propsViewRef.value.countAdd();
14
- };
15
- const comCount = ref(0);
16
- const open = () => {
17
- const { appContext } = getCurrentInstance() || {};
18
- let dialog = {};
19
- const options = {
20
- props: {
21
- title: "hello dialog",
22
- },
23
- events: {
24
- onClose: () => {
25
- console.log("close11");
26
- },
27
- },
28
- slots: {
29
- default: () => <ComView count={comCount.value} dialog={dialog} />,
30
- title: () => <div>title slot</div>,
31
- footer: () => <div>footer slot</div>,
32
- },
33
- };
34
- dialog.close = openDialog(options, appContext).close;
35
- };
36
- return () => (
37
- <>
38
- <div class="mb-4">
39
- 123
40
- <span>
41
- <el-button type="primary" onClick={open}>
42
- open dialog
43
- </el-button>
44
- <el-button type="primary" onClick={countAdd}>
45
- props countAdd
46
- </el-button>
47
- <div>count: {count.value}</div>
48
- <PropsView
49
- ref={propsViewRef}
50
- msg="hello props"
51
- onMyEvent={() => {
52
- count.value++;
53
- }}
54
- >
55
- {{
56
- default: () => <div>default slot</div>,
57
- }}
58
- </PropsView>
59
- </span>
60
- </div>
61
- </>
62
- );
63
- },
64
- });
65
- </script>
package/app/jsx/props.vue DELETED
@@ -1,33 +0,0 @@
1
- <script lang="jsx">
2
- import { defineComponent, ref, h, Fragment } from 'vue'
3
-
4
- export default defineComponent({
5
- name: 'PropsView',
6
- emits: ['myEvent'],
7
- setup(props, { attrs, emit ,slots ,expose }) {
8
- console.log(props, 'props');
9
- console.log(attrs, 'attrs');
10
- console.log(emit, 'emit');
11
- console.log(slots, 'slots');
12
- console.log(expose, 'expose');
13
- const count = ref(0);
14
- const countAdd = () => {
15
- count.value++;
16
- }
17
- expose({
18
- countAdd,
19
- })
20
- return () => <>
21
- <div>
22
- {attrs.msg}
23
- <div>props count: {count.value}</div>
24
- {slots.default()}
25
- <el-button type="primary" onClick={() => {
26
- console.log('myEvent');
27
-
28
- emit('myEvent')
29
- }}>countAdd</el-button>
30
- </div></>
31
- }
32
- })
33
- </script>
package/app.md DELETED
@@ -1 +0,0 @@
1
- 1.0.16 vue3 jsx element-plus文档