react-lookup-select 1.0.2 → 1.0.4
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/LICENSE +21 -0
- package/dist/index.cjs +109 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -1
- package/dist/index.d.ts +152 -1
- package/dist/index.js +110 -35
- package/dist/index.js.map +1 -1
- package/dist/styles.css +49 -59
- package/package.json +2 -2
- package/readme.md +166 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Onur Altuntaş
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -1292,6 +1292,12 @@ function LookupSelect(props) {
|
|
|
1292
1292
|
size = "medium",
|
|
1293
1293
|
icon,
|
|
1294
1294
|
renderTrigger,
|
|
1295
|
+
renderModal,
|
|
1296
|
+
renderGrid,
|
|
1297
|
+
renderHeader,
|
|
1298
|
+
renderFooter,
|
|
1299
|
+
renderSearch,
|
|
1300
|
+
renderPagination,
|
|
1295
1301
|
modalTitle,
|
|
1296
1302
|
classNames,
|
|
1297
1303
|
styles,
|
|
@@ -1455,7 +1461,7 @@ function LookupSelect(props) {
|
|
|
1455
1461
|
virtualThreshold
|
|
1456
1462
|
]
|
|
1457
1463
|
);
|
|
1458
|
-
const
|
|
1464
|
+
const renderGridComponent = import_react5.default.useCallback(() => {
|
|
1459
1465
|
const commonGridProps = {
|
|
1460
1466
|
data: currentData,
|
|
1461
1467
|
columns,
|
|
@@ -1506,6 +1512,96 @@ function LookupSelect(props) {
|
|
|
1506
1512
|
shouldUseVirtualization,
|
|
1507
1513
|
virtualizationConfig
|
|
1508
1514
|
]);
|
|
1515
|
+
const renderModalContent = () => {
|
|
1516
|
+
const defaultContent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1517
|
+
renderSearch ? renderSearch({
|
|
1518
|
+
value: searchValue,
|
|
1519
|
+
onChange: handleSearchChange,
|
|
1520
|
+
placeholder: texts.searchPlaceholder,
|
|
1521
|
+
loading,
|
|
1522
|
+
onClear: () => handleSearchChange("")
|
|
1523
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1524
|
+
SearchInput,
|
|
1525
|
+
{
|
|
1526
|
+
value: searchValue,
|
|
1527
|
+
onChange: handleSearchChange,
|
|
1528
|
+
placeholder: texts.searchPlaceholder
|
|
1529
|
+
}
|
|
1530
|
+
),
|
|
1531
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "lookup-select__modal-content", children: [
|
|
1532
|
+
renderGrid ? renderGrid({
|
|
1533
|
+
data: currentData,
|
|
1534
|
+
columns,
|
|
1535
|
+
selectedIds: currentSelections.map(mapper.getId),
|
|
1536
|
+
onRowSelect: toggleRowSelection,
|
|
1537
|
+
onSelectAll: mode === "multiple" ? () => {
|
|
1538
|
+
const allIds = currentData.map(mapper.getId);
|
|
1539
|
+
const selectedIds = currentSelections.map(mapper.getId);
|
|
1540
|
+
if (allIds.length === selectedIds.length) {
|
|
1541
|
+
clearSelections();
|
|
1542
|
+
} else {
|
|
1543
|
+
currentData.forEach((row) => {
|
|
1544
|
+
if (!isRowSelected(row)) {
|
|
1545
|
+
toggleRowSelection(row);
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
} : void 0,
|
|
1550
|
+
onClearAll: clearSelections,
|
|
1551
|
+
loading,
|
|
1552
|
+
error,
|
|
1553
|
+
mode,
|
|
1554
|
+
mapper,
|
|
1555
|
+
virtualization: shouldUseVirtualization ? virtualizationConfig : void 0,
|
|
1556
|
+
selectableRow,
|
|
1557
|
+
onSortChange: handleSortChange,
|
|
1558
|
+
sortBy: getCurrentQuery().sortBy,
|
|
1559
|
+
sortDir: getCurrentQuery().sortDir
|
|
1560
|
+
}) : renderGridComponent(),
|
|
1561
|
+
dataSource && !renderPagination && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1562
|
+
Pagination,
|
|
1563
|
+
{
|
|
1564
|
+
currentPage,
|
|
1565
|
+
totalCount,
|
|
1566
|
+
pageSize: optimizedPageSize,
|
|
1567
|
+
onPageChange: handlePageChange
|
|
1568
|
+
}
|
|
1569
|
+
),
|
|
1570
|
+
dataSource && renderPagination && renderPagination({
|
|
1571
|
+
currentPage,
|
|
1572
|
+
totalPages: Math.ceil(totalCount / optimizedPageSize),
|
|
1573
|
+
onPageChange: handlePageChange,
|
|
1574
|
+
pageSize: optimizedPageSize,
|
|
1575
|
+
onPageSizeChange: (newSize) => {
|
|
1576
|
+
},
|
|
1577
|
+
totalCount,
|
|
1578
|
+
loading
|
|
1579
|
+
})
|
|
1580
|
+
] }),
|
|
1581
|
+
renderFooter ? renderFooter({
|
|
1582
|
+
selectedCount: currentSelections.length,
|
|
1583
|
+
totalCount,
|
|
1584
|
+
onConfirm: confirmSelection,
|
|
1585
|
+
onCancel: cancelSelection,
|
|
1586
|
+
currentPage,
|
|
1587
|
+
totalPages: Math.ceil(totalCount / optimizedPageSize),
|
|
1588
|
+
onPageChange: handlePageChange,
|
|
1589
|
+
pageSize: optimizedPageSize,
|
|
1590
|
+
loading,
|
|
1591
|
+
mode
|
|
1592
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1593
|
+
ModalFooter,
|
|
1594
|
+
{
|
|
1595
|
+
onConfirm: confirmSelection,
|
|
1596
|
+
onCancel: cancelSelection,
|
|
1597
|
+
confirmText: texts.confirmText,
|
|
1598
|
+
cancelText: texts.cancelText,
|
|
1599
|
+
selectedCount: currentSelections.length
|
|
1600
|
+
}
|
|
1601
|
+
)
|
|
1602
|
+
] });
|
|
1603
|
+
return defaultContent;
|
|
1604
|
+
};
|
|
1509
1605
|
const getThemeClasses = () => {
|
|
1510
1606
|
const classes = ["lookup-select"];
|
|
1511
1607
|
if (variant && variant !== "default") {
|
|
@@ -1553,7 +1649,17 @@ function LookupSelect(props) {
|
|
|
1553
1649
|
onRemoveTag: (item) => toggleRowSelection(item)
|
|
1554
1650
|
}
|
|
1555
1651
|
),
|
|
1556
|
-
|
|
1652
|
+
renderModal ? renderModal({
|
|
1653
|
+
isOpen: modalOpen,
|
|
1654
|
+
onClose: cancelSelection,
|
|
1655
|
+
children: renderModalContent(),
|
|
1656
|
+
title: modalTitle || texts.modalTitle,
|
|
1657
|
+
loading,
|
|
1658
|
+
error,
|
|
1659
|
+
query: getCurrentQuery(),
|
|
1660
|
+
selectedCount: currentSelections.length,
|
|
1661
|
+
totalCount
|
|
1662
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1557
1663
|
Modal,
|
|
1558
1664
|
{
|
|
1559
1665
|
isOpen: modalOpen,
|
|
@@ -1561,38 +1667,7 @@ function LookupSelect(props) {
|
|
|
1561
1667
|
title: modalTitle || texts.modalTitle,
|
|
1562
1668
|
className: classNames?.modal,
|
|
1563
1669
|
style: styles?.modal,
|
|
1564
|
-
children:
|
|
1565
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1566
|
-
SearchInput,
|
|
1567
|
-
{
|
|
1568
|
-
value: searchValue,
|
|
1569
|
-
onChange: handleSearchChange,
|
|
1570
|
-
placeholder: texts.searchPlaceholder
|
|
1571
|
-
}
|
|
1572
|
-
),
|
|
1573
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "lookup-select__modal-content", children: [
|
|
1574
|
-
renderGrid(),
|
|
1575
|
-
dataSource && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1576
|
-
Pagination,
|
|
1577
|
-
{
|
|
1578
|
-
currentPage,
|
|
1579
|
-
totalCount,
|
|
1580
|
-
pageSize: optimizedPageSize,
|
|
1581
|
-
onPageChange: handlePageChange
|
|
1582
|
-
}
|
|
1583
|
-
)
|
|
1584
|
-
] }),
|
|
1585
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1586
|
-
ModalFooter,
|
|
1587
|
-
{
|
|
1588
|
-
onConfirm: confirmSelection,
|
|
1589
|
-
onCancel: cancelSelection,
|
|
1590
|
-
confirmText: texts.confirmText,
|
|
1591
|
-
cancelText: texts.cancelText,
|
|
1592
|
-
selectedCount: currentSelections.length
|
|
1593
|
-
}
|
|
1594
|
-
)
|
|
1595
|
-
]
|
|
1670
|
+
children: renderModalContent()
|
|
1596
1671
|
}
|
|
1597
1672
|
)
|
|
1598
1673
|
] });
|