bge-ui 1.5.3 → 1.5.4
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/index.js +54 -36
- package/dist/input/index.vue.d.ts +3 -0
- package/package.json +1 -1
- package/src/input/index.vue +48 -25
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, renderSlot, normalizeStyle, createStaticVNode, provide, reactive, toRefs, ref, watch, unref, getCurrentScope, onScopeDispose, readonly, computed, getCurrentInstance, onMounted, useSlots, inject, createTextVNode, toDisplayString, createCommentVNode, TransitionGroup, withCtx,
|
|
7
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, renderSlot, normalizeStyle, createStaticVNode, provide, reactive, toRefs, ref, watch, unref, getCurrentScope, onScopeDispose, readonly, computed, getCurrentInstance, onMounted, useSlots, inject, createTextVNode, toDisplayString, createCommentVNode, TransitionGroup, withCtx, createBlock, withModifiers, withDirectives, cloneVNode, Fragment, Text, Comment, onUnmounted, h, Transition, vShow, onBeforeMount, nextTick, Teleport, resolveDynamicComponent, shallowReactive, render as render$7, isVNode, vModelCheckbox, renderList, toRef, useAttrs, normalizeProps, mergeProps, onBeforeUpdate, withKeys, createSlots, guardReactiveProps, isRef } from "vue";
|
|
8
8
|
const _hoisted_1$26 = ["disabled"];
|
|
9
9
|
const _hoisted_2$1M = { class: "loading-icon" };
|
|
10
10
|
const _sfc_main$2g = /* @__PURE__ */ defineComponent({
|
|
@@ -6162,8 +6162,8 @@ const _hoisted_2$f = {
|
|
|
6162
6162
|
class: "bge-input__prefix"
|
|
6163
6163
|
};
|
|
6164
6164
|
const _hoisted_3$b = { class: "bge-input__prefix-inner" };
|
|
6165
|
-
const _hoisted_4$a = ["maxlength", "disabled", "readonly", "type", "placeholder"];
|
|
6166
|
-
const _hoisted_5$6 = ["rows", "maxlength", "disabled", "readonly", "placeholder"];
|
|
6165
|
+
const _hoisted_4$a = ["value", "maxlength", "disabled", "readonly", "type", "placeholder"];
|
|
6166
|
+
const _hoisted_5$6 = ["rows", "maxlength", "value", "disabled", "readonly", "placeholder"];
|
|
6167
6167
|
const _hoisted_6$5 = { class: "bge-input__suffix-inner" };
|
|
6168
6168
|
const formItemContextKey$4 = "bge-form-item-context";
|
|
6169
6169
|
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
@@ -6182,6 +6182,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
6182
6182
|
type: [String, Number],
|
|
6183
6183
|
default: ""
|
|
6184
6184
|
},
|
|
6185
|
+
thousand: Boolean,
|
|
6185
6186
|
placeholder: String,
|
|
6186
6187
|
disabled: Boolean,
|
|
6187
6188
|
readonly: Boolean,
|
|
@@ -6204,49 +6205,68 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
6204
6205
|
setup(__props, { emit: __emit }) {
|
|
6205
6206
|
const props = __props;
|
|
6206
6207
|
const emit = __emit;
|
|
6208
|
+
const input = ref("");
|
|
6209
|
+
const inputField = ref();
|
|
6207
6210
|
const formItemContext = inject(formItemContextKey$4, void 0);
|
|
6208
6211
|
const suffixSlot = useSlots().suffix;
|
|
6209
6212
|
const prefixSlot = useSlots().prefix;
|
|
6210
|
-
const input = ref("");
|
|
6211
6213
|
const isFocus = ref(false);
|
|
6212
6214
|
const isClearHover = ref(false);
|
|
6213
6215
|
function handleFocus() {
|
|
6214
6216
|
isFocus.value = true;
|
|
6215
6217
|
emit("focus");
|
|
6216
6218
|
}
|
|
6217
|
-
function handleBlur() {
|
|
6219
|
+
function handleBlur(event) {
|
|
6218
6220
|
isFocus.value = false;
|
|
6219
6221
|
emit("blur");
|
|
6220
|
-
emit("update:modelValue",
|
|
6222
|
+
emit("update:modelValue", toNormal(event.target.value));
|
|
6221
6223
|
}
|
|
6222
|
-
watch(() => props.modelValue, (
|
|
6223
|
-
input.value =
|
|
6224
|
+
watch(() => props.modelValue, () => {
|
|
6225
|
+
input.value = filterValue(props.modelValue);
|
|
6224
6226
|
formItemContext && formItemContext.validate && formItemContext.validate().catch((err) => err);
|
|
6225
6227
|
});
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6228
|
+
onMounted(() => {
|
|
6229
|
+
input.value = filterValue(props.modelValue);
|
|
6230
|
+
});
|
|
6231
|
+
function toNormal(value) {
|
|
6232
|
+
if (props.thousand) {
|
|
6233
|
+
return value.toString().split(",").join("");
|
|
6234
|
+
}
|
|
6235
|
+
return value.toString();
|
|
6236
|
+
}
|
|
6237
|
+
function filterValue(value) {
|
|
6238
|
+
if (props.thousand) {
|
|
6239
|
+
return toNormal(value.toString()).replace(/(^|\s)\d+/g, (m) => m.replace(/(?=(?!\b)(\d{3})+$)/g, ","));
|
|
6240
|
+
}
|
|
6241
|
+
return value;
|
|
6242
|
+
}
|
|
6243
|
+
function handleChange(event) {
|
|
6244
|
+
emit("change", toNormal(event.target.value));
|
|
6245
|
+
emit("update:modelValue", toNormal(event.target.value));
|
|
6229
6246
|
}
|
|
6230
|
-
function handleInput() {
|
|
6231
|
-
|
|
6232
|
-
|
|
6247
|
+
function handleInput(event) {
|
|
6248
|
+
const cursorPosition = filterValue(event.target.value).toString().length - (event.target.value.length - event.target.selectionEnd);
|
|
6249
|
+
if (toNormal(event.target.value) === toNormal(props.modelValue)) {
|
|
6250
|
+
return false;
|
|
6251
|
+
}
|
|
6252
|
+
emit("input", toNormal(event.target.value));
|
|
6253
|
+
emit("update:modelValue", toNormal(event.target.value));
|
|
6254
|
+
setTimeout(() => {
|
|
6255
|
+
if (inputField.value) {
|
|
6256
|
+
inputField.value.setSelectionRange(cursorPosition, cursorPosition);
|
|
6257
|
+
}
|
|
6258
|
+
});
|
|
6233
6259
|
}
|
|
6234
6260
|
function hoverClear(isHover) {
|
|
6235
6261
|
isClearHover.value = isHover;
|
|
6236
6262
|
}
|
|
6237
6263
|
function handelClear() {
|
|
6238
|
-
input.value = "";
|
|
6239
6264
|
isFocus.value = false;
|
|
6240
|
-
emit("clear",
|
|
6241
|
-
emit("input",
|
|
6242
|
-
emit("change",
|
|
6243
|
-
emit("update:modelValue",
|
|
6265
|
+
emit("clear", "");
|
|
6266
|
+
emit("input", "");
|
|
6267
|
+
emit("change", "");
|
|
6268
|
+
emit("update:modelValue", "");
|
|
6244
6269
|
}
|
|
6245
|
-
onMounted(() => {
|
|
6246
|
-
if (props.modelValue) {
|
|
6247
|
-
input.value = props.modelValue;
|
|
6248
|
-
}
|
|
6249
|
-
});
|
|
6250
6270
|
return (_ctx, _cache) => {
|
|
6251
6271
|
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
6252
6272
|
createElementVNode("div", {
|
|
@@ -6257,10 +6277,12 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
6257
6277
|
renderSlot(_ctx.$slots, "prefix")
|
|
6258
6278
|
])
|
|
6259
6279
|
])) : createCommentVNode("", true),
|
|
6260
|
-
__props.type !== "textarea" ?
|
|
6280
|
+
__props.type !== "textarea" ? (openBlock(), createElementBlock("input", {
|
|
6261
6281
|
key: 1,
|
|
6282
|
+
ref_key: "inputField",
|
|
6283
|
+
ref: inputField,
|
|
6262
6284
|
class: "bge-input__inner",
|
|
6263
|
-
|
|
6285
|
+
value: input.value,
|
|
6264
6286
|
maxlength: __props.maxlength,
|
|
6265
6287
|
disabled: __props.disabled,
|
|
6266
6288
|
readonly: __props.readonly,
|
|
@@ -6270,14 +6292,12 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
6270
6292
|
onBlur: handleBlur,
|
|
6271
6293
|
onChange: handleChange,
|
|
6272
6294
|
onInput: handleInput
|
|
6273
|
-
}, null, 40, _hoisted_4$a)),
|
|
6274
|
-
[vModelDynamic, input.value]
|
|
6275
|
-
]) : withDirectives((openBlock(), createElementBlock("textarea", {
|
|
6295
|
+
}, null, 40, _hoisted_4$a)) : (openBlock(), createElementBlock("textarea", {
|
|
6276
6296
|
key: 2,
|
|
6277
6297
|
rows: __props.rows,
|
|
6278
6298
|
maxlength: __props.maxlength,
|
|
6279
6299
|
class: "bge-input__inner",
|
|
6280
|
-
|
|
6300
|
+
value: input.value,
|
|
6281
6301
|
disabled: __props.disabled,
|
|
6282
6302
|
readonly: __props.readonly,
|
|
6283
6303
|
placeholder: __props.placeholder,
|
|
@@ -6285,18 +6305,16 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
6285
6305
|
onBlur: handleBlur,
|
|
6286
6306
|
onChange: handleChange,
|
|
6287
6307
|
onInput: handleInput
|
|
6288
|
-
}, null, 40, _hoisted_5$6)),
|
|
6289
|
-
[vModelText, input.value]
|
|
6290
|
-
]),
|
|
6308
|
+
}, null, 40, _hoisted_5$6)),
|
|
6291
6309
|
createElementVNode("span", {
|
|
6292
6310
|
class: normalizeClass(["bge-input__suffix", { suffix: !!unref(suffixSlot) }])
|
|
6293
6311
|
}, [
|
|
6294
6312
|
createElementVNode("span", _hoisted_6$5, [
|
|
6295
|
-
|
|
6313
|
+
__props.modelValue && !__props.readonly && !__props.disabled ? (openBlock(), createBlock(_sfc_main$27, {
|
|
6296
6314
|
key: 0,
|
|
6297
6315
|
class: "bge-input__icon clear",
|
|
6298
|
-
onMouseover: _cache[
|
|
6299
|
-
onMouseout: _cache[
|
|
6316
|
+
onMouseover: _cache[0] || (_cache[0] = withModifiers(($event) => hoverClear(true), ["prevent"])),
|
|
6317
|
+
onMouseout: _cache[1] || (_cache[1] = withModifiers(($event) => hoverClear(false), ["prevent"])),
|
|
6300
6318
|
onClick: handelClear,
|
|
6301
6319
|
size: "20"
|
|
6302
6320
|
})) : createCommentVNode("", true),
|
|
@@ -8,6 +8,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
8
8
|
type: (StringConstructor | NumberConstructor)[];
|
|
9
9
|
default: string;
|
|
10
10
|
};
|
|
11
|
+
thousand: BooleanConstructor;
|
|
11
12
|
placeholder: StringConstructor;
|
|
12
13
|
disabled: BooleanConstructor;
|
|
13
14
|
readonly: BooleanConstructor;
|
|
@@ -35,6 +36,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
35
36
|
type: (StringConstructor | NumberConstructor)[];
|
|
36
37
|
default: string;
|
|
37
38
|
};
|
|
39
|
+
thousand: BooleanConstructor;
|
|
38
40
|
placeholder: StringConstructor;
|
|
39
41
|
disabled: BooleanConstructor;
|
|
40
42
|
readonly: BooleanConstructor;
|
|
@@ -57,6 +59,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
57
59
|
disabled: boolean;
|
|
58
60
|
modelValue: string | number;
|
|
59
61
|
readonly: boolean;
|
|
62
|
+
thousand: boolean;
|
|
60
63
|
rows: string | number;
|
|
61
64
|
}, {}>, {
|
|
62
65
|
prefix?(_: {}): any;
|
package/package.json
CHANGED
package/src/input/index.vue
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
<slot name="prefix" />
|
|
7
7
|
</span>
|
|
8
8
|
</span>
|
|
9
|
-
<input v-if="type !== 'textarea'" class="bge-input__inner"
|
|
9
|
+
<input v-if="type !== 'textarea'" ref="inputField" class="bge-input__inner" :value="input" :maxlength="maxlength"
|
|
10
10
|
:disabled="disabled" :readonly="readonly" :type="type" :placeholder="placeholder" @focus="handleFocus"
|
|
11
11
|
@blur="handleBlur" @change="handleChange" @input="handleInput" />
|
|
12
|
-
<textarea v-else="type !== 'textarea'" :rows="rows" :maxlength="maxlength" class="bge-input__inner"
|
|
12
|
+
<textarea v-else="type !== 'textarea'" :rows="rows" :maxlength="maxlength" class="bge-input__inner" :value="input"
|
|
13
13
|
:disabled="disabled" :readonly="readonly" :placeholder="placeholder" @focus="handleFocus" @blur="handleBlur"
|
|
14
14
|
@change="handleChange" @input="handleInput" />
|
|
15
15
|
<span class="bge-input__suffix" :class="{ suffix: !!suffixSlot }">
|
|
16
16
|
<span class="bge-input__suffix-inner">
|
|
17
|
-
<mono-close class="bge-input__icon clear" v-if="
|
|
17
|
+
<mono-close class="bge-input__icon clear" v-if="modelValue && !readonly && !disabled" @mouseover.prevent="hoverClear(true)"
|
|
18
18
|
@mouseout.prevent="hoverClear(false)" @click="handelClear" size="20" />
|
|
19
19
|
<slot v-if="type !== 'textarea'" name="suffix" />
|
|
20
20
|
</span>
|
|
@@ -39,6 +39,7 @@ const props = defineProps({
|
|
|
39
39
|
type: [String, Number],
|
|
40
40
|
default: '',
|
|
41
41
|
},
|
|
42
|
+
thousand: Boolean,
|
|
42
43
|
placeholder: String,
|
|
43
44
|
disabled: Boolean,
|
|
44
45
|
readonly: Boolean,
|
|
@@ -58,13 +59,14 @@ const emit = defineEmits([
|
|
|
58
59
|
'clear',
|
|
59
60
|
'update:modelValue'
|
|
60
61
|
])
|
|
62
|
+
const input = ref<string | number>('')
|
|
63
|
+
const inputField = ref()
|
|
61
64
|
const formItemContextKey = 'bge-form-item-context'
|
|
62
65
|
|
|
63
66
|
const formItemContext: any = inject(formItemContextKey, undefined)
|
|
64
67
|
|
|
65
68
|
const suffixSlot = useSlots().suffix
|
|
66
69
|
const prefixSlot = useSlots().prefix
|
|
67
|
-
const input = ref<string | number>('')
|
|
68
70
|
const isFocus = ref(false)
|
|
69
71
|
const isClearHover = ref<Boolean>(false)
|
|
70
72
|
function handleFocus() {
|
|
@@ -72,25 +74,53 @@ function handleFocus() {
|
|
|
72
74
|
emit('focus')
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
function handleBlur() {
|
|
77
|
+
function handleBlur(event: any) {
|
|
76
78
|
isFocus.value = false
|
|
77
79
|
emit('blur')
|
|
78
|
-
emit('update:modelValue',
|
|
80
|
+
emit('update:modelValue', toNormal(event.target.value))
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
watch(() => props.modelValue, (
|
|
82
|
-
input.value =
|
|
83
|
+
watch(() => props.modelValue, () => {
|
|
84
|
+
input.value = filterValue(props.modelValue)
|
|
83
85
|
formItemContext && formItemContext.validate && formItemContext.validate().catch((err: any) => (err))
|
|
84
86
|
})
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
onMounted(() => {
|
|
89
|
+
input.value = filterValue(props.modelValue)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
function toNormal(value: string|number) {
|
|
93
|
+
if (props.thousand) {
|
|
94
|
+
return value.toString().split(',').join('')
|
|
95
|
+
}
|
|
96
|
+
return value.toString()
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
function filterValue(value: string|number) {
|
|
100
|
+
if (props.thousand) {
|
|
101
|
+
return toNormal(value.toString()).replace(/(^|\s)\d+/g, (m: string) => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
|
|
102
|
+
}
|
|
103
|
+
return value
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function handleChange(event: any) {
|
|
108
|
+
emit('change', toNormal(event.target.value))
|
|
109
|
+
emit('update:modelValue', toNormal(event.target.value))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function handleInput(event: any) {
|
|
113
|
+
const cursorPosition = filterValue(event.target.value).toString().length - (event.target.value.length - event.target.selectionEnd)
|
|
114
|
+
if (toNormal(event.target.value) === toNormal(props.modelValue)) {
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
emit('input', toNormal(event.target.value))
|
|
118
|
+
emit('update:modelValue', toNormal(event.target.value))
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
if (inputField.value) {
|
|
121
|
+
inputField.value.setSelectionRange(cursorPosition, cursorPosition)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
94
124
|
}
|
|
95
125
|
|
|
96
126
|
function hoverClear(isHover: Boolean) {
|
|
@@ -98,20 +128,13 @@ function hoverClear(isHover: Boolean) {
|
|
|
98
128
|
}
|
|
99
129
|
|
|
100
130
|
function handelClear() {
|
|
101
|
-
input.value = ''
|
|
102
131
|
isFocus.value = false
|
|
103
|
-
emit('clear',
|
|
104
|
-
emit('input',
|
|
105
|
-
emit('change',
|
|
106
|
-
emit('update:modelValue',
|
|
132
|
+
emit('clear', '')
|
|
133
|
+
emit('input', '')
|
|
134
|
+
emit('change', '')
|
|
135
|
+
emit('update:modelValue', '')
|
|
107
136
|
}
|
|
108
137
|
|
|
109
|
-
onMounted(() => {
|
|
110
|
-
if (props.modelValue) {
|
|
111
|
-
input.value = props.modelValue
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
|
|
115
138
|
</script>
|
|
116
139
|
<style lang="scss">
|
|
117
140
|
.bge-input {
|