@zextras/carbonio-ui-preview 1.2.2 → 1.2.4

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 (116) hide show
  1. package/README.md +62 -0
  2. package/THIRDPARTIES +388 -0
  3. package/lib/constants/index.js +2 -5
  4. package/lib/constants/index.js.map +1 -1
  5. package/lib/index.d.ts +9 -6
  6. package/lib/index.js +11 -22
  7. package/lib/index.js.map +1 -1
  8. package/lib/preview/FocusWithin.d.ts +5 -0
  9. package/lib/preview/FocusWithin.js +26 -57
  10. package/lib/preview/FocusWithin.js.map +1 -1
  11. package/lib/preview/FocusWithin.module.css +13 -0
  12. package/lib/preview/Header.d.ts +37 -4
  13. package/lib/preview/Header.js +17 -38
  14. package/lib/preview/Header.js.map +1 -1
  15. package/lib/preview/Header.module.css +37 -0
  16. package/lib/preview/ImagePreview.d.ts +7 -47
  17. package/lib/preview/ImagePreview.js +17 -96
  18. package/lib/preview/ImagePreview.js.map +1 -1
  19. package/lib/preview/ImagePreview.module.css +29 -0
  20. package/lib/preview/Navigator.d.ts +1 -0
  21. package/lib/preview/Navigator.js +7 -21
  22. package/lib/preview/Navigator.js.map +1 -1
  23. package/lib/preview/Navigator.module.css +18 -0
  24. package/lib/preview/PageController.d.ts +8 -0
  25. package/lib/preview/PageController.js +29 -67
  26. package/lib/preview/PageController.js.map +1 -1
  27. package/lib/preview/PageController.module.css +19 -0
  28. package/lib/preview/PdfPreview.d.ts +21 -69
  29. package/lib/preview/PdfPreview.js +79 -161
  30. package/lib/preview/PdfPreview.js.map +1 -1
  31. package/lib/preview/PdfPreview.module.css +46 -0
  32. package/lib/preview/PreviewCriteriaAlternativeContent.d.ts +13 -1
  33. package/lib/preview/PreviewCriteriaAlternativeContent.js +22 -55
  34. package/lib/preview/PreviewCriteriaAlternativeContent.js.map +1 -1
  35. package/lib/preview/PreviewCriteriaAlternativeContent.module.css +15 -0
  36. package/lib/preview/PreviewManager.d.ts +38 -15
  37. package/lib/preview/PreviewManager.js +40 -74
  38. package/lib/preview/PreviewManager.js.map +1 -1
  39. package/lib/preview/PreviewNavigator.d.ts +42 -0
  40. package/lib/preview/PreviewNavigator.js +29 -0
  41. package/lib/preview/PreviewNavigator.js.map +1 -0
  42. package/lib/preview/PreviewNavigator.module.css +43 -0
  43. package/lib/preview/PreviewWrapper.d.ts +14 -8
  44. package/lib/preview/PreviewWrapper.js +12 -24
  45. package/lib/preview/PreviewWrapper.js.map +1 -1
  46. package/lib/preview/ZoomController.d.ts +1 -0
  47. package/lib/preview/ZoomController.js +11 -52
  48. package/lib/preview/ZoomController.js.map +1 -1
  49. package/lib/preview/ZoomController.module.css +18 -0
  50. package/lib/preview/usePageScrollController.js +18 -22
  51. package/lib/preview/usePageScrollController.js.map +1 -1
  52. package/lib/preview/useZoom.js +31 -39
  53. package/lib/preview/useZoom.js.map +1 -1
  54. package/lib/types/utils.d.ts +4 -0
  55. package/lib/types/utils.js +2 -0
  56. package/lib/types/utils.js.map +1 -0
  57. package/lib/utils/utils.js +5 -9
  58. package/lib/utils/utils.js.map +1 -1
  59. package/package.json +55 -44
  60. package/lib/preview/StyledComponents.d.ts +0 -2
  61. package/lib/preview/StyledComponents.js +0 -21
  62. package/lib/preview/StyledComponents.js.map +0 -1
  63. package/lib/utils/type-utils.d.ts +0 -3
  64. package/lib/utils/type-utils.js +0 -3
  65. package/lib/utils/type-utils.js.map +0 -1
  66. package/lib-esm/constants/index.d.ts +0 -2
  67. package/lib-esm/constants/index.js +0 -8
  68. package/lib-esm/constants/index.js.map +0 -1
  69. package/lib-esm/index.d.ts +0 -6
  70. package/lib-esm/index.js +0 -12
  71. package/lib-esm/index.js.map +0 -1
  72. package/lib-esm/preview/FocusWithin.d.ts +0 -7
  73. package/lib-esm/preview/FocusWithin.js +0 -57
  74. package/lib-esm/preview/FocusWithin.js.map +0 -1
  75. package/lib-esm/preview/Header.d.ts +0 -29
  76. package/lib-esm/preview/Header.js +0 -39
  77. package/lib-esm/preview/Header.js.map +0 -1
  78. package/lib-esm/preview/ImagePreview.d.ts +0 -50
  79. package/lib-esm/preview/ImagePreview.js +0 -105
  80. package/lib-esm/preview/ImagePreview.js.map +0 -1
  81. package/lib-esm/preview/Navigator.d.ts +0 -5
  82. package/lib-esm/preview/Navigator.js +0 -21
  83. package/lib-esm/preview/Navigator.js.map +0 -1
  84. package/lib-esm/preview/PageController.d.ts +0 -8
  85. package/lib-esm/preview/PageController.js +0 -82
  86. package/lib-esm/preview/PageController.js.map +0 -1
  87. package/lib-esm/preview/PdfPreview.d.ts +0 -89
  88. package/lib-esm/preview/PdfPreview.js +0 -280
  89. package/lib-esm/preview/PdfPreview.js.map +0 -1
  90. package/lib-esm/preview/PreviewCriteriaAlternativeContent.d.ts +0 -13
  91. package/lib-esm/preview/PreviewCriteriaAlternativeContent.js +0 -42
  92. package/lib-esm/preview/PreviewCriteriaAlternativeContent.js.map +0 -1
  93. package/lib-esm/preview/PreviewManager.d.ts +0 -19
  94. package/lib-esm/preview/PreviewManager.js +0 -108
  95. package/lib-esm/preview/PreviewManager.js.map +0 -1
  96. package/lib-esm/preview/PreviewWrapper.d.ts +0 -9
  97. package/lib-esm/preview/PreviewWrapper.js +0 -36
  98. package/lib-esm/preview/PreviewWrapper.js.map +0 -1
  99. package/lib-esm/preview/StyledComponents.d.ts +0 -2
  100. package/lib-esm/preview/StyledComponents.js +0 -15
  101. package/lib-esm/preview/StyledComponents.js.map +0 -1
  102. package/lib-esm/preview/ZoomController.d.ts +0 -17
  103. package/lib-esm/preview/ZoomController.js +0 -28
  104. package/lib-esm/preview/ZoomController.js.map +0 -1
  105. package/lib-esm/preview/usePageScrollController.d.ts +0 -4
  106. package/lib-esm/preview/usePageScrollController.js +0 -67
  107. package/lib-esm/preview/usePageScrollController.js.map +0 -1
  108. package/lib-esm/preview/useZoom.d.ts +0 -13
  109. package/lib-esm/preview/useZoom.js +0 -78
  110. package/lib-esm/preview/useZoom.js.map +0 -1
  111. package/lib-esm/utils/type-utils.d.ts +0 -3
  112. package/lib-esm/utils/type-utils.js +0 -2
  113. package/lib-esm/utils/type-utils.js.map +0 -1
  114. package/lib-esm/utils/utils.d.ts +0 -1
  115. package/lib-esm/utils/utils.js +0 -18
  116. package/lib-esm/utils/utils.js.map +0 -1
