@manohub/ui 0.9.0 → 0.10.0
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 +13 -7
- package/dist/components/checkbox/index.js +5 -1
- package/dist/components/code-block/index.js +18 -11
- package/dist/components/filter/index.d.ts +8 -2
- package/dist/components/filter/index.js +11 -20
- package/dist/components/form/index.d.ts +39 -0
- package/dist/components/form/index.js +6 -0
- package/dist/components/input/index.d.ts +48 -7
- package/dist/components/input/index.js +23 -3
- package/dist/components/radio/index.js +29 -3
- package/dist/components/search/index.js +37 -35
- package/dist/components/select/index.js +1 -3
- package/dist/components/select/select-trigger.d.ts +4 -2
- package/dist/components/select/select-trigger.js +9 -4
- package/dist/components/table/index.d.ts +19 -8
- package/dist/components/table/index.js +3 -3
- package/dist/components/text/index.d.ts +4 -3
- package/dist/components/toast/index.js +16 -1
- package/dist/styles/components/avatar.css +4 -1
- package/dist/styles/components/button.css +2 -0
- package/dist/styles/components/filter.css +22 -34
- package/dist/styles/components/input.css +24 -0
- package/dist/styles/components/select.css +3 -4
- package/dist/styles/components/table.css +33 -22
- package/dist/styles/components/table.tokens.css +6 -6
- package/dist/styles/components/text.css +10 -0
- package/dist/styles/components/toast.css +35 -6
- package/dist/styles/components/upload.css +1 -0
- package/dist/styles/index.css +5 -4
- package/dist/styles/reset.css +52 -167
- package/package.json +2 -2
- package/dist/styles/components/filter.tokens.css +0 -14
package/dist/styles/reset.css
CHANGED
|
@@ -1,70 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 元素级基线 —— 随 `@manohub/ui/styles.css` 一起到达消费方(该入口的**首条 import**)。
|
|
3
3
|
*
|
|
4
|
-
* ##
|
|
4
|
+
* ## 它现在只有两面
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* 1. **盒模型**:`box-sizing: border-box` 覆盖容器、全部后代与伪元素
|
|
7
|
+
* —— 本库所有面的几何都按 border-box 写盒高与内距,这条一丢,全库尺寸集体走样。
|
|
8
|
+
* 2. **容器基座**:`[data-manohub-ui]` 上的字族 / 字号 / 行高 / 字色 / 底色 / 整链高度与抗锯齿。
|
|
9
|
+
* 它是令牌的落点(`@manohub/theme` 的全局令牌与各件的 `<件>.tokens.css` 都锚这个属性),
|
|
10
|
+
* 也是本文件唯一一条**描述容器自身、不涉及后代**、因此不带 `:where()` 的规则。
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
+
* 除这两面之外**一条都不留**(2026-09 瘦身)。理由与去向见下面两节。
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
* 覆盖的元素清单一致,**唯一的有意差异是表单控件的底色** —— Preflight 把 `input` / `select` /
|
|
15
|
-
* `textarea` 也清成透明,本文件保留浏览器原生底色(裸输入框若连底都没有就完全不可见);
|
|
16
|
-
* 挂类的控件(`.mh-input` 等)有自己的面,不受这条影响。本包组件面本来就是按「已清零」的环境写的 ——
|
|
17
|
-
* 全部 33 处挂类的 `<button>` 合并后都自带 border / background / padding ——
|
|
18
|
-
* 所以本文件**不改变任何组件的外观**;它的作用是:
|
|
14
|
+
* ## 为什么删:未分层 > 分层(不是特异性问题)
|
|
19
15
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* 旧版这份文件是按 **Tailwind Preflight** 逐条复刻的(盒模型 / 块级外边距归零 / 标题字阶 /
|
|
17
|
+
* 列表序号 / 链接下划线 / 控件外观 / 媒体元素转块 …)。问题出在**级联层**上:Tailwind 4 的
|
|
18
|
+
* 产物首行是 `@layer theme, base, components, utilities;`,preflight 与全部工具类都在层里,
|
|
19
|
+
* 而本文件**在层外** —— CSS 里未分层的普通声明一律赢过分层里的普通声明,**这条优先于特异性**。
|
|
20
|
+
* 于是那些复刻规则把消费方的工具类整片压住(实测:`border*` 被 `border-width: 0` 打掉、
|
|
21
|
+
* `img` 上的 `h-*` 被 `height: auto` 打掉,同类还有 `h1`–`h6` 的 `text-*`、`p` 的 `mb-*`、
|
|
22
|
+
* `svg`/`img` 上的 `hidden`),而 `:where()` 把特异性降到 0 也救不了 —— 胜负不在特异性上。
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* 两件事要分开:**分层**管优先级(本文件现在不再依赖消费方分层,因为可抢的声明已经没有了),
|
|
25
|
+
* **瘦身**管重复 —— 与 preflight 重合的规则对 Tailwind 消费方本就是零增量,剩下的都归了具体组件。
|
|
26
26
|
*
|
|
27
|
-
* ##
|
|
27
|
+
* ## 删掉的那些去了哪
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* | 旧规则 | 现在的落点 |
|
|
30
|
+
* |---|---|
|
|
31
|
+
* | `img` / `svg` / `video` / `canvas` / `audio` / `iframe` / `embed` / `object` 转块级、`img`+`video` 不溢出 | 用图的件各自写:Card / ListView / QueryState 本来就有,Avatar / Upload 已补 `display: block` |
|
|
32
|
+
* | `a { color: inherit; text-decoration: inherit }` | `.mh-button` 基块补 `text-decoration: none`(链接形态的按钮就是 `<a>`);正文链接的颜色与下划线交给消费方 |
|
|
33
|
+
* | `textarea { resize: vertical }` | `.mh-input--textarea` |
|
|
34
|
+
* | `button` 的 `cursor: pointer` / 透明底 / 无渐变 / 无缩改 | 各按钮形态的面(本来都自带 `border` / `background` / `padding` / `cursor`) |
|
|
35
|
+
* | `code` / `kbd` / `samp` / `pre` 等宽族 | CodeBlock 面,以及 `.mh-text--mono`(消费方写裸 `<code>` 时用后者) |
|
|
36
|
+
* | `:disabled { cursor: default }` | 各件禁用态(Button / Input / Select / Checkbox / Capsule / Card / Collapse 等都已自带) |
|
|
37
|
+
* | `[type='search'] { outline-offset: -2px }` | 搜索框的面自画焦点环 |
|
|
38
|
+
* | 标题字阶归位 / 块级元素外边距归零 / 列表序号与缩进 / 控件字体与颜色继承 / `b`+`strong` / `small` / `summary` / `label` | **直接删**:全库零组件依赖,且 Tailwind Preflight 全都有 |
|
|
39
|
+
*
|
|
40
|
+
* `border-width: 0; border-style: solid` 也一并删了:库内每个面都写全简写
|
|
41
|
+
* (`border: 1px solid …` / `border: none` / `border-bottom: 1px solid …`),没有一处依赖默认值,
|
|
42
|
+
* 留着只会继续压消费方的 `border*` 工具类。
|
|
43
|
+
*
|
|
44
|
+
* ## 特异性的老纪律(往这里加东西前必读)
|
|
45
|
+
*
|
|
46
|
+
* **作用域一律用 `:where([data-manohub-ui])` 包裹**:`:where()` 特异性为 0,等价于纯元素选择器。
|
|
31
47
|
* 写成 `.container button` 这类高特异性选择器(0,1,1)会**反压本包组件面**(普遍是单类 0,1,0)——
|
|
32
|
-
* 本仓踩过:主按钮文字变成 `color: inherit`
|
|
33
|
-
* 也正因为它的特异性最低,消费方在自己的样式里写任何元素选择器都能盖过它。
|
|
48
|
+
* 本仓踩过:主按钮文字变成 `color: inherit` 的黑色。
|
|
34
49
|
*
|
|
35
|
-
*
|
|
36
|
-
* 且要能在消费方「同名选择器后写即胜」的规则里被覆盖,故保持 (0,1,0)
|
|
50
|
+
* 唯一例外是**容器基座**(下面的 `[data-manohub-ui]`):它描述容器自身而非其后代,
|
|
51
|
+
* 且要能在消费方「同名选择器后写即胜」的规则里被覆盖,故保持 (0,1,0)。
|
|
37
52
|
*
|
|
38
|
-
*
|
|
53
|
+
* **加声明之前先自问**:这条会不会压住消费方的 Tailwind 工具类?会压就落进**具体组件的面**
|
|
54
|
+
* (谁渲染这个元素谁负责),不要放这里。`__tests__/contract-reset.spec.ts` 按这条锁着:
|
|
55
|
+
* 除容器基座外,整份文件只允许 `box-sizing` 一条声明。
|
|
56
|
+
*
|
|
57
|
+
* ## 三条不做
|
|
39
58
|
*
|
|
40
59
|
* 1. **不碰 `html` / `body` / `#app`**:micro-app 的 scopecss **不作用域化**它们,
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* (`@manohub/kit/CONTRACT.md` §1.2「入口基线」,是 L1-6「不得用裸元素选择器」的**唯一例外**);
|
|
60
|
+
* 写进去会泄漏到宿主应用的全局样式。整链高度由消费方承担
|
|
61
|
+
* (`@manohub/kit/CONTRACT.md` §1.2「入口基线」,是 L1-6「不得用裸元素选择器」的唯一例外);
|
|
44
62
|
* 容器自身在这里给 `height: 100%`,`Page` 的 `height: 100%` 依赖上面那条链存在。
|
|
45
63
|
* 2. **不定义任何 `--ui-*` 令牌**:值一律归 `@manohub/theme`,本文件只**消费**(两处定义必然漂)。
|
|
46
64
|
* 3. **不出现任何类选择器**:本层是元素基线,类归各组件面(`styles/components/`)。
|
|
47
|
-
* 4. **不写 `appearance`**:作者一旦声明了 `background` / `border`,浏览器即放弃原生控件绘制。
|
|
48
|
-
* 实测(无头 Chrome,只引 theme + ui/styles.css):裸 `button` 的计算值是透明底 /
|
|
49
|
-
* `border-width: 0` / `border-radius: 0` / 内距 0 / 字色与字族继承容器 —— 已经是清零态。
|
|
50
|
-
* Safari / iOS 是否还需 `appearance: none` 未在真机核对,故不动(补它前请先在真机取证)。
|
|
51
65
|
*
|
|
52
|
-
* ##
|
|
66
|
+
* ## 富文本须知(相对旧版是反转)
|
|
53
67
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* 本文件有意**不含** `.mh-markdown` 一类的富文本预设:那是独立的一件事,不混进元素基线。
|
|
68
|
+
* 本文件现在**不归零列表序号、不归零链接下划线、不归位标题字阶**,所以富文本(markdown)与正文
|
|
69
|
+
* 可以直接吃浏览器默认排版 —— 旧版那条「消费方须为自己的富文本容器复权」的告示随之作废
|
|
70
|
+
* (见 `@manohub/kit/CONTRACT.md` §10)。反之,消费方想要一套自己的正文排版,按自己的容器类写即可。
|
|
58
71
|
*/
|
|
59
72
|
|
|
60
|
-
/* =====
|
|
73
|
+
/* ===== 盒模型:容器、其后代与伪元素一律 border-box(本库全部面的几何前提) ===== */
|
|
61
74
|
:where([data-manohub-ui]),
|
|
62
75
|
:where([data-manohub-ui]) *,
|
|
63
76
|
:where([data-manohub-ui]) *::before,
|
|
64
77
|
:where([data-manohub-ui]) *::after {
|
|
65
78
|
box-sizing: border-box;
|
|
66
|
-
border-width: 0;
|
|
67
|
-
border-style: solid;
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
/* ===== 容器基座:字族 / 字号 / 行高 / 字色 / 底色 / 整链高度(本文件唯一不带 :where() 的一条) ===== */
|
|
@@ -81,129 +92,3 @@
|
|
|
81
92
|
-webkit-font-smoothing: antialiased;
|
|
82
93
|
-moz-osx-font-smoothing: grayscale;
|
|
83
94
|
}
|
|
84
|
-
|
|
85
|
-
/* ===== 块级元素的默认外边距归零 ===== */
|
|
86
|
-
:where([data-manohub-ui]) h1,
|
|
87
|
-
:where([data-manohub-ui]) h2,
|
|
88
|
-
:where([data-manohub-ui]) h3,
|
|
89
|
-
:where([data-manohub-ui]) h4,
|
|
90
|
-
:where([data-manohub-ui]) h5,
|
|
91
|
-
:where([data-manohub-ui]) h6,
|
|
92
|
-
:where([data-manohub-ui]) p,
|
|
93
|
-
:where([data-manohub-ui]) figure,
|
|
94
|
-
:where([data-manohub-ui]) blockquote,
|
|
95
|
-
:where([data-manohub-ui]) dl,
|
|
96
|
-
:where([data-manohub-ui]) dd,
|
|
97
|
-
:where([data-manohub-ui]) pre,
|
|
98
|
-
:where([data-manohub-ui]) hr {
|
|
99
|
-
margin: 0;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* 标题回归正文档:字阶一律由使用方(组件面 / 页面样式)决定,浏览器默认的 2em / bold 不再参与 */
|
|
103
|
-
:where([data-manohub-ui]) h1,
|
|
104
|
-
:where([data-manohub-ui]) h2,
|
|
105
|
-
:where([data-manohub-ui]) h3,
|
|
106
|
-
:where([data-manohub-ui]) h4,
|
|
107
|
-
:where([data-manohub-ui]) h5,
|
|
108
|
-
:where([data-manohub-ui]) h6 {
|
|
109
|
-
font-size: inherit;
|
|
110
|
-
font-weight: inherit;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/* ===== 列表:去序号、去缩进(富文本自行复权,见文件头「富文本须知」) ===== */
|
|
114
|
-
:where([data-manohub-ui]) ul,
|
|
115
|
-
:where([data-manohub-ui]) ol,
|
|
116
|
-
:where([data-manohub-ui]) menu {
|
|
117
|
-
margin: 0;
|
|
118
|
-
padding: 0;
|
|
119
|
-
list-style: none;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/* ===== 链接:继承文字色,下划线交还使用方(链接态由使用方叠加) ===== */
|
|
123
|
-
:where([data-manohub-ui]) a {
|
|
124
|
-
color: inherit;
|
|
125
|
-
text-decoration: inherit;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/* ===== 表单控件:清掉浏览器默认外观,字体与颜色继承上下文 ===== */
|
|
129
|
-
:where([data-manohub-ui]) button,
|
|
130
|
-
:where([data-manohub-ui]) input,
|
|
131
|
-
:where([data-manohub-ui]) optgroup,
|
|
132
|
-
:where([data-manohub-ui]) select,
|
|
133
|
-
:where([data-manohub-ui]) textarea {
|
|
134
|
-
margin: 0;
|
|
135
|
-
padding: 0;
|
|
136
|
-
font: inherit;
|
|
137
|
-
color: inherit;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
:where([data-manohub-ui]) button,
|
|
141
|
-
:where([data-manohub-ui]) [type='button'],
|
|
142
|
-
:where([data-manohub-ui]) [type='reset'],
|
|
143
|
-
:where([data-manohub-ui]) [type='submit'] {
|
|
144
|
-
background-color: transparent;
|
|
145
|
-
background-image: none;
|
|
146
|
-
text-transform: none;
|
|
147
|
-
cursor: pointer;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
:where([data-manohub-ui]) select {
|
|
151
|
-
text-transform: none;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
:where([data-manohub-ui]) textarea {
|
|
155
|
-
resize: vertical;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
:where([data-manohub-ui]) :disabled {
|
|
159
|
-
cursor: default;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
:where([data-manohub-ui]) [type='search'] {
|
|
163
|
-
outline-offset: -2px;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/* ===== 媒体元素:转块级(消除行内基线间隙),宽度不溢出容器 ===== */
|
|
167
|
-
:where([data-manohub-ui]) img,
|
|
168
|
-
:where([data-manohub-ui]) svg,
|
|
169
|
-
:where([data-manohub-ui]) video,
|
|
170
|
-
:where([data-manohub-ui]) canvas,
|
|
171
|
-
:where([data-manohub-ui]) audio,
|
|
172
|
-
:where([data-manohub-ui]) iframe,
|
|
173
|
-
:where([data-manohub-ui]) embed,
|
|
174
|
-
:where([data-manohub-ui]) object {
|
|
175
|
-
display: block;
|
|
176
|
-
vertical-align: middle;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
:where([data-manohub-ui]) img,
|
|
180
|
-
:where([data-manohub-ui]) video {
|
|
181
|
-
max-width: 100%;
|
|
182
|
-
height: auto;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* ===== 行内语义与文本节点 ===== */
|
|
186
|
-
:where([data-manohub-ui]) b,
|
|
187
|
-
:where([data-manohub-ui]) strong {
|
|
188
|
-
font-weight: bolder;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
:where([data-manohub-ui]) code,
|
|
192
|
-
:where([data-manohub-ui]) kbd,
|
|
193
|
-
:where([data-manohub-ui]) samp,
|
|
194
|
-
:where([data-manohub-ui]) pre {
|
|
195
|
-
font-family: var(--ui-font-mono);
|
|
196
|
-
font-size: 1em;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
:where([data-manohub-ui]) small {
|
|
200
|
-
font-size: 80%;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
:where([data-manohub-ui]) summary {
|
|
204
|
-
display: list-item;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
:where([data-manohub-ui]) label {
|
|
208
|
-
margin: 0;
|
|
209
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manohub/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "AIHub 自绘组件层:不依赖 farris 的手写 Vue TSX 组件 + 自带令牌层(Farris 规范视觉 · daisyUI 式语义令牌 · shadcn 式 API 词汇)。",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"vue": "^3.5.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@manohub/icon": "^0.
|
|
49
|
+
"@manohub/icon": "^0.10.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^24.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 单件令牌(只服务本件,故不随主题进 `@manohub/theme`):
|
|
3
|
-
* 字段最小宽 240 —— 与稿里 270 的字段宽同档,但允许容器够宽时均分铺满、不够时整体换行
|
|
4
|
-
* (1160 内容宽下一行正好排 4 个:4×240 + 3×24 = 1032 ≤ 1160)。
|
|
5
|
-
*
|
|
6
|
-
* ## 抽出说明
|
|
7
|
-
* 本文件从面文件里抽出:这些是**基础值**,锚在 `[data-manohub-ui]`(跨包唯一作用域锚,
|
|
8
|
-
* 由入口层无条件写在应用容器上)—— 任何落在容器里的分件都取得到值,不再依赖
|
|
9
|
-
* 「声明在某个组件根类上」这条脆弱假设。
|
|
10
|
-
* ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里(拆开会让档位失效)。
|
|
11
|
-
*/
|
|
12
|
-
[data-manohub-ui] {
|
|
13
|
-
--ui-filter-item-min: 240px;
|
|
14
|
-
}
|