๐ - Default Value support
rikusen0335 opened this issue ยท 3 comments
Which package(s) are relevant/related to the feature request?
@maskito/kit, @maskito/react
Description
when filtering items by price (on our situation), we want default value set to filters so that users won't need to remember what are they searching for.
My thouhgt is:
const Test = ({ defaultValue, ...props }) => {
const maskitoOptions = useMemo(
() =>
maskitoNumberOptionsGenerator({
thousandSeparator,
max: maxNumber,
min: 0,
defaultValue,
}),
[defaultValue, maxNumber, thousandSeparator]
)
const ref = useMaskito({ options: maskitoOptions })
return <CustomInput {...props} ref={ref}>
}
Current behavior:
setting defaultValue
directly CustomInput like 2000
, will results showing 2000
not 2,000
.
Unfortunately, I am not sure that I fully understand you problem ๐ข
Could you provide more description, please ?
Have you read this section of the documentation ?
https://maskito.dev/core-concepts/transformer
Probably, it can help you without any need to augment public API of Number
.
There is also maskitoInitialCalibrationPlugin
:
https://maskito.dev/core-concepts/plugins#initial-calibration
Probably, it can help you too.
Will look into this, thanks!
This worked as I expected, thanks!
const Test = ({ defaultValue: _defaultValue, ...props }) => {
const maskitoOptions = useMemo(
() =>
maskitoNumberOptionsGenerator({
thousandSeparator,
}),
[thousandSeparator]
)
const ref = useMaskito({ options: maskitoOptions })
const defaultValue = useMemo(
() => maskitoTransform(_defaultValue, maskitoOptions),
[_defaultValue, maskitoOptions]
)
return <CustomInput {...props} ref={ref} defaultValue={defaultValue}>
}