Commit 8c0cc47d by Vladislav Lagunov

-[fields] Тултип в AutoComplete

-[fields] Уменьшены иконки в полях ввода
parent 200d9f46
...@@ -15,6 +15,7 @@ import * as Rx from 'rxjs'; ...@@ -15,6 +15,7 @@ import * as Rx from 'rxjs';
import memoize from '~/functions/memoize'; import memoize from '~/functions/memoize';
import { pick } from 'lodash'; import { pick } from 'lodash';
import classNames = require('classnames'); import classNames = require('classnames');
import { withGettext, Gettext } from '~/gettext';
// Props // Props
...@@ -48,7 +49,9 @@ export type State<A> = AutoCompleteState<A> & { ...@@ -48,7 +49,9 @@ export type State<A> = AutoCompleteState<A> & {
// Component // Component
// @ts-ignore Хак для работы дженерик-параметров // @ts-ignore Хак для работы дженерик-параметров
@withStyles(styles) @withStyles(styles)
export default class AutoComplete<A=string> extends React.Component<Props<A>, State<A>> { // @ts-ignore
@withGettext(require('./i18n'))
export default class AutoComplete<A=string> extends React.Component<Props<A> & { __: Gettext }, State<A>> {
static defaultProps = { static defaultProps = {
openOnFocus: true, openOnFocus: true,
openOnClick: true, openOnClick: true,
...@@ -162,13 +165,13 @@ export default class AutoComplete<A=string> extends React.Component<Props<A>, St ...@@ -162,13 +165,13 @@ export default class AutoComplete<A=string> extends React.Component<Props<A>, St
this.subscription && (this.subscription.unsubscribe(), this.subscription = null); this.subscription && (this.subscription.unsubscribe(), this.subscription = null);
} }
endAdornment = memoize((nonNull: boolean, disabled: boolean) => <React.Fragment> endAdornment = memoize((nonNull: boolean, disabled: boolean, __: Gettext) => <React.Fragment>
<Icon onClick={disabled ? undefined : this.handleToggleVisibility}>arrow_drop_down</Icon> <Icon onClick={disabled ? undefined : this.handleToggleVisibility}>arrow_drop_down</Icon>
{!nonNull && <Icon onClick={disabled ? undefined : this.handleCloseClick}>close</Icon>} {!nonNull && <Icon onClick={disabled ? undefined : this.handleCloseClick} data-rh={__('Clear')}>close</Icon>}
</React.Fragment>); </React.Fragment>);
childrenProps = () => { childrenProps = () => {
const { nonNull, disabled } = this.props; const { nonNull, disabled, __ } = this.props;
return { return {
...pick(this.props, 'disabled', 'error', 'fullWidth', 'placeholder', 'ctx'), ...pick(this.props, 'disabled', 'error', 'fullWidth', 'placeholder', 'ctx'),
...@@ -179,7 +182,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A>, St ...@@ -179,7 +182,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A>, St
onBlur: disabled ? undefined : this.handleBlur, onBlur: disabled ? undefined : this.handleBlur,
onKeyDown: disabled ? undefined : this.handleKeyDown, onKeyDown: disabled ? undefined : this.handleKeyDown,
onClick: disabled ? undefined : this.handleClick, onClick: disabled ? undefined : this.handleClick,
endAdornment: this.endAdornment(!!nonNull, !!disabled), endAdornment: this.endAdornment(!!nonNull, !!disabled, __),
}; };
}; };
......
...@@ -128,7 +128,7 @@ function styles(theme: Theme): StyleRules<ClassKey> { ...@@ -128,7 +128,7 @@ function styles(theme: Theme): StyleRules<ClassKey> {
return { return {
root: { root: {
height: unit * 4.5, height: unit * 4,
boxSizing: 'border-box', boxSizing: 'border-box',
display: 'inline-flex', display: 'inline-flex',
alignItems: 'center', alignItems: 'center',
...@@ -138,6 +138,9 @@ function styles(theme: Theme): StyleRules<ClassKey> { ...@@ -138,6 +138,9 @@ function styles(theme: Theme): StyleRules<ClassKey> {
'&$error': { '&$error': {
background: `rgba(255,0,0,0.08)`, background: `rgba(255,0,0,0.08)`,
}, },
'& .material-icons': {
fontSize: 18,
},
}, },
disabled: { disabled: {
......
...@@ -5,8 +5,11 @@ msgstr "" ...@@ -5,8 +5,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
msgid "Fill out this field" msgid "Cannot be empty"
msgstr "Заполните это поле" msgstr "Заполните это поле"
msgid "Nothing found…" msgid "Nothing found…"
msgstr "Ничего не найдено…" msgstr "Ничего не найдено…"
msgid "Clear"
msgstr "Очистить"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment