Skip to content

Commit c686db7

Browse files
authored
Merge pull request #113 from Jenesius/issue_112
Issue 112
2 parents a392531 + 2c43db4 commit c686db7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

examples/all-inputs/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<input-field name = "username" label = "Error array" :errors = "['Some mistake', 'Length more then 5']"/>
1111
<input-field name = "username" label = "Prefix" prefix = "Login:"/>
1212
<input-field name = "username" label = "Placeholder" placeholder = "Write something"/>
13-
13+
<input-field name = "username" label = "Numeric" numeric/>
1414
<h2>Input Textarea</h2>
1515
<input-field name = "description" type = "textarea"/>
1616
<input-field name = "description" type = "textarea" label = "With label"/>

plugin/widgets/inputs/input-text/widget-input-text.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
ref="refInput"
1313
class="vf-input_clean input-text"
1414
type="text"
15-
:value="pretty(modelValue)"
15+
:value="isFocused ? modelValue : pretty ? pretty(modelValue) : modelValue"
1616
:disabled="disabled"
1717
:autofocus="autofocus"
1818
:placeholder="placeholder"
1919
@input="onInput($event.target.value)"
20+
@focusin = "isFocused = true"
21+
@focusout = "isFocused = false"
2022
>
2123
</div>
2224
</input-wrap>
@@ -47,13 +49,14 @@ const props = withDefaults(defineProps<{
4749
pretty: (a: string) => a,
4850
})
4951
52+
const isFocused = ref(false);
5053
const refInput = ref<HTMLInputElement>(props.modelValue);
5154
const emit = defineEmits<{
5255
(e: 'update:modelValue', value: any): void
5356
}>()
5457
5558
function onlyNumber(a: string) {
56-
return a.replace(/[^0-9,]/,'')
59+
return a.replace(/[^\d,.+-]/,'')
5760
}
5861
5962
/**

0 commit comments

Comments
 (0)