@bindu-dashing/dam-solution-v2 5.8.180 → 5.8.181

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.
@@ -72,33 +72,33 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
72
72
  }
73
73
  return params;
74
74
  };
75
- console.log('## folderId', parentFolderId);
75
+ const effectiveFolderId = parentFolderId || folderId || id || rootFolderId || '';
76
+ const prevEffectiveFolderIdRef = useRef(null);
77
+ const folderIdChanged = prevEffectiveFolderIdRef.current !== null &&
78
+ prevEffectiveFolderIdRef.current !== effectiveFolderId;
79
+ prevEffectiveFolderIdRef.current = effectiveFolderId;
76
80
  const folderParams = merge({}, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ page: DEFAULT_PAGE }, (type ? { category: type } : {})), (!!imagePicker
77
81
  ? {
78
82
  includeSubFolders: get(imagePicker, "includeSubFolders", true),
79
83
  teamVisibility: get(imagePicker, "teamVisibility", true),
80
84
  }
81
- : {})), (!!searchKey && !!searchValue ? getSearchParams() : {})), (!!metadataKey && !!metadataValue
85
+ : {})), (!folderIdChanged && !!searchKey && !!searchValue ? getSearchParams() : {})), (!folderIdChanged && !!metadataKey && !!metadataValue
82
86
  ? { metadataKey: metadataKey, metadataValue: metadataValue }
83
- : {})), (!!folderSearch ? { name: folderSearch } : {})), (!!globalSearch && ((parentFolderId || folderId || id) === rootFolderId || !(parentFolderId || folderId || id))
87
+ : {})), (!folderIdChanged && !!folderSearch ? { name: folderSearch } : {})), (!folderIdChanged && !!globalSearch && ((parentFolderId || folderId || id) === rootFolderId || !(parentFolderId || folderId || id))
84
88
  ? { globalSearch }
85
- : {})), { sortBy: sortBy, sortOrder: sortOrder }), Object.assign(Object.assign({}, (selectedDateKey === "custom" && customDateRange && customDateRange[0] && customDateRange[1]
89
+ : {})), { sortBy: sortBy, sortOrder: sortOrder }), Object.assign(Object.assign({}, (!folderIdChanged && selectedDateKey === "custom" && customDateRange && customDateRange[0] && customDateRange[1]
86
90
  ? {
87
91
  startDate: dayjs(customDateRange[0]).format(DATE_FORMAT),
88
92
  endDate: dayjs(customDateRange[1]).format(DATE_FORMAT),
89
93
  }
90
- : getDateRangeFromKey(selectedDateKey))), (!!selectedType ? { type: selectedType } : {})));
91
- const effectiveFolderId = parentFolderId || folderId || id || rootFolderId || '';
92
- const prevEffectiveFolderIdRef = useRef(null);
94
+ : folderIdChanged ? {} : getDateRangeFromKey(selectedDateKey))), (!folderIdChanged && !!selectedType ? { type: selectedType } : {})));
93
95
  useEffect(() => {
94
- const prev = prevEffectiveFolderIdRef.current;
95
- prevEffectiveFolderIdRef.current = effectiveFolderId;
96
- if (prev != null && prev !== effectiveFolderId) {
96
+ if (folderIdChanged) {
97
97
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { selectedType: "", selectedDateKey: "", customDateRange: null, searchKey: "", searchValue: "", metadataKey: "", metadataValue: "", folderSearch: "" })));
98
98
  if (setGlobalSearch)
99
99
  setGlobalSearch("");
100
100
  }
101
- }, [effectiveFolderId, setGlobalSearch]);
101
+ }, [effectiveFolderId, folderIdChanged, setGlobalSearch]);
102
102
  const { data: foldersPaginatedData, isLoading, hasNextPage, fetchNextPage, refetch, isFetching, error, } = useFolders(api, generateFoldersQueryKey(type), folderParams, effectiveFolderId);
