@varlet/ui 3.4.0 → 3.5.0-alpha.1726249557629
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/es/auto-complete/AutoComplete.mjs +20 -11
- package/es/auto-complete/props.mjs +1 -1
- package/es/checkbox/props.mjs +1 -1
- package/es/checkbox-group/props.mjs +1 -1
- package/es/counter/props.mjs +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/input/props.mjs +1 -1
- package/es/menu-select/MenuSelect.mjs +1 -0
- package/es/menu-select/props.mjs +9 -2
- package/es/radio/props.mjs +1 -1
- package/es/radio-group/props.mjs +1 -1
- package/es/select/props.mjs +1 -1
- package/es/slider/props.mjs +1 -1
- package/es/switch/props.mjs +1 -1
- package/es/tooltip/Tooltip.mjs +5 -1
- package/es/tooltip/props.mjs +1 -0
- package/es/uploader/props.mjs +1 -1
- package/es/utils/components.mjs +30 -9
- package/es/varlet.esm.js +4816 -4786
- package/highlight/web-types.en-US.json +32 -23
- package/highlight/web-types.zh-CN.json +32 -23
- package/lib/varlet.cjs.js +93 -60
- package/package.json +8 -7
- package/types/autoComplete.d.ts +1 -1
- package/types/checkbox.d.ts +1 -1
- package/types/checkboxGroup.d.ts +1 -1
- package/types/counter.d.ts +1 -1
- package/types/input.d.ts +1 -1
- package/types/radio.d.ts +1 -1
- package/types/radioGroup.d.ts +1 -1
- package/types/rate.d.ts +1 -1
- package/types/select.d.ts +1 -1
- package/types/slider.d.ts +1 -1
- package/types/switch.d.ts +1 -1
- package/types/tooltip.d.ts +1 -0
- package/types/uploader.d.ts +1 -1
- package/umd/varlet.js +7 -7
|
@@ -55,7 +55,8 @@ function __render__(_ctx, _cache) {
|
|
|
55
55
|
"popover-class": _ctx.variant === "standard" ? _ctx.n("--standard-menu-margin") : void 0,
|
|
56
56
|
show: _ctx.isShowMenuSelect,
|
|
57
57
|
"onUpdate:show": _cache[1] || (_cache[1] = ($event) => _ctx.isShowMenuSelect = $event),
|
|
58
|
-
"onUpdate:modelValue": _ctx.handleAutoComplete
|
|
58
|
+
"onUpdate:modelValue": _ctx.handleAutoComplete,
|
|
59
|
+
onKeyEscape: _ctx.handleKeyEscape
|
|
59
60
|
}, {
|
|
60
61
|
options: _withCtx(() => [
|
|
61
62
|
_createElementVNode(
|
|
@@ -146,7 +147,7 @@ function __render__(_ctx, _cache) {
|
|
|
146
147
|
]),
|
|
147
148
|
_: 3
|
|
148
149
|
/* FORWARDED */
|
|
149
|
-
}, 8, ["disabled", "class", "popover-class", "show", "onUpdate:modelValue"]),
|
|
150
|
+
}, 8, ["disabled", "class", "popover-class", "show", "onUpdate:modelValue", "onKeyEscape"]),
|
|
150
151
|
_createVNode(_component_var_form_details, {
|
|
151
152
|
"error-message": _ctx.errorMessage,
|
|
152
153
|
"extra-message": _ctx.maxlengthText
|
|
@@ -303,15 +304,22 @@ const __sfc__ = defineComponent({
|
|
|
303
304
|
validateWithTrigger("onChange");
|
|
304
305
|
}
|
|
305
306
|
function handleAutoComplete(newValue) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
307
|
+
return __async(this, null, function* () {
|
|
308
|
+
var _a;
|
|
309
|
+
if (props2.maxlength != null) {
|
|
310
|
+
newValue = newValue.slice(0, toNumber(props2.maxlength));
|
|
311
|
+
}
|
|
312
|
+
if (newValue !== value.value) {
|
|
313
|
+
value.value = newValue;
|
|
314
|
+
call(props2.onChange, newValue);
|
|
315
|
+
validateWithTrigger("onChange");
|
|
316
|
+
}
|
|
317
|
+
yield raf();
|
|
318
|
+
(_a = input.value) == null ? void 0 : _a.focus();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function handleKeyEscape() {
|
|
322
|
+
input.value.focus();
|
|
315
323
|
}
|
|
316
324
|
function getShowMenuSelect(newValue) {
|
|
317
325
|
if (props2.disabled || props2.readonly || (form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value)) {
|
|
@@ -336,6 +344,7 @@ const __sfc__ = defineComponent({
|
|
|
336
344
|
handleClick,
|
|
337
345
|
handleChange,
|
|
338
346
|
handleBlur,
|
|
347
|
+
handleKeyEscape,
|
|
339
348
|
handleAutoComplete,
|
|
340
349
|
reset,
|
|
341
350
|
validate,
|
|
@@ -38,7 +38,7 @@ const props = __spreadValues({
|
|
|
38
38
|
default: () => ["onInput", "onClear", "onChange"]
|
|
39
39
|
},
|
|
40
40
|
getShow: Function,
|
|
41
|
-
rules: Array,
|
|
41
|
+
rules: [Array, Function, Object],
|
|
42
42
|
onFocus: defineListenerProp(),
|
|
43
43
|
onBlur: defineListenerProp(),
|
|
44
44
|
onInput: defineListenerProp(),
|
package/es/checkbox/props.mjs
CHANGED
package/es/counter/props.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const props = {
|
|
|
45
45
|
type: Array,
|
|
46
46
|
default: () => ["onInputChange", "onLazyChange", "onIncrement", "onDecrement"]
|
|
47
47
|
},
|
|
48
|
-
rules: Array,
|
|
48
|
+
rules: [Array, Function, Object],
|
|
49
49
|
onBeforeChange: defineListenerProp(),
|
|
50
50
|
onChange: defineListenerProp(),
|
|
51
51
|
onIncrement: defineListenerProp(),
|
package/es/index.bundle.mjs
CHANGED
|
@@ -268,7 +268,7 @@ import './tooltip/style/index.mjs'
|
|
|
268
268
|
import './uploader/style/index.mjs'
|
|
269
269
|
import './watermark/style/index.mjs'
|
|
270
270
|
|
|
271
|
-
const version = '3.
|
|
271
|
+
const version = '3.5.0-alpha.1726249557629'
|
|
272
272
|
|
|
273
273
|
function install(app) {
|
|
274
274
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -178,7 +178,7 @@ export * from './tooltip/index.mjs'
|
|
|
178
178
|
export * from './uploader/index.mjs'
|
|
179
179
|
export * from './watermark/index.mjs'
|
|
180
180
|
|
|
181
|
-
const version = '3.
|
|
181
|
+
const version = '3.5.0-alpha.1726249557629'
|
|
182
182
|
|
|
183
183
|
function install(app) {
|
|
184
184
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/input/props.mjs
CHANGED
package/es/menu-select/props.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,9 +16,10 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
import { menuProps } from "../menu/index.mjs";
|
|
18
21
|
import { defineListenerProp, pickProps } from "../utils/components.mjs";
|
|
19
|
-
const props = __spreadValues({
|
|
22
|
+
const props = __spreadProps(__spreadValues({
|
|
20
23
|
modelValue: {
|
|
21
24
|
type: [String, Number, Boolean, Array],
|
|
22
25
|
default: void 0
|
|
@@ -64,7 +67,11 @@ const props = __spreadValues({
|
|
|
64
67
|
"onClosed",
|
|
65
68
|
"onClickOutside",
|
|
66
69
|
"onUpdate:show"
|
|
67
|
-
]))
|
|
70
|
+
])), {
|
|
71
|
+
// internal start
|
|
72
|
+
onKeyEscape: defineListenerProp()
|
|
73
|
+
// internal end
|
|
74
|
+
});
|
|
68
75
|
export {
|
|
69
76
|
props
|
|
70
77
|
};
|
package/es/radio/props.mjs
CHANGED
package/es/radio-group/props.mjs
CHANGED
package/es/select/props.mjs
CHANGED
|
@@ -52,7 +52,7 @@ const props = __spreadValues({
|
|
|
52
52
|
type: Array,
|
|
53
53
|
default: () => ["onChange", "onClear", "onClose"]
|
|
54
54
|
},
|
|
55
|
-
rules: Array,
|
|
55
|
+
rules: [Array, Function, Object],
|
|
56
56
|
onFocus: defineListenerProp(),
|
|
57
57
|
onBlur: defineListenerProp(),
|
|
58
58
|
onClose: defineListenerProp(),
|
package/es/slider/props.mjs
CHANGED
package/es/switch/props.mjs
CHANGED
package/es/tooltip/Tooltip.mjs
CHANGED
|
@@ -43,7 +43,11 @@ function __render__(_ctx, _cache) {
|
|
|
43
43
|
_createElementVNode(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
|
-
style: _normalizeStyle({
|
|
46
|
+
style: _normalizeStyle({
|
|
47
|
+
background: _ctx.color,
|
|
48
|
+
color: _ctx.textColor,
|
|
49
|
+
width: _ctx.sameWidth ? _ctx.toSizeUnit(Math.ceil(_ctx.hostSize.width)) : void 0
|
|
50
|
+
}),
|
|
47
51
|
class: _normalizeClass(_ctx.classes(_ctx.n("content-container"), _ctx.n(`--${_ctx.type}`))),
|
|
48
52
|
role: "tooltip"
|
|
49
53
|
},
|
package/es/tooltip/props.mjs
CHANGED
package/es/uploader/props.mjs
CHANGED
package/es/utils/components.mjs
CHANGED
|
@@ -48,7 +48,15 @@ import {
|
|
|
48
48
|
Fragment,
|
|
49
49
|
defineComponent
|
|
50
50
|
} from "vue";
|
|
51
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
createNamespaceFn,
|
|
53
|
+
hasOwn,
|
|
54
|
+
isArray,
|
|
55
|
+
isFunction,
|
|
56
|
+
isPlainObject,
|
|
57
|
+
isString,
|
|
58
|
+
normalizeToArray
|
|
59
|
+
} from "@varlet/shared";
|
|
52
60
|
function pickProps(props, propsKey) {
|
|
53
61
|
return isArray(propsKey) ? propsKey.reduce((pickedProps, key) => {
|
|
54
62
|
pickedProps[key] = props[key];
|
|
@@ -124,17 +132,28 @@ function flatFragment(vNodes) {
|
|
|
124
132
|
});
|
|
125
133
|
return result;
|
|
126
134
|
}
|
|
135
|
+
function isZodRule(rule) {
|
|
136
|
+
return isPlainObject(rule) && isFunction(rule.safeParseAsync);
|
|
137
|
+
}
|
|
138
|
+
function isZodResult(result) {
|
|
139
|
+
return isPlainObject(result) && hasOwn(result, "success");
|
|
140
|
+
}
|
|
127
141
|
function useValidation() {
|
|
128
142
|
const errorMessage = ref("");
|
|
129
|
-
const validate = (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
const validate = (ruleOrRules, value, apis) => __async(this, null, function* () {
|
|
144
|
+
const rules = normalizeToArray(ruleOrRules).filter((rule) => isZodRule(rule) || isFunction(rule));
|
|
145
|
+
const results = yield Promise.all(
|
|
146
|
+
rules.map((rule) => isZodRule(rule) ? rule.safeParseAsync(value) : rule(value, apis))
|
|
147
|
+
);
|
|
134
148
|
resetValidation();
|
|
135
|
-
return !
|
|
136
|
-
if (
|
|
137
|
-
|
|
149
|
+
return !results.some((result) => {
|
|
150
|
+
if (isZodResult(result)) {
|
|
151
|
+
if (result.success === false) {
|
|
152
|
+
errorMessage.value = result.error.issues[0].message;
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
} else if (result !== true) {
|
|
156
|
+
errorMessage.value = String(result);
|
|
138
157
|
return true;
|
|
139
158
|
}
|
|
140
159
|
return false;
|
|
@@ -208,6 +227,8 @@ export {
|
|
|
208
227
|
defineListenerProp,
|
|
209
228
|
flatFragment,
|
|
210
229
|
formatElevation,
|
|
230
|
+
isZodResult,
|
|
231
|
+
isZodRule,
|
|
211
232
|
mount,
|
|
212
233
|
mountInstance,
|
|
213
234
|
pickProps,
|