@spteck/react-controls-v2 2.0.2 → 2.0.3
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/components/appDashboard/AppDashboard.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -26864,20 +26864,26 @@ const AppDashboard = ({
|
|
|
26864
26864
|
const layoutCacheKey = `${cacheKeyPrefix}-layout-settings`;
|
|
26865
26865
|
const orderCacheKey = `${cacheKeyPrefix}-card-order`;
|
|
26866
26866
|
const { getCachedData, setCachedData } = useIndexedDBCache();
|
|
26867
|
-
const getData = (key) => getCachedData(key);
|
|
26868
|
-
const setData = (
|
|
26867
|
+
const getData = useCallback((key) => getCachedData(key), [getCachedData]);
|
|
26868
|
+
const setData = useCallback(
|
|
26869
|
+
(key, value) => setCachedData(key, value, CACHE_EXPIRATION_DAYS * 24 * 60),
|
|
26870
|
+
[setCachedData]
|
|
26871
|
+
);
|
|
26869
26872
|
const {
|
|
26870
26873
|
getCachedData: getOrderCachedData,
|
|
26871
26874
|
setCachedData: setOrderCachedData
|
|
26872
26875
|
} = useIndexedDBCache();
|
|
26873
|
-
const getOrderData = (key) => getOrderCachedData(key);
|
|
26874
|
-
const setOrderData = (
|
|
26876
|
+
const getOrderData = useCallback((key) => getOrderCachedData(key), [getOrderCachedData]);
|
|
26877
|
+
const setOrderData = useCallback(
|
|
26878
|
+
(key, value) => setOrderCachedData(key, value, CACHE_EXPIRATION_DAYS * 24 * 60),
|
|
26879
|
+
[setOrderCachedData]
|
|
26880
|
+
);
|
|
26875
26881
|
const [cardContainers, setCardContainers] = useState([]);
|
|
26876
26882
|
const [sizes, setSizes] = useState({});
|
|
26877
26883
|
const dragItem = useRef(null);
|
|
26878
26884
|
const dragOverItem = useRef(null);
|
|
26879
26885
|
const containerRef = useRef(null);
|
|
26880
|
-
|
|
26886
|
+
useEffect(() => {
|
|
26881
26887
|
const initializeData = async () => {
|
|
26882
26888
|
try {
|
|
26883
26889
|
let orderedCards = cards;
|
|
@@ -26929,10 +26935,10 @@ const AppDashboard = ({
|
|
|
26929
26935
|
setSizes(fallbackSizes);
|
|
26930
26936
|
}
|
|
26931
26937
|
};
|
|
26932
|
-
initializeData();
|
|
26933
|
-
}, [cards, enableCache, layoutCacheKey, orderCacheKey]);
|
|
26938
|
+
void initializeData();
|
|
26939
|
+
}, [cards, enableCache, layoutCacheKey, orderCacheKey, getData, getOrderData]);
|
|
26934
26940
|
useEffect(() => {
|
|
26935
|
-
if (!enableCache) return;
|
|
26941
|
+
if (!enableCache || Object.keys(sizes).length === 0) return;
|
|
26936
26942
|
const saveSizesToCache = async () => {
|
|
26937
26943
|
try {
|
|
26938
26944
|
await setData(layoutCacheKey, sizes);
|
|
@@ -26940,12 +26946,10 @@ const AppDashboard = ({
|
|
|
26940
26946
|
console.warn("Failed to save dashboard layout to cache:", error);
|
|
26941
26947
|
}
|
|
26942
26948
|
};
|
|
26943
|
-
|
|
26944
|
-
saveSizesToCache();
|
|
26945
|
-
}
|
|
26949
|
+
void saveSizesToCache();
|
|
26946
26950
|
}, [sizes, enableCache, layoutCacheKey, setData]);
|
|
26947
26951
|
useEffect(() => {
|
|
26948
|
-
if (!enableCache) return;
|
|
26952
|
+
if (!enableCache || cardContainers.length === 0) return;
|
|
26949
26953
|
const saveOrderToCache = async () => {
|
|
26950
26954
|
try {
|
|
26951
26955
|
const cardOrder = cardContainers.map((card) => card.id);
|
|
@@ -26954,9 +26958,7 @@ const AppDashboard = ({
|
|
|
26954
26958
|
console.warn("Failed to save dashboard order to cache:", error);
|
|
26955
26959
|
}
|
|
26956
26960
|
};
|
|
26957
|
-
|
|
26958
|
-
saveOrderToCache();
|
|
26959
|
-
}
|
|
26961
|
+
void saveOrderToCache();
|
|
26960
26962
|
}, [cardContainers, enableCache, orderCacheKey, setOrderData]);
|
|
26961
26963
|
useEffect(() => {
|
|
26962
26964
|
if (containerWidth <= MINIMUM_DASHBOARD_WIDTH) {
|
|
@@ -27029,21 +27031,16 @@ const AppDashboard = ({
|
|
|
27029
27031
|
return cardContainers.map((cardContainer, idx) => {
|
|
27030
27032
|
var _a3, _b2, _c2, _d2;
|
|
27031
27033
|
const shouldShowZoom = cardContainer.showZoom !== false && showZoom;
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
|
|
27035
|
-
|
|
27036
|
-
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
IsOpen: false,
|
|
27043
|
-
onChange: (v) => handleZoomSelect(cardContainer.id, v)
|
|
27044
|
-
}
|
|
27045
|
-
);
|
|
27046
|
-
}
|
|
27034
|
+
const headerAction = cardContainer.headerAction || (shouldShowZoom ? /* @__PURE__ */ jsx$2(
|
|
27035
|
+
SelectZoom,
|
|
27036
|
+
{
|
|
27037
|
+
values: sizes[cardContainer.id] || defaultColsAndRowSpanBasedOnNumberColumns[cardContainer.id] || { spanCols: 1, spanRows: 1 },
|
|
27038
|
+
maxCols: maxZoom,
|
|
27039
|
+
maxRows: maxSpanRows,
|
|
27040
|
+
IsOpen: false,
|
|
27041
|
+
onChange: (v) => handleZoomSelect(cardContainer.id, v)
|
|
27042
|
+
}
|
|
27043
|
+
) : void 0);
|
|
27047
27044
|
return /* @__PURE__ */ jsx$2(
|
|
27048
27045
|
"div",
|
|
27049
27046
|
{
|
|
@@ -27062,7 +27059,7 @@ const AppDashboard = ({
|
|
|
27062
27059
|
/* @__PURE__ */ jsx$2(
|
|
27063
27060
|
CardHeader,
|
|
27064
27061
|
{
|
|
27065
|
-
header: /* @__PURE__ */ jsxs$1("
|
|
27062
|
+
header: /* @__PURE__ */ jsxs$1(StackV2, { gap: "0px", children: [
|
|
27066
27063
|
/* @__PURE__ */ jsx$2(Text, { weight: "semibold", size: 400, children: cardContainer.cardTitle }),
|
|
27067
27064
|
cardContainer.cardDescription && /* @__PURE__ */ jsx$2(Text, { className: styles2.cardDescription, size: 200, children: cardContainer.cardDescription })
|
|
27068
27065
|
] }),
|