@eztrak/shared 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4P22KKIJ.mjs → chunk-DFOALLDC.mjs} +45 -19
- package/dist/chunk-DFOALLDC.mjs.map +1 -0
- package/dist/chunk-HGLO5LDS.mjs +1 -0
- package/dist/chunk-HGLO5LDS.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 +4 -2
- package/dist/components/index.d.ts +4 -2
- package/dist/components/index.js +81 -27
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/index.js +50 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -15
- package/dist/utils/index.mjs +12 -13
- package/package.json +1 -1
- package/dist/chunk-4P22KKIJ.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/components/index.js
CHANGED
|
@@ -675,6 +675,7 @@ function CustomPagination({
|
|
|
675
675
|
}
|
|
676
676
|
|
|
677
677
|
// src/components/search-filters/DropdownFilter.tsx
|
|
678
|
+
var import_react2 = require("react");
|
|
678
679
|
var import_react_select = __toESM(require("react-select"));
|
|
679
680
|
var import_react_router_dom2 = require("react-router-dom");
|
|
680
681
|
|
|
@@ -686,13 +687,13 @@ var themeColors = {
|
|
|
686
687
|
textColor: "black",
|
|
687
688
|
white: "white"
|
|
688
689
|
};
|
|
689
|
-
var dropdownStyles = (_borderRadius
|
|
690
|
+
var dropdownStyles = (_borderRadius) => ({
|
|
690
691
|
control: (provided, state) => ({
|
|
691
692
|
...provided,
|
|
692
693
|
fontSize: "14px",
|
|
693
694
|
padding: "4px 8px",
|
|
694
695
|
minWidth: "180px",
|
|
695
|
-
borderRadius:
|
|
696
|
+
borderRadius: _borderRadius,
|
|
696
697
|
cursor: "pointer",
|
|
697
698
|
borderColor: state.isFocused ? themeColors.primary : "#e0e0e0",
|
|
698
699
|
boxShadow: state.isFocused ? "0 0 0 2px rgba(255, 115, 53, 0.3)" : "none",
|
|
@@ -746,6 +747,37 @@ var dropdownStyles = (_borderRadius = "5px") => ({
|
|
|
746
747
|
})
|
|
747
748
|
});
|
|
748
749
|
|
|
750
|
+
// src/utils/localStorage.ts
|
|
751
|
+
function getStorage() {
|
|
752
|
+
if (typeof window === "undefined") return null;
|
|
753
|
+
return window.localStorage;
|
|
754
|
+
}
|
|
755
|
+
function getItem(key, fallback = null) {
|
|
756
|
+
try {
|
|
757
|
+
const raw = getStorage()?.getItem(key);
|
|
758
|
+
if (raw === null || raw === void 0) {
|
|
759
|
+
return fallback;
|
|
760
|
+
}
|
|
761
|
+
return JSON.parse(raw);
|
|
762
|
+
} catch {
|
|
763
|
+
return fallback;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
function setItem(key, value) {
|
|
767
|
+
try {
|
|
768
|
+
getStorage()?.setItem(key, JSON.stringify(value));
|
|
769
|
+
} catch {
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function removeItem(key) {
|
|
773
|
+
try {
|
|
774
|
+
getStorage()?.removeItem(key);
|
|
775
|
+
} catch {
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
var getItemFromLocalStorage = getItem;
|
|
779
|
+
var storeItemInLocalStorage = setItem;
|
|
780
|
+
|
|
749
781
|
// src/components/search-filters/DropdownFilter.tsx
|
|
750
782
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
751
783
|
function DropdownFilter({
|
|
@@ -759,22 +791,44 @@ function DropdownFilter({
|
|
|
759
791
|
isSearchable = true,
|
|
760
792
|
isDisabled = false,
|
|
761
793
|
isLoading = false,
|
|
794
|
+
saveToLocalStorage = false,
|
|
762
795
|
...otherProps
|
|
763
796
|
}) {
|
|
764
797
|
const [searchParams, setSearchParams] = (0, import_react_router_dom2.useSearchParams)();
|
|
798
|
+
const hasRestoredFromStorage = (0, import_react2.useRef)(false);
|
|
799
|
+
(0, import_react2.useEffect)(() => {
|
|
800
|
+
if (!saveToLocalStorage || hasRestoredFromStorage.current) return;
|
|
801
|
+
hasRestoredFromStorage.current = true;
|
|
802
|
+
if (searchParams.get(name)) return;
|
|
803
|
+
const stored = getItemFromLocalStorage(name);
|
|
804
|
+
if (stored != null && stored !== "") {
|
|
805
|
+
setSearchParams((prev) => {
|
|
806
|
+
prev.set(name, String(stored));
|
|
807
|
+
return prev;
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
}, [saveToLocalStorage, name, searchParams, setSearchParams]);
|
|
765
811
|
const currentValue = searchParams.get(name);
|
|
766
812
|
const selectedOption = currentValue ? options?.find(
|
|
767
813
|
(option) => option[valueKey]?.toString() === currentValue
|
|
768
814
|
) ?? null : null;
|
|
769
815
|
const handleChange = (selected) => {
|
|
816
|
+
const selectedValue = selected && selected[valueKey] !== "" ? String(selected[valueKey]) : null;
|
|
770
817
|
setSearchParams((prev) => {
|
|
771
|
-
if (!
|
|
818
|
+
if (!selectedValue) {
|
|
772
819
|
prev.delete(name);
|
|
773
820
|
} else {
|
|
774
|
-
prev.set(name,
|
|
821
|
+
prev.set(name, selectedValue);
|
|
775
822
|
}
|
|
776
823
|
return prev;
|
|
777
824
|
});
|
|
825
|
+
if (saveToLocalStorage) {
|
|
826
|
+
if (selectedValue) {
|
|
827
|
+
storeItemInLocalStorage(name, selectedValue);
|
|
828
|
+
} else {
|
|
829
|
+
removeItem(name);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
778
832
|
};
|
|
779
833
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: cn(className), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
780
834
|
import_react_select.default,
|
|
@@ -865,7 +919,7 @@ function ResetFiltersButton({
|
|
|
865
919
|
}
|
|
866
920
|
|
|
867
921
|
// src/components/search-filters/SearchInput.tsx
|
|
868
|
-
var
|
|
922
|
+
var import_react3 = require("react");
|
|
869
923
|
var import_fi = require("react-icons/fi");
|
|
870
924
|
var import_react_router_dom4 = require("react-router-dom");
|
|
871
925
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -887,8 +941,8 @@ function SearchInput({
|
|
|
887
941
|
}) {
|
|
888
942
|
const [searchParams, setSearchParams] = (0, import_react_router_dom4.useSearchParams)();
|
|
889
943
|
const queryParam = searchParams.get(defaultParam) || defaultValue || "";
|
|
890
|
-
const [inputValue, setInputValue] = (0,
|
|
891
|
-
const debounceTimerRef = (0,
|
|
944
|
+
const [inputValue, setInputValue] = (0, import_react3.useState)(queryParam);
|
|
945
|
+
const debounceTimerRef = (0, import_react3.useRef)(null);
|
|
892
946
|
const updateSearchParams = (searchQuery) => {
|
|
893
947
|
if (searchQuery?.trim()) {
|
|
894
948
|
setSearchParams((prev) => {
|
|
@@ -927,10 +981,10 @@ function SearchInput({
|
|
|
927
981
|
updateSearchParams("");
|
|
928
982
|
}
|
|
929
983
|
};
|
|
930
|
-
(0,
|
|
984
|
+
(0, import_react3.useEffect)(() => {
|
|
931
985
|
setInputValue(queryParam);
|
|
932
986
|
}, [queryParam]);
|
|
933
|
-
(0,
|
|
987
|
+
(0, import_react3.useEffect)(() => {
|
|
934
988
|
return () => {
|
|
935
989
|
if (debounceTimerRef.current) {
|
|
936
990
|
clearTimeout(debounceTimerRef.current);
|
|
@@ -981,7 +1035,7 @@ function SearchInput({
|
|
|
981
1035
|
|
|
982
1036
|
// src/components/modal/Modal.tsx
|
|
983
1037
|
var import_framer_motion = require("framer-motion");
|
|
984
|
-
var
|
|
1038
|
+
var import_react4 = require("react");
|
|
985
1039
|
var import_react_dom = require("react-dom");
|
|
986
1040
|
var import_fa = require("react-icons/fa");
|
|
987
1041
|
var import_io5 = require("react-icons/io5");
|
|
@@ -1026,13 +1080,13 @@ function Modal({
|
|
|
1026
1080
|
customLoader = null,
|
|
1027
1081
|
footerClassName
|
|
1028
1082
|
}) {
|
|
1029
|
-
const modalRef = (0,
|
|
1083
|
+
const modalRef = (0, import_react4.useRef)(null);
|
|
1030
1084
|
const handleBackdropClick = (e) => {
|
|
1031
1085
|
if (e.target === e.currentTarget && closeOnBackdropClick) {
|
|
1032
1086
|
onClose();
|
|
1033
1087
|
}
|
|
1034
1088
|
};
|
|
1035
|
-
(0,
|
|
1089
|
+
(0, import_react4.useEffect)(() => {
|
|
1036
1090
|
const handleEscape = (e) => {
|
|
1037
1091
|
if (e.key === "Escape" && isOpen && closeOnEscape) {
|
|
1038
1092
|
onClose();
|
|
@@ -1276,7 +1330,7 @@ function CardSkeleton({
|
|
|
1276
1330
|
}
|
|
1277
1331
|
|
|
1278
1332
|
// src/components/tooltip/ToolTip.tsx
|
|
1279
|
-
var
|
|
1333
|
+
var import_react5 = require("react");
|
|
1280
1334
|
var import_react_tooltip = require("react-tooltip");
|
|
1281
1335
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1282
1336
|
var defaultTooltipStyle = {
|
|
@@ -1301,7 +1355,7 @@ function ToolTip({
|
|
|
1301
1355
|
disabled = false,
|
|
1302
1356
|
children
|
|
1303
1357
|
}) {
|
|
1304
|
-
const generatedId = (0,
|
|
1358
|
+
const generatedId = (0, import_react5.useId)();
|
|
1305
1359
|
const tooltipId = `eztrak-tooltip-${generatedId.replace(/:/g, "")}`;
|
|
1306
1360
|
const tooltipText = String(text ?? "");
|
|
1307
1361
|
if (disabled || !tooltipText) {
|
|
@@ -1400,7 +1454,7 @@ function TooltipText({
|
|
|
1400
1454
|
}
|
|
1401
1455
|
|
|
1402
1456
|
// src/components/cell-editor/CustomCellEditor.tsx
|
|
1403
|
-
var
|
|
1457
|
+
var import_react6 = require("react");
|
|
1404
1458
|
var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
|
|
1405
1459
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1406
1460
|
function ButtonSpinner() {
|
|
@@ -1447,7 +1501,7 @@ function normalizeInitialValue(initialValue, inputType) {
|
|
|
1447
1501
|
}
|
|
1448
1502
|
return initialValue;
|
|
1449
1503
|
}
|
|
1450
|
-
var CustomCellEditor = (0,
|
|
1504
|
+
var CustomCellEditor = (0, import_react6.forwardRef)(
|
|
1451
1505
|
({
|
|
1452
1506
|
value: initialValue,
|
|
1453
1507
|
name,
|
|
@@ -1472,11 +1526,11 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1472
1526
|
cancelButtonClassName
|
|
1473
1527
|
}, ref) => {
|
|
1474
1528
|
const normalizedInitial = normalizeInitialValue(initialValue, inputType);
|
|
1475
|
-
const [value, setValue] = (0,
|
|
1476
|
-
const [isLoading, setIsLoading] = (0,
|
|
1477
|
-
const inputRef = (0,
|
|
1478
|
-
const selectRef = (0,
|
|
1479
|
-
const normalizedOptions = (0,
|
|
1529
|
+
const [value, setValue] = (0, import_react6.useState)(normalizedInitial);
|
|
1530
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
|
|
1531
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
1532
|
+
const selectRef = (0, import_react6.useRef)(null);
|
|
1533
|
+
const normalizedOptions = (0, import_react6.useMemo)(() => {
|
|
1480
1534
|
if (customOptions && customOptions.length > 0) {
|
|
1481
1535
|
return customOptions.map((opt) => ({
|
|
1482
1536
|
value: String(opt[valueKey] ?? ""),
|
|
@@ -1486,13 +1540,13 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1486
1540
|
return dropdownOptions;
|
|
1487
1541
|
}, [customOptions, dropdownOptions, valueKey, labelKey]);
|
|
1488
1542
|
const isDropdown = inputType === "dropdown" || normalizedOptions.length > 0;
|
|
1489
|
-
(0,
|
|
1543
|
+
(0, import_react6.useImperativeHandle)(ref, () => ({
|
|
1490
1544
|
getValue: () => value,
|
|
1491
1545
|
isCancelBeforeStart: () => false,
|
|
1492
1546
|
isCancelAfterEnd: () => false,
|
|
1493
1547
|
isPopup: () => true
|
|
1494
1548
|
}));
|
|
1495
|
-
(0,
|
|
1549
|
+
(0, import_react6.useEffect)(() => {
|
|
1496
1550
|
if (isDropdown) {
|
|
1497
1551
|
selectRef.current?.focus();
|
|
1498
1552
|
return;
|
|
@@ -1629,8 +1683,8 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1629
1683
|
CustomCellEditor.displayName = "CustomCellEditor";
|
|
1630
1684
|
|
|
1631
1685
|
// src/components/popup-cell-renderer/PopupCellRenderer.tsx
|
|
1632
|
-
var
|
|
1633
|
-
var
|
|
1686
|
+
var import_react7 = require("react");
|
|
1687
|
+
var import_react8 = __toESM(require("@tippyjs/react"));
|
|
1634
1688
|
var import_bi = require("react-icons/bi");
|
|
1635
1689
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1636
1690
|
function PopupCellRenderer({
|
|
@@ -1644,7 +1698,7 @@ function PopupCellRenderer({
|
|
|
1644
1698
|
placement = "bottom-end",
|
|
1645
1699
|
tippyProps
|
|
1646
1700
|
}) {
|
|
1647
|
-
const [visible, setVisible] = (0,
|
|
1701
|
+
const [visible, setVisible] = (0, import_react7.useState)(false);
|
|
1648
1702
|
const show = () => setVisible(true);
|
|
1649
1703
|
const hide = () => setVisible(false);
|
|
1650
1704
|
const rowData = params?.data;
|
|
@@ -1654,7 +1708,7 @@ function PopupCellRenderer({
|
|
|
1654
1708
|
};
|
|
1655
1709
|
const content = typeof dropDownContent === "function" ? dropDownContent(handleAction) : dropDownContent;
|
|
1656
1710
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex h-full", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1657
|
-
|
|
1711
|
+
import_react8.default,
|
|
1658
1712
|
{
|
|
1659
1713
|
content,
|
|
1660
1714
|
visible,
|