Skip to content

Commit 839f6c7

Browse files
committed
feat: fix pretty, update regex for text[numeric]
1 parent a392531 commit 839f6c7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/all-inputs/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
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/>
14+
<input type = "number"/>
1415
<h2>Input Textarea</h2>
1516
<input-field name = "description" type = "textarea"/>
1617
<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)