Skip to content

Commit

Permalink
chore(*): merge master conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lakerswgq committed Jul 28, 2022
2 parents 3f09e6b + 8d49599 commit 80e4a8c
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .commitlintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rules": {
"header-max-length": [2, "always", 90],
"header-max-length": [2, "always", 120],
"scope-empty": [2, "never"],
"scope-case": [2, "always", "pascal-case"],
"subject-empty": [2, "never"],
Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Change Log

## [1.25.48](https://github.com/alibaba-fusion/next/compare/1.25.47...1.25.48) (2022-07-28)


### Bug Fixes

* **NumberPicker:** ignore input not in -.\d fix [#3363](https://github.com/alibaba-fusion/next/issues/3363), [#3916](https://github.com/alibaba-fusion/next/issues/3916) ([e9c361f](https://github.com/alibaba-fusion/next/commit/e9c361f))
* **NumberPicker:** should not input bigger then max fix [#4002](https://github.com/alibaba-fusion/next/issues/4002) ([e2371e0](https://github.com/alibaba-fusion/next/commit/e2371e0))
* **Select:** auto close popup when item get clicked, close [#4004](https://github.com/alibaba-fusion/next/issues/4004) ([c879a52](https://github.com/alibaba-fusion/next/commit/c879a52))
* **Table:** table tree if without children should icon type equal, close [#4009](https://github.com/alibaba-fusion/next/issues/4009) ([#4022](https://github.com/alibaba-fusion/next/issues/4022)) ([09ea83e](https://github.com/alibaba-fusion/next/commit/09ea83e))




## [1.25.47](https://github.com/alibaba-fusion/next/compare/1.25.46...1.25.47) (2022-07-26)


### Bug Fixes

* **Tree:** fix select-all bug on parent node when treeCheckedStrategy set as "child", close [#3984](https://github.com/alibaba-fusion/next/issues/3984), [#3936](https://github.com/alibaba-fusion/next/issues/3936) ([7a86713](https://github.com/alibaba-fusion/next/commit/7a86713))




## [1.25.46](https://github.com/alibaba-fusion/next/compare/1.25.45...1.25.46) (2022-07-25)


### Bug Fixes

* fix sass build error ([7438bff](https://github.com/alibaba-fusion/next/commit/7438bff))




## [1.25.45](https://github.com/alibaba-fusion/next/compare/1.25.44...1.25.45) (2022-06-28)


Expand Down
7 changes: 5 additions & 2 deletions LATESTLOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Latest Log

## [1.25.45](https://github.com/alibaba-fusion/next/compare/1.25.44...1.25.45) (2022-06-28)
## [1.25.48](https://github.com/alibaba-fusion/next/compare/1.25.47...1.25.48) (2022-07-28)


### Bug Fixes

* **CascaderSelect:** filter duplicated non-existent value, close [#3921](https://github.com/alibaba-fusion/next/issues/3921) ([#3968](https://github.com/alibaba-fusion/next/issues/3968)) ([7b8ab75](https://github.com/alibaba-fusion/next/commit/7b8ab75))
* **NumberPicker:** ignore input not in -.\d fix [#3363](https://github.com/alibaba-fusion/next/issues/3363), [#3916](https://github.com/alibaba-fusion/next/issues/3916) ([e9c361f](https://github.com/alibaba-fusion/next/commit/e9c361f))
* **NumberPicker:** should not input bigger then max fix [#4002](https://github.com/alibaba-fusion/next/issues/4002) ([e2371e0](https://github.com/alibaba-fusion/next/commit/e2371e0))
* **Select:** auto close popup when item get clicked, close [#4004](https://github.com/alibaba-fusion/next/issues/4004) ([c879a52](https://github.com/alibaba-fusion/next/commit/c879a52))
* **Table:** table tree if without children should icon type equal, close [#4009](https://github.com/alibaba-fusion/next/issues/4009) ([#4022](https://github.com/alibaba-fusion/next/issues/4022)) ([09ea83e](https://github.com/alibaba-fusion/next/commit/09ea83e))


3 changes: 3 additions & 0 deletions docs/icon/demo/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ ReactDOM.render(
margin-top: 10px;
text-align: center;
font-size: 14px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}

.icon-list-custom-title {
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.25.45';
next.version = '1.25.48';

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.25.45",
"version": "1.25.48",
"description": "A configurable component library for web built on React.",
"keywords": [
"fusion",
Expand Down
2 changes: 1 addition & 1 deletion src/grid/scss/mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@if ($name == 'xl') {
$query: $minQuery;
} @else {
$query: $minQuery + "and" + $maxQuery;
$query: $minQuery + " and " + $maxQuery;
}
@media #{$query} { @content; }
}
Expand Down
31 changes: 21 additions & 10 deletions src/number-picker/number-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class NumberPicker extends React.Component {
const { stringMode } = this.props;
if (stringMode) {
try {
return Big(v1).gt(v2);
return Big(v1).gt(v2);
} catch (e) {
// big.js 遇到 Infinity 和 NaN 异常回退到 Number
return Number(v1) > Number(v2);
Expand Down Expand Up @@ -273,12 +273,7 @@ class NumberPicker extends React.Component {
const displayValue = `${this.state.displayValue}`;
// 展示值合法但超出边界时,额外在Blur时触发onChange
// 展示值非法时,回退前一个有效值
if (
editable === true &&
!isNaN(displayValue) &&
!this.shouldFireOnChange(displayValue) &&
!this.withinMinMax(displayValue)
) {
if (editable === true && !isNaN(displayValue) && !this.withinMinMax(displayValue)) {
let valueCorrected = this.correctValue(displayValue);
valueCorrected = stringMode ? Big(valueCorrected).toFixed(this.getPrecision()) : valueCorrected;
if (this.state.value !== valueCorrected) {
Expand All @@ -300,6 +295,12 @@ class NumberPicker extends React.Component {
return true;
}

withinMin(value) {
const { min } = this.state;
if (isNaN(value) || this.isGreaterThan(min, value)) return false;
return true;
}

setDisplayValue({ displayValue, onlyDisplay = false }) {
this.setState({ displayValue, onlyDisplay });
}
Expand All @@ -316,9 +317,13 @@ class NumberPicker extends React.Component {
: displayValue;
}

/**
* 输入时判断是否要触发onChange
* 正常触发: 合法数字 (eg: -0 -0. 0.1);超出最大值
* 不触发: 1. 非数字(eg: - ), 2. 小于最小值(输入需要过程由小变大)
*/
shouldFireOnChange(value) {
// 不触发onChange:a.非数字 b.超出边界的数字输入
if (isNaN(value) || !this.withinMinMax(value)) {
if (isNaN(value) || !this.withinMin(value)) {
return false;
}
return true;
Expand All @@ -327,12 +332,18 @@ class NumberPicker extends React.Component {
onChange(value, e) {
// ignore space & Compatible Chinese Input Method
value = value.replace('。', '.').trim();
// 过滤非数字
value = value.replace(/[^-.\d]/g, '');

let onlyDisplay = false;
if (this.props.editable === true && this.shouldFireOnChange(value)) {
let valueCorrected = this.correctValue(value);
const valueCorrected = this.correctValue(value);
if (this.state.value !== valueCorrected) {
this.setValue({ value: valueCorrected, e });
}
if (typeof this.props.max !== 'undefined' && this.isGreaterThan(value, this.state.max)) {
value = String(valueCorrected);
}
} else {
onlyDisplay = true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/select/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ class Select extends Base {
this.focusInput();
}

if (this.props.mode === 'single' && key === this.state.value) {
// key is string type here, fix https://github.com/alibaba-fusion/next/issues/4004
if (this.props.mode === 'single' && key === String(this.state.value)) {
this.setVisible(false, 'itemClick');
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/table/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@
}
}
&-tree-placeholder {
display: inline-block;
width: 12px;
@include icon-size($table-tree-expanded-icon-size);
visibility: hidden;
// display: inline-block;
// width: 12px;
}
}

Expand Down
36 changes: 6 additions & 30 deletions src/table/tree/cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,8 @@ export default class TreeCell extends React.Component {
};

render() {
const {
colIndex,
record,
prefix,
primaryKey,
locale,
rtl,
children,
} = this.props;
const {
openTreeRowKeys: openRowKeys,
indent,
isTree,
rowSelection,
} = this.context;
const { colIndex, record, prefix, primaryKey, locale, rtl, children } = this.props;
const { openTreeRowKeys: openRowKeys, indent, isTree, rowSelection } = this.context;
const treeArrowNodeIndex = rowSelection ? 1 : 0;
let firstCellStyle, treeArrowNode;
if (colIndex === treeArrowNodeIndex) {
Expand All @@ -65,15 +52,10 @@ export default class TreeCell extends React.Component {
[paddingType]: indent * (record.__level + 1),
};
treeArrowNode = (
<Icon
size="xs"
rtl={rtl}
className={`${prefix}table-tree-placeholder`}
/>
<Icon size="xs" rtl={rtl} className={`${prefix}table-tree-placeholder`} type="arrow-right" />
);
if (record.children && record.children.length) {
const hasExpanded =
openRowKeys.indexOf(record[primaryKey]) > -1;
const hasExpanded = openRowKeys.indexOf(record[primaryKey]) > -1;

treeArrowType = hasExpanded ? 'arrow-down' : 'arrow-right';

Expand All @@ -88,20 +70,14 @@ export default class TreeCell extends React.Component {
role="button"
tabIndex="0"
aria-expanded={hasExpanded}
aria-label={
hasExpanded ? locale.expanded : locale.folded
}
aria-label={hasExpanded ? locale.expanded : locale.folded}
/>
);
}
}
}
return (
<CellComponent
{...this.props}
innerStyle={firstCellStyle}
isIconLeft={!!treeArrowNode}
>
<CellComponent {...this.props} innerStyle={firstCellStyle} isIconLeft={!!treeArrowNode}>
{children}
{treeArrowNode}
</CellComponent>
Expand Down
5 changes: 1 addition & 4 deletions src/tree-select/tree-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,7 @@ class TreeSelect extends Component {

let keys = this.getKeysByValue(value);

if (treeCheckedStrategy !== 'child') {
// there's no need to calculate all checked value when treeCheckedStrategy=child, close #3936
keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n);
}
keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n);

switch (treeCheckedStrategy) {
case 'parent':
Expand Down
7 changes: 2 additions & 5 deletions src/tree/view/tree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const getCheckedKeys = (props, willReceiveProps, _k2n, _p2n) => {
checkedKeys = [];
}

const { checkStrictly, checkedStrategy } = props; // TODO TEST
const { checkStrictly } = props; // TODO TEST
if (checkStrictly) {
if (isPlainObject(checkedKeys)) {
const { checked, indeterminate } = checkedKeys;
Expand All @@ -142,10 +142,7 @@ const getCheckedKeys = (props, willReceiveProps, _k2n, _p2n) => {

checkedKeys = checkedKeys.filter(key => !!_k2n[key]);
} else {
if (checkedStrategy !== 'child') {
// checkedStrategy 为 child 时不需要计算所有可选值
checkedKeys = getAllCheckedKeys(checkedKeys, _k2n, _p2n);
}
checkedKeys = getAllCheckedKeys(checkedKeys, _k2n, _p2n);

checkedKeys = checkedKeys.filter(key => !!_k2n[key]);

Expand Down
10 changes: 9 additions & 1 deletion src/tree/view/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,15 @@ export function getAllCheckedKeys(checkedKeys, _k2n, _p2n) {
const parent = _p2n[parentPos];
if (parent.checkable === false || parent.disabled || parent.checkboxDisabled) continue;
const parentChecked = parent.children.every(child => isNodeChecked(child, flatKeys));
if (parentChecked) {

const isAllChildrenDisabled = parent.children.every(child => {
return child.disabled;
});

// don't auto select parent when all children are disabled,
// fix https://github.com/alibaba-fusion/next/issues/3936

if (parentChecked && !isAllChildrenDisabled) {
parent.children.forEach(removeKey);
addParentKey(i, parent);
} else {
Expand Down
28 changes: 25 additions & 3 deletions test/number-picker/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('number-picker', () => {
wrapper
.find('input')
.simulate('change', { target: { value: `${Number.MAX_SAFE_INTEGER}a2333` } });
assert(wrapper.find('input').prop('value') === `${Number.MAX_SAFE_INTEGER}a2333`);
assert(wrapper.find('input').prop('value') === `${Number.MAX_SAFE_INTEGER}2333`);
wrapper.find('input').simulate('blur');
assert(wrapper.find('input').prop('value') === `${Number.MAX_SAFE_INTEGER}2333`);
wrapper
Expand All @@ -148,7 +148,7 @@ describe('number-picker', () => {
wrapper2
.find('input')
.simulate('change', { target: { value: `${Number.MAX_SAFE_INTEGER}a2333` } });
assert(wrapper2.find('input').prop('value') === `${Number.MAX_SAFE_INTEGER}a2333`);
assert(wrapper2.find('input').prop('value') === `${Number.MAX_SAFE_INTEGER}2333`);
wrapper2.find('input').simulate('blur');
assert(wrapper2.find('input').prop('value') === `${Number.MAX_SAFE_INTEGER}2333`);
wrapper2
Expand Down Expand Up @@ -322,6 +322,18 @@ describe('number-picker', () => {
done();
});

it('should only input -.1234567890', () => {
let wrapper = mount(
<NumberPicker />
);
wrapper.find('input').simulate('change', { target: { value: '-1.' } });
assert(wrapper.find('input').prop('value') === "-1.");
wrapper.find('input').simulate('change', { target: { value: '-1.a' } });
assert(wrapper.find('input').prop('value') === "-1.");
wrapper.find('input').simulate('change', { target: { value: '-1.13a2' } });
assert(wrapper.find('input').prop('value') === "-1.132");
});

it('onChange value 1.9 -> 1. should input displayValue === 1. onchange value === 1', done => {
const onChange = (value) => {
assert(value === 1)
Expand Down Expand Up @@ -969,7 +981,17 @@ describe('number-picker', () => {
.at(1)
.simulate('click');
});


it('should not input number large then max', () => {
let wrapper = mount(
<NumberPicker max={10} />
);
wrapper.find('input').simulate('change', { target: { value: '100' } });
assert(wrapper.find('input').prop('value') === "10");
wrapper.find('input').simulate('change', { target: { value: '5' } });
assert(wrapper.find('input').prop('value') === "5");
});

it('should support precision', done => {
const wrapper = mount(
<NumberPicker defaultValue={0.121} step={0.01} precision={3} />
Expand Down
16 changes: 16 additions & 0 deletions test/tree-select/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,22 @@ describe('TreeSelect', () => {
assert.deepEqual(getLabels(wrapper), ['test1']);
});

it('should set parent node checked if all child nodes is checked even treeCheckedStrategy is "child"', () => {
wrapper = mount(
<TreeSelect
defaultVisible
treeCheckable
treeDefaultExpandAll
dataSource={dataSource}
style={{ width: 200 }}
treeCheckedStrategy="child"
value={['6']}
/>
)

assertChecked('3', true);
})

it('should render parent tag when set treeCheckedStrategy to all', () => {
wrapper = mount(
<TreeSelect
Expand Down

0 comments on commit 80e4a8c

Please sign in to comment.