@manohub/ui 0.6.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 +141 -0
- package/dist/components/avatar/index.d.ts +283 -0
- package/dist/components/avatar/index.js +167 -0
- package/dist/components/badge/index.d.ts +132 -0
- package/dist/components/badge/index.js +99 -0
- package/dist/components/button/index.d.ts +578 -0
- package/dist/components/button/index.js +191 -0
- package/dist/components/capsule/index.d.ts +161 -0
- package/dist/components/capsule/index.js +101 -0
- package/dist/components/card/index.d.ts +456 -0
- package/dist/components/card/index.js +231 -0
- package/dist/components/checkbox/index.d.ts +331 -0
- package/dist/components/checkbox/index.js +165 -0
- package/dist/components/code/index.d.ts +134 -0
- package/dist/components/code/index.js +117 -0
- package/dist/components/code-editor/index.d.ts +163 -0
- package/dist/components/code-editor/index.js +98 -0
- package/dist/components/collapse/index.d.ts +125 -0
- package/dist/components/collapse/index.js +95 -0
- package/dist/components/control-size.d.ts +8 -0
- package/dist/components/dialog/index.d.ts +224 -0
- package/dist/components/dialog/index.js +194 -0
- package/dist/components/divider/index.d.ts +64 -0
- package/dist/components/divider/index.js +62 -0
- package/dist/components/drawer/index.d.ts +226 -0
- package/dist/components/drawer/index.js +190 -0
- package/dist/components/filter/index.d.ts +391 -0
- package/dist/components/filter/index.js +203 -0
- package/dist/components/form/index.d.ts +704 -0
- package/dist/components/form/index.js +329 -0
- package/dist/components/input/index.d.ts +980 -0
- package/dist/components/input/index.js +334 -0
- package/dist/components/layout/index.d.ts +162 -0
- package/dist/components/layout/index.js +100 -0
- package/dist/components/list-view/index.d.ts +563 -0
- package/dist/components/list-view/index.js +221 -0
- package/dist/components/loading/index.d.ts +77 -0
- package/dist/components/loading/index.js +40 -0
- package/dist/components/nav/index.d.ts +293 -0
- package/dist/components/nav/index.js +164 -0
- package/dist/components/notice/index.d.ts +137 -0
- package/dist/components/notice/index.js +101 -0
- package/dist/components/notification/index.d.ts +118 -0
- package/dist/components/notification/index.js +99 -0
- package/dist/components/page/index.d.ts +276 -0
- package/dist/components/page/index.js +351 -0
- package/dist/components/page/split-resize.d.ts +42 -0
- package/dist/components/page/split-resize.js +36 -0
- package/dist/components/pagination/index.d.ts +171 -0
- package/dist/components/pagination/index.js +226 -0
- package/dist/components/panel/index.d.ts +401 -0
- package/dist/components/panel/index.js +193 -0
- package/dist/components/part-padding.d.ts +27 -0
- package/dist/components/part-padding.js +23 -0
- package/dist/components/query-state/index.d.ts +207 -0
- package/dist/components/query-state/index.js +181 -0
- package/dist/components/radio/index.d.ts +473 -0
- package/dist/components/radio/index.js +250 -0
- package/dist/components/search/index.d.ts +167 -0
- package/dist/components/search/index.js +105 -0
- package/dist/components/select/index.d.ts +252 -0
- package/dist/components/select/index.js +281 -0
- package/dist/components/skeleton/index.d.ts +88 -0
- package/dist/components/skeleton/index.js +56 -0
- package/dist/components/steps/index.d.ts +199 -0
- package/dist/components/steps/index.js +117 -0
- package/dist/components/switch/index.d.ts +150 -0
- package/dist/components/switch/index.js +103 -0
- package/dist/components/table/index.d.ts +351 -0
- package/dist/components/table/index.js +286 -0
- package/dist/components/tabs/index.d.ts +179 -0
- package/dist/components/tabs/index.js +153 -0
- package/dist/components/tabset/index.d.ts +105 -0
- package/dist/components/tabset/index.js +68 -0
- package/dist/components/tag/index.d.ts +203 -0
- package/dist/components/tag/index.js +144 -0
- package/dist/components/toast/index.d.ts +271 -0
- package/dist/components/toast/index.js +116 -0
- package/dist/components/tooltip/index.d.ts +126 -0
- package/dist/components/tooltip/index.js +97 -0
- package/dist/components/tree/index.d.ts +317 -0
- package/dist/components/tree/index.js +251 -0
- package/dist/components/upload/index.d.ts +384 -0
- package/dist/components/upload/index.js +172 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +102 -0
- package/dist/services/base.d.ts +21 -0
- package/dist/services/base.js +42 -0
- package/dist/services/dialog.d.ts +41 -0
- package/dist/services/dialog.js +83 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/loading.d.ts +21 -0
- package/dist/services/loading.js +41 -0
- package/dist/services/toast.d.ts +40 -0
- package/dist/services/toast.js +74 -0
- package/dist/styles/components/avatar.css +128 -0
- package/dist/styles/components/avatar.tokens.css +24 -0
- package/dist/styles/components/badge.css +237 -0
- package/dist/styles/components/button.css +454 -0
- package/dist/styles/components/button.tokens.css +56 -0
- package/dist/styles/components/capsule.css +120 -0
- package/dist/styles/components/capsule.tokens.css +27 -0
- package/dist/styles/components/card.css +192 -0
- package/dist/styles/components/checkbox.css +145 -0
- package/dist/styles/components/checkbox.tokens.css +26 -0
- package/dist/styles/components/code-editor.css +91 -0
- package/dist/styles/components/code-editor.tokens.css +24 -0
- package/dist/styles/components/code.css +153 -0
- package/dist/styles/components/code.tokens.css +29 -0
- package/dist/styles/components/collapse.css +62 -0
- package/dist/styles/components/collapse.tokens.css +20 -0
- package/dist/styles/components/dialog.css +106 -0
- package/dist/styles/components/dialog.tokens.css +24 -0
- package/dist/styles/components/divider.css +71 -0
- package/dist/styles/components/divider.tokens.css +21 -0
- package/dist/styles/components/drawer.css +143 -0
- package/dist/styles/components/drawer.tokens.css +22 -0
- package/dist/styles/components/filter.css +41 -0
- package/dist/styles/components/filter.tokens.css +14 -0
- package/dist/styles/components/form.css +220 -0
- package/dist/styles/components/form.tokens.css +15 -0
- package/dist/styles/components/input.css +445 -0
- package/dist/styles/components/input.tokens.css +41 -0
- package/dist/styles/components/layout.css +198 -0
- package/dist/styles/components/list-view.css +244 -0
- package/dist/styles/components/loading.css +76 -0
- package/dist/styles/components/loading.tokens.css +23 -0
- package/dist/styles/components/nav.css +48 -0
- package/dist/styles/components/notice.css +153 -0
- package/dist/styles/components/notice.tokens.css +17 -0
- package/dist/styles/components/notification.css +159 -0
- package/dist/styles/components/notification.tokens.css +37 -0
- package/dist/styles/components/page.css +473 -0
- package/dist/styles/components/pagination.css +297 -0
- package/dist/styles/components/pagination.tokens.css +32 -0
- package/dist/styles/components/panel.css +77 -0
- package/dist/styles/components/query-state.css +88 -0
- package/dist/styles/components/radio.css +271 -0
- package/dist/styles/components/radio.tokens.css +26 -0
- package/dist/styles/components/search.css +30 -0
- package/dist/styles/components/select.css +242 -0
- package/dist/styles/components/select.tokens.css +33 -0
- package/dist/styles/components/skeleton.css +60 -0
- package/dist/styles/components/skeleton.tokens.css +27 -0
- package/dist/styles/components/steps.css +157 -0
- package/dist/styles/components/steps.tokens.css +42 -0
- package/dist/styles/components/switch.css +165 -0
- package/dist/styles/components/switch.tokens.css +26 -0
- package/dist/styles/components/table.css +439 -0
- package/dist/styles/components/table.tokens.css +41 -0
- package/dist/styles/components/tabs.css +234 -0
- package/dist/styles/components/tabs.tokens.css +30 -0
- package/dist/styles/components/tag.css +200 -0
- package/dist/styles/components/tag.tokens.css +30 -0
- package/dist/styles/components/toast.css +150 -0
- package/dist/styles/components/toast.tokens.css +26 -0
- package/dist/styles/components/tooltip.css +89 -0
- package/dist/styles/components/tooltip.tokens.css +25 -0
- package/dist/styles/components/tree.css +139 -0
- package/dist/styles/components/tree.tokens.css +20 -0
- package/dist/styles/components/upload.css +150 -0
- package/dist/styles/components/upload.tokens.css +27 -0
- package/dist/styles/index.css +149 -0
- package/dist/styles/operations/collapse.css +84 -0
- package/dist/styles/operations/popup.css +189 -0
- package/dist/styles/operations/tabset.css +57 -0
- package/dist/utils/state-illustration.d.ts +31 -0
- package/dist/utils/state-illustration.js +156 -0
- package/package.json +62 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, createVNode, mergeProps, createTextVNode } from "vue";
|
|
2
|
+
import { Icon } from "@manohub/icon";
|
|
3
|
+
const Input = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "Input",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
/** 受控值 */
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: void 0
|
|
11
|
+
},
|
|
12
|
+
/** 非受控初始值 */
|
|
13
|
+
defaultValue: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: ""
|
|
16
|
+
},
|
|
17
|
+
placeholder: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: void 0
|
|
20
|
+
},
|
|
21
|
+
/** 原生 input 类型(`password` 时自动出现可见性切换) */
|
|
22
|
+
type: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: "text"
|
|
25
|
+
},
|
|
26
|
+
/** 尺寸档(与全库 `ControlSize` 同表:24 / 28 / 32) */
|
|
27
|
+
size: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "md"
|
|
30
|
+
},
|
|
31
|
+
disabled: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
readonly: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
},
|
|
39
|
+
/** 校验态(下发 `aria-invalid`,样式走协议不看 data-*);等价于 `status="error"` */
|
|
40
|
+
invalid: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
/** 校验状态(`invalid` 的显式写法;两者同时给以 `status` 为准) */
|
|
45
|
+
status: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: void 0
|
|
48
|
+
},
|
|
49
|
+
/** 有内容时显示清除按钮 */
|
|
50
|
+
clearable: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
/** 是否带边框;`false` 用于表格内编辑 / 行内编辑(无框、无底) */
|
|
55
|
+
bordered: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
},
|
|
59
|
+
maxlength: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
/** 右侧字数统计(单行须给 `maxlength` 才有意义) */
|
|
64
|
+
showCount: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
},
|
|
68
|
+
/** 自动聚焦(进页面即可输入,如搜索框) */
|
|
69
|
+
autofocus: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
},
|
|
73
|
+
/** 值变更回调(每次输入都调) */
|
|
74
|
+
onChange: {
|
|
75
|
+
type: Function,
|
|
76
|
+
default: void 0
|
|
77
|
+
},
|
|
78
|
+
/** 回车回调 */
|
|
79
|
+
onEnter: {
|
|
80
|
+
type: Function,
|
|
81
|
+
default: void 0
|
|
82
|
+
},
|
|
83
|
+
/* ===== 触发器形态(`as="button"`,给复合件用的口子) =====
|
|
84
|
+
* 整件的**表壳、附加位与状态规则一并复用**,只把「控件元素」从 `<input>` 换成 `<button>`:
|
|
85
|
+
* 于是 `Select` 这类件能拿到输入框的框与内距、内建清除位、右侧图标位与三态反馈,同时保留
|
|
86
|
+
* 原生 `<button>` 才有的语义(如 `popovertarget` 触发 popover —— 该属性只认 button)。
|
|
87
|
+
* 缺省 `as="input"` 的渲染路径除本组 prop 外零变化。 */
|
|
88
|
+
/** 控件元素形态:`input` 文本输入(缺省)/ `button` 触发器 */
|
|
89
|
+
as: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: "input"
|
|
92
|
+
},
|
|
93
|
+
/** 追加到**控件元素**上的类(复合件挂自己的排版类用;本件的 `class` 仍落表壳) */
|
|
94
|
+
controlClass: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: void 0
|
|
97
|
+
},
|
|
98
|
+
/** 展开到**控件元素**上的属性(触发器形态要 `popovertarget` / `aria-*` / `onKeydown` 落到控件上) */
|
|
99
|
+
controlAttrs: {
|
|
100
|
+
type: Object,
|
|
101
|
+
default: void 0
|
|
102
|
+
},
|
|
103
|
+
/** 显式覆盖清除位显隐;不给时仍按「有内容」判定(多选类复合件没有单值可判) */
|
|
104
|
+
hasValue: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: void 0
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
emits: {
|
|
110
|
+
"update:modelValue": (v) => true
|
|
111
|
+
},
|
|
112
|
+
slots: Object,
|
|
113
|
+
setup(props, {
|
|
114
|
+
emit,
|
|
115
|
+
slots,
|
|
116
|
+
attrs
|
|
117
|
+
}) {
|
|
118
|
+
const inner = ref(props.defaultValue);
|
|
119
|
+
const current = computed(() => props.modelValue ?? inner.value);
|
|
120
|
+
const revealed = ref(false);
|
|
121
|
+
const visualStatus = computed(() => props.status ?? (props.invalid ? "error" : void 0));
|
|
122
|
+
const isInvalid = computed(() => visualStatus.value === "error");
|
|
123
|
+
const commit = (value) => {
|
|
124
|
+
if (props.modelValue === void 0) inner.value = value;
|
|
125
|
+
emit("update:modelValue", value);
|
|
126
|
+
props.onChange?.(value);
|
|
127
|
+
};
|
|
128
|
+
const onInput = (event) => {
|
|
129
|
+
const el = event.target;
|
|
130
|
+
commit(el.value);
|
|
131
|
+
if (props.modelValue !== void 0 && props.modelValue !== el.value) el.value = props.modelValue;
|
|
132
|
+
};
|
|
133
|
+
const onKeydown = (event) => {
|
|
134
|
+
if (event.key === "Enter") props.onEnter?.(current.value ?? "");
|
|
135
|
+
if (event.key === "Delete" && props.clearable) commit("");
|
|
136
|
+
};
|
|
137
|
+
const inputType = computed(() => props.type === "password" && revealed.value ? "text" : props.type);
|
|
138
|
+
const isTrigger = computed(() => props.as === "button");
|
|
139
|
+
const controlClasses = computed(() => ["mh-input", isTrigger.value ? "mh-input--trigger" : "", props.size === "md" ? "" : `mh-input--${props.size}`, props.bordered ? "" : "mh-input--borderless", visualStatus.value ? `is-${visualStatus.value}` : "", props.disabled ? "is-disabled" : "", props.controlClass].filter(Boolean).join(" "));
|
|
140
|
+
const showClear = computed(() => props.clearable && (props.hasValue ?? !!current.value));
|
|
141
|
+
return () => createVNode("div", {
|
|
142
|
+
"class": ["mh-input__wrap", attrs.class].filter(Boolean).join(" "),
|
|
143
|
+
"style": attrs.style
|
|
144
|
+
}, [slots.prefix ? createVNode("span", {
|
|
145
|
+
"class": "mh-input__prefix"
|
|
146
|
+
}, [slots.prefix()]) : null, isTrigger.value ? (
|
|
147
|
+
/* 触发器形态:控件是 `<button type="button">` —— 显式 `button` 不能省,缺省是 `submit`,
|
|
148
|
+
放进表单会提交。内容走默认插槽;键盘事件由 `controlAttrs` 交给消费方 ——
|
|
149
|
+
本件的 Enter / Delete 是**输入框**语义,触发器有自己的一套(如 `↓` 开面板),不在此套用。 */
|
|
150
|
+
createVNode("button", mergeProps({
|
|
151
|
+
"type": "button"
|
|
152
|
+
}, props.controlAttrs, {
|
|
153
|
+
"class": controlClasses.value,
|
|
154
|
+
"disabled": props.disabled,
|
|
155
|
+
"aria-invalid": isInvalid.value ? "true" : void 0
|
|
156
|
+
}), [slots.default ? slots.default() : null])
|
|
157
|
+
) : createVNode("input", {
|
|
158
|
+
"class": controlClasses.value,
|
|
159
|
+
"type": inputType.value,
|
|
160
|
+
"value": current.value,
|
|
161
|
+
"placeholder": props.placeholder,
|
|
162
|
+
"disabled": props.disabled,
|
|
163
|
+
"readonly": props.readonly,
|
|
164
|
+
"maxlength": props.maxlength,
|
|
165
|
+
"autofocus": props.autofocus,
|
|
166
|
+
"aria-invalid": isInvalid.value ? "true" : void 0,
|
|
167
|
+
"onInput": onInput,
|
|
168
|
+
"onKeydown": onKeydown
|
|
169
|
+
}, null), showClear.value ? createVNode("button", {
|
|
170
|
+
"type": "button",
|
|
171
|
+
"class": "mh-input__clear",
|
|
172
|
+
"aria-label": "清除",
|
|
173
|
+
"tabindex": -1,
|
|
174
|
+
"onClick": () => commit("")
|
|
175
|
+
}, [createVNode(Icon, {
|
|
176
|
+
"name": "close",
|
|
177
|
+
"size": 10,
|
|
178
|
+
"class": "mh-input__clear-icon"
|
|
179
|
+
}, null)]) : null, !isTrigger.value && props.type === "password" ? createVNode("button", {
|
|
180
|
+
"type": "button",
|
|
181
|
+
"class": ["mh-input__eye", revealed.value ? "is-on" : ""].filter(Boolean).join(" "),
|
|
182
|
+
"aria-label": revealed.value ? "隐藏密码" : "显示密码",
|
|
183
|
+
"aria-pressed": revealed.value ? "true" : "false",
|
|
184
|
+
"tabindex": -1,
|
|
185
|
+
"onClick": () => revealed.value = !revealed.value
|
|
186
|
+
}, [createVNode(Icon, {
|
|
187
|
+
"name": "eye",
|
|
188
|
+
"class": "mh-input__eye-icon"
|
|
189
|
+
}, null)]) : null, slots.suffix ? createVNode("span", {
|
|
190
|
+
"class": "mh-input__suffix"
|
|
191
|
+
}, [slots.suffix()]) : null, !isTrigger.value && props.showCount ? createVNode("span", {
|
|
192
|
+
"class": "mh-input__counter"
|
|
193
|
+
}, [current.value?.length ?? 0, createTextVNode("/"), props.maxlength ?? 0]) : null]);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
const Textarea = /* @__PURE__ */ defineComponent({
|
|
197
|
+
name: "Textarea",
|
|
198
|
+
inheritAttrs: false,
|
|
199
|
+
props: {
|
|
200
|
+
modelValue: {
|
|
201
|
+
type: String,
|
|
202
|
+
default: void 0
|
|
203
|
+
},
|
|
204
|
+
defaultValue: {
|
|
205
|
+
type: String,
|
|
206
|
+
default: ""
|
|
207
|
+
},
|
|
208
|
+
placeholder: {
|
|
209
|
+
type: String,
|
|
210
|
+
default: void 0
|
|
211
|
+
},
|
|
212
|
+
rows: {
|
|
213
|
+
type: Number,
|
|
214
|
+
default: void 0
|
|
215
|
+
},
|
|
216
|
+
autoSize: {
|
|
217
|
+
type: [Boolean, Object],
|
|
218
|
+
default: false
|
|
219
|
+
},
|
|
220
|
+
size: {
|
|
221
|
+
type: String,
|
|
222
|
+
default: "md"
|
|
223
|
+
},
|
|
224
|
+
disabled: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
default: false
|
|
227
|
+
},
|
|
228
|
+
readonly: {
|
|
229
|
+
type: Boolean,
|
|
230
|
+
default: false
|
|
231
|
+
},
|
|
232
|
+
invalid: {
|
|
233
|
+
type: Boolean,
|
|
234
|
+
default: false
|
|
235
|
+
},
|
|
236
|
+
status: {
|
|
237
|
+
type: String,
|
|
238
|
+
default: void 0
|
|
239
|
+
},
|
|
240
|
+
bordered: {
|
|
241
|
+
type: Boolean,
|
|
242
|
+
default: true
|
|
243
|
+
},
|
|
244
|
+
maxlength: {
|
|
245
|
+
type: Number,
|
|
246
|
+
default: void 0
|
|
247
|
+
},
|
|
248
|
+
showCount: {
|
|
249
|
+
type: Boolean,
|
|
250
|
+
default: false
|
|
251
|
+
},
|
|
252
|
+
autofocus: {
|
|
253
|
+
type: Boolean,
|
|
254
|
+
default: false
|
|
255
|
+
},
|
|
256
|
+
onChange: {
|
|
257
|
+
type: Function,
|
|
258
|
+
default: void 0
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
emits: {
|
|
262
|
+
"update:modelValue": (v) => true
|
|
263
|
+
},
|
|
264
|
+
setup(props, {
|
|
265
|
+
emit,
|
|
266
|
+
attrs
|
|
267
|
+
}) {
|
|
268
|
+
const inner = ref(props.defaultValue);
|
|
269
|
+
const current = computed(() => props.modelValue ?? inner.value);
|
|
270
|
+
const visualStatus = computed(() => props.status ?? (props.invalid ? "error" : void 0));
|
|
271
|
+
const isInvalid = computed(() => visualStatus.value === "error");
|
|
272
|
+
const autoRows = computed(() => {
|
|
273
|
+
if (!props.autoSize) return props.rows;
|
|
274
|
+
const option = typeof props.autoSize === "object" ? props.autoSize : {};
|
|
275
|
+
const min = option.minRows ?? 2;
|
|
276
|
+
const max = option.maxRows ?? 6;
|
|
277
|
+
const lines = (current.value ?? "").split("\n").length;
|
|
278
|
+
return Math.min(Math.max(lines, min), max);
|
|
279
|
+
});
|
|
280
|
+
const onInput = (event) => {
|
|
281
|
+
const el = event.target;
|
|
282
|
+
const value = el.value;
|
|
283
|
+
if (props.modelValue === void 0) inner.value = value;
|
|
284
|
+
emit("update:modelValue", value);
|
|
285
|
+
props.onChange?.(value);
|
|
286
|
+
if (props.modelValue !== void 0 && props.modelValue !== value) el.value = props.modelValue;
|
|
287
|
+
};
|
|
288
|
+
return () => createVNode("div", {
|
|
289
|
+
"class": ["mh-input__wrap", attrs.class].filter(Boolean).join(" "),
|
|
290
|
+
"style": attrs.style
|
|
291
|
+
}, [createVNode("textarea", {
|
|
292
|
+
"class": ["mh-input", "mh-input--textarea", props.size === "md" ? "" : `mh-input--${props.size}`, props.bordered ? "" : "mh-input--borderless", visualStatus.value ? `is-${visualStatus.value}` : "", props.disabled ? "is-disabled" : ""].filter(Boolean).join(" "),
|
|
293
|
+
"rows": autoRows.value,
|
|
294
|
+
"value": current.value,
|
|
295
|
+
"placeholder": props.placeholder,
|
|
296
|
+
"disabled": props.disabled,
|
|
297
|
+
"readonly": props.readonly,
|
|
298
|
+
"maxlength": props.maxlength,
|
|
299
|
+
"autofocus": props.autofocus,
|
|
300
|
+
"aria-invalid": isInvalid.value ? "true" : void 0,
|
|
301
|
+
"onInput": onInput
|
|
302
|
+
}, null), props.showCount ? createVNode("span", {
|
|
303
|
+
"class": "mh-input__counter"
|
|
304
|
+
}, [current.value?.length ?? 0, createTextVNode("/"), props.maxlength ?? 0]) : null]);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
const InputDisplay = /* @__PURE__ */ defineComponent({
|
|
308
|
+
name: "InputDisplay",
|
|
309
|
+
inheritAttrs: false,
|
|
310
|
+
props: {
|
|
311
|
+
value: {
|
|
312
|
+
type: String,
|
|
313
|
+
default: ""
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
slots: Object,
|
|
317
|
+
setup(props, {
|
|
318
|
+
slots,
|
|
319
|
+
attrs
|
|
320
|
+
}) {
|
|
321
|
+
return () => createVNode("span", {
|
|
322
|
+
"class": ["mh-input--display", attrs.class].filter(Boolean).join(" "),
|
|
323
|
+
"style": attrs.style
|
|
324
|
+
}, [slots.default ? slots.default() : props.value]);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
Object.assign(Input, {
|
|
328
|
+
Textarea,
|
|
329
|
+
Display: InputDisplay
|
|
330
|
+
});
|
|
331
|
+
export {
|
|
332
|
+
Input,
|
|
333
|
+
Textarea
|
|
334
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 布局间距档:**只开放令牌档位,不开放任意 px**(`none/sm/md/lg/xl` → `0 / --ui-space-1/2/3/4`)。
|
|
4
|
+
*
|
|
5
|
+
* 间距一旦可以随手写,同一个页面里就会出现 6/7/9/10/14 这些「看着差不多」的值,
|
|
6
|
+
* 而它们在不同缩放档、不同人手里会继续分叉 —— 与「应用侧只写布局」是同一条理由的另一面。
|
|
7
|
+
*/
|
|
8
|
+
export type LayoutGap = 'none' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
/** 交叉轴对齐(`align-items`);主轴排布用 `justify` */
|
|
10
|
+
export type LayoutAlign = 'start' | 'center' | 'end' | 'baseline' | 'stretch';
|
|
11
|
+
/** 主轴排布(`justify-content`):`between` = 两端对齐(左文右操作这种) */
|
|
12
|
+
export type LayoutJustify = 'start' | 'center' | 'end' | 'between';
|
|
13
|
+
/** 栅格列数**上限**(传了它才切成等分栅格;实际列数还受最小列宽约束,窄了会自动减列) */
|
|
14
|
+
export type LayoutColumns = 1 | 2 | 3 | 4;
|
|
15
|
+
/** 栅格单元跨格数:不应超过所在行的 `columns`(超了 auto-fit 会为它多开轨道) */
|
|
16
|
+
export type LayoutSpan = 1 | 2 | 3 | 4;
|
|
17
|
+
/**
|
|
18
|
+
* 布局原子件族(命名空间,**本身不是组件**)。
|
|
19
|
+
*
|
|
20
|
+
* | 成员 | 干什么 | 什么时候用 |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `Layout.Row` | **排「行」**:竖排(一条一行往下堆);传 `columns` 则一行分 n 列(列数上限 + 窄了自动减列) | 逐条清单 / 摘要字段 / 并排字段与卡片 |
|
|
23
|
+
* | `Layout.Column` | **排「列」**:水平容器(内容左右排),同时是 `Row columns` 的栅格单元 | 徽标 + 文本 / 标签 + 值 / 控件 + 按钮 / 一行里的一格 |
|
|
24
|
+
*
|
|
25
|
+
* ## 命名与方向口径(别再改回去)
|
|
26
|
+
*
|
|
27
|
+
* - **方向按表格语义定**:行与行上下相邻 ⇒ `Row` 竖排;列与列左右相邻 ⇒ `Column` 横排。
|
|
28
|
+
* - `columns` 说的是「**这一行分几列**」(每行摆几格),不是「这个容器有几种方向」。
|
|
29
|
+
* - 嵌套:要分栏 / 栅格就 `Row columns={n}` + `Column`;一格里要上下堆,就在 `Column` 里再放 `Row`。
|
|
30
|
+
* - **公开面只出 `Layout`**,不平级导出 `Row` / `Column` —— 通用词会与 `TableColumn`
|
|
31
|
+
* 在一份 import 清单里混读,也破坏「成族子件用点号」的约定(`Page.Header` / `Form.Item`)。
|
|
32
|
+
*
|
|
33
|
+
* ## 与其它件的边界
|
|
34
|
+
*
|
|
35
|
+
* - 表单里并排字段用 `Form columns={2}`(它管 label 列与行距),不要用本族拼表单;
|
|
36
|
+
* - 页面级两栏(各自滚动)用 `Page.Split`;
|
|
37
|
+
* - 只有「块与块怎么摆」这一件事归本族,滚动 / 工具位 / 卡片外观都不归它。
|
|
38
|
+
*/
|
|
39
|
+
export declare const Layout: {
|
|
40
|
+
Row: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
41
|
+
/** 行间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
42
|
+
gap: {
|
|
43
|
+
type: PropType<LayoutGap>;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
/** 交叉轴对齐(竖排时是水平方向);不传即 CSS 默认 `stretch`(子项齐宽) */
|
|
47
|
+
align: {
|
|
48
|
+
type: PropType<LayoutAlign>;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
/** 主轴排布(竖排时是纵向);不传即 `start` */
|
|
52
|
+
justify: {
|
|
53
|
+
type: PropType<LayoutJustify>;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
56
|
+
/** 列数;**不传 = 纯竖排**,传了 = 一行分 n 列(等分栅格,列数恒为 n) */
|
|
57
|
+
columns: {
|
|
58
|
+
type: PropType<LayoutColumns>;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
61
|
+
/** **希望**的单元最小宽度(px);缺省取令牌 `--ui-grid-column-min`。容器放不下 n 列时列会等分收窄 */
|
|
62
|
+
minColumnWidth: {
|
|
63
|
+
type: NumberConstructor;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
67
|
+
/** 行间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
68
|
+
gap: {
|
|
69
|
+
type: PropType<LayoutGap>;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
/** 交叉轴对齐(竖排时是水平方向);不传即 CSS 默认 `stretch`(子项齐宽) */
|
|
73
|
+
align: {
|
|
74
|
+
type: PropType<LayoutAlign>;
|
|
75
|
+
default: undefined;
|
|
76
|
+
};
|
|
77
|
+
/** 主轴排布(竖排时是纵向);不传即 `start` */
|
|
78
|
+
justify: {
|
|
79
|
+
type: PropType<LayoutJustify>;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
/** 列数;**不传 = 纯竖排**,传了 = 一行分 n 列(等分栅格,列数恒为 n) */
|
|
83
|
+
columns: {
|
|
84
|
+
type: PropType<LayoutColumns>;
|
|
85
|
+
default: undefined;
|
|
86
|
+
};
|
|
87
|
+
/** **希望**的单元最小宽度(px);缺省取令牌 `--ui-grid-column-min`。容器放不下 n 列时列会等分收窄 */
|
|
88
|
+
minColumnWidth: {
|
|
89
|
+
type: NumberConstructor;
|
|
90
|
+
default: undefined;
|
|
91
|
+
};
|
|
92
|
+
}>> & Readonly<{}>, {
|
|
93
|
+
justify: LayoutJustify;
|
|
94
|
+
gap: LayoutGap;
|
|
95
|
+
align: LayoutAlign;
|
|
96
|
+
columns: LayoutColumns;
|
|
97
|
+
minColumnWidth: number;
|
|
98
|
+
}, SlotsType<{
|
|
99
|
+
default?: () => VNodeChild;
|
|
100
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
101
|
+
Column: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
102
|
+
/** 单元内间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
103
|
+
gap: {
|
|
104
|
+
type: PropType<LayoutGap>;
|
|
105
|
+
default: string;
|
|
106
|
+
};
|
|
107
|
+
/** 单元内交叉轴对齐;不传即 `center`(内容齐中线) */
|
|
108
|
+
align: {
|
|
109
|
+
type: PropType<LayoutAlign>;
|
|
110
|
+
default: undefined;
|
|
111
|
+
};
|
|
112
|
+
/** 单元内主轴排布;不传即 `start` */
|
|
113
|
+
justify: {
|
|
114
|
+
type: PropType<LayoutJustify>;
|
|
115
|
+
default: undefined;
|
|
116
|
+
};
|
|
117
|
+
/** 允许折行:内容宽过容器时下一项换行(窄格子里的「按钮 + 摘要」靠它不撑破外层) */
|
|
118
|
+
wrap: {
|
|
119
|
+
type: BooleanConstructor;
|
|
120
|
+
default: boolean;
|
|
121
|
+
};
|
|
122
|
+
/** 跨格数(默认 1);不要超过所在行的 `columns` */
|
|
123
|
+
span: {
|
|
124
|
+
type: PropType<LayoutSpan>;
|
|
125
|
+
default: number;
|
|
126
|
+
};
|
|
127
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
128
|
+
/** 单元内间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
129
|
+
gap: {
|
|
130
|
+
type: PropType<LayoutGap>;
|
|
131
|
+
default: string;
|
|
132
|
+
};
|
|
133
|
+
/** 单元内交叉轴对齐;不传即 `center`(内容齐中线) */
|
|
134
|
+
align: {
|
|
135
|
+
type: PropType<LayoutAlign>;
|
|
136
|
+
default: undefined;
|
|
137
|
+
};
|
|
138
|
+
/** 单元内主轴排布;不传即 `start` */
|
|
139
|
+
justify: {
|
|
140
|
+
type: PropType<LayoutJustify>;
|
|
141
|
+
default: undefined;
|
|
142
|
+
};
|
|
143
|
+
/** 允许折行:内容宽过容器时下一项换行(窄格子里的「按钮 + 摘要」靠它不撑破外层) */
|
|
144
|
+
wrap: {
|
|
145
|
+
type: BooleanConstructor;
|
|
146
|
+
default: boolean;
|
|
147
|
+
};
|
|
148
|
+
/** 跨格数(默认 1);不要超过所在行的 `columns` */
|
|
149
|
+
span: {
|
|
150
|
+
type: PropType<LayoutSpan>;
|
|
151
|
+
default: number;
|
|
152
|
+
};
|
|
153
|
+
}>> & Readonly<{}>, {
|
|
154
|
+
wrap: boolean;
|
|
155
|
+
justify: LayoutJustify;
|
|
156
|
+
span: LayoutSpan;
|
|
157
|
+
gap: LayoutGap;
|
|
158
|
+
align: LayoutAlign;
|
|
159
|
+
}, SlotsType<{
|
|
160
|
+
default?: () => VNodeChild;
|
|
161
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
162
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineComponent, createVNode } from "vue";
|
|
2
|
+
function modifier(base, name, value) {
|
|
3
|
+
return value === void 0 || value === "" ? "" : `${base}--${name}-${value}`;
|
|
4
|
+
}
|
|
5
|
+
const LayoutColumn = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "LayoutColumn",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: {
|
|
9
|
+
/** 单元内间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
10
|
+
gap: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "md"
|
|
13
|
+
},
|
|
14
|
+
/** 单元内交叉轴对齐;不传即 `center`(内容齐中线) */
|
|
15
|
+
align: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
/** 单元内主轴排布;不传即 `start` */
|
|
20
|
+
justify: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: void 0
|
|
23
|
+
},
|
|
24
|
+
/** 允许折行:内容宽过容器时下一项换行(窄格子里的「按钮 + 摘要」靠它不撑破外层) */
|
|
25
|
+
wrap: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false
|
|
28
|
+
},
|
|
29
|
+
/** 跨格数(默认 1);不要超过所在行的 `columns` */
|
|
30
|
+
span: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 1
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
slots: Object,
|
|
36
|
+
setup(props, {
|
|
37
|
+
slots,
|
|
38
|
+
attrs
|
|
39
|
+
}) {
|
|
40
|
+
return () => createVNode("div", {
|
|
41
|
+
"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}` : "", attrs.class].filter(Boolean).join(" "),
|
|
42
|
+
"style": attrs.style
|
|
43
|
+
}, [slots.default?.()]);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const LayoutRow = /* @__PURE__ */ defineComponent({
|
|
47
|
+
name: "LayoutRow",
|
|
48
|
+
inheritAttrs: false,
|
|
49
|
+
props: {
|
|
50
|
+
/** 行间距档(默认 `md` 8px;要贴紧写 `none`) */
|
|
51
|
+
gap: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: "md"
|
|
54
|
+
},
|
|
55
|
+
/** 交叉轴对齐(竖排时是水平方向);不传即 CSS 默认 `stretch`(子项齐宽) */
|
|
56
|
+
align: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: void 0
|
|
59
|
+
},
|
|
60
|
+
/** 主轴排布(竖排时是纵向);不传即 `start` */
|
|
61
|
+
justify: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: void 0
|
|
64
|
+
},
|
|
65
|
+
/** 列数;**不传 = 纯竖排**,传了 = 一行分 n 列(等分栅格,列数恒为 n) */
|
|
66
|
+
columns: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: void 0
|
|
69
|
+
},
|
|
70
|
+
/** **希望**的单元最小宽度(px);缺省取令牌 `--ui-grid-column-min`。容器放不下 n 列时列会等分收窄 */
|
|
71
|
+
minColumnWidth: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: void 0
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
slots: Object,
|
|
77
|
+
setup(props, {
|
|
78
|
+
slots,
|
|
79
|
+
attrs
|
|
80
|
+
}) {
|
|
81
|
+
return () => {
|
|
82
|
+
const isGrid = props.columns !== void 0;
|
|
83
|
+
const style = {
|
|
84
|
+
...attrs.style ?? {}
|
|
85
|
+
};
|
|
86
|
+
if (props.minColumnWidth) style["--mh-layout-row-min"] = `${props.minColumnWidth}px`;
|
|
87
|
+
return createVNode("div", {
|
|
88
|
+
"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) : "", attrs.class].filter(Boolean).join(" "),
|
|
89
|
+
"style": style
|
|
90
|
+
}, [slots.default?.()]);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const Layout = {
|
|
95
|
+
Row: LayoutRow,
|
|
96
|
+
Column: LayoutColumn
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
Layout
|
|
100
|
+
};
|