Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sysvale/cuida",
"version": "3.155.0",
"version": "3.155.1",
"description": "A design system built by Sysvale, using storybook and Vue components",
"repository": {
"type": "git",
Expand Down
17 changes: 16 additions & 1 deletion src/components/NumberInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,24 @@ let cdsBrlBiding = {};

/* WATCHERS */
watch(model, (newValue, oldValue) => {
if (newValue !== oldValue) {
if (newValue === oldValue) return;

if (!props.money) {
internalValue.value = newValue;
return;
}

if (typeof newValue === 'number') {
internalValue.value = `R$ ${newValue.toFixed(2).replace('.', ',')}`;
return;
}

if (typeof newValue === 'string' && newValue.startsWith('R$')) {
internalValue.value = newValue;
return;
}

internalValue.value = `R$ ${newValue.replace('.', ',')}`;
Comment thread
lucasn4s marked this conversation as resolved.
Outdated
Comment thread
lucasn4s marked this conversation as resolved.
Outdated
}, {immediate: true});

watch(internalValue, (value, oldValue) => {
Expand Down
5 changes: 4 additions & 1 deletion src/utils/directives/cdsBRL.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const vCdsBrl = {
let currentValue = String(event.target.value || '');

let onlyNumbers = currentValue.replace(/\D/g, '');
let number = parseFloat(onlyNumbers) / 100;
if (onlyNumbers.length > 1 && onlyNumbers.startsWith('0')) {
onlyNumbers = onlyNumbers.replace(/^0+/, '');
}
let number = parseFloat(onlyNumbers || '0') / 100;

const formattedValue = formatValue(currentValue);
event.target.value = formattedValue;
Expand Down
Loading