@manohub/ui 1.2.12 → 1.2.14
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 +1 -1
- package/dist/components/button/index.d.ts +12 -98
- package/dist/components/button/index.js +17 -41
- package/dist/components/dropdown/dropdown-item.d.ts +88 -0
- package/dist/components/dropdown/dropdown-item.js +84 -0
- package/dist/components/dropdown/dropdown-panel.d.ts +129 -0
- package/dist/components/dropdown/dropdown-panel.js +89 -0
- package/dist/components/dropdown/dropdown-separator.d.ts +1 -0
- package/dist/components/dropdown/dropdown-separator.js +17 -0
- package/dist/components/dropdown/dropdown-shared.d.ts +33 -0
- package/dist/components/dropdown/dropdown-shared.js +8 -0
- package/dist/components/dropdown/index.d.ts +372 -0
- package/dist/components/dropdown/index.js +282 -0
- package/dist/components/select/index.js +2 -1
- package/dist/components/select/select-shared.d.ts +2 -7
- package/dist/components/select/select-shared.js +3 -3
- package/dist/components/select/select-tree.js +2 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/styles/components/button.css +6 -59
- package/dist/styles/components/button.tokens.css +4 -4
- package/dist/styles/components/dialog.css +18 -9
- package/dist/styles/components/drawer.css +25 -9
- package/dist/styles/components/dropdown.css +124 -0
- package/dist/styles/components/dropdown.tokens.css +16 -0
- package/dist/styles/components/tooltip.css +6 -2
- package/dist/styles/index.css +2 -0
- package/dist/styles/operations/popup.css +15 -8
- package/dist/utils/popover.d.ts +14 -0
- package/dist/utils/popover.js +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, watch, onMounted, provide, toRef, createVNode, mergeProps, nextTick } from "vue";
|
|
2
|
+
import { Icon } from "@manohub/icon";
|
|
3
|
+
import { showPanel, hidePanel } from "../../utils/popover.js";
|
|
4
|
+
import { Button } from "../button/index.js";
|
|
5
|
+
import { DropdownItem } from "./dropdown-item.js";
|
|
6
|
+
import { DropdownPanel } from "./dropdown-panel.js";
|
|
7
|
+
import { DropdownSeparator } from "./dropdown-separator.js";
|
|
8
|
+
import { createDropdownPanelId, DROPDOWN_CONTEXT } from "./dropdown-shared.js";
|
|
9
|
+
const dropdownProps = {
|
|
10
|
+
/** 受控开合;给了就是受控(必须接 `update:open` / `v-model:open`) */
|
|
11
|
+
open: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: void 0
|
|
14
|
+
},
|
|
15
|
+
/** 非受控初始开合 */
|
|
16
|
+
defaultOpen: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
/** 内建触发器文案(给 `#trigger` 时不生效) */
|
|
21
|
+
label: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "更多"
|
|
24
|
+
},
|
|
25
|
+
/** 内建触发器的按钮型 */
|
|
26
|
+
variant: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "secondary"
|
|
29
|
+
},
|
|
30
|
+
/** 内建触发器尺寸 + 菜单项密度(`sm` 24 / `md` 32 / `lg` 40) */
|
|
31
|
+
size: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "md"
|
|
34
|
+
},
|
|
35
|
+
/** 整个菜单禁用(触发器不可开、菜单项不响应) */
|
|
36
|
+
disabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
/** 面板落在锚点哪一侧 */
|
|
41
|
+
side: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "bottom"
|
|
44
|
+
},
|
|
45
|
+
/** 两侧对齐;`center` 不写 `data-align` */
|
|
46
|
+
align: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "start"
|
|
49
|
+
},
|
|
50
|
+
/** 面板最小宽度是否对齐触发器 */
|
|
51
|
+
matchWidth: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
/** 选中后是否收起 */
|
|
56
|
+
closeOnSelect: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
60
|
+
/** 菜单的可访问名;不给则由触发器的 id 反推 `aria-labelledby` */
|
|
61
|
+
ariaLabel: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: void 0
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const DropdownBase = /* @__PURE__ */ defineComponent({
|
|
67
|
+
name: "Dropdown",
|
|
68
|
+
inheritAttrs: false,
|
|
69
|
+
props: dropdownProps,
|
|
70
|
+
emits: {
|
|
71
|
+
"update:open": (_open) => true,
|
|
72
|
+
openChange: (_open) => true
|
|
73
|
+
},
|
|
74
|
+
slots: Object,
|
|
75
|
+
setup(props, {
|
|
76
|
+
slots,
|
|
77
|
+
attrs,
|
|
78
|
+
emit
|
|
79
|
+
}) {
|
|
80
|
+
const panelId = createDropdownPanelId();
|
|
81
|
+
const triggerId = `${panelId}-trigger`;
|
|
82
|
+
const rootRef = ref(null);
|
|
83
|
+
const panelRef = ref(null);
|
|
84
|
+
const innerOpen = ref(props.defaultOpen);
|
|
85
|
+
const nativeOpen = ref(false);
|
|
86
|
+
const restoreFocus = ref(false);
|
|
87
|
+
const pendingFocus = ref(null);
|
|
88
|
+
const isControlled = computed(() => props.open !== void 0);
|
|
89
|
+
const open = computed(() => props.open ?? innerOpen.value);
|
|
90
|
+
const syncPanel = (next) => {
|
|
91
|
+
if (next === nativeOpen.value) return;
|
|
92
|
+
nativeOpen.value = next;
|
|
93
|
+
try {
|
|
94
|
+
if (next) showPanel(panelRef.value);
|
|
95
|
+
else hidePanel(panelRef.value);
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const itemElements = () => [...panelRef.value?.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])') ?? []];
|
|
100
|
+
const focusInitial = () => {
|
|
101
|
+
if (!nativeOpen.value) return;
|
|
102
|
+
const target = pendingFocus.value;
|
|
103
|
+
pendingFocus.value = null;
|
|
104
|
+
const items = itemElements();
|
|
105
|
+
if (!items.length) {
|
|
106
|
+
panelRef.value?.focus({
|
|
107
|
+
preventScroll: true
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const el = target === "last" ? items[items.length - 1] : items[0];
|
|
112
|
+
el.focus({
|
|
113
|
+
preventScroll: true
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const triggerEl = () => rootRef.value?.querySelector("[popovertarget]") ?? rootRef.value?.firstElementChild ?? null;
|
|
117
|
+
const shouldRestoreFocus = () => {
|
|
118
|
+
const active = document.activeElement;
|
|
119
|
+
if (!active || active === document.body) return true;
|
|
120
|
+
if (panelRef.value?.contains(active)) return true;
|
|
121
|
+
return active === triggerEl();
|
|
122
|
+
};
|
|
123
|
+
const close = (reason) => {
|
|
124
|
+
if (reason === "select" || reason === "escape") restoreFocus.value = true;
|
|
125
|
+
if (isControlled.value) {
|
|
126
|
+
emit("update:open", false);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
innerOpen.value = false;
|
|
130
|
+
syncPanel(false);
|
|
131
|
+
};
|
|
132
|
+
const openPanel = (position) => {
|
|
133
|
+
if (props.disabled) return;
|
|
134
|
+
pendingFocus.value = position;
|
|
135
|
+
if (open.value && nativeOpen.value) {
|
|
136
|
+
focusInitial();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (isControlled.value) {
|
|
140
|
+
emit("update:open", true);
|
|
141
|
+
if (open.value && !nativeOpen.value) syncPanel(true);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
innerOpen.value = true;
|
|
145
|
+
syncPanel(true);
|
|
146
|
+
};
|
|
147
|
+
const onTriggerKeydown = (event) => {
|
|
148
|
+
if (props.disabled) return;
|
|
149
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
openPanel(event.key === "ArrowDown" ? "first" : "last");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const onPanelKeydown = (event) => {
|
|
155
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
const items = itemElements();
|
|
158
|
+
if (!items.length) return;
|
|
159
|
+
const current = items.indexOf(document.activeElement);
|
|
160
|
+
const dir = event.key === "ArrowDown" ? 1 : -1;
|
|
161
|
+
const next = current < 0 ? dir > 0 ? 0 : items.length - 1 : (current + dir + items.length) % items.length;
|
|
162
|
+
items[next]?.focus();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (event.key === "Home" || event.key === "End") {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
const items = itemElements();
|
|
168
|
+
items[event.key === "Home" ? 0 : items.length - 1]?.focus();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (event.key === "Escape") {
|
|
172
|
+
restoreFocus.value = true;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (event.key === "Tab") {
|
|
176
|
+
requestAnimationFrame(() => {
|
|
177
|
+
if (panelRef.value) close("tab");
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const onPanelFocusout = (event) => {
|
|
182
|
+
const next = event.relatedTarget;
|
|
183
|
+
if (!next) return;
|
|
184
|
+
if (rootRef.value?.contains(next)) return;
|
|
185
|
+
if (!nativeOpen.value) return;
|
|
186
|
+
close("outside");
|
|
187
|
+
};
|
|
188
|
+
const onToggle = (event) => {
|
|
189
|
+
const opening = event.newState === "open";
|
|
190
|
+
nativeOpen.value = opening;
|
|
191
|
+
if (!isControlled.value) innerOpen.value = opening;
|
|
192
|
+
emit("update:open", opening);
|
|
193
|
+
emit("openChange", opening);
|
|
194
|
+
if (opening) {
|
|
195
|
+
restoreFocus.value = false;
|
|
196
|
+
nextTick(focusInitial);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (restoreFocus.value) {
|
|
200
|
+
restoreFocus.value = false;
|
|
201
|
+
nextTick(() => {
|
|
202
|
+
if (shouldRestoreFocus()) triggerEl()?.focus();
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
pendingFocus.value = null;
|
|
206
|
+
};
|
|
207
|
+
const triggerProps = () => ({
|
|
208
|
+
id: triggerId,
|
|
209
|
+
popoverTarget: props.disabled ? void 0 : panelId,
|
|
210
|
+
"aria-haspopup": "menu",
|
|
211
|
+
"aria-expanded": open.value ? "true" : "false",
|
|
212
|
+
"aria-controls": panelId,
|
|
213
|
+
onKeydown: onTriggerKeydown,
|
|
214
|
+
disabled: props.disabled || void 0,
|
|
215
|
+
"aria-disabled": props.disabled ? "true" : void 0
|
|
216
|
+
});
|
|
217
|
+
watch(() => props.open, (value) => {
|
|
218
|
+
if (value !== void 0) syncPanel(value);
|
|
219
|
+
}, {
|
|
220
|
+
flush: "post"
|
|
221
|
+
});
|
|
222
|
+
onMounted(() => {
|
|
223
|
+
if (open.value) syncPanel(true);
|
|
224
|
+
});
|
|
225
|
+
provide(DROPDOWN_CONTEXT, {
|
|
226
|
+
close,
|
|
227
|
+
closeOnSelect: toRef(props, "closeOnSelect"),
|
|
228
|
+
disabled: toRef(props, "disabled")
|
|
229
|
+
});
|
|
230
|
+
return () => {
|
|
231
|
+
const trigger = slots.trigger ? slots.trigger({
|
|
232
|
+
triggerProps: triggerProps(),
|
|
233
|
+
open: open.value,
|
|
234
|
+
panelId
|
|
235
|
+
}) : createVNode(Button, mergeProps({
|
|
236
|
+
"variant": props.variant,
|
|
237
|
+
"size": props.size,
|
|
238
|
+
"disabled": props.disabled
|
|
239
|
+
}, {
|
|
240
|
+
id: triggerId,
|
|
241
|
+
popovertarget: props.disabled ? void 0 : panelId,
|
|
242
|
+
"aria-haspopup": "menu",
|
|
243
|
+
"aria-expanded": open.value ? "true" : "false",
|
|
244
|
+
"aria-controls": panelId,
|
|
245
|
+
onKeydown: onTriggerKeydown
|
|
246
|
+
}), {
|
|
247
|
+
default: () => [props.label, createVNode(Icon, {
|
|
248
|
+
"name": "chevron-down",
|
|
249
|
+
"class": "mh-button__caret mh-popup-caret"
|
|
250
|
+
}, null)]
|
|
251
|
+
});
|
|
252
|
+
return createVNode("span", mergeProps({
|
|
253
|
+
"ref": rootRef
|
|
254
|
+
}, attrs, {
|
|
255
|
+
"class": ["mh-dropdown", "mh-popup-host", props.size === "md" ? "" : `mh-dropdown--${props.size}`, attrs.class].filter(Boolean).join(" "),
|
|
256
|
+
"style": attrs.style
|
|
257
|
+
}), [createVNode("span", {
|
|
258
|
+
"class": "mh-popup-anchor"
|
|
259
|
+
}, [trigger]), createVNode(DropdownPanel, {
|
|
260
|
+
"id": panelId,
|
|
261
|
+
"panelRef": panelRef,
|
|
262
|
+
"side": props.side,
|
|
263
|
+
"align": props.align,
|
|
264
|
+
"matchWidth": props.matchWidth,
|
|
265
|
+
"ariaLabel": props.ariaLabel,
|
|
266
|
+
"labelledby": triggerId,
|
|
267
|
+
"onToggle": onToggle,
|
|
268
|
+
"onKeydown": onPanelKeydown,
|
|
269
|
+
"onFocusout": onPanelFocusout
|
|
270
|
+
}, {
|
|
271
|
+
default: () => slots.default?.()
|
|
272
|
+
})]);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
const Dropdown = Object.assign(DropdownBase, {
|
|
277
|
+
Item: DropdownItem,
|
|
278
|
+
Separator: DropdownSeparator
|
|
279
|
+
});
|
|
280
|
+
export {
|
|
281
|
+
Dropdown
|
|
282
|
+
};
|
|
@@ -2,7 +2,8 @@ import { defineComponent, ref, computed, watch, createVNode, Fragment } from "vu
|
|
|
2
2
|
import { SelectList } from "./select-list.js";
|
|
3
3
|
import { SelectPanel } from "./select-panel.js";
|
|
4
4
|
import { SelectTrigger } from "./select-trigger.js";
|
|
5
|
-
import { createSelectPanelId, isGroup, activatableOptions, activatableCount, createTriggerKeydown, optionDomId
|
|
5
|
+
import { createSelectPanelId, isGroup, activatableOptions, activatableCount, createTriggerKeydown, optionDomId } from "./select-shared.js";
|
|
6
|
+
import { showPanel, hidePanel } from "../../utils/popover.js";
|
|
6
7
|
const Select = /* @__PURE__ */ defineComponent({
|
|
7
8
|
name: "Select",
|
|
8
9
|
inheritAttrs: false,
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* 全页唯一)、popover 开合、触发器键盘契约、可激活项的摊平顺序(两件必须同一份)。
|
|
8
8
|
*/
|
|
9
9
|
import type { Ref } from 'vue';
|
|
10
|
+
import { hidePanel, showPanel } from '../../utils/popover';
|
|
11
|
+
export { hidePanel, showPanel };
|
|
10
12
|
/** 选项(平铺项与分组内选项同构) */
|
|
11
13
|
export interface SelectOption {
|
|
12
14
|
label: string;
|
|
@@ -38,13 +40,6 @@ export declare const activatableCount: (items: SelectItem[], creatable: boolean)
|
|
|
38
40
|
export declare const optionDomId: (panelId: string, index: number) => string;
|
|
39
41
|
/** 生成全页唯一的面板 id(随机段与全库其它随机 id 同法) */
|
|
40
42
|
export declare const createSelectPanelId: () => string;
|
|
41
|
-
/**
|
|
42
|
-
* 开 / 收面板 —— 调**原生** `showPopover()` / `hidePopover()`,不是自建浮层逻辑(开合、Esc、点外部关闭、顶层渲染全归
|
|
43
|
-
* 浏览器与 `styles/operations/popup.css`)。先探存在性再调用:jsdom 至今没实现这套 API,直接 `?.()` 会在测试里抛
|
|
44
|
-
* 「不是函数」。
|
|
45
|
-
*/
|
|
46
|
-
export declare const showPanel: (element: HTMLElement | null) => void;
|
|
47
|
-
export declare const hidePanel: (element: HTMLElement | null) => void;
|
|
48
43
|
/** 触发器键盘契约的输入 */
|
|
49
44
|
export interface TriggerKeydownOptions {
|
|
50
45
|
/** 有清除位时才接 `Delete` 清值(与输入框的键盘清除同款) */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { createPanelId } from "../../utils/popover.js";
|
|
2
|
+
import { hidePanel, showPanel } from "../../utils/popover.js";
|
|
1
3
|
const isGroup = (item) => Array.isArray(item.options);
|
|
2
4
|
const activatableOptions = (items) => items.flatMap((item) => isGroup(item) ? item.options : [item]).filter((option) => !option.disabled);
|
|
3
5
|
const activatableCount = (items, creatable) => activatableOptions(items).length + (creatable ? 1 : 0);
|
|
4
6
|
const optionDomId = (panelId, index) => `${panelId}-opt-${index}`;
|
|
5
7
|
const PANEL_ID_PREFIX = "mh-select-";
|
|
6
|
-
const createSelectPanelId = () =>
|
|
7
|
-
const showPanel = (element) => element?.showPopover?.();
|
|
8
|
-
const hidePanel = (element) => element?.hidePopover?.();
|
|
8
|
+
const createSelectPanelId = () => createPanelId(PANEL_ID_PREFIX);
|
|
9
9
|
function createTriggerKeydown(options) {
|
|
10
10
|
return (event) => {
|
|
11
11
|
if (options.readonly) return;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineComponent, ref, computed, watch, createVNode, createTextVNode, Fragment } from "vue";
|
|
2
2
|
import { SelectPanel } from "./select-panel.js";
|
|
3
3
|
import { SelectTrigger } from "./select-trigger.js";
|
|
4
|
-
import { createSelectPanelId, createTriggerKeydown
|
|
4
|
+
import { createSelectPanelId, createTriggerKeydown } from "./select-shared.js";
|
|
5
5
|
import { filterTreeNodes, findTreeNode, treeLabel, splitHighlight, treeChildren, treeNodeKey } from "./select-tree-filter.js";
|
|
6
6
|
import { Tree } from "../list/tree.js";
|
|
7
|
+
import { showPanel, hidePanel } from "../../utils/popover.js";
|
|
7
8
|
const SelectTree = /* @__PURE__ */ defineComponent({
|
|
8
9
|
name: "SelectTree",
|
|
9
10
|
inheritAttrs: false,
|
|
@@ -103,9 +103,9 @@ export declare const Tooltip: import("vue").DefineComponent<import("vue").Extrac
|
|
|
103
103
|
content: string;
|
|
104
104
|
title: string;
|
|
105
105
|
align: TooltipAlign;
|
|
106
|
-
action: string;
|
|
107
106
|
side: TooltipSide;
|
|
108
107
|
trigger: TooltipTrigger;
|
|
108
|
+
action: string;
|
|
109
109
|
guide: boolean;
|
|
110
110
|
onAction: () => void;
|
|
111
111
|
}, SlotsType<{
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { List, Tree, type ListNode } from './components/list';
|
|
|
31
31
|
export { ListView, type ListViewProps, type ListViewStatus, type ListViewStatusTone, type ListViewCardItemProps, type ListViewCompound, } from './components/list-view';
|
|
32
32
|
export { Badge, type BadgeTone, type BadgeShape, type BadgeSize, type BadgeDot, type BadgeStatus, } from './components/badge';
|
|
33
33
|
export { Button, Segmented, type ButtonVariant, type ButtonCompound, type ButtonCompoundType, type SegmentedOption, type SegmentedValue, } from './components/button';
|
|
34
|
+
export { Dropdown, type DropdownProps, type DropdownItemProps, type DropdownSide, type DropdownAlign, type DropdownCompound, } from './components/dropdown';
|
|
34
35
|
export { Input, Textarea, NumberInput, type TextareaProps, type NumberInputProps, type InputCompound, type InputCompoundType, } from './components/input';
|
|
35
36
|
export { Search, type SearchProps } from './components/search';
|
|
36
37
|
export { Select, SelectTree, type SelectOption, type SelectValue } from './components/select';
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { Text } from "./components/text/index.js";
|
|
|
13
13
|
import { ListView } from "./components/list-view/index.js";
|
|
14
14
|
import { Badge } from "./components/badge/index.js";
|
|
15
15
|
import { Button } from "./components/button/index.js";
|
|
16
|
+
import { Dropdown } from "./components/dropdown/index.js";
|
|
16
17
|
import { Input, Textarea } from "./components/input/index.js";
|
|
17
18
|
import { Search } from "./components/search/index.js";
|
|
18
19
|
import { Select } from "./components/select/index.js";
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
Dialog,
|
|
62
63
|
Divider,
|
|
63
64
|
Drawer,
|
|
65
|
+
Dropdown,
|
|
64
66
|
FILTER_ALL,
|
|
65
67
|
Filter,
|
|
66
68
|
FilterItem,
|
|
@@ -93,15 +93,7 @@
|
|
|
93
93
|
width: var(--ui-button-icon-size-lg);
|
|
94
94
|
height: var(--ui-button-icon-size-lg);
|
|
95
95
|
}
|
|
96
|
-
/*
|
|
97
|
-
`.mh-button--menu` 的 md 缺省值)。
|
|
98
|
-
(原先还有「分割线高度跟档位」两条 —— 菜单按钮自 2026-10-12 起不再渲染分割线,那两条随之撤掉) */
|
|
99
|
-
.mh-button--sm.mh-button--menu {
|
|
100
|
-
padding: 0 var(--ui-button-padding-x-sm);
|
|
101
|
-
}
|
|
102
|
-
.mh-button--lg.mh-button--menu {
|
|
103
|
-
padding: 0 var(--ui-button-padding-x-lg);
|
|
104
|
-
}
|
|
96
|
+
/* 尺寸档的图标槽在上面的 `.mh-button--sm/lg .mh-button__icon, .mh-button__caret` 已统一处理 */
|
|
105
97
|
|
|
106
98
|
/* ===== 外形修饰(与型正交) ===== */
|
|
107
99
|
.mh-button--round {
|
|
@@ -346,7 +338,7 @@
|
|
|
346
338
|
}
|
|
347
339
|
}
|
|
348
340
|
|
|
349
|
-
/* =====
|
|
341
|
+
/* ===== 尾部方向图标槽(Dropdown 的内建触发器 / Button.Group 的「更多」共用) =====
|
|
350
342
|
* **只给槽位尺寸,不给字形**:字形由 `@manohub/icon` 的 `<Icon name="chevron-down">` 画,展开时的转向
|
|
351
343
|
* 由操作层 `popup.css` 的 `.mh-popup-caret` 承担(本件不定义第二份 mask / 第二处转向)。 */
|
|
352
344
|
.mh-button__caret {
|
|
@@ -355,25 +347,6 @@
|
|
|
355
347
|
height: var(--ui-button-icon-size);
|
|
356
348
|
}
|
|
357
349
|
|
|
358
|
-
/* ===== 菜单按钮(文字区 + 箭头区;**不画竖分割线**,色调随修饰符) =====
|
|
359
|
-
分割线原属「文本区 ‖ 分割线 ‖ 箭头区」的三段结构,2026-10-12 按设计口径撤掉:
|
|
360
|
-
线压在实心主色底上太重,把一颗按钮切成两半。两区之间现在靠白空分开。
|
|
361
|
-
|
|
362
|
-
**内距与两区间隔都归容器**(`.mh-button--menu` 自己吃左右内距、用 `gap` 给间隔),
|
|
363
|
-
`label` 与 `caret` 都不再自带内距 / margin —— 间距只由一处拥有,否则「文字 → 箭头」会空出双份
|
|
364
|
-
(与组容器那条 `.mh-button__group > .mh-button--text { padding-inline: 0 }` 同一口径)。 */
|
|
365
|
-
.mh-button--menu {
|
|
366
|
-
padding: 0 var(--ui-button-padding-x);
|
|
367
|
-
gap: var(--ui-button-gap);
|
|
368
|
-
}
|
|
369
|
-
/* 文字区只是文字容器:内距全归 `.mh-button--menu`(这条留着是为了「不吃内距」有据可查) */
|
|
370
|
-
.mh-button__label {
|
|
371
|
-
padding: 0;
|
|
372
|
-
}
|
|
373
|
-
.mh-button--menu .mh-button__caret {
|
|
374
|
-
margin: 0;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
350
|
/* 竖分割线(1px,跟按钮同高)—— 现在只服务 `Button.Divider`(组内分割线),菜单按钮不再渲染它 */
|
|
378
351
|
.mh-button__divider {
|
|
379
352
|
flex: none;
|
|
@@ -494,42 +467,16 @@
|
|
|
494
467
|
outline-offset: -2px;
|
|
495
468
|
}
|
|
496
469
|
|
|
497
|
-
/* ===== 子菜单浮层皮肤(与操作层并列组合:`class="mh-popup mh-button__menu"`) =====
|
|
498
|
-
* 只给面(底 / 圆角 / 内距 / 阴影 / 选项行),开合、Esc、点外部关闭、顶层渲染、定位档全在 popup.css。 */
|
|
499
|
-
.mh-button__menu {
|
|
500
|
-
width: 130px;
|
|
501
|
-
padding: var(--ui-space-1) 6px;
|
|
502
|
-
/* 圆角取容器档(不写硬编码 px,改版时才会跟随);投影取锚定浮层档,不是居中浮层档 */
|
|
503
|
-
border-radius: var(--ui-radius-md);
|
|
504
|
-
background: var(--ui-base-100);
|
|
505
|
-
box-shadow: var(--ui-shadow-popover);
|
|
506
|
-
}
|
|
507
|
-
.mh-button__menu-item {
|
|
508
|
-
height: 30px;
|
|
509
|
-
padding: 0 var(--ui-space-2);
|
|
510
|
-
border-radius: var(--ui-button-radius);
|
|
511
|
-
font-size: var(--ui-button-font-size);
|
|
512
|
-
line-height: 30px;
|
|
513
|
-
color: var(--ui-base-content);
|
|
514
|
-
cursor: pointer;
|
|
515
|
-
}
|
|
516
|
-
.mh-button__menu-item:hover,
|
|
517
|
-
.mh-button__menu-item.is-hover {
|
|
518
|
-
background: var(--ui-base-200);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
470
|
/* ===== 按钮组的收纳面板皮肤(`Button.Group maxVisible` 用)=====
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
* 内距 / 投影),版式不同:这里宽度随内容、每颗按钮独立成行。
|
|
526
|
-
* 开合、Esc、点外部关闭、顶层渲染、定位档仍全在 `operations/popup.css`。 */
|
|
471
|
+
* 这里装的是**原样的 Button**(原 `variant` / `danger` 全保留 —— 「保存是主色、删除是危险色」
|
|
472
|
+
* 这类语义不该因为被收进抽屉就丢掉),要的是**竖排一列按钮**;与动作菜单的 `.mh-dropdown__panel`
|
|
473
|
+
* 是两种面(那边装菜单项)。开合、Esc、点外部关闭、顶层渲染、定位档仍全在 `operations/popup.css`。 */
|
|
527
474
|
.mh-button__group-menu {
|
|
528
475
|
display: flex;
|
|
529
476
|
flex-direction: column;
|
|
530
477
|
align-items: stretch;
|
|
531
478
|
gap: var(--ui-space-1);
|
|
532
|
-
/*
|
|
479
|
+
/* 宽度随最宽那颗按钮(按钮文案可能很长,不能像菜单那样定宽) */
|
|
533
480
|
width: max-content;
|
|
534
481
|
padding: var(--ui-space-1) 6px;
|
|
535
482
|
border-radius: var(--ui-radius-md);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 单件令牌(只服务本件,故不进 `@manohub/theme`)。
|
|
3
3
|
*
|
|
4
|
-
* **本件有一批令牌是「跨分件消费」的**:`--ui-button-group-gap` 归组容器 `.mh-button__group
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* **本件有一批令牌是「跨分件消费」的**:`--ui-button-group-gap` 归组容器 `.mh-button__group`、
|
|
5
|
+
* `--ui-button-height` 归组内分割线 `.mh-button__divider` —— 自定义属性只向下继承,声明在 `.mh-button`
|
|
6
|
+
* 上这类分件取不到值(声明作废且不报错)。锚到容器后**容器是每个分件的祖先**,「把令牌同时声明在
|
|
7
|
+
* 4 个外层类上」那类 workaround 整块撤掉 —— 这正是本文件抽出来的原因。
|
|
8
8
|
* ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里(拆开会让档位失效)。
|
|
9
9
|
*/
|
|
10
10
|
[data-manohub-ui] {
|
|
@@ -54,15 +54,19 @@
|
|
|
54
54
|
transition-timing-function: var(--ui-ease-out);
|
|
55
55
|
transition-behavior: allow-discrete;
|
|
56
56
|
}
|
|
57
|
-
/* 展开态(`[open]` 由原生 `showModal()`
|
|
57
|
+
/* 展开态(`[open]` 由原生 `showModal()` 写上)。
|
|
58
|
+
进场走 **animation**、不用 `@starting-style`:宿主微前端(micro-app)的作用域转换是 **at-rule 白名单**
|
|
59
|
+
(keyframes / media / supports / import / container / layer …),`@starting-style` 不在名单里,会被当成
|
|
60
|
+
普通选择器加前缀、产出 `micro-app[name=x] @starting-style{…}` 这条非法规则并被浏览器整块丢弃 ——
|
|
61
|
+
微应用里表现为「进场硬切、退场照播」。`@keyframes` 在白名单内,scoping 后保持合法。
|
|
62
|
+
退场仍走上面的 transition(收起态本身就是终点,不需要前值)。 */
|
|
58
63
|
.mh-dialog[open] {
|
|
59
64
|
opacity: 1;
|
|
60
65
|
translate: 0 0;
|
|
66
|
+
animation: mh-dialog-in var(--ui-duration-slow) var(--ui-ease-out);
|
|
61
67
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@starting-style {
|
|
65
|
-
.mh-dialog[open] {
|
|
68
|
+
@keyframes mh-dialog-in {
|
|
69
|
+
from {
|
|
66
70
|
opacity: 0;
|
|
67
71
|
translate: 0 8px;
|
|
68
72
|
}
|
|
@@ -96,9 +100,10 @@
|
|
|
96
100
|
}
|
|
97
101
|
.mh-dialog[open]::backdrop {
|
|
98
102
|
opacity: 1;
|
|
103
|
+
animation: mh-dialog-backdrop-in var(--ui-duration-slow) var(--ui-ease-out);
|
|
99
104
|
}
|
|
100
|
-
@
|
|
101
|
-
|
|
105
|
+
@keyframes mh-dialog-backdrop-in {
|
|
106
|
+
from {
|
|
102
107
|
opacity: 0;
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -240,10 +245,14 @@
|
|
|
240
245
|
padding-inline: var(--ui-dialog-padding-x);
|
|
241
246
|
}
|
|
242
247
|
|
|
243
|
-
/*
|
|
248
|
+
/* 减弱动效:过渡与进场动画一起关掉(含 `display` / `overlay` 的延后)—— 收起回到「立即消失」的既有行为。
|
|
249
|
+
`[open]` 那两条的 animation 特异性高于基态,必须在这里显式点名压掉。 */
|
|
244
250
|
@media (prefers-reduced-motion: reduce) {
|
|
245
251
|
.mh-dialog,
|
|
246
|
-
.mh-dialog::backdrop
|
|
252
|
+
.mh-dialog::backdrop,
|
|
253
|
+
.mh-dialog[open],
|
|
254
|
+
.mh-dialog[open]::backdrop {
|
|
247
255
|
transition: none;
|
|
256
|
+
animation: none;
|
|
248
257
|
}
|
|
249
258
|
}
|
|
@@ -57,34 +57,50 @@
|
|
|
57
57
|
}
|
|
58
58
|
.mh-drawer[open]::backdrop {
|
|
59
59
|
opacity: 1;
|
|
60
|
+
animation: mh-drawer-backdrop-in var(--ui-duration-slow) var(--ui-ease-out);
|
|
60
61
|
}
|
|
61
|
-
@
|
|
62
|
-
|
|
62
|
+
@keyframes mh-drawer-backdrop-in {
|
|
63
|
+
from {
|
|
63
64
|
opacity: 0;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
/* 收起态 =
|
|
68
|
-
|
|
68
|
+
/* 收起态 = 停在所贴那一侧视口外(退场的终点)。
|
|
69
|
+
进场起点走 **animation**、不用 `@starting-style`:宿主微前端(micro-app)的作用域转换是 at-rule 白名单
|
|
70
|
+
(不含 `@starting-style`),那条规则会被改写成非法选择器、整块丢弃 ⇒ 微应用里进场硬切、退场照播。
|
|
71
|
+
位移只碰独立的 `translate`,不碰 `transform`(不覆盖定位)。 */
|
|
69
72
|
.mh-drawer:not([open]) {
|
|
70
73
|
translate: 100% 0;
|
|
71
74
|
}
|
|
72
75
|
.mh-drawer--left:not([open]) {
|
|
73
76
|
translate: -100% 0;
|
|
74
77
|
}
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
.mh-drawer[open] {
|
|
79
|
+
animation: mh-drawer-in var(--ui-duration-slow) var(--ui-ease-out);
|
|
80
|
+
}
|
|
81
|
+
/* 左档必须排在右档之后:两条特异性相同,靠源码顺序取最后一个 animation-name */
|
|
82
|
+
.mh-drawer--left[open] {
|
|
83
|
+
animation-name: mh-drawer-in-left;
|
|
84
|
+
}
|
|
85
|
+
@keyframes mh-drawer-in {
|
|
86
|
+
from {
|
|
77
87
|
translate: 100% 0;
|
|
78
88
|
}
|
|
79
|
-
|
|
89
|
+
}
|
|
90
|
+
@keyframes mh-drawer-in-left {
|
|
91
|
+
from {
|
|
80
92
|
translate: -100% 0;
|
|
81
93
|
}
|
|
82
94
|
}
|
|
83
|
-
/*
|
|
95
|
+
/* 减弱动效:过渡与进场动画一起关掉(含 `display` / `overlay` 的延后)—— 收起回到「立即消失」的既有行为。
|
|
96
|
+
`[open]` 那两条的 animation 特异性高于基态,必须在这里显式点名压掉。 */
|
|
84
97
|
@media (prefers-reduced-motion: reduce) {
|
|
85
98
|
.mh-drawer,
|
|
86
|
-
.mh-drawer::backdrop
|
|
99
|
+
.mh-drawer::backdrop,
|
|
100
|
+
.mh-drawer[open],
|
|
101
|
+
.mh-drawer[open]::backdrop {
|
|
87
102
|
transition: none;
|
|
103
|
+
animation: none;
|
|
88
104
|
}
|
|
89
105
|
}
|
|
90
106
|
|