An open API service indexing awesome lists of open source software.

https://github.com/johnnyxcy/mas-data-mapping

A data mapping component
https://github.com/johnnyxcy/mas-data-mapping

component javascript jsx react react-redux redux redux-toolkit typescript

Last synced: 16 days ago
JSON representation

A data mapping component

Awesome Lists containing this project

README

        

---
title: 'MaSDataMapping'
---

mas-icon

MaS Data Mapping

A React component for performing "map" actions

**_Visit this [github page](https://johnnyxcy.github.io/mas-data-mapping)_** 🤓

## ⭐ Feature

- 😸 Perform "map" action in multiple ways
- 👍 Well-implemented **drag and drop** functionality
- 🌈 Customizable styles

## 📦 Installation

```bash
$ git clone [email protected]:Johnnyxcy/mas-data-mapping.git
$ npm install
```

Will be published to npm ASAP 🥹

## Basic Usage

```tsx
/**
* title: Basic Demo
* desc: 👉 Try to drag node in **Available** slot into any slot below
👉 Try to click slot to trigger dropdown selection
👉 Try to input any value in slot
👉 Try to use `ctrl` / `cmd` key to select multiple nodes and drag
👉 Try to use `shift` key to select multiple nodes in the same slot and drag
*/

import React from 'react';
import DataMapping from 'mas-data-mapping';
import { Alert, Divider, Space, Switch } from 'antd';

const demoData = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
const nodes = demoData.map((colName) => ({ id: colName, label: colName }));

const slots = [
{
id: 'SingleRequired',
label: 'SingleRequired',
required: true,
allowMultiple: false,
visible: true,
},
{
id: 'MultipleRequired',
label: 'MultipleRequired',
required: true,
allowMultiple: true,
visible: true,
},
{
id: 'SingleOptional',
label: 'SingleOptional',
required: false,
allowMultiple: false,
visible: true,
},
{
id: 'MultipleOptional',
label: 'MultipleOptional',
required: false,
allowMultiple: true,
visible: true,
},
{
id: 'HiddenSlot',
label: 'HiddenSlot',
visible: false,
},
];

type MappingType = Record;
const initialMapping: MappingType = {};
initialMapping['SingleOptional'] = ['E'];
initialMapping['HiddenSlot'] = ['F'];

export default () => {
const [mappingHistoryList, setMappingHistoryList] = React.useState<
MappingType[]
>([]);

const [showHidden, setShowHidden] = React.useState(true);

const onMappingChange = React.useCallback(
(mapping: MappingType) =>
setMappingHistoryList(mappingHistoryList.concat(mapping)),
[mappingHistoryList],
);

const mappingHistoryAlerts = React.useMemo(
() =>
mappingHistoryList.map((mappingHistory, index) => (

)),
[mappingHistoryList],
);

return (
<>



Show Hidden:






Action History


{mappingHistoryAlerts}

>
);
};
```

## Development

### Clone and install the dependencies

```bash
$ git clone [email protected]:Johnnyxcy/mas-data-mapping.git
$ npm install
```

### Start dev server via scaffolding [umijs/dumi](https://github.com/umijs/dumi)

```bash
npm start
```

### License

`mas-data-mapping` is licensed under [MIT](https://opensource.org/licenses/MIT)