@v-c/input 1.1.0 → 1.1.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/BaseInput.js +9 -10
- package/dist/input.js +1 -1
- package/dist/utils/commonUtils.js +14 -7
- package/package.json +8 -2
package/dist/BaseInput.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasAddon, hasPrefixSuffix } from "./utils/commonUtils.js";
|
|
2
2
|
import { Fragment, computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
|
|
3
|
-
import { clsx } from "@v-c/util";
|
|
3
|
+
import { clsx, isVueRenderable } from "@v-c/util";
|
|
4
4
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
5
5
|
//#region src/BaseInput.tsx
|
|
6
6
|
function _isSlot(s) {
|
|
@@ -34,7 +34,7 @@ var BaseInput = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }
|
|
|
34
34
|
const clearDisabled = typeof allowClear === "object" && allowClear?.disabled;
|
|
35
35
|
const needClear = !disabled && !readOnly && value && !clearDisabled;
|
|
36
36
|
const clearIconCls = `${prefixCls}-clear-icon`;
|
|
37
|
-
const iconNode = typeof allowClear === "object" && allowClear?.clearIcon ? allowClear.clearIcon : "✖";
|
|
37
|
+
const iconNode = typeof allowClear === "object" && isVueRenderable(allowClear?.clearIcon) ? allowClear.clearIcon : "✖";
|
|
38
38
|
clearIcon = createVNode("button", {
|
|
39
39
|
"type": "button",
|
|
40
40
|
"disabled": clearDisabled || void 0,
|
|
@@ -46,7 +46,7 @@ var BaseInput = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }
|
|
|
46
46
|
"onMousedown": (e) => e.preventDefault(),
|
|
47
47
|
"class": clsx(clearIconCls, classNames?.clear, {
|
|
48
48
|
[`${clearIconCls}-hidden`]: !needClear,
|
|
49
|
-
[`${clearIconCls}-has-suffix`]:
|
|
49
|
+
[`${clearIconCls}-has-suffix`]: isVueRenderable(suffix)
|
|
50
50
|
}),
|
|
51
51
|
"style": styles?.clear
|
|
52
52
|
}, [iconNode]);
|
|
@@ -57,9 +57,9 @@ var BaseInput = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }
|
|
|
57
57
|
[`${affixWrapperPrefixCls}-disabled`]: disabled,
|
|
58
58
|
[`${affixWrapperPrefixCls}-focused`]: focused,
|
|
59
59
|
[`${affixWrapperPrefixCls}-readonly`]: readOnly,
|
|
60
|
-
[`${affixWrapperPrefixCls}-input-with-clear-btn`]: suffix && allowClear && value
|
|
60
|
+
[`${affixWrapperPrefixCls}-input-with-clear-btn`]: isVueRenderable(suffix) && allowClear && value
|
|
61
61
|
}, classNames?.affixWrapper, classNames?.variant);
|
|
62
|
-
const suffixNode = (suffix || allowClear) && createVNode("span", {
|
|
62
|
+
const suffixNode = (isVueRenderable(suffix) || allowClear) && createVNode("span", {
|
|
63
63
|
"class": clsx(`${prefixCls}-suffix`, classNames?.suffix),
|
|
64
64
|
"style": styles?.suffix
|
|
65
65
|
}, [clearIcon, suffix]);
|
|
@@ -71,7 +71,7 @@ var BaseInput = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }
|
|
|
71
71
|
"style": styles?.affixWrapper,
|
|
72
72
|
"onClick": onInputClick
|
|
73
73
|
}, dataAttrs?.affixWrapper, { "ref": containerRef }), { default: () => [
|
|
74
|
-
prefix && createVNode("span", {
|
|
74
|
+
isVueRenderable(prefix) && createVNode("span", {
|
|
75
75
|
"class": clsx(`${prefixCls}-prefix`, classNames?.prefix),
|
|
76
76
|
"style": styles?.prefix
|
|
77
77
|
}, [prefix]),
|
|
@@ -84,14 +84,13 @@ var BaseInput = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }
|
|
|
84
84
|
const addonCls = `${wrapperCls}-addon`;
|
|
85
85
|
const groupWrapperCls = `${wrapperCls}-wrapper`;
|
|
86
86
|
const mergedWrapperClassName = clsx(`${prefixCls}-wrapper`, wrapperCls, classNames?.wrapper);
|
|
87
|
-
const mergedGroupClassName = clsx(groupWrapperCls, { [`${groupWrapperCls}-disabled`]: disabled }, classNames?.groupWrapper);
|
|
88
87
|
element = createVNode(GroupWrapperComponent, {
|
|
89
|
-
"class":
|
|
88
|
+
"class": clsx(groupWrapperCls, { [`${groupWrapperCls}-disabled`]: disabled }, classNames?.groupWrapper),
|
|
90
89
|
"ref": groupRef
|
|
91
90
|
}, { default: () => [createVNode(WrapperComponent, { "class": mergedWrapperClassName }, { default: () => [
|
|
92
|
-
addonBefore && createVNode(GroupAddonComponent, { "class": addonCls }, _isSlot(addonBefore) ? addonBefore : { default: () => [addonBefore] }),
|
|
91
|
+
isVueRenderable(addonBefore) && createVNode(GroupAddonComponent, { "class": addonCls }, _isSlot(addonBefore) ? addonBefore : { default: () => [addonBefore] }),
|
|
93
92
|
element,
|
|
94
|
-
addonAfter && createVNode(GroupAddonComponent, { "class": addonCls }, _isSlot(addonAfter) ? addonAfter : { default: () => [addonAfter] })
|
|
93
|
+
isVueRenderable(addonAfter) && createVNode(GroupAddonComponent, { "class": addonCls }, _isSlot(addonAfter) ? addonAfter : { default: () => [addonAfter] })
|
|
95
94
|
] })] });
|
|
96
95
|
}
|
|
97
96
|
return createVNode(element, {
|
package/dist/input.js
CHANGED
|
@@ -226,7 +226,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }) =>
|
|
|
226
226
|
}, _isSlot(inputElement) ? inputElement : { default: () => [inputElement] });
|
|
227
227
|
};
|
|
228
228
|
}, {
|
|
229
|
-
props:
|
|
229
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
230
230
|
value: {
|
|
231
231
|
required: false,
|
|
232
232
|
default: void 0
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isVueRenderable } from "@v-c/util";
|
|
1
2
|
import { triggerFocus as triggerFocus$1 } from "@v-c/util/dist/Dom/focus";
|
|
2
3
|
//#region src/utils/commonUtils.ts
|
|
3
4
|
function createPatchedTarget(target, value) {
|
|
@@ -12,27 +13,32 @@ function createPatchedTarget(target, value) {
|
|
|
12
13
|
};
|
|
13
14
|
return patched;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
const patchedTarget = createPatchedTarget(target, value);
|
|
16
|
+
function buildSafeEvent(event, target) {
|
|
17
17
|
return {
|
|
18
18
|
type: event?.type,
|
|
19
19
|
timeStamp: event?.timeStamp,
|
|
20
20
|
bubbles: event?.bubbles,
|
|
21
21
|
cancelable: event?.cancelable,
|
|
22
22
|
composed: event?.composed,
|
|
23
|
-
target
|
|
24
|
-
currentTarget:
|
|
23
|
+
target,
|
|
24
|
+
currentTarget: target,
|
|
25
25
|
preventDefault: event?.preventDefault ? event.preventDefault.bind(event) : void 0,
|
|
26
26
|
stopPropagation: event?.stopPropagation ? event.stopPropagation.bind(event) : void 0,
|
|
27
27
|
stopImmediatePropagation: event?.stopImmediatePropagation ? event.stopImmediatePropagation.bind(event) : void 0,
|
|
28
28
|
nativeEvent: event
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
function cloneEvent(event, target, value) {
|
|
32
|
+
return buildSafeEvent(event, createPatchedTarget(target, value));
|
|
33
|
+
}
|
|
34
|
+
function cloneEventWithTarget(event, target) {
|
|
35
|
+
return buildSafeEvent(event, target);
|
|
36
|
+
}
|
|
31
37
|
function hasAddon(props) {
|
|
32
|
-
return
|
|
38
|
+
return isVueRenderable(props.addonBefore) || isVueRenderable(props.addonAfter);
|
|
33
39
|
}
|
|
34
40
|
function hasPrefixSuffix(props) {
|
|
35
|
-
return
|
|
41
|
+
return isVueRenderable(props.prefix) || isVueRenderable(props.suffix) || Boolean(props.allowClear);
|
|
36
42
|
}
|
|
37
43
|
function resolveOnChange(target, e, onChange, targetValue) {
|
|
38
44
|
if (!onChange) return;
|
|
@@ -41,7 +47,8 @@ function resolveOnChange(target, e, onChange, targetValue) {
|
|
|
41
47
|
return;
|
|
42
48
|
}
|
|
43
49
|
if (target.type !== "file" && targetValue !== void 0) {
|
|
44
|
-
onChange(cloneEvent(e, target, targetValue));
|
|
50
|
+
if (target.value !== targetValue) onChange(cloneEvent(e, target, targetValue));
|
|
51
|
+
else onChange(cloneEventWithTarget(e, target));
|
|
45
52
|
return;
|
|
46
53
|
}
|
|
47
54
|
onChange(e);
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/input",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/antdv-next/vue-components/tree/next/packages/input",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/antdv-next/vue-components.git"
|
|
11
|
+
},
|
|
6
12
|
"publishConfig": {
|
|
7
13
|
"access": "public"
|
|
8
14
|
},
|
|
@@ -24,7 +30,7 @@
|
|
|
24
30
|
"vue": "^3.0.0"
|
|
25
31
|
},
|
|
26
32
|
"dependencies": {
|
|
27
|
-
"@v-c/util": "^1.0
|
|
33
|
+
"@v-c/util": "^1.2.0"
|
|
28
34
|
},
|
|
29
35
|
"scripts": {
|
|
30
36
|
"build": "vite build",
|