@manohub/ui 1.2.1 → 1.2.2
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/checkbox/index.d.ts +3 -0
- package/dist/components/checkbox/index.js +5 -1
- package/dist/components/radio/index.d.ts +4 -0
- package/dist/components/radio/index.js +7 -2
- package/dist/components/switch/index.d.ts +7 -0
- package/dist/components/switch/index.js +5 -1
- package/dist/components/table/index.js +3 -2
- package/package.json +2 -2
|
@@ -22,6 +22,9 @@ export interface CheckboxOption {
|
|
|
22
22
|
* (复用本件)以及 `@aihub/theme` 的「已选择背景取主色」三处同一口径。
|
|
23
23
|
* 要再引入中性面填充请做成 `tone` 的第二档,**不要**把默认改回深色;
|
|
24
24
|
* - 半选(`indeterminate`)是**旁路态**:点击后由消费方自行决定落到 `checked` 还是 `unchecked`。
|
|
25
|
+
* - **根 `label` 拦掉 `click` 冒泡**(与 `Switch` / `Radio` 同口径):行内叶控件常嵌在「整块可点」容器里
|
|
26
|
+
* (可点表格行 / 卡片 / 分组头),不拦就会「勾选的同时把父容器也点了」。只拦冒泡、不 `preventDefault`,
|
|
27
|
+
* 勾选 / `update:modelValue` / 键盘 Space 都不受影响;判据与边界见 `onRootClick` 的注释。
|
|
25
28
|
*
|
|
26
29
|
* 用法见 `docs/demos/checkbox/`(每个维度一份可运行样例;文档页 `docs/components/checkbox.md`)。
|
|
27
30
|
*/
|
|
@@ -54,6 +54,9 @@ const Checkbox = /* @__PURE__ */ defineComponent({
|
|
|
54
54
|
watchEffect(() => {
|
|
55
55
|
if (inputRef.value) inputRef.value.indeterminate = props.indeterminate;
|
|
56
56
|
});
|
|
57
|
+
const onRootClick = (event) => {
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
};
|
|
57
60
|
const handleChange = (event) => {
|
|
58
61
|
const next = event.target.checked;
|
|
59
62
|
emit("update:modelValue", next);
|
|
@@ -68,7 +71,8 @@ const Checkbox = /* @__PURE__ */ defineComponent({
|
|
|
68
71
|
return createVNode("label", {
|
|
69
72
|
"class": ["mh-checkbox", props.size === "md" ? "" : `mh-checkbox--${props.size}`, props.disabled ? "is-disabled" : "", attrs.class].filter(Boolean).join(" "),
|
|
70
73
|
"data-inline-control": "true",
|
|
71
|
-
"style": attrs.style
|
|
74
|
+
"style": attrs.style,
|
|
75
|
+
"onClick": onRootClick
|
|
72
76
|
}, [createVNode("input", mergeProps(inputAttrs.value, {
|
|
73
77
|
"ref": inputRef,
|
|
74
78
|
"class": "mh-checkbox__input",
|
|
@@ -24,6 +24,10 @@ import type { ControlSize } from '../control-size';
|
|
|
24
24
|
* (跳过禁用项)—— 单选语义就是必选其一,与 `Tabs` 的「缺省第一项」同口径;没有可选项(表为空或全禁用)
|
|
25
25
|
* 才是空值。自排插槽(不给 `options`)时组件无从推断有哪些值,缺省值由消费方自定。
|
|
26
26
|
*
|
|
27
|
+
* **两个叶的根 `label` 拦掉 `click` 冒泡**(`Switch` / `Checkbox` 同口径):选项常嵌在可点的表格行 /
|
|
28
|
+
* 卡片里,不拦就会「选中选项的同时把容器也点了」。只拦冒泡、不 `preventDefault`,方向键与上报不受影响;
|
|
29
|
+
* 判据与边界见 `stopClickBubble` 的注释。
|
|
30
|
+
*
|
|
27
31
|
* 状态表达不统一是**有意的**(各自贴着自己的面):`Radio` 走原生 `input:checked + .mh-radio__box`
|
|
28
32
|
* (故 **input 必须紧邻框体之前**),`Radio.Card` 走卡片上的 `data-state`(卡片就是 label,圆点在卡内)。
|
|
29
33
|
*
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineComponent, inject, ref, computed, createVNode, watch, nextTick, provide } from "vue";
|
|
2
2
|
const RADIO_GROUP = /* @__PURE__ */ Symbol("mh-radio-group");
|
|
3
|
+
const stopClickBubble = (event) => {
|
|
4
|
+
event.stopPropagation();
|
|
5
|
+
};
|
|
3
6
|
function useNativeSync(group, inputRef, checked) {
|
|
4
7
|
const sync = () => {
|
|
5
8
|
const el = inputRef.value;
|
|
@@ -68,7 +71,8 @@ const Radio = /* @__PURE__ */ defineComponent({
|
|
|
68
71
|
return () => createVNode("label", {
|
|
69
72
|
"class": ["mh-radio", size.value === "md" ? "" : `mh-radio--${size.value}`, disabled.value ? "is-disabled" : void 0, attrs.class].filter(Boolean).join(" "),
|
|
70
73
|
"data-inline-control": "true",
|
|
71
|
-
"style": attrs.style
|
|
74
|
+
"style": attrs.style,
|
|
75
|
+
"onClick": stopClickBubble
|
|
72
76
|
}, [createVNode("input", {
|
|
73
77
|
"ref": inputRef,
|
|
74
78
|
"class": "mh-radio__input",
|
|
@@ -140,7 +144,8 @@ const RadioCard = /* @__PURE__ */ defineComponent({
|
|
|
140
144
|
"class": ["mh-radio-card", attrs.class].filter(Boolean).join(" "),
|
|
141
145
|
"data-state": checked.value ? "checked" : "unchecked",
|
|
142
146
|
"data-disabled": disabled.value ? "true" : "false",
|
|
143
|
-
"style": attrs.style
|
|
147
|
+
"style": attrs.style,
|
|
148
|
+
"onClick": stopClickBubble
|
|
144
149
|
}, [createVNode("input", {
|
|
145
150
|
"ref": inputRef,
|
|
146
151
|
"class": "mh-radio-card__input",
|
|
@@ -27,6 +27,13 @@ import type { ControlSize } from '../control-size';
|
|
|
27
27
|
* 「启用 启用 (开关)」,同一个词出现两遍)。只有**没有表单行**的场合(表格行内 / 工具栏 / 设置面板)才需要 `label`
|
|
28
28
|
* 自带文字,那种场景要把文字放到开关右侧就给 `labelPosition="right"`。
|
|
29
29
|
*
|
|
30
|
+
* ## 点击不冒泡(**本件的默认行为**)
|
|
31
|
+
* 根 `<label>` 上 `stopPropagation` 掉 `click` 的冒泡:开关是行内小控件,绝大多数场景嵌在「整块可点」的容器里
|
|
32
|
+
* (可点 `Card` / 表格行 / 分组头),不拦就会「切开关的同时把父容器也点了」(典型:顺手打开详情抽屉)。
|
|
33
|
+
* 消费方**不需要**再自己包一层 `<span onClick={stop}>` —— 本件 `inheritAttrs: false`、只认 `class` / `style`,
|
|
34
|
+
* 挂上来的 `onClick` 会被静默丢弃(要拦只能自己多包一层);把它收进件里,消费方就少这一层。
|
|
35
|
+
* 判据与边界见 `onRootClick` 的注释。
|
|
36
|
+
*
|
|
30
37
|
* 用法见 `docs/demos/switch/`(每个维度一份可运行样例;文档页 `docs/components/switch.md`)。
|
|
31
38
|
*/
|
|
32
39
|
export declare const Switch: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
@@ -89,10 +89,14 @@ const Switch = /* @__PURE__ */ defineComponent({
|
|
|
89
89
|
const onInputClick = (event) => {
|
|
90
90
|
if (props.readonly) event.preventDefault();
|
|
91
91
|
};
|
|
92
|
+
const onRootClick = (event) => {
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
};
|
|
92
95
|
return () => createVNode("label", {
|
|
93
96
|
"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(" "),
|
|
94
97
|
"data-inline-control": "true",
|
|
95
|
-
"style": attrs.style
|
|
98
|
+
"style": attrs.style,
|
|
99
|
+
"onClick": onRootClick
|
|
96
100
|
}, [createVNode("input", {
|
|
97
101
|
"class": "mh-switch__input",
|
|
98
102
|
"type": "checkbox",
|
|
@@ -299,8 +299,9 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
299
299
|
"name": "chevron-down",
|
|
300
300
|
"class": "mh-table__expand-icon"
|
|
301
301
|
}, null)])]) : null, hasSelectColumn.value ? (
|
|
302
|
-
/* 勾选列复用 `Checkbox`(不手写原生 input
|
|
303
|
-
|
|
302
|
+
/* 勾选列复用 `Checkbox`(不手写原生 input)。勾选不该顺带触发行点击:`Checkbox` 自己会在
|
|
303
|
+
根 `label` 上拦一次冒泡(钩到的只有控件本身),这里在**单元格**上再拦一次是为了盖住
|
|
304
|
+
**单元格空白区**(点在勾选框旁边的留白上同样不该选中/打开该行)。
|
|
304
305
|
`selectable` 为函数时逐行判定:返回 `false` 的行给禁用态(置灰 + not-allowed)。 */
|
|
305
306
|
createVNode("td", {
|
|
306
307
|
"class": "mh-table__col-check",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manohub/ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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.2.
|
|
38
|
+
"@manohub/icon": "^1.2.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^24.0.0",
|