@opentinyvue/vue-form-item 2.28.0 → 2.29.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/lib/index.js +4 -0
- package/lib/mobile-first.js +18 -4
- package/lib/pc.js +30 -2
- package/package.json +5 -5
- package/src/index.d.ts +4 -0
package/lib/index.js
CHANGED
package/lib/mobile-first.js
CHANGED
|
@@ -73,6 +73,10 @@ var __vue2_script = defineComponent({
|
|
|
73
73
|
default: ""
|
|
74
74
|
},
|
|
75
75
|
label: String,
|
|
76
|
+
labelLine: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: 2
|
|
79
|
+
},
|
|
76
80
|
labelWidth: String,
|
|
77
81
|
manual: Boolean,
|
|
78
82
|
popperOptions: {
|
|
@@ -119,7 +123,9 @@ var render = function render2() {
|
|
|
119
123
|
return _c("div", {
|
|
120
124
|
class: _vm.m("flex min-h-[theme(spacing.12)] sm:min-h-[theme(spacing.7)] mb-0 p-0 sm:mb-4 box-border after:content-[''] after:table after:clear-both before:content-[''] before:table border-b-0.5 border-color-border-separator sm:border-none", _vm.state.validateState === "error" && _vm.state.validateType === "text" ? "mb-0 sm:mb-4" : "", _vm.state.formInline ? "align-sub" : "", _vm.state.labelPosition === "top" ? "block mb-4" : "", _vm.state.validateState === "error" ? "[&_.tiny-range-editor]:border-color-error [&_[data-tag~=tiny-range-editor]]:border-color-error [&_[data-tag=tiny-numeric-main]]:border-color-error [&_input]:border-color-error [&_textarea]:border-color-error [&_input:focus]:border-color-error [&_input:hover]:border-color-error [&_textarea:focus]:border-color-error [&_textarea:hover]:border-color-error" : "", _vm.state.labelPosition === "top" && !_vm.state.hideRequiredAsterisk ? "pl-0" : "", !_vm.slots.label && !_vm.label ? "border-none" : "", _vm.state.isDisplayOnly ? "border-none py-0.5" : ""),
|
|
121
125
|
attrs: {
|
|
122
|
-
"data-tag": "tiny-form-item"
|
|
126
|
+
"data-tag": "tiny-form-item",
|
|
127
|
+
"role": "group",
|
|
128
|
+
"aria-labelledby": _vm.state.labelId
|
|
123
129
|
}
|
|
124
130
|
}, [_c("label-wrap", {
|
|
125
131
|
attrs: {
|
|
@@ -132,10 +138,12 @@ var render = function render2() {
|
|
|
132
138
|
style: _vm.state.labelStyle,
|
|
133
139
|
attrs: {
|
|
134
140
|
"data-tag": "tiny-item-label",
|
|
135
|
-
"
|
|
141
|
+
"id": _vm.state.labelId,
|
|
142
|
+
"for": _vm.state.labelFor,
|
|
143
|
+
"aria-required": _vm.state.isRequired || _vm.required ? "true" : void 0
|
|
136
144
|
}
|
|
137
145
|
}, [_c("span", {
|
|
138
|
-
class: _vm.m("max-h-[theme(spacing.
|
|
146
|
+
class: _vm.m("max-h-[theme(spacing." + _vm.labelLine * 5 + ")] line-clamp-" + _vm.labelLine + " inline-block relative top-px leading-normal", (_vm.state.isRequired || _vm.required) && !_vm.state.hideRequiredAsterisk ? "before:content-['*'] before:text-color-error before:relative before:mr-1" : "", _vm.state.isDisplayOnly ? "pl-0 before:hidden" : "")
|
|
139
147
|
}, [_vm._t("label", function() {
|
|
140
148
|
return [_vm._v(_vm._s(_vm.label + _vm.state.labelSuffix))];
|
|
141
149
|
})], 2), _vm.tipContent ? _c("tiny-tooltip", {
|
|
@@ -173,12 +181,18 @@ var render = function render2() {
|
|
|
173
181
|
}],
|
|
174
182
|
class: ["[&_[aria-label=checkbox-group]]:pl-0.5 sm:[&_[aria-label=checkbox-group]]:pl-0", "[&_>:first-child[data-tag=tiny-checkbox]]:pl-0.5 sm:[&_>:first-child[data-tag=tiny-checkbox]]:pl-0", "[&_[class^=tiny-autocomplete]]:w-full", "[&_[class^=tiny-cascader]]:w-full", _vm.state.isDisplayOnly ? "[&_>*:not([data-tag^=tiny-],[class^=tiny-])]:leading-8 [&_>*:not([data-tag^=tiny-],[class^=tiny-])]:sm:leading-normal" : ""],
|
|
175
183
|
attrs: {
|
|
176
|
-
"data-tag": "tiny-form-item-show"
|
|
184
|
+
"data-tag": "tiny-form-item-show",
|
|
185
|
+
"aria-describedby": _vm.state.validateState === "error" ? _vm.state.errorId : void 0,
|
|
186
|
+
"aria-invalid": _vm.state.validateState === "error" ? "true" : "false"
|
|
177
187
|
}
|
|
178
188
|
}, [_vm._t("default")], 2), _vm.state.validateState === "error" && _vm.showMessage && _vm.state.showMessage ? _vm._t("error", function() {
|
|
179
189
|
return [_c("div", {
|
|
180
190
|
class: _vm.m("sm:absolute left-0 bottom-1 sm:-bottom-4 text-color-error text-xs leading-4 line-clamp-3 sm:line-clamp-1 break-all", typeof _vm.inlineMessage === "boolean" && _vm.inlineMessage || _vm.state.inlineMessage ? "relative top-auto left-auto inline-block" : ""),
|
|
181
191
|
attrs: {
|
|
192
|
+
"id": _vm.state.errorId,
|
|
193
|
+
"role": "alert",
|
|
194
|
+
"aria-live": "assertive",
|
|
195
|
+
"aria-atomic": "true",
|
|
182
196
|
"title": _vm.state.validateMessage
|
|
183
197
|
}
|
|
184
198
|
}, [_vm._v(" " + _vm._s(_vm.state.validateMessage) + " ")])];
|
package/lib/pc.js
CHANGED
|
@@ -167,10 +167,24 @@ var __vue2_script = defineComponent({
|
|
|
167
167
|
if (!item.dynamicProps.includes("size")) {
|
|
168
168
|
item.dynamicProps.push("size");
|
|
169
169
|
}
|
|
170
|
+
var ariaAttrs = {};
|
|
171
|
+
if (state.isRequired || required) {
|
|
172
|
+
ariaAttrs["aria-required"] = "true";
|
|
173
|
+
}
|
|
174
|
+
if (isShowError && state.errorId) {
|
|
175
|
+
ariaAttrs["aria-describedby"] = state.errorId;
|
|
176
|
+
ariaAttrs["aria-invalid"] = "true";
|
|
177
|
+
} else {
|
|
178
|
+
ariaAttrs["aria-invalid"] = "false";
|
|
179
|
+
}
|
|
170
180
|
Object.assign(item.props, {
|
|
171
181
|
size: state.formItemSize,
|
|
172
182
|
mini: state.formItemSize === "mini" || Boolean(item.props.mini)
|
|
173
183
|
});
|
|
184
|
+
if (!item.attrs) {
|
|
185
|
+
item.attrs = {};
|
|
186
|
+
}
|
|
187
|
+
Object.assign(item.attrs, ariaAttrs);
|
|
174
188
|
if (type && type.name && type.name.toLowerCase().endsWith("button")) {
|
|
175
189
|
return item;
|
|
176
190
|
}
|
|
@@ -231,10 +245,21 @@ var __vue2_script = defineComponent({
|
|
|
231
245
|
var ErrorContent = isShowError && state.getValidateType === "text" ? errorSlot || h("div", {
|
|
232
246
|
class: (_class = {}, _class[classPrefix + "form-item__error"] = true, _class[classPrefix + "form-item__error--inline"] = isErrorInline, _class[classPrefix + "form-item__error--block"] = isErrorBlock, _class),
|
|
233
247
|
attrs: {
|
|
248
|
+
id: state.errorId,
|
|
249
|
+
// 为错误信息添加唯一 ID,用于 aria-describedby 关联
|
|
250
|
+
role: "alert",
|
|
251
|
+
// 使用 alert 角色,屏幕阅读器会立即读出错误
|
|
252
|
+
"aria-live": "assertive",
|
|
253
|
+
// 确保错误信息能被立即通知
|
|
254
|
+
"aria-atomic": "true",
|
|
255
|
+
// 确保完整读出错误信息
|
|
234
256
|
title: [state.validateMessage]
|
|
235
257
|
}
|
|
236
258
|
}, [validateIcon ? h(validateIcon, {
|
|
237
|
-
class: "validate-icon"
|
|
259
|
+
class: "validate-icon",
|
|
260
|
+
attrs: {
|
|
261
|
+
"aria-hidden": "true"
|
|
262
|
+
}
|
|
238
263
|
}) : null, h("span", {
|
|
239
264
|
"class": classPrefix + "form-item__validate-message"
|
|
240
265
|
}, [state.validateMessage])]) : null;
|
|
@@ -280,7 +305,10 @@ var __vue2_script = defineComponent({
|
|
|
280
305
|
tooltipContent = [errorSlot];
|
|
281
306
|
} else {
|
|
282
307
|
tooltipContent = [validateIconNode, h2("span", {
|
|
283
|
-
"class": classPrefix + "form-item__validate-message"
|
|
308
|
+
"class": classPrefix + "form-item__validate-message",
|
|
309
|
+
"attrs": {
|
|
310
|
+
"id": state.errorId
|
|
311
|
+
}
|
|
284
312
|
}, [state.validateMessage])];
|
|
285
313
|
}
|
|
286
314
|
return tooltipContent;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentinyvue/vue-form-item",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.29.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"module": "./lib/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@opentinyvue/vue-common": "~2.
|
|
12
|
-
"@opentinyvue/vue-icon": "~2.
|
|
13
|
-
"@opentinyvue/vue-renderless": "~3.
|
|
14
|
-
"@opentinyvue/vue-tooltip": "~2.
|
|
11
|
+
"@opentinyvue/vue-common": "~2.29.0",
|
|
12
|
+
"@opentinyvue/vue-icon": "~2.29.0",
|
|
13
|
+
"@opentinyvue/vue-renderless": "~3.29.0",
|
|
14
|
+
"@opentinyvue/vue-tooltip": "~2.29.0"
|
|
15
15
|
},
|
|
16
16
|
"types": "index.d.ts",
|
|
17
17
|
"scripts": {
|
package/src/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare const formItemProps: {
|
|
|
25
25
|
};
|
|
26
26
|
messageType: StringConstructor;
|
|
27
27
|
label: StringConstructor;
|
|
28
|
+
labelLine: {
|
|
29
|
+
type: NumberConstructor;
|
|
30
|
+
default: number;
|
|
31
|
+
};
|
|
28
32
|
labelWidth: StringConstructor;
|
|
29
33
|
manual: BooleanConstructor;
|
|
30
34
|
popperOptions: {
|