103
103
  useEffect(() => {
104
104
  if (typeof window !== "undefined") {
@@ -31,6 +31,7 @@ const FileDetails = ({ open, handleClose, file, files, fileIds, onCloseSelection
31
31
  console.log("## FileDetails - files:", files, "file:", file, "initialFile:", initialFile, "fileIds:", fileIds, "initialFileId:", initialFileId);
32
32
  const { id } = useAppParams();
33
33
  const damConfig = useDamConfig();
34
+ const headerHeight = get(damConfig, "headerHeight", 0) || 0;
34
35
  const api = useMemo(() => createApiClient(damConfig), [damConfig]);
35
36
  const [state, setState] = useState({
36
37
  visible: false,
@@ -110,16 +111,19 @@ const FileDetails = ({ open, handleClose, file, files, fileIds, onCloseSelection
110
111
  }, [open]);
111
112
  if (!open && !visible)
112
113
  return null;
113
- const modalContent = (_jsxs("div", { className: `md-lib-fixed md-lib-inset-0 md-lib-z-[1000] md-lib-w-screen md-lib-h-screen md-lib-bg-white dark:md-lib-bg-darkPrimary md-lib-text-black dark:md-lib-text-white md-lib-overflow-auto md-lib-transform md-lib-transition-all md-lib-duration-300 md-lib-ease-in-out ${open && visible
114
+ const modalStyle = headerHeight > 0
115
+ ? { top: headerHeight, left: 0, right: 0, bottom: 0, height: `calc(100vh - ${headerHeight}px)` }
116
+ : undefined;
117
+ const modalContent = (_jsxs("div", { className: `md-lib-fixed md-lib-z-[1000] md-lib-w-screen md-lib-bg-white dark:md-lib-bg-darkPrimary md-lib-text-black dark:md-lib-text-white md-lib-flex md-lib-flex-col md-lib-transform md-lib-transition-all md-lib-duration-300 md-lib-ease-in-out ${headerHeight === 0 ? "md-lib-inset-0 md-lib-h-screen" : ""} ${open && visible
114
118
  ? "md-lib-opacity-100 md-lib-translate-y-0"
115
- : "md-lib-opacity-0 md-lib-translate-y-4"}`, onTransitionEnd: () => {
119
+ : "md-lib-opacity-0 md-lib-translate-y-4"}`, style: modalStyle, onTransitionEnd: () => {
116
120
  if (!open)
117
121
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { visible: false })));
118
- }, children: [_jsx(FileDetailsHeader, { handleClose: handleClose, file: currentFile, onCloseSelection: onCloseSelection }), isFetching ? (_jsx(Loader, {})) : (_jsx(FileViewer, { file: currentFile, hasPrev: (!!files && currentIndex > 0) ||
119
- (!!fileIds && fileIds.length > 1 && currentIndex > 0) ||
120
- !!get(currentFile, "prevFileId"), hasNext: (!!files && currentIndex < get(files, "length", 0) - 1) ||
121
- (!!fileIds && fileIds.length > 1 && currentIndex < fileIds.length - 1) ||
122
- !!get(currentFile, "nextFileId"), onPrev: handlePrevious, onNext: handleNext, handleClose: handleClose }))] }));
122
+ }, children: [_jsx("div", { className: "md-lib-shrink-0", children: _jsx(FileDetailsHeader, { handleClose: handleClose, file: currentFile, onCloseSelection: onCloseSelection }) }), _jsx("div", { className: "md-lib-flex-1 md-lib-min-h-0 md-lib-overflow-auto", children: isFetching ? (_jsx(Loader, {})) : (_jsx(FileViewer, { file: currentFile, hasPrev: (!!files && currentIndex > 0) ||
123
+ (!!fileIds && fileIds.length > 1 && currentIndex > 0) ||
124
+ !!get(currentFile, "prevFileId"), hasNext: (!!files && currentIndex < get(files, "length", 0) - 1) ||
125
+ (!!fileIds && fileIds.length > 1 && currentIndex < fileIds.length - 1) ||
126
+ !!get(currentFile, "nextFileId"), onPrev: handlePrevious, onNext: handleNext, handleClose: handleClose })) })] }));
123
127
  return ReactDOM.createPortal(modalContent, document.body);
124
128
  };
125
129
  export default FileDetails;
@@ -12,5 +12,7 @@ declare function App(props: {
12
12
  showSubfolders?: boolean;
13
13
  userEmail?: string;
14
14
  onFolderChange?: (folderId: string) => void;
15
+ /** Height of host app header (e.g. navbar) in px. When set, preview modal positions below it instead of covering. */
16
+ headerHeight?: number;
15
17
  }): JSX.Element;
16
18
  export default App;
@@ -23,6 +23,7 @@ function App(props) {
23
23
  parentId: props === null || props === void 0 ? void 0 : props.parentId,
24
24
  showSubfolders: props === null || props === void 0 ? void 0 : props.showSubfolders,
25
25
  routerVersion: props === null || props === void 0 ? void 0 : props.routerVersion,
26
+ headerHeight: props === null || props === void 0 ? void 0 : props.headerHeight,
26
27
  }), [
27
28
  props === null || props === void 0 ? void 0 : props.accessKey,
28
29
  props === null || props === void 0 ? void 0 : props.secretKey,
@@ -35,6 +36,7 @@ function App(props) {
35
36
  props === null || props === void 0 ? void 0 : props.id,
36
37
  props === null || props === void 0 ? void 0 : props.parentId,
37
38
  props === null || props === void 0 ? void 0 : props.showSubfolders,
39
+ props === null || props === void 0 ? void 0 : props.headerHeight,
38
40
  ]);
39
41
  const [folders, setFolders] = useState([]);
40
42
  if (typeof window !== "undefined" && !window.process) {
@@ -19,7 +19,7 @@ import { SUBSCRIPTION_EXPIRED_ERROR_MESSAGE } from "./appConstants";
19
19
  const DamConfigContext = createContext(null);
20
20
  export const DamConfigProvider = ({ children, config }) => {
21
21
  // console.log(config);
22
- const { damAccessKey, secretKey, subdomain, teamIds, appType, initialRootFolderId } = config;
22
+ const { damAccessKey, secretKey, subdomain, teamIds, appType, initialRootFolderId, headerHeight } = config;
23
23
  const [accessToken, setAccessToken] = useState(null);
24
24
  const [user, setDamUser] = useState(null);
25
25
  const [brand, setBrand] = useState(null);
@@ -148,6 +148,7 @@ export const DamConfigProvider = ({ children, config }) => {
148
148
  rootFolderId,
149
149
  teams,
150
150
  isAdmin,
151
+ headerHeight: headerHeight !== null && headerHeight !== void 0 ? headerHeight : 0,
151
152
  }, children: loading ? (_jsx(Loader, {})) : (_jsx(_Fragment, { children: showPaymentErr ? (_jsx("div", { className: "flex items-center justify-center h-[calc(100vh-200px)]", children: _jsx("p", { className: "text-sm font-medium text-textColor dark:text-darkTextColor", children: SUBSCRIPTION_EXPIRED_ERROR_MESSAGE }) })) : (children) })) }));
152
153
  };
153
154
  export const useDamConfig = () => useContext(DamConfigContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.180",
3
+ "version": "5.8.181",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",