Package Exports
- @bywin/drawer-hoc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bywin/drawer-hoc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
DrawerHOC Usage Guide
A high-order component for Ant Design Drawer.
Encapsulate Drawer
- Create the component and wrap it with DrawerHOC.
import DrawerHOC from '@bywin/drawer-hoc'
import React from 'react'
const XxxDrawer = (props) => {
const [form] = Form.useForm()
const model = {
[key]: value
}
return (
props.bindForm(form, model)({
schema: {
properties: [
[
{
key: 'form field key',
title: 'form field label',
value: 'string or form field component'
}
]
]
}
})
)
}
export default DrawerHOC(XxxDrawer, {
title: 'drawer title',
type: 'ADD' | 'UPDATE' | 'DETAIL',
events: {
onOk: (dispatch, data) => {
// TODO: handle form submition here with dispatch.
}
}
})- Dispatch UI change
const dispatch = useDispatch()
dispatch({
type: 'DrawerHOC/updateUI',
payload: {
XxxDrawer: {
visible: true
}
}
})- Add the corresponding component state in
src/models/DrawerHOC.jsfile.
state: {
UIState: {
DispositionCreateDrawer: {
visible: false
},
DispositionFeatureCreateDrawer: {
visible: false
},
FeatureListUpdateDrawer: {
visible: false
},
XxxDrawer: {
visible: false
},
}
}- Import the component in your page.
<XxxDrawer />- Naming style of DrawerHOC.
- XxxDetailDrawer
- XxxCreateDrawer
- XxxUpdateDrawer
Encapsulate Form
FormBuilder.createForm({
schema: {
properties: [
[
{
key: 'form field key',
title: 'form field label',
value: 'string or form field component'
}
]
]
}
})