This repository was archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathApp.js
82 lines (73 loc) · 2.54 KB
/
App.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
74
75
76
77
78
79
80
81
82
/* eslint no-magic-numbers: 0 */
import * as R from 'ramda';
import React, {Component} from 'react';
import { DataTable } from 'dash-table';
import {mockData} from './data';
import { memoizeOne } from 'core/memoizer';
import Logger from 'core/Logger';
const clone = o => JSON.parse(JSON.stringify(o));
class App extends Component {
constructor() {
super();
const data: any[] = clone(mockData.data);
this.state = {
filter: '',
tableProps: {
id: 'table',
data,
columns: clone(mockData.columns).map(col => R.merge(col, {
name: col.name || col.id,
editable_name: true,
deletable: true
// type: 'dropdown'
})),
editable: true,
sorting: true,
n_fixed_rows: 4,
n_fixed_columns: 2,
merge_duplicate_headers: false,
row_deletable: true,
row_selectable: 'single',
content_style: 'fit',
column_static_dropdown: [
{
id: 'bbb',
dropdown: ['Humid', 'Wet', 'Snowy', 'Tropical Beaches'].map(i => ({
label: i,
value: i,
}))
}
],
style_table: {
max_width: '1000px',
width: '1000px'
},
style_data_conditional: [
{ max_width: 150, min_width: 150, width: 150 },
{ if: { column_id: 'rows' }, max_width: 40, min_width: 40, width: 40 },
{ if: { column_id: 'bbb' }, max_width: 200, min_width: 200, width: 200 },
{ if: { column_id: 'bbb-readonly' }, max_width: 200, min_width: 200, width: 200 }
],
}
};
const setProps = memoizeOne(() => {
return newProps => {
Logger.debug('--->', newProps);
this.setState(prevState => ({
tableProps: R.merge(prevState.tableProps, newProps)
}));
};
});
Object.defineProperty(this, 'setProps', {
get: () => setProps()
});
}
render() {
return (<DataTable
setProps={this.setProps}
{...this.state.tableProps}
{...{ filtering: 'fe' }}
/>);
}
}
export default App;