Commit e44c6488 by Vladislav Lagunov

Исправления тайпингов

parent 15b21b11
......@@ -75,11 +75,12 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
const error = options.validate ? options.validate(value, self) : {};
const disabled = options.disabled ? options.disabled(value, self) : {};
const onValueChange = (value, at: ObjectPath=[]) => dispatch({ tag: 'Change', value, at });
const zoomedError = zoomAny(keys, error);
return {
ctx,
value: zoomAny(keys, value),
error: zoomAny(keys, error),
error: typeof(zoomedError) === 'function' && ctx ? zoomedError(ctx) : zoomedError,
disabled: zoomAny(keys, disabled),
onValueChange: zoomOnChange(keys, onValueChange),
};
......
......@@ -22,6 +22,7 @@ import { fade } from '@material-ui/core/styles/colorManipulator';
// Props
export type Props<A> = StandardProps<React.HTMLProps<HTMLDivElement>, string, 'value'|'disabled'> & FieldProps<A> & {
ctx?: Ctx;
__?: Gettext;
source: Source<A>;
debounce?: number;
renderItem?: SuggestionProps['renderSuggestion'];
......@@ -52,7 +53,7 @@ export type State<A> = AutoCompleteState<A> & {
@withStyles(styles)
// @ts-ignore
@withGettext(require('./i18n'))
export default class AutoComplete<A=string> extends React.Component<Props<A> & { __: Gettext }, State<A>> {
export default class AutoComplete<A=string> extends React.Component<Props<A>, State<A>> {
static defaultProps = {
openOnFocus: true,
openOnClick: true,
......@@ -194,7 +195,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
onBlur: disabled ? undefined : this.handleBlur,
onKeyDown: disabled ? undefined : this.handleKeyDown,
onClick: disabled ? undefined : this.handleClick,
endAdornment: this.endAdornment(!!nonNull, !!disabled, __),
endAdornment: this.endAdornment(!!nonNull, !!disabled, __!),
};
};
......@@ -213,7 +214,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
if (total !== 0 && limit + offset >= total) return null;
return <ListItem className={classes!.seeMore}>
<a href="javascript://void 0" onMouseDown={this.handleSeeMore}>{__('See more')}</a>
<a href="javascript://void 0" onMouseDown={this.handleSeeMore}>{__!('See more')}</a>
</ListItem>;
}
render() {
......@@ -226,7 +227,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
return <div {...rest} className={rootClass}>
{!observable && (children ? React.cloneElement(children, this.childrenProps()) : <TextField {...this.childrenProps() as any} {...textFieldProps}/>)}
<Suggestions
{...suggestionProps}
{...suggestionProps as any}
pending={pending}
ctx={ctx!}
anchorEl={anchorEl || this.anchorEl || undefined}
......
......@@ -6,7 +6,7 @@ import * as classNames from 'classnames';
// Component
class IconComponent extends React.Component<IconProps & WithStyles> {
class IconComponent extends React.Component<IconProps & WithStyles<string>> {
render() {
const { classes, className } = this.props;
const rootClass = classNames(className, {
......@@ -20,7 +20,6 @@ class IconComponent extends React.Component<IconProps & WithStyles> {
export default withStyles(styles)(IconComponent);
// Styles
export function styles(theme: Theme): StyleRules {
// const { unit } = theme.spacing;
......
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Theme } from '@material-ui/core/styles/createMuiTheme';
import withStyles, { WithStyles, StyleRules } from '@material-ui/core/styles/withStyles';
import withStyles, { StyleRules } from '@material-ui/core/styles/withStyles';
import { FieldProps } from '~/create-form';
import * as moment from 'moment';
import TextField, { Props as TextFieldProps } from './TextField';
......@@ -13,7 +13,7 @@ import DayPicker from 'react-dates/lib/components/DayPicker';
// Props
export type Props = StandardProps<React.HTMLProps<HTMLDivElement>, ClassKey, 'value'> & FieldProps<moment.Moment> & WithStyles<ClassKey> & {
export type Props = StandardProps<React.HTMLProps<HTMLDivElement>, ClassKey, 'value'|'disabled'> & FieldProps<moment.Moment> & {
InputProps?: Partial<TextFieldProps>;
format?: string;
nonNull?: boolean;
......@@ -146,7 +146,7 @@ class MomentField extends React.Component<Props, State> {
{...InputProps as any}
disabled={disabled}
error={error}
className={classes.input}
className={classes!.input}
onValueChange={this.handleChange}
onBlur={this.handleBlur}
onKeyDown={this.handleKeyDown}
......
......@@ -87,7 +87,7 @@ export function withGettext(...webpackContexts) {
makeGettext: (locale?: string|LocaleCtx) => Gettext = memoize((locale) => translations.bind(locale))
render() {
const { ctx } = this.props;
const { ctx } = this.props as any;
// @ts-ignore
const locale = ctx ? (ctx.locale || 'en-US') : 'en-US';
return React.createElement(Component as any, { ...this.props as any, __: this.makeGettext(locale) });
......@@ -106,6 +106,12 @@ export function withGettext(...webpackContexts) {
*/
function assignData(dst: TranslationsData, ...srcs: POData[]): TranslationsData {
srcs.forEach(data => {
let is_jed_1_format = false;
if (data['locale_data']) {
is_jed_1_format = true;
data = data['locale_data']['messages'];
}
// @ts-ignore
const locale_ = data[''].language || data[''].lang || data[''].locale; if (!locale_ || typeof(locale_) !== 'string') return;
const locale = locale_.replace(/_/g, '-');
......@@ -113,7 +119,7 @@ function assignData(dst: TranslationsData, ...srcs: POData[]): TranslationsData
if (k === '') continue;
dst[locale] = dst[locale] || {};
if (Array.isArray(data[k])) {
dst[locale][k] = data[k].slice(1);
dst[locale][k] = is_jed_1_format ? data[k] : data[k].slice(1);
if (dst[locale][k].length === 1) dst[locale][k] = dst[locale][k][0];
} else {
dst[locale][k] = data[k];
......
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