@v-c/input 0.0.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/LICENSE +21 -0
- package/dist/BaseInput.cjs +230 -0
- package/dist/BaseInput.d.ts +7 -0
- package/dist/BaseInput.js +227 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/hooks/useCount.cjs +26 -0
- package/dist/hooks/useCount.d.ts +18 -0
- package/dist/hooks/useCount.js +23 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/dist/input.cjs +414 -0
- package/dist/input.d.ts +3 -0
- package/dist/input.js +410 -0
- package/dist/interface.cjs +0 -0
- package/dist/interface.d.ts +119 -0
- package/dist/interface.js +0 -0
- package/dist/utils/commonUtils.cjs +44 -0
- package/dist/utils/commonUtils.d.ts +6 -0
- package/dist/utils/commonUtils.js +40 -0
- package/dist/utils/types.cjs +0 -0
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.js +0 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 antdv-community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
3
|
+
const require_commonUtils = require("./utils/commonUtils.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
let __v_c_util = require("@v-c/util");
|
|
6
|
+
let __v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
7
|
+
function _isSlot(s) {
|
|
8
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
|
|
9
|
+
}
|
|
10
|
+
var BaseInput = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, expose, attrs }) => {
|
|
11
|
+
const containerRef = (0, vue.shallowRef)();
|
|
12
|
+
const onInputClick = (e) => {
|
|
13
|
+
if (containerRef.value?.contains(e.target)) props?.triggerFocus?.();
|
|
14
|
+
};
|
|
15
|
+
const hasAffix = (0, vue.computed)(() => require_commonUtils.hasPrefixSuffix(props));
|
|
16
|
+
const groupRef = (0, vue.shallowRef)();
|
|
17
|
+
expose({ nativeElement: (0, vue.computed)(() => groupRef.value || containerRef.value) });
|
|
18
|
+
return () => {
|
|
19
|
+
const { components, allowClear, readOnly, disabled, value, prefixCls, handleReset, onClear, suffix, focused, classNames, styles, dataAttrs, prefix, addonAfter, addonBefore, hidden } = props;
|
|
20
|
+
let children = (0, __v_c_util_dist_props_util.filterEmpty)(slots?.default?.() ?? []);
|
|
21
|
+
if (children.length === 1) children = children[0];
|
|
22
|
+
else children = (0, vue.createVNode)(vue.Fragment, null, children);
|
|
23
|
+
const inputElement = children;
|
|
24
|
+
const AffixWrapperComponent = components?.affixWrapper || "span";
|
|
25
|
+
const GroupWrapperComponent = components?.groupWrapper || "span";
|
|
26
|
+
const WrapperComponent = components?.wrapper || "span";
|
|
27
|
+
const GroupAddonComponent = components?.groupAddon || "span";
|
|
28
|
+
let element = (0, vue.createVNode)(inputElement, {
|
|
29
|
+
value,
|
|
30
|
+
class: !hasAffix.value && classNames?.variant
|
|
31
|
+
});
|
|
32
|
+
if (hasAffix.value) {
|
|
33
|
+
let clearIcon = null;
|
|
34
|
+
if (allowClear) {
|
|
35
|
+
const needClear = !disabled && !readOnly && value;
|
|
36
|
+
const clearIconCls = `${prefixCls}-clear-icon`;
|
|
37
|
+
const iconNode = typeof allowClear === "object" && allowClear?.clearIcon ? allowClear.clearIcon : "✖";
|
|
38
|
+
clearIcon = (0, vue.createVNode)("button", {
|
|
39
|
+
"type": "button",
|
|
40
|
+
"tabindex": -1,
|
|
41
|
+
"onClick": (event) => {
|
|
42
|
+
handleReset?.(event);
|
|
43
|
+
onClear?.();
|
|
44
|
+
},
|
|
45
|
+
"onMousedown": (e) => e.preventDefault(),
|
|
46
|
+
"class": (0, __v_c_util.clsx)(clearIconCls, {
|
|
47
|
+
[`${clearIconCls}-hidden`]: !needClear,
|
|
48
|
+
[`${clearIconCls}-has-suffix`]: !!suffix
|
|
49
|
+
})
|
|
50
|
+
}, [iconNode]);
|
|
51
|
+
}
|
|
52
|
+
const affixWrapperPrefixCls = `${prefixCls}-affix-wrapper`;
|
|
53
|
+
const affixWrapperCls = (0, __v_c_util.clsx)(affixWrapperPrefixCls, {
|
|
54
|
+
[`${prefixCls}-disabled`]: disabled,
|
|
55
|
+
[`${affixWrapperPrefixCls}-disabled`]: disabled,
|
|
56
|
+
[`${affixWrapperPrefixCls}-focused`]: focused,
|
|
57
|
+
[`${affixWrapperPrefixCls}-readonly`]: readOnly,
|
|
58
|
+
[`${affixWrapperPrefixCls}-input-with-clear-btn`]: suffix && allowClear && value
|
|
59
|
+
}, classNames?.affixWrapper, classNames?.variant);
|
|
60
|
+
const suffixNode = (suffix || allowClear) && (0, vue.createVNode)("span", {
|
|
61
|
+
"class": (0, __v_c_util.clsx)(`${prefixCls}-suffix`, classNames?.suffix),
|
|
62
|
+
"style": styles?.suffix
|
|
63
|
+
}, [clearIcon, suffix]);
|
|
64
|
+
const _element = function() {
|
|
65
|
+
return element;
|
|
66
|
+
}();
|
|
67
|
+
element = (0, vue.createVNode)(AffixWrapperComponent, (0, vue.mergeProps)({
|
|
68
|
+
"class": affixWrapperCls,
|
|
69
|
+
"style": styles?.affixWrapper,
|
|
70
|
+
"onClick": onInputClick
|
|
71
|
+
}, dataAttrs?.affixWrapper, { "ref": containerRef }), { default: () => [
|
|
72
|
+
prefix && (0, vue.createVNode)("span", {
|
|
73
|
+
"class": (0, __v_c_util.clsx)(`${prefixCls}-prefix`, classNames?.prefix),
|
|
74
|
+
"style": styles?.prefix
|
|
75
|
+
}, [prefix]),
|
|
76
|
+
_element,
|
|
77
|
+
suffixNode
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
if (require_commonUtils.hasAddon(props)) {
|
|
81
|
+
const wrapperCls = `${prefixCls}-group`;
|
|
82
|
+
const addonCls = `${wrapperCls}-addon`;
|
|
83
|
+
const groupWrapperCls = `${wrapperCls}-wrapper`;
|
|
84
|
+
const mergedWrapperClassName = (0, __v_c_util.clsx)(`${prefixCls}-wrapper`, wrapperCls, classNames?.wrapper);
|
|
85
|
+
const mergedGroupClassName = (0, __v_c_util.clsx)(groupWrapperCls, { [`${groupWrapperCls}-disabled`]: disabled }, classNames?.groupWrapper);
|
|
86
|
+
element = (0, vue.createVNode)(GroupWrapperComponent, {
|
|
87
|
+
"class": mergedGroupClassName,
|
|
88
|
+
"ref": groupRef
|
|
89
|
+
}, { default: () => [(0, vue.createVNode)(WrapperComponent, { "class": mergedWrapperClassName }, { default: () => [
|
|
90
|
+
addonBefore && (0, vue.createVNode)(GroupAddonComponent, { "class": addonCls }, _isSlot(addonBefore) ? addonBefore : { default: () => [addonBefore] }),
|
|
91
|
+
element,
|
|
92
|
+
addonAfter && (0, vue.createVNode)(GroupAddonComponent, { "class": addonCls }, _isSlot(addonAfter) ? addonAfter : { default: () => [addonAfter] })
|
|
93
|
+
] })] });
|
|
94
|
+
}
|
|
95
|
+
return (0, vue.createVNode)(element, {
|
|
96
|
+
...attrs,
|
|
97
|
+
hidden
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}, {
|
|
101
|
+
props: {
|
|
102
|
+
value: {
|
|
103
|
+
type: null,
|
|
104
|
+
required: false,
|
|
105
|
+
default: void 0
|
|
106
|
+
},
|
|
107
|
+
prefixCls: {
|
|
108
|
+
type: String,
|
|
109
|
+
required: false,
|
|
110
|
+
default: void 0
|
|
111
|
+
},
|
|
112
|
+
disabled: {
|
|
113
|
+
type: Boolean,
|
|
114
|
+
required: false,
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
focused: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
required: false,
|
|
120
|
+
default: void 0
|
|
121
|
+
},
|
|
122
|
+
triggerFocus: {
|
|
123
|
+
type: Function,
|
|
124
|
+
required: false,
|
|
125
|
+
default: void 0
|
|
126
|
+
},
|
|
127
|
+
readOnly: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
required: false,
|
|
130
|
+
default: void 0
|
|
131
|
+
},
|
|
132
|
+
handleReset: {
|
|
133
|
+
type: Function,
|
|
134
|
+
required: false,
|
|
135
|
+
default: void 0
|
|
136
|
+
},
|
|
137
|
+
onClear: {
|
|
138
|
+
type: Function,
|
|
139
|
+
required: false,
|
|
140
|
+
default: void 0
|
|
141
|
+
},
|
|
142
|
+
hidden: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
required: false,
|
|
145
|
+
default: void 0
|
|
146
|
+
},
|
|
147
|
+
dataAttrs: {
|
|
148
|
+
type: Object,
|
|
149
|
+
required: false,
|
|
150
|
+
default: void 0
|
|
151
|
+
},
|
|
152
|
+
components: {
|
|
153
|
+
type: Object,
|
|
154
|
+
required: false,
|
|
155
|
+
default: void 0
|
|
156
|
+
},
|
|
157
|
+
prefix: {
|
|
158
|
+
type: [
|
|
159
|
+
String,
|
|
160
|
+
Number,
|
|
161
|
+
null,
|
|
162
|
+
Boolean,
|
|
163
|
+
Array
|
|
164
|
+
],
|
|
165
|
+
required: false,
|
|
166
|
+
skipCheck: true,
|
|
167
|
+
default: void 0
|
|
168
|
+
},
|
|
169
|
+
suffix: {
|
|
170
|
+
type: [
|
|
171
|
+
String,
|
|
172
|
+
Number,
|
|
173
|
+
null,
|
|
174
|
+
Boolean,
|
|
175
|
+
Array
|
|
176
|
+
],
|
|
177
|
+
required: false,
|
|
178
|
+
skipCheck: true,
|
|
179
|
+
default: void 0
|
|
180
|
+
},
|
|
181
|
+
addonBefore: {
|
|
182
|
+
type: [
|
|
183
|
+
String,
|
|
184
|
+
Number,
|
|
185
|
+
null,
|
|
186
|
+
Boolean,
|
|
187
|
+
Array
|
|
188
|
+
],
|
|
189
|
+
required: false,
|
|
190
|
+
skipCheck: true,
|
|
191
|
+
default: void 0
|
|
192
|
+
},
|
|
193
|
+
addonAfter: {
|
|
194
|
+
type: [
|
|
195
|
+
String,
|
|
196
|
+
Number,
|
|
197
|
+
null,
|
|
198
|
+
Boolean,
|
|
199
|
+
Array
|
|
200
|
+
],
|
|
201
|
+
required: false,
|
|
202
|
+
skipCheck: true,
|
|
203
|
+
default: void 0
|
|
204
|
+
},
|
|
205
|
+
classes: {
|
|
206
|
+
type: Object,
|
|
207
|
+
required: false,
|
|
208
|
+
default: void 0
|
|
209
|
+
},
|
|
210
|
+
classNames: {
|
|
211
|
+
type: Object,
|
|
212
|
+
required: false,
|
|
213
|
+
default: void 0
|
|
214
|
+
},
|
|
215
|
+
styles: {
|
|
216
|
+
type: Object,
|
|
217
|
+
required: false,
|
|
218
|
+
default: void 0
|
|
219
|
+
},
|
|
220
|
+
allowClear: {
|
|
221
|
+
type: [Boolean, Object],
|
|
222
|
+
required: false,
|
|
223
|
+
default: void 0
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
name: "BaseInput",
|
|
227
|
+
inheritAttrs: false
|
|
228
|
+
});
|
|
229
|
+
var BaseInput_default = BaseInput;
|
|
230
|
+
exports.default = BaseInput_default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseInputProps } from './interface';
|
|
2
|
+
export interface HolderRef {
|
|
3
|
+
/** Provider holder ref. Will return `null` if not wrap anything */
|
|
4
|
+
nativeElement: HTMLElement | null;
|
|
5
|
+
}
|
|
6
|
+
declare const BaseInput: import('vue').DefineSetupFnComponent<BaseInputProps, {}, {}, BaseInputProps & {}, import('vue').PublicProps>;
|
|
7
|
+
export default BaseInput;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { hasAddon, hasPrefixSuffix } from "./utils/commonUtils.js";
|
|
2
|
+
import { Fragment, computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
|
|
3
|
+
import { clsx } from "@v-c/util";
|
|
4
|
+
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
5
|
+
function _isSlot(s) {
|
|
6
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
7
|
+
}
|
|
8
|
+
var BaseInput_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs }) => {
|
|
9
|
+
const containerRef = shallowRef();
|
|
10
|
+
const onInputClick = (e) => {
|
|
11
|
+
if (containerRef.value?.contains(e.target)) props?.triggerFocus?.();
|
|
12
|
+
};
|
|
13
|
+
const hasAffix = computed(() => hasPrefixSuffix(props));
|
|
14
|
+
const groupRef = shallowRef();
|
|
15
|
+
expose({ nativeElement: computed(() => groupRef.value || containerRef.value) });
|
|
16
|
+
return () => {
|
|
17
|
+
const { components, allowClear, readOnly, disabled, value, prefixCls, handleReset, onClear, suffix, focused, classNames, styles, dataAttrs, prefix, addonAfter, addonBefore, hidden } = props;
|
|
18
|
+
let children = filterEmpty(slots?.default?.() ?? []);
|
|
19
|
+
if (children.length === 1) children = children[0];
|
|
20
|
+
else children = createVNode(Fragment, null, children);
|
|
21
|
+
const inputElement = children;
|
|
22
|
+
const AffixWrapperComponent = components?.affixWrapper || "span";
|
|
23
|
+
const GroupWrapperComponent = components?.groupWrapper || "span";
|
|
24
|
+
const WrapperComponent = components?.wrapper || "span";
|
|
25
|
+
const GroupAddonComponent = components?.groupAddon || "span";
|
|
26
|
+
let element = createVNode(inputElement, {
|
|
27
|
+
value,
|
|
28
|
+
class: !hasAffix.value && classNames?.variant
|
|
29
|
+
});
|
|
30
|
+
if (hasAffix.value) {
|
|
31
|
+
let clearIcon = null;
|
|
32
|
+
if (allowClear) {
|
|
33
|
+
const needClear = !disabled && !readOnly && value;
|
|
34
|
+
const clearIconCls = `${prefixCls}-clear-icon`;
|
|
35
|
+
const iconNode = typeof allowClear === "object" && allowClear?.clearIcon ? allowClear.clearIcon : "✖";
|
|
36
|
+
clearIcon = createVNode("button", {
|
|
37
|
+
"type": "button",
|
|
38
|
+
"tabindex": -1,
|
|
39
|
+
"onClick": (event) => {
|
|
40
|
+
handleReset?.(event);
|
|
41
|
+
onClear?.();
|
|
42
|
+
},
|
|
43
|
+
"onMousedown": (e) => e.preventDefault(),
|
|
44
|
+
"class": clsx(clearIconCls, {
|
|
45
|
+
[`${clearIconCls}-hidden`]: !needClear,
|
|
46
|
+
[`${clearIconCls}-has-suffix`]: !!suffix
|
|
47
|
+
})
|
|
48
|
+
}, [iconNode]);
|
|
49
|
+
}
|
|
50
|
+
const affixWrapperPrefixCls = `${prefixCls}-affix-wrapper`;
|
|
51
|
+
const affixWrapperCls = clsx(affixWrapperPrefixCls, {
|
|
52
|
+
[`${prefixCls}-disabled`]: disabled,
|
|
53
|
+
[`${affixWrapperPrefixCls}-disabled`]: disabled,
|
|
54
|
+
[`${affixWrapperPrefixCls}-focused`]: focused,
|
|
55
|
+
[`${affixWrapperPrefixCls}-readonly`]: readOnly,
|
|
56
|
+
[`${affixWrapperPrefixCls}-input-with-clear-btn`]: suffix && allowClear && value
|
|
57
|
+
}, classNames?.affixWrapper, classNames?.variant);
|
|
58
|
+
const suffixNode = (suffix || allowClear) && createVNode("span", {
|
|
59
|
+
"class": clsx(`${prefixCls}-suffix`, classNames?.suffix),
|
|
60
|
+
"style": styles?.suffix
|
|
61
|
+
}, [clearIcon, suffix]);
|
|
62
|
+
const _element = function() {
|
|
63
|
+
return element;
|
|
64
|
+
}();
|
|
65
|
+
element = createVNode(AffixWrapperComponent, mergeProps({
|
|
66
|
+
"class": affixWrapperCls,
|
|
67
|
+
"style": styles?.affixWrapper,
|
|
68
|
+
"onClick": onInputClick
|
|
69
|
+
}, dataAttrs?.affixWrapper, { "ref": containerRef }), { default: () => [
|
|
70
|
+
prefix && createVNode("span", {
|
|
71
|
+
"class": clsx(`${prefixCls}-prefix`, classNames?.prefix),
|
|
72
|
+
"style": styles?.prefix
|
|
73
|
+
}, [prefix]),
|
|
74
|
+
_element,
|
|
75
|
+
suffixNode
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
if (hasAddon(props)) {
|
|
79
|
+
const wrapperCls = `${prefixCls}-group`;
|
|
80
|
+
const addonCls = `${wrapperCls}-addon`;
|
|
81
|
+
const groupWrapperCls = `${wrapperCls}-wrapper`;
|
|
82
|
+
const mergedWrapperClassName = clsx(`${prefixCls}-wrapper`, wrapperCls, classNames?.wrapper);
|
|
83
|
+
const mergedGroupClassName = clsx(groupWrapperCls, { [`${groupWrapperCls}-disabled`]: disabled }, classNames?.groupWrapper);
|
|
84
|
+
element = createVNode(GroupWrapperComponent, {
|
|
85
|
+
"class": mergedGroupClassName,
|
|
86
|
+
"ref": groupRef
|
|
87
|
+
}, { default: () => [createVNode(WrapperComponent, { "class": mergedWrapperClassName }, { default: () => [
|
|
88
|
+
addonBefore && createVNode(GroupAddonComponent, { "class": addonCls }, _isSlot(addonBefore) ? addonBefore : { default: () => [addonBefore] }),
|
|
89
|
+
element,
|
|
90
|
+
addonAfter && createVNode(GroupAddonComponent, { "class": addonCls }, _isSlot(addonAfter) ? addonAfter : { default: () => [addonAfter] })
|
|
91
|
+
] })] });
|
|
92
|
+
}
|
|
93
|
+
return createVNode(element, {
|
|
94
|
+
...attrs,
|
|
95
|
+
hidden
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
}, {
|
|
99
|
+
props: {
|
|
100
|
+
value: {
|
|
101
|
+
type: null,
|
|
102
|
+
required: false,
|
|
103
|
+
default: void 0
|
|
104
|
+
},
|
|
105
|
+
prefixCls: {
|
|
106
|
+
type: String,
|
|
107
|
+
required: false,
|
|
108
|
+
default: void 0
|
|
109
|
+
},
|
|
110
|
+
disabled: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
required: false,
|
|
113
|
+
default: void 0
|
|
114
|
+
},
|
|
115
|
+
focused: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
required: false,
|
|
118
|
+
default: void 0
|
|
119
|
+
},
|
|
120
|
+
triggerFocus: {
|
|
121
|
+
type: Function,
|
|
122
|
+
required: false,
|
|
123
|
+
default: void 0
|
|
124
|
+
},
|
|
125
|
+
readOnly: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
required: false,
|
|
128
|
+
default: void 0
|
|
129
|
+
},
|
|
130
|
+
handleReset: {
|
|
131
|
+
type: Function,
|
|
132
|
+
required: false,
|
|
133
|
+
default: void 0
|
|
134
|
+
},
|
|
135
|
+
onClear: {
|
|
136
|
+
type: Function,
|
|
137
|
+
required: false,
|
|
138
|
+
default: void 0
|
|
139
|
+
},
|
|
140
|
+
hidden: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
required: false,
|
|
143
|
+
default: void 0
|
|
144
|
+
},
|
|
145
|
+
dataAttrs: {
|
|
146
|
+
type: Object,
|
|
147
|
+
required: false,
|
|
148
|
+
default: void 0
|
|
149
|
+
},
|
|
150
|
+
components: {
|
|
151
|
+
type: Object,
|
|
152
|
+
required: false,
|
|
153
|
+
default: void 0
|
|
154
|
+
},
|
|
155
|
+
prefix: {
|
|
156
|
+
type: [
|
|
157
|
+
String,
|
|
158
|
+
Number,
|
|
159
|
+
null,
|
|
160
|
+
Boolean,
|
|
161
|
+
Array
|
|
162
|
+
],
|
|
163
|
+
required: false,
|
|
164
|
+
skipCheck: true,
|
|
165
|
+
default: void 0
|
|
166
|
+
},
|
|
167
|
+
suffix: {
|
|
168
|
+
type: [
|
|
169
|
+
String,
|
|
170
|
+
Number,
|
|
171
|
+
null,
|
|
172
|
+
Boolean,
|
|
173
|
+
Array
|
|
174
|
+
],
|
|
175
|
+
required: false,
|
|
176
|
+
skipCheck: true,
|
|
177
|
+
default: void 0
|
|
178
|
+
},
|
|
179
|
+
addonBefore: {
|
|
180
|
+
type: [
|
|
181
|
+
String,
|
|
182
|
+
Number,
|
|
183
|
+
null,
|
|
184
|
+
Boolean,
|
|
185
|
+
Array
|
|
186
|
+
],
|
|
187
|
+
required: false,
|
|
188
|
+
skipCheck: true,
|
|
189
|
+
default: void 0
|
|
190
|
+
},
|
|
191
|
+
addonAfter: {
|
|
192
|
+
type: [
|
|
193
|
+
String,
|
|
194
|
+
Number,
|
|
195
|
+
null,
|
|
196
|
+
Boolean,
|
|
197
|
+
Array
|
|
198
|
+
],
|
|
199
|
+
required: false,
|
|
200
|
+
skipCheck: true,
|
|
201
|
+
default: void 0
|
|
202
|
+
},
|
|
203
|
+
classes: {
|
|
204
|
+
type: Object,
|
|
205
|
+
required: false,
|
|
206
|
+
default: void 0
|
|
207
|
+
},
|
|
208
|
+
classNames: {
|
|
209
|
+
type: Object,
|
|
210
|
+
required: false,
|
|
211
|
+
default: void 0
|
|
212
|
+
},
|
|
213
|
+
styles: {
|
|
214
|
+
type: Object,
|
|
215
|
+
required: false,
|
|
216
|
+
default: void 0
|
|
217
|
+
},
|
|
218
|
+
allowClear: {
|
|
219
|
+
type: [Boolean, Object],
|
|
220
|
+
required: false,
|
|
221
|
+
default: void 0
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
name: "BaseInput",
|
|
225
|
+
inheritAttrs: false
|
|
226
|
+
});
|
|
227
|
+
export { BaseInput_default as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
9
|
+
key = keys[i];
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: ((k) => from[k]).bind(null, key),
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
value: mod,
|
|
19
|
+
enumerable: true
|
|
20
|
+
}) : target, mod));
|
|
21
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
function inCountRange(value, countConfig) {
|
|
5
|
+
if (!countConfig.max) return true;
|
|
6
|
+
return countConfig.strategy(value) <= countConfig.max;
|
|
7
|
+
}
|
|
8
|
+
function useCount(count, showCount) {
|
|
9
|
+
return (0, vue.computed)(() => {
|
|
10
|
+
let mergedConfig = {};
|
|
11
|
+
if (showCount?.value) mergedConfig.show = typeof showCount.value === "object" && showCount.value?.formatter ? showCount.value?.formatter : !!showCount.value;
|
|
12
|
+
mergedConfig = {
|
|
13
|
+
...mergedConfig,
|
|
14
|
+
...count?.value
|
|
15
|
+
};
|
|
16
|
+
const { show,...rest } = mergedConfig;
|
|
17
|
+
return {
|
|
18
|
+
...rest,
|
|
19
|
+
show: !!show,
|
|
20
|
+
showFormatter: typeof show === "function" ? show : void 0,
|
|
21
|
+
strategy: rest.strategy || ((value) => value.length)
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.default = useCount;
|
|
26
|
+
exports.inCountRange = inCountRange;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { CountConfig, InputProps, ShowCountFormatter } from '../interface';
|
|
3
|
+
type ForcedCountConfig = Omit<CountConfig, 'show'> & Pick<Required<CountConfig>, 'strategy'> & {
|
|
4
|
+
show: boolean;
|
|
5
|
+
showFormatter?: ShowCountFormatter;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Cut `value` by the `count.max` prop.
|
|
9
|
+
*/
|
|
10
|
+
export declare function inCountRange(value: string, countConfig: ForcedCountConfig): boolean;
|
|
11
|
+
export default function useCount(count?: Ref<CountConfig>, showCount?: Ref<InputProps['showCount']>): import('vue').ComputedRef<{
|
|
12
|
+
readonly show: boolean;
|
|
13
|
+
readonly showFormatter: ShowCountFormatter | undefined;
|
|
14
|
+
readonly strategy: (value: string) => number;
|
|
15
|
+
readonly max?: number;
|
|
16
|
+
readonly exceedFormatter?: import('../interface').ExceedFormatter;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
function inCountRange(value, countConfig) {
|
|
3
|
+
if (!countConfig.max) return true;
|
|
4
|
+
return countConfig.strategy(value) <= countConfig.max;
|
|
5
|
+
}
|
|
6
|
+
function useCount(count, showCount) {
|
|
7
|
+
return computed(() => {
|
|
8
|
+
let mergedConfig = {};
|
|
9
|
+
if (showCount?.value) mergedConfig.show = typeof showCount.value === "object" && showCount.value?.formatter ? showCount.value?.formatter : !!showCount.value;
|
|
10
|
+
mergedConfig = {
|
|
11
|
+
...mergedConfig,
|
|
12
|
+
...count?.value
|
|
13
|
+
};
|
|
14
|
+
const { show,...rest } = mergedConfig;
|
|
15
|
+
return {
|
|
16
|
+
...rest,
|
|
17
|
+
show: !!show,
|
|
18
|
+
showFormatter: typeof show === "function" ? show : void 0,
|
|
19
|
+
strategy: rest.strategy || ((value) => value.length)
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export { useCount as default, inCountRange };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_commonUtils = require("./utils/commonUtils.cjs");
|
|
3
|
+
const require_BaseInput = require("./BaseInput.cjs");
|
|
4
|
+
const require_useCount = require("./hooks/useCount.cjs");
|
|
5
|
+
const require_input = require("./input.cjs");
|
|
6
|
+
var src_default = require_input.default;
|
|
7
|
+
exports.BaseInput = require_BaseInput.default;
|
|
8
|
+
exports.default = src_default;
|
|
9
|
+
exports.resolveOnChange = require_commonUtils.resolveOnChange;
|
|
10
|
+
exports.useCount = require_useCount.default;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as BaseInput } from './BaseInput';
|
|
2
|
+
import { default as useCount } from './hooks/useCount';
|
|
3
|
+
import { default as Input } from './input';
|
|
4
|
+
export type { CountConfig, InputProps, InputRef, ShowCountFormatter } from './interface';
|
|
5
|
+
export { BaseInput };
|
|
6
|
+
export { useCount, };
|
|
7
|
+
export { resolveOnChange } from './utils/commonUtils';
|
|
8
|
+
export default Input;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { resolveOnChange } from "./utils/commonUtils.js";
|
|
2
|
+
import BaseInput_default from "./BaseInput.js";
|
|
3
|
+
import useCount from "./hooks/useCount.js";
|
|
4
|
+
import input_default from "./input.js";
|
|
5
|
+
var src_default = input_default;
|
|
6
|
+
export { BaseInput_default as BaseInput, src_default as default, resolveOnChange, useCount };
|