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
b12dd411
Commit
b12dd411
authored
Oct 12, 2018
by
Vladislav Lagunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Необязательный printItem в MultiSelect
parent
aa441891
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
MultiSelect.tsx
+6
-2
context.tsx
+2
-1
No files found.
MultiSelect.tsx
View file @
b12dd411
...
...
@@ -17,7 +17,7 @@ export type Props<A> = StandardProps<React.HTMLProps<HTMLDivElement>, string, 'v
textFieldProps
?:
Partial
<
TextFieldProps
>
;
renderSuggestion
?(
a
:
A
):
React
.
ReactNode
;
placeholder
?:
string
;
printItem
(
a
:
A
):
string
;
printItem
?
(
a
:
A
):
string
;
id
?:
string
;
// Используется для установки `key` пропсов
isEqual
?(
a
:
A
,
b
:
A
):
boolean
;
}
...
...
@@ -26,6 +26,10 @@ export type Props<A> = StandardProps<React.HTMLProps<HTMLDivElement>, string, 'v
// @ts-ignore Component
@
withStyles
(
styles
)
export
default
class
MultiSelect
<
A
>
extends
React
.
Component
<
Props
<
A
>>
{
static
defaultProps
=
{
printItem
:
String
,
};
handleDelete
=
memoize
((
idx
:
number
)
=>
(
e
?:
React
.
MouseEvent
<
HTMLDivElement
>
)
=>
{
const
{
value
,
onValueChange
,
disabled
}
=
this
.
props
;
if
(
disabled
)
return
;
const
nextValue
=
value
!
.
slice
();
...
...
@@ -67,7 +71,7 @@ export default class MultiSelect<A> extends React.Component<Props<A>> {
const
chipClassName
=
classNames
({
[
classes
!
.
disabled
!
]:
disabled
});
return
!
value
.
length
?
null
:
<
div
><
span
className=
{
classes
!
.
chips
}
>
{
value
!
.
map
((
ch
,
i
)
=>
(
<
Chip
key=
{
ch
[
id
]
}
className=
{
chipClassName
}
label=
{
printItem
(
ch
)
}
onClick=
{
this
.
handleDelete
(
i
)
}
onDelete=
{
this
.
handleDelete
(
i
)
}
/>
<
Chip
key=
{
ch
[
id
]
}
className=
{
chipClassName
}
label=
{
printItem
!
(
ch
)
}
onClick=
{
this
.
handleDelete
(
i
)
}
onDelete=
{
this
.
handleDelete
(
i
)
}
/>
))
}
</
span
></
div
>;
});
...
...
context.tsx
View file @
b12dd411
...
...
@@ -2,6 +2,7 @@ import * as React from 'react';
import
{
AuthCtx
as
Ctx
}
from
'~/context'
;
import
{
I18nString
}
from
'@bitmaster/utils/gettext'
;
import
{
ObjectPath
}
from
'~/utils'
;
import
*
as
gettext
from
'~/gettext'
;
const
hoistNonReactStatics
=
require
(
'hoist-non-react-statics'
);
...
...
@@ -71,4 +72,4 @@ export type Disabled = boolean|DisabledRecord;
export
interface
ErrorRecord
{
[
K
:
string
]:
Error
;
}
export
type
Error
=
boolean
|
I18nString
|
string
|
ErrorRecord
;
export
type
Error
=
boolean
|
I18nString
|
string
|
ErrorRecord
|
gettext
.
I18nString
;
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