diff --git a/CHANGELOG.md b/CHANGELOG.md
index 680526640..ddc0dd71a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# 更新日志
+## 2.5.3
+- 修复 `` 异步多选在输入关键字时会清除已选择项的问题 [#746](https://github.com/XiaoMi/hiui/issues/746)
+- 修复 `` 在某些情况下导致页面布局发生变化的问题 [#749](https://github.com/XiaoMi/hiui/issues/749)
+- 修改 `` photo 模式、drag 模式下超出数量限制的展现形式 [#756](https://github.com/XiaoMi/hiui/issues/756)
+- 修复 `` 组件的控制台警告 [#760](https://github.com/XiaoMi/hiui/issues/760)
+- 变更 ``、``、`
` 的远程 Mock 数据地址
+
## 2.5.2
- 修复 `` 编辑模式下删除最后一个 tab 报错的问题 [#735](https://github.com/XiaoMi/hiui/issues/735)
diff --git a/components/loading/Loading.js b/components/loading/Loading.js
index 7609259ea..567c386d3 100755
--- a/components/loading/Loading.js
+++ b/components/loading/Loading.js
@@ -60,8 +60,10 @@ function PortalWrapper ({ mountNode, children }) {
function open (target, { content, key, duration, size } = {}) {
let renderNode = document.createElement('div')
const mountNode = target || document.body
- window.getComputedStyle(mountNode).position === 'absolute' ||
+ mountNode.nodeName !== 'BODY' && (
+ window.getComputedStyle(mountNode).position === 'absolute' ||
mountNode.style.setProperty('position', 'relative')
+ )
const full = !target
ReactDOM.render(
,
@@ -79,8 +81,10 @@ function open (target, { content, key, duration, size } = {}) {
function deprecatedOpen ({ target, tip } = {}) {
let renderNode = document.createElement('div')
const mountNode = target || document.body
- window.getComputedStyle(mountNode).position === 'absolute' ||
+ mountNode.nodeName !== 'BODY' && (
+ window.getComputedStyle(mountNode).position === 'absolute' ||
mountNode.style.setProperty('position', 'relative')
+ )
const full = !target
ReactDOM.render(
,
diff --git a/components/locales/en-US.js b/components/locales/en-US.js
index c98516a28..9fd9e6f90 100644
--- a/components/locales/en-US.js
+++ b/components/locales/en-US.js
@@ -57,6 +57,7 @@ export default {
delete: 'Delete',
drag: 'Drag and drop files for uploading',
dragTips: 'Please click or drag and drop file upload',
+ dragTipsLimited: 'The number has reached the upper limit',
preview: 'Preview'
},
modal: {
diff --git a/components/locales/zh-CN.js b/components/locales/zh-CN.js
index 42e7e6d35..0196b1274 100644
--- a/components/locales/zh-CN.js
+++ b/components/locales/zh-CN.js
@@ -58,6 +58,7 @@ export default {
delete: '删除',
drag: '拖拽文件上传',
dragTips: '请点击或拖拽文件上传',
+ dragTipsLimited: '数量已达上限',
preview: '预览'
},
modal: {
diff --git a/components/rate/Rate.js b/components/rate/Rate.js
index 59bf9772e..82074bef3 100644
--- a/components/rate/Rate.js
+++ b/components/rate/Rate.js
@@ -18,6 +18,7 @@ class Rate extends Component {
value
}
}
+ return null
}
state = {
value: 0,
diff --git a/components/select/Select.js b/components/select/Select.js
index 700a2d13d..131cfe09e 100644
--- a/components/select/Select.js
+++ b/components/select/Select.js
@@ -70,7 +70,7 @@ class Select extends Component {
const { data, value, defaultValue } = props
const dropdownItems = cloneDeep(data)
const initialValue = value === undefined ? defaultValue : value
- const selectedItems = this.resetSelectedItems(initialValue, dropdownItems)
+ const selectedItems = this.resetSelectedItems(initialValue, dropdownItems, [])
const searchable = this.getSearchable()
this.debouncedFilterItems = debounce(this.onFilterItems.bind(this), 300)
this.clickOutsideHandel = this.clickOutside.bind(this)
@@ -124,7 +124,7 @@ class Select extends Component {
const selectedItems = this.resetSelectedItems(
nextProps.value || this.state.selectedItems,
nextProps.data,
- true
+ this.state.selectedItems
)
this.setState({
selectedItems,
@@ -162,11 +162,11 @@ class Select extends Component {
}
isRemote () {
- const { dataSource } = this.props
- return dataSource && !!dataSource.url
+ const { dataSource, onSearch } = this.props
+ return onSearch || (dataSource && !!dataSource.url)
}
- resetSelectedItems (value, dropdownItems = [], listChanged = false) {
+ resetSelectedItems (value, dropdownItems = [], reviceSelectedItems = []) {
const values = this.parseValue(value)
let selectedItems = []
dropdownItems.forEach((item) => {
@@ -174,7 +174,7 @@ class Select extends Component {
selectedItems.push(item)
}
})
- return selectedItems
+ return reviceSelectedItems.concat(selectedItems)
}
addOption (option) {
@@ -328,65 +328,75 @@ class Select extends Component {
}
remoteSearch (keyword) {
- let {
- url,
- transformResponse,
- error,
- params,
- headers,
- mode,
- data = {},
- type = 'GET',
- key,
- jsonpCallback = 'callback',
- ...options
- } = this.props.dataSource
- keyword =
- !keyword && this.autoloadFlag && this.props.autoload
- ? this.props.dataSource.keyword
+ const {onSearch, dataSource, autoload} = this.props
+ if (onSearch && typeof onSearch === 'function') {
+ this.setState({
+ fetching: true
+ })
+ onSearch(keyword).finally(() => {
+ this.setState({fetching: false})
+ })
+ } else {
+ let {
+ url,
+ transformResponse,
+ error,
+ params,
+ headers,
+ mode,
+ data = {},
+ type = 'GET',
+ key,
+ jsonpCallback = 'callback',
+ ...options
+ } = dataSource
+ keyword =
+ !keyword && this.autoloadFlag && autoload
+ ? dataSource.keyword
: keyword
- this.autoloadFlag = false // 第一次自动加载数据后,输入的关键词即使为空也不再使用默认关键词
+ this.autoloadFlag = false // 第一次自动加载数据后,输入的关键词即使为空也不再使用默认关键词
- const queryParams = qs.stringify(
- Object.assign({}, params, key && { [key]: keyword })
- )
- url = url.includes('?') ? `${url}&${queryParams}` : `${url}?${queryParams}`
-
- if (type.toUpperCase() === 'POST') {
- options.body = JSON.stringify(data)
- }
- this.setState({
- fetching: true
- })
+ const queryParams = qs.stringify(
+ Object.assign({}, params, key && { [key]: keyword })
+ )
+ url = url.includes('?') ? `${url}&${queryParams}` : `${url}?${queryParams}`
- if (type.toUpperCase() === 'JSONP') {
- const _o = {
- jsonpCallback: jsonpCallback,
- jsonpCallbackFunction: jsonpCallback
+ if (type.toUpperCase() === 'POST') {
+ options.body = JSON.stringify(data)
}
- fetchJsonp(url, _o)
- .then((res) => res.json())
- .then((json) => {
- this._setDropdownItems(json, transformResponse)
- })
- } else {
- /* eslint-disable */
- fetch(url, {
- method: type,
- ...options
+ this.setState({
+ fetching: true
})
- .then((response) => response.json())
- .then(
- (res) => {
- this._setDropdownItems(res, transformResponse)
- },
- (err) => {
- error && error(err)
- this.setState({
- fetching: false
- })
- }
- )
+
+ if (type.toUpperCase() === 'JSONP') {
+ const _o = {
+ jsonpCallback: jsonpCallback,
+ jsonpCallbackFunction: jsonpCallback
+ }
+ fetchJsonp(url, _o)
+ .then((res) => res.json())
+ .then((json) => {
+ this._setDropdownItems(json, transformResponse)
+ })
+ } else {
+ /* eslint-disable */
+ fetch(url, {
+ method: type,
+ ...options
+ })
+ .then((response) => response.json())
+ .then(
+ (res) => {
+ this._setDropdownItems(res, transformResponse)
+ },
+ (err) => {
+ error && error(err)
+ this.setState({
+ fetching: false
+ })
+ }
+ )
+ }
}
}
_setDropdownItems(res, func) {
@@ -400,7 +410,7 @@ class Select extends Component {
const selectedItems = this.resetSelectedItems(
this.props.value,
dropdownItems,
- true
+ this.state.selectedItems
)
this.setState({
dropdownItems,
@@ -412,6 +422,7 @@ class Select extends Component {
})
}
onFilterItems(keyword) {
+ const { onSearch, dataSource, autoload } = this.props
this.setState(
{
keyword: keyword
@@ -419,13 +430,15 @@ class Select extends Component {
() => this.resetFocusedIndex()
)
- if (this.props.dataSource && this.props.dataSource.key) {
+ if (dataSource && dataSource.key) {
if (
- this.props.autoload ||
+ autoload ||
keyword.toString().length >= this.state.queryLength
) {
this.remoteSearch(keyword)
}
+ } else if(onSearch) {
+ this.remoteSearch(keyword)
}
}
diff --git a/components/upload/UploadDrag.js b/components/upload/UploadDrag.js
index b19d3bee3..3ae6ec997 100644
--- a/components/upload/UploadDrag.js
+++ b/components/upload/UploadDrag.js
@@ -111,7 +111,7 @@ class UploadDrag extends Upload {
fileList.length > 0 &&
- {localeDatas.upload.dragTips}
+ {fileCountLimted ? localeDatas.upload.dragTipsLimited : localeDatas.upload.dragTips}
}
diff --git a/components/upload/UploadPhoto.js b/components/upload/UploadPhoto.js
index 93338b417..05ec5cb90 100644
--- a/components/upload/UploadPhoto.js
+++ b/components/upload/UploadPhoto.js
@@ -93,21 +93,23 @@ class UploadPhoto extends Upload {
)
}
})}
-
-
-
+ {
+ !fileCountLimted &&
+
+
+ }
{
showModal && {
- console.log('----', res)
- return res.data
- },
- error: err => console.log('error:', err)
- }}
- onChange={(item) => {
- console.log('异步多选结果', item)
- }}
- />
- )
- }
-}`
+const rightOptions = ['使用DataSource', '使用onSearch']
+const code = [{
+ code: `import React from 'react'
+ import { Select } from '@hi-ui/hiui'\n
+ class Demo extends React.Component {
+ render () {
+ return (
+