@manohub/ui 1.0.10 → 1.1.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 +3 -3
- package/dist/components/button/index.d.ts +74 -20
- package/dist/components/button/index.js +59 -14
- package/dist/components/button/segmented.d.ts +122 -0
- package/dist/components/button/segmented.js +99 -0
- package/dist/components/capsule/index.d.ts +2 -2
- package/dist/components/filter/index.d.ts +3 -3
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/input/index.d.ts +57 -6
- package/dist/components/input/index.js +12 -0
- package/dist/components/input/number-input.d.ts +12 -1
- package/dist/components/input/number-input.js +6 -0
- package/dist/components/list/index.d.ts +19 -0
- package/dist/components/list/list-shared.d.ts +196 -0
- package/dist/components/list/list-shared.js +143 -0
- package/dist/components/list/list.d.ts +221 -0
- package/dist/components/list/list.js +131 -0
- package/dist/components/{tree/index.d.ts → list/tree.d.ts} +33 -33
- package/dist/components/{tree/index.js → list/tree.js} +23 -62
- package/dist/components/list-view/index.d.ts +7 -7
- package/dist/components/notice/index.d.ts +1 -1
- package/dist/components/panel/index.d.ts +39 -84
- package/dist/components/panel/index.js +18 -32
- package/dist/components/radio/index.d.ts +233 -118
- package/dist/components/radio/index.js +146 -150
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.js +6 -3
- package/dist/components/select/select-panel.d.ts +20 -0
- package/dist/components/select/select-panel.js +8 -1
- package/dist/components/select/select-tree-filter.d.ts +9 -9
- package/dist/components/select/select-tree.d.ts +23 -23
- package/dist/components/select/select-tree.js +16 -3
- package/dist/components/select/select-trigger.d.ts +43 -1
- package/dist/components/select/select-trigger.js +22 -5
- package/dist/components/steps/index.d.ts +4 -4
- package/dist/components/table/index.d.ts +4 -4
- package/dist/components/table/index.js +1 -1
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +5 -3
- package/dist/styles/components/button.css +107 -33
- package/dist/styles/components/input.css +8 -10
- package/dist/styles/components/{tree.css → list.css} +24 -24
- package/dist/styles/components/{tree.tokens.css → list.tokens.css} +5 -5
- package/dist/styles/components/pagination.css +3 -3
- package/dist/styles/components/panel.css +2 -9
- package/dist/styles/components/radio.css +21 -20
- package/dist/styles/components/select.css +2 -2
- package/dist/styles/components/select.tokens.css +2 -2
- package/dist/styles/index.css +2 -3
- package/package.json +2 -2
- package/dist/components/nav/index.d.ts +0 -299
- package/dist/components/nav/index.js +0 -174
- package/dist/styles/components/nav.css +0 -48
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, inject, ref, computed, createVNode, watch, nextTick, provide } from "vue";
|
|
2
|
+
const RADIO_GROUP = /* @__PURE__ */ Symbol("mh-radio-group");
|
|
3
|
+
function useNativeSync(group, inputRef, checked) {
|
|
4
|
+
const sync = () => {
|
|
5
|
+
const el = inputRef.value;
|
|
6
|
+
if (el && el.checked !== checked.value) el.checked = checked.value;
|
|
7
|
+
};
|
|
8
|
+
if (group) watch(() => group.revision.value, sync, {
|
|
9
|
+
flush: "post"
|
|
10
|
+
});
|
|
11
|
+
return sync;
|
|
12
|
+
}
|
|
2
13
|
const Radio = /* @__PURE__ */ defineComponent({
|
|
3
14
|
name: "Radio",
|
|
4
15
|
inheritAttrs: false,
|
|
@@ -25,7 +36,7 @@ const Radio = /* @__PURE__ */ defineComponent({
|
|
|
25
36
|
},
|
|
26
37
|
size: {
|
|
27
38
|
type: String,
|
|
28
|
-
default:
|
|
39
|
+
default: void 0
|
|
29
40
|
},
|
|
30
41
|
/** 自动聚焦 */
|
|
31
42
|
autofocus: {
|
|
@@ -42,135 +53,123 @@ const Radio = /* @__PURE__ */ defineComponent({
|
|
|
42
53
|
slots,
|
|
43
54
|
attrs
|
|
44
55
|
}) {
|
|
56
|
+
const group = inject(RADIO_GROUP, null);
|
|
57
|
+
const inputRef = ref(null);
|
|
58
|
+
const checked = computed(() => group ? group.value.value === props.value : props.checked === true);
|
|
59
|
+
const name = computed(() => props.name ?? group?.name.value);
|
|
60
|
+
const size = computed(() => props.size ?? group?.size.value ?? "md");
|
|
61
|
+
const disabled = computed(() => props.disabled || group?.disabled.value === true);
|
|
62
|
+
const syncInput = useNativeSync(group, inputRef, checked);
|
|
63
|
+
const handleChange = () => {
|
|
64
|
+
group?.select(props.value);
|
|
65
|
+
props.onChange?.(props.value);
|
|
66
|
+
void nextTick(syncInput);
|
|
67
|
+
};
|
|
45
68
|
return () => createVNode("label", {
|
|
46
|
-
"class": ["mh-radio",
|
|
69
|
+
"class": ["mh-radio", size.value === "md" ? "" : `mh-radio--${size.value}`, disabled.value ? "is-disabled" : void 0, attrs.class].filter(Boolean).join(" "),
|
|
47
70
|
"data-inline-control": "true",
|
|
48
71
|
"style": attrs.style
|
|
49
72
|
}, [createVNode("input", {
|
|
73
|
+
"ref": inputRef,
|
|
50
74
|
"class": "mh-radio__input",
|
|
51
75
|
"type": "radio",
|
|
52
|
-
"name":
|
|
76
|
+
"name": name.value,
|
|
53
77
|
"value": props.value,
|
|
54
|
-
"checked":
|
|
55
|
-
"disabled":
|
|
78
|
+
"checked": checked.value,
|
|
79
|
+
"disabled": disabled.value,
|
|
56
80
|
"autofocus": props.autofocus,
|
|
57
|
-
"onChange":
|
|
81
|
+
"onChange": handleChange
|
|
58
82
|
}, null), createVNode("span", {
|
|
59
83
|
"class": "mh-radio__box",
|
|
60
|
-
"data-state":
|
|
84
|
+
"data-state": checked.value ? "checked" : "unchecked"
|
|
61
85
|
}, null), createVNode("span", {
|
|
62
86
|
"class": "mh-radio__label"
|
|
63
87
|
}, [slots.default ? slots.default() : props.label])]);
|
|
64
88
|
}
|
|
65
89
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const current = computed(() => props.modelValue ?? inner.value ?? firstSelectable());
|
|
69
|
-
const select = (value) => {
|
|
70
|
-
if (isBlocked(value)) return;
|
|
71
|
-
if (props.modelValue === void 0) inner.value = value;
|
|
72
|
-
report(value);
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
current,
|
|
76
|
-
select
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const RadioGroup = /* @__PURE__ */ defineComponent({
|
|
80
|
-
name: "RadioGroup",
|
|
90
|
+
const RadioCard = /* @__PURE__ */ defineComponent({
|
|
91
|
+
name: "RadioCard",
|
|
81
92
|
inheritAttrs: false,
|
|
82
93
|
props: {
|
|
83
|
-
|
|
84
|
-
type: Array,
|
|
85
|
-
default: void 0
|
|
86
|
-
},
|
|
87
|
-
modelValue: {
|
|
94
|
+
value: {
|
|
88
95
|
type: [String, Number],
|
|
96
|
+
required: true
|
|
97
|
+
},
|
|
98
|
+
label: {
|
|
99
|
+
type: String,
|
|
89
100
|
default: void 0
|
|
90
101
|
},
|
|
91
|
-
|
|
92
|
-
type:
|
|
102
|
+
description: {
|
|
103
|
+
type: String,
|
|
93
104
|
default: void 0
|
|
94
105
|
},
|
|
95
106
|
name: {
|
|
96
107
|
type: String,
|
|
97
108
|
default: void 0
|
|
98
109
|
},
|
|
99
|
-
|
|
110
|
+
checked: {
|
|
100
111
|
type: Boolean,
|
|
101
|
-
default:
|
|
112
|
+
default: void 0
|
|
102
113
|
},
|
|
103
114
|
disabled: {
|
|
104
115
|
type: Boolean,
|
|
105
116
|
default: false
|
|
106
117
|
},
|
|
107
|
-
size: {
|
|
108
|
-
type: String,
|
|
109
|
-
default: "md"
|
|
110
|
-
},
|
|
111
118
|
onChange: {
|
|
112
119
|
type: Function,
|
|
113
120
|
default: void 0
|
|
114
121
|
}
|
|
115
122
|
},
|
|
116
|
-
emits: {
|
|
117
|
-
"update:modelValue": (value) => true
|
|
118
|
-
},
|
|
119
123
|
slots: Object,
|
|
120
124
|
setup(props, {
|
|
121
|
-
emit,
|
|
122
125
|
slots,
|
|
123
126
|
attrs
|
|
124
127
|
}) {
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
|
|
134
|
-
(
|
|
135
|
-
emit("update:modelValue", value);
|
|
136
|
-
props.onChange?.(value);
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
const rootRef = ref(null);
|
|
140
|
-
const syncNative = () => {
|
|
141
|
-
const root = rootRef.value;
|
|
142
|
-
if (!root) return;
|
|
143
|
-
root.querySelectorAll(".mh-radio__input").forEach((el) => {
|
|
144
|
-
const want = String(current.value) === el.value;
|
|
145
|
-
if (el.checked !== want) el.checked = want;
|
|
146
|
-
});
|
|
128
|
+
const group = inject(RADIO_GROUP, null);
|
|
129
|
+
const inputRef = ref(null);
|
|
130
|
+
const checked = computed(() => group ? group.value.value === props.value : props.checked === true);
|
|
131
|
+
const name = computed(() => props.name ?? group?.name.value);
|
|
132
|
+
const disabled = computed(() => props.disabled || group?.disabled.value === true);
|
|
133
|
+
const syncInput = useNativeSync(group, inputRef, checked);
|
|
134
|
+
const handleChange = () => {
|
|
135
|
+
group?.select(props.value);
|
|
136
|
+
props.onChange?.(props.value);
|
|
137
|
+
void nextTick(syncInput);
|
|
147
138
|
};
|
|
148
|
-
return () => createVNode("
|
|
149
|
-
"
|
|
150
|
-
"
|
|
139
|
+
return () => createVNode("label", {
|
|
140
|
+
"class": ["mh-radio-card", attrs.class].filter(Boolean).join(" "),
|
|
141
|
+
"data-state": checked.value ? "checked" : "unchecked",
|
|
142
|
+
"data-disabled": disabled.value ? "true" : "false",
|
|
151
143
|
"style": attrs.style
|
|
152
|
-
}, [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
}, [createVNode("input", {
|
|
145
|
+
"ref": inputRef,
|
|
146
|
+
"class": "mh-radio-card__input",
|
|
147
|
+
"type": "radio",
|
|
148
|
+
"name": name.value,
|
|
149
|
+
"value": String(props.value),
|
|
150
|
+
"checked": checked.value,
|
|
151
|
+
"disabled": disabled.value,
|
|
152
|
+
"onChange": handleChange
|
|
153
|
+
}, null), createVNode("span", {
|
|
154
|
+
"class": "mh-radio-card__radio",
|
|
155
|
+
"aria-hidden": "true"
|
|
156
|
+
}, null), createVNode("span", {
|
|
157
|
+
"class": "mh-radio-card__body"
|
|
158
|
+
}, [createVNode("span", {
|
|
159
|
+
"class": "mh-radio-card__label"
|
|
160
|
+
}, [props.label]), props.description ? createVNode("span", {
|
|
161
|
+
"class": "mh-radio-card__desc"
|
|
162
|
+
}, [props.description]) : null, slots.extra?.()])]);
|
|
168
163
|
}
|
|
169
164
|
});
|
|
170
|
-
const
|
|
171
|
-
name: "
|
|
165
|
+
const RadioGroup = /* @__PURE__ */ defineComponent({
|
|
166
|
+
name: "RadioGroup",
|
|
172
167
|
inheritAttrs: false,
|
|
173
168
|
props: {
|
|
169
|
+
options: {
|
|
170
|
+
type: Array,
|
|
171
|
+
default: void 0
|
|
172
|
+
},
|
|
174
173
|
modelValue: {
|
|
175
174
|
type: [String, Number],
|
|
176
175
|
default: void 0
|
|
@@ -179,20 +178,30 @@ const RadioCard = /* @__PURE__ */ defineComponent({
|
|
|
179
178
|
type: [String, Number],
|
|
180
179
|
default: void 0
|
|
181
180
|
},
|
|
182
|
-
|
|
183
|
-
type:
|
|
184
|
-
default:
|
|
181
|
+
name: {
|
|
182
|
+
type: String,
|
|
183
|
+
default: void 0
|
|
184
|
+
},
|
|
185
|
+
layout: {
|
|
186
|
+
type: String,
|
|
187
|
+
default: "inline"
|
|
185
188
|
},
|
|
186
|
-
/** 每行几个(>1 时走等宽网格;缺省 1 列堆叠) */
|
|
187
189
|
columns: {
|
|
188
190
|
type: Number,
|
|
189
191
|
default: 1
|
|
190
192
|
},
|
|
191
|
-
|
|
193
|
+
vertical: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
default: false
|
|
196
|
+
},
|
|
192
197
|
disabled: {
|
|
193
198
|
type: Boolean,
|
|
194
199
|
default: false
|
|
195
200
|
},
|
|
201
|
+
size: {
|
|
202
|
+
type: String,
|
|
203
|
+
default: "md"
|
|
204
|
+
},
|
|
196
205
|
onChange: {
|
|
197
206
|
type: Function,
|
|
198
207
|
default: void 0
|
|
@@ -201,77 +210,64 @@ const RadioCard = /* @__PURE__ */ defineComponent({
|
|
|
201
210
|
emits: {
|
|
202
211
|
"update:modelValue": (value) => true
|
|
203
212
|
},
|
|
213
|
+
slots: Object,
|
|
204
214
|
setup(props, {
|
|
205
215
|
emit,
|
|
216
|
+
slots,
|
|
206
217
|
attrs
|
|
207
218
|
}) {
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
219
|
+
const fallbackName = `mh-radio-${Math.random().toString(36).slice(2, 10)}`;
|
|
220
|
+
const inner = ref(props.defaultValue);
|
|
221
|
+
const current = computed(() => props.modelValue ?? inner.value ?? props.options?.find((option) => !option.disabled)?.value);
|
|
222
|
+
const revision = ref(0);
|
|
223
|
+
const select = (value) => {
|
|
224
|
+
if (props.disabled || props.options?.find((option) => option.value === value)?.disabled) return;
|
|
225
|
+
if (props.modelValue === void 0) inner.value = value;
|
|
226
|
+
revision.value += 1;
|
|
227
|
+
emit("update:modelValue", value);
|
|
228
|
+
props.onChange?.(value);
|
|
229
|
+
};
|
|
230
|
+
provide(RADIO_GROUP, {
|
|
231
|
+
name: computed(() => props.name ?? fallbackName),
|
|
232
|
+
size: computed(() => props.size),
|
|
233
|
+
disabled: computed(() => props.disabled),
|
|
234
|
+
value: current,
|
|
235
|
+
revision,
|
|
211
236
|
select
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
});
|
|
238
|
+
return () => {
|
|
239
|
+
const isCard = props.layout === "card";
|
|
240
|
+
const isGrid = isCard && props.columns > 1;
|
|
241
|
+
return createVNode("div", {
|
|
242
|
+
"class": ["mh-radio-group", !isCard && props.vertical ? "mh-radio-group--vertical" : void 0, isCard ? "mh-radio-group--card" : void 0, isGrid ? "mh-radio-group--card-grid" : void 0, attrs.class].filter(Boolean).join(" "),
|
|
243
|
+
"style": isGrid ? {
|
|
244
|
+
...attrs.style,
|
|
245
|
+
"--ui-radio-card-columns": String(props.columns)
|
|
246
|
+
} : attrs.style,
|
|
247
|
+
"role": "radiogroup"
|
|
248
|
+
}, [slots.default ? slots.default({
|
|
249
|
+
value: current.value,
|
|
250
|
+
select
|
|
251
|
+
}) : props.options?.map((option) => isCard ? createVNode(RadioCard, {
|
|
252
|
+
"key": String(option.value),
|
|
253
|
+
"value": option.value,
|
|
254
|
+
"label": option.label,
|
|
255
|
+
"description": option.description,
|
|
256
|
+
"disabled": option.disabled
|
|
257
|
+
}, null) : createVNode(Radio, {
|
|
258
|
+
"key": String(option.value),
|
|
259
|
+
"value": option.value,
|
|
260
|
+
"label": option.label,
|
|
261
|
+
"disabled": option.disabled
|
|
262
|
+
}, null))]);
|
|
230
263
|
};
|
|
231
|
-
return () => createVNode("div", {
|
|
232
|
-
"ref": rootRef,
|
|
233
|
-
"class": ["mh-radio-card", props.columns > 1 ? "mh-radio-card--grid" : "", attrs.class].filter(Boolean).join(" "),
|
|
234
|
-
"style": props.columns > 1 ? {
|
|
235
|
-
...attrs.style,
|
|
236
|
-
"--ui-radio-card-columns": String(props.columns)
|
|
237
|
-
} : attrs.style,
|
|
238
|
-
"role": "radiogroup"
|
|
239
|
-
}, [props.items.map((item) => {
|
|
240
|
-
const isDisabled = props.disabled || !!item.disabled;
|
|
241
|
-
const isChecked = current.value === item.value;
|
|
242
|
-
return createVNode("label", {
|
|
243
|
-
"class": "mh-radio-card__item",
|
|
244
|
-
"key": String(item.value),
|
|
245
|
-
"data-state": isChecked ? "checked" : "unchecked",
|
|
246
|
-
"data-disabled": isDisabled ? "true" : "false"
|
|
247
|
-
}, [createVNode("input", {
|
|
248
|
-
"class": "mh-radio-card__input",
|
|
249
|
-
"type": "radio",
|
|
250
|
-
"name": groupName,
|
|
251
|
-
"value": String(item.value),
|
|
252
|
-
"checked": isChecked,
|
|
253
|
-
"disabled": isDisabled,
|
|
254
|
-
"onChange": () => {
|
|
255
|
-
select(item.value);
|
|
256
|
-
void nextTick(syncNative);
|
|
257
|
-
}
|
|
258
|
-
}, null), createVNode("span", {
|
|
259
|
-
"class": "mh-radio-card__radio",
|
|
260
|
-
"aria-hidden": "true"
|
|
261
|
-
}, null), createVNode("span", {
|
|
262
|
-
"class": "mh-radio-card__body"
|
|
263
|
-
}, [createVNode("span", {
|
|
264
|
-
"class": "mh-radio-card__label"
|
|
265
|
-
}, [item.label]), item.description ? createVNode("span", {
|
|
266
|
-
"class": "mh-radio-card__desc"
|
|
267
|
-
}, [item.description]) : null])]);
|
|
268
|
-
})]);
|
|
269
264
|
}
|
|
270
265
|
});
|
|
271
266
|
Object.assign(Radio, {
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
Card: RadioCard,
|
|
268
|
+
Group: RadioGroup
|
|
274
269
|
});
|
|
275
270
|
export {
|
|
276
|
-
Radio
|
|
271
|
+
Radio,
|
|
272
|
+
RadioCard
|
|
277
273
|
};
|
|
@@ -270,13 +270,13 @@ export declare const Select: import("vue").DefineComponent<import("vue").Extract
|
|
|
270
270
|
disabled: boolean;
|
|
271
271
|
onChange: (v: SelectValue) => void;
|
|
272
272
|
loading: boolean;
|
|
273
|
-
bordered: boolean | "focus";
|
|
274
273
|
options: SelectItem[];
|
|
275
274
|
defaultValue: SelectValue | undefined;
|
|
276
275
|
placeholder: string;
|
|
277
276
|
modelValue: SelectValue | undefined;
|
|
278
277
|
status: InputStatus;
|
|
279
278
|
readonly: boolean;
|
|
279
|
+
bordered: boolean | "focus";
|
|
280
280
|
clearable: boolean;
|
|
281
281
|
onSearch: (keyword: string) => void;
|
|
282
282
|
emptyText: string;
|
|
@@ -224,9 +224,9 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
224
224
|
showPanel(panelRef.value);
|
|
225
225
|
};
|
|
226
226
|
const onPanelToggle = (event) => {
|
|
227
|
-
|
|
228
|
-
panelOpen.value =
|
|
229
|
-
activeIndex.value = void 0;
|
|
227
|
+
const opening = event.newState === "open";
|
|
228
|
+
panelOpen.value = opening;
|
|
229
|
+
if (!opening) activeIndex.value = void 0;
|
|
230
230
|
};
|
|
231
231
|
const onTriggerKeydown = createTriggerKeydown({
|
|
232
232
|
clearable: props.clearable,
|
|
@@ -264,6 +264,8 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
264
264
|
"multiple": props.multiple,
|
|
265
265
|
"placeholder": props.placeholder,
|
|
266
266
|
"label": selectedOptions.value[0]?.label,
|
|
267
|
+
"haspopup": "listbox",
|
|
268
|
+
"expanded": panelOpen.value,
|
|
267
269
|
"activeDescendant": activeDescendant.value,
|
|
268
270
|
"onKeydown": onTriggerKeydown,
|
|
269
271
|
"onClear": clear,
|
|
@@ -276,6 +278,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
276
278
|
}, null), createVNode(SelectPanel, {
|
|
277
279
|
"id": panelId,
|
|
278
280
|
"elementRef": panelRef,
|
|
281
|
+
"role": "listbox",
|
|
279
282
|
"searchable": props.searchable,
|
|
280
283
|
"onToggle": onPanelToggle,
|
|
281
284
|
"keyword": keyword.value,
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* 形态里不再各包一层给内距)与**内容槽**(列表体或树体)。「面板里装什么」不在本件 —— 这正是让列表与树共用同一份面板
|
|
7
7
|
* 皮肤的原因。
|
|
8
8
|
*
|
|
9
|
+
* **然而角色必须由形态侧传入**(`role`,2026-10-12):ARIA 里角色的**必需子元素**是硬约束 —— `listbox` 的子元素
|
|
10
|
+
* 只能是 `option` / `group`,往 `listbox` 里装一棵 `tree` 是非法嵌套(AT 会忽略/降级角色,扫描器按
|
|
11
|
+
* `aria-required-children` 报)。本件是两形态共用的壳,写死任一角色都会让另一种形态错位,故 `role` 是 prop:
|
|
12
|
+
* `Select` 传 `listbox`、`SelectTree` 传 `tree`(各传一次,同 `haspopup` 在触发器上的口径)。
|
|
13
|
+
*
|
|
9
14
|
* **限高在面层**:面板根上钉着 `--ui-select-panel-max-height`(`select.css`),超出即内容区滚动、搜索行常驻不滚。内容区
|
|
10
15
|
* 这一层因此是**结构性的**(不是可有可无的包裹):少了它,长列表 / 长树会把面板一路撑高(实测 60 条选项 2212px),搜索行
|
|
11
16
|
* 也会跟着滚走。本件只负责把它渲染出来。
|
|
@@ -26,6 +31,13 @@ export declare const SelectPanel: import("vue").DefineComponent<import("vue").Ex
|
|
|
26
31
|
type: StringConstructor;
|
|
27
32
|
required: true;
|
|
28
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* 面板根的**角色**(由形态侧传,见文件头)。
|
|
36
|
+
*/
|
|
37
|
+
role: {
|
|
38
|
+
type: PropType<"listbox" | "tree">;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
29
41
|
/** 面板元素的 ref,由消费方持有(父层要用它开合与遍历选项) */
|
|
30
42
|
elementRef: {
|
|
31
43
|
type: PropType<ElementRef>;
|
|
@@ -73,6 +85,13 @@ export declare const SelectPanel: import("vue").DefineComponent<import("vue").Ex
|
|
|
73
85
|
type: StringConstructor;
|
|
74
86
|
required: true;
|
|
75
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* 面板根的**角色**(由形态侧传,见文件头)。
|
|
90
|
+
*/
|
|
91
|
+
role: {
|
|
92
|
+
type: PropType<"listbox" | "tree">;
|
|
93
|
+
default: string;
|
|
94
|
+
};
|
|
76
95
|
/** 面板元素的 ref,由消费方持有(父层要用它开合与遍历选项) */
|
|
77
96
|
elementRef: {
|
|
78
97
|
type: PropType<ElementRef>;
|
|
@@ -117,6 +136,7 @@ export declare const SelectPanel: import("vue").DefineComponent<import("vue").Ex
|
|
|
117
136
|
}>> & Readonly<{}>, {
|
|
118
137
|
onKeydown: (event: KeyboardEvent) => void;
|
|
119
138
|
onToggle: (event: Event) => void;
|
|
139
|
+
role: "listbox" | "tree";
|
|
120
140
|
keyword: string;
|
|
121
141
|
elementRef: ElementRef;
|
|
122
142
|
searchable: boolean;
|
|
@@ -8,6 +8,13 @@ const SelectPanel = /* @__PURE__ */ defineComponent({
|
|
|
8
8
|
type: String,
|
|
9
9
|
required: true
|
|
10
10
|
},
|
|
11
|
+
/**
|
|
12
|
+
* 面板根的**角色**(由形态侧传,见文件头)。
|
|
13
|
+
*/
|
|
14
|
+
role: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "listbox"
|
|
17
|
+
},
|
|
11
18
|
/** 面板元素的 ref,由消费方持有(父层要用它开合与遍历选项) */
|
|
12
19
|
elementRef: {
|
|
13
20
|
type: Object,
|
|
@@ -63,7 +70,7 @@ const SelectPanel = /* @__PURE__ */ defineComponent({
|
|
|
63
70
|
"class": "mh-popup mh-select__panel mh-popup--anchored",
|
|
64
71
|
"data-side": "bottom",
|
|
65
72
|
"data-align": "start",
|
|
66
|
-
"role":
|
|
73
|
+
"role": props.role,
|
|
67
74
|
"onKeydown": props.onKeydown,
|
|
68
75
|
"onToggle": props.onToggle
|
|
69
76
|
}), [props.searchable ? createVNode("div", {
|
|
@@ -8,33 +8,33 @@
|
|
|
8
8
|
* 本文件不 import 任何 Vue 运行时代码(只有类型),也不产出类名 ——
|
|
9
9
|
* 它是 `select/` 目录里的叶子模块之一。
|
|
10
10
|
*/
|
|
11
|
-
import type {
|
|
11
|
+
import type { ListNode } from '../list';
|
|
12
12
|
/** 树的三条取值口径(与 `Tree` 的同名 prop 同义,故整包传同一个对象即可) */
|
|
13
13
|
export interface TreeAccessors {
|
|
14
14
|
/** 节点主键:字段名或取值函数 */
|
|
15
|
-
rowKey: string | ((node:
|
|
15
|
+
rowKey: string | ((node: ListNode) => string);
|
|
16
16
|
/** 子节点字段名 */
|
|
17
17
|
childrenKey: string;
|
|
18
18
|
/** 标签字段名 */
|
|
19
19
|
labelKey: string;
|
|
20
20
|
}
|
|
21
21
|
/** 取节点主键(与 `Tree` 内部的 `String()` 口径一致:值一律以字符串参与比较) */
|
|
22
|
-
export declare const treeNodeKey: (node:
|
|
22
|
+
export declare const treeNodeKey: (node: ListNode, rowKey: TreeAccessors["rowKey"]) => string;
|
|
23
23
|
/** 取子节点(字段不是数组一律当没有子节点,与 `Tree` 同款宽容) */
|
|
24
|
-
export declare const treeChildren: (node:
|
|
24
|
+
export declare const treeChildren: (node: ListNode, childrenKey: string) => ListNode[];
|
|
25
25
|
/** 取标签文本 */
|
|
26
|
-
export declare const treeLabel: (node:
|
|
26
|
+
export declare const treeLabel: (node: ListNode, labelKey: string) => string;
|
|
27
27
|
/** 按主键在整棵树里找节点(触发器要显示选中节点的名称;找不到时由消费方回退显示原值) */
|
|
28
|
-
export declare function findTreeNode(nodes:
|
|
28
|
+
export declare function findTreeNode(nodes: ListNode[], key: string, accessors: Pick<TreeAccessors, 'rowKey' | 'childrenKey'>): ListNode | undefined;
|
|
29
29
|
export interface TreeFilterOptions extends TreeAccessors {
|
|
30
30
|
/** 关键词(调用方保证非空;空串走「不过滤」那条路,不进本函数) */
|
|
31
31
|
keyword: string;
|
|
32
32
|
/** 自定义命中判定(缺省:标签**区分大小写**地包含关键词 —— 与 `Select` 的缺省过滤同口径) */
|
|
33
|
-
match?: (node:
|
|
33
|
+
match?: (node: ListNode, keyword: string) => boolean;
|
|
34
34
|
}
|
|
35
35
|
export interface TreeFilterResult {
|
|
36
36
|
/** 过滤后的树(命中项 + 它们的祖先链;被剪掉的分支不在其中) */
|
|
37
|
-
nodes:
|
|
37
|
+
nodes: ListNode[];
|
|
38
38
|
/** 结果里出现的**全部**节点 key(含祖先)—— 消费方用它做「过滤态强制全展」 */
|
|
39
39
|
keys: string[];
|
|
40
40
|
}
|
|
@@ -47,7 +47,7 @@ export interface TreeFilterResult {
|
|
|
47
47
|
*
|
|
48
48
|
* 复杂度 O(N)(每个节点只看一次),只在关键词或数据变化时由 `computed` 触发。
|
|
49
49
|
*/
|
|
50
|
-
export declare function filterTreeNodes(nodes:
|
|
50
|
+
export declare function filterTreeNodes(nodes: ListNode[], options: TreeFilterOptions): TreeFilterResult;
|
|
51
51
|
/** 命中切分的一段:`hit` 为真时由面层给底色(`.mh-select__hit`) */
|
|
52
52
|
export interface HitSegment {
|
|
53
53
|
text: string;
|