Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components/atom/input): Enable full input features on Mask input #2756

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions components/atom/input/demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ const TypeDemo = () => {
)
}
],
[
'MASK WITH RIGHT ICON',
{
type: inputTypes.MASK,
mask: {mask: Number},
placeholder: 'ES00 0000 0000 00 0000000000',
charsSize: 31,
value: '100000',
rightIcon: '€',
radix: ',',
thousandsSeparator: '.',
mapToRadix: ['.']
},
{
description: (
<>
Let the user define its own mask for custom purposes. More info at{' '}
<Anchor href="http://shorturl.at/foBF1">http://shorturl.at/foBF1</Anchor>
</>
)
}
],
[
'NUMBER',
{
Expand Down
2 changes: 1 addition & 1 deletion components/atom/input/src/Mask/iMask.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {IMaskMixin} from 'react-imask'

import Input from '../Input/Component/index.js'
import Input from '../Input/index.js'

const IMask = IMaskMixin(({inputRef, value, size, ...props}) => {
return <Input type="text" ref={inputRef} size={size} value={value} {...props} />
Expand Down
26 changes: 26 additions & 0 deletions components/atom/input/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,32 @@ describe(json.name, () => {
expect(findClassName(container.innerHTML)).to.be.null
expect(value).to.equal('')
})

it('should be able to display addons', () => {
const props = {
className: 'extended-classNames',
type: pkg.inputTypes.MASK,
mask: {mask: Number},
placeholder: 'Ex: 100.000,00',
charsSize: 31,
value: '100000',
rightIcon: '€',
radix: ',',
thousandsSeparator: '.',
mapToRadix: ['.'],
leftAddon: 'leftAddon',
rightAddon: 'rightAddon'
}

// When
const {getByRole, getByText} = setup(props)
const input = getByRole('textbox')

// Then
expect(input).to.have.value('100.000')
expect(getByText('leftAddon')).to.exist
expect(getByText('rightAddon')).to.exist
})
})

describe(`${Component.displayName} ${pkg.inputTypes.SUI_PASSWORD}`, () => {
Expand Down
Loading