@layers-app/shared 0.4.5 → 0.4.6

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 (128) hide show
  1. package/dist/components/AppContainer/AppContainer.d.ts.map +1 -1
  2. package/dist/components/AppContainer/AppContainer.js +72 -79
  3. package/dist/components/AppContainer/AppContainer.module.css.js +6 -6
  4. package/dist/components/AppContainer/components/AppsSidebar/TopSection.d.ts.map +1 -1
  5. package/dist/components/AppContainer/components/AppsSidebar/TopSection.js +24 -22
  6. package/dist/components/AppContainer/components/AppsSidebar/UserSection.d.ts.map +1 -1
  7. package/dist/components/AppContainer/components/AppsSidebar/UserSection.js +46 -37
  8. package/dist/components/AppContainer/components/Header.d.ts.map +1 -1
  9. package/dist/components/AppContainer/components/Header.js +6 -5
  10. package/dist/components/AppContainer/components/Main.js +4 -4
  11. package/dist/components/AppContainer/components/SlideAnimation.js +4 -4
  12. package/dist/components/AppContainer/components/ToolSidebar.d.ts.map +1 -1
  13. package/dist/components/AppContainer/components/ToolSidebar.js +161 -128
  14. package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.d.ts.map +1 -1
  15. package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.js +131 -121
  16. package/dist/components/AppContainer/hooks/useAppContainer.d.ts +1 -1
  17. package/dist/components/AppContainer/hooks/useAppContainer.d.ts.map +1 -1
  18. package/dist/components/AppContainer/hooks/useAppContainer.js +59 -56
  19. package/dist/components/AppContainer/hooks/useAppContainerDataStore.d.ts.map +1 -1
  20. package/dist/components/AppContainer/hooks/useAppContainerDataStore.js +4 -3
  21. package/dist/components/AppContainer/types.d.ts +1 -0
  22. package/dist/components/AppContainer/types.d.ts.map +1 -1
  23. package/dist/components/AttachmentsGalleryModal/components/ModalHeader.d.ts.map +1 -1
  24. package/dist/components/AttachmentsGalleryModal/components/ModalHeader.js +37 -37
  25. package/dist/components/AttachmentsGalleryModal/components/ShakePlayer/useShakePlayer.d.ts.map +1 -1
  26. package/dist/components/AttachmentsGalleryModal/components/ShakePlayer/useShakePlayer.js +68 -62
  27. package/dist/components/AttachmentsGalleryModal/helpers.d.ts +8 -0
  28. package/dist/components/AttachmentsGalleryModal/helpers.d.ts.map +1 -1
  29. package/dist/components/AttachmentsGalleryModal/helpers.js +22 -17
  30. package/dist/components/AttachmentsGalleryModal/hooks/useDownloadFile.d.ts.map +1 -1
  31. package/dist/components/AttachmentsGalleryModal/hooks/useDownloadFile.js +28 -25
  32. package/dist/components/AttachmentsGalleryModal/hooks/useGetPreviewUrl.d.ts.map +1 -1
  33. package/dist/components/AttachmentsGalleryModal/hooks/useGetPreviewUrl.js +36 -41
  34. package/dist/components/AttachmentsPreview/AttachmentsPreview.d.ts.map +1 -1
  35. package/dist/components/AttachmentsPreview/AttachmentsPreview.js +135 -80
  36. package/dist/components/AttachmentsPreview/AttachmentsPreview.module.css.js +24 -14
  37. package/dist/components/BouncingLogo/BouncingLogo.d.ts +1 -3
  38. package/dist/components/BouncingLogo/BouncingLogo.d.ts.map +1 -1
  39. package/dist/components/BouncingLogo/BouncingLogo.js +14 -20
  40. package/dist/components/BouncingLogo/BouncingLogo.module.css.js +4 -8
  41. package/dist/components/Chat/ChatBubble/ChatBubble.module.css.js +5 -5
  42. package/dist/components/Chat/ChatInput/ChatInput.module.css.js +40 -28
  43. package/dist/components/Chat/ChatInput/index.d.ts +29 -1
  44. package/dist/components/Chat/ChatInput/index.d.ts.map +1 -1
  45. package/dist/components/Chat/ChatInput/index.js +178 -118
  46. package/dist/components/Chat/ChatInput/smilePlusIcon.d.ts +3 -0
  47. package/dist/components/Chat/ChatInput/smilePlusIcon.d.ts.map +1 -0
  48. package/dist/components/Chat/ChatInput/smilePlusIcon.js +49 -0
  49. package/dist/components/Chat/ChatMessage/ChatMessage.module.css.js +9 -9
  50. package/dist/components/Chat/ChatMessage/index.d.ts +2 -0
  51. package/dist/components/Chat/ChatMessage/index.d.ts.map +1 -1
  52. package/dist/components/Chat/ChatMessage/index.js +136 -118
  53. package/dist/components/Chat/MediaDocument/MediaDocument.module.css.js +4 -4
  54. package/dist/components/Chat/MessageActions/index.d.ts +7 -0
  55. package/dist/components/Chat/MessageActions/index.d.ts.map +1 -1
  56. package/dist/components/Chat/MessageActions/index.js +33 -30
  57. package/dist/components/Chat/MessageList/MessageList.module.css.js +14 -10
  58. package/dist/components/Chat/MessageList/index.d.ts +30 -3
  59. package/dist/components/Chat/MessageList/index.d.ts.map +1 -1
  60. package/dist/components/Chat/MessageList/index.js +154 -66
  61. package/dist/components/Chat/MessageReactions/MessageReactions.module.css.js +7 -7
  62. package/dist/components/Chat/MessageReactions/index.d.ts +17 -0
  63. package/dist/components/Chat/MessageReactions/index.d.ts.map +1 -1
  64. package/dist/components/Chat/MessageReactions/index.js +60 -28
  65. package/dist/components/Chat/MessageStatus/MessageStatus.module.css.js +6 -4
  66. package/dist/components/Chat/MessageStatus/index.d.ts +1 -1
  67. package/dist/components/Chat/MessageStatus/index.d.ts.map +1 -1
  68. package/dist/components/Chat/MessageStatus/index.js +49 -34
  69. package/dist/components/CircleColorPicker/CircleColorPicker.d.ts.map +1 -1
  70. package/dist/components/CircleColorPicker/CircleColorPicker.js +17 -15
  71. package/dist/components/ColorPicker/ColorPicker.module.css.js +26 -20
  72. package/dist/components/ColorPicker/ColorPickerList.d.ts.map +1 -1
  73. package/dist/components/ColorPicker/ColorPickerList.js +81 -68
  74. package/dist/components/ColorPicker/ColorPickerToolbar.d.ts.map +1 -1
  75. package/dist/components/ColorPicker/ColorPickerToolbar.js +75 -70
  76. package/dist/components/ColorPicker/icons.js +5 -5
  77. package/dist/components/ColorPicker/types.d.ts +6 -0
  78. package/dist/components/ColorPicker/types.d.ts.map +1 -1
  79. package/dist/components/ColorPicker/types.js +53 -11
  80. package/dist/components/ColorPicker/useRecentColors.d.ts +3 -1
  81. package/dist/components/ColorPicker/useRecentColors.d.ts.map +1 -1
  82. package/dist/components/ColorPicker/useRecentColors.js +43 -20
  83. package/dist/components/EmojiPicker/EmojiPanel.d.ts +2 -1
  84. package/dist/components/EmojiPicker/EmojiPanel.d.ts.map +1 -1
  85. package/dist/components/EmojiPicker/EmojiPanel.js +73 -72
  86. package/dist/components/EmojiPicker/EmojiPicker.d.ts +16 -1
  87. package/dist/components/EmojiPicker/EmojiPicker.d.ts.map +1 -1
  88. package/dist/components/EmojiPicker/EmojiPicker.js +121 -86
  89. package/dist/components/EmojiPicker/IconsPanel.d.ts.map +1 -1
  90. package/dist/components/EmojiPicker/IconsPanel.js +28 -25
  91. package/dist/components/EntityIcon.d.ts +1 -0
  92. package/dist/components/EntityIcon.d.ts.map +1 -1
  93. package/dist/components/EntityIcon.js +80 -32
  94. package/dist/components/ErrorPage/components/Error403.d.ts +5 -1
  95. package/dist/components/ErrorPage/components/Error403.d.ts.map +1 -1
  96. package/dist/components/ErrorPage/components/Error403.js +25 -21
  97. package/dist/components/ErrorPage/index.d.ts +5 -1
  98. package/dist/components/ErrorPage/index.d.ts.map +1 -1
  99. package/dist/components/ErrorPage/index.js +17 -10
  100. package/dist/components/MusicPlayerBar/components/HoverActions.js +28 -28
  101. package/dist/components/NavMenu/NavMenu.d.ts +7 -1
  102. package/dist/components/NavMenu/NavMenu.d.ts.map +1 -1
  103. package/dist/components/NavMenu/NavMenu.js +54 -44
  104. package/dist/components/NavMenu/NavMenu.module.css.js +10 -10
  105. package/dist/components/NavMenu/components/NavMenuItem.d.ts.map +1 -1
  106. package/dist/components/NavMenu/components/NavMenuItem.js +84 -84
  107. package/dist/components/NavMenu/types.d.ts +4 -0
  108. package/dist/components/NavMenu/types.d.ts.map +1 -1
  109. package/dist/components/WorkspaceMenu/WorkspaceItem.d.ts.map +1 -1
  110. package/dist/components/WorkspaceMenu/WorkspaceItem.js +16 -14
  111. package/dist/config/envConfig.d.ts +2 -0
  112. package/dist/config/envConfig.d.ts.map +1 -1
  113. package/dist/config/envConfig.js +41 -37
  114. package/dist/helpers/showNotifications.d.ts +15 -0
  115. package/dist/helpers/showNotifications.d.ts.map +1 -1
  116. package/dist/helpers/showNotifications.js +114 -72
  117. package/dist/helpers/showNotifications.module.css.js +16 -4
  118. package/dist/hooks/useUiPref.d.ts +2 -0
  119. package/dist/hooks/useUiPref.d.ts.map +1 -0
  120. package/dist/hooks/useUiPref.js +80 -0
  121. package/dist/index.css +1 -1
  122. package/dist/index.d.ts +1 -0
  123. package/dist/index.d.ts.map +1 -1
  124. package/dist/index.js +550 -540
  125. package/dist/lang/locales/ui_en.json.js +1 -1
  126. package/dist/lang/locales/ui_es.json.js +1 -1
  127. package/dist/lang/locales/ui_ru.json.js +1 -1
  128. package/package.json +1 -1
