JSPM

@bywin/drawer-hoc

1.0.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 2
    • Score
      100M100P100Q54429F
    • License ISC

    A higher-order component for Ant Design Drawer.

    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

    1. 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.
        }
      }
    })
    1. Dispatch UI change
    const dispatch = useDispatch()
    dispatch({
      type: 'DrawerHOC/updateUI',
      payload: {
        XxxDrawer: {
          visible: true
        }
      }
    })
    1. Add the corresponding component state in src/models/DrawerHOC.js file.
    state: {
      UIState: {
        DispositionCreateDrawer: {
          visible: false
        },
        DispositionFeatureCreateDrawer: {
          visible: false
        },
        FeatureListUpdateDrawer: {
          visible: false
        },
        XxxDrawer: {
          visible: false
        },
      }
    }
    1. Import the component in your page.
    <XxxDrawer />
    1. 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'
            }
          ]
        ]
      }
    })