@manohub/ui 1.2.13 → 1.3.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 +1 -1
- package/dist/components/button/index.d.ts +20 -106
- 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/notice/index.d.ts +1 -1
- package/dist/components/notification/index.d.ts +1 -1
- 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/toast/index.d.ts +4 -4
- 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/dropdown.css +124 -0
- package/dist/styles/components/dropdown.tokens.css +16 -0
- package/dist/styles/index.css +2 -0
- package/dist/utils/popover.d.ts +14 -0
- package/dist/utils/popover.js +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dropdown —— 动作菜单皮肤(与操作层并列组合)。
|
|
3
|
+
*
|
|
4
|
+
* 组合方式与选择器同一套:面板根 `class="mh-popup mh-dropdown__panel"`、`popover="auto"`、
|
|
5
|
+
* `data-side` / `data-align` 交给 `popup.css`。**开合 / 定位 / 翻面 / 动画一行都不在这里**:
|
|
6
|
+
* 作者源压过 UA,面板也不写 `display`(否则收起态会被皮肤顶掉,`popup.css` 已有兜底但那是以防万一)。
|
|
7
|
+
*
|
|
8
|
+
* 菜单项是原生 `<button role="menuitem">`(键盘 / 点击语义归原生),故必须自带
|
|
9
|
+
* `border` / `background` / `padding` —— 本包 reset 不替裸按钮归零(`contract-reset` 会按标签扫源码)。
|
|
10
|
+
*
|
|
11
|
+
* 类名与令牌同根:`.mh-dropdown__*` ↔ `--ui-dropdown-*`,与 `button` / `select` 的口径一致。
|
|
12
|
+
*/
|
|
13
|
+
.mh-dropdown {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* 密度档:只改写「项高」这一枚令牌,档位靠同一元素上的变量覆盖生效 */
|
|
18
|
+
.mh-dropdown--sm {
|
|
19
|
+
--ui-dropdown-item-height: var(--ui-control-height-sm);
|
|
20
|
+
}
|
|
21
|
+
.mh-dropdown--lg {
|
|
22
|
+
--ui-dropdown-item-height: var(--ui-control-height-lg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* ===== 面板(只给面) ===== */
|
|
26
|
+
.mh-dropdown__panel {
|
|
27
|
+
min-width: var(--ui-dropdown-panel-min-width);
|
|
28
|
+
/* 先给固定上限兜底;支持时再按视口收一步(不支持的浏览器会丢掉第二条,保留第一条) */
|
|
29
|
+
max-width: var(--ui-dropdown-panel-max-width);
|
|
30
|
+
max-width: min(var(--ui-dropdown-panel-max-width), calc(100vw - var(--ui-space-4)));
|
|
31
|
+
max-height: var(--ui-dropdown-panel-max-height);
|
|
32
|
+
max-height: min(var(--ui-dropdown-panel-max-height), calc(100dvh - var(--ui-space-4)));
|
|
33
|
+
padding: var(--ui-space-1);
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
/* 滚到菜单尽头不要接着滚页面(否则面板还开着、页面已经跑远) */
|
|
36
|
+
overscroll-behavior: contain;
|
|
37
|
+
border-radius: var(--ui-radius-md);
|
|
38
|
+
background: var(--ui-base-100);
|
|
39
|
+
box-shadow: var(--ui-shadow-popover);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* 与触发器同宽:`anchor-size` 不支持时整条声明作废,退回上面的令牌最小宽 */
|
|
43
|
+
.mh-dropdown__panel--match-trigger {
|
|
44
|
+
min-width: max(var(--ui-dropdown-panel-min-width), anchor-size(width));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* ===== 菜单项(原生 button;整块可点) ===== */
|
|
48
|
+
.mh-dropdown__item {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: var(--ui-space-2);
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: var(--ui-dropdown-item-height);
|
|
54
|
+
padding: 0 var(--ui-space-2);
|
|
55
|
+
border: 0;
|
|
56
|
+
border-radius: var(--ui-radius-control);
|
|
57
|
+
background: transparent;
|
|
58
|
+
color: var(--ui-base-content);
|
|
59
|
+
font-family: inherit;
|
|
60
|
+
font-size: var(--ui-font-body);
|
|
61
|
+
line-height: 1;
|
|
62
|
+
text-align: start;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
appearance: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* 键盘焦点环;鼠标路径的「高亮」由下面的 :focus 底给出(不另设 data-active) */
|
|
68
|
+
.mh-dropdown__item:focus-visible {
|
|
69
|
+
outline: 2px solid var(--ui-primary);
|
|
70
|
+
outline-offset: -2px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.mh-dropdown__item:not([aria-disabled='true']):hover,
|
|
74
|
+
.mh-dropdown__item:not([aria-disabled='true']):focus {
|
|
75
|
+
background: var(--ui-base-200);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.mh-dropdown__item--danger {
|
|
79
|
+
color: var(--ui-error);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.mh-dropdown__item--danger:not([aria-disabled='true']):hover,
|
|
83
|
+
.mh-dropdown__item--danger:not([aria-disabled='true']):focus {
|
|
84
|
+
background: var(--ui-error-weak);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.mh-dropdown__item[aria-disabled='true'] {
|
|
88
|
+
color: var(--ui-base-content-subtle);
|
|
89
|
+
cursor: not-allowed;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* 禁用项即使被点到 / 聚焦也不点亮(语义真假只看 aria-disabled) */
|
|
93
|
+
.mh-dropdown__item[aria-disabled='true']:hover,
|
|
94
|
+
.mh-dropdown__item[aria-disabled='true']:focus {
|
|
95
|
+
background: transparent;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* 文字区:占满剩余宽、超出省略;`title` 由组件按 label 补 */
|
|
99
|
+
.mh-dropdown__label {
|
|
100
|
+
flex: 1;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
text-overflow: ellipsis;
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.mh-dropdown__shortcut {
|
|
108
|
+
flex: none;
|
|
109
|
+
color: var(--ui-base-content-subtle);
|
|
110
|
+
font-size: var(--ui-font-caption);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.mh-dropdown__icon {
|
|
114
|
+
flex: none;
|
|
115
|
+
width: var(--ui-font-icon);
|
|
116
|
+
height: var(--ui-font-icon);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* ===== 分隔线(声明式 `Dropdown.Separator`) ===== */
|
|
120
|
+
.mh-dropdown__separator {
|
|
121
|
+
height: 1px;
|
|
122
|
+
margin: var(--ui-space-1) 0;
|
|
123
|
+
background: var(--ui-base-300);
|
|
124
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dropdown —— 动作菜单的单件令牌(**基础值**)。
|
|
3
|
+
*
|
|
4
|
+
* 只服务本件,故不随主题进 `@manohub/theme`;锚 `[data-manohub-ui]`(容器是面板与项的祖先)。
|
|
5
|
+
* 面板与项都可能在 top layer,但 DOM 仍在应用容器里 ⇒ 令牌与主题色全程有效
|
|
6
|
+
* (把浮层 portal 到 body 的旧做法拿不到这组值,才会逼着面板写死色值)。
|
|
7
|
+
*
|
|
8
|
+
* ⚠️ `.mh-dropdown--sm` / `--lg` 的档位改写留在面文件:那里靠「同一元素上两个选择器改写同一枚令牌」
|
|
9
|
+
* 生效,搬到本文件就断链。
|
|
10
|
+
*/
|
|
11
|
+
[data-manohub-ui] {
|
|
12
|
+
--ui-dropdown-panel-min-width: 160px;
|
|
13
|
+
--ui-dropdown-panel-max-width: 320px;
|
|
14
|
+
--ui-dropdown-panel-max-height: 320px;
|
|
15
|
+
--ui-dropdown-item-height: 32px;
|
|
16
|
+
}
|
package/dist/styles/index.css
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
/* 表单与选择控件 */
|
|
47
47
|
@import './components/button.tokens.css';
|
|
48
|
+
@import './components/dropdown.tokens.css';
|
|
48
49
|
@import './components/input.tokens.css';
|
|
49
50
|
@import './components/select.tokens.css';
|
|
50
51
|
@import './components/date-picker.tokens.css';
|
|
@@ -103,6 +104,7 @@
|
|
|
103
104
|
|
|
104
105
|
/* 表单与选择控件(按钮 → 输入 → 选择 → 开关 → 勾选 → 单选 → 胶囊) */
|
|
105
106
|
@import './components/button.css';
|
|
107
|
+
@import './components/dropdown.css'; /* 动作菜单:面板皮肤独立,触发器仍复用按钮族 */
|
|
106
108
|
@import './components/input.css';
|
|
107
109
|
@import './components/search.css'; /* 只有「一行里怎么摆」,输入框与按钮的面各自归族(故排在 input.css 之后) */
|
|
108
110
|
@import './components/select.css';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 原生 popover 的三只极简工具(`Select` / `Dropdown` 共用)。
|
|
3
|
+
*
|
|
4
|
+
* 开合、Esc、点外部关闭、顶层渲染全归浏览器;这里只做「先探存在性再调用」——
|
|
5
|
+
* jsdom 至今没实现 `showPopover` / `hidePopover`,直接调用会在测试里抛「不是函数」。
|
|
6
|
+
*/
|
|
7
|
+
export type PopoverHost = HTMLElement & {
|
|
8
|
+
showPopover?: () => void;
|
|
9
|
+
hidePopover?: () => void;
|
|
10
|
+
};
|
|
11
|
+
/** 全页唯一的面板 id(`popovertarget` 按 id 找面板;前缀由调用方给,便于排查) */
|
|
12
|
+
export declare const createPanelId: (prefix: string) => string;
|
|
13
|
+
export declare const showPanel: (element: HTMLElement | null) => void;
|
|
14
|
+
export declare const hidePanel: (element: HTMLElement | null) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manohub/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "AIHub 自绘组件层:不依赖 farris 的手写 Vue TSX 组件 + 自带令牌层(Farris 规范视觉 · daisyUI 式语义令牌 · shadcn 式 API 词汇)。",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"vue": "^3.5.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@manohub/icon": "^1.
|
|
38
|
+
"@manohub/icon": "^1.3.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^24.0.0",
|