File tree Expand file tree Collapse file tree 1 file changed +24
-7
lines changed
src/Resources/src/components/misc Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<input
3
3
v-model =" value"
4
- type =" text"
5
- pattern =" \d*([.,]?\d{0,2})"
4
+ type =" number"
6
5
required
6
+ min =" 0.00"
7
+ step =" .01"
7
8
class =" h-[46px] rounded-full border-[2px] border-solid border-[#CAD6E1] bg-white text-center"
9
+ @focus =" (e) => selectAllAndPlaceCursor(e.target as HTMLInputElement)"
8
10
/>
9
11
</template >
10
12
11
13
<script setup lang="ts">
12
14
import { computed } from ' vue' ;
13
- import { useI18n } from ' vue-i18n' ;
14
15
15
16
const props = defineProps <{
16
17
modelValue: number ;
17
18
}>();
18
19
19
- const { locale } = useI18n ();
20
-
21
20
const emit = defineEmits ([' update:modelValue' ]);
22
21
23
22
const value = computed ({
24
23
get() {
25
- return locale . value === ' en ' ? props .modelValue . toFixed ( 2 ) : props . modelValue . toFixed ( 2 ). replace ( / \. / g , ' , ' ) ;
24
+ return props .modelValue ;
26
25
},
27
26
set(value ) {
28
- emit (' update:modelValue' , parseFloat (value .replace ( / , / , ' . ' )));
27
+ emit (' update:modelValue' , parseFloat (value .toFixed ( 2 )));
29
28
}
30
29
});
30
+
31
+ function selectAllAndPlaceCursor(element : HTMLInputElement ) {
32
+ element .select ();
33
+ element .focus ();
34
+ element .setSelectionRange (0 , 0 );
35
+ }
31
36
</script >
37
+
38
+ <style scoped>
39
+ input ::-webkit-outer-spin-button ,
40
+ input ::-webkit-inner-spin-button {
41
+ -webkit-appearance : none ;
42
+ margin : 0 ;
43
+ }
44
+
45
+ input [type = ' number' ] {
46
+ -moz-appearance : textfield;
47
+ }
48
+ </style >
You can’t perform that action at this time.
0 commit comments