best-dialog 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.
- package/README.md +76 -32
- package/dist/{runtime/index.d.mts → index.d.mts} +6 -1
- package/dist/{runtime/index.mjs → index.mjs} +41 -19
- package/dist/module.mjs +5 -5
- package/package.json +13 -9
- package/dist/module.d.ts +0 -3
- package/dist/runtime/index.d.ts +0 -223
- package/dist/runtime/plugin.d.ts +0 -3
- /package/dist/{runtime/plugin.d.mts → plugin.d.mts} +0 -0
- /package/dist/{runtime/plugin.mjs → plugin.mjs} +0 -0
- /package/dist/{runtime/style.css → style.css} +0 -0
package/README.md
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
- **三种调用方式** — 模板组件 / 组合式(链式 API)/ 函数式
|
|
8
8
|
- **高级方法** — `alert` / `confirm` / `prompt` 开箱即用
|
|
9
|
+
- **语义回调** — `onOk` / `onCancel`,确定、取消、叉叉、ESC 一目了然
|
|
9
10
|
- **精美动画** — zoom / slide / fade 三种过渡效果,GPU 加速
|
|
10
11
|
- **灵活定位** — 9 种位置(center / top / bottom / left / right / 四角)
|
|
11
|
-
- **丰富内容** — 文本 / HTML / iframe / Vue 组件 /
|
|
12
|
+
- **丰富内容** — 文本 / HTML / iframe / Vue 组件 / 插槽(组件自动 `markRaw`,无响应式警告)
|
|
12
13
|
- **actions 插槽** — 完全自定义底部按钮区域
|
|
13
|
-
- **事件信息** — `onClose(e)`
|
|
14
|
+
- **事件信息** — `onClose(e)` 返回触发事件详情(source / 按钮索引 / 按钮配置)
|
|
14
15
|
- **暗色模式** — 自动跟随系统 `prefers-color-scheme`
|
|
15
16
|
- **响应式** — 移动端自适应布局
|
|
16
17
|
- **无障碍** — ARIA 属性 + ESC 关闭
|
|
@@ -31,7 +32,7 @@ export default defineNuxtConfig({
|
|
|
31
32
|
})
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
安装后即可直接使用 `<BestDialog>`、`useDialog`、`showDialog`,无需手动导入。
|
|
35
|
+
> 安装后即可直接使用 `<BestDialog>`、`useDialog`、`showDialog`,无需手动导入。
|
|
35
36
|
|
|
36
37
|
### Vue 3 (Vite / Webpack)
|
|
37
38
|
|
|
@@ -42,8 +43,8 @@ npm install best-dialog
|
|
|
42
43
|
```ts
|
|
43
44
|
// main.ts
|
|
44
45
|
import { createApp, h } from 'vue'
|
|
45
|
-
import { BestDialogContainer } from 'best-dialog
|
|
46
|
-
import 'best-dialog/
|
|
46
|
+
import { BestDialogContainer } from 'best-dialog'
|
|
47
|
+
import 'best-dialog/style.css'
|
|
47
48
|
|
|
48
49
|
const app = createApp(App)
|
|
49
50
|
|
|
@@ -55,6 +56,8 @@ createApp({ render: () => h(BestDialogContainer) }).mount(el)
|
|
|
55
56
|
app.mount('#app')
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
> 若只使用模板组件 `<BestDialog>`,可以省略容器挂载。
|
|
60
|
+
|
|
58
61
|
---
|
|
59
62
|
|
|
60
63
|
## 使用方式
|
|
@@ -68,7 +71,7 @@ app.mount('#app')
|
|
|
68
71
|
<!-- 基础 -->
|
|
69
72
|
<BestDialog v-model="show" title="提示" content="内容"
|
|
70
73
|
:actions="['取消', { label: '确定', primary: true }]"
|
|
71
|
-
@close="onClose" />
|
|
74
|
+
@ok="onOk" @cancel="onCancel" @close="onClose" />
|
|
72
75
|
|
|
73
76
|
<!-- 插槽 -->
|
|
74
77
|
<BestDialog v-model="show2">
|
|
@@ -91,16 +94,15 @@ const dialog = useDialog({
|
|
|
91
94
|
})
|
|
92
95
|
|
|
93
96
|
// ── 基础 ──
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
dialog.open() // 打开(返回 handle,支持链式)
|
|
98
|
+
dialog.open({ content: '新内容' }) // 合并新选项
|
|
99
|
+
dialog.close() // 关闭
|
|
96
100
|
|
|
97
|
-
// ──
|
|
101
|
+
// ── 链式回调 ──
|
|
98
102
|
dialog.open()
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.log('按钮配置:', e.currentTarget.dataset.btn)
|
|
103
|
-
})
|
|
103
|
+
.onOk(() => { /* 点击了 primary 按钮 */ })
|
|
104
|
+
.onCancel((e) => { /* 取消按钮 / 叉叉 / ESC / 遮罩 */ })
|
|
105
|
+
.onClose((e) => { /* 任何方式关闭 */ })
|
|
104
106
|
|
|
105
107
|
// ── alert ──
|
|
106
108
|
dialog.alert('操作成功!')
|
|
@@ -108,7 +110,7 @@ dialog.alert('操作成功!')
|
|
|
108
110
|
// ── confirm ──
|
|
109
111
|
dialog.confirm('确定删除吗?')
|
|
110
112
|
.onOk(() => { /* 用户点了确定 */ })
|
|
111
|
-
.
|
|
113
|
+
.onCancel(() => { /* 用户点了取消 */ })
|
|
112
114
|
|
|
113
115
|
// ── prompt ──
|
|
114
116
|
dialog.prompt('请输入您的姓名')
|
|
@@ -127,6 +129,37 @@ const close = showDialog({
|
|
|
127
129
|
setTimeout(close, 3000)
|
|
128
130
|
```
|
|
129
131
|
|
|
132
|
+
### 4. 语义回调 `onOk` / `onCancel`
|
|
133
|
+
|
|
134
|
+
除 `onClose` 外,所有 API 均支持语义回调,关闭来源自动归类:
|
|
135
|
+
|
|
136
|
+
| 关闭方式 | onOk | onCancel |
|
|
137
|
+
|---------|------|----------|
|
|
138
|
+
| 点击 primary 按钮(确定) | ✅ | — |
|
|
139
|
+
| 点击普通按钮(取消) | — | ✅ |
|
|
140
|
+
| 点击右上角叉叉 | — | ✅ |
|
|
141
|
+
| 按 ESC | — | ✅ |
|
|
142
|
+
| 点击遮罩 | — | ✅ |
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
// showDialog:options 直接传
|
|
146
|
+
showDialog({
|
|
147
|
+
title: '删除确认',
|
|
148
|
+
content: '确定要删除这条记录吗?',
|
|
149
|
+
actions: ['取消', { label: '确定', primary: true }],
|
|
150
|
+
onOk: () => doDelete(),
|
|
151
|
+
onCancel: (e) => console.log('取消来源:', e.source),
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
// useDialog:链式或 options 均可
|
|
155
|
+
dialog.confirm('确定删除吗?').onOk(doDelete)
|
|
156
|
+
|
|
157
|
+
// BestDialog 组件:@ok / @cancel 事件
|
|
158
|
+
<BestDialog v-model="show" @ok="doOk" @cancel="onCancel" />
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> `prompt` 的 `onOk` 回调参数为输入框的值。
|
|
162
|
+
|
|
130
163
|
---
|
|
131
164
|
|
|
132
165
|
## API 参考
|
|
@@ -167,19 +200,17 @@ setTimeout(close, 3000)
|
|
|
167
200
|
|------|------|------|
|
|
168
201
|
| `update:modelValue` | `boolean` | v-model 更新 |
|
|
169
202
|
| `open` | — | 打开 |
|
|
170
|
-
| `close` | `DialogCloseEvent` |
|
|
203
|
+
| `close` | `DialogCloseEvent` | 任何方式关闭(含事件信息)|
|
|
204
|
+
| `ok` | — | 点击 primary 按钮 |
|
|
205
|
+
| `cancel` | `DialogCloseEvent` | 取消按钮 / 叉叉 / ESC / 遮罩 |
|
|
171
206
|
|
|
172
207
|
### DialogCloseEvent
|
|
173
208
|
|
|
174
209
|
```ts
|
|
175
210
|
interface DialogCloseEvent {
|
|
176
|
-
source: 'button' | 'overlay' | 'close-btn' | 'esc'
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
index?: number // 按钮索引
|
|
180
|
-
btn?: DialogAction // 按钮配置
|
|
181
|
-
}
|
|
182
|
-
}
|
|
211
|
+
source: 'button' | 'overlay' | 'close-btn' | 'esc' // 关闭来源
|
|
212
|
+
index: number // 按钮索引,非按钮关闭为 -1
|
|
213
|
+
button?: DialogAction // 按钮配置(source 为 button 时)
|
|
183
214
|
}
|
|
184
215
|
```
|
|
185
216
|
|
|
@@ -190,18 +221,22 @@ interface DialogCloseEvent {
|
|
|
190
221
|
```ts
|
|
191
222
|
const dialog = useDialog(options?)
|
|
192
223
|
|
|
193
|
-
dialog.open(opts?) // 打开,返回
|
|
194
|
-
.onClose(e => {}) // 链式:关闭回调
|
|
195
|
-
.onOk(value => {}) // 链式:确认回调(confirm/prompt 用)
|
|
196
|
-
|
|
224
|
+
dialog.open(opts?) // 打开,返回 DialogHandle(可继续链式)
|
|
197
225
|
dialog.close() // 关闭
|
|
198
226
|
|
|
199
|
-
|
|
200
|
-
dialog.
|
|
201
|
-
|
|
202
|
-
|
|
227
|
+
// DialogHandle 链式回调
|
|
228
|
+
dialog.open()
|
|
229
|
+
.onOk(value => {}) // 确认回调(prompt 的 value 为输入值)
|
|
230
|
+
.onCancel(e => {}) // 取消回调(取消按钮 / 叉叉 / ESC / 遮罩)
|
|
231
|
+
.onClose(e => {}) // 任意关闭回调
|
|
232
|
+
|
|
233
|
+
dialog.alert(content, title?) // 快捷提示
|
|
234
|
+
dialog.confirm(content, title?) // 确认框
|
|
235
|
+
dialog.prompt(placeholder?, title?, default?) // 输入框
|
|
203
236
|
```
|
|
204
237
|
|
|
238
|
+
`options` 中也可以直接声明 `onOk` / `onCancel` / `onClose`,与链式回调等价(两者会同时触发)。
|
|
239
|
+
|
|
205
240
|
---
|
|
206
241
|
|
|
207
242
|
## Actions 详解
|
|
@@ -214,7 +249,7 @@ type DialogActionItem = string | {
|
|
|
214
249
|
href?: string
|
|
215
250
|
target?: string
|
|
216
251
|
class?: string
|
|
217
|
-
primary?: boolean //
|
|
252
|
+
primary?: boolean // 默认最后一个按钮为 primary
|
|
218
253
|
}
|
|
219
254
|
```
|
|
220
255
|
|
|
@@ -257,6 +292,15 @@ showDialog({
|
|
|
257
292
|
|
|
258
293
|
---
|
|
259
294
|
|
|
295
|
+
## 内容渲染优先级
|
|
296
|
+
|
|
297
|
+
`default 插槽` > `url`(iframe)> `content`:
|
|
298
|
+
- `content` 为字符串 → 文本段落
|
|
299
|
+
- `content` 为字符串且 `html: true` → HTML 渲染
|
|
300
|
+
- `content` 为 Vue 组件 → 直接渲染(内部自动 `markRaw`,避免响应式代理警告)
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
260
304
|
## 样式定制
|
|
261
305
|
|
|
262
306
|
```css
|
|
@@ -39,12 +39,15 @@ interface DialogOptions {
|
|
|
39
39
|
zIndex?: number;
|
|
40
40
|
onOpen?: () => void;
|
|
41
41
|
onClose?: (e: DialogCloseEvent) => void;
|
|
42
|
+
onOk?: (value?: any) => void;
|
|
43
|
+
onCancel?: (e: DialogCloseEvent) => void;
|
|
42
44
|
[key: string]: any;
|
|
43
45
|
}
|
|
44
46
|
interface DialogHandle {
|
|
45
47
|
close: () => void;
|
|
46
48
|
onClose: (cb: (e: DialogCloseEvent) => void) => DialogHandle;
|
|
47
49
|
onOk: (cb: (value?: any) => void) => DialogHandle;
|
|
50
|
+
onCancel: (cb: (e: DialogCloseEvent) => void) => DialogHandle;
|
|
48
51
|
open: (opts?: DialogOptions) => DialogHandle;
|
|
49
52
|
alert: (content: string, title?: string) => DialogHandle;
|
|
50
53
|
confirm: (content: string, title?: string) => DialogHandle;
|
|
@@ -123,7 +126,7 @@ declare const BestDialog: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
123
126
|
};
|
|
124
127
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
125
128
|
[key: string]: any;
|
|
126
|
-
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("update:modelValue" | "open" | "close")[], "update:modelValue" | "open" | "close", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
129
|
+
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("update:modelValue" | "open" | "close" | "ok" | "cancel")[], "update:modelValue" | "open" | "close" | "ok" | "cancel", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
127
130
|
modelValue: {
|
|
128
131
|
type: BooleanConstructor;
|
|
129
132
|
default: boolean;
|
|
@@ -196,6 +199,8 @@ declare const BestDialog: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
196
199
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
197
200
|
onOpen?: ((...args: any[]) => any) | undefined;
|
|
198
201
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
202
|
+
onOk?: ((...args: any[]) => any) | undefined;
|
|
203
|
+
onCancel?: ((...args: any[]) => any) | undefined;
|
|
199
204
|
}>, {
|
|
200
205
|
modelValue: boolean;
|
|
201
206
|
title: string | object;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { ref, defineComponent, h, computed, watch, onMounted, onUnmounted, Teleport, Transition, markRaw } from 'vue';
|
|
1
|
+
import { ref, defineComponent, h, computed, watch, onMounted, onUnmounted, Teleport, Transition, shallowRef, markRaw } from 'vue';
|
|
2
2
|
|
|
3
3
|
const store = ref([]);
|
|
4
4
|
let _uid = 0;
|
|
5
5
|
function uid() {
|
|
6
6
|
return `bd-${++_uid}`;
|
|
7
7
|
}
|
|
8
|
+
function sanitizeOptions(o) {
|
|
9
|
+
const r = { ...o };
|
|
10
|
+
if (r.content && typeof r.content === "object") r.content = markRaw(r.content);
|
|
11
|
+
if (r.title && typeof r.title === "object") r.title = markRaw(r.title);
|
|
12
|
+
return r;
|
|
13
|
+
}
|
|
8
14
|
function storeAdd(id, options) {
|
|
15
|
+
const o = sanitizeOptions(options);
|
|
9
16
|
const existing = store.value.find((d) => d.id === id);
|
|
10
17
|
if (existing) {
|
|
11
|
-
existing.options =
|
|
18
|
+
existing.options = o;
|
|
12
19
|
existing.visible = true;
|
|
13
|
-
} else store.value.push({ id, visible: true, options });
|
|
20
|
+
} else store.value.push({ id, visible: true, options: o });
|
|
14
21
|
}
|
|
15
22
|
function storeHide(id) {
|
|
16
23
|
const d = store.value.find((d2) => d2.id === id);
|
|
@@ -25,13 +32,19 @@ function storeClose(id, e) {
|
|
|
25
32
|
if (!item) return;
|
|
26
33
|
item.visible = false;
|
|
27
34
|
item.options.onClose?.(e || { source: "overlay", index: -1 });
|
|
35
|
+
if (e) {
|
|
36
|
+
if (e.source === "button" && e.button?.primary) item.options.onOk?.();
|
|
37
|
+
else item.options.onCancel?.(e);
|
|
38
|
+
}
|
|
28
39
|
setTimeout(() => storeRemove(id), 420);
|
|
29
40
|
}
|
|
30
41
|
function useDialog(defaults = {}) {
|
|
31
42
|
const id = uid();
|
|
32
|
-
const options =
|
|
43
|
+
const options = shallowRef({ ...defaults });
|
|
33
44
|
let _onClose = null;
|
|
34
45
|
let _onOk = null;
|
|
46
|
+
let _onCancel = null;
|
|
47
|
+
let _okValue;
|
|
35
48
|
let _closing = false;
|
|
36
49
|
onUnmounted(() => storeRemove(id));
|
|
37
50
|
function doClose(e) {
|
|
@@ -49,6 +62,8 @@ function useDialog(defaults = {}) {
|
|
|
49
62
|
if (opts) options.value = { ...options.value, ...opts };
|
|
50
63
|
_onClose = null;
|
|
51
64
|
_onOk = null;
|
|
65
|
+
_onCancel = null;
|
|
66
|
+
_okValue = void 0;
|
|
52
67
|
_closing = false;
|
|
53
68
|
const userOnClose = options.value.onClose;
|
|
54
69
|
options.value.onClose = (e) => {
|
|
@@ -58,6 +73,16 @@ function useDialog(defaults = {}) {
|
|
|
58
73
|
_onClose?.(e);
|
|
59
74
|
}
|
|
60
75
|
};
|
|
76
|
+
const userOnOk = options.value.onOk;
|
|
77
|
+
options.value.onOk = () => {
|
|
78
|
+
userOnOk?.(_okValue?.());
|
|
79
|
+
_onOk?.(_okValue?.());
|
|
80
|
+
};
|
|
81
|
+
const userOnCancel = options.value.onCancel;
|
|
82
|
+
options.value.onCancel = (e) => {
|
|
83
|
+
userOnCancel?.(e);
|
|
84
|
+
_onCancel?.(e);
|
|
85
|
+
};
|
|
61
86
|
storeAdd(id, options.value);
|
|
62
87
|
options.value.onOpen?.();
|
|
63
88
|
return handle;
|
|
@@ -72,6 +97,10 @@ function useDialog(defaults = {}) {
|
|
|
72
97
|
_onOk = cb;
|
|
73
98
|
return handle;
|
|
74
99
|
},
|
|
100
|
+
onCancel(cb) {
|
|
101
|
+
_onCancel = cb;
|
|
102
|
+
return handle;
|
|
103
|
+
},
|
|
75
104
|
open,
|
|
76
105
|
alert(content, title) {
|
|
77
106
|
open({
|
|
@@ -87,13 +116,7 @@ function useDialog(defaults = {}) {
|
|
|
87
116
|
content,
|
|
88
117
|
actions: [
|
|
89
118
|
{ label: "\u53D6\u6D88" },
|
|
90
|
-
{
|
|
91
|
-
label: "\u786E\u5B9A",
|
|
92
|
-
primary: true,
|
|
93
|
-
onClick: () => {
|
|
94
|
-
_onOk?.();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
119
|
+
{ label: "\u786E\u5B9A", primary: true }
|
|
97
120
|
]
|
|
98
121
|
});
|
|
99
122
|
return handle;
|
|
@@ -118,15 +141,10 @@ function useDialog(defaults = {}) {
|
|
|
118
141
|
content: PromptInput,
|
|
119
142
|
actions: [
|
|
120
143
|
{ label: "\u53D6\u6D88" },
|
|
121
|
-
{
|
|
122
|
-
label: "\u786E\u5B9A",
|
|
123
|
-
primary: true,
|
|
124
|
-
onClick: () => {
|
|
125
|
-
_onOk?.(inputVal.value);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
144
|
+
{ label: "\u786E\u5B9A", primary: true }
|
|
128
145
|
]
|
|
129
146
|
});
|
|
147
|
+
_okValue = () => inputVal.value;
|
|
130
148
|
return handle;
|
|
131
149
|
}
|
|
132
150
|
};
|
|
@@ -290,7 +308,7 @@ const BestDialog = defineComponent({
|
|
|
290
308
|
dialogClass: { type: [String, Array, Object], default: void 0 },
|
|
291
309
|
dialogStyle: { type: [String, Object], default: void 0 }
|
|
292
310
|
},
|
|
293
|
-
emits: ["update:modelValue", "open", "close"],
|
|
311
|
+
emits: ["update:modelValue", "open", "close", "ok", "cancel"],
|
|
294
312
|
setup(props, { emit, slots }) {
|
|
295
313
|
const localVisible = ref(props.modelValue);
|
|
296
314
|
computed(() => props.effect || effectForPos(props.position));
|
|
@@ -302,6 +320,10 @@ const BestDialog = defineComponent({
|
|
|
302
320
|
localVisible.value = false;
|
|
303
321
|
emit("update:modelValue", false);
|
|
304
322
|
emit("close", e);
|
|
323
|
+
if (e) {
|
|
324
|
+
if (e.source === "button" && e.button?.primary) emit("ok");
|
|
325
|
+
else emit("cancel", e);
|
|
326
|
+
}
|
|
305
327
|
}
|
|
306
328
|
function onKey(e) {
|
|
307
329
|
if (e.key === "Escape" && localVisible.value && props.escClose) {
|
package/dist/module.mjs
CHANGED
|
@@ -13,18 +13,18 @@ const module$1 = defineNuxtModule({
|
|
|
13
13
|
const { resolve } = createResolver(import.meta.url);
|
|
14
14
|
addComponent({
|
|
15
15
|
name: "BestDialog",
|
|
16
|
-
filePath: resolve("./
|
|
16
|
+
filePath: resolve("./index"),
|
|
17
17
|
export: "BestDialog"
|
|
18
18
|
});
|
|
19
19
|
addImports([
|
|
20
|
-
{ name: "useDialog", from: resolve("./
|
|
21
|
-
{ name: "showDialog", from: resolve("./
|
|
20
|
+
{ name: "useDialog", from: resolve("./index") },
|
|
21
|
+
{ name: "showDialog", from: resolve("./index") }
|
|
22
22
|
]);
|
|
23
23
|
addPlugin({
|
|
24
|
-
src: resolve("./
|
|
24
|
+
src: resolve("./plugin"),
|
|
25
25
|
mode: "client"
|
|
26
26
|
});
|
|
27
|
-
nuxt.options.css.push(resolve("./
|
|
27
|
+
nuxt.options.css.push(resolve("./style.css"));
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "best-dialog",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Lightweight, beautiful Vue3 dialog component with Nuxt 3 support. Template / Composable / Functional API with alert, confirm, prompt.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.mts"
|
|
10
|
+
},
|
|
11
|
+
"./module": {
|
|
8
12
|
"import": "./dist/module.mjs",
|
|
9
|
-
"types": "./dist/module.d.
|
|
13
|
+
"types": "./dist/module.d.mts"
|
|
10
14
|
},
|
|
11
|
-
"./
|
|
12
|
-
"import": "./dist/
|
|
13
|
-
"types": "./dist/
|
|
15
|
+
"./nuxt": {
|
|
16
|
+
"import": "./dist/module.mjs",
|
|
17
|
+
"types": "./dist/module.d.mts"
|
|
14
18
|
},
|
|
15
|
-
"./
|
|
19
|
+
"./style.css": "./dist/style.css"
|
|
16
20
|
},
|
|
17
|
-
"main": "./dist/
|
|
18
|
-
"module": "./dist/
|
|
19
|
-
"types": "./dist/
|
|
21
|
+
"main": "./dist/index.mjs",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
20
24
|
"files": [
|
|
21
25
|
"dist"
|
|
22
26
|
],
|
package/dist/module.d.ts
DELETED
package/dist/runtime/index.d.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType, CSSProperties, VNode } from 'vue';
|
|
3
|
-
|
|
4
|
-
type DialogPosition = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
5
|
-
type DialogEffect = 'fade' | 'slide' | 'zoom';
|
|
6
|
-
type DialogContentType = string | object | null | undefined;
|
|
7
|
-
interface DialogAction {
|
|
8
|
-
label?: string;
|
|
9
|
-
onClick?: (close: () => void) => void | Promise<void> | boolean;
|
|
10
|
-
as?: 'button' | 'a';
|
|
11
|
-
href?: string;
|
|
12
|
-
target?: string;
|
|
13
|
-
class?: string;
|
|
14
|
-
primary?: boolean;
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
type DialogActionItem = string | DialogAction;
|
|
18
|
-
interface DialogCloseEvent {
|
|
19
|
-
source: 'button' | 'overlay' | 'close-btn' | 'esc';
|
|
20
|
-
index: number;
|
|
21
|
-
button?: DialogAction;
|
|
22
|
-
}
|
|
23
|
-
interface DialogOptions {
|
|
24
|
-
title?: string | object;
|
|
25
|
-
content?: DialogContentType;
|
|
26
|
-
html?: boolean;
|
|
27
|
-
url?: string;
|
|
28
|
-
actions?: DialogActionItem[];
|
|
29
|
-
position?: DialogPosition;
|
|
30
|
-
effect?: DialogEffect;
|
|
31
|
-
overlay?: boolean;
|
|
32
|
-
overlayClose?: boolean;
|
|
33
|
-
escClose?: boolean;
|
|
34
|
-
closable?: boolean;
|
|
35
|
-
class?: string | string[] | Record<string, boolean>;
|
|
36
|
-
style?: CSSProperties | string;
|
|
37
|
-
width?: string | number;
|
|
38
|
-
fullscreen?: boolean;
|
|
39
|
-
zIndex?: number;
|
|
40
|
-
onOpen?: () => void;
|
|
41
|
-
onClose?: (e: DialogCloseEvent) => void;
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}
|
|
44
|
-
interface DialogHandle {
|
|
45
|
-
close: () => void;
|
|
46
|
-
onClose: (cb: (e: DialogCloseEvent) => void) => DialogHandle;
|
|
47
|
-
onOk: (cb: (value?: any) => void) => DialogHandle;
|
|
48
|
-
open: (opts?: DialogOptions) => DialogHandle;
|
|
49
|
-
alert: (content: string, title?: string) => DialogHandle;
|
|
50
|
-
confirm: (content: string, title?: string) => DialogHandle;
|
|
51
|
-
prompt: (placeholder?: string, title?: string, defaultValue?: string) => DialogHandle;
|
|
52
|
-
}
|
|
53
|
-
declare function useDialog(defaults?: DialogOptions): DialogHandle;
|
|
54
|
-
declare function showDialog(options: DialogOptions): (e?: DialogCloseEvent) => void;
|
|
55
|
-
declare const BestDialog: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
56
|
-
modelValue: {
|
|
57
|
-
type: BooleanConstructor;
|
|
58
|
-
default: boolean;
|
|
59
|
-
};
|
|
60
|
-
title: {
|
|
61
|
-
type: PropType<string | object>;
|
|
62
|
-
default: undefined;
|
|
63
|
-
};
|
|
64
|
-
content: {
|
|
65
|
-
type: PropType<DialogContentType>;
|
|
66
|
-
default: undefined;
|
|
67
|
-
};
|
|
68
|
-
html: {
|
|
69
|
-
type: BooleanConstructor;
|
|
70
|
-
default: boolean;
|
|
71
|
-
};
|
|
72
|
-
url: {
|
|
73
|
-
type: StringConstructor;
|
|
74
|
-
default: undefined;
|
|
75
|
-
};
|
|
76
|
-
actions: {
|
|
77
|
-
type: PropType<DialogActionItem[]>;
|
|
78
|
-
default: undefined;
|
|
79
|
-
};
|
|
80
|
-
position: {
|
|
81
|
-
type: PropType<DialogPosition>;
|
|
82
|
-
default: string;
|
|
83
|
-
};
|
|
84
|
-
effect: {
|
|
85
|
-
type: PropType<DialogEffect>;
|
|
86
|
-
default: undefined;
|
|
87
|
-
};
|
|
88
|
-
overlay: {
|
|
89
|
-
type: BooleanConstructor;
|
|
90
|
-
default: boolean;
|
|
91
|
-
};
|
|
92
|
-
overlayClose: {
|
|
93
|
-
type: BooleanConstructor;
|
|
94
|
-
default: boolean;
|
|
95
|
-
};
|
|
96
|
-
escClose: {
|
|
97
|
-
type: BooleanConstructor;
|
|
98
|
-
default: boolean;
|
|
99
|
-
};
|
|
100
|
-
closable: {
|
|
101
|
-
type: BooleanConstructor;
|
|
102
|
-
default: boolean;
|
|
103
|
-
};
|
|
104
|
-
width: {
|
|
105
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
106
|
-
default: string;
|
|
107
|
-
};
|
|
108
|
-
fullscreen: {
|
|
109
|
-
type: BooleanConstructor;
|
|
110
|
-
default: boolean;
|
|
111
|
-
};
|
|
112
|
-
zIndex: {
|
|
113
|
-
type: NumberConstructor;
|
|
114
|
-
default: undefined;
|
|
115
|
-
};
|
|
116
|
-
dialogClass: {
|
|
117
|
-
type: PropType<any>;
|
|
118
|
-
default: undefined;
|
|
119
|
-
};
|
|
120
|
-
dialogStyle: {
|
|
121
|
-
type: PropType<CSSProperties | string>;
|
|
122
|
-
default: undefined;
|
|
123
|
-
};
|
|
124
|
-
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
125
|
-
[key: string]: any;
|
|
126
|
-
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("update:modelValue" | "open" | "close")[], "update:modelValue" | "open" | "close", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
127
|
-
modelValue: {
|
|
128
|
-
type: BooleanConstructor;
|
|
129
|
-
default: boolean;
|
|
130
|
-
};
|
|
131
|
-
title: {
|
|
132
|
-
type: PropType<string | object>;
|
|
133
|
-
default: undefined;
|
|
134
|
-
};
|
|
135
|
-
content: {
|
|
136
|
-
type: PropType<DialogContentType>;
|
|
137
|
-
default: undefined;
|
|
138
|
-
};
|
|
139
|
-
html: {
|
|
140
|
-
type: BooleanConstructor;
|
|
141
|
-
default: boolean;
|
|
142
|
-
};
|
|
143
|
-
url: {
|
|
144
|
-
type: StringConstructor;
|
|
145
|
-
default: undefined;
|
|
146
|
-
};
|
|
147
|
-
actions: {
|
|
148
|
-
type: PropType<DialogActionItem[]>;
|
|
149
|
-
default: undefined;
|
|
150
|
-
};
|
|
151
|
-
position: {
|
|
152
|
-
type: PropType<DialogPosition>;
|
|
153
|
-
default: string;
|
|
154
|
-
};
|
|
155
|
-
effect: {
|
|
156
|
-
type: PropType<DialogEffect>;
|
|
157
|
-
default: undefined;
|
|
158
|
-
};
|
|
159
|
-
overlay: {
|
|
160
|
-
type: BooleanConstructor;
|
|
161
|
-
default: boolean;
|
|
162
|
-
};
|
|
163
|
-
overlayClose: {
|
|
164
|
-
type: BooleanConstructor;
|
|
165
|
-
default: boolean;
|
|
166
|
-
};
|
|
167
|
-
escClose: {
|
|
168
|
-
type: BooleanConstructor;
|
|
169
|
-
default: boolean;
|
|
170
|
-
};
|
|
171
|
-
closable: {
|
|
172
|
-
type: BooleanConstructor;
|
|
173
|
-
default: boolean;
|
|
174
|
-
};
|
|
175
|
-
width: {
|
|
176
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
177
|
-
default: string;
|
|
178
|
-
};
|
|
179
|
-
fullscreen: {
|
|
180
|
-
type: BooleanConstructor;
|
|
181
|
-
default: boolean;
|
|
182
|
-
};
|
|
183
|
-
zIndex: {
|
|
184
|
-
type: NumberConstructor;
|
|
185
|
-
default: undefined;
|
|
186
|
-
};
|
|
187
|
-
dialogClass: {
|
|
188
|
-
type: PropType<any>;
|
|
189
|
-
default: undefined;
|
|
190
|
-
};
|
|
191
|
-
dialogStyle: {
|
|
192
|
-
type: PropType<CSSProperties | string>;
|
|
193
|
-
default: undefined;
|
|
194
|
-
};
|
|
195
|
-
}>> & Readonly<{
|
|
196
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
197
|
-
onOpen?: ((...args: any[]) => any) | undefined;
|
|
198
|
-
onClose?: ((...args: any[]) => any) | undefined;
|
|
199
|
-
}>, {
|
|
200
|
-
modelValue: boolean;
|
|
201
|
-
title: string | object;
|
|
202
|
-
content: DialogContentType;
|
|
203
|
-
html: boolean;
|
|
204
|
-
url: string;
|
|
205
|
-
actions: DialogActionItem[];
|
|
206
|
-
position: DialogPosition;
|
|
207
|
-
effect: DialogEffect;
|
|
208
|
-
overlay: boolean;
|
|
209
|
-
overlayClose: boolean;
|
|
210
|
-
escClose: boolean;
|
|
211
|
-
closable: boolean;
|
|
212
|
-
width: string | number;
|
|
213
|
-
fullscreen: boolean;
|
|
214
|
-
zIndex: number;
|
|
215
|
-
dialogClass: any;
|
|
216
|
-
dialogStyle: string | CSSProperties;
|
|
217
|
-
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
218
|
-
declare const BestDialogContainer: vue.DefineComponent<{}, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
219
|
-
[key: string]: any;
|
|
220
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
221
|
-
|
|
222
|
-
export { BestDialog, BestDialogContainer, showDialog, useDialog };
|
|
223
|
-
export type { DialogAction, DialogActionItem, DialogCloseEvent, DialogContentType, DialogEffect, DialogHandle, DialogOptions, DialogPosition };
|
package/dist/runtime/plugin.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|