react-table-edit 0.5.5 → 0.5.7
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/dist/index.d.mts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +758 -189
- package/dist/index.mjs +759 -182
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,13 +51,13 @@ __export(Table_edit_exports, {
|
|
|
51
51
|
module.exports = __toCommonJS(Table_edit_exports);
|
|
52
52
|
|
|
53
53
|
// test-app/src/component/table/index.tsx
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
54
|
+
var import_react14 = require("react");
|
|
55
|
+
var import_reactstrap9 = require("reactstrap");
|
|
56
|
+
var import_classnames12 = __toESM(require("classnames"));
|
|
57
|
+
var import_react_i18next10 = require("react-i18next");
|
|
58
58
|
var import_react_select3 = __toESM(require("react-select"));
|
|
59
59
|
var import_async = __toESM(require("react-select/async"));
|
|
60
|
-
var
|
|
60
|
+
var import_becoxy_icons6 = require("becoxy-icons");
|
|
61
61
|
|
|
62
62
|
// test-app/src/component/react-input/index.tsx
|
|
63
63
|
var import_becoxy_icons = require("becoxy-icons");
|
|
@@ -345,7 +345,7 @@ var IconCustom = (props) => {
|
|
|
345
345
|
var icon_default = IconCustom;
|
|
346
346
|
|
|
347
347
|
// test-app/src/component/table/index.tsx
|
|
348
|
-
var
|
|
348
|
+
var import_moment2 = __toESM(require("moment"));
|
|
349
349
|
|
|
350
350
|
// test-app/src/component/edit-form/index.tsx
|
|
351
351
|
var import_react9 = require("react");
|
|
@@ -1512,7 +1512,8 @@ var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOpt
|
|
|
1512
1512
|
onChangePage({ totalItem, pageSize, currentPage: index, old: currentPage });
|
|
1513
1513
|
},
|
|
1514
1514
|
children: index
|
|
1515
|
-
}
|
|
1515
|
+
},
|
|
1516
|
+
`page-${index}`
|
|
1516
1517
|
)
|
|
1517
1518
|
);
|
|
1518
1519
|
}
|
|
@@ -1568,10 +1569,525 @@ var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOpt
|
|
|
1568
1569
|
] }) });
|
|
1569
1570
|
};
|
|
1570
1571
|
|
|
1571
|
-
// test-app/src/component/table/index.tsx
|
|
1572
|
+
// test-app/src/component/select-table/index.tsx
|
|
1573
|
+
var import_react13 = require("react");
|
|
1574
|
+
var import_reactstrap8 = require("reactstrap");
|
|
1575
|
+
var import_react_i18next9 = require("react-i18next");
|
|
1576
|
+
var import_classnames11 = __toESM(require("classnames"));
|
|
1577
|
+
var import_moment = __toESM(require("moment"));
|
|
1578
|
+
var import_becoxy_icons5 = require("becoxy-icons");
|
|
1572
1579
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1573
|
-
var
|
|
1580
|
+
var defaultMaxHeight = 300;
|
|
1581
|
+
var SelectTable = (0, import_react13.forwardRef)((props, ref) => {
|
|
1582
|
+
const {
|
|
1583
|
+
id,
|
|
1584
|
+
menuWidth,
|
|
1585
|
+
invalid,
|
|
1586
|
+
onKeyDown,
|
|
1587
|
+
placeholder,
|
|
1588
|
+
textAlign,
|
|
1589
|
+
options,
|
|
1590
|
+
columns,
|
|
1591
|
+
decimalSeparator,
|
|
1592
|
+
thousandSeparator,
|
|
1593
|
+
onChange,
|
|
1594
|
+
value,
|
|
1595
|
+
fieldValue,
|
|
1596
|
+
fieldLabel,
|
|
1597
|
+
loadOptions,
|
|
1598
|
+
maxHeight,
|
|
1599
|
+
handleAdd,
|
|
1600
|
+
isClearable,
|
|
1601
|
+
component,
|
|
1602
|
+
isMulti
|
|
1603
|
+
} = props;
|
|
1604
|
+
const selectTableRef = (0, import_react13.useRef)();
|
|
1605
|
+
const selectMenuTableRef = (0, import_react13.useRef)();
|
|
1606
|
+
const inputRef = (0, import_react13.useRef)();
|
|
1607
|
+
const [dropdownOpen, setDropdownOpen] = (0, import_react13.useState)(false);
|
|
1608
|
+
const [indexFocus, setIndexFocus] = (0, import_react13.useState)(-1);
|
|
1609
|
+
const [isFocus, setIsFocus] = (0, import_react13.useState)(false);
|
|
1610
|
+
const [searchTerm, setSearchTerm] = (0, import_react13.useState)("");
|
|
1611
|
+
const [optionsLoad, setOptionsLoad] = (0, import_react13.useState)();
|
|
1574
1612
|
const { t } = (0, import_react_i18next9.useTranslation)();
|
|
1613
|
+
const defaultColumns = [
|
|
1614
|
+
{
|
|
1615
|
+
field: "key",
|
|
1616
|
+
headerText: "Code",
|
|
1617
|
+
width: 100,
|
|
1618
|
+
maxWidth: 120,
|
|
1619
|
+
minWidth: 80
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
headerText: "Name",
|
|
1623
|
+
field: "label",
|
|
1624
|
+
width: 150,
|
|
1625
|
+
maxWidth: 200,
|
|
1626
|
+
minWidth: 250
|
|
1627
|
+
}
|
|
1628
|
+
];
|
|
1629
|
+
const closeMenu = () => {
|
|
1630
|
+
setDropdownOpen(false);
|
|
1631
|
+
};
|
|
1632
|
+
(0, import_react13.useEffect)(() => {
|
|
1633
|
+
if (dropdownOpen) {
|
|
1634
|
+
if (value) {
|
|
1635
|
+
if (selectMenuTableRef) {
|
|
1636
|
+
const elementFocus = document.getElementById(`row-select-table-${(optionsLoad ? optionsLoad : options)?.findIndex((e) => e[fieldValue ?? "value"] === value[fieldValue ?? "value"])}`);
|
|
1637
|
+
if (elementFocus) {
|
|
1638
|
+
const rect = elementFocus.getBoundingClientRect();
|
|
1639
|
+
const parentRect = selectMenuTableRef.current?.getBoundingClientRect();
|
|
1640
|
+
if (rect.top < parentRect.top || rect.bottom > parentRect.bottom) {
|
|
1641
|
+
selectMenuTableRef.current.scrollTo({
|
|
1642
|
+
top: elementFocus.offsetTop,
|
|
1643
|
+
behavior: "smooth"
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
}, [dropdownOpen]);
|
|
1651
|
+
let timeOutBlur;
|
|
1652
|
+
(0, import_react13.useEffect)(() => {
|
|
1653
|
+
if (inputRef) {
|
|
1654
|
+
inputRef.current.addEventListener("blur", function() {
|
|
1655
|
+
timeOutBlur = setTimeout(() => {
|
|
1656
|
+
if (document.activeElement?.className !== "select-input" && !selectTableRef.current?.contains(document.activeElement)) {
|
|
1657
|
+
setDropdownOpen(false);
|
|
1658
|
+
setIsFocus(false);
|
|
1659
|
+
}
|
|
1660
|
+
}, 100);
|
|
1661
|
+
});
|
|
1662
|
+
inputRef.current.addEventListener("focus", function() {
|
|
1663
|
+
if (!isFocus) {
|
|
1664
|
+
setIsFocus(true);
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}, [inputRef]);
|
|
1669
|
+
(0, import_react13.useEffect)(() => {
|
|
1670
|
+
if (searchTerm && !dropdownOpen) {
|
|
1671
|
+
setDropdownOpen(true);
|
|
1672
|
+
setIndexFocus(0);
|
|
1673
|
+
}
|
|
1674
|
+
}, [searchTerm]);
|
|
1675
|
+
const handleOpenClose = () => {
|
|
1676
|
+
setSearchTerm("");
|
|
1677
|
+
if (dropdownOpen) {
|
|
1678
|
+
closeMenu();
|
|
1679
|
+
} else {
|
|
1680
|
+
setDropdownOpen(true);
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
const listKeyUse = ["Escape", "Space", "Enter", "Tab", "NumpadEnter", "ArrowDown", "ArrowUp", "F9"];
|
|
1684
|
+
const handleOnKeyDown = (e) => {
|
|
1685
|
+
let key = "";
|
|
1686
|
+
if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code))) {
|
|
1687
|
+
key = onKeyDown(e);
|
|
1688
|
+
if (key === "ArrowRight" || key === "ArrowLeft") {
|
|
1689
|
+
closeMenu();
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
let flag = false;
|
|
1693
|
+
if (!key) {
|
|
1694
|
+
if (e.code === "F9") {
|
|
1695
|
+
handleAdd();
|
|
1696
|
+
flag = true;
|
|
1697
|
+
} else if (e.code === "Escape" || e.code === "Space") {
|
|
1698
|
+
if (dropdownOpen) {
|
|
1699
|
+
onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
|
|
1700
|
+
}
|
|
1701
|
+
if (!searchTerm) {
|
|
1702
|
+
handleOpenClose();
|
|
1703
|
+
flag = true;
|
|
1704
|
+
}
|
|
1705
|
+
} else if (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter") {
|
|
1706
|
+
if (dropdownOpen) {
|
|
1707
|
+
onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
|
|
1708
|
+
handleOpenClose();
|
|
1709
|
+
flag = true;
|
|
1710
|
+
}
|
|
1711
|
+
} else if (e.code === "ArrowDown") {
|
|
1712
|
+
if (dropdownOpen) {
|
|
1713
|
+
let newIndex = 0;
|
|
1714
|
+
if (indexFocus >= 0) {
|
|
1715
|
+
newIndex = indexFocus + 1;
|
|
1716
|
+
} else if (value) {
|
|
1717
|
+
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((e2) => e2[fieldValue ?? "value"] === value[fieldValue ?? "value"]) + 1;
|
|
1718
|
+
}
|
|
1719
|
+
if (newIndex < (optionsLoad ? optionsLoad : options).length) {
|
|
1720
|
+
setIndexFocus(newIndex);
|
|
1721
|
+
checkIfElementIsOutOfScroll(0);
|
|
1722
|
+
} else {
|
|
1723
|
+
setIndexFocus(0);
|
|
1724
|
+
checkIfElementIsOutOfScroll(1);
|
|
1725
|
+
}
|
|
1726
|
+
flag = true;
|
|
1727
|
+
} else {
|
|
1728
|
+
handleOpenClose();
|
|
1729
|
+
flag = true;
|
|
1730
|
+
}
|
|
1731
|
+
} else if (e.code === "ArrowUp") {
|
|
1732
|
+
if (dropdownOpen) {
|
|
1733
|
+
let newIndex = 0;
|
|
1734
|
+
if (indexFocus >= 0) {
|
|
1735
|
+
newIndex = indexFocus - 1;
|
|
1736
|
+
} else if (value) {
|
|
1737
|
+
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((e2) => e2[fieldValue ?? "value"] === value[fieldValue ?? "value"]) - 1;
|
|
1738
|
+
}
|
|
1739
|
+
if (newIndex >= 0) {
|
|
1740
|
+
setIndexFocus(newIndex);
|
|
1741
|
+
checkIfElementIsOutOfScroll(2);
|
|
1742
|
+
} else {
|
|
1743
|
+
setIndexFocus((optionsLoad ? optionsLoad : options).length - 1);
|
|
1744
|
+
checkIfElementIsOutOfScroll(3);
|
|
1745
|
+
}
|
|
1746
|
+
flag = true;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
if (flag) {
|
|
1751
|
+
e.stopPropagation();
|
|
1752
|
+
e.preventDefault();
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
const checkIfElementIsOutOfScroll = (flag) => {
|
|
1756
|
+
if (selectMenuTableRef) {
|
|
1757
|
+
const elementFocus = document.getElementById(`row-select-table-${indexFocus}`);
|
|
1758
|
+
if (elementFocus) {
|
|
1759
|
+
const rect = elementFocus.getBoundingClientRect();
|
|
1760
|
+
const parentRect = selectMenuTableRef.current?.getBoundingClientRect();
|
|
1761
|
+
if (flag === 1) {
|
|
1762
|
+
scrollToElement(selectMenuTableRef.current, 0);
|
|
1763
|
+
} else if (flag === 3) {
|
|
1764
|
+
scrollToElement(selectMenuTableRef.current, selectMenuTableRef.current.scrollHeight);
|
|
1765
|
+
} else if (flag === 0 && rect.bottom + 30 > parentRect.bottom) {
|
|
1766
|
+
scrollToElement(selectMenuTableRef.current, elementFocus.offsetTop - selectMenuTableRef.current.offsetTop - parentRect.height + rect.height + 50);
|
|
1767
|
+
} else if (flag === 2 && rect.top < parentRect.top + 50) {
|
|
1768
|
+
scrollToElement(selectMenuTableRef.current, elementFocus.offsetTop - 65);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
let timeOutElement;
|
|
1774
|
+
const scrollToElement = (elemment, top) => {
|
|
1775
|
+
clearTimeout(timeOutElement);
|
|
1776
|
+
timeOutElement = setTimeout(() => {
|
|
1777
|
+
elemment.scrollTo({
|
|
1778
|
+
top
|
|
1779
|
+
});
|
|
1780
|
+
}, 100);
|
|
1781
|
+
};
|
|
1782
|
+
const renderHeaderCol = (col, indexCol) => {
|
|
1783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1784
|
+
import_react13.Fragment,
|
|
1785
|
+
{
|
|
1786
|
+
children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1787
|
+
"th",
|
|
1788
|
+
{
|
|
1789
|
+
className: (0, import_classnames11.default)(
|
|
1790
|
+
`r-select-headercell fix-${col.fixedType}`,
|
|
1791
|
+
{ "cell-fixed": col.fixedType }
|
|
1792
|
+
),
|
|
1793
|
+
style: {
|
|
1794
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
1795
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
1796
|
+
top: `${0 * 35}px`,
|
|
1797
|
+
maxWidth: col.maxWidth
|
|
1798
|
+
},
|
|
1799
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1800
|
+
"div",
|
|
1801
|
+
{
|
|
1802
|
+
role: "textbox",
|
|
1803
|
+
title: t(col.headerText ?? ""),
|
|
1804
|
+
style: {
|
|
1805
|
+
height: `${1 * 35}px`,
|
|
1806
|
+
justifyContent: col.textAlign ?? "left"
|
|
1807
|
+
},
|
|
1808
|
+
className: "r-select-headercell-div",
|
|
1809
|
+
children: t(col.headerText ?? "")
|
|
1810
|
+
}
|
|
1811
|
+
)
|
|
1812
|
+
}
|
|
1813
|
+
)
|
|
1814
|
+
},
|
|
1815
|
+
`header-select-${indexCol}`
|
|
1816
|
+
);
|
|
1817
|
+
};
|
|
1818
|
+
const checkSearch = (keyword, data, columnsSearch) => {
|
|
1819
|
+
if (!keyword || columnsSearch.length === 0) {
|
|
1820
|
+
return true;
|
|
1821
|
+
}
|
|
1822
|
+
for (let index = 0; index < columnsSearch.length; index++) {
|
|
1823
|
+
const key = columnsSearch[index].field.trim();
|
|
1824
|
+
if (data[key] && data[key].toString().trim().toLowerCase().includes(keyword.trim().toLowerCase())) {
|
|
1825
|
+
return true;
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return false;
|
|
1829
|
+
};
|
|
1830
|
+
const callbackLoadOption = (rs) => {
|
|
1831
|
+
setOptionsLoad(rs);
|
|
1832
|
+
};
|
|
1833
|
+
(0, import_react13.useEffect)(() => {
|
|
1834
|
+
if (!searchTerm) {
|
|
1835
|
+
setOptionsLoad(void 0);
|
|
1836
|
+
}
|
|
1837
|
+
}, [searchTerm]);
|
|
1838
|
+
const checkOverflow = (element) => {
|
|
1839
|
+
return element && element.scrollWidth > element.clientWidth;
|
|
1840
|
+
};
|
|
1841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1842
|
+
"div",
|
|
1843
|
+
{
|
|
1844
|
+
className: "react-select-table",
|
|
1845
|
+
ref,
|
|
1846
|
+
id,
|
|
1847
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: selectTableRef, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1848
|
+
import_reactstrap8.Dropdown,
|
|
1849
|
+
{
|
|
1850
|
+
isOpen: dropdownOpen,
|
|
1851
|
+
toggle: () => {
|
|
1852
|
+
},
|
|
1853
|
+
children: [
|
|
1854
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1855
|
+
import_reactstrap8.DropdownToggle,
|
|
1856
|
+
{
|
|
1857
|
+
onClick: () => {
|
|
1858
|
+
inputRef?.current.focus();
|
|
1859
|
+
clearTimeout(timeOutBlur);
|
|
1860
|
+
handleOpenClose();
|
|
1861
|
+
},
|
|
1862
|
+
tabIndex: 0,
|
|
1863
|
+
tag: "div",
|
|
1864
|
+
className: (0, import_classnames11.default)("select-table-control", { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
|
|
1865
|
+
children: [
|
|
1866
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "select-table-container", children: [
|
|
1867
|
+
isMulti ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: (0, import_classnames11.default)("select-value is-mutil", { "d-none": searchTerm }), children: value?.map((ele, index) => {
|
|
1868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
|
|
1869
|
+
index === 0 ? "" : ", ",
|
|
1870
|
+
ele[fieldLabel ?? "label"]
|
|
1871
|
+
] }, index);
|
|
1872
|
+
}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_classnames11.default)("select-value", { "d-none": searchTerm }), children: [
|
|
1873
|
+
value ? value[fieldLabel ?? "label"] : "",
|
|
1874
|
+
" "
|
|
1875
|
+
] }) }),
|
|
1876
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: (0, import_classnames11.default)("select-placeholder", { "d-none": (isMulti ? value?.length > 0 : value) || searchTerm }), children: placeholder }),
|
|
1877
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "input-container", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1878
|
+
"input",
|
|
1879
|
+
{
|
|
1880
|
+
style: { textAlign: textAlign ?? "left" },
|
|
1881
|
+
ref: inputRef,
|
|
1882
|
+
className: (0, import_classnames11.default)("select-input"),
|
|
1883
|
+
value: searchTerm,
|
|
1884
|
+
onChange: (val) => {
|
|
1885
|
+
if (loadOptions && val.target.value) {
|
|
1886
|
+
loadOptions(val.target.value, callbackLoadOption);
|
|
1887
|
+
}
|
|
1888
|
+
setSearchTerm(val.target.value);
|
|
1889
|
+
},
|
|
1890
|
+
onKeyDown: (e) => handleOnKeyDown(e)
|
|
1891
|
+
}
|
|
1892
|
+
) })
|
|
1893
|
+
] }),
|
|
1894
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1895
|
+
"div",
|
|
1896
|
+
{
|
|
1897
|
+
className: (0, import_classnames11.default)("select-table-indicator cursor-pointer", { "d-none": !isClearable || !value }),
|
|
1898
|
+
onClick: (e) => {
|
|
1899
|
+
onChange(isMulti ? [] : void 0);
|
|
1900
|
+
e.stopPropagation();
|
|
1901
|
+
},
|
|
1902
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { height: "20", width: "20", style: { color: "#c4c4c4" }, viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
|
|
1903
|
+
}
|
|
1904
|
+
),
|
|
1905
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "select-table-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { height: "20", width: "20", style: { color: dropdownOpen ? "#000000af" : "#c4c4c4" }, viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
|
|
1906
|
+
]
|
|
1907
|
+
}
|
|
1908
|
+
),
|
|
1909
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1910
|
+
import_reactstrap8.DropdownMenu,
|
|
1911
|
+
{
|
|
1912
|
+
container: component,
|
|
1913
|
+
className: "formula-dropdown icon-dropdown p-0",
|
|
1914
|
+
style: {
|
|
1915
|
+
width: menuWidth ? menuWidth : "min-content",
|
|
1916
|
+
position: "fixed",
|
|
1917
|
+
zIndex: 9999
|
|
1918
|
+
},
|
|
1919
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap8.DropdownItem, { className: (0, import_classnames11.default)("p-0 menu-select-table"), style: { borderRadius: "6px" }, tag: "div", header: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1920
|
+
"div",
|
|
1921
|
+
{
|
|
1922
|
+
onMouseDown: (e) => {
|
|
1923
|
+
inputRef?.current.focus();
|
|
1924
|
+
clearTimeout(timeOutBlur);
|
|
1925
|
+
e.preventDefault();
|
|
1926
|
+
},
|
|
1927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "r-select-grid", children: [
|
|
1928
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "r-select-gridtable", ref: selectMenuTableRef, style: { maxHeight: maxHeight ?? defaultMaxHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { style: { width: "100%" }, children: [
|
|
1929
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tr", { className: "r-select-row", role: "row", children: [
|
|
1930
|
+
isMulti && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("th", { className: (0, import_classnames11.default)(`r-select-headercell`), style: { width: 40, top: `0px` }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1931
|
+
"div",
|
|
1932
|
+
{
|
|
1933
|
+
style: { justifyContent: "center" },
|
|
1934
|
+
className: (0, import_classnames11.default)("r-select-headercell-div"),
|
|
1935
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1936
|
+
import_reactstrap8.Input,
|
|
1937
|
+
{
|
|
1938
|
+
checked: (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length,
|
|
1939
|
+
type: "checkbox",
|
|
1940
|
+
className: (0, import_classnames11.default)("cursor-pointer", { "d-none": !isMulti }),
|
|
1941
|
+
style: { textAlign: "center", marginTop: 6 },
|
|
1942
|
+
onChange: (e) => {
|
|
1943
|
+
if (isMulti) {
|
|
1944
|
+
if (e.target.checked) {
|
|
1945
|
+
onChange((optionsLoad ? optionsLoad : options).map((item) => {
|
|
1946
|
+
return item;
|
|
1947
|
+
}));
|
|
1948
|
+
} else {
|
|
1949
|
+
onChange([]);
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
)
|
|
1955
|
+
}
|
|
1956
|
+
) }),
|
|
1957
|
+
(columns ? columns : defaultColumns).map((col, index) => {
|
|
1958
|
+
return renderHeaderCol(col, index);
|
|
1959
|
+
})
|
|
1960
|
+
] }) }),
|
|
1961
|
+
(optionsLoad ? optionsLoad : options).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
|
|
1962
|
+
if (loadOptions || checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
|
|
1963
|
+
const refRow = (0, import_react13.useRef)(null);
|
|
1964
|
+
const isSelected = isMulti && value?.some((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
|
|
1965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1966
|
+
"tr",
|
|
1967
|
+
{
|
|
1968
|
+
id: `row-select-table-${indexRow}`,
|
|
1969
|
+
className: (0, import_classnames11.default)("r-select-row", { "last-row": indexRow === (optionsLoad ? optionsLoad : options).length - 1 }, { "fisrt-row": indexRow === 0 }),
|
|
1970
|
+
children: [
|
|
1971
|
+
isMulti && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1972
|
+
"td",
|
|
1973
|
+
{
|
|
1974
|
+
className: (0, import_classnames11.default)(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
|
|
1975
|
+
style: { width: 40, textAlign: "center", padding: 0, paddingBottom: 6 },
|
|
1976
|
+
onClick: (e) => {
|
|
1977
|
+
if (isMulti) {
|
|
1978
|
+
const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
|
|
1979
|
+
if (index > -1) {
|
|
1980
|
+
value?.splice(index, 1);
|
|
1981
|
+
onChange(value);
|
|
1982
|
+
} else {
|
|
1983
|
+
if (value) {
|
|
1984
|
+
value?.push(row);
|
|
1985
|
+
onChange(value);
|
|
1986
|
+
} else {
|
|
1987
|
+
onChange([row]);
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
e.stopPropagation();
|
|
1991
|
+
}
|
|
1992
|
+
},
|
|
1993
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1994
|
+
import_reactstrap8.Input,
|
|
1995
|
+
{
|
|
1996
|
+
checked: isSelected,
|
|
1997
|
+
type: "checkbox",
|
|
1998
|
+
className: "cursor-pointer",
|
|
1999
|
+
onChange: () => {
|
|
2000
|
+
},
|
|
2001
|
+
style: { textAlign: "center", marginTop: 6 }
|
|
2002
|
+
}
|
|
2003
|
+
)
|
|
2004
|
+
}
|
|
2005
|
+
),
|
|
2006
|
+
(columns ? columns : defaultColumns).map((col, indexCol) => {
|
|
2007
|
+
let valueDisplay = row[col.field];
|
|
2008
|
+
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
2009
|
+
valueDisplay = formartNumberic(row[col.field], decimalSeparator ?? ".", thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
|
|
2010
|
+
} else if (col.type === "date") {
|
|
2011
|
+
valueDisplay = valueDisplay ? (0, import_moment.default)(valueDisplay).format("DD/MM/yyyy") : "";
|
|
2012
|
+
} else if (col.type === "datetime") {
|
|
2013
|
+
valueDisplay = valueDisplay ? (0, import_moment.default)(valueDisplay).format("DD/MM/yyyy HH:mm") : "";
|
|
2014
|
+
}
|
|
2015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react13.Fragment, { children: [
|
|
2016
|
+
col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2017
|
+
"td",
|
|
2018
|
+
{
|
|
2019
|
+
id: `content-select-${indexRow}-${indexCol}`,
|
|
2020
|
+
ref: refRow,
|
|
2021
|
+
className: (0, import_classnames11.default)(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
|
|
2022
|
+
style: {
|
|
2023
|
+
minWidth: col.minWidth,
|
|
2024
|
+
width: col.width,
|
|
2025
|
+
maxWidth: col.maxWidth,
|
|
2026
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
2027
|
+
},
|
|
2028
|
+
onClick: (e) => {
|
|
2029
|
+
if (isMulti) {
|
|
2030
|
+
const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
|
|
2031
|
+
if (index > -1) {
|
|
2032
|
+
value?.splice(index, 1);
|
|
2033
|
+
onChange(value);
|
|
2034
|
+
} else {
|
|
2035
|
+
if (value) {
|
|
2036
|
+
value?.push(row);
|
|
2037
|
+
onChange(value);
|
|
2038
|
+
} else {
|
|
2039
|
+
onChange([row]);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
} else {
|
|
2043
|
+
onChange(row);
|
|
2044
|
+
closeMenu();
|
|
2045
|
+
}
|
|
2046
|
+
e.preventDefault();
|
|
2047
|
+
e.stopPropagation();
|
|
2048
|
+
},
|
|
2049
|
+
onMouseMove: (e) => {
|
|
2050
|
+
if (indexRow !== indexFocus) {
|
|
2051
|
+
setIndexFocus(indexRow);
|
|
2052
|
+
}
|
|
2053
|
+
e.stopPropagation();
|
|
2054
|
+
},
|
|
2055
|
+
children: col.template ? col.template(row, indexRow) : valueDisplay
|
|
2056
|
+
},
|
|
2057
|
+
`col-${indexRow}-${indexCol}`
|
|
2058
|
+
),
|
|
2059
|
+
checkOverflow(refRow.current) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap8.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-select-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : valueDisplay })
|
|
2060
|
+
] }, indexCol);
|
|
2061
|
+
})
|
|
2062
|
+
]
|
|
2063
|
+
},
|
|
2064
|
+
`row-${indexRow}`
|
|
2065
|
+
);
|
|
2066
|
+
}
|
|
2067
|
+
}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "r-no-data", children: t("No data available.") })
|
|
2068
|
+
] }) }),
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "r-select-footer", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_reactstrap8.Button, { outline: true, color: "primary", className: "r-btn-add d-flex align-items-center", onClick: handleAdd, children: [
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_becoxy_icons5.Plus, { className: "me-50", fontSize: 16 }),
|
|
2071
|
+
t("AddNew"),
|
|
2072
|
+
" (F9)"
|
|
2073
|
+
] }) })
|
|
2074
|
+
] })
|
|
2075
|
+
}
|
|
2076
|
+
) })
|
|
2077
|
+
}
|
|
2078
|
+
)
|
|
2079
|
+
]
|
|
2080
|
+
}
|
|
2081
|
+
) })
|
|
2082
|
+
}
|
|
2083
|
+
);
|
|
2084
|
+
});
|
|
2085
|
+
var select_table_default = SelectTable;
|
|
2086
|
+
|
|
2087
|
+
// test-app/src/component/table/index.tsx
|
|
2088
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2089
|
+
var TableEdit = (0, import_react14.forwardRef)((props, ref) => {
|
|
2090
|
+
const { t } = (0, import_react_i18next10.useTranslation)();
|
|
1575
2091
|
const {
|
|
1576
2092
|
idTable,
|
|
1577
2093
|
dataSource,
|
|
@@ -1599,36 +2115,36 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1599
2115
|
handleSelect,
|
|
1600
2116
|
isMulti
|
|
1601
2117
|
} = props;
|
|
1602
|
-
(0,
|
|
2118
|
+
(0, import_react14.useImperativeHandle)(ref, () => {
|
|
1603
2119
|
return {
|
|
1604
2120
|
refeshFocusRow: handleRefeshRow
|
|
1605
2121
|
};
|
|
1606
2122
|
});
|
|
1607
|
-
const [refreshRow, setRefreshRow] = (0,
|
|
1608
|
-
const [indexFocus, setIndexFocus] = (0,
|
|
1609
|
-
const [selectedRows, setSelectedRows] = (0,
|
|
1610
|
-
const [headerColumns, setHeaderColumns] = (0,
|
|
1611
|
-
const [contentColumns, setContentColumns] = (0,
|
|
1612
|
-
const [levelCol, setLevelCol] = (0,
|
|
1613
|
-
const [columnFistEdit, setColumnFistEdit] = (0,
|
|
1614
|
-
const [columnLastEdit, setColumnlastEdit] = (0,
|
|
1615
|
-
const [objWidthFix, setObjWidthFix] = (0,
|
|
1616
|
-
const [openPopupTree, setOpenPopupTree] = (0,
|
|
1617
|
-
const [openPopupSetupColumn, setOpenPopupSetupColumn] = (0,
|
|
1618
|
-
const [searchTerm, setSearchTerm] = (0,
|
|
1619
|
-
const tableElement = (0,
|
|
1620
|
-
const gridRef = (0,
|
|
2123
|
+
const [refreshRow, setRefreshRow] = (0, import_react14.useState)(false);
|
|
2124
|
+
const [indexFocus, setIndexFocus] = (0, import_react14.useState)();
|
|
2125
|
+
const [selectedRows, setSelectedRows] = (0, import_react14.useState)([]);
|
|
2126
|
+
const [headerColumns, setHeaderColumns] = (0, import_react14.useState)([[]]);
|
|
2127
|
+
const [contentColumns, setContentColumns] = (0, import_react14.useState)([]);
|
|
2128
|
+
const [levelCol, setLevelCol] = (0, import_react14.useState)(0);
|
|
2129
|
+
const [columnFistEdit, setColumnFistEdit] = (0, import_react14.useState)(0);
|
|
2130
|
+
const [columnLastEdit, setColumnlastEdit] = (0, import_react14.useState)(0);
|
|
2131
|
+
const [objWidthFix, setObjWidthFix] = (0, import_react14.useState)({});
|
|
2132
|
+
const [openPopupTree, setOpenPopupTree] = (0, import_react14.useState)(false);
|
|
2133
|
+
const [openPopupSetupColumn, setOpenPopupSetupColumn] = (0, import_react14.useState)(false);
|
|
2134
|
+
const [searchTerm, setSearchTerm] = (0, import_react14.useState)("");
|
|
2135
|
+
const tableElement = (0, import_react14.useRef)(null);
|
|
2136
|
+
const gridRef = (0, import_react14.useRef)();
|
|
1621
2137
|
let totalCount = dataSource.length;
|
|
1622
2138
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
1623
2139
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
1624
2140
|
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
1625
2141
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
1626
|
-
(0,
|
|
2142
|
+
(0, import_react14.useEffect)(() => {
|
|
1627
2143
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
1628
2144
|
pagingSetting.setCurrentPage(1);
|
|
1629
2145
|
}
|
|
1630
2146
|
}, [dataSource]);
|
|
1631
|
-
(0,
|
|
2147
|
+
(0, import_react14.useEffect)(() => {
|
|
1632
2148
|
let indexFirst = -1;
|
|
1633
2149
|
let indexlast = -1;
|
|
1634
2150
|
let letfWidthFix = 0;
|
|
@@ -1661,7 +2177,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1661
2177
|
setColumnFistEdit(indexFirst + 1);
|
|
1662
2178
|
setColumnlastEdit(indexlast + 1);
|
|
1663
2179
|
}, [contentColumns]);
|
|
1664
|
-
(0,
|
|
2180
|
+
(0, import_react14.useEffect)(() => {
|
|
1665
2181
|
const arrHeaderColumns = [];
|
|
1666
2182
|
const arrContentColumns = [];
|
|
1667
2183
|
let headerLevelRow = 0;
|
|
@@ -1678,7 +2194,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1678
2194
|
setHeaderColumns(arrHeaderColumns);
|
|
1679
2195
|
setContentColumns(arrContentColumns);
|
|
1680
2196
|
}, [columns]);
|
|
1681
|
-
(0,
|
|
2197
|
+
(0, import_react14.useEffect)(() => {
|
|
1682
2198
|
const arrHeaderColumns = [];
|
|
1683
2199
|
const arrContentColumns = [];
|
|
1684
2200
|
let headerLevelRow = 0;
|
|
@@ -1789,7 +2305,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1789
2305
|
}
|
|
1790
2306
|
};
|
|
1791
2307
|
const searchTemplate = () => {
|
|
1792
|
-
return /* @__PURE__ */ (0,
|
|
2308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "me-50 r-search", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1793
2309
|
react_input_default,
|
|
1794
2310
|
{
|
|
1795
2311
|
style: { width: "230px" },
|
|
@@ -1810,12 +2326,12 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1810
2326
|
const renderEdit = (row, col, indexRow, indexCol) => {
|
|
1811
2327
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
1812
2328
|
case "date":
|
|
1813
|
-
return /* @__PURE__ */ (0,
|
|
1814
|
-
|
|
2329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2330
|
+
import_reactstrap9.Input,
|
|
1815
2331
|
{
|
|
1816
2332
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1817
2333
|
style: { textAlign: col.textAlign, height: 29 },
|
|
1818
|
-
value: row[col.field] ? (0,
|
|
2334
|
+
value: row[col.field] ? (0, import_moment2.default)(row[col.field]).format("yyyy-MM-DD") : row[col.field],
|
|
1819
2335
|
onChange: (val) => {
|
|
1820
2336
|
row[col.field] = val.target.value;
|
|
1821
2337
|
if (col.callback) {
|
|
@@ -1823,7 +2339,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1823
2339
|
}
|
|
1824
2340
|
handleDataChange(row, col, indexRow);
|
|
1825
2341
|
},
|
|
1826
|
-
className: (0,
|
|
2342
|
+
className: (0, import_classnames12.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1827
2343
|
type: "date",
|
|
1828
2344
|
max: "9999-12-31",
|
|
1829
2345
|
onKeyDown: (e) => {
|
|
@@ -1833,12 +2349,12 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1833
2349
|
}
|
|
1834
2350
|
);
|
|
1835
2351
|
case "datetime":
|
|
1836
|
-
return /* @__PURE__ */ (0,
|
|
1837
|
-
|
|
2352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2353
|
+
import_reactstrap9.Input,
|
|
1838
2354
|
{
|
|
1839
2355
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1840
2356
|
style: { textAlign: col.textAlign, height: 29 },
|
|
1841
|
-
value: row[col.field] ? (0,
|
|
2357
|
+
value: row[col.field] ? (0, import_moment2.default)(row[col.field]).format("yyyy-MM-DD HH:MM") : row[col.field],
|
|
1842
2358
|
onChange: (val) => {
|
|
1843
2359
|
row[col.field] = val.target.value;
|
|
1844
2360
|
if (col.callback) {
|
|
@@ -1846,7 +2362,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1846
2362
|
}
|
|
1847
2363
|
handleDataChange(row, col, indexRow);
|
|
1848
2364
|
},
|
|
1849
|
-
className: (0,
|
|
2365
|
+
className: (0, import_classnames12.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1850
2366
|
type: "datetime-local",
|
|
1851
2367
|
max: "9999-12-31T23:59",
|
|
1852
2368
|
onKeyDown: (e) => {
|
|
@@ -1866,8 +2382,8 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1866
2382
|
if (!valueAsyncSelect && col.selectSettings?.defaultValue) {
|
|
1867
2383
|
valueAsyncSelect = col.selectSettings?.defaultValue(row);
|
|
1868
2384
|
}
|
|
1869
|
-
return /* @__PURE__ */ (0,
|
|
1870
|
-
/* @__PURE__ */ (0,
|
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: (0, import_classnames12.default)("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
|
|
2386
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1871
2387
|
import_async.default,
|
|
1872
2388
|
{
|
|
1873
2389
|
menuPosition: "fixed",
|
|
@@ -1886,23 +2402,23 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1886
2402
|
placeholder: t("Select"),
|
|
1887
2403
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1888
2404
|
loadOptions: col.selectSettings?.loadOptions,
|
|
1889
|
-
className: (0,
|
|
2405
|
+
className: (0, import_classnames12.default)("react-select"),
|
|
1890
2406
|
onKeyDown: (e) => {
|
|
1891
2407
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
1892
2408
|
}
|
|
1893
2409
|
}
|
|
1894
2410
|
}
|
|
1895
2411
|
),
|
|
1896
|
-
/* @__PURE__ */ (0,
|
|
2412
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1897
2413
|
"span",
|
|
1898
2414
|
{
|
|
1899
2415
|
onClick: () => {
|
|
1900
|
-
if (col.selectSettings?.
|
|
1901
|
-
col.selectSettings?.
|
|
2416
|
+
if (col.selectSettings?.handAddNew) {
|
|
2417
|
+
col.selectSettings?.handAddNew("right");
|
|
1902
2418
|
}
|
|
1903
2419
|
},
|
|
1904
|
-
className: (0,
|
|
1905
|
-
children: /* @__PURE__ */ (0,
|
|
2420
|
+
className: (0, import_classnames12.default)("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
|
|
2421
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(icon_default, { iconName: col.selectSettings?.iconGroup ?? "", size: 16 })
|
|
1906
2422
|
}
|
|
1907
2423
|
)
|
|
1908
2424
|
] });
|
|
@@ -1919,7 +2435,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1919
2435
|
} else {
|
|
1920
2436
|
valueSelect = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? options?.find((val) => val[col.selectSettings?.fieldValue ?? "value"] === row[col.field]) : "";
|
|
1921
2437
|
}
|
|
1922
|
-
return /* @__PURE__ */ (0,
|
|
2438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1923
2439
|
import_react_select3.default,
|
|
1924
2440
|
{
|
|
1925
2441
|
menuPosition: "fixed",
|
|
@@ -1938,7 +2454,56 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1938
2454
|
isClearable: col.selectSettings?.isClearable ?? false,
|
|
1939
2455
|
classNamePrefix: col.selectSettings?.widthPopup ? `select-${col.selectSettings?.widthPopup}` : "select",
|
|
1940
2456
|
placeholder: t("Select"),
|
|
1941
|
-
className: (0,
|
|
2457
|
+
className: (0, import_classnames12.default)("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2458
|
+
onKeyDown: (e) => {
|
|
2459
|
+
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
);
|
|
2464
|
+
case "selectTable":
|
|
2465
|
+
let valueSelectTable;
|
|
2466
|
+
let optionsSelectTable = [];
|
|
2467
|
+
if (col.selectSettings?.optionsField) {
|
|
2468
|
+
optionsSelectTable = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
2469
|
+
} else {
|
|
2470
|
+
optionsSelectTable = col.selectSettings?.options ? col.selectSettings?.validateOption ? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row)) : col.selectSettings?.options : [];
|
|
2471
|
+
}
|
|
2472
|
+
if (col.selectSettings?.isMulti) {
|
|
2473
|
+
valueSelectTable = !isNullOrUndefined(row[col.field]) && row[col.field]?.length > 0 ? optionsSelectTable?.filter((val) => row[col.field]?.includes(val[col.selectSettings?.fieldValue ?? "value"])) : [];
|
|
2474
|
+
} else {
|
|
2475
|
+
valueSelectTable = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? optionsSelectTable?.find((val) => val[col.selectSettings?.fieldValue ?? "value"] === row[col.field]) : "";
|
|
2476
|
+
}
|
|
2477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2478
|
+
select_table_default,
|
|
2479
|
+
{
|
|
2480
|
+
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2481
|
+
value: valueSelectTable,
|
|
2482
|
+
options: optionsSelectTable,
|
|
2483
|
+
rowData: row,
|
|
2484
|
+
onChange: (val) => {
|
|
2485
|
+
row[col.field] = col.selectSettings?.isMulti ? val?.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) ?? [] : val ? val[col.selectSettings?.fieldValue ?? "value"] : void 0;
|
|
2486
|
+
if (col.callback) {
|
|
2487
|
+
col.callback(val, indexRow);
|
|
2488
|
+
}
|
|
2489
|
+
handleDataChange(row, col, indexRow);
|
|
2490
|
+
},
|
|
2491
|
+
fieldValue: col.selectSettings?.fieldValue,
|
|
2492
|
+
fieldLabel: col.selectSettings?.fieldLabel,
|
|
2493
|
+
component: tableElement,
|
|
2494
|
+
columns: col.selectSettings?.columns,
|
|
2495
|
+
isClearable: col.selectSettings?.isClearable ?? false,
|
|
2496
|
+
decimalSeparator,
|
|
2497
|
+
thousandSeparator,
|
|
2498
|
+
placeholder: t("Select"),
|
|
2499
|
+
loadOptions: col.selectSettings?.loadOptions,
|
|
2500
|
+
field: col.field,
|
|
2501
|
+
handleAdd: col.selectSettings?.handAddNew,
|
|
2502
|
+
isMulti: col.selectSettings?.isMulti,
|
|
2503
|
+
invalid: col.validate && col.validate(row[col.field], row),
|
|
2504
|
+
maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : void 0,
|
|
2505
|
+
menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : void 0,
|
|
2506
|
+
textAlign: col.textAlign ?? "left",
|
|
1942
2507
|
onKeyDown: (e) => {
|
|
1943
2508
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
1944
2509
|
}
|
|
@@ -1960,14 +2525,14 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1960
2525
|
}
|
|
1961
2526
|
}
|
|
1962
2527
|
};
|
|
1963
|
-
return /* @__PURE__ */ (0,
|
|
2528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1964
2529
|
"div",
|
|
1965
2530
|
{
|
|
1966
2531
|
onKeyDown: (e) => {
|
|
1967
2532
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
1968
2533
|
}
|
|
1969
2534
|
},
|
|
1970
|
-
children: /* @__PURE__ */ (0,
|
|
2535
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1971
2536
|
import_ej2_react_dropdowns.DropDownTreeComponent,
|
|
1972
2537
|
{
|
|
1973
2538
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -1978,7 +2543,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
1978
2543
|
parentValue: "parentId",
|
|
1979
2544
|
child: "children"
|
|
1980
2545
|
},
|
|
1981
|
-
className: (0,
|
|
2546
|
+
className: (0, import_classnames12.default)("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1982
2547
|
allowFiltering: false,
|
|
1983
2548
|
value: valueSelectTree,
|
|
1984
2549
|
popupHeight: 250,
|
|
@@ -2006,8 +2571,8 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2006
2571
|
}
|
|
2007
2572
|
);
|
|
2008
2573
|
case "checkbox":
|
|
2009
|
-
return /* @__PURE__ */ (0,
|
|
2010
|
-
|
|
2574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2575
|
+
import_reactstrap9.Input,
|
|
2011
2576
|
{
|
|
2012
2577
|
checked: row[col.field],
|
|
2013
2578
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -2029,13 +2594,13 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2029
2594
|
);
|
|
2030
2595
|
case "numeric":
|
|
2031
2596
|
let valueCurrency = row[col.field];
|
|
2032
|
-
return /* @__PURE__ */ (0,
|
|
2033
|
-
|
|
2597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2598
|
+
import_reactstrap9.Input,
|
|
2034
2599
|
{
|
|
2035
2600
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2036
2601
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2037
2602
|
defaultValue: formartNumberic(valueCurrency, decimalSeparator, thousandSeparator, col.numericSettings?.fraction),
|
|
2038
|
-
className: (0,
|
|
2603
|
+
className: (0, import_classnames12.default)("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2039
2604
|
onChange: (val) => {
|
|
2040
2605
|
let newVal = "";
|
|
2041
2606
|
const flag = val.target?.value.startsWith("-");
|
|
@@ -2119,8 +2684,8 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2119
2684
|
}
|
|
2120
2685
|
);
|
|
2121
2686
|
case "color":
|
|
2122
|
-
return /* @__PURE__ */ (0,
|
|
2123
|
-
|
|
2687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { padding: "4px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2688
|
+
import_reactstrap9.Input,
|
|
2124
2689
|
{
|
|
2125
2690
|
type: "color",
|
|
2126
2691
|
value: row[col.field],
|
|
@@ -2142,7 +2707,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2142
2707
|
`col-${indexRow}-${indexCol}`
|
|
2143
2708
|
) });
|
|
2144
2709
|
case "form":
|
|
2145
|
-
return /* @__PURE__ */ (0,
|
|
2710
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2146
2711
|
edit_form_default,
|
|
2147
2712
|
{
|
|
2148
2713
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -2164,13 +2729,13 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2164
2729
|
}
|
|
2165
2730
|
);
|
|
2166
2731
|
default:
|
|
2167
|
-
return /* @__PURE__ */ (0,
|
|
2168
|
-
|
|
2732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2733
|
+
import_reactstrap9.Input,
|
|
2169
2734
|
{
|
|
2170
2735
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2171
2736
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2172
2737
|
defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
|
|
2173
|
-
className: (0,
|
|
2738
|
+
className: (0, import_classnames12.default)("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2174
2739
|
onBlur: (val) => {
|
|
2175
2740
|
if (row[col.field] != val.target?.value) {
|
|
2176
2741
|
row[col.field] = val.target?.value;
|
|
@@ -2208,14 +2773,14 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2208
2773
|
}
|
|
2209
2774
|
};
|
|
2210
2775
|
const renderCommand = (commandItems, rowData, i) => {
|
|
2211
|
-
return /* @__PURE__ */ (0,
|
|
2212
|
-
return /* @__PURE__ */ (0,
|
|
2213
|
-
|
|
2776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "d-flex align-items-center", style: { columnGap: 10 }, children: commandItems.map((item, index) => {
|
|
2777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2778
|
+
import_reactstrap9.Button,
|
|
2214
2779
|
{
|
|
2215
2780
|
id: `command-item-${i}`,
|
|
2216
2781
|
tabIndex: -1,
|
|
2217
2782
|
style: { padding: "5px", minWidth: 45, height: "100%" },
|
|
2218
|
-
className: (0,
|
|
2783
|
+
className: (0, import_classnames12.default)("command-item", {
|
|
2219
2784
|
"btn-icon": item.tooltip === ""
|
|
2220
2785
|
}),
|
|
2221
2786
|
color: item.color ? item.color : "#000",
|
|
@@ -2227,8 +2792,8 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2227
2792
|
e.preventDefault();
|
|
2228
2793
|
},
|
|
2229
2794
|
children: [
|
|
2230
|
-
item.icon && /* @__PURE__ */ (0,
|
|
2231
|
-
/* @__PURE__ */ (0,
|
|
2795
|
+
item.icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(icon_default, { iconName: item.icon, size: 16 }),
|
|
2796
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.UncontrolledTooltip, { className: "r-tooltip", target: `command-item-${i}`, place: "top", children: t(item.tooltip ?? "") })
|
|
2232
2797
|
]
|
|
2233
2798
|
},
|
|
2234
2799
|
`command-${index}`
|
|
@@ -2485,7 +3050,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2485
3050
|
}
|
|
2486
3051
|
}
|
|
2487
3052
|
};
|
|
2488
|
-
(0,
|
|
3053
|
+
(0, import_react14.useEffect)(() => {
|
|
2489
3054
|
setIndexFocus(-1);
|
|
2490
3055
|
if (setSelectedItem) {
|
|
2491
3056
|
if (isMulti) {
|
|
@@ -2512,7 +3077,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2512
3077
|
}
|
|
2513
3078
|
}
|
|
2514
3079
|
}, [selectedRows]);
|
|
2515
|
-
(0,
|
|
3080
|
+
(0, import_react14.useEffect)(() => {
|
|
2516
3081
|
if (!isMulti) {
|
|
2517
3082
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
2518
3083
|
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
@@ -2529,10 +3094,10 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2529
3094
|
}, [selectedItem]);
|
|
2530
3095
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
2531
3096
|
if (col.field === "command") {
|
|
2532
|
-
return col.visible !== false && /* @__PURE__ */ (0,
|
|
3097
|
+
return col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2533
3098
|
"td",
|
|
2534
3099
|
{
|
|
2535
|
-
className: (0,
|
|
3100
|
+
className: (0, import_classnames12.default)(
|
|
2536
3101
|
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
2537
3102
|
{ "cell-fixed": col.fixedType },
|
|
2538
3103
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -2542,15 +3107,15 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2542
3107
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
2543
3108
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
2544
3109
|
},
|
|
2545
|
-
children: /* @__PURE__ */ (0,
|
|
3110
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-rowcell-div ", children: renderCommand(col.commandItems, row, indexRow) })
|
|
2546
3111
|
},
|
|
2547
3112
|
`col-${indexRow}-${indexCol}`
|
|
2548
3113
|
);
|
|
2549
3114
|
} else if (col.field === "#") {
|
|
2550
|
-
return col.visible !== false && /* @__PURE__ */ (0,
|
|
3115
|
+
return col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2551
3116
|
"td",
|
|
2552
3117
|
{
|
|
2553
|
-
className: (0,
|
|
3118
|
+
className: (0, import_classnames12.default)(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
2554
3119
|
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
2555
3120
|
style: {
|
|
2556
3121
|
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
@@ -2594,15 +3159,15 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2594
3159
|
e.stopPropagation();
|
|
2595
3160
|
}
|
|
2596
3161
|
},
|
|
2597
|
-
children: /* @__PURE__ */ (0,
|
|
3162
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-rowcell-div pt-50", children: indexRow + 1 })
|
|
2598
3163
|
},
|
|
2599
3164
|
`col-${indexRow}-${indexCol}`
|
|
2600
3165
|
);
|
|
2601
3166
|
} else if (col.field === "checkbox") {
|
|
2602
|
-
return /* @__PURE__ */ (0,
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2603
3168
|
"td",
|
|
2604
3169
|
{
|
|
2605
|
-
className: (0,
|
|
3170
|
+
className: (0, import_classnames12.default)(
|
|
2606
3171
|
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
2607
3172
|
{ "cell-fixed": col.fixedType },
|
|
2608
3173
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -2612,7 +3177,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2612
3177
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
2613
3178
|
textAlign: col.textAlign ? col.textAlign : "center"
|
|
2614
3179
|
},
|
|
2615
|
-
children: /* @__PURE__ */ (0,
|
|
3180
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2616
3181
|
"div",
|
|
2617
3182
|
{
|
|
2618
3183
|
className: "r-rowcell-div cursor-pointer",
|
|
@@ -2636,8 +3201,8 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2636
3201
|
e.stopPropagation();
|
|
2637
3202
|
}
|
|
2638
3203
|
},
|
|
2639
|
-
children: /* @__PURE__ */ (0,
|
|
2640
|
-
|
|
3204
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3205
|
+
import_reactstrap9.Input,
|
|
2641
3206
|
{
|
|
2642
3207
|
checked: isSelected,
|
|
2643
3208
|
type: "checkbox",
|
|
@@ -2657,16 +3222,16 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2657
3222
|
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
2658
3223
|
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
2659
3224
|
} else if (col.editType === "date") {
|
|
2660
|
-
value = value ? (0,
|
|
3225
|
+
value = value ? (0, import_moment2.default)(value).format("DD/MM/yyyy") : "";
|
|
2661
3226
|
} else if (col.editType === "datetime") {
|
|
2662
|
-
value = value ? (0,
|
|
3227
|
+
value = value ? (0, import_moment2.default)(value).format("DD/MM/yyyy HH:mm") : "";
|
|
2663
3228
|
}
|
|
2664
3229
|
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
2665
3230
|
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
2666
|
-
return /* @__PURE__ */ (0,
|
|
3231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2667
3232
|
"td",
|
|
2668
3233
|
{
|
|
2669
|
-
className: (0,
|
|
3234
|
+
className: (0, import_classnames12.default)(
|
|
2670
3235
|
`r-rowcell fix-${col.fixedType}`,
|
|
2671
3236
|
{ "cell-fixed": col.fixedType },
|
|
2672
3237
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -2708,28 +3273,28 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2708
3273
|
e.stopPropagation();
|
|
2709
3274
|
}
|
|
2710
3275
|
},
|
|
2711
|
-
children: /* @__PURE__ */ (0,
|
|
3276
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2712
3277
|
"div",
|
|
2713
3278
|
{
|
|
2714
|
-
className: (0,
|
|
3279
|
+
className: (0, import_classnames12.default)("r-rowcell-div"),
|
|
2715
3280
|
style: {
|
|
2716
3281
|
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width
|
|
2717
3282
|
},
|
|
2718
|
-
children: /* @__PURE__ */ (0,
|
|
3283
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2719
3284
|
"div",
|
|
2720
3285
|
{
|
|
2721
3286
|
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
2722
|
-
className: (0,
|
|
3287
|
+
className: (0, import_classnames12.default)("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
2723
3288
|
style: {
|
|
2724
3289
|
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
2725
3290
|
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
2726
3291
|
},
|
|
2727
3292
|
children: [
|
|
2728
|
-
typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : /* @__PURE__ */ (0,
|
|
2729
|
-
/* @__PURE__ */ (0,
|
|
2730
|
-
!(typeDis === 1 && !refreshRow) &&
|
|
2731
|
-
/* @__PURE__ */ (0,
|
|
2732
|
-
|
|
3293
|
+
typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { id: `content-${idTable}-${indexRow}-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3294
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: `error-${indexRow}-${indexCol}`, className: (0, import_classnames12.default)("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons6.AlertCircle, { fontSize: 15.5 }) }),
|
|
3295
|
+
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-${indexRow}-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3296
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3297
|
+
import_reactstrap9.UncontrolledTooltip,
|
|
2733
3298
|
{
|
|
2734
3299
|
target: `error-${indexRow}-${indexCol}`,
|
|
2735
3300
|
className: "r-tooltip tooltip-error",
|
|
@@ -2746,14 +3311,18 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2746
3311
|
) }, indexCol);
|
|
2747
3312
|
}
|
|
2748
3313
|
};
|
|
3314
|
+
const checkOverflow = (indexRow, indexCol) => {
|
|
3315
|
+
const element = document.getElementById(`content-${idTable}-${indexRow}-${indexCol}`);
|
|
3316
|
+
return element && element.scrollWidth > element.clientWidth;
|
|
3317
|
+
};
|
|
2749
3318
|
const renderHeaderCol = (col, indexCol, indexParent) => {
|
|
2750
3319
|
if (col.field === "checkbox") {
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
3320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2752
3321
|
"th",
|
|
2753
3322
|
{
|
|
2754
3323
|
rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
|
|
2755
3324
|
colSpan: col.columns?.length ?? 1,
|
|
2756
|
-
className: (0,
|
|
3325
|
+
className: (0, import_classnames12.default)(
|
|
2757
3326
|
`r-headercell fix-${col.fixedType}`,
|
|
2758
3327
|
{ "cell-fixed": col.fixedType }
|
|
2759
3328
|
),
|
|
@@ -2765,17 +3334,17 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2765
3334
|
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
2766
3335
|
maxWidth: col.maxWidth
|
|
2767
3336
|
},
|
|
2768
|
-
children: /* @__PURE__ */ (0,
|
|
3337
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2769
3338
|
"div",
|
|
2770
3339
|
{
|
|
2771
3340
|
style: { justifyContent: col.textAlign ?? "left" },
|
|
2772
|
-
className: (0,
|
|
2773
|
-
children: /* @__PURE__ */ (0,
|
|
2774
|
-
|
|
3341
|
+
className: (0, import_classnames12.default)("r-headercell-div"),
|
|
3342
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3343
|
+
import_reactstrap9.Input,
|
|
2775
3344
|
{
|
|
2776
3345
|
checked: totalCount > 0 && selectedRows?.length >= totalCount,
|
|
2777
3346
|
type: "checkbox",
|
|
2778
|
-
className: (0,
|
|
3347
|
+
className: (0, import_classnames12.default)("cursor-pointer", { "d-none": !isMulti }),
|
|
2779
3348
|
style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
|
|
2780
3349
|
onChange: (e) => {
|
|
2781
3350
|
if (selectEnable) {
|
|
@@ -2795,15 +3364,15 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2795
3364
|
}
|
|
2796
3365
|
) }, `header-${indexCol}`);
|
|
2797
3366
|
} else if (col.field === "#") {
|
|
2798
|
-
return /* @__PURE__ */ (0,
|
|
2799
|
-
|
|
3367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3368
|
+
import_react14.Fragment,
|
|
2800
3369
|
{
|
|
2801
|
-
children: col.visible !== false && /* @__PURE__ */ (0,
|
|
3370
|
+
children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2802
3371
|
"th",
|
|
2803
3372
|
{
|
|
2804
3373
|
rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
|
|
2805
3374
|
colSpan: col.columns?.length ?? 1,
|
|
2806
|
-
className: (0,
|
|
3375
|
+
className: (0, import_classnames12.default)(
|
|
2807
3376
|
`r-headercell fix-${col.fixedType}`,
|
|
2808
3377
|
{ "cell-fixed": col.fixedType }
|
|
2809
3378
|
),
|
|
@@ -2815,7 +3384,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2815
3384
|
left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
|
|
2816
3385
|
right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0
|
|
2817
3386
|
},
|
|
2818
|
-
children: /* @__PURE__ */ (0,
|
|
3387
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2819
3388
|
"div",
|
|
2820
3389
|
{
|
|
2821
3390
|
title: t(col.headerText ?? ""),
|
|
@@ -2830,15 +3399,15 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2830
3399
|
`header-${indexCol}`
|
|
2831
3400
|
);
|
|
2832
3401
|
} else {
|
|
2833
|
-
return /* @__PURE__ */ (0,
|
|
2834
|
-
|
|
3402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3403
|
+
import_react14.Fragment,
|
|
2835
3404
|
{
|
|
2836
|
-
children: col.visible !== false && /* @__PURE__ */ (0,
|
|
3405
|
+
children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2837
3406
|
"th",
|
|
2838
3407
|
{
|
|
2839
3408
|
rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
|
|
2840
3409
|
colSpan: col.columns?.length ?? 1,
|
|
2841
|
-
className: (0,
|
|
3410
|
+
className: (0, import_classnames12.default)(
|
|
2842
3411
|
`r-headercell fix-${col.fixedType}`,
|
|
2843
3412
|
{ "cell-fixed": col.fixedType }
|
|
2844
3413
|
),
|
|
@@ -2850,7 +3419,7 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2850
3419
|
right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
|
|
2851
3420
|
maxWidth: col.maxWidth
|
|
2852
3421
|
},
|
|
2853
|
-
children: /* @__PURE__ */ (0,
|
|
3422
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2854
3423
|
"div",
|
|
2855
3424
|
{
|
|
2856
3425
|
role: "textbox",
|
|
@@ -2868,10 +3437,10 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2868
3437
|
}
|
|
2869
3438
|
};
|
|
2870
3439
|
const renderFooterCol = (col, indexCol) => {
|
|
2871
|
-
return /* @__PURE__ */ (0,
|
|
3440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2872
3441
|
"td",
|
|
2873
3442
|
{
|
|
2874
|
-
className: (0,
|
|
3443
|
+
className: (0, import_classnames12.default)(
|
|
2875
3444
|
`p-0 px-50 r-footer fix-${col.fixedType}`,
|
|
2876
3445
|
{ "cell-fixed": col.fixedType }
|
|
2877
3446
|
),
|
|
@@ -2883,56 +3452,56 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2883
3452
|
maxWidth: col.maxWidth,
|
|
2884
3453
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
2885
3454
|
},
|
|
2886
|
-
children: /* @__PURE__ */ (0,
|
|
3455
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-footer-div", children: col.haveSum === true && col.editType === "numeric" ? formartNumberic(dataSource.reduce(function(accumulator, currentValue) {
|
|
2887
3456
|
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
2888
3457
|
}, 0), decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) : "" })
|
|
2889
3458
|
}
|
|
2890
3459
|
) }, `summarycell-${indexCol}`);
|
|
2891
3460
|
};
|
|
2892
3461
|
const renderToolbarTop = () => {
|
|
2893
|
-
return /* @__PURE__ */ (0,
|
|
2894
|
-
/* @__PURE__ */ (0,
|
|
2895
|
-
return item.align === "left" ? /* @__PURE__ */ (0,
|
|
3462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "r-toolbar-items", children: [
|
|
3463
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
|
|
3464
|
+
return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) : "";
|
|
2896
3465
|
}) }),
|
|
2897
|
-
/* @__PURE__ */ (0,
|
|
2898
|
-
return item.align === "center" ? /* @__PURE__ */ (0,
|
|
3466
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-center", children: toolbarTopOption?.map((item, index) => {
|
|
3467
|
+
return item.align === "center" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-center-${index}`) : "";
|
|
2899
3468
|
}) }),
|
|
2900
|
-
/* @__PURE__ */ (0,
|
|
2901
|
-
return item.align === "right" ? /* @__PURE__ */ (0,
|
|
3469
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-right", children: toolbarTopOption?.map((item, index) => {
|
|
3470
|
+
return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-right-${index}`) : "";
|
|
2902
3471
|
}) })
|
|
2903
3472
|
] }) });
|
|
2904
3473
|
};
|
|
2905
3474
|
const renderToolbarBottom = () => {
|
|
2906
|
-
return /* @__PURE__ */ (0,
|
|
2907
|
-
/* @__PURE__ */ (0,
|
|
2908
|
-
/* @__PURE__ */ (0,
|
|
2909
|
-
(indexFocus ?? -1) > -1 ? /* @__PURE__ */ (0,
|
|
2910
|
-
/* @__PURE__ */ (0,
|
|
3475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "r-toolbar-items", children: [
|
|
3476
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "r-toolbar-left", children: [
|
|
3477
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.Button, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
|
|
3478
|
+
(indexFocus ?? -1) > -1 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.Button, { color: "success", outline: true, onClick: () => {
|
|
2911
3480
|
handleDuplicate(dataSource[indexFocus ?? -1], indexFocus ?? -1);
|
|
2912
3481
|
}, className: "d-flex", children: t("Duplicate") }) }),
|
|
2913
|
-
/* @__PURE__ */ (0,
|
|
2914
|
-
/* @__PURE__ */ (0,
|
|
2915
|
-
] }) : /* @__PURE__ */ (0,
|
|
2916
|
-
/* @__PURE__ */ (0,
|
|
3482
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.Button, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
|
|
3483
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.Button, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
|
|
3484
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: " " }),
|
|
3485
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item", { "d-none": editDisable || buttonSetting?.deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.Button, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
|
|
2917
3486
|
toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
2918
|
-
return item.align === "left" ? /* @__PURE__ */ (0,
|
|
3487
|
+
return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
|
|
2919
3488
|
})
|
|
2920
3489
|
] }),
|
|
2921
|
-
/* @__PURE__ */ (0,
|
|
2922
|
-
return item.align === "center" ? /* @__PURE__ */ (0,
|
|
3490
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-center", children: toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
3491
|
+
return item.align === "center" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : "";
|
|
2923
3492
|
}) }),
|
|
2924
|
-
/* @__PURE__ */ (0,
|
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "r-toolbar-right", children: [
|
|
2925
3494
|
toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
2926
|
-
return item.align === "right" ? /* @__PURE__ */ (0,
|
|
3495
|
+
return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : "";
|
|
2927
3496
|
}),
|
|
2928
|
-
/* @__PURE__ */ (0,
|
|
2929
|
-
/* @__PURE__ */ (0,
|
|
2930
|
-
/* @__PURE__ */ (0,
|
|
2931
|
-
/* @__PURE__ */ (0,
|
|
2932
|
-
/* @__PURE__ */ (0,
|
|
2933
|
-
/* @__PURE__ */ (0,
|
|
2934
|
-
/* @__PURE__ */ (0,
|
|
2935
|
-
/* @__PURE__ */ (0,
|
|
3497
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons6.Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_classnames12.default)("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_reactstrap9.UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
|
|
3499
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.DropdownToggle, { href: "/", tag: "a", color: "info", onClick: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons6.Info, { className: "cursor-pointer" }) }),
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.DropdownMenu, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "d-flex flex-column p-50 py-25", children: [
|
|
3501
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\xE2n b\u1EA3n" }),
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { fontSize: 13 }, children: "Ch\u1ECDn \xF4 v\xE0 Ctrl + V \u0111\u1EC3 d\xE1n th\xF4ng tin t\u1EEB excel" }),
|
|
3503
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + C \u0111\u1EC3 sao ch\xE9p h\xE0ng" }),
|
|
3504
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + V \u0111\u1EC3 d\xE1n h\xE0ng" })
|
|
2936
3505
|
] }) })
|
|
2937
3506
|
] }) })
|
|
2938
3507
|
] })
|
|
@@ -2961,10 +3530,10 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2961
3530
|
const flagDisplay = !pagingClient || totalCount > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && totalCount <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0);
|
|
2962
3531
|
if (flagDisplay) {
|
|
2963
3532
|
countDisplay++;
|
|
2964
|
-
return /* @__PURE__ */ (0,
|
|
3533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2965
3534
|
"tr",
|
|
2966
3535
|
{
|
|
2967
|
-
className: (0,
|
|
3536
|
+
className: (0, import_classnames12.default)("r-row", { "fisrt-row": countDisplay === 0 }),
|
|
2968
3537
|
children: contentColumns.map((col, indexCol) => {
|
|
2969
3538
|
return renderContentCol(col, row, indexRow, indexCol, isSelected);
|
|
2970
3539
|
})
|
|
@@ -2975,29 +3544,29 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
2975
3544
|
}
|
|
2976
3545
|
});
|
|
2977
3546
|
};
|
|
2978
|
-
(0,
|
|
3547
|
+
(0, import_react14.useEffect)(() => {
|
|
2979
3548
|
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
2980
3549
|
pagingSetting?.setCurrentPage(1);
|
|
2981
3550
|
}
|
|
2982
3551
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
2983
|
-
return /* @__PURE__ */ (0,
|
|
2984
|
-
/* @__PURE__ */ (0,
|
|
2985
|
-
/* @__PURE__ */ (0,
|
|
2986
|
-
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ (0,
|
|
2987
|
-
/* @__PURE__ */ (0,
|
|
2988
|
-
/* @__PURE__ */ (0,
|
|
2989
|
-
return /* @__PURE__ */ (0,
|
|
3552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react14.Fragment, { children: [
|
|
3553
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "react-table-edit", children: [
|
|
3554
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "r-grid", ref: gridRef, children: [
|
|
3555
|
+
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: renderToolbarTop() }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, {}),
|
|
3556
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("table", { style: { width: "100%" }, children: [
|
|
3557
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("thead", { className: "r-gridheader", children: headerColumns.map((element, indexParent) => {
|
|
3558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
2990
3559
|
return renderHeaderCol(col, index, indexParent);
|
|
2991
3560
|
}) }, indexParent);
|
|
2992
3561
|
}) }),
|
|
2993
|
-
/* @__PURE__ */ (0,
|
|
2994
|
-
/* @__PURE__ */ (0,
|
|
3562
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tbody", { className: "r-gridcontent", children: renderData() }),
|
|
3563
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tfoot", { className: "r-gridfoot", children: haveSum == true ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
2995
3564
|
return renderFooterCol(col, index);
|
|
2996
|
-
}) }) : /* @__PURE__ */ (0,
|
|
3565
|
+
}) }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, {}) })
|
|
2997
3566
|
] }) }),
|
|
2998
|
-
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ (0,
|
|
3567
|
+
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: renderToolbarBottom() }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, {})
|
|
2999
3568
|
] }),
|
|
3000
|
-
pagingSetting?.allowPaging ? /* @__PURE__ */ (0,
|
|
3569
|
+
pagingSetting?.allowPaging ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3001
3570
|
PagingComponent,
|
|
3002
3571
|
{
|
|
3003
3572
|
onChangePage,
|
|
@@ -3007,9 +3576,9 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
3007
3576
|
totalItem: pagingClient ? totalCount : pagingSetting?.totalItem ?? 0,
|
|
3008
3577
|
onChangePageSize
|
|
3009
3578
|
}
|
|
3010
|
-
) : /* @__PURE__ */ (0,
|
|
3579
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, {})
|
|
3011
3580
|
] }),
|
|
3012
|
-
/* @__PURE__ */ (0,
|
|
3581
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3013
3582
|
sidebar_setting_column_default,
|
|
3014
3583
|
{
|
|
3015
3584
|
handleSidebar: () => {
|
|
@@ -3025,12 +3594,12 @@ var TableEdit = (0, import_react13.forwardRef)((props, ref) => {
|
|
|
3025
3594
|
var table_default = TableEdit;
|
|
3026
3595
|
|
|
3027
3596
|
// test-app/src/component/tab-menu/index.tsx
|
|
3028
|
-
var
|
|
3029
|
-
var
|
|
3030
|
-
var
|
|
3597
|
+
var import_becoxy_icons7 = require("becoxy-icons");
|
|
3598
|
+
var import_classnames13 = __toESM(require("classnames"));
|
|
3599
|
+
var import_react15 = require("react");
|
|
3031
3600
|
var import_react_router_dom = require("react-router-dom");
|
|
3032
|
-
var
|
|
3033
|
-
var
|
|
3601
|
+
var import_reactstrap10 = require("reactstrap");
|
|
3602
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3034
3603
|
var TabsMenuComponent = ({
|
|
3035
3604
|
buttonWidth,
|
|
3036
3605
|
tabParent,
|
|
@@ -3042,14 +3611,14 @@ var TabsMenuComponent = ({
|
|
|
3042
3611
|
renderModal
|
|
3043
3612
|
}) => {
|
|
3044
3613
|
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
3045
|
-
const [dataMenu, setDataMenu] = (0,
|
|
3046
|
-
const [openMenu, setOpenMenu] = (0,
|
|
3047
|
-
const [url, setUrl] = (0,
|
|
3048
|
-
const [contentWidth, setContentWidth] = (0,
|
|
3049
|
-
const [componentWidth, setComponentWidth] = (0,
|
|
3050
|
-
const [scrollPosition, setScrollPosition] = (0,
|
|
3051
|
-
const [dataItem, setDataItem] = (0,
|
|
3052
|
-
const [openModal, setOpenModal] = (0,
|
|
3614
|
+
const [dataMenu, setDataMenu] = (0, import_react15.useState)([]);
|
|
3615
|
+
const [openMenu, setOpenMenu] = (0, import_react15.useState)(false);
|
|
3616
|
+
const [url, setUrl] = (0, import_react15.useState)("");
|
|
3617
|
+
const [contentWidth, setContentWidth] = (0, import_react15.useState)(0);
|
|
3618
|
+
const [componentWidth, setComponentWidth] = (0, import_react15.useState)(0);
|
|
3619
|
+
const [scrollPosition, setScrollPosition] = (0, import_react15.useState)(0);
|
|
3620
|
+
const [dataItem, setDataItem] = (0, import_react15.useState)([]);
|
|
3621
|
+
const [openModal, setOpenModal] = (0, import_react15.useState)({});
|
|
3053
3622
|
const handleWindowResize = () => {
|
|
3054
3623
|
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3055
3624
|
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
@@ -3058,7 +3627,7 @@ var TabsMenuComponent = ({
|
|
|
3058
3627
|
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
3059
3628
|
}
|
|
3060
3629
|
};
|
|
3061
|
-
(0,
|
|
3630
|
+
(0, import_react15.useEffect)(() => {
|
|
3062
3631
|
setUrl(window.location.pathname);
|
|
3063
3632
|
window.addEventListener("resize", handleWindowResize);
|
|
3064
3633
|
setTimeout(() => {
|
|
@@ -3074,7 +3643,7 @@ var TabsMenuComponent = ({
|
|
|
3074
3643
|
window.removeEventListener("resize", handleWindowResize);
|
|
3075
3644
|
};
|
|
3076
3645
|
}, []);
|
|
3077
|
-
(0,
|
|
3646
|
+
(0, import_react15.useEffect)(() => {
|
|
3078
3647
|
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
3079
3648
|
if (item) {
|
|
3080
3649
|
if (resourceCodeParent) {
|
|
@@ -3105,23 +3674,23 @@ var TabsMenuComponent = ({
|
|
|
3105
3674
|
const handleModal = (name) => {
|
|
3106
3675
|
setOpenModal((old) => ({ ...old, [name]: !(openModal[name] ?? false) }));
|
|
3107
3676
|
};
|
|
3108
|
-
return /* @__PURE__ */ (0,
|
|
3677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react15.Fragment, { children: [
|
|
3109
3678
|
renderModal ? renderModal({ handleModal, windowSize, openModal, setDataItem, dataItem }) : "",
|
|
3110
|
-
/* @__PURE__ */ (0,
|
|
3111
|
-
/* @__PURE__ */ (0,
|
|
3679
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: (0, import_classnames13.default)("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
3680
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3112
3681
|
"div",
|
|
3113
3682
|
{
|
|
3114
3683
|
onClick: () => handleScroll(-200),
|
|
3115
|
-
className: (0,
|
|
3116
|
-
children: /* @__PURE__ */ (0,
|
|
3684
|
+
className: (0, import_classnames13.default)("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3685
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_becoxy_icons7.ChevronLeft, {})
|
|
3117
3686
|
}
|
|
3118
3687
|
),
|
|
3119
|
-
/* @__PURE__ */ (0,
|
|
3688
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
3120
3689
|
if (item?.resAttributes?.IS_MENU === "1") {
|
|
3121
|
-
return /* @__PURE__ */ (0,
|
|
3122
|
-
/* @__PURE__ */ (0,
|
|
3123
|
-
/* @__PURE__ */ (0,
|
|
3124
|
-
|
|
3690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_reactstrap10.UncontrolledDropdown, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
3691
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_reactstrap10.DropdownToggle, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { children: item.name }) }),
|
|
3692
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_reactstrap10.DropdownMenu, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3693
|
+
import_reactstrap10.DropdownItem,
|
|
3125
3694
|
{
|
|
3126
3695
|
style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%" },
|
|
3127
3696
|
onClick: () => {
|
|
@@ -3137,23 +3706,23 @@ var TabsMenuComponent = ({
|
|
|
3137
3706
|
)) })
|
|
3138
3707
|
] }, item.code);
|
|
3139
3708
|
} else {
|
|
3140
|
-
return /* @__PURE__ */ (0,
|
|
3709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3141
3710
|
import_react_router_dom.Link,
|
|
3142
3711
|
{
|
|
3143
3712
|
to: item.url,
|
|
3144
|
-
className: (0,
|
|
3713
|
+
className: (0, import_classnames13.default)("tab-custom-item", { active: item.url === url || tabParent && url?.split("/").length > 3 && item.url.startsWith(url.substring(0, url.lastIndexOf("/"))) }),
|
|
3145
3714
|
children: item.name
|
|
3146
3715
|
},
|
|
3147
3716
|
item.code
|
|
3148
3717
|
);
|
|
3149
3718
|
}
|
|
3150
3719
|
}) }) }),
|
|
3151
|
-
/* @__PURE__ */ (0,
|
|
3720
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3152
3721
|
"div",
|
|
3153
3722
|
{
|
|
3154
3723
|
onClick: () => handleScroll(200),
|
|
3155
|
-
className: (0,
|
|
3156
|
-
children: /* @__PURE__ */ (0,
|
|
3724
|
+
className: (0, import_classnames13.default)("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3725
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_becoxy_icons7.ChevronRight, {})
|
|
3157
3726
|
}
|
|
3158
3727
|
)
|
|
3159
3728
|
] })
|