@hh.ru/magritte-ui-media-viewer 1.0.7 → 1.2.0

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 (87) hide show
  1. package/index.css +166 -88
  2. package/index.d.ts +3 -4
  3. package/index.js +25 -19
  4. package/index.js.map +1 -1
  5. package/index.mock.d.ts +9 -0
  6. package/index.mock.js +55 -0
  7. package/index.mock.js.map +1 -0
  8. package/internal/Counter.js +9 -5
  9. package/internal/Counter.js.map +1 -1
  10. package/internal/GalleryItemBody.d.ts +2 -0
  11. package/internal/GalleryItemBody.js +41 -23
  12. package/internal/GalleryItemBody.js.map +1 -1
  13. package/internal/ImagesLoader.d.ts +1 -1
  14. package/internal/ImagesLoader.js +16 -6
  15. package/internal/ImagesLoader.js.map +1 -1
  16. package/internal/PreviewItem.js +3 -2
  17. package/internal/PreviewItem.js.map +1 -1
  18. package/internal/PreviewItemBody.js +28 -16
  19. package/internal/PreviewItemBody.js.map +1 -1
  20. package/internal/PreviewZoomControl.js +42 -16
  21. package/internal/PreviewZoomControl.js.map +1 -1
  22. package/internal/animations.d.ts +1 -0
  23. package/internal/animations.js +12 -0
  24. package/internal/animations.js.map +1 -0
  25. package/internal/context.d.ts +28 -9
  26. package/internal/context.js +54 -9
  27. package/internal/context.js.map +1 -1
  28. package/internal/hooks/useAutoHideTools.d.ts +2 -1
  29. package/internal/hooks/useAutoHideTools.js +23 -6
  30. package/internal/hooks/useAutoHideTools.js.map +1 -1
  31. package/internal/hooks/useDoubleTapScale.js +8 -3
  32. package/internal/hooks/useDoubleTapScale.js.map +1 -1
  33. package/internal/hooks/useGalleryItemController.d.ts +8 -8
  34. package/internal/hooks/useGalleryItemController.js +27 -14
  35. package/internal/hooks/useGalleryItemController.js.map +1 -1
  36. package/internal/hooks/usePan.d.ts +2 -2
  37. package/internal/hooks/usePan.js +2 -0
  38. package/internal/hooks/usePan.js.map +1 -1
  39. package/internal/hooks/usePinchToZoom.d.ts +2 -6
  40. package/internal/hooks/usePinchToZoom.js +4 -8
  41. package/internal/hooks/usePinchToZoom.js.map +1 -1
  42. package/internal/hooks/useSwipe.js +8 -2
  43. package/internal/hooks/useSwipe.js.map +1 -1
  44. package/internal/hooks/useSwipeToClose.d.ts +1 -1
  45. package/internal/hooks/useSwipeToClose.js +55 -33
  46. package/internal/hooks/useSwipeToClose.js.map +1 -1
  47. package/internal/hooks/useTapToToggleTools.js +4 -1
  48. package/internal/hooks/useTapToToggleTools.js.map +1 -1
  49. package/internal/hooks/useVirtualization.js +2 -0
  50. package/internal/hooks/useVirtualization.js.map +1 -1
  51. package/internal/hooks/useWheelToZoom.d.ts +2 -6
  52. package/internal/hooks/useWheelToZoom.js +6 -10
  53. package/internal/hooks/useWheelToZoom.js.map +1 -1
  54. package/internal/utils.d.ts +5 -2
  55. package/internal/utils.js +19 -5
  56. package/internal/utils.js.map +1 -1
  57. package/media-viewer-EEyLOGS2.js +5 -0
  58. package/media-viewer-EEyLOGS2.js.map +1 -0
  59. package/package.json +12 -7
  60. package/public/Footer.d.ts +2 -0
  61. package/public/Footer.js +10 -0
  62. package/public/Footer.js.map +1 -0
  63. package/public/Gallery.js +46 -16
  64. package/public/Gallery.js.map +1 -1
  65. package/public/GalleryItem.d.ts +2 -2
  66. package/public/GalleryItem.js +8 -3
  67. package/public/GalleryItem.js.map +1 -1
  68. package/public/Header.d.ts +2 -0
  69. package/public/Header.js +10 -0
  70. package/public/Header.js.map +1 -0
  71. package/public/MediaViewer.d.ts +13 -2
  72. package/public/MediaViewer.js +299 -65
  73. package/public/MediaViewer.js.map +1 -1
  74. package/public/Preview.d.ts +2 -6
  75. package/public/Preview.js +22 -15
  76. package/public/Preview.js.map +1 -1
  77. package/public/Toolbar.d.ts +6 -6
  78. package/public/Toolbar.js +12 -8
  79. package/public/Toolbar.js.map +1 -1
  80. package/public/Tools.d.ts +2 -0
  81. package/public/Tools.js +11 -2
  82. package/public/Tools.js.map +1 -1
  83. package/internal/ObservableValue.d.ts +0 -9
  84. package/internal/ObservableValue.js +0 -29
  85. package/internal/ObservableValue.js.map +0 -1
  86. package/media-viewer-BNuKXbLq.js +0 -5
  87. package/media-viewer-BNuKXbLq.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Counter.js","sources":["../../src/internal/Counter.tsx"],"sourcesContent":["import { type FC, type ReactElement, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { useMotionValueEvent } from 'motion/react';\n\nimport { BottomSheet } from '@hh.ru/magritte-ui-bottom-sheet';\nimport type { GalleryItemProps } from '@hh.ru/magritte-ui-media-viewer/internal/GalleryItemBody';\nimport { useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { Tooltip } from '@hh.ru/magritte-ui-tooltip';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\nexport const Counter: FC<{ items: ReactElement<GalleryItemProps>[] }> = ({ items }) => {\n const globalContext = useMediaViewerContext();\n const [currentItemIndex, setCurrentItemIndex] = useState(globalContext.currentSlideIndex.get());\n const [showDescription, setShowDescription] = useState(false);\n const description = items[currentItemIndex]?.props.description;\n const elementRef = useRef<HTMLDivElement>(null);\n\n useMotionValueEvent(globalContext.currentSlideIndex, 'change', (newIndex) => {\n setShowDescription(false);\n setCurrentItemIndex(Math.round(newIndex));\n });\n\n if (items.length <= 1) {\n return null;\n }\n\n return (\n <div\n className={classNames(styles.previewCounter, { [styles.withDescription]: !!description })}\n onClick={() => {\n setShowDescription(!!description);\n }}\n >\n <span className={styles.counterNumber}>\n <Text\n style=\"contrast\"\n typography=\"subtitle-1-semibold\"\n ellipsis\n >{`${currentItemIndex + 1} / ${items.length}`}</Text>\n </span>\n {!!description && (\n <>\n <span ref={elementRef}>\n <Text style=\"contrast-secondary\" typography=\"label-4-regular\" ellipsis>\n {description}\n </Text>\n </span>\n <Tooltip\n placement={'top-center'}\n activatorRef={elementRef}\n closeByClickOutside\n visible={showDescription}\n onClose={() => setShowDescription(false)}\n >\n {description}\n </Tooltip>\n <BottomSheet visible={showDescription} onClose={() => setShowDescription(false)}>\n <Text style=\"primary\" typography=\"paragraph-2-regular\">\n {description}\n </Text>\n </BottomSheet>\n </>\n )}\n {!description && <span className={styles.noDescriptionPlaceholder}></span>}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;MAYa,OAAO,GAAoD,CAAC,EAAE,KAAK,EAAE,KAAI;AAClF,IAAA,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;AAC9C,IAAA,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC;IAChG,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;AAC/D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEhD,mBAAmB,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,EAAE,CAAC,QAAQ,KAAI;QACxE,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9C,KAAC,CAAC,CAAC;AAEH,IAAA,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;AACnB,QAAA,OAAO,IAAI,CAAC;KACf;IAED,QACIA,IACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EACzF,OAAO,EAAE,MAAK;AACV,YAAA,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AACtC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sx"],"sourcesContent":["import { type FC, type ReactElement, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { useMotionValueEvent } from 'motion/react';\n\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { BottomSheet } from '@hh.ru/magritte-ui-bottom-sheet';\nimport type { GalleryItemProps } from '@hh.ru/magritte-ui-media-viewer/internal/GalleryItemBody';\nimport { useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { TooltipHover } from '@hh.ru/magritte-ui-tooltip';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\nexport const Counter: FC<{ items: ReactElement<GalleryItemProps>[] }> = ({ items }) => {\n const globalContext = useMediaViewerContext();\n const [currentItemIndex, setCurrentItemIndex] = useState(Math.round(globalContext.currentSlideIndex.get()));\n const [showDescription, setShowDescription] = useState(false);\n const description = items[currentItemIndex]?.props.description;\n const elementRef = useRef<HTMLDivElement>(null);\n\n useMotionValueEvent(globalContext.currentSlideIndex, 'change', (newIndex) => {\n setShowDescription(false);\n setCurrentItemIndex(Math.round(newIndex));\n });\n\n const ofTrl = useTranslation('MediaViewer', 'of');\n\n if (items.length <= 1) {\n return null;\n }\n\n return (\n <div\n className={classNames(styles.previewCounter, { [styles.withDescription]: !!description })}\n onClick={() => {\n setShowDescription(!!description);\n }}\n >\n <span className={styles.counterNumber} aria-atomic=\"true\" aria-live=\"polite\">\n <Text\n style=\"contrast\"\n typography=\"subtitle-1-semibold\"\n ellipsis\n >{`${currentItemIndex + 1} ${ofTrl} ${items.length}`}</Text>\n </span>\n {!!description && (\n <>\n <span ref={elementRef} className={styles.description}>\n <Text style=\"contrast-secondary\" typography=\"label-4-regular\" ellipsis>\n {description}\n </Text>\n </span>\n <TooltipHover\n placement={'top-center'}\n activatorRef={elementRef}\n size=\"small\"\n onClose={() => setShowDescription(false)}\n ignoreIntersections={false}\n >\n {description}\n </TooltipHover>\n <BottomSheet visible={showDescription} onClose={() => setShowDescription(false)}>\n <div className={styles.descriptionBottomSheetContent}>\n <Text style=\"primary\" typography=\"paragraph-2-regular\">\n {description}\n </Text>\n </div>\n </BottomSheet>\n </>\n )}\n {!description && <span className={styles.noDescriptionPlaceholder}></span>}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;MAaa,OAAO,GAAoD,CAAC,EAAE,KAAK,EAAE,KAAI;AAClF,IAAA,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;IAC9C,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5G,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;AAC/D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEhD,mBAAmB,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,EAAE,CAAC,QAAQ,KAAI;QACxE,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9C,KAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAElD,IAAA,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;AACnB,QAAA,OAAO,IAAI,CAAC;KACf;IAED,QACIA,IACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EACzF,OAAO,EAAE,M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,CAAA,EAAA,CACf,CACN,EACA,CAAC,WAAW,IAAIA,GAAM,CAAA,MAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,wBAAwB,EAAS,CAAA,CAAA,EAAA,CACxE,EACR;AACN;;;;"}
@@ -3,7 +3,9 @@ import { type FC } from 'react';
3
3
  export interface GalleryItemProps {
4
4
  /** Описание элемента */
5
5
  description?: string;
6
+ /** URL изображения */
6
7
  src: string;
8
+ /** URL превью изображения */
7
9
  previewSrc?: string;
8
10
  }
9
11
  /** Внутренние пропсы GalleryItem — включают index, инжектируемый Gallery */
@@ -1,7 +1,11 @@
1
1
  import './../index.css';
2
- import { jsx } from 'react/jsx-runtime';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { useState, useEffect } from 'react';
4
- import { useTransform, useMotionValue, useMotionValueEvent, animate, motion } from 'motion/react';
4
+ import { useMotionValueEvent, useTransform, useMotionValue, animate, motion } from 'motion/react';
5
+ import { useTranslation } from '@hh.ru/magritte-common-use-translation';
6
+ import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
7
+ import { Loader } from '@hh.ru/magritte-ui-loader';
8
+ import { EASE_BASE } from './animations.js';
5
9
  import { useMediaViewerContext, GalleryItemContext } from './context.js';
6
10
  import { useDoubleTapScale } from './hooks/useDoubleTapScale.js';
7
11
  import { useGalleryItemController, isFullyInvisible } from './hooks/useGalleryItemController.js';
@@ -9,29 +13,46 @@ import { usePan } from './hooks/usePan.js';
9
13
  import { usePinchToZoom } from './hooks/usePinchToZoom.js';
10
14
  import { useWheelToZoom } from './hooks/useWheelToZoom.js';
11
15
  import { lerp, clamp } from './utils.js';
12
- import { s as styles } from '../media-viewer-BNuKXbLq.js';
16
+ import { Text } from '@hh.ru/magritte-ui-typography';
17
+ import { s as styles } from '../media-viewer-EEyLOGS2.js';
13
18
  import './ImagesLoader.js';
14
- import './ObservableValue.js';
15
19
  import '@use-gesture/react';
16
20
 
17
21
  const SLIDE_GAP = 24;
18
22
  const GalleryItemBody = ({ index = 0, src, description }) => {
19
23
  const globalContext = useMediaViewerContext();
20
- const [setContentSize, controller] = useGalleryItemController(globalContext);
24
+ const [setContentSize, controller] = useGalleryItemController(globalContext, src, index, description);
21
25
  controller.index.set(index);
22
26
  const bindPinchToZoom = usePinchToZoom(controller, globalContext.viewPortDimensions);
23
27
  const bindPan = usePan(controller, globalContext.viewPortDimensions);
24
28
  const bindDoubleTapScale = useDoubleTapScale(controller);
25
29
  const bindWheelToZoom = useWheelToZoom(controller, globalContext.viewPortDimensions);
26
30
  const [isVisible, setIsVisible] = useState(() => controller.contentSize.get() !== null);
27
- useEffect(() => {
31
+ const [loadingFailed, setLoadingFailed] = useState(false);
32
+ const loadErrTrl = useTranslation('MediaViewer', 'itemLoadErrorTitle');
33
+ const loadErrDescTrl = useTranslation('MediaViewer', 'itemLoadErrorDescription');
34
+ useMotionValueEvent(controller.contentSize, 'change', () => {
28
35
  setIsVisible(controller.contentSize.get() !== null);
29
- return controller.contentSize.on('change', () => {
30
- setIsVisible(controller.contentSize.get() !== null);
31
- });
32
- }, [controller.contentSize]);
36
+ });
33
37
  useEffect(() => {
34
- return globalContext.imagesLoader.waitingForUrl(src, ({ width, height }) => {
38
+ const meta = globalContext.imagesLoader.getUrlMeta(src);
39
+ if (meta) {
40
+ if (meta.status === 'loaded' && meta.width && meta.height) {
41
+ setContentSize({ width: meta.width, height: meta.height });
42
+ return void 0;
43
+ }
44
+ if (meta.status === 'error') {
45
+ setLoadingFailed(true);
46
+ return void 0;
47
+ }
48
+ }
49
+ setIsVisible(false);
50
+ setLoadingFailed(false);
51
+ return globalContext.imagesLoader.waitingForUrl(src, ({ status, width, height }) => {
52
+ if (status === 'error') {
53
+ setLoadingFailed(true);
54
+ return;
55
+ }
35
56
  width && height && setContentSize({ width, height });
36
57
  });
37
58
  }, [setContentSize, globalContext, src]);
@@ -49,19 +70,16 @@ const GalleryItemBody = ({ index = 0, src, description }) => {
49
70
  rotate.set(targetRotation);
50
71
  return;
51
72
  }
52
- animate(rotate, targetRotation, { duration: 0.2 });
53
- animate(controller.offsetX, 0, { duration: 0.2 });
54
- animate(controller.offsetY, 0, { duration: 0.2 });
73
+ animate(rotate, targetRotation, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });
74
+ animate(controller.offsetX, 0, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });
75
+ animate(controller.offsetY, 0, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });
55
76
  });
56
- if (!isVisible) {
57
- return null;
58
- }
59
- return (jsx(GalleryItemContext.Provider, { value: setContentSize, children: jsx(motion.div, { className: styles.galleryItem, style: { x: translateX }, ...bindPinchToZoom, ...bindPan(), ...bindDoubleTapScale, ...bindWheelToZoom, children: jsx(motion.div, { className: styles.galleryItemTransformContainer, style: {
60
- scale: controller.scale,
61
- rotate,
62
- x,
63
- y,
64
- }, draggable: false, children: jsx("img", { src: src, alt: description || '', draggable: false }) }) }) }));
77
+ return (jsx(GalleryItemContext.Provider, { value: setContentSize, children: jsxs(motion.div, { className: styles.galleryItem, style: { x: translateX }, ...bindPinchToZoom, ...bindPan(), ...bindDoubleTapScale, ...bindWheelToZoom, children: [!!loadingFailed && (jsxs("div", { className: styles.galleryItemErrorContainer, children: [jsx(Text, { typography: "title-5-semibold", style: "contrast", Element: "span", children: loadErrTrl }), jsx(Text, { typography: "paragraph-2-regular", style: "contrast-secondary", Element: "span", children: loadErrDescTrl })] })), !isVisible && !loadingFailed && (jsx("div", { className: styles.galleryItemLoader, children: jsx(Loader, { size: 48, initial: "constant-secondary" }) })), !!isVisible && (jsx(motion.div, { className: styles.galleryItemTransformContainer, style: {
78
+ scale: controller.scale,
79
+ rotate,
80
+ x,
81
+ y,
82
+ }, draggable: false, children: jsx("img", { src: src, alt: description || '', draggable: false }) }))] }) }));
65
83
  };
