Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.

ensure reactable works with react-hot-loader #395

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
435 changes: 249 additions & 186 deletions README.md

Large diffs are not rendered by default.

165 changes: 0 additions & 165 deletions build/.module-cache/fcf0a1449e059bf673190ccebbcf9f88c23c163d.js

This file was deleted.

This file was deleted.

180 changes: 102 additions & 78 deletions build/reactable.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ window.ReactDOM["default"] = window.ReactDOM;
// Manually transfer props
var props = (0, _libFilter_props_from.filterPropsFrom)(this.props);

return _react['default'].DOM.tr(props, children);
return _react['default'].createElement('tr', props, children);
}
}]);

Expand Down Expand Up @@ -1082,78 +1082,132 @@ window.ReactDOM["default"] = window.ReactDOM;
}
}, {
key: 'parseChildData',
value: function parseChildData(props) {
value: function parseChildData(props, moduleHot) {
var data = [],
tfoot = undefined;

// Transform any children back to a data array
if (typeof props.children !== 'undefined') {
_react['default'].Children.forEach(props.children, (function (child) {
if (typeof child === 'undefined' || child === null) {
if (typeof child === 'undefined' || child === null || !child) {
return;
}

switch (child.type) {
case _thead.Thead:
break;
case _tfoot.Tfoot:
if (typeof tfoot !== 'undefined') {
console.warn('You can only have one <Tfoot>, but more than one was specified.' + 'Ignoring all but the last one');
}
tfoot = child;
break;
case _tr.Tr:
var childData = child.props.data || {};

_react['default'].Children.forEach(child.props.children, function (descendant) {
// TODO
/* if (descendant.type.ConvenienceConstructor === Td) { */
if (typeof descendant !== 'object' || descendant == null) {
return;
} else if (typeof descendant.props.column !== 'undefined') {
var value = undefined;

if (typeof descendant.props.data !== 'undefined') {
value = descendant.props.data;
} else if (typeof descendant.props.children !== 'undefined') {
value = descendant.props.children;
} else {
console.warn('exports.Td specified without ' + 'a `data` property or children, ' + 'ignoring');
if (moduleHot) {
var displayName = child.type.displayName ? child.type.displayName : null;

switch (displayName) {
case _thead.Thead.name:
break;
case _tfoot.Tfoot.name:
if (typeof tfoot !== 'undefined') {
console.warn('You can only have one <Tfoot>, but more than one was specified.' + 'Ignoring all but the last one');
}
tfoot = child;
break;
case _tr.Tr.name:
var childData = child.props.data || {};

_react['default'].Children.forEach(child.props.children, function (descendant) {
// TODO
/* if (descendant.type.ConvenienceConstructor === Td) { */
if (typeof descendant !== 'object' || descendant == null) {
return;
} else if (typeof descendant.props.column !== 'undefined') {
var value = undefined;

if (typeof descendant.props.data !== 'undefined') {
value = descendant.props.data;
} else if (typeof descendant.props.children !== 'undefined') {
value = descendant.props.children;
} else {
console.warn('exports.Td specified without ' + 'a `data` property or children, ' + 'ignoring');
return;
}

childData[descendant.props.column] = {
value: value,
props: (0, _libFilter_props_from.filterPropsFrom)(descendant.props),
__reactableMeta: true
};
} else {
console.warn('exports.Td specified without a ' + '`column` property, ignoring');
}
});

childData[descendant.props.column] = {
value: value,
props: (0, _libFilter_props_from.filterPropsFrom)(descendant.props),
__reactableMeta: true
};
} else {
console.warn('exports.Td specified without a ' + '`column` property, ignoring');
data.push({
data: childData,
props: (0, _libFilter_props_from.filterPropsFrom)(child.props),
__reactableMeta: true
});
break;

default:
console.warn('The only possible children of <Table> are <Thead>, <Tr>, ' + 'or one <Tfoot>.');
}
} else {
switch (child.type) {
case _thead.Thead:
break;
case _tfoot.Tfoot:
if (typeof tfoot !== 'undefined') {
console.warn('You can only have one <Tfoot>, but more than one was specified.' + 'Ignoring all but the last one');
}
});
tfoot = child;
break;
case _tr.Tr:
var childData = child.props.data || {};

data.push({
data: childData,
props: (0, _libFilter_props_from.filterPropsFrom)(child.props),
__reactableMeta: true
});
break;
_react['default'].Children.forEach(child.props.children, function (descendant) {
// TODO
/* if (descendant.type.ConvenienceConstructor === Td) { */
if (typeof descendant !== 'object' || descendant == null) {
return;
} else if (typeof descendant.props.column !== 'undefined') {
var value = undefined;

if (typeof descendant.props.data !== 'undefined') {
value = descendant.props.data;
} else if (typeof descendant.props.children !== 'undefined') {
value = descendant.props.children;
} else {
console.warn('exports.Td specified without ' + 'a `data` property or children, ' + 'ignoring');
return;
}

childData[descendant.props.column] = {
value: value,
props: (0, _libFilter_props_from.filterPropsFrom)(descendant.props),
__reactableMeta: true
};
} else {
console.warn('exports.Td specified without a ' + '`column` property, ignoring');
}
});

data.push({
data: childData,
props: (0, _libFilter_props_from.filterPropsFrom)(child.props),
__reactableMeta: true
});
break;

default:
console.warn('The only possible children of <Table> are <Thead>, <Tr>, ' + 'or one <Tfoot>.');
default:
console.warn('The only possible children of <Table> are <Thead>, <Tr>, ' + 'or one <Tfoot>.');
}
}
}).bind(this));
}

return { data: data, tfoot: tfoot };
}
}, {
key: 'initialize',
value: function initialize(props) {
this.data = props.data || [];
var hasModuleHot = typeof module !== 'undefined' && module.hot;
var parseChildData = parseChildData = this.parseChildData(props, hasModuleHot);

var _parseChildData = this.parseChildData(props);

var _parseChildData = parseChildData;
var data = _parseChildData.data;
var tfoot = _parseChildData.tfoot;

Expand Down Expand Up @@ -1591,36 +1645,6 @@ window.ReactDOM["default"] = window.ReactDOM;
}) || [];
};

// Array.prototype.find polyfill - see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
enumerable: false,
configurable: true,
writable: true,
value: function value(predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
if (i in list) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
}
return undefined;
}
});
}

var Reactable = { Table: _reactableTable.Table, Tr: _reactableTr.Tr, Td: _reactableTd.Td, Th: _reactableTh.Th, Tfoot: _reactableTfoot.Tfoot, Thead: _reactableThead.Thead, Sort: _reactableSort.Sort, unsafe: _reactableUnsafe.unsafe };

exports['default'] = Reactable;
Expand Down
Loading