@@ -1,33 +1,33 @@
1
1
  import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
2
  import { memo as v, useRef as I } from "react";
3
- import { useTranslation as C } from "react-i18next";
4
- import { Box as F, Tooltip as i, ActionIcon as t, Flex as s, Text as g } from "@mantine/core";
5
- import { IconDownload as p, IconMinus as N, IconPlus as R, IconX as k } from "@tabler/icons-react";
3
+ import { useTranslation as F } from "react-i18next";
4
+ import { Box as C, Tooltip as t, ActionIcon as i, Flex as s, Text as u } from "@mantine/core";
5
+ import { IconDownload as f, IconMinus as N, IconPlus as R, IconX as k } from "@tabler/icons-react";
6
6
  import { getFileIcons as T } from "../../../helpers/getFileIcons.js";
7
- import { getFileType as j } from "../../../helpers/getFileType.js";
8
- import { useAttachmentsGalleryContext as D } from "../AttachmentsGalleryContext.js";
9
- import { zoomStep as f } from "../helpers.js";
7
+ import { getFileType as Z } from "../../../helpers/getFileType.js";
8
+ import { useAttachmentsGalleryContext as j } from "../AttachmentsGalleryContext.js";
9
+ import { getAttachmentFormat as D, zoomStep as p } from "../helpers.js";
10
10
  import { useDownloadFile as M } from "../hooks/useDownloadFile.js";
