@alfalab/core-components-gallery 6.0.1-snapshot-c2c8d5a → 6.0.2

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 (95) hide show
  1. package/components/bottom-button/index.css +5 -5
  2. package/components/bottom-button/index.module.css.js +1 -1
  3. package/components/buttons/index.css +5 -5
  4. package/components/buttons/index.module.css.js +1 -1
  5. package/components/header/index.css +1 -1
  6. package/components/header/index.module.css.js +1 -1
  7. package/components/header-info-block/index.css +4 -4
  8. package/components/header-info-block/index.module.css.js +1 -1
  9. package/components/header-mobile/Component.js +59 -26
  10. package/components/header-mobile/Component.js.map +1 -1
  11. package/components/header-mobile/index.css +6 -6
  12. package/components/header-mobile/index.module.css.js +1 -1
  13. package/components/image-preview/index.css +17 -17
  14. package/components/image-preview/index.module.css.js +1 -1
  15. package/components/image-viewer/component.js +2 -4
  16. package/components/image-viewer/component.js.map +1 -1
  17. package/components/image-viewer/index.css +25 -25
  18. package/components/image-viewer/index.module.css.js +1 -1
  19. package/components/image-viewer/video/index.css +7 -7
  20. package/components/image-viewer/video/index.module.css.js +1 -1
  21. package/components/info-bar/index.css +3 -3
  22. package/components/info-bar/index.module.css.js +1 -1
  23. package/components/navigation-bar/index.css +8 -8
  24. package/components/navigation-bar/index.module.css.js +1 -1
  25. package/components/subtitles/index.css +3 -3
  26. package/components/subtitles/index.module.css.js +1 -1
  27. package/cssm/components/header-mobile/Component.js +59 -26
  28. package/cssm/components/header-mobile/Component.js.map +1 -1
  29. package/cssm/components/image-viewer/component.js +2 -4
  30. package/cssm/components/image-viewer/component.js.map +1 -1
  31. package/esm/components/bottom-button/index.css +5 -5
  32. package/esm/components/bottom-button/index.module.css.js +1 -1
  33. package/esm/components/buttons/index.css +5 -5
  34. package/esm/components/buttons/index.module.css.js +1 -1
  35. package/esm/components/header/index.css +1 -1
  36. package/esm/components/header/index.module.css.js +1 -1
  37. package/esm/components/header-info-block/index.css +4 -4
  38. package/esm/components/header-info-block/index.module.css.js +1 -1
  39. package/esm/components/header-mobile/Component.js +59 -26
  40. package/esm/components/header-mobile/Component.js.map +1 -1
  41. package/esm/components/header-mobile/index.css +6 -6
  42. package/esm/components/header-mobile/index.module.css.js +1 -1
  43. package/esm/components/image-preview/index.css +17 -17
  44. package/esm/components/image-preview/index.module.css.js +1 -1
  45. package/esm/components/image-viewer/component.js +2 -4
  46. package/esm/components/image-viewer/component.js.map +1 -1
  47. package/esm/components/image-viewer/index.css +25 -25
  48. package/esm/components/image-viewer/index.module.css.js +1 -1
  49. package/esm/components/image-viewer/video/index.css +7 -7
  50. package/esm/components/image-viewer/video/index.module.css.js +1 -1
  51. package/esm/components/info-bar/index.css +3 -3
  52. package/esm/components/info-bar/index.module.css.js +1 -1
  53. package/esm/components/navigation-bar/index.css +8 -8
  54. package/esm/components/navigation-bar/index.module.css.js +1 -1
  55. package/esm/components/subtitles/index.css +3 -3
  56. package/esm/components/subtitles/index.module.css.js +1 -1
  57. package/esm/index.css +9 -9
  58. package/esm/index.module.css.js +1 -1
  59. package/index.css +9 -9
  60. package/index.module.css.js +1 -1
  61. package/modern/components/bottom-button/index.css +5 -5
  62. package/modern/components/bottom-button/index.module.css.js +1 -1
  63. package/modern/components/buttons/index.css +5 -5
  64. package/modern/components/buttons/index.module.css.js +1 -1
  65. package/modern/components/header/index.css +1 -1
  66. package/modern/components/header/index.module.css.js +1 -1
  67. package/modern/components/header-info-block/index.css +4 -4
  68. package/modern/components/header-info-block/index.module.css.js +1 -1
  69. package/modern/components/header-mobile/Component.js +41 -15
  70. package/modern/components/header-mobile/Component.js.map +1 -1
  71. package/modern/components/header-mobile/index.css +6 -6
  72. package/modern/components/header-mobile/index.module.css.js +1 -1
  73. package/modern/components/image-preview/index.css +17 -17
  74. package/modern/components/image-preview/index.module.css.js +1 -1
  75. package/modern/components/image-viewer/component.js +2 -4
  76. package/modern/components/image-viewer/component.js.map +1 -1
  77. package/modern/components/image-viewer/index.css +25 -25
  78. package/modern/components/image-viewer/index.module.css.js +1 -1
  79. package/modern/components/image-viewer/video/index.css +7 -7
  80. package/modern/components/image-viewer/video/index.module.css.js +1 -1
  81. package/modern/components/info-bar/index.css +3 -3
  82. package/modern/components/info-bar/index.module.css.js +1 -1
  83. package/modern/components/navigation-bar/index.css +8 -8
  84. package/modern/components/navigation-bar/index.module.css.js +1 -1
  85. package/modern/components/subtitles/index.css +3 -3
  86. package/modern/components/subtitles/index.module.css.js +1 -1
  87. package/modern/index.css +9 -9
  88. package/modern/index.module.css.js +1 -1
  89. package/moderncssm/components/header-mobile/Component.js +41 -15
  90. package/moderncssm/components/header-mobile/Component.js.map +1 -1
  91. package/moderncssm/components/image-viewer/component.js +2 -4
  92. package/moderncssm/components/image-viewer/component.js.map +1 -1
  93. package/package.json +11 -11
  94. package/src/components/header-mobile/Component.tsx +45 -17
  95. package/src/components/image-viewer/component.tsx +1 -1