66
84
 
67
85
  export { GalleryItemBody };
@@ -1 +1 @@
1
- {"version":3,"file":"GalleryItemBody.js","sources":["../../src/internal/GalleryItemBody.tsx"],"sourcesContent":["import { type FC, useEffect, useState } from 'react';\nimport { motion, useMotionValue, useTransform, animate, useMotionValueEvent, HTMLMotionProps } from 'motion/react';\n\nimport { useMediaViewerContext, GalleryItemContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { useDoubleTapScale } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useDoubleTapScale';\nimport {\n useGalleryItemController,\n isFullyInvisible,\n} from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useGalleryItemController';\nimport { usePan } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/usePan';\nimport { usePinchToZoom } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/usePinchToZoom';\nimport { useWheelToZoom } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useWheelToZoom';\nimport { lerp, clamp } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nimport styles from '../public/media-viewer.less';\n\n/** Внешние пропсы GalleryItem — то, что передаёт пользователь */\nexport interface GalleryItemProps {\n /** Описание элемента */\n description?: string;\n src: string;\n previewSrc?: string;\n}\n\n/** Внутренние пропсы GalleryItem — включают index, инжектируемый Gallery */\nexport interface GalleryItemInternalProps extends GalleryItemProps {\n index: number;\n}\n\nconst SLIDE_GAP = 24;\n\nexport const GalleryItemBody: FC<GalleryItemInternalProps> = ({ index = 0, src, description }) => {\n const globalContext = useMediaViewerContext();\n const [setContentSize, controller] = useGalleryItemController(globalContext);\n controller.index.set(index);\n\n const bindPinchToZoom = usePinchToZoom(controller, globalContext.viewPortDimensions);\n const bindPan = usePan(controller, globalContext.viewPortDimensions);\n const bindDoubleTapScale = useDoubleTapScale(controller);\n const bindWheelToZoom = useWheelToZoom(controller, globalContext.viewPortDimensions);\n\n const [isVisible, setIsVisible] = useState(() => controller.contentSize.get() !== null);\n\n useEffect(() => {\n setIsVisible(controller.contentSize.get() !== null);\n return controller.contentSize.on('change', () => {\n setIsVisible(controller.contentSize.get() !== null);\n });\n }, [controller.contentSize]);\n\n useEffect(() => {\n return globalContext.imagesLoader.waitingForUrl(src, ({ width, height }) => {\n width && height && setContentSize({ width, height });\n });\n }, [setContentSize, globalContext, src]);\n\n const translateX = useTransform(globalContext.currentSlideIndex, (value) => {\n const progress = clamp(index - value, -1, 1);\n return `calc(${lerp(0, 100, progress)}% + ${lerp(0, SLIDE_GAP, progress)}px)`;\n });\n\n const x = useTransform(controller.offsetX, (value) => `calc(-50% + ${value}px)`);\n const y = useTransform(controller.offsetY, (value) => `calc(-50% + ${value}px)`);\n const rotate = useMotionValue(0);\n useMotionValueEvent(controller.rotation, 'change', (value) => {\n const targetRotation = value * 90;\n rotate.stop();\n if (isFullyInvisible(controller, globalContext)) {\n rotate.set(targetRotation);\n return;\n }\n animate(rotate, targetRotation, { duration: 0.2 });\n animate(controller.offsetX, 0, { duration: 0.2 });\n animate(controller.offsetY, 0, { duration: 0.2 });\n });\n\n if (!isVisible) {\n return null;\n }\n\n return (\n <GalleryItemContext.Provider value={setContentSize}>\n <motion.div\n className={styles.galleryItem}\n style={{ x: translateX }}\n {...bindPinchToZoom}\n {...(bindPan() as HTMLMotionProps<'div'>)}\n {...bindDoubleTapScale}\n {...bindWheelToZoom}\n >\n <motion.div\n className={styles.galleryItemTransformContainer}\n style={{\n scale: controller.scale,\n rotate,\n x,\n y,\n }}\n draggable={false}\n >\n <img src={src} alt={description || ''} draggable={false} />\n </motion.div>\n </motion.div>\n </GalleryItemContext.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,SAAS,GAAG,EAAE,CAAC;AAEd,MAAM,eAAe,GAAiC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,KAAI;AAC7F,IAAA,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;IAC9C,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC;AAC7E,I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AI,CAAC;KACf;IAED,QACIA,IAAC,kBAAkB,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,cAAc,EAC9C,QAAA,EAAAA,GAAA,CAAC,MAAM,CAAC,GAAG,EACP,EAAA,SAAS,EAAE,MAAM,CAAC,WAAW,EAC7B,KAAK,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,KACpB,eAAe,EAAA,GACd,OAAO,EAA6B,EAAA,GACrC,kBAAkB,EAAA,GAClB,eAAe,EAAA,QAAA,EAEnBA,IAAC,MAAM,CAAC,GAAG,EAAA,EACP,SAAS,EAAE,MAAM,CAAC,6BAA6B,EAC/C,KAAK,EAAE;oBACH,KAAK,EAAE,UAAU,CAAC,KAAK;oBACvB,MAAM;oBACN,CAAC;oBACD,CAAC;iBACJ,EACD,SAAS,EAAE,KAAK,EAAA,QAAA,EAEhBA,aAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,GAAI,EAClD,CAAA,EAAA,CACJ,EACa,CAAA,EAChC;AACN;;;;"}
1
+ {"version":3,"file":"GalleryItemBody.js","sources":["../../src/internal/GalleryItemBody.tsx"],"sourcesContent":["import { type FC, useEffect, useState } from 'react';\nimport { motion, useMotionValue, useTransform, animate, useMotionValueEvent, HTMLMotionProps } from 'motion/react';\n\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { useMediaViewerContext, GalleryItemContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { useDoubleTapScale } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useDoubleTapScale';\nimport {\n useGalleryItemController,\n isFullyInvisible,\n} from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useGalleryItemController';\nimport { usePan } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/usePan';\nimport { usePinchToZoom } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/usePinchToZoom';\nimport { useWheelToZoom } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useWheelToZoom';\nimport { lerp, clamp } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\n/** Внешние пропсы GalleryItem — то, что передаёт пользователь */\nexport interface GalleryItemProps {\n /** Описание элемента */\n description?: string;\n /** URL изображения */\n src: string;\n /** URL превью изображения */\n previewSrc?: string;\n}\n\n/** Внутренние пропсы GalleryItem — включают index, инжектируемый Gallery */\nexport interface GalleryItemInternalProps extends GalleryItemProps {\n index: number;\n}\n\nconst SLIDE_GAP = 24;\n\nexport const GalleryItemBody: FC<GalleryItemInternalProps> = ({ index = 0, src, description }) => {\n const globalContext = useMediaViewerContext();\n const [setContentSize, controller] = useGalleryItemController(globalContext, src, index, description);\n controller.index.set(index);\n\n const bindPinchToZoom = usePinchToZoom(controller, globalContext.viewPortDimensions);\n const bindPan = usePan(controller, globalContext.viewPortDimensions);\n const bindDoubleTapScale = useDoubleTapScale(controller);\n const bindWheelToZoom = useWheelToZoom(controller, globalContext.viewPortDimensions);\n\n const [isVisible, setIsVisible] = useState(() => controller.contentSize.get() !== null);\n const [loadingFailed, setLoadingFailed] = useState(false);\n\n const loadErrTrl = useTranslation('MediaViewer', 'itemLoadErrorTitle');\n const loadErrDescTrl = useTranslation('MediaViewer', 'itemLoadErrorDescription');\n\n useMotionValueEvent(controller.contentSize, 'change', () => {\n setIsVisible(controller.contentSize.get() !== null);\n });\n\n useEffect(() => {\n const meta = globalContext.imagesLoader.getUrlMeta(src);\n if (meta) {\n if (meta.status === 'loaded' && meta.width && meta.height) {\n setContentSize({ width: meta.width, height: meta.height });\n return void 0;\n }\n if (meta.status === 'error') {\n setLoadingFailed(true);\n return void 0;\n }\n }\n\n setIsVisible(false);\n setLoadingFailed(false);\n\n return globalContext.imagesLoader.waitingForUrl(src, ({ status, width, height }) => {\n if (status === 'error') {\n setLoadingFailed(true);\n return;\n }\n\n width && height && setContentSize({ width, height });\n });\n }, [setContentSize, globalContext, src]);\n\n const translateX = useTransform(globalContext.currentSlideIndex, (value) => {\n const progress = clamp(index - value, -1, 1);\n return `calc(${lerp(0, 100, progress)}% + ${lerp(0, SLIDE_GAP, progress)}px)`;\n });\n\n const x = useTransform(controller.offsetX, (value) => `calc(-50% + ${value}px)`);\n const y = useTransform(controller.offsetY, (value) => `calc(-50% + ${value}px)`);\n const rotate = useMotionValue(0);\n useMotionValueEvent(controller.rotation, 'change', (value) => {\n const targetRotation = value * 90;\n rotate.stop();\n if (isFullyInvisible(controller, globalContext)) {\n rotate.set(targetRotation);\n return;\n }\n animate(rotate, targetRotation, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });\n animate(controller.offsetX, 0, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });\n animate(controller.offsetY, 0, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });\n });\n\n return (\n <GalleryItemContext.Provider value={setContentSize}>\n <motion.div\n className={styles.galleryItem}\n style={{ x: translateX }}\n {...bindPinchToZoom}\n {...(bindPan() as HTMLMotionProps<'div'>)}\n {...bindDoubleTapScale}\n {...bindWheelToZoom}\n >\n {!!loadingFailed && (\n <div className={styles.galleryItemErrorContainer}>\n <Text typography=\"title-5-semibold\" style=\"contrast\" Element=\"span\">\n {loadErrTrl}\n </Text>\n <Text typography=\"paragraph-2-regular\" style=\"contrast-secondary\" Element=\"span\">\n {loadErrDescTrl}\n </Text>\n </div>\n )}\n {!isVisible && !loadingFailed && (\n <div className={styles.galleryItemLoader}>\n <Loader size={48} initial=\"constant-secondary\" />\n </div>\n )}\n {!!isVisible && (\n <motion.div\n className={styles.galleryItemTransformContainer}\n style={{\n scale: controller.scale,\n rotate,\n x,\n y,\n }}\n draggable={false}\n >\n <img src={src} alt={description || ''} draggable={false} />\n </motion.div>\n )}\n </motion.div>\n </GalleryItemContext.Provider>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAS,GAAG,EAAE,CAAC;AAEd,MAAM,eAAe,GAAiC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,KAAI;AAC7F,IAAA,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;AAC9C,IAAA,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG,wBAAwB,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;AACtG,IAAA,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE5B,MAAM,eAAe,GAAG,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;AACrE,IAAA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACzD,MAAM,eAAe,GAAG,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAErF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;IACxF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1D,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IACvE,MAAM,cAAc,GAAG,cAAc,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAC;IAEjF,mBAAmB,CAAC,UAAU,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAK;QAC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AA,EAAAA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAA,CAAI,GAClD,CAChB,CAAA,EAAA,CACQ,EACa,CAAA,EAChC;AACN;;;;"}
@@ -1,6 +1,6 @@
1
1
  interface GalleryItemMeta {
2
2
  type: 'image' | 'video';
3
- status: 'loaded' | 'loading';
3
+ status: 'loaded' | 'loading' | 'error';
4
4
  width?: number;
5
5
  height?: number;
6
6
  url?: string;
@@ -6,12 +6,8 @@ class ImagesLoader {
6
6
  }
7
7
  waitingForUrl(url, callback = null) {
8
8
  let callbackFn = callback;
9
- this.loadImage(url)
10
- .then((meta) => {
9
+ void this.loadImage(url).then((meta) => {
11
10
  callbackFn?.(meta);
12
- })
13
- .catch(() => {
14
- console.error('Failed to load URL', url);
15
11
  });
16
12
  return () => (callbackFn = null);
17
13
  }
@@ -23,11 +19,25 @@ class ImagesLoader {
23
19
  status: 'loading',
24
20
  loadPromise: new Promise((resolve) => {
25
21
  const img = new Image();
22
+ img.onerror = () => {
23
+ const meta = this.galleryItemsMeta.get(url);
24
+ meta.status = 'error';
25
+ resolve(meta);
26
+ };
26
27
  img.onload = () => {
27
28
  const meta = this.galleryItemsMeta.get(url);
28
29
  meta.width = img.naturalWidth;
29
30
  meta.height = img.naturalHeight;
30
- void img.decode().then(() => resolve(meta));
31
+ void img
32
+ .decode()
33
+ .then(() => {
34
+ meta.status = 'loaded';
35
+ resolve(meta);
36
+ })
37
+ .catch(() => {
38
+ meta.status = 'error';
39
+ resolve(meta);
40
+ });
31
41
  };
32
42
  img.src = url;
33
43
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"ImagesLoader.js","sources":["../../src/internal/ImagesLoader.ts"],"sourcesContent":["interface GalleryItemMeta {\n type: 'image' | 'video';\n status: 'loaded' | 'loading';\n width?: number;\n height?: number;\n url?: string;\n loadPromise: Promise<GalleryItemMeta>;\n}\n\nexport class ImagesLoader {\n private galleryItemsMeta: Map<string, GalleryItemMeta> = new Map();\n\n getUrlMeta(url: string): GalleryItemMeta | undefined {\n return this.galleryItemsMeta.get(url);\n }\n\n waitingForUrl(url: string, callback: ((meta: GalleryItemMeta) => void) | null = null): VoidFunction {\n let callbackFn: ((meta: GalleryItemMeta) => void) | null = callback;\n this.loadImage(url)\n .then((meta) => {\n callbackFn?.(meta);\n })\n .catch(() => {\n console.error('Failed to load URL', url);\n });\n\n return () => (callbackFn = null);\n }\n\n private loadImage(url: string): Promise<GalleryItemMeta> {\n let meta = this.galleryItemsMeta.get(url);\n if (!meta) {\n meta = {\n type: 'image',\n status: 'loading',\n loadPromise: new Promise((resolve) => {\n const img = new Image();\n img.onload = () => {\n const meta = this.galleryItemsMeta.get(url) as GalleryItemMeta;\n meta.width = img.naturalWidth;\n meta.height = img.naturalHeight;\n void img.decode().then(() => resolve(meta));\n };\n img.src = url;\n }),\n };\n this.galleryItemsMeta.set(url, meta);\n }\n return meta.loadPromise;\n }\n}\n"],"names":[],"mappings":"MASa,YAAY,CAAA;AACb,IAAA,gBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;AAEnE,IAAA,UAAU,CAAC,GAAW,EAAA;QAClB,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACzC;AAED,IAAA,aAAa,CAAC,GAAW,EAAE,QAAA,GAAqD,IAAI,EAAA;QAChF,IAAI,UAAU,GAA6C,QAAQ,CAAC;AACpE,QAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;AACd,aAAA,IAAI,CAAC,CAAC,IAAI,KAAI;AACX,YAAA,UAAU,GAAG,IAAI,CAAC,CAAC;AACvB,SAAC,CAAC;aACD,KAAK,CAAC,MAAK;AACR,YAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;AAC7C,SAAC,CAAC,CAAC;QAEP,OAAO,OAAO,UAAU,GAAG,IAAI,CAAC,CAAC;KACpC;AAEO,IAAA,SAAS,CAAC,GAAW,EAAA;QACzB,IAAI,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE;AACP,YAAA,IAAI,GAAG;AACH,gBAAA,IAAI,EAAE,OAAO;AACb,gBAAA,MAAM,EAAE,SAAS;AACjB,gBAAA,WAAW,EAAE,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;AACjC,oBAAA,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;AACxB,oBAAA,GAAG,CAAC,MAAM,GAAG,MAAK;wBACd,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAoB,CAAC;AAC/D,wBAAA,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC;AAC9B,wBAAA,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC;AAChC,wBAAA,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,qBAAC,CAAC;AACF,oBAAA,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;AAClB,iBAAC,CAAC;aACL,CAAC;YACF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;KAC3B;AACJ;;;;"}
1
+ {"version":3,"file":"ImagesLoader.js","sources":["../../src/internal/ImagesLoader.ts"],"sourcesContent":["interface GalleryItemMeta {\n type: 'image' | 'video';\n status: 'loaded' | 'loading' | 'error';\n width?: number;\n height?: number;\n url?: string;\n loadPromise: Promise<GalleryItemMeta>;\n}\n\nexport class ImagesLoader {\n private galleryItemsMeta: Map<string, GalleryItemMeta> = new Map();\n\n getUrlMeta(url: string): GalleryItemMeta | undefined {\n return this.galleryItemsMeta.get(url);\n }\n\n waitingForUrl(url: string, callback: ((meta: GalleryItemMeta) => void) | null = null): VoidFunction {\n let callbackFn: ((meta: GalleryItemMeta) => void) | null = callback;\n void this.loadImage(url).then((meta) => {\n callbackFn?.(meta);\n });\n\n return () => (callbackFn = null);\n }\n\n private loadImage(url: string): Promise<GalleryItemMeta> {\n let meta = this.galleryItemsMeta.get(url);\n if (!meta) {\n meta = {\n type: 'image',\n status: 'loading',\n loadPromise: new Promise((resolve) => {\n const img = new Image();\n img.onerror = () => {\n const meta = this.galleryItemsMeta.get(url) as GalleryItemMeta;\n meta.status = 'error';\n resolve(meta);\n };\n img.onload = () => {\n const meta = this.galleryItemsMeta.get(url) as GalleryItemMeta;\n meta.width = img.naturalWidth;\n meta.height = img.naturalHeight;\n void img\n .decode()\n .then(() => {\n meta.status = 'loaded';\n resolve(meta);\n })\n .catch(() => {\n meta.status = 'error';\n resolve(meta);\n });\n };\n img.src = url;\n }),\n };\n this.galleryItemsMeta.set(url, meta);\n }\n return meta.loadPromise;\n }\n}\n"],"names":[],"mappings":"MASa,YAAY,CAAA;AACb,IAAA,gBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;AAEnE,IAAA,UAAU,CAAC,GAAW,EAAA;QAClB,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACzC;AAED,IAAA,aAAa,CAAC,GAAW,EAAE,QAAA,GAAqD,IAAI,EAAA;QAChF,IAAI,UAAU,GAA6C,QAAQ,CAAC;AACpE,QAAA,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;AACnC,YAAA,UAAU,GAAG,IAAI,CAAC,CAAC;AACvB,SAAC,CAAC,CAAC;QAEH,OAAO,OAAO,UAAU,GAAG,IAAI,CAAC,CAAC;KACpC;AAEO,IAAA,SAAS,CAAC,GAAW,EAAA;QACzB,IAAI,IAAI,GAAG,IAAI,CAAC,gBAAgB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;SACxC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;KAC3B;AACJ;;;;"}
@@ -7,9 +7,10 @@ import 'react';
7
7
  import 'motion/react';
8
8
  import '@hh.ru/magritte-ui-breakpoint';
9
9
  import './utils.js';
10
- import '../media-viewer-BNuKXbLq.js';
10
+ import '@hh.ru/magritte-design-tokens/types';
11
+ import './animations.js';
12
+ import '../media-viewer-EEyLOGS2.js';
11
13
  import './ImagesLoader.js';
12
- import './ObservableValue.js';
13
14
 
14
15
  const PreviewItem = ({ index, ...props }) => {
15
16
  const { visibleRange } = usePreviewContext();
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewItem.js","sources":["../../src/internal/PreviewItem.tsx"],"sourcesContent":["import { type FC } from 'react';\nimport { type MotionValue } from 'motion/react';\n\nimport { PreviewItemBody } from '@hh.ru/magritte-ui-media-viewer/internal/PreviewItemBody';\nimport { usePreviewContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { useIsVisible } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useVirtualization';\n\nexport const PreviewItem: FC<{ index: number; src: string; dragFactor: MotionValue<number> }> = ({\n index,\n ...props\n}) => {\n const { visibleRange } = usePreviewContext();\n\n const isVisible = useIsVisible(index, visibleRange);\n\n if (!isVisible) {\n return null;\n }\n\n return <PreviewItemBody index={index} {...props} />;\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;AAOO,MAAM,WAAW,GAAwE,CAAC,EAC7F,KAAK,EACL,GAAG,KAAK,EACX,KAAI;AACD,IAAA,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE7C,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAEpD,IAAI,CAAC,SAAS,EAAE;AACZ,QAAA,OAAO,IAAI,CAAC;KACf;IAED,OAAOA,GAAA,CAAC,eAAe,EAAC,EAAA,KAAK,EAAE,KAAK,EAAA,GAAM,KAAK,EAAA,CAAI,CAAC;AACxD;;;;"}
1
+ {"version":3,"file":"PreviewItem.js","sources":["../../src/internal/PreviewItem.tsx"],"sourcesContent":["import { type FC } from 'react';\nimport { type MotionValue } from 'motion/react';\n\nimport { PreviewItemBody } from '@hh.ru/magritte-ui-media-viewer/internal/PreviewItemBody';\nimport { usePreviewContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { useIsVisible } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useVirtualization';\n\nexport const PreviewItem: FC<{ index: number; src: string; dragFactor: MotionValue<number> }> = ({\n index,\n ...props\n}) => {\n const { visibleRange } = usePreviewContext();\n\n const isVisible = useIsVisible(index, visibleRange);\n\n if (!isVisible) {\n return null;\n }\n\n return <PreviewItemBody index={index} {...props} />;\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;AAOO,MAAM,WAAW,GAAwE,CAAC,EAC7F,KAAK,EACL,GAAG,KAAK,EACX,KAAI;AACD,IAAA,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE7C,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAEpD,IAAI,CAAC,SAAS,EAAE;AACZ,QAAA,OAAO,IAAI,CAAC;KACf;IAED,OAAOA,GAAA,CAAC,eAAe,EAAC,EAAA,KAAK,EAAE,KAAK,EAAA,GAAM,KAAK,EAAA,CAAI,CAAC;AACxD;;;;"}
@@ -5,9 +5,10 @@ import { useMotionValue, useTransform, useMotionValueEvent, animate, motion } fr
5
5
  import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
6
6
  import { useMediaViewerContext, usePreviewContext } from './context.js';
7
7
  import { useDetectDiscreteChange, clamp } from './utils.js';
8
- import { s as styles } from '../media-viewer-BNuKXbLq.js';
8
+ import { s as styles } from '../media-viewer-EEyLOGS2.js';
9
9
  import './ImagesLoader.js';
10
- import './ObservableValue.js';
10
+ import '@hh.ru/magritte-design-tokens/types';
11
+ import './animations.js';
11
12
 
12
13
  const calcSizeFactor = (activeItemIndex, itemIndex, dragFactor) => {
13
14
  const diff = Math.abs(activeItemIndex - itemIndex);
@@ -24,7 +25,7 @@ const PreviewItemBody = ({ index, src, dragFactor }) => {
24
25
  const isDiscrete = useDetectDiscreteChange(activeItemIndex);
25
26
  const sizeFactorTarget = useRef(-1);
26
27
  const { isMobile } = useBreakpoint();
27
- const width = useTransform(sizeFactor, [0, 1], isMobile ? [24, 48] : [32, 64]);
28
+ const width = useTransform(sizeFactor, [0, 1], isMobile ? [24, 48] : [40, 80]);
28
29
  useMotionValueEvent(dragFactor, 'change', (value) => {
29
30
  sizeFactor.set(calcSizeFactor(activeItemIndex.get(), index, value));
30
31
  });
@@ -41,19 +42,30 @@ const PreviewItemBody = ({ index, src, dragFactor }) => {
41
42
  sizeFactor.set(newSizeFactor);
42
43
  }
43
44
  });
44
- useEffect(() => globalContext.imagesLoader.waitingForUrl(src, ({ width, height }) => {
45
- if (!width || !height) {
46
- return;
45
+ useEffect(() => {
46
+ const applySize = (width, height) => {
47
+ const minSide = Math.min(width, height);
48
+ const scale = MINIATURE_MIN_SIZE / minSide;
49
+ const scaledWidth = width * scale;
50
+ const scaledHeight = height * scale;
51
+ imageWidth.set(scaledWidth);
52
+ imageHeight.set(scaledHeight);
53
+ display.set('block');
54
+ };
55
+ const meta = globalContext.imagesLoader.getUrlMeta(src);
56
+ if (meta && meta.status === 'loaded' && meta.width && meta.height) {
57
+ applySize(meta.width, meta.height);
58
+ return void 0;
47
59
  }
48
- const minSide = Math.min(width, height);
49
- const scale = MINIATURE_MIN_SIZE / minSide;
50
- const scaledWidth = width * scale;
51
- const scaledHeight = height * scale;
52
- imageWidth.set(scaledWidth);
53
- imageHeight.set(scaledHeight);
54
- display.set('block');
55
- }), [src, globalContext, display, imageWidth, imageHeight]);
56
- return (jsx(motion.button, { onClick: () => {
60
+ display.set('none');
61
+ return globalContext.imagesLoader.waitingForUrl(src, ({ width, height }) => {
62
+ if (!width || !height) {
63
+ return;
64
+ }
65
+ applySize(width, height);
66
+ });
67
+ }, [src, globalContext, display, imageWidth, imageHeight]);
68
+ return (jsx(motion.div, { onClick: () => {
57
69
  globalContext.currentSlideIndex.set(index);
58
70
  }, className: styles.previewItem, style: {
59
71
  width,
@@ -62,7 +74,7 @@ const PreviewItemBody = ({ index, src, dragFactor }) => {
62
74
  height: imageHeight,
63
75
  display,
64
76
  flex: '0 0 auto',
65
- }, children: jsx("img", { src: src, alt: "", draggable: false }) }) }));
77
+ }, children: jsx("img", { src: src, draggable: false }) }) }));
66
78
  };
67
79
 
68
80
  export { PreviewItemBody };
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewItemBody.js","sources":["../../src/internal/PreviewItemBody.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, useEffect, useRef } from 'react';\nimport { useMotionValue, animate, useTransform, type MotionValue, useMotionValueEvent, motion } from 'motion/react';\n\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { useMediaViewerContext, usePreviewContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { clamp, useDetectDiscreteChange } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nimport styles from '../public/media-viewer.less';\n\nconst calcSizeFactor = (activeItemIndex: number, itemIndex: number, dragFactor: number): number => {\n const diff = Math.abs(activeItemIndex - itemIndex);\n return Math.max(0, clamp(1 - diff, 0, 1) - dragFactor);\n};\n\nconst MINIATURE_MIN_SIZE = 48;\n\nexport const PreviewItemBody: FC<\n PropsWithChildren<{ index: number; src: string; dragFactor: MotionValue<number> }>\n> = ({ index, src, dragFactor }) => {\n const globalContext = useMediaViewerContext();\n const { activeItemIndex } = usePreviewContext();\n const sizeFactor = useMotionValue(calcSizeFactor(activeItemIndex.get(), index, dragFactor.get()));\n const display = useMotionValue<'block' | 'none'>('none');\n const imageWidth = useMotionValue(0);\n const imageHeight = useMotionValue(0);\n const isDiscrete = useDetectDiscreteChange(activeItemIndex);\n const sizeFactorTarget = useRef<number>(-1);\n const { isMobile } = useBreakpoint();\n const width = useTransform(sizeFactor, [0, 1], isMobile ? [24, 48] : [32, 64]);\n useMotionValueEvent(dragFactor, 'change', (value) => {\n sizeFactor.set(calcSizeFactor(activeItemIndex.get(), index, value));\n });\n\n useMotionValueEvent(activeItemIndex, 'change', (newIndex) => {\n const newSizeFactor = calcSizeFactor(newIndex, index, dragFactor.get());\n if (newSizeFactor === sizeFactorTarget.current || newSizeFactor === sizeFactor.get()) {\n return;\n }\n sizeFactorTarget.current = newSizeFactor;\n if (isDiscrete()) {\n animate(sizeFactor, newSizeFactor, { duration: 0.2 });\n } else {\n sizeFactor.set(newSizeFactor);\n }\n });\n\n useEffect(\n () =>\n globalContext.imagesLoader.waitingForUrl(src, ({ width, height }) => {\n if (!width || !height) {\n return;\n }\n const minSide = Math.min(width, height);\n const scale = MINIATURE_MIN_SIZE / minSide;\n const scaledWidth = width * scale;\n const scaledHeight = height * scale;\n imageWidth.set(scaledWidth);\n imageHeight.set(scaledHeight);\n display.set('block');\n }),\n [src, globalContext, display, imageWidth, imageHeight]\n );\n\n return (\n <motion.button\n onClick={() => {\n globalContext.currentSlideIndex.set(index);\n }}\n className={styles.previewItem}\n style={{\n width,\n }}\n draggable={false}\n >\n <motion.div\n draggable={false}\n className={styles.previewItemContainer}\n style={{\n width: imageWidth,\n height: imageHeight,\n display,\n flex: '0 0 auto',\n }}\n >\n <img src={src} alt=\"\" draggable={false} />\n </motion.div>\n </motion.button>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AASA,MAAM,cAAc,GAAG,CAAC,eAAuB,EAAE,SAAiB,EAAE,UAAkB,KAAY;IAC9F,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;AACnD,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;AAC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aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC9C,EACD,SAAS,EAAE,MAAM,CAAC,WAAW,EAC7B,KAAK,EAAE;YACH,KAAK;SACR,EACD,SAAS,EAAE,KAAK,EAAA,QAAA,EAEhBA,IAAC,MAAM,CAAC,GAAG,EACP,EAAA,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,MAAM,CAAC,oBAAoB,EACtC,KAAK,EAAE;AACH,gBAAA,KAAK,EAAE,UAAU;AACjB,gBAAA,MAAM,EAAE,WAAW;gBACnB,OAAO;AACP,gBAAA,IAAI,EAAE,UAAU;AACnB,aAAA,EAAA,QAAA,EAEDA,aAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAC,EAAE,EAAC,SAAS,EAAE,KAAK,EAAA,CAAI,EACjC,CAAA,EAAA,CACD,EAClB;AACN;;;;"}
1
+ {"version":3,"file":"PreviewItemBody.js","sources":["../../src/internal/PreviewItemBody.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, useEffect, useRef } from 'react';\nimport { useMotionValue, animate, useTransform, type MotionValue, useMotionValueEvent, motion } from 'motion/react';\n\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { useMediaViewerContext, usePreviewContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { clamp, useDetectDiscreteChange } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nimport styles from '../public/media-viewer.less';\n\nconst calcSizeFactor = (activeItemIndex: number, itemIndex: number, dragFactor: number): number => {\n const diff = Math.abs(activeItemIndex - itemIndex);\n return Math.max(0, clamp(1 - diff, 0, 1) - dragFactor);\n};\n\nconst MINIATURE_MIN_SIZE = 48;\n\nexport const PreviewItemBody: FC<\n PropsWithChildren<{ index: number; src: string; dragFactor: MotionValue<number> }>\n> = ({ index, src, dragFactor }) => {\n const globalContext = useMediaViewerContext();\n const { activeItemIndex } = usePreviewContext();\n const sizeFactor = useMotionValue(calcSizeFactor(activeItemIndex.get(), index, dragFactor.get()));\n const display = useMotionValue<'block' | 'none'>('none');\n const imageWidth = useMotionValue(0);\n const imageHeight = useMotionValue(0);\n const isDiscrete = useDetectDiscreteChange(activeItemIndex);\n const sizeFactorTarget = useRef<number>(-1);\n const { isMobile } = useBreakpoint();\n const width = useTransform(sizeFactor, [0, 1], isMobile ? [24, 48] : [40, 80]);\n useMotionValueEvent(dragFactor, 'change', (value) => {\n sizeFactor.set(calcSizeFactor(activeItemIndex.get(), index, value));\n });\n\n useMotionValueEvent(activeItemIndex, 'change', (newIndex) => {\n const newSizeFactor = calcSizeFactor(newIndex, index, dragFactor.get());\n if (newSizeFactor === sizeFactorTarget.current || newSizeFactor === sizeFactor.get()) {\n return;\n }\n sizeFactorTarget.current = newSizeFactor;\n if (isDiscrete()) {\n animate(sizeFactor, newSizeFactor, { duration: 0.2 });\n } else {\n sizeFactor.set(newSizeFactor);\n }\n });\n\n useEffect(() => {\n const applySize = (width: number, height: number) => {\n const minSide = Math.min(width, height);\n const scale = MINIATURE_MIN_SIZE / minSide;\n const scaledWidth = width * scale;\n const scaledHeight = height * scale;\n imageWidth.set(scaledWidth);\n imageHeight.set(scaledHeight);\n display.set('block');\n };\n const meta = globalContext.imagesLoader.getUrlMeta(src);\n if (meta && meta.status === 'loaded' && meta.width && meta.height) {\n applySize(meta.width, meta.height);\n return void 0;\n }\n display.set('none');\n return globalContext.imagesLoader.waitingForUrl(src, ({ width, height }) => {\n if (!width || !height) {\n return;\n }\n applySize(width, height);\n });\n }, [src, globalContext, display, imageWidth, imageHeight]);\n\n return (\n <motion.div\n onClick={() => {\n globalContext.currentSlideIndex.set(index);\n }}\n className={styles.previewItem}\n style={{\n width,\n }}\n draggable={false}\n >\n <motion.div\n draggable={false}\n className={styles.previewItemContainer}\n style={{\n width: imageWidth,\n height: imageHeight,\n display,\n flex: '0 0 auto',\n }}\n >\n <img src={src} draggable={false} />\n </motion.div>\n </motion.div>\n );\n};\n"],"names":["_jsx"],"mappings":";;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QAAA,EAEDA,GAAK,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAI,CAAA,EAAA,CAC1B,EACJ,CAAA,EACf;AACN;;;;"}
@@ -2,13 +2,15 @@ import './../index.css';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useRef, useEffect } from 'react';
4
4
  import { animate } from 'motion/react';
5
+ import { useTranslation } from '@hh.ru/magritte-common-use-translation';
6
+ import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
5
7
  import { MagnifierMinusOutlinedSize24, MagnifierPlusOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
8
+ import { EASE_BASE } from './animations.js';
6
9
  import { useMediaViewerContext } from './context.js';
7
- import { findNextValue, getDimensionsAfterRotation, clampOffset } from './utils.js';
10
+ import { useInitOnce, findNextValue, getDimensionsAfterRotation, clampOffset } from './utils.js';
8
11
  import { Text } from '@hh.ru/magritte-ui-typography';
9
- import { s as styles } from '../media-viewer-BNuKXbLq.js';
12
+ import { s as styles } from '../media-viewer-EEyLOGS2.js';
10
13
  import './ImagesLoader.js';
11
- import './ObservableValue.js';
12
14
 
13
15
  const getCurrentControllerLimits = (globalContext) => {
14
16
  const controller = globalContext.currentSlideController.get();
@@ -16,7 +18,7 @@ const getCurrentControllerLimits = (globalContext) => {
16
18
  return null;
17
19
  }
18
20
  const rotation = controller.rotation.get();
19
- const zoomStops = controller.zoomStops[rotation % 2];
21
+ const zoomStops = controller.zoomStops.get()[rotation % 2];
20
22
  return {
21
23
  min: zoomStops?.[0] ?? Number.NEGATIVE_INFINITY,
22
24
  max: zoomStops?.[zoomStops.length - 1] ?? Number.POSITIVE_INFINITY,
@@ -24,9 +26,17 @@ const getCurrentControllerLimits = (globalContext) => {
24
26
  };
25
27
  const PreviewZoomControl = () => {
26
28
  const globalContext = useMediaViewerContext();
27
- const [zoom, setZoom] = useState(() => globalContext.currentSlideController.get()?.scale.get() || null);
29
+ const [zoom, setZoom] = useState(() => {
30
+ const zoom = globalContext.currentSlideController.get()?.scale.get() || null;
31
+ return zoom ? Math.round(zoom * 100) : null;
32
+ });
33
+ const updateZoom = useInitOnce(() => (newZoom) => {
34
+ setZoom(newZoom ? Math.round(newZoom * 100) : null);
35
+ });
28
36
  const [zoomLimits, setZoomLimits] = useState(() => getCurrentControllerLimits(globalContext));
29
37
  const prevControllerUnsubRef = useRef([]);
38
+ const zoomInTrl = useTranslation('MediaViewer', 'zoomIn');
39
+ const zoomOutTrl = useTranslation('MediaViewer', 'zoomOut');
30
40
  const applyNextZoom = (direction) => {
31
41
  const controller = globalContext.currentSlideController.get();
32
42
  const contentSize = controller?.contentSize.get();
@@ -35,16 +45,22 @@ const PreviewZoomControl = () => {
35
45
  if (!controller || !contentSize || !viewPortDimensions) {
36
46
  return;
37
47
  }
38
- const nextZoom = findNextValue(controller.zoomStops[rotation % 2], controller.scale.get() ?? 1, direction === 'in');
48
+ const nextZoom = findNextValue(controller.zoomStops.get()[rotation % 2], controller.scale.get() ?? 1, direction === 'in');
39
49
  controller.scale.stop();
40
50
  controller.offsetX.stop();
41
51
  controller.offsetY.stop();
42
52
  const sizeAfterRotation = getDimensionsAfterRotation(contentSize, rotation);
43
53
  const clampedOffsetX = clampOffset(controller.offsetX.get(), sizeAfterRotation.width * nextZoom, viewPortDimensions.width);
44
54
  const clampedOffsetY = clampOffset(controller.offsetY.get(), sizeAfterRotation.height * nextZoom, viewPortDimensions.height);
45
- animate(controller.scale, nextZoom, { duration: 0.2 });
46
- animate(controller.offsetX, clampedOffsetX, { duration: 0.2 });
47
- animate(controller.offsetY, clampedOffsetY, { duration: 0.2 });
55
+ animate(controller.scale, nextZoom, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });
56
+ animate(controller.offsetX, clampedOffsetX, {
57
+ duration: tokenSemanticAnimationTimeMDuration / 1000,
58
+ ease: EASE_BASE,
59
+ });
60
+ animate(controller.offsetY, clampedOffsetY, {
61
+ duration: tokenSemanticAnimationTimeMDuration / 1000,
62
+ ease: EASE_BASE,
63
+ });
48
64
  };
49
65
  useEffect(() => {
50
66
  const subs = [
@@ -53,22 +69,32 @@ const PreviewZoomControl = () => {
53
69
  return;
54
70
  }
55
71
  const scale = controller.scale.get() || null;
56
- setZoom(scale);
72
+ updateZoom(scale);
57
73
  // слушаем всегда только один контроллер, от предыдущего надо отписаться
58
74
  prevControllerUnsubRef.current.forEach((unsub) => unsub());
59
- prevControllerUnsubRef.current = [controller.scale.on('change', setZoom)];
75
+ prevControllerUnsubRef.current = [
76
+ controller.scale.on('change', updateZoom),
77
+ controller.zoomStops.on('change', () => setZoomLimits(getCurrentControllerLimits(globalContext))),
78
+ ];
60
79
  setZoomLimits(getCurrentControllerLimits(globalContext));
61
80
  }),
62
- globalContext.currentSlideController.get()?.scale.on('change', setZoom),
63
81
  () => prevControllerUnsubRef.current.forEach((unsub) => unsub()),
64
82
  ];
83
+ const currentController = globalContext.currentSlideController.get();
84
+ if (currentController) {
85
+ prevControllerUnsubRef.current = [
86
+ currentController.scale.on('change', updateZoom),
87
+ currentController.zoomStops.on('change', () => setZoomLimits(getCurrentControllerLimits(globalContext))),
88
+ ];
89
+ setZoomLimits(getCurrentControllerLimits(globalContext));
90
+ }
65
91
  return () => subs.forEach((unsub) => unsub?.());
66
- }, [globalContext]);
67
- return (jsxs("div", { className: styles.previewZoomControl, children: [jsx(MagnifierMinusOutlinedSize24, { initialColor: "contrast", padding: 8, disabled: zoom !== null && (zoomLimits === null || zoom <= zoomLimits?.min), onClick: () => {
92
+ }, [globalContext, updateZoom]);
93
+ return (jsxs("div", { className: styles.previewZoomControl, children: [jsx(MagnifierMinusOutlinedSize24, { initialColor: "contrast", padding: 8, disabled: zoom !== null && (zoomLimits === null || zoom <= Math.round(zoomLimits?.min * 100)), onClick: () => {
68
94
  applyNextZoom('out');
69
- } }), jsx(Text, { style: "contrast", typography: "label-2-regular", children: zoom ? `${Math.round(zoom * 100)}%` : '100%' }), jsx(MagnifierPlusOutlinedSize24, { initialColor: "contrast", padding: 8, disabled: zoom !== null && (zoomLimits === null || zoom >= zoomLimits?.max), onClick: () => {
95
+ }, borderRadius: "halfHeight", "aria-label": zoomOutTrl }), jsx(Text, { style: "contrast", typography: "label-2-regular", children: `${zoom ?? 100}%` }), jsx(MagnifierPlusOutlinedSize24, { initialColor: "contrast", padding: 8, disabled: zoom !== null && (zoomLimits === null || zoom >= Math.round(zoomLimits?.max * 100)), onClick: () => {
70
96
  applyNextZoom('in');
71
- } })] }));
97
+ }, borderRadius: "halfHeight", "aria-label": zoomInTrl })] }));
72
98
  };
73
99
 
74
100
  export { PreviewZoomControl };
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewZoomControl.js","sources":["../../src/internal/PreviewZoomControl.tsx"],"sourcesContent":["import { type FC, useState, useRef, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport { MagnifierMinusOutlinedSize24, MagnifierPlusOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { type MediaViewerContextValue, useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { findNextValue, getDimensionsAfterRotation, clampOffset } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\nconst getCurrentControllerLimits = (globalContext: MediaViewerContextValue) => {\n const controller = globalContext.currentSlideController.get();\n if (!controller) {\n return null;\n }\n const rotation = controller.rotation.get();\n const zoomStops = controller.zoomStops[rotation % 2];\n return {\n min: zoomStops?.[0] ?? Number.NEGATIVE_INFINITY,\n max: zoomStops?.[zoomStops.length - 1] ?? Number.POSITIVE_INFINITY,\n };\n};\n\nexport const PreviewZoomControl: FC = () => {\n const globalContext = useMediaViewerContext();\n const [zoom, setZoom] = useState<number | null>(\n () => globalContext.currentSlideController.get()?.scale.get() || null\n );\n const [zoomLimits, setZoomLimits] = useState<{ min: number; max: number } | null>(() =>\n getCurrentControllerLimits(globalContext)\n );\n const prevControllerUnsubRef = useRef<VoidFunction[]>([]);\n\n const applyNextZoom = (direction: 'in' | 'out') => {\n const controller = globalContext.currentSlideController.get();\n const contentSize = controller?.contentSize.get();\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n const rotation = controller?.rotation.get() ?? 0;\n if (!controller || !contentSize || !viewPortDimensions) {\n return;\n }\n const nextZoom = findNextValue(\n controller.zoomStops[rotation % 2],\n controller.scale.get() ?? 1,\n direction === 'in'\n );\n\n controller.scale.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n\n const sizeAfterRotation = getDimensionsAfterRotation(contentSize, rotation);\n const clampedOffsetX = clampOffset(\n controller.offsetX.get(),\n sizeAfterRotation.width * nextZoom,\n viewPortDimensions.width\n );\n const clampedOffsetY = clampOffset(\n controller.offsetY.get(),\n sizeAfterRotation.height * nextZoom,\n viewPortDimensions.height\n );\n\n animate(controller.scale, nextZoom, { duration: 0.2 });\n animate(controller.offsetX, clampedOffsetX, { duration: 0.2 });\n animate(controller.offsetY, clampedOffsetY, { duration: 0.2 });\n };\n\n useEffect(() => {\n const subs = [\n globalContext.currentSlideController.on('change', (controller) => {\n if (!controller) {\n return;\n }\n const scale = controller.scale.get() || null;\n setZoom(scale);\n // слушаем всегда только один контроллер, от предыдущего надо отписаться\n prevControllerUnsubRef.current.forEach((unsub) => unsub());\n prevControllerUnsubRef.current = [controller.scale.on('change', setZoom)];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }),\n\n globalContext.currentSlideController.get()?.scale.on('change', setZoom),\n () => prevControllerUnsubRef.current.forEach((unsub) => unsub()),\n ];\n\n return () => subs.forEach((unsub) => unsub?.());\n }, [globalContext]);\n\n return (\n <div className={styles.previewZoomControl}>\n <MagnifierMinusOutlinedSize24\n initialColor=\"contrast\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom <= zoomLimits?.min)}\n onClick={() => {\n applyNextZoom('out');\n }}\n />\n <Text style=\"contrast\" typography=\"label-2-regular\">\n {zoom ? `${Math.round(zoom * 100)}%` : '100%'}\n </Text>\n <MagnifierPlusOutlinedSize24\n initialColor=\"contrast\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom >= zoomLimits?.max)}\n onClick={() => {\n applyNextZoom('in');\n }}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAUA,MAAM,0BAA0B,GAAG,CAAC,aAAsC,KAAI;IAC1E,MAAM,UAAU,GAAG,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC;IAC9D,IAAI,CAAC,UAAU,EAAE;AACb,QAAA,OAAO,IAAI,CAAC;KACf;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC3C,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO;QACH,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,iBAAiB;AAC/C,QAAA,GAAG,EAAE,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,iBAAiB;KACrE,CAAC;AACN,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAO,MAAK;AACvC,IAAA,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;IAC9C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAC5B,MAAM,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,IAAI,CACxE,CAAC;AACF,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAsC,MAC9E,0BAA0B,CAAC,aAAa,CAAC,CAC5C,CAAC;AACF,IAAA,MAAM,sBAAsB,GAAG,MAAM,CAAiB,EAAE,CAAC,CAAC;AAE1D,IAAA,MAAM,aAAa,GAAG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BAAkB,EACrC,QAAA,EAAA,CAAAC,GAAA,CAAC,4BAA4B,EAAA,EACzB,YAAY,EAAC,UAAU,EACvB,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,IAAI,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI,IAAI,IAAI,IAAI,UAAU,EAAE,GAAG,CAAC,EAC3E,OAAO,EAAE,MAAK;oBACV,aAAa,CAAC,KAAK,CAAC,CAAC;AACzB,iBAAC,EACH,CAAA,EACFA,GAAC,CAAA,IAAI,EAAC,EAAA,KAAK,EAAC,UAAU,EAAC,UAAU,EAAC,iBAAiB,YAC9C,IAAI,GAAG,CAAG,EAAA,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAA,CAAA,CAAG,GAAG,MAAM,EAAA,CAC1C,EACPA,GAAA,CAAC,2BAA2B,EAAA,EACxB,YAAY,EAAC,UAAU,EACvB,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,IAAI,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI,IAAI,IAAI,IAAI,UAAU,EAAE,GAAG,CAAC,EAC3E,OAAO,EAAE,MAAK;oBACV,aAAa,CAAC,IAAI,CAAC,CAAC;iBACvB,EAAA,CACH,CACA,EAAA,CAAA,EACR;AACN;;;;"}
1
+ {"version":3,"file":"PreviewZoomControl.js","sources":["../../src/internal/PreviewZoomControl.tsx"],"sourcesContent":["import { type FC, useState, useRef, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { MagnifierMinusOutlinedSize24, MagnifierPlusOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue, useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport {\n findNextValue,\n getDimensionsAfterRotation,\n clampOffset,\n useInitOnce,\n} from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\nconst getCurrentControllerLimits = (globalContext: MediaViewerContextValue) => {\n const controller = globalContext.currentSlideController.get();\n if (!controller) {\n return null;\n }\n const rotation = controller.rotation.get();\n const zoomStops = controller.zoomStops.get()[rotation % 2];\n return {\n min: zoomStops?.[0] ?? Number.NEGATIVE_INFINITY,\n max: zoomStops?.[zoomStops.length - 1] ?? Number.POSITIVE_INFINITY,\n };\n};\n\nexport const PreviewZoomControl: FC = () => {\n const globalContext = useMediaViewerContext();\n const [zoom, setZoom] = useState<number | null>(() => {\n const zoom = globalContext.currentSlideController.get()?.scale.get() || null;\n return zoom ? Math.round(zoom * 100) : null;\n });\n const updateZoom = useInitOnce(() => (newZoom: number | null) => {\n setZoom(newZoom ? Math.round(newZoom * 100) : null);\n });\n\n const [zoomLimits, setZoomLimits] = useState<{ min: number; max: number } | null>(() =>\n getCurrentControllerLimits(globalContext)\n );\n const prevControllerUnsubRef = useRef<VoidFunction[]>([]);\n const zoomInTrl = useTranslation('MediaViewer', 'zoomIn');\n const zoomOutTrl = useTranslation('MediaViewer', 'zoomOut');\n\n const applyNextZoom = (direction: 'in' | 'out') => {\n const controller = globalContext.currentSlideController.get();\n const contentSize = controller?.contentSize.get();\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n const rotation = controller?.rotation.get() ?? 0;\n if (!controller || !contentSize || !viewPortDimensions) {\n return;\n }\n const nextZoom = findNextValue(\n controller.zoomStops.get()[rotation % 2],\n controller.scale.get() ?? 1,\n direction === 'in'\n );\n\n controller.scale.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n\n const sizeAfterRotation = getDimensionsAfterRotation(contentSize, rotation);\n const clampedOffsetX = clampOffset(\n controller.offsetX.get(),\n sizeAfterRotation.width * nextZoom,\n viewPortDimensions.width\n );\n const clampedOffsetY = clampOffset(\n controller.offsetY.get(),\n sizeAfterRotation.height * nextZoom,\n viewPortDimensions.height\n );\n\n animate(controller.scale, nextZoom, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });\n animate(controller.offsetX, clampedOffsetX, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetY, clampedOffsetY, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n };\n\n useEffect(() => {\n const subs = [\n globalContext.currentSlideController.on('change', (controller) => {\n if (!controller) {\n return;\n }\n const scale = controller.scale.get() || null;\n updateZoom(scale);\n // слушаем всегда только один контроллер, от предыдущего надо отписаться\n prevControllerUnsubRef.current.forEach((unsub) => unsub());\n prevControllerUnsubRef.current = [\n controller.scale.on('change', updateZoom),\n controller.zoomStops.on('change', () => setZoomLimits(getCurrentControllerLimits(globalContext))),\n ];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }),\n () => prevControllerUnsubRef.current.forEach((unsub) => unsub()),\n ];\n\n const currentController = globalContext.currentSlideController.get();\n if (currentController) {\n prevControllerUnsubRef.current = [\n currentController.scale.on('change', updateZoom),\n currentController.zoomStops.on('change', () =>\n setZoomLimits(getCurrentControllerLimits(globalContext))\n ),\n ];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }\n return () => subs.forEach((unsub) => unsub?.());\n }, [globalContext, updateZoom]);\n\n return (\n <div className={styles.previewZoomControl}>\n <MagnifierMinusOutlinedSize24\n initialColor=\"contrast\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom <= Math.round(zoomLimits?.min * 100))}\n onClick={() => {\n applyNextZoom('out');\n }}\n borderRadius=\"halfHeight\"\n aria-label={zoomOutTrl}\n />\n <Text style=\"contrast\" typography=\"label-2-regular\">\n {`${zoom ?? 100}%`}\n </Text>\n <MagnifierPlusOutlinedSize24\n initialColor=\"contrast\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom >= Math.round(zoomLimits?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AAC,CAAC;AACzB,iBAAC,EACD,YAAY,EAAC,YAAY,EACb,YAAA,EAAA,UAAU,EACxB,CAAA,EACFA,GAAC,CAAA,IAAI,EAAC,EAAA,KAAK,EAAC,UAAU,EAAC,UAAU,EAAC,iBAAiB,EAAA,QAAA,EAC9C,CAAG,EAAA,IAAI,IAAI,GAAG,CAAG,CAAA,CAAA,EAAA,CACf,EACPA,GAAA,CAAC,2BAA2B,EAAA,EACxB,YAAY,EAAC,UAAU,EACvB,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,IAAI,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,EAC7F,OAAO,EAAE,MAAK;oBACV,aAAa,CAAC,IAAI,CAAC,CAAC;iBACvB,EACD,YAAY,EAAC,YAAY,gBACb,SAAS,EAAA,CACvB,CACA,EAAA,CAAA,EACR;AACN;;;;"}
@@ -0,0 +1 @@
1
+ export declare const EASE_BASE: readonly [0.4, 0.24, 0, 1];
@@ -0,0 +1,12 @@
1
+ import './../index.css';
2
+ import { tokenSemanticAnimationEaseBaseX1, tokenSemanticAnimationEaseBaseY1, tokenSemanticAnimationEaseBaseX2, tokenSemanticAnimationEaseBaseY2 } from '@hh.ru/magritte-design-tokens/types';
3
+
4
+ const EASE_BASE = [
5
+ tokenSemanticAnimationEaseBaseX1,
6
+ tokenSemanticAnimationEaseBaseY1,
7
+ tokenSemanticAnimationEaseBaseX2,
8
+ tokenSemanticAnimationEaseBaseY2,
9
+ ];
10
+
11
+ export { EASE_BASE };
12
+ //# sourceMappingURL=animations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animations.js","sources":["../../src/internal/animations.ts"],"sourcesContent":["import {\n tokenSemanticAnimationEaseBaseX1,\n tokenSemanticAnimationEaseBaseX2,\n tokenSemanticAnimationEaseBaseY1,\n tokenSemanticAnimationEaseBaseY2,\n} from '@hh.ru/magritte-design-tokens/types';\n\nexport const EASE_BASE = [\n tokenSemanticAnimationEaseBaseX1,\n tokenSemanticAnimationEaseBaseY1,\n tokenSemanticAnimationEaseBaseX2,\n tokenSemanticAnimationEaseBaseY2,\n] as const;\n"],"names":[],"mappings":";;AAOa,MAAA,SAAS,GAAG;IACrB,gCAAgC;IAChC,gCAAgC;IAChC,gCAAgC;IAChC,gCAAgC;;;;;"}