Skip to content

Commit

Permalink
Merge branch 'master' into feat-life-cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Apr 9, 2020
2 parents 373119e + 592ab9d commit 563038a
Show file tree
Hide file tree
Showing 16 changed files with 296 additions and 92 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Change Log

## [1.19.24](https://github.com/alibaba-fusion/next/compare/1.19.23...1.19.24) (2020-04-08)


### Bug Fixes

* **Button:** pass style underline to button ([#1750](https://github.com/alibaba-fusion/next/issues/1750)) ([d8cc226](https://github.com/alibaba-fusion/next/commit/d8cc226))
* **Nav:** fix sub nav vertical not middle ([#1744](https://github.com/alibaba-fusion/next/issues/1744)) ([aaf6f69](https://github.com/alibaba-fusion/next/commit/aaf6f69))
* **Pagination:** reset input if value is illegal ([#1747](https://github.com/alibaba-fusion/next/issues/1747)) ([9fbadb7](https://github.com/alibaba-fusion/next/commit/9fbadb7))




## [1.19.23](https://github.com/alibaba-fusion/next/compare/1.19.22...1.19.23) (2020-04-03)


### Bug Fixes

* **Cascader:** support to remove title, close [#1665](https://github.com/alibaba-fusion/next/issues/1665) ([#1742](https://github.com/alibaba-fusion/next/issues/1742)) ([ed9df0c](https://github.com/alibaba-fusion/next/commit/ed9df0c))
* **Dialog:** get the wrong computed size of borderbox in IE,close [#1609](https://github.com/alibaba-fusion/next/issues/1609) ([#1732](https://github.com/alibaba-fusion/next/issues/1732)) ([e8b4caf](https://github.com/alibaba-fusion/next/commit/e8b4caf))
* **Nav:** resolve issue [#215](https://github.com/alibaba-fusion/next/issues/215) ([1d90980](https://github.com/alibaba-fusion/next/commit/1d90980))
* **Slider:** correct dotsRender arguments, close [#1730](https://github.com/alibaba-fusion/next/issues/1730) ([#1731](https://github.com/alibaba-fusion/next/issues/1731)) ([10c384a](https://github.com/alibaba-fusion/next/commit/10c384a))




## [1.19.22](https://github.com/alibaba-fusion/next/compare/1.19.21...1.19.22) (2020-03-31)


Expand Down
9 changes: 8 additions & 1 deletion LATESTLOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Latest Log

## [1.19.22](https://github.com/alibaba-fusion/next/compare/1.19.21...1.19.22) (2020-03-31)
## [1.19.24](https://github.com/alibaba-fusion/next/compare/1.19.23...1.19.24) (2020-04-08)


### Bug Fixes

* **Button:** pass style underline to button ([#1750](https://github.com/alibaba-fusion/next/issues/1750)) ([d8cc226](https://github.com/alibaba-fusion/next/commit/d8cc226))
* **Nav:** fix sub nav vertical not middle ([#1744](https://github.com/alibaba-fusion/next/issues/1744)) ([aaf6f69](https://github.com/alibaba-fusion/next/commit/aaf6f69))
* **Pagination:** reset input if value is illegal ([#1747](https://github.com/alibaba-fusion/next/issues/1747)) ([9fbadb7](https://github.com/alibaba-fusion/next/commit/9fbadb7))


2 changes: 1 addition & 1 deletion docs/slider/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
| centerMode | 是否启用居中模式 | Boolean | false |
| dots | 是否显示导航锚点 | Boolean | true |
| dotsDirection | 导航锚点位置<br><br>**可选值**:<br>'hoz', 'ver' | Enum | 'hoz' |
| dotRender | 自定义导航锚点<br><br>**签名**:<br>Function() => void | Function | - |
| dotsRender | 自定义导航锚点<br><br>**签名**:<br>Function() => void | Function | null |
| draggable | 是否可拖拽 | Boolean | true |
| infinite | 是否使用无穷循环模式 | Boolean | true |
| defaultActiveIndex | 初始被激活的轮播图 | Number | 0 |
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var next = require('./lib/index.js');

next.version = '1.19.22';
next.version = '1.19.24';

module.exports = next;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alifd/next",
"version": "1.19.22",
"version": "1.19.24",
"description": "A configurable component library for web built on React.",
"keywords": [
"fusion",
Expand Down
7 changes: 6 additions & 1 deletion src/button/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@
vertical-align: middle;
}

> span,
> div {
display: inline-block;
vertical-align: middle;
}

> #{$btn-prefix}-helper {
text-decoration: inherit;
display: inline-block;
vertical-align: middle;
}

&.hover,
&:hover {
box-shadow: $btn-shadow-hover;
Expand Down
2 changes: 1 addition & 1 deletion src/button/view/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default class Button extends Component {
}

if (!isValidElement(child)) {
return <span>{child}</span>;
return <span className={`${prefix}btn-helper`}>{child}</span>;
}

return child;
Expand Down
4 changes: 4 additions & 0 deletions src/cascader/cascader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,10 @@ class Cascader extends Component {
onFold: this.handleFold,
};

if ('title' in item) {
props.title = item.title;
}

if (multiple) {
props.checkable = !(canOnlyCheckLeaf && canExpand);
props.checked =
Expand Down
30 changes: 24 additions & 6 deletions src/dialog/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Overlay from '../overlay';
import zhCN from '../locale/zh-cn';
import { focus, obj, func, events, dom } from '../util';
import { focus, obj, func, events, dom, env } from '../util';
import Inner from './inner';

const noop = () => {};
Expand All @@ -11,6 +11,22 @@ const { bindCtx } = func;
const { pickOthers } = obj;
const { getStyle, setStyle } = dom;

// [fix issue #1609](https://github.com/alibaba-fusion/next/issues/1609)
// https://stackoverflow.com/questions/19717907/getcomputedstyle-reporting-different-heights-between-chrome-safari-firefox-and-i
function _getSize(dom, name) {
const boxSizing = getStyle(dom, 'boxSizing');

if (
env.ieVersion &&
['width', 'height'].indexOf(name) !== -1 &&
boxSizing === 'border-box'
) {
return parseFloat(dom.getBoundingClientRect()[name].toFixed(1));
} else {
return getStyle(dom, name);
}
}

/**
* Dialog
*/
Expand Down Expand Up @@ -201,7 +217,7 @@ export default class Dialog extends Component {
const inner = this.getInner();
if (inner) {
const node = this.getInnerNode();
if (this._lastDialogHeight !== getStyle(node, 'height')) {
if (this._lastDialogHeight !== _getSize(node, 'height')) {
this.revertSize(inner.bodyNode);
}
}
Expand All @@ -221,10 +237,12 @@ export default class Dialog extends Component {
setStyle(node, 'top', `${minMargin}px`);
}

const height = getStyle(node, 'height');
const height = _getSize(node, 'height');
const viewportHeight =
window.innerHeight || document.documentElement.clientHeight;
if (viewportHeight < height + top * 2) {

// 分辨率和精确度的原因 高度计算的时候 可能会有1px内的偏差
if (viewportHeight < height + top * 2 - 1) {
const expectHeight = viewportHeight - top * 2;
this.adjustSize(inner, node, expectHeight);
} else {
Expand All @@ -239,8 +257,8 @@ export default class Dialog extends Component {
adjustSize(inner, node, expectHeight) {
const { headerNode, bodyNode, footerNode } = inner;

const headerHeight = headerNode ? getStyle(headerNode, 'height') : 0;
const footerHeight = footerNode ? getStyle(footerNode, 'height') : 0;
const headerHeight = headerNode ? _getSize(headerNode, 'height') : 0;
const footerHeight = footerNode ? _getSize(footerNode, 'height') : 0;
const padding =
getStyle(node, 'padding-top') + getStyle(node, 'padding-bottom');
let maxBodyHeight =
Expand Down
2 changes: 1 addition & 1 deletion src/menu/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
&-embeddable,
&-embeddable &-item.#{$css-prefix}disabled,
&-embeddable &-item.#{$css-prefix}disabled #{$menu-prefix}-item-text > a {
background: initial;
background: transparent;
border: none;
}

Expand Down
11 changes: 7 additions & 4 deletions src/nav/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ $nav-icononly-width: 58px;
margin-bottom: $nav-ver-item-margin-tb;
}

#{$menu-prefix}-sub-menu {
line-height: $nav-ver-sub-nav-height;
}

#{$menu-prefix}-sub-menu #{$menu-prefix}-item-inner {
height: $nav-ver-sub-nav-height;
line-height: $nav-ver-sub-nav-height;
font-size: $nav-ver-sub-nav-font-size;
}

Expand Down Expand Up @@ -391,13 +394,13 @@ $nav-icononly-width: 58px;
&.#{$css-prefix}secondary,
&.#{$css-prefix}normal {
height: 100%;
background: initial;
background: transparent;
box-shadow: none;
border: none;

#{$menu-prefix}-sub-menu #{$menu-prefix}-item,
#{$nav-prefix}-item#{$menu-prefix}-item {
background: initial;
background: transparent;
}

&.#{$css-prefix}icon-only {
Expand All @@ -420,7 +423,7 @@ $nav-icononly-width: 58px;
&-embeddable,
&-embeddable &-item.#{$css-prefix}disabled,
&-embeddable &-item.#{$css-prefix}disabled #{$menu-prefix}-item-text > a {
background: initial;
background: transparent;
border: none;
}
}
Expand Down
31 changes: 22 additions & 9 deletions src/pagination/pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class Pagination extends Component {
this.state = {
current: props.defaultCurrent || 1,
currentPageSize: 0,
inputValue: '',
};
}

Expand All @@ -193,17 +194,25 @@ class Pagination extends Component {

handleJump = e => {
const { total } = this.props;
const { current, currentPageSize } = this.state;
const { current, currentPageSize, inputValue } = this.state;
const totalPage = getTotalPage(total, currentPageSize);
const value = parseInt(this.inputValue, 10);
if (
typeof value === 'number' &&
value >= 1 &&
value <= totalPage &&
value !== current
) {
let value = parseInt(inputValue, 10);

if (isNaN(value)) {
value = '';
} else if (value < 1) {
value = 1;
} else if (value > totalPage) {
value = totalPage;
}

if (value && value !== current) {
this.onPageItemClick(value, e);
}

this.setState({
inputValue: '',
});
};
onPageItemClick(page, e) {
if (!('current' in this.props)) {
Expand All @@ -215,7 +224,9 @@ class Pagination extends Component {
}

onInputChange(value) {
this.inputValue = value;
this.setState({
inputValue: value,
});
}

onSelectSize(pageSize) {
Expand Down Expand Up @@ -372,6 +383,7 @@ class Pagination extends Component {

renderPageJump() {
const { prefix, size, locale } = this.props;
const { inputValue } = this.state;

/* eslint-disable react/jsx-key */
return [
Expand All @@ -383,6 +395,7 @@ class Pagination extends Component {
type="text"
aria-label={locale.inputAriaLabel}
size={size}
value={inputValue}
onChange={this.onInputChange.bind(this)}
onKeyDown={e => {
if (e.keyCode === KEYCODE.ENTER) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/env.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* IE浏览器的渲染引擎版本号
* 注意:此属性与浏览器版本号不同,IE的渲染引擎版本号是可以通过HTML header或手动设置去更改的
* @type {Number} 6 ~ 10
* @type {Number} 6 ~ 11
*/
export const ieVersion =
typeof document !== 'undefined' ? document.documentMode : undefined;
Expand Down
36 changes: 29 additions & 7 deletions test/cascader/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@ describe('Cascader', () => {
findItem(wrapper, 1, 1).simulate('click');
});

it('should support remove title', () => {
ChinaArea[0].title = '';
wrapper = mount(<Cascader dataSource={ChinaArea} />);
assert(
wrapper
.find('.next-menu-item')
.at(0)
.getDOMNode()
.getAttribute('title') === ''
);
assert(
wrapper
.find('.next-menu-item')
.at(1)
.getDOMNode()
.getAttribute('title') === '四川'
);
delete ChinaArea[0].title;
});

it('could only select leaf item when set canOnlySelectLeaf to true', () => {
const handleChange = () => {
assert(false);
Expand Down Expand Up @@ -342,20 +362,22 @@ describe('Cascader', () => {

setTimeout(() => {
(value = ['2980']),
(data = [{ value: '2980', label: '铜川', pos: '0-0-1' }]);
(data = [{ value: '2980', label: '铜川', pos: '0-0-1' }]);
extra = {
checked: false,
currentData: { value: '2974', label: '西安', pos: '0-0-0' },
checkedData: [{ value: '2980', label: '铜川', pos: '0-0-1' }],
indeterminateData: [{ value: '2973', label: '陕西', pos: '0-0' }],
indeterminateData: [
{ value: '2973', label: '陕西', pos: '0-0' },
],
};
checkItem(findItem(wrapper, 1, 0), false);
compareIndeterminate(findItem(wrapper, 0, 0));
compareNotChecked(findItem(wrapper, 1, 0));
findItem(wrapper, 2).forEach(compareNotChecked);
assert(changeCalled);
done();
}, 20)
}, 20);
});

it('should render multiple cascader when set checkStrictly to true', () => {
Expand Down Expand Up @@ -701,14 +723,14 @@ function findRealItem(listIndex, itemIndex) {
[listIndex].querySelectorAll('.next-cascader-menu-item')[itemIndex];
}

function filter$Source (data) {
function filter$Source(data) {
if (!data) return;

return [...data].map((it) => {
return [...data].map(it => {
const item = {
...it
...it,
};
delete item._source;
return item;
})
});
}
Loading

0 comments on commit 563038a

Please sign in to comment.