Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
common
Commits
e44c6488
Commit
e44c6488
authored
Dec 12, 2018
by
Vladislav Lagunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Исправления тайпингов
parent
15b21b11
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
12 deletions
+19
-12
create-form/index.ts
+2
-1
fields/AutoComplete.tsx
+5
-4
fields/Icon/index.tsx
+1
-2
fields/MomentField.tsx
+3
-3
gettext/index.ts
+8
-2
No files found.
create-form/index.ts
View file @
e44c6488
...
@@ -75,11 +75,12 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
...
@@ -75,11 +75,12 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
const
error
=
options
.
validate
?
options
.
validate
(
value
,
self
)
:
{};
const
error
=
options
.
validate
?
options
.
validate
(
value
,
self
)
:
{};
const
disabled
=
options
.
disabled
?
options
.
disabled
(
value
,
self
)
:
{};
const
disabled
=
options
.
disabled
?
options
.
disabled
(
value
,
self
)
:
{};
const
onValueChange
=
(
value
,
at
:
ObjectPath
=
[])
=>
dispatch
({
tag
:
'Change'
,
value
,
at
});
const
onValueChange
=
(
value
,
at
:
ObjectPath
=
[])
=>
dispatch
({
tag
:
'Change'
,
value
,
at
});
const
zoomedError
=
zoomAny
(
keys
,
error
);
return
{
return
{
ctx
,
ctx
,
value
:
zoomAny
(
keys
,
value
),
value
:
zoomAny
(
keys
,
value
),
error
:
zoomAny
(
keys
,
error
)
,
error
:
typeof
(
zoomedError
)
===
'function'
&&
ctx
?
zoomedError
(
ctx
)
:
zoomedError
,
disabled
:
zoomAny
(
keys
,
disabled
),
disabled
:
zoomAny
(
keys
,
disabled
),
onValueChange
:
zoomOnChange
(
keys
,
onValueChange
),
onValueChange
:
zoomOnChange
(
keys
,
onValueChange
),
};
};
...
...
fields/AutoComplete.tsx
View file @
e44c6488
...
@@ -22,6 +22,7 @@ import { fade } from '@material-ui/core/styles/colorManipulator';
...
@@ -22,6 +22,7 @@ import { fade } from '@material-ui/core/styles/colorManipulator';
// Props
// Props
export
type
Props
<
A
>
=
StandardProps
<
React
.
HTMLProps
<
HTMLDivElement
>
,
string
,
'value'
|
'disabled'
>
&
FieldProps
<
A
>
&
{
export
type
Props
<
A
>
=
StandardProps
<
React
.
HTMLProps
<
HTMLDivElement
>
,
string
,
'value'
|
'disabled'
>
&
FieldProps
<
A
>
&
{
ctx
?:
Ctx
;
ctx
?:
Ctx
;
__
?:
Gettext
;
source
:
Source
<
A
>
;
source
:
Source
<
A
>
;
debounce
?:
number
;
debounce
?:
number
;
renderItem
?:
SuggestionProps
[
'renderSuggestion'
];
renderItem
?:
SuggestionProps
[
'renderSuggestion'
];
...
@@ -52,7 +53,7 @@ export type State<A> = AutoCompleteState<A> & {
...
@@ -52,7 +53,7 @@ export type State<A> = AutoCompleteState<A> & {
@
withStyles
(
styles
)
@
withStyles
(
styles
)
// @ts-ignore
// @ts-ignore
@
withGettext
(
require
(
'./i18n'
))
@
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
=
{
static
defaultProps
=
{
openOnFocus
:
true
,
openOnFocus
:
true
,
openOnClick
:
true
,
openOnClick
:
true
,
...
@@ -194,7 +195,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
...
@@ -194,7 +195,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
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
,
__
!
),
};
};
};
};
...
@@ -213,7 +214,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
...
@@ -213,7 +214,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
if
(
total
!==
0
&&
limit
+
offset
>=
total
)
return
null
;
if
(
total
!==
0
&&
limit
+
offset
>=
total
)
return
null
;
return
<
ListItem
className=
{
classes
!
.
seeMore
}
>
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
>;
</
ListItem
>;
}
}
render
()
{
render
()
{
...
@@ -226,7 +227,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
...
@@ -226,7 +227,7 @@ export default class AutoComplete<A=string> extends React.Component<Props<A> & {
return
<
div
{
...
rest
}
className=
{
rootClass
}
>
return
<
div
{
...
rest
}
className=
{
rootClass
}
>
{
!
observable
&&
(
children
?
React
.
cloneElement
(
children
,
this
.
childrenProps
())
:
<
TextField
{
...
this
.
childrenProps
()
as
any
}
{
...
textFieldProps
}
/>)
}
{
!
observable
&&
(
children
?
React
.
cloneElement
(
children
,
this
.
childrenProps
())
:
<
TextField
{
...
this
.
childrenProps
()
as
any
}
{
...
textFieldProps
}
/>)
}
<
Suggestions
<
Suggestions
{
...
suggestionProps
}
{
...
suggestionProps
as
any
}
pending=
{
pending
}
pending=
{
pending
}
ctx=
{
ctx
!
}
ctx=
{
ctx
!
}
anchorEl=
{
anchorEl
||
this
.
anchorEl
||
undefined
}
anchorEl=
{
anchorEl
||
this
.
anchorEl
||
undefined
}
...
...
fields/Icon/index.tsx
View file @
e44c6488
...
@@ -6,7 +6,7 @@ import * as classNames from 'classnames';
...
@@ -6,7 +6,7 @@ import * as classNames from 'classnames';
// Component
// Component
class
IconComponent
extends
React
.
Component
<
IconProps
&
WithStyles
>
{
class
IconComponent
extends
React
.
Component
<
IconProps
&
WithStyles
<
string
>
>
{
render
()
{
render
()
{
const
{
classes
,
className
}
=
this
.
props
;
const
{
classes
,
className
}
=
this
.
props
;
const
rootClass
=
classNames
(
className
,
{
const
rootClass
=
classNames
(
className
,
{
...
@@ -20,7 +20,6 @@ class IconComponent extends React.Component<IconProps & WithStyles> {
...
@@ -20,7 +20,6 @@ class IconComponent extends React.Component<IconProps & WithStyles> {
export
default
withStyles
(
styles
)(
IconComponent
);
export
default
withStyles
(
styles
)(
IconComponent
);
// Styles
// Styles
export
function
styles
(
theme
:
Theme
):
StyleRules
{
export
function
styles
(
theme
:
Theme
):
StyleRules
{
// const { unit } = theme.spacing;
// const { unit } = theme.spacing;
...
...
fields/MomentField.tsx
View file @
e44c6488
import
*
as
React
from
'react'
;
import
*
as
React
from
'react'
;
import
*
as
ReactDOM
from
'react-dom'
;
import
*
as
ReactDOM
from
'react-dom'
;
import
{
Theme
}
from
'@material-ui/core/styles/createMuiTheme'
;
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
{
FieldProps
}
from
'~/create-form'
;
import
*
as
moment
from
'moment'
;
import
*
as
moment
from
'moment'
;
import
TextField
,
{
Props
as
TextFieldProps
}
from
'./TextField'
;
import
TextField
,
{
Props
as
TextFieldProps
}
from
'./TextField'
;
...
@@ -13,7 +13,7 @@ import DayPicker from 'react-dates/lib/components/DayPicker';
...
@@ -13,7 +13,7 @@ import DayPicker from 'react-dates/lib/components/DayPicker';
// Props
// 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
>
;
InputProps
?:
Partial
<
TextFieldProps
>
;
format
?:
string
;
format
?:
string
;
nonNull
?:
boolean
;
nonNull
?:
boolean
;
...
@@ -146,7 +146,7 @@ class MomentField extends React.Component<Props, State> {
...
@@ -146,7 +146,7 @@ class MomentField extends React.Component<Props, State> {
{
...
InputProps
as
any
}
{
...
InputProps
as
any
}
disabled=
{
disabled
}
disabled=
{
disabled
}
error=
{
error
}
error=
{
error
}
className=
{
classes
.
input
}
className=
{
classes
!
.
input
}
onValueChange=
{
this
.
handleChange
}
onValueChange=
{
this
.
handleChange
}
onBlur=
{
this
.
handleBlur
}
onBlur=
{
this
.
handleBlur
}
onKeyDown=
{
this
.
handleKeyDown
}
onKeyDown=
{
this
.
handleKeyDown
}
...
...
gettext/index.ts
View file @
e44c6488
...
@@ -87,7 +87,7 @@ export function withGettext(...webpackContexts) {
...
@@ -87,7 +87,7 @@ export function withGettext(...webpackContexts) {
makeGettext
:
(
locale
?:
string
|
LocaleCtx
)
=>
Gettext
=
memoize
((
locale
)
=>
translations
.
bind
(
locale
))
makeGettext
:
(
locale
?:
string
|
LocaleCtx
)
=>
Gettext
=
memoize
((
locale
)
=>
translations
.
bind
(
locale
))
render
()
{
render
()
{
const
{
ctx
}
=
this
.
props
;
const
{
ctx
}
=
this
.
props
as
any
;
// @ts-ignore
// @ts-ignore
const
locale
=
ctx
?
(
ctx
.
locale
||
'en-US'
)
:
'en-US'
;
const
locale
=
ctx
?
(
ctx
.
locale
||
'en-US'
)
:
'en-US'
;
return
React
.
createElement
(
Component
as
any
,
{
...
this
.
props
as
any
,
__
:
this
.
makeGettext
(
locale
)
});
return
React
.
createElement
(
Component
as
any
,
{
...
this
.
props
as
any
,
__
:
this
.
makeGettext
(
locale
)
});
...
@@ -106,6 +106,12 @@ export function withGettext(...webpackContexts) {
...
@@ -106,6 +106,12 @@ export function withGettext(...webpackContexts) {
*/
*/
function
assignData
(
dst
:
TranslationsData
,
...
srcs
:
POData
[]):
TranslationsData
{
function
assignData
(
dst
:
TranslationsData
,
...
srcs
:
POData
[]):
TranslationsData
{
srcs
.
forEach
(
data
=>
{
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
// @ts-ignore
const
locale_
=
data
[
''
].
language
||
data
[
''
].
lang
||
data
[
''
].
locale
;
if
(
!
locale_
||
typeof
(
locale_
)
!==
'string'
)
return
;
const
locale_
=
data
[
''
].
language
||
data
[
''
].
lang
||
data
[
''
].
locale
;
if
(
!
locale_
||
typeof
(
locale_
)
!==
'string'
)
return
;
const
locale
=
locale_
.
replace
(
/_/g
,
'-'
);
const
locale
=
locale_
.
replace
(
/_/g
,
'-'
);
...
@@ -113,7 +119,7 @@ function assignData(dst: TranslationsData, ...srcs: POData[]): TranslationsData
...
@@ -113,7 +119,7 @@ function assignData(dst: TranslationsData, ...srcs: POData[]): TranslationsData
if
(
k
===
''
)
continue
;
if
(
k
===
''
)
continue
;
dst
[
locale
]
=
dst
[
locale
]
||
{};
dst
[
locale
]
=
dst
[
locale
]
||
{};
if
(
Array
.
isArray
(
data
[
k
]))
{
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
];
if
(
dst
[
locale
][
k
].
length
===
1
)
dst
[
locale
][
k
]
=
dst
[
locale
][
k
][
0
];
}
else
{
}
else
{
dst
[
locale
][
k
]
=
data
[
k
];
dst
[
locale
][
k
]
=
data
[
k
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment