@spteck/react-controls-v2 2.0.1 → 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/abstractions/IGraphProvider.d.ts +6 -0
- package/dist/abstractions/IGraphProvider.d.ts.map +1 -1
- package/dist/abstractions/providers/DefaultGraphClient.d.ts +1 -0
- package/dist/abstractions/providers/DefaultGraphClient.d.ts.map +1 -1
- package/dist/components/appDashboard/AppDashboard.d.ts.map +1 -1
- package/dist/components/userCard/useUserProfile.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -33
- package/dist/index.mjs.map +1 -1
- package/dist/providers.js +1 -1
- package/dist/providers.js.map +1 -1
- package/dist/providers.mjs +24 -0
- package/dist/providers.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25945,6 +25945,27 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
25945
25945
|
return null;
|
|
25946
25946
|
}
|
|
25947
25947
|
}, [graphClient]);
|
|
25948
|
+
const getUserPhoto = useCallback(async (id) => {
|
|
25949
|
+
if (!graphClient) {
|
|
25950
|
+
console.warn("Graph client not available");
|
|
25951
|
+
return void 0;
|
|
25952
|
+
}
|
|
25953
|
+
try {
|
|
25954
|
+
const photoBlob = await graphClient.getBlob(`/users/${id}/photo/$value`);
|
|
25955
|
+
if (photoBlob) {
|
|
25956
|
+
return new Promise((resolve, reject) => {
|
|
25957
|
+
const reader = new FileReader();
|
|
25958
|
+
reader.onloadend = () => resolve(reader.result);
|
|
25959
|
+
reader.onerror = reject;
|
|
25960
|
+
reader.readAsDataURL(photoBlob);
|
|
25961
|
+
});
|
|
25962
|
+
}
|
|
25963
|
+
return void 0;
|
|
25964
|
+
} catch (error) {
|
|
25965
|
+
console.debug("No photo available for user:", id);
|
|
25966
|
+
return void 0;
|
|
25967
|
+
}
|
|
25968
|
+
}, [graphClient]);
|
|
25948
25969
|
const fetchUser = useCallback(async () => {
|
|
25949
25970
|
var _a3;
|
|
25950
25971
|
if (!userId) {
|
|
@@ -25962,6 +25983,7 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
25962
25983
|
const fetchedUser = await getUserById(userId);
|
|
25963
25984
|
if (!fetchedUser) return;
|
|
25964
25985
|
let presence = { availability: "Offline", activity: "Offline" };
|
|
25986
|
+
let userPhoto;
|
|
25965
25987
|
try {
|
|
25966
25988
|
if (fetchedUser.id) {
|
|
25967
25989
|
const fetchedPresence = await getUserPresence(fetchedUser.id);
|
|
@@ -25988,7 +26010,18 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
25988
26010
|
);
|
|
25989
26011
|
}
|
|
25990
26012
|
}
|
|
25991
|
-
|
|
26013
|
+
try {
|
|
26014
|
+
if (fetchedUser.id) {
|
|
26015
|
+
userPhoto = await getUserPhoto(fetchedUser.id);
|
|
26016
|
+
}
|
|
26017
|
+
} catch (error) {
|
|
26018
|
+
logError(
|
|
26019
|
+
"fetchUser: Error fetching user photo",
|
|
26020
|
+
error,
|
|
26021
|
+
ErrorType.Warning
|
|
26022
|
+
);
|
|
26023
|
+
}
|
|
26024
|
+
const userData = { ...fetchedUser, presence, userPhoto };
|
|
25992
26025
|
userCache.set(userId, {
|
|
25993
26026
|
data: userData,
|
|
25994
26027
|
timestamp: now,
|
|
@@ -26000,7 +26033,7 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
26000
26033
|
} finally {
|
|
26001
26034
|
setLoading(false);
|
|
26002
26035
|
}
|
|
26003
|
-
}, [userId, getUserById, getUserPresence, logError]);
|
|
26036
|
+
}, [userId, getUserById, getUserPresence, getUserPhoto, logError]);
|
|
26004
26037
|
const checkUserPresence = useCallback(async () => {
|
|
26005
26038
|
var _a3;
|
|
26006
26039
|
if (!userId || !user) return;
|
|
@@ -26831,20 +26864,26 @@ const AppDashboard = ({
|
|
|
26831
26864
|
const layoutCacheKey = `${cacheKeyPrefix}-layout-settings`;
|
|
26832
26865
|
const orderCacheKey = `${cacheKeyPrefix}-card-order`;
|
|
26833
26866
|
const { getCachedData, setCachedData } = useIndexedDBCache();
|
|
26834
|
-
const getData = (key) => getCachedData(key);
|
|
26835
|
-
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
|
+
);
|
|
26836
26872
|
const {
|
|
26837
26873
|
getCachedData: getOrderCachedData,
|
|
26838
26874
|
setCachedData: setOrderCachedData
|
|
26839
26875
|
} = useIndexedDBCache();
|
|
26840
|
-
const getOrderData = (key) => getOrderCachedData(key);
|
|
26841
|
-
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
|
+
);
|
|
26842
26881
|
const [cardContainers, setCardContainers] = useState([]);
|
|
26843
26882
|
const [sizes, setSizes] = useState({});
|
|
26844
26883
|
const dragItem = useRef(null);
|
|
26845
26884
|
const dragOverItem = useRef(null);
|
|
26846
26885
|
const containerRef = useRef(null);
|
|
26847
|
-
|
|
26886
|
+
useEffect(() => {
|
|
26848
26887
|
const initializeData = async () => {
|
|
26849
26888
|
try {
|
|
26850
26889
|
let orderedCards = cards;
|
|
@@ -26896,10 +26935,10 @@ const AppDashboard = ({
|
|
|
26896
26935
|
setSizes(fallbackSizes);
|
|
26897
26936
|
}
|
|
26898
26937
|
};
|
|
26899
|
-
initializeData();
|
|
26900
|
-
}, [cards, enableCache, layoutCacheKey, orderCacheKey]);
|
|
26938
|
+
void initializeData();
|
|
26939
|
+
}, [cards, enableCache, layoutCacheKey, orderCacheKey, getData, getOrderData]);
|
|
26901
26940
|
useEffect(() => {
|
|
26902
|
-
if (!enableCache) return;
|
|
26941
|
+
if (!enableCache || Object.keys(sizes).length === 0) return;
|
|
26903
26942
|
const saveSizesToCache = async () => {
|
|
26904
26943
|
try {
|
|
26905
26944
|
await setData(layoutCacheKey, sizes);
|
|
@@ -26907,12 +26946,10 @@ const AppDashboard = ({
|
|
|
26907
26946
|
console.warn("Failed to save dashboard layout to cache:", error);
|
|
26908
26947
|
}
|
|
26909
26948
|
};
|
|
26910
|
-
|
|
26911
|
-
saveSizesToCache();
|
|
26912
|
-
}
|
|
26949
|
+
void saveSizesToCache();
|
|
26913
26950
|
}, [sizes, enableCache, layoutCacheKey, setData]);
|
|
26914
26951
|
useEffect(() => {
|
|
26915
|
-
if (!enableCache) return;
|
|
26952
|
+
if (!enableCache || cardContainers.length === 0) return;
|
|
26916
26953
|
const saveOrderToCache = async () => {
|
|
26917
26954
|
try {
|
|
26918
26955
|
const cardOrder = cardContainers.map((card) => card.id);
|
|
@@ -26921,9 +26958,7 @@ const AppDashboard = ({
|
|
|
26921
26958
|
console.warn("Failed to save dashboard order to cache:", error);
|
|
26922
26959
|
}
|
|
26923
26960
|
};
|
|
26924
|
-
|
|
26925
|
-
saveOrderToCache();
|
|
26926
|
-
}
|
|
26961
|
+
void saveOrderToCache();
|
|
26927
26962
|
}, [cardContainers, enableCache, orderCacheKey, setOrderData]);
|
|
26928
26963
|
useEffect(() => {
|
|
26929
26964
|
if (containerWidth <= MINIMUM_DASHBOARD_WIDTH) {
|
|
@@ -26996,21 +27031,16 @@ const AppDashboard = ({
|
|
|
26996
27031
|
return cardContainers.map((cardContainer, idx) => {
|
|
26997
27032
|
var _a3, _b2, _c2, _d2;
|
|
26998
27033
|
const shouldShowZoom = cardContainer.showZoom !== false && showZoom;
|
|
26999
|
-
|
|
27000
|
-
|
|
27001
|
-
|
|
27002
|
-
|
|
27003
|
-
|
|
27004
|
-
|
|
27005
|
-
|
|
27006
|
-
|
|
27007
|
-
|
|
27008
|
-
|
|
27009
|
-
IsOpen: false,
|
|
27010
|
-
onChange: (v) => handleZoomSelect(cardContainer.id, v)
|
|
27011
|
-
}
|
|
27012
|
-
);
|
|
27013
|
-
}
|
|
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);
|
|
27014
27044
|
return /* @__PURE__ */ jsx$2(
|
|
27015
27045
|
"div",
|
|
27016
27046
|
{
|
|
@@ -27029,7 +27059,7 @@ const AppDashboard = ({
|
|
|
27029
27059
|
/* @__PURE__ */ jsx$2(
|
|
27030
27060
|
CardHeader,
|
|
27031
27061
|
{
|
|
27032
|
-
header: /* @__PURE__ */ jsxs$1("
|
|
27062
|
+
header: /* @__PURE__ */ jsxs$1(StackV2, { gap: "0px", children: [
|
|
27033
27063
|
/* @__PURE__ */ jsx$2(Text, { weight: "semibold", size: 400, children: cardContainer.cardTitle }),
|
|
27034
27064
|
cardContainer.cardDescription && /* @__PURE__ */ jsx$2(Text, { className: styles2.cardDescription, size: 200, children: cardContainer.cardDescription })
|
|
27035
27065
|
] }),
|