Author Image

joabsilvalima

Apr 22, 2024

Configuração de Máscara de Moeda em Software React

integraçãodesenvolvimentoSoftwareReactPropTypesMaskedInputcreateNumberMaskCurrencyInput

isso eu mudo em algum arquivo do gerencianet ou no meu software?

Respostas (2):
Avatar discord do usuario rubenskuhl

rubenskuhl

22/04/2024

Do seu software.

Avatar discord do usuario joabsilvalima

joabsilvalima

22/04/2024

import React from 'react'
import PropTypes from 'prop-types'
import MaskedInput from 'react-text-mask'
import createNumberMask from 'text-mask-addons/dist/createNumberMask'

const defaultMaskOptions = {
prefix: 'R$',
suffix: '',
includeThousandsSeparator: true,
thousandsSeparatorSymbol: '.',
allowDecimal: true,
decimalSymbol: ',',
decimalLimit: 2, // how many digits allowed after the decimal
integerLimit: 7, // limit length of integer numbers
allowNegative: false,
allowLeadingZeroes: false,
}

const CurrencyInput = ({ maskOptions, ...inputProps }) => {
const currencyMask = createNumberMask({
...defaultMaskOptions,
...maskOptions,
})

return
}

CurrencyInput.defaultProps = {
inputMode: 'numeric',
maskOptions: {},
}

CurrencyInput.propTypes = {
inputmode: PropTypes.string,
maskOptions: PropTypes.shape({
prefix: PropTypes.string,
suffix: PropTypes.string,
includeThousandsSeparator: PropTypes.bool,
thousandsSeparatorSymbol: PropTypes.string,
allowDecimal: PropTypes.bool,
decimalSymbol: PropTypes.string,
decimalLimit: PropTypes.string,
requireDecimal: PropTypes.bool,
allowNegative: PropTypes.bool,
allowLeadingZeroes: PropTypes.bool,
integerLimit: PropTypes.number,
}),
}

export default CurrencyInput