Skip to content

Commit ab16fde

Browse files
author
Pavlo Kulyk
committed
fix: simplify input handling by removing min/max validation logic
1 parent f5a4ba8 commit ab16fde

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

adminforth/spa/src/afcl/Input.vue

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
ref="input"
1313
v-bind="$attrs"
1414
:type="type"
15-
:min="min"
16-
:max="max"
17-
@input="onInput"
15+
@input="$emit('update:modelValue', type === 'number' ? Number(($event.target as HTMLInputElement)?.value) : ($event.target as HTMLInputElement)?.value)"
1816
:value="modelValue"
1917
aria-describedby="helper-text-explanation"
2018
class="afcl-input inline-flex bg-lightInputBackground text-lightInputText dark:text-darkInputText border border-lightInputBorder rounded-0 focus:ring-lightPrimary focus:border-lightPrimary dark:focus:ring-darkPrimary dark:focus:border-darkPrimary
@@ -50,31 +48,8 @@ const props = defineProps<{
5048
suffix?: string,
5149
prefix?: string,
5250
readonly?: boolean,
53-
min?: number | null,
54-
max?: number | null,
5551
}>()
5652
57-
const emit = defineEmits<{
58-
(e: 'update:modelValue', value: number | null): void
59-
}>();
60-
61-
const onInput = (e: Event) => {
62-
const el = e.target as HTMLInputElement;
63-
64-
if (props.type === 'number') {
65-
let val = Number(el.value);
66-
67-
if (props.min != null && val < props.min) val = props.min;
68-
if (props.max != null && val > props.max) val = props.max;
69-
70-
el.value = String(val);
71-
emit('update:modelValue', val);
72-
} else {
73-
emit('update:modelValue', el.value);
74-
}
75-
};
76-
77-
7853
const input = ref<HTMLInputElement | null>(null)
7954
8055
defineExpose({

0 commit comments

Comments
 (0)