Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
5b5a737a
Commit
5b5a737a
authored
Sep 12, 2018
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #2124 add new api: onVisibleChange and open
parent
9e626603
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
3 deletions
+56
-3
src/components/GlobalHeader/index.less
src/components/GlobalHeader/index.less
+1
-0
src/components/HeaderSearch/index.d.ts
src/components/HeaderSearch/index.d.ts
+3
-0
src/components/HeaderSearch/index.en-US.md
src/components/HeaderSearch/index.en-US.md
+23
-0
src/components/HeaderSearch/index.js
src/components/HeaderSearch/index.js
+26
-2
src/components/HeaderSearch/index.zh-CN.md
src/components/HeaderSearch/index.zh-CN.md
+3
-1
No files found.
src/components/GlobalHeader/index.less
View file @
5b5a737a
...
@@ -48,6 +48,7 @@ i.trigger {
...
@@ -48,6 +48,7 @@ i.trigger {
.right {
.right {
float: right;
float: right;
height: 100%;
height: 100%;
overflow: hidden;
.action {
.action {
cursor: pointer;
cursor: pointer;
padding: 0 12px;
padding: 0 12px;
...
...
src/components/HeaderSearch/index.d.ts
View file @
5b5a737a
...
@@ -2,8 +2,11 @@ import * as React from 'react';
...
@@ -2,8 +2,11 @@ import * as React from 'react';
export
interface
IHeaderSearchProps
{
export
interface
IHeaderSearchProps
{
placeholder
?:
string
;
placeholder
?:
string
;
dataSource
?:
string
[];
dataSource
?:
string
[];
defaultOpen
:
boolean
;
open
:
boolean
;
onSearch
?:
(
value
:
string
)
=>
void
;
onSearch
?:
(
value
:
string
)
=>
void
;
onChange
?:
(
value
:
string
)
=>
void
;
onChange
?:
(
value
:
string
)
=>
void
;
onVisibleChange
?:
(
visible
:
boolean
)
=>
void
;
onPressEnter
?:
(
value
:
string
)
=>
void
;
onPressEnter
?:
(
value
:
string
)
=>
void
;
style
?:
React
.
CSSProperties
;
style
?:
React
.
CSSProperties
;
className
?:
string
;
className
?:
string
;
...
...
src/components/HeaderSearch/index.en-US.md
0 → 100644
View file @
5b5a737a
---
title
:
en-US
:
HeaderSearch
zh-CN
:
HeaderSearch
subtitle
:
Top search box
cols
:
1
order
:
8
---
Usually placed as an entry to the global search, placed on the right side of the navigation toolbar.
## API
参数 | 说明 | 类型 | 默认值
----|------|-----|------
placeholder | placeholder text | string | -
dataSource | current list of prompts | string[] | -
onSearch | Callback when selecting an item or pressing Enter | function(value) | -
onChange | Enter a callback for the search text | function(value) | -
onPressEnter | Callback when pressing Enter | function(value) | -
onVisibleChange | Show or hide the callback of the text box | function(value) |-
defaultOpen | The input box is displayed for the first time. | boolean | false
open | The input box is displayed | booelan |false
\ No newline at end of file
src/components/HeaderSearch/index.js
View file @
5b5a737a
...
@@ -15,6 +15,7 @@ export default class HeaderSearch extends PureComponent {
...
@@ -15,6 +15,7 @@ export default class HeaderSearch extends PureComponent {
defaultActiveFirstOption
:
PropTypes
.
bool
,
defaultActiveFirstOption
:
PropTypes
.
bool
,
dataSource
:
PropTypes
.
array
,
dataSource
:
PropTypes
.
array
,
defaultOpen
:
PropTypes
.
bool
,
defaultOpen
:
PropTypes
.
bool
,
onVisibleChange
:
PropTypes
.
func
,
};
};
static
defaultProps
=
{
static
defaultProps
=
{
...
@@ -25,8 +26,18 @@ export default class HeaderSearch extends PureComponent {
...
@@ -25,8 +26,18 @@ export default class HeaderSearch extends PureComponent {
placeholder
:
''
,
placeholder
:
''
,
dataSource
:
[],
dataSource
:
[],
defaultOpen
:
false
,
defaultOpen
:
false
,
onVisibleChange
:
()
=>
{},
};
};
static
getDerivedStateFromProps
(
props
)
{
if
(
'
open
'
in
props
)
{
return
{
searchMode
:
props
.
open
,
};
}
return
null
;
}
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
...
@@ -64,6 +75,8 @@ export default class HeaderSearch extends PureComponent {
...
@@ -64,6 +75,8 @@ export default class HeaderSearch extends PureComponent {
this
.
input
.
focus
();
this
.
input
.
focus
();
}
}
});
});
const
{
onVisibleChange
}
=
this
.
props
;
onVisibleChange
(
true
);
};
};
leaveSearchMode
=
()
=>
{
leaveSearchMode
=
()
=>
{
...
@@ -86,14 +99,25 @@ export default class HeaderSearch extends PureComponent {
...
@@ -86,14 +99,25 @@ export default class HeaderSearch extends PureComponent {
}
}
render
()
{
render
()
{
const
{
className
,
placeholder
,
...
restProps
}
=
this
.
props
;
const
{
className
,
placeholder
,
open
,
...
restProps
}
=
this
.
props
;
const
{
searchMode
,
value
}
=
this
.
state
;
const
{
searchMode
,
value
}
=
this
.
state
;
delete
restProps
.
defaultOpen
;
// for rc-select not affected
delete
restProps
.
defaultOpen
;
// for rc-select not affected
const
inputClass
=
classNames
(
styles
.
input
,
{
const
inputClass
=
classNames
(
styles
.
input
,
{
[
styles
.
show
]:
searchMode
,
[
styles
.
show
]:
searchMode
,
});
});
return
(
return
(
<
span
className
=
{
classNames
(
className
,
styles
.
headerSearch
)}
onClick
=
{
this
.
enterSearchMode
}
>
<
span
className
=
{
classNames
(
className
,
styles
.
headerSearch
)}
onClick
=
{
this
.
enterSearchMode
}
onTransitionEnd
=
{({
propertyName
})
=>
{
if
(
propertyName
===
'
width
'
)
{
if
(
!
searchMode
)
{
const
{
onVisibleChange
}
=
this
.
props
;
onVisibleChange
(
searchMode
);
}
}
}}
>
<
Icon
type
=
"
search
"
key
=
"
Icon
"
/>
<
Icon
type
=
"
search
"
key
=
"
Icon
"
/>
<
AutoComplete
<
AutoComplete
key
=
"
AutoComplete
"
key
=
"
AutoComplete
"
...
...
src/components/HeaderSearch/index.md
→
src/components/HeaderSearch/index.
zh-CN.
md
View file @
5b5a737a
...
@@ -18,4 +18,6 @@ dataSource | 当前提示内容列表 | string[] | -
...
@@ -18,4 +18,6 @@ dataSource | 当前提示内容列表 | string[] | -
onSearch | 选择某项或按下回车时的回调 | function(value) | -
onSearch | 选择某项或按下回车时的回调 | function(value) | -
onChange | 输入搜索字符的回调 | function(value) | -
onChange | 输入搜索字符的回调 | function(value) | -
onPressEnter | 按下回车时的回调 | function(value) | -
onPressEnter | 按下回车时的回调 | function(value) | -
defaultOpen | 输入框首次显示是否打开 | boolean | false
onVisibleChange | 显示或隐藏文本框的回调 | function(value) |-
defaultOpen | 输入框首次显示是否显示 | boolean | false
open | 控制输入框是否显示 | booelan |false
\ No newline at end of file
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