@orangelogic/orange-dam-content-browser-sdk 2.1.55 → 2.2.0-beta

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.
Files changed (281) hide show
  1. package/.env +1 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +82 -0
  4. package/.releaserc +17 -0
  5. package/.travis.yml +20 -0
  6. package/CBSDKdemo.html +315 -0
  7. package/GitVersion.yml +18 -0
  8. package/azure-pipeline.yaml +94 -0
  9. package/clientlib.config.js +36 -0
  10. package/config/env.js +105 -0
  11. package/config/getHttpsConfig.js +67 -0
  12. package/config/jest/babelTransform.js +30 -0
  13. package/config/jest/cssTransform.js +14 -0
  14. package/config/jest/fileTransform.js +41 -0
  15. package/config/modules.js +135 -0
  16. package/config/paths.js +79 -0
  17. package/config/webpack/persistentCache/createEnvironmentHash.js +10 -0
  18. package/config/webpack.config.js +762 -0
  19. package/config/webpackDevServer.config.js +128 -0
  20. package/config-overrides.js +8 -0
  21. package/gab_extension/GAB.html +85 -0
  22. package/gab_extension/GoogleChrome/manifest.json +28 -0
  23. package/gab_extension/GoogleChrome/src/assets/icon48.png +0 -0
  24. package/gab_extension/GoogleChrome/src/background/index.js +6 -0
  25. package/gab_extension/GoogleChrome/src/scripts/index.js +347 -0
  26. package/gab_extension/MozillaFirefox/manifest.json +20 -0
  27. package/gab_extension/MozillaFirefox/src/assets/icon.png +0 -0
  28. package/gab_extension/MozillaFirefox/src/background/index.js +5 -0
  29. package/gab_extension/MozillaFirefox/src/scripts/index.js +347 -0
  30. package/gab_extension/README.md +11 -0
  31. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.pbxproj +927 -0
  32. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  33. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  34. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcuserdata/oldevmac01.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  35. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/xcuserdata/oldevmac01.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  36. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  37. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +63 -0
  38. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/Contents.json +6 -0
  39. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +20 -0
  40. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Base.lproj/Main.html +23 -0
  41. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Icon.png +0 -0
  42. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Script.js +24 -0
  43. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Style.css +61 -0
  44. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/ViewController.swift +81 -0
  45. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (Extension)/SafariWebExtensionHandler.swift +26 -0
  46. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/AppDelegate.swift +24 -0
  47. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
  48. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/Main.storyboard +38 -0
  49. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Info.plist +27 -0
  50. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/SceneDelegate.swift +18 -0
  51. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (Extension)/Info.plist +13 -0
  52. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/AppDelegate.swift +21 -0
  53. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Base.lproj/Main.storyboard +125 -0
  54. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Info.plist +8 -0
  55. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Orange DAM Asset Browser Extension.entitlements +12 -0
  56. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Info.plist +13 -0
  57. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Orange DAM Asset Browser Extension.entitlements +10 -0
  58. package/package.json +8 -49
  59. package/public/index.html +92 -0
  60. package/scripts/build.js +218 -0
  61. package/scripts/start.js +154 -0
  62. package/scripts/test.js +53 -0
  63. package/src/App.tsx +98 -0
  64. package/src/AppContext.ts +18 -0
  65. package/src/GlobalConfigContext.ts +46 -0
  66. package/src/components/ArrayClamp/ArrayClamp.styled.ts +42 -0
  67. package/src/components/ArrayClamp/ArrayClamp.tsx +167 -0
  68. package/src/components/ArrayClamp/index.ts +1 -0
  69. package/src/components/Browser/Browser.styled.ts +82 -0
  70. package/src/components/Browser/Browser.tsx +284 -0
  71. package/src/components/Browser/BrowserItem.tsx +98 -0
  72. package/src/components/ControlBar/ControlBar.constants.tsx +66 -0
  73. package/src/components/ControlBar/ControlBar.styled.ts +82 -0
  74. package/src/components/ControlBar/ControlBar.tsx +528 -0
  75. package/src/components/ControlBar/Facet/Facet.tsx +113 -0
  76. package/src/components/ControlBar/Facet/index.ts +1 -0
  77. package/src/components/FormatDialog/CropPreviewer/CropPreviewer.tsx +224 -0
  78. package/{build/components/FormatDialog/CropPreviewer/index.d.ts → src/components/FormatDialog/CropPreviewer/index.ts} +1 -1
  79. package/src/components/FormatDialog/CustomRendition/CustomRendition.constants.ts +24 -0
  80. package/src/components/FormatDialog/CustomRendition/CustomRendition.styled.ts +57 -0
  81. package/src/components/FormatDialog/CustomRendition/CustomRendition.tsx +178 -0
  82. package/src/components/FormatDialog/CustomRendition/index.ts +1 -0
  83. package/src/components/FormatDialog/CustomRendition/transformations/Crop.tsx +249 -0
  84. package/src/components/FormatDialog/CustomRendition/transformations/Extension.tsx +54 -0
  85. package/src/components/FormatDialog/CustomRendition/transformations/Format.tsx +86 -0
  86. package/src/components/FormatDialog/CustomRendition/transformations/Resize.tsx +176 -0
  87. package/src/components/FormatDialog/CustomRendition/transformations/Rotate.tsx +101 -0
  88. package/{build/components/FormatDialog/CustomRendition/transformations/index.d.ts → src/components/FormatDialog/CustomRendition/transformations/index.ts} +1 -3
  89. package/src/components/FormatDialog/FormatDialog.styled.ts +137 -0
  90. package/src/components/FormatDialog/FormatDialog.tsx +1533 -0
  91. package/src/components/FormatDialog/Previewer/Previewer.styled.ts +31 -0
  92. package/src/components/FormatDialog/Previewer/Previewer.tsx +143 -0
  93. package/src/components/FormatDialog/Previewer/index.ts +1 -0
  94. package/src/components/FormatDialog/ProxyMenu/ProxyMenu.styled.ts +88 -0
  95. package/src/components/FormatDialog/ProxyMenu/ProxyMenu.tsx +74 -0
  96. package/src/components/FormatDialog/ProxyMenu/index.ts +1 -0
  97. package/src/components/FormatDialog/TrackingParameters/TrackingParameters.tsx +59 -0
  98. package/src/components/FormatDialog/TrackingParameters/index.ts +1 -0
  99. package/src/components/FormatDialog/index.ts +1 -0
  100. package/src/components/Header/Header.styled.ts +51 -0
  101. package/src/components/Header/Header.tsx +118 -0
  102. package/src/components/Loader/Loader.tsx +37 -0
  103. package/src/components/Loader/index.ts +1 -0
  104. package/src/components/NoResult/NoResult.tsx +37 -0
  105. package/src/components/NoResult/index.tsx +1 -0
  106. package/src/components/Result/AssetCard/AssetCard.styled.ts +120 -0
  107. package/src/components/Result/AssetCard/AssetCard.tsx +192 -0
  108. package/src/components/Result/AssetCard/AssetCardWrapper.styled.ts +35 -0
  109. package/src/components/Result/AssetCard/AssetCardWrapper.tsx +165 -0
  110. package/src/components/Result/AssetCard/index.ts +1 -0
  111. package/src/components/Result/AssetPreview/AssetPreview.styled.ts +108 -0
  112. package/src/components/Result/AssetPreview/AssetPreview.tsx +78 -0
  113. package/src/components/Result/AssetPreview/ImagePreview/ImagePreview.tsx +42 -0
  114. package/src/components/Result/AssetPreview/ImagePreview/index.ts +1 -0
  115. package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.ts +23 -0
  116. package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.tsx +28 -0
  117. package/src/components/Result/AssetPreview/OtherPreview/index.ts +1 -0
  118. package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.tsx +132 -0
  119. package/src/components/Result/AssetPreview/VideoPreview/index.ts +1 -0
  120. package/src/components/Result/AssetPreview/index.ts +1 -0
  121. package/src/consts/asset.ts +16 -0
  122. package/src/consts/data.ts +17 -0
  123. package/src/index.tsx +305 -0
  124. package/src/page/Authenticate/Authenticate.tsx +232 -0
  125. package/src/page/Authenticate/ConnectingBackground.tsx +44 -0
  126. package/src/page/Authenticate/index.tsx +94 -0
  127. package/src/page/Home/Home.styled.ts +46 -0
  128. package/src/page/Home/Home.tsx +941 -0
  129. package/src/react-web-component.d.ts +4617 -0
  130. package/src/store/assets/assets.api.ts +167 -0
  131. package/src/store/assets/assets.service.ts +223 -0
  132. package/src/store/assets/assets.slice.ts +104 -0
  133. package/src/store/auth/auth.service.ts +71 -0
  134. package/src/store/auth/auth.slice.ts +295 -0
  135. package/src/store/index.ts +27 -0
  136. package/src/store/search/search.api.ts +319 -0
  137. package/src/store/search/search.slice.ts +28 -0
  138. package/src/store/user/user.api.ts +29 -0
  139. package/src/styles.css +42 -0
  140. package/src/types/assets.ts +71 -0
  141. package/src/types/auth.ts +42 -0
  142. package/src/types/common.ts +11 -0
  143. package/src/types/download.ts +8 -0
  144. package/src/types/navigation.ts +3 -0
  145. package/src/types/search.ts +116 -0
  146. package/{build/types/storage.d.ts → src/types/storage.ts} +1 -1
  147. package/src/types/user.ts +6 -0
  148. package/src/utils/api.ts +186 -0
  149. package/src/utils/array.ts +25 -0
  150. package/src/utils/constants.ts +12 -0
  151. package/src/utils/fetch.ts +116 -0
  152. package/src/utils/getRequestUrl.ts +15 -0
  153. package/src/utils/hooks.ts +36 -0
  154. package/src/utils/icon.ts +22 -0
  155. package/src/utils/image.ts +157 -0
  156. package/src/utils/number.ts +11 -0
  157. package/src/utils/rotate.ts +23 -0
  158. package/src/utils/storage.ts +184 -0
  159. package/src/utils/string.ts +24 -0
  160. package/src/view/AssetsPicker.tsx +24 -0
  161. package/src/web-component.d.ts +8151 -0
  162. package/tsconfig.eslint.json +10 -0
  163. package/tsconfig.json +37 -0
  164. package/build/ApiService.d.ts +0 -15
  165. package/build/App.d.ts +0 -62
  166. package/build/AppContext.d.ts +0 -18
  167. package/build/GlobalConfigContext.d.ts +0 -32
  168. package/build/OrangeDAMContentBrowserSDK.min.css +0 -2
  169. package/build/OrangeDAMContentBrowserSDK.min.css.map +0 -1
  170. package/build/OrangeDAMContentBrowserSDK.min.js +0 -11468
  171. package/build/OrangeDAMContentBrowserSDK.min.js.map +0 -1
  172. package/build/asset-manifest.json +0 -13
  173. package/build/components/ArrayClamp/ArrayClamp.d.ts +0 -10
  174. package/build/components/ArrayClamp/ArrayClamp.styled.d.ts +0 -1
  175. package/build/components/ArrayClamp/index.d.ts +0 -1
  176. package/build/components/Browser/Browser.constants.d.ts +0 -3
  177. package/build/components/Browser/Browser.d.ts +0 -21
  178. package/build/components/Browser/Browser.styled.d.ts +0 -2
  179. package/build/components/Browser/BrowserItem.d.ts +0 -13
  180. package/build/components/Browser/LoadMoreButton.d.ts +0 -9
  181. package/build/components/ControlBar/ControlBar.constants.d.ts +0 -10
  182. package/build/components/ControlBar/ControlBar.d.ts +0 -23
  183. package/build/components/ControlBar/ControlBar.styled.d.ts +0 -1
  184. package/build/components/ControlBar/Facet/Facet.d.ts +0 -14
  185. package/build/components/ControlBar/Facet/index.d.ts +0 -1
  186. package/build/components/FormatDialog/CropPreviewer/CropPreviewer.d.ts +0 -41
  187. package/build/components/FormatDialog/CustomRendition/CustomRendition.constants.d.ts +0 -5
  188. package/build/components/FormatDialog/CustomRendition/CustomRendition.d.ts +0 -56
  189. package/build/components/FormatDialog/CustomRendition/CustomRendition.styled.d.ts +0 -1
  190. package/build/components/FormatDialog/CustomRendition/index.d.ts +0 -1
  191. package/build/components/FormatDialog/CustomRendition/transformations/Crop.d.ts +0 -26
  192. package/build/components/FormatDialog/CustomRendition/transformations/Extension.d.ts +0 -11
  193. package/build/components/FormatDialog/CustomRendition/transformations/Format.d.ts +0 -10
  194. package/build/components/FormatDialog/CustomRendition/transformations/Metadata.d.ts +0 -7
  195. package/build/components/FormatDialog/CustomRendition/transformations/Quality.d.ts +0 -7
  196. package/build/components/FormatDialog/CustomRendition/transformations/Resize.d.ts +0 -18
  197. package/build/components/FormatDialog/CustomRendition/transformations/Rotate.d.ts +0 -8
  198. package/build/components/FormatDialog/FormatDialog.d.ts +0 -49
  199. package/build/components/FormatDialog/FormatDialog.styled.d.ts +0 -3
  200. package/build/components/FormatDialog/Previewer/Previewer.d.ts +0 -17
  201. package/build/components/FormatDialog/Previewer/Previewer.styled.d.ts +0 -1
  202. package/build/components/FormatDialog/Previewer/index.d.ts +0 -1
  203. package/build/components/FormatDialog/ProxyMenu/ProxyMenu.d.ts +0 -20
  204. package/build/components/FormatDialog/ProxyMenu/ProxyMenu.styled.d.ts +0 -2
  205. package/build/components/FormatDialog/ProxyMenu/index.d.ts +0 -1
  206. package/build/components/FormatDialog/TrackingParameters/TrackingParameters.d.ts +0 -13
  207. package/build/components/FormatDialog/TrackingParameters/index.d.ts +0 -1
  208. package/build/components/FormatDialog/VersionHistory/VersionHistory.d.ts +0 -6
  209. package/build/components/FormatDialog/VersionHistory/VersionHistory.styled.d.ts +0 -1
  210. package/build/components/FormatDialog/VersionHistory/index.d.ts +0 -1
  211. package/build/components/FormatDialog/index.d.ts +0 -1
  212. package/build/components/Header/Header.d.ts +0 -15
  213. package/build/components/Header/Header.styled.d.ts +0 -5
  214. package/build/components/Loader/Loader.d.ts +0 -7
  215. package/build/components/Loader/index.d.ts +0 -1
  216. package/build/components/NoResult/NoResult.d.ts +0 -7
  217. package/build/components/NoResult/index.d.ts +0 -1
  218. package/build/components/Result/AssetCard/AssetCard.d.ts +0 -15
  219. package/build/components/Result/AssetCard/AssetCard.styled.d.ts +0 -2
  220. package/build/components/Result/AssetCard/AssetCardWrapper.d.ts +0 -18
  221. package/build/components/Result/AssetCard/AssetCardWrapper.styled.d.ts +0 -1
  222. package/build/components/Result/AssetCard/index.d.ts +0 -1
  223. package/build/components/Result/AssetPreview/AssetPreview.d.ts +0 -11
  224. package/build/components/Result/AssetPreview/AssetPreview.styled.d.ts +0 -1
  225. package/build/components/Result/AssetPreview/ImagePreview/ImagePreview.d.ts +0 -11
  226. package/build/components/Result/AssetPreview/ImagePreview/index.d.ts +0 -1
  227. package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.d.ts +0 -9
  228. package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.d.ts +0 -1
  229. package/build/components/Result/AssetPreview/OtherPreview/index.d.ts +0 -1
  230. package/build/components/Result/AssetPreview/VideoPreview/VideoPreview.d.ts +0 -11
  231. package/build/components/Result/AssetPreview/VideoPreview/index.d.ts +0 -1
  232. package/build/components/Result/AssetPreview/index.d.ts +0 -1
  233. package/build/consts/asset.d.ts +0 -14
  234. package/build/consts/auth.d.ts +0 -4
  235. package/build/consts/data.d.ts +0 -21
  236. package/build/index.d.ts +0 -225
  237. package/build/index.html +0 -1
  238. package/build/page/Authenticate/Authenticate.d.ts +0 -2
  239. package/build/page/Authenticate/ConnectingBackground.d.ts +0 -8
  240. package/build/page/Authenticate/index.d.ts +0 -2
  241. package/build/page/Home/Home.d.ts +0 -6
  242. package/build/page/Home/Home.styled.d.ts +0 -2
  243. package/build/setupTests.d.ts +0 -1
  244. package/build/store/assets/assets.api.d.ts +0 -66
  245. package/build/store/assets/assets.service.d.ts +0 -23
  246. package/build/store/assets/assets.slice.d.ts +0 -65
  247. package/build/store/auth/auth.service.d.ts +0 -10
  248. package/build/store/auth/auth.slice.d.ts +0 -76
  249. package/build/store/index.d.ts +0 -368
  250. package/build/store/search/search.api.d.ts +0 -39
  251. package/build/store/search/search.slice.d.ts +0 -12
  252. package/build/store/user/user.api.d.ts +0 -5
  253. package/build/types/assets.d.ts +0 -68
  254. package/build/types/auth.d.ts +0 -35
  255. package/build/types/common.d.ts +0 -11
  256. package/build/types/download.d.ts +0 -8
  257. package/build/types/navigation.d.ts +0 -3
  258. package/build/types/search.d.ts +0 -148
  259. package/build/types/user.d.ts +0 -7
  260. package/build/utils/api.d.ts +0 -27
  261. package/build/utils/array.d.ts +0 -13
  262. package/build/utils/constants.d.ts +0 -11
  263. package/build/utils/function.d.ts +0 -1
  264. package/build/utils/getRequestUrl.d.ts +0 -1
  265. package/build/utils/hooks.d.ts +0 -1
  266. package/build/utils/icon.d.ts +0 -3
  267. package/build/utils/image.d.ts +0 -24
  268. package/build/utils/number.d.ts +0 -4
  269. package/build/utils/rotate.d.ts +0 -4
  270. package/build/utils/storage.d.ts +0 -23
  271. package/build/utils/string.d.ts +0 -12
  272. package/build/view/AssetsPicker.d.ts +0 -6
  273. /package/{build → public}/favicon.ico +0 -0
  274. /package/{build → public}/logo192.png +0 -0
  275. /package/{build → public}/logo512.png +0 -0
  276. /package/{build → public}/manifest.json +0 -0
  277. /package/{build → public}/robots.txt +0 -0
  278. /package/{build/components/Browser/index.d.ts → src/components/Browser/index.ts} +0 -0
  279. /package/{build/components/ControlBar/index.d.ts → src/components/ControlBar/index.ts} +0 -0
  280. /package/{build/components/Header/index.d.ts → src/components/Header/index.ts} +0 -0
  281. /package/{build/page/Home/index.d.ts → src/page/Home/index.ts} +0 -0
