mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #10151 from baidu/280-6.3.0
Merge 280-6.3.0 into master
This commit is contained in:
commit
f079ca1128
@ -1,7 +1,10 @@
|
||||
import {toFixed} from '@rc-component/mini-decimal';
|
||||
|
||||
// 主要用于解决 0.1+0.2 结果的精度问题导致太长
|
||||
export function stripNumber(number: number, precision = 16) {
|
||||
if (typeof number === 'number' && !Number.isInteger(number)) {
|
||||
return parseFloat(number.toPrecision(precision));
|
||||
// return parseFloat(number.toPrecision(precision));
|
||||
return parseFloat(toFixed(number.toString(), '.', precision));
|
||||
} else {
|
||||
return number;
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ $tooltip-bottom: '[data-tooltip][data-position=' bottom ']:hover:after';
|
||||
&.width-draggable {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
// 用于避免右侧配置面板被超长的valueLabel撑开,导致样式异常
|
||||
.#{$ns}SubForm-valueLabel {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
// 外层有多个tab面板
|
||||
&.mul-tabs-panel {
|
||||
|
@ -681,6 +681,7 @@
|
||||
.#{$ns}ResultBox-value-wrap {
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
flex-wrap: nowrap; // 避免右侧下拉箭头换行
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,6 +452,7 @@
|
||||
display: inline-block;
|
||||
margin: px2rem(3px);
|
||||
vertical-align: middle;
|
||||
max-width: 100%; // 避免超出父级容器显示
|
||||
|
||||
&-caret {
|
||||
transition: transform var(--animation-duration) ease-out;
|
||||
|
@ -382,11 +382,21 @@ export class Range extends React.Component<RangeItemProps, any> {
|
||||
*/
|
||||
getStepValue(value: number, step: number) {
|
||||
const surplus = value % step;
|
||||
let curValue = 0;
|
||||
const closeNum = value - surplus;
|
||||
// 余数 >= 步长一半 -> 向上取,value为正值的时候,使用 safeAdd,否则使用 safeSub
|
||||
// 余数 < 步长一半 -> 向下取,使用 closeNum
|
||||
if (Math.abs(surplus) >= step / 2) {
|
||||
curValue = value >= 0 ? safeAdd(closeNum, step) : safeSub(closeNum, step);
|
||||
} else {
|
||||
curValue = closeNum;
|
||||
}
|
||||
/*
|
||||
let result = 0;
|
||||
let closeNum = Math.floor(value - (value % step));
|
||||
let closeNum = Math.floor(value - surplus);
|
||||
// 余数 >= 步长一半 -> 向上取
|
||||
// 余数 < 步长一半 -> 向下取
|
||||
const _value = surplus >= step / 2 ? value : safeSub(value, step);
|
||||
const _value = Math.abs(surplus) >= step / 2 ? value : safeSub(value, step);
|
||||
while (result <= _value) {
|
||||
if (step < 1 || result === 0 || result === closeNum) {
|
||||
result = safeAdd(result, step);
|
||||
@ -395,6 +405,8 @@ export class Range extends React.Component<RangeItemProps, any> {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
return curValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ exports[`EventAction:inputRange 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-InputRange-label pos-top cxd-InputRange-label-visible"
|
||||
class="cxd-InputRange-label pos-top"
|
||||
style="position: relative;"
|
||||
>
|
||||
<span>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {fireEvent, render, waitFor} from '@testing-library/react';
|
||||
// import {fireEvent as fireEvent2} from '@testing-library/dom';
|
||||
import '../../../../src';
|
||||
import {render as amisRender} from '../../../../src';
|
||||
import {makeEnv, wait} from '../../../helper';
|
||||
@ -14,6 +15,7 @@ test('EventAction:inputRange', async () => {
|
||||
type: 'input-range',
|
||||
name: 'range',
|
||||
value: 10,
|
||||
min: 0,
|
||||
showInput: true,
|
||||
clearabled: true,
|
||||
onEvent: {
|
||||
@ -116,6 +118,8 @@ test('EventAction:inputRange', async () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
/**
|
||||
* 滑动 change case先注释掉,因为fireEvent.mouseMove时,event中拿不到pageX。
|
||||
// 滑动 change
|
||||
const slider = container.querySelector('.cxd-InputRange-handle-icon')!;
|
||||
fireEvent.mouseDown(slider);
|
||||
@ -131,6 +135,15 @@ test('EventAction:inputRange', async () => {
|
||||
).toBeInTheDocument();
|
||||
expect(container.querySelector(`[value="值为0"]`)).toBeInTheDocument();
|
||||
});
|
||||
*/
|
||||
|
||||
// 临时替代滑动 change case
|
||||
fireEvent.change(inputs, {
|
||||
target: {
|
||||
value: 0
|
||||
}
|
||||
});
|
||||
await wait(300);
|
||||
|
||||
// focus
|
||||
fireEvent.focus(inputs);
|
||||
|
@ -54,7 +54,7 @@ const DEFAULT_EVENT_PARAMS = [
|
||||
|
||||
/**
|
||||
* Chart 图表渲染器。
|
||||
* 文档:https://aisuda.bce.baidu.com/amis/zh-CN/components/carousel
|
||||
* 文档:https://aisuda.bce.baidu.com/amis/zh-CN/components/chart
|
||||
*/
|
||||
export interface ChartSchema extends BaseSchema {
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user