diff --git a/package.json b/package.json index 5306f0d..ac0534d 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ }, "peerDependencies": { "jquery": "^3.x", - "react": "15.x", - "react-dom": "15.x" + "react": "15.x - 16.x", + "react-dom": "15.x - 16.x" }, "devDependencies": { "babel-cli": "^6.6.4", diff --git a/src/editors/text.jsx b/src/editors/text.jsx index b9aecf0..ce0c55f 100644 --- a/src/editors/text.jsx +++ b/src/editors/text.jsx @@ -11,7 +11,7 @@ function validate(value, props) { class TextEditor extends BaseEditor { componentDidMount() { if (this.props.editReplace) { - this.refs.field.setSelectionRange(this.state.value.length, this.state.value.length) + this.field.setSelectionRange(this.state.value.length, this.state.value.length) } } @@ -20,7 +20,7 @@ class TextEditor extends BaseEditor { } handleChange = (event) => { - let newValue = this.refs.field.value + let newValue = this.field.value this.setState(state => { state.value = newValue return state @@ -30,7 +30,7 @@ class TextEditor extends BaseEditor { handleFocus = (event) => { if (this.props.editReplace === null) { window.setTimeout(() => { - let inputElement = this.refs.field + let inputElement = this.field inputElement.select() }, 0) } @@ -43,7 +43,7 @@ class TextEditor extends BaseEditor { onKeyDown={this.handleKeyDown} > { this.field = el }} value={this.state.value} onChange={this.handleChange} onBlur={this.handleBlur} diff --git a/src/object-cell.jsx b/src/object-cell.jsx index 81db40d..bf5ba85 100644 --- a/src/object-cell.jsx +++ b/src/object-cell.jsx @@ -15,6 +15,7 @@ class ObjectCell extends React.Component { PropTypes.string, PropTypes.number, ]), + object: PropTypes.object, onMouseDownCell: PropTypes.func, disabled: PropTypes.bool, beginEdit: PropTypes.func, @@ -96,11 +97,12 @@ class ObjectCell extends React.Component { if (this.props.editing) { let editor = this.props.column.editor || TextEditor let editorProps = Clone(this.props.column.editorProps || {}) - editorProps.ref = 'editor' editorProps.value = this.props.value editorProps.update = this.props.updateField editorProps.abort = this.props.abortField editorProps.objectId = this.props.objectId + editorProps.column = this.props.column + editorProps.object = this.props.object editorProps.columnKey = this.props.column.key editorProps.height = this.props.height editorProps.editReplace = this.props.editReplace @@ -123,8 +125,10 @@ class ObjectCell extends React.Component { } else { let drawer = this.props.column.drawer || TextDrawer let drawerProps = Clone(this.props.column.drawerProps || {}) - drawerProps.ref = 'drawer' + drawerProps.value = this.props.value + drawerProps.column = this.props.column + drawerProps.object = this.props.object drawerProps.beginEdit = this.beginEdit drawerProps.context = this.props.drawerContext diff --git a/src/object-row.jsx b/src/object-row.jsx index 2be2cbc..9a840c0 100644 --- a/src/object-row.jsx +++ b/src/object-row.jsx @@ -126,12 +126,14 @@ class ObjectRow extends React.Component { } let ref = 'column-' + column.key + let cellProps = { key: ref, ref: ref, value: this.props.object[column.key], objectId: this.props.object.id, + object: this.props.object, column: column, height: this.props.height, @@ -146,6 +148,7 @@ class ObjectRow extends React.Component { abortField: this.props.abortField, cellError: this.props.cellError, } + cellProps.editorContext = null if (editing && column.editorContext) { cellProps.editorContext = column.editorContext(this.props.object) @@ -189,7 +192,7 @@ class ObjectRow extends React.Component { cells.push( { this.actions = el }} className="actions open" style={cellStyle} > @@ -203,7 +206,7 @@ class ObjectRow extends React.Component { cells.push( { this.actions = el }} className="actions closed" onClick={this.openActions} style={cellStyle} diff --git a/src/object-table.jsx b/src/object-table.jsx index 13f25b1..2570916 100644 --- a/src/object-table.jsx +++ b/src/object-table.jsx @@ -566,7 +566,7 @@ class ObjectTable extends React.PureComponent { let mouseX = event.clientX + document.body.scrollLeft let mouseY = event.clientY + document.body.scrollTop this.setState(state => { - let tableBounds = this.refs.table.getBoundingClientRect() + let tableBounds = this.table.getBoundingClientRect() state.selectedColumns = this.getDraggedColumns(state.selectionDragStart.x, mouseX, tableBounds) state.selectedRows = this.getDraggedRows(state.selectionDragStart.y, mouseY, tableBounds) state.selectedColumnsRight = true @@ -580,7 +580,7 @@ class ObjectTable extends React.PureComponent { let mouseX = event.clientX + document.body.scrollLeft let mouseY = event.clientY + document.body.scrollTop this.setState(state => { - let tableBounds = this.refs.table.getBoundingClientRect() + let tableBounds = this.table.getBoundingClientRect() state.selectedColumnsRight = (state.selectionDragStart.x < mouseX) state.selectedRowsDown = (state.selectionDragStart.y < mouseY) state.selectedColumns = this.getDraggedColumns(state.selectionDragStart.x, mouseX, tableBounds) @@ -915,7 +915,7 @@ class ObjectTable extends React.PureComponent { if (this.props.actions && this.props.actions.length) { columns.push( { this.actions = el }} key="actions" className="actions" width={25} @@ -999,7 +999,7 @@ class ObjectTable extends React.PureComponent { return (
{ this.table = el }} tabIndex="1" className={classes} >