Merge remote-tracking branch 'baidu/master'

This commit is contained in:
2betop 2020-04-08 14:56:56 +08:00
commit 1538f77e3a
5 changed files with 112 additions and 57 deletions

View File

@ -171,13 +171,18 @@
}
}
@mixin hover-focus {
&:hover,
@mixin focus {
&:focus {
@content;
}
}
@mixin hover-focus {
&:hover:focus {
@content;
}
}
@mixin hover-active {
&:hover:active {
@content;
@ -226,10 +231,24 @@
border-color: $border;
box-shadow: $Button-boxShadow;
@include hover {
color: $hover-color;
background-color: $hover-background;
border-color: $hover-border;
}
@include focus {
color: $color;
background-color: $background;
border-color: $border;
box-shadow: $Button-boxShadow;
}
@include hover-focus {
color: $hover-color;
background-color: $hover-background;
border-color: $hover-border;
box-shadow: $Button-boxShadow;
}
&.is-disabled,

View File

@ -87,6 +87,7 @@
background: $Calendar-shortcuts-bg;
padding: ($Calendar-shortcuts-height - $Calendar-fontSize * $lineHeightBase) / 2 $gap-sm;
list-style: none;
width: px2rem(250px);
&+.rdt .rdtPicker {
padding-top: 0;
@ -95,7 +96,7 @@
.#{$ns}DatePicker-shortcut {
display: inline-block;
margin-right: $gap-md;
margin-right: $gap-sm;
a {
font-size: $Calendar-fontSize;

View File

@ -17,6 +17,12 @@ import Calendar from './calendar/Calendar';
import 'react-datetime/css/react-datetime.css';
const availableShortcuts: {[propName: string]: any} = {
now: {
label: '现在',
date: (now: moment.Moment) => {
return now;
}
},
today: {
label: '今天',
date: (now: moment.Moment) => {
@ -89,6 +95,28 @@ const availableShortcuts: {[propName: string]: any} = {
};
const advancedShortcuts = [
{
regexp: /^(\d+)hoursago$/,
resolve: (_: string, hours: string) => {
return {
label: `${hours}小时前`,
date: (now: moment.Moment) => {
return now.subtract(hours, 'hours');
}
};
}
},
{
regexp: /^(\d+)hourslater$/,
resolve: (_: string, hours: string) => {
return {
label: `${hours}小时后`,
date: (now: moment.Moment) => {
return now.add(hours, 'hours');
}
};
}
},
{
regexp: /^(\d+)daysago$/,
resolve: (_: string, days: string) => {

View File

@ -348,7 +348,14 @@ export const filters: {
* @param data
*/
function getStrOrVariable(arg: string, data: any) {
return /^('|")(.*)\1$/.test(arg) ? RegExp.$2 : resolveVariable(arg, data);
return /^('|")(.*)\1$/.test(arg)
? RegExp.$2
: /^-?\d+$/.test(arg)
? parseInt(arg, 10)
: /^(-?\d+)\.\d+?$/.test(arg)
? parseFloat(arg)
: resolveVariable(arg, data);
}
function getConditionValue(

View File

@ -4,7 +4,7 @@ const isEmpty = (value: any) => value === '';
const makeRegexp = (reg: string | RegExp) => {
if (reg instanceof RegExp) {
return reg;
} else if (/\/(.+)\/([gimuy]*)/.test(reg)) {
} else if (/^\/(.+)\/([gimuy]*)$/.test(reg)) {
return new RegExp(RegExp.$1, RegExp.$2 || '');
} else if (typeof reg === 'string') {
return new RegExp(reg);