react-table-edit 0.5.4 → 0.5.6
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 +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +790 -194
- package/dist/index.mjs +791 -187
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// test-app/src/component/table/index.tsx
|
|
2
|
-
import { Fragment as
|
|
3
|
-
import { Button as
|
|
4
|
-
import
|
|
5
|
-
import { useTranslation as
|
|
2
|
+
import { Fragment as Fragment15, forwardRef as forwardRef3, useEffect as useEffect8, useImperativeHandle, useRef as useRef3, useState as useState7 } from "react";
|
|
3
|
+
import { Button as Button4, DropdownMenu as DropdownMenu3, DropdownToggle as DropdownToggle3, Input as Input7, UncontrolledDropdown, UncontrolledTooltip as UncontrolledTooltip2 } from "reactstrap";
|
|
4
|
+
import classnames7 from "classnames";
|
|
5
|
+
import { useTranslation as useTranslation10 } from "react-i18next";
|
|
6
6
|
import Select3 from "react-select";
|
|
7
7
|
import AsyncSelect from "react-select/async";
|
|
8
8
|
import { AlertCircle, Info as Info2, Settings } from "becoxy-icons";
|
|
@@ -293,7 +293,7 @@ var IconCustom = (props) => {
|
|
|
293
293
|
var icon_default = IconCustom;
|
|
294
294
|
|
|
295
295
|
// test-app/src/component/table/index.tsx
|
|
296
|
-
import
|
|
296
|
+
import moment2 from "moment";
|
|
297
297
|
|
|
298
298
|
// test-app/src/component/edit-form/index.tsx
|
|
299
299
|
import { forwardRef, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
@@ -1451,13 +1451,16 @@ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
|
1451
1451
|
var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOptions, onChangePageSize }) => {
|
|
1452
1452
|
const { t } = useTranslation8();
|
|
1453
1453
|
const [countPage, setCountPage] = useState5(0);
|
|
1454
|
+
const [currentPageNumber, setCurrentPageNumber] = useState5(1);
|
|
1454
1455
|
useEffect6(() => {
|
|
1455
|
-
|
|
1456
|
-
setCountPage(count);
|
|
1456
|
+
setCountPage(Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1));
|
|
1457
1457
|
}, [totalItem, pageSize]);
|
|
1458
|
-
|
|
1458
|
+
useEffect6(() => {
|
|
1459
|
+
setCurrentPageNumber(Math.floor(currentPage / 5) + (Math.floor(currentPage / 5) === currentPage / 5 ? 0 : 1));
|
|
1460
|
+
}, [currentPage]);
|
|
1461
|
+
const renderPageNumber = (number) => {
|
|
1459
1462
|
const arr = [];
|
|
1460
|
-
for (let index = 1; index <= Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1); index++) {
|
|
1463
|
+
for (let index = (number - 1) * 5 + 1; index <= number * 5 && index <= Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1); index++) {
|
|
1461
1464
|
arr.push(
|
|
1462
1465
|
/* @__PURE__ */ jsx12(
|
|
1463
1466
|
"div",
|
|
@@ -1467,7 +1470,8 @@ var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOpt
|
|
|
1467
1470
|
onChangePage({ totalItem, pageSize, currentPage: index, old: currentPage });
|
|
1468
1471
|
},
|
|
1469
1472
|
children: index
|
|
1470
|
-
}
|
|
1473
|
+
},
|
|
1474
|
+
`page-${index}`
|
|
1471
1475
|
)
|
|
1472
1476
|
);
|
|
1473
1477
|
}
|
|
@@ -1477,7 +1481,31 @@ var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOpt
|
|
|
1477
1481
|
/* @__PURE__ */ jsxs11("div", { className: "r-pagercontainer", children: [
|
|
1478
1482
|
/* @__PURE__ */ jsx12("button", { className: "r-button", type: "button", disabled: countPage === 1 || currentPage === 1, onClick: () => onChangePage({ totalItem, pageSize, currentPage: 1, old: currentPage }), children: /* @__PURE__ */ jsx12(ChevronsLeft, { fontSize: 16 }) }),
|
|
1479
1483
|
/* @__PURE__ */ jsx12("button", { className: "r-button", type: "button", disabled: countPage === 1 || currentPage === 1, onClick: () => onChangePage({ totalItem, pageSize, currentPage: currentPage - 1, old: currentPage }), children: /* @__PURE__ */ jsx12(ChevronLeft2, { fontSize: 16 }) }),
|
|
1480
|
-
|
|
1484
|
+
/* @__PURE__ */ jsx12(
|
|
1485
|
+
"button",
|
|
1486
|
+
{
|
|
1487
|
+
className: classNames5("r-button", { "d-none": currentPageNumber === 1 }),
|
|
1488
|
+
type: "button",
|
|
1489
|
+
onClick: () => {
|
|
1490
|
+
setCurrentPageNumber(currentPageNumber - 1);
|
|
1491
|
+
onChangePage({ totalItem, pageSize, currentPage: (currentPageNumber - 2) * 5 + 1, old: currentPage });
|
|
1492
|
+
},
|
|
1493
|
+
children: "..."
|
|
1494
|
+
}
|
|
1495
|
+
),
|
|
1496
|
+
renderPageNumber(currentPageNumber),
|
|
1497
|
+
/* @__PURE__ */ jsx12(
|
|
1498
|
+
"button",
|
|
1499
|
+
{
|
|
1500
|
+
className: classNames5("r-button", { "d-none": currentPageNumber * 5 >= countPage }),
|
|
1501
|
+
type: "button",
|
|
1502
|
+
onClick: () => {
|
|
1503
|
+
setCurrentPageNumber(currentPageNumber + 1);
|
|
1504
|
+
onChangePage({ totalItem, pageSize, currentPage: currentPageNumber * 5 + 1, old: currentPage });
|
|
1505
|
+
},
|
|
1506
|
+
children: "..."
|
|
1507
|
+
}
|
|
1508
|
+
),
|
|
1481
1509
|
/* @__PURE__ */ jsx12("button", { className: "r-button", type: "button", disabled: countPage === 1 || countPage === currentPage, onClick: () => onChangePage({ totalItem, pageSize, currentPage: currentPage + 1, old: currentPage }), children: /* @__PURE__ */ jsx12(ChevronRight2, { fontSize: 16 }) }),
|
|
1482
1510
|
/* @__PURE__ */ jsx12("button", { className: "r-button", type: "button", disabled: countPage === 1 || countPage === currentPage, onClick: () => onChangePage({ totalItem, pageSize, currentPage: Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1), old: currentPage }), children: /* @__PURE__ */ jsx12(ChevronsRight, { fontSize: 16 }) }),
|
|
1483
1511
|
/* @__PURE__ */ jsx12("div", { className: "r-pagesize", children: /* @__PURE__ */ jsx12(
|
|
@@ -1499,10 +1527,533 @@ var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOpt
|
|
|
1499
1527
|
] }) });
|
|
1500
1528
|
};
|
|
1501
1529
|
|
|
1502
|
-
// test-app/src/component/table/index.tsx
|
|
1530
|
+
// test-app/src/component/select-table/index.tsx
|
|
1531
|
+
import { forwardRef as forwardRef2, Fragment as Fragment13, useEffect as useEffect7, useRef as useRef2, useState as useState6 } from "react";
|
|
1532
|
+
import {
|
|
1533
|
+
DropdownItem as DropdownItem2,
|
|
1534
|
+
DropdownMenu as DropdownMenu2,
|
|
1535
|
+
DropdownToggle as DropdownToggle2,
|
|
1536
|
+
Dropdown as Dropdown2,
|
|
1537
|
+
Button as Button3,
|
|
1538
|
+
UncontrolledTooltip,
|
|
1539
|
+
Input as Input6
|
|
1540
|
+
} from "reactstrap";
|
|
1541
|
+
import { useTranslation as useTranslation9 } from "react-i18next";
|
|
1542
|
+
import classnames6 from "classnames";
|
|
1543
|
+
import moment from "moment";
|
|
1544
|
+
import { Plus as Plus2 } from "becoxy-icons";
|
|
1503
1545
|
import { Fragment as Fragment14, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1504
|
-
var
|
|
1546
|
+
var defaultMaxHeight = 300;
|
|
1547
|
+
var SelectTable = forwardRef2((props, ref) => {
|
|
1548
|
+
const {
|
|
1549
|
+
id,
|
|
1550
|
+
menuWidth,
|
|
1551
|
+
invalid,
|
|
1552
|
+
onKeyDown,
|
|
1553
|
+
placeholder,
|
|
1554
|
+
textAlign,
|
|
1555
|
+
options,
|
|
1556
|
+
columns,
|
|
1557
|
+
decimalSeparator,
|
|
1558
|
+
thousandSeparator,
|
|
1559
|
+
onChange,
|
|
1560
|
+
value,
|
|
1561
|
+
fieldValue,
|
|
1562
|
+
fieldLabel,
|
|
1563
|
+
loadOptions,
|
|
1564
|
+
maxHeight,
|
|
1565
|
+
handleAdd,
|
|
1566
|
+
isClearable,
|
|
1567
|
+
component,
|
|
1568
|
+
isMulti
|
|
1569
|
+
} = props;
|
|
1570
|
+
const selectTableRef = useRef2();
|
|
1571
|
+
const selectMenuTableRef = useRef2();
|
|
1572
|
+
const inputRef = useRef2();
|
|
1573
|
+
const [dropdownOpen, setDropdownOpen] = useState6(false);
|
|
1574
|
+
const [indexFocus, setIndexFocus] = useState6(-1);
|
|
1575
|
+
const [isFocus, setIsFocus] = useState6(false);
|
|
1576
|
+
const [searchTerm, setSearchTerm] = useState6("");
|
|
1577
|
+
const [optionsLoad, setOptionsLoad] = useState6();
|
|
1505
1578
|
const { t } = useTranslation9();
|
|
1579
|
+
const defaultColumns = [
|
|
1580
|
+
{
|
|
1581
|
+
field: "key",
|
|
1582
|
+
headerText: "Code",
|
|
1583
|
+
width: 100,
|
|
1584
|
+
maxWidth: 120,
|
|
1585
|
+
minWidth: 80
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
headerText: "Name",
|
|
1589
|
+
field: "label",
|
|
1590
|
+
width: 150,
|
|
1591
|
+
maxWidth: 200,
|
|
1592
|
+
minWidth: 250
|
|
1593
|
+
}
|
|
1594
|
+
];
|
|
1595
|
+
const closeMenu = () => {
|
|
1596
|
+
setDropdownOpen(false);
|
|
1597
|
+
};
|
|
1598
|
+
useEffect7(() => {
|
|
1599
|
+
if (dropdownOpen) {
|
|
1600
|
+
if (value) {
|
|
1601
|
+
if (selectMenuTableRef) {
|
|
1602
|
+
const elementFocus = document.getElementById(`row-select-table-${(optionsLoad ? optionsLoad : options)?.findIndex((e) => e[fieldValue ?? "value"] === value[fieldValue ?? "value"])}`);
|
|
1603
|
+
if (elementFocus) {
|
|
1604
|
+
const rect = elementFocus.getBoundingClientRect();
|
|
1605
|
+
const parentRect = selectMenuTableRef.current?.getBoundingClientRect();
|
|
1606
|
+
if (rect.top < parentRect.top || rect.bottom > parentRect.bottom) {
|
|
1607
|
+
selectMenuTableRef.current.scrollTo({
|
|
1608
|
+
top: elementFocus.offsetTop,
|
|
1609
|
+
behavior: "smooth"
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}, [dropdownOpen]);
|
|
1617
|
+
let timeOutBlur;
|
|
1618
|
+
useEffect7(() => {
|
|
1619
|
+
if (inputRef) {
|
|
1620
|
+
inputRef.current.addEventListener("blur", function() {
|
|
1621
|
+
timeOutBlur = setTimeout(() => {
|
|
1622
|
+
if (document.activeElement?.className !== "select-input" && !selectTableRef.current?.contains(document.activeElement)) {
|
|
1623
|
+
setDropdownOpen(false);
|
|
1624
|
+
setIsFocus(false);
|
|
1625
|
+
}
|
|
1626
|
+
}, 100);
|
|
1627
|
+
});
|
|
1628
|
+
inputRef.current.addEventListener("focus", function() {
|
|
1629
|
+
if (!isFocus) {
|
|
1630
|
+
setIsFocus(true);
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
}, [inputRef]);
|
|
1635
|
+
useEffect7(() => {
|
|
1636
|
+
if (searchTerm && !dropdownOpen) {
|
|
1637
|
+
setDropdownOpen(true);
|
|
1638
|
+
setIndexFocus(0);
|
|
1639
|
+
}
|
|
1640
|
+
}, [searchTerm]);
|
|
1641
|
+
const handleOpenClose = () => {
|
|
1642
|
+
setSearchTerm("");
|
|
1643
|
+
if (dropdownOpen) {
|
|
1644
|
+
closeMenu();
|
|
1645
|
+
} else {
|
|
1646
|
+
setDropdownOpen(true);
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
const listKeyUse = ["Escape", "Space", "Enter", "Tab", "NumpadEnter", "ArrowDown", "ArrowUp", "F9"];
|
|
1650
|
+
const handleOnKeyDown = (e) => {
|
|
1651
|
+
let key = "";
|
|
1652
|
+
if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code))) {
|
|
1653
|
+
key = onKeyDown(e);
|
|
1654
|
+
if (key === "ArrowRight" || key === "ArrowLeft") {
|
|
1655
|
+
closeMenu();
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
let flag = false;
|
|
1659
|
+
if (!key) {
|
|
1660
|
+
if (e.code === "F9") {
|
|
1661
|
+
handleAdd();
|
|
1662
|
+
flag = true;
|
|
1663
|
+
} else if (e.code === "Escape" || e.code === "Space") {
|
|
1664
|
+
if (dropdownOpen) {
|
|
1665
|
+
onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
|
|
1666
|
+
}
|
|
1667
|
+
if (!searchTerm) {
|
|
1668
|
+
handleOpenClose();
|
|
1669
|
+
flag = true;
|
|
1670
|
+
}
|
|
1671
|
+
} else if (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter") {
|
|
1672
|
+
if (dropdownOpen) {
|
|
1673
|
+
onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
|
|
1674
|
+
handleOpenClose();
|
|
1675
|
+
flag = true;
|
|
1676
|
+
}
|
|
1677
|
+
} else if (e.code === "ArrowDown") {
|
|
1678
|
+
if (dropdownOpen) {
|
|
1679
|
+
let newIndex = 0;
|
|
1680
|
+
if (indexFocus >= 0) {
|
|
1681
|
+
newIndex = indexFocus + 1;
|
|
1682
|
+
} else if (value) {
|
|
1683
|
+
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((e2) => e2[fieldValue ?? "value"] === value[fieldValue ?? "value"]) + 1;
|
|
1684
|
+
}
|
|
1685
|
+
if (newIndex < (optionsLoad ? optionsLoad : options).length) {
|
|
1686
|
+
setIndexFocus(newIndex);
|
|
1687
|
+
checkIfElementIsOutOfScroll(0);
|
|
1688
|
+
} else {
|
|
1689
|
+
setIndexFocus(0);
|
|
1690
|
+
checkIfElementIsOutOfScroll(1);
|
|
1691
|
+
}
|
|
1692
|
+
flag = true;
|
|
1693
|
+
} else {
|
|
1694
|
+
handleOpenClose();
|
|
1695
|
+
flag = true;
|
|
1696
|
+
}
|
|
1697
|
+
} else if (e.code === "ArrowUp") {
|
|
1698
|
+
if (dropdownOpen) {
|
|
1699
|
+
let newIndex = 0;
|
|
1700
|
+
if (indexFocus >= 0) {
|
|
1701
|
+
newIndex = indexFocus - 1;
|
|
1702
|
+
} else if (value) {
|
|
1703
|
+
newIndex = (optionsLoad ? optionsLoad : options)?.findIndex((e2) => e2[fieldValue ?? "value"] === value[fieldValue ?? "value"]) - 1;
|
|
1704
|
+
}
|
|
1705
|
+
if (newIndex >= 0) {
|
|
1706
|
+
setIndexFocus(newIndex);
|
|
1707
|
+
checkIfElementIsOutOfScroll(2);
|
|
1708
|
+
} else {
|
|
1709
|
+
setIndexFocus((optionsLoad ? optionsLoad : options).length - 1);
|
|
1710
|
+
checkIfElementIsOutOfScroll(3);
|
|
1711
|
+
}
|
|
1712
|
+
flag = true;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
if (flag) {
|
|
1717
|
+
e.stopPropagation();
|
|
1718
|
+
e.preventDefault();
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
const checkIfElementIsOutOfScroll = (flag) => {
|
|
1722
|
+
if (selectMenuTableRef) {
|
|
1723
|
+
const elementFocus = document.getElementById(`row-select-table-${indexFocus}`);
|
|
1724
|
+
if (elementFocus) {
|
|
1725
|
+
const rect = elementFocus.getBoundingClientRect();
|
|
1726
|
+
const parentRect = selectMenuTableRef.current?.getBoundingClientRect();
|
|
1727
|
+
if (flag === 1) {
|
|
1728
|
+
scrollToElement(selectMenuTableRef.current, 0);
|
|
1729
|
+
} else if (flag === 3) {
|
|
1730
|
+
scrollToElement(selectMenuTableRef.current, selectMenuTableRef.current.scrollHeight);
|
|
1731
|
+
} else if (flag === 0 && rect.bottom + 30 > parentRect.bottom) {
|
|
1732
|
+
scrollToElement(selectMenuTableRef.current, elementFocus.offsetTop - selectMenuTableRef.current.offsetTop - parentRect.height + rect.height + 50);
|
|
1733
|
+
} else if (flag === 2 && rect.top < parentRect.top + 50) {
|
|
1734
|
+
scrollToElement(selectMenuTableRef.current, elementFocus.offsetTop - 65);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
let timeOutElement;
|
|
1740
|
+
const scrollToElement = (elemment, top) => {
|
|
1741
|
+
clearTimeout(timeOutElement);
|
|
1742
|
+
timeOutElement = setTimeout(() => {
|
|
1743
|
+
elemment.scrollTo({
|
|
1744
|
+
top
|
|
1745
|
+
});
|
|
1746
|
+
}, 100);
|
|
1747
|
+
};
|
|
1748
|
+
const renderHeaderCol = (col, indexCol) => {
|
|
1749
|
+
return /* @__PURE__ */ jsx13(
|
|
1750
|
+
Fragment13,
|
|
1751
|
+
{
|
|
1752
|
+
children: col.visible !== false && /* @__PURE__ */ jsx13(
|
|
1753
|
+
"th",
|
|
1754
|
+
{
|
|
1755
|
+
className: classnames6(
|
|
1756
|
+
`r-select-headercell fix-${col.fixedType}`,
|
|
1757
|
+
{ "cell-fixed": col.fixedType }
|
|
1758
|
+
),
|
|
1759
|
+
style: {
|
|
1760
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
1761
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
1762
|
+
top: `${0 * 35}px`,
|
|
1763
|
+
maxWidth: col.maxWidth
|
|
1764
|
+
},
|
|
1765
|
+
children: /* @__PURE__ */ jsx13(
|
|
1766
|
+
"div",
|
|
1767
|
+
{
|
|
1768
|
+
role: "textbox",
|
|
1769
|
+
title: t(col.headerText ?? ""),
|
|
1770
|
+
style: {
|
|
1771
|
+
height: `${1 * 35}px`,
|
|
1772
|
+
justifyContent: col.textAlign ?? "left"
|
|
1773
|
+
},
|
|
1774
|
+
className: "r-select-headercell-div",
|
|
1775
|
+
children: t(col.headerText ?? "")
|
|
1776
|
+
}
|
|
1777
|
+
)
|
|
1778
|
+
}
|
|
1779
|
+
)
|
|
1780
|
+
},
|
|
1781
|
+
`header-select-${indexCol}`
|
|
1782
|
+
);
|
|
1783
|
+
};
|
|
1784
|
+
const checkSearch = (keyword, data, columnsSearch) => {
|
|
1785
|
+
if (!keyword || columnsSearch.length === 0) {
|
|
1786
|
+
return true;
|
|
1787
|
+
}
|
|
1788
|
+
for (let index = 0; index < columnsSearch.length; index++) {
|
|
1789
|
+
const key = columnsSearch[index].field.trim();
|
|
1790
|
+
if (data[key] && data[key].toString().trim().toLowerCase().includes(keyword.trim().toLowerCase())) {
|
|
1791
|
+
return true;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return false;
|
|
1795
|
+
};
|
|
1796
|
+
const callbackLoadOption = (rs) => {
|
|
1797
|
+
setOptionsLoad(rs);
|
|
1798
|
+
};
|
|
1799
|
+
useEffect7(() => {
|
|
1800
|
+
if (!searchTerm) {
|
|
1801
|
+
setOptionsLoad(void 0);
|
|
1802
|
+
}
|
|
1803
|
+
}, [searchTerm]);
|
|
1804
|
+
const checkOverflow = (element) => {
|
|
1805
|
+
return element && element.scrollWidth > element.clientWidth;
|
|
1806
|
+
};
|
|
1807
|
+
return /* @__PURE__ */ jsx13(
|
|
1808
|
+
"div",
|
|
1809
|
+
{
|
|
1810
|
+
className: "react-select-table",
|
|
1811
|
+
ref,
|
|
1812
|
+
id,
|
|
1813
|
+
children: /* @__PURE__ */ jsx13("div", { ref: selectTableRef, children: /* @__PURE__ */ jsxs12(
|
|
1814
|
+
Dropdown2,
|
|
1815
|
+
{
|
|
1816
|
+
isOpen: dropdownOpen,
|
|
1817
|
+
toggle: () => {
|
|
1818
|
+
},
|
|
1819
|
+
children: [
|
|
1820
|
+
/* @__PURE__ */ jsxs12(
|
|
1821
|
+
DropdownToggle2,
|
|
1822
|
+
{
|
|
1823
|
+
onClick: () => {
|
|
1824
|
+
inputRef?.current.focus();
|
|
1825
|
+
clearTimeout(timeOutBlur);
|
|
1826
|
+
handleOpenClose();
|
|
1827
|
+
},
|
|
1828
|
+
tabIndex: 0,
|
|
1829
|
+
tag: "div",
|
|
1830
|
+
className: classnames6("select-table-control", { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
|
|
1831
|
+
children: [
|
|
1832
|
+
/* @__PURE__ */ jsxs12("div", { className: "select-table-container", children: [
|
|
1833
|
+
isMulti ? /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsx13("div", { className: classnames6("select-value is-mutil", { "d-none": searchTerm }), children: value?.map((ele, index) => {
|
|
1834
|
+
return /* @__PURE__ */ jsxs12("span", { children: [
|
|
1835
|
+
index === 0 ? "" : ", ",
|
|
1836
|
+
ele[fieldLabel ?? "label"]
|
|
1837
|
+
] }, index);
|
|
1838
|
+
}) }) }) : /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsxs12("div", { className: classnames6("select-value", { "d-none": searchTerm }), children: [
|
|
1839
|
+
value ? value[fieldLabel ?? "label"] : "",
|
|
1840
|
+
" "
|
|
1841
|
+
] }) }),
|
|
1842
|
+
/* @__PURE__ */ jsx13("div", { className: classnames6("select-placeholder", { "d-none": (isMulti ? value?.length > 0 : value) || searchTerm }), children: placeholder }),
|
|
1843
|
+
/* @__PURE__ */ jsx13("div", { className: "input-container", children: /* @__PURE__ */ jsx13(
|
|
1844
|
+
"input",
|
|
1845
|
+
{
|
|
1846
|
+
style: { textAlign: textAlign ?? "left" },
|
|
1847
|
+
ref: inputRef,
|
|
1848
|
+
className: classnames6("select-input"),
|
|
1849
|
+
value: searchTerm,
|
|
1850
|
+
onChange: (val) => {
|
|
1851
|
+
if (loadOptions && val.target.value) {
|
|
1852
|
+
loadOptions(val.target.value, callbackLoadOption);
|
|
1853
|
+
}
|
|
1854
|
+
setSearchTerm(val.target.value);
|
|
1855
|
+
},
|
|
1856
|
+
onKeyDown: (e) => handleOnKeyDown(e)
|
|
1857
|
+
}
|
|
1858
|
+
) })
|
|
1859
|
+
] }),
|
|
1860
|
+
/* @__PURE__ */ jsx13(
|
|
1861
|
+
"div",
|
|
1862
|
+
{
|
|
1863
|
+
className: classnames6("select-table-indicator cursor-pointer", { "d-none": !isClearable || !value }),
|
|
1864
|
+
onClick: (e) => {
|
|
1865
|
+
onChange(isMulti ? [] : void 0);
|
|
1866
|
+
e.stopPropagation();
|
|
1867
|
+
},
|
|
1868
|
+
children: /* @__PURE__ */ jsx13("svg", { height: "20", width: "20", style: { color: "#c4c4c4" }, viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ jsx13("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" }) })
|
|
1869
|
+
}
|
|
1870
|
+
),
|
|
1871
|
+
/* @__PURE__ */ jsx13("div", { className: "select-table-indicator", children: /* @__PURE__ */ jsx13("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__ */ jsx13("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" }) }) })
|
|
1872
|
+
]
|
|
1873
|
+
}
|
|
1874
|
+
),
|
|
1875
|
+
/* @__PURE__ */ jsx13(
|
|
1876
|
+
DropdownMenu2,
|
|
1877
|
+
{
|
|
1878
|
+
container: component,
|
|
1879
|
+
className: "formula-dropdown icon-dropdown p-0",
|
|
1880
|
+
style: {
|
|
1881
|
+
width: menuWidth ? menuWidth : "min-content",
|
|
1882
|
+
position: "fixed",
|
|
1883
|
+
zIndex: 9999
|
|
1884
|
+
},
|
|
1885
|
+
children: /* @__PURE__ */ jsx13(DropdownItem2, { className: classnames6("p-0 menu-select-table"), style: { borderRadius: "6px" }, tag: "div", header: true, children: /* @__PURE__ */ jsx13(
|
|
1886
|
+
"div",
|
|
1887
|
+
{
|
|
1888
|
+
onMouseDown: (e) => {
|
|
1889
|
+
inputRef?.current.focus();
|
|
1890
|
+
clearTimeout(timeOutBlur);
|
|
1891
|
+
e.preventDefault();
|
|
1892
|
+
},
|
|
1893
|
+
children: /* @__PURE__ */ jsxs12("div", { className: "r-select-grid", children: [
|
|
1894
|
+
/* @__PURE__ */ jsx13("div", { className: "r-select-gridtable", ref: selectMenuTableRef, style: { maxHeight: maxHeight ?? defaultMaxHeight }, children: /* @__PURE__ */ jsxs12("table", { style: { width: "100%" }, children: [
|
|
1895
|
+
/* @__PURE__ */ jsx13("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ jsxs12("tr", { className: "r-select-row", role: "row", children: [
|
|
1896
|
+
isMulti && /* @__PURE__ */ jsx13("th", { className: classnames6(`r-select-headercell`), style: { width: 40, top: `0px` }, children: /* @__PURE__ */ jsx13(
|
|
1897
|
+
"div",
|
|
1898
|
+
{
|
|
1899
|
+
style: { justifyContent: "center" },
|
|
1900
|
+
className: classnames6("r-select-headercell-div"),
|
|
1901
|
+
children: /* @__PURE__ */ jsx13(
|
|
1902
|
+
Input6,
|
|
1903
|
+
{
|
|
1904
|
+
checked: (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length,
|
|
1905
|
+
type: "checkbox",
|
|
1906
|
+
className: classnames6("cursor-pointer", { "d-none": !isMulti }),
|
|
1907
|
+
style: { textAlign: "center", marginTop: 6 },
|
|
1908
|
+
onChange: (e) => {
|
|
1909
|
+
if (isMulti) {
|
|
1910
|
+
if (e.target.checked) {
|
|
1911
|
+
onChange((optionsLoad ? optionsLoad : options).map((item) => {
|
|
1912
|
+
return item;
|
|
1913
|
+
}));
|
|
1914
|
+
} else {
|
|
1915
|
+
onChange([]);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
)
|
|
1921
|
+
}
|
|
1922
|
+
) }),
|
|
1923
|
+
(columns ? columns : defaultColumns).map((col, index) => {
|
|
1924
|
+
return renderHeaderCol(col, index);
|
|
1925
|
+
})
|
|
1926
|
+
] }) }),
|
|
1927
|
+
(optionsLoad ? optionsLoad : options).length > 0 ? /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsx13("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
|
|
1928
|
+
if (loadOptions || checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
|
|
1929
|
+
const refRow = useRef2(null);
|
|
1930
|
+
const isSelected = isMulti && value?.some((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
|
|
1931
|
+
return /* @__PURE__ */ jsxs12(
|
|
1932
|
+
"tr",
|
|
1933
|
+
{
|
|
1934
|
+
id: `row-select-table-${indexRow}`,
|
|
1935
|
+
className: classnames6("r-select-row", { "last-row": indexRow === (optionsLoad ? optionsLoad : options).length - 1 }, { "fisrt-row": indexRow === 0 }),
|
|
1936
|
+
children: [
|
|
1937
|
+
isMulti && /* @__PURE__ */ jsx13(
|
|
1938
|
+
"td",
|
|
1939
|
+
{
|
|
1940
|
+
className: classnames6(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
|
|
1941
|
+
style: { width: 40, textAlign: "center", padding: 0, paddingBottom: 6 },
|
|
1942
|
+
onClick: (e) => {
|
|
1943
|
+
if (isMulti) {
|
|
1944
|
+
const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
|
|
1945
|
+
if (index > -1) {
|
|
1946
|
+
value?.splice(index, 1);
|
|
1947
|
+
onChange(value);
|
|
1948
|
+
} else {
|
|
1949
|
+
if (value) {
|
|
1950
|
+
value?.push(row);
|
|
1951
|
+
onChange(value);
|
|
1952
|
+
} else {
|
|
1953
|
+
onChange([row]);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
e.stopPropagation();
|
|
1957
|
+
}
|
|
1958
|
+
},
|
|
1959
|
+
children: /* @__PURE__ */ jsx13(
|
|
1960
|
+
Input6,
|
|
1961
|
+
{
|
|
1962
|
+
checked: isSelected,
|
|
1963
|
+
type: "checkbox",
|
|
1964
|
+
className: "cursor-pointer",
|
|
1965
|
+
onChange: () => {
|
|
1966
|
+
},
|
|
1967
|
+
style: { textAlign: "center", marginTop: 6 }
|
|
1968
|
+
}
|
|
1969
|
+
)
|
|
1970
|
+
}
|
|
1971
|
+
),
|
|
1972
|
+
(columns ? columns : defaultColumns).map((col, indexCol) => {
|
|
1973
|
+
let valueDisplay = row[col.field];
|
|
1974
|
+
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
1975
|
+
valueDisplay = formartNumberic(row[col.field], decimalSeparator ?? ".", thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
|
|
1976
|
+
} else if (col.type === "date") {
|
|
1977
|
+
valueDisplay = valueDisplay ? moment(valueDisplay).format("DD/MM/yyyy") : "";
|
|
1978
|
+
} else if (col.type === "datetime") {
|
|
1979
|
+
valueDisplay = valueDisplay ? moment(valueDisplay).format("DD/MM/yyyy HH:mm") : "";
|
|
1980
|
+
}
|
|
1981
|
+
return /* @__PURE__ */ jsxs12(Fragment13, { children: [
|
|
1982
|
+
col.visible !== false && /* @__PURE__ */ jsx13(
|
|
1983
|
+
"td",
|
|
1984
|
+
{
|
|
1985
|
+
id: `content-select-${indexRow}-${indexCol}`,
|
|
1986
|
+
ref: refRow,
|
|
1987
|
+
className: classnames6(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
|
|
1988
|
+
style: {
|
|
1989
|
+
minWidth: col.minWidth,
|
|
1990
|
+
width: col.width,
|
|
1991
|
+
maxWidth: col.maxWidth,
|
|
1992
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
1993
|
+
},
|
|
1994
|
+
onClick: (e) => {
|
|
1995
|
+
if (isMulti) {
|
|
1996
|
+
const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
|
|
1997
|
+
if (index > -1) {
|
|
1998
|
+
value?.splice(index, 1);
|
|
1999
|
+
onChange(value);
|
|
2000
|
+
} else {
|
|
2001
|
+
if (value) {
|
|
2002
|
+
value?.push(row);
|
|
2003
|
+
onChange(value);
|
|
2004
|
+
} else {
|
|
2005
|
+
onChange([row]);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
} else {
|
|
2009
|
+
onChange(row);
|
|
2010
|
+
closeMenu();
|
|
2011
|
+
}
|
|
2012
|
+
e.preventDefault();
|
|
2013
|
+
e.stopPropagation();
|
|
2014
|
+
},
|
|
2015
|
+
onMouseMove: (e) => {
|
|
2016
|
+
if (indexRow !== indexFocus) {
|
|
2017
|
+
setIndexFocus(indexRow);
|
|
2018
|
+
}
|
|
2019
|
+
e.stopPropagation();
|
|
2020
|
+
},
|
|
2021
|
+
children: col.template ? col.template(row, indexRow) : valueDisplay
|
|
2022
|
+
},
|
|
2023
|
+
`col-${indexRow}-${indexCol}`
|
|
2024
|
+
),
|
|
2025
|
+
checkOverflow(refRow.current) && /* @__PURE__ */ jsx13(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-select-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : valueDisplay })
|
|
2026
|
+
] }, indexCol);
|
|
2027
|
+
})
|
|
2028
|
+
]
|
|
2029
|
+
},
|
|
2030
|
+
`row-${indexRow}`
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
}) }) }) : /* @__PURE__ */ jsx13("div", { className: "r-no-data", children: t("No data available.") })
|
|
2034
|
+
] }) }),
|
|
2035
|
+
/* @__PURE__ */ jsx13("div", { className: "r-select-footer", children: /* @__PURE__ */ jsxs12(Button3, { outline: true, color: "primary", className: "r-btn-add d-flex align-items-center", onClick: handleAdd, children: [
|
|
2036
|
+
/* @__PURE__ */ jsx13(Plus2, { className: "me-50", fontSize: 16 }),
|
|
2037
|
+
t("AddNew"),
|
|
2038
|
+
" (F9)"
|
|
2039
|
+
] }) })
|
|
2040
|
+
] })
|
|
2041
|
+
}
|
|
2042
|
+
) })
|
|
2043
|
+
}
|
|
2044
|
+
)
|
|
2045
|
+
]
|
|
2046
|
+
}
|
|
2047
|
+
) })
|
|
2048
|
+
}
|
|
2049
|
+
);
|
|
2050
|
+
});
|
|
2051
|
+
var select_table_default = SelectTable;
|
|
2052
|
+
|
|
2053
|
+
// test-app/src/component/table/index.tsx
|
|
2054
|
+
import { Fragment as Fragment16, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2055
|
+
var TableEdit = forwardRef3((props, ref) => {
|
|
2056
|
+
const { t } = useTranslation10();
|
|
1506
2057
|
const {
|
|
1507
2058
|
idTable,
|
|
1508
2059
|
dataSource,
|
|
@@ -1535,31 +2086,31 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1535
2086
|
refeshFocusRow: handleRefeshRow
|
|
1536
2087
|
};
|
|
1537
2088
|
});
|
|
1538
|
-
const [refreshRow, setRefreshRow] =
|
|
1539
|
-
const [indexFocus, setIndexFocus] =
|
|
1540
|
-
const [selectedRows, setSelectedRows] =
|
|
1541
|
-
const [headerColumns, setHeaderColumns] =
|
|
1542
|
-
const [contentColumns, setContentColumns] =
|
|
1543
|
-
const [levelCol, setLevelCol] =
|
|
1544
|
-
const [columnFistEdit, setColumnFistEdit] =
|
|
1545
|
-
const [columnLastEdit, setColumnlastEdit] =
|
|
1546
|
-
const [objWidthFix, setObjWidthFix] =
|
|
1547
|
-
const [openPopupTree, setOpenPopupTree] =
|
|
1548
|
-
const [openPopupSetupColumn, setOpenPopupSetupColumn] =
|
|
1549
|
-
const [searchTerm, setSearchTerm] =
|
|
1550
|
-
const tableElement =
|
|
1551
|
-
const gridRef =
|
|
2089
|
+
const [refreshRow, setRefreshRow] = useState7(false);
|
|
2090
|
+
const [indexFocus, setIndexFocus] = useState7();
|
|
2091
|
+
const [selectedRows, setSelectedRows] = useState7([]);
|
|
2092
|
+
const [headerColumns, setHeaderColumns] = useState7([[]]);
|
|
2093
|
+
const [contentColumns, setContentColumns] = useState7([]);
|
|
2094
|
+
const [levelCol, setLevelCol] = useState7(0);
|
|
2095
|
+
const [columnFistEdit, setColumnFistEdit] = useState7(0);
|
|
2096
|
+
const [columnLastEdit, setColumnlastEdit] = useState7(0);
|
|
2097
|
+
const [objWidthFix, setObjWidthFix] = useState7({});
|
|
2098
|
+
const [openPopupTree, setOpenPopupTree] = useState7(false);
|
|
2099
|
+
const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState7(false);
|
|
2100
|
+
const [searchTerm, setSearchTerm] = useState7("");
|
|
2101
|
+
const tableElement = useRef3(null);
|
|
2102
|
+
const gridRef = useRef3();
|
|
1552
2103
|
let totalCount = dataSource.length;
|
|
1553
2104
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
1554
2105
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
1555
2106
|
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
1556
2107
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
1557
|
-
|
|
2108
|
+
useEffect8(() => {
|
|
1558
2109
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
1559
2110
|
pagingSetting.setCurrentPage(1);
|
|
1560
2111
|
}
|
|
1561
2112
|
}, [dataSource]);
|
|
1562
|
-
|
|
2113
|
+
useEffect8(() => {
|
|
1563
2114
|
let indexFirst = -1;
|
|
1564
2115
|
let indexlast = -1;
|
|
1565
2116
|
let letfWidthFix = 0;
|
|
@@ -1592,7 +2143,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1592
2143
|
setColumnFistEdit(indexFirst + 1);
|
|
1593
2144
|
setColumnlastEdit(indexlast + 1);
|
|
1594
2145
|
}, [contentColumns]);
|
|
1595
|
-
|
|
2146
|
+
useEffect8(() => {
|
|
1596
2147
|
const arrHeaderColumns = [];
|
|
1597
2148
|
const arrContentColumns = [];
|
|
1598
2149
|
let headerLevelRow = 0;
|
|
@@ -1609,7 +2160,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1609
2160
|
setHeaderColumns(arrHeaderColumns);
|
|
1610
2161
|
setContentColumns(arrContentColumns);
|
|
1611
2162
|
}, [columns]);
|
|
1612
|
-
|
|
2163
|
+
useEffect8(() => {
|
|
1613
2164
|
const arrHeaderColumns = [];
|
|
1614
2165
|
const arrContentColumns = [];
|
|
1615
2166
|
let headerLevelRow = 0;
|
|
@@ -1720,7 +2271,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1720
2271
|
}
|
|
1721
2272
|
};
|
|
1722
2273
|
const searchTemplate = () => {
|
|
1723
|
-
return /* @__PURE__ */
|
|
2274
|
+
return /* @__PURE__ */ jsx14(Fragment15, { children: /* @__PURE__ */ jsx14("div", { className: "me-50 r-search", children: /* @__PURE__ */ jsx14(
|
|
1724
2275
|
react_input_default,
|
|
1725
2276
|
{
|
|
1726
2277
|
style: { width: "230px" },
|
|
@@ -1741,12 +2292,12 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1741
2292
|
const renderEdit = (row, col, indexRow, indexCol) => {
|
|
1742
2293
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
1743
2294
|
case "date":
|
|
1744
|
-
return /* @__PURE__ */
|
|
1745
|
-
|
|
2295
|
+
return /* @__PURE__ */ jsx14(
|
|
2296
|
+
Input7,
|
|
1746
2297
|
{
|
|
1747
2298
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1748
2299
|
style: { textAlign: col.textAlign, height: 29 },
|
|
1749
|
-
value: row[col.field] ?
|
|
2300
|
+
value: row[col.field] ? moment2(row[col.field]).format("yyyy-MM-DD") : row[col.field],
|
|
1750
2301
|
onChange: (val) => {
|
|
1751
2302
|
row[col.field] = val.target.value;
|
|
1752
2303
|
if (col.callback) {
|
|
@@ -1754,7 +2305,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1754
2305
|
}
|
|
1755
2306
|
handleDataChange(row, col, indexRow);
|
|
1756
2307
|
},
|
|
1757
|
-
className:
|
|
2308
|
+
className: classnames7("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1758
2309
|
type: "date",
|
|
1759
2310
|
max: "9999-12-31",
|
|
1760
2311
|
onKeyDown: (e) => {
|
|
@@ -1764,12 +2315,12 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1764
2315
|
}
|
|
1765
2316
|
);
|
|
1766
2317
|
case "datetime":
|
|
1767
|
-
return /* @__PURE__ */
|
|
1768
|
-
|
|
2318
|
+
return /* @__PURE__ */ jsx14(
|
|
2319
|
+
Input7,
|
|
1769
2320
|
{
|
|
1770
2321
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1771
2322
|
style: { textAlign: col.textAlign, height: 29 },
|
|
1772
|
-
value: row[col.field] ?
|
|
2323
|
+
value: row[col.field] ? moment2(row[col.field]).format("yyyy-MM-DD HH:MM") : row[col.field],
|
|
1773
2324
|
onChange: (val) => {
|
|
1774
2325
|
row[col.field] = val.target.value;
|
|
1775
2326
|
if (col.callback) {
|
|
@@ -1777,7 +2328,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1777
2328
|
}
|
|
1778
2329
|
handleDataChange(row, col, indexRow);
|
|
1779
2330
|
},
|
|
1780
|
-
className:
|
|
2331
|
+
className: classnames7("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1781
2332
|
type: "datetime-local",
|
|
1782
2333
|
max: "9999-12-31T23:59",
|
|
1783
2334
|
onKeyDown: (e) => {
|
|
@@ -1797,8 +2348,8 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1797
2348
|
if (!valueAsyncSelect && col.selectSettings?.defaultValue) {
|
|
1798
2349
|
valueAsyncSelect = col.selectSettings?.defaultValue(row);
|
|
1799
2350
|
}
|
|
1800
|
-
return /* @__PURE__ */
|
|
1801
|
-
/* @__PURE__ */
|
|
2351
|
+
return /* @__PURE__ */ jsxs13("div", { className: classnames7("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
|
|
2352
|
+
/* @__PURE__ */ jsx14(
|
|
1802
2353
|
AsyncSelect,
|
|
1803
2354
|
{
|
|
1804
2355
|
menuPosition: "fixed",
|
|
@@ -1817,23 +2368,23 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1817
2368
|
placeholder: t("Select"),
|
|
1818
2369
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1819
2370
|
loadOptions: col.selectSettings?.loadOptions,
|
|
1820
|
-
className:
|
|
2371
|
+
className: classnames7("react-select"),
|
|
1821
2372
|
onKeyDown: (e) => {
|
|
1822
2373
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
1823
2374
|
}
|
|
1824
2375
|
}
|
|
1825
2376
|
}
|
|
1826
2377
|
),
|
|
1827
|
-
/* @__PURE__ */
|
|
2378
|
+
/* @__PURE__ */ jsx14(
|
|
1828
2379
|
"span",
|
|
1829
2380
|
{
|
|
1830
2381
|
onClick: () => {
|
|
1831
|
-
if (col.selectSettings?.
|
|
1832
|
-
col.selectSettings?.
|
|
2382
|
+
if (col.selectSettings?.handAddNew) {
|
|
2383
|
+
col.selectSettings?.handAddNew("right");
|
|
1833
2384
|
}
|
|
1834
2385
|
},
|
|
1835
|
-
className:
|
|
1836
|
-
children: /* @__PURE__ */
|
|
2386
|
+
className: classnames7("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
|
|
2387
|
+
children: /* @__PURE__ */ jsx14(icon_default, { iconName: col.selectSettings?.iconGroup ?? "", size: 16 })
|
|
1837
2388
|
}
|
|
1838
2389
|
)
|
|
1839
2390
|
] });
|
|
@@ -1850,7 +2401,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1850
2401
|
} else {
|
|
1851
2402
|
valueSelect = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? options?.find((val) => val[col.selectSettings?.fieldValue ?? "value"] === row[col.field]) : "";
|
|
1852
2403
|
}
|
|
1853
|
-
return /* @__PURE__ */
|
|
2404
|
+
return /* @__PURE__ */ jsx14(
|
|
1854
2405
|
Select3,
|
|
1855
2406
|
{
|
|
1856
2407
|
menuPosition: "fixed",
|
|
@@ -1869,7 +2420,56 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1869
2420
|
isClearable: col.selectSettings?.isClearable ?? false,
|
|
1870
2421
|
classNamePrefix: col.selectSettings?.widthPopup ? `select-${col.selectSettings?.widthPopup}` : "select",
|
|
1871
2422
|
placeholder: t("Select"),
|
|
1872
|
-
className:
|
|
2423
|
+
className: classnames7("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2424
|
+
onKeyDown: (e) => {
|
|
2425
|
+
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
);
|
|
2430
|
+
case "selectTable":
|
|
2431
|
+
let valueSelectTable;
|
|
2432
|
+
let optionsSelectTable = [];
|
|
2433
|
+
if (col.selectSettings?.optionsField) {
|
|
2434
|
+
optionsSelectTable = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
2435
|
+
} else {
|
|
2436
|
+
optionsSelectTable = col.selectSettings?.options ? col.selectSettings?.validateOption ? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row)) : col.selectSettings?.options : [];
|
|
2437
|
+
}
|
|
2438
|
+
if (col.selectSettings?.isMulti) {
|
|
2439
|
+
valueSelectTable = !isNullOrUndefined(row[col.field]) && row[col.field]?.length > 0 ? optionsSelectTable?.filter((val) => row[col.field]?.includes(val[col.selectSettings?.fieldValue ?? "value"])) : [];
|
|
2440
|
+
} else {
|
|
2441
|
+
valueSelectTable = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? optionsSelectTable?.find((val) => val[col.selectSettings?.fieldValue ?? "value"] === row[col.field]) : "";
|
|
2442
|
+
}
|
|
2443
|
+
return /* @__PURE__ */ jsx14(
|
|
2444
|
+
select_table_default,
|
|
2445
|
+
{
|
|
2446
|
+
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2447
|
+
value: valueSelectTable,
|
|
2448
|
+
options: optionsSelectTable,
|
|
2449
|
+
rowData: row,
|
|
2450
|
+
onChange: (val) => {
|
|
2451
|
+
row[col.field] = col.selectSettings?.isMulti ? val?.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) ?? [] : val ? val[col.selectSettings?.fieldValue ?? "value"] : void 0;
|
|
2452
|
+
if (col.callback) {
|
|
2453
|
+
col.callback(val, indexRow);
|
|
2454
|
+
}
|
|
2455
|
+
handleDataChange(row, col, indexRow);
|
|
2456
|
+
},
|
|
2457
|
+
fieldValue: col.selectSettings?.fieldValue,
|
|
2458
|
+
fieldLabel: col.selectSettings?.fieldLabel,
|
|
2459
|
+
component: tableElement,
|
|
2460
|
+
columns: col.selectSettings?.columns,
|
|
2461
|
+
isClearable: col.selectSettings?.isClearable ?? false,
|
|
2462
|
+
decimalSeparator,
|
|
2463
|
+
thousandSeparator,
|
|
2464
|
+
placeholder: t("Select"),
|
|
2465
|
+
loadOptions: col.selectSettings?.loadOptions,
|
|
2466
|
+
field: col.field,
|
|
2467
|
+
handleAdd: col.selectSettings?.handAddNew,
|
|
2468
|
+
isMulti: col.selectSettings?.isMulti,
|
|
2469
|
+
invalid: col.validate && col.validate(row[col.field], row),
|
|
2470
|
+
maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : void 0,
|
|
2471
|
+
menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : void 0,
|
|
2472
|
+
textAlign: col.textAlign ?? "left",
|
|
1873
2473
|
onKeyDown: (e) => {
|
|
1874
2474
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
1875
2475
|
}
|
|
@@ -1891,14 +2491,14 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1891
2491
|
}
|
|
1892
2492
|
}
|
|
1893
2493
|
};
|
|
1894
|
-
return /* @__PURE__ */
|
|
2494
|
+
return /* @__PURE__ */ jsx14(
|
|
1895
2495
|
"div",
|
|
1896
2496
|
{
|
|
1897
2497
|
onKeyDown: (e) => {
|
|
1898
2498
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
1899
2499
|
}
|
|
1900
2500
|
},
|
|
1901
|
-
children: /* @__PURE__ */
|
|
2501
|
+
children: /* @__PURE__ */ jsx14(
|
|
1902
2502
|
DropDownTreeComponent,
|
|
1903
2503
|
{
|
|
1904
2504
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -1909,7 +2509,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1909
2509
|
parentValue: "parentId",
|
|
1910
2510
|
child: "children"
|
|
1911
2511
|
},
|
|
1912
|
-
className:
|
|
2512
|
+
className: classnames7("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1913
2513
|
allowFiltering: false,
|
|
1914
2514
|
value: valueSelectTree,
|
|
1915
2515
|
popupHeight: 250,
|
|
@@ -1937,8 +2537,8 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1937
2537
|
}
|
|
1938
2538
|
);
|
|
1939
2539
|
case "checkbox":
|
|
1940
|
-
return /* @__PURE__ */
|
|
1941
|
-
|
|
2540
|
+
return /* @__PURE__ */ jsx14(
|
|
2541
|
+
Input7,
|
|
1942
2542
|
{
|
|
1943
2543
|
checked: row[col.field],
|
|
1944
2544
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -1960,13 +2560,13 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1960
2560
|
);
|
|
1961
2561
|
case "numeric":
|
|
1962
2562
|
let valueCurrency = row[col.field];
|
|
1963
|
-
return /* @__PURE__ */
|
|
1964
|
-
|
|
2563
|
+
return /* @__PURE__ */ jsx14(
|
|
2564
|
+
Input7,
|
|
1965
2565
|
{
|
|
1966
2566
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
1967
2567
|
style: { textAlign: col.textAlign, height: 29 },
|
|
1968
2568
|
defaultValue: formartNumberic(valueCurrency, decimalSeparator, thousandSeparator, col.numericSettings?.fraction),
|
|
1969
|
-
className:
|
|
2569
|
+
className: classnames7("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
1970
2570
|
onChange: (val) => {
|
|
1971
2571
|
let newVal = "";
|
|
1972
2572
|
const flag = val.target?.value.startsWith("-");
|
|
@@ -2050,8 +2650,8 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2050
2650
|
}
|
|
2051
2651
|
);
|
|
2052
2652
|
case "color":
|
|
2053
|
-
return /* @__PURE__ */
|
|
2054
|
-
|
|
2653
|
+
return /* @__PURE__ */ jsx14("div", { style: { padding: "4px 8px" }, children: /* @__PURE__ */ jsx14(
|
|
2654
|
+
Input7,
|
|
2055
2655
|
{
|
|
2056
2656
|
type: "color",
|
|
2057
2657
|
value: row[col.field],
|
|
@@ -2073,7 +2673,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2073
2673
|
`col-${indexRow}-${indexCol}`
|
|
2074
2674
|
) });
|
|
2075
2675
|
case "form":
|
|
2076
|
-
return /* @__PURE__ */
|
|
2676
|
+
return /* @__PURE__ */ jsx14(
|
|
2077
2677
|
edit_form_default,
|
|
2078
2678
|
{
|
|
2079
2679
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -2095,13 +2695,13 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2095
2695
|
}
|
|
2096
2696
|
);
|
|
2097
2697
|
default:
|
|
2098
|
-
return /* @__PURE__ */
|
|
2099
|
-
|
|
2698
|
+
return /* @__PURE__ */ jsx14(
|
|
2699
|
+
Input7,
|
|
2100
2700
|
{
|
|
2101
2701
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2102
2702
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2103
2703
|
defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
|
|
2104
|
-
className:
|
|
2704
|
+
className: classnames7("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2105
2705
|
onBlur: (val) => {
|
|
2106
2706
|
if (row[col.field] != val.target?.value) {
|
|
2107
2707
|
row[col.field] = val.target?.value;
|
|
@@ -2139,14 +2739,14 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2139
2739
|
}
|
|
2140
2740
|
};
|
|
2141
2741
|
const renderCommand = (commandItems, rowData, i) => {
|
|
2142
|
-
return /* @__PURE__ */
|
|
2143
|
-
return /* @__PURE__ */
|
|
2144
|
-
|
|
2742
|
+
return /* @__PURE__ */ jsx14(Fragment15, { children: /* @__PURE__ */ jsx14("div", { className: "d-flex align-items-center", style: { columnGap: 10 }, children: commandItems.map((item, index) => {
|
|
2743
|
+
return /* @__PURE__ */ jsxs13(
|
|
2744
|
+
Button4,
|
|
2145
2745
|
{
|
|
2146
2746
|
id: `command-item-${i}`,
|
|
2147
2747
|
tabIndex: -1,
|
|
2148
2748
|
style: { padding: "5px", minWidth: 45, height: "100%" },
|
|
2149
|
-
className:
|
|
2749
|
+
className: classnames7("command-item", {
|
|
2150
2750
|
"btn-icon": item.tooltip === ""
|
|
2151
2751
|
}),
|
|
2152
2752
|
color: item.color ? item.color : "#000",
|
|
@@ -2158,8 +2758,8 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2158
2758
|
e.preventDefault();
|
|
2159
2759
|
},
|
|
2160
2760
|
children: [
|
|
2161
|
-
item.icon && /* @__PURE__ */
|
|
2162
|
-
/* @__PURE__ */
|
|
2761
|
+
item.icon && /* @__PURE__ */ jsx14(icon_default, { iconName: item.icon, size: 16 }),
|
|
2762
|
+
/* @__PURE__ */ jsx14(UncontrolledTooltip2, { className: "r-tooltip", target: `command-item-${i}`, place: "top", children: t(item.tooltip ?? "") })
|
|
2163
2763
|
]
|
|
2164
2764
|
},
|
|
2165
2765
|
`command-${index}`
|
|
@@ -2416,7 +3016,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2416
3016
|
}
|
|
2417
3017
|
}
|
|
2418
3018
|
};
|
|
2419
|
-
|
|
3019
|
+
useEffect8(() => {
|
|
2420
3020
|
setIndexFocus(-1);
|
|
2421
3021
|
if (setSelectedItem) {
|
|
2422
3022
|
if (isMulti) {
|
|
@@ -2443,7 +3043,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2443
3043
|
}
|
|
2444
3044
|
}
|
|
2445
3045
|
}, [selectedRows]);
|
|
2446
|
-
|
|
3046
|
+
useEffect8(() => {
|
|
2447
3047
|
if (!isMulti) {
|
|
2448
3048
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
2449
3049
|
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
@@ -2460,10 +3060,10 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2460
3060
|
}, [selectedItem]);
|
|
2461
3061
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
2462
3062
|
if (col.field === "command") {
|
|
2463
|
-
return col.visible !== false && /* @__PURE__ */
|
|
3063
|
+
return col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2464
3064
|
"td",
|
|
2465
3065
|
{
|
|
2466
|
-
className:
|
|
3066
|
+
className: classnames7(
|
|
2467
3067
|
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
2468
3068
|
{ "cell-fixed": col.fixedType },
|
|
2469
3069
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -2473,15 +3073,15 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2473
3073
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
2474
3074
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
2475
3075
|
},
|
|
2476
|
-
children: /* @__PURE__ */
|
|
3076
|
+
children: /* @__PURE__ */ jsx14("div", { className: "r-rowcell-div ", children: renderCommand(col.commandItems, row, indexRow) })
|
|
2477
3077
|
},
|
|
2478
3078
|
`col-${indexRow}-${indexCol}`
|
|
2479
3079
|
);
|
|
2480
3080
|
} else if (col.field === "#") {
|
|
2481
|
-
return col.visible !== false && /* @__PURE__ */
|
|
3081
|
+
return col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2482
3082
|
"td",
|
|
2483
3083
|
{
|
|
2484
|
-
className:
|
|
3084
|
+
className: classnames7(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
2485
3085
|
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
2486
3086
|
style: {
|
|
2487
3087
|
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
@@ -2525,15 +3125,15 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2525
3125
|
e.stopPropagation();
|
|
2526
3126
|
}
|
|
2527
3127
|
},
|
|
2528
|
-
children: /* @__PURE__ */
|
|
3128
|
+
children: /* @__PURE__ */ jsx14("div", { className: "r-rowcell-div pt-50", children: indexRow + 1 })
|
|
2529
3129
|
},
|
|
2530
3130
|
`col-${indexRow}-${indexCol}`
|
|
2531
3131
|
);
|
|
2532
3132
|
} else if (col.field === "checkbox") {
|
|
2533
|
-
return /* @__PURE__ */
|
|
3133
|
+
return /* @__PURE__ */ jsx14(
|
|
2534
3134
|
"td",
|
|
2535
3135
|
{
|
|
2536
|
-
className:
|
|
3136
|
+
className: classnames7(
|
|
2537
3137
|
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
2538
3138
|
{ "cell-fixed": col.fixedType },
|
|
2539
3139
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -2543,7 +3143,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2543
3143
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
2544
3144
|
textAlign: col.textAlign ? col.textAlign : "center"
|
|
2545
3145
|
},
|
|
2546
|
-
children: /* @__PURE__ */
|
|
3146
|
+
children: /* @__PURE__ */ jsx14(
|
|
2547
3147
|
"div",
|
|
2548
3148
|
{
|
|
2549
3149
|
className: "r-rowcell-div cursor-pointer",
|
|
@@ -2567,8 +3167,8 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2567
3167
|
e.stopPropagation();
|
|
2568
3168
|
}
|
|
2569
3169
|
},
|
|
2570
|
-
children: /* @__PURE__ */
|
|
2571
|
-
|
|
3170
|
+
children: /* @__PURE__ */ jsx14(
|
|
3171
|
+
Input7,
|
|
2572
3172
|
{
|
|
2573
3173
|
checked: isSelected,
|
|
2574
3174
|
type: "checkbox",
|
|
@@ -2588,16 +3188,16 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2588
3188
|
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
2589
3189
|
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
2590
3190
|
} else if (col.editType === "date") {
|
|
2591
|
-
value = value ?
|
|
3191
|
+
value = value ? moment2(value).format("DD/MM/yyyy") : "";
|
|
2592
3192
|
} else if (col.editType === "datetime") {
|
|
2593
|
-
value = value ?
|
|
3193
|
+
value = value ? moment2(value).format("DD/MM/yyyy HH:mm") : "";
|
|
2594
3194
|
}
|
|
2595
3195
|
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
2596
3196
|
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
2597
|
-
return /* @__PURE__ */
|
|
3197
|
+
return /* @__PURE__ */ jsx14(Fragment15, { children: col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2598
3198
|
"td",
|
|
2599
3199
|
{
|
|
2600
|
-
className:
|
|
3200
|
+
className: classnames7(
|
|
2601
3201
|
`r-rowcell fix-${col.fixedType}`,
|
|
2602
3202
|
{ "cell-fixed": col.fixedType },
|
|
2603
3203
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -2639,28 +3239,28 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2639
3239
|
e.stopPropagation();
|
|
2640
3240
|
}
|
|
2641
3241
|
},
|
|
2642
|
-
children: /* @__PURE__ */
|
|
3242
|
+
children: /* @__PURE__ */ jsx14(
|
|
2643
3243
|
"div",
|
|
2644
3244
|
{
|
|
2645
|
-
className:
|
|
3245
|
+
className: classnames7("r-rowcell-div"),
|
|
2646
3246
|
style: {
|
|
2647
3247
|
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width
|
|
2648
3248
|
},
|
|
2649
|
-
children: /* @__PURE__ */
|
|
3249
|
+
children: /* @__PURE__ */ jsxs13(
|
|
2650
3250
|
"div",
|
|
2651
3251
|
{
|
|
2652
3252
|
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
2653
|
-
className:
|
|
3253
|
+
className: classnames7("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
2654
3254
|
style: {
|
|
2655
3255
|
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
2656
3256
|
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
2657
3257
|
},
|
|
2658
3258
|
children: [
|
|
2659
|
-
typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : /* @__PURE__ */
|
|
2660
|
-
/* @__PURE__ */
|
|
2661
|
-
!(typeDis === 1 && !refreshRow) &&
|
|
2662
|
-
/* @__PURE__ */
|
|
2663
|
-
|
|
3259
|
+
typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : /* @__PURE__ */ jsx14("div", { id: `content-${idTable}-${indexRow}-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3260
|
+
/* @__PURE__ */ jsx14("span", { id: `error-${indexRow}-${indexCol}`, className: classnames7("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ jsx14(AlertCircle, { fontSize: 15.5 }) }),
|
|
3261
|
+
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ jsx14(UncontrolledTooltip2, { className: "r-tooltip", autohide: false, target: `content-${idTable}-${indexRow}-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3262
|
+
/* @__PURE__ */ jsx14(
|
|
3263
|
+
UncontrolledTooltip2,
|
|
2664
3264
|
{
|
|
2665
3265
|
target: `error-${indexRow}-${indexCol}`,
|
|
2666
3266
|
className: "r-tooltip tooltip-error",
|
|
@@ -2677,14 +3277,18 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2677
3277
|
) }, indexCol);
|
|
2678
3278
|
}
|
|
2679
3279
|
};
|
|
3280
|
+
const checkOverflow = (indexRow, indexCol) => {
|
|
3281
|
+
const element = document.getElementById(`content-${idTable}-${indexRow}-${indexCol}`);
|
|
3282
|
+
return element && element.scrollWidth > element.clientWidth;
|
|
3283
|
+
};
|
|
2680
3284
|
const renderHeaderCol = (col, indexCol, indexParent) => {
|
|
2681
3285
|
if (col.field === "checkbox") {
|
|
2682
|
-
return /* @__PURE__ */
|
|
3286
|
+
return /* @__PURE__ */ jsx14(Fragment15, { children: col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2683
3287
|
"th",
|
|
2684
3288
|
{
|
|
2685
3289
|
rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
|
|
2686
3290
|
colSpan: col.columns?.length ?? 1,
|
|
2687
|
-
className:
|
|
3291
|
+
className: classnames7(
|
|
2688
3292
|
`r-headercell fix-${col.fixedType}`,
|
|
2689
3293
|
{ "cell-fixed": col.fixedType }
|
|
2690
3294
|
),
|
|
@@ -2696,17 +3300,17 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2696
3300
|
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
2697
3301
|
maxWidth: col.maxWidth
|
|
2698
3302
|
},
|
|
2699
|
-
children: /* @__PURE__ */
|
|
3303
|
+
children: /* @__PURE__ */ jsx14(
|
|
2700
3304
|
"div",
|
|
2701
3305
|
{
|
|
2702
3306
|
style: { justifyContent: col.textAlign ?? "left" },
|
|
2703
|
-
className:
|
|
2704
|
-
children: /* @__PURE__ */
|
|
2705
|
-
|
|
3307
|
+
className: classnames7("r-headercell-div"),
|
|
3308
|
+
children: /* @__PURE__ */ jsx14(
|
|
3309
|
+
Input7,
|
|
2706
3310
|
{
|
|
2707
3311
|
checked: totalCount > 0 && selectedRows?.length >= totalCount,
|
|
2708
3312
|
type: "checkbox",
|
|
2709
|
-
className:
|
|
3313
|
+
className: classnames7("cursor-pointer", { "d-none": !isMulti }),
|
|
2710
3314
|
style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
|
|
2711
3315
|
onChange: (e) => {
|
|
2712
3316
|
if (selectEnable) {
|
|
@@ -2726,15 +3330,15 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2726
3330
|
}
|
|
2727
3331
|
) }, `header-${indexCol}`);
|
|
2728
3332
|
} else if (col.field === "#") {
|
|
2729
|
-
return /* @__PURE__ */
|
|
2730
|
-
|
|
3333
|
+
return /* @__PURE__ */ jsx14(
|
|
3334
|
+
Fragment15,
|
|
2731
3335
|
{
|
|
2732
|
-
children: col.visible !== false && /* @__PURE__ */
|
|
3336
|
+
children: col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2733
3337
|
"th",
|
|
2734
3338
|
{
|
|
2735
3339
|
rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
|
|
2736
3340
|
colSpan: col.columns?.length ?? 1,
|
|
2737
|
-
className:
|
|
3341
|
+
className: classnames7(
|
|
2738
3342
|
`r-headercell fix-${col.fixedType}`,
|
|
2739
3343
|
{ "cell-fixed": col.fixedType }
|
|
2740
3344
|
),
|
|
@@ -2746,7 +3350,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2746
3350
|
left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
|
|
2747
3351
|
right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0
|
|
2748
3352
|
},
|
|
2749
|
-
children: /* @__PURE__ */
|
|
3353
|
+
children: /* @__PURE__ */ jsx14(
|
|
2750
3354
|
"div",
|
|
2751
3355
|
{
|
|
2752
3356
|
title: t(col.headerText ?? ""),
|
|
@@ -2761,15 +3365,15 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2761
3365
|
`header-${indexCol}`
|
|
2762
3366
|
);
|
|
2763
3367
|
} else {
|
|
2764
|
-
return /* @__PURE__ */
|
|
2765
|
-
|
|
3368
|
+
return /* @__PURE__ */ jsx14(
|
|
3369
|
+
Fragment15,
|
|
2766
3370
|
{
|
|
2767
|
-
children: col.visible !== false && /* @__PURE__ */
|
|
3371
|
+
children: col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2768
3372
|
"th",
|
|
2769
3373
|
{
|
|
2770
3374
|
rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
|
|
2771
3375
|
colSpan: col.columns?.length ?? 1,
|
|
2772
|
-
className:
|
|
3376
|
+
className: classnames7(
|
|
2773
3377
|
`r-headercell fix-${col.fixedType}`,
|
|
2774
3378
|
{ "cell-fixed": col.fixedType }
|
|
2775
3379
|
),
|
|
@@ -2781,7 +3385,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2781
3385
|
right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
|
|
2782
3386
|
maxWidth: col.maxWidth
|
|
2783
3387
|
},
|
|
2784
|
-
children: /* @__PURE__ */
|
|
3388
|
+
children: /* @__PURE__ */ jsx14(
|
|
2785
3389
|
"div",
|
|
2786
3390
|
{
|
|
2787
3391
|
role: "textbox",
|
|
@@ -2799,10 +3403,10 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2799
3403
|
}
|
|
2800
3404
|
};
|
|
2801
3405
|
const renderFooterCol = (col, indexCol) => {
|
|
2802
|
-
return /* @__PURE__ */
|
|
3406
|
+
return /* @__PURE__ */ jsx14(Fragment15, { children: col.visible !== false && /* @__PURE__ */ jsx14(
|
|
2803
3407
|
"td",
|
|
2804
3408
|
{
|
|
2805
|
-
className:
|
|
3409
|
+
className: classnames7(
|
|
2806
3410
|
`p-0 px-50 r-footer fix-${col.fixedType}`,
|
|
2807
3411
|
{ "cell-fixed": col.fixedType }
|
|
2808
3412
|
),
|
|
@@ -2814,56 +3418,56 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2814
3418
|
maxWidth: col.maxWidth,
|
|
2815
3419
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
2816
3420
|
},
|
|
2817
|
-
children: /* @__PURE__ */
|
|
3421
|
+
children: /* @__PURE__ */ jsx14("div", { className: "r-footer-div", children: col.haveSum === true && col.editType === "numeric" ? formartNumberic(dataSource.reduce(function(accumulator, currentValue) {
|
|
2818
3422
|
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
2819
3423
|
}, 0), decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) : "" })
|
|
2820
3424
|
}
|
|
2821
3425
|
) }, `summarycell-${indexCol}`);
|
|
2822
3426
|
};
|
|
2823
3427
|
const renderToolbarTop = () => {
|
|
2824
|
-
return /* @__PURE__ */
|
|
2825
|
-
/* @__PURE__ */
|
|
2826
|
-
return item.align === "left" ? /* @__PURE__ */
|
|
3428
|
+
return /* @__PURE__ */ jsx14("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ jsxs13("div", { className: "r-toolbar-items", children: [
|
|
3429
|
+
/* @__PURE__ */ jsx14("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
|
|
3430
|
+
return item.align === "left" ? /* @__PURE__ */ jsx14("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) : "";
|
|
2827
3431
|
}) }),
|
|
2828
|
-
/* @__PURE__ */
|
|
2829
|
-
return item.align === "center" ? /* @__PURE__ */
|
|
3432
|
+
/* @__PURE__ */ jsx14("div", { className: "r-toolbar-center", children: toolbarTopOption?.map((item, index) => {
|
|
3433
|
+
return item.align === "center" ? /* @__PURE__ */ jsx14("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-center-${index}`) : "";
|
|
2830
3434
|
}) }),
|
|
2831
|
-
/* @__PURE__ */
|
|
2832
|
-
return item.align === "right" ? /* @__PURE__ */
|
|
3435
|
+
/* @__PURE__ */ jsx14("div", { className: "r-toolbar-right", children: toolbarTopOption?.map((item, index) => {
|
|
3436
|
+
return item.align === "right" ? /* @__PURE__ */ jsx14("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-right-${index}`) : "";
|
|
2833
3437
|
}) })
|
|
2834
3438
|
] }) });
|
|
2835
3439
|
};
|
|
2836
3440
|
const renderToolbarBottom = () => {
|
|
2837
|
-
return /* @__PURE__ */
|
|
2838
|
-
/* @__PURE__ */
|
|
2839
|
-
/* @__PURE__ */
|
|
2840
|
-
(indexFocus ?? -1) > -1 ? /* @__PURE__ */
|
|
2841
|
-
/* @__PURE__ */
|
|
3441
|
+
return /* @__PURE__ */ jsx14("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__ */ jsxs13("div", { className: "r-toolbar-items", children: [
|
|
3442
|
+
/* @__PURE__ */ jsxs13("div", { className: "r-toolbar-left", children: [
|
|
3443
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx14(Button4, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
|
|
3444
|
+
(indexFocus ?? -1) > -1 ? /* @__PURE__ */ jsxs13(Fragment16, { children: [
|
|
3445
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx14(Button4, { color: "success", outline: true, onClick: () => {
|
|
2842
3446
|
handleDuplicate(dataSource[indexFocus ?? -1], indexFocus ?? -1);
|
|
2843
3447
|
}, className: "d-flex", children: t("Duplicate") }) }),
|
|
2844
|
-
/* @__PURE__ */
|
|
2845
|
-
/* @__PURE__ */
|
|
2846
|
-
] }) : /* @__PURE__ */
|
|
2847
|
-
/* @__PURE__ */
|
|
3448
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx14(Button4, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
|
|
3449
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx14(Button4, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
|
|
3450
|
+
] }) : /* @__PURE__ */ jsx14(Fragment16, { children: " " }),
|
|
3451
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item", { "d-none": editDisable || buttonSetting?.deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx14(Button4, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
|
|
2848
3452
|
toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
2849
|
-
return item.align === "left" ? /* @__PURE__ */
|
|
3453
|
+
return item.align === "left" ? /* @__PURE__ */ jsx14("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
|
|
2850
3454
|
})
|
|
2851
3455
|
] }),
|
|
2852
|
-
/* @__PURE__ */
|
|
2853
|
-
return item.align === "center" ? /* @__PURE__ */
|
|
3456
|
+
/* @__PURE__ */ jsx14("div", { className: "r-toolbar-center", children: toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
3457
|
+
return item.align === "center" ? /* @__PURE__ */ jsx14("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : "";
|
|
2854
3458
|
}) }),
|
|
2855
|
-
/* @__PURE__ */
|
|
3459
|
+
/* @__PURE__ */ jsxs13("div", { className: "r-toolbar-right", children: [
|
|
2856
3460
|
toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
2857
|
-
return item.align === "right" ? /* @__PURE__ */
|
|
3461
|
+
return item.align === "right" ? /* @__PURE__ */ jsx14("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : "";
|
|
2858
3462
|
}),
|
|
2859
|
-
/* @__PURE__ */
|
|
2860
|
-
/* @__PURE__ */
|
|
2861
|
-
/* @__PURE__ */
|
|
2862
|
-
/* @__PURE__ */
|
|
2863
|
-
/* @__PURE__ */
|
|
2864
|
-
/* @__PURE__ */
|
|
2865
|
-
/* @__PURE__ */
|
|
2866
|
-
/* @__PURE__ */
|
|
3463
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ jsx14(Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
|
|
3464
|
+
/* @__PURE__ */ jsx14("div", { className: classnames7("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsxs13(UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
|
|
3465
|
+
/* @__PURE__ */ jsx14(DropdownToggle3, { href: "/", tag: "a", color: "info", onClick: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx14(Info2, { className: "cursor-pointer" }) }),
|
|
3466
|
+
/* @__PURE__ */ jsx14(DropdownMenu3, { children: /* @__PURE__ */ jsxs13("div", { className: "d-flex flex-column p-50 py-25", children: [
|
|
3467
|
+
/* @__PURE__ */ jsx14("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" }),
|
|
3468
|
+
/* @__PURE__ */ jsx14("div", { style: { fontSize: 13 }, children: "Ch\u1ECDn \xF4 v\xE0 Ctrl + V \u0111\u1EC3 d\xE1n th\xF4ng tin t\u1EEB excel" }),
|
|
3469
|
+
/* @__PURE__ */ jsx14("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" }),
|
|
3470
|
+
/* @__PURE__ */ jsx14("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" })
|
|
2867
3471
|
] }) })
|
|
2868
3472
|
] }) })
|
|
2869
3473
|
] })
|
|
@@ -2892,10 +3496,10 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2892
3496
|
const flagDisplay = !pagingClient || totalCount > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && totalCount <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0);
|
|
2893
3497
|
if (flagDisplay) {
|
|
2894
3498
|
countDisplay++;
|
|
2895
|
-
return /* @__PURE__ */
|
|
3499
|
+
return /* @__PURE__ */ jsx14(
|
|
2896
3500
|
"tr",
|
|
2897
3501
|
{
|
|
2898
|
-
className:
|
|
3502
|
+
className: classnames7("r-row", { "fisrt-row": countDisplay === 0 }),
|
|
2899
3503
|
children: contentColumns.map((col, indexCol) => {
|
|
2900
3504
|
return renderContentCol(col, row, indexRow, indexCol, isSelected);
|
|
2901
3505
|
})
|
|
@@ -2906,29 +3510,29 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2906
3510
|
}
|
|
2907
3511
|
});
|
|
2908
3512
|
};
|
|
2909
|
-
|
|
3513
|
+
useEffect8(() => {
|
|
2910
3514
|
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
2911
3515
|
pagingSetting?.setCurrentPage(1);
|
|
2912
3516
|
}
|
|
2913
3517
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
2914
|
-
return /* @__PURE__ */
|
|
2915
|
-
/* @__PURE__ */
|
|
2916
|
-
/* @__PURE__ */
|
|
2917
|
-
toolbarSetting?.showTopToolbar ? /* @__PURE__ */
|
|
2918
|
-
/* @__PURE__ */
|
|
2919
|
-
/* @__PURE__ */
|
|
2920
|
-
return /* @__PURE__ */
|
|
3518
|
+
return /* @__PURE__ */ jsxs13(Fragment15, { children: [
|
|
3519
|
+
/* @__PURE__ */ jsxs13("div", { className: "react-table-edit", children: [
|
|
3520
|
+
/* @__PURE__ */ jsxs13("div", { className: "r-grid", ref: gridRef, children: [
|
|
3521
|
+
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ jsx14(Fragment16, { children: renderToolbarTop() }) : /* @__PURE__ */ jsx14(Fragment16, {}),
|
|
3522
|
+
/* @__PURE__ */ jsx14("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ jsxs13("table", { style: { width: "100%" }, children: [
|
|
3523
|
+
/* @__PURE__ */ jsx14("thead", { className: "r-gridheader", children: headerColumns.map((element, indexParent) => {
|
|
3524
|
+
return /* @__PURE__ */ jsx14("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
2921
3525
|
return renderHeaderCol(col, index, indexParent);
|
|
2922
3526
|
}) }, indexParent);
|
|
2923
3527
|
}) }),
|
|
2924
|
-
/* @__PURE__ */
|
|
2925
|
-
/* @__PURE__ */
|
|
3528
|
+
/* @__PURE__ */ jsx14("tbody", { className: "r-gridcontent", children: renderData() }),
|
|
3529
|
+
/* @__PURE__ */ jsx14("tfoot", { className: "r-gridfoot", children: haveSum == true ? /* @__PURE__ */ jsx14("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
2926
3530
|
return renderFooterCol(col, index);
|
|
2927
|
-
}) }) : /* @__PURE__ */
|
|
3531
|
+
}) }) : /* @__PURE__ */ jsx14(Fragment16, {}) })
|
|
2928
3532
|
] }) }),
|
|
2929
|
-
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */
|
|
3533
|
+
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ jsx14(Fragment16, { children: renderToolbarBottom() }) : /* @__PURE__ */ jsx14(Fragment16, {})
|
|
2930
3534
|
] }),
|
|
2931
|
-
pagingSetting?.allowPaging ? /* @__PURE__ */
|
|
3535
|
+
pagingSetting?.allowPaging ? /* @__PURE__ */ jsx14(
|
|
2932
3536
|
PagingComponent,
|
|
2933
3537
|
{
|
|
2934
3538
|
onChangePage,
|
|
@@ -2938,9 +3542,9 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2938
3542
|
totalItem: pagingClient ? totalCount : pagingSetting?.totalItem ?? 0,
|
|
2939
3543
|
onChangePageSize
|
|
2940
3544
|
}
|
|
2941
|
-
) : /* @__PURE__ */
|
|
3545
|
+
) : /* @__PURE__ */ jsx14(Fragment16, {})
|
|
2942
3546
|
] }),
|
|
2943
|
-
/* @__PURE__ */
|
|
3547
|
+
/* @__PURE__ */ jsx14(
|
|
2944
3548
|
sidebar_setting_column_default,
|
|
2945
3549
|
{
|
|
2946
3550
|
handleSidebar: () => {
|
|
@@ -2958,10 +3562,10 @@ var table_default = TableEdit;
|
|
|
2958
3562
|
// test-app/src/component/tab-menu/index.tsx
|
|
2959
3563
|
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight3 } from "becoxy-icons";
|
|
2960
3564
|
import classNames6 from "classnames";
|
|
2961
|
-
import { Fragment as
|
|
3565
|
+
import { Fragment as Fragment17, useEffect as useEffect9, useState as useState8 } from "react";
|
|
2962
3566
|
import { Link, useNavigate } from "react-router-dom";
|
|
2963
|
-
import { DropdownItem as
|
|
2964
|
-
import { jsx as
|
|
3567
|
+
import { DropdownItem as DropdownItem3, DropdownMenu as DropdownMenu4, DropdownToggle as DropdownToggle4, UncontrolledDropdown as UncontrolledDropdown2 } from "reactstrap";
|
|
3568
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2965
3569
|
var TabsMenuComponent = ({
|
|
2966
3570
|
buttonWidth,
|
|
2967
3571
|
tabParent,
|
|
@@ -2973,14 +3577,14 @@ var TabsMenuComponent = ({
|
|
|
2973
3577
|
renderModal
|
|
2974
3578
|
}) => {
|
|
2975
3579
|
const navigate = useNavigate();
|
|
2976
|
-
const [dataMenu, setDataMenu] =
|
|
2977
|
-
const [openMenu, setOpenMenu] =
|
|
2978
|
-
const [url, setUrl] =
|
|
2979
|
-
const [contentWidth, setContentWidth] =
|
|
2980
|
-
const [componentWidth, setComponentWidth] =
|
|
2981
|
-
const [scrollPosition, setScrollPosition] =
|
|
2982
|
-
const [dataItem, setDataItem] =
|
|
2983
|
-
const [openModal, setOpenModal] =
|
|
3580
|
+
const [dataMenu, setDataMenu] = useState8([]);
|
|
3581
|
+
const [openMenu, setOpenMenu] = useState8(false);
|
|
3582
|
+
const [url, setUrl] = useState8("");
|
|
3583
|
+
const [contentWidth, setContentWidth] = useState8(0);
|
|
3584
|
+
const [componentWidth, setComponentWidth] = useState8(0);
|
|
3585
|
+
const [scrollPosition, setScrollPosition] = useState8(0);
|
|
3586
|
+
const [dataItem, setDataItem] = useState8([]);
|
|
3587
|
+
const [openModal, setOpenModal] = useState8({});
|
|
2984
3588
|
const handleWindowResize = () => {
|
|
2985
3589
|
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2986
3590
|
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
@@ -2989,7 +3593,7 @@ var TabsMenuComponent = ({
|
|
|
2989
3593
|
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2990
3594
|
}
|
|
2991
3595
|
};
|
|
2992
|
-
|
|
3596
|
+
useEffect9(() => {
|
|
2993
3597
|
setUrl(window.location.pathname);
|
|
2994
3598
|
window.addEventListener("resize", handleWindowResize);
|
|
2995
3599
|
setTimeout(() => {
|
|
@@ -3005,7 +3609,7 @@ var TabsMenuComponent = ({
|
|
|
3005
3609
|
window.removeEventListener("resize", handleWindowResize);
|
|
3006
3610
|
};
|
|
3007
3611
|
}, []);
|
|
3008
|
-
|
|
3612
|
+
useEffect9(() => {
|
|
3009
3613
|
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
3010
3614
|
if (item) {
|
|
3011
3615
|
if (resourceCodeParent) {
|
|
@@ -3036,23 +3640,23 @@ var TabsMenuComponent = ({
|
|
|
3036
3640
|
const handleModal = (name) => {
|
|
3037
3641
|
setOpenModal((old) => ({ ...old, [name]: !(openModal[name] ?? false) }));
|
|
3038
3642
|
};
|
|
3039
|
-
return /* @__PURE__ */
|
|
3643
|
+
return /* @__PURE__ */ jsxs14(Fragment17, { children: [
|
|
3040
3644
|
renderModal ? renderModal({ handleModal, windowSize, openModal, setDataItem, dataItem }) : "",
|
|
3041
|
-
/* @__PURE__ */
|
|
3042
|
-
/* @__PURE__ */
|
|
3645
|
+
/* @__PURE__ */ jsxs14("div", { className: classNames6("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
3646
|
+
/* @__PURE__ */ jsx15(
|
|
3043
3647
|
"div",
|
|
3044
3648
|
{
|
|
3045
3649
|
onClick: () => handleScroll(-200),
|
|
3046
3650
|
className: classNames6("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3047
|
-
children: /* @__PURE__ */
|
|
3651
|
+
children: /* @__PURE__ */ jsx15(ChevronLeft3, {})
|
|
3048
3652
|
}
|
|
3049
3653
|
),
|
|
3050
|
-
/* @__PURE__ */
|
|
3654
|
+
/* @__PURE__ */ jsx15("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ jsx15("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
3051
3655
|
if (item?.resAttributes?.IS_MENU === "1") {
|
|
3052
|
-
return /* @__PURE__ */
|
|
3053
|
-
/* @__PURE__ */
|
|
3054
|
-
/* @__PURE__ */
|
|
3055
|
-
|
|
3656
|
+
return /* @__PURE__ */ jsxs14(UncontrolledDropdown2, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
3657
|
+
/* @__PURE__ */ jsx15(DropdownToggle4, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ jsx15("div", { children: item.name }) }),
|
|
3658
|
+
/* @__PURE__ */ jsx15(DropdownMenu4, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ jsx15(
|
|
3659
|
+
DropdownItem3,
|
|
3056
3660
|
{
|
|
3057
3661
|
style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%" },
|
|
3058
3662
|
onClick: () => {
|
|
@@ -3068,7 +3672,7 @@ var TabsMenuComponent = ({
|
|
|
3068
3672
|
)) })
|
|
3069
3673
|
] }, item.code);
|
|
3070
3674
|
} else {
|
|
3071
|
-
return /* @__PURE__ */
|
|
3675
|
+
return /* @__PURE__ */ jsx15(
|
|
3072
3676
|
Link,
|
|
3073
3677
|
{
|
|
3074
3678
|
to: item.url,
|
|
@@ -3079,12 +3683,12 @@ var TabsMenuComponent = ({
|
|
|
3079
3683
|
);
|
|
3080
3684
|
}
|
|
3081
3685
|
}) }) }),
|
|
3082
|
-
/* @__PURE__ */
|
|
3686
|
+
/* @__PURE__ */ jsx15(
|
|
3083
3687
|
"div",
|
|
3084
3688
|
{
|
|
3085
3689
|
onClick: () => handleScroll(200),
|
|
3086
3690
|
className: classNames6("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3087
|
-
children: /* @__PURE__ */
|
|
3691
|
+
children: /* @__PURE__ */ jsx15(ChevronRight3, {})
|
|
3088
3692
|
}
|
|
3089
3693
|
)
|
|
3090
3694
|
] })
|