Add form support to `InputOtp`

pull/6632/head
Mert Sincan 2024-10-18 16:49:48 +01:00
parent 79f51434d7
commit 044a900f9d
2 changed files with 5 additions and 20 deletions

View File

@ -1,31 +1,15 @@
<script> <script>
import BaseComponent from '@primevue/core/basecomponent'; import BaseInput from '@primevue/core/baseinput';
import InputOtpStyle from 'primevue/inputotp/style'; import InputOtpStyle from 'primevue/inputotp/style';
export default { export default {
name: 'BaseInputOtp', name: 'BaseInputOtp',
extends: BaseComponent, extends: BaseInput,
props: { props: {
modelValue: {
type: null,
default: null
},
invalid: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
readonly: { readonly: {
type: Boolean, type: Boolean,
default: false default: false
}, },
variant: {
type: String,
default: null
},
tabindex: { tabindex: {
type: Number, type: Number,
default: null default: null

View File

@ -6,6 +6,7 @@
:value="tokens[i - 1]" :value="tokens[i - 1]"
:type="inputType" :type="inputType"
:class="cx('pcInputText')" :class="cx('pcInputText')"
:name="$formName"
:inputmode="inputMode" :inputmode="inputMode"
:variant="variant" :variant="variant"
:readonly="readonly" :readonly="readonly"
@ -34,7 +35,7 @@ export default {
name: 'InputOtp', name: 'InputOtp',
extends: BaseInputOtp, extends: BaseInputOtp,
inheritAttrs: false, inheritAttrs: false,
emits: ['update:modelValue', 'change', 'focus', 'blur'], emits: ['change', 'focus', 'blur'],
data() { data() {
return { return {
tokens: [] tokens: []
@ -76,7 +77,7 @@ export default {
updateModel(event) { updateModel(event) {
const newValue = this.tokens.join(''); const newValue = this.tokens.join('');
this.$emit('update:modelValue', newValue); this.updateValue(newValue, event);
this.$emit('change', { this.$emit('change', {
originalEvent: event, originalEvent: event,
value: newValue value: newValue