@eztrak/shared 0.12.1 → 0.13.1
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/chunk-HGLO5LDS.mjs +1 -0
- package/dist/chunk-HGLO5LDS.mjs.map +1 -0
- package/dist/{chunk-3FD7O5VS.mjs → chunk-TN7TPFJ3.mjs} +106 -18
- package/dist/chunk-TN7TPFJ3.mjs.map +1 -0
- package/dist/{chunk-BMX2RODZ.mjs → chunk-YWS7JMII.mjs} +54 -1
- package/dist/chunk-YWS7JMII.mjs.map +1 -0
- package/dist/components/index.d.mts +34 -2
- package/dist/components/index.d.ts +34 -2
- package/dist/components/index.js +138 -21
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -2
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +107 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -15
- package/dist/utils/index.mjs +12 -13
- package/package.json +6 -2
- package/dist/chunk-3FD7O5VS.mjs.map +0 -1
- package/dist/chunk-7PPCJV2M.mjs +0 -56
- package/dist/chunk-7PPCJV2M.mjs.map +0 -1
- package/dist/chunk-BMX2RODZ.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
EztrakTabs: () => EztrakTabs,
|
|
38
38
|
Loader: () => Loader,
|
|
39
39
|
Modal: () => Modal,
|
|
40
|
+
PopupCellRenderer: () => PopupCellRenderer,
|
|
40
41
|
ResetColumnsButton: () => ResetColumnsButton,
|
|
41
42
|
ResetFiltersButton: () => ResetFiltersButton,
|
|
42
43
|
SearchInput: () => SearchInput,
|
|
@@ -1065,6 +1066,7 @@ function CustomPagination({
|
|
|
1065
1066
|
}
|
|
1066
1067
|
|
|
1067
1068
|
// src/components/search-filters/DropdownFilter.tsx
|
|
1069
|
+
var import_react4 = require("react");
|
|
1068
1070
|
var import_react_select = __toESM(require("react-select"));
|
|
1069
1071
|
var import_react_router_dom2 = require("react-router-dom");
|
|
1070
1072
|
|
|
@@ -1149,22 +1151,44 @@ function DropdownFilter({
|
|
|
1149
1151
|
isSearchable = true,
|
|
1150
1152
|
isDisabled = false,
|
|
1151
1153
|
isLoading = false,
|
|
1154
|
+
saveToLocalStorage = false,
|
|
1152
1155
|
...otherProps
|
|
1153
1156
|
}) {
|
|
1154
1157
|
const [searchParams, setSearchParams] = (0, import_react_router_dom2.useSearchParams)();
|
|
1158
|
+
const hasRestoredFromStorage = (0, import_react4.useRef)(false);
|
|
1159
|
+
(0, import_react4.useEffect)(() => {
|
|
1160
|
+
if (!saveToLocalStorage || hasRestoredFromStorage.current) return;
|
|
1161
|
+
hasRestoredFromStorage.current = true;
|
|
1162
|
+
if (searchParams.get(name)) return;
|
|
1163
|
+
const stored = getItemFromLocalStorage(name);
|
|
1164
|
+
if (stored != null && stored !== "") {
|
|
1165
|
+
setSearchParams((prev) => {
|
|
1166
|
+
prev.set(name, String(stored));
|
|
1167
|
+
return prev;
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
}, [saveToLocalStorage, name, searchParams, setSearchParams]);
|
|
1155
1171
|
const currentValue = searchParams.get(name);
|
|
1156
1172
|
const selectedOption = currentValue ? options?.find(
|
|
1157
1173
|
(option) => option[valueKey]?.toString() === currentValue
|
|
1158
1174
|
) ?? null : null;
|
|
1159
1175
|
const handleChange = (selected) => {
|
|
1176
|
+
const selectedValue = selected && selected[valueKey] !== "" ? String(selected[valueKey]) : null;
|
|
1160
1177
|
setSearchParams((prev) => {
|
|
1161
|
-
if (!
|
|
1178
|
+
if (!selectedValue) {
|
|
1162
1179
|
prev.delete(name);
|
|
1163
1180
|
} else {
|
|
1164
|
-
prev.set(name,
|
|
1181
|
+
prev.set(name, selectedValue);
|
|
1165
1182
|
}
|
|
1166
1183
|
return prev;
|
|
1167
1184
|
});
|
|
1185
|
+
if (saveToLocalStorage) {
|
|
1186
|
+
if (selectedValue) {
|
|
1187
|
+
storeItemInLocalStorage(name, selectedValue);
|
|
1188
|
+
} else {
|
|
1189
|
+
removeItem(name);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1168
1192
|
};
|
|
1169
1193
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: cn(className), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1170
1194
|
import_react_select.default,
|
|
@@ -1255,7 +1279,7 @@ function ResetFiltersButton({
|
|
|
1255
1279
|
}
|
|
1256
1280
|
|
|
1257
1281
|
// src/components/search-filters/SearchInput.tsx
|
|
1258
|
-
var
|
|
1282
|
+
var import_react5 = require("react");
|
|
1259
1283
|
var import_fi = require("react-icons/fi");
|
|
1260
1284
|
var import_react_router_dom4 = require("react-router-dom");
|
|
1261
1285
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1277,8 +1301,8 @@ function SearchInput({
|
|
|
1277
1301
|
}) {
|
|
1278
1302
|
const [searchParams, setSearchParams] = (0, import_react_router_dom4.useSearchParams)();
|
|
1279
1303
|
const queryParam = searchParams.get(defaultParam) || defaultValue || "";
|
|
1280
|
-
const [inputValue, setInputValue] = (0,
|
|
1281
|
-
const debounceTimerRef = (0,
|
|
1304
|
+
const [inputValue, setInputValue] = (0, import_react5.useState)(queryParam);
|
|
1305
|
+
const debounceTimerRef = (0, import_react5.useRef)(null);
|
|
1282
1306
|
const updateSearchParams = (searchQuery) => {
|
|
1283
1307
|
if (searchQuery?.trim()) {
|
|
1284
1308
|
setSearchParams((prev) => {
|
|
@@ -1317,10 +1341,10 @@ function SearchInput({
|
|
|
1317
1341
|
updateSearchParams("");
|
|
1318
1342
|
}
|
|
1319
1343
|
};
|
|
1320
|
-
(0,
|
|
1344
|
+
(0, import_react5.useEffect)(() => {
|
|
1321
1345
|
setInputValue(queryParam);
|
|
1322
1346
|
}, [queryParam]);
|
|
1323
|
-
(0,
|
|
1347
|
+
(0, import_react5.useEffect)(() => {
|
|
1324
1348
|
return () => {
|
|
1325
1349
|
if (debounceTimerRef.current) {
|
|
1326
1350
|
clearTimeout(debounceTimerRef.current);
|
|
@@ -1371,7 +1395,7 @@ function SearchInput({
|
|
|
1371
1395
|
|
|
1372
1396
|
// src/components/modal/Modal.tsx
|
|
1373
1397
|
var import_framer_motion = require("framer-motion");
|
|
1374
|
-
var
|
|
1398
|
+
var import_react6 = require("react");
|
|
1375
1399
|
var import_react_dom = require("react-dom");
|
|
1376
1400
|
var import_fa = require("react-icons/fa");
|
|
1377
1401
|
var import_io5 = require("react-icons/io5");
|
|
@@ -1416,13 +1440,13 @@ function Modal({
|
|
|
1416
1440
|
customLoader = null,
|
|
1417
1441
|
footerClassName
|
|
1418
1442
|
}) {
|
|
1419
|
-
const modalRef = (0,
|
|
1443
|
+
const modalRef = (0, import_react6.useRef)(null);
|
|
1420
1444
|
const handleBackdropClick = (e) => {
|
|
1421
1445
|
if (e.target === e.currentTarget && closeOnBackdropClick) {
|
|
1422
1446
|
onClose();
|
|
1423
1447
|
}
|
|
1424
1448
|
};
|
|
1425
|
-
(0,
|
|
1449
|
+
(0, import_react6.useEffect)(() => {
|
|
1426
1450
|
const handleEscape = (e) => {
|
|
1427
1451
|
if (e.key === "Escape" && isOpen && closeOnEscape) {
|
|
1428
1452
|
onClose();
|
|
@@ -1666,7 +1690,7 @@ function CardSkeleton({
|
|
|
1666
1690
|
}
|
|
1667
1691
|
|
|
1668
1692
|
// src/components/tooltip/ToolTip.tsx
|
|
1669
|
-
var
|
|
1693
|
+
var import_react7 = require("react");
|
|
1670
1694
|
var import_react_tooltip = require("react-tooltip");
|
|
1671
1695
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1672
1696
|
var defaultTooltipStyle = {
|
|
@@ -1691,7 +1715,7 @@ function ToolTip({
|
|
|
1691
1715
|
disabled = false,
|
|
1692
1716
|
children
|
|
1693
1717
|
}) {
|
|
1694
|
-
const generatedId = (0,
|
|
1718
|
+
const generatedId = (0, import_react7.useId)();
|
|
1695
1719
|
const tooltipId = `eztrak-tooltip-${generatedId.replace(/:/g, "")}`;
|
|
1696
1720
|
const tooltipText = String(text ?? "");
|
|
1697
1721
|
if (disabled || !tooltipText) {
|
|
@@ -1762,7 +1786,7 @@ function TooltipText({
|
|
|
1762
1786
|
}
|
|
1763
1787
|
|
|
1764
1788
|
// src/components/cell-editor/CustomCellEditor.tsx
|
|
1765
|
-
var
|
|
1789
|
+
var import_react8 = require("react");
|
|
1766
1790
|
var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
|
|
1767
1791
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1768
1792
|
function ButtonSpinner() {
|
|
@@ -1809,7 +1833,7 @@ function normalizeInitialValue(initialValue, inputType) {
|
|
|
1809
1833
|
}
|
|
1810
1834
|
return initialValue;
|
|
1811
1835
|
}
|
|
1812
|
-
var CustomCellEditor = (0,
|
|
1836
|
+
var CustomCellEditor = (0, import_react8.forwardRef)(
|
|
1813
1837
|
({
|
|
1814
1838
|
value: initialValue,
|
|
1815
1839
|
name,
|
|
@@ -1834,11 +1858,11 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
|
|
|
1834
1858
|
cancelButtonClassName
|
|
1835
1859
|
}, ref) => {
|
|
1836
1860
|
const normalizedInitial = normalizeInitialValue(initialValue, inputType);
|
|
1837
|
-
const [value, setValue] = (0,
|
|
1838
|
-
const [isLoading, setIsLoading] = (0,
|
|
1839
|
-
const inputRef = (0,
|
|
1840
|
-
const selectRef = (0,
|
|
1841
|
-
const normalizedOptions = (0,
|
|
1861
|
+
const [value, setValue] = (0, import_react8.useState)(normalizedInitial);
|
|
1862
|
+
const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
|
|
1863
|
+
const inputRef = (0, import_react8.useRef)(null);
|
|
1864
|
+
const selectRef = (0, import_react8.useRef)(null);
|
|
1865
|
+
const normalizedOptions = (0, import_react8.useMemo)(() => {
|
|
1842
1866
|
if (customOptions && customOptions.length > 0) {
|
|
1843
1867
|
return customOptions.map((opt) => ({
|
|
1844
1868
|
value: String(opt[valueKey] ?? ""),
|
|
@@ -1848,13 +1872,13 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
|
|
|
1848
1872
|
return dropdownOptions;
|
|
1849
1873
|
}, [customOptions, dropdownOptions, valueKey, labelKey]);
|
|
1850
1874
|
const isDropdown = inputType === "dropdown" || normalizedOptions.length > 0;
|
|
1851
|
-
(0,
|
|
1875
|
+
(0, import_react8.useImperativeHandle)(ref, () => ({
|
|
1852
1876
|
getValue: () => value,
|
|
1853
1877
|
isCancelBeforeStart: () => false,
|
|
1854
1878
|
isCancelAfterEnd: () => false,
|
|
1855
1879
|
isPopup: () => true
|
|
1856
1880
|
}));
|
|
1857
|
-
(0,
|
|
1881
|
+
(0, import_react8.useEffect)(() => {
|
|
1858
1882
|
if (isDropdown) {
|
|
1859
1883
|
selectRef.current?.focus();
|
|
1860
1884
|
return;
|
|
@@ -1989,6 +2013,67 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
|
|
|
1989
2013
|
}
|
|
1990
2014
|
);
|
|
1991
2015
|
CustomCellEditor.displayName = "CustomCellEditor";
|
|
2016
|
+
|
|
2017
|
+
// src/components/popup-cell-renderer/PopupCellRenderer.tsx
|
|
2018
|
+
var import_react9 = require("react");
|
|
2019
|
+
var import_react10 = __toESM(require("@tippyjs/react"));
|
|
2020
|
+
var import_bi = require("react-icons/bi");
|
|
2021
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2022
|
+
function PopupCellRenderer({
|
|
2023
|
+
dropDownContent,
|
|
2024
|
+
actionIcon: ActionIcon = import_bi.BiDotsVerticalRounded,
|
|
2025
|
+
title = "Actions",
|
|
2026
|
+
className,
|
|
2027
|
+
hideTitle = false,
|
|
2028
|
+
params,
|
|
2029
|
+
onAction,
|
|
2030
|
+
placement = "bottom-end",
|
|
2031
|
+
tippyProps
|
|
2032
|
+
}) {
|
|
2033
|
+
const [visible, setVisible] = (0, import_react9.useState)(false);
|
|
2034
|
+
const show = () => setVisible(true);
|
|
2035
|
+
const hide = () => setVisible(false);
|
|
2036
|
+
const rowData = params?.data;
|
|
2037
|
+
const handleAction = (actionType, actionRowData) => {
|
|
2038
|
+
onAction?.(actionType, actionRowData ?? rowData, hide);
|
|
2039
|
+
hide();
|
|
2040
|
+
};
|
|
2041
|
+
const content = typeof dropDownContent === "function" ? dropDownContent(handleAction) : dropDownContent;
|
|
2042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex h-full", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2043
|
+
import_react10.default,
|
|
2044
|
+
{
|
|
2045
|
+
content,
|
|
2046
|
+
visible,
|
|
2047
|
+
onClickOutside: hide,
|
|
2048
|
+
allowHTML: true,
|
|
2049
|
+
arrow: false,
|
|
2050
|
+
appendTo: () => document.body,
|
|
2051
|
+
interactive: true,
|
|
2052
|
+
placement,
|
|
2053
|
+
animation: "shift-away",
|
|
2054
|
+
theme: "light",
|
|
2055
|
+
maxWidth: "none",
|
|
2056
|
+
offset: [0, 5],
|
|
2057
|
+
...tippyProps,
|
|
2058
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2059
|
+
"button",
|
|
2060
|
+
{
|
|
2061
|
+
type: "button",
|
|
2062
|
+
onClick: visible ? hide : show,
|
|
2063
|
+
className: cn(
|
|
2064
|
+
"flex items-center justify-center gap-2 rounded-full text-gray-500 hover:text-gray-800",
|
|
2065
|
+
className
|
|
2066
|
+
),
|
|
2067
|
+
"aria-label": "Row actions",
|
|
2068
|
+
children: [
|
|
2069
|
+
!hideTitle && title,
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActionIcon, { "aria-hidden": true })
|
|
2071
|
+
]
|
|
2072
|
+
}
|
|
2073
|
+
)
|
|
2074
|
+
}
|
|
2075
|
+
) });
|
|
2076
|
+
}
|
|
1992
2077
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1993
2078
|
0 && (module.exports = {
|
|
1994
2079
|
CardSkeleton,
|
|
@@ -1998,6 +2083,7 @@ CustomCellEditor.displayName = "CustomCellEditor";
|
|
|
1998
2083
|
EztrakTabs,
|
|
1999
2084
|
Loader,
|
|
2000
2085
|
Modal,
|
|
2086
|
+
PopupCellRenderer,
|
|
2001
2087
|
ResetColumnsButton,
|
|
2002
2088
|
ResetFiltersButton,
|
|
2003
2089
|
SearchInput,
|