Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Kornkitt Poolsup
nexpie-grafana-theme
Commits
07ce88f6
Commit
07ce88f6
authored
Dec 11, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up hoc and extend component props automatically
parent
645812f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
14 deletions
+7
-14
public/app/features/dashboard/dashgrid/withKeyboardNavigation.tsx
+7
-14
No files found.
public/app/features/dashboard/dashgrid/withKeyboardNavigation.tsx
View file @
07ce88f6
import
React
from
'react'
;
import
{
Props
as
DataSourceProps
}
from
'./DataSourcePicker'
;
import
{
Props
as
VizTypeProps
}
from
'./VizTypePicker'
;
import
React
,
{
KeyboardEvent
,
ComponentType
,
Component
}
from
'react'
;
interface
State
{
selected
:
number
;
}
export
interface
KeyboardNavigationProps
{
selected
?:
number
;
on
KeyDown
?:
(
evt
:
React
.
KeyboardEvent
<
EventTarget
>
,
maxSelectedIndex
:
number
,
onEnterAction
:
()
=>
void
)
=>
void
;
onMouseEnter
?:
(
select
:
number
)
=>
void
;
onKeyDown
:
(
evt
:
KeyboardEvent
<
EventTarget
>
,
maxSelectedIndex
:
number
,
onEnterAction
:
()
=>
void
)
=>
void
;
on
MouseEnter
:
(
select
:
number
)
=>
void
;
selected
:
number
;
}
const
withKeyboardNavigation
=
WrappedComponent
=>
{
return
class
extends
React
.
Component
<
DataSourceProps
|
VizTypeProps
,
State
>
{
const
withKeyboardNavigation
=
<
P
extends
object
>
(WrappedComponent: ComponentType
<
P
&
KeyboardNavigationProps
>
)
=
>
{
return
class
WithKeyboardNavigation
extends
Component
<
P
,
State
>
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -58,12 +56,7 @@ const withKeyboardNavigation = WrappedComponent => {
render
()
{
return
(
<
WrappedComponent
selected=
{
this
.
state
.
selected
}
onKeyDown=
{
this
.
onKeyDown
}
onMouseEnter=
{
this
.
onMouseEnter
}
{
...
this
.
props
}
/>
<
WrappedComponent
{
...
this
.
state
}
{
...
this
.
props
}
onKeyDown=
{
this
.
onKeyDown
}
onMouseEnter=
{
this
.
onMouseEnter
}
/>
);
}
};
...
...
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