From bb5272c9e30a992942689c3a88d9dedd82fb37fb Mon Sep 17 00:00:00 2001 From: wugaoliang Date: Sat, 20 Jun 2020 22:02:31 +0800 Subject: [PATCH 01/38] fix: #1098 --- components/date-picker/BasePicker.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/date-picker/BasePicker.js b/components/date-picker/BasePicker.js index b7ca849f9..ef828fbf1 100644 --- a/components/date-picker/BasePicker.js +++ b/components/date-picker/BasePicker.js @@ -68,6 +68,10 @@ class BasePicker extends Component { calcPanelPos (rect) { const {showTime, type} = this.props let _w = type.indexOf('range') !== -1 ? 578 : 288 + if (type === 'timerange') { + _w = 400 + } + let _h = 298 if (type === 'daterange' && showTime) { _h = 344 @@ -80,6 +84,7 @@ class BasePicker extends Component { const _st = document.documentElement.scrollTop || document.body.scrollTop let {left, width, top, height} = rect let _top = rect.top + rect.height + _st + 4 + if (left + _w > _cw) { left = left + width - _w } From 84d75a0ce1c7c8720d7ad4183f2f2e3b26f45e79 Mon Sep 17 00:00:00 2001 From: wugaoliang Date: Sat, 20 Jun 2020 22:13:22 +0800 Subject: [PATCH 02/38] fix: #1099 --- components/date-picker/BasePicker.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/date-picker/BasePicker.js b/components/date-picker/BasePicker.js index b7ca849f9..e04748368 100644 --- a/components/date-picker/BasePicker.js +++ b/components/date-picker/BasePicker.js @@ -173,9 +173,9 @@ class BasePicker extends Component { }) } callback () { - const { type, onChange } = this.props + const { type, onChange, disabled } = this.props const { date, format } = this.state - if (onChange) { + if (onChange && !disabled) { let {startDate, endDate} = date startDate = isValid(startDate) ? startDate : '' endDate = isValid(endDate) ? endDate : '' @@ -268,15 +268,16 @@ class BasePicker extends Component { ) } _clear () { - this.setState({date: {startDate: null, endDate: null}, texts: ['', ''], isFocus: false}, () => { this.callback() }) + const { disabled } = this.props + !disabled && this.setState({date: {startDate: null, endDate: null}, texts: ['', ''], isFocus: false}, () => { this.callback() }) } _icon () { const {isFocus, texts} = this.state - const { clearable, type, showTime } = this.props + const { clearable, type, showTime, disabled } = this.props const iconCls = classNames( 'hi-datepicker__input-icon', 'hi-icon', - (texts[0].length && isFocus && clearable) + (texts[0].length && isFocus && clearable && !disabled) ? 'icon-close-circle clear' : ((type.includes('time') || showTime) ? 'icon-time' : 'icon-date') ) From 83a3df9d73298ce83375446ec8b11de55e4e35c8 Mon Sep 17 00:00:00 2001 From: Wugaoliang Date: Mon, 22 Jun 2020 10:05:58 +0800 Subject: [PATCH 03/38] fix: #1102 --- components/dropdown/Dropdown.jsx | 2 +- components/popper/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/dropdown/Dropdown.jsx b/components/dropdown/Dropdown.jsx index 37a65b153..093a87da5 100644 --- a/components/dropdown/Dropdown.jsx +++ b/components/dropdown/Dropdown.jsx @@ -139,7 +139,7 @@ class Dropdown extends React.Component { } Dropdown.propTypes = { - placement: PropTypes.oneOf(['top-start', 'bottom-start', 'top', 'bottom']), + placement: PropTypes.oneOf(['top-start', 'bottom-start', 'top', 'bottom', 'bottom-end', 'top-end']), trigger: PropTypes.oneOfType([ PropTypes.oneOf(['contextmenu', 'click', 'hover']), PropTypes.arrayOf(PropTypes.oneOf(['contextmenu', 'click', 'hover'])) diff --git a/components/popper/index.js b/components/popper/index.js index c26f5c1c1..572f49800 100644 --- a/components/popper/index.js +++ b/components/popper/index.js @@ -17,7 +17,7 @@ export default class Popper extends Component { topGap: PropTypes.number, leftGap: PropTypes.number, zIndex: PropTypes.number, - placement: PropTypes.oneOf(['bottom', 'bottom-start', 'top', 'top-start', 'left', 'right', 'right-start', 'top-bottom-start', 'top-bottom']), + placement: PropTypes.oneOf(['bottom', 'bottom-start', 'top', 'top-start', 'top-end', 'left', 'right', 'right-start', 'top-bottom-start', 'top-bottom', 'bottom-end']), onMouseOver: PropTypes.func, onMouseOut: PropTypes.func, onMouseEnter: PropTypes.func, From ec73e0d3fb6867474a4398d3817245505304e889 Mon Sep 17 00:00:00 2001 From: wugaoliang Date: Sat, 27 Jun 2020 16:36:14 +0800 Subject: [PATCH 04/38] fix: #1108 --- components/counter/Counter.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/components/counter/Counter.js b/components/counter/Counter.js index 22791b66f..c279aadba 100644 --- a/components/counter/Counter.js +++ b/components/counter/Counter.js @@ -211,17 +211,13 @@ class Counter extends React.Component { } getInputNumber () { - const { max = Infinity, min = 0 } = this.props + const { max, min } = this.props let value = this.valueTrue if (isNaN(value)) { - value = min - } - if (value - max >= 0) { - value = max - } - if (value - min <= 0) { - value = min + value = 0 } + value = max && value - max >= 0 ? max : value + value = min && value - min <= 0 ? min : value return value } From 33a576fc9ab1e9118e4addb9ea9ffc48313232b8 Mon Sep 17 00:00:00 2001 From: zhangboya3 Date: Mon, 6 Jul 2020 15:09:50 +0800 Subject: [PATCH 05/38] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=9B=BE=E6=A0=87=E7=9A=84=E6=97=B6=E5=80=99=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=94=A4=E8=B5=B7=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/date-picker/BasePicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/date-picker/BasePicker.js b/components/date-picker/BasePicker.js index 4f35abbe1..5eba54bd1 100644 --- a/components/date-picker/BasePicker.js +++ b/components/date-picker/BasePicker.js @@ -286,7 +286,7 @@ class BasePicker extends Component { ? 'icon-close-circle clear' : ((type.includes('time') || showTime) ? 'icon-time' : 'icon-date') ) - return (isFocus && clearable) + return (texts[0].length && isFocus && clearable) ? : { if (this.props.disabled) return From cc75ec0aa1c87f007fc37686885dfc5438f7833f Mon Sep 17 00:00:00 2001 From: wugaoliang Date: Sun, 12 Jul 2020 14:10:51 +0800 Subject: [PATCH 06/38] fix: #1106 --- components/date-picker/BasePicker.js | 31 +++++++++++++++++------- components/date-picker/DateRangePanel.js | 10 +++++--- components/date-picker/util.js | 23 +++++++++++++++++- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/components/date-picker/BasePicker.js b/components/date-picker/BasePicker.js index 4f35abbe1..36be7f546 100644 --- a/components/date-picker/BasePicker.js +++ b/components/date-picker/BasePicker.js @@ -3,7 +3,7 @@ import _ from 'lodash' import Modal from './Modal' import classNames from 'classnames' import {formatterDate, FORMATS} from './constants' -import {showLargeCalendar} from './util' +import {showLargeCalendar, getInRangeDate} from './util' import PropTypes from 'prop-types' import DatePickerType from './Type' @@ -177,27 +177,30 @@ class BasePicker extends Component { } }) } + callback () { - const { type, onChange, disabled } = this.props + const { type, onChange, disabled, max, min } = this.props + const { date, format } = this.state if (onChange && !disabled) { - let {startDate, endDate} = date + let {startDate, endDate} = getInRangeDate(date.startDate, date.endDate, max, min) startDate = isValid(startDate) ? startDate : '' endDate = isValid(endDate) ? endDate : '' if (type === 'week' || type === 'weekrange') { - onChange(date) + isValid(startDate) && isValid(endDate) && onChange(date) return } if (type === 'time') { - onChange(startDate, dateFormat(startDate, format)) + isValid(startDate) && onChange(startDate, dateFormat(startDate, format)) return } if (['timerange', 'timeperiod', 'daterange', 'yearrange', 'monthrange'].includes(type)) { - onChange({start: startDate, end: endDate}, {start: dateFormat(startDate, format), end: dateFormat(endDate, format)}) + isValid(startDate) && isValid(endDate) && onChange({start: startDate, end: endDate}, {start: dateFormat(startDate, format), end: dateFormat(endDate, format)}) + return } - onChange(startDate, startDate ? dateFormat(startDate, format) : '') + isValid(startDate) && isValid(endDate) && onChange(startDate, startDate ? dateFormat(startDate, format) : '') } } timeCancel () { @@ -228,6 +231,7 @@ class BasePicker extends Component { } } clickOutSide (e) { + const {max, min} = this.props const tar = e.target this.inputChangeEvent() @@ -239,8 +243,17 @@ class BasePicker extends Component { return false } if (tar !== this.input && tar !== this.rInput) { - this.timeCancel() - this.callback() + let { texts } = this.state + + let {startDate, endDate} = getInRangeDate(texts[0], texts[1], max, min) + + texts = [this.callFormatterDate(startDate), this.callFormatterDate(endDate)] + this.setState({ + texts + }, () => { + this.timeCancel() + this.callback() + }) } } _input (text, ref, placeholder) { diff --git a/components/date-picker/DateRangePanel.js b/components/date-picker/DateRangePanel.js index 1e98b9edd..84065f1f7 100644 --- a/components/date-picker/DateRangePanel.js +++ b/components/date-picker/DateRangePanel.js @@ -1,6 +1,7 @@ import React, {Component} from 'react' import Calender from './Calender' -import { deconstructDate, nextMonth, showLargeCalendar, colDisabled } from './util' +import { deconstructDate, nextMonth, showLargeCalendar, colDisabled, getInRangeDate } from './util' + import { DAY_MILLISECONDS } from './constants' import Icon from '../icon' import classNames from 'classnames' @@ -170,7 +171,7 @@ class DateRangePanel extends Component { }) } shortcutsClickEvent (e) { - const { localeDatas } = this.props + const { localeDatas, max, min } = this.props const {range} = this.state const _date = new Date() const val = e.target.innerText @@ -193,8 +194,9 @@ class DateRangePanel extends Component { break } const nDate = new Date((endOfDay(_date).getTime() + 1) - days * DAY_MILLISECONDS) - range.startDate = nDate - range.endDate = _date + const {startDate, endDate} = getInRangeDate(nDate, _date, max, min) + range.startDate = startDate + range.endDate = endDate this.props.onPick(range) } renderShortcut (shortcuts) { diff --git a/components/date-picker/util.js b/components/date-picker/util.js index f098b17da..023e7fe91 100644 --- a/components/date-picker/util.js +++ b/components/date-picker/util.js @@ -1,5 +1,5 @@ import request from 'axios' -import { addMonths, getDay, subDays, differenceInDays, startOfWeek, endOfWeek, getYear, getMonth } from './dateUtil' +import { addMonths, getDay, subDays, differenceInDays, startOfWeek, endOfWeek, getYear, getMonth, toDate, isValid } from './dateUtil' const holiday = { PRCHoliday: 'https://cdn.cnbj1.fds.api.mi-img.com/hiui/PRCHoliday.json?', PRCLunar: 'https://cdn.cnbj1.fds.api.mi-img.com/hiui/PRCLunar.json?', @@ -80,3 +80,24 @@ export const getPRCDate = (api) => { } return url ? request.create().request(options) : null } + +// 处理输入不在该范围内的处理 +export const getInRangeDate = (startDate, endDate, max, min) => { + let _startDate = isValid(startDate) ? startDate : '' + let _endDate = isValid(endDate) ? endDate : '' + if (min) { + const minTimestamp = Date.parse(toDate(min)) + const startDateTimestamp = Date.parse(startDate) + const endDateTimestamp = Date.parse(endDate) + _startDate = startDateTimestamp < minTimestamp ? new Date(minTimestamp) : new Date(startDate) + _endDate = endDateTimestamp < minTimestamp ? new Date(minTimestamp) : new Date(endDate) + } + if (max) { + const maxTimestamp = Date.parse(toDate(max)) + const startDateTimestamp = Date.parse(_startDate) + const endDateTimestamp = Date.parse(_endDate) + _startDate = startDateTimestamp > maxTimestamp ? new Date(maxTimestamp) : new Date(_startDate) + _endDate = endDateTimestamp > maxTimestamp ? new Date(maxTimestamp) : new Date(_endDate) + } + return {startDate: _startDate, endDate: _endDate} +} From b52472640e1529a4de61005e8cbdf7b8090e440d Mon Sep 17 00:00:00 2001 From: Wugaoliang Date: Mon, 13 Jul 2020 10:43:11 +0800 Subject: [PATCH 07/38] fix: #1106 --- components/date-picker/BasePicker.js | 25 ++++++++++++++++++++----- components/date-picker/util.js | 4 ++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/components/date-picker/BasePicker.js b/components/date-picker/BasePicker.js index 36be7f546..f4a61c569 100644 --- a/components/date-picker/BasePicker.js +++ b/components/date-picker/BasePicker.js @@ -183,24 +183,39 @@ class BasePicker extends Component { const { date, format } = this.state if (onChange && !disabled) { - let {startDate, endDate} = getInRangeDate(date.startDate, date.endDate, max, min) + let {startDate, endDate} = getInRangeDate(_.cloneDeep(date.startDate), _.cloneDeep(date.endDate), max, min) startDate = isValid(startDate) ? startDate : '' endDate = isValid(endDate) ? endDate : '' if (type === 'week' || type === 'weekrange') { - isValid(startDate) && isValid(endDate) && onChange(date) + this.setState({ + texts: [this.callFormatterDate(startDate), this.callFormatterDate(endDate)] + }) + onChange(date) return } if (type === 'time') { - isValid(startDate) && onChange(startDate, dateFormat(startDate, format)) + this.setState({ + texts: [this.callFormatterDate(startDate), ''] + }) + onChange(startDate, dateFormat(startDate, format)) return } if (['timerange', 'timeperiod', 'daterange', 'yearrange', 'monthrange'].includes(type)) { - isValid(startDate) && isValid(endDate) && onChange({start: startDate, end: endDate}, {start: dateFormat(startDate, format), end: dateFormat(endDate, format)}) + this.setState({ + texts: [this.callFormatterDate(startDate), this.callFormatterDate(endDate)] + }) + onChange({start: startDate, end: endDate}, {start: dateFormat(startDate, format), end: dateFormat(endDate, format)}) return } - isValid(startDate) && isValid(endDate) && onChange(startDate, startDate ? dateFormat(startDate, format) : '') + + if (isValid(startDate) || startDate === '') { + this.setState({ + texts: [this.callFormatterDate(startDate), ''] + }) + onChange(startDate, startDate ? dateFormat(startDate, format) : '') + } } } timeCancel () { diff --git a/components/date-picker/util.js b/components/date-picker/util.js index 023e7fe91..3088eb3ed 100644 --- a/components/date-picker/util.js +++ b/components/date-picker/util.js @@ -85,14 +85,14 @@ export const getPRCDate = (api) => { export const getInRangeDate = (startDate, endDate, max, min) => { let _startDate = isValid(startDate) ? startDate : '' let _endDate = isValid(endDate) ? endDate : '' - if (min) { + if (min && isValid(startDate)) { const minTimestamp = Date.parse(toDate(min)) const startDateTimestamp = Date.parse(startDate) const endDateTimestamp = Date.parse(endDate) _startDate = startDateTimestamp < minTimestamp ? new Date(minTimestamp) : new Date(startDate) _endDate = endDateTimestamp < minTimestamp ? new Date(minTimestamp) : new Date(endDate) } - if (max) { + if (max && isValid(startDate)) { const maxTimestamp = Date.parse(toDate(max)) const startDateTimestamp = Date.parse(_startDate) const endDateTimestamp = Date.parse(_endDate) From 57946397351eac1ed0ac78c9c975c44e55ba7341 Mon Sep 17 00:00:00 2001 From: Wugaoliang Date: Tue, 21 Jul 2020 14:35:45 +0800 Subject: [PATCH 08/38] fix: #1128 --- components/select/Select.js | 5 ++++- docs/zh-CN/components/select.mdx | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/select/Select.js b/components/select/Select.js index d5417fadc..06d68f515 100644 --- a/components/select/Select.js +++ b/components/select/Select.js @@ -37,6 +37,7 @@ class Select extends Component { ]), showCheckAll: PropTypes.bool, autoload: PropTypes.bool, + withCredentials: PropTypes.bool, searchable: PropTypes.bool, filterOption: PropTypes.func, clearable: PropTypes.bool, @@ -60,6 +61,7 @@ class Select extends Component { autoload: false, showCheckAll: false, open: true, + withCredentials: false, onClick: () => {}, onBlur: () => {}, onFocus: () => {} @@ -337,7 +339,7 @@ class Select extends Component { } remoteSearch (keyword) { - const { onSearch, dataSource, autoload } = this.props + const { onSearch, dataSource, autoload, withCredentials } = this.props if (onSearch && typeof onSearch === 'function') { this.setState({ fetching: true @@ -396,6 +398,7 @@ class Select extends Component { /* eslint-disable */ fetch(url, { method: type, + credentials: withCredentials ? 'include' : 'omit', ...options }) .then(response => response.json()) diff --git a/docs/zh-CN/components/select.mdx b/docs/zh-CN/components/select.mdx index 8ab633de9..9a9241458 100755 --- a/docs/zh-CN/components/select.mdx +++ b/docs/zh-CN/components/select.mdx @@ -79,4 +79,5 @@ import DemoAsync from '../../demo/select/section-async' | params | url 查询参数 | object | - | - | | headers | 请求头 | object | - | - | | mode | 请求模式 | string | 'same-origin' \| 'cors' \| 'no-cors' \| 'navigate' | 'same-origin' | +| withCredentials | 上传请求时是否携带 cookie | boolean | true \| false | false | | transformResponse | 成功时的回调,用于对数据进行预处理 | (response: object) => DataItem[] | - | - | From e73c17bc76f808de1daf06194e5cff3d1d42c63e Mon Sep 17 00:00:00 2001 From: Wugaoliang Date: Tue, 21 Jul 2020 14:47:34 +0800 Subject: [PATCH 09/38] fix: #1128 --- components/select/Select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/select/Select.js b/components/select/Select.js index 06d68f515..6cefce2c6 100644 --- a/components/select/Select.js +++ b/components/select/Select.js @@ -398,7 +398,7 @@ class Select extends Component { /* eslint-disable */ fetch(url, { method: type, - credentials: withCredentials ? 'include' : 'omit', + credentials: withCredentials ? 'include' : 'same-origin', ...options }) .then(response => response.json()) From b5d5c5cde40f32ce681c6526a8dcb3b7c9b06c08 Mon Sep 17 00:00:00 2001 From: Wugaoliang Date: Thu, 23 Jul 2020 08:44:23 +0800 Subject: [PATCH 10/38] feat: #1125 --- components/context/index.js | 2 +- components/locales/index.js | 1 + docs/zh-CN/components/i18n.mdx | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/context/index.js b/components/context/index.js index 3f1b2da3e..dcccfc311 100644 --- a/components/context/index.js +++ b/components/context/index.js @@ -2,7 +2,7 @@ import React, { Component, forwardRef } from 'react' import locales from '../locales' export const ThemeContext = React.createContext('hiui-blue') -export const LocaleContext = React.createContext('zh-CN') +export const LocaleContext = React.createContext('zh-Hans') /** * 临时解决 notice组件获取不到theme的问题 */ diff --git a/components/locales/index.js b/components/locales/index.js index bbb51cddb..b0c6cd609 100644 --- a/components/locales/index.js +++ b/components/locales/index.js @@ -5,6 +5,7 @@ import zhHantTW from './zh-Hant-TW' export default { 'zh-CN': zhCN, + 'zh-Hans': zhCN, 'en-US': enUS, 'zh-Hant-HK': zhHantHK, 'zh-Hant-TW': zhHantTW diff --git a/docs/zh-CN/components/i18n.mdx b/docs/zh-CN/components/i18n.mdx index 9ac20f065..990984d40 100755 --- a/docs/zh-CN/components/i18n.mdx +++ b/docs/zh-CN/components/i18n.mdx @@ -1,6 +1,6 @@ # 国际化 -HIUI 目前支持简体中文、英文两种语言,默认为 **zh-CN** +HIUI 目前支持简体中文、英文两种语言,默认为 **zh-Hans** ## 使用方法 @@ -35,7 +35,7 @@ import DemoExample from '../../demo/i18n/section-example.jsx' 简体中文 - zh-CN + zh-Hans | zh-CN 英语 From 9f1d33bc9eb570a9298276eaf093fa44964dcd75 Mon Sep 17 00:00:00 2001 From: Wugaoliang Date: Thu, 23 Jul 2020 08:46:39 +0800 Subject: [PATCH 11/38] feat: #1125 --- docs/zh-CN/components/i18n.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-CN/components/i18n.mdx b/docs/zh-CN/components/i18n.mdx index 990984d40..06fa87e43 100755 --- a/docs/zh-CN/components/i18n.mdx +++ b/docs/zh-CN/components/i18n.mdx @@ -1,6 +1,6 @@ # 国际化 -HIUI 目前支持简体中文、英文两种语言,默认为 **zh-Hans** +HIUI 目前支持简体中文、香港繁体、台湾繁体、英文四种语言,默认为 **zh-Hans** ## 使用方法 From bae9c52939bf9447dad8e630ec50e3ea94b3aa15 Mon Sep 17 00:00:00 2001 From: zhangboya3 Date: Fri, 24 Jul 2020 15:27:02 +0800 Subject: [PATCH 12/38] hotfix:#1137 --- components/rate/Rate.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/rate/Rate.js b/components/rate/Rate.js index 82074bef3..825835f45 100644 --- a/components/rate/Rate.js +++ b/components/rate/Rate.js @@ -136,7 +136,7 @@ Rate.defaultProps = { count: 5, prefixCls: 'hi-rate', tooltips: [], - onChange: () => {} + onChange: () => { } } function ToolTipWrapper ({ children, title }) { @@ -144,6 +144,9 @@ function ToolTipWrapper ({ children, title }) { } function Icon ({ value, currentValue, disabled, useEmoji, allowHalf }) { + if (currentValue > 5) { + currentValue = 5 + } if (useEmoji) { const Emojis = [ Icons.EmojiOne, From 26955424e8f5f14bcb9568eff74d8ed20fa37b79 Mon Sep 17 00:00:00 2001 From: zhangboya3 Date: Fri, 24 Jul 2020 15:39:25 +0800 Subject: [PATCH 13/38] hotfix:#1137 --- components/rate/Rate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/rate/Rate.js b/components/rate/Rate.js index 825835f45..c2f569f3b 100644 --- a/components/rate/Rate.js +++ b/components/rate/Rate.js @@ -144,10 +144,10 @@ function ToolTipWrapper ({ children, title }) { } function Icon ({ value, currentValue, disabled, useEmoji, allowHalf }) { - if (currentValue > 5) { - currentValue = 5 - } if (useEmoji) { + if (currentValue > 5) { + currentValue = 5 + } const Emojis = [ Icons.EmojiOne, Icons.EmojiTwo, From 7bac577a18c5ccda09ff7615ad5da09b2a84a0c4 Mon Sep 17 00:00:00 2001 From: zhangboya3 Date: Mon, 27 Jul 2020 14:50:57 +0800 Subject: [PATCH 14/38] rate --- components/rate/Rate.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/rate/Rate.js b/components/rate/Rate.js index c2f569f3b..b96e86239 100644 --- a/components/rate/Rate.js +++ b/components/rate/Rate.js @@ -145,9 +145,7 @@ function ToolTipWrapper ({ children, title }) { function Icon ({ value, currentValue, disabled, useEmoji, allowHalf }) { if (useEmoji) { - if (currentValue > 5) { - currentValue = 5 - } + const emojiValue = currentValue > 5 ? 5 : currentValue const Emojis = [ Icons.EmojiOne, Icons.EmojiTwo, @@ -155,8 +153,8 @@ function Icon ({ value, currentValue, disabled, useEmoji, allowHalf }) { Icons.EmojiFour, Icons.EmojiFive ] - if (value <= currentValue) { - return React.createElement(Emojis[currentValue - 1]) + if (value <= emojiValue) { + return React.createElement(Emojis[emojiValue - 1]) } else { return } From c677a2beed9dcd436d5a795fb4a7001c81afe30e Mon Sep 17 00:00:00 2001 From: solarjoker Date: Tue, 28 Jul 2020 10:30:45 +0800 Subject: [PATCH 15/38] fix: #1143 --- components/input/Input.js | 117 +++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 41 deletions(-) diff --git a/components/input/Input.js b/components/input/Input.js index b2d97ad81..ca1c0abaf 100644 --- a/components/input/Input.js +++ b/components/input/Input.js @@ -33,8 +33,7 @@ class Input extends Component { const prependNode = typeof prepend !== 'string' && prepend const appendNode = typeof append !== 'string' && append this.state = { - value: - type === 'string' || type === 'number' ? format(valueSource, this.props.type) : '', + value: type === 'string' || type === 'number' ? format(valueSource, this.props.type) : '', valueTrue: prefix + valueSource + suffix, hover: false, active: false, @@ -85,7 +84,19 @@ class Input extends Component { let prefixId = id ? id + '_prefix' : '' let suffixId = id ? id + '_suffix' : '' const { defaultValue, ...attrs } = this.attrs - const filterAttrs = filterObjProps(attrs, ['locale', 'theme', 'suffixicon', 'suffix', 'prepend', 'prefixicon', 'prefix', 'localeDatas', 'append', 'innerRef']) + const filterAttrs = filterObjProps(attrs, [ + 'locale', + 'theme', + 'suffixicon', + 'suffix', + 'prepend', + 'prefixicon', + 'prefix', + 'localeDatas', + 'append', + 'innerRef', + 'clearable' + ]) return (
- {// 前置元素 - prepend && {prepend}} + { + // 前置元素 + prepend && {prepend} + }
- {// 前缀 + { + // 前缀 prefix && ( {prefix} - )} + ) + } { + ref={(arg) => { this._Input = arg }} className={`hi-input__text ${disabled ? 'disabled' : ''}`} @@ -112,7 +127,7 @@ class Input extends Component { disabled={disabled} {...filterAttrs} placeholder={placeholder} - onChange={e => { + onChange={(e) => { e.persist() let value = e.target.value let valueTrue = formatValue(value, type) @@ -130,7 +145,7 @@ class Input extends Component { this.props.value === undefined && this.setState({ value, valueTrue }) }} - onBlur={e => { + onBlur={(e) => { e.persist() let value = e.target.value const valueTrue = this.state.valueTrue @@ -144,7 +159,7 @@ class Input extends Component { this.props.onBlur && this.props.onBlur(e, valueTrue) }) }} - onFocus={e => { + onFocus={(e) => { e.persist() const valueTrue = this.state.valueTrue @@ -152,34 +167,34 @@ class Input extends Component { this.props.onFocus && this.props.onFocus(e, valueTrue) }) }} - onKeyDown={e => { + onKeyDown={(e) => { const valueTrue = this.state.valueTrue this.props.onKeyDown && this.props.onKeyDown(e, valueTrue) }} - onKeyUp={e => { + onKeyUp={(e) => { const valueTrue = this.state.valueTrue this.props.onKeyUp && this.props.onKeyUp(e, valueTrue) }} - onKeyPress={e => { + onKeyPress={(e) => { const valueTrue = this.state.valueTrue this.props.onKeyPress && this.props.onKeyPress(e, valueTrue) }} - onInput={e => { + onInput={(e) => { const valueTrue = this.state.valueTrue this.props.onInput && this.props.onInput(e, valueTrue) }} /> - {// 清除 - noClear.indexOf(type) === -1 && - prefix === '' && - suffix === '' && - (value !== '' && clearable) && ( + { + // 清除 + noClear.indexOf(type) === -1 && prefix === '' && suffix === '' && value !== '' && clearable && ( { this._Input.focus() @@ -197,16 +212,21 @@ class Input extends Component { > - )} - {// 后缀 + ) + } + { + // 后缀 suffix && ( {suffix} - )} + ) + }
- {// 后置元素 - append && {append}} + { + // 后置元素 + append && {append} + }
) } @@ -218,7 +238,19 @@ class Input extends Component { let { active } = this.state let { disabled, theme } = this.props const { defaultValue, ...attrs } = this.attrs - const filterAttrs = filterObjProps(attrs, ['locale', 'theme', 'suffixicon', 'suffix', 'prepend', 'prefixicon', 'prefix', 'localeDatas', 'append', 'innerRef']) + const filterAttrs = filterObjProps(attrs, [ + 'locale', + 'theme', + 'suffixicon', + 'suffix', + 'prepend', + 'prefixicon', + 'prefix', + 'localeDatas', + 'append', + 'innerRef', + 'clearable' + ]) return (