Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/ConfigUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@ export interface IProps {
downloadReady?: any;
downloadComplete?: any;
options?: any;
selectableCheck?: any;
}
export declare const propsToOptions: (props: any) => Promise<any>;
2 changes: 1 addition & 1 deletion lib/ConfigUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ exports.propsToOptions = function (props) { return __awaiter(void 0, void 0, voi
'groupVisibilityChanged', 'groupClick', 'groupDblClick', 'groupContext', 'groupTap', 'groupDblTap', 'groupTapHold',
'movableRowsSendingStart', 'movableRowsSent', 'movableRowsSentFailed', 'movableRowsSendingStop', 'movableRowsReceivingStart', 'movableRowsReceived', 'movableRowsReceivedFailed', 'movableRowsReceivingStop',
'validationFailed', 'clipboardCopied', 'clipboardPasted', 'clipboardPasteError',
'downloadReady', 'downloadComplete', 'selectableCheck'];
'downloadReady', 'downloadComplete'];
for (_a = 0, callbackNames_1 = callbackNames; _a < callbackNames_1.length; _a++) {
callbackName = callbackNames_1[_a];
output[callbackName] = props[callbackName] || NOOPS;
Expand Down
8 changes: 4 additions & 4 deletions lib/React15Tabulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ var default_1 = /** @class */ (function (_super) {
});
};
default_1.prototype.componentWillUnmount = function () {
this.table.destroy();
this.table && this.table.destroy();
};
// this is for React 15.x only
default_1.prototype.componentWillReceiveProps = function (props) {
var _this = this;
if (!Utils_1.isSameArray(this.state.data, props.data)) {
// console.log('- data changed');
this.setState({ data: props.data }, function () {
_this.table.setData(_this.state.data);
_this.table && _this.table.setData(_this.state.data);
});
}
if (!Utils_1.isSameArray(this.state.columns, props.columns)) {
// console.log('- columns changed');
this.setState({ columns: props.columns }, function () {
_this.table.setColumns(_this.state.columns);
_this.table && _this.table.setColumns(_this.state.columns);
});
}
};
Expand All @@ -143,7 +143,7 @@ var default_1 = /** @class */ (function (_super) {
// console.log('*** render');
this.pickValidHTMLProps();
var className = this.props.className;
return React.createElement("div", __assign({ ref: function (ref) { return (_this.ref = ref); }, "data-instance": this.mainId }, this.htmlProps, { className: className }));
return (React.createElement("div", __assign({ ref: function (ref) { return (_this.ref = ref); }, "data-instance": this.mainId }, this.htmlProps, { className: className })));
};
return default_1;
}(React.Component));
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactTabulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var default_1 = /** @class */ (function (_super) {
var _this = this;
this.pickValidHTMLProps();
var className = this.props.className;
return React.createElement("div", __assign({ ref: function (ref) { return (_this.ref = ref); }, "data-instance": this.mainId }, this.htmlProps, { className: className }));
return (React.createElement("div", __assign({ ref: function (ref) { return (_this.ref = ref); }, "data-instance": this.mainId }, this.htmlProps, { className: className })));
};
return default_1;
}(React.Component));
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "React Tabulator is based on tabulator - a JS table library with many advanced features.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "es/index.js",
"files": [
"css",
"es",
Expand Down
10 changes: 6 additions & 4 deletions src/React15Tabulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ export default class extends React.Component<IProps, Partial<IState>> {
}

componentWillUnmount() {
this.table.destroy();
this.table && this.table.destroy();
}

// this is for React 15.x only
componentWillReceiveProps(props: IProps) {
if (!isSameArray(this.state.data, props.data)) {
// console.log('- data changed');
this.setState({ data: props.data }, () => {
this.table.setData(this.state.data);
this.table && this.table.setData(this.state.data);
});
}
if (!isSameArray(this.state.columns, props.columns)) {
// console.log('- columns changed');
this.setState({ columns: props.columns }, () => {
this.table.setColumns(this.state.columns);
this.table && this.table.setColumns(this.state.columns);
});
}
}
Expand All @@ -84,6 +84,8 @@ export default class extends React.Component<IProps, Partial<IState>> {
// console.log('*** render');
this.pickValidHTMLProps();
const { className } = this.props;
return <div ref={ref => (this.ref = ref)} data-instance={this.mainId} {...this.htmlProps} className={className} />;
return (
<div ref={(ref) => (this.ref = ref)} data-instance={this.mainId} {...this.htmlProps} className={className} />
);
}
}
11 changes: 7 additions & 4 deletions src/ReactTabulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class extends React.Component<IProps, Partial<IState>> {
}

componentWillUnmount() {
this.table.destroy();
this.table && this.table.destroy();
}

// React 16.5.x - "getDerivedStateFromProps" replaces both "componentWillMount" & "componentWillReceiveProps"
Expand Down Expand Up @@ -90,11 +90,12 @@ export default class extends React.Component<IProps, Partial<IState>> {
// props data changed! (see: getDerivedStateFromProps)
if (!isSameArray(prevState.data, this.state.data)) {
// only when data is really different: call this.table.setData (will re-render table)
this.table.setData(this.state.data);

this.table && this.table.setData(this.state.data);
}
if (!isSameArray(prevState.columns, this.state.columns)) {
// only when data is really different: call this.table.setData (will re-render table)
this.table.setColumns(this.state.columns);
this.table && this.table.setColumns(this.state.columns);
}
}

Expand All @@ -110,6 +111,8 @@ export default class extends React.Component<IProps, Partial<IState>> {
render() {
this.pickValidHTMLProps();
const { className } = this.props;
return <div ref={ref => (this.ref = ref)} data-instance={this.mainId} {...this.htmlProps} className={className} />;
return (
<div ref={(ref) => (this.ref = ref)} data-instance={this.mainId} {...this.htmlProps} className={className} />
);
}
}