Skip to content

Commit

Permalink
feat: handle max number input (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkri authored Aug 17, 2023
1 parent 79ad129 commit 30c9b59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@supplycart/ui",
"version": "1.14.33",
"version": "1.14.34",
"repository": {
"type": "git",
"url": "https://github.com/supplycart/ui"
Expand Down
10 changes: 10 additions & 0 deletions src/form/components/QuantityInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
v-if="onFocus"
v-bind="$attrs"
type="number"
:max="maximumValue"
:label="label"
v-model="input"
:error="error"
Expand Down Expand Up @@ -34,6 +35,10 @@ export default {
components: { BaseInput },
mixins: [InputMixins],
props: {
maximumValue: {
type: Number,
default: null,
},
maxDecimal: {
type: Number,
default: 0,
Expand Down Expand Up @@ -104,6 +109,11 @@ export default {
if (!this.allowNegative && value < 0) {
emitValue = Number(value) * -1;
}
if (this.maximumValue != null && emitValue > this.maximumValue) {
emitValue = this.maximumValue
}
return emitValue;
},
blur(e) {
Expand Down

0 comments on commit 30c9b59

Please sign in to comment.