import React, { Component } from 'react';
import { Input, InputNumber, Select, Radio, DatePicker, Form } from 'antd';
import * as Tools from 'jad-tool'
import classname from 'classnames'
import { checkValidateRule } from 'jad-tool'
const { RangePicker } = DatePicker;
export const baseShow_middle = ({ config, componentInstance, interrupt }) => (next) => (params) => {
const { show = true } = componentInstance.props
if (!show) {
interrupt(null)
}
next(params)
}
export const baseValidate_middle = ({ config, componentInstance, interrupt }) => (next) => (params) => {
let { value, props={}, rule = new RegExp(''), message = '', name = '' } = componentInstance.props
let error = checkValidateRule(rule, value)
message = Tools.isString(error) ? error : message;
const validate = !error ? 'success' : 'error';
const help = !error ? false : message
const render = (
{params}
)
next(render)
}
export const baseFormLabel_middle = ({ config, componentInstance, interrupt }) => (next) => (params) => {
const { label = '', hint = '', } = componentInstance.props
const render = (
{params}
{
hint ?
{hint}
: ''
}
)
next(render)
}
export const baseInput_middle = ({ config, componentInstance, interrupt }) => {
//如果中间件内部使用classComponent 需要把他放到第一次科里化中 ,不然会因为fiber.elementType render的不同一直卸载重装
// fiber的update是同步的 Input update被提升
// 导致 第一次 input value = a
// 第二次 classComponent update input value = ''
// 第三次 classComponent propsUpdate input value = a
class InputMiddel extends React.Component{
state = {
value: ''
}
constructor(props) {
super(props)
if ('value' in props) {
this.state.value = props.value
}
}
UNSAFE_componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
this.setState({
value: nextProps.value
})
}
}
handleChange = (e) => {
const { onChange = (e) => e } = this.props
this.setState({
value: e.target.value
})
onChange(e)
}
render() {
const { type = 'text',props={}, placeholder = "", disabled = false, name = "", style = { width: '100%' } } = this.props
const { value } = this.state
return
}
}//如果中间件内部使用classComponent 需要把他放到第一次科里化中 ,不然会因为fiber.elementType render的不同一直卸载重装
return (next) => (params) => {
next()
}
}
export const baseSelect_middle = ({ config, componentInstance, interrupt }) => (next) => (params) => {
const { value = [], props={}, placeholder = "", disabled = false, onChange = (e) => { }, children = null, style = { width: '100%' }, showSearch = false, filterOption = false, onSearch = (e) => { } } = componentInstance.props
const render = (
)
next(render)
}
export const baseRadio_middle = ({ config, componentInstance, interrupt }) => (next) => (params) => {
const { value = false, props={}, disabled = false, onChange = (e) => { }, children = null } = componentInstance.props
const render = (
{children}
)
next(render)
}
export const baseRangePicker_middle = ({ config, componentInstance, interrupt }) => (next) => (params) => {
const { value = false, props={}, disabled = false, onChange = (e) => { } } = componentInstance.props
const render = (
)
next(render)
}