@@ -4,30 +4,30 @@
4
4
  } :root {
5
5
  --border-radius-3xl: 24px;
6
6
  --border-radius-24: var(--border-radius-3xl);
7
- } .gallery__videoWrapper_1beje {
7
+ } .gallery__videoWrapper_s9vff {
8
8
  display: flex;
9
9
  justify-content: center;
10
10
  height: 100%;
11
11
  width: auto;
12
12
  position: relative;
13
- } .gallery__video_1beje {
13
+ } .gallery__video_s9vff {
14
14
  max-width: 100%;
15
15
  max-height: 100%;
16
16
  border-radius: var(--border-radius-24);
17
- } .gallery__mobile_1beje {
17
+ } .gallery__mobile_s9vff {
18
18
  border-radius: 0;
19
- } .gallery__videoButton_1beje {
19
+ } .gallery__videoButton_s9vff {
20
20
  position: absolute;
21
21
  top: 50%;
22
22
  left: 50%;
23
23
  transform: translate(-50%, -50%);
24
24
  z-index: 1;
25
25
  color: green;
26
- } .gallery__icon_1beje {
26
+ } .gallery__icon_s9vff {
27
27
  color: var(--color-static-neutral-0);
28
- } .gallery__iconShape_1beje {
28
+ } .gallery__iconShape_s9vff {
29
29
  fill: var(--color-static-neutral-translucent-700);
30
- } .gallery__bottomButton_1beje {
30
+ } .gallery__bottomButton_s9vff {
31
31
  position: absolute;
32
32
  bottom: 48px;
33
33
  left: 32px;
@@ -1,6 +1,6 @@
1
1
  import './index.css';
2
2
 
3
- const styles = {"videoWrapper":"gallery__videoWrapper_1beje","video":"gallery__video_1beje","mobile":"gallery__mobile_1beje","videoButton":"gallery__videoButton_1beje","icon":"gallery__icon_1beje","iconShape":"gallery__iconShape_1beje","bottomButton":"gallery__bottomButton_1beje"};
3
+ const styles = {"videoWrapper":"gallery__videoWrapper_s9vff","video":"gallery__video_s9vff","mobile":"gallery__mobile_s9vff","videoButton":"gallery__videoButton_s9vff","icon":"gallery__icon_s9vff","iconShape":"gallery__iconShape_s9vff","bottomButton":"gallery__bottomButton_s9vff"};
4
4
 
5
5
  export { styles as default };
6
6
  //# sourceMappingURL=index.module.css.js.map
@@ -5,9 +5,9 @@
5
5
  --gap-xs: 8px;
6
6
  --gap-4: var(--gap-2xs);
7
7
  --gap-8: var(--gap-xs);
8
- } .gallery__description_1o3h0 {
8
+ } .gallery__description_1wotl {
9
9
  text-align: center;
10
- } .gallery__infoWrapper_1o3h0 {
10
+ } .gallery__infoWrapper_1wotl {
11
11
  background-color: var(--color-static-neutral-0-inverted);
12
12
  display: flex;
13
13
  align-items: center;
@@ -15,7 +15,7 @@
15
15
  padding: 0 var(--gap-8) var(--gap-4);
16
16
  position: relative;
17
17
  height: 48px
18
- } .gallery__infoWrapper_1o3h0.gallery__video_1o3h0 {
18
+ } .gallery__infoWrapper_1wotl.gallery__video_1wotl {
19
19
  padding: 0 var(--gap-4) var(--gap-4);
20
20
  justify-content: space-between;
21
21
  }
@@ -1,6 +1,6 @@
1
1
  import './index.css';
2
2
 
3
- const styles = {"description":"gallery__description_1o3h0","infoWrapper":"gallery__infoWrapper_1o3h0","video":"gallery__video_1o3h0"};
3
+ const styles = {"description":"gallery__description_1wotl","infoWrapper":"gallery__infoWrapper_1wotl","video":"gallery__video_1wotl"};
4
4
 
5
5
  export { styles as default };
6
6
  //# sourceMappingURL=index.module.css.js.map
@@ -11,7 +11,7 @@
11
11
  --gap-8: var(--gap-xs);
12
12
  --gap-12: var(--gap-s);
13
13
  --gap-24: var(--gap-xl);
14
- } .gallery__component_1xzqj {
14
+ } .gallery__component_vhjcl {
15
15
  display: flex;
16
16
  flex-wrap: nowrap;
17
17
  align-content: center;
@@ -22,19 +22,19 @@
22
22
  padding: var(--gap-12) var(--gap-24);
23
23
  scrollbar-width: none;
24
24
  background-color: var(--color-static-neutral-0-inverted)
25
- } .gallery__component_1xzqj.gallery__mobile_1xzqj {
25
+ } .gallery__component_vhjcl.gallery__mobile_vhjcl {
26
26
  padding: var(--gap-8) var(--gap-24);
27
- } .gallery__component_1xzqj::-webkit-scrollbar {
27
+ } .gallery__component_vhjcl::-webkit-scrollbar {
28
28
  display: none;
29
- } .gallery__previews_1xzqj {
29
+ } .gallery__previews_vhjcl {
30
30
  display: flex;
31
- } .gallery__preview_1xzqj {
31
+ } .gallery__preview_vhjcl {
32
32
  flex-shrink: 0;
33
33
  margin-right: var(--gap-4)
34
- } .gallery__preview_1xzqj.gallery__mobile_1xzqj {
34
+ } .gallery__preview_vhjcl.gallery__mobile_vhjcl {
35
35
  margin-right: var(--gap-2);
36
- } .gallery__preview_1xzqj:first-child {
36
+ } .gallery__preview_vhjcl:first-child {
37
37
  margin-left: auto;
38
- } .gallery__preview_1xzqj:last-child {
38
+ } .gallery__preview_vhjcl:last-child {
39
39
  margin-right: auto;
40
40
  }