@@ -0,0 +1,1533 @@
1
+ import _uniqBy from 'lodash-es/uniqBy';
2
+ import {
3
+ CSSProperties, FC, useCallback, useEffect, useMemo, useReducer, useRef, useState,
4
+ } from 'react';
5
+
6
+ import { TrackingParameter, Transformation, TransformationAction, Unit } from '@/types/assets';
7
+ import { Asset, MediaType, Proxy } from '@/types/search';
8
+ import { convertPixelsToAspectRatio } from '@/utils/number';
9
+ import { rotateBox } from '@/utils/rotate';
10
+ import { CxDialog, CxDrawer, CxSelectEvent } from '@/web-component';
11
+
12
+ import CropPreviewer, { CropPreviewerHandle } from './CropPreviewer';
13
+ import CustomRendition from './CustomRendition';
14
+ import { Dialog, Drawer } from './FormatDialog.styled';
15
+ import Previewer from './Previewer';
16
+ import ProxyMenu from './ProxyMenu';
17
+ import TrackingParameters from './TrackingParameters';
18
+
19
+ type Props = {
20
+ allowTracking: boolean;
21
+ allowCustomFormat: boolean;
22
+ autoExtension: string;
23
+ availableExtensions?: Record<MediaType, { displayName: string; value: string }[]>;
24
+ availableProxies?: Proxy[];
25
+ ctaText?: string;
26
+ extensions: string[];
27
+ maxHeight?: number;
28
+ open: boolean;
29
+ previewUrl?: string;
30
+ searchInDrive: boolean;
31
+ selectedAsset: Asset | null;
32
+ supportedRepresentativeSubtypes?: string[];
33
+ variant?: 'dialog' | 'drawer';
34
+ onClose: () => void;
35
+ onProxyConfirm: (value: {
36
+ extension: string;
37
+ permanentLink?: string;
38
+ parameters?: TrackingParameter[];
39
+ useRepresentative?: boolean;
40
+ value: string;
41
+ }) => void;
42
+ onFormatConfirm: (value: {
43
+ value: Transformation[];
44
+ parameters?: TrackingParameter[];
45
+ proxiesPreference?: string;
46
+ extension?: string;
47
+ }) => void;
48
+ onOpenInDriveConfirm: () => void;
49
+ };
50
+
51
+ type State = {
52
+ previewLoadable: boolean;
53
+ defaultSize: {
54
+ width: number;
55
+ height: number;
56
+ },
57
+ selectedProxy: string;
58
+ selectedFormat: {
59
+ url: string;
60
+ originalUrl: string;
61
+ width: number;
62
+ height: number;
63
+ x: number;
64
+ y: number;
65
+ extension: string;
66
+ rotation: number;
67
+ };
68
+ resizeSize: {
69
+ width: number;
70
+ height: number;
71
+ unit: Unit;
72
+ };
73
+ lastResizeSize: Record<Unit, { width: number; height: number; unit: Unit; }>;
74
+ cropSize: {
75
+ width: number;
76
+ height: number;
77
+ percentageWidth: number;
78
+ percentageHeight: number;
79
+ x: number;
80
+ y: number;
81
+ unit: Unit;
82
+ };
83
+ lastCropSize: Record<Unit, {
84
+ width: number;
85
+ height: number;
86
+ percentageWidth: number;
87
+ percentageHeight: number;
88
+ x: number;
89
+ y: number;
90
+ unit: Unit;
91
+ }>;
92
+ rotation: number;
93
+ transformations: Transformation[];
94
+ enabledTracking: boolean;
95
+ trackingParameters: TrackingParameter[];
96
+ showCustomRendition: boolean;
97
+ useCustomRendition: boolean;
98
+ useRepresentative: boolean;
99
+ activeSetting: string;
100
+ isLoading: boolean;
101
+ };
102
+
103
+ type Action =
104
+ | { type: 'CANCEL_USE_CUSTOM_RENDITION'; payload: { width: number; height: number, url: string, originalUrl: string, extension: string } }
105
+ | { type: 'CONFIRM_USE_CUSTOM_RENDITION' }
106
+ | { type: 'RESET_DATA' }
107
+ | { type: 'SET_ACTIVE_SETTING'; payload: string }
108
+ | { type: 'SET_CROP_SIZE'; payload: Partial<State['cropSize']> }
109
+ | { type: 'SET_DEFAULT_SIZE'; payload: Partial<State['defaultSize']> }
110
+ | { type: 'SET_ENABLED_TRACKING'; payload: boolean }
111
+ | { type: 'SET_LAST_RESIZE_SIZE'; payload: Partial<State['lastResizeSize']> }
112
+ | { type: 'SET_LAST_CROP_SIZE'; payload: Partial<State['lastCropSize']> }
113
+ | { type: 'SET_LOADING'; payload: boolean }
114
+ | { type: 'SET_PREVIEW_LOADABLE'; payload: boolean }
115
+ | { type: 'SET_RESIZE_SIZE'; payload: Partial<State['resizeSize']> }
116
+ | { type: 'SET_ROTATION'; payload: number }
117
+ | { type: 'SET_SELECTED_FORMAT'; payload: Partial<State['selectedFormat']> }
118
+ | { type: 'SET_SELECTED_PROXY'; payload: string | { proxy: string; useCustomRendition?: boolean } }
119
+ | { type: 'SET_SHOW_CUSTOM_RENDITION'; payload: boolean }
120
+ | { type: 'SET_TRACKING_PARAMETERS'; payload: TrackingParameter[] }
121
+ | { type: 'SET_TRANSFORMATIONS'; payload: Transformation }
122
+ | { type: 'SET_USE_REPRESENTATIVE'; payload: boolean };
123
+
124
+ const initialState: State = {
125
+ previewLoadable: false,
126
+ defaultSize: {
127
+ width: 0,
128
+ height: 0,
129
+ },
130
+ selectedProxy: '',
131
+ selectedFormat: {
132
+ url: '',
133
+ originalUrl: '',
134
+ width: 0,
135
+ height: 0,
136
+ x: 0,
137
+ y: 0,
138
+ extension: '',
139
+ rotation: 0,
140
+ },
141
+ resizeSize: {
142
+ width: 0,
143
+ height: 0,
144
+ unit: Unit.Pixel,
145
+ },
146
+ lastResizeSize: {
147
+ [Unit.AspectRatio]: {
148
+ width: 0,
149
+ height: 0,
150
+ unit: Unit.AspectRatio,
151
+ },
152
+ [Unit.Pixel]: {
153
+ width: 0,
154
+ height: 0,
155
+ unit: Unit.Pixel,
156
+ },
157
+ },
158
+ cropSize: {
159
+ width: 0,
160
+ height: 0,
161
+ percentageWidth: 0,
162
+ percentageHeight: 0,
163
+ x: 0,
164
+ y: 0,
165
+ unit: Unit.Pixel,
166
+ },
167
+ lastCropSize: {
168
+ [Unit.AspectRatio]: {
169
+ width: 0,
170
+ height: 0,
171
+ percentageWidth: 0,
172
+ percentageHeight: 0,
173
+ x: 0,
174
+ y: 0,
175
+ unit: Unit.AspectRatio,
176
+ },
177
+ [Unit.Pixel]: {
178
+ width: 0,
179
+ height: 0,
180
+ percentageWidth: 0,
181
+ percentageHeight: 0,
182
+ x: 0,
183
+ y: 0,
184
+ unit: Unit.Pixel,
185
+ },
186
+ },
187
+ rotation: 0,
188
+ transformations: [],
189
+ enabledTracking: false,
190
+ trackingParameters: [{
191
+ key: 'UTM_source',
192
+ value: '',
193
+ }, {
194
+ key: 'UTM_campaign',
195
+ value: '',
196
+ }, {
197
+ key: 'UTM_description',
198
+ value: '',
199
+ }],
200
+ showCustomRendition: false,
201
+ useCustomRendition: false,
202
+ useRepresentative: false,
203
+ activeSetting: 'format',
204
+ isLoading: false,
205
+ };
206
+
207
+ const reducer = (state: State, action: Action): State => {
208
+ switch (action.type) {
209
+ case 'CANCEL_USE_CUSTOM_RENDITION':
210
+ return {
211
+ ...state,
212
+ cropSize: {
213
+ ...state.cropSize,
214
+ width: action.payload.width,
215
+ height: action.payload.height,
216
+ },
217
+ resizeSize: {
218
+ ...state.resizeSize,
219
+ width: action.payload.width,
220
+ height: action.payload.height,
221
+ },
222
+ selectedFormat: {
223
+ ...state.selectedFormat,
224
+ ...action.payload,
225
+ rotation: 0,
226
+ x: 0,
227
+ y: 0,
228
+ },
229
+ rotation: 0,
230
+ transformations: [],
231
+ showCustomRendition: false,
232
+ useCustomRendition: false,
233
+ activeSetting: 'resize',
234
+ };
235
+ case 'CONFIRM_USE_CUSTOM_RENDITION':
236
+ return {
237
+ ...state,
238
+ cropSize: {
239
+ ...state.cropSize,
240
+ width: state.selectedFormat.width,
241
+ height: state.selectedFormat.height,
242
+ },
243
+ resizeSize: {
244
+ ...state.resizeSize,
245
+ width: state.selectedFormat.width,
246
+ height: state.selectedFormat.height,
247
+ },
248
+ rotation: 0,
249
+ activeSetting: 'resize',
250
+ showCustomRendition: false,
251
+ useCustomRendition: true,
252
+ };
253
+ case 'SET_DEFAULT_SIZE':
254
+ return {
255
+ ...state,
256
+ defaultSize: {
257
+ ...state.defaultSize,
258
+ ...action.payload,
259
+ },
260
+ };
261
+ case 'RESET_DATA':
262
+ return initialState;
263
+ case 'SET_ACTIVE_SETTING':
264
+ return {
265
+ ...state,
266
+ activeSetting: action.payload,
267
+ };
268
+ case 'SET_CROP_SIZE':
269
+ return {
270
+ ...state,
271
+ cropSize: {
272
+ ...state.cropSize,
273
+ ...action.payload,
274
+ },
275
+ };
276
+ case 'SET_ENABLED_TRACKING':
277
+ return {
278
+ ...state,
279
+ enabledTracking: action.payload,
280
+ };
281
+ case 'SET_LAST_CROP_SIZE':
282
+ return {
283
+ ...state,
284
+ lastCropSize: {
285
+ ...state.lastCropSize,
286
+ ...action.payload,
287
+ },
288
+ };
289
+ case 'SET_LAST_RESIZE_SIZE':
290
+ return {
291
+ ...state,
292
+ lastResizeSize: {
293
+ ...state.lastResizeSize,
294
+ ...action.payload,
295
+ },
296
+ };
297
+ case 'SET_LOADING':
298
+ return {
299
+ ...state,
300
+ isLoading: action.payload,
301
+ };
302
+ case 'SET_PREVIEW_LOADABLE':
303
+ return {
304
+ ...state,
305
+ previewLoadable: action.payload,
306
+ };
307
+ case 'SET_RESIZE_SIZE':
308
+ return {
309
+ ...state,
310
+ resizeSize: {
311
+ ...state.resizeSize,
312
+ ...action.payload,
313
+ },
314
+ };
315
+ case 'SET_ROTATION':
316
+ return {
317
+ ...state,
318
+ rotation: action.payload,
319
+ };
320
+ case 'SET_SELECTED_FORMAT':
321
+ return {
322
+ ...state,
323
+ selectedFormat: {
324
+ ...state.selectedFormat,
325
+ ...action.payload,
326
+ },
327
+ };
328
+ case 'SET_SELECTED_PROXY':
329
+
330
+ if (typeof action.payload === 'string') {
331
+ return {
332
+ ...state,
333
+ selectedProxy: action.payload,
334
+ useCustomRendition: false,
335
+ useRepresentative: false,
336
+ };
337
+ }
338
+ return {
339
+ ...state,
340
+ selectedProxy: action.payload.proxy,
341
+ useCustomRendition: Boolean(action.payload.useCustomRendition),
342
+ useRepresentative: false,
343
+ };
344
+ case 'SET_SHOW_CUSTOM_RENDITION':
345
+ return {
346
+ ...state,
347
+ // Remove selected proxy when custom rendition is selected
348
+ selectedProxy: '',
349
+ showCustomRendition: action.payload,
350
+ useCustomRendition: false,
351
+ };
352
+ case 'SET_TRACKING_PARAMETERS':
353
+ return {
354
+ ...state,
355
+ trackingParameters: action.payload,
356
+ };
357
+ case 'SET_TRANSFORMATIONS':
358
+ return {
359
+ ...state,
360
+ transformations: [...state.transformations, action.payload],
361
+ };
362
+ case 'SET_USE_REPRESENTATIVE':
363
+ return {
364
+ ...state,
365
+ selectedProxy: action.payload ? '' : state.selectedProxy,
366
+ useRepresentative: action.payload,
367
+ };
368
+ default:
369
+ return state;
370
+ }
371
+ };
372
+
373
+ const FormatDialog: FC<Props> = ({
374
+ allowTracking,
375
+ allowCustomFormat,
376
+ autoExtension,
377
+ availableExtensions,
378
+ availableProxies,
379
+ ctaText,
380
+ extensions,
381
+ maxHeight,
382
+ open,
383
+ previewUrl,
384
+ searchInDrive,
385
+ selectedAsset,
386
+ supportedRepresentativeSubtypes,
387
+ variant = 'dialog',
388
+ onClose,
389
+ onProxyConfirm,
390
+ onFormatConfirm,
391
+ onOpenInDriveConfirm,
392
+ }) => {
393
+ const [state, dispatch] = useReducer(reducer, initialState);
394
+ const [isDefined, setIsDefined] = useState(false);
395
+ const dialogRef = useRef<CxDialog>(null);
396
+ const drawerRef = useRef<CxDrawer>(null);
397
+ const previewerRef = useRef<CropPreviewerHandle>(null);
398
+
399
+ const setDefaultValues = useCallback(() => {
400
+ if (!selectedAsset) {
401
+ return;
402
+ }
403
+
404
+ const defaultRatio = convertPixelsToAspectRatio(
405
+ state.defaultSize.width,
406
+ state.defaultSize.height,
407
+ );
408
+
409
+ dispatch({
410
+ type: 'SET_RESIZE_SIZE',
411
+ payload: {
412
+ ...initialState.resizeSize,
413
+ width: state.defaultSize.width,
414
+ height: state.defaultSize.height,
415
+ },
416
+ });
417
+
418
+ dispatch({
419
+ type: 'SET_CROP_SIZE',
420
+ payload: {
421
+ ...initialState.cropSize,
422
+ width: state.defaultSize.width,
423
+ height: state.defaultSize.height,
424
+ percentageHeight: 100,
425
+ percentageWidth: 100,
426
+ },
427
+ });
428
+
429
+ dispatch({
430
+ type: 'SET_ROTATION',
431
+ payload: 0,
432
+ });
433
+
434
+ dispatch({
435
+ type: 'SET_LAST_CROP_SIZE',
436
+ payload: {
437
+ ...initialState.lastCropSize,
438
+ [Unit.Pixel]: {
439
+ width: state.defaultSize.width,
440
+ height: state.defaultSize.height,
441
+ percentageHeight: 100,
442
+ percentageWidth: 100,
443
+ x: 0,
444
+ y: 0,
445
+ unit: Unit.Pixel,
446
+ },
447
+ [Unit.AspectRatio]: {
448
+ width: defaultRatio.width,
449
+ height: defaultRatio.height,
450
+ percentageHeight: 100,
451
+ percentageWidth: 100,
452
+ x: 0,
453
+ y: 0,
454
+ unit: Unit.AspectRatio,
455
+ },
456
+ },
457
+ });
458
+
459
+ dispatch({
460
+ type: 'SET_LAST_RESIZE_SIZE',
461
+ payload: {
462
+ [Unit.Pixel]: {
463
+ width: state.defaultSize.width,
464
+ height: state.defaultSize.height,
465
+ unit: Unit.Pixel,
466
+ },
467
+ [Unit.AspectRatio]: {
468
+ width: defaultRatio.width,
469
+ height: defaultRatio.height,
470
+ unit: Unit.AspectRatio,
471
+ },
472
+ },
473
+ });
474
+
475
+ if (availableProxies) {
476
+ dispatch({
477
+ type: 'SET_SELECTED_PROXY',
478
+ payload: availableProxies[0]?.id,
479
+ });
480
+
481
+ dispatch({
482
+ type: 'SET_SELECTED_FORMAT',
483
+ payload: {
484
+ ...initialState.selectedFormat,
485
+ url: selectedAsset.imageUrl,
486
+ originalUrl: selectedAsset.originalUrl,
487
+ extension: autoExtension ?? selectedAsset.extension,
488
+ width: availableProxies[0].formatWidth,
489
+ height: availableProxies[0].formatHeight,
490
+ },
491
+ });
492
+ } else {
493
+ dispatch({
494
+ type: 'SET_SELECTED_FORMAT',
495
+ payload: {
496
+ ...initialState.selectedFormat,
497
+ url: selectedAsset.imageUrl,
498
+ originalUrl: selectedAsset.originalUrl,
499
+ extension: autoExtension ?? selectedAsset.extension,
500
+ width: state.defaultSize.width,
501
+ height: state.defaultSize.height,
502
+ },
503
+ });
504
+ }
505
+ }, [autoExtension, availableProxies, selectedAsset, state.defaultSize.height, state.defaultSize.width]);
506
+
507
+ useEffect(() => {
508
+ if (selectedAsset?.width && selectedAsset?.height) {
509
+ dispatch({
510
+ type: 'SET_DEFAULT_SIZE',
511
+ payload: {
512
+ width: parseInt(selectedAsset.width, 10),
513
+ height: parseInt(selectedAsset.height, 10),
514
+ },
515
+ });
516
+ }
517
+ }, [selectedAsset?.width, selectedAsset?.height]);
518
+
519
+
520
+ useEffect(() => {
521
+ Promise.all([
522
+ customElements.whenDefined('cx-dialog'),
523
+ customElements.whenDefined('cx-drawer'),
524
+ customElements.whenDefined('cx-dropdown'),
525
+ ]).then(() => {
526
+ setIsDefined(true);
527
+ });
528
+ }, []);
529
+
530
+ useEffect(() => {
531
+ const onRequestClose = () => {
532
+ dispatch({ type: 'SET_PREVIEW_LOADABLE', payload: false });
533
+ dispatch({ type: 'RESET_DATA' });
534
+ onClose();
535
+ };
536
+
537
+ const dialog = dialogRef.current;
538
+ const drawer = drawerRef.current;
539
+
540
+ dialog?.addEventListener('cx-request-close', onRequestClose);
541
+ drawer?.addEventListener('cx-request-close', onRequestClose);
542
+
543
+ return () => {
544
+ dialog?.removeEventListener('cx-request-close', onRequestClose);
545
+ drawer?.removeEventListener('cx-request-close', onRequestClose);
546
+ };
547
+ }, [isDefined, onClose]);
548
+
549
+ useEffect(() => {
550
+ const onAfterShow = () => {
551
+ dispatch({ type: 'SET_PREVIEW_LOADABLE', payload: true });
552
+ };
553
+
554
+ const dialog = dialogRef.current;
555
+ const drawer = drawerRef.current;
556
+
557
+ dialog?.addEventListener('cx-after-show', onAfterShow);
558
+ drawer?.addEventListener('cx-after-show', onAfterShow);
559
+
560
+ return () => {
561
+ dialog?.removeEventListener('cx-after-show', onAfterShow);
562
+ drawer?.removeEventListener('cx-after-show', onAfterShow);
563
+ };
564
+ }, [isDefined, state.showCustomRendition, variant]);
565
+
566
+ useEffect(() => {
567
+ const onProxySelect = (e: CxSelectEvent) => {
568
+ const value = e.detail.item.value;
569
+
570
+ if (value === 'custom') {
571
+ dispatch({ type: 'SET_SHOW_CUSTOM_RENDITION', payload: true });
572
+ if (!state.useCustomRendition) {
573
+ setDefaultValues();
574
+ }
575
+ return;
576
+ }
577
+
578
+ if (value === 'tracking') {
579
+ dispatch({
580
+ type: 'SET_ENABLED_TRACKING',
581
+ payload: !state.enabledTracking,
582
+ });
583
+ return;
584
+ }
585
+
586
+ if (value === 'use-representative') {
587
+ dispatch({
588
+ type: 'SET_USE_REPRESENTATIVE',
589
+ payload: !state.useRepresentative,
590
+ });
591
+ return;
592
+ }
593
+
594
+ if (value && availableProxies) {
595
+ if (!availableProxies.map(item => item.id).includes(value)) {
596
+ return;
597
+ }
598
+ dispatch({ type: 'SET_SELECTED_PROXY', payload: value });
599
+ }
600
+ };
601
+
602
+ const dialog = dialogRef.current;
603
+ const drawer = drawerRef.current;
604
+
605
+ dialog?.addEventListener('cx-select', onProxySelect);
606
+ drawer?.addEventListener('cx-select', onProxySelect);
607
+
608
+ return () => {
609
+ dialog?.removeEventListener('cx-select', onProxySelect);
610
+ drawer?.removeEventListener('cx-select', onProxySelect);
611
+ };
612
+ }, [
613
+ isDefined,
614
+ state.enabledTracking,
615
+ state.useCustomRendition,
616
+ state.useRepresentative,
617
+ setDefaultValues,
618
+ availableProxies,
619
+ selectedAsset?.extension,
620
+ ]);
621
+
622
+ useEffect(() => {
623
+ setDefaultValues();
624
+ }, [setDefaultValues]);
625
+
626
+ const supportedRepresentative = useMemo(
627
+ () =>
628
+ supportedRepresentativeSubtypes?.includes(selectedAsset?.docSubType ?? '') &&
629
+ selectedAsset?.imageUrl,
630
+ [selectedAsset, supportedRepresentativeSubtypes],
631
+ );
632
+
633
+ const onLoadingChange = useCallback((isLoading: boolean) => {
634
+ dispatch({ type: 'SET_LOADING', payload: isLoading });
635
+ }, []);
636
+
637
+ const onResizeChange = useCallback(async (width: number, height: number, unit: Unit, shouldApply: boolean) => {
638
+ if (!selectedAsset) {
639
+ return;
640
+ }
641
+
642
+ const currentWidth = state.selectedFormat.width || state.defaultSize.width;
643
+ const currentHeight = state.selectedFormat.height || state.defaultSize.height;
644
+
645
+ dispatch({
646
+ type: 'SET_RESIZE_SIZE',
647
+ payload: {
648
+ width,
649
+ height,
650
+ unit,
651
+ },
652
+ });
653
+
654
+ if (shouldApply) {
655
+ let newFormatWidth = width;
656
+ let newFormatHeight = height;
657
+
658
+ if (state.resizeSize.unit !== unit) {
659
+ newFormatWidth = currentWidth;
660
+ newFormatHeight = currentHeight;
661
+ } else if (unit === Unit.AspectRatio) {
662
+ newFormatWidth =
663
+ Math.round((width / height) * currentHeight);
664
+ newFormatHeight = currentHeight;
665
+ }
666
+
667
+ const newImage = await previewerRef.current?.applyResize();
668
+
669
+ dispatch({
670
+ type: 'SET_SELECTED_FORMAT',
671
+ payload: {
672
+ url: newImage,
673
+ width: newFormatWidth,
674
+ height: newFormatHeight,
675
+ },
676
+ });
677
+
678
+ dispatch({
679
+ type: 'SET_TRANSFORMATIONS',
680
+ payload: {
681
+ key: TransformationAction.Resize,
682
+ value: {
683
+ width: newFormatWidth,
684
+ height: newFormatHeight,
685
+ },
686
+ },
687
+ });
688
+
689
+ dispatch({
690
+ type: 'SET_CROP_SIZE',
691
+ payload: {
692
+ width: newFormatWidth,
693
+ height: newFormatHeight,
694
+ },
695
+ });
696
+
697
+ const ratio = convertPixelsToAspectRatio(newFormatWidth, newFormatHeight);
698
+ dispatch({
699
+ type: 'SET_LAST_RESIZE_SIZE',
700
+ payload: {
701
+ [Unit.Pixel]: {
702
+ width: newFormatWidth,
703
+ height: newFormatHeight,
704
+ unit: Unit.Pixel,
705
+ },
706
+ [Unit.AspectRatio]: {
707
+ width: unit === Unit.AspectRatio ? width : ratio.width,
708
+ height: unit === Unit.AspectRatio ? height : ratio.height,
709
+ unit: Unit.AspectRatio,
710
+ },
711
+ },
712
+ });
713
+
714
+ dispatch({
715
+ type: 'SET_LAST_CROP_SIZE',
716
+ payload: {
717
+ [Unit.Pixel]: {
718
+ width: newFormatWidth,
719
+ height: newFormatHeight,
720
+ percentageHeight: 100,
721
+ percentageWidth: 100,
722
+ x: 0,
723
+ y: 0,
724
+ unit: Unit.Pixel,
725
+ },
726
+ [Unit.AspectRatio]: {
727
+ width: unit === Unit.AspectRatio ? width : ratio.width,
728
+ height: unit === Unit.AspectRatio ? height : ratio.height,
729
+ percentageHeight: 100,
730
+ percentageWidth: 100,
731
+ x: 0,
732
+ y: 0,
733
+ unit: Unit.AspectRatio,
734
+ },
735
+ },
736
+ });
737
+ }
738
+ }, [selectedAsset, state.defaultSize.height, state.defaultSize.width, state.resizeSize.unit, state.selectedFormat.height, state.selectedFormat.width]);
739
+
740
+ const onCropChange = useCallback(async (width: number, height: number, unit: Unit, shouldApply: boolean) => {
741
+ if (!selectedAsset) {
742
+ return;
743
+ }
744
+ const previousUnit = state.cropSize.unit;
745
+ const previewHandle = previewerRef.current;
746
+
747
+ if (previewHandle && state.selectedFormat?.width && state.selectedFormat?.height) {
748
+
749
+ if (unit === previousUnit && unit === Unit.Pixel) {
750
+ const scale = Math.max(
751
+ width / state.selectedFormat.width,
752
+ height / state.selectedFormat.height,
753
+ );
754
+ previewHandle.setZoom(1 / scale);
755
+ }
756
+
757
+ if (unit !== previousUnit) {
758
+ previewHandle.setZoom(1);
759
+ }
760
+ }
761
+
762
+
763
+ dispatch({
764
+ type: 'SET_CROP_SIZE',
765
+ payload: {
766
+ width,
767
+ height,
768
+ unit,
769
+ },
770
+ });
771
+
772
+ if (shouldApply) {
773
+ const newImage = await previewerRef.current?.applyCrop();
774
+
775
+ let newWidth = width;
776
+ let newHeight = height;
777
+ if (unit === Unit.AspectRatio) {
778
+ newWidth = Math.round((state.cropSize.percentageWidth * state.selectedFormat.width) / 100);
779
+ newHeight = Math.round((state.cropSize.percentageHeight * state.selectedFormat.height) / 100);
780
+ }
781
+ previewHandle?.setZoom(1);
782
+
783
+ const newX = Number(
784
+ ((state.cropSize.x / 100) * state.selectedFormat.width).toFixed(0),
785
+ );
786
+ const newY = Number(
787
+ ((state.cropSize.y / 100) * state.selectedFormat.height).toFixed(0),
788
+ );
789
+
790
+ dispatch({
791
+ type: 'SET_SELECTED_FORMAT',
792
+ payload: {
793
+ url: newImage,
794
+ width: newWidth,
795
+ height: newHeight,
796
+ },
797
+ });
798
+
799
+ dispatch({
800
+ type: 'SET_RESIZE_SIZE',
801
+ payload: {
802
+ width: newWidth,
803
+ height: newHeight,
804
+ unit: Unit.Pixel,
805
+ },
806
+ });
807
+
808
+ dispatch({
809
+ type: 'SET_TRANSFORMATIONS',
810
+ payload: {
811
+ key: TransformationAction.Crop,
812
+ value: {
813
+ width: Number(newWidth.toFixed(0)),
814
+ height: Number(newHeight.toFixed(0)),
815
+ x: newX,
816
+ y: newY,
817
+ },
818
+ },
819
+ });
820
+
821
+ const ratio = convertPixelsToAspectRatio(newWidth, newHeight);
822
+
823
+ dispatch({
824
+ type: 'SET_LAST_CROP_SIZE',
825
+ payload: {
826
+ [Unit.Pixel]:{
827
+ width: Math.round(newWidth),
828
+ height: Math.round(newHeight),
829
+ percentageHeight: 100,
830
+ percentageWidth: 100,
831
+ x: 0,
832
+ y: 0,
833
+ unit: Unit.Pixel,
834
+ },
835
+ [Unit.AspectRatio]: {
836
+ width: unit === Unit.AspectRatio ? width : ratio.width,
837
+ height: unit === Unit.AspectRatio ? height : ratio.height,
838
+ percentageHeight: 100,
839
+ percentageWidth: 100,
840
+ x: 0,
841
+ y: 0,
842
+ unit: Unit.AspectRatio,
843
+ },
844
+ },
845
+ });
846
+
847
+ dispatch({
848
+ type: 'SET_LAST_RESIZE_SIZE',
849
+ payload: {
850
+ [Unit.Pixel]: {
851
+ width: newWidth,
852
+ height: newHeight,
853
+ unit: Unit.Pixel,
854
+ },
855
+ [Unit.AspectRatio]: {
856
+ width: unit === Unit.AspectRatio ? width : ratio.width,
857
+ height: unit === Unit.AspectRatio ? height : ratio.height,
858
+ unit: Unit.AspectRatio,
859
+ },
860
+ },
861
+ });
862
+ }
863
+ },
864
+ [
865
+ selectedAsset,
866
+ state.cropSize,
867
+ state.selectedFormat.height,
868
+ state.selectedFormat.width,
869
+ ],
870
+ );
871
+
872
+ const onRotateChange = useCallback(async (rotation: number, shouldApply: boolean) => {
873
+ dispatch({
874
+ type: 'SET_ROTATION',
875
+ payload: shouldApply ? 0 : rotation,
876
+ });
877
+
878
+ if (shouldApply) {
879
+ const { width: newWidth, height: newHeight } = rotateBox(
880
+ state.selectedFormat.width,
881
+ state.selectedFormat.height,
882
+ rotation,
883
+ );
884
+ const newImage = await previewerRef.current?.applyRotation();
885
+ dispatch({
886
+ type: 'SET_SELECTED_FORMAT',
887
+ payload: {
888
+ rotation,
889
+ url: newImage,
890
+ width: newWidth,
891
+ height: newHeight,
892
+ },
893
+ });
894
+
895
+ dispatch({
896
+ type: 'SET_TRANSFORMATIONS',
897
+ payload: {
898
+ key: TransformationAction.Rotate,
899
+ value: {
900
+ rotation,
901
+ },
902
+ },
903
+ });
904
+
905
+ dispatch({
906
+ type: 'SET_CROP_SIZE',
907
+ payload: {
908
+ width: newWidth,
909
+ height: newHeight,
910
+ },
911
+ });
912
+
913
+ dispatch({
914
+ type: 'SET_RESIZE_SIZE',
915
+ payload: {
916
+ width: newWidth,
917
+ height: newHeight,
918
+ unit: Unit.Pixel,
919
+ },
920
+ });
921
+
922
+ const ratio = convertPixelsToAspectRatio(newWidth, newHeight);
923
+ dispatch({
924
+ type: 'SET_LAST_CROP_SIZE',
925
+ payload: {
926
+ [Unit.Pixel]:{
927
+ width: newWidth,
928
+ height: newHeight,
929
+ percentageHeight: 100,
930
+ percentageWidth: 100,
931
+ x: 0,
932
+ y: 0,
933
+ unit: Unit.Pixel,
934
+ },
935
+ [Unit.AspectRatio]: {
936
+ width: ratio.width,
937
+ height: ratio.height,
938
+ percentageHeight: 100,
939
+ percentageWidth: 100,
940
+ x: 0,
941
+ y: 0,
942
+ unit: Unit.AspectRatio,
943
+ },
944
+ },
945
+ });
946
+
947
+ dispatch({
948
+ type: 'SET_LAST_RESIZE_SIZE',
949
+ payload: {
950
+ [Unit.Pixel]: {
951
+ width: newWidth,
952
+ height: newHeight,
953
+ unit: Unit.Pixel,
954
+ },
955
+ [Unit.AspectRatio]: {
956
+ width: ratio.width,
957
+ height: ratio.height,
958
+ unit: Unit.AspectRatio,
959
+ },
960
+ },
961
+ });
962
+ }
963
+ }, [state.selectedFormat]);
964
+
965
+ const onExtensionChange = useCallback((extension: string) => {
966
+ dispatch({
967
+ type: 'SET_SELECTED_FORMAT',
968
+ payload: {
969
+ extension,
970
+ },
971
+ });
972
+ }, []);
973
+
974
+ const onViewChange = useCallback((view: string) => {
975
+ dispatch({
976
+ type: 'SET_CROP_SIZE',
977
+ payload: {
978
+ width: state.selectedFormat.width,
979
+ height: state.selectedFormat.height,
980
+ unit: Unit.Pixel,
981
+ },
982
+ });
983
+ dispatch({
984
+ type: 'SET_RESIZE_SIZE',
985
+ payload: {
986
+ width: state.selectedFormat.width,
987
+ height: state.selectedFormat.height,
988
+ unit: Unit.Pixel,
989
+ },
990
+ });
991
+ dispatch({
992
+ type: 'SET_ROTATION',
993
+ payload: 0,
994
+ });
995
+ dispatch({
996
+ type: 'SET_ACTIVE_SETTING',
997
+ payload: view,
998
+ });
999
+ }, [state.selectedFormat]);
1000
+
1001
+ const onFormatChange = useCallback((format: Proxy) => {
1002
+ let width = format.formatWidth;
1003
+ let height = format.formatHeight;
1004
+
1005
+ if (format.proxyName === 'TRX' && selectedAsset) {
1006
+ width = Number(selectedAsset.width);
1007
+ height = Number(selectedAsset.height);
1008
+ }
1009
+
1010
+ dispatch({
1011
+ type: 'SET_SELECTED_PROXY',
1012
+ payload: {
1013
+ proxy: format.id,
1014
+ useCustomRendition: true,
1015
+ },
1016
+ });
1017
+
1018
+ dispatch({
1019
+ type: 'SET_SELECTED_FORMAT',
1020
+ payload: {
1021
+ width,
1022
+ height,
1023
+ },
1024
+ });
1025
+ dispatch({
1026
+ type: 'SET_RESIZE_SIZE',
1027
+ payload: {
1028
+ width,
1029
+ height,
1030
+ unit: Unit.Pixel,
1031
+ },
1032
+ });
1033
+ dispatch({
1034
+ type: 'SET_CROP_SIZE',
1035
+ payload: {
1036
+ width,
1037
+ height,
1038
+ percentageWidth: 100,
1039
+ percentageHeight: 100,
1040
+ x: 0,
1041
+ y: 0,
1042
+ unit: Unit.Pixel,
1043
+ },
1044
+ });
1045
+
1046
+ const ratio = convertPixelsToAspectRatio(width, height);
1047
+
1048
+ dispatch({
1049
+ type: 'SET_LAST_CROP_SIZE',
1050
+ payload: {
1051
+ [Unit.Pixel]:{
1052
+ width: Math.round(width),
1053
+ height: Math.round(height),
1054
+ percentageHeight: 100,
1055
+ percentageWidth: 100,
1056
+ x: 0,
1057
+ y: 0,
1058
+ unit: Unit.Pixel,
1059
+ },
1060
+ [Unit.AspectRatio]: {
1061
+ width: ratio.width,
1062
+ height: ratio.height,
1063
+ percentageHeight: 100,
1064
+ percentageWidth: 100,
1065
+ x: 0,
1066
+ y: 0,
1067
+ unit: Unit.AspectRatio,
1068
+ },
1069
+ },
1070
+ });
1071
+
1072
+ dispatch({
1073
+ type: 'SET_LAST_RESIZE_SIZE',
1074
+ payload: {
1075
+ [Unit.Pixel]: {
1076
+ width: width,
1077
+ height: height,
1078
+ unit: Unit.Pixel,
1079
+ },
1080
+ [Unit.AspectRatio]: {
1081
+ width: ratio.width,
1082
+ height: ratio.height,
1083
+ unit: Unit.AspectRatio,
1084
+ },
1085
+ },
1086
+ });
1087
+ }, [selectedAsset]);
1088
+
1089
+ useEffect(() => {
1090
+ if (!availableProxies || availableProxies.length === 0) {
1091
+ dispatch({ type: 'SET_SELECTED_PROXY', payload: '' });
1092
+ return;
1093
+ }
1094
+ dispatch({ type: 'SET_SELECTED_PROXY', payload: availableProxies[0].id });
1095
+ }, [availableProxies, selectedAsset]);
1096
+
1097
+ const renderContent = useCallback(() => {
1098
+ const disabledInsert =
1099
+ state.isLoading || (!state.selectedProxy && !state.useCustomRendition && !state.useRepresentative);
1100
+ const supportedATS = allowCustomFormat && extensions.includes(
1101
+ selectedAsset ? selectedAsset.extension : '',
1102
+ );
1103
+ const supportedProxies = availableProxies && Object.values(availableProxies).flat().length > 0;
1104
+
1105
+ const showCustomDimension = state.selectedFormat.width && state.selectedFormat.height && state.useCustomRendition;
1106
+
1107
+ const renderBody = () => {
1108
+ let previewer = null;
1109
+ let rendition = null;
1110
+
1111
+ if (state.selectedFormat.width && state.selectedFormat.height && selectedAsset?.docType !== MediaType.Video) {
1112
+ previewer = (
1113
+ <CropPreviewer
1114
+ ref={previewerRef}
1115
+ loadable={state.previewLoadable}
1116
+ image={state.selectedFormat}
1117
+ selectedProxy={state.selectedProxy}
1118
+ resizer={state.resizeSize}
1119
+ cropper={state.cropSize}
1120
+ rotation={state.rotation}
1121
+ disabled={state.activeSetting !== 'crop' || !state.showCustomRendition}
1122
+ onCropComplete={(croppedArea) => {
1123
+ dispatch({
1124
+ type: 'SET_CROP_SIZE',
1125
+ payload: {
1126
+ percentageWidth: croppedArea.width,
1127
+ percentageHeight: croppedArea.height,
1128
+ x: croppedArea.x,
1129
+ y: croppedArea.y,
1130
+ },
1131
+ });
1132
+ }}
1133
+ onLoadingChange={onLoadingChange}
1134
+ />
1135
+ );
1136
+ } else {
1137
+ previewer = (
1138
+ <Previewer
1139
+ loadable={state.previewLoadable}
1140
+ asset={{
1141
+ docType: selectedAsset?.docType,
1142
+ imageUrl: selectedAsset?.imageUrl,
1143
+ videoUrl: previewUrl,
1144
+ extension: selectedAsset?.extension,
1145
+ }}
1146
+ onLoad={(size) => {
1147
+ if ((selectedAsset?.width && selectedAsset?.height) || !selectedAsset?.imageUrl) {
1148
+ return;
1149
+ }
1150
+
1151
+ const defaultWidth = selectedAsset?.width ? parseInt(selectedAsset.width, 10) : size.width;
1152
+ const defaultHeight = selectedAsset?.height ? parseInt(selectedAsset.height, 10) : size.height;
1153
+
1154
+ dispatch({ type: 'SET_DEFAULT_SIZE', payload: {
1155
+ width: defaultWidth,
1156
+ height: defaultHeight,
1157
+ } });
1158
+ }}
1159
+ />
1160
+ );
1161
+ }
1162
+
1163
+ if (searchInDrive) {
1164
+ return previewer;
1165
+ }
1166
+
1167
+ if (state.showCustomRendition && availableProxies) {
1168
+ rendition = (
1169
+ <CustomRendition
1170
+ activeSetting={state.activeSetting}
1171
+ extensions={
1172
+ availableExtensions && selectedAsset?.docType
1173
+ ? _uniqBy([
1174
+ ...availableExtensions[selectedAsset.docType],
1175
+ { displayName: 'Automatic', value: autoExtension },
1176
+ ], 'value')
1177
+ : [{ displayName: 'Automatic', value: autoExtension }]
1178
+ }
1179
+ availableProxies={availableProxies}
1180
+ imageSize={{
1181
+ width: state.selectedFormat.width
1182
+ ? state.selectedFormat.width
1183
+ : Infinity,
1184
+ height: state.selectedFormat.height
1185
+ ? state.selectedFormat.height
1186
+ : Infinity,
1187
+ }}
1188
+ resize={{
1189
+ width: state.resizeSize.width,
1190
+ height: state.resizeSize.height,
1191
+ unit: state.resizeSize.unit,
1192
+ }}
1193
+ crop={state.cropSize}
1194
+ lastAppliedCrop={state.lastCropSize}
1195
+ lastAppliedResize={state.lastResizeSize}
1196
+ proxy={state.selectedProxy}
1197
+ rotation={state.rotation}
1198
+ extension={state.selectedFormat.extension}
1199
+ onCropChange={onCropChange}
1200
+ onExtensionChange={onExtensionChange}
1201
+ onFormatChange={onFormatChange}
1202
+ onResizeChange={onResizeChange}
1203
+ onRotateChange={onRotateChange}
1204
+ onViewChange={onViewChange}
1205
+ />
1206
+ );
1207
+ } else {
1208
+ rendition = (
1209
+ <cx-space direction="vertical" spacing="small">
1210
+ {supportedProxies || supportedATS ? (
1211
+ <div
1212
+ style={{
1213
+ width: '100%',
1214
+ }}
1215
+ >
1216
+ {supportedProxies && (
1217
+ <ProxyMenu
1218
+ items={availableProxies.map((proxy) => {
1219
+ if (proxy.proxyName === 'TRX' && selectedAsset) {
1220
+ return {
1221
+ value: proxy.id,
1222
+ name: proxy.proxyLabel,
1223
+ cdnName: proxy.cdnName,
1224
+ width: selectedAsset.width,
1225
+ height: selectedAsset.height,
1226
+ extension: selectedAsset.extension,
1227
+ docType: selectedAsset.docType,
1228
+ };
1229
+ }
1230
+ return {
1231
+ value: proxy.id,
1232
+ name: proxy.proxyLabel,
1233
+ cdnName: proxy.cdnName,
1234
+ width: String(proxy.formatWidth),
1235
+ height: String(proxy.formatHeight),
1236
+ extension: proxy.extension ?? undefined,
1237
+ docType: selectedAsset?.docType,
1238
+ };
1239
+ })}
1240
+ selectedDisabled={state.useCustomRendition}
1241
+ selectedItem={state.selectedProxy}
1242
+ >
1243
+ {supportedRepresentative && (
1244
+ <cx-menu-item value="use-representative">
1245
+ <cx-typography
1246
+ variant="body3"
1247
+ className={`proxy__name ${
1248
+ state.useRepresentative ? 'selected' : ''
1249
+ }`}
1250
+ >
1251
+ Representative image
1252
+ </cx-typography>
1253
+ <cx-icon slot="suffix" name={state.useRepresentative ? 'check' : ''}></cx-icon>
1254
+ </cx-menu-item>
1255
+ )}
1256
+ </ProxyMenu>
1257
+ )}
1258
+ {supportedATS && (
1259
+ <ProxyMenu
1260
+ items={[]}
1261
+ selectedItem={state.selectedProxy}
1262
+ style={{
1263
+ borderTopWidth: '0',
1264
+ }}
1265
+ >
1266
+ <cx-menu-item value="custom">
1267
+ <cx-icon slot="prefix" name="crop_rotate" className='icon--large'></cx-icon>
1268
+ <div>
1269
+ <cx-typography
1270
+ variant="body3"
1271
+ className={`proxy__name ${
1272
+ state.useCustomRendition ? 'selected' : ''
1273
+ }`}
1274
+ >
1275
+ Custom format
1276
+ </cx-typography>
1277
+ {showCustomDimension && (
1278
+ <cx-typography variant="body3" className="proxy__details">
1279
+ {state.selectedFormat.width} x {state.selectedFormat.height}
1280
+ {state.selectedFormat.extension && (
1281
+ <div className="proxy__extension-dot"></div>
1282
+ )}
1283
+ {state.selectedFormat.extension?.replace(/^\./, '').toUpperCase()}
1284
+ </cx-typography>
1285
+ )}
1286
+ </div>
1287
+ <cx-icon
1288
+ slot="suffix"
1289
+ name={state.useCustomRendition ? 'edit' : ''}
1290
+ className="icon--large"
1291
+ ></cx-icon>
1292
+ <cx-icon
1293
+ slot="suffix"
1294
+ name={state.useCustomRendition ? 'check' : ''}
1295
+ className="icon--large icon--primary"
1296
+ ></cx-icon>
1297
+ </cx-menu-item>
1298
+ </ProxyMenu>
1299
+ )}
1300
+ {allowTracking && (
1301
+ <div
1302
+ style={{
1303
+ backgroundColor: 'var(--cx-color-neutral-0)',
1304
+ width: '100%',
1305
+ }}
1306
+ >
1307
+ <ProxyMenu
1308
+ style={{
1309
+ border: 'none',
1310
+ }}
1311
+ >
1312
+ <cx-menu-item value="tracking" className="proxy--switch">
1313
+ <cx-typography variant="body3" className="proxy__name">
1314
+ Tracking parameters
1315
+ </cx-typography>
1316
+ <cx-switch
1317
+ checked={state.enabledTracking}
1318
+ onClick={(e) => e.preventDefault()}
1319
+ ></cx-switch>
1320
+ </cx-menu-item>
1321
+ </ProxyMenu>
1322
+ {state.enabledTracking && (
1323
+ <TrackingParameters
1324
+ values={state.trackingParameters}
1325
+ onChange={(params) =>
1326
+ dispatch({
1327
+ type: 'SET_TRACKING_PARAMETERS',
1328
+ payload: params,
1329
+ })
1330
+ }
1331
+ />
1332
+ )}
1333
+ </div>
1334
+ )}
1335
+ </div>
1336
+ ) : (
1337
+ <cx-space
1338
+ align-items="center"
1339
+ spacing="large"
1340
+ wrap="nowrap"
1341
+ style={{
1342
+ backgroundColor: 'var(--cx-color-neutral-0)',
1343
+ width: '100%',
1344
+ padding: 'var(--cx-spacing-medium)',
1345
+ gap: '20px',
1346
+ }}
1347
+ >
1348
+ <cx-icon
1349
+ style={{
1350
+ color: 'var(--cx-color-warning)',
1351
+ }}
1352
+ name="warning"
1353
+ className="ic_warning_amber"
1354
+ ></cx-icon>
1355
+ <cx-typography variant="body3" className="proxy__name">
1356
+ You don&apos;t have permission to share this asset.
1357
+ </cx-typography>
1358
+ </cx-space>
1359
+ )}
1360
+ </cx-space>
1361
+ );
1362
+ }
1363
+
1364
+ return <>{previewer}{rendition}</>;
1365
+ };
1366
+
1367
+ const renderFooter = () => {
1368
+ if (searchInDrive) {
1369
+ return (
1370
+ <cx-button
1371
+ className="dialog__footer__button"
1372
+ onClick={onOpenInDriveConfirm}
1373
+ variant="primary"
1374
+ >
1375
+ <cx-icon slot="prefix" name="folder"></cx-icon>
1376
+ {ctaText ?? 'Open in drive'}
1377
+ </cx-button>
1378
+ );
1379
+ }
1380
+
1381
+ if (state.showCustomRendition) {
1382
+ return (
1383
+ <cx-space spacing="small" style={{ width: 'fit-content' }}>
1384
+ <cx-button
1385
+ variant="default"
1386
+ onClick={() => {
1387
+ dispatch({
1388
+ type: 'CANCEL_USE_CUSTOM_RENDITION',
1389
+ payload: {
1390
+ url: selectedAsset?.imageUrl ?? '',
1391
+ originalUrl: selectedAsset?.originalUrl ?? '',
1392
+ width: parseInt(selectedAsset?.width ?? '0', 10),
1393
+ height: parseInt(selectedAsset?.height ?? '0', 10),
1394
+ extension: selectedAsset?.extension ?? '',
1395
+ },
1396
+ });
1397
+ }}
1398
+ >
1399
+ Cancel
1400
+ </cx-button>
1401
+ <cx-button
1402
+ variant="primary"
1403
+ onClick={() => {
1404
+ dispatch({ type: 'CONFIRM_USE_CUSTOM_RENDITION' });
1405
+ }}
1406
+ >
1407
+ Done
1408
+ </cx-button>
1409
+ </cx-space>
1410
+ );
1411
+ }
1412
+
1413
+ return (
1414
+ <cx-button
1415
+ className="dialog__footer__button"
1416
+ disabled={disabledInsert}
1417
+ variant="primary"
1418
+ style={{ flex: 1 }}
1419
+ onClick={() => {
1420
+ const selectedProxy = availableProxies?.find((proxy) => {
1421
+ return proxy.id === state.selectedProxy;
1422
+ });
1423
+
1424
+ if (!state.useCustomRendition) {
1425
+ if (!selectedAsset?.docType) {
1426
+ return;
1427
+ }
1428
+
1429
+ if (!selectedProxy) {
1430
+ return;
1431
+ }
1432
+
1433
+ onProxyConfirm({
1434
+ extension: selectedProxy.extension ?? selectedAsset.extension,
1435
+ value: selectedProxy.proxyName,
1436
+ permanentLink: selectedProxy.permanentLink ?? undefined,
1437
+ parameters: state.enabledTracking
1438
+ ? state.trackingParameters
1439
+ : undefined,
1440
+ useRepresentative: state.useRepresentative,
1441
+ });
1442
+ } else {
1443
+ onFormatConfirm({
1444
+ value: state.transformations,
1445
+ parameters: state.enabledTracking
1446
+ ? state.trackingParameters
1447
+ : undefined,
1448
+ proxiesPreference: selectedProxy?.proxyName,
1449
+ extension: state.selectedFormat.extension,
1450
+ });
1451
+ }
1452
+ dispatch({ type: 'RESET_DATA' });
1453
+ onClose();
1454
+ }}
1455
+ >
1456
+ {ctaText ?? 'Insert'}
1457
+ </cx-button>
1458
+ );
1459
+ };
1460
+
1461
+ return (
1462
+ <>
1463
+ <cx-space slot="label" direction="vertical" spacing="2x-small">
1464
+ <cx-typography variant="h4">Formats</cx-typography>
1465
+ <cx-typography variant="body3" className='asset-name'>
1466
+ <cx-line-clamp lines={1}>{selectedAsset?.name}</cx-line-clamp>
1467
+ </cx-typography>
1468
+ </cx-space>
1469
+ {renderBody()}
1470
+ <div slot="footer" className="dialog__footer">
1471
+ {renderFooter()}
1472
+ </div>
1473
+ </>
1474
+ );
1475
+ }, [
1476
+ allowTracking,
1477
+ allowCustomFormat,
1478
+ autoExtension,
1479
+ availableExtensions,
1480
+ availableProxies,
1481
+ ctaText,
1482
+ extensions,
1483
+ previewUrl,
1484
+ searchInDrive,
1485
+ selectedAsset,
1486
+ supportedRepresentative,
1487
+ onClose,
1488
+ onCropChange,
1489
+ onExtensionChange,
1490
+ onFormatChange,
1491
+ onFormatConfirm,
1492
+ onLoadingChange,
1493
+ onOpenInDriveConfirm,
1494
+ onProxyConfirm,
1495
+ onResizeChange,
1496
+ onRotateChange,
1497
+ onViewChange,
1498
+ state,
1499
+ ]);
1500
+
1501
+ if (variant === 'drawer') {
1502
+ return (
1503
+ <Drawer
1504
+ ref={drawerRef}
1505
+ className="dialog"
1506
+ label="Drawer"
1507
+ placement="bottom"
1508
+ contained
1509
+ open={open}
1510
+ >
1511
+ {renderContent()}
1512
+ </Drawer>
1513
+ );
1514
+ }
1515
+
1516
+ return (
1517
+ <Dialog
1518
+ ref={dialogRef}
1519
+ className="dialog"
1520
+ open={open}
1521
+ strategy="absolute"
1522
+ style={
1523
+ {
1524
+ '--max-height': `${maxHeight}px`,
1525
+ } as CSSProperties
1526
+ }
1527
+ >
1528
+ {renderContent()}
1529
+ </Dialog>
1530
+ );
1531
+ };
1532
+
1533
+ export default FormatDialog;