aio-table 6.0.1 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +1 -1
- package/index.js +45 -25
- package/package.json +1 -1
package/index.css
CHANGED
package/index.js
CHANGED
|
@@ -1602,22 +1602,36 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1602
1602
|
minWidth = _column$minWidth === void 0 ? '30px' : _column$minWidth;
|
|
1603
1603
|
var _this$context14 = this.context,
|
|
1604
1604
|
rowHeight = _this$context14.rowHeight,
|
|
1605
|
-
striped = _this$context14.striped
|
|
1605
|
+
striped = _this$context14.striped,
|
|
1606
|
+
_this$context14$getCe = _this$context14.getCellStyle,
|
|
1607
|
+
getCellStyle = _this$context14$getCe === void 0 ? function () {
|
|
1608
|
+
return {};
|
|
1609
|
+
} : _this$context14$getCe;
|
|
1606
1610
|
var style = {
|
|
1607
1611
|
height: rowHeight,
|
|
1608
1612
|
overflow: template ? undefined : 'hidden',
|
|
1609
1613
|
minWidth: minWidth
|
|
1610
1614
|
};
|
|
1611
1615
|
|
|
1612
|
-
if (
|
|
1613
|
-
|
|
1616
|
+
if (row._index % 2 === 0) {
|
|
1617
|
+
if (typeof striped === 'string') {
|
|
1618
|
+
style.background = striped;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
if (Array.isArray(striped)) {
|
|
1622
|
+
style.background = striped[0];
|
|
1623
|
+
style.color = striped[1];
|
|
1624
|
+
}
|
|
1614
1625
|
}
|
|
1615
1626
|
|
|
1616
1627
|
if (column.template === 'gantt') {
|
|
1617
1628
|
style.padding = "0 ".concat(padding);
|
|
1618
1629
|
}
|
|
1619
1630
|
|
|
1620
|
-
|
|
1631
|
+
var cellStyle = getCellStyle(row, column);
|
|
1632
|
+
return { ...style,
|
|
1633
|
+
...cellStyle
|
|
1634
|
+
};
|
|
1621
1635
|
}
|
|
1622
1636
|
}, {
|
|
1623
1637
|
key: "getClassName",
|
|
@@ -1708,7 +1722,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1708
1722
|
content = fn.getOptionsCell(template);
|
|
1709
1723
|
} else if (template === 'gantt') {
|
|
1710
1724
|
content = fn.getGanttCell(row, column);
|
|
1711
|
-
} else if (template &&
|
|
1725
|
+
} else if (template && this.inlineEdit) {
|
|
1712
1726
|
if (!focused) {
|
|
1713
1727
|
content = template;
|
|
1714
1728
|
} else {
|
|
@@ -1716,7 +1730,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1716
1730
|
}
|
|
1717
1731
|
} else if (template) {
|
|
1718
1732
|
content = template;
|
|
1719
|
-
} else if (
|
|
1733
|
+
} else if (this.inlineEdit) {
|
|
1720
1734
|
content = this.getInput(row, column);
|
|
1721
1735
|
} else if (column.getValue) {
|
|
1722
1736
|
content = value;
|
|
@@ -1747,26 +1761,33 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1747
1761
|
value: function getInput(row, column) {
|
|
1748
1762
|
var _this17 = this;
|
|
1749
1763
|
|
|
1750
|
-
var
|
|
1751
|
-
type =
|
|
1752
|
-
getValue =
|
|
1764
|
+
var _this$inlineEdit = this.inlineEdit,
|
|
1765
|
+
type = _this$inlineEdit.type,
|
|
1766
|
+
getValue = _this$inlineEdit.getValue,
|
|
1767
|
+
_this$inlineEdit$disa = _this$inlineEdit.disabled,
|
|
1768
|
+
disabled = _this$inlineEdit$disa === void 0 ? function () {
|
|
1769
|
+
return false;
|
|
1770
|
+
} : _this$inlineEdit$disa;
|
|
1753
1771
|
var renderIndex = this.props.renderIndex;
|
|
1754
1772
|
var value = this.state.value;
|
|
1755
|
-
var _column$inlineEdit$di = column.inlineEdit.disabled,
|
|
1756
|
-
disabled = _column$inlineEdit$di === void 0 ? function () {
|
|
1757
|
-
return false;
|
|
1758
|
-
} : _column$inlineEdit$di;
|
|
1759
1773
|
|
|
1760
1774
|
if (getValue) {
|
|
1761
1775
|
value = getValue(row);
|
|
1762
1776
|
}
|
|
1763
1777
|
|
|
1764
|
-
|
|
1778
|
+
if (disabled(row)) {
|
|
1779
|
+
if (typeof value === 'boolean') {
|
|
1780
|
+
return JSON.stringify(value);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
return value;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
var props = { ...this.inlineEdit,
|
|
1765
1787
|
className: 'aio-table-input',
|
|
1766
1788
|
rowindex: renderIndex,
|
|
1767
1789
|
colindex: column._renderIndex,
|
|
1768
|
-
value: value === null || value === undefined ? '' : value
|
|
1769
|
-
disabled: disabled(row)
|
|
1790
|
+
value: value === null || value === undefined ? '' : value
|
|
1770
1791
|
};
|
|
1771
1792
|
|
|
1772
1793
|
if (type === 'text' || type === 'number') {
|
|
@@ -1790,7 +1811,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1790
1811
|
loading: true
|
|
1791
1812
|
});
|
|
1792
1813
|
|
|
1793
|
-
var res = await
|
|
1814
|
+
var res = await _this17.inlineEdit.onChange(row, type === 'number' ? parseFloat(value) : value);
|
|
1794
1815
|
|
|
1795
1816
|
_this17.setState({
|
|
1796
1817
|
loading: false
|
|
@@ -1812,12 +1833,12 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1812
1833
|
}
|
|
1813
1834
|
|
|
1814
1835
|
if (type === 'select') {
|
|
1815
|
-
if (!
|
|
1836
|
+
if (!this.inlineEdit.options) {
|
|
1816
1837
|
console.error('aio table => missing options property of column inlineEdit with type="select"');
|
|
1817
1838
|
return '';
|
|
1818
1839
|
}
|
|
1819
1840
|
|
|
1820
|
-
if (!Array.isArray(
|
|
1841
|
+
if (!Array.isArray(this.inlineEdit.options)) {
|
|
1821
1842
|
console.error('aio table => options property of column inlineEdit with type="select" must be an array of objects . each object must have text and value property!!!');
|
|
1822
1843
|
return '';
|
|
1823
1844
|
}
|
|
@@ -1847,7 +1868,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1847
1868
|
value: value
|
|
1848
1869
|
});
|
|
1849
1870
|
|
|
1850
|
-
var res = await
|
|
1871
|
+
var res = await _this17.inlineEdit.onChange(row, value);
|
|
1851
1872
|
|
|
1852
1873
|
_this17.setState({
|
|
1853
1874
|
loading: false
|
|
@@ -1863,7 +1884,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1863
1884
|
});
|
|
1864
1885
|
}
|
|
1865
1886
|
}
|
|
1866
|
-
}),
|
|
1887
|
+
}), this.inlineEdit.options.map(function (o, i) {
|
|
1867
1888
|
return /*#__PURE__*/_react.default.createElement("option", {
|
|
1868
1889
|
key: i,
|
|
1869
1890
|
value: o.value
|
|
@@ -1879,9 +1900,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1879
1900
|
}, {
|
|
1880
1901
|
key: "componentDidUpdate",
|
|
1881
1902
|
value: function componentDidUpdate() {
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
if (column.inlineEdit && column.inlineEdit.type === 'select' && this.focus) {
|
|
1903
|
+
if (this.inlineEdit && this.inlineEdit.type === 'select' && this.focus) {
|
|
1885
1904
|
(0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
|
|
1886
1905
|
}
|
|
1887
1906
|
}
|
|
@@ -1904,6 +1923,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1904
1923
|
value = _this$props15.value,
|
|
1905
1924
|
cellId = _this$props15.cellId,
|
|
1906
1925
|
renderIndex = _this$props15.renderIndex;
|
|
1926
|
+
this.inlineEdit = typeof column.inlineEdit === 'function' ? column.inlineEdit(row, column) : column.inlineEdit;
|
|
1907
1927
|
|
|
1908
1928
|
if (this.state.prevValue !== value) {
|
|
1909
1929
|
setTimeout(function () {
|
|
@@ -1979,7 +1999,7 @@ var AIOTableCell = /*#__PURE__*/function (_Component7) {
|
|
|
1979
1999
|
return _onDrop2(row);
|
|
1980
2000
|
},
|
|
1981
2001
|
onClick: function onClick(e) {
|
|
1982
|
-
if (
|
|
2002
|
+
if (_this18.inlineEdit) {
|
|
1983
2003
|
if (focused !== cellId) {
|
|
1984
2004
|
SetState({
|
|
1985
2005
|
focused: cellId
|