-
Notifications
You must be signed in to change notification settings - Fork 0
/
Row.js
73 lines (68 loc) · 2.13 KB
/
Row.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react';
import { Column, CheckColumn } from './';
import Styled from 'styled-components';
const row = Styled.div
export const Row = React.forwardRef((props, ref) => {
let { columns, data, onClick, rowKey,onDoubleClick, selected, selectable, onChecked, editing, editingErrors, onConfirm, onCancelEdit, dataLength, index, appendRow, onCellDoubleClick, table, disabledChangeIndicator = false } = props;
if (Array.isArray(columns)) {
return (
<div ref={ref} className={`row-body ${data._isValid === false && "row-invalid"} ${!disabledChangeIndicator && data.phantom ? "row-body-phantom" : ""} ${selected && "selected"}`} onClick={onClick} onDoubleClick={onDoubleClick}>
{
!disabledChangeIndicator && data.phantom ? <div className={"arrow-corner"}></div> : null
}
{
selectable ?
<CheckColumn data={data} width={50} align={"center"} checked={selected} onChecked={onChecked} />
: null
}
{
columns.map((col, colIndex) => {
let key = col.id;
return (<Column
key={`${rowKey}${key}`}
type={col.type}
format={col.format}
value={data.get ? data.get(col.dataIndex) || "" : data[col.dataIndex]}
dataIndex={col.dataIndex}
width={col.width}
align={col.align}
render={col.render}
col={col}
table={table}
record={data}
colIndex={colIndex}
rowIndex={index}
editing={editing}
editingErrors={editingErrors}
onConfirm={onConfirm}
onCancelEdit={onCancelEdit}
onDoubleClick={(e) => {
onCellDoubleClick({
e,
value: data.get ? data.get(col.dataIndex) || "" : data[col.dataIndex],
dataIndex: col.dataIndex,
table: table,
record: data,
rowIndex: index,
colIndex,
col
})
}
}
/>)
})
}
{
appendRow && appendRow({ data, columns, index, dataLength, selected, selected })
// (dataLength == index && appendRow) && customAddRow
}
</div>
);
} else {
return <div></div>;
}
}
// <button ref={ref} className="FancyButton">
// {props.children}
// </button>
);