luna-plus 0.0.7 → 0.0.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/dist/MessageBox/index.js
CHANGED
|
@@ -1,32 +1,85 @@
|
|
|
1
|
+
import { mount, unmount } from 'svelte';
|
|
2
|
+
import MessageBox from './MessageBox.svelte';
|
|
3
|
+
let containerEl = null;
|
|
4
|
+
let messageBoxInstance = null;
|
|
5
|
+
/** 确保 MessageBox 容器已挂载 */
|
|
6
|
+
const ensureContainer = () => {
|
|
7
|
+
if (typeof window === 'undefined')
|
|
8
|
+
return;
|
|
9
|
+
if (containerEl)
|
|
10
|
+
return;
|
|
11
|
+
containerEl = document.createElement('div');
|
|
12
|
+
containerEl.className = 'lm-messagebox-container';
|
|
13
|
+
document.body.appendChild(containerEl);
|
|
14
|
+
messageBoxInstance = mount(MessageBox, {
|
|
15
|
+
target: containerEl,
|
|
16
|
+
props: {}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
1
19
|
/** 显示消息框 */
|
|
2
20
|
export const showMessageBox = (options) => {
|
|
3
21
|
return new Promise((resolve) => {
|
|
4
|
-
|
|
5
|
-
options.onOk?.();
|
|
6
|
-
resolve(true);
|
|
7
|
-
};
|
|
8
|
-
const onCancel = () => {
|
|
9
|
-
options.onCancel?.();
|
|
22
|
+
if (typeof window === 'undefined') {
|
|
10
23
|
resolve(false);
|
|
11
|
-
|
|
12
|
-
// 实际实现需要挂载组件,这里提供基础结构
|
|
13
|
-
console.log('MessageBox:', options);
|
|
14
|
-
// 模拟异步确认
|
|
15
|
-
if (typeof window !== 'undefined' && window.confirm(options.content)) {
|
|
16
|
-
onOk();
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
onCancel();
|
|
24
|
+
return;
|
|
20
25
|
}
|
|
26
|
+
ensureContainer();
|
|
27
|
+
const wrappedOptions = {
|
|
28
|
+
...options,
|
|
29
|
+
onOk: () => {
|
|
30
|
+
options.onOk?.();
|
|
31
|
+
resolve(true);
|
|
32
|
+
},
|
|
33
|
+
onCancel: () => {
|
|
34
|
+
options.onCancel?.();
|
|
35
|
+
resolve(false);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// 派发自定义事件触发 MessageBox 组件
|
|
39
|
+
const event = new CustomEvent('lumen-messagebox', {
|
|
40
|
+
detail: wrappedOptions
|
|
41
|
+
});
|
|
42
|
+
window.dispatchEvent(event);
|
|
21
43
|
});
|
|
22
44
|
};
|
|
23
45
|
/** 便捷方法 */
|
|
24
46
|
export const messageBox = {
|
|
25
47
|
show: showMessageBox,
|
|
26
|
-
alert: (content, title) => showMessageBox({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
alert: (content, title) => showMessageBox({
|
|
49
|
+
content,
|
|
50
|
+
title,
|
|
51
|
+
type: 'info',
|
|
52
|
+
okText: '确定'
|
|
53
|
+
}),
|
|
54
|
+
confirm: (content, title) => showMessageBox({
|
|
55
|
+
content,
|
|
56
|
+
title,
|
|
57
|
+
type: 'warning',
|
|
58
|
+
okText: '确定',
|
|
59
|
+
cancelText: '取消'
|
|
60
|
+
}),
|
|
61
|
+
success: (content, title) => showMessageBox({
|
|
62
|
+
content,
|
|
63
|
+
title,
|
|
64
|
+
type: 'success',
|
|
65
|
+
okText: '确定'
|
|
66
|
+
}),
|
|
67
|
+
warning: (content, title) => showMessageBox({
|
|
68
|
+
content,
|
|
69
|
+
title,
|
|
70
|
+
type: 'warning',
|
|
71
|
+
okText: '确定'
|
|
72
|
+
}),
|
|
73
|
+
error: (content, title) => showMessageBox({
|
|
74
|
+
content,
|
|
75
|
+
title,
|
|
76
|
+
type: 'error',
|
|
77
|
+
okText: '确定'
|
|
78
|
+
}),
|
|
79
|
+
info: (content, title) => showMessageBox({
|
|
80
|
+
content,
|
|
81
|
+
title,
|
|
82
|
+
type: 'info',
|
|
83
|
+
okText: '确定'
|
|
84
|
+
})
|
|
32
85
|
};
|
|
@@ -1,21 +1,56 @@
|
|
|
1
|
-
import type { PaginationLayout } from './types';
|
|
1
|
+
import type { PaginationLayout, PaginationSize, PaginationShowTotal } from './types';
|
|
2
2
|
interface PaginationProps {
|
|
3
|
-
|
|
3
|
+
/** 当前页(受控) */
|
|
4
|
+
current?: number;
|
|
5
|
+
/** 默认当前页(非受控) */
|
|
6
|
+
defaultCurrent?: number;
|
|
7
|
+
|
|
8
|
+
/** 每页条数(受控) */
|
|
4
9
|
pageSize?: number;
|
|
10
|
+
/** 默认每页条数(非受控) */
|
|
11
|
+
defaultPageSize?: number;
|
|
12
|
+
|
|
13
|
+
/** 总条数 */
|
|
5
14
|
total?: number;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
/** 页码按钮数量 */
|
|
16
|
+
pageBufferSize?: number;
|
|
17
|
+
|
|
18
|
+
/** 是否禁用 */
|
|
9
19
|
disabled?: boolean;
|
|
20
|
+
/** 是否隐藏只有一页时的分页 */
|
|
10
21
|
hideOnSinglePage?: boolean;
|
|
11
|
-
|
|
22
|
+
|
|
23
|
+
/** 尺寸 */
|
|
24
|
+
size?: PaginationSize;
|
|
25
|
+
/** 是否使用背景色 */
|
|
12
26
|
background?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
/** 简洁模式 */
|
|
28
|
+
simple?: boolean;
|
|
29
|
+
|
|
30
|
+
/** 是否显示总数 */
|
|
31
|
+
showTotal?: boolean | PaginationShowTotal;
|
|
32
|
+
/** 是否显示 pageSize 选择器 */
|
|
33
|
+
showSizeChanger?: boolean;
|
|
34
|
+
/** pageSize 选项 */
|
|
35
|
+
pageSizeOptions?: number[];
|
|
36
|
+
/** 是否显示快速跳转 */
|
|
37
|
+
showQuickJumper?: boolean;
|
|
38
|
+
|
|
39
|
+
/** 布局 */
|
|
40
|
+
layout?: PaginationLayout[];
|
|
41
|
+
|
|
42
|
+
/** 页码变化回调 */
|
|
43
|
+
onChange?: (page: number, pageSize: number) => void;
|
|
44
|
+
/** pageSize 变化回调 */
|
|
45
|
+
onShowSizeChange?: (current: number, size: number) => void;
|
|
46
|
+
|
|
47
|
+
/** 上一页文本 */
|
|
15
48
|
prevText?: string;
|
|
49
|
+
/** 下一页文本 */
|
|
16
50
|
nextText?: string;
|
|
51
|
+
/** 自定义类名 */
|
|
17
52
|
class?: string;
|
|
18
53
|
}
|
|
19
|
-
declare const Pagination: import("svelte").Component<PaginationProps, {}, "
|
|
54
|
+
declare const Pagination: import("svelte").Component<PaginationProps, {}, "current" | "pageSize">;
|
|
20
55
|
type Pagination = ReturnType<typeof Pagination>;
|
|
21
56
|
export default Pagination;
|