@@ -1,6 +1,6 @@
1
1
  import './index.css';
2
2
 
3
- const styles = {"component":"gallery__component_1xzqj","mobile":"gallery__mobile_1xzqj","preview":"gallery__preview_1xzqj"};
3
+ const styles = {"component":"gallery__component_vhjcl","mobile":"gallery__mobile_vhjcl","preview":"gallery__preview_vhjcl"};
4
4
 
5
5
  export { styles as default };
6
6
  //# sourceMappingURL=index.module.css.js.map
@@ -4,7 +4,7 @@
4
4
  --gap-0: 0px;
5
5
  --gap-16: var(--gap-m);
6
6
  --gap-32: var(--gap-2xl);
7
- } .gallery__subtitles_19v8x {
7
+ } .gallery__subtitles_17mnq {
8
8
  position: absolute;
9
9
  align-self: flex-end;
10
10
  padding: var(--gap-0) var(--gap-32);
@@ -14,8 +14,8 @@
14
14
  opacity: 1;
15
15
  z-index: 1;
16
16
  transition: opacity 500ms ease-in-out, margin-bottom 270ms ease-in-out
17
- } .gallery__subtitles_19v8x.gallery__mobile_19v8x {
17
+ } .gallery__subtitles_17mnq.gallery__mobile_17mnq {
18
18
  position: unset;
19
- } .gallery__hideSubtitles_19v8x {
19
+ } .gallery__hideSubtitles_17mnq {
20
20
  opacity: 0;
21
21
  }
@@ -1,6 +1,6 @@
1
1
  import './index.css';
2
2
 
3
- const styles = {"subtitles":"gallery__subtitles_19v8x","mobile":"gallery__mobile_19v8x","hideSubtitles":"gallery__hideSubtitles_19v8x"};
3
+ const styles = {"subtitles":"gallery__subtitles_17mnq","mobile":"gallery__mobile_17mnq","hideSubtitles":"gallery__hideSubtitles_17mnq"};
4
4
 
5
5
  export { styles as default };
6
6
  //# sourceMappingURL=index.module.css.js.map
package/modern/index.css CHANGED
@@ -10,7 +10,7 @@
10
10
  } :root {
11
11
  --sat: env(safe-area-inset-top, var(--gap-0));
12
12
  --sab: env(safe-area-inset-bottom, var(--gap-0));
13
- } .gallery__container_1hoow {
13
+ } .gallery__container_ywvi1 {
14
14
  position: relative;
15
15
  overflow-x: hidden;
16
16
  overflow-y: auto;
@@ -22,14 +22,14 @@
22
22
  background-color: var(--color-static-neutral-0-inverted);
23
23
  padding-top: var(--sat);
24
24
  padding-bottom: var(--sab)
25
- } .gallery__container_1hoow.gallery__mobile_1hoow {
25
+ } .gallery__container_ywvi1.gallery__mobile_ywvi1 {
26
26
  overflow: hidden;
27
- } .gallery__modal_1hoow {
27
+ } .gallery__modal_ywvi1 {
28
28
  flex-grow: 1;
29
29
  width: 100vw;
30
30
  height: 100vh;
31
31
  background: transparent;
32
- } .gallery__navigationVideo_1hoow {
32
+ } .gallery__navigationVideo_ywvi1 {
33
33
  z-index: 3;
34
34
  width: 100%;
35
35
  position: absolute;
@@ -37,15 +37,15 @@
37
37
  left: 0;
38
38
  transition: transform 0.3s ease-in-out;
39
39
  text-align: center;
40
- } .gallery__hide_1hoow {
40
+ } .gallery__hide_ywvi1 {
41
41
  transform: translateY(114px);
42
- } .gallery__hideInfo_1hoow {
42
+ } .gallery__hideInfo_ywvi1 {
43
43
  transform: translateY(48px);
44
- } .gallery__bottomButton_1hoow {
44
+ } .gallery__bottomButton_ywvi1 {
45
45
  width: calc(100% - var(--gap-32));
46
46
  margin: var(--gap-16);
47
47
  background-color: var(--color-static-neutral-translucent-500-inverted);
48
- } .gallery__subtitles_1hoow {
48
+ } .gallery__subtitles_ywvi1 {
49
49
  padding: var(--gap-0) var(--gap-32);
50
50
  margin-bottom: var(--gap-16);
51
51
  width: 100%;
@@ -53,6 +53,6 @@
53
53
  opacity: 1;
54
54
  z-index: 1;
55
55
  transition: opacity 500ms ease-in-out, margin-bottom 270ms ease-in-out;
56
- } .gallery__hideSubtitles_1hoow {
56
+ } .gallery__hideSubtitles_ywvi1 {
57
57
  opacity: 0;
58
58
  }
@@ -1,6 +1,6 @@
1
1
  import './index.css';
2
2
 
3
- const styles = {"container":"gallery__container_1hoow","mobile":"gallery__mobile_1hoow","modal":"gallery__modal_1hoow","navigationVideo":"gallery__navigationVideo_1hoow","hide":"gallery__hide_1hoow","hideInfo":"gallery__hideInfo_1hoow","bottomButton":"gallery__bottomButton_1hoow"};
3
+ const styles = {"container":"gallery__container_ywvi1","mobile":"gallery__mobile_ywvi1","modal":"gallery__modal_ywvi1","navigationVideo":"gallery__navigationVideo_ywvi1","hide":"gallery__hide_ywvi1","hideInfo":"gallery__hideInfo_ywvi1","bottomButton":"gallery__bottomButton_ywvi1"};
4
4
 
