Skip to content

Commit 10f07b2

Browse files
committed
feat: VUE-3 PlusMinus vue3
restore ipm-input event + fix event names
1 parent 91310ad commit 10f07b2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ in this library that you can override.
9595
You can also override style regrouped under `.int-pm` class.
9696

9797
### Events
98+
- 'ipm-input' is triggered on value change
9899
- 'ipm-increment' is triggered on value increment
99100
- 'ipm-decrement' is triggered on value decrement
100101

src/components/IntegerPlusminus.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const props = defineProps({
1818
const intValue = ref(0)
1919
const spinButton = ref(null)
2020
21-
const emit = defineEmits(['update:modelValue', 'imp-increment', 'imp-decrement'])
21+
const emit = defineEmits(['update:modelValue', 'ipm-input', 'ipm-increment', 'ipm-decrement'])
2222
2323
// computed
2424
const canIncrement = computed(() => {
@@ -47,6 +47,7 @@ watch(() => props.modelValue, (newValue, oldValue) => {
4747
const inputChange = () => {
4848
if (props.modelValue !== undefined) {
4949
emit('update:modelValue', intValue.value)
50+
emit('ipm-input', intValue.value)
5051
}
5152
}
5253
const isSpinButtonFocused = () => {
@@ -65,14 +66,14 @@ const setToMax = () => {
6566
const increment = () => {
6667
if (canIncrement.value) {
6768
intValue.value = intValue.value + props.step
68-
emit('imp-increment', intValue.value)
69+
emit('ipm-increment', intValue.value)
6970
inputChange()
7071
}
7172
}
7273
const decrement = () => {
7374
if (canDecrement.value) {
7475
intValue.value = intValue.value - props.step
75-
emit('imp-decrement', intValue.value)
76+
emit('ipm-decrement', intValue.value)
7677
inputChange()
7778
}
7879
}

0 commit comments

Comments
 (0)