Skip to content

Commit

Permalink
feat(input-autocomplete): revert arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
reme3d2y committed Nov 23, 2020
1 parent 99a87eb commit 07f0ef4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/input-autocomplete/src/Component.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ComponentHeader } from 'storybook/blocks/component-header';
import { Tag } from '@alfalab/core-components-tag';
import { Input } from '@alfalab/core-components-input';
import { MaskedInput } from '@alfalab/core-components-masked-input';
import { Option } from '@alfalab/core-components-select';
import { Arrow, Option } from '@alfalab/core-components-select';

import { InputAutocomplete } from './Component';

Expand Down Expand Up @@ -64,6 +64,7 @@ export const matchOption = (option, inputValue) =>
hint={text('hint', '')}
allowUnselect={boolean('allowUnselect', true)}
closeOnSelect={boolean('closeOnSelect', false)}
Arrow={boolean('Arrow', false) ? Arrow : undefined}
circularNavigation={boolean('circularNavigation', false)}
placeholder={text('placeholder', 'Введите элемент')}
label={text('label', 'Элемент')}
Expand Down Expand Up @@ -252,15 +253,15 @@ import { InputAutocomplete } from '@alfalab/core-components-input-autocomplete';
content: '4111 1111 1111 1111',
},
];
const CardOption = React.forwardRef((props, ref) => (
<Option {...props} ref={ref}>
const CardOption = (props) => (
<Option {...props}>
<div>
{props.option.key}
<br />
<sub>{props.option.content}</sub>
</div>
</Option>
));
);
const [value, setValue] = React.useState('');
const handleInput = (event) => {
setValue(event.target.value);
Expand Down Expand Up @@ -326,3 +327,11 @@ import { InputAutocomplete } from '@alfalab/core-components-input-autocomplete';
);
})}
</Preview>


### Автокомплит со стрелкой

```tsx
import { Arrow } from '@alfalab/core-components/select';
<InputAutocomplete Arrow={Arrow} />
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const AutocompleteField = ({
label,
placeholder,
size,
Arrow,
Input = DefaultInput,
value,
error,
Expand Down Expand Up @@ -58,6 +59,14 @@ export const AutocompleteField = ({
onClick={handleClick}
autoComplete='off'
value={value}
rightAddons={
(Arrow || inputProps.rightAddons) && (
<React.Fragment>
{inputProps.rightAddons}
{Arrow}
</React.Fragment>
)
}
/>
);
};

0 comments on commit 07f0ef4

Please sign in to comment.