@manohub/ui 1.0.8 → 1.0.10
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 +8 -8
- package/dist/components/card/index.d.ts +19 -18
- package/dist/components/card/index.js +4 -4
- package/dist/components/form/index.js +3 -3
- package/dist/components/input/index.d.ts +10 -0
- package/dist/components/input/index.js +16 -2
- package/dist/components/layout/index.js +1 -1
- package/dist/components/list-view/index.d.ts +2 -2
- package/dist/components/list-view/index.js +2 -2
- package/dist/components/notice/index.d.ts +1 -1
- package/dist/components/notification/index.d.ts +1 -1
- package/dist/components/pagination/index.d.ts +15 -1
- package/dist/components/pagination/index.js +23 -2
- package/dist/components/select/index.d.ts +24 -0
- package/dist/components/select/index.js +10 -0
- package/dist/components/select/select-shared.d.ts +6 -0
- package/dist/components/select/select-shared.js +1 -0
- package/dist/components/select/select-tree.d.ts +11 -0
- package/dist/components/select/select-tree.js +7 -0
- package/dist/components/select/select-trigger.d.ts +14 -1
- package/dist/components/select/select-trigger.js +51 -37
- package/dist/components/switch/index.d.ts +28 -3
- package/dist/components/switch/index.js +15 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/toast/index.d.ts +4 -4
- package/dist/styles/components/badge.css +46 -48
- package/dist/styles/components/badge.tokens.css +7 -0
- package/dist/styles/components/button.css +37 -11
- package/dist/styles/components/button.tokens.css +3 -0
- package/dist/styles/components/card.css +19 -22
- package/dist/styles/components/card.tokens.css +23 -0
- package/dist/styles/components/dialog.css +18 -13
- package/dist/styles/components/dialog.tokens.css +5 -1
- package/dist/styles/components/form.css +11 -18
- package/dist/styles/components/form.tokens.css +6 -1
- package/dist/styles/components/input.css +77 -23
- package/dist/styles/components/input.tokens.css +4 -0
- package/dist/styles/components/layout.css +23 -26
- package/dist/styles/components/layout.tokens.css +19 -0
- package/dist/styles/components/list-view.css +23 -26
- package/dist/styles/components/list-view.tokens.css +23 -0
- package/dist/styles/components/pagination.css +6 -4
- package/dist/styles/components/switch.css +7 -0
- package/dist/styles/components/text.css +13 -10
- package/dist/styles/components/text.tokens.css +16 -0
- package/dist/styles/index.css +4 -0
- package/dist/utils/vnode-children.d.ts +10 -0
- package/dist/utils/vnode-children.js +26 -0
- package/package.json +2 -2
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
* 底 / 字 / hover / 聚焦 / 禁用 / 校验色与**清除位**、**右侧图标位**全部归输入面与它的表壳;本件只给选择器
|
|
16
16
|
* 自己的排版(值 / 标签 / 面板内容)。
|
|
17
17
|
*
|
|
18
|
+
* ## 只读档(`readonly`)与禁用档(`disabled`)的分工
|
|
19
|
+
*
|
|
20
|
+
* 只读 = **值不可改,但控件照常**(不置灰、不降透明度、仍可聚焦);禁用 = 控件不可用(灰底 + 不可聚焦)。
|
|
21
|
+
* 两档在行为上都拿掉了三件事,只是**做法**不同:① 不展开面板 —— 禁用靠原生 `disabled` 收不到点击,只读靠
|
|
22
|
+
* **不下发 `popovertarget`**(原生开合属性在就点得开,JS 再拦一层不如不给);② 不给清除位(清除是改值入口,
|
|
23
|
+
* 由输入面按 `readonly` 收掉);③ **不渲染右侧箭头** —— 两档同理:箭头是「点我能展开」的线索,此时是假线索。
|
|
24
|
+
*
|
|
18
25
|
* ## 浮层边界(与「popup 只给零 JS 面」的取舍一致)
|
|
19
26
|
*
|
|
20
27
|
* 面板走**原生 popover**(`<button popovertarget>` + `<div popover>`):开合 / Esc / 点外部关闭 / 顶层渲染 /
|
|
@@ -103,6 +110,14 @@ export declare const Select: import("vue").DefineComponent<import("vue").Extract
|
|
|
103
110
|
type: BooleanConstructor;
|
|
104
111
|
default: boolean;
|
|
105
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* 只读:值不可改、面板不可展开,右侧箭头与清除位都不给;**观感与可编辑档一致**(不置灰、不降透明度、
|
|
115
|
+
* 仍可聚焦 —— 那是 `disabled` 档的效果)。要「值回显」那一眼观感配 `bordered={false}`(同 `Input` 口径)。
|
|
116
|
+
*/
|
|
117
|
+
readonly: {
|
|
118
|
+
type: BooleanConstructor;
|
|
119
|
+
default: boolean;
|
|
120
|
+
};
|
|
106
121
|
/** 尺寸档(24 / 28 / 32) */
|
|
107
122
|
size: {
|
|
108
123
|
type: PropType<ControlSize>;
|
|
@@ -201,6 +216,14 @@ export declare const Select: import("vue").DefineComponent<import("vue").Extract
|
|
|
201
216
|
type: BooleanConstructor;
|
|
202
217
|
default: boolean;
|
|
203
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* 只读:值不可改、面板不可展开,右侧箭头与清除位都不给;**观感与可编辑档一致**(不置灰、不降透明度、
|
|
221
|
+
* 仍可聚焦 —— 那是 `disabled` 档的效果)。要「值回显」那一眼观感配 `bordered={false}`(同 `Input` 口径)。
|
|
222
|
+
*/
|
|
223
|
+
readonly: {
|
|
224
|
+
type: BooleanConstructor;
|
|
225
|
+
default: boolean;
|
|
226
|
+
};
|
|
204
227
|
/** 尺寸档(24 / 28 / 32) */
|
|
205
228
|
size: {
|
|
206
229
|
type: PropType<ControlSize>;
|
|
@@ -253,6 +276,7 @@ export declare const Select: import("vue").DefineComponent<import("vue").Extract
|
|
|
253
276
|
placeholder: string;
|
|
254
277
|
modelValue: SelectValue | undefined;
|
|
255
278
|
status: InputStatus;
|
|
279
|
+
readonly: boolean;
|
|
256
280
|
clearable: boolean;
|
|
257
281
|
onSearch: (keyword: string) => void;
|
|
258
282
|
emptyText: string;
|
|
@@ -64,6 +64,14 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
64
64
|
type: Boolean,
|
|
65
65
|
default: false
|
|
66
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* 只读:值不可改、面板不可展开,右侧箭头与清除位都不给;**观感与可编辑档一致**(不置灰、不降透明度、
|
|
69
|
+
* 仍可聚焦 —— 那是 `disabled` 档的效果)。要「值回显」那一眼观感配 `bordered={false}`(同 `Input` 口径)。
|
|
70
|
+
*/
|
|
71
|
+
readonly: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
67
75
|
/** 尺寸档(24 / 28 / 32) */
|
|
68
76
|
size: {
|
|
69
77
|
type: String,
|
|
@@ -223,6 +231,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
223
231
|
const onTriggerKeydown = createTriggerKeydown({
|
|
224
232
|
clearable: props.clearable,
|
|
225
233
|
disabled: props.disabled,
|
|
234
|
+
readonly: props.readonly,
|
|
226
235
|
clear,
|
|
227
236
|
openPanel,
|
|
228
237
|
isPanelOpen,
|
|
@@ -248,6 +257,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
248
257
|
"size": props.size,
|
|
249
258
|
"status": props.status,
|
|
250
259
|
"disabled": props.disabled,
|
|
260
|
+
"readonly": props.readonly,
|
|
251
261
|
"bordered": props.bordered,
|
|
252
262
|
"clearable": props.clearable,
|
|
253
263
|
"hasValue": hasValue,
|
|
@@ -50,6 +50,12 @@ export interface TriggerKeydownOptions {
|
|
|
50
50
|
/** 有清除位时才接 `Delete` 清值(与输入框的键盘清除同款) */
|
|
51
51
|
clearable: boolean;
|
|
52
52
|
disabled: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 只读档:整条契约都不生效(键位不开面板、`Delete` 也不清值)。
|
|
55
|
+
* 与 `disabled` 的差别在**前提**上:禁用档的 `<button>` 收不到键盘事件、这里只是多一层兜底;
|
|
56
|
+
* 只读档的按钮**仍可聚焦**,管住它的是这一条。
|
|
57
|
+
*/
|
|
58
|
+
readonly?: boolean;
|
|
53
59
|
clear: () => void;
|
|
54
60
|
openPanel: () => void;
|
|
55
61
|
/** 面板当前是否开着(**只服务 `Enter` / `Space` 的接管判定**):开着才把这两个键从触发器的原生行为里抢过来交给高亮项;关着时必须原样放过,否则「关掉后再按回车」不会重开面板。 */
|
|
@@ -8,6 +8,7 @@ const showPanel = (element) => element?.showPopover?.();
|
|
|
8
8
|
const hidePanel = (element) => element?.hidePopover?.();
|
|
9
9
|
function createTriggerKeydown(options) {
|
|
10
10
|
return (event) => {
|
|
11
|
+
if (options.readonly) return;
|
|
11
12
|
if (event.key === "Delete" && options.clearable) options.clear();
|
|
12
13
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
13
14
|
event.preventDefault();
|
|
@@ -105,6 +105,11 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
105
105
|
type: BooleanConstructor;
|
|
106
106
|
default: boolean;
|
|
107
107
|
};
|
|
108
|
+
/** 只读:值不可改、面板不可展开,右侧箭头与清除位都不给(口径与观感同 `Select.readonly`) */
|
|
109
|
+
readonly: {
|
|
110
|
+
type: BooleanConstructor;
|
|
111
|
+
default: boolean;
|
|
112
|
+
};
|
|
108
113
|
/** 加载中(面板里出一行提示,不渲染树) */
|
|
109
114
|
loading: {
|
|
110
115
|
type: BooleanConstructor;
|
|
@@ -229,6 +234,11 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
229
234
|
type: BooleanConstructor;
|
|
230
235
|
default: boolean;
|
|
231
236
|
};
|
|
237
|
+
/** 只读:值不可改、面板不可展开,右侧箭头与清除位都不给(口径与观感同 `Select.readonly`) */
|
|
238
|
+
readonly: {
|
|
239
|
+
type: BooleanConstructor;
|
|
240
|
+
default: boolean;
|
|
241
|
+
};
|
|
232
242
|
/** 加载中(面板里出一行提示,不渲染树) */
|
|
233
243
|
loading: {
|
|
234
244
|
type: BooleanConstructor;
|
|
@@ -293,6 +303,7 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
293
303
|
placeholder: string;
|
|
294
304
|
modelValue: string;
|
|
295
305
|
status: InputStatus;
|
|
306
|
+
readonly: boolean;
|
|
296
307
|
clearable: boolean;
|
|
297
308
|
onSearch: (keyword: string) => void;
|
|
298
309
|
emptyText: string;
|
|
@@ -85,6 +85,11 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
85
85
|
type: Boolean,
|
|
86
86
|
default: false
|
|
87
87
|
},
|
|
88
|
+
/** 只读:值不可改、面板不可展开,右侧箭头与清除位都不给(口径与观感同 `Select.readonly`) */
|
|
89
|
+
readonly: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false
|
|
92
|
+
},
|
|
88
93
|
/** 加载中(面板里出一行提示,不渲染树) */
|
|
89
94
|
loading: {
|
|
90
95
|
type: Boolean,
|
|
@@ -197,6 +202,7 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
197
202
|
const onTriggerKeydown = createTriggerKeydown({
|
|
198
203
|
clearable: props.clearable,
|
|
199
204
|
disabled: props.disabled,
|
|
205
|
+
readonly: props.readonly,
|
|
200
206
|
clear,
|
|
201
207
|
openPanel: () => showPanel(panelRef.value)
|
|
202
208
|
/* 有意不给 `moveActive` / `commitActive`:树不做面板内键盘导航(行不可聚焦、与 `Tree` 自身
|
|
@@ -216,6 +222,7 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
216
222
|
"size": props.size,
|
|
217
223
|
"status": props.status,
|
|
218
224
|
"disabled": props.disabled,
|
|
225
|
+
"readonly": props.readonly,
|
|
219
226
|
"bordered": props.bordered,
|
|
220
227
|
"clearable": props.clearable,
|
|
221
228
|
"hasValue": hasValue.value,
|
|
@@ -21,6 +21,11 @@ export declare const SelectTrigger: import("vue").DefineComponent<import("vue").
|
|
|
21
21
|
type: BooleanConstructor;
|
|
22
22
|
default: boolean;
|
|
23
23
|
};
|
|
24
|
+
/** 只读档(不展开面板、不给箭头;观感与可编辑档一致,见文件头) */
|
|
25
|
+
readonly: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
24
29
|
/** 有无边框(**直接透传给输入面**,三档口径与 `Input` 的同名 prop 完全一致):`true` 常有框 / `false` 无框(任何状态都不显)/ `'focus'` 聚焦(与悬停)才显框。 */
|
|
25
30
|
bordered: {
|
|
26
31
|
type: PropType<boolean | "focus">;
|
|
@@ -73,7 +78,9 @@ export declare const SelectTrigger: import("vue").DefineComponent<import("vue").
|
|
|
73
78
|
type: PropType<() => VNodeChild>;
|
|
74
79
|
default: undefined;
|
|
75
80
|
};
|
|
76
|
-
}>, () => import("vue
|
|
81
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
77
84
|
/** 面板 id(`popovertarget` 的目标,由 `createSelectPanelId()` 产出的全页唯一 id) */
|
|
78
85
|
panelId: {
|
|
79
86
|
type: StringConstructor;
|
|
@@ -93,6 +100,11 @@ export declare const SelectTrigger: import("vue").DefineComponent<import("vue").
|
|
|
93
100
|
type: BooleanConstructor;
|
|
94
101
|
default: boolean;
|
|
95
102
|
};
|
|
103
|
+
/** 只读档(不展开面板、不给箭头;观感与可编辑档一致,见文件头) */
|
|
104
|
+
readonly: {
|
|
105
|
+
type: BooleanConstructor;
|
|
106
|
+
default: boolean;
|
|
107
|
+
};
|
|
96
108
|
/** 有无边框(**直接透传给输入面**,三档口径与 `Input` 的同名 prop 完全一致):`true` 常有框 / `false` 无框(任何状态都不显)/ `'focus'` 聚焦(与悬停)才显框。 */
|
|
97
109
|
bordered: {
|
|
98
110
|
type: PropType<boolean | "focus">;
|
|
@@ -154,6 +166,7 @@ export declare const SelectTrigger: import("vue").DefineComponent<import("vue").
|
|
|
154
166
|
bordered: boolean | "focus";
|
|
155
167
|
placeholder: string;
|
|
156
168
|
status: InputStatus;
|
|
169
|
+
readonly: boolean;
|
|
157
170
|
clearable: boolean;
|
|
158
171
|
hasValue: boolean;
|
|
159
172
|
onClear: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, createVNode } from "vue";
|
|
1
|
+
import { defineComponent, h, createVNode } from "vue";
|
|
2
2
|
import { Icon } from "@manohub/icon";
|
|
3
3
|
import { Input } from "../input/index.js";
|
|
4
4
|
const SelectTrigger = /* @__PURE__ */ defineComponent({
|
|
@@ -24,6 +24,11 @@ const SelectTrigger = /* @__PURE__ */ defineComponent({
|
|
|
24
24
|
type: Boolean,
|
|
25
25
|
default: false
|
|
26
26
|
},
|
|
27
|
+
/** 只读档(不展开面板、不给箭头;观感与可编辑档一致,见文件头) */
|
|
28
|
+
readonly: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
27
32
|
/** 有无边框(**直接透传给输入面**,三档口径与 `Input` 的同名 prop 完全一致):`true` 常有框 / `false` 无框(任何状态都不显)/ `'focus'` 聚焦(与悬停)才显框。 */
|
|
28
33
|
bordered: {
|
|
29
34
|
type: [Boolean, String],
|
|
@@ -79,43 +84,52 @@ const SelectTrigger = /* @__PURE__ */ defineComponent({
|
|
|
79
84
|
},
|
|
80
85
|
setup(props) {
|
|
81
86
|
const controlClass = () => ["mh-select", props.multiple ? "mh-select--multiple" : "", props.size === "md" ? "" : `mh-select--${props.size}`].filter(Boolean).join(" ");
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
"controlClass": controlClass(),
|
|
93
|
-
"controlAttrs": {
|
|
94
|
-
popovertarget: props.panelId,
|
|
95
|
-
"aria-haspopup": "listbox",
|
|
96
|
-
/* 开合态由原生 popover 与 popup.css 的箭头转向承担,本件不维护第二份;恒定 'false' 是既有口径(输入面的触发器
|
|
97
|
-
形态不跟踪 popover 的开关状态)。⚠️ 这与 `aria-activedescendant` **都是焦点留在触发器上的必然结果**:
|
|
98
|
-
真的做完整要连 `aria-expanded` 一起跟踪开合态,那是另一次改动(见 select.md 的注意事项)。 */
|
|
99
|
-
"aria-expanded": "false",
|
|
100
|
-
/* 高亮行引用(列表形态给、树形态不给):值 `undefined` 时 Vue 会整个摘掉这个属性 */
|
|
101
|
-
"aria-activedescendant": props.activeDescendant,
|
|
102
|
-
onKeydown: props.onKeydown
|
|
103
|
-
},
|
|
104
|
-
"onChange": () => props.onClear?.()
|
|
105
|
-
}, {
|
|
106
|
-
default: () => props.renderValue ? props.renderValue() : (
|
|
107
|
-
/* 只画**有值**时的那一行;无值态在上面被输入面的占位取代(`default` 不会被调用) */
|
|
108
|
-
createVNode("span", {
|
|
109
|
-
"class": "mh-select__value"
|
|
110
|
-
}, [props.label])
|
|
111
|
-
),
|
|
112
|
-
/* 箭头沿用输入框的右侧图标位(槽内尺寸收敛见 `select.css` 的 `.mh-select-host` 一节);
|
|
113
|
-
展开转向由 `popup.css` 的 `.mh-popup-caret` 承担(含触发器进表壳后的兄弟档) */
|
|
114
|
-
suffix: () => createVNode(Icon, {
|
|
115
|
-
"name": "chevron-down",
|
|
116
|
-
"class": "mh-select__caret mh-popup-caret"
|
|
117
|
-
}, null)
|
|
87
|
+
const controlAttrs = () => ({
|
|
88
|
+
popovertarget: props.readonly ? void 0 : props.panelId,
|
|
89
|
+
"aria-haspopup": props.readonly ? void 0 : "listbox",
|
|
90
|
+
/* 开合态由原生 popover 与 popup.css 的箭头转向承担,本件不维护第二份;恒定 'false' 是既有口径(输入面的触发器
|
|
91
|
+
形态不跟踪 popover 的开关状态)。⚠️ 这与 `aria-activedescendant` **都是焦点留在触发器上的必然结果**:
|
|
92
|
+
真的做完整要连 `aria-expanded` 一起跟踪开合态,那是另一次改动(见 select.md 的注意事项)。 */
|
|
93
|
+
"aria-expanded": props.readonly ? void 0 : "false",
|
|
94
|
+
/* 高亮行引用(列表形态给、树形态不给):值 `undefined` 时 Vue 会整个摘掉这个属性 */
|
|
95
|
+
"aria-activedescendant": props.activeDescendant,
|
|
96
|
+
onKeydown: props.onKeydown
|
|
118
97
|
});
|
|
98
|
+
const triggerSlots = () => {
|
|
99
|
+
const slots = {
|
|
100
|
+
default: () => props.renderValue ? props.renderValue() : (
|
|
101
|
+
/* 只画**有值**时的那一行;无值态在上面被输入面的占位取代(`default` 不会被调用) */
|
|
102
|
+
createVNode("span", {
|
|
103
|
+
"class": "mh-select__value"
|
|
104
|
+
}, [props.label])
|
|
105
|
+
)
|
|
106
|
+
};
|
|
107
|
+
if (!props.readonly && !props.disabled) {
|
|
108
|
+
slots.suffix = () => createVNode(Icon, {
|
|
109
|
+
"name": "chevron-down",
|
|
110
|
+
"class": "mh-select__caret mh-popup-caret"
|
|
111
|
+
}, null);
|
|
112
|
+
}
|
|
113
|
+
return slots;
|
|
114
|
+
};
|
|
115
|
+
return () => h(Input, {
|
|
116
|
+
as: "button",
|
|
117
|
+
size: props.size,
|
|
118
|
+
status: props.status,
|
|
119
|
+
disabled: props.disabled,
|
|
120
|
+
readonly: props.readonly,
|
|
121
|
+
bordered: props.bordered,
|
|
122
|
+
clearable: props.clearable,
|
|
123
|
+
hasValue: props.hasValue,
|
|
124
|
+
/* 无值态交给输入面:它按 `hasValue === false && placeholder` 渲染 `.mh-input__placeholder`
|
|
125
|
+
并取代 `default` 插槽(本件不再自绘占位 span) */
|
|
126
|
+
placeholder: props.placeholder,
|
|
127
|
+
class: "mh-popup-anchor mh-select-host",
|
|
128
|
+
controlClass: controlClass(),
|
|
129
|
+
controlAttrs: controlAttrs(),
|
|
130
|
+
/* 内建清除位:输入框形态会给 `''`,本件只把它转给消费方(单选写 `''`、多选写 `[]`) */
|
|
131
|
+
onChange: () => props.onClear?.()
|
|
132
|
+
}, triggerSlots());
|
|
119
133
|
}
|
|
120
134
|
});
|
|
121
135
|
export {
|
|
@@ -3,9 +3,17 @@ import type { ControlSize } from '../control-size';
|
|
|
3
3
|
/**
|
|
4
4
|
* 开关(**自绘**,不封装 farris)。
|
|
5
5
|
*
|
|
6
|
-
* 统一词表(与 `Checkbox` / `Radio` 同款):`modelValue` / `onChange` / `disabled` / `size
|
|
7
|
-
* `md` 36×18(表格与列表档)/ `lg` 50×24(表单档)—— 几何全在样式层的 `--ui-switch-*`
|
|
8
|
-
*
|
|
6
|
+
* 统一词表(与 `Checkbox` / `Radio` 同款):`modelValue` / `onChange` / `disabled` / `size`,另有 `readonly` 档。
|
|
7
|
+
* 三档尺寸:`sm` 28×14 / `md` 36×18(表格与列表档)/ `lg` 50×24(表单档)—— 几何全在样式层的 `--ui-switch-*`
|
|
8
|
+
* 令牌里,档位只覆盖令牌;`form` 是 `size="lg"` 的既有写法。
|
|
9
|
+
*
|
|
10
|
+
* ## 只读(`readonly`)与禁用(`disabled`)的分工
|
|
11
|
+
*
|
|
12
|
+
* 只读 = **值不可改,开关照常**(不降透明度、不置灰、仍可聚焦);禁用 = 控件不可用(整行降透明度 + 不可聚焦)。
|
|
13
|
+
* 做法上只读**不置原生 `disabled`**(那会把「灰 + 不可聚焦」一起带上),而是:① `preventDefault` 掉 `click`
|
|
14
|
+
* —— checkbox 的默认动作就是「点一下翻转」,挡住它等于挡掉鼠标与 Space(后者也走 `click`),`modelValue` 因此
|
|
15
|
+
* 不会被改;② 根上加 `is-readonly`(光标不再是手型)+ 隐身 input 上 `aria-readonly`(读屏能读出「只读」)。
|
|
16
|
+
* 与 `Input.readonly` / `Select.readonly` 同一口径:只读是「不可改」,不是「不可用」。
|
|
9
17
|
*
|
|
10
18
|
* 实现要点(与 `Checkbox` 同配方):真实 `<input type="checkbox">` 负责可访问性与键盘(Tab / Space),视觉由轨道 +
|
|
11
19
|
* 滑块自绘;结构固定 `input → label → track > knob`,样式层靠**通用兄弟** `~` 命中轨道(文字可夹在中间);选中态三源
|
|
@@ -39,6 +47,14 @@ export declare const Switch: import("vue").DefineComponent<import("vue").Extract
|
|
|
39
47
|
type: BooleanConstructor;
|
|
40
48
|
default: boolean;
|
|
41
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* 只读:值不可改,但**开关照常**(不降透明度、不置灰、仍可聚焦)—— 与 `disabled` 的分工见文件头。
|
|
52
|
+
* 挡住的是「翻转」这个动作本身:鼠标点击与 Space 都走 checkbox 的原生默认动作,被 `preventDefault` 拦掉。
|
|
53
|
+
*/
|
|
54
|
+
readonly: {
|
|
55
|
+
type: BooleanConstructor;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
42
58
|
/** 尺寸档(28×14 / 36×18 / 50×24) */
|
|
43
59
|
size: {
|
|
44
60
|
type: PropType<ControlSize>;
|
|
@@ -99,6 +115,14 @@ export declare const Switch: import("vue").DefineComponent<import("vue").Extract
|
|
|
99
115
|
type: BooleanConstructor;
|
|
100
116
|
default: boolean;
|
|
101
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* 只读:值不可改,但**开关照常**(不降透明度、不置灰、仍可聚焦)—— 与 `disabled` 的分工见文件头。
|
|
120
|
+
* 挡住的是「翻转」这个动作本身:鼠标点击与 Space 都走 checkbox 的原生默认动作,被 `preventDefault` 拦掉。
|
|
121
|
+
*/
|
|
122
|
+
readonly: {
|
|
123
|
+
type: BooleanConstructor;
|
|
124
|
+
default: boolean;
|
|
125
|
+
};
|
|
102
126
|
/** 尺寸档(28×14 / 36×18 / 50×24) */
|
|
103
127
|
size: {
|
|
104
128
|
type: PropType<ControlSize>;
|
|
@@ -150,6 +174,7 @@ export declare const Switch: import("vue").DefineComponent<import("vue").Extract
|
|
|
150
174
|
loading: boolean;
|
|
151
175
|
autofocus: boolean;
|
|
152
176
|
modelValue: boolean;
|
|
177
|
+
readonly: boolean;
|
|
153
178
|
labelPosition: "left" | "right";
|
|
154
179
|
checkedText: string;
|
|
155
180
|
uncheckedText: string;
|
|
@@ -20,6 +20,14 @@ const Switch = /* @__PURE__ */ defineComponent({
|
|
|
20
20
|
type: Boolean,
|
|
21
21
|
default: false
|
|
22
22
|
},
|
|
23
|
+
/**
|
|
24
|
+
* 只读:值不可改,但**开关照常**(不降透明度、不置灰、仍可聚焦)—— 与 `disabled` 的分工见文件头。
|
|
25
|
+
* 挡住的是「翻转」这个动作本身:鼠标点击与 Space 都走 checkbox 的原生默认动作,被 `preventDefault` 拦掉。
|
|
26
|
+
*/
|
|
27
|
+
readonly: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
23
31
|
/** 尺寸档(28×14 / 36×18 / 50×24) */
|
|
24
32
|
size: {
|
|
25
33
|
type: String,
|
|
@@ -73,12 +81,16 @@ const Switch = /* @__PURE__ */ defineComponent({
|
|
|
73
81
|
const resolvedSize = computed(() => props.form ? "lg" : props.size);
|
|
74
82
|
const hasTrackText = computed(() => !!props.checkedText || !!props.uncheckedText);
|
|
75
83
|
const handleChange = (event) => {
|
|
84
|
+
if (props.readonly) return;
|
|
76
85
|
const next = event.target.checked;
|
|
77
86
|
emit("update:modelValue", next);
|
|
78
87
|
props.onChange?.(next);
|
|
79
88
|
};
|
|
89
|
+
const onInputClick = (event) => {
|
|
90
|
+
if (props.readonly) event.preventDefault();
|
|
91
|
+
};
|
|
80
92
|
return () => createVNode("label", {
|
|
81
|
-
"class": ["mh-switch", resolvedSize.value === "md" ? "" : `mh-switch--${resolvedSize.value}`, props.form ? "mh-switch--form" : "", hasTrackText.value ? "mh-switch--with-text" : "", props.labelPosition === "right" ? "mh-switch--label-right" : "", props.loading ? "is-loading" : "", props.disabled ? "is-disabled" : "", props.modelValue ? "is-checked" : "", attrs.class].filter(Boolean).join(" "),
|
|
93
|
+
"class": ["mh-switch", resolvedSize.value === "md" ? "" : `mh-switch--${resolvedSize.value}`, props.form ? "mh-switch--form" : "", hasTrackText.value ? "mh-switch--with-text" : "", props.labelPosition === "right" ? "mh-switch--label-right" : "", props.loading ? "is-loading" : "", props.disabled ? "is-disabled" : "", props.readonly ? "is-readonly" : "", props.modelValue ? "is-checked" : "", attrs.class].filter(Boolean).join(" "),
|
|
82
94
|
"data-inline-control": "true",
|
|
83
95
|
"style": attrs.style
|
|
84
96
|
}, [createVNode("input", {
|
|
@@ -86,7 +98,9 @@ const Switch = /* @__PURE__ */ defineComponent({
|
|
|
86
98
|
"type": "checkbox",
|
|
87
99
|
"checked": props.modelValue,
|
|
88
100
|
"disabled": props.disabled || props.loading,
|
|
101
|
+
"aria-readonly": props.readonly ? "true" : void 0,
|
|
89
102
|
"autofocus": props.autofocus,
|
|
103
|
+
"onClick": onInputClick,
|
|
90
104
|
"onChange": handleChange
|
|
91
105
|
}, null), slots.default || props.label ? createVNode("span", {
|
|
92
106
|
"class": "mh-switch__label"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, createVNode } from "vue";
|
|
2
2
|
import { TabBar } from "../tabbar/index.js";
|
|
3
|
+
import { flattenChildren } from "../../utils/vnode-children.js";
|
|
3
4
|
const TabPanel = /* @__PURE__ */ defineComponent({
|
|
4
5
|
name: "TabPanel",
|
|
5
6
|
/* 渲染的是插槽内容(片段根),属性无处可继承 —— 壳归 `Tabs`,属性由它在渲染期搬过去 */
|
|
@@ -29,7 +30,6 @@ const TabPanel = /* @__PURE__ */ defineComponent({
|
|
|
29
30
|
return () => slots.default?.() ?? null;
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
|
-
const flattenChildren = (raw) => (Array.isArray(raw) ? raw : raw == null ? [] : [raw]).flatMap((child) => Array.isArray(child) ? child : [child]).filter((child) => child !== null && child !== void 0 && child !== false && child !== true && child !== "");
|
|
33
33
|
const isTabPanel = (child) => !!child && typeof child === "object" && child.type === TabPanel;
|
|
34
34
|
const panelPropsOf = (child) => isTabPanel(child) ? child.props ?? {} : null;
|
|
35
35
|
const Tabs = /* @__PURE__ */ defineComponent({
|
|
@@ -90,7 +90,7 @@ export declare const Toast: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
90
90
|
onClose?: (() => any) | undefined;
|
|
91
91
|
}>, {
|
|
92
92
|
text: string;
|
|
93
|
-
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
93
|
+
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
94
94
|
closable: boolean;
|
|
95
95
|
tone: ToastTone;
|
|
96
96
|
action: string;
|
|
@@ -142,7 +142,7 @@ export declare const ToastCompound: {
|
|
|
142
142
|
close: () => true;
|
|
143
143
|
}, import("vue").PublicProps, {
|
|
144
144
|
text: string;
|
|
145
|
-
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
145
|
+
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
146
146
|
closable: boolean;
|
|
147
147
|
tone: ToastTone;
|
|
148
148
|
action: string;
|
|
@@ -196,7 +196,7 @@ export declare const ToastCompound: {
|
|
|
196
196
|
onClose?: (() => any) | undefined;
|
|
197
197
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, {
|
|
198
198
|
text: string;
|
|
199
|
-
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
199
|
+
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
200
200
|
closable: boolean;
|
|
201
201
|
tone: ToastTone;
|
|
202
202
|
action: string;
|
|
@@ -247,7 +247,7 @@ export declare const ToastCompound: {
|
|
|
247
247
|
close: () => true;
|
|
248
248
|
}, string, {
|
|
249
249
|
text: string;
|
|
250
|
-
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
250
|
+
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
|
|
251
251
|
closable: boolean;
|
|
252
252
|
tone: ToastTone;
|
|
253
253
|
action: string;
|