@manohub/ui 1.2.3 → 1.2.5
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/components/code-block/index.d.ts +71 -5
- package/dist/components/code-block/index.js +19 -2
- package/dist/components/layout/index.d.ts +392 -0
- package/dist/components/layout/index.js +125 -8
- package/dist/components/part-padding.d.ts +18 -0
- package/dist/components/part-padding.js +25 -0
- package/dist/components/table/index.d.ts +4 -4
- package/dist/components/table/index.js +3 -3
- package/dist/components/text/index.d.ts +18 -0
- package/dist/components/text/index.js +6 -1
- package/dist/styles/components/code-block.css +228 -206
- package/dist/styles/components/layout.css +268 -181
- package/dist/styles/components/text.css +125 -102
- package/package.json +2 -2
|
@@ -16,6 +16,28 @@ export type LayoutJustify = 'start' | 'center' | 'end' | 'between';
|
|
|
16
16
|
export type LayoutColumns = 1 | 2 | 3 | 4;
|
|
17
17
|
/** 栅格单元跨格数:不应超过所在行的 `columns`(超了 auto-fit 会为它多开轨道) */
|
|
18
18
|
export type LayoutSpan = 1 | 2 | 3 | 4;
|
|
19
|
+
/**
|
|
20
|
+
* 伸缩档(`flex` 简写)—— 「**我在父级里占多少**」,与 `gap` / `align`(「我怎么排子级」)
|
|
21
|
+
* 是方向相反的两件事:后者归**容器**,前者归**盒子**。
|
|
22
|
+
*
|
|
23
|
+
* - `none` → `flex: 0 0 auto`:不伸不缩,按内容定大小(工具栏块、页脚操作组、错误提示行)
|
|
24
|
+
* - `auto` → `flex: 1 1 auto`:按内容起步、有剩余就吃(搜索框、主编辑区、表单主列)
|
|
25
|
+
* - `fill` → `flex: 1 1 0`:**忽略内容宽**、按比例均分(左右分栏各一半;内容不对称时才看得出差别)
|
|
26
|
+
*
|
|
27
|
+
* 三档覆盖了本仓应用侧 90% 的 `flex` 简写;极少数「按内容起步但要指定下限」的用 `basis`。
|
|
28
|
+
*/
|
|
29
|
+
export type LayoutGrow = 'none' | 'auto' | 'fill';
|
|
30
|
+
/**
|
|
31
|
+
* 滚动档(`overflow`)。**必须配 `fill` 或 `maxHeight`** —— 没有确定高度/宽度时 `auto` 等于不滚,
|
|
32
|
+
* 内容会把父级撑开(这也是 `Layout` 只提供「谁滚」、不提供「多高」的原因:高度该由结构给)。
|
|
33
|
+
*/
|
|
34
|
+
export type LayoutScroll = 'y' | 'x' | 'both';
|
|
35
|
+
/**
|
|
36
|
+
* 自动外边距:`start` = 把自己推到**末尾**(`margin-inline-start: auto`,flex 里做「右推」);
|
|
37
|
+
* `end` = 推到**开头**(左推)。与 `justify` 的区别:`justify` 均匀分布所有子项,
|
|
38
|
+
* 自动外边距只推**这一个**,同排里还有别的元素时不会把它们一起推开。
|
|
39
|
+
*/
|
|
40
|
+
export type LayoutMarginAuto = 'start' | 'end';
|
|
19
41
|
/**
|
|
20
42
|
* 布局原子件族(命名空间,**本身不是组件**)。
|
|
21
43
|
*
|
|
@@ -75,6 +97,91 @@ export declare const Layout: {
|
|
|
75
97
|
type: PropType<Padding>;
|
|
76
98
|
default: undefined;
|
|
77
99
|
};
|
|
100
|
+
/** 伸缩档;不传 = 不干预(保留 CSS 默认 `0 1 auto`) */
|
|
101
|
+
grow: {
|
|
102
|
+
type: PropType<LayoutGrow>;
|
|
103
|
+
default: undefined;
|
|
104
|
+
};
|
|
105
|
+
/** 伸缩基准:`number` 补 px、`string` 原样(`'42%'` / `'auto'` / 引令牌);配 `grow="auto"` 表达「按 280px 起步,有剩余继续吃」 */
|
|
106
|
+
basis: {
|
|
107
|
+
type: PropType<number | string>;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
/** `false` = 不许收缩(`flex-shrink: 0`):内容不能被压扁时用;不传 = 允许 */
|
|
111
|
+
shrink: {
|
|
112
|
+
type: BooleanConstructor;
|
|
113
|
+
default: undefined;
|
|
114
|
+
};
|
|
115
|
+
/** 撑满父级(`height: 100%` + `min-height: 0`):分栏/弹窗正文的纵向链起点 */
|
|
116
|
+
fill: {
|
|
117
|
+
type: BooleanConstructor;
|
|
118
|
+
default: boolean;
|
|
119
|
+
};
|
|
120
|
+
/** 滚动档;配 `fill` 或 `maxHeight` 才有意义 */
|
|
121
|
+
scroll: {
|
|
122
|
+
type: PropType<LayoutScroll>;
|
|
123
|
+
default: undefined;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* 裁掉溢出(`overflow: hidden`)—— **不滚动**的那种。
|
|
127
|
+
* 与 `scroll` 是互斥的两件事:`scroll` = 溢出后出滚动条、`clip` = 溢出直接看不见。
|
|
128
|
+
* 典型场景:填充型件(`Table` / `CodeBlock`)的父级「给定高度但不许撑破」。
|
|
129
|
+
*/
|
|
130
|
+
clip: {
|
|
131
|
+
type: BooleanConstructor;
|
|
132
|
+
default: boolean;
|
|
133
|
+
};
|
|
134
|
+
/** 高度上限:`number` 补 px、`string` 原样(引令牌);`scroll` 的定高兜底档 */
|
|
135
|
+
maxHeight: {
|
|
136
|
+
type: PropType<number | string>;
|
|
137
|
+
default: undefined;
|
|
138
|
+
};
|
|
139
|
+
/** 显式宽度下限(px);`Layout` 本身自带 `min-width: 0`,这里是**抬高**下限时用 */
|
|
140
|
+
minWidth: {
|
|
141
|
+
type: NumberConstructor;
|
|
142
|
+
default: undefined;
|
|
143
|
+
};
|
|
144
|
+
/** 高度下限(px);`minHeight={0}` 是「允许被压小」,纵向 flex 链里与 `min-width:0` 对称 */
|
|
145
|
+
minHeight: {
|
|
146
|
+
type: NumberConstructor;
|
|
147
|
+
default: undefined;
|
|
148
|
+
};
|
|
149
|
+
/** 宽度上限(px) */
|
|
150
|
+
maxWidth: {
|
|
151
|
+
type: NumberConstructor;
|
|
152
|
+
default: undefined;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* 原样透传到根元素的 `title`(原生悬浮提示)。
|
|
156
|
+
*
|
|
157
|
+
* 为什么必须单独收:本件是 `inheritAttrs: false`,只处理 `class` / `style` / `padding` / `margin`,
|
|
158
|
+
* 消费方挂上来的 `title` 不会落地 —— 而「长文本被截断后 hover 看全名」必须挂 `title`,
|
|
159
|
+
* 应用侧只好在外面多套一层 `<span title>`,白白多一层 DOM。
|
|
160
|
+
*/
|
|
161
|
+
title: {
|
|
162
|
+
type: StringConstructor;
|
|
163
|
+
default: undefined;
|
|
164
|
+
};
|
|
165
|
+
/** 不换行(`white-space: nowrap`):配 `clip` 就是「容器级裁切」,混排内容(子元素 + 文本)也裁得住 */
|
|
166
|
+
nowrap: {
|
|
167
|
+
type: BooleanConstructor;
|
|
168
|
+
default: boolean;
|
|
169
|
+
};
|
|
170
|
+
/** 固定宽度:`number` 补 px、`string` 原样 */
|
|
171
|
+
width: {
|
|
172
|
+
type: PropType<number | string>;
|
|
173
|
+
default: undefined;
|
|
174
|
+
};
|
|
175
|
+
/** 外边距:口径同 `padding`(`number` / `{ y, x }` / `string` 逃生舱) */
|
|
176
|
+
margin: {
|
|
177
|
+
type: PropType<Padding>;
|
|
178
|
+
default: undefined;
|
|
179
|
+
};
|
|
180
|
+
/** 自动外边距(单侧 `auto`);与 `margin` 同时给时 **`margin` 胜出**(行内样式优先于类) */
|
|
181
|
+
marginAuto: {
|
|
182
|
+
type: PropType<LayoutMarginAuto>;
|
|
183
|
+
default: undefined;
|
|
184
|
+
};
|
|
78
185
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
79
186
|
/** 行间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
80
187
|
gap: {
|
|
@@ -112,11 +219,111 @@ export declare const Layout: {
|
|
|
112
219
|
type: PropType<Padding>;
|
|
113
220
|
default: undefined;
|
|
114
221
|
};
|
|
222
|
+
/** 伸缩档;不传 = 不干预(保留 CSS 默认 `0 1 auto`) */
|
|
223
|
+
grow: {
|
|
224
|
+
type: PropType<LayoutGrow>;
|
|
225
|
+
default: undefined;
|
|
226
|
+
};
|
|
227
|
+
/** 伸缩基准:`number` 补 px、`string` 原样(`'42%'` / `'auto'` / 引令牌);配 `grow="auto"` 表达「按 280px 起步,有剩余继续吃」 */
|
|
228
|
+
basis: {
|
|
229
|
+
type: PropType<number | string>;
|
|
230
|
+
default: undefined;
|
|
231
|
+
};
|
|
232
|
+
/** `false` = 不许收缩(`flex-shrink: 0`):内容不能被压扁时用;不传 = 允许 */
|
|
233
|
+
shrink: {
|
|
234
|
+
type: BooleanConstructor;
|
|
235
|
+
default: undefined;
|
|
236
|
+
};
|
|
237
|
+
/** 撑满父级(`height: 100%` + `min-height: 0`):分栏/弹窗正文的纵向链起点 */
|
|
238
|
+
fill: {
|
|
239
|
+
type: BooleanConstructor;
|
|
240
|
+
default: boolean;
|
|
241
|
+
};
|
|
242
|
+
/** 滚动档;配 `fill` 或 `maxHeight` 才有意义 */
|
|
243
|
+
scroll: {
|
|
244
|
+
type: PropType<LayoutScroll>;
|
|
245
|
+
default: undefined;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* 裁掉溢出(`overflow: hidden`)—— **不滚动**的那种。
|
|
249
|
+
* 与 `scroll` 是互斥的两件事:`scroll` = 溢出后出滚动条、`clip` = 溢出直接看不见。
|
|
250
|
+
* 典型场景:填充型件(`Table` / `CodeBlock`)的父级「给定高度但不许撑破」。
|
|
251
|
+
*/
|
|
252
|
+
clip: {
|
|
253
|
+
type: BooleanConstructor;
|
|
254
|
+
default: boolean;
|
|
255
|
+
};
|
|
256
|
+
/** 高度上限:`number` 补 px、`string` 原样(引令牌);`scroll` 的定高兜底档 */
|
|
257
|
+
maxHeight: {
|
|
258
|
+
type: PropType<number | string>;
|
|
259
|
+
default: undefined;
|
|
260
|
+
};
|
|
261
|
+
/** 显式宽度下限(px);`Layout` 本身自带 `min-width: 0`,这里是**抬高**下限时用 */
|
|
262
|
+
minWidth: {
|
|
263
|
+
type: NumberConstructor;
|
|
264
|
+
default: undefined;
|
|
265
|
+
};
|
|
266
|
+
/** 高度下限(px);`minHeight={0}` 是「允许被压小」,纵向 flex 链里与 `min-width:0` 对称 */
|
|
267
|
+
minHeight: {
|
|
268
|
+
type: NumberConstructor;
|
|
269
|
+
default: undefined;
|
|
270
|
+
};
|
|
271
|
+
/** 宽度上限(px) */
|
|
272
|
+
maxWidth: {
|
|
273
|
+
type: NumberConstructor;
|
|
274
|
+
default: undefined;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* 原样透传到根元素的 `title`(原生悬浮提示)。
|
|
278
|
+
*
|
|
279
|
+
* 为什么必须单独收:本件是 `inheritAttrs: false`,只处理 `class` / `style` / `padding` / `margin`,
|
|
280
|
+
* 消费方挂上来的 `title` 不会落地 —— 而「长文本被截断后 hover 看全名」必须挂 `title`,
|
|
281
|
+
* 应用侧只好在外面多套一层 `<span title>`,白白多一层 DOM。
|
|
282
|
+
*/
|
|
283
|
+
title: {
|
|
284
|
+
type: StringConstructor;
|
|
285
|
+
default: undefined;
|
|
286
|
+
};
|
|
287
|
+
/** 不换行(`white-space: nowrap`):配 `clip` 就是「容器级裁切」,混排内容(子元素 + 文本)也裁得住 */
|
|
288
|
+
nowrap: {
|
|
289
|
+
type: BooleanConstructor;
|
|
290
|
+
default: boolean;
|
|
291
|
+
};
|
|
292
|
+
/** 固定宽度:`number` 补 px、`string` 原样 */
|
|
293
|
+
width: {
|
|
294
|
+
type: PropType<number | string>;
|
|
295
|
+
default: undefined;
|
|
296
|
+
};
|
|
297
|
+
/** 外边距:口径同 `padding`(`number` / `{ y, x }` / `string` 逃生舱) */
|
|
298
|
+
margin: {
|
|
299
|
+
type: PropType<Padding>;
|
|
300
|
+
default: undefined;
|
|
301
|
+
};
|
|
302
|
+
/** 自动外边距(单侧 `auto`);与 `margin` 同时给时 **`margin` 胜出**(行内样式优先于类) */
|
|
303
|
+
marginAuto: {
|
|
304
|
+
type: PropType<LayoutMarginAuto>;
|
|
305
|
+
default: undefined;
|
|
306
|
+
};
|
|
115
307
|
}>> & Readonly<{}>, {
|
|
116
308
|
padding: Padding;
|
|
309
|
+
margin: Padding;
|
|
310
|
+
fill: boolean;
|
|
311
|
+
scroll: LayoutScroll;
|
|
312
|
+
nowrap: boolean;
|
|
313
|
+
clip: boolean;
|
|
117
314
|
justify: LayoutJustify;
|
|
315
|
+
title: string;
|
|
316
|
+
width: string | number;
|
|
317
|
+
minWidth: number;
|
|
318
|
+
minHeight: number;
|
|
319
|
+
maxWidth: number;
|
|
320
|
+
maxHeight: string | number;
|
|
118
321
|
gap: LayoutGap;
|
|
119
322
|
align: LayoutAlign;
|
|
323
|
+
grow: LayoutGrow;
|
|
324
|
+
basis: string | number;
|
|
325
|
+
shrink: boolean;
|
|
326
|
+
marginAuto: LayoutMarginAuto;
|
|
120
327
|
columns: LayoutColumns;
|
|
121
328
|
minColumnWidth: number;
|
|
122
329
|
}, SlotsType<{
|
|
@@ -153,6 +360,91 @@ export declare const Layout: {
|
|
|
153
360
|
type: PropType<Padding>;
|
|
154
361
|
default: undefined;
|
|
155
362
|
};
|
|
363
|
+
/** 伸缩档;不传 = 不干预(保留 CSS 默认 `0 1 auto`) */
|
|
364
|
+
grow: {
|
|
365
|
+
type: PropType<LayoutGrow>;
|
|
366
|
+
default: undefined;
|
|
367
|
+
};
|
|
368
|
+
/** 伸缩基准:`number` 补 px、`string` 原样(`'42%'` / `'auto'` / 引令牌);配 `grow="auto"` 表达「按 280px 起步,有剩余继续吃」 */
|
|
369
|
+
basis: {
|
|
370
|
+
type: PropType<number | string>;
|
|
371
|
+
default: undefined;
|
|
372
|
+
};
|
|
373
|
+
/** `false` = 不许收缩(`flex-shrink: 0`):内容不能被压扁时用;不传 = 允许 */
|
|
374
|
+
shrink: {
|
|
375
|
+
type: BooleanConstructor;
|
|
376
|
+
default: undefined;
|
|
377
|
+
};
|
|
378
|
+
/** 撑满父级(`height: 100%` + `min-height: 0`):分栏/弹窗正文的纵向链起点 */
|
|
379
|
+
fill: {
|
|
380
|
+
type: BooleanConstructor;
|
|
381
|
+
default: boolean;
|
|
382
|
+
};
|
|
383
|
+
/** 滚动档;配 `fill` 或 `maxHeight` 才有意义 */
|
|
384
|
+
scroll: {
|
|
385
|
+
type: PropType<LayoutScroll>;
|
|
386
|
+
default: undefined;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* 裁掉溢出(`overflow: hidden`)—— **不滚动**的那种。
|
|
390
|
+
* 与 `scroll` 是互斥的两件事:`scroll` = 溢出后出滚动条、`clip` = 溢出直接看不见。
|
|
391
|
+
* 典型场景:填充型件(`Table` / `CodeBlock`)的父级「给定高度但不许撑破」。
|
|
392
|
+
*/
|
|
393
|
+
clip: {
|
|
394
|
+
type: BooleanConstructor;
|
|
395
|
+
default: boolean;
|
|
396
|
+
};
|
|
397
|
+
/** 高度上限:`number` 补 px、`string` 原样(引令牌);`scroll` 的定高兜底档 */
|
|
398
|
+
maxHeight: {
|
|
399
|
+
type: PropType<number | string>;
|
|
400
|
+
default: undefined;
|
|
401
|
+
};
|
|
402
|
+
/** 显式宽度下限(px);`Layout` 本身自带 `min-width: 0`,这里是**抬高**下限时用 */
|
|
403
|
+
minWidth: {
|
|
404
|
+
type: NumberConstructor;
|
|
405
|
+
default: undefined;
|
|
406
|
+
};
|
|
407
|
+
/** 高度下限(px);`minHeight={0}` 是「允许被压小」,纵向 flex 链里与 `min-width:0` 对称 */
|
|
408
|
+
minHeight: {
|
|
409
|
+
type: NumberConstructor;
|
|
410
|
+
default: undefined;
|
|
411
|
+
};
|
|
412
|
+
/** 宽度上限(px) */
|
|
413
|
+
maxWidth: {
|
|
414
|
+
type: NumberConstructor;
|
|
415
|
+
default: undefined;
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* 原样透传到根元素的 `title`(原生悬浮提示)。
|
|
419
|
+
*
|
|
420
|
+
* 为什么必须单独收:本件是 `inheritAttrs: false`,只处理 `class` / `style` / `padding` / `margin`,
|
|
421
|
+
* 消费方挂上来的 `title` 不会落地 —— 而「长文本被截断后 hover 看全名」必须挂 `title`,
|
|
422
|
+
* 应用侧只好在外面多套一层 `<span title>`,白白多一层 DOM。
|
|
423
|
+
*/
|
|
424
|
+
title: {
|
|
425
|
+
type: StringConstructor;
|
|
426
|
+
default: undefined;
|
|
427
|
+
};
|
|
428
|
+
/** 不换行(`white-space: nowrap`):配 `clip` 就是「容器级裁切」,混排内容(子元素 + 文本)也裁得住 */
|
|
429
|
+
nowrap: {
|
|
430
|
+
type: BooleanConstructor;
|
|
431
|
+
default: boolean;
|
|
432
|
+
};
|
|
433
|
+
/** 固定宽度:`number` 补 px、`string` 原样 */
|
|
434
|
+
width: {
|
|
435
|
+
type: PropType<number | string>;
|
|
436
|
+
default: undefined;
|
|
437
|
+
};
|
|
438
|
+
/** 外边距:口径同 `padding`(`number` / `{ y, x }` / `string` 逃生舱) */
|
|
439
|
+
margin: {
|
|
440
|
+
type: PropType<Padding>;
|
|
441
|
+
default: undefined;
|
|
442
|
+
};
|
|
443
|
+
/** 自动外边距(单侧 `auto`);与 `margin` 同时给时 **`margin` 胜出**(行内样式优先于类) */
|
|
444
|
+
marginAuto: {
|
|
445
|
+
type: PropType<LayoutMarginAuto>;
|
|
446
|
+
default: undefined;
|
|
447
|
+
};
|
|
156
448
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
157
449
|
/** 单元内间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
158
450
|
gap: {
|
|
@@ -184,13 +476,113 @@ export declare const Layout: {
|
|
|
184
476
|
type: PropType<Padding>;
|
|
185
477
|
default: undefined;
|
|
186
478
|
};
|
|
479
|
+
/** 伸缩档;不传 = 不干预(保留 CSS 默认 `0 1 auto`) */
|
|
480
|
+
grow: {
|
|
481
|
+
type: PropType<LayoutGrow>;
|
|
482
|
+
default: undefined;
|
|
483
|
+
};
|
|
484
|
+
/** 伸缩基准:`number` 补 px、`string` 原样(`'42%'` / `'auto'` / 引令牌);配 `grow="auto"` 表达「按 280px 起步,有剩余继续吃」 */
|
|
485
|
+
basis: {
|
|
486
|
+
type: PropType<number | string>;
|
|
487
|
+
default: undefined;
|
|
488
|
+
};
|
|
489
|
+
/** `false` = 不许收缩(`flex-shrink: 0`):内容不能被压扁时用;不传 = 允许 */
|
|
490
|
+
shrink: {
|
|
491
|
+
type: BooleanConstructor;
|
|
492
|
+
default: undefined;
|
|
493
|
+
};
|
|
494
|
+
/** 撑满父级(`height: 100%` + `min-height: 0`):分栏/弹窗正文的纵向链起点 */
|
|
495
|
+
fill: {
|
|
496
|
+
type: BooleanConstructor;
|
|
497
|
+
default: boolean;
|
|
498
|
+
};
|
|
499
|
+
/** 滚动档;配 `fill` 或 `maxHeight` 才有意义 */
|
|
500
|
+
scroll: {
|
|
501
|
+
type: PropType<LayoutScroll>;
|
|
502
|
+
default: undefined;
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* 裁掉溢出(`overflow: hidden`)—— **不滚动**的那种。
|
|
506
|
+
* 与 `scroll` 是互斥的两件事:`scroll` = 溢出后出滚动条、`clip` = 溢出直接看不见。
|
|
507
|
+
* 典型场景:填充型件(`Table` / `CodeBlock`)的父级「给定高度但不许撑破」。
|
|
508
|
+
*/
|
|
509
|
+
clip: {
|
|
510
|
+
type: BooleanConstructor;
|
|
511
|
+
default: boolean;
|
|
512
|
+
};
|
|
513
|
+
/** 高度上限:`number` 补 px、`string` 原样(引令牌);`scroll` 的定高兜底档 */
|
|
514
|
+
maxHeight: {
|
|
515
|
+
type: PropType<number | string>;
|
|
516
|
+
default: undefined;
|
|
517
|
+
};
|
|
518
|
+
/** 显式宽度下限(px);`Layout` 本身自带 `min-width: 0`,这里是**抬高**下限时用 */
|
|
519
|
+
minWidth: {
|
|
520
|
+
type: NumberConstructor;
|
|
521
|
+
default: undefined;
|
|
522
|
+
};
|
|
523
|
+
/** 高度下限(px);`minHeight={0}` 是「允许被压小」,纵向 flex 链里与 `min-width:0` 对称 */
|
|
524
|
+
minHeight: {
|
|
525
|
+
type: NumberConstructor;
|
|
526
|
+
default: undefined;
|
|
527
|
+
};
|
|
528
|
+
/** 宽度上限(px) */
|
|
529
|
+
maxWidth: {
|
|
530
|
+
type: NumberConstructor;
|
|
531
|
+
default: undefined;
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* 原样透传到根元素的 `title`(原生悬浮提示)。
|
|
535
|
+
*
|
|
536
|
+
* 为什么必须单独收:本件是 `inheritAttrs: false`,只处理 `class` / `style` / `padding` / `margin`,
|
|
537
|
+
* 消费方挂上来的 `title` 不会落地 —— 而「长文本被截断后 hover 看全名」必须挂 `title`,
|
|
538
|
+
* 应用侧只好在外面多套一层 `<span title>`,白白多一层 DOM。
|
|
539
|
+
*/
|
|
540
|
+
title: {
|
|
541
|
+
type: StringConstructor;
|
|
542
|
+
default: undefined;
|
|
543
|
+
};
|
|
544
|
+
/** 不换行(`white-space: nowrap`):配 `clip` 就是「容器级裁切」,混排内容(子元素 + 文本)也裁得住 */
|
|
545
|
+
nowrap: {
|
|
546
|
+
type: BooleanConstructor;
|
|
547
|
+
default: boolean;
|
|
548
|
+
};
|
|
549
|
+
/** 固定宽度:`number` 补 px、`string` 原样 */
|
|
550
|
+
width: {
|
|
551
|
+
type: PropType<number | string>;
|
|
552
|
+
default: undefined;
|
|
553
|
+
};
|
|
554
|
+
/** 外边距:口径同 `padding`(`number` / `{ y, x }` / `string` 逃生舱) */
|
|
555
|
+
margin: {
|
|
556
|
+
type: PropType<Padding>;
|
|
557
|
+
default: undefined;
|
|
558
|
+
};
|
|
559
|
+
/** 自动外边距(单侧 `auto`);与 `margin` 同时给时 **`margin` 胜出**(行内样式优先于类) */
|
|
560
|
+
marginAuto: {
|
|
561
|
+
type: PropType<LayoutMarginAuto>;
|
|
562
|
+
default: undefined;
|
|
563
|
+
};
|
|
187
564
|
}>> & Readonly<{}>, {
|
|
188
565
|
padding: Padding;
|
|
566
|
+
margin: Padding;
|
|
567
|
+
fill: boolean;
|
|
568
|
+
scroll: LayoutScroll;
|
|
569
|
+
nowrap: boolean;
|
|
189
570
|
wrap: boolean;
|
|
571
|
+
clip: boolean;
|
|
190
572
|
justify: LayoutJustify;
|
|
191
573
|
span: LayoutSpan;
|
|
574
|
+
title: string;
|
|
575
|
+
width: string | number;
|
|
576
|
+
minWidth: number;
|
|
577
|
+
minHeight: number;
|
|
578
|
+
maxWidth: number;
|
|
579
|
+
maxHeight: string | number;
|
|
192
580
|
gap: LayoutGap;
|
|
193
581
|
align: LayoutAlign;
|
|
582
|
+
grow: LayoutGrow;
|
|
583
|
+
basis: string | number;
|
|
584
|
+
shrink: boolean;
|
|
585
|
+
marginAuto: LayoutMarginAuto;
|
|
194
586
|
}, SlotsType<{
|
|
195
587
|
default?: () => VNodeChild;
|
|
196
588
|
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,12 +1,128 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { mergePartBoxStyle } from "../part-padding.js";
|
|
3
3
|
function modifier(base, name, value) {
|
|
4
4
|
return value === void 0 || value === "" ? "" : `${base}--${name}-${value}`;
|
|
5
5
|
}
|
|
6
|
+
const boxProps = {
|
|
7
|
+
/** 伸缩档;不传 = 不干预(保留 CSS 默认 `0 1 auto`) */
|
|
8
|
+
grow: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: void 0
|
|
11
|
+
},
|
|
12
|
+
/** 伸缩基准:`number` 补 px、`string` 原样(`'42%'` / `'auto'` / 引令牌);配 `grow="auto"` 表达「按 280px 起步,有剩余继续吃」 */
|
|
13
|
+
basis: {
|
|
14
|
+
type: [Number, String],
|
|
15
|
+
default: void 0
|
|
16
|
+
},
|
|
17
|
+
/** `false` = 不许收缩(`flex-shrink: 0`):内容不能被压扁时用;不传 = 允许 */
|
|
18
|
+
shrink: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: void 0
|
|
21
|
+
},
|
|
22
|
+
/** 撑满父级(`height: 100%` + `min-height: 0`):分栏/弹窗正文的纵向链起点 */
|
|
23
|
+
fill: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
/** 滚动档;配 `fill` 或 `maxHeight` 才有意义 */
|
|
28
|
+
scroll: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: void 0
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* 裁掉溢出(`overflow: hidden`)—— **不滚动**的那种。
|
|
34
|
+
* 与 `scroll` 是互斥的两件事:`scroll` = 溢出后出滚动条、`clip` = 溢出直接看不见。
|
|
35
|
+
* 典型场景:填充型件(`Table` / `CodeBlock`)的父级「给定高度但不许撑破」。
|
|
36
|
+
*/
|
|
37
|
+
clip: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
/** 高度上限:`number` 补 px、`string` 原样(引令牌);`scroll` 的定高兜底档 */
|
|
42
|
+
maxHeight: {
|
|
43
|
+
type: [Number, String],
|
|
44
|
+
default: void 0
|
|
45
|
+
},
|
|
46
|
+
/** 显式宽度下限(px);`Layout` 本身自带 `min-width: 0`,这里是**抬高**下限时用 */
|
|
47
|
+
minWidth: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
/** 高度下限(px);`minHeight={0}` 是「允许被压小」,纵向 flex 链里与 `min-width:0` 对称 */
|
|
52
|
+
minHeight: {
|
|
53
|
+
type: Number,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
/** 宽度上限(px) */
|
|
57
|
+
maxWidth: {
|
|
58
|
+
type: Number,
|
|
59
|
+
default: void 0
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* 原样透传到根元素的 `title`(原生悬浮提示)。
|
|
63
|
+
*
|
|
64
|
+
* 为什么必须单独收:本件是 `inheritAttrs: false`,只处理 `class` / `style` / `padding` / `margin`,
|
|
65
|
+
* 消费方挂上来的 `title` 不会落地 —— 而「长文本被截断后 hover 看全名」必须挂 `title`,
|
|
66
|
+
* 应用侧只好在外面多套一层 `<span title>`,白白多一层 DOM。
|
|
67
|
+
*/
|
|
68
|
+
title: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: void 0
|
|
71
|
+
},
|
|
72
|
+
/** 不换行(`white-space: nowrap`):配 `clip` 就是「容器级裁切」,混排内容(子元素 + 文本)也裁得住 */
|
|
73
|
+
nowrap: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
/** 固定宽度:`number` 补 px、`string` 原样 */
|
|
78
|
+
width: {
|
|
79
|
+
type: [Number, String],
|
|
80
|
+
default: void 0
|
|
81
|
+
},
|
|
82
|
+
/** 外边距:口径同 `padding`(`number` / `{ y, x }` / `string` 逃生舱) */
|
|
83
|
+
margin: {
|
|
84
|
+
type: [Number, Object, String],
|
|
85
|
+
default: void 0
|
|
86
|
+
},
|
|
87
|
+
/** 自动外边距(单侧 `auto`);与 `margin` 同时给时 **`margin` 胜出**(行内样式优先于类) */
|
|
88
|
+
marginAuto: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: void 0
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function boxClasses(base, props) {
|
|
94
|
+
return [
|
|
95
|
+
props.grow ? `${base}--grow-${props.grow}` : "",
|
|
96
|
+
props.shrink === false ? `${base}--no-shrink` : "",
|
|
97
|
+
/* `shrink={true}` 也要挂类:`grow="none"` 的 `flex: 0 0 auto` 把 shrink 一起关掉了,
|
|
98
|
+
而真实需求里有「能缩但不能长」(`flex: 0 1 auto`)—— 显式 true 才是那一档 */
|
|
99
|
+
props.shrink === true ? `${base}--can-shrink` : "",
|
|
100
|
+
props.fill ? `${base}--fill` : "",
|
|
101
|
+
props.scroll ? `${base}--scroll-${props.scroll}` : "",
|
|
102
|
+
props.clip ? `${base}--clip` : "",
|
|
103
|
+
props.marginAuto ? `${base}--margin-auto-${props.marginAuto}` : "",
|
|
104
|
+
props.nowrap ? `${base}--nowrap` : ""
|
|
105
|
+
].filter(Boolean);
|
|
106
|
+
}
|
|
107
|
+
function boxStyle(attrsStyle, props) {
|
|
108
|
+
const style = {
|
|
109
|
+
...attrsStyle ?? {}
|
|
110
|
+
};
|
|
111
|
+
const px = (v) => `${v}px`;
|
|
112
|
+
const len = (v) => typeof v === "number" ? px(v) : v;
|
|
113
|
+
if (props.basis !== void 0) style.flexBasis = len(props.basis);
|
|
114
|
+
if (props.width !== void 0) style.width = len(props.width);
|
|
115
|
+
if (props.minWidth !== void 0) style.minWidth = px(props.minWidth);
|
|
116
|
+
if (props.minHeight !== void 0) style.minHeight = px(props.minHeight);
|
|
117
|
+
if (props.maxWidth !== void 0) style.maxWidth = px(props.maxWidth);
|
|
118
|
+
if (props.maxHeight !== void 0) style.maxHeight = len(props.maxHeight);
|
|
119
|
+
return style;
|
|
120
|
+
}
|
|
6
121
|
const LayoutColumn = /* @__PURE__ */ defineComponent({
|
|
7
122
|
name: "LayoutColumn",
|
|
8
123
|
inheritAttrs: false,
|
|
9
124
|
props: {
|
|
125
|
+
...boxProps,
|
|
10
126
|
/** 单元内间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
11
127
|
gap: {
|
|
12
128
|
type: String,
|
|
@@ -44,8 +160,9 @@ const LayoutColumn = /* @__PURE__ */ defineComponent({
|
|
|
44
160
|
attrs
|
|
45
161
|
}) {
|
|
46
162
|
return () => createVNode("div", {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
163
|
+
"title": props.title,
|
|
164
|
+
"class": ["mh-layout-column", modifier("mh-layout-column", "gap", props.gap), modifier("mh-layout-column", "align", props.align), props.justify && props.justify !== "start" ? modifier("mh-layout-column", "justify", props.justify) : "", props.wrap ? "mh-layout-column--wrap" : "", props.span > 1 ? `mh-layout-column--span-${props.span}` : "", ...boxClasses("mh-layout-column", props), attrs.class].filter(Boolean).join(" "),
|
|
165
|
+
"style": mergePartBoxStyle(boxStyle(attrs.style, props), props.padding, props.margin)
|
|
49
166
|
}, [slots.default?.()]);
|
|
50
167
|
}
|
|
51
168
|
});
|
|
@@ -53,6 +170,7 @@ const LayoutRow = /* @__PURE__ */ defineComponent({
|
|
|
53
170
|
name: "LayoutRow",
|
|
54
171
|
inheritAttrs: false,
|
|
55
172
|
props: {
|
|
173
|
+
...boxProps,
|
|
56
174
|
/** 行间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
57
175
|
gap: {
|
|
58
176
|
type: String,
|
|
@@ -97,13 +215,12 @@ const LayoutRow = /* @__PURE__ */ defineComponent({
|
|
|
97
215
|
}) {
|
|
98
216
|
return () => {
|
|
99
217
|
const isGrid = props.columns !== void 0;
|
|
100
|
-
const style =
|
|
101
|
-
...attrs.style ?? {}
|
|
102
|
-
};
|
|
218
|
+
const style = boxStyle(attrs.style, props);
|
|
103
219
|
if (props.minColumnWidth) style["--ui-layout-row-min"] = `${props.minColumnWidth}px`;
|
|
104
220
|
return createVNode("div", {
|
|
105
|
-
"
|
|
106
|
-
"
|
|
221
|
+
"title": props.title,
|
|
222
|
+
"class": ["mh-layout-row", modifier("mh-layout-row", "gap", props.gap), modifier("mh-layout-row", "align", props.align), props.justify && props.justify !== "start" ? modifier("mh-layout-row", "justify", props.justify) : "", isGrid ? "mh-layout-row--grid" : "", isGrid ? modifier("mh-layout-row", "columns", props.columns) : "", ...boxClasses("mh-layout-row", props), attrs.class].filter(Boolean).join(" "),
|
|
223
|
+
"style": mergePartBoxStyle(style, props.padding, props.margin)
|
|
107
224
|
}, [slots.default?.()]);
|
|
108
225
|
};
|
|
109
226
|
}
|
|
@@ -21,8 +21,26 @@ export type Padding = number | {
|
|
|
21
21
|
} | string;
|
|
22
22
|
/** 内距 → 行内样式。缺省(`undefined` / 空串)时返回 `undefined`:**不额外产生 style 属性**,DOM 与「没有这个维度」时一致。 */
|
|
23
23
|
export declare function partPaddingStyle(padding: Padding | undefined): StyleValue | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* **外边距**口径 —— 与上面的 `Padding` 完全同一套(`number` / `{ y, x }` / `string` 逃生舱),
|
|
26
|
+
* 只是属性名换成 `margin*`。目前只有 `Layout` 用(2026-10-23 起):
|
|
27
|
+
* 块与块之间的外边距在应用侧原来只能写 `margin-bottom: 12px`,而「相邻兄弟的间距」用 `gap`、
|
|
28
|
+
* 「我这块与下一块」用 `margin`,两者语义不同、都需要有通道。
|
|
29
|
+
*
|
|
30
|
+
* 与 `padding` 一起放在本文件,是因为**两者共用同一份「长度 → CSS 值」换算**(`lengthOf`);
|
|
31
|
+
* 分开两份会立刻分叉(一方支持令牌字符串、另一方只支持数字)。
|
|
32
|
+
*/
|
|
33
|
+
export declare function partMarginStyle(margin: Padding | undefined): StyleValue | undefined;
|
|
24
34
|
/**
|
|
25
35
|
* 合并「消费方给的 `style`」与「内距行内样式」:两者都可能有时内距排在后面 —— 同一属性以组件的 `padding` 为准(消费方
|
|
26
36
|
* 要覆盖就用 `class` 里更具体的规则)。不给 `padding` 时**原样返回消费方的 style**(含 `undefined`)。
|
|
27
37
|
*/
|
|
28
38
|
export declare function mergePartStyle(attrsStyle: unknown, padding: Padding | undefined): StyleValue | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* 同时合并内距与**外边距**(顺序:消费方 `style` → 内距 → 外边距)。
|
|
41
|
+
*
|
|
42
|
+
* 为什么外边距排最后:`margin` 的语义是「我要和外面隔开」,比 `style` 里随手写的更权威;
|
|
43
|
+
* 而 `marginAuto`(自动外边距)走的是类、**优先级低于行内**,故两者同时给时 `margin` 胜出 ——
|
|
44
|
+
* 这是有意的(写死具体值的人比写 auto 的人更清楚要多少)。
|
|
45
|
+
*/
|
|
46
|
+
export declare function mergePartBoxStyle(attrsStyle: unknown, padding: Padding | undefined, margin: Padding | undefined): StyleValue | undefined;
|
|
@@ -19,12 +19,37 @@ function partPaddingStyle(padding) {
|
|
|
19
19
|
}
|
|
20
20
|
return style;
|
|
21
21
|
}
|
|
22
|
+
function partMarginStyle(margin) {
|
|
23
|
+
if (margin === void 0 || margin === "") return void 0;
|
|
24
|
+
if (typeof margin === "number") return { margin: `${margin}px` };
|
|
25
|
+
if (typeof margin === "string") return { margin };
|
|
26
|
+
const style = {};
|
|
27
|
+
const y = margin.y === void 0 ? void 0 : lengthOf(margin.y);
|
|
28
|
+
const x = margin.x === void 0 ? void 0 : lengthOf(margin.x);
|
|
29
|
+
if (y !== void 0) {
|
|
30
|
+
style.marginTop = y;
|
|
31
|
+
style.marginBottom = y;
|
|
32
|
+
}
|
|
33
|
+
if (x !== void 0) {
|
|
34
|
+
style.marginLeft = x;
|
|
35
|
+
style.marginRight = x;
|
|
36
|
+
}
|
|
37
|
+
return style;
|
|
38
|
+
}
|
|
22
39
|
function mergePartStyle(attrsStyle, padding) {
|
|
23
40
|
const paddingStyle = partPaddingStyle(padding);
|
|
24
41
|
if (paddingStyle === void 0) return attrsStyle;
|
|
25
42
|
return [attrsStyle, paddingStyle];
|
|
26
43
|
}
|
|
44
|
+
function mergePartBoxStyle(attrsStyle, padding, margin) {
|
|
45
|
+
const marginStyle = partMarginStyle(margin);
|
|
46
|
+
const withPadding = mergePartStyle(attrsStyle, padding);
|
|
47
|
+
if (marginStyle === void 0) return withPadding;
|
|
48
|
+
return [withPadding, marginStyle];
|
|
49
|
+
}
|
|
27
50
|
export {
|
|
51
|
+
mergePartBoxStyle,
|
|
28
52
|
mergePartStyle,
|
|
53
|
+
partMarginStyle,
|
|
29
54
|
partPaddingStyle
|
|
30
55
|
};
|