mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
feat: 时间类的事件和动作补充
This commit is contained in:
parent
15c36bc608
commit
5924521a39
@ -332,7 +332,7 @@ export class DateRangePicker extends React.Component<
|
||||
isFocused: true
|
||||
});
|
||||
const {onFocus} = this.props;
|
||||
onFocus && onFocus();
|
||||
onFocus && onFocus(e);
|
||||
}
|
||||
|
||||
handleBlur(e: React.SyntheticEvent<HTMLDivElement>) {
|
||||
@ -340,7 +340,7 @@ export class DateRangePicker extends React.Component<
|
||||
isFocused: false
|
||||
});
|
||||
const {onBlur} = this.props;
|
||||
onBlur && onBlur();
|
||||
onBlur && onBlur(e);
|
||||
}
|
||||
|
||||
open() {
|
||||
|
@ -415,9 +415,9 @@ export default class DateControl extends React.PureComponent<
|
||||
|
||||
// 派发有event的事件
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent(event, createObject(data));
|
||||
dispatchEvent(eventName: string, e: React.SyntheticEvent<HTMLElement> | string) {
|
||||
const {dispatchEvent, value} = this.props;
|
||||
const dispatcher = dispatchEvent(eventName, createObject({e, value}));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
@ -434,8 +434,11 @@ export default class DateControl extends React.PureComponent<
|
||||
// 值的变化
|
||||
@autobind
|
||||
async handleChange(data: any) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject(data));
|
||||
const {dispatchEvent, value} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject({
|
||||
oldValue: value,
|
||||
value: data
|
||||
}));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
@ -485,8 +488,8 @@ export default class DateControl extends React.PureComponent<
|
||||
largeMode={largeMode}
|
||||
onScheduleClick={this.onScheduleClick.bind(this)}
|
||||
onChange={this.handleChange}
|
||||
onFocus={this.dispatchEvent}
|
||||
onBlur={this.dispatchEvent}
|
||||
onFocus={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('focus', e)}
|
||||
onBlur={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('blur', e)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -165,9 +165,9 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
||||
|
||||
// 派发有event的事件
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent(event, createObject(data));
|
||||
dispatchEvent(eventName: string, e: React.SyntheticEvent<HTMLElement> | string) {
|
||||
const {dispatchEvent, value} = this.props;
|
||||
const dispatcher = dispatchEvent(eventName, createObject({e, value}));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
@ -184,8 +184,11 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
||||
// 值的变化
|
||||
@autobind
|
||||
async handleChange(data: any) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject(data));
|
||||
const {dispatchEvent, value} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject({
|
||||
oldValue: value,
|
||||
value: data
|
||||
}));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
@ -227,8 +230,8 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
||||
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
||||
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
||||
onChange={this.handleChange}
|
||||
onFocus={this.dispatchEvent}
|
||||
onBlur={this.dispatchEvent}
|
||||
onFocus={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('focus', e)}
|
||||
onBlur={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('blur', e)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -162,9 +162,9 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
||||
|
||||
// 派发有event的事件
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent(event, createObject(data));
|
||||
dispatchEvent(eventName: string, e: React.SyntheticEvent<HTMLElement> | string) {
|
||||
const {dispatchEvent, value} = this.props;
|
||||
const dispatcher = dispatchEvent(eventName, createObject({e, value}));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
@ -181,8 +181,11 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
||||
// 值的变化
|
||||
@autobind
|
||||
async handleChange(data: any) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject(data));
|
||||
const {dispatchEvent, value} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject({
|
||||
oldValue: value,
|
||||
value: data
|
||||
}));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
@ -217,8 +220,8 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
||||
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
||||
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
||||
onChange={this.handleChange}
|
||||
onFocus={this.dispatchEvent}
|
||||
onBlur={this.dispatchEvent}
|
||||
onFocus={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('focus', e)}
|
||||
onBlur={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('blur', e)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -1,12 +1,10 @@
|
||||
import React from 'react';
|
||||
import {FormItem} from './Item';
|
||||
import cx from 'classnames';
|
||||
import includes from 'lodash/includes';
|
||||
import {filterDate, parseDuration} from '../../utils/tpl-builtin';
|
||||
import InputDateRange, {DateRangeControlSchema} from './InputDateRange';
|
||||
import DateRangePicker from '../../components/DateRangePicker';
|
||||
import {createObject, autobind} from '../../utils/helper';
|
||||
import {Action} from '../../types';
|
||||
|
||||
/**
|
||||
* YearRange 年份范围控件
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/input-year-range
|
||||
@ -17,7 +15,6 @@ export interface YearRangeControlSchema
|
||||
}
|
||||
|
||||
export default class YearRangeControl extends InputDateRange {
|
||||
|
||||
render() {
|
||||
const {
|
||||
className,
|
||||
@ -50,8 +47,8 @@ export default class YearRangeControl extends InputDateRange {
|
||||
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
||||
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
||||
onChange={this.handleChange}
|
||||
onFocus={this.dispatchEvent}
|
||||
onBlur={this.dispatchEvent}
|
||||
onFocus={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('focus', e)}
|
||||
onBlur={(e: React.SyntheticEvent<HTMLDivElement>) => this.dispatchEvent('blur', e)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user