Xinon mobile/improve

This commit is contained in:
Luca Haid
2026-01-17 12:48:08 +00:00
parent 51c9c5ae7e
commit 1426d769d2
37 changed files with 7502 additions and 1042 deletions

View File

@@ -0,0 +1,43 @@
export function useNumericKeypad(initialValue = '1') {
const { ref } = Vue;
const quantity = ref(initialValue);
const appendDigit = (digit) => {
if (digit === '.' && quantity.value.includes('.')) return;
if (quantity.value === '0' && digit !== '.') {
quantity.value = digit;
} else {
quantity.value += digit;
}
};
const deleteDigit = () => {
quantity.value = quantity.value.length > 1 ? quantity.value.slice(0, -1) : '0';
};
const clearQuantity = () => {
quantity.value = '0';
};
const setQuantity = (value) => {
quantity.value = String(value);
};
const increment = (amount = 1) => {
quantity.value = String(Math.max(1, parseFloat(quantity.value) + amount));
};
const decrement = (amount = 1) => {
quantity.value = String(Math.max(1, parseFloat(quantity.value) - amount));
};
return {
quantity,
appendDigit,
deleteDigit,
clearQuantity,
setQuantity,
increment,
decrement
};
}