mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
feat: data等组件focus&blur组件参数修改,新增级联demo
This commit is contained in:
parent
6093109451
commit
e49b380104
@ -116,8 +116,8 @@ order: 15
|
|||||||
| 事件名称 | 事件参数 | 说明 |
|
| 事件名称 | 事件参数 | 说明 |
|
||||||
| -------- | ---------------------- | -------------------- |
|
| -------- | ---------------------- | -------------------- |
|
||||||
| change | `value: string` 时间值 | 值变化 |
|
| change | `value: string` 时间值 | 值变化 |
|
||||||
| focus | - | 获得焦点(非内嵌模式) |
|
| focus | `value: string` 时间值 | 获得焦点(非内嵌模式) |
|
||||||
| blur | - | 失去焦点(非内嵌模式) |
|
| blur | `value: string` 时间值 | 失去焦点(非内嵌模式) |
|
||||||
|
|
||||||
## 动作表
|
## 动作表
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ order: 15
|
|||||||
| 事件名称 | 事件参数 | 说明 |
|
| 事件名称 | 事件参数 | 说明 |
|
||||||
| -------- | ---------------------- | -------------------- |
|
| -------- | ---------------------- | -------------------- |
|
||||||
| change | `value: string` 时间值 | 值变化 |
|
| change | `value: string` 时间值 | 值变化 |
|
||||||
| focus | - | 获得焦点(非内嵌模式) |
|
| focus | `value: string` 时间值 | 获得焦点(非内嵌模式) |
|
||||||
| blur | - | 失去焦点(非内嵌模式) |
|
| blur | `value: string` 时间值 | 失去焦点(非内嵌模式) |
|
||||||
|
|
||||||
## 动作表
|
## 动作表
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ order: 32
|
|||||||
| 事件名称 | 事件参数 | 说明 |
|
| 事件名称 | 事件参数 | 说明 |
|
||||||
| -------- | ---------------------- | -------------------- |
|
| -------- | ---------------------- | -------------------- |
|
||||||
| change | `value: number` 值变化 | 输入值发生变化时触发 |
|
| change | `value: number` 值变化 | 输入值发生变化时触发 |
|
||||||
| blur | - | - |
|
| blur | `value: number` 值变化 | - |
|
||||||
| focus | - | - |
|
| focus | `value: number` 值变化 | - |
|
||||||
|
|
||||||
## 动作表
|
## 动作表
|
||||||
|
|
||||||
|
@ -283,8 +283,8 @@ order: 38
|
|||||||
| 事件名称 | 事件参数 | 说明 |
|
| 事件名称 | 事件参数 | 说明 |
|
||||||
| -------- | ----------------------------------------------------------------- | ---------------------------------------------- |
|
| -------- | ----------------------------------------------------------------- | ---------------------------------------------- |
|
||||||
| change | `value: number \| string \|{min: number, max: number}` 滑块当前值 | 当值变化时触发的事件 |
|
| change | `value: number \| string \|{min: number, max: number}` 滑块当前值 | 当值变化时触发的事件 |
|
||||||
| blur | - | 输入框失去焦点<br/>前置条件:showInput 为 true |
|
| blur | `value: number \| string \|{min: number, max: number}` 滑块当前值 | 输入框失去焦点<br/>前置条件:showInput 为 true |
|
||||||
| focus | - | 输入框获取焦点<br/>前置条件:showInput 为 true |
|
| focus | `value: number \| string \|{min: number, max: number}` 滑块当前值 | 输入框获取焦点<br/>前置条件:showInput 为 true |
|
||||||
|
|
||||||
## 动作表
|
## 动作表
|
||||||
|
|
||||||
|
@ -318,8 +318,8 @@ order: 60
|
|||||||
| edit | `options: Option[]`,`value: Option` 编辑节点信息 | 编辑选项 |
|
| edit | `options: Option[]`,`value: Option` 编辑节点信息 | 编辑选项 |
|
||||||
| delete | `options: Option[]`,`value: Option` 删除节点信息 | 删除选项 |
|
| delete | `options: Option[]`,`value: Option` 删除节点信息 | 删除选项 |
|
||||||
| loadFinished | value: `json` 懒加载返回的数据 | 懒加载完成触发 |
|
| loadFinished | value: `json` 懒加载返回的数据 | 懒加载完成触发 |
|
||||||
| blur | - | 输入框失去焦点 |
|
| blur | `value: string` 选中值 | 输入框失去焦点 |
|
||||||
| focus | - | 输入框获取焦点 |
|
| focus | `value: string` 选中值 | 输入框获取焦点 |
|
||||||
|
|
||||||
## 动作表
|
## 动作表
|
||||||
|
|
||||||
|
@ -332,6 +332,55 @@ export default {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'tpl',
|
||||||
|
tpl: 'chained-select级联下拉框',
|
||||||
|
inline: false,
|
||||||
|
wrapperComponent: 'h2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'form',
|
||||||
|
debug: true,
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'group',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
name: 'trigger11',
|
||||||
|
id: 'trigger11',
|
||||||
|
type: 'action',
|
||||||
|
label: 'clear触发器',
|
||||||
|
level: 'primary',
|
||||||
|
onEvent: {
|
||||||
|
click: {
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
actionType: 'clear',
|
||||||
|
componentId: 'clear-chained-select',
|
||||||
|
description: '点击清空指定级联下拉框选中值'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'clear-chained-select',
|
||||||
|
id: 'clear-chained-select',
|
||||||
|
label: 'clear动作测试',
|
||||||
|
mode: 'row',
|
||||||
|
type: 'chained-select',
|
||||||
|
source: '/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4',
|
||||||
|
value: 'a,b',
|
||||||
|
onEvent: {
|
||||||
|
change,
|
||||||
|
blur,
|
||||||
|
focus
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'tpl',
|
type: 'tpl',
|
||||||
tpl: 'input-city城市选择器',
|
tpl: 'input-city城市选择器',
|
||||||
|
@ -179,9 +179,15 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|||||||
|
|
||||||
// 派发有event的事件
|
// 派发有event的事件
|
||||||
@autobind
|
@autobind
|
||||||
dispatchEvent(e: React.SyntheticEvent<HTMLElement>) {
|
dispatchEvent(eventName: string) {
|
||||||
const {dispatchEvent, data} = this.props;
|
const {dispatchEvent, data, value} = this.props;
|
||||||
dispatchEvent(e, data);
|
|
||||||
|
dispatchEvent(
|
||||||
|
eventName,
|
||||||
|
createObject(data, {
|
||||||
|
value
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动作
|
// 动作
|
||||||
@ -258,8 +264,8 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|||||||
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
||||||
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
onFocus={this.dispatchEvent}
|
onFocus={() => this.dispatchEvent('focus')}
|
||||||
onBlur={this.dispatchEvent}
|
onBlur={() => this.dispatchEvent('blur')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -162,9 +162,15 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
|||||||
|
|
||||||
// 派发有event的事件
|
// 派发有event的事件
|
||||||
@autobind
|
@autobind
|
||||||
dispatchEvent(e: React.SyntheticEvent<HTMLElement>) {
|
dispatchEvent(eventName: string) {
|
||||||
const {dispatchEvent, data} = this.props;
|
const {dispatchEvent, data, value} = this.props;
|
||||||
dispatchEvent(e, data);
|
|
||||||
|
dispatchEvent(
|
||||||
|
eventName,
|
||||||
|
createObject(data, {
|
||||||
|
value
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动作
|
// 动作
|
||||||
@ -220,8 +226,8 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
|||||||
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
||||||
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
onFocus={this.dispatchEvent}
|
onFocus={() => this.dispatchEvent('focus')}
|
||||||
onBlur={this.dispatchEvent}
|
onBlur={() => this.dispatchEvent('blur')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -195,9 +195,15 @@ export default class NumberControl extends React.Component<
|
|||||||
|
|
||||||
// 派发有event的事件
|
// 派发有event的事件
|
||||||
@autobind
|
@autobind
|
||||||
dispatchEvent(e: React.SyntheticEvent<HTMLElement>) {
|
async dispatchEvent(eventName: string) {
|
||||||
const {dispatchEvent, data} = this.props;
|
const {dispatchEvent, data, value} = this.props;
|
||||||
dispatchEvent(e, data);
|
|
||||||
|
dispatchEvent(
|
||||||
|
eventName,
|
||||||
|
createObject(data, {
|
||||||
|
value
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleChange(inputValue: any) {
|
async handleChange(inputValue: any) {
|
||||||
@ -333,8 +339,8 @@ export default class NumberControl extends React.Component<
|
|||||||
showSteps={showSteps}
|
showSteps={showSteps}
|
||||||
borderMode={borderMode}
|
borderMode={borderMode}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
onFocus={this.dispatchEvent}
|
onFocus={() => this.dispatchEvent('focus')}
|
||||||
onBlur={this.dispatchEvent}
|
onBlur={() => this.dispatchEvent('blur')}
|
||||||
keyboard={keyboard}
|
keyboard={keyboard}
|
||||||
displayMode={displayMode}
|
displayMode={displayMode}
|
||||||
/>
|
/>
|
||||||
|
@ -375,17 +375,29 @@ export class Input extends React.Component<RangeItemProps, any> {
|
|||||||
*/
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
onBlur() {
|
onBlur() {
|
||||||
const {data, dispatchEvent} = this.props;
|
const {data, dispatchEvent, value} = this.props;
|
||||||
dispatchEvent('blur', data);
|
|
||||||
|
dispatchEvent(
|
||||||
|
'blur',
|
||||||
|
createObject(data, {
|
||||||
|
value
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聚焦事件
|
* 聚焦事件
|
||||||
*/
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
onFocus() {
|
async onFocus() {
|
||||||
const {data, dispatchEvent} = this.props;
|
const {data, dispatchEvent, value} = this.props;
|
||||||
dispatchEvent('focus', data);
|
|
||||||
|
dispatchEvent(
|
||||||
|
'focus',
|
||||||
|
createObject(data, {
|
||||||
|
value
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -205,19 +205,23 @@ export default class TreeSelectControl extends React.Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleFocus(e: any) {
|
handleFocus(e: any) {
|
||||||
const {dispatchEvent} = this.props;
|
const {dispatchEvent, value, data} = this.props;
|
||||||
this.setState({
|
this.setState({
|
||||||
isFocused: true
|
isFocused: true
|
||||||
});
|
});
|
||||||
dispatchEvent('focus', e);
|
dispatchEvent('focus', createObject(data, {
|
||||||
|
value
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBlur(e: any) {
|
handleBlur(e: any) {
|
||||||
const {dispatchEvent} = this.props;
|
const {dispatchEvent, value, data} = this.props;
|
||||||
this.setState({
|
this.setState({
|
||||||
isFocused: false
|
isFocused: false
|
||||||
});
|
});
|
||||||
dispatchEvent('blur', e);
|
dispatchEvent('blur', createObject(data, {
|
||||||
|
value
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyPress(e: React.KeyboardEvent) {
|
handleKeyPress(e: React.KeyboardEvent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user