# @bywin/drawer-hoc

> A higher-order component for Ant Design Drawer.

Latest version **1.0.2** (published 2020-11-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @bywin/drawer-hoc
pnpm add @bywin/drawer-hoc
yarn add @bywin/drawer-hoc
bun add @bywin/drawer-hoc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-11-29 |
| First published | 2020-11-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wengzhijie |
| Maintainers | bytrix |
| Keywords | Drawer |

## Links

- npm: https://www.npmjs.com/package/@bywin/drawer-hoc
- npm.io page: https://npm.io/package/@bywin/drawer-hoc

## Dependencies (1)

- [nanoid](https://npm.io/package/nanoid.md) ^3.1.18

## Recent versions

- 1.0.2 (latest) — 2020-11-29
- 1.0.1 — 2020-11-22
- 1.0.0 — 2020-11-22

## README

# DrawerHOC Usage Guide

A high-order component for Ant Design Drawer.

## Encapsulate Drawer

1. Create the component and wrap it with DrawerHOC.

```javascript
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.
    }
  }
})
```

2. Dispatch UI change

```javascript
const dispatch = useDispatch()
dispatch({
  type: 'DrawerHOC/updateUI',
  payload: {
    XxxDrawer: {
      visible: true
    }
  }
})
```

3. Add the corresponding component state in `src/models/DrawerHOC.js` file.

```javascript
state: {
  UIState: {
    DispositionCreateDrawer: {
      visible: false
    },
    DispositionFeatureCreateDrawer: {
      visible: false
    },
    FeatureListUpdateDrawer: {
      visible: false
    },
    XxxDrawer: {
      visible: false
    },
  }
}
```

4. Import the component in your page.

```jsx
<XxxDrawer />
```

5. Naming style of DrawerHOC.

  - XxxDetailDrawer
  - XxxCreateDrawer
  - XxxUpdateDrawer

## Encapsulate Form

```javascript
FormBuilder.createForm({
  schema: {
    properties: [
      [
        {
          key: 'form field key',
          title: 'form field label',
          value: 'string or form field component'
        }
      ]
    ]
  }
})
```

---
_Source: https://npm.io/package/@bywin/drawer-hoc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
