vue-dialog-view 1.0.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/LICENSE +24 -0
- package/README.md +116 -0
- package/dist/DialogView.vue.d.ts +37 -0
- package/dist/dialog-view.es.js +61 -0
- package/dist/dialog-view.umd.js +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +54 -0
- package/src/DialogView.vue +149 -0
- package/src/index.ts +8 -0
- package/tsconfig.json +29 -0
- package/vite.config.ts +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# vue-dialog-view
|
|
2
|
+
|
|
3
|
+
A modern Vue 3 dialog component using the native HTML5 `<dialog>` element.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎯 **Native HTML5 Dialog** - Uses the built-in `<dialog>` element for better accessibility and performance
|
|
8
|
+
- 🎨 **Customizable** - Configurable title bar and close button
|
|
9
|
+
- ♿ **Accessible** - Proper ARIA labels and keyboard support
|
|
10
|
+
- 📱 **Responsive** - Adapts to different screen sizes
|
|
11
|
+
- 🎪 **Slot Support** - Flexible content slots for title and main content
|
|
12
|
+
- 🎠**Vue 3 Ready** - Built with Composition API and TypeScript
|
|
13
|
+
- 🎨 **Zero CSS Setup** - Styles are automatically injected, no need to import CSS files
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i vue-dialog-view
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Global Registration
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import { createApp } from 'vue'
|
|
27
|
+
import App from './App.vue'
|
|
28
|
+
import DialogView from 'vue-dialog-view'
|
|
29
|
+
|
|
30
|
+
const app = createApp(App)
|
|
31
|
+
app.use(DialogView)
|
|
32
|
+
app.mount('#app')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Local Registration
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<template>
|
|
39
|
+
<div>
|
|
40
|
+
<button @click="showDialog = true">Open Dialog</button>
|
|
41
|
+
|
|
42
|
+
<DialogView v-model="showDialog">
|
|
43
|
+
<template #title>
|
|
44
|
+
Dialog Title
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<p>This is your dialog content!</p>
|
|
48
|
+
<p>You can put any content here.</p>
|
|
49
|
+
</DialogView>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup>
|
|
54
|
+
import { ref } from 'vue'
|
|
55
|
+
import { DialogView } from 'vue-dialog-view'
|
|
56
|
+
|
|
57
|
+
const showDialog = ref(false)
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Props
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Default | Description |
|
|
64
|
+
|------|------|---------|-------------|
|
|
65
|
+
| `modelValue` | `boolean` | **required** | Controls the visibility of the dialog |
|
|
66
|
+
| `showTitleBar` | `boolean` | `true` | Whether to show the title bar |
|
|
67
|
+
| `showCloseButton` | `boolean` | `true` | Whether to show the close button in title bar |
|
|
68
|
+
|
|
69
|
+
## Events
|
|
70
|
+
|
|
71
|
+
| Event | Description |
|
|
72
|
+
|-------|-------------|
|
|
73
|
+
| `update:modelValue` | Emitted when dialog visibility changes |
|
|
74
|
+
|
|
75
|
+
## Slots
|
|
76
|
+
|
|
77
|
+
| Slot | Description |
|
|
78
|
+
|------|-------------|
|
|
79
|
+
| `#title` | Content for the dialog title |
|
|
80
|
+
| `default` | Main content of the dialog |
|
|
81
|
+
|
|
82
|
+
## Methods
|
|
83
|
+
|
|
84
|
+
The component exposes the following methods via template refs:
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<template>
|
|
88
|
+
<DialogView ref="dialogRef" v-model="showDialog">
|
|
89
|
+
<!-- content -->
|
|
90
|
+
</DialogView>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<script setup>
|
|
94
|
+
import { ref } from 'vue'
|
|
95
|
+
|
|
96
|
+
const dialogRef = ref()
|
|
97
|
+
|
|
98
|
+
// Open dialog programmatically
|
|
99
|
+
dialogRef.value.open()
|
|
100
|
+
|
|
101
|
+
// Close dialog programmatically
|
|
102
|
+
dialogRef.value.close()
|
|
103
|
+
</script>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Browser Support
|
|
107
|
+
|
|
108
|
+
This component requires a browser that supports the HTML5 `<dialog>` element. For older browsers, consider using a polyfill.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
Unlicense - See LICENSE file for details.
|
|
113
|
+
|
|
114
|
+
## Contributing
|
|
115
|
+
|
|
116
|
+
Issues and pull requests are welcome! Please feel free to contribute.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
modelValue: boolean;
|
|
3
|
+
showTitleBar?: boolean;
|
|
4
|
+
showCloseButton?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function __VLS_template(): {
|
|
7
|
+
attrs: Partial<{}>;
|
|
8
|
+
slots: {
|
|
9
|
+
title?(_: {}): any;
|
|
10
|
+
default?(_: {}): any;
|
|
11
|
+
};
|
|
12
|
+
refs: {
|
|
13
|
+
dialogRef: HTMLDialogElement;
|
|
14
|
+
};
|
|
15
|
+
rootEl: HTMLDialogElement;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
18
|
+
declare const __VLS_component: import('vue').DefineComponent<Props, {
|
|
19
|
+
open: () => void;
|
|
20
|
+
close: () => void;
|
|
21
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
22
|
+
"update:modelValue": (value: boolean) => any;
|
|
23
|
+
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
|
24
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
25
|
+
}>, {
|
|
26
|
+
showTitleBar: boolean;
|
|
27
|
+
showCloseButton: boolean;
|
|
28
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
29
|
+
dialogRef: HTMLDialogElement;
|
|
30
|
+
}, HTMLDialogElement>;
|
|
31
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
32
|
+
export default _default;
|
|
33
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
34
|
+
new (): {
|
|
35
|
+
$slots: S;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dialog-view[data-v-1ca83b6e]{padding:20px;border-radius:5px;border:1px solid gray;outline:0!important}.dialog-view[open][data-v-1ca83b6e]{display:flex;flex-direction:column;position:fixed;margin:auto;max-width:90vw;max-height:90vh}.dialog-view[data-v-1ca83b6e]::backdrop{background:#00000080}.dialog-title-bar[data-v-1ca83b6e]{display:flex;flex-direction:row;align-items:center;margin-bottom:.5em;min-height:24px}.dialog-title[data-v-1ca83b6e]{flex:1;text-align:center;font-weight:700;font-size:1.1em}.dialog-close-button[data-v-1ca83b6e]{margin-left:.5em;text-decoration:none;color:#666;font-size:1.5em;line-height:1;width:24px;height:24px;display:flex;align-items:center;justify-content:center;cursor:pointer;border:none;background:none}.dialog-close-button[data-v-1ca83b6e]:hover{color:#333;background-color:#f0f0f0;border-radius:3px}.dialog-content[data-v-1ca83b6e]{flex:1;overflow:auto;display:flex;flex-direction:column}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
import { defineComponent as g, ref as h, watch as w, nextTick as _, createElementBlock as n, openBlock as c, mergeProps as V, createCommentVNode as r, createElementVNode as u, renderSlot as p, withModifiers as B } from "vue";
|
|
3
|
+
const k = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "dialog-title-bar"
|
|
6
|
+
}, y = { class: "dialog-title" }, C = { class: "dialog-content" }, D = /* @__PURE__ */ g({
|
|
7
|
+
__name: "DialogView",
|
|
8
|
+
props: {
|
|
9
|
+
modelValue: { type: Boolean },
|
|
10
|
+
showTitleBar: { type: Boolean, default: !0 },
|
|
11
|
+
showCloseButton: { type: Boolean, default: !0 }
|
|
12
|
+
},
|
|
13
|
+
emits: ["update:modelValue"],
|
|
14
|
+
setup(o, { expose: s, emit: t }) {
|
|
15
|
+
const a = o, i = t, e = h(null), v = () => {
|
|
16
|
+
e.value && !e.value.open && e.value.showModal();
|
|
17
|
+
}, d = () => {
|
|
18
|
+
e.value && e.value.open && e.value.close();
|
|
19
|
+
}, m = () => {
|
|
20
|
+
a.modelValue && i("update:modelValue", !1);
|
|
21
|
+
};
|
|
22
|
+
return w(() => a.modelValue, async (l) => {
|
|
23
|
+
await _(), l ? e.value && !e.value.open && e.value.showModal() : e.value && e.value.open && e.value.close();
|
|
24
|
+
}), s({
|
|
25
|
+
open: v,
|
|
26
|
+
close: d
|
|
27
|
+
}), (l, M) => (c(), n("dialog", V({
|
|
28
|
+
ref_key: "dialogRef",
|
|
29
|
+
ref: e,
|
|
30
|
+
class: "dialog-view"
|
|
31
|
+
}, l.$attrs, { onClose: m }), [
|
|
32
|
+
o.showTitleBar ? (c(), n("div", k, [
|
|
33
|
+
u("span", y, [
|
|
34
|
+
p(l.$slots, "title", {}, void 0, !0)
|
|
35
|
+
]),
|
|
36
|
+
o.showCloseButton ? (c(), n("a", {
|
|
37
|
+
key: 0,
|
|
38
|
+
href: "javascript:void(0)",
|
|
39
|
+
role: "button",
|
|
40
|
+
"aria-label": "Close the dialog",
|
|
41
|
+
class: "dialog-close-button",
|
|
42
|
+
onClick: B(d, ["prevent"])
|
|
43
|
+
}, "×")) : r("", !0)
|
|
44
|
+
])) : r("", !0),
|
|
45
|
+
u("div", C, [
|
|
46
|
+
p(l.$slots, "default", {}, void 0, !0)
|
|
47
|
+
])
|
|
48
|
+
], 16));
|
|
49
|
+
}
|
|
50
|
+
}), b = (o, s) => {
|
|
51
|
+
const t = o.__vccOpts || o;
|
|
52
|
+
for (const [a, i] of s)
|
|
53
|
+
t[a] = i;
|
|
54
|
+
return t;
|
|
55
|
+
}, f = /* @__PURE__ */ b(D, [["__scopeId", "data-v-1ca83b6e"]]);
|
|
56
|
+
f.install = (o) => {
|
|
57
|
+
o.component("DialogView", f);
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
f as default
|
|
61
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dialog-view[data-v-1ca83b6e]{padding:20px;border-radius:5px;border:1px solid gray;outline:0!important}.dialog-view[open][data-v-1ca83b6e]{display:flex;flex-direction:column;position:fixed;margin:auto;max-width:90vw;max-height:90vh}.dialog-view[data-v-1ca83b6e]::backdrop{background:#00000080}.dialog-title-bar[data-v-1ca83b6e]{display:flex;flex-direction:row;align-items:center;margin-bottom:.5em;min-height:24px}.dialog-title[data-v-1ca83b6e]{flex:1;text-align:center;font-weight:700;font-size:1.1em}.dialog-close-button[data-v-1ca83b6e]{margin-left:.5em;text-decoration:none;color:#666;font-size:1.5em;line-height:1;width:24px;height:24px;display:flex;align-items:center;justify-content:center;cursor:pointer;border:none;background:none}.dialog-close-button[data-v-1ca83b6e]:hover{color:#333;background-color:#f0f0f0;border-radius:3px}.dialog-content[data-v-1ca83b6e]{flex:1;overflow:auto;display:flex;flex-direction:column}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
(function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l(require("vue")):typeof define=="function"&&define.amd?define(["vue"],l):(e=typeof globalThis<"u"?globalThis:e||self,e.DialogView=l(e.Vue))})(this,(function(e){"use strict";const l={key:0,class:"dialog-title-bar"},f={class:"dialog-title"},u={class:"dialog-content"},i=((t,c)=>{const n=t.__vccOpts||t;for(const[s,d]of c)n[s]=d;return n})(e.defineComponent({__name:"DialogView",props:{modelValue:{type:Boolean},showTitleBar:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0}},emits:["update:modelValue"],setup(t,{expose:c,emit:n}){const s=t,d=n,o=e.ref(null),p=()=>{o.value&&!o.value.open&&o.value.showModal()},r=()=>{o.value&&o.value.open&&o.value.close()},m=()=>{s.modelValue&&d("update:modelValue",!1)};return e.watch(()=>s.modelValue,async a=>{await e.nextTick(),a?o.value&&!o.value.open&&o.value.showModal():o.value&&o.value.open&&o.value.close()}),c({open:p,close:r}),(a,_)=>(e.openBlock(),e.createElementBlock("dialog",e.mergeProps({ref_key:"dialogRef",ref:o,class:"dialog-view"},a.$attrs,{onClose:m}),[t.showTitleBar?(e.openBlock(),e.createElementBlock("div",l,[e.createElementVNode("span",f,[e.renderSlot(a.$slots,"title",{},void 0,!0)]),t.showCloseButton?(e.openBlock(),e.createElementBlock("a",{key:0,href:"javascript:void(0)",role:"button","aria-label":"Close the dialog",class:"dialog-close-button",onClick:e.withModifiers(r,["prevent"])},"×")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",u,[e.renderSlot(a.$slots,"default",{},void 0,!0)])],16))}}),[["__scopeId","data-v-1ca83b6e"]]);return i.install=t=>{t.component("DialogView",i)},i}));
|
package/dist/index.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-dialog-view",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A modern Vue 3 dialog component using native dialog element",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/dialog-view.umd.js",
|
|
7
|
+
"module": "./dist/dialog-view.es.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/dialog-view.es.js",
|
|
13
|
+
"require": "./dist/dialog-view.umd.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src/**",
|
|
18
|
+
"dist/**",
|
|
19
|
+
"README.md",
|
|
20
|
+
"tsconfig.json",
|
|
21
|
+
"vite.config.ts",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "vite",
|
|
26
|
+
"build": "vue-tsc --noEmit && vite build",
|
|
27
|
+
"preview": "vite preview"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"vue": "^3.3.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vite": "^7.1.10",
|
|
36
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
37
|
+
"vite-plugin-dts": "^4.5.4",
|
|
38
|
+
"vue": "^3.5.22",
|
|
39
|
+
"vue-tsc": "^3.1.1"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"front-end",
|
|
43
|
+
"vue",
|
|
44
|
+
"dialog",
|
|
45
|
+
"dialog-view",
|
|
46
|
+
"html5"
|
|
47
|
+
],
|
|
48
|
+
"author": "chcs1013",
|
|
49
|
+
"license": "Unlicense",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/shc0743/MyUtility/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/shc0743/MyUtility/tree/main/js/lib/vue-dialog-view#readme"
|
|
54
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dialog
|
|
3
|
+
ref="dialogRef"
|
|
4
|
+
class="dialog-view"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
@close="handleDialogClose"
|
|
7
|
+
>
|
|
8
|
+
<div v-if="showTitleBar" class="dialog-title-bar">
|
|
9
|
+
<span class="dialog-title">
|
|
10
|
+
<slot name="title"></slot>
|
|
11
|
+
</span>
|
|
12
|
+
<a
|
|
13
|
+
v-if="showCloseButton"
|
|
14
|
+
href="javascript:void(0)"
|
|
15
|
+
role="button"
|
|
16
|
+
aria-label="Close the dialog"
|
|
17
|
+
class="dialog-close-button"
|
|
18
|
+
@click.prevent="closeDialog"
|
|
19
|
+
>×</a>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="dialog-content">
|
|
22
|
+
<slot></slot>
|
|
23
|
+
</div>
|
|
24
|
+
</dialog>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { ref, watch, nextTick } from 'vue'
|
|
29
|
+
|
|
30
|
+
interface Props {
|
|
31
|
+
modelValue: boolean
|
|
32
|
+
showTitleBar?: boolean
|
|
33
|
+
showCloseButton?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
37
|
+
showTitleBar: true,
|
|
38
|
+
showCloseButton: true
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{
|
|
42
|
+
(e: 'update:modelValue', value: boolean): void
|
|
43
|
+
}>()
|
|
44
|
+
|
|
45
|
+
const dialogRef = ref<HTMLDialogElement | null>(null)
|
|
46
|
+
|
|
47
|
+
const openDialog = (): void => {
|
|
48
|
+
if (dialogRef.value && !dialogRef.value.open) {
|
|
49
|
+
dialogRef.value.showModal()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const closeDialog = (): void => {
|
|
54
|
+
if (dialogRef.value && dialogRef.value.open) {
|
|
55
|
+
dialogRef.value.close()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const handleDialogClose = (): void => {
|
|
60
|
+
if (props.modelValue) {
|
|
61
|
+
emit('update:modelValue', false)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
watch(() => props.modelValue, async (newValue) => {
|
|
66
|
+
await nextTick()
|
|
67
|
+
|
|
68
|
+
if (newValue) {
|
|
69
|
+
if (dialogRef.value && !dialogRef.value.open) {
|
|
70
|
+
dialogRef.value.showModal()
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
if (dialogRef.value && dialogRef.value.open) {
|
|
74
|
+
dialogRef.value.close()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
defineExpose({
|
|
80
|
+
open: openDialog,
|
|
81
|
+
close: closeDialog,
|
|
82
|
+
})
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style scoped>
|
|
86
|
+
.dialog-view {
|
|
87
|
+
padding: 20px;
|
|
88
|
+
border-radius: 5px;
|
|
89
|
+
border: 1px solid gray;
|
|
90
|
+
outline: 0 !important;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.dialog-view[open] {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
position: fixed;
|
|
97
|
+
margin: auto;
|
|
98
|
+
max-width: 90vw;
|
|
99
|
+
max-height: 90vh;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.dialog-view::backdrop {
|
|
103
|
+
background: rgba(0, 0, 0, 0.5);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.dialog-title-bar {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: row;
|
|
109
|
+
align-items: center;
|
|
110
|
+
margin-bottom: 0.5em;
|
|
111
|
+
min-height: 24px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dialog-title {
|
|
115
|
+
flex: 1;
|
|
116
|
+
text-align: center;
|
|
117
|
+
font-weight: bold;
|
|
118
|
+
font-size: 1.1em;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.dialog-close-button {
|
|
122
|
+
margin-left: 0.5em;
|
|
123
|
+
text-decoration: none;
|
|
124
|
+
color: #666;
|
|
125
|
+
font-size: 1.5em;
|
|
126
|
+
line-height: 1;
|
|
127
|
+
width: 24px;
|
|
128
|
+
height: 24px;
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
border: none;
|
|
134
|
+
background: none;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.dialog-close-button:hover {
|
|
138
|
+
color: #333;
|
|
139
|
+
background-color: #f0f0f0;
|
|
140
|
+
border-radius: 3px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.dialog-content {
|
|
144
|
+
flex: 1;
|
|
145
|
+
overflow: auto;
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
}
|
|
149
|
+
</style>
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "preserve",
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
|
|
23
|
+
/* For component library */
|
|
24
|
+
"declaration": true,
|
|
25
|
+
"outDir": "dist"
|
|
26
|
+
},
|
|
27
|
+
"include": ["src/**/*"],
|
|
28
|
+
"exclude": ["node_modules", "dist"]
|
|
29
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import { fileURLToPath, URL } from 'node:url'
|
|
4
|
+
import dts from 'vite-plugin-dts'
|
|
5
|
+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [
|
|
9
|
+
vue(),
|
|
10
|
+
cssInjectedByJsPlugin(),
|
|
11
|
+
dts({
|
|
12
|
+
insertTypesEntry: true,
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
build: {
|
|
16
|
+
lib: {
|
|
17
|
+
entry: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
|
|
18
|
+
name: 'DialogView',
|
|
19
|
+
fileName: (format) => `dialog-view.${format}.js`
|
|
20
|
+
},
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
external: ['vue'],
|
|
23
|
+
output: {
|
|
24
|
+
globals: {
|
|
25
|
+
vue: 'Vue'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
cssCodeSplit: false,
|
|
30
|
+
}
|
|
31
|
+
})
|