Merge pull request #2476 from tugcekucukoglu/readonly
Fixed #2469 - InputNumber new readonly attributepull/2496/head
commit
1591c3e1e1
|
@ -131,6 +131,12 @@ const InputNumberProps = [
|
|||
default: "true",
|
||||
description: "Determines whether the input field is empty."
|
||||
},
|
||||
{
|
||||
name: "readonly",
|
||||
type: "boolean",
|
||||
default: "false",
|
||||
description: "When present, it specifies that an input field is read-only."
|
||||
},
|
||||
{
|
||||
name: "inputStyle",
|
||||
type: "any",
|
||||
|
|
|
@ -133,6 +133,10 @@ export interface InputNumberProps {
|
|||
* Default value is true.
|
||||
*/
|
||||
allowEmpty?: boolean | undefined;
|
||||
/**
|
||||
* When present, it specifies that an input field is read-only.
|
||||
*/
|
||||
readonly?: boolean | undefined;
|
||||
/**
|
||||
* Inline style of the input field.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<span :class="containerClass" :style="style">
|
||||
<INInputText ref="input" :class="['p-inputnumber-input', inputClass]" :style="inputStyle" :value="formattedValue" v-bind="$attrs" :aria-valumin="min" :aria-valuemax="max"
|
||||
<INInputText ref="input" :class="['p-inputnumber-input', inputClass]" :style="inputStyle" :value="formattedValue" v-bind="$attrs" :aria-valumin="min" :aria-valuemax="max" :readonly="readonly"
|
||||
@input="onUserInput" @keydown="onInputKeyDown" @keypress="onInputKeyPress" @paste="onPaste" @click="onInputClick" @focus="onInputFocus" @blur="onInputBlur"/>
|
||||
<span class="p-inputnumber-button-group" v-if="showButtons && buttonLayout === 'stacked'">
|
||||
<INButton :class="upButtonClass" :icon="incrementButtonIcon" v-on="upButtonListeners" :disabled="$attrs.disabled" />
|
||||
|
@ -108,6 +108,10 @@ export default {
|
|||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
style: null,
|
||||
class: null,
|
||||
inputStyle: null,
|
||||
|
@ -297,6 +301,10 @@ export default {
|
|||
return null;
|
||||
},
|
||||
repeat(event, interval, dir) {
|
||||
if (this.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
let i = interval || 500;
|
||||
|
||||
this.clearTimer();
|
||||
|
@ -379,6 +387,10 @@ export default {
|
|||
this.isSpecialChar = false;
|
||||
},
|
||||
onInputKeyDown(event) {
|
||||
if (this.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastValue = event.target.value;
|
||||
if (event.shiftKey || event.altKey) {
|
||||
this.isSpecialChar = true;
|
||||
|
@ -528,6 +540,10 @@ export default {
|
|||
}
|
||||
},
|
||||
onInputKeyPress(event) {
|
||||
if (this.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
let code = event.which || event.keyCode;
|
||||
let char = String.fromCharCode(code);
|
||||
|
@ -734,7 +750,9 @@ export default {
|
|||
return index || 0;
|
||||
},
|
||||
onInputClick() {
|
||||
this.initCursor();
|
||||
if (!this.readonly) {
|
||||
this.initCursor();
|
||||
}
|
||||
},
|
||||
isNumeralChar(char) {
|
||||
if (char.length === 1 && (this._numeral.test(char) || this._decimal.test(char) || this._group.test(char) || this._minusSign.test(char))) {
|
||||
|
|
|
@ -270,6 +270,12 @@ Vertical
|
|||
<td>allowEmpty</td>
|
||||
<td>boolean</td>
|
||||
<td>true</td>
|
||||
<td>When present, it specifies that an input field is read-only.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>readonly</td>
|
||||
<td>boolean</td>
|
||||
<td>false</td>
|
||||
<td>Determines whether the input field is empty.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
Loading…
Reference in New Issue