1.3.17 • Published 10 months ago

react-data-mapping v1.3.17

Weekly downloads
58
License
MIT
Repository
gitlab
Last release
10 months ago

English | 简体中文

✨ Features

  • support for custom field attributes
  • support custom table name
  • support field connection number limit
  • support field sorting
  • support delay rendering, automatic adaptation of height and width, blank padding around
  • support custom empty field content

🔨QUCIK DEMO LOCAL

git clone git@github.com:aliyun/react-data-mapping.git
npm install
cd example
npm install
npm start

📦 Install

npm install react-data-mapping

API

DataMapping属性

PropertyDescriptionTypeDefault
widthComponent widthnumberDefault 500, you can set "auto" for adaptive
heightComponent heightnumberDefault 500, you can set "auto" for adaptive
typemapping typestringsingle | mutiply, default single
classNameComponent classNamestring-
sourceClassNameSource table classNamestring-
targetClassNameTarget table classNamestring-
columnsColumn propsColumns | Array<Columns>undefined
sourceDataSource table dataSourceData | Object | Array<SourceData>undefined
targetDataTarget table dataTargetData | Object | Array<TargetData>undefined
mappingDataInit mapping data, mappingData Proparray
emptyContentShow content when table field is emptystring | ReactNode-
emptyWidthTable container width when table field is empty, config Propstring | number150
configThe extra configuration of components,please reviewe the detailed API belowobject{}
isConnectEvent triggered before each edge connection to determine whether it can be connectedfunction(edge): boolean
onChangeEvent triggered by connectionfunction
onRowMouseOverEvent triggered when the mouse moves onto a row of datafunction(row)
onRowMouseOutEvent triggered when the mouse moves out of a row of datafunction(row)
onEdgeClickEvent triggered when the connection is clickedfunction(row)
readonlyRead onlybooleanDefault false

Column

A column describes a data object and is an item in a Columns.

PropertyDescriptionTypeDefault
keyThe path of column data in a data itemstring-
titleThe column header displays textstring-
widthThe column widthnumber-
primaryKeyWhether this property is uniquely identified for the set of databoolean必须且仅有一个属性为true
renderCustom rendering function, parameters are the value of the current row, the current row data, row indexfunction(text, record, index) {}-

sourceData

Source table data,when type is single , the sourceData type is { }; when typemutiply , the sourceData type is .

PropertyDescriptionTypeDefault
idColumn identifies, when type is single,the id is not required, when the type is mutiply, the id is requiredstring-
titleColumn titlestring-
filedsData record array to be displayedarray-
checkedIs it checkedbooleanfalse
disableNo connectionbooleanfalse

targetData

Target table data, when type is single , the targetData type is { }, when type is mutiply , the targetData type is , Please check sourceData

mappingData

PropertyDescriptionType
sourceUnique identification of the current row data in the source table-
targetUnique identification of the current row data in the target table-
sourceNodeThe ID of the source table, Please check sourceData IDstring
targetNodeThe ID of the target table, Please check targetData IDstring

config

The extra configuration of components

PropertyDescriptionTypeDefault
delayDrawDelayed rendering. This component must ensure that the canvas container rendering (including animation execution) is completed before rendering, otherwise the coordinates will be offset, for example:Animation of Ant Design Modalnumber0
extraPosPadding is reserved when rendering the canvasextraPos Prop { }-
sortableSorterboolean | object-
linkNumLimitNumber of lines limitednumber | object-
checkableSupport check boxcheckable Prop { }-

extraPos

Padding is reserved when rendering the canvas

PropertyDescriptionTypeDefault
paddingLeftPadding spacing on the leftnumber0
paddingRightPadding spacing on the rightnumber0
paddingTopPadding spacing on the topnumber0
paddingBottomPadding spacing on the bottomnumber0
paddingCenterCenter spacingnumber150
nodeVerticalPaddingNode vertical spacingnumber10
rowHeightfield row heightnumber26

checkable

Table supports checkbox

PropertyDescriptionTypeDefault
sourceleft table supports checkboxbooleanfalse
targetright table supports checkboxbooleanfalse

🔗API

interface columns { // setting the attributes of each column
  title ? : string; // the title of each column, similar to the concept of thead
  key: string; // the unique mark of each column, corresponding to the key value on the data
  width ? : number; // width of each column
  primaryKey: boolean // whether the value corresponding to the key in this column is used as a unique sign
  render?(text: any, record: any, index: number): void; // Custom rendering function
}

interface config {
  delayDraw: number; // Delayed rendering, this component must ensure that the canvas container rendering (including animation execution) is completed before rendering, otherwise the coordinates will be offset, such as: antd's modal animation
  extraPos ? : { // Padding is reserved when the canvas is rendered
      paddingLeft ? : number,
      paddingRight ? : number,
      paddingTop ? : number,
      paddingBottom ? : number,
      paddingCenter ? : number,
    },
    sortable ? : boolean | { // Sorting support, if it is true, the canvas will support sorting
      source ? : boolean, // If it is true, only the left source table supports sorting
      target ? : boolean // If it is true, only pure right target table supports sorting
    },
    linkNumLimit ? : number | { // Connection Number support, if it is number, the canvas supports n connections
      source ? : number, // If it is number, only the left source table supports n connections
      target ? : number // If it is number, only the left target table supports n connections
    },
    checkable ?: {  // table supports checkbox
      source ? : boolean, // // If it is true, only pure right target table supports checkbox
      target ? : boolean
    }
}

interface ComProps { // component props
  width ? : number; // component width
  height ? : number; // component height
  type ? : string; // "single"or"mutiply", single-table mapping (above pic one) or multi-table mapping (above pic two)
  className ? : string; // component className
  sourceClassName ? : string; // source table className
  targetClassName ? : string; // target table className
  columns: Array < columns > ; // please refer to the above interface columns
  sourceData: Array < any > | Object; // single-table mapping corresponds to Object, multi-table mapping Array, please refer to demo
  targetData: Array < any > | Object; // single-table mapping corresponds to Object, multi-table mapping Array, please refer to demo
  mappingData: Array < any > ; // initialize correspondence data, please refer to demo
  emptyContent ? : string | JSX.Element; // show content when table field is empty
  emptyWidth ? : number | string; // table container width when table field is empty
  isConnect?(edge: any): boolean; // isConnect event is triggered before you connect an edge, return true, it will connect, and false will not
  onChange(data: any): void // onChange event is triggered every time you connect edge
  onRowMouseOver?(row:any):void, // onRowMouseOver event is triggered when you move the cursor onto a row of data
  onRowMouseOut?(row:any):void, // onRowMouseOver event is triggered when you move the cursor out of a row of data
};
import ButterflyDataMapping from 'react-data-mapping';
import 'react-data-mapping/dist/index.css';

<ButterflyDataMapping
  width={500}
  height={1000}
  type={'single'}
  columns={columns}
  sourceData={sourceData}
  targetData={targetData}
  mappingData={mappingData}
  className={'butterfly-data-mapping'}
  sourceClassName={'source-column'}
  targetClassName={'target-column'}
/>

If you need more customized requirements, you can refer to issue or butterfly to customize your needs

1.3.17

10 months ago

1.3.15-beta.1

1 year ago

1.3.14

1 year ago

1.3.15

1 year ago

1.3.16

12 months ago

1.3.13

2 years ago

1.3.11

2 years ago

1.3.12

2 years ago

1.3.10

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.16

3 years ago

1.1.12

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.2

3 years ago