@manohub/ui 1.3.2 → 1.3.4
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 +25 -4
- package/dist/components/button/index.d.ts +5 -5
- package/dist/components/button/index.js +1 -1
- package/dist/components/card/index.d.ts +3 -3
- package/dist/components/checkbox/index.d.ts +30 -25
- package/dist/components/checkbox/index.js +16 -11
- package/dist/components/dialog/index.d.ts +121 -120
- package/dist/components/dialog/index.js +122 -144
- package/dist/components/divider/index.d.ts +1 -1
- package/dist/components/drawer/index.d.ts +53 -54
- package/dist/components/drawer/index.js +71 -96
- package/dist/components/form/index.d.ts +3 -3
- package/dist/components/form/index.js +1 -1
- package/dist/components/input/index.d.ts +1 -2
- package/dist/components/layout/index.d.ts +2 -2
- package/dist/components/layout/index.js +1 -1
- package/dist/components/list/tree.d.ts +5 -5
- package/dist/components/list-view/index.d.ts +1 -1
- package/dist/components/notice/index.d.ts +3 -3
- package/dist/components/notice/index.js +1 -1
- package/dist/components/notification/index.d.ts +2 -2
- package/dist/components/page/index.d.ts +1 -1
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/popup/index.d.ts +117 -0
- package/dist/components/popup/index.js +223 -0
- package/dist/components/popup/inert-scope.d.ts +22 -0
- package/dist/components/popup/inert-scope.js +54 -0
- package/dist/components/popup/scroll-lock.d.ts +2 -0
- package/dist/components/popup/scroll-lock.js +43 -0
- package/dist/components/query-state/index.d.ts +1 -1
- package/dist/components/radio/index.d.ts +18 -19
- package/dist/components/radio/index.js +12 -6
- package/dist/components/scrollbar/index.d.ts +4 -4
- package/dist/components/steps/index.d.ts +7 -7
- package/dist/components/steps/index.js +1 -1
- package/dist/components/tabbar/index.d.ts +1 -1
- package/dist/components/table/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/services/dialog.d.ts +5 -5
- package/dist/services/dialog.js +9 -6
- package/dist/styles/components/avatar.css +3 -3
- package/dist/styles/components/badge.css +4 -4
- package/dist/styles/components/button.css +11 -12
- package/dist/styles/components/button.tokens.css +20 -21
- package/dist/styles/components/capsule.css +4 -4
- package/dist/styles/components/capsule.tokens.css +7 -7
- package/dist/styles/components/card.css +1 -2
- package/dist/styles/components/card.tokens.css +2 -2
- package/dist/styles/components/checkbox.css +24 -29
- package/dist/styles/components/checkbox.tokens.css +5 -9
- package/dist/styles/components/code-block.css +230 -230
- package/dist/styles/components/code-block.tokens.css +9 -9
- package/dist/styles/components/collapse.css +2 -2
- package/dist/styles/components/collapse.tokens.css +2 -2
- package/dist/styles/components/date-picker.tokens.css +1 -1
- package/dist/styles/components/dialog.css +36 -31
- package/dist/styles/components/dialog.tokens.css +7 -7
- package/dist/styles/components/divider.css +4 -5
- package/dist/styles/components/divider.tokens.css +1 -1
- package/dist/styles/components/drawer.css +15 -24
- package/dist/styles/components/drawer.tokens.css +4 -4
- package/dist/styles/components/filter.css +2 -2
- package/dist/styles/components/form.css +4 -4
- package/dist/styles/components/form.tokens.css +5 -5
- package/dist/styles/components/input.css +8 -8
- package/dist/styles/components/input.tokens.css +16 -18
- package/dist/styles/components/layout.tokens.css +3 -3
- package/dist/styles/components/list-view.tokens.css +2 -2
- package/dist/styles/components/list.css +4 -5
- package/dist/styles/components/list.tokens.css +3 -3
- package/dist/styles/components/loading.css +3 -3
- package/dist/styles/components/loading.tokens.css +4 -3
- package/dist/styles/components/notice.css +8 -9
- package/dist/styles/components/notice.tokens.css +4 -5
- package/dist/styles/components/notification.css +11 -12
- package/dist/styles/components/notification.tokens.css +12 -14
- package/dist/styles/components/page.css +4 -4
- package/dist/styles/components/pagination.css +8 -10
- package/dist/styles/components/pagination.tokens.css +10 -10
- package/dist/styles/components/panel.css +1 -1
- package/dist/styles/components/query-state.css +7 -7
- package/dist/styles/components/query-state.tokens.css +1 -1
- package/dist/styles/components/radio.css +14 -18
- package/dist/styles/components/radio.tokens.css +6 -8
- package/dist/styles/components/scrollbar.css +2 -2
- package/dist/styles/components/select.css +4 -4
- package/dist/styles/components/select.tokens.css +5 -5
- package/dist/styles/components/skeleton.css +1 -1
- package/dist/styles/components/skeleton.tokens.css +7 -8
- package/dist/styles/components/steps.css +5 -5
- package/dist/styles/components/steps.tokens.css +10 -11
- package/dist/styles/components/switch.css +2 -2
- package/dist/styles/components/switch.tokens.css +5 -5
- package/dist/styles/components/tabbar.css +1 -2
- package/dist/styles/components/tabbar.tokens.css +9 -9
- package/dist/styles/components/table.css +8 -10
- package/dist/styles/components/table.tokens.css +6 -6
- package/dist/styles/components/tag.css +3 -3
- package/dist/styles/components/tag.tokens.css +2 -2
- package/dist/styles/components/toast.css +8 -8
- package/dist/styles/components/toast.tokens.css +7 -6
- package/dist/styles/components/tooltip.css +3 -3
- package/dist/styles/components/tooltip.tokens.css +6 -6
- package/dist/styles/components/upload.css +3 -3
- package/dist/styles/components/upload.tokens.css +8 -8
- package/dist/styles/index.css +1 -0
- package/dist/styles/operations/collapse.css +1 -1
- package/dist/styles/operations/popup-layer.css +95 -0
- package/dist/styles/operations/popup.css +4 -4
- package/dist/styles/operations/tabs.css +3 -3
- package/dist/utils/popup-host.d.ts +36 -0
- package/dist/utils/popup-host.js +21 -0
- package/dist/utils/scope-svg-ids.d.ts +4 -4
- package/dist/utils/state-illustration.d.ts +8 -8
- package/package.json +3 -3
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { defineComponent, ref, computed,
|
|
1
|
+
import { defineComponent, ref, computed, createVNode } from "vue";
|
|
2
2
|
import { Icon } from "@manohub/icon";
|
|
3
3
|
import { Button } from "../button/index.js";
|
|
4
|
+
import { Popup } from "../popup/index.js";
|
|
4
5
|
import { useOverlayScrollbar } from "../scrollbar/index.js";
|
|
6
|
+
import { resolvePopupHost } from "../../utils/popup-host.js";
|
|
5
7
|
const TONE_ICON = {
|
|
6
8
|
info: "info-circle",
|
|
7
9
|
success: "check-circle",
|
|
@@ -25,7 +27,7 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
25
27
|
/**
|
|
26
28
|
* 语义档(缺省不渲染图标):`warning` / `error` 用于「这一步有风险」的确认 ——
|
|
27
29
|
* 服务层的 `confirm()` / `alert()` 就是靠它把「删除确认」与「保存成功」区分开的。
|
|
28
|
-
* 它**只加一个带圈语义图标与配色**,不改标题文案、不动底栏按钮的语义(危险色仍由 `
|
|
30
|
+
* 它**只加一个带圈语义图标与配色**,不改标题文案、不动底栏按钮的语义(危险色仍由 `confirmDanger` 定)。
|
|
29
31
|
*/
|
|
30
32
|
tone: {
|
|
31
33
|
type: String,
|
|
@@ -36,22 +38,54 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
36
38
|
type: [String, Number],
|
|
37
39
|
default: "md"
|
|
38
40
|
},
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
type:
|
|
42
|
-
default:
|
|
41
|
+
/** 大小档(如 `700px` / `min(720px, 90vw)`),给它就是唯一宽度来源 */
|
|
42
|
+
panelWidth: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: void 0
|
|
43
45
|
},
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
47
|
+
* 固定高度(如 `480px` / `min(560px, 80vh)`)—— 与 `panelWidth` 对称。
|
|
48
|
+
* 给了之后内容区吃满剩余高度并自行滚动,页头与底栏始终可见(`styles/components/dialog.css` 的三段布局)。
|
|
49
|
+
*/
|
|
50
|
+
panelHeight: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: void 0
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* 是否在页头提供「全屏 / 退出全屏」按钮(关闭位左边)。
|
|
46
56
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
57
|
+
* 尺寸归本件:全屏档是「可见区域减 32」(四周各留 16),消费方不用再按视口折算宽度、
|
|
58
|
+
* 也不用写 `calc()` / `min()`。触发点要在内容区(如编辑器动作列)时**不传本 prop**,
|
|
59
|
+
* 改用 `v-model:fullscreen` 从外部驱动,尺寸仍由本件管。
|
|
49
60
|
*/
|
|
50
|
-
|
|
61
|
+
fullscreenable: {
|
|
51
62
|
type: Boolean,
|
|
52
63
|
default: false
|
|
53
64
|
},
|
|
54
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* 受控全屏态(`v-model:fullscreen`)。不传 = 本件自持(非受控),
|
|
67
|
+
* 传了就以外部为准:点按钮只上报 `update:fullscreen`,不自己翻。
|
|
68
|
+
*/
|
|
69
|
+
fullscreen: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: void 0
|
|
72
|
+
},
|
|
73
|
+
/** Teleport 目标(选择器 / 元素 / 取值函数) */
|
|
74
|
+
host: {
|
|
75
|
+
type: [String, Object, Function],
|
|
76
|
+
default: void 0
|
|
77
|
+
},
|
|
78
|
+
/** 是否显示遮罩(缺省 `true`):`false` 只改底色,不改模态语义,并关掉点空白关闭 */
|
|
79
|
+
mask: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: true
|
|
82
|
+
},
|
|
83
|
+
/** 是否显示关闭位 */
|
|
84
|
+
closable: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: true
|
|
87
|
+
},
|
|
88
|
+
/** 点遮罩是否关闭 */
|
|
55
89
|
maskClosable: {
|
|
56
90
|
type: Boolean,
|
|
57
91
|
default: false
|
|
@@ -61,21 +95,13 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
61
95
|
type: Boolean,
|
|
62
96
|
default: true
|
|
63
97
|
},
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
type:
|
|
67
|
-
default: void 0
|
|
68
|
-
},
|
|
69
|
-
/**
|
|
70
|
-
* 固定高度(如 `480px` / `min(560px, 80vh)`)—— 与 `panelWidth` 对称。
|
|
71
|
-
* 给了之后内容区吃满剩余高度并自行滚动,页头与底栏始终可见(`styles/components/dialog.css` 的三段布局)。
|
|
72
|
-
*/
|
|
73
|
-
panelHeight: {
|
|
74
|
-
type: String,
|
|
98
|
+
/** 是否渲染内建底栏;缺省 = 「给了 `onConfirm` 才渲染」 */
|
|
99
|
+
showFooter: {
|
|
100
|
+
type: Boolean,
|
|
75
101
|
default: void 0
|
|
76
102
|
},
|
|
77
103
|
/** 内建底栏:确定按钮文案 */
|
|
78
|
-
|
|
104
|
+
confirmText: {
|
|
79
105
|
type: String,
|
|
80
106
|
default: "确定"
|
|
81
107
|
},
|
|
@@ -85,22 +111,17 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
85
111
|
default: "取消"
|
|
86
112
|
},
|
|
87
113
|
/** 确定按钮的危险色(删除类确认) */
|
|
88
|
-
|
|
114
|
+
confirmDanger: {
|
|
89
115
|
type: Boolean,
|
|
90
116
|
default: false
|
|
91
117
|
},
|
|
92
|
-
/** 确定按钮的加载态(外部受控;`
|
|
118
|
+
/** 确定按钮的加载态(外部受控;`onConfirm` 返回 Promise 时本件也会自己管) */
|
|
93
119
|
confirmLoading: {
|
|
94
120
|
type: Boolean,
|
|
95
121
|
default: false
|
|
96
122
|
},
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
type: Boolean,
|
|
100
|
-
default: void 0
|
|
101
|
-
},
|
|
102
|
-
/** 确定回调(返回 Promise 时按钮自动进加载态;返回值类型不限,非 thenable 一律忽略) */
|
|
103
|
-
onOk: {
|
|
123
|
+
/** 确定回调(返回 Promise 时按钮自动进加载态;非 thenable 一律忽略) */
|
|
124
|
+
onConfirm: {
|
|
104
125
|
type: Function,
|
|
105
126
|
default: void 0
|
|
106
127
|
},
|
|
@@ -113,27 +134,6 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
113
134
|
onClose: {
|
|
114
135
|
type: Function,
|
|
115
136
|
default: void 0
|
|
116
|
-
},
|
|
117
|
-
/**
|
|
118
|
-
* 是否在页头提供「全屏 / 退出全屏」按钮(关闭位左边)。
|
|
119
|
-
*
|
|
120
|
-
* <p>尺寸归本件:全屏档是「视口减 32」(四周各留 16),消费方不用再按视口折算宽度、
|
|
121
|
-
* 也不用写 `calc()` / `min()`。</p>
|
|
122
|
-
*
|
|
123
|
-
* <p>触发点要在内容区(如编辑器动作列)时**不传本 prop**,改用 `v-model:fullscreen`
|
|
124
|
-
* 从外部驱动,尺寸仍由本件管。</p>
|
|
125
|
-
*/
|
|
126
|
-
fullscreenable: {
|
|
127
|
-
type: Boolean,
|
|
128
|
-
default: false
|
|
129
|
-
},
|
|
130
|
-
/**
|
|
131
|
-
* 受控全屏态(`v-model:fullscreen`)。不传 = 本件自持(非受控),
|
|
132
|
-
* 传了就以外部为准:点按钮只上报 `update:fullscreen`,不自己翻。
|
|
133
|
-
*/
|
|
134
|
-
fullscreen: {
|
|
135
|
-
type: Boolean,
|
|
136
|
-
default: void 0
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
emits: {
|
|
@@ -146,10 +146,10 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
146
146
|
slots,
|
|
147
147
|
attrs
|
|
148
148
|
}) {
|
|
149
|
-
const dialogRef = ref(null);
|
|
150
149
|
const scrollRef = ref(null);
|
|
151
150
|
const scrollbar = useOverlayScrollbar(scrollRef);
|
|
152
151
|
const innerLoading = ref(false);
|
|
152
|
+
const isHost = computed(() => (props.host === void 0 ? resolvePopupHost() : resolvePopupHost(props.host)) !== null);
|
|
153
153
|
const innerFullscreen = ref(false);
|
|
154
154
|
const isFullscreen = computed(() => props.fullscreen ?? innerFullscreen.value);
|
|
155
155
|
const setFullscreen = (value) => {
|
|
@@ -161,47 +161,32 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
161
161
|
props.onClose?.();
|
|
162
162
|
emit("update:open", false);
|
|
163
163
|
};
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (!el.open && typeof el.showModal === "function") {
|
|
169
|
-
el.showModal();
|
|
170
|
-
el.focus({
|
|
171
|
-
preventScroll: true
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
} else if (el.open && typeof el.close === "function") {
|
|
175
|
-
el.close();
|
|
176
|
-
}
|
|
164
|
+
const handleEscape = () => {
|
|
165
|
+
if (!isFullscreen.value) return false;
|
|
166
|
+
setFullscreen(false);
|
|
167
|
+
return true;
|
|
177
168
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
181
|
-
onMounted(syncOpen);
|
|
182
|
-
onBeforeUnmount(() => {
|
|
183
|
-
const el = dialogRef.value;
|
|
184
|
-
if (el?.open && typeof el.close === "function") el.close();
|
|
185
|
-
});
|
|
186
|
-
const handleOk = () => {
|
|
187
|
-
const result = props.onOk?.();
|
|
169
|
+
const handleConfirm = () => {
|
|
170
|
+
const result = props.onConfirm?.();
|
|
188
171
|
if (result && typeof result.then === "function") {
|
|
189
172
|
innerLoading.value = true;
|
|
190
173
|
void result.finally(() => innerLoading.value = false);
|
|
191
174
|
}
|
|
192
175
|
};
|
|
193
176
|
const loading = computed(() => props.confirmLoading || innerLoading.value);
|
|
194
|
-
const showBuiltinFooter = computed(() => props.showFooter ?? props.
|
|
177
|
+
const showBuiltinFooter = computed(() => props.showFooter ?? props.onConfirm !== void 0);
|
|
178
|
+
const widthBounds = computed(() => isHost.value ? "100%" : "100vw");
|
|
179
|
+
const heightBounds = computed(() => isHost.value ? "100%" : "100vh");
|
|
195
180
|
const widthStyle = computed(() => {
|
|
196
181
|
if (isFullscreen.value) return void 0;
|
|
197
182
|
if (props.panelWidth) return {
|
|
198
183
|
width: props.panelWidth,
|
|
199
|
-
maxWidth:
|
|
184
|
+
maxWidth: `calc(${widthBounds.value} - 32px)`
|
|
200
185
|
};
|
|
201
186
|
if (typeof props.width === "number") {
|
|
202
187
|
return {
|
|
203
188
|
width: `${props.width}px`,
|
|
204
|
-
maxWidth:
|
|
189
|
+
maxWidth: `calc(${widthBounds.value} - 32px)`
|
|
205
190
|
};
|
|
206
191
|
}
|
|
207
192
|
return void 0;
|
|
@@ -209,77 +194,70 @@ const Dialog = /* @__PURE__ */ defineComponent({
|
|
|
209
194
|
const widthClass = computed(() => !isFullscreen.value && typeof props.width === "string" && props.width !== "md" ? `mh-dialog--${props.width}` : "");
|
|
210
195
|
const heightStyle = computed(() => !isFullscreen.value && props.panelHeight ? {
|
|
211
196
|
height: props.panelHeight,
|
|
212
|
-
maxHeight:
|
|
197
|
+
maxHeight: `calc(${heightBounds.value} - 32px)`
|
|
213
198
|
} : void 0);
|
|
214
|
-
return () => createVNode(
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
199
|
+
return () => createVNode(Popup, {
|
|
200
|
+
"open": props.open,
|
|
201
|
+
"host": props.host,
|
|
202
|
+
"mask": props.mask,
|
|
203
|
+
"maskClosable": props.maskClosable,
|
|
204
|
+
"keyboard": props.keyboard,
|
|
205
|
+
"onEscape": handleEscape,
|
|
206
|
+
"onRequestClose": requestClose,
|
|
207
|
+
"class": ["mh-dialog", widthClass.value, isFullscreen.value ? "mh-dialog--fullscreen" : "", props.tone ? `mh-dialog--${props.tone}` : "", isHost.value ? "mh-dialog--host" : "", attrs.class].filter(Boolean).join(" "),
|
|
218
208
|
"style": {
|
|
219
209
|
...widthStyle.value,
|
|
220
210
|
...heightStyle.value,
|
|
221
211
|
...attrs.style
|
|
222
|
-
},
|
|
223
|
-
"onCancel": (event) => {
|
|
224
|
-
event.preventDefault();
|
|
225
|
-
if (isFullscreen.value) {
|
|
226
|
-
setFullscreen(false);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (!props.keyboard) return;
|
|
230
|
-
requestClose("cancel");
|
|
231
|
-
},
|
|
232
|
-
"onClick": (event) => {
|
|
233
|
-
if ((props.closeOnBackdrop || props.maskClosable) && event.target === dialogRef.value) {
|
|
234
|
-
requestClose("close");
|
|
235
|
-
}
|
|
236
212
|
}
|
|
237
|
-
}, [props.title || slots.title || props.closable || props.tone || props.fullscreenable ? createVNode("div", {
|
|
238
|
-
"class": "mh-dialog__header"
|
|
239
|
-
}, [props.tone ? createVNode(Icon, {
|
|
240
|
-
"name": TONE_ICON[props.tone],
|
|
241
|
-
"class": "mh-dialog__tone-icon"
|
|
242
|
-
}, null) : null, createVNode("span", {
|
|
243
|
-
"class": "mh-dialog__title"
|
|
244
|
-
}, [slots.title ? slots.title() : props.title]), props.fullscreenable ? createVNode("button", {
|
|
245
|
-
"type": "button",
|
|
246
|
-
"class": "mh-dialog__fullscreen",
|
|
247
|
-
"aria-label": isFullscreen.value ? "退出全屏" : "全屏",
|
|
248
|
-
"aria-pressed": isFullscreen.value,
|
|
249
|
-
"onClick": () => setFullscreen(!isFullscreen.value)
|
|
250
|
-
}, [createVNode(Icon, {
|
|
251
|
-
"name": isFullscreen.value ? "minimize" : "maximize",
|
|
252
|
-
"size": 14
|
|
253
|
-
}, null)]) : null, props.closable ? createVNode("button", {
|
|
254
|
-
"type": "button",
|
|
255
|
-
"class": "mh-dialog__close",
|
|
256
|
-
"aria-label": "关闭",
|
|
257
|
-
"onClick": () => requestClose("cancel")
|
|
258
|
-
}, [createVNode(Icon, {
|
|
259
|
-
"name": "close",
|
|
260
|
-
"size": 14
|
|
261
|
-
}, null)]) : null]) : null, createVNode("div", {
|
|
262
|
-
"class": "mh-dialog__body"
|
|
263
|
-
}, [createVNode("div", {
|
|
264
|
-
"class": "mh-dialog__scroll",
|
|
265
|
-
"ref": scrollRef
|
|
266
|
-
}, [slots.default?.()]), scrollbar.render()]), slots.footer ? createVNode("div", {
|
|
267
|
-
"class": "mh-dialog__footer"
|
|
268
|
-
}, [slots.footer()]) : showBuiltinFooter.value ? createVNode("div", {
|
|
269
|
-
"class": "mh-dialog__footer"
|
|
270
|
-
}, [createVNode(Button, {
|
|
271
|
-
"variant": "secondary",
|
|
272
|
-
"onClick": () => requestClose("cancel")
|
|
273
213
|
}, {
|
|
274
|
-
default: () => props.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
"
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
214
|
+
default: () => [props.title || slots.title || props.closable || props.tone || props.fullscreenable ? createVNode("div", {
|
|
215
|
+
"class": "mh-dialog__header"
|
|
216
|
+
}, [props.tone ? createVNode(Icon, {
|
|
217
|
+
"name": TONE_ICON[props.tone],
|
|
218
|
+
"class": "mh-dialog__tone-icon"
|
|
219
|
+
}, null) : null, createVNode("span", {
|
|
220
|
+
"class": "mh-dialog__title"
|
|
221
|
+
}, [slots.title ? slots.title() : props.title]), props.fullscreenable ? createVNode("button", {
|
|
222
|
+
"type": "button",
|
|
223
|
+
"class": "mh-dialog__fullscreen",
|
|
224
|
+
"aria-label": isFullscreen.value ? "退出全屏" : "全屏",
|
|
225
|
+
"aria-pressed": isFullscreen.value,
|
|
226
|
+
"onClick": () => setFullscreen(!isFullscreen.value)
|
|
227
|
+
}, [createVNode(Icon, {
|
|
228
|
+
"name": isFullscreen.value ? "minimize" : "maximize",
|
|
229
|
+
"size": 14
|
|
230
|
+
}, null)]) : null, props.closable ? createVNode("button", {
|
|
231
|
+
"type": "button",
|
|
232
|
+
"class": "mh-dialog__close",
|
|
233
|
+
"aria-label": "关闭",
|
|
234
|
+
"onClick": () => requestClose("cancel")
|
|
235
|
+
}, [createVNode(Icon, {
|
|
236
|
+
"name": "close",
|
|
237
|
+
"size": 14
|
|
238
|
+
}, null)]) : null]) : null, createVNode("div", {
|
|
239
|
+
"class": "mh-dialog__body"
|
|
240
|
+
}, [createVNode("div", {
|
|
241
|
+
"class": "mh-dialog__scroll",
|
|
242
|
+
"ref": scrollRef
|
|
243
|
+
}, [slots.default?.()]), scrollbar.render()]), slots.footer ? createVNode("div", {
|
|
244
|
+
"class": "mh-dialog__footer"
|
|
245
|
+
}, [slots.footer()]) : showBuiltinFooter.value ? createVNode("div", {
|
|
246
|
+
"class": "mh-dialog__footer"
|
|
247
|
+
}, [createVNode(Button, {
|
|
248
|
+
"variant": "secondary",
|
|
249
|
+
"onClick": () => requestClose("cancel")
|
|
250
|
+
}, {
|
|
251
|
+
default: () => props.cancelText
|
|
252
|
+
}), createVNode(Button, {
|
|
253
|
+
"variant": "primary",
|
|
254
|
+
"danger": props.confirmDanger,
|
|
255
|
+
"loading": loading.value,
|
|
256
|
+
"onClick": handleConfirm
|
|
257
|
+
}, {
|
|
258
|
+
default: () => props.confirmText
|
|
259
|
+
})]) : null]
|
|
260
|
+
});
|
|
283
261
|
}
|
|
284
262
|
});
|
|
285
263
|
export {
|
|
@@ -2,7 +2,7 @@ import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
|
2
2
|
export interface DividerProps {
|
|
3
3
|
/** 方向:`horizontal`(缺省,分隔上下内容)/ `vertical`(分隔左右内容,高度由父容器拉伸) */
|
|
4
4
|
direction?: 'horizontal' | 'vertical';
|
|
5
|
-
/**
|
|
5
|
+
/** 虚线档(沿用「实线为默认」的惯例,虚线给弱分组用) */
|
|
6
6
|
dashed?: boolean;
|
|
7
7
|
/** 中段文字(只用水平档:给线让位,左段固定 24、右段吃剩余) */
|
|
8
8
|
label?: string;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
import { type PopupHostTarget } from '../../utils/popup-host';
|
|
2
3
|
/** 贴哪一侧滑出:`right`(缺省,属性 / 详情面板)/ `left`(导航 / 目录) */
|
|
3
4
|
export type DrawerSide = 'left' | 'right';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* 抽屉(**自绘**;落位与开合归内件 `Popup`,与 `Dialog` 共用同一份)。
|
|
6
7
|
*
|
|
7
|
-
* ## 与 `Dialog`
|
|
8
|
+
* ## 与 `Dialog` 的关系:同一套开合,只换落位
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
12
|
-
* 差异只有一条:本件贴屏幕某一侧、**整屏高**,而不是视口居中。
|
|
10
|
+
* 「插到哪 / `showModal()` 还是 `show()` / 遮罩在哪 / Esc / 焦点归还」全在 `Popup`(两件零重复);
|
|
11
|
+
* 本件只负责:贴屏幕某一侧、**整屏高**,以及自己的页头 / 正文 / 底栏三段。宿主态下把「贴视口」换成
|
|
12
|
+
* 「贴容器」(`mh-drawer--host`:`fixed` → `absolute`、高度随容器),侧贴沿用。
|
|
13
13
|
* **不另开一套浮层机制**:抽屉不是「新的定位体系」,是同一张面板换个落位 —— 故类名同样并列 `.mh-popup`
|
|
14
14
|
* (操作层状态根)+ 本族皮肤,开合 / 遮罩 / UA 装饰归零全部免费继承。
|
|
15
15
|
*
|
|
16
16
|
* ## 关闭是受控的
|
|
17
17
|
*
|
|
18
|
-
* 关闭位、Esc(原生 `cancel`
|
|
19
|
-
*
|
|
18
|
+
* 关闭位、Esc(原生 `cancel` 事件 / 宿主态的 `keydown`)与点遮罩都只回调(`update:open(false)` +
|
|
19
|
+
* `onClose()` / `onCancel()`);可见性归消费方 —— 避免「组件自己消失、业务状态还以为开着」两套口径。
|
|
20
20
|
*
|
|
21
21
|
* ## 底栏三态(**由消费方按需选一**,不要混着用)
|
|
22
22
|
*
|
|
23
23
|
* | 用法 | 结果 |
|
|
24
24
|
* | --- | --- |
|
|
25
25
|
* | 给 `footer` 插槽 | 完全自绘底栏(要用别的按钮形态时选这条) |
|
|
26
|
-
* | 给 `
|
|
26
|
+
* | 给 `confirmText` / `onConfirm` | 内建底栏:`[取消] [确定]`,按钮就是本包 `Button` |
|
|
27
27
|
* | `:show-footer="false"` | 不渲染底栏(纯展示抽屉) |
|
|
28
28
|
*
|
|
29
29
|
* 用法见 `docs/demos/drawer/`(每个维度一份可运行样例;文档页 `docs/components/drawer.md`)。
|
|
@@ -49,23 +49,22 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
49
49
|
type: PropType<number | string>;
|
|
50
50
|
default: number;
|
|
51
51
|
};
|
|
52
|
-
/**
|
|
53
|
-
|
|
52
|
+
/** Teleport 目标(选择器 / 元素 / 取值函数) */
|
|
53
|
+
host: {
|
|
54
|
+
type: PropType<PopupHostTarget | null>;
|
|
55
|
+
default: undefined;
|
|
56
|
+
};
|
|
57
|
+
/** 是否显示遮罩(缺省 `true`):`false` 只改底色,不改模态语义,并关掉点空白关闭 */
|
|
58
|
+
mask: {
|
|
54
59
|
type: BooleanConstructor;
|
|
55
60
|
default: boolean;
|
|
56
61
|
};
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
* 「误点遮罩丢掉填了一半的表单」比「多点一次关闭」代价高,故缺省关;
|
|
61
|
-
* 「看一眼就关」的帮助 / 预览类抽屉自己显式传 `:close-on-backdrop="true"`。
|
|
62
|
-
* 与 `Dialog` 同一口径;命令式 `confirm()` / `alert()` 显式传 `false`,不受本缺省影响。
|
|
63
|
-
*/
|
|
64
|
-
closeOnBackdrop: {
|
|
62
|
+
/** 是否显示关闭位 */
|
|
63
|
+
closable: {
|
|
65
64
|
type: BooleanConstructor;
|
|
66
65
|
default: boolean;
|
|
67
66
|
};
|
|
68
|
-
/**
|
|
67
|
+
/** 点遮罩是否关闭 */
|
|
69
68
|
maskClosable: {
|
|
70
69
|
type: BooleanConstructor;
|
|
71
70
|
default: boolean;
|
|
@@ -75,8 +74,13 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
75
74
|
type: BooleanConstructor;
|
|
76
75
|
default: boolean;
|
|
77
76
|
};
|
|
77
|
+
/** 是否渲染内建底栏;缺省 = 「给了 `onConfirm` 才渲染」 */
|
|
78
|
+
showFooter: {
|
|
79
|
+
type: PropType<boolean | undefined>;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
78
82
|
/** 内建底栏:确定按钮文案 */
|
|
79
|
-
|
|
83
|
+
confirmText: {
|
|
80
84
|
type: StringConstructor;
|
|
81
85
|
default: string;
|
|
82
86
|
};
|
|
@@ -86,22 +90,17 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
86
90
|
default: string;
|
|
87
91
|
};
|
|
88
92
|
/** 确定按钮的危险色(删除类确认) */
|
|
89
|
-
|
|
93
|
+
confirmDanger: {
|
|
90
94
|
type: BooleanConstructor;
|
|
91
95
|
default: boolean;
|
|
92
96
|
};
|
|
93
|
-
/** 确定按钮的加载态(外部受控;`
|
|
97
|
+
/** 确定按钮的加载态(外部受控;`onConfirm` 返回 Promise 时本件也会自己管) */
|
|
94
98
|
confirmLoading: {
|
|
95
99
|
type: BooleanConstructor;
|
|
96
100
|
default: boolean;
|
|
97
101
|
};
|
|
98
|
-
/** 是否渲染内建底栏;缺省 = 「给了 `onOk` 才渲染」 */
|
|
99
|
-
showFooter: {
|
|
100
|
-
type: PropType<boolean | undefined>;
|
|
101
|
-
default: undefined;
|
|
102
|
-
};
|
|
103
102
|
/** 确定回调(返回 Promise 时按钮自动进加载态;非 thenable 一律忽略) */
|
|
104
|
-
|
|
103
|
+
onConfirm: {
|
|
105
104
|
type: PropType<() => unknown>;
|
|
106
105
|
default: undefined;
|
|
107
106
|
};
|
|
@@ -138,23 +137,22 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
138
137
|
type: PropType<number | string>;
|
|
139
138
|
default: number;
|
|
140
139
|
};
|
|
141
|
-
/**
|
|
142
|
-
|
|
140
|
+
/** Teleport 目标(选择器 / 元素 / 取值函数) */
|
|
141
|
+
host: {
|
|
142
|
+
type: PropType<PopupHostTarget | null>;
|
|
143
|
+
default: undefined;
|
|
144
|
+
};
|
|
145
|
+
/** 是否显示遮罩(缺省 `true`):`false` 只改底色,不改模态语义,并关掉点空白关闭 */
|
|
146
|
+
mask: {
|
|
143
147
|
type: BooleanConstructor;
|
|
144
148
|
default: boolean;
|
|
145
149
|
};
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
*
|
|
149
|
-
* 「误点遮罩丢掉填了一半的表单」比「多点一次关闭」代价高,故缺省关;
|
|
150
|
-
* 「看一眼就关」的帮助 / 预览类抽屉自己显式传 `:close-on-backdrop="true"`。
|
|
151
|
-
* 与 `Dialog` 同一口径;命令式 `confirm()` / `alert()` 显式传 `false`,不受本缺省影响。
|
|
152
|
-
*/
|
|
153
|
-
closeOnBackdrop: {
|
|
150
|
+
/** 是否显示关闭位 */
|
|
151
|
+
closable: {
|
|
154
152
|
type: BooleanConstructor;
|
|
155
153
|
default: boolean;
|
|
156
154
|
};
|
|
157
|
-
/**
|
|
155
|
+
/** 点遮罩是否关闭 */
|
|
158
156
|
maskClosable: {
|
|
159
157
|
type: BooleanConstructor;
|
|
160
158
|
default: boolean;
|
|
@@ -164,8 +162,13 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
164
162
|
type: BooleanConstructor;
|
|
165
163
|
default: boolean;
|
|
166
164
|
};
|
|
165
|
+
/** 是否渲染内建底栏;缺省 = 「给了 `onConfirm` 才渲染」 */
|
|
166
|
+
showFooter: {
|
|
167
|
+
type: PropType<boolean | undefined>;
|
|
168
|
+
default: undefined;
|
|
169
|
+
};
|
|
167
170
|
/** 内建底栏:确定按钮文案 */
|
|
168
|
-
|
|
171
|
+
confirmText: {
|
|
169
172
|
type: StringConstructor;
|
|
170
173
|
default: string;
|
|
171
174
|
};
|
|
@@ -175,22 +178,17 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
175
178
|
default: string;
|
|
176
179
|
};
|
|
177
180
|
/** 确定按钮的危险色(删除类确认) */
|
|
178
|
-
|
|
181
|
+
confirmDanger: {
|
|
179
182
|
type: BooleanConstructor;
|
|
180
183
|
default: boolean;
|
|
181
184
|
};
|
|
182
|
-
/** 确定按钮的加载态(外部受控;`
|
|
185
|
+
/** 确定按钮的加载态(外部受控;`onConfirm` 返回 Promise 时本件也会自己管) */
|
|
183
186
|
confirmLoading: {
|
|
184
187
|
type: BooleanConstructor;
|
|
185
188
|
default: boolean;
|
|
186
189
|
};
|
|
187
|
-
/** 是否渲染内建底栏;缺省 = 「给了 `onOk` 才渲染」 */
|
|
188
|
-
showFooter: {
|
|
189
|
-
type: PropType<boolean | undefined>;
|
|
190
|
-
default: undefined;
|
|
191
|
-
};
|
|
192
190
|
/** 确定回调(返回 Promise 时按钮自动进加载态;非 thenable 一律忽略) */
|
|
193
|
-
|
|
191
|
+
onConfirm: {
|
|
194
192
|
type: PropType<() => unknown>;
|
|
195
193
|
default: undefined;
|
|
196
194
|
};
|
|
@@ -209,20 +207,21 @@ export declare const Drawer: import("vue").DefineComponent<import("vue").Extract
|
|
|
209
207
|
}>, {
|
|
210
208
|
open: boolean;
|
|
211
209
|
title: string;
|
|
210
|
+
mask: boolean;
|
|
212
211
|
onCancel: () => void;
|
|
213
212
|
onClose: () => void;
|
|
214
213
|
width: string | number;
|
|
215
214
|
closable: boolean;
|
|
216
215
|
side: DrawerSide;
|
|
217
|
-
|
|
216
|
+
host: PopupHostTarget | null;
|
|
218
217
|
maskClosable: boolean;
|
|
219
218
|
keyboard: boolean;
|
|
220
|
-
|
|
219
|
+
showFooter: boolean | undefined;
|
|
220
|
+
confirmText: string;
|
|
221
221
|
cancelText: string;
|
|
222
|
-
|
|
222
|
+
confirmDanger: boolean;
|
|
223
223
|
confirmLoading: boolean;
|
|
224
|
-
|
|
225
|
-
onOk: () => unknown;
|
|
224
|
+
onConfirm: () => unknown;
|
|
226
225
|
}, SlotsType<{
|
|
227
226
|
default?: () => VNodeChild;
|
|
228
227
|
title?: () => VNodeChild;
|