5
5
  export { styles as default };
6
6
  //# sourceMappingURL=index.module.css.js.map
@@ -15,25 +15,51 @@ const HeaderMobile = () => {
15
15
  const canDownload = currentImage?.canDownload ?? true;
16
16
  const showDownloadButton = !meta?.broken && canDownload;
17
17
  const handleShareClick = async () => {
18
- if (!currentImage)
18
+ if (!currentImage || !navigator.share) {
19
19
  return;
20
+ }
20
21
  const title = currentImage.name ?? new Date().toISOString().split('T')[0];
21
- const image = await fetch(currentImage.src);
22
- const blob = await image.blob();
23
- const filesArray = [
24
- new File([blob], title, {
22
+ const url = currentImage.src;
23
+ try {
24
+ if (isVideo(url)) {
25
+ // Если видео — всегда делим ссылку
26
+ await navigator.share({
27
+ title,
28
+ url,
29
+ text: 'Видео',
30
+ });
31
+ return;
32
+ }
33
+ // Попробуем скачать изображение
34
+ const response = await fetch(url, { mode: 'cors' });
35
+ const blob = await response.blob();
36
+ const file = new File([blob], `${title}.png`, {
25
37
  type: blob.type,
26
- lastModified: new Date().getTime(),
27
- }),
28
- ];
29
- const shareData = {
30
- files: filesArray,
31
- };
32
- if (navigator.canShare(shareData) && !isVideo(currentImage.src)) {
33
- await navigator.share(shareData);
38
+ lastModified: Date.now(),
39
+ });
40
+ const shareData = {
41
+ files: [file],
42
+ title,
43
+ text: 'Картинка',
44
+ };
45
+ // Попробуем поделиться файлом
46
+ if (navigator.canShare?.(shareData) && response.ok) {
47
+ await navigator.share(shareData);
48
+ }
49
+ else {
50
+ // Fallback: делимся только ссылкой
51
+ await navigator.share({
52
+ title,
53
+ text: 'Картинка',
54
+ url,
55
+ });
56
+ }
34
57
  }
35
- else {
36
- await navigator.share({ url: currentImage.src, title });
58
+ catch {
59
+ await navigator.share({
60
+ title,
61
+ url,
62
+ });
37
63
  }
38
64
  };
39
65
  return (React.createElement("div", { className: cn(styles.headerMobile, {
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","sources":["../../../src/components/header-mobile/Component.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport cn from 'classnames';\n\nimport { Text } from '@alfalab/core-components-typography';\n\nimport { GalleryContext } from '../../context';\nimport { isVideo, TestIds } from '../../utils';\nimport * as Buttons from '../buttons';\n\nimport styles from './index.module.css';\n\nexport const HeaderMobile = () => {\n const {\n onClose,\n images,\n currentSlideIndex,\n getCurrentImage,\n getCurrentImageMeta,\n hideNavigation,\n } = useContext(GalleryContext);\n\n const currentImage = getCurrentImage();\n const meta = getCurrentImageMeta();\n\n const description = images.length > 1 && `${currentSlideIndex + 1} из ${images.length}`;\n\n const canDownload = currentImage?.canDownload ?? true;\n const showDownloadButton = !meta?.broken && canDownload;\n\n const handleShareClick = async () => {\n if (!currentImage) return;\n\n const title = currentImage.name ?? new Date().toISOString().split('T')[0];\n\n const image = await fetch(currentImage.src);\n const blob = await image.blob();\n\n const filesArray = [\n new File([blob], title, {\n type: blob.type,\n lastModified: new Date().getTime(),\n }),\n ];\n\n const shareData = {\n files: filesArray,\n };\n\n if (navigator.canShare(shareData) && !isVideo(currentImage.src)) {\n await navigator.share(shareData);\n } else {\n await navigator.share({ url: currentImage.src, title });\n }\n };\n\n return (\n <div\n className={cn(styles.headerMobile, {\n [styles.video]: isVideo(currentImage?.src),\n [styles.hide]: hideNavigation,\n })}\n >\n <Buttons.BackArrow onClick={onClose} />\n <Text\n className={styles.description}\n tag='div'\n view='component-primary'\n color='static-primary-light'\n >\n {description}\n </Text>\n <div className={styles.rightButtons}>\n {showDownloadButton && (\n <Buttons.Download\n href={currentImage?.src}\n download={currentImage?.name}\n dataTestId={TestIds.DOWNLOAD_BUTTON}\n />\n )}\n {!meta?.broken && <Buttons.Share onClick={handleShareClick} />}\n </div>\n </div>\n );\n};\n"],"names":["Buttons.BackArrow","Buttons.Download","Buttons.Share"],"mappings":";;;;;;;;;AAWO,MAAM,YAAY,GAAG,MAAK;AAC7B,IAAA,MAAM,EACF,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,cAAc,GACjB,GAAG,UAAU,CAAC,cAAc,CAAC;AAE9B,IAAA,MAAM,YAAY,GAAG,eAAe,EAAE;AACtC,IAAA,MAAM,IAAI,GAAG,mBAAmB,EAAE;AAElC,IAA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YAC/B,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC;AAC1C,YAAA,CAAC,MAAM,CAAC,IAAI,GAAG,cAAc;SAChC,CAAC,EAAA;AAEF,QAAA,KAAA,CAAA,aAAA,CAACA,SAAiB,IAAC,OAAO,EAAE,OAAO,EAAI,CAAA;QACvC,KAAC,CAAA,aAAA,CAAA,IAAI,IACD,SAAS,EAAE,MAAM,CAAC,WAAW,EAC7B,GAAG,EAAC,KAAK,EACT,IAAI,EAAC,mBAAmB,EACxB,KAAK,EAAC,sBAAsB,EAE3B,EAAA,WAAW,CACT;AACP,QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA;YAC9B,kBAAkB,KACf,KAAA,CAAA,aAAA,CAACC,QAAgB,EACb,EAAA,IAAI,EAAE,YAAY,EAAE,GAAG,EACvB,QAAQ,EAAE,YAAY,EAAE,IAAI,EAC5B,UAAU,EAAE,OAAO,CAAC,eAAe,EAAA,CACrC,CACL;AACA,YAAA,CAAC,IAAI,EAAE,MAAM,IAAI,KAAA,CAAA,aAAA,CAACC,KAAa,EAAC,EAAA,OAAO,EAAE,gBAAgB,EAAA,CAAI,CAC5D,CACJ;AAEd;;;;"}
1
+ {"version":3,"file":"Component.js","sources":["../../../src/components/header-mobile/Component.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport cn from 'classnames';\n\nimport { Text } from '@alfalab/core-components-typography';\n\nimport { GalleryContext } from '../../context';\nimport { isVideo, TestIds } from '../../utils';\nimport * as Buttons from '../buttons';\n\nimport styles from './index.module.css';\n\nexport const HeaderMobile = () => {\n const {\n onClose,\n images,\n currentSlideIndex,\n getCurrentImage,\n getCurrentImageMeta,\n hideNavigation,\n } = useContext(GalleryContext);\n\n const currentImage = getCurrentImage();\n const meta = getCurrentImageMeta();\n\n const description = images.length > 1 && `${currentSlideIndex + 1} из ${images.length}`;\n\n const canDownload = currentImage?.canDownload ?? true;\n const showDownloadButton = !meta?.broken && canDownload;\n\n const handleShareClick = async () => {\n if (!currentImage || !navigator.share) {\n return;\n }\n\n const title = currentImage.name ?? new Date().toISOString().split('T')[0];\n const url = currentImage.src;\n\n try {\n if (isVideo(url)) {\n // Если видео — всегда делим ссылку\n await navigator.share({\n title,\n url,\n text: 'Видео',\n });\n\n return;\n }\n\n // Попробуем скачать изображение\n const response = await fetch(url, { mode: 'cors' });\n const blob = await response.blob();\n\n const file = new File([blob], `${title}.png`, {\n type: blob.type,\n lastModified: Date.now(),\n });\n\n const shareData: ShareData = {\n files: [file],\n title,\n text: 'Картинка',\n };\n\n // Попробуем поделиться файлом\n if (navigator.canShare?.(shareData) && response.ok) {\n await navigator.share(shareData);\n } else {\n // Fallback: делимся только ссылкой\n await navigator.share({\n title,\n text: 'Картинка',\n url,\n });\n }\n } catch {\n await navigator.share({\n title,\n url,\n });\n }\n };\n\n return (\n <div\n className={cn(styles.headerMobile, {\n [styles.video]: isVideo(currentImage?.src),\n [styles.hide]: hideNavigation,\n })}\n >\n <Buttons.BackArrow onClick={onClose} />\n <Text\n className={styles.description}\n tag='div'\n view='component-primary'\n color='static-primary-light'\n >\n {description}\n </Text>\n <div className={styles.rightButtons}>\n {showDownloadButton && (\n <Buttons.Download\n href={currentImage?.src}\n download={currentImage?.name}\n dataTestId={TestIds.DOWNLOAD_BUTTON}\n />\n )}\n {!meta?.broken && <Buttons.Share onClick={handleShareClick} />}\n </div>\n </div>\n );\n};\n"],"names":["Buttons.BackArrow","Buttons.Download","Buttons.Share"],"mappings":";;;;;;;;;AAWO,MAAM,YAAY,GAAG,MAAK;AAC7B,IAAA,MAAM,EACF,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,cAAc,GACjB,GAAG,UAAU,CAAC,cAAc,CAAC;AAE9B,IAAA,MAAM,YAAY,GAAG,eAAe,EAAE;AACtC,IAAA,MAAM,IAAI,GAAG,mBAAmB,EA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EAAA,CAAI,CAC5D,CACJ;AAEd;;;;"}
@@ -72,12 +72,10 @@ const ImageViewer = () => {
72
72
  const swiperWidth = swiper?.width || 1;
73
73
  const swiperHeight = swiper?.height || swiper?.width || 1;
74
74
  const swiperAspectRatio = swiperWidth / swiperHeight;
75
- return (
76
- /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
77
- React.createElement("div", { className: cn(styles.component, {
75
+ return (React.createElement("div", { className: cn(styles.component, {
78
76
  [styles.mobile]: isMobile,
79
77
  [styles.mobileVideo]: isMobile && isVideo(currentImage?.src),
80
- }), onClick: handleWrapperClick },
78
+ }), "aria-hidden": true, onClick: handleWrapperClick },
81
79
  showControls && (React.createElement("div", { className: cn(styles.arrow, {
82
80
  [styles.focused]: leftArrowFocused,
83
81
  }), onClick: handlePrevClick, role: 'button', onKeyDown: handleArrowLeftKeyDown, tabIndex: 0, ref: leftArrowRef, "aria-label": '\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0435\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435', "data-test-id": TestIds.PREV_SLIDE_BUTTON },
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/image-viewer/component.tsx"],"sourcesContent":["import React, { FC, KeyboardEventHandler, useCallback, useContext, useMemo } from 'react';\nimport cn from 'classnames';\nimport SwiperCore, { A11y, Controller, EffectFade } from 'swiper';\nimport { Swiper, SwiperSlide } from 'swiper/react';\n\nimport { useFocus } from '@alfalab/hooks';\nimport { ChevronBackHeavyMIcon } from '@alfalab/icons-glyph/ChevronBackHeavyMIcon';\nimport { ChevronForwardHeavyMIcon } from '@alfalab/icons-glyph/ChevronForwardHeavyMIcon';\n\nimport { GalleryContext } from '../../context';\nimport { getImageAlt, getImageKey, isVideo, TestIds } from '../../utils';\n\nimport { useHandleImageViewer } from './hooks';\nimport { Slide } from './slide';\n\nimport 'swiper/swiper.min.css';\nimport styles from './index.module.css';\n\nSwiperCore.use([EffectFade, A11y, Controller]);\n\nexport const ImageViewer: FC = () => {\n const {\n images,\n imagesMeta,\n fullScreen,\n currentSlideIndex,\n initialSlide,\n setCurrentSlideIndex,\n getSwiper,\n setSwiper,\n slidePrev,\n slideNext,\n getCurrentImage,\n } = useContext(GalleryContext);\n\n const { handleWrapperClick, isMobile, rightArrowRef, leftArrowRef } = useHandleImageViewer();\n\n const [leftArrowFocused] = useFocus(leftArrowRef, 'keyboard');\n const [rightArrowFocused] = useFocus(rightArrowRef, 'keyboard');\n\n const swiper = getSwiper();\n const currentImage = getCurrentImage();\n\n const handleSlideChange = useCallback(() => {\n setCurrentSlideIndex?.(swiper?.activeIndex ?? initialSlide);\n }, [setCurrentSlideIndex, swiper, initialSlide]);\n\n const handlePrevClick = () => {\n slidePrev();\n };\n\n const handleNextClick = () => {\n slideNext();\n };\n\n const handleArrowLeftKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === 'Enter') {\n slidePrev();\n }\n };\n\n const handleArrowRightKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === 'Enter') {\n slideNext();\n }\n };\n\n const swiperProps = useMemo<Swiper>(\n () => ({\n slidesPerView: 1,\n effect: 'slide',\n className: cn(styles.swiper, {\n [styles.hidden]: fullScreen && !isVideo(currentImage?.src),\n [styles.fullScreenVideo]: fullScreen && isVideo(currentImage?.src),\n [styles.mobile]: isMobile,\n [styles.mobileVideo]: isMobile && isVideo(currentImage?.src),\n }),\n controller: { control: swiper },\n a11y: {\n slideRole: 'img',\n },\n initialSlide,\n simulateTouch: false,\n zoom: { maxRatio: 4, minRatio: 1, toggle: true },\n onSwiper: setSwiper,\n onSlideChange: handleSlideChange,\n lazy: { loadPrevNext: true },\n }),\n [\n fullScreen,\n currentImage?.src,\n isMobile,\n swiper,\n initialSlide,\n setSwiper,\n handleSlideChange,\n ],\n );\n\n const showControls = !fullScreen && !isMobile && !!images.length;\n\n const swiperWidth = swiper?.width || 1;\n const swiperHeight = swiper?.height || swiper?.width || 1;\n\n const swiperAspectRatio = swiperWidth / swiperHeight;\n\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */\n <div\n className={cn(styles.component, {\n [styles.mobile]: isMobile,\n [styles.mobileVideo]: isMobile && isVideo(currentImage?.src),\n })}\n onClick={handleWrapperClick}\n >\n {showControls && (\n <div\n className={cn(styles.arrow, {\n [styles.focused]: leftArrowFocused,\n })}\n onClick={handlePrevClick}\n role='button'\n onKeyDown={handleArrowLeftKeyDown}\n tabIndex={0}\n ref={leftArrowRef}\n aria-label='Предыдущее изображение'\n data-test-id={TestIds.PREV_SLIDE_BUTTON}\n >\n <ChevronBackHeavyMIcon />\n </div>\n )}\n\n {fullScreen && !isVideo(currentImage?.src) && (\n <img\n src={currentImage?.src}\n alt={currentImage ? getImageAlt(currentImage, currentSlideIndex) : ''}\n className={styles.fullScreenImage}\n />\n )}\n\n <Swiper {...swiperProps}>\n {images.map((image, index) => {\n const meta = imagesMeta[index];\n\n const imageWidth = meta?.width || 1;\n const imageHeight = meta?.height || 1;\n\n const imageAspectRatio = imageWidth / imageHeight;\n\n const slideVisible = index === currentSlideIndex;\n\n return (\n <SwiperSlide\n key={getImageKey(image, index)}\n style={{\n pointerEvents: slideVisible ? 'auto' : 'none',\n transitionProperty: 'opacity',\n }}\n >\n {({ isActive }) => (\n <Slide\n isActive={isActive}\n containerAspectRatio={swiperAspectRatio}\n image={image}\n containerHeight={swiperHeight}\n meta={meta}\n index={index}\n imageAspectRatio={imageAspectRatio}\n slideVisible={slideVisible}\n />\n )}\n </SwiperSlide>\n );\n })}\n </Swiper>\n\n {showControls && (\n <div\n className={cn(styles.arrow, {\n [styles.focused]: rightArrowFocused,\n })}\n onClick={handleNextClick}\n role='button'\n onKeyDown={handleArrowRightKeyDown}\n tabIndex={0}\n ref={rightArrowRef}\n aria-label='Следующее изображение'\n data-test-id={TestIds.NEXT_SLIDE_BUTTON}\n >\n <ChevronForwardHeavyM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A,CAAA,aAAA,CAAC,wBAAwB,EAAG,IAAA,CAAA,CAC1B,CACT,CACC;AAEd;;;;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/image-viewer/component.tsx"],"sourcesContent":["import React, { FC, KeyboardEventHandler, useCallback, useContext, useMemo } from 'react';\nimport cn from 'classnames';\nimport SwiperCore, { A11y, Controller, EffectFade } from 'swiper';\nimport { Swiper, SwiperSlide } from 'swiper/react';\n\nimport { useFocus } from '@alfalab/hooks';\nimport { ChevronBackHeavyMIcon } from '@alfalab/icons-glyph/ChevronBackHeavyMIcon';\nimport { ChevronForwardHeavyMIcon } from '@alfalab/icons-glyph/ChevronForwardHeavyMIcon';\n\nimport { GalleryContext } from '../../context';\nimport { getImageAlt, getImageKey, isVideo, TestIds } from '../../utils';\n\nimport { useHandleImageViewer } from './hooks';\nimport { Slide } from './slide';\n\nimport 'swiper/swiper.min.css';\nimport styles from './index.module.css';\n\nSwiperCore.use([EffectFade, A11y, Controller]);\n\nexport const ImageViewer: FC = () => {\n const {\n images,\n imagesMeta,\n fullScreen,\n currentSlideIndex,\n initialSlide,\n setCurrentSlideIndex,\n getSwiper,\n setSwiper,\n slidePrev,\n slideNext,\n getCurrentImage,\n } = useContext(GalleryContext);\n\n const { handleWrapperClick, isMobile, rightArrowRef, leftArrowRef } = useHandleImageViewer();\n\n const [leftArrowFocused] = useFocus(leftArrowRef, 'keyboard');\n const [rightArrowFocused] = useFocus(rightArrowRef, 'keyboard');\n\n const swiper = getSwiper();\n const currentImage = getCurrentImage();\n\n const handleSlideChange = useCallback(() => {\n setCurrentSlideIndex?.(swiper?.activeIndex ?? initialSlide);\n }, [setCurrentSlideIndex, swiper, initialSlide]);\n\n const handlePrevClick = () => {\n slidePrev();\n };\n\n const handleNextClick = () => {\n slideNext();\n };\n\n const handleArrowLeftKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === 'Enter') {\n slidePrev();\n }\n };\n\n const handleArrowRightKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === 'Enter') {\n slideNext();\n }\n };\n\n const swiperProps = useMemo<Swiper>(\n () => ({\n slidesPerView: 1,\n effect: 'slide',\n className: cn(styles.swiper, {\n [styles.hidden]: fullScreen && !isVideo(currentImage?.src),\n [styles.fullScreenVideo]: fullScreen && isVideo(currentImage?.src),\n [styles.mobile]: isMobile,\n [styles.mobileVideo]: isMobile && isVideo(currentImage?.src),\n }),\n controller: { control: swiper },\n a11y: {\n slideRole: 'img',\n },\n initialSlide,\n simulateTouch: false,\n zoom: { maxRatio: 4, minRatio: 1, toggle: true },\n onSwiper: setSwiper,\n onSlideChange: handleSlideChange,\n lazy: { loadPrevNext: true },\n }),\n [\n fullScreen,\n currentImage?.src,\n isMobile,\n swiper,\n initialSlide,\n setSwiper,\n handleSlideChange,\n ],\n );\n\n const showControls = !fullScreen && !isMobile && !!images.length;\n\n const swiperWidth = swiper?.width || 1;\n const swiperHeight = swiper?.height || swiper?.width || 1;\n\n const swiperAspectRatio = swiperWidth / swiperHeight;\n\n return (\n <div\n className={cn(styles.component, {\n [styles.mobile]: isMobile,\n [styles.mobileVideo]: isMobile && isVideo(currentImage?.src),\n })}\n aria-hidden={true}\n onClick={handleWrapperClick}\n >\n {showControls && (\n <div\n className={cn(styles.arrow, {\n [styles.focused]: leftArrowFocused,\n })}\n onClick={handlePrevClick}\n role='button'\n onKeyDown={handleArrowLeftKeyDown}\n tabIndex={0}\n ref={leftArrowRef}\n aria-label='Предыдущее изображение'\n data-test-id={TestIds.PREV_SLIDE_BUTTON}\n >\n <ChevronBackHeavyMIcon />\n </div>\n )}\n\n {fullScreen && !isVideo(currentImage?.src) && (\n <img\n src={currentImage?.src}\n alt={currentImage ? getImageAlt(currentImage, currentSlideIndex) : ''}\n className={styles.fullScreenImage}\n />\n )}\n\n <Swiper {...swiperProps}>\n {images.map((image, index) => {\n const meta = imagesMeta[index];\n\n const imageWidth = meta?.width || 1;\n const imageHeight = meta?.height || 1;\n\n const imageAspectRatio = imageWidth / imageHeight;\n\n const slideVisible = index === currentSlideIndex;\n\n return (\n <SwiperSlide\n key={getImageKey(image, index)}\n style={{\n pointerEvents: slideVisible ? 'auto' : 'none',\n transitionProperty: 'opacity',\n }}\n >\n {({ isActive }) => (\n <Slide\n isActive={isActive}\n containerAspectRatio={swiperAspectRatio}\n image={image}\n containerHeight={swiperHeight}\n meta={meta}\n index={index}\n imageAspectRatio={imageAspectRatio}\n slideVisible={slideVisible}\n />\n )}\n </SwiperSlide>\n );\n })}\n </Swiper>\n\n {showControls && (\n <div\n className={cn(styles.arrow, {\n [styles.focused]: rightArrowFocused,\n })}\n onClick={handleNextClick}\n role='button'\n onKeyDown={handleArrowRightKeyDown}\n tabIndex={0}\n ref={rightArrowRef}\n aria-label='Следующее изображение'\n data-test-id={TestIds.NEXT_SLIDE_BUTTON}\n >\n <ChevronForwardHeavyMIcon />\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAkBA,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;AAEvC,MAAM,WAAW,GAAO,MAAK;AAChC,IAAA,MAAM,EACF,MAAM,EACN,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,eAAe,GAClB,GAAG,UAAU,CAAC,cAAc,CAAC;AAE9B,IAAA,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,oBAAoB,EAAE;IAE5F,MAAM,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAC7D,MAAM,CAAC,iBAAiB,CAAC,GAAG,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;AAE/D,IAAA,MAAM,MAAM,GAAG,SAAS,EAAE;AAC1B,IAAA,MAAM,YAAY,GAAG,eAAe,EAAE;AAEtC,IAAA,MA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AE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,EAC5B,CAAA,CACL,CACS;AAEtB,SAAC,CAAC,CACG;QAER,YAAY,KACT,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;AACxB,gBAAA,CAAC,MAAM,CAAC,OAAO,GAAG,iBAAiB;aACtC,CAAC,EACF,OAAO,EAAE,eAAe,EACxB,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,uBAAuB,EAClC,QAAQ,EAAE,CAAC,EACX,GAAG,EAAE,aAAa,EAAA,YAAA,EACP,2HAAuB,EAAA,cAAA,EACpB,OAAO,CAAC,iBAAiB,EAAA;AAEvC,YAAA,KAAA,CAAA,aAAA,CAAC,wBAAwB,EAAG,IAAA,CAAA,CAC1B,CACT,CACC;AAEd;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-gallery",
3
- "version": "6.0.1-snapshot-c2c8d5a",
3
+ "version": "6.0.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,16 +10,16 @@
10
10
  "main": "index.js",
11
11
  "module": "./esm/index.js",
12
12
  "dependencies": {
13
- "@alfalab/core-components-base-modal": "6.0.1-snapshot-c2c8d5a",
14
- "@alfalab/core-components-button": "12.0.1-snapshot-c2c8d5a",
15
- "@alfalab/core-components-icon-button": "7.0.1-snapshot-c2c8d5a",
13
+ "@alfalab/core-components-base-modal": "^6.0.1",
14
+ "@alfalab/core-components-button": "^12.0.1",
15
+ "@alfalab/core-components-icon-button": "^7.0.1",
16
16
  "@alfalab/core-components-icon-view": "^4.0.0",
17
- "@alfalab/core-components-mq": "5.0.1-snapshot-c2c8d5a",
18
- "@alfalab/core-components-spinner": "5.0.1-snapshot-c2c8d5a",
19
- "@alfalab/core-components-tooltip": "8.0.1-snapshot-c2c8d5a",
20
- "@alfalab/core-components-typography": "5.0.1-snapshot-c2c8d5a",
17
+ "@alfalab/core-components-mq": "^5.0.1",
18
+ "@alfalab/core-components-spinner": "^5.0.1",
19
+ "@alfalab/core-components-tooltip": "^8.0.1",
20
+ "@alfalab/core-components-typography": "^5.0.1",
21
21
  "@alfalab/hooks": "^1.13.1",
22
- "@alfalab/icons-glyph": "^2.210.0",
22
+ "@alfalab/icons-glyph": "^2.247.0",
23
23
  "classnames": "^2.5.1",
24
24
  "element-closest": "^3.0.2",
25
25
  "hls.js": "^1.5.13",
@@ -35,6 +35,6 @@
35
35
  "access": "public",
36
36
  "directory": "dist"
37
37
  },
38
- "themesVersion": "14.0.0",
39
- "varsVersion": "10.0.1-snapshot-c2c8d5a"
38
+ "themesVersion": "14.1.0",
39
+ "varsVersion": "10.1.0"
40
40
  }
@@ -28,28 +28,56 @@ export const HeaderMobile = () => {
28
28
  const showDownloadButton = !meta?.broken && canDownload;
29
29
 
30
30
  const handleShareClick = async () => {
31
- if (!currentImage) return;
31
+ if (!currentImage || !navigator.share) {
32
+ return;
33
+ }
32
34
 
33
35
  const title = currentImage.name ?? new Date().toISOString().split('T')[0];
36
+ const url = currentImage.src;
37
+
38
+ try {
39
+ if (isVideo(url)) {
40
+ // Если видео — всегда делим ссылку
41
+ await navigator.share({
42
+ title,
43
+ url,
44
+ text: 'Видео',
45
+ });
46
+
47
+ return;
48
+ }
34
49
 
35
- const image = await fetch(currentImage.src);
36
- const blob = await image.blob();
50
+ // Попробуем скачать изображение
51
+ const response = await fetch(url, { mode: 'cors' });
52
+ const blob = await response.blob();
37
53
 
38
- const filesArray = [
39
- new File([blob], title, {
54
+ const file = new File([blob], `${title}.png`, {
40
55
  type: blob.type,
41
- lastModified: new Date().getTime(),
42
- }),
43
- ];
44
-
45
- const shareData = {
46
- files: filesArray,
47
- };
48
-
49
- if (navigator.canShare(shareData) && !isVideo(currentImage.src)) {
50
- await navigator.share(shareData);
51
- } else {
52
- await navigator.share({ url: currentImage.src, title });
56
+ lastModified: Date.now(),
57
+ });
58
+
59
+ const shareData: ShareData = {
60
+ files: [file],
61
+ title,
62
+ text: 'Картинка',
63
+ };
64
+
65
+ // Попробуем поделиться файлом
66
+ if (navigator.canShare?.(shareData) && response.ok) {
67
+ await navigator.share(shareData);
68
+ } else {
69
+ // Fallback: делимся только ссылкой
70
+ await navigator.share({
71
+ title,
72
+ text: 'Картинка',
73
+ url,
74
+ });
75
+ }
76
+ } catch {
77
+ await navigator.share({
78
+ title,
79
+ url,
80
+ });
53
81
  }
54
82
  };
55
83
 
@@ -105,12 +105,12 @@ export const ImageViewer: FC = () => {
105
105
  const swiperAspectRatio = swiperWidth / swiperHeight;
106
106
 
107
107
  return (
108
- /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
109
108
  <div
110
109
  className={cn(styles.component, {
111
110
  [styles.mobile]: isMobile,
112
111
  [styles.mobileVideo]: isMobile && isVideo(currentImage?.src),
113
112
  })}
113
+ aria-hidden={true}
114
114
  onClick={handleWrapperClick}
115
115
  >
116
116
  {showControls && (