@@ -1,34 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePageScrollController = void 0;
4
1
  /*
5
2
  * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
6
3
  *
7
4
  * SPDX-License-Identifier: AGPL-3.0-only
8
5
  */
9
- var react_1 = require("react");
10
- function usePageScrollController(scrollContainerRef, onPageChange) {
11
- var updatePageObserverRef = (0, react_1.useRef)();
12
- var currentPageIntersectionEntryRef = (0, react_1.useRef)();
13
- var observedPagesRef = (0, react_1.useRef)([]);
14
- var destroyObserver = (0, react_1.useCallback)(function () {
6
+ import { useCallback, useEffect, useRef } from 'react';
7
+ export function usePageScrollController(scrollContainerRef, onPageChange) {
8
+ const updatePageObserverRef = useRef();
9
+ const currentPageIntersectionEntryRef = useRef();
10
+ const observedPagesRef = useRef([]);
11
+ const destroyObserver = useCallback(() => {
15
12
  var _a;
16
13
  (_a = updatePageObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
17
14
  }, []);
18
- var initObserver = (0, react_1.useCallback)(function () {
15
+ const initObserver = useCallback(() => {
19
16
  // destroy before creating a new one
20
17
  destroyObserver();
21
18
  if (scrollContainerRef.current) {
22
- var clientHeight = scrollContainerRef.current.clientHeight;
23
- var options = {
19
+ const { clientHeight } = scrollContainerRef.current;
20
+ const options = {
24
21
  root: scrollContainerRef.current,
25
22
  // set root margin to be a line at ~30% of the scrollable area visible height
26
- rootMargin: "-".concat(clientHeight * 0.3, "px 0px -").concat(clientHeight * 0.65, "px 0px"),
23
+ rootMargin: `-${clientHeight * 0.3}px 0px -${clientHeight * 0.65}px 0px`,
27
24
  threshold: 0
28
25
  };
29
- updatePageObserverRef.current = new IntersectionObserver(function (entries) {
26
+ updatePageObserverRef.current = new IntersectionObserver((entries) => {
30
27
  var _a;
31
- entries.forEach(function (entry) {
28
+ entries.forEach((entry) => {
32
29
  if (entry.isIntersecting) {
33
30
  currentPageIntersectionEntryRef.current = entry;
34
31
  }
@@ -37,19 +34,19 @@ function usePageScrollController(scrollContainerRef, onPageChange) {
37
34
  }, options);
38
35
  }
39
36
  }, [destroyObserver, onPageChange, scrollContainerRef]);
40
- var reObserveAll = (0, react_1.useCallback)(function () {
37
+ const reObserveAll = useCallback(() => {
41
38
  initObserver();
42
- observedPagesRef.current.forEach(function (observedPage) {
39
+ observedPagesRef.current.forEach((observedPage) => {
43
40
  if (updatePageObserverRef.current) {
44
41
  updatePageObserverRef.current.observe(observedPage);
45
42
  }
46
43
  });
47
44
  }, [initObserver]);
48
- (0, react_1.useEffect)(function () {
45
+ useEffect(() => {
49
46
  window.addEventListener('resize', reObserveAll);
50
47
  // first run
51
48
  initObserver();
52
- return function () {
49
+ return () => {
53
50
  // on unmount
54
51
  // destroy observer
55
52
  destroyObserver();
@@ -59,13 +56,12 @@ function usePageScrollController(scrollContainerRef, onPageChange) {
59
56
  observedPagesRef.current = [];
60
57
  };
61
58
  }, [initObserver, reObserveAll, destroyObserver]);
62
- var observePage = (0, react_1.useCallback)(function (pageElement) {
59
+ const observePage = useCallback((pageElement) => {
63
60
  if (updatePageObserverRef.current) {
64
61
  updatePageObserverRef.current.observe(pageElement);
65
62
  observedPagesRef.current.push(pageElement);
66
63
  }
67
64
  }, []);
68
- return { observePage: observePage };
65
+ return { observePage };
69
66
  }
70
- exports.usePageScrollController = usePageScrollController;
71
67
  //# sourceMappingURL=usePageScrollController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePageScrollController.js","sourceRoot":"","sources":["../../src/preview/usePageScrollController.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,+BAA8D;AAE9D,SAAgB,uBAAuB,CACtC,kBAAgD,EAChD,YAAwD;IAIxD,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CAAC,OAAO,EAAE;gBAClC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;aACpD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,IAAA,iBAAS,EAAC;QACT,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,YAAY;QACZ,YAAY,EAAE,CAAC;QAEf,OAAO;YACN,aAAa;YACb,mBAAmB;YACnB,eAAe,EAAE,CAAC;YAClB,sBAAsB;YACtB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACnD,yBAAyB;YACzB,gBAAgB,CAAC,OAAO,GAAG,EAAE,CAAC;QAC/B,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;IAElD,IAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,UAAC,WAAwB;QACxD,IAAI,qBAAqB,CAAC,OAAO,EAAE;YAClC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACnD,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC3C;IACF,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,WAAW,aAAA,EAAE,CAAC;AACxB,CAAC;AAtED,0DAsEC"}
1
+ {"version":3,"file":"usePageScrollController.js","sourceRoot":"","sources":["../../src/preview/usePageScrollController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,UAAU,uBAAuB,CACtC,kBAAgD,EAChD,YAAwD;IAIxD,MAAM,qBAAqB,GAAG,MAAM,EAAwB,CAAC;IAC7D,MAAM,+BAA+B,GAAG,MAAM,EAA6B,CAAC;IAC5E,MAA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CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACrD,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,YAAY;QACZ,YAAY,EAAE,CAAC;QAEf,OAAO,GAAS,EAAE;YACjB,aAAa;YACb,mBAAmB;YACnB,eAAe,EAAE,CAAC;YAClB,sBAAsB;YACtB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACnD,yBAAyB;YACzB,gBAAgB,CAAC,OAAO,GAAG,EAAE,CAAC;QAC/B,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,WAAwB,EAAE,EAAE;QAC5D,IAAI,qBAAqB,CAAC,OAAO,EAAE,CAAC;YACnC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACnD,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,WAAW,EAAE,CAAC;AACxB,CAAC"}
@@ -1,35 +1,28 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useZoom = void 0;
7
1
  /*
8
2
  * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
9
3
  *
10
4
  * SPDX-License-Identifier: AGPL-3.0-only
11
5
  */
12
- var react_1 = require("react");
13
- var findIndex_1 = __importDefault(require("lodash/findIndex"));
14
- var findLastIndex_1 = __importDefault(require("lodash/findLastIndex"));
15
- var constants_1 = require("../constants");
16
- function useZoom(previewRef) {
17
- var _a = (0, react_1.useState)(constants_1.ZOOM_STEPS[0]), currentZoom = _a[0], setCurrentZoom = _a[1];
18
- var _b = (0, react_1.useState)(true), incrementable = _b[0], setIncrementable = _b[1];
19
- var _c = (0, react_1.useState)(false), decrementable = _c[0], setDecrementable = _c[1];
20
- var _d = (0, react_1.useState)(false), fitToWidthActive = _d[0], setFitToWidthActive = _d[1];
21
- var reset = (0, react_1.useCallback)(function () {
22
- setCurrentZoom(constants_1.ZOOM_STEPS[0]);
6
+ import { useCallback, useEffect, useState } from 'react';
7
+ import { findLastIndex } from 'lodash';
8
+ import { ZOOM_STEPS } from '../constants/index.js';
9
+ export function useZoom(previewRef) {
10
+ const [currentZoom, setCurrentZoom] = useState(ZOOM_STEPS[0]);
11
+ const [incrementable, setIncrementable] = useState(true);
12
+ const [decrementable, setDecrementable] = useState(false);
13
+ const [fitToWidthActive, setFitToWidthActive] = useState(false);
14
+ const reset = useCallback(() => {
15
+ setCurrentZoom(ZOOM_STEPS[0]);
23
16
  setIncrementable(true);
24
17
  setDecrementable(false);
25
18
  setFitToWidthActive(false);
26
19
  }, []);
27
- var increaseOfOneStep = (0, react_1.useCallback)(function () {
20
+ const increaseOfOneStep = useCallback(() => {
28
21
  if (incrementable) {
29
- var targetIndex = (0, findIndex_1.default)(constants_1.ZOOM_STEPS, function (step) { return step > currentZoom; });
22
+ const targetIndex = ZOOM_STEPS.findIndex((step) => step > currentZoom);
30
23
  if (targetIndex >= 0) {
31
- setCurrentZoom(constants_1.ZOOM_STEPS[targetIndex]);
32
- if (targetIndex === constants_1.ZOOM_STEPS.length - 1) {
24
+ setCurrentZoom(ZOOM_STEPS[targetIndex]);
25
+ if (targetIndex === ZOOM_STEPS.length - 1) {
33
26
  setIncrementable(false);
34
27
  }
35
28
  if (targetIndex > 0) {
@@ -39,47 +32,46 @@ function useZoom(previewRef) {
39
32
  }
40
33
  setFitToWidthActive(false);
41
34
  }, [currentZoom, incrementable]);
42
- var decreaseOfOneStep = (0, react_1.useCallback)(function () {
35
+ const decreaseOfOneStep = useCallback(() => {
43
36
  if (decrementable) {
44
- var targetIndex = (0, findLastIndex_1.default)(constants_1.ZOOM_STEPS, function (step) { return step < currentZoom; });
37
+ const targetIndex = findLastIndex(ZOOM_STEPS, (step) => step < currentZoom);
45
38
  if (targetIndex >= 0) {
46
- setCurrentZoom(constants_1.ZOOM_STEPS[targetIndex]);
39
+ setCurrentZoom(ZOOM_STEPS[targetIndex]);
47
40
  if (targetIndex === 0) {
48
41
  setDecrementable(false);
49
42
  }
50
- if (targetIndex < constants_1.ZOOM_STEPS.length - 1) {
43
+ if (targetIndex < ZOOM_STEPS.length - 1) {
51
44
  setIncrementable(true);
52
45
  }
53
46
  }
54
47
  }
55
48
  setFitToWidthActive(false);
56
49
  }, [currentZoom, decrementable]);
57
- var fitToWidth = (0, react_1.useCallback)(function () {
50
+ const fitToWidth = useCallback(() => {
58
51
  if (previewRef.current) {
59
52
  setCurrentZoom(previewRef.current.clientWidth);
60
- setIncrementable(previewRef.current.clientWidth < constants_1.ZOOM_STEPS[constants_1.ZOOM_STEPS.length - 1]);
61
- setDecrementable(previewRef.current.clientWidth > constants_1.ZOOM_STEPS[0]);
53
+ setIncrementable(previewRef.current.clientWidth < ZOOM_STEPS[ZOOM_STEPS.length - 1]);
54
+ setDecrementable(previewRef.current.clientWidth > ZOOM_STEPS[0]);
62
55
  setFitToWidthActive(true);
63
56
  }
64
57
  }, [previewRef]);
65
- (0, react_1.useEffect)(function () {
58
+ useEffect(() => {
66
59
  if (fitToWidthActive) {
67
60
  window.addEventListener('resize', fitToWidth);
68
61
  }
69
- return function () {
62
+ return () => {
70
63
  window.removeEventListener('resize', fitToWidth);
71
64
  };
72
65
  }, [fitToWidth, fitToWidthActive]);
73
66
  return {
74
- currentZoom: currentZoom,
75
- incrementable: incrementable,
76
- decrementable: decrementable,
77
- increaseOfOneStep: increaseOfOneStep,
78
- decreaseOfOneStep: decreaseOfOneStep,
79
- reset: reset,
80
- fitToWidth: fitToWidth,
81
- fitToWidthActive: fitToWidthActive
67
+ currentZoom,
68
+ incrementable,
69
+ decrementable,
70
+ increaseOfOneStep,
71
+ decreaseOfOneStep,
72
+ reset,
73
+ fitToWidth,
74
+ fitToWidthActive
82
75
  };
83
76
  }
84
- exports.useZoom = useZoom;
85
77
  //# sourceMappingURL=useZoom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useZoom.js","sourceRoot":"","sources":["../../src/preview/useZoom.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,+BAAgE;AAEhE,+DAAyC;AACzC,uEAAiD;AAEjD,0CAA0C;AAa1C,SAAgB,OAAO,CAAC,UAAoC;IACrD,IAAA,KAAgC,IAAA,gBAAQ,EAAC,sBAAU,CAAC,CAAC,CAAC,CAAC,EAAtD,WAAW,QAAA,EAAE,cAAc,QAA2B,CAAC;IACxD,IAAA,KAAoC,IAAA,gBAAQ,EAAC,IAAI,CAAC,EAAjD,aAAa,QAAA,EAAE,gBAAgB,QAAkB,CAAC;IACnD,IAAA,KAAoC,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAlD,aAAa,QAAA,EAAE,gBAAgB,QAAmB,CAAC;IACpD,IAAA,KAA0C,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAxD,gBAAgB,QAAA,EAAE,mBAAmB,QAAmB,CAAC;IAEhE,IAAM,KAAK,GAAG,IAAA,mBAAW,EAAC;QACzB,cAAc,CAAC,sBAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACxB,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,iBAAiB,GAAG,IAAA,mBAAW,EAAC;QACrC,IAAI,aAAa,EAAE;YAClB,IAAM,WAA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AAC,CAAC,CAAC;IAEnC,OAAO;QACN,WAAW;QACX,aAAa;QACb,aAAa;QACb,iBAAiB;QACjB,iBAAiB;QACjB,KAAK;QACL,UAAU;QACV,gBAAgB;KAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
2
+ [P in keyof T]?: T[P];
3
+ };
4
+ export type MakeRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":""}
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.print = void 0;
4
1
  /*
5
2
  * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
6
3
  *
7
4
  * SPDX-License-Identifier: AGPL-3.0-only
8
5
  */
9
- function print(documentFile) {
10
- var documentUrl = URL.createObjectURL((documentFile instanceof Blob && documentFile) || new Blob([documentFile]));
11
- var printWin = window.open(documentUrl, '');
6
+ export function print(documentFile) {
7
+ const documentUrl = URL.createObjectURL((documentFile instanceof Blob && documentFile) || new Blob([documentFile]));
8
+ const printWin = window.open(documentUrl, '');
12
9
  if (printWin) {
13
- printWin.onload = function () {
10
+ printWin.onload = () => {
14
11
  printWin.focus();
15
- setTimeout(function () {
12
+ setTimeout(() => {
16
13
  printWin.print();
17
14
  }, 1000);
18
15
  };
19
16
  }
20
17
  }
21
- exports.print = print;
22
18
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,KAAK,CAAC,YAAgC;IACrD,IAAM,WAAW,GAAG,GAAG,CAAC,eAAe,CACtC,CAAC,YAAY,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAC1E,CAAC;IACF,IAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,QAAQ,EAAE;QACb,QAAQ,CAAC,MAAM,GAAG;YACjB,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,UAAU,CAAC;gBACV,QAAQ,CAAC,KAAK,EAAE,CAAC;YAClB,CAAC,EAAE,IAAI,CAAC,CAAC;QACV,CAAC,CAAC;KACF;AACF,CAAC;AAbD,sBAaC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,YAAgC;IACrD,MAAM,WAAW,GAAG,GAAG,CAAC,eAAe,CACtC,CAAC,YAAY,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAC1E,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,QAAQ,EAAE,CAAC;QACd,QAAQ,CAAC,MAAM,GAAG,GAAS,EAAE;YAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,UAAU,CAAC,GAAG,EAAE;gBACf,QAAQ,CAAC,KAAK,EAAE,CAAC;YAClB,CAAC,EAAE,IAAI,CAAC,CAAC;QACV,CAAC,CAAC;IACH,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,75 +1,86 @@
1
1
  {
2
2
  "name": "@zextras/carbonio-ui-preview",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Preview ui utility for Zextras Carbonio",
5
- "main": "lib/index.js",
6
- "module": "lib-esm/index.js",
7
- "types": "lib/index.d.ts",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ "import": "./lib/index.js"
11
+ },
8
12
  "files": [
9
- "/lib",
10
- "/lib-esm"
13
+ "lib",
14
+ "COPYING",
15
+ "THIRDPARTIES",
16
+ "README.md"
11
17
  ],
12
18
  "scripts": {
13
- "build-cjs": "tsc",
14
- "build-esm": "tsc -m es6 --outDir lib-esm",
15
- "clean": "rm -rf lib lib-esm",
16
- "build": "npm run clean && npm run build-cjs && npm run build-esm",
17
- "prepare": "is-ci || husky install",
19
+ "prebuild:lib": "rm -rf lib",
20
+ "build:lib": "tsc -p tsconfig.lib.json && npm run copy-styles",
21
+ "prebuild:docs": "rm -rf docs",
22
+ "build:docs": "npx api-extractor run --verbose && npx api-documenter generate -i ./temp/ -o ./docs",
23
+ "prebuild:docs:local": "rm -rf docs",
24
+ "build:docs:local": "npx api-extractor run --verbose --local && npx api-documenter generate -i ./temp/ -o ./docs",
25
+ "build:local": "npm run build:lib && npm run build:docs:local",
26
+ "build": "npm run build:lib && npm run build:docs",
27
+ "prepare": "is-ci || husky",
18
28
  "prepack": "npm run build",
19
- "type-check": "tsc --project tsconfig.type-check.json",
29
+ "type-check": "tsc",
20
30
  "type-check:watch": "npm run type-check -- --watch",
21
31
  "lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs src",
22
32
  "packTo": "npm pack --pack-destination $PKG_PATH && cd $PKG_PATH && npm i zextras-carbonio-ui-preview-$npm_package_version.tgz",
23
33
  "deploy": "npm pack && rm -rf $PKG_PATH/node_modules/@zextras/carbonio-ui-preview/* && tar -xf zextras-carbonio-ui-preview-$npm_package_version.tgz -C $PKG_PATH/node_modules/@zextras/carbonio-ui-preview/ --strip-components 1",
24
34
  "test": "jest",
25
- "postbuild": "is-ci || ./scripts/check-build.sh"
35
+ "postbuild": "is-ci || ./scripts/check-build.sh",
36
+ "copy-styles": "cp src/preview/*.css lib/preview/"
26
37
  },
27
38
  "keywords": [],
28
- "author": "Zextras SF Team <https://www.zextras.com/carbonio/>",
39
+ "author": "Zextras DEV Team <https://www.zextras.com/carbonio/>",
29
40
  "license": "AGPL-3.0-only",
30
41
  "devDependencies": {
31
- "@babel/core": "^7.22.10",
32
- "@babel/preset-env": "^7.22.10",
33
- "@babel/preset-react": "^7.22.5",
34
- "@babel/preset-typescript": "^7.22.5",
35
- "@commitlint/cli": "^17.7.0",
36
- "@commitlint/config-conventional": "^17.7.0",
37
- "@faker-js/faker": "^8.0.2",
42
+ "@babel/core": "^7.24.7",
43
+ "@babel/plugin-transform-modules-commonjs": "^7.24.7",
44
+ "@babel/preset-env": "^7.24.7",
45
+ "@babel/preset-react": "^7.24.7",
46
+ "@babel/preset-typescript": "^7.24.7",
47
+ "@commitlint/cli": "^19.3.0",
48
+ "@commitlint/config-conventional": "^19.2.2",
49
+ "@faker-js/faker": "^8.4.1",
50
+ "@microsoft/api-documenter": "^7.25.3",
51
+ "@microsoft/api-extractor": "^7.47.0",
38
52
  "@testing-library/dom": "^8.20.1",
39
- "@testing-library/jest-dom": "^6.0.1",
53
+ "@testing-library/jest-dom": "^6.4.5",
40
54
  "@testing-library/react": "^12.1.5",
41
- "@testing-library/user-event": "^14.4.3",
42
- "@types/jest": "^29.5.3",
43
- "@types/lodash": "^4.14.196",
44
- "@types/react": "^17.0.63",
45
- "@types/react-dom": "^17.0.20",
46
- "@types/react-pdf": "^6.2.0",
47
- "@types/styled-components": "^5.1.26",
48
- "@zextras/carbonio-ui-configs": "^0.1.12",
49
- "babel-plugin-i18next-extract": "^0.9.0",
50
- "babel-plugin-styled-components": "^2.1.4",
55
+ "@testing-library/user-event": "^14.5.2",
56
+ "@types/jest": "^29.5.12",
57
+ "@types/lodash": "^4.17.4",
58
+ "@types/node": "^18.19.34",
59
+ "@types/react": "^17.0.80",
60
+ "@types/react-dom": "^17.0.25",
61
+ "@zextras/carbonio-ui-configs": "^1.0.1",
62
+ "babel-jest": "^29.7.0",
63
+ "eslint-import-resolver-typescript": "^3.6.1",
51
64
  "eslint-plugin-notice": "^0.9.10",
52
- "husky": "^8.0.3",
65
+ "eslint-plugin-tsdoc": "^0.3.0",
66
+ "husky": "^9.0.11",
67
+ "identity-obj-proxy": "^3.0.0",
53
68
  "is-ci": "^3.0.1",
54
- "jest": "^29.6.2",
55
- "jest-canvas-mock": "^2.5.2",
56
- "jest-environment-jsdom": "^29.6.2",
57
- "jest-fail-on-console": "^3.1.1",
58
- "jest-fetch-mock": "^3.0.3",
69
+ "jest": "^29.7.0",
70
+ "jest-environment-jsdom": "^29.7.0",
71
+ "jest-fail-on-console": "^3.3.0",
59
72
  "jest-junit": "^16.0.0",
60
- "ts-node": "^10.9.1",
61
- "web-streams-polyfill": "^3.2.1"
73
+ "ts-node": "^10.9.2"
62
74
  },
63
75
  "dependencies": {
64
- "core-js": "^3.32.0",
65
- "react-pdf": "^6.2.2"
76
+ "core-js": "^3.37.1",
77
+ "react-pdf": "^7.7.3"
66
78
  },
67
79
  "peerDependencies": {
68
80
  "@zextras/carbonio-design-system": ">=1.0.0",
69
81
  "lodash": "^4.17.21",
70
82
  "react": "^17.0.2",
71
- "react-dom": "^17.0.2",
72
- "styled-components": "^5.3.11"
83
+ "react-dom": "^17.0.2"
73
84
  },
74
85
  "browserslist": [
75
86
  ">1%",
@@ -1,2 +0,0 @@
1
- export declare const AbsoluteLeftIconButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@zextras/carbonio-design-system").IconButtonProps & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
2
- export declare const AbsoluteRightIconButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@zextras/carbonio-design-system").IconButtonProps & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- /*
3
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
4
- *
5
- * SPDX-License-Identifier: AGPL-3.0-only
6
- */
7
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
8
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
9
- return cooked;
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AbsoluteRightIconButton = exports.AbsoluteLeftIconButton = void 0;
16
- var carbonio_design_system_1 = require("@zextras/carbonio-design-system");
17
- var styled_components_1 = __importDefault(require("styled-components"));
18
- exports.AbsoluteLeftIconButton = (0, styled_components_1.default)(carbonio_design_system_1.IconButton)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tposition: absolute;\n\tleft: 0.5rem;\n\ttop: 50%;\n\tz-index: 1;\n"], ["\n\tposition: absolute;\n\tleft: 0.5rem;\n\ttop: 50%;\n\tz-index: 1;\n"])));
19
- exports.AbsoluteRightIconButton = (0, styled_components_1.default)(carbonio_design_system_1.IconButton)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\tposition: absolute;\n\tright: 0.5rem;\n\ttop: 50%;\n"], ["\n\tposition: absolute;\n\tright: 0.5rem;\n\ttop: 50%;\n"])));
20
- var templateObject_1, templateObject_2;
21
- //# sourceMappingURL=StyledComponents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StyledComponents.js","sourceRoot":"","sources":["../../src/preview/StyledComponents.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;AAEH,0EAA6D;AAC7D,wEAAuC;AAE1B,QAAA,sBAAsB,GAAG,IAAA,2BAAM,EAAC,mCAAU,CAAC,2IAAA,wEAKvD,KAAC;AAEW,QAAA,uBAAuB,GAAG,IAAA,2BAAM,EAAC,mCAAU,CAAC,6HAAA,0DAIxD,KAAC"}
@@ -1,3 +0,0 @@
1
- export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
2
- [SubKey in K]?: T[SubKey];
3
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=type-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../src/utils/type-utils.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare const ZOOM_STEPS: number[];
2
- export declare const SCROLL_STEP = 40;
@@ -1,8 +0,0 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
3
- *
4
- * SPDX-License-Identifier: AGPL-3.0-only
5
- */
6
- export var ZOOM_STEPS = [800, 1000, 1200, 1400, 1600, 2000, 2400, 3200];
7
- export var SCROLL_STEP = 40;
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,IAAM,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC1E,MAAM,CAAC,IAAM,WAAW,GAAG,EAAE,CAAC"}
@@ -1,6 +0,0 @@
1
- /** Base components */
2
- export * from './preview/ImagePreview';
3
- export * from './preview/PdfPreview';
4
- /** Utils */
5
- export * from './preview/PreviewManager';
6
- export * from './preview/PreviewWrapper';
package/lib-esm/index.js DELETED
@@ -1,12 +0,0 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2021 Zextras <https://www.zextras.com>
3
- *
4
- * SPDX-License-Identifier: AGPL-3.0-only
5
- */
6
- /** Base components */
7
- export * from './preview/ImagePreview';
8
- export * from './preview/PdfPreview';
9
- /** Utils */
10
- export * from './preview/PreviewManager';
11
- export * from './preview/PreviewWrapper';
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sBAAsB;AACtB,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,YAAY;AACZ,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface FocusContainerProps {
3
- returnFocus?: boolean;
4
- children: React.ReactChild | React.ReactChildren;
5
- }
6
- declare const FocusWithin: ({ children, returnFocus }: FocusContainerProps) => React.JSX.Element;
7
- export default FocusWithin;
@@ -1,57 +0,0 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
6
- /*
7
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
8
- *
9
- * SPDX-License-Identifier: AGPL-3.0-only
10
- */
11
- import React, { useCallback, useEffect, useRef } from 'react';
12
- import last from 'lodash/last';
13
- import styled from 'styled-components';
14
- var FocusContainer = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\toutline: none;\n\t& > * {\n\t\toutline: none;\n\t}\n"], ["\n\toutline: none;\n\t& > * {\n\t\toutline: none;\n\t}\n"])));
15
- var FocusWithin = function (_a) {
16
- var children = _a.children, _b = _a.returnFocus, returnFocus = _b === void 0 ? true : _b;
17
- var contentRef = useRef(null);
18
- var startSentinelRef = useRef(null);
19
- var endSentinelRef = useRef(null);
20
- var onStartSentinelFocus = useCallback(function () {
21
- if (contentRef.current) {
22
- var node = last(contentRef.current.querySelectorAll('[tabindex]'));
23
- node === null || node === void 0 ? void 0 : node.focus();
24
- }
25
- }, []);
26
- var onEndSentinelFocus = useCallback(function () {
27
- if (contentRef.current) {
28
- var node = contentRef.current.querySelector('[tabindex]');
29
- node === null || node === void 0 ? void 0 : node.focus();
30
- }
31
- }, []);
32
- useEffect(function () {
33
- var _a, _b, _c, _d, _e;
34
- var documentElement = (_b = (_a = window.top) === null || _a === void 0 ? void 0 : _a.document) !== null && _b !== void 0 ? _b : document;
35
- var focusedElement = documentElement.activeElement;
36
- (_c = contentRef.current) === null || _c === void 0 ? void 0 : _c.focus();
37
- (_d = startSentinelRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('focus', onStartSentinelFocus);
38
- (_e = endSentinelRef.current) === null || _e === void 0 ? void 0 : _e.addEventListener('focus', onEndSentinelFocus);
39
- var startSentinelRefSave = startSentinelRef.current;
40
- var endSentinelRefSave = endSentinelRef.current;
41
- return function () {
42
- startSentinelRefSave === null || startSentinelRefSave === void 0 ? void 0 : startSentinelRefSave.removeEventListener('focus', onStartSentinelFocus);
43
- endSentinelRefSave === null || endSentinelRefSave === void 0 ? void 0 : endSentinelRefSave.removeEventListener('focus', onEndSentinelFocus);
44
- // return focus to previous initial element
45
- if (focusedElement && returnFocus) {
46
- focusedElement.focus();
47
- }
48
- };
49
- }, [onStartSentinelFocus, onEndSentinelFocus, returnFocus]);
50
- return (React.createElement(FocusContainer, null,
51
- React.createElement("span", { tabIndex: 0, ref: startSentinelRef }),
52
- React.createElement("div", { tabIndex: -1, ref: contentRef }, children),
53
- React.createElement("span", { tabIndex: 0, ref: endSentinelRef })));
54
- };
55
- export default FocusWithin;
56
- var templateObject_1;
57
- //# sourceMappingURL=FocusWithin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FocusWithin.js","sourceRoot":"","sources":["../../src/preview/FocusWithin.tsx"],"names":[],"mappings":";;;;AAAA,wDAAwD;AACxD;;;;GAIG;AACH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,IAAM,cAAc,GAAG,MAAM,CAAC,IAAI,6HAAA,0DAKjC,IAAA,C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B,CAAC,OAAO,CAAC;QACtD,IAAM,kBAAkB,GAAG,cAAc,CAAC,OAAO,CAAC;QAElD,OAAO;YACN,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;YACzE,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;YACrE,2CAA2C;YAC3C,IAAI,cAAc,IAAI,WAAW,EAAE;gBAClC,cAAc,CAAC,KAAK,EAAE,CAAC;aACvB;QACF,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,WAAW,CAAC,CAAC,CAAC;IAE5D,OAAO,CACN,oBAAC,cAAc;QACd,8BAAM,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,gBAAgB,GAAI;QAC5C,6BAAK,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,IAChC,QAAQ,CACJ;QACN,8BAAM,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,cAAc,GAAI,CAC1B,CACjB,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { Tooltip } from '@zextras/carbonio-design-system';
3
- export interface HeaderAction {
4
- /** id used as key */
5
- id: string;
6
- /** Action called on click */
7
- onClick: (ev: React.MouseEvent<HTMLButtonElement> | KeyboardEvent) => void;
8
- /** Icon from the theme */
9
- icon: string;
10
- /** Label to show as tooltip for the action */
11
- tooltipLabel?: string;
12
- tooltipPlacement?: React.ComponentPropsWithRef<typeof Tooltip>['placement'];
13
- /** Disabled status for the action */
14
- disabled?: boolean;
15
- }
16
- export interface HeaderProps {
17
- /** Left Action for the preview */
18
- closeAction?: HeaderAction;
19
- /** Actions for the preview */
20
- actions: HeaderAction[];
21
- /** Extension of the file, shown as info */
22
- extension: string;
23
- /** Name of the file, shown as info */
24
- filename: string;
25
- /** Size of the file, shown as info */
26
- size: string;
27
- }
28
- declare const Header: React.VFC<HeaderProps>;
29
- export default Header;