@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
57 lines • 3.45 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from 'react';
import { useInput } from '../../hooks/useInput/useInput';
import { useStyles } from '../../hooks/useStyles/useStyles';
import { ErrorBoundary } from '../../provider/errorBoundary/errorBoundary';
import { FallbackComponent } from '../../provider/errorBoundary/fallbackComponent';
// helpers
import { INTERNAL_ERROR_EXECUTION } from '../input/types/input';
import { InputTypeType } from '../input/types/inputType';
import { InputCurrencyStandAlone } from './inputCurrencyStandAlone';
const INPUT_CURRENCY_STYLES = 'INPUT_CURRENCY_STYLES';
const InputCurrencyComponent = React.forwardRef(({ maxDecimals = 2, truncate = true, min = 0, internalErrorExecution = INTERNAL_ERROR_EXECUTION.ON_CHANGE_ON_BLUR, disabledArrowUpDownInputNumber = false, ignoreKeys = ['+', '-', 'e'], disabledWheelMouse = true, disabledCopyAndPaste, type = InputTypeType.NUMBER, max, errorExecution, keyValidation, maxLength, minLength, mask, maskType, disabled, error, value: currentValue, informationAssociatedValue, regex, formatNumber, locale, variant, onBlur, onChange, onFocus, onKeyDown, onError, onInternalErrors, onPaste, ctv, ...props }, ref) => {
const styles = useStyles(INPUT_CURRENCY_STYLES, variant, ctv);
const inputCurrencyType = formatNumber ? InputTypeType.TEXT : type;
// if formatNumber is true (input element of type text), min and maxDecimals should be undefined because it will be handled by the formatNumber function
const inputCurrencyMin = formatNumber ? undefined : min;
const inputCurrencyMaxDecimals = formatNumber ? undefined : maxDecimals;
const { value, state, inputRef, handleChangeInternal, handleBlurInternal, handleFocusInternal, handleKeyDownInternal, handlePasteInternal, } = useInput({
ref,
errorExecution,
internalErrorExecution,
keyValidation,
max,
min: inputCurrencyMin,
maxLength,
minLength,
mask,
maskType,
disabled,
disabledArrowUpDownInputNumber,
error,
currentValue,
type: inputCurrencyType,
maxDecimals: inputCurrencyMaxDecimals,
truncate,
informationAssociated: informationAssociatedValue?.content,
ignoreKeys,
regex,
formatNumber,
locale,
disabledWheelMouse,
disabledCopyAndPaste,
onBlur,
onChange,
onFocus,
onKeyDown,
onError,
onInternalErrors,
onPaste,
});
return (_jsx(InputCurrencyStandAlone, { ...props, ref: inputRef, informationAssociatedValue: informationAssociatedValue, max: max, maxDecimals: maxDecimals, maxLength: maxLength, min: inputCurrencyMin, minLength: minLength, state: state, styles: styles, truncate: truncate, type: inputCurrencyType, value: value, onBlur: handleBlurInternal, onChange: handleChangeInternal, onFocus: handleFocusInternal, onKeyDown: handleKeyDownInternal, onPaste: handlePasteInternal }));
});
InputCurrencyComponent.displayName = 'InputCurrencyComponent';
const InputCurrencyBoundary = (props, ref) => (_jsx(ErrorBoundary, { fallBackComponent: _jsx(FallbackComponent, { children: _jsx(InputCurrencyStandAlone, { ...props, ref: ref }) }), children: _jsx(InputCurrencyComponent, { ...props, ref: ref }) }));
const InputCurrency = React.forwardRef(InputCurrencyBoundary);
export { InputCurrency };
//# sourceMappingURL=inputCurrency.js.map