11
- import { useZoomReset as Z } from "../hooks/useZoomReset.js";
11
+ import { useZoomReset as O } from "../hooks/useZoomReset.js";
12
12
  import n from "../styles.module.css.js";
13
- const L = v(
13
+ const U = v(
14
14
  ({ onClose: w, attachments: z }) => {
15
- Z();
16
- const { t: r } = C("ui"), c = I(null), { zoomPercentage: y, transformRefs: m, selectedIndex: a } = D(), o = z?.[a], x = () => {
17
- f({
15
+ O();
16
+ const { t: r } = F("ui"), c = I(null), { zoomPercentage: y, transformRefs: m, selectedIndex: a } = j(), o = z?.[a], b = () => {
17
+ p({
18
18
  animationRef: c,
19
19
  dir: "in",
20
20
  activeRef: m.current[a]
21
21
  });
22
- }, b = () => {
23
- f({
22
+ }, x = () => {
23
+ p({
24
24
  animationRef: c,
25
25
  dir: "out",
26
26
  activeRef: m.current[a]
27
27
  });
28
- }, { isVideo: A, isFetching: d, onDownload: u, isMobile: h } = M(o);
28
+ }, { isFetching: d, onDownload: g, isMobile: h } = M(o), A = o ? D(o).isImage : !1;
29
29
  return /* @__PURE__ */ l(
30
- F,
30
+ C,
31
31
  {
32
32
  style: {
33
33
  borderRadius: 8,
@@ -41,19 +41,19 @@ const L = v(
41
41
  py: 8,
42
42
  bg: "var(--mantine-color-dark-6)",
43
43
  children: [
44
- h ? /* @__PURE__ */ e(i, { withArrow: !0, label: r("gallery.download"), children: /* @__PURE__ */ e(
45
- t,
44
+ h ? /* @__PURE__ */ e(t, { withArrow: !0, label: r("gallery.download"), children: /* @__PURE__ */ e(
45
+ i,
46
46
  {
47
47
  className: n.headerAction,
48
48
  size: "lg",
49
49
  variant: "subtle",
50
50
  loading: d,
51
- onClick: u,
52
- children: /* @__PURE__ */ e(p, { size: 20 })
51
+ onClick: g,
52
+ children: /* @__PURE__ */ e(f, { size: 20 })
53
53
  }
54
54
  ) }) : /* @__PURE__ */ l(s, { align: "center", gap: 8, ml: 6, miw: 0, children: [
55
55
  o ? T(
56
- j(
56
+ Z(
57
57
  o.contentType ?? "",
58
58
  !1,
59
59
  o.originalFileName
@@ -61,21 +61,21 @@ const L = v(
61
61
  !1,
62
62
  20
63
63
  ) : null,
64
- /* @__PURE__ */ e(g, { fw: 500, fz: 14, c: "var(--app-gallary-text)", truncate: !0, children: o?.originalFileName || "" })
64
+ /* @__PURE__ */ e(u, { fw: 500, fz: 14, c: "var(--app-gallary-text)", truncate: !0, children: o?.originalFileName || "" })
65
65
  ] }),
66
- A ? /* @__PURE__ */ e("div", {}) : /* @__PURE__ */ l(s, { gap: "xs", children: [
67
- /* @__PURE__ */ e(i, { withArrow: !0, label: r("gallery.zoomOut"), children: /* @__PURE__ */ e(
68
- t,
66
+ A ? /* @__PURE__ */ l(s, { gap: "xs", children: [
67
+ /* @__PURE__ */ e(t, { withArrow: !0, label: r("gallery.zoomOut"), children: /* @__PURE__ */ e(
68
+ i,
69
69
  {
70
70
  className: n.headerAction,
71
71
  size: "lg",
72
72
  variant: "subtle",
73
- onClick: b,
73
+ onClick: x,
74
74
  children: /* @__PURE__ */ e(N, { size: 20 })
75
75
  }
76
76
  ) }),
77
77
  /* @__PURE__ */ l(
78
- g,
78
+ u,
79
79
  {
80
80
  fw: 500,
81
81
  fz: 14,
@@ -88,31 +88,31 @@ const L = v(
88
88
  ]
89
89
  }
90
90
  ),
91
- /* @__PURE__ */ e(i, { withArrow: !0, label: r("gallery.zoomIn"), children: /* @__PURE__ */ e(
92
- t,
91
+ /* @__PURE__ */ e(t, { withArrow: !0, label: r("gallery.zoomIn"), children: /* @__PURE__ */ e(
92
+ i,
93
93
  {
94
94
  className: n.headerAction,
95
95
  size: "lg",
96
96
  variant: "subtle",
97
- onClick: x,
97
+ onClick: b,
98
98
  children: /* @__PURE__ */ e(R, { size: 20 })
99
99
  }
100
100
  ) })
101
- ] }),
101
+ ] }) : /* @__PURE__ */ e("div", {}),
102
102
  /* @__PURE__ */ l(s, { justify: "end", gap: "xs", children: [
103
- !h && /* @__PURE__ */ e(i, { withArrow: !0, label: r("gallery.download"), children: /* @__PURE__ */ e(
104
- t,
103
+ !h && /* @__PURE__ */ e(t, { withArrow: !0, label: r("gallery.download"), children: /* @__PURE__ */ e(
104
+ i,
105
105
  {
106
106
  className: n.headerAction,
107
107
  size: "lg",
108
108
  variant: "subtle",
109
109
  loading: d,
110
- onClick: u,
111
- children: /* @__PURE__ */ e(p, { size: 20 })
110
+ onClick: g,
111
+ children: /* @__PURE__ */ e(f, { size: 20 })
112
112
  }
113
113
  ) }),
114
- /* @__PURE__ */ e(i, { withArrow: !0, label: r("gallery.close"), children: /* @__PURE__ */ e(
115
- t,
114
+ /* @__PURE__ */ e(t, { withArrow: !0, label: r("gallery.close"), children: /* @__PURE__ */ e(
115
+ i,
116
116
  {
117
117
  className: n.headerAction,
118
118
  size: "lg",
@@ -128,5 +128,5 @@ const L = v(
128
128
  }
129
129
  );
130
130
  export {
131
- L as ModalHeader
131
+ U as ModalHeader
132
132
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useShakePlayer.d.ts","sourceRoot":"","sources":["../../../../../src/components/AttachmentsGalleryModal/components/ShakePlayer/useShakePlayer.tsx"],"names":[],"mappings":"AA4CA,eAAO,MAAM,cAAc,GAAI,uCAI5B;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;CA+KA,CAAC"}
1
+ {"version":3,"file":"useShakePlayer.d.ts","sourceRoot":"","sources":["../../../../../src/components/AttachmentsGalleryModal/components/ShakePlayer/useShakePlayer.tsx"],"names":[],"mappings":"AAkDA,eAAO,MAAM,cAAc,GAAI,uCAI5B;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;CAqLA,CAAC"}
@@ -1,101 +1,107 @@
1
- import { useState as U, useRef as i, useCallback as A, useEffect as E } from "react";
2
- import { getEnvConfig as k } from "../../../../config/envConfig.js";
3
- const m = () => {
4
- const r = k().apiBaseUrl || "";
5
- return r.endsWith("/") ? r.slice(0, -1) : r;
6
- }, T = async (r) => {
7
- const u = m();
8
- return (await fetch(`${u}/v1/auth/refresh`, {
1
+ import { useState as R, useRef as f, useCallback as A, useEffect as C } from "react";
2
+ import { getEnvConfig as S } from "../../../../config/envConfig.js";
3
+ const U = () => {
4
+ const e = S().apiBaseUrl || "";
5
+ return e.endsWith("/") ? e.slice(0, -1) : e;
6
+ }, E = async (e) => {
7
+ const s = U();
8
+ return (await fetch(`${s}/v1/auth/refresh`, {
9
9
  method: "POST",
10
10
  credentials: "include",
11
- signal: r
11
+ signal: e
12
12
  })).ok;
13
- }, $ = async (r, u) => {
14
- const s = await fetch(r, {
15
- ...u,
13
+ }, $ = async (e, s) => {
14
+ const l = await fetch(e, {
15
+ ...s,
16
16
  credentials: "include"
17
17
  });
18
- return s.status !== 401 && s.status !== 403 || !await T(u.signal) || u.signal.aborted ? s : fetch(r, {
19
- ...u,
18
+ return l.status !== 401 && l.status !== 403 || !await E(s.signal) || s.signal.aborted ? l : fetch(e, {
19
+ ...s,
20
20
  credentials: "include"
21
21
  });
22
- }, V = ({
23
- attachmentId: r,
24
- isActive: u,
25
- autoPlay: s
22
+ }, q = () => !!window.layersDesktop || (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") && window.location.port !== "3000", V = ({
23
+ attachmentId: e,
24
+ isActive: s,
25
+ autoPlay: l
26
26
  }) => {
27
- const [f, h] = U(null), [b, p] = U(null), [v, w] = U(!1), R = i(null), c = i(!0), o = i(null), t = i(null), l = i(null), d = A(
28
- (e) => {
29
- if (!r || l.current || !c.current || e.aborted) return;
30
- const g = m() || window.location.origin, a = new URL(
31
- `/v1/attachments/${r}`,
32
- g
27
+ const [w, g] = R(null), [b, p] = R(null), [T, d] = R(!1), m = f(null), c = f(!0), o = f(null), t = f(null), u = f(null), a = A(
28
+ (r) => {
29
+ if (!e || u.current || !c.current || r.aborted) return;
30
+ const h = U() || window.location.origin, i = new URL(
31
+ `/v1/attachments/${e}`,
32
+ h
33
33
  ).toString();
34
- l.current = a, h(null), p(a);
34
+ u.current = i, g(null), p(i);
35
35
  },
36
- [r]
37
- ), C = A(async () => {
38
- if (!r || l.current) return;
36
+ [e]
37
+ ), k = A(async () => {
38
+ if (!e || u.current) return;
39
39
  o.current && (clearTimeout(o.current), o.current = null), t.current && t.current.abort();
40
- const e = new AbortController();
41
- t.current = e, w(!1);
40
+ const r = new AbortController();
41
+ t.current = r, d(!1);
42
42
  try {
43
- await T(e.signal), d(e.signal);
43
+ await E(r.signal), a(r.signal);
44
44
  } catch (n) {
45
- if (n instanceof Error && n.name === "AbortError" || !c.current || e.signal.aborted) return;
46
- w(!0);
45
+ if (n instanceof Error && n.name === "AbortError" || !c.current || r.signal.aborted) return;
46
+ d(!0);
47
47
  }
48
- }, [r, d]), y = async () => {
49
- if (!r)
48
+ }, [e, a]), y = async () => {
49
+ if (!e)
50
50
  return;
51
51
  t.current && t.current.abort();
52
- const e = new AbortController();
53
- t.current = e;
52
+ const r = new AbortController();
53
+ t.current = r;
54
54
  try {
55
- const n = m(), g = await $(
56
- `${n}/v1/attachments/${r}/vod`,
55
+ const n = U(), h = await $(
56
+ `${n}/v1/attachments/${e}/vod`,
57
57
  {
58
58
  method: "GET",
59
59
  headers: {
60
60
  Accept: "*/*"
61
61
  },
62
- signal: e.signal
62
+ signal: r.signal
63
63
  }
64
64
  );
65
- if (!g.ok) {
66
- await d(e.signal);
65
+ if (!h.ok) {
66
+ await a(r.signal);
67
67
  return;
68
68
  }
69
- const a = await g.json();
70
- if (!c.current || e.signal.aborted) return;
71
- const B = n || window.location.origin;
72
- if (a.ready) {
73
- const S = new URL(a.url, B).toString();
74
- if (l.current) return;
75
- p(null), h(S);
69
+ const i = await h.json();
70
+ if (!c.current || r.signal.aborted) return;
71
+ const v = n || window.location.origin;
72
+ if (i.ready) {
73
+ const B = new URL(i.url, v).toString();
74
+ if (u.current) return;
75
+ p(null), g(B);
76
76
  } else
77
- d(e.signal), o.current = setTimeout(() => {
77
+ a(r.signal), o.current = setTimeout(() => {
78
78
  y();
79
79
  }, 3e3);
80
80
  } catch (n) {
81
- if (n instanceof Error && n.name === "AbortError" || !c.current || e.signal.aborted) return;
82
- w(!0);
81
+ if (n instanceof Error && n.name === "AbortError" || !c.current || r.signal.aborted) return;
82
+ d(!0);
83
83
  }
84
84
  };
85
- return E(() => {
86
- if (c.current = !0, h(null), p(null), w(!1), l.current = null, o.current && (clearTimeout(o.current), o.current = null), t.current && (t.current.abort(), t.current = null), !!r)
87
- return y(), () => {
88
- c.current = !1, o.current && (clearTimeout(o.current), o.current = null), t.current && (t.current.abort(), t.current = null), l.current = null;
85
+ return C(() => {
86
+ if (c.current = !0, g(null), p(null), d(!1), u.current = null, o.current && (clearTimeout(o.current), o.current = null), t.current && (t.current.abort(), t.current = null), !!e) {
87
+ if (q()) {
88
+ const r = new AbortController();
89
+ t.current = r, a(r.signal);
90
+ } else
91
+ y();
92
+ return () => {
93
+ c.current = !1, o.current && (clearTimeout(o.current), o.current = null), t.current && (t.current.abort(), t.current = null), u.current = null;
89
94
  };
90
- }, [r]), E(() => {
91
- if (!f && !b || !R.current) return;
92
- const e = R.current.querySelector(
95
+ }
96
+ }, [e]), C(() => {
97
+ if (!w && !b || !m.current) return;
98
+ const r = m.current.querySelector(
93
99
  "video"
94
100
  );
95
- e && (u ? s !== !1 && e.play().catch((n) => {
101
+ r && (s ? l !== !1 && r.play().catch((n) => {
96
102
  console.error("Ошибка при воспроизведении видео:", n);
97
- }) : e.pause());
98
- }, [u, f, b, s]), { containerRef: R, fallbackToRawAttachment: C, isError: v, vodUrl: f, rawUrl: b };
103
+ }) : r.pause());
104
+ }, [s, w, b, l]), { containerRef: m, fallbackToRawAttachment: k, isError: T, vodUrl: w, rawUrl: b };
99
105
  };
100
106
  export {
101
107
  V as useShakePlayer
@@ -1,5 +1,13 @@
1
1
  import { MutableRefObject } from 'react';
2
2
  import { ReactZoomPanPinchContentRef } from 'react-zoom-pan-pinch';
3
+ import { IFileResponse } from '../../types/files';
4
+ export declare const getAttachmentFormat: (attachment: Pick<IFileResponse, "contentType" | "originalFileName">) => {
5
+ isVideo: boolean;
6
+ isPdf: boolean;
7
+ isImage: boolean;
8
+ isAudio: boolean;
9
+ isSupported: boolean;
10
+ };
3
11
  export declare const animateTransform: ({ instance, from, to, duration, animationRef, }: {
4
12
  instance: ReactZoomPanPinchContentRef["instance"];
5
13
  from: {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentsGalleryModal/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAInE,eAAO,MAAM,gBAAgB,GAAI,iDAM9B;IACD,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAClD,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC/C,SAuBA,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,mCAItB;IACD,GAAG,EAAE,IAAI,GAAG,KAAK,CAAC;IAClB,SAAS,EAAE,2BAA2B,CAAC;IACvC,YAAY,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC/C,SA2BA,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentsGalleryModal/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,mBAAmB,GAC9B,YAAY,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,kBAAkB,CAAC;;;;;;CAkBpE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,iDAM9B;IACD,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAClD,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC/C,SAuBA,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,mCAItB;IACD,GAAG,EAAE,IAAI,GAAG,KAAK,CAAC;IAClB,SAAS,EAAE,2BAA2B,CAAC;IACvC,YAAY,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC/C,SA2BA,CAAC"}
@@ -1,40 +1,45 @@
1
- import { STEPS as h } from "./constants.js";
2
- const y = ({
3
- instance: r,
1
+ import { isVideoFile as w } from "../../helpers/fileUtils.js";
2
+ import { STEPS as l } from "./constants.js";
3
+ const T = (i) => {
4
+ const t = (i.contentType || "").toLowerCase(), e = i.originalFileName || "", s = w(i.contentType, e), n = t === "application/pdf" || e.toLowerCase().endsWith(".pdf"), o = t.startsWith("image/") || /\.(jpe?g|png|gif|webp|bmp|svg|avif|heic|heif|tiff?|ico)$/i.test(e), c = t.startsWith("audio/") || /\.(mp3|wav|ogg|flac|m4a|aac|opus|weba)$/i.test(e);
5
+ return { isVideo: s, isPdf: n, isImage: o, isAudio: c, isSupported: o || s || n || c };
6
+ }, y = ({
7
+ instance: i,
4
8
  from: t,
5
9
  to: e,
6
10
  duration: s = 200,
7
11
  animationRef: n
8
12
  }) => {
9
13
  n.current && cancelAnimationFrame(n.current);
10
- const c = performance.now(), a = (p) => {
11
- const i = Math.min((p - c) / s, 1), o = 1 - Math.pow(1 - i, 3), x = t.scale + (e.scale - t.scale) * o, l = t.x + (e.x - t.x) * o, m = t.y + (e.y - t.y) * o;
12
- r.setTransformState(x, l, m), i < 1 && (n.current = requestAnimationFrame(a));
14
+ const o = performance.now(), c = (r) => {
15
+ const p = Math.min((r - o) / s, 1), a = 1 - Math.pow(1 - p, 3), m = t.scale + (e.scale - t.scale) * a, f = t.x + (e.x - t.x) * a, d = t.y + (e.y - t.y) * a;
16
+ i.setTransformState(m, f, d), p < 1 && (n.current = requestAnimationFrame(c));
13
17
  };
14
- n.current = requestAnimationFrame(a);
15
- }, I = ({
16
- dir: r,
18
+ n.current = requestAnimationFrame(c);
19
+ }, A = ({
20
+ dir: i,
17
21
  activeRef: t,
18
22
  animationRef: e
19
23
  }) => {
20
24
  const s = t?.instance;
21
25
  if (!s) return;
22
- const { scale: n, positionX: c, positionY: a } = s.transformState, p = s.wrapperComponent?.getBoundingClientRect(), i = (p?.width ?? 0) / 2, o = (p?.height ?? 0) / 2, x = S(n), l = r === "in" ? x + 1 : x - 1, m = Math.min(Math.max(l, 0), h.length - 1), u = h[m], d = u / n, f = i - (i - c) * d, w = o - (o - a) * d;
26
+ const { scale: n, positionX: o, positionY: c } = s.transformState, r = s.wrapperComponent?.getBoundingClientRect(), p = (r?.width ?? 0) / 2, a = (r?.height ?? 0) / 2, m = S(n), f = i === "in" ? m + 1 : m - 1, d = Math.min(Math.max(f, 0), l.length - 1), g = l[d], u = g / n, h = p - (p - o) * u, x = a - (a - c) * u;
23
27
  y({
24
28
  instance: s,
25
- from: { scale: n, x: c, y: a },
26
- to: { scale: u, x: f, y: w },
29
+ from: { scale: n, x: o, y: c },
30
+ to: { scale: g, x: h, y: x },
27
31
  duration: 200,
28
32
  animationRef: e
29
33
  });
30
- }, S = (r) => {
34
+ }, S = (i) => {
31
35
  let t = 0, e = 1 / 0;
32
- return h.forEach((s, n) => {
33
- const c = Math.abs(s - r);
34
- c < e && (e = c, t = n);
36
+ return l.forEach((s, n) => {
37
+ const o = Math.abs(s - i);
38
+ o < e && (e = o, t = n);
35
39
  }), t;
36
40
  };
37
41
  export {
38
42
  y as animateTransform,
39
- I as zoomStep
43
+ T as getAttachmentFormat,
44
+ A as zoomStep
40
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDownloadFile.d.ts","sourceRoot":"","sources":["../../../../src/components/AttachmentsGalleryModal/hooks/useDownloadFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkC,MAAM,OAAO,CAAC;AAQvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,eAAe,GAAI,eAAe,aAAa;;;oBAI9C,cAAc;;CA8C3B,CAAC"}
1
+ {"version":3,"file":"useDownloadFile.d.ts","sourceRoot":"","sources":["../../../../src/components/AttachmentsGalleryModal/hooks/useDownloadFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkC,MAAM,OAAO,CAAC;AAQvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,eAAe,GAAI,eAAe,aAAa;;;oBAI9C,cAAc;;CAgD3B,CAAC"}
@@ -1,35 +1,38 @@
1
- import { useState as w, useCallback as u, useMemo as p } from "react";
2
- import { downloadImageFromExternalUrl as m, downloadURL as c } from "../../../helpers/download.js";
3
- import { isVideoFile as b } from "../../../helpers/fileUtils.js";
4
- import { useMenu as F } from "../../../hooks/useMenu.js";
5
- const L = (o) => {
6
- const [l, e] = w(!1), n = u(
7
- async (a) => {
8
- if (a.stopPropagation(), !!o)
9
- if (e(!0), o?.Url)
10
- await m(o?.Url, "file"), e(!1);
11
- else {
12
- const i = await fetch(`/v1/attachments/${o.id}`, {
13
- method: "GET"
14
- });
15
- if (!i.ok)
16
- throw e(!1), new Error(`Error loading: ${i.statusText}`);
17
- const d = await i.blob();
18
- e(!1);
19
- const s = window.URL.createObjectURL(d);
20
- s && o && (o.id ? c(s, o.originalFileName || "file") : m(s, "file"));
21
- }
1
+ import { useState as u, useCallback as c, useMemo as p } from "react";
2
+ import { downloadImageFromExternalUrl as a, downloadURL as b } from "../../../helpers/download.js";
3
+ import { isVideoFile as F } from "../../../helpers/fileUtils.js";
4
+ import { useMenu as U } from "../../../hooks/useMenu.js";
5
+ const M = (o) => {
6
+ const [l, e] = u(!1), r = c(
7
+ async (d) => {
8
+ if (d.stopPropagation(), !o)
9
+ return;
10
+ e(!0);
11
+ const i = o.originalFileName || "file";
12
+ if (o?.Url)
13
+ await a(o?.Url, i), e(!1);
14
+ else {
15
+ const s = await fetch(`/v1/attachments/${o.id}`, {
16
+ method: "GET"
17
+ });
18
+ if (!s.ok)
19
+ throw e(!1), new Error(`Error loading: ${s.statusText}`);
20
+ const w = await s.blob();
21
+ e(!1);
22
+ const n = window.URL.createObjectURL(w);
23
+ n && o && (o.id ? b(n, i) : a(n, i));
24
+ }
22
25
  },
23
26
  [o]
24
- ), { isMobile: r } = F(), f = b(
27
+ ), { isMobile: f } = U(), m = F(
25
28
  o?.contentType,
26
29
  o?.originalFileName
27
30
  );
28
31
  return p(
29
- () => ({ isVideo: f, isMobile: r, onDownload: n, isFetching: l }),
30
- [r, f, n, l]
32
+ () => ({ isVideo: m, isMobile: f, onDownload: r, isFetching: l }),
33
+ [f, m, r, l]
31
34
  );
32
35
  };
33
36
  export {
34
- L as useDownloadFile
37
+ M as useDownloadFile
35
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useGetPreviewUrl.d.ts","sourceRoot":"","sources":["../../../../src/components/AttachmentsGalleryModal/hooks/useGetPreviewUrl.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAOrD,eAAO,MAAM,gBAAgB,GAAI,YAAY,aAAa;;;;;;;;;;CA4GzD,CAAC"}
1
+ {"version":3,"file":"useGetPreviewUrl.d.ts","sourceRoot":"","sources":["../../../../src/components/AttachmentsGalleryModal/hooks/useGetPreviewUrl.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQrD,eAAO,MAAM,gBAAgB,GAAI,YAAY,aAAa;;;;;;;;;;CA0FzD,CAAC"}
@@ -1,20 +1,20 @@
1
- import { useState as p, useEffect as F, useMemo as T } from "react";
2
- import { getEnvConfig as L } from "../../../config/envConfig.js";
3
- import { isVideoFile as v } from "../../../helpers/fileUtils.js";
4
- const h = () => {
5
- const e = L().apiBaseUrl || "";
1
+ import { useState as f, useEffect as A, useMemo as v } from "react";
2
+ import { getEnvConfig as F } from "../../../config/envConfig.js";
3
+ import { getAttachmentFormat as $ } from "../helpers.js";
4
+ const m = () => {
5
+ const e = F().apiBaseUrl || "";
6
6
  return e.endsWith("/") ? e.slice(0, -1) : e;
7
- }, B = (e) => {
8
- const [u, y] = p(null), [d, n] = p(!1), [w, a] = p(!1);
9
- async function g(i) {
10
- return fetch(`${h()}/v1/attachments/${i}`, {
7
+ }, S = (e) => {
8
+ const [l, g] = f(null), [u, n] = f(!1), [d, a] = f(!1);
9
+ async function p(r) {
10
+ return fetch(`${m()}/v1/attachments/${r}`, {
11
11
  method: "GET",
12
12
  credentials: "include"
13
13
  });
14
14
  }
15
- async function m() {
15
+ async function U() {
16
16
  try {
17
- return (await fetch(`${h()}/v1/auth/refresh`, {
17
+ return (await fetch(`${m()}/v1/auth/refresh`, {
18
18
  method: "POST",
19
19
  credentials: "include"
20
20
  })).ok;
@@ -22,46 +22,41 @@ const h = () => {
22
22
  return !1;
23
23
  }
24
24
  }
25
- async function U(i, b) {
25
+ async function E(r, b) {
26
26
  n(!0);
27
- let s = await g(i);
28
- if ((s.status === 401 || s.status === 403) && await m() && (s = await g(i)), !s.ok)
29
- throw n(!1), a(!0), new Error(`Error loading: ${s.statusText}`);
30
- const f = await s.blob(), E = b && f.type !== "application/pdf" ? new Blob([f], { type: "application/pdf" }) : f;
31
- y(window.URL.createObjectURL(E)), n(!1), a(!1);
27
+ let t = await p(r);
28
+ if ((t.status === 401 || t.status === 403) && await U() && (t = await p(r)), !t.ok)
29
+ throw n(!1), a(!0), new Error(`Error loading: ${t.statusText}`);
30
+ const c = await t.blob(), y = b && c.type !== "application/pdf" ? new Blob([c], { type: "application/pdf" }) : c;
31
+ g(window.URL.createObjectURL(y)), n(!1), a(!1);
32
32
  }
33
- const t = v(
34
- e.contentType,
35
- e.originalFileName
36
- ), o = (e.contentType || "").toLowerCase() === "application/pdf" || (e.originalFileName || "").toLowerCase().endsWith(".pdf"), c = (e.contentType || "").toLowerCase().startsWith("image/"), l = (e.contentType || "").toLowerCase().startsWith("audio/") || /\.(mp3|wav|ogg|flac|m4a|aac|opus|weba)$/i.test(
37
- e.originalFileName || ""
38
- ), r = c || t || o || l;
39
- return F(() => {
40
- e.id && !t && r && !e.Url && U(e.id, o);
41
- }, [e.Url, e.id, t, o, r]), T(
33
+ const { isVideo: s, isPdf: i, isImage: h, isAudio: w, isSupported: o } = $(e);
34
+ return A(() => {
35
+ e.id && !s && o && !e.Url && E(e.id, i);
36
+ }, [e.Url, e.id, s, i, o]), v(
42
37
  () => ({
43
- fileUrl: u,
44
- isFetching: d,
45
- isError: w,
38
+ fileUrl: l,
39
+ isFetching: u,
40
+ isError: d,
46
41
  setIsError: a,
47
- isVideo: t,
48
- isPdf: o,
49
- isImage: c,
50
- isAudio: l,
51
- isSupported: r
42
+ isVideo: s,
43
+ isPdf: i,
44
+ isImage: h,
45
+ isAudio: w,
46
+ isSupported: o
52
47
  }),
53
48
  [
49
+ l,
50
+ d,
54
51
  u,
52
+ s,
53
+ i,
54
+ h,
55
55
  w,
56
- d,
57
- t,
58
- o,
59
- c,
60
- l,
61
- r
56
+ o
62
57
  ]
63
58
  );
64
59
  };
65
60
  export {
66
- B as useGetPreviewUrl
61
+ S as useGetPreviewUrl
67
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentsPreview.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentsPreview/AttachmentsPreview.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAIhE,UAAU,8BAA8B;IACtC,KAAK,EAAE,oBAAoB,CAAC,cAAc,EAAE,CAAC;IAC7C,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,kBAAkB,GAAI,8CAKhC,8BAA8B,mDAmNhC,CAAC"}
1
+ {"version":3,"file":"AttachmentsPreview.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentsPreview/AttachmentsPreview.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAOhE,UAAU,8BAA8B;IACtC,KAAK,EAAE,oBAAoB,CAAC,cAAc,EAAE,CAAC;IAC7C,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,kBAAkB,GAAI,8CAKhC,8BAA8B,mDA4QhC